@amplifyup/sdk 0.1.78 → 0.2.0

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.
Files changed (48) hide show
  1. package/README.md +91 -28
  2. package/dist/AmplifyRenderer-BNWBrFQN.d.ts +47 -0
  3. package/dist/AmplifyRenderer-CPUr9Bkc.d.mts +47 -0
  4. package/dist/AmplifyRenderer.d.mts +4 -40
  5. package/dist/AmplifyRenderer.d.ts +4 -40
  6. package/dist/AmplifyRenderer.js +106 -14
  7. package/dist/AmplifyRenderer.js.map +1 -1
  8. package/dist/AmplifyRenderer.mjs +106 -14
  9. package/dist/AmplifyRenderer.mjs.map +1 -1
  10. package/dist/cli.d.mts +1 -0
  11. package/dist/cli.d.ts +1 -0
  12. package/dist/cli.js +266 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/cli.mjs +260 -0
  15. package/dist/cli.mjs.map +1 -0
  16. package/dist/config.d.mts +18 -0
  17. package/dist/config.d.ts +18 -0
  18. package/dist/config.js +10 -0
  19. package/dist/config.js.map +1 -0
  20. package/dist/config.mjs +8 -0
  21. package/dist/config.mjs.map +1 -0
  22. package/dist/index.d.mts +3 -3
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.js +2 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +2 -2
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/next.d.mts +9 -0
  29. package/dist/next.d.ts +9 -0
  30. package/dist/next.js +259 -0
  31. package/dist/next.js.map +1 -0
  32. package/dist/next.mjs +253 -0
  33. package/dist/next.mjs.map +1 -0
  34. package/dist/query-DYjs4LQQ.d.mts +262 -0
  35. package/dist/query-Xo9cy-2F.d.ts +262 -0
  36. package/dist/react.d.mts +19 -21
  37. package/dist/react.d.ts +19 -21
  38. package/dist/react.js +1141 -1035
  39. package/dist/react.js.map +1 -1
  40. package/dist/react.mjs +1140 -1035
  41. package/dist/react.mjs.map +1 -1
  42. package/dist/server.d.mts +3 -3
  43. package/dist/server.d.ts +3 -3
  44. package/dist/{types-D4TSd2Yt.d.mts → types-ffQNIQCK.d.mts} +1 -102
  45. package/dist/{types-D4TSd2Yt.d.ts → types-ffQNIQCK.d.ts} +1 -102
  46. package/package.json +17 -2
  47. package/dist/query-B23UsNIv.d.ts +0 -161
  48. package/dist/query-CV8x3oQT.d.mts +0 -161
