@amplifyup/sdk 0.1.63 → 0.1.64
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 +183 -61
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +184 -62
- 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 +136 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +136 -27
- 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 +296 -302
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +293 -303
- 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 +136 -27
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +136 -27
- 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
|
}
|
|
@@ -421,21 +431,70 @@ function isPortableImageShape(value) {
|
|
|
421
431
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
422
432
|
return "url" in value;
|
|
423
433
|
}
|
|
424
|
-
function
|
|
425
|
-
|
|
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;
|
|
434
|
+
function isIdentifierKey(key) {
|
|
435
|
+
return IDENTIFIER_KEYS.has(key);
|
|
428
436
|
}
|
|
429
|
-
function
|
|
437
|
+
function isRecordList(value) {
|
|
430
438
|
if (!Array.isArray(value) || value.length === 0) return false;
|
|
431
439
|
const sample = value.find((item) => item != null);
|
|
432
440
|
if (sample === void 0) return false;
|
|
433
441
|
if (typeof sample !== "object" || Array.isArray(sample)) return false;
|
|
434
442
|
if (isPortableImageShape(sample)) return false;
|
|
435
|
-
if (isEntryRefItem(sample)) return false;
|
|
436
443
|
if (sample.$$typeof) return false;
|
|
437
444
|
return true;
|
|
438
445
|
}
|
|
446
|
+
function isFieldRef(value) {
|
|
447
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
448
|
+
const rec = value;
|
|
449
|
+
return typeof rec.providerId === "string" && !!rec.providerId && typeof rec.entity === "string" && !!rec.entity && typeof rec.id === "string" && !!rec.id;
|
|
450
|
+
}
|
|
451
|
+
function isListOwner(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;
|
|
455
|
+
}
|
|
456
|
+
function listOwnerFromConnection(conn) {
|
|
457
|
+
if (!conn || typeof conn !== "object") return void 0;
|
|
458
|
+
if (conn.mode === "query") {
|
|
459
|
+
const providerId = String(conn.spec?.providerId || "").trim();
|
|
460
|
+
const entity = String(conn.spec?.entity || "").trim();
|
|
461
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
462
|
+
}
|
|
463
|
+
if (conn.mode === "item" || conn.mode === "items") {
|
|
464
|
+
const providerId = String(conn.providerId || "").trim();
|
|
465
|
+
const entity = String(conn.entity || "").trim();
|
|
466
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
467
|
+
}
|
|
468
|
+
return void 0;
|
|
469
|
+
}
|
|
470
|
+
function listOwnerFromSpec(spec) {
|
|
471
|
+
const providerId = String(spec?.providerId || "").trim();
|
|
472
|
+
const entity = String(spec?.entity || "").trim();
|
|
473
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
474
|
+
}
|
|
475
|
+
function isEnvelopeSources(value) {
|
|
476
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
477
|
+
const rec = value;
|
|
478
|
+
return rec.connections != null || rec.reads != null;
|
|
479
|
+
}
|
|
480
|
+
function normalizeEnvelopeSources(sources) {
|
|
481
|
+
if (!sources) return {};
|
|
482
|
+
if (isEnvelopeSources(sources) && !("mode" in sources)) {
|
|
483
|
+
return sources;
|
|
484
|
+
}
|
|
485
|
+
return { connections: sources };
|
|
486
|
+
}
|
|
487
|
+
function listOwnerForField(fieldName, props, sources) {
|
|
488
|
+
const { connections, reads } = normalizeEnvelopeSources(sources);
|
|
489
|
+
const resourceName = reads?.[fieldName]?.resource || fieldName;
|
|
490
|
+
const fromConn = listOwnerFromConnection(connections?.[resourceName]);
|
|
491
|
+
if (fromConn) return fromConn;
|
|
492
|
+
const paging = props?.[`${fieldName}Pagination`];
|
|
493
|
+
if (paging && typeof paging === "object" && !Array.isArray(paging)) {
|
|
494
|
+
return listOwnerFromSpec(paging.spec);
|
|
495
|
+
}
|
|
496
|
+
return void 0;
|
|
497
|
+
}
|
|
439
498
|
function joinPath(prefix, key) {
|
|
440
499
|
return prefix ? `${prefix}.${key}` : key;
|
|
441
500
|
}
|
|
@@ -443,61 +502,101 @@ function emptyValue(raw) {
|
|
|
443
502
|
if (raw === void 0) return null;
|
|
444
503
|
return raw;
|
|
445
504
|
}
|
|
446
|
-
function
|
|
505
|
+
function rowId(raw) {
|
|
506
|
+
const candidates = [raw.id, raw._id, raw.docId, raw.key, raw._key];
|
|
507
|
+
for (const c of candidates) {
|
|
508
|
+
if (typeof c === "string" && c.trim()) return c;
|
|
509
|
+
}
|
|
510
|
+
return "";
|
|
511
|
+
}
|
|
512
|
+
function withLeaf(envelope, scope) {
|
|
513
|
+
if (isFieldRef(scope?.ref)) envelope.ref = scope.ref;
|
|
514
|
+
else if (scope?.readOnly) envelope.readOnly = true;
|
|
515
|
+
return envelope;
|
|
516
|
+
}
|
|
517
|
+
function toFieldEnvelopes(source, prefix = "", scope) {
|
|
518
|
+
const ctx = isFieldRef(scope) ? { ref: scope } : scope || {};
|
|
447
519
|
const input = source && typeof source === "object" && !Array.isArray(source) ? source : {};
|
|
448
520
|
if (isBrandedFields(input)) {
|
|
449
521
|
return input;
|
|
450
522
|
}
|
|
451
523
|
const out = {};
|
|
452
524
|
for (const [key, raw] of Object.entries(input)) {
|
|
525
|
+
if (isIdentifierKey(key) && (typeof raw === "string" || raw == null)) {
|
|
526
|
+
out[key] = raw ?? "";
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
453
529
|
const path = joinPath(prefix, key);
|
|
454
530
|
if (isFieldEnvelope(raw)) {
|
|
455
531
|
const inner = raw.value;
|
|
456
|
-
if (
|
|
532
|
+
if (isRecordList(inner)) {
|
|
533
|
+
const owner = ctx.owners?.(key);
|
|
457
534
|
out[key] = {
|
|
458
|
-
value:
|
|
535
|
+
value: envelopeListRows(inner, owner),
|
|
459
536
|
name: raw.name || path
|
|
460
537
|
};
|
|
461
538
|
continue;
|
|
462
539
|
}
|
|
463
|
-
out[key] =
|
|
540
|
+
out[key] = withLeaf(
|
|
541
|
+
{ value: raw.value ?? null, name: raw.name || path },
|
|
542
|
+
raw.ref ? { ref: raw.ref } : ctx
|
|
543
|
+
);
|
|
464
544
|
continue;
|
|
465
545
|
}
|
|
466
|
-
if (
|
|
467
|
-
|
|
546
|
+
if (isRecordList(raw)) {
|
|
547
|
+
const owner = ctx.owners?.(key);
|
|
548
|
+
out[key] = { value: envelopeListRows(raw, owner), name: path };
|
|
468
549
|
continue;
|
|
469
550
|
}
|
|
470
551
|
if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !raw.$$typeof) {
|
|
471
|
-
out[key] = toFieldEnvelopes(raw, path);
|
|
552
|
+
out[key] = toFieldEnvelopes(raw, path, ctx);
|
|
472
553
|
continue;
|
|
473
554
|
}
|
|
474
|
-
out[key] = { value: emptyValue(raw), name: path };
|
|
555
|
+
out[key] = withLeaf({ value: emptyValue(raw), name: path }, ctx);
|
|
475
556
|
}
|
|
476
557
|
return brandFields(out);
|
|
477
558
|
}
|
|
478
|
-
function
|
|
479
|
-
return items.map((item
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
559
|
+
function envelopeListRows(items, owner) {
|
|
560
|
+
return items.map((item) => envelopeListRow(item, owner));
|
|
561
|
+
}
|
|
562
|
+
function envelopeListRow(item, owner) {
|
|
563
|
+
if (isBrandedFields(item) && typeof item.id === "string") {
|
|
564
|
+
return item;
|
|
565
|
+
}
|
|
566
|
+
const raw = item && typeof item === "object" && !Array.isArray(item) ? item : {};
|
|
567
|
+
const id = rowId(raw);
|
|
568
|
+
const ref = isListOwner(owner) && id ? { providerId: owner.providerId, entity: owner.entity, id } : void 0;
|
|
569
|
+
const fields = toFieldEnvelopes(raw, "", {
|
|
570
|
+
ref,
|
|
571
|
+
readOnly: !ref
|
|
486
572
|
});
|
|
573
|
+
const row = fields;
|
|
574
|
+
if (typeof row.id !== "string") {
|
|
575
|
+
row.id = id;
|
|
576
|
+
}
|
|
577
|
+
return row;
|
|
487
578
|
}
|
|
488
|
-
function attachFieldEnvelopes(props) {
|
|
579
|
+
function attachFieldEnvelopes(props, sources) {
|
|
489
580
|
const raw = props && typeof props === "object" ? { ...props } : {};
|
|
490
581
|
if (isBrandedFields(raw.fields)) return raw;
|
|
491
582
|
const { fields: existing, ...content } = raw;
|
|
492
583
|
const source = existing && typeof existing === "object" && !isFieldEnvelope(existing) ? existing : content;
|
|
493
|
-
return {
|
|
584
|
+
return {
|
|
585
|
+
...raw,
|
|
586
|
+
fields: toFieldEnvelopes(source, "", {
|
|
587
|
+
owners: (fieldName) => listOwnerForField(fieldName, source, sources)
|
|
588
|
+
})
|
|
589
|
+
};
|
|
494
590
|
}
|
|
495
591
|
function walkLayoutNodes(nodes) {
|
|
496
592
|
if (!Array.isArray(nodes)) return;
|
|
497
593
|
for (const node of nodes) {
|
|
498
594
|
if (!node || typeof node !== "object") continue;
|
|
499
595
|
const rec = node;
|
|
500
|
-
rec.props = attachFieldEnvelopes(rec.props
|
|
596
|
+
rec.props = attachFieldEnvelopes(rec.props, {
|
|
597
|
+
connections: rec.resources,
|
|
598
|
+
reads: rec.reads
|
|
599
|
+
});
|
|
501
600
|
for (const slot of rec.slots || []) {
|
|
502
601
|
walkLayoutNodes(slot.children);
|
|
503
602
|
}
|
|
@@ -764,7 +863,10 @@ async function fetchEdgeResolve(options) {
|
|
|
764
863
|
return envelopeResolvedPayload(body);
|
|
765
864
|
}
|
|
766
865
|
function envelopeResolvedComponent(node) {
|
|
767
|
-
node.props = attachFieldEnvelopes(node.props
|
|
866
|
+
node.props = attachFieldEnvelopes(node.props, {
|
|
867
|
+
connections: node.resources,
|
|
868
|
+
reads: node.reads
|
|
869
|
+
});
|
|
768
870
|
if (!node.children) return;
|
|
769
871
|
for (const kids of Object.values(node.children)) {
|
|
770
872
|
for (const child of kids || []) envelopeResolvedComponent(child);
|
|
@@ -1023,7 +1125,7 @@ async function fetchEdgeQuery(options) {
|
|
|
1023
1125
|
async function queryContent(options) {
|
|
1024
1126
|
const target = resolveAmplifyUpTarget({ configTarget: options.target });
|
|
1025
1127
|
const { edgeUrl } = resolveAmplifyUpUrls(target);
|
|
1026
|
-
|
|
1128
|
+
const raw = await fetchEdgeQuery({
|
|
1027
1129
|
edgeUrl,
|
|
1028
1130
|
trackingId: options.trackingId,
|
|
1029
1131
|
route: options.route,
|
|
@@ -1032,6 +1134,13 @@ async function queryContent(options) {
|
|
|
1032
1134
|
fetch: options.fetch,
|
|
1033
1135
|
signal: options.signal
|
|
1034
1136
|
});
|
|
1137
|
+
return {
|
|
1138
|
+
...raw,
|
|
1139
|
+
results: envelopeListRows(
|
|
1140
|
+
raw.results,
|
|
1141
|
+
listOwnerFromSpec(options.spec)
|
|
1142
|
+
)
|
|
1143
|
+
};
|
|
1035
1144
|
}
|
|
1036
1145
|
function nextPageSpec(pagination) {
|
|
1037
1146
|
return { ...pagination.spec, offset: pagination.nextOffset };
|