@eigenpal/sdk 0.19.1 → 0.20.1
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/generated/index.ts +2 -2
- package/src/generated/sdk.gen.ts +101 -1
- package/src/generated/types.gen.ts +1153 -29
- package/src/resources/automations.ts +216 -2
- package/src/telemetry.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OperationResult } from '../client';
|
|
1
|
+
import type { OperationResult, RequestDispatchOptions } from '../client';
|
|
2
2
|
import type { Client } from '../generated/client';
|
|
3
3
|
import {
|
|
4
4
|
automationsDatasetExport,
|
|
@@ -40,7 +40,10 @@ import type {
|
|
|
40
40
|
UpdateAutomationRequest,
|
|
41
41
|
} from '../generated/types.gen';
|
|
42
42
|
|
|
43
|
-
type Dispatch = <T>(
|
|
43
|
+
type Dispatch = <T>(
|
|
44
|
+
call: () => Promise<OperationResult<T>>,
|
|
45
|
+
options?: RequestDispatchOptions
|
|
46
|
+
) => Promise<T>;
|
|
44
47
|
type SignalOptions = { signal?: AbortSignal };
|
|
45
48
|
type AnyResponse = any;
|
|
46
49
|
|
|
@@ -48,6 +51,7 @@ export type ListAutomationsOptions = NonNullable<AutomationsListData['query']> &
|
|
|
48
51
|
|
|
49
52
|
export class AutomationsResource {
|
|
50
53
|
public readonly dataset: AutomationDatasetResource;
|
|
54
|
+
public readonly datasetReviewRequests: AutomationDatasetReviewRequestsResource;
|
|
51
55
|
public readonly examples: AutomationExamplesResource;
|
|
52
56
|
public readonly evaluators: AutomationEvaluatorsResource;
|
|
53
57
|
public readonly experiments: AutomationExperimentsResource;
|
|
@@ -58,6 +62,7 @@ export class AutomationsResource {
|
|
|
58
62
|
private readonly dispatch: Dispatch
|
|
59
63
|
) {
|
|
60
64
|
this.dataset = new AutomationDatasetResource(client, dispatch);
|
|
65
|
+
this.datasetReviewRequests = new AutomationDatasetReviewRequestsResource(client, dispatch);
|
|
61
66
|
this.examples = new AutomationExamplesResource(client, dispatch);
|
|
62
67
|
this.evaluators = new AutomationEvaluatorsResource(client, dispatch);
|
|
63
68
|
this.experiments = new AutomationExperimentsResource(client, dispatch);
|
|
@@ -472,3 +477,212 @@ export class AutomationExperimentsResource {
|
|
|
472
477
|
);
|
|
473
478
|
}
|
|
474
479
|
}
|
|
480
|
+
|
|
481
|
+
type DatasetReviewItemStatus = 'pending' | 'approved' | 'edited' | 'rejected';
|
|
482
|
+
type DatasetReviewItemAction =
|
|
483
|
+
| 'approve'
|
|
484
|
+
| 'edit'
|
|
485
|
+
| 'reject'
|
|
486
|
+
| 'reopen'
|
|
487
|
+
| 'comment'
|
|
488
|
+
| 'field-decision';
|
|
489
|
+
|
|
490
|
+
function datasetReviewRequestsBaseUrl(automationId: string): string {
|
|
491
|
+
return `/v1/automations/${automationId}/dataset-review-requests`;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function joinCsv(values: string | readonly string[] | undefined): string | undefined {
|
|
495
|
+
if (values === undefined) return undefined;
|
|
496
|
+
if (typeof values === 'string') return values;
|
|
497
|
+
return values.join(',');
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
export type ListDatasetReviewRequestsOptions = SignalOptions & {
|
|
501
|
+
status?: string | readonly string[];
|
|
502
|
+
limit?: number;
|
|
503
|
+
offset?: number;
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
export type DatasetReviewFocusField = {
|
|
507
|
+
path: string;
|
|
508
|
+
reason?: string | null;
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
export type DatasetReviewCreateItemNote = {
|
|
512
|
+
exampleName: string;
|
|
513
|
+
comment?: string | null;
|
|
514
|
+
fields?: Array<{ path: string; comment: string }>;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
export type CreateDatasetReviewRequestBody = {
|
|
518
|
+
title: string;
|
|
519
|
+
exampleNames: string[];
|
|
520
|
+
instructions?: string | null;
|
|
521
|
+
focusFields?: DatasetReviewFocusField[];
|
|
522
|
+
ignoredFields?: string[];
|
|
523
|
+
itemNotes?: DatasetReviewCreateItemNote[];
|
|
524
|
+
status?: 'draft' | 'open' | 'paused';
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
export type UpdateDatasetReviewRequestBody = {
|
|
528
|
+
title?: string;
|
|
529
|
+
instructions?: string | null;
|
|
530
|
+
focusFields?: DatasetReviewFocusField[];
|
|
531
|
+
ignoredFields?: string[];
|
|
532
|
+
status?: 'draft' | 'open' | 'paused' | 'closed';
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
export type UpdateDatasetReviewItemBody = {
|
|
536
|
+
action: DatasetReviewItemAction;
|
|
537
|
+
expected?: unknown;
|
|
538
|
+
comment?: string | null;
|
|
539
|
+
fieldPath?: string | null;
|
|
540
|
+
/** Field decision for `field-decision`; pass `null` to clear. */
|
|
541
|
+
decision?: 'approved' | 'rejected' | null;
|
|
542
|
+
expectedUpdatedAt: string;
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
export class AutomationDatasetReviewRequestsResource {
|
|
546
|
+
constructor(
|
|
547
|
+
private readonly client: Client,
|
|
548
|
+
private readonly dispatch: Dispatch
|
|
549
|
+
) {}
|
|
550
|
+
|
|
551
|
+
async list(
|
|
552
|
+
automationId: string,
|
|
553
|
+
options: ListDatasetReviewRequestsOptions = {}
|
|
554
|
+
): Promise<AnyResponse> {
|
|
555
|
+
const { signal, status, limit, offset } = options;
|
|
556
|
+
const query = {
|
|
557
|
+
status: joinCsv(status),
|
|
558
|
+
limit,
|
|
559
|
+
offset,
|
|
560
|
+
};
|
|
561
|
+
return this.dispatch(
|
|
562
|
+
() =>
|
|
563
|
+
this.client.get({
|
|
564
|
+
url: datasetReviewRequestsBaseUrl(automationId),
|
|
565
|
+
query,
|
|
566
|
+
signal,
|
|
567
|
+
}) as Promise<OperationResult<AnyResponse>>
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
async create(
|
|
572
|
+
automationId: string,
|
|
573
|
+
body: CreateDatasetReviewRequestBody,
|
|
574
|
+
options: SignalOptions = {}
|
|
575
|
+
): Promise<AnyResponse> {
|
|
576
|
+
return this.dispatch(
|
|
577
|
+
() =>
|
|
578
|
+
this.client.post({
|
|
579
|
+
url: datasetReviewRequestsBaseUrl(automationId),
|
|
580
|
+
body: body as never,
|
|
581
|
+
signal: options.signal,
|
|
582
|
+
}) as Promise<OperationResult<AnyResponse>>
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
async get(
|
|
587
|
+
automationId: string,
|
|
588
|
+
reviewId: string,
|
|
589
|
+
options: SignalOptions = {}
|
|
590
|
+
): Promise<AnyResponse> {
|
|
591
|
+
return this.dispatch(
|
|
592
|
+
() =>
|
|
593
|
+
this.client.get({
|
|
594
|
+
url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}`,
|
|
595
|
+
signal: options.signal,
|
|
596
|
+
}) as Promise<OperationResult<AnyResponse>>
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
async update(
|
|
601
|
+
automationId: string,
|
|
602
|
+
reviewId: string,
|
|
603
|
+
body: UpdateDatasetReviewRequestBody,
|
|
604
|
+
options: SignalOptions = {}
|
|
605
|
+
): Promise<AnyResponse> {
|
|
606
|
+
return this.dispatch(
|
|
607
|
+
() =>
|
|
608
|
+
this.client.patch({
|
|
609
|
+
url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}`,
|
|
610
|
+
body: body as never,
|
|
611
|
+
signal: options.signal,
|
|
612
|
+
}) as Promise<OperationResult<AnyResponse>>
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
async listItems(
|
|
617
|
+
automationId: string,
|
|
618
|
+
reviewId: string,
|
|
619
|
+
options: SignalOptions & { status?: string | readonly DatasetReviewItemStatus[] } = {}
|
|
620
|
+
): Promise<AnyResponse> {
|
|
621
|
+
const { signal, status } = options;
|
|
622
|
+
return this.dispatch(
|
|
623
|
+
() =>
|
|
624
|
+
this.client.get({
|
|
625
|
+
url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}/items`,
|
|
626
|
+
query: { status: joinCsv(status) },
|
|
627
|
+
signal,
|
|
628
|
+
}) as Promise<OperationResult<AnyResponse>>
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
async updateItem(
|
|
633
|
+
automationId: string,
|
|
634
|
+
reviewId: string,
|
|
635
|
+
itemId: string,
|
|
636
|
+
body: UpdateDatasetReviewItemBody,
|
|
637
|
+
options: SignalOptions = {}
|
|
638
|
+
): Promise<AnyResponse> {
|
|
639
|
+
return this.dispatch(
|
|
640
|
+
() =>
|
|
641
|
+
this.client.patch({
|
|
642
|
+
url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}/items/${itemId}`,
|
|
643
|
+
body: body as never,
|
|
644
|
+
signal: options.signal,
|
|
645
|
+
}) as Promise<OperationResult<AnyResponse>>
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
async getItemFile(
|
|
650
|
+
automationId: string,
|
|
651
|
+
reviewId: string,
|
|
652
|
+
itemId: string,
|
|
653
|
+
path: string,
|
|
654
|
+
options: SignalOptions = {}
|
|
655
|
+
): Promise<Blob> {
|
|
656
|
+
// Encode per segment: the path comes from snapshot manifests and may
|
|
657
|
+
// contain spaces or unicode; encoding the whole string would escape the
|
|
658
|
+
// separators the route needs to split on.
|
|
659
|
+
const relative = path
|
|
660
|
+
.replace(/^\/+/, '')
|
|
661
|
+
.split('/')
|
|
662
|
+
.map((segment) => encodeURIComponent(segment))
|
|
663
|
+
.join('/');
|
|
664
|
+
return this.dispatch(
|
|
665
|
+
() =>
|
|
666
|
+
this.client.get({
|
|
667
|
+
url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}/items/${itemId}/files/${relative}`,
|
|
668
|
+
parseAs: 'blob',
|
|
669
|
+
signal: options.signal,
|
|
670
|
+
}) as Promise<OperationResult<Blob>>,
|
|
671
|
+
{ responseKind: 'binary' }
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
async events(
|
|
676
|
+
automationId: string,
|
|
677
|
+
reviewId: string,
|
|
678
|
+
options: SignalOptions = {}
|
|
679
|
+
): Promise<AnyResponse> {
|
|
680
|
+
return this.dispatch(
|
|
681
|
+
() =>
|
|
682
|
+
this.client.get({
|
|
683
|
+
url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}/events`,
|
|
684
|
+
signal: options.signal,
|
|
685
|
+
}) as Promise<OperationResult<AnyResponse>>
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
}
|
package/src/telemetry.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
export const SDK_LANGUAGE = 'typescript';
|
|
20
20
|
// Rewritten at publish time by scripts/release/platform/render-sdk-versions.sh.
|
|
21
21
|
// Keep this string literal exactly stable — sed matches on it.
|
|
22
|
-
export const SDK_VERSION = '0.
|
|
22
|
+
export const SDK_VERSION = '0.20.1';
|
|
23
23
|
|
|
24
24
|
function detectRuntime(): string {
|
|
25
25
|
const g = globalThis as unknown as {
|