@appbaseio/reactivesearch-vue 1.23.0 → 1.23.4-alpha

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.
Files changed (53) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +332 -97
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/DataSearch.js +2 -2
  6. package/dist/cjs/{DropDown-59a7971b.js → DropDown-6815b9b6.js} +1 -1
  7. package/dist/cjs/DynamicRangeSlider.js +1 -1
  8. package/dist/cjs/MultiDropdownList.js +2 -2
  9. package/dist/cjs/MultiList.js +1 -1
  10. package/dist/cjs/MultiRange.js +1 -1
  11. package/dist/cjs/RangeInput.js +1 -1
  12. package/dist/cjs/RangeSlider.js +1 -1
  13. package/dist/cjs/ReactiveBase.js +14 -8
  14. package/dist/cjs/ReactiveComponent.js +40 -6
  15. package/dist/cjs/ReactiveList.js +52 -53
  16. package/dist/cjs/ResultCard.js +1 -1
  17. package/dist/cjs/ResultList.js +1 -1
  18. package/dist/cjs/SelectedFilters.js +1 -1
  19. package/dist/cjs/SingleDropdownList.js +2 -2
  20. package/dist/cjs/SingleList.js +1 -1
  21. package/dist/cjs/SingleRange.js +1 -1
  22. package/dist/cjs/StateProvider.js +1 -1
  23. package/dist/cjs/ToggleButton.js +1 -1
  24. package/dist/cjs/index.js +3 -3
  25. package/dist/cjs/initReactivesearch.js +3 -2
  26. package/dist/cjs/install.js +3 -3
  27. package/dist/cjs/version.js +1 -1
  28. package/dist/cjs/{vueTypes-22b4fd3a.js → vueTypes-4c19b4c8.js} +5 -1
  29. package/dist/es/DataSearch.js +2 -2
  30. package/dist/es/{DropDown-db7fe433.js → DropDown-035c804f.js} +1 -1
  31. package/dist/es/DynamicRangeSlider.js +1 -1
  32. package/dist/es/MultiDropdownList.js +2 -2
  33. package/dist/es/MultiList.js +1 -1
  34. package/dist/es/MultiRange.js +1 -1
  35. package/dist/es/RangeInput.js +1 -1
  36. package/dist/es/RangeSlider.js +1 -1
  37. package/dist/es/ReactiveBase.js +14 -8
  38. package/dist/es/ReactiveComponent.js +40 -6
  39. package/dist/es/ReactiveList.js +52 -53
  40. package/dist/es/ResultCard.js +1 -1
  41. package/dist/es/ResultList.js +1 -1
  42. package/dist/es/SelectedFilters.js +1 -1
  43. package/dist/es/SingleDropdownList.js +2 -2
  44. package/dist/es/SingleList.js +1 -1
  45. package/dist/es/SingleRange.js +1 -1
  46. package/dist/es/StateProvider.js +1 -1
  47. package/dist/es/ToggleButton.js +1 -1
  48. package/dist/es/index.js +3 -3
  49. package/dist/es/initReactivesearch.js +3 -2
  50. package/dist/es/install.js +3 -3
  51. package/dist/es/version.js +1 -1
  52. package/dist/es/{vueTypes-e89c8a3c.js → vueTypes-fb61bb7b.js} +5 -1
  53. package/package.json +3 -3
@@ -5517,7 +5517,7 @@
5517
5517
  }, size > 0 ? {
5518
5518
  numberOfPages: Math.ceil(total / size)
5519
5519
  } : null, {
5520
- time: time,
5520
+ time: time || 0,
5521
5521
  hidden: hidden,
5522
5522
  promoted: promotedResults && promotedResults.length
5523
5523
  });
@@ -8636,7 +8636,7 @@
8636
8636
  componentList.forEach(function (component) {
8637
8637
  var componentProps = props[component];
8638
8638
 
8639
- if (selectedValues[componentId] && selectedValues[componentId].reference !== 'URL' && [constants$1.componentTypes.reactiveList, constants$1.componentTypes.reactiveMap].includes(componentProps.componentType)) {
8639
+ if (selectedValues[componentId] && selectedValues[componentId].reference !== 'URL' && componentProps && [constants$1.componentTypes.reactiveList, constants$1.componentTypes.reactiveMap].includes(componentProps.componentType)) {
8640
8640
  dispatch((0, value.setValue)(component, null));
8641
8641
  }
8642
8642
 
@@ -8721,8 +8721,9 @@
8721
8721
  }
8722
8722
  }
8723
8723
  } else {
8724
+ var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + '_' + component : component;
8724
8725
  finalQuery = [].concat(_toConsumableArray(finalQuery), [{
8725
- preference: component
8726
+ preference: preference
8726
8727
  }, currentQuery]);
8727
8728
  }
8728
8729
  }
