@builder.io/sdk-solid 0.7.1-1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,51 +1,950 @@
1
1
  import * as solid_js from 'solid-js';
2
2
 
3
- declare function Blocks(props: any): solid_js.JSX.Element;
3
+ /**
4
+ * This import is used by the Svelte SDK. Do not remove.
5
+ */
6
+ interface ButtonProps {
7
+ attributes?: any;
8
+ text?: string;
9
+ link?: string;
10
+ openLinkInNewTab?: boolean;
11
+ }
12
+ declare function Button(props: ButtonProps): solid_js.JSX.Element;
4
13
 
5
- declare function Button(props: any): solid_js.JSX.Element;
14
+ type JSONValue$1 = string | number | boolean | JSONObject$1 | JSONArray$1;
15
+ interface JSONObject$1 {
16
+ [x: string]: JSONValue$1;
17
+ }
18
+ interface JSONArray$1 extends Array<JSONValue$1> {
19
+ }
20
+ /** @todo typedoc this */
21
+ interface BuilderBlock {
22
+ '@type': '@builder.io/sdk:Element';
23
+ '@version'?: number;
24
+ id?: string;
25
+ tagName?: string;
26
+ layerName?: string;
27
+ groupLocked?: boolean;
28
+ layerLocked?: boolean;
29
+ /** @todo make alias for properties.class */
30
+ class?: string;
31
+ children?: BuilderBlock[];
32
+ responsiveStyles?: {
33
+ large?: Partial<CSSStyleDeclaration>;
34
+ medium?: Partial<CSSStyleDeclaration>;
35
+ small?: Partial<CSSStyleDeclaration>;
36
+ /** @deprecated */
37
+ xsmall?: Partial<CSSStyleDeclaration>;
38
+ };
39
+ component?: {
40
+ name: string;
41
+ options?: any;
42
+ tag?: string;
43
+ };
44
+ bindings?: {
45
+ [key: string]: string;
46
+ };
47
+ meta?: {
48
+ [key: string]: JSONValue$1;
49
+ };
50
+ actions?: {
51
+ [key: string]: string;
52
+ };
53
+ properties?: {
54
+ [key: string]: string;
55
+ };
56
+ code?: {
57
+ bindings?: {
58
+ [key: string]: string;
59
+ };
60
+ actions?: {
61
+ [key: string]: string;
62
+ };
63
+ };
64
+ repeat?: {
65
+ collection: string;
66
+ itemName?: string;
67
+ } | null;
68
+ animations?: any[];
69
+ style?: Partial<CSSStyleDeclaration>;
70
+ /**
71
+ * generated by the "Hide If" binding
72
+ */
73
+ hide?: boolean;
74
+ /**
75
+ * generated by the "Show If" binding
76
+ */
77
+ show?: boolean;
78
+ }
6
79
 
7
- declare function Columns(props: any): solid_js.JSX.Element;
80
+ type ApiVersion = 'v2' | 'v3';
8
81
 
