@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.cjs.js
CHANGED
|
@@ -958,7 +958,7 @@ function toError(err) {
|
|
|
958
958
|
|
|
959
959
|
var DEFAULT_API_VERSION = 'v3';
|
|
960
960
|
|
|
961
|
-
var SDK_VERSION = '
|
|
961
|
+
var SDK_VERSION = '6.0.0';
|
|
962
962
|
|
|
963
963
|
function datePlusMinutes(minutes) {
|
|
964
964
|
if (minutes === void 0) { minutes = 30; }
|
|
@@ -1106,6 +1106,11 @@ var Builder = /** @class */ (function () {
|
|
|
1106
1106
|
this.overrideParams = '';
|
|
1107
1107
|
this.noCache = false;
|
|
1108
1108
|
this.preview = false;
|
|
1109
|
+
/**
|
|
1110
|
+
* Dictates which API endpoint is used when fetching content. Allows `'content'` and `'query'`.
|
|
1111
|
+
* Defaults to `'query'`.
|
|
1112
|
+
*/
|
|
1113
|
+
this.apiEndpoint$ = new BehaviorSubject('query');
|
|
1109
1114
|
this.apiVersion$ = new BehaviorSubject(undefined);
|
|
1110
1115
|
this.canTrack$ = new BehaviorSubject(!this.browserTrackingDisabled);
|
|
1111
1116
|
this.apiKey$ = new BehaviorSubject(null);
|
|
@@ -1359,8 +1364,14 @@ var Builder = /** @class */ (function () {
|
|
|
1359
1364
|
// 2. `name(args) => {code}`
|
|
1360
1365
|
// 3. `(args) => {}`
|
|
1361
1366
|
// 4. `args => {}`
|
|
1367
|
+
// 5. `async function(args) {code}`
|
|
1368
|
+
// 6. `async (args) => {}`
|
|
1369
|
+
// 7. `async args => {}`
|
|
1362
1370
|
var isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
1363
|
-
var appendFunction = !fnStr.startsWith('function') &&
|
|
1371
|
+
var appendFunction = !fnStr.startsWith('function') &&
|
|
1372
|
+
!fnStr.startsWith('async') &&
|
|
1373
|
+
!fnStr.startsWith('(') &&
|
|
1374
|
+
!isArrowWithoutParens;
|
|
1364
1375
|
return "return (".concat(appendFunction ? 'function ' : '').concat(fnStr, ").apply(this, arguments)");
|
|
1365
1376
|
};
|
|
1366
1377
|
return JSON.parse(JSON.stringify(info, function (key, value) {
|
|
@@ -1492,6 +1503,18 @@ var Builder = /** @class */ (function () {
|
|
|
1492
1503
|
enumerable: false,
|
|
1493
1504
|
configurable: true
|
|
1494
1505
|
});
|
|
1506
|
+
Object.defineProperty(Builder.prototype, "apiEndpoint", {
|
|
1507
|
+
get: function () {
|
|
1508
|
+
return this.apiEndpoint$.value;
|
|
1509
|
+
},
|
|
1510
|
+
set: function (apiEndpoint) {
|
|
1511
|
+
if (this.apiEndpoint !== apiEndpoint) {
|
|
1512
|
+
this.apiEndpoint$.next(apiEndpoint);
|
|
1513
|
+
}
|
|
1514
|
+
},
|
|
1515
|
+
enumerable: false,
|
|
1516
|
+
configurable: true
|
|
1517
|
+
});
|
|
1495
1518
|
Object.defineProperty(Builder.prototype, "editingMode", {
|
|
1496
1519
|
get: function () {
|
|
1497
1520
|
return this.editingMode$.value;
|
|
@@ -2130,12 +2153,16 @@ var Builder = /** @class */ (function () {
|
|
|
2130
2153
|
if (options === void 0) { options = {}; }
|
|
2131
2154
|
var instance = this;
|
|
2132
2155
|
var finalLocale = options.locale || ((_a = options.userAttributes) === null || _a === void 0 ? void 0 : _a.locale) || this.getUserAttributes().locale;
|
|
2156
|
+
if (!('noTraverse' in options)) {
|
|
2157
|
+
options.noTraverse = false;
|
|
2158
|
+
}
|
|
2133
2159
|
var finalOptions = tslib.__assign(tslib.__assign({}, options), (finalLocale && {
|
|
2134
2160
|
locale: String(finalLocale),
|
|
2135
2161
|
userAttributes: tslib.__assign({ locale: String(finalLocale) }, options.userAttributes),
|
|
2136
2162
|
}));
|
|
2137
2163
|
if (!Builder.isBrowser) {
|
|
2138
2164
|
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken, options.apiVersion || this.apiVersion);
|
|
2165
|
+
instance.apiEndpoint = this.apiEndpoint;
|
|
2139
2166
|
instance.setUserAttributes(this.getUserAttributes());
|
|
2140
2167
|
}
|
|
2141
2168
|
else {
|
|
@@ -2335,7 +2362,6 @@ var Builder = /** @class */ (function () {
|
|
|
2335
2362
|
return;
|
|
2336
2363
|
}
|
|
2337
2364
|
var queue = useQueue || (usePastQueue ? this.priorContentQueue : this.getContentQueue) || [];
|
|
2338
|
-
var apiEndpoint = queue[0].apiEndpoint || 'query';
|
|
2339
2365
|
// TODO: do this on every request send?
|
|
2340
2366
|
this.getOverridesFromQueryString();
|
|
2341
2367
|
var queryParams = tslib.__assign(tslib.__assign({
|
|
@@ -2429,6 +2455,9 @@ var Builder = /** @class */ (function () {
|
|
|
2429
2455
|
if (isPositiveNumber(options.staleCacheSeconds)) {
|
|
2430
2456
|
queryParams.staleCacheSeconds = options.staleCacheSeconds;
|
|
2431
2457
|
}
|
|
2458
|
+
if (this.apiEndpoint === 'content') {
|
|
2459
|
+
queryParams.includeRefs = true;
|
|
2460
|
+
}
|
|
2432
2461
|
var properties = [
|
|
2433
2462
|
'prerender',
|
|
2434
2463
|
'extractCss',
|
|
@@ -2440,12 +2469,13 @@ var Builder = /** @class */ (function () {
|
|
|
2440
2469
|
'entry',
|
|
2441
2470
|
'rev',
|
|
2442
2471
|
'static',
|
|
2472
|
+
'includeRefs',
|
|
2443
2473
|
];
|
|
2444
2474
|
for (var _a = 0, properties_1 = properties; _a < properties_1.length; _a++) {
|
|
2445
2475
|
var key = properties_1[_a];
|
|
2446
2476
|
var value = options[key];
|
|
2447
2477
|
if (value !== undefined) {
|
|
2448
|
-
if (apiEndpoint === 'query') {
|
|
2478
|
+
if (this.apiEndpoint === 'query') {
|
|
2449
2479
|
queryParams.options = queryParams.options || {};
|
|
2450
2480
|
queryParams.options[options.key] = queryParams.options[options.key] || {};
|
|
2451
2481
|
queryParams.options[options.key][key] = JSON.stringify(value);
|
|
@@ -2469,9 +2499,8 @@ var Builder = /** @class */ (function () {
|
|
|
2469
2499
|
}
|
|
2470
2500
|
var format = queryParams.format;
|
|
2471
2501
|
var isApiCallForCodegen = format === 'solid' || format === 'react';
|
|
2472
|
-
var isApiCallForCodegenOrQuery = isApiCallForCodegen || apiEndpoint === 'query';
|
|
2473
|
-
if (apiEndpoint === 'content') {
|
|
2474
|
-
queryParams.enrich = true;
|
|
2502
|
+
var isApiCallForCodegenOrQuery = isApiCallForCodegen || this.apiEndpoint === 'query';
|
|
2503
|
+
if (this.apiEndpoint === 'content') {
|
|
2475
2504
|
if (queue[0].query) {
|
|
2476
2505
|
var flattened = this.flattenMongoQuery({ query: queue[0].query });
|
|
2477
2506
|
for (var key in flattened) {
|
|
@@ -2489,7 +2518,7 @@ var Builder = /** @class */ (function () {
|
|
|
2489
2518
|
if (isApiCallForCodegen) {
|
|
2490
2519
|
url = "".concat(host, "/api/v1/codegen/").concat(this.apiKey, "/").concat(keyNames);
|
|
2491
2520
|
}
|
|
2492
|
-
else if (apiEndpoint === 'query') {
|
|
2521
|
+
else if (this.apiEndpoint === 'query') {
|
|
2493
2522
|
url = "".concat(host, "/api/v3/query/").concat(this.apiKey, "/").concat(keyNames);
|
|
2494
2523
|
}
|
|
2495
2524
|
else {
|