@amplifyup/sdk 0.1.61 → 0.1.63
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/README.md +404 -10
- package/dist/AmplifyRenderer-Bwob7ICJ.d.ts +93 -0
- package/dist/AmplifyRenderer-TawbUIKZ.d.mts +93 -0
- package/dist/AmplifyRenderer.d.mts +4 -40
- package/dist/AmplifyRenderer.d.ts +4 -40
- package/dist/AmplifyRenderer.js +327 -30
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +328 -31
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +135 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{query-BqApXxQi.d.ts → query-3AXnQgzO.d.ts} +1 -0
- package/dist/{query-DaJlqU-Z.d.mts → query-DIZjc7st.d.mts} +1 -0
- package/dist/react.d.mts +74 -42
- package/dist/react.d.ts +74 -42
- package/dist/react.js +1613 -1253
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1690 -1334
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +134 -2
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +134 -2
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as Even
|
|
|
2
2
|
export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-Db_eLrfU.mjs';
|
|
3
3
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
|
|
4
4
|
export { A as AMPLIFYUP_EDITOR_ROUTE, i as isAmplifyUpEditorRoute } from './reservedRoutes-aGgViBDM.mjs';
|
|
5
|
-
export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, 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, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-
|
|
5
|
+
export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, 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, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-DIZjc7st.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Storage utilities for instance ID and user ID
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as Even
|
|
|
2
2
|
export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-Db_eLrfU.js';
|
|
3
3
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.js';
|
|
4
4
|
export { A as AMPLIFYUP_EDITOR_ROUTE, i as isAmplifyUpEditorRoute } from './reservedRoutes-aGgViBDM.js';
|
|
5
|
-
export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, 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, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-
|
|
5
|
+
export { g as FetchEdgeQueryOptions, F as FetchEdgeSelectOptions, 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, c as fetchEdgeQuery, f as fetchEdgeSelect, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-3AXnQgzO.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Storage utilities for instance ID and user ID
|
package/dist/index.js
CHANGED
|
@@ -398,6 +398,118 @@ function isComposerPreview() {
|
|
|
398
398
|
return false;
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
+
// src/field-envelope.ts
|
|
402
|
+
var FIELDS_BRAND = Symbol("amplifyup.fields");
|
|
403
|
+
function isBrandedFields(value) {
|
|
404
|
+
return !!value && typeof value === "object" && FIELDS_BRAND in value;
|
|
405
|
+
}
|
|
406
|
+
function brandFields(bag) {
|
|
407
|
+
if (isBrandedFields(bag)) return bag;
|
|
408
|
+
Object.defineProperty(bag, FIELDS_BRAND, {
|
|
409
|
+
value: true,
|
|
410
|
+
enumerable: false,
|
|
411
|
+
configurable: false
|
|
412
|
+
});
|
|
413
|
+
return bag;
|
|
414
|
+
}
|
|
415
|
+
function isFieldEnvelope(value) {
|
|
416
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
417
|
+
const rec = value;
|
|
418
|
+
return typeof rec.name === "string" && "value" in rec && !("url" in rec);
|
|
419
|
+
}
|
|
420
|
+
function isPortableImageShape(value) {
|
|
421
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
422
|
+
return "url" in value;
|
|
423
|
+
}
|
|
424
|
+
function isEntryRefItem(value) {
|
|
425
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
426
|
+
const rec = value;
|
|
427
|
+
return typeof rec.id === "string" && rec.id.trim().length > 0 || typeof rec._id === "string" && rec._id.trim().length > 0 || typeof rec.docId === "string" && rec.docId.trim().length > 0;
|
|
428
|
+
}
|
|
429
|
+
function isRepeaterArray(value) {
|
|
430
|
+
if (!Array.isArray(value) || value.length === 0) return false;
|
|
431
|
+
const sample = value.find((item) => item != null);
|
|
432
|
+
if (sample === void 0) return false;
|
|
433
|
+
if (typeof sample !== "object" || Array.isArray(sample)) return false;
|
|
434
|
+
if (isPortableImageShape(sample)) return false;
|
|
435
|
+
if (isEntryRefItem(sample)) return false;
|
|
436
|
+
if (sample.$$typeof) return false;
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
function joinPath(prefix, key) {
|
|
440
|
+
return prefix ? `${prefix}.${key}` : key;
|
|
441
|
+
}
|
|
442
|
+
function emptyValue(raw) {
|
|
443
|
+
if (raw === void 0) return null;
|
|
444
|
+
return raw;
|
|
445
|
+
}
|
|
446
|
+
function toFieldEnvelopes(source, prefix = "") {
|
|
447
|
+
const input = source && typeof source === "object" && !Array.isArray(source) ? source : {};
|
|
448
|
+
if (isBrandedFields(input)) {
|
|
449
|
+
return input;
|
|
450
|
+
}
|
|
451
|
+
const out = {};
|
|
452
|
+
for (const [key, raw] of Object.entries(input)) {
|
|
453
|
+
const path = joinPath(prefix, key);
|
|
454
|
+
if (isFieldEnvelope(raw)) {
|
|
455
|
+
const inner = raw.value;
|
|
456
|
+
if (isRepeaterArray(inner)) {
|
|
457
|
+
out[key] = {
|
|
458
|
+
value: envelopeRepeaterItems(inner, raw.name || path),
|
|
459
|
+
name: raw.name || path
|
|
460
|
+
};
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
out[key] = { value: raw.value ?? null, name: raw.name || path };
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (isRepeaterArray(raw)) {
|
|
467
|
+
out[key] = { value: envelopeRepeaterItems(raw, path), name: path };
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !raw.$$typeof) {
|
|
471
|
+
out[key] = toFieldEnvelopes(raw, path);
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
out[key] = { value: emptyValue(raw), name: path };
|
|
475
|
+
}
|
|
476
|
+
return brandFields(out);
|
|
477
|
+
}
|
|
478
|
+
function envelopeRepeaterItems(items, prefix) {
|
|
479
|
+
return items.map((item, i) => {
|
|
480
|
+
const path = joinPath(prefix, String(i));
|
|
481
|
+
if (isBrandedFields(item)) return item;
|
|
482
|
+
if (item && typeof item === "object" && !Array.isArray(item)) {
|
|
483
|
+
return toFieldEnvelopes(item, path);
|
|
484
|
+
}
|
|
485
|
+
return toFieldEnvelopes({}, path);
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
function attachFieldEnvelopes(props) {
|
|
489
|
+
const raw = props && typeof props === "object" ? { ...props } : {};
|
|
490
|
+
if (isBrandedFields(raw.fields)) return raw;
|
|
491
|
+
const { fields: existing, ...content } = raw;
|
|
492
|
+
const source = existing && typeof existing === "object" && !isFieldEnvelope(existing) ? existing : content;
|
|
493
|
+
return { ...raw, fields: toFieldEnvelopes(source) };
|
|
494
|
+
}
|
|
495
|
+
function walkLayoutNodes(nodes) {
|
|
496
|
+
if (!Array.isArray(nodes)) return;
|
|
497
|
+
for (const node of nodes) {
|
|
498
|
+
if (!node || typeof node !== "object") continue;
|
|
499
|
+
const rec = node;
|
|
500
|
+
rec.props = attachFieldEnvelopes(rec.props);
|
|
501
|
+
for (const slot of rec.slots || []) {
|
|
502
|
+
walkLayoutNodes(slot.children);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function envelopePageConfig(page2) {
|
|
507
|
+
if (!page2 || typeof page2 !== "object") return page2 ?? null;
|
|
508
|
+
const tree = page2.layoutTree;
|
|
509
|
+
if (Array.isArray(tree)) walkLayoutNodes(tree);
|
|
510
|
+
return page2;
|
|
511
|
+
}
|
|
512
|
+
|
|
401
513
|
// src/page-context.ts
|
|
402
514
|
var defaultLog = {
|
|
403
515
|
warn: (...args) => {
|
|
@@ -649,7 +761,25 @@ async function fetchEdgeResolve(options) {
|
|
|
649
761
|
body
|
|
650
762
|
);
|
|
651
763
|
}
|
|
652
|
-
return body;
|
|
764
|
+
return envelopeResolvedPayload(body);
|
|
765
|
+
}
|
|
766
|
+
function envelopeResolvedComponent(node) {
|
|
767
|
+
node.props = attachFieldEnvelopes(node.props);
|
|
768
|
+
if (!node.children) return;
|
|
769
|
+
for (const kids of Object.values(node.children)) {
|
|
770
|
+
for (const child of kids || []) envelopeResolvedComponent(child);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
function envelopeResolvedPayload(payload) {
|
|
774
|
+
if (payload.tree) {
|
|
775
|
+
for (const node of payload.tree) envelopeResolvedComponent(node);
|
|
776
|
+
}
|
|
777
|
+
if (payload.zones) {
|
|
778
|
+
for (const roots of Object.values(payload.zones)) {
|
|
779
|
+
for (const node of roots || []) envelopeResolvedComponent(node);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return payload;
|
|
653
783
|
}
|
|
654
784
|
|
|
655
785
|
// src/edge/mapResolvedToPageConfig.ts
|
|
@@ -709,7 +839,9 @@ async function fetchContent(options) {
|
|
|
709
839
|
const preview = options.preview ?? (typeof window !== "undefined" ? isComposerPreview() : false);
|
|
710
840
|
if (preview) {
|
|
711
841
|
try {
|
|
712
|
-
const page2 =
|
|
842
|
+
const page2 = envelopePageConfig(
|
|
843
|
+
await options.fetchOrchestratorPage(options.route, true)
|
|
844
|
+
);
|
|
713
845
|
return {
|
|
714
846
|
pageConfig: page2,
|
|
715
847
|
source: "orchestrator",
|
|
@@ -1979,7 +2111,7 @@ Available Console Commands:
|
|
|
1979
2111
|
this.refreshEventTracking();
|
|
1980
2112
|
}, 800);
|
|
1981
2113
|
}
|
|
1982
|
-
return pageConfig;
|
|
2114
|
+
return envelopePageConfig(pageConfig);
|
|
1983
2115
|
}
|
|
1984
2116
|
/**
|
|
1985
2117
|
* Set up view-level event tracking based on configuration
|