@retab/node 1.0.84 → 1.0.86

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,6 +6,7 @@ import APIProjects from "./projects/client";
6
6
  import APIExtractions from "./extractions/client";
7
7
  import APIWorkflows from "./workflows/client";
8
8
  import APIEdit from "./edit/client";
9
+ import APIJobs from "./jobs/client";
9
10
  export default class APIV1 extends CompositionClient {
10
11
  constructor(client: AbstractClient);
11
12
  models: APIModels;
@@ -15,5 +16,6 @@ export default class APIV1 extends CompositionClient {
15
16
  extractions: APIExtractions;
16
17
  workflows: APIWorkflows;
17
18
  edit: APIEdit;
19
+ jobs: APIJobs;
18
20
  }
19
21
  //# sourceMappingURL=client.d.ts.map
@@ -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;AAClD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,OAAO,MAAM,eAAe,CAAC;AAEpC,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;IACnC,IAAI,UAAqB;CAC5B"}
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;AAC9C,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,OAAO,MAAM,eAAe,CAAC;AAEpC,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;IACnC,IAAI,UAAqB;IACzB,IAAI,UAAqB;CAC5B"}
@@ -6,6 +6,7 @@ import APIProjects from "./projects/client";
6
6
  import APIExtractions from "./extractions/client";
7
7
  import APIWorkflows from "./workflows/client";
8
8
  import APIEdit from "./edit/client";
9
+ import APIJobs from "./jobs/client";
9
10
  export default class APIV1 extends CompositionClient {
10
11
  constructor(client) {
11
12
  super(client);
@@ -16,5 +17,6 @@ export default class APIV1 extends CompositionClient {
16
17
  this.extractions = new APIExtractions(this);
17
18
  this.workflows = new APIWorkflows(this);
18
19
  this.edit = new APIEdit(this);
20
+ this.jobs = new APIJobs(this);
19
21
  }
20
22
  }
@@ -0,0 +1,280 @@
1
+ import { CompositionClient, RequestOptions } from "../../client.js";
2
+ import * as z from "zod";
3
+ type JobStatus = "validating" | "queued" | "in_progress" | "completed" | "failed" | "cancelled" | "expired";
4
+ 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
+ declare const ZJobResponse: z.ZodObject<{
6
+ status_code: z.ZodNumber;
7
+ body: z.ZodRecord<z.ZodString, z.ZodAny>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ status_code: number;
10
+ body: Record<string, any>;
11
+ }, {
12
+ status_code: number;
13
+ body: Record<string, any>;
14
+ }>;
15
+ type JobResponse = z.infer<typeof ZJobResponse>;
16
+ declare const ZJobError: z.ZodObject<{
17
+ code: z.ZodString;
18
+ message: z.ZodString;
19
+ details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ code: string;
22
+ message: string;
23
+ details?: Record<string, any> | null | undefined;
24
+ }, {
25
+ code: string;
26
+ message: string;
27
+ details?: Record<string, any> | null | undefined;
28
+ }>;
29
+ type JobError = z.infer<typeof ZJobError>;
30
+ declare const ZJob: z.ZodObject<{
31
+ id: z.ZodString;
32
+ object: z.ZodLiteral<"job">;
33
+ status: z.ZodEnum<["validating", "queued", "in_progress", "completed", "failed", "cancelled", "expired"]>;
34
+ endpoint: z.ZodEnum<["/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"]>;
35
+ request: z.ZodRecord<z.ZodString, z.ZodAny>;
36
+ response: z.ZodOptional<z.ZodNullable<z.ZodObject<{
37
+ status_code: z.ZodNumber;
38
+ body: z.ZodRecord<z.ZodString, z.ZodAny>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ status_code: number;
41
+ body: Record<string, any>;
42
+ }, {
43
+ status_code: number;
44
+ body: Record<string, any>;
45
+ }>>>;
46
+ error: z.ZodOptional<z.ZodNullable<z.ZodObject<{
47
+ code: z.ZodString;
48
+ message: z.ZodString;
49
+ details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ code: string;
52
+ message: string;
53
+ details?: Record<string, any> | null | undefined;
54
+ }, {
55
+ code: string;
56
+ message: string;
57
+ details?: Record<string, any> | null | undefined;
58
+ }>>>;
59
+ created_at: z.ZodNumber;
60
+ started_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
61
+ completed_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
62
+ expires_at: z.ZodNumber;
63
+ organization_id: z.ZodString;
64
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ object: "job";
67
+ status: "completed" | "in_progress" | "failed" | "cancelled" | "queued" | "validating" | "expired";
68
+ id: string;
69
+ organization_id: string;
70
+ created_at: number;
71
+ expires_at: number;
72
+ endpoint: "/v1/documents/extract" | "/v1/documents/parse" | "/v1/documents/split" | "/v1/documents/classify" | "/v1/schemas/generate" | "/v1/edit/templates/generate" | "/v1/edit/templates/fill" | "/v1/edit/agent/fill" | "/v1/projects/extract";
73
+ request: Record<string, any>;
74
+ metadata?: Record<string, string> | null | undefined;
75
+ error?: {
76
+ code: string;
77
+ message: string;
78
+ details?: Record<string, any> | null | undefined;
79
+ } | null | undefined;
80
+ started_at?: number | null | undefined;
81
+ completed_at?: number | null | undefined;
82
+ response?: {
83
+ status_code: number;
84
+ body: Record<string, any>;
85
+ } | null | undefined;
86
+ }, {
87
+ object: "job";
88
+ status: "completed" | "in_progress" | "failed" | "cancelled" | "queued" | "validating" | "expired";
89
+ id: string;
90
+ organization_id: string;
91
+ created_at: number;
92
+ expires_at: number;
93
+ endpoint: "/v1/documents/extract" | "/v1/documents/parse" | "/v1/documents/split" | "/v1/documents/classify" | "/v1/schemas/generate" | "/v1/edit/templates/generate" | "/v1/edit/templates/fill" | "/v1/edit/agent/fill" | "/v1/projects/extract";
94
+ request: Record<string, any>;
95
+ metadata?: Record<string, string> | null | undefined;
96
+ error?: {
97
+ code: string;
98
+ message: string;
99
+ details?: Record<string, any> | null | undefined;
100
+ } | null | undefined;
101
+ started_at?: number | null | undefined;
102
+ completed_at?: number | null | undefined;
103
+ response?: {
104
+ status_code: number;
105
+ body: Record<string, any>;
106
+ } | null | undefined;
107
+ }>;
108
+ type Job = z.infer<typeof ZJob>;
109
+ declare const ZJobListResponse: z.ZodObject<{
110
+ object: z.ZodLiteral<"list">;
111
+ data: z.ZodArray<z.ZodObject<{
112
+ id: z.ZodString;
113
+ object: z.ZodLiteral<"job">;
114
+ status: z.ZodEnum<["validating", "queued", "in_progress", "completed", "failed", "cancelled", "expired"]>;
115
+ endpoint: z.ZodEnum<["/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"]>;
116
+ request: z.ZodRecord<z.ZodString, z.ZodAny>;
117
+ response: z.ZodOptional<z.ZodNullable<z.ZodObject<{
118
+ status_code: z.ZodNumber;
119
+ body: z.ZodRecord<z.ZodString, z.ZodAny>;
120
+ }, "strip", z.ZodTypeAny, {
121
+ status_code: number;
122
+ body: Record<string, any>;
123
+ }, {
124
+ status_code: number;
125
+ body: Record<string, any>;
126
+ }>>>;
127
+ error: z.ZodOptional<z.ZodNullable<z.ZodObject<{
128
+ code: z.ZodString;
129
+ message: z.ZodString;
130
+ details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
131
+ }, "strip", z.ZodTypeAny, {
132
+ code: string;
133
+ message: string;
134
+ details?: Record<string, any> | null | undefined;
135
+ }, {
136
+ code: string;
137
+ message: string;
138
+ details?: Record<string, any> | null | undefined;
139
+ }>>>;
140
+ created_at: z.ZodNumber;
141
+ started_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
142
+ completed_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
143
+ expires_at: z.ZodNumber;
144
+ organization_id: z.ZodString;
145
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
146
+ }, "strip", z.ZodTypeAny, {
147
+ object: "job";
148
+ status: "completed" | "in_progress" | "failed" | "cancelled" | "queued" | "validating" | "expired";
149
+ id: string;
150
+ organization_id: string;
151
+ created_at: number;
152
+ expires_at: number;
153
+ endpoint: "/v1/documents/extract" | "/v1/documents/parse" | "/v1/documents/split" | "/v1/documents/classify" | "/v1/schemas/generate" | "/v1/edit/templates/generate" | "/v1/edit/templates/fill" | "/v1/edit/agent/fill" | "/v1/projects/extract";
154
+ request: Record<string, any>;
155
+ metadata?: Record<string, string> | null | undefined;
156
+ error?: {
157
+ code: string;
158
+ message: string;
159
+ details?: Record<string, any> | null | undefined;
160
+ } | null | undefined;
161
+ started_at?: number | null | undefined;
162
+ completed_at?: number | null | undefined;
163
+ response?: {
164
+ status_code: number;
165
+ body: Record<string, any>;
166
+ } | null | undefined;
167
+ }, {
168
+ object: "job";
169
+ status: "completed" | "in_progress" | "failed" | "cancelled" | "queued" | "validating" | "expired";
170
+ id: string;
171
+ organization_id: string;
172
+ created_at: number;
173
+ expires_at: number;
174
+ endpoint: "/v1/documents/extract" | "/v1/documents/parse" | "/v1/documents/split" | "/v1/documents/classify" | "/v1/schemas/generate" | "/v1/edit/templates/generate" | "/v1/edit/templates/fill" | "/v1/edit/agent/fill" | "/v1/projects/extract";
175
+ request: Record<string, any>;
176
+ metadata?: Record<string, string> | null | undefined;
177
+ error?: {
178
+ code: string;
179
+ message: string;
180
+ details?: Record<string, any> | null | undefined;
181
+ } | null | undefined;
182
+ started_at?: number | null | undefined;
183
+ completed_at?: number | null | undefined;
184
+ response?: {
185
+ status_code: number;
186
+ body: Record<string, any>;
187
+ } | null | undefined;
188
+ }>, "many">;
189
+ first_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
190
+ last_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
191
+ has_more: z.ZodBoolean;
192
+ }, "strip", z.ZodTypeAny, {
193
+ object: "list";
194
+ data: {
195
+ object: "job";
196
+ status: "completed" | "in_progress" | "failed" | "cancelled" | "queued" | "validating" | "expired";
197
+ id: string;
198
+ organization_id: string;
199
+ created_at: number;
200
+ expires_at: number;
201
+ endpoint: "/v1/documents/extract" | "/v1/documents/parse" | "/v1/documents/split" | "/v1/documents/classify" | "/v1/schemas/generate" | "/v1/edit/templates/generate" | "/v1/edit/templates/fill" | "/v1/edit/agent/fill" | "/v1/projects/extract";
202
+ request: Record<string, any>;
203
+ metadata?: Record<string, string> | null | undefined;
204
+ error?: {
205
+ code: string;
206
+ message: string;
207
+ details?: Record<string, any> | null | undefined;
208
+ } | null | undefined;
209
+ started_at?: number | null | undefined;
210
+ completed_at?: number | null | undefined;
211
+ response?: {
212
+ status_code: number;
213
+ body: Record<string, any>;
214
+ } | null | undefined;
215
+ }[];
216
+ has_more: boolean;
217
+ first_id?: string | null | undefined;
218
+ last_id?: string | null | undefined;
219
+ }, {
220
+ object: "list";
221
+ data: {
222
+ object: "job";
223
+ status: "completed" | "in_progress" | "failed" | "cancelled" | "queued" | "validating" | "expired";
224
+ id: string;
225
+ organization_id: string;
226
+ created_at: number;
227
+ expires_at: number;
228
+ endpoint: "/v1/documents/extract" | "/v1/documents/parse" | "/v1/documents/split" | "/v1/documents/classify" | "/v1/schemas/generate" | "/v1/edit/templates/generate" | "/v1/edit/templates/fill" | "/v1/edit/agent/fill" | "/v1/projects/extract";
229
+ request: Record<string, any>;
230
+ metadata?: Record<string, string> | null | undefined;
231
+ error?: {
232
+ code: string;
233
+ message: string;
234
+ details?: Record<string, any> | null | undefined;
235
+ } | null | undefined;
236
+ started_at?: number | null | undefined;
237
+ completed_at?: number | null | undefined;
238
+ response?: {
239
+ status_code: number;
240
+ body: Record<string, any>;
241
+ } | null | undefined;
242
+ }[];
243
+ has_more: boolean;
244
+ first_id?: string | null | undefined;
245
+ last_id?: string | null | undefined;
246
+ }>;
247
+ type JobListResponse = z.infer<typeof ZJobListResponse>;
248
+ export default class APIJobs extends CompositionClient {
249
+ constructor(client: CompositionClient);
250
+ /**
251
+ * Create a new asynchronous job.
252
+ *
253
+ * @param endpoint - The API endpoint to call ("/v1/documents/extract" or "/v1/documents/parse")
254
+ * @param request - The full request body for the target endpoint
255
+ * @param metadata - Optional metadata (max 16 pairs; keys ≤64 chars, values ≤512 chars)
256
+ */
257
+ create({ endpoint, request, metadata, }: {
258
+ endpoint: SupportedEndpoint;
259
+ request: Record<string, any>;
260
+ metadata?: Record<string, string>;
261
+ }, options?: RequestOptions): Promise<Job>;
262
+ /**
263
+ * Retrieve a job by ID.
264
+ */
265
+ retrieve(job_id: string, options?: RequestOptions): Promise<Job>;
266
+ /**
267
+ * Cancel a queued or in-progress job.
268
+ */
269
+ cancel(job_id: string, options?: RequestOptions): Promise<Job>;
270
+ /**
271
+ * List jobs with pagination and optional status filtering.
272
+ */
273
+ list({ after, limit, status, }?: {
274
+ after?: string;
275
+ limit?: number;
276
+ status?: JobStatus;
277
+ }, options?: RequestOptions): Promise<JobListResponse>;
278
+ }
279
+ export { Job, JobListResponse, JobStatus, SupportedEndpoint, JobResponse, JobError };
280
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +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;AAG5G,KAAK,iBAAiB,GAChB,uBAAuB,GACvB,qBAAqB,GACrB,qBAAqB,GACrB,wBAAwB,GACxB,sBAAsB,GACtB,qBAAqB,GACrB,yBAAyB,GACzB,6BAA6B,GAC7B,sBAAsB,CAAC;AAG7B,QAAA,MAAM,YAAY;;;;;;;;;EAGhB,CAAC;AACH,KAAK,WAAW,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AAc,GAAG,OAAO,CAAC,GAAG,CAAC;IASpE;;OAEG;IACG,IAAI,CAAC,EACP,KAAK,EACL,KAAU,EACV,MAAM,GACT,GAAE;QACC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,SAAS,CAAC;KACjB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;CAmB9D;AAED,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,114 @@
1
+ import { CompositionClient } from "../../client.js";
2
+ import * as z from "zod";
3
+ // Job response schema
4
+ const ZJobResponse = z.object({
5
+ status_code: z.number(),
6
+ body: z.record(z.any()),
7
+ });
8
+ // Job error schema
9
+ const ZJobError = z.object({
10
+ code: z.string(),
11
+ message: z.string(),
12
+ details: z.record(z.any()).nullable().optional(),
13
+ });
14
+ // Job schema
15
+ const ZJob = z.object({
16
+ id: z.string(),
17
+ object: z.literal("job"),
18
+ status: z.enum(["validating", "queued", "in_progress", "completed", "failed", "cancelled", "expired"]),
19
+ endpoint: z.enum([
20
+ "/v1/documents/extract",
21
+ "/v1/documents/parse",
22
+ "/v1/documents/split",
23
+ "/v1/documents/classify",
24
+ "/v1/schemas/generate",
25
+ "/v1/edit/agent/fill",
26
+ "/v1/edit/templates/fill",
27
+ "/v1/edit/templates/generate",
28
+ "/v1/projects/extract",
29
+ ]),
30
+ request: z.record(z.any()),
31
+ response: ZJobResponse.nullable().optional(),
32
+ error: ZJobError.nullable().optional(),
33
+ created_at: z.number(),
34
+ started_at: z.number().nullable().optional(),
35
+ completed_at: z.number().nullable().optional(),
36
+ expires_at: z.number(),
37
+ organization_id: z.string(),
38
+ metadata: z.record(z.string()).nullable().optional(),
39
+ });
40
+ // Job list response schema
41
+ const ZJobListResponse = z.object({
42
+ object: z.literal("list"),
43
+ data: z.array(ZJob),
44
+ first_id: z.string().nullable().optional(),
45
+ last_id: z.string().nullable().optional(),
46
+ has_more: z.boolean(),
47
+ });
48
+ export default class APIJobs extends CompositionClient {
49
+ constructor(client) {
50
+ super(client);
51
+ }
52
+ /**
53
+ * Create a new asynchronous job.
54
+ *
55
+ * @param endpoint - The API endpoint to call ("/v1/documents/extract" or "/v1/documents/parse")
56
+ * @param request - The full request body for the target endpoint
57
+ * @param metadata - Optional metadata (max 16 pairs; keys ≤64 chars, values ≤512 chars)
58
+ */
59
+ async create({ endpoint, request, metadata, }, options) {
60
+ const body = {
61
+ endpoint,
62
+ request,
63
+ };
64
+ if (metadata !== undefined)
65
+ body.metadata = metadata;
66
+ return this._fetchJson(ZJob, {
67
+ url: "/v1/jobs",
68
+ method: "POST",
69
+ body: { ...body, ...(options?.body || {}) },
70
+ params: options?.params,
71
+ headers: options?.headers,
72
+ });
73
+ }
74
+ /**
75
+ * Retrieve a job by ID.
76
+ */
77
+ async retrieve(job_id, options) {
78
+ return this._fetchJson(ZJob, {
79
+ url: `/v1/jobs/${job_id}`,
80
+ method: "GET",
81
+ params: options?.params,
82
+ headers: options?.headers,
83
+ });
84
+ }
85
+ /**
86
+ * Cancel a queued or in-progress job.
87
+ */
88
+ async cancel(job_id, options) {
89
+ return this._fetchJson(ZJob, {
90
+ url: `/v1/jobs/${job_id}/cancel`,
91
+ method: "POST",
92
+ params: options?.params,
93
+ headers: options?.headers,
94
+ });
95
+ }
96
+ /**
97
+ * List jobs with pagination and optional status filtering.
98
+ */
99
+ async list({ after, limit = 20, status, } = {}, options) {
100
+ const params = {
101
+ after,
102
+ limit,
103
+ status,
104
+ };
105
+ // Remove undefined values
106
+ const cleanParams = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined));
107
+ return this._fetchJson(ZJobListResponse, {
108
+ url: "/v1/jobs",
109
+ method: "GET",
110
+ params: { ...cleanParams, ...(options?.params || {}) },
111
+ headers: options?.headers,
112
+ });
113
+ }
114
+ }
@@ -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,aA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ACzB,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.86",
4
4
  "description": "Retab official Node.js library",
5
5
  "main": "dist/index.js",
6
6
  "exports": {