@amplifyup/sdk 0.1.72 → 0.1.74

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.
@@ -851,7 +851,8 @@ function mergeEventContext(properties, attached) {
851
851
  ...properties,
852
852
  ...attached.resource ? { resource: attached.resource } : {},
853
853
  page: attached.page,
854
- ...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
854
+ ...attached.pageRoute ? { pageRoute: attached.pageRoute } : {},
855
+ ...attached.pageResource ? { pageResource: attached.pageResource } : {}
855
856
  };
856
857
  }
857
858
  var PAGE_RESOURCE_MARKER = "__amplifyupPageResource";
@@ -1076,6 +1077,7 @@ var AmplifyUpSDK = class {
1076
1077
  this.pendingPageContext = null;
1077
1078
  this.attachedPageContext = null;
1078
1079
  this.resolvedPageData = null;
1080
+ this.resolvedPageResource = null;
1079
1081
  this.resolvedPageRoute = "";
1080
1082
  this.resolvedRouteParams = {};
1081
1083
  this.historyHooksInstalled = false;
@@ -1608,28 +1610,38 @@ var AmplifyUpSDK = class {
1608
1610
  * Apply published pageData (from /v1/resolve) so field validation and
1609
1611
  * mapped page fields can run.
1610
1612
  */
1611
- applyResolvedPageData(pageData, pageRoute, routeParams) {
1613
+ applyResolvedPageData(pageData, pageRoute, routeParams, pageResources) {
1612
1614
  this.resolvedPageData = pageData || null;
1613
1615
  if (pageRoute) this.resolvedPageRoute = pageRoute;
1614
1616
  if (routeParams) this.resolvedRouteParams = routeParams;
1617
+ const firstResourceName = pageData?.resources?.[0]?.name;
1618
+ const resolvedForPage = (firstResourceName ? pageResources?.[firstResourceName] : void 0) || (pageResources ? Object.values(pageResources)[0] : void 0);
1619
+ this.resolvedPageResource = resolvedForPage || null;
1615
1620
  this.recomputeAttachedContext();
1616
1621
  }
1617
1622
  recomputeAttachedContext() {
1618
1623
  if (!this.pendingPageContext) {
1619
- this.attachedPageContext = attachStaticPageContext(
1620
- this.resolvedPageData,
1621
- this.resolvedPageRoute
1624
+ this.attachedPageContext = this.withPageResource(
1625
+ attachStaticPageContext(this.resolvedPageData, this.resolvedPageRoute)
1622
1626
  );
1623
1627
  setPageResourceFields(null);
1624
1628
  return;
1625
1629
  }
1626
- this.attachedPageContext = applyPageContext(this.pendingPageContext, {
1627
- pageData: this.resolvedPageData,
1628
- routeParams: this.resolvedRouteParams,
1629
- pageRoute: this.resolvedPageRoute
1630
- });
1630
+ this.attachedPageContext = this.withPageResource(
1631
+ applyPageContext(this.pendingPageContext, {
1632
+ pageData: this.resolvedPageData,
1633
+ routeParams: this.resolvedRouteParams,
1634
+ pageRoute: this.resolvedPageRoute
1635
+ })
1636
+ );
1631
1637
  setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
1632
1638
  }
1639
+ /** Stamp the resolved entry onto the context so events carry it. */
1640
+ withPageResource(context) {
1641
+ if (!context || !this.resolvedPageResource) return context;
1642
+ const { entity, providerId, docId } = this.resolvedPageResource;
1643
+ return { ...context, pageResource: { entity, providerId, docId } };
1644
+ }
1633
1645
  getAttachedPageContext() {
1634
1646
  return this.attachedPageContext;
1635
1647
  }