@retab/node 1.0.84 → 1.0.85

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.
@@ -6,7 +6,7 @@ import { MIMEDataInput, WorkflowRun } from "../../../types.js";
6
6
  export default class APIWorkflowRuns extends CompositionClient {
7
7
  constructor(client: CompositionClient);
8
8
  /**
9
- * Run a workflow with the provided input documents.
9
+ * Run a workflow with the provided inputs.
10
10
  *
11
11
  * This creates a workflow run and starts execution in the background.
12
12
  * The returned WorkflowRun will have status "running" - use get()
@@ -14,6 +14,8 @@ export default class APIWorkflowRuns extends CompositionClient {
14
14
  *
15
15
  * @param workflowId - The ID of the workflow to run
16
16
  * @param documents - Mapping of start node IDs to their input documents
17
+ * @param jsonInputs - Mapping of start_json node IDs to their input JSON data
18
+ * @param textInputs - Mapping of start_text node IDs to their input text
17
19
  * @param options - Optional request options
18
20
  * @returns The created workflow run with status "running"
19
21
  *
@@ -23,15 +25,22 @@ export default class APIWorkflowRuns extends CompositionClient {
23
25
  * workflowId: "wf_abc123",
24
26
  * documents: {
25
27
  * "start-node-1": "./invoice.pdf",
26
- * "start-node-2": Buffer.from(...)
28
+ * },
29
+ * jsonInputs: {
30
+ * "json-node-1": { key: "value" },
31
+ * },
32
+ * textInputs: {
33
+ * "text-node-1": "Hello, world!",
27
34
  * }
28
35
  * });
29
36
  * console.log(`Run started: ${run.id}, status: ${run.status}`);
30
37
  * ```
31
38
  */
32
- create({ workflowId, documents, }: {
39
+ create({ workflowId, documents, jsonInputs, textInputs, }: {
33
40
  workflowId: string;
34
- documents: Record<string, MIMEDataInput>;
41
+ documents?: Record<string, MIMEDataInput>;
42
+ jsonInputs?: Record<string, Record<string, unknown>>;
43
+ textInputs?: Record<string, string>;
35
44
  }, options?: RequestOptions): Promise<WorkflowRun>;
36
45
  /**
37
46
  * Get a workflow run by ID.
@@ -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,EAAE,aAAa,EAAa,WAAW,EAAgB,MAAM,mBAAmB,CAAC;AAExF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,iBAAiB;gBAC9C,MAAM,EAAE,iBAAiB;IAIrC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,MAAM,CACR,EACI,UAAU,EACV,SAAS,GACZ,EAAE;QACC,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;KAC5C,EACD,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,WAAW,CAAC;IA0BvB;;;;;;;;;;;;OAYG;IACG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;CAQ3E"}
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,EAAE,aAAa,EAAa,WAAW,EAAgB,MAAM,mBAAmB,CAAC;AAExF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,iBAAiB;gBAC9C,MAAM,EAAE,iBAAiB;IAIrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,MAAM,CACR,EACI,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,GACb,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,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACvC,EACD,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,WAAW,CAAC;IA2CvB;;;;;;;;;;;;OAYG;IACG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;CAQ3E"}
@@ -8,7 +8,7 @@ export default class APIWorkflowRuns extends CompositionClient {
8
8
  super(client);
9
9
  }
10
10
  /**
11
- * Run a workflow with the provided input documents.
11
+ * Run a workflow with the provided inputs.
12
12
  *
13
13
  * This creates a workflow run and starts execution in the background.
14
14
  * The returned WorkflowRun will have status "running" - use get()
@@ -16,6 +16,8 @@ export default class APIWorkflowRuns extends CompositionClient {
16
16
  *
17
17
  * @param workflowId - The ID of the workflow to run
18
18
  * @param documents - Mapping of start node IDs to their input documents
19
+ * @param jsonInputs - Mapping of start_json node IDs to their input JSON data
20
+ * @param textInputs - Mapping of start_text node IDs to their input text
19
21
  * @param options - Optional request options
20
22
  * @returns The created workflow run with status "running"
21
23
  *
@@ -25,30 +27,49 @@ export default class APIWorkflowRuns extends CompositionClient {
25
27
  * workflowId: "wf_abc123",
26
28
  * documents: {
27
29
  * "start-node-1": "./invoice.pdf",
28
- * "start-node-2": Buffer.from(...)
30
+ * },
31
+ * jsonInputs: {
32
+ * "json-node-1": { key: "value" },
33
+ * },
34
+ * textInputs: {
35
+ * "text-node-1": "Hello, world!",
29
36
  * }
30
37
  * });
31
38
  * console.log(`Run started: ${run.id}, status: ${run.status}`);
32
39
  * ```
33
40
  */
34
- async create({ workflowId, documents, }, options) {
41
+ async create({ workflowId, documents, jsonInputs, textInputs, }, options) {
42
+ // Build the request body
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ const body = {};
35
45
  // Convert each document to MIMEData format expected by backend
36
- const documentsPayload = {};
37
- for (const [nodeId, document] of Object.entries(documents)) {
38
- const parsedDocument = await ZMIMEData.parseAsync(document);
39
- // Extract base64 content from data URL
40
- const content = parsedDocument.url.split(",")[1];
41
- const mimeType = parsedDocument.url.split(";")[0].split(":")[1];
42
- documentsPayload[nodeId] = {
43
- filename: parsedDocument.filename,
44
- content: content,
45
- mime_type: mimeType,
46
- };
46
+ if (documents) {
47
+ const documentsPayload = {};
48
+ for (const [nodeId, document] of Object.entries(documents)) {
49
+ const parsedDocument = await ZMIMEData.parseAsync(document);
50
+ // Extract base64 content from data URL
51
+ const content = parsedDocument.url.split(",")[1];
52
+ const mimeType = parsedDocument.url.split(";")[0].split(":")[1];
53
+ documentsPayload[nodeId] = {
54
+ filename: parsedDocument.filename,
55
+ content: content,
56
+ mime_type: mimeType,
57
+ };
58
+ }
59
+ body.documents = documentsPayload;
60
+ }
61
+ // Add JSON inputs directly
62
+ if (jsonInputs) {
63
+ body.json_inputs = jsonInputs;
64
+ }
65
+ // Add text inputs directly
66
+ if (textInputs) {
67
+ body.text_inputs = textInputs;
47
68
  }
48
69
  return this._fetchJson(ZWorkflowRun, {
49
70
  url: `/v1/workflows/${workflowId}/run`,
50
71
  method: "POST",
51
- body: { documents: documentsPayload, ...(options?.body || {}) },
72
+ body: { ...body, ...(options?.body || {}) },
52
73
  params: options?.params,
53
74
  headers: options?.headers,
54
75
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retab/node",
3
- "version": "1.0.84",
3
+ "version": "1.0.85",
4
4
  "description": "Retab official Node.js library",
5
5
  "main": "dist/index.js",
6
6
  "exports": {