@gpt-platform/client 0.8.2 → 0.8.3

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
@@ -1333,7 +1333,7 @@ function buildUserAgent(sdkVersion, appInfo) {
1333
1333
  }
1334
1334
 
1335
1335
  // src/version.ts
1336
- var SDK_VERSION = "0.8.2";
1336
+ var SDK_VERSION = "0.8.3";
1337
1337
  var DEFAULT_API_VERSION = "2026-03-11";
1338
1338
 
1339
1339
  // src/base-client.ts
@@ -1604,6 +1604,36 @@ var BaseClient = class {
1604
1604
  clearToken() {
1605
1605
  this.config = { ...this.config, token: void 0 };
1606
1606
  }
1607
+ /**
1608
+ * Switch the workspace context for all subsequent requests.
1609
+ *
1610
+ * Sets the `workspace_id` query parameter appended to every request.
1611
+ * Use this after creating a new workspace or switching workspace context
1612
+ * without constructing a new client instance.
1613
+ *
1614
+ * @param workspaceId - The workspace UUID to scope requests to, or
1615
+ * `undefined` to clear workspace scoping.
1616
+ *
1617
+ * @example
1618
+ * ```typescript
1619
+ * const org = await sdk.platform.tenants.createOrg({ name: 'Acme' });
1620
+ * const workspaces = await sdk.platform.workspaces.mine();
1621
+ * const ws = workspaces.find(w => w.tenant_id === org.id);
1622
+ *
1623
+ * sdk.setWorkspaceId(ws.id);
1624
+ * // All subsequent calls are scoped to the new workspace
1625
+ * await sdk.scheduling.events.create({ ... });
1626
+ * ```
1627
+ */
1628
+ setWorkspaceId(workspaceId) {
1629
+ this.config = { ...this.config, workspaceId };
1630
+ }
1631
+ /**
1632
+ * Get the current workspace ID, if set.
1633
+ */
1634
+ getWorkspaceId() {
1635
+ return this.config.workspaceId;
1636
+ }
1607
1637
  };
1608
1638
 
1609
1639
  // src/namespaces/audit.ts
@@ -3882,6 +3912,11 @@ var postVoiceSessions = (options) => (options.client ?? client).post({
3882
3912
  ...options.headers
3883
3913
  }
3884
3914
  });
