@retab/node 1.0.75 → 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/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 +1114 -504
- package/dist/generated_types.d.ts.map +1 -1
- package/dist/generated_types.js +49 -0
- package/dist/types.d.ts +2 -2
- 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
|
}
|
|
@@ -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
|
+
}
|