mobx-lark 2.7.0 → 2.8.1
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.
- package/ReadMe.md +2 -0
- package/dist/Lark.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module/BITable/index.d.ts +105 -53
- package/dist/module/BITable/type.d.ts +1 -1
- package/dist/module/BITable/utility.d.ts +1 -0
- package/dist/module/DocumentAI/index.d.ts +31 -0
- package/dist/module/DocumentAI/type.d.ts +19 -0
- package/dist/module/index.d.ts +1 -0
- package/package.json +10 -10
- package/src/Lark.ts +5 -0
- package/src/module/BITable/index.ts +53 -31
- package/src/module/BITable/type.ts +1 -1
- package/src/module/BITable/utility.ts +11 -11
- package/src/module/DocumentAI/index.ts +61 -0
- package/src/module/DocumentAI/type.ts +69 -0
- package/src/module/index.ts +1 -0
|
@@ -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
|
+
}
|
package/src/module/index.ts
CHANGED