@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/AmplifyRenderer.js
CHANGED
|
@@ -464,14 +464,14 @@ function applyPageContext(input, opts) {
|
|
|
464
464
|
log.warn("AmplifyUp: pageContext needs resourceType and key");
|
|
465
465
|
return null;
|
|
466
466
|
}
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
467
|
+
const resource = opts.pageData?.resources?.[0];
|
|
468
|
+
if (resource && resource.type && resource.type !== input.resourceType) {
|
|
469
469
|
log.warn(
|
|
470
|
-
`AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page
|
|
470
|
+
`AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page resource "${resource.type}"`
|
|
471
471
|
);
|
|
472
472
|
return null;
|
|
473
473
|
}
|
|
474
|
-
const fieldDefs =
|
|
474
|
+
const fieldDefs = resource?.fields || [];
|
|
475
475
|
const defByKey = new Map(fieldDefs.map((f) => [f.key, f]));
|
|
476
476
|
const rawFields = input.fields && typeof input.fields === "object" ? input.fields : {};
|
|
477
477
|
const fields = {};
|
|
@@ -484,12 +484,16 @@ function applyPageContext(input, opts) {
|
|
|
484
484
|
log.warn(`AmplifyUp: unknown resource field "${k}" dropped`);
|
|
485
485
|
continue;
|
|
486
486
|
}
|
|
487
|
+
if (def.passThrough) {
|
|
488
|
+
if (v != null) fields[k] = v;
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
487
491
|
const coerced = coerceField(def, v, log);
|
|
488
492
|
if (coerced !== void 0) fields[k] = coerced;
|
|
489
493
|
}
|
|
490
494
|
}
|
|
491
495
|
const params = { ...opts.routeParams || {} };
|
|
492
|
-
const mapping =
|
|
496
|
+
const mapping = resource?.urlParamMapping;
|
|
493
497
|
let resourceKey = key;
|
|
494
498
|
if (mapping) {
|
|
495
499
|
const fromUrl = params[mapping.param];
|
|
@@ -507,7 +511,7 @@ function applyPageContext(input, opts) {
|
|
|
507
511
|
if (pf.value !== void 0) pageFields[pf.key] = pf.value;
|
|
508
512
|
continue;
|
|
509
513
|
}
|
|
510
|
-
if (pf.source === "mapped" && pf.
|
|
514
|
+
if (pf.source === "mapped" && pf.resource && pf.field) {
|
|
511
515
|
pageFields[pf.key] = fields[pf.field];
|
|
512
516
|
}
|
|
513
517
|
}
|
|
@@ -551,7 +555,7 @@ function mergeEventContext(properties, attached) {
|
|
|
551
555
|
...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
|
|
552
556
|
};
|
|
553
557
|
}
|
|
554
|
-
function
|
|
558
|
+
function setPageResourceFields(fields) {
|
|
555
559
|
}
|
|
556
560
|
|
|
557
561
|
// src/index.ts
|
|
@@ -1184,7 +1188,7 @@ var AmplifyUpSDK = class {
|
|
|
1184
1188
|
routeParams: this.resolvedRouteParams,
|
|
1185
1189
|
pageRoute: this.resolvedPageRoute
|
|
1186
1190
|
});
|
|
1187
|
-
|
|
1191
|
+
setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
|
|
1188
1192
|
}
|
|
1189
1193
|
getAttachedPageContext() {
|
|
1190
1194
|
return this.attachedPageContext;
|