@replicated/portal-components 0.0.12 → 0.0.13

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.
Files changed (53) hide show
  1. package/components/metadata/registry.json +2 -2
  2. package/components/metadata/registry.md +2 -2
  3. package/dist/actions/index.d.mts +26 -4
  4. package/dist/actions/index.d.ts +26 -4
  5. package/dist/actions/index.js +171 -124
  6. package/dist/actions/index.js.map +1 -1
  7. package/dist/airgap-instances.js.map +1 -1
  8. package/dist/esm/actions/index.js +170 -124
  9. package/dist/esm/actions/index.js.map +1 -1
  10. package/dist/esm/airgap-instances.js.map +1 -1
  11. package/dist/esm/helm-install-wizard.js +15 -9
  12. package/dist/esm/helm-install-wizard.js.map +1 -1
  13. package/dist/esm/index.js +127 -108
  14. package/dist/esm/index.js.map +1 -1
  15. package/dist/esm/install-actions.js +42 -47
  16. package/dist/esm/install-actions.js.map +1 -1
  17. package/dist/esm/instance-card.js.map +1 -1
  18. package/dist/esm/license-details.js +20 -10
  19. package/dist/esm/license-details.js.map +1 -1
  20. package/dist/esm/linux-install-wizard.js +26 -47
  21. package/dist/esm/linux-install-wizard.js.map +1 -1
  22. package/dist/esm/online-instance-list.js.map +1 -1
  23. package/dist/esm/support-card.js +18 -49
  24. package/dist/esm/support-card.js.map +1 -1
  25. package/dist/esm/top-nav.js +13 -31
  26. package/dist/esm/top-nav.js.map +1 -1
  27. package/dist/esm/update-layout.js +13 -31
  28. package/dist/esm/update-layout.js.map +1 -1
  29. package/dist/esm/utils/index.js +14 -10
  30. package/dist/esm/utils/index.js.map +1 -1
  31. package/dist/helm-install-wizard.js +15 -9
  32. package/dist/helm-install-wizard.js.map +1 -1
  33. package/dist/index.d.mts +1 -1
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +126 -106
  36. package/dist/index.js.map +1 -1
  37. package/dist/install-actions.js +43 -48
  38. package/dist/install-actions.js.map +1 -1
  39. package/dist/instance-card.js.map +1 -1
  40. package/dist/license-details.js +20 -10
  41. package/dist/license-details.js.map +1 -1
  42. package/dist/linux-install-wizard.js +26 -47
  43. package/dist/linux-install-wizard.js.map +1 -1
  44. package/dist/online-instance-list.js.map +1 -1
  45. package/dist/support-card.js +18 -49
  46. package/dist/support-card.js.map +1 -1
  47. package/dist/top-nav.js +13 -31
  48. package/dist/top-nav.js.map +1 -1
  49. package/dist/update-layout.js +13 -31
  50. package/dist/update-layout.js.map +1 -1
  51. package/dist/utils/index.js +14 -10
  52. package/dist/utils/index.js.map +1 -1
  53. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { Buffer } from 'buffer';
1
2
  import { cache } from 'react';
2
3
 
