@gpt-core/admin 0.10.20 → 0.10.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -49
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -10
- package/dist/index.mjs +32 -10
- package/package.json +13 -13
- package/dist/index.cjs +0 -1606
package/README.md
CHANGED
|
@@ -32,8 +32,11 @@ AI_CONTEXT_END -->
|
|
|
32
32
|
> **TL;DR for Claude, Cursor, Copilot, and other AI assistants:**
|
|
33
33
|
>
|
|
34
34
|
> ```typescript
|
|
35
|
-
> import { GptAdmin } from
|
|
36
|
-
> const admin = new GptAdmin({
|
|
35
|
+
> import { GptAdmin } from "@gpt-core/admin";
|
|
36
|
+
> const admin = new GptAdmin({
|
|
37
|
+
> baseUrl: "https://api.example.com",
|
|
38
|
+
> token: "admin-jwt",
|
|
39
|
+
> });
|
|
37
40
|
> ```
|
|
38
41
|
>
|
|
39
42
|
> **Common operations:**
|
|
@@ -75,12 +78,12 @@ pnpm add @gpt-core/admin
|
|
|
75
78
|
## Quick Start
|
|
76
79
|
|
|
77
80
|
```typescript
|
|
78
|
-
import { GptAdmin } from
|
|
81
|
+
import { GptAdmin } from "@gpt-core/admin";
|
|
79
82
|
|
|
80
83
|
// Initialize admin client
|
|
81
84
|
const admin = new GptAdmin({
|
|
82
|
-
baseUrl:
|
|
83
|
-
token: process.env.ADMIN_JWT_TOKEN,
|
|
85
|
+
baseUrl: "https://api.gpt-core.com",
|
|
86
|
+
token: process.env.ADMIN_JWT_TOKEN, // Admin JWT token
|
|
84
87
|
applicationId: process.env.APPLICATION_ID, // Your application ID
|
|
85
88
|
});
|
|
86
89
|
|
|
@@ -91,7 +94,9 @@ console.log(`Total files: ${stats.file_count}`);
|
|
|
91
94
|
|
|
92
95
|
// List webhook configurations
|
|
93
96
|
const webhooks = await admin.webhooks.configs.list();
|
|
94
|
-
console.log(
|
|
97
|
+
console.log(
|
|
98
|
+
`Active webhooks: ${webhooks.filter((w) => w.attributes.enabled).length}`,
|
|
99
|
+
);
|
|
95
100
|
```
|
|
96
101
|
|
|
97
102
|
## Configuration
|
|
@@ -99,13 +104,13 @@ console.log(`Active webhooks: ${webhooks.filter(w => w.attributes.enabled).lengt
|
|
|
99
104
|
```typescript
|
|
100
105
|
const admin = new GptAdmin({
|
|
101
106
|
// Required: API base URL
|
|
102
|
-
baseUrl:
|
|
107
|
+
baseUrl: "https://api.gpt-core.com",
|
|
103
108
|
|
|
104
109
|
// Required: Admin JWT token
|
|
105
|
-
token:
|
|
110
|
+
token: "admin-jwt-token",
|
|
106
111
|
|
|
107
112
|
// Required: Application ID
|
|
108
|
-
applicationId:
|
|
113
|
+
applicationId: "your-app-id",
|
|
109
114
|
});
|
|
110
115
|
```
|
|
111
116
|
|
|
@@ -120,7 +125,7 @@ APPLICATION_ID=your-application-id
|
|
|
120
125
|
|
|
121
126
|
```typescript
|
|
122
127
|
// lib/admin-client.ts
|
|
123
|
-
import { GptAdmin } from
|
|
128
|
+
import { GptAdmin } from "@gpt-core/admin";
|
|
124
129
|
|
|
125
130
|
export const admin = new GptAdmin({
|
|
126
131
|
baseUrl: process.env.ADMIN_API_URL!,
|
|
@@ -149,10 +154,10 @@ Pin a specific API version to protect your integration from breaking changes:
|
|
|
149
154
|
|
|
150
155
|
```typescript
|
|
151
156
|
const admin = new GptAdmin({
|
|
152
|
-
baseUrl:
|
|
157
|
+
baseUrl: "https://api.gpt-core.com",
|
|
153
158
|
token: process.env.ADMIN_JWT_TOKEN,
|
|
154
159
|
applicationId: process.env.APPLICATION_ID,
|
|
155
|
-
apiVersion:
|
|
160
|
+
apiVersion: "2025-12-03", // Pin to this version
|
|
156
161
|
});
|
|
157
162
|
```
|
|
158
163
|
|
|
@@ -195,35 +200,35 @@ const configs = await admin.webhooks.configs.list();
|
|
|
195
200
|
|
|
196
201
|
```typescript
|
|
197
202
|
const webhook = await admin.webhooks.configs.create(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
[
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
true
|
|
203
|
+
"My Webhook", // name
|
|
204
|
+
"https://your-server.com/webhook", // url
|
|
205
|
+
["document.analyzed", "thread.message.created"], // events
|
|
206
|
+
"app-123", // application_id
|
|
207
|
+
"your-webhook-secret", // secret (optional)
|
|
208
|
+
true, // enabled
|
|
204
209
|
);
|
|
205
210
|
```
|
|
206
211
|
|
|
207
212
|
#### Update Webhook Config
|
|
208
213
|
|
|
209
214
|
```typescript
|
|
210
|
-
const config = await admin.webhooks.configs.update(
|
|
215
|
+
const config = await admin.webhooks.configs.update("webhook-id", {
|
|
211
216
|
enabled: false,
|
|
212
|
-
events: [
|
|
217
|
+
events: ["document.analyzed"],
|
|
213
218
|
});
|
|
214
219
|
```
|
|
215
220
|
|
|
216
221
|
#### Delete Webhook Config
|
|
217
222
|
|
|
218
223
|
```typescript
|
|
219
|
-
await admin.webhooks.configs.delete(
|
|
224
|
+
await admin.webhooks.configs.delete("webhook-id");
|
|
220
225
|
```
|
|
221
226
|
|
|
222
227
|
#### Test Webhook Config
|
|
223
228
|
|
|
224
229
|
```typescript
|
|
225
|
-
const result = await admin.webhooks.configs.test(
|
|
226
|
-
console.log(
|
|
230
|
+
const result = await admin.webhooks.configs.test("webhook-id");
|
|
231
|
+
console.log("Test delivery ID:", result.delivery_id);
|
|
227
232
|
```
|
|
228
233
|
|
|
229
234
|
#### Webhook Deliveries
|
|
@@ -233,10 +238,10 @@ console.log('Test delivery ID:', result.delivery_id);
|
|
|
233
238
|
const deliveries = await admin.webhooks.deliveries.list();
|
|
234
239
|
|
|
235
240
|
// Get delivery details
|
|
236
|
-
const delivery = await admin.webhooks.deliveries.get(
|
|
241
|
+
const delivery = await admin.webhooks.deliveries.get("delivery-id");
|
|
237
242
|
|
|
238
243
|
// Retry failed delivery
|
|
239
|
-
await admin.webhooks.deliveries.retry(
|
|
244
|
+
await admin.webhooks.deliveries.retry("delivery-id");
|
|
240
245
|
```
|
|
241
246
|
|
|
242
247
|
### Storage Administration
|
|
@@ -247,19 +252,19 @@ const stats = await admin.storage.stats();
|
|
|
247
252
|
console.log(stats.total_size, stats.file_count);
|
|
248
253
|
|
|
249
254
|
// Get stats for specific workspace
|
|
250
|
-
const workspaceStats = await admin.storage.stats(
|
|
255
|
+
const workspaceStats = await admin.storage.stats("workspace-id");
|
|
251
256
|
|
|
252
257
|
// List all buckets
|
|
253
258
|
const buckets = await admin.storage.buckets.list();
|
|
254
259
|
|
|
255
260
|
// Get bucket details
|
|
256
|
-
const bucket = await admin.storage.buckets.get(
|
|
261
|
+
const bucket = await admin.storage.buckets.get("bucket-id");
|
|
257
262
|
|
|
258
263
|
// Get bucket stats
|
|
259
|
-
const bucketStats = await admin.storage.buckets.stats(
|
|
264
|
+
const bucketStats = await admin.storage.buckets.stats("bucket-id");
|
|
260
265
|
|
|
261
266
|
// List bucket objects
|
|
262
|
-
const objects = await admin.storage.buckets.objects(
|
|
267
|
+
const objects = await admin.storage.buckets.objects("bucket-id");
|
|
263
268
|
```
|
|
264
269
|
|
|
265
270
|
### Account Management
|
|
@@ -269,13 +274,13 @@ const objects = await admin.storage.buckets.objects('bucket-id');
|
|
|
269
274
|
const accounts = await admin.accounts.list();
|
|
270
275
|
|
|
271
276
|
// Get account details
|
|
272
|
-
const account = await admin.accounts.get(
|
|
277
|
+
const account = await admin.accounts.get("account-id");
|
|
273
278
|
|
|
274
279
|
// Credit an account
|
|
275
|
-
await admin.accounts.credit(
|
|
280
|
+
await admin.accounts.credit("account-id", 1000, "Bonus credits");
|
|
276
281
|
|
|
277
282
|
// Debit an account
|
|
278
|
-
await admin.accounts.debit(
|
|
283
|
+
await admin.accounts.debit("account-id", 500, "Usage charge");
|
|
279
284
|
```
|
|
280
285
|
|
|
281
286
|
### Document Administration
|
|
@@ -285,13 +290,13 @@ await admin.accounts.debit('account-id', 500, 'Usage charge');
|
|
|
285
290
|
const documents = await admin.documents.list();
|
|
286
291
|
|
|
287
292
|
// Get document details
|
|
288
|
-
const document = await admin.documents.get(
|
|
293
|
+
const document = await admin.documents.get("doc-id");
|
|
289
294
|
|
|
290
295
|
// Bulk delete documents
|
|
291
|
-
await admin.documents.bulkDelete([
|
|
296
|
+
await admin.documents.bulkDelete(["doc-id-1", "doc-id-2"]);
|
|
292
297
|
|
|
293
298
|
// Bulk reprocess documents
|
|
294
|
-
await admin.documents.bulkReprocess([
|
|
299
|
+
await admin.documents.bulkReprocess(["doc-id-1", "doc-id-2"]);
|
|
295
300
|
```
|
|
296
301
|
|
|
297
302
|
### API Key Management
|
|
@@ -301,21 +306,22 @@ await admin.documents.bulkReprocess(['doc-id-1', 'doc-id-2']);
|
|
|
301
306
|
const keys = await admin.apiKeys.list();
|
|
302
307
|
|
|
303
308
|
// Get API key details
|
|
304
|
-
const key = await admin.apiKeys.get(
|
|
309
|
+
const key = await admin.apiKeys.get("key-id");
|
|
305
310
|
|
|
306
311
|
// Allocate credits to API key
|
|
307
|
-
await admin.apiKeys.allocate(
|
|
312
|
+
await admin.apiKeys.allocate("key-id", 5000, "Monthly allocation");
|
|
308
313
|
|
|
309
314
|
// Revoke API key
|
|
310
|
-
await admin.apiKeys.revoke(
|
|
315
|
+
await admin.apiKeys.revoke("key-id");
|
|
311
316
|
|
|
312
317
|
// Rotate API key
|
|
313
|
-
await admin.apiKeys.rotate(
|
|
318
|
+
await admin.apiKeys.rotate("key-id");
|
|
314
319
|
```
|
|
315
320
|
|
|
316
321
|
## Webhook Events
|
|
317
322
|
|
|
318
323
|
Available webhook events:
|
|
324
|
+
|
|
319
325
|
- `document.uploaded`
|
|
320
326
|
- `document.analyzed`
|
|
321
327
|
- `document.deleted`
|
|
@@ -328,13 +334,14 @@ Available webhook events:
|
|
|
328
334
|
## Bulk Operations
|
|
329
335
|
|
|
330
336
|
All bulk operations support:
|
|
337
|
+
|
|
331
338
|
- Minimum: 1 item
|
|
332
339
|
- Maximum: 100 items per request
|
|
333
340
|
- Validation via Zod schemas
|
|
334
341
|
|
|
335
342
|
```typescript
|
|
336
343
|
// Bulk delete up to 100 documents
|
|
337
|
-
const documentIds = [
|
|
344
|
+
const documentIds = ["doc-1", "doc-2", "doc-3"];
|
|
338
345
|
await admin.documents.bulkDelete(documentIds);
|
|
339
346
|
|
|
340
347
|
// Bulk reprocess documents
|
|
@@ -355,12 +362,12 @@ await admin.documents.bulkReprocess(documentIds);
|
|
|
355
362
|
|
|
356
363
|
```typescript
|
|
357
364
|
try {
|
|
358
|
-
await admin.accounts.credit(
|
|
365
|
+
await admin.accounts.credit("account-id", 1000);
|
|
359
366
|
} catch (error) {
|
|
360
367
|
if (error instanceof ZodError) {
|
|
361
|
-
console.error(
|
|
368
|
+
console.error("Validation error:", error.errors);
|
|
362
369
|
} else {
|
|
363
|
-
console.error(
|
|
370
|
+
console.error("API error:", error);
|
|
364
371
|
}
|
|
365
372
|
}
|
|
366
373
|
```
|
|
@@ -369,10 +376,10 @@ try {
|
|
|
369
376
|
|
|
370
377
|
```typescript
|
|
371
378
|
const admin = new GptAdmin({
|
|
372
|
-
baseUrl:
|
|
373
|
-
token:
|
|
374
|
-
applicationId:
|
|
375
|
-
apiKey:
|
|
379
|
+
baseUrl: "https://api.gpt-core.com", // API base URL
|
|
380
|
+
token: "admin-jwt-token", // Admin JWT token
|
|
381
|
+
applicationId: "app-id", // Application ID
|
|
382
|
+
apiKey: "api-key", // Optional: API key
|
|
376
383
|
});
|
|
377
384
|
```
|
|
378
385
|
|
|
@@ -387,8 +394,8 @@ import type {
|
|
|
387
394
|
Account,
|
|
388
395
|
Document,
|
|
389
396
|
ApiKey,
|
|
390
|
-
Bucket
|
|
391
|
-
} from
|
|
397
|
+
Bucket,
|
|
398
|
+
} from "@gpt-core/admin";
|
|
392
399
|
```
|
|
393
400
|
|
|
394
401
|
## Testing
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -873,7 +873,8 @@ function isSecureUrl(url) {
|
|
|
873
873
|
try {
|
|
874
874
|
const parsed = new URL(url);
|
|
875
875
|
if (parsed.protocol === "https:") return true;
|
|
876
|
-
if (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1")
|
|
876
|
+
if (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1")
|
|
877
|
+
return true;
|
|
877
878
|
return false;
|
|
878
879
|
} catch {
|
|
879
880
|
return false;
|
|
@@ -898,7 +899,10 @@ var BaseClient = class {
|
|
|
898
899
|
"[GPT Core SDK] Warning: Sending credentials over non-HTTPS connection."
|
|
899
900
|
);
|
|
900
901
|
}
|
|
901
|
-
req.headers.set(
|
|
902
|
+
req.headers.set(
|
|
903
|
+
"Accept",
|
|
904
|
+
`application/vnd.api+json; version=${this.apiVersion}`
|
|
905
|
+
);
|
|
902
906
|
req.headers.set("Content-Type", "application/vnd.api+json");
|
|
903
907
|
if (config.apiKey) {
|
|
904
908
|
req.headers.set("x-application-key", config.apiKey);
|
|
@@ -1226,7 +1230,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1226
1230
|
* Get storage statistics
|
|
1227
1231
|
*/
|
|
1228
1232
|
stats: async (workspaceId) => {
|
|
1229
|
-
const validated = StorageStatsRequestSchema.parse({
|
|
1233
|
+
const validated = StorageStatsRequestSchema.parse({
|
|
1234
|
+
workspace_id: workspaceId
|
|
1235
|
+
});
|
|
1230
1236
|
const { data } = await getAdminStorageStats({
|
|
1231
1237
|
headers: this.getHeaders(),
|
|
1232
1238
|
query: validated.workspace_id ? { filter: { workspace_id: validated.workspace_id } } : void 0
|
|
@@ -1316,7 +1322,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1316
1322
|
this.webhooks = {
|
|
1317
1323
|
configs: {
|
|
1318
1324
|
list: async () => {
|
|
1319
|
-
const { data } = await getAdminWebhookConfigs({
|
|
1325
|
+
const { data } = await getAdminWebhookConfigs({
|
|
1326
|
+
headers: this.getHeaders()
|
|
1327
|
+
});
|
|
1320
1328
|
return this.unwrap(data?.data);
|
|
1321
1329
|
},
|
|
1322
1330
|
create: async (name, url, events, applicationId, secret, enabled = true) => {
|
|
@@ -1376,7 +1384,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1376
1384
|
},
|
|
1377
1385
|
deliveries: {
|
|
1378
1386
|
list: async () => {
|
|
1379
|
-
const { data } = await getAdminWebhookDeliveries({
|
|
1387
|
+
const { data } = await getAdminWebhookDeliveries({
|
|
1388
|
+
headers: this.getHeaders()
|
|
1389
|
+
});
|
|
1380
1390
|
return this.unwrap(data?.data);
|
|
1381
1391
|
},
|
|
1382
1392
|
get: async (id) => {
|
|
@@ -1400,7 +1410,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1400
1410
|
*/
|
|
1401
1411
|
this.documents = {
|
|
1402
1412
|
list: async () => {
|
|
1403
|
-
const { data } = await getAdminExtractionDocuments({
|
|
1413
|
+
const { data } = await getAdminExtractionDocuments({
|
|
1414
|
+
headers: this.getHeaders()
|
|
1415
|
+
});
|
|
1404
1416
|
return this.unwrap(data?.data);
|
|
1405
1417
|
},
|
|
1406
1418
|
get: async (id) => {
|
|
@@ -1411,11 +1423,15 @@ var GptAdmin = class extends BaseClient {
|
|
|
1411
1423
|
return this.unwrap(data?.data);
|
|
1412
1424
|
},
|
|
1413
1425
|
stats: async () => {
|
|
1414
|
-
const { data } = await getAdminDocumentsStats({
|
|
1426
|
+
const { data } = await getAdminDocumentsStats({
|
|
1427
|
+
headers: this.getHeaders()
|
|
1428
|
+
});
|
|
1415
1429
|
return this.unwrap(data?.data);
|
|
1416
1430
|
},
|
|
1417
1431
|
bulkDelete: async (documentIds) => {
|
|
1418
|
-
const validated = DocumentBulkDeleteSchema.parse({
|
|
1432
|
+
const validated = DocumentBulkDeleteSchema.parse({
|
|
1433
|
+
document_ids: documentIds
|
|
1434
|
+
});
|
|
1419
1435
|
const { data } = await postAdminDocumentsBulkDelete({
|
|
1420
1436
|
headers: this.getHeaders(),
|
|
1421
1437
|
body: {
|
|
@@ -1573,7 +1589,9 @@ function handleApiError(error) {
|
|
|
1573
1589
|
const entries = hdrs instanceof Headers ? Array.from(hdrs.entries()) : Object.entries(hdrs);
|
|
1574
1590
|
const filtered = entries.filter(([key]) => {
|
|
1575
1591
|
const lowerKey = key.toLowerCase();
|
|
1576
|
-
return !sensitiveHeaderPatterns.some(
|
|
1592
|
+
return !sensitiveHeaderPatterns.some(
|
|
1593
|
+
(pattern) => lowerKey.includes(pattern)
|
|
1594
|
+
);
|
|
1577
1595
|
});
|
|
1578
1596
|
return filtered.length > 0 ? Object.fromEntries(filtered) : void 0;
|
|
1579
1597
|
};
|
|
@@ -1596,7 +1614,11 @@ function handleApiError(error) {
|
|
|
1596
1614
|
throw new ValidationError(message, errors, errorOptions);
|
|
1597
1615
|
case 429: {
|
|
1598
1616
|
const retryAfter = headers?.get?.("retry-after") || headers?.["retry-after"];
|
|
1599
|
-
throw new RateLimitError(
|
|
1617
|
+
throw new RateLimitError(
|
|
1618
|
+
message,
|
|
1619
|
+
retryAfter ? parseInt(retryAfter, 10) : void 0,
|
|
1620
|
+
errorOptions
|
|
1621
|
+
);
|
|
1600
1622
|
}
|
|
1601
1623
|
case 500:
|
|
1602
1624
|
case 502:
|
package/dist/index.mjs
CHANGED
|
@@ -824,7 +824,8 @@ function isSecureUrl(url) {
|
|
|
824
824
|
try {
|
|
825
825
|
const parsed = new URL(url);
|
|
826
826
|
if (parsed.protocol === "https:") return true;
|
|
827
|
-
if (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1")
|
|
827
|
+
if (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1")
|
|
828
|
+
return true;
|
|
828
829
|
return false;
|
|
829
830
|
} catch {
|
|
830
831
|
return false;
|
|
@@ -849,7 +850,10 @@ var BaseClient = class {
|
|
|
849
850
|
"[GPT Core SDK] Warning: Sending credentials over non-HTTPS connection."
|
|
850
851
|
);
|
|
851
852
|
}
|
|
852
|
-
req.headers.set(
|
|
853
|
+
req.headers.set(
|
|
854
|
+
"Accept",
|
|
855
|
+
`application/vnd.api+json; version=${this.apiVersion}`
|
|
856
|
+
);
|
|
853
857
|
req.headers.set("Content-Type", "application/vnd.api+json");
|
|
854
858
|
if (config.apiKey) {
|
|
855
859
|
req.headers.set("x-application-key", config.apiKey);
|
|
@@ -1177,7 +1181,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1177
1181
|
* Get storage statistics
|
|
1178
1182
|
*/
|
|
1179
1183
|
stats: async (workspaceId) => {
|
|
1180
|
-
const validated = StorageStatsRequestSchema.parse({
|
|
1184
|
+
const validated = StorageStatsRequestSchema.parse({
|
|
1185
|
+
workspace_id: workspaceId
|
|
1186
|
+
});
|
|
1181
1187
|
const { data } = await getAdminStorageStats({
|
|
1182
1188
|
headers: this.getHeaders(),
|
|
1183
1189
|
query: validated.workspace_id ? { filter: { workspace_id: validated.workspace_id } } : void 0
|
|
@@ -1267,7 +1273,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1267
1273
|
this.webhooks = {
|
|
1268
1274
|
configs: {
|
|
1269
1275
|
list: async () => {
|
|
1270
|
-
const { data } = await getAdminWebhookConfigs({
|
|
1276
|
+
const { data } = await getAdminWebhookConfigs({
|
|
1277
|
+
headers: this.getHeaders()
|
|
1278
|
+
});
|
|
1271
1279
|
return this.unwrap(data?.data);
|
|
1272
1280
|
},
|
|
1273
1281
|
create: async (name, url, events, applicationId, secret, enabled = true) => {
|
|
@@ -1327,7 +1335,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1327
1335
|
},
|
|
1328
1336
|
deliveries: {
|
|
1329
1337
|
list: async () => {
|
|
1330
|
-
const { data } = await getAdminWebhookDeliveries({
|
|
1338
|
+
const { data } = await getAdminWebhookDeliveries({
|
|
1339
|
+
headers: this.getHeaders()
|
|
1340
|
+
});
|
|
1331
1341
|
return this.unwrap(data?.data);
|
|
1332
1342
|
},
|
|
1333
1343
|
get: async (id) => {
|
|
@@ -1351,7 +1361,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1351
1361
|
*/
|
|
1352
1362
|
this.documents = {
|
|
1353
1363
|
list: async () => {
|
|
1354
|
-
const { data } = await getAdminExtractionDocuments({
|
|
1364
|
+
const { data } = await getAdminExtractionDocuments({
|
|
1365
|
+
headers: this.getHeaders()
|
|
1366
|
+
});
|
|
1355
1367
|
return this.unwrap(data?.data);
|
|
1356
1368
|
},
|
|
1357
1369
|
get: async (id) => {
|
|
@@ -1362,11 +1374,15 @@ var GptAdmin = class extends BaseClient {
|
|
|
1362
1374
|
return this.unwrap(data?.data);
|
|
1363
1375
|
},
|
|
1364
1376
|
stats: async () => {
|
|
1365
|
-
const { data } = await getAdminDocumentsStats({
|
|
1377
|
+
const { data } = await getAdminDocumentsStats({
|
|
1378
|
+
headers: this.getHeaders()
|
|
1379
|
+
});
|
|
1366
1380
|
return this.unwrap(data?.data);
|
|
1367
1381
|
},
|
|
1368
1382
|
bulkDelete: async (documentIds) => {
|
|
1369
|
-
const validated = DocumentBulkDeleteSchema.parse({
|
|
1383
|
+
const validated = DocumentBulkDeleteSchema.parse({
|
|
1384
|
+
document_ids: documentIds
|
|
1385
|
+
});
|
|
1370
1386
|
const { data } = await postAdminDocumentsBulkDelete({
|
|
1371
1387
|
headers: this.getHeaders(),
|
|
1372
1388
|
body: {
|
|
@@ -1524,7 +1540,9 @@ function handleApiError(error) {
|
|
|
1524
1540
|
const entries = hdrs instanceof Headers ? Array.from(hdrs.entries()) : Object.entries(hdrs);
|
|
1525
1541
|
const filtered = entries.filter(([key]) => {
|
|
1526
1542
|
const lowerKey = key.toLowerCase();
|
|
1527
|
-
return !sensitiveHeaderPatterns.some(
|
|
1543
|
+
return !sensitiveHeaderPatterns.some(
|
|
1544
|
+
(pattern) => lowerKey.includes(pattern)
|
|
1545
|
+
);
|
|
1528
1546
|
});
|
|
1529
1547
|
return filtered.length > 0 ? Object.fromEntries(filtered) : void 0;
|
|
1530
1548
|
};
|
|
@@ -1547,7 +1565,11 @@ function handleApiError(error) {
|
|
|
1547
1565
|
throw new ValidationError(message, errors, errorOptions);
|
|
1548
1566
|
case 429: {
|
|
1549
1567
|
const retryAfter = headers?.get?.("retry-after") || headers?.["retry-after"];
|
|
1550
|
-
throw new RateLimitError(
|
|
1568
|
+
throw new RateLimitError(
|
|
1569
|
+
message,
|
|
1570
|
+
retryAfter ? parseInt(retryAfter, 10) : void 0,
|
|
1571
|
+
errorOptions
|
|
1572
|
+
);
|
|
1551
1573
|
}
|
|
1552
1574
|
case 500:
|
|
1553
1575
|
case 502:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gpt-core/admin",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.21",
|
|
4
4
|
"description": "TypeScript SDK for GPT Core Admin API - Platform administration and ISV management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -45,12 +45,21 @@
|
|
|
45
45
|
"license": "MIT",
|
|
46
46
|
"repository": {
|
|
47
47
|
"type": "git",
|
|
48
|
-
"url": "https://github.com/GPT-Integrators/gpt-core
|
|
49
|
-
"directory": "ts/packages/admin"
|
|
48
|
+
"url": "git+https://github.com/GPT-Integrators/gpt-core.git",
|
|
49
|
+
"directory": "sdks/ts/packages/admin"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"generate": "bunx openapi-ts",
|
|
56
|
+
"typecheck": "bunx tsc --noEmit",
|
|
57
|
+
"build": "bun run typecheck && bunx tsup src/index.ts --format cjs,esm --dts",
|
|
58
|
+
"test": "bunx vitest run",
|
|
59
|
+
"test:watch": "bunx vitest",
|
|
60
|
+
"test:ui": "bunx vitest --ui",
|
|
61
|
+
"test:coverage": "bunx vitest run --coverage"
|
|
62
|
+
},
|
|
54
63
|
"dependencies": {
|
|
55
64
|
"zod": "^3.25.76"
|
|
56
65
|
},
|
|
@@ -62,14 +71,5 @@
|
|
|
62
71
|
"tsup": "^8.5.1",
|
|
63
72
|
"typescript": "^5.9.3",
|
|
64
73
|
"vitest": "^4.0.15"
|
|
65
|
-
},
|
|
66
|
-
"scripts": {
|
|
67
|
-
"generate": "bunx openapi-ts",
|
|
68
|
-
"typecheck": "bunx tsc --noEmit",
|
|
69
|
-
"build": "bun run typecheck && bunx tsup src/index.ts --format cjs,esm --dts",
|
|
70
|
-
"test": "bunx vitest run",
|
|
71
|
-
"test:watch": "bunx vitest",
|
|
72
|
-
"test:ui": "bunx vitest --ui",
|
|
73
|
-
"test:coverage": "bunx vitest run --coverage"
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
}
|