@retab/node 1.0.98 → 1.0.99
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/README.md +39 -42
- package/dist/api/client.d.ts +4 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +4 -0
- package/dist/api/documents/client.d.ts +17 -11
- package/dist/api/documents/client.d.ts.map +1 -1
- package/dist/api/documents/client.js +81 -34
- package/dist/api/edit/client.d.ts +1 -1
- package/dist/api/edit/client.js +1 -1
- package/dist/api/edit/templates/client.d.ts +1 -75
- package/dist/api/edit/templates/client.d.ts.map +1 -1
- package/dist/api/edit/templates/client.js +1 -128
- package/dist/api/evals/classify/client.d.ts +20 -0
- package/dist/api/evals/classify/client.d.ts.map +1 -0
- package/dist/api/evals/classify/client.js +25 -0
- package/dist/api/evals/client.d.ts +11 -0
- package/dist/api/evals/client.d.ts.map +1 -0
- package/dist/api/evals/client.js +12 -0
- package/dist/api/evals/extract/client.d.ts +287 -0
- package/dist/api/evals/extract/client.d.ts.map +1 -0
- package/dist/api/evals/extract/client.js +56 -0
- package/dist/api/evals/helpers.d.ts +30 -0
- package/dist/api/evals/helpers.d.ts.map +1 -0
- package/dist/api/evals/helpers.js +46 -0
- package/dist/api/evals/schemas.d.ts +6522 -0
- package/dist/api/evals/schemas.d.ts.map +1 -0
- package/dist/api/evals/schemas.js +219 -0
- package/dist/api/evals/split/client.d.ts +105 -0
- package/dist/api/evals/split/client.d.ts.map +1 -0
- package/dist/api/evals/split/client.js +28 -0
- package/dist/api/extractions/client.d.ts +3 -43
- package/dist/api/extractions/client.d.ts.map +1 -1
- package/dist/api/extractions/client.js +3 -64
- package/dist/api/files/client.d.ts +9 -1
- package/dist/api/files/client.d.ts.map +1 -1
- package/dist/api/files/client.js +7 -1
- package/dist/api/jobs/client.d.ts +11 -9
- package/dist/api/jobs/client.d.ts.map +1 -1
- package/dist/api/jobs/client.js +7 -11
- package/dist/api/models/client.d.ts +3 -10
- package/dist/api/models/client.d.ts.map +1 -1
- package/dist/api/models/client.js +9 -8
- package/dist/api/projects/client.d.ts +1640 -4
- package/dist/api/projects/client.d.ts.map +1 -1
- package/dist/api/projects/client.js +451 -22
- package/dist/api/schemas/client.d.ts +3 -0
- package/dist/api/schemas/client.d.ts.map +1 -1
- package/dist/api/workflows/blocks/client.d.ts +67 -0
- package/dist/api/workflows/blocks/client.d.ts.map +1 -0
- package/dist/api/workflows/blocks/client.js +132 -0
- package/dist/api/workflows/client.d.ts +73 -1
- package/dist/api/workflows/client.d.ts.map +1 -1
- package/dist/api/workflows/client.js +121 -1
- package/dist/api/workflows/edges/client.d.ts +66 -0
- package/dist/api/workflows/edges/client.d.ts.map +1 -0
- package/dist/api/workflows/edges/client.js +120 -0
- package/dist/api/workflows/runs/client.d.ts +57 -113
- package/dist/api/workflows/runs/client.d.ts.map +1 -1
- package/dist/api/workflows/runs/client.js +111 -112
- package/dist/api/workflows/runs/steps/client.d.ts +35 -13
- package/dist/api/workflows/runs/steps/client.d.ts.map +1 -1
- package/dist/api/workflows/runs/steps/client.js +61 -13
- package/dist/client.d.ts +4 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +78 -4
- package/dist/generated_types.d.ts +7751 -2718
- package/dist/generated_types.d.ts.map +1 -1
- package/dist/generated_types.js +709 -68
- package/dist/mime.d.ts.map +1 -1
- package/dist/mime.js +11 -1
- package/dist/schema_types.d.ts +2 -2
- package/dist/schema_types.d.ts.map +1 -1
- package/dist/schema_types.js +2 -2
- package/dist/types.d.ts +614 -109
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +70 -14
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CompositionClient, RequestOptions } from "../../../client.js";
|
|
2
|
-
import { MIMEDataInput, WorkflowRun, PaginatedList, CancelWorkflowResponse, ResumeWorkflowResponse } from "../../../types.js";
|
|
2
|
+
import { MIMEDataInput, WorkflowRun, PaginatedList, CancelWorkflowResponse, ResumeWorkflowResponse, WorkflowRunExportResponse, WorkflowRunStatus, WorkflowRunTriggerType } from "../../../types.js";
|
|
3
3
|
import APIWorkflowRunSteps from "./steps/client.js";
|
|
4
4
|
/**
|
|
5
5
|
* Workflow Runs API client for managing workflow executions.
|
|
6
6
|
*
|
|
7
7
|
* Sub-clients:
|
|
8
|
-
* - steps: Step output operations (get, list)
|
|
8
|
+
* - steps: Step output operations (get, list, getMany, getAll)
|
|
9
9
|
*/
|
|
10
10
|
export default class APIWorkflowRuns extends CompositionClient {
|
|
11
11
|
steps: APIWorkflowRunSteps;
|
|
@@ -17,24 +17,12 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
17
17
|
* The returned WorkflowRun will have status "running" - use get()
|
|
18
18
|
* to check for updates on the run status.
|
|
19
19
|
*
|
|
20
|
-
* @param workflowId - The ID of the workflow to run
|
|
21
|
-
* @param documents - Mapping of start node IDs to their input documents
|
|
22
|
-
* @param jsonInputs - Mapping of start_json node IDs to their input JSON data
|
|
23
|
-
* @param options - Optional request options
|
|
24
|
-
* @returns The created workflow run with status "running"
|
|
25
|
-
*
|
|
26
20
|
* @example
|
|
27
21
|
* ```typescript
|
|
28
22
|
* const run = await client.workflows.runs.create({
|
|
29
23
|
* workflowId: "wf_abc123",
|
|
30
|
-
* documents: {
|
|
31
|
-
* "start-node-1": "./invoice.pdf",
|
|
32
|
-
* },
|
|
33
|
-
* jsonInputs: {
|
|
34
|
-
* "json-node-1": { key: "value" },
|
|
35
|
-
* },
|
|
24
|
+
* documents: { "start-node-1": "./invoice.pdf" },
|
|
36
25
|
* });
|
|
37
|
-
* console.log(`Run started: ${run.id}, status: ${run.status}`);
|
|
38
26
|
* ```
|
|
39
27
|
*/
|
|
40
28
|
create({ workflowId, documents, jsonInputs, }: {
|
|
@@ -44,47 +32,27 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
44
32
|
}, options?: RequestOptions): Promise<WorkflowRun>;
|
|
45
33
|
/**
|
|
46
34
|
* Get a workflow run by ID.
|
|
47
|
-
*
|
|
48
|
-
* @param runId - The ID of the workflow run to retrieve
|
|
49
|
-
* @param options - Optional request options
|
|
50
|
-
* @returns The workflow run
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const run = await client.workflows.runs.get("run_abc123");
|
|
55
|
-
* console.log(`Run status: ${run.status}`);
|
|
56
|
-
* ```
|
|
57
35
|
*/
|
|
58
36
|
get(runId: string, options?: RequestOptions): Promise<WorkflowRun>;
|
|
59
37
|
/**
|
|
60
38
|
* List workflow runs with filtering and pagination.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```typescript
|
|
64
|
-
* const runs = await client.workflows.runs.list({
|
|
65
|
-
* workflowId: "wf_abc123",
|
|
66
|
-
* status: "completed",
|
|
67
|
-
* limit: 10,
|
|
68
|
-
* });
|
|
69
|
-
* console.log(`Found ${runs.data.length} runs`);
|
|
70
|
-
* ```
|
|
71
39
|
*/
|
|
72
40
|
list({ workflowId, status, statuses, excludeStatus, triggerType, triggerTypes, fromDate, toDate, minCost, maxCost, minDuration, maxDuration, search, sortBy, fields, before, after, limit, order, }?: {
|
|
73
41
|
workflowId?: string;
|
|
74
|
-
status?:
|
|
75
|
-
statuses?: string;
|
|
76
|
-
excludeStatus?:
|
|
77
|
-
triggerType?:
|
|
78
|
-
triggerTypes?: string;
|
|
79
|
-
fromDate?: string;
|
|
80
|
-
toDate?: string;
|
|
42
|
+
status?: WorkflowRunStatus;
|
|
43
|
+
statuses?: WorkflowRunStatus[] | string;
|
|
44
|
+
excludeStatus?: WorkflowRunStatus;
|
|
45
|
+
triggerType?: WorkflowRunTriggerType;
|
|
46
|
+
triggerTypes?: WorkflowRunTriggerType[] | string;
|
|
47
|
+
fromDate?: string | Date;
|
|
48
|
+
toDate?: string | Date;
|
|
81
49
|
minCost?: number;
|
|
82
50
|
maxCost?: number;
|
|
83
51
|
minDuration?: number;
|
|
84
52
|
maxDuration?: number;
|
|
85
53
|
search?: string;
|
|
86
54
|
sortBy?: string;
|
|
87
|
-
fields?: string;
|
|
55
|
+
fields?: string[] | string;
|
|
88
56
|
before?: string;
|
|
89
57
|
after?: string;
|
|
90
58
|
limit?: number;
|
|
@@ -92,70 +60,22 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
92
60
|
}, options?: RequestOptions): Promise<PaginatedList>;
|
|
93
61
|
/**
|
|
94
62
|
* Delete a workflow run and its associated step data.
|
|
95
|
-
*
|
|
96
|
-
* @param runId - The ID of the workflow run to delete
|
|
97
|
-
* @param options - Optional request options
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```typescript
|
|
101
|
-
* await client.workflows.runs.delete("run_abc123");
|
|
102
|
-
* ```
|
|
103
63
|
*/
|
|
104
64
|
delete(runId: string, options?: RequestOptions): Promise<void>;
|
|
105
65
|
/**
|
|
106
66
|
* Cancel a running or pending workflow run.
|
|
107
|
-
*
|
|
108
|
-
* @param runId - The ID of the workflow run to cancel
|
|
109
|
-
* @param commandId - Optional idempotency key for deduplicating cancel commands
|
|
110
|
-
* @param options - Optional request options
|
|
111
|
-
* @returns The updated run with cancellation status
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* ```typescript
|
|
115
|
-
* const result = await client.workflows.runs.cancel("run_abc123");
|
|
116
|
-
* console.log(`Cancellation: ${result.cancellation_status}`);
|
|
117
|
-
* ```
|
|
118
67
|
*/
|
|
119
68
|
cancel(runId: string, { commandId }?: {
|
|
120
69
|
commandId?: string;
|
|
121
70
|
}, options?: RequestOptions): Promise<CancelWorkflowResponse>;
|
|
122
71
|
/**
|
|
123
72
|
* Restart a completed or failed workflow run with the same inputs.
|
|
124
|
-
*
|
|
125
|
-
* @param runId - The ID of the workflow run to restart
|
|
126
|
-
* @param commandId - Optional idempotency key for deduplicating restart commands
|
|
127
|
-
* @param options - Optional request options
|
|
128
|
-
* @returns The new workflow run
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* ```typescript
|
|
132
|
-
* const newRun = await client.workflows.runs.restart("run_abc123");
|
|
133
|
-
* console.log(`New run: ${newRun.id}`);
|
|
134
|
-
* ```
|
|
135
73
|
*/
|
|
136
74
|
restart(runId: string, { commandId }?: {
|
|
137
75
|
commandId?: string;
|
|
138
76
|
}, options?: RequestOptions): Promise<WorkflowRun>;
|
|
139
77
|
/**
|
|
140
78
|
* Resume a workflow run after human-in-the-loop (HIL) review.
|
|
141
|
-
*
|
|
142
|
-
* @param runId - The ID of the workflow run to resume
|
|
143
|
-
* @param nodeId - The ID of the HIL node being approved/rejected
|
|
144
|
-
* @param approved - Whether the human approved the data
|
|
145
|
-
* @param modifiedData - Optional modified data if the human made changes
|
|
146
|
-
* @param commandId - Optional idempotency key for deduplicating resume commands
|
|
147
|
-
* @param options - Optional request options
|
|
148
|
-
* @returns The resume response with status and queue information
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* const result = await client.workflows.runs.resume("run_abc123", {
|
|
153
|
-
* nodeId: "hil-node-1",
|
|
154
|
-
* approved: true,
|
|
155
|
-
* modifiedData: { field: "corrected value" },
|
|
156
|
-
* });
|
|
157
|
-
* console.log(`Resume status: ${result.resume_status}`);
|
|
158
|
-
* ```
|
|
159
79
|
*/
|
|
160
80
|
resume(runId: string, { nodeId, approved, modifiedData, commandId, }: {
|
|
161
81
|
nodeId: string;
|
|
@@ -166,58 +86,82 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
166
86
|
/**
|
|
167
87
|
* Poll a workflow run until it reaches a terminal state.
|
|
168
88
|
*
|
|
169
|
-
* Terminal states: "completed", "error", "cancelled".
|
|
89
|
+
* Terminal states: "completed", "error", "cancelled", "waiting_for_human".
|
|
170
90
|
*
|
|
171
91
|
* @param runId - The ID of the workflow run to wait for
|
|
172
92
|
* @param pollIntervalMs - Milliseconds between polls (default: 2000)
|
|
173
93
|
* @param timeoutMs - Maximum time to wait in milliseconds (default: 600000 = 10 minutes)
|
|
174
|
-
* @
|
|
175
|
-
* @throws Error if the run doesn't complete within the timeout
|
|
94
|
+
* @param onStatus - Optional callback invoked with the WorkflowRun on each poll
|
|
176
95
|
*
|
|
177
96
|
* @example
|
|
178
97
|
* ```typescript
|
|
179
98
|
* const run = await client.workflows.runs.waitForCompletion("run_abc123", {
|
|
180
|
-
*
|
|
181
|
-
* timeoutMs: 300000,
|
|
99
|
+
* onStatus: (r) => console.log(`${r.status}...`),
|
|
182
100
|
* });
|
|
183
|
-
* console.log(`Final status: ${run.status}`);
|
|
184
101
|
* ```
|
|
185
102
|
*/
|
|
186
|
-
waitForCompletion(runId: string, { pollIntervalMs, timeoutMs, }?: {
|
|
103
|
+
waitForCompletion(runId: string, { pollIntervalMs, timeoutMs, onStatus, }?: {
|
|
187
104
|
pollIntervalMs?: number;
|
|
188
105
|
timeoutMs?: number;
|
|
106
|
+
onStatus?: (run: WorkflowRun) => void | Promise<void>;
|
|
107
|
+
}): Promise<WorkflowRun>;
|
|
108
|
+
wait_for_completion(runId: string, { poll_interval_ms, timeout_ms, on_status, }?: {
|
|
109
|
+
poll_interval_ms?: number;
|
|
110
|
+
timeout_ms?: number;
|
|
111
|
+
on_status?: (run: WorkflowRun) => void | Promise<void>;
|
|
189
112
|
}): Promise<WorkflowRun>;
|
|
190
113
|
/**
|
|
191
114
|
* Create a workflow run and wait for it to complete.
|
|
192
115
|
*
|
|
193
|
-
* Convenience method that combines create() and waitForCompletion().
|
|
194
|
-
*
|
|
195
|
-
* @param workflowId - The ID of the workflow to run
|
|
196
|
-
* @param documents - Mapping of start node IDs to their input documents
|
|
197
|
-
* @param jsonInputs - Mapping of start_json node IDs to their input JSON data
|
|
198
|
-
* @param pollIntervalMs - Milliseconds between polls (default: 2000)
|
|
199
|
-
* @param timeoutMs - Maximum time to wait in milliseconds (default: 600000)
|
|
200
|
-
* @param options - Optional request options
|
|
201
|
-
* @returns The workflow run in a terminal state
|
|
202
|
-
*
|
|
203
116
|
* @example
|
|
204
117
|
* ```typescript
|
|
118
|
+
* import { raiseForStatus } from "retab";
|
|
119
|
+
*
|
|
205
120
|
* const run = await client.workflows.runs.createAndWait({
|
|
206
121
|
* workflowId: "wf_abc123",
|
|
207
122
|
* documents: { "start-node-1": "./invoice.pdf" },
|
|
208
|
-
*
|
|
123
|
+
* onStatus: (r) => console.log(`${r.status}...`),
|
|
209
124
|
* });
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* }
|
|
125
|
+
* raiseForStatus(run);
|
|
126
|
+
* console.log(run.final_outputs);
|
|
213
127
|
* ```
|
|
214
128
|
*/
|
|
215
|
-
createAndWait({ workflowId, documents, jsonInputs, pollIntervalMs, timeoutMs, }: {
|
|
129
|
+
createAndWait({ workflowId, documents, jsonInputs, pollIntervalMs, timeoutMs, onStatus, }: {
|
|
216
130
|
workflowId: string;
|
|
217
131
|
documents?: Record<string, MIMEDataInput>;
|
|
218
132
|
jsonInputs?: Record<string, Record<string, unknown>>;
|
|
219
133
|
pollIntervalMs?: number;
|
|
220
134
|
timeoutMs?: number;
|
|
135
|
+
onStatus?: (run: WorkflowRun) => void | Promise<void>;
|
|
221
136
|
}, options?: RequestOptions): Promise<WorkflowRun>;
|
|
137
|
+
/**
|
|
138
|
+
* Get the configuration snapshot used for a run.
|
|
139
|
+
*/
|
|
140
|
+
getConfig(runId: string, options?: RequestOptions): Promise<Record<string, unknown>>;
|
|
141
|
+
/**
|
|
142
|
+
* Get the DAG-ordered execution order for a run.
|
|
143
|
+
*/
|
|
144
|
+
executionOrder(runId: string, options?: RequestOptions): Promise<Record<string, unknown>>;
|
|
145
|
+
/**
|
|
146
|
+
* Get a signed URL for downloading a document from a run step.
|
|
147
|
+
*/
|
|
148
|
+
getDocumentUrl(runId: string, nodeId: string, options?: RequestOptions): Promise<Record<string, unknown>>;
|
|
149
|
+
/**
|
|
150
|
+
* Export run results as structured CSV data.
|
|
151
|
+
*
|
|
152
|
+
* @returns Object with `csv_data` (string), `rows` (number), `columns` (number)
|
|
153
|
+
*/
|
|
154
|
+
export({ workflowId, nodeId, exportSource, selectedRunIds, status, excludeStatus, fromDate, toDate, triggerTypes, preferredColumns, }: {
|
|
155
|
+
workflowId: string;
|
|
156
|
+
nodeId: string;
|
|
157
|
+
exportSource?: "outputs" | "inputs";
|
|
158
|
+
selectedRunIds?: string[];
|
|
159
|
+
status?: string;
|
|
160
|
+
excludeStatus?: string;
|
|
161
|
+
fromDate?: string | Date;
|
|
162
|
+
toDate?: string | Date;
|
|
163
|
+
triggerTypes?: WorkflowRunTriggerType[];
|
|
164
|
+
preferredColumns?: string[];
|
|
165
|
+
}, options?: RequestOptions): Promise<WorkflowRunExportResponse>;
|
|
222
166
|
}
|
|
223
167
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/workflows/runs/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/workflows/runs/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EACH,aAAa,EAEb,WAAW,EAEX,aAAa,EAEb,sBAAsB,EAEtB,sBAAsB,EAEtB,yBAAyB,EAEzB,iBAAiB,EACjB,sBAAsB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,mBAAmB,MAAM,mBAAmB,CAAC;AAyBpD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,iBAAiB;IACnD,KAAK,EAAE,mBAAmB,CAAC;gBAEtB,MAAM,EAAE,iBAAiB;IAKrC;;;;;;;;;;;;;;OAcG;IACG,MAAM,CACR,EACI,UAAU,EACV,SAAS,EACT,UAAU,GACb,EAAE;QACC,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,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,CAChB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IASnC;;;;OAIG;IACG,MAAM,CACR,EACI,UAAU,EACV,MAAM,EACN,YAAwB,EACxB,cAAc,EACd,MAAM,EACN,aAAa,EACb,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,gBAAgB,GACnB,EAAE;QACC,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;QACpC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,YAAY,CAAC,EAAE,sBAAsB,EAAE,CAAC;QACxC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC/B,EACD,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,yBAAyB,CAAC;CAuBxC"}
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
1
2
|
import { CompositionClient } from "../../../client.js";
|
|
2
|
-
import { ZMIMEData, ZWorkflowRun, ZPaginatedList, ZCancelWorkflowResponse, ZResumeWorkflowResponse, } from "../../../types.js";
|
|
3
|
+
import { ZMIMEData, ZWorkflowRun, ZPaginatedList, ZCancelWorkflowResponse, ZResumeWorkflowResponse, ZWorkflowRunExportResponse, } from "../../../types.js";
|
|
3
4
|
import APIWorkflowRunSteps from "./steps/client.js";
|
|
4
5
|
const TERMINAL_STATUSES = new Set(["completed", "error", "cancelled"]);
|
|
6
|
+
function normalizeCsvParam(value) {
|
|
7
|
+
if (value === undefined) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
return Array.isArray(value) ? value.join(",") : value;
|
|
11
|
+
}
|
|
12
|
+
function normalizeDateParam(value) {
|
|
13
|
+
if (value === undefined) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
if (value instanceof Date) {
|
|
17
|
+
return value.toISOString().slice(0, 10);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
5
21
|
function sleep(ms) {
|
|
6
22
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
23
|
}
|
|
@@ -9,7 +25,7 @@ function sleep(ms) {
|
|
|
9
25
|
* Workflow Runs API client for managing workflow executions.
|
|
10
26
|
*
|
|
11
27
|
* Sub-clients:
|
|
12
|
-
* - steps: Step output operations (get, list)
|
|
28
|
+
* - steps: Step output operations (get, list, getMany, getAll)
|
|
13
29
|
*/
|
|
14
30
|
export default class APIWorkflowRuns extends CompositionClient {
|
|
15
31
|
constructor(client) {
|
|
@@ -23,24 +39,12 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
23
39
|
* The returned WorkflowRun will have status "running" - use get()
|
|
24
40
|
* to check for updates on the run status.
|
|
25
41
|
*
|
|
26
|
-
* @param workflowId - The ID of the workflow to run
|
|
27
|
-
* @param documents - Mapping of start node IDs to their input documents
|
|
28
|
-
* @param jsonInputs - Mapping of start_json node IDs to their input JSON data
|
|
29
|
-
* @param options - Optional request options
|
|
30
|
-
* @returns The created workflow run with status "running"
|
|
31
|
-
*
|
|
32
42
|
* @example
|
|
33
43
|
* ```typescript
|
|
34
44
|
* const run = await client.workflows.runs.create({
|
|
35
45
|
* workflowId: "wf_abc123",
|
|
36
|
-
* documents: {
|
|
37
|
-
* "start-node-1": "./invoice.pdf",
|
|
38
|
-
* },
|
|
39
|
-
* jsonInputs: {
|
|
40
|
-
* "json-node-1": { key: "value" },
|
|
41
|
-
* },
|
|
46
|
+
* documents: { "start-node-1": "./invoice.pdf" },
|
|
42
47
|
* });
|
|
43
|
-
* console.log(`Run started: ${run.id}, status: ${run.status}`);
|
|
44
48
|
* ```
|
|
45
49
|
*/
|
|
46
50
|
async create({ workflowId, documents, jsonInputs, }, options) {
|
|
@@ -73,16 +77,6 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
75
79
|
* Get a workflow run by ID.
|
|
76
|
-
*
|
|
77
|
-
* @param runId - The ID of the workflow run to retrieve
|
|
78
|
-
* @param options - Optional request options
|
|
79
|
-
* @returns The workflow run
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const run = await client.workflows.runs.get("run_abc123");
|
|
84
|
-
* console.log(`Run status: ${run.status}`);
|
|
85
|
-
* ```
|
|
86
80
|
*/
|
|
87
81
|
async get(runId, options) {
|
|
88
82
|
return this._fetchJson(ZWorkflowRun, {
|
|
@@ -94,35 +88,25 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
94
88
|
}
|
|
95
89
|
/**
|
|
96
90
|
* List workflow runs with filtering and pagination.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```typescript
|
|
100
|
-
* const runs = await client.workflows.runs.list({
|
|
101
|
-
* workflowId: "wf_abc123",
|
|
102
|
-
* status: "completed",
|
|
103
|
-
* limit: 10,
|
|
104
|
-
* });
|
|
105
|
-
* console.log(`Found ${runs.data.length} runs`);
|
|
106
|
-
* ```
|
|
107
91
|
*/
|
|
108
92
|
async list({ workflowId, status, statuses, excludeStatus, triggerType, triggerTypes, fromDate, toDate, minCost, maxCost, minDuration, maxDuration, search, sortBy, fields, before, after, limit = 20, order = "desc", } = {}, options) {
|
|
109
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
94
|
const params = {
|
|
111
95
|
workflow_id: workflowId,
|
|
112
96
|
status,
|
|
113
|
-
statuses,
|
|
97
|
+
statuses: normalizeCsvParam(statuses),
|
|
114
98
|
exclude_status: excludeStatus,
|
|
115
99
|
trigger_type: triggerType,
|
|
116
|
-
trigger_types: triggerTypes,
|
|
117
|
-
from_date: fromDate,
|
|
118
|
-
to_date: toDate,
|
|
100
|
+
trigger_types: normalizeCsvParam(triggerTypes),
|
|
101
|
+
from_date: normalizeDateParam(fromDate),
|
|
102
|
+
to_date: normalizeDateParam(toDate),
|
|
119
103
|
min_cost: minCost,
|
|
120
104
|
max_cost: maxCost,
|
|
121
105
|
min_duration: minDuration,
|
|
122
106
|
max_duration: maxDuration,
|
|
123
107
|
search,
|
|
124
108
|
sort_by: sortBy,
|
|
125
|
-
fields,
|
|
109
|
+
fields: normalizeCsvParam(fields),
|
|
126
110
|
before,
|
|
127
111
|
after,
|
|
128
112
|
limit,
|
|
@@ -138,14 +122,6 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
138
122
|
}
|
|
139
123
|
/**
|
|
140
124
|
* Delete a workflow run and its associated step data.
|
|
141
|
-
*
|
|
142
|
-
* @param runId - The ID of the workflow run to delete
|
|
143
|
-
* @param options - Optional request options
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```typescript
|
|
147
|
-
* await client.workflows.runs.delete("run_abc123");
|
|
148
|
-
* ```
|
|
149
125
|
*/
|
|
150
126
|
async delete(runId, options) {
|
|
151
127
|
return this._fetchJson({
|
|
@@ -157,17 +133,6 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
157
133
|
}
|
|
158
134
|
/**
|
|
159
135
|
* Cancel a running or pending workflow run.
|
|
160
|
-
*
|
|
161
|
-
* @param runId - The ID of the workflow run to cancel
|
|
162
|
-
* @param commandId - Optional idempotency key for deduplicating cancel commands
|
|
163
|
-
* @param options - Optional request options
|
|
164
|
-
* @returns The updated run with cancellation status
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* ```typescript
|
|
168
|
-
* const result = await client.workflows.runs.cancel("run_abc123");
|
|
169
|
-
* console.log(`Cancellation: ${result.cancellation_status}`);
|
|
170
|
-
* ```
|
|
171
136
|
*/
|
|
172
137
|
async cancel(runId, { commandId } = {}, options) {
|
|
173
138
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -184,17 +149,6 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
184
149
|
}
|
|
185
150
|
/**
|
|
186
151
|
* Restart a completed or failed workflow run with the same inputs.
|
|
187
|
-
*
|
|
188
|
-
* @param runId - The ID of the workflow run to restart
|
|
189
|
-
* @param commandId - Optional idempotency key for deduplicating restart commands
|
|
190
|
-
* @param options - Optional request options
|
|
191
|
-
* @returns The new workflow run
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```typescript
|
|
195
|
-
* const newRun = await client.workflows.runs.restart("run_abc123");
|
|
196
|
-
* console.log(`New run: ${newRun.id}`);
|
|
197
|
-
* ```
|
|
198
152
|
*/
|
|
199
153
|
async restart(runId, { commandId } = {}, options) {
|
|
200
154
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -211,24 +165,6 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
211
165
|
}
|
|
212
166
|
/**
|
|
213
167
|
* Resume a workflow run after human-in-the-loop (HIL) review.
|
|
214
|
-
*
|
|
215
|
-
* @param runId - The ID of the workflow run to resume
|
|
216
|
-
* @param nodeId - The ID of the HIL node being approved/rejected
|
|
217
|
-
* @param approved - Whether the human approved the data
|
|
218
|
-
* @param modifiedData - Optional modified data if the human made changes
|
|
219
|
-
* @param commandId - Optional idempotency key for deduplicating resume commands
|
|
220
|
-
* @param options - Optional request options
|
|
221
|
-
* @returns The resume response with status and queue information
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* ```typescript
|
|
225
|
-
* const result = await client.workflows.runs.resume("run_abc123", {
|
|
226
|
-
* nodeId: "hil-node-1",
|
|
227
|
-
* approved: true,
|
|
228
|
-
* modifiedData: { field: "corrected value" },
|
|
229
|
-
* });
|
|
230
|
-
* console.log(`Resume status: ${result.resume_status}`);
|
|
231
|
-
* ```
|
|
232
168
|
*/
|
|
233
169
|
async resume(runId, { nodeId, approved, modifiedData, commandId, }, options) {
|
|
234
170
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -251,24 +187,21 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
251
187
|
/**
|
|
252
188
|
* Poll a workflow run until it reaches a terminal state.
|
|
253
189
|
*
|
|
254
|
-
* Terminal states: "completed", "error", "cancelled".
|
|
190
|
+
* Terminal states: "completed", "error", "cancelled", "waiting_for_human".
|
|
255
191
|
*
|
|
256
192
|
* @param runId - The ID of the workflow run to wait for
|
|
257
193
|
* @param pollIntervalMs - Milliseconds between polls (default: 2000)
|
|
258
194
|
* @param timeoutMs - Maximum time to wait in milliseconds (default: 600000 = 10 minutes)
|
|
259
|
-
* @
|
|
260
|
-
* @throws Error if the run doesn't complete within the timeout
|
|
195
|
+
* @param onStatus - Optional callback invoked with the WorkflowRun on each poll
|
|
261
196
|
*
|
|
262
197
|
* @example
|
|
263
198
|
* ```typescript
|
|
264
199
|
* const run = await client.workflows.runs.waitForCompletion("run_abc123", {
|
|
265
|
-
*
|
|
266
|
-
* timeoutMs: 300000,
|
|
200
|
+
* onStatus: (r) => console.log(`${r.status}...`),
|
|
267
201
|
* });
|
|
268
|
-
* console.log(`Final status: ${run.status}`);
|
|
269
202
|
* ```
|
|
270
203
|
*/
|
|
271
|
-
async waitForCompletion(runId, { pollIntervalMs = 2000, timeoutMs = 600000, } = {}) {
|
|
204
|
+
async waitForCompletion(runId, { pollIntervalMs = 2000, timeoutMs = 600000, onStatus, } = {}) {
|
|
272
205
|
if (pollIntervalMs <= 0)
|
|
273
206
|
throw new Error("pollIntervalMs must be positive");
|
|
274
207
|
if (timeoutMs <= 0)
|
|
@@ -276,7 +209,9 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
276
209
|
const deadline = Date.now() + timeoutMs;
|
|
277
210
|
while (true) {
|
|
278
211
|
const run = await this.get(runId);
|
|
279
|
-
if (
|
|
212
|
+
if (onStatus)
|
|
213
|
+
await onStatus(run);
|
|
214
|
+
if (TERMINAL_STATUSES.has(run.status) || run.status === "waiting_for_human") {
|
|
280
215
|
return run;
|
|
281
216
|
}
|
|
282
217
|
if (Date.now() >= deadline) {
|
|
@@ -285,33 +220,97 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
285
220
|
await sleep(pollIntervalMs);
|
|
286
221
|
}
|
|
287
222
|
}
|
|
223
|
+
async wait_for_completion(runId, { poll_interval_ms = 2000, timeout_ms = 600000, on_status, } = {}) {
|
|
224
|
+
return this.waitForCompletion(runId, {
|
|
225
|
+
pollIntervalMs: poll_interval_ms,
|
|
226
|
+
timeoutMs: timeout_ms,
|
|
227
|
+
onStatus: on_status,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
288
230
|
/**
|
|
289
231
|
* Create a workflow run and wait for it to complete.
|
|
290
232
|
*
|
|
291
|
-
* Convenience method that combines create() and waitForCompletion().
|
|
292
|
-
*
|
|
293
|
-
* @param workflowId - The ID of the workflow to run
|
|
294
|
-
* @param documents - Mapping of start node IDs to their input documents
|
|
295
|
-
* @param jsonInputs - Mapping of start_json node IDs to their input JSON data
|
|
296
|
-
* @param pollIntervalMs - Milliseconds between polls (default: 2000)
|
|
297
|
-
* @param timeoutMs - Maximum time to wait in milliseconds (default: 600000)
|
|
298
|
-
* @param options - Optional request options
|
|
299
|
-
* @returns The workflow run in a terminal state
|
|
300
|
-
*
|
|
301
233
|
* @example
|
|
302
234
|
* ```typescript
|
|
235
|
+
* import { raiseForStatus } from "retab";
|
|
236
|
+
*
|
|
303
237
|
* const run = await client.workflows.runs.createAndWait({
|
|
304
238
|
* workflowId: "wf_abc123",
|
|
305
239
|
* documents: { "start-node-1": "./invoice.pdf" },
|
|
306
|
-
*
|
|
240
|
+
* onStatus: (r) => console.log(`${r.status}...`),
|
|
307
241
|
* });
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
* }
|
|
242
|
+
* raiseForStatus(run);
|
|
243
|
+
* console.log(run.final_outputs);
|
|
311
244
|
* ```
|
|
312
245
|
*/
|
|
313
|
-
async createAndWait({ workflowId, documents, jsonInputs, pollIntervalMs = 2000, timeoutMs = 600000, }, options) {
|
|
246
|
+
async createAndWait({ workflowId, documents, jsonInputs, pollIntervalMs = 2000, timeoutMs = 600000, onStatus, }, options) {
|
|
314
247
|
const run = await this.create({ workflowId, documents, jsonInputs }, options);
|
|
315
|
-
return this.waitForCompletion(run.id, { pollIntervalMs, timeoutMs });
|
|
248
|
+
return this.waitForCompletion(run.id, { pollIntervalMs, timeoutMs, onStatus });
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Get the configuration snapshot used for a run.
|
|
252
|
+
*/
|
|
253
|
+
async getConfig(runId, options) {
|
|
254
|
+
return this._fetchJson(z.record(z.any()), {
|
|
255
|
+
url: `/workflows/runs/${runId}/config`,
|
|
256
|
+
method: "GET",
|
|
257
|
+
params: options?.params,
|
|
258
|
+
headers: options?.headers,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Get the DAG-ordered execution order for a run.
|
|
263
|
+
*/
|
|
264
|
+
async executionOrder(runId, options) {
|
|
265
|
+
return this._fetchJson(z.record(z.any()), {
|
|
266
|
+
url: `/workflows/runs/${runId}/execution-order`,
|
|
267
|
+
method: "GET",
|
|
268
|
+
params: options?.params,
|
|
269
|
+
headers: options?.headers,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Get a signed URL for downloading a document from a run step.
|
|
274
|
+
*/
|
|
275
|
+
async getDocumentUrl(runId, nodeId, options) {
|
|
276
|
+
return this._fetchJson(z.record(z.any()), {
|
|
277
|
+
url: `/workflows/runs/${runId}/documents/${nodeId}`,
|
|
278
|
+
method: "GET",
|
|
279
|
+
params: options?.params,
|
|
280
|
+
headers: options?.headers,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Export run results as structured CSV data.
|
|
285
|
+
*
|
|
286
|
+
* @returns Object with `csv_data` (string), `rows` (number), `columns` (number)
|
|
287
|
+
*/
|
|
288
|
+
async export({ workflowId, nodeId, exportSource = "outputs", selectedRunIds, status, excludeStatus, fromDate, toDate, triggerTypes, preferredColumns, }, options) {
|
|
289
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
290
|
+
const body = {
|
|
291
|
+
workflow_id: workflowId,
|
|
292
|
+
node_id: nodeId,
|
|
293
|
+
export_source: exportSource,
|
|
294
|
+
preferred_columns: preferredColumns || [],
|
|
295
|
+
};
|
|
296
|
+
if (selectedRunIds !== undefined)
|
|
297
|
+
body.selected_run_ids = selectedRunIds;
|
|
298
|
+
if (status !== undefined)
|
|
299
|
+
body.status = status;
|
|
300
|
+
if (excludeStatus !== undefined)
|
|
301
|
+
body.exclude_status = excludeStatus;
|
|
302
|
+
if (fromDate !== undefined)
|
|
303
|
+
body.from_date = normalizeDateParam(fromDate);
|
|
304
|
+
if (toDate !== undefined)
|
|
305
|
+
body.to_date = normalizeDateParam(toDate);
|
|
306
|
+
if (triggerTypes !== undefined)
|
|
307
|
+
body.trigger_types = triggerTypes;
|
|
308
|
+
return this._fetchJson(ZWorkflowRunExportResponse, {
|
|
309
|
+
url: "/workflows/runs/export_payload",
|
|
310
|
+
method: "POST",
|
|
311
|
+
body: { ...body, ...(options?.body || {}) },
|
|
312
|
+
params: options?.params,
|
|
313
|
+
headers: options?.headers,
|
|
314
|
+
});
|
|
316
315
|
}
|
|
317
316
|
}
|