@perstack/api-client 0.0.48 → 0.0.51
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/{bundle.d.mts → index.d.mts} +593 -1040
- package/dist/index.d.mts.map +1 -0
- package/dist/{bundle.mjs → index.mjs} +802 -1200
- package/dist/index.mjs.map +1 -0
- package/package.json +10 -8
- package/dist/bundle.d.mts.map +0 -1
- package/dist/bundle.mjs.map +0 -1
- package/dist/chunk-Bdv87wj9.mjs +0 -42
|
@@ -1,7 +1,414 @@
|
|
|
1
|
-
import { r as __toESM, t as __commonJSMin } from "./chunk-Bdv87wj9.mjs";
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
import { activityOrGroupSchema, checkpointSchema as perstackCheckpointSchema, instructionMessageSchema, messageSchema, stepSchema, toolCallSchema, toolMessageSchema, toolResultSchema, usageSchema, userMessageSchema } from "@perstack/core";
|
|
4
3
|
|
|
4
|
+
//#region src/lib/api-key.ts
|
|
5
|
+
function matchWildcard(value, pattern) {
|
|
6
|
+
if (pattern === "*") return true;
|
|
7
|
+
if (pattern.endsWith("*")) return value.startsWith(pattern.slice(0, -1));
|
|
8
|
+
if (pattern.startsWith("*")) return value.endsWith(pattern.slice(1));
|
|
9
|
+
return value === pattern;
|
|
10
|
+
}
|
|
11
|
+
function matchOperations(operations, requiredOperation) {
|
|
12
|
+
return operations.some((pattern) => matchWildcard(requiredOperation, pattern));
|
|
13
|
+
}
|
|
14
|
+
function matchExperts(experts, expertId) {
|
|
15
|
+
if (experts === void 0 || experts === "*") return true;
|
|
16
|
+
return experts.some((pattern) => matchWildcard(expertId, pattern));
|
|
17
|
+
}
|
|
18
|
+
function isApiKeyPermissions(parsed) {
|
|
19
|
+
return typeof parsed === "object" && parsed !== null && "operations" in parsed && Array.isArray(parsed.operations);
|
|
20
|
+
}
|
|
21
|
+
function parseApiKeyPermissions(permissionsJson) {
|
|
22
|
+
if (!permissionsJson) return null;
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(permissionsJson);
|
|
25
|
+
if (!isApiKeyPermissions(parsed)) return null;
|
|
26
|
+
return parsed;
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function stringifyApiKeyPermissions(permissions) {
|
|
32
|
+
return JSON.stringify(permissions);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/lib/auth.ts
|
|
37
|
+
function buildAuthHeaders(auth) {
|
|
38
|
+
if (auth.type === "apiKey") return { Authorization: `Bearer ${auth.apiKey}` };
|
|
39
|
+
return { Cookie: auth.cookie };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/lib/errors.ts
|
|
44
|
+
function createValidationError(error) {
|
|
45
|
+
return {
|
|
46
|
+
errorType: "validation",
|
|
47
|
+
code: 400,
|
|
48
|
+
message: `Validation failed: ${error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")}`,
|
|
49
|
+
reason: error.issues
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function createAbortError() {
|
|
53
|
+
return {
|
|
54
|
+
errorType: "abort",
|
|
55
|
+
code: 0,
|
|
56
|
+
message: "Request aborted",
|
|
57
|
+
aborted: true
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function createTimeoutError() {
|
|
61
|
+
return {
|
|
62
|
+
errorType: "timeout",
|
|
63
|
+
code: 0,
|
|
64
|
+
message: "Request timed out"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function createNetworkError(error) {
|
|
68
|
+
return {
|
|
69
|
+
errorType: "network",
|
|
70
|
+
code: 0,
|
|
71
|
+
message: error instanceof Error ? error.message : "Network error",
|
|
72
|
+
reason: error,
|
|
73
|
+
cause: error instanceof Error ? error : void 0
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async function handleHttpError(response$23) {
|
|
77
|
+
let errorBody;
|
|
78
|
+
try {
|
|
79
|
+
errorBody = await response$23.json();
|
|
80
|
+
} catch {
|
|
81
|
+
errorBody = void 0;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
ok: false,
|
|
85
|
+
error: createHttpError(response$23.status, response$23.statusText, errorBody)
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function createHttpError(status, statusText, body) {
|
|
89
|
+
if (typeof body === "object" && body !== null) {
|
|
90
|
+
const hasReason = "reason" in body;
|
|
91
|
+
if ("error" in body && typeof body.error === "string") return {
|
|
92
|
+
errorType: "http",
|
|
93
|
+
code: status,
|
|
94
|
+
message: body.error,
|
|
95
|
+
reason: hasReason ? body.reason : void 0
|
|
96
|
+
};
|
|
97
|
+
if (hasReason) return {
|
|
98
|
+
errorType: "http",
|
|
99
|
+
code: status,
|
|
100
|
+
message: statusText,
|
|
101
|
+
reason: body.reason
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
errorType: "http",
|
|
106
|
+
code: status,
|
|
107
|
+
message: statusText
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function isHttpError(error) {
|
|
111
|
+
return error.errorType === "http";
|
|
112
|
+
}
|
|
113
|
+
function isNetworkError(error) {
|
|
114
|
+
return error.errorType === "network";
|
|
115
|
+
}
|
|
116
|
+
function isTimeoutError(error) {
|
|
117
|
+
return error.errorType === "timeout";
|
|
118
|
+
}
|
|
119
|
+
function isValidationError(error) {
|
|
120
|
+
return error.errorType === "validation";
|
|
121
|
+
}
|
|
122
|
+
function isAbortError(error) {
|
|
123
|
+
return error.errorType === "abort";
|
|
124
|
+
}
|
|
125
|
+
function isClientError(error) {
|
|
126
|
+
return error.errorType !== "http";
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/lib/fetcher.ts
|
|
131
|
+
const DEFAULT_BASE_URL = "https://api.perstack.ai";
|
|
132
|
+
const DEFAULT_TIMEOUT = 3e4;
|
|
133
|
+
function createFetcher(config) {
|
|
134
|
+
const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
135
|
+
const timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
136
|
+
const useCredentials = "credentials" in config && config.credentials === "include";
|
|
137
|
+
const apiKey = "apiKey" in config ? config.apiKey : void 0;
|
|
138
|
+
function buildUrl(path) {
|
|
139
|
+
return `${baseUrl}${path}`;
|
|
140
|
+
}
|
|
141
|
+
function buildHeaders(options) {
|
|
142
|
+
const headers = {};
|
|
143
|
+
if (options?.hasBody) headers["Content-Type"] = "application/json";
|
|
144
|
+
if (apiKey) headers.Authorization = `Bearer ${apiKey}`;
|
|
145
|
+
return headers;
|
|
146
|
+
}
|
|
147
|
+
function getCredentials() {
|
|
148
|
+
return useCredentials ? "include" : void 0;
|
|
149
|
+
}
|
|
150
|
+
function createTimeoutSignal(externalSignal) {
|
|
151
|
+
const controller = new AbortController();
|
|
152
|
+
let timedOut = false;
|
|
153
|
+
const timeoutId = setTimeout(() => {
|
|
154
|
+
timedOut = true;
|
|
155
|
+
controller.abort();
|
|
156
|
+
}, timeout);
|
|
157
|
+
let abortHandler;
|
|
158
|
+
if (externalSignal) if (externalSignal.aborted) controller.abort();
|
|
159
|
+
else {
|
|
160
|
+
abortHandler = () => controller.abort();
|
|
161
|
+
externalSignal.addEventListener("abort", abortHandler);
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
signal: controller.signal,
|
|
165
|
+
cleanup: () => {
|
|
166
|
+
clearTimeout(timeoutId);
|
|
167
|
+
if (abortHandler && externalSignal) externalSignal.removeEventListener("abort", abortHandler);
|
|
168
|
+
},
|
|
169
|
+
isTimeout: () => timedOut
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function wrapStreamWithIdleTimeout(stream, idleTimeoutMs, externalSignal) {
|
|
173
|
+
const reader = stream.getReader();
|
|
174
|
+
const controller = new AbortController();
|
|
175
|
+
let timeoutId;
|
|
176
|
+
let abortHandler;
|
|
177
|
+
if (externalSignal) if (externalSignal.aborted) controller.abort();
|
|
178
|
+
else {
|
|
179
|
+
abortHandler = () => controller.abort();
|
|
180
|
+
externalSignal.addEventListener("abort", abortHandler);
|
|
181
|
+
}
|
|
182
|
+
function resetTimeout() {
|
|
183
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
184
|
+
timeoutId = setTimeout(() => controller.abort(), idleTimeoutMs);
|
|
185
|
+
}
|
|
186
|
+
function cleanup() {
|
|
187
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
188
|
+
if (abortHandler && externalSignal) externalSignal.removeEventListener("abort", abortHandler);
|
|
189
|
+
}
|
|
190
|
+
return new ReadableStream({
|
|
191
|
+
start() {
|
|
192
|
+
resetTimeout();
|
|
193
|
+
},
|
|
194
|
+
async pull(streamController) {
|
|
195
|
+
try {
|
|
196
|
+
const result = await Promise.race([reader.read(), new Promise((_, reject) => {
|
|
197
|
+
if (controller.signal.aborted) reject(new DOMException("Stream idle timeout", "AbortError"));
|
|
198
|
+
controller.signal.addEventListener("abort", () => {
|
|
199
|
+
reject(new DOMException("Stream idle timeout", "AbortError"));
|
|
200
|
+
});
|
|
201
|
+
})]);
|
|
202
|
+
if (result.done) {
|
|
203
|
+
cleanup();
|
|
204
|
+
streamController.close();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
resetTimeout();
|
|
208
|
+
streamController.enqueue(result.value);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
cleanup();
|
|
211
|
+
reader.cancel().catch(() => {});
|
|
212
|
+
if (error instanceof DOMException && error.name === "AbortError") streamController.error(new DOMException("Stream idle timeout", "AbortError"));
|
|
213
|
+
else streamController.error(error);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
cancel(reason) {
|
|
217
|
+
cleanup();
|
|
218
|
+
reader.cancel(reason).catch(() => {});
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
async function request$23(method, path, body, options) {
|
|
223
|
+
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
224
|
+
try {
|
|
225
|
+
const response$23 = await fetch(buildUrl(path), {
|
|
226
|
+
method,
|
|
227
|
+
headers: buildHeaders(body ? { hasBody: true } : void 0),
|
|
228
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
229
|
+
signal,
|
|
230
|
+
credentials: getCredentials()
|
|
231
|
+
});
|
|
232
|
+
if (!response$23.ok) return handleHttpError(response$23);
|
|
233
|
+
return {
|
|
234
|
+
ok: true,
|
|
235
|
+
data: await response$23.json()
|
|
236
|
+
};
|
|
237
|
+
} catch (error) {
|
|
238
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
239
|
+
if (isTimeout()) return {
|
|
240
|
+
ok: false,
|
|
241
|
+
error: createTimeoutError()
|
|
242
|
+
};
|
|
243
|
+
return {
|
|
244
|
+
ok: false,
|
|
245
|
+
error: createAbortError()
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
ok: false,
|
|
250
|
+
error: createNetworkError(error)
|
|
251
|
+
};
|
|
252
|
+
} finally {
|
|
253
|
+
cleanup();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
async function requestBlob(path, options) {
|
|
257
|
+
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
258
|
+
try {
|
|
259
|
+
const response$23 = await fetch(buildUrl(path), {
|
|
260
|
+
method: "GET",
|
|
261
|
+
headers: buildHeaders(),
|
|
262
|
+
signal,
|
|
263
|
+
credentials: getCredentials()
|
|
264
|
+
});
|
|
265
|
+
if (!response$23.ok) return handleHttpError(response$23);
|
|
266
|
+
return {
|
|
267
|
+
ok: true,
|
|
268
|
+
data: await response$23.blob()
|
|
269
|
+
};
|
|
270
|
+
} catch (error) {
|
|
271
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
272
|
+
if (isTimeout()) return {
|
|
273
|
+
ok: false,
|
|
274
|
+
error: createTimeoutError()
|
|
275
|
+
};
|
|
276
|
+
return {
|
|
277
|
+
ok: false,
|
|
278
|
+
error: createAbortError()
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
ok: false,
|
|
283
|
+
error: createNetworkError(error)
|
|
284
|
+
};
|
|
285
|
+
} finally {
|
|
286
|
+
cleanup();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
async function requestStream(path, options) {
|
|
290
|
+
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
291
|
+
try {
|
|
292
|
+
const response$23 = await fetch(buildUrl(path), {
|
|
293
|
+
method: "GET",
|
|
294
|
+
headers: buildHeaders(),
|
|
295
|
+
signal,
|
|
296
|
+
credentials: getCredentials()
|
|
297
|
+
});
|
|
298
|
+
if (!response$23.ok) {
|
|
299
|
+
cleanup();
|
|
300
|
+
return handleHttpError(response$23);
|
|
301
|
+
}
|
|
302
|
+
if (!response$23.body) {
|
|
303
|
+
cleanup();
|
|
304
|
+
return {
|
|
305
|
+
ok: false,
|
|
306
|
+
error: createNetworkError(/* @__PURE__ */ new Error("Response body is null"))
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
cleanup();
|
|
310
|
+
const idleTimeout = options?.streamIdleTimeout ?? timeout;
|
|
311
|
+
return {
|
|
312
|
+
ok: true,
|
|
313
|
+
data: wrapStreamWithIdleTimeout(response$23.body, idleTimeout, options?.signal)
|
|
314
|
+
};
|
|
315
|
+
} catch (error) {
|
|
316
|
+
cleanup();
|
|
317
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
318
|
+
if (isTimeout()) return {
|
|
319
|
+
ok: false,
|
|
320
|
+
error: createTimeoutError()
|
|
321
|
+
};
|
|
322
|
+
return {
|
|
323
|
+
ok: false,
|
|
324
|
+
error: createAbortError()
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
ok: false,
|
|
329
|
+
error: createNetworkError(error)
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
async function requestNoContent(method, path, options) {
|
|
334
|
+
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
335
|
+
try {
|
|
336
|
+
const response$23 = await fetch(buildUrl(path), {
|
|
337
|
+
method,
|
|
338
|
+
headers: buildHeaders(),
|
|
339
|
+
signal,
|
|
340
|
+
credentials: getCredentials()
|
|
341
|
+
});
|
|
342
|
+
if (!response$23.ok) return handleHttpError(response$23);
|
|
343
|
+
return {
|
|
344
|
+
ok: true,
|
|
345
|
+
data: void 0
|
|
346
|
+
};
|
|
347
|
+
} catch (error) {
|
|
348
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
349
|
+
if (isTimeout()) return {
|
|
350
|
+
ok: false,
|
|
351
|
+
error: createTimeoutError()
|
|
352
|
+
};
|
|
353
|
+
return {
|
|
354
|
+
ok: false,
|
|
355
|
+
error: createAbortError()
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
ok: false,
|
|
360
|
+
error: createNetworkError(error)
|
|
361
|
+
};
|
|
362
|
+
} finally {
|
|
363
|
+
cleanup();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
get: (path, options) => request$23("GET", path, void 0, options),
|
|
368
|
+
post: (path, body, options) => request$23("POST", path, body, options),
|
|
369
|
+
put: (path, body, options) => request$23("PUT", path, body, options),
|
|
370
|
+
delete: (path, options) => request$23("DELETE", path, void 0, options),
|
|
371
|
+
deleteNoContent: (path, options) => requestNoContent("DELETE", path, options),
|
|
372
|
+
getBlob: (path, options) => requestBlob(path, options),
|
|
373
|
+
getStream: (path, options) => requestStream(path, options)
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/lib/query-string.ts
|
|
379
|
+
function buildQueryString(params) {
|
|
380
|
+
if (!params) return "";
|
|
381
|
+
const searchParams = new URLSearchParams();
|
|
382
|
+
for (const [key, value] of Object.entries(params)) if (value !== void 0) searchParams.set(key, String(value));
|
|
383
|
+
const queryString = searchParams.toString();
|
|
384
|
+
return queryString ? `?${queryString}` : "";
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/lib/sse.ts
|
|
389
|
+
async function* parseSSE(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 !== "message" || !data) continue;
|
|
404
|
+
try {
|
|
405
|
+
yield JSON.parse(data);
|
|
406
|
+
} catch {}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
//#endregion
|
|
5
412
|
//#region ../constants/index.ts
|
|
6
413
|
const organizationNameRegex = /^[a-z0-9][a-z0-9_.-]*$/;
|
|
7
414
|
const maxOrganizationNameLength = 128;
|
|
@@ -44,13 +451,13 @@ const maxProviderHeadersCount = 50;
|
|
|
44
451
|
|
|
45
452
|
//#endregion
|
|
46
453
|
//#region ../models/src/domain/common.ts
|
|
47
|
-
const cuidSchema = z.cuid2();
|
|
454
|
+
const cuidSchema = z.string().cuid2();
|
|
455
|
+
const cuidRequestSchema = z.string().min(24).cuid2();
|
|
48
456
|
const runtimeVersionSchema = z.enum(["v1.0"]);
|
|
49
457
|
const providerSchema = z.enum([
|
|
50
458
|
"anthropic",
|
|
51
459
|
"google",
|
|
52
460
|
"openai",
|
|
53
|
-
"ollama",
|
|
54
461
|
"deepseek",
|
|
55
462
|
"azure-openai",
|
|
56
463
|
"amazon-bedrock",
|
|
@@ -154,7 +561,7 @@ const createApiKeyResponseSchema = z.object({
|
|
|
154
561
|
|
|
155
562
|
//#endregion
|
|
156
563
|
//#region ../models/src/api/api-keys/create.ts
|
|
157
|
-
const request$
|
|
564
|
+
const request$22 = { body: z.object({
|
|
158
565
|
name: z.string().min(1).max(255).optional(),
|
|
159
566
|
operations: z.array(z.string()).optional(),
|
|
160
567
|
experts: z.union([z.array(z.string()), z.literal("*")]).optional(),
|
|
@@ -162,7 +569,7 @@ const request$49 = { body: z.object({
|
|
|
162
569
|
applicationIds: z.array(cuidSchema).optional(),
|
|
163
570
|
expiresIn: z.number().min(60).optional()
|
|
164
571
|
}) };
|
|
165
|
-
const response$
|
|
572
|
+
const response$22 = z.object({ data: z.object({
|
|
166
573
|
apiKey: apiKeySchema.extend({
|
|
167
574
|
permissions: apiKeyPermissionsSchema.optional(),
|
|
168
575
|
wildcardApplicationAccess: z.boolean(),
|
|
@@ -173,57 +580,50 @@ const response$51 = z.object({ data: z.object({
|
|
|
173
580
|
|
|
174
581
|
//#endregion
|
|
175
582
|
//#region ../models/src/api/api-keys/get.ts
|
|
176
|
-
const request$
|
|
177
|
-
const response$
|
|
583
|
+
const request$21 = { params: z.object({ apiKeyId: cuidSchema }) };
|
|
584
|
+
const response$21 = z.object({ data: z.object({ apiKey: apiKeySchema.extend({
|
|
178
585
|
permissions: apiKeyPermissionsSchema.optional(),
|
|
179
586
|
wildcardApplicationAccess: z.boolean(),
|
|
180
587
|
applicationIds: z.array(cuidSchema)
|
|
181
588
|
}) }) });
|
|
182
589
|
|
|
183
590
|
//#endregion
|
|
184
|
-
//#region
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return str.replace(pattern_1, "\n");
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
strings[0] = strings[0].replace(/^\r?\n/, "");
|
|
208
|
-
var string = strings[0];
|
|
209
|
-
values.forEach(function(value, i) {
|
|
210
|
-
var endentations = string.match(/(?:^|\n)( *)$/);
|
|
211
|
-
var endentation = endentations ? endentations[1] : "";
|
|
212
|
-
var indentedValue = value;
|
|
213
|
-
if (typeof value === "string" && value.includes("\n")) indentedValue = String(value).split("\n").map(function(str, i$1) {
|
|
214
|
-
return i$1 === 0 ? str : "" + endentation + str;
|
|
215
|
-
}).join("\n");
|
|
216
|
-
string += indentedValue + strings[i + 1];
|
|
217
|
-
});
|
|
218
|
-
return string;
|
|
591
|
+
//#region ../models/src/lib/dedent.ts
|
|
592
|
+
/**
|
|
593
|
+
* Dedent function for multi-line template strings.
|
|
594
|
+
* Adapted from ts-dedent (MIT License) to provide pure ESM support.
|
|
595
|
+
*
|
|
596
|
+
* Removes leading indentation from multi-line strings while preserving
|
|
597
|
+
* relative indentation between lines.
|
|
598
|
+
*/
|
|
599
|
+
function dedent(templ, ...values) {
|
|
600
|
+
let strings = Array.from(typeof templ === "string" ? [templ] : templ);
|
|
601
|
+
const lastIndex = strings.length - 1;
|
|
602
|
+
strings[lastIndex] = (strings[lastIndex] ?? "").replace(/\r?\n([\t ]*)$/, "");
|
|
603
|
+
const indentLengths = strings.reduce((arr, str) => {
|
|
604
|
+
const matches = str.match(/\n([\t ]+|(?!\s).)/g);
|
|
605
|
+
if (matches) return arr.concat(matches.map((match) => match.match(/[\t ]/g)?.length ?? 0));
|
|
606
|
+
return arr;
|
|
607
|
+
}, []);
|
|
608
|
+
if (indentLengths.length) {
|
|
609
|
+
const pattern = new RegExp(`\n[\t ]{${Math.min(...indentLengths)}}`, "g");
|
|
610
|
+
strings = strings.map((str) => str.replace(pattern, "\n"));
|
|
219
611
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
612
|
+
strings[0] = (strings[0] ?? "").replace(/^\r?\n/, "");
|
|
613
|
+
let string = strings[0] ?? "";
|
|
614
|
+
values.forEach((value, i) => {
|
|
615
|
+
const endentation = string.match(/(?:^|\n)( *)$/)?.[1] ?? "";
|
|
616
|
+
let indentedValue = value;
|
|
617
|
+
if (typeof value === "string" && value.includes("\n")) indentedValue = String(value).split("\n").map((str, j) => {
|
|
618
|
+
return j === 0 ? str : `${endentation}${str}`;
|
|
619
|
+
}).join("\n");
|
|
620
|
+
string += String(indentedValue) + (strings[i + 1] ?? "");
|
|
621
|
+
});
|
|
622
|
+
return string;
|
|
623
|
+
}
|
|
223
624
|
|
|
224
625
|
//#endregion
|
|
225
626
|
//#region ../models/src/api/common.ts
|
|
226
|
-
var import_dist = /* @__PURE__ */ __toESM(require_dist(), 1);
|
|
227
627
|
const errorBadRequest = z.object({
|
|
228
628
|
code: z.literal(400),
|
|
229
629
|
error: z.literal("Bad Request"),
|
|
@@ -233,7 +633,7 @@ const errorUnauthorized = z.object({
|
|
|
233
633
|
code: z.literal(401),
|
|
234
634
|
error: z.literal("Unauthorized"),
|
|
235
635
|
reason: z.literal("Failed to authenticate")
|
|
236
|
-
}).describe(
|
|
636
|
+
}).describe(dedent`
|
|
237
637
|
Authentication failed. Possible reasons:
|
|
238
638
|
- Authorization header is not provided
|
|
239
639
|
- Invalid API key
|
|
@@ -266,25 +666,24 @@ const errorUnauthorizedFlexible = z.object({
|
|
|
266
666
|
}).describe("Unauthorized");
|
|
267
667
|
|
|
268
668
|
//#endregion
|
|
269
|
-
//#region ../models/src/api/api-keys/
|
|
270
|
-
const request$
|
|
271
|
-
|
|
272
|
-
skip: z.coerce.number().min(0).default(0)
|
|
273
|
-
}) };
|
|
274
|
-
const apiKeyWithApplicationsSchema = apiKeySchema.extend({
|
|
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({
|
|
275
672
|
permissions: apiKeyPermissionsSchema.optional(),
|
|
276
673
|
wildcardApplicationAccess: z.boolean(),
|
|
277
674
|
applicationIds: z.array(cuidSchema)
|
|
278
|
-
});
|
|
279
|
-
const response$49 = z.object({
|
|
280
|
-
data: z.object({ apiKeys: z.array(apiKeyWithApplicationsSchema) }),
|
|
281
|
-
meta: paginationMeta
|
|
282
|
-
});
|
|
675
|
+
}) }) });
|
|
283
676
|
|
|
284
677
|
//#endregion
|
|
285
|
-
//#region ../models/src/api/api-keys/
|
|
286
|
-
const request$
|
|
287
|
-
|
|
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({
|
|
288
687
|
permissions: apiKeyPermissionsSchema.optional(),
|
|
289
688
|
wildcardApplicationAccess: z.boolean(),
|
|
290
689
|
applicationIds: z.array(cuidSchema)
|
|
@@ -313,25 +712,15 @@ const applicationSchema = z.object({
|
|
|
313
712
|
|
|
314
713
|
//#endregion
|
|
315
714
|
//#region ../models/src/api/applications/create.ts
|
|
316
|
-
const request$
|
|
715
|
+
const request$18 = { body: z.object({
|
|
317
716
|
name: applicationNameSchema,
|
|
318
717
|
applicationGroupId: cuidSchema.optional()
|
|
319
718
|
}) };
|
|
320
|
-
const response$
|
|
321
|
-
|
|
322
|
-
//#endregion
|
|
323
|
-
//#region ../models/src/api/applications/delete.ts
|
|
324
|
-
const request$44 = { params: z.object({ applicationId: cuidSchema }) };
|
|
325
|
-
const response$46 = z.object({ data: z.object({ application: applicationSchema }) });
|
|
326
|
-
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region ../models/src/api/applications/get.ts
|
|
329
|
-
const request$43 = { params: z.object({ applicationId: cuidSchema }) };
|
|
330
|
-
const response$45 = z.object({ data: z.object({ application: applicationSchema }) });
|
|
719
|
+
const response$18 = z.object({ data: z.object({ application: applicationSchema }) });
|
|
331
720
|
|
|
332
721
|
//#endregion
|
|
333
722
|
//#region ../models/src/api/applications/getAll.ts
|
|
334
|
-
const request$
|
|
723
|
+
const request$17 = { query: z.object({
|
|
335
724
|
name: z.union([z.string(), z.array(z.string())]).optional().transform((v) => Array.isArray(v) ? v.join(",") : v),
|
|
336
725
|
sort: z.enum([
|
|
337
726
|
"name",
|
|
@@ -342,21 +731,21 @@ const request$42 = { query: z.object({
|
|
|
342
731
|
take: z.coerce.number().min(1).max(100).default(20),
|
|
343
732
|
skip: z.coerce.number().min(0).default(0)
|
|
344
733
|
}) };
|
|
345
|
-
const response$
|
|
734
|
+
const response$17 = z.object({
|
|
346
735
|
data: z.object({ applications: z.array(applicationSchema) }),
|
|
347
736
|
meta: paginationMeta
|
|
348
737
|
});
|
|
349
738
|
|
|
350
739
|
//#endregion
|
|
351
740
|
//#region ../models/src/api/applications/update.ts
|
|
352
|
-
const request$
|
|
741
|
+
const request$16 = {
|
|
353
742
|
params: z.object({ applicationId: cuidSchema }),
|
|
354
743
|
body: z.object({
|
|
355
744
|
name: applicationNameSchema.optional(),
|
|
356
745
|
status: applicationStatusSchema.exclude(["deleted"]).optional()
|
|
357
746
|
}).refine((data) => data.name !== void 0 || data.status !== void 0, { message: "At least one field must be provided" })
|
|
358
747
|
};
|
|
359
|
-
const response$
|
|
748
|
+
const response$16 = z.object({ data: z.object({ application: applicationSchema }) });
|
|
360
749
|
|
|
361
750
|
//#endregion
|
|
362
751
|
//#region ../models/src/domain/secret.ts
|
|
@@ -378,44 +767,28 @@ const secretSchema = z.object({
|
|
|
378
767
|
|
|
379
768
|
//#endregion
|
|
380
769
|
//#region ../models/src/api/env/secrets/create.ts
|
|
381
|
-
const request$
|
|
770
|
+
const request$15 = { body: z.object({
|
|
382
771
|
applicationId: cuidSchema,
|
|
383
772
|
name: secretNameSchema,
|
|
384
773
|
value: secretValueSchema
|
|
385
774
|
}) };
|
|
386
|
-
const response$
|
|
387
|
-
|
|
388
|
-
//#endregion
|
|
389
|
-
//#region ../models/src/api/env/secrets/delete.ts
|
|
390
|
-
const request$39 = {
|
|
391
|
-
params: z.object({ name: z.string().min(1) }),
|
|
392
|
-
query: z.object({ applicationId: cuidSchema })
|
|
393
|
-
};
|
|
394
|
-
const response$41 = z.null();
|
|
395
|
-
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region ../models/src/api/env/secrets/get.ts
|
|
398
|
-
const request$38 = {
|
|
399
|
-
params: z.object({ name: z.string().min(1) }),
|
|
400
|
-
query: z.object({ applicationId: cuidSchema })
|
|
401
|
-
};
|
|
402
|
-
const response$40 = z.object({ data: z.object({ secret: secretMetadataSchema }) });
|
|
775
|
+
const response$15 = z.object({ data: z.object({ secret: secretMetadataSchema }) });
|
|
403
776
|
|
|
404
777
|
//#endregion
|
|
405
778
|
//#region ../models/src/api/env/secrets/getAll.ts
|
|
406
|
-
const request$
|
|
407
|
-
const response$
|
|
779
|
+
const request$14 = { query: z.object({ applicationId: cuidSchema.optional() }) };
|
|
780
|
+
const response$14 = z.object({ data: z.object({ secrets: z.array(secretMetadataSchema) }) });
|
|
408
781
|
|
|
409
782
|
//#endregion
|
|
410
783
|
//#region ../models/src/api/env/secrets/update.ts
|
|
411
|
-
const request$
|
|
784
|
+
const request$13 = {
|
|
412
785
|
params: z.object({ name: z.string().min(1) }),
|
|
413
786
|
body: z.object({
|
|
414
787
|
applicationId: cuidSchema,
|
|
415
788
|
value: secretValueSchema
|
|
416
789
|
})
|
|
417
790
|
};
|
|
418
|
-
const response$
|
|
791
|
+
const response$13 = z.object({ data: z.object({ secret: secretMetadataSchema }) });
|
|
419
792
|
|
|
420
793
|
//#endregion
|
|
421
794
|
//#region ../models/src/domain/variable.ts
|
|
@@ -439,44 +812,28 @@ const variableResponseSchema = z.object({
|
|
|
439
812
|
|
|
440
813
|
//#endregion
|
|
441
814
|
//#region ../models/src/api/env/variables/create.ts
|
|
442
|
-
const request$
|
|
815
|
+
const request$12 = { body: z.object({
|
|
443
816
|
applicationId: cuidSchema,
|
|
444
817
|
name: variableNameSchema,
|
|
445
818
|
value: variableValueSchema
|
|
446
819
|
}) };
|
|
447
|
-
const response$
|
|
448
|
-
|
|
449
|
-
//#endregion
|
|
450
|
-
//#region ../models/src/api/env/variables/delete.ts
|
|
451
|
-
const request$34 = {
|
|
452
|
-
params: z.object({ name: z.string().min(1) }),
|
|
453
|
-
query: z.object({ applicationId: cuidSchema })
|
|
454
|
-
};
|
|
455
|
-
const response$36 = z.null();
|
|
456
|
-
|
|
457
|
-
//#endregion
|
|
458
|
-
//#region ../models/src/api/env/variables/get.ts
|
|
459
|
-
const request$33 = {
|
|
460
|
-
params: z.object({ name: z.string().min(1) }),
|
|
461
|
-
query: z.object({ applicationId: cuidSchema })
|
|
462
|
-
};
|
|
463
|
-
const response$35 = z.object({ data: z.object({ variable: variableResponseSchema }) });
|
|
820
|
+
const response$12 = z.object({ data: z.object({ variable: variableResponseSchema }) });
|
|
464
821
|
|
|
465
822
|
//#endregion
|
|
466
823
|
//#region ../models/src/api/env/variables/getAll.ts
|
|
467
|
-
const request$
|
|
468
|
-
const response$
|
|
824
|
+
const request$11 = { query: z.object({ applicationId: cuidSchema }) };
|
|
825
|
+
const response$11 = z.object({ data: z.object({ variables: z.array(variableResponseSchema) }) });
|
|
469
826
|
|
|
470
827
|
//#endregion
|
|
471
828
|
//#region ../models/src/api/env/variables/update.ts
|
|
472
|
-
const request$
|
|
829
|
+
const request$10 = {
|
|
473
830
|
params: z.object({ name: z.string().min(1) }),
|
|
474
831
|
body: z.object({
|
|
475
832
|
applicationId: cuidSchema,
|
|
476
833
|
value: variableValueSchema
|
|
477
834
|
})
|
|
478
835
|
};
|
|
479
|
-
const response$
|
|
836
|
+
const response$10 = z.object({ data: z.object({ variable: variableResponseSchema }) });
|
|
480
837
|
|
|
481
838
|
//#endregion
|
|
482
839
|
//#region ../models/src/domain/expertScope.ts
|
|
@@ -484,6 +841,7 @@ const expertScopeSchema = z.object({
|
|
|
484
841
|
id: cuidSchema,
|
|
485
842
|
name: scopeNameSchema,
|
|
486
843
|
organizationId: cuidSchema,
|
|
844
|
+
expertDraftScopeId: cuidSchema,
|
|
487
845
|
published: z.boolean(),
|
|
488
846
|
publishedAt: datetimeSchema.optional(),
|
|
489
847
|
category: expertCategoryFieldSchema,
|
|
@@ -602,171 +960,9 @@ const expertWithMetadataSchema = expertSchema.extend({
|
|
|
602
960
|
version: expertVersionSchema
|
|
603
961
|
});
|
|
604
962
|
|
|
605
|
-
//#endregion
|
|
606
|
-
//#region ../models/src/api/experts/definition.ts
|
|
607
|
-
const expertDefinitionSchema = z.object({
|
|
608
|
-
name: expertNameFieldSchema,
|
|
609
|
-
version: expertVersionFieldSchema,
|
|
610
|
-
organizationId: cuidSchema,
|
|
611
|
-
createdAt: datetimeSchema,
|
|
612
|
-
updatedAt: datetimeSchema,
|
|
613
|
-
createdBy: cuidSchema,
|
|
614
|
-
updatedBy: cuidSchema,
|
|
615
|
-
experts: z.record(expertKeyFieldSchema, expertSchema.omit({ key: true }))
|
|
616
|
-
});
|
|
617
|
-
|
|
618
|
-
//#endregion
|
|
619
|
-
//#region ../models/src/api/experts/delete.ts
|
|
620
|
-
const request$30 = { params: z.object({ scopeName: scopeNameRefSchema }) };
|
|
621
|
-
const response$32 = z.object({ data: expertMetadataSchema.extend({
|
|
622
|
-
yanked: z.literal(true),
|
|
623
|
-
latestTagUpdated: z.boolean()
|
|
624
|
-
}) });
|
|
625
|
-
|
|
626
|
-
//#endregion
|
|
627
|
-
//#region ../models/src/domain/expertDraftScope.ts
|
|
628
|
-
const expertDraftScopeSchema = z.object({
|
|
629
|
-
id: cuidSchema,
|
|
630
|
-
name: scopeNameSchema,
|
|
631
|
-
organizationId: cuidSchema,
|
|
632
|
-
applicationId: cuidSchema,
|
|
633
|
-
totalRuns: z.number().int().min(0),
|
|
634
|
-
totalJobs: z.number().int().min(0),
|
|
635
|
-
createdAt: datetimeSchema,
|
|
636
|
-
updatedAt: datetimeSchema,
|
|
637
|
-
createdBy: cuidSchema,
|
|
638
|
-
updatedBy: cuidSchema
|
|
639
|
-
});
|
|
640
|
-
const expertDraftRefSchema = z.object({
|
|
641
|
-
id: cuidSchema,
|
|
642
|
-
expertDraftScopeId: cuidSchema,
|
|
643
|
-
totalRuns: z.number().int().min(0),
|
|
644
|
-
totalJobs: z.number().int().min(0),
|
|
645
|
-
createdAt: datetimeSchema,
|
|
646
|
-
updatedAt: datetimeSchema,
|
|
647
|
-
createdBy: cuidSchema,
|
|
648
|
-
updatedBy: cuidSchema
|
|
649
|
-
});
|
|
650
|
-
const expertDraftScopeWithRefsSchema = expertDraftScopeSchema.extend({ draftRefs: z.array(expertDraftRefSchema) });
|
|
651
|
-
|
|
652
|
-
//#endregion
|
|
653
|
-
//#region ../models/src/api/experts/drafts/definition.ts
|
|
654
|
-
const expertDefinitionContentSchema = z.object({
|
|
655
|
-
name: expertNameFieldSchema,
|
|
656
|
-
version: z.literal("0.0.0-draft"),
|
|
657
|
-
applicationId: cuidSchema,
|
|
658
|
-
createdAt: datetimeSchema,
|
|
659
|
-
updatedAt: datetimeSchema,
|
|
660
|
-
createdBy: cuidSchema,
|
|
661
|
-
updatedBy: cuidSchema,
|
|
662
|
-
experts: z.record(expertKeyFieldSchema, expertSchema.omit({ key: true }))
|
|
663
|
-
});
|
|
664
|
-
|
|
665
|
-
//#endregion
|
|
666
|
-
//#region ../models/src/api/experts/drafts/create.ts
|
|
667
|
-
const request$29 = {
|
|
668
|
-
params: z.object({ scopeName: scopeNameSchema }),
|
|
669
|
-
body: z.object({
|
|
670
|
-
applicationId: cuidSchema,
|
|
671
|
-
experts: z.array(expertSchema)
|
|
672
|
-
})
|
|
673
|
-
};
|
|
674
|
-
const response$31 = z.object({ data: z.object({
|
|
675
|
-
scope: expertDraftScopeSchema,
|
|
676
|
-
draftRef: expertDraftRefSchema,
|
|
677
|
-
definition: expertDefinitionContentSchema
|
|
678
|
-
}) });
|
|
679
|
-
|
|
680
|
-
//#endregion
|
|
681
|
-
//#region ../models/src/api/experts/drafts/delete.ts
|
|
682
|
-
const request$28 = { params: z.object({
|
|
683
|
-
scopeName: scopeNameSchema,
|
|
684
|
-
draftRef: expertDraftRefSchema.shape.id
|
|
685
|
-
}) };
|
|
686
|
-
const response$30 = z.object({ data: z.object({
|
|
687
|
-
deleted: z.boolean(),
|
|
688
|
-
draftRef: z.string()
|
|
689
|
-
}) });
|
|
690
|
-
|
|
691
|
-
//#endregion
|
|
692
|
-
//#region ../models/src/api/experts/drafts/get.ts
|
|
693
|
-
const request$27 = { params: z.object({
|
|
694
|
-
scopeName: scopeNameSchema,
|
|
695
|
-
draftRef: expertDraftRefSchema.shape.id
|
|
696
|
-
}) };
|
|
697
|
-
const response$29 = z.object({ data: z.object({
|
|
698
|
-
scope: expertDraftScopeSchema,
|
|
699
|
-
draftRef: expertDraftRefSchema,
|
|
700
|
-
definition: expertDefinitionContentSchema
|
|
701
|
-
}) });
|
|
702
|
-
|
|
703
|
-
//#endregion
|
|
704
|
-
//#region ../models/src/api/experts/drafts/getAll.ts
|
|
705
|
-
const request$26 = {
|
|
706
|
-
params: z.object({ scopeName: expertDraftScopeSchema.shape.name }),
|
|
707
|
-
query: z.object({
|
|
708
|
-
take: z.coerce.number().int().min(1).max(100).default(20),
|
|
709
|
-
skip: z.coerce.number().int().min(0).default(0)
|
|
710
|
-
})
|
|
711
|
-
};
|
|
712
|
-
const response$28 = z.object({
|
|
713
|
-
data: z.object({ draftRefs: z.array(expertDraftRefSchema) }),
|
|
714
|
-
meta: paginationMeta
|
|
715
|
-
});
|
|
716
|
-
|
|
717
|
-
//#endregion
|
|
718
|
-
//#region ../models/src/api/experts/drafts/update.ts
|
|
719
|
-
const request$25 = {
|
|
720
|
-
params: z.object({
|
|
721
|
-
scopeName: scopeNameSchema,
|
|
722
|
-
draftRef: expertDraftRefSchema.shape.id
|
|
723
|
-
}),
|
|
724
|
-
body: z.object({ experts: z.array(expertSchema) })
|
|
725
|
-
};
|
|
726
|
-
const response$27 = z.object({ data: z.object({
|
|
727
|
-
scope: expertDraftScopeSchema,
|
|
728
|
-
draftRef: expertDraftRefSchema,
|
|
729
|
-
definition: expertDefinitionContentSchema
|
|
730
|
-
}) });
|
|
731
|
-
|
|
732
|
-
//#endregion
|
|
733
|
-
//#region ../models/src/api/experts/drafts/version.ts
|
|
734
|
-
const request$24 = {
|
|
735
|
-
params: z.object({
|
|
736
|
-
scopeName: scopeNameSchema,
|
|
737
|
-
draftRef: z.string().min(1)
|
|
738
|
-
}),
|
|
739
|
-
body: z.object({
|
|
740
|
-
version: z.string().min(1, "Version is required.").max(maxExpertVersionTagLength, "Version is too long.").regex(expertVersionRegex, "Invalid version format. (e.g. 1.0.0)"),
|
|
741
|
-
tag: z.string().max(maxExpertVersionTagLength, "Tag is too long.").regex(tagNameRegex, "Invalid tag format. (e.g. latest)").optional()
|
|
742
|
-
})
|
|
743
|
-
};
|
|
744
|
-
const response$26 = z.object({ data: z.object({
|
|
745
|
-
scope: expertScopeSchema,
|
|
746
|
-
version: expertVersionSchema,
|
|
747
|
-
definitionUrl: z.string()
|
|
748
|
-
}) });
|
|
749
|
-
|
|
750
|
-
//#endregion
|
|
751
|
-
//#region ../models/src/api/experts/featured.ts
|
|
752
|
-
const response$25 = z.object({ data: z.object({ featuredExperts: z.array(z.object({
|
|
753
|
-
scope: expertScopeSchema,
|
|
754
|
-
currentVersion: expertVersionSchema,
|
|
755
|
-
displayOrder: z.number().int().min(0).max(2),
|
|
756
|
-
featuredAt: z.string().datetime()
|
|
757
|
-
})) }) });
|
|
758
|
-
|
|
759
|
-
//#endregion
|
|
760
|
-
//#region ../models/src/api/experts/get.ts
|
|
761
|
-
const request$23 = { params: z.object({ scopeName: scopeNameRefSchema }) };
|
|
762
|
-
const response$24 = z.object({ data: z.object({
|
|
763
|
-
definition: expertDefinitionSchema,
|
|
764
|
-
yanked: z.boolean().optional()
|
|
765
|
-
}) });
|
|
766
|
-
|
|
767
963
|
//#endregion
|
|
768
964
|
//#region ../models/src/api/experts/getAll.ts
|
|
769
|
-
const request$
|
|
965
|
+
const request$9 = { query: z.object({
|
|
770
966
|
filter: z.string().describe("Filter by scope name (partial match)").optional(),
|
|
771
967
|
category: z.enum([
|
|
772
968
|
"general",
|
|
@@ -775,38 +971,15 @@ const request$22 = { query: z.object({
|
|
|
775
971
|
"writing",
|
|
776
972
|
"data",
|
|
777
973
|
"automation"
|
|
778
|
-
]).describe("Filter by category").optional(),
|
|
779
|
-
includeDrafts: z.coerce.boolean().default(false).describe("Include unpublished scopes (owner only)").optional(),
|
|
780
|
-
take: z.coerce.number().min(1).max(100).default(20),
|
|
781
|
-
skip: z.coerce.number().min(0).default(0)
|
|
782
|
-
}) };
|
|
783
|
-
const response$
|
|
784
|
-
data: z.object({ experts: z.array(expertScopeSchema.extend({ currentVersion: expertVersionSchema })) }),
|
|
785
|
-
meta: paginationMeta
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
//#endregion
|
|
789
|
-
//#region ../models/src/api/experts/meta.ts
|
|
790
|
-
const request$21 = {
|
|
791
|
-
params: z.object({ scopeName: scopeNameRefSchema }),
|
|
792
|
-
query: z.object({ public: z.enum(["true", "false"]).transform((val) => val === "true").optional().default(false).describe("Public access check (no auth)") })
|
|
793
|
-
};
|
|
794
|
-
const response$22 = z.object({ data: expertMetadataSchema.extend({ definitionUrl: z.string() }) });
|
|
795
|
-
|
|
796
|
-
//#endregion
|
|
797
|
-
//#region ../models/src/api/experts/publish.ts
|
|
798
|
-
const request$20 = { params: z.object({ scopeName: scopeNameSchema }) };
|
|
799
|
-
const response$21 = z.object({ data: z.object({ scope: expertScopeSchema }) });
|
|
800
|
-
|
|
801
|
-
//#endregion
|
|
802
|
-
//#region ../models/src/api/experts/unpublish.ts
|
|
803
|
-
const request$19 = { params: z.object({ scopeName: scopeNameSchema }) };
|
|
804
|
-
const response$20 = z.object({ data: z.object({ scope: expertScopeSchema }) });
|
|
805
|
-
|
|
806
|
-
//#endregion
|
|
807
|
-
//#region ../models/src/api/experts/versions.ts
|
|
808
|
-
const request$18 = { params: z.object({ scopeName: scopeNameSchema }) };
|
|
809
|
-
const response$19 = z.object({ data: z.object({ versions: z.array(expertVersionSchema) }) });
|
|
974
|
+
]).describe("Filter by category").optional(),
|
|
975
|
+
includeDrafts: z.coerce.boolean().default(false).describe("Include unpublished scopes (owner only)").optional(),
|
|
976
|
+
take: z.coerce.number().min(1).max(100).default(20),
|
|
977
|
+
skip: z.coerce.number().min(0).default(0)
|
|
978
|
+
}) };
|
|
979
|
+
const response$9 = z.object({
|
|
980
|
+
data: z.object({ experts: z.array(expertScopeSchema.extend({ currentVersion: expertVersionSchema.nullable() })) }),
|
|
981
|
+
meta: paginationMeta
|
|
982
|
+
});
|
|
810
983
|
|
|
811
984
|
//#endregion
|
|
812
985
|
//#region ../models/src/domain/checkpoint.ts
|
|
@@ -885,26 +1058,18 @@ const requestCheckpointSchema = perstackCheckpointSchema.omit({
|
|
|
885
1058
|
id: true,
|
|
886
1059
|
runId: true
|
|
887
1060
|
}).extend({ runId: z.string().optional() });
|
|
888
|
-
const request$
|
|
1061
|
+
const request$8 = {
|
|
889
1062
|
params: z.object({ jobId: cuidSchema }),
|
|
890
1063
|
body: z.object({
|
|
891
1064
|
checkpoint: requestCheckpointSchema,
|
|
892
1065
|
step: stepSchema
|
|
893
1066
|
})
|
|
894
1067
|
};
|
|
895
|
-
const response$
|
|
896
|
-
|
|
897
|
-
//#endregion
|
|
898
|
-
//#region ../models/src/api/jobs/checkpoints/get.ts
|
|
899
|
-
const request$16 = { params: z.object({
|
|
900
|
-
jobId: cuidSchema,
|
|
901
|
-
checkpointId: cuidSchema
|
|
902
|
-
}) };
|
|
903
|
-
const response$17 = z.object({ data: z.object({ checkpoint: apiCheckpointSchema }) });
|
|
1068
|
+
const response$8 = z.object({ data: z.object({ checkpoint: apiCheckpointSchema }) });
|
|
904
1069
|
|
|
905
1070
|
//#endregion
|
|
906
1071
|
//#region ../models/src/api/jobs/checkpoints/getAll.ts
|
|
907
|
-
const request$
|
|
1072
|
+
const request$7 = {
|
|
908
1073
|
params: z.object({ jobId: cuidSchema }),
|
|
909
1074
|
query: z.object({
|
|
910
1075
|
filter: z.string().min(1).max(256).optional(),
|
|
@@ -914,16 +1079,11 @@ const request$15 = {
|
|
|
914
1079
|
skip: z.coerce.number().min(0).default(0)
|
|
915
1080
|
})
|
|
916
1081
|
};
|
|
917
|
-
const response$
|
|
1082
|
+
const response$7 = z.object({
|
|
918
1083
|
data: z.object({ checkpoints: z.array(apiCheckpointSchema) }),
|
|
919
1084
|
meta: paginationMeta
|
|
920
1085
|
});
|
|
921
1086
|
|
|
922
|
-
//#endregion
|
|
923
|
-
//#region ../models/src/api/jobs/checkpoints/stream.ts
|
|
924
|
-
const request$14 = { params: z.object({ jobId: cuidSchema }) };
|
|
925
|
-
const response$15 = z.object({ data: apiCheckpointSchema });
|
|
926
|
-
|
|
927
1087
|
//#endregion
|
|
928
1088
|
//#region ../support-models/src/index.ts
|
|
929
1089
|
const anthropicSupportModels = [
|
|
@@ -1124,7 +1284,7 @@ const jobSchema = z.object({
|
|
|
1124
1284
|
|
|
1125
1285
|
//#endregion
|
|
1126
1286
|
//#region ../models/src/api/jobs/continue.ts
|
|
1127
|
-
const request$
|
|
1287
|
+
const request$6 = {
|
|
1128
1288
|
params: z.object({ jobId: cuidSchema }),
|
|
1129
1289
|
body: z.object({
|
|
1130
1290
|
query: jobSchema.shape.query.optional(),
|
|
@@ -1137,11 +1297,11 @@ const request$13 = {
|
|
|
1137
1297
|
maxRetries: z.coerce.number().optional()
|
|
1138
1298
|
})
|
|
1139
1299
|
};
|
|
1140
|
-
const response$
|
|
1300
|
+
const response$6 = z.object({ data: z.object({ job: jobSchema }) });
|
|
1141
1301
|
|
|
1142
1302
|
//#endregion
|
|
1143
1303
|
//#region ../models/src/api/jobs/create.ts
|
|
1144
|
-
const request$
|
|
1304
|
+
const request$5 = { body: z.object({
|
|
1145
1305
|
applicationId: cuidSchema.describe("Application ID to create the job in"),
|
|
1146
1306
|
expertKey: expertKeyFieldSchema,
|
|
1147
1307
|
query: jobSchema.shape.query.optional(),
|
|
@@ -1152,33 +1312,28 @@ const request$12 = { body: z.object({
|
|
|
1152
1312
|
maxSteps: z.coerce.number().optional(),
|
|
1153
1313
|
maxRetries: z.coerce.number().optional()
|
|
1154
1314
|
}) };
|
|
1155
|
-
const response$
|
|
1156
|
-
|
|
1157
|
-
//#endregion
|
|
1158
|
-
//#region ../models/src/api/jobs/get.ts
|
|
1159
|
-
const request$11 = { params: z.object({ jobId: cuidSchema }) };
|
|
1160
|
-
const response$12 = z.object({ data: z.object({ job: jobSchema }) });
|
|
1315
|
+
const response$5 = z.object({ data: z.object({ job: jobSchema }) });
|
|
1161
1316
|
|
|
1162
1317
|
//#endregion
|
|
1163
1318
|
//#region ../models/src/api/jobs/getAll.ts
|
|
1164
|
-
const request$
|
|
1319
|
+
const request$4 = { query: z.object({
|
|
1165
1320
|
sort: z.enum(["createdAt", "updatedAt"]).optional(),
|
|
1166
1321
|
order: z.enum(["asc", "desc"]).optional(),
|
|
1167
1322
|
take: z.coerce.number().min(1).max(100).default(20),
|
|
1168
1323
|
skip: z.coerce.number().min(0).default(0)
|
|
1169
1324
|
}) };
|
|
1170
|
-
const response$
|
|
1325
|
+
const response$4 = z.object({
|
|
1171
1326
|
data: z.object({ jobs: z.array(jobSchema) }),
|
|
1172
1327
|
meta: paginationMeta
|
|
1173
1328
|
});
|
|
1174
1329
|
|
|
1175
1330
|
//#endregion
|
|
1176
1331
|
//#region ../models/src/api/jobs/update.ts
|
|
1177
|
-
const request$
|
|
1332
|
+
const request$3 = {
|
|
1178
1333
|
params: z.object({ jobId: cuidSchema }),
|
|
1179
1334
|
body: z.object({ status: jobStatusSchema })
|
|
1180
1335
|
};
|
|
1181
|
-
const response$
|
|
1336
|
+
const response$3 = z.object({ data: z.object({ job: jobSchema }) });
|
|
1182
1337
|
|
|
1183
1338
|
//#endregion
|
|
1184
1339
|
//#region ../models/src/domain/providerSetting.ts
|
|
@@ -1255,7 +1410,7 @@ const providerApiKeyMetadataSchema = z.object({
|
|
|
1255
1410
|
|
|
1256
1411
|
//#endregion
|
|
1257
1412
|
//#region ../models/src/api/provider-settings/api-keys/create.ts
|
|
1258
|
-
const request$
|
|
1413
|
+
const request$2 = {
|
|
1259
1414
|
params: z.object({
|
|
1260
1415
|
applicationId: cuidSchema,
|
|
1261
1416
|
provider: providerSchema
|
|
@@ -1264,947 +1419,433 @@ const request$8 = {
|
|
|
1264
1419
|
name: z.string().min(1).max(255),
|
|
1265
1420
|
value: z.string().min(1)
|
|
1266
1421
|
})
|
|
1267
|
-
};
|
|
1268
|
-
const response$
|
|
1269
|
-
|
|
1270
|
-
//#endregion
|
|
1271
|
-
//#region ../models/src/api/provider-settings/api-keys/delete.ts
|
|
1272
|
-
const request$7 = { params: z.object({
|
|
1273
|
-
applicationId: cuidSchema,
|
|
1274
|
-
provider: providerSchema,
|
|
1275
|
-
apiKeyId: cuidSchema
|
|
1276
|
-
}) };
|
|
1277
|
-
const response$8 = z.null();
|
|
1278
|
-
|
|
1279
|
-
//#endregion
|
|
1280
|
-
//#region ../models/src/api/provider-settings/api-keys/getAll.ts
|
|
1281
|
-
const request$6 = { params: z.object({
|
|
1282
|
-
applicationId: cuidSchema,
|
|
1283
|
-
provider: providerSchema
|
|
1284
|
-
}) };
|
|
1285
|
-
const response$7 = z.object({ data: z.object({ apiKeys: z.array(providerApiKeyMetadataSchema) }) });
|
|
1286
|
-
|
|
1287
|
-
//#endregion
|
|
1288
|
-
//#region ../models/src/api/provider-settings/create.ts
|
|
1289
|
-
const request$5 = {
|
|
1290
|
-
params: z.object({ applicationId: cuidSchema }),
|
|
1291
|
-
body: z.object({
|
|
1292
|
-
provider: providerSchema,
|
|
1293
|
-
settings: providerSettingsSchema.optional()
|
|
1294
|
-
})
|
|
1295
|
-
};
|
|
1296
|
-
const response$6 = z.object({ data: z.object({ providerSetting: providerSettingResponseSchema }) });
|
|
1297
|
-
|
|
1298
|
-
//#endregion
|
|
1299
|
-
//#region ../models/src/api/provider-settings/delete.ts
|
|
1300
|
-
const request$4 = { params: z.object({
|
|
1301
|
-
applicationId: cuidSchema,
|
|
1302
|
-
provider: providerSchema
|
|
1303
|
-
}) };
|
|
1304
|
-
const response$5 = z.null();
|
|
1305
|
-
|
|
1306
|
-
//#endregion
|
|
1307
|
-
//#region ../models/src/api/provider-settings/get.ts
|
|
1308
|
-
const request$3 = { params: z.object({
|
|
1309
|
-
applicationId: cuidSchema,
|
|
1310
|
-
provider: providerSchema
|
|
1311
|
-
}) };
|
|
1312
|
-
const response$4 = z.object({ data: z.object({
|
|
1313
|
-
providerSetting: providerSettingResponseSchema,
|
|
1314
|
-
apiKeys: z.array(providerApiKeyMetadataSchema)
|
|
1315
|
-
}) });
|
|
1316
|
-
|
|
1317
|
-
//#endregion
|
|
1318
|
-
//#region ../models/src/api/provider-settings/getAll.ts
|
|
1319
|
-
const request$2 = { params: z.object({ applicationId: cuidSchema }) };
|
|
1320
|
-
const response$3 = z.object({ data: z.object({ providerSettings: z.array(providerSettingResponseSchema) }) });
|
|
1321
|
-
|
|
1322
|
-
//#endregion
|
|
1323
|
-
//#region ../models/src/api/provider-settings/update.ts
|
|
1324
|
-
const request$1 = {
|
|
1325
|
-
params: z.object({
|
|
1326
|
-
applicationId: cuidSchema,
|
|
1327
|
-
provider: providerSchema
|
|
1328
|
-
}),
|
|
1329
|
-
body: z.object({ settings: providerSettingsSchema.optional() })
|
|
1330
|
-
};
|
|
1331
|
-
const response$2 = z.object({ data: z.object({ providerSetting: providerSettingResponseSchema }) });
|
|
1332
|
-
|
|
1333
|
-
//#endregion
|
|
1334
|
-
//#region ../models/src/api/session/get.ts
|
|
1335
|
-
const response$1 = z.object({ data: z.object({
|
|
1336
|
-
user: userSchema,
|
|
1337
|
-
organization: organizationSchema,
|
|
1338
|
-
application: applicationSchema.nullable()
|
|
1339
|
-
}) });
|
|
1340
|
-
|
|
1341
|
-
//#endregion
|
|
1342
|
-
//#region ../models/src/api/session/setApplication.ts
|
|
1343
|
-
const request = { body: z.object({ applicationId: z.string().min(1, "Application ID is required") }) };
|
|
1344
|
-
const response = z.object({ data: z.object({ success: z.literal(true) }) });
|
|
1345
|
-
|
|
1346
|
-
//#endregion
|
|
1347
|
-
//#region ../models/src/domain/providerApiKey.ts
|
|
1348
|
-
const providerApiKeyNameSchema = z.string().min(1).max(255);
|
|
1349
|
-
const providerApiKeyValueSchema = z.string().min(1);
|
|
1350
|
-
const providerApiKeySchema = z.object({
|
|
1351
|
-
type: z.literal("providerApiKey"),
|
|
1352
|
-
id: cuidSchema,
|
|
1353
|
-
providerSettingId: cuidSchema,
|
|
1354
|
-
name: providerApiKeyNameSchema,
|
|
1355
|
-
lastUsedAt: datetimeSchema.optional(),
|
|
1356
|
-
expiresAt: datetimeSchema.optional(),
|
|
1357
|
-
providerSetting: providerSettingSchema,
|
|
1358
|
-
createdAt: datetimeSchema,
|
|
1359
|
-
updatedAt: datetimeSchema
|
|
1360
|
-
});
|
|
1361
|
-
|
|
1362
|
-
//#endregion
|
|
1363
|
-
//#region ../models/src/domain/run.ts
|
|
1364
|
-
const runStatusSchema = z.enum([
|
|
1365
|
-
"queued",
|
|
1366
|
-
"processing",
|
|
1367
|
-
"completed",
|
|
1368
|
-
"stoppedByInteractiveTool",
|
|
1369
|
-
"stoppedByDelegate",
|
|
1370
|
-
"stoppedByExceededMaxSteps",
|
|
1371
|
-
"stoppedByError"
|
|
1372
|
-
]);
|
|
1373
|
-
const runSchema = z.object({
|
|
1374
|
-
type: z.literal("run"),
|
|
1375
|
-
id: cuidSchema,
|
|
1376
|
-
jobId: cuidSchema,
|
|
1377
|
-
parentRunId: cuidSchema.optional(),
|
|
1378
|
-
organizationId: cuidSchema,
|
|
1379
|
-
createdAt: datetimeSchema,
|
|
1380
|
-
updatedAt: datetimeSchema,
|
|
1381
|
-
status: runStatusSchema,
|
|
1382
|
-
runtimeVersion: runtimeVersionSchema,
|
|
1383
|
-
expertKey: expertKeyFieldSchema,
|
|
1384
|
-
interactiveToolCallResult: z.boolean().optional(),
|
|
1385
|
-
expert: expertWithMetadataSchema,
|
|
1386
|
-
stepNumber: z.number().int().min(0),
|
|
1387
|
-
usage: usageSchema,
|
|
1388
|
-
machineId: z.string().optional()
|
|
1389
|
-
});
|
|
1390
|
-
|
|
1391
|
-
//#endregion
|
|
1392
|
-
//#region src/lib/errors.ts
|
|
1393
|
-
function createValidationError(error) {
|
|
1394
|
-
return {
|
|
1395
|
-
errorType: "validation",
|
|
1396
|
-
code: 400,
|
|
1397
|
-
message: `Validation failed: ${error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")}`,
|
|
1398
|
-
reason: error.issues
|
|
1399
|
-
};
|
|
1400
|
-
}
|
|
1401
|
-
function createAbortError() {
|
|
1402
|
-
return {
|
|
1403
|
-
errorType: "abort",
|
|
1404
|
-
code: 0,
|
|
1405
|
-
message: "Request aborted",
|
|
1406
|
-
aborted: true
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
|
-
function createTimeoutError() {
|
|
1410
|
-
return {
|
|
1411
|
-
errorType: "timeout",
|
|
1412
|
-
code: 0,
|
|
1413
|
-
message: "Request timed out"
|
|
1414
|
-
};
|
|
1415
|
-
}
|
|
1416
|
-
function createNetworkError(error) {
|
|
1417
|
-
return {
|
|
1418
|
-
errorType: "network",
|
|
1419
|
-
code: 0,
|
|
1420
|
-
message: error instanceof Error ? error.message : "Network error",
|
|
1421
|
-
reason: error,
|
|
1422
|
-
cause: error instanceof Error ? error : void 0
|
|
1423
|
-
};
|
|
1424
|
-
}
|
|
1425
|
-
async function handleHttpError(response$52) {
|
|
1426
|
-
let errorBody;
|
|
1427
|
-
try {
|
|
1428
|
-
errorBody = await response$52.json();
|
|
1429
|
-
} catch {
|
|
1430
|
-
errorBody = void 0;
|
|
1431
|
-
}
|
|
1432
|
-
return {
|
|
1433
|
-
ok: false,
|
|
1434
|
-
error: createHttpError(response$52.status, response$52.statusText, errorBody)
|
|
1435
|
-
};
|
|
1436
|
-
}
|
|
1437
|
-
function createHttpError(status, statusText, body) {
|
|
1438
|
-
if (typeof body === "object" && body !== null) {
|
|
1439
|
-
const hasReason = "reason" in body;
|
|
1440
|
-
if ("error" in body && typeof body.error === "string") return {
|
|
1441
|
-
errorType: "http",
|
|
1442
|
-
code: status,
|
|
1443
|
-
message: body.error,
|
|
1444
|
-
reason: hasReason ? body.reason : void 0
|
|
1445
|
-
};
|
|
1446
|
-
if (hasReason) return {
|
|
1447
|
-
errorType: "http",
|
|
1448
|
-
code: status,
|
|
1449
|
-
message: statusText,
|
|
1450
|
-
reason: body.reason
|
|
1451
|
-
};
|
|
1452
|
-
}
|
|
1453
|
-
return {
|
|
1454
|
-
errorType: "http",
|
|
1455
|
-
code: status,
|
|
1456
|
-
message: statusText
|
|
1457
|
-
};
|
|
1458
|
-
}
|
|
1459
|
-
function isHttpError(error) {
|
|
1460
|
-
return error.errorType === "http";
|
|
1461
|
-
}
|
|
1462
|
-
function isNetworkError(error) {
|
|
1463
|
-
return error.errorType === "network";
|
|
1464
|
-
}
|
|
1465
|
-
function isTimeoutError(error) {
|
|
1466
|
-
return error.errorType === "timeout";
|
|
1467
|
-
}
|
|
1468
|
-
function isValidationError(error) {
|
|
1469
|
-
return error.errorType === "validation";
|
|
1470
|
-
}
|
|
1471
|
-
function isAbortError(error) {
|
|
1472
|
-
return error.errorType === "abort";
|
|
1473
|
-
}
|
|
1474
|
-
function isClientError(error) {
|
|
1475
|
-
return error.errorType !== "http";
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
//#endregion
|
|
1479
|
-
//#region src/endpoints/api-keys.ts
|
|
1480
|
-
const BASE_PATH$6 = "/api/v1/api_keys";
|
|
1481
|
-
function createApiKeysApi(fetcher) {
|
|
1482
|
-
return {
|
|
1483
|
-
async create(input, options) {
|
|
1484
|
-
const result = request$49.body.safeParse(input);
|
|
1485
|
-
if (!result.success) return {
|
|
1486
|
-
ok: false,
|
|
1487
|
-
error: createValidationError(result.error)
|
|
1488
|
-
};
|
|
1489
|
-
return fetcher.post(BASE_PATH$6, input, options);
|
|
1490
|
-
},
|
|
1491
|
-
async list(input, options) {
|
|
1492
|
-
const queryParams = new URLSearchParams();
|
|
1493
|
-
if (input?.take !== void 0) queryParams.set("take", String(input.take));
|
|
1494
|
-
if (input?.skip !== void 0) queryParams.set("skip", String(input.skip));
|
|
1495
|
-
const queryString = queryParams.toString();
|
|
1496
|
-
const url = queryString ? `${BASE_PATH$6}?${queryString}` : BASE_PATH$6;
|
|
1497
|
-
return fetcher.get(url, options);
|
|
1498
|
-
},
|
|
1499
|
-
async get(id, options) {
|
|
1500
|
-
const result = request$48.params.safeParse({ apiKeyId: id });
|
|
1501
|
-
if (!result.success) return {
|
|
1502
|
-
ok: false,
|
|
1503
|
-
error: createValidationError(result.error)
|
|
1504
|
-
};
|
|
1505
|
-
return fetcher.get(`${BASE_PATH$6}/${id}`, options);
|
|
1506
|
-
},
|
|
1507
|
-
async revoke(id, options) {
|
|
1508
|
-
const result = request$46.params.safeParse({ apiKeyId: id });
|
|
1509
|
-
if (!result.success) return {
|
|
1510
|
-
ok: false,
|
|
1511
|
-
error: createValidationError(result.error)
|
|
1512
|
-
};
|
|
1513
|
-
return fetcher.post(`${BASE_PATH$6}/${id}/revoke`, {}, options);
|
|
1514
|
-
}
|
|
1515
|
-
};
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
//#endregion
|
|
1519
|
-
//#region src/lib/query-string.ts
|
|
1520
|
-
function buildQueryString(params) {
|
|
1521
|
-
if (!params) return "";
|
|
1522
|
-
const searchParams = new URLSearchParams();
|
|
1523
|
-
for (const [key, value] of Object.entries(params)) if (value !== void 0) searchParams.set(key, String(value));
|
|
1524
|
-
const queryString = searchParams.toString();
|
|
1525
|
-
return queryString ? `?${queryString}` : "";
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
//#endregion
|
|
1529
|
-
//#region src/endpoints/applications.ts
|
|
1530
|
-
const BASE_PATH$5 = "/api/v1/applications";
|
|
1531
|
-
function createApplicationsApi(fetcher) {
|
|
1532
|
-
return {
|
|
1533
|
-
async list(params, options) {
|
|
1534
|
-
if (params) {
|
|
1535
|
-
const result = request$42.query.safeParse(params);
|
|
1536
|
-
if (!result.success) return {
|
|
1537
|
-
ok: false,
|
|
1538
|
-
error: createValidationError(result.error)
|
|
1539
|
-
};
|
|
1540
|
-
}
|
|
1541
|
-
const queryString = buildQueryString(params);
|
|
1542
|
-
return fetcher.get(`${BASE_PATH$5}${queryString}`, options);
|
|
1543
|
-
},
|
|
1544
|
-
async get(id, options) {
|
|
1545
|
-
return fetcher.get(`${BASE_PATH$5}/${id}`, options);
|
|
1546
|
-
},
|
|
1547
|
-
async create(input, options) {
|
|
1548
|
-
const result = request$45.body.safeParse(input);
|
|
1549
|
-
if (!result.success) return {
|
|
1550
|
-
ok: false,
|
|
1551
|
-
error: createValidationError(result.error)
|
|
1552
|
-
};
|
|
1553
|
-
return fetcher.post(BASE_PATH$5, input, options);
|
|
1554
|
-
},
|
|
1555
|
-
async update(id, input, options) {
|
|
1556
|
-
const result = request$41.body.safeParse(input);
|
|
1557
|
-
if (!result.success) return {
|
|
1558
|
-
ok: false,
|
|
1559
|
-
error: createValidationError(result.error)
|
|
1560
|
-
};
|
|
1561
|
-
return fetcher.post(`${BASE_PATH$5}/${id}`, input, options);
|
|
1562
|
-
},
|
|
1563
|
-
async delete(id, options) {
|
|
1564
|
-
return fetcher.delete(`${BASE_PATH$5}/${id}`, options);
|
|
1565
|
-
}
|
|
1566
|
-
};
|
|
1567
|
-
}
|
|
1422
|
+
};
|
|
1423
|
+
const response$2 = z.object({ data: z.object({ apiKey: providerApiKeyMetadataSchema }) });
|
|
1568
1424
|
|
|
1569
1425
|
//#endregion
|
|
1570
|
-
//#region src/
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1426
|
+
//#region ../models/src/api/provider-settings/create.ts
|
|
1427
|
+
const request$1 = {
|
|
1428
|
+
params: z.object({ applicationId: cuidSchema }),
|
|
1429
|
+
body: z.object({
|
|
1430
|
+
provider: providerSchema,
|
|
1431
|
+
settings: providerSettingsSchema.optional()
|
|
1432
|
+
})
|
|
1433
|
+
};
|
|
1434
|
+
const response$1 = z.object({ data: z.object({ providerSetting: providerSettingResponseSchema }) });
|
|
1435
|
+
|
|
1436
|
+
//#endregion
|
|
1437
|
+
//#region ../models/src/api/provider-settings/update.ts
|
|
1438
|
+
const request = {
|
|
1439
|
+
params: z.object({
|
|
1440
|
+
applicationId: cuidSchema,
|
|
1441
|
+
provider: providerSchema
|
|
1442
|
+
}),
|
|
1443
|
+
body: z.object({ settings: providerSettingsSchema.optional() })
|
|
1444
|
+
};
|
|
1445
|
+
const response = z.object({ data: z.object({ providerSetting: providerSettingResponseSchema }) });
|
|
1446
|
+
|
|
1447
|
+
//#endregion
|
|
1448
|
+
//#region src/endpoints/api-keys.ts
|
|
1449
|
+
const BASE_PATH$6 = "/api/v1/api_keys";
|
|
1450
|
+
function createApiKeysApi(fetcher) {
|
|
1573
1451
|
return {
|
|
1574
|
-
async list(params, options) {
|
|
1575
|
-
if (params) {
|
|
1576
|
-
const result = request$37.query.safeParse(params);
|
|
1577
|
-
if (!result.success) return {
|
|
1578
|
-
ok: false,
|
|
1579
|
-
error: createValidationError(result.error)
|
|
1580
|
-
};
|
|
1581
|
-
}
|
|
1582
|
-
const queryString = buildQueryString(params);
|
|
1583
|
-
return fetcher.get(`${BASE_PATH$4}${queryString}`, options);
|
|
1584
|
-
},
|
|
1585
|
-
async get(name, options) {
|
|
1586
|
-
const encodedName = encodeURIComponent(name);
|
|
1587
|
-
return fetcher.get(`${BASE_PATH$4}/${encodedName}`, options);
|
|
1588
|
-
},
|
|
1589
1452
|
async create(input, options) {
|
|
1590
|
-
const result = request$
|
|
1453
|
+
const result = request$22.body.safeParse(input);
|
|
1591
1454
|
if (!result.success) return {
|
|
1592
1455
|
ok: false,
|
|
1593
1456
|
error: createValidationError(result.error)
|
|
1594
1457
|
};
|
|
1595
|
-
return fetcher.post(BASE_PATH$
|
|
1458
|
+
return fetcher.post(BASE_PATH$6, input, options);
|
|
1596
1459
|
},
|
|
1597
|
-
async
|
|
1598
|
-
const
|
|
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 });
|
|
1599
1470
|
if (!result.success) return {
|
|
1600
1471
|
ok: false,
|
|
1601
1472
|
error: createValidationError(result.error)
|
|
1602
1473
|
};
|
|
1603
|
-
|
|
1604
|
-
return fetcher.put(`${BASE_PATH$4}/${encodedName}`, input, options);
|
|
1474
|
+
return fetcher.get(`${BASE_PATH$6}/${id}`, options);
|
|
1605
1475
|
},
|
|
1606
|
-
async
|
|
1607
|
-
const
|
|
1608
|
-
return fetcher.deleteNoContent(`${BASE_PATH$4}/${encodedName}`, options);
|
|
1609
|
-
}
|
|
1610
|
-
};
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
//#endregion
|
|
1614
|
-
//#region src/endpoints/env-variables.ts
|
|
1615
|
-
const BASE_PATH$3 = "/api/v1/env/variables";
|
|
1616
|
-
function createVariablesApi(fetcher) {
|
|
1617
|
-
return {
|
|
1618
|
-
async list(params, options) {
|
|
1619
|
-
const result = request$32.query.safeParse(params);
|
|
1476
|
+
async revoke(id, options) {
|
|
1477
|
+
const result = request$20.params.safeParse({ apiKeyId: id });
|
|
1620
1478
|
if (!result.success) return {
|
|
1621
1479
|
ok: false,
|
|
1622
1480
|
error: createValidationError(result.error)
|
|
1623
1481
|
};
|
|
1624
|
-
|
|
1625
|
-
return fetcher.get(`${BASE_PATH$3}${queryString}`, options);
|
|
1626
|
-
},
|
|
1627
|
-
async get(name, options) {
|
|
1628
|
-
const encodedName = encodeURIComponent(name);
|
|
1629
|
-
return fetcher.get(`${BASE_PATH$3}/${encodedName}`, options);
|
|
1482
|
+
return fetcher.post(`${BASE_PATH$6}/${id}/revoke`, {}, options);
|
|
1630
1483
|
},
|
|
1631
|
-
async
|
|
1632
|
-
const
|
|
1633
|
-
if (!
|
|
1484
|
+
async update(id, input, options) {
|
|
1485
|
+
const paramsResult = request$19.params.safeParse({ apiKeyId: id });
|
|
1486
|
+
if (!paramsResult.success) return {
|
|
1634
1487
|
ok: false,
|
|
1635
|
-
error: createValidationError(
|
|
1488
|
+
error: createValidationError(paramsResult.error)
|
|
1636
1489
|
};
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
async update(name, input, options) {
|
|
1640
|
-
const result = request$31.body.safeParse(input);
|
|
1641
|
-
if (!result.success) return {
|
|
1490
|
+
const bodyResult = request$19.body.safeParse(input);
|
|
1491
|
+
if (!bodyResult.success) return {
|
|
1642
1492
|
ok: false,
|
|
1643
|
-
error: createValidationError(
|
|
1493
|
+
error: createValidationError(bodyResult.error)
|
|
1644
1494
|
};
|
|
1645
|
-
|
|
1646
|
-
return fetcher.put(`${BASE_PATH$3}/${encodedName}`, input, options);
|
|
1647
|
-
},
|
|
1648
|
-
async delete(name, options) {
|
|
1649
|
-
const encodedName = encodeURIComponent(name);
|
|
1650
|
-
return fetcher.deleteNoContent(`${BASE_PATH$3}/${encodedName}`, options);
|
|
1495
|
+
return fetcher.post(`${BASE_PATH$6}/${id}`, input, options);
|
|
1651
1496
|
}
|
|
1652
1497
|
};
|
|
1653
1498
|
}
|
|
1654
1499
|
|
|
1655
1500
|
//#endregion
|
|
1656
|
-
//#region src/endpoints/
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
secrets: createSecretsApi(fetcher),
|
|
1660
|
-
variables: createVariablesApi(fetcher)
|
|
1661
|
-
};
|
|
1662
|
-
}
|
|
1663
|
-
|
|
1664
|
-
//#endregion
|
|
1665
|
-
//#region src/endpoints/experts-drafts.ts
|
|
1666
|
-
function createDraftsApi(fetcher, basePath) {
|
|
1501
|
+
//#region src/endpoints/applications.ts
|
|
1502
|
+
const BASE_PATH$5 = "/api/v1/applications";
|
|
1503
|
+
function createApplicationsApi(fetcher) {
|
|
1667
1504
|
return {
|
|
1668
|
-
async list(
|
|
1505
|
+
async list(params, options) {
|
|
1669
1506
|
if (params) {
|
|
1670
|
-
const result = request$
|
|
1507
|
+
const result = request$17.query.safeParse(params);
|
|
1671
1508
|
if (!result.success) return {
|
|
1672
1509
|
ok: false,
|
|
1673
1510
|
error: createValidationError(result.error)
|
|
1674
1511
|
};
|
|
1675
1512
|
}
|
|
1676
|
-
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1677
1513
|
const queryString = buildQueryString(params);
|
|
1678
|
-
return fetcher.get(`${
|
|
1679
|
-
},
|
|
1680
|
-
async get(scopeName, draftRef, options) {
|
|
1681
|
-
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1682
|
-
const encodedDraftRef = encodeURIComponent(draftRef);
|
|
1683
|
-
return fetcher.get(`${basePath}/${encodedScopeName}/drafts/${encodedDraftRef}`, options);
|
|
1684
|
-
},
|
|
1685
|
-
async create(scopeName, input, options) {
|
|
1686
|
-
const result = request$29.body.safeParse(input);
|
|
1687
|
-
if (!result.success) return {
|
|
1688
|
-
ok: false,
|
|
1689
|
-
error: createValidationError(result.error)
|
|
1690
|
-
};
|
|
1691
|
-
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1692
|
-
return fetcher.post(`${basePath}/${encodedScopeName}/drafts`, input, options);
|
|
1693
|
-
},
|
|
1694
|
-
async update(scopeName, draftRef, input, options) {
|
|
1695
|
-
const result = request$25.body.safeParse(input);
|
|
1696
|
-
if (!result.success) return {
|
|
1697
|
-
ok: false,
|
|
1698
|
-
error: createValidationError(result.error)
|
|
1699
|
-
};
|
|
1700
|
-
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1701
|
-
const encodedDraftRef = encodeURIComponent(draftRef);
|
|
1702
|
-
return fetcher.post(`${basePath}/${encodedScopeName}/drafts/${encodedDraftRef}`, input, options);
|
|
1514
|
+
return fetcher.get(`${BASE_PATH$5}${queryString}`, options);
|
|
1703
1515
|
},
|
|
1704
|
-
async
|
|
1705
|
-
|
|
1706
|
-
const encodedDraftRef = encodeURIComponent(draftRef);
|
|
1707
|
-
return fetcher.delete(`${basePath}/${encodedScopeName}/drafts/${encodedDraftRef}`, options);
|
|
1516
|
+
async get(id, options) {
|
|
1517
|
+
return fetcher.get(`${BASE_PATH$5}/${id}`, options);
|
|
1708
1518
|
},
|
|
1709
|
-
async
|
|
1710
|
-
const result = request$
|
|
1519
|
+
async create(input, options) {
|
|
1520
|
+
const result = request$18.body.safeParse(input);
|
|
1711
1521
|
if (!result.success) return {
|
|
1712
1522
|
ok: false,
|
|
1713
1523
|
error: createValidationError(result.error)
|
|
1714
1524
|
};
|
|
1715
|
-
|
|
1716
|
-
const encodedDraftRef = encodeURIComponent(draftRef);
|
|
1717
|
-
return fetcher.post(`${basePath}/${encodedScopeName}/drafts/${encodedDraftRef}/version`, input, options);
|
|
1718
|
-
}
|
|
1719
|
-
};
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
//#endregion
|
|
1723
|
-
//#region src/endpoints/experts-versions.ts
|
|
1724
|
-
function createVersionsApi(fetcher, basePath) {
|
|
1725
|
-
return { async list(scopeName, options) {
|
|
1726
|
-
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1727
|
-
return fetcher.get(`${basePath}/${encodedScopeName}/versions`, options);
|
|
1728
|
-
} };
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
//#endregion
|
|
1732
|
-
//#region src/endpoints/experts.ts
|
|
1733
|
-
const BASE_PATH$2 = "/api/v1/experts";
|
|
1734
|
-
function createExpertsApi(fetcher) {
|
|
1735
|
-
return {
|
|
1736
|
-
async list(params, options) {
|
|
1737
|
-
if (params) {
|
|
1738
|
-
const result = request$22.query.safeParse(params);
|
|
1739
|
-
if (!result.success) return {
|
|
1740
|
-
ok: false,
|
|
1741
|
-
error: createValidationError(result.error)
|
|
1742
|
-
};
|
|
1743
|
-
}
|
|
1744
|
-
const queryString = buildQueryString(params);
|
|
1745
|
-
return fetcher.get(`${BASE_PATH$2}${queryString}`, options);
|
|
1746
|
-
},
|
|
1747
|
-
async get(key, options) {
|
|
1748
|
-
const encodedKey = encodeURIComponent(key);
|
|
1749
|
-
return fetcher.get(`${BASE_PATH$2}/${encodedKey}`, options);
|
|
1750
|
-
},
|
|
1751
|
-
async getFeatured(options) {
|
|
1752
|
-
return fetcher.get(`${BASE_PATH$2}/featured`, options);
|
|
1753
|
-
},
|
|
1754
|
-
async getMeta(key, options) {
|
|
1755
|
-
const encodedKey = encodeURIComponent(key);
|
|
1756
|
-
return fetcher.get(`${BASE_PATH$2}/${encodedKey}/meta`, options);
|
|
1757
|
-
},
|
|
1758
|
-
async publish(scopeName, options) {
|
|
1759
|
-
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1760
|
-
return fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/publish`, {}, options);
|
|
1761
|
-
},
|
|
1762
|
-
async unpublish(scopeName, options) {
|
|
1763
|
-
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1764
|
-
return fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/unpublish`, {}, options);
|
|
1765
|
-
},
|
|
1766
|
-
async yank(key, options) {
|
|
1767
|
-
const encodedKey = encodeURIComponent(key);
|
|
1768
|
-
return fetcher.delete(`${BASE_PATH$2}/${encodedKey}`, options);
|
|
1769
|
-
},
|
|
1770
|
-
drafts: createDraftsApi(fetcher, BASE_PATH$2),
|
|
1771
|
-
versions: createVersionsApi(fetcher, BASE_PATH$2)
|
|
1772
|
-
};
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
//#endregion
|
|
1776
|
-
//#region src/lib/sse.ts
|
|
1777
|
-
async function* parseSSE(reader) {
|
|
1778
|
-
const decoder = new TextDecoder();
|
|
1779
|
-
let buffer = "";
|
|
1780
|
-
while (true) {
|
|
1781
|
-
const { value, done } = await reader.read();
|
|
1782
|
-
if (done) break;
|
|
1783
|
-
buffer += decoder.decode(value, { stream: true });
|
|
1784
|
-
const events = buffer.split("\n\n");
|
|
1785
|
-
buffer = events.pop() || "";
|
|
1786
|
-
for (const event of events) {
|
|
1787
|
-
if (event.trim() === "") continue;
|
|
1788
|
-
const lines = event.split("\n");
|
|
1789
|
-
const eventType = lines.find((line) => line.startsWith("event:"))?.slice(6).trim();
|
|
1790
|
-
const data = lines.find((line) => line.startsWith("data:"))?.slice(5).trim();
|
|
1791
|
-
if (eventType !== "message" || !data) continue;
|
|
1792
|
-
try {
|
|
1793
|
-
yield JSON.parse(data);
|
|
1794
|
-
} catch {}
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
//#endregion
|
|
1800
|
-
//#region src/endpoints/jobs-checkpoints.ts
|
|
1801
|
-
function createCheckpointsApi(fetcher, basePath) {
|
|
1802
|
-
return {
|
|
1803
|
-
async list(jobId, params, options) {
|
|
1804
|
-
if (params) {
|
|
1805
|
-
const result = request$15.query.safeParse(params);
|
|
1806
|
-
if (!result.success) return {
|
|
1807
|
-
ok: false,
|
|
1808
|
-
error: createValidationError(result.error)
|
|
1809
|
-
};
|
|
1810
|
-
}
|
|
1811
|
-
const queryString = buildQueryString(params);
|
|
1812
|
-
return fetcher.get(`${basePath}/${jobId}/checkpoints${queryString}`, options);
|
|
1813
|
-
},
|
|
1814
|
-
async get(jobId, checkpointId, options) {
|
|
1815
|
-
return fetcher.get(`${basePath}/${jobId}/checkpoints/${checkpointId}`, options);
|
|
1525
|
+
return fetcher.post(BASE_PATH$5, input, options);
|
|
1816
1526
|
},
|
|
1817
|
-
async
|
|
1818
|
-
const result = request$
|
|
1527
|
+
async update(id, input, options) {
|
|
1528
|
+
const result = request$16.body.safeParse(input);
|
|
1819
1529
|
if (!result.success) return {
|
|
1820
1530
|
ok: false,
|
|
1821
1531
|
error: createValidationError(result.error)
|
|
1822
1532
|
};
|
|
1823
|
-
return fetcher.post(`${
|
|
1533
|
+
return fetcher.post(`${BASE_PATH$5}/${id}`, input, options);
|
|
1824
1534
|
},
|
|
1825
|
-
async
|
|
1826
|
-
|
|
1827
|
-
if (!result.ok) {
|
|
1828
|
-
yield {
|
|
1829
|
-
ok: false,
|
|
1830
|
-
error: result.error
|
|
1831
|
-
};
|
|
1832
|
-
return;
|
|
1833
|
-
}
|
|
1834
|
-
const reader = result.data.getReader();
|
|
1835
|
-
try {
|
|
1836
|
-
for await (const checkpoint of parseSSE(reader)) yield {
|
|
1837
|
-
ok: true,
|
|
1838
|
-
data: checkpoint
|
|
1839
|
-
};
|
|
1840
|
-
} catch (error) {
|
|
1841
|
-
if (error instanceof DOMException && error.name === "AbortError") yield {
|
|
1842
|
-
ok: false,
|
|
1843
|
-
error: createAbortError()
|
|
1844
|
-
};
|
|
1845
|
-
else yield {
|
|
1846
|
-
ok: false,
|
|
1847
|
-
error: createNetworkError(error)
|
|
1848
|
-
};
|
|
1849
|
-
}
|
|
1535
|
+
async delete(id, options) {
|
|
1536
|
+
return fetcher.delete(`${BASE_PATH$5}/${id}`, options);
|
|
1850
1537
|
}
|
|
1851
1538
|
};
|
|
1852
1539
|
}
|
|
1853
1540
|
|
|
1854
1541
|
//#endregion
|
|
1855
|
-
//#region src/endpoints/
|
|
1856
|
-
const BASE_PATH$
|
|
1857
|
-
function
|
|
1542
|
+
//#region src/endpoints/env-secrets.ts
|
|
1543
|
+
const BASE_PATH$4 = "/api/v1/env/secrets";
|
|
1544
|
+
function createSecretsApi(fetcher) {
|
|
1858
1545
|
return {
|
|
1859
1546
|
async list(params, options) {
|
|
1860
1547
|
if (params) {
|
|
1861
|
-
const result = request$
|
|
1548
|
+
const result = request$14.query.safeParse(params);
|
|
1862
1549
|
if (!result.success) return {
|
|
1863
1550
|
ok: false,
|
|
1864
1551
|
error: createValidationError(result.error)
|
|
1865
1552
|
};
|
|
1866
1553
|
}
|
|
1867
1554
|
const queryString = buildQueryString(params);
|
|
1868
|
-
return fetcher.get(`${BASE_PATH$
|
|
1869
|
-
},
|
|
1870
|
-
async get(id, options) {
|
|
1871
|
-
return fetcher.get(`${BASE_PATH$1}/${id}`, options);
|
|
1555
|
+
return fetcher.get(`${BASE_PATH$4}${queryString}`, options);
|
|
1872
1556
|
},
|
|
1873
|
-
async
|
|
1874
|
-
const
|
|
1875
|
-
|
|
1876
|
-
ok: false,
|
|
1877
|
-
error: createValidationError(result.error)
|
|
1878
|
-
};
|
|
1879
|
-
return fetcher.post(BASE_PATH$1, input, options);
|
|
1557
|
+
async get(name, options) {
|
|
1558
|
+
const encodedName = encodeURIComponent(name);
|
|
1559
|
+
return fetcher.get(`${BASE_PATH$4}/${encodedName}`, options);
|
|
1880
1560
|
},
|
|
1881
|
-
async
|
|
1882
|
-
const result = request$
|
|
1561
|
+
async create(input, options) {
|
|
1562
|
+
const result = request$15.body.safeParse(input);
|
|
1883
1563
|
if (!result.success) return {
|
|
1884
1564
|
ok: false,
|
|
1885
1565
|
error: createValidationError(result.error)
|
|
1886
1566
|
};
|
|
1887
|
-
return fetcher.post(
|
|
1567
|
+
return fetcher.post(BASE_PATH$4, input, options);
|
|
1888
1568
|
},
|
|
1889
|
-
async
|
|
1569
|
+
async update(name, input, options) {
|
|
1890
1570
|
const result = request$13.body.safeParse(input);
|
|
1891
1571
|
if (!result.success) return {
|
|
1892
1572
|
ok: false,
|
|
1893
1573
|
error: createValidationError(result.error)
|
|
1894
1574
|
};
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
async cancel(id, options) {
|
|
1898
|
-
return fetcher.post(`${BASE_PATH$1}/${id}/cancel`, {}, options);
|
|
1575
|
+
const encodedName = encodeURIComponent(name);
|
|
1576
|
+
return fetcher.put(`${BASE_PATH$4}/${encodedName}`, input, options);
|
|
1899
1577
|
},
|
|
1900
|
-
|
|
1578
|
+
async delete(name, options) {
|
|
1579
|
+
const encodedName = encodeURIComponent(name);
|
|
1580
|
+
return fetcher.deleteNoContent(`${BASE_PATH$4}/${encodedName}`, options);
|
|
1581
|
+
}
|
|
1901
1582
|
};
|
|
1902
1583
|
}
|
|
1903
1584
|
|
|
1904
1585
|
//#endregion
|
|
1905
|
-
//#region src/endpoints/
|
|
1906
|
-
const BASE_PATH = "/api/v1/
|
|
1907
|
-
function
|
|
1586
|
+
//#region src/endpoints/env-variables.ts
|
|
1587
|
+
const BASE_PATH$3 = "/api/v1/env/variables";
|
|
1588
|
+
function createVariablesApi(fetcher) {
|
|
1908
1589
|
return {
|
|
1909
|
-
async list(
|
|
1910
|
-
|
|
1911
|
-
},
|
|
1912
|
-
async get(applicationId, provider, options) {
|
|
1913
|
-
const encodedProvider = encodeURIComponent(provider);
|
|
1914
|
-
return fetcher.get(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, options);
|
|
1915
|
-
},
|
|
1916
|
-
async create(applicationId, input, options) {
|
|
1917
|
-
const result = request$5.body.safeParse(input);
|
|
1590
|
+
async list(params, options) {
|
|
1591
|
+
const result = request$11.query.safeParse(params);
|
|
1918
1592
|
if (!result.success) return {
|
|
1919
1593
|
ok: false,
|
|
1920
1594
|
error: createValidationError(result.error)
|
|
1921
1595
|
};
|
|
1922
|
-
|
|
1596
|
+
const queryString = buildQueryString(params);
|
|
1597
|
+
return fetcher.get(`${BASE_PATH$3}${queryString}`, options);
|
|
1923
1598
|
},
|
|
1924
|
-
async
|
|
1925
|
-
const
|
|
1599
|
+
async get(name, options) {
|
|
1600
|
+
const encodedName = encodeURIComponent(name);
|
|
1601
|
+
return fetcher.get(`${BASE_PATH$3}/${encodedName}`, options);
|
|
1602
|
+
},
|
|
1603
|
+
async create(input, options) {
|
|
1604
|
+
const result = request$12.body.safeParse(input);
|
|
1926
1605
|
if (!result.success) return {
|
|
1927
1606
|
ok: false,
|
|
1928
1607
|
error: createValidationError(result.error)
|
|
1929
1608
|
};
|
|
1930
|
-
|
|
1931
|
-
return fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, input, options);
|
|
1932
|
-
},
|
|
1933
|
-
async delete(applicationId, provider, options) {
|
|
1934
|
-
const encodedProvider = encodeURIComponent(provider);
|
|
1935
|
-
return fetcher.deleteNoContent(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, options);
|
|
1936
|
-
},
|
|
1937
|
-
async listApiKeys(applicationId, provider, options) {
|
|
1938
|
-
const encodedProvider = encodeURIComponent(provider);
|
|
1939
|
-
return fetcher.get(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}/api_keys`, options);
|
|
1609
|
+
return fetcher.post(BASE_PATH$3, input, options);
|
|
1940
1610
|
},
|
|
1941
|
-
async
|
|
1942
|
-
const result = request$
|
|
1611
|
+
async update(name, input, options) {
|
|
1612
|
+
const result = request$10.body.safeParse(input);
|
|
1943
1613
|
if (!result.success) return {
|
|
1944
1614
|
ok: false,
|
|
1945
1615
|
error: createValidationError(result.error)
|
|
1946
1616
|
};
|
|
1947
|
-
const
|
|
1948
|
-
return fetcher.
|
|
1617
|
+
const encodedName = encodeURIComponent(name);
|
|
1618
|
+
return fetcher.put(`${BASE_PATH$3}/${encodedName}`, input, options);
|
|
1949
1619
|
},
|
|
1950
|
-
async
|
|
1951
|
-
const
|
|
1952
|
-
|
|
1953
|
-
return fetcher.deleteNoContent(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}/api_keys/${encodedApiKeyId}`, options);
|
|
1620
|
+
async delete(name, options) {
|
|
1621
|
+
const encodedName = encodeURIComponent(name);
|
|
1622
|
+
return fetcher.deleteNoContent(`${BASE_PATH$3}/${encodedName}`, options);
|
|
1954
1623
|
}
|
|
1955
1624
|
};
|
|
1956
1625
|
}
|
|
1957
1626
|
|
|
1958
1627
|
//#endregion
|
|
1959
|
-
//#region src/
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
const
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
}, timeout);
|
|
1986
|
-
let abortHandler;
|
|
1987
|
-
if (externalSignal) if (externalSignal.aborted) controller.abort();
|
|
1988
|
-
else {
|
|
1989
|
-
abortHandler = () => controller.abort();
|
|
1990
|
-
externalSignal.addEventListener("abort", abortHandler);
|
|
1991
|
-
}
|
|
1992
|
-
return {
|
|
1993
|
-
signal: controller.signal,
|
|
1994
|
-
cleanup: () => {
|
|
1995
|
-
clearTimeout(timeoutId);
|
|
1996
|
-
if (abortHandler && externalSignal) externalSignal.removeEventListener("abort", abortHandler);
|
|
1997
|
-
},
|
|
1998
|
-
isTimeout: () => timedOut
|
|
1999
|
-
};
|
|
2000
|
-
}
|
|
2001
|
-
function wrapStreamWithIdleTimeout(stream, idleTimeoutMs, externalSignal) {
|
|
2002
|
-
const reader = stream.getReader();
|
|
2003
|
-
const controller = new AbortController();
|
|
2004
|
-
let timeoutId;
|
|
2005
|
-
let abortHandler;
|
|
2006
|
-
if (externalSignal) if (externalSignal.aborted) controller.abort();
|
|
2007
|
-
else {
|
|
2008
|
-
abortHandler = () => controller.abort();
|
|
2009
|
-
externalSignal.addEventListener("abort", abortHandler);
|
|
2010
|
-
}
|
|
2011
|
-
function resetTimeout() {
|
|
2012
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
2013
|
-
timeoutId = setTimeout(() => controller.abort(), idleTimeoutMs);
|
|
2014
|
-
}
|
|
2015
|
-
function cleanup() {
|
|
2016
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
2017
|
-
if (abortHandler && externalSignal) externalSignal.removeEventListener("abort", abortHandler);
|
|
2018
|
-
}
|
|
2019
|
-
return new ReadableStream({
|
|
2020
|
-
start() {
|
|
2021
|
-
resetTimeout();
|
|
2022
|
-
},
|
|
2023
|
-
async pull(streamController) {
|
|
2024
|
-
try {
|
|
2025
|
-
const result = await Promise.race([reader.read(), new Promise((_, reject) => {
|
|
2026
|
-
if (controller.signal.aborted) reject(new DOMException("Stream idle timeout", "AbortError"));
|
|
2027
|
-
controller.signal.addEventListener("abort", () => {
|
|
2028
|
-
reject(new DOMException("Stream idle timeout", "AbortError"));
|
|
2029
|
-
});
|
|
2030
|
-
})]);
|
|
2031
|
-
if (result.done) {
|
|
2032
|
-
cleanup();
|
|
2033
|
-
streamController.close();
|
|
2034
|
-
return;
|
|
2035
|
-
}
|
|
2036
|
-
resetTimeout();
|
|
2037
|
-
streamController.enqueue(result.value);
|
|
2038
|
-
} catch (error) {
|
|
2039
|
-
cleanup();
|
|
2040
|
-
reader.cancel().catch(() => {});
|
|
2041
|
-
if (error instanceof DOMException && error.name === "AbortError") streamController.error(new DOMException("Stream idle timeout", "AbortError"));
|
|
2042
|
-
else streamController.error(error);
|
|
2043
|
-
}
|
|
2044
|
-
},
|
|
2045
|
-
cancel(reason) {
|
|
2046
|
-
cleanup();
|
|
2047
|
-
reader.cancel(reason).catch(() => {});
|
|
2048
|
-
}
|
|
2049
|
-
});
|
|
2050
|
-
}
|
|
2051
|
-
async function request$50(method, path, body, options) {
|
|
2052
|
-
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
2053
|
-
try {
|
|
2054
|
-
const response$52 = await fetch(buildUrl(path), {
|
|
2055
|
-
method,
|
|
2056
|
-
headers: buildHeaders(body ? { hasBody: true } : void 0),
|
|
2057
|
-
body: body ? JSON.stringify(body) : void 0,
|
|
2058
|
-
signal,
|
|
2059
|
-
credentials: getCredentials()
|
|
2060
|
-
});
|
|
2061
|
-
if (!response$52.ok) return handleHttpError(response$52);
|
|
2062
|
-
return {
|
|
2063
|
-
ok: true,
|
|
2064
|
-
data: await response$52.json()
|
|
2065
|
-
};
|
|
2066
|
-
} catch (error) {
|
|
2067
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
2068
|
-
if (isTimeout()) return {
|
|
1628
|
+
//#region src/endpoints/env.ts
|
|
1629
|
+
function createEnvApi(fetcher) {
|
|
1630
|
+
return {
|
|
1631
|
+
secrets: createSecretsApi(fetcher),
|
|
1632
|
+
variables: createVariablesApi(fetcher)
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
//#endregion
|
|
1637
|
+
//#region src/endpoints/experts-versions.ts
|
|
1638
|
+
function createVersionsApi(fetcher, basePath) {
|
|
1639
|
+
return { async list(scopeName, options) {
|
|
1640
|
+
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1641
|
+
return fetcher.get(`${basePath}/${encodedScopeName}/versions`, options);
|
|
1642
|
+
} };
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
//#endregion
|
|
1646
|
+
//#region src/endpoints/experts.ts
|
|
1647
|
+
const BASE_PATH$2 = "/api/v1/experts";
|
|
1648
|
+
function createExpertsApi(fetcher) {
|
|
1649
|
+
return {
|
|
1650
|
+
async list(params, options) {
|
|
1651
|
+
if (params) {
|
|
1652
|
+
const result = request$9.query.safeParse(params);
|
|
1653
|
+
if (!result.success) return {
|
|
2069
1654
|
ok: false,
|
|
2070
|
-
error:
|
|
1655
|
+
error: createValidationError(result.error)
|
|
2071
1656
|
};
|
|
2072
|
-
|
|
1657
|
+
}
|
|
1658
|
+
const queryString = buildQueryString(params);
|
|
1659
|
+
return fetcher.get(`${BASE_PATH$2}${queryString}`, options);
|
|
1660
|
+
},
|
|
1661
|
+
async get(key, options) {
|
|
1662
|
+
const encodedKey = encodeURIComponent(key);
|
|
1663
|
+
return fetcher.get(`${BASE_PATH$2}/${encodedKey}`, options);
|
|
1664
|
+
},
|
|
1665
|
+
async getFeatured(options) {
|
|
1666
|
+
return fetcher.get(`${BASE_PATH$2}/featured`, options);
|
|
1667
|
+
},
|
|
1668
|
+
async getMeta(key, options) {
|
|
1669
|
+
const encodedKey = encodeURIComponent(key);
|
|
1670
|
+
return fetcher.get(`${BASE_PATH$2}/${encodedKey}/meta`, options);
|
|
1671
|
+
},
|
|
1672
|
+
async publish(scopeName, options) {
|
|
1673
|
+
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1674
|
+
return fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/publish`, {}, options);
|
|
1675
|
+
},
|
|
1676
|
+
async unpublish(scopeName, options) {
|
|
1677
|
+
const encodedScopeName = encodeURIComponent(scopeName);
|
|
1678
|
+
return fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/unpublish`, {}, options);
|
|
1679
|
+
},
|
|
1680
|
+
async yank(key, options) {
|
|
1681
|
+
const encodedKey = encodeURIComponent(key);
|
|
1682
|
+
return fetcher.delete(`${BASE_PATH$2}/${encodedKey}`, options);
|
|
1683
|
+
},
|
|
1684
|
+
versions: createVersionsApi(fetcher, BASE_PATH$2)
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
//#endregion
|
|
1689
|
+
//#region src/endpoints/jobs-checkpoints.ts
|
|
1690
|
+
function createCheckpointsApi(fetcher, basePath) {
|
|
1691
|
+
return {
|
|
1692
|
+
async list(jobId, params, options) {
|
|
1693
|
+
if (params) {
|
|
1694
|
+
const result = request$7.query.safeParse(params);
|
|
1695
|
+
if (!result.success) return {
|
|
2073
1696
|
ok: false,
|
|
2074
|
-
error:
|
|
1697
|
+
error: createValidationError(result.error)
|
|
2075
1698
|
};
|
|
2076
1699
|
}
|
|
2077
|
-
|
|
1700
|
+
const queryString = buildQueryString(params);
|
|
1701
|
+
return fetcher.get(`${basePath}/${jobId}/checkpoints${queryString}`, options);
|
|
1702
|
+
},
|
|
1703
|
+
async get(jobId, checkpointId, options) {
|
|
1704
|
+
return fetcher.get(`${basePath}/${jobId}/checkpoints/${checkpointId}`, options);
|
|
1705
|
+
},
|
|
1706
|
+
async create(jobId, input, options) {
|
|
1707
|
+
const result = request$8.body.safeParse(input);
|
|
1708
|
+
if (!result.success) return {
|
|
2078
1709
|
ok: false,
|
|
2079
|
-
error:
|
|
2080
|
-
};
|
|
2081
|
-
} finally {
|
|
2082
|
-
cleanup();
|
|
2083
|
-
}
|
|
2084
|
-
}
|
|
2085
|
-
async function requestBlob(path, options) {
|
|
2086
|
-
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
2087
|
-
try {
|
|
2088
|
-
const response$52 = await fetch(buildUrl(path), {
|
|
2089
|
-
method: "GET",
|
|
2090
|
-
headers: buildHeaders(),
|
|
2091
|
-
signal,
|
|
2092
|
-
credentials: getCredentials()
|
|
2093
|
-
});
|
|
2094
|
-
if (!response$52.ok) return handleHttpError(response$52);
|
|
2095
|
-
return {
|
|
2096
|
-
ok: true,
|
|
2097
|
-
data: await response$52.blob()
|
|
1710
|
+
error: createValidationError(result.error)
|
|
2098
1711
|
};
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
1712
|
+
return fetcher.post(`${basePath}/${jobId}/checkpoints`, input, options);
|
|
1713
|
+
},
|
|
1714
|
+
async *stream(jobId, options) {
|
|
1715
|
+
const result = await fetcher.getStream(`${basePath}/${jobId}/checkpoints/stream`, options);
|
|
1716
|
+
if (!result.ok) {
|
|
1717
|
+
yield {
|
|
2102
1718
|
ok: false,
|
|
2103
|
-
error:
|
|
1719
|
+
error: result.error
|
|
2104
1720
|
};
|
|
2105
|
-
return
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1723
|
+
const reader = result.data.getReader();
|
|
1724
|
+
try {
|
|
1725
|
+
for await (const checkpoint of parseSSE(reader)) yield {
|
|
1726
|
+
ok: true,
|
|
1727
|
+
data: checkpoint
|
|
1728
|
+
};
|
|
1729
|
+
} catch (error) {
|
|
1730
|
+
if (error instanceof DOMException && error.name === "AbortError") yield {
|
|
2106
1731
|
ok: false,
|
|
2107
1732
|
error: createAbortError()
|
|
2108
1733
|
};
|
|
2109
|
-
|
|
2110
|
-
return {
|
|
2111
|
-
ok: false,
|
|
2112
|
-
error: createNetworkError(error)
|
|
2113
|
-
};
|
|
2114
|
-
} finally {
|
|
2115
|
-
cleanup();
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
async function requestStream(path, options) {
|
|
2119
|
-
const { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);
|
|
2120
|
-
try {
|
|
2121
|
-
const response$52 = await fetch(buildUrl(path), {
|
|
2122
|
-
method: "GET",
|
|
2123
|
-
headers: buildHeaders(),
|
|
2124
|
-
signal,
|
|
2125
|
-
credentials: getCredentials()
|
|
2126
|
-
});
|
|
2127
|
-
if (!response$52.ok) {
|
|
2128
|
-
cleanup();
|
|
2129
|
-
return handleHttpError(response$52);
|
|
2130
|
-
}
|
|
2131
|
-
if (!response$52.body) {
|
|
2132
|
-
cleanup();
|
|
2133
|
-
return {
|
|
1734
|
+
else yield {
|
|
2134
1735
|
ok: false,
|
|
2135
|
-
error: createNetworkError(
|
|
1736
|
+
error: createNetworkError(error)
|
|
2136
1737
|
};
|
|
2137
1738
|
}
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
return {
|
|
1739
|
+
}
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
//#endregion
|
|
1744
|
+
//#region src/endpoints/jobs.ts
|
|
1745
|
+
const BASE_PATH$1 = "/api/v1/jobs";
|
|
1746
|
+
function createJobsApi(fetcher) {
|
|
1747
|
+
return {
|
|
1748
|
+
async list(params, options) {
|
|
1749
|
+
if (params) {
|
|
1750
|
+
const result = request$4.query.safeParse(params);
|
|
1751
|
+
if (!result.success) return {
|
|
2152
1752
|
ok: false,
|
|
2153
|
-
error:
|
|
1753
|
+
error: createValidationError(result.error)
|
|
2154
1754
|
};
|
|
2155
1755
|
}
|
|
2156
|
-
|
|
1756
|
+
const queryString = buildQueryString(params);
|
|
1757
|
+
return fetcher.get(`${BASE_PATH$1}${queryString}`, options);
|
|
1758
|
+
},
|
|
1759
|
+
async get(id, options) {
|
|
1760
|
+
return fetcher.get(`${BASE_PATH$1}/${id}`, options);
|
|
1761
|
+
},
|
|
1762
|
+
async start(input, options) {
|
|
1763
|
+
const result = request$5.body.safeParse(input);
|
|
1764
|
+
if (!result.success) return {
|
|
2157
1765
|
ok: false,
|
|
2158
|
-
error:
|
|
1766
|
+
error: createValidationError(result.error)
|
|
2159
1767
|
};
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
headers: buildHeaders(),
|
|
2168
|
-
signal,
|
|
2169
|
-
credentials: getCredentials()
|
|
2170
|
-
});
|
|
2171
|
-
if (!response$52.ok) return handleHttpError(response$52);
|
|
2172
|
-
return {
|
|
2173
|
-
ok: true,
|
|
2174
|
-
data: void 0
|
|
1768
|
+
return fetcher.post(BASE_PATH$1, input, options);
|
|
1769
|
+
},
|
|
1770
|
+
async update(id, input, options) {
|
|
1771
|
+
const result = request$3.body.safeParse(input);
|
|
1772
|
+
if (!result.success) return {
|
|
1773
|
+
ok: false,
|
|
1774
|
+
error: createValidationError(result.error)
|
|
2175
1775
|
};
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
};
|
|
2182
|
-
return {
|
|
2183
|
-
ok: false,
|
|
2184
|
-
error: createAbortError()
|
|
2185
|
-
};
|
|
2186
|
-
}
|
|
2187
|
-
return {
|
|
1776
|
+
return fetcher.post(`${BASE_PATH$1}/${id}`, input, options);
|
|
1777
|
+
},
|
|
1778
|
+
async continue(id, input, options) {
|
|
1779
|
+
const result = request$6.body.safeParse(input);
|
|
1780
|
+
if (!result.success) return {
|
|
2188
1781
|
ok: false,
|
|
2189
|
-
error:
|
|
1782
|
+
error: createValidationError(result.error)
|
|
2190
1783
|
};
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
1784
|
+
return fetcher.post(`${BASE_PATH$1}/${id}/continue`, input, options);
|
|
1785
|
+
},
|
|
1786
|
+
async cancel(id, options) {
|
|
1787
|
+
return fetcher.post(`${BASE_PATH$1}/${id}/cancel`, {}, options);
|
|
1788
|
+
},
|
|
1789
|
+
checkpoints: createCheckpointsApi(fetcher, BASE_PATH$1)
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
//#endregion
|
|
1794
|
+
//#region src/endpoints/provider-settings.ts
|
|
1795
|
+
const BASE_PATH = "/api/v1/applications";
|
|
1796
|
+
function createProviderSettingsApi(fetcher) {
|
|
2195
1797
|
return {
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
1798
|
+
async list(applicationId, options) {
|
|
1799
|
+
return fetcher.get(`${BASE_PATH}/${applicationId}/provider_settings`, options);
|
|
1800
|
+
},
|
|
1801
|
+
async get(applicationId, provider, options) {
|
|
1802
|
+
const encodedProvider = encodeURIComponent(provider);
|
|
1803
|
+
return fetcher.get(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, options);
|
|
1804
|
+
},
|
|
1805
|
+
async create(applicationId, input, options) {
|
|
1806
|
+
const result = request$1.body.safeParse(input);
|
|
1807
|
+
if (!result.success) return {
|
|
1808
|
+
ok: false,
|
|
1809
|
+
error: createValidationError(result.error)
|
|
1810
|
+
};
|
|
1811
|
+
return fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings`, input, options);
|
|
1812
|
+
},
|
|
1813
|
+
async update(applicationId, provider, input, options) {
|
|
1814
|
+
const result = request.body.safeParse(input);
|
|
1815
|
+
if (!result.success) return {
|
|
1816
|
+
ok: false,
|
|
1817
|
+
error: createValidationError(result.error)
|
|
1818
|
+
};
|
|
1819
|
+
const encodedProvider = encodeURIComponent(provider);
|
|
1820
|
+
return fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, input, options);
|
|
1821
|
+
},
|
|
1822
|
+
async delete(applicationId, provider, options) {
|
|
1823
|
+
const encodedProvider = encodeURIComponent(provider);
|
|
1824
|
+
return fetcher.deleteNoContent(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, options);
|
|
1825
|
+
},
|
|
1826
|
+
async listApiKeys(applicationId, provider, options) {
|
|
1827
|
+
const encodedProvider = encodeURIComponent(provider);
|
|
1828
|
+
return fetcher.get(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}/api_keys`, options);
|
|
1829
|
+
},
|
|
1830
|
+
async createApiKey(applicationId, provider, input, options) {
|
|
1831
|
+
const result = request$2.body.safeParse(input);
|
|
1832
|
+
if (!result.success) return {
|
|
1833
|
+
ok: false,
|
|
1834
|
+
error: createValidationError(result.error)
|
|
1835
|
+
};
|
|
1836
|
+
const encodedProvider = encodeURIComponent(provider);
|
|
1837
|
+
return fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}/api_keys`, input, options);
|
|
1838
|
+
},
|
|
1839
|
+
async deleteApiKey(applicationId, provider, apiKeyId, options) {
|
|
1840
|
+
const encodedProvider = encodeURIComponent(provider);
|
|
1841
|
+
const encodedApiKeyId = encodeURIComponent(apiKeyId);
|
|
1842
|
+
return fetcher.deleteNoContent(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}/api_keys/${encodedApiKeyId}`, options);
|
|
1843
|
+
}
|
|
2203
1844
|
};
|
|
2204
1845
|
}
|
|
2205
1846
|
|
|
2206
1847
|
//#endregion
|
|
2207
|
-
//#region src/client
|
|
1848
|
+
//#region src/public/client.ts
|
|
2208
1849
|
function createApiClient(config) {
|
|
2209
1850
|
const fetcher = createFetcher(config);
|
|
2210
1851
|
return {
|
|
@@ -2217,45 +1858,6 @@ function createApiClient(config) {
|
|
|
2217
1858
|
};
|
|
2218
1859
|
}
|
|
2219
1860
|
|
|
2220
|
-
//#endregion
|
|
2221
|
-
//#region src/lib/api-key.ts
|
|
2222
|
-
function matchWildcard(value, pattern) {
|
|
2223
|
-
if (pattern === "*") return true;
|
|
2224
|
-
if (pattern.endsWith("*")) return value.startsWith(pattern.slice(0, -1));
|
|
2225
|
-
if (pattern.startsWith("*")) return value.endsWith(pattern.slice(1));
|
|
2226
|
-
return value === pattern;
|
|
2227
|
-
}
|
|
2228
|
-
function matchOperations(operations, requiredOperation) {
|
|
2229
|
-
return operations.some((pattern) => matchWildcard(requiredOperation, pattern));
|
|
2230
|
-
}
|
|
2231
|
-
function matchExperts(experts, expertId) {
|
|
2232
|
-
if (experts === void 0 || experts === "*") return true;
|
|
2233
|
-
return experts.some((pattern) => matchWildcard(expertId, pattern));
|
|
2234
|
-
}
|
|
2235
|
-
function isApiKeyPermissions(parsed) {
|
|
2236
|
-
return typeof parsed === "object" && parsed !== null && "operations" in parsed && Array.isArray(parsed.operations);
|
|
2237
|
-
}
|
|
2238
|
-
function parseApiKeyPermissions(permissionsJson) {
|
|
2239
|
-
if (!permissionsJson) return null;
|
|
2240
|
-
try {
|
|
2241
|
-
const parsed = JSON.parse(permissionsJson);
|
|
2242
|
-
if (!isApiKeyPermissions(parsed)) return null;
|
|
2243
|
-
return parsed;
|
|
2244
|
-
} catch {
|
|
2245
|
-
return null;
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
function stringifyApiKeyPermissions(permissions) {
|
|
2249
|
-
return JSON.stringify(permissions);
|
|
2250
|
-
}
|
|
2251
|
-
|
|
2252
|
-
//#endregion
|
|
2253
|
-
//#region src/lib/auth.ts
|
|
2254
|
-
function buildAuthHeaders(auth) {
|
|
2255
|
-
if (auth.type === "apiKey") return { Authorization: `Bearer ${auth.apiKey}` };
|
|
2256
|
-
return { Cookie: auth.cookie };
|
|
2257
|
-
}
|
|
2258
|
-
|
|
2259
1861
|
//#endregion
|
|
2260
1862
|
export { buildAuthHeaders, buildQueryString, createAbortError, createApiClient, createFetcher, createHttpError, createNetworkError, createTimeoutError, createValidationError, handleHttpError, isAbortError, isClientError, isHttpError, isNetworkError, isTimeoutError, isValidationError, matchExperts, matchOperations, matchWildcard, parseApiKeyPermissions, parseSSE, stringifyApiKeyPermissions };
|
|
2261
|
-
//# sourceMappingURL=
|
|
1863
|
+
//# sourceMappingURL=index.mjs.map
|