@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/index.mjs CHANGED
@@ -451,14 +451,14 @@ function applyPageContext(input, opts) {
451
451
  log.warn("AmplifyUp: pageContext needs resourceType and key");
452
452
  return null;
453
453
  }
454
- const slot = opts.pageData?.slots?.[0];
455
- if (slot && slot.type && slot.type !== input.resourceType) {
454
+ const resource = opts.pageData?.resources?.[0];
455
+ if (resource && resource.type && resource.type !== input.resourceType) {
456
456
  log.warn(
457
- `AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page slot "${slot.type}"`
457
+ `AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page resource "${resource.type}"`
458
458
  );
459
459
  return null;
460
460
  }
461
- const fieldDefs = slot?.fields || [];
461
+ const fieldDefs = resource?.fields || [];
462
462
  const defByKey = new Map(fieldDefs.map((f) => [f.key, f]));
463
463
  const rawFields = input.fields && typeof input.fields === "object" ? input.fields : {};
464
464
  const fields = {};
@@ -471,12 +471,16 @@ function applyPageContext(input, opts) {
471
471
  log.warn(`AmplifyUp: unknown resource field "${k}" dropped`);
472
472
  continue;
473
473
  }
474
+ if (def.passThrough) {
475
+ if (v != null) fields[k] = v;
476
+ continue;
477
+ }
474
478
  const coerced = coerceField(def, v, log);
475
479
  if (coerced !== void 0) fields[k] = coerced;
476
480
  }
477
481
  }
478
482
  const params = { ...opts.routeParams || {} };
479
- const mapping = slot?.urlParamMapping;
483
+ const mapping = resource?.urlParamMapping;
480
484
  let resourceKey = key;
481
485
  if (mapping) {
482
486
  const fromUrl = params[mapping.param];
@@ -494,7 +498,7 @@ function applyPageContext(input, opts) {
494
498
  if (pf.value !== void 0) pageFields[pf.key] = pf.value;
495
499
  continue;
496
500
  }
497
- if (pf.source === "mapped" && pf.slot && pf.field) {
501
+ if (pf.source === "mapped" && pf.resource && pf.field) {
498
502
  pageFields[pf.key] = fields[pf.field];
499
503
  }
500
504
  }
@@ -538,7 +542,7 @@ function mergeEventContext(properties, attached) {
538
542
  ...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
539
543
  };
540
544
  }
541
- function setPageSlotFields(fields) {
545
+ function setPageResourceFields(fields) {
542
546
  }
543
547
 
544
548
  // src/reservedRoutes.ts
@@ -1519,7 +1523,7 @@ var AmplifyUpSDK = class {
1519
1523
  routeParams: this.resolvedRouteParams,
1520
1524
  pageRoute: this.resolvedPageRoute
1521
1525
  });
1522
- setPageSlotFields(this.attachedPageContext?.resource?.fields || null);
1526
+ setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
1523
1527
  }
1524
1528
  getAttachedPageContext() {
1525
1529
  return this.attachedPageContext;