@gpt-platform/client 0.10.3 → 0.10.4

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.mjs CHANGED
@@ -1272,7 +1272,7 @@ function buildUserAgent(sdkVersion, appInfo) {
1272
1272
  }
1273
1273
 
1274
1274
  // src/version.ts
1275
- var SDK_VERSION = "0.10.3";
1275
+ var SDK_VERSION = "0.10.4";
1276
1276
  var DEFAULT_API_VERSION = "2026-03-23";
1277
1277
 
1278
1278
  // src/base-client.ts
@@ -2393,6 +2393,11 @@ var getExtractionBatchesWorkspaceByWorkspaceId = (options) => (options.client ??
2393
2393
  url: "/extraction/batches/workspace/{workspace_id}",
2394
2394
  ...options
2395
2395
  });
2396
+ var getExtractionAgents = (options) => (options.client ?? client).get({
2397
+ security: [{ scheme: "bearer", type: "http" }],
2398
+ url: "/extraction/agents",
2399
+ ...options
2400
+ });
2396
2401
  var deleteClinicalPracticeResourcesByIdPermanent = (options) => (options.client ?? client).delete({
2397
2402
  security: [{ scheme: "bearer", type: "http" }],
2398
2403
  url: "/clinical/practice-resources/{id}/permanent",
@@ -2584,6 +2589,15 @@ var patchInvitationsByIdRevoke = (options) => (options.client ?? client).patch({
2584
2589
  ...options.headers
2585
2590
  }
2586
2591
  });
2592
+ var postExtractionAgentsPredict = (options) => (options.client ?? client).post({
2593
+ security: [{ scheme: "bearer", type: "http" }],
2594
+ url: "/extraction/agents/predict",
2595
+ ...options,
2596
+ headers: {
2597
+ "Content-Type": "application/vnd.api+json",
2598
+ ...options.headers
2599
+ }
2600
+ });
2587
2601
  var getCatalogTaxonomiesApplicationByApplicationId = (options) => (options.client ?? client).get({
2588
2602
  security: [{ scheme: "bearer", type: "http" }],
2589
2603
  url: "/catalog/taxonomies/application/{application_id}",
@@ -3189,6 +3203,11 @@ var patchStorageFilesByIdRestore = (options) => (options.client ?? client).patch
3189
3203
  ...options.headers
3190
3204
  }
3191
3205
  });
3206
+ var getWorkspacesByWorkspaceIdTrainingAnalytics = (options) => (options.client ?? client).get({
3207
+ security: [{ scheme: "bearer", type: "http" }],
3208
+ url: "/workspaces/{workspace_id}/training/analytics",
3209
+ ...options
3210
+ });
3192
3211
  var patchSocialCampaignsByIdCancel = (options) => (options.client ?? client).patch({
3193
3212
  security: [{ scheme: "bearer", type: "http" }],
3194
3213
  url: "/social/campaigns/{id}/cancel",
@@ -6954,6 +6973,15 @@ var postUsersAuthResendConfirmation = (options) => (options.client ?? client).po
6954
6973
  ...options.headers
6955
6974
  }
6956
6975
  });
6976
+ var postSocialCampaignsByIdPreviewAdaptations = (options) => (options.client ?? client).post({
6977
+ security: [{ scheme: "bearer", type: "http" }],
6978
+ url: "/social/campaigns/{id}/preview-adaptations",
6979
+ ...options,
6980
+ headers: {
6981
+ "Content-Type": "application/vnd.api+json",
6982
+ ...options.headers
6983
+ }
6984
+ });
6957
6985
  var getCrawlerResultsById = (options) => (options.client ?? client).get({
6958
6986
  security: [{ scheme: "bearer", type: "http" }],
6959
6987
  url: "/crawler/results/{id}",
@@ -7337,6 +7365,11 @@ var postExtractionDocumentsBulkReprocess = (options) => (options.client ?? clien
7337
7365
  ...options.headers
7338
7366
  }
7339
7367
  });
