@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
|
@@ -1,3 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field envelopes — same shape in published, draft, and Composer edit.
|
|
3
|
+
* `{ value, name, ref? }` where `name` is the path within the owning record
|
|
4
|
+
* (`title`, `author.name`). Page-level fields omit `ref`.
|
|
5
|
+
* `ref` is stamped from the connection that produced the row
|
|
6
|
+
* (`providerId`, AmplifyUp `entity`, `id`) — never from a CMS `_type`.
|
|
7
|
+
* Produced once at the Edge resolve boundary (`fetchEdgeResolve`) and again
|
|
8
|
+
* on the SDK for `queryContent` rows.
|
|
9
|
+
*/
|
|
10
|
+
declare const FIELDS_BRAND: unique symbol;
|
|
11
|
+
type ImageValue = {
|
|
12
|
+
url: string;
|
|
13
|
+
alt?: string;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
};
|
|
17
|
+
/** Connection that produced a list row. Omitted on page-level fields. */
|
|
18
|
+
type FieldRef = {
|
|
19
|
+
providerId: string;
|
|
20
|
+
entity: string;
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
/** AmplifyUp entity + provider from the connection that produced a list. */
|
|
24
|
+
type ListOwner = {
|
|
25
|
+
providerId: string;
|
|
26
|
+
entity: string;
|
|
27
|
+
};
|
|
28
|
+
type ConnectionLike = {
|
|
29
|
+
mode?: string;
|
|
30
|
+
providerId?: string;
|
|
31
|
+
entity?: string;
|
|
32
|
+
spec?: {
|
|
33
|
+
providerId?: string;
|
|
34
|
+
entity?: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type EnvelopeSources = {
|
|
38
|
+
connections?: Record<string, ConnectionLike | null | undefined>;
|
|
39
|
+
reads?: Record<string, {
|
|
40
|
+
resource: string;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
type Field<T> = {
|
|
44
|
+
value: T;
|
|
45
|
+
name: string;
|
|
46
|
+
ref?: FieldRef;
|
|
47
|
+
/** Row field with no write target — display only in Composer. */
|
|
48
|
+
readOnly?: true;
|
|
49
|
+
};
|
|
50
|
+
/** Portable entry identity after normalize (`id` required). */
|
|
51
|
+
type PortableRef = {
|
|
52
|
+
id: string;
|
|
53
|
+
type?: string;
|
|
54
|
+
};
|
|
55
|
+
type IdentifierKey = 'id' | '_id' | 'slug' | 'key' | '_key' | 'docId' | '_type' | 'type';
|
|
56
|
+
type IsPlainObject<T> = T extends object ? T extends readonly unknown[] ? false : T extends ImageValue ? false : true : false;
|
|
57
|
+
type AsRecord<T> = T extends Record<string, unknown> ? T : Record<string, unknown>;
|
|
58
|
+
/** A list row: enveloped fields plus a plain `id`. */
|
|
59
|
+
type ListRow<T extends Record<string, unknown> = Record<string, unknown>> = Fields<T> & {
|
|
60
|
+
id: string;
|
|
61
|
+
};
|
|
62
|
+
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>;
|
|
63
|
+
type Fields<T> = {
|
|
64
|
+
readonly [FIELDS_BRAND]: true;
|
|
65
|
+
} & {
|
|
66
|
+
[K in keyof T]-?: K extends IdentifierKey ? T[K] : FieldsProp<T[K]>;
|
|
67
|
+
};
|
|
68
|
+
/** Props passed into site components. Raw CMS bags are not assignable. */
|
|
69
|
+
type LayoutComponentProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
70
|
+
fields: Fields<T>;
|
|
71
|
+
};
|
|
72
|
+
declare function isBrandedFields(value: unknown): value is Fields<Record<string, unknown>>;
|
|
73
|
+
declare function isFieldEnvelope(value: unknown): value is Field<unknown>;
|
|
74
|
+
declare function isReadOnlyRowField(value: unknown): boolean;
|
|
75
|
+
declare function composerStoreKey(name: string, ref?: FieldRef | null, layoutNodeId?: string): string;
|
|
76
|
+
declare function listOwnerFromSpec(spec: {
|
|
77
|
+
providerId?: string;
|
|
78
|
+
entity?: string;
|
|
79
|
+
} | null | undefined): ListOwner | undefined;
|
|
80
|
+
type EnvelopeScope = {
|
|
81
|
+
ref?: FieldRef;
|
|
82
|
+
readOnly?: boolean;
|
|
83
|
+
owners?: (fieldName: string) => ListOwner | undefined;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Wrap a props bag as envelopes. Already-enveloped bags are returned as-is.
|
|
87
|
+
* Nested plain objects become nested bags; portable images stay a leaf.
|
|
88
|
+
* Object arrays become list rows (`Fields` + plain `id`); `name` is the path
|
|
89
|
+
* within the record when `ref` is set.
|
|
90
|
+
*/
|
|
91
|
+
declare function toFieldEnvelopes<T extends Record<string, unknown>>(source: T | null | undefined, prefix?: string, scope?: EnvelopeScope | FieldRef): Fields<T>;
|
|
92
|
+
declare function envelopeListRows<T extends Record<string, unknown> = Record<string, unknown>>(items: unknown[], owner?: ListOwner | null): Array<ListRow<T>>;
|
|
93
|
+
/** Attach branded `fields` once. Keeps sibling keys (e.g. zoneId). */
|
|
94
|
+
declare function attachFieldEnvelopes(props: Record<string, unknown> | null | undefined, sources?: EnvelopeSources | Record<string, ConnectionLike | null | undefined>): Record<string, unknown>;
|
|
95
|
+
|
|
1
96
|
/**
|
|
2
97
|
* Runtime page-data context: validate SDK-supplied entity fields against
|
|
3
98
|
* the published pageData contract and attach to events.
|
|
@@ -266,4 +361,4 @@ interface EventTrackingConfig {
|
|
|
266
361
|
componentName?: string | null;
|
|
267
362
|
}
|
|
268
363
|
|
|
269
|
-
export { type AmplifyContentMeta as A, type ContentSource as C, type EventTrackingConfig as E, type IdentifyInput as I, type PageConfig as P, type ZoneConfig as Z, type PageDataSnapshot as a, type CDPAdapter as b, type AmplifyUpConfig as c, type EventProperties as d, type AmplifyPageContextInput as e, type AttachedPageEventContext as f, type IdentifyTraits as g, type ProfileFieldsInput as h, type AmplifyUpTarget as i, resolveAmplifyUpUrls as j, isAmplifyUpTarget as k, normalizeAmplifyUpTarget as n, resolveAmplifyUpTarget as r };
|
|
364
|
+
export { type AmplifyContentMeta as A, type PortableRef as B, type ContentSource as C, type EventTrackingConfig as E, type Field as F, type IdentifyInput as I, type LayoutComponentProps as L, type PageConfig as P, type ZoneConfig as Z, type PageDataSnapshot as a, type CDPAdapter as b, type AmplifyUpConfig as c, type EventProperties as d, type AmplifyPageContextInput as e, type AttachedPageEventContext as f, type IdentifyTraits as g, type ProfileFieldsInput as h, type AmplifyUpTarget as i, resolveAmplifyUpUrls as j, isAmplifyUpTarget as k, FIELDS_BRAND as l, attachFieldEnvelopes as m, normalizeAmplifyUpTarget as n, envelopeListRows as o, composerStoreKey as p, listOwnerFromSpec as q, resolveAmplifyUpTarget as r, isFieldEnvelope as s, toFieldEnvelopes as t, isReadOnlyRowField as u, isBrandedFields as v, type FieldRef as w, type Fields as x, type ListRow as y, type ImageValue as z };
|
package/package.json
CHANGED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { P as PageConfig } from './types-Db_eLrfU.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Field envelopes — same shape in published, draft, and Composer edit.
|
|
8
|
-
* `{ value, name }` where `name` is the full dot path (`hero.image`).
|
|
9
|
-
* Produced once at the Edge resolve boundary (`fetchEdgeResolve`).
|
|
10
|
-
*/
|
|
11
|
-
declare const FIELDS_BRAND: unique symbol;
|
|
12
|
-
type ImageValue = {
|
|
13
|
-
url: string;
|
|
14
|
-
alt?: string;
|
|
15
|
-
width?: number;
|
|
16
|
-
height?: number;
|
|
17
|
-
};
|
|
18
|
-
type Field<T> = {
|
|
19
|
-
value: T;
|
|
20
|
-
name: string;
|
|
21
|
-
};
|
|
22
|
-
/** Portable entry ref after normalize (`id` required). */
|
|
23
|
-
type PortableRef = {
|
|
24
|
-
id: string;
|
|
25
|
-
type?: string;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Repeater envelope: each item is a `Fields` bag.
|
|
29
|
-
* Paths are dotted indexes (`slides.0.title`).
|
|
30
|
-
*/
|
|
31
|
-
type CollectionField<T extends Record<string, unknown>> = {
|
|
32
|
-
value: Array<Fields<T>>;
|
|
33
|
-
name: string;
|
|
34
|
-
};
|
|
35
|
-
type IsPlainObject<T> = T extends object ? T extends readonly unknown[] ? false : T extends ImageValue ? false : true : false;
|
|
36
|
-
/** Resolved / authored entry refs carry `id` (see `stampPlatformIdentity`). */
|
|
37
|
-
type IsEntryRefItem<T> = T extends {
|
|
38
|
-
id: string;
|
|
39
|
-
} ? true : false;
|
|
40
|
-
type AsRecord<T> = T extends Record<string, unknown> ? T : Record<string, unknown>;
|
|
41
|
-
type FieldsProp<T> = NonNullable<T> extends ImageValue ? Field<T | null> : NonNullable<T> extends readonly (infer U)[] ? IsEntryRefItem<U> extends true ? Field<T> : IsPlainObject<U> extends true ? CollectionField<AsRecord<U>> : Field<T> : IsPlainObject<NonNullable<T>> extends true ? Fields<NonNullable<T>> : Field<T>;
|
|
42
|
-
type Fields<T> = {
|
|
43
|
-
readonly [FIELDS_BRAND]: true;
|
|
44
|
-
} & {
|
|
45
|
-
[K in keyof T]-?: FieldsProp<T[K]>;
|
|
46
|
-
};
|
|
47
|
-
/** Props passed into site components. Raw CMS bags are not assignable. */
|
|
48
|
-
type LayoutComponentProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
49
|
-
fields: Fields<T>;
|
|
50
|
-
};
|
|
51
|
-
declare function isBrandedFields(value: unknown): value is Fields<Record<string, unknown>>;
|
|
52
|
-
declare function isFieldEnvelope(value: unknown): value is Field<unknown>;
|
|
53
|
-
/**
|
|
54
|
-
* Wrap a props bag as envelopes. Already-enveloped bags are returned as-is.
|
|
55
|
-
* Nested plain objects become nested bags; portable images stay a leaf.
|
|
56
|
-
*/
|
|
57
|
-
declare function toFieldEnvelopes<T extends Record<string, unknown>>(source: T | null | undefined, prefix?: string): Fields<T>;
|
|
58
|
-
|
|
59
|
-
interface AmplifyRendererProps {
|
|
60
|
-
/**
|
|
61
|
-
* Component renderer function that maps componentId to React component
|
|
62
|
-
* This is site-specific and must be provided by the developer
|
|
63
|
-
*/
|
|
64
|
-
renderComponent: (componentId: string, props: LayoutComponentProps, slots?: Record<string, ReactNode>, context?: {
|
|
65
|
-
layoutNodeId: string;
|
|
66
|
-
}) => ReactNode;
|
|
67
|
-
/**
|
|
68
|
-
* Optional page config for server-side rendering (SSR/SSG)
|
|
69
|
-
* If provided, the component will use this instead of fetching client-side
|
|
70
|
-
*/
|
|
71
|
-
pageConfig?: PageConfig;
|
|
72
|
-
/**
|
|
73
|
-
* Optional loading component
|
|
74
|
-
*/
|
|
75
|
-
loadingComponent?: ReactNode;
|
|
76
|
-
/**
|
|
77
|
-
* Optional error component
|
|
78
|
-
*/
|
|
79
|
-
errorComponent?: (error: string) => ReactNode;
|
|
80
|
-
/**
|
|
81
|
-
* Optional empty state component (when no content is configured)
|
|
82
|
-
*/
|
|
83
|
-
emptyComponent?: ReactNode;
|
|
84
|
-
/**
|
|
85
|
-
* Force Composer page-slot wrapper (avoids SSR miss when window isn't available yet).
|
|
86
|
-
* When true, root components stay under [data-slot-source="page"] so hierarchy can climb to Page.
|
|
87
|
-
*/
|
|
88
|
-
composerPreview?: boolean;
|
|
89
|
-
}
|
|
90
|
-
declare function AmplifyRendererInner({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, composerPreview, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
91
|
-
declare const AmplifyRenderer: react.MemoExoticComponent<typeof AmplifyRendererInner>;
|
|
92
|
-
|
|
93
|
-
export { AmplifyRenderer as A, type CollectionField as C, type Field as F, type ImageValue as I, type LayoutComponentProps as L, type PortableRef as P, type Fields as a, isBrandedFields as b, isFieldEnvelope as i, toFieldEnvelopes as t };
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { P as PageConfig } from './types-Db_eLrfU.mjs';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Field envelopes — same shape in published, draft, and Composer edit.
|
|
8
|
-
* `{ value, name }` where `name` is the full dot path (`hero.image`).
|
|
9
|
-
* Produced once at the Edge resolve boundary (`fetchEdgeResolve`).
|
|
10
|
-
*/
|
|
11
|
-
declare const FIELDS_BRAND: unique symbol;
|
|
12
|
-
type ImageValue = {
|
|
13
|
-
url: string;
|
|
14
|
-
alt?: string;
|
|
15
|
-
width?: number;
|
|
16
|
-
height?: number;
|
|
17
|
-
};
|
|
18
|
-
type Field<T> = {
|
|
19
|
-
value: T;
|
|
20
|
-
name: string;
|
|
21
|
-
};
|
|
22
|
-
/** Portable entry ref after normalize (`id` required). */
|
|
23
|
-
type PortableRef = {
|
|
24
|
-
id: string;
|
|
25
|
-
type?: string;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Repeater envelope: each item is a `Fields` bag.
|
|
29
|
-
* Paths are dotted indexes (`slides.0.title`).
|
|
30
|
-
*/
|
|
31
|
-
type CollectionField<T extends Record<string, unknown>> = {
|
|
32
|
-
value: Array<Fields<T>>;
|
|
33
|
-
name: string;
|
|
34
|
-
};
|
|
35
|
-
type IsPlainObject<T> = T extends object ? T extends readonly unknown[] ? false : T extends ImageValue ? false : true : false;
|
|
36
|
-
/** Resolved / authored entry refs carry `id` (see `stampPlatformIdentity`). */
|
|
37
|
-
type IsEntryRefItem<T> = T extends {
|
|
38
|
-
id: string;
|
|
39
|
-
} ? true : false;
|
|
40
|
-
type AsRecord<T> = T extends Record<string, unknown> ? T : Record<string, unknown>;
|
|
41
|
-
type FieldsProp<T> = NonNullable<T> extends ImageValue ? Field<T | null> : NonNullable<T> extends readonly (infer U)[] ? IsEntryRefItem<U> extends true ? Field<T> : IsPlainObject<U> extends true ? CollectionField<AsRecord<U>> : Field<T> : IsPlainObject<NonNullable<T>> extends true ? Fields<NonNullable<T>> : Field<T>;
|
|
42
|
-
type Fields<T> = {
|
|
43
|
-
readonly [FIELDS_BRAND]: true;
|
|
44
|
-
} & {
|
|
45
|
-
[K in keyof T]-?: FieldsProp<T[K]>;
|
|
46
|
-
};
|
|
47
|
-
/** Props passed into site components. Raw CMS bags are not assignable. */
|
|
48
|
-
type LayoutComponentProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
49
|
-
fields: Fields<T>;
|
|
50
|
-
};
|
|
51
|
-
declare function isBrandedFields(value: unknown): value is Fields<Record<string, unknown>>;
|
|
52
|
-
declare function isFieldEnvelope(value: unknown): value is Field<unknown>;
|
|
53
|
-
/**
|
|
54
|
-
* Wrap a props bag as envelopes. Already-enveloped bags are returned as-is.
|
|
55
|
-
* Nested plain objects become nested bags; portable images stay a leaf.
|
|
56
|
-
*/
|
|
57
|
-
declare function toFieldEnvelopes<T extends Record<string, unknown>>(source: T | null | undefined, prefix?: string): Fields<T>;
|
|
58
|
-
|
|
59
|
-
interface AmplifyRendererProps {
|
|
60
|
-
/**
|
|
61
|
-
* Component renderer function that maps componentId to React component
|
|
62
|
-
* This is site-specific and must be provided by the developer
|
|
63
|
-
*/
|
|
64
|
-
renderComponent: (componentId: string, props: LayoutComponentProps, slots?: Record<string, ReactNode>, context?: {
|
|
65
|
-
layoutNodeId: string;
|
|
66
|
-
}) => ReactNode;
|
|
67
|
-
/**
|
|
68
|
-
* Optional page config for server-side rendering (SSR/SSG)
|
|
69
|
-
* If provided, the component will use this instead of fetching client-side
|
|
70
|
-
*/
|
|
71
|
-
pageConfig?: PageConfig;
|
|
72
|
-
/**
|
|
73
|
-
* Optional loading component
|
|
74
|
-
*/
|
|
75
|
-
loadingComponent?: ReactNode;
|
|
76
|
-
/**
|
|
77
|
-
* Optional error component
|
|
78
|
-
*/
|
|
79
|
-
errorComponent?: (error: string) => ReactNode;
|
|
80
|
-
/**
|
|
81
|
-
* Optional empty state component (when no content is configured)
|
|
82
|
-
*/
|
|
83
|
-
emptyComponent?: ReactNode;
|
|
84
|
-
/**
|
|
85
|
-
* Force Composer page-slot wrapper (avoids SSR miss when window isn't available yet).
|
|
86
|
-
* When true, root components stay under [data-slot-source="page"] so hierarchy can climb to Page.
|
|
87
|
-
*/
|
|
88
|
-
composerPreview?: boolean;
|
|
89
|
-
}
|
|
90
|
-
declare function AmplifyRendererInner({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, composerPreview, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
91
|
-
declare const AmplifyRenderer: react.MemoExoticComponent<typeof AmplifyRendererInner>;
|
|
92
|
-
|
|
93
|
-
export { AmplifyRenderer as A, type CollectionField as C, type Field as F, type ImageValue as I, type LayoutComponentProps as L, type PortableRef as P, type Fields as a, isBrandedFields as b, isFieldEnvelope as i, toFieldEnvelopes as t };
|