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