7368
+ var getExtractionAgentsById = (options) => (options.client ?? client).get({
7369
+ security: [{ scheme: "bearer", type: "http" }],
7370
+ url: "/extraction/agents/{id}",
7371
+ ...options
7372
+ });
7340
7373
  var getApplicationsBySlugBySlug = (options) => (options.client ?? client).get({
7341
7374
  security: [{ scheme: "bearer", type: "http" }],
7342
7375
  url: "/applications/by-slug/{slug}",
@@ -25418,6 +25451,94 @@ function createExtractionNamespace(rb) {
25418
25451
  options
25419
25452
  );
25420
25453
  }
25454
+ },
25455
+ /** Extraction agents — list and predict best extraction agents for documents. */
25456
+ extractionAgents: {
25457
+ /**
25458
+ * Lists all available extraction agents (system agents tagged with
25459
+ * "extraction" category).
25460
+ *
25461
+ * @param options - Optional request options (abort signal, custom headers).
25462
+ * @returns An array of extraction agent objects.
25463
+ *
25464
+ * @example
25465
+ * ```typescript
25466
+ * const agents = await client.extraction.extractionAgents.list();
25467
+ * ```
25468
+ */
25469
+ list: async (options) => {
25470
+ return rb.execute(getExtractionAgents, {}, options);
25471
+ },
25472
+ /**
25473
+ * Retrieves a single extraction agent by its unique identifier.
25474
+ *
25475
+ * @param id - The UUID of the extraction agent.
25476
+ * @param options - Optional request options (abort signal, custom headers).
25477
+ * @returns The matching extraction agent object.
25478
+ *
25479
+ * @example
25480
+ * ```typescript
25481
+ * const agent = await client.extraction.extractionAgents.get('agent-uuid');
25482
+ * ```
25483
+ */
25484
+ get: async (id, options) => {
25485
+ return rb.execute(
25486
+ getExtractionAgentsById,
25487
+ { path: { id } },
25488
+ options
25489
+ );
25490
+ },
25491
+ /**
25492
+ * Predicts the best extraction agent for a given document based on its
25493
+ * name, description, or file content.
25494
+ *
25495
+ * @param attributes - Prediction input (name, description, file_content, document_id).
25496
+ * @param options - Optional request options (abort signal, custom headers).
25497
+ * @returns A prediction result with recommended agents.
25498
+ *
25499
+ * @example
25500
+ * ```typescript
25501
+ * const prediction = await client.extraction.extractionAgents.predict({
25502
+ * name: 'invoice.pdf',
25503
+ * file_content: 'Invoice #12345...',
25504
+ * });
25505
+ * ```
25506
+ */
25507
+ predict: async (attributes, options) => {
25508
+ return rb.execute(
25509
+ postExtractionAgentsPredict,
25510
+ {
25511
+ body: {
25512
+ data: { type: "extraction-agent", attributes }
25513
+ }
25514
+ },
25515
+ options
25516
+ );
25517
+ }
25518
+ },
25519
+ /** Training analytics — workspace-level extraction training metrics. */
25520
+ trainingAnalytics: {
25521
+ /**
25522
+ * Retrieves training analytics for a specific workspace, including
25523
+ * accuracy trends, correction counts, and low-confidence documents.
25524
+ *
25525
+ * @param workspaceId - The UUID of the workspace.
25526
+ * @param options - Optional request options (abort signal, custom headers).
25527
+ * @returns The training analytics object for the workspace.
25528
+ *
25529
+ * @example
25530
+ * ```typescript
25531
+ * const analytics = await client.extraction.trainingAnalytics.forWorkspace('ws-uuid');
25532
+ * console.log(analytics.avg_confidence, analytics.total_examples);
25533
+ * ```
25534
+ */
25535
+ forWorkspace: async (workspaceId, options) => {
25536
+ return rb.execute(
25537
+ getWorkspacesByWorkspaceIdTrainingAnalytics,
25538
+ { path: { workspace_id: workspaceId } },
25539
+ options
25540
+ );
25541
+ }
25421
25542
  }
