@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
  'use strict';
2
2
 
3
+ var buffer = require('buffer');
3
4
  var react = require('react');
4
5
 
5
6
  /**
@@ -62,12 +63,12 @@ var fetchCustomBrandingImpl = async () => {
62
63
  if (!appSlug) {
63
64
  throw new Error("PORTAL_APP_SLUG is not configured");
64
65
  }
65
- const url = `${getApiOrigin()}/v3/custom-branding?app_slug=${encodeURIComponent(
66
+ const url = `${getApiOrigin()}/enterprise-portal/public/branding?app_slug=${encodeURIComponent(
66
67
  appSlug
67
68
  )}`;
68
69
  if (process.env.NODE_ENV !== "production") {
69
70
  console.debug(
70
- "[portal-components] fetching custom branding via %s",
71
+ "[portal-components] fetching custom branding via %s (Enterprise Portal API)",
71
72
  url
72
73
  );
73
74
  }
@@ -82,13 +83,18 @@ var fetchCustomBrandingImpl = async () => {
82
83
  );
83
84
  }
84
85
  const payload = await response.json();
85
- const brandingData = payload?.branding_data;
86
- if (typeof brandingData !== "string") {
87
- throw new Error("Custom branding response missing branding_data string");
88
- }
86
+ const brandingObject = {
87
+ logo: payload.logoUrl,
88
+ title: payload.appName,
89
+ customColor1: payload.primaryColor,
90
+ customColor2: payload.secondaryColor,
91
+ favicon: payload.faviconUrl
92
+ };
93
+ const brandingData = buffer.Buffer.from(JSON.stringify(brandingObject)).toString("base64");
89
94
  return {
90
95
  brandingData,
91
- documentation: payload?.documentation ?? null
96
+ documentation: null
97
+ // Documentation not included in new API's public endpoint
92
98
  };
93
99
  };
94
100
  react.cache(fetchCustomBrandingImpl);
@@ -105,7 +111,7 @@ var decodeJwtPayload = (token) => {
105
111
  payloadSegment.length + (4 - payloadSegment.length % 4) % 4,
106
112
  "="
107
113
  );
108
- const decoded = Buffer.from(padded, "base64").toString("utf-8");
114
+ const decoded = buffer.Buffer.from(padded, "base64").toString("utf-8");
109
115
  return JSON.parse(decoded);
110
116
  };
111
117
  var getCustomerIdFromToken = (token) => {
@@ -123,15 +129,13 @@ async function fetchChannelReleases(input, context) {
123
129
  if (!token || typeof token !== "string") {
124
130
  throw new Error("fetchChannelReleases requires a session token");
125
131
  }
126
- const customerId = getCustomerIdFromToken(token);
127
132
  const origin = getApiOrigin();
128
- const url = new URL(`${origin}/v3/channel-releases`);
129
- url.searchParams.set("customer_id", customerId);
133
+ const url = new URL(`${origin}/enterprise-portal/channel-releases`);
130
134
  if (channelId) {
131
135
  url.searchParams.set("channel_id", channelId);
132
136
  }
133
137
  if (process.env.NODE_ENV !== "production") {
134
- console.debug("[portal-components] fetching channel releases via %s", url.toString());
138
+ console.debug("[portal-components] fetching channel releases via %s (Enterprise Portal API)", url.toString());
135
139
  }
136
140
  const response = await authenticatedFetch(url.toString(), {
137
141
  method: "GET",
@@ -147,9 +151,10 @@ async function fetchChannelReleases(input, context) {
147
151
  `Channel releases request failed (${response.status} ${response.statusText}): ${errorText}`
148
152
  );
149
153
  }
150
- const payload = await response.json();
154
+ const envelope = await response.json();
155
+ const payload = envelope.data;
151
156
  return {
152
- channelReleases: payload.channelReleases || []
157
+ channelReleases: payload?.channelReleases || []
153
158
  };
154
159
  }
155
160
  async function createInstallOptions(input, context) {
@@ -174,9 +179,8 @@ async function createInstallOptions(input, context) {
174
179
  if (!serviceAccountId?.trim()) {
175
180
  throw new Error("Service account ID is required");
176
181
  }
177
- const customerId = getCustomerIdFromToken(token);
178
182
  const origin = getApiOrigin();
179
- const endpoint = `${origin}/v3/customers/${customerId}/install-options?includeInstructions=true`;
183
+ const endpoint = `${origin}/enterprise-portal/install-options?includeInstructions=true`;
180
184
  const body = {
181
185
  install_type: installType,
182
186
  instance_name: instanceName.trim(),
@@ -231,9 +235,8 @@ async function getInstallOptions(input, context) {
231
235
  if (!installOptionsId?.trim()) {
232
236
  throw new Error("Install options ID is required");
233
237
  }
234
- const customerId = getCustomerIdFromToken(token);
235
238
  const origin = getApiOrigin();
236
- const url = new URL(`${origin}/v3/customers/${customerId}/install-options/${installOptionsId.trim()}`);
239
+ const url = new URL(`${origin}/enterprise-portal/install-options/${installOptionsId.trim()}`);
237
240
  if (includeInstructions) {
238
241
  url.searchParams.set("includeInstructions", "true");
239
242
  }
@@ -244,7 +247,7 @@ async function getInstallOptions(input, context) {
244
247
  url.searchParams.set("proxyUrl", proxyUrl);
245
248
  }
246
249
  if (process.env.NODE_ENV !== "production") {
247
- console.debug("[portal-components] fetching install options via %s", url.toString());
250
+ console.debug("[portal-components] fetching install options via %s (Enterprise Portal API)", url.toString());
248
251
  }
249
252
  const response = await authenticatedFetch(url.toString(), {
250
253
  method: "GET",
@@ -260,7 +263,8 @@ async function getInstallOptions(input, context) {
260
263
  `Get install options failed (${response.status} ${response.statusText}): ${errorText}`
261
264
  );
262
265
  }
263
- return await response.json();
266
+ const envelope = await response.json();
267
+ return envelope.data;
264
268
  }
265
269
  async function updateInstallOptions(input, context) {
266
270
  const {
@@ -286,9 +290,8 @@ async function updateInstallOptions(input, context) {
286
290
  if (!installOptionsId?.trim()) {
287
291
  throw new Error("Install options ID is required");
288
292
  }
289
- const customerId = getCustomerIdFromToken(token);
290
293
  const origin = getApiOrigin();
291
- const url = new URL(`${origin}/v3/customers/${customerId}/install-options/${installOptionsId.trim()}`);
294
+ const url = new URL(`${origin}/enterprise-portal/install-options/${installOptionsId.trim()}`);
292
295
  if (includeInstructions) {
293
296
  url.searchParams.set("includeInstructions", "true");
294
297
  }
@@ -382,7 +385,7 @@ async function getUpdateInstructions(input, context) {
382
385
  if (!identifier) {
383
386
  throw new Error("Either installOptionsId or instanceId is required");
384
387
  }
385
- const customerId = getCustomerIdFromToken(token);
388
+ getCustomerIdFromToken(token);
386
389
  const origin = getApiOrigin();
387
390
  const queryParams = new URLSearchParams();
388
391
  queryParams.set("targetChannelId", targetChannelId.trim());
@@ -394,7 +397,7 @@ async function getUpdateInstructions(input, context) {
394
397
  queryParams.set("instance_id", instanceId);
395
398
  }
396
399
  const pathId = installOptionsId || "placeholder";
397
- const url = `${origin}/v3/customers/${customerId}/install-options/${pathId}/update-instructions?${queryParams.toString()}`;
400
+ const url = `${origin}/enterprise-portal/install-options/${pathId}/update-instructions?${queryParams.toString()}`;
398
401
  if (process.env.NODE_ENV !== "production") {
399
402
  console.debug("[portal-components] fetching update instructions via %s", url);
400
403
  }
@@ -431,19 +434,16 @@ async function fetchPendingInstallations(input, context) {
431
434
  if (typeof token !== "string" || token.trim().length === 0) {
432
435
  throw new Error("fetchPendingInstallations requires a non-empty token");
433
436
  }
434
- let customerId;
435
- try {
436
- customerId = getCustomerIdFromToken(token);
437
- } catch {
438
- return { installations: [] };
439
- }
440
437
  const origin = getApiOrigin();
441
438
  const queryParams = new URLSearchParams();
442
439
  queryParams.set("status", "in_progress");
443
440
  queryParams.set("page_size", "5");
444
441
  queryParams.set("order_by", "created_at");
445
442
  queryParams.set("order_direction", "desc");
446
- const endpoint = `${origin}/v3/customers/${customerId}/install-options?${queryParams.toString()}`;
443
+ const endpoint = `${origin}/enterprise-portal/install-options?${queryParams.toString()}`;
444
+ if (process.env.NODE_ENV !== "production") {
445
+ console.debug("[portal-components] fetching pending installations via %s (Enterprise Portal API)", endpoint);
446
+ }
447
447
  const response = await authenticatedFetch(endpoint, {
448
448
  method: "GET",
449
449
  token,
@@ -457,8 +457,8 @@ async function fetchPendingInstallations(input, context) {
457
457
  `Pending installations request failed (${response.status} ${response.statusText})`
458
458
  );
459
459
  }
460
- const payload = await response.json();
461
- console.log("[portal-components] fetchPendingInstallations raw response:", JSON.stringify(payload, null, 2));
460
+ const envelope = await response.json();
461
+ const payload = envelope.data;
462
462
  const installArray = payload?.install_options || [];
463
463
  const installations = installArray.map((item) => ({
464
464
  id: String(item.id || ""),
@@ -467,7 +467,6 @@ async function fetchPendingInstallations(input, context) {
467
467
  startedBy: String(item.service_account_email_address || "Unknown"),
468
468
  startedAt: String(item.started_at || (/* @__PURE__ */ new Date()).toISOString())
