@builder.io/sdk 4.0.2 → 4.0.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/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 = '4.0.2';
961
+ var SDK_VERSION = '4.0.3';
962
962
 
963
963
  function datePlusMinutes(minutes) {
964
964
  if (minutes === void 0) { minutes = 30; }
@@ -1358,7 +1358,9 @@ var Builder = /** @class */ (function () {
1358
1358
  // 1. `function name(args) => {code}`
1359
1359
  // 2. `name(args) => {code}`
1360
1360
  // 3. `(args) => {}`
1361
- var appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
1361
+ // 4. `args => {}`
1362
+ var isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
1363
+ var appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
1362
1364
  return "return (".concat(appendFunction ? 'function ' : '').concat(fnStr, ").apply(this, arguments)");
1363
1365
  };
1364
1366
  return JSON.parse(JSON.stringify(info, function (key, value) {
@@ -2124,8 +2126,14 @@ var Builder = /** @class */ (function () {
2124
2126
  assign(this.trackingUserAttributes, attributes);
2125
2127
  };
2126
2128
  Builder.prototype.get = function (modelName, options) {
2129
+ var _a;
2127
2130
  if (options === void 0) { options = {}; }
2128
2131
  var instance = this;
2132
+ var finalLocale = options.locale || ((_a = options.userAttributes) === null || _a === void 0 ? void 0 : _a.locale) || this.getUserAttributes().locale;
2133
+ var finalOptions = tslib.__assign(tslib.__assign({}, options), (finalLocale && {
2134
+ locale: String(finalLocale),
2135
+ userAttributes: tslib.__assign({ locale: String(finalLocale) }, options.userAttributes),
2136
+ }));
2129
2137
  if (!Builder.isBrowser) {
2130
2138
  instance = new Builder(options.apiKey || this.apiKey, options.req, options.res, undefined, options.authToken || this.authToken, options.apiVersion || this.apiVersion);
2131
2139
  instance.setUserAttributes(this.getUserAttributes());
@@ -2143,7 +2151,7 @@ var Builder = /** @class */ (function () {
2143
2151
  this.apiVersion = options.apiVersion;
2144
2152
  }
2145
2153
  }
2146
- return instance.queueGetContent(modelName, options).map(
2154
+ return instance.queueGetContent(modelName, finalOptions).map(
2147
2155
  /* map( */ function (matches) {
2148
2156
  var match = matches && matches[0];
2149
2157
  if (Builder.isStatic) {
@@ -2351,9 +2359,9 @@ var Builder = /** @class */ (function () {
2351
2359
  if (queue[0].sort) {
2352
2360
  queryParams.sort = queue[0].sort;
2353
2361
  }
2354
- var pageQueryParams = typeof location !== 'undefined'
2362
+ var pageQueryParams = (typeof location !== 'undefined'
2355
2363
  ? QueryString.parseDeep(location.search.substr(1))
2356
- : {}; // TODO: WHAT about SSR (this.request) ?
2364
+ : undefined) || {}; // TODO: WHAT about SSR (this.request) ?
2357
2365
  var userAttributes =
2358
2366
  // FIXME: HACK: only checks first in queue for user attributes overrides, should check all
2359
2367
  // TODO: merge user attributes provided here with defaults and current user attiributes (?)