@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/index.mjs
CHANGED
|
@@ -451,14 +451,14 @@ function applyPageContext(input, opts) {
|
|
|
451
451
|
log.warn("AmplifyUp: pageContext needs resourceType and key");
|
|
452
452
|
return null;
|
|
453
453
|
}
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
454
|
+
const resource = opts.pageData?.resources?.[0];
|
|
455
|
+
if (resource && resource.type && resource.type !== input.resourceType) {
|
|
456
456
|
log.warn(
|
|
457
|
-
`AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page
|
|
457
|
+
`AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page resource "${resource.type}"`
|
|
458
458
|
);
|
|
459
459
|
return null;
|
|
460
460
|
}
|
|
461
|
-
const fieldDefs =
|
|
461
|
+
const fieldDefs = resource?.fields || [];
|
|
462
462
|
const defByKey = new Map(fieldDefs.map((f) => [f.key, f]));
|
|
463
463
|
const rawFields = input.fields && typeof input.fields === "object" ? input.fields : {};
|
|
464
464
|
const fields = {};
|
|
@@ -471,12 +471,16 @@ function applyPageContext(input, opts) {
|
|
|
471
471
|
log.warn(`AmplifyUp: unknown resource field "${k}" dropped`);
|
|
472
472
|
continue;
|
|
473
473
|
}
|
|
474
|
+
if (def.passThrough) {
|
|
475
|
+
if (v != null) fields[k] = v;
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
474
478
|
const coerced = coerceField(def, v, log);
|
|
475
479
|
if (coerced !== void 0) fields[k] = coerced;
|
|
476
480
|
}
|
|
477
481
|
}
|
|
478
482
|
const params = { ...opts.routeParams || {} };
|
|
479
|
-
const mapping =
|
|
483
|
+
const mapping = resource?.urlParamMapping;
|
|
480
484
|
let resourceKey = key;
|
|
481
485
|
if (mapping) {
|
|
482
486
|
const fromUrl = params[mapping.param];
|
|
@@ -494,7 +498,7 @@ function applyPageContext(input, opts) {
|
|
|
494
498
|
if (pf.value !== void 0) pageFields[pf.key] = pf.value;
|
|
495
499
|
continue;
|
|
496
500
|
}
|
|
497
|
-
if (pf.source === "mapped" && pf.
|
|
501
|
+
if (pf.source === "mapped" && pf.resource && pf.field) {
|
|
498
502
|
pageFields[pf.key] = fields[pf.field];
|
|
499
503
|
}
|
|
500
504
|
}
|
|
@@ -538,7 +542,7 @@ function mergeEventContext(properties, attached) {
|
|
|
538
542
|
...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
|
|
539
543
|
};
|
|
540
544
|
}
|
|
541
|
-
function
|
|
545
|
+
function setPageResourceFields(fields) {
|
|
542
546
|
}
|
|
543
547
|
|
|
544
548
|
// src/reservedRoutes.ts
|
|
@@ -1519,7 +1523,7 @@ var AmplifyUpSDK = class {
|
|
|
1519
1523
|
routeParams: this.resolvedRouteParams,
|
|
1520
1524
|
pageRoute: this.resolvedPageRoute
|
|
1521
1525
|
});
|
|
1522
|
-
|
|
1526
|
+
setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
|
|
1523
1527
|
}
|
|
1524
1528
|
getAttachedPageContext() {
|
|
1525
1529
|
return this.attachedPageContext;
|