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