@builder.io/sdk 1.1.34 → 1.1.35
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 +3 -0
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +85 -24
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.esm.js +85 -24
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +96 -35
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +16 -14
- package/dist/src/builder.class.d.ts +842 -837
- package/dist/src/builder.class.js +46 -6
- package/dist/src/builder.class.js.map +1 -1
- package/dist/src/classes/animator.class.d.ts +26 -26
- package/dist/src/classes/cookies.class.d.ts +15 -15
- package/dist/src/classes/observable.class.d.ts +26 -26
- package/dist/src/classes/promise.class.d.ts +17 -17
- package/dist/src/classes/query-string.class.d.ts +9 -9
- package/dist/src/classes/query-string.class.test.d.ts +1 -1
- package/dist/src/constants/builder.d.ts +2 -2
- package/dist/src/functions/assign.function.d.ts +1 -1
- package/dist/src/functions/fetch.function.d.ts +28 -28
- package/dist/src/functions/finder.function.d.ts +10 -10
- package/dist/src/functions/finder.function.js +1 -1
- package/dist/src/functions/get-top-level-domain.d.ts +6 -6
- package/dist/src/functions/next-tick.function.d.ts +1 -1
- package/dist/src/functions/omit.function.d.ts +1 -1
- package/dist/src/functions/server-only-require.function.d.ts +3 -3
- package/dist/src/functions/throttle.function.d.ts +1 -1
- package/dist/src/functions/to-error.d.ts +13 -13
- package/dist/src/functions/uuid.d.ts +8 -8
- package/dist/src/types/api-version.d.ts +2 -0
- package/dist/src/types/api-version.js +5 -0
- package/dist/src/types/api-version.js.map +1 -0
- package/dist/src/types/content.d.ts +31 -31
- package/dist/src/types/element.d.ts +60 -60
- package/dist/src/url.d.ts +9 -9
- package/dist/src/url.test.d.ts +1 -1
- package/dist/src/url.test.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Builder, BuilderComponent, isBrowser, Input, Component, GetContentOptions, Class } from './src/builder.class';
|
|
2
|
-
export { Builder, BuilderComponent, isBrowser, Input, Component, GetContentOptions, Class };
|
|
3
|
-
export { BehaviorSubject, Subscription } from './src/classes/observable.class';
|
|
4
|
-
export { BuilderElement } from './src/types/element';
|
|
5
|
-
export { BuilderContent, BuilderContentVariation } from './src/types/content';
|
|
6
|
-
export {
|
|
1
|
+
import { Builder, BuilderComponent, isBrowser, Input, Component, GetContentOptions, Class } from './src/builder.class';
|
|
2
|
+
export { Builder, BuilderComponent, isBrowser, Input, Component, GetContentOptions, Class };
|
|
3
|
+
export { BehaviorSubject, Subscription } from './src/classes/observable.class';
|
|
4
|
+
export { BuilderElement } from './src/types/element';
|
|
5
|
+
export { BuilderContent, BuilderContentVariation } from './src/types/content';
|
|
6
|
+
export { ApiVersion } from './src/types/api-version';
|
|
7
|
+
export { builder } from './src/constants/builder';
|
package/dist/index.esm.js
CHANGED
|
@@ -42,7 +42,8 @@ function nextTick(fn) {
|
|
|
42
42
|
});
|
|
43
43
|
// tslint:disable-next-line
|
|
44
44
|
element.data = String((called = ++called));
|
|
45
|
-
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=next-tick.function.js.map
|
|
46
47
|
|
|
47
48
|
var PROPERTY_NAME_DENY_LIST = Object.freeze(['__proto__', 'prototype', 'constructor']);
|
|
48
49
|
// TODO: unit tests
|
|
@@ -121,9 +122,10 @@ var QueryString = /** @class */ (function () {
|
|
|
121
122
|
function assertAllowedPropertyName(name) {
|
|
122
123
|
if (PROPERTY_NAME_DENY_LIST.indexOf(name) >= 0)
|
|
123
124
|
throw new Error("Property name \"".concat(name, "\" is not allowed"));
|
|
124
|
-
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=query-string.class.js.map
|
|
125
127
|
|
|
126
|
-
var version = "1.1.
|
|
128
|
+
var version = "1.1.35";
|
|
127
129
|
|
|
128
130
|
var Subscription = /** @class */ (function () {
|
|
129
131
|
function Subscription(listeners, listener) {
|
|
@@ -216,7 +218,8 @@ var BehaviorSubject = /** @class */ (function () {
|
|
|
216
218
|
return this.toPromise();
|
|
217
219
|
};
|
|
218
220
|
return BehaviorSubject;
|
|
219
|
-
}());
|
|
221
|
+
}());
|
|
222
|
+
//# sourceMappingURL=observable.class.js.map
|
|
220
223
|
|
|
221
224
|
var State = {
|
|
222
225
|
Pending: 'Pending',
|
|
@@ -381,7 +384,8 @@ var TinyPromise = /** @class */ (function () {
|
|
|
381
384
|
};
|
|
382
385
|
return TinyPromise;
|
|
383
386
|
}());
|
|
384
|
-
var Promise$1 = (typeof Promise !== 'undefined' ? Promise : TinyPromise);
|
|
387
|
+
var Promise$1 = (typeof Promise !== 'undefined' ? Promise : TinyPromise);
|
|
388
|
+
//# sourceMappingURL=promise.class.js.map
|
|
385
389
|
|
|
386
390
|
// Webpack workaround to conditionally require certain external modules
|
|
387
391
|
// only on the server and not bundle them on the client
|
|
@@ -394,7 +398,8 @@ catch (err) {
|
|
|
394
398
|
// all good
|
|
395
399
|
serverOnlyRequire = (function () { return null; });
|
|
396
400
|
}
|
|
397
|
-
var serverOnlyRequire$1 = serverOnlyRequire;
|
|
401
|
+
var serverOnlyRequire$1 = serverOnlyRequire;
|
|
402
|
+
//# sourceMappingURL=server-only-require.function.js.map
|
|
398
403
|
|
|
399
404
|
function promiseResolve(value) {
|
|
400
405
|
return new Promise$1(function (resolve) { return resolve(value); });
|
|
@@ -470,7 +475,8 @@ function getFetch() {
|
|
|
470
475
|
}
|
|
471
476
|
// Otherwise, use tiny-fetch.
|
|
472
477
|
return _fetch !== null && _fetch !== void 0 ? _fetch : tinyFetch;
|
|
473
|
-
}
|
|
478
|
+
}
|
|
479
|
+
//# sourceMappingURL=fetch.function.js.map
|
|
474
480
|
|
|
475
481
|
function assign(target) {
|
|
476
482
|
var args = [];
|
|
@@ -491,7 +497,8 @@ function assign(target) {
|
|
|
491
497
|
}
|
|
492
498
|
}
|
|
493
499
|
return to;
|
|
494
|
-
}
|
|
500
|
+
}
|
|
501
|
+
//# sourceMappingURL=assign.function.js.map
|
|
495
502
|
|
|
496
503
|
function throttle(func, wait, options) {
|
|
497
504
|
if (options === void 0) { options = {}; }
|
|
@@ -529,7 +536,8 @@ function throttle(func, wait, options) {
|
|
|
529
536
|
}
|
|
530
537
|
return result;
|
|
531
538
|
};
|
|
532
|
-
}
|
|
539
|
+
}
|
|
540
|
+
//# sourceMappingURL=throttle.function.js.map
|
|
533
541
|
|
|
534
542
|
var camelCaseToKebabCase = function (str) {
|
|
535
543
|
return str ? str.replace(/([A-Z])/g, function (g) { return "-".concat(g[0].toLowerCase()); }) : '';
|
|
@@ -731,7 +739,8 @@ var Animator = /** @class */ (function () {
|
|
|
731
739
|
});
|
|
732
740
|
};
|
|
733
741
|
return Animator;
|
|
734
|
-
}());
|
|
742
|
+
}());
|
|
743
|
+
//# sourceMappingURL=animator.class.js.map
|
|
735
744
|
|
|
736
745
|
/**
|
|
737
746
|
* Only gets one level up from hostname
|
|
@@ -744,7 +753,8 @@ function getTopLevelDomain(host) {
|
|
|
744
753
|
return parts.slice(1).join('.');
|
|
745
754
|
}
|
|
746
755
|
return host;
|
|
747
|
-
}
|
|
756
|
+
}
|
|
757
|
+
//# sourceMappingURL=get-top-level-domain.js.map
|
|
748
758
|
|
|
749
759
|
/**
|
|
750
760
|
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
@@ -868,7 +878,8 @@ function pushCookie(headers, cookie) {
|
|
|
868
878
|
}
|
|
869
879
|
}
|
|
870
880
|
headers.push(cookie.toHeader());
|
|
871
|
-
}
|
|
881
|
+
}
|
|
882
|
+
//# sourceMappingURL=cookies.class.js.map
|
|
872
883
|
|
|
873
884
|
function omit(obj) {
|
|
874
885
|
var values = [];
|
|
@@ -881,7 +892,8 @@ function omit(obj) {
|
|
|
881
892
|
delete newObject[key];
|
|
882
893
|
}
|
|
883
894
|
return newObject;
|
|
884
|
-
}
|
|
895
|
+
}
|
|
896
|
+
//# sourceMappingURL=omit.function.js.map
|
|
885
897
|
|
|
886
898
|
/**
|
|
887
899
|
* @credit https://stackoverflow.com/a/2117523
|
|
@@ -897,7 +909,8 @@ function uuidv4() {
|
|
|
897
909
|
*/
|
|
898
910
|
function uuid() {
|
|
899
911
|
return uuidv4().replace(/-/g, '');
|
|
900
|
-
}
|
|
912
|
+
}
|
|
913
|
+
//# sourceMappingURL=uuid.js.map
|
|
901
914
|
|
|
902
915
|
function emptyUrl() {
|
|
903
916
|
return {
|
|
@@ -943,7 +956,8 @@ function parse(url) {
|
|
|
943
956
|
out.path = "".concat(u.pathname).concat(u.search);
|
|
944
957
|
out.pathname = u.pathname;
|
|
945
958
|
return out;
|
|
946
|
-
}
|
|
959
|
+
}
|
|
960
|
+
//# sourceMappingURL=url.js.map
|
|
947
961
|
|
|
948
962
|
/**
|
|
949
963
|
* Safe conversion to error type. Intended to be used in catch blocks where the
|
|
@@ -961,7 +975,11 @@ function toError(err) {
|
|
|
961
975
|
if (err instanceof Error)
|
|
962
976
|
return err;
|
|
963
977
|
return new Error(String(err));
|
|
964
|
-
}
|
|
978
|
+
}
|
|
979
|
+
//# sourceMappingURL=to-error.js.map
|
|
980
|
+
|
|
981
|
+
var DEFAULT_API_VERSION = 'v1';
|
|
982
|
+
//# sourceMappingURL=api-version.js.map
|
|
965
983
|
|
|
966
984
|
function datePlusMinutes(minutes) {
|
|
967
985
|
if (minutes === void 0) { minutes = 30; }
|
|
@@ -1085,7 +1103,7 @@ function BuilderComponent(info) {
|
|
|
1085
1103
|
return Builder.Component(info);
|
|
1086
1104
|
}
|
|
1087
1105
|
var Builder = /** @class */ (function () {
|
|
1088
|
-
function Builder(apiKey, request, response, forceNewInstance, authToken) {
|
|
1106
|
+
function Builder(apiKey, request, response, forceNewInstance, authToken, apiVersion) {
|
|
1089
1107
|
if (apiKey === void 0) { apiKey = null; }
|
|
1090
1108
|
if (forceNewInstance === void 0) { forceNewInstance = false; }
|
|
1091
1109
|
if (authToken === void 0) { authToken = null; }
|
|
@@ -1110,6 +1128,7 @@ var Builder = /** @class */ (function () {
|
|
|
1110
1128
|
this.overrideParams = '';
|
|
1111
1129
|
this.noCache = false;
|
|
1112
1130
|
this.preview = false;
|
|
1131
|
+
this.apiVersion$ = new BehaviorSubject(undefined);
|
|
1113
1132
|
this.canTrack$ = new BehaviorSubject(!this.browserTrackingDisabled);
|
|
1114
1133
|
this.apiKey$ = new BehaviorSubject(null);
|
|
1115
1134
|
this.authToken$ = new BehaviorSubject(null);
|
|
@@ -1149,6 +1168,9 @@ var Builder = /** @class */ (function () {
|
|
|
1149
1168
|
if (apiKey) {
|
|
1150
1169
|
this.apiKey = apiKey;
|
|
1151
1170
|
}
|
|
1171
|
+
if (apiVersion) {
|
|
1172
|
+
this.apiVersion = apiVersion;
|
|
1173
|
+
}
|
|
1152
1174
|
if (authToken) {
|
|
1153
1175
|
this.authToken = authToken;
|
|
1154
1176
|
}
|
|
@@ -1457,6 +1479,18 @@ var Builder = /** @class */ (function () {
|
|
|
1457
1479
|
enumerable: false,
|
|
1458
1480
|
configurable: true
|
|
1459
1481
|
});
|
|
1482
|
+
Object.defineProperty(Builder.prototype, "apiVersion", {
|
|
1483
|
+
get: function () {
|
|
1484
|
+
return this.apiVersion$.value;
|
|
1485
|
+
},
|
|
1486
|
+
set: function (apiVersion) {
|
|
1487
|
+
if (this.apiVersion !== apiVersion) {
|
|
1488
|
+
this.apiVersion$.next(apiVersion);
|
|
1489
|
+
}
|
|
1490
|
+
},
|
|
1491
|
+
enumerable: false,
|
|
1492
|
+
configurable: true
|
|
1493
|
+
});
|
|
1460
1494
|
Object.defineProperty(Builder.prototype, "editingMode", {
|
|
1461
1495
|
get: function () {
|
|
1462
1496
|
return this.editingMode$.value;
|
|
@@ -1988,7 +2022,7 @@ var Builder = /** @class */ (function () {
|
|
|
1988
2022
|
enumerable: false,
|
|
1989
2023
|
configurable: true
|
|
1990
2024
|
});
|
|
1991
|
-
Builder.prototype.init = function (apiKey, canTrack, req, res, authToken) {
|
|
2025
|
+
Builder.prototype.init = function (apiKey, canTrack, req, res, authToken, apiVersion) {
|
|
1992
2026
|
if (canTrack === void 0) { canTrack = this.defaultCanTrack; }
|
|
1993
2027
|
if (req) {
|
|
1994
2028
|
this.request = req;
|
|
@@ -2001,6 +2035,9 @@ var Builder = /** @class */ (function () {
|
|
|
2001
2035
|
if (authToken) {
|
|
2002
2036
|
this.authToken = authToken;
|
|
2003
2037
|
}
|
|
2038
|
+
if (apiVersion) {
|
|
2039
|
+
this.apiVersion = apiVersion;
|
|
2040
|
+
}
|
|
2004
2041
|
return this;
|
|
2005
2042
|
};
|
|
2006
2043
|
Object.defineProperty(Builder.prototype, "previewingModel", {
|
|
@@ -2083,16 +2120,21 @@ var Builder = /** @class */ (function () {
|
|
|
2083
2120
|
if (options === void 0) { options = {}; }
|
|
2084
2121
|
var instance = this;
|
|
2085
2122
|
if (!Builder.isBrowser) {
|
|
2086
|
-
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken);
|
|
2123
|
+
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken, options.apiVersion || this.apiVersion);
|
|
2087
2124
|
instance.setUserAttributes(this.getUserAttributes());
|
|
2088
2125
|
}
|
|
2089
2126
|
else {
|
|
2127
|
+
// NOTE: All these are when .init is not called and the customer
|
|
2128
|
+
// directly calls .get on the singleton instance of Builder
|
|
2090
2129
|
if (options.apiKey && !this.apiKey) {
|
|
2091
2130
|
this.apiKey = options.apiKey;
|
|
2092
2131
|
}
|
|
2093
2132
|
if (options.authToken && !this.authToken) {
|
|
2094
2133
|
this.authToken = options.authToken;
|
|
2095
2134
|
}
|
|
2135
|
+
if (options.apiVersion && !this.apiVersion) {
|
|
2136
|
+
this.apiVersion = options.apiVersion;
|
|
2137
|
+
}
|
|
2096
2138
|
}
|
|
2097
2139
|
return instance.queueGetContent(modelName, options).map(
|
|
2098
2140
|
/* map( */ function (matches) {
|
|
@@ -2233,6 +2275,14 @@ var Builder = /** @class */ (function () {
|
|
|
2233
2275
|
if (!this.apiKey) {
|
|
2234
2276
|
throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
|
|
2235
2277
|
}
|
|
2278
|
+
if (this.apiVersion) {
|
|
2279
|
+
if (!['v1', 'v3'].includes(this.apiVersion)) {
|
|
2280
|
+
throw new Error("Invalid apiVersion: expected 'v1' or 'v3', received '".concat(this.apiVersion, "'"));
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
else {
|
|
2284
|
+
this.apiVersion = DEFAULT_API_VERSION;
|
|
2285
|
+
}
|
|
2236
2286
|
if (!usePastQueue && !this.getContentQueue) {
|
|
2237
2287
|
return;
|
|
2238
2288
|
}
|
|
@@ -2362,7 +2412,9 @@ var Builder = /** @class */ (function () {
|
|
|
2362
2412
|
requestOptions.headers = __assign(__assign({}, requestOptions.headers), { Authorization: "Bearer ".concat(this.authToken) });
|
|
2363
2413
|
}
|
|
2364
2414
|
var fn = format === 'solid' || format === 'react' ? 'codegen' : 'query';
|
|
2365
|
-
|
|
2415
|
+
// NOTE: this is a hack to get around the fact that the codegen endpoint is not yet available in v3
|
|
2416
|
+
var apiVersionBasedOnFn = fn === 'query' ? this.apiVersion : 'v1';
|
|
2417
|
+
var url = "".concat(host, "/api/").concat(apiVersionBasedOnFn, "/").concat(fn, "/").concat(this.apiKey, "/").concat(keyNames) +
|
|
2366
2418
|
(queryParams && hasParams ? "?".concat(queryStr) : '');
|
|
2367
2419
|
var promise = getFetch()(url, requestOptions)
|
|
2368
2420
|
.then(function (res) { return res.json(); })
|
|
@@ -2492,17 +2544,22 @@ var Builder = /** @class */ (function () {
|
|
|
2492
2544
|
if (options === void 0) { options = {}; }
|
|
2493
2545
|
var instance = this;
|
|
2494
2546
|
if (!Builder.isBrowser) {
|
|
2495
|
-
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res);
|
|
2547
|
+
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, false, null, options.apiVersion);
|
|
2496
2548
|
instance.setUserAttributes(this.getUserAttributes());
|
|
2497
2549
|
}
|
|
2498
2550
|
else {
|
|
2551
|
+
// NOTE: All these are when .init is not called and the customer
|
|
2552
|
+
// directly calls .get on the singleton instance of Builder
|
|
2499
2553
|
if (options.apiKey && !this.apiKey) {
|
|
2500
2554
|
this.apiKey = options.apiKey;
|
|
2501
2555
|
}
|
|
2556
|
+
if (options.apiVersion && !this.apiVersion) {
|
|
2557
|
+
this.apiVersion = options.apiVersion;
|
|
2558
|
+
}
|
|
2502
2559
|
}
|
|
2503
2560
|
return instance
|
|
2504
2561
|
.getContent(modelName, __assign(__assign({ limit: 30 }, options), { key: options.key ||
|
|
2505
|
-
// Make the key include all options so we don't reuse cache for the same
|
|
2562
|
+
// Make the key include all options, so we don't reuse cache for the same content fetched
|
|
2506
2563
|
// with different options
|
|
2507
2564
|
Builder.isBrowser
|
|
2508
2565
|
? "".concat(modelName, ":").concat(hash(omit(options, 'initialContent', 'req', 'res')))
|
|
@@ -2552,10 +2609,14 @@ var Builder = /** @class */ (function () {
|
|
|
2552
2609
|
Builder.isReact = false;
|
|
2553
2610
|
Builder.overrideUserAttributes = {};
|
|
2554
2611
|
return Builder;
|
|
2555
|
-
}());
|
|
2612
|
+
}());
|
|
2613
|
+
//# sourceMappingURL=builder.class.js.map
|
|
2556
2614
|
|
|
2557
2615
|
var builder = new Builder(null, undefined, undefined, true);
|
|
2558
|
-
Builder.singletonInstance = builder;
|
|
2616
|
+
Builder.singletonInstance = builder;
|
|
2617
|
+
//# sourceMappingURL=builder.js.map
|
|
2618
|
+
|
|
2619
|
+
//# sourceMappingURL=index.js.map
|
|
2559
2620
|
|
|
2560
2621
|
export { Builder, BuilderComponent, isBrowser, BehaviorSubject, Subscription, builder };
|
|
2561
2622
|
//# sourceMappingURL=index.esm.js.map
|