@builder.io/sdk 1.1.27-0 → 1.1.27-3
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 +6 -0
- package/README.md +5 -4
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +61 -56
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +61 -56
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +61 -56
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +9 -2
- package/dist/src/builder.class.d.ts +203 -18
- package/dist/src/builder.class.js +63 -57
- package/dist/src/builder.class.js.map +1 -1
- package/dist/src/classes/animator.class.js +13 -12
- package/dist/src/classes/animator.class.js.map +1 -1
- package/dist/src/classes/cookies.class.js +8 -8
- package/dist/src/classes/cookies.class.js.map +1 -1
- package/dist/src/classes/observable.class.js +2 -1
- package/dist/src/classes/observable.class.js.map +1 -1
- package/dist/src/classes/promise.class.js +5 -4
- package/dist/src/classes/promise.class.js.map +1 -1
- package/dist/src/classes/query-string.class.js +2 -1
- package/dist/src/classes/query-string.class.js.map +1 -1
- package/dist/src/constants/builder.js +1 -0
- package/dist/src/constants/builder.js.map +1 -1
- package/dist/src/functions/assign.function.js +1 -0
- package/dist/src/functions/assign.function.js.map +1 -1
- package/dist/src/functions/fetch.function.js +3 -2
- package/dist/src/functions/fetch.function.js.map +1 -1
- package/dist/src/functions/finder.function.js +13 -11
- package/dist/src/functions/finder.function.js.map +1 -1
- package/dist/src/functions/get-top-level-domain.js +1 -0
- package/dist/src/functions/get-top-level-domain.js.map +1 -1
- package/dist/src/functions/next-tick.function.js +1 -0
- package/dist/src/functions/next-tick.function.js.map +1 -1
- package/dist/src/functions/omit.function.js +1 -0
- package/dist/src/functions/omit.function.js.map +1 -1
- package/dist/src/functions/throttle.function.js +1 -0
- package/dist/src/functions/throttle.function.js.map +1 -1
- package/dist/src/functions/uuid.js +1 -0
- package/dist/src/functions/uuid.js.map +1 -1
- package/dist/src/types/element.d.ts +4 -2
- package/docs/interfaces/Component.md +267 -0
- package/docs/interfaces/GetContentOptions.md +396 -0
- package/docs/interfaces/Input.md +232 -0
- package/docs/interfaces/InsertMenuConfig.md +83 -0
- package/docs/interfaces/InsertMenuItem.md +39 -0
- package/docs/interfaces/ParamsMap.md +5 -0
- package/docs/interfaces/UserAttributes.md +25 -0
- package/jest.config.ts +4 -4
- package/package.json +9 -2
- package/scripts/cleanup-generated-docs.js +18 -0
- package/typedoc.js +5 -0
- package/BUILD +0 -19
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Builder = exports.BuilderComponent = exports.isIframe = exports.isBrowser = exports.validEnvList = exports.isReactNative = void 0;
|
|
17
18
|
require("./polyfills/custom-event-polyfill");
|
|
18
19
|
var next_tick_function_1 = require("./functions/next-tick.function");
|
|
19
20
|
var query_string_class_1 = require("./classes/query-string.class");
|
|
@@ -85,7 +86,7 @@ var parse = exports.isReactNative
|
|
|
85
86
|
? function () { return ({}); }
|
|
86
87
|
: typeof window === 'object'
|
|
87
88
|
? urlParser.parse
|
|
88
|
-
: server_only_require_function_1.default('url').parse;
|
|
89
|
+
: (0, server_only_require_function_1.default)('url').parse;
|
|
89
90
|
function setCookie(name, value, expires) {
|
|
90
91
|
try {
|
|
91
92
|
var expiresString = '';
|
|
@@ -100,7 +101,7 @@ function setCookie(name, value, expires) {
|
|
|
100
101
|
(value || '') +
|
|
101
102
|
expiresString +
|
|
102
103
|
'; path=/' +
|
|
103
|
-
|
|
104
|
+
"; domain=".concat((0, get_top_level_domain_1.getTopLevelDomain)(location.hostname)) +
|
|
104
105
|
(secure ? ';secure ; SameSite=None' : '');
|
|
105
106
|
}
|
|
106
107
|
catch (err) {
|
|
@@ -143,14 +144,14 @@ function BuilderComponent(info) {
|
|
|
143
144
|
exports.BuilderComponent = BuilderComponent;
|
|
144
145
|
var Builder = /** @class */ (function () {
|
|
145
146
|
function Builder(apiKey, request, response, forceNewInstance, authToken) {
|
|
146
|
-
var _this = this;
|
|
147
147
|
if (apiKey === void 0) { apiKey = null; }
|
|
148
148
|
if (forceNewInstance === void 0) { forceNewInstance = false; }
|
|
149
149
|
if (authToken === void 0) { authToken = null; }
|
|
150
|
+
var _this = this;
|
|
150
151
|
this.request = request;
|
|
151
152
|
this.response = response;
|
|
152
153
|
this.eventsQueue = [];
|
|
153
|
-
this.throttledClearEventsQueue = throttle_function_1.throttle(function () {
|
|
154
|
+
this.throttledClearEventsQueue = (0, throttle_function_1.throttle)(function () {
|
|
154
155
|
_this.processEventsQueue();
|
|
155
156
|
// Extend the session cookie
|
|
156
157
|
_this.setCookie(sessionStorageKey, _this.sessionId, datePlusMinutes(30));
|
|
@@ -287,7 +288,7 @@ var Builder = /** @class */ (function () {
|
|
|
287
288
|
if (Builder.isBrowser) {
|
|
288
289
|
window.postMessage({
|
|
289
290
|
type: 'builder.registerEditor',
|
|
290
|
-
data: omit_function_1.omit(info, 'component'),
|
|
291
|
+
data: (0, omit_function_1.omit)(info, 'component'),
|
|
291
292
|
}, '*');
|
|
292
293
|
var hostname = location.hostname;
|
|
293
294
|
if (!Builder.isTrustedHost(hostname)) {
|
|
@@ -306,13 +307,13 @@ var Builder = /** @class */ (function () {
|
|
|
306
307
|
this.trustedHosts.push(host);
|
|
307
308
|
};
|
|
308
309
|
Builder.isTrustedHost = function (hostname) {
|
|
309
|
-
return (this.trustedHosts.findIndex(function (trustedHost) { return trustedHost === hostname || hostname.endsWith("."
|
|
310
|
+
return (this.trustedHosts.findIndex(function (trustedHost) { return trustedHost === hostname || hostname.endsWith(".".concat(trustedHost)); }) > -1);
|
|
310
311
|
};
|
|
311
312
|
Builder.runAction = function (action) {
|
|
312
313
|
// TODO
|
|
313
314
|
var actionObject = typeof action === 'string' ? find(this.actions, function (item) { return item.name === action; }) : action;
|
|
314
315
|
if (!actionObject) {
|
|
315
|
-
throw new Error("Action not found: "
|
|
316
|
+
throw new Error("Action not found: ".concat(action));
|
|
316
317
|
}
|
|
317
318
|
};
|
|
318
319
|
Builder.fields = function (name, fields) {
|
|
@@ -322,17 +323,14 @@ var Builder = /** @class */ (function () {
|
|
|
322
323
|
data: { name: name, fields: fields },
|
|
323
324
|
}, '*');
|
|
324
325
|
};
|
|
326
|
+
/**
|
|
327
|
+
* @deprecated
|
|
328
|
+
* @hidden
|
|
329
|
+
*
|
|
330
|
+
* Use Builder.register('editor.settings', {}) instead.
|
|
331
|
+
*/
|
|
325
332
|
Builder.set = function (settings) {
|
|
326
|
-
|
|
327
|
-
// TODO: merge
|
|
328
|
-
Object.assign(this.settings, settings);
|
|
329
|
-
var message = {
|
|
330
|
-
type: 'builder.settingsChange',
|
|
331
|
-
data: this.settings,
|
|
332
|
-
};
|
|
333
|
-
parent.postMessage(message, '*');
|
|
334
|
-
}
|
|
335
|
-
this.settingsChange.next(this.settings);
|
|
333
|
+
Builder.register('editor.settings', settings);
|
|
336
334
|
};
|
|
337
335
|
Builder.import = function (packageName) {
|
|
338
336
|
if (!Builder.isBrowser) {
|
|
@@ -345,7 +343,7 @@ var Builder = /** @class */ (function () {
|
|
|
345
343
|
console.warn('System.js not available. Please include System.js when using Builder.import');
|
|
346
344
|
return;
|
|
347
345
|
}
|
|
348
|
-
return System.import("https://cdn.builder.io/systemjs/"
|
|
346
|
+
return System.import("https://cdn.builder.io/systemjs/".concat(packageName));
|
|
349
347
|
};
|
|
350
348
|
Object.defineProperty(Builder, "editingPage", {
|
|
351
349
|
// useCdnApi = false;
|
|
@@ -363,7 +361,7 @@ var Builder = /** @class */ (function () {
|
|
|
363
361
|
}
|
|
364
362
|
}
|
|
365
363
|
},
|
|
366
|
-
enumerable:
|
|
364
|
+
enumerable: false,
|
|
367
365
|
configurable: true
|
|
368
366
|
});
|
|
369
367
|
Builder.prepareComponentSpecToSend = function (spec) {
|
|
@@ -378,7 +376,7 @@ var Builder = /** @class */ (function () {
|
|
|
378
376
|
var key = keysToConvertFnToString_1[_i];
|
|
379
377
|
if (input[key] && typeof input[key] === 'function') {
|
|
380
378
|
var fn = input[key];
|
|
381
|
-
input = __assign(__assign({}, input), (_a = {}, _a[key] = "return ("
|
|
379
|
+
input = __assign(__assign({}, input), (_a = {}, _a[key] = "return (".concat(fn.toString(), ").apply(this, arguments)"), _a));
|
|
382
380
|
}
|
|
383
381
|
}
|
|
384
382
|
return input;
|
|
@@ -392,7 +390,7 @@ var Builder = /** @class */ (function () {
|
|
|
392
390
|
memo[key] = value;
|
|
393
391
|
}
|
|
394
392
|
else {
|
|
395
|
-
memo[key] = "return ("
|
|
393
|
+
memo[key] = "return (".concat(value.toString(), ").apply(this, arguments)");
|
|
396
394
|
}
|
|
397
395
|
return memo;
|
|
398
396
|
}, {}), class: undefined });
|
|
@@ -455,7 +453,7 @@ var Builder = /** @class */ (function () {
|
|
|
455
453
|
get: function () {
|
|
456
454
|
return this.component;
|
|
457
455
|
},
|
|
458
|
-
enumerable:
|
|
456
|
+
enumerable: false,
|
|
459
457
|
configurable: true
|
|
460
458
|
});
|
|
461
459
|
Builder.prototype.processEventsQueue = function () {
|
|
@@ -476,7 +474,7 @@ var Builder = /** @class */ (function () {
|
|
|
476
474
|
Object.assign(event_1.data.metadata.user, fullUserAttributes, event_1.data.metadata.user);
|
|
477
475
|
}
|
|
478
476
|
var host = this.host;
|
|
479
|
-
fetch_function_1.fetch(host
|
|
477
|
+
(0, fetch_function_1.fetch)("".concat(host, "/api/v1/track"), {
|
|
480
478
|
method: 'POST',
|
|
481
479
|
body: JSON.stringify({ events: events }),
|
|
482
480
|
headers: {
|
|
@@ -489,9 +487,9 @@ var Builder = /** @class */ (function () {
|
|
|
489
487
|
};
|
|
490
488
|
Object.defineProperty(Builder.prototype, "browserTrackingDisabled", {
|
|
491
489
|
get: function () {
|
|
492
|
-
return
|
|
490
|
+
return Builder.isBrowser && Boolean(window.builderNoTrack || !navigator.cookieEnabled);
|
|
493
491
|
},
|
|
494
|
-
enumerable:
|
|
492
|
+
enumerable: false,
|
|
495
493
|
configurable: true
|
|
496
494
|
});
|
|
497
495
|
Object.defineProperty(Builder.prototype, "canTrack", {
|
|
@@ -503,7 +501,7 @@ var Builder = /** @class */ (function () {
|
|
|
503
501
|
this.canTrack$.next(canTrack);
|
|
504
502
|
}
|
|
505
503
|
},
|
|
506
|
-
enumerable:
|
|
504
|
+
enumerable: false,
|
|
507
505
|
configurable: true
|
|
508
506
|
});
|
|
509
507
|
Object.defineProperty(Builder.prototype, "editingMode", {
|
|
@@ -515,7 +513,7 @@ var Builder = /** @class */ (function () {
|
|
|
515
513
|
this.editingMode$.next(value);
|
|
516
514
|
}
|
|
517
515
|
},
|
|
518
|
-
enumerable:
|
|
516
|
+
enumerable: false,
|
|
519
517
|
configurable: true
|
|
520
518
|
});
|
|
521
519
|
Object.defineProperty(Builder.prototype, "editingModel", {
|
|
@@ -527,7 +525,7 @@ var Builder = /** @class */ (function () {
|
|
|
527
525
|
this.editingModel$.next(value);
|
|
528
526
|
}
|
|
529
527
|
},
|
|
530
|
-
enumerable:
|
|
528
|
+
enumerable: false,
|
|
531
529
|
configurable: true
|
|
532
530
|
});
|
|
533
531
|
Builder.prototype.findParentElement = function (target, callback, checkElement) {
|
|
@@ -584,7 +582,7 @@ var Builder = /** @class */ (function () {
|
|
|
584
582
|
}
|
|
585
583
|
var eventData = JSON.parse(JSON.stringify({
|
|
586
584
|
type: eventName,
|
|
587
|
-
data: __assign(__assign({}, omit_function_1.omit(properties, 'meta')), { metadata: __assign(__assign({ sdkVersion: Builder.VERSION, url: location.href }, properties.meta), properties.metadata), ownerId: apiKey, userAttributes: this.getUserAttributes(), sessionId: this.sessionId, visitorId: this.visitorId }),
|
|
585
|
+
data: __assign(__assign({}, (0, omit_function_1.omit)(properties, 'meta')), { metadata: __assign(__assign({ sdkVersion: Builder.VERSION, url: location.href }, properties.meta), properties.metadata), ownerId: apiKey, userAttributes: this.getUserAttributes(), sessionId: this.sessionId, visitorId: this.visitorId }),
|
|
588
586
|
}));
|
|
589
587
|
for (var _i = 0, _a = this.trackingHooks; _i < _a.length; _i++) {
|
|
590
588
|
var hook = _a[_i];
|
|
@@ -612,7 +610,7 @@ var Builder = /** @class */ (function () {
|
|
|
612
610
|
// It's ok
|
|
613
611
|
}
|
|
614
612
|
if (!sessionId) {
|
|
615
|
-
sessionId = uuid_1.uuid();
|
|
613
|
+
sessionId = (0, uuid_1.uuid)();
|
|
616
614
|
}
|
|
617
615
|
// Give the app a second to start up and set canTrack to false if needed
|
|
618
616
|
if (Builder.isBrowser) {
|
|
@@ -646,7 +644,7 @@ var Builder = /** @class */ (function () {
|
|
|
646
644
|
// It's ok
|
|
647
645
|
}
|
|
648
646
|
if (!visitorId) {
|
|
649
|
-
visitorId = uuid_1.uuid();
|
|
647
|
+
visitorId = (0, uuid_1.uuid)();
|
|
650
648
|
}
|
|
651
649
|
this.visitorId = visitorId;
|
|
652
650
|
// Give the app a second to start up and set canTrack to false if needed
|
|
@@ -691,7 +689,7 @@ var Builder = /** @class */ (function () {
|
|
|
691
689
|
(Builder.isBrowser && (location.hostname === 'localhost' || location.port !== '')) ||
|
|
692
690
|
this.env !== 'production');
|
|
693
691
|
},
|
|
694
|
-
enumerable:
|
|
692
|
+
enumerable: false,
|
|
695
693
|
configurable: true
|
|
696
694
|
});
|
|
697
695
|
Builder.prototype.trackInteraction = function (contentId, variationId, alreadyTrackedOne, event, context) {
|
|
@@ -756,7 +754,7 @@ var Builder = /** @class */ (function () {
|
|
|
756
754
|
set: function (key) {
|
|
757
755
|
this.apiKey$.next(key);
|
|
758
756
|
},
|
|
759
|
-
enumerable:
|
|
757
|
+
enumerable: false,
|
|
760
758
|
configurable: true
|
|
761
759
|
});
|
|
762
760
|
Object.defineProperty(Builder.prototype, "authToken", {
|
|
@@ -766,7 +764,7 @@ var Builder = /** @class */ (function () {
|
|
|
766
764
|
set: function (token) {
|
|
767
765
|
this.authToken$.next(token);
|
|
768
766
|
},
|
|
769
|
-
enumerable:
|
|
767
|
+
enumerable: false,
|
|
770
768
|
configurable: true
|
|
771
769
|
});
|
|
772
770
|
Builder.prototype.modifySearch = function (search) {
|
|
@@ -966,7 +964,7 @@ var Builder = /** @class */ (function () {
|
|
|
966
964
|
break;
|
|
967
965
|
case 'builder.overrideUserAttributes':
|
|
968
966
|
var userAttributes = data.data;
|
|
969
|
-
assign_function_1.assign(Builder.overrideUserAttributes, userAttributes);
|
|
967
|
+
(0, assign_function_1.assign)(Builder.overrideUserAttributes, userAttributes);
|
|
970
968
|
_this.flushGetContentQueue(true);
|
|
971
969
|
// TODO: refetch too
|
|
972
970
|
break;
|
|
@@ -1030,7 +1028,7 @@ var Builder = /** @class */ (function () {
|
|
|
1030
1028
|
!navigator.userAgent.match(/bot|crawler|spider|robot|crawling|prerender|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|phantom|headless|selenium|puppeteer/i) &&
|
|
1031
1029
|
!this.browserTrackingDisabled);
|
|
1032
1030
|
},
|
|
1033
|
-
enumerable:
|
|
1031
|
+
enumerable: false,
|
|
1034
1032
|
configurable: true
|
|
1035
1033
|
});
|
|
1036
1034
|
Builder.prototype.init = function (apiKey, canTrack, req, res, authToken) {
|
|
@@ -1054,7 +1052,7 @@ var Builder = /** @class */ (function () {
|
|
|
1054
1052
|
var params = query_string_class_1.QueryString.parse((search || '').substr(1));
|
|
1055
1053
|
return params['builder.preview'];
|
|
1056
1054
|
},
|
|
1057
|
-
enumerable:
|
|
1055
|
+
enumerable: false,
|
|
1058
1056
|
configurable: true
|
|
1059
1057
|
});
|
|
1060
1058
|
// TODO: allow adding location object as property and/or in constructor
|
|
@@ -1108,7 +1106,7 @@ var Builder = /** @class */ (function () {
|
|
|
1108
1106
|
device: isTablet ? 'tablet' : isMobile.any() ? 'mobile' : 'desktop' }, Builder.overrideUserAttributes);
|
|
1109
1107
|
};
|
|
1110
1108
|
Builder.prototype.setUserAttributes = function (options) {
|
|
1111
|
-
assign_function_1.assign(Builder.overrideUserAttributes, options);
|
|
1109
|
+
(0, assign_function_1.assign)(Builder.overrideUserAttributes, options);
|
|
1112
1110
|
this.userAttributesChanged.next(options);
|
|
1113
1111
|
};
|
|
1114
1112
|
/**
|
|
@@ -1121,7 +1119,7 @@ var Builder = /** @class */ (function () {
|
|
|
1121
1119
|
* of them to optimize cache efficiency
|
|
1122
1120
|
*/
|
|
1123
1121
|
Builder.prototype.setTrackingUserAttributes = function (attributes) {
|
|
1124
|
-
assign_function_1.assign(this.trackingUserAttributes, attributes);
|
|
1122
|
+
(0, assign_function_1.assign)(this.trackingUserAttributes, attributes);
|
|
1125
1123
|
};
|
|
1126
1124
|
Builder.prototype.get = function (modelName, options) {
|
|
1127
1125
|
if (options === void 0) { options = {}; }
|
|
@@ -1195,7 +1193,7 @@ var Builder = /** @class */ (function () {
|
|
|
1195
1193
|
if (currentObservable && (!currentObservable.value || options.cache)) {
|
|
1196
1194
|
// TODO: test if this ran, otherwise on 404 some observers may never be called...
|
|
1197
1195
|
if (currentObservable.value) {
|
|
1198
|
-
next_tick_function_1.nextTick(function () {
|
|
1196
|
+
(0, next_tick_function_1.nextTick)(function () {
|
|
1199
1197
|
// TODO: return a new observable and only that one fires subscribers, don't refire for existing ones
|
|
1200
1198
|
currentObservable.next(currentObservable.value);
|
|
1201
1199
|
});
|
|
@@ -1215,12 +1213,12 @@ var Builder = /** @class */ (function () {
|
|
|
1215
1213
|
if (this.getContentQueue && this.getContentQueue.length >= this.contentPerRequest) {
|
|
1216
1214
|
var queue_1 = this.getContentQueue.slice();
|
|
1217
1215
|
this.getContentQueue = [];
|
|
1218
|
-
next_tick_function_1.nextTick(function () {
|
|
1216
|
+
(0, next_tick_function_1.nextTick)(function () {
|
|
1219
1217
|
_this.flushGetContentQueue(false, queue_1);
|
|
1220
1218
|
});
|
|
1221
1219
|
}
|
|
1222
1220
|
else {
|
|
1223
|
-
next_tick_function_1.nextTick(function () {
|
|
1221
|
+
(0, next_tick_function_1.nextTick)(function () {
|
|
1224
1222
|
_this.flushGetContentQueue();
|
|
1225
1223
|
});
|
|
1226
1224
|
}
|
|
@@ -1231,7 +1229,7 @@ var Builder = /** @class */ (function () {
|
|
|
1231
1229
|
this.noEditorUpdates[key] = true;
|
|
1232
1230
|
}
|
|
1233
1231
|
if (initialContent) {
|
|
1234
|
-
next_tick_function_1.nextTick(function () {
|
|
1232
|
+
(0, next_tick_function_1.nextTick)(function () {
|
|
1235
1233
|
// TODO: need to testModify this I think...?
|
|
1236
1234
|
observable.next(initialContent);
|
|
1237
1235
|
});
|
|
@@ -1240,11 +1238,11 @@ var Builder = /** @class */ (function () {
|
|
|
1240
1238
|
};
|
|
1241
1239
|
Builder.prototype.requestUrl = function (url, options) {
|
|
1242
1240
|
if (Builder.isBrowser) {
|
|
1243
|
-
return fetch_function_1.fetch(url, options).then(function (res) { return res.json(); });
|
|
1241
|
+
return (0, fetch_function_1.fetch)(url, options).then(function (res) { return res.json(); });
|
|
1244
1242
|
}
|
|
1245
1243
|
return new Promise(function (resolve, reject) {
|
|
1246
1244
|
var parsedUrl = parse(url);
|
|
1247
|
-
var module = parsedUrl.protocol === 'http:' ? server_only_require_function_1.default('http') : server_only_require_function_1.default('https');
|
|
1245
|
+
var module = parsedUrl.protocol === 'http:' ? (0, server_only_require_function_1.default)('http') : (0, server_only_require_function_1.default)('https');
|
|
1248
1246
|
var requestOptions = {
|
|
1249
1247
|
host: parsedUrl.hostname,
|
|
1250
1248
|
port: parsedUrl.port,
|
|
@@ -1266,6 +1264,10 @@ var Builder = /** @class */ (function () {
|
|
|
1266
1264
|
resolve(JSON.parse(data));
|
|
1267
1265
|
}
|
|
1268
1266
|
catch (err) {
|
|
1267
|
+
if ((err === null || err === void 0 ? void 0 : err.name) === 'SyntaxError') {
|
|
1268
|
+
var jsonParseError = new Error("[Builder.io] ERROR: invalid response.\nRequest: ".concat(JSON.stringify(requestOptions, null, 2), "\nResponse Data: ").concat(data, "\n"));
|
|
1269
|
+
reject(jsonParseError);
|
|
1270
|
+
}
|
|
1269
1271
|
reject(err);
|
|
1270
1272
|
}
|
|
1271
1273
|
});
|
|
@@ -1299,14 +1301,14 @@ var Builder = /** @class */ (function () {
|
|
|
1299
1301
|
return Builder.overrideHost || 'https://cdn.builder.io';
|
|
1300
1302
|
}
|
|
1301
1303
|
},
|
|
1302
|
-
enumerable:
|
|
1304
|
+
enumerable: false,
|
|
1303
1305
|
configurable: true
|
|
1304
1306
|
});
|
|
1305
1307
|
Builder.prototype.flushGetContentQueue = function (usePastQueue, useQueue) {
|
|
1306
1308
|
var _this = this;
|
|
1307
1309
|
if (usePastQueue === void 0) { usePastQueue = false; }
|
|
1308
1310
|
if (!this.apiKey) {
|
|
1309
|
-
throw new Error("Fetching content failed, expected apiKey to be defined instead got: "
|
|
1311
|
+
throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
|
|
1310
1312
|
}
|
|
1311
1313
|
if (!usePastQueue && !this.getContentQueue) {
|
|
1312
1314
|
return;
|
|
@@ -1340,7 +1342,7 @@ var Builder = /** @class */ (function () {
|
|
|
1340
1342
|
if (fullUrlQueueItem) {
|
|
1341
1343
|
var location_1 = this.getLocation();
|
|
1342
1344
|
if (location_1.origin) {
|
|
1343
|
-
queryParams.url = ""
|
|
1345
|
+
queryParams.url = "".concat(location_1.origin).concat(location_1.pathname).concat(location_1.search);
|
|
1344
1346
|
}
|
|
1345
1347
|
}
|
|
1346
1348
|
var urlQueueItem = useQueue === null || useQueue === void 0 ? void 0 : useQueue.find(function (item) { return item.url; });
|
|
@@ -1370,7 +1372,7 @@ var Builder = /** @class */ (function () {
|
|
|
1370
1372
|
if (size(this.overrides)) {
|
|
1371
1373
|
for (var key in this.overrides) {
|
|
1372
1374
|
if (this.overrides.hasOwnProperty(key)) {
|
|
1373
|
-
queryParams["overrides."
|
|
1375
|
+
queryParams["overrides.".concat(key)] = this.overrides[key];
|
|
1374
1376
|
}
|
|
1375
1377
|
}
|
|
1376
1378
|
}
|
|
@@ -1427,16 +1429,16 @@ var Builder = /** @class */ (function () {
|
|
|
1427
1429
|
var host = this.host;
|
|
1428
1430
|
var keyNames = queue.map(function (item) { return encodeURIComponent(item.key); }).join(',');
|
|
1429
1431
|
if (this.overrideParams) {
|
|
1430
|
-
var params = omit_function_1.omit(query_string_class_1.QueryString.parse(this.overrideParams), 'apiKey');
|
|
1431
|
-
assign_function_1.assign(queryParams, params);
|
|
1432
|
+
var params = (0, omit_function_1.omit)(query_string_class_1.QueryString.parse(this.overrideParams), 'apiKey');
|
|
1433
|
+
(0, assign_function_1.assign)(queryParams, params);
|
|
1432
1434
|
}
|
|
1433
1435
|
var queryStr = query_string_class_1.QueryString.stringifyDeep(queryParams);
|
|
1434
1436
|
var format = queryParams.format;
|
|
1435
1437
|
var requestOptions = { headers: {} };
|
|
1436
1438
|
if (this.authToken) {
|
|
1437
|
-
requestOptions.headers = __assign(__assign({}, requestOptions.headers), { Authorization: "Bearer "
|
|
1439
|
+
requestOptions.headers = __assign(__assign({}, requestOptions.headers), { Authorization: "Bearer ".concat(this.authToken) });
|
|
1438
1440
|
}
|
|
1439
|
-
var promise = this.requestUrl(host
|
|
1441
|
+
var promise = this.requestUrl("".concat(host, "/api/v1/").concat(format === 'solid' || format === 'react' ? 'codegen' : 'query', "/").concat(this.apiKey, "/").concat(keyNames) + (queryParams && hasParams ? "?".concat(queryStr) : ''), requestOptions).then(function (result) {
|
|
1440
1442
|
for (var _i = 0, queue_3 = queue; _i < queue_3.length; _i++) {
|
|
1441
1443
|
var options = queue_3[_i];
|
|
1442
1444
|
var keyName = options.key;
|
|
@@ -1524,7 +1526,7 @@ var Builder = /** @class */ (function () {
|
|
|
1524
1526
|
return mappedResults;
|
|
1525
1527
|
};
|
|
1526
1528
|
Builder.prototype.getTestCookie = function (contentId) {
|
|
1527
|
-
return this.getCookie(this.testCookiePrefix
|
|
1529
|
+
return this.getCookie("".concat(this.testCookiePrefix, ".").concat(contentId));
|
|
1528
1530
|
};
|
|
1529
1531
|
Builder.prototype.setTestCookie = function (contentId, variationId) {
|
|
1530
1532
|
if (!this.canTrack) {
|
|
@@ -1534,7 +1536,7 @@ var Builder = /** @class */ (function () {
|
|
|
1534
1536
|
// 30 days from now
|
|
1535
1537
|
var future = new Date();
|
|
1536
1538
|
future.setDate(future.getDate() + 30);
|
|
1537
|
-
return this.setCookie(this.testCookiePrefix
|
|
1539
|
+
return this.setCookie("".concat(this.testCookiePrefix, ".").concat(contentId), variationId, future);
|
|
1538
1540
|
};
|
|
1539
1541
|
Builder.prototype.getCookie = function (name) {
|
|
1540
1542
|
if (this.cookies) {
|
|
@@ -1554,7 +1556,7 @@ var Builder = /** @class */ (function () {
|
|
|
1554
1556
|
Builder.prototype.getContent = function (modelName, options) {
|
|
1555
1557
|
if (options === void 0) { options = {}; }
|
|
1556
1558
|
if (!this.apiKey) {
|
|
1557
|
-
throw new Error("Fetching content from model "
|
|
1559
|
+
throw new Error("Fetching content from model ".concat(modelName, " failed, expected apiKey to be defined instead got: ").concat(this.apiKey));
|
|
1558
1560
|
}
|
|
1559
1561
|
return this.queueGetContent(modelName, options);
|
|
1560
1562
|
};
|
|
@@ -1575,10 +1577,14 @@ var Builder = /** @class */ (function () {
|
|
|
1575
1577
|
// Make the key include all options so we don't reuse cache for the same conent fetched
|
|
1576
1578
|
// with different options
|
|
1577
1579
|
Builder.isBrowser
|
|
1578
|
-
? modelName
|
|
1580
|
+
? "".concat(modelName, ":").concat((0, hash_sum_1.default)((0, omit_function_1.omit)(options, 'initialContent', 'req', 'res')))
|
|
1579
1581
|
: undefined }))
|
|
1580
1582
|
.promise();
|
|
1581
1583
|
};
|
|
1584
|
+
/**
|
|
1585
|
+
* @hidden
|
|
1586
|
+
* @deprecated. This is buggy, and always behind by a version.
|
|
1587
|
+
*/
|
|
1582
1588
|
Builder.VERSION = package_json_1.version;
|
|
1583
1589
|
Builder.components = [];
|
|
1584
1590
|
/**
|