@builder.io/sdk 5.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/CHANGELOG.md +14 -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 +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -950,7 +950,7 @@ function toError(err) {
|
|
|
950
950
|
|
|
951
951
|
var DEFAULT_API_VERSION = 'v3';
|
|
952
952
|
|
|
953
|
-
var SDK_VERSION = '
|
|
953
|
+
var SDK_VERSION = '6.0.0';
|
|
954
954
|
|
|
955
955
|
function datePlusMinutes(minutes) {
|
|
956
956
|
if (minutes === void 0) { minutes = 30; }
|
|
@@ -1098,6 +1098,11 @@ var Builder = /** @class */ (function () {
|
|
|
1098
1098
|
this.overrideParams = '';
|
|
1099
1099
|
this.noCache = false;
|
|
1100
1100
|
this.preview = false;
|
|
1101
|
+
/**
|
|
1102
|
+
* Dictates which API endpoint is used when fetching content. Allows `'content'` and `'query'`.
|
|
1103
|
+
* Defaults to `'query'`.
|
|
1104
|
+
*/
|
|
1105
|
+
this.apiEndpoint$ = new BehaviorSubject('query');
|
|
1101
1106
|
this.apiVersion$ = new BehaviorSubject(undefined);
|
|
1102
1107
|
this.canTrack$ = new BehaviorSubject(!this.browserTrackingDisabled);
|
|
1103
1108
|
this.apiKey$ = new BehaviorSubject(null);
|
|
@@ -1351,8 +1356,14 @@ var Builder = /** @class */ (function () {
|
|
|
1351
1356
|
// 2. `name(args) => {code}`
|
|
1352
1357
|
// 3. `(args) => {}`
|
|
1353
1358
|
// 4. `args => {}`
|
|
1359
|
+
// 5. `async function(args) {code}`
|
|
1360
|
+
// 6. `async (args) => {}`
|
|
1361
|
+
// 7. `async args => {}`
|
|
1354
1362
|
var isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
1355
|
-
var appendFunction = !fnStr.startsWith('function') &&
|
|
1363
|
+
var appendFunction = !fnStr.startsWith('function') &&
|
|
1364
|
+
!fnStr.startsWith('async') &&
|
|
1365
|
+
!fnStr.startsWith('(') &&
|
|
1366
|
+
!isArrowWithoutParens;
|
|
1356
1367
|
return "return (".concat(appendFunction ? 'function ' : '').concat(fnStr, ").apply(this, arguments)");
|
|
1357
1368
|
};
|
|
1358
1369
|
return JSON.parse(JSON.stringify(info, function (key, value) {
|
|
@@ -1484,6 +1495,18 @@ var Builder = /** @class */ (function () {
|
|
|
1484
1495
|
enumerable: false,
|
|
1485
1496
|
configurable: true
|
|
1486
1497
|
});
|
|
1498
|
+
Object.defineProperty(Builder.prototype, "apiEndpoint", {
|
|
1499
|
+
get: function () {
|
|
1500
|
+
return this.apiEndpoint$.value;
|
|
1501
|
+
},
|
|
1502
|
+
set: function (apiEndpoint) {
|
|
1503
|
+
if (this.apiEndpoint !== apiEndpoint) {
|
|
1504
|
+
this.apiEndpoint$.next(apiEndpoint);
|
|
1505
|
+
}
|
|
1506
|
+
},
|
|
1507
|
+
enumerable: false,
|
|
1508
|
+
configurable: true
|
|
1509
|
+
});
|
|
1487
1510
|
Object.defineProperty(Builder.prototype, "editingMode", {
|
|
1488
1511
|
get: function () {
|
|
1489
1512
|
return this.editingMode$.value;
|
|
@@ -2122,12 +2145,16 @@ var Builder = /** @class */ (function () {
|
|
|
2122
2145
|
if (options === void 0) { options = {}; }
|
|
2123
2146
|
var instance = this;
|
|
2124
2147
|
var finalLocale = options.locale || ((_a = options.userAttributes) === null || _a === void 0 ? void 0 : _a.locale) || this.getUserAttributes().locale;
|
|
2148
|
+
if (!('noTraverse' in options)) {
|
|
2149
|
+
options.noTraverse = false;
|
|
2150
|
+
}
|
|
2125
2151
|
var finalOptions = __assign(__assign({}, options), (finalLocale && {
|
|
2126
2152
|
locale: String(finalLocale),
|
|
2127
2153
|
userAttributes: __assign({ locale: String(finalLocale) }, options.userAttributes),
|
|
2128
2154
|
}));
|
|
2129
2155
|
if (!Builder.isBrowser) {
|
|
2130
2156
|
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken, options.apiVersion || this.apiVersion);
|
|
2157
|
+
instance.apiEndpoint = this.apiEndpoint;
|
|
2131
2158
|
instance.setUserAttributes(this.getUserAttributes());
|
|
2132
2159
|
}
|
|
2133
2160
|
else {
|
|
@@ -2327,7 +2354,6 @@ var Builder = /** @class */ (function () {
|
|
|
2327
2354
|
return;
|
|
2328
2355
|
}
|
|
2329
2356
|
var queue = useQueue || (usePastQueue ? this.priorContentQueue : this.getContentQueue) || [];
|
|
2330
|
-
var apiEndpoint = queue[0].apiEndpoint || 'query';
|
|
2331
2357
|
// TODO: do this on every request send?
|
|
2332
2358
|
this.getOverridesFromQueryString();
|
|
2333
2359
|
var queryParams = __assign(__assign({
|
|
@@ -2421,6 +2447,9 @@ var Builder = /** @class */ (function () {
|
|
|
2421
2447
|
if (isPositiveNumber(options.staleCacheSeconds)) {
|
|
2422
2448
|
queryParams.staleCacheSeconds = options.staleCacheSeconds;
|
|
2423
2449
|
}
|
|
2450
|
+
if (this.apiEndpoint === 'content') {
|
|
2451
|
+
queryParams.includeRefs = true;
|
|
2452
|
+
}
|
|
2424
2453
|
var properties = [
|
|
2425
2454
|
'prerender',
|
|
2426
2455
|
'extractCss',
|
|
@@ -2432,12 +2461,13 @@ var Builder = /** @class */ (function () {
|
|
|
2432
2461
|
'entry',
|
|
2433
2462
|
'rev',
|
|
2434
2463
|
'static',
|
|
2464
|
+
'includeRefs',
|
|
2435
2465
|
];
|
|
2436
2466
|
for (var _a = 0, properties_1 = properties; _a < properties_1.length; _a++) {
|
|
2437
2467
|
var key = properties_1[_a];
|
|
2438
2468
|
var value = options[key];
|
|
2439
2469
|
if (value !== undefined) {
|
|
2440
|
-
if (apiEndpoint === 'query') {
|
|
2470
|
+
if (this.apiEndpoint === 'query') {
|
|
2441
2471
|
queryParams.options = queryParams.options || {};
|
|
2442
2472
|
queryParams.options[options.key] = queryParams.options[options.key] || {};
|
|
2443
2473
|
queryParams.options[options.key][key] = JSON.stringify(value);
|
|
@@ -2461,9 +2491,8 @@ var Builder = /** @class */ (function () {
|
|
|
2461
2491
|
}
|
|
2462
2492
|
var format = queryParams.format;
|
|
2463
2493
|
var isApiCallForCodegen = format === 'solid' || format === 'react';
|
|
2464
|
-
var isApiCallForCodegenOrQuery = isApiCallForCodegen || apiEndpoint === 'query';
|
|
2465
|
-
if (apiEndpoint === 'content') {
|
|
2466
|
-
queryParams.enrich = true;
|
|
2494
|
+
var isApiCallForCodegenOrQuery = isApiCallForCodegen || this.apiEndpoint === 'query';
|
|
2495
|
+
if (this.apiEndpoint === 'content') {
|
|
2467
2496
|
if (queue[0].query) {
|
|
2468
2497
|
var flattened = this.flattenMongoQuery({ query: queue[0].query });
|
|
2469
2498
|
for (var key in flattened) {
|
|
@@ -2481,7 +2510,7 @@ var Builder = /** @class */ (function () {
|
|
|
2481
2510
|
if (isApiCallForCodegen) {
|
|
2482
2511
|
url = "".concat(host, "/api/v1/codegen/").concat(this.apiKey, "/").concat(keyNames);
|
|
2483
2512
|
}
|
|
2484
|
-
else if (apiEndpoint === 'query') {
|
|
2513
|
+
else if (this.apiEndpoint === 'query') {
|
|
2485
2514
|
url = "".concat(host, "/api/v3/query/").concat(this.apiKey, "/").concat(keyNames);
|
|
2486
2515
|
}
|
|
2487
2516
|
else {
|