@amplifyup/sdk 0.1.44 → 0.1.46

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 = {};
@@ -495,12 +495,16 @@ function applyPageContext(input, opts) {
495
495
  log.warn(`AmplifyUp: unknown resource field "${k}" dropped`);
496
496
  continue;
497
497
  }
498
+ if (def.passThrough) {
499
+ if (v != null) fields[k] = v;
500
+ continue;
501
+ }
498
502
  const coerced = coerceField(def, v, log);
499
503
  if (coerced !== void 0) fields[k] = coerced;
500
504
  }
501
505
  }
502
506
  const params = { ...opts.routeParams || {} };
503
- const mapping = slot?.urlParamMapping;
507
+ const mapping = resource?.urlParamMapping;
504
508
  let resourceKey = key;
505
509
  if (mapping) {
506
510
  const fromUrl = params[mapping.param];
@@ -518,7 +522,7 @@ function applyPageContext(input, opts) {
518
522
  if (pf.value !== void 0) pageFields[pf.key] = pf.value;
519
523
  continue;
520
524
  }
521
- if (pf.source === "mapped" && pf.slot && pf.field) {
525
+ if (pf.source === "mapped" && pf.resource && pf.field) {
522
526
  pageFields[pf.key] = fields[pf.field];
523
527
  }
524
528
  }
@@ -562,9 +566,9 @@ function mergeEventContext(properties, attached) {
562
566
  ...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
563
567
  };
564
568
  }
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";
569
+ var PAGE_RESOURCE_MARKER = "__amplifyupPageResource";
570
+ function isPageResourceSentinel(value) {
571
+ return !!value && typeof value === "object" && !Array.isArray(value) && typeof value[PAGE_RESOURCE_MARKER] === "string";
568
572
  }
569
573
  function getByDotPath(source, path) {
570
574
  if (!path) return source;
@@ -578,30 +582,30 @@ function getByDotPath(source, path) {
578
582
  }
579
583
  return cur;
580
584
  }
581
- function hydratePageSlotValue(value, fields) {
582
- if (!isPageSlotSentinel(value)) return value;
585
+ function hydratePageResourceValue(value, fields) {
586
+ if (!isPageResourceSentinel(value)) return value;
583
587
  if (!fields) return null;
584
588
  if (value.path) return getByDotPath(fields, value.path) ?? null;
585
589
  return fields;
586
590
  }
587
- function hydratePageSlotProps(props, fields) {
591
+ function hydratePageResourceProps(props, fields) {
588
592
  const source = props && typeof props === "object" ? props : {};
589
593
  const out = { ...source };
590
594
  for (const [key, val] of Object.entries(out)) {
591
- if (isPageSlotSentinel(val)) {
592
- out[key] = hydratePageSlotValue(val, fields);
595
+ if (isPageResourceSentinel(val)) {
596
+ out[key] = hydratePageResourceValue(val, fields);
593
597
  }
594
598
  }
595
599
  return out;
596
600
  }
597
601
 
598
- // src/page-slot-runtime.ts
599
- var pageSlotFields = null;
600
- function setPageSlotFields(fields) {
601
- pageSlotFields = fields && typeof fields === "object" ? fields : null;
602
+ // src/page-resource-runtime.ts
603
+ var pageResourceFields = null;
604
+ function setPageResourceFields(fields) {
605
+ pageResourceFields = fields && typeof fields === "object" ? fields : null;
602
606
  }
603
- function getPageSlotFields() {
604
- return pageSlotFields;
607
+ function getPageResourceFields() {
608
+ return pageResourceFields;
605
609
  }
606
610
 
607
611
  // src/edge/normalizeRoute.ts
@@ -1569,7 +1573,7 @@ var AmplifyUpSDK = class {
1569
1573
  this.resolvedPageData,
1570
1574
  this.resolvedPageRoute
1571
1575
  );
1572
- setPageSlotFields(null);
1576
+ setPageResourceFields(null);
1573
1577
  return;
1574
1578
  }
1575
1579
  this.attachedPageContext = applyPageContext(this.pendingPageContext, {
@@ -1577,7 +1581,7 @@ var AmplifyUpSDK = class {
1577
1581
  routeParams: this.resolvedRouteParams,
1578
1582
  pageRoute: this.resolvedPageRoute
1579
1583
  });
1580
- setPageSlotFields(this.attachedPageContext?.resource?.fields || null);
1584
+ setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
1581
1585
  }
1582
1586
  getAttachedPageContext() {
1583
1587
  return this.attachedPageContext;
@@ -3382,7 +3386,7 @@ function ComponentContextProvider({
3382
3386
  }) {
3383
3387
  const liveProps = useLiveComposerProps(
3384
3388
  layoutNodeId,
3385
- hydratePageSlotProps(props || {}, getPageSlotFields())
3389
+ hydratePageResourceProps(props || {}, getPageResourceFields())
3386
3390
  );
3387
3391
  return /* @__PURE__ */ jsx(
3388
3392
  ComponentContext.Provider,