@appbaseio/reactivesearch-vue 1.16.0-alpha.22 → 1.16.0-alpha.26

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 (57) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +335 -116
  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-d3c78c41.js → DropDown-323d7048.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/{Pagination-d4dbfd5a.js → Pagination-0b9ec0fc.js} +1 -1
  12. package/dist/cjs/RangeInput.js +1 -1
  13. package/dist/cjs/RangeSlider.js +1 -1
  14. package/dist/cjs/ReactiveBase.js +14 -8
  15. package/dist/cjs/ReactiveComponent.js +12 -12
  16. package/dist/cjs/ReactiveGoogleMap.js +2 -2
  17. package/dist/cjs/ReactiveList.js +58 -54
  18. package/dist/cjs/ResultCard.js +1 -1
  19. package/dist/cjs/ResultList.js +1 -1
  20. package/dist/cjs/SelectedFilters.js +1 -1
  21. package/dist/cjs/SingleDropdownList.js +2 -2
  22. package/dist/cjs/SingleList.js +1 -1
  23. package/dist/cjs/SingleRange.js +1 -1
  24. package/dist/cjs/StateProvider.js +1 -1
  25. package/dist/cjs/ToggleButton.js +1 -1
  26. package/dist/cjs/index.js +4 -4
  27. package/dist/cjs/initReactivesearch.js +15 -14
  28. package/dist/cjs/install.js +4 -4
  29. package/dist/cjs/version.js +1 -1
  30. package/dist/cjs/{vueTypes-409348b0.js → vueTypes-829a5f2c.js} +5 -1
  31. package/dist/es/DataSearch.js +2 -2
  32. package/dist/es/{DropDown-8894cc22.js → DropDown-c4ef3292.js} +1 -1
  33. package/dist/es/DynamicRangeSlider.js +1 -1
  34. package/dist/es/MultiDropdownList.js +2 -2
  35. package/dist/es/MultiList.js +1 -1
  36. package/dist/es/MultiRange.js +1 -1
  37. package/dist/es/{Pagination-a2ab7fcb.js → Pagination-e8216949.js} +1 -1
  38. package/dist/es/RangeInput.js +1 -1
  39. package/dist/es/RangeSlider.js +1 -1
  40. package/dist/es/ReactiveBase.js +14 -8
  41. package/dist/es/ReactiveComponent.js +12 -12
  42. package/dist/es/ReactiveGoogleMap.js +2 -2
  43. package/dist/es/ReactiveList.js +58 -54
  44. package/dist/es/ResultCard.js +1 -1
  45. package/dist/es/ResultList.js +1 -1
  46. package/dist/es/SelectedFilters.js +1 -1
  47. package/dist/es/SingleDropdownList.js +2 -2
  48. package/dist/es/SingleList.js +1 -1
  49. package/dist/es/SingleRange.js +1 -1
  50. package/dist/es/StateProvider.js +1 -1
  51. package/dist/es/ToggleButton.js +1 -1
  52. package/dist/es/index.js +4 -4
  53. package/dist/es/initReactivesearch.js +15 -14
  54. package/dist/es/install.js +4 -4
  55. package/dist/es/version.js +1 -1
  56. package/dist/es/{vueTypes-a9b9d5c9.js → vueTypes-98819a12.js} +5 -1
  57. package/package.json +3 -3
@@ -5521,7 +5521,7 @@
5521
5521
  }, size > 0 ? {
5522
5522
  numberOfPages: Math.ceil(total / size)
5523
5523
  } : null, {
5524
- time: time,
5524
+ time: time || 0,
5525
5525
  hidden: hidden,
5526
5526
  promoted: promotedResults && promotedResults.length
5527
5527
  });
@@ -8402,6 +8402,11 @@
8402
8402
  var value = internalValue && internalValue.value || '';
8403
8403
 
8404
8404
  if (isAppbaseEnabled && (componentProps.enablePopularSuggestions || componentProps.enableQuerySuggestions)) {
8405
+ if (config.mongodb) {
8406
+ dispatch((0, misc.setDefaultPopularSuggestions)([], componentId.split('__internal')[0]));
8407
+ return;
8408
+ }
8409
+
8405
8410
  var suggQuery = (0, utils.getSuggestionQuery)(getState, componentId);
8406
8411
  appbaseRef.getQuerySuggestions(suggQuery).then(function (suggestions) {
8407
8412
  var querySuggestion = suggestions[(0, utils.getQuerySuggestionsId)(componentId)];
@@ -8725,8 +8730,9 @@
8725
8730
  }
8726
8731
  }
8727
8732
  } else {
8733
+ var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + '_' + component : component;
8728
8734
  finalQuery = [].concat(_toConsumableArray(finalQuery), [{
8729
- preference: component
8735
+ preference: preference
8730
8736
  }, currentQuery]);
8731
8737
  }
8732
8738
  }
@@ -8931,8 +8937,9 @@
8931
8937
  appendToAggs: appendToAggs
8932
8938
  }));
8933
8939
  } else {
8940
+ var preference = store.config && store.config.analyticsConfig && store.config.analyticsConfig.userId ? store.config.analyticsConfig.userId + '_' + component : component;
8934
8941
  var _finalQuery = [{
8935
- preference: component
8942
+ preference: preference
8936
8943
  }, currentQuery];
8937
8944
  dispatch(msearch(_finalQuery, [component], appendToHits, false, appendToAggs));
8938
8945
  }
