@eigenpal/sdk 0.25.13 → 1.0.0-rc.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/README.md +27 -105
- package/dist/client.d.ts +164 -0
- package/dist/client.js +234 -0
- package/dist/core.d.ts +82 -0
- package/dist/core.js +311 -0
- package/dist/errors.d.ts +64 -0
- package/dist/errors.js +132 -0
- package/dist/generated/operations.gen.d.ts +336 -0
- package/dist/generated/operations.gen.js +135 -0
- package/dist/generated/public.gen.d.ts +2 -0
- package/dist/generated/public.gen.js +2 -0
- package/dist/generated/resources.gen.d.ts +490 -0
- package/dist/generated/resources.gen.js +659 -0
- package/dist/generated/types.gen.d.ts +2457 -0
- package/dist/generated/types.gen.js +2 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +15 -0
- package/dist/lib/fetch-body.d.ts +23 -0
- package/dist/lib/fetch-body.js +66 -0
- package/dist/lib/files.d.ts +134 -0
- package/dist/lib/files.js +296 -0
- package/dist/lib/upload-app-chunked.d.ts +36 -0
- package/dist/lib/upload-app-chunked.js +94 -0
- package/dist/lib/upload-limits.d.ts +32 -0
- package/dist/lib/upload-limits.js +60 -0
- package/dist/lib/upload-presigned-multipart.d.ts +74 -0
- package/dist/lib/upload-presigned-multipart.js +212 -0
- package/dist/page.d.ts +30 -0
- package/dist/page.js +38 -0
- package/dist/resources.d.ts +85 -0
- package/dist/resources.js +247 -0
- package/dist/telemetry.d.ts +20 -0
- package/{src/telemetry.ts → dist/telemetry.js} +26 -31
- package/dist/upload-file.d.ts +31 -0
- package/dist/upload-file.js +286 -0
- package/{src/upload.ts → dist/upload.d.ts} +4 -4
- package/dist/upload.js +12 -0
- package/package.json +19 -15
- package/src/client.ts +0 -656
- package/src/errors.ts +0 -130
- package/src/generated/client/client.gen.ts +0 -277
- package/src/generated/client/index.ts +0 -27
- package/src/generated/client/types.gen.ts +0 -218
- package/src/generated/client/utils.gen.ts +0 -316
- package/src/generated/client.gen.ts +0 -18
- package/src/generated/core/auth.gen.ts +0 -48
- package/src/generated/core/bodySerializer.gen.ts +0 -82
- package/src/generated/core/params.gen.ts +0 -178
- package/src/generated/core/pathSerializer.gen.ts +0 -171
- package/src/generated/core/queryKeySerializer.gen.ts +0 -117
- package/src/generated/core/serverSentEvents.gen.ts +0 -242
- package/src/generated/core/types.gen.ts +0 -110
- package/src/generated/core/utils.gen.ts +0 -140
- package/src/generated/index.ts +0 -4
- package/src/generated/sdk.gen.ts +0 -1361
- package/src/generated/types.gen.ts +0 -9282
- package/src/index.ts +0 -120
- package/src/lib/fetch-body.ts +0 -92
- package/src/lib/files.ts +0 -390
- package/src/lib/upload-app-chunked.ts +0 -121
- package/src/lib/upload-limits.ts +0 -72
- package/src/lib/upload-presigned-multipart.ts +0 -285
- package/src/resources/auth.ts +0 -18
- package/src/resources/automations.ts +0 -830
- package/src/resources/dataset-review-requests.ts +0 -38
- package/src/resources/email-servers.ts +0 -95
- package/src/resources/files.ts +0 -592
- package/src/resources/folders.ts +0 -77
- package/src/resources/human-reviews.ts +0 -106
- package/src/resources/models.ts +0 -37
- package/src/resources/runs.ts +0 -350
- package/src/resources/templates.ts +0 -153
- package/src/runtime-config.ts +0 -14
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { OperationResult, RequestDispatchOptions } from '../client';
|
|
2
|
-
import type { Client } from '../generated/client';
|
|
3
|
-
import {
|
|
4
|
-
humanReviewsApprove,
|
|
5
|
-
humanReviewsConfirmField,
|
|
6
|
-
humanReviewsFilesContentGet,
|
|
7
|
-
humanReviewsGet,
|
|
8
|
-
humanReviewsList,
|
|
9
|
-
humanReviewsReject,
|
|
10
|
-
} from '../generated/sdk.gen';
|
|
11
|
-
import type {
|
|
12
|
-
HumanReviewsApproveResponse,
|
|
13
|
-
HumanReviewsConfirmFieldData,
|
|
14
|
-
HumanReviewsConfirmFieldResponse,
|
|
15
|
-
HumanReviewsGetResponse,
|
|
16
|
-
HumanReviewsListData,
|
|
17
|
-
HumanReviewsListResponse,
|
|
18
|
-
HumanReviewsRejectResponse,
|
|
19
|
-
} from '../generated/types.gen';
|
|
20
|
-
|
|
21
|
-
type Dispatch = <T>(
|
|
22
|
-
call: () => Promise<OperationResult<T>>,
|
|
23
|
-
options?: RequestDispatchOptions
|
|
24
|
-
) => Promise<T>;
|
|
25
|
-
type SignalOptions = { signal?: AbortSignal };
|
|
26
|
-
|
|
27
|
-
export type ListHumanReviewsOptions = NonNullable<HumanReviewsListData['query']> & SignalOptions;
|
|
28
|
-
export type ConfirmHumanReviewFieldRequest = HumanReviewsConfirmFieldData['body'];
|
|
29
|
-
|
|
30
|
-
export class HumanReviewsResource {
|
|
31
|
-
constructor(
|
|
32
|
-
private readonly client: Client,
|
|
33
|
-
private readonly dispatch: Dispatch
|
|
34
|
-
) {}
|
|
35
|
-
|
|
36
|
-
async list(options: ListHumanReviewsOptions = {}): Promise<HumanReviewsListResponse> {
|
|
37
|
-
const { signal, ...query } = options;
|
|
38
|
-
return this.dispatch(() => humanReviewsList({ client: this.client, query, signal }));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async get(taskId: string, options: SignalOptions = {}): Promise<HumanReviewsGetResponse> {
|
|
42
|
-
return this.dispatch(() =>
|
|
43
|
-
humanReviewsGet({ client: this.client, path: { taskId }, signal: options.signal })
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async approve(
|
|
48
|
-
taskId: string,
|
|
49
|
-
body: { expectedVersion: number },
|
|
50
|
-
options: SignalOptions = {}
|
|
51
|
-
): Promise<HumanReviewsApproveResponse> {
|
|
52
|
-
return this.dispatch(() =>
|
|
53
|
-
humanReviewsApprove({
|
|
54
|
-
client: this.client,
|
|
55
|
-
path: { taskId },
|
|
56
|
-
body,
|
|
57
|
-
signal: options.signal,
|
|
58
|
-
})
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async confirmField(
|
|
63
|
-
taskId: string,
|
|
64
|
-
body: ConfirmHumanReviewFieldRequest,
|
|
65
|
-
options: SignalOptions = {}
|
|
66
|
-
): Promise<HumanReviewsConfirmFieldResponse> {
|
|
67
|
-
return this.dispatch(() =>
|
|
68
|
-
humanReviewsConfirmField({
|
|
69
|
-
client: this.client,
|
|
70
|
-
path: { taskId },
|
|
71
|
-
body,
|
|
72
|
-
signal: options.signal,
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async reject(
|
|
78
|
-
taskId: string,
|
|
79
|
-
body: { reason: string; expectedVersion: number; idempotencyKey: string },
|
|
80
|
-
options: SignalOptions = {}
|
|
81
|
-
): Promise<HumanReviewsRejectResponse> {
|
|
82
|
-
return this.dispatch(() =>
|
|
83
|
-
humanReviewsReject({
|
|
84
|
-
client: this.client,
|
|
85
|
-
path: { taskId },
|
|
86
|
-
body,
|
|
87
|
-
signal: options.signal,
|
|
88
|
-
})
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async downloadFile(taskId: string, fileId: string, options: SignalOptions = {}): Promise<Blob> {
|
|
93
|
-
return this.dispatch(
|
|
94
|
-
async () => {
|
|
95
|
-
const response = await humanReviewsFilesContentGet({
|
|
96
|
-
client: this.client,
|
|
97
|
-
path: { taskId, fileId },
|
|
98
|
-
parseAs: 'blob',
|
|
99
|
-
signal: options.signal,
|
|
100
|
-
});
|
|
101
|
-
return response as OperationResult<Blob>;
|
|
102
|
-
},
|
|
103
|
-
{ responseKind: 'binary' }
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
}
|
package/src/resources/models.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { OperationResult } from '../client';
|
|
2
|
-
import type { Client } from '../generated/client';
|
|
3
|
-
import { modelsList, modelsParserReadiness } from '../generated/sdk.gen';
|
|
4
|
-
import type { ListModelsResponse, ParsingReadiness } from '../generated/types.gen';
|
|
5
|
-
|
|
6
|
-
type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
|
|
7
|
-
type SignalOptions = { signal?: AbortSignal };
|
|
8
|
-
|
|
9
|
-
export class ModelsResource {
|
|
10
|
-
constructor(
|
|
11
|
-
private readonly client: Client,
|
|
12
|
-
private readonly dispatch: Dispatch
|
|
13
|
-
) {}
|
|
14
|
-
|
|
15
|
-
/** Catalog readiness for automatic parsing; run a document probe to verify live health. */
|
|
16
|
-
async parserReadiness(options: SignalOptions = {}): Promise<ParsingReadiness> {
|
|
17
|
-
return this.dispatch(() =>
|
|
18
|
-
modelsParserReadiness({ client: this.client, signal: options.signal })
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* List text, vision, and OCR models configured for this tenant environment.
|
|
24
|
-
* Catalog inventory only — not a live provider health probe.
|
|
25
|
-
*/
|
|
26
|
-
async list(
|
|
27
|
-
options: SignalOptions & { capability?: 'text' | 'vision' | 'ocr' } = {}
|
|
28
|
-
): Promise<ListModelsResponse> {
|
|
29
|
-
return this.dispatch(() =>
|
|
30
|
-
modelsList({
|
|
31
|
-
client: this.client,
|
|
32
|
-
query: { capability: options.capability },
|
|
33
|
-
signal: options.signal,
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
}
|
package/src/resources/runs.ts
DELETED
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import type { OperationResult, RequestDispatchOptions } from '../client';
|
|
2
|
-
import type { Client } from '../generated/client';
|
|
3
|
-
import {
|
|
4
|
-
runsArtifactsGet,
|
|
5
|
-
runsArtifactsList,
|
|
6
|
-
runsCancel,
|
|
7
|
-
runsEventsList,
|
|
8
|
-
runsGet,
|
|
9
|
-
runsList,
|
|
10
|
-
runsPromote,
|
|
11
|
-
runsRerun,
|
|
12
|
-
runsReviewsClear,
|
|
13
|
-
runsReviewsExpectedCreate,
|
|
14
|
-
runsReviewsExpectedFileDelete,
|
|
15
|
-
runsReviewsExpectedFileGet,
|
|
16
|
-
runsReviewsExpectedFileUpdate,
|
|
17
|
-
runsReviewsExpectedGet,
|
|
18
|
-
runsReviewsGet,
|
|
19
|
-
runsReviewsUpdate,
|
|
20
|
-
runsScoresList,
|
|
21
|
-
runsStepsGet,
|
|
22
|
-
runsStepsList,
|
|
23
|
-
runsTraceGet,
|
|
24
|
-
runsUsageGet,
|
|
25
|
-
} from '../generated/sdk.gen';
|
|
26
|
-
import type {
|
|
27
|
-
RunsArtifactsListResponse,
|
|
28
|
-
RunsCancelResponse,
|
|
29
|
-
RunsEventsListResponse,
|
|
30
|
-
RunsGetResponse,
|
|
31
|
-
RunsListData,
|
|
32
|
-
RunsListResponse,
|
|
33
|
-
RunsPromoteResponse,
|
|
34
|
-
RunsRerunResponse,
|
|
35
|
-
RunsReviewsClearResponse,
|
|
36
|
-
RunsReviewsExpectedCreateResponse,
|
|
37
|
-
RunsReviewsExpectedFileDeleteResponse,
|
|
38
|
-
RunsReviewsExpectedFileUpdateResponse,
|
|
39
|
-
RunsReviewsExpectedGetResponse,
|
|
40
|
-
RunsReviewsGetResponse,
|
|
41
|
-
RunsReviewsUpdateResponse,
|
|
42
|
-
RunsScoresListResponse,
|
|
43
|
-
RunsStepsGetResponse,
|
|
44
|
-
RunsStepsListResponse,
|
|
45
|
-
RunsTraceGetResponse,
|
|
46
|
-
RunsUsageGetResponse,
|
|
47
|
-
} from '../generated/types.gen';
|
|
48
|
-
import { buildSingleFileMultipart, type FileInput } from '../lib/files';
|
|
49
|
-
|
|
50
|
-
type Dispatch = <T>(
|
|
51
|
-
call: () => Promise<OperationResult<T>>,
|
|
52
|
-
options?: RequestDispatchOptions
|
|
53
|
-
) => Promise<T>;
|
|
54
|
-
type SignalOptions = { signal?: AbortSignal };
|
|
55
|
-
|
|
56
|
-
export type ListRunsOptions = NonNullable<RunsListData['query']> & { signal?: AbortSignal };
|
|
57
|
-
|
|
58
|
-
export type RunExpandSection = 'input' | 'usage' | 'execution' | 'debug';
|
|
59
|
-
export type RunExpand = readonly RunExpandSection[] | (string & {});
|
|
60
|
-
|
|
61
|
-
function formatExpand(expand: RunExpand | undefined): string | undefined {
|
|
62
|
-
if (expand === undefined) return undefined;
|
|
63
|
-
const joined = typeof expand === 'string' ? expand : expand.join(',');
|
|
64
|
-
return joined.length > 0 ? joined : undefined;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export class RunsResource {
|
|
68
|
-
public readonly artifacts: RunsArtifactsResource;
|
|
69
|
-
public readonly scores: RunsScoresResource;
|
|
70
|
-
public readonly reviews: RunsReviewsResource;
|
|
71
|
-
public readonly trace: RunsTraceResource;
|
|
72
|
-
|
|
73
|
-
constructor(
|
|
74
|
-
private readonly client: Client,
|
|
75
|
-
private readonly dispatch: Dispatch
|
|
76
|
-
) {
|
|
77
|
-
this.artifacts = new RunsArtifactsResource(client, dispatch);
|
|
78
|
-
this.scores = new RunsScoresResource(client, dispatch);
|
|
79
|
-
this.reviews = new RunsReviewsResource(client, dispatch);
|
|
80
|
-
this.trace = new RunsTraceResource(client, dispatch);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async list(options: ListRunsOptions = {}): Promise<RunsListResponse> {
|
|
84
|
-
const { signal, ...query } = options;
|
|
85
|
-
return this.dispatch(() => runsList({ client: this.client, query, signal }));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async get(
|
|
89
|
-
runId: string,
|
|
90
|
-
options: { expand?: RunExpand; signal?: AbortSignal } = {}
|
|
91
|
-
): Promise<RunsGetResponse> {
|
|
92
|
-
const expand = formatExpand(options.expand);
|
|
93
|
-
return this.dispatch(() =>
|
|
94
|
-
runsGet({
|
|
95
|
-
client: this.client,
|
|
96
|
-
path: { id: runId },
|
|
97
|
-
query: expand ? { expand } : {},
|
|
98
|
-
signal: options.signal,
|
|
99
|
-
})
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async cancel(runId: string, options: SignalOptions = {}): Promise<RunsCancelResponse> {
|
|
104
|
-
return this.dispatch(() =>
|
|
105
|
-
runsCancel({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async promote(
|
|
110
|
-
runId: string,
|
|
111
|
-
body: Record<string, unknown> = {},
|
|
112
|
-
options: SignalOptions = {}
|
|
113
|
-
): Promise<RunsPromoteResponse> {
|
|
114
|
-
return this.dispatch(() =>
|
|
115
|
-
runsPromote({
|
|
116
|
-
client: this.client,
|
|
117
|
-
path: { id: runId },
|
|
118
|
-
body: body as never,
|
|
119
|
-
signal: options.signal,
|
|
120
|
-
})
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async rerun(
|
|
125
|
-
runId: string,
|
|
126
|
-
query: { version?: string; wait_for_completion?: number } = {},
|
|
127
|
-
options: SignalOptions = {}
|
|
128
|
-
): Promise<RunsRerunResponse> {
|
|
129
|
-
// Rerun starts a new billed run: never retry it on a lost response.
|
|
130
|
-
return this.dispatch(
|
|
131
|
-
() => runsRerun({ client: this.client, path: { id: runId }, query, signal: options.signal }),
|
|
132
|
-
{ nonIdempotent: true }
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async usage(runId: string, options: SignalOptions = {}): Promise<RunsUsageGetResponse> {
|
|
137
|
-
return this.dispatch(() =>
|
|
138
|
-
runsUsageGet({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async steps(runId: string, options: SignalOptions = {}): Promise<RunsStepsListResponse> {
|
|
143
|
-
return this.dispatch(() =>
|
|
144
|
-
runsStepsList({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async getStep(
|
|
149
|
-
runId: string,
|
|
150
|
-
stepExecutionId: string,
|
|
151
|
-
options: SignalOptions = {}
|
|
152
|
-
): Promise<RunsStepsGetResponse> {
|
|
153
|
-
return this.dispatch(() =>
|
|
154
|
-
runsStepsGet({
|
|
155
|
-
client: this.client,
|
|
156
|
-
path: { id: runId, stepExecutionId },
|
|
157
|
-
signal: options.signal,
|
|
158
|
-
})
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async events(runId: string, options: SignalOptions = {}): Promise<RunsEventsListResponse> {
|
|
163
|
-
return this.dispatch(() =>
|
|
164
|
-
runsEventsList({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function runOutput(run: unknown): unknown {
|
|
170
|
-
return isRecord(run) ? run.output : undefined;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export class RunsArtifactsResource {
|
|
174
|
-
constructor(
|
|
175
|
-
private readonly client: Client,
|
|
176
|
-
private readonly dispatch: Dispatch
|
|
177
|
-
) {}
|
|
178
|
-
|
|
179
|
-
async list(runId: string, options: SignalOptions = {}): Promise<RunsArtifactsListResponse> {
|
|
180
|
-
return this.dispatch(() =>
|
|
181
|
-
runsArtifactsList({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
async download(runId: string, path: string, options: SignalOptions = {}): Promise<Blob> {
|
|
186
|
-
return this.dispatch(async () => {
|
|
187
|
-
const response = await runsArtifactsGet({
|
|
188
|
-
client: this.client,
|
|
189
|
-
path: { id: runId, path },
|
|
190
|
-
signal: options.signal,
|
|
191
|
-
});
|
|
192
|
-
return response as OperationResult<Blob>;
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export class RunsReviewsResource {
|
|
198
|
-
constructor(
|
|
199
|
-
private readonly client: Client,
|
|
200
|
-
private readonly dispatch: Dispatch
|
|
201
|
-
) {}
|
|
202
|
-
|
|
203
|
-
async get(runId: string, options: SignalOptions = {}): Promise<RunsReviewsGetResponse> {
|
|
204
|
-
return this.dispatch(() =>
|
|
205
|
-
runsReviewsGet({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async update(
|
|
210
|
-
runId: string,
|
|
211
|
-
body: Record<string, unknown>,
|
|
212
|
-
options: SignalOptions = {}
|
|
213
|
-
): Promise<RunsReviewsUpdateResponse> {
|
|
214
|
-
return this.dispatch(() =>
|
|
215
|
-
runsReviewsUpdate({
|
|
216
|
-
client: this.client,
|
|
217
|
-
path: { id: runId },
|
|
218
|
-
body: body as never,
|
|
219
|
-
signal: options.signal,
|
|
220
|
-
})
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
async clear(runId: string, options: SignalOptions = {}): Promise<RunsReviewsClearResponse> {
|
|
225
|
-
return this.dispatch(() =>
|
|
226
|
-
runsReviewsClear({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
async listExpected(
|
|
231
|
-
runId: string,
|
|
232
|
-
options: SignalOptions = {}
|
|
233
|
-
): Promise<RunsReviewsExpectedGetResponse> {
|
|
234
|
-
return this.dispatch(() =>
|
|
235
|
-
runsReviewsExpectedGet({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
async copyOutputToExpected(
|
|
240
|
-
runId: string,
|
|
241
|
-
outputFileName: string,
|
|
242
|
-
options: { expectedName?: string; signal?: AbortSignal } = {}
|
|
243
|
-
): Promise<RunsReviewsExpectedCreateResponse> {
|
|
244
|
-
return this.dispatch(() =>
|
|
245
|
-
runsReviewsExpectedCreate({
|
|
246
|
-
client: this.client,
|
|
247
|
-
path: { id: runId },
|
|
248
|
-
body: {
|
|
249
|
-
outputFileName,
|
|
250
|
-
...(options.expectedName ? { expectedName: options.expectedName } : {}),
|
|
251
|
-
},
|
|
252
|
-
signal: options.signal,
|
|
253
|
-
})
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
async uploadExpected(
|
|
258
|
-
runId: string,
|
|
259
|
-
file: FileInput,
|
|
260
|
-
options: { name?: string; signal?: AbortSignal } = {}
|
|
261
|
-
): Promise<RunsReviewsExpectedCreateResponse> {
|
|
262
|
-
const formData = await buildSingleFileMultipart(file, options.name);
|
|
263
|
-
return this.dispatch(
|
|
264
|
-
() =>
|
|
265
|
-
this.client.post({
|
|
266
|
-
url: '/v1/runs/{id}/reviews/expected',
|
|
267
|
-
path: { id: runId },
|
|
268
|
-
body: formData,
|
|
269
|
-
bodySerializer: null,
|
|
270
|
-
headers: { 'Content-Type': null },
|
|
271
|
-
signal: options.signal,
|
|
272
|
-
}) as Promise<OperationResult<RunsReviewsExpectedCreateResponse>>
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
async downloadExpected(
|
|
277
|
-
runId: string,
|
|
278
|
-
filename: string,
|
|
279
|
-
options: SignalOptions = {}
|
|
280
|
-
): Promise<Blob> {
|
|
281
|
-
return this.dispatch(async () => {
|
|
282
|
-
const response = await runsReviewsExpectedFileGet({
|
|
283
|
-
client: this.client,
|
|
284
|
-
path: { id: runId, filename },
|
|
285
|
-
signal: options.signal,
|
|
286
|
-
});
|
|
287
|
-
return response as OperationResult<Blob>;
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
async renameExpected(
|
|
292
|
-
runId: string,
|
|
293
|
-
filename: string,
|
|
294
|
-
newFilename: string,
|
|
295
|
-
options: SignalOptions = {}
|
|
296
|
-
): Promise<RunsReviewsExpectedFileUpdateResponse> {
|
|
297
|
-
return this.dispatch(() =>
|
|
298
|
-
runsReviewsExpectedFileUpdate({
|
|
299
|
-
client: this.client,
|
|
300
|
-
path: { id: runId, filename },
|
|
301
|
-
body: { name: newFilename },
|
|
302
|
-
signal: options.signal,
|
|
303
|
-
})
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
async deleteExpected(
|
|
308
|
-
runId: string,
|
|
309
|
-
filename: string,
|
|
310
|
-
options: SignalOptions = {}
|
|
311
|
-
): Promise<RunsReviewsExpectedFileDeleteResponse> {
|
|
312
|
-
return this.dispatch(() =>
|
|
313
|
-
runsReviewsExpectedFileDelete({
|
|
314
|
-
client: this.client,
|
|
315
|
-
path: { id: runId, filename },
|
|
316
|
-
signal: options.signal,
|
|
317
|
-
})
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export class RunsScoresResource {
|
|
323
|
-
constructor(
|
|
324
|
-
private readonly client: Client,
|
|
325
|
-
private readonly dispatch: Dispatch
|
|
326
|
-
) {}
|
|
327
|
-
|
|
328
|
-
async list(runId: string, options: SignalOptions = {}): Promise<RunsScoresListResponse> {
|
|
329
|
-
return this.dispatch(() =>
|
|
330
|
-
runsScoresList({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
export class RunsTraceResource {
|
|
336
|
-
constructor(
|
|
337
|
-
private readonly client: Client,
|
|
338
|
-
private readonly dispatch: Dispatch
|
|
339
|
-
) {}
|
|
340
|
-
|
|
341
|
-
async get(runId: string, options: SignalOptions = {}): Promise<RunsTraceGetResponse> {
|
|
342
|
-
return this.dispatch(() =>
|
|
343
|
-
runsTraceGet({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
349
|
-
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
350
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import type { OperationResult, RequestDispatchOptions } from '../client';
|
|
2
|
-
import type { Client } from '../generated/client';
|
|
3
|
-
import {
|
|
4
|
-
templatesContentGet,
|
|
5
|
-
templatesDelete,
|
|
6
|
-
templatesGet,
|
|
7
|
-
templatesList,
|
|
8
|
-
} from '../generated/sdk.gen';
|
|
9
|
-
import type { ListTemplatesResponse, Template } from '../generated/types.gen';
|
|
10
|
-
import type { FilesResource } from './files';
|
|
11
|
-
|
|
12
|
-
type Dispatch = <T>(
|
|
13
|
-
call: () => Promise<OperationResult<T>>,
|
|
14
|
-
options?: RequestDispatchOptions
|
|
15
|
-
) => Promise<T>;
|
|
16
|
-
type SignalOptions = { signal?: AbortSignal };
|
|
17
|
-
type UploadOptions = SignalOptions & {
|
|
18
|
-
/** Required only when `file` is a nameless Blob. */
|
|
19
|
-
filename?: string;
|
|
20
|
-
name?: string;
|
|
21
|
-
description?: string;
|
|
22
|
-
};
|
|
23
|
-
type FileIdOptions = SignalOptions & {
|
|
24
|
-
name?: string;
|
|
25
|
-
description?: string;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const TEMPORARY_UPLOAD_CLEANUP_TIMEOUT_MS = 10_000;
|
|
29
|
-
|
|
30
|
-
function temporaryUploadCleanupSignal(): AbortSignal {
|
|
31
|
-
return AbortSignal.timeout(TEMPORARY_UPLOAD_CLEANUP_TIMEOUT_MS);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function filenameFor(file: Blob | File, filename?: string): string {
|
|
35
|
-
const resolved =
|
|
36
|
-
filename ?? (typeof File !== 'undefined' && file instanceof File ? file.name : undefined);
|
|
37
|
-
if (!resolved) throw new Error('filename is required when uploading a Blob');
|
|
38
|
-
return resolved;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export class TemplatesResource {
|
|
42
|
-
constructor(
|
|
43
|
-
private readonly client: Client,
|
|
44
|
-
private readonly dispatch: Dispatch,
|
|
45
|
-
private readonly files: FilesResource
|
|
46
|
-
) {}
|
|
47
|
-
|
|
48
|
-
async list(
|
|
49
|
-
options: SignalOptions & { limit?: number; offset?: number } = {}
|
|
50
|
-
): Promise<ListTemplatesResponse> {
|
|
51
|
-
return this.dispatch(() =>
|
|
52
|
-
templatesList({
|
|
53
|
-
client: this.client,
|
|
54
|
-
query: { limit: options.limit, offset: options.offset },
|
|
55
|
-
signal: options.signal,
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async get(templateId: string, options: SignalOptions = {}): Promise<Template> {
|
|
61
|
-
return this.dispatch(() =>
|
|
62
|
-
templatesGet({ client: this.client, path: { id: templateId }, signal: options.signal })
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async create(file: Blob | File, options: UploadOptions = {}): Promise<Template> {
|
|
67
|
-
const uploaded = await this.files.upload(file, {
|
|
68
|
-
filename: filenameFor(file, options.filename),
|
|
69
|
-
signal: options.signal,
|
|
70
|
-
});
|
|
71
|
-
try {
|
|
72
|
-
return await this.createFromFileId(uploaded.id, options);
|
|
73
|
-
} finally {
|
|
74
|
-
await this.files
|
|
75
|
-
.delete(uploaded.id, { signal: temporaryUploadCleanupSignal() })
|
|
76
|
-
.catch(() => undefined);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** Create a template from an existing reusable `file_…` resource. */
|
|
81
|
-
async createFromFileId(fileId: string, options: FileIdOptions = {}): Promise<Template> {
|
|
82
|
-
return this.dispatch(
|
|
83
|
-
() =>
|
|
84
|
-
this.client.post({
|
|
85
|
-
url: '/v1/templates',
|
|
86
|
-
body: {
|
|
87
|
-
fileId,
|
|
88
|
-
name: options.name,
|
|
89
|
-
description: options.description,
|
|
90
|
-
},
|
|
91
|
-
signal: options.signal,
|
|
92
|
-
}) as Promise<OperationResult<Template>>
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async replace(
|
|
97
|
-
templateId: string,
|
|
98
|
-
file: Blob | File,
|
|
99
|
-
options: Pick<UploadOptions, 'filename' | 'signal'> = {}
|
|
100
|
-
): Promise<Template> {
|
|
101
|
-
const uploaded = await this.files.upload(file, {
|
|
102
|
-
filename: filenameFor(file, options.filename),
|
|
103
|
-
signal: options.signal,
|
|
104
|
-
});
|
|
105
|
-
try {
|
|
106
|
-
return await this.replaceFromFileId(templateId, uploaded.id, options);
|
|
107
|
-
} finally {
|
|
108
|
-
await this.files
|
|
109
|
-
.delete(uploaded.id, { signal: temporaryUploadCleanupSignal() })
|
|
110
|
-
.catch(() => undefined);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** Append a revision from an existing reusable `file_…` resource. */
|
|
115
|
-
async replaceFromFileId(
|
|
116
|
-
templateId: string,
|
|
117
|
-
fileId: string,
|
|
118
|
-
options: SignalOptions = {}
|
|
119
|
-
): Promise<Template> {
|
|
120
|
-
return this.dispatch(
|
|
121
|
-
() =>
|
|
122
|
-
this.client.put({
|
|
123
|
-
url: '/v1/templates/{id}',
|
|
124
|
-
path: { id: templateId },
|
|
125
|
-
body: { fileId },
|
|
126
|
-
signal: options.signal,
|
|
127
|
-
}) as Promise<OperationResult<Template>>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async download(
|
|
132
|
-
templateId: string,
|
|
133
|
-
options: SignalOptions & { revisionId?: string } = {}
|
|
134
|
-
): Promise<Blob> {
|
|
135
|
-
return this.dispatch(
|
|
136
|
-
async () =>
|
|
137
|
-
(await templatesContentGet({
|
|
138
|
-
client: this.client,
|
|
139
|
-
path: { id: templateId },
|
|
140
|
-
query: { revisionId: options.revisionId },
|
|
141
|
-
parseAs: 'blob',
|
|
142
|
-
signal: options.signal,
|
|
143
|
-
})) as OperationResult<Blob>,
|
|
144
|
-
{ responseKind: 'binary' }
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async delete(templateId: string, options: SignalOptions = {}): Promise<{ deleted: boolean }> {
|
|
149
|
-
return this.dispatch(() =>
|
|
150
|
-
templatesDelete({ client: this.client, path: { id: templateId }, signal: options.signal })
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
}
|
package/src/runtime-config.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CreateClientConfig } from './generated/client.gen';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Runtime configuration hook for the generated hey-api client.
|
|
5
|
-
*
|
|
6
|
-
* This hook only affects direct use of the generated SDK functions in
|
|
7
|
-
* `@eigenpal/sdk/generated`. `EigenpalClient` in `client.ts` creates its own
|
|
8
|
-
* client with `createClient(config)` and does not go through this factory.
|
|
9
|
-
* The default baseUrl here is used only when a caller does not pass one.
|
|
10
|
-
*/
|
|
11
|
-
export const createClientConfig: CreateClientConfig = (config) => ({
|
|
12
|
-
...config,
|
|
13
|
-
baseUrl: config?.baseUrl ?? 'https://api.eigenpal.com',
|
|
14
|
-
});
|