@builder.io/sdk 2.2.8 → 3.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @builder.io/sdk
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - bc1d409: Fix: Reintroduced `JSON.stringify(userAttributes)` change to standardize parsing logic and preserve strings. This is a breaking change as it doesn't require manual stringification of `userAttributes` values. Ensure that attributes are not manually stringified before passing them to avoid potential issues.
8
+
9
+ ### Patch Changes
10
+
11
+ - 1586519: Fix: remove `next: { revalidate: 1 }` in SDKs fetch
12
+
13
+ ## 2.2.9
14
+
15
+ ### Patch Changes
16
+
17
+ - b7c00cf: Silence errors from non essential query params parsing
18
+
3
19
  ## 2.2.8
4
20
 
5
21
  ### Patch Changes
@@ -152,7 +152,7 @@
152
152
  throw new Error("Property name \"".concat(name, "\" is not allowed"));
153
153
  }
154
154
 
155
- var version = "2.2.8";
155
+ var version = "3.0.0";
156
156
 
157
157
  var Subscription = /** @class */ (function () {
158
158
  function Subscription(listeners, listener) {
@@ -1850,15 +1850,20 @@
1850
1850
  };
1851
1851
  Builder.prototype.setTestsFromUrl = function () {
1852
1852
  var search = this.getLocation().search;
1853
- var params = QueryString.parseDeep(this.modifySearch(search || '').substr(1));
1854
- var tests = params.builder && params.builder.tests;
1855
- if (tests && typeof tests === 'object') {
1856
- for (var key in tests) {
1857
- if (tests.hasOwnProperty(key)) {
1858
- this.setTestCookie(key, tests[key]);
1853
+ try {
1854
+ var params = QueryString.parseDeep(this.modifySearch(search || '').substr(1));
1855
+ var tests = params.builder && params.builder.tests;
1856
+ if (tests && typeof tests === 'object') {
1857
+ for (var key in tests) {
1858
+ if (tests.hasOwnProperty(key)) {
1859
+ this.setTestCookie(key, tests[key]);
1860
+ }
1859
1861
  }
1860
1862
  }
1861
1863
  }
1864
+ catch (e) {
1865
+ console.debug('Error parsing tests from URL', e);
1866
+ }
1862
1867
  };
1863
1868
  Builder.prototype.resetOverrides = function () {
1864
1869
  // Ugly - pass down instances per request instead using react context
@@ -1876,41 +1881,46 @@
1876
1881
  };
1877
1882
  Builder.prototype.getOverridesFromQueryString = function () {
1878
1883
  var location = this.getLocation();
1879
- var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
1880
- var builder = params.builder;
1881
- if (builder) {
1882
- var userAttributes = builder.userAttributes, overrides = builder.overrides, env = builder.env; builder.host; var api = builder.api, cachebust = builder.cachebust, noCache = builder.noCache, preview = builder.preview, editing = builder.editing, frameEditing = builder.frameEditing, options = builder.options, overrideParams = builder.params;
1883
- if (userAttributes) {
1884
- this.setUserAttributes(userAttributes);
1885
- }
1886
- if (options) {
1887
- // picking only locale, includeRefs, and enrich for now
1888
- this.queryOptions = __assign(__assign(__assign({}, (options.locale && { locale: options.locale })), (options.includeRefs && { includeRefs: options.includeRefs })), (options.enrich && { enrich: options.enrich }));
1889
- }
1890
- if (overrides) {
1891
- this.overrides = overrides;
1892
- }
1893
- if (validEnvList.indexOf(env || api) > -1) {
1894
- this.env = env || api;
1895
- }
1896
- if (Builder.isEditing) {
1897
- var editingModel = frameEditing || editing || preview;
1898
- if (editingModel && editingModel !== 'true') {
1899
- this.editingModel = editingModel;
1884
+ try {
1885
+ var params = QueryString.parseDeep(this.modifySearch(location.search || '').substr(1));
1886
+ var builder = params.builder;
1887
+ if (builder) {
1888
+ var userAttributes = builder.userAttributes, overrides = builder.overrides, env = builder.env, host = builder.host, api = builder.api, cachebust = builder.cachebust, noCache = builder.noCache, preview = builder.preview, editing = builder.editing, frameEditing = builder.frameEditing, options = builder.options, overrideParams = builder.params;
1889
+ if (userAttributes) {
1890
+ this.setUserAttributes(userAttributes);
1891
+ }
1892
+ if (options) {
1893
+ // picking only locale, includeRefs, and enrich for now
1894
+ this.queryOptions = __assign(__assign(__assign({}, (options.locale && { locale: options.locale })), (options.includeRefs && { includeRefs: options.includeRefs })), (options.enrich && { enrich: options.enrich }));
1895
+ }
1896
+ if (overrides) {
1897
+ this.overrides = overrides;
1898
+ }
1899
+ if (validEnvList.indexOf(env || api) > -1) {
1900
+ this.env = env || api;
1901
+ }
1902
+ if (Builder.isEditing) {
1903
+ var editingModel = frameEditing || editing || preview;
1904
+ if (editingModel && editingModel !== 'true') {
1905
+ this.editingModel = editingModel;
1906
+ }
1907
+ }
1908
+ if (cachebust) {
1909
+ this.cachebust = true;
1910
+ }
1911
+ if (noCache) {
1912
+ this.noCache = true;
1913
+ }
1914
+ if (preview) {
1915
+ this.preview = true;
1916
+ }
1917
+ if (params) {
1918
+ this.overrideParams = overrideParams;
1900
1919
  }
1901
1920
  }
1902
- if (cachebust) {
1903
- this.cachebust = true;
1904
- }
1905
- if (noCache) {
1906
- this.noCache = true;
1907
- }
1908
- if (preview) {
1909
- this.preview = true;
1910
- }
1911
- if (params) {
1912
- this.overrideParams = overrideParams;
1913
- }
1921
+ }
1922
+ catch (e) {
1923
+ console.debug('Error parsing overrides from URL', e);
1914
1924
  }
1915
1925
  };
1916
1926
  Builder.prototype.messageFrameLoaded = function () {
@@ -2331,7 +2341,7 @@
2331
2341
  // even though we only use `fetch()` now, we prefer to keep the old behavior and use the `fetch` that comes from
2332
2342
  // the core SDK for consistency
2333
2343
  Builder.prototype.requestUrl = function (url, options) {
2334
- return getFetch()(url, __assign({ next: __assign({ revalidate: 1 }, options === null || options === void 0 ? void 0 : options.next) }, options)).then(function (res) { return res.json(); });
2344
+ return getFetch()(url, options).then(function (res) { return res.json(); });
2335
2345
  };
2336
2346
  Object.defineProperty(Builder.prototype, "host", {
2337
2347
  get: function () {
@@ -2427,7 +2437,7 @@
2427
2437
  }
2428
2438
  // TODO: merge in the attribute from query string ones
2429
2439
  // TODO: make this an option per component/request
2430
- queryParams.userAttributes = userAttributes;
2440
+ queryParams.userAttributes = JSON.stringify(userAttributes);
2431
2441
  if (!usePastQueue && !useQueue) {
2432
2442
  this.priorContentQueue = queue;
2433
2443
  this.getContentQueue = null;
@@ -2505,7 +2515,7 @@
2505
2515
  }
2506
2516
  var queryStr = QueryString.stringifyDeep(queryParams);
2507
2517
  var format = queryParams.format;
2508
- var requestOptions = { headers: {}, next: { revalidate: 1 } };
2518
+ var requestOptions = { headers: {} };
2509
2519
  if (this.authToken) {
2510
2520
  requestOptions.headers = __assign(__assign({}, requestOptions.headers), { Authorization: "Bearer ".concat(this.authToken) });
2511
2521
  }