@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.js CHANGED
@@ -1339,7 +1339,7 @@ function buildUserAgent(sdkVersion, appInfo) {
1339
1339
  }
1340
1340
 
1341
1341
  // src/version.ts
1342
- var SDK_VERSION = "0.10.3";
1342
+ var SDK_VERSION = "0.10.4";
1343
1343
  var DEFAULT_API_VERSION = "2026-03-23";
1344
1344
 
1345
1345
  // src/base-client.ts
@@ -2460,6 +2460,11 @@ var getExtractionBatchesWorkspaceByWorkspaceId = (options) => (options.client ??
2460
2460
  url: "/extraction/batches/workspace/{workspace_id}",
2461
2461
  ...options
2462
2462
  });
2463
+ var getExtractionAgents = (options) => (options.client ?? client).get({
2464
+ security: [{ scheme: "bearer", type: "http" }],
2465
+ url: "/extraction/agents",
2466
+ ...options
2467
+ });
2463
2468
  var deleteClinicalPracticeResourcesByIdPermanent = (options) => (options.client ?? client).delete({
2464
2469
  security: [{ scheme: "bearer", type: "http" }],
2465
2470
  url: "/clinical/practice-resources/{id}/permanent",
@@ -2651,6 +2656,15 @@ var patchInvitationsByIdRevoke = (options) => (options.client ?? client).patch({
2651
2656
  ...options.headers
2652
2657
  }
2653
2658
  });
2659
+ var postExtractionAgentsPredict = (options) => (options.client ?? client).post({
2660
+ security: [{ scheme: "bearer", type: "http" }],
2661
+ url: "/extraction/agents/predict",
2662
+ ...options,
2663
+ headers: {
2664
+ "Content-Type": "application/vnd.api+json",
2665
+ ...options.headers
2666
+ }
2667
+ });
2654
2668
  var getCatalogTaxonomiesApplicationByApplicationId = (options) => (options.client ?? client).get({
2655
2669
  security: [{ scheme: "bearer", type: "http" }],
2656
2670
  url: "/catalog/taxonomies/application/{application_id}",
@@ -3256,6 +3270,11 @@ var patchStorageFilesByIdRestore = (options) => (options.client ?? client).patch
3256
3270
  ...options.headers
3257
3271
  }
3258
3272
  });
3273
+ var getWorkspacesByWorkspaceIdTrainingAnalytics = (options) => (options.client ?? client).get({
3274
+ security: [{ scheme: "bearer", type: "http" }],
3275
+ url: "/workspaces/{workspace_id}/training/analytics",
3276
+ ...options
3277
+ });
3259
3278
  var patchSocialCampaignsByIdCancel = (options) => (options.client ?? client).patch({
3260
3279
  security: [{ scheme: "bearer", type: "http" }],
3261
3280
  url: "/social/campaigns/{id}/cancel",
@@ -7021,6 +7040,15 @@ var postUsersAuthResendConfirmation = (options) => (options.client ?? client).po
7021
7040
  ...options.headers
7022
7041
  }
7023
7042
  });
7043
+ var postSocialCampaignsByIdPreviewAdaptations = (options) => (options.client ?? client).post({
7044
+ security: [{ scheme: "bearer", type: "http" }],
7045
+ url: "/social/campaigns/{id}/preview-adaptations",
7046
+ ...options,
7047
+ headers: {
7048
+ "Content-Type": "application/vnd.api+json",
7049
+ ...options.headers
7050
+ }
7051
+ });
7024
7052
  var getCrawlerResultsById = (options) => (options.client ?? client).get({
7025
7053
  security: [{ scheme: "bearer", type: "http" }],
7026
7054
  url: "/crawler/results/{id}",
@@ -7404,6 +7432,11 @@ var postExtractionDocumentsBulkReprocess = (options) => (options.client ?? clien
7404
7432
  ...options.headers
7405
7433
  }
7406
7434
  });
