From 7b41729c90c1ba0bdf7ea2e93f90e2a4ae534d4b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 00:30:20 +0000 Subject: [PATCH 1/6] Initial plan From 23e408e65556dbb5e18c7ad78219557295147f2f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 00:33:30 +0000 Subject: [PATCH 2/6] feat(document-ai): add id card, business card and license recognize APIs --- src/module/DocumentAI/index.ts | 42 +++++++++++++++++++++++ src/module/DocumentAI/type.ts | 61 ++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) diff --git a/src/module/DocumentAI/index.ts b/src/module/DocumentAI/index.ts index b4ba4c0..a9fbe08 100644 --- a/src/module/DocumentAI/index.ts +++ b/src/module/DocumentAI/index.ts @@ -4,7 +4,10 @@ import { BaseModel, RESTClient, toggle } from 'mobx-restful'; import { LarkData } from '../../type'; import { BankCardEntity, + BusinessCard, + BusinessLicense, Contract, + IDCard, Resume, TaxiInvoice, TrainInvoice, @@ -95,6 +98,45 @@ export abstract class DocumentAIModel extends BaseModel { return body!.data!.bank_card.entities; } + /** + * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/id_card/recognize} + */ + @toggle('uploading') + async recognizeIDCard(file: File) { + const { body } = await this.client.post>( + `${this.baseURI}/id_card/recognize`, + makeFormData({ file }) + ); + + return body!.data!.id_card; + } + + /** + * @see {@link https://open.feishu.cn/document/server-docs/ai/document_ai-v1/business_card/recognize} + */ + @toggle('uploading') + async recognizeBusinessCard(file: File) { + const { body } = await this.client.post>( + `${this.baseURI}/business_card/recognize`, + makeFormData({ file }) + ); + + return body!.data!.business_cards; + } + + /** + * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/business_license/recognize} + */ + @toggle('uploading') + async recognizeBusinessLicense(file: File) { + const { body } = await this.client.post>( + `${this.baseURI}/business_license/recognize`, + makeFormData({ file }) + ); + + return body!.data!.business_license; + } + /** * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/resume/parse} */ diff --git a/src/module/DocumentAI/type.ts b/src/module/DocumentAI/type.ts index 8248ead..f95ea51 100644 --- a/src/module/DocumentAI/type.ts +++ b/src/module/DocumentAI/type.ts @@ -75,6 +75,67 @@ export interface BankCardEntity { value: string; } +export interface IDCardEntity { + type: + | 'identity_code' + | 'identity_name' + | 'address' + | 'valid_date_start' + | 'valid_date_end' + | 'gender' + | 'race' + | 'issued_by' + | 'birth'; + value: string; +} + +export interface IDCard { + entities: IDCardEntity[]; + side: 0 | 1; + conners: number[]; +} + +export interface BusinessCardEntity { + type: + | 'contact_names' + | 'company_names' + | 'departments' + | 'job_titles' + | 'emails' + | 'websites' + | 'addresses' + | 'mobile_phones' + | 'work_phones' + | 'other_phones' + | 'faxes'; + value: string; +} + +export interface BusinessCard { + entities: BusinessCardEntity[]; +} + +export interface BusinessLicenseEntity { + type: + | 'certificate_type' + | 'unified_social_credit_code' + | 'company_name' + | 'company_type' + | 'domicile' + | 'legal_representative' + | 'registered_capital' + | 'established_time' + | 'established_date' + | 'business_scope' + | 'website' + | 'approval_date'; + value: string; +} + +export interface BusinessLicense { + entities: BusinessLicenseEntity[]; +} + export type ResumePeriod = Record<`${'start' | 'end'}_${'date' | 'time'}`, string>; export enum EducationQualification { From 1a1e3fb64f1d4a7de8c9ba03e24b1a835569ac67 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 00:34:31 +0000 Subject: [PATCH 3/6] fix(document-ai): support both conners and corners id card coords --- src/module/DocumentAI/type.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/module/DocumentAI/type.ts b/src/module/DocumentAI/type.ts index f95ea51..7046b10 100644 --- a/src/module/DocumentAI/type.ts +++ b/src/module/DocumentAI/type.ts @@ -93,6 +93,7 @@ export interface IDCard { entities: IDCardEntity[]; side: 0 | 1; conners: number[]; + corners?: number[]; } export interface BusinessCardEntity { From 63994b1e0bca71a819559992e1e1c233e01e230b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 00:35:44 +0000 Subject: [PATCH 4/6] refactor(document-ai): normalize id card corners field --- src/module/DocumentAI/index.ts | 13 ++++++++----- src/module/DocumentAI/type.ts | 3 +-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/module/DocumentAI/index.ts b/src/module/DocumentAI/index.ts index a9fbe08..5351c08 100644 --- a/src/module/DocumentAI/index.ts +++ b/src/module/DocumentAI/index.ts @@ -103,12 +103,15 @@ export abstract class DocumentAIModel extends BaseModel { */ @toggle('uploading') async recognizeIDCard(file: File) { - const { body } = await this.client.post>( - `${this.baseURI}/id_card/recognize`, - makeFormData({ file }) - ); + const { body } = await this.client.post< + LarkData<{ + id_card: Omit & { corners?: number[]; conners?: number[] }; + }> + >(`${this.baseURI}/id_card/recognize`, makeFormData({ file })); + + const { conners, ...idCard } = body!.data!.id_card; - return body!.data!.id_card; + return { ...idCard, corners: idCard.corners || conners || [] }; } /** diff --git a/src/module/DocumentAI/type.ts b/src/module/DocumentAI/type.ts index 7046b10..c9314c8 100644 --- a/src/module/DocumentAI/type.ts +++ b/src/module/DocumentAI/type.ts @@ -92,8 +92,7 @@ export interface IDCardEntity { export interface IDCard { entities: IDCardEntity[]; side: 0 | 1; - conners: number[]; - corners?: number[]; + corners: number[]; } export interface BusinessCardEntity { From 972183ac870eea6756c15d6ab11157dfbccc9893 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 00:36:43 +0000 Subject: [PATCH 5/6] docs(types): clarify business license date fields --- src/module/DocumentAI/type.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/module/DocumentAI/type.ts b/src/module/DocumentAI/type.ts index c9314c8..599e503 100644 --- a/src/module/DocumentAI/type.ts +++ b/src/module/DocumentAI/type.ts @@ -124,8 +124,8 @@ export interface BusinessLicenseEntity { | 'domicile' | 'legal_representative' | 'registered_capital' - | 'established_time' - | 'established_date' + | 'established_time' // 成立日期 + | 'established_date' // 营业期限 | 'business_scope' | 'website' | 'approval_date'; From 7df84c37e71a9acbc1464ec6848d403c3e3c1ac2 Mon Sep 17 00:00:00 2001 From: TechQuery Date: Thu, 25 Jun 2026 05:15:22 +0800 Subject: [PATCH 6/6] [optimize] simplify Copilot codes --- package.json | 4 +- pnpm-lock.yaml | 178 ++++++++++++++++----------------- src/module/DocumentAI/index.ts | 16 ++- src/module/DocumentAI/type.ts | 34 +++---- 4 files changed, 114 insertions(+), 118 deletions(-) diff --git a/package.json b/package.json index 71d020f..a5fcfbb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mobx-lark", - "version": "2.9.0", + "version": "2.10.0", "license": "LGPL-3.0", "author": "shiy2008@gmail.com", "description": "Unofficial TypeScript SDK for FeiShu/Lark API, which is based on MobX-RESTful.", @@ -48,7 +48,7 @@ "dotenv": "^17.4.2", "fs-extra": "^11.3.5", "husky": "^9.1.7", - "lint-staged": "^17.0.7", + "lint-staged": "^17.0.8", "parcel": "~2.16.4", "prettier": "^3.8.4", "react": "^19.2.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index af7269a..d159d71 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,8 +64,8 @@ importers: specifier: ^9.1.7 version: 9.1.7 lint-staged: - specifier: ^17.0.7 - version: 17.0.7 + specifier: ^17.0.8 + version: 17.0.8 parcel: specifier: ~2.16.4 version: 2.16.4(@swc/helpers@0.5.23) @@ -80,7 +80,7 @@ importers: version: 19.2.7(react@19.2.7) ts-node: specifier: ^10.9.2 - version: 10.9.2(@swc/core@1.15.41(@swc/helpers@0.5.23))(@types/node@24.13.2)(typescript@5.8.3) + version: 10.9.2(@swc/core@1.15.43(@swc/helpers@0.5.23))(@types/node@24.13.2)(typescript@5.8.3) turndown: specifier: ^7.2.4 version: 7.2.4 @@ -595,86 +595,86 @@ packages: '@shikijs/vscode-textmate@10.0.2': resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==} - '@swc/core-darwin-arm64@1.15.41': - resolution: {integrity: sha512-kREh6J5paQFvP3i7f/4FbqRNOJREutVFVOkder4GVyCBQ39YmER55cW/y1NNjwrchzFqgYswFn0mMDCqbqKzrw==} + '@swc/core-darwin-arm64@1.15.43': + resolution: {integrity: sha512-v1aVuvXdo/BHxJzco9V2xpHrvwWmhfS8t6gziY5wJxd+Z2h8AeJRnAwPD8itCDaGXVBwJ/CaKfxEzTkG0Va0OA==} engines: {node: '>=10'} cpu: [arm64] os: [darwin] - '@swc/core-darwin-x64@1.15.41': - resolution: {integrity: sha512-N8B56ESFazZAWZyIkecADSPCwlLEinW7QLMEeotCpv4J7VXwfH+OLkmRL8o96UZ+1355fwHxDTS6/wK7yucvkA==} + '@swc/core-darwin-x64@1.15.43': + resolution: {integrity: sha512-lp3d4Lamc8dt5huYdGLSR+9hLxmfr1jb0l+4XXG2zPqZwYWRN9R0U2qYoTrggiU2RWW0oV9VbWM3kBnqIc2kdQ==} engines: {node: '>=10'} cpu: [x64] os: [darwin] - '@swc/core-linux-arm-gnueabihf@1.15.41': - resolution: {integrity: sha512-6XrId2fyle0mS5xxON8rU84mPd2Cq1kDJRj+4BnQKTd7u+2kSA6Ww+JkOP0iTNqOqt9OXhPOEAjBHAuonWcdCg==} + '@swc/core-linux-arm-gnueabihf@1.15.43': + resolution: {integrity: sha512-JWTQQELtsG5GgphDrr/XqqmM2pDN3cZqbMS0Mrg+iTiXL3F74sn/S2IyYE/5u4h2KLkTf9qQ7dXyxsbx7YzkeA==} engines: {node: '>=10'} cpu: [arm] os: [linux] - '@swc/core-linux-arm64-gnu@1.15.41': - resolution: {integrity: sha512-ynLIarxlkVnqHn1D0fKOVht6mNU5ks6lrH+MY3kkS+XFaGGgDxFZVjWKJlkYTKm3RCvBTfA8Ng5fLufXheMRKQ==} + '@swc/core-linux-arm64-gnu@1.15.43': + resolution: {integrity: sha512-B4otJRdPWIsmiSBf0uG7Z/+vMWmkufjz5MmYxubwKuZazDW14Zd3symga1N62QR4RT+kEFeHEgsXfZGyn/w0hw==} engines: {node: '>=10'} cpu: [arm64] os: [linux] libc: [glibc] - '@swc/core-linux-arm64-musl@1.15.41': - resolution: {integrity: sha512-dXu/5vd4gh8symyhRF+4G7gOPkjmb4pONhh7sl+6GSiW0LOKZlfu5kXmyFbTz9smOT7jgr002qY9b1nujjXt2A==} + '@swc/core-linux-arm64-musl@1.15.43': + resolution: {integrity: sha512-6zB6OnpViBxYy4tgY3v2i6AZY9fwkcHZ032UOwtwUuW1d19sdT07qF0kZe6/3UR1tUaK6jjg2rmVcUIBCEYVjQ==} engines: {node: '>=10'} cpu: [arm64] os: [linux] libc: [musl] - '@swc/core-linux-ppc64-gnu@1.15.41': - resolution: {integrity: sha512-XGO6zVPXoPE0gf/XnI4jBbafNT13AYgoh6ns0JCSdOetI/kqVf0vhpz7NuNgAzZrMVCsmieqjPoTwViDgh4mOQ==} + '@swc/core-linux-ppc64-gnu@1.15.43': + resolution: {integrity: sha512-coxE1ZWdB3uSDVNoEtYNrRi/1epvckZx9cTJ8ICUxTMTxGk+yvQ/Twacp3ruZSaMPGCriUjP86C37VhaT6nyRg==} engines: {node: '>=10'} cpu: [ppc64] os: [linux] libc: [glibc] - '@swc/core-linux-s390x-gnu@1.15.41': - resolution: {integrity: sha512-0WUglRwyZtW+iMi7J3iFdrCxreZZIKf4egTwEQfIYRsqFax69A0OrFj+NIoFSE03xBT/IFRrg+S8K6f9Ky+4hA==} + '@swc/core-linux-s390x-gnu@1.15.43': + resolution: {integrity: sha512-lXfLhs+LpBsD5inuYx+YDH5WsPPBQ95KPUiy8P5wq9ob9xKDZFqwNfU2QW6bGO8NqRO/H9JQomTSt5Yyh+FGfA==} engines: {node: '>=10'} cpu: [s390x] os: [linux] libc: [glibc] - '@swc/core-linux-x64-gnu@1.15.41': - resolution: {integrity: sha512-VxkuQK59c0tHm6uJZCUrS3cyA2JhGGfdU6e41SZz0x/JS+4Sm7C1mIc97In14vkZJopEt7yXA2TouCqZDSygEA==} + '@swc/core-linux-x64-gnu@1.15.43': + resolution: {integrity: sha512-07XnKwTmKy8TGOZG3D9fRnLWGynxPjwQnZLVmBFbo6F+7vHYzBIOuwXEhemrChBWb6yDNZsVCcMWCPX6FDD2xg==} engines: {node: '>=10'} cpu: [x64] os: [linux] libc: [glibc] - '@swc/core-linux-x64-musl@1.15.41': - resolution: {integrity: sha512-/0qXIu1ZxggLuovLb22vFfKHq2AA4n6Whw5UwmVCHk4pkw7KWnPIQpMCEqUMPsNkFJig7PPp/TSYFu8ZEb2rtQ==} + '@swc/core-linux-x64-musl@1.15.43': + resolution: {integrity: sha512-TJc+bsSIaBh+hZvZ5GRtW/K1bw66TJ9vsUwvVIsZdiWxU5ObLwZvfcnZ3UpgVfMnFibRes9uriJrQNBHEEogRQ==} engines: {node: '>=10'} cpu: [x64] os: [linux] libc: [musl] - '@swc/core-win32-arm64-msvc@1.15.41': - resolution: {integrity: sha512-Y481sMNZM6rECh9VO4+y26N1lWEDAyxnBZskUf37fl90uHE946VHfmiVQWT0uMFOhyJJFovGTRuF4W82dwewUg==} + '@swc/core-win32-arm64-msvc@1.15.43': + resolution: {integrity: sha512-jfd7s2/bUQYkOHLs+LWQNKZdmDa8+sufKLllhpWAhVQ2GDCwsHe3vR/j+OSiItZNtkzFuaawa3+SAKz9y5gYfw==} engines: {node: '>=10'} cpu: [arm64] os: [win32] - '@swc/core-win32-ia32-msvc@1.15.41': - resolution: {integrity: sha512-BAchBD5qeUzy3hiPSLJtaaoSm4blCLyYffOF1bGE4ETcV+OisqjUAwDQMJj++4bTpvMCDzwC+Bj3PmQyBCtscw==} + '@swc/core-win32-ia32-msvc@1.15.43': + resolution: {integrity: sha512-rLAE8JvucqEW1ZGohxPQrQWPBQeJG4+ypKbWfdlU/qmKScvCkxf9/Jxnzki1dkUQCQ7P5Enp13RlvqOlvx/32g==} engines: {node: '>=10'} cpu: [ia32] os: [win32] - '@swc/core-win32-x64-msvc@1.15.41': - resolution: {integrity: sha512-WOkA+fJ/ViVBQDsSV9JC52NACTe5PhlurA6viASDZGb7HR3KS01ZG7RZ+Bg6SVQFIoq3gSbTsskQVe6EbHFAYw==} + '@swc/core-win32-x64-msvc@1.15.43': + resolution: {integrity: sha512-h8MLDHZcfIukwQWj03rIJZx1I0E81AYj2X7J/nGErG4nz+QAv6G1Z+peotvinL3lqpbo32tLYSMFo32/ySzxKg==} engines: {node: '>=10'} cpu: [x64] os: [win32] - '@swc/core@1.15.41': - resolution: {integrity: sha512-03nQq/082QRJJiOvp3FGbgxTGyyxMxohPTjhk/W9bD2J0tk4ukITI7goOhOO2WbaHn/lsPmo/zf8+DIXhwpgYQ==} + '@swc/core@1.15.43': + resolution: {integrity: sha512-1CuKjFkPxIgGdeHVuNbkxmBxkcbdc08u0aiI43pFq6yY1tTVKmXT9hFEooyyKs/sJ3xf1GPHyEwTtk9Xl8dvQw==} engines: {node: '>=10'} peerDependencies: '@swc/helpers': '>=0.5.17' @@ -782,8 +782,8 @@ packages: resolution: {integrity: sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==} engines: {node: 18 || 20 || >=22} - browserslist@4.28.2: - resolution: {integrity: sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==} + browserslist@4.28.4: + resolution: {integrity: sha512-MTc8i/x9jBQd1iMw2CFGS+rwMa07eYjLR0CCTLDACl9xhxy+nIs3KeML/biicXtk9JrZ6dnnTatmc7ErPXIxqw==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true @@ -852,8 +852,8 @@ packages: resolution: {integrity: sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==} engines: {node: '>=12'} - electron-to-chromium@1.5.375: - resolution: {integrity: sha512-ZWP5eB4BVPW/ZYo9252hQZHZ5XavtsTgpbhcmMmRwymavC5AsLWQWBPaKMeNd2LW0KGby5HPXvj7+sr4ta5j/Q==} + electron-to-chromium@1.5.377: + resolution: {integrity: sha512-cH1jZgJHoezfTnKfKwnScpHywTFVnJUNITDPREFdhNjiuD502+QFpG0Qk7G8jhsV/f+CEAFlIrzP1fT+IMb92g==} emoji-regex@10.6.0: resolution: {integrity: sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==} @@ -1007,8 +1007,8 @@ packages: linkify-it@5.0.1: resolution: {integrity: sha512-wVoTjP4Q6R0NW5hiZkVJaFZPWgtXfoGF+6LucL3/FtiNjmcHhYjEr5f1Kqjirc1nBW07J/ZuRFumqr2oqccEWg==} - lint-staged@17.0.7: - resolution: {integrity: sha512-JrSobt+tW3rH8IOMi8tDZd3foorM5yPEkLD/V2NxobgHrFfHWGee4MOLVuZeScgxftEwbHrPHIFA/ZL+nUJeuA==} + lint-staged@17.0.8: + resolution: {integrity: sha512-B2P/d+jVW0UXOQ0MVMLrB/9ydA1P+zz6jYfdrbbEd9ur3S2rcbduFWKiUCC02Sm5hbC8nrm7y24WuYMG54HfxA==} engines: {node: '>=22.22.1'} hasBin: true @@ -1077,8 +1077,8 @@ packages: resolution: {integrity: sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==} hasBin: true - node-releases@2.0.47: - resolution: {integrity: sha512-Uzmd6LXpouKo8EUK68IjH4+E01w/hXyV3R3g/geCJo+rXLNfh1xucB+LOzYEOQPSiUK3h/xZf0cQGcSsmyL2Og==} + node-releases@2.0.48: + resolution: {integrity: sha512-1uz8041X6LoI6ZSdZacM9lVY28vuzDlSKitnpbSNK0RfKoIJkX29NBPVEFXhnuSuEOA9Ww0xnPJ+ILWbGAv8DA==} engines: {node: '>=18'} nullthrows@1.1.1: @@ -1144,8 +1144,8 @@ packages: scheduler@0.27.0: resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==} - semver@7.8.4: - resolution: {integrity: sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==} + semver@7.8.5: + resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==} engines: {node: '>=10'} hasBin: true @@ -1448,14 +1448,14 @@ snapshots: '@parcel/utils': 2.16.4 '@parcel/workers': 2.16.4(@parcel/core@2.16.4(@swc/helpers@0.5.23)) base-x: 3.0.11 - browserslist: 4.28.2 + browserslist: 4.28.4 clone: 2.1.2 dotenv: 16.6.1 dotenv-expand: 11.0.7 json5: 2.2.3 msgpackr: 1.12.1 nullthrows: 1.1.1 - semver: 7.8.4 + semver: 7.8.5 transitivePeerDependencies: - '@swc/helpers' - napi-wasm @@ -1514,7 +1514,7 @@ snapshots: '@parcel/rust': 2.16.4 '@parcel/utils': 2.16.4 nullthrows: 1.1.1 - semver: 7.8.4 + semver: 7.8.5 transitivePeerDependencies: - '@parcel/core' - napi-wasm @@ -1525,7 +1525,7 @@ snapshots: '@parcel/plugin': 2.16.4(@parcel/core@2.16.4(@swc/helpers@0.5.23)) '@parcel/source-map': 2.1.1 '@parcel/utils': 2.16.4 - browserslist: 4.28.2 + browserslist: 4.28.4 lightningcss: 1.32.0 nullthrows: 1.1.1 transitivePeerDependencies: @@ -1567,7 +1567,7 @@ snapshots: '@parcel/plugin': 2.16.4(@parcel/core@2.16.4(@swc/helpers@0.5.23)) '@parcel/source-map': 2.1.1 '@parcel/utils': 2.16.4 - '@swc/core': 1.15.41(@swc/helpers@0.5.23) + '@swc/core': 1.15.43(@swc/helpers@0.5.23) nullthrows: 1.1.1 transitivePeerDependencies: - '@parcel/core' @@ -1584,8 +1584,8 @@ snapshots: '@parcel/types': 2.16.4(@parcel/core@2.16.4(@swc/helpers@0.5.23)) '@parcel/utils': 2.16.4 '@parcel/workers': 2.16.4(@parcel/core@2.16.4(@swc/helpers@0.5.23)) - '@swc/core': 1.15.41(@swc/helpers@0.5.23) - semver: 7.8.4 + '@swc/core': 1.15.43(@swc/helpers@0.5.23) + semver: 7.8.5 transitivePeerDependencies: - '@swc/helpers' - napi-wasm @@ -1785,10 +1785,10 @@ snapshots: '@parcel/plugin': 2.16.4(@parcel/core@2.16.4(@swc/helpers@0.5.23)) '@parcel/source-map': 2.1.1 '@parcel/utils': 2.16.4 - browserslist: 4.28.2 + browserslist: 4.28.4 json5: 2.2.3 nullthrows: 1.1.1 - semver: 7.8.4 + semver: 7.8.5 transitivePeerDependencies: - '@parcel/core' - napi-wasm @@ -1799,7 +1799,7 @@ snapshots: '@parcel/plugin': 2.16.4(@parcel/core@2.16.4(@swc/helpers@0.5.23)) '@parcel/source-map': 2.1.1 '@parcel/utils': 2.16.4 - browserslist: 4.28.2 + browserslist: 4.28.4 lightningcss: 1.32.0 nullthrows: 1.1.1 transitivePeerDependencies: @@ -1835,10 +1835,10 @@ snapshots: '@parcel/utils': 2.16.4 '@parcel/workers': 2.16.4(@parcel/core@2.16.4(@swc/helpers@0.5.23)) '@swc/helpers': 0.5.23 - browserslist: 4.28.2 + browserslist: 4.28.4 nullthrows: 1.1.1 regenerator-runtime: 0.14.1 - semver: 7.8.4 + semver: 7.8.5 transitivePeerDependencies: - napi-wasm @@ -1866,7 +1866,7 @@ snapshots: clone: 2.1.2 nullthrows: 1.1.1 postcss-value-parser: 4.2.0 - semver: 7.8.4 + semver: 7.8.5 transitivePeerDependencies: - '@parcel/core' - napi-wasm @@ -2040,59 +2040,59 @@ snapshots: '@shikijs/vscode-textmate@10.0.2': {} - '@swc/core-darwin-arm64@1.15.41': + '@swc/core-darwin-arm64@1.15.43': optional: true - '@swc/core-darwin-x64@1.15.41': + '@swc/core-darwin-x64@1.15.43': optional: true - '@swc/core-linux-arm-gnueabihf@1.15.41': + '@swc/core-linux-arm-gnueabihf@1.15.43': optional: true - '@swc/core-linux-arm64-gnu@1.15.41': + '@swc/core-linux-arm64-gnu@1.15.43': optional: true - '@swc/core-linux-arm64-musl@1.15.41': + '@swc/core-linux-arm64-musl@1.15.43': optional: true - '@swc/core-linux-ppc64-gnu@1.15.41': + '@swc/core-linux-ppc64-gnu@1.15.43': optional: true - '@swc/core-linux-s390x-gnu@1.15.41': + '@swc/core-linux-s390x-gnu@1.15.43': optional: true - '@swc/core-linux-x64-gnu@1.15.41': + '@swc/core-linux-x64-gnu@1.15.43': optional: true - '@swc/core-linux-x64-musl@1.15.41': + '@swc/core-linux-x64-musl@1.15.43': optional: true - '@swc/core-win32-arm64-msvc@1.15.41': + '@swc/core-win32-arm64-msvc@1.15.43': optional: true - '@swc/core-win32-ia32-msvc@1.15.41': + '@swc/core-win32-ia32-msvc@1.15.43': optional: true - '@swc/core-win32-x64-msvc@1.15.41': + '@swc/core-win32-x64-msvc@1.15.43': optional: true - '@swc/core@1.15.41(@swc/helpers@0.5.23)': + '@swc/core@1.15.43(@swc/helpers@0.5.23)': dependencies: '@swc/counter': 0.1.3 '@swc/types': 0.1.27 optionalDependencies: - '@swc/core-darwin-arm64': 1.15.41 - '@swc/core-darwin-x64': 1.15.41 - '@swc/core-linux-arm-gnueabihf': 1.15.41 - '@swc/core-linux-arm64-gnu': 1.15.41 - '@swc/core-linux-arm64-musl': 1.15.41 - '@swc/core-linux-ppc64-gnu': 1.15.41 - '@swc/core-linux-s390x-gnu': 1.15.41 - '@swc/core-linux-x64-gnu': 1.15.41 - '@swc/core-linux-x64-musl': 1.15.41 - '@swc/core-win32-arm64-msvc': 1.15.41 - '@swc/core-win32-ia32-msvc': 1.15.41 - '@swc/core-win32-x64-msvc': 1.15.41 + '@swc/core-darwin-arm64': 1.15.43 + '@swc/core-darwin-x64': 1.15.43 + '@swc/core-linux-arm-gnueabihf': 1.15.43 + '@swc/core-linux-arm64-gnu': 1.15.43 + '@swc/core-linux-arm64-musl': 1.15.43 + '@swc/core-linux-ppc64-gnu': 1.15.43 + '@swc/core-linux-s390x-gnu': 1.15.43 + '@swc/core-linux-x64-gnu': 1.15.43 + '@swc/core-linux-x64-musl': 1.15.43 + '@swc/core-win32-arm64-msvc': 1.15.43 + '@swc/core-win32-ia32-msvc': 1.15.43 + '@swc/core-win32-x64-msvc': 1.15.43 '@swc/helpers': 0.5.23 '@swc/counter@0.1.3': {} @@ -2182,13 +2182,13 @@ snapshots: dependencies: balanced-match: 4.0.4 - browserslist@4.28.2: + browserslist@4.28.4: dependencies: baseline-browser-mapping: 2.10.38 caniuse-lite: 1.0.30001799 - electron-to-chromium: 1.5.375 - node-releases: 2.0.47 - update-browserslist-db: 1.2.3(browserslist@4.28.2) + electron-to-chromium: 1.5.377 + node-releases: 2.0.48 + update-browserslist-db: 1.2.3(browserslist@4.28.4) caniuse-lite@1.0.30001799: {} @@ -2236,7 +2236,7 @@ snapshots: dotenv@17.4.2: {} - electron-to-chromium@1.5.375: {} + electron-to-chromium@1.5.377: {} emoji-regex@10.6.0: {} @@ -2351,7 +2351,7 @@ snapshots: dependencies: uc.micro: 2.1.0 - lint-staged@17.0.7: + lint-staged@17.0.8: dependencies: listr2: 10.2.1 picomatch: 4.0.4 @@ -2459,7 +2459,7 @@ snapshots: detect-libc: 2.1.2 optional: true - node-releases@2.0.47: {} + node-releases@2.0.48: {} nullthrows@1.1.1: {} @@ -2522,7 +2522,7 @@ snapshots: scheduler@0.27.0: {} - semver@7.8.4: {} + semver@7.8.5: {} signal-exit@4.1.0: {} @@ -2561,7 +2561,7 @@ snapshots: tinyexec@1.2.4: {} - ts-node@10.9.2(@swc/core@1.15.41(@swc/helpers@0.5.23))(@types/node@24.13.2)(typescript@5.8.3): + ts-node@10.9.2(@swc/core@1.15.43(@swc/helpers@0.5.23))(@types/node@24.13.2)(typescript@5.8.3): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.12 @@ -2579,7 +2579,7 @@ snapshots: v8-compile-cache-lib: 3.0.1 yn: 3.1.1 optionalDependencies: - '@swc/core': 1.15.41(@swc/helpers@0.5.23) + '@swc/core': 1.15.43(@swc/helpers@0.5.23) tslib@2.8.1: {} @@ -2610,9 +2610,9 @@ snapshots: universalify@2.0.1: {} - update-browserslist-db@1.2.3(browserslist@4.28.2): + update-browserslist-db@1.2.3(browserslist@4.28.4): dependencies: - browserslist: 4.28.2 + browserslist: 4.28.4 escalade: 3.2.0 picocolors: 1.1.1 diff --git a/src/module/DocumentAI/index.ts b/src/module/DocumentAI/index.ts index 5351c08..7a4a9ab 100644 --- a/src/module/DocumentAI/index.ts +++ b/src/module/DocumentAI/index.ts @@ -103,15 +103,15 @@ export abstract class DocumentAIModel extends BaseModel { */ @toggle('uploading') async recognizeIDCard(file: File) { - const { body } = await this.client.post< - LarkData<{ - id_card: Omit & { corners?: number[]; conners?: number[] }; - }> - >(`${this.baseURI}/id_card/recognize`, makeFormData({ file })); + type IDCardTypo = Omit & { conners: number[] }; - const { conners, ...idCard } = body!.data!.id_card; + const { body } = await this.client.post>( + `${this.baseURI}/id_card/recognize`, + makeFormData({ file }) + ); + const { conners: corners, ...idCard } = body!.data!.id_card; - return { ...idCard, corners: idCard.corners || conners || [] }; + return { ...idCard, corners } as IDCard; } /** @@ -123,7 +123,6 @@ export abstract class DocumentAIModel extends BaseModel { `${this.baseURI}/business_card/recognize`, makeFormData({ file }) ); - return body!.data!.business_cards; } @@ -136,7 +135,6 @@ export abstract class DocumentAIModel extends BaseModel { `${this.baseURI}/business_license/recognize`, makeFormData({ file }) ); - return body!.data!.business_license; } diff --git a/src/module/DocumentAI/type.ts b/src/module/DocumentAI/type.ts index 599e503..7375a62 100644 --- a/src/module/DocumentAI/type.ts +++ b/src/module/DocumentAI/type.ts @@ -77,36 +77,36 @@ export interface BankCardEntity { export interface IDCardEntity { type: - | 'identity_code' - | 'identity_name' - | 'address' - | 'valid_date_start' - | 'valid_date_end' + | `identity_${'code' | 'name'}` + | 'birth' | 'gender' | 'race' + | 'address' | 'issued_by' - | 'birth'; + | `valid_date_${'start' | 'end'}`; value: string; } +export enum IDCardSide { + Cover = 0, + Profile = 1 +} + export interface IDCard { entities: IDCardEntity[]; - side: 0 | 1; + side: IDCardSide; corners: number[]; } export interface BusinessCardEntity { type: - | 'contact_names' - | 'company_names' + | `${'contact' | 'company'}_names` | 'departments' | 'job_titles' | 'emails' | 'websites' | 'addresses' - | 'mobile_phones' - | 'work_phones' - | 'other_phones' + | `${'mobile' | 'work' | 'other'}_phones` | 'faxes'; value: string; } @@ -119,16 +119,14 @@ export interface BusinessLicenseEntity { type: | 'certificate_type' | 'unified_social_credit_code' - | 'company_name' - | 'company_type' + | `company_${'name' | 'type'}` | 'domicile' | 'legal_representative' | 'registered_capital' - | 'established_time' // 成立日期 - | 'established_date' // 营业期限 + | `established_${'time' | 'date'}` // 成立日期、营业期限 | 'business_scope' - | 'website' - | 'approval_date'; + | 'approval_date' + | 'website'; value: string; }