9
- declare function ContentVariants(props: any): solid_js.JSX.Element;
82
+ interface Input {
83
+ /** This is the name of the component prop this input represents */
84
+ name: string;
85
+ /** A friendlier name to show in the UI if the component prop name is not ideal for end users */
86
+ friendlyName?: string;
87
+ /** @hidden @deprecated */
88
+ description?: string;
89
+ /** A default value to use */
90
+ defaultValue?: any;
91
+ /**
92
+ * The type of input to use, such as 'text'
93
+ *
94
+ * See all available inputs [here](https://www.builder.io/c/docs/custom-react-components#input-types)
95
+ * and you can create your own custom input types and associated editor UIs with [plugins](https://www.builder.io/c/docs/extending/plugins)
96
+ */
97
+ type: string;
98
+ /** Is this input mandatory or not */
99
+ required?: boolean;
100
+ /** @hidden */
101
+ autoFocus?: boolean;
102
+ subFields?: Input[];
103
+ /**
104
+ * Additional text to render in the UI to give guidance on how to use this
105
+ *
106
+ * @example
107
+ * ```js
108
+ * helperText: 'Be sure to use a proper URL, starting with "https://"'
109
+ * 111
110
+ */
111
+ helperText?: string;
112
+ /** @hidden */
113
+ allowedFileTypes?: string[];
114
+ /** @hidden */
115
+ imageHeight?: number;
116
+ /** @hidden */
117
+ imageWidth?: number;
118
+ /** @hidden */
119
+ mediaHeight?: number;
120
+ /** @hidden */
121
+ mediaWidth?: number;
122
+ /** @hidden */
123
+ hideFromUI?: boolean;
124
+ /** @hidden */
125
+ modelId?: string;
126
+ /**
127
+ * Number field type validation maximum accepted input
128
+ */
129
+ max?: number;
130
+ /**
131
+ * Number field type validation minimum accepted input
132
+ */
133
+ min?: number;
134
+ /**
135
+ * Number field type step size when using arrows
136
+ */
137
+ step?: number;
138
+ /**
139
+ * Set this to `true` to show the editor for this input when
140
+ * children of this component are selected. This is useful for things
141
+ * like Tabs, such that users may not always select the Tabs component
142
+ * directly but will still be looking for how to add additional tabs
143
+ */
144
+ broadcast?: boolean;
145
+ /**
146
+ * Set this to `true` to show the editor for this input when
147
+ * group locked parents of this component are selected. This is useful
148
+ * to bubble up important inputs for locked groups, like text and images
149
+ */
150
+ bubble?: boolean;
151
+ /**
152
+ * Set this to `true` if you want this component to be translatable
153
+ */
154
+ localized?: boolean;
155
+ /** @hidden */
156
+ options?: {
157
+ [key: string]: any;
158
+ };
159
+ /**
160
+ * For "text" input type, specifying an enum will show a dropdown of options instead
161
+ */
162
+ enum?: string[] | {
163
+ label: string;
164
+ value: any;
165
+ helperText?: string;
166
+ }[];
167
+ /** Regex field validation for all string types (text, longText, html, url, etc) */
168
+ regex?: {
169
+ /** pattern to test, like "^\/[a-z]$" */
170
+ pattern: string;
171
+ /** flags for the RegExp constructor, e.g. "gi" */
172
+ options?: string;
173
+ /**
174
+ * Friendly message to display to end-users if the regex fails, e.g.
175
+ * "You must use a relative url starting with '/...' "
176
+ */
177
+ message: string;
178
+ };
179
+ /**
180
+ * Set this to `true` to put this under the "show more" section of
181
+ * the options editor. Useful for things that are more advanced
182
+ * or more rarely used and don't need to be too prominent
183
+ */
184
+ advanced?: boolean;
185
+ /** @hidden */
186
+ /** @hidden */
187
+ code?: boolean;
188
+ /** @hidden */
189
+ richText?: boolean;
190
+ /** @hidden */
191
+ showIf?: ((options: Map<string, any>) => boolean) | string;
192
+ /** @hidden */
193
+ copyOnAdd?: boolean;
194
+ /**
195
+ * Use optionally with inputs of type `reference`. Restricts the content entry picker to a specific model by name.
196
+ */
197
+ model?: string;
198
+ valueType?: {
199
+ type?: string;
200
+ };
201
+ onChange?: ((options: Map<string, any>) => void | Promise<void>) | string;
202
+ }
203
+
204
+ type Nullable<T> = T | null | undefined;
205
+ type Dictionary<T> = {
206
+ [key: string]: T;
207
+ };
208
+ type Prettify<T> = {
209
+ [K in keyof T]: T[K];
210
+ } & {};
211
+
212
+ interface Breakpoints {
213
+ small: number;
214
+ medium: number;
215
+ }
216
+ interface BuilderContentVariation {
217
+ data?: {
218
+ title?: string;
219
+ blocks?: BuilderBlock[];
220
+ inputs?: Input[];
221
+ state?: {
222
+ [key: string]: any;
223
+ };
224
+ jsCode?: string;
225
+ tsCode?: string;
226
+ httpRequests?: {
227
+ [key: string]: string;
228
+ };
229
+ [key: string]: any;
230
+ };
231
+ name?: string;
232
+ testRatio?: number;
233
+ id?: string;
234
+ meta?: {
235
+ breakpoints?: Nullable<Breakpoints>;
236
+ [key: string]: any;
237
+ };
238
+ }
239
+ interface BuilderContent extends BuilderContentVariation {
240
+ '@version'?: number;
241
+ published?: 'published' | 'draft' | 'archived';
242
+ modelId?: string;
243
+ priority?: number;
244
+ lastUpdated?: number;
245
+ startDate?: number;
246
+ endDate?: number;
247
+ variations?: {
248
+ [id: string]: BuilderContentVariation;
249
+ };
250
+ testVariationId?: string;
251
+ testVariationName?: string;
252
+ }
253
+
254
+ type JSONValue = string | number | boolean | JSONObject | JSONArray;
255
+ interface JSONObject {
256
+ [x: string]: JSONValue;
257
+ }
258
+ interface JSONArray extends Array<JSONValue> {
259
+ }
260
+ /** @todo typedoc this */
261
+ interface BuilderElement {
262
+ '@type': '@builder.io/sdk:Element';
263
+ '@version'?: number;
264
+ id?: string;
265
+ tagName?: string;
266
+ layerName?: string;
267
+ groupLocked?: boolean;
268
+ layerLocked?: boolean;
269
+ /** @todo make alias for properties.class */
270
+ class?: string;
271
+ children?: BuilderElement[];
272
+ responsiveStyles?: {
273
+ large?: Partial<CSSStyleDeclaration>;
274
+ medium?: Partial<CSSStyleDeclaration>;
275
+ small?: Partial<CSSStyleDeclaration>;
276
+ /** @deprecated */
277
+ xsmall?: Partial<CSSStyleDeclaration>;
278
+ };
279
+ component?: {
280
+ name: string;
281
+ options?: any;
282
+ tag?: string;
283
+ };
284
+ bindings?: {
285
+ [key: string]: string;
286
+ };
287
+ meta?: {
288
+ [key: string]: JSONValue;
289
+ };
290
+ actions?: {
291
+ [key: string]: string;
292
+ };
293
+ properties?: {
294
+ [key: string]: string;
295
+ };
296
+ code?: {
297
+ bindings?: {
298
+ [key: string]: string;
299
+ };
300
+ actions?: {
301
+ [key: string]: string;
302
+ };
303
+ };
304
+ repeat?: {
305
+ collection: string;
306
+ itemName?: string;
307
+ } | null;
308
+ animations?: Animation[];
309
+ }
310
+ interface Animation {
311
+ }
312
+
313
+ interface ComponentInfo {
314
+ /**
315
+ * Name your component something unique, e.g. 'MyButton'. You can override built-in components
316
+ * by registering a component with the same name, e.g. 'Text', to replace the built-in text component
317
+ */
318
+ name: string;
319
+ description?: string;
320
+ /**
321
+ * Link to a documentation page for this component
322
+ */
323
+ docsLink?: string;
324
+ image?: string;
325
+ /**
326
+ * Input schema for your component for users to fill in the options
327
+ */
328
+ inputs?: Input[];
329
+ class?: any;
330
+ type?: 'angular' | 'webcomponent' | 'react' | 'vue';
331
+ defaultStyles?: {
332
+ [key: string]: string;
333
+ };
334
+ /**
335
+ * Turn on if your component can accept children. Be sure to use in combination with
336
+ * withChildren(YourComponent) like here
337
+ * github.com/BuilderIO/builder/blob/master/examples/react-design-system/src/components/HeroWithChildren/HeroWithChildren.builder.js#L5
338
+ */
339
+ canHaveChildren?: boolean;
340
+ fragment?: boolean;
341
+ /**
342
+ * Do not wrap a component in a dom element. Be sure to use {...props.attributes} with this option
343
+ * like here github.com/BuilderIO/builder/blob/master/packages/react/src/blocks/forms/Input.tsx#L34
344
+ */
345
+ noWrap?: boolean;
346
+ /**
347
+ * TO-DO: make this optional only for RSC SDK.
348
+ *
349
+ * Set this to `true` if your component is a React Server Component (RSC).
350
+ */
351
+ isRSC?: boolean;
352
+ /**
353
+ * Default children
354
+ */
355
+ defaultChildren?: BuilderElement[];
356
+ defaults?: Partial<BuilderElement>;
357
+ hooks?: {
358
+ [key: string]: string | Function;
359
+ };
360
+ /**
361
+ * Hide your component in editor, useful for gradually deprecating components
362
+ */
363
+ hideFromInsertMenu?: boolean;
364
+ tag?: string;
365
+ static?: boolean;
366
+ /**
367
+ * 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
368
+ */
369
+ models?: string[];
370
+ /**
371
+ * Specify restrictions direct children must match
372
+ */
373
+ childRequirements?: {
374
+ /** Message to show when this doesn't match, e.g. "Children of 'Columns' must be a 'Column'" */
375
+ message: string;
376
+ /** Simple way to say children must be a specific component name */
377
+ component?: string;
378
+ /**
379
+ * More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
380
+ * of what the children objects should match, e.g.
381
+ *
382
+ * @example
383
+ * query: {
384
+ * // Child of this element must be a 'Button' or 'Text' component
385
+ * 'component.name': { $in: ['Button', 'Text'] }
386
+ * }
387
+ */
388
+ query?: any;
389
+ };
390
+ /**
391
+ * Specify restrictions any parent must match
392
+ */
393
+ requiresParent?: {
394
+ /** Message to show when this doesn't match, e.g. "'Add to cart' buttons must be within a 'Product box'" */
395
+ message: string;
396
+ /** Simple way to say a parent must be a specific component name, e.g. 'Product box' */
397
+ component?: string;
398
+ /**
399
+ * More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
400
+ * of what at least one parent in the parents hierarchy should match, e.g.
401
+ *
402
+ * @example
403
+ * query: {
404
+ * // Thils element must be somewhere inside either a 'Product box' or 'Collection' component
405
+ * 'component.name': { $in: ['Product Box', 'Collection'] }
406
+ * }
407
+ */
408
+ query?: any;
409
+ };
410
+ friendlyName?: string;
411
+ /**
412
+ * Use to restrict access to your component based on a the current user permissions
413
+ * By default components will show to all users
414
+ * for more information on permissions in builder check https://www.builder.io/c/docs/guides/roles-and-permissions
415
+ */
416
+ requiredPermissions?: Array<Permission>;
417
+ hidden?: boolean;
418
+ }
419
+ type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create';
420
+
421
+ type RegisteredComponent = ComponentInfo & {
422
+ component: any;
423
+ };
424
+ type RegisteredComponents = Dictionary<RegisteredComponent>;
425
+ type BuilderRenderState = Record<string, unknown>;
426
+ type BuilderRenderContext = Record<string, unknown>;
427
+ interface BuilderContextInterface {
428
+ content: Nullable<BuilderContent>;
429
+ context: BuilderRenderContext;
430
+ /**
431
+ * The state of the application.
432
+ *
433
+ * NOTE: see `localState` below to understand how it is different from `rootState`.
434
+ */
435
+ rootState: BuilderRenderState;
436
+ /**
437
+ * Some frameworks have a `setState` function which needs to be invoked to notify
438
+ * the framework of state change. (other frameworks don't in which case it is `undefined')
439
+ */
440
+ rootSetState: ((rootState: BuilderRenderState) => void) | undefined;
441
+ /**
442
+ * The local state of the current component. This is different from `rootState` in that
443
+ * it can be a child state created by a repeater containing local state.
444
+ * The `rootState` is where all of the state mutations are actually stored.
445
+ */
446
+ localState: BuilderRenderState | undefined;
447
+ apiKey: string | null;
448
+ apiVersion: ApiVersion | undefined;
449
+ componentInfos: Dictionary<ComponentInfo>;
450
+ inheritedStyles: Record<string, unknown>;
451
+ }
452
+
453
+ type PropsWithBuilderData<T> = T & {
454
+ builderBlock: BuilderBlock;
455
+ builderContext: BuilderContextInterface;
456
+ };
457
+ type BuilderComponentsProp = {
458
+ builderComponents: RegisteredComponents;
459
+ };
460
+
461
+ type Column = {
462
+ blocks: BuilderBlock[];
463
+ width?: number;
464
+ };
465
+ type StackColumnsAt = "tablet" | "mobile" | "never";
466
+ interface ColumnProps extends BuilderComponentsProp {
467
+ columns?: Column[];
468
+ builderBlock: BuilderBlock;
469
+ space?: number;
470
+ stackColumnsAt?: StackColumnsAt;
471
+ reverseColumnsWhenStacked?: boolean;
472
+ }
473
+
474
+ declare function Columns(props: PropsWithBuilderData<ColumnProps>): solid_js.JSX.Element;
475
+
476
+ interface FragmentProps {
477
+ maxWidth?: number;
478
+ attributes?: any;
479
+ children?: any;
480
+ }
481
+ declare function FragmentComponent(props: FragmentProps): solid_js.JSX.Element;
482
+
483
+ interface ImageProps {
484
+ className?: string;
485
+ image: string;
486
+ sizes?: string;
487
+ lazy?: boolean;
488
+ height?: number;
489
+ width?: number;
490
+ altText?: string;
491
+ backgroundSize?: "cover" | "contain";
492
+ backgroundPosition?: string;
493
+ srcset?: string;
494
+ aspectRatio?: number;
495
+ children?: any;
496
+ fitContent?: boolean;
497
+ builderBlock?: BuilderBlock;
498
+ noWebp?: boolean;
499
+ src?: string;
500
+ }
501
+
502
+ declare function Image(props: ImageProps): solid_js.JSX.Element;
503
+
504
+ /**
505
+ * This import is used by the Svelte SDK. Do not remove.
506
+ */
507
+ interface SectionProps {
508
+ maxWidth?: number;
509
+ attributes?: any;
510
+ children?: any;
511
+ builderBlock?: any;
512
+ }
513
+ declare function SectionComponent(props: SectionProps): solid_js.JSX.Element;
514
+
515
+ /**
516
+ * This import is used by the Svelte SDK. Do not remove.
517
+ */
518
+ interface SymbolInfo {
519
+ model?: string;
520
+ entry?: string;
521
+ data?: any;
522
+ content?: BuilderContent;
523
+ inline?: boolean;
524
+ dynamic?: boolean;
525
+ }
526
+ /**
527
+ * This import is used by the Svelte SDK. Do not remove.
528
+ */
529
+ interface SymbolProps extends BuilderComponentsProp {
530
+ symbol?: SymbolInfo;
531
+ dataOnly?: boolean;
532
+ dynamic?: boolean;
533
+ attributes?: any;
534
+ inheritState?: boolean;
535
+ }
536
+
537
+ declare function Symbol(props: PropsWithBuilderData<SymbolProps>): solid_js.JSX.Element;
538
+
539
+ interface TextProps {
540
+ text?: string;
541
+ }
542
+ declare function Text(props: TextProps): solid_js.JSX.Element;
10
543
 
