@builder.io/sdk 3.0.7 → 4.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/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 = '3.0.7';
961
+ var SDK_VERSION = '4.0.0';
962
962
 
963
963
  function datePlusMinutes(minutes) {
964
964
  if (minutes === void 0) { minutes = 30; }
@@ -2311,6 +2311,7 @@ var Builder = /** @class */ (function () {
2311
2311
  };
2312
2312
  Builder.prototype.flushGetContentQueue = function (usePastQueue, useQueue) {
2313
2313
  var _this = this;
2314
+ var _a, _b;
2314
2315
  if (usePastQueue === void 0) { usePastQueue = false; }
2315
2316
  if (!this.apiKey) {
2316
2317
  throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
@@ -2327,7 +2328,6 @@ var Builder = /** @class */ (function () {
2327
2328
  return;
2328
2329
  }
2329
2330
  var queue = useQueue || (usePastQueue ? this.priorContentQueue : this.getContentQueue) || [];
2330
- var apiEndpoint = queue[0].apiEndpoint || 'query';
2331
2331
  // TODO: do this on every request send?
2332
2332
  this.getOverridesFromQueryString();
2333
2333
  var queryParams = tslib.__assign(tslib.__assign({
@@ -2402,6 +2402,7 @@ var Builder = /** @class */ (function () {
2402
2402
  }
2403
2403
  }
2404
2404
  }
2405
+ var isApiCallForCodegen = ((_a = queue[0].options) === null || _a === void 0 ? void 0 : _a.format) === 'solid' || ((_b = queue[0].options) === null || _b === void 0 ? void 0 : _b.format) === 'react';
2405
2406
  for (var _i = 0, queue_2 = queue; _i < queue_2.length; _i++) {
2406
2407
  var options = queue_2[_i];
2407
2408
  var format_1 = options.format;
@@ -2433,11 +2434,11 @@ var Builder = /** @class */ (function () {
2433
2434
  'rev',
2434
2435
  'static',
2435
2436
  ];
2436
- for (var _a = 0, properties_1 = properties; _a < properties_1.length; _a++) {
2437
- var key = properties_1[_a];
2437
+ for (var _c = 0, properties_1 = properties; _c < properties_1.length; _c++) {
2438
+ var key = properties_1[_c];
2438
2439
  var value = options[key];
2439
2440
  if (value !== undefined) {
2440
- if (apiEndpoint === 'query') {
2441
+ if (isApiCallForCodegen) {
2441
2442
  queryParams.options = queryParams.options || {};
2442
2443
  queryParams.options[options.key] = queryParams.options[options.key] || {};
2443
2444
  queryParams.options[options.key][key] = JSON.stringify(value);
@@ -2459,10 +2460,8 @@ var Builder = /** @class */ (function () {
2459
2460
  var params = omit(QueryString.parse(this.overrideParams), 'apiKey');
2460
2461
  assign(queryParams, params);
2461
2462
  }
2462
- var format = queryParams.format;
2463
- var isApiCallForCodegen = format === 'solid' || format === 'react';
2464
- var isApiCallForCodegenOrQuery = isApiCallForCodegen || apiEndpoint === 'query';
2465
- if (apiEndpoint === 'content') {
2463
+ queryParams.format;
2464
+ if (!isApiCallForCodegen) {
2466
2465
  queryParams.enrich = true;
2467
2466
  if (queue[0].query) {
2468
2467
  var flattened = this.flattenMongoQuery({ query: queue[0].query });
@@ -2481,9 +2480,6 @@ var Builder = /** @class */ (function () {
2481
2480
  if (isApiCallForCodegen) {
2482
2481
  url = "".concat(host, "/api/v1/codegen/").concat(this.apiKey, "/").concat(keyNames);
2483
2482
  }
2484
- else if (apiEndpoint === 'query') {
2485
- url = "".concat(host, "/api/v3/query/").concat(this.apiKey, "/").concat(keyNames);
2486
- }
2487
2483
  else {
2488
2484
  url = "".concat(host, "/api/v3/content/").concat(queue[0].model);
2489
2485
  }
@@ -2506,7 +2502,7 @@ var Builder = /** @class */ (function () {
2506
2502
  if (!observer) {
2507
2503
  return;
2508
2504
  }
2509
- var data = isApiCallForCodegenOrQuery ? result[keyName] : result.results;
2505
+ var data = isApiCallForCodegen ? result[keyName] : result.results;
2510
2506
  var sorted = data; // sortBy(data, item => item.priority);
2511
2507
  if (data) {
2512
2508
  var testModifiedResults = Builder.isServer