3
4
  /**
@@ -71,10 +72,10 @@ var createServiceAccount = defineServerAction({
71
72
  if (!name || typeof name !== "string" || !name.trim()) {
72
73
  throw new Error("Service account name is required");
73
74
  }
74
- const endpoint = `${getApiOrigin()}/v3/service-account`;
75
+ const endpoint = `${getApiOrigin()}/enterprise-portal/team/service-accounts`;
75
76
  if (process.env.NODE_ENV !== "production") {
76
77
  console.debug(
77
- "[portal-components] creating service account via %s",
78
+ "[portal-components] creating service account via %s (Enterprise Portal API)",
78
79
  endpoint
79
80
  );
80
81
  }
@@ -102,7 +103,7 @@ var initiateLogin = defineServerAction({
102
103
  visibility: "customer",
103
104
  tags: ["auth", "login", "session"],
104
105
  async run(input) {
105
- const endpoint = `${getApiOrigin()}/v3/login/magic-link`;
106
+ const endpoint = `${getApiOrigin()}/enterprise-portal/auth/magic-link`;
106
107
  const appSlug = process.env.PORTAL_APP_SLUG;
107
108
  if (!appSlug) {
108
109
  throw new Error("PORTAL_APP_SLUG is not configured");
@@ -152,7 +153,7 @@ var verifyMagicLink = defineServerAction({
152
153
  visibility: "customer",
153
154
  tags: ["auth", "login", "verify"],
154
155
  async run({ nonce }) {
155
- const endpoint = `${getApiOrigin()}/v3/login/magic-link/verify`;
156
+ const endpoint = `${getApiOrigin()}/enterprise-portal/auth/magic-link/verify`;
156
157
  if (process.env.NODE_ENV !== "production") {
157
158
  console.debug(
158
159
  "[portal-components] verifying magic link via %s",
@@ -208,12 +209,12 @@ var fetchCustomBrandingImpl = async () => {
208
209
  if (!appSlug) {
209
210
  throw new Error("PORTAL_APP_SLUG is not configured");
210
211
  }
211
- const url = `${getApiOrigin()}/v3/custom-branding?app_slug=${encodeURIComponent(
212
+ const url = `${getApiOrigin()}/enterprise-portal/public/branding?app_slug=${encodeURIComponent(
212
213
  appSlug
213
214
  )}`;
214
215
  if (process.env.NODE_ENV !== "production") {
215
216
  console.debug(
216
- "[portal-components] fetching custom branding via %s",
217
+ "[portal-components] fetching custom branding via %s (Enterprise Portal API)",
217
218
  url
218
219
  );
219
220
  }
@@ -228,13 +229,18 @@ var fetchCustomBrandingImpl = async () => {
228
229
  );
229
230
  }
230
231
  const payload = await response.json();
231
- const brandingData = payload?.branding_data;
232
- if (typeof brandingData !== "string") {
233
- throw new Error("Custom branding response missing branding_data string");
234
- }
232
+ const brandingObject = {
233
+ logo: payload.logoUrl,
234
+ title: payload.appName,
235
+ customColor1: payload.primaryColor,
236
+ customColor2: payload.secondaryColor,
237
+ favicon: payload.faviconUrl
238
+ };
239
+ const brandingData = Buffer.from(JSON.stringify(brandingObject)).toString("base64");
235
240
  return {
236
241
  brandingData,
237
- documentation: payload?.documentation ?? null
242
+ documentation: null
243
+ // Documentation not included in new API's public endpoint
238
244
  };
239
245
  };
240
246
  var fetchCustomBranding = cache(fetchCustomBrandingImpl);
@@ -262,22 +268,6 @@ var getCustomerIdFromToken = (token) => {
262
268
  }
263
269
  return customerId.trim();
264
270
  };
265
- var resolveSupportBundlesEndpoint = () => {
266
- const fallback = `${getApiOrigin()}/v3/supportbundles`;
267
- const explicit = process.env.SUPPORT_BUNDLES_ENDPOINT;
268
- if (!explicit) {
269
- return new URL(fallback);
270
- }
271
- try {
272
- return new URL(explicit);
273
- } catch (error) {
274
- console.warn(
275
- `[portal-components] invalid SUPPORT_BUNDLES_ENDPOINT, using fallback`,
276
- error
277
- );
278
- return new URL(fallback);
279
- }
280
- };
281
271
  var listSupportBundles = defineServerAction({
282
272
  id: "support/list-bundles",
283
273
  description: "Fetches support bundles associated with the customer found in the portal session JWT.",
@@ -287,17 +277,11 @@ var listSupportBundles = defineServerAction({
287
277
  if (!token || typeof token !== "string") {
288
278
  throw new Error("Support bundle listing requires a session token");
289
279
  }
290
- const payload = decodeJwtPayload(token);
291
- const customerId = payload?.customer_id;
292
- if (typeof customerId !== "string" || !customerId.trim()) {
293
- throw new Error("Unable to determine customer_id from session token");
294
- }
295
- const url = resolveSupportBundlesEndpoint();
296
- url.searchParams.set("customer_id", customerId.trim());
280
+ const url = `${getApiOrigin()}/enterprise-portal/support-bundles`;
297
281
  if (process.env.NODE_ENV !== "production") {
298
- console.debug("[portal-components] fetching support bundles via %s", url);
282
+ console.debug("[portal-components] fetching support bundles via %s (Enterprise Portal API)", url);
299
283
  }
300
- const response = await authenticatedFetch(url.toString(), {
284
+ const response = await authenticatedFetch(url, {
301
285
  token,
302
286
  headers: {
303
287
  accept: "application/json"
@@ -312,7 +296,8 @@ var listSupportBundles = defineServerAction({
312
296
  `Support bundles request failed (${response.status} ${response.statusText})`
313
297
  );
314
298
  }
315
- const raw = await response.json();
299
+ const payload = await response.json();
300
+ const raw = payload.data;
316
301
  const rawRecord = raw && typeof raw === "object" ? raw : void 0;
317
302
  const parseInsights = (raw2) => {
318
303
  if (!Array.isArray(raw2)) return void 0;
@@ -403,12 +388,8 @@ var downloadSupportBundle = defineServerAction({
403
388
  if (!bundleId || typeof bundleId !== "string") {
404
389
  throw new Error("Support bundle download requires a bundle ID");
405
390
  }
406
- const payload = decodeJwtPayload(token);
407
- const customerId = payload?.customer_id;
408
- if (typeof customerId !== "string" || !customerId.trim()) {
409
- throw new Error("Unable to determine customer_id from session token");
410
- }
411
- const endpoint = `${getApiOrigin()}/v3/supportbundle/${encodeURIComponent(bundleId)}/download?customer_id=${encodeURIComponent(customerId.trim())}`;
391
+ const customerId = getCustomerIdFromToken(token);
392
+ const endpoint = `${getApiOrigin()}/enterprise-portal/support-bundles/${encodeURIComponent(bundleId)}/download?customer_id=${encodeURIComponent(customerId)}`;
412
393
  if (process.env.NODE_ENV !== "production") {
413
394
  console.debug("[portal-components] getting support bundle download URL via %s", endpoint);
414
395
  }
@@ -446,12 +427,8 @@ var deleteSupportBundle = defineServerAction({
446
427
  if (!bundleId || typeof bundleId !== "string") {
447
428
  throw new Error("Support bundle deletion requires a bundle ID");
448
429
  }
449
- const payload = decodeJwtPayload(token);
450
- const customerId = payload?.customer_id;
451
- if (typeof customerId !== "string" || !customerId.trim()) {
452
- throw new Error("Unable to determine customer_id from session token");
453
- }
454
- const endpoint = `${getApiOrigin()}/v3/supportbundle/${encodeURIComponent(bundleId)}?customer_id=${encodeURIComponent(customerId.trim())}`;
430
+ const customerId = getCustomerIdFromToken(token);
431
+ const endpoint = `${getApiOrigin()}/enterprise-portal/support-bundles/${encodeURIComponent(bundleId)}?customer_id=${encodeURIComponent(customerId)}`;
455
432
  if (process.env.NODE_ENV !== "production") {
456
433
  console.debug("[portal-components] deleting support bundle via %s", endpoint);
457
434
  }
@@ -490,7 +467,7 @@ var uploadSupportBundle = defineServerAction({
490
467
  if (!fileContent || !(fileContent instanceof ArrayBuffer)) {
491
468
  throw new Error("Support bundle upload requires file content");
492
469
  }
493
- const endpoint = `${getApiOrigin()}/v3/supportbundle/upload/${encodeURIComponent(appId)}`;
470
+ const endpoint = `${getApiOrigin()}/enterprise-portal/support-bundles/upload/${encodeURIComponent(appId)}`;
494
471
  if (process.env.NODE_ENV !== "production") {
495
472
  console.debug("[portal-components] uploading support bundle via %s", endpoint);
496
473
  }
@@ -518,7 +495,7 @@ var uploadSupportBundle = defineServerAction({
518
495
  }
519
496
  });
520
497
  var getSupportBundleUploadUrl = (appId) => {
521
- return `${getApiOrigin()}/v3/supportbundle/upload/${encodeURIComponent(appId)}`;
498
+ return `${getApiOrigin()}/enterprise-portal/support-bundles/upload/${encodeURIComponent(appId)}`;
522
499
  };
523
500
  var listReleases = defineServerAction({
524
501
  id: "releases/list",
@@ -529,10 +506,10 @@ var listReleases = defineServerAction({
529
506
  if (!token || typeof token !== "string") {
530
507
  throw new Error("List releases requires a session token");
531
508
  }
532
- const endpoint = `${getApiOrigin()}/v3/release-history`;
533
- console.log("[portal-components] listReleases request", {
534
- endpoint
535
- });
509
+ const endpoint = `${getApiOrigin()}/enterprise-portal/releases`;
510
+ if (process.env.NODE_ENV !== "production") {
511
+ console.debug("[portal-components] fetching releases via %s (Enterprise Portal API)", endpoint);
512
+ }
536
513
  const response = await authenticatedFetch(endpoint, {
537
514
  method: "GET",
538
515
  token,
@@ -545,7 +522,6 @@ var listReleases = defineServerAction({
545
522
  console.warn("[portal-components] listReleases read error", error);
546
523
  return null;
547
524
  });
548
- console.log("[portal-components] listReleases response", response.status, bodyText);
549
525
  if (!response.ok) {
550
526
  throw new Error(
551
527
  `List releases request failed (${response.status} ${response.statusText})`
@@ -842,7 +818,10 @@ var fetchLicenseDetails = defineServerAction({
842
818
  if (typeof token !== "string" || token.trim().length === 0) {
843
819
  throw new Error("fetchLicenseDetails requires a non-empty token");
844
820
  }
845
- const endpoint = `${getApiOrigin()}/v3/license`;
821
+ const endpoint = `${getApiOrigin()}/enterprise-portal/license`;
822
+ if (process.env.NODE_ENV !== "production") {
823
+ console.debug("[portal-components] fetching license via %s (Enterprise Portal API)", endpoint);
824
+ }
846
825
  const response = await authenticatedFetch(endpoint, {
847
826
  method: "GET",
848
827
  token,
@@ -857,10 +836,11 @@ var fetchLicenseDetails = defineServerAction({
857
836
  );
858
837
  }
859
838
  const payload = await response.json();
860
- const license = normalizeLicensePayload(payload);
839
+ const licenseData = payload.data;
840
+ const license = normalizeLicensePayload(licenseData);
861
841
  return {
862
842
  license,
863
- raw: payload ?? null
843
+ raw: licenseData ?? null
864
844
  };
865
845
  }
866
846
  });
@@ -873,7 +853,10 @@ var fetchInstallOptions = defineServerAction({
873
853
  if (typeof token !== "string" || token.trim().length === 0) {
874
854
  throw new Error("fetchInstallOptions requires a non-empty token");
875
855
  }
876
- const endpoint = `${getApiOrigin()}/v3/license`;
856
+ const endpoint = `${getApiOrigin()}/enterprise-portal/license`;
857
+ if (process.env.NODE_ENV !== "production") {
858
+ console.debug("[portal-components] fetching install options via %s (Enterprise Portal API)", endpoint);
859
+ }
877
860
  const response = await authenticatedFetch(endpoint, {
878
861
  method: "GET",
879
862
  token,
@@ -887,7 +870,8 @@ var fetchInstallOptions = defineServerAction({
887
870
  `License request failed (${response.status} ${response.statusText})`
888
871
  );
889
872
  }
890
- const payload = await response.json();
873
+ const envelope = await response.json();
874
+ const licenseData = envelope.data;
891
875
  const getBoolean2 = (obj, key) => {
892
876
  if (obj && typeof obj === "object" && key in obj) {
893
877
  const val = obj[key];
@@ -895,9 +879,8 @@ var fetchInstallOptions = defineServerAction({
895
879
  }
896
880
  return false;
897
881
  };
898
- const license = payload?.license ?? payload ?? {};
899
- const showLinux = getBoolean2(license, "isEmbeddedClusterDownloadEnabled");
900
- const showHelm = getBoolean2(license, "isHelmInstallEnabled");
882
+ const showLinux = getBoolean2(licenseData, "isEmbeddedClusterDownloadEnabled");
883
+ const showHelm = getBoolean2(licenseData, "isHelmInstallEnabled");
901
884
  return {
902
885
  showLinux,
903
886
  showHelm
@@ -913,7 +896,10 @@ var fetchLicenseSummary = defineServerAction({
913
896
  if (typeof token !== "string" || token.trim().length === 0) {
914
897
  throw new Error("fetchLicenseSummary requires a non-empty token");
915
898
  }
916
- const endpoint = `${getApiOrigin()}/v3/license`;
899
+ const endpoint = `${getApiOrigin()}/enterprise-portal/license`;
900
+ if (process.env.NODE_ENV !== "production") {
901
+ console.debug("[portal-components] fetching license summary via %s (Enterprise Portal API)", endpoint);
902
+ }
917
903
  const response = await authenticatedFetch(endpoint, {
918
904
  method: "GET",
919
905
  token,
@@ -927,8 +913,9 @@ var fetchLicenseSummary = defineServerAction({
927
913
  `License request failed (${response.status} ${response.statusText})`
928
914
  );
929
915
  }
930
- const payload = await response.json();
931
- const license = normalizeLicensePayload(payload);
916
+ const envelope = await response.json();
917
+ const licenseData = envelope.data;
918
+ const license = normalizeLicensePayload(licenseData);
932
919
  const type = license.environment || "Unknown";
933
920
  const expiresAt = license.expiresAt || null;
934
921
  return {
@@ -946,7 +933,10 @@ var fetchCustomers = defineServerAction({
946
933
  if (typeof token !== "string" || token.trim().length === 0) {
947
934
  throw new Error("fetchCustomers requires a non-empty token");
948
935
  }
949
- const endpoint = `${getApiOrigin()}/v3/customers`;
936
+ const endpoint = `${getApiOrigin()}/enterprise-portal/user`;
937
+ if (process.env.NODE_ENV !== "production") {
938
+ console.debug("[portal-components] fetching customers via %s (Enterprise Portal API)", endpoint);
939
+ }
950
940
  const response = await authenticatedFetch(endpoint, {
951
941
  method: "GET",
952
942
  token,
@@ -960,9 +950,10 @@ var fetchCustomers = defineServerAction({
960
950
  `Fetch customers request failed (${response.status} ${response.statusText})`
961
951
  );
962
952
  }
963
- const payload = await response.json();
953
+ const envelope = await response.json();
954
+ const userData = envelope.data;
964
955
  return {
965
- customers: payload.customers || []
956
+ customers: userData?.customers || []
966
957
  };
967
958
  }
968
959
  });
@@ -978,10 +969,10 @@ var switchCustomer = defineServerAction({
978
969
  if (typeof customerId !== "string" || customerId.trim().length === 0) {
979
970
  throw new Error("switchCustomer requires a non-empty customerId");
980
971
  }
981
- const endpoint = `${getApiOrigin()}/v3/select-customer`;
972
+ const endpoint = `${getApiOrigin()}/enterprise-portal/auth/switch-team`;
982
973
  const requestBody = { customer_id: customerId };
983
974
  const response = await authenticatedFetch(endpoint, {
984
- method: "PUT",
975
+ method: "POST",
985
976
  token,
986
977
  headers: {
987
978
  "content-type": "application/json",
@@ -990,7 +981,6 @@ var switchCustomer = defineServerAction({
990
981
  body: JSON.stringify(requestBody),
991
982
  signal: context?.signal
992
983
  });
993
- console.log("[portal-components] switchCustomer response status:", response.status);
994
984
  if (!response.ok) {
995
985
  const errorText = await response.text();
996
986
  console.error("[portal-components] switchCustomer error response:", errorText);
@@ -999,9 +989,7 @@ var switchCustomer = defineServerAction({
999
989
  );
1000
990
  }
1001
991
  const payload = await response.json();
1002
- console.log("[portal-components] switchCustomer response payload:", payload);
1003
992
  const newToken = payload.jwt || payload.token || token;
1004
- console.log("[portal-components] switchCustomer using token field:", payload.jwt ? "jwt" : payload.token ? "token" : "fallback");
1005
993
  return {
1006
994
  token: newToken
1007
995
  };
@@ -1016,16 +1004,14 @@ var getSecurityInfo = defineServerAction({
1016
1004
  if (!token || typeof token !== "string") {
1017
1005
  throw new Error("Security info request requires a session token");
1018
1006
  }
1019
- const customerId = getCustomerIdFromToken(token);
1020
1007
  const params = new URLSearchParams({
1021
- customer_id: customerId,
1022
1008
  install_type: installType,
1023
1009
  channel_sequence: channelSequence.toString(),
1024
1010
  is_airgap: isAirgap.toString()
1025
1011
  });
1026
- const url = `${getApiOrigin()}/v3/security-info?${params.toString()}`;
1012
+ const url = `${getApiOrigin()}/enterprise-portal/security?${params.toString()}`;
1027
1013
  if (process.env.NODE_ENV !== "production") {
1028
- console.debug("[portal-components] fetching security info via %s", url);
1014
+ console.debug("[portal-components] fetching security info via %s (Enterprise Portal API)", url);
1029
1015
  }
1030
1016
  const response = await authenticatedFetch(url, {
1031
1017
  token,
@@ -1037,8 +1023,8 @@ var getSecurityInfo = defineServerAction({
1037
1023
  `Security info request failed (${response.status} ${response.statusText})`
1038
1024
  );
1039
1025
  }
1040
- const data = await response.json();
1041
- return data;
1026
+ const payload = await response.json();
1027
+ return payload.data;
1042
1028
  }
1043
1029
  });
1044
1030
  var getSecurityInfoDiff = defineServerAction({
@@ -1050,15 +1036,13 @@ var getSecurityInfoDiff = defineServerAction({
1050
1036
  if (!token || typeof token !== "string") {
1051
1037
  throw new Error("Security info diff request requires a session token");
1052
1038
  }
1053
- const customerId = getCustomerIdFromToken(token);
1054
1039
  const params = new URLSearchParams({
1055
- customer_id: customerId,
1056
1040
  install_type: installType,
1057
1041
  from_channel_sequence: fromChannelSequence.toString(),
1058
1042
  to_channel_sequence: toChannelSequence.toString(),
1059
1043
  is_airgap: isAirgap.toString()
1060
1044
  });
1061
- const url = `${getApiOrigin()}/v3/security-info-diff?${params.toString()}`;
1045
+ const url = `${getApiOrigin()}/enterprise-portal/security-diff?${params.toString()}`;
1062
1046
  if (process.env.NODE_ENV !== "production") {
1063
1047
  console.debug("[portal-components] fetching security info diff via %s", url);
1064
1048
  }
@@ -1072,8 +1056,8 @@ var getSecurityInfoDiff = defineServerAction({
1072
1056
  `Security info diff request failed (${response.status} ${response.statusText})`
1073
1057
  );
1074
1058
  }
1075
- const data = await response.json();
1076
- return data;
1059
+ const envelope = await response.json();
1060
+ return envelope.data;
1077
1061
  }
1078
1062
  });
1079
1063
  var getSecurityInfoSBOM = defineServerAction({
@@ -1085,15 +1069,13 @@ var getSecurityInfoSBOM = defineServerAction({
1085
1069
  if (!token || typeof token !== "string") {
1086
1070
  throw new Error("Security SBOM request requires a session token");
1087
1071
  }
1088
- const customerId = getCustomerIdFromToken(token);
1089
1072
  const params = new URLSearchParams({
1090
- customer_id: customerId,
1091
1073
  install_type: installType,
1092
1074
  channel_sequence: channelSequence.toString(),
1093
1075
  is_airgap: isAirgap.toString(),
1094
1076
  unified_sbom: unifiedSbom.toString()
1095
1077
  });
1096
- const url = `${getApiOrigin()}/v3/security-info-sbom?${params.toString()}`;
1078
+ const url = `${getApiOrigin()}/enterprise-portal/security-sbom?${params.toString()}`;
1097
1079
  if (process.env.NODE_ENV !== "production") {
1098
1080
  console.debug("[portal-components] fetching security SBOM via %s", url);
1099
1081
  }
@@ -1110,8 +1092,77 @@ var getSecurityInfoSBOM = defineServerAction({
1110
1092
  `Security SBOM request failed (${response.status} ${response.statusText})`
1111
1093
  );
1112
1094
  }
1113
- const data = await response.json();
1114
- return data;
1095
+ const envelope = await response.json();
1096
+ return envelope.data;
1097
+ }
1098
+ });
1099
+ var fetchDashboardComposite = defineServerAction({
1100
+ id: "dashboard/fetch-composite",
1101
+ description: "Fetches all dashboard data from the composite Enterprise Portal API endpoint",
1102
+ visibility: "customer",
1103
+ tags: ["dashboard", "enterprise-portal-api"],
1104
+ async run({ token }, context) {
1105
+ if (!token || typeof token !== "string") {
1106
+ throw new Error("Dashboard request requires a session token");
1107
+ }
1108
+ const origin = getApiOrigin();
1109
+ const url = `${origin}/enterprise-portal/dashboard`;
1110
+ if (process.env.NODE_ENV !== "production") {
1111
+ console.debug("[portal-components] fetching dashboard via %s (Enterprise Portal API)", url);
1112
+ }
1113
+ const response = await authenticatedFetch(url, {
1114
+ method: "GET",
1115
+ token,
1116
+ headers: { accept: "application/json" },
1117
+ signal: context?.signal
1118
+ });
1119
+ if (!response.ok) {
1120
+ throw new Error(
1121
+ `Dashboard request failed (${response.status} ${response.statusText})`
1122
+ );
1123
+ }
1124
+ const payload = await response.json();
1125
+ const data = payload.data;
1126
+ const allInstances = data?.instances || [];
1127
+ const channelReleases = data?.channelReleases || [];
1128
+ const licenseData = data?.license || {};
1129
+ const teamStats = data?.teamStats || {};
1130
+ const onlineInstances = allInstances.filter((i) => !i.isAirgap);
1131
+ const airgapInstances = allInstances.filter((i) => i.isAirgap);
1132
+ const twentyFourHoursAgo = Date.now() - 24 * 60 * 60 * 1e3;
1133
+ const activeOnlineInstances = onlineInstances.filter((instance) => {
1134
+ const lastCheckin = instance.lastCheckin ? new Date(instance.lastCheckin).getTime() : 0;
1135
+ return lastCheckin > twentyFourHoursAgo;
1136
+ });
1137
+ const onlineActiveCount = activeOnlineInstances.length;
1138
+ const airgapCount = airgapInstances.length;
1139
+ const calculateUpdates = (instances) => {
1140
+ if (!channelReleases.length) return 0;
1141
+ let numUpdates = 0;
1142
+ for (const instance of instances) {
1143
+ const instanceSequence = instance.channelSequence ?? 0;
1144
+ const matchingReleases = channelReleases.filter(
1145
+ (release) => release.channelId === instance.channelId
1146
+ );
1147
+ for (const release of matchingReleases) {
1148
+ if ((release.channelSequence ?? 0) > instanceSequence) {
1149
+ numUpdates++;
1150
+ }
1151
+ }
1152
+ }
1153
+ return numUpdates;
1154
+ };
1155
+ const onlineUpdates = calculateUpdates(activeOnlineInstances);
1156
+ const airgapUpdates = calculateUpdates(airgapInstances);
1157
+ return {
1158
+ onlineActiveCount,
1159
+ airgapCount,
1160
+ onlineUpdates,
1161
+ airgapUpdates,
1162
+ // Additional data available from the composite endpoint
1163
+ license: licenseData,
1164
+ teamStats
1165
+ };
1115
1166
  }
1116
1167
  });
1117
1168
  var fetchTeamStats = defineServerAction({
@@ -1260,7 +1311,7 @@ var fetchCurrentUser = defineServerAction({
1260
1311
  if (!token || typeof token !== "string") {
1261
1312
  throw new Error("Fetch current user requires a session token");
1262
1313
  }
1263
- const endpoint = `${getApiOrigin()}/v3/user`;
1314
+ const endpoint = `${getApiOrigin()}/enterprise-portal/user/profile`;
1264
1315
  if (process.env.NODE_ENV !== "production") {
1265
1316
  console.debug("[portal-components] fetching current user via %s", endpoint);
1266
1317
  }
@@ -1297,7 +1348,7 @@ var updateUser = defineServerAction({
1297
1348
  if (!firstName && !lastName) {
1298
1349
  throw new Error("At least one of firstName or lastName must be provided");
1299
1350
  }
1300
- const endpoint = `${getApiOrigin()}/v3/user`;
1351
+ const endpoint = `${getApiOrigin()}/enterprise-portal/user/profile`;
1301
1352
  if (process.env.NODE_ENV !== "production") {
1302
1353
  console.debug("[portal-components] updating user via %s", endpoint);
1303
1354
  }
@@ -1305,7 +1356,7 @@ var updateUser = defineServerAction({
1305
1356
  if (firstName !== void 0) body.firstName = firstName;
1306
1357
  if (lastName !== void 0) body.lastName = lastName;
1307
1358
  const response = await authenticatedFetch(endpoint, {
1308
- method: "POST",
1359
+ method: "PUT",
1309
1360
  token,
1310
1361
  headers: {
1311
1362
  "content-type": "application/json",
@@ -1333,9 +1384,9 @@ var fetchNotifications = defineServerAction({
1333
1384
  throw new Error("Fetch notifications requires a session token");
1334
1385
  }
1335
1386
  if (!customerId || typeof customerId !== "string") {
1336
- throw new Error("Fetch notifications requires a customerId");
1387
+ throw new Error("Fetch notifications requires a valid customerId");
1337
1388
  }
1338
- const endpoint = `${getApiOrigin()}/v3/notifications?customer_id=${encodeURIComponent(customerId)}`;
1389
+ const endpoint = `${getApiOrigin()}/enterprise-portal/user/notifications?customer_id=${encodeURIComponent(customerId)}`;
1339
1390
  if (process.env.NODE_ENV !== "production") {
1340
1391
  console.debug("[portal-components] fetching notifications via %s", endpoint);
1341
1392
  }
@@ -1366,12 +1417,12 @@ var updateNotifications = defineServerAction({
1366
1417
  throw new Error("Update notifications requires a session token");
1367
1418
  }
1368
1419
  if (!customerId || typeof customerId !== "string") {
1369
- throw new Error("Update notifications requires a customerId");
1420
+ throw new Error("Update notifications requires a valid customerId");
1370
1421
  }
1371
1422
  if (!Array.isArray(notifications)) {
1372
1423
  throw new Error("Update notifications requires a notifications array");
1373
1424
  }
1374
- const endpoint = `${getApiOrigin()}/v3/notifications?customer_id=${encodeURIComponent(customerId)}`;
1425
+ const endpoint = `${getApiOrigin()}/enterprise-portal/user/notifications?customer_id=${encodeURIComponent(customerId)}`;
1375
1426
  if (process.env.NODE_ENV !== "production") {
1376
1427
  console.debug("[portal-components] updating notifications via %s", endpoint);
1377
1428
  }
@@ -1412,7 +1463,7 @@ var fetchTeamUsers = defineServerAction({
1412
1463
  limit: limit.toString(),
1413
1464
  offset: offset.toString()
1414
1465
  });
1415
- const endpoint = `${getApiOrigin()}/v3/users?${params.toString()}`;
1466
+ const endpoint = `${getApiOrigin()}/enterprise-portal/team/users?${params.toString()}`;
1416
1467
  if (process.env.NODE_ENV !== "production") {
1417
1468
  console.debug("[portal-components] fetching team users via %s", endpoint);
1418
1469
  }
@@ -1446,12 +1497,11 @@ var inviteUser = defineServerAction({
1446
1497
  if (!email || typeof email !== "string") {
1447
1498
  throw new Error("Invite user requires an email address");
1448
1499
  }
1449
- const customerId = getCustomerIdFromToken(token);
1500
+ getCustomerIdFromToken(token);
1450
1501
  const params = new URLSearchParams({
1451
- customer_id: customerId,
1452
1502
  email_address: email
1453
1503
  });
1454
- const endpoint = `${getApiOrigin()}/v3/invite?${params.toString()}`;
1504
+ const endpoint = `${getApiOrigin()}/enterprise-portal/team/invite?${params.toString()}`;
1455
1505
  if (process.env.NODE_ENV !== "production") {
1456
1506
  console.debug("[portal-components] inviting user via %s", endpoint);
1457
1507
  }
@@ -1475,24 +1525,20 @@ var inviteUser = defineServerAction({
1475
1525
  });
1476
1526
  var deleteUser = defineServerAction({
1477
1527
  id: "team/delete-user",
1478
- description: "Removes a user from the team",
1528
+ description: "Removes a user or pending invite from the team by ID",
1479
1529
  visibility: "customer",
1480
1530
  tags: ["team", "users", "delete"],
1481
- async run({ token, email }, context) {
1531
+ async run({ token, id, isPendingInvite }, context) {
1482
1532
  if (!token || typeof token !== "string") {
1483
1533
  throw new Error("Delete user requires a session token");
1484
1534
  }
1485
- if (!email || typeof email !== "string") {
1486
- throw new Error("Delete user requires an email address");
1535
+ if (!id || typeof id !== "string") {
1536
+ throw new Error("Delete user requires an ID");
1487
1537
  }
1488
- const customerId = getCustomerIdFromToken(token);
1489
- const params = new URLSearchParams({
1490
- customer_id: customerId,
1491
- email_address: email
1492
- });
1493
- const endpoint = `${getApiOrigin()}/v3/user?${params.toString()}`;
1538
+ const resource = isPendingInvite ? "invites" : "users";
1539
+ const endpoint = `${getApiOrigin()}/enterprise-portal/team/${resource}/${encodeURIComponent(id)}`;
1494
1540
  if (process.env.NODE_ENV !== "production") {
1495
- console.debug("[portal-components] deleting user via %s", endpoint);
1541
+ console.debug("[portal-components] deleting %s %s via %s", resource, id, endpoint);
1496
1542
  }
1497
1543
  const response = await authenticatedFetch(endpoint, {
1498
1544
  method: "DELETE",
@@ -1501,7 +1547,7 @@ var deleteUser = defineServerAction({
1501
1547
  signal: context?.signal
1502
1548
  });
1503
1549
  if (!response.ok) {
1504
- let errorMessage = "Failed to delete user";
1550
+ let errorMessage = isPendingInvite ? "Failed to delete invite" : "Failed to delete user";
1505
1551
  try {
1506
1552
  const data = await response.json();
1507
1553
  errorMessage = data.message || data.error || errorMessage;
@@ -1530,7 +1576,7 @@ var fetchServiceAccounts = defineServerAction({
1530
1576
  if (!includeRevoked) {
1531
1577
  params.set("filterRevoked", "false");
1532
1578
  }
1533
- const endpoint = `${getApiOrigin()}/v3/service-accounts?${params.toString()}`;
1579
+ const endpoint = `${getApiOrigin()}/enterprise-portal/team/service-accounts?${params.toString()}`;
1534
1580
  if (process.env.NODE_ENV !== "production") {
1535
1581
  console.debug("[portal-components] fetching service accounts via %s", endpoint);
1536
1582
  }
@@ -1564,8 +1610,8 @@ var revokeServiceAccount = defineServerAction({
1564
1610
  if (!accountId || typeof accountId !== "string") {
1565
1611
  throw new Error("Revoke service account requires an account ID");
1566
1612
  }
1567
- const customerId = getCustomerIdFromToken(token);
1568
- const endpoint = `${getApiOrigin()}/v3/service-account/${encodeURIComponent(accountId)}?customer_id=${encodeURIComponent(customerId)}`;
1613
+ getCustomerIdFromToken(token);
1614
+ const endpoint = `${getApiOrigin()}/enterprise-portal/team/service-accounts/${encodeURIComponent(accountId)}`;
1569
1615
  if (process.env.NODE_ENV !== "production") {
1570
1616
  console.debug("[portal-components] revoking service account via %s", endpoint);
1571
1617
  }
@@ -1599,8 +1645,8 @@ var rotateServiceAccountToken = defineServerAction({
1599
1645
  if (!accountId || typeof accountId !== "string") {
1600
1646
  throw new Error("Rotate service account token requires an account ID");
1601
1647
  }
1602
- const customerId = getCustomerIdFromToken(token);
1603
- const endpoint = `${getApiOrigin()}/v3/service-account/${encodeURIComponent(accountId)}/rotate-token?customer_id=${encodeURIComponent(customerId)}`;
1648
+ getCustomerIdFromToken(token);
1649
+ const endpoint = `${getApiOrigin()}/enterprise-portal/team/service-accounts/${encodeURIComponent(accountId)}/rotate-token`;
1604
1650
  if (process.env.NODE_ENV !== "production") {
1605
1651
  console.debug("[portal-components] rotating service account token via %s", endpoint);
1606
1652
  }
@@ -1823,9 +1869,9 @@ var acceptInvite = defineServerAction({
1823
1869
  };
1824
1870
  throw error;
1825
1871
  }
1826
- const endpoint = `${getApiOrigin()}/v3/invite/accept`;
1872
+ const endpoint = `${getApiOrigin()}/enterprise-portal/auth/invite/accept`;
1827
1873
  if (process.env.NODE_ENV !== "production") {
1828
- console.debug("[portal-components] accepting invite via %s", endpoint);
1874
+ console.debug("[portal-components] accepting invite via %s (Enterprise Portal API)", endpoint);
1829
1875
  }
1830
1876
  const response = await fetch(endpoint, {
1831
1877
  method: "POST",
@@ -1872,9 +1918,9 @@ var refreshInvite = defineServerAction({
1872
1918
  if (!code || typeof code !== "string") {
1873
1919
  throw new Error("Invite code is required");
1874
1920
  }
1875
- const endpoint = `${getApiOrigin()}/v3/invite/refresh`;
1921
+ const endpoint = `${getApiOrigin()}/enterprise-portal/auth/invite/refresh`;
1876
1922
  if (process.env.NODE_ENV !== "production") {
1877
- console.debug("[portal-components] refreshing invite via %s", endpoint);
1923
+ console.debug("[portal-components] refreshing invite via %s (Enterprise Portal API)", endpoint);
1878
1924
  }
1879
1925
  const response = await fetch(endpoint, {
1880
1926
  method: "POST",
@@ -1897,6 +1943,6 @@ var refreshInvite = defineServerAction({
1897
1943
  }
1898
1944
  });
1899
1945
 
1900
- export { acceptInvite, createServiceAccount, decodeJwtPayload, defineServerAction, deleteSupportBundle, deleteUser, deprovisionSaml, downloadSupportBundle, fetchCurrentUser, fetchCustomBranding, fetchCustomers, fetchDashboardInstances, fetchInstallOptions, fetchInstances, fetchLicenseDetails, fetchLicenseSummary, fetchNotifications, fetchSamlConfig, fetchServiceAccounts, fetchTeamStats, fetchTeamUsers, getApiOrigin, getCustomerIdFromToken, getSecurityInfo, getSecurityInfoDiff, getSecurityInfoSBOM, getSupportBundleUploadUrl, initiateLogin, inviteUser, listReleases, listSupportBundles, refreshInvite, revokeServiceAccount, rotateServiceAccountToken, switchCustomer, toggleSamlEnabled, updateNotifications, updateSamlConfig, updateUser, uploadSupportBundle, verifyMagicLink };
1946
+ export { acceptInvite, createServiceAccount, decodeJwtPayload, defineServerAction, deleteSupportBundle, deleteUser, deprovisionSaml, downloadSupportBundle, fetchCurrentUser, fetchCustomBranding, fetchCustomers, fetchDashboardComposite, fetchDashboardInstances, fetchInstallOptions, fetchInstances, fetchLicenseDetails, fetchLicenseSummary, fetchNotifications, fetchSamlConfig, fetchServiceAccounts, fetchTeamStats, fetchTeamUsers, getApiOrigin, getCustomerIdFromToken, getSecurityInfo, getSecurityInfoDiff, getSecurityInfoSBOM, getSupportBundleUploadUrl, initiateLogin, inviteUser, listReleases, listSupportBundles, refreshInvite, revokeServiceAccount, rotateServiceAccountToken, switchCustomer, toggleSamlEnabled, updateNotifications, updateSamlConfig, updateUser, uploadSupportBundle, verifyMagicLink };
1901
1947
  //# sourceMappingURL=index.js.map
1902
1948
  //# sourceMappingURL=index.js.map