@retab/node 1.0.81 → 1.0.83

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.
@@ -69,6 +69,7 @@ export default class APIDocuments extends CompositionClient {
69
69
  * - document: MIMEData object, file path, Buffer, or Readable stream
70
70
  * - categories: Array of categories with 'name' and 'description'
71
71
  * - model: LLM model for inference (e.g., "retab-small")
72
+ * - first_n_pages: (optional) Only use the first N pages for classification. Useful for large documents.
72
73
  * @param options - Optional request options
73
74
  * @returns ClassifyResponse containing result with reasoning and classification
74
75
  *
@@ -81,7 +82,8 @@ export default class APIDocuments extends CompositionClient {
81
82
  * { name: "invoice", description: "Invoice documents with billing information" },
82
83
  * { name: "receipt", description: "Receipt documents for payments" },
83
84
  * { name: "contract", description: "Legal contract documents" },
84
- * ]
85
+ * ],
86
+ * first_n_pages: 3 // Optional: only use first 3 pages
85
87
  * });
86
88
  * console.log(`Classification: ${response.result.classification}`);
87
89
  * console.log(`Reasoning: ${response.result.reasoning}`);
@@ -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,eAAe,EAAuC,MAAM,gBAAgB,CAAC;AACrjB,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,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,CA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a,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,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;IASnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAS/F"}
@@ -128,6 +128,7 @@ export default class APIDocuments extends CompositionClient {
128
128
  * - document: MIMEData object, file path, Buffer, or Readable stream
129
129
  * - categories: Array of categories with 'name' and 'description'
130
130
  * - model: LLM model for inference (e.g., "retab-small")
131
+ * - first_n_pages: (optional) Only use the first N pages for classification. Useful for large documents.
131
132
  * @param options - Optional request options
132
133
  * @returns ClassifyResponse containing result with reasoning and classification
133
134
  *
@@ -140,7 +141,8 @@ export default class APIDocuments extends CompositionClient {
140
141
  * { name: "invoice", description: "Invoice documents with billing information" },
141
142
  * { name: "receipt", description: "Receipt documents for payments" },
142
143
  * { name: "contract", description: "Legal contract documents" },
143
- * ]
144
+ * ],
145
+ * first_n_pages: 3 // Optional: only use first 3 pages
144
146
  * });
145
147
  * console.log(`Classification: ${response.result.classification}`);
146
148
  * console.log(`Reasoning: ${response.result.reasoning}`);