@@ -0,0 +1,262 @@
1
+ import { A as AmplifyUpTarget } from './types-ffQNIQCK.mjs';
2
+
3
+ /**
4
+ * On-request variant selection (tier 3).
5
+ *
6
+ * Decisions happen on AmplifyUp Edge. The client asks after the view has
7
+ * rendered; the Worker returns variant keys only. Profile data never leaves
8
+ * the edge. This helper is the JS wrapper around POST /v1/select — the same
9
+ * wire format is the contract for Flutter / native / .NET clients. No DOM
10
+ * or Next.js assumptions.
11
+ */
12
+
13
+ interface SelectVariantsResult {
14
+ siteId: string;
15
+ view: string;
16
+ variantKeys: Record<string, string>;
17
+ meta?: Record<string, unknown>;
18
+ }
19
+ declare class SelectVariantsError extends Error {
20
+ status: number;
21
+ body: unknown;
22
+ constructor(message: string, status: number, body?: unknown);
23
+ }
24
+ interface FetchEdgeSelectOptions {
25
+ edgeUrl: string;
26
+ trackingId?: string;
27
+ site?: string;
28
+ view: string;
29
+ anonId: string;
30
+ sessionId?: string;
31
+ zones?: string[];
32
+ /** Request-local facts the edge cannot observe (app version, screen class). */
33
+ context?: Record<string, unknown>;
34
+ fetch?: typeof fetch;
35
+ signal?: AbortSignal;
36
+ }
37
+ declare function fetchEdgeSelect(options: FetchEdgeSelectOptions): Promise<SelectVariantsResult>;
38
+ interface SelectVariantsOptions {
39
+ trackingId?: string;
40
+ site?: string;
41
+ view: string;
42
+ anonId: string;
43
+ sessionId?: string;
44
+ zones?: string[];
45
+ context?: Record<string, unknown>;
46
+ target?: AmplifyUpTarget;
47
+ edgeUrl?: string;
48
+ fetch?: typeof fetch;
49
+ signal?: AbortSignal;
50
+ }
51
+ /**
52
+ * Ask Edge to decide deferred rules for a view. Returns variant keys to pass
53
+ * to `/v1/resolve?variants=`.
54
+ */
55
+ declare function selectVariants(options: SelectVariantsOptions): Promise<SelectVariantsResult>;
56
+
57
+ /**
58
+ * Field envelopes — same shape in published, draft, and Composer edit.
59
+ * `{ value, name, ref? }` where `name` is the path within the owning record
60
+ * (`title`, `author.name`). Page-level fields omit `ref`.
61
+ * `ref` is stamped from the connection that produced the row
62
+ * (`providerId`, AmplifyUp `entity`, `id`) — never from a CMS `_type`.
63
+ * Produced once at the Edge resolve boundary (`fetchEdgeResolve`) and again
64
+ * on the SDK for `queryContent` rows.
65
+ */
66
+ declare const FIELDS_BRAND: unique symbol;
67
+ type ImageValue = {
68
+ url: string;
69
+ alt?: string;
70
+ width?: number;
71
+ height?: number;
72
+ };
73
+ /** Connection that produced a list row. Omitted on page-level fields. */
74
+ type FieldRef = {
75
+ providerId: string;
76
+ entity: string;
77
+ id: string;
78
+ };
79
+ /** AmplifyUp entity + provider from the connection that produced a list. */
80
+ type ListOwner = {
81
+ providerId: string;
82
+ entity: string;
83
+ };
84
+ type ConnectionLike = {
85
+ mode?: string;
86
+ providerId?: string;
87
+ entity?: string;
88
+ spec?: {
89
+ providerId?: string;
90
+ entity?: string;
91
+ };
92
+ };
93
+ type FieldReadLike = {
94
+ resource: string;
95
+ path?: string;
96
+ /** Schema field kind (image, string, object, …) from the component definition. */
97
+ kind?: string;
98
+ };
99
+ type EnvelopeSources = {
100
+ connections?: Record<string, ConnectionLike | null | undefined>;
101
+ reads?: Record<string, FieldReadLike>;
102
+ };
103
+ type Field<T> = {
104
+ value: T;
105
+ name: string;
106
+ ref?: FieldRef;
107
+ /** Row field with no write target — display only in Composer. */
108
+ readOnly?: true;
109
+ };
110
+ /** Portable entry identity after normalize (`id` required). */
111
+ type PortableRef = {
112
+ id: string;
113
+ type?: string;
114
+ };
115
+ type IdentifierKey = 'id' | '_id' | 'slug' | 'key' | '_key' | 'docId' | '_type' | 'type';
116
+ type IsPlainObject<T> = T extends object ? T extends readonly unknown[] ? false : T extends ImageValue ? false : true : false;
117
+ type AsRecord<T> = T extends Record<string, unknown> ? T : Record<string, unknown>;
118
+ /** A list row: enveloped fields plus a plain `id`. */
119
+ type ListRow<T extends Record<string, unknown> = Record<string, unknown>> = Fields<T> & {
120
+ id: string;
121
+ };
122
+ type FieldsProp<T> = NonNullable<T> extends ImageValue ? Field<T | null> : NonNullable<T> extends readonly (infer U)[] ? IsPlainObject<U> extends true ? Field<Array<ListRow<AsRecord<U>>>> : Field<T> : IsPlainObject<NonNullable<T>> extends true ? Fields<NonNullable<T>> : Field<T>;
123
+ type Fields<T> = {
124
+ readonly [FIELDS_BRAND]: true;
125
+ } & {
126
+ [K in keyof T]-?: K extends IdentifierKey ? T[K] : FieldsProp<T[K]>;
127
+ };
128
+ /** Props passed into site components. Raw CMS bags are not assignable. */
129
+ type LayoutComponentProps<T extends Record<string, unknown> = Record<string, unknown>> = {
130
+ fields: Fields<T>;
131
+ };
132
+ declare function isBrandedFields(value: unknown): value is Fields<Record<string, unknown>>;
133
+ declare function isFieldEnvelope(value: unknown): value is Field<unknown>;
134
+ declare function isReadOnlyRowField(value: unknown): boolean;
135
+ declare function composerStoreKey(name: string, ref?: FieldRef | null, layoutNodeId?: string): string;
136
+ declare function listOwnerFromSpec(spec: {
137
+ providerId?: string;
138
+ entity?: string;
139
+ } | null | undefined): ListOwner | undefined;
140
+ type EnvelopeScope = {
141
+ ref?: FieldRef;
142
+ readOnly?: boolean;
143
+ owners?: (fieldName: string) => ListOwner | undefined;
144
+ /** Schema-driven: true when the field at this path is a scalar leaf. */
145
+ leaf?: (path: string) => boolean;
146
+ };
147
+ /**
148
+ * Wrap a props bag as envelopes. Already-enveloped bags are returned as-is.
149
+ * Nested plain objects become nested bags; portable images stay a leaf.
150
+ * Object arrays become list rows (`Fields` + plain `id`); `name` is the path
151
+ * within the record when `ref` is set.
152
+ */
153
+ declare function toFieldEnvelopes<T extends Record<string, unknown>>(source: T | null | undefined, prefix?: string, scope?: EnvelopeScope | FieldRef): Fields<T>;
154
+ declare function envelopeListRows<T extends Record<string, unknown> = Record<string, unknown>>(items: unknown[], owner?: ListOwner | null): Array<ListRow<T>>;
155
+ /** Attach branded `fields` once. Keeps sibling keys (e.g. zoneId). */
156
+ declare function attachFieldEnvelopes(props: Record<string, unknown> | null | undefined, sources?: EnvelopeSources | Record<string, ConnectionLike | null | undefined>): Record<string, unknown>;
157
+
158
+ /**
159
+ * Runtime content queries.
160
+ *
161
+ * Page resolve covers data known at Deploy. Visitor-triggered data — search,
162
+ * load more, pickers — runs here: the browser asks AmplifyUp, AmplifyUp asks
163
+ * the CMS. Only entities published with the page can be queried.
164
+ * Edge JSON stays raw. `queryContent` envelopes rows on the SDK so they
165
+ * edit in Composer the same way as list-field rows.
166
+ */
167
+
168
+ type QueryFilterOp = 'eq' | 'neq' | 'in' | 'nin' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'exists';
169
+ interface QueryFilter {
170
+ field: string;
171
+ op: QueryFilterOp;
172
+ value?: unknown;
173
+ }
174
+ interface QuerySort {
175
+ field: string;
176
+ dir: 'asc' | 'desc';
177
+ }
178
+ /**
179
+ * Provider-neutral query. AmplifyUp compiles this for the connected CMS —
180
+ * it never contains CMS query syntax. Same shape Composer saves on a
181
+ * query connection, and the shape returned in `{field}Pagination.spec`.
182
+ */
183
+ interface QuerySpec {
184
+ providerId: string;
185
+ entity: string;
186
+ filter: QueryFilter[];
187
+ sort: QuerySort[];
188
+ limit: number;
189
+ offset: number;
190
+ }
191
+ /** Pagination meta added to list props when a query connection is paginated. */
192
+ interface QueryPagination {
193
+ hasMore: boolean;
194
+ limit: number;
195
+ offset: number;
196
+ nextOffset: number;
197
+ spec: QuerySpec;
198
+ }
199
+ interface QueryResult<T = Record<string, unknown>> {
200
+ results: T[];
201
+ count: number;
202
+ hasMore: boolean;
203
+ limit: number;
204
+ offset: number;
205
+ nextOffset: number;
206
+ /** True when a content source failed and results may be incomplete. */
207
+ degraded?: boolean;
208
+ }
209
+ declare class QueryContentError extends Error {
210
+ status: number;
211
+ body: unknown;
212
+ constructor(message: string, status: number, body?: unknown);
213
+ }
214
+ interface FetchEdgeQueryOptions {
215
+ edgeUrl: string;
216
+ trackingId: string;
217
+ /** Published route the query belongs to (provides sources + entity mapping). */
218
+ route: string;
219
+ spec: QuerySpec;
220
+ siteId?: string | null;
221
+ fetch?: typeof fetch;
222
+ signal?: AbortSignal;
223
+ }
224
+ /**
225
+ * Low-level runtime query against a known Edge URL.
226
+ * Most callers should use `queryContent`, which resolves the URL for them.
227
+ */
228
+ declare function fetchEdgeQuery<T = Record<string, unknown>>(options: FetchEdgeQueryOptions): Promise<QueryResult<T>>;
229
+ interface QueryContentOptions {
230
+ trackingId: string;
231
+ /** Published route the query belongs to, e.g. '/insights'. */
232
+ route: string;
233
+ spec: QuerySpec;
234
+ siteId?: string | null;
235
+ target?: AmplifyUpTarget;
236
+ fetch?: typeof fetch;
237
+ signal?: AbortSignal;
238
+ }
239
+ /**
240
+ * Run a content query at request time (search, load more, pickers).
241
+ *
242
+ * Start from the published spec on a paginated list prop so filters and sort
243
+ * stay owned by Composer:
244
+ *
245
+ * ```ts
246
+ * const next = await queryContent({
247
+ * trackingId,
248
+ * route: '/insights',
249
+ * spec: { ...postsPagination.spec, offset: postsPagination.nextOffset },
250
+ * });
251
+ * ```
252
+ */
253
+ declare function queryContent<T extends Record<string, unknown> = Record<string, unknown>>(options: QueryContentOptions): Promise<QueryResult<ListRow<T>>>;
254
+ /** Convenience: next page from pagination meta on a list prop. */
255
+ declare function nextPageSpec(pagination: QueryPagination): QuerySpec;
256
+ /**
257
+ * Convenience: same published query, filtered by a visitor's search term.
258
+ * Resets to the first page. Empty terms return the unfiltered spec.
259
+ */
260
+ declare function searchSpec(pagination: QueryPagination, field: string, term: string): QuerySpec;
261
+
262
+ export { type FieldRef as A, type Fields as B, type LayoutComponentProps as C, type FetchEdgeSelectOptions as F, type ImageValue as I, type ListRow as L, type PortableRef as P, QueryContentError as Q, SelectVariantsError as S, type SelectVariantsOptions as a, type SelectVariantsResult as b, fetchEdgeQuery as c, searchSpec as d, type QueryContentOptions as e, fetchEdgeSelect as f, type FetchEdgeQueryOptions as g, type QueryResult as h, type QueryPagination as i, type QuerySpec as j, type QueryFilter as k, type QueryFilterOp as l, type QuerySort as m, nextPageSpec as n, type Field as o, FIELDS_BRAND as p, queryContent as q, attachFieldEnvelopes as r, selectVariants as s, toFieldEnvelopes as t, envelopeListRows as u, composerStoreKey as v, listOwnerFromSpec as w, isFieldEnvelope as x, isReadOnlyRowField as y, isBrandedFields as z };
@@ -0,0 +1,262 @@
1
+ import { A as AmplifyUpTarget } from './types-ffQNIQCK.js';
2
+
3
+ /**
4
+ * On-request variant selection (tier 3).
5
+ *
6
+ * Decisions happen on AmplifyUp Edge. The client asks after the view has
7
+ * rendered; the Worker returns variant keys only. Profile data never leaves
8
+ * the edge. This helper is the JS wrapper around POST /v1/select — the same
9
+ * wire format is the contract for Flutter / native / .NET clients. No DOM
10
+ * or Next.js assumptions.
11
+ */
12
+
13
+ interface SelectVariantsResult {
14
+ siteId: string;
15
+ view: string;
16
+ variantKeys: Record<string, string>;
17
+ meta?: Record<string, unknown>;
18
+ }
19
+ declare class SelectVariantsError extends Error {
20
+ status: number;
21
+ body: unknown;
22
+ constructor(message: string, status: number, body?: unknown);
23
+ }
24
+ interface FetchEdgeSelectOptions {
25
+ edgeUrl: string;
26
+ trackingId?: string;
27
+ site?: string;
28
+ view: string;
29
+ anonId: string;
30
+ sessionId?: string;
31
+ zones?: string[];
32
+ /** Request-local facts the edge cannot observe (app version, screen class). */
33
+ context?: Record<string, unknown>;
34
+ fetch?: typeof fetch;
35
+ signal?: AbortSignal;
36
+ }
37
+ declare function fetchEdgeSelect(options: FetchEdgeSelectOptions): Promise<SelectVariantsResult>;
38
+ interface SelectVariantsOptions {
39
+ trackingId?: string;
40
+ site?: string;
41
+ view: string;
42
+ anonId: string;
43
+ sessionId?: string;
44
+ zones?: string[];
45
+ context?: Record<string, unknown>;
46
+ target?: AmplifyUpTarget;
47
+ edgeUrl?: string;
48
+ fetch?: typeof fetch;
49
+ signal?: AbortSignal;
50
+ }
51
+ /**
52
+ * Ask Edge to decide deferred rules for a view. Returns variant keys to pass
53
+ * to `/v1/resolve?variants=`.
54
+ */
55
+ declare function selectVariants(options: SelectVariantsOptions): Promise<SelectVariantsResult>;
56
+
57
+ /**
58
+ * Field envelopes — same shape in published, draft, and Composer edit.
59
+ * `{ value, name, ref? }` where `name` is the path within the owning record
60
+ * (`title`, `author.name`). Page-level fields omit `ref`.
61
+ * `ref` is stamped from the connection that produced the row
62
+ * (`providerId`, AmplifyUp `entity`, `id`) — never from a CMS `_type`.
63
+ * Produced once at the Edge resolve boundary (`fetchEdgeResolve`) and again
64
+ * on the SDK for `queryContent` rows.
65
+ */
66
+ declare const FIELDS_BRAND: unique symbol;
67
+ type ImageValue = {
68
+ url: string;
69
+ alt?: string;
70
+ width?: number;
71
+ height?: number;
72
+ };
73
+ /** Connection that produced a list row. Omitted on page-level fields. */
74
+ type FieldRef = {
75
+ providerId: string;
76
+ entity: string;
77
+ id: string;
78
+ };
79
+ /** AmplifyUp entity + provider from the connection that produced a list. */
80
+ type ListOwner = {
81
+ providerId: string;
82
+ entity: string;
83
+ };
84
+ type ConnectionLike = {
85
+ mode?: string;
86
+ providerId?: string;
87
+ entity?: string;
88
+ spec?: {
89
+ providerId?: string;
90
+ entity?: string;
91
+ };
92
+ };
93
+ type FieldReadLike = {
94
+ resource: string;
95
+ path?: string;
96
+ /** Schema field kind (image, string, object, …) from the component definition. */
97
+ kind?: string;
98
+ };
99
+ type EnvelopeSources = {
100
+ connections?: Record<string, ConnectionLike | null | undefined>;
101
+ reads?: Record<string, FieldReadLike>;
102
+ };
103
+ type Field<T> = {
104
+ value: T;
105
+ name: string;
106
+ ref?: FieldRef;
107
+ /** Row field with no write target — display only in Composer. */
108
+ readOnly?: true;
109
+ };
110
+ /** Portable entry identity after normalize (`id` required). */
111
+ type PortableRef = {
112
+ id: string;
113
+ type?: string;
114
+ };
115
+ type IdentifierKey = 'id' | '_id' | 'slug' | 'key' | '_key' | 'docId' | '_type' | 'type';
116
+ type IsPlainObject<T> = T extends object ? T extends readonly unknown[] ? false : T extends ImageValue ? false : true : false;
117
+ type AsRecord<T> = T extends Record<string, unknown> ? T : Record<string, unknown>;
118
+ /** A list row: enveloped fields plus a plain `id`. */
119
+ type ListRow<T extends Record<string, unknown> = Record<string, unknown>> = Fields<T> & {
120
+ id: string;
121
+ };
122
+ type FieldsProp<T> = NonNullable<T> extends ImageValue ? Field<T | null> : NonNullable<T> extends readonly (infer U)[] ? IsPlainObject<U> extends true ? Field<Array<ListRow<AsRecord<U>>>> : Field<T> : IsPlainObject<NonNullable<T>> extends true ? Fields<NonNullable<T>> : Field<T>;
123
+ type Fields<T> = {
124
+ readonly [FIELDS_BRAND]: true;
125
+ } & {
126
+ [K in keyof T]-?: K extends IdentifierKey ? T[K] : FieldsProp<T[K]>;
127
+ };
128
+ /** Props passed into site components. Raw CMS bags are not assignable. */
129
+ type LayoutComponentProps<T extends Record<string, unknown> = Record<string, unknown>> = {
130
+ fields: Fields<T>;
131
+ };
132
+ declare function isBrandedFields(value: unknown): value is Fields<Record<string, unknown>>;
133
+ declare function isFieldEnvelope(value: unknown): value is Field<unknown>;
134
+ declare function isReadOnlyRowField(value: unknown): boolean;
135
+ declare function composerStoreKey(name: string, ref?: FieldRef | null, layoutNodeId?: string): string;
136
+ declare function listOwnerFromSpec(spec: {
137
+ providerId?: string;
138
+ entity?: string;
139
+ } | null | undefined): ListOwner | undefined;
140
+ type EnvelopeScope = {
141
+ ref?: FieldRef;
142
+ readOnly?: boolean;
143
+ owners?: (fieldName: string) => ListOwner | undefined;
144
+ /** Schema-driven: true when the field at this path is a scalar leaf. */
145
+ leaf?: (path: string) => boolean;
146
+ };
147
+ /**
148
+ * Wrap a props bag as envelopes. Already-enveloped bags are returned as-is.
149
+ * Nested plain objects become nested bags; portable images stay a leaf.
150
+ * Object arrays become list rows (`Fields` + plain `id`); `name` is the path
151
+ * within the record when `ref` is set.
152
+ */
153
+ declare function toFieldEnvelopes<T extends Record<string, unknown>>(source: T | null | undefined, prefix?: string, scope?: EnvelopeScope | FieldRef): Fields<T>;
154
+ declare function envelopeListRows<T extends Record<string, unknown> = Record<string, unknown>>(items: unknown[], owner?: ListOwner | null): Array<ListRow<T>>;
155
+ /** Attach branded `fields` once. Keeps sibling keys (e.g. zoneId). */
156
+ declare function attachFieldEnvelopes(props: Record<string, unknown> | null | undefined, sources?: EnvelopeSources | Record<string, ConnectionLike | null | undefined>): Record<string, unknown>;
157
+
158
+ /**
159
+ * Runtime content queries.
160
+ *
161
+ * Page resolve covers data known at Deploy. Visitor-triggered data — search,
162
+ * load more, pickers — runs here: the browser asks AmplifyUp, AmplifyUp asks
163
+ * the CMS. Only entities published with the page can be queried.
164
+ * Edge JSON stays raw. `queryContent` envelopes rows on the SDK so they
165
+ * edit in Composer the same way as list-field rows.
166
+ */
167
+
168
+ type QueryFilterOp = 'eq' | 'neq' | 'in' | 'nin' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'exists';
169
+ interface QueryFilter {
170
+ field: string;
171
+ op: QueryFilterOp;
172
+ value?: unknown;
173
+ }
174
+ interface QuerySort {
175
+ field: string;
176
+ dir: 'asc' | 'desc';
177
+ }
178
+ /**
179
+ * Provider-neutral query. AmplifyUp compiles this for the connected CMS —
180
+ * it never contains CMS query syntax. Same shape Composer saves on a
181
+ * query connection, and the shape returned in `{field}Pagination.spec`.
182
+ */
183
+ interface QuerySpec {
184
+ providerId: string;
185
+ entity: string;
186
+ filter: QueryFilter[];
187
+ sort: QuerySort[];
188
+ limit: number;
189
+ offset: number;
190
+ }
191
+ /** Pagination meta added to list props when a query connection is paginated. */
192
+ interface QueryPagination {
193
+ hasMore: boolean;
194
+ limit: number;
195
+ offset: number;
196
+ nextOffset: number;
197
+ spec: QuerySpec;
198
+ }
199
+ interface QueryResult<T = Record<string, unknown>> {
200
+ results: T[];
201
+ count: number;
202
+ hasMore: boolean;
203
+ limit: number;
204
+ offset: number;
205
+ nextOffset: number;
206
+ /** True when a content source failed and results may be incomplete. */
207
+ degraded?: boolean;
208
+ }
209
+ declare class QueryContentError extends Error {
210
+ status: number;
211
+ body: unknown;
212
+ constructor(message: string, status: number, body?: unknown);
213
+ }
214
+ interface FetchEdgeQueryOptions {
215
+ edgeUrl: string;
216
+ trackingId: string;
217
+ /** Published route the query belongs to (provides sources + entity mapping). */
218
+ route: string;
219
+ spec: QuerySpec;
220
+ siteId?: string | null;
221
+ fetch?: typeof fetch;
222
+ signal?: AbortSignal;
223
+ }
224
+ /**
225
+ * Low-level runtime query against a known Edge URL.
226
+ * Most callers should use `queryContent`, which resolves the URL for them.
227
+ */
228
+ declare function fetchEdgeQuery<T = Record<string, unknown>>(options: FetchEdgeQueryOptions): Promise<QueryResult<T>>;
229
+ interface QueryContentOptions {
230
+ trackingId: string;
231
+ /** Published route the query belongs to, e.g. '/insights'. */
232
+ route: string;
233
+ spec: QuerySpec;
234
+ siteId?: string | null;
235
+ target?: AmplifyUpTarget;
236
+ fetch?: typeof fetch;
237
+ signal?: AbortSignal;
238
+ }
239
+ /**
240
+ * Run a content query at request time (search, load more, pickers).
241
+ *
242
+ * Start from the published spec on a paginated list prop so filters and sort
243
+ * stay owned by Composer:
244
+ *
245
+ * ```ts
246
+ * const next = await queryContent({
247
+ * trackingId,
248
+ * route: '/insights',
249
+ * spec: { ...postsPagination.spec, offset: postsPagination.nextOffset },
250
+ * });
251
+ * ```
252
+ */
253
+ declare function queryContent<T extends Record<string, unknown> = Record<string, unknown>>(options: QueryContentOptions): Promise<QueryResult<ListRow<T>>>;
254
+ /** Convenience: next page from pagination meta on a list prop. */
255
+ declare function nextPageSpec(pagination: QueryPagination): QuerySpec;
256
+ /**
257
+ * Convenience: same published query, filtered by a visitor's search term.
258
+ * Resets to the first page. Empty terms return the unfiltered spec.
259
+ */
260
+ declare function searchSpec(pagination: QueryPagination, field: string, term: string): QuerySpec;
261
+
262
+ export { type FieldRef as A, type Fields as B, type LayoutComponentProps as C, type FetchEdgeSelectOptions as F, type ImageValue as I, type ListRow as L, type PortableRef as P, QueryContentError as Q, SelectVariantsError as S, type SelectVariantsOptions as a, type SelectVariantsResult as b, fetchEdgeQuery as c, searchSpec as d, type QueryContentOptions as e, fetchEdgeSelect as f, type FetchEdgeQueryOptions as g, type QueryResult as h, type QueryPagination as i, type QuerySpec as j, type QueryFilter as k, type QueryFilterOp as l, type QuerySort as m, nextPageSpec as n, type Field as o, FIELDS_BRAND as p, queryContent as q, attachFieldEnvelopes as r, selectVariants as s, toFieldEnvelopes as t, envelopeListRows as u, composerStoreKey as v, listOwnerFromSpec as w, isFieldEnvelope as x, isReadOnlyRowField as y, isBrandedFields as z };
package/dist/react.d.mts CHANGED
@@ -1,24 +1,21 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { L as LayoutComponentProps, P as PageConfig, F as Field$1, m as FIELDS_BRAND, d as AmplifyUpConfig, f as AmplifyPageContextInput, C as ContentSource, A as AmplifyContentMeta } from './types-D4TSd2Yt.mjs';
3
- export { x as FieldRef, y as Fields, B as ImageValue, z as ListRow, D as PortableRef, Z as ZoneConfig, o as attachFieldEnvelopes, q as composerStoreKey, p as envelopeListRows, w as isBrandedFields, u as isFieldEnvelope, v as isReadOnlyRowField, s as listOwnerFromSpec, t as toFieldEnvelopes } from './types-D4TSd2Yt.mjs';
4
- import react__default, { ReactNode } from 'react';
5
- export { AmplifyRenderer } from './AmplifyRenderer.mjs';
6
- export { 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, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-CV8x3oQT.mjs';
2
+ import { P as PageConfig, f as AmplifyUpConfig, h as AmplifyPageContextInput, C as ContentSource, a as AmplifyContentMeta } from './types-ffQNIQCK.mjs';
3
+ export { Z as ZoneConfig } from './types-ffQNIQCK.mjs';
4
+ import react__default, { ReactNode, FC } from 'react';
5
+ import { C as ComponentRegistry } from './AmplifyRenderer-CPUr9Bkc.mjs';
6
+ export { A as AmplifyRenderer, d as defineComponentRegistry } from './AmplifyRenderer-CPUr9Bkc.mjs';
7
+ import { o as Field$1, p as FIELDS_BRAND } from './query-DYjs4LQQ.mjs';
8
+ export { A as FieldRef, B as Fields, I as ImageValue, C as LayoutComponentProps, L as ListRow, P as PortableRef, 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, r as attachFieldEnvelopes, v as composerStoreKey, u as envelopeListRows, z as isBrandedFields, x as isFieldEnvelope, y as isReadOnlyRowField, w as listOwnerFromSpec, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants, t as toFieldEnvelopes } from './query-DYjs4LQQ.mjs';
7
9
  export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
8
10
 
9
- type RenderComponentContext = {
10
- /** Unique layout-tree node id — required when multiple instances share a component type. */
11
- layoutNodeId: string;
12
- };
13
- type RenderComponentFn = (componentId: string, props: LayoutComponentProps, slots?: Record<string, ReactNode>, context?: RenderComponentContext) => ReactNode;
14
11
  interface AmplifyPageContentProps {
15
12
  /**
16
13
  * Native page content shown to visitors when no AmplifyUp layout is configured.
17
14
  * Never rendered in Composer preview — only the layout canvas is shown there.
18
15
  */
19
16
  fallback?: ReactNode;
20
- /** Maps AmplifyUp component IDs to your React components. */
21
- renderComponent: RenderComponentFn;
17
+ /** The generated component registry. `<AmplifyPage />` passes it for you. */
18
+ registry: ComponentRegistry;
22
19
  /** SSG/ISR layout from the server. Client overlay applies only when variants differ. */
23
20
  pageConfig?: PageConfig | null;
24
21
  /**
@@ -41,7 +38,15 @@ interface AmplifyPageContentProps {
41
38
  * Live pages paint the SSG/ISR layout first. Client Edge resolve (visitor id)
42
39
  * overlays only when the personalized tree differs from that static HTML.
43
40
  */
44
- declare function AmplifyPageContent({ fallback, renderComponent, pageConfig: pageConfigProp, forceComposerPreview, previewLoadingComponent, previewEmptyComponent, loadingComponent, emptyComponent, errorComponent, }: AmplifyPageContentProps): react_jsx_runtime.JSX.Element | null;
41
+ declare function AmplifyPageContent(contentProps: AmplifyPageContentProps): react_jsx_runtime.JSX.Element | null;
42
+
43
+ type AmplifyPageProps = Omit<AmplifyPageContentProps, 'registry'>;
44
+ /**
45
+ * Used by the generated registry module to export `<AmplifyPage />`. The
46
+ * binding happens in that client module because a server `page.tsx` can't
47
+ * pass components to a client component.
48
+ */
49
+ declare const bindAmplifyPage: (registry: ComponentRegistry) => FC<AmplifyPageProps>;
45
50
 
46
51
  /**
47
52
  * True when the page is running inside AmplifyUp Composer.
@@ -57,13 +62,6 @@ declare function useInComposer(force?: boolean): boolean;
57
62
  /** @deprecated Prefer `useInComposer`. Kept for internal AmplifyPageContent. */
58
63
  declare function useComposerPreviewFlag(force?: boolean): boolean;
59
64
 
60
- declare function ComponentContextProvider({ children, slots, props, layoutNodeId, componentId, }: {
61
- children: ReactNode;
62
- slots?: Record<string, ReactNode>;
63
- props?: Record<string, any>;
64
- layoutNodeId?: string;
65
- componentId?: string;
66
- }): react_jsx_runtime.JSX.Element;
67
65
  /**
68
66
  * Slot Component
69
67
  *
@@ -230,4 +228,4 @@ interface AmplifyUpProviderProps {
230
228
  declare function AmplifyUpProvider({ children, config, pageContext, }: AmplifyUpProviderProps): react_jsx_runtime.JSX.Element;
231
229
  declare function useAmplifyUp(): AmplifyUpContextType;
232
230
 
233
- export { AmplifyContentMeta, AmplifyPageContent, AmplifyUpProvider, ComponentContextProvider, ComposerLayoutStatusProvider, ComposerProvider, ContentSource, Field, Field$1 as FieldEnvelope, Image, LayoutComponentProps, MaybeComposerProvider, PageConfig, RichText, Slot, type SlotState, resolveSlotState, slotShowsAddComponent, slotStateFromEl, useAmplifyUp, useComposerPreviewFlag, useInComposer };
231
+ export { AmplifyContentMeta, AmplifyPageContent, type AmplifyPageContentProps, type AmplifyPageProps, AmplifyUpProvider, ComponentRegistry, ComposerLayoutStatusProvider, ComposerProvider, ContentSource, Field, Field$1 as FieldEnvelope, Image, MaybeComposerProvider, PageConfig, RichText, Slot, type SlotState, bindAmplifyPage, resolveSlotState, slotShowsAddComponent, slotStateFromEl, useAmplifyUp, useComposerPreviewFlag, useInComposer };
package/dist/react.d.ts CHANGED
@@ -1,24 +1,21 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { L as LayoutComponentProps, P as PageConfig, F as Field$1, m as FIELDS_BRAND, d as AmplifyUpConfig, f as AmplifyPageContextInput, C as ContentSource, A as AmplifyContentMeta } from './types-D4TSd2Yt.js';
3
- export { x as FieldRef, y as Fields, B as ImageValue, z as ListRow, D as PortableRef, Z as ZoneConfig, o as attachFieldEnvelopes, q as composerStoreKey, p as envelopeListRows, w as isBrandedFields, u as isFieldEnvelope, v as isReadOnlyRowField, s as listOwnerFromSpec, t as toFieldEnvelopes } from './types-D4TSd2Yt.js';
4
- import react__default, { ReactNode } from 'react';
5
- export { AmplifyRenderer } from './AmplifyRenderer.js';
6
- export { 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, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-B23UsNIv.js';
2
+ import { P as PageConfig, f as AmplifyUpConfig, h as AmplifyPageContextInput, C as ContentSource, a as AmplifyContentMeta } from './types-ffQNIQCK.js';
3
+ export { Z as ZoneConfig } from './types-ffQNIQCK.js';
4
+ import react__default, { ReactNode, FC } from 'react';
5
+ import { C as ComponentRegistry } from './AmplifyRenderer-BNWBrFQN.js';
6
+ export { A as AmplifyRenderer, d as defineComponentRegistry } from './AmplifyRenderer-BNWBrFQN.js';
7
+ import { o as Field$1, p as FIELDS_BRAND } from './query-Xo9cy-2F.js';
8
+ export { A as FieldRef, B as Fields, I as ImageValue, C as LayoutComponentProps, L as ListRow, P as PortableRef, 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, r as attachFieldEnvelopes, v as composerStoreKey, u as envelopeListRows, z as isBrandedFields, x as isFieldEnvelope, y as isReadOnlyRowField, w as listOwnerFromSpec, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants, t as toFieldEnvelopes } from './query-Xo9cy-2F.js';
7
9
  export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.js';
8
10
 
9
- type RenderComponentContext = {
10
- /** Unique layout-tree node id — required when multiple instances share a component type. */
11
- layoutNodeId: string;
12
- };
13
- type RenderComponentFn = (componentId: string, props: LayoutComponentProps, slots?: Record<string, ReactNode>, context?: RenderComponentContext) => ReactNode;
14
11
  interface AmplifyPageContentProps {
15
12
  /**
16
13
  * Native page content shown to visitors when no AmplifyUp layout is configured.
17
14
  * Never rendered in Composer preview — only the layout canvas is shown there.
18
15
  */
19
16
  fallback?: ReactNode;
20
- /** Maps AmplifyUp component IDs to your React components. */
21
- renderComponent: RenderComponentFn;
17
+ /** The generated component registry. `<AmplifyPage />` passes it for you. */
18
+ registry: ComponentRegistry;
22
19
  /** SSG/ISR layout from the server. Client overlay applies only when variants differ. */
23
20
  pageConfig?: PageConfig | null;
24
21
  /**
@@ -41,7 +38,15 @@ interface AmplifyPageContentProps {
41
38
  * Live pages paint the SSG/ISR layout first. Client Edge resolve (visitor id)
42
39
  * overlays only when the personalized tree differs from that static HTML.
43
40
  */
44
- declare function AmplifyPageContent({ fallback, renderComponent, pageConfig: pageConfigProp, forceComposerPreview, previewLoadingComponent, previewEmptyComponent, loadingComponent, emptyComponent, errorComponent, }: AmplifyPageContentProps): react_jsx_runtime.JSX.Element | null;
41
+ declare function AmplifyPageContent(contentProps: AmplifyPageContentProps): react_jsx_runtime.JSX.Element | null;
42
+
43
+ type AmplifyPageProps = Omit<AmplifyPageContentProps, 'registry'>;
44
+ /**
45
+ * Used by the generated registry module to export `<AmplifyPage />`. The
46
+ * binding happens in that client module because a server `page.tsx` can't
47
+ * pass components to a client component.
48
+ */
49
+ declare const bindAmplifyPage: (registry: ComponentRegistry) => FC<AmplifyPageProps>;
45
50
 
46
51
  /**
47
52
  * True when the page is running inside AmplifyUp Composer.
@@ -57,13 +62,6 @@ declare function useInComposer(force?: boolean): boolean;
57
62
  /** @deprecated Prefer `useInComposer`. Kept for internal AmplifyPageContent. */
58
63
  declare function useComposerPreviewFlag(force?: boolean): boolean;
59
64
 
60
- declare function ComponentContextProvider({ children, slots, props, layoutNodeId, componentId, }: {
61
- children: ReactNode;
62
- slots?: Record<string, ReactNode>;
63
- props?: Record<string, any>;
64
- layoutNodeId?: string;
65
- componentId?: string;
66
- }): react_jsx_runtime.JSX.Element;
67
65
  /**
68
66
  * Slot Component
69
67
  *
@@ -230,4 +228,4 @@ interface AmplifyUpProviderProps {
230
228
  declare function AmplifyUpProvider({ children, config, pageContext, }: AmplifyUpProviderProps): react_jsx_runtime.JSX.Element;
231
229
  declare function useAmplifyUp(): AmplifyUpContextType;
232
230
 
233
- export { AmplifyContentMeta, AmplifyPageContent, AmplifyUpProvider, ComponentContextProvider, ComposerLayoutStatusProvider, ComposerProvider, ContentSource, Field, Field$1 as FieldEnvelope, Image, LayoutComponentProps, MaybeComposerProvider, PageConfig, RichText, Slot, type SlotState, resolveSlotState, slotShowsAddComponent, slotStateFromEl, useAmplifyUp, useComposerPreviewFlag, useInComposer };
231
+ export { AmplifyContentMeta, AmplifyPageContent, type AmplifyPageContentProps, type AmplifyPageProps, AmplifyUpProvider, ComponentRegistry, ComposerLayoutStatusProvider, ComposerProvider, ContentSource, Field, Field$1 as FieldEnvelope, Image, MaybeComposerProvider, PageConfig, RichText, Slot, type SlotState, bindAmplifyPage, resolveSlotState, slotShowsAddComponent, slotStateFromEl, useAmplifyUp, useComposerPreviewFlag, useInComposer };