25422
25543
  };
25423
25544
  }
@@ -29995,11 +30116,108 @@ function createStorageNamespace(rb) {
29995
30116
  { query: { parent_id: parentId } },
29996
30117
  options
29997
30118
  );
30119
+ },
30120
+ /**
30121
+ * Generate a short-lived presigned download URL for a file.
30122
+ *
30123
+ * Returns a URL that can be used to download the file directly from
30124
+ * object storage (GCS in production, MinIO in dev) without routing
30125
+ * through the application server.
30126
+ *
30127
+ * @param id - The UUID of the file to download.
30128
+ * @param params - Optional parameters (e.g., custom `expires_in` seconds).
30129
+ * @param options - Optional request options (abort signal, custom headers).
30130
+ * @returns A promise resolving to the presigned URL and its expiry.
30131
+ *
30132
+ * @example
30133
+ * ```typescript
30134
+ * const { url, expires_at } = await client.storage.files.requestDownloadUrl(
30135
+ * 'file-uuid',
30136
+ * { expires_in: 300 }, // 5 minutes
30137
+ * );
30138
+ * // Redirect browser to `url` for direct download
30139
+ * ```
30140
+ */
30141
+ requestDownloadUrl: async (id, params, options) => {
30142
+ return rb.rawPostDirect(
30143
+ `/storage-files/${id}/download-url`,
30144
+ params?.expires_in != null ? { data: { expires_in: params.expires_in } } : void 0,
30145
+ options
30146
+ );
29998
30147
  }
29999
30148
  }
30000
30149
  };
30001
30150
  }
30002
30151
 
30152
+ // src/namespaces/documents.ts
30153
+ function createDocumentsNamespace(rb) {
30154
+ return {
30155
+ /**
30156
+ * Generate a PDF from HTML content and store it in platform Storage.
30157
+ *
30158
+ * Always pass `store: true` and `workspace_id` to get a JSON response with
30159
+ * a `storage_key`. Without `store: true`, the server returns raw
30160
+ * `application/pdf` binary which cannot be parsed as JSON by this SDK method.
30161
+ *
30162
+ * HTML input is capped at 2MB by the server.
30163
+ *
30164
+ * @param params - PDF generation parameters. Set `store: true` and provide
30165
+ * `workspace_id` for JSON response.
30166
+ * @param options - Optional request options (abort signal, custom headers).
30167
+ * @returns A storage key reference for the generated PDF.
30168
+ *
30169
+ * @example
30170
+ * ```typescript
30171
+ * const { storage_key } = await client.documents.generatePdf({
30172
+ * html: '<html><body>Report</body></html>',
30173
+ * store: true,
30174
+ * workspace_id: 'ws-123',
30175
+ * });
30176
+ * ```
30177
+ */
30178
+ generatePdf: async (params, options) => {
30179
+ return rb.rawPostDirect(
30180
+ "/documents/pdf",
30181
+ params,
30182
+ options
30183
+ );
30184
+ },
30185
+ /**
30186
+ * Generate a PDF from HTML and email it as an attachment.
30187
+ *
30188
+ * The PDF is generated server-side and delivered via platform SMTP.
30189
+ * Optionally stores the PDF in platform Storage alongside the email delivery.
30190
+ *
30191
+ * If storage fails but the email succeeds, the response includes
30192
+ * `storage_error` with the failure reason (email is still delivered).
30193
+ *
30194
+ * @param params - Email report parameters.
30195
+ * @param options - Optional request options (abort signal, custom headers).
30196
+ * @returns Delivery status, optional storage key, and any storage error.
30197
+ *
30198
+ * @example
30199
+ * ```typescript
30200
+ * const result = await client.documents.emailReport({
30201
+ * html: '<html><body><h1>Q1 Summary</h1></body></html>',
30202
+ * to: 'finance@company.com',
30203
+ * subject: 'Q1 Financial Summary',
30204
+ * store: true,
30205
+ * workspace_id: 'ws-123',
30206
+ * });
30207
+ * console.log(result.sent); // true
30208
+ * console.log(result.storage_key); // 'ws-123/documents/...'
30209
+ * ```
30210
+ */
30211
+ emailReport: async (params, options) => {
30212
+ return rb.rawPostDirect(
30213
+ "/documents/pdf/email",
30214
+ params,
30215
+ options
30216
+ );
30217
+ }
30218
+ };
30219
+ }
30220
+
30003
30221
  // src/namespaces/threads.ts
