@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.mjs CHANGED
@@ -1269,7 +1269,7 @@ function buildUserAgent(sdkVersion, appInfo) {
1269
1269
  }
1270
1270
 
1271
1271
  // src/version.ts
1272
- var SDK_VERSION = "0.8.2";
1272
+ var SDK_VERSION = "0.8.3";
1273
1273
  var DEFAULT_API_VERSION = "2026-03-11";
1274
1274
 
1275
1275
  // src/base-client.ts
@@ -1540,6 +1540,36 @@ var BaseClient = class {
1540
1540
  clearToken() {
1541
1541
  this.config = { ...this.config, token: void 0 };
1542
1542
  }
1543
+ /**
1544
+ * Switch the workspace context for all subsequent requests.
1545
+ *
1546
+ * Sets the `workspace_id` query parameter appended to every request.
1547
+ * Use this after creating a new workspace or switching workspace context
1548
+ * without constructing a new client instance.
1549
+ *
1550
+ * @param workspaceId - The workspace UUID to scope requests to, or
1551
+ * `undefined` to clear workspace scoping.
1552
+ *
1553
+ * @example
1554
+ * ```typescript
1555
+ * const org = await sdk.platform.tenants.createOrg({ name: 'Acme' });
1556
+ * const workspaces = await sdk.platform.workspaces.mine();
1557
+ * const ws = workspaces.find(w => w.tenant_id === org.id);
1558
+ *
1559
+ * sdk.setWorkspaceId(ws.id);
1560
+ * // All subsequent calls are scoped to the new workspace
1561
+ * await sdk.scheduling.events.create({ ... });
1562
+ * ```
1563
+ */
1564
+ setWorkspaceId(workspaceId) {
1565
+ this.config = { ...this.config, workspaceId };
1566
+ }
1567
+ /**
1568
+ * Get the current workspace ID, if set.
1569
+ */
1570
+ getWorkspaceId() {
1571
+ return this.config.workspaceId;
1572
+ }
1543
1573
  };
1544
1574
 
1545
1575
  // src/namespaces/audit.ts
@@ -3818,6 +3848,11 @@ var postVoiceSessions = (options) => (options.client ?? client).post({
3818
3848
  ...options.headers
3819
3849
  }
3820
3850
  });
