@amplifyup/sdk 0.1.61 → 0.1.62

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.
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as Even
2
2
  export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-Db_eLrfU.mjs';
3
3
  export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
4
4
  export { A as AMPLIFYUP_EDITOR_ROUTE, i as isAmplifyUpEditorRoute } from './reservedRoutes-aGgViBDM.mjs';
5
- export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-DaJlqU-Z.mjs';
5
+ export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-DIZjc7st.mjs';
6
6
 
7
7
  /**
8
8
  * Storage utilities for instance ID and user ID
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as Even
2
2
  export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-Db_eLrfU.js';
3
3
  export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.js';
4
4
  export { A as AMPLIFYUP_EDITOR_ROUTE, i as isAmplifyUpEditorRoute } from './reservedRoutes-aGgViBDM.js';
5
- export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-BqApXxQi.js';
5
+ export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-3AXnQgzO.js';
6
6
 
7
7
  /**
8
8
  * Storage utilities for instance ID and user ID
package/dist/index.js CHANGED
@@ -398,6 +398,81 @@ function isComposerPreview() {
398
398
  return false;
399
399
  }
400
400
 
401
+ // src/field-envelope.ts
402
+ var FIELDS_BRAND = Symbol("amplifyup.fields");
403
+ function isBrandedFields(value) {
404
+ return !!value && typeof value === "object" && FIELDS_BRAND in value;
405
+ }
406
+ function brandFields(bag) {
407
+ if (isBrandedFields(bag)) return bag;
408
+ Object.defineProperty(bag, FIELDS_BRAND, {
409
+ value: true,
410
+ enumerable: false,
411
+ configurable: false
412
+ });
413
+ return bag;
414
+ }
415
+ function isFieldEnvelope(value) {
416
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
417
+ const rec = value;
418
+ return typeof rec.name === "string" && "value" in rec && !("url" in rec);
419
+ }
420
+ function isPortableImageShape(value) {
421
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
422
+ return "url" in value;
423
+ }
424
+ function joinPath(prefix, key) {
425
+ return prefix ? `${prefix}.${key}` : key;
426
+ }
427
+ function emptyValue(raw) {
428
+ if (raw === void 0) return null;
429
+ return raw;
430
+ }
431
+ function toFieldEnvelopes(source, prefix = "") {
432
+ const input = source && typeof source === "object" && !Array.isArray(source) ? source : {};
433
+ if (isBrandedFields(input)) {
434
+ return input;
435
+ }
436
+ const out = {};
437
+ for (const [key, raw] of Object.entries(input)) {
438
+ const path = joinPath(prefix, key);
439
+ if (isFieldEnvelope(raw)) {
440
+ out[key] = { value: raw.value ?? null, name: raw.name || path };
441
+ continue;
442
+ }
443
+ if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !raw.$$typeof) {
444
+ out[key] = toFieldEnvelopes(raw, path);
445
+ continue;
446
+ }
447
+ out[key] = { value: emptyValue(raw), name: path };
448
+ }
449
+ return brandFields(out);
450
+ }
451
+ function attachFieldEnvelopes(props) {
452
+ const raw = props && typeof props === "object" ? { ...props } : {};
453
+ if (isBrandedFields(raw.fields)) return raw;
454
+ const { fields: existing, ...content } = raw;
455
+ const source = existing && typeof existing === "object" && !isFieldEnvelope(existing) ? existing : content;
456
+ return { ...raw, fields: toFieldEnvelopes(source) };
457
+ }
458
+ function walkLayoutNodes(nodes) {
459
+ if (!Array.isArray(nodes)) return;
460
+ for (const node of nodes) {
461
+ if (!node || typeof node !== "object") continue;
462
+ const rec = node;
463
+ rec.props = attachFieldEnvelopes(rec.props);
464
+ for (const slot of rec.slots || []) {
465
+ walkLayoutNodes(slot.children);
466
+ }
467
+ }
468
+ }
469
+ function envelopePageConfig(page2) {
470
+ if (!page2 || typeof page2 !== "object") return page2 ?? null;
471
+ const tree = page2.layoutTree;
472
+ if (Array.isArray(tree)) walkLayoutNodes(tree);
473
+ return page2;
474
+ }
475
+
401
476
  // src/page-context.ts
402
477
  var defaultLog = {
403
478
  warn: (...args) => {
@@ -649,7 +724,25 @@ async function fetchEdgeResolve(options) {
649
724
  body
650
725
  );
651
726
  }
652
- return body;
727
+ return envelopeResolvedPayload(body);
728
+ }
729
+ function envelopeResolvedComponent(node) {
730
+ node.props = attachFieldEnvelopes(node.props);
731
+ if (!node.children) return;
732
+ for (const kids of Object.values(node.children)) {
733
+ for (const child of kids || []) envelopeResolvedComponent(child);
734
+ }
735
+ }
736
+ function envelopeResolvedPayload(payload) {
737
+ if (payload.tree) {
738
+ for (const node of payload.tree) envelopeResolvedComponent(node);
739
+ }
740
+ if (payload.zones) {
741
+ for (const roots of Object.values(payload.zones)) {
742
+ for (const node of roots || []) envelopeResolvedComponent(node);
743
+ }
744
+ }
745
+ return payload;
653
746
  }
654
747
 
655
748
  // src/edge/mapResolvedToPageConfig.ts
@@ -709,7 +802,9 @@ async function fetchContent(options) {
709
802
  const preview = options.preview ?? (typeof window !== "undefined" ? isComposerPreview() : false);
710
803
  if (preview) {
711
804
  try {
712
- const page2 = await options.fetchOrchestratorPage(options.route, true);
805
+ const page2 = envelopePageConfig(
806
+ await options.fetchOrchestratorPage(options.route, true)
807
+ );
713
808
  return {
714
809
  pageConfig: page2,
715
810
  source: "orchestrator",
@@ -1979,7 +2074,7 @@ Available Console Commands:
1979
2074
  this.refreshEventTracking();
1980
2075
  }, 800);
1981
2076
  }
1982
- return pageConfig;
2077
+ return envelopePageConfig(pageConfig);
1983
2078
  }
1984
2079
  /**
1985
2080
  * Set up view-level event tracking based on configuration