@gpt-platform/admin 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +80481 -87271
- package/dist/index.d.ts +80481 -87271
- package/dist/index.js +531 -544
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +503 -511
- package/dist/index.mjs.map +1 -0
- package/llms.txt +17 -3
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -8,18 +8,14 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// src/index.ts
|
|
25
21
|
var index_exports = {};
|
|
@@ -47,16 +43,16 @@ __export(index_exports, {
|
|
|
47
43
|
WebhookConfigCreateSchema: () => WebhookConfigCreateSchema,
|
|
48
44
|
WebhookDeliveryBulkRetrySchema: () => WebhookDeliveryBulkRetrySchema,
|
|
49
45
|
default: () => index_default,
|
|
50
|
-
handleApiError: () => handleApiError
|
|
46
|
+
handleApiError: () => handleApiError
|
|
51
47
|
});
|
|
52
48
|
module.exports = __toCommonJS(index_exports);
|
|
53
49
|
|
|
54
50
|
// src/_internal/core/bodySerializer.gen.ts
|
|
55
51
|
var jsonBodySerializer = {
|
|
56
|
-
bodySerializer: (body) =>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
bodySerializer: (body) => JSON.stringify(
|
|
53
|
+
body,
|
|
54
|
+
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
55
|
+
)
|
|
60
56
|
};
|
|
61
57
|
|
|
62
58
|
// src/_internal/core/serverSentEvents.gen.ts
|
|
@@ -74,8 +70,7 @@ var createSseClient = ({
|
|
|
74
70
|
...options
|
|
75
71
|
}) => {
|
|
76
72
|
let lastEventId;
|
|
77
|
-
const sleep =
|
|
78
|
-
sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
73
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
79
74
|
const createStream = async function* () {
|
|
80
75
|
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
81
76
|
let attempt = 0;
|
|
@@ -83,10 +78,7 @@ var createSseClient = ({
|
|
|
83
78
|
while (true) {
|
|
84
79
|
if (signal.aborted) break;
|
|
85
80
|
attempt++;
|
|
86
|
-
const headers =
|
|
87
|
-
options.headers instanceof Headers
|
|
88
|
-
? options.headers
|
|
89
|
-
: new Headers(options.headers);
|
|
81
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
90
82
|
if (lastEventId !== void 0) {
|
|
91
83
|
headers.set("Last-Event-ID", lastEventId);
|
|
92
84
|
}
|
|
@@ -96,7 +88,7 @@ var createSseClient = ({
|
|
|
96
88
|
...options,
|
|
97
89
|
body: options.serializedBody,
|
|
98
90
|
headers,
|
|
99
|
-
signal
|
|
91
|
+
signal
|
|
100
92
|
};
|
|
101
93
|
let request = new Request(url, requestInit);
|
|
102
94
|
if (onRequest) {
|
|
@@ -106,17 +98,16 @@ var createSseClient = ({
|
|
|
106
98
|
const response = await _fetch(request);
|
|
107
99
|
if (!response.ok)
|
|
108
100
|
throw new Error(
|
|
109
|
-
`SSE failed: ${response.status} ${response.statusText}
|
|
101
|
+
`SSE failed: ${response.status} ${response.statusText}`
|
|
110
102
|
);
|
|
111
103
|
if (!response.body) throw new Error("No body in SSE response");
|
|
112
|
-
const reader = response.body
|
|
113
|
-
.pipeThrough(new TextDecoderStream())
|
|
114
|
-
.getReader();
|
|
104
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
115
105
|
let buffer = "";
|
|
116
106
|
const abortHandler = () => {
|
|
117
107
|
try {
|
|
118
108
|
reader.cancel();
|
|
119
|
-
} catch {
|
|
109
|
+
} catch {
|
|
110
|
+
}
|
|
120
111
|
};
|
|
121
112
|
signal.addEventListener("abort", abortHandler);
|
|
122
113
|
try {
|
|
@@ -141,7 +132,7 @@ var createSseClient = ({
|
|
|
141
132
|
} else if (line.startsWith("retry:")) {
|
|
142
133
|
const parsed = Number.parseInt(
|
|
143
134
|
line.replace(/^retry:\s*/, ""),
|
|
144
|
-
10
|
|
135
|
+
10
|
|
145
136
|
);
|
|
146
137
|
if (!Number.isNaN(parsed)) {
|
|
147
138
|
retryDelay = parsed;
|
|
@@ -171,7 +162,7 @@ var createSseClient = ({
|
|
|
171
162
|
data,
|
|
172
163
|
event: eventName,
|
|
173
164
|
id: lastEventId,
|
|
174
|
-
retry: retryDelay
|
|
165
|
+
retry: retryDelay
|
|
175
166
|
});
|
|
176
167
|
if (dataLines.length) {
|
|
177
168
|
yield data;
|
|
@@ -190,7 +181,7 @@ var createSseClient = ({
|
|
|
190
181
|
}
|
|
191
182
|
const backoff = Math.min(
|
|
192
183
|
retryDelay * 2 ** (attempt - 1),
|
|
193
|
-
sseMaxRetryDelay ?? 3e4
|
|
184
|
+
sseMaxRetryDelay ?? 3e4
|
|
194
185
|
);
|
|
195
186
|
await sleep(backoff);
|
|
196
187
|
}
|
|
@@ -237,11 +228,15 @@ var separatorObjectExplode = (style) => {
|
|
|
237
228
|
return "&";
|
|
238
229
|
}
|
|
239
230
|
};
|
|
240
|
-
var serializeArrayParam = ({
|
|
231
|
+
var serializeArrayParam = ({
|
|
232
|
+
allowReserved,
|
|
233
|
+
explode,
|
|
234
|
+
name,
|
|
235
|
+
style,
|
|
236
|
+
value
|
|
237
|
+
}) => {
|
|
241
238
|
if (!explode) {
|
|
242
|
-
const joinedValues2 = (
|
|
243
|
-
allowReserved ? value : value.map((v) => encodeURIComponent(v))
|
|
244
|
-
).join(separatorArrayNoExplode(style));
|
|
239
|
+
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
245
240
|
switch (style) {
|
|
246
241
|
case "label":
|
|
247
242
|
return `.${joinedValues2}`;
|
|
@@ -254,29 +249,29 @@ var serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
|
254
249
|
}
|
|
255
250
|
}
|
|
256
251
|
const separator = separatorArrayExplode(style);
|
|
257
|
-
const joinedValues = value
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
.join(separator);
|
|
269
|
-
return style === "label" || style === "matrix"
|
|
270
|
-
? separator + joinedValues
|
|
271
|
-
: joinedValues;
|
|
252
|
+
const joinedValues = value.map((v) => {
|
|
253
|
+
if (style === "label" || style === "simple") {
|
|
254
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
255
|
+
}
|
|
256
|
+
return serializePrimitiveParam({
|
|
257
|
+
allowReserved,
|
|
258
|
+
name,
|
|
259
|
+
value: v
|
|
260
|
+
});
|
|
261
|
+
}).join(separator);
|
|
262
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
272
263
|
};
|
|
273
|
-
var serializePrimitiveParam = ({
|
|
264
|
+
var serializePrimitiveParam = ({
|
|
265
|
+
allowReserved,
|
|
266
|
+
name,
|
|
267
|
+
value
|
|
268
|
+
}) => {
|
|
274
269
|
if (value === void 0 || value === null) {
|
|
275
270
|
return "";
|
|
276
271
|
}
|
|
277
272
|
if (typeof value === "object") {
|
|
278
273
|
throw new Error(
|
|
279
|
-
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
274
|
+
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
280
275
|
);
|
|
281
276
|
}
|
|
282
277
|
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
@@ -287,7 +282,7 @@ var serializeObjectParam = ({
|
|
|
287
282
|
name,
|
|
288
283
|
style,
|
|
289
284
|
value,
|
|
290
|
-
valueOnly
|
|
285
|
+
valueOnly
|
|
291
286
|
}) => {
|
|
292
287
|
if (value instanceof Date) {
|
|
293
288
|
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
@@ -295,7 +290,11 @@ var serializeObjectParam = ({
|
|
|
295
290
|
if (style !== "deepObject" && !explode) {
|
|
296
291
|
let values = [];
|
|
297
292
|
Object.entries(value).forEach(([key, v]) => {
|
|
298
|
-
values = [
|
|
293
|
+
values = [
|
|
294
|
+
...values,
|
|
295
|
+
key,
|
|
296
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
297
|
+
];
|
|
299
298
|
});
|
|
300
299
|
const joinedValues2 = values.join(",");
|
|
301
300
|
switch (style) {
|
|
@@ -310,18 +309,14 @@ var serializeObjectParam = ({
|
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
const separator = separatorObjectExplode(style);
|
|
313
|
-
const joinedValues = Object.entries(value)
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
.join(separator);
|
|
322
|
-
return style === "label" || style === "matrix"
|
|
323
|
-
? separator + joinedValues
|
|
324
|
-
: joinedValues;
|
|
312
|
+
const joinedValues = Object.entries(value).map(
|
|
313
|
+
([key, v]) => serializePrimitiveParam({
|
|
314
|
+
allowReserved,
|
|
315
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
316
|
+
value: v
|
|
317
|
+
})
|
|
318
|
+
).join(separator);
|
|
319
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
325
320
|
};
|
|
326
321
|
|
|
327
322
|
// src/_internal/core/utils.gen.ts
|
|
@@ -352,7 +347,7 @@ var defaultPathSerializer = ({ path, url: _url }) => {
|
|
|
352
347
|
if (Array.isArray(value)) {
|
|
353
348
|
url = url.replace(
|
|
354
349
|
match,
|
|
355
|
-
serializeArrayParam({ explode, name, style, value })
|
|
350
|
+
serializeArrayParam({ explode, name, style, value })
|
|
356
351
|
);
|
|
357
352
|
continue;
|
|
358
353
|
}
|
|
@@ -364,8 +359,8 @@ var defaultPathSerializer = ({ path, url: _url }) => {
|
|
|
364
359
|
name,
|
|
365
360
|
style,
|
|
366
361
|
value,
|
|
367
|
-
valueOnly: true
|
|
368
|
-
})
|
|
362
|
+
valueOnly: true
|
|
363
|
+
})
|
|
369
364
|
);
|
|
370
365
|
continue;
|
|
371
366
|
}
|
|
@@ -374,20 +369,26 @@ var defaultPathSerializer = ({ path, url: _url }) => {
|
|
|
374
369
|
match,
|
|
375
370
|
`;${serializePrimitiveParam({
|
|
376
371
|
name,
|
|
377
|
-
value
|
|
378
|
-
})}
|
|
372
|
+
value
|
|
373
|
+
})}`
|
|
379
374
|
);
|
|
380
375
|
continue;
|
|
381
376
|
}
|
|
382
377
|
const replaceValue = encodeURIComponent(
|
|
383
|
-
style === "label" ? `.${value}` : value
|
|
378
|
+
style === "label" ? `.${value}` : value
|
|
384
379
|
);
|
|
385
380
|
url = url.replace(match, replaceValue);
|
|
386
381
|
}
|
|
387
382
|
}
|
|
388
383
|
return url;
|
|
389
384
|
};
|
|
390
|
-
var getUrl = ({
|
|
385
|
+
var getUrl = ({
|
|
386
|
+
baseUrl,
|
|
387
|
+
path,
|
|
388
|
+
query,
|
|
389
|
+
querySerializer,
|
|
390
|
+
url: _url
|
|
391
|
+
}) => {
|
|
391
392
|
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
392
393
|
let url = (baseUrl ?? "") + pathUrl;
|
|
393
394
|
if (path) {
|
|
@@ -407,8 +408,7 @@ function getValidRequestBody(options) {
|
|
|
407
408
|
const isSerializedBody = hasBody && options.bodySerializer;
|
|
408
409
|
if (isSerializedBody) {
|
|
409
410
|
if ("serializedBody" in options) {
|
|
410
|
-
const hasSerializedBody =
|
|
411
|
-
options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
411
|
+
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
412
412
|
return hasSerializedBody ? options.serializedBody : null;
|
|
413
413
|
}
|
|
414
414
|
return options.body !== "" ? options.body : null;
|
|
@@ -421,8 +421,7 @@ function getValidRequestBody(options) {
|
|
|
421
421
|
|
|
422
422
|
// src/_internal/core/auth.gen.ts
|
|
423
423
|
var getAuthToken = async (auth, callback) => {
|
|
424
|
-
const token =
|
|
425
|
-
typeof callback === "function" ? await callback(auth) : callback;
|
|
424
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
426
425
|
if (!token) {
|
|
427
426
|
return;
|
|
428
427
|
}
|
|
@@ -436,7 +435,10 @@ var getAuthToken = async (auth, callback) => {
|
|
|
436
435
|
};
|
|
437
436
|
|
|
438
437
|
// src/_internal/client/utils.gen.ts
|
|
439
|
-
var createQuerySerializer = ({
|
|
438
|
+
var createQuerySerializer = ({
|
|
439
|
+
parameters = {},
|
|
440
|
+
...args
|
|
441
|
+
} = {}) => {
|
|
440
442
|
const querySerializer = (queryParams) => {
|
|
441
443
|
const search = [];
|
|
442
444
|
if (queryParams && typeof queryParams === "object") {
|
|
@@ -453,7 +455,7 @@ var createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
|
453
455
|
name,
|
|
454
456
|
style: "form",
|
|
455
457
|
value,
|
|
456
|
-
...options.array
|
|
458
|
+
...options.array
|
|
457
459
|
});
|
|
458
460
|
if (serializedArray) search.push(serializedArray);
|
|
459
461
|
} else if (typeof value === "object") {
|
|
@@ -463,14 +465,14 @@ var createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
|
463
465
|
name,
|
|
464
466
|
style: "deepObject",
|
|
465
467
|
value,
|
|
466
|
-
...options.object
|
|
468
|
+
...options.object
|
|
467
469
|
});
|
|
468
470
|
if (serializedObject) search.push(serializedObject);
|
|
469
471
|
} else {
|
|
470
472
|
const serializedPrimitive = serializePrimitiveParam({
|
|
471
473
|
allowReserved: options.allowReserved,
|
|
472
474
|
name,
|
|
473
|
-
value
|
|
475
|
+
value
|
|
474
476
|
});
|
|
475
477
|
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
476
478
|
}
|
|
@@ -488,20 +490,15 @@ var getParseAs = (contentType) => {
|
|
|
488
490
|
if (!cleanContent) {
|
|
489
491
|
return;
|
|
490
492
|
}
|
|
491
|
-
if (
|
|
492
|
-
cleanContent.startsWith("application/json") ||
|
|
493
|
-
cleanContent.endsWith("+json")
|
|
494
|
-
) {
|
|
493
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
495
494
|
return "json";
|
|
496
495
|
}
|
|
497
496
|
if (cleanContent === "multipart/form-data") {
|
|
498
497
|
return "formData";
|
|
499
498
|
}
|
|
500
|
-
if (
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
)
|
|
504
|
-
) {
|
|
499
|
+
if (["application/", "audio/", "image/", "video/"].some(
|
|
500
|
+
(type) => cleanContent.startsWith(type)
|
|
501
|
+
)) {
|
|
505
502
|
return "blob";
|
|
506
503
|
}
|
|
507
504
|
if (cleanContent.startsWith("text/")) {
|
|
@@ -513,16 +510,15 @@ var checkForExistence = (options, name) => {
|
|
|
513
510
|
if (!name) {
|
|
514
511
|
return false;
|
|
515
512
|
}
|
|
516
|
-
if (
|
|
517
|
-
options.headers.has(name) ||
|
|
518
|
-
options.query?.[name] ||
|
|
519
|
-
options.headers.get("Cookie")?.includes(`${name}=`)
|
|
520
|
-
) {
|
|
513
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
521
514
|
return true;
|
|
522
515
|
}
|
|
523
516
|
return false;
|
|
524
517
|
};
|
|
525
|
-
var setAuthParams = async ({
|
|
518
|
+
var setAuthParams = async ({
|
|
519
|
+
security,
|
|
520
|
+
...options
|
|
521
|
+
}) => {
|
|
526
522
|
for (const auth of security) {
|
|
527
523
|
if (checkForExistence(options, auth.name)) {
|
|
528
524
|
continue;
|
|
@@ -549,17 +545,13 @@ var setAuthParams = async ({ security, ...options }) => {
|
|
|
549
545
|
}
|
|
550
546
|
}
|
|
551
547
|
};
|
|
552
|
-
var buildUrl = (options) =>
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
? options.querySerializer
|
|
560
|
-
: createQuerySerializer(options.querySerializer),
|
|
561
|
-
url: options.url,
|
|
562
|
-
});
|
|
548
|
+
var buildUrl = (options) => getUrl({
|
|
549
|
+
baseUrl: options.baseUrl,
|
|
550
|
+
path: options.path,
|
|
551
|
+
query: options.query,
|
|
552
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
553
|
+
url: options.url
|
|
554
|
+
});
|
|
563
555
|
var mergeConfigs = (a, b) => {
|
|
564
556
|
const config = { ...a, ...b };
|
|
565
557
|
if (config.baseUrl?.endsWith("/")) {
|
|
@@ -581,10 +573,7 @@ var mergeHeaders = (...headers) => {
|
|
|
581
573
|
if (!header) {
|
|
582
574
|
continue;
|
|
583
575
|
}
|
|
584
|
-
const iterator =
|
|
585
|
-
header instanceof Headers
|
|
586
|
-
? headersEntries(header)
|
|
587
|
-
: Object.entries(header);
|
|
576
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
588
577
|
for (const [key, value] of iterator) {
|
|
589
578
|
if (value === null) {
|
|
590
579
|
mergedHeaders.delete(key);
|
|
@@ -595,7 +584,7 @@ var mergeHeaders = (...headers) => {
|
|
|
595
584
|
} else if (value !== void 0) {
|
|
596
585
|
mergedHeaders.set(
|
|
597
586
|
key,
|
|
598
|
-
typeof value === "object" ? JSON.stringify(value) : value
|
|
587
|
+
typeof value === "object" ? JSON.stringify(value) : value
|
|
599
588
|
);
|
|
600
589
|
}
|
|
601
590
|
}
|
|
@@ -641,28 +630,28 @@ var Interceptors = class {
|
|
|
641
630
|
var createInterceptors = () => ({
|
|
642
631
|
error: new Interceptors(),
|
|
643
632
|
request: new Interceptors(),
|
|
644
|
-
response: new Interceptors()
|
|
633
|
+
response: new Interceptors()
|
|
645
634
|
});
|
|
646
635
|
var defaultQuerySerializer = createQuerySerializer({
|
|
647
636
|
allowReserved: false,
|
|
648
637
|
array: {
|
|
649
638
|
explode: true,
|
|
650
|
-
style: "form"
|
|
639
|
+
style: "form"
|
|
651
640
|
},
|
|
652
641
|
object: {
|
|
653
642
|
explode: true,
|
|
654
|
-
style: "deepObject"
|
|
655
|
-
}
|
|
643
|
+
style: "deepObject"
|
|
644
|
+
}
|
|
656
645
|
});
|
|
657
646
|
var defaultHeaders = {
|
|
658
|
-
"Content-Type": "application/json"
|
|
647
|
+
"Content-Type": "application/json"
|
|
659
648
|
};
|
|
660
649
|
var createConfig = (override = {}) => ({
|
|
661
650
|
...jsonBodySerializer,
|
|
662
651
|
headers: defaultHeaders,
|
|
663
652
|
parseAs: "auto",
|
|
664
653
|
querySerializer: defaultQuerySerializer,
|
|
665
|
-
...override
|
|
654
|
+
...override
|
|
666
655
|
});
|
|
667
656
|
|
|
668
657
|
// src/_internal/client/client.gen.ts
|
|
@@ -680,12 +669,12 @@ var createClient = (config = {}) => {
|
|
|
680
669
|
...options,
|
|
681
670
|
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
682
671
|
headers: mergeHeaders(_config.headers, options.headers),
|
|
683
|
-
serializedBody: void 0
|
|
672
|
+
serializedBody: void 0
|
|
684
673
|
};
|
|
685
674
|
if (opts.security) {
|
|
686
675
|
await setAuthParams({
|
|
687
676
|
...opts,
|
|
688
|
-
security: opts.security
|
|
677
|
+
security: opts.security
|
|
689
678
|
});
|
|
690
679
|
}
|
|
691
680
|
if (opts.requestValidator) {
|
|
@@ -705,7 +694,7 @@ var createClient = (config = {}) => {
|
|
|
705
694
|
const requestInit = {
|
|
706
695
|
redirect: "follow",
|
|
707
696
|
...opts,
|
|
708
|
-
body: getValidRequestBody(opts)
|
|
697
|
+
body: getValidRequestBody(opts)
|
|
709
698
|
};
|
|
710
699
|
let request2 = new Request(url, requestInit);
|
|
711
700
|
for (const fn of interceptors.request.fns) {
|
|
@@ -721,20 +710,23 @@ var createClient = (config = {}) => {
|
|
|
721
710
|
let finalError2 = error2;
|
|
722
711
|
for (const fn of interceptors.error.fns) {
|
|
723
712
|
if (fn) {
|
|
724
|
-
finalError2 = await fn(
|
|
713
|
+
finalError2 = await fn(
|
|
714
|
+
error2,
|
|
715
|
+
void 0,
|
|
716
|
+
request2,
|
|
717
|
+
opts
|
|
718
|
+
);
|
|
725
719
|
}
|
|
726
720
|
}
|
|
727
721
|
finalError2 = finalError2 || {};
|
|
728
722
|
if (opts.throwOnError) {
|
|
729
723
|
throw finalError2;
|
|
730
724
|
}
|
|
731
|
-
return opts.responseStyle === "data"
|
|
732
|
-
|
|
733
|
-
:
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
response: void 0,
|
|
737
|
-
};
|
|
725
|
+
return opts.responseStyle === "data" ? void 0 : {
|
|
726
|
+
error: finalError2,
|
|
727
|
+
request: request2,
|
|
728
|
+
response: void 0
|
|
729
|
+
};
|
|
738
730
|
}
|
|
739
731
|
for (const fn of interceptors.response.fns) {
|
|
740
732
|
if (fn) {
|
|
@@ -743,17 +735,11 @@ var createClient = (config = {}) => {
|
|
|
743
735
|
}
|
|
744
736
|
const result = {
|
|
745
737
|
request: request2,
|
|
746
|
-
response
|
|
738
|
+
response
|
|
747
739
|
};
|
|
748
740
|
if (response.ok) {
|
|
749
|
-
const parseAs =
|
|
750
|
-
|
|
751
|
-
? getParseAs(response.headers.get("Content-Type"))
|
|
752
|
-
: opts.parseAs) ?? "json";
|
|
753
|
-
if (
|
|
754
|
-
response.status === 204 ||
|
|
755
|
-
response.headers.get("Content-Length") === "0"
|
|
756
|
-
) {
|
|
741
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
742
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
757
743
|
let emptyData;
|
|
758
744
|
switch (parseAs) {
|
|
759
745
|
case "arrayBuffer":
|
|
@@ -772,12 +758,10 @@ var createClient = (config = {}) => {
|
|
|
772
758
|
emptyData = {};
|
|
773
759
|
break;
|
|
774
760
|
}
|
|
775
|
-
return opts.responseStyle === "data"
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
...result,
|
|
780
|
-
};
|
|
761
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
762
|
+
data: emptyData,
|
|
763
|
+
...result
|
|
764
|
+
};
|
|
781
765
|
}
|
|
782
766
|
let data;
|
|
783
767
|
switch (parseAs) {
|
|
@@ -789,12 +773,10 @@ var createClient = (config = {}) => {
|
|
|
789
773
|
data = await response[parseAs]();
|
|
790
774
|
break;
|
|
791
775
|
case "stream":
|
|
792
|
-
return opts.responseStyle === "data"
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
...result,
|
|
797
|
-
};
|
|
776
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
777
|
+
data: response.body,
|
|
778
|
+
...result
|
|
779
|
+
};
|
|
798
780
|
}
|
|
799
781
|
if (parseAs === "json") {
|
|
800
782
|
if (opts.responseValidator) {
|
|
@@ -804,18 +786,17 @@ var createClient = (config = {}) => {
|
|
|
804
786
|
data = await opts.responseTransformer(data);
|
|
805
787
|
}
|
|
806
788
|
}
|
|
807
|
-
return opts.responseStyle === "data"
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
...result,
|
|
812
|
-
};
|
|
789
|
+
return opts.responseStyle === "data" ? data : {
|
|
790
|
+
data,
|
|
791
|
+
...result
|
|
792
|
+
};
|
|
813
793
|
}
|
|
814
794
|
const textError = await response.text();
|
|
815
795
|
let jsonError;
|
|
816
796
|
try {
|
|
817
797
|
jsonError = JSON.parse(textError);
|
|
818
|
-
} catch {
|
|
798
|
+
} catch {
|
|
799
|
+
}
|
|
819
800
|
const error = jsonError ?? textError;
|
|
820
801
|
let finalError = error;
|
|
821
802
|
for (const fn of interceptors.error.fns) {
|
|
@@ -827,12 +808,10 @@ var createClient = (config = {}) => {
|
|
|
827
808
|
if (opts.throwOnError) {
|
|
828
809
|
throw finalError;
|
|
829
810
|
}
|
|
830
|
-
return opts.responseStyle === "data"
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
...result,
|
|
835
|
-
};
|
|
811
|
+
return opts.responseStyle === "data" ? void 0 : {
|
|
812
|
+
error: finalError,
|
|
813
|
+
...result
|
|
814
|
+
};
|
|
836
815
|
};
|
|
837
816
|
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
838
817
|
const makeSseFn = (method) => async (options) => {
|
|
@@ -851,7 +830,7 @@ var createClient = (config = {}) => {
|
|
|
851
830
|
}
|
|
852
831
|
return request2;
|
|
853
832
|
},
|
|
854
|
-
url
|
|
833
|
+
url
|
|
855
834
|
});
|
|
856
835
|
};
|
|
857
836
|
return {
|
|
@@ -877,14 +856,16 @@ var createClient = (config = {}) => {
|
|
|
877
856
|
patch: makeSseFn("PATCH"),
|
|
878
857
|
post: makeSseFn("POST"),
|
|
879
858
|
put: makeSseFn("PUT"),
|
|
880
|
-
trace: makeSseFn("TRACE")
|
|
859
|
+
trace: makeSseFn("TRACE")
|
|
881
860
|
},
|
|
882
|
-
trace: makeMethodFn("TRACE")
|
|
861
|
+
trace: makeMethodFn("TRACE")
|
|
883
862
|
};
|
|
884
863
|
};
|
|
885
864
|
|
|
886
865
|
// src/_internal/client.gen.ts
|
|
887
|
-
var client = createClient(
|
|
866
|
+
var client = createClient(
|
|
867
|
+
createConfig({ baseUrl: "http://localhost:33333" })
|
|
868
|
+
);
|
|
888
869
|
|
|
889
870
|
// src/base-client.ts
|
|
890
871
|
var DEFAULT_API_VERSION = "2025-12-03";
|
|
@@ -907,7 +888,7 @@ var BaseClient = class {
|
|
|
907
888
|
this.apiVersion = config.apiVersion ?? DEFAULT_API_VERSION;
|
|
908
889
|
if (config.baseUrl && !isSecureUrl(config.baseUrl)) {
|
|
909
890
|
console.warn(
|
|
910
|
-
"[GPT Core SDK] Warning: Using non-HTTPS URL. Credentials may be transmitted insecurely. Use HTTPS in production environments."
|
|
891
|
+
"[GPT Core SDK] Warning: Using non-HTTPS URL. Credentials may be transmitted insecurely. Use HTTPS in production environments."
|
|
911
892
|
);
|
|
912
893
|
}
|
|
913
894
|
if (config.baseUrl) {
|
|
@@ -917,12 +898,12 @@ var BaseClient = class {
|
|
|
917
898
|
const requestUrl = req.url || config.baseUrl || "";
|
|
918
899
|
if ((config.apiKey || config.token) && !isSecureUrl(requestUrl)) {
|
|
919
900
|
console.warn(
|
|
920
|
-
"[GPT Core SDK] Warning: Sending credentials over non-HTTPS connection."
|
|
901
|
+
"[GPT Core SDK] Warning: Sending credentials over non-HTTPS connection."
|
|
921
902
|
);
|
|
922
903
|
}
|
|
923
904
|
req.headers.set(
|
|
924
905
|
"Accept",
|
|
925
|
-
`application/vnd.api+json; version=${this.apiVersion}
|
|
906
|
+
`application/vnd.api+json; version=${this.apiVersion}`
|
|
926
907
|
);
|
|
927
908
|
req.headers.set("Content-Type", "application/vnd.api+json");
|
|
928
909
|
if (config.apiKey) {
|
|
@@ -950,7 +931,7 @@ var BaseClient = class {
|
|
|
950
931
|
}
|
|
951
932
|
getHeaders() {
|
|
952
933
|
return {
|
|
953
|
-
"x-application-key": this.config.apiKey || ""
|
|
934
|
+
"x-application-key": this.config.apiKey || ""
|
|
954
935
|
};
|
|
955
936
|
}
|
|
956
937
|
};
|
|
@@ -1019,8 +1000,7 @@ function handleApiError(error) {
|
|
|
1019
1000
|
const statusCode = response?.status || err?.status || err?.statusCode;
|
|
1020
1001
|
const headers = response?.headers || err?.headers;
|
|
1021
1002
|
const requestId = headers?.get?.("x-request-id") || headers?.["x-request-id"];
|
|
1022
|
-
const body =
|
|
1023
|
-
response?.body || response?.data || err?.body || err?.data || err;
|
|
1003
|
+
const body = response?.body || response?.data || err?.body || err?.data || err;
|
|
1024
1004
|
let message = "An error occurred";
|
|
1025
1005
|
let errors;
|
|
1026
1006
|
const bodyObj = body;
|
|
@@ -1029,7 +1009,7 @@ function handleApiError(error) {
|
|
|
1029
1009
|
message = firstError?.title || firstError?.detail || message;
|
|
1030
1010
|
errors = bodyObj.errors.map((e) => ({
|
|
1031
1011
|
field: e.source?.pointer?.split("/").pop(),
|
|
1032
|
-
message: e.detail || e.title || "Unknown error"
|
|
1012
|
+
message: e.detail || e.title || "Unknown error"
|
|
1033
1013
|
}));
|
|
1034
1014
|
} else if (bodyObj?.message) {
|
|
1035
1015
|
message = bodyObj.message;
|
|
@@ -1044,18 +1024,15 @@ function handleApiError(error) {
|
|
|
1044
1024
|
"x-application-key",
|
|
1045
1025
|
"cookie",
|
|
1046
1026
|
"x-forwarded-for",
|
|
1047
|
-
"x-real-ip"
|
|
1027
|
+
"x-real-ip"
|
|
1048
1028
|
];
|
|
1049
1029
|
const filterSensitiveHeaders = (hdrs) => {
|
|
1050
1030
|
if (!hdrs) return void 0;
|
|
1051
|
-
const entries =
|
|
1052
|
-
hdrs instanceof Headers
|
|
1053
|
-
? Array.from(hdrs.entries())
|
|
1054
|
-
: Object.entries(hdrs);
|
|
1031
|
+
const entries = hdrs instanceof Headers ? Array.from(hdrs.entries()) : Object.entries(hdrs);
|
|
1055
1032
|
const filtered = entries.filter(([key]) => {
|
|
1056
1033
|
const lowerKey = key.toLowerCase();
|
|
1057
|
-
return !sensitiveHeaderPatterns.some(
|
|
1058
|
-
lowerKey.includes(pattern)
|
|
1034
|
+
return !sensitiveHeaderPatterns.some(
|
|
1035
|
+
(pattern) => lowerKey.includes(pattern)
|
|
1059
1036
|
);
|
|
1060
1037
|
});
|
|
1061
1038
|
return filtered.length > 0 ? Object.fromEntries(filtered) : void 0;
|
|
@@ -1065,7 +1042,7 @@ function handleApiError(error) {
|
|
|
1065
1042
|
requestId,
|
|
1066
1043
|
headers: filterSensitiveHeaders(headers),
|
|
1067
1044
|
body,
|
|
1068
|
-
cause: error instanceof Error ? error : void 0
|
|
1045
|
+
cause: error instanceof Error ? error : void 0
|
|
1069
1046
|
};
|
|
1070
1047
|
switch (statusCode) {
|
|
1071
1048
|
case 401:
|
|
@@ -1078,12 +1055,11 @@ function handleApiError(error) {
|
|
|
1078
1055
|
case 422:
|
|
1079
1056
|
throw new ValidationError(message, errors, errorOptions);
|
|
1080
1057
|
case 429: {
|
|
1081
|
-
const retryAfter =
|
|
1082
|
-
headers?.get?.("retry-after") || headers?.["retry-after"];
|
|
1058
|
+
const retryAfter = headers?.get?.("retry-after") || headers?.["retry-after"];
|
|
1083
1059
|
throw new RateLimitError(
|
|
1084
1060
|
message,
|
|
1085
1061
|
retryAfter ? parseInt(retryAfter, 10) : void 0,
|
|
1086
|
-
errorOptions
|
|
1062
|
+
errorOptions
|
|
1087
1063
|
);
|
|
1088
1064
|
}
|
|
1089
1065
|
case 500:
|
|
@@ -1122,13 +1098,13 @@ async function* streamSSE(response, options = {}) {
|
|
|
1122
1098
|
if (elapsed > timeout) {
|
|
1123
1099
|
reader.cancel();
|
|
1124
1100
|
throw new TimeoutError(
|
|
1125
|
-
`Stream timeout exceeded after ${elapsed}ms (limit: ${timeout}ms)
|
|
1101
|
+
`Stream timeout exceeded after ${elapsed}ms (limit: ${timeout}ms)`
|
|
1126
1102
|
);
|
|
1127
1103
|
}
|
|
1128
1104
|
if (chunkCount >= maxChunks) {
|
|
1129
1105
|
reader.cancel();
|
|
1130
1106
|
throw new GptCoreError(`Maximum chunk limit exceeded (${maxChunks})`, {
|
|
1131
|
-
code: "stream_limit_exceeded"
|
|
1107
|
+
code: "stream_limit_exceeded"
|
|
1132
1108
|
});
|
|
1133
1109
|
}
|
|
1134
1110
|
const { done, value } = await reader.read();
|
|
@@ -1142,7 +1118,7 @@ async function* streamSSE(response, options = {}) {
|
|
|
1142
1118
|
reader.cancel();
|
|
1143
1119
|
throw new GptCoreError(
|
|
1144
1120
|
`Stream buffer size exceeded (${bufferSize} bytes, limit: ${maxBufferSize})`,
|
|
1145
|
-
{ code: "stream_limit_exceeded" }
|
|
1121
|
+
{ code: "stream_limit_exceeded" }
|
|
1146
1122
|
);
|
|
1147
1123
|
}
|
|
1148
1124
|
buffer += decoder.decode(value, { stream: true });
|
|
@@ -1158,7 +1134,7 @@ async function* streamSSE(response, options = {}) {
|
|
|
1158
1134
|
} catch {
|
|
1159
1135
|
yield {
|
|
1160
1136
|
type: "error",
|
|
1161
|
-
error: `Malformed SSE data: ${data.substring(0, 200)}
|
|
1137
|
+
error: `Malformed SSE data: ${data.substring(0, 200)}`
|
|
1162
1138
|
};
|
|
1163
1139
|
}
|
|
1164
1140
|
}
|
|
@@ -1207,13 +1183,13 @@ var RequestBuilder = class {
|
|
|
1207
1183
|
async execute(fn, params, options) {
|
|
1208
1184
|
const headers = buildHeaders(this.getHeaders, options);
|
|
1209
1185
|
try {
|
|
1210
|
-
const { data } = await this.requestWithRetry(
|
|
1211
|
-
fn({
|
|
1186
|
+
const { data } = await this.requestWithRetry(
|
|
1187
|
+
() => fn({
|
|
1212
1188
|
client: this.clientInstance,
|
|
1213
1189
|
headers,
|
|
1214
1190
|
...params,
|
|
1215
|
-
...
|
|
1216
|
-
})
|
|
1191
|
+
...options?.signal && { signal: options.signal }
|
|
1192
|
+
})
|
|
1217
1193
|
);
|
|
1218
1194
|
return this.unwrap(data?.data);
|
|
1219
1195
|
} catch (error) {
|
|
@@ -1226,13 +1202,13 @@ var RequestBuilder = class {
|
|
|
1226
1202
|
async executeDelete(fn, params, options) {
|
|
1227
1203
|
const headers = buildHeaders(this.getHeaders, options);
|
|
1228
1204
|
try {
|
|
1229
|
-
await this.requestWithRetry(
|
|
1230
|
-
fn({
|
|
1205
|
+
await this.requestWithRetry(
|
|
1206
|
+
() => fn({
|
|
1231
1207
|
client: this.clientInstance,
|
|
1232
1208
|
headers,
|
|
1233
1209
|
...params,
|
|
1234
|
-
...
|
|
1235
|
-
})
|
|
1210
|
+
...options?.signal && { signal: options.signal }
|
|
1211
|
+
})
|
|
1236
1212
|
);
|
|
1237
1213
|
return true;
|
|
1238
1214
|
} catch (error) {
|
|
@@ -1246,12 +1222,12 @@ var RequestBuilder = class {
|
|
|
1246
1222
|
async rawGet(url, options) {
|
|
1247
1223
|
const headers = buildHeaders(this.getHeaders, options);
|
|
1248
1224
|
try {
|
|
1249
|
-
const { data } = await this.requestWithRetry(
|
|
1250
|
-
this.clientInstance.get({
|
|
1225
|
+
const { data } = await this.requestWithRetry(
|
|
1226
|
+
() => this.clientInstance.get({
|
|
1251
1227
|
url,
|
|
1252
1228
|
headers,
|
|
1253
|
-
...
|
|
1254
|
-
})
|
|
1229
|
+
...options?.signal && { signal: options.signal }
|
|
1230
|
+
})
|
|
1255
1231
|
);
|
|
1256
1232
|
return this.unwrap(data?.data);
|
|
1257
1233
|
} catch (error) {
|
|
@@ -1265,13 +1241,13 @@ var RequestBuilder = class {
|
|
|
1265
1241
|
async rawPost(url, body, options) {
|
|
1266
1242
|
const headers = buildHeaders(this.getHeaders, options);
|
|
1267
1243
|
try {
|
|
1268
|
-
const { data } = await this.requestWithRetry(
|
|
1269
|
-
this.clientInstance.post({
|
|
1244
|
+
const { data } = await this.requestWithRetry(
|
|
1245
|
+
() => this.clientInstance.post({
|
|
1270
1246
|
url,
|
|
1271
1247
|
headers,
|
|
1272
|
-
...
|
|
1273
|
-
...
|
|
1274
|
-
})
|
|
1248
|
+
...body !== void 0 && { body: JSON.stringify(body) },
|
|
1249
|
+
...options?.signal && { signal: options.signal }
|
|
1250
|
+
})
|
|
1275
1251
|
);
|
|
1276
1252
|
return this.unwrap(data?.data);
|
|
1277
1253
|
} catch (error) {
|
|
@@ -1290,13 +1266,13 @@ var RequestBuilder = class {
|
|
|
1290
1266
|
createPaginatedFetcher(fn, queryBuilder, options) {
|
|
1291
1267
|
return async (page, pageSize) => {
|
|
1292
1268
|
const headers = buildHeaders(this.getHeaders, options);
|
|
1293
|
-
const { data } = await this.requestWithRetry(
|
|
1294
|
-
fn({
|
|
1269
|
+
const { data } = await this.requestWithRetry(
|
|
1270
|
+
() => fn({
|
|
1295
1271
|
client: this.clientInstance,
|
|
1296
1272
|
headers,
|
|
1297
|
-
...
|
|
1298
|
-
...queryBuilder(page, pageSize)
|
|
1299
|
-
})
|
|
1273
|
+
...options?.signal && { signal: options.signal },
|
|
1274
|
+
...queryBuilder(page, pageSize)
|
|
1275
|
+
})
|
|
1300
1276
|
);
|
|
1301
1277
|
const envelope = data;
|
|
1302
1278
|
const items = this.unwrap(envelope.data) || [];
|
|
@@ -1319,38 +1295,38 @@ var RequestBuilder = class {
|
|
|
1319
1295
|
headers,
|
|
1320
1296
|
body: JSON.stringify({ data: { type: "message", attributes: body } }),
|
|
1321
1297
|
parseAs: "stream",
|
|
1322
|
-
...
|
|
1298
|
+
...options?.signal && { signal: options.signal }
|
|
1323
1299
|
});
|
|
1324
1300
|
const envelope = result;
|
|
1325
1301
|
const streamBody = envelope.data ?? result;
|
|
1326
1302
|
const response = envelope.response;
|
|
1327
1303
|
if (response && !response.ok) {
|
|
1328
1304
|
throw new ServerError(`Stream request failed: ${response.status}`, {
|
|
1329
|
-
statusCode: response.status
|
|
1305
|
+
statusCode: response.status
|
|
1330
1306
|
});
|
|
1331
1307
|
}
|
|
1332
1308
|
if (streamBody instanceof ReadableStream) {
|
|
1333
1309
|
const syntheticResponse = new Response(streamBody, {
|
|
1334
|
-
headers: { "Content-Type": "text/event-stream" }
|
|
1310
|
+
headers: { "Content-Type": "text/event-stream" }
|
|
1335
1311
|
});
|
|
1336
1312
|
return streamMessage(syntheticResponse, {
|
|
1337
1313
|
signal: options?.signal,
|
|
1338
|
-
...streamOptions
|
|
1314
|
+
...streamOptions
|
|
1339
1315
|
});
|
|
1340
1316
|
}
|
|
1341
1317
|
if (streamBody instanceof Response) {
|
|
1342
1318
|
if (!streamBody.ok) {
|
|
1343
1319
|
throw new ServerError(`Stream request failed: ${streamBody.status}`, {
|
|
1344
|
-
statusCode: streamBody.status
|
|
1320
|
+
statusCode: streamBody.status
|
|
1345
1321
|
});
|
|
1346
1322
|
}
|
|
1347
1323
|
return streamMessage(streamBody, {
|
|
1348
1324
|
signal: options?.signal,
|
|
1349
|
-
...streamOptions
|
|
1325
|
+
...streamOptions
|
|
1350
1326
|
});
|
|
1351
1327
|
}
|
|
1352
1328
|
throw new GptCoreError("Unexpected stream response format", {
|
|
1353
|
-
code: "stream_error"
|
|
1329
|
+
code: "stream_error"
|
|
1354
1330
|
});
|
|
1355
1331
|
}
|
|
1356
1332
|
/**
|
|
@@ -1364,288 +1340,261 @@ var RequestBuilder = class {
|
|
|
1364
1340
|
url,
|
|
1365
1341
|
headers,
|
|
1366
1342
|
parseAs: "stream",
|
|
1367
|
-
...
|
|
1343
|
+
...options?.signal && { signal: options.signal }
|
|
1368
1344
|
});
|
|
1369
1345
|
const envelope = result;
|
|
1370
1346
|
const streamBody = envelope.data ?? result;
|
|
1371
1347
|
const response = envelope.response;
|
|
1372
1348
|
if (response && !response.ok) {
|
|
1373
1349
|
throw new ServerError(`Stream request failed: ${response.status}`, {
|
|
1374
|
-
statusCode: response.status
|
|
1350
|
+
statusCode: response.status
|
|
1375
1351
|
});
|
|
1376
1352
|
}
|
|
1377
1353
|
if (streamBody instanceof ReadableStream) {
|
|
1378
1354
|
const syntheticResponse = new Response(streamBody, {
|
|
1379
|
-
headers: { "Content-Type": "text/event-stream" }
|
|
1355
|
+
headers: { "Content-Type": "text/event-stream" }
|
|
1380
1356
|
});
|
|
1381
1357
|
return streamMessage(syntheticResponse, {
|
|
1382
1358
|
signal: options?.signal,
|
|
1383
|
-
...streamOptions
|
|
1359
|
+
...streamOptions
|
|
1384
1360
|
});
|
|
1385
1361
|
}
|
|
1386
1362
|
if (streamBody instanceof Response) {
|
|
1387
1363
|
if (!streamBody.ok) {
|
|
1388
1364
|
throw new ServerError(`Stream request failed: ${streamBody.status}`, {
|
|
1389
|
-
statusCode: streamBody.status
|
|
1365
|
+
statusCode: streamBody.status
|
|
1390
1366
|
});
|
|
1391
1367
|
}
|
|
1392
1368
|
return streamMessage(streamBody, {
|
|
1393
1369
|
signal: options?.signal,
|
|
1394
|
-
...streamOptions
|
|
1370
|
+
...streamOptions
|
|
1395
1371
|
});
|
|
1396
1372
|
}
|
|
1397
1373
|
throw new GptCoreError("Unexpected stream response format", {
|
|
1398
|
-
code: "stream_error"
|
|
1374
|
+
code: "stream_error"
|
|
1399
1375
|
});
|
|
1400
1376
|
}
|
|
1401
1377
|
};
|
|
1402
1378
|
|
|
1403
1379
|
// src/_internal/sdk.gen.ts
|
|
1404
|
-
var patchAdminAccountsByIdCredit = (options) =>
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
var
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
headers
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
}
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
var
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
});
|
|
1580
|
-
var getAdminBucketsById = (options) =>
|
|
1581
|
-
(options.client ?? client).get({
|
|
1582
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1583
|
-
url: "/admin/buckets/{id}",
|
|
1584
|
-
...options,
|
|
1585
|
-
});
|
|
1586
|
-
var postAdminWebhookConfigsByIdTest = (options) =>
|
|
1587
|
-
(options.client ?? client).post({
|
|
1588
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1589
|
-
url: "/admin/webhook-configs/{id}/test",
|
|
1590
|
-
...options,
|
|
1591
|
-
headers: {
|
|
1592
|
-
"Content-Type": "application/vnd.api+json",
|
|
1593
|
-
...options.headers,
|
|
1594
|
-
},
|
|
1595
|
-
});
|
|
1596
|
-
var postAdminWebhookDeliveriesByIdRetry = (options) =>
|
|
1597
|
-
(options.client ?? client).post({
|
|
1598
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1599
|
-
url: "/admin/webhook-deliveries/{id}/retry",
|
|
1600
|
-
...options,
|
|
1601
|
-
headers: {
|
|
1602
|
-
"Content-Type": "application/vnd.api+json",
|
|
1603
|
-
...options.headers,
|
|
1604
|
-
},
|
|
1605
|
-
});
|
|
1380
|
+
var patchAdminAccountsByIdCredit = (options) => (options.client ?? client).patch({
|
|
1381
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1382
|
+
url: "/admin/accounts/{id}/credit",
|
|
1383
|
+
...options,
|
|
1384
|
+
headers: {
|
|
1385
|
+
"Content-Type": "application/vnd.api+json",
|
|
1386
|
+
...options.headers
|
|
1387
|
+
}
|
|
1388
|
+
});
|
|
1389
|
+
var getAdminWebhookDeliveriesById = (options) => (options.client ?? client).get({
|
|
1390
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1391
|
+
url: "/admin/webhook-deliveries/{id}",
|
|
1392
|
+
...options
|
|
1393
|
+
});
|
|
1394
|
+
var getAdminApiKeysById = (options) => (options.client ?? client).get({
|
|
1395
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1396
|
+
url: "/admin/api-keys/{id}",
|
|
1397
|
+
...options
|
|
1398
|
+
});
|
|
1399
|
+
var deleteAdminWebhookConfigsById = (options) => (options.client ?? client).delete({
|
|
1400
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1401
|
+
url: "/admin/webhook-configs/{id}",
|
|
1402
|
+
...options
|
|
1403
|
+
});
|
|
1404
|
+
var getAdminWebhookConfigsById = (options) => (options.client ?? client).get({
|
|
1405
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1406
|
+
url: "/admin/webhook-configs/{id}",
|
|
1407
|
+
...options
|
|
1408
|
+
});
|
|
1409
|
+
var patchAdminWebhookConfigsById = (options) => (options.client ?? client).patch({
|
|
1410
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1411
|
+
url: "/admin/webhook-configs/{id}",
|
|
1412
|
+
...options,
|
|
1413
|
+
headers: {
|
|
1414
|
+
"Content-Type": "application/vnd.api+json",
|
|
1415
|
+
...options.headers
|
|
1416
|
+
}
|
|
1417
|
+
});
|
|
1418
|
+
var patchAdminAccountsByIdDebit = (options) => (options.client ?? client).patch({
|
|
1419
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1420
|
+
url: "/admin/accounts/{id}/debit",
|
|
1421
|
+
...options,
|
|
1422
|
+
headers: {
|
|
1423
|
+
"Content-Type": "application/vnd.api+json",
|
|
1424
|
+
...options.headers
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
var getAdminApiKeys = (options) => (options.client ?? client).get({
|
|
1428
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1429
|
+
url: "/admin/api-keys",
|
|
1430
|
+
...options
|
|
1431
|
+
});
|
|
1432
|
+
var getAdminExtractionDocumentsById = (options) => (options.client ?? client).get({
|
|
1433
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1434
|
+
url: "/admin/extraction/documents/{id}",
|
|
1435
|
+
...options
|
|
1436
|
+
});
|
|
1437
|
+
var getAdminAccounts = (options) => (options.client ?? client).get({
|
|
1438
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1439
|
+
url: "/admin/accounts",
|
|
1440
|
+
...options
|
|
1441
|
+
});
|
|
1442
|
+
var getAdminStorageStats = (options) => (options.client ?? client).get({
|
|
1443
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1444
|
+
url: "/admin/storage/stats",
|
|
1445
|
+
...options
|
|
1446
|
+
});
|
|
1447
|
+
var getAdminAccountsById = (options) => (options.client ?? client).get({
|
|
1448
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1449
|
+
url: "/admin/accounts/{id}",
|
|
1450
|
+
...options
|
|
1451
|
+
});
|
|
1452
|
+
var getAdminBucketsByIdStats = (options) => (options.client ?? client).get({
|
|
1453
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1454
|
+
url: "/admin/buckets/{id}/stats",
|
|
1455
|
+
...options
|
|
1456
|
+
});
|
|
1457
|
+
var getAdminDocumentsStats = (options) => (options.client ?? client).get({
|
|
1458
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1459
|
+
url: "/admin/documents/stats",
|
|
1460
|
+
...options
|
|
1461
|
+
});
|
|
1462
|
+
var getAdminWebhookDeliveries = (options) => (options.client ?? client).get({
|
|
1463
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1464
|
+
url: "/admin/webhook-deliveries",
|
|
1465
|
+
...options
|
|
1466
|
+
});
|
|
1467
|
+
var getAdminExtractionDocuments = (options) => (options.client ?? client).get({
|
|
1468
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1469
|
+
url: "/admin/extraction/documents",
|
|
1470
|
+
...options
|
|
1471
|
+
});
|
|
1472
|
+
var getAdminBucketsByIdObjects = (options) => (options.client ?? client).get({
|
|
1473
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1474
|
+
url: "/admin/buckets/{id}/objects",
|
|
1475
|
+
...options
|
|
1476
|
+
});
|
|
1477
|
+
var postAdminDocumentsBulkDelete = (options) => (options.client ?? client).post({
|
|
1478
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1479
|
+
url: "/admin/documents/bulk-delete",
|
|
1480
|
+
...options,
|
|
1481
|
+
headers: {
|
|
1482
|
+
"Content-Type": "application/vnd.api+json",
|
|
1483
|
+
...options.headers
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
var getAdminWebhookConfigs = (options) => (options.client ?? client).get({
|
|
1487
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1488
|
+
url: "/admin/webhook-configs",
|
|
1489
|
+
...options
|
|
1490
|
+
});
|
|
1491
|
+
var postAdminWebhookConfigs = (options) => (options.client ?? client).post({
|
|
1492
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1493
|
+
url: "/admin/webhook-configs",
|
|
1494
|
+
...options,
|
|
1495
|
+
headers: {
|
|
1496
|
+
"Content-Type": "application/vnd.api+json",
|
|
1497
|
+
...options.headers
|
|
1498
|
+
}
|
|
1499
|
+
});
|
|
1500
|
+
var patchAdminApiKeysByIdAllocate = (options) => (options.client ?? client).patch({
|
|
1501
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1502
|
+
url: "/admin/api-keys/{id}/allocate",
|
|
1503
|
+
...options,
|
|
1504
|
+
headers: {
|
|
1505
|
+
"Content-Type": "application/vnd.api+json",
|
|
1506
|
+
...options.headers
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
var patchAdminApiKeysByIdRevoke = (options) => (options.client ?? client).patch({
|
|
1510
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1511
|
+
url: "/admin/api-keys/{id}/revoke",
|
|
1512
|
+
...options,
|
|
1513
|
+
headers: {
|
|
1514
|
+
"Content-Type": "application/vnd.api+json",
|
|
1515
|
+
...options.headers
|
|
1516
|
+
}
|
|
1517
|
+
});
|
|
1518
|
+
var getAdminBuckets = (options) => (options.client ?? client).get({
|
|
1519
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1520
|
+
url: "/admin/buckets",
|
|
1521
|
+
...options
|
|
1522
|
+
});
|
|
1523
|
+
var patchAdminApiKeysByIdRotate = (options) => (options.client ?? client).patch({
|
|
1524
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1525
|
+
url: "/admin/api-keys/{id}/rotate",
|
|
1526
|
+
...options,
|
|
1527
|
+
headers: {
|
|
1528
|
+
"Content-Type": "application/vnd.api+json",
|
|
1529
|
+
...options.headers
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
var getAdminBucketsById = (options) => (options.client ?? client).get({
|
|
1533
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1534
|
+
url: "/admin/buckets/{id}",
|
|
1535
|
+
...options
|
|
1536
|
+
});
|
|
1537
|
+
var postAdminWebhookConfigsByIdTest = (options) => (options.client ?? client).post({
|
|
1538
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1539
|
+
url: "/admin/webhook-configs/{id}/test",
|
|
1540
|
+
...options,
|
|
1541
|
+
headers: {
|
|
1542
|
+
"Content-Type": "application/vnd.api+json",
|
|
1543
|
+
...options.headers
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
var postAdminWebhookDeliveriesByIdRetry = (options) => (options.client ?? client).post({
|
|
1547
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1548
|
+
url: "/admin/webhook-deliveries/{id}/retry",
|
|
1549
|
+
...options,
|
|
1550
|
+
headers: {
|
|
1551
|
+
"Content-Type": "application/vnd.api+json",
|
|
1552
|
+
...options.headers
|
|
1553
|
+
}
|
|
1554
|
+
});
|
|
1606
1555
|
|
|
1607
1556
|
// src/schemas/requests.ts
|
|
1608
1557
|
var import_zod = require("zod");
|
|
1609
1558
|
var StorageStatsRequestSchema = import_zod.z.object({
|
|
1610
|
-
workspace_id: import_zod.z.string().optional()
|
|
1559
|
+
workspace_id: import_zod.z.string().optional()
|
|
1611
1560
|
});
|
|
1612
1561
|
var WebhookConfigCreateSchema = import_zod.z.object({
|
|
1613
1562
|
url: import_zod.z.string().url(),
|
|
1614
1563
|
events: import_zod.z.array(import_zod.z.string()).min(1),
|
|
1615
1564
|
secret: import_zod.z.string().optional(),
|
|
1616
|
-
enabled: import_zod.z.boolean().default(true)
|
|
1565
|
+
enabled: import_zod.z.boolean().default(true)
|
|
1617
1566
|
});
|
|
1618
1567
|
var WebhookBulkEnableSchema = import_zod.z.object({
|
|
1619
|
-
config_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
|
|
1568
|
+
config_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
|
|
1620
1569
|
});
|
|
1621
1570
|
var WebhookBulkDisableSchema = import_zod.z.object({
|
|
1622
|
-
config_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
|
|
1571
|
+
config_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
|
|
1623
1572
|
});
|
|
1624
1573
|
var WebhookDeliveryBulkRetrySchema = import_zod.z.object({
|
|
1625
|
-
delivery_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
|
|
1574
|
+
delivery_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
|
|
1626
1575
|
});
|
|
1627
1576
|
var AgentAdminCreateSchema = import_zod.z.object({
|
|
1628
1577
|
name: import_zod.z.string().min(1).max(255),
|
|
1629
1578
|
prompt_template: import_zod.z.string().min(1),
|
|
1630
|
-
system_wide: import_zod.z.boolean().default(false)
|
|
1579
|
+
system_wide: import_zod.z.boolean().default(false)
|
|
1631
1580
|
});
|
|
1632
1581
|
var AccountCreditSchema = import_zod.z.object({
|
|
1633
1582
|
amount: import_zod.z.number().positive(),
|
|
1634
|
-
description: import_zod.z.string().optional()
|
|
1583
|
+
description: import_zod.z.string().optional()
|
|
1635
1584
|
});
|
|
1636
1585
|
var AccountDebitSchema = import_zod.z.object({
|
|
1637
1586
|
amount: import_zod.z.number().positive(),
|
|
1638
|
-
description: import_zod.z.string().optional()
|
|
1587
|
+
description: import_zod.z.string().optional()
|
|
1639
1588
|
});
|
|
1640
1589
|
var ApiKeyAllocateSchema = import_zod.z.object({
|
|
1641
1590
|
rate_limit: import_zod.z.number().int().positive().optional(),
|
|
1642
|
-
expires_at: import_zod.z.string().datetime().optional()
|
|
1591
|
+
expires_at: import_zod.z.string().datetime().optional()
|
|
1643
1592
|
});
|
|
1644
1593
|
var DocumentBulkDeleteSchema = import_zod.z.object({
|
|
1645
|
-
document_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
|
|
1594
|
+
document_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
|
|
1646
1595
|
});
|
|
1647
1596
|
var DocumentBulkReprocessSchema = import_zod.z.object({
|
|
1648
|
-
document_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
|
|
1597
|
+
document_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
|
|
1649
1598
|
});
|
|
1650
1599
|
|
|
1651
1600
|
// src/namespaces/accounts.ts
|
|
@@ -1657,7 +1606,11 @@ function createAccountsNamespace(rb) {
|
|
|
1657
1606
|
},
|
|
1658
1607
|
/** Get a billing account by ID */
|
|
1659
1608
|
get: async (id, options) => {
|
|
1660
|
-
return rb.execute(
|
|
1609
|
+
return rb.execute(
|
|
1610
|
+
getAdminAccountsById,
|
|
1611
|
+
{ path: { id } },
|
|
1612
|
+
options
|
|
1613
|
+
);
|
|
1661
1614
|
},
|
|
1662
1615
|
/** Credit an account */
|
|
1663
1616
|
credit: async (id, amount, description, options) => {
|
|
@@ -1670,11 +1623,11 @@ function createAccountsNamespace(rb) {
|
|
|
1670
1623
|
data: {
|
|
1671
1624
|
id,
|
|
1672
1625
|
type: "account",
|
|
1673
|
-
attributes: validated
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1626
|
+
attributes: validated
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1676
1629
|
},
|
|
1677
|
-
options
|
|
1630
|
+
options
|
|
1678
1631
|
);
|
|
1679
1632
|
},
|
|
1680
1633
|
/** Debit an account */
|
|
@@ -1688,13 +1641,13 @@ function createAccountsNamespace(rb) {
|
|
|
1688
1641
|
data: {
|
|
1689
1642
|
id,
|
|
1690
1643
|
type: "account",
|
|
1691
|
-
attributes: validated
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1644
|
+
attributes: validated
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1694
1647
|
},
|
|
1695
|
-
options
|
|
1648
|
+
options
|
|
1696
1649
|
);
|
|
1697
|
-
}
|
|
1650
|
+
}
|
|
1698
1651
|
};
|
|
1699
1652
|
}
|
|
1700
1653
|
|
|
@@ -1721,22 +1674,30 @@ function createApiKeysNamespace(rb) {
|
|
|
1721
1674
|
type: "api_key",
|
|
1722
1675
|
attributes: {
|
|
1723
1676
|
amount,
|
|
1724
|
-
description
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1677
|
+
description
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1728
1681
|
},
|
|
1729
|
-
options
|
|
1682
|
+
options
|
|
1730
1683
|
);
|
|
1731
1684
|
},
|
|
1732
1685
|
/** Revoke an API key */
|
|
1733
1686
|
revoke: async (id, options) => {
|
|
1734
|
-
return rb.execute(
|
|
1687
|
+
return rb.execute(
|
|
1688
|
+
patchAdminApiKeysByIdRevoke,
|
|
1689
|
+
{ path: { id } },
|
|
1690
|
+
options
|
|
1691
|
+
);
|
|
1735
1692
|
},
|
|
1736
1693
|
/** Rotate an API key */
|
|
1737
1694
|
rotate: async (id, options) => {
|
|
1738
|
-
return rb.execute(
|
|
1739
|
-
|
|
1695
|
+
return rb.execute(
|
|
1696
|
+
patchAdminApiKeysByIdRotate,
|
|
1697
|
+
{ path: { id } },
|
|
1698
|
+
options
|
|
1699
|
+
);
|
|
1700
|
+
}
|
|
1740
1701
|
};
|
|
1741
1702
|
}
|
|
1742
1703
|
|
|
@@ -1745,14 +1706,18 @@ function createDocumentsNamespace(rb) {
|
|
|
1745
1706
|
return {
|
|
1746
1707
|
/** List extraction documents */
|
|
1747
1708
|
list: async (options) => {
|
|
1748
|
-
return rb.execute(
|
|
1709
|
+
return rb.execute(
|
|
1710
|
+
getAdminExtractionDocuments,
|
|
1711
|
+
{},
|
|
1712
|
+
options
|
|
1713
|
+
);
|
|
1749
1714
|
},
|
|
1750
1715
|
/** Get a document by ID */
|
|
1751
1716
|
get: async (id, options) => {
|
|
1752
1717
|
return rb.execute(
|
|
1753
1718
|
getAdminExtractionDocumentsById,
|
|
1754
1719
|
{ path: { id } },
|
|
1755
|
-
options
|
|
1720
|
+
options
|
|
1756
1721
|
);
|
|
1757
1722
|
},
|
|
1758
1723
|
/** Get document statistics */
|
|
@@ -1762,7 +1727,7 @@ function createDocumentsNamespace(rb) {
|
|
|
1762
1727
|
/** Bulk delete documents */
|
|
1763
1728
|
bulkDelete: async (documentIds, options) => {
|
|
1764
1729
|
const validated = DocumentBulkDeleteSchema.parse({
|
|
1765
|
-
document_ids: documentIds
|
|
1730
|
+
document_ids: documentIds
|
|
1766
1731
|
});
|
|
1767
1732
|
return rb.execute(
|
|
1768
1733
|
postAdminDocumentsBulkDelete,
|
|
@@ -1771,14 +1736,14 @@ function createDocumentsNamespace(rb) {
|
|
|
1771
1736
|
data: {
|
|
1772
1737
|
type: "operation_success",
|
|
1773
1738
|
attributes: {
|
|
1774
|
-
ids: validated.document_ids
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1739
|
+
ids: validated.document_ids
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1778
1743
|
},
|
|
1779
|
-
options
|
|
1744
|
+
options
|
|
1780
1745
|
);
|
|
1781
|
-
}
|
|
1746
|
+
}
|
|
1782
1747
|
};
|
|
1783
1748
|
}
|
|
1784
1749
|
|
|
@@ -1787,44 +1752,44 @@ function addExecutionStreaming(executions, getHeaders) {
|
|
|
1787
1752
|
executions.stream = async (executionId, options) => {
|
|
1788
1753
|
const headers = {
|
|
1789
1754
|
...getHeaders(),
|
|
1790
|
-
Accept: "text/event-stream"
|
|
1755
|
+
Accept: "text/event-stream"
|
|
1791
1756
|
};
|
|
1792
1757
|
const result = await client.get({
|
|
1793
1758
|
url: `/isv/agent-executions/${executionId}/stream`,
|
|
1794
1759
|
headers,
|
|
1795
1760
|
parseAs: "stream",
|
|
1796
|
-
...
|
|
1761
|
+
...options?.signal && { signal: options.signal }
|
|
1797
1762
|
});
|
|
1798
1763
|
const envelope = result;
|
|
1799
1764
|
const streamBody = envelope.data ?? result;
|
|
1800
1765
|
const response = envelope.response;
|
|
1801
1766
|
if (response && !response.ok) {
|
|
1802
1767
|
throw new ServerError(`Stream request failed: ${response.status}`, {
|
|
1803
|
-
statusCode: response.status
|
|
1768
|
+
statusCode: response.status
|
|
1804
1769
|
});
|
|
1805
1770
|
}
|
|
1806
1771
|
if (streamBody instanceof ReadableStream) {
|
|
1807
1772
|
const syntheticResponse = new Response(streamBody, {
|
|
1808
|
-
headers: { "Content-Type": "text/event-stream" }
|
|
1773
|
+
headers: { "Content-Type": "text/event-stream" }
|
|
1809
1774
|
});
|
|
1810
1775
|
return streamMessage(syntheticResponse, {
|
|
1811
1776
|
signal: options?.signal,
|
|
1812
|
-
...options
|
|
1777
|
+
...options
|
|
1813
1778
|
});
|
|
1814
1779
|
}
|
|
1815
1780
|
if (streamBody instanceof Response) {
|
|
1816
1781
|
if (!streamBody.ok) {
|
|
1817
1782
|
throw new ServerError(`Stream request failed: ${streamBody.status}`, {
|
|
1818
|
-
statusCode: streamBody.status
|
|
1783
|
+
statusCode: streamBody.status
|
|
1819
1784
|
});
|
|
1820
1785
|
}
|
|
1821
1786
|
return streamMessage(streamBody, {
|
|
1822
1787
|
signal: options?.signal,
|
|
1823
|
-
...options
|
|
1788
|
+
...options
|
|
1824
1789
|
});
|
|
1825
1790
|
}
|
|
1826
1791
|
throw new GptCoreError("Unexpected stream response format", {
|
|
1827
|
-
code: "stream_error"
|
|
1792
|
+
code: "stream_error"
|
|
1828
1793
|
});
|
|
1829
1794
|
};
|
|
1830
1795
|
}
|
|
@@ -1834,23 +1799,33 @@ function createExecutionsNamespace(rb) {
|
|
|
1834
1799
|
const executions = {
|
|
1835
1800
|
/** Start a new agent execution */
|
|
1836
1801
|
start: async (agentId, params, options) => {
|
|
1837
|
-
return rb.rawPost(
|
|
1802
|
+
return rb.rawPost(
|
|
1803
|
+
`/isv/agents/${agentId}/execute`,
|
|
1804
|
+
params,
|
|
1805
|
+
options
|
|
1806
|
+
);
|
|
1838
1807
|
},
|
|
1839
1808
|
/** Get execution status and details */
|
|
1840
1809
|
get: async (executionId, options) => {
|
|
1841
|
-
return rb.rawGet(
|
|
1810
|
+
return rb.rawGet(
|
|
1811
|
+
`/isv/agent-executions/${executionId}`,
|
|
1812
|
+
options
|
|
1813
|
+
);
|
|
1842
1814
|
},
|
|
1843
1815
|
/** List executions for a workspace */
|
|
1844
1816
|
list: async (filters, options) => {
|
|
1845
1817
|
const query = filters?.status ? `?status=${filters.status}` : "";
|
|
1846
|
-
return rb.rawGet(
|
|
1818
|
+
return rb.rawGet(
|
|
1819
|
+
`/isv/agent-executions${query}`,
|
|
1820
|
+
options
|
|
1821
|
+
);
|
|
1847
1822
|
},
|
|
1848
1823
|
/** Cancel a running execution */
|
|
1849
1824
|
cancel: async (executionId, options) => {
|
|
1850
1825
|
return rb.rawPost(
|
|
1851
1826
|
`/isv/agent-executions/${executionId}/cancel`,
|
|
1852
1827
|
void 0,
|
|
1853
|
-
options
|
|
1828
|
+
options
|
|
1854
1829
|
);
|
|
1855
1830
|
},
|
|
1856
1831
|
/** Approve a pending tool call */
|
|
@@ -1858,7 +1833,7 @@ function createExecutionsNamespace(rb) {
|
|
|
1858
1833
|
return rb.rawPost(
|
|
1859
1834
|
`/isv/agent-executions/${executionId}/approve`,
|
|
1860
1835
|
void 0,
|
|
1861
|
-
options
|
|
1836
|
+
options
|
|
1862
1837
|
);
|
|
1863
1838
|
},
|
|
1864
1839
|
/** Deny a pending tool call */
|
|
@@ -1866,26 +1841,36 @@ function createExecutionsNamespace(rb) {
|
|
|
1866
1841
|
return rb.rawPost(
|
|
1867
1842
|
`/isv/agent-executions/${executionId}/deny`,
|
|
1868
1843
|
reason ? { reason } : void 0,
|
|
1869
|
-
options
|
|
1844
|
+
options
|
|
1870
1845
|
);
|
|
1871
1846
|
},
|
|
1872
1847
|
/** Estimate cost for executing an agent */
|
|
1873
1848
|
estimate: async (agentId, params, options) => {
|
|
1874
|
-
return rb.rawPost(
|
|
1849
|
+
return rb.rawPost(
|
|
1850
|
+
`/isv/agents/${agentId}/estimate`,
|
|
1851
|
+
params,
|
|
1852
|
+
options
|
|
1853
|
+
);
|
|
1875
1854
|
},
|
|
1876
1855
|
/** Get child executions of a parent execution */
|
|
1877
1856
|
getChildren: async (executionId, options) => {
|
|
1878
1857
|
return rb.rawGet(
|
|
1879
1858
|
`/isv/agent-executions/${executionId}/children`,
|
|
1880
|
-
options
|
|
1859
|
+
options
|
|
1881
1860
|
);
|
|
1882
1861
|
},
|
|
1883
1862
|
/** Get the execution tree rooted at a given execution */
|
|
1884
1863
|
getTree: async (executionId, options) => {
|
|
1885
|
-
return rb.rawGet(
|
|
1886
|
-
|
|
1864
|
+
return rb.rawGet(
|
|
1865
|
+
`/isv/agent-executions/${executionId}/tree`,
|
|
1866
|
+
options
|
|
1867
|
+
);
|
|
1868
|
+
}
|
|
1887
1869
|
};
|
|
1888
|
-
addExecutionStreaming(
|
|
1870
|
+
addExecutionStreaming(
|
|
1871
|
+
executions,
|
|
1872
|
+
() => rb.getRequestHeaders()
|
|
1873
|
+
);
|
|
1889
1874
|
return executions;
|
|
1890
1875
|
}
|
|
1891
1876
|
|
|
@@ -1895,14 +1880,12 @@ function createStorageNamespace(rb) {
|
|
|
1895
1880
|
/** Get storage statistics */
|
|
1896
1881
|
stats: async (workspaceId, options) => {
|
|
1897
1882
|
const validated = StorageStatsRequestSchema.parse({
|
|
1898
|
-
workspace_id: workspaceId
|
|
1883
|
+
workspace_id: workspaceId
|
|
1899
1884
|
});
|
|
1900
1885
|
return rb.execute(
|
|
1901
1886
|
getAdminStorageStats,
|
|
1902
|
-
validated.workspace_id
|
|
1903
|
-
|
|
1904
|
-
: {},
|
|
1905
|
-
options,
|
|
1887
|
+
validated.workspace_id ? { query: { filter: { workspace_id: validated.workspace_id } } } : {},
|
|
1888
|
+
options
|
|
1906
1889
|
);
|
|
1907
1890
|
},
|
|
1908
1891
|
/** Bucket management */
|
|
@@ -1913,21 +1896,29 @@ function createStorageNamespace(rb) {
|
|
|
1913
1896
|
},
|
|
1914
1897
|
/** Get a bucket by ID */
|
|
1915
1898
|
get: async (id, options) => {
|
|
1916
|
-
return rb.execute(
|
|
1899
|
+
return rb.execute(
|
|
1900
|
+
getAdminBucketsById,
|
|
1901
|
+
{ path: { id } },
|
|
1902
|
+
options
|
|
1903
|
+
);
|
|
1917
1904
|
},
|
|
1918
1905
|
/** Get bucket statistics */
|
|
1919
1906
|
stats: async (id, options) => {
|
|
1920
|
-
return rb.execute(
|
|
1907
|
+
return rb.execute(
|
|
1908
|
+
getAdminBucketsByIdStats,
|
|
1909
|
+
{ path: { id } },
|
|
1910
|
+
options
|
|
1911
|
+
);
|
|
1921
1912
|
},
|
|
1922
1913
|
/** List objects in a bucket */
|
|
1923
1914
|
objects: async (id, options) => {
|
|
1924
1915
|
return rb.execute(
|
|
1925
1916
|
getAdminBucketsByIdObjects,
|
|
1926
1917
|
{ path: { id } },
|
|
1927
|
-
options
|
|
1918
|
+
options
|
|
1928
1919
|
);
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1931
1922
|
};
|
|
1932
1923
|
}
|
|
1933
1924
|
|
|
@@ -1940,15 +1931,7 @@ function createWebhooksNamespace(rb) {
|
|
|
1940
1931
|
return rb.execute(getAdminWebhookConfigs, {}, options);
|
|
1941
1932
|
},
|
|
1942
1933
|
/** Create a webhook config */
|
|
1943
|
-
create: async (
|
|
1944
|
-
name,
|
|
1945
|
-
url,
|
|
1946
|
-
events,
|
|
1947
|
-
applicationId,
|
|
1948
|
-
secret,
|
|
1949
|
-
enabled = true,
|
|
1950
|
-
options,
|
|
1951
|
-
) => {
|
|
1934
|
+
create: async (name, url, events, applicationId, secret, enabled = true, options) => {
|
|
1952
1935
|
return rb.execute(
|
|
1953
1936
|
postAdminWebhookConfigs,
|
|
1954
1937
|
{
|
|
@@ -1961,12 +1944,12 @@ function createWebhooksNamespace(rb) {
|
|
|
1961
1944
|
events,
|
|
1962
1945
|
application_id: applicationId,
|
|
1963
1946
|
secret,
|
|
1964
|
-
enabled
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1947
|
+
enabled
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1968
1951
|
},
|
|
1969
|
-
options
|
|
1952
|
+
options
|
|
1970
1953
|
);
|
|
1971
1954
|
},
|
|
1972
1955
|
/** Get a webhook config by ID */
|
|
@@ -1974,7 +1957,7 @@ function createWebhooksNamespace(rb) {
|
|
|
1974
1957
|
return rb.execute(
|
|
1975
1958
|
getAdminWebhookConfigsById,
|
|
1976
1959
|
{ path: { id } },
|
|
1977
|
-
options
|
|
1960
|
+
options
|
|
1978
1961
|
);
|
|
1979
1962
|
},
|
|
1980
1963
|
/** Update a webhook config */
|
|
@@ -1987,11 +1970,11 @@ function createWebhooksNamespace(rb) {
|
|
|
1987
1970
|
data: {
|
|
1988
1971
|
id,
|
|
1989
1972
|
type: "webhook_config",
|
|
1990
|
-
attributes: updates
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1973
|
+
attributes: updates
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1993
1976
|
},
|
|
1994
|
-
options
|
|
1977
|
+
options
|
|
1995
1978
|
);
|
|
1996
1979
|
},
|
|
1997
1980
|
/** Delete a webhook config */
|
|
@@ -1999,7 +1982,7 @@ function createWebhooksNamespace(rb) {
|
|
|
1999
1982
|
return rb.executeDelete(
|
|
2000
1983
|
deleteAdminWebhookConfigsById,
|
|
2001
1984
|
{ path: { id } },
|
|
2002
|
-
options
|
|
1985
|
+
options
|
|
2003
1986
|
);
|
|
2004
1987
|
},
|
|
2005
1988
|
/** Test a webhook config */
|
|
@@ -2007,21 +1990,25 @@ function createWebhooksNamespace(rb) {
|
|
|
2007
1990
|
return rb.execute(
|
|
2008
1991
|
postAdminWebhookConfigsByIdTest,
|
|
2009
1992
|
{ path: { id } },
|
|
2010
|
-
options
|
|
1993
|
+
options
|
|
2011
1994
|
);
|
|
2012
|
-
}
|
|
1995
|
+
}
|
|
2013
1996
|
},
|
|
2014
1997
|
deliveries: {
|
|
2015
1998
|
/** List webhook deliveries */
|
|
2016
1999
|
list: async (options) => {
|
|
2017
|
-
return rb.execute(
|
|
2000
|
+
return rb.execute(
|
|
2001
|
+
getAdminWebhookDeliveries,
|
|
2002
|
+
{},
|
|
2003
|
+
options
|
|
2004
|
+
);
|
|
2018
2005
|
},
|
|
2019
2006
|
/** Get a webhook delivery by ID */
|
|
2020
2007
|
get: async (id, options) => {
|
|
2021
2008
|
return rb.execute(
|
|
2022
2009
|
getAdminWebhookDeliveriesById,
|
|
2023
2010
|
{ path: { id } },
|
|
2024
|
-
options
|
|
2011
|
+
options
|
|
2025
2012
|
);
|
|
2026
2013
|
},
|
|
2027
2014
|
/** Retry a webhook delivery */
|
|
@@ -2029,10 +2016,10 @@ function createWebhooksNamespace(rb) {
|
|
|
2029
2016
|
return rb.execute(
|
|
2030
2017
|
postAdminWebhookDeliveriesByIdRetry,
|
|
2031
2018
|
{ path: { id } },
|
|
2032
|
-
options
|
|
2019
|
+
options
|
|
2033
2020
|
);
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2036
2023
|
};
|
|
2037
2024
|
}
|
|
2038
2025
|
|
|
@@ -2044,7 +2031,7 @@ var GptAdmin = class extends BaseClient {
|
|
|
2044
2031
|
this.clientInstance,
|
|
2045
2032
|
() => this.getHeaders(),
|
|
2046
2033
|
(d) => this.unwrap(d),
|
|
2047
|
-
(fn) => this.requestWithRetry(fn)
|
|
2034
|
+
(fn) => this.requestWithRetry(fn)
|
|
2048
2035
|
);
|
|
2049
2036
|
this.accounts = createAccountsNamespace(rb);
|
|
2050
2037
|
this.apiKeys = createApiKeysNamespace(rb);
|
|
@@ -2058,29 +2045,29 @@ var GptAdmin = class extends BaseClient {
|
|
|
2058
2045
|
// src/index.ts
|
|
2059
2046
|
var index_default = GptAdmin;
|
|
2060
2047
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2061
|
-
0 &&
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2048
|
+
0 && (module.exports = {
|
|
2049
|
+
AccountCreditSchema,
|
|
2050
|
+
AccountDebitSchema,
|
|
2051
|
+
AgentAdminCreateSchema,
|
|
2052
|
+
ApiKeyAllocateSchema,
|
|
2053
|
+
AuthenticationError,
|
|
2054
|
+
AuthorizationError,
|
|
2055
|
+
DEFAULT_API_VERSION,
|
|
2056
|
+
DocumentBulkDeleteSchema,
|
|
2057
|
+
DocumentBulkReprocessSchema,
|
|
2058
|
+
GptAdmin,
|
|
2059
|
+
GptCoreError,
|
|
2060
|
+
NetworkError,
|
|
2061
|
+
NotFoundError,
|
|
2062
|
+
RateLimitError,
|
|
2063
|
+
ServerError,
|
|
2064
|
+
StorageStatsRequestSchema,
|
|
2065
|
+
TimeoutError,
|
|
2066
|
+
ValidationError,
|
|
2067
|
+
WebhookBulkDisableSchema,
|
|
2068
|
+
WebhookBulkEnableSchema,
|
|
2069
|
+
WebhookConfigCreateSchema,
|
|
2070
|
+
WebhookDeliveryBulkRetrySchema,
|
|
2071
|
+
handleApiError
|
|
2072
|
+
});
|
|
2073
|
+
//# sourceMappingURL=index.js.map
|