3851
+ var getInvitations = (options) => (options.client ?? client).get({
3852
+ security: [{ scheme: "bearer", type: "http" }],
3853
+ url: "/invitations",
3854
+ ...options
3855
+ });
3821
3856
  var postInvitations = (options) => (options.client ?? client).post({
3822
3857
  security: [{ scheme: "bearer", type: "http" }],
3823
3858
  url: "/invitations",
@@ -4573,6 +4608,15 @@ var getEmailInclusionsEmailByOutboundEmailId = (options) => (options.client ?? c
4573
4608
  url: "/email/inclusions/email/{outbound_email_id}",
4574
4609
  ...options
4575
4610
  });
4611
+ var patchTenantsByIdReactivate = (options) => (options.client ?? client).patch({
4612
+ security: [{ scheme: "bearer", type: "http" }],
4613
+ url: "/tenants/{id}/reactivate",
4614
+ ...options,
4615
+ headers: {
4616
+ "Content-Type": "application/vnd.api+json",
4617
+ ...options.headers
4618
+ }
4619
+ });
4576
4620
  var getWorkspacesByWorkspaceIdExtractionExportsById = (options) => (options.client ?? client).get({
4577
4621
  security: [{ scheme: "bearer", type: "http" }],
4578
4622
  url: "/workspaces/{workspace_id}/extraction/exports/{id}",
@@ -4675,6 +4719,15 @@ var postConnectorsFullscriptCheckPatient = (options) => (options.client ?? clien
4675
4719
  ...options.headers
4676
4720
  }
4677
4721
  });
4722
+ var patchTenantsByIdDeactivate = (options) => (options.client ?? client).patch({
4723
+ security: [{ scheme: "bearer", type: "http" }],
4724
+ url: "/tenants/{id}/deactivate",
4725
+ ...options,
4726
+ headers: {
4727
+ "Content-Type": "application/vnd.api+json",
4728
+ ...options.headers
4729
+ }
4730
+ });
4678
4731
  var getSchedulingEventTypes = (options) => (options.client ?? client).get({
4679
4732
  security: [{ scheme: "bearer", type: "http" }],
4680
4733
  url: "/scheduling/event-types",
@@ -5993,11 +6046,6 @@ var patchBrandIdentitiesByIdUnsetDefault = (options) => (options.client ?? clien
5993
6046
  ...options.headers
5994
6047
  }
5995
6048
  });
5996
- var deleteTenantsById = (options) => (options.client ?? client).delete({
5997
- security: [{ scheme: "bearer", type: "http" }],
5998
- url: "/tenants/{id}",
5999
- ...options
6000
- });
6001
6049
  var getTenantsById = (options) => (options.client ?? client).get({
6002
6050
  security: [{ scheme: "bearer", type: "http" }],
6003
6051
  url: "/tenants/{id}",
@@ -6849,6 +6897,15 @@ var postAgentsByIdExport = (options) => (options.client ?? client).post({
6849
6897
  url: "/agents/{id}/export",
6850
6898
  ...options
6851
6899
  });
6900
+ var postUsersAuthRegisterViaInvitation = (options) => (options.client ?? client).post({
6901
+ security: [{ scheme: "bearer", type: "http" }],
6902
+ url: "/users/auth/register-via-invitation",
6903
+ ...options,
6904
+ headers: {
6905
+ "Content-Type": "application/vnd.api+json",
6906
+ ...options.headers
6907
+ }
6908
+ });
6852
6909
  var postEmailInboundAddresses = (options) => (options.client ?? client).post({
6853
6910
  security: [{ scheme: "bearer", type: "http" }],
6854
6911
  url: "/email/inbound-addresses",
@@ -10139,6 +10196,31 @@ function createBillingNamespace(rb) {
10139
10196
  );
10140
10197
  return result.data ?? result;
10141
10198
  }
10199
+ },
10200
+ /**
10201
+ * Get capacity estimates for a plan's monthly credits.
10202
+ *
10203
+ * Returns how many of each ISV-defined feature the plan supports per month.
10204
+ * No Bearer token required — uses application key only.
10205
+ *
10206
+ * @param planSlug - The plan slug to calculate capacity for.
10207
+ * @param options - Optional request-level overrides.
10208
+ * @returns Plan details and capacity breakdown per composite operation.
10209
+ *
10210
+ * @example
10211
+ * ```typescript
10212
+ * const result = await client.billing.capacityCalculator("pro-plan");
10213
+ * console.log(`Plan: ${result.plan.name}`);
10214
+ * for (const item of result.capacity) {
10215
+ * console.log(`${item.display_name}: ~${item.estimated_monthly_count}/month`);
10216
+ * }
10217
+ * ```
10218
+ */
10219
+ capacityCalculator: async (planSlug, options) => {
10220
+ return rb.rawGet(
10221
+ `/billing/capacity-calculator?plan_slug=${encodeURIComponent(planSlug)}`,
10222
+ options
10223
+ );
10142
10224
  }
10143
10225
  };
10144
10226
  }
@@ -11914,6 +11996,46 @@ function createClinicalNamespace(rb) {
11914
11996
  getClinicalPracticeResourcesCatalog,
11915
11997
  { query: params ?? {} },
11916
11998
  options
11999
+ ),
12000
+ /**
12001
+ * List distinct practice resource categories in a workspace.
12002
+ *
12003
+ * Returns unique `resource_type` values with their active resource counts,
12004
+ * sorted by count descending.
12005
+ *
12006
+ * @param params - Must include `workspace_id`
12007
+ * @param options - Request options
12008
+ * @returns Array of {@link PracticeResourceCategory} records
12009
+ *
12010
+ * @example
12011
+ * ```typescript
12012
+ * const categories = await client.clinical.practiceResources.listCategories({
12013
+ * workspace_id: "..."
12014
+ * });
12015
+ * // [{ category: "article", resource_count: 5 }, { category: "video", resource_count: 3 }]
12016
+ * ```
12017
+ */
12018
+ listCategories: async (params, options) => rb.rawGet(
12019
+ `/clinical/practice-resources/categories?workspace_id=${encodeURIComponent(params.workspace_id)}`,
12020
+ options
12021
+ ),
12022
+ /**
12023
+ * List distinct catalog practice resource categories.
12024
+ *
12025
+ * Returns unique `resource_type` values from application-level catalog resources.
12026
+ * Application ID is resolved from the API key context.
12027
+ *
12028
+ * @param options - Request options
12029
+ * @returns Array of {@link PracticeResourceCategory} records
12030
+ *
12031
+ * @example
12032
+ * ```typescript
12033
+ * const cats = await client.clinical.practiceResources.listCatalogCategories();
12034
+ * ```
12035
+ */
12036
+ listCatalogCategories: async (options) => rb.rawGet(
12037
+ `/clinical/practice-resources/categories/catalog`,
12038
+ options
11917
12039
  )
11918
12040
  },
