@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/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
|
}
|
|
@@ -117,25 +127,79 @@ function isFieldEnvelope(value) {
|
|
|
117
127
|
const rec = value;
|
|
118
128
|
return typeof rec.name === "string" && "value" in rec && !("url" in rec);
|
|
119
129
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
return "url" in value;
|
|
130
|
+
function isPageResourceSentinel(value) {
|
|
131
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && typeof value.__amplifyupPageResource === "string";
|
|
123
132
|
}
|
|
124
|
-
function
|
|
133
|
+
function isPortableImageShape(value) {
|
|
125
134
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
135
|
+
if ("url" in value) return true;
|
|
126
136
|
const rec = value;
|
|
127
|
-
return
|
|
137
|
+
return rec._type === "image" || rec.asset != null;
|
|
128
138
|
}
|
|
129
|
-
function
|
|
139
|
+
function isIdentifierKey(key) {
|
|
140
|
+
return IDENTIFIER_KEYS.has(key);
|
|
141
|
+
}
|
|
142
|
+
function isRecordList(value) {
|
|
130
143
|
if (!Array.isArray(value) || value.length === 0) return false;
|
|
131
144
|
const sample = value.find((item) => item != null);
|
|
132
145
|
if (sample === void 0) return false;
|
|
133
146
|
if (typeof sample !== "object" || Array.isArray(sample)) return false;
|
|
134
147
|
if (isPortableImageShape(sample)) return false;
|
|
135
|
-
if (isEntryRefItem(sample)) return false;
|
|
136
148
|
if (sample.$$typeof) return false;
|
|
137
149
|
return true;
|
|
138
150
|
}
|
|
151
|
+
function isFieldRef(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 && typeof rec.id === "string" && !!rec.id;
|
|
155
|
+
}
|
|
156
|
+
function isListOwner(value) {
|
|
157
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
158
|
+
const rec = value;
|
|
159
|
+
return typeof rec.providerId === "string" && !!rec.providerId && typeof rec.entity === "string" && !!rec.entity;
|
|
160
|
+
}
|
|
161
|
+
function listOwnerFromConnection(conn) {
|
|
162
|
+
if (!conn || typeof conn !== "object") return void 0;
|
|
163
|
+
if (conn.mode === "query") {
|
|
164
|
+
const providerId = String(conn.spec?.providerId || "").trim();
|
|
165
|
+
const entity = String(conn.spec?.entity || "").trim();
|
|
166
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
167
|
+
}
|
|
168
|
+
if (conn.mode === "item" || conn.mode === "items") {
|
|
169
|
+
const providerId = String(conn.providerId || "").trim();
|
|
170
|
+
const entity = String(conn.entity || "").trim();
|
|
171
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
172
|
+
}
|
|
173
|
+
return void 0;
|
|
174
|
+
}
|
|
175
|
+
function listOwnerFromSpec(spec) {
|
|
176
|
+
const providerId = String(spec?.providerId || "").trim();
|
|
177
|
+
const entity = String(spec?.entity || "").trim();
|
|
178
|
+
return providerId && entity ? { providerId, entity } : void 0;
|
|
179
|
+
}
|
|
180
|
+
function isEnvelopeSources(value) {
|
|
181
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
182
|
+
const rec = value;
|
|
183
|
+
return rec.connections != null || rec.reads != null;
|
|
184
|
+
}
|
|
185
|
+
function normalizeEnvelopeSources(sources) {
|
|
186
|
+
if (!sources) return {};
|
|
187
|
+
if (isEnvelopeSources(sources) && !("mode" in sources)) {
|
|
188
|
+
return sources;
|
|
189
|
+
}
|
|
190
|
+
return { connections: sources };
|
|
191
|
+
}
|
|
192
|
+
function listOwnerForField(fieldName, props, sources) {
|
|
193
|
+
const { connections, reads } = normalizeEnvelopeSources(sources);
|
|
194
|
+
const resourceName = reads?.[fieldName]?.resource || fieldName;
|
|
195
|
+
const fromConn = listOwnerFromConnection(connections?.[resourceName]);
|
|
196
|
+
if (fromConn) return fromConn;
|
|
197
|
+
const paging = props?.[`${fieldName}Pagination`];
|
|
198
|
+
if (paging && typeof paging === "object" && !Array.isArray(paging)) {
|
|
199
|
+
return listOwnerFromSpec(paging.spec);
|
|
200
|
+
}
|
|
201
|
+
return void 0;
|
|
202
|
+
}
|
|
139
203
|
function joinPath(prefix, key) {
|
|
140
204
|
return prefix ? `${prefix}.${key}` : key;
|
|
141
205
|
}
|
|
@@ -143,61 +207,105 @@ function emptyValue(raw) {
|
|
|
143
207
|
if (raw === void 0) return null;
|
|
144
208
|
return raw;
|
|
145
209
|
}
|
|
146
|
-
function
|
|
210
|
+
function rowId(raw) {
|
|
211
|
+
const candidates = [raw.id, raw._id, raw.docId, raw.key, raw._key];
|
|
212
|
+
for (const c of candidates) {
|
|
213
|
+
if (typeof c === "string" && c.trim()) return c;
|
|
214
|
+
}
|
|
215
|
+
return "";
|
|
216
|
+
}
|
|
217
|
+
function withLeaf(envelope, scope) {
|
|
218
|
+
if (isFieldRef(scope?.ref)) envelope.ref = scope.ref;
|
|
219
|
+
else if (scope?.readOnly) envelope.readOnly = true;
|
|
220
|
+
return envelope;
|
|
221
|
+
}
|
|
222
|
+
function toFieldEnvelopes(source, prefix = "", scope) {
|
|
223
|
+
const ctx = isFieldRef(scope) ? { ref: scope } : scope || {};
|
|
147
224
|
const input = source && typeof source === "object" && !Array.isArray(source) ? source : {};
|
|
148
225
|
if (isBrandedFields(input)) {
|
|
149
226
|
return input;
|
|
150
227
|
}
|
|
151
228
|
const out = {};
|
|
152
229
|
for (const [key, raw] of Object.entries(input)) {
|
|
230
|
+
if (isIdentifierKey(key) && (typeof raw === "string" || raw == null)) {
|
|
231
|
+
out[key] = raw ?? "";
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
153
234
|
const path = joinPath(prefix, key);
|
|
235
|
+
if (isPageResourceSentinel(raw)) {
|
|
236
|
+
out[key] = withLeaf({ value: raw, name: path }, ctx);
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
154
239
|
if (isFieldEnvelope(raw)) {
|
|
155
240
|
const inner = raw.value;
|
|
156
|
-
if (
|
|
241
|
+
if (isRecordList(inner)) {
|
|
242
|
+
const owner = ctx.owners?.(key);
|
|
157
243
|
out[key] = {
|
|
158
|
-
value:
|
|
244
|
+
value: envelopeListRows(inner, owner),
|
|
159
245
|
name: raw.name || path
|
|
160
246
|
};
|
|
161
247
|
continue;
|
|
162
248
|
}
|
|
163
|
-
out[key] =
|
|
249
|
+
out[key] = withLeaf(
|
|
250
|
+
{ value: raw.value ?? null, name: raw.name || path },
|
|
251
|
+
raw.ref ? { ref: raw.ref } : ctx
|
|
252
|
+
);
|
|
164
253
|
continue;
|
|
165
254
|
}
|
|
166
|
-
if (
|
|
167
|
-
|
|
255
|
+
if (isRecordList(raw)) {
|
|
256
|
+
const owner = ctx.owners?.(key);
|
|
257
|
+
out[key] = { value: envelopeListRows(raw, owner), name: path };
|
|
168
258
|
continue;
|
|
169
259
|
}
|
|
170
260
|
if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !raw.$$typeof) {
|
|
171
|
-
out[key] = toFieldEnvelopes(raw, path);
|
|
261
|
+
out[key] = toFieldEnvelopes(raw, path, ctx);
|
|
172
262
|
continue;
|
|
173
263
|
}
|
|
174
|
-
out[key] = { value: emptyValue(raw), name: path };
|
|
264
|
+
out[key] = withLeaf({ value: emptyValue(raw), name: path }, ctx);
|
|
175
265
|
}
|
|
176
266
|
return brandFields(out);
|
|
177
267
|
}
|
|
178
|
-
function
|
|
179
|
-
return items.map((item
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
268
|
+
function envelopeListRows(items, owner) {
|
|
269
|
+
return items.map((item) => envelopeListRow(item, owner));
|
|
270
|
+
}
|
|
271
|
+
function envelopeListRow(item, owner) {
|
|
272
|
+
if (isBrandedFields(item) && typeof item.id === "string") {
|
|
273
|
+
return item;
|
|
274
|
+
}
|
|
275
|
+
const raw = item && typeof item === "object" && !Array.isArray(item) ? item : {};
|
|
276
|
+
const id = rowId(raw);
|
|
277
|
+
const ref = isListOwner(owner) && id ? { providerId: owner.providerId, entity: owner.entity, id } : void 0;
|
|
278
|
+
const fields = toFieldEnvelopes(raw, "", {
|
|
279
|
+
ref,
|
|
280
|
+
readOnly: !ref
|
|
186
281
|
});
|
|
282
|
+
const row = fields;
|
|
283
|
+
if (typeof row.id !== "string") {
|
|
284
|
+
row.id = id;
|
|
285
|
+
}
|
|
286
|
+
return row;
|
|
187
287
|
}
|
|
188
|
-
function attachFieldEnvelopes(props) {
|
|
288
|
+
function attachFieldEnvelopes(props, sources) {
|
|
189
289
|
const raw = props && typeof props === "object" ? { ...props } : {};
|
|
190
290
|
if (isBrandedFields(raw.fields)) return raw;
|
|
191
291
|
const { fields: existing, ...content } = raw;
|
|
192
292
|
const source = existing && typeof existing === "object" && !isFieldEnvelope(existing) ? existing : content;
|
|
193
|
-
return {
|
|
293
|
+
return {
|
|
294
|
+
...raw,
|
|
295
|
+
fields: toFieldEnvelopes(source, "", {
|
|
296
|
+
owners: (fieldName) => listOwnerForField(fieldName, source, sources)
|
|
297
|
+
})
|
|
298
|
+
};
|
|
194
299
|
}
|
|
195
300
|
function walkLayoutNodes(nodes) {
|
|
196
301
|
if (!Array.isArray(nodes)) return;
|
|
197
302
|
for (const node of nodes) {
|
|
198
303
|
if (!node || typeof node !== "object") continue;
|
|
199
304
|
const rec = node;
|
|
200
|
-
rec.props = attachFieldEnvelopes(rec.props
|
|
305
|
+
rec.props = attachFieldEnvelopes(rec.props, {
|
|
306
|
+
connections: rec.resources,
|
|
307
|
+
reads: rec.reads
|
|
308
|
+
});
|
|
201
309
|
for (const slot of rec.slots || []) {
|
|
202
310
|
walkLayoutNodes(slot.children);
|
|
203
311
|
}
|
|
@@ -314,7 +422,10 @@ async function fetchEdgeResolve(options) {
|
|
|
314
422
|
return envelopeResolvedPayload(body);
|
|
315
423
|
}
|
|
316
424
|
function envelopeResolvedComponent(node) {
|
|
317
|
-
node.props = attachFieldEnvelopes(node.props
|
|
425
|
+
node.props = attachFieldEnvelopes(node.props, {
|
|
426
|
+
connections: node.resources,
|
|
427
|
+
reads: node.reads
|
|
428
|
+
});
|
|
318
429
|
if (!node.children) return;
|
|
319
430
|
for (const kids of Object.values(node.children)) {
|
|
320
431
|
for (const child of kids || []) envelopeResolvedComponent(child);
|
|
@@ -608,7 +719,7 @@ async function fetchEdgeQuery(options) {
|
|
|
608
719
|
async function queryContent(options) {
|
|
609
720
|
const target = resolveAmplifyUpTarget({ configTarget: options.target });
|
|
610
721
|
const { edgeUrl } = resolveAmplifyUpUrls(target);
|
|
611
|
-
|
|
722
|
+
const raw = await fetchEdgeQuery({
|
|
612
723
|
edgeUrl,
|
|
613
724
|
trackingId: options.trackingId,
|
|
614
725
|
route: options.route,
|
|
@@ -617,6 +728,13 @@ async function queryContent(options) {
|
|
|
617
728
|
fetch: options.fetch,
|
|
618
729
|
signal: options.signal
|
|
619
730
|
});
|
|
731
|
+
return {
|
|
732
|
+
...raw,
|
|
733
|
+
results: envelopeListRows(
|
|
734
|
+
raw.results,
|
|
735
|
+
listOwnerFromSpec(options.spec)
|
|
736
|
+
)
|
|
737
|
+
};
|
|
620
738
|
}
|
|
621
739
|
function nextPageSpec(pagination) {
|
|
622
740
|
return { ...pagination.spec, offset: pagination.nextOffset };
|