@amplifyup/sdk 0.1.66 → 0.1.68
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/dist/AmplifyRenderer.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +117 -13
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +117 -13
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +113 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{query-DuRilU_n.d.mts → query-B_DU7yEm.d.mts} +1 -1
- package/dist/{query-BLjZYjHJ.d.ts → query-Hay-oVYp.d.ts} +1 -1
- package/dist/react.d.mts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +205 -47
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +205 -47
- 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 +30 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +30 -1
- package/dist/server.mjs.map +1 -1
- package/dist/{types-C32MgOiv.d.mts → types-CGeBbx84.d.mts} +9 -3
- package/dist/{types-C32MgOiv.d.ts → types-CGeBbx84.d.ts} +9 -3
- package/package.json +1 -1
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-CGeBbx84.mjs';
|
|
2
|
+
export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-CGeBbx84.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-B_DU7yEm.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Storage utilities for instance ID and user ID
|
|
@@ -396,6 +396,7 @@ declare class AmplifyUpSDK {
|
|
|
396
396
|
* Fetch page configuration from orchestrator's Layout Provider
|
|
397
397
|
*/
|
|
398
398
|
fetchPageConfig(route: string, preview?: boolean): Promise<any>;
|
|
399
|
+
private fetchPageConfigUncached;
|
|
399
400
|
/**
|
|
400
401
|
* Set up view-level event tracking based on configuration
|
|
401
402
|
*/
|
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-CGeBbx84.js';
|
|
2
|
+
export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, j as resolveAmplifyUpUrls } from './types-CGeBbx84.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-Hay-oVYp.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Storage utilities for instance ID and user ID
|
|
@@ -396,6 +396,7 @@ declare class AmplifyUpSDK {
|
|
|
396
396
|
* Fetch page configuration from orchestrator's Layout Provider
|
|
397
397
|
*/
|
|
398
398
|
fetchPageConfig(route: string, preview?: boolean): Promise<any>;
|
|
399
|
+
private fetchPageConfigUncached;
|
|
399
400
|
/**
|
|
400
401
|
* Set up view-level event tracking based on configuration
|
|
401
402
|
*/
|
package/dist/index.js
CHANGED
|
@@ -427,6 +427,13 @@ function isFieldEnvelope(value) {
|
|
|
427
427
|
const rec = value;
|
|
428
428
|
return typeof rec.name === "string" && "value" in rec && !("url" in rec);
|
|
429
429
|
}
|
|
430
|
+
var OBJECT_FIELD_KINDS = /* @__PURE__ */ new Set(["object", "array", "list"]);
|
|
431
|
+
function isLeafFieldKind(kind) {
|
|
432
|
+
if (typeof kind !== "string") return false;
|
|
433
|
+
const normalized = kind.trim().toLowerCase();
|
|
434
|
+
if (!normalized) return false;
|
|
435
|
+
return !OBJECT_FIELD_KINDS.has(normalized);
|
|
436
|
+
}
|
|
430
437
|
function isPageResourceSentinel(value) {
|
|
431
438
|
return !!value && typeof value === "object" && !Array.isArray(value) && typeof value.__amplifyupPageResource === "string";
|
|
432
439
|
}
|
|
@@ -557,6 +564,10 @@ function toFieldEnvelopes(source, prefix = "", scope) {
|
|
|
557
564
|
out[key] = { value: envelopeListRows(raw, owner), name: path };
|
|
558
565
|
continue;
|
|
559
566
|
}
|
|
567
|
+
if (ctx.leaf?.(path)) {
|
|
568
|
+
out[key] = withLeaf({ value: emptyValue(raw), name: path }, ctx);
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
560
571
|
if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !raw.$$typeof) {
|
|
561
572
|
out[key] = toFieldEnvelopes(raw, path, ctx);
|
|
562
573
|
continue;
|
|
@@ -585,15 +596,33 @@ function envelopeListRow(item, owner) {
|
|
|
585
596
|
}
|
|
586
597
|
return row;
|
|
587
598
|
}
|
|
599
|
+
var warnedMissingFieldKind = /* @__PURE__ */ new Set();
|
|
600
|
+
function warnMissingFieldKind(fieldName) {
|
|
601
|
+
if (process.env.NODE_ENV === "production") return;
|
|
602
|
+
if (warnedMissingFieldKind.has(fieldName)) return;
|
|
603
|
+
warnedMissingFieldKind.add(fieldName);
|
|
604
|
+
console.warn(
|
|
605
|
+
`[AmplifyUp SDK] Field "${fieldName}" has no schema kind; using value-shape detection. Republish the component definition so its fields carry a type.`
|
|
606
|
+
);
|
|
607
|
+
}
|
|
588
608
|
function attachFieldEnvelopes(props, sources) {
|
|
589
609
|
const raw = props && typeof props === "object" ? { ...props } : {};
|
|
590
610
|
if (isBrandedFields(raw.fields)) return raw;
|
|
591
611
|
const { fields: existing, ...content } = raw;
|
|
592
612
|
const source = existing && typeof existing === "object" && !isFieldEnvelope(existing) ? existing : content;
|
|
613
|
+
const { reads } = normalizeEnvelopeSources(sources);
|
|
614
|
+
if (reads) {
|
|
615
|
+
for (const [fieldName, read] of Object.entries(reads)) {
|
|
616
|
+
if (!read?.kind) warnMissingFieldKind(fieldName);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
593
619
|
return {
|
|
594
620
|
...raw,
|
|
595
621
|
fields: toFieldEnvelopes(source, "", {
|
|
596
|
-
owners: (fieldName) => listOwnerForField(fieldName, source, sources)
|
|
622
|
+
owners: (fieldName) => listOwnerForField(fieldName, source, sources),
|
|
623
|
+
// Top-level field paths equal field names; nested paths have no schema
|
|
624
|
+
// entry and fall back to shape-based handling.
|
|
625
|
+
leaf: (path) => isLeafFieldKind(reads?.[path]?.kind)
|
|
597
626
|
})
|
|
598
627
|
};
|
|
599
628
|
}
|
|
@@ -783,7 +812,58 @@ function readAmplifyUpDebugEnv() {
|
|
|
783
812
|
return false;
|
|
784
813
|
}
|
|
785
814
|
}
|
|
815
|
+
var configDebug;
|
|
786
816
|
function setAmplifyUpDebug(enabled) {
|
|
817
|
+
configDebug = enabled;
|
|
818
|
+
}
|
|
819
|
+
function isAmplifyUpDebug() {
|
|
820
|
+
if (configDebug === true) return true;
|
|
821
|
+
if (configDebug === false) return false;
|
|
822
|
+
return readAmplifyUpDebugEnv();
|
|
823
|
+
}
|
|
824
|
+
function sdkDebug(...args) {
|
|
825
|
+
if (!isAmplifyUpDebug()) return;
|
|
826
|
+
console.log(...args);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
// src/content/layoutProviderCache.ts
|
|
830
|
+
var SETTLED_TTL_MS = 5e3;
|
|
831
|
+
var inflight = /* @__PURE__ */ new Map();
|
|
832
|
+
var settled = /* @__PURE__ */ new Map();
|
|
833
|
+
function layoutProviderCacheKey(opts) {
|
|
834
|
+
const route = (opts.route || "/").split("?")[0] || "/";
|
|
835
|
+
return [
|
|
836
|
+
route,
|
|
837
|
+
opts.trackingId || "",
|
|
838
|
+
opts.instanceId || "",
|
|
839
|
+
opts.preview ? "1" : "0",
|
|
840
|
+
opts.working ? "1" : "0",
|
|
841
|
+
opts.zoneId || "",
|
|
842
|
+
opts.compositionId || ""
|
|
843
|
+
].join("|");
|
|
844
|
+
}
|
|
845
|
+
function getSettledLayoutProvider(key) {
|
|
846
|
+
const entry = settled.get(key);
|
|
847
|
+
if (!entry) return void 0;
|
|
848
|
+
if (Date.now() - entry.at > SETTLED_TTL_MS) {
|
|
849
|
+
settled.delete(key);
|
|
850
|
+
return void 0;
|
|
851
|
+
}
|
|
852
|
+
return entry.value;
|
|
853
|
+
}
|
|
854
|
+
function dedupeLayoutProviderFetch(key, fetchFn) {
|
|
855
|
+
const cached = getSettledLayoutProvider(key);
|
|
856
|
+
if (cached !== void 0) return Promise.resolve(cached);
|
|
857
|
+
const existing = inflight.get(key);
|
|
858
|
+
if (existing) return existing;
|
|
859
|
+
const pending = fetchFn().then((value) => {
|
|
860
|
+
settled.set(key, { value, at: Date.now() });
|
|
861
|
+
return value;
|
|
862
|
+
}).finally(() => {
|
|
863
|
+
inflight.delete(key);
|
|
864
|
+
});
|
|
865
|
+
inflight.set(key, pending);
|
|
866
|
+
return pending;
|
|
787
867
|
}
|
|
788
868
|
|
|
789
869
|
// src/reservedRoutes.ts
|
|
@@ -2204,6 +2284,32 @@ Available Console Commands:
|
|
|
2204
2284
|
*/
|
|
2205
2285
|
async fetchPageConfig(route, preview = false) {
|
|
2206
2286
|
const url = this.buildLayoutProviderUrl(route, preview);
|
|
2287
|
+
const pageSearch = typeof window !== "undefined" ? new URLSearchParams(window.location.search) : null;
|
|
2288
|
+
const cacheKey = layoutProviderCacheKey({
|
|
2289
|
+
route,
|
|
2290
|
+
trackingId: this.getTrackingId(),
|
|
2291
|
+
instanceId: getInstanceId(),
|
|
2292
|
+
preview,
|
|
2293
|
+
working: pageSearch ? isWorkingContentRequest(pageSearch) : false,
|
|
2294
|
+
zoneId: pageSearch?.get("zoneId"),
|
|
2295
|
+
compositionId: pageSearch?.get("compositionId")
|
|
2296
|
+
});
|
|
2297
|
+
return dedupeLayoutProviderFetch(cacheKey, async () => {
|
|
2298
|
+
const startedAt = Date.now();
|
|
2299
|
+
sdkDebug("[AmplifyUp SDK] layout/provider request", {
|
|
2300
|
+
route,
|
|
2301
|
+
at: new Date(startedAt).toISOString()
|
|
2302
|
+
});
|
|
2303
|
+
const page2 = await this.fetchPageConfigUncached(url);
|
|
2304
|
+
sdkDebug("[AmplifyUp SDK] layout/provider response", {
|
|
2305
|
+
route,
|
|
2306
|
+
durationMs: Date.now() - startedAt,
|
|
2307
|
+
hasPage: !!page2
|
|
2308
|
+
});
|
|
2309
|
+
return page2;
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
async fetchPageConfigUncached(url) {
|
|
2207
2313
|
const response = await fetch(url);
|
|
2208
2314
|
if (!response.ok) {
|
|
2209
2315
|
if (response.status === 404) {
|
|
@@ -2562,6 +2668,12 @@ Available Console Commands:
|
|
|
2562
2668
|
);
|
|
2563
2669
|
return;
|
|
2564
2670
|
}
|
|
2671
|
+
if (event.data?.type === "AMPLIFYUP_LAYOUT_PATCH") {
|
|
2672
|
+
window.dispatchEvent(
|
|
2673
|
+
new CustomEvent("amplifyup:layout-patch", { detail: event.data })
|
|
2674
|
+
);
|
|
2675
|
+
return;
|
|
2676
|
+
}
|
|
2565
2677
|
if (event.data?.type === "COMPONENT_DELETABLE_STATUS") {
|
|
2566
2678
|
const { componentId, deletable, nodeId } = event.data;
|
|
2567
2679
|
const element = document.querySelector(`[data-component-id="${componentId}"]`);
|