7435
+ var getExtractionAgentsById = (options) => (options.client ?? client).get({
7436
+ security: [{ scheme: "bearer", type: "http" }],
7437
+ url: "/extraction/agents/{id}",
7438
+ ...options
7439
+ });
7407
7440
  var getApplicationsBySlugBySlug = (options) => (options.client ?? client).get({
7408
7441
  security: [{ scheme: "bearer", type: "http" }],
7409
7442
  url: "/applications/by-slug/{slug}",
@@ -25485,6 +25518,94 @@ function createExtractionNamespace(rb) {
25485
25518
  options
25486
25519
  );
25487
25520
  }
25521
+ },
25522
+ /** Extraction agents — list and predict best extraction agents for documents. */
25523
+ extractionAgents: {
25524
+ /**
25525
+ * Lists all available extraction agents (system agents tagged with
25526
+ * "extraction" category).
25527
+ *
25528
+ * @param options - Optional request options (abort signal, custom headers).
25529
+ * @returns An array of extraction agent objects.
25530
+ *
25531
+ * @example
25532
+ * ```typescript
25533
+ * const agents = await client.extraction.extractionAgents.list();
25534
+ * ```
25535
+ */
25536
+ list: async (options) => {
25537
+ return rb.execute(getExtractionAgents, {}, options);
25538
+ },
25539
+ /**
25540
+ * Retrieves a single extraction agent by its unique identifier.
25541
+ *
25542
+ * @param id - The UUID of the extraction agent.
25543
+ * @param options - Optional request options (abort signal, custom headers).
25544
+ * @returns The matching extraction agent object.
25545
+ *
25546
+ * @example
25547
+ * ```typescript
25548
+ * const agent = await client.extraction.extractionAgents.get('agent-uuid');
25549
+ * ```
25550
+ */
25551
+ get: async (id, options) => {
25552
+ return rb.execute(
25553
+ getExtractionAgentsById,
25554
+ { path: { id } },
25555
+ options
25556
+ );
25557
+ },
25558
+ /**
25559
+ * Predicts the best extraction agent for a given document based on its
25560
+ * name, description, or file content.
25561
+ *
25562
+ * @param attributes - Prediction input (name, description, file_content, document_id).
25563
+ * @param options - Optional request options (abort signal, custom headers).
25564
+ * @returns A prediction result with recommended agents.
25565
+ *
25566
+ * @example
25567
+ * ```typescript
25568
+ * const prediction = await client.extraction.extractionAgents.predict({
25569
+ * name: 'invoice.pdf',
25570
+ * file_content: 'Invoice #12345...',
25571
+ * });
25572
+ * ```
25573
+ */
25574
+ predict: async (attributes, options) => {
25575
+ return rb.execute(
25576
+ postExtractionAgentsPredict,
25577
+ {
25578
+ body: {
25579
+ data: { type: "extraction-agent", attributes }
25580
+ }
25581
+ },
25582
+ options
25583
+ );
25584
+ }
25585
+ },
25586
+ /** Training analytics — workspace-level extraction training metrics. */
25587
+ trainingAnalytics: {
25588
+ /**
25589
+ * Retrieves training analytics for a specific workspace, including
25590
+ * accuracy trends, correction counts, and low-confidence documents.
25591
+ *
25592
+ * @param workspaceId - The UUID of the workspace.
25593
+ * @param options - Optional request options (abort signal, custom headers).
25594
+ * @returns The training analytics object for the workspace.
25595
+ *
25596
+ * @example
25597
+ * ```typescript
25598
+ * const analytics = await client.extraction.trainingAnalytics.forWorkspace('ws-uuid');
25599
+ * console.log(analytics.avg_confidence, analytics.total_examples);
25600
+ * ```
25601
+ */
25602
+ forWorkspace: async (workspaceId, options) => {
25603
+ return rb.execute(
25604
+ getWorkspacesByWorkspaceIdTrainingAnalytics,
25605
+ { path: { workspace_id: workspaceId } },
25606
+ options
25607
+ );
25608
+ }
25488
25609
  }
