@retab/node 1.0.91 → 1.0.94
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/documents/client.d.ts +7 -6
- package/dist/api/documents/client.d.ts.map +1 -1
- package/dist/api/documents/client.js +15 -5
- package/dist/api/workflows/runs/client.d.ts +3 -10
- package/dist/api/workflows/runs/client.d.ts.map +1 -1
- package/dist/api/workflows/runs/client.js +3 -11
- package/dist/generated_types.d.ts +120 -8
- package/dist/generated_types.d.ts.map +1 -1
- package/dist/generated_types.js +14 -3
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CompositionClient, RequestOptions } from "../../client.js";
|
|
2
|
-
import { DocumentExtractRequest, RetabParsedChatCompletion, ParseRequest, ParseResult, DocumentCreateMessageRequest, DocumentMessage, DocumentCreateInputRequest, RetabParsedChatCompletionChunk, EditRequest, EditResponse, SplitRequest, ClassifyRequest } from "../../types.js";
|
|
3
|
-
import type { SplitResponse, ClassifyResponse } from "../../generated_types.js";
|
|
2
|
+
import { DocumentExtractRequest, RetabParsedChatCompletion, ParseRequest, ParseResult, DocumentCreateMessageRequest, DocumentMessage, DocumentCreateInputRequest, RetabParsedChatCompletionChunk, EditRequest, EditResponse, SplitRequest, ClassifyRequest, GenerateSplitConfigRequest } from "../../types.js";
|
|
3
|
+
import type { SplitResponse, ClassifyResponse, GenerateSplitConfigResponse } from "../../generated_types.js";
|
|
4
4
|
export default class APIDocuments extends CompositionClient {
|
|
5
5
|
constructor(client: CompositionClient);
|
|
6
6
|
extract(params: DocumentExtractRequest, options?: RequestOptions): Promise<RetabParsedChatCompletion>;
|
|
@@ -29,14 +29,14 @@ export default class APIDocuments extends CompositionClient {
|
|
|
29
29
|
*/
|
|
30
30
|
edit(params: EditRequest, options?: RequestOptions): Promise<EditResponse>;
|
|
31
31
|
/**
|
|
32
|
-
* Split a document into sections based on provided
|
|
32
|
+
* Split a document into sections based on provided subdocuments.
|
|
33
33
|
*
|
|
34
34
|
* This method analyzes a multi-page document and classifies pages into
|
|
35
|
-
* user-defined
|
|
35
|
+
* user-defined subdocuments, returning the page ranges for each section.
|
|
36
36
|
*
|
|
37
37
|
* @param params - SplitRequest containing:
|
|
38
38
|
* - document: MIMEData object, file path, Buffer, or Readable stream
|
|
39
|
-
* -
|
|
39
|
+
* - subdocuments: Array of subdocuments with 'name' and 'description'
|
|
40
40
|
* - model: LLM model for inference (e.g., "retab-small")
|
|
41
41
|
* @param options - Optional request options
|
|
42
42
|
* @returns SplitResponse containing splits array with name and pages for each section
|
|
@@ -46,7 +46,7 @@ export default class APIDocuments extends CompositionClient {
|
|
|
46
46
|
* const response = await retab.documents.split({
|
|
47
47
|
* document: "invoice_batch.pdf",
|
|
48
48
|
* model: "retab-small",
|
|
49
|
-
*
|
|
49
|
+
* subdocuments: [
|
|
50
50
|
* { name: "invoice", description: "Invoice documents with billing information" },
|
|
51
51
|
* { name: "receipt", description: "Receipt documents for payments" },
|
|
52
52
|
* { name: "contract", description: "Legal contract documents" },
|
|
@@ -90,5 +90,6 @@ export default class APIDocuments extends CompositionClient {
|
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
92
|
classify(params: ClassifyRequest, options?: RequestOptions): Promise<ClassifyResponse>;
|
|
93
|
+
generate_split_config(params: GenerateSplitConfigRequest, options?: RequestOptions): Promise<GenerateSplitConfigResponse>;
|
|
93
94
|
}
|
|
94
95
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -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,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AAM,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;IASnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAStF,qBAAqB,CAAC,MAAM,EAAE,0BAA0B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,2BAA2B,CAAC;CASlI"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CompositionClient } from "../../client.js";
|
|
2
|
-
import { ZDocumentExtractRequest, ZRetabParsedChatCompletion, ZParseResult, ZParseRequest, ZDocumentMessage, ZDocumentCreateMessageRequest, ZDocumentCreateInputRequest, ZRetabParsedChatCompletionChunk, ZEditRequest, ZEditResponse, ZSplitRequest, ZSplitResponse, ZClassifyRequest, ZClassifyResponse } from "../../types.js";
|
|
2
|
+
import { ZDocumentExtractRequest, ZRetabParsedChatCompletion, ZParseResult, ZParseRequest, ZDocumentMessage, ZDocumentCreateMessageRequest, ZDocumentCreateInputRequest, ZRetabParsedChatCompletionChunk, ZEditRequest, ZEditResponse, ZSplitRequest, ZSplitResponse, ZClassifyRequest, ZClassifyResponse, ZGenerateSplitConfigRequest } from "../../types.js";
|
|
3
|
+
import { ZGenerateSplitConfigResponse } from "../../generated_types.js";
|
|
3
4
|
export default class APIDocuments extends CompositionClient {
|
|
4
5
|
constructor(client) {
|
|
5
6
|
super(client);
|
|
@@ -80,14 +81,14 @@ export default class APIDocuments extends CompositionClient {
|
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
83
|
/**
|
|
83
|
-
* Split a document into sections based on provided
|
|
84
|
+
* Split a document into sections based on provided subdocuments.
|
|
84
85
|
*
|
|
85
86
|
* This method analyzes a multi-page document and classifies pages into
|
|
86
|
-
* user-defined
|
|
87
|
+
* user-defined subdocuments, returning the page ranges for each section.
|
|
87
88
|
*
|
|
88
89
|
* @param params - SplitRequest containing:
|
|
89
90
|
* - document: MIMEData object, file path, Buffer, or Readable stream
|
|
90
|
-
* -
|
|
91
|
+
* - subdocuments: Array of subdocuments with 'name' and 'description'
|
|
91
92
|
* - model: LLM model for inference (e.g., "retab-small")
|
|
92
93
|
* @param options - Optional request options
|
|
93
94
|
* @returns SplitResponse containing splits array with name and pages for each section
|
|
@@ -97,7 +98,7 @@ export default class APIDocuments extends CompositionClient {
|
|
|
97
98
|
* const response = await retab.documents.split({
|
|
98
99
|
* document: "invoice_batch.pdf",
|
|
99
100
|
* model: "retab-small",
|
|
100
|
-
*
|
|
101
|
+
* subdocuments: [
|
|
101
102
|
* { name: "invoice", description: "Invoice documents with billing information" },
|
|
102
103
|
* { name: "receipt", description: "Receipt documents for payments" },
|
|
103
104
|
* { name: "contract", description: "Legal contract documents" },
|
|
@@ -157,4 +158,13 @@ export default class APIDocuments extends CompositionClient {
|
|
|
157
158
|
headers: options?.headers,
|
|
158
159
|
});
|
|
159
160
|
}
|
|
161
|
+
async generate_split_config(params, options) {
|
|
162
|
+
return this._fetchJson(ZGenerateSplitConfigResponse, {
|
|
163
|
+
url: "/v1/documents/split/generate_config",
|
|
164
|
+
method: "POST",
|
|
165
|
+
body: { ...(await ZGenerateSplitConfigRequest.parseAsync(params)), ...(options?.body || {}) },
|
|
166
|
+
params: options?.params,
|
|
167
|
+
headers: options?.headers,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
160
170
|
}
|
|
@@ -20,7 +20,6 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
20
20
|
* @param workflowId - The ID of the workflow to run
|
|
21
21
|
* @param documents - Mapping of start node IDs to their input documents
|
|
22
22
|
* @param jsonInputs - Mapping of start_json node IDs to their input JSON data
|
|
23
|
-
* @param textInputs - Mapping of start_text node IDs to their input text
|
|
24
23
|
* @param options - Optional request options
|
|
25
24
|
* @returns The created workflow run with status "running"
|
|
26
25
|
*
|
|
@@ -34,18 +33,14 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
34
33
|
* jsonInputs: {
|
|
35
34
|
* "json-node-1": { key: "value" },
|
|
36
35
|
* },
|
|
37
|
-
* textInputs: {
|
|
38
|
-
* "text-node-1": "Hello, world!",
|
|
39
|
-
* }
|
|
40
36
|
* });
|
|
41
37
|
* console.log(`Run started: ${run.id}, status: ${run.status}`);
|
|
42
38
|
* ```
|
|
43
39
|
*/
|
|
44
|
-
create({ workflowId, documents, jsonInputs,
|
|
40
|
+
create({ workflowId, documents, jsonInputs, }: {
|
|
45
41
|
workflowId: string;
|
|
46
42
|
documents?: Record<string, MIMEDataInput>;
|
|
47
43
|
jsonInputs?: Record<string, Record<string, unknown>>;
|
|
48
|
-
textInputs?: Record<string, string>;
|
|
49
44
|
}, options?: RequestOptions): Promise<WorkflowRun>;
|
|
50
45
|
/**
|
|
51
46
|
* Get a workflow run by ID.
|
|
@@ -79,7 +74,7 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
79
74
|
status?: "pending" | "running" | "completed" | "error" | "waiting_for_human" | "cancelled";
|
|
80
75
|
statuses?: string;
|
|
81
76
|
excludeStatus?: "pending" | "running" | "completed" | "error" | "waiting_for_human" | "cancelled";
|
|
82
|
-
triggerType?: "manual" | "api" | "schedule" | "webhook" | "restart";
|
|
77
|
+
triggerType?: "manual" | "api" | "schedule" | "webhook" | "email" | "restart";
|
|
83
78
|
triggerTypes?: string;
|
|
84
79
|
fromDate?: string;
|
|
85
80
|
toDate?: string;
|
|
@@ -200,7 +195,6 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
200
195
|
* @param workflowId - The ID of the workflow to run
|
|
201
196
|
* @param documents - Mapping of start node IDs to their input documents
|
|
202
197
|
* @param jsonInputs - Mapping of start_json node IDs to their input JSON data
|
|
203
|
-
* @param textInputs - Mapping of start_text node IDs to their input text
|
|
204
198
|
* @param pollIntervalMs - Milliseconds between polls (default: 2000)
|
|
205
199
|
* @param timeoutMs - Maximum time to wait in milliseconds (default: 600000)
|
|
206
200
|
* @param options - Optional request options
|
|
@@ -218,11 +212,10 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
218
212
|
* }
|
|
219
213
|
* ```
|
|
220
214
|
*/
|
|
221
|
-
createAndWait({ workflowId, documents, jsonInputs,
|
|
215
|
+
createAndWait({ workflowId, documents, jsonInputs, pollIntervalMs, timeoutMs, }: {
|
|
222
216
|
workflowId: string;
|
|
223
217
|
documents?: Record<string, MIMEDataInput>;
|
|
224
218
|
jsonInputs?: Record<string, Record<string, unknown>>;
|
|
225
|
-
textInputs?: Record<string, string>;
|
|
226
219
|
pollIntervalMs?: number;
|
|
227
220
|
timeoutMs?: number;
|
|
228
221
|
}, options?: RequestOptions): Promise<WorkflowRun>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/workflows/runs/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EACH,aAAa,EAEb,WAAW,EAEX,aAAa,EAEb,sBAAsB,EAEtB,sBAAsB,EAEzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,mBAAmB,MAAM,mBAAmB,CAAC;AAQpD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,iBAAiB;IACnD,KAAK,EAAE,mBAAmB,CAAC;gBAEtB,MAAM,EAAE,iBAAiB;IAKrC
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/workflows/runs/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvE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,WAAW,CAAC;IAcvB;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,MAAM,CACR,KAAK,EAAE,MAAM,EACb,EACI,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,SAAS,GACZ,EAAE;QACC,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,OAAO,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;QAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;KACtB,EACD,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;;;;;;;;;;;;;;;;;;OAmBG;IACG,iBAAiB,CACnB,KAAK,EAAE,MAAM,EACb,EACI,cAAqB,EACrB,SAAkB,GACrB,GAAE;QACC,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACjB,GACP,OAAO,CAAC,WAAW,CAAC;IAuBvB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,aAAa,CACf,EACI,UAAU,EACV,SAAS,EACT,UAAU,EACV,cAAqB,EACrB,SAAkB,GACrB,EAAE;QACC,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QAC1C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACrD,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACtB,EACD,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,WAAW,CAAC;CAO1B"}
|
|
@@ -26,7 +26,6 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
26
26
|
* @param workflowId - The ID of the workflow to run
|
|
27
27
|
* @param documents - Mapping of start node IDs to their input documents
|
|
28
28
|
* @param jsonInputs - Mapping of start_json node IDs to their input JSON data
|
|
29
|
-
* @param textInputs - Mapping of start_text node IDs to their input text
|
|
30
29
|
* @param options - Optional request options
|
|
31
30
|
* @returns The created workflow run with status "running"
|
|
32
31
|
*
|
|
@@ -40,14 +39,11 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
40
39
|
* jsonInputs: {
|
|
41
40
|
* "json-node-1": { key: "value" },
|
|
42
41
|
* },
|
|
43
|
-
* textInputs: {
|
|
44
|
-
* "text-node-1": "Hello, world!",
|
|
45
|
-
* }
|
|
46
42
|
* });
|
|
47
43
|
* console.log(`Run started: ${run.id}, status: ${run.status}`);
|
|
48
44
|
* ```
|
|
49
45
|
*/
|
|
50
|
-
async create({ workflowId, documents, jsonInputs,
|
|
46
|
+
async create({ workflowId, documents, jsonInputs, }, options) {
|
|
51
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
48
|
const body = {};
|
|
53
49
|
if (documents) {
|
|
@@ -67,9 +63,6 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
67
63
|
if (jsonInputs) {
|
|
68
64
|
body.json_inputs = jsonInputs;
|
|
69
65
|
}
|
|
70
|
-
if (textInputs) {
|
|
71
|
-
body.text_inputs = textInputs;
|
|
72
|
-
}
|
|
73
66
|
return this._fetchJson(ZWorkflowRun, {
|
|
74
67
|
url: `/v1/workflows/${workflowId}/run`,
|
|
75
68
|
method: "POST",
|
|
@@ -300,7 +293,6 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
300
293
|
* @param workflowId - The ID of the workflow to run
|
|
301
294
|
* @param documents - Mapping of start node IDs to their input documents
|
|
302
295
|
* @param jsonInputs - Mapping of start_json node IDs to their input JSON data
|
|
303
|
-
* @param textInputs - Mapping of start_text node IDs to their input text
|
|
304
296
|
* @param pollIntervalMs - Milliseconds between polls (default: 2000)
|
|
305
297
|
* @param timeoutMs - Maximum time to wait in milliseconds (default: 600000)
|
|
306
298
|
* @param options - Optional request options
|
|
@@ -318,8 +310,8 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
318
310
|
* }
|
|
319
311
|
* ```
|
|
320
312
|
*/
|
|
321
|
-
async createAndWait({ workflowId, documents, jsonInputs,
|
|
322
|
-
const run = await this.create({ workflowId, documents, jsonInputs
|
|
313
|
+
async createAndWait({ workflowId, documents, jsonInputs, pollIntervalMs = 2000, timeoutMs = 600000, }, options) {
|
|
314
|
+
const run = await this.create({ workflowId, documents, jsonInputs }, options);
|
|
323
315
|
return this.waitForCompletion(run.id, { pollIntervalMs, timeoutMs });
|
|
324
316
|
}
|
|
325
317
|
}
|