11919
12041
  /**
@@ -12017,6 +12139,24 @@ function createClinicalNamespace(rb) {
12017
12139
  getClinicalPracticeToolsCatalog,
12018
12140
  { query: params ?? {} },
12019
12141
  options
12142
+ ),
12143
+ /**
12144
+ * List distinct catalog practice tool categories.
12145
+ *
12146
+ * Returns unique `tool_type` values from application-level catalog tools.
12147
+ * Application ID is resolved from the API key context.
12148
+ *
12149
+ * @param options - Request options
12150
+ * @returns Array of {@link PracticeToolCategory} records
12151
+ *
12152
+ * @example
12153
+ * ```typescript
12154
+ * const cats = await client.clinical.practiceTools.listCatalogCategories();
12155
+ * ```
12156
+ */
12157
+ listCatalogCategories: async (options) => rb.rawGet(
12158
+ `/clinical/practice-tools/categories/catalog`,
12159
+ options
12020
12160
  )
12021
12161
  },
12022
12162
  /**
@@ -12296,6 +12436,24 @@ function createClinicalNamespace(rb) {
12296
12436
  getClinicalGoalTemplatesCatalog,
12297
12437
  { query: params ?? {} },
12298
12438
  options
12439
+ ),
12440
+ /**
12441
+ * List distinct catalog goal template categories.
12442
+ *
12443
+ * Returns unique `category` values from application-level catalog templates.
12444
+ * Application ID is resolved from the API key context.
12445
+ *
12446
+ * @param options - Request options
12447
+ * @returns Array of {@link ClinicalGoalTemplateCategory} records
12448
+ *
12449
+ * @example
12450
+ * ```typescript
12451
+ * const cats = await client.clinical.goalTemplates.listCatalogCategories();
12452
+ * ```
12453
+ */
12454
+ listCatalogCategories: async (options) => rb.rawGet(
12455
+ `/clinical/goal-templates/categories/catalog`,
12456
+ options
12299
12457
  )
12300
12458
  },
12301
12459
  /**
@@ -22219,6 +22377,15 @@ var ChangePasswordSchema = z2.object({
22219
22377
  message: "Passwords do not match",
22220
22378
  path: ["password_confirmation"]
22221
22379
  });
22380
+ var RegisterViaInvitationSchema = z2.object({
22381
+ email: z2.string().email(),
22382
+ password: z2.string().min(8),
22383
+ password_confirmation: z2.string().min(8),
22384
+ invitation_token: z2.string().min(1)
22385
+ }).refine((data) => data.password === data.password_confirmation, {
22386
+ message: "Passwords do not match",
22387
+ path: ["password_confirmation"]
22388
+ });
22222
22389
  function createIdentityNamespace(rb, baseUrl) {
22223
22390
  return {
22224
22391
  /**
@@ -22307,6 +22474,57 @@ function createIdentityNamespace(rb, baseUrl) {
22307
22474
  options
22308
22475
  );
22309
22476
  },
22477
+ /**
22478
+ * Register a new user via invitation — skips personal tenant creation.
22479
+ *
22480
+ * Creates the user account, accepts the invitation (creating tenant/workspace
22481
+ * memberships), and returns the authenticated user with a session token.
22482
+ * The email must match the invitation's recipient email.
22483
+ *
22484
+ * @param email - Must match the invitation recipient email
22485
+ * @param password - Minimum 8 characters
22486
+ * @param passwordConfirmation - Must match password
22487
+ * @param invitationToken - Raw token from the invitation email link
22488
+ * @param attrs - Optional extra attributes (first_name, last_name)
22489
+ * @param options - Optional request options
22490
+ * @returns The newly created `User` with session token
22491
+ *
22492
+ * @example
22493
+ * ```typescript
22494
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
22495
+ * const user = await client.identity.registerViaInvitation(
22496
+ * 'invited@example.com', 'securepass', 'securepass', 'raw-token-from-email',
22497
+ * { first_name: 'Jane', last_name: 'Doe' },
22498
+ * );
22499
+ * console.log(user.token); // JWT session token
22500
+ * ```
22501
+ */
22502
+ registerViaInvitation: async (email, password, passwordConfirmation, invitationToken, attrs, options) => {
22503
+ RegisterViaInvitationSchema.parse({
22504
+ email,
22505
+ password,
22506
+ password_confirmation: passwordConfirmation,
22507
+ invitation_token: invitationToken
22508
+ });
22509
+ return rb.execute(
22510
+ postUsersAuthRegisterViaInvitation,
22511
+ {
22512
+ body: {
22513
+ data: {
22514
+ type: "user",
22515
+ attributes: {
22516
+ email,
22517
+ password,
22518
+ password_confirmation: passwordConfirmation,
22519
+ invitation_token: invitationToken,
22520
+ ...attrs
22521
+ }
22522
+ }
22523
+ }
22524
+ },
22525
+ options
22526
+ );
22527
+ },
22310
22528
  /** Get the currently authenticated user */
22311
22529
  me: async (options) => {
22312
22530
  return rb.execute(getUsersMe, {}, options);
@@ -23457,26 +23675,56 @@ function createPlatformNamespace(rb) {
23457
23675
  );
23458
23676
  },
