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