@gravity-rail/cli 0.7.1 → 0.7.2

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.
@@ -1,7 +1,5 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
3
  var __esm = (fn, res) => function __init() {
6
4
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
5
  };
@@ -9,15 +7,6 @@ var __export = (target, all) => {
9
7
  for (var name in all)
10
8
  __defProp(target, name, { get: all[name], enumerable: true });
11
9
  };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
10
 
22
11
  // src/cli-utils/config.ts
23
12
  import { existsSync, readFileSync } from "fs";
@@ -807,1664 +796,6 @@ var init_output = __esm({
807
796
  }
808
797
  });
809
798
 
810
- // ../client/dist/index.mjs
811
- var dist_exports = {};
812
- __export(dist_exports, {
813
- AdminApi: () => AdminApi,
814
- ApiClient: () => ApiClient,
815
- bindAdminMethods: () => bindAdminMethods
816
- });
817
- import * as internal_star from "@gravity-rail/sdk/internal";
818
- import { BaseApiClient } from "@gravity-rail/sdk/internal";
819
- import { GravityRailClient } from "@gravity-rail/sdk";
820
- function supportRequestParams(params) {
821
- const searchParams = new URLSearchParams();
822
- if (params?.page) searchParams.append("page", params.page.toString());
823
- if (params?.pageSize) searchParams.append("pageSize", params.pageSize.toString());
824
- if (params?.status) searchParams.append("status", params.status);
825
- if (params?.supportRequestType) {
826
- searchParams.append("supportRequestType", params.supportRequestType);
827
- }
828
- if (params?.severity) searchParams.append("severity", params.severity);
829
- if (params?.source) searchParams.append("source", params.source);
830
- if (params?.organizationId !== void 0) {
831
- searchParams.append("organizationId", params.organizationId.toString());
832
- }
833
- if (params?.workspaceId !== void 0) {
834
- searchParams.append("workspaceId", params.workspaceId.toString());
835
- }
836
- if (params?.linearLinked !== void 0) {
837
- searchParams.append("linearLinked", params.linearLinked.toString());
838
- }
839
- const query = searchParams.toString();
840
- return query ? `?${query}` : "";
841
- }
842
- function appendTemporalWorkspaceParams(params, options) {
843
- const seen = /* @__PURE__ */ new Set();
844
- const push = (raw) => {
845
- if (!raw) return;
846
- const trimmed = raw.trim();
847
- if (!trimmed || seen.has(trimmed)) return;
848
- seen.add(trimmed);
849
- params.append("workspace_uuid", trimmed);
850
- };
851
- if (options.workspaceUuids) {
852
- for (const value of options.workspaceUuids) push(value);
853
- }
854
- push(options.workspaceUuid);
855
- }
856
- function bindAdminMethods(target, admin) {
857
- target.listSupportRequestsAsAdmin = admin.listSupportRequestsAsAdmin.bind(admin);
858
- target.getSupportRequestAsAdmin = admin.getSupportRequestAsAdmin.bind(admin);
859
- target.commentOnSupportRequestAsAdmin = admin.commentOnSupportRequestAsAdmin.bind(admin);
860
- target.noteOnSupportRequestAsAdmin = admin.noteOnSupportRequestAsAdmin.bind(admin);
861
- target.updateSupportRequestStatusAsAdmin = admin.updateSupportRequestStatusAsAdmin.bind(admin);
862
- target.updateSupportRequestAttributesAsAdmin = admin.updateSupportRequestAttributesAsAdmin.bind(admin);
863
- target.createSupportRequestLinearIssueAsAdmin = admin.createSupportRequestLinearIssueAsAdmin.bind(admin);
864
- target.createOutboundSupportRequestAsAdmin = admin.createOutboundSupportRequestAsAdmin.bind(admin);
865
- target.attachSupportRequestResourceAsAdmin = admin.attachSupportRequestResourceAsAdmin.bind(admin);
866
- target.revokeSupportRequestResourceAsAdmin = admin.revokeSupportRequestResourceAsAdmin.bind(admin);
867
- target.listCustomerActivityEvents = admin.listCustomerActivityEvents.bind(admin);
868
- target.getCustomerActivityEvent = admin.getCustomerActivityEvent.bind(admin);
869
- target.setCustomerActivityEventDisposition = admin.setCustomerActivityEventDisposition.bind(admin);
870
- target.setCustomerActivityEventStatus = admin.setCustomerActivityEventStatus.bind(admin);
871
- target.reclassifyCustomerActivityEvent = admin.reclassifyCustomerActivityEvent.bind(admin);
872
- target.getAccounts = admin.getAccounts.bind(admin);
873
- target.getAccountDetails = admin.getAccountDetails.bind(admin);
874
- target.getAccountByUuid = admin.getAccountByUuid.bind(admin);
875
- target.getAccountMemberships = admin.getAccountMemberships.bind(admin);
876
- target.getAccountOrgMemberships = admin.getAccountOrgMemberships.bind(admin);
877
- target.createAccountOrgMembership = admin.createAccountOrgMembership.bind(admin);
878
- target.deleteAccountOrgMembership = admin.deleteAccountOrgMembership.bind(admin);
879
- target.getAccountMembership = admin.getAccountMembership.bind(admin);
880
- target.updateAccountMembership = admin.updateAccountMembership.bind(admin);
881
- target.createAccountMembership = admin.createAccountMembership.bind(admin);
882
- target.deleteAccountMembership = admin.deleteAccountMembership.bind(admin);
883
- target.updateAccountAsAdmin = admin.updateAccountAsAdmin.bind(admin);
884
- target.createAccountAsAdmin = admin.createAccountAsAdmin.bind(admin);
885
- target.deleteAccountAsAdmin = admin.deleteAccountAsAdmin.bind(admin);
886
- target.lookupAccount = admin.lookupAccount.bind(admin);
887
- target.exportAccountData = admin.exportAccountData.bind(admin);
888
- target.requestAccountDeletion = admin.requestAccountDeletion.bind(admin);
889
- target.cancelAccountDeletion = admin.cancelAccountDeletion.bind(admin);
890
- target.getOrganizations = admin.getOrganizations.bind(admin);
891
- target.getOrganization = admin.getOrganization.bind(admin);
892
- target.getOrganizationAsAdmin = admin.getOrganizationAsAdmin.bind(admin);
893
- target.getOrganizationMembersAsAdmin = admin.getOrganizationMembersAsAdmin.bind(admin);
894
- target.createOrganization = admin.createOrganization.bind(admin);
895
- target.updateOrganization = admin.updateOrganization.bind(admin);
896
- target.deleteOrganization = admin.deleteOrganization.bind(admin);
897
- target.joinOrganization = admin.joinOrganization.bind(admin);
898
- target.leaveOrganization = admin.leaveOrganization.bind(admin);
899
- target.generateLogoUploadUrl = admin.generateLogoUploadUrl.bind(admin);
900
- target.importProducts = admin.importProducts.bind(admin);
901
- target.createProductAsAdmin = admin.createProductAsAdmin.bind(admin);
902
- target.getProductsAsAdmin = admin.getProductsAsAdmin.bind(admin);
903
- target.getProductAsAdmin = admin.getProductAsAdmin.bind(admin);
904
- target.updateProductAsAdmin = admin.updateProductAsAdmin.bind(admin);
905
- target.deleteProductAsAdmin = admin.deleteProductAsAdmin.bind(admin);
906
- target.getWorkspacesAsAdmin = admin.getWorkspacesAsAdmin.bind(admin);
907
- target.getWorkspaceAsAdmin = admin.getWorkspaceAsAdmin.bind(admin);
908
- target.getWorkspaceByNumericIdAsAdmin = admin.getWorkspaceByNumericIdAsAdmin.bind(admin);
909
- target.createWorkspaceAsAdmin = admin.createWorkspaceAsAdmin.bind(admin);
910
- target.updateWorkspaceAsAdmin = admin.updateWorkspaceAsAdmin.bind(admin);
911
- target.deleteWorkspaceAsAdmin = admin.deleteWorkspaceAsAdmin.bind(admin);
912
- target.createSchemaAsAdmin = admin.createSchemaAsAdmin.bind(admin);
913
- target.migrateSchemaAsAdmin = admin.migrateSchemaAsAdmin.bind(admin);
914
- target.provisionWorkspaceAsAdmin = admin.provisionWorkspaceAsAdmin.bind(admin);
915
- target.refreshProvisionStatusAsAdmin = admin.refreshProvisionStatusAsAdmin.bind(admin);
916
- target.enableMaintenanceMode = admin.enableMaintenanceMode.bind(admin);
917
- target.disableMaintenanceMode = admin.disableMaintenanceMode.bind(admin);
918
- target.getWorkspaceHealth = admin.getWorkspaceHealth.bind(admin);
919
- target.provisionPlanFeatures = admin.provisionPlanFeatures.bind(admin);
920
- target.changeWorkspaceProduct = admin.changeWorkspaceProduct.bind(admin);
921
- target.validateWorkflowAccessAsAdmin = admin.validateWorkflowAccessAsAdmin.bind(admin);
922
- target.mergeMembers = admin.mergeMembers.bind(admin);
923
- target.getAdminWorkspaceMember = admin.getAdminWorkspaceMember.bind(admin);
924
- target.createAdminWorkspaceMember = admin.createAdminWorkspaceMember.bind(admin);
925
- target.updateAdminWorkspaceMember = admin.updateAdminWorkspaceMember.bind(admin);
926
- target.unarchiveAdminWorkspaceMember = admin.unarchiveAdminWorkspaceMember.bind(admin);
927
- target.getAdminWorkspaceMemberRoles = admin.getAdminWorkspaceMemberRoles.bind(admin);
928
- target.getMissingMemberships = admin.getMissingMemberships.bind(admin);
929
- target.linkMissingMembership = admin.linkMissingMembership.bind(admin);
930
- target.getUnmappedPhoneNumbers = admin.getUnmappedPhoneNumbers.bind(admin);
931
- target.getWorkspaceUnmappedPhoneNumbers = admin.getWorkspaceUnmappedPhoneNumbers.bind(admin);
932
- target.getWorkspacePhoneNumbersAsAdmin = admin.getWorkspacePhoneNumbersAsAdmin.bind(admin);
933
- target.getProviderPhoneNumbers = admin.getProviderPhoneNumbers.bind(admin);
934
- target.getProviderPhoneNumber = admin.getProviderPhoneNumber.bind(admin);
935
- target.updateProviderPhoneNumber = admin.updateProviderPhoneNumber.bind(admin);
936
- target.mapMainAccountPhone = admin.mapMainAccountPhone.bind(admin);
937
- target.unmapPhoneNumber = admin.unmapPhoneNumber.bind(admin);
938
- target.searchAvailablePhoneNumbersAsAdmin = admin.searchAvailablePhoneNumbersAsAdmin.bind(admin);
939
- target.purchasePhoneNumberAsAdmin = admin.purchasePhoneNumberAsAdmin.bind(admin);
940
- target.startBulkPhoneClassification = admin.startBulkPhoneClassification.bind(admin);
941
- target.getOrgA2PStatusAsAdmin = admin.getOrgA2PStatusAsAdmin.bind(admin);
942
- target.resetOrgA2PStatusAsAdmin = admin.resetOrgA2PStatusAsAdmin.bind(admin);
943
- target.getSiteMappings = admin.getSiteMappings.bind(admin);
944
- target.getSiteMapping = admin.getSiteMapping.bind(admin);
945
- target.updateSiteMapping = admin.updateSiteMapping.bind(admin);
946
- target.updateSiteMappingWorkspace = admin.updateSiteMappingWorkspace.bind(admin);
947
- target.adminDeleteSiteMapping = admin.adminDeleteSiteMapping.bind(admin);
948
- target.createSiteMapping = admin.createSiteMapping.bind(admin);
949
- target.createOrUpdateSiteMapping = admin.createOrUpdateSiteMapping.bind(admin);
950
- target.deleteSiteMapping = admin.deleteSiteMapping.bind(admin);
951
- target.getInboxMappings = admin.getInboxMappings.bind(admin);
952
- target.getInboxMapping = admin.getInboxMapping.bind(admin);
953
- target.updateInboxMapping = admin.updateInboxMapping.bind(admin);
954
- target.deleteAdminInboxMapping = admin.deleteAdminInboxMapping.bind(admin);
955
- target.generateChatSummaries = admin.generateChatSummaries.bind(admin);
956
- target.executeQuery = admin.executeQuery.bind(admin);
957
- target.getTraceUrl = admin.getTraceUrl.bind(admin);
958
- target.listAllThemes = admin.listAllThemes.bind(admin);
959
- target.startBulkTOSAcceptance = admin.startBulkTOSAcceptance.bind(admin);
960
- target.startTokenUsageBackfill = admin.startTokenUsageBackfill.bind(admin);
961
- target.updateChatMessage = admin.updateChatMessage.bind(admin);
962
- target.createCustomerFromAccount = admin.createCustomerFromAccount.bind(admin);
963
- target.getCustomers = admin.getCustomers.bind(admin);
964
- target.getCustomer = admin.getCustomer.bind(admin);
965
- target.createCustomer = admin.createCustomer.bind(admin);
966
- target.updateCustomer = admin.updateCustomer.bind(admin);
967
- target.getCustomerAccounts = admin.getCustomerAccounts.bind(admin);
968
- target.linkCustomerToAccount = admin.linkCustomerToAccount.bind(admin);
969
- target.unlinkCustomerFromAccount = admin.unlinkCustomerFromAccount.bind(admin);
970
- target.syncCustomerToStripe = admin.syncCustomerToStripe.bind(admin);
971
- target.getStripeCustomer = admin.getStripeCustomer.bind(admin);
972
- target.createStripeCustomer = admin.createStripeCustomer.bind(admin);
973
- target.updateStripeCustomer = admin.updateStripeCustomer.bind(admin);
974
- target.getStripeSubscriptions = admin.getStripeSubscriptions.bind(admin);
975
- target.createStripeSubscription = admin.createStripeSubscription.bind(admin);
976
- target.createDirectSubscription = admin.createDirectSubscription.bind(admin);
977
- target.updateStripeSubscription = admin.updateStripeSubscription.bind(admin);
978
- target.cancelStripeSubscription = admin.cancelStripeSubscription.bind(admin);
979
- target.provisionWorkspaceForSubscription = admin.provisionWorkspaceForSubscription.bind(admin);
980
- target.associateWorkspaceWithSubscription = admin.associateWorkspaceWithSubscription.bind(admin);
981
- target.createSubscriptionPaymentLink = admin.createSubscriptionPaymentLink.bind(admin);
982
- target.createSetupIntent = admin.createSetupIntent.bind(admin);
983
- target.getStripePaymentMethods = admin.getStripePaymentMethods.bind(admin);
984
- target.attachStripePaymentMethod = admin.attachStripePaymentMethod.bind(admin);
985
- target.detachStripePaymentMethod = admin.detachStripePaymentMethod.bind(admin);
986
- target.setDefaultStripePaymentMethod = admin.setDefaultStripePaymentMethod.bind(admin);
987
- target.convertSubscriptionToStripe = admin.convertSubscriptionToStripe.bind(admin);
988
- target.createCustomerSetupIntent = admin.createCustomerSetupIntent.bind(admin);
989
- target.getCustomerPaymentMethods = admin.getCustomerPaymentMethods.bind(admin);
990
- target.attachCustomerPaymentMethod = admin.attachCustomerPaymentMethod.bind(admin);
991
- target.detachCustomerPaymentMethod = admin.detachCustomerPaymentMethod.bind(admin);
992
- target.setDefaultCustomerPaymentMethod = admin.setDefaultCustomerPaymentMethod.bind(admin);
993
- target.previewWorkspaceOrganizationChange = admin.previewWorkspaceOrganizationChange.bind(admin);
994
- target.changeWorkspaceOrganization = admin.changeWorkspaceOrganization.bind(admin);
995
- target.createStripeInvoice = admin.createStripeInvoice.bind(admin);
996
- target.getStripeInvoices = admin.getStripeInvoices.bind(admin);
997
- target.getStripeUpcomingInvoice = admin.getStripeUpcomingInvoice.bind(admin);
998
- target.getBillingPeriods = admin.getBillingPeriods.bind(admin);
999
- target.generateInvoice = admin.generateInvoice.bind(admin);
1000
- target.getInvoices = admin.getInvoices.bind(admin);
1001
- target.getInvoiceDownloadUrl = admin.getInvoiceDownloadUrl.bind(admin);
1002
- target.getReceiptDownloadUrl = admin.getReceiptDownloadUrl.bind(admin);
1003
- target.recordInvoicePayment = admin.recordInvoicePayment.bind(admin);
1004
- target.getWorkspaceUsageDashboard = admin.getWorkspaceUsageDashboard.bind(admin);
1005
- target.compareProductsWithStripe = admin.compareProductsWithStripe.bind(admin);
1006
- target.syncProductToStripe = admin.syncProductToStripe.bind(admin);
1007
- target.searchStripeProducts = admin.searchStripeProducts.bind(admin);
1008
- target.getUsageReport = admin.getUsageReport.bind(admin);
1009
- target.getSubscriptionsAsAdmin = admin.getSubscriptionsAsAdmin.bind(admin);
1010
- target.getSubscriptionAsAdmin = admin.getSubscriptionAsAdmin.bind(admin);
1011
- target.updateSubscriptionStatusAsAdmin = admin.updateSubscriptionStatusAsAdmin.bind(admin);
1012
- target.updateSubscriptionCreditSettingsAsAdmin = admin.updateSubscriptionCreditSettingsAsAdmin.bind(admin);
1013
- target.grantCreditsAsAdmin = admin.grantCreditsAsAdmin.bind(admin);
1014
- target.listCreditGrantsAsAdmin = admin.listCreditGrantsAsAdmin.bind(admin);
1015
- target.getVoiceMetrics = admin.getVoiceMetrics.bind(admin);
1016
- target.getHealthMetrics = admin.getHealthMetrics.bind(admin);
1017
- target.getHealthDetail = admin.getHealthDetail.bind(admin);
1018
- target.getWorkspaceInboxesAsAdmin = admin.getWorkspaceInboxesAsAdmin.bind(admin);
1019
- target.listWorkspaceChats = admin.listWorkspaceChats.bind(admin);
1020
- target.getWorkspaceChat = admin.getWorkspaceChat.bind(admin);
1021
- target.rateWorkspaceChatMessage = admin.rateWorkspaceChatMessage.bind(admin);
1022
- target.getTemporalAdminConfig = admin.getTemporalAdminConfig.bind(admin);
1023
- target.listFailedTemporalWorkflows = admin.listFailedTemporalWorkflows.bind(admin);
1024
- target.listStuckTemporalWorkflows = admin.listStuckTemporalWorkflows.bind(admin);
1025
- target.getTemporalSummary = admin.getTemporalSummary.bind(admin);
1026
- target.getTemporalWorkflowDetail = admin.getTemporalWorkflowDetail.bind(admin);
1027
- target.getResellers = admin.getResellers.bind(admin);
1028
- target.getReseller = admin.getReseller.bind(admin);
1029
- target.createReseller = admin.createReseller.bind(admin);
1030
- target.updateReseller = admin.updateReseller.bind(admin);
1031
- target.getResellerAccounts = admin.getResellerAccounts.bind(admin);
1032
- target.linkResellerToAccount = admin.linkResellerToAccount.bind(admin);
1033
- target.unlinkResellerFromAccount = admin.unlinkResellerFromAccount.bind(admin);
1034
- }
1035
- var AdminApi, ApiClient;
1036
- var init_dist = __esm({
1037
- "../client/dist/index.mjs"() {
1038
- "use strict";
1039
- __reExport(dist_exports, internal_star);
1040
- AdminApi = class extends BaseApiClient {
1041
- // Support Requests API
1042
- async listSupportRequestsAsAdmin(params) {
1043
- return this.fetch(
1044
- `admin/support-requests${supportRequestParams(params)}`
1045
- );
1046
- }
1047
- async getSupportRequestAsAdmin(uuid) {
1048
- return this.fetch(`admin/support-requests/${uuid}`);
1049
- }
1050
- async commentOnSupportRequestAsAdmin(uuid, data) {
1051
- return this.fetch(`admin/support-requests/${uuid}/comments`, {
1052
- method: "POST",
1053
- body: JSON.stringify(data)
1054
- });
1055
- }
1056
- async noteOnSupportRequestAsAdmin(uuid, data) {
1057
- return this.fetch(`admin/support-requests/${uuid}/notes`, {
1058
- method: "POST",
1059
- body: JSON.stringify(data)
1060
- });
1061
- }
1062
- async updateSupportRequestStatusAsAdmin(uuid, data) {
1063
- return this.fetch(`admin/support-requests/${uuid}/status`, {
1064
- method: "POST",
1065
- body: JSON.stringify(data)
1066
- });
1067
- }
1068
- async updateSupportRequestAttributesAsAdmin(uuid, data) {
1069
- return this.fetch(`admin/support-requests/${uuid}/attributes`, {
1070
- method: "POST",
1071
- body: JSON.stringify(data)
1072
- });
1073
- }
1074
- async createSupportRequestLinearIssueAsAdmin(uuid) {
1075
- return this.fetch(`admin/support-requests/${uuid}/linear-issue`, {
1076
- method: "POST"
1077
- });
1078
- }
1079
- // Proactive Support: outbound (us→customer) requests + resources
1080
- async createOutboundSupportRequestAsAdmin(data) {
1081
- return this.fetch("admin/support-requests/outbound", {
1082
- method: "POST",
1083
- body: JSON.stringify(data)
1084
- });
1085
- }
1086
- async attachSupportRequestResourceAsAdmin(uuid, data) {
1087
- return this.fetch(`admin/support-requests/${uuid}/resources`, {
1088
- method: "POST",
1089
- body: JSON.stringify(data)
1090
- });
1091
- }
1092
- async revokeSupportRequestResourceAsAdmin(uuid, resourceUuid) {
1093
- return this.fetch(
1094
- `admin/support-requests/${uuid}/resources/${resourceUuid}/revoke`,
1095
- { method: "POST" }
1096
- );
1097
- }
1098
- // Admin Accounts API
1099
- async getAccounts(options) {
1100
- const params = new URLSearchParams();
1101
- if (options.search) params.append("search", options.search);
1102
- if (options.createdAfter) params.append("created_after", options.createdAfter);
1103
- if (options.createdBefore) params.append("created_before", options.createdBefore);
1104
- if (options.sortBy) params.append("sortBy", options.sortBy);
1105
- if (options.sortOrder) params.append("sortOrder", options.sortOrder);
1106
- if (options.page) params.append("page", options.page.toString());
1107
- if (options.pageSize) params.append("pageSize", options.pageSize.toString());
1108
- if (options.isActive !== void 0) params.append("isActive", options.isActive.toString());
1109
- if (options.organizationId !== void 0)
1110
- params.append("organizationId", options.organizationId.toString());
1111
- if (options.workspaceId !== void 0)
1112
- params.append("workspaceId", options.workspaceId.toString());
1113
- if (options.pendingDeletion !== void 0)
1114
- params.append("pendingDeletion", options.pendingDeletion.toString());
1115
- return this.fetch(`admin/accounts?${params.toString()}`);
1116
- }
1117
- async getAccountDetails(id) {
1118
- return this.fetch(`admin/accounts/${id}`);
1119
- }
1120
- async getAccountByUuid(uuid) {
1121
- return this.fetch(`admin/accounts/${uuid}`);
1122
- }
1123
- async getAccountMemberships(accountId) {
1124
- return this.fetch(`admin/accounts/${accountId}/memberships`);
1125
- }
1126
- async getAccountOrgMemberships(accountId) {
1127
- return this.fetch(`admin/accounts/${accountId}/org-memberships`);
1128
- }
1129
- async createAccountOrgMembership(accountId, organizationId, role = "member") {
1130
- return this.fetch(`admin/accounts/${accountId}/org-memberships`, {
1131
- method: "POST",
1132
- body: JSON.stringify({ organizationId, role })
1133
- });
1134
- }
1135
- async deleteAccountOrgMembership(accountId, organizationId) {
1136
- return this.fetch(`admin/accounts/${accountId}/org-memberships/${organizationId}`, {
1137
- method: "DELETE"
1138
- });
1139
- }
1140
- async getAccountMembership(accountId, workspaceId) {
1141
- return this.fetch(
1142
- `admin/accounts/${accountId}/memberships/${workspaceId}`
1143
- );
1144
- }
1145
- async updateAccountMembership(accountId, workspaceId, updates) {
1146
- return this.fetch(
1147
- `admin/accounts/${accountId}/memberships/${workspaceId}`,
1148
- {
1149
- method: "PUT",
1150
- body: JSON.stringify(updates)
1151
- }
1152
- );
1153
- }
1154
- async createAccountMembership(accountId, workspaceId, data) {
1155
- return this.fetch(
1156
- `admin/accounts/${accountId}/memberships/${workspaceId}`,
1157
- {
1158
- method: "POST",
1159
- body: JSON.stringify(data)
1160
- }
1161
- );
1162
- }
1163
- async deleteAccountMembership(accountId, workspaceId) {
1164
- return this.fetch(`admin/accounts/${accountId}/memberships/${workspaceId}`, {
1165
- method: "DELETE"
1166
- });
1167
- }
1168
- async updateAccountAsAdmin(id, updates) {
1169
- return this.fetch(`admin/accounts/${id}`, {
1170
- method: "PUT",
1171
- body: JSON.stringify(updates)
1172
- });
1173
- }
1174
- async createAccountAsAdmin(data) {
1175
- return this.fetch("admin/accounts", {
1176
- method: "POST",
1177
- body: JSON.stringify(data)
1178
- });
1179
- }
1180
- async deleteAccountAsAdmin(id) {
1181
- return this.fetch(`admin/accounts/${id}`, {
1182
- method: "DELETE"
1183
- });
1184
- }
1185
- // GDPR Data Subject Rights (superuser only)
1186
- async exportAccountData(accountId) {
1187
- return this.fetch(`admin/data-rights/${accountId}/export`, {
1188
- method: "POST"
1189
- });
1190
- }
1191
- async requestAccountDeletion(accountId) {
1192
- return this.fetch(`admin/data-rights/${accountId}/delete`, {
1193
- method: "POST"
1194
- });
1195
- }
1196
- async cancelAccountDeletion(accountId) {
1197
- return this.fetch(`admin/data-rights/${accountId}/cancel-delete`, {
1198
- method: "POST"
1199
- });
1200
- }
1201
- /**
1202
- * Look up an account by email or phone. Returns verification status.
1203
- * Used to check if a verified account exists before creating a new one.
1204
- */
1205
- async lookupAccount(options) {
1206
- const params = new URLSearchParams();
1207
- if (options.email) params.append("email", options.email);
1208
- if (options.phone) params.append("phone", options.phone);
1209
- return this.fetch(`admin/accounts/lookup?${params.toString()}`);
1210
- }
1211
- // Admin Organizations API
1212
- async getOrganizations(options) {
1213
- const params = new URLSearchParams();
1214
- if (options?.search) params.append("search", options.search);
1215
- if (options?.page) params.append("page", options.page.toString());
1216
- if (options?.pageSize) params.append("pageSize", options.pageSize.toString());
1217
- if (options?.noSubscription) params.append("no_subscription", "true");
1218
- if (options?.sortBy) params.append("sortBy", options.sortBy);
1219
- if (options?.sortOrder) params.append("sortOrder", options.sortOrder);
1220
- return this.fetch(
1221
- `admin/organizations?${params.toString()}`
1222
- );
1223
- }
1224
- /**
1225
- * Get organization by ID or UUID.
1226
- * Returns different response based on user's role:
1227
- * - Admins/Owners: AdminOrganization with full details
1228
- * - Members: MemberOrgView with basic info and workspace list
1229
- *
1230
- * Use `viewType` field to determine the response type:
1231
- * - 'admin': AdminOrganization
1232
- * - 'member': MemberOrgView
1233
- */
1234
- async getOrganization(idOrUuid) {
1235
- return this.fetch(`o/${idOrUuid}`);
1236
- }
1237
- /**
1238
- * Get organization by numeric ID or UUID via admin endpoint.
1239
- * Does NOT require organization membership — superuser-only.
1240
- */
1241
- async getOrganizationAsAdmin(idOrUuid) {
1242
- return this.fetch(`admin/organizations/${idOrUuid}`);
1243
- }
1244
- async getOrganizationMembersAsAdmin(organizationId, options) {
1245
- const params = new URLSearchParams();
1246
- if (options?.search) params.append("search", options.search);
1247
- if (options?.role) params.append("role", options.role);
1248
- if (options?.page) params.append("page", options.page.toString());
1249
- if (options?.pageSize) params.append("pageSize", options.pageSize.toString());
1250
- const qs = params.toString();
1251
- return this.fetch(
1252
- `admin/organizations/${organizationId}/members${qs ? `?${qs}` : ""}`
1253
- );
1254
- }
1255
- async createOrganization(data) {
1256
- return this.fetch("admin/organizations", {
1257
- method: "POST",
1258
- body: JSON.stringify(data)
1259
- });
1260
- }
1261
- async updateOrganization(id, data) {
1262
- return this.fetch(`admin/organizations/${id}`, {
1263
- method: "PUT",
1264
- body: JSON.stringify(data)
1265
- });
1266
- }
1267
- async deleteOrganization(id) {
1268
- return this.fetch(`admin/organizations/${id}`, {
1269
- method: "DELETE"
1270
- });
1271
- }
1272
- /**
1273
- * Join an organization with a specified role (superuser only).
1274
- * Creates or updates membership in the target org.
1275
- * @param orgUuid - Organization UUID or numeric ID as string
1276
- */
1277
- async joinOrganization(orgUuid, role = "owner") {
1278
- return this.fetch(`admin/organizations/${orgUuid}/join`, {
1279
- method: "POST",
1280
- body: JSON.stringify({ role })
1281
- });
1282
- }
1283
- /**
1284
- * Leave an organization (superuser only).
1285
- * @param orgUuid - Organization UUID or numeric ID as string
1286
- */
1287
- async leaveOrganization(orgUuid) {
1288
- return this.fetch(`admin/organizations/${orgUuid}/join`, {
1289
- method: "DELETE"
1290
- });
1291
- }
1292
- async generateLogoUploadUrl(organizationUuid, data) {
1293
- return this.fetch(`o/${organizationUuid}/logo-upload-url`, {
1294
- method: "POST",
1295
- body: JSON.stringify(data)
1296
- });
1297
- }
1298
- // Organization Members API - moved to OrgApi at /api/v2/o/{org_uuid}/members
1299
- // See packages/client/src/api/org.ts
1300
- // Organization Invitations API - moved to OrgApi at /api/v2/o/{org_uuid}/invitations
1301
- // See packages/client/src/api/org.ts
1302
- // Admin Products API
1303
- async importProducts(workspaceId) {
1304
- return this.fetch("admin/import-products", {
1305
- method: "POST",
1306
- body: JSON.stringify({ workspaceId })
1307
- });
1308
- }
1309
- // ===== Product CRUD =====
1310
- async createProductAsAdmin(product) {
1311
- return this.fetch("admin/products", {
1312
- method: "POST",
1313
- body: JSON.stringify(product)
1314
- });
1315
- }
1316
- async getProductsAsAdmin(workspaceUuid, productTypes) {
1317
- const params = new URLSearchParams();
1318
- if (workspaceUuid) {
1319
- params.append("workspace_uuid", workspaceUuid);
1320
- }
1321
- if (productTypes && productTypes.length > 0) {
1322
- productTypes.forEach((type) => params.append("product_types", type));
1323
- }
1324
- const queryString = params.toString();
1325
- return this.fetch(`admin/products${queryString ? `?${queryString}` : ""}`);
1326
- }
1327
- async getProductAsAdmin(productId) {
1328
- return this.fetch(`admin/products/${productId}`);
1329
- }
1330
- async updateProductAsAdmin(product_id, product) {
1331
- return this.fetch(`admin/products/${product_id}`, {
1332
- method: "PUT",
1333
- body: JSON.stringify(product)
1334
- });
1335
- }
1336
- async deleteProductAsAdmin(productId) {
1337
- return this.fetch(`admin/products/${productId}`, {
1338
- method: "DELETE"
1339
- });
1340
- }
1341
- // Admin Workspace API
1342
- async getWorkspacesAsAdmin(options = {}) {
1343
- const params = new URLSearchParams();
1344
- if (options.page !== void 0) params.append("page", options.page.toString());
1345
- if (options.pageSize !== void 0) params.append("pageSize", options.pageSize.toString());
1346
- if (options.sortBy) params.append("sortBy", options.sortBy);
1347
- if (options.sortOrder) params.append("sortOrder", options.sortOrder);
1348
- if (options.search) params.append("search", options.search);
1349
- if (options.isReseller !== void 0)
1350
- params.append("isReseller", options.isReseller.toString());
1351
- if (options.organizationId !== void 0)
1352
- params.append("organizationId", options.organizationId.toString());
1353
- if (options.noActiveSubscription) params.append("noActiveSubscription", "true");
1354
- return this.fetch(`admin/workspaces?${params.toString()}`);
1355
- }
1356
- async getWorkspaceAsAdmin(wid) {
1357
- return this.fetch(`admin/workspaces/${wid}`);
1358
- }
1359
- async getWorkspaceByNumericIdAsAdmin(workspace_id) {
1360
- return this.fetch(`admin/workspaces/id/${workspace_id}`);
1361
- }
1362
- async createWorkspaceAsAdmin(ws) {
1363
- return this.fetch("admin/workspaces", {
1364
- method: "POST",
1365
- body: JSON.stringify(ws)
1366
- });
1367
- }
1368
- async updateWorkspaceAsAdmin(wid, ws) {
1369
- return this.fetch(`admin/workspaces/${wid}`, {
1370
- method: "PUT",
1371
- body: JSON.stringify(ws)
1372
- });
1373
- }
1374
- async deleteWorkspaceAsAdmin(wid) {
1375
- return this.fetch(`admin/workspaces/${wid}`, {
1376
- method: "DELETE"
1377
- });
1378
- }
1379
- async createSchemaAsAdmin(wid) {
1380
- return this.fetch(`admin/workspaces/${wid}/provision/create`, {
1381
- method: "POST"
1382
- });
1383
- }
1384
- async migrateSchemaAsAdmin(wid) {
1385
- return this.fetch(`admin/workspaces/${wid}/provision/migrate`, {
1386
- method: "POST"
1387
- });
1388
- }
1389
- async provisionWorkspaceAsAdmin(wid) {
1390
- return this.fetch(`admin/workspaces/${wid}/provision`, {
1391
- method: "POST"
1392
- });
1393
- }
1394
- async refreshProvisionStatusAsAdmin(wid) {
1395
- return this.fetch(`admin/workspaces/${wid}/provision/refresh`, {
1396
- method: "POST"
1397
- });
1398
- }
1399
- async enableMaintenanceMode(wid) {
1400
- return this.fetch(`admin/workspaces/${wid}/maintenance`, {
1401
- method: "PUT"
1402
- });
1403
- }
1404
- async disableMaintenanceMode(wid) {
1405
- return this.fetch(`admin/workspaces/${wid}/maintenance`, {
1406
- method: "DELETE"
1407
- });
1408
- }
1409
- // ===== Workspace Health Check =====
1410
- async getWorkspaceHealth(workspaceUuid) {
1411
- return this.fetch(`admin/workspaces/${workspaceUuid}/health`);
1412
- }
1413
- async provisionPlanFeatures(workspaceUuid, request) {
1414
- return this.fetch(`admin/workspaces/${workspaceUuid}/provision-plan`, {
1415
- method: "POST",
1416
- body: JSON.stringify(request || {})
1417
- });
1418
- }
1419
- /**
1420
- * Switch a workspace's plan product on its active SubscriptionItem.
1421
- *
1422
- * Superuser only. Re-syncs ``workspace.features`` from the new product
1423
- * and emits a ``WORKSPACE_PRODUCT_CHANGED`` audit event identifying the
1424
- * actor, target workspace, prior and new product, and feature diff.
1425
- *
1426
- * Stripe is not touched here; price-id changes belong to the dedicated
1427
- * Stripe sync surface (``syncProductToStripe``).
1428
- */
1429
- async changeWorkspaceProduct(workspaceUuid, productId) {
1430
- const body = { productId };
1431
- return this.fetch(
1432
- `admin/workspaces/${workspaceUuid}/product`,
1433
- {
1434
- method: "POST",
1435
- body: JSON.stringify(body)
1436
- }
1437
- );
1438
- }
1439
- // ===== Workflow Access Validation =====
1440
- async validateWorkflowAccessAsAdmin(workspaceUuid) {
1441
- const params = new URLSearchParams();
1442
- if (workspaceUuid) params.append("workspace_uuid", workspaceUuid);
1443
- const qs = params.toString();
1444
- return this.fetch(
1445
- `admin/workspaces/validate-workflow-access${qs ? `?${qs}` : ""}`
1446
- );
1447
- }
1448
- async mergeMembers(wid, request) {
1449
- return this.fetch(`admin/workspaces/${wid}/merge-members`, {
1450
- method: "POST",
1451
- body: JSON.stringify(request)
1452
- });
1453
- }
1454
- async getAdminWorkspaceMember(wid) {
1455
- return this.fetch(`admin/workspaces/${wid}/me`, {
1456
- method: "GET"
1457
- });
1458
- }
1459
- async createAdminWorkspaceMember(wid, data) {
1460
- return this.fetch(`admin/workspaces/${wid}/me`, {
1461
- method: "POST",
1462
- body: JSON.stringify(data)
1463
- });
1464
- }
1465
- async updateAdminWorkspaceMember(wid, data) {
1466
- return this.fetch(`admin/workspaces/${wid}/me`, {
1467
- method: "PUT",
1468
- body: JSON.stringify(data)
1469
- });
1470
- }
1471
- async unarchiveAdminWorkspaceMember(wid) {
1472
- return this.fetch(`admin/workspaces/${wid}/me/unarchive`, {
1473
- method: "POST"
1474
- });
1475
- }
1476
- async getAdminWorkspaceMemberRoles(wid) {
1477
- return this.fetch(`admin/workspaces/${wid}/member-roles`);
1478
- }
1479
- async getUnmappedPhoneNumbers() {
1480
- return this.fetch(`admin/phone-numbers/unmapped`);
1481
- }
1482
- async getWorkspaceUnmappedPhoneNumbers(workspaceId) {
1483
- return this.fetch(
1484
- `admin/phone-numbers/workspace/${workspaceId}/unmapped`
1485
- );
1486
- }
1487
- async getWorkspacePhoneNumbersAsAdmin(workspaceRef) {
1488
- return this.fetch(`admin/workspaces/${workspaceRef}/phone-numbers`);
1489
- }
1490
- // Phone Numbers API (Provider phone numbers from Twilio, AWS, etc.)
1491
- async getProviderPhoneNumbers(options = {}) {
1492
- const params = new URLSearchParams();
1493
- if (options.page) params.append("page", options.page.toString());
1494
- if (options.pageSize) params.append("pageSize", options.pageSize.toString());
1495
- if (options.search) params.append("search", options.search);
1496
- if (options.isAssigned !== void 0)
1497
- params.append("is_assigned", String(options.isAssigned));
1498
- if (options.provider) params.append("provider", options.provider);
1499
- if (options.organizationId !== void 0)
1500
- params.append("organizationId", options.organizationId.toString());
1501
- if (options.sortBy) params.append("sortBy", options.sortBy);
1502
- if (options.sortOrder) params.append("sortOrder", options.sortOrder);
1503
- return this.fetch(
1504
- `admin/phone-numbers${params.toString() ? `?${params.toString()}` : ""}`
1505
- );
1506
- }
1507
- async getProviderPhoneNumber(id) {
1508
- return this.fetch(`admin/phone-numbers/${id}`);
1509
- }
1510
- async updateProviderPhoneNumber(id, data) {
1511
- return this.fetch(`admin/phone-numbers/${id}`, {
1512
- method: "PATCH",
1513
- body: JSON.stringify(data)
1514
- });
1515
- }
1516
- async mapMainAccountPhone(data) {
1517
- return this.fetch(`admin/phone-numbers/map-from-main-account`, {
1518
- method: "POST",
1519
- body: JSON.stringify(data)
1520
- });
1521
- }
1522
- async unmapPhoneNumber(data) {
1523
- return this.fetch(`admin/phone-numbers/unmap`, {
1524
- method: "POST",
1525
- body: JSON.stringify(data)
1526
- });
1527
- }
1528
- async searchAvailablePhoneNumbersAsAdmin(data) {
1529
- return this.fetch(`admin/phone-numbers/search`, {
1530
- method: "POST",
1531
- body: JSON.stringify(data)
1532
- });
1533
- }
1534
- async purchasePhoneNumberAsAdmin(data) {
1535
- return this.fetch(`admin/phone-numbers/purchase`, {
1536
- method: "POST",
1537
- body: JSON.stringify(data)
1538
- });
1539
- }
1540
- async getOrgA2PStatusAsAdmin(organizationId) {
1541
- return this.fetch(`admin/organizations/${organizationId}/a2p-status`);
1542
- }
1543
- async resetOrgA2PStatusAsAdmin(organizationId) {
1544
- return this.fetch(`admin/organizations/${organizationId}/a2p-status`, {
1545
- method: "DELETE"
1546
- });
1547
- }
1548
- // Site Mappings API
1549
- async getSiteMappings(options) {
1550
- const queryParams = new URLSearchParams();
1551
- if (options?.search) queryParams.append("search", options.search);
1552
- if (options?.page) queryParams.append("page", options.page.toString());
1553
- if (options?.pageSize) queryParams.append("pageSize", options.pageSize.toString());
1554
- const queryString = queryParams.toString();
1555
- const url = `admin/site-mappings${queryString ? `?${queryString}` : ""}`;
1556
- return this.fetch(url);
1557
- }
1558
- async getSiteMapping(siteId) {
1559
- return this.fetch(`admin/site-mappings/${siteId}`);
1560
- }
1561
- async updateSiteMapping(siteId, data) {
1562
- return this.fetch(`admin/site-mappings/${siteId}`, {
1563
- method: "PUT",
1564
- body: JSON.stringify(data)
1565
- });
1566
- }
1567
- async updateSiteMappingWorkspace(siteId, workspaceId) {
1568
- return this.updateSiteMapping(siteId, {
1569
- workspaceId,
1570
- siteUuid: ""
1571
- // These fields are required by the type but will be ignored on the server
1572
- });
1573
- }
1574
- async adminDeleteSiteMapping(siteId) {
1575
- return this.fetch(`admin/site-mappings/${siteId}`, {
1576
- method: "DELETE"
1577
- });
1578
- }
1579
- async createSiteMapping(mapping) {
1580
- return this.fetch(`admin/site-mappings`, {
1581
- method: "POST",
1582
- body: JSON.stringify(mapping)
1583
- });
1584
- }
1585
- // Keep for backward compatibility
1586
- async createOrUpdateSiteMapping(wid, mapping) {
1587
- return this.fetch(`admin/workspaces/${wid}/site-mappings`, {
1588
- method: "POST",
1589
- body: JSON.stringify(mapping)
1590
- });
1591
- }
1592
- async deleteSiteMapping(wid, siteUuid) {
1593
- return this.fetch(`admin/workspaces/${wid}/site-mappings/${siteUuid}`, {
1594
- method: "DELETE"
1595
- });
1596
- }
1597
- async getWorkspaceInboxesAsAdmin(workspaceUuid) {
1598
- return this.fetch(
1599
- `admin/workspaces/${workspaceUuid}/inboxes`
1600
- );
1601
- }
1602
- // Admin Inbox Mappings API
1603
- async getInboxMappings(options = {}) {
1604
- const params = new URLSearchParams();
1605
- if (options.page) params.append("page", options.page.toString());
1606
- if (options.pageSize) params.append("pageSize", options.pageSize.toString());
1607
- if (options.search) params.append("search", options.search);
1608
- if (options.workspaceId) params.append("workspaceId", options.workspaceId.toString());
1609
- return this.fetch(
1610
- `admin/inbox-mappings${params.toString() ? `?${params.toString()}` : ""}`
1611
- );
1612
- }
1613
- async getInboxMapping(id) {
1614
- return this.fetch(`admin/inbox-mappings/${id}`);
1615
- }
1616
- async updateInboxMapping(id, workspaceId) {
1617
- return this.fetch(`admin/inbox-mappings/${id}`, {
1618
- method: "PUT",
1619
- body: JSON.stringify({ workspaceId })
1620
- });
1621
- }
1622
- async deleteAdminInboxMapping(id) {
1623
- return this.fetch(`admin/inbox-mappings/${id}`, {
1624
- method: "DELETE"
1625
- });
1626
- }
1627
- // Evaluation API
1628
- async generateChatSummaries(options) {
1629
- return this.fetch("admin/generate-summaries", {
1630
- method: "POST",
1631
- body: JSON.stringify({
1632
- after_date: options.afterDate ? options.afterDate.toISOString().split("T")[0] + "T" + options.afterDate.toTimeString().split(" ")[0] : void 0,
1633
- only_without_summaries: options.onlyWithoutSummaries ?? true
1634
- })
1635
- });
1636
- }
1637
- async executeQuery(options) {
1638
- return this.fetch("admin/execute-query", {
1639
- method: "POST",
1640
- body: JSON.stringify({
1641
- query: options.query,
1642
- workspace_uuid: options.workspaceUuid
1643
- })
1644
- });
1645
- }
1646
- /**
1647
- * Resolve a Langfuse trace UI URL from a trace ID, chat ID, or message ID.
1648
- *
1649
- * URL-only: never fetches Langfuse payloads, Message content, or
1650
- * tool arguments. Exactly one of ``traceId``, ``chatId``, or
1651
- * ``messageId`` must be set; chat/message forms require a
1652
- * workspaceUuid. See
1653
- * docs/development/observability/llm-call-investigation.md.
1654
- */
1655
- async getTraceUrl(options) {
1656
- return this.fetch("admin/trace/url", {
1657
- method: "POST",
1658
- body: JSON.stringify({
1659
- trace_id: options.traceId,
1660
- chat_id: options.chatId,
1661
- message_id: options.messageId,
1662
- workspace_uuid: options.workspaceUuid
1663
- })
1664
- });
1665
- }
1666
- // Admin Themes API
1667
- async listAllThemes() {
1668
- return this.fetch("admin/themes/list");
1669
- }
1670
- // Missing Memberships API
1671
- async getMissingMemberships(workspaceId) {
1672
- return this.fetch(
1673
- `admin/workspaces/${workspaceId}/missing-memberships`
1674
- );
1675
- }
1676
- async linkMissingMembership(workspaceId, memberId, accountId) {
1677
- return this.fetch(
1678
- `admin/workspaces/${workspaceId}/link-membership?member_id=${memberId}&account_id=${accountId}`,
1679
- {
1680
- method: "POST"
1681
- }
1682
- );
1683
- }
1684
- // Bulk Phone Classification API
1685
- async startBulkPhoneClassification(workspaceUuid, includeUnknown = false) {
1686
- const params = new URLSearchParams();
1687
- params.append("include_unknown", includeUnknown.toString());
1688
- return this.fetch(`admin/workspaces/${workspaceUuid}/bulk-classify-phones?${params.toString()}`, {
1689
- method: "POST"
1690
- });
1691
- }
1692
- // Bulk TOS Acceptance API
1693
- async startBulkTOSAcceptance(workspaceUuid) {
1694
- return this.fetch(`admin/workspaces/${workspaceUuid}/bulk-accept-tos`, {
1695
- method: "POST"
1696
- });
1697
- }
1698
- // Token Usage Backfill API
1699
- async startTokenUsageBackfill(workspaceUuid) {
1700
- return this.fetch(`admin/workspaces/${workspaceUuid}/backfill-token-usage`, {
1701
- method: "POST"
1702
- });
1703
- }
1704
- // ===== Admin Chat Endpoints =====
1705
- async listWorkspaceChats(workspaceUuid, options) {
1706
- const params = new URLSearchParams();
1707
- if (options?.page) params.set("page", String(options.page));
1708
- if (options?.pageSize) params.set("pageSize", String(options.pageSize));
1709
- if (options?.search) params.set("search", options.search);
1710
- if (options?.chatType) params.set("chatType", options.chatType);
1711
- if (options?.channel) params.set("channel", options.channel);
1712
- if (options?.archived !== void 0) params.set("archived", String(options.archived));
1713
- const qs = params.toString();
1714
- return this.fetch(
1715
- `admin/workspaces/${workspaceUuid}/chats${qs ? `?${qs}` : ""}`
1716
- );
1717
- }
1718
- async getWorkspaceChat(workspaceUuid, chatId, options) {
1719
- const params = new URLSearchParams();
1720
- if (options?.page) params.set("page", String(options.page));
1721
- if (options?.pageSize) params.set("pageSize", String(options.pageSize));
1722
- const qs = params.toString();
1723
- return this.fetch(
1724
- `admin/workspaces/${workspaceUuid}/chats/${chatId}${qs ? `?${qs}` : ""}`
1725
- );
1726
- }
1727
- // Update chat message content
1728
- async updateChatMessage(workspaceUuid, chatId, messageId, content) {
1729
- return this.fetch(`admin/workspaces/${workspaceUuid}/chats/${chatId}/messages/${messageId}`, {
1730
- method: "POST",
1731
- body: JSON.stringify({ content })
1732
- });
1733
- }
1734
- async rateWorkspaceChatMessage(workspaceUuid, chatId, messageId, rating, comment) {
1735
- return this.fetch(
1736
- `admin/workspaces/${workspaceUuid}/chats/${chatId}/messages/${messageId}/rate`,
1737
- {
1738
- method: "POST",
1739
- body: JSON.stringify({ rating, comment })
1740
- }
1741
- );
1742
- }
1743
- // ===== Stripe Customer Management =====
1744
- async getStripeCustomer(accountId) {
1745
- return this.fetch(`admin/accounts/${accountId}/stripe/customer`);
1746
- }
1747
- async createStripeCustomer(accountId, data) {
1748
- return this.fetch(`admin/accounts/${accountId}/stripe/customer`, {
1749
- method: "POST",
1750
- body: JSON.stringify(data)
1751
- });
1752
- }
1753
- async updateStripeCustomer(accountId, data) {
1754
- return this.fetch(`admin/accounts/${accountId}/stripe/customer`, {
1755
- method: "PUT",
1756
- body: JSON.stringify(data)
1757
- });
1758
- }
1759
- // ===== Customer Management =====
1760
- async createCustomerFromAccount(accountId) {
1761
- return this.fetch(`admin/accounts/${accountId}/customer`, {
1762
- method: "POST"
1763
- });
1764
- }
1765
- async getCustomers(options) {
1766
- const params = new URLSearchParams();
1767
- if (options?.search) params.set("search", options.search);
1768
- if (options?.page) params.set("page", String(options.page));
1769
- if (options?.pageSize) params.set("page_size", String(options.pageSize));
1770
- const qs = params.toString();
1771
- return this.fetch(`admin/customers${qs ? `?${qs}` : ""}`);
1772
- }
1773
- async getCustomer(customerId) {
1774
- return this.fetch(`admin/customers/${customerId}`);
1775
- }
1776
- async createCustomer(data) {
1777
- return this.fetch("admin/customers", {
1778
- method: "POST",
1779
- body: JSON.stringify(data)
1780
- });
1781
- }
1782
- async updateCustomer(customerId, data) {
1783
- return this.fetch(`admin/customers/${customerId}`, {
1784
- method: "PUT",
1785
- body: JSON.stringify(data)
1786
- });
1787
- }
1788
- async syncCustomerToStripe(customerId) {
1789
- return this.fetch(`admin/customers/${customerId}/stripe/sync`, {
1790
- method: "POST"
1791
- });
1792
- }
1793
- async getCustomerAccounts(customerId) {
1794
- return this.fetch(`admin/customers/${customerId}/accounts`);
1795
- }
1796
- async linkCustomerToAccount(customerId, accountId, role) {
1797
- return this.fetch(`admin/customers/${customerId}/accounts`, {
1798
- method: "POST",
1799
- body: JSON.stringify({ accountId, role })
1800
- });
1801
- }
1802
- async unlinkCustomerFromAccount(customerId, accountId) {
1803
- await this.fetch(`admin/customers/${customerId}/accounts/${accountId}`, {
1804
- method: "DELETE"
1805
- });
1806
- }
1807
- // ===== Stripe Subscription Management =====
1808
- async getStripeSubscriptions(accountId) {
1809
- return this.fetch(`admin/accounts/${accountId}/stripe/subscriptions`);
1810
- }
1811
- async createStripeSubscription(customerId, data) {
1812
- return this.fetch(`admin/customers/${customerId}/stripe/subscriptions`, {
1813
- method: "POST",
1814
- body: JSON.stringify(data)
1815
- });
1816
- }
1817
- async createDirectSubscription(customerId, data) {
1818
- return this.fetch(`admin/customers/${customerId}/direct/subscriptions`, {
1819
- method: "POST",
1820
- body: JSON.stringify(data)
1821
- });
1822
- }
1823
- async updateStripeSubscription(accountId, subscriptionId, data) {
1824
- return this.fetch(
1825
- `admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}`,
1826
- {
1827
- method: "PUT",
1828
- body: JSON.stringify(data)
1829
- }
1830
- );
1831
- }
1832
- async cancelStripeSubscription(accountId, subscriptionId) {
1833
- return this.fetch(
1834
- `admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}`,
1835
- {
1836
- method: "DELETE"
1837
- }
1838
- );
1839
- }
1840
- async provisionWorkspaceForSubscription(accountId, subscriptionId) {
1841
- return this.fetch(
1842
- `admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}/provision`,
1843
- {
1844
- method: "POST"
1845
- }
1846
- );
1847
- }
1848
- async associateWorkspaceWithSubscription(accountId, subscriptionId, workspaceId) {
1849
- return this.fetch(
1850
- `admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}/associate?workspace_id=${workspaceId}`,
1851
- {
1852
- method: "POST"
1853
- }
1854
- );
1855
- }
1856
- async createSubscriptionPaymentLink(accountId, subscriptionId) {
1857
- return this.fetch(`admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}/payment-link`, {
1858
- method: "POST"
1859
- });
1860
- }
1861
- // ===== Stripe Payment Methods Management =====
1862
- async createSetupIntent(accountId) {
1863
- return this.fetch(`admin/accounts/${accountId}/stripe/setup-intent`, {
1864
- method: "POST"
1865
- });
1866
- }
1867
- async getStripePaymentMethods(accountId) {
1868
- return this.fetch(
1869
- `admin/accounts/${accountId}/stripe/payment-methods`
1870
- );
1871
- }
1872
- async attachStripePaymentMethod(accountId, paymentMethodId, setAsDefault = false) {
1873
- return this.fetch(`admin/accounts/${accountId}/stripe/payment-methods/${paymentMethodId}/attach`, {
1874
- method: "POST",
1875
- body: JSON.stringify({ setAsDefault })
1876
- });
1877
- }
1878
- async detachStripePaymentMethod(accountId, paymentMethodId) {
1879
- return this.fetch(
1880
- `admin/accounts/${accountId}/stripe/payment-methods/${paymentMethodId}`,
1881
- {
1882
- method: "DELETE"
1883
- }
1884
- );
1885
- }
1886
- async setDefaultStripePaymentMethod(accountId, paymentMethodId) {
1887
- return this.fetch(
1888
- `admin/accounts/${accountId}/stripe/payment-methods/${paymentMethodId}/set-default`,
1889
- {
1890
- method: "PUT"
1891
- }
1892
- );
1893
- }
1894
- // ===== Convert Direct Subscription to Stripe =====
1895
- async convertSubscriptionToStripe(customerId, subscriptionId) {
1896
- return this.fetch(
1897
- `admin/customers/${customerId}/subscriptions/${subscriptionId}/convert-to-stripe`,
1898
- { method: "POST" }
1899
- );
1900
- }
1901
- // ===== Customer-Level Stripe Payment Methods =====
1902
- async createCustomerSetupIntent(customerId) {
1903
- return this.fetch(`admin/customers/${customerId}/stripe/setup-intent`, {
1904
- method: "POST"
1905
- });
1906
- }
1907
- async getCustomerPaymentMethods(customerId) {
1908
- return this.fetch(
1909
- `admin/customers/${customerId}/stripe/payment-methods`
1910
- );
1911
- }
1912
- async attachCustomerPaymentMethod(customerId, paymentMethodId, setAsDefault = false) {
1913
- return this.fetch(`admin/customers/${customerId}/stripe/payment-methods/${paymentMethodId}/attach`, {
1914
- method: "POST",
1915
- body: JSON.stringify({ setAsDefault })
1916
- });
1917
- }
1918
- async detachCustomerPaymentMethod(customerId, paymentMethodId) {
1919
- return this.fetch(
1920
- `admin/customers/${customerId}/stripe/payment-methods/${paymentMethodId}`,
1921
- {
1922
- method: "DELETE"
1923
- }
1924
- );
1925
- }
1926
- async setDefaultCustomerPaymentMethod(customerId, paymentMethodId) {
1927
- return this.fetch(
1928
- `admin/customers/${customerId}/stripe/payment-methods/${paymentMethodId}/set-default`,
1929
- {
1930
- method: "PUT"
1931
- }
1932
- );
1933
- }
1934
- // ===== Workspace Organization Migration =====
1935
- async previewWorkspaceOrganizationChange(workspaceUuid, targetOrganizationId, newCreatorId) {
1936
- return this.fetch(`admin/workspaces/${workspaceUuid}/change-org/preview`, {
1937
- method: "POST",
1938
- headers: {
1939
- "Content-Type": "application/json"
1940
- },
1941
- body: JSON.stringify({
1942
- targetOrganizationId,
1943
- newCreatorId
1944
- })
1945
- });
1946
- }
1947
- async changeWorkspaceOrganization(workspaceUuid, targetOrganizationId, newCreatorId) {
1948
- return this.fetch(`admin/workspaces/${workspaceUuid}/change-org`, {
1949
- method: "POST",
1950
- body: JSON.stringify({
1951
- targetOrganizationId,
1952
- newCreatorId
1953
- })
1954
- });
1955
- }
1956
- // ===== Stripe Invoice Management =====
1957
- async createStripeInvoice(accountId, data) {
1958
- return this.fetch(`admin/accounts/${accountId}/stripe/invoices`, {
1959
- method: "POST",
1960
- body: JSON.stringify({
1961
- customer: data.customer,
1962
- description: data.description,
1963
- collection_method: data.collectionMethod,
1964
- days_until_due: data.daysUntilDue,
1965
- auto_advance: data.autoAdvance,
1966
- metadata: data.metadata
1967
- })
1968
- });
1969
- }
1970
- async getStripeInvoices(accountId, options) {
1971
- const params = new URLSearchParams();
1972
- if (options?.limit) params.append("limit", options.limit.toString());
1973
- if (options?.startingAfter) params.append("starting_after", options.startingAfter);
1974
- return this.fetch(`admin/accounts/${accountId}/stripe/invoices?${params.toString()}`);
1975
- }
1976
- async getStripeUpcomingInvoice(accountId, subscriptionId) {
1977
- const params = new URLSearchParams();
1978
- if (subscriptionId) params.append("subscription_id", subscriptionId);
1979
- return this.fetch(`admin/accounts/${accountId}/stripe/upcoming-invoice?${params.toString()}`);
1980
- }
1981
- // Billing Dashboard API
1982
- async getWorkspaceUsageDashboard(workspaceUuid) {
1983
- return this.fetch(
1984
- `admin/workspaces/${workspaceUuid}/usage-dashboard`
1985
- );
1986
- }
1987
- // Product Stripe Sync API
1988
- async compareProductsWithStripe(workspaceUuid) {
1989
- const params = workspaceUuid ? `?workspace_uuid=${encodeURIComponent(workspaceUuid)}` : "";
1990
- return this.fetch(`admin/products/compare-stripe${params}`);
1991
- }
1992
- async syncProductToStripe(productId, request) {
1993
- return this.fetch(`admin/products/${productId}/sync-stripe`, {
1994
- method: "POST",
1995
- body: JSON.stringify({ ...request, productId })
1996
- });
1997
- }
1998
- // Search Stripe products
1999
- async searchStripeProducts(query, limit = 10) {
2000
- const params = new URLSearchParams({ query, limit: limit.toString() });
2001
- return this.fetch(`admin/products/stripe/search?${params.toString()}`);
2002
- }
2003
- // ===== Subscriptions API =====
2004
- async getSubscriptionsAsAdmin(options) {
2005
- const params = new URLSearchParams();
2006
- if (options?.productId) params.append("product_id", options.productId.toString());
2007
- if (options?.productType) params.append("product_type", options.productType);
2008
- if (options?.customerId) params.append("customer_id", options.customerId.toString());
2009
- if (options?.organizationId)
2010
- params.append("organization_id", options.organizationId.toString());
2011
- if (options?.accountId) params.append("account_id", options.accountId.toString());
2012
- if (options?.isDirect !== void 0) params.append("is_direct", options.isDirect.toString());
2013
- if (options?.status) params.append("status", options.status);
2014
- if (options?.page) params.append("page", options.page.toString());
2015
- if (options?.pageSize) params.append("page_size", options.pageSize.toString());
2016
- const queryString = params.toString();
2017
- return this.fetch(
2018
- `admin/subscriptions${queryString ? `?${queryString}` : ""}`
2019
- );
2020
- }
2021
- async getSubscriptionAsAdmin(subscriptionId) {
2022
- return this.fetch(`admin/subscriptions/${subscriptionId}`);
2023
- }
2024
- async updateSubscriptionStatusAsAdmin(subscriptionId, subscriptionStatus) {
2025
- return this.fetch(`admin/subscriptions/${subscriptionId}`, {
2026
- method: "PUT",
2027
- body: JSON.stringify({ subscription_status: subscriptionStatus })
2028
- });
2029
- }
2030
- async updateSubscriptionCreditSettingsAsAdmin(subscriptionId, settings) {
2031
- return this.fetch(`admin/subscriptions/${subscriptionId}`, {
2032
- method: "PUT",
2033
- body: JSON.stringify(settings)
2034
- });
2035
- }
2036
- /** Grant credits to a subscription (superuser only). */
2037
- async grantCreditsAsAdmin(subscriptionId, creditUnits, grantType, reason) {
2038
- return this.fetch(`admin/subscriptions/${subscriptionId}/grant-credits`, {
2039
- method: "POST",
2040
- body: JSON.stringify({ credit_units: creditUnits, grant_type: grantType, reason })
2041
- });
2042
- }
2043
- /** List credit grants for a subscription (superuser only). */
2044
- async listCreditGrantsAsAdmin(subscriptionId) {
2045
- return this.fetch(`admin/subscriptions/${subscriptionId}/credit-grants`);
2046
- }
2047
- // ===== Usage API =====
2048
- async getUsageReport(request) {
2049
- return this.fetch("admin/usage", {
2050
- method: "POST",
2051
- body: JSON.stringify(request)
2052
- });
2053
- }
2054
- // Voice Metrics API
2055
- async getVoiceMetrics(options) {
2056
- const params = new URLSearchParams();
2057
- if (options?.hours) params.append("hours", options.hours.toString());
2058
- if (options?.period) params.append("period", options.period.toString());
2059
- if (options?.workspace_uuid) params.append("workspace_uuid", options.workspace_uuid);
2060
- if (options?.organization_id != null)
2061
- params.append("organization_id", options.organization_id.toString());
2062
- if (options?.engine) params.append("engine", options.engine);
2063
- if (options?.channel) params.append("channel", options.channel);
2064
- const qs = params.toString();
2065
- return this.fetch(`admin/voice-metrics${qs ? `?${qs}` : ""}`);
2066
- }
2067
- // Health Dashboard API
2068
- async getHealthMetrics(request) {
2069
- return this.fetch("admin/health/metrics", {
2070
- method: "POST",
2071
- body: JSON.stringify(request)
2072
- });
2073
- }
2074
- async getHealthDetail(workspaceUuid, request) {
2075
- return this.fetch(`admin/health/detail/${workspaceUuid}`, {
2076
- method: "POST",
2077
- body: JSON.stringify(request)
2078
- });
2079
- }
2080
- // ===== Reseller Management =====
2081
- async getResellers(options) {
2082
- const params = new URLSearchParams();
2083
- if (options?.search) params.set("search", options.search);
2084
- if (options?.page) params.set("page", String(options.page));
2085
- if (options?.pageSize) params.set("page_size", String(options.pageSize));
2086
- const qs = params.toString();
2087
- return this.fetch(`admin/resellers${qs ? `?${qs}` : ""}`);
2088
- }
2089
- async getReseller(resellerId) {
2090
- return this.fetch(`admin/resellers/${resellerId}`);
2091
- }
2092
- async createReseller(data) {
2093
- return this.fetch("admin/resellers", {
2094
- method: "POST",
2095
- body: JSON.stringify(data)
2096
- });
2097
- }
2098
- async updateReseller(resellerId, data) {
2099
- return this.fetch(`admin/resellers/${resellerId}`, {
2100
- method: "PUT",
2101
- body: JSON.stringify(data)
2102
- });
2103
- }
2104
- async getResellerAccounts(resellerId) {
2105
- return this.fetch(`admin/resellers/${resellerId}/accounts`);
2106
- }
2107
- async linkResellerToAccount(resellerId, data) {
2108
- return this.fetch(`admin/resellers/${resellerId}/accounts`, {
2109
- method: "POST",
2110
- body: JSON.stringify({ account_id: data.accountId, role: data.role })
2111
- });
2112
- }
2113
- async unlinkResellerFromAccount(resellerId, accountId) {
2114
- await this.fetch(`admin/resellers/${resellerId}/accounts/${accountId}`, {
2115
- method: "DELETE"
2116
- });
2117
- }
2118
- // ===== Invoice Management =====
2119
- async generateInvoice(data) {
2120
- return this.fetch("admin/invoices/generate", {
2121
- method: "POST",
2122
- body: JSON.stringify(data)
2123
- });
2124
- }
2125
- async getInvoices(subscriptionId, pageOpts) {
2126
- const params = new URLSearchParams();
2127
- if (subscriptionId !== void 0) params.set("subscription_id", String(subscriptionId));
2128
- if (pageOpts?.page !== void 0) params.set("page", String(pageOpts.page));
2129
- if (pageOpts?.pageSize !== void 0) params.set("pageSize", String(pageOpts.pageSize));
2130
- const qs = params.toString();
2131
- return this.fetch(`admin/invoices${qs ? `?${qs}` : ""}`);
2132
- }
2133
- async getBillingPeriods(subscriptionId) {
2134
- return this.fetch(
2135
- `admin/invoices/periods?subscription_id=${subscriptionId}`
2136
- );
2137
- }
2138
- async getInvoiceDownloadUrl(invoiceId) {
2139
- return this.fetch(
2140
- `admin/invoices/${invoiceId}/download`
2141
- );
2142
- }
2143
- async getReceiptDownloadUrl(invoiceId) {
2144
- return this.fetch(
2145
- `admin/invoices/${invoiceId}/receipt`
2146
- );
2147
- }
2148
- async recordInvoicePayment(invoiceId, data) {
2149
- return this.fetch(`admin/invoices/${invoiceId}/record-payment`, {
2150
- method: "POST",
2151
- body: JSON.stringify(data)
2152
- });
2153
- }
2154
- // ===== Admin Temporal Inspection (PHI-safe, read-only) =====
2155
- /**
2156
- * Server-enforced bounds for admin Temporal queries (lookback, thresholds,
2157
- * page sizes, history event cap). Superuser only.
2158
- */
2159
- async getTemporalAdminConfig() {
2160
- return this.fetch("admin/temporal/config");
2161
- }
2162
- /**
2163
- * List recent Temporal workflows in FAILED, TIMED_OUT, or TERMINATED
2164
- * status. Returns only PHI-safe operational metadata. Superuser only.
2165
- *
2166
- * Pass `options.status` to filter to a single status and enable
2167
- * deep pagination via `nextPageToken`. Merged mode (no status) returns
2168
- * the first page only and always emits `nextPageToken: null`.
2169
- */
2170
- async listFailedTemporalWorkflows(options = {}) {
2171
- const params = new URLSearchParams();
2172
- if (options.lookbackHours !== void 0)
2173
- params.set("lookback_hours", String(options.lookbackHours));
2174
- if (options.pageSize !== void 0) params.set("page_size", String(options.pageSize));
2175
- if (options.status) params.set("status", String(options.status));
2176
- if (options.nextPageToken) params.set("next_page_token", options.nextPageToken);
2177
- appendTemporalWorkspaceParams(params, options);
2178
- const qs = params.toString();
2179
- return this.fetch(
2180
- `admin/temporal/workflows/failed${qs ? `?${qs}` : ""}`
2181
- );
2182
- }
2183
- /**
2184
- * List open Temporal workflows older than the stuck threshold.
2185
- * Superuser only.
2186
- */
2187
- async listStuckTemporalWorkflows(options = {}) {
2188
- const params = new URLSearchParams();
2189
- if (options.thresholdMinutes !== void 0)
2190
- params.set("threshold_minutes", String(options.thresholdMinutes));
2191
- if (options.pageSize !== void 0) params.set("page_size", String(options.pageSize));
2192
- if (options.nextPageToken) params.set("next_page_token", options.nextPageToken);
2193
- appendTemporalWorkspaceParams(params, options);
2194
- const qs = params.toString();
2195
- return this.fetch(
2196
- `admin/temporal/workflows/stuck${qs ? `?${qs}` : ""}`
2197
- );
2198
- }
2199
- /**
2200
- * Return grouped counts for recent Temporal executions. Superuser only.
2201
- */
2202
- async getTemporalSummary(options = {}) {
2203
- const params = new URLSearchParams();
2204
- if (options.lookbackHours !== void 0)
2205
- params.set("lookback_hours", String(options.lookbackHours));
2206
- appendTemporalWorkspaceParams(params, options);
2207
- const qs = params.toString();
2208
- return this.fetch(
2209
- `admin/temporal/workflows/summary${qs ? `?${qs}` : ""}`
2210
- );
2211
- }
2212
- /**
2213
- * Fetch metadata + bounded sanitized history summary for one Temporal
2214
- * workflow. Superuser only. Does not return raw events or payloads.
2215
- */
2216
- async getTemporalWorkflowDetail(workflowId, options = {}) {
2217
- const params = new URLSearchParams();
2218
- if (options.runId) params.set("run_id", options.runId);
2219
- appendTemporalWorkspaceParams(params, options);
2220
- const qs = params.toString();
2221
- const encoded = encodeURIComponent(workflowId);
2222
- return this.fetch(
2223
- `admin/temporal/workflows/${encoded}${qs ? `?${qs}` : ""}`
2224
- );
2225
- }
2226
- // ── Customer activity events (cross-workspace operator feed) ──────────────
2227
- async listCustomerActivityEvents(params = {}) {
2228
- const qs = new URLSearchParams();
2229
- if (params.page) qs.set("page", String(params.page));
2230
- if (params.pageSize) qs.set("pageSize", String(params.pageSize));
2231
- if (params.status) qs.set("status", params.status);
2232
- if (params.subjectType) qs.set("subjectType", params.subjectType);
2233
- if (params.source) qs.set("source", params.source);
2234
- if (params.severity) qs.set("severity", params.severity);
2235
- if (params.disposition) qs.set("disposition", params.disposition);
2236
- if (params.workspaceId !== void 0) qs.set("workspaceId", String(params.workspaceId));
2237
- if (params.organizationId !== void 0)
2238
- qs.set("organizationId", String(params.organizationId));
2239
- if (params.accountId !== void 0) qs.set("accountId", String(params.accountId));
2240
- const query = qs.toString();
2241
- return this.fetch(
2242
- `admin/customer-activity${query ? `?${query}` : ""}`
2243
- );
2244
- }
2245
- async getCustomerActivityEvent(uuid) {
2246
- return this.fetch(`admin/customer-activity/${uuid}`);
2247
- }
2248
- async setCustomerActivityEventDisposition(uuid, data) {
2249
- return this.fetch(`admin/customer-activity/${uuid}/disposition`, {
2250
- method: "POST",
2251
- body: JSON.stringify(data)
2252
- });
2253
- }
2254
- async setCustomerActivityEventStatus(uuid, data) {
2255
- return this.fetch(`admin/customer-activity/${uuid}/status`, {
2256
- method: "POST",
2257
- body: JSON.stringify(data)
2258
- });
2259
- }
2260
- async reclassifyCustomerActivityEvent(uuid) {
2261
- return this.fetch(`admin/customer-activity/${uuid}/reclassify`, {
2262
- method: "POST"
2263
- });
2264
- }
2265
- };
2266
- ApiClient = class extends GravityRailClient {
2267
- // Admin API
2268
- listSupportRequestsAsAdmin;
2269
- getSupportRequestAsAdmin;
2270
- commentOnSupportRequestAsAdmin;
2271
- noteOnSupportRequestAsAdmin;
2272
- updateSupportRequestStatusAsAdmin;
2273
- updateSupportRequestAttributesAsAdmin;
2274
- createSupportRequestLinearIssueAsAdmin;
2275
- createOutboundSupportRequestAsAdmin;
2276
- attachSupportRequestResourceAsAdmin;
2277
- revokeSupportRequestResourceAsAdmin;
2278
- listCustomerActivityEvents;
2279
- getCustomerActivityEvent;
2280
- setCustomerActivityEventDisposition;
2281
- setCustomerActivityEventStatus;
2282
- reclassifyCustomerActivityEvent;
2283
- getAccounts;
2284
- getAccountDetails;
2285
- getAccountByUuid;
2286
- getAccountMemberships;
2287
- getAccountOrgMemberships;
2288
- createAccountOrgMembership;
2289
- deleteAccountOrgMembership;
2290
- getAccountMembership;
2291
- updateAccountMembership;
2292
- createAccountMembership;
2293
- deleteAccountMembership;
2294
- updateAccountAsAdmin;
2295
- createAccountAsAdmin;
2296
- deleteAccountAsAdmin;
2297
- lookupAccount;
2298
- exportAccountData;
2299
- requestAccountDeletion;
2300
- cancelAccountDeletion;
2301
- getOrganizations;
2302
- getOrganization;
2303
- getOrganizationAsAdmin;
2304
- getOrganizationMembersAsAdmin;
2305
- createOrganization;
2306
- updateOrganization;
2307
- deleteOrganization;
2308
- joinOrganization;
2309
- leaveOrganization;
2310
- generateLogoUploadUrl;
2311
- importProducts;
2312
- createProductAsAdmin;
2313
- getProductsAsAdmin;
2314
- getProductAsAdmin;
2315
- updateProductAsAdmin;
2316
- deleteProductAsAdmin;
2317
- getWorkspacesAsAdmin;
2318
- getWorkspaceAsAdmin;
2319
- getWorkspaceByNumericIdAsAdmin;
2320
- createWorkspaceAsAdmin;
2321
- updateWorkspaceAsAdmin;
2322
- deleteWorkspaceAsAdmin;
2323
- createSchemaAsAdmin;
2324
- migrateSchemaAsAdmin;
2325
- provisionWorkspaceAsAdmin;
2326
- refreshProvisionStatusAsAdmin;
2327
- enableMaintenanceMode;
2328
- disableMaintenanceMode;
2329
- getWorkspaceHealth;
2330
- provisionPlanFeatures;
2331
- changeWorkspaceProduct;
2332
- validateWorkflowAccessAsAdmin;
2333
- mergeMembers;
2334
- getAdminWorkspaceMember;
2335
- createAdminWorkspaceMember;
2336
- updateAdminWorkspaceMember;
2337
- unarchiveAdminWorkspaceMember;
2338
- getAdminWorkspaceMemberRoles;
2339
- getMissingMemberships;
2340
- linkMissingMembership;
2341
- getUnmappedPhoneNumbers;
2342
- getWorkspaceUnmappedPhoneNumbers;
2343
- getWorkspacePhoneNumbersAsAdmin;
2344
- getProviderPhoneNumbers;
2345
- getProviderPhoneNumber;
2346
- updateProviderPhoneNumber;
2347
- mapMainAccountPhone;
2348
- unmapPhoneNumber;
2349
- searchAvailablePhoneNumbersAsAdmin;
2350
- purchasePhoneNumberAsAdmin;
2351
- startBulkPhoneClassification;
2352
- getOrgA2PStatusAsAdmin;
2353
- resetOrgA2PStatusAsAdmin;
2354
- getSiteMappings;
2355
- getSiteMapping;
2356
- updateSiteMapping;
2357
- updateSiteMappingWorkspace;
2358
- adminDeleteSiteMapping;
2359
- createSiteMapping;
2360
- createOrUpdateSiteMapping;
2361
- deleteSiteMapping;
2362
- getInboxMappings;
2363
- getInboxMapping;
2364
- updateInboxMapping;
2365
- deleteAdminInboxMapping;
2366
- generateChatSummaries;
2367
- executeQuery;
2368
- getTraceUrl;
2369
- listAllThemes;
2370
- startBulkTOSAcceptance;
2371
- startTokenUsageBackfill;
2372
- updateChatMessage;
2373
- createCustomerFromAccount;
2374
- getCustomers;
2375
- getCustomer;
2376
- createCustomer;
2377
- updateCustomer;
2378
- getCustomerAccounts;
2379
- linkCustomerToAccount;
2380
- unlinkCustomerFromAccount;
2381
- syncCustomerToStripe;
2382
- getStripeCustomer;
2383
- createStripeCustomer;
2384
- updateStripeCustomer;
2385
- getStripeSubscriptions;
2386
- createStripeSubscription;
2387
- createDirectSubscription;
2388
- updateStripeSubscription;
2389
- cancelStripeSubscription;
2390
- provisionWorkspaceForSubscription;
2391
- associateWorkspaceWithSubscription;
2392
- createSubscriptionPaymentLink;
2393
- createSetupIntent;
2394
- getStripePaymentMethods;
2395
- attachStripePaymentMethod;
2396
- detachStripePaymentMethod;
2397
- setDefaultStripePaymentMethod;
2398
- createCustomerSetupIntent;
2399
- getCustomerPaymentMethods;
2400
- attachCustomerPaymentMethod;
2401
- detachCustomerPaymentMethod;
2402
- setDefaultCustomerPaymentMethod;
2403
- convertSubscriptionToStripe;
2404
- previewWorkspaceOrganizationChange;
2405
- changeWorkspaceOrganization;
2406
- createStripeInvoice;
2407
- getStripeInvoices;
2408
- getStripeUpcomingInvoice;
2409
- getWorkspaceUsageDashboard;
2410
- compareProductsWithStripe;
2411
- syncProductToStripe;
2412
- searchStripeProducts;
2413
- getUsageReport;
2414
- getSubscriptionsAsAdmin;
2415
- getSubscriptionAsAdmin;
2416
- updateSubscriptionStatusAsAdmin;
2417
- updateSubscriptionCreditSettingsAsAdmin;
2418
- grantCreditsAsAdmin;
2419
- listCreditGrantsAsAdmin;
2420
- getVoiceMetrics;
2421
- getHealthMetrics;
2422
- getHealthDetail;
2423
- getWorkspaceInboxesAsAdmin;
2424
- listWorkspaceChats;
2425
- getWorkspaceChat;
2426
- rateWorkspaceChatMessage;
2427
- getTemporalAdminConfig;
2428
- listFailedTemporalWorkflows;
2429
- listStuckTemporalWorkflows;
2430
- getTemporalSummary;
2431
- getTemporalWorkflowDetail;
2432
- getResellers;
2433
- getReseller;
2434
- createReseller;
2435
- updateReseller;
2436
- getResellerAccounts;
2437
- linkResellerToAccount;
2438
- unlinkResellerFromAccount;
2439
- getBillingPeriods;
2440
- generateInvoice;
2441
- getInvoices;
2442
- getInvoiceDownloadUrl;
2443
- getReceiptDownloadUrl;
2444
- recordInvoicePayment;
2445
- adminApi;
2446
- constructor(apiKey, baseUrl2, customFetch) {
2447
- super(apiKey, baseUrl2, customFetch);
2448
- this.adminApi = new AdminApi(apiKey, baseUrl2, customFetch);
2449
- bindAdminMethods(this, this.adminApi);
2450
- }
2451
- /**
2452
- * Propagates acting member switches to the admin API module as well.
2453
- */
2454
- setActingMember(memberUuid) {
2455
- super.setActingMember(memberUuid);
2456
- if (typeof this.adminApi.setActingMember === "function") {
2457
- this.adminApi.setActingMember(memberUuid);
2458
- }
2459
- }
2460
- // setOrgToken is intentionally NOT overridden here. Admin routes
2461
- // (/api/v2/admin/*) are protected by the bearer token's superuser claim and
2462
- // ignore X-Org-Token entirely, so propagating an org token to adminApi is
2463
- // dead code that would only obscure auth flow if admin route logic changes.
2464
- };
2465
- }
2466
- });
2467
-
2468
799
  // src/lib/realm.ts
2469
800
  import { execSync } from "child_process";
2470
801
  import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, statSync, writeFileSync as writeFileSync2 } from "fs";
@@ -2497,6 +828,7 @@ var init_pinned_fetch = __esm({
2497
828
  });
2498
829
 
2499
830
  // src/lib/context.ts
831
+ import { GravityRailClient } from "@gravity-rail/sdk";
2500
832
  import { homedir } from "os";
2501
833
  function requireAuth(ctx) {
2502
834
  if (!("apiClient" in ctx)) {
@@ -2507,7 +839,6 @@ function requireAuth(ctx) {
2507
839
  var init_context = __esm({
2508
840
  "src/lib/context.ts"() {
2509
841
  "use strict";
2510
- init_dist();
2511
842
  init_cli_utils();
2512
843
  init_output();
2513
844
  init_realm();