@builder.io/sdk 5.0.0-0 → 6.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/.yarnrc.yml +1 -0
- package/CHANGELOG.md +20 -0
- package/dist/index.browser.js +37 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +37 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +37 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +37 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/builder.class.d.ts +10 -5
- package/dist/src/builder.class.js +36 -7
- package/dist/src/builder.class.js.map +1 -1
- package/dist/src/builder.class.test.js +289 -8
- package/dist/src/builder.class.test.js.map +1 -1
- package/dist/src/sdk-version.d.ts +1 -1
- package/dist/src/sdk-version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/scripts/set-sdk-version.sh +0 -0
package/dist/index.umd.js
CHANGED
|
@@ -1052,7 +1052,7 @@
|
|
|
1052
1052
|
|
|
1053
1053
|
var DEFAULT_API_VERSION = 'v3';
|
|
1054
1054
|
|
|
1055
|
-
var SDK_VERSION = '
|
|
1055
|
+
var SDK_VERSION = '6.0.0';
|
|
1056
1056
|
|
|
1057
1057
|
function datePlusMinutes(minutes) {
|
|
1058
1058
|
if (minutes === void 0) { minutes = 30; }
|
|
@@ -1200,6 +1200,11 @@
|
|
|
1200
1200
|
this.overrideParams = '';
|
|
1201
1201
|
this.noCache = false;
|
|
1202
1202
|
this.preview = false;
|
|
1203
|
+
/**
|
|
1204
|
+
* Dictates which API endpoint is used when fetching content. Allows `'content'` and `'query'`.
|
|
1205
|
+
* Defaults to `'query'`.
|
|
1206
|
+
*/
|
|
1207
|
+
this.apiEndpoint$ = new BehaviorSubject('query');
|
|
1203
1208
|
this.apiVersion$ = new BehaviorSubject(undefined);
|
|
1204
1209
|
this.canTrack$ = new BehaviorSubject(!this.browserTrackingDisabled);
|
|
1205
1210
|
this.apiKey$ = new BehaviorSubject(null);
|
|
@@ -1453,8 +1458,14 @@
|
|
|
1453
1458
|
// 2. `name(args) => {code}`
|
|
1454
1459
|
// 3. `(args) => {}`
|
|
1455
1460
|
// 4. `args => {}`
|
|
1461
|
+
// 5. `async function(args) {code}`
|
|
1462
|
+
// 6. `async (args) => {}`
|
|
1463
|
+
// 7. `async args => {}`
|
|
1456
1464
|
var isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
1457
|
-
var appendFunction = !fnStr.startsWith('function') &&
|
|
1465
|
+
var appendFunction = !fnStr.startsWith('function') &&
|
|
1466
|
+
!fnStr.startsWith('async') &&
|
|
1467
|
+
!fnStr.startsWith('(') &&
|
|
1468
|
+
!isArrowWithoutParens;
|
|
1458
1469
|
return "return (".concat(appendFunction ? 'function ' : '').concat(fnStr, ").apply(this, arguments)");
|
|
1459
1470
|
};
|
|
1460
1471
|
return JSON.parse(JSON.stringify(info, function (key, value) {
|
|
@@ -1586,6 +1597,18 @@
|
|
|
1586
1597
|
enumerable: false,
|
|
1587
1598
|
configurable: true
|
|
1588
1599
|
});
|
|
1600
|
+
Object.defineProperty(Builder.prototype, "apiEndpoint", {
|
|
1601
|
+
get: function () {
|
|
1602
|
+
return this.apiEndpoint$.value;
|
|
1603
|
+
},
|
|
1604
|
+
set: function (apiEndpoint) {
|
|
1605
|
+
if (this.apiEndpoint !== apiEndpoint) {
|
|
1606
|
+
this.apiEndpoint$.next(apiEndpoint);
|
|
1607
|
+
}
|
|
1608
|
+
},
|
|
1609
|
+
enumerable: false,
|
|
1610
|
+
configurable: true
|
|
1611
|
+
});
|
|
1589
1612
|
Object.defineProperty(Builder.prototype, "editingMode", {
|
|
1590
1613
|
get: function () {
|
|
1591
1614
|
return this.editingMode$.value;
|
|
@@ -2224,12 +2247,16 @@
|
|
|
2224
2247
|
if (options === void 0) { options = {}; }
|
|
2225
2248
|
var instance = this;
|
|
2226
2249
|
var finalLocale = options.locale || ((_a = options.userAttributes) === null || _a === void 0 ? void 0 : _a.locale) || this.getUserAttributes().locale;
|
|
2250
|
+
if (!('noTraverse' in options)) {
|
|
2251
|
+
options.noTraverse = false;
|
|
2252
|
+
}
|
|
2227
2253
|
var finalOptions = __assign(__assign({}, options), (finalLocale && {
|
|
2228
2254
|
locale: String(finalLocale),
|
|
2229
2255
|
userAttributes: __assign({ locale: String(finalLocale) }, options.userAttributes),
|
|
2230
2256
|
}));
|
|
2231
2257
|
if (!Builder.isBrowser) {
|
|
2232
2258
|
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken, options.apiVersion || this.apiVersion);
|
|
2259
|
+
instance.apiEndpoint = this.apiEndpoint;
|
|
2233
2260
|
instance.setUserAttributes(this.getUserAttributes());
|
|
2234
2261
|
}
|
|
2235
2262
|
else {
|
|
@@ -2429,7 +2456,6 @@
|
|
|
2429
2456
|
return;
|
|
2430
2457
|
}
|
|
2431
2458
|
var queue = useQueue || (usePastQueue ? this.priorContentQueue : this.getContentQueue) || [];
|
|
2432
|
-
var apiEndpoint = queue[0].apiEndpoint || 'query';
|
|
2433
2459
|
// TODO: do this on every request send?
|
|
2434
2460
|
this.getOverridesFromQueryString();
|
|
2435
2461
|
var queryParams = __assign(__assign({
|
|
@@ -2523,6 +2549,9 @@
|
|
|
2523
2549
|
if (isPositiveNumber(options.staleCacheSeconds)) {
|
|
2524
2550
|
queryParams.staleCacheSeconds = options.staleCacheSeconds;
|
|
2525
2551
|
}
|
|
2552
|
+
if (this.apiEndpoint === 'content') {
|
|
2553
|
+
queryParams.includeRefs = true;
|
|
2554
|
+
}
|
|
2526
2555
|
var properties = [
|
|
2527
2556
|
'prerender',
|
|
2528
2557
|
'extractCss',
|
|
@@ -2534,12 +2563,13 @@
|
|
|
2534
2563
|
'entry',
|
|
2535
2564
|
'rev',
|
|
2536
2565
|
'static',
|
|
2566
|
+
'includeRefs',
|
|
2537
2567
|
];
|
|
2538
2568
|
for (var _a = 0, properties_1 = properties; _a < properties_1.length; _a++) {
|
|
2539
2569
|
var key = properties_1[_a];
|
|
2540
2570
|
var value = options[key];
|
|
2541
2571
|
if (value !== undefined) {
|
|
2542
|
-
if (apiEndpoint === 'query') {
|
|
2572
|
+
if (this.apiEndpoint === 'query') {
|
|
2543
2573
|
queryParams.options = queryParams.options || {};
|
|
2544
2574
|
queryParams.options[options.key] = queryParams.options[options.key] || {};
|
|
2545
2575
|
queryParams.options[options.key][key] = JSON.stringify(value);
|
|
@@ -2563,9 +2593,8 @@
|
|
|
2563
2593
|
}
|
|
2564
2594
|
var format = queryParams.format;
|
|
2565
2595
|
var isApiCallForCodegen = format === 'solid' || format === 'react';
|
|
2566
|
-
var isApiCallForCodegenOrQuery = isApiCallForCodegen || apiEndpoint === 'query';
|
|
2567
|
-
if (apiEndpoint === 'content') {
|
|
2568
|
-
queryParams.enrich = true;
|
|
2596
|
+
var isApiCallForCodegenOrQuery = isApiCallForCodegen || this.apiEndpoint === 'query';
|
|
2597
|
+
if (this.apiEndpoint === 'content') {
|
|
2569
2598
|
if (queue[0].query) {
|
|
2570
2599
|
var flattened = this.flattenMongoQuery({ query: queue[0].query });
|
|
2571
2600
|
for (var key in flattened) {
|
|
@@ -2583,7 +2612,7 @@
|
|
|
2583
2612
|
if (isApiCallForCodegen) {
|
|
2584
2613
|
url = "".concat(host, "/api/v1/codegen/").concat(this.apiKey, "/").concat(keyNames);
|
|
2585
2614
|
}
|
|
2586
|
-
else if (apiEndpoint === 'query') {
|
|
2615
|
+
else if (this.apiEndpoint === 'query') {
|
|
2587
2616
|
url = "".concat(host, "/api/v3/query/").concat(this.apiKey, "/").concat(keyNames);
|
|
2588
2617
|
}
|
|
2589
2618
|
else {
|