@amplifyup/sdk 0.1.63 → 0.1.65
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 +133 -88
- package/dist/AmplifyRenderer.d.mts +40 -4
- package/dist/AmplifyRenderer.d.ts +40 -4
- package/dist/AmplifyRenderer.js +198 -67
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +199 -68
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +146 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +146 -28
- package/dist/index.mjs.map +1 -1
- package/dist/{query-3AXnQgzO.d.ts → query-BLjZYjHJ.d.ts} +4 -3
- package/dist/{query-DIZjc7st.d.mts → query-DuRilU_n.d.mts} +4 -3
- package/dist/react.d.mts +19 -30
- package/dist/react.d.ts +19 -30
- package/dist/react.js +353 -311
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +350 -312
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +146 -28
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +146 -28
- package/dist/server.mjs.map +1 -1
- package/dist/{types-Db_eLrfU.d.mts → types-C32MgOiv.d.mts} +96 -1
- package/dist/{types-Db_eLrfU.d.ts → types-C32MgOiv.d.ts} +96 -1
- package/package.json +1 -1
- package/dist/AmplifyRenderer-Bwob7ICJ.d.ts +0 -93
- package/dist/AmplifyRenderer-TawbUIKZ.d.mts +0 -93
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as PageDataSnapshot, b as CDPAdapter, c as AmplifyUpConfig, d as EventProperties, e as AmplifyPageContextInput, f as AttachedPageEventContext, I as IdentifyInput, g as IdentifyTraits, h as ProfileFieldsInput, i as AmplifyUpTarget } from './types-
|
|
2
|
-
export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-
|
|
1
|
+
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as PageDataSnapshot, b as CDPAdapter, c as AmplifyUpConfig, d as EventProperties, e as AmplifyPageContextInput, f as AttachedPageEventContext, I as IdentifyInput, g as IdentifyTraits, h as ProfileFieldsInput, i as AmplifyUpTarget } from './types-C32MgOiv.mjs';
|
|
2
|
+
export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-C32MgOiv.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-DuRilU_n.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Storage utilities for instance ID and user ID
|
|
@@ -53,6 +53,11 @@ interface EdgeResolvedComponent {
|
|
|
53
53
|
instanceId: string;
|
|
54
54
|
componentId: string;
|
|
55
55
|
props: Record<string, unknown>;
|
|
56
|
+
/** Connection map from the snapshot — used to stamp list-row `ref`. */
|
|
57
|
+
resources?: Record<string, unknown>;
|
|
58
|
+
reads?: Record<string, {
|
|
59
|
+
resource: string;
|
|
60
|
+
}>;
|
|
56
61
|
children?: Record<string, EdgeResolvedComponent[]>;
|
|
57
62
|
appliedRules?: string[];
|
|
58
63
|
degraded?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as PageDataSnapshot, b as CDPAdapter, c as AmplifyUpConfig, d as EventProperties, e as AmplifyPageContextInput, f as AttachedPageEventContext, I as IdentifyInput, g as IdentifyTraits, h as ProfileFieldsInput, i as AmplifyUpTarget } from './types-
|
|
2
|
-
export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-
|
|
1
|
+
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as PageDataSnapshot, b as CDPAdapter, c as AmplifyUpConfig, d as EventProperties, e as AmplifyPageContextInput, f as AttachedPageEventContext, I as IdentifyInput, g as IdentifyTraits, h as ProfileFieldsInput, i as AmplifyUpTarget } from './types-C32MgOiv.js';
|
|
2
|
+
export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-C32MgOiv.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-BLjZYjHJ.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Storage utilities for instance ID and user ID
|
|
@@ -53,6 +53,11 @@ interface EdgeResolvedComponent {
|
|
|
53
53
|
instanceId: string;
|
|
54
54
|
componentId: string;
|
|
55
55
|
props: Record<string, unknown>;
|
|
56
|
+
/** Connection map from the snapshot — used to stamp list-row `ref`. */
|
|
57
|
+
resources?: Record<string, unknown>;
|
|
58
|
+
reads?: Record<string, {
|
|
59
|
+
resource: string;
|
|
60
|
+
}>;
|
|
56
61
|
children?: Record<string, EdgeResolvedComponent[]>;
|
|
57
62
|
appliedRules?: string[];
|
|
58
63
|
degraded?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -400,6 +400,16 @@ function isComposerPreview() {
|
|
|
400
400
|
|
|
401
401
|
// src/field-envelope.ts
|
|
402
402
|
var FIELDS_BRAND = Symbol("amplifyup.fields");
|
|
403
|
+
var IDENTIFIER_KEYS = /* @__PURE__ */ new Set([
|
|
404
|
+
"id",
|
|
405
|
+
"_id",
|
|
406
|
+
"slug",
|
|
407
|
+
"key",
|
|
408
|
+
"_key",
|
|
409
|
+
"docId",
|
|
410
|
+
"_type",
|
|
411
|
+
"type"
|
|
412
|
+
]);
|
|
403
413
|
function isBrandedFields(value) {
|
|
404
414
|
return !!value && typeof value === "object" && FIELDS_BRAND in value;
|
|
405
415
|
}
|
|
@@ -417,25 +427,79 @@ function isFieldEnvelope(value) {
|
|
|
417
427
|
const rec = value;
|
|
418
428
|
return typeof rec.name === "string" && "value" in rec && !("url" in rec);
|
|
419
429
|
}
|
|
420
|
-
function
|
|
421
|
-
|
|
422
|
-
return "url" in value;
|
|
430
|
+
function isPageResourceSentinel(value) {
|
|
431
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && typeof value.__amplifyupPageResource === "string";
|
|
423
432
|
}
|
|
424
|
-
function
|
|
433
|
+
function isPortableImageShape(value) {
|
|
425
434
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
435
|
+
if ("url" in value) return true;
|
|
426
436
|
const rec = value;
|
|
427
|
-
return
|
|
437
|
+
return rec._type === "image" || rec.asset != null;
|
|
428
438
|
}
|
|
429
|
-
function
|
|
439
|
+
function isIdentifierKey(key) {
|
|
440
|
+
return IDENTIFIER_KEYS.has(key);
|
|
441
|
+
}
|
|
442
|
+
function isRecordList(value) {
|
|
430
443
|
if (!Array.isArray(value) || value.length === 0) return false;
|
|
431
444
|
const sample = value.find((item) => item != null);
|
|
432
445
|
if (sample === void 0) return false;
|
|
433
446
|
if (typeof sample !== "object" || Array.isArray(sample)) return false;
|
|
434
447
|
if (isPortableImageShape(sample)) return false;
|
|
435
|
-
if (isEntryRefItem(sample)) return false;
|
|
436
448
|
if (sample.$$typeof) return false;
|
|
437
449
|
return true;
|
|
438
450
|
}
|
|
451
|
+
function isFieldRef(value) {
|
|
452
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
453
|
+
const rec = value;
|
|
454
|
+
return typeof rec.providerId === "string" && !!rec.providerId && typeof rec.entity === "string" && !!rec.entity && typeof rec.id === "string" && !!rec.id;
|
|
455
|
+
}
|
|
456
|
+
function isListOwner(value) {
|
|
457
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
458
|
+
const rec = value;
|
|
459
|
+
return typeof rec.providerId === "string" && !!rec.providerId && typeof rec.entity === "string" && !!rec.entity;
|
|
460
|
+
}
|
|
461
|
+
function listOwnerFromConnection(conn) {
|
|
462
|
+
if (!conn || typeof conn !== "object") return void 0;
|
|
463
|
+
if (conn.mode === "query") {
|
|
464
|
+
const providerId = String(conn.spec?.providerId || "").trim();
|
|
465
|
+
const entity = String(conn.spec?.entity || "").trim();
|
|
466
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
467
|
+
}
|
|
468
|
+
if (conn.mode === "item" || conn.mode === "items") {
|
|
469
|
+
const providerId = String(conn.providerId || "").trim();
|
|
470
|
+
const entity = String(conn.entity || "").trim();
|
|
471
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
472
|
+
}
|
|
473
|
+
return void 0;
|
|
474
|
+
}
|
|
475
|
+
function listOwnerFromSpec(spec) {
|
|
476
|
+
const providerId = String(spec?.providerId || "").trim();
|
|
477
|
+
const entity = String(spec?.entity || "").trim();
|
|
478
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
479
|
+
}
|
|
480
|
+
function isEnvelopeSources(value) {
|
|
481
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
482
|
+
const rec = value;
|
|
483
|
+
return rec.connections != null || rec.reads != null;
|
|
484
|
+
}
|
|
485
|
+
function normalizeEnvelopeSources(sources) {
|
|
486
|
+
if (!sources) return {};
|
|
487
|
+
if (isEnvelopeSources(sources) && !("mode" in sources)) {
|
|
488
|
+
return sources;
|
|
489
|
+
}
|
|
490
|
+
return { connections: sources };
|
|
491
|
+
}
|
|
492
|
+
function listOwnerForField(fieldName, props, sources) {
|
|
493
|
+
const { connections, reads } = normalizeEnvelopeSources(sources);
|
|
494
|
+
const resourceName = reads?.[fieldName]?.resource || fieldName;
|
|
495
|
+
const fromConn = listOwnerFromConnection(connections?.[resourceName]);
|
|
496
|
+
if (fromConn) return fromConn;
|
|
497
|
+
const paging = props?.[`${fieldName}Pagination`];
|
|
498
|
+
if (paging && typeof paging === "object" && !Array.isArray(paging)) {
|
|
499
|
+
return listOwnerFromSpec(paging.spec);
|
|
500
|
+
}
|
|
501
|
+
return void 0;
|
|
502
|
+
}
|
|
439
503
|
function joinPath(prefix, key) {
|
|
440
504
|
return prefix ? `${prefix}.${key}` : key;
|
|
441
505
|
}
|
|
@@ -443,61 +507,105 @@ function emptyValue(raw) {
|
|
|
443
507
|
if (raw === void 0) return null;
|
|
444
508
|
return raw;
|
|
445
509
|
}
|
|
446
|
-
function
|
|
510
|
+
function rowId(raw) {
|
|
511
|
+
const candidates = [raw.id, raw._id, raw.docId, raw.key, raw._key];
|
|
512
|
+
for (const c of candidates) {
|
|
513
|
+
if (typeof c === "string" && c.trim()) return c;
|
|
514
|
+
}
|
|
515
|
+
return "";
|
|
516
|
+
}
|
|
517
|
+
function withLeaf(envelope, scope) {
|
|
518
|
+
if (isFieldRef(scope?.ref)) envelope.ref = scope.ref;
|
|
519
|
+
else if (scope?.readOnly) envelope.readOnly = true;
|
|
520
|
+
return envelope;
|
|
521
|
+
}
|
|
522
|
+
function toFieldEnvelopes(source, prefix = "", scope) {
|
|
523
|
+
const ctx = isFieldRef(scope) ? { ref: scope } : scope || {};
|
|
447
524
|
const input = source && typeof source === "object" && !Array.isArray(source) ? source : {};
|
|
448
525
|
if (isBrandedFields(input)) {
|
|
449
526
|
return input;
|
|
450
527
|
}
|
|
451
528
|
const out = {};
|
|
452
529
|
for (const [key, raw] of Object.entries(input)) {
|
|
530
|
+
if (isIdentifierKey(key) && (typeof raw === "string" || raw == null)) {
|
|
531
|
+
out[key] = raw ?? "";
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
453
534
|
const path = joinPath(prefix, key);
|
|
535
|
+
if (isPageResourceSentinel(raw)) {
|
|
536
|
+
out[key] = withLeaf({ value: raw, name: path }, ctx);
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
454
539
|
if (isFieldEnvelope(raw)) {
|
|
455
540
|
const inner = raw.value;
|
|
456
|
-
if (
|
|
541
|
+
if (isRecordList(inner)) {
|
|
542
|
+
const owner = ctx.owners?.(key);
|
|
457
543
|
out[key] = {
|
|
458
|
-
value:
|
|
544
|
+
value: envelopeListRows(inner, owner),
|
|
459
545
|
name: raw.name || path
|
|
460
546
|
};
|
|
461
547
|
continue;
|
|
462
548
|
}
|
|
463
|
-
out[key] =
|
|
549
|
+
out[key] = withLeaf(
|
|
550
|
+
{ value: raw.value ?? null, name: raw.name || path },
|
|
551
|
+
raw.ref ? { ref: raw.ref } : ctx
|
|
552
|
+
);
|
|
464
553
|
continue;
|
|
465
554
|
}
|
|
466
|
-
if (
|
|
467
|
-
|
|
555
|
+
if (isRecordList(raw)) {
|
|
556
|
+
const owner = ctx.owners?.(key);
|
|
557
|
+
out[key] = { value: envelopeListRows(raw, owner), name: path };
|
|
468
558
|
continue;
|
|
469
559
|
}
|
|
470
560
|
if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !raw.$$typeof) {
|
|
471
|
-
out[key] = toFieldEnvelopes(raw, path);
|
|
561
|
+
out[key] = toFieldEnvelopes(raw, path, ctx);
|
|
472
562
|
continue;
|
|
473
563
|
}
|
|
474
|
-
out[key] = { value: emptyValue(raw), name: path };
|
|
564
|
+
out[key] = withLeaf({ value: emptyValue(raw), name: path }, ctx);
|
|
475
565
|
}
|
|
476
566
|
return brandFields(out);
|
|
477
567
|
}
|
|
478
|
-
function
|
|
479
|
-
return items.map((item
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
568
|
+
function envelopeListRows(items, owner) {
|
|
569
|
+
return items.map((item) => envelopeListRow(item, owner));
|
|
570
|
+
}
|
|
571
|
+
function envelopeListRow(item, owner) {
|
|
572
|
+
if (isBrandedFields(item) && typeof item.id === "string") {
|
|
573
|
+
return item;
|
|
574
|
+
}
|
|
575
|
+
const raw = item && typeof item === "object" && !Array.isArray(item) ? item : {};
|
|
576
|
+
const id = rowId(raw);
|
|
577
|
+
const ref = isListOwner(owner) && id ? { providerId: owner.providerId, entity: owner.entity, id } : void 0;
|
|
578
|
+
const fields = toFieldEnvelopes(raw, "", {
|
|
579
|
+
ref,
|
|
580
|
+
readOnly: !ref
|
|
486
581
|
});
|
|
582
|
+
const row = fields;
|
|
583
|
+
if (typeof row.id !== "string") {
|
|
584
|
+
row.id = id;
|
|
585
|
+
}
|
|
586
|
+
return row;
|
|
487
587
|
}
|
|
488
|
-
function attachFieldEnvelopes(props) {
|
|
588
|
+
function attachFieldEnvelopes(props, sources) {
|
|
489
589
|
const raw = props && typeof props === "object" ? { ...props } : {};
|
|
490
590
|
if (isBrandedFields(raw.fields)) return raw;
|
|
491
591
|
const { fields: existing, ...content } = raw;
|
|
492
592
|
const source = existing && typeof existing === "object" && !isFieldEnvelope(existing) ? existing : content;
|
|
493
|
-
return {
|
|
593
|
+
return {
|
|
594
|
+
...raw,
|
|
595
|
+
fields: toFieldEnvelopes(source, "", {
|
|
596
|
+
owners: (fieldName) => listOwnerForField(fieldName, source, sources)
|
|
597
|
+
})
|
|
598
|
+
};
|
|
494
599
|
}
|
|
495
600
|
function walkLayoutNodes(nodes) {
|
|
496
601
|
if (!Array.isArray(nodes)) return;
|
|
497
602
|
for (const node of nodes) {
|
|
498
603
|
if (!node || typeof node !== "object") continue;
|
|
499
604
|
const rec = node;
|
|
500
|
-
rec.props = attachFieldEnvelopes(rec.props
|
|
605
|
+
rec.props = attachFieldEnvelopes(rec.props, {
|
|
606
|
+
connections: rec.resources,
|
|
607
|
+
reads: rec.reads
|
|
608
|
+
});
|
|
501
609
|
for (const slot of rec.slots || []) {
|
|
502
610
|
walkLayoutNodes(slot.children);
|
|
503
611
|
}
|
|
@@ -764,7 +872,10 @@ async function fetchEdgeResolve(options) {
|
|
|
764
872
|
return envelopeResolvedPayload(body);
|
|
765
873
|
}
|
|
766
874
|
function envelopeResolvedComponent(node) {
|
|
767
|
-
node.props = attachFieldEnvelopes(node.props
|
|
875
|
+
node.props = attachFieldEnvelopes(node.props, {
|
|
876
|
+
connections: node.resources,
|
|
877
|
+
reads: node.reads
|
|
878
|
+
});
|
|
768
879
|
if (!node.children) return;
|
|
769
880
|
for (const kids of Object.values(node.children)) {
|
|
770
881
|
for (const child of kids || []) envelopeResolvedComponent(child);
|
|
@@ -1023,7 +1134,7 @@ async function fetchEdgeQuery(options) {
|
|
|
1023
1134
|
async function queryContent(options) {
|
|
1024
1135
|
const target = resolveAmplifyUpTarget({ configTarget: options.target });
|
|
1025
1136
|
const { edgeUrl } = resolveAmplifyUpUrls(target);
|
|
1026
|
-
|
|
1137
|
+
const raw = await fetchEdgeQuery({
|
|
1027
1138
|
edgeUrl,
|
|
1028
1139
|
trackingId: options.trackingId,
|
|
1029
1140
|
route: options.route,
|
|
@@ -1032,6 +1143,13 @@ async function queryContent(options) {
|
|
|
1032
1143
|
fetch: options.fetch,
|
|
1033
1144
|
signal: options.signal
|
|
1034
1145
|
});
|
|
1146
|
+
return {
|
|
1147
|
+
...raw,
|
|
1148
|
+
results: envelopeListRows(
|
|
1149
|
+
raw.results,
|
|
1150
|
+
listOwnerFromSpec(options.spec)
|
|
1151
|
+
)
|
|
1152
|
+
};
|
|
1035
1153
|
}
|
|
1036
1154
|
function nextPageSpec(pagination) {
|
|
1037
1155
|
return { ...pagination.spec, offset: pagination.nextOffset };
|