11
- declare function FragmentComponent(props: any): solid_js.JSX.Element;
544
+ interface VideoProps {
545
+ attributes?: any;
546
+ video?: string;
547
+ autoPlay?: boolean;
548
+ controls?: boolean;
549
+ muted?: boolean;
550
+ loop?: boolean;
551
+ playsInline?: boolean;
552
+ aspectRatio?: number;
553
+ width?: number;
554
+ height?: number;
555
+ fit?: "contain" | "cover" | "fill";
556
+ preload?: "auto" | "metadata" | "none";
557
+ position?: "center" | "top" | "left" | "right" | "bottom" | "top left" | "top right" | "bottom left" | "bottom right";
558
+ posterImage?: string;
559
+ lazyLoad?: boolean;
560
+ }
561
+ declare function Video(props: VideoProps): solid_js.JSX.Element;
12
562
 
13
- declare function Image(props: any): solid_js.JSX.Element;
563
+ type BlocksWrapperProps = {
564
+ blocks: BuilderBlock[] | undefined;
565
+ parent: string | undefined;
566
+ path: string | undefined;
567
+ styleProp: Record<string, any> | undefined;
568
+ };
569
+
570
+ type BlocksProps = Partial<BlocksWrapperProps> & {
571
+ context?: BuilderContextInterface;
572
+ registeredComponents?: RegisteredComponents;
573
+ };
14
574
 