3915
+ var getInvitations = (options) => (options.client ?? client).get({
3916
+ security: [{ scheme: "bearer", type: "http" }],
3917
+ url: "/invitations",
3918
+ ...options
3919
+ });
3885
3920
  var postInvitations = (options) => (options.client ?? client).post({
3886
3921
  security: [{ scheme: "bearer", type: "http" }],
3887
3922
  url: "/invitations",
@@ -4637,6 +4672,15 @@ var getEmailInclusionsEmailByOutboundEmailId = (options) => (options.client ?? c
4637
4672
  url: "/email/inclusions/email/{outbound_email_id}",
4638
4673
  ...options
4639
4674
  });
4675
+ var patchTenantsByIdReactivate = (options) => (options.client ?? client).patch({
4676
+ security: [{ scheme: "bearer", type: "http" }],
4677
+ url: "/tenants/{id}/reactivate",
4678
+ ...options,
4679
+ headers: {
4680
+ "Content-Type": "application/vnd.api+json",
4681
+ ...options.headers
4682
+ }
4683
+ });
4640
4684
  var getWorkspacesByWorkspaceIdExtractionExportsById = (options) => (options.client ?? client).get({
4641
4685
  security: [{ scheme: "bearer", type: "http" }],
4642
4686
  url: "/workspaces/{workspace_id}/extraction/exports/{id}",
@@ -4739,6 +4783,15 @@ var postConnectorsFullscriptCheckPatient = (options) => (options.client ?? clien
4739
4783
  ...options.headers
4740
4784
  }
4741
4785
  });
4786
+ var patchTenantsByIdDeactivate = (options) => (options.client ?? client).patch({
4787
+ security: [{ scheme: "bearer", type: "http" }],
4788
+ url: "/tenants/{id}/deactivate",
4789
+ ...options,
4790
+ headers: {
4791
+ "Content-Type": "application/vnd.api+json",
4792
+ ...options.headers
4793
+ }
4794
+ });
4742
4795
  var getSchedulingEventTypes = (options) => (options.client ?? client).get({
4743
4796
  security: [{ scheme: "bearer", type: "http" }],
4744
4797
  url: "/scheduling/event-types",
@@ -6057,11 +6110,6 @@ var patchBrandIdentitiesByIdUnsetDefault = (options) => (options.client ?? clien
6057
6110
  ...options.headers
6058
6111
  }
6059
6112
  });
6060
- var deleteTenantsById = (options) => (options.client ?? client).delete({
6061
- security: [{ scheme: "bearer", type: "http" }],
6062
- url: "/tenants/{id}",
6063
- ...options
6064
- });
6065
6113
  var getTenantsById = (options) => (options.client ?? client).get({
6066
6114
  security: [{ scheme: "bearer", type: "http" }],
6067
6115
  url: "/tenants/{id}",
@@ -6913,6 +6961,15 @@ var postAgentsByIdExport = (options) => (options.client ?? client).post({
6913
6961
  url: "/agents/{id}/export",
6914
6962
  ...options
6915
6963
  });
6964
+ var postUsersAuthRegisterViaInvitation = (options) => (options.client ?? client).post({
6965
+ security: [{ scheme: "bearer", type: "http" }],
6966
+ url: "/users/auth/register-via-invitation",
6967
+ ...options,
6968
+ headers: {
6969
+ "Content-Type": "application/vnd.api+json",
6970
+ ...options.headers
6971
+ }
6972
+ });
6916
6973
  var postEmailInboundAddresses = (options) => (options.client ?? client).post({
6917
6974
  security: [{ scheme: "bearer", type: "http" }],
6918
6975
  url: "/email/inbound-addresses",
@@ -10203,6 +10260,31 @@ function createBillingNamespace(rb) {
10203
10260
  );
10204
10261
  return result.data ?? result;
10205
10262
  }
10263
+ },
10264
+ /**
10265
+ * Get capacity estimates for a plan's monthly credits.
10266
+ *
10267
+ * Returns how many of each ISV-defined feature the plan supports per month.
10268
+ * No Bearer token required — uses application key only.
10269
+ *
10270
+ * @param planSlug - The plan slug to calculate capacity for.
10271
+ * @param options - Optional request-level overrides.
10272
+ * @returns Plan details and capacity breakdown per composite operation.
10273
+ *
10274
+ * @example
10275
+ * ```typescript
10276
+ * const result = await client.billing.capacityCalculator("pro-plan");
10277
+ * console.log(`Plan: ${result.plan.name}`);
10278
+ * for (const item of result.capacity) {
10279
+ * console.log(`${item.display_name}: ~${item.estimated_monthly_count}/month`);
10280
+ * }
10281
+ * ```
10282
+ */
10283
+ capacityCalculator: async (planSlug, options) => {
10284
+ return rb.rawGet(
10285
+ `/billing/capacity-calculator?plan_slug=${encodeURIComponent(planSlug)}`,
10286
+ options
10287
+ );
10206
10288
  }
10207
10289
  };
10208
10290
  }
@@ -11978,6 +12060,46 @@ function createClinicalNamespace(rb) {
11978
12060
  getClinicalPracticeResourcesCatalog,
11979
12061
  { query: params ?? {} },
11980
12062
  options
12063
+ ),
12064
+ /**
12065
+ * List distinct practice resource categories in a workspace.
12066
+ *
12067
+ * Returns unique `resource_type` values with their active resource counts,
12068
+ * sorted by count descending.
12069
+ *
12070
+ * @param params - Must include `workspace_id`
12071
+ * @param options - Request options
12072
+ * @returns Array of {@link PracticeResourceCategory} records
12073
+ *
12074
+ * @example
12075
+ * ```typescript
12076
+ * const categories = await client.clinical.practiceResources.listCategories({
12077
+ * workspace_id: "..."
12078
+ * });
12079
+ * // [{ category: "article", resource_count: 5 }, { category: "video", resource_count: 3 }]
12080
+ * ```
12081
+ */
12082
+ listCategories: async (params, options) => rb.rawGet(
12083
+ `/clinical/practice-resources/categories?workspace_id=${encodeURIComponent(params.workspace_id)}`,
12084
+ options
12085
+ ),
12086
+ /**
12087
+ * List distinct catalog practice resource categories.
12088
+ *
12089
+ * Returns unique `resource_type` values from application-level catalog resources.
12090
+ * Application ID is resolved from the API key context.
12091
+ *
12092
+ * @param options - Request options
12093
+ * @returns Array of {@link PracticeResourceCategory} records
12094
+ *
12095
+ * @example
12096
+ * ```typescript
12097
+ * const cats = await client.clinical.practiceResources.listCatalogCategories();
12098
+ * ```
12099
+ */
12100
+ listCatalogCategories: async (options) => rb.rawGet(
12101
+ `/clinical/practice-resources/categories/catalog`,
12102
+ options
11981
12103
  )
11982
12104
  },
