@builder.io/sdk-svelte 0.6.4 → 0.7.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 +5 -6
- package/lib/browser/components/content/components/enable-editor.svelte.d.ts +1 -1
- 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 +6 -1
- package/lib/edge/components/content/components/enable-editor.svelte +5 -6
- package/lib/edge/components/content/components/enable-editor.svelte.d.ts +1 -1
- 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 +6 -1
- package/lib/node/components/content/components/enable-editor.svelte +5 -6
- package/lib/node/components/content/components/enable-editor.svelte.d.ts +1 -1
- 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 +6 -1
- package/package.json +2 -1
- package/src/components/content/components/enable-editor.svelte +5 -6
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/get-content/generate-content-url.ts +8 -1
|
@@ -9,17 +9,17 @@ import { createRegisterComponentMessage } from "../../../functions/register-comp
|
|
|
9
9
|
import { _track } from "../../../functions/track/index.js";
|
|
10
10
|
import builderContext from "../../../context/builder.context.js";
|
|
11
11
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing.js";
|
|
12
|
-
import { checkIsDefined } from "../../../helpers/nullable.js";
|
|
13
12
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.js";
|
|
14
|
-
import { logger } from "../../../helpers/logger.js";
|
|
15
13
|
import { fetchOneEntry } from "../../../functions/get-content/index.js";
|
|
16
14
|
import { isPreviewing } from "../../../functions/is-previewing.js";
|
|
17
15
|
import "../../../helpers/preview-lru-cache/set.js";
|
|
18
16
|
import { fastClone } from "../../../functions/fast-clone.js";
|
|
19
|
-
|
|
17
|
+
import { logger } from "../../../helpers/logger.js";
|
|
18
|
+
import { getDefaultCanTrack } from "../../../helpers/canTrack.js";
|
|
20
19
|
export let builderContextSignal;
|
|
21
20
|
export let model = undefined;
|
|
22
21
|
export let context = undefined;
|
|
22
|
+
export let canTrack = undefined;
|
|
23
23
|
export let apiKey;
|
|
24
24
|
export let showContent;
|
|
25
25
|
export let classNameProp;
|
|
@@ -99,7 +99,7 @@ function onClick(event) {
|
|
|
99
99
|
const contentId = $builderContextSignal.content?.id;
|
|
100
100
|
_track({
|
|
101
101
|
type: "click",
|
|
102
|
-
canTrack:
|
|
102
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
103
103
|
contentId,
|
|
104
104
|
apiKey: apiKey,
|
|
105
105
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
@@ -160,7 +160,6 @@ function emitStateUpdate() {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
let elementRef;
|
|
163
|
-
let canTrackToUse = checkIsDefined(canTrack) ? canTrack : true;
|
|
164
163
|
let forceReRenderCount = 0;
|
|
165
164
|
let lastUpdated = 0;
|
|
166
165
|
let shouldSendResetCookie = false;
|
|
@@ -203,7 +202,7 @@ onMount(() => {
|
|
|
203
202
|
const contentId = $builderContextSignal.content?.id;
|
|
204
203
|
_track({
|
|
205
204
|
type: "impression",
|
|
206
|
-
canTrack:
|
|
205
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
207
206
|
contentId,
|
|
208
207
|
apiKey: apiKey,
|
|
209
208
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
@@ -9,10 +9,10 @@ import type { ContentProps } from "../content.types.js";
|
|
|
9
9
|
import type { Writable } from "svelte/store";
|
|
10
10
|
declare const __propDef: {
|
|
11
11
|
props: {
|
|
12
|
-
canTrack?: BuilderEditorProps["canTrack"];
|
|
13
12
|
builderContextSignal: BuilderEditorProps["builderContextSignal"];
|
|
14
13
|
model?: BuilderEditorProps["model"];
|
|
15
14
|
context?: BuilderEditorProps["context"];
|
|
15
|
+
canTrack?: BuilderEditorProps["canTrack"];
|
|
16
16
|
apiKey: BuilderEditorProps["apiKey"];
|
|
17
17
|
showContent: BuilderEditorProps["showContent"];
|
|
18
18
|
classNameProp: BuilderEditorProps["classNameProp"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.7.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.7.0";
|
|
@@ -2,13 +2,18 @@ import { flatten } from '../../helpers/flatten.js';
|
|
|
2
2
|
import { getBuilderSearchParamsFromWindow, normalizeSearchParams } from '../get-builder-search-params/index.js';
|
|
3
3
|
import { DEFAULT_API_VERSION } from '../../types/api-version.js';
|
|
4
4
|
export const generateContentUrl = (options) => {
|
|
5
|
-
|
|
5
|
+
let { noTraverse = false } = options;
|
|
6
|
+
const { limit = 30, userAttributes, query, model, apiKey, includeRefs = true, enrich, locale, apiVersion = DEFAULT_API_VERSION } = options;
|
|
6
7
|
if (!apiKey) {
|
|
7
8
|
throw new Error('Missing API key');
|
|
8
9
|
}
|
|
9
10
|
if (!['v2', 'v3'].includes(apiVersion)) {
|
|
10
11
|
throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
|
|
11
12
|
}
|
|
13
|
+
// Set noTraverse=true if NOT already passed by user, for query performance
|
|
14
|
+
if ((options.limit === undefined || options.limit > 1) && !('noTraverse' in options)) {
|
|
15
|
+
noTraverse = true;
|
|
16
|
+
}
|
|
12
17
|
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}${enrich ? `&enrich=${enrich}` : ''}`);
|
|
13
18
|
const queryOptions = {
|
|
14
19
|
...getBuilderSearchParamsFromWindow(),
|
|
@@ -9,17 +9,17 @@ import { createRegisterComponentMessage } from "../../../functions/register-comp
|
|
|
9
9
|
import { _track } from "../../../functions/track/index.js";
|
|
10
10
|
import builderContext from "../../../context/builder.context.js";
|
|
11
11
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing.js";
|
|
12
|
-
import { checkIsDefined } from "../../../helpers/nullable.js";
|
|
13
12
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.js";
|
|
14
|
-
import { logger } from "../../../helpers/logger.js";
|
|
15
13
|
import { fetchOneEntry } from "../../../functions/get-content/index.js";
|
|
16
14
|
import { isPreviewing } from "../../../functions/is-previewing.js";
|
|
17
15
|
import "../../../helpers/preview-lru-cache/set.js";
|
|
18
16
|
import { fastClone } from "../../../functions/fast-clone.js";
|
|
19
|
-
|
|
17
|
+
import { logger } from "../../../helpers/logger.js";
|
|
18
|
+
import { getDefaultCanTrack } from "../../../helpers/canTrack.js";
|
|
20
19
|
export let builderContextSignal;
|
|
21
20
|
export let model = undefined;
|
|
22
21
|
export let context = undefined;
|
|
22
|
+
export let canTrack = undefined;
|
|
23
23
|
export let apiKey;
|
|
24
24
|
export let showContent;
|
|
25
25
|
export let classNameProp;
|
|
@@ -99,7 +99,7 @@ function onClick(event) {
|
|
|
99
99
|
const contentId = $builderContextSignal.content?.id;
|
|
100
100
|
_track({
|
|
101
101
|
type: "click",
|
|
102
|
-
canTrack:
|
|
102
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
103
103
|
contentId,
|
|
104
104
|
apiKey: apiKey,
|
|
105
105
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
@@ -160,7 +160,6 @@ function emitStateUpdate() {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
let elementRef;
|
|
163
|
-
let canTrackToUse = checkIsDefined(canTrack) ? canTrack : true;
|
|
164
163
|
let forceReRenderCount = 0;
|
|
165
164
|
let lastUpdated = 0;
|
|
166
165
|
let shouldSendResetCookie = false;
|
|
@@ -203,7 +202,7 @@ onMount(() => {
|
|
|
203
202
|
const contentId = $builderContextSignal.content?.id;
|
|
204
203
|
_track({
|
|
205
204
|
type: "impression",
|
|
206
|
-
canTrack:
|
|
205
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
207
206
|
contentId,
|
|
208
207
|
apiKey: apiKey,
|
|
209
208
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
@@ -9,10 +9,10 @@ import type { ContentProps } from "../content.types.js";
|
|
|
9
9
|
import type { Writable } from "svelte/store";
|
|
10
10
|
declare const __propDef: {
|
|
11
11
|
props: {
|
|
12
|
-
canTrack?: BuilderEditorProps["canTrack"];
|
|
13
12
|
builderContextSignal: BuilderEditorProps["builderContextSignal"];
|
|
14
13
|
model?: BuilderEditorProps["model"];
|
|
15
14
|
context?: BuilderEditorProps["context"];
|
|
15
|
+
canTrack?: BuilderEditorProps["canTrack"];
|
|
16
16
|
apiKey: BuilderEditorProps["apiKey"];
|
|
17
17
|
showContent: BuilderEditorProps["showContent"];
|
|
18
18
|
classNameProp: BuilderEditorProps["classNameProp"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.7.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.7.0";
|
|
@@ -2,13 +2,18 @@ import { flatten } from '../../helpers/flatten.js';
|
|
|
2
2
|
import { getBuilderSearchParamsFromWindow, normalizeSearchParams } from '../get-builder-search-params/index.js';
|
|
3
3
|
import { DEFAULT_API_VERSION } from '../../types/api-version.js';
|
|
4
4
|
export const generateContentUrl = (options) => {
|
|
5
|
-
|
|
5
|
+
let { noTraverse = false } = options;
|
|
6
|
+
const { limit = 30, userAttributes, query, model, apiKey, includeRefs = true, enrich, locale, apiVersion = DEFAULT_API_VERSION } = options;
|
|
6
7
|
if (!apiKey) {
|
|
7
8
|
throw new Error('Missing API key');
|
|
8
9
|
}
|
|
9
10
|
if (!['v2', 'v3'].includes(apiVersion)) {
|
|
10
11
|
throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
|
|
11
12
|
}
|
|
13
|
+
// Set noTraverse=true if NOT already passed by user, for query performance
|
|
14
|
+
if ((options.limit === undefined || options.limit > 1) && !('noTraverse' in options)) {
|
|
15
|
+
noTraverse = true;
|
|
16
|
+
}
|
|
12
17
|
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}${enrich ? `&enrich=${enrich}` : ''}`);
|
|
13
18
|
const queryOptions = {
|
|
14
19
|
...getBuilderSearchParamsFromWindow(),
|
|
@@ -9,17 +9,17 @@ import { createRegisterComponentMessage } from "../../../functions/register-comp
|
|
|
9
9
|
import { _track } from "../../../functions/track/index.js";
|
|
10
10
|
import builderContext from "../../../context/builder.context.js";
|
|
11
11
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing.js";
|
|
12
|
-
import { checkIsDefined } from "../../../helpers/nullable.js";
|
|
13
12
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.js";
|
|
14
|
-
import { logger } from "../../../helpers/logger.js";
|
|
15
13
|
import { fetchOneEntry } from "../../../functions/get-content/index.js";
|
|
16
14
|
import { isPreviewing } from "../../../functions/is-previewing.js";
|
|
17
15
|
import "../../../helpers/preview-lru-cache/set.js";
|
|
18
16
|
import { fastClone } from "../../../functions/fast-clone.js";
|
|
19
|
-
|
|
17
|
+
import { logger } from "../../../helpers/logger.js";
|
|
18
|
+
import { getDefaultCanTrack } from "../../../helpers/canTrack.js";
|
|
20
19
|
export let builderContextSignal;
|
|
21
20
|
export let model = undefined;
|
|
22
21
|
export let context = undefined;
|
|
22
|
+
export let canTrack = undefined;
|
|
23
23
|
export let apiKey;
|
|
24
24
|
export let showContent;
|
|
25
25
|
export let classNameProp;
|
|
@@ -99,7 +99,7 @@ function onClick(event) {
|
|
|
99
99
|
const contentId = $builderContextSignal.content?.id;
|
|
100
100
|
_track({
|
|
101
101
|
type: "click",
|
|
102
|
-
canTrack:
|
|
102
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
103
103
|
contentId,
|
|
104
104
|
apiKey: apiKey,
|
|
105
105
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
@@ -160,7 +160,6 @@ function emitStateUpdate() {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
let elementRef;
|
|
163
|
-
let canTrackToUse = checkIsDefined(canTrack) ? canTrack : true;
|
|
164
163
|
let forceReRenderCount = 0;
|
|
165
164
|
let lastUpdated = 0;
|
|
166
165
|
let shouldSendResetCookie = false;
|
|
@@ -203,7 +202,7 @@ onMount(() => {
|
|
|
203
202
|
const contentId = $builderContextSignal.content?.id;
|
|
204
203
|
_track({
|
|
205
204
|
type: "impression",
|
|
206
|
-
canTrack:
|
|
205
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
207
206
|
contentId,
|
|
208
207
|
apiKey: apiKey,
|
|
209
208
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
@@ -9,10 +9,10 @@ import type { ContentProps } from "../content.types.js";
|
|
|
9
9
|
import type { Writable } from "svelte/store";
|
|
10
10
|
declare const __propDef: {
|
|
11
11
|
props: {
|
|
12
|
-
canTrack?: BuilderEditorProps["canTrack"];
|
|
13
12
|
builderContextSignal: BuilderEditorProps["builderContextSignal"];
|
|
14
13
|
model?: BuilderEditorProps["model"];
|
|
15
14
|
context?: BuilderEditorProps["context"];
|
|
15
|
+
canTrack?: BuilderEditorProps["canTrack"];
|
|
16
16
|
apiKey: BuilderEditorProps["apiKey"];
|
|
17
17
|
showContent: BuilderEditorProps["showContent"];
|
|
18
18
|
classNameProp: BuilderEditorProps["classNameProp"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.7.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.7.0";
|
|
@@ -2,13 +2,18 @@ import { flatten } from '../../helpers/flatten.js';
|
|
|
2
2
|
import { getBuilderSearchParamsFromWindow, normalizeSearchParams } from '../get-builder-search-params/index.js';
|
|
3
3
|
import { DEFAULT_API_VERSION } from '../../types/api-version.js';
|
|
4
4
|
export const generateContentUrl = (options) => {
|
|
5
|
-
|
|
5
|
+
let { noTraverse = false } = options;
|
|
6
|
+
const { limit = 30, userAttributes, query, model, apiKey, includeRefs = true, enrich, locale, apiVersion = DEFAULT_API_VERSION } = options;
|
|
6
7
|
if (!apiKey) {
|
|
7
8
|
throw new Error('Missing API key');
|
|
8
9
|
}
|
|
9
10
|
if (!['v2', 'v3'].includes(apiVersion)) {
|
|
10
11
|
throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
|
|
11
12
|
}
|
|
13
|
+
// Set noTraverse=true if NOT already passed by user, for query performance
|
|
14
|
+
if ((options.limit === undefined || options.limit > 1) && !('noTraverse' in options)) {
|
|
15
|
+
noTraverse = true;
|
|
16
|
+
}
|
|
12
17
|
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}${enrich ? `&enrich=${enrich}` : ''}`);
|
|
13
18
|
const queryOptions = {
|
|
14
19
|
...getBuilderSearchParamsFromWindow(),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-svelte",
|
|
3
3
|
"description": "Builder.io SDK for Svelte",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"lib",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"types": "./lib/browser/index.d.ts",
|
|
39
39
|
"scripts": {
|
|
40
|
+
"release": "npm publish",
|
|
40
41
|
"prepare": "SDK_ENV=browser svelte-kit sync",
|
|
41
42
|
"build": "nx run-many -p @builder.io/sdk-svelte -t build:node build:edge build:browser",
|
|
42
43
|
"build:node": "SDK_ENV=node svelte-package -i src/ -o lib/node",
|
|
@@ -24,25 +24,25 @@
|
|
|
24
24
|
registerInsertMenu,
|
|
25
25
|
setupBrowserForEditing,
|
|
26
26
|
} from "../../../scripts/init-editing.js";
|
|
27
|
-
import { checkIsDefined } from "../../../helpers/nullable.js";
|
|
28
27
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.js";
|
|
29
28
|
import type {
|
|
30
29
|
ContentProps,
|
|
31
30
|
BuilderComponentStateChange,
|
|
32
31
|
} from "../content.types.js";
|
|
33
|
-
import { logger } from "../../../helpers/logger.js";
|
|
34
32
|
import type { ComponentInfo } from "../../../types/components.js";
|
|
35
33
|
import { fetchOneEntry } from "../../../functions/get-content/index.js";
|
|
36
34
|
import { isPreviewing } from "../../../functions/is-previewing.js";
|
|
37
35
|
import type { BuilderContent } from "../../../types/builder-content.js";
|
|
38
36
|
import { postPreviewContent } from "../../../helpers/preview-lru-cache/set.js";
|
|
39
37
|
import { fastClone } from "../../../functions/fast-clone.js";
|
|
38
|
+
import { logger } from "../../../helpers/logger.js";
|
|
39
|
+
import { getDefaultCanTrack } from "../../../helpers/canTrack.js";
|
|
40
40
|
import type { Writable } from "svelte/store";
|
|
41
41
|
|
|
42
|
-
export let canTrack: BuilderEditorProps["canTrack"] = undefined;
|
|
43
42
|
export let builderContextSignal: BuilderEditorProps["builderContextSignal"];
|
|
44
43
|
export let model: BuilderEditorProps["model"] = undefined;
|
|
45
44
|
export let context: BuilderEditorProps["context"] = undefined;
|
|
45
|
+
export let canTrack: BuilderEditorProps["canTrack"] = undefined;
|
|
46
46
|
export let apiKey: BuilderEditorProps["apiKey"];
|
|
47
47
|
export let showContent: BuilderEditorProps["showContent"];
|
|
48
48
|
export let classNameProp: BuilderEditorProps["classNameProp"];
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
const contentId = $builderContextSignal.content?.id;
|
|
128
128
|
_track({
|
|
129
129
|
type: "click",
|
|
130
|
-
canTrack:
|
|
130
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
131
131
|
contentId,
|
|
132
132
|
apiKey: apiKey,
|
|
133
133
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
@@ -199,7 +199,6 @@
|
|
|
199
199
|
|
|
200
200
|
let elementRef;
|
|
201
201
|
|
|
202
|
-
let canTrackToUse = checkIsDefined(canTrack) ? canTrack : true;
|
|
203
202
|
let forceReRenderCount = 0;
|
|
204
203
|
let lastUpdated = 0;
|
|
205
204
|
let shouldSendResetCookie = false;
|
|
@@ -250,7 +249,7 @@
|
|
|
250
249
|
const contentId = $builderContextSignal.content?.id;
|
|
251
250
|
_track({
|
|
252
251
|
type: "impression",
|
|
253
|
-
canTrack:
|
|
252
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
254
253
|
contentId,
|
|
255
254
|
apiKey: apiKey,
|
|
256
255
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.7.0"
|
|
@@ -3,11 +3,13 @@ import { getBuilderSearchParamsFromWindow, normalizeSearchParams } from '../get-
|
|
|
3
3
|
import type { GetContentOptions } from './types.js';
|
|
4
4
|
import { DEFAULT_API_VERSION } from '../../types/api-version.js';
|
|
5
5
|
export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
6
|
+
let {
|
|
7
|
+
noTraverse = false
|
|
8
|
+
} = options;
|
|
6
9
|
const {
|
|
7
10
|
limit = 30,
|
|
8
11
|
userAttributes,
|
|
9
12
|
query,
|
|
10
|
-
noTraverse = false,
|
|
11
13
|
model,
|
|
12
14
|
apiKey,
|
|
13
15
|
includeRefs = true,
|
|
@@ -21,6 +23,11 @@ export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
|
21
23
|
if (!['v2', 'v3'].includes(apiVersion)) {
|
|
22
24
|
throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
// Set noTraverse=true if NOT already passed by user, for query performance
|
|
28
|
+
if ((options.limit === undefined || options.limit > 1) && !('noTraverse' in options)) {
|
|
29
|
+
noTraverse = true;
|
|
30
|
+
}
|
|
24
31
|
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}${enrich ? `&enrich=${enrich}` : ''}`);
|
|
25
32
|
const queryOptions = {
|
|
26
33
|
...getBuilderSearchParamsFromWindow(),
|