@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/AmplifyRenderer.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +8 -8
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +8 -8
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/index.mjs.map +1 -1
- package/dist/{query-DhyG93JN.d.mts → query-2-zPPrMI.d.mts} +1 -1
- package/dist/{query-CMiGo_Kt.d.ts → query-CFpvzSZT.d.ts} +1 -1
- package/dist/react.d.mts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +23 -23
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +23 -23
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/{types-BjlTE_cW.d.mts → types-NdLzHxZo.d.mts} +2 -2
- package/dist/{types-BjlTE_cW.d.ts → types-NdLzHxZo.d.ts} +2 -2
- package/package.json +1 -1
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
|
|
479
|
-
if (
|
|
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
|
|
481
|
+
`AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page resource "${resource.type}"`
|
|
482
482
|
);
|
|
483
483
|
return null;
|
|
484
484
|
}
|
|
485
|
-
const fieldDefs =
|
|
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 =
|
|
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.
|
|
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
|
|
566
|
-
function
|
|
567
|
-
return !!value && typeof value === "object" && !Array.isArray(value) && typeof value[
|
|
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
|
|
582
|
-
if (!
|
|
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
|
|
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 (
|
|
592
|
-
out[key] =
|
|
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-
|
|
599
|
-
var
|
|
600
|
-
function
|
|
601
|
-
|
|
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
|
|
604
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3385
|
+
hydratePageResourceProps(props || {}, getPageResourceFields())
|
|
3386
3386
|
);
|
|
3387
3387
|
return /* @__PURE__ */ jsx(
|
|
3388
3388
|
ComponentContext.Provider,
|