@builder.io/sdk-svelte 2.0.30 → 3.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/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 +11 -4
- package/lib/browser/functions/get-content/index.d.ts +1 -1
- package/lib/browser/functions/get-content/index.js +10 -16
- package/lib/browser/functions/register-component.js +3 -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 +11 -4
- package/lib/edge/functions/get-content/index.d.ts +1 -1
- package/lib/edge/functions/get-content/index.js +10 -16
- package/lib/edge/functions/register-component.js +3 -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 +11 -4
- package/lib/node/functions/get-content/index.d.ts +1 -1
- package/lib/node/functions/get-content/index.js +10 -16
- package/lib/node/functions/register-component.js +3 -1
- package/package.json +1 -1
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/get-content/generate-content-url.ts +11 -3
- package/src/functions/get-content/index.ts +10 -15
- package/src/functions/register-component.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "3.0.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "
|
|
1
|
+
export const SDK_VERSION = "3.0.0";
|
|
@@ -19,8 +19,15 @@ export const generateContentUrl = (options) => {
|
|
|
19
19
|
url.searchParams.set('limit', String(limit));
|
|
20
20
|
url.searchParams.set('noTraverse', String(noTraverse));
|
|
21
21
|
url.searchParams.set('includeRefs', String(true));
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const finalLocale = locale || userAttributes?.locale;
|
|
23
|
+
let finalUserAttributes = userAttributes;
|
|
24
|
+
if (finalLocale) {
|
|
25
|
+
url.searchParams.set('locale', finalLocale);
|
|
26
|
+
finalUserAttributes = {
|
|
27
|
+
locale: finalLocale,
|
|
28
|
+
...finalUserAttributes
|
|
29
|
+
};
|
|
30
|
+
}
|
|
24
31
|
if (enrich)
|
|
25
32
|
url.searchParams.set('enrich', String(enrich));
|
|
26
33
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
@@ -56,8 +63,8 @@ export const generateContentUrl = (options) => {
|
|
|
56
63
|
for (const key in flattened) {
|
|
57
64
|
url.searchParams.set(key, String(flattened[key]));
|
|
58
65
|
}
|
|
59
|
-
if (
|
|
60
|
-
url.searchParams.set('userAttributes', JSON.stringify(
|
|
66
|
+
if (finalUserAttributes) {
|
|
67
|
+
url.searchParams.set('userAttributes', JSON.stringify(finalUserAttributes));
|
|
61
68
|
}
|
|
62
69
|
if (query) {
|
|
63
70
|
const flattened = flattenMongoQuery({
|
|
@@ -14,5 +14,5 @@ export declare const _processContentResult: (options: GetContentOptions, content
|
|
|
14
14
|
/**
|
|
15
15
|
* Returns a paginated array of entries that match the given options.
|
|
16
16
|
*/
|
|
17
|
-
export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]
|
|
17
|
+
export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]>;
|
|
18
18
|
export {};
|
|
@@ -78,21 +78,15 @@ export const _processContentResult = async (options, content, url = generateCont
|
|
|
78
78
|
* Returns a paginated array of entries that match the given options.
|
|
79
79
|
*/
|
|
80
80
|
export async function fetchEntries(options) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
return _processContentResult(options, content);
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
logger.error('Error fetching data. ', error);
|
|
96
|
-
return null;
|
|
81
|
+
const url = generateContentUrl(options);
|
|
82
|
+
const content = await _fetchContent(options);
|
|
83
|
+
if (!checkContentHasResults(content)) {
|
|
84
|
+
logger.error('Error fetching data. ', {
|
|
85
|
+
url,
|
|
86
|
+
content,
|
|
87
|
+
options
|
|
88
|
+
});
|
|
89
|
+
throw content;
|
|
97
90
|
}
|
|
91
|
+
return _processContentResult(options, content);
|
|
98
92
|
}
|
|
@@ -9,7 +9,9 @@ const serializeFn = (fnValue) => {
|
|
|
9
9
|
// 1. `function name(args) => {code}`
|
|
10
10
|
// 2. `name(args) => {code}`
|
|
11
11
|
// 3. `(args) => {}`
|
|
12
|
-
|
|
12
|
+
// 4. `args => {}`
|
|
13
|
+
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
14
|
+
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
|
|
13
15
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
14
16
|
};
|
|
15
17
|
export function serializeIncludingFunctions(info) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "3.0.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "
|
|
1
|
+
export const SDK_VERSION = "3.0.0";
|
|
@@ -19,8 +19,15 @@ export const generateContentUrl = (options) => {
|
|
|
19
19
|
url.searchParams.set('limit', String(limit));
|
|
20
20
|
url.searchParams.set('noTraverse', String(noTraverse));
|
|
21
21
|
url.searchParams.set('includeRefs', String(true));
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const finalLocale = locale || userAttributes?.locale;
|
|
23
|
+
let finalUserAttributes = userAttributes;
|
|
24
|
+
if (finalLocale) {
|
|
25
|
+
url.searchParams.set('locale', finalLocale);
|
|
26
|
+
finalUserAttributes = {
|
|
27
|
+
locale: finalLocale,
|
|
28
|
+
...finalUserAttributes
|
|
29
|
+
};
|
|
30
|
+
}
|
|
24
31
|
if (enrich)
|
|
25
32
|
url.searchParams.set('enrich', String(enrich));
|
|
26
33
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
@@ -56,8 +63,8 @@ export const generateContentUrl = (options) => {
|
|
|
56
63
|
for (const key in flattened) {
|
|
57
64
|
url.searchParams.set(key, String(flattened[key]));
|
|
58
65
|
}
|
|
59
|
-
if (
|
|
60
|
-
url.searchParams.set('userAttributes', JSON.stringify(
|
|
66
|
+
if (finalUserAttributes) {
|
|
67
|
+
url.searchParams.set('userAttributes', JSON.stringify(finalUserAttributes));
|
|
61
68
|
}
|
|
62
69
|
if (query) {
|
|
63
70
|
const flattened = flattenMongoQuery({
|
|
@@ -14,5 +14,5 @@ export declare const _processContentResult: (options: GetContentOptions, content
|
|
|
14
14
|
/**
|
|
15
15
|
* Returns a paginated array of entries that match the given options.
|
|
16
16
|
*/
|
|
17
|
-
export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]
|
|
17
|
+
export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]>;
|
|
18
18
|
export {};
|
|
@@ -78,21 +78,15 @@ export const _processContentResult = async (options, content, url = generateCont
|
|
|
78
78
|
* Returns a paginated array of entries that match the given options.
|
|
79
79
|
*/
|
|
80
80
|
export async function fetchEntries(options) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
return _processContentResult(options, content);
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
logger.error('Error fetching data. ', error);
|
|
96
|
-
return null;
|
|
81
|
+
const url = generateContentUrl(options);
|
|
82
|
+
const content = await _fetchContent(options);
|
|
83
|
+
if (!checkContentHasResults(content)) {
|
|
84
|
+
logger.error('Error fetching data. ', {
|
|
85
|
+
url,
|
|
86
|
+
content,
|
|
87
|
+
options
|
|
88
|
+
});
|
|
89
|
+
throw content;
|
|
97
90
|
}
|
|
91
|
+
return _processContentResult(options, content);
|
|
98
92
|
}
|
|
@@ -9,7 +9,9 @@ const serializeFn = (fnValue) => {
|
|
|
9
9
|
// 1. `function name(args) => {code}`
|
|
10
10
|
// 2. `name(args) => {code}`
|
|
11
11
|
// 3. `(args) => {}`
|
|
12
|
-
|
|
12
|
+
// 4. `args => {}`
|
|
13
|
+
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
14
|
+
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
|
|
13
15
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
14
16
|
};
|
|
15
17
|
export function serializeIncludingFunctions(info) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "3.0.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "
|
|
1
|
+
export const SDK_VERSION = "3.0.0";
|
|
@@ -19,8 +19,15 @@ export const generateContentUrl = (options) => {
|
|
|
19
19
|
url.searchParams.set('limit', String(limit));
|
|
20
20
|
url.searchParams.set('noTraverse', String(noTraverse));
|
|
21
21
|
url.searchParams.set('includeRefs', String(true));
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const finalLocale = locale || userAttributes?.locale;
|
|
23
|
+
let finalUserAttributes = userAttributes;
|
|
24
|
+
if (finalLocale) {
|
|
25
|
+
url.searchParams.set('locale', finalLocale);
|
|
26
|
+
finalUserAttributes = {
|
|
27
|
+
locale: finalLocale,
|
|
28
|
+
...finalUserAttributes
|
|
29
|
+
};
|
|
30
|
+
}
|
|
24
31
|
if (enrich)
|
|
25
32
|
url.searchParams.set('enrich', String(enrich));
|
|
26
33
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
@@ -56,8 +63,8 @@ export const generateContentUrl = (options) => {
|
|
|
56
63
|
for (const key in flattened) {
|
|
57
64
|
url.searchParams.set(key, String(flattened[key]));
|
|
58
65
|
}
|
|
59
|
-
if (
|
|
60
|
-
url.searchParams.set('userAttributes', JSON.stringify(
|
|
66
|
+
if (finalUserAttributes) {
|
|
67
|
+
url.searchParams.set('userAttributes', JSON.stringify(finalUserAttributes));
|
|
61
68
|
}
|
|
62
69
|
if (query) {
|
|
63
70
|
const flattened = flattenMongoQuery({
|
|
@@ -14,5 +14,5 @@ export declare const _processContentResult: (options: GetContentOptions, content
|
|
|
14
14
|
/**
|
|
15
15
|
* Returns a paginated array of entries that match the given options.
|
|
16
16
|
*/
|
|
17
|
-
export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]
|
|
17
|
+
export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]>;
|
|
18
18
|
export {};
|
|
@@ -78,21 +78,15 @@ export const _processContentResult = async (options, content, url = generateCont
|
|
|
78
78
|
* Returns a paginated array of entries that match the given options.
|
|
79
79
|
*/
|
|
80
80
|
export async function fetchEntries(options) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
return _processContentResult(options, content);
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
logger.error('Error fetching data. ', error);
|
|
96
|
-
return null;
|
|
81
|
+
const url = generateContentUrl(options);
|
|
82
|
+
const content = await _fetchContent(options);
|
|
83
|
+
if (!checkContentHasResults(content)) {
|
|
84
|
+
logger.error('Error fetching data. ', {
|
|
85
|
+
url,
|
|
86
|
+
content,
|
|
87
|
+
options
|
|
88
|
+
});
|
|
89
|
+
throw content;
|
|
97
90
|
}
|
|
91
|
+
return _processContentResult(options, content);
|
|
98
92
|
}
|
|
@@ -9,7 +9,9 @@ const serializeFn = (fnValue) => {
|
|
|
9
9
|
// 1. `function name(args) => {code}`
|
|
10
10
|
// 2. `name(args) => {code}`
|
|
11
11
|
// 3. `(args) => {}`
|
|
12
|
-
|
|
12
|
+
// 4. `args => {}`
|
|
13
|
+
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
14
|
+
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
|
|
13
15
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
14
16
|
};
|
|
15
17
|
export function serializeIncludingFunctions(info) {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "
|
|
1
|
+
export const SDK_VERSION = "3.0.0"
|
|
@@ -38,7 +38,15 @@ export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
|
38
38
|
url.searchParams.set('limit', String(limit));
|
|
39
39
|
url.searchParams.set('noTraverse', String(noTraverse));
|
|
40
40
|
url.searchParams.set('includeRefs', String(true));
|
|
41
|
-
|
|
41
|
+
const finalLocale = locale || userAttributes?.locale;
|
|
42
|
+
let finalUserAttributes = userAttributes;
|
|
43
|
+
if (finalLocale) {
|
|
44
|
+
url.searchParams.set('locale', finalLocale);
|
|
45
|
+
finalUserAttributes = {
|
|
46
|
+
locale: finalLocale,
|
|
47
|
+
...finalUserAttributes
|
|
48
|
+
};
|
|
49
|
+
}
|
|
42
50
|
if (enrich) url.searchParams.set('enrich', String(enrich));
|
|
43
51
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
44
52
|
if (fields) {
|
|
@@ -75,8 +83,8 @@ export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
|
75
83
|
for (const key in flattened) {
|
|
76
84
|
url.searchParams.set(key, String(flattened[key]));
|
|
77
85
|
}
|
|
78
|
-
if (
|
|
79
|
-
url.searchParams.set('userAttributes', JSON.stringify(
|
|
86
|
+
if (finalUserAttributes) {
|
|
87
|
+
url.searchParams.set('userAttributes', JSON.stringify(finalUserAttributes));
|
|
80
88
|
}
|
|
81
89
|
if (query) {
|
|
82
90
|
const flattened = flattenMongoQuery({
|
|
@@ -88,20 +88,15 @@ export const _processContentResult = async (options: GetContentOptions, content:
|
|
|
88
88
|
* Returns a paginated array of entries that match the given options.
|
|
89
89
|
*/
|
|
90
90
|
export async function fetchEntries(options: GetContentOptions) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
return _processContentResult(options, content);
|
|
103
|
-
} catch (error) {
|
|
104
|
-
logger.error('Error fetching data. ', error);
|
|
105
|
-
return null;
|
|
91
|
+
const url = generateContentUrl(options);
|
|
92
|
+
const content = await _fetchContent(options);
|
|
93
|
+
if (!checkContentHasResults(content)) {
|
|
94
|
+
logger.error('Error fetching data. ', {
|
|
95
|
+
url,
|
|
96
|
+
content,
|
|
97
|
+
options
|
|
98
|
+
});
|
|
99
|
+
throw content;
|
|
106
100
|
}
|
|
101
|
+
return _processContentResult(options, content);
|
|
107
102
|
}
|
|
@@ -12,7 +12,9 @@ const serializeFn = (fnValue: Function) => {
|
|
|
12
12
|
// 1. `function name(args) => {code}`
|
|
13
13
|
// 2. `name(args) => {code}`
|
|
14
14
|
// 3. `(args) => {}`
|
|
15
|
-
|
|
15
|
+
// 4. `args => {}`
|
|
16
|
+
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
17
|
+
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
|
|
16
18
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
17
19
|
};
|
|
18
20
|
export function serializeIncludingFunctions(info: ComponentInfo) {
|