11983
12105
  /**
@@ -12081,6 +12203,24 @@ function createClinicalNamespace(rb) {
12081
12203
  getClinicalPracticeToolsCatalog,
12082
12204
  { query: params ?? {} },
12083
12205
  options
12206
+ ),
12207
+ /**
12208
+ * List distinct catalog practice tool categories.
12209
+ *
12210
+ * Returns unique `tool_type` values from application-level catalog tools.
12211
+ * Application ID is resolved from the API key context.
12212
+ *
12213
+ * @param options - Request options
12214
+ * @returns Array of {@link PracticeToolCategory} records
12215
+ *
12216
+ * @example
12217
+ * ```typescript
12218
+ * const cats = await client.clinical.practiceTools.listCatalogCategories();
12219
+ * ```
12220
+ */
12221
+ listCatalogCategories: async (options) => rb.rawGet(
12222
+ `/clinical/practice-tools/categories/catalog`,
12223
+ options
12084
12224
  )
12085
12225
  },
12086
12226
  /**
@@ -12360,6 +12500,24 @@ function createClinicalNamespace(rb) {
12360
12500
  getClinicalGoalTemplatesCatalog,
12361
12501
  { query: params ?? {} },
12362
12502
  options
12503
+ ),
12504
+ /**
12505
+ * List distinct catalog goal template categories.
12506
+ *
12507
+ * Returns unique `category` values from application-level catalog templates.
12508
+ * Application ID is resolved from the API key context.
12509
+ *
12510
+ * @param options - Request options
12511
+ * @returns Array of {@link ClinicalGoalTemplateCategory} records
12512
+ *
12513
+ * @example
12514
+ * ```typescript
12515
+ * const cats = await client.clinical.goalTemplates.listCatalogCategories();
12516
+ * ```
12517
+ */
12518
+ listCatalogCategories: async (options) => rb.rawGet(
12519
+ `/clinical/goal-templates/categories/catalog`,
12520
+ options
12363
12521
  )
12364
12522
  },
12365
12523
  /**
@@ -22283,6 +22441,15 @@ var ChangePasswordSchema = import_zod2.z.object({
22283
22441
  message: "Passwords do not match",
22284
22442
  path: ["password_confirmation"]
22285
22443
  });
22444
+ var RegisterViaInvitationSchema = import_zod2.z.object({
22445
+ email: import_zod2.z.string().email(),
22446
+ password: import_zod2.z.string().min(8),
22447
+ password_confirmation: import_zod2.z.string().min(8),
22448
+ invitation_token: import_zod2.z.string().min(1)
22449
+ }).refine((data) => data.password === data.password_confirmation, {
22450
+ message: "Passwords do not match",
22451
+ path: ["password_confirmation"]
22452
+ });
22286
22453
  function createIdentityNamespace(rb, baseUrl) {
22287
22454
  return {
22288
22455
  /**
@@ -22371,6 +22538,57 @@ function createIdentityNamespace(rb, baseUrl) {
22371
22538
  options
22372
22539
  );
22373
22540
  },
22541
+ /**
22542
+ * Register a new user via invitation — skips personal tenant creation.
22543
+ *
22544
+ * Creates the user account, accepts the invitation (creating tenant/workspace
22545
+ * memberships), and returns the authenticated user with a session token.
22546
+ * The email must match the invitation's recipient email.
22547
+ *
22548
+ * @param email - Must match the invitation recipient email
22549
+ * @param password - Minimum 8 characters
22550
+ * @param passwordConfirmation - Must match password
22551
+ * @param invitationToken - Raw token from the invitation email link
22552
+ * @param attrs - Optional extra attributes (first_name, last_name)
22553
+ * @param options - Optional request options
22554
+ * @returns The newly created `User` with session token
22555
+ *
22556
+ * @example
22557
+ * ```typescript
22558
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
22559
+ * const user = await client.identity.registerViaInvitation(
22560
+ * 'invited@example.com', 'securepass', 'securepass', 'raw-token-from-email',
22561
+ * { first_name: 'Jane', last_name: 'Doe' },
22562
+ * );
22563
+ * console.log(user.token); // JWT session token
22564
+ * ```
22565
+ */
22566
+ registerViaInvitation: async (email, password, passwordConfirmation, invitationToken, attrs, options) => {
22567
+ RegisterViaInvitationSchema.parse({
22568
+ email,
22569
+ password,
22570
+ password_confirmation: passwordConfirmation,
22571
+ invitation_token: invitationToken
22572
+ });
22573
+ return rb.execute(
22574
+ postUsersAuthRegisterViaInvitation,
22575
+ {
22576
+ body: {
22577
+ data: {
22578
+ type: "user",
22579
+ attributes: {
22580
+ email,
22581
+ password,
22582
+ password_confirmation: passwordConfirmation,
22583
+ invitation_token: invitationToken,
22584
+ ...attrs
22585
+ }
22586
+ }
22587
+ }
22588
+ },
22589
+ options
22590
+ );
22591
+ },
22374
22592
  /** Get the currently authenticated user */