@@ -8927,8 +8928,9 @@
8927
8928
  appendToAggs: appendToAggs
8928
8929
  }));
8929
8930
  } else {
8931
+ var preference = store.config && store.config.analyticsConfig && store.config.analyticsConfig.userId ? store.config.analyticsConfig.userId + '_' + component : component;
8930
8932
  var _finalQuery = [{
8931
- preference: component
8933
+ preference: preference
8932
8934
  }, currentQuery];
8933
8935
  dispatch(msearch(_finalQuery, [component], appendToHits, false, appendToAggs));
8934
8936
  }
@@ -12778,7 +12780,11 @@
12778
12780
  userId: VueTypes.string,
12779
12781
  customEvents: VueTypes.object,
12780
12782
  enableTelemetry: VueTypes.bool.def(true)
12781
- }).def({})
12783
+ }).def({}),
12784
+ mongodb: VueTypes.shape({
12785
+ db: VueTypes.string,
12786
+ collection: VueTypes.string
12787
+ })
12782
12788
  };
12783
12789
 
12784
12790
  var getClassName = lib_8.getClassName,
@@ -13882,18 +13888,17 @@
13882
13888
  ResultCardsWrapper: ResultCardsWrapper
13883
13889
  },
13884
13890
  data: function data() {
13885
- var props = this.$props;
13886
13891
  var currentPageState = 0;
13892
+ var defaultPage = this.defaultPage || -1;
13887
13893
 
13888
- if (props.defaultPage >= 0) {
13889
- currentPageState = props.defaultPage;
13890
- } else if (props.currentPage) {
13891
- currentPageState = Math.max(props.currentPage - 1, 0);
13894
+ if (defaultPage >= 0) {
13895
+ currentPageState = defaultPage;
13896
+ } else if (this.currentPage) {
13897
+ currentPageState = Math.max(this.currentPage - 1, 0);
13892
13898
  }
13893
13899
 
13894
13900
  this.__state = {
13895
- from: currentPageState * props.size,
13896
- isLoading: true,
13901
+ from: currentPageState * this.size,
13897
13902
  currentPageState: currentPageState
13898
13903
  };
13899
13904
  return this.__state;
@@ -13922,8 +13927,10 @@
13922
13927
  console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
13923
13928
  }
13924
13929
 
13925
- if (this.defaultPage >= 0) {
13926
- this.currentPageState = this.defaultPage;
13930
+ var defaultPage = this.defaultPage || -1;
13931
+
13932
+ if (defaultPage >= 0) {
13933
+ this.currentPageState = defaultPage;
13927
13934
  this.from = this.currentPageState * this.$props.size;
13928
13935
  }
13929
13936
 
@@ -13990,12 +13997,9 @@
13990
13997
  return this.$listeners && this.$listeners.resultStats;
13991
13998
  },
13992
13999
  stats: function stats() {
13993
- var _this$getAllData = this.getAllData(),
13994
- filteredResults = _this$getAllData.filteredResults;
13995
-
13996
14000
  return _extends({}, getResultStats(this), {
13997
14001
  currentPage: this.currentPageState,
13998
- displayedResults: filteredResults.length
14002
+ displayedResults: this.data.length
13999
14003
  });
14000
14004
  },
14001
14005
  hasCustomRender: function hasCustomRender() {
@@ -14004,6 +14008,27 @@
14004
14008
  showInfiniteScroll: function showInfiniteScroll() {
14005
14009
  // Pagination has higher priority then infinite scroll
14006
14010
  return this.infiniteScroll && !this.shouldRenderPagination;
14011
+ },
14012
+ data: function data() {
14013
+ var results = parseHits(this.hits) || [];
14014
+ var parsedPromotedResults = parseHits(this.promotedResults) || [];
14015
+ var filteredResults = results;
14016
+
14017
+ if (parsedPromotedResults.length) {
14018
+ var ids = parsedPromotedResults.map(function (item) {
14019
+ return item._id;
14020
+ }).filter(Boolean);
14021
+
14022
+ if (ids) {
14023
+ filteredResults = filteredResults.filter(function (item) {
14024
+ return !ids.includes(item._id);
14025
+ });
14026
+ }
14027
+
14028
+ filteredResults = [].concat(parsedPromotedResults, filteredResults);
14029
+ }
14030
+
14031
+ return helper_2(filteredResults);
14007
14032
  }
14008
14033
  },
14009
14034
  watch: {
@@ -14085,7 +14110,7 @@
14085
14110
  }
14086
14111
  },
