@perstack/api-client 0.0.51 → 0.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +6311 -1356
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +133 -193
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -73,16 +73,16 @@ function createNetworkError(error) {
|
|
|
73
73
|
cause: error instanceof Error ? error : void 0
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
async function handleHttpError(response$
|
|
76
|
+
async function handleHttpError(response$19) {
|
|
77
77
|
let errorBody;
|
|
78
78
|
try {
|
|
79
|
-
errorBody = await response$
|
|
79
|
+
errorBody = await response$19.json();
|
|
80
80
|
} catch {
|
|
81
81
|
errorBody = void 0;
|
|
82
82
|
}
|
|
83
83
|
return {
|
|
84
84
|
ok: false,
|
|
85
|
-
error: createHttpError(response$
|
|
85
|
+
error: createHttpError(response$19.status, response$19.statusText, errorBody)
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
function createHttpError(status, statusText, body) {
|
|
@@ -219,20 +219,20 @@ function createFetcher(config) {
|
|
|
219
219
|
}
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
|
-
async function request$
|
|
222
|
+
async function request$19(method, path, body, options) {
|
|
223
223
|
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
224
224
|
try {
|
|
225
|
-
const response$
|
|
225
|
+
const response$19 = await fetch(buildUrl(path), {
|
|
226
226
|
method,
|
|
227
227
|
headers: buildHeaders(body ? { hasBody: true } : void 0),
|
|
228
228
|
body: body ? JSON.stringify(body) : void 0,
|
|
229
229
|
signal,
|
|
230
230
|
credentials: getCredentials()
|
|
231
231
|
});
|
|
232
|
-
if (!response$
|
|
232
|
+
if (!response$19.ok) return handleHttpError(response$19);
|
|
233
233
|
return {
|
|
234
234
|
ok: true,
|
|
235
|
-
data: await response$
|
|
235
|
+
data: await response$19.json()
|
|
236
236
|
};
|
|
237
237
|
} catch (error) {
|
|
238
238
|
if (error instanceof Error && error.name === "AbortError") {
|
|
@@ -256,16 +256,16 @@ function createFetcher(config) {
|
|
|
256
256
|
async function requestBlob(path, options) {
|
|
257
257
|
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
258
258
|
try {
|
|
259
|
-
const response$
|
|
259
|
+
const response$19 = await fetch(buildUrl(path), {
|
|
260
260
|
method: "GET",
|
|
261
261
|
headers: buildHeaders(),
|
|
262
262
|
signal,
|
|
263
263
|
credentials: getCredentials()
|
|
264
264
|
});
|
|
265
|
-
if (!response$
|
|
265
|
+
if (!response$19.ok) return handleHttpError(response$19);
|
|
266
266
|
return {
|
|
267
267
|
ok: true,
|
|
268
|
-
data: await response$
|
|
268
|
+
data: await response$19.blob()
|
|
269
269
|
};
|
|
270
270
|
} catch (error) {
|
|
271
271
|
if (error instanceof Error && error.name === "AbortError") {
|
|
@@ -289,17 +289,17 @@ function createFetcher(config) {
|
|
|
289
289
|
async function requestStream(path, options) {
|
|
290
290
|
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
291
291
|
try {
|
|
292
|
-
const response$
|
|
292
|
+
const response$19 = await fetch(buildUrl(path), {
|
|
293
293
|
method: "GET",
|
|
294
294
|
headers: buildHeaders(),
|
|
295
295
|
signal,
|
|
296
296
|
credentials: getCredentials()
|
|
297
297
|
});
|
|
298
|
-
if (!response$
|
|
298
|
+
if (!response$19.ok) {
|
|
299
299
|
cleanup();
|
|
300
|
-
return handleHttpError(response$
|
|
300
|
+
return handleHttpError(response$19);
|
|
301
301
|
}
|
|
302
|
-
if (!response$
|
|
302
|
+
if (!response$19.body) {
|
|
303
303
|
cleanup();
|
|
304
304
|
return {
|
|
305
305
|
ok: false,
|
|
@@ -310,7 +310,7 @@ function createFetcher(config) {
|
|
|
310
310
|
const idleTimeout = options?.streamIdleTimeout ?? timeout;
|
|
311
311
|
return {
|
|
312
312
|
ok: true,
|
|
313
|
-
data: wrapStreamWithIdleTimeout(response$
|
|
313
|
+
data: wrapStreamWithIdleTimeout(response$19.body, idleTimeout, options?.signal)
|
|
314
314
|
};
|
|
315
315
|
} catch (error) {
|
|
316
316
|
cleanup();
|
|
@@ -333,13 +333,13 @@ function createFetcher(config) {
|
|
|
333
333
|
async function requestNoContent(method, path, options) {
|
|
334
334
|
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
335
335
|
try {
|
|
336
|
-
const response$
|
|
336
|
+
const response$19 = await fetch(buildUrl(path), {
|
|
337
337
|
method,
|
|
338
338
|
headers: buildHeaders(),
|
|
339
339
|
signal,
|
|
340
340
|
credentials: getCredentials()
|
|
341
341
|
});
|
|
342
|
-
if (!response$
|
|
342
|
+
if (!response$19.ok) return handleHttpError(response$19);
|
|
343
343
|
return {
|
|
344
344
|
ok: true,
|
|
345
345
|
data: void 0
|
|
@@ -364,10 +364,10 @@ function createFetcher(config) {
|
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
return {
|
|
367
|
-
get: (path, options) => request$
|
|
368
|
-
post: (path, body, options) => request$
|
|
369
|
-
put: (path, body, options) => request$
|
|
370
|
-
delete: (path, options) => request$
|
|
367
|
+
get: (path, options) => request$19("GET", path, void 0, options),
|
|
368
|
+
post: (path, body, options) => request$19("POST", path, body, options),
|
|
369
|
+
put: (path, body, options) => request$19("PUT", path, body, options),
|
|
370
|
+
delete: (path, options) => request$19("DELETE", path, void 0, options),
|
|
371
371
|
deleteNoContent: (path, options) => requestNoContent("DELETE", path, options),
|
|
372
372
|
getBlob: (path, options) => requestBlob(path, options),
|
|
373
373
|
getStream: (path, options) => requestStream(path, options)
|
|
@@ -386,6 +386,31 @@ function buildQueryString(params) {
|
|
|
386
386
|
|
|
387
387
|
//#endregion
|
|
388
388
|
//#region src/lib/sse.ts
|
|
389
|
+
async function* parseSSEEvents(reader) {
|
|
390
|
+
const decoder = new TextDecoder();
|
|
391
|
+
let buffer = "";
|
|
392
|
+
while (true) {
|
|
393
|
+
const { value, done } = await reader.read();
|
|
394
|
+
if (done) break;
|
|
395
|
+
buffer += decoder.decode(value, { stream: true });
|
|
396
|
+
const events = buffer.split("\n\n");
|
|
397
|
+
buffer = events.pop() || "";
|
|
398
|
+
for (const event of events) {
|
|
399
|
+
if (event.trim() === "") continue;
|
|
400
|
+
const lines = event.split("\n");
|
|
401
|
+
const eventType = lines.find((line) => line.startsWith("event:"))?.slice(6).trim();
|
|
402
|
+
const data = lines.find((line) => line.startsWith("data:"))?.slice(5).trim();
|
|
403
|
+
if (!eventType || !data) continue;
|
|
404
|
+
if (eventType !== "message" && eventType !== "error" && eventType !== "complete") continue;
|
|
405
|
+
try {
|
|
406
|
+
yield {
|
|
407
|
+
event: eventType,
|
|
408
|
+
data: JSON.parse(data)
|
|
409
|
+
};
|
|
410
|
+
} catch {}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
389
414
|
async function* parseSSE(reader) {
|
|
390
415
|
const decoder = new TextDecoder();
|
|
391
416
|
let buffer = "";
|
|
@@ -507,86 +532,6 @@ const organizationSchema = z.object({
|
|
|
507
532
|
maxExperts: z.number().int().min(0)
|
|
508
533
|
});
|
|
509
534
|
|
|
510
|
-
//#endregion
|
|
511
|
-
//#region ../models/src/domain/user.ts
|
|
512
|
-
const userStatusSchema = z.enum([
|
|
513
|
-
"active",
|
|
514
|
-
"inactive",
|
|
515
|
-
"deleted"
|
|
516
|
-
]);
|
|
517
|
-
const userSchema = z.object({
|
|
518
|
-
type: z.literal("user"),
|
|
519
|
-
id: cuidSchema,
|
|
520
|
-
email: z.string().email(),
|
|
521
|
-
emailVerified: z.boolean(),
|
|
522
|
-
name: z.string().min(1).max(255).optional(),
|
|
523
|
-
image: z.string().url().optional(),
|
|
524
|
-
status: userStatusSchema,
|
|
525
|
-
organizations: z.array(organizationSchema),
|
|
526
|
-
createdAt: datetimeSchema,
|
|
527
|
-
updatedAt: datetimeSchema
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
//#endregion
|
|
531
|
-
//#region ../models/src/domain/apiKey.ts
|
|
532
|
-
const apiKeyPermissionsSchema = z.object({
|
|
533
|
-
operations: z.array(z.string()),
|
|
534
|
-
experts: z.union([z.array(z.string()), z.literal("*")]).optional()
|
|
535
|
-
});
|
|
536
|
-
const apiKeySchema = z.object({
|
|
537
|
-
type: z.literal("apiKey"),
|
|
538
|
-
id: cuidSchema,
|
|
539
|
-
name: z.string().min(1).max(255).optional(),
|
|
540
|
-
start: z.string().optional(),
|
|
541
|
-
prefix: z.string().optional(),
|
|
542
|
-
user: userSchema.optional(),
|
|
543
|
-
enabled: z.boolean(),
|
|
544
|
-
expiresAt: datetimeSchema.optional(),
|
|
545
|
-
permissions: apiKeyPermissionsSchema.optional(),
|
|
546
|
-
lastRequest: datetimeSchema.optional(),
|
|
547
|
-
createdAt: datetimeSchema,
|
|
548
|
-
updatedAt: datetimeSchema
|
|
549
|
-
});
|
|
550
|
-
const createApiKeyInputSchema = z.object({
|
|
551
|
-
name: z.string().min(1).max(255).optional(),
|
|
552
|
-
organizationId: cuidSchema,
|
|
553
|
-
operations: z.array(z.string()).optional(),
|
|
554
|
-
experts: z.union([z.array(z.string()), z.literal("*")]).optional(),
|
|
555
|
-
expiresIn: z.number().min(60).optional()
|
|
556
|
-
});
|
|
557
|
-
const createApiKeyResponseSchema = z.object({
|
|
558
|
-
apiKey: apiKeySchema,
|
|
559
|
-
key: z.string()
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
//#endregion
|
|
563
|
-
//#region ../models/src/api/api-keys/create.ts
|
|
564
|
-
const request$22 = { body: z.object({
|
|
565
|
-
name: z.string().min(1).max(255).optional(),
|
|
566
|
-
operations: z.array(z.string()).optional(),
|
|
567
|
-
experts: z.union([z.array(z.string()), z.literal("*")]).optional(),
|
|
568
|
-
wildcardApplicationAccess: z.boolean().optional(),
|
|
569
|
-
applicationIds: z.array(cuidSchema).optional(),
|
|
570
|
-
expiresIn: z.number().min(60).optional()
|
|
571
|
-
}) };
|
|
572
|
-
const response$22 = z.object({ data: z.object({
|
|
573
|
-
apiKey: apiKeySchema.extend({
|
|
574
|
-
permissions: apiKeyPermissionsSchema.optional(),
|
|
575
|
-
wildcardApplicationAccess: z.boolean(),
|
|
576
|
-
applicationIds: z.array(cuidSchema)
|
|
577
|
-
}),
|
|
578
|
-
key: z.string()
|
|
579
|
-
}) });
|
|
580
|
-
|
|
581
|
-
//#endregion
|
|
582
|
-
//#region ../models/src/api/api-keys/get.ts
|
|
583
|
-
const request$21 = { params: z.object({ apiKeyId: cuidSchema }) };
|
|
584
|
-
const response$21 = z.object({ data: z.object({ apiKey: apiKeySchema.extend({
|
|
585
|
-
permissions: apiKeyPermissionsSchema.optional(),
|
|
586
|
-
wildcardApplicationAccess: z.boolean(),
|
|
587
|
-
applicationIds: z.array(cuidSchema)
|
|
588
|
-
}) }) });
|
|
589
|
-
|
|
590
535
|
//#endregion
|
|
591
536
|
//#region ../models/src/lib/dedent.ts
|
|
592
537
|
/**
|
|
@@ -644,6 +589,16 @@ const errorForbidden = z.object({
|
|
|
644
589
|
error: z.literal("Forbidden"),
|
|
645
590
|
reason: z.string()
|
|
646
591
|
}).describe("Access denied. The authenticated user does not have permission to perform this action.");
|
|
592
|
+
const errorUsageLimitExceeded = z.object({
|
|
593
|
+
code: z.literal(403),
|
|
594
|
+
error: z.literal("Forbidden"),
|
|
595
|
+
reason: z.string(),
|
|
596
|
+
details: z.object({
|
|
597
|
+
minutesUsed: z.number(),
|
|
598
|
+
limitMinutes: z.number(),
|
|
599
|
+
upgradeUrl: z.string()
|
|
600
|
+
})
|
|
601
|
+
}).describe("Usage limit exceeded. Upgrade your plan to continue.");
|
|
647
602
|
const errorNotFound = z.object({
|
|
648
603
|
code: z.literal(404),
|
|
649
604
|
error: z.literal("Not Found"),
|
|
@@ -665,30 +620,6 @@ const errorUnauthorizedFlexible = z.object({
|
|
|
665
620
|
reason: z.string()
|
|
666
621
|
}).describe("Unauthorized");
|
|
667
622
|
|
|
668
|
-
//#endregion
|
|
669
|
-
//#region ../models/src/api/api-keys/revoke.ts
|
|
670
|
-
const request$20 = { params: z.object({ apiKeyId: cuidSchema }) };
|
|
671
|
-
const response$20 = z.object({ data: z.object({ apiKey: apiKeySchema.extend({
|
|
672
|
-
permissions: apiKeyPermissionsSchema.optional(),
|
|
673
|
-
wildcardApplicationAccess: z.boolean(),
|
|
674
|
-
applicationIds: z.array(cuidSchema)
|
|
675
|
-
}) }) });
|
|
676
|
-
|
|
677
|
-
//#endregion
|
|
678
|
-
//#region ../models/src/api/api-keys/update.ts
|
|
679
|
-
const request$19 = {
|
|
680
|
-
params: z.object({ apiKeyId: cuidSchema }),
|
|
681
|
-
body: z.object({
|
|
682
|
-
applicationIds: z.array(cuidSchema).optional(),
|
|
683
|
-
wildcardApplicationAccess: z.boolean().optional()
|
|
684
|
-
})
|
|
685
|
-
};
|
|
686
|
-
const response$19 = z.object({ data: z.object({ apiKey: apiKeySchema.extend({
|
|
687
|
-
permissions: apiKeyPermissionsSchema.optional(),
|
|
688
|
-
wildcardApplicationAccess: z.boolean(),
|
|
689
|
-
applicationIds: z.array(cuidSchema)
|
|
690
|
-
}) }) });
|
|
691
|
-
|
|
692
623
|
//#endregion
|
|
693
624
|
//#region ../models/src/domain/application.ts
|
|
694
625
|
const applicationNameSchema = z.string().min(1).max(maxApplicationNameLength).regex(applicationNameRegex);
|
|
@@ -707,7 +638,9 @@ const applicationSchema = z.object({
|
|
|
707
638
|
name: applicationNameSchema,
|
|
708
639
|
status: applicationStatusSchema,
|
|
709
640
|
expertCount: z.number().describe("Number of expert draft scopes associated with this application").optional(),
|
|
710
|
-
providers: z.array(providerSchema).describe("List of configured providers for this application").optional()
|
|
641
|
+
providers: z.array(providerSchema).describe("List of configured providers for this application").optional(),
|
|
642
|
+
totalJobs: z.number().describe("Total number of jobs executed for this application").optional(),
|
|
643
|
+
lastJobExecutionAt: z.string().datetime({ offset: true }).nullable().describe("Timestamp of the most recent job execution").optional()
|
|
711
644
|
});
|
|
712
645
|
|
|
713
646
|
//#endregion
|
|
@@ -865,7 +798,8 @@ const expertVersionSchema = z.object({
|
|
|
865
798
|
updatedAt: datetimeSchema,
|
|
866
799
|
createdBy: cuidSchema,
|
|
867
800
|
updatedBy: cuidSchema,
|
|
868
|
-
tags: z.array(expertTagFieldSchema)
|
|
801
|
+
tags: z.array(expertTagFieldSchema),
|
|
802
|
+
readmeUrl: z.string().optional()
|
|
869
803
|
});
|
|
870
804
|
const expertScopeWithVersionsSchema = expertScopeSchema.extend({ versions: z.array(expertVersionSchema) });
|
|
871
805
|
|
|
@@ -945,7 +879,7 @@ const expertSchema = z.object({
|
|
|
945
879
|
key: expertKeyFieldSchema,
|
|
946
880
|
name: expertNameFieldSchema,
|
|
947
881
|
version: expertVersionFieldSchema,
|
|
948
|
-
description: z.string().
|
|
882
|
+
description: z.string().max(maxExpertDescriptionLength).optional(),
|
|
949
883
|
instruction: z.string().min(1).max(maxExpertInstructionLength),
|
|
950
884
|
skills: z.record(skillNameSchema, skillSchema).optional().default({}),
|
|
951
885
|
delegates: z.array(expertKeyFieldSchema).min(0).max(maxExpertDelegateItems).optional().default([]),
|
|
@@ -1269,8 +1203,8 @@ const jobSchema = z.object({
|
|
|
1269
1203
|
status: jobStatusSchema,
|
|
1270
1204
|
coordinatorExpertKey: expertKeyFieldSchema,
|
|
1271
1205
|
query: z.string().min(1).max(maxExpertJobQueryLength).optional(),
|
|
1272
|
-
files: z.array(z.string().min(1).max(maxExpertJobFileNameLength)),
|
|
1273
1206
|
expert: expertWithMetadataSchema,
|
|
1207
|
+
expertDraftRefId: cuidSchema.optional(),
|
|
1274
1208
|
provider: providerSchema,
|
|
1275
1209
|
model: modelEnum,
|
|
1276
1210
|
reasoningBudget: reasoningBudgetSchema,
|
|
@@ -1279,7 +1213,8 @@ const jobSchema = z.object({
|
|
|
1279
1213
|
currentStep: z.number().int().min(0),
|
|
1280
1214
|
totalSteps: z.number().int().min(0),
|
|
1281
1215
|
totalDuration: z.number().min(0),
|
|
1282
|
-
usage: usageSchema
|
|
1216
|
+
usage: usageSchema,
|
|
1217
|
+
lastActivity: activityOrGroupSchema.nullable().optional()
|
|
1283
1218
|
});
|
|
1284
1219
|
|
|
1285
1220
|
//#endregion
|
|
@@ -1287,9 +1222,8 @@ const jobSchema = z.object({
|
|
|
1287
1222
|
const request$6 = {
|
|
1288
1223
|
params: z.object({ jobId: cuidSchema }),
|
|
1289
1224
|
body: z.object({
|
|
1290
|
-
query:
|
|
1225
|
+
query: z.string().min(1).max(maxExpertJobQueryLength),
|
|
1291
1226
|
interactiveToolCallResult: z.boolean().optional(),
|
|
1292
|
-
files: z.union([z.instanceof(File), z.array(z.instanceof(File))]).optional(),
|
|
1293
1227
|
provider: providerSchema.optional(),
|
|
1294
1228
|
model: jobSchema.shape.model.optional(),
|
|
1295
1229
|
reasoningBudget: reasoningBudgetSchema.optional(),
|
|
@@ -1301,17 +1235,23 @@ const response$6 = z.object({ data: z.object({ job: jobSchema }) });
|
|
|
1301
1235
|
|
|
1302
1236
|
//#endregion
|
|
1303
1237
|
//#region ../models/src/api/jobs/create.ts
|
|
1304
|
-
const
|
|
1238
|
+
const baseBodySchema = z.object({
|
|
1305
1239
|
applicationId: cuidSchema.describe("Application ID to create the job in"),
|
|
1306
|
-
|
|
1307
|
-
query: jobSchema.shape.query.optional(),
|
|
1308
|
-
files: z.union([z.instanceof(File), z.array(z.instanceof(File))]).optional(),
|
|
1240
|
+
query: z.string().min(1).max(maxExpertJobQueryLength),
|
|
1309
1241
|
provider: providerSchema,
|
|
1310
1242
|
model: jobSchema.shape.model.optional(),
|
|
1311
1243
|
reasoningBudget: reasoningBudgetSchema.optional(),
|
|
1312
1244
|
maxSteps: z.coerce.number().optional(),
|
|
1313
1245
|
maxRetries: z.coerce.number().optional()
|
|
1314
|
-
})
|
|
1246
|
+
});
|
|
1247
|
+
const request$5 = { body: baseBodySchema.extend({
|
|
1248
|
+
expertKey: expertKeyFieldSchema.optional(),
|
|
1249
|
+
draftRefId: cuidSchema.describe("Draft ref ID to run the job with").optional()
|
|
1250
|
+
}).refine((data) => {
|
|
1251
|
+
const hasExpertKey = data.expertKey !== void 0;
|
|
1252
|
+
const hasDraftRefId = data.draftRefId !== void 0;
|
|
1253
|
+
return hasExpertKey && !hasDraftRefId || !hasExpertKey && hasDraftRefId;
|
|
1254
|
+
}, { message: "Either expertKey or draftRefId must be provided, but not both" }) };
|
|
1315
1255
|
const response$5 = z.object({ data: z.object({ job: jobSchema }) });
|
|
1316
1256
|
|
|
1317
1257
|
//#endregion
|
|
@@ -1320,7 +1260,12 @@ const request$4 = { query: z.object({
|
|
|
1320
1260
|
sort: z.enum(["createdAt", "updatedAt"]).optional(),
|
|
1321
1261
|
order: z.enum(["asc", "desc"]).optional(),
|
|
1322
1262
|
take: z.coerce.number().min(1).max(100).default(20),
|
|
1323
|
-
skip: z.coerce.number().min(0).default(0)
|
|
1263
|
+
skip: z.coerce.number().min(0).default(0),
|
|
1264
|
+
expertScopeId: cuidSchema.optional(),
|
|
1265
|
+
expertDraftScopeId: cuidSchema.optional(),
|
|
1266
|
+
applicationId: cuidSchema.optional(),
|
|
1267
|
+
statuses: z.preprocess((val) => typeof val === "string" ? val.split(",") : val, z.array(jobStatusSchema).optional()),
|
|
1268
|
+
expertKeyFilter: z.string().max(100).optional()
|
|
1324
1269
|
}) };
|
|
1325
1270
|
const response$4 = z.object({
|
|
1326
1271
|
data: z.object({ jobs: z.array(jobSchema) }),
|
|
@@ -1444,59 +1389,6 @@ const request = {
|
|
|
1444
1389
|
};
|
|
1445
1390
|
const response = z.object({ data: z.object({ providerSetting: providerSettingResponseSchema }) });
|
|
1446
1391
|
|
|
1447
|
-
//#endregion
|
|
1448
|
-
//#region src/endpoints/api-keys.ts
|
|
1449
|
-
const BASE_PATH$6 = "/api/v1/api_keys";
|
|
1450
|
-
function createApiKeysApi(fetcher) {
|
|
1451
|
-
return {
|
|
1452
|
-
async create(input, options) {
|
|
1453
|
-
const result = request$22.body.safeParse(input);
|
|
1454
|
-
if (!result.success) return {
|
|
1455
|
-
ok: false,
|
|
1456
|
-
error: createValidationError(result.error)
|
|
1457
|
-
};
|
|
1458
|
-
return fetcher.post(BASE_PATH$6, input, options);
|
|
1459
|
-
},
|
|
1460
|
-
async list(input, options) {
|
|
1461
|
-
const queryParams = new URLSearchParams();
|
|
1462
|
-
if (input?.take !== void 0) queryParams.set("take", String(input.take));
|
|
1463
|
-
if (input?.skip !== void 0) queryParams.set("skip", String(input.skip));
|
|
1464
|
-
const queryString = queryParams.toString();
|
|
1465
|
-
const url = queryString ? `${BASE_PATH$6}?${queryString}` : BASE_PATH$6;
|
|
1466
|
-
return fetcher.get(url, options);
|
|
1467
|
-
},
|
|
1468
|
-
async get(id, options) {
|
|
1469
|
-
const result = request$21.params.safeParse({ apiKeyId: id });
|
|
1470
|
-
if (!result.success) return {
|
|
1471
|
-
ok: false,
|
|
1472
|
-
error: createValidationError(result.error)
|
|
1473
|
-
};
|
|
1474
|
-
return fetcher.get(`${BASE_PATH$6}/${id}`, options);
|
|
1475
|
-
},
|
|
1476
|
-
async revoke(id, options) {
|
|
1477
|
-
const result = request$20.params.safeParse({ apiKeyId: id });
|
|
1478
|
-
if (!result.success) return {
|
|
1479
|
-
ok: false,
|
|
1480
|
-
error: createValidationError(result.error)
|
|
1481
|
-
};
|
|
1482
|
-
return fetcher.post(`${BASE_PATH$6}/${id}/revoke`, {}, options);
|
|
1483
|
-
},
|
|
1484
|
-
async update(id, input, options) {
|
|
1485
|
-
const paramsResult = request$19.params.safeParse({ apiKeyId: id });
|
|
1486
|
-
if (!paramsResult.success) return {
|
|
1487
|
-
ok: false,
|
|
1488
|
-
error: createValidationError(paramsResult.error)
|
|
1489
|
-
};
|
|
1490
|
-
const bodyResult = request$19.body.safeParse(input);
|
|
1491
|
-
if (!bodyResult.success) return {
|
|
1492
|
-
ok: false,
|
|
1493
|
-
error: createValidationError(bodyResult.error)
|
|
1494
|
-
};
|
|
1495
|
-
return fetcher.post(`${BASE_PATH$6}/${id}`, input, options);
|
|
1496
|
-
}
|
|
1497
|
-
};
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
1392
|
//#endregion
|
|
1501
1393
|
//#region src/endpoints/applications.ts
|
|
1502
1394
|
const BASE_PATH$5 = "/api/v1/applications";
|
|
@@ -1687,6 +1579,12 @@ function createExpertsApi(fetcher) {
|
|
|
1687
1579
|
|
|
1688
1580
|
//#endregion
|
|
1689
1581
|
//#region src/endpoints/jobs-checkpoints.ts
|
|
1582
|
+
function isErrorEventData(data) {
|
|
1583
|
+
return typeof data === "object" && data !== null && "type" in data && typeof data.type === "string" && "jobId" in data && typeof data.jobId === "string";
|
|
1584
|
+
}
|
|
1585
|
+
function isCompleteEventData(data) {
|
|
1586
|
+
return typeof data === "object" && data !== null && "status" in data && typeof data.status === "string" && "jobId" in data && typeof data.jobId === "string";
|
|
1587
|
+
}
|
|
1690
1588
|
function createCheckpointsApi(fetcher, basePath) {
|
|
1691
1589
|
return {
|
|
1692
1590
|
async list(jobId, params, options) {
|
|
@@ -1736,6 +1634,49 @@ function createCheckpointsApi(fetcher, basePath) {
|
|
|
1736
1634
|
error: createNetworkError(error)
|
|
1737
1635
|
};
|
|
1738
1636
|
}
|
|
1637
|
+
},
|
|
1638
|
+
async *streamEvents(jobId, options) {
|
|
1639
|
+
const result = await fetcher.getStream(`${basePath}/${jobId}/checkpoints/stream`, options);
|
|
1640
|
+
if (!result.ok) {
|
|
1641
|
+
yield {
|
|
1642
|
+
ok: false,
|
|
1643
|
+
error: result.error
|
|
1644
|
+
};
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
const reader = result.data.getReader();
|
|
1648
|
+
try {
|
|
1649
|
+
for await (const sseEvent of parseSSEEvents(reader)) if (sseEvent.event === "message") yield {
|
|
1650
|
+
ok: true,
|
|
1651
|
+
data: {
|
|
1652
|
+
event: "message",
|
|
1653
|
+
data: sseEvent.data
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
else if (sseEvent.event === "error" && isErrorEventData(sseEvent.data)) yield {
|
|
1657
|
+
ok: true,
|
|
1658
|
+
data: {
|
|
1659
|
+
event: "error",
|
|
1660
|
+
data: sseEvent.data
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
else if (sseEvent.event === "complete" && isCompleteEventData(sseEvent.data)) yield {
|
|
1664
|
+
ok: true,
|
|
1665
|
+
data: {
|
|
1666
|
+
event: "complete",
|
|
1667
|
+
data: sseEvent.data
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
} catch (error) {
|
|
1671
|
+
if (error instanceof DOMException && error.name === "AbortError") yield {
|
|
1672
|
+
ok: false,
|
|
1673
|
+
error: createAbortError()
|
|
1674
|
+
};
|
|
1675
|
+
else yield {
|
|
1676
|
+
ok: false,
|
|
1677
|
+
error: createNetworkError(error)
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1739
1680
|
}
|
|
1740
1681
|
};
|
|
1741
1682
|
}
|
|
@@ -1849,7 +1790,6 @@ function createProviderSettingsApi(fetcher) {
|
|
|
1849
1790
|
function createApiClient(config) {
|
|
1850
1791
|
const fetcher = createFetcher(config);
|
|
1851
1792
|
return {
|
|
1852
|
-
apiKeys: createApiKeysApi(fetcher),
|
|
1853
1793
|
applications: createApplicationsApi(fetcher),
|
|
1854
1794
|
env: createEnvApi(fetcher),
|
|
1855
1795
|
jobs: createJobsApi(fetcher),
|
|
@@ -1859,5 +1799,5 @@ function createApiClient(config) {
|
|
|
1859
1799
|
}
|
|
1860
1800
|
|
|
1861
1801
|
//#endregion
|
|
1862
|
-
export { buildAuthHeaders, buildQueryString, createAbortError, createApiClient, createFetcher, createHttpError, createNetworkError, createTimeoutError, createValidationError, handleHttpError, isAbortError, isClientError, isHttpError, isNetworkError, isTimeoutError, isValidationError, matchExperts, matchOperations, matchWildcard, parseApiKeyPermissions, parseSSE, stringifyApiKeyPermissions };
|
|
1802
|
+
export { buildAuthHeaders, buildQueryString, createAbortError, createApiClient, createFetcher, createHttpError, createNetworkError, createTimeoutError, createValidationError, handleHttpError, isAbortError, isClientError, isHttpError, isNetworkError, isTimeoutError, isValidationError, matchExperts, matchOperations, matchWildcard, parseApiKeyPermissions, parseSSE, parseSSEEvents, stringifyApiKeyPermissions };
|
|
1863
1803
|
//# sourceMappingURL=index.mjs.map
|