469
469
  }));
470
- console.log("[portal-components] fetchPendingInstallations parsed installations:", installations.length);
471
470
  return {
472
471
  installations
473
472
  };
@@ -536,10 +535,9 @@ async function fetchInstances2(input, context) {
536
535
  if (!token || typeof token !== "string") {
537
536
  throw new Error("fetchInstances requires a session token");
538
537
  }
539
- const customerId = getCustomerIdFromToken(token);
538
+ getCustomerIdFromToken(token);
540
539
  const origin = getApiOrigin();
541
- const url = new URL(`${origin}/v3/instances`);
542
- url.searchParams.set("customer_id", customerId);
540
+ const url = new URL(`${origin}/enterprise-portal/instances`);
543
541
  if (process.env.NODE_ENV !== "production") {
544
542
  console.debug("[portal-components] fetching instances via %s", url.toString());
545
543
  }
@@ -558,7 +556,8 @@ async function fetchInstances2(input, context) {
558
556
  );
559
557
  }
560
558
  const payload = await response.json();
561
- const allInstances = payload.instances || [];
559
+ const data = payload.data;
560
+ const allInstances = data?.instances || [];
562
561
  const online = allInstances.filter((instance) => !instance.isAirgap);
563
562
  const airgap = allInstances.filter((instance) => instance.isAirgap);
