@builder.io/sdk-svelte 1.0.26 → 1.0.27
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 +2 -2
- package/lib/browser/helpers/flatten.d.ts +10 -0
- package/lib/browser/helpers/flatten.js +20 -0
- 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 +2 -2
- package/lib/edge/helpers/flatten.d.ts +10 -0
- package/lib/edge/helpers/flatten.js +20 -0
- 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 +2 -2
- package/lib/node/helpers/flatten.d.ts +10 -0
- package/lib/node/helpers/flatten.js +20 -0
- package/package.json +1 -1
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/get-content/generate-content-url.ts +3 -3
- package/src/helpers/flatten.ts +22 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.27";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.27";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flatten } from '../../helpers/flatten';
|
|
1
|
+
import { flatten, flattenMongoQuery } from '../../helpers/flatten';
|
|
2
2
|
import { normalizeSearchParams } from '../../helpers/search/search';
|
|
3
3
|
import { DEFAULT_API_VERSION } from '../../types/api-version';
|
|
4
4
|
import { getBuilderSearchParamsFromWindow } from '../get-builder-search-params/index';
|
|
@@ -59,7 +59,7 @@ export const generateContentUrl = (options) => {
|
|
|
59
59
|
url.searchParams.set('userAttributes', JSON.stringify(userAttributes));
|
|
60
60
|
}
|
|
61
61
|
if (query) {
|
|
62
|
-
const flattened =
|
|
62
|
+
const flattened = flattenMongoQuery({
|
|
63
63
|
query
|
|
64
64
|
});
|
|
65
65
|
for (const key in flattened) {
|
|
@@ -4,3 +4,13 @@
|
|
|
4
4
|
* { foo: { bar: 'baz' }} -> { 'foo.bar': 'baz' }
|
|
5
5
|
*/
|
|
6
6
|
export declare function flatten<T extends Record<string, any>>(object: T, path?: string | null, separator?: string): T;
|
|
7
|
+
/**
|
|
8
|
+
* Flatten a nested MongoDB query object into a flat object with dot-separated keys.
|
|
9
|
+
* $ keys are not flattened and are left as is.
|
|
10
|
+
*
|
|
11
|
+
* { foo: { bar: { $gt: 5 }}} -> { 'foo.bar': { '$gt': 5 }}
|
|
12
|
+
* { foo: {'bar.id': { $elemMatch: { 'baz.id': { $in: ['abc', 'bcd'] }}}}} -> { 'foo.bar.id': { '$elemMatch': { 'baz.id': { '$in': ['abc', 'bcd'] }}}}
|
|
13
|
+
*/
|
|
14
|
+
export declare function flattenMongoQuery(obj: any, _current?: any, _res?: any): {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
@@ -17,3 +17,23 @@ export function flatten(object, path = null, separator = '.') {
|
|
|
17
17
|
};
|
|
18
18
|
}, {});
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Flatten a nested MongoDB query object into a flat object with dot-separated keys.
|
|
22
|
+
* $ keys are not flattened and are left as is.
|
|
23
|
+
*
|
|
24
|
+
* { foo: { bar: { $gt: 5 }}} -> { 'foo.bar': { '$gt': 5 }}
|
|
25
|
+
* { foo: {'bar.id': { $elemMatch: { 'baz.id': { $in: ['abc', 'bcd'] }}}}} -> { 'foo.bar.id': { '$elemMatch': { 'baz.id': { '$in': ['abc', 'bcd'] }}}}
|
|
26
|
+
*/
|
|
27
|
+
export function flattenMongoQuery(obj, _current, _res = {}) {
|
|
28
|
+
for (const key in obj) {
|
|
29
|
+
const value = obj[key];
|
|
30
|
+
const newKey = _current ? _current + '.' + key : key;
|
|
31
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).find(item => item.startsWith('$'))) {
|
|
32
|
+
flattenMongoQuery(value, newKey, _res);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
_res[newKey] = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return _res;
|
|
39
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.27";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.27";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flatten } from '../../helpers/flatten';
|
|
1
|
+
import { flatten, flattenMongoQuery } from '../../helpers/flatten';
|
|
2
2
|
import { normalizeSearchParams } from '../../helpers/search/search';
|
|
3
3
|
import { DEFAULT_API_VERSION } from '../../types/api-version';
|
|
4
4
|
import { getBuilderSearchParamsFromWindow } from '../get-builder-search-params/index';
|
|
@@ -59,7 +59,7 @@ export const generateContentUrl = (options) => {
|
|
|
59
59
|
url.searchParams.set('userAttributes', JSON.stringify(userAttributes));
|
|
60
60
|
}
|
|
61
61
|
if (query) {
|
|
62
|
-
const flattened =
|
|
62
|
+
const flattened = flattenMongoQuery({
|
|
63
63
|
query
|
|
64
64
|
});
|
|
65
65
|
for (const key in flattened) {
|
|
@@ -4,3 +4,13 @@
|
|
|
4
4
|
* { foo: { bar: 'baz' }} -> { 'foo.bar': 'baz' }
|
|
5
5
|
*/
|
|
6
6
|
export declare function flatten<T extends Record<string, any>>(object: T, path?: string | null, separator?: string): T;
|
|
7
|
+
/**
|
|
8
|
+
* Flatten a nested MongoDB query object into a flat object with dot-separated keys.
|
|
9
|
+
* $ keys are not flattened and are left as is.
|
|
10
|
+
*
|
|
11
|
+
* { foo: { bar: { $gt: 5 }}} -> { 'foo.bar': { '$gt': 5 }}
|
|
12
|
+
* { foo: {'bar.id': { $elemMatch: { 'baz.id': { $in: ['abc', 'bcd'] }}}}} -> { 'foo.bar.id': { '$elemMatch': { 'baz.id': { '$in': ['abc', 'bcd'] }}}}
|
|
13
|
+
*/
|
|
14
|
+
export declare function flattenMongoQuery(obj: any, _current?: any, _res?: any): {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
@@ -17,3 +17,23 @@ export function flatten(object, path = null, separator = '.') {
|
|
|
17
17
|
};
|
|
18
18
|
}, {});
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Flatten a nested MongoDB query object into a flat object with dot-separated keys.
|
|
22
|
+
* $ keys are not flattened and are left as is.
|
|
23
|
+
*
|
|
24
|
+
* { foo: { bar: { $gt: 5 }}} -> { 'foo.bar': { '$gt': 5 }}
|
|
25
|
+
* { foo: {'bar.id': { $elemMatch: { 'baz.id': { $in: ['abc', 'bcd'] }}}}} -> { 'foo.bar.id': { '$elemMatch': { 'baz.id': { '$in': ['abc', 'bcd'] }}}}
|
|
26
|
+
*/
|
|
27
|
+
export function flattenMongoQuery(obj, _current, _res = {}) {
|
|
28
|
+
for (const key in obj) {
|
|
29
|
+
const value = obj[key];
|
|
30
|
+
const newKey = _current ? _current + '.' + key : key;
|
|
31
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).find(item => item.startsWith('$'))) {
|
|
32
|
+
flattenMongoQuery(value, newKey, _res);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
_res[newKey] = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return _res;
|
|
39
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.27";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.27";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flatten } from '../../helpers/flatten';
|
|
1
|
+
import { flatten, flattenMongoQuery } from '../../helpers/flatten';
|
|
2
2
|
import { normalizeSearchParams } from '../../helpers/search/search';
|
|
3
3
|
import { DEFAULT_API_VERSION } from '../../types/api-version';
|
|
4
4
|
import { getBuilderSearchParamsFromWindow } from '../get-builder-search-params/index';
|
|
@@ -59,7 +59,7 @@ export const generateContentUrl = (options) => {
|
|
|
59
59
|
url.searchParams.set('userAttributes', JSON.stringify(userAttributes));
|
|
60
60
|
}
|
|
61
61
|
if (query) {
|
|
62
|
-
const flattened =
|
|
62
|
+
const flattened = flattenMongoQuery({
|
|
63
63
|
query
|
|
64
64
|
});
|
|
65
65
|
for (const key in flattened) {
|
|
@@ -4,3 +4,13 @@
|
|
|
4
4
|
* { foo: { bar: 'baz' }} -> { 'foo.bar': 'baz' }
|
|
5
5
|
*/
|
|
6
6
|
export declare function flatten<T extends Record<string, any>>(object: T, path?: string | null, separator?: string): T;
|
|
7
|
+
/**
|
|
8
|
+
* Flatten a nested MongoDB query object into a flat object with dot-separated keys.
|
|
9
|
+
* $ keys are not flattened and are left as is.
|
|
10
|
+
*
|
|
11
|
+
* { foo: { bar: { $gt: 5 }}} -> { 'foo.bar': { '$gt': 5 }}
|
|
12
|
+
* { foo: {'bar.id': { $elemMatch: { 'baz.id': { $in: ['abc', 'bcd'] }}}}} -> { 'foo.bar.id': { '$elemMatch': { 'baz.id': { '$in': ['abc', 'bcd'] }}}}
|
|
13
|
+
*/
|
|
14
|
+
export declare function flattenMongoQuery(obj: any, _current?: any, _res?: any): {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
@@ -17,3 +17,23 @@ export function flatten(object, path = null, separator = '.') {
|
|
|
17
17
|
};
|
|
18
18
|
}, {});
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Flatten a nested MongoDB query object into a flat object with dot-separated keys.
|
|
22
|
+
* $ keys are not flattened and are left as is.
|
|
23
|
+
*
|
|
24
|
+
* { foo: { bar: { $gt: 5 }}} -> { 'foo.bar': { '$gt': 5 }}
|
|
25
|
+
* { foo: {'bar.id': { $elemMatch: { 'baz.id': { $in: ['abc', 'bcd'] }}}}} -> { 'foo.bar.id': { '$elemMatch': { 'baz.id': { '$in': ['abc', 'bcd'] }}}}
|
|
26
|
+
*/
|
|
27
|
+
export function flattenMongoQuery(obj, _current, _res = {}) {
|
|
28
|
+
for (const key in obj) {
|
|
29
|
+
const value = obj[key];
|
|
30
|
+
const newKey = _current ? _current + '.' + key : key;
|
|
31
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).find(item => item.startsWith('$'))) {
|
|
32
|
+
flattenMongoQuery(value, newKey, _res);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
_res[newKey] = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return _res;
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.27"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flatten } from '../../helpers/flatten';
|
|
1
|
+
import { flatten, flattenMongoQuery } from '../../helpers/flatten';
|
|
2
2
|
import { normalizeSearchParams } from '../../helpers/search/search';
|
|
3
3
|
import { DEFAULT_API_VERSION } from '../../types/api-version';
|
|
4
4
|
import { getBuilderSearchParamsFromWindow } from '../get-builder-search-params/index';
|
|
@@ -77,11 +77,11 @@ export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
|
77
77
|
url.searchParams.set('userAttributes', JSON.stringify(userAttributes));
|
|
78
78
|
}
|
|
79
79
|
if (query) {
|
|
80
|
-
const flattened =
|
|
80
|
+
const flattened = flattenMongoQuery({
|
|
81
81
|
query
|
|
82
82
|
});
|
|
83
83
|
for (const key in flattened) {
|
|
84
|
-
url.searchParams.set(key, JSON.stringify(
|
|
84
|
+
url.searchParams.set(key, JSON.stringify(flattened[key]));
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
return url;
|
package/src/helpers/flatten.ts
CHANGED
|
@@ -16,4 +16,26 @@ export function flatten<T extends Record<string, any>>(object: T, path: string |
|
|
|
16
16
|
[newPath]: value
|
|
17
17
|
};
|
|
18
18
|
}, ({} as T));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Flatten a nested MongoDB query object into a flat object with dot-separated keys.
|
|
23
|
+
* $ keys are not flattened and are left as is.
|
|
24
|
+
*
|
|
25
|
+
* { foo: { bar: { $gt: 5 }}} -> { 'foo.bar': { '$gt': 5 }}
|
|
26
|
+
* { foo: {'bar.id': { $elemMatch: { 'baz.id': { $in: ['abc', 'bcd'] }}}}} -> { 'foo.bar.id': { '$elemMatch': { 'baz.id': { '$in': ['abc', 'bcd'] }}}}
|
|
27
|
+
*/
|
|
28
|
+
export function flattenMongoQuery(obj: any, _current?: any, _res: any = {}): {
|
|
29
|
+
[key: string]: string;
|
|
30
|
+
} {
|
|
31
|
+
for (const key in obj) {
|
|
32
|
+
const value = obj[key];
|
|
33
|
+
const newKey = _current ? _current + '.' + key : key;
|
|
34
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).find(item => item.startsWith('$'))) {
|
|
35
|
+
flattenMongoQuery(value, newKey, _res);
|
|
36
|
+
} else {
|
|
37
|
+
_res[newKey] = value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return _res;
|
|
19
41
|
}
|