@builder.io/sdk 4.0.3 → 5.0.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 = '4.0.3';
961
+ var SDK_VERSION = '5.0.0-0';
962
962
 
963
963
  function datePlusMinutes(minutes) {
964
964
  if (minutes === void 0) { minutes = 30; }
@@ -2319,7 +2319,6 @@ var Builder = /** @class */ (function () {
2319
2319
  };
2320
2320
  Builder.prototype.flushGetContentQueue = function (usePastQueue, useQueue) {
2321
2321
  var _this = this;
2322
- var _a, _b;
2323
2322
  if (usePastQueue === void 0) { usePastQueue = false; }
2324
2323
  if (!this.apiKey) {
2325
2324
  throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
@@ -2336,6 +2335,7 @@ var Builder = /** @class */ (function () {
2336
2335
  return;
2337
2336
  }
2338
2337
  var queue = useQueue || (usePastQueue ? this.priorContentQueue : this.getContentQueue) || [];
2338
+ var apiEndpoint = queue[0].apiEndpoint || 'query';
2339
2339
  // TODO: do this on every request send?
2340
2340
  this.getOverridesFromQueryString();
2341
2341
  var queryParams = tslib.__assign(tslib.__assign({
@@ -2410,7 +2410,6 @@ var Builder = /** @class */ (function () {
2410
2410
  }
2411
2411
  }
2412
2412
  }
2413
- 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';
2414
2413
  for (var _i = 0, queue_2 = queue; _i < queue_2.length; _i++) {
2415
2414
  var options = queue_2[_i];
2416
2415
  var format_1 = options.format;
@@ -2442,11 +2441,11 @@ var Builder = /** @class */ (function () {
2442
2441
  'rev',
2443
2442
  'static',
2444
2443
  ];
2445
- for (var _c = 0, properties_1 = properties; _c < properties_1.length; _c++) {
2446
- var key = properties_1[_c];
2444
+ for (var _a = 0, properties_1 = properties; _a < properties_1.length; _a++) {
2445
+ var key = properties_1[_a];
2447
2446
  var value = options[key];
2448
2447
  if (value !== undefined) {
2449
- if (isApiCallForCodegen) {
2448
+ if (apiEndpoint === 'query') {
2450
2449
  queryParams.options = queryParams.options || {};
2451
2450
  queryParams.options[options.key] = queryParams.options[options.key] || {};
2452
2451
  queryParams.options[options.key][key] = JSON.stringify(value);
@@ -2468,8 +2467,10 @@ var Builder = /** @class */ (function () {
2468
2467
  var params = omit(QueryString.parse(this.overrideParams), 'apiKey');
2469
2468
  assign(queryParams, params);
2470
2469
  }
2471
- queryParams.format;
2472
- if (!isApiCallForCodegen) {
2470
+ var format = queryParams.format;
2471
+ var isApiCallForCodegen = format === 'solid' || format === 'react';
2472
+ var isApiCallForCodegenOrQuery = isApiCallForCodegen || apiEndpoint === 'query';
2473
+ if (apiEndpoint === 'content') {
2473
2474
  queryParams.enrich = true;
2474
2475
  if (queue[0].query) {
2475
2476
  var flattened = this.flattenMongoQuery({ query: queue[0].query });
@@ -2488,6 +2489,9 @@ var Builder = /** @class */ (function () {
2488
2489
  if (isApiCallForCodegen) {
2489
2490
  url = "".concat(host, "/api/v1/codegen/").concat(this.apiKey, "/").concat(keyNames);
2490
2491
  }
2492
+ else if (apiEndpoint === 'query') {
2493
+ url = "".concat(host, "/api/v3/query/").concat(this.apiKey, "/").concat(keyNames);
2494
+ }
2491
2495
  else {
2492
2496
  url = "".concat(host, "/api/v3/content/").concat(queue[0].model);
2493
2497
  }
@@ -2510,7 +2514,7 @@ var Builder = /** @class */ (function () {
2510
2514
  if (!observer) {
2511
2515
  return;
2512
2516
  }
2513
- var data = isApiCallForCodegen ? result[keyName] : result.results;
2517
+ var data = isApiCallForCodegenOrQuery ? result[keyName] : result.results;
2514
2518
  var sorted = data; // sortBy(data, item => item.priority);
2515
2519
  if (data) {
2516
2520
  var testModifiedResults = Builder.isServer