mobx-lark 2.7.0 → 2.8.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.
@@ -11,7 +11,7 @@ export interface TableView extends Record<'view_id' | 'view_name', string> {
11
11
  view_type: 'grid' | 'kanban' | 'gallery' | 'gantt' | 'form';
12
12
  }
13
13
  export interface TableFormView extends Record<'name' | 'description' | 'shared_url', string>, Record<'shared' | 'submit_limit_once', boolean> {
14
- shared_limit: 'tenant_editable';
14
+ shared_limit: 'off' | `${'tenant' | 'anyone'}_editable`;
15
15
  }
16
16
  export type LarkFormData = LarkData<{
17
17
  form: TableFormView;
@@ -0,0 +1,31 @@
1
+ import { BaseModel, RESTClient } from 'mobx-restful';
2
+ import { TaxiInvoice, TrainInvoice, VatInvoice, VehicleInvoice } from './type';
3
+ export * from './type';
4
+ export declare abstract class DocumentAIModel extends BaseModel {
5
+ baseURI: string;
6
+ abstract client: RESTClient;
7
+ /**
8
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/vat_invoice/recognize}
9
+ */
10
+ recognizeVatInvoices(file: File): Promise<{
11
+ entities: VatInvoice[];
12
+ }[]>;
13
+ /**
14
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/taxi_invoice/recognize}
15
+ */
16
+ recognizeTaxiInvoices(file: File): Promise<{
17
+ entities: TaxiInvoice[];
18
+ }[]>;
19
+ /**
20
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/train_invoice/recognize}
21
+ */
22
+ recognizeTrainInvoices(file: File): Promise<{
23
+ entities: TrainInvoice[];
24
+ }[]>;
25
+ /**
26
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/vehicle_invoice/recognize}
27
+ */
28
+ recognizeVehicleInvoice(file: File): Promise<{
29
+ entities: VehicleInvoice[];
30
+ }>;
31
+ }
@@ -0,0 +1,19 @@
1
+ export type InvoiceEntityType = `invoice_${'code' | 'no' | 'special_seal'}` | `seller_${'name' | 'taxpayer_no'}_in_seal`;
2
+ export type TrafficInvoiceEntityType = 'total_amount' | 'price';
3
+ export interface VatInvoice {
4
+ type: InvoiceEntityType | `invoice_${'name' | 'date'}` | `total_${'price' | 'tax'}` | `${'big_' | ''}total_price_and_tax` | 'check_code' | `buyer_${'name' | 'taxpayer_no' | 'address_phone' | 'account'}` | `seller_${'name' | 'taxpayer_no' | 'address_phone' | 'account'}` | 'payee' | 'password_area' | 'remarks' | 'reviewer' | 'drawer' | 'is_sealed' | 'machine_num';
5
+ value: string;
6
+ items: Record<'type' | 'value', string>[][];
7
+ }
8
+ export interface TaxiInvoice {
9
+ type: InvoiceEntityType | TrafficInvoiceEntityType | 'car_number' | 'start_date' | `${'start' | 'end'}_time` | 'distance' | `${'dispatch' | 'additional'}_fee` | 'is_sealed' | 'title_trial';
10
+ value: string;
11
+ }
12
+ export interface TrainInvoice {
13
+ type: TrafficInvoiceEntityType | 'name' | 'id_num' | 'time' | `${'start' | 'end'}_station` | `sale_${'num' | 'station'}` | `${'train' | 'seat' | 'ticket'}_num` | `seat_${'num' | 'cls'}`;
14
+ value: string;
15
+ }
16
+ export interface VehicleInvoice {
17
+ 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
+ value: string;
19
+ }
@@ -8,3 +8,4 @@ export * from './SpreadSheet';
8
8
  export * from './BITable';
9
9
  export * from './Drive';
10
10
  export * from './Wiki';
11
+ export * from './DocumentAI';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-lark",
3
- "version": "2.7.0",
3
+ "version": "2.8.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,9 +25,9 @@
25
25
  "url": "https://github.com/idea2app/MobX-Lark/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@swc/helpers": "^0.5.19",
28
+ "@swc/helpers": "^0.5.20",
29
29
  "@types/react": "^19.2.14",
30
- "koajax": "^3.1.2",
30
+ "koajax": "^3.3.0",
31
31
  "lodash.memoize": "^4.1.2",
32
32
  "mobx": "^6.15.0",
33
33
  "mobx-restful": "^2.1.4",
@@ -42,20 +42,20 @@
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.10.13",
45
+ "@types/node": "^24.12.0",
46
46
  "@types/react-dom": "^19.2.3",
47
47
  "@types/turndown": "^5.0.6",
48
48
  "dotenv": "^17.3.1",
49
- "fs-extra": "^11.3.3",
49
+ "fs-extra": "^11.3.4",
50
50
  "husky": "^9.1.7",
51
- "lint-staged": "^16.2.7",
51
+ "lint-staged": "^16.4.0",
52
52
  "parcel": "~2.16.4",
53
53
  "prettier": "^3.8.1",
54
54
  "react": "^19.2.4",
55
55
  "react-dom": "^19.2.4",
56
56
  "ts-node": "^10.9.2",
57
57
  "turndown": "^7.2.2",
58
- "typedoc": "^0.28.17",
58
+ "typedoc": "^0.28.18",
59
59
  "typedoc-plugin-mdn-links": "^5.1.1",
60
60
  "typescript": "~5.8.3"
61
61
  },
