@eigenpal/sdk 0.25.14 → 1.0.0-rc.2

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.
Files changed (73) hide show
  1. package/README.md +27 -105
  2. package/dist/client.d.ts +164 -0
  3. package/dist/client.js +234 -0
  4. package/dist/core.d.ts +82 -0
  5. package/dist/core.js +311 -0
  6. package/dist/errors.d.ts +64 -0
  7. package/dist/errors.js +132 -0
  8. package/dist/generated/operations.gen.d.ts +336 -0
  9. package/dist/generated/operations.gen.js +135 -0
  10. package/dist/generated/public.gen.d.ts +2 -0
  11. package/dist/generated/public.gen.js +2 -0
  12. package/dist/generated/resources.gen.d.ts +490 -0
  13. package/dist/generated/resources.gen.js +659 -0
  14. package/dist/generated/types.gen.d.ts +2457 -0
  15. package/dist/generated/types.gen.js +2 -0
  16. package/dist/index.d.ts +20 -0
  17. package/dist/index.js +15 -0
  18. package/dist/lib/fetch-body.d.ts +23 -0
  19. package/dist/lib/fetch-body.js +66 -0
  20. package/dist/lib/files.d.ts +134 -0
  21. package/dist/lib/files.js +296 -0
  22. package/dist/lib/upload-app-chunked.d.ts +36 -0
  23. package/dist/lib/upload-app-chunked.js +94 -0
  24. package/dist/lib/upload-limits.d.ts +32 -0
  25. package/dist/lib/upload-limits.js +60 -0
  26. package/dist/lib/upload-presigned-multipart.d.ts +74 -0
  27. package/dist/lib/upload-presigned-multipart.js +212 -0
  28. package/dist/page.d.ts +30 -0
  29. package/dist/page.js +38 -0
  30. package/dist/resources.d.ts +85 -0
  31. package/dist/resources.js +247 -0
  32. package/dist/telemetry.d.ts +20 -0
  33. package/{src/telemetry.ts → dist/telemetry.js} +26 -31
  34. package/dist/upload-file.d.ts +31 -0
  35. package/dist/upload-file.js +286 -0
  36. package/{src/upload.ts → dist/upload.d.ts} +4 -4
  37. package/dist/upload.js +12 -0
  38. package/package.json +19 -15
  39. package/src/client.ts +0 -656
  40. package/src/errors.ts +0 -130
  41. package/src/generated/client/client.gen.ts +0 -277
  42. package/src/generated/client/index.ts +0 -27
  43. package/src/generated/client/types.gen.ts +0 -218
  44. package/src/generated/client/utils.gen.ts +0 -316
  45. package/src/generated/client.gen.ts +0 -18
  46. package/src/generated/core/auth.gen.ts +0 -48
  47. package/src/generated/core/bodySerializer.gen.ts +0 -82
  48. package/src/generated/core/params.gen.ts +0 -178
  49. package/src/generated/core/pathSerializer.gen.ts +0 -171
  50. package/src/generated/core/queryKeySerializer.gen.ts +0 -117
  51. package/src/generated/core/serverSentEvents.gen.ts +0 -242
  52. package/src/generated/core/types.gen.ts +0 -110
  53. package/src/generated/core/utils.gen.ts +0 -140
  54. package/src/generated/index.ts +0 -4
  55. package/src/generated/sdk.gen.ts +0 -1361
  56. package/src/generated/types.gen.ts +0 -9282
  57. package/src/index.ts +0 -120
  58. package/src/lib/fetch-body.ts +0 -92
  59. package/src/lib/files.ts +0 -390
  60. package/src/lib/upload-app-chunked.ts +0 -121
  61. package/src/lib/upload-limits.ts +0 -72
  62. package/src/lib/upload-presigned-multipart.ts +0 -285
  63. package/src/resources/auth.ts +0 -18
  64. package/src/resources/automations.ts +0 -830
  65. package/src/resources/dataset-review-requests.ts +0 -38
  66. package/src/resources/email-servers.ts +0 -95
  67. package/src/resources/files.ts +0 -592
  68. package/src/resources/folders.ts +0 -77
  69. package/src/resources/human-reviews.ts +0 -106
  70. package/src/resources/models.ts +0 -37
  71. package/src/resources/runs.ts +0 -350
  72. package/src/resources/templates.ts +0 -153
  73. package/src/runtime-config.ts +0 -14