@@ -111,15 +111,17 @@ export default class APIEditTemplates extends CompositionClient {
111
111
  * - template_id: The template ID to use for filling
112
112
  * - instructions: Instructions describing how to fill the form fields
113
113
  * - model: LLM model for inference (default: "retab-small")
114
+ * - color: Hex color code for filled text (default: "#000080")
114
115
  * @param options - Optional request options
115
116
  * @returns EditResponse containing:
116
117
  * - form_data: List of form fields with filled values
117
118
  * - filled_document: The filled PDF document as MIMEData
118
119
  */
119
- fill({ template_id, instructions, model, }: {
120
+ fill({ template_id, instructions, model, color, }: {
120
121
  template_id: string;
121
122
  instructions: string;
122
123
  model?: string;
124
+ color?: string;
123
125
  }, options?: RequestOptions): Promise<EditResponse>;
124
126
  }
125
127
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/edit/templates/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAEH,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EAGvB,aAAa,EAEb,YAAY,EAEf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,YAAY,EAEZ,SAAS,EACZ,MAAM,6BAA6B,CAAC;AAErC,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,iBAAiB;gBAC/C,MAAM,EAAE,iBAAiB;IAIrC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IACG,SAAS,CACX,WAAW,EAAE,MAAM,EACnB,EAAE,IAAI,EAAE,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO,EAChC,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,YAAY,CAAC;IAaxB;;;;;;;;;;;;;;;;;;OAkBG;IACG,QAAQ,CACV,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,uBAAuB,CAAC;IAUnC;;;;;;;;;;;;;;;;;;;OAmBG;IACG,IAAI,CACN,EACI,WAAW,EACX,YAAY,EACZ,KAAqB,GACxB,EAAE;QACC,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,EACD,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,YAAY,CAAC;CAc3B"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/edit/templates/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAEH,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EAGvB,aAAa,EAEb,YAAY,EAEf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,YAAY,EAEZ,SAAS,EACZ,MAAM,6BAA6B,CAAC;AAErC,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,iBAAiB;gBAC/C,MAAM,EAAE,iBAAiB;IAIrC;;;;;;OAMG;IACG,IAAI,CACN,EACI,MAAM,EACN,KAAK,EACL,KAAU,EACV,KAAc,EACd,QAAQ,EACR,SAAS,EACT,kBAA0B,EAC1B,OAAsB,GACzB,GAAE;QACC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE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,cAAc,GACzB,OAAO,CAAC,uBAAuB,CAAC;IAUnC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,IAAI,CACN,EACI,WAAW,EACX,YAAY,EACZ,KAAqB,EACrB,KAAK,GACR,EAAE;QACC,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,EACD,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,YAAY,CAAC;CAqB3B"}
@@ -174,19 +174,26 @@ export default class APIEditTemplates extends CompositionClient {
174
174
  * - template_id: The template ID to use for filling
175
175
  * - instructions: Instructions describing how to fill the form fields
176
176
  * - model: LLM model for inference (default: "retab-small")
177
+ * - color: Hex color code for filled text (default: "#000080")
177
178
  * @param options - Optional request options
178
179
  * @returns EditResponse containing:
179
180
  * - form_data: List of form fields with filled values
180
181
  * - filled_document: The filled PDF document as MIMEData
181
182
  */
182
- async fill({ template_id, instructions, model = "retab-small", }, options) {
183
+ async fill({ template_id, instructions, model = "retab-small", color, }, options) {
184
+ const body = {
185
+ template_id,
186
+ instructions,
187
+ model,
188
+ };
189
+ if (color !== undefined) {
190
+ body.config = { color };
191
+ }
183
192
  return this._fetchJson(ZEditResponse, {
184
193
  url: "/v1/edit/templates/fill",
185
194
  method: "POST",
186
195
  body: {
187
- template_id,
188
- instructions,
189
- model,
196
+ ...body,
190
197
  ...(options?.body || {}),
191
198
  },
192
199
  params: options?.params,
@@ -1,48 +1,13 @@
1
- import { CompositionClient, RequestOptions } from "../../client.js";
2
- import { MIMEDataInput, WorkflowRun } from "../../types.js";
1
+ import { CompositionClient } from "../../client.js";
2
+ import APIWorkflowRuns from "./runs/client.js";
3
+ /**
4
+ * Workflows API client for workflow operations.
5
+ *
6
+ * Sub-clients:
7
+ * - runs: Workflow run operations (create, get)
8
+ */
3
9
  export default class APIWorkflows extends CompositionClient {
10
+ runs: APIWorkflowRuns;
4
11
  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
12
  }
48
13
  //# sourceMappingURL=client.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/workflows/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAAiB;IAChD,IAAI,EAAE,eAAe,CAAC;gBAEjB,MAAM,EAAE,iBAAiB;CAIxC"}
@@ -1,74 +1,14 @@
1
1
  import { CompositionClient } from "../../client.js";
2
- import { ZMIMEData, ZWorkflowRun } from "../../types.js";
2
+ import APIWorkflowRuns from "./runs/client.js";
3
+ /**
4
+ * Workflows API client for workflow operations.
5
+ *
6
+ * Sub-clients:
7
+ * - runs: Workflow run operations (create, get)
8
+ */
3
9
  export default class APIWorkflows extends CompositionClient {
4
10
  constructor(client) {
5
11
  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
- });
12
+ this.runs = new APIWorkflowRuns(this);
73
13
  }
74
14
  }
@@ -0,0 +1,51 @@
1
+ import { CompositionClient, RequestOptions } from "../../../client.js";
2
+ import { MIMEDataInput, WorkflowRun } from "../../../types.js";
3
+ /**
4
+ * Workflow Runs API client for managing workflow executions.
5
+ */
6
+ export default class APIWorkflowRuns extends CompositionClient {
7
+ constructor(client: CompositionClient);
8
+ /**
9
+ * Run a workflow with the provided input documents.
10
+ *
11
+ * This creates a workflow run and starts execution in the background.
12
+ * The returned WorkflowRun will have status "running" - use get()
13
+ * to check for updates on the run status.
14
+ *
15
+ * @param workflowId - The ID of the workflow to run
16
+ * @param documents - Mapping of start node IDs to their input documents
17
+ * @param options - Optional request options
18
+ * @returns The created workflow run with status "running"
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const run = await client.workflows.runs.create({
23
+ * workflowId: "wf_abc123",
24
+ * documents: {
25
+ * "start-node-1": "./invoice.pdf",
26
+ * "start-node-2": Buffer.from(...)
27
+ * }
28
+ * });
29
+ * console.log(`Run started: ${run.id}, status: ${run.status}`);
30
+ * ```
31
+ */
32
+ create({ workflowId, documents, }: {
33
+ workflowId: string;
34
+ documents: Record<string, MIMEDataInput>;
35
+ }, options?: RequestOptions): Promise<WorkflowRun>;
36
+ /**
37
+ * Get a workflow run by ID.
38
+ *
39
+ * @param runId - The ID of the workflow run to retrieve
40
+ * @param options - Optional request options
41
+ * @returns The workflow run
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const run = await client.workflows.runs.get("run_abc123");
46
+ * console.log(`Run status: ${run.status}`);
47
+ * ```
48
+ */
49
+ get(runId: string, options?: RequestOptions): Promise<WorkflowRun>;
50
+ }
51
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,77 @@
1
+ import { CompositionClient } from "../../../client.js";
2
+ import { ZMIMEData, ZWorkflowRun } from "../../../types.js";
3
+ /**
4
+ * Workflow Runs API client for managing workflow executions.
5
+ */
6
+ export default class APIWorkflowRuns extends CompositionClient {
7
+ constructor(client) {
8
+ super(client);
9
+ }
10
+ /**
11
+ * Run a workflow with the provided input documents.
12
+ *
13
+ * This creates a workflow run and starts execution in the background.
14
+ * The returned WorkflowRun will have status "running" - use get()
15
+ * to check for updates on the run status.
16
+ *
17
+ * @param workflowId - The ID of the workflow to run
18
+ * @param documents - Mapping of start node IDs to their input documents
19
+ * @param options - Optional request options
20
+ * @returns The created workflow run with status "running"
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const run = await client.workflows.runs.create({
25
+ * workflowId: "wf_abc123",
26
+ * documents: {
27
+ * "start-node-1": "./invoice.pdf",
28
+ * "start-node-2": Buffer.from(...)
29
+ * }
30
+ * });
31
+ * console.log(`Run started: ${run.id}, status: ${run.status}`);
32
+ * ```
33
+ */
34
+ async create({ workflowId, documents, }, options) {
35
+ // 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
+ };
47
+ }
48
+ return this._fetchJson(ZWorkflowRun, {
49
+ url: `/v1/workflows/${workflowId}/run`,
50
+ method: "POST",
51
+ body: { documents: documentsPayload, ...(options?.body || {}) },
52
+ params: options?.params,
53
+ headers: options?.headers,
54
+ });
55
+ }
56
+ /**
57
+ * Get a workflow run by ID.
58
+ *
59
+ * @param runId - The ID of the workflow run to retrieve
60
+ * @param options - Optional request options
61
+ * @returns The workflow run
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const run = await client.workflows.runs.get("run_abc123");
66
+ * console.log(`Run status: ${run.status}`);
67
+ * ```
68
+ */
69
+ async get(runId, options) {
70
+ return this._fetchJson(ZWorkflowRun, {
71
+ url: `/v1/workflows/runs/${runId}`,
72
+ method: "GET",
73
+ params: options?.params,
74
+ headers: options?.headers,
75
+ });
76
+ }
77
+ }