25489
25610
  };
25490
25611
  }
@@ -30062,11 +30183,108 @@ function createStorageNamespace(rb) {
30062
30183
  { query: { parent_id: parentId } },
30063
30184
  options
30064
30185
  );
30186
+ },
30187
+ /**
30188
+ * Generate a short-lived presigned download URL for a file.
30189
+ *
30190
+ * Returns a URL that can be used to download the file directly from
30191
+ * object storage (GCS in production, MinIO in dev) without routing
30192
+ * through the application server.
30193
+ *
30194
+ * @param id - The UUID of the file to download.
30195
+ * @param params - Optional parameters (e.g., custom `expires_in` seconds).
30196
+ * @param options - Optional request options (abort signal, custom headers).
30197
+ * @returns A promise resolving to the presigned URL and its expiry.
30198
+ *
30199
+ * @example
30200
+ * ```typescript
30201
+ * const { url, expires_at } = await client.storage.files.requestDownloadUrl(
30202
+ * 'file-uuid',
30203
+ * { expires_in: 300 }, // 5 minutes
30204
+ * );
30205
+ * // Redirect browser to `url` for direct download
30206
+ * ```
30207
+ */
30208
+ requestDownloadUrl: async (id, params, options) => {
30209
+ return rb.rawPostDirect(
30210
+ `/storage-files/${id}/download-url`,
30211
+ params?.expires_in != null ? { data: { expires_in: params.expires_in } } : void 0,
30212
+ options
30213
+ );
30065
30214
  }
30066
30215
  }
30067
30216
  };
30068
30217
  }
30069
30218
 
30219
+ // src/namespaces/documents.ts
30220
+ function createDocumentsNamespace(rb) {
30221
+ return {
30222
+ /**
30223
+ * Generate a PDF from HTML content and store it in platform Storage.
30224
+ *
30225
+ * Always pass `store: true` and `workspace_id` to get a JSON response with
30226
+ * a `storage_key`. Without `store: true`, the server returns raw
30227
+ * `application/pdf` binary which cannot be parsed as JSON by this SDK method.
30228
+ *
30229
+ * HTML input is capped at 2MB by the server.
30230
+ *
30231
+ * @param params - PDF generation parameters. Set `store: true` and provide
30232
+ * `workspace_id` for JSON response.
30233
+ * @param options - Optional request options (abort signal, custom headers).
30234
+ * @returns A storage key reference for the generated PDF.
30235
+ *
30236
+ * @example
30237
+ * ```typescript
30238
+ * const { storage_key } = await client.documents.generatePdf({
30239
+ * html: '<html><body>Report</body></html>',
30240
+ * store: true,
30241
+ * workspace_id: 'ws-123',
30242
+ * });
30243
+ * ```
30244
+ */
30245
+ generatePdf: async (params, options) => {
30246
+ return rb.rawPostDirect(
30247
+ "/documents/pdf",
30248
+ params,
30249
+ options
30250
+ );
30251
+ },
30252
+ /**
30253
+ * Generate a PDF from HTML and email it as an attachment.
30254
+ *
30255
+ * The PDF is generated server-side and delivered via platform SMTP.
30256
+ * Optionally stores the PDF in platform Storage alongside the email delivery.
30257
+ *
30258
+ * If storage fails but the email succeeds, the response includes
30259
+ * `storage_error` with the failure reason (email is still delivered).
30260
+ *
30261
+ * @param params - Email report parameters.
30262
+ * @param options - Optional request options (abort signal, custom headers).
30263
+ * @returns Delivery status, optional storage key, and any storage error.
30264
+ *
30265
+ * @example
30266
+ * ```typescript
30267
+ * const result = await client.documents.emailReport({
30268
+ * html: '<html><body><h1>Q1 Summary</h1></body></html>',
30269
+ * to: 'finance@company.com',
30270
+ * subject: 'Q1 Financial Summary',
30271
+ * store: true,
30272
+ * workspace_id: 'ws-123',
30273
+ * });
30274
+ * console.log(result.sent); // true
30275
+ * console.log(result.storage_key); // 'ws-123/documents/...'
30276
+ * ```
30277
+ */
30278
+ emailReport: async (params, options) => {
30279
+ return rb.rawPostDirect(
30280
+ "/documents/pdf/email",
30281
+ params,
30282
+ options
30283
+ );
30284
+ }
30285
+ };
30286
+ }
30287
+
30070
30288
  // src/namespaces/threads.ts
