@gpt-core/admin 0.10.13 → 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 +165 -11
- package/dist/index.d.ts +165 -11
- package/dist/index.js +69 -9
- package/dist/index.mjs +69 -9
- package/llms.txt +1 -0
- package/package.json +10 -10
- package/dist/index.cjs +0 -1606
package/dist/index.js
CHANGED
|
@@ -869,15 +869,40 @@ var client = createClient(
|
|
|
869
869
|
|
|
870
870
|
// src/base-client.ts
|
|
871
871
|
var DEFAULT_API_VERSION = "2025-12-03";
|
|
872
|
+
function isSecureUrl(url) {
|
|
873
|
+
try {
|
|
874
|
+
const parsed = new URL(url);
|
|
875
|
+
if (parsed.protocol === "https:") return true;
|
|
876
|
+
if (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1")
|
|
877
|
+
return true;
|
|
878
|
+
return false;
|
|
879
|
+
} catch {
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
872
883
|
var BaseClient = class {
|
|
873
884
|
constructor(config = {}) {
|
|
874
885
|
this.config = config;
|
|
875
886
|
this.apiVersion = config.apiVersion ?? DEFAULT_API_VERSION;
|
|
887
|
+
if (config.baseUrl && !isSecureUrl(config.baseUrl)) {
|
|
888
|
+
console.warn(
|
|
889
|
+
"[GPT Core SDK] Warning: Using non-HTTPS URL. Credentials may be transmitted insecurely. Use HTTPS in production environments."
|
|
890
|
+
);
|
|
891
|
+
}
|
|
876
892
|
if (config.baseUrl) {
|
|
877
893
|
client.setConfig({ baseUrl: config.baseUrl });
|
|
878
894
|
}
|
|
879
895
|
client.interceptors.request.use((req) => {
|
|
880
|
-
req.
|
|
896
|
+
const requestUrl = req.url || config.baseUrl || "";
|
|
897
|
+
if ((config.apiKey || config.token) && !isSecureUrl(requestUrl)) {
|
|
898
|
+
console.warn(
|
|
899
|
+
"[GPT Core SDK] Warning: Sending credentials over non-HTTPS connection."
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
req.headers.set(
|
|
903
|
+
"Accept",
|
|
904
|
+
`application/vnd.api+json; version=${this.apiVersion}`
|
|
905
|
+
);
|
|
881
906
|
req.headers.set("Content-Type", "application/vnd.api+json");
|
|
882
907
|
if (config.apiKey) {
|
|
883
908
|
req.headers.set("x-application-key", config.apiKey);
|
|
@@ -1205,7 +1230,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1205
1230
|
* Get storage statistics
|
|
1206
1231
|
*/
|
|
1207
1232
|
stats: async (workspaceId) => {
|
|
1208
|
-
const validated = StorageStatsRequestSchema.parse({
|
|
1233
|
+
const validated = StorageStatsRequestSchema.parse({
|
|
1234
|
+
workspace_id: workspaceId
|
|
1235
|
+
});
|
|
1209
1236
|
const { data } = await getAdminStorageStats({
|
|
1210
1237
|
headers: this.getHeaders(),
|
|
1211
1238
|
query: validated.workspace_id ? { filter: { workspace_id: validated.workspace_id } } : void 0
|
|
@@ -1295,7 +1322,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1295
1322
|
this.webhooks = {
|
|
1296
1323
|
configs: {
|
|
1297
1324
|
list: async () => {
|
|
1298
|
-
const { data } = await getAdminWebhookConfigs({
|
|
1325
|
+
const { data } = await getAdminWebhookConfigs({
|
|
1326
|
+
headers: this.getHeaders()
|
|
1327
|
+
});
|
|
1299
1328
|
return this.unwrap(data?.data);
|
|
1300
1329
|
},
|
|
1301
1330
|
create: async (name, url, events, applicationId, secret, enabled = true) => {
|
|
@@ -1355,7 +1384,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1355
1384
|
},
|
|
1356
1385
|
deliveries: {
|
|
1357
1386
|
list: async () => {
|
|
1358
|
-
const { data } = await getAdminWebhookDeliveries({
|
|
1387
|
+
const { data } = await getAdminWebhookDeliveries({
|
|
1388
|
+
headers: this.getHeaders()
|
|
1389
|
+
});
|
|
1359
1390
|
return this.unwrap(data?.data);
|
|
1360
1391
|
},
|
|
1361
1392
|
get: async (id) => {
|
|
@@ -1379,7 +1410,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1379
1410
|
*/
|
|
1380
1411
|
this.documents = {
|
|
1381
1412
|
list: async () => {
|
|
1382
|
-
const { data } = await getAdminExtractionDocuments({
|
|
1413
|
+
const { data } = await getAdminExtractionDocuments({
|
|
1414
|
+
headers: this.getHeaders()
|
|
1415
|
+
});
|
|
1383
1416
|
return this.unwrap(data?.data);
|
|
1384
1417
|
},
|
|
1385
1418
|
get: async (id) => {
|
|
@@ -1390,11 +1423,15 @@ var GptAdmin = class extends BaseClient {
|
|
|
1390
1423
|
return this.unwrap(data?.data);
|
|
1391
1424
|
},
|
|
1392
1425
|
stats: async () => {
|
|
1393
|
-
const { data } = await getAdminDocumentsStats({
|
|
1426
|
+
const { data } = await getAdminDocumentsStats({
|
|
1427
|
+
headers: this.getHeaders()
|
|
1428
|
+
});
|
|
1394
1429
|
return this.unwrap(data?.data);
|
|
1395
1430
|
},
|
|
1396
1431
|
bulkDelete: async (documentIds) => {
|
|
1397
|
-
const validated = DocumentBulkDeleteSchema.parse({
|
|
1432
|
+
const validated = DocumentBulkDeleteSchema.parse({
|
|
1433
|
+
document_ids: documentIds
|
|
1434
|
+
});
|
|
1398
1435
|
const { data } = await postAdminDocumentsBulkDelete({
|
|
1399
1436
|
headers: this.getHeaders(),
|
|
1400
1437
|
body: {
|
|
@@ -1539,10 +1576,29 @@ function handleApiError(error) {
|
|
|
1539
1576
|
} else if (error?.message) {
|
|
1540
1577
|
message = error.message;
|
|
1541
1578
|
}
|
|
1579
|
+
const sensitiveHeaderPatterns = [
|
|
1580
|
+
"set-cookie",
|
|
1581
|
+
"authorization",
|
|
1582
|
+
"x-application-key",
|
|
1583
|
+
"cookie",
|
|
1584
|
+
"x-forwarded-for",
|
|
1585
|
+
"x-real-ip"
|
|
1586
|
+
];
|
|
1587
|
+
const filterSensitiveHeaders = (hdrs) => {
|
|
1588
|
+
if (!hdrs) return void 0;
|
|
1589
|
+
const entries = hdrs instanceof Headers ? Array.from(hdrs.entries()) : Object.entries(hdrs);
|
|
1590
|
+
const filtered = entries.filter(([key]) => {
|
|
1591
|
+
const lowerKey = key.toLowerCase();
|
|
1592
|
+
return !sensitiveHeaderPatterns.some(
|
|
1593
|
+
(pattern) => lowerKey.includes(pattern)
|
|
1594
|
+
);
|
|
1595
|
+
});
|
|
1596
|
+
return filtered.length > 0 ? Object.fromEntries(filtered) : void 0;
|
|
1597
|
+
};
|
|
1542
1598
|
const errorOptions = {
|
|
1543
1599
|
statusCode,
|
|
1544
1600
|
requestId,
|
|
1545
|
-
headers:
|
|
1601
|
+
headers: filterSensitiveHeaders(headers),
|
|
1546
1602
|
body,
|
|
1547
1603
|
cause: error
|
|
1548
1604
|
};
|
|
@@ -1558,7 +1614,11 @@ function handleApiError(error) {
|
|
|
1558
1614
|
throw new ValidationError(message, errors, errorOptions);
|
|
1559
1615
|
case 429: {
|
|
1560
1616
|
const retryAfter = headers?.get?.("retry-after") || headers?.["retry-after"];
|
|
1561
|
-
throw new RateLimitError(
|
|
1617
|
+
throw new RateLimitError(
|
|
1618
|
+
message,
|
|
1619
|
+
retryAfter ? parseInt(retryAfter, 10) : void 0,
|
|
1620
|
+
errorOptions
|
|
1621
|
+
);
|
|
1562
1622
|
}
|
|
1563
1623
|
case 500:
|
|
1564
1624
|
case 502:
|
package/dist/index.mjs
CHANGED
|
@@ -820,15 +820,40 @@ var client = createClient(
|
|
|
820
820
|
|
|
821
821
|
// src/base-client.ts
|
|
822
822
|
var DEFAULT_API_VERSION = "2025-12-03";
|
|
823
|
+
function isSecureUrl(url) {
|
|
824
|
+
try {
|
|
825
|
+
const parsed = new URL(url);
|
|
826
|
+
if (parsed.protocol === "https:") return true;
|
|
827
|
+
if (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1")
|
|
828
|
+
return true;
|
|
829
|
+
return false;
|
|
830
|
+
} catch {
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
823
834
|
var BaseClient = class {
|
|
824
835
|
constructor(config = {}) {
|
|
825
836
|
this.config = config;
|
|
826
837
|
this.apiVersion = config.apiVersion ?? DEFAULT_API_VERSION;
|
|
838
|
+
if (config.baseUrl && !isSecureUrl(config.baseUrl)) {
|
|
839
|
+
console.warn(
|
|
840
|
+
"[GPT Core SDK] Warning: Using non-HTTPS URL. Credentials may be transmitted insecurely. Use HTTPS in production environments."
|
|
841
|
+
);
|
|
842
|
+
}
|
|
827
843
|
if (config.baseUrl) {
|
|
828
844
|
client.setConfig({ baseUrl: config.baseUrl });
|
|
829
845
|
}
|
|
830
846
|
client.interceptors.request.use((req) => {
|
|
831
|
-
req.
|
|
847
|
+
const requestUrl = req.url || config.baseUrl || "";
|
|
848
|
+
if ((config.apiKey || config.token) && !isSecureUrl(requestUrl)) {
|
|
849
|
+
console.warn(
|
|
850
|
+
"[GPT Core SDK] Warning: Sending credentials over non-HTTPS connection."
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
req.headers.set(
|
|
854
|
+
"Accept",
|
|
855
|
+
`application/vnd.api+json; version=${this.apiVersion}`
|
|
856
|
+
);
|
|
832
857
|
req.headers.set("Content-Type", "application/vnd.api+json");
|
|
833
858
|
if (config.apiKey) {
|
|
834
859
|
req.headers.set("x-application-key", config.apiKey);
|
|
@@ -1156,7 +1181,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1156
1181
|
* Get storage statistics
|
|
1157
1182
|
*/
|
|
1158
1183
|
stats: async (workspaceId) => {
|
|
1159
|
-
const validated = StorageStatsRequestSchema.parse({
|
|
1184
|
+
const validated = StorageStatsRequestSchema.parse({
|
|
1185
|
+
workspace_id: workspaceId
|
|
1186
|
+
});
|
|
1160
1187
|
const { data } = await getAdminStorageStats({
|
|
1161
1188
|
headers: this.getHeaders(),
|
|
1162
1189
|
query: validated.workspace_id ? { filter: { workspace_id: validated.workspace_id } } : void 0
|
|
@@ -1246,7 +1273,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1246
1273
|
this.webhooks = {
|
|
1247
1274
|
configs: {
|
|
1248
1275
|
list: async () => {
|
|
1249
|
-
const { data } = await getAdminWebhookConfigs({
|
|
1276
|
+
const { data } = await getAdminWebhookConfigs({
|
|
1277
|
+
headers: this.getHeaders()
|
|
1278
|
+
});
|
|
1250
1279
|
return this.unwrap(data?.data);
|
|
1251
1280
|
},
|
|
1252
1281
|
create: async (name, url, events, applicationId, secret, enabled = true) => {
|
|
@@ -1306,7 +1335,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1306
1335
|
},
|
|
1307
1336
|
deliveries: {
|
|
1308
1337
|
list: async () => {
|
|
1309
|
-
const { data } = await getAdminWebhookDeliveries({
|
|
1338
|
+
const { data } = await getAdminWebhookDeliveries({
|
|
1339
|
+
headers: this.getHeaders()
|
|
1340
|
+
});
|
|
1310
1341
|
return this.unwrap(data?.data);
|
|
1311
1342
|
},
|
|
1312
1343
|
get: async (id) => {
|
|
@@ -1330,7 +1361,9 @@ var GptAdmin = class extends BaseClient {
|
|
|
1330
1361
|
*/
|
|
1331
1362
|
this.documents = {
|
|
1332
1363
|
list: async () => {
|
|
1333
|
-
const { data } = await getAdminExtractionDocuments({
|
|
1364
|
+
const { data } = await getAdminExtractionDocuments({
|
|
1365
|
+
headers: this.getHeaders()
|
|
1366
|
+
});
|
|
1334
1367
|
return this.unwrap(data?.data);
|
|
1335
1368
|
},
|
|
1336
1369
|
get: async (id) => {
|
|
@@ -1341,11 +1374,15 @@ var GptAdmin = class extends BaseClient {
|
|
|
1341
1374
|
return this.unwrap(data?.data);
|
|
1342
1375
|
},
|
|
1343
1376
|
stats: async () => {
|
|
1344
|
-
const { data } = await getAdminDocumentsStats({
|
|
1377
|
+
const { data } = await getAdminDocumentsStats({
|
|
1378
|
+
headers: this.getHeaders()
|
|
1379
|
+
});
|
|
1345
1380
|
return this.unwrap(data?.data);
|
|
1346
1381
|
},
|
|
1347
1382
|
bulkDelete: async (documentIds) => {
|
|
1348
|
-
const validated = DocumentBulkDeleteSchema.parse({
|
|
1383
|
+
const validated = DocumentBulkDeleteSchema.parse({
|
|
1384
|
+
document_ids: documentIds
|
|
1385
|
+
});
|
|
1349
1386
|
const { data } = await postAdminDocumentsBulkDelete({
|
|
1350
1387
|
headers: this.getHeaders(),
|
|
1351
1388
|
body: {
|
|
@@ -1490,10 +1527,29 @@ function handleApiError(error) {
|
|
|
1490
1527
|
} else if (error?.message) {
|
|
1491
1528
|
message = error.message;
|
|
1492
1529
|
}
|
|
1530
|
+
const sensitiveHeaderPatterns = [
|
|
1531
|
+
"set-cookie",
|
|
1532
|
+
"authorization",
|
|
1533
|
+
"x-application-key",
|
|
1534
|
+
"cookie",
|
|
1535
|
+
"x-forwarded-for",
|
|
1536
|
+
"x-real-ip"
|
|
1537
|
+
];
|
|
1538
|
+
const filterSensitiveHeaders = (hdrs) => {
|
|
1539
|
+
if (!hdrs) return void 0;
|
|
1540
|
+
const entries = hdrs instanceof Headers ? Array.from(hdrs.entries()) : Object.entries(hdrs);
|
|
1541
|
+
const filtered = entries.filter(([key]) => {
|
|
1542
|
+
const lowerKey = key.toLowerCase();
|
|
1543
|
+
return !sensitiveHeaderPatterns.some(
|
|
1544
|
+
(pattern) => lowerKey.includes(pattern)
|
|
1545
|
+
);
|
|
1546
|
+
});
|
|
1547
|
+
return filtered.length > 0 ? Object.fromEntries(filtered) : void 0;
|
|
1548
|
+
};
|
|
1493
1549
|
const errorOptions = {
|
|
1494
1550
|
statusCode,
|
|
1495
1551
|
requestId,
|
|
1496
|
-
headers:
|
|
1552
|
+
headers: filterSensitiveHeaders(headers),
|
|
1497
1553
|
body,
|
|
1498
1554
|
cause: error
|
|
1499
1555
|
};
|
|
@@ -1509,7 +1565,11 @@ function handleApiError(error) {
|
|
|
1509
1565
|
throw new ValidationError(message, errors, errorOptions);
|
|
1510
1566
|
case 429: {
|
|
1511
1567
|
const retryAfter = headers?.get?.("retry-after") || headers?.["retry-after"];
|
|
1512
|
-
throw new RateLimitError(
|
|
1568
|
+
throw new RateLimitError(
|
|
1569
|
+
message,
|
|
1570
|
+
retryAfter ? parseInt(retryAfter, 10) : void 0,
|
|
1571
|
+
errorOptions
|
|
1572
|
+
);
|
|
1513
1573
|
}
|
|
1514
1574
|
case 500:
|
|
1515
1575
|
case 502:
|
package/llms.txt
CHANGED
|
@@ -304,6 +304,7 @@ client.setConfig({
|
|
|
304
304
|
- `getExtractionResults()` - List results
|
|
305
305
|
- `getExtractionResultsById()` - Get results
|
|
306
306
|
- `getExtractionResultsDocumentByDocumentId()` - Get document
|
|
307
|
+
- `getExtractionResultsDocumentByDocumentIdHistory()` - Get history
|
|
307
308
|
- `getExtractionResultsWorkspaceByWorkspaceId()` - Get workspace
|
|
308
309
|
- `patchExtractionResultsById()` - Update results
|
|
309
310
|
- `patchExtractionResultsByIdRegenerate()` - Update regenerate
|
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,20 +45,20 @@
|
|
|
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
54
|
"scripts": {
|
|
55
|
-
"generate": "openapi-ts",
|
|
56
|
-
"typecheck": "tsc --noEmit",
|
|
57
|
-
"build": "
|
|
58
|
-
"test": "vitest run",
|
|
59
|
-
"test:watch": "vitest",
|
|
60
|
-
"test:ui": "vitest --ui",
|
|
61
|
-
"test:coverage": "vitest run --coverage"
|
|
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
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"zod": "^3.25.76"
|