@replicated/portal-components 0.0.12 → 0.0.14

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,5 +1,6 @@
1
1
  import { cache, useState, useRef, useMemo, useEffect, useCallback } from 'react';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { Buffer } from 'buffer';
3
4
 
4
5
  /**
5
6
  * Enterprise Portal Components
@@ -754,10 +755,10 @@ var createServiceAccount = defineServerAction({
754
755
  if (!name || typeof name !== "string" || !name.trim()) {
755
756
  throw new Error("Service account name is required");
756
757
  }
757
- const endpoint = `${getApiOrigin()}/v3/service-account`;
758
+ const endpoint = `${getApiOrigin()}/enterprise-portal/team/service-accounts`;
758
759
  if (process.env.NODE_ENV !== "production") {
759
760
  console.debug(
760
- "[portal-components] creating service account via %s",
761
+ "[portal-components] creating service account via %s (Enterprise Portal API)",
761
762
  endpoint
762
763
  );
763
764
  }
@@ -784,12 +785,12 @@ var fetchCustomBrandingImpl = async () => {
784
785
  if (!appSlug) {
785
786
  throw new Error("PORTAL_APP_SLUG is not configured");
786
787
  }
787
- const url = `${getApiOrigin()}/v3/custom-branding?app_slug=${encodeURIComponent(
788
+ const url = `${getApiOrigin()}/enterprise-portal/public/branding?app_slug=${encodeURIComponent(
788
789
  appSlug
789
790
  )}`;
790
791
  if (process.env.NODE_ENV !== "production") {
791
792
  console.debug(
792
- "[portal-components] fetching custom branding via %s",
793
+ "[portal-components] fetching custom branding via %s (Enterprise Portal API)",
793
794
  url
794
795
  );
795
796
  }
@@ -804,40 +805,21 @@ var fetchCustomBrandingImpl = async () => {
804
805
  );
805
806
  }
806
807
  const payload = await response.json();
807
- const brandingData = payload?.branding_data;
808
- if (typeof brandingData !== "string") {
809
- throw new Error("Custom branding response missing branding_data string");
810
- }
808
+ const brandingObject = {
809
+ logo: payload.logoUrl,
810
+ title: payload.appName,
811
+ customColor1: payload.primaryColor,
812
+ customColor2: payload.secondaryColor,
813
+ favicon: payload.faviconUrl
814
+ };
815
+ const brandingData = Buffer.from(JSON.stringify(brandingObject)).toString("base64");
811
816
  return {
812
817
  brandingData,
813
- documentation: payload?.documentation ?? null
818
+ documentation: null
819
+ // Documentation not included in new API's public endpoint
814
820
  };
815
821
  };
816
822
  cache(fetchCustomBrandingImpl);
817
- var decodeJwtPayload = (token) => {
818
- const parts = token.split(".");
819
- if (parts.length !== 3) {
820
- throw new Error("Invalid JWT received");
821
- }
822
- const payloadSegment = parts[1];
823
- if (!payloadSegment) {
824
- throw new Error("JWT payload segment missing");
825
- }
826
- const padded = payloadSegment.padEnd(
827
- payloadSegment.length + (4 - payloadSegment.length % 4) % 4,
828
- "="
829
- );
830
- const decoded = Buffer.from(padded, "base64").toString("utf-8");
831
- return JSON.parse(decoded);
832
- };
833
- var getCustomerIdFromToken = (token) => {
834
- const payload = decodeJwtPayload(token);
835
- const customerId = payload?.customer_id || payload?.customerId;
836
- if (typeof customerId !== "string" || !customerId.trim()) {
837
- throw new Error("Unable to determine customer_id from session token");
838
- }
839
- return customerId.trim();
840
- };
841
823
 
842
824
  // src/actions/install.ts
843
825
  async function fetchChannelReleases(input, context) {
@@ -845,15 +827,13 @@ async function fetchChannelReleases(input, context) {
845
827
  if (!token || typeof token !== "string") {
846
828
  throw new Error("fetchChannelReleases requires a session token");
847
829
  }
848
- const customerId = getCustomerIdFromToken(token);
849
830
  const origin = getApiOrigin();
850
- const url = new URL(`${origin}/v3/channel-releases`);
851
- url.searchParams.set("customer_id", customerId);
831
+ const url = new URL(`${origin}/enterprise-portal/channel-releases`);
852
832
  if (channelId) {
853
833
  url.searchParams.set("channel_id", channelId);
854
834
  }
855
835
  if (process.env.NODE_ENV !== "production") {
856
- console.debug("[portal-components] fetching channel releases via %s", url.toString());
836
+ console.debug("[portal-components] fetching channel releases via %s (Enterprise Portal API)", url.toString());
857
837
  }
858
838
  const response = await authenticatedFetch(url.toString(), {
859
839
  method: "GET",
@@ -869,9 +849,10 @@ async function fetchChannelReleases(input, context) {
869
849
  `Channel releases request failed (${response.status} ${response.statusText}): ${errorText}`
870
850
  );
871
851
  }
872
- const payload = await response.json();
852
+ const envelope = await response.json();
853
+ const payload = envelope.data;
873
854
  return {
874
- channelReleases: payload.channelReleases || []
855
+ channelReleases: payload?.channelReleases || []
875
856
  };
876
857
  }
877
858
  async function createInstallOptions(input, context) {
@@ -896,9 +877,8 @@ async function createInstallOptions(input, context) {
896
877
  if (!serviceAccountId?.trim()) {
897
878
  throw new Error("Service account ID is required");
898
879
  }
899
- const customerId = getCustomerIdFromToken(token);
900
880
  const origin = getApiOrigin();
901
- const endpoint = `${origin}/v3/customers/${customerId}/install-options?includeInstructions=true`;
881
+ const endpoint = `${origin}/enterprise-portal/install-options?includeInstructions=true`;
902
882
  const body = {
903
883
  install_type: installType,
904
884
  instance_name: instanceName.trim(),
@@ -953,9 +933,8 @@ async function getInstallOptions(input, context) {
953
933
  if (!installOptionsId?.trim()) {
954
934
  throw new Error("Install options ID is required");
955
935
  }
956
- const customerId = getCustomerIdFromToken(token);
957
936
  const origin = getApiOrigin();
958
- const url = new URL(`${origin}/v3/customers/${customerId}/install-options/${installOptionsId.trim()}`);
937
+ const url = new URL(`${origin}/enterprise-portal/install-options/${installOptionsId.trim()}`);
959
938
  if (includeInstructions) {
960
939
  url.searchParams.set("includeInstructions", "true");
961
940
  }
@@ -966,7 +945,7 @@ async function getInstallOptions(input, context) {
966
945
  url.searchParams.set("proxyUrl", proxyUrl);
967
946
  }
968
947
  if (process.env.NODE_ENV !== "production") {
969
- console.debug("[portal-components] fetching install options via %s", url.toString());
948
+ console.debug("[portal-components] fetching install options via %s (Enterprise Portal API)", url.toString());
970
949
  }
971
950
  const response = await authenticatedFetch(url.toString(), {
972
951
  method: "GET",
@@ -982,7 +961,8 @@ async function getInstallOptions(input, context) {
982
961
  `Get install options failed (${response.status} ${response.statusText}): ${errorText}`
983
962
  );
984
963
  }
985
- return await response.json();
964
+ const envelope = await response.json();
965
+ return envelope.data;
986
966
  }
987
967
  async function updateInstallOptions(input, context) {
988
968
  const {
@@ -1008,9 +988,8 @@ async function updateInstallOptions(input, context) {
1008
988
  if (!installOptionsId?.trim()) {
1009
989
  throw new Error("Install options ID is required");
1010
990
  }
1011
- const customerId = getCustomerIdFromToken(token);
1012
991
  const origin = getApiOrigin();
1013
- const url = new URL(`${origin}/v3/customers/${customerId}/install-options/${installOptionsId.trim()}`);
992
+ const url = new URL(`${origin}/enterprise-portal/install-options/${installOptionsId.trim()}`);
1014
993
  if (includeInstructions) {
1015
994
  url.searchParams.set("includeInstructions", "true");
1016
995
  }