@amplifyup/sdk 0.1.44 → 0.1.45

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/react.mjs CHANGED
@@ -475,14 +475,14 @@ function applyPageContext(input, opts) {
475
475
  log.warn("AmplifyUp: pageContext needs resourceType and key");
476
476
  return null;
477
477
  }
478
- const slot = opts.pageData?.slots?.[0];
479
- if (slot && slot.type && slot.type !== input.resourceType) {
478
+ const resource = opts.pageData?.resources?.[0];
479
+ if (resource && resource.type && resource.type !== input.resourceType) {
480
480
  log.warn(
481
- `AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page slot "${slot.type}"`
481
+ `AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page resource "${resource.type}"`
482
482
  );
483
483
  return null;
484
484
  }
485
- const fieldDefs = slot?.fields || [];
485
+ const fieldDefs = resource?.fields || [];
486
486
  const defByKey = new Map(fieldDefs.map((f) => [f.key, f]));
487
487
  const rawFields = input.fields && typeof input.fields === "object" ? input.fields : {};
488
488
  const fields = {};
@@ -500,7 +500,7 @@ function applyPageContext(input, opts) {
500
500
  }
501
501
  }
502
502
  const params = { ...opts.routeParams || {} };
503
- const mapping = slot?.urlParamMapping;
503
+ const mapping = resource?.urlParamMapping;
504
504
  let resourceKey = key;
505
505
  if (mapping) {
506
506
  const fromUrl = params[mapping.param];
@@ -518,7 +518,7 @@ function applyPageContext(input, opts) {
518
518
  if (pf.value !== void 0) pageFields[pf.key] = pf.value;
519
519
  continue;
520
520
  }
521
- if (pf.source === "mapped" && pf.slot && pf.field) {
521
+ if (pf.source === "mapped" && pf.resource && pf.field) {
522
522
  pageFields[pf.key] = fields[pf.field];
523
523
  }
524
524
  }
@@ -562,9 +562,9 @@ function mergeEventContext(properties, attached) {
562
562
  ...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
563
563
  };
564
564
  }
565
- var PAGE_SLOT_MARKER = "__amplifyupPageSlot";
566
- function isPageSlotSentinel(value) {
567
- return !!value && typeof value === "object" && !Array.isArray(value) && typeof value[PAGE_SLOT_MARKER] === "string";
565
+ var PAGE_RESOURCE_MARKER = "__amplifyupPageResource";
566
+ function isPageResourceSentinel(value) {
567
+ return !!value && typeof value === "object" && !Array.isArray(value) && typeof value[PAGE_RESOURCE_MARKER] === "string";
568
568
  }
569
569
  function getByDotPath(source, path) {
570
570
  if (!path) return source;
@@ -578,30 +578,30 @@ function getByDotPath(source, path) {
578
578
  }
579
579
  return cur;
580
580
  }
581
- function hydratePageSlotValue(value, fields) {
582
- if (!isPageSlotSentinel(value)) return value;
581
+ function hydratePageResourceValue(value, fields) {
582
+ if (!isPageResourceSentinel(value)) return value;
583
583
  if (!fields) return null;
584
584
  if (value.path) return getByDotPath(fields, value.path) ?? null;
585
585
  return fields;
586
586
  }
587
- function hydratePageSlotProps(props, fields) {
587
+ function hydratePageResourceProps(props, fields) {
588
588
  const source = props && typeof props === "object" ? props : {};
589
589
  const out = { ...source };
590
590
  for (const [key, val] of Object.entries(out)) {
591
- if (isPageSlotSentinel(val)) {
592
- out[key] = hydratePageSlotValue(val, fields);
591
+ if (isPageResourceSentinel(val)) {
592
+ out[key] = hydratePageResourceValue(val, fields);
593
593
  }
594
594
  }
595
595
  return out;
596
596
  }
597
597
 
598
- // src/page-slot-runtime.ts
599
- var pageSlotFields = null;
600
- function setPageSlotFields(fields) {
601
- pageSlotFields = fields && typeof fields === "object" ? fields : null;
598
+ // src/page-resource-runtime.ts
599
+ var pageResourceFields = null;
600
+ function setPageResourceFields(fields) {
601
+ pageResourceFields = fields && typeof fields === "object" ? fields : null;
602
602
  }
603
- function getPageSlotFields() {
604
- return pageSlotFields;
603
+ function getPageResourceFields() {
604
+ return pageResourceFields;
605
605
  }
606
606
 
607
607
  // src/edge/normalizeRoute.ts
@@ -1569,7 +1569,7 @@ var AmplifyUpSDK = class {
1569
1569
  this.resolvedPageData,
1570
1570
  this.resolvedPageRoute
1571
1571
  );
1572
- setPageSlotFields(null);
1572
+ setPageResourceFields(null);
1573
1573
  return;
1574
1574
  }
1575
1575
  this.attachedPageContext = applyPageContext(this.pendingPageContext, {
@@ -1577,7 +1577,7 @@ var AmplifyUpSDK = class {
1577
1577
  routeParams: this.resolvedRouteParams,
1578
1578
  pageRoute: this.resolvedPageRoute
1579
1579
  });
1580
- setPageSlotFields(this.attachedPageContext?.resource?.fields || null);
1580
+ setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
1581
1581
  }
1582
1582
  getAttachedPageContext() {
1583
1583
  return this.attachedPageContext;
@@ -3382,7 +3382,7 @@ function ComponentContextProvider({
3382
3382
  }) {
3383
3383
  const liveProps = useLiveComposerProps(
3384
3384
  layoutNodeId,
3385
- hydratePageSlotProps(props || {}, getPageSlotFields())
3385
+ hydratePageResourceProps(props || {}, getPageResourceFields())
3386
3386
  );
3387
3387
  return /* @__PURE__ */ jsx(
3388
3388
  ComponentContext.Provider,