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