@@ -9130,7 +9137,8 @@
9130
9137
  protocol = _getState$appbaseRef.protocol,
9131
9138
  credentials = _getState$appbaseRef.credentials;
9132
9139
 
9133
- var app = config.app;
9140
+ var app = config.app,
9141
+ mongodb = config.mongodb;
9134
9142
  var esURL = protocol + '://' + url;
9135
9143
  var parsedURL = (esURL || '').replace(/\/+$/, '');
9136
9144
  var requestOptions = {
@@ -9177,7 +9185,14 @@
9177
9185
  }
9178
9186
  }
9179
9187
 
9180
- fetch(parsedURL + '/_analytics/' + app + '/recent-searches?' + queryString, requestOptions).then(function (res) {
9188
+ if (mongodb) {
9189
+ return dispatch({
9190
+ type: constants.RECENT_SEARCHES_SUCCESS,
9191
+ data: []
9192
+ });
9193
+ }
9194
+
9195
+ return fetch(parsedURL + '/_analytics/' + app + '/recent-searches?' + queryString, requestOptions).then(function (res) {
9181
9196
  if (res.status >= 500 || res.status >= 400) {
9182
9197
  return dispatch({
9183
9198
  type: constants.RECENT_SEARCHES_ERROR,
@@ -12809,7 +12824,11 @@
12809
12824
  userId: VueTypes.string,
12810
12825
  customEvents: VueTypes.object,
12811
12826
  enableTelemetry: VueTypes.bool.def(true)
12812
- }).def({})
12827
+ }).def({}),
12828
+ mongodb: VueTypes.shape({
12829
+ db: VueTypes.string,
12830
+ collection: VueTypes.string
12831
+ })
12813
12832
  };
12814
12833
 
12815
12834
  var getClassName = lib_8.getClassName,
@@ -13913,18 +13932,17 @@
13913
13932
  ResultCardsWrapper: ResultCardsWrapper
13914
13933
  },
13915
13934
  data: function data() {
13916
- var props = this.$props;
13917
13935
  var currentPageState = 0;
13936
+ var defaultPage = this.defaultPage || -1;
13918
13937
 
13919
- if (props.defaultPage >= 0) {
13920
- currentPageState = props.defaultPage;
13921
- } else if (props.currentPage) {
13922
- currentPageState = Math.max(props.currentPage - 1, 0);
13938
+ if (defaultPage >= 0) {
13939
+ currentPageState = defaultPage;
13940
+ } else if (this.currentPage) {
13941
+ currentPageState = Math.max(this.currentPage - 1, 0);
13923
13942
  }
13924
13943
 
13925
13944
  this.__state = {
13926
- from: currentPageState * props.size,
13927
- isLoading: true,
13945
+ from: currentPageState * this.size,
13928
13946
  currentPageState: currentPageState
13929
13947
  };
13930
13948
  return this.__state;
@@ -13953,8 +13971,10 @@
13953
13971
  console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
13954
13972
  }
13955
13973
 
13956
- if (this.defaultPage >= 0) {
13957
- this.currentPageState = this.defaultPage;
13974
+ var defaultPage = this.defaultPage || -1;
13975
+
13976
+ if (defaultPage >= 0) {
13977
+ this.currentPageState = defaultPage;
13958
13978
  this.from = this.currentPageState * this.$props.size;
13959
13979
  }
13960
13980
 
@@ -14021,12 +14041,9 @@
14021
14041
  return this.$listeners && this.$listeners.resultStats;
14022
14042
  },
14023
14043
  stats: function stats() {
14024
- var _this$getAllData = this.getAllData(),
14025
- filteredResults = _this$getAllData.filteredResults;
14026
-
14027
14044
  return _extends({}, getResultStats(this), {
14028
14045
  currentPage: this.currentPageState,
14029
- displayedResults: filteredResults.length
14046
+ displayedResults: this.data.length
14030
14047
  });
14031
14048
  },
14032
14049
  hasCustomRender: function hasCustomRender() {
@@ -14035,6 +14052,27 @@
14035
14052
  showInfiniteScroll: function showInfiniteScroll() {
14036
14053
  // Pagination has higher priority then infinite scroll
14037
14054
  return this.infiniteScroll && !this.shouldRenderPagination;
14055
+ },
14056
+ data: function data() {
14057
+ var results = parseHits(this.hits) || [];
14058
+ var parsedPromotedResults = parseHits(this.promotedResults) || [];
14059
+ var filteredResults = results;
14060
+
14061
+ if (parsedPromotedResults.length) {
14062
+ var ids = parsedPromotedResults.map(function (item) {
14063
+ return item._id;
14064
+ }).filter(Boolean);
14065
+
14066
+ if (ids) {
14067
+ filteredResults = filteredResults.filter(function (item) {
14068
+ return !ids.includes(item._id);
14069
+ });
14070
+ }
14071
+
14072
+ filteredResults = [].concat(parsedPromotedResults, filteredResults);
14073
+ }
14074
+
14075
+ return helper_2(filteredResults);
14038
14076
  }
14039
14077
  },
14040
14078
  watch: {
@@ -14116,7 +14154,7 @@
14116
14154
  }
14117
14155
  },
14118
14156
  hits: function hits(newVal, oldVal) {
14119
- this.$emit('data', this.getAllData());
14157
+ this.$emit('data', this.getData());
14120
14158
 
14121
14159
  if (this.shouldRenderPagination) {
14122
14160
  // called when page is changed
@@ -14301,13 +14339,10 @@
14301
14339
 
14302
14340
  var h = this.$createElement;
14303
14341
  var size = this.$props.size;
14304
- var hits = this.$data.hits;
14305
- var results = parseHits(hits) || [];
14306
- var filteredResults = results;
14307
14342
  var renderItem = this.$scopedSlots.renderItem || this.$props.renderItem;
14308
14343
  var element = this.hasCustomRender ? this.getComponent() : h("div", {
14309
14344
  "class": this.$props.listClass + " " + getClassName$1(this.$props.innerClass, 'list')
14310
- }, [[].concat(filteredResults).map(function (item, index) {
14345
+ }, [this.data.map(function (item, index) {
14311
14346
  return renderItem({
14312
14347
  item: item,
14313
14348
  triggerClickAnalytics: function triggerClickAnalytics() {
@@ -14318,7 +14353,7 @@
14318
14353
 
14319
14354
  return this.analytics ? h(ImpressionTracker$1, {
14320
14355
  "attrs": {
14321
- "hits": filteredResults
14356
+ "hits": this.data
14322
14357
  }
14323
14358
  }, [element]) : element;
14324
14359
  },
@@ -14422,7 +14457,7 @@
14422
14457
  if (this.stats.numberOfResults) {
14423
14458
  return h("p", {
14424
14459
  "class": resultStats + " " + getClassName$1(this.$props.innerClass, 'resultStats')
14425
- }, [this.stats.numberOfResults, " results found in ", this.stats.time, "ms"]);
14460
+ }, [this.stats.numberOfResults, " results found in ", this.stats.time || 0, "ms"]);
14426
14461
  }
14427
14462
 
14428
14463
  return null;
@@ -14430,6 +14465,11 @@
14430
14465
  renderNoResult: function renderNoResult() {
14431
14466
  var h = this.$createElement;
14432
14467
  var renderNoResults = this.$scopedSlots.renderNoResults || this.$props.renderNoResults;
14468
+
14469
+ if (this.$scopedSlots.renderNoResults) {
14470
+ return isFunction$1(renderNoResults) ? renderNoResults() : renderNoResults;
14471
+ }
14472
+
14433
14473
  return h("p", {
14434
14474
  "class": getClassName$1(this.$props.innerClass, 'noResults') || null
14435
14475
  }, [isFunction$1(renderNoResults) ? renderNoResults() : renderNoResults]);
@@ -14498,8 +14538,8 @@
14498
14538
  })]);
14499
14539
  },
14500
14540
  withClickIds: function withClickIds(results) {
14501
- var _this$getAllData2 = this.getAllData(),
14502
- base = _this$getAllData2.base;
14541
+ var _this$getAllData = this.getAllData(),
14542
+ base = _this$getAllData.base;
14503
14543
 
14504
14544
  return results.map(function (result, index) {
14505
14545
  return _extends({}, result, {
@@ -14517,26 +14557,9 @@
14517
14557
  hits = this.hits;
14518
14558
  var results = parseHits(hits) || [];
14519
14559
  var parsedPromotedResults = parseHits(promotedResults) || [];
14520
- var filteredResults = results;
14521
14560
  var base = currentPage * size;
14522
-
14523
- if (parsedPromotedResults.length) {
14524
- var ids = parsedPromotedResults.map(function (item) {
14525
- return item._id;
14526
- }).filter(Boolean);
14527
-
14528
- if (ids) {
14529
- filteredResults = filteredResults.filter(function (item) {
14530
- return !ids.includes(item._id);
14531
- });
14532
- }
14533
-
14534
- filteredResults = [].concat(parsedPromotedResults, filteredResults);
14535
- }
14536
-
14537
14561
  return {
14538
14562
  results: results,
14539
- filteredResults: filteredResults,
14540
14563
  customData: customData || {},
14541
14564
  promotedResults: parsedPromotedResults,
14542
14565
  aggregationData: aggregationData,
@@ -14546,16 +14569,15 @@
14546
14569
  };
14547
14570
  },
14548
14571
  getData: function getData() {
14549
- var _this$getAllData3 = this.getAllData(),
14550
- filteredResults = _this$getAllData3.filteredResults,
14551
- promotedResults = _this$getAllData3.promotedResults,
14552
- aggregationData = _this$getAllData3.aggregationData,
14553
- customData = _this$getAllData3.customData;
14572
+ var _this$getAllData2 = this.getAllData(),
14573
+ promotedResults = _this$getAllData2.promotedResults,
14574
+ aggregationData = _this$getAllData2.aggregationData,
14575
+ customData = _this$getAllData2.customData;
14554
14576
 
14555
14577
  return {
14556
- data: this.withClickIds(filteredResults),
14578
+ data: this.data,
14557
14579
  aggregationData: this.withClickIds(aggregationData || []),
14558
- promotedData: this.withClickIds(promotedResults),
14580
+ promotedData: this.withClickIds(promotedResults || []),
14559
14581
  rawData: this.rawData,
14560
14582
  resultStats: this.stats,
14561
14583
  customData: customData
@@ -14567,7 +14589,7 @@
14567
14589
 
14568
14590
  var data = _extends({
14569
14591
  error: error,
14570
- loading: isLoading,
14592
+ loading: isLoading || false,
14571
14593
  loadMore: this.loadMore,
14572
14594
  // TODO: Remove in v2
14573
14595
  triggerAnalytics: this.triggerClickAnalytics,
@@ -14582,13 +14604,13 @@
14582
14604
 
14583
14605
  var mapStateToProps$1 = function mapStateToProps(state, props) {
14584
14606
  return {
14585
- defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1 || -1,
14607
+ defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
14586
14608
  hits: state.hits[props.componentId] && state.hits[props.componentId].hits,
14587
14609
  rawData: state.rawData[props.componentId],
14588
- aggregationData: state.compositeAggregations[props.componentId] || [],
14589
- promotedResults: state.promotedResults[props.componentId] || [],
14610
+ aggregationData: state.compositeAggregations[props.componentId],
14611
+ promotedResults: state.promotedResults[props.componentId],
14590
14612
  customData: state.customData[props.componentId],
14591
- time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
14613
+ time: state.hits[props.componentId] && state.hits[props.componentId].time,
14592
14614
  total: state.hits[props.componentId] && state.hits[props.componentId].total,
14593
14615
  hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
14594
14616
  analytics: state.config && state.config.analytics,
@@ -14597,7 +14619,7 @@
14597
14619
  error: state.error[props.componentId],
14598
14620
  afterKey: state.aggregations[props.componentId] && state.aggregations[props.componentId][props.aggregationField] && state.aggregations[props.componentId][props.aggregationField].after_key,
14599
14621
  componentProps: state.props[props.componentId],
14600
- isLoading: state.isLoading[props.componentId] || false
14622
+ isLoading: state.isLoading[props.componentId]
14601
14623
  };
14602
14624
  };
14603
14625
 
@@ -15436,8 +15458,33 @@
15436
15458
  return encodedHeaders;
15437
15459
  }
15438
15460
 
15439
- function getTelemetryHeaders(enableTelemetry) {
15461
+ function getMongoRequest(app, mongo) {
15462
+ var mongodb = {};
15463
+
15464
+ if (app) {
15465
+ mongodb.index = app;
15466
+ }
15467
+
15468
+ if (mongo) {
15469
+ if (mongo.db) {
15470
+ mongodb.db = mongo.db;
15471
+ }
15472
+
15473
+ if (mongo.collection) {
15474
+ mongodb.collection = mongo.collection;
15475
+ }
15476
+ }
15477
+
15478
+ return mongodb;
15479
+ }
15480
+
15481
+ function getTelemetryHeaders(enableTelemetry, shouldSetHeaders) {
15440
15482
  var headers = {};
15483
+
15484
+ if (!shouldSetHeaders) {
15485
+ return headers;
15486
+ }
15487
+
15441
15488
  Object.assign(headers, {
15442
15489
  'X-Search-Client': 'Appbase JS'
15443
15490
  });
@@ -15450,6 +15497,133 @@
15450
15497
 
15451
15498
  return headers;
15452
15499
  }
15500
+
15501
+ var backendAlias = {
15502
+ MONGODB: 'mongodb',
15503
+ // mongodb
15504
+ ELASTICSEARCH: 'elasticsearch' // elasticsearch
15505
+
15506
+ };
15507
+ var dataTypes = {
15508
+ ARRAY: 'array',
15509
+ FUNCTION: 'function',
15510
+ OBJECT: 'object',
15511
+ NUMBER: 'number',
15512
+ BOOLEAN: 'boolean',
15513
+ STRING: 'string'
15514
+ };
15515
+
15516
+ var checkDataType = function checkDataType(temp) {
15517
+ // eslint-disable-next-line
15518
+ if ((typeof temp === 'undefined' ? 'undefined' : _typeof$1(temp)) === dataTypes.OBJECT) {
15519
+ if (Array.isArray(temp)) {
15520
+ return dataTypes.ARRAY;
15521
+ }
15522
+
15523
+ return dataTypes.OBJECT;
15524
+ }
15525
+
15526
+ return typeof temp === 'undefined' ? 'undefined' : _typeof$1(temp);
15527
+ };
15528
+
15529
+ function validateSchema() {
15530
+ var passedProperties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15531
+ var schema = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15532
+ var backendName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
15533
+ var passedPropertiesKeys = Object.keys(passedProperties).filter(function (propertyKey) {
15534
+ return !!passedProperties[propertyKey];
15535
+ });
15536
+ var acceptedProperties = Object.keys(schema);
15537
+ var requiredProperties = []; // fetch required properties
15538
+
15539
+ acceptedProperties.forEach(function (propName) {
15540
+ var currentProperty = schema[propName];
15541
+
15542
+ if (currentProperty.required) {
15543
+ requiredProperties.push(propName);
15544
+ }
15545
+ }); // check for required properties
15546
+
15547
+ requiredProperties.forEach(function (requiredProperty) {
15548
+ if (!passedPropertiesKeys.includes(requiredProperty)) {
15549
+ throw new Error(requiredProperty + ' is required when using the ' + backendName + ' Search backend.');
15550
+ }
15551
+ }); // check for accepted properties
15552
+
15553
+ passedPropertiesKeys.forEach(function (passedPropertyKey) {
15554
+ if (!acceptedProperties.includes(passedPropertyKey)) {
15555
+ throw new Error(passedPropertyKey + ' property isn\'t accepted property by ' + backendName + ' backend.');
15556
+ }
15557
+
15558
+ var acceptedTypes = Array.isArray(schema[passedPropertyKey].type) ? schema[passedPropertyKey].type : [].concat(schema[passedPropertyKey].type);
15559
+ var receivedPropertyType = checkDataType(passedProperties[passedPropertyKey]);
15560
+
15561
+ if (!acceptedTypes.includes(receivedPropertyType)) {
15562
+ throw new Error('The property ' + passedPropertyKey + ' is expected with type(s) [' + acceptedTypes.join(', ') + '], but type was set as ' + receivedPropertyType + '.');
15563
+ }
15564
+ });
15565
+ }
15566
+
15567
+ var mongodb = {
15568
+ url: {
15569
+ type: dataTypes.STRING,
15570
+ required: true
15571
+ },
15572
+ app: {
15573
+ type: dataTypes.STRING,
15574
+ required: false
15575
+ },
15576
+ credentials: {
15577
+ type: dataTypes.STRING,
15578
+ required: false
15579
+ },
15580
+ enableTelemetry: {
15581
+ type: dataTypes.BOOLEAN,
15582
+ required: false
15583
+ },
15584
+ mongodb: {
15585
+ type: dataTypes.OBJECT,
15586
+ required: true
15587
+ },
15588
+ username: {
15589
+ type: dataTypes.STRING,
15590
+ required: false
15591
+ },
15592
+ password: {
15593
+ type: dataTypes.STRING,
15594
+ required: false
15595
+ }
15596
+ };
15597
+ var elasticsearch = {
15598
+ url: {
15599
+ type: dataTypes.STRING,
15600
+ required: true
15601
+ },
15602
+ app: {
15603
+ type: dataTypes.STRING,
15604
+ required: true
15605
+ },
15606
+ credentials: {
15607
+ type: dataTypes.STRING,
15608
+ required: false
15609
+ },
15610
+ enableTelemetry: {
15611
+ type: dataTypes.BOOLEAN,
15612
+ required: false
15613
+ },
15614
+ username: {
15615
+ type: dataTypes.STRING,
15616
+ required: false
15617
+ },
15618
+ password: {
15619
+ type: dataTypes.STRING,
15620
+ required: false
15621
+ }
15622
+ };
15623
+ var SCHEMA = {
15624
+ mongodb: mongodb,
15625
+ elasticsearch: elasticsearch
15626
+ };
15453
15627
  /**
15454
15628
  * Returns an instance of Appbase client
15455
15629
  * @param {Object} config To configure properties
@@ -15459,10 +15633,10 @@
15459
15633
  * @param {String} config.username
15460
15634
  * @param {String} config.password
15461
15635
  * @param {Boolean} config.enableTelemetry
15636
+ * @param {Object} config.mongodb
15462
15637
  * A callback function which will be invoked before a fetch request made
15463
15638
  */
15464
15639
 
15465
-
15466
15640
  function AppBase(config) {
15467
15641
  var _URL = urlParserLite(config.url || ''),
15468
15642
  _URL$auth = _URL.auth,
@@ -15474,30 +15648,42 @@
15474
15648
  _URL$protocol = _URL.protocol,
15475
15649
  protocol = _URL$protocol === undefined ? '' : _URL$protocol;
15476
15650
 
15477
- var url = host + path; // Validate config and throw appropriate error
15651
+ var url = config.url;
15652
+ url = host + path; // Parse url
15478
15653
 
15479
- if (typeof url !== 'string' || url === '') {
15480
- throw new Error('URL not present in options.');
15654
+ if (url.slice(-1) === '/') {
15655
+ url = url.slice(0, -1);
15481
15656
  }
15482
15657
 
15483
- if (typeof config.app !== 'string' || config.app === '') {
15484
- throw new Error('App name is not present in options.');
15485
- }
15658
+ var backendName = backendAlias[config.mongodb ? 'MONGODB' : 'ELASTICSEARCH']; // eslint-disable-next-line
15659
+
15660
+ var schema = SCHEMA[backendName];
15661
+ validateSchema({
15662
+ url: config.url,
15663
+ app: config.app,
15664
+ credentials: config.credentials,
15665
+ username: config.username,
15666
+ password: config.password,
15667
+ enableTelemetry: config.enableTelemetry,
15668
+ mongodb: config.mongodb
15669
+ }, schema, backendName);
15486
15670
 
15487
15671
  if (typeof protocol !== 'string' || protocol === '') {
15488
15672
  throw new Error('Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io');
15489
- } // Parse url
15490
-
15491
-
15492
- if (url.slice(-1) === '/') {
15493
- url = url.slice(0, -1);
15494
15673
  }
15495
15674
 
15496
15675
  var credentials = auth || null;
15676
+
15677
+ if (!config.mongodb) {
15678
+ if (isAppbase(url) && credentials === null) {
15679
+ throw new Error('Authentication information is not present. Did you add credentials?');
15680
+ }
15681
+ }
15497
15682
  /**
15498
15683
  * Credentials can be provided as a part of the URL,
15499
15684
  * as username, password args or as a credentials argument directly */
15500
15685
 
15686
+
15501
15687
  if (typeof config.credentials === 'string' && config.credentials !== '') {
15502
15688
  // eslint-disable-next-line
15503
15689
  credentials = config.credentials;
@@ -15505,15 +15691,15 @@
15505
15691
  credentials = config.username + ':' + config.password;
15506
15692
  }
15507
15693
 
15508
- if (isAppbase(url) && credentials === null) {
15509
- throw new Error('Authentication information is not present. Did you add credentials?');
15510
- }
15511
-
15512
15694
  this.url = url;
15513
15695
  this.protocol = protocol;
15514
15696
  this.app = config.app;
15515
15697
  this.credentials = credentials;
15516
15698
 
15699
+ if (config.mongodb) {
15700
+ this.mongodb = config.mongodb;
15701
+ }
15702
+
15517
15703
  if (typeof config.enableTelemetry === 'boolean') {
15518
15704
  this.enableTelemetry = config.enableTelemetry;
15519
15705
  }
@@ -15542,7 +15728,9 @@
15542
15728
  params = parsedArgs.params,
15543
15729
  body = parsedArgs.body,
15544
15730
  isRSAPI = parsedArgs.isRSAPI,
15545
- isSuggestionsAPI = parsedArgs.isSuggestionsAPI;
15731
+ isSuggestionsAPI = parsedArgs.isSuggestionsAPI,
15732
+ _parsedArgs$isMongoRe = parsedArgs.isMongoRequest,
15733
+ isMongoRequest = _parsedArgs$isMongoRe === undefined ? false : _parsedArgs$isMongoRe;
15546
15734
  var app = isSuggestionsAPI ? '.suggestions' : _this.app;
15547
15735
  var bodyCopy = body;
15548
15736
  var contentType = path.endsWith('msearch') || path.endsWith('bulk') ? 'application/x-ndjson' : 'application/json';
@@ -15593,7 +15781,7 @@
15593
15781
  paramsString = '?' + querystring.stringify(params);
15594
15782
  }
15595
15783
 
15596
- var finalURL = _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString;
15784
+ var finalURL = isMongoRequest ? _this.protocol + '://' + _this.url : _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString;
15597
15785
  return handleTransformRequest(Object.assign({}, {
15598
15786
  url: finalURL
15599
15787
  }, requestOptions)).then(function (ts) {
@@ -15602,7 +15790,7 @@
15602
15790
  delete transformedRequest.url;
15603
15791
  return browserPonyfill$1(url || finalURL, Object.assign({}, transformedRequest, {
15604
15792
  // apply timestamp header for RS API
15605
- headers: isRSAPI ? Object.assign({}, transformedRequest.headers, {
15793
+ headers: isRSAPI && !isMongoRequest ? Object.assign({}, transformedRequest.headers, {
15606
15794
  'x-timestamp': new Date().getTime()
15607
15795
  }) : transformedRequest.headers
15608
15796
  })).then(function (res) {
@@ -15630,7 +15818,7 @@
15630
15818
 
15631
15819
  if (data) {
15632
15820
  Object.keys(data).forEach(function (key) {
15633
- if (data[key] && Object.prototype.hasOwnProperty.call(data[key], 'error')) {
15821
+ if (data[key] && Object.prototype.hasOwnProperty.call(data[key], 'error') && !!data[key].error) {
15634
15822
  errorResponses += 1;
15635
15823
  }
15636
15824
  });
@@ -15967,12 +16155,20 @@
15967
16155
  settings: parsedSettings,
15968
16156
  query: query
15969
16157
  };
16158
+
16159
+ if (this.mongodb) {
16160
+ Object.assign(body, {
16161
+ mongodb: getMongoRequest(this.app, this.mongodb)
16162
+ });
16163
+ }
16164
+
15970
16165
  return this.performFetchRequest({
15971
16166
  method: 'POST',
15972
16167
  path: '_reactivesearch',
15973
16168
  body: body,
15974
- headers: getTelemetryHeaders(this.enableTelemetry),
15975
- isRSAPI: true
16169
+ headers: getTelemetryHeaders(this.enableTelemetry, !this.mongodb),
16170
+ isRSAPI: true,
16171
+ isMongoRequest: !!this.mongodb
15976
16172
  });
15977
16173
  }
15978
16174
  /**
@@ -15999,12 +16195,20 @@
15999
16195
  settings: parsedSettings,
16000
16196
  query: query
16001
16197
  };
16198
+
16199
+ if (this.mongodb) {
16200
+ Object.assign(body, {
16201
+ mongodb: getMongoRequest(this.app, this.mongodb)
16202
+ });
16203
+ }
16204
+
16002
16205
  return this.performFetchRequest({
16003
16206
  method: 'POST',
16004
16207
  path: '_reactivesearch.v3',
16005
16208
  body: body,
16006
- headers: getTelemetryHeaders(this.enableTelemetry),
16007
- isRSAPI: true
16209
+ headers: getTelemetryHeaders(this.enableTelemetry, !this.mongodb),
16210
+ isRSAPI: true,
16211
+ isMongoRequest: !!this.mongodb
16008
16212
  });
16009
16213
  }
16010
16214
  /**
@@ -16042,13 +16246,21 @@
16042
16246
  settings: parsedSettings,
16043
16247
  query: query
16044
16248
  };
16249
+
16250
+ if (this.mongodb) {
16251
+ Object.assign(body, {
16252
+ mongodb: getMongoRequest(this.app, this.mongodb)
16253
+ });
16254
+ }
16255
+
16045
16256
  return this.performFetchRequest({
16046
16257
  method: 'POST',
16047
16258
  path: '_reactivesearch.v3',
16048
16259
  body: body,
16049
16260
  headers: getTelemetryHeaders(this.enableTelemetry),
16050
16261
  isRSAPI: true,
16051
- isSuggestionsAPI: true
16262
+ isSuggestionsAPI: true,
16263
+ isMongoRequest: !!this.mongodb
16052
16264
  });
16053
16265
  }
16054
16266
 
@@ -16781,7 +16993,7 @@
16781
16993
  }
16782
16994
  },
16783
16995
  props: {
16784
- app: types.stringRequired,
16996
+ app: types.string,
16785
16997
  analytics: VueTypes.bool,
16786
16998
  analyticsConfig: types.analyticsConfig,
16787
16999
  appbaseConfig: types.appbaseConfig,
@@ -16801,7 +17013,8 @@
16801
17013
  transformResponse: types.func,
16802
17014
  as: VueTypes.string.def('div'),
16803
17015
  getSearchParams: types.func,
16804
- setSearchParams: types.func
17016
+ setSearchParams: types.func,
17017
+ mongodb: types.mongodb
16805
17018
  },
16806
17019
  provide: function provide() {
16807
17020
  return {
@@ -16841,6 +17054,9 @@
16841
17054
  this.store.dispatch(analytics_3$1(newVal));
16842
17055
  }
16843
17056
  }
17057
+ },
17058
+ mongodb: function mongodb() {
17059
+ this.updateState(this.$props);
16844
17060
  }
16845
17061
  },
16846
17062
  computed: {
@@ -16848,12 +17064,13 @@
16848
17064
  var _this$$props = this.$props,
16849
17065
  enableAppbase = _this$$props.enableAppbase,
16850
17066
  headers = _this$$props.headers,
16851
- appbaseConfig = _this$$props.appbaseConfig;
17067
+ appbaseConfig = _this$$props.appbaseConfig,
17068
+ mongodb = _this$$props.mongodb;
16852
17069
 
16853
17070
  var _ref = appbaseConfig || {},
16854
17071
  enableTelemetry = _ref.enableTelemetry;
16855
17072
 
16856
- return _extends({}, enableAppbase && _extends({
17073
+ return _extends({}, enableAppbase && !mongodb && _extends({
16857
17074
  'X-Search-Client': X_SEARCH_CLIENT
16858
17075
  }, enableTelemetry === false && {
16859
17076
  'X-Enable-Telemetry': false
@@ -16871,7 +17088,7 @@
16871
17088
  var appbaseConfig = _extends({}, props.analyticsConfig, props.appbaseConfig);
16872
17089
 
16873
17090
  var config = {
16874
- url: props.url && props.url.trim() !== '' ? props.url : 'https://scalr.api.appbase.io',
17091
+ url: props.url && props.url.trim() !== '' ? props.url : '',
16875
17092
  app: props.app,
16876
17093
  credentials: credentials,
16877
17094
  type: props.type ? props.type : '*',
@@ -16879,7 +17096,8 @@
16879
17096
  transformResponse: props.transformResponse,
16880
17097
  enableAppbase: props.enableAppbase,
16881
17098
  analytics: props.appbaseConfig ? props.appbaseConfig.recordAnalytics : props.analytics,
16882
- analyticsConfig: appbaseConfig
17099
+ analyticsConfig: appbaseConfig,
17100
+ mongodb: props.mongodb
16883
17101
  };
16884
17102
  var queryParams = '';
16885
17103
 
@@ -23495,7 +23713,7 @@
23495
23713
  this.internalComponent = null;
23496
23714
  this.$defaultQuery = null; // Set custom query in store
23497
23715
 
23498
- updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, undefined);
23716
+ updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
23499
23717
  var customQuery = props.customQuery,
23500
23718
  componentId = props.componentId,
23501
23719
  filterLabel = props.filterLabel,
@@ -23518,7 +23736,7 @@
23518
23736
  }
23519
23737
 
23520
23738
  if (customQuery) {
23521
- var calcCustomQuery = customQuery(props);
23739
+ var calcCustomQuery = customQuery(this.selectedValue, props);
23522
23740
 
23523
23741
  var _ref = calcCustomQuery || {},
23524
23742
  query = _ref.query;
@@ -23537,7 +23755,7 @@
23537
23755
 
23538
23756
  this.updateQuery({
23539
23757
  componentId: componentId,
23540
- queryToSet: queryToSet,
23758
+ query: queryToSet,
23541
23759
  value: this.selectedValue || null,
23542
23760
  label: filterLabel,
23543
23761
  showFilter: showFilter,
@@ -23588,8 +23806,8 @@
23588
23806
  },
23589
23807
  beforeMount: function beforeMount() {
23590
23808
  if (this.internalComponent && this.$props.defaultQuery) {
23591
- updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, undefined);
23592
- this.$defaultQuery = this.$props.defaultQuery();
23809
+ updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.selectedValue);
23810
+ this.$defaultQuery = this.$props.defaultQuery(this.selectedValue, this.$props);
23593
23811
 
23594
23812
  var _ref3 = this.$defaultQuery || {},
23595
23813
  query = _ref3.query,
@@ -23653,8 +23871,8 @@
23653
23871
  }
23654
23872
  },
23655
23873
  defaultQuery: function defaultQuery(newVal, oldVal) {
23656
- if (newVal && !isQueryIdentical(newVal, oldVal, undefined, this.$props)) {
23657
- this.$defaultQuery = newVal();
23874
+ if (newVal && !isQueryIdentical(newVal, oldVal, this.selectedValue, this.$props)) {
23875
+ this.$defaultQuery = newVal(this.selectedValue, this.$props);
23658
23876
 
23659
23877
  var _ref4 = this.$defaultQuery || {},
23660
23878
  query = _ref4.query,
@@ -23665,7 +23883,7 @@
23665
23883
  } else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false); // Update default query for RS API
23666
23884
 
23667
23885
 
23668
- updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, undefined);
23886
+ updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.selectedValue);
23669
23887
  var queryToSet = query || null;
23670
23888
 
23671
23889
  if (!queryToSet && this.$defaultQuery && this.$defaultQuery.id) {
@@ -23679,9 +23897,9 @@
23679
23897
  }
23680
23898
  },
23681
23899
  customQuery: function customQuery(newVal, oldVal) {
23682
- if (newVal && !isQueryIdentical(newVal, oldVal, undefined, this.$props)) {
23900
+ if (newVal && !isQueryIdentical(newVal, oldVal, this.selectedValue, this.$props)) {
23683
23901
  var componentId = this.$props.componentId;
23684
- this.$customQuery = newVal(this.$props);
23902
+ this.$customQuery = newVal(this.selectedValue, this.$props);
23685
23903
 
23686
23904
  var _ref5 = this.$customQuery || {},
23687
23905
  query = _ref5.query,
@@ -23692,7 +23910,7 @@
23692
23910
  } else this.setQueryOptions(componentId, this.getAggsQuery(), false); // Update custom query for RS API
23693
23911
 
23694
23912
 
23695
- updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, undefined);
23913
+ updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
23696
23914
  var queryToSet = query || null;
23697
23915
 
23698
23916
  if (this.$customQuery && this.$customQuery.id) {
@@ -25586,7 +25804,7 @@
25586
25804
  watch: {
25587
25805
  searchState: function searchState(newVal, oldVal) {
25588
25806
  if (this.isStateChanged(newVal, oldVal)) {
25589
- this.$emit('change', newVal, oldVal);
25807
+ this.$emit('change', oldVal, newVal);
25590
25808
  }
25591
25809
  },
25592
25810
  selectedValues: function selectedValues(newVal, oldVal) {
@@ -32566,16 +32784,7 @@
32566
32784
  compProps[key] = component[key];
32567
32785
  }
32568
32786
  });
32569
- var isInternalComponentPresent = false; // Set custom and default queries
32570
-
32571
- if (component.customQuery && typeof component.customQuery === 'function') {
32572
- customQueries[component.componentId] = component.customQuery(component.value, compProps);
32573
- }
32574
-
32575
- if (component.defaultQuery && typeof component.defaultQuery === 'function') {
32576
- defaultQueries[component.componentId] = component.defaultQuery(component.value, compProps);
32577
- }
32578
-
32787
+ var isInternalComponentPresent = false;
32579
32788
  var isResultComponent = resultComponents.includes(componentType);
32580
32789
  var internalComponent = component.componentId + "__internal";
32581
32790
  var label = component.filterLabel || component.componentId;
@@ -32599,7 +32808,16 @@
32599
32808
  reference: reference,
32600
32809
  showFilter: showFilter,
32601
32810
  URLParams: component.URLParams || false
32602
- }); // [2] set query options - main component query (valid for result components)
32811
+ }); // Set custom and default queries
32812
+
32813
+ if (component.customQuery && typeof component.customQuery === 'function') {
32814
+ customQueries[component.componentId] = component.customQuery(value, compProps);
32815
+ }
32816
+
32817
+ if (component.defaultQuery && typeof component.defaultQuery === 'function') {
32818
+ defaultQueries[component.componentId] = component.defaultQuery(value, compProps);
32819
+ } // [2] set query options - main component query (valid for result components)
32820
+
32603
32821
 
32604
32822
  if (componentsWithOptions.includes(componentType)) {
32605
32823
  var options = component.source.generateQueryOptions ? component.source.generateQueryOptions(component) : null;
@@ -32686,7 +32904,7 @@
32686
32904
 
32687
32905
 
32688
32906
  if (isResultComponent) {
32689
- var _getQuery = getQuery(component, null, componentType),
32907
+ var _getQuery = getQuery(component, value, componentType),
32690
32908
  query = _getQuery.query;
32691
32909
 
32692
32910
  queryList = queryReducer(queryList, {
@@ -32757,8 +32975,9 @@
32757
32975
  appbaseQuery = _extends({}, appbaseQuery, (_extends3 = {}, _extends3[component.componentId] = query, _extends3), transform_1(state, component.componentId, orderOfQueries));
32758
32976
  }
32759
32977
  } else {
32978
+ var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + "_" + component : component;
32760
32979
  finalQuery = [].concat(finalQuery, [{
32761
- preference: component.componentId
32980
+ preference: preference
32762
32981
  }, currentQuery]);
32763
32982
  }
32764
32983
  }
@@ -32912,7 +33131,7 @@
32912
33131
  });
32913
33132
  }
32914
33133
 
32915
- var version = "1.16.0-alpha.22";
33134
+ var version = "1.16.0-alpha.26";
32916
33135
 
32917
33136
  var _templateObject$o, _templateObject2$b;
32918
33137