typesense-instantsearch-adapter 2.5.0-9 → 2.5.1

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.
@@ -2704,9 +2704,17 @@ var SearchRequestAdapter = /*#__PURE__*/function () {
2704
2704
  typesenseSearchParams.per_page = 0;
2705
2705
  } // console.log(params);
2706
2706
  // console.log(typesenseSearchParams);
2707
+ // Filter out empty or null values, so we don't accidentally override values set in presets
2708
+ // eslint-disable-next-line no-unused-vars
2707
2709
 
2708
2710
 
2709
- return typesenseSearchParams;
2711
+ return Object.fromEntries(Object.entries(typesenseSearchParams).filter(function (_ref2) {
2712
+ var _ref3 = (0,_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__["default"])(_ref2, 2),
2713
+ _ = _ref3[0],
2714
+ v = _ref3[1];
2715
+
2716
+ return v != null && v !== "";
2717
+ }));
2710
2718
  }
2711
2719
  }, {
2712
2720
  key: "_camelToSnakeCase",
@@ -3016,8 +3024,10 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
3016
3024
  key: "_adaptHighlightInPrimitiveValue",
3017
3025
  value: function _adaptHighlightInPrimitiveValue(primitiveValue, highlightPrimitiveValue, snippetOrValue) {
3018
3026
  if (highlightPrimitiveValue != null) {
3027
+ var _ref9, _highlightPrimitiveVa;
3028
+
3019
3029
  return {
3020
- value: this._adaptHighlightTag("".concat(highlightPrimitiveValue[snippetOrValue]), this.instantsearchRequest.params.highlightPreTag, this.instantsearchRequest.params.highlightPostTag),
3030
+ value: this._adaptHighlightTag("".concat((_ref9 = (_highlightPrimitiveVa = highlightPrimitiveValue[snippetOrValue]) !== null && _highlightPrimitiveVa !== void 0 ? _highlightPrimitiveVa : highlightPrimitiveValue["highlight"]) !== null && _ref9 !== void 0 ? _ref9 : highlightPrimitiveValue["snippet"]), this.instantsearchRequest.params.highlightPreTag, this.instantsearchRequest.params.highlightPostTag),
3021
3031
  matchLevel: (highlightPrimitiveValue.matched_tokens || []).length > 0 ? "full" : "none",
3022
3032
  matchedWords: highlightPrimitiveValue.matched_tokens || []
3023
3033
  };
@@ -4784,6 +4794,8 @@ var Metrics_1 = __importDefault(__webpack_require__(/*! ./Metrics */ "./node_mod
4784
4794
  var Health_1 = __importDefault(__webpack_require__(/*! ./Health */ "./node_modules/typesense/lib/Typesense/Health.js"));
4785
4795
  var Operations_1 = __importDefault(__webpack_require__(/*! ./Operations */ "./node_modules/typesense/lib/Typesense/Operations.js"));
4786
4796
  var MultiSearch_1 = __importDefault(__webpack_require__(/*! ./MultiSearch */ "./node_modules/typesense/lib/Typesense/MultiSearch.js"));
4797
+ var Presets_1 = __importDefault(__webpack_require__(/*! ./Presets */ "./node_modules/typesense/lib/Typesense/Presets.js"));
4798
+ var Preset_1 = __importDefault(__webpack_require__(/*! ./Preset */ "./node_modules/typesense/lib/Typesense/Preset.js"));
4787
4799
  var Client = /** @class */ (function () {
4788
4800
  function Client(options) {
4789
4801
  var _a;
@@ -4801,6 +4813,8 @@ var Client = /** @class */ (function () {
4801
4813
  this.individualAliases = {};
4802
4814
  this._keys = new Keys_1.default(this.apiCall);
4803
4815
  this.individualKeys = {};
4816
+ this._presets = new Presets_1.default(this.apiCall);
4817
+ this.individualPresets = {};
4804
4818
  }
4805
4819
  Client.prototype.collections = function (collectionName) {
4806
4820
  if (collectionName === undefined) {
@@ -4835,6 +4849,17 @@ var Client = /** @class */ (function () {
4835
4849
  return this.individualKeys[id];
4836
4850
  }
4837
4851
  };
4852
+ Client.prototype.presets = function (id) {
4853
+ if (id === undefined) {
4854
+ return this._presets;
4855
+ }
4856
+ else {
4857
+ if (this.individualPresets[id] === undefined) {
4858
+ this.individualPresets[id] = new Preset_1.default(id, this.apiCall);
4859
+ }
4860
+ return this.individualPresets[id];
4861
+ }
4862
+ };
4838
4863
  return Client;
4839
4864
  }());
4840
4865
  exports["default"] = Client;
@@ -6624,6 +6649,165 @@ exports["default"] = Overrides;
6624
6649
 
6625
6650
  /***/ }),
6626
6651
 
6652
+ /***/ "./node_modules/typesense/lib/Typesense/Preset.js":
6653
+ /*!********************************************************!*\
6654
+ !*** ./node_modules/typesense/lib/Typesense/Preset.js ***!
6655
+ \********************************************************/
6656
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
6657
+
6658
+ "use strict";
6659
+
6660
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6661
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6662
+ return new (P || (P = Promise))(function (resolve, reject) {
6663
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6664
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6665
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6666
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
6667
+ });
6668
+ };
6669
+ var __generator = (this && this.__generator) || function (thisArg, body) {
6670
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6671
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6672
+ function verb(n) { return function (v) { return step([n, v]); }; }
6673
+ function step(op) {
6674
+ if (f) throw new TypeError("Generator is already executing.");
6675
+ while (_) try {
6676
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
6677
+ if (y = 0, t) op = [op[0] & 2, t.value];
6678
+ switch (op[0]) {
6679
+ case 0: case 1: t = op; break;
6680
+ case 4: _.label++; return { value: op[1], done: false };
6681
+ case 5: _.label++; y = op[1]; op = [0]; continue;
6682
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
6683
+ default:
6684
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6685
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6686
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6687
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6688
+ if (t[2]) _.ops.pop();
6689
+ _.trys.pop(); continue;
6690
+ }
6691
+ op = body.call(thisArg, _);
6692
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6693
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6694
+ }
6695
+ };
6696
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6697
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6698
+ };
6699
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
6700
+ var Presets_1 = __importDefault(__webpack_require__(/*! ./Presets */ "./node_modules/typesense/lib/Typesense/Presets.js"));
6701
+ var Preset = /** @class */ (function () {
6702
+ function Preset(presetId, apiCall) {
6703
+ this.presetId = presetId;
6704
+ this.apiCall = apiCall;
6705
+ }
6706
+ Preset.prototype.retrieve = function () {
6707
+ return __awaiter(this, void 0, void 0, function () {
6708
+ return __generator(this, function (_a) {
6709
+ return [2 /*return*/, this.apiCall.get(this.endpointPath())];
6710
+ });
6711
+ });
6712
+ };
6713
+ Preset.prototype.delete = function () {
6714
+ return __awaiter(this, void 0, void 0, function () {
6715
+ return __generator(this, function (_a) {
6716
+ return [2 /*return*/, this.apiCall.delete(this.endpointPath())];
6717
+ });
6718
+ });
6719
+ };
6720
+ Preset.prototype.endpointPath = function () {
6721
+ return "".concat(Presets_1.default.RESOURCEPATH, "/").concat(this.presetId);
6722
+ };
6723
+ return Preset;
6724
+ }());
6725
+ exports["default"] = Preset;
6726
+ //# sourceMappingURL=Preset.js.map
6727
+
6728
+ /***/ }),
6729
+
6730
+ /***/ "./node_modules/typesense/lib/Typesense/Presets.js":
6731
+ /*!*********************************************************!*\
6732
+ !*** ./node_modules/typesense/lib/Typesense/Presets.js ***!
6733
+ \*********************************************************/
6734
+ /***/ (function(__unused_webpack_module, exports) {
6735
+
6736
+ "use strict";
6737
+
6738
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6739
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6740
+ return new (P || (P = Promise))(function (resolve, reject) {
6741
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6742
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6743
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6744
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
6745
+ });
6746
+ };
6747
+ var __generator = (this && this.__generator) || function (thisArg, body) {
6748
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6749
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6750
+ function verb(n) { return function (v) { return step([n, v]); }; }
6751
+ function step(op) {
6752
+ if (f) throw new TypeError("Generator is already executing.");
6753
+ while (_) try {
6754
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
6755
+ if (y = 0, t) op = [op[0] & 2, t.value];
6756
+ switch (op[0]) {
6757
+ case 0: case 1: t = op; break;
6758
+ case 4: _.label++; return { value: op[1], done: false };
6759
+ case 5: _.label++; y = op[1]; op = [0]; continue;
6760
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
6761
+ default:
6762
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6763
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6764
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6765
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6766
+ if (t[2]) _.ops.pop();
6767
+ _.trys.pop(); continue;
6768
+ }
6769
+ op = body.call(thisArg, _);
6770
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6771
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6772
+ }
6773
+ };
6774
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
6775
+ var RESOURCEPATH = '/presets';
6776
+ var Presets = /** @class */ (function () {
6777
+ function Presets(apiCall) {
6778
+ this.apiCall = apiCall;
6779
+ }
6780
+ Presets.prototype.upsert = function (presetId, params) {
6781
+ return __awaiter(this, void 0, void 0, function () {
6782
+ return __generator(this, function (_a) {
6783
+ return [2 /*return*/, this.apiCall.put(this.endpointPath(presetId), params)];
6784
+ });
6785
+ });
6786
+ };
6787
+ Presets.prototype.retrieve = function () {
6788
+ return __awaiter(this, void 0, void 0, function () {
6789
+ return __generator(this, function (_a) {
6790
+ return [2 /*return*/, this.apiCall.get(this.endpointPath())];
6791
+ });
6792
+ });
6793
+ };
6794
+ Presets.prototype.endpointPath = function (operation) {
6795
+ return "".concat(Presets.RESOURCEPATH).concat(operation === undefined ? '' : '/' + operation);
6796
+ };
6797
+ Object.defineProperty(Presets, "RESOURCEPATH", {
6798
+ get: function () {
6799
+ return RESOURCEPATH;
6800
+ },
6801
+ enumerable: false,
6802
+ configurable: true
6803
+ });
6804
+ return Presets;
6805
+ }());
6806
+ exports["default"] = Presets;
6807
+ //# sourceMappingURL=Presets.js.map
6808
+
6809
+ /***/ }),
6810
+
6627
6811
  /***/ "./node_modules/typesense/lib/Typesense/RequestWithCache.js":
6628
6812
  /*!******************************************************************!*\
6629
6813
  !*** ./node_modules/typesense/lib/Typesense/RequestWithCache.js ***!