@builder.io/sdk-svelte 0.7.0 → 0.7.1-1
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/blocks/custom-code/custom-code.svelte +35 -37
- package/lib/browser/components/content/components/enable-editor.svelte +82 -65
- package/lib/browser/components/content/components/enable-editor.svelte.d.ts +3 -3
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/evaluate/choose-eval.d.ts +6 -0
- package/lib/browser/functions/evaluate/choose-eval.js +19 -0
- package/lib/browser/functions/evaluate/evaluate.d.ts +1 -5
- package/lib/browser/functions/evaluate/evaluate.js +7 -30
- package/lib/browser/functions/evaluate/helpers.d.ts +7 -1
- package/lib/browser/functions/evaluate/helpers.js +18 -0
- package/lib/browser/functions/evaluate/node-runtime/index.d.ts +1 -1
- package/lib/browser/functions/evaluate/node-runtime/index.js +1 -1
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.d.ts +2 -0
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.js +120 -0
- package/lib/browser/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +13 -0
- package/lib/browser/functions/evaluate/node-runtime/safeDynamicRequire.js +18 -0
- package/lib/browser/functions/get-content/generate-content-url.js +27 -1
- package/lib/browser/functions/get-content/types.d.ts +94 -3
- package/lib/browser/functions/is-edge-runtime.js +2 -2
- package/lib/browser/functions/is-node-runtime.d.ts +4 -0
- package/lib/browser/functions/is-node-runtime.js +7 -0
- package/lib/edge/blocks/custom-code/custom-code.svelte +35 -37
- package/lib/edge/components/content/components/enable-editor.svelte +82 -65
- package/lib/edge/components/content/components/enable-editor.svelte.d.ts +3 -3
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/evaluate/choose-eval.d.ts +6 -0
- package/lib/edge/functions/evaluate/choose-eval.js +19 -0
- package/lib/edge/functions/evaluate/evaluate.d.ts +1 -5
- package/lib/edge/functions/evaluate/evaluate.js +7 -30
- package/lib/edge/functions/evaluate/helpers.d.ts +7 -1
- package/lib/edge/functions/evaluate/helpers.js +18 -0
- package/lib/edge/functions/evaluate/node-runtime/index.d.ts +1 -1
- package/lib/edge/functions/evaluate/node-runtime/index.js +1 -1
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.d.ts +2 -0
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.js +120 -0
- package/lib/edge/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +13 -0
- package/lib/edge/functions/evaluate/node-runtime/safeDynamicRequire.js +18 -0
- package/lib/edge/functions/get-content/generate-content-url.js +27 -1
- package/lib/edge/functions/get-content/types.d.ts +94 -3
- package/lib/edge/functions/is-edge-runtime.js +2 -2
- package/lib/edge/functions/is-node-runtime.d.ts +4 -0
- package/lib/edge/functions/is-node-runtime.js +7 -0
- package/lib/node/blocks/custom-code/custom-code.svelte +35 -37
- package/lib/node/components/content/components/enable-editor.svelte +82 -65
- package/lib/node/components/content/components/enable-editor.svelte.d.ts +3 -3
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/evaluate/choose-eval.d.ts +6 -0
- package/lib/node/functions/evaluate/choose-eval.js +19 -0
- package/lib/node/functions/evaluate/evaluate.d.ts +1 -5
- package/lib/node/functions/evaluate/evaluate.js +7 -30
- package/lib/node/functions/evaluate/helpers.d.ts +7 -1
- package/lib/node/functions/evaluate/helpers.js +18 -0
- package/lib/node/functions/evaluate/node-runtime/index.d.ts +1 -1
- package/lib/node/functions/evaluate/node-runtime/index.js +1 -1
- package/lib/node/functions/evaluate/node-runtime/node-runtime.d.ts +2 -0
- package/lib/node/functions/evaluate/node-runtime/node-runtime.js +120 -0
- package/lib/node/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +13 -0
- package/lib/node/functions/evaluate/node-runtime/safeDynamicRequire.js +18 -0
- package/lib/node/functions/get-content/generate-content-url.js +27 -1
- package/lib/node/functions/get-content/types.d.ts +94 -3
- package/lib/node/functions/is-edge-runtime.js +2 -2
- package/lib/node/functions/is-node-runtime.d.ts +4 -0
- package/lib/node/functions/is-node-runtime.js +7 -0
- package/package.json +4 -1
- package/src/blocks/custom-code/custom-code.svelte +37 -40
- package/src/blocks/image/image.svelte +1 -1
- package/src/components/content/components/enable-editor.svelte +97 -79
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/evaluate/choose-eval.ts +22 -0
- package/src/functions/evaluate/evaluate.ts +8 -37
- package/src/functions/evaluate/helpers.ts +24 -1
- package/src/functions/evaluate/node-runtime/index.ts +1 -1
- package/src/functions/evaluate/node-runtime/node-runtime.ts +138 -0
- package/src/functions/evaluate/node-runtime/safeDynamicRequire.ts +18 -0
- package/src/functions/get-content/generate-content-url.ts +36 -1
- package/src/functions/get-content/types.ts +101 -3
- package/src/functions/is-edge-runtime.ts +2 -2
- package/src/functions/is-node-runtime.ts +8 -0
|
@@ -8,12 +8,44 @@ export interface GetContentOptions {
|
|
|
8
8
|
/** Number of items to fetch. Default is 1 */
|
|
9
9
|
limit?: number;
|
|
10
10
|
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Use to specify an offset for pagination of results. The default is 0.
|
|
13
|
+
*/
|
|
14
|
+
offset?: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* User attribute key value pairs to be used for targeting
|
|
18
|
+
* https://www.builder.io/c/docs/custom-targeting-attributes
|
|
19
|
+
*
|
|
20
|
+
* e.g.
|
|
21
|
+
* ```js
|
|
22
|
+
* userAttributes: {
|
|
23
|
+
* urlPath: '/',
|
|
24
|
+
* returnVisitor: true,
|
|
25
|
+
* device: 'mobile'
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
12
29
|
userAttributes?: (Record<string, string> & {
|
|
13
30
|
urlPath?: string;
|
|
14
31
|
}) | null;
|
|
15
32
|
|
|
16
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Mongodb style query of your data. E.g.:
|
|
35
|
+
*
|
|
36
|
+
* ```js
|
|
37
|
+
* query: {
|
|
38
|
+
* id: 'abc123',
|
|
39
|
+
* data: {
|
|
40
|
+
* myCustomField: { $gt: 20 },
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* See more info on MongoDB's query operators and format.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link https://docs.mongodb.com/manual/reference/operator/query/}
|
|
48
|
+
*/
|
|
17
49
|
query?: Record<string, any>;
|
|
18
50
|
|
|
19
51
|
/**
|
|
@@ -38,7 +70,7 @@ export interface GetContentOptions {
|
|
|
38
70
|
canTrack?: boolean;
|
|
39
71
|
|
|
40
72
|
/**
|
|
41
|
-
* Include references in the response. Defaults to `true`.
|
|
73
|
+
* Include content of references in the response. Defaults to `true`.
|
|
42
74
|
* @deprecated use `enrich` instead
|
|
43
75
|
*/
|
|
44
76
|
includeRefs?: boolean;
|
|
@@ -59,4 +91,70 @@ export interface GetContentOptions {
|
|
|
59
91
|
* Defaults to `v3`.
|
|
60
92
|
*/
|
|
61
93
|
apiVersion?: 'v2' | 'v3';
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Only include these fields.
|
|
97
|
+
* Note: 'omit' takes precedence over 'fields'
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```
|
|
101
|
+
* fields: 'id, name, data.customField'
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
fields?: string;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Omit only these fields.
|
|
108
|
+
* Note: 'omit' takes precedence over 'fields'
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```
|
|
112
|
+
* omit: 'data.bigField,data.blocks'
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
omit?: string;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Seconds to cache content. Sets the max-age of the cache-control header
|
|
119
|
+
* response header.
|
|
120
|
+
*
|
|
121
|
+
* Use a higher value for better performance, lower for content that will change more frequently
|
|
122
|
+
*
|
|
123
|
+
* @see {@link https://www.builder.io/c/docs/query-api#__next:~:text=%26includeRefs%3Dtrue-,cacheSeconds,-No}
|
|
124
|
+
*/
|
|
125
|
+
cacheSeconds?: number;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Builder.io uses stale-while-revalidate caching at the CDN level. This means we always serve
|
|
129
|
+
* from edge cache and update caches in the background for maximum possible performance. This also
|
|
130
|
+
* means that the more frequently content is requested, the more fresh it will be. The longest we
|
|
131
|
+
* will ever hold something in stale cache is 1 day by default, and you can set this to be shorter
|
|
132
|
+
* yourself as well. We suggest keeping this high unless you have content that must change rapidly
|
|
133
|
+
* and gets very little traffic.
|
|
134
|
+
*
|
|
135
|
+
* @see {@link https://www.fastly.com/blog/prevent-application-network-instability-serve-stale-content}
|
|
136
|
+
*/
|
|
137
|
+
staleCacheSeconds?: number;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Property to order results by.
|
|
141
|
+
* Use 1 for ascending and -1 for descending.
|
|
142
|
+
*
|
|
143
|
+
* The key is what you're sorting on, so the following example sorts by createdDate
|
|
144
|
+
* and because the value is 1, the sort is ascending.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```
|
|
148
|
+
* createdDate: 1
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
sort?: {
|
|
152
|
+
[key: string]: 1 | -1;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Include content entries in a response that are still in
|
|
157
|
+
* draft mode and un-archived. Default is false.
|
|
158
|
+
*/
|
|
159
|
+
includeUnpublished?: boolean;
|
|
62
160
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isBrowser } from './is-browser.js';
|
|
2
|
+
import { isNodeRuntime } from './is-node-runtime.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Identifies edge runtimes (edge, workers, serverless, etc.)
|
|
5
6
|
*/
|
|
6
7
|
export function isEdgeRuntime(): boolean {
|
|
7
|
-
|
|
8
|
-
return !isBrowser() && !hasNode();
|
|
8
|
+
return !isBrowser() && !isNodeRuntime();
|
|
9
9
|
}
|