mobx-lark 2.8.1 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -97,7 +97,7 @@ export declare function BiDataTable<D extends DataObject, F extends Filter<D> =
97
97
  export type BiSearchFilter<D extends DataObject> = Filter<D> & {
98
98
  keywords?: string;
99
99
  };
100
- export declare function BiSearch<D extends DataObject, F extends BiSearchFilter<D> = BiSearchFilter<D>>(Model: ReturnType<typeof BiDataTable<D, F>>): abstract new (appId: string, tableId: string) => {
100
+ export declare function BiSearch<D extends DataObject, F extends BiSearchFilter<D> = BiSearchFilter<D>, M extends ReturnType<typeof BiDataTable<D, F>> = ReturnType<typeof BiDataTable<D, F>>>(Model: M): abstract new (appId: string, tableId: string) => {
101
101
  baseURI: string;
102
102
  client: RESTClient;
103
103
  searchKeys: readonly (keyof TableRecordFields)[];
@@ -6,4 +6,4 @@ export declare function registerBlocks<T extends Block<any, any, any>>(blocks: T
6
6
  export declare const ChildrenRenderer: FC<{
7
7
  children?: string[];
8
8
  }>;
9
- export declare function renderBlocks(blocks: Block<any, any, any>[]): import("react/jsx-runtime").JSX.Element;
9
+ export declare function renderBlocks(blocks: Block<any, any, any>[]): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { BaseModel, RESTClient } from 'mobx-restful';
2
- import { TaxiInvoice, TrainInvoice, VatInvoice, VehicleInvoice } from './type';
2
+ import { BankCardEntity, Contract, Resume, TaxiInvoice, TrainInvoice, VatInvoice, VehicleInvoice } from './type';
3
3
  export * from './type';
4
4
  export declare abstract class DocumentAIModel extends BaseModel {
5
5
  baseURI: string;
@@ -28,4 +28,20 @@ export declare abstract class DocumentAIModel extends BaseModel {
28
28
  recognizeVehicleInvoice(file: File): Promise<{
29
29
  entities: VehicleInvoice[];
30
30
  }>;
31
+ /**
32
+ * @see {@link https://open.feishu.cn/document/server-docs/ai/optical_char_recognition-v1/basic_recognize}
33
+ */
34
+ recognizeText(image: File): Promise<string[]>;
35
+ /**
36
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/bank_card/recognize}
37
+ */
38
+ recognizeBankCard(file: File): Promise<BankCardEntity[]>;
39
+ /**
40
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/resume/parse}
41
+ */
42
+ parseResume(file: File): Promise<Resume[]>;
43
+ /**
44
+ * @see {@link https://open.feishu.cn/document/server-docs/ai/document_ai-v1/contract/field_extraction}
45
+ */
46
+ extractContract(file: File, ocr_mode?: 'unused' | 'force' | 'auto', pdf_page_limit?: number): Promise<Contract>;
31
47
  }
@@ -1,3 +1,4 @@
1
+ import { Gender } from '../User/type';
1
2
  export type InvoiceEntityType = `invoice_${'code' | 'no' | 'special_seal'}` | `seller_${'name' | 'taxpayer_no'}_in_seal`;
2
3
  export type TrafficInvoiceEntityType = 'total_amount' | 'price';
3
4
  export interface VatInvoice {
@@ -17,3 +18,83 @@ export interface VehicleInvoice {
17
18
  type: 'date' | `invoice_${'code' | 'num'}` | `print_${'code' | 'num'}` | `buyer_${'name' | 'id'}` | `saler_${'name' | 'id' | 'addr'}` | 'vehicle_type' | 'product_model' | `${'certificate' | 'machine' | 'engine'}_num` | 'vin' | `tax${'' | '_rate'}` | 'price' | `total_price${'' | '_little'}`;
18
19
  value: string;
19
20
  }
21
+ export interface BankCardEntity {
22
+ type: 'card_number' | 'date_of_expiry';
23
+ value: string;
24
+ }
25
+ export type ResumePeriod = Record<`${'start' | 'end'}_${'date' | 'time'}`, string>;
26
+ export declare enum EducationQualification {
27
+ PrimarySchool = 1,
28
+ JuniorHighSchool = 2,
29
+ VocationalHighSchool = 3,
30
+ HighSchool = 4,
31
+ AssociateDegree = 5,
32
+ BachelorDegree = 6,
33
+ MasterDegree = 7,
34
+ Doctorate = 8,
35
+ Other = 9
36
+ }
37
+ export interface ResumeEducation extends ResumePeriod, Record<'school' | 'major' | 'degree', string> {
38
+ qualification: EducationQualification;
39
+ }
40
+ export declare enum CareerType {
41
+ Internship = 1,
42
+ FullTime = 2
43
+ }
44
+ export interface ResumeCareer extends ResumePeriod, Record<'company' | 'title' | 'type_str' | 'job_description', string> {
45
+ type: CareerType;
46
+ }
47
+ export type ResumeProject = ResumePeriod & Record<'name' | 'title' | 'description', string>;
48
+ export interface ResumeLanguage {
49
+ level: number;
50
+ description: string;
51
+ }
52
+ export type ResumeAward = Record<'award' | 'date' | 'description', string>;
53
+ export type ResumeCertificate = Record<'name' | 'desc', string>;
54
+ export type ResumeCompetition = ResumeCertificate;
55
+ export interface Resume extends Record<'file_md5' | `${'' | 'new_'}content` | 'name' | 'email' | 'mobile' | 'country_code' | 'date_of_birth' | `${'current' | 'home'}_location` | 'self_evaluation', string>, Record<`willing_${'positions' | 'locations'}` | 'urls' | 'social_links', string[]> {
56
+ mobile_is_virtual: boolean;
57
+ educations: ResumeEducation[];
58
+ careers: ResumeCareer[];
59
+ projects: ResumeProject[];
60
+ work_year: number | null;
61
+ gender: Gender;
62
+ languages: ResumeLanguage[];
63
+ awards: ResumeAward[];
64
+ certificates: ResumeCertificate[];
65
+ competitions: ResumeCompetition[];
66
+ }
67
+ export interface ContractPrice {
68
+ contract_price: number;
69
+ contract_price_original: string;
70
+ text: string;
71
+ }
72
+ export type ContractInitialTerm = Record<`initial_${'time' | 'unit'}`, string>;
73
+ export interface ContractTime extends Record<`${'' | 'original_'}time_${'start' | 'end'}` | `text_${'start' | 'end' | 'initial_term'}`, string> {
74
+ initial_term: ContractInitialTerm;
75
+ }
76
+ export interface ContractCopy extends Record<'original_copy' | 'key' | 'text', string> {
77
+ copy_num: number;
78
+ }
79
+ export type ContractCurrency = Record<`currency_${'name' | 'text'}`, string>;
80
+ export type ContractBodyType = 'buy' | 'sell' | 'third';
81
+ export type ContractContact = Record<'contacts' | 'id_number' | 'phone' | 'email' | 'address', string>;
82
+ export type ContractBodyEntity = ContractContact & Record<'legal_representative' | 'party', string>;
83
+ export interface ContractBodyInfo {
84
+ body_type: ContractBodyType;
85
+ value: ContractBodyEntity;
86
+ }
87
+ export type ContractBankType = `${'buy' | 'sell' | 'third' | 'uncertain'}_bank`;
88
+ export type ContractBankEntity = ContractContact & Record<'bank_name' | `account_${'name' | 'number'}` | 'tax_number', string>;
89
+ export interface ContractBankInfo {
90
+ bank_type: ContractBankType;
91
+ value: ContractBankEntity;
92
+ }
93
+ export interface Contract extends Record<'file_id' | 'header', string> {
94
+ price: ContractPrice;
95
+ time: ContractTime;
96
+ copy: ContractCopy;
97
+ currency: ContractCurrency;
98
+ body_info: ContractBodyInfo[];
99
+ bank_info: ContractBankInfo[];
100
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-lark",
3
- "version": "2.8.1",
3
+ "version": "2.9.0",
4
4
  "license": "LGPL-3.0",
5
5
  "author": "shiy2008@gmail.com",
6
6
  "description": "Unofficial TypeScript SDK for FeiShu/Lark API, which is based on MobX-RESTful.",
@@ -25,14 +25,14 @@
25
25
  "url": "https://github.com/idea2app/MobX-Lark/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@swc/helpers": "^0.5.21",
29
- "@types/react": "^19.2.14",
28
+ "@swc/helpers": "^0.5.23",
29
+ "@types/react": "^19.2.17",
30
30
  "koajax": "^3.3.0",
31
31
  "lodash.memoize": "^4.1.2",
32
- "mobx": "^6.15.0",
32
+ "mobx": "^6.16.1",
33
33
  "mobx-restful": "^2.1.4",
34
34
  "regenerator-runtime": "^0.14.1",
35
- "web-utility": "^4.6.5"
35
+ "web-utility": "^4.6.6"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": ">=16"
@@ -42,31 +42,23 @@
42
42
  "@parcel/transformer-typescript-tsc": "~2.16.4",
43
43
  "@types/fs-extra": "^11.0.4",
44
44
  "@types/lodash.memoize": "^4.1.9",
45
- "@types/node": "^24.12.2",
45
+ "@types/node": "^24.13.2",
46
46
  "@types/react-dom": "^19.2.3",
47
47
  "@types/turndown": "^5.0.6",
48
- "dotenv": "^17.4.0",
49
- "fs-extra": "^11.3.4",
48
+ "dotenv": "^17.4.2",
49
+ "fs-extra": "^11.3.5",
50
50
  "husky": "^9.1.7",
51
- "lint-staged": "^16.4.0",
51
+ "lint-staged": "^17.0.7",
52
52
  "parcel": "~2.16.4",
53
- "prettier": "^3.8.1",
54
- "react": "^19.2.4",
55
- "react-dom": "^19.2.4",
53
+ "prettier": "^3.8.4",
54
+ "react": "^19.2.7",
55
+ "react-dom": "^19.2.7",
56
56
  "ts-node": "^10.9.2",
57
57
  "turndown": "^7.2.4",
58
- "typedoc": "^0.28.18",
58
+ "typedoc": "^0.28.19",
59
59
  "typedoc-plugin-mdn-links": "^5.1.1",
60
60
  "typescript": "~5.8.3"
61
61
  },
62
- "pnpm": {
63
- "onlyBuiltDependencies": [
64
- "@parcel/watcher",
65
- "@swc/core",
66
- "lmdb",
67
- "msgpackr-extract"
68
- ]
69
- },
70
62
  "prettier": {
71
63
  "singleQuote": true,
72
64
  "trailingComma": "none",
@@ -0,0 +1,9 @@
1
+ packages:
2
+ - .
3
+ autoInstallPeers: false
4
+ allowBuilds:
5
+ '@parcel/watcher': true
6
+ '@swc/core': true
7
+ core-js: true
8
+ lmdb: true
9
+ msgpackr-extract: true
package/src/Lark.ts CHANGED
@@ -39,7 +39,7 @@ export interface LarkAppClientOption extends LarkAppBaseOption {
39
39
  accessToken: string;
40
40
  }
41
41
 
42
- export interface LarkAppOption extends LarkAppServerOption, LarkAppClientOption {}
42
+ export type LarkAppOption = LarkAppServerOption & LarkAppClientOption;
43
43
 
44
44
  export class LarkApp implements LarkAppOption {
45
45
  host = 'https://open.feishu.cn/open-apis/';
@@ -177,10 +177,12 @@ export type BiSearchFilter<D extends DataObject> = Filter<D> & {
177
177
  keywords?: string;
178
178
  };
179
179
 
180
- export function BiSearch<D extends DataObject, F extends BiSearchFilter<D> = BiSearchFilter<D>>(
181
- Model: ReturnType<typeof BiDataTable<D, F>>
182
- ) {
183
- abstract class BiSearchModel extends Model {
180
+ export function BiSearch<
181
+ D extends DataObject,
182
+ F extends BiSearchFilter<D> = BiSearchFilter<D>,
183
+ M extends ReturnType<typeof BiDataTable<D, F>> = ReturnType<typeof BiDataTable<D, F>>
184
+ >(Model: M) {
185
+ abstract class BiSearchModel extends (Model as ReturnType<typeof BiDataTable<D, F>>) {
184
186
  declare baseURI: string;
185
187
  declare client: RESTClient;
186
188
 
@@ -1,8 +1,16 @@
1
- import { makeFormData } from 'koajax';
1
+ import { makeFormData, readAs } from 'koajax';
2
2
  import { BaseModel, RESTClient, toggle } from 'mobx-restful';
3
3
 
4
4
  import { LarkData } from '../../type';
5
- import { TaxiInvoice, TrainInvoice, VatInvoice, VehicleInvoice } from './type';
5
+ import {
6
+ BankCardEntity,
7
+ Contract,
8
+ Resume,
9
+ TaxiInvoice,
10
+ TrainInvoice,
11
+ VatInvoice,
12
+ VehicleInvoice
13
+ } from './type';
6
14
 
7
15
  export * from './type';
8
16
 
@@ -58,4 +66,60 @@ export abstract class DocumentAIModel extends BaseModel {
58
66
 
59
67
  return body!.data!.vehicle_invoice;
60
68
  }
69
+
70
+ /**
71
+ * @see {@link https://open.feishu.cn/document/server-docs/ai/optical_char_recognition-v1/basic_recognize}
72
+ */
73
+ @toggle('uploading')
74
+ async recognizeText(image: File) {
75
+ const URI = (await readAs(image, 'dataURL').result) as string;
76
+
77
+ const [, base64] = URI.split(',');
78
+
79
+ const { body } = await this.client.post<LarkData<{ text_list: string[] }>>(
80
+ 'optical_char_recognition/v1/image/basic_recognize',
81
+ { image: base64 }
82
+ );
83
+ return body!.data!.text_list;
84
+ }
85
+
86
+ /**
87
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/bank_card/recognize}
88
+ */
89
+ @toggle('uploading')
90
+ async recognizeBankCard(file: File) {
91
+ const { body } = await this.client.post<
92
+ LarkData<{ bank_card: { entities: BankCardEntity[] } }>
93
+ >(`${this.baseURI}/bank_card/recognize`, makeFormData({ file }));
94
+
95
+ return body!.data!.bank_card.entities;
96
+ }
97
+
98
+ /**
99
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/resume/parse}
100
+ */
101
+ @toggle('uploading')
102
+ async parseResume(file: File) {
103
+ const { body } = await this.client.post<LarkData<{ resumes: Resume[] }>>(
104
+ `${this.baseURI}/resume/parse`,
105
+ makeFormData({ file })
106
+ );
107
+ return body!.data!.resumes;
108
+ }
109
+
110
+ /**
111
+ * @see {@link https://open.feishu.cn/document/server-docs/ai/document_ai-v1/contract/field_extraction}
112
+ */
113
+ @toggle('uploading')
114
+ async extractContract(
115
+ file: File,
116
+ ocr_mode: 'unused' | 'force' | 'auto' = 'auto',
117
+ pdf_page_limit = 100
118
+ ) {
119
+ const { body } = await this.client.post<LarkData<Contract>>(
120
+ `${this.baseURI}/contract/field_extraction`,
121
+ makeFormData({ file, ocr_mode, pdf_page_limit })
122
+ );
123
+ return body!.data!;
124
+ }
61
125
  }
@@ -1,3 +1,5 @@
1
+ import { Gender } from '../User/type';
2
+
1
3
  export type InvoiceEntityType =
2
4
  | `invoice_${'code' | 'no' | 'special_seal'}`
3
5
  | `seller_${'name' | 'taxpayer_no'}_in_seal`;
@@ -67,3 +69,130 @@ export interface VehicleInvoice {
67
69
  | `total_price${'' | '_little'}`;
68
70
  value: string;
69
71
  }
72
+
73
+ export interface BankCardEntity {
74
+ type: 'card_number' | 'date_of_expiry';
75
+ value: string;
76
+ }
77
+
78
+ export type ResumePeriod = Record<`${'start' | 'end'}_${'date' | 'time'}`, string>;
79
+
80
+ export enum EducationQualification {
81
+ PrimarySchool = 1,
82
+ JuniorHighSchool = 2,
83
+ VocationalHighSchool = 3,
84
+ HighSchool = 4,
85
+ AssociateDegree = 5,
86
+ BachelorDegree = 6,
87
+ MasterDegree = 7,
88
+ Doctorate = 8,
89
+ Other = 9
90
+ }
91
+
92
+ export interface ResumeEducation
93
+ extends ResumePeriod, Record<'school' | 'major' | 'degree', string> {
94
+ qualification: EducationQualification;
95
+ }
96
+
97
+ export enum CareerType {
98
+ Internship = 1,
99
+ FullTime = 2
100
+ }
101
+
102
+ export interface ResumeCareer
103
+ extends ResumePeriod, Record<'company' | 'title' | 'type_str' | 'job_description', string> {
104
+ type: CareerType;
105
+ }
106
+
107
+ export type ResumeProject = ResumePeriod & Record<'name' | 'title' | 'description', string>;
108
+
109
+ export interface ResumeLanguage {
110
+ level: number;
111
+ description: string;
112
+ }
113
+
114
+ export type ResumeAward = Record<'award' | 'date' | 'description', string>;
115
+
116
+ export type ResumeCertificate = Record<'name' | 'desc', string>;
117
+
118
+ export type ResumeCompetition = ResumeCertificate;
119
+
120
+ export interface Resume
121
+ extends
122
+ Record<
123
+ | 'file_md5'
124
+ | `${'' | 'new_'}content`
125
+ | 'name'
126
+ | 'email'
127
+ | 'mobile'
128
+ | 'country_code'
129
+ | 'date_of_birth'
130
+ | `${'current' | 'home'}_location`
131
+ | 'self_evaluation',
132
+ string
133
+ >,
134
+ Record<`willing_${'positions' | 'locations'}` | 'urls' | 'social_links', string[]> {
135
+ mobile_is_virtual: boolean;
136
+ educations: ResumeEducation[];
137
+ careers: ResumeCareer[];
138
+ projects: ResumeProject[];
139
+ work_year: number | null;
140
+ gender: Gender;
141
+ languages: ResumeLanguage[];
142
+ awards: ResumeAward[];
143
+ certificates: ResumeCertificate[];
144
+ competitions: ResumeCompetition[];
145
+ }
146
+
147
+ export interface ContractPrice {
148
+ contract_price: number;
149
+ contract_price_original: string;
150
+ text: string;
151
+ }
152
+
153
+ export type ContractInitialTerm = Record<`initial_${'time' | 'unit'}`, string>;
154
+
155
+ export interface ContractTime extends Record<
156
+ `${'' | 'original_'}time_${'start' | 'end'}` | `text_${'start' | 'end' | 'initial_term'}`,
157
+ string
158
+ > {
159
+ initial_term: ContractInitialTerm;
160
+ }
161
+
162
+ export interface ContractCopy extends Record<'original_copy' | 'key' | 'text', string> {
163
+ copy_num: number;
164
+ }
165
+
166
+ export type ContractCurrency = Record<`currency_${'name' | 'text'}`, string>;
167
+
168
+ export type ContractBodyType = 'buy' | 'sell' | 'third';
169
+
170
+ export type ContractContact = Record<
171
+ 'contacts' | 'id_number' | 'phone' | 'email' | 'address',
172
+ string
173
+ >;
174
+ export type ContractBodyEntity = ContractContact & Record<'legal_representative' | 'party', string>;
175
+
176
+ export interface ContractBodyInfo {
177
+ body_type: ContractBodyType;
178
+ value: ContractBodyEntity;
179
+ }
180
+
181
+ export type ContractBankType = `${'buy' | 'sell' | 'third' | 'uncertain'}_bank`;
182
+
183
+ export type ContractBankEntity = ContractContact &
184
+ Record<'bank_name' | `account_${'name' | 'number'}` | 'tax_number', string>;
185
+
186
+ export interface ContractBankInfo {
187
+ bank_type: ContractBankType;
188
+ value: ContractBankEntity;
189
+ }
190
+
191
+ export interface Contract extends Record<'file_id' | 'header', string> {
192
+ price: ContractPrice;
193
+ time: ContractTime;
194
+ copy: ContractCopy;
195
+ currency: ContractCurrency;
196
+ body_info: ContractBodyInfo[];
197
+ bank_info: ContractBankInfo[];
198
+ }