@@ -1,830 +0,0 @@
1
- import type { OperationResult, RequestDispatchOptions } from '../client';
2
- import type { Client } from '../generated/client';
3
- import {
4
- automationsDatasetExport,
5
- automationsDatasetImport,
6
- automationsDelete,
7
- automationsEvaluatorsGet,
8
- automationsEvaluatorsUpdate,
9
- automationsExamplesCreate,
10
- automationsExamplesDelete,
11
- automationsExamplesGet,
12
- automationsExamplesList,
13
- automationsExamplesRun,
14
- automationsExamplesUpdate,
15
- automationsExperimentsCancel,
16
- automationsExperimentsCreate,
17
- automationsExperimentsCreateStream,
18
- automationsExperimentsExport,
19
- automationsExperimentsExportAll,
20
- automationsExperimentsGet,
21
- automationsExperimentsList,
22
- automationsGet,
23
- automationsList,
24
- automationsReviewsHealth,
25
- automationsSync,
26
- automationsTriggersGet,
27
- automationsUpdate,
28
- automationsVersionsCreate,
29
- automationsVersionsList,
30
- automationsVersionsPromote,
31
- automationsVersionsRestore,
32
- } from '../generated/sdk.gen';
33
- import type {
34
- AutomationDetail,
35
- AutomationsDatasetImportResponse,
36
- AutomationsDatasetReviewRequestsCreateResponse,
37
- AutomationsDatasetReviewRequestsGetResponse,
38
- AutomationsDatasetReviewRequestsListEventsResponse,
39
- AutomationsDatasetReviewRequestsListItemsResponse,
40
- AutomationsDatasetReviewRequestsListResponse,
41
- AutomationsDatasetReviewRequestsUpdateItemResponse,
42
- AutomationsDatasetReviewRequestsUpdateResponse,
43
- AutomationsEvaluatorsGetResponse,
44
- AutomationsEvaluatorsUpdateResponse,
45
- AutomationsExamplesCreateResponse,
46
- AutomationsExamplesDeleteResponse,
47
- AutomationsExamplesGetResponse,
48
- AutomationsExamplesListResponse,
49
- AutomationsExamplesRunResponse,
50
- AutomationsExamplesUpdateResponse,
51
- AutomationsExperimentsCancelResponse,
52
- AutomationsExperimentsCreateResponse,
53
- AutomationsExperimentsGetResponse,
54
- AutomationsExperimentsListResponse,
55
- AutomationsGetResponse,
56
- AutomationsListData,
57
- AutomationsReviewsHealthData,
58
- AutomationsReviewsHealthResponse,
59
- AutomationsSyncResponse,
60
- AutomationsTriggersGetResponse,
61
- AutomationsVersionsCreateResponse,
62
- AutomationsVersionsListResponse,
63
- AutomationsVersionsPromoteResponse,
64
- AutomationsVersionsRestoreResponse,
65
- CreateAutomationVersionRequest,
66
- DeleteAutomationResponse,
67
- ListAutomationsResponse,
68
- UpdateAutomationRequest,
69
- } from '../generated/types.gen';
70
-
71
- type Dispatch = <T>(
72
- call: () => Promise<OperationResult<T>>,
73
- options?: RequestDispatchOptions
74
- ) => Promise<T>;
75
- type SignalOptions = { signal?: AbortSignal };
76
-
77
- export type ListAutomationsOptions = NonNullable<AutomationsListData['query']> & SignalOptions;
78
-
79
- export class AutomationsResource {
80
- public readonly dataset: AutomationDatasetResource;
81
- public readonly datasetReviewRequests: AutomationDatasetReviewRequestsResource;
82
- public readonly examples: AutomationExamplesResource;
83
- public readonly evaluators: AutomationEvaluatorsResource;
84
- public readonly experiments: AutomationExperimentsResource;
85
- public readonly reviews: AutomationReviewsResource;
86
-
87
- constructor(
88
- private readonly client: Client,
89
- private readonly dispatch: Dispatch
90
- ) {
91
- this.dataset = new AutomationDatasetResource(client, dispatch);
92
- this.datasetReviewRequests = new AutomationDatasetReviewRequestsResource(client, dispatch);
93
- this.examples = new AutomationExamplesResource(client, dispatch);
94
- this.evaluators = new AutomationEvaluatorsResource(client, dispatch);
95
- this.experiments = new AutomationExperimentsResource(client, dispatch);
96
- this.reviews = new AutomationReviewsResource(client, dispatch);
97
- }
98
-
99
- async list(options: ListAutomationsOptions = {}): Promise<ListAutomationsResponse> {
100
- const { signal, ...query } = options;
101
- return this.dispatch(() => automationsList({ client: this.client, query, signal }));
102
- }
103
-
104
- async get(id: string, options: SignalOptions = {}): Promise<AutomationsGetResponse> {
105
- return this.dispatch(() =>
106
- automationsGet({ client: this.client, path: { id }, signal: options.signal })
107
- );
108
- }
109
-
110
- /**
111
- * Move a YAML workflow between organizing folders. Agent automations have no
112
- * folder model and are removed by the API.
113
- */
114
- async move(
115
- id: string,
116
- body: UpdateAutomationRequest,
117
- options: SignalOptions = {}
118
- ): Promise<AutomationDetail> {
119
- return this.dispatch(() =>
120
- automationsUpdate({
121
- client: this.client,
122
- path: { id },
123
- body,
124
- signal: options.signal,
125
- })
126
- );
127
- }
128
-
129
- /**
130
- * Delete a workflow or agent automation using the same cleanup as the dashboard.
131
- * Workflows archive the automations registry parent and keep execution history.
132
- * Agents delete the implementation, versions, and builder sessions, archive the
133
- * registry parent, and best-effort-delete agent storage; unified prior runs remain.
134
- */
135
- async delete(id: string, options: SignalOptions = {}): Promise<DeleteAutomationResponse> {
136
- return this.dispatch(() =>
137
- automationsDelete({ client: this.client, path: { id }, signal: options.signal })
138
- );
139
- }
140
-
141
- async versions(
142
- id: string,
143
- options: SignalOptions = {}
144
- ): Promise<AutomationsVersionsListResponse> {
145
- return this.dispatch(() =>
146
- automationsVersionsList({ client: this.client, path: { id }, signal: options.signal })
147
- );
148
- }
149
-
150
- async createVersion(
151
- id: string,
152
- body: CreateAutomationVersionRequest,
153
- options: SignalOptions = {}
154
- ): Promise<AutomationsVersionsCreateResponse> {
155
- return this.dispatch(() =>
156
- automationsVersionsCreate({
157
- client: this.client,
158
- path: { id },
159
- body,
160
- signal: options.signal,
161
- })
162
- );
163
- }
164
-
165
- async restoreVersion(
166
- id: string,
167
- versionId: string,
168
- body: { message?: string } = {},
169
- options: SignalOptions = {}
170
- ): Promise<AutomationsVersionsRestoreResponse> {
171
- return this.dispatch(() =>
172
- automationsVersionsRestore({
173
- client: this.client,
174
- path: { id, versionId },
175
- body,
176
- signal: options.signal,
177
- })
178
- );
179
- }
180
-
181
- async promoteVersion(
182
- id: string,
183
- versionId: string,
184
- options: SignalOptions = {}
185
- ): Promise<AutomationsVersionsPromoteResponse> {
186
- return this.dispatch(() =>
187
- automationsVersionsPromote({
188
- client: this.client,
189
- path: { id, versionId },
190
- signal: options.signal,
191
- })
192
- );
193
- }
194
-
195
- async triggers(id: string, options: SignalOptions = {}): Promise<AutomationsTriggersGetResponse> {
196
- return this.dispatch(() =>
197
- automationsTriggersGet({ client: this.client, path: { id }, signal: options.signal })
198
- );
199
- }
200
-
201
- async sync(id: string, options: SignalOptions = {}): Promise<AutomationsSyncResponse> {
202
- return this.dispatch(() =>
203
- automationsSync({ client: this.client, path: { id }, signal: options.signal })
204
- );
205
- }
206
- }
207
-
208
- type AutomationReviewHealthOptions = NonNullable<AutomationsReviewsHealthData['query']> &
209
- SignalOptions;
210
-
211
- export class AutomationReviewsResource {
212
- constructor(
213
- private readonly client: Client,
214
- private readonly dispatch: Dispatch
215
- ) {}
216
-
217
- async health(
218
- automationId: string,
219
- options: AutomationReviewHealthOptions = {}
220
- ): Promise<AutomationsReviewsHealthResponse> {
221
- const { signal, ...query } = options;
222
- return this.dispatch(() =>
223
- automationsReviewsHealth({
224
- client: this.client,
225
- path: { id: automationId },
226
- query,
227
- signal,
228
- })
229
- );
230
- }
231
- }
232
-
233
- export class AutomationDatasetResource {
234
- constructor(
235
- private readonly client: Client,
236
- private readonly dispatch: Dispatch
237
- ) {}
238
-
239
- async export(
240
- automationId: string,
241
- options: { exampleIds?: string[]; signal?: AbortSignal } = {}
242
- ): Promise<Blob> {
243
- const query = options.exampleIds?.length ? { exampleIds: options.exampleIds.join(',') } : {};
244
- return this.dispatch(
245
- () =>
246
- automationsDatasetExport({
247
- client: this.client,
248
- path: { id: automationId },
249
- query,
250
- signal: options.signal,
251
- }) as Promise<OperationResult<Blob>>
252
- );
253
- }
254
-
255
- async import(
256
- automationId: string,
257
- file: Blob | File,
258
- options: { mode?: 'append' | 'replace'; signal?: AbortSignal } = {}
259
- ): Promise<AutomationsDatasetImportResponse> {
260
- const formData = new FormData();
261
- formData.set('file', file);
262
- formData.set('mode', options.mode ?? 'append');
263
- return this.dispatch(() =>
264
- automationsDatasetImport({
265
- client: this.client,
266
- path: { id: automationId },
267
- body: formData as never,
268
- bodySerializer: null,
269
- headers: { 'Content-Type': null },
270
- signal: options.signal,
271
- })
272
- );
273
- }
274
- }
275
-
276
- export class AutomationExamplesResource {
277
- constructor(
278
- private readonly client: Client,
279
- private readonly dispatch: Dispatch
280
- ) {}
281
-
282
- async list(
283
- automationId: string,
284
- options: {
285
- limit?: number;
286
- offset?: number;
287
- include?: 'full' | 'metadata';
288
- signal?: AbortSignal;
289
- } = {}
290
- ): Promise<AutomationsExamplesListResponse> {
291
- const { signal, ...query } = options;
292
- return this.dispatch(() =>
293
- automationsExamplesList({ client: this.client, path: { id: automationId }, query, signal })
294
- );
295
- }
296
-
297
- async create(
298
- automationId: string,
299
- body: Record<string, unknown>,
300
- options: SignalOptions = {}
301
- ): Promise<AutomationsExamplesCreateResponse> {
302
- return this.dispatch(() =>
303
- automationsExamplesCreate({
304
- client: this.client,
305
- path: { id: automationId },
306
- body: body as never,
307
- signal: options.signal,
308
- })
309
- );
310
- }
311
-
312
- async get(
313
- automationId: string,
314
- exampleId: string,
315
- options: SignalOptions = {}
316
- ): Promise<AutomationsExamplesGetResponse> {
317
- return this.dispatch(() =>
318
- automationsExamplesGet({
319
- client: this.client,
320
- path: { id: automationId, exampleId },
321
- signal: options.signal,
322
- })
323
- );
324
- }
325
-
326
- async update(
327
- automationId: string,
328
- exampleId: string,
329
- body: Record<string, unknown>,
330
- options: SignalOptions = {}
331
- ): Promise<AutomationsExamplesUpdateResponse> {
332
- return this.dispatch(() =>
333
- automationsExamplesUpdate({
334
- client: this.client,
335
- path: { id: automationId, exampleId },
336
- body: body as never,
337
- signal: options.signal,
338
- })
339
- );
340
- }
341
-
342
- async delete(
343
- automationId: string,
344
- exampleId: string,
345
- options: SignalOptions = {}
346
- ): Promise<AutomationsExamplesDeleteResponse> {
347
- return this.dispatch(() =>
348
- automationsExamplesDelete({
349
- client: this.client,
350
- path: { id: automationId, exampleId },
351
- signal: options.signal,
352
- })
353
- );
354
- }
355
-
356
- async run(
357
- automationId: string,
358
- exampleId: string,
359
- options: SignalOptions = {}
360
- ): Promise<AutomationsExamplesRunResponse> {
361
- return this.dispatch(() =>
362
- automationsExamplesRun({
363
- client: this.client,
364
- path: { id: automationId, exampleId },
365
- signal: options.signal,
366
- })
367
- );
368
- }
369
- }
370
-
371
- export class AutomationEvaluatorsResource {
372
- constructor(
373
- private readonly client: Client,
374
- private readonly dispatch: Dispatch
375
- ) {}
376
-
377
- async get(
378
- automationId: string,
379
- options: SignalOptions = {}
380
- ): Promise<AutomationsEvaluatorsGetResponse> {
381
- return this.dispatch(() =>
382
- automationsEvaluatorsGet({
383
- client: this.client,
384
- path: { id: automationId },
385
- signal: options.signal,
386
- })
387
- );
388
- }
389
-
390
- async update(
391
- automationId: string,
392
- yaml: string,
393
- options: SignalOptions = {}
394
- ): Promise<AutomationsEvaluatorsUpdateResponse> {
395
- return this.dispatch(() =>
396
- automationsEvaluatorsUpdate({
397
- client: this.client,
398
- path: { id: automationId },
399
- body: { yaml },
400
- signal: options.signal,
401
- })
402
- );
403
- }
404
- }
405
-
406
- export class AutomationExperimentsResource {
407
- constructor(
408
- private readonly client: Client,
409
- private readonly dispatch: Dispatch
410
- ) {}
411
-
412
- async list(
413
- automationId: string,
414
- options: { limit?: number; offset?: number; signal?: AbortSignal } = {}
415
- ): Promise<AutomationsExperimentsListResponse> {
416
- const { signal, ...query } = options;
417
- return this.dispatch(() =>
418
- automationsExperimentsList({ client: this.client, path: { id: automationId }, query, signal })
419
- );
420
- }
421
-
422
- async create(
423
- automationId: string,
424
- body: Record<string, unknown> = {},
425
- options: SignalOptions = {}
426
- ): Promise<AutomationsExperimentsCreateResponse> {
427
- return this.dispatch(() =>
428
- automationsExperimentsCreate({
429
- client: this.client,
430
- path: { id: automationId },
431
- body: body as never,
432
- signal: options.signal,
433
- })
434
- );
435
- }
436
-
437
- async get(
438
- automationId: string,
439
- experimentId: string,
440
- options: SignalOptions = {}
441
- ): Promise<AutomationsExperimentsGetResponse> {
442
- return this.dispatch(() =>
443
- automationsExperimentsGet({
444
- client: this.client,
445
- path: { id: automationId, experimentId },
446
- signal: options.signal,
447
- })
448
- );
449
- }
450
-
451
- async cancel(
452
- automationId: string,
453
- experimentId: string,
454
- options: SignalOptions = {}
455
- ): Promise<AutomationsExperimentsCancelResponse> {
456
- return this.dispatch(() =>
457
- automationsExperimentsCancel({
458
- client: this.client,
459
- path: { id: automationId, experimentId },
460
- signal: options.signal,
461
- })
462
- );
463
- }
464
-
465
- async export(
466
- automationId: string,
467
- experimentId: string,
468
- options: { format?: 'csv' | 'json'; signal?: AbortSignal } = {}
469
- ): Promise<string> {
470
- return this.dispatch(() =>
471
- automationsExperimentsExport({
472
- client: this.client,
473
- path: { id: automationId, experimentId },
474
- query: { format: options.format ?? 'csv' },
475
- parseAs: 'text',
476
- signal: options.signal,
477
- })
478
- );
479
- }
480
-
481
- async exportAll(
482
- automationId: string,
483
- options: { format?: 'csv' | 'json'; signal?: AbortSignal } = {}
484
- ): Promise<string> {
485
- return this.dispatch(() =>
486
- automationsExperimentsExportAll({
487
- client: this.client,
488
- path: { id: automationId },
489
- query: { format: options.format ?? 'csv' },
490
- parseAs: 'text',
491
- signal: options.signal,
492
- })
493
- );
494
- }
495
-
496
- async createStream(
497
- automationId: string,
498
- body: Record<string, unknown> = {},
499
- options: SignalOptions = {}
500
- ): Promise<ReadableStream<Uint8Array> | null> {
501
- return this.dispatch(
502
- () =>
503
- automationsExperimentsCreateStream({
504
- client: this.client,
505
- path: { id: automationId },
506
- body: body as never,
507
- parseAs: 'stream',
508
- signal: options.signal,
509
- }) as Promise<OperationResult<ReadableStream<Uint8Array> | null>>
510
- );
511
- }
512
- }
513
-
514
- type DatasetReviewItemStatus = 'pending' | 'approved' | 'edited' | 'removed';
515
- type DatasetReviewItemAction =
516
- | 'approve'
517
- | 'edit'
518
- | 'remove'
519
- | 'reopen'
520
- | 'comment'
521
- | 'field-decision'
522
- | 'file-decision'
523
- | 'edit-file';
524
-
525
- function datasetReviewRequestsBaseUrl(automationId: string): string {
526
- return `/v1/automations/${encodeURIComponent(automationId)}/dataset-review-requests`;
527
- }
528
-
529
- function joinCsv(values: string | readonly string[] | undefined): string | undefined {
530
- if (values === undefined) return undefined;
531
- if (typeof values === 'string') return values;
532
- return values.join(',');
533
- }
534
-
535
- export type ListDatasetReviewRequestsOptions = SignalOptions & {
536
- status?: string | readonly string[];
537
- limit?: number;
538
- offset?: number;
539
- };
540
-
541
- export type DatasetReviewFocusField = {
542
- path: string;
543
- reason?: string | null;
544
- };
545
-
546
- export type DatasetReviewCreateItemNote = {
547
- exampleName: string;
548
- comment?: string | null;
549
- fields?: Array<{ path: string; comment: string }>;
550
- };
551
-
552
- export type CreateDatasetReviewRequestBody = {
553
- title: string;
554
- exampleNames: string[];
555
- instructions?: string | null;
556
- focusFields?: DatasetReviewFocusField[];
557
- ignoredFields?: string[];
558
- itemNotes?: DatasetReviewCreateItemNote[];
559
- status?: 'draft' | 'open' | 'paused';
560
- };
561
-
562
- export type UpdateDatasetReviewRequestBody = {
563
- title?: string;
564
- instructions?: string | null;
565
- focusFields?: DatasetReviewFocusField[];
566
- ignoredFields?: string[];
567
- status?: 'draft' | 'open' | 'paused' | 'closed';
568
- };
569
-
570
- export type UpdateDatasetReviewItemBody = {
571
- action: DatasetReviewItemAction;
572
- expected?: unknown;
573
- comment?: string | null;
574
- fieldPath?: string | null;
575
- /** Expected-file path for `file-decision`. */
576
- filePath?: string | null;
577
- /** Field decision for `field-decision`; pass `null` to clear. */
578
- decision?: 'approved' | 'removed' | null;
579
- expectedUpdatedAt: string;
580
- };
581
-
582
- /** One entry of an item's expected-file overlay (`currentExpectedFiles`). */
583
- export type DatasetReviewExpectedFile = {
584
- /** Expected-file path relative to the example `expected/` folder. */
585
- path: string;
586
- /**
587
- * Version id for the current bytes. Empty for snapshot-origin files, which
588
- * resolve by path.
589
- */
590
- fileId: string;
591
- filename: string;
592
- /**
593
- * Whether the current bytes are the snapshotted dataset file, a
594
- * reviewer-corrected version, or a brand-new reviewer upload.
595
- */
596
- origin: 'snapshot' | 'corrected' | 'uploaded';
597
- };
598
-
599
- /** Durable per-expected-file approve/remove, keyed by expected-file path. */
600
- export type DatasetReviewFileDecision = {
601
- decision: 'approved' | 'removed';
602
- comment?: string | null;
603
- reviewerId: string;
604
- updatedAt: string;
605
- };
606
-
607
- export type RecordDatasetReviewItemFileDecisionBody = {
608
- /** Expected-file path the decision applies to. */
609
- filePath: string;
610
- /**
611
- * File decision; pass `null` to clear a recorded decision. A comment
612
- * without a decision is a note — allowed only when a decision exists.
613
- */
614
- decision?: 'approved' | 'removed' | null;
615
- comment?: string | null;
616
- expectedUpdatedAt: string;
617
- };
618
-
619
- export type EditDatasetReviewItemFileOptions = SignalOptions & {
620
- /** Correct an existing expected file. Exactly one of `filePath` / `newPath`. */
621
- filePath?: string;
622
- /** Upload a brand-new expected file. Exactly one of `filePath` / `newPath`. */
623
- newPath?: string;
624
- comment?: string;
625
- expectedUpdatedAt: string;
626
- };
627
-
628
- export class AutomationDatasetReviewRequestsResource {
629
- constructor(
630
- private readonly client: Client,
631
- private readonly dispatch: Dispatch
632
- ) {}
633
-
634
- async list(
635
- automationId: string,
636
- options: ListDatasetReviewRequestsOptions = {}
637
- ): Promise<AutomationsDatasetReviewRequestsListResponse> {
638
- const { signal, status, limit, offset } = options;
639
- const query = {
640
- status: joinCsv(status),
641
- limit,
642
- offset,
643
- };
644
- return this.dispatch(
645
- () =>
646
- this.client.get({
647
- url: datasetReviewRequestsBaseUrl(automationId),
648
- query,
649
- signal,
650
- }) as Promise<OperationResult<AutomationsDatasetReviewRequestsListResponse>>
651
- );
652
- }
653
-
654
- async create(
655
- automationId: string,
656
- body: CreateDatasetReviewRequestBody,
657
- options: SignalOptions = {}
658
- ): Promise<AutomationsDatasetReviewRequestsCreateResponse> {
659
- return this.dispatch(
660
- () =>
661
- this.client.post({
662
- url: datasetReviewRequestsBaseUrl(automationId),
663
- body: body as never,
664
- signal: options.signal,
665
- }) as Promise<OperationResult<AutomationsDatasetReviewRequestsCreateResponse>>
666
- );
667
- }
668
-
669
- async get(
670
- automationId: string,
671
- reviewId: string,
672
- options: SignalOptions = {}
673
- ): Promise<AutomationsDatasetReviewRequestsGetResponse> {
674
- return this.dispatch(
675
- () =>
676
- this.client.get({
677
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}`,
678
- signal: options.signal,
679
- }) as Promise<OperationResult<AutomationsDatasetReviewRequestsGetResponse>>
680
- );
681
- }
682
-
683
- async update(
684
- automationId: string,
685
- reviewId: string,
686
- body: UpdateDatasetReviewRequestBody,
687
- options: SignalOptions = {}
688
- ): Promise<AutomationsDatasetReviewRequestsUpdateResponse> {
689
- return this.dispatch(
690
- () =>
691
- this.client.patch({
692
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}`,
693
- body: body as never,
694
- signal: options.signal,
695
- }) as Promise<OperationResult<AutomationsDatasetReviewRequestsUpdateResponse>>
696
- );
697
- }
698
-
699
- async listItems(
700
- automationId: string,
701
- reviewId: string,
702
- options: SignalOptions & { status?: string | readonly DatasetReviewItemStatus[] } = {}
703
- ): Promise<AutomationsDatasetReviewRequestsListItemsResponse> {
704
- const { signal, status } = options;
705
- return this.dispatch(
706
- () =>
707
- this.client.get({
708
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/items`,
709
- query: { status: joinCsv(status) },
710
- signal,
711
- }) as Promise<OperationResult<AutomationsDatasetReviewRequestsListItemsResponse>>
712
- );
713
- }
714
-
715
- async updateItem(
716
- automationId: string,
717
- reviewId: string,
718
- itemId: string,
719
- body: UpdateDatasetReviewItemBody,
720
- options: SignalOptions = {}
721
- ): Promise<AutomationsDatasetReviewRequestsUpdateItemResponse> {
722
- return this.dispatch(
723
- () =>
724
- this.client.patch({
725
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/items/${encodeURIComponent(itemId)}`,
726
- body: body as never,
727
- signal: options.signal,
728
- }) as Promise<OperationResult<AutomationsDatasetReviewRequestsUpdateItemResponse>>
729
- );
730
- }
731
-
732
- async getItemFile(
733
- automationId: string,
734
- reviewId: string,
735
- itemId: string,
736
- path: string,
737
- options: SignalOptions & { kind?: 'input' | 'expected' } = {}
738
- ): Promise<Blob> {
739
- // Encode per segment: the path comes from snapshot manifests and may
740
- // contain spaces or unicode; encoding the whole string would escape the
741
- // separators the route needs to split on.
742
- const relative = path
743
- .replace(/^\/+/, '')
744
- .split('/')
745
- .map((segment) => encodeURIComponent(segment))
746
- .join('/');
747
- const { kind, signal } = options;
748
- const suffix = kind === 'expected' ? '?kind=expected' : '';
749
- return this.dispatch(
750
- () =>
751
- this.client.get({
752
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/items/${encodeURIComponent(itemId)}/files/${relative}${suffix}`,
753
- parseAs: 'blob',
754
- signal,
755
- }) as Promise<OperationResult<Blob>>,
756
- { responseKind: 'binary' }
757
- );
758
- }
759
-
760
- /**
761
- * Record a per-expected-file approve/remove (or a note) on a review item.
762
- * Pass `decision: null` to clear a recorded decision; a comment without a
763
- * decision is a note and requires an existing decision server-side.
764
- */
765
- async recordItemFileDecision(
766
- automationId: string,
767
- reviewId: string,
768
- itemId: string,
769
- body: RecordDatasetReviewItemFileDecisionBody,
770
- options: SignalOptions = {}
771
- ): Promise<AutomationsDatasetReviewRequestsUpdateItemResponse> {
772
- return this.dispatch(
773
- () =>
774
- this.client.patch({
775
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/items/${encodeURIComponent(itemId)}`,
776
- body: { action: 'file-decision', ...body } as never,
777
- signal: options.signal,
778
- }) as Promise<OperationResult<AutomationsDatasetReviewRequestsUpdateItemResponse>>
779
- );
780
- }
781
-
782
- /**
783
- * Upload corrected bytes for an existing expected file (`filePath`) or a
784
- * brand-new reviewer upload (`newPath`). Multipart-only — mirrors the
785
- * dataset import's FormData passthrough. Replaces the item's expected-file
786
- * overlay entry and records a `file-edited` event.
787
- */
788
- async editItemFile(
789
- automationId: string,
790
- reviewId: string,
791
- itemId: string,
792
- file: Blob | File,
793
- options: EditDatasetReviewItemFileOptions
794
- ): Promise<AutomationsDatasetReviewRequestsUpdateItemResponse> {
795
- const target = options.filePath ?? options.newPath ?? 'file';
796
- const fallbackName = target.split('/').pop() || 'file';
797
- const filename = file instanceof File && file.name ? file.name : fallbackName;
798
- const formData = new FormData();
799
- formData.set('action', 'edit-file');
800
- formData.set('file', file, filename);
801
- if (options.filePath !== undefined) formData.set('filePath', options.filePath);
802
- if (options.newPath !== undefined) formData.set('newPath', options.newPath);
803
- if (options.comment !== undefined) formData.set('comment', options.comment);
804
- formData.set('expectedUpdatedAt', options.expectedUpdatedAt);
805
- return this.dispatch(
806
- () =>
807
- this.client.patch({
808
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/items/${encodeURIComponent(itemId)}`,
809
- body: formData as never,
810
- bodySerializer: null,
811
- headers: { 'Content-Type': null },
812
- signal: options.signal,
813
- }) as Promise<OperationResult<AutomationsDatasetReviewRequestsUpdateItemResponse>>
814
- );
815
- }
816
-
817
- async events(
818
- automationId: string,
819
- reviewId: string,
820
- options: SignalOptions = {}
821
- ): Promise<AutomationsDatasetReviewRequestsListEventsResponse> {
822
- return this.dispatch(
823
- () =>
824
- this.client.get({
825
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/events`,
826
- signal: options.signal,
827
- }) as Promise<OperationResult<AutomationsDatasetReviewRequestsListEventsResponse>>
828
- );
829
- }
830
- }