@gpt-core/admin 0.3.2 → 0.3.5

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.js CHANGED
@@ -122,6 +122,7 @@ var createSseClient = ({
122
122
  const { done, value } = await reader.read();
123
123
  if (done) break;
124
124
  buffer += value;
125
+ buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
125
126
  const chunks = buffer.split("\n\n");
126
127
  buffer = chunks.pop() ?? "";
127
128
  for (const chunk of chunks) {
@@ -897,8 +898,9 @@ var BaseClient = class {
897
898
  }
898
899
  unwrap(resource) {
899
900
  if (!resource) return null;
900
- if (resource.data && !resource.id && !resource.type) {
901
- return resource.data;
901
+ const obj = resource;
902
+ if (obj.data && !obj.id && !obj.type) {
903
+ return obj.data;
902
904
  }
903
905
  return resource;
904
906
  }
@@ -961,11 +963,6 @@ var patchAdminWebhookConfigsById = (options) => (options.client ?? client).patch
961
963
  ...options.headers
962
964
  }
963
965
  });
964
- var getAdminDocumentsById = (options) => (options.client ?? client).get({
965
- security: [{ scheme: "bearer", type: "http" }],
966
- url: "/admin/documents/{id}",
967
- ...options
968
- });
969
966
  var postAdminWebhookConfigsByIdTest = (options) => (options.client ?? client).post({
970
967
  security: [{ scheme: "bearer", type: "http" }],
971
968
  url: "/admin/webhook_configs/{id}/test",
@@ -984,6 +981,11 @@ var patchAdminAccountsByIdDebit = (options) => (options.client ?? client).patch(
984
981
  ...options.headers
985
982
  }
986
983
  });
984
+ var getAdminExtractionDocumentsById = (options) => (options.client ?? client).get({
985
+ security: [{ scheme: "bearer", type: "http" }],
986
+ url: "/admin/extraction/documents/{id}",
987
+ ...options
988
+ });
987
989
  var getAdminAccounts = (options) => (options.client ?? client).get({
988
990
  security: [{ scheme: "bearer", type: "http" }],
989
991
  url: "/admin/accounts",
@@ -1008,11 +1010,6 @@ var postAdminDocumentsBulkDelete = (options) => (options.client ?? client).post(
1008
1010
  ...options.headers
1009
1011
  }
1010
1012
  });
1011
- var getAdminDocuments = (options) => (options.client ?? client).get({
1012
- security: [{ scheme: "bearer", type: "http" }],
1013
- url: "/admin/documents",
1014
- ...options
1015
- });
1016
1013
  var patchAdminApiKeysByIdAllocate = (options) => (options.client ?? client).patch({
1017
1014
  security: [{ scheme: "bearer", type: "http" }],
1018
1015
  url: "/admin/api_keys/{id}/allocate",
@@ -1041,6 +1038,16 @@ var getAdminWebhookDeliveriesById = (options) => (options.client ?? client).get(
1041
1038
  url: "/admin/webhook_deliveries/{id}",
1042
1039
  ...options
1043
1040
  });
1041
+ var getAdminDocumentsStats = (options) => (options.client ?? client).get({
1042
+ security: [{ scheme: "bearer", type: "http" }],
1043
+ url: "/admin/documents/stats",
1044
+ ...options
1045
+ });
1046
+ var getAdminExtractionDocuments = (options) => (options.client ?? client).get({
1047
+ security: [{ scheme: "bearer", type: "http" }],
1048
+ url: "/admin/extraction/documents",
1049
+ ...options
1050
+ });
1044
1051
  var getAdminBucketsByIdObjects = (options) => (options.client ?? client).get({
1045
1052
  security: [{ scheme: "bearer", type: "http" }],
1046
1053
  url: "/admin/buckets/{id}/objects",
@@ -1056,15 +1063,6 @@ var getAdminApiKeysById = (options) => (options.client ?? client).get({
1056
1063
  url: "/admin/api_keys/{id}",
1057
1064
  ...options
1058
1065
  });
1059
- var postAdminDocumentsBulkReprocess = (options) => (options.client ?? client).post({
1060
- security: [{ scheme: "bearer", type: "http" }],
1061
- url: "/admin/documents/bulk_reprocess",
1062
- ...options,
1063
- headers: {
1064
- "Content-Type": "application/vnd.api+json",
1065
- ...options.headers
1066
- }
1067
- });
1068
1066
  var getAdminBuckets = (options) => (options.client ?? client).get({
1069
1067
  security: [{ scheme: "bearer", type: "http" }],
1070
1068
  url: "/admin/buckets",
@@ -1320,16 +1318,20 @@ var GptAdmin = class extends BaseClient {
1320
1318
  */
1321
1319
  this.documents = {
1322
1320
  list: async () => {
1323
- const { data } = await getAdminDocuments({ headers: this.getHeaders() });
1321
+ const { data } = await getAdminExtractionDocuments({ headers: this.getHeaders() });
1324
1322
  return this.unwrap(data?.data);
1325
1323
  },
1326
1324
  get: async (id) => {
1327
- const { data } = await getAdminDocumentsById({
1325
+ const { data } = await getAdminExtractionDocumentsById({
1328
1326
  headers: this.getHeaders(),
1329
1327
  path: { id }
1330
1328
  });
1331
1329
  return this.unwrap(data?.data);
1332
1330
  },
1331
+ stats: async () => {
1332
+ const { data } = await getAdminDocumentsStats({ headers: this.getHeaders() });
1333
+ return this.unwrap(data?.data);
1334
+ },
1333
1335
  bulkDelete: async (documentIds) => {
1334
1336
  const validated = DocumentBulkDeleteSchema.parse({ document_ids: documentIds });
1335
1337
  const { data } = await postAdminDocumentsBulkDelete({
@@ -1344,18 +1346,6 @@ var GptAdmin = class extends BaseClient {
1344
1346
  }
1345
1347
  });
1346
1348
  return this.unwrap(data?.data);
1347
- },
1348
- bulkReprocess: async (documentIds) => {
1349
- const validated = DocumentBulkReprocessSchema.parse({ document_ids: documentIds });
1350
- const { data } = await postAdminDocumentsBulkReprocess({
1351
- headers: this.getHeaders(),
1352
- body: {
1353
- data: {
1354
- ids: validated.document_ids
1355
- }
1356
- }
1357
- });
1358
- return this.unwrap(data?.data);
1359
1349
  }
1360
1350
  };
1361
1351
  /**
package/dist/index.mjs CHANGED
@@ -75,6 +75,7 @@ var createSseClient = ({
75
75
  const { done, value } = await reader.read();
76
76
  if (done) break;
77
77
  buffer += value;
78
+ buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
78
79
  const chunks = buffer.split("\n\n");
79
80
  buffer = chunks.pop() ?? "";
80
81
  for (const chunk of chunks) {
@@ -850,8 +851,9 @@ var BaseClient = class {
850
851
  }
851
852
  unwrap(resource) {
852
853
  if (!resource) return null;
853
- if (resource.data && !resource.id && !resource.type) {
854
- return resource.data;
854
+ const obj = resource;
855
+ if (obj.data && !obj.id && !obj.type) {
856
+ return obj.data;
855
857
  }
856
858
  return resource;
857
859
  }
@@ -914,11 +916,6 @@ var patchAdminWebhookConfigsById = (options) => (options.client ?? client).patch
914
916
  ...options.headers
915
917
  }
916
918
  });
917
- var getAdminDocumentsById = (options) => (options.client ?? client).get({
918
- security: [{ scheme: "bearer", type: "http" }],
919
- url: "/admin/documents/{id}",
920
- ...options
921
- });
922
919
  var postAdminWebhookConfigsByIdTest = (options) => (options.client ?? client).post({
923
920
  security: [{ scheme: "bearer", type: "http" }],
924
921
  url: "/admin/webhook_configs/{id}/test",
@@ -937,6 +934,11 @@ var patchAdminAccountsByIdDebit = (options) => (options.client ?? client).patch(
937
934
  ...options.headers
938
935
  }
939
936
  });
937
+ var getAdminExtractionDocumentsById = (options) => (options.client ?? client).get({
938
+ security: [{ scheme: "bearer", type: "http" }],
939
+ url: "/admin/extraction/documents/{id}",
940
+ ...options
941
+ });
940
942
  var getAdminAccounts = (options) => (options.client ?? client).get({
941
943
  security: [{ scheme: "bearer", type: "http" }],
942
944
  url: "/admin/accounts",
@@ -961,11 +963,6 @@ var postAdminDocumentsBulkDelete = (options) => (options.client ?? client).post(
961
963
  ...options.headers
962
964
  }
963
965
  });
964
- var getAdminDocuments = (options) => (options.client ?? client).get({
965
- security: [{ scheme: "bearer", type: "http" }],
966
- url: "/admin/documents",
967
- ...options
968
- });
969
966
  var patchAdminApiKeysByIdAllocate = (options) => (options.client ?? client).patch({
970
967
  security: [{ scheme: "bearer", type: "http" }],
971
968
  url: "/admin/api_keys/{id}/allocate",
@@ -994,6 +991,16 @@ var getAdminWebhookDeliveriesById = (options) => (options.client ?? client).get(
994
991
  url: "/admin/webhook_deliveries/{id}",
995
992
  ...options
996
993
  });
994
+ var getAdminDocumentsStats = (options) => (options.client ?? client).get({
995
+ security: [{ scheme: "bearer", type: "http" }],
996
+ url: "/admin/documents/stats",
997
+ ...options
998
+ });
999
+ var getAdminExtractionDocuments = (options) => (options.client ?? client).get({
1000
+ security: [{ scheme: "bearer", type: "http" }],
1001
+ url: "/admin/extraction/documents",
1002
+ ...options
1003
+ });
997
1004
  var getAdminBucketsByIdObjects = (options) => (options.client ?? client).get({
998
1005
  security: [{ scheme: "bearer", type: "http" }],
999
1006
  url: "/admin/buckets/{id}/objects",
@@ -1009,15 +1016,6 @@ var getAdminApiKeysById = (options) => (options.client ?? client).get({
1009
1016
  url: "/admin/api_keys/{id}",
1010
1017
  ...options
1011
1018
  });
1012
- var postAdminDocumentsBulkReprocess = (options) => (options.client ?? client).post({
1013
- security: [{ scheme: "bearer", type: "http" }],
1014
- url: "/admin/documents/bulk_reprocess",
1015
- ...options,
1016
- headers: {
1017
- "Content-Type": "application/vnd.api+json",
1018
- ...options.headers
1019
- }
1020
- });
1021
1019
  var getAdminBuckets = (options) => (options.client ?? client).get({
1022
1020
  security: [{ scheme: "bearer", type: "http" }],
1023
1021
  url: "/admin/buckets",
@@ -1273,16 +1271,20 @@ var GptAdmin = class extends BaseClient {
1273
1271
  */
1274
1272
  this.documents = {
1275
1273
  list: async () => {
1276
- const { data } = await getAdminDocuments({ headers: this.getHeaders() });
1274
+ const { data } = await getAdminExtractionDocuments({ headers: this.getHeaders() });
1277
1275
  return this.unwrap(data?.data);
1278
1276
  },
1279
1277
  get: async (id) => {
1280
- const { data } = await getAdminDocumentsById({
1278
+ const { data } = await getAdminExtractionDocumentsById({
1281
1279
  headers: this.getHeaders(),
1282
1280
  path: { id }
1283
1281
  });
1284
1282
  return this.unwrap(data?.data);
1285
1283
  },
1284
+ stats: async () => {
1285
+ const { data } = await getAdminDocumentsStats({ headers: this.getHeaders() });
1286
+ return this.unwrap(data?.data);
1287
+ },
1286
1288
  bulkDelete: async (documentIds) => {
1287
1289
  const validated = DocumentBulkDeleteSchema.parse({ document_ids: documentIds });
1288
1290
  const { data } = await postAdminDocumentsBulkDelete({
@@ -1297,18 +1299,6 @@ var GptAdmin = class extends BaseClient {
1297
1299
  }
1298
1300
  });
1299
1301
  return this.unwrap(data?.data);
1300
- },
1301
- bulkReprocess: async (documentIds) => {
1302
- const validated = DocumentBulkReprocessSchema.parse({ document_ids: documentIds });
1303
- const { data } = await postAdminDocumentsBulkReprocess({
1304
- headers: this.getHeaders(),
1305
- body: {
1306
- data: {
1307
- ids: validated.document_ids
1308
- }
1309
- }
1310
- });
1311
- return this.unwrap(data?.data);
1312
1302
  }
1313
1303
  };
1314
1304
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpt-core/admin",
3
- "version": "0.3.2",
3
+ "version": "0.3.5",
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",
@@ -35,15 +35,15 @@
35
35
  "test:coverage": "vitest run --coverage"
36
36
  },
37
37
  "dependencies": {
38
- "zod": "^3.23.8"
38
+ "zod": "^3.24.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@hey-api/openapi-ts": "^0.88.1",
42
- "@vitest/coverage-v8": "^1.0.0",
43
- "@vitest/ui": "^1.0.0",
44
- "msw": "^2.0.0",
42
+ "@vitest/coverage-v8": "^4.0.15",
43
+ "@vitest/ui": "^4.0.15",
44
+ "msw": "^2.12.4",
45
45
  "tsup": "^8.5.1",
46
46
  "typescript": "^5.9.3",
47
- "vitest": "^1.0.0"
47
+ "vitest": "^4.0.15"
48
48
  }
49
49
  }