@builder.io/sdk 2.0.6 → 2.0.7
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/CHANGELOG.md +18 -0
- package/dist/index.browser.js +2726 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +29 -31
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.esm.js +22 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +31 -30
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +13 -9
- package/dist/src/builder.class.d.ts +862 -862
- package/dist/src/classes/animator.class.d.ts +26 -26
- package/dist/src/classes/cookies.class.d.ts +15 -15
- package/dist/src/classes/observable.class.d.ts +27 -27
- package/dist/src/classes/promise.class.d.ts +17 -17
- package/dist/src/classes/query-string.class.d.ts +9 -9
- package/dist/src/classes/query-string.class.test.d.ts +1 -1
- package/dist/src/constants/builder.d.ts +2 -2
- package/dist/src/functions/assign.function.d.ts +1 -1
- package/dist/src/functions/fetch.function.d.ts +28 -28
- package/dist/src/functions/finder.function.d.ts +10 -10
- package/dist/src/functions/get-top-level-domain.d.ts +6 -6
- package/dist/src/functions/next-tick.function.d.ts +2 -1
- package/dist/src/functions/omit.function.d.ts +1 -1
- package/dist/src/functions/server-only-require.function.d.ts +3 -3
- package/dist/src/functions/throttle.function.d.ts +1 -1
- package/dist/src/functions/to-error.d.ts +13 -13
- package/dist/src/functions/uuid.d.ts +8 -8
- package/dist/src/types/api-version.d.ts +2 -2
- package/dist/src/types/content.d.ts +31 -31
- package/dist/src/types/element.d.ts +60 -60
- package/dist/src/url.d.ts +9 -9
- package/dist/src/url.test.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -9
- package/project.json +4 -0
|
@@ -1,862 +1,862 @@
|
|
|
1
|
-
/// <reference types="@types/node" />
|
|
2
|
-
import './polyfills/custom-event-polyfill';
|
|
3
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
4
|
-
import { nextTick } from './functions/next-tick.function';
|
|
5
|
-
import { BehaviorSubject } from './classes/observable.class';
|
|
6
|
-
import { throttle } from './functions/throttle.function';
|
|
7
|
-
import { Animator } from './classes/animator.class';
|
|
8
|
-
import { BuilderElement } from './types/element';
|
|
9
|
-
import Cookies from './classes/cookies.class';
|
|
10
|
-
import { BuilderContent } from './types/content';
|
|
11
|
-
import { ApiVersion } from './types/api-version';
|
|
12
|
-
export type Url = any;
|
|
13
|
-
export declare const isReactNative: boolean;
|
|
14
|
-
export declare const validEnvList: string[];
|
|
15
|
-
export declare const isBrowser: boolean;
|
|
16
|
-
export declare const isIframe: boolean;
|
|
17
|
-
export interface ParamsMap {
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
}
|
|
20
|
-
type TrackingHook = (eventData: Event, context: {
|
|
21
|
-
content?: BuilderContent;
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
}) => Event | undefined;
|
|
24
|
-
interface EventData {
|
|
25
|
-
contentId?: string;
|
|
26
|
-
ownerId: string;
|
|
27
|
-
variationId?: string;
|
|
28
|
-
userAttributes?: any;
|
|
29
|
-
targetSelector?: string;
|
|
30
|
-
targetBuilderElement?: string;
|
|
31
|
-
unique?: boolean;
|
|
32
|
-
metadata?: any | string;
|
|
33
|
-
meta?: any | string;
|
|
34
|
-
sessionId?: string;
|
|
35
|
-
visitorId?: string;
|
|
36
|
-
amount?: number;
|
|
37
|
-
}
|
|
38
|
-
interface Event {
|
|
39
|
-
type: string;
|
|
40
|
-
data: EventData;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Attributes that can be used for custom targeting. {@link
|
|
44
|
-
* https://www.builder.io/c/docs/guides/targeting-and-scheduling}
|
|
45
|
-
*/
|
|
46
|
-
export interface UserAttributes {
|
|
47
|
-
[key: string]: undefined | string | string[] | boolean | boolean[] | number | number[] | Record<string, any>;
|
|
48
|
-
/**
|
|
49
|
-
* URL path of the current user.
|
|
50
|
-
*/
|
|
51
|
-
urlPath?: string;
|
|
52
|
-
/**
|
|
53
|
-
* @deprecated
|
|
54
|
-
* @hidden
|
|
55
|
-
*/
|
|
56
|
-
queryString?: string | ParamsMap;
|
|
57
|
-
/**
|
|
58
|
-
* @deprecated
|
|
59
|
-
* @hidden
|
|
60
|
-
*/
|
|
61
|
-
device?: 'mobile' | 'tablet' | 'desktop';
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated
|
|
64
|
-
* @hidden
|
|
65
|
-
*/
|
|
66
|
-
location?: any;
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated
|
|
69
|
-
* @hidden
|
|
70
|
-
*/
|
|
71
|
-
userAgent?: string;
|
|
72
|
-
/**
|
|
73
|
-
* @deprecated
|
|
74
|
-
* @hidden
|
|
75
|
-
*/
|
|
76
|
-
referrer?: string;
|
|
77
|
-
/**
|
|
78
|
-
* @deprecated
|
|
79
|
-
* @hidden
|
|
80
|
-
*/
|
|
81
|
-
entryMedium?: string;
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated
|
|
84
|
-
* @hidden
|
|
85
|
-
*/
|
|
86
|
-
language?: string;
|
|
87
|
-
/**
|
|
88
|
-
* @deprecated
|
|
89
|
-
* @hidden
|
|
90
|
-
*/
|
|
91
|
-
browser?: string;
|
|
92
|
-
/**
|
|
93
|
-
* @deprecated
|
|
94
|
-
* @hidden
|
|
95
|
-
*/
|
|
96
|
-
cookie?: string;
|
|
97
|
-
/**
|
|
98
|
-
* @deprecated
|
|
99
|
-
* @hidden
|
|
100
|
-
*/
|
|
101
|
-
newVisitor?: boolean;
|
|
102
|
-
/**
|
|
103
|
-
* @deprecated
|
|
104
|
-
* @hidden
|
|
105
|
-
*/
|
|
106
|
-
operatingSystem?: string;
|
|
107
|
-
}
|
|
108
|
-
type AllowEnrich = {
|
|
109
|
-
apiVersion?: Extract<ApiVersion, 'v1'>;
|
|
110
|
-
} | {
|
|
111
|
-
apiVersion?: Extract<ApiVersion, 'v3'>;
|
|
112
|
-
enrich?: boolean;
|
|
113
|
-
} | {
|
|
114
|
-
apiVersion?: never;
|
|
115
|
-
enrich?: boolean;
|
|
116
|
-
};
|
|
117
|
-
export type GetContentOptions = AllowEnrich & {
|
|
118
|
-
/**
|
|
119
|
-
* User attribute key value pairs to be used for targeting
|
|
120
|
-
* https://www.builder.io/c/docs/custom-targeting-attributes
|
|
121
|
-
*
|
|
122
|
-
* e.g.
|
|
123
|
-
* ```js
|
|
124
|
-
* userAttributes: {
|
|
125
|
-
* urlPath: '/',
|
|
126
|
-
* returnVisitor: true,
|
|
127
|
-
* }
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
userAttributes?: UserAttributes;
|
|
131
|
-
/**
|
|
132
|
-
* Alias for userAttributes.urlPath except it can handle a full URL (optionally with host,
|
|
133
|
-
* protocol, query, etc) and we will parse out the path.
|
|
134
|
-
*/
|
|
135
|
-
url?: string;
|
|
136
|
-
/**
|
|
137
|
-
* @package
|
|
138
|
-
*/
|
|
139
|
-
includeUrl?: boolean;
|
|
140
|
-
/**
|
|
141
|
-
* Follow references. If you use the `reference` field to pull in other content without this
|
|
142
|
-
* enabled we will not fetch that content for the final response.
|
|
143
|
-
* @deprecated use `enrich` instead
|
|
144
|
-
*/
|
|
145
|
-
includeRefs?: boolean;
|
|
146
|
-
/**
|
|
147
|
-
* How long in seconds content should be cached for. Sets the max-age of the cache-control header
|
|
148
|
-
* response header.
|
|
149
|
-
*
|
|
150
|
-
* Use a higher value for better performance, lower for content that will change more frequently
|
|
151
|
-
*
|
|
152
|
-
* @see {@link https://www.builder.io/c/docs/query-api#__next:~:text=%26includeRefs%3Dtrue-,cacheSeconds,-No}
|
|
153
|
-
*/
|
|
154
|
-
cacheSeconds?: number;
|
|
155
|
-
/**
|
|
156
|
-
* Builder.io uses stale-while-revalidate caching at the CDN level. This means we always serve
|
|
157
|
-
* from edge cache and update caches in the background for maximum possible performance. This also
|
|
158
|
-
* means that the more frequently content is requested, the more fresh it will be. The longest we
|
|
159
|
-
* will ever hold something in stale cache is 1 day by default, and you can set this to be shorter
|
|
160
|
-
* yourself as well. We suggest keeping this high unless you have content that must change rapidly
|
|
161
|
-
* and gets very little traffic.
|
|
162
|
-
*
|
|
163
|
-
* @see {@link https://www.fastly.com/blog/prevent-application-network-instability-serve-stale-content}
|
|
164
|
-
*/
|
|
165
|
-
staleCacheSeconds?: number;
|
|
166
|
-
/**
|
|
167
|
-
* Maximum number of results to return. Defaults to `1`.
|
|
168
|
-
*/
|
|
169
|
-
limit?: number;
|
|
170
|
-
/**
|
|
171
|
-
* Mongodb style query of your data. E.g.:
|
|
172
|
-
*
|
|
173
|
-
* ```js
|
|
174
|
-
* query: {
|
|
175
|
-
* id: 'abc123',
|
|
176
|
-
* data: {
|
|
177
|
-
* myCustomField: { $gt: 20 },
|
|
178
|
-
* }
|
|
179
|
-
* }
|
|
180
|
-
* ```
|
|
181
|
-
*
|
|
182
|
-
* See more info on MongoDB's query operators and format.
|
|
183
|
-
*
|
|
184
|
-
* @see {@link https://docs.mongodb.com/manual/reference/operator/query/}
|
|
185
|
-
*/
|
|
186
|
-
query?: any;
|
|
187
|
-
/**
|
|
188
|
-
* Bust through all caches. Not recommended for production (for performance),
|
|
189
|
-
* but can be useful for development and static builds (so the static site has
|
|
190
|
-
* fully fresh / up to date content)
|
|
191
|
-
*/
|
|
192
|
-
cachebust?: boolean;
|
|
193
|
-
/**
|
|
194
|
-
* Convert any visual builder content to HTML.
|
|
195
|
-
*
|
|
196
|
-
* This will be on data.html of the response's content entry object json.
|
|
197
|
-
*/
|
|
198
|
-
prerender?: boolean;
|
|
199
|
-
/**
|
|
200
|
-
* Extract any styles to a separate css property when generating HTML.
|
|
201
|
-
*/
|
|
202
|
-
extractCss?: boolean;
|
|
203
|
-
/**
|
|
204
|
-
* Pagination results offset. Defaults to zero.
|
|
205
|
-
*/
|
|
206
|
-
offset?: number;
|
|
207
|
-
/**
|
|
208
|
-
* @package
|
|
209
|
-
*
|
|
210
|
-
* `BuilderContent` to render instead of fetching.
|
|
211
|
-
*/
|
|
212
|
-
initialContent?: any;
|
|
213
|
-
/**
|
|
214
|
-
* The name of the model to fetch content for.
|
|
215
|
-
*/
|
|
216
|
-
model?: string;
|
|
217
|
-
/**
|
|
218
|
-
* Set to `false` to not cache responses when running on the client.
|
|
219
|
-
*/
|
|
220
|
-
cache?: boolean;
|
|
221
|
-
/**
|
|
222
|
-
* Set to the current locale in your application if you want localized inputs to be auto-resolved, should match one of the locales keys in your space settings
|
|
223
|
-
* Learn more about adding or removing locales [here](https://www.builder.io/c/docs/add-remove-locales)
|
|
224
|
-
*/
|
|
225
|
-
locale?: string;
|
|
226
|
-
/**
|
|
227
|
-
* @package
|
|
228
|
-
*
|
|
229
|
-
* Indicate that the fetch request is for preview purposes.
|
|
230
|
-
*/
|
|
231
|
-
preview?: boolean;
|
|
232
|
-
/**
|
|
233
|
-
* Specific content entry ID to fetch.
|
|
234
|
-
*/
|
|
235
|
-
entry?: string;
|
|
236
|
-
/**
|
|
237
|
-
* @package
|
|
238
|
-
* @deprecated
|
|
239
|
-
* @hidden
|
|
240
|
-
*/
|
|
241
|
-
alias?: string;
|
|
242
|
-
fields?: string;
|
|
243
|
-
/**
|
|
244
|
-
* Omit only these fields.
|
|
245
|
-
*
|
|
246
|
-
* @example
|
|
247
|
-
* ```
|
|
248
|
-
* &omit=data.bigField,data.blocks
|
|
249
|
-
* ```
|
|
250
|
-
*/
|
|
251
|
-
omit?: string;
|
|
252
|
-
key?: string;
|
|
253
|
-
/**
|
|
254
|
-
* @package
|
|
255
|
-
*
|
|
256
|
-
* Affects HTML generation for specific targets.
|
|
257
|
-
*/
|
|
258
|
-
format?: 'amp' | 'email' | 'html' | 'react' | 'solid';
|
|
259
|
-
/**
|
|
260
|
-
* @deprecated
|
|
261
|
-
* @hidden
|
|
262
|
-
*/
|
|
263
|
-
noWrap?: true;
|
|
264
|
-
/**
|
|
265
|
-
* @package
|
|
266
|
-
*
|
|
267
|
-
* Specific string to use for cache busting. e.g. every time we generate
|
|
268
|
-
* HTML we generate a rev (a revision ID) and we send that with each request
|
|
269
|
-
* on the client, such that if we generate new server HTML we get a new rev
|
|
270
|
-
* and we use that to bust the cache because even though the content ID may
|
|
271
|
-
* be the same, it could be an updated version of this content that needs to
|
|
272
|
-
* be fresh.
|
|
273
|
-
*/
|
|
274
|
-
rev?: string;
|
|
275
|
-
/**
|
|
276
|
-
* @package
|
|
277
|
-
*
|
|
278
|
-
* Tell the API that when generating HTML to generate it in static mode for
|
|
279
|
-
* a/b tests instead of the older way we did this
|
|
280
|
-
*/
|
|
281
|
-
static?: boolean;
|
|
282
|
-
/**
|
|
283
|
-
* Additional query params of the Content API to send.
|
|
284
|
-
*/
|
|
285
|
-
options?: {
|
|
286
|
-
[key: string]: any;
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
* @package
|
|
290
|
-
*
|
|
291
|
-
* Don't listen to updates in the editor - this is useful for embedded
|
|
292
|
-
* symbols so they don't accidentally listen to messages as you are editing
|
|
293
|
-
* content thinking they should updates when they actually shouldn't.
|
|
294
|
-
*/
|
|
295
|
-
noEditorUpdates?: boolean;
|
|
296
|
-
};
|
|
297
|
-
export type Class = {
|
|
298
|
-
name?: string;
|
|
299
|
-
new (...args: any[]): any;
|
|
300
|
-
};
|
|
301
|
-
interface Map<K, V> {
|
|
302
|
-
clear(): void;
|
|
303
|
-
delete(key: K): boolean;
|
|
304
|
-
entries(): IterableIterator<[K, V]>;
|
|
305
|
-
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
|
|
306
|
-
get(key: K): V;
|
|
307
|
-
has(key: K): boolean;
|
|
308
|
-
keys(): IterableIterator<K>;
|
|
309
|
-
set(key: K, value?: V): Map<K, V>;
|
|
310
|
-
size: number;
|
|
311
|
-
values(): IterableIterator<V>;
|
|
312
|
-
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* This is the interface for inputs in `Builder.registerComponent`
|
|
316
|
-
*
|
|
317
|
-
* ```js
|
|
318
|
-
* Builder.registerComponent(MyComponent, {
|
|
319
|
-
* inputs: [{ name: 'title', type: 'text' }] // <- Input[]
|
|
320
|
-
* })
|
|
321
|
-
* ```
|
|
322
|
-
*
|
|
323
|
-
* Learn more about registering custom components [here](https://www.builder.io/c/docs/custom-react-components)
|
|
324
|
-
*/
|
|
325
|
-
export interface Input {
|
|
326
|
-
/** This is the name of the component prop this input represents */
|
|
327
|
-
name: string;
|
|
328
|
-
/** A friendlier name to show in the UI if the component prop name is not ideal for end users */
|
|
329
|
-
friendlyName?: string;
|
|
330
|
-
/** @hidden @deprecated */
|
|
331
|
-
description?: string;
|
|
332
|
-
/** A default value to use */
|
|
333
|
-
defaultValue?: any;
|
|
334
|
-
/**
|
|
335
|
-
* The type of input to use, such as 'text'
|
|
336
|
-
*
|
|
337
|
-
* See all available inputs [here](https://www.builder.io/c/docs/custom-react-components#input-types)
|
|
338
|
-
* and you can create your own custom input types and associated editor UIs with [plugins](https://www.builder.io/c/docs/extending/plugins)
|
|
339
|
-
*/
|
|
340
|
-
type: string;
|
|
341
|
-
/** Is this input mandatory or not */
|
|
342
|
-
required?: boolean;
|
|
343
|
-
/** @hidden */
|
|
344
|
-
autoFocus?: boolean;
|
|
345
|
-
subFields?: Input[];
|
|
346
|
-
/**
|
|
347
|
-
* Additional text to render in the UI to give guidance on how to use this
|
|
348
|
-
*
|
|
349
|
-
* @example
|
|
350
|
-
* ```js
|
|
351
|
-
* helperText: 'Be sure to use a proper URL, starting with "https://"'
|
|
352
|
-
* 111
|
|
353
|
-
*/
|
|
354
|
-
helperText?: string;
|
|
355
|
-
/** @hidden */
|
|
356
|
-
allowedFileTypes?: string[];
|
|
357
|
-
/** @hidden */
|
|
358
|
-
imageHeight?: number;
|
|
359
|
-
/** @hidden */
|
|
360
|
-
imageWidth?: number;
|
|
361
|
-
/** @hidden */
|
|
362
|
-
mediaHeight?: number;
|
|
363
|
-
/** @hidden */
|
|
364
|
-
mediaWidth?: number;
|
|
365
|
-
/** @hidden */
|
|
366
|
-
hideFromUI?: boolean;
|
|
367
|
-
/** @hidden */
|
|
368
|
-
modelId?: string;
|
|
369
|
-
/**
|
|
370
|
-
* Number field type validation maximum accepted input
|
|
371
|
-
*/
|
|
372
|
-
max?: number;
|
|
373
|
-
/**
|
|
374
|
-
* Number field type validation minimum accepted input
|
|
375
|
-
*/
|
|
376
|
-
min?: number;
|
|
377
|
-
/**
|
|
378
|
-
* Number field type step size when using arrows
|
|
379
|
-
*/
|
|
380
|
-
step?: number;
|
|
381
|
-
/**
|
|
382
|
-
* Set this to `true` to show the editor for this input when
|
|
383
|
-
* children of this component are selected. This is useful for things
|
|
384
|
-
* like Tabs, such that users may not always select the Tabs component
|
|
385
|
-
* directly but will still be looking for how to add additional tabs
|
|
386
|
-
*/
|
|
387
|
-
broadcast?: boolean;
|
|
388
|
-
/**
|
|
389
|
-
* Set this to `true` to show the editor for this input when
|
|
390
|
-
* group locked parents of this component are selected. This is useful
|
|
391
|
-
* to bubble up important inputs for locked groups, like text and images
|
|
392
|
-
*/
|
|
393
|
-
bubble?: boolean;
|
|
394
|
-
/**
|
|
395
|
-
* Set this to `true` if you want this component to be translatable
|
|
396
|
-
*/
|
|
397
|
-
localized?: boolean;
|
|
398
|
-
/** @hidden */
|
|
399
|
-
options?: {
|
|
400
|
-
[key: string]: any;
|
|
401
|
-
};
|
|
402
|
-
/**
|
|
403
|
-
* For "text" input type, specifying an enum will show a dropdown of options instead
|
|
404
|
-
*/
|
|
405
|
-
enum?: string[] | {
|
|
406
|
-
label: string;
|
|
407
|
-
value: string | number | boolean;
|
|
408
|
-
helperText?: string;
|
|
409
|
-
}[];
|
|
410
|
-
/** Regex field validation for all string types (text, longText, html, url, etc) */
|
|
411
|
-
regex?: {
|
|
412
|
-
/** pattern to test, like "^\/[a-z]$" */
|
|
413
|
-
pattern: string;
|
|
414
|
-
/** flags for the RegExp constructor, e.g. "gi" */
|
|
415
|
-
options?: string;
|
|
416
|
-
/**
|
|
417
|
-
* Friendly message to display to end-users if the regex fails, e.g.
|
|
418
|
-
* "You must use a relative url starting with '/...' "
|
|
419
|
-
*/
|
|
420
|
-
message: string;
|
|
421
|
-
};
|
|
422
|
-
/**
|
|
423
|
-
* Set this to `true` to put this under the "show more" section of
|
|
424
|
-
* the options editor. Useful for things that are more advanced
|
|
425
|
-
* or more rarely used and don't need to be too prominent
|
|
426
|
-
*/
|
|
427
|
-
advanced?: boolean;
|
|
428
|
-
/** @hidden */
|
|
429
|
-
onChange?: Function | string;
|
|
430
|
-
/** @hidden */
|
|
431
|
-
code?: boolean;
|
|
432
|
-
/** @hidden */
|
|
433
|
-
richText?: boolean;
|
|
434
|
-
/** @hidden */
|
|
435
|
-
showIf?: ((options: Map<string, any>) => boolean) | string;
|
|
436
|
-
/** @hidden */
|
|
437
|
-
copyOnAdd?: boolean;
|
|
438
|
-
/**
|
|
439
|
-
* Use optionally with inputs of type `reference`. Restricts the content entry picker to a specific model by name.
|
|
440
|
-
*/
|
|
441
|
-
model?: string;
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* This is the interface for the options for `Builder.registerComponent`
|
|
445
|
-
*
|
|
446
|
-
* ```js
|
|
447
|
-
* Builder.registerComponent(YourComponent, {
|
|
448
|
-
* // <- Component options
|
|
449
|
-
* })
|
|
450
|
-
* ```
|
|
451
|
-
*
|
|
452
|
-
* Learn more about registering custom components [here](https://www.builder.io/c/docs/custom-react-components)
|
|
453
|
-
*/
|
|
454
|
-
export interface Component {
|
|
455
|
-
/**
|
|
456
|
-
* Name your component something unique, e.g. 'MyButton'. You can override built-in components
|
|
457
|
-
* by registering a component with the same name, e.g. 'Text', to replace the built-in text component
|
|
458
|
-
*/
|
|
459
|
-
name: string;
|
|
460
|
-
/** @hidden @deprecated */
|
|
461
|
-
description?: string;
|
|
462
|
-
/**
|
|
463
|
-
* Link to a documentation page for this component
|
|
464
|
-
*/
|
|
465
|
-
docsLink?: string;
|
|
466
|
-
/**
|
|
467
|
-
* Link to an image to be used as an icon for this component in Builder's editor
|
|
468
|
-
*
|
|
469
|
-
* @example
|
|
470
|
-
* ```js
|
|
471
|
-
* image: 'https://some-cdn.com/my-icon-for-this-component.png'
|
|
472
|
-
* ```
|
|
473
|
-
*/
|
|
474
|
-
image?: string;
|
|
475
|
-
/**
|
|
476
|
-
* Link to a screenshot shown when user hovers over the component in Builder's editor
|
|
477
|
-
* use https://builder.io/upload to upload your screeshot, for easier resizing by Builder.
|
|
478
|
-
*/
|
|
479
|
-
screenshot?: string;
|
|
480
|
-
/**
|
|
481
|
-
* When overriding built-in components, if you don't want any special behavior that
|
|
482
|
-
* the original has, set this to `true` to skip the default behavior
|
|
483
|
-
*
|
|
484
|
-
* Default behaviors include special "virtual options", such as a custom
|
|
485
|
-
* aspect ratio editor for Images, or a special column editor for Columns
|
|
486
|
-
*
|
|
487
|
-
* Learn more about overriding built-in components here: https://www.builder.io/c/docs/custom-components-overriding
|
|
488
|
-
*/
|
|
489
|
-
override?: boolean;
|
|
490
|
-
/**
|
|
491
|
-
* Input schema for your component for users to fill in the options via a UI
|
|
492
|
-
* that translate to this components props
|
|
493
|
-
*/
|
|
494
|
-
inputs?: Input[];
|
|
495
|
-
/** @hidden @deprecated */
|
|
496
|
-
class?: any;
|
|
497
|
-
/** @hidden @deprecated */
|
|
498
|
-
type?: 'angular' | 'webcomponent' | 'react' | 'vue';
|
|
499
|
-
/**
|
|
500
|
-
* Default styles to apply when droppged into the Builder.io editor
|
|
501
|
-
*
|
|
502
|
-
* @example
|
|
503
|
-
* ```js
|
|
504
|
-
* defaultStyles: {
|
|
505
|
-
* // large (default) breakpoint
|
|
506
|
-
* large: {
|
|
507
|
-
* backgroundColor: 'black'
|
|
508
|
-
* },
|
|
509
|
-
* }
|
|
510
|
-
* ```
|
|
511
|
-
*/
|
|
512
|
-
defaultStyles?: {
|
|
513
|
-
[key: string]: string;
|
|
514
|
-
};
|
|
515
|
-
/**
|
|
516
|
-
* Turn on if your component can accept children. Be sure to use in combination with
|
|
517
|
-
* withChildren(YourComponent) like here
|
|
518
|
-
* github.com/BuilderIO/builder/blob/master/examples/react-design-system/src/components/HeroWithChildren/HeroWithChildren.builder.js#L5
|
|
519
|
-
*/
|
|
520
|
-
canHaveChildren?: boolean;
|
|
521
|
-
/** @hidden */
|
|
522
|
-
fragment?: boolean;
|
|
523
|
-
/**
|
|
524
|
-
* Do not wrap a component in a dom element. Be sure to use {...props.attributes} with this option
|
|
525
|
-
* like here github.com/BuilderIO/builder/blob/master/packages/react/src/blocks/forms/Input.tsx#L34
|
|
526
|
-
*/
|
|
527
|
-
noWrap?: boolean;
|
|
528
|
-
/**
|
|
529
|
-
* Default children
|
|
530
|
-
*/
|
|
531
|
-
defaultChildren?: BuilderElement[];
|
|
532
|
-
/**
|
|
533
|
-
* Default options to merge in when creating this block
|
|
534
|
-
*/
|
|
535
|
-
defaults?: Partial<BuilderElement>;
|
|
536
|
-
/** @hidden @deprecated */
|
|
537
|
-
hooks?: {
|
|
538
|
-
[key: string]: string | Function;
|
|
539
|
-
};
|
|
540
|
-
/**
|
|
541
|
-
* Hide your component in editor, useful for gradually deprecating components
|
|
542
|
-
*/
|
|
543
|
-
hideFromInsertMenu?: boolean;
|
|
544
|
-
/** Custom tag name (for custom webcomponents only) */
|
|
545
|
-
tag?: string;
|
|
546
|
-
/** @hidden @deprecated */
|
|
547
|
-
static?: boolean;
|
|
548
|
-
/**
|
|
549
|
-
* Passing a list of model names will restrict using the component to only the models listed here, otherwise it'll be available for all models
|
|
550
|
-
*/
|
|
551
|
-
models?: string[];
|
|
552
|
-
/**
|
|
553
|
-
* Specify restrictions direct children must match
|
|
554
|
-
*/
|
|
555
|
-
childRequirements?: {
|
|
556
|
-
/** Message to show when this doesn't match, e.g. "Children of 'Columns' must be a 'Column'" */
|
|
557
|
-
message: string;
|
|
558
|
-
/** Simple way to say children must be a specific component name */
|
|
559
|
-
component?: string;
|
|
560
|
-
/**
|
|
561
|
-
* More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
|
|
562
|
-
* of what the children objects should match, e.g.
|
|
563
|
-
*
|
|
564
|
-
* @example
|
|
565
|
-
* query: {
|
|
566
|
-
* // Child of this element must be a 'Button' or 'Text' component
|
|
567
|
-
* 'component.name': { $in: ['Button', 'Text'] }
|
|
568
|
-
* }
|
|
569
|
-
*/
|
|
570
|
-
query?: any;
|
|
571
|
-
};
|
|
572
|
-
/**
|
|
573
|
-
* Specify restrictions any parent must match
|
|
574
|
-
*/
|
|
575
|
-
requiresParent?: {
|
|
576
|
-
/** Message to show when this doesn't match, e.g. "'Add to cart' buttons must be within a 'Product box'" */
|
|
577
|
-
message: string;
|
|
578
|
-
/** Simple way to say a parent must be a specific component name, e.g. 'Product box' */
|
|
579
|
-
component?: string;
|
|
580
|
-
/**
|
|
581
|
-
* More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
|
|
582
|
-
* of what at least one parent in the parents hierarchy should match, e.g.
|
|
583
|
-
*
|
|
584
|
-
* @example
|
|
585
|
-
* query: {
|
|
586
|
-
* // Thils element must be somewhere inside either a 'Product box' or 'Collection' component
|
|
587
|
-
* 'component.name': { $in: ['Product Box', 'Collection'] }
|
|
588
|
-
* }
|
|
589
|
-
*/
|
|
590
|
-
query?: any;
|
|
591
|
-
};
|
|
592
|
-
/** @hidden @deprecated */
|
|
593
|
-
friendlyName?: string;
|
|
594
|
-
/**
|
|
595
|
-
* Use to restrict access to your component based on a the current user permissions
|
|
596
|
-
* By default components will show to all users
|
|
597
|
-
* for more information on permissions in builder check https://www.builder.io/c/docs/guides/roles-and-permissions
|
|
598
|
-
*/
|
|
599
|
-
requiredPermissions?: Array<Permission>;
|
|
600
|
-
}
|
|
601
|
-
type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create';
|
|
602
|
-
type DeepPartial<T> = {
|
|
603
|
-
[P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
|
|
604
|
-
};
|
|
605
|
-
export interface InsertMenuItem {
|
|
606
|
-
name: string;
|
|
607
|
-
icon?: string;
|
|
608
|
-
item: DeepPartial<BuilderElement>;
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* Use this to register custom sections in the Insert menu, for instance
|
|
612
|
-
* to make new sections to organize your custom components
|
|
613
|
-
*
|
|
614
|
-
* 
|
|
615
|
-
*
|
|
616
|
-
* @example
|
|
617
|
-
* ```js
|
|
618
|
-
* Builder.register('insertMenu', {
|
|
619
|
-
* name: 'Our components',
|
|
620
|
-
* items: [
|
|
621
|
-
* { name: 'Hero' },
|
|
622
|
-
* { name: 'Double Columns' },
|
|
623
|
-
* { name: 'Triple Columns' },
|
|
624
|
-
* { name: 'Dynamic Columns' },
|
|
625
|
-
* ],
|
|
626
|
-
* })
|
|
627
|
-
* ```
|
|
628
|
-
*
|
|
629
|
-
* You can make as many custom sections as you like
|
|
630
|
-
*
|
|
631
|
-
* See a complete usage example [here](https://github.com/builderio/builder/blob/main/examples/react-design-system/src/builder-settings.js)
|
|
632
|
-
*/
|
|
633
|
-
export interface InsertMenuConfig {
|
|
634
|
-
name: string;
|
|
635
|
-
priority?: number;
|
|
636
|
-
persist?: boolean;
|
|
637
|
-
advanced?: boolean;
|
|
638
|
-
items: InsertMenuItem[];
|
|
639
|
-
}
|
|
640
|
-
export declare function BuilderComponent(info?: Partial<Component>): (component: Class) => Class;
|
|
641
|
-
type Settings = any;
|
|
642
|
-
export interface Action {
|
|
643
|
-
name: string;
|
|
644
|
-
inputs?: Input[];
|
|
645
|
-
returnType?: Input;
|
|
646
|
-
action: Function | string;
|
|
647
|
-
}
|
|
648
|
-
export declare class Builder {
|
|
649
|
-
protected request?: IncomingMessage | undefined;
|
|
650
|
-
protected response?: ServerResponse | undefined;
|
|
651
|
-
/**
|
|
652
|
-
* @hidden
|
|
653
|
-
* @deprecated. This is buggy, and always behind by a version.
|
|
654
|
-
*/
|
|
655
|
-
static VERSION: string;
|
|
656
|
-
static components: Component[];
|
|
657
|
-
static singletonInstance: Builder;
|
|
658
|
-
/**
|
|
659
|
-
* Makes it so that a/b tests generate code like {@link
|
|
660
|
-
* https://www.builder.io/blog/high-performance-no-code#__next:~:text=Static%20generated%20A%2FB%20testing}
|
|
661
|
-
* instead of the old way where we render only one test group at a time on the
|
|
662
|
-
* server. This is the preferred/better way not and we should ultimately make it
|
|
663
|
-
* the default
|
|
664
|
-
*/
|
|
665
|
-
static isStatic: boolean;
|
|
666
|
-
static animator: Animator;
|
|
667
|
-
static nextTick: typeof nextTick;
|
|
668
|
-
static throttle: typeof throttle;
|
|
669
|
-
static editors: any[];
|
|
670
|
-
static trustedHosts: string[];
|
|
671
|
-
static serverContext: any;
|
|
672
|
-
static plugins: any[];
|
|
673
|
-
static actions: Action[];
|
|
674
|
-
static registry: {
|
|
675
|
-
[key: string]: any[];
|
|
676
|
-
};
|
|
677
|
-
static overrideHost: string | undefined;
|
|
678
|
-
/**
|
|
679
|
-
* @todo `key` property on any info where if a key matches a current
|
|
680
|
-
* key it gets removed
|
|
681
|
-
*/
|
|
682
|
-
static register(type: 'insertMenu', info: InsertMenuConfig): void;
|
|
683
|
-
static register(type: string, info: any): void;
|
|
684
|
-
static registryChange: BehaviorSubject<{
|
|
685
|
-
[key: string]: any[];
|
|
686
|
-
}, any>;
|
|
687
|
-
static registerEditor(info: any): void;
|
|
688
|
-
static registerPlugin(info: any): void;
|
|
689
|
-
static registerAction(action: Action): void;
|
|
690
|
-
static registerTrustedHost(host: string): void;
|
|
691
|
-
/**
|
|
692
|
-
* @param context @type {import('isolated-vm').Context}
|
|
693
|
-
* Use this function to control the execution context of custom code on the server.
|
|
694
|
-
* const ivm = require('isolated-vm');
|
|
695
|
-
* const isolate = new ivm.Isolate({ memoryLimit: 128 });
|
|
696
|
-
* const context = isolate.createContextSync();
|
|
697
|
-
* Builder.setServerContext(context);
|
|
698
|
-
*/
|
|
699
|
-
static setServerContext(context: any): void;
|
|
700
|
-
static isTrustedHost(hostname: string): boolean;
|
|
701
|
-
static runAction(action: Action | string): void;
|
|
702
|
-
static fields(name: string, fields: Input[]): void;
|
|
703
|
-
private static _editingPage;
|
|
704
|
-
static isIframe: boolean;
|
|
705
|
-
static isBrowser: boolean;
|
|
706
|
-
static isReactNative: boolean;
|
|
707
|
-
static isServer: boolean;
|
|
708
|
-
static previewingModel: string | false | null;
|
|
709
|
-
static settings: Settings;
|
|
710
|
-
static settingsChange: BehaviorSubject<any, any>;
|
|
711
|
-
/**
|
|
712
|
-
* @deprecated
|
|
713
|
-
* @hidden
|
|
714
|
-
*
|
|
715
|
-
* Use Builder.register('editor.settings', {}) instead.
|
|
716
|
-
*/
|
|
717
|
-
static set(settings: Settings): void;
|
|
718
|
-
static import(packageName: string): any;
|
|
719
|
-
static isEditing: boolean;
|
|
720
|
-
static isPreviewing: boolean;
|
|
721
|
-
static get editingPage(): boolean;
|
|
722
|
-
static set editingPage(editingPage: boolean);
|
|
723
|
-
private static prepareComponentSpecToSend;
|
|
724
|
-
static registerBlock(component: any, options: Component): void;
|
|
725
|
-
static registerComponent(component: any, options: Component): void;
|
|
726
|
-
private static addComponent;
|
|
727
|
-
static component(info?: Partial<Component>): (component: Class) => Class;
|
|
728
|
-
static isReact: boolean;
|
|
729
|
-
static get Component(): typeof Builder.component;
|
|
730
|
-
private eventsQueue;
|
|
731
|
-
private throttledClearEventsQueue;
|
|
732
|
-
private processEventsQueue;
|
|
733
|
-
env: string;
|
|
734
|
-
sessionId: string;
|
|
735
|
-
targetContent: boolean;
|
|
736
|
-
contentPerRequest: number;
|
|
737
|
-
allowCustomFonts: boolean;
|
|
738
|
-
private cookies;
|
|
739
|
-
private cachebust;
|
|
740
|
-
private overrideParams;
|
|
741
|
-
private noCache;
|
|
742
|
-
private preview;
|
|
743
|
-
get browserTrackingDisabled(): boolean;
|
|
744
|
-
get canTrack(): boolean;
|
|
745
|
-
set canTrack(canTrack: boolean);
|
|
746
|
-
get apiVersion(): ApiVersion | undefined;
|
|
747
|
-
set apiVersion(apiVersion: ApiVersion | undefined);
|
|
748
|
-
private apiVersion$;
|
|
749
|
-
private canTrack$;
|
|
750
|
-
private apiKey$;
|
|
751
|
-
private authToken$;
|
|
752
|
-
userAttributesChanged: BehaviorSubject<any, any>;
|
|
753
|
-
get editingMode(): boolean;
|
|
754
|
-
set editingMode(value: boolean);
|
|
755
|
-
editingMode$: BehaviorSubject<boolean, any>;
|
|
756
|
-
get editingModel(): string | null;
|
|
757
|
-
set editingModel(value: string | null);
|
|
758
|
-
private findParentElement;
|
|
759
|
-
private findBuilderParent;
|
|
760
|
-
editingModel$: BehaviorSubject<string | null, any>;
|
|
761
|
-
setUserAgent(userAgent: string): void;
|
|
762
|
-
userAgent: string;
|
|
763
|
-
trackingHooks: TrackingHook[];
|
|
764
|
-
/**
|
|
765
|
-
* Set a hook to modify events being tracked from builder, such as impressions and clicks
|
|
766
|
-
*
|
|
767
|
-
* For example, to track the model ID of each event associated with content for querying
|
|
768
|
-
* by mode, you can do
|
|
769
|
-
*
|
|
770
|
-
* builder.setTrackingHook((event, context) => {
|
|
771
|
-
* if (context.content) {
|
|
772
|
-
* event.data.metadata.modelId = context.content.modelId
|
|
773
|
-
* }
|
|
774
|
-
* })
|
|
775
|
-
*/
|
|
776
|
-
setTrackingHook(hook: TrackingHook): void;
|
|
777
|
-
track(eventName: string, properties?: Partial<EventData>, context?: any): void;
|
|
778
|
-
getSessionId(): string;
|
|
779
|
-
visitorId: string;
|
|
780
|
-
getVisitorId(): string;
|
|
781
|
-
trackImpression(contentId: string, variationId?: string, properties?: any, context?: any): void;
|
|
782
|
-
trackConversion(amount?: number, customProperties?: any): void;
|
|
783
|
-
autoTrack: boolean;
|
|
784
|
-
private get isDevelopmentEnv();
|
|
785
|
-
trackInteraction(contentId: string, variationId?: string, alreadyTrackedOne?: boolean, event?: MouseEvent, context?: any): void;
|
|
786
|
-
static overrideUserAttributes: Partial<UserAttributes>;
|
|
787
|
-
trackingUserAttributes: {
|
|
788
|
-
[key: string]: any;
|
|
789
|
-
};
|
|
790
|
-
component(info?: Partial<Component>): (component: Class) => Class;
|
|
791
|
-
get apiKey(): string | null;
|
|
792
|
-
set apiKey(key: string | null);
|
|
793
|
-
get authToken(): string | null;
|
|
794
|
-
set authToken(token: string | null);
|
|
795
|
-
constructor(apiKey?: string | null, request?: IncomingMessage | undefined, response?: ServerResponse | undefined, forceNewInstance?: boolean, authToken?: string | null, apiVersion?: ApiVersion);
|
|
796
|
-
private modifySearch;
|
|
797
|
-
setTestsFromUrl(): void;
|
|
798
|
-
resetOverrides(): void;
|
|
799
|
-
getOverridesFromQueryString(): void;
|
|
800
|
-
private messageFrameLoaded;
|
|
801
|
-
private blockContentLoading;
|
|
802
|
-
private bindMessageListeners;
|
|
803
|
-
observersByKey: {
|
|
804
|
-
[key: string]: BehaviorSubject<BuilderContent[]> | undefined;
|
|
805
|
-
};
|
|
806
|
-
noEditorUpdates: {
|
|
807
|
-
[key: string]: boolean;
|
|
808
|
-
};
|
|
809
|
-
get defaultCanTrack(): boolean;
|
|
810
|
-
init(apiKey: string, canTrack?: boolean, req?: IncomingMessage, res?: ServerResponse, authToken?: string | null, apiVersion?: ApiVersion): this;
|
|
811
|
-
get previewingModel(): string;
|
|
812
|
-
getLocation(): Url;
|
|
813
|
-
getUserAttributes(userAgent?: string): UserAttributes;
|
|
814
|
-
protected overrides: {
|
|
815
|
-
[key: string]: string;
|
|
816
|
-
};
|
|
817
|
-
protected queryOptions: {
|
|
818
|
-
[key: string]: string;
|
|
819
|
-
};
|
|
820
|
-
private getContentQueue;
|
|
821
|
-
private priorContentQueue;
|
|
822
|
-
setUserAttributes(options: object): void;
|
|
823
|
-
/**
|
|
824
|
-
* Set user attributes just for tracking purposes.
|
|
825
|
-
*
|
|
826
|
-
* Do this so properties exist on event objects for querying insights, but
|
|
827
|
-
* won't affect targeting
|
|
828
|
-
*
|
|
829
|
-
* Use this when you want to track properties but don't need to target off
|
|
830
|
-
* of them to optimize cache efficiency
|
|
831
|
-
*/
|
|
832
|
-
setTrackingUserAttributes(attributes: object): void;
|
|
833
|
-
get(modelName: string, options?: GetContentOptions & {
|
|
834
|
-
req?: IncomingMessage;
|
|
835
|
-
res?: ServerResponse;
|
|
836
|
-
apiKey?: string;
|
|
837
|
-
authToken?: string;
|
|
838
|
-
}): BehaviorSubject<any, any>;
|
|
839
|
-
queueGetContent(modelName: string, options?: GetContentOptions): BehaviorSubject<BuilderContent[], any>;
|
|
840
|
-
requestUrl(url: string, options?: {
|
|
841
|
-
headers: {
|
|
842
|
-
[header: string]: number | string | string[] | undefined;
|
|
843
|
-
};
|
|
844
|
-
next?: any;
|
|
845
|
-
}): Promise<any>;
|
|
846
|
-
get host(): string;
|
|
847
|
-
private flushGetContentQueue;
|
|
848
|
-
private testCookiePrefix;
|
|
849
|
-
private processResultsForTests;
|
|
850
|
-
private getTestCookie;
|
|
851
|
-
private cookieQueue;
|
|
852
|
-
private setTestCookie;
|
|
853
|
-
getCookie(name: string): any;
|
|
854
|
-
setCookie(name: string, value: any, expires?: Date): false | void | Cookies;
|
|
855
|
-
getContent(modelName: string, options?: GetContentOptions): BehaviorSubject<BuilderContent[], any>;
|
|
856
|
-
getAll(modelName: string, options?: GetContentOptions & {
|
|
857
|
-
req?: IncomingMessage;
|
|
858
|
-
res?: ServerResponse;
|
|
859
|
-
apiKey?: string;
|
|
860
|
-
}): Promise<BuilderContent[]>;
|
|
861
|
-
}
|
|
862
|
-
export {};
|
|
1
|
+
/// <reference types="@types/node" />
|
|
2
|
+
import './polyfills/custom-event-polyfill';
|
|
3
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
4
|
+
import { nextTick } from './functions/next-tick.function';
|
|
5
|
+
import { BehaviorSubject } from './classes/observable.class';
|
|
6
|
+
import { throttle } from './functions/throttle.function';
|
|
7
|
+
import { Animator } from './classes/animator.class';
|
|
8
|
+
import { BuilderElement } from './types/element';
|
|
9
|
+
import Cookies from './classes/cookies.class';
|
|
10
|
+
import { BuilderContent } from './types/content';
|
|
11
|
+
import { ApiVersion } from './types/api-version';
|
|
12
|
+
export type Url = any;
|
|
13
|
+
export declare const isReactNative: boolean;
|
|
14
|
+
export declare const validEnvList: string[];
|
|
15
|
+
export declare const isBrowser: boolean;
|
|
16
|
+
export declare const isIframe: boolean;
|
|
17
|
+
export interface ParamsMap {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
type TrackingHook = (eventData: Event, context: {
|
|
21
|
+
content?: BuilderContent;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}) => Event | undefined;
|
|
24
|
+
interface EventData {
|
|
25
|
+
contentId?: string;
|
|
26
|
+
ownerId: string;
|
|
27
|
+
variationId?: string;
|
|
28
|
+
userAttributes?: any;
|
|
29
|
+
targetSelector?: string;
|
|
30
|
+
targetBuilderElement?: string;
|
|
31
|
+
unique?: boolean;
|
|
32
|
+
metadata?: any | string;
|
|
33
|
+
meta?: any | string;
|
|
34
|
+
sessionId?: string;
|
|
35
|
+
visitorId?: string;
|
|
36
|
+
amount?: number;
|
|
37
|
+
}
|
|
38
|
+
interface Event {
|
|
39
|
+
type: string;
|
|
40
|
+
data: EventData;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Attributes that can be used for custom targeting. {@link
|
|
44
|
+
* https://www.builder.io/c/docs/guides/targeting-and-scheduling}
|
|
45
|
+
*/
|
|
46
|
+
export interface UserAttributes {
|
|
47
|
+
[key: string]: undefined | string | string[] | boolean | boolean[] | number | number[] | Record<string, any>;
|
|
48
|
+
/**
|
|
49
|
+
* URL path of the current user.
|
|
50
|
+
*/
|
|
51
|
+
urlPath?: string;
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated
|
|
54
|
+
* @hidden
|
|
55
|
+
*/
|
|
56
|
+
queryString?: string | ParamsMap;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated
|
|
59
|
+
* @hidden
|
|
60
|
+
*/
|
|
61
|
+
device?: 'mobile' | 'tablet' | 'desktop';
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
location?: any;
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated
|
|
69
|
+
* @hidden
|
|
70
|
+
*/
|
|
71
|
+
userAgent?: string;
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated
|
|
74
|
+
* @hidden
|
|
75
|
+
*/
|
|
76
|
+
referrer?: string;
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated
|
|
79
|
+
* @hidden
|
|
80
|
+
*/
|
|
81
|
+
entryMedium?: string;
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated
|
|
84
|
+
* @hidden
|
|
85
|
+
*/
|
|
86
|
+
language?: string;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated
|
|
89
|
+
* @hidden
|
|
90
|
+
*/
|
|
91
|
+
browser?: string;
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated
|
|
94
|
+
* @hidden
|
|
95
|
+
*/
|
|
96
|
+
cookie?: string;
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated
|
|
99
|
+
* @hidden
|
|
100
|
+
*/
|
|
101
|
+
newVisitor?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* @deprecated
|
|
104
|
+
* @hidden
|
|
105
|
+
*/
|
|
106
|
+
operatingSystem?: string;
|
|
107
|
+
}
|
|
108
|
+
type AllowEnrich = {
|
|
109
|
+
apiVersion?: Extract<ApiVersion, 'v1'>;
|
|
110
|
+
} | {
|
|
111
|
+
apiVersion?: Extract<ApiVersion, 'v3'>;
|
|
112
|
+
enrich?: boolean;
|
|
113
|
+
} | {
|
|
114
|
+
apiVersion?: never;
|
|
115
|
+
enrich?: boolean;
|
|
116
|
+
};
|
|
117
|
+
export type GetContentOptions = AllowEnrich & {
|
|
118
|
+
/**
|
|
119
|
+
* User attribute key value pairs to be used for targeting
|
|
120
|
+
* https://www.builder.io/c/docs/custom-targeting-attributes
|
|
121
|
+
*
|
|
122
|
+
* e.g.
|
|
123
|
+
* ```js
|
|
124
|
+
* userAttributes: {
|
|
125
|
+
* urlPath: '/',
|
|
126
|
+
* returnVisitor: true,
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
userAttributes?: UserAttributes;
|
|
131
|
+
/**
|
|
132
|
+
* Alias for userAttributes.urlPath except it can handle a full URL (optionally with host,
|
|
133
|
+
* protocol, query, etc) and we will parse out the path.
|
|
134
|
+
*/
|
|
135
|
+
url?: string;
|
|
136
|
+
/**
|
|
137
|
+
* @package
|
|
138
|
+
*/
|
|
139
|
+
includeUrl?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Follow references. If you use the `reference` field to pull in other content without this
|
|
142
|
+
* enabled we will not fetch that content for the final response.
|
|
143
|
+
* @deprecated use `enrich` instead
|
|
144
|
+
*/
|
|
145
|
+
includeRefs?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* How long in seconds content should be cached for. Sets the max-age of the cache-control header
|
|
148
|
+
* response header.
|
|
149
|
+
*
|
|
150
|
+
* Use a higher value for better performance, lower for content that will change more frequently
|
|
151
|
+
*
|
|
152
|
+
* @see {@link https://www.builder.io/c/docs/query-api#__next:~:text=%26includeRefs%3Dtrue-,cacheSeconds,-No}
|
|
153
|
+
*/
|
|
154
|
+
cacheSeconds?: number;
|
|
155
|
+
/**
|
|
156
|
+
* Builder.io uses stale-while-revalidate caching at the CDN level. This means we always serve
|
|
157
|
+
* from edge cache and update caches in the background for maximum possible performance. This also
|
|
158
|
+
* means that the more frequently content is requested, the more fresh it will be. The longest we
|
|
159
|
+
* will ever hold something in stale cache is 1 day by default, and you can set this to be shorter
|
|
160
|
+
* yourself as well. We suggest keeping this high unless you have content that must change rapidly
|
|
161
|
+
* and gets very little traffic.
|
|
162
|
+
*
|
|
163
|
+
* @see {@link https://www.fastly.com/blog/prevent-application-network-instability-serve-stale-content}
|
|
164
|
+
*/
|
|
165
|
+
staleCacheSeconds?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Maximum number of results to return. Defaults to `1`.
|
|
168
|
+
*/
|
|
169
|
+
limit?: number;
|
|
170
|
+
/**
|
|
171
|
+
* Mongodb style query of your data. E.g.:
|
|
172
|
+
*
|
|
173
|
+
* ```js
|
|
174
|
+
* query: {
|
|
175
|
+
* id: 'abc123',
|
|
176
|
+
* data: {
|
|
177
|
+
* myCustomField: { $gt: 20 },
|
|
178
|
+
* }
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* See more info on MongoDB's query operators and format.
|
|
183
|
+
*
|
|
184
|
+
* @see {@link https://docs.mongodb.com/manual/reference/operator/query/}
|
|
185
|
+
*/
|
|
186
|
+
query?: any;
|
|
187
|
+
/**
|
|
188
|
+
* Bust through all caches. Not recommended for production (for performance),
|
|
189
|
+
* but can be useful for development and static builds (so the static site has
|
|
190
|
+
* fully fresh / up to date content)
|
|
191
|
+
*/
|
|
192
|
+
cachebust?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Convert any visual builder content to HTML.
|
|
195
|
+
*
|
|
196
|
+
* This will be on data.html of the response's content entry object json.
|
|
197
|
+
*/
|
|
198
|
+
prerender?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Extract any styles to a separate css property when generating HTML.
|
|
201
|
+
*/
|
|
202
|
+
extractCss?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Pagination results offset. Defaults to zero.
|
|
205
|
+
*/
|
|
206
|
+
offset?: number;
|
|
207
|
+
/**
|
|
208
|
+
* @package
|
|
209
|
+
*
|
|
210
|
+
* `BuilderContent` to render instead of fetching.
|
|
211
|
+
*/
|
|
212
|
+
initialContent?: any;
|
|
213
|
+
/**
|
|
214
|
+
* The name of the model to fetch content for.
|
|
215
|
+
*/
|
|
216
|
+
model?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Set to `false` to not cache responses when running on the client.
|
|
219
|
+
*/
|
|
220
|
+
cache?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Set to the current locale in your application if you want localized inputs to be auto-resolved, should match one of the locales keys in your space settings
|
|
223
|
+
* Learn more about adding or removing locales [here](https://www.builder.io/c/docs/add-remove-locales)
|
|
224
|
+
*/
|
|
225
|
+
locale?: string;
|
|
226
|
+
/**
|
|
227
|
+
* @package
|
|
228
|
+
*
|
|
229
|
+
* Indicate that the fetch request is for preview purposes.
|
|
230
|
+
*/
|
|
231
|
+
preview?: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Specific content entry ID to fetch.
|
|
234
|
+
*/
|
|
235
|
+
entry?: string;
|
|
236
|
+
/**
|
|
237
|
+
* @package
|
|
238
|
+
* @deprecated
|
|
239
|
+
* @hidden
|
|
240
|
+
*/
|
|
241
|
+
alias?: string;
|
|
242
|
+
fields?: string;
|
|
243
|
+
/**
|
|
244
|
+
* Omit only these fields.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```
|
|
248
|
+
* &omit=data.bigField,data.blocks
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
omit?: string;
|
|
252
|
+
key?: string;
|
|
253
|
+
/**
|
|
254
|
+
* @package
|
|
255
|
+
*
|
|
256
|
+
* Affects HTML generation for specific targets.
|
|
257
|
+
*/
|
|
258
|
+
format?: 'amp' | 'email' | 'html' | 'react' | 'solid';
|
|
259
|
+
/**
|
|
260
|
+
* @deprecated
|
|
261
|
+
* @hidden
|
|
262
|
+
*/
|
|
263
|
+
noWrap?: true;
|
|
264
|
+
/**
|
|
265
|
+
* @package
|
|
266
|
+
*
|
|
267
|
+
* Specific string to use for cache busting. e.g. every time we generate
|
|
268
|
+
* HTML we generate a rev (a revision ID) and we send that with each request
|
|
269
|
+
* on the client, such that if we generate new server HTML we get a new rev
|
|
270
|
+
* and we use that to bust the cache because even though the content ID may
|
|
271
|
+
* be the same, it could be an updated version of this content that needs to
|
|
272
|
+
* be fresh.
|
|
273
|
+
*/
|
|
274
|
+
rev?: string;
|
|
275
|
+
/**
|
|
276
|
+
* @package
|
|
277
|
+
*
|
|
278
|
+
* Tell the API that when generating HTML to generate it in static mode for
|
|
279
|
+
* a/b tests instead of the older way we did this
|
|
280
|
+
*/
|
|
281
|
+
static?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Additional query params of the Content API to send.
|
|
284
|
+
*/
|
|
285
|
+
options?: {
|
|
286
|
+
[key: string]: any;
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* @package
|
|
290
|
+
*
|
|
291
|
+
* Don't listen to updates in the editor - this is useful for embedded
|
|
292
|
+
* symbols so they don't accidentally listen to messages as you are editing
|
|
293
|
+
* content thinking they should updates when they actually shouldn't.
|
|
294
|
+
*/
|
|
295
|
+
noEditorUpdates?: boolean;
|
|
296
|
+
};
|
|
297
|
+
export type Class = {
|
|
298
|
+
name?: string;
|
|
299
|
+
new (...args: any[]): any;
|
|
300
|
+
};
|
|
301
|
+
interface Map<K, V> {
|
|
302
|
+
clear(): void;
|
|
303
|
+
delete(key: K): boolean;
|
|
304
|
+
entries(): IterableIterator<[K, V]>;
|
|
305
|
+
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
|
|
306
|
+
get(key: K): V;
|
|
307
|
+
has(key: K): boolean;
|
|
308
|
+
keys(): IterableIterator<K>;
|
|
309
|
+
set(key: K, value?: V): Map<K, V>;
|
|
310
|
+
size: number;
|
|
311
|
+
values(): IterableIterator<V>;
|
|
312
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* This is the interface for inputs in `Builder.registerComponent`
|
|
316
|
+
*
|
|
317
|
+
* ```js
|
|
318
|
+
* Builder.registerComponent(MyComponent, {
|
|
319
|
+
* inputs: [{ name: 'title', type: 'text' }] // <- Input[]
|
|
320
|
+
* })
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* Learn more about registering custom components [here](https://www.builder.io/c/docs/custom-react-components)
|
|
324
|
+
*/
|
|
325
|
+
export interface Input {
|
|
326
|
+
/** This is the name of the component prop this input represents */
|
|
327
|
+
name: string;
|
|
328
|
+
/** A friendlier name to show in the UI if the component prop name is not ideal for end users */
|
|
329
|
+
friendlyName?: string;
|
|
330
|
+
/** @hidden @deprecated */
|
|
331
|
+
description?: string;
|
|
332
|
+
/** A default value to use */
|
|
333
|
+
defaultValue?: any;
|
|
334
|
+
/**
|
|
335
|
+
* The type of input to use, such as 'text'
|
|
336
|
+
*
|
|
337
|
+
* See all available inputs [here](https://www.builder.io/c/docs/custom-react-components#input-types)
|
|
338
|
+
* and you can create your own custom input types and associated editor UIs with [plugins](https://www.builder.io/c/docs/extending/plugins)
|
|
339
|
+
*/
|
|
340
|
+
type: string;
|
|
341
|
+
/** Is this input mandatory or not */
|
|
342
|
+
required?: boolean;
|
|
343
|
+
/** @hidden */
|
|
344
|
+
autoFocus?: boolean;
|
|
345
|
+
subFields?: Input[];
|
|
346
|
+
/**
|
|
347
|
+
* Additional text to render in the UI to give guidance on how to use this
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```js
|
|
351
|
+
* helperText: 'Be sure to use a proper URL, starting with "https://"'
|
|
352
|
+
* 111
|
|
353
|
+
*/
|
|
354
|
+
helperText?: string;
|
|
355
|
+
/** @hidden */
|
|
356
|
+
allowedFileTypes?: string[];
|
|
357
|
+
/** @hidden */
|
|
358
|
+
imageHeight?: number;
|
|
359
|
+
/** @hidden */
|
|
360
|
+
imageWidth?: number;
|
|
361
|
+
/** @hidden */
|
|
362
|
+
mediaHeight?: number;
|
|
363
|
+
/** @hidden */
|
|
364
|
+
mediaWidth?: number;
|
|
365
|
+
/** @hidden */
|
|
366
|
+
hideFromUI?: boolean;
|
|
367
|
+
/** @hidden */
|
|
368
|
+
modelId?: string;
|
|
369
|
+
/**
|
|
370
|
+
* Number field type validation maximum accepted input
|
|
371
|
+
*/
|
|
372
|
+
max?: number;
|
|
373
|
+
/**
|
|
374
|
+
* Number field type validation minimum accepted input
|
|
375
|
+
*/
|
|
376
|
+
min?: number;
|
|
377
|
+
/**
|
|
378
|
+
* Number field type step size when using arrows
|
|
379
|
+
*/
|
|
380
|
+
step?: number;
|
|
381
|
+
/**
|
|
382
|
+
* Set this to `true` to show the editor for this input when
|
|
383
|
+
* children of this component are selected. This is useful for things
|
|
384
|
+
* like Tabs, such that users may not always select the Tabs component
|
|
385
|
+
* directly but will still be looking for how to add additional tabs
|
|
386
|
+
*/
|
|
387
|
+
broadcast?: boolean;
|
|
388
|
+
/**
|
|
389
|
+
* Set this to `true` to show the editor for this input when
|
|
390
|
+
* group locked parents of this component are selected. This is useful
|
|
391
|
+
* to bubble up important inputs for locked groups, like text and images
|
|
392
|
+
*/
|
|
393
|
+
bubble?: boolean;
|
|
394
|
+
/**
|
|
395
|
+
* Set this to `true` if you want this component to be translatable
|
|
396
|
+
*/
|
|
397
|
+
localized?: boolean;
|
|
398
|
+
/** @hidden */
|
|
399
|
+
options?: {
|
|
400
|
+
[key: string]: any;
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* For "text" input type, specifying an enum will show a dropdown of options instead
|
|
404
|
+
*/
|
|
405
|
+
enum?: string[] | {
|
|
406
|
+
label: string;
|
|
407
|
+
value: string | number | boolean;
|
|
408
|
+
helperText?: string;
|
|
409
|
+
}[];
|
|
410
|
+
/** Regex field validation for all string types (text, longText, html, url, etc) */
|
|
411
|
+
regex?: {
|
|
412
|
+
/** pattern to test, like "^\/[a-z]$" */
|
|
413
|
+
pattern: string;
|
|
414
|
+
/** flags for the RegExp constructor, e.g. "gi" */
|
|
415
|
+
options?: string;
|
|
416
|
+
/**
|
|
417
|
+
* Friendly message to display to end-users if the regex fails, e.g.
|
|
418
|
+
* "You must use a relative url starting with '/...' "
|
|
419
|
+
*/
|
|
420
|
+
message: string;
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* Set this to `true` to put this under the "show more" section of
|
|
424
|
+
* the options editor. Useful for things that are more advanced
|
|
425
|
+
* or more rarely used and don't need to be too prominent
|
|
426
|
+
*/
|
|
427
|
+
advanced?: boolean;
|
|
428
|
+
/** @hidden */
|
|
429
|
+
onChange?: Function | string;
|
|
430
|
+
/** @hidden */
|
|
431
|
+
code?: boolean;
|
|
432
|
+
/** @hidden */
|
|
433
|
+
richText?: boolean;
|
|
434
|
+
/** @hidden */
|
|
435
|
+
showIf?: ((options: Map<string, any>) => boolean) | string;
|
|
436
|
+
/** @hidden */
|
|
437
|
+
copyOnAdd?: boolean;
|
|
438
|
+
/**
|
|
439
|
+
* Use optionally with inputs of type `reference`. Restricts the content entry picker to a specific model by name.
|
|
440
|
+
*/
|
|
441
|
+
model?: string;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* This is the interface for the options for `Builder.registerComponent`
|
|
445
|
+
*
|
|
446
|
+
* ```js
|
|
447
|
+
* Builder.registerComponent(YourComponent, {
|
|
448
|
+
* // <- Component options
|
|
449
|
+
* })
|
|
450
|
+
* ```
|
|
451
|
+
*
|
|
452
|
+
* Learn more about registering custom components [here](https://www.builder.io/c/docs/custom-react-components)
|
|
453
|
+
*/
|
|
454
|
+
export interface Component {
|
|
455
|
+
/**
|
|
456
|
+
* Name your component something unique, e.g. 'MyButton'. You can override built-in components
|
|
457
|
+
* by registering a component with the same name, e.g. 'Text', to replace the built-in text component
|
|
458
|
+
*/
|
|
459
|
+
name: string;
|
|
460
|
+
/** @hidden @deprecated */
|
|
461
|
+
description?: string;
|
|
462
|
+
/**
|
|
463
|
+
* Link to a documentation page for this component
|
|
464
|
+
*/
|
|
465
|
+
docsLink?: string;
|
|
466
|
+
/**
|
|
467
|
+
* Link to an image to be used as an icon for this component in Builder's editor
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```js
|
|
471
|
+
* image: 'https://some-cdn.com/my-icon-for-this-component.png'
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
image?: string;
|
|
475
|
+
/**
|
|
476
|
+
* Link to a screenshot shown when user hovers over the component in Builder's editor
|
|
477
|
+
* use https://builder.io/upload to upload your screeshot, for easier resizing by Builder.
|
|
478
|
+
*/
|
|
479
|
+
screenshot?: string;
|
|
480
|
+
/**
|
|
481
|
+
* When overriding built-in components, if you don't want any special behavior that
|
|
482
|
+
* the original has, set this to `true` to skip the default behavior
|
|
483
|
+
*
|
|
484
|
+
* Default behaviors include special "virtual options", such as a custom
|
|
485
|
+
* aspect ratio editor for Images, or a special column editor for Columns
|
|
486
|
+
*
|
|
487
|
+
* Learn more about overriding built-in components here: https://www.builder.io/c/docs/custom-components-overriding
|
|
488
|
+
*/
|
|
489
|
+
override?: boolean;
|
|
490
|
+
/**
|
|
491
|
+
* Input schema for your component for users to fill in the options via a UI
|
|
492
|
+
* that translate to this components props
|
|
493
|
+
*/
|
|
494
|
+
inputs?: Input[];
|
|
495
|
+
/** @hidden @deprecated */
|
|
496
|
+
class?: any;
|
|
497
|
+
/** @hidden @deprecated */
|
|
498
|
+
type?: 'angular' | 'webcomponent' | 'react' | 'vue';
|
|
499
|
+
/**
|
|
500
|
+
* Default styles to apply when droppged into the Builder.io editor
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* ```js
|
|
504
|
+
* defaultStyles: {
|
|
505
|
+
* // large (default) breakpoint
|
|
506
|
+
* large: {
|
|
507
|
+
* backgroundColor: 'black'
|
|
508
|
+
* },
|
|
509
|
+
* }
|
|
510
|
+
* ```
|
|
511
|
+
*/
|
|
512
|
+
defaultStyles?: {
|
|
513
|
+
[key: string]: string;
|
|
514
|
+
};
|
|
515
|
+
/**
|
|
516
|
+
* Turn on if your component can accept children. Be sure to use in combination with
|
|
517
|
+
* withChildren(YourComponent) like here
|
|
518
|
+
* github.com/BuilderIO/builder/blob/master/examples/react-design-system/src/components/HeroWithChildren/HeroWithChildren.builder.js#L5
|
|
519
|
+
*/
|
|
520
|
+
canHaveChildren?: boolean;
|
|
521
|
+
/** @hidden */
|
|
522
|
+
fragment?: boolean;
|
|
523
|
+
/**
|
|
524
|
+
* Do not wrap a component in a dom element. Be sure to use {...props.attributes} with this option
|
|
525
|
+
* like here github.com/BuilderIO/builder/blob/master/packages/react/src/blocks/forms/Input.tsx#L34
|
|
526
|
+
*/
|
|
527
|
+
noWrap?: boolean;
|
|
528
|
+
/**
|
|
529
|
+
* Default children
|
|
530
|
+
*/
|
|
531
|
+
defaultChildren?: BuilderElement[];
|
|
532
|
+
/**
|
|
533
|
+
* Default options to merge in when creating this block
|
|
534
|
+
*/
|
|
535
|
+
defaults?: Partial<BuilderElement>;
|
|
536
|
+
/** @hidden @deprecated */
|
|
537
|
+
hooks?: {
|
|
538
|
+
[key: string]: string | Function;
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* Hide your component in editor, useful for gradually deprecating components
|
|
542
|
+
*/
|
|
543
|
+
hideFromInsertMenu?: boolean;
|
|
544
|
+
/** Custom tag name (for custom webcomponents only) */
|
|
545
|
+
tag?: string;
|
|
546
|
+
/** @hidden @deprecated */
|
|
547
|
+
static?: boolean;
|
|
548
|
+
/**
|
|
549
|
+
* Passing a list of model names will restrict using the component to only the models listed here, otherwise it'll be available for all models
|
|
550
|
+
*/
|
|
551
|
+
models?: string[];
|
|
552
|
+
/**
|
|
553
|
+
* Specify restrictions direct children must match
|
|
554
|
+
*/
|
|
555
|
+
childRequirements?: {
|
|
556
|
+
/** Message to show when this doesn't match, e.g. "Children of 'Columns' must be a 'Column'" */
|
|
557
|
+
message: string;
|
|
558
|
+
/** Simple way to say children must be a specific component name */
|
|
559
|
+
component?: string;
|
|
560
|
+
/**
|
|
561
|
+
* More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
|
|
562
|
+
* of what the children objects should match, e.g.
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* query: {
|
|
566
|
+
* // Child of this element must be a 'Button' or 'Text' component
|
|
567
|
+
* 'component.name': { $in: ['Button', 'Text'] }
|
|
568
|
+
* }
|
|
569
|
+
*/
|
|
570
|
+
query?: any;
|
|
571
|
+
};
|
|
572
|
+
/**
|
|
573
|
+
* Specify restrictions any parent must match
|
|
574
|
+
*/
|
|
575
|
+
requiresParent?: {
|
|
576
|
+
/** Message to show when this doesn't match, e.g. "'Add to cart' buttons must be within a 'Product box'" */
|
|
577
|
+
message: string;
|
|
578
|
+
/** Simple way to say a parent must be a specific component name, e.g. 'Product box' */
|
|
579
|
+
component?: string;
|
|
580
|
+
/**
|
|
581
|
+
* More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
|
|
582
|
+
* of what at least one parent in the parents hierarchy should match, e.g.
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* query: {
|
|
586
|
+
* // Thils element must be somewhere inside either a 'Product box' or 'Collection' component
|
|
587
|
+
* 'component.name': { $in: ['Product Box', 'Collection'] }
|
|
588
|
+
* }
|
|
589
|
+
*/
|
|
590
|
+
query?: any;
|
|
591
|
+
};
|
|
592
|
+
/** @hidden @deprecated */
|
|
593
|
+
friendlyName?: string;
|
|
594
|
+
/**
|
|
595
|
+
* Use to restrict access to your component based on a the current user permissions
|
|
596
|
+
* By default components will show to all users
|
|
597
|
+
* for more information on permissions in builder check https://www.builder.io/c/docs/guides/roles-and-permissions
|
|
598
|
+
*/
|
|
599
|
+
requiredPermissions?: Array<Permission>;
|
|
600
|
+
}
|
|
601
|
+
type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create';
|
|
602
|
+
type DeepPartial<T> = {
|
|
603
|
+
[P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
|
|
604
|
+
};
|
|
605
|
+
export interface InsertMenuItem {
|
|
606
|
+
name: string;
|
|
607
|
+
icon?: string;
|
|
608
|
+
item: DeepPartial<BuilderElement>;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Use this to register custom sections in the Insert menu, for instance
|
|
612
|
+
* to make new sections to organize your custom components
|
|
613
|
+
*
|
|
614
|
+
* 
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```js
|
|
618
|
+
* Builder.register('insertMenu', {
|
|
619
|
+
* name: 'Our components',
|
|
620
|
+
* items: [
|
|
621
|
+
* { name: 'Hero' },
|
|
622
|
+
* { name: 'Double Columns' },
|
|
623
|
+
* { name: 'Triple Columns' },
|
|
624
|
+
* { name: 'Dynamic Columns' },
|
|
625
|
+
* ],
|
|
626
|
+
* })
|
|
627
|
+
* ```
|
|
628
|
+
*
|
|
629
|
+
* You can make as many custom sections as you like
|
|
630
|
+
*
|
|
631
|
+
* See a complete usage example [here](https://github.com/builderio/builder/blob/main/examples/react-design-system/src/builder-settings.js)
|
|
632
|
+
*/
|
|
633
|
+
export interface InsertMenuConfig {
|
|
634
|
+
name: string;
|
|
635
|
+
priority?: number;
|
|
636
|
+
persist?: boolean;
|
|
637
|
+
advanced?: boolean;
|
|
638
|
+
items: InsertMenuItem[];
|
|
639
|
+
}
|
|
640
|
+
export declare function BuilderComponent(info?: Partial<Component>): (component: Class) => Class;
|
|
641
|
+
type Settings = any;
|
|
642
|
+
export interface Action {
|
|
643
|
+
name: string;
|
|
644
|
+
inputs?: Input[];
|
|
645
|
+
returnType?: Input;
|
|
646
|
+
action: Function | string;
|
|
647
|
+
}
|
|
648
|
+
export declare class Builder {
|
|
649
|
+
protected request?: IncomingMessage | undefined;
|
|
650
|
+
protected response?: ServerResponse<IncomingMessage> | undefined;
|
|
651
|
+
/**
|
|
652
|
+
* @hidden
|
|
653
|
+
* @deprecated. This is buggy, and always behind by a version.
|
|
654
|
+
*/
|
|
655
|
+
static VERSION: string;
|
|
656
|
+
static components: Component[];
|
|
657
|
+
static singletonInstance: Builder;
|
|
658
|
+
/**
|
|
659
|
+
* Makes it so that a/b tests generate code like {@link
|
|
660
|
+
* https://www.builder.io/blog/high-performance-no-code#__next:~:text=Static%20generated%20A%2FB%20testing}
|
|
661
|
+
* instead of the old way where we render only one test group at a time on the
|
|
662
|
+
* server. This is the preferred/better way not and we should ultimately make it
|
|
663
|
+
* the default
|
|
664
|
+
*/
|
|
665
|
+
static isStatic: boolean;
|
|
666
|
+
static animator: Animator;
|
|
667
|
+
static nextTick: typeof nextTick;
|
|
668
|
+
static throttle: typeof throttle;
|
|
669
|
+
static editors: any[];
|
|
670
|
+
static trustedHosts: string[];
|
|
671
|
+
static serverContext: any;
|
|
672
|
+
static plugins: any[];
|
|
673
|
+
static actions: Action[];
|
|
674
|
+
static registry: {
|
|
675
|
+
[key: string]: any[];
|
|
676
|
+
};
|
|
677
|
+
static overrideHost: string | undefined;
|
|
678
|
+
/**
|
|
679
|
+
* @todo `key` property on any info where if a key matches a current
|
|
680
|
+
* key it gets removed
|
|
681
|
+
*/
|
|
682
|
+
static register(type: 'insertMenu', info: InsertMenuConfig): void;
|
|
683
|
+
static register(type: string, info: any): void;
|
|
684
|
+
static registryChange: BehaviorSubject<{
|
|
685
|
+
[key: string]: any[];
|
|
686
|
+
}, any>;
|
|
687
|
+
static registerEditor(info: any): void;
|
|
688
|
+
static registerPlugin(info: any): void;
|
|
689
|
+
static registerAction(action: Action): void;
|
|
690
|
+
static registerTrustedHost(host: string): void;
|
|
691
|
+
/**
|
|
692
|
+
* @param context @type {import('isolated-vm').Context}
|
|
693
|
+
* Use this function to control the execution context of custom code on the server.
|
|
694
|
+
* const ivm = require('isolated-vm');
|
|
695
|
+
* const isolate = new ivm.Isolate({ memoryLimit: 128 });
|
|
696
|
+
* const context = isolate.createContextSync();
|
|
697
|
+
* Builder.setServerContext(context);
|
|
698
|
+
*/
|
|
699
|
+
static setServerContext(context: any): void;
|
|
700
|
+
static isTrustedHost(hostname: string): boolean;
|
|
701
|
+
static runAction(action: Action | string): void;
|
|
702
|
+
static fields(name: string, fields: Input[]): void;
|
|
703
|
+
private static _editingPage;
|
|
704
|
+
static isIframe: boolean;
|
|
705
|
+
static isBrowser: boolean;
|
|
706
|
+
static isReactNative: boolean;
|
|
707
|
+
static isServer: boolean;
|
|
708
|
+
static previewingModel: string | false | null;
|
|
709
|
+
static settings: Settings;
|
|
710
|
+
static settingsChange: BehaviorSubject<any, any>;
|
|
711
|
+
/**
|
|
712
|
+
* @deprecated
|
|
713
|
+
* @hidden
|
|
714
|
+
*
|
|
715
|
+
* Use Builder.register('editor.settings', {}) instead.
|
|
716
|
+
*/
|
|
717
|
+
static set(settings: Settings): void;
|
|
718
|
+
static import(packageName: string): any;
|
|
719
|
+
static isEditing: boolean;
|
|
720
|
+
static isPreviewing: boolean;
|
|
721
|
+
static get editingPage(): boolean;
|
|
722
|
+
static set editingPage(editingPage: boolean);
|
|
723
|
+
private static prepareComponentSpecToSend;
|
|
724
|
+
static registerBlock(component: any, options: Component): void;
|
|
725
|
+
static registerComponent(component: any, options: Component): void;
|
|
726
|
+
private static addComponent;
|
|
727
|
+
static component(info?: Partial<Component>): (component: Class) => Class;
|
|
728
|
+
static isReact: boolean;
|
|
729
|
+
static get Component(): typeof Builder.component;
|
|
730
|
+
private eventsQueue;
|
|
731
|
+
private throttledClearEventsQueue;
|
|
732
|
+
private processEventsQueue;
|
|
733
|
+
env: string;
|
|
734
|
+
sessionId: string;
|
|
735
|
+
targetContent: boolean;
|
|
736
|
+
contentPerRequest: number;
|
|
737
|
+
allowCustomFonts: boolean;
|
|
738
|
+
private cookies;
|
|
739
|
+
private cachebust;
|
|
740
|
+
private overrideParams;
|
|
741
|
+
private noCache;
|
|
742
|
+
private preview;
|
|
743
|
+
get browserTrackingDisabled(): boolean;
|
|
744
|
+
get canTrack(): boolean;
|
|
745
|
+
set canTrack(canTrack: boolean);
|
|
746
|
+
get apiVersion(): ApiVersion | undefined;
|
|
747
|
+
set apiVersion(apiVersion: ApiVersion | undefined);
|
|
748
|
+
private apiVersion$;
|
|
749
|
+
private canTrack$;
|
|
750
|
+
private apiKey$;
|
|
751
|
+
private authToken$;
|
|
752
|
+
userAttributesChanged: BehaviorSubject<any, any>;
|
|
753
|
+
get editingMode(): boolean;
|
|
754
|
+
set editingMode(value: boolean);
|
|
755
|
+
editingMode$: BehaviorSubject<boolean, any>;
|
|
756
|
+
get editingModel(): string | null;
|
|
757
|
+
set editingModel(value: string | null);
|
|
758
|
+
private findParentElement;
|
|
759
|
+
private findBuilderParent;
|
|
760
|
+
editingModel$: BehaviorSubject<string | null, any>;
|
|
761
|
+
setUserAgent(userAgent: string): void;
|
|
762
|
+
userAgent: string;
|
|
763
|
+
trackingHooks: TrackingHook[];
|
|
764
|
+
/**
|
|
765
|
+
* Set a hook to modify events being tracked from builder, such as impressions and clicks
|
|
766
|
+
*
|
|
767
|
+
* For example, to track the model ID of each event associated with content for querying
|
|
768
|
+
* by mode, you can do
|
|
769
|
+
*
|
|
770
|
+
* builder.setTrackingHook((event, context) => {
|
|
771
|
+
* if (context.content) {
|
|
772
|
+
* event.data.metadata.modelId = context.content.modelId
|
|
773
|
+
* }
|
|
774
|
+
* })
|
|
775
|
+
*/
|
|
776
|
+
setTrackingHook(hook: TrackingHook): void;
|
|
777
|
+
track(eventName: string, properties?: Partial<EventData>, context?: any): void;
|
|
778
|
+
getSessionId(): string;
|
|
779
|
+
visitorId: string;
|
|
780
|
+
getVisitorId(): string;
|
|
781
|
+
trackImpression(contentId: string, variationId?: string, properties?: any, context?: any): void;
|
|
782
|
+
trackConversion(amount?: number, customProperties?: any): void;
|
|
783
|
+
autoTrack: boolean;
|
|
784
|
+
private get isDevelopmentEnv();
|
|
785
|
+
trackInteraction(contentId: string, variationId?: string, alreadyTrackedOne?: boolean, event?: MouseEvent, context?: any): void;
|
|
786
|
+
static overrideUserAttributes: Partial<UserAttributes>;
|
|
787
|
+
trackingUserAttributes: {
|
|
788
|
+
[key: string]: any;
|
|
789
|
+
};
|
|
790
|
+
component(info?: Partial<Component>): (component: Class) => Class;
|
|
791
|
+
get apiKey(): string | null;
|
|
792
|
+
set apiKey(key: string | null);
|
|
793
|
+
get authToken(): string | null;
|
|
794
|
+
set authToken(token: string | null);
|
|
795
|
+
constructor(apiKey?: string | null, request?: IncomingMessage | undefined, response?: ServerResponse<IncomingMessage> | undefined, forceNewInstance?: boolean, authToken?: string | null, apiVersion?: ApiVersion);
|
|
796
|
+
private modifySearch;
|
|
797
|
+
setTestsFromUrl(): void;
|
|
798
|
+
resetOverrides(): void;
|
|
799
|
+
getOverridesFromQueryString(): void;
|
|
800
|
+
private messageFrameLoaded;
|
|
801
|
+
private blockContentLoading;
|
|
802
|
+
private bindMessageListeners;
|
|
803
|
+
observersByKey: {
|
|
804
|
+
[key: string]: BehaviorSubject<BuilderContent[]> | undefined;
|
|
805
|
+
};
|
|
806
|
+
noEditorUpdates: {
|
|
807
|
+
[key: string]: boolean;
|
|
808
|
+
};
|
|
809
|
+
get defaultCanTrack(): boolean;
|
|
810
|
+
init(apiKey: string, canTrack?: boolean, req?: IncomingMessage, res?: ServerResponse, authToken?: string | null, apiVersion?: ApiVersion): this;
|
|
811
|
+
get previewingModel(): string;
|
|
812
|
+
getLocation(): Url;
|
|
813
|
+
getUserAttributes(userAgent?: string): UserAttributes;
|
|
814
|
+
protected overrides: {
|
|
815
|
+
[key: string]: string;
|
|
816
|
+
};
|
|
817
|
+
protected queryOptions: {
|
|
818
|
+
[key: string]: string;
|
|
819
|
+
};
|
|
820
|
+
private getContentQueue;
|
|
821
|
+
private priorContentQueue;
|
|
822
|
+
setUserAttributes(options: object): void;
|
|
823
|
+
/**
|
|
824
|
+
* Set user attributes just for tracking purposes.
|
|
825
|
+
*
|
|
826
|
+
* Do this so properties exist on event objects for querying insights, but
|
|
827
|
+
* won't affect targeting
|
|
828
|
+
*
|
|
829
|
+
* Use this when you want to track properties but don't need to target off
|
|
830
|
+
* of them to optimize cache efficiency
|
|
831
|
+
*/
|
|
832
|
+
setTrackingUserAttributes(attributes: object): void;
|
|
833
|
+
get(modelName: string, options?: GetContentOptions & {
|
|
834
|
+
req?: IncomingMessage;
|
|
835
|
+
res?: ServerResponse;
|
|
836
|
+
apiKey?: string;
|
|
837
|
+
authToken?: string;
|
|
838
|
+
}): BehaviorSubject<any, any>;
|
|
839
|
+
queueGetContent(modelName: string, options?: GetContentOptions): BehaviorSubject<BuilderContent[], any>;
|
|
840
|
+
requestUrl(url: string, options?: {
|
|
841
|
+
headers: {
|
|
842
|
+
[header: string]: number | string | string[] | undefined;
|
|
843
|
+
};
|
|
844
|
+
next?: any;
|
|
845
|
+
}): Promise<any>;
|
|
846
|
+
get host(): string;
|
|
847
|
+
private flushGetContentQueue;
|
|
848
|
+
private testCookiePrefix;
|
|
849
|
+
private processResultsForTests;
|
|
850
|
+
private getTestCookie;
|
|
851
|
+
private cookieQueue;
|
|
852
|
+
private setTestCookie;
|
|
853
|
+
getCookie(name: string): any;
|
|
854
|
+
setCookie(name: string, value: any, expires?: Date): false | void | Cookies;
|
|
855
|
+
getContent(modelName: string, options?: GetContentOptions): BehaviorSubject<BuilderContent[], any>;
|
|
856
|
+
getAll(modelName: string, options?: GetContentOptions & {
|
|
857
|
+
req?: IncomingMessage;
|
|
858
|
+
res?: ServerResponse;
|
|
859
|
+
apiKey?: string;
|
|
860
|
+
}): Promise<BuilderContent[]>;
|
|
861
|
+
}
|
|
862
|
+
export {};
|