@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.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,qDAQ6B;AACpB,wFARP,uBAAO,OAQO;AAAE,iGAPhB,gCAAgB,OAOgB;AAAE,0FANlC,yBAAS,OAMkC;AAE7C,mEAA+E;AAAtE,mHAAA,eAAe,OAAA;AAAE,gHAAA,YAAY,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,qDAQ6B;AACpB,wFARP,uBAAO,OAQO;AAAE,iGAPhB,gCAAgB,OAOgB;AAAE,0FANlC,yBAAS,OAMkC;AAE7C,mEAA+E;AAAtE,mHAAA,eAAe,OAAA;AAAE,gHAAA,YAAY,OAAA;AAMtC,mDAAkD;AAAzC,kGAAA,OAAO,OAAA"}
|
package/dist/index.umd.js
CHANGED
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
(factory((global.BuilderIO = {})));
|
|
5
5
|
}(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
10
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
11
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
16
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
20
|
***************************************************************************** */
|
|
21
21
|
|
|
22
22
|
var __assign = function() {
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
});
|
|
72
72
|
// tslint:disable-next-line
|
|
73
73
|
element.data = String((called = ++called));
|
|
74
|
-
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=next-tick.function.js.map
|
|
75
76
|
|
|
76
77
|
var PROPERTY_NAME_DENY_LIST = Object.freeze(['__proto__', 'prototype', 'constructor']);
|
|
77
78
|
// TODO: unit tests
|
|
@@ -150,9 +151,10 @@
|
|
|
150
151
|
function assertAllowedPropertyName(name) {
|
|
151
152
|
if (PROPERTY_NAME_DENY_LIST.indexOf(name) >= 0)
|
|
152
153
|
throw new Error("Property name \"".concat(name, "\" is not allowed"));
|
|
153
|
-
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=query-string.class.js.map
|
|
154
156
|
|
|
155
|
-
var version = "1.1.
|
|
157
|
+
var version = "1.1.35";
|
|
156
158
|
|
|
157
159
|
var Subscription = /** @class */ (function () {
|
|
158
160
|
function Subscription(listeners, listener) {
|
|
@@ -245,7 +247,8 @@
|
|
|
245
247
|
return this.toPromise();
|
|
246
248
|
};
|
|
247
249
|
return BehaviorSubject;
|
|
248
|
-
}());
|
|
250
|
+
}());
|
|
251
|
+
//# sourceMappingURL=observable.class.js.map
|
|
249
252
|
|
|
250
253
|
var State = {
|
|
251
254
|
Pending: 'Pending',
|
|
@@ -410,7 +413,8 @@
|
|
|
410
413
|
};
|
|
411
414
|
return TinyPromise;
|
|
412
415
|
}());
|
|
413
|
-
var Promise$1 = (typeof Promise !== 'undefined' ? Promise : TinyPromise);
|
|
416
|
+
var Promise$1 = (typeof Promise !== 'undefined' ? Promise : TinyPromise);
|
|
417
|
+
//# sourceMappingURL=promise.class.js.map
|
|
414
418
|
|
|
415
419
|
// Webpack workaround to conditionally require certain external modules
|
|
416
420
|
// only on the server and not bundle them on the client
|
|
@@ -423,7 +427,8 @@
|
|
|
423
427
|
// all good
|
|
424
428
|
serverOnlyRequire = (function () { return null; });
|
|
425
429
|
}
|
|
426
|
-
var serverOnlyRequire$1 = serverOnlyRequire;
|
|
430
|
+
var serverOnlyRequire$1 = serverOnlyRequire;
|
|
431
|
+
//# sourceMappingURL=server-only-require.function.js.map
|
|
427
432
|
|
|
428
433
|
function promiseResolve(value) {
|
|
429
434
|
return new Promise$1(function (resolve) { return resolve(value); });
|
|
@@ -499,7 +504,8 @@
|
|
|
499
504
|
}
|
|
500
505
|
// Otherwise, use tiny-fetch.
|
|
501
506
|
return _fetch !== null && _fetch !== void 0 ? _fetch : tinyFetch;
|
|
502
|
-
}
|
|
507
|
+
}
|
|
508
|
+
//# sourceMappingURL=fetch.function.js.map
|
|
503
509
|
|
|
504
510
|
function assign(target) {
|
|
505
511
|
var args = [];
|
|
@@ -520,7 +526,8 @@
|
|
|
520
526
|
}
|
|
521
527
|
}
|
|
522
528
|
return to;
|
|
523
|
-
}
|
|
529
|
+
}
|
|
530
|
+
//# sourceMappingURL=assign.function.js.map
|
|
524
531
|
|
|
525
532
|
function throttle(func, wait, options) {
|
|
526
533
|
if (options === void 0) { options = {}; }
|
|
@@ -558,7 +565,8 @@
|
|
|
558
565
|
}
|
|
559
566
|
return result;
|
|
560
567
|
};
|
|
561
|
-
}
|
|
568
|
+
}
|
|
569
|
+
//# sourceMappingURL=throttle.function.js.map
|
|
562
570
|
|
|
563
571
|
var camelCaseToKebabCase = function (str) {
|
|
564
572
|
return str ? str.replace(/([A-Z])/g, function (g) { return "-".concat(g[0].toLowerCase()); }) : '';
|
|
@@ -760,7 +768,8 @@
|
|
|
760
768
|
});
|
|
761
769
|
};
|
|
762
770
|
return Animator;
|
|
763
|
-
}());
|
|
771
|
+
}());
|
|
772
|
+
//# sourceMappingURL=animator.class.js.map
|
|
764
773
|
|
|
765
774
|
/**
|
|
766
775
|
* Only gets one level up from hostname
|
|
@@ -773,7 +782,8 @@
|
|
|
773
782
|
return parts.slice(1).join('.');
|
|
774
783
|
}
|
|
775
784
|
return host;
|
|
776
|
-
}
|
|
785
|
+
}
|
|
786
|
+
//# sourceMappingURL=get-top-level-domain.js.map
|
|
777
787
|
|
|
778
788
|
/**
|
|
779
789
|
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
@@ -897,7 +907,8 @@
|
|
|
897
907
|
}
|
|
898
908
|
}
|
|
899
909
|
headers.push(cookie.toHeader());
|
|
900
|
-
}
|
|
910
|
+
}
|
|
911
|
+
//# sourceMappingURL=cookies.class.js.map
|
|
901
912
|
|
|
902
913
|
function omit(obj) {
|
|
903
914
|
var values = [];
|
|
@@ -910,7 +921,8 @@
|
|
|
910
921
|
delete newObject[key];
|
|
911
922
|
}
|
|
912
923
|
return newObject;
|
|
913
|
-
}
|
|
924
|
+
}
|
|
925
|
+
//# sourceMappingURL=omit.function.js.map
|
|
914
926
|
|
|
915
927
|
/**
|
|
916
928
|
* @credit https://stackoverflow.com/a/2117523
|
|
@@ -926,7 +938,8 @@
|
|
|
926
938
|
*/
|
|
927
939
|
function uuid() {
|
|
928
940
|
return uuidv4().replace(/-/g, '');
|
|
929
|
-
}
|
|
941
|
+
}
|
|
942
|
+
//# sourceMappingURL=uuid.js.map
|
|
930
943
|
|
|
931
944
|
function emptyUrl() {
|
|
932
945
|
return {
|
|
@@ -972,7 +985,8 @@
|
|
|
972
985
|
out.path = "".concat(u.pathname).concat(u.search);
|
|
973
986
|
out.pathname = u.pathname;
|
|
974
987
|
return out;
|
|
975
|
-
}
|
|
988
|
+
}
|
|
989
|
+
//# sourceMappingURL=url.js.map
|
|
976
990
|
|
|
977
991
|
function pad (hash, len) {
|
|
978
992
|
while (hash.length < len) {
|
|
@@ -1058,7 +1072,11 @@
|
|
|
1058
1072
|
if (err instanceof Error)
|
|
1059
1073
|
return err;
|
|
1060
1074
|
return new Error(String(err));
|
|
1061
|
-
}
|
|
1075
|
+
}
|
|
1076
|
+
//# sourceMappingURL=to-error.js.map
|
|
1077
|
+
|
|
1078
|
+
var DEFAULT_API_VERSION = 'v1';
|
|
1079
|
+
//# sourceMappingURL=api-version.js.map
|
|
1062
1080
|
|
|
1063
1081
|
function datePlusMinutes(minutes) {
|
|
1064
1082
|
if (minutes === void 0) { minutes = 30; }
|
|
@@ -1182,7 +1200,7 @@
|
|
|
1182
1200
|
return Builder.Component(info);
|
|
1183
1201
|
}
|
|
1184
1202
|
var Builder = /** @class */ (function () {
|
|
1185
|
-
function Builder(apiKey, request, response, forceNewInstance, authToken) {
|
|
1203
|
+
function Builder(apiKey, request, response, forceNewInstance, authToken, apiVersion) {
|
|
1186
1204
|
if (apiKey === void 0) { apiKey = null; }
|
|
1187
1205
|
if (forceNewInstance === void 0) { forceNewInstance = false; }
|
|
1188
1206
|
if (authToken === void 0) { authToken = null; }
|
|
@@ -1207,6 +1225,7 @@
|
|
|
1207
1225
|
this.overrideParams = '';
|
|
1208
1226
|
this.noCache = false;
|
|
1209
1227
|
this.preview = false;
|
|
1228
|
+
this.apiVersion$ = new BehaviorSubject(undefined);
|
|
1210
1229
|
this.canTrack$ = new BehaviorSubject(!this.browserTrackingDisabled);
|
|
1211
1230
|
this.apiKey$ = new BehaviorSubject(null);
|
|
1212
1231
|
this.authToken$ = new BehaviorSubject(null);
|
|
@@ -1246,6 +1265,9 @@
|
|
|
1246
1265
|
if (apiKey) {
|
|
1247
1266
|
this.apiKey = apiKey;
|
|
1248
1267
|
}
|
|
1268
|
+
if (apiVersion) {
|
|
1269
|
+
this.apiVersion = apiVersion;
|
|
1270
|
+
}
|
|
1249
1271
|
if (authToken) {
|
|
1250
1272
|
this.authToken = authToken;
|
|
1251
1273
|
}
|
|
@@ -1554,6 +1576,18 @@
|
|
|
1554
1576
|
enumerable: false,
|
|
1555
1577
|
configurable: true
|
|
1556
1578
|
});
|
|
1579
|
+
Object.defineProperty(Builder.prototype, "apiVersion", {
|
|
1580
|
+
get: function () {
|
|
1581
|
+
return this.apiVersion$.value;
|
|
1582
|
+
},
|
|
1583
|
+
set: function (apiVersion) {
|
|
1584
|
+
if (this.apiVersion !== apiVersion) {
|
|
1585
|
+
this.apiVersion$.next(apiVersion);
|
|
1586
|
+
}
|
|
1587
|
+
},
|
|
1588
|
+
enumerable: false,
|
|
1589
|
+
configurable: true
|
|
1590
|
+
});
|
|
1557
1591
|
Object.defineProperty(Builder.prototype, "editingMode", {
|
|
1558
1592
|
get: function () {
|
|
1559
1593
|
return this.editingMode$.value;
|
|
@@ -2085,7 +2119,7 @@
|
|
|
2085
2119
|
enumerable: false,
|
|
2086
2120
|
configurable: true
|
|
2087
2121
|
});
|
|
2088
|
-
Builder.prototype.init = function (apiKey, canTrack, req, res, authToken) {
|
|
2122
|
+
Builder.prototype.init = function (apiKey, canTrack, req, res, authToken, apiVersion) {
|
|
2089
2123
|
if (canTrack === void 0) { canTrack = this.defaultCanTrack; }
|
|
2090
2124
|
if (req) {
|
|
2091
2125
|
this.request = req;
|
|
@@ -2098,6 +2132,9 @@
|
|
|
2098
2132
|
if (authToken) {
|
|
2099
2133
|
this.authToken = authToken;
|
|
2100
2134
|
}
|
|
2135
|
+
if (apiVersion) {
|
|
2136
|
+
this.apiVersion = apiVersion;
|
|
2137
|
+
}
|
|
2101
2138
|
return this;
|
|
2102
2139
|
};
|
|
2103
2140
|
Object.defineProperty(Builder.prototype, "previewingModel", {
|
|
@@ -2180,16 +2217,21 @@
|
|
|
2180
2217
|
if (options === void 0) { options = {}; }
|
|
2181
2218
|
var instance = this;
|
|
2182
2219
|
if (!Builder.isBrowser) {
|
|
2183
|
-
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken);
|
|
2220
|
+
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken, options.apiVersion || this.apiVersion);
|
|
2184
2221
|
instance.setUserAttributes(this.getUserAttributes());
|
|
2185
2222
|
}
|
|
2186
2223
|
else {
|
|
2224
|
+
// NOTE: All these are when .init is not called and the customer
|
|
2225
|
+
// directly calls .get on the singleton instance of Builder
|
|
2187
2226
|
if (options.apiKey && !this.apiKey) {
|
|
2188
2227
|
this.apiKey = options.apiKey;
|
|
2189
2228
|
}
|
|
2190
2229
|
if (options.authToken && !this.authToken) {
|
|
2191
2230
|
this.authToken = options.authToken;
|
|
2192
2231
|
}
|
|
2232
|
+
if (options.apiVersion && !this.apiVersion) {
|
|
2233
|
+
this.apiVersion = options.apiVersion;
|
|
2234
|
+
}
|
|
2193
2235
|
}
|
|
2194
2236
|
return instance.queueGetContent(modelName, options).map(
|
|
2195
2237
|
/* map( */ function (matches) {
|
|
@@ -2330,6 +2372,14 @@
|
|
|
2330
2372
|
if (!this.apiKey) {
|
|
2331
2373
|
throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
|
|
2332
2374
|
}
|
|
2375
|
+
if (this.apiVersion) {
|
|
2376
|
+
if (!['v1', 'v3'].includes(this.apiVersion)) {
|
|
2377
|
+
throw new Error("Invalid apiVersion: expected 'v1' or 'v3', received '".concat(this.apiVersion, "'"));
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
else {
|
|
2381
|
+
this.apiVersion = DEFAULT_API_VERSION;
|
|
2382
|
+
}
|
|
2333
2383
|
if (!usePastQueue && !this.getContentQueue) {
|
|
2334
2384
|
return;
|
|
2335
2385
|
}
|
|
@@ -2459,7 +2509,9 @@
|
|
|
2459
2509
|
requestOptions.headers = __assign(__assign({}, requestOptions.headers), { Authorization: "Bearer ".concat(this.authToken) });
|
|
2460
2510
|
}
|
|
2461
2511
|
var fn = format === 'solid' || format === 'react' ? 'codegen' : 'query';
|
|
2462
|
-
|
|
2512
|
+
// NOTE: this is a hack to get around the fact that the codegen endpoint is not yet available in v3
|
|
2513
|
+
var apiVersionBasedOnFn = fn === 'query' ? this.apiVersion : 'v1';
|
|
2514
|
+
var url = "".concat(host, "/api/").concat(apiVersionBasedOnFn, "/").concat(fn, "/").concat(this.apiKey, "/").concat(keyNames) +
|
|
2463
2515
|
(queryParams && hasParams ? "?".concat(queryStr) : '');
|
|
2464
2516
|
var promise = getFetch()(url, requestOptions)
|
|
2465
2517
|
.then(function (res) { return res.json(); })
|
|
@@ -2589,17 +2641,22 @@
|
|
|
2589
2641
|
if (options === void 0) { options = {}; }
|
|
2590
2642
|
var instance = this;
|
|
2591
2643
|
if (!Builder.isBrowser) {
|
|
2592
|
-
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res);
|
|
2644
|
+
instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, false, null, options.apiVersion);
|
|
2593
2645
|
instance.setUserAttributes(this.getUserAttributes());
|
|
2594
2646
|
}
|
|
2595
2647
|
else {
|
|
2648
|
+
// NOTE: All these are when .init is not called and the customer
|
|
2649
|
+
// directly calls .get on the singleton instance of Builder
|
|
2596
2650
|
if (options.apiKey && !this.apiKey) {
|
|
2597
2651
|
this.apiKey = options.apiKey;
|
|
2598
2652
|
}
|
|
2653
|
+
if (options.apiVersion && !this.apiVersion) {
|
|
2654
|
+
this.apiVersion = options.apiVersion;
|
|
2655
|
+
}
|
|
2599
2656
|
}
|
|
2600
2657
|
return instance
|
|
2601
2658
|
.getContent(modelName, __assign(__assign({ limit: 30 }, options), { key: options.key ||
|
|
2602
|
-
// Make the key include all options so we don't reuse cache for the same
|
|
2659
|
+
// Make the key include all options, so we don't reuse cache for the same content fetched
|
|
2603
2660
|
// with different options
|
|
2604
2661
|
Builder.isBrowser
|
|
2605
2662
|
? "".concat(modelName, ":").concat(hashSum(omit(options, 'initialContent', 'req', 'res')))
|
|
@@ -2649,10 +2706,14 @@
|
|
|
2649
2706
|
Builder.isReact = false;
|
|
2650
2707
|
Builder.overrideUserAttributes = {};
|
|
2651
2708
|
return Builder;
|
|
2652
|
-
}());
|
|
2709
|
+
}());
|
|
2710
|
+
//# sourceMappingURL=builder.class.js.map
|
|
2653
2711
|
|
|
2654
2712
|
var builder = new Builder(null, undefined, undefined, true);
|
|
2655
|
-
Builder.singletonInstance = builder;
|
|
2713
|
+
Builder.singletonInstance = builder;
|
|
2714
|
+
//# sourceMappingURL=builder.js.map
|
|
2715
|
+
|
|
2716
|
+
//# sourceMappingURL=index.js.map
|
|
2656
2717
|
|
|
2657
2718
|
exports.Builder = Builder;
|
|
2658
2719
|
exports.BuilderComponent = BuilderComponent;
|