@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.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { P as PageConfig, c as AmplifyUpConfig, e as AmplifyPageContextInput, C as ContentSource, A as AmplifyContentMeta } from './types-
|
|
3
|
-
export { Z as ZoneConfig } from './types-
|
|
2
|
+
import { P as PageConfig, c as AmplifyUpConfig, e as AmplifyPageContextInput, C as ContentSource, A as AmplifyContentMeta } from './types-DpTzUg1C.mjs';
|
|
3
|
+
export { Z as ZoneConfig } from './types-DpTzUg1C.mjs';
|
|
4
4
|
import React, { ReactNode } from 'react';
|
|
5
5
|
export { AmplifyRenderer } from './AmplifyRenderer.mjs';
|
|
6
|
-
export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-
|
|
6
|
+
export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-CWFb7rSm.mjs';
|
|
7
7
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
|
|
8
8
|
export { fetchPageConfigServer } from './server.mjs';
|
|
9
9
|
import './reservedRoutes-aGgViBDM.mjs';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { P as PageConfig, c as AmplifyUpConfig, e as AmplifyPageContextInput, C as ContentSource, A as AmplifyContentMeta } from './types-
|
|
3
|
-
export { Z as ZoneConfig } from './types-
|
|
2
|
+
import { P as PageConfig, c as AmplifyUpConfig, e as AmplifyPageContextInput, C as ContentSource, A as AmplifyContentMeta } from './types-DpTzUg1C.js';
|
|
3
|
+
export { Z as ZoneConfig } from './types-DpTzUg1C.js';
|
|
4
4
|
import React, { ReactNode } from 'react';
|
|
5
5
|
export { AmplifyRenderer } from './AmplifyRenderer.js';
|
|
6
|
-
export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-
|
|
6
|
+
export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-L7zSmLFX.js';
|
|
7
7
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.js';
|
|
8
8
|
export { fetchPageConfigServer } from './server.js';
|
|
9
9
|
import './reservedRoutes-aGgViBDM.js';
|
package/dist/react.js
CHANGED
|
@@ -481,14 +481,14 @@ function applyPageContext(input, opts) {
|
|
|
481
481
|
log.warn("AmplifyUp: pageContext needs resourceType and key");
|
|
482
482
|
return null;
|
|
483
483
|
}
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
484
|
+
const resource = opts.pageData?.resources?.[0];
|
|
485
|
+
if (resource && resource.type && resource.type !== input.resourceType) {
|
|
486
486
|
log.warn(
|
|
487
|
-
`AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page
|
|
487
|
+
`AmplifyUp: pageContext resourceType "${input.resourceType}" does not match page resource "${resource.type}"`
|
|
488
488
|
);
|
|
489
489
|
return null;
|
|
490
490
|
}
|
|
491
|
-
const fieldDefs =
|
|
491
|
+
const fieldDefs = resource?.fields || [];
|
|
492
492
|
const defByKey = new Map(fieldDefs.map((f) => [f.key, f]));
|
|
493
493
|
const rawFields = input.fields && typeof input.fields === "object" ? input.fields : {};
|
|
494
494
|
const fields = {};
|
|
@@ -501,12 +501,16 @@ function applyPageContext(input, opts) {
|
|
|
501
501
|
log.warn(`AmplifyUp: unknown resource field "${k}" dropped`);
|
|
502
502
|
continue;
|
|
503
503
|
}
|
|
504
|
+
if (def.passThrough) {
|
|
505
|
+
if (v != null) fields[k] = v;
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
504
508
|
const coerced = coerceField(def, v, log);
|
|
505
509
|
if (coerced !== void 0) fields[k] = coerced;
|
|
506
510
|
}
|
|
507
511
|
}
|
|
508
512
|
const params = { ...opts.routeParams || {} };
|
|
509
|
-
const mapping =
|
|
513
|
+
const mapping = resource?.urlParamMapping;
|
|
510
514
|
let resourceKey = key;
|
|
511
515
|
if (mapping) {
|
|
512
516
|
const fromUrl = params[mapping.param];
|
|
@@ -524,7 +528,7 @@ function applyPageContext(input, opts) {
|
|
|
524
528
|
if (pf.value !== void 0) pageFields[pf.key] = pf.value;
|
|
525
529
|
continue;
|
|
526
530
|
}
|
|
527
|
-
if (pf.source === "mapped" && pf.
|
|
531
|
+
if (pf.source === "mapped" && pf.resource && pf.field) {
|
|
528
532
|
pageFields[pf.key] = fields[pf.field];
|
|
529
533
|
}
|
|
530
534
|
}
|
|
@@ -568,9 +572,9 @@ function mergeEventContext(properties, attached) {
|
|
|
568
572
|
...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
|
|
569
573
|
};
|
|
570
574
|
}
|
|
571
|
-
var
|
|
572
|
-
function
|
|
573
|
-
return !!value && typeof value === "object" && !Array.isArray(value) && typeof value[
|
|
575
|
+
var PAGE_RESOURCE_MARKER = "__amplifyupPageResource";
|
|
576
|
+
function isPageResourceSentinel(value) {
|
|
577
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && typeof value[PAGE_RESOURCE_MARKER] === "string";
|
|
574
578
|
}
|
|
575
579
|
function getByDotPath(source, path) {
|
|
576
580
|
if (!path) return source;
|
|
@@ -584,30 +588,30 @@ function getByDotPath(source, path) {
|
|
|
584
588
|
}
|
|
585
589
|
return cur;
|
|
586
590
|
}
|
|
587
|
-
function
|
|
588
|
-
if (!
|
|
591
|
+
function hydratePageResourceValue(value, fields) {
|
|
592
|
+
if (!isPageResourceSentinel(value)) return value;
|
|
589
593
|
if (!fields) return null;
|
|
590
594
|
if (value.path) return getByDotPath(fields, value.path) ?? null;
|
|
591
595
|
return fields;
|
|
592
596
|
}
|
|
593
|
-
function
|
|
597
|
+
function hydratePageResourceProps(props, fields) {
|
|
594
598
|
const source = props && typeof props === "object" ? props : {};
|
|
595
599
|
const out = { ...source };
|
|
596
600
|
for (const [key, val] of Object.entries(out)) {
|
|
597
|
-
if (
|
|
598
|
-
out[key] =
|
|
601
|
+
if (isPageResourceSentinel(val)) {
|
|
602
|
+
out[key] = hydratePageResourceValue(val, fields);
|
|
599
603
|
}
|
|
600
604
|
}
|
|
601
605
|
return out;
|
|
602
606
|
}
|
|
603
607
|
|
|
604
|
-
// src/page-
|
|
605
|
-
var
|
|
606
|
-
function
|
|
607
|
-
|
|
608
|
+
// src/page-resource-runtime.ts
|
|
609
|
+
var pageResourceFields = null;
|
|
610
|
+
function setPageResourceFields(fields) {
|
|
611
|
+
pageResourceFields = fields && typeof fields === "object" ? fields : null;
|
|
608
612
|
}
|
|
609
|
-
function
|
|
610
|
-
return
|
|
613
|
+
function getPageResourceFields() {
|
|
614
|
+
return pageResourceFields;
|
|
611
615
|
}
|
|
612
616
|
|
|
613
617
|
// src/edge/normalizeRoute.ts
|
|
@@ -1575,7 +1579,7 @@ var AmplifyUpSDK = class {
|
|
|
1575
1579
|
this.resolvedPageData,
|
|
1576
1580
|
this.resolvedPageRoute
|
|
1577
1581
|
);
|
|
1578
|
-
|
|
1582
|
+
setPageResourceFields(null);
|
|
1579
1583
|
return;
|
|
1580
1584
|
}
|
|
1581
1585
|
this.attachedPageContext = applyPageContext(this.pendingPageContext, {
|
|
@@ -1583,7 +1587,7 @@ var AmplifyUpSDK = class {
|
|
|
1583
1587
|
routeParams: this.resolvedRouteParams,
|
|
1584
1588
|
pageRoute: this.resolvedPageRoute
|
|
1585
1589
|
});
|
|
1586
|
-
|
|
1590
|
+
setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
|
|
1587
1591
|
}
|
|
1588
1592
|
getAttachedPageContext() {
|
|
1589
1593
|
return this.attachedPageContext;
|
|
@@ -3388,7 +3392,7 @@ function ComponentContextProvider({
|
|
|
3388
3392
|
}) {
|
|
3389
3393
|
const liveProps = useLiveComposerProps(
|
|
3390
3394
|
layoutNodeId,
|
|
3391
|
-
|
|
3395
|
+
hydratePageResourceProps(props || {}, getPageResourceFields())
|
|
3392
3396
|
);
|
|
3393
3397
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3394
3398
|
ComponentContext.Provider,
|