22375
22593
  me: async (options) => {
22376
22594
  return rb.execute(getUsersMe, {}, options);
@@ -23521,26 +23739,56 @@ function createPlatformNamespace(rb) {
23521
23739
  );
23522
23740
  },
23523
23741
  /**
23524
- * Delete a tenant and all associated data.
23742
+ * Deactivate a tenant (hide from user's account).
23525
23743
  *
23526
- * Permanently removes the tenant, all their workspaces, documents, and
23527
- * billing records. This operation is irreversible. For a graceful
23528
- * off-boarding, prefer `schedulePurge` which allows data export before
23529
- * deletion.
23744
+ * Sets `deactivated_at` on the tenant. The tenant and its workspaces
23745
+ * disappear from `workspaces.mine()` and tenant listings. Billing and
23746
+ * data are completely unaffected. Reversible via `reactivate()`.
23530
23747
  *
23531
- * @param id - The UUID of the tenant to delete.
23748
+ * Only the tenant owner can deactivate.
23749
+ *
23750
+ * @param id - The UUID of the tenant to deactivate.
23532
23751
  * @param options - Optional request options.
23533
- * @returns `true` on successful deletion.
23752
+ * @returns The updated tenant record.
23534
23753
  *
23535
23754
  * @example
23536
23755
  * ```typescript
23537
- * const client = new GptClient({ apiKey: 'sk_app_...' });
23538
- * await client.platform.tenants.delete('tenant_abc123');
23756
+ * await client.platform.tenants.deactivate('tenant_abc123');
23539
23757
  * ```
23540
23758
  */
23541
- delete: async (id, options) => {
23542
- return rb.executeDelete(deleteTenantsById, { path: { id } }, options);
23543
- },
23759
+ deactivate: async (id, options) => rb.execute(
23760
+ patchTenantsByIdDeactivate,
23761
+ {
23762
+ path: { id },
23763
+ body: { data: { type: "tenant", id, attributes: {} } }
23764
+ },
23765
+ options
23766
+ ),
23767
+ /**
23768
+ * Reactivate a previously deactivated tenant.
23769
+ *
23770
+ * Clears `deactivated_at`, restoring the tenant and its workspaces
23771
+ * to the user's account. Only works on deactivated tenants.
23772
+ *
23773
+ * Only the tenant owner can reactivate.
23774
+ *
23775
+ * @param id - The UUID of the tenant to reactivate.
23776
+ * @param options - Optional request options.
23777
+ * @returns The updated tenant record.
23778
+ *
23779
+ * @example
23780
+ * ```typescript
23781
+ * await client.platform.tenants.reactivate('tenant_abc123');
23782
+ * ```
23783
+ */
23784
+ reactivate: async (id, options) => rb.execute(
23785
+ patchTenantsByIdReactivate,
23786
+ {
23787
+ path: { id },
23788
+ body: { data: { type: "tenant", id, attributes: {} } }
23789
+ },
23790
+ options
23791
+ ),
23544
23792
  /**
23545
23793
  * Create a new tenant (ISV provisioning flow).
23546
23794
  *
@@ -23911,6 +24159,52 @@ function createPlatformNamespace(rb) {
23911
24159
  options
23912
24160
  );
23913
24161
  },
24162
+ /**
24163
+ * List invitations visible to the current actor.
24164
+ *
24165
+ * Returns invitations where the actor is the inviter, the tenant owner,
24166
+ * or the recipient (matched by email). Use this to build admin views
24167
+ * of pending/accepted invitations for a tenant or workspace.
24168
+ *
24169
+ * @param options - Optional page number, page size, and request options.
24170
+ * @returns A page of `Invitation` records.
24171
+ *
24172
+ * @example
24173
+ * ```typescript
24174
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
24175
+ * const invites = await client.platform.invitations.list();
24176
+ * ```
24177
+ */
24178
+ list: async (options) => {
24179
+ return rb.execute(
24180
+ getInvitations,
24181
+ buildPageQuery(options?.page, options?.pageSize),
24182
+ options
24183
+ );
24184
+ },
24185
+ /**
24186
+ * List all invitations visible to the current actor, auto-paginating.
24187
+ *
24188
+ * @param options - Optional request options.
24189
+ * @returns All visible `Invitation` records as a flat array.
24190
+ *
24191
+ * @example
24192
+ * ```typescript
24193
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
24194
+ * const all = await client.platform.invitations.listAll();
24195
+ * ```
24196
+ */
24197
+ listAll: async (options) => {
24198
+ return paginateToArray(
24199
+ rb.createPaginatedFetcher(
24200
+ getInvitations,
24201
+ (page, pageSize) => ({
24202
+ query: { page: { number: page, size: pageSize } }
24203
+ }),
24204
+ options
24205
+ )
24206
+ );
24207
+ },
23914
24208
  /**
23915
24209
  * Look up a pending invitation by its raw token.
23916
24210
  *