@amplifyup/sdk 0.1.73 → 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.
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- import { L as LayoutComponentProps, P as PageConfig } from './types-CGeBbx84.mjs';
4
+ import { L as LayoutComponentProps, P as PageConfig } from './types-BGZYaFxP.mjs';
5
5
 
6
6
  interface AmplifyRendererProps {
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- import { L as LayoutComponentProps, P as PageConfig } from './types-CGeBbx84.js';
4
+ import { L as LayoutComponentProps, P as PageConfig } from './types-BGZYaFxP.js';
5
5
 
6
6
  interface AmplifyRendererProps {
7
7
  /**
@@ -853,7 +853,8 @@ function mergeEventContext(properties, attached) {
853
853
  ...properties,
854
854
  ...attached.resource ? { resource: attached.resource } : {},
855
855
  page: attached.page,
856
- ...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
856
+ ...attached.pageRoute ? { pageRoute: attached.pageRoute } : {},
857
+ ...attached.pageResource ? { pageResource: attached.pageResource } : {}
857
858
  };
858
859
  }
859
860
  var PAGE_RESOURCE_MARKER = "__amplifyupPageResource";
@@ -1078,6 +1079,7 @@ var AmplifyUpSDK = class {
1078
1079
  this.pendingPageContext = null;
1079
1080
  this.attachedPageContext = null;
1080
1081
  this.resolvedPageData = null;
1082
+ this.resolvedPageResource = null;
1081
1083
  this.resolvedPageRoute = "";
1082
1084
  this.resolvedRouteParams = {};
1083
1085
  this.historyHooksInstalled = false;
@@ -1610,28 +1612,38 @@ var AmplifyUpSDK = class {
1610
1612
  * Apply published pageData (from /v1/resolve) so field validation and
1611
1613
  * mapped page fields can run.
1612
1614
  */
1613
- applyResolvedPageData(pageData, pageRoute, routeParams) {
1615
+ applyResolvedPageData(pageData, pageRoute, routeParams, pageResources) {
1614
1616
  this.resolvedPageData = pageData || null;
1615
1617
  if (pageRoute) this.resolvedPageRoute = pageRoute;
1616
1618
  if (routeParams) this.resolvedRouteParams = routeParams;
1619
+ const firstResourceName = pageData?.resources?.[0]?.name;
1620
+ const resolvedForPage = (firstResourceName ? pageResources?.[firstResourceName] : void 0) || (pageResources ? Object.values(pageResources)[0] : void 0);
1621
+ this.resolvedPageResource = resolvedForPage || null;
1617
1622
  this.recomputeAttachedContext();
1618
1623
  }
1619
1624
  recomputeAttachedContext() {
1620
1625
  if (!this.pendingPageContext) {
1621
- this.attachedPageContext = attachStaticPageContext(
1622
- this.resolvedPageData,
1623
- this.resolvedPageRoute
1626
+ this.attachedPageContext = this.withPageResource(
1627
+ attachStaticPageContext(this.resolvedPageData, this.resolvedPageRoute)
1624
1628
  );
1625
1629
  setPageResourceFields(null);
1626
1630
  return;
1627
1631
  }
1628
- this.attachedPageContext = applyPageContext(this.pendingPageContext, {
1629
- pageData: this.resolvedPageData,
1630
- routeParams: this.resolvedRouteParams,
1631
- pageRoute: this.resolvedPageRoute
1632
- });
1632
+ this.attachedPageContext = this.withPageResource(
1633
+ applyPageContext(this.pendingPageContext, {
1634
+ pageData: this.resolvedPageData,
1635
+ routeParams: this.resolvedRouteParams,
1636
+ pageRoute: this.resolvedPageRoute
1637
+ })
1638
+ );
1633
1639
  setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
1634
1640
  }
1641
+ /** Stamp the resolved entry onto the context so events carry it. */
1642
+ withPageResource(context) {
1643
+ if (!context || !this.resolvedPageResource) return context;
1644
+ const { entity, providerId, docId } = this.resolvedPageResource;
1645
+ return { ...context, pageResource: { entity, providerId, docId } };
1646
+ }
1635
1647
  getAttachedPageContext() {
1636
1648
  return this.attachedPageContext;
1637
1649
  }