@gpt-platform/client 0.4.2 → 0.4.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.d.mts +7917 -7388
- package/dist/index.d.ts +7917 -7388
- package/dist/index.js +687 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +684 -87
- package/dist/index.mjs.map +1 -1
- package/llms.txt +25 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -901,6 +901,34 @@ var ConflictError = class extends GptCoreError {
|
|
|
901
901
|
super(message, { statusCode: 409, code: "conflict_error", ...options });
|
|
902
902
|
}
|
|
903
903
|
};
|
|
904
|
+
var PaymentRequiredError = class extends GptCoreError {
|
|
905
|
+
constructor(message = "Payment required", options) {
|
|
906
|
+
super(message, {
|
|
907
|
+
statusCode: 402,
|
|
908
|
+
code: "payment_required",
|
|
909
|
+
...options
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
var CardDeclinedError = class extends GptCoreError {
|
|
914
|
+
constructor(message = "Card declined", declineCode, options) {
|
|
915
|
+
super(message, {
|
|
916
|
+
statusCode: 402,
|
|
917
|
+
code: "card_declined",
|
|
918
|
+
...options
|
|
919
|
+
});
|
|
920
|
+
this.declineCode = declineCode;
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
var SubscriptionConflictError = class extends GptCoreError {
|
|
924
|
+
constructor(message = "Subscription conflict", options) {
|
|
925
|
+
super(message, {
|
|
926
|
+
statusCode: 409,
|
|
927
|
+
code: "subscription_conflict",
|
|
928
|
+
...options
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
};
|
|
904
932
|
function handleApiError(error) {
|
|
905
933
|
if (typeof error !== "object" || error === null) {
|
|
906
934
|
throw new NetworkError(
|
|
@@ -909,7 +937,7 @@ function handleApiError(error) {
|
|
|
909
937
|
}
|
|
910
938
|
const err = error;
|
|
911
939
|
const response = err.response || err;
|
|
912
|
-
|
|
940
|
+
let statusCode = response.status || err.status || err.statusCode;
|
|
913
941
|
const headers = response.headers || err.headers;
|
|
914
942
|
const requestId = (headers && typeof headers === "object" && "get" in headers ? headers.get("x-request-id") : headers?.["x-request-id"]) || void 0;
|
|
915
943
|
const body = response.body || response.data || err.body || err.data || err;
|
|
@@ -923,6 +951,10 @@ function handleApiError(error) {
|
|
|
923
951
|
field: err2.source?.pointer?.split("/").pop(),
|
|
924
952
|
message: err2.detail || err2.title || "Unknown error"
|
|
925
953
|
}));
|
|
954
|
+
if (!statusCode && firstError?.status) {
|
|
955
|
+
const parsed = parseInt(firstError.status, 10);
|
|
956
|
+
if (!isNaN(parsed)) statusCode = parsed;
|
|
957
|
+
}
|
|
926
958
|
} else if (typeof body === "object" && body !== null && "message" in body && typeof body.message === "string") {
|
|
927
959
|
message = body.message;
|
|
928
960
|
} else if (typeof body === "string") {
|
|
@@ -969,8 +1001,21 @@ function handleApiError(error) {
|
|
|
969
1001
|
throw new AuthorizationError(message, errorOptions);
|
|
970
1002
|
case 404:
|
|
971
1003
|
throw new NotFoundError(message, errorOptions);
|
|
972
|
-
case
|
|
1004
|
+
case 402: {
|
|
1005
|
+
const bodyCode = typeof body === "object" && body !== null && "code" in body ? body.code : void 0;
|
|
1006
|
+
const declineCode = typeof body === "object" && body !== null && "decline_code" in body ? body.decline_code : void 0;
|
|
1007
|
+
if (bodyCode === "card_declined") {
|
|
1008
|
+
throw new CardDeclinedError(message, declineCode, errorOptions);
|
|
1009
|
+
}
|
|
1010
|
+
throw new PaymentRequiredError(message, errorOptions);
|
|
1011
|
+
}
|
|
1012
|
+
case 409: {
|
|
1013
|
+
const bodyCode409 = typeof body === "object" && body !== null && "code" in body ? body.code : void 0;
|
|
1014
|
+
if (bodyCode409 === "subscription_conflict") {
|
|
1015
|
+
throw new SubscriptionConflictError(message, errorOptions);
|
|
1016
|
+
}
|
|
973
1017
|
throw new ConflictError(message, errorOptions);
|
|
1018
|
+
}
|
|
974
1019
|
case 400:
|
|
975
1020
|
case 422:
|
|
976
1021
|
throw new ValidationError(message, errors, errorOptions);
|
|
@@ -1224,7 +1269,7 @@ function buildUserAgent(sdkVersion, appInfo) {
|
|
|
1224
1269
|
}
|
|
1225
1270
|
|
|
1226
1271
|
// src/version.ts
|
|
1227
|
-
var SDK_VERSION = "0.4.
|
|
1272
|
+
var SDK_VERSION = "0.4.3";
|
|
1228
1273
|
var DEFAULT_API_VERSION = "2026-02-27";
|
|
1229
1274
|
|
|
1230
1275
|
// src/base-client.ts
|
|
@@ -1737,6 +1782,11 @@ var patchApiKeysByIdRotate = (options) => (options.client ?? client).patch({
|
|
|
1737
1782
|
...options.headers
|
|
1738
1783
|
}
|
|
1739
1784
|
});
|
|
1785
|
+
var getApplicationsCurrent = (options) => (options.client ?? client).get({
|
|
1786
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1787
|
+
url: "/applications/current",
|
|
1788
|
+
...options
|
|
1789
|
+
});
|
|
1740
1790
|
var patchWorkspaceMembershipsByWorkspaceIdByUserIdProfile = (options) => (options.client ?? client).patch({
|
|
1741
1791
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1742
1792
|
url: "/workspace-memberships/{workspace_id}/{user_id}/profile",
|
|
@@ -1746,6 +1796,15 @@ var patchWorkspaceMembershipsByWorkspaceIdByUserIdProfile = (options) => (option
|
|
|
1746
1796
|
...options.headers
|
|
1747
1797
|
}
|
|
1748
1798
|
});
|
|
1799
|
+
var postInvitationsAcceptByToken = (options) => (options.client ?? client).post({
|
|
1800
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1801
|
+
url: "/invitations/accept-by-token",
|
|
1802
|
+
...options,
|
|
1803
|
+
headers: {
|
|
1804
|
+
"Content-Type": "application/vnd.api+json",
|
|
1805
|
+
...options.headers
|
|
1806
|
+
}
|
|
1807
|
+
});
|
|
1749
1808
|
var getWorkspaces = (options) => (options.client ?? client).get({
|
|
1750
1809
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1751
1810
|
url: "/workspaces",
|
|
@@ -1784,6 +1843,11 @@ var getAgentsByIdStats = (options) => (options.client ?? client).get({
|
|
|
1784
1843
|
url: "/agents/{id}/stats",
|
|
1785
1844
|
...options
|
|
1786
1845
|
});
|
|
1846
|
+
var getSchedulingEventsByParticipant = (options) => (options.client ?? client).get({
|
|
1847
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1848
|
+
url: "/scheduling/events/by_participant",
|
|
1849
|
+
...options
|
|
1850
|
+
});
|
|
1787
1851
|
var getEmailTrackingEventsById = (options) => (options.client ?? client).get({
|
|
1788
1852
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1789
1853
|
url: "/email/tracking-events/{id}",
|
|
@@ -1837,15 +1901,6 @@ var patchCrmDealsById = (options) => (options.client ?? client).patch({
|
|
|
1837
1901
|
...options.headers
|
|
1838
1902
|
}
|
|
1839
1903
|
});
|
|
1840
|
-
var postUsersAuthResetPasswordRequest = (options) => (options.client ?? client).post({
|
|
1841
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1842
|
-
url: "/users/auth/reset-password/request",
|
|
1843
|
-
...options,
|
|
1844
|
-
headers: {
|
|
1845
|
-
"Content-Type": "application/vnd.api+json",
|
|
1846
|
-
...options.headers
|
|
1847
|
-
}
|
|
1848
|
-
});
|
|
1849
1904
|
var getSupportTagsWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
|
|
1850
1905
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1851
1906
|
url: "/support/tags/workspace/{workspace_id}",
|
|
@@ -1977,6 +2032,11 @@ var getAgentsByIdTrainingExamples = (options) => (options.client ?? client).get(
|
|
|
1977
2032
|
url: "/agents/{id}/training-examples",
|
|
1978
2033
|
...options
|
|
1979
2034
|
});
|
|
2035
|
+
var getInvitationsConsumeByToken = (options) => (options.client ?? client).get({
|
|
2036
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2037
|
+
url: "/invitations/consume/{token}",
|
|
2038
|
+
...options
|
|
2039
|
+
});
|
|
1980
2040
|
var postEmailMarketingCampaignsByIdOptimizeSendTimes = (options) => (options.client ?? client).post({
|
|
1981
2041
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1982
2042
|
url: "/email-marketing/campaigns/{id}/optimize-send-times",
|
|
@@ -2043,6 +2103,15 @@ var patchRetentionPoliciesById = (options) => (options.client ?? client).patch({
|
|
|
2043
2103
|
...options.headers
|
|
2044
2104
|
}
|
|
2045
2105
|
});
|
|
2106
|
+
var patchInvitationsByIdRevoke = (options) => (options.client ?? client).patch({
|
|
2107
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2108
|
+
url: "/invitations/{id}/revoke",
|
|
2109
|
+
...options,
|
|
2110
|
+
headers: {
|
|
2111
|
+
"Content-Type": "application/vnd.api+json",
|
|
2112
|
+
...options.headers
|
|
2113
|
+
}
|
|
2114
|
+
});
|
|
2046
2115
|
var getCatalogTaxonomiesApplicationByApplicationId = (options) => (options.client ?? client).get({
|
|
2047
2116
|
security: [{ scheme: "bearer", type: "http" }],
|
|
2048
2117
|
url: "/catalog/taxonomies/application/{application_id}",
|
|
@@ -2348,6 +2417,15 @@ var getEmailMarketingUnsubscribersWorkspaceByWorkspaceId = (options) => (options
|
|
|
2348
2417
|
url: "/email-marketing/unsubscribers/workspace/{workspace_id}",
|
|
2349
2418
|
...options
|
|
2350
2419
|
});
|
|
2420
|
+
var patchInvitationsByIdResend = (options) => (options.client ?? client).patch({
|
|
2421
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2422
|
+
url: "/invitations/{id}/resend",
|
|
2423
|
+
...options,
|
|
2424
|
+
headers: {
|
|
2425
|
+
"Content-Type": "application/vnd.api+json",
|
|
2426
|
+
...options.headers
|
|
2427
|
+
}
|
|
2428
|
+
});
|
|
2351
2429
|
var getSearchSaved = (options) => (options.client ?? client).get({
|
|
2352
2430
|
security: [{ scheme: "bearer", type: "http" }],
|
|
2353
2431
|
url: "/search/saved",
|
|
@@ -2593,6 +2671,15 @@ var postSupportTickets = (options) => (options.client ?? client).post({
|
|
|
2593
2671
|
...options.headers
|
|
2594
2672
|
}
|
|
2595
2673
|
});
|
|
2674
|
+
var patchInvitationsByIdAccept = (options) => (options.client ?? client).patch({
|
|
2675
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2676
|
+
url: "/invitations/{id}/accept",
|
|
2677
|
+
...options,
|
|
2678
|
+
headers: {
|
|
2679
|
+
"Content-Type": "application/vnd.api+json",
|
|
2680
|
+
...options.headers
|
|
2681
|
+
}
|
|
2682
|
+
});
|
|
2596
2683
|
var getCreditPackagesById = (options) => (options.client ?? client).get({
|
|
2597
2684
|
security: [{ scheme: "bearer", type: "http" }],
|
|
2598
2685
|
url: "/credit-packages/{id}",
|
|
@@ -2786,6 +2873,20 @@ var getSchedulingBookingsById = (options) => (options.client ?? client).get({
|
|
|
2786
2873
|
url: "/scheduling/bookings/{id}",
|
|
2787
2874
|
...options
|
|
2788
2875
|
});
|
|
2876
|
+
var getTenantMemberships = (options) => (options.client ?? client).get({
|
|
2877
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2878
|
+
url: "/tenant-memberships",
|
|
2879
|
+
...options
|
|
2880
|
+
});
|
|
2881
|
+
var postTenantMemberships = (options) => (options.client ?? client).post({
|
|
2882
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2883
|
+
url: "/tenant-memberships",
|
|
2884
|
+
...options,
|
|
2885
|
+
headers: {
|
|
2886
|
+
"Content-Type": "application/vnd.api+json",
|
|
2887
|
+
...options.headers
|
|
2888
|
+
}
|
|
2889
|
+
});
|
|
2789
2890
|
var getWebhookDeliveriesById = (options) => (options.client ?? client).get({
|
|
2790
2891
|
security: [{ scheme: "bearer", type: "http" }],
|
|
2791
2892
|
url: "/webhook-deliveries/{id}",
|
|
@@ -3388,6 +3489,11 @@ var getEmailTrackingEventsWorkspaceByWorkspaceId = (options) => (options.client
|
|
|
3388
3489
|
url: "/email/tracking-events/workspace/{workspace_id}",
|
|
3389
3490
|
...options
|
|
3390
3491
|
});
|
|
3492
|
+
var getTenants = (options) => (options.client ?? client).get({
|
|
3493
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
3494
|
+
url: "/tenants",
|
|
3495
|
+
...options
|
|
3496
|
+
});
|
|
3391
3497
|
var getExtractionSchemaDiscoveriesById = (options) => (options.client ?? client).get({
|
|
3392
3498
|
security: [{ scheme: "bearer", type: "http" }],
|
|
3393
3499
|
url: "/extraction/schema-discoveries/{id}",
|
|
@@ -3797,6 +3903,15 @@ var getApplicationsById = (options) => (options.client ?? client).get({
|
|
|
3797
3903
|
url: "/applications/{id}",
|
|
3798
3904
|
...options
|
|
3799
3905
|
});
|
|
3906
|
+
var patchApplicationsById = (options) => (options.client ?? client).patch({
|
|
3907
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
3908
|
+
url: "/applications/{id}",
|
|
3909
|
+
...options,
|
|
3910
|
+
headers: {
|
|
3911
|
+
"Content-Type": "application/vnd.api+json",
|
|
3912
|
+
...options.headers
|
|
3913
|
+
}
|
|
3914
|
+
});
|
|
3800
3915
|
var patchEmailOutboundEmailsByIdSchedule = (options) => (options.client ?? client).patch({
|
|
3801
3916
|
security: [{ scheme: "bearer", type: "http" }],
|
|
3802
3917
|
url: "/email/outbound-emails/{id}/schedule",
|
|
@@ -4271,15 +4386,6 @@ var getExtractionDocumentsWorkspaceByWorkspaceId = (options) => (options.client
|
|
|
4271
4386
|
url: "/extraction/documents/workspace/{workspace_id}",
|
|
4272
4387
|
...options
|
|
4273
4388
|
});
|
|
4274
|
-
var patchApplicationsByIdAllocateCredits = (options) => (options.client ?? client).patch({
|
|
4275
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
4276
|
-
url: "/applications/{id}/allocate-credits",
|
|
4277
|
-
...options,
|
|
4278
|
-
headers: {
|
|
4279
|
-
"Content-Type": "application/vnd.api+json",
|
|
4280
|
-
...options.headers
|
|
4281
|
-
}
|
|
4282
|
-
});
|
|
4283
4389
|
var postUsersAuthMagicLinkRequest = (options) => (options.client ?? client).post({
|
|
4284
4390
|
security: [{ scheme: "bearer", type: "http" }],
|
|
4285
4391
|
url: "/users/auth/magic-link/request",
|
|
@@ -4378,6 +4484,25 @@ var getExtractionDocuments = (options) => (options.client ?? client).get({
|
|
|
4378
4484
|
url: "/extraction/documents",
|
|
4379
4485
|
...options
|
|
4380
4486
|
});
|
|
4487
|
+
var getDataStoreRecordsByNamespace = (options) => (options.client ?? client).get({
|
|
4488
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
4489
|
+
url: "/data_store/records/by_namespace",
|
|
4490
|
+
...options
|
|
4491
|
+
});
|
|
4492
|
+
var deleteTenantMembershipsByTenantIdByUserId = (options) => (options.client ?? client).delete({
|
|
4493
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
4494
|
+
url: "/tenant-memberships/{tenant_id}/{user_id}",
|
|
4495
|
+
...options
|
|
4496
|
+
});
|
|
4497
|
+
var patchTenantMembershipsByTenantIdByUserId = (options) => (options.client ?? client).patch({
|
|
4498
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
4499
|
+
url: "/tenant-memberships/{tenant_id}/{user_id}",
|
|
4500
|
+
...options,
|
|
4501
|
+
headers: {
|
|
4502
|
+
"Content-Type": "application/vnd.api+json",
|
|
4503
|
+
...options.headers
|
|
4504
|
+
}
|
|
4505
|
+
});
|
|
4381
4506
|
var getCrmDealsWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
|
|
4382
4507
|
security: [{ scheme: "bearer", type: "http" }],
|
|
4383
4508
|
url: "/crm/deals/workspace/{workspace_id}",
|
|
@@ -4842,6 +4967,11 @@ var deleteWorkspaceMembershipsByWorkspaceIdByUserId = (options) => (options.clie
|
|
|
4842
4967
|
url: "/workspace-memberships/{workspace_id}/{user_id}",
|
|
4843
4968
|
...options
|
|
4844
4969
|
});
|
|
4970
|
+
var getWorkspaceMembershipsByWorkspaceIdByUserId = (options) => (options.client ?? client).get({
|
|
4971
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
4972
|
+
url: "/workspace-memberships/{workspace_id}/{user_id}",
|
|
4973
|
+
...options
|
|
4974
|
+
});
|
|
4845
4975
|
var patchWorkspaceMembershipsByWorkspaceIdByUserId = (options) => (options.client ?? client).patch({
|
|
4846
4976
|
security: [{ scheme: "bearer", type: "http" }],
|
|
4847
4977
|
url: "/workspace-memberships/{workspace_id}/{user_id}",
|
|
@@ -4894,6 +5024,15 @@ var getUsers = (options) => (options.client ?? client).get({
|
|
|
4894
5024
|
url: "/users",
|
|
4895
5025
|
...options
|
|
4896
5026
|
});
|
|
5027
|
+
var postDataStoreRecordsUpsert = (options) => (options.client ?? client).post({
|
|
5028
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
5029
|
+
url: "/data_store/records/upsert",
|
|
5030
|
+
...options,
|
|
5031
|
+
headers: {
|
|
5032
|
+
"Content-Type": "application/vnd.api+json",
|
|
5033
|
+
...options.headers
|
|
5034
|
+
}
|
|
5035
|
+
});
|
|
4897
5036
|
var deleteSupportTicketsById = (options) => (options.client ?? client).delete({
|
|
4898
5037
|
security: [{ scheme: "bearer", type: "http" }],
|
|
4899
5038
|
url: "/support/tickets/{id}",
|
|
@@ -7188,6 +7327,9 @@ function createBillingNamespace(rb) {
|
|
|
7188
7327
|
* Preview the cost and effective date of a plan change before committing.
|
|
7189
7328
|
*
|
|
7190
7329
|
* @param planSlug - The slug of the target plan (e.g. `"pro-monthly"`).
|
|
7330
|
+
* @returns A projected `Wallet` representing the hypothetical post-change
|
|
7331
|
+
* state — **not** the caller's current wallet. Do not cache or use this
|
|
7332
|
+
* as live balance data. Call `wallet.get()` for authoritative state.
|
|
7191
7333
|
*/
|
|
7192
7334
|
previewPlanChange: async (planSlug, options) => {
|
|
7193
7335
|
return rb.execute(
|
|
@@ -7199,14 +7341,41 @@ function createBillingNamespace(rb) {
|
|
|
7199
7341
|
/**
|
|
7200
7342
|
* Change the workspace's subscription plan.
|
|
7201
7343
|
*
|
|
7344
|
+
* Two call signatures:
|
|
7345
|
+
* - `changePlan(planSlug)` — fetches the wallet automatically (recommended)
|
|
7346
|
+
* - `changePlan(walletId, planSlug)` — use when you already have the wallet ID
|
|
7347
|
+
*
|
|
7202
7348
|
* Upgrades charge a prorated amount immediately against the default payment
|
|
7203
7349
|
* method. Downgrades are deferred to the end of the current billing period.
|
|
7204
7350
|
* Use `previewPlanChange` first to show the user a cost estimate.
|
|
7205
7351
|
*
|
|
7206
|
-
* @
|
|
7207
|
-
*
|
|
7352
|
+
* @example
|
|
7353
|
+
* ```typescript
|
|
7354
|
+
* // Simple form — no wallet ID needed
|
|
7355
|
+
* await client.billing.wallet.changePlan("pro-monthly");
|
|
7356
|
+
*
|
|
7357
|
+
* // Explicit form — when walletId is already known
|
|
7358
|
+
* await client.billing.wallet.changePlan(wallet.id, "pro-monthly");
|
|
7359
|
+
* ```
|
|
7208
7360
|
*/
|
|
7209
|
-
changePlan: async (
|
|
7361
|
+
changePlan: async (walletIdOrSlug, planSlugOrOptions, options) => {
|
|
7362
|
+
let walletId;
|
|
7363
|
+
let planSlug;
|
|
7364
|
+
let reqOptions;
|
|
7365
|
+
if (typeof planSlugOrOptions === "string") {
|
|
7366
|
+
walletId = walletIdOrSlug;
|
|
7367
|
+
planSlug = planSlugOrOptions;
|
|
7368
|
+
reqOptions = options;
|
|
7369
|
+
} else {
|
|
7370
|
+
const wallet = await rb.execute(
|
|
7371
|
+
getWallet,
|
|
7372
|
+
{},
|
|
7373
|
+
planSlugOrOptions
|
|
7374
|
+
);
|
|
7375
|
+
walletId = wallet.id;
|
|
7376
|
+
planSlug = walletIdOrSlug;
|
|
7377
|
+
reqOptions = planSlugOrOptions;
|
|
7378
|
+
}
|
|
7210
7379
|
return rb.execute(
|
|
7211
7380
|
patchWalletPlan,
|
|
7212
7381
|
{
|
|
@@ -7218,7 +7387,7 @@ function createBillingNamespace(rb) {
|
|
|
7218
7387
|
}
|
|
7219
7388
|
}
|
|
7220
7389
|
},
|
|
7221
|
-
|
|
7390
|
+
reqOptions
|
|
7222
7391
|
);
|
|
7223
7392
|
},
|
|
7224
7393
|
/**
|
|
@@ -7687,8 +7856,12 @@ function createBillingNamespace(rb) {
|
|
|
7687
7856
|
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
7688
7857
|
*
|
|
7689
7858
|
* const method = await client.billing.paymentMethods.create({
|
|
7690
|
-
*
|
|
7691
|
-
*
|
|
7859
|
+
* provider_token: 'tok_visa_4242',
|
|
7860
|
+
* type: 'card',
|
|
7861
|
+
* last4: '4242',
|
|
7862
|
+
* exp_month: 12,
|
|
7863
|
+
* exp_year: 2027,
|
|
7864
|
+
* brand: 'Visa',
|
|
7692
7865
|
* });
|
|
7693
7866
|
* console.log(`Added card ending in ${method.last4}`);
|
|
7694
7867
|
* ```
|
|
@@ -7703,14 +7876,21 @@ function createBillingNamespace(rb) {
|
|
|
7703
7876
|
/**
|
|
7704
7877
|
* Tokenizes a raw card server-side and saves the resulting payment method.
|
|
7705
7878
|
*
|
|
7706
|
-
*
|
|
7707
|
-
*
|
|
7708
|
-
*
|
|
7879
|
+
* @remarks **SERVER-SIDE ONLY — PCI-DSS.**
|
|
7880
|
+
* This method transmits raw card numbers (`card_number`, `cvc`) over the
|
|
7881
|
+
* network. It **must only be called from a trusted server context** (Node.js,
|
|
7882
|
+
* server-side rendering). Calling this method from browser/client-side code
|
|
7883
|
+
* (React, Vue, browser fetch) is a **PCI-DSS violation** — raw card numbers
|
|
7884
|
+
* must never pass through browser memory or JavaScript bundles.
|
|
7885
|
+
*
|
|
7886
|
+
* For browser flows, use the payment provider's hosted fields iframe to tokenize
|
|
7887
|
+
* on the client side, then call `paymentMethods.create({ provider_token })` instead.
|
|
7709
7888
|
*
|
|
7710
|
-
*
|
|
7711
|
-
*
|
|
7889
|
+
* The platform forwards `cardDetails` to the payment gateway over TLS and stores
|
|
7890
|
+
* only the resulting token — raw card data is never persisted.
|
|
7712
7891
|
*
|
|
7713
|
-
* @param cardDetails - Raw card fields
|
|
7892
|
+
* @param cardDetails - Raw PCI-sensitive card fields. All fields must be treated
|
|
7893
|
+
* as sensitive: do not log, serialize, or pass through error reporters.
|
|
7714
7894
|
*/
|
|
7715
7895
|
tokenize: async (cardDetails, options) => {
|
|
7716
7896
|
return rb.execute(
|
|
@@ -16144,8 +16324,12 @@ function createIdentityNamespace(rb, baseUrl) {
|
|
|
16144
16324
|
);
|
|
16145
16325
|
},
|
|
16146
16326
|
/** Resend confirmation email to an unconfirmed user */
|
|
16147
|
-
resendConfirmation: async (options) => {
|
|
16148
|
-
return rb.execute(
|
|
16327
|
+
resendConfirmation: async (email, options) => {
|
|
16328
|
+
return rb.execute(
|
|
16329
|
+
postUsersAuthResendConfirmation,
|
|
16330
|
+
{ body: { data: { type: "user", attributes: { email } } } },
|
|
16331
|
+
options
|
|
16332
|
+
);
|
|
16149
16333
|
},
|
|
16150
16334
|
/** Confirm an email address using the token from the confirmation email */
|
|
16151
16335
|
confirmEmail: async (email, confirmationToken, options) => {
|
|
@@ -16186,7 +16370,7 @@ function createIdentityNamespace(rb, baseUrl) {
|
|
|
16186
16370
|
requestPasswordReset: async (email, options) => {
|
|
16187
16371
|
RequestPasswordResetSchema.parse({ email });
|
|
16188
16372
|
return rb.execute(
|
|
16189
|
-
|
|
16373
|
+
patchUsersAuthResetPassword,
|
|
16190
16374
|
{
|
|
16191
16375
|
body: {
|
|
16192
16376
|
data: { type: "user", attributes: { email } }
|
|
@@ -17064,7 +17248,7 @@ function createPlatformNamespace(rb) {
|
|
|
17064
17248
|
*/
|
|
17065
17249
|
update: async (id, attributes, options) => {
|
|
17066
17250
|
return rb.execute(
|
|
17067
|
-
|
|
17251
|
+
patchApplicationsById,
|
|
17068
17252
|
{
|
|
17069
17253
|
path: { id },
|
|
17070
17254
|
body: { data: { id, type: "application", attributes } }
|
|
@@ -17111,7 +17295,7 @@ function createPlatformNamespace(rb) {
|
|
|
17111
17295
|
* ```
|
|
17112
17296
|
*/
|
|
17113
17297
|
readCurrent: async (options) => {
|
|
17114
|
-
return rb.execute(
|
|
17298
|
+
return rb.execute(getApplicationsCurrent, {}, options);
|
|
17115
17299
|
}
|
|
17116
17300
|
},
|
|
17117
17301
|
/**
|
|
@@ -17122,6 +17306,21 @@ function createPlatformNamespace(rb) {
|
|
|
17122
17306
|
* ISVs provision tenants when onboarding new customers.
|
|
17123
17307
|
*/
|
|
17124
17308
|
tenants: {
|
|
17309
|
+
/**
|
|
17310
|
+
* List all tenants (paginated).
|
|
17311
|
+
*
|
|
17312
|
+
* Returns tenants accessible to the current actor (application-scoped).
|
|
17313
|
+
*
|
|
17314
|
+
* @param options - Optional page number, page size, and request options.
|
|
17315
|
+
* @returns A page of `Tenant` records.
|
|
17316
|
+
*/
|
|
17317
|
+
list: async (options) => {
|
|
17318
|
+
return rb.execute(
|
|
17319
|
+
getTenants,
|
|
17320
|
+
buildPageQuery(options?.page, options?.pageSize),
|
|
17321
|
+
options
|
|
17322
|
+
);
|
|
17323
|
+
},
|
|
17125
17324
|
/**
|
|
17126
17325
|
* List document statistics for tenants (paginated).
|
|
17127
17326
|
*
|
|
@@ -17138,30 +17337,35 @@ function createPlatformNamespace(rb) {
|
|
|
17138
17337
|
* stats.forEach(s => console.log(s.attributes?.document_count));
|
|
17139
17338
|
* ```
|
|
17140
17339
|
*/
|
|
17141
|
-
listDocumentStats: async (options) => {
|
|
17340
|
+
listDocumentStats: async (tenantId, options) => {
|
|
17142
17341
|
return rb.execute(
|
|
17143
17342
|
getTenantsByTenantIdDocumentStats,
|
|
17144
|
-
|
|
17343
|
+
{
|
|
17344
|
+
path: { tenant_id: tenantId },
|
|
17345
|
+
...buildPageQuery(options?.page, options?.pageSize)
|
|
17346
|
+
},
|
|
17145
17347
|
options
|
|
17146
17348
|
);
|
|
17147
17349
|
},
|
|
17148
17350
|
/**
|
|
17149
17351
|
* List all document statistics for tenants, auto-paginating.
|
|
17150
17352
|
*
|
|
17353
|
+
* @param tenantId - The UUID of the tenant.
|
|
17151
17354
|
* @param options - Optional request options.
|
|
17152
17355
|
* @returns All tenant document stat records as a flat array.
|
|
17153
17356
|
*
|
|
17154
17357
|
* @example
|
|
17155
17358
|
* ```typescript
|
|
17156
17359
|
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
17157
|
-
* const allStats = await client.platform.tenants.listAllDocumentStats();
|
|
17360
|
+
* const allStats = await client.platform.tenants.listAllDocumentStats('tenant_abc123');
|
|
17158
17361
|
* ```
|
|
17159
17362
|
*/
|
|
17160
|
-
listAllDocumentStats: async (options) => {
|
|
17363
|
+
listAllDocumentStats: async (tenantId, options) => {
|
|
17161
17364
|
return paginateToArray(
|
|
17162
17365
|
rb.createPaginatedFetcher(
|
|
17163
17366
|
getTenantsByTenantIdDocumentStats,
|
|
17164
17367
|
(page, pageSize) => ({
|
|
17368
|
+
path: { tenant_id: tenantId },
|
|
17165
17369
|
query: { page: { number: page, size: pageSize } }
|
|
17166
17370
|
}),
|
|
17167
17371
|
options
|
|
@@ -17186,10 +17390,15 @@ function createPlatformNamespace(rb) {
|
|
|
17186
17390
|
* console.log(tenant.attributes?.credit_balance);
|
|
17187
17391
|
* ```
|
|
17188
17392
|
*/
|
|
17189
|
-
credit: async (id, options) => {
|
|
17393
|
+
credit: async (id, amount, description, options) => {
|
|
17394
|
+
const attributes = { amount };
|
|
17395
|
+
if (description !== void 0) attributes.description = description;
|
|
17190
17396
|
return rb.execute(
|
|
17191
17397
|
postTenantsByIdCredit,
|
|
17192
|
-
{
|
|
17398
|
+
{
|
|
17399
|
+
path: { id },
|
|
17400
|
+
body: { data: { type: "tenant", attributes } }
|
|
17401
|
+
},
|
|
17193
17402
|
options
|
|
17194
17403
|
);
|
|
17195
17404
|
},
|
|
@@ -17297,24 +17506,6 @@ function createPlatformNamespace(rb) {
|
|
|
17297
17506
|
);
|
|
17298
17507
|
},
|
|
17299
17508
|
/**
|
|
17300
|
-
* Add a payment method to a tenant via raw details (server-to-server proxy).
|
|
17301
|
-
*
|
|
17302
|
-
* Proxies payment method registration to the underlying payment provider
|
|
17303
|
-
* on behalf of the tenant. Used in server-side flows where the payment
|
|
17304
|
-
* form is embedded by the ISV rather than the platform.
|
|
17305
|
-
*
|
|
17306
|
-
* @param options - Optional request options.
|
|
17307
|
-
* @returns The updated `Tenant` with new payment method reference.
|
|
17308
|
-
*
|
|
17309
|
-
* @example
|
|
17310
|
-
* ```typescript
|
|
17311
|
-
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
17312
|
-
* const tenant = await client.platform.tenants.addPaymentMethod();
|
|
17313
|
-
* ```
|
|
17314
|
-
*/
|
|
17315
|
-
addPaymentMethod: async (options) => {
|
|
17316
|
-
return rb.execute(postTenantsIsv, {}, options);
|
|
17317
|
-
},
|
|
17318
17509
|
/**
|
|
17319
17510
|
* Retrieve a single tenant by its ID.
|
|
17320
17511
|
*
|
|
@@ -17331,6 +17522,33 @@ function createPlatformNamespace(rb) {
|
|
|
17331
17522
|
*/
|
|
17332
17523
|
get: async (id, options) => {
|
|
17333
17524
|
return rb.execute(getTenantsById, { path: { id } }, options);
|
|
17525
|
+
},
|
|
17526
|
+
/**
|
|
17527
|
+
* Transfer ownership of a tenant to another admin member.
|
|
17528
|
+
*
|
|
17529
|
+
* The new owner must already be a tenant admin. The previous owner
|
|
17530
|
+
* retains their admin role. Cannot be used on personal tenants.
|
|
17531
|
+
*
|
|
17532
|
+
* @param tenantId - The UUID of the tenant to transfer.
|
|
17533
|
+
* @param newOwnerId - The UUID of the user to become the new owner.
|
|
17534
|
+
* @param options - Optional request options.
|
|
17535
|
+
* @returns The updated `Tenant`.
|
|
17536
|
+
*/
|
|
17537
|
+
transferOwnership: async (tenantId, newOwnerId, options) => {
|
|
17538
|
+
return rb.execute(
|
|
17539
|
+
patchTenantsById,
|
|
17540
|
+
{
|
|
17541
|
+
path: { id: tenantId },
|
|
17542
|
+
body: {
|
|
17543
|
+
data: {
|
|
17544
|
+
id: tenantId,
|
|
17545
|
+
type: "tenant",
|
|
17546
|
+
attributes: { new_owner_id: newOwnerId }
|
|
17547
|
+
}
|
|
17548
|
+
}
|
|
17549
|
+
},
|
|
17550
|
+
options
|
|
17551
|
+
);
|
|
17334
17552
|
}
|
|
17335
17553
|
},
|
|
17336
17554
|
/**
|
|
@@ -17338,22 +17556,63 @@ function createPlatformNamespace(rb) {
|
|
|
17338
17556
|
*/
|
|
17339
17557
|
invitations: {
|
|
17340
17558
|
/**
|
|
17341
|
-
*
|
|
17559
|
+
* Accept a pending invitation (authenticated user flow).
|
|
17342
17560
|
*
|
|
17343
|
-
*
|
|
17344
|
-
*
|
|
17561
|
+
* Accepts an invitation the current user received, creating
|
|
17562
|
+
* the appropriate membership records.
|
|
17345
17563
|
*
|
|
17564
|
+
* @param id - The UUID of the invitation to accept.
|
|
17346
17565
|
* @param options - Optional request options.
|
|
17347
|
-
* @returns
|
|
17566
|
+
* @returns The updated `Invitation`.
|
|
17567
|
+
*/
|
|
17568
|
+
accept: async (id, options) => {
|
|
17569
|
+
return rb.execute(
|
|
17570
|
+
patchInvitationsByIdAccept,
|
|
17571
|
+
{
|
|
17572
|
+
path: { id },
|
|
17573
|
+
body: { data: { id, type: "invitation", attributes: {} } }
|
|
17574
|
+
},
|
|
17575
|
+
options
|
|
17576
|
+
);
|
|
17577
|
+
},
|
|
17578
|
+
/**
|
|
17579
|
+
* Decline a pending invitation.
|
|
17348
17580
|
*
|
|
17349
|
-
*
|
|
17350
|
-
*
|
|
17351
|
-
*
|
|
17352
|
-
*
|
|
17353
|
-
*
|
|
17581
|
+
* The invitation status is set to `:declined` and no membership is created.
|
|
17582
|
+
*
|
|
17583
|
+
* @param id - The UUID of the invitation to decline.
|
|
17584
|
+
* @param options - Optional request options.
|
|
17585
|
+
* @returns The updated `Invitation`.
|
|
17354
17586
|
*/
|
|
17355
|
-
|
|
17356
|
-
return rb.
|
|
17587
|
+
decline: async (id, options) => {
|
|
17588
|
+
return rb.execute(
|
|
17589
|
+
patchInvitationsByIdDecline,
|
|
17590
|
+
{
|
|
17591
|
+
path: { id },
|
|
17592
|
+
body: { data: { id, type: "invitation", attributes: {} } }
|
|
17593
|
+
},
|
|
17594
|
+
options
|
|
17595
|
+
);
|
|
17596
|
+
},
|
|
17597
|
+
/**
|
|
17598
|
+
* Revoke a pending invitation (inviter flow).
|
|
17599
|
+
*
|
|
17600
|
+
* Cancels the invitation so it can no longer be accepted or declined.
|
|
17601
|
+
* Callable by the original inviter or a tenant admin.
|
|
17602
|
+
*
|
|
17603
|
+
* @param id - The UUID of the invitation to revoke.
|
|
17604
|
+
* @param options - Optional request options.
|
|
17605
|
+
* @returns The updated `Invitation`.
|
|
17606
|
+
*/
|
|
17607
|
+
revoke: async (id, options) => {
|
|
17608
|
+
return rb.execute(
|
|
17609
|
+
patchInvitationsByIdRevoke,
|
|
17610
|
+
{
|
|
17611
|
+
path: { id },
|
|
17612
|
+
body: { data: { id, type: "invitation", attributes: {} } }
|
|
17613
|
+
},
|
|
17614
|
+
options
|
|
17615
|
+
);
|
|
17357
17616
|
},
|
|
17358
17617
|
/**
|
|
17359
17618
|
* List pending invitations for the currently authenticated user (paginated).
|
|
@@ -17432,31 +17691,119 @@ function createPlatformNamespace(rb) {
|
|
|
17432
17691
|
);
|
|
17433
17692
|
},
|
|
17434
17693
|
/**
|
|
17435
|
-
|
|
17694
|
+
/**
|
|
17695
|
+
* Resend an invitation email with a refreshed token and new 7-day expiry.
|
|
17436
17696
|
*
|
|
17437
|
-
*
|
|
17438
|
-
*
|
|
17439
|
-
*
|
|
17697
|
+
* Only pending invitations can be resent. Generates a new token (invalidating
|
|
17698
|
+
* the old one) and re-sends the invitation email. Callable by the original
|
|
17699
|
+
* inviter or the tenant owner.
|
|
17440
17700
|
*
|
|
17441
|
-
* @param id - The UUID of the invitation to
|
|
17442
|
-
* @param attributes - Attribute map, typically `{ status: "declined" }`.
|
|
17701
|
+
* @param id - The UUID of the invitation to resend.
|
|
17443
17702
|
* @param options - Optional request options.
|
|
17444
17703
|
* @returns The updated `Invitation`.
|
|
17445
17704
|
*
|
|
17446
17705
|
* @example
|
|
17447
17706
|
* ```typescript
|
|
17448
17707
|
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
17449
|
-
*
|
|
17450
|
-
* status: 'declined',
|
|
17451
|
-
* });
|
|
17708
|
+
* await client.platform.invitations.resend('inv_abc123');
|
|
17452
17709
|
* ```
|
|
17453
17710
|
*/
|
|
17454
|
-
|
|
17711
|
+
resend: async (id, applicationId, options) => {
|
|
17455
17712
|
return rb.execute(
|
|
17456
|
-
|
|
17713
|
+
patchInvitationsByIdResend,
|
|
17457
17714
|
{
|
|
17458
17715
|
path: { id },
|
|
17459
|
-
body: {
|
|
17716
|
+
body: {
|
|
17717
|
+
data: {
|
|
17718
|
+
id,
|
|
17719
|
+
type: "invitation",
|
|
17720
|
+
...applicationId ? { attributes: { application_id: applicationId } } : {}
|
|
17721
|
+
}
|
|
17722
|
+
}
|
|
17723
|
+
},
|
|
17724
|
+
options
|
|
17725
|
+
);
|
|
17726
|
+
},
|
|
17727
|
+
/**
|
|
17728
|
+
* Look up a pending invitation by its raw token.
|
|
17729
|
+
*
|
|
17730
|
+
* Call this on the `/invite/:token` landing page to display invitation
|
|
17731
|
+
* details before the user accepts. Returns the full invitation record
|
|
17732
|
+
* including `email` (to pre-fill the register form), `role`, `scope_type`,
|
|
17733
|
+
* `scope_id`, `tenant_id`, `expires_at`, and the `inviter` relationship
|
|
17734
|
+
* (pass `include=inviter` via request options to embed inviter email).
|
|
17735
|
+
*
|
|
17736
|
+
* Returns `null` if the token is invalid, already used, or expired —
|
|
17737
|
+
* there is no partial response for consumed tokens.
|
|
17738
|
+
*
|
|
17739
|
+
* **Note:** The response does not include the workspace or tenant name.
|
|
17740
|
+
* Fetch it separately using `platform.workspaces.get(scope_id)` or
|
|
17741
|
+
* `platform.tenants.get(scope_id)` based on `scope_type`.
|
|
17742
|
+
*
|
|
17743
|
+
* @param token - The raw invitation token from the email link (`/invite/:token`).
|
|
17744
|
+
* @param options - Optional request options (e.g., `{ headers: { include: 'inviter' } }`).
|
|
17745
|
+
* @returns The pending `Invitation` record, or `null` if not found.
|
|
17746
|
+
*
|
|
17747
|
+
* @example
|
|
17748
|
+
* ```typescript
|
|
17749
|
+
* // On your /invite/:token page
|
|
17750
|
+
* const invite = await client.platform.invitations.consumeByToken(token);
|
|
17751
|
+
* if (!invite) {
|
|
17752
|
+
* // Token expired or already used
|
|
17753
|
+
* return redirect('/invite/expired');
|
|
17754
|
+
* }
|
|
17755
|
+
* // Pre-fill form
|
|
17756
|
+
* setEmail(invite.attributes?.email);
|
|
17757
|
+
* setRole(invite.attributes?.role);
|
|
17758
|
+
* ```
|
|
17759
|
+
*/
|
|
17760
|
+
consumeByToken: async (token, options) => {
|
|
17761
|
+
try {
|
|
17762
|
+
return await rb.execute(
|
|
17763
|
+
getInvitationsConsumeByToken,
|
|
17764
|
+
{ path: { token } },
|
|
17765
|
+
options
|
|
17766
|
+
);
|
|
17767
|
+
} catch {
|
|
17768
|
+
return null;
|
|
17769
|
+
}
|
|
17770
|
+
},
|
|
17771
|
+
/**
|
|
17772
|
+
* Accept a pending invitation using only the raw token.
|
|
17773
|
+
*
|
|
17774
|
+
* Call this after the user is authenticated (either via `registerViaInvitation`
|
|
17775
|
+
* or an existing account login). The platform validates the token, creates or
|
|
17776
|
+
* upgrades the user's `TenantMembership` and `WorkspaceMembership`, and returns
|
|
17777
|
+
* the accepted invitation.
|
|
17778
|
+
*
|
|
17779
|
+
* For new users: `registerViaInvitation` accepts the invitation atomically —
|
|
17780
|
+
* do NOT call `acceptByToken` again after registration. Only call this for
|
|
17781
|
+
* existing users accepting a new invite after sign-in.
|
|
17782
|
+
*
|
|
17783
|
+
* @param token - The raw invitation token from the email link.
|
|
17784
|
+
* @param options - Optional request options.
|
|
17785
|
+
* @returns The accepted `Invitation` with `scope_id` and `tenant_id` populated.
|
|
17786
|
+
*
|
|
17787
|
+
* @example
|
|
17788
|
+
* ```typescript
|
|
17789
|
+
* // Existing user accepting an invite after login
|
|
17790
|
+
* const accepted = await client.platform.invitations.acceptByToken(token);
|
|
17791
|
+
* const workspaceId = accepted.attributes?.scope_type === 'workspace'
|
|
17792
|
+
* ? accepted.attributes?.scope_id
|
|
17793
|
+
* : null;
|
|
17794
|
+
* const tenantId = accepted.attributes?.tenant_id;
|
|
17795
|
+
* ```
|
|
17796
|
+
*/
|
|
17797
|
+
acceptByToken: async (token, options) => {
|
|
17798
|
+
return rb.execute(
|
|
17799
|
+
postInvitationsAcceptByToken,
|
|
17800
|
+
{
|
|
17801
|
+
body: {
|
|
17802
|
+
data: {
|
|
17803
|
+
type: "invitation",
|
|
17804
|
+
attributes: { token }
|
|
17805
|
+
}
|
|
17806
|
+
}
|
|
17460
17807
|
},
|
|
17461
17808
|
options
|
|
17462
17809
|
);
|
|
@@ -17499,6 +17846,42 @@ function createPlatformNamespace(rb) {
|
|
|
17499
17846
|
options
|
|
17500
17847
|
);
|
|
17501
17848
|
},
|
|
17849
|
+
/**
|
|
17850
|
+
* List workspace members with user profile data (name, email, avatar) included.
|
|
17851
|
+
*
|
|
17852
|
+
* Equivalent to `list()` with `?include=user,user.profile` appended. Each
|
|
17853
|
+
* membership in the response will have `relationships.user` and nested
|
|
17854
|
+
* `user.relationships.profile` populated in the JSON:API `included` array.
|
|
17855
|
+
*
|
|
17856
|
+
* The `RequestBuilder` flattens included relationships automatically, so
|
|
17857
|
+
* each membership object will have `user` and `user.profile` accessible.
|
|
17858
|
+
*
|
|
17859
|
+
* @param workspaceId - The UUID of the workspace to list members for.
|
|
17860
|
+
* @param options - Optional page number, page size, and request options.
|
|
17861
|
+
* @returns A page of `WorkspaceMembership` records with embedded user + profile.
|
|
17862
|
+
*
|
|
17863
|
+
* @example
|
|
17864
|
+
* ```typescript
|
|
17865
|
+
* const members = await client.platform.workspaceMembers.listWithProfiles('ws_abc123');
|
|
17866
|
+
* members.forEach(m => {
|
|
17867
|
+
* console.log(m.attributes?.user_id, m.attributes?.role);
|
|
17868
|
+
* // Profile fields come from included relationships
|
|
17869
|
+
* });
|
|
17870
|
+
* ```
|
|
17871
|
+
*/
|
|
17872
|
+
listWithProfiles: async (workspaceId, options) => {
|
|
17873
|
+
return rb.execute(
|
|
17874
|
+
getWorkspaceMemberships,
|
|
17875
|
+
{
|
|
17876
|
+
query: {
|
|
17877
|
+
filter: { workspace_id: workspaceId },
|
|
17878
|
+
include: "user,user.profile",
|
|
17879
|
+
...buildPageQuery(options?.page, options?.pageSize)?.query
|
|
17880
|
+
}
|
|
17881
|
+
},
|
|
17882
|
+
options
|
|
17883
|
+
);
|
|
17884
|
+
},
|
|
17502
17885
|
/**
|
|
17503
17886
|
* Retrieve the membership record for a specific user within a workspace.
|
|
17504
17887
|
*
|
|
@@ -17518,8 +17901,9 @@ function createPlatformNamespace(rb) {
|
|
|
17518
17901
|
* ```
|
|
17519
17902
|
*/
|
|
17520
17903
|
get: async (workspaceId, memberId, options) => {
|
|
17521
|
-
return rb.
|
|
17522
|
-
|
|
17904
|
+
return rb.execute(
|
|
17905
|
+
getWorkspaceMembershipsByWorkspaceIdByUserId,
|
|
17906
|
+
{ path: { workspace_id: workspaceId, user_id: memberId } },
|
|
17523
17907
|
options
|
|
17524
17908
|
);
|
|
17525
17909
|
},
|
|
@@ -17750,6 +18134,95 @@ function createPlatformNamespace(rb) {
|
|
|
17750
18134
|
options
|
|
17751
18135
|
);
|
|
17752
18136
|
}
|
|
18137
|
+
},
|
|
18138
|
+
/**
|
|
18139
|
+
* Tenant Members — manage tenant-level membership (org roles).
|
|
18140
|
+
*
|
|
18141
|
+
* TenantMembership records represent a user's role within a tenant.
|
|
18142
|
+
* Roles are either `"admin"` or `"member"`.
|
|
18143
|
+
*/
|
|
18144
|
+
tenantMembers: {
|
|
18145
|
+
/**
|
|
18146
|
+
* List members of a tenant (paginated).
|
|
18147
|
+
*
|
|
18148
|
+
* @param tenantId - The UUID of the tenant.
|
|
18149
|
+
* @param options - Optional page number, page size, and request options.
|
|
18150
|
+
* @returns A page of `TenantMembership` records.
|
|
18151
|
+
*/
|
|
18152
|
+
list: async (tenantId, options) => {
|
|
18153
|
+
return rb.execute(
|
|
18154
|
+
getTenantMemberships,
|
|
18155
|
+
{
|
|
18156
|
+
query: {
|
|
18157
|
+
filter: { tenant_id: tenantId },
|
|
18158
|
+
...buildPageQuery(options?.page, options?.pageSize).query
|
|
18159
|
+
}
|
|
18160
|
+
},
|
|
18161
|
+
options
|
|
18162
|
+
);
|
|
18163
|
+
},
|
|
18164
|
+
/**
|
|
18165
|
+
* Add a user to a tenant with the given role.
|
|
18166
|
+
*
|
|
18167
|
+
* @param tenantId - The UUID of the tenant.
|
|
18168
|
+
* @param userId - The UUID of the user to add.
|
|
18169
|
+
* @param role - The role to assign (`"admin"` or `"member"`).
|
|
18170
|
+
* @param options - Optional request options.
|
|
18171
|
+
* @returns The created `TenantMembership`.
|
|
18172
|
+
*/
|
|
18173
|
+
create: async (tenantId, userId, role, options) => {
|
|
18174
|
+
return rb.execute(
|
|
18175
|
+
postTenantMemberships,
|
|
18176
|
+
{
|
|
18177
|
+
body: {
|
|
18178
|
+
data: {
|
|
18179
|
+
type: "tenant_membership",
|
|
18180
|
+
attributes: { tenant_id: tenantId, user_id: userId, role }
|
|
18181
|
+
}
|
|
18182
|
+
}
|
|
18183
|
+
},
|
|
18184
|
+
options
|
|
18185
|
+
);
|
|
18186
|
+
},
|
|
18187
|
+
/**
|
|
18188
|
+
* Change a member's role within a tenant.
|
|
18189
|
+
*
|
|
18190
|
+
* @param tenantId - The UUID of the tenant.
|
|
18191
|
+
* @param userId - The UUID of the user.
|
|
18192
|
+
* @param role - The new role (`"admin"` or `"member"`).
|
|
18193
|
+
* @param options - Optional request options.
|
|
18194
|
+
* @returns The updated `TenantMembership`.
|
|
18195
|
+
*/
|
|
18196
|
+
updateRole: async (tenantId, userId, role, options) => {
|
|
18197
|
+
return rb.execute(
|
|
18198
|
+
patchTenantMembershipsByTenantIdByUserId,
|
|
18199
|
+
{
|
|
18200
|
+
path: { tenant_id: tenantId, user_id: userId },
|
|
18201
|
+
body: {
|
|
18202
|
+
data: {
|
|
18203
|
+
type: "tenant_membership",
|
|
18204
|
+
attributes: { role }
|
|
18205
|
+
}
|
|
18206
|
+
}
|
|
18207
|
+
},
|
|
18208
|
+
options
|
|
18209
|
+
);
|
|
18210
|
+
},
|
|
18211
|
+
/**
|
|
18212
|
+
* Remove a user from a tenant.
|
|
18213
|
+
*
|
|
18214
|
+
* @param tenantId - The UUID of the tenant.
|
|
18215
|
+
* @param userId - The UUID of the user to remove.
|
|
18216
|
+
* @param options - Optional request options.
|
|
18217
|
+
* @returns `true` on success.
|
|
18218
|
+
*/
|
|
18219
|
+
remove: async (tenantId, userId, options) => {
|
|
18220
|
+
return rb.executeDelete(
|
|
18221
|
+
deleteTenantMembershipsByTenantIdByUserId,
|
|
18222
|
+
{ path: { tenant_id: tenantId, user_id: userId } },
|
|
18223
|
+
options
|
|
18224
|
+
);
|
|
18225
|
+
}
|
|
17753
18226
|
}
|
|
17754
18227
|
};
|
|
17755
18228
|
}
|
|
@@ -18038,6 +18511,42 @@ function createSchedulingNamespace(rb) {
|
|
|
18038
18511
|
},
|
|
18039
18512
|
options
|
|
18040
18513
|
);
|
|
18514
|
+
},
|
|
18515
|
+
/**
|
|
18516
|
+
* List events that include a specific participant by email.
|
|
18517
|
+
*
|
|
18518
|
+
* Use this to retrieve all sessions for a client (e.g., all appointments
|
|
18519
|
+
* for a given patient). Filters events in the workspace where a Participant
|
|
18520
|
+
* record with the given email exists.
|
|
18521
|
+
*
|
|
18522
|
+
* @param email - The participant's email address to filter by.
|
|
18523
|
+
* @param workspaceId - The workspace to scope the query to.
|
|
18524
|
+
* @param options - Optional page number, page size, and request options.
|
|
18525
|
+
* @returns A flat array of `SchedulingEvent` records.
|
|
18526
|
+
*
|
|
18527
|
+
* @example
|
|
18528
|
+
* ```typescript
|
|
18529
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
18530
|
+
* const sessions = await client.scheduling.events.listByParticipant(
|
|
18531
|
+
* 'patient@example.com',
|
|
18532
|
+
* workspaceId,
|
|
18533
|
+
* );
|
|
18534
|
+
* sessions.forEach(s => console.log(s.attributes?.start_time, s.attributes?.status));
|
|
18535
|
+
* ```
|
|
18536
|
+
*/
|
|
18537
|
+
listByParticipant: async (email, workspaceId, options) => {
|
|
18538
|
+
return rb.execute(
|
|
18539
|
+
getSchedulingEventsByParticipant,
|
|
18540
|
+
{
|
|
18541
|
+
query: {
|
|
18542
|
+
email,
|
|
18543
|
+
workspace_id: workspaceId,
|
|
18544
|
+
...options?.pageSize && { "page[size]": options.pageSize },
|
|
18545
|
+
...options?.page && { "page[number]": options.page }
|
|
18546
|
+
}
|
|
18547
|
+
},
|
|
18548
|
+
options
|
|
18549
|
+
);
|
|
18041
18550
|
}
|
|
18042
18551
|
},
|
|
18043
18552
|
/**
|
|
@@ -18598,6 +19107,91 @@ function createSchedulingNamespace(rb) {
|
|
|
18598
19107
|
options
|
|
18599
19108
|
);
|
|
18600
19109
|
}
|
|
19110
|
+
},
|
|
19111
|
+
/**
|
|
19112
|
+
* Session Notes — clinical notes per appointment, stored in DataStore.
|
|
19113
|
+
*
|
|
19114
|
+
* Notes are keyed by `{eventId}:{noteType}` under the `sessions` namespace.
|
|
19115
|
+
* Each event supports up to 4 note types: `adime`, `soap`, `goals`, `email`.
|
|
19116
|
+
*
|
|
19117
|
+
* Notes are versioned automatically by DataStore — each `upsert` increments
|
|
19118
|
+
* the version counter. Full version history retrieval requires a future
|
|
19119
|
+
* DataStore enhancement.
|
|
19120
|
+
*
|
|
19121
|
+
* @example
|
|
19122
|
+
* ```typescript
|
|
19123
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
19124
|
+
*
|
|
19125
|
+
* // Read an ADIME note
|
|
19126
|
+
* const note = await client.scheduling.sessionNotes.get(sessionId, 'adime');
|
|
19127
|
+
* console.log(note?.attributes?.value?.content);
|
|
19128
|
+
*
|
|
19129
|
+
* // Write/update a SOAP note
|
|
19130
|
+
* await client.scheduling.sessionNotes.upsert(sessionId, 'soap', {
|
|
19131
|
+
* content: 'S: Patient reports...',
|
|
19132
|
+
* reviewed_by_user_id: currentUserId,
|
|
19133
|
+
* reviewed_at: new Date().toISOString(),
|
|
19134
|
+
* });
|
|
19135
|
+
* ```
|
|
19136
|
+
*/
|
|
19137
|
+
sessionNotes: {
|
|
19138
|
+
/**
|
|
19139
|
+
* Get the current version of a session note.
|
|
19140
|
+
*
|
|
19141
|
+
* Returns `null` if no note of this type exists for the event yet.
|
|
19142
|
+
*
|
|
19143
|
+
* @param eventId - The UUID of the scheduling event (session).
|
|
19144
|
+
* @param noteType - The note type: `"adime"`, `"soap"`, `"goals"`, or `"email"`.
|
|
19145
|
+
* @param workspaceId - The workspace UUID. Required for application-scoped API keys.
|
|
19146
|
+
* @param options - Optional request options.
|
|
19147
|
+
* @returns The `DataStoreRecord`, or `null` if not found.
|
|
19148
|
+
*/
|
|
19149
|
+
get: async (eventId, noteType, workspaceId, options) => {
|
|
19150
|
+
const results = await rb.execute(
|
|
19151
|
+
getDataStoreRecordsByNamespace,
|
|
19152
|
+
{
|
|
19153
|
+
query: {
|
|
19154
|
+
workspace_id: workspaceId,
|
|
19155
|
+
namespace: "sessions",
|
|
19156
|
+
"filter[record_key]": `${eventId}:${noteType}`
|
|
19157
|
+
}
|
|
19158
|
+
},
|
|
19159
|
+
options
|
|
19160
|
+
);
|
|
19161
|
+
return results.length > 0 ? results[0] ?? null : null;
|
|
19162
|
+
},
|
|
19163
|
+
/**
|
|
19164
|
+
* Create or update a session note (auto-versions on update).
|
|
19165
|
+
*
|
|
19166
|
+
* If the note does not exist, it is created. If it exists, its value
|
|
19167
|
+
* is replaced and the version counter is incremented.
|
|
19168
|
+
*
|
|
19169
|
+
* @param eventId - The UUID of the scheduling event (session).
|
|
19170
|
+
* @param noteType - The note type: `"adime"`, `"soap"`, `"goals"`, or `"email"`.
|
|
19171
|
+
* @param workspaceId - The workspace UUID. Required for application-scoped API keys.
|
|
19172
|
+
* @param value - The note content and optional metadata.
|
|
19173
|
+
* @param options - Optional request options.
|
|
19174
|
+
* @returns The upserted `DataStoreRecord`.
|
|
19175
|
+
*/
|
|
19176
|
+
upsert: async (eventId, noteType, workspaceId, value, options) => {
|
|
19177
|
+
return rb.execute(
|
|
19178
|
+
postDataStoreRecordsUpsert,
|
|
19179
|
+
{
|
|
19180
|
+
body: {
|
|
19181
|
+
data: {
|
|
19182
|
+
type: "data_store_record",
|
|
19183
|
+
attributes: {
|
|
19184
|
+
namespace: "sessions",
|
|
19185
|
+
record_key: `${eventId}:${noteType}`,
|
|
19186
|
+
workspace_id: workspaceId,
|
|
19187
|
+
value
|
|
19188
|
+
}
|
|
19189
|
+
}
|
|
19190
|
+
}
|
|
19191
|
+
},
|
|
19192
|
+
options
|
|
19193
|
+
);
|
|
19194
|
+
}
|
|
18601
19195
|
}
|
|
18602
19196
|
};
|
|
18603
19197
|
}
|
|
@@ -22467,6 +23061,7 @@ export {
|
|
|
22467
23061
|
AuthenticationError,
|
|
22468
23062
|
AuthorizationError,
|
|
22469
23063
|
BrowserApiKeyError,
|
|
23064
|
+
CardDeclinedError,
|
|
22470
23065
|
ConflictError,
|
|
22471
23066
|
DEFAULT_API_VERSION,
|
|
22472
23067
|
DEFAULT_RETRY_CONFIG,
|
|
@@ -22476,12 +23071,14 @@ export {
|
|
|
22476
23071
|
LOG_LEVELS,
|
|
22477
23072
|
NetworkError,
|
|
22478
23073
|
NotFoundError,
|
|
23074
|
+
PaymentRequiredError,
|
|
22479
23075
|
RateLimitError,
|
|
22480
23076
|
RequestBuilder,
|
|
22481
23077
|
RetryTimeoutError,
|
|
22482
23078
|
SDK_VERSION,
|
|
22483
23079
|
SdkEventEmitter,
|
|
22484
23080
|
ServerError,
|
|
23081
|
+
SubscriptionConflictError,
|
|
22485
23082
|
TimeoutError,
|
|
22486
23083
|
ValidationError,
|
|
22487
23084
|
WebhookSignatureError,
|