@builder.io/sdk-svelte 0.13.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/components/content/components/enable-editor.svelte +0 -6
- package/lib/browser/components/content/components/enable-editor.svelte.d.ts +0 -1
- package/lib/browser/components/content/content.svelte +1 -15
- package/lib/browser/components/content/content.svelte.d.ts +0 -1
- package/lib/browser/components/content-variants/content-variants.svelte +0 -3
- package/lib/browser/components/content-variants/content-variants.svelte.d.ts +0 -1
- package/lib/browser/components/content-variants/content-variants.types.d.ts +0 -2
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/get-content/generate-content-url.js +12 -7
- package/lib/browser/functions/get-content/index.d.ts +0 -10
- package/lib/browser/functions/get-content/index.js +0 -10
- package/lib/browser/functions/get-content/types.d.ts +0 -11
- package/lib/browser/functions/register-component.d.ts +0 -9
- package/lib/browser/functions/register-component.js +0 -15
- package/lib/browser/index-helpers/blocks-exports.d.ts +0 -8
- package/lib/browser/index-helpers/blocks-exports.js +0 -8
- package/lib/browser/server-index.d.ts +1 -1
- package/lib/browser/server-index.js +1 -1
- package/lib/edge/components/content/components/enable-editor.svelte +0 -6
- package/lib/edge/components/content/components/enable-editor.svelte.d.ts +0 -1
- package/lib/edge/components/content/content.svelte +1 -15
- package/lib/edge/components/content/content.svelte.d.ts +0 -1
- package/lib/edge/components/content-variants/content-variants.svelte +0 -3
- package/lib/edge/components/content-variants/content-variants.svelte.d.ts +0 -1
- package/lib/edge/components/content-variants/content-variants.types.d.ts +0 -2
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/get-content/generate-content-url.js +12 -7
- package/lib/edge/functions/get-content/index.d.ts +0 -10
- package/lib/edge/functions/get-content/index.js +0 -10
- package/lib/edge/functions/get-content/types.d.ts +0 -11
- package/lib/edge/functions/register-component.d.ts +0 -9
- package/lib/edge/functions/register-component.js +0 -15
- package/lib/edge/index-helpers/blocks-exports.d.ts +0 -8
- package/lib/edge/index-helpers/blocks-exports.js +0 -8
- package/lib/edge/server-index.d.ts +1 -1
- package/lib/edge/server-index.js +1 -1
- package/lib/node/components/content/components/enable-editor.svelte +0 -6
- package/lib/node/components/content/components/enable-editor.svelte.d.ts +0 -1
- package/lib/node/components/content/content.svelte +1 -15
- package/lib/node/components/content/content.svelte.d.ts +0 -1
- package/lib/node/components/content-variants/content-variants.svelte +0 -3
- package/lib/node/components/content-variants/content-variants.svelte.d.ts +0 -1
- package/lib/node/components/content-variants/content-variants.types.d.ts +0 -2
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/get-content/generate-content-url.js +12 -7
- package/lib/node/functions/get-content/index.d.ts +0 -10
- package/lib/node/functions/get-content/index.js +0 -10
- package/lib/node/functions/get-content/types.d.ts +0 -11
- package/lib/node/functions/register-component.d.ts +0 -9
- package/lib/node/functions/register-component.js +0 -15
- package/lib/node/index-helpers/blocks-exports.d.ts +0 -8
- package/lib/node/index-helpers/blocks-exports.js +0 -8
- package/lib/node/server-index.d.ts +1 -1
- package/lib/node/server-index.js +1 -1
- package/package.json +1 -1
- package/src/components/content/components/enable-editor.svelte +0 -6
- package/src/components/content/content.svelte +1 -18
- package/src/components/content-variants/content-variants.svelte +0 -3
- package/src/components/content-variants/content-variants.types.ts +0 -3
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/get-content/generate-content-url.ts +9 -9
- package/src/functions/get-content/index.ts +1 -13
- package/src/functions/get-content/types.ts +0 -13
- package/src/functions/register-component.ts +0 -18
- package/src/index-helpers/blocks-exports.ts +1 -10
- package/src/server-index.ts +1 -1
|
@@ -26,7 +26,6 @@ export let context = undefined;
|
|
|
26
26
|
export let canTrack = undefined;
|
|
27
27
|
export let apiKey;
|
|
28
28
|
export let locale = undefined;
|
|
29
|
-
export let includeRefs = undefined;
|
|
30
29
|
export let enrich = undefined;
|
|
31
30
|
export let content = undefined;
|
|
32
31
|
export let showContent;
|
|
@@ -179,11 +178,6 @@ function elementRef_onIniteditingbldr(event) {
|
|
|
179
178
|
locale: locale,
|
|
180
179
|
}
|
|
181
180
|
: {}),
|
|
182
|
-
...(includeRefs
|
|
183
|
-
? {
|
|
184
|
-
includeRefs: includeRefs,
|
|
185
|
-
}
|
|
186
|
-
: {}),
|
|
187
181
|
...(enrich
|
|
188
182
|
? {
|
|
189
183
|
enrich: enrich,
|
|
@@ -17,7 +17,6 @@ declare const __propDef: {
|
|
|
17
17
|
canTrack?: BuilderEditorProps["canTrack"];
|
|
18
18
|
apiKey: BuilderEditorProps["apiKey"];
|
|
19
19
|
locale?: BuilderEditorProps["locale"];
|
|
20
|
-
includeRefs?: BuilderEditorProps["includeRefs"];
|
|
21
20
|
enrich?: BuilderEditorProps["enrich"];
|
|
22
21
|
content?: BuilderEditorProps["content"];
|
|
23
22
|
showContent: BuilderEditorProps["showContent"];
|
|
@@ -3,7 +3,7 @@ import { writable } from "svelte/store";
|
|
|
3
3
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
4
4
|
import { TARGET } from "../../constants/target.js";
|
|
5
5
|
import ComponentsContext from "../../context/components.context.js";
|
|
6
|
-
import {
|
|
6
|
+
import { serializeComponentInfo } from "../../functions/register-component.js";
|
|
7
7
|
import Blocks from "../blocks/blocks.svelte";
|
|
8
8
|
import { getUpdateVariantVisibilityScript } from "../content-variants/helpers.js";
|
|
9
9
|
import InlinedScript from "../inlined-script.svelte";
|
|
@@ -22,7 +22,6 @@ export let blocksWrapper = undefined;
|
|
|
22
22
|
export let blocksWrapperProps = undefined;
|
|
23
23
|
export let model = undefined;
|
|
24
24
|
export let canTrack = undefined;
|
|
25
|
-
export let includeRefs = undefined;
|
|
26
25
|
export let enrich = undefined;
|
|
27
26
|
export let showContent;
|
|
28
27
|
export let contentWrapper = undefined;
|
|
@@ -41,12 +40,6 @@ let scriptStr = getUpdateVariantVisibilityScript({
|
|
|
41
40
|
});
|
|
42
41
|
let registeredComponents = [
|
|
43
42
|
...getDefaultRegisteredComponents(),
|
|
44
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
45
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
46
|
-
// existing usage.
|
|
47
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
48
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
49
|
-
...components,
|
|
50
43
|
...(customComponents || []),
|
|
51
44
|
].reduce((acc, { component, ...info }) => ({
|
|
52
45
|
...acc,
|
|
@@ -72,12 +65,6 @@ let builderContextSignal = writable({
|
|
|
72
65
|
apiVersion: apiVersion,
|
|
73
66
|
componentInfos: [
|
|
74
67
|
...getDefaultRegisteredComponents(),
|
|
75
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
76
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
77
|
-
// existing usage.
|
|
78
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
79
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
80
|
-
...components,
|
|
81
68
|
...(customComponents || []),
|
|
82
69
|
].reduce((acc, { component: _, ...info }) => ({
|
|
83
70
|
...acc,
|
|
@@ -100,7 +87,6 @@ setContext(ComponentsContext.key, {
|
|
|
100
87
|
{apiKey}
|
|
101
88
|
{canTrack}
|
|
102
89
|
{locale}
|
|
103
|
-
{includeRefs}
|
|
104
90
|
{enrich}
|
|
105
91
|
{showContent}
|
|
106
92
|
{builderContextSignal}
|
|
@@ -13,7 +13,6 @@ declare const __propDef: {
|
|
|
13
13
|
blocksWrapperProps?: ContentProps["blocksWrapperProps"];
|
|
14
14
|
model?: ContentProps["model"];
|
|
15
15
|
canTrack?: ContentProps["canTrack"];
|
|
16
|
-
includeRefs?: ContentProps["includeRefs"];
|
|
17
16
|
enrich?: ContentProps["enrich"];
|
|
18
17
|
showContent: ContentProps["showContent"];
|
|
19
18
|
contentWrapper?: ContentProps["contentWrapper"];
|
|
@@ -19,7 +19,6 @@ export let apiVersion = undefined;
|
|
|
19
19
|
export let customComponents = undefined;
|
|
20
20
|
export let linkComponent = undefined;
|
|
21
21
|
export let locale = undefined;
|
|
22
|
-
export let includeRefs = undefined;
|
|
23
22
|
export let enrich = undefined;
|
|
24
23
|
export let blocksWrapper = undefined;
|
|
25
24
|
export let blocksWrapperProps = undefined;
|
|
@@ -85,7 +84,6 @@ onMount(() => {
|
|
|
85
84
|
{linkComponent}
|
|
86
85
|
{canTrack}
|
|
87
86
|
{locale}
|
|
88
|
-
{includeRefs}
|
|
89
87
|
{enrich}
|
|
90
88
|
isSsrAbTest={shouldRenderVariants}
|
|
91
89
|
{blocksWrapper}
|
|
@@ -110,7 +108,6 @@ onMount(() => {
|
|
|
110
108
|
{linkComponent}
|
|
111
109
|
{canTrack}
|
|
112
110
|
{locale}
|
|
113
|
-
{includeRefs}
|
|
114
111
|
{enrich}
|
|
115
112
|
isSsrAbTest={shouldRenderVariants}
|
|
116
113
|
{blocksWrapper}
|
|
@@ -19,7 +19,6 @@ declare const __propDef: {
|
|
|
19
19
|
customComponents?: VariantsProviderProps["customComponents"];
|
|
20
20
|
linkComponent?: VariantsProviderProps["linkComponent"];
|
|
21
21
|
locale?: VariantsProviderProps["locale"];
|
|
22
|
-
includeRefs?: VariantsProviderProps["includeRefs"];
|
|
23
22
|
enrich?: VariantsProviderProps["enrich"];
|
|
24
23
|
blocksWrapper?: VariantsProviderProps["blocksWrapper"];
|
|
25
24
|
blocksWrapperProps?: VariantsProviderProps["blocksWrapperProps"];
|
|
@@ -42,8 +42,6 @@ export interface ContentVariantsPrps {
|
|
|
42
42
|
* If provided, the API will auto-resolve localized objects to the value of this `locale` key (optional).
|
|
43
43
|
*/
|
|
44
44
|
locale?: string;
|
|
45
|
-
/** @deprecated use `enrich` instead */
|
|
46
|
-
includeRefs?: boolean;
|
|
47
45
|
/**
|
|
48
46
|
* A boolean to enable or disable enriching API content (optional).
|
|
49
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "1.0.0";
|
|
@@ -3,19 +3,24 @@ import { DEFAULT_API_VERSION } from '../../types/api-version.js';
|
|
|
3
3
|
import { getBuilderSearchParamsFromWindow, normalizeSearchParams } from '../get-builder-search-params/index.js';
|
|
4
4
|
const isPositiveNumber = (thing) => typeof thing === 'number' && !isNaN(thing) && thing >= 0;
|
|
5
5
|
export const generateContentUrl = (options) => {
|
|
6
|
-
|
|
7
|
-
const { limit = 30, userAttributes, query, model, apiKey, includeRefs = true, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
6
|
+
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
8
7
|
if (!apiKey) {
|
|
9
8
|
throw new Error('Missing API key');
|
|
10
9
|
}
|
|
11
10
|
if (!['v3'].includes(apiVersion)) {
|
|
12
11
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
13
12
|
}
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
// if we are fetching an array of content, we disable noTraverse for perf reasons.
|
|
14
|
+
const noTraverse = limit !== 1;
|
|
15
|
+
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
|
|
16
|
+
url.searchParams.set('apiKey', apiKey);
|
|
17
|
+
url.searchParams.set('limit', String(limit));
|
|
18
|
+
url.searchParams.set('noTraverse', String(noTraverse));
|
|
19
|
+
url.searchParams.set('includeRefs', String(true));
|
|
20
|
+
if (locale)
|
|
21
|
+
url.searchParams.set('locale', locale);
|
|
22
|
+
if (enrich)
|
|
23
|
+
url.searchParams.set('enrich', String(enrich));
|
|
19
24
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
20
25
|
if (fields) {
|
|
21
26
|
url.searchParams.set('fields', fields);
|
|
@@ -4,12 +4,6 @@ import type { GetContentOptions } from './types.js';
|
|
|
4
4
|
* Returns the first content entry that matches the given options.
|
|
5
5
|
*/
|
|
6
6
|
export declare function fetchOneEntry(options: GetContentOptions): Promise<BuilderContent | null>;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated `getContent` was renamed to `fetchOneEntry`. This is a temporary alias to avoid breaking changes.
|
|
9
|
-
*
|
|
10
|
-
* NOTE: consider using `fetchBuilderProps` instead for easier setup.
|
|
11
|
-
*/
|
|
12
|
-
export declare const getContent: typeof fetchOneEntry;
|
|
13
7
|
type ContentResults = {
|
|
14
8
|
results: BuilderContent[];
|
|
15
9
|
};
|
|
@@ -21,8 +15,4 @@ export declare const _processContentResult: (options: GetContentOptions, content
|
|
|
21
15
|
* Returns a paginated array of entries that match the given options.
|
|
22
16
|
*/
|
|
23
17
|
export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[] | null>;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated `getAllContent` was renamed to `fetchEntries`. This is a temporary alias to avoid breaking changes.
|
|
26
|
-
*/
|
|
27
|
-
export declare const getAllContent: typeof fetchEntries;
|
|
28
18
|
export {};
|
|
@@ -20,12 +20,6 @@ export async function fetchOneEntry(options) {
|
|
|
20
20
|
}
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated `getContent` was renamed to `fetchOneEntry`. This is a temporary alias to avoid breaking changes.
|
|
25
|
-
*
|
|
26
|
-
* NOTE: consider using `fetchBuilderProps` instead for easier setup.
|
|
27
|
-
*/
|
|
28
|
-
export const getContent = fetchOneEntry;
|
|
29
23
|
const _fetchContent = async (options) => {
|
|
30
24
|
const url = generateContentUrl(options);
|
|
31
25
|
const res = await fetch(url.href);
|
|
@@ -93,7 +87,3 @@ export async function fetchEntries(options) {
|
|
|
93
87
|
return null;
|
|
94
88
|
}
|
|
95
89
|
}
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated `getAllContent` was renamed to `fetchEntries`. This is a temporary alias to avoid breaking changes.
|
|
98
|
-
*/
|
|
99
|
-
export const getAllContent = fetchEntries;
|
|
@@ -47,12 +47,6 @@ export interface GetContentOptions {
|
|
|
47
47
|
* Accepts both a key/value object or a `URLSearchParams` instance
|
|
48
48
|
* */
|
|
49
49
|
options?: Record<string, any> | URLSearchParams;
|
|
50
|
-
/**
|
|
51
|
-
* If set to `true`, it will lazy load symbols/references.
|
|
52
|
-
* If set to `false`, it will render the entire content tree eagerly.
|
|
53
|
-
* @deprecated use `enrich` instead
|
|
54
|
-
*/
|
|
55
|
-
noTraverse?: boolean;
|
|
56
50
|
/**
|
|
57
51
|
* If set to `false`, it will not use cookies to target content. Therefore, A/B Testing will be disabled and
|
|
58
52
|
* only the default variation will be returned to every user.
|
|
@@ -60,11 +54,6 @@ export interface GetContentOptions {
|
|
|
60
54
|
* Defaults to `true`.
|
|
61
55
|
*/
|
|
62
56
|
canTrack?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Include content of references in the response. Defaults to `true`.
|
|
65
|
-
* @deprecated use `enrich` instead
|
|
66
|
-
*/
|
|
67
|
-
includeRefs?: boolean;
|
|
68
57
|
/**
|
|
69
58
|
* Include multilevel references in the response.
|
|
70
59
|
*/
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import type { RegisteredComponent } from '../context/types.js';
|
|
2
1
|
import type { ComponentInfo } from '../types/components.js';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
5
|
-
*/
|
|
6
|
-
export declare const components: RegisteredComponent[];
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
9
|
-
*/
|
|
10
|
-
export declare function registerComponent(component: any, info: ComponentInfo): void;
|
|
11
2
|
export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
|
|
12
3
|
type: string;
|
|
13
4
|
data: ComponentInfo;
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { fastClone } from './fast-clone.js';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
4
|
-
*/
|
|
5
|
-
export const components = [];
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
8
|
-
*/
|
|
9
|
-
export function registerComponent(component, info) {
|
|
10
|
-
components.push({
|
|
11
|
-
component,
|
|
12
|
-
...info
|
|
13
|
-
});
|
|
14
|
-
console.warn('registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.');
|
|
15
|
-
return component;
|
|
16
|
-
}
|
|
17
2
|
export const createRegisterComponentMessage = (info) => ({
|
|
18
3
|
type: 'builder.registerComponent',
|
|
19
4
|
data: serializeComponentInfo(info)
|
|
@@ -9,11 +9,3 @@ export { default as Video } from '../blocks/video/video.svelte';
|
|
|
9
9
|
import { default as Blocks } from '../components/blocks/blocks.svelte';
|
|
10
10
|
import { default as Content } from '../components/content-variants/content-variants.svelte';
|
|
11
11
|
export { Blocks, Content };
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Renamed to `Blocks`.
|
|
14
|
-
*/
|
|
15
|
-
export declare const RenderBlocks: typeof Blocks;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Renamed to `Content`.
|
|
18
|
-
*/
|
|
19
|
-
export declare const RenderContent: typeof Content;
|
|
@@ -9,11 +9,3 @@ export { default as Video } from '../blocks/video/video.svelte';
|
|
|
9
9
|
import { default as Blocks } from '../components/blocks/blocks.svelte';
|
|
10
10
|
import { default as Content } from '../components/content-variants/content-variants.svelte';
|
|
11
11
|
export { Blocks, Content };
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Renamed to `Blocks`.
|
|
14
|
-
*/
|
|
15
|
-
export const RenderBlocks = Blocks;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Renamed to `Content`.
|
|
18
|
-
*/
|
|
19
|
-
export const RenderContent = Content;
|
|
@@ -36,4 +36,4 @@ export { subscribeToEditor } from './helpers/subscribe-to-editor.js';
|
|
|
36
36
|
* Content fetching
|
|
37
37
|
*/
|
|
38
38
|
export { fetchBuilderProps } from './functions/fetch-builder-props.js';
|
|
39
|
-
export { _processContentResult, fetchEntries, fetchOneEntry
|
|
39
|
+
export { _processContentResult, fetchEntries, fetchOneEntry } from './functions/get-content/index.js';
|
package/lib/node/server-index.js
CHANGED
|
@@ -14,4 +14,4 @@ export { subscribeToEditor } from './helpers/subscribe-to-editor.js';
|
|
|
14
14
|
* Content fetching
|
|
15
15
|
*/
|
|
16
16
|
export { fetchBuilderProps } from './functions/fetch-builder-props.js';
|
|
17
|
-
export { _processContentResult, fetchEntries, fetchOneEntry
|
|
17
|
+
export { _processContentResult, fetchEntries, fetchOneEntry } from './functions/get-content/index.js';
|
package/package.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
export let canTrack: BuilderEditorProps["canTrack"] = undefined;
|
|
55
55
|
export let apiKey: BuilderEditorProps["apiKey"];
|
|
56
56
|
export let locale: BuilderEditorProps["locale"] = undefined;
|
|
57
|
-
export let includeRefs: BuilderEditorProps["includeRefs"] = undefined;
|
|
58
57
|
export let enrich: BuilderEditorProps["enrich"] = undefined;
|
|
59
58
|
export let content: BuilderEditorProps["content"] = undefined;
|
|
60
59
|
export let showContent: BuilderEditorProps["showContent"];
|
|
@@ -219,11 +218,6 @@
|
|
|
219
218
|
locale: locale,
|
|
220
219
|
}
|
|
221
220
|
: {}),
|
|
222
|
-
...(includeRefs
|
|
223
|
-
? {
|
|
224
|
-
includeRefs: includeRefs,
|
|
225
|
-
}
|
|
226
|
-
: {}),
|
|
227
221
|
...(enrich
|
|
228
222
|
? {
|
|
229
223
|
enrich: enrich,
|
|
@@ -10,10 +10,7 @@
|
|
|
10
10
|
BuilderRenderState,
|
|
11
11
|
RegisteredComponents,
|
|
12
12
|
} from "../../context/types.js";
|
|
13
|
-
import {
|
|
14
|
-
components,
|
|
15
|
-
serializeComponentInfo,
|
|
16
|
-
} from "../../functions/register-component.js";
|
|
13
|
+
import { serializeComponentInfo } from "../../functions/register-component.js";
|
|
17
14
|
import type { ComponentInfo } from "../../types/components.js";
|
|
18
15
|
import type { Dictionary } from "../../types/typescript.js";
|
|
19
16
|
import Blocks from "../blocks/blocks.svelte";
|
|
@@ -39,7 +36,6 @@
|
|
|
39
36
|
export let blocksWrapperProps: ContentProps["blocksWrapperProps"] = undefined;
|
|
40
37
|
export let model: ContentProps["model"] = undefined;
|
|
41
38
|
export let canTrack: ContentProps["canTrack"] = undefined;
|
|
42
|
-
export let includeRefs: ContentProps["includeRefs"] = undefined;
|
|
43
39
|
export let enrich: ContentProps["enrich"] = undefined;
|
|
44
40
|
export let showContent: ContentProps["showContent"];
|
|
45
41
|
export let contentWrapper: ContentProps["contentWrapper"] = undefined;
|
|
@@ -61,12 +57,6 @@
|
|
|
61
57
|
});
|
|
62
58
|
let registeredComponents = [
|
|
63
59
|
...getDefaultRegisteredComponents(),
|
|
64
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
65
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
66
|
-
// existing usage.
|
|
67
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
68
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
69
|
-
...components,
|
|
70
60
|
...(customComponents || []),
|
|
71
61
|
].reduce<RegisteredComponents>(
|
|
72
62
|
(acc, { component, ...info }) => ({
|
|
@@ -95,12 +85,6 @@
|
|
|
95
85
|
apiVersion: apiVersion,
|
|
96
86
|
componentInfos: [
|
|
97
87
|
...getDefaultRegisteredComponents(),
|
|
98
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
99
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
100
|
-
// existing usage.
|
|
101
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
102
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
103
|
-
...components,
|
|
104
88
|
...(customComponents || []),
|
|
105
89
|
].reduce<Dictionary<ComponentInfo>>(
|
|
106
90
|
(acc, { component: _, ...info }) => ({
|
|
@@ -127,7 +111,6 @@
|
|
|
127
111
|
{apiKey}
|
|
128
112
|
{canTrack}
|
|
129
113
|
{locale}
|
|
130
|
-
{includeRefs}
|
|
131
114
|
{enrich}
|
|
132
115
|
{showContent}
|
|
133
116
|
{builderContextSignal}
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
undefined;
|
|
38
38
|
export let linkComponent: VariantsProviderProps["linkComponent"] = undefined;
|
|
39
39
|
export let locale: VariantsProviderProps["locale"] = undefined;
|
|
40
|
-
export let includeRefs: VariantsProviderProps["includeRefs"] = undefined;
|
|
41
40
|
export let enrich: VariantsProviderProps["enrich"] = undefined;
|
|
42
41
|
export let blocksWrapper: VariantsProviderProps["blocksWrapper"] = undefined;
|
|
43
42
|
export let blocksWrapperProps: VariantsProviderProps["blocksWrapperProps"] =
|
|
@@ -112,7 +111,6 @@
|
|
|
112
111
|
{linkComponent}
|
|
113
112
|
{canTrack}
|
|
114
113
|
{locale}
|
|
115
|
-
{includeRefs}
|
|
116
114
|
{enrich}
|
|
117
115
|
isSsrAbTest={shouldRenderVariants}
|
|
118
116
|
{blocksWrapper}
|
|
@@ -137,7 +135,6 @@
|
|
|
137
135
|
{linkComponent}
|
|
138
136
|
{canTrack}
|
|
139
137
|
{locale}
|
|
140
|
-
{includeRefs}
|
|
141
138
|
{enrich}
|
|
142
139
|
isSsrAbTest={shouldRenderVariants}
|
|
143
140
|
{blocksWrapper}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "1.0.0"
|
|
@@ -4,16 +4,12 @@ import { getBuilderSearchParamsFromWindow, normalizeSearchParams } from '../get-
|
|
|
4
4
|
import type { GetContentOptions } from './types.js';
|
|
5
5
|
const isPositiveNumber = (thing: unknown) => typeof thing === 'number' && !isNaN(thing) && thing >= 0;
|
|
6
6
|
export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
7
|
-
let {
|
|
8
|
-
noTraverse = false
|
|
9
|
-
} = options;
|
|
10
7
|
const {
|
|
11
8
|
limit = 30,
|
|
12
9
|
userAttributes,
|
|
13
10
|
query,
|
|
14
11
|
model,
|
|
15
12
|
apiKey,
|
|
16
|
-
includeRefs = true,
|
|
17
13
|
enrich,
|
|
18
14
|
locale,
|
|
19
15
|
apiVersion = DEFAULT_API_VERSION,
|
|
@@ -32,11 +28,15 @@ export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
|
32
28
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
// if we are fetching an array of content, we disable noTraverse for perf reasons.
|
|
32
|
+
const noTraverse = limit !== 1;
|
|
33
|
+
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
|
|
34
|
+
url.searchParams.set('apiKey', apiKey);
|
|
35
|
+
url.searchParams.set('limit', String(limit));
|
|
36
|
+
url.searchParams.set('noTraverse', String(noTraverse));
|
|
37
|
+
url.searchParams.set('includeRefs', String(true));
|
|
38
|
+
if (locale) url.searchParams.set('locale', locale);
|
|
39
|
+
if (enrich) url.searchParams.set('enrich', String(enrich));
|
|
40
40
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
41
41
|
if (fields) {
|
|
42
42
|
url.searchParams.set('fields', fields);
|
|
@@ -23,13 +23,6 @@ export async function fetchOneEntry(options: GetContentOptions): Promise<Builder
|
|
|
23
23
|
}
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated `getContent` was renamed to `fetchOneEntry`. This is a temporary alias to avoid breaking changes.
|
|
29
|
-
*
|
|
30
|
-
* NOTE: consider using `fetchBuilderProps` instead for easier setup.
|
|
31
|
-
*/
|
|
32
|
-
export const getContent = fetchOneEntry;
|
|
33
26
|
type ContentResults = {
|
|
34
27
|
results: BuilderContent[];
|
|
35
28
|
};
|
|
@@ -102,9 +95,4 @@ export async function fetchEntries(options: GetContentOptions) {
|
|
|
102
95
|
logger.error('Error fetching data. ', error);
|
|
103
96
|
return null;
|
|
104
97
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @deprecated `getAllContent` was renamed to `fetchEntries`. This is a temporary alias to avoid breaking changes.
|
|
109
|
-
*/
|
|
110
|
-
export const getAllContent = fetchEntries
|
|
98
|
+
}
|
|
@@ -54,13 +54,6 @@ export interface GetContentOptions {
|
|
|
54
54
|
* */
|
|
55
55
|
options?: Record<string, any> | URLSearchParams;
|
|
56
56
|
|
|
57
|
-
/**
|
|
58
|
-
* If set to `true`, it will lazy load symbols/references.
|
|
59
|
-
* If set to `false`, it will render the entire content tree eagerly.
|
|
60
|
-
* @deprecated use `enrich` instead
|
|
61
|
-
*/
|
|
62
|
-
noTraverse?: boolean;
|
|
63
|
-
|
|
64
57
|
/**
|
|
65
58
|
* If set to `false`, it will not use cookies to target content. Therefore, A/B Testing will be disabled and
|
|
66
59
|
* only the default variation will be returned to every user.
|
|
@@ -69,12 +62,6 @@ export interface GetContentOptions {
|
|
|
69
62
|
*/
|
|
70
63
|
canTrack?: boolean;
|
|
71
64
|
|
|
72
|
-
/**
|
|
73
|
-
* Include content of references in the response. Defaults to `true`.
|
|
74
|
-
* @deprecated use `enrich` instead
|
|
75
|
-
*/
|
|
76
|
-
includeRefs?: boolean;
|
|
77
|
-
|
|
78
65
|
/**
|
|
79
66
|
* Include multilevel references in the response.
|
|
80
67
|
*/
|
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
import type { RegisteredComponent } from '../context/types.js';
|
|
2
1
|
import type { ComponentInfo } from '../types/components.js';
|
|
3
2
|
import type { Input } from '../types/input.js';
|
|
4
3
|
import { fastClone } from './fast-clone.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
8
|
-
*/
|
|
9
|
-
export const components: RegisteredComponent[] = [];
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
13
|
-
*/
|
|
14
|
-
export function registerComponent(component: any, info: ComponentInfo): void {
|
|
15
|
-
components.push({
|
|
16
|
-
component,
|
|
17
|
-
...info
|
|
18
|
-
});
|
|
19
|
-
console.warn('registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.');
|
|
20
|
-
return component;
|
|
21
|
-
}
|
|
22
4
|
export const createRegisterComponentMessage = (info: ComponentInfo) => ({
|
|
23
5
|
type: 'builder.registerComponent',
|
|
24
6
|
data: serializeComponentInfo(info)
|
|
@@ -8,13 +8,4 @@ export { default as Text } from '../blocks/text/text.svelte';
|
|
|
8
8
|
export { default as Video } from '../blocks/video/video.svelte';
|
|
9
9
|
import { default as Blocks } from '../components/blocks/blocks.svelte';
|
|
10
10
|
import { default as Content } from '../components/content-variants/content-variants.svelte';
|
|
11
|
-
export { Blocks, Content }
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Renamed to `Blocks`.
|
|
15
|
-
*/
|
|
16
|
-
export const RenderBlocks = Blocks;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Renamed to `Content`.
|
|
19
|
-
*/
|
|
20
|
-
export const RenderContent = Content
|
|
11
|
+
export { Blocks, Content }
|
package/src/server-index.ts
CHANGED
|
@@ -40,4 +40,4 @@ export { subscribeToEditor } from './helpers/subscribe-to-editor.js';
|
|
|
40
40
|
* Content fetching
|
|
41
41
|
*/
|
|
42
42
|
export { fetchBuilderProps } from './functions/fetch-builder-props.js';
|
|
43
|
-
export { _processContentResult, fetchEntries, fetchOneEntry
|
|
43
|
+
export { _processContentResult, fetchEntries, fetchOneEntry } from './functions/get-content/index.js'
|