@retab/node 1.0.90 → 1.0.91
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/jobs/client.d.ts +39 -3
- package/dist/api/jobs/client.d.ts.map +1 -1
- package/dist/api/jobs/client.js +81 -6
- package/dist/api/projects/client.d.ts +1 -4
- package/dist/api/projects/client.d.ts.map +1 -1
- package/dist/api/projects/client.js +1 -7
- package/dist/api/workflows/runs/client.d.ts +171 -1
- package/dist/api/workflows/runs/client.d.ts.map +1 -1
- package/dist/api/workflows/runs/client.js +233 -6
- package/dist/api/workflows/runs/steps/client.d.ts +46 -0
- package/dist/api/workflows/runs/steps/client.d.ts.map +1 -0
- package/dist/api/workflows/runs/steps/client.js +62 -0
- package/dist/generated_types.d.ts +1168 -415
- package/dist/generated_types.d.ts.map +1 -1
- package/dist/generated_types.js +30 -20
- package/dist/types.d.ts +2 -17
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CompositionClient, RequestOptions } from "../../client.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
type JobStatus = "validating" | "queued" | "in_progress" | "completed" | "failed" | "cancelled" | "expired";
|
|
4
|
+
type JobListSource = "api" | "project" | "workflow";
|
|
5
|
+
type JobListOrder = "asc" | "desc";
|
|
4
6
|
type SupportedEndpoint = "/v1/documents/extract" | "/v1/documents/parse" | "/v1/documents/split" | "/v1/documents/classify" | "/v1/schemas/generate" | "/v1/edit/agent/fill" | "/v1/edit/templates/fill" | "/v1/edit/templates/generate" | "/v1/projects/extract";
|
|
5
7
|
declare const ZJobResponse: z.ZodObject<{
|
|
6
8
|
status_code: z.ZodNumber;
|
|
@@ -249,6 +251,12 @@ type JobRetrieveOptions = RequestOptions & {
|
|
|
249
251
|
include_request?: boolean;
|
|
250
252
|
include_response?: boolean;
|
|
251
253
|
};
|
|
254
|
+
type JobWaitForCompletionOptions = RequestOptions & {
|
|
255
|
+
poll_interval_ms?: number;
|
|
256
|
+
timeout_ms?: number;
|
|
257
|
+
include_request?: boolean;
|
|
258
|
+
include_response?: boolean;
|
|
259
|
+
};
|
|
252
260
|
export default class APIJobs extends CompositionClient {
|
|
253
261
|
constructor(client: CompositionClient);
|
|
254
262
|
/**
|
|
@@ -267,20 +275,48 @@ export default class APIJobs extends CompositionClient {
|
|
|
267
275
|
* Retrieve a job by ID.
|
|
268
276
|
*/
|
|
269
277
|
retrieve(job_id: string, options?: JobRetrieveOptions): Promise<Job>;
|
|
278
|
+
/**
|
|
279
|
+
* Retrieve a job by ID including full request and response payloads.
|
|
280
|
+
*/
|
|
281
|
+
retrieveFull(job_id: string, options?: RequestOptions): Promise<Job>;
|
|
282
|
+
/**
|
|
283
|
+
* Poll a job until terminal status, then fetch final payload once.
|
|
284
|
+
*/
|
|
285
|
+
waitForCompletion(job_id: string, options?: JobWaitForCompletionOptions): Promise<Job>;
|
|
270
286
|
/**
|
|
271
287
|
* Cancel a queued or in-progress job.
|
|
272
288
|
*/
|
|
273
289
|
cancel(job_id: string, options?: RequestOptions): Promise<Job>;
|
|
274
290
|
/**
|
|
275
|
-
*
|
|
291
|
+
* Retry a failed, cancelled, or expired job.
|
|
276
292
|
*/
|
|
277
|
-
|
|
293
|
+
retry(job_id: string, options?: RequestOptions): Promise<Job>;
|
|
294
|
+
/**
|
|
295
|
+
* List jobs with pagination and optional filtering.
|
|
296
|
+
*/
|
|
297
|
+
list({ before, after, limit, order, id, status, endpoint, source, project_id, workflow_id, workflow_node_id, model, filename_regex, filename_contains, document_type, from_date, to_date, metadata, include_request, include_response, }?: {
|
|
298
|
+
before?: string;
|
|
278
299
|
after?: string;
|
|
279
300
|
limit?: number;
|
|
301
|
+
order?: JobListOrder;
|
|
302
|
+
id?: string;
|
|
280
303
|
status?: JobStatus;
|
|
304
|
+
endpoint?: SupportedEndpoint;
|
|
305
|
+
source?: JobListSource;
|
|
306
|
+
project_id?: string;
|
|
307
|
+
workflow_id?: string;
|
|
308
|
+
workflow_node_id?: string;
|
|
309
|
+
model?: string;
|
|
310
|
+
filename_regex?: string;
|
|
311
|
+
filename_contains?: string;
|
|
312
|
+
document_type?: string[];
|
|
313
|
+
from_date?: string;
|
|
314
|
+
to_date?: string;
|
|
315
|
+
metadata?: Record<string, string>;
|
|
281
316
|
include_request?: boolean;
|
|
282
317
|
include_response?: boolean;
|
|
283
318
|
}, options?: RequestOptions): Promise<JobListResponse>;
|
|
284
319
|
}
|
|
285
|
-
export { Job, JobListResponse, JobStatus, SupportedEndpoint, JobResponse, JobError };
|
|
320
|
+
export { Job, JobListOrder, JobListResponse, JobListSource, JobStatus, SupportedEndpoint, JobResponse, JobError };
|
|
321
|
+
export { JobRetrieveOptions, JobWaitForCompletionOptions };
|
|
286
322
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/jobs/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,KAAK,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/jobs/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,KAAK,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AAC5G,KAAK,aAAa,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC;AACpD,KAAK,YAAY,GAAG,KAAK,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,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,YAAY,CAAC;QACrB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,SAAS,CAAC;QACnB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;QAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAClC,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;KACzB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;CAoC9D;AAED,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AAClH,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,CAAC"}
|
package/dist/api/jobs/client.js
CHANGED
|
@@ -75,13 +75,13 @@ export default class APIJobs extends CompositionClient {
|
|
|
75
75
|
* Retrieve a job by ID.
|
|
76
76
|
*/
|
|
77
77
|
async retrieve(job_id, options) {
|
|
78
|
+
const include_request = options?.include_request ?? false;
|
|
79
|
+
const include_response = options?.include_response ?? false;
|
|
78
80
|
const params = {
|
|
79
81
|
...(options?.params || {}),
|
|
82
|
+
include_request,
|
|
83
|
+
include_response,
|
|
80
84
|
};
|
|
81
|
-
if (options?.include_request !== undefined)
|
|
82
|
-
params.include_request = options.include_request;
|
|
83
|
-
if (options?.include_response !== undefined)
|
|
84
|
-
params.include_response = options.include_response;
|
|
85
85
|
return this._fetchJson(ZJob, {
|
|
86
86
|
url: `/v1/jobs/${job_id}`,
|
|
87
87
|
method: "GET",
|
|
@@ -89,6 +89,55 @@ export default class APIJobs extends CompositionClient {
|
|
|
89
89
|
headers: options?.headers,
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Retrieve a job by ID including full request and response payloads.
|
|
94
|
+
*/
|
|
95
|
+
async retrieveFull(job_id, options) {
|
|
96
|
+
return this.retrieve(job_id, {
|
|
97
|
+
...options,
|
|
98
|
+
include_request: true,
|
|
99
|
+
include_response: true,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Poll a job until terminal status, then fetch final payload once.
|
|
104
|
+
*/
|
|
105
|
+
async waitForCompletion(job_id, options = {}) {
|
|
106
|
+
const poll_interval_ms = options.poll_interval_ms ?? 2000;
|
|
107
|
+
const timeout_ms = options.timeout_ms ?? 600000;
|
|
108
|
+
const include_request = options.include_request ?? false;
|
|
109
|
+
const include_response = options.include_response ?? true;
|
|
110
|
+
if (poll_interval_ms <= 0)
|
|
111
|
+
throw new Error("poll_interval_ms must be > 0");
|
|
112
|
+
if (timeout_ms <= 0)
|
|
113
|
+
throw new Error("timeout_ms must be > 0");
|
|
114
|
+
const terminal_statuses = new Set(["completed", "failed", "cancelled", "expired"]);
|
|
115
|
+
const started_at_ms = Date.now();
|
|
116
|
+
const deadline_ms = started_at_ms + timeout_ms;
|
|
117
|
+
while (true) {
|
|
118
|
+
const job = await this.retrieve(job_id, {
|
|
119
|
+
...options,
|
|
120
|
+
include_request: false,
|
|
121
|
+
include_response: false,
|
|
122
|
+
});
|
|
123
|
+
if (terminal_statuses.has(job.status)) {
|
|
124
|
+
if (include_request || include_response) {
|
|
125
|
+
return this.retrieve(job_id, {
|
|
126
|
+
...options,
|
|
127
|
+
include_request,
|
|
128
|
+
include_response,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return job;
|
|
132
|
+
}
|
|
133
|
+
const now_ms = Date.now();
|
|
134
|
+
if (now_ms >= deadline_ms) {
|
|
135
|
+
throw new Error(`Timed out waiting for job ${job_id} completion after ${timeout_ms}ms`);
|
|
136
|
+
}
|
|
137
|
+
const sleep_for_ms = Math.min(poll_interval_ms, Math.max(deadline_ms - now_ms, 0));
|
|
138
|
+
await new Promise((resolve) => setTimeout(resolve, sleep_for_ms));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
92
141
|
/**
|
|
93
142
|
* Cancel a queued or in-progress job.
|
|
94
143
|
*/
|
|
@@ -101,13 +150,39 @@ export default class APIJobs extends CompositionClient {
|
|
|
101
150
|
});
|
|
102
151
|
}
|
|
103
152
|
/**
|
|
104
|
-
*
|
|
153
|
+
* Retry a failed, cancelled, or expired job.
|
|
105
154
|
*/
|
|
106
|
-
async
|
|
155
|
+
async retry(job_id, options) {
|
|
156
|
+
return this._fetchJson(ZJob, {
|
|
157
|
+
url: `/v1/jobs/${job_id}/retry`,
|
|
158
|
+
method: "POST",
|
|
159
|
+
params: options?.params,
|
|
160
|
+
headers: options?.headers,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* List jobs with pagination and optional filtering.
|
|
165
|
+
*/
|
|
166
|
+
async list({ before, after, limit = 20, order = "desc", id, status, endpoint, source, project_id, workflow_id, workflow_node_id, model, filename_regex, filename_contains, document_type, from_date, to_date, metadata, include_request, include_response, } = {}, options) {
|
|
107
167
|
const params = {
|
|
168
|
+
before,
|
|
108
169
|
after,
|
|
109
170
|
limit,
|
|
171
|
+
order,
|
|
172
|
+
id,
|
|
110
173
|
status,
|
|
174
|
+
endpoint,
|
|
175
|
+
source,
|
|
176
|
+
project_id,
|
|
177
|
+
workflow_id,
|
|
178
|
+
workflow_node_id,
|
|
179
|
+
model,
|
|
180
|
+
filename_regex,
|
|
181
|
+
filename_contains,
|
|
182
|
+
document_type,
|
|
183
|
+
from_date,
|
|
184
|
+
to_date,
|
|
185
|
+
metadata: metadata ? JSON.stringify(metadata) : undefined,
|
|
111
186
|
include_request,
|
|
112
187
|
include_response,
|
|
113
188
|
};
|
|
@@ -7,16 +7,13 @@ export default class APIProjects extends CompositionClient {
|
|
|
7
7
|
get(projectId: string, options?: RequestOptions): Promise<Project>;
|
|
8
8
|
delete(projectId: string, options?: RequestOptions): Promise<void>;
|
|
9
9
|
publish(projectId: string, origin?: string, options?: RequestOptions): Promise<Project>;
|
|
10
|
-
extract({ project_id, iteration_id, document, model, image_resolution_dpi, n_consensus,
|
|
10
|
+
extract({ project_id, iteration_id, document, model, image_resolution_dpi, n_consensus, metadata, extraction_id }: {
|
|
11
11
|
project_id: string;
|
|
12
12
|
iteration_id?: string;
|
|
13
13
|
document: MIMEDataInput;
|
|
14
14
|
model?: string;
|
|
15
15
|
image_resolution_dpi?: number;
|
|
16
16
|
n_consensus?: number;
|
|
17
|
-
temperature?: number;
|
|
18
|
-
seed?: number;
|
|
19
|
-
store?: boolean;
|
|
20
17
|
metadata?: Record<string, string>;
|
|
21
18
|
extraction_id?: string;
|
|
22
19
|
}, options?: RequestOptions): Promise<RetabParsedChatCompletion>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/projects/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAa,OAAO,EAAmC,oBAAoB,EAAE,aAAa,EAAa,yBAAyB,EAA8B,MAAM,gBAAgB,CAAC;AAE5L,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,iBAAiB;gBAC1C,MAAM,EAAE,i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AM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IASlE,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAWvF,OAAO,CAAC,EACV,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,aAAa,EAChB,EAAE;QACC,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,EAAE,aAAa,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAClC,aAAa,CAAC,EAAE,MAAM,CAAC;KAC1B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;CA2BnE"}
|
|
@@ -47,7 +47,7 @@ export default class APIProjects extends CompositionClient {
|
|
|
47
47
|
headers: options?.headers,
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
async extract({ project_id, iteration_id, document, model, image_resolution_dpi, n_consensus,
|
|
50
|
+
async extract({ project_id, iteration_id, document, model, image_resolution_dpi, n_consensus, metadata, extraction_id }, options) {
|
|
51
51
|
const url = iteration_id ? `/v1/projects/extract/${project_id}/${iteration_id}` : `/v1/projects/extract/${project_id}`;
|
|
52
52
|
// Parse and convert document to blob for multipart form upload
|
|
53
53
|
const parsedDocument = await ZMIMEData.parseAsync(document);
|
|
@@ -61,12 +61,6 @@ export default class APIProjects extends CompositionClient {
|
|
|
61
61
|
bodyParams.image_resolution_dpi = image_resolution_dpi;
|
|
62
62
|
if (n_consensus !== undefined)
|
|
63
63
|
bodyParams.n_consensus = n_consensus;
|
|
64
|
-
if (temperature !== undefined)
|
|
65
|
-
bodyParams.temperature = temperature;
|
|
66
|
-
if (seed !== undefined)
|
|
67
|
-
bodyParams.seed = seed;
|
|
68
|
-
if (store !== undefined)
|
|
69
|
-
bodyParams.store = store;
|
|
70
64
|
// Note: metadata must be JSON-serialized since multipart forms only accept primitive types
|
|
71
65
|
if (metadata !== undefined)
|
|
72
66
|
bodyParams.metadata = JSON.stringify(metadata);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { CompositionClient, RequestOptions } from "../../../client.js";
|
|
2
|
-
import { MIMEDataInput, WorkflowRun } from "../../../types.js";
|
|
2
|
+
import { MIMEDataInput, WorkflowRun, PaginatedList, CancelWorkflowResponse, ResumeWorkflowResponse } from "../../../types.js";
|
|
3
|
+
import APIWorkflowRunSteps from "./steps/client.js";
|
|
3
4
|
/**
|
|
4
5
|
* Workflow Runs API client for managing workflow executions.
|
|
6
|
+
*
|
|
7
|
+
* Sub-clients:
|
|
8
|
+
* - steps: Step output operations (get, getBatch)
|
|
5
9
|
*/
|
|
6
10
|
export default class APIWorkflowRuns extends CompositionClient {
|
|
11
|
+
steps: APIWorkflowRunSteps;
|
|
7
12
|
constructor(client: CompositionClient);
|
|
8
13
|
/**
|
|
9
14
|
* Run a workflow with the provided inputs.
|
|
@@ -56,5 +61,170 @@ export default class APIWorkflowRuns extends CompositionClient {
|
|
|
56
61
|
* ```
|
|
57
62
|
*/
|
|
58
63
|
get(runId: string, options?: RequestOptions): Promise<WorkflowRun>;
|
|
64
|
+
/**
|
|
65
|
+
* List workflow runs with filtering and pagination.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const runs = await client.workflows.runs.list({
|
|
70
|
+
* workflowId: "wf_abc123",
|
|
71
|
+
* status: "completed",
|
|
72
|
+
* limit: 10,
|
|
73
|
+
* });
|
|
74
|
+
* console.log(`Found ${runs.data.length} runs`);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
list({ workflowId, status, statuses, excludeStatus, triggerType, triggerTypes, fromDate, toDate, minCost, maxCost, minDuration, maxDuration, search, sortBy, fields, before, after, limit, order, }?: {
|
|
78
|
+
workflowId?: string;
|
|
79
|
+
status?: "pending" | "running" | "completed" | "error" | "waiting_for_human" | "cancelled";
|
|
80
|
+
statuses?: string;
|
|
81
|
+
excludeStatus?: "pending" | "running" | "completed" | "error" | "waiting_for_human" | "cancelled";
|
|
82
|
+
triggerType?: "manual" | "api" | "schedule" | "webhook" | "restart";
|
|
83
|
+
triggerTypes?: string;
|
|
84
|
+
fromDate?: string;
|
|
85
|
+
toDate?: string;
|
|
86
|
+
minCost?: number;
|
|
87
|
+
maxCost?: number;
|
|
88
|
+
minDuration?: number;
|
|
89
|
+
maxDuration?: number;
|
|
90
|
+
search?: string;
|
|
91
|
+
sortBy?: string;
|
|
92
|
+
fields?: string;
|
|
93
|
+
before?: string;
|
|
94
|
+
after?: string;
|
|
95
|
+
limit?: number;
|
|
96
|
+
order?: "asc" | "desc";
|
|
97
|
+
}, options?: RequestOptions): Promise<PaginatedList>;
|
|
98
|
+
/**
|
|
99
|
+
* Delete a workflow run and its associated step data.
|
|
100
|
+
*
|
|
101
|
+
* @param runId - The ID of the workflow run to delete
|
|
102
|
+
* @param options - Optional request options
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* await client.workflows.runs.delete("run_abc123");
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
delete(runId: string, options?: RequestOptions): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Cancel a running or pending workflow run.
|
|
112
|
+
*
|
|
113
|
+
* @param runId - The ID of the workflow run to cancel
|
|
114
|
+
* @param commandId - Optional idempotency key for deduplicating cancel commands
|
|
115
|
+
* @param options - Optional request options
|
|
116
|
+
* @returns The updated run with cancellation status
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const result = await client.workflows.runs.cancel("run_abc123");
|
|
121
|
+
* console.log(`Cancellation: ${result.cancellation_status}`);
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
cancel(runId: string, { commandId }?: {
|
|
125
|
+
commandId?: string;
|
|
126
|
+
}, options?: RequestOptions): Promise<CancelWorkflowResponse>;
|
|
127
|
+
/**
|
|
128
|
+
* Restart a completed or failed workflow run with the same inputs.
|
|
129
|
+
*
|
|
130
|
+
* @param runId - The ID of the workflow run to restart
|
|
131
|
+
* @param commandId - Optional idempotency key for deduplicating restart commands
|
|
132
|
+
* @param options - Optional request options
|
|
133
|
+
* @returns The new workflow run
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* const newRun = await client.workflows.runs.restart("run_abc123");
|
|
138
|
+
* console.log(`New run: ${newRun.id}`);
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
restart(runId: string, { commandId }?: {
|
|
142
|
+
commandId?: string;
|
|
143
|
+
}, options?: RequestOptions): Promise<WorkflowRun>;
|
|
144
|
+
/**
|
|
145
|
+
* Resume a workflow run after human-in-the-loop (HIL) review.
|
|
146
|
+
*
|
|
147
|
+
* @param runId - The ID of the workflow run to resume
|
|
148
|
+
* @param nodeId - The ID of the HIL node being approved/rejected
|
|
149
|
+
* @param approved - Whether the human approved the data
|
|
150
|
+
* @param modifiedData - Optional modified data if the human made changes
|
|
151
|
+
* @param commandId - Optional idempotency key for deduplicating resume commands
|
|
152
|
+
* @param options - Optional request options
|
|
153
|
+
* @returns The resume response with status and queue information
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const result = await client.workflows.runs.resume("run_abc123", {
|
|
158
|
+
* nodeId: "hil-node-1",
|
|
159
|
+
* approved: true,
|
|
160
|
+
* modifiedData: { field: "corrected value" },
|
|
161
|
+
* });
|
|
162
|
+
* console.log(`Resume status: ${result.resume_status}`);
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
resume(runId: string, { nodeId, approved, modifiedData, commandId, }: {
|
|
166
|
+
nodeId: string;
|
|
167
|
+
approved: boolean;
|
|
168
|
+
modifiedData?: Record<string, unknown> | null;
|
|
169
|
+
commandId?: string;
|
|
170
|
+
}, options?: RequestOptions): Promise<ResumeWorkflowResponse>;
|
|
171
|
+
/**
|
|
172
|
+
* Poll a workflow run until it reaches a terminal state.
|
|
173
|
+
*
|
|
174
|
+
* Terminal states: "completed", "error", "cancelled".
|
|
175
|
+
*
|
|
176
|
+
* @param runId - The ID of the workflow run to wait for
|
|
177
|
+
* @param pollIntervalMs - Milliseconds between polls (default: 2000)
|
|
178
|
+
* @param timeoutMs - Maximum time to wait in milliseconds (default: 600000 = 10 minutes)
|
|
179
|
+
* @returns The workflow run in a terminal state
|
|
180
|
+
* @throws Error if the run doesn't complete within the timeout
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const run = await client.workflows.runs.waitForCompletion("run_abc123", {
|
|
185
|
+
* pollIntervalMs: 1000,
|
|
186
|
+
* timeoutMs: 300000,
|
|
187
|
+
* });
|
|
188
|
+
* console.log(`Final status: ${run.status}`);
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
waitForCompletion(runId: string, { pollIntervalMs, timeoutMs, }?: {
|
|
192
|
+
pollIntervalMs?: number;
|
|
193
|
+
timeoutMs?: number;
|
|
194
|
+
}): Promise<WorkflowRun>;
|
|
195
|
+
/**
|
|
196
|
+
* Create a workflow run and wait for it to complete.
|
|
197
|
+
*
|
|
198
|
+
* Convenience method that combines create() and waitForCompletion().
|
|
199
|
+
*
|
|
200
|
+
* @param workflowId - The ID of the workflow to run
|
|
201
|
+
* @param documents - Mapping of start node IDs to their input documents
|
|
202
|
+
* @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
|
+
* @param pollIntervalMs - Milliseconds between polls (default: 2000)
|
|
205
|
+
* @param timeoutMs - Maximum time to wait in milliseconds (default: 600000)
|
|
206
|
+
* @param options - Optional request options
|
|
207
|
+
* @returns The workflow run in a terminal state
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const run = await client.workflows.runs.createAndWait({
|
|
212
|
+
* workflowId: "wf_abc123",
|
|
213
|
+
* documents: { "start-node-1": "./invoice.pdf" },
|
|
214
|
+
* timeoutMs: 120000,
|
|
215
|
+
* });
|
|
216
|
+
* if (run.status === "completed") {
|
|
217
|
+
* console.log("Outputs:", run.final_outputs);
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
createAndWait({ workflowId, documents, jsonInputs, textInputs, pollIntervalMs, timeoutMs, }: {
|
|
222
|
+
workflowId: string;
|
|
223
|
+
documents?: Record<string, MIMEDataInput>;
|
|
224
|
+
jsonInputs?: Record<string, Record<string, unknown>>;
|
|
225
|
+
textInputs?: Record<string, string>;
|
|
226
|
+
pollIntervalMs?: number;
|
|
227
|
+
timeoutMs?: number;
|
|
228
|
+
}, options?: RequestOptions): Promise<WorkflowRun>;
|
|
59
229
|
}
|
|
60
230
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -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,
|
|
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,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