@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/AmplifyRenderer.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +12 -8
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +12 -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 +12 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -8
- package/dist/index.mjs.map +1 -1
- package/dist/{query-DhyG93JN.d.mts → query-CWFb7rSm.d.mts} +1 -1
- package/dist/{query-CMiGo_Kt.d.ts → query-L7zSmLFX.d.ts} +1 -1
- package/dist/react.d.mts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +27 -23
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +27 -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-DpTzUg1C.d.mts} +3 -2
- package/dist/{types-BjlTE_cW.d.ts → types-DpTzUg1C.d.ts} +3 -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 = {};
|
|
@@ -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 =
|
|
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.
|
|
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
|
|
566
|
-
function
|
|
567
|
-
return !!value && typeof value === "object" && !Array.isArray(value) && typeof value[
|
|
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
|
|
582
|
-
if (!
|
|
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
|
|
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 (
|
|
592
|
-
out[key] =
|
|
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-
|
|
599
|
-
var
|
|
600
|
-
function
|
|
601
|
-
|
|
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
|
|
604
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3389
|
+
hydratePageResourceProps(props || {}, getPageResourceFields())
|
|
3386
3390
|
);
|
|
3387
3391
|
return /* @__PURE__ */ jsx(
|
|
3388
3392
|
ComponentContext.Provider,
|