564
563
  return {
@@ -587,10 +586,8 @@ async function createAirgapInstance(input, context) {
587
586
  if (!channelId?.trim()) {
588
587
  throw new Error("Channel ID is required");
589
588
  }
590
- const customerId = getCustomerIdFromToken(token);
591
589
  const origin = getApiOrigin();
592
- const url = new URL(`${origin}/v3/instance/airgap`);
593
- url.searchParams.set("customer_id", customerId);
590
+ const url = new URL(`${origin}/enterprise-portal/instances/airgap`);
594
591
  const body = {
595
592
  service_account_id: serviceAccountId.trim(),
596
593
  channel_id: channelId.trim(),
@@ -661,10 +658,8 @@ async function updateAirgapInstance(input, context) {
661
658
  if (!channelId?.trim()) {
662
659
  throw new Error("Channel ID is required");
663
660
  }
664
- const customerId = getCustomerIdFromToken(token);
665
661
  const origin = getApiOrigin();
666
- const url = new URL(`${origin}/v3/instance/airgap/${instanceId.trim()}`);
667
- url.searchParams.set("customer_id", customerId);
662
+ const url = new URL(`${origin}/enterprise-portal/instances/airgap/${instanceId.trim()}`);
668
663
  const body = {
669
664
  channel_id: channelId.trim(),
670
665
  channel_sequence: channelSequence
@@ -705,7 +700,7 @@ async function fetchInstallOptionsByInstanceIds(input, context) {
705
700
  if (!instanceIds || instanceIds.length === 0) {
706
701
  return { installOptions: [] };
707
702
  }
708
- const customerId = getCustomerIdFromToken(token);
703
+ getCustomerIdFromToken(token);
709
704
  const origin = getApiOrigin();
710
705
  const chunks = [];
711
706
  for (let i = 0; i < instanceIds.length; i += 50) {
@@ -715,7 +710,7 @@ async function fetchInstallOptionsByInstanceIds(input, context) {
715
710
  for (const chunk of chunks) {
716
711
  if (chunk.length === 0) continue;
717
712
  const queryParams = chunk.map((id) => `instance_id=${encodeURIComponent(id)}`).join("&");
718
- const url = `${origin}/v3/customers/${customerId}/install-options?${queryParams}`;
713
+ const url = `${origin}/enterprise-portal/install-options?${queryParams}`;
719
714
  if (process.env.NODE_ENV !== "production") {
720
715
  console.debug("[portal-components] fetching install options via %s", url);
721
716
  }
@@ -736,8 +731,8 @@ async function fetchInstallOptionsByInstanceIds(input, context) {
736
731
  `Install options request failed (${response.status} ${response.statusText}): ${errorText}`
737
732
  );
738
733
  }
739
- const payload = await response.json();
740
- const options = payload?.install_options || [];
734
+ const envelope = await response.json();
735
+ const options = envelope?.data?.install_options || [];
741
736
  allInstallOptions.push(...options);
742
737
  }
743
738
  return { installOptions: allInstallOptions };