package/src/Lark.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  BiTableSchema,
7
7
  BiTableView,
8
8
  CopiedFile,
9
+ DocumentAIModel,
9
10
  DocumentModel,
10
11
  DriveFileModel,
11
12
  TableFormView,
@@ -51,6 +52,7 @@ export class LarkApp implements LarkAppOption {
51
52
  driveFileStore: DriveFileModel;
52
53
  wikiNodeStore: WikiNodeModel;
53
54
  documentStore: DocumentModel;
55
+ documentAIStore: DocumentAIModel;
54
56
 
55
57
  constructor(option: LarkAppServerOption | LarkAppClientOption) {
56
58
  Object.assign(this, option);
@@ -74,6 +76,9 @@ export class LarkApp implements LarkAppOption {
74
76
  this.documentStore = new (class extends DocumentModel {
75
77
  client = client;
76
78
  })('');
79
+ this.documentAIStore = new (class extends DocumentAIModel {
80
+ client = client;
81
+ })();
77
82
  }
78
83
 
79
84
  private boot() {
@@ -18,7 +18,7 @@ export interface TableFormView
18
18
  extends
19
19
  Record<'name' | 'description' | 'shared_url', string>,
20
20
  Record<'shared' | 'submit_limit_once', boolean> {
21
- shared_limit: 'tenant_editable';
21
+ shared_limit: 'off' | `${'tenant' | 'anyone'}_editable`;
22
22
  }
23
23
 
24
24
  export type LarkFormData = LarkData<{ form: TableFormView }>;
@@ -0,0 +1,61 @@
1
+ import { makeFormData } from 'koajax';
2
+ import { BaseModel, RESTClient, toggle } from 'mobx-restful';
3
+
4
+ import { LarkData } from '../../type';
5
+ import { TaxiInvoice, TrainInvoice, VatInvoice, VehicleInvoice } from './type';
6
+
7
+ export * from './type';
8
+
9
+ export abstract class DocumentAIModel extends BaseModel {
10
+ baseURI = 'document_ai/v1';
11
+
12
+ abstract client: RESTClient;
13
+
14
+ /**
15
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/vat_invoice/recognize}
16
+ */
17
+ @toggle('uploading')
18
+ async recognizeVatInvoices(file: File) {
19
+ const { body } = await this.client.post<
20
+ LarkData<{ vat_invoices: { entities: VatInvoice[] }[] }>
21
+ >(`${this.baseURI}/vat_invoice/recognize`, makeFormData({ file }));
22
+
23
+ return body!.data!.vat_invoices;
24
+ }
25
+
26
+ /**
27
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/taxi_invoice/recognize}
28
+ */
29
+ @toggle('uploading')
30
+ async recognizeTaxiInvoices(file: File) {
31
+ const { body } = await this.client.post<
32
+ LarkData<{ taxi_invoices: { entities: TaxiInvoice[] }[] }>
33
+ >(`${this.baseURI}/taxi_invoice/recognize`, makeFormData({ file }));
34
+
35
+ return body!.data!.taxi_invoices;
36
+ }
37
+
38
+ /**
39
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/train_invoice/recognize}
40
+ */
41
+ @toggle('uploading')
42
+ async recognizeTrainInvoices(file: File) {
43
+ const { body } = await this.client.post<
44
+ LarkData<{ train_invoices: { entities: TrainInvoice[] }[] }>
45
+ >(`${this.baseURI}/train_invoice/recognize`, makeFormData({ file }));
46
+
47
+ return body!.data!.train_invoices;
48
+ }
49
+
50
+ /**
51
+ * @see {@link https://open.feishu.cn/document/ai/document_ai-v1/vehicle_invoice/recognize}
52
+ */
53
+ @toggle('uploading')
54
+ async recognizeVehicleInvoice(file: File) {
55
+ const { body } = await this.client.post<
56
+ LarkData<{ vehicle_invoice: { entities: VehicleInvoice[] } }>
57
+ >(`${this.baseURI}/vehicle_invoice/recognize`, makeFormData({ file }));
58
+
59
+ return body!.data!.vehicle_invoice;
60
+ }
61
+ }
@@ -0,0 +1,69 @@
1
+ export type InvoiceEntityType =
2
+ | `invoice_${'code' | 'no' | 'special_seal'}`
3
+ | `seller_${'name' | 'taxpayer_no'}_in_seal`;
4
+
5
+ export type TrafficInvoiceEntityType = 'total_amount' | 'price';
6
+
7
+ export interface VatInvoice {
8
+ type:
9
+ | InvoiceEntityType
10
+ | `invoice_${'name' | 'date'}`
11
+ | `total_${'price' | 'tax'}`
12
+ | `${'big_' | ''}total_price_and_tax`
13
+ | 'check_code'
14
+ | `buyer_${'name' | 'taxpayer_no' | 'address_phone' | 'account'}`
15
+ | `seller_${'name' | 'taxpayer_no' | 'address_phone' | 'account'}`
16
+ | 'payee'
17
+ | 'password_area'
18
+ | 'remarks'
19
+ | 'reviewer'
20
+ | 'drawer'
21
+ | 'is_sealed'
22
+ | 'machine_num';
23
+ value: string;
24
+ items: Record<'type' | 'value', string>[][];
25
+ }
26
+
27
+ export interface TaxiInvoice {
28
+ type:
29
+ | InvoiceEntityType
30
+ | TrafficInvoiceEntityType
31
+ | 'car_number'
32
+ | 'start_date'
33
+ | `${'start' | 'end'}_time`
34
+ | 'distance'
35
+ | `${'dispatch' | 'additional'}_fee`
36
+ | 'is_sealed'
37
+ | 'title_trial';
38
+ value: string;
39
+ }
40
+
41
+ export interface TrainInvoice {
42
+ type:
43
+ | TrafficInvoiceEntityType
44
+ | 'name'
45
+ | 'id_num'
46
+ | 'time'
47
+ | `${'start' | 'end'}_station`
48
+ | `sale_${'num' | 'station'}`
49
+ | `${'train' | 'seat' | 'ticket'}_num`
50
+ | `seat_${'num' | 'cls'}`;
51
+ value: string;
52
+ }
53
+
54
+ export interface VehicleInvoice {
55
+ type:
56
+ | 'date'
57
+ | `invoice_${'code' | 'num'}`
58
+ | `print_${'code' | 'num'}`
59
+ | `buyer_${'name' | 'id'}`
60
+ | `saler_${'name' | 'id' | 'addr'}`
61
+ | 'vehicle_type'
62
+ | 'product_model'
63
+ | `${'certificate' | 'machine' | 'engine'}_num`
64
+ | 'vin'
65
+ | `tax${'' | '_rate'}`
66
+ | 'price'
67
+ | `total_price${'' | '_little'}`;
68
+ value: string;
69
+ }
@@ -8,3 +8,4 @@ export * from './SpreadSheet';
8
8
  export * from './BITable';
9
9
  export * from './Drive';
10
10
  export * from './Wiki';
11
+ export * from './DocumentAI';