@amplifyup/sdk 0.1.62 → 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 +446 -12
- package/dist/AmplifyRenderer.d.mts +40 -4
- package/dist/AmplifyRenderer.d.ts +40 -4
- package/dist/AmplifyRenderer.js +219 -27
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +220 -28
- 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 +155 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +155 -9
- 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 +44 -21
- package/dist/react.d.ts +44 -21
- package/dist/react.js +356 -127
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +353 -129
- 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 +155 -9
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +155 -9
- 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-BQ8-H2H4.d.ts +0 -74
- package/dist/AmplifyRenderer-W7eqltSj.d.mts +0 -74
package/dist/server.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as AmplifyUpTarget, P as PageConfig, A as AmplifyContentMeta } from './types-
|
|
2
|
-
export { r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-
|
|
1
|
+
import { i as AmplifyUpTarget, P as PageConfig, A as AmplifyContentMeta } from './types-C32MgOiv.mjs';
|
|
2
|
+
export { r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-C32MgOiv.mjs';
|
|
3
3
|
export { A as AMPLIFYUP_EDITOR_ROUTE, i as isAmplifyUpEditorRoute } from './reservedRoutes-aGgViBDM.mjs';
|
|
4
|
-
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-
|
|
4
|
+
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';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Compact variant-key codec for URLs and Edge `variants` query params.
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as AmplifyUpTarget, P as PageConfig, A as AmplifyContentMeta } from './types-
|
|
2
|
-
export { r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-
|
|
1
|
+
import { i as AmplifyUpTarget, P as PageConfig, A as AmplifyContentMeta } from './types-C32MgOiv.js';
|
|
2
|
+
export { r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-C32MgOiv.js';
|
|
3
3
|
export { A as AMPLIFYUP_EDITOR_ROUTE, i as isAmplifyUpEditorRoute } from './reservedRoutes-aGgViBDM.js';
|
|
4
|
-
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-
|
|
4
|
+
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';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Compact variant-key codec for URLs and Edge `variants` query params.
|
package/dist/server.js
CHANGED
|
@@ -100,6 +100,16 @@ function isComposerPreview() {
|
|
|
100
100
|
|
|
101
101
|
// src/field-envelope.ts
|
|
102
102
|
var FIELDS_BRAND = Symbol("amplifyup.fields");
|
|
103
|
+
var IDENTIFIER_KEYS = /* @__PURE__ */ new Set([
|
|
104
|
+
"id",
|
|
105
|
+
"_id",
|
|
106
|
+
"slug",
|
|
107
|
+
"key",
|
|
108
|
+
"_key",
|
|
109
|
+
"docId",
|
|
110
|
+
"_type",
|
|
111
|
+
"type"
|
|
112
|
+
]);
|
|
103
113
|
function isBrandedFields(value) {
|
|
104
114
|
return !!value && typeof value === "object" && FIELDS_BRAND in value;
|
|
105
115
|
}
|
|
@@ -121,6 +131,70 @@ function isPortableImageShape(value) {
|
|
|
121
131
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
122
132
|
return "url" in value;
|
|
123
133
|
}
|
|
134
|
+
function isIdentifierKey(key) {
|
|
135
|
+
return IDENTIFIER_KEYS.has(key);
|
|
136
|
+
}
|
|
137
|
+
function isRecordList(value) {
|
|
138
|
+
if (!Array.isArray(value) || value.length === 0) return false;
|
|
139
|
+
const sample = value.find((item) => item != null);
|
|
140
|
+
if (sample === void 0) return false;
|
|
141
|
+
if (typeof sample !== "object" || Array.isArray(sample)) return false;
|
|
142
|
+
if (isPortableImageShape(sample)) return false;
|
|
143
|
+
if (sample.$$typeof) return false;
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
function isFieldRef(value) {
|
|
147
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
148
|
+
const rec = value;
|
|
149
|
+
return typeof rec.providerId === "string" && !!rec.providerId && typeof rec.entity === "string" && !!rec.entity && typeof rec.id === "string" && !!rec.id;
|
|
150
|
+
}
|
|
151
|
+
function isListOwner(value) {
|
|
152
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
153
|
+
const rec = value;
|
|
154
|
+
return typeof rec.providerId === "string" && !!rec.providerId && typeof rec.entity === "string" && !!rec.entity;
|
|
155
|
+
}
|
|
156
|
+
function listOwnerFromConnection(conn) {
|
|
157
|
+
if (!conn || typeof conn !== "object") return void 0;
|
|
158
|
+
if (conn.mode === "query") {
|
|
159
|
+
const providerId = String(conn.spec?.providerId || "").trim();
|
|
160
|
+
const entity = String(conn.spec?.entity || "").trim();
|
|
161
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
162
|
+
}
|
|
163
|
+
if (conn.mode === "item" || conn.mode === "items") {
|
|
164
|
+
const providerId = String(conn.providerId || "").trim();
|
|
165
|
+
const entity = String(conn.entity || "").trim();
|
|
166
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
167
|
+
}
|
|
168
|
+
return void 0;
|
|
169
|
+
}
|
|
170
|
+
function listOwnerFromSpec(spec) {
|
|
171
|
+
const providerId = String(spec?.providerId || "").trim();
|
|
172
|
+
const entity = String(spec?.entity || "").trim();
|
|
173
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
174
|
+
}
|
|
175
|
+
function isEnvelopeSources(value) {
|
|
176
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
177
|
+
const rec = value;
|
|
178
|
+
return rec.connections != null || rec.reads != null;
|
|
179
|
+
}
|
|
180
|
+
function normalizeEnvelopeSources(sources) {
|
|
181
|
+
if (!sources) return {};
|
|
182
|
+
if (isEnvelopeSources(sources) && !("mode" in sources)) {
|
|
183
|
+
return sources;
|
|
184
|
+
}
|
|
185
|
+
return { connections: sources };
|
|
186
|
+
}
|
|
187
|
+
function listOwnerForField(fieldName, props, sources) {
|
|
188
|
+
const { connections, reads } = normalizeEnvelopeSources(sources);
|
|
189
|
+
const resourceName = reads?.[fieldName]?.resource || fieldName;
|
|
190
|
+
const fromConn = listOwnerFromConnection(connections?.[resourceName]);
|
|
191
|
+
if (fromConn) return fromConn;
|
|
192
|
+
const paging = props?.[`${fieldName}Pagination`];
|
|
193
|
+
if (paging && typeof paging === "object" && !Array.isArray(paging)) {
|
|
194
|
+
return listOwnerFromSpec(paging.spec);
|
|
195
|
+
}
|
|
196
|
+
return void 0;
|
|
197
|
+
}
|
|
124
198
|
function joinPath(prefix, key) {
|
|
125
199
|
return prefix ? `${prefix}.${key}` : key;
|
|
126
200
|
}
|
|
@@ -128,39 +202,101 @@ function emptyValue(raw) {
|
|
|
128
202
|
if (raw === void 0) return null;
|
|
129
203
|
return raw;
|
|
130
204
|
}
|
|
131
|
-
function
|
|
205
|
+
function rowId(raw) {
|
|
206
|
+
const candidates = [raw.id, raw._id, raw.docId, raw.key, raw._key];
|
|
207
|
+
for (const c of candidates) {
|
|
208
|
+
if (typeof c === "string" && c.trim()) return c;
|
|
209
|
+
}
|
|
210
|
+
return "";
|
|
211
|
+
}
|
|
212
|
+
function withLeaf(envelope, scope) {
|
|
213
|
+
if (isFieldRef(scope?.ref)) envelope.ref = scope.ref;
|
|
214
|
+
else if (scope?.readOnly) envelope.readOnly = true;
|
|
215
|
+
return envelope;
|
|
216
|
+
}
|
|
217
|
+
function toFieldEnvelopes(source, prefix = "", scope) {
|
|
218
|
+
const ctx = isFieldRef(scope) ? { ref: scope } : scope || {};
|
|
132
219
|
const input = source && typeof source === "object" && !Array.isArray(source) ? source : {};
|
|
133
220
|
if (isBrandedFields(input)) {
|
|
134
221
|
return input;
|
|
135
222
|
}
|
|
136
223
|
const out = {};
|
|
137
224
|
for (const [key, raw] of Object.entries(input)) {
|
|
225
|
+
if (isIdentifierKey(key) && (typeof raw === "string" || raw == null)) {
|
|
226
|
+
out[key] = raw ?? "";
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
138
229
|
const path = joinPath(prefix, key);
|
|
139
230
|
if (isFieldEnvelope(raw)) {
|
|
140
|
-
|
|
231
|
+
const inner = raw.value;
|
|
232
|
+
if (isRecordList(inner)) {
|
|
233
|
+
const owner = ctx.owners?.(key);
|
|
234
|
+
out[key] = {
|
|
235
|
+
value: envelopeListRows(inner, owner),
|
|
236
|
+
name: raw.name || path
|
|
237
|
+
};
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
out[key] = withLeaf(
|
|
241
|
+
{ value: raw.value ?? null, name: raw.name || path },
|
|
242
|
+
raw.ref ? { ref: raw.ref } : ctx
|
|
243
|
+
);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (isRecordList(raw)) {
|
|
247
|
+
const owner = ctx.owners?.(key);
|
|
248
|
+
out[key] = { value: envelopeListRows(raw, owner), name: path };
|
|
141
249
|
continue;
|
|
142
250
|
}
|
|
143
251
|
if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !raw.$$typeof) {
|
|
144
|
-
out[key] = toFieldEnvelopes(raw, path);
|
|
252
|
+
out[key] = toFieldEnvelopes(raw, path, ctx);
|
|
145
253
|
continue;
|
|
146
254
|
}
|
|
147
|
-
out[key] = { value: emptyValue(raw), name: path };
|
|
255
|
+
out[key] = withLeaf({ value: emptyValue(raw), name: path }, ctx);
|
|
148
256
|
}
|
|
149
257
|
return brandFields(out);
|
|
150
258
|
}
|
|
151
|
-
function
|
|
259
|
+
function envelopeListRows(items, owner) {
|
|
260
|
+
return items.map((item) => envelopeListRow(item, owner));
|
|
261
|
+
}
|
|
262
|
+
function envelopeListRow(item, owner) {
|
|
263
|
+
if (isBrandedFields(item) && typeof item.id === "string") {
|
|
264
|
+
return item;
|
|
265
|
+
}
|
|
266
|
+
const raw = item && typeof item === "object" && !Array.isArray(item) ? item : {};
|
|
267
|
+
const id = rowId(raw);
|
|
268
|
+
const ref = isListOwner(owner) && id ? { providerId: owner.providerId, entity: owner.entity, id } : void 0;
|
|
269
|
+
const fields = toFieldEnvelopes(raw, "", {
|
|
270
|
+
ref,
|
|
271
|
+
readOnly: !ref
|
|
272
|
+
});
|
|
273
|
+
const row = fields;
|
|
274
|
+
if (typeof row.id !== "string") {
|
|
275
|
+
row.id = id;
|
|
276
|
+
}
|
|
277
|
+
return row;
|
|
278
|
+
}
|
|
279
|
+
function attachFieldEnvelopes(props, sources) {
|
|
152
280
|
const raw = props && typeof props === "object" ? { ...props } : {};
|
|
153
281
|
if (isBrandedFields(raw.fields)) return raw;
|
|
154
282
|
const { fields: existing, ...content } = raw;
|
|
155
283
|
const source = existing && typeof existing === "object" && !isFieldEnvelope(existing) ? existing : content;
|
|
156
|
-
return {
|
|
284
|
+
return {
|
|
285
|
+
...raw,
|
|
286
|
+
fields: toFieldEnvelopes(source, "", {
|
|
287
|
+
owners: (fieldName) => listOwnerForField(fieldName, source, sources)
|
|
288
|
+
})
|
|
289
|
+
};
|
|
157
290
|
}
|
|
158
291
|
function walkLayoutNodes(nodes) {
|
|
159
292
|
if (!Array.isArray(nodes)) return;
|
|
160
293
|
for (const node of nodes) {
|
|
161
294
|
if (!node || typeof node !== "object") continue;
|
|
162
295
|
const rec = node;
|
|
163
|
-
rec.props = attachFieldEnvelopes(rec.props
|
|
296
|
+
rec.props = attachFieldEnvelopes(rec.props, {
|
|
297
|
+
connections: rec.resources,
|
|
298
|
+
reads: rec.reads
|
|
299
|
+
});
|
|
164
300
|
for (const slot of rec.slots || []) {
|
|
165
301
|
walkLayoutNodes(slot.children);
|
|
166
302
|
}
|
|
@@ -277,7 +413,10 @@ async function fetchEdgeResolve(options) {
|
|
|
277
413
|
return envelopeResolvedPayload(body);
|
|
278
414
|
}
|
|
279
415
|
function envelopeResolvedComponent(node) {
|
|
280
|
-
node.props = attachFieldEnvelopes(node.props
|
|
416
|
+
node.props = attachFieldEnvelopes(node.props, {
|
|
417
|
+
connections: node.resources,
|
|
418
|
+
reads: node.reads
|
|
419
|
+
});
|
|
281
420
|
if (!node.children) return;
|
|
282
421
|
for (const kids of Object.values(node.children)) {
|
|
283
422
|
for (const child of kids || []) envelopeResolvedComponent(child);
|
|
@@ -571,7 +710,7 @@ async function fetchEdgeQuery(options) {
|
|
|
571
710
|
async function queryContent(options) {
|
|
572
711
|
const target = resolveAmplifyUpTarget({ configTarget: options.target });
|
|
573
712
|
const { edgeUrl } = resolveAmplifyUpUrls(target);
|
|
574
|
-
|
|
713
|
+
const raw = await fetchEdgeQuery({
|
|
575
714
|
edgeUrl,
|
|
576
715
|
trackingId: options.trackingId,
|
|
577
716
|
route: options.route,
|
|
@@ -580,6 +719,13 @@ async function queryContent(options) {
|
|
|
580
719
|
fetch: options.fetch,
|
|
581
720
|
signal: options.signal
|
|
582
721
|
});
|
|
722
|
+
return {
|
|
723
|
+
...raw,
|
|
724
|
+
results: envelopeListRows(
|
|
725
|
+
raw.results,
|
|
726
|
+
listOwnerFromSpec(options.spec)
|
|
727
|
+
)
|
|
728
|
+
};
|
|
583
729
|
}
|
|
584
730
|
function nextPageSpec(pagination) {
|
|
585
731
|
return { ...pagination.spec, offset: pagination.nextOffset };
|