30004
30222
  function getBrowserContext() {
30005
30223
  const ctx = {};
@@ -33219,6 +33437,32 @@ function createSocialNamespace(rb) {
33219
33437
  },
33220
33438
  options
33221
33439
  );
33440
+ },
33441
+ /**
33442
+ * Preview adapted copy per platform without creating SocialPost records.
33443
+ *
33444
+ * Returns the AI-adapted text for each target platform so the user can
33445
+ * review before committing via `adaptForPlatforms`.
33446
+ *
33447
+ * @param id - Campaign UUID.
33448
+ * @param workspaceId - Workspace UUID.
33449
+ * @param options - Optional request options.
33450
+ * @returns `{ adaptations: [{ platform: string, content: string }] }`
33451
+ */
33452
+ previewAdaptations: async (id, workspaceId, options) => {
33453
+ return rb.execute(
33454
+ postSocialCampaignsByIdPreviewAdaptations,
33455
+ {
33456
+ path: { id },
33457
+ body: {
33458
+ data: {
33459
+ campaign_id: id,
33460
+ workspace_id: workspaceId
33461
+ }
33462
+ }
33463
+ },
33464
+ options
33465
+ );
33222
33466
  }
33223
33467
  },
33224
33468
  /** Trending content discovery — snapshots, items, and watch alerts. */
@@ -34320,6 +34564,31 @@ var RequestBuilder = class {
34320
34564
  throw handleApiError(error);
34321
34565
  }
34322
34566
  }
34567
+ /**
34568
+ * Execute a raw POST to a custom endpoint that returns flat JSON (no data wrapper).
34569
+ * Unlike rawPost (which unwraps data.data), this returns the response body directly.
34570
+ * Used for hand-written Phoenix controllers like DocumentsController.
34571
+ */
34572
+ async rawPostDirect(url, body, options) {
34573
+ const headers = buildHeaders(this.getHeaders, options);
34574
+ try {
34575
+ const result = await this.requestWithRetry(
34576
+ () => this.clientInstance.post({
34577
+ url,
34578
+ headers,
34579
+ ...body !== void 0 && { body },
34580
+ ...options?.signal && { signal: options.signal }
34581
+ })
34582
+ );
34583
+ const { data, error } = result;
34584
+ if (error) {
34585
+ throw handleApiError(enrichError(error, result));
34586
+ }
34587
+ return data;
34588
+ } catch (error) {
34589
+ throw handleApiError(error);
34590
+ }
34591
+ }
34323
34592
  /**
34324
34593
  * Execute a raw PUT request to a custom (non-generated) endpoint.
34325
34594
  */
@@ -34539,6 +34808,7 @@ var GptClient = class extends BaseClient {
34539
34808
  this.campaigns = createCampaignsNamespace(rb);
34540
34809
  this.email = createEmailNamespace(rb);
34541
34810
  this.support = createSupportNamespace(rb);
34811
+ this.documents = createDocumentsNamespace(rb);
34542
34812
  this.extraction = createExtractionNamespace(rb);
34543
34813
  this.identity = createIdentityNamespace(rb, this.config?.baseUrl);
34544
34814
  this.portal = createPortalNamespace(rb);