30071
30289
  function getBrowserContext() {
30072
30290
  const ctx = {};
@@ -33286,6 +33504,32 @@ function createSocialNamespace(rb) {
33286
33504
  },
33287
33505
  options
33288
33506
  );
33507
+ },
33508
+ /**
33509
+ * Preview adapted copy per platform without creating SocialPost records.
33510
+ *
33511
+ * Returns the AI-adapted text for each target platform so the user can
33512
+ * review before committing via `adaptForPlatforms`.
33513
+ *
33514
+ * @param id - Campaign UUID.
33515
+ * @param workspaceId - Workspace UUID.
33516
+ * @param options - Optional request options.
33517
+ * @returns `{ adaptations: [{ platform: string, content: string }] }`
33518
+ */
33519
+ previewAdaptations: async (id, workspaceId, options) => {
33520
+ return rb.execute(
33521
+ postSocialCampaignsByIdPreviewAdaptations,
33522
+ {
33523
+ path: { id },
33524
+ body: {
33525
+ data: {
33526
+ campaign_id: id,
33527
+ workspace_id: workspaceId
33528
+ }
33529
+ }
33530
+ },
33531
+ options
33532
+ );
33289
33533
  }
33290
33534
  },
33291
33535
  /** Trending content discovery — snapshots, items, and watch alerts. */
@@ -34387,6 +34631,31 @@ var RequestBuilder = class {
34387
34631
  throw handleApiError(error);
34388
34632
  }
34389
34633
  }
34634
+ /**
34635
+ * Execute a raw POST to a custom endpoint that returns flat JSON (no data wrapper).
34636
+ * Unlike rawPost (which unwraps data.data), this returns the response body directly.
34637
+ * Used for hand-written Phoenix controllers like DocumentsController.
34638
+ */
34639
+ async rawPostDirect(url, body, options) {
34640
+ const headers = buildHeaders(this.getHeaders, options);
34641
+ try {
34642
+ const result = await this.requestWithRetry(
34643
+ () => this.clientInstance.post({
34644
+ url,
34645
+ headers,
34646
+ ...body !== void 0 && { body },
34647
+ ...options?.signal && { signal: options.signal }
34648
+ })
34649
+ );
34650
+ const { data, error } = result;
34651
+ if (error) {
34652
+ throw handleApiError(enrichError(error, result));
34653
+ }
34654
+ return data;
34655
+ } catch (error) {
34656
+ throw handleApiError(error);
34657
+ }
34658
+ }
34390
34659
  /**
34391
34660
  * Execute a raw PUT request to a custom (non-generated) endpoint.
34392
34661
  */
@@ -34606,6 +34875,7 @@ var GptClient = class extends BaseClient {
34606
34875
  this.campaigns = createCampaignsNamespace(rb);
34607
34876
  this.email = createEmailNamespace(rb);
34608
34877
  this.support = createSupportNamespace(rb);
34878
+ this.documents = createDocumentsNamespace(rb);
34609
34879
  this.extraction = createExtractionNamespace(rb);
34610
34880
  this.identity = createIdentityNamespace(rb, this.config?.baseUrl);
34611
34881
  this.portal = createPortalNamespace(rb);