23459
23677
  /**
23460
- * Delete a tenant and all associated data.
23678
+ * Deactivate a tenant (hide from user's account).
23461
23679
  *
23462
- * Permanently removes the tenant, all their workspaces, documents, and
23463
- * billing records. This operation is irreversible. For a graceful
23464
- * off-boarding, prefer `schedulePurge` which allows data export before
23465
- * deletion.
23680
+ * Sets `deactivated_at` on the tenant. The tenant and its workspaces
23681
+ * disappear from `workspaces.mine()` and tenant listings. Billing and
23682
+ * data are completely unaffected. Reversible via `reactivate()`.
23466
23683
  *
23467
- * @param id - The UUID of the tenant to delete.
23684
+ * Only the tenant owner can deactivate.
23685
+ *
23686
+ * @param id - The UUID of the tenant to deactivate.
23468
23687
  * @param options - Optional request options.
23469
- * @returns `true` on successful deletion.
23688
+ * @returns The updated tenant record.
23470
23689
  *
23471
23690
  * @example
23472
23691
  * ```typescript
23473
- * const client = new GptClient({ apiKey: 'sk_app_...' });
23474
- * await client.platform.tenants.delete('tenant_abc123');
23692
+ * await client.platform.tenants.deactivate('tenant_abc123');
23475
23693
  * ```
23476
23694
  */
23477
- delete: async (id, options) => {
23478
- return rb.executeDelete(deleteTenantsById, { path: { id } }, options);
23479
- },
23695
+ deactivate: async (id, options) => rb.execute(
23696
+ patchTenantsByIdDeactivate,
23697
+ {
23698
+ path: { id },
23699
+ body: { data: { type: "tenant", id, attributes: {} } }
23700
+ },
23701
+ options
23702
+ ),
23703
+ /**
23704
+ * Reactivate a previously deactivated tenant.
23705
+ *
23706
+ * Clears `deactivated_at`, restoring the tenant and its workspaces
23707
+ * to the user's account. Only works on deactivated tenants.
23708
+ *
23709
+ * Only the tenant owner can reactivate.
23710
+ *
23711
+ * @param id - The UUID of the tenant to reactivate.
23712
+ * @param options - Optional request options.
23713
+ * @returns The updated tenant record.
23714
+ *
23715
+ * @example
23716
+ * ```typescript
23717
+ * await client.platform.tenants.reactivate('tenant_abc123');
23718
+ * ```
23719
+ */
23720
+ reactivate: async (id, options) => rb.execute(
23721
+ patchTenantsByIdReactivate,
23722
+ {
23723
+ path: { id },
23724
+ body: { data: { type: "tenant", id, attributes: {} } }
23725
+ },
23726
+ options
23727
+ ),
23480
23728
  /**
23481
23729
  * Create a new tenant (ISV provisioning flow).
23482
23730
  *
@@ -23847,6 +24095,52 @@ function createPlatformNamespace(rb) {
23847
24095
  options
23848
24096
  );
23849
24097
  },
24098
+ /**
24099
+ * List invitations visible to the current actor.
24100
+ *
24101
+ * Returns invitations where the actor is the inviter, the tenant owner,
24102
+ * or the recipient (matched by email). Use this to build admin views
24103
+ * of pending/accepted invitations for a tenant or workspace.
24104
+ *
24105
+ * @param options - Optional page number, page size, and request options.
24106
+ * @returns A page of `Invitation` records.
24107
+ *
24108
+ * @example
24109
+ * ```typescript
24110
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
24111
+ * const invites = await client.platform.invitations.list();
24112
+ * ```
24113
+ */
24114
+ list: async (options) => {
24115
+ return rb.execute(
24116
+ getInvitations,
24117
+ buildPageQuery(options?.page, options?.pageSize),
24118
+ options
24119
+ );
24120
+ },
24121
+ /**
24122
+ * List all invitations visible to the current actor, auto-paginating.
24123
+ *
24124
+ * @param options - Optional request options.
24125
+ * @returns All visible `Invitation` records as a flat array.
24126
+ *
24127
+ * @example
24128
+ * ```typescript
24129
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
24130
+ * const all = await client.platform.invitations.listAll();
24131
+ * ```
24132
+ */
24133
+ listAll: async (options) => {
24134
+ return paginateToArray(
24135
+ rb.createPaginatedFetcher(
24136
+ getInvitations,
24137
+ (page, pageSize) => ({
24138
+ query: { page: { number: page, size: pageSize } }
24139
+ }),
24140
+ options
24141
+ )
24142
+ );
24143
+ },
23850
24144
  /**
23851
24145
  * Look up a pending invitation by its raw token.
23852
24146
  *