15
- declare function SectionComponent(props: any): solid_js.JSX.Element;
575
+ declare function Blocks(props: BlocksProps): solid_js.JSX.Element;
16
576
 
17
- declare function Symbol(props: any): solid_js.JSX.Element;
577
+ interface ContentVariantsPrps {
578
+ content?: Nullable<BuilderContent>;
579
+ model?: string;
580
+ data?: {
581
+ [key: string]: any;
582
+ };
583
+ context?: BuilderRenderContext;
584
+ apiKey: string;
585
+ apiVersion?: ApiVersion;
586
+ customComponents?: RegisteredComponent[];
587
+ canTrack?: boolean;
588
+ locale?: string;
589
+ /** @deprecated use `enrich` instead **/
590
+ includeRefs?: boolean;
591
+ enrich?: boolean;
592
+ }
18
593
 
19
- declare function Text(props: any): solid_js.JSX.Element;
594
+ type VariantsProviderProps = ContentVariantsPrps & {
595
+ /**
596
+ * For internal use only. Do not provide this prop.
597
+ */
598
+ __isNestedRender?: boolean;
599
+ };
20
600
 
21
- declare function Video(props: any): solid_js.JSX.Element;
601
+ declare function ContentVariants(props: VariantsProviderProps): solid_js.JSX.Element;
22
602
 