14087
14112
  hits: function hits(newVal, oldVal) {
14088
- this.$emit('data', this.getAllData());
14113
+ this.$emit('data', this.getData());
14089
14114
 
14090
14115
  if (this.shouldRenderPagination) {
14091
14116
  // called when page is changed
@@ -14270,13 +14295,10 @@
14270
14295
 
14271
14296
  var h = this.$createElement;
14272
14297
  var size = this.$props.size;
14273
- var hits = this.$data.hits;
14274
- var results = parseHits(hits) || [];
14275
- var filteredResults = results;
14276
14298
  var renderItem = this.$scopedSlots.renderItem || this.$props.renderItem;
14277
14299
  var element = this.hasCustomRender ? this.getComponent() : h("div", {
14278
14300
  "class": this.$props.listClass + " " + getClassName$1(this.$props.innerClass, 'list')
14279
- }, [[].concat(filteredResults).map(function (item, index) {
14301
+ }, [this.data.map(function (item, index) {
14280
14302
  return renderItem({
14281
14303
  item: item,
14282
14304
  triggerClickAnalytics: function triggerClickAnalytics() {
@@ -14287,7 +14309,7 @@
14287
14309
 
14288
14310
  return this.analytics ? h(ImpressionTracker$1, {
14289
14311
  "attrs": {
14290
- "hits": filteredResults
14312
+ "hits": this.data
14291
14313
  }
14292
14314
  }, [element]) : element;
14293
14315
  },
@@ -14391,7 +14413,7 @@
14391
14413
  if (this.stats.numberOfResults) {
14392
14414
  return h("p", {
14393
14415
  "class": resultStats + " " + getClassName$1(this.$props.innerClass, 'resultStats')
14394
- }, [this.stats.numberOfResults, " results found in ", this.stats.time, "ms"]);
14416
+ }, [this.stats.numberOfResults, " results found in ", this.stats.time || 0, "ms"]);
14395
14417
  }
14396
14418
 
14397
14419
  return null;
@@ -14467,8 +14489,8 @@
14467
14489
  })]);
14468
14490
  },
14469
14491
  withClickIds: function withClickIds(results) {
14470
- var _this$getAllData2 = this.getAllData(),
14471
- base = _this$getAllData2.base;
14492
+ var _this$getAllData = this.getAllData(),
14493
+ base = _this$getAllData.base;
14472
14494
 
14473
14495
  return results.map(function (result, index) {
14474
14496
  return _extends({}, result, {
@@ -14486,26 +14508,9 @@
14486
14508
  hits = this.hits;
14487
14509
  var results = parseHits(hits) || [];
14488
14510
  var parsedPromotedResults = parseHits(promotedResults) || [];
14489
- var filteredResults = results;
14490
14511
  var base = currentPage * size;
14491
-
14492
- if (parsedPromotedResults.length) {
14493
- var ids = parsedPromotedResults.map(function (item) {
14494
- return item._id;
14495
- }).filter(Boolean);
14496
-
14497
- if (ids) {
14498
- filteredResults = filteredResults.filter(function (item) {
14499
- return !ids.includes(item._id);
14500
- });
14501
- }
14502
-
14503
- filteredResults = [].concat(parsedPromotedResults, filteredResults);
14504
- }
14505
-
14506
14512
  return {
14507
14513
  results: results,
14508
- filteredResults: filteredResults,
14509
14514
  customData: customData || {},
14510
14515
  promotedResults: parsedPromotedResults,
14511
14516
  aggregationData: aggregationData,
@@ -14515,16 +14520,15 @@
14515
14520
  };
14516
14521
  },
14517
14522
  getData: function getData() {
14518
- var _this$getAllData3 = this.getAllData(),
14519
- filteredResults = _this$getAllData3.filteredResults,
14520
- promotedResults = _this$getAllData3.promotedResults,
14521
- aggregationData = _this$getAllData3.aggregationData,
14522
- customData = _this$getAllData3.customData;
14523
+ var _this$getAllData2 = this.getAllData(),
14524
+ promotedResults = _this$getAllData2.promotedResults,
14525
+ aggregationData = _this$getAllData2.aggregationData,
14526
+ customData = _this$getAllData2.customData;
14523
14527
 
14524
14528
  return {
14525
- data: this.withClickIds(filteredResults),
14529
+ data: this.data,
14526
14530
  aggregationData: this.withClickIds(aggregationData || []),
14527
- promotedData: this.withClickIds(promotedResults),
14531
+ promotedData: this.withClickIds(promotedResults || []),
14528
14532
  rawData: this.rawData,
14529
14533
  resultStats: this.stats,
14530
14534
  customData: customData
@@ -14536,7 +14540,7 @@
14536
14540
 
14537
14541
  var data = _extends({
14538
14542
  error: error,
14539
- loading: isLoading,
14543
+ loading: isLoading || false,
14540
14544
  loadMore: this.loadMore,
14541
14545
  // TODO: Remove in v2
14542
14546
  triggerAnalytics: this.triggerClickAnalytics,
@@ -14551,13 +14555,13 @@
14551
14555
 
14552
14556
  var mapStateToProps$1 = function mapStateToProps(state, props) {
14553
14557
  return {
14554
- defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1 || -1,
14558
+ defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
14555
14559
  hits: state.hits[props.componentId] && state.hits[props.componentId].hits,
14556
14560
  rawData: state.rawData[props.componentId],
14557
- aggregationData: state.compositeAggregations[props.componentId] || [],
14558
- promotedResults: state.promotedResults[props.componentId] || [],
14561
+ aggregationData: state.compositeAggregations[props.componentId],
14562
+ promotedResults: state.promotedResults[props.componentId],
14559
14563
  customData: state.customData[props.componentId],
14560
- time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
14564
+ time: state.hits[props.componentId] && state.hits[props.componentId].time,
14561
14565
  total: state.hits[props.componentId] && state.hits[props.componentId].total,
14562
14566
  hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
14563
14567
  analytics: state.config && state.config.analytics,
@@ -14566,7 +14570,7 @@
14566
14570
  error: state.error[props.componentId],
14567
14571
  afterKey: state.aggregations[props.componentId] && state.aggregations[props.componentId][props.aggregationField] && state.aggregations[props.componentId][props.aggregationField].after_key,
14568
14572
  componentProps: state.props[props.componentId],
14569
- isLoading: state.isLoading[props.componentId] || false
14573
+ isLoading: state.isLoading[props.componentId]
14570
14574
  };
14571
14575
  };
14572
14576
 
@@ -15405,8 +15409,33 @@
15405
15409
  return encodedHeaders;
15406
15410
  }
15407
15411
 
15408
- function getTelemetryHeaders(enableTelemetry) {
15412
+ function getMongoRequest(app, mongo) {
15413
+ var mongodb = {};
15414
+
15415
+ if (app) {
15416
+ mongodb.index = app;
15417
+ }
15418
+
15419
+ if (mongo) {
15420
+ if (mongo.db) {
15421
+ mongodb.db = mongo.db;
15422
+ }
15423
+
15424
+ if (mongo.collection) {
15425
+ mongodb.collection = mongo.collection;
15426
+ }
15427
+ }
15428
+
15429
+ return mongodb;
15430
+ }
15431
+
15432
+ function getTelemetryHeaders(enableTelemetry, shouldSetHeaders) {
15409
15433
  var headers = {};
15434
+
15435
+ if (!shouldSetHeaders) {
15436
+ return headers;
15437
+ }
15438
+
15410
15439
  Object.assign(headers, {
15411
15440
  'X-Search-Client': 'Appbase JS'
15412
15441
  });
@@ -15419,6 +15448,133 @@
15419
15448
 
15420
15449
  return headers;
15421
15450
  }
15451
+
15452
+ var backendAlias = {
15453
+ MONGODB: 'mongodb',
15454
+ // mongodb
15455
+ ELASTICSEARCH: 'elasticsearch' // elasticsearch
15456
+
15457
+ };
15458
+ var dataTypes = {
15459
+ ARRAY: 'array',
15460
+ FUNCTION: 'function',
15461
+ OBJECT: 'object',
15462
+ NUMBER: 'number',
15463
+ BOOLEAN: 'boolean',
15464
+ STRING: 'string'
15465
+ };
15466
+
15467
+ var checkDataType = function checkDataType(temp) {
15468
+ // eslint-disable-next-line
15469
+ if ((typeof temp === 'undefined' ? 'undefined' : _typeof$1(temp)) === dataTypes.OBJECT) {
15470
+ if (Array.isArray(temp)) {
15471
+ return dataTypes.ARRAY;
15472
+ }
15473
+
15474
+ return dataTypes.OBJECT;
15475
+ }
15476
+
15477
+ return typeof temp === 'undefined' ? 'undefined' : _typeof$1(temp);
15478
+ };
15479
+
15480
+ function validateSchema() {
15481
+ var passedProperties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15482
+ var schema = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15483
+ var backendName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
15484
+ var passedPropertiesKeys = Object.keys(passedProperties).filter(function (propertyKey) {
15485
+ return !!passedProperties[propertyKey];
15486
+ });
15487
+ var acceptedProperties = Object.keys(schema);
15488
+ var requiredProperties = []; // fetch required properties
15489
+
15490
+ acceptedProperties.forEach(function (propName) {
15491
+ var currentProperty = schema[propName];
15492
+
15493
+ if (currentProperty.required) {
15494
+ requiredProperties.push(propName);
15495
+ }
15496
+ }); // check for required properties
15497
+
15498
+ requiredProperties.forEach(function (requiredProperty) {
15499
+ if (!passedPropertiesKeys.includes(requiredProperty)) {
15500
+ throw new Error(requiredProperty + ' is required when using the ' + backendName + ' Search backend.');
15501
+ }
15502
+ }); // check for accepted properties
15503
+
15504
+ passedPropertiesKeys.forEach(function (passedPropertyKey) {
15505
+ if (!acceptedProperties.includes(passedPropertyKey)) {
15506
+ throw new Error(passedPropertyKey + ' property isn\'t accepted property by ' + backendName + ' backend.');
15507
+ }
15508
+
15509
+ var acceptedTypes = Array.isArray(schema[passedPropertyKey].type) ? schema[passedPropertyKey].type : [].concat(schema[passedPropertyKey].type);
15510
+ var receivedPropertyType = checkDataType(passedProperties[passedPropertyKey]);
15511
+
15512
+ if (!acceptedTypes.includes(receivedPropertyType)) {
15513
+ throw new Error('The property ' + passedPropertyKey + ' is expected with type(s) [' + acceptedTypes.join(', ') + '], but type was set as ' + receivedPropertyType + '.');
15514
+ }
15515
+ });
15516
+ }
15517
+
15518
+ var mongodb = {
15519
+ url: {
15520
+ type: dataTypes.STRING,
15521
+ required: true
15522
+ },
15523
+ app: {
15524
+ type: dataTypes.STRING,
15525
+ required: false
15526
+ },
15527
+ credentials: {
15528
+ type: dataTypes.STRING,
15529
+ required: false
15530
+ },
15531
+ enableTelemetry: {
15532
+ type: dataTypes.BOOLEAN,
15533
+ required: false
15534
+ },
15535
+ mongodb: {
15536
+ type: dataTypes.OBJECT,
15537
+ required: true
15538
+ },
15539
+ username: {
15540
+ type: dataTypes.STRING,
15541
+ required: false
15542
+ },
15543
+ password: {
15544
+ type: dataTypes.STRING,
15545
+ required: false
15546
+ }
15547
+ };
15548
+ var elasticsearch = {
15549
+ url: {
15550
+ type: dataTypes.STRING,
15551
+ required: true
15552
+ },
15553
+ app: {
15554
+ type: dataTypes.STRING,
15555
+ required: true
15556
+ },
15557
+ credentials: {
15558
+ type: dataTypes.STRING,
15559
+ required: false
15560
+ },
15561
+ enableTelemetry: {
15562
+ type: dataTypes.BOOLEAN,
15563
+ required: false
15564
+ },
15565
+ username: {
15566
+ type: dataTypes.STRING,
15567
+ required: false
15568
+ },
15569
+ password: {
15570
+ type: dataTypes.STRING,
15571
+ required: false
15572
+ }
15573
+ };
15574
+ var SCHEMA = {
15575
+ mongodb: mongodb,
15576
+ elasticsearch: elasticsearch
15577
+ };
15422
15578
  /**
15423
15579
  * Returns an instance of Appbase client
15424
15580
  * @param {Object} config To configure properties
@@ -15428,10 +15584,10 @@
15428
15584
  * @param {String} config.username
15429
15585
  * @param {String} config.password
15430
15586
  * @param {Boolean} config.enableTelemetry
15587
+ * @param {Object} config.mongodb
15431
15588
  * A callback function which will be invoked before a fetch request made
15432
15589
  */
15433
15590
 
15434
-
15435
15591
  function AppBase(config) {
15436
15592
  var _URL = urlParserLite(config.url || ''),
15437
15593
  _URL$auth = _URL.auth,
@@ -15443,30 +15599,42 @@
15443
15599
  _URL$protocol = _URL.protocol,
15444
15600
  protocol = _URL$protocol === undefined ? '' : _URL$protocol;
15445
15601
 
15446
- var url = host + path; // Validate config and throw appropriate error
15602
+ var url = config.url;
15603
+ url = host + path; // Parse url
15447
15604
 
15448
- if (typeof url !== 'string' || url === '') {
15449
- throw new Error('URL not present in options.');
15605
+ if (url.slice(-1) === '/') {
15606
+ url = url.slice(0, -1);
15450
15607
  }
15451
15608
 
15452
- if (typeof config.app !== 'string' || config.app === '') {
15453
- throw new Error('App name is not present in options.');
15454
- }
15609
+ var backendName = backendAlias[config.mongodb ? 'MONGODB' : 'ELASTICSEARCH']; // eslint-disable-next-line
15610
+
15611
+ var schema = SCHEMA[backendName];
15612
+ validateSchema({
15613
+ url: config.url,
15614
+ app: config.app,
15615
+ credentials: config.credentials,
15616
+ username: config.username,
15617
+ password: config.password,
15618
+ enableTelemetry: config.enableTelemetry,
15619
+ mongodb: config.mongodb
15620
+ }, schema, backendName);
15455
15621
 
15456
15622
  if (typeof protocol !== 'string' || protocol === '') {
15457
15623
  throw new Error('Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io');
15458
- } // Parse url
15459
-
15460
-
15461
- if (url.slice(-1) === '/') {
15462
- url = url.slice(0, -1);
15463
15624
  }
15464
15625
 
15465
15626
  var credentials = auth || null;
15627
+
15628
+ if (!config.mongodb) {
15629
+ if (isAppbase(url) && credentials === null) {
15630
+ throw new Error('Authentication information is not present. Did you add credentials?');
15631
+ }
15632
+ }
15466
15633
  /**
15467
15634
  * Credentials can be provided as a part of the URL,
15468
15635
  * as username, password args or as a credentials argument directly */
15469
15636
 
15637
+
15470
15638
  if (typeof config.credentials === 'string' && config.credentials !== '') {
15471
15639
  // eslint-disable-next-line
15472
15640
  credentials = config.credentials;
@@ -15474,15 +15642,15 @@
15474
15642
  credentials = config.username + ':' + config.password;
15475
15643
  }
15476
15644
 
15477
- if (isAppbase(url) && credentials === null) {
15478
- throw new Error('Authentication information is not present. Did you add credentials?');
15479
- }
15480
-
15481
15645
  this.url = url;
15482
15646
  this.protocol = protocol;
15483
15647
  this.app = config.app;
15484
15648
  this.credentials = credentials;
15485
15649
 
15650
+ if (config.mongodb) {
15651
+ this.mongodb = config.mongodb;
15652
+ }
15653
+
15486
15654
  if (typeof config.enableTelemetry === 'boolean') {
15487
15655
  this.enableTelemetry = config.enableTelemetry;
15488
15656
  }
@@ -15511,7 +15679,9 @@
15511
15679
  params = parsedArgs.params,
15512
15680
  body = parsedArgs.body,
15513
15681
  isRSAPI = parsedArgs.isRSAPI,
15514
- isSuggestionsAPI = parsedArgs.isSuggestionsAPI;
15682
+ isSuggestionsAPI = parsedArgs.isSuggestionsAPI,
15683
+ _parsedArgs$isMongoRe = parsedArgs.isMongoRequest,
15684
+ isMongoRequest = _parsedArgs$isMongoRe === undefined ? false : _parsedArgs$isMongoRe;
15515
15685
  var app = isSuggestionsAPI ? '.suggestions' : _this.app;
15516
15686
  var bodyCopy = body;
15517
15687
  var contentType = path.endsWith('msearch') || path.endsWith('bulk') ? 'application/x-ndjson' : 'application/json';
@@ -15562,7 +15732,7 @@
15562
15732
  paramsString = '?' + querystring.stringify(params);
15563
15733
  }
15564
15734
 
15565
- var finalURL = _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString;
15735
+ var finalURL = isMongoRequest ? _this.protocol + '://' + _this.url : _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString;
15566
15736
  return handleTransformRequest(Object.assign({}, {
15567
15737
  url: finalURL
15568
15738
  }, requestOptions)).then(function (ts) {
@@ -15571,7 +15741,7 @@
15571
15741
  delete transformedRequest.url;
15572
15742
  return browserPonyfill$1(url || finalURL, Object.assign({}, transformedRequest, {
15573
15743
  // apply timestamp header for RS API
15574
- headers: isRSAPI ? Object.assign({}, transformedRequest.headers, {
15744
+ headers: isRSAPI && !isMongoRequest ? Object.assign({}, transformedRequest.headers, {
15575
15745
  'x-timestamp': new Date().getTime()
15576
15746
  }) : transformedRequest.headers
15577
15747
  })).then(function (res) {
@@ -15606,7 +15776,7 @@
15606
15776
  } // reject only when all responses has error
15607
15777
 
15608
15778
 
15609
- if (errorResponses > 0 && allResponses === errorResponses) {
15779
+ if (errorResponses > 0 && allResponses === errorResponses && !isMongoRequest) {
15610
15780
  return reject(data);
15611
15781
  }
15612
15782
  }
@@ -15936,12 +16106,20 @@
15936
16106
  settings: parsedSettings,
15937
16107
  query: query
15938
16108
  };
16109
+
16110
+ if (this.mongodb) {
16111
+ Object.assign(body, {
16112
+ mongodb: getMongoRequest(this.app, this.mongodb)
16113
+ });
16114
+ }
16115
+
15939
16116
  return this.performFetchRequest({
15940
16117
  method: 'POST',
15941
16118
  path: '_reactivesearch',
15942
16119
  body: body,
15943
- headers: getTelemetryHeaders(this.enableTelemetry),
15944
- isRSAPI: true
16120
+ headers: getTelemetryHeaders(this.enableTelemetry, !this.mongodb),
16121
+ isRSAPI: true,
16122
+ isMongoRequest: !!this.mongodb
15945
16123
  });
15946
16124
  }
15947
16125
  /**
@@ -15968,12 +16146,20 @@
15968
16146
  settings: parsedSettings,
15969
16147
  query: query
15970
16148
  };
16149
+
16150
+ if (this.mongodb) {
16151
+ Object.assign(body, {
16152
+ mongodb: getMongoRequest(this.app, this.mongodb)
16153
+ });
16154
+ }
16155
+
15971
16156
  return this.performFetchRequest({
15972
16157
  method: 'POST',
15973
16158
  path: '_reactivesearch.v3',
15974
16159
  body: body,
15975
- headers: getTelemetryHeaders(this.enableTelemetry),
15976
- isRSAPI: true
16160
+ headers: getTelemetryHeaders(this.enableTelemetry, !this.mongodb),
16161
+ isRSAPI: true,
16162
+ isMongoRequest: !!this.mongodb
15977
16163
  });
15978
16164
  }
15979
16165
  /**
@@ -16011,13 +16197,21 @@
16011
16197
  settings: parsedSettings,
16012
16198
  query: query
16013
16199
  };
16200
+
16201
+ if (this.mongodb) {
16202
+ Object.assign(body, {
16203
+ mongodb: getMongoRequest(this.app, this.mongodb)
16204
+ });
16205
+ }
16206
+
16014
16207
  return this.performFetchRequest({
16015
16208
  method: 'POST',
16016
16209
  path: '_reactivesearch.v3',
16017
16210
  body: body,
16018
16211
  headers: getTelemetryHeaders(this.enableTelemetry),
16019
16212
  isRSAPI: true,
16020
- isSuggestionsAPI: true
16213
+ isSuggestionsAPI: true,
16214
+ isMongoRequest: !!this.mongodb
16021
16215
  });
16022
16216
  }
16023
16217
 
@@ -16749,7 +16943,7 @@
16749
16943
  }
16750
16944
  },
16751
16945
  props: {
16752
- app: types.stringRequired,
16946
+ app: types.string,
16753
16947
  analytics: VueTypes.bool,
16754
16948
  analyticsConfig: types.analyticsConfig,
16755
16949
  appbaseConfig: types.appbaseConfig,
@@ -16769,7 +16963,8 @@
16769
16963
  transformResponse: types.func,
16770
16964
  as: VueTypes.string.def('div'),
16771
16965
  getSearchParams: types.func,
16772
- setSearchParams: types.func
16966
+ setSearchParams: types.func,
16967
+ mongodb: types.mongodb
16773
16968
  },
16774
16969
  provide: function provide() {
16775
16970
  return {
@@ -16809,6 +17004,9 @@
16809
17004
  this.store.dispatch(analytics_3$1(newVal));
16810
17005
  }
16811
17006
  }
17007
+ },
17008
+ mongodb: function mongodb() {
17009
+ this.updateState(this.$props);
16812
17010
  }
16813
17011
  },
16814
17012
  computed: {
@@ -16816,12 +17014,13 @@
16816
17014
  var _this$$props = this.$props,
16817
17015
  enableAppbase = _this$$props.enableAppbase,
16818
17016
  headers = _this$$props.headers,
16819
- appbaseConfig = _this$$props.appbaseConfig;
17017
+ appbaseConfig = _this$$props.appbaseConfig,
17018
+ mongodb = _this$$props.mongodb;
16820
17019
 
16821
17020
  var _ref = appbaseConfig || {},
16822
17021
  enableTelemetry = _ref.enableTelemetry;
16823
17022
 
16824
- return _extends({}, enableAppbase && _extends({
17023
+ return _extends({}, enableAppbase && !mongodb && _extends({
16825
17024
  'X-Search-Client': X_SEARCH_CLIENT
16826
17025
  }, enableTelemetry === false && {
16827
17026
  'X-Enable-Telemetry': false
@@ -16839,7 +17038,7 @@
16839
17038
  var appbaseConfig = _extends({}, props.analyticsConfig, props.appbaseConfig);
16840
17039
 
16841
17040
  var config = {
16842
- url: props.url && props.url.trim() !== '' ? props.url : 'https://scalr.api.appbase.io',
17041
+ url: props.url && props.url.trim() !== '' ? props.url : '',
16843
17042
  app: props.app,
16844
17043
  credentials: credentials,
16845
17044
  type: props.type ? props.type : '*',
@@ -16847,7 +17046,8 @@
16847
17046
  transformResponse: props.transformResponse,
16848
17047
  enableAppbase: props.enableAppbase,
16849
17048
  analytics: props.appbaseConfig ? props.appbaseConfig.recordAnalytics : props.analytics,
16850
- analyticsConfig: appbaseConfig
17049
+ analyticsConfig: appbaseConfig,
17050
+ mongodb: props.mongodb
16851
17051
  };
16852
17052
  var queryParams = '';
16853
17053
 
@@ -23497,9 +23697,15 @@
23497
23697
  this.setQueryOptions(componentId, _extends({}, customQueryOptions, this.getAggsQuery()), false);
23498
23698
  } else this.setQueryOptions(componentId, this.getAggsQuery(), false);
23499
23699
 
23700
+ var queryToSet = query || null;
23701
+
23702
+ if (calcCustomQuery && calcCustomQuery.id) {
23703
+ queryToSet = calcCustomQuery;
23704
+ }
23705
+
23500
23706
  this.updateQuery({
23501
23707
  componentId: componentId,
23502
- query: query,
23708
+ queryToSet: queryToSet,
23503
23709
  value: this.selectedValue || null,
23504
23710
  label: filterLabel,
23505
23711
  showFilter: showFilter,
@@ -23513,6 +23719,12 @@
23513
23719
 
23514
23720
  if (options) {
23515
23721
  _this.setQueryOptions(props.componentId, _extends({}, options, _this.getAggsQuery()), false);
23722
+ }
23723
+
23724
+ var queryToBeSet = obj.query; // when enableAppbase is true, Backend throws error because of repeated query in request body
23725
+
23726
+ if (obj && obj.query && obj.query.query) {
23727
+ queryToBeSet = obj.query.query;
23516
23728
  } // Update customQuery field for RS API
23517
23729
 
23518
23730
 
@@ -23520,7 +23732,11 @@
23520
23732
  var customQueryCalc = _extends({}, options);
23521
23733
 
23522
23734
  if (obj && obj.query) {
23523
- customQueryCalc.query = obj.query;
23735
+ if (obj.query.id) {
23736
+ customQueryCalc = queryToBeSet;
23737
+ } else {
23738
+ customQueryCalc.query = obj.query;
23739
+ }
23524
23740
  }
23525
23741
 
23526
23742
  _this.setCustomQuery(props.componentId, customQueryCalc);
@@ -23551,9 +23767,15 @@
23551
23767
  this.setQueryOptions(this.internalComponent, _extends({}, queryOptions, this.getAggsQuery()), false);
23552
23768
  } else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false);
23553
23769
 
23770
+ var queryToSet = query || null;
23771
+
23772
+ if (!queryToSet && this.$defaultQuery && this.$defaultQuery.id) {
23773
+ queryToSet = this.$defaultQuery;
23774
+ }
23775
+
23554
23776
  this.updateQuery({
23555
23777
  componentId: this.internalComponent,
23556
- query: query || null
23778
+ query: queryToSet
23557
23779
  });
23558
23780
  }
23559
23781
  },
@@ -23612,9 +23834,15 @@
23612
23834
 
23613
23835
 
23614
23836
  updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, undefined);
23837
+ var queryToSet = query || null;
23838
+
23839
+ if (!queryToSet && this.$defaultQuery && this.$defaultQuery.id) {
23840
+ queryToSet = this.$defaultQuery;
23841
+ }
23842
+
23615
23843
  this.updateQuery({
23616
23844
  componentId: this.internalComponent,
23617
- query: query || null
23845
+ query: queryToSet
23618
23846
  });
23619
23847
  }
23620
23848
  },
@@ -23633,9 +23861,15 @@
23633
23861
 
23634
23862
 
23635
23863
  updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, undefined);
23864
+ var queryToSet = query || null;
23865
+
23866
+ if (this.$customQuery && this.$customQuery.id) {
23867
+ queryToSet = this.$customQuery;
23868
+ }
23869
+
23636
23870
  this.updateQuery({
23637
23871
  componentId: componentId,
23638
- query: query || null
23872
+ query: queryToSet
23639
23873
  });
23640
23874
  }
23641
23875
  }
@@ -25520,7 +25754,7 @@
25520
25754
  watch: {
25521
25755
  searchState: function searchState(newVal, oldVal) {
25522
25756
  if (this.isStateChanged(newVal, oldVal)) {
25523
- this.$emit('change', newVal, oldVal);
25757
+ this.$emit('change', oldVal, newVal);
25524
25758
  }
25525
25759
  },
25526
25760
  selectedValues: function selectedValues(newVal, oldVal) {
@@ -25905,8 +26139,9 @@
25905
26139
  appbaseQuery = _extends({}, appbaseQuery, (_extends3 = {}, _extends3[component.componentId] = query, _extends3), transform_1(state, component.componentId, orderOfQueries));
25906
26140
  }
25907
26141
  } else {
26142
+ var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + "_" + component : component;
25908
26143
  finalQuery = [].concat(finalQuery, [{
25909
- preference: component.componentId
26144
+ preference: preference
25910
26145
  }, currentQuery]);
25911
26146
  }
25912
26147
  }
@@ -26060,7 +26295,7 @@
26060
26295
  });
26061
26296
  }
26062
26297
 
26063
- var version = "1.23.0";
26298
+ var version = "1.23.4-alpha";
26064
26299
 
26065
26300
  var _templateObject$n, _templateObject2$a;
26066
26301