@uniformdev/canvas 16.2.4 → 17.0.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.
@@ -1,266 +0,0 @@
1
- import Pusher from 'pusher-js';
2
-
3
- /** @deprecated use CANVAS_DRAFT_STATE and CANVAS_PUBLISHED_STATE instead */
4
- declare type CompositionFetchState = 'preview' | 'published' | number;
5
- /** The GET response from /api/v1/canvas when `component` or `slug` params are specified */
6
- declare type CompositionAPIResponse = {
7
- /** The state of the layout. See CANVAS_DRAFT_STATE and CANVAS_PUBLISHED_STATE. */
8
- state: number;
9
- /** The project ID that this layout data is part of */
10
- projectId: string;
11
- /** Layout data being read or written */
12
- composition: RootComponentInstance;
13
- /** Whether this composition is a pattern (can be referenced by other compositions) */
14
- pattern: boolean;
15
- /** Created date string for this definition */
16
- created?: string;
17
- /** Modified date string for this definition */
18
- modified?: string;
19
- };
20
- /** Shape of the DELETE request body for /api/v1/canvas */
21
- declare type CompositionAPIDeleteRequest = {
22
- /** Public ID of the composition to delete */
23
- compositionId: string;
24
- /** Project ID that the composition lives on. */
25
- projectId: string;
26
- /** The state to delete. If unspecified, all states will be deleted. See CANVAS_DRAFT_STATE and CANVAS_PUBLISHED_STATE. */
27
- state?: number;
28
- };
29
- /** The GET response from /api/v1/canvas when `component` or `slug` are not specified */
30
- declare type CompositionListAPIResponse = {
31
- compositions: Array<CompositionAPIResponse>;
32
- };
33
- /** Query parameter options for GET /api/v1/canvas */
34
- declare type CompositionAPIOptions = {
35
- /** Specify a single composition ID to fetch. Changes response from list to single. */
36
- compositionId?: string;
37
- /** Specify a single composition to fetch by slug. Changes response from list to single. */
38
- slug?: string;
39
- /** The project the composition(s) are on. */
40
- projectId: string;
41
- /** The component type to filter by */
42
- type?: string;
43
- /** Number of records to skip */
44
- offset?: number;
45
- /** Max number of records to return (defaults to 100) */
46
- limit?: number;
47
- /** State of compositions to fetch. Default = 'published' */
48
- state?: number;
49
- /**
50
- * Signals a Canvas enhancer proxy to skip processing enhancements to the data and return raw data only.
51
- * This improves performance if you do not require enhanced component data.
52
- * If calling the Canvas API directly with no enhancer proxy, this has no effect.
53
- */
54
- skipEnhance?: boolean;
55
- /**
56
- * If true, any pattern references in the composition will be left unresolved.
57
- * This is appropriate if you intend to serialize the composition data without pattern
58
- * data embedded into it, and serialize the pattern data separately.
59
- */
60
- skipPatternResolution?: boolean;
61
- };
62
- declare type ComponentParameter<TValue = unknown> = {
63
- /** The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
64
- type: string;
65
- /**
66
- * The value of the parameter.
67
- * Any JSON-serializable value is acceptable.
68
- */
69
- value: TValue;
70
- };
71
- /**
72
- * Defines the shape of a component instance served by the composition API.
73
- */
74
- declare type ComponentInstance = {
75
- /** Type of the component instance (public_id of its definition) */
76
- type: string;
77
- /** Component parameter values for the component instance */
78
- parameters?: Record<string, ComponentParameter>;
79
- /** Public ID of alternate visual appearance for this component, if any selected */
80
- variant?: string;
81
- /** Slots containing any sub-components */
82
- slots?: Record<string, ComponentInstance[]>;
83
- /** Data for the component instance, provided by a component enhancer. Never set in unenhanced data. */
84
- data?: Record<string, unknown>;
85
- /** Indicates this component instance should be sourced from a pattern library pattern */
86
- _pattern?: string;
87
- /**
88
- * If an error occurs resolving a pattern reference, it is left unresolved and this property is set to indicate why.
89
- * CYCLIC: A cyclic pattern graph was detected, which could not be resolved because it would cause an infinite loop.
90
- * NOTFOUND: The pattern ID referenced could not be found. It may have been deleted, or not be published yet.
91
- */
92
- _patternError?: 'CYCLIC' | 'NOTFOUND';
93
- };
94
- /** Defines the shape of the root component in a composition */
95
- declare type RootComponentInstance = ComponentInstance & {
96
- /** The public UUID of the composition. */
97
- _id?: string;
98
- /** Slug pattern of this component. */
99
- _slug?: string | null;
100
- /** Friendly name of this component. */
101
- _name?: string;
102
- };
103
-
104
- /** Shape of the GET response from /api/v1/canvas-definitions */
105
- declare type ComponentDefinitionAPIResponse = {
106
- componentDefinitions: Array<ComponentDefinition>;
107
- };
108
- /** Shape of the PUT request body for /api/v1/canvas-definitions */
109
- declare type ComponentDefinitionAPIPutRequest = {
110
- componentDefinition: CreatingComponentDefinition;
111
- projectId: string;
112
- };
113
- /** Shape of the DELETE request body for /api/v1/canvas-definitions */
114
- declare type ComponentDefinitionAPIDeleteRequest = {
115
- /** Public ID of the component definition to delete */
116
- componentId: string;
117
- /** Project ID that the component definition lives on */
118
- projectId: string;
119
- };
120
- /** Query parameter options for GET /api/v1/canvas-definitions */
121
- declare type ComponentDefinitionListAPIOptions = {
122
- /** Limit list to one result by ID (response remains an array) */
123
- componentId?: string;
124
- /** Number of records to skip */
125
- offset?: number;
126
- /** Max number of records to return (defaults to 100) */
127
- limit?: number;
128
- projectId: string;
129
- };
130
- /** The definition of a component parameter */
131
- declare type ComponentDefinitionParameter<TConfig = unknown> = {
132
- /** Public ID of the parameter (used in code). Do not change after creation. */
133
- id: string;
134
- /** Friendly name of the parameter */
135
- name: string;
136
- /** Appears next to the parameter in the Composition editor */
137
- helpText?: string;
138
- /** Type name of the parameter (provided by a Uniform integration) */
139
- type: string;
140
- /** The configuration object for the type (type-specific) */
141
- typeConfig?: TConfig;
142
- };
143
- /** The definition of a component variant */
144
- declare type ComponentDefinitionVariant = {
145
- /** Public ID of the variant (used in code). Do not change after creation. */
146
- id: string;
147
- /** Friendly name of the variant */
148
- name: string;
149
- };
150
- /** The definition of a component slug */
151
- declare type ComponentDefinitionSlugSettings = {
152
- /**
153
- * Is slug required
154
- * no: slug is optional
155
- * yes: slug is required
156
- * disabled: slug is disabled and will not be shown in the editor
157
- * @default no
158
- */
159
- required?: 'no' | 'yes' | 'disabled';
160
- /** Slug uniqueness configuration.
161
- * no = no unique constraint
162
- * local = must be unique within this component type
163
- * global = must be unique across all component types
164
- * @default no
165
- */
166
- unique?: 'no' | 'local' | 'global';
167
- /** Regular expression slugs must match */
168
- regularExpression?: string;
169
- /**
170
- * Custom error message when regular expression validation fails.
171
- * Has no effect if `regularExpression` is not set.
172
- */
173
- regularExpressionMessage?: string;
174
- };
175
- /** The definition of a named component slot that can contain other components */
176
- declare type ComponentDefinitionSlot = {
177
- /** Public ID of the slot (used in code). Do not change after creation. */
178
- id: string;
179
- /** Friendly name of the slot */
180
- name: string;
181
- /** Whether this slot inherits its allowed components from the parent slot it lives in. If true, allowedComponents is irrelevant. */
182
- inheritAllowedComponents: boolean;
183
- /** A list of component definition public IDs that are allowed in this named slot */
184
- allowedComponents: Array<string>;
185
- /** Minimum valid number of components in this slot */
186
- minComponents?: number;
187
- /** Maximum valid number of components in this slot */
188
- maxComponents?: number;
189
- };
190
- /** Permission set for a component defintion */
191
- declare type ComponentDefinitionPermission = {
192
- /** Role ID associated with this permission */
193
- roleId: string;
194
- /** Permission type for this defintion read | write | delete. */
195
- permission: string;
196
- /** State of the component that this permission applies to */
197
- state: number;
198
- };
199
- /** Defines a component type that can live on a Composition */
200
- declare type ComponentDefinition = {
201
- /** Public ID of the component (used in code). Do not change after creation. */
202
- id: string;
203
- /** Friendly name of the component definition */
204
- name: string;
205
- /** Icon name for the component definition (e.g. 'screen') */
206
- icon: string;
207
- /** Applicable role permissions */
208
- permissions?: Array<ComponentDefinitionPermission>;
209
- /** if this component uses team permissions or custom permissions */
210
- useTeamPermissions?: boolean;
211
- /**
212
- * The public ID of the parameter whose value should be used to create a display title for this component in the UI.
213
- * The parameter type must support being used as a title parameter for this to work.
214
- */
215
- titleParameter?: string | null;
216
- /** Whether this component type can be the root of a composition. If false, this component is only used within slots on other components. */
217
- canBeComposition?: boolean;
218
- /** The parameters for this component. Parameters are key-value pairs that can be anything from text values to links to CMS entries. */
219
- parameters?: Array<ComponentDefinitionParameter>;
220
- /** The named slots for this component; placement areas where arrays of other components can be added. */
221
- slots?: Array<ComponentDefinitionSlot>;
222
- /** Default component instance value */
223
- defaults?: ComponentInstance | null;
224
- /** Named variants for this component; enables creation of visual variants that use the same parameter data/ */
225
- variants?: Array<ComponentDefinitionVariant>;
226
- /** Setting for slug validation */
227
- slugSettings?: ComponentDefinitionSlugSettings;
228
- /** Created date string for this definition */
229
- created?: string;
230
- /** Updated date string for this definition */
231
- updated?: string;
232
- /** Modified date string for this definition */
233
- modified?: string;
234
- };
235
- /** Defines a component type that can live on a Composition, when it is being created or updated */
236
- declare type CreatingComponentDefinition = Omit<Partial<ComponentDefinition>, 'created' | 'modified' | 'id' | 'name'> & {
237
- id: string;
238
- name: string;
239
- };
240
-
241
- /**
242
- * Pusher-js is large (80k) and not tree shakable so it is always bundled if directly referenced,
243
- * when it's only needed during preview mode. To avoid bundling it for all, we use an old-school
244
- * write-a-script-tag hack to load it in a poor man's approximation of a dynamic import ;)
245
- */
246
- declare type ChannelSubscription = {
247
- addEventHandler: (eventName: string, handler: (data: unknown) => void) => () => void;
248
- unsubscribe: () => void;
249
- };
250
- declare type PreviewEventBus = {
251
- subscribe: (channel: string) => ChannelSubscription;
252
- };
253
- declare global {
254
- interface Window {
255
- Pusher?: typeof Pusher;
256
- __UNIFORM_EVENT_BUS__?: PreviewEventBus;
257
- }
258
- }
259
- /**
260
- * Creates an event bus client to receive updates from Canvas
261
- * IMPORTANT: in a server-side context this will always return undefined
262
- * IMPORTANT: in a browser context this is cached in window and does not create multiple instances
263
- */
264
- declare function createEventBus(): Promise<PreviewEventBus | undefined>;
265
-
266
- export { ComponentInstance as C, PreviewEventBus as P, RootComponentInstance as R, ComponentParameter as a, CompositionAPIOptions as b, CompositionListAPIResponse as c, CompositionAPIResponse as d, CompositionAPIDeleteRequest as e, ComponentDefinitionListAPIOptions as f, ComponentDefinitionAPIResponse as g, ComponentDefinitionAPIPutRequest as h, ComponentDefinitionAPIDeleteRequest as i, ComponentDefinitionParameter as j, ComponentDefinitionVariant as k, ComponentDefinitionSlugSettings as l, ComponentDefinitionSlot as m, ComponentDefinitionPermission as n, ComponentDefinition as o, CreatingComponentDefinition as p, CompositionFetchState as q, ChannelSubscription as r, createEventBus as s };