@retab/node 1.0.74 → 1.0.76
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/dist/api/client.d.ts +2 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +2 -0
- package/dist/api/documents/client.d.ts +11 -6
- package/dist/api/documents/client.d.ts.map +1 -1
- package/dist/api/documents/client.js +11 -6
- package/dist/api/workflows/client.d.ts +48 -0
- package/dist/api/workflows/client.d.ts.map +1 -0
- package/dist/api/workflows/client.js +74 -0
- package/dist/generated_types.d.ts +1328 -687
- package/dist/generated_types.d.ts.map +1 -1
- package/dist/generated_types.js +79 -25
- package/dist/types.d.ts +7 -36
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -4
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import APIDocuments from "./documents/client";
|
|
|
4
4
|
import APISchemas from "./schemas/client";
|
|
5
5
|
import APIProjects from "./projects/client";
|
|
6
6
|
import APIExtractions from "./extractions/client";
|
|
7
|
+
import APIWorkflows from "./workflows/client";
|
|
7
8
|
export default class APIV1 extends CompositionClient {
|
|
8
9
|
constructor(client: AbstractClient);
|
|
9
10
|
models: APIModels;
|
|
@@ -11,5 +12,6 @@ export default class APIV1 extends CompositionClient {
|
|
|
11
12
|
schemas: APISchemas;
|
|
12
13
|
projects: APIProjects;
|
|
13
14
|
extractions: APIExtractions;
|
|
15
|
+
workflows: APIWorkflows;
|
|
14
16
|
}
|
|
15
17
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,cAAc,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,iBAAiB;gBACpC,MAAM,EAAE,cAAc;IAGlC,MAAM,YAAuB;IAC7B,SAAS,eAA0B;IACnC,OAAO,aAAwB;IAC/B,QAAQ,cAAyB;IACjC,WAAW,iBAA4B;IACvC,SAAS,eAA0B;CACtC"}
|
package/dist/api/client.js
CHANGED
|
@@ -4,6 +4,7 @@ import APIDocuments from "./documents/client";
|
|
|
4
4
|
import APISchemas from "./schemas/client";
|
|
5
5
|
import APIProjects from "./projects/client";
|
|
6
6
|
import APIExtractions from "./extractions/client";
|
|
7
|
+
import APIWorkflows from "./workflows/client";
|
|
7
8
|
export default class APIV1 extends CompositionClient {
|
|
8
9
|
constructor(client) {
|
|
9
10
|
super(client);
|
|
@@ -12,5 +13,6 @@ export default class APIV1 extends CompositionClient {
|
|
|
12
13
|
this.schemas = new APISchemas(this);
|
|
13
14
|
this.projects = new APIProjects(this);
|
|
14
15
|
this.extractions = new APIExtractions(this);
|
|
16
|
+
this.workflows = new APIWorkflows(this);
|
|
15
17
|
}
|
|
16
18
|
}
|
|
@@ -15,12 +15,17 @@ export default class APIDocuments extends CompositionClient {
|
|
|
15
15
|
* and filling. It accepts any PDF document and natural language instructions
|
|
16
16
|
* describing the values to fill in.
|
|
17
17
|
*
|
|
18
|
+
* Either `document` OR `template_id` must be provided, but not both.
|
|
19
|
+
* - When `document` is provided: OCR + LLM inference to detect and fill form fields
|
|
20
|
+
* - When `template_id` is provided: Uses pre-defined form fields from the template (PDF only)
|
|
21
|
+
*
|
|
18
22
|
* @param params - EditRequest containing:
|
|
19
|
-
* -
|
|
20
|
-
* -
|
|
21
|
-
* - model: LLM model for inference (default: "
|
|
23
|
+
* - filling_instructions: Natural language instructions for filling (required)
|
|
24
|
+
* - document: MIMEData object, file path, Buffer, or Readable stream (optional, mutually exclusive with template_id)
|
|
25
|
+
* - model: LLM model for inference (default: "retab-small")
|
|
26
|
+
* - template_id: Template ID to use for filling with pre-defined form fields (optional, mutually exclusive with document)
|
|
22
27
|
* @param options - Optional request options
|
|
23
|
-
* @returns EditResponse containing
|
|
28
|
+
* @returns EditResponse containing form_data (filled fields) and filled_document (MIMEData)
|
|
24
29
|
*/
|
|
25
30
|
edit(params: EditRequest, options?: RequestOptions): Promise<EditResponse>;
|
|
26
31
|
/**
|
|
@@ -32,7 +37,7 @@ export default class APIDocuments extends CompositionClient {
|
|
|
32
37
|
* @param params - SplitRequest containing:
|
|
33
38
|
* - document: MIMEData object, file path, Buffer, or Readable stream
|
|
34
39
|
* - categories: Array of categories with 'name' and 'description'
|
|
35
|
-
* - model: LLM model for inference (e.g., "
|
|
40
|
+
* - model: LLM model for inference (e.g., "retab-small")
|
|
36
41
|
* @param options - Optional request options
|
|
37
42
|
* @returns SplitResponse containing splits array with name, start_page, and end_page for each section
|
|
38
43
|
*
|
|
@@ -40,7 +45,7 @@ export default class APIDocuments extends CompositionClient {
|
|
|
40
45
|
* ```typescript
|
|
41
46
|
* const response = await retab.documents.split({
|
|
42
47
|
* document: "invoice_batch.pdf",
|
|
43
|
-
* model: "
|
|
48
|
+
* model: "retab-small",
|
|
44
49
|
* categories: [
|
|
45
50
|
* { name: "invoice", description: "Invoice documents with billing information" },
|
|
46
51
|
* { name: "receipt", description: "Receipt documents for payments" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/documents/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAA2B,sBAAsB,EAAE,yBAAyB,EAA8B,YAAY,EAAE,WAAW,EAA+B,4BAA4B,EAAE,eAAe,EAAmD,0BAA0B,EAA+B,8BAA8B,EAAmC,WAAW,EAAE,YAAY,EAA+B,YAAY,EAAiC,MAAM,gBAAgB,CAAC;AAC/f,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAAiB;gBAC3C,MAAM,EAAE,iBAAiB;IAG/B,OAAO,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAUrG,cAAc,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,8BAA8B,CAAC,CAAC;IAUjI,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IAS3E,eAAe,CAAC,MAAM,EAAE,4BAA4B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IASzG,aAAa,CAAC,MAAM,EAAE,0BAA0B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAS3G
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/documents/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAA2B,sBAAsB,EAAE,yBAAyB,EAA8B,YAAY,EAAE,WAAW,EAA+B,4BAA4B,EAAE,eAAe,EAAmD,0BAA0B,EAA+B,8BAA8B,EAAmC,WAAW,EAAE,YAAY,EAA+B,YAAY,EAAiC,MAAM,gBAAgB,CAAC;AAC/f,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAAiB;gBAC3C,MAAM,EAAE,iBAAiB;IAG/B,OAAO,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAUrG,cAAc,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,8BAA8B,CAAC,CAAC;IAUjI,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IAS3E,eAAe,CAAC,MAAM,EAAE,4BAA4B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IASzG,aAAa,CAAC,MAAM,EAAE,0BAA0B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAS3G;;;;;;;;;;;;;;;;;;OAkBG;IACG,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAShF;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAStF"}
|
|
@@ -58,12 +58,17 @@ export default class APIDocuments extends CompositionClient {
|
|
|
58
58
|
* and filling. It accepts any PDF document and natural language instructions
|
|
59
59
|
* describing the values to fill in.
|
|
60
60
|
*
|
|
61
|
+
* Either `document` OR `template_id` must be provided, but not both.
|
|
62
|
+
* - When `document` is provided: OCR + LLM inference to detect and fill form fields
|
|
63
|
+
* - When `template_id` is provided: Uses pre-defined form fields from the template (PDF only)
|
|
64
|
+
*
|
|
61
65
|
* @param params - EditRequest containing:
|
|
62
|
-
* -
|
|
63
|
-
* -
|
|
64
|
-
* - model: LLM model for inference (default: "
|
|
66
|
+
* - filling_instructions: Natural language instructions for filling (required)
|
|
67
|
+
* - document: MIMEData object, file path, Buffer, or Readable stream (optional, mutually exclusive with template_id)
|
|
68
|
+
* - model: LLM model for inference (default: "retab-small")
|
|
69
|
+
* - template_id: Template ID to use for filling with pre-defined form fields (optional, mutually exclusive with document)
|
|
65
70
|
* @param options - Optional request options
|
|
66
|
-
* @returns EditResponse containing
|
|
71
|
+
* @returns EditResponse containing form_data (filled fields) and filled_document (MIMEData)
|
|
67
72
|
*/
|
|
68
73
|
async edit(params, options) {
|
|
69
74
|
return this._fetchJson(ZEditResponse, {
|
|
@@ -83,7 +88,7 @@ export default class APIDocuments extends CompositionClient {
|
|
|
83
88
|
* @param params - SplitRequest containing:
|
|
84
89
|
* - document: MIMEData object, file path, Buffer, or Readable stream
|
|
85
90
|
* - categories: Array of categories with 'name' and 'description'
|
|
86
|
-
* - model: LLM model for inference (e.g., "
|
|
91
|
+
* - model: LLM model for inference (e.g., "retab-small")
|
|
87
92
|
* @param options - Optional request options
|
|
88
93
|
* @returns SplitResponse containing splits array with name, start_page, and end_page for each section
|
|
89
94
|
*
|
|
@@ -91,7 +96,7 @@ export default class APIDocuments extends CompositionClient {
|
|
|
91
96
|
* ```typescript
|
|
92
97
|
* const response = await retab.documents.split({
|
|
93
98
|
* document: "invoice_batch.pdf",
|
|
94
|
-
* model: "
|
|
99
|
+
* model: "retab-small",
|
|
95
100
|
* categories: [
|
|
96
101
|
* { name: "invoice", description: "Invoice documents with billing information" },
|
|
97
102
|
* { name: "receipt", description: "Receipt documents for payments" },
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CompositionClient, RequestOptions } from "../../client.js";
|
|
2
|
+
import { MIMEDataInput, WorkflowRun } from "../../types.js";
|
|
3
|
+
export default class APIWorkflows extends CompositionClient {
|
|
4
|
+
constructor(client: CompositionClient);
|
|
5
|
+
/**
|
|
6
|
+
* Run a workflow with the provided input documents.
|
|
7
|
+
*
|
|
8
|
+
* This creates a workflow run and starts execution in the background.
|
|
9
|
+
* The returned WorkflowRun will have status "running" - use getRun()
|
|
10
|
+
* to check for updates on the run status.
|
|
11
|
+
*
|
|
12
|
+
* @param workflowId - The ID of the workflow to run
|
|
13
|
+
* @param documents - Mapping of start node IDs to their input documents
|
|
14
|
+
* @param options - Optional request options
|
|
15
|
+
* @returns The created workflow run with status "running"
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const run = await client.workflows.run({
|
|
20
|
+
* workflowId: "wf_abc123",
|
|
21
|
+
* documents: {
|
|
22
|
+
* "start-node-1": "./invoice.pdf",
|
|
23
|
+
* "start-node-2": Buffer.from(...)
|
|
24
|
+
* }
|
|
25
|
+
* });
|
|
26
|
+
* console.log(`Run started: ${run.id}, status: ${run.status}`);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
run({ workflowId, documents, }: {
|
|
30
|
+
workflowId: string;
|
|
31
|
+
documents: Record<string, MIMEDataInput>;
|
|
32
|
+
}, options?: RequestOptions): Promise<WorkflowRun>;
|
|
33
|
+
/**
|
|
34
|
+
* Get a workflow run by ID.
|
|
35
|
+
*
|
|
36
|
+
* @param runId - The ID of the workflow run to retrieve
|
|
37
|
+
* @param options - Optional request options
|
|
38
|
+
* @returns The workflow run
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const run = await client.workflows.getRun("run_abc123");
|
|
43
|
+
* console.log(`Run status: ${run.status}`);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
getRun(runId: string, options?: RequestOptions): Promise<WorkflowRun>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/workflows/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAa,WAAW,EAAgB,MAAM,gBAAgB,CAAC;AAErF,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAAiB;gBAC3C,MAAM,EAAE,iBAAiB;IAIrC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,GAAG,CAAC,EACN,UAAU,EACV,SAAS,GACZ,EAAE;QACC,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;KAC5C,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IA0BlD;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;CAQ9E"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { CompositionClient } from "../../client.js";
|
|
2
|
+
import { ZMIMEData, ZWorkflowRun } from "../../types.js";
|
|
3
|
+
export default class APIWorkflows extends CompositionClient {
|
|
4
|
+
constructor(client) {
|
|
5
|
+
super(client);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Run a workflow with the provided input documents.
|
|
9
|
+
*
|
|
10
|
+
* This creates a workflow run and starts execution in the background.
|
|
11
|
+
* The returned WorkflowRun will have status "running" - use getRun()
|
|
12
|
+
* to check for updates on the run status.
|
|
13
|
+
*
|
|
14
|
+
* @param workflowId - The ID of the workflow to run
|
|
15
|
+
* @param documents - Mapping of start node IDs to their input documents
|
|
16
|
+
* @param options - Optional request options
|
|
17
|
+
* @returns The created workflow run with status "running"
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const run = await client.workflows.run({
|
|
22
|
+
* workflowId: "wf_abc123",
|
|
23
|
+
* documents: {
|
|
24
|
+
* "start-node-1": "./invoice.pdf",
|
|
25
|
+
* "start-node-2": Buffer.from(...)
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* console.log(`Run started: ${run.id}, status: ${run.status}`);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
async run({ workflowId, documents, }, options) {
|
|
32
|
+
// Convert each document to MIMEData format expected by backend
|
|
33
|
+
const documentsPayload = {};
|
|
34
|
+
for (const [nodeId, document] of Object.entries(documents)) {
|
|
35
|
+
const parsedDocument = await ZMIMEData.parseAsync(document);
|
|
36
|
+
// Extract base64 content from data URL
|
|
37
|
+
const content = parsedDocument.url.split(",")[1];
|
|
38
|
+
const mimeType = parsedDocument.url.split(";")[0].split(":")[1];
|
|
39
|
+
documentsPayload[nodeId] = {
|
|
40
|
+
filename: parsedDocument.filename,
|
|
41
|
+
content: content,
|
|
42
|
+
mime_type: mimeType,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return this._fetchJson(ZWorkflowRun, {
|
|
46
|
+
url: `/v1/workflows/${workflowId}/run`,
|
|
47
|
+
method: "POST",
|
|
48
|
+
body: { documents: documentsPayload, ...(options?.body || {}) },
|
|
49
|
+
params: options?.params,
|
|
50
|
+
headers: options?.headers,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get a workflow run by ID.
|
|
55
|
+
*
|
|
56
|
+
* @param runId - The ID of the workflow run to retrieve
|
|
57
|
+
* @param options - Optional request options
|
|
58
|
+
* @returns The workflow run
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const run = await client.workflows.getRun("run_abc123");
|
|
63
|
+
* console.log(`Run status: ${run.status}`);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
async getRun(runId, options) {
|
|
67
|
+
return this._fetchJson(ZWorkflowRun, {
|
|
68
|
+
url: `/v1/workflows/runs/${runId}`,
|
|
69
|
+
method: "GET",
|
|
70
|
+
params: options?.params,
|
|
71
|
+
headers: options?.headers,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|