603
+ /**
604
+ * @deprecated Renamed to `Blocks`.
605
+ */
23
606
  declare const RenderBlocks: typeof Blocks;
607
+ /**
608
+ * @deprecated Renamed to `Content`.
609
+ */
24
610
  declare const RenderContent: typeof ContentVariants;
25
611
 
26
- declare function _processContentResult(_0: any, _1: any, ..._2: any[]): Promise<any>;
27
- declare function fetchEntries(options: any): Promise<any>;
28
- declare function fetchOneEntry(options: any): Promise<any>;
29
- declare function getAllContent(options: any): Promise<any>;
30
- declare function getContent(options: any): Promise<any>;
612
+ declare function isEditing(): boolean;
31
613
 
32
- declare function createRegisterComponentMessage(info: any): {
614
+ declare function isPreviewing(): boolean;
615
+
616
+ declare const createRegisterComponentMessage: (info: ComponentInfo) => {
33
617
  type: string;
34
- data: any;
618
+ data: ComponentInfo;
35
619
  };
36
620
 
37
- declare function fetchBuilderProps(_args: any): Promise<any>;
621
+ type DeepPartial<T> = {
622
+ [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]>;
623
+ };
38
624
 
39
- declare function getBuilderSearchParams(_options: any): {};
625
+ interface InsertMenuItem {
626
+ name: string;
627
+ icon?: string;
628
+ item: DeepPartial<BuilderBlock>;
629
+ }
630
+ interface InsertMenuConfig {
631
+ name: string;
632
+ priority?: number;
633
+ persist?: boolean;
634
+ advanced?: boolean;
635
+ items: InsertMenuItem[];
636
+ }
637
+ declare function register(type: 'insertMenu', info: InsertMenuConfig): void;
638
+ declare function register(type: string, info: any): void;
40
639
 
41
- declare function isEditing(): boolean;
640
+ type Settings = {
641
+ customInsertMenu?: boolean;
642
+ };
643
+ declare function setEditorSettings(newSettings: Settings): void;
42
644
 
43
- declare function isPreviewing(): boolean;
645
+ interface GetContentOptions {
646
+ /** The model to get content for */
647
+ model: string;
648
+ /** Your public API key */
649
+ apiKey: string;
650
+ /** Number of items to fetch. Default is 1 */
651
+ limit?: number;
652
+ /**
653
+ * Use to specify an offset for pagination of results. The default is 0.
654
+ */
655
+ offset?: number;
656
+ /**
657
+ * User attribute key value pairs to be used for targeting
658
+ * https://www.builder.io/c/docs/custom-targeting-attributes
659
+ *
660
+ * e.g.
661
+ * ```js
662
+ * userAttributes: {
663
+ * urlPath: '/',
664
+ * returnVisitor: true,
665
+ * device: 'mobile'
666
+ * }
667
+ * ```
668
+ */
669
+ userAttributes?: (Record<string, string> & {
670
+ urlPath?: string;
671
+ }) | null;
672
+ /**
673
+ * Mongodb style query of your data. E.g.:
674
+ *
675
+ * ```js
676
+ * query: {
677
+ * id: 'abc123',
678
+ * data: {
679
+ * myCustomField: { $gt: 20 },
680
+ * }
681
+ * }
682
+ * ```
683
+ *
684
+ * See more info on MongoDB's query operators and format.
685
+ *
686
+ * @see {@link https://docs.mongodb.com/manual/reference/operator/query/}
687
+ */
688
+ query?: Record<string, any>;
689
+ /**
690
+ * Any other API options.
691
+ * Accepts both a key/value object or a `URLSearchParams` instance
692
+ * */
693
+ options?: Record<string, any> | URLSearchParams;
694
+ /**
695
+ * If set to `true`, it will lazy load symbols/references.
696
+ * If set to `false`, it will render the entire content tree eagerly.
697
+ * @deprecated use `enrich` instead
698
+ */
699
+ noTraverse?: boolean;
700
+ /**
701
+ * If set to `false`, it will not use cookies to target content. Therefore, A/B Testing will be disabled and
702
+ * only the default variation will be returned to every user.
703
+ *
704
+ * Defaults to `true`.
705
+ */
706
+ canTrack?: boolean;
707
+ /**
708
+ * Include content of references in the response. Defaults to `true`.
709
+ * @deprecated use `enrich` instead
710
+ */
711
+ includeRefs?: boolean;
712
+ /**
713
+ * Include multilevel references in the response.
714
+ */
715
+ enrich?: boolean;
716
+ /**
717
+ * If provided, the API will auto-resolve localized objects to the value of this `locale` key.
718
+ */
719
+ locale?: string;
720
+ /**
721
+ * If provided, sets the Builder API version used to fetch content.
722
+ *
723
+ * Defaults to `v3`.
724
+ */
725
+ apiVersion?: 'v2' | 'v3';
726
+ /**
727
+ * Only include these fields.
728
+ * Note: 'omit' takes precedence over 'fields'
729
+ *
730
+ * @example
731
+ * ```
732
+ * fields: 'id, name, data.customField'
733
+ * ```
734
+ */
735
+ fields?: string;
736
+ /**
737
+ * Omit only these fields.
738
+ * Note: 'omit' takes precedence over 'fields'
739
+ *
740
+ * @example
741
+ * ```
742
+ * omit: 'data.bigField,data.blocks'
743
+ * ```
744
+ */
745
+ omit?: string;
746
+ /**
747
+ * Seconds to cache content. Sets the max-age of the cache-control header
748
+ * response header.
749
+ *
750
+ * Use a higher value for better performance, lower for content that will change more frequently
751
+ *
752
+ * @see {@link https://www.builder.io/c/docs/query-api#__next:~:text=%26includeRefs%3Dtrue-,cacheSeconds,-No}
753
+ */
754
+ cacheSeconds?: number;
755
+ /**
756
+ * Builder.io uses stale-while-revalidate caching at the CDN level. This means we always serve
757
+ * from edge cache and update caches in the background for maximum possible performance. This also
758
+ * means that the more frequently content is requested, the more fresh it will be. The longest we
759
+ * will ever hold something in stale cache is 1 day by default, and you can set this to be shorter
760
+ * yourself as well. We suggest keeping this high unless you have content that must change rapidly
761
+ * and gets very little traffic.
762
+ *
763
+ * @see {@link https://www.fastly.com/blog/prevent-application-network-instability-serve-stale-content}
764
+ */
765
+ staleCacheSeconds?: number;
766
+ /**
767
+ * Property to order results by.
768
+ * Use 1 for ascending and -1 for descending.
769
+ *
770
+ * The key is what you're sorting on, so the following example sorts by createdDate
771
+ * and because the value is 1, the sort is ascending.
772
+ *
773
+ * @example
774
+ * ```
775
+ * createdDate: 1
776
+ * ```
777
+ */
778
+ sort?: {
779
+ [key: string]: 1 | -1;
780
+ };
781
+ /**
782
+ * Include content entries in a response that are still in
783
+ * draft mode and un-archived. Default is false.
784
+ */
785
+ includeUnpublished?: boolean;
786
+ }
44
787
 
45
- declare function register(type: any, info: any): void;
788
+ /**
789
+ * Returns a the first entry that matches the given options.
790
+ */
791
+ declare function fetchOneEntry(options: GetContentOptions): Promise<BuilderContent | null>;
792
+ /**
793
+ * @deprecated `getContent` was renamed to `fetchOneEntry`. This is a temporary alias to avoid breaking changes.
794
+ *
795
+ * NOTE: consider using `fetchBuilderProps` instead for easier setup.
796
+ */
797
+ declare const getContent: typeof fetchOneEntry;
798
+ type ContentResults = {
799
+ results: BuilderContent[];
800
+ };
801
+ /**
802
+ * @internal Exported only for testing purposes. Do not use.
803
+ */
804
+ declare const _processContentResult: (options: GetContentOptions, content: ContentResults, url?: URL) => Promise<ContentResults>;
805
+ /**
806
+ * Returns a paginated array of entries that match the given options.
807
+ */
808
+ declare function fetchEntries(options: GetContentOptions): Promise<ContentResults>;
809
+ /**
810
+ * @deprecated `getAllContent` was renamed to `fetchEntries`. This is a temporary alias to avoid breaking changes.
811
+ */
812
+ declare const getAllContent: typeof fetchEntries;
813
+
814
+ type QueryObject = Record<string, string | string[]>;
815
+ /**
816
+ * Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
817
+ * relevant to the Builder SDK.
818
+ *
819
+ * @returns
820
+ */
821
+ declare const getBuilderSearchParams: (_options: QueryObject | URLSearchParams | undefined) => QueryObject;
822
+
823
+ interface Event {
824
+ /**
825
+ * The type of your event.
826
+ *
827
+ * Examples: `click`, `conversion`, `pageview`, `impression`
828
+ */
829
+ type: string;
830
+ data: {
831
+ /**
832
+ * (Optional) The content's ID. Useful if this event pertains to a specific piece of content.
833
+ */
834
+ contentId?: string;
835
+ /**
836
+ * This is the ID of the space that the content belongs to.
837
+ */
838
+ ownerId: string;
839
+ /**
840
+ * (Optional) metadata that you want to provide with your event.
841
+ */
842
+ metadata?: Dictionary<any>;
843
+ /**
844
+ * Session ID of the user. This is provided by the SDK by checking session storage.
845
+ */
846
+ sessionId: string | undefined;
847
+ /**
848
+ * Visitor ID of the user. This is provided by the SDK by checking cookies.
849
+ */
850
+ visitorId: string | undefined;
851
+ /**
852
+ * (Optional) If running an A/B test, the ID of the variation that the user is in.
853
+ */
854
+ variationId?: string;
855
+ [index: string]: any;
856
+ };
857
+ }
858
+ type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | 'variationId' | 'metadata'> & {
859
+ /**
860
+ * Your organization's API key.
861
+ */
862
+ apiKey: Event['data']['ownerId'];
863
+ /**
864
+ * (Optional) Any additional (non-metadata) properties to add to the event.
865
+ */
866
+ [index: string]: any;
867
+ };
868
+ declare const track: (args: EventProperties) => Promise<void | Response>;
869
+
870
+ type OptionalFieldsOnly<T> = {
871
+ [K in keyof T as T[K] extends Required<T>[K] ? never : K]: T[K];
872
+ };
873
+ type RequiredFieldsOnly<T> = {
874
+ [K in keyof T as T[K] extends Required<T>[K] ? K : never]: T[K];
875
+ };
876
+ type Enforced<T> = {
877
+ [K in keyof T]-?: T[K];
878
+ };
879
+ type AndUndefined<T> = {
880
+ [K in keyof T]: T[K] | undefined;
881
+ };
882
+ /**
883
+ * Enforce that all optional fields are undefined
884
+ * @example
885
+ * type Foo = { a: string, b?: number }
886
+ * type Bar = EnforcePartials<Foo> // { a: string, b: number | undefined }
887
+ */
888
+ type EnforcePartials<From> = Prettify<AndUndefined<Enforced<OptionalFieldsOnly<From>>> & RequiredFieldsOnly<From>>;
46
889
 
47
- declare function setEditorSettings(newSettings: any): void;
890
+ interface InternalRenderProps {
891
+ /**
892
+ * TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
893
+ */
894
+ classNameProp: string | undefined;
895
+ showContent: boolean;
896
+ isSsrAbTest: boolean;
897
+ }
898
+ type ContentProps = InternalRenderProps & EnforcePartials<ContentVariantsPrps>;
48
899
 
49
- declare function track(args: any): Promise<any>;
900
+ type GetBuilderPropsOptions = (Omit<GetContentOptions, 'model'> & {
901
+ model?: string;
902
+ }) & ({
903
+ /**
904
+ * The current URL path. Used to determine the `urlPath` for targeting content.
905
+ *
906
+ * Cannot be used with `url`.
907
+ */
908
+ path: string;
909
+ /**
910
+ * The current URL search params. Used to parse the `searchParams` for targeting content.
911
+ *
912
+ * Cannot be used with `url`.
913
+ */
914
+ searchParams?: URLSearchParams | Dictionary<string | string[]>;
915
+ url?: undefined;
916
+ } | {
917
+ /**
918
+ * The current URL. Used to determine the `urlPath` for targeting content and
919
+ * to parse the `searchParams` for targeting content.
920
+ *
921
+ * Cannot be used with `path` or `searchParams`.
922
+ */
923
+ url: URL;
924
+ path?: undefined;
925
+ searchParams?: undefined;
926
+ } | {
927
+ url?: undefined;
928
+ path?: undefined;
929
+ searchParams?: undefined;
930
+ });
931
+ /**
932
+ * Given an `apiKey` and `url` (or `path` + `searchParams`), provides all props that `Content` needs to render Builder Content.
933
+ *
934
+ * @example
935
+ * ```jsx
936
+ * const builderProps = await fetchBuilderProps({
937
+ * apiKey: 'API_KEY',
938
+ * // provide `url`
939
+ * url: yourPageUrl,
940
+ * // OR provide `path` + `searchParams`
941
+ * path: yourPath,
942
+ * searchParams: yourSearchParams,
943
+ * });
944
+ *
945
+ * return <Content {...builderProps} />;
946
+ * ```
947
+ */
948
+ declare const fetchBuilderProps: (_args: GetBuilderPropsOptions) => Promise<ContentVariantsPrps>;
50
949
 
51
- export { Blocks, Button, Columns, ContentVariants as Content, FragmentComponent as Fragment, Image, RenderBlocks, RenderContent, SectionComponent as Section, Symbol, Text, Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, track };
950
+ export { Blocks, Button, Columns, ComponentInfo, ContentVariants as Content, ContentProps, FragmentComponent as Fragment, Image, InsertMenuConfig, InsertMenuItem, RegisteredComponent, RenderBlocks, RenderContent, SectionComponent as Section, Settings, Symbol, Text, Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, track };