@appbaseio/reactivesearch-vue 1.16.0-alpha.20 → 1.16.0-alpha.24

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 (61) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +179 -1055
  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/{ComponentWrapper-d7d87585.js → ComponentWrapper-ab813390.js} +1 -1
  6. package/dist/cjs/DataSearch.js +4 -4
  7. package/dist/cjs/{DropDown-35d1472d.js → DropDown-d3c78c41.js} +2 -2
  8. package/dist/cjs/DynamicRangeSlider.js +2 -2
  9. package/dist/cjs/MultiDropdownList.js +4 -4
  10. package/dist/cjs/MultiList.js +3 -3
  11. package/dist/cjs/MultiRange.js +3 -3
  12. package/dist/cjs/{Pagination-96c06392.js → Pagination-d4dbfd5a.js} +1 -1
  13. package/dist/cjs/RangeInput.js +3 -3
  14. package/dist/cjs/RangeSlider.js +3 -3
  15. package/dist/cjs/ReactiveBase.js +25 -11
  16. package/dist/cjs/ReactiveComponent.js +42 -8
  17. package/dist/cjs/ReactiveGoogleMap.js +4 -4
  18. package/dist/cjs/ReactiveList.js +22 -21
  19. package/dist/cjs/ResultCard.js +1 -1
  20. package/dist/cjs/ResultList.js +1 -1
  21. package/dist/cjs/SelectedFilters.js +2 -2
  22. package/dist/cjs/SingleDropdownList.js +4 -4
  23. package/dist/cjs/SingleList.js +3 -3
  24. package/dist/cjs/SingleRange.js +3 -3
  25. package/dist/cjs/StateProvider.js +2 -2
  26. package/dist/cjs/ToggleButton.js +3 -3
  27. package/dist/cjs/{index-9e4adbb3.js → index-2a8358cd.js} +2 -0
  28. package/dist/cjs/index.js +5 -5
  29. package/dist/cjs/initReactivesearch.js +12 -2
  30. package/dist/cjs/install.js +5 -5
  31. package/dist/cjs/version.js +1 -1
  32. package/dist/cjs/{vueTypes-c21f265b.js → vueTypes-409348b0.js} +3 -2
  33. package/dist/es/{ComponentWrapper-66d3e6b8.js → ComponentWrapper-459505fd.js} +1 -1
  34. package/dist/es/DataSearch.js +4 -4
  35. package/dist/es/{DropDown-ece64867.js → DropDown-8894cc22.js} +2 -2
  36. package/dist/es/DynamicRangeSlider.js +2 -2
  37. package/dist/es/MultiDropdownList.js +4 -4
  38. package/dist/es/MultiList.js +3 -3
  39. package/dist/es/MultiRange.js +3 -3
  40. package/dist/es/{Pagination-f8d7a011.js → Pagination-a2ab7fcb.js} +1 -1
  41. package/dist/es/RangeInput.js +3 -3
  42. package/dist/es/RangeSlider.js +3 -3
  43. package/dist/es/ReactiveBase.js +25 -11
  44. package/dist/es/ReactiveComponent.js +42 -8
  45. package/dist/es/ReactiveGoogleMap.js +4 -4
  46. package/dist/es/ReactiveList.js +22 -21
  47. package/dist/es/ResultCard.js +1 -1
  48. package/dist/es/ResultList.js +1 -1
  49. package/dist/es/SelectedFilters.js +2 -2
  50. package/dist/es/SingleDropdownList.js +4 -4
  51. package/dist/es/SingleList.js +3 -3
  52. package/dist/es/SingleRange.js +3 -3
  53. package/dist/es/StateProvider.js +2 -2
  54. package/dist/es/ToggleButton.js +3 -3
  55. package/dist/es/{index-f5d9c5c6.js → index-4755c9a0.js} +2 -1
  56. package/dist/es/index.js +5 -5
  57. package/dist/es/initReactivesearch.js +13 -3
  58. package/dist/es/install.js +5 -5
  59. package/dist/es/version.js +1 -1
  60. package/dist/es/{vueTypes-98d938a9.js → vueTypes-a9b9d5c9.js} +3 -2
  61. 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
  });
@@ -7073,11 +7073,6 @@
7073
7073
 
7074
7074
  var queryType = componentToTypeMap[componentProps.componentType];
7075
7075
  var calcValues = store.selectedValues[component] || store.internalValues[component];
7076
-
7077
- if (isSearchComponent(componentProps.componentType) && !calcValues) {
7078
- calcValues = store.internalValues[getInternalComponentID(component)];
7079
- }
7080
-
7081
7076
  var value = calcValues !== undefined && calcValues !== null ? calcValues.value : undefined;
7082
7077
  var queryFormat = componentProps.queryFormat;
7083
7078
  var interval = componentProps.interval;
@@ -8623,7 +8618,8 @@
8623
8618
  queryOptions = _getState4.queryOptions,
8624
8619
  queryListener = _getState4.queryListener,
8625
8620
  props = _getState4.props,
8626
- selectedValues = _getState4.selectedValues;
8621
+ selectedValues = _getState4.selectedValues,
8622
+ internalValues = _getState4.internalValues;
8627
8623
 
8628
8624
  var lockTime = config.initialQueriesSyncTime;
8629
8625
  var initialTimestamp = config.initialTimestamp;
@@ -8644,7 +8640,7 @@
8644
8640
  componentList.forEach(function (component) {
8645
8641
  var componentProps = props[component];
8646
8642
 
8647
- if (selectedValues[componentId] && selectedValues[componentId].reference !== 'URL' && [constants$1.componentTypes.reactiveList, constants$1.componentTypes.reactiveMap].includes(componentProps.componentType)) {
8643
+ if (selectedValues[componentId] && selectedValues[componentId].reference !== 'URL' && componentProps && [constants$1.componentTypes.reactiveList, constants$1.componentTypes.reactiveMap].includes(componentProps.componentType)) {
8648
8644
  dispatch((0, value.setValue)(component, null));
8649
8645
  }
8650
8646
 
@@ -8698,9 +8694,19 @@
8698
8694
  (0, utils.executeQueryListener)(queryListener[component], oldQuery, currentQuery);
8699
8695
 
8700
8696
  if (isAppbaseEnabled) {
8701
- var query = (0, transform.getRSQuery)(component, (0, transform.extractPropsFromState)(getState(), component, metaOptions ? {
8697
+ var value$1 = void 0;
8698
+ var isInternalComponent = componentId.endsWith('__internal');
8699
+ var mainComponentProps = props[componentId];
8700
+
8701
+ if (isInternalComponent && (0, transform.isSearchComponent)(mainComponentProps.componentType)) {
8702
+ value$1 = internalValues[componentId] && internalValues[componentId].value;
8703
+ }
8704
+
8705
+ var query = (0, transform.getRSQuery)(component, (0, transform.extractPropsFromState)(getState(), component, _extends({}, value$1 ? {
8706
+ value: value$1
8707
+ } : null, metaOptions ? {
8702
8708
  from: metaOptions.from
8703
- } : null));
8709
+ } : null)));
8704
8710
 
8705
8711
  if (query) {
8706
8712
  appbaseQuery = _extends({}, appbaseQuery, _defineProperty({}, component, query), (0, transform.getDependentQueries)(getState(), component, orderOfQueries));
@@ -8719,8 +8725,9 @@
8719
8725
  }
8720
8726
  }
8721
8727
  } else {
8728
+ var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + '_' + component : component;
8722
8729
  finalQuery = [].concat(_toConsumableArray(finalQuery), [{
8723
- preference: component
8730
+ preference: preference
8724
8731
  }, currentQuery]);
8725
8732
  }
8726
8733
  }
@@ -8925,8 +8932,9 @@
8925
8932
  appendToAggs: appendToAggs
8926
8933
  }));
8927
8934
  } else {
8935
+ var preference = store.config && store.config.analyticsConfig && store.config.analyticsConfig.userId ? store.config.analyticsConfig.userId + '_' + component : component;
8928
8936
  var _finalQuery = [{
8929
- preference: component
8937
+ preference: preference
8930
8938
  }, currentQuery];
8931
8939
  dispatch(msearch(_finalQuery, [component], appendToHits, false, appendToAggs));
8932
8940
  }
@@ -12801,8 +12809,9 @@
12801
12809
  emptyQuery: VueTypes.bool,
12802
12810
  suggestionAnalytics: VueTypes.bool,
12803
12811
  userId: VueTypes.string,
12804
- customEvents: VueTypes.object
12805
- })
12812
+ customEvents: VueTypes.object,
12813
+ enableTelemetry: VueTypes.bool.def(true)
12814
+ }).def({})
12806
12815
  };
12807
12816
 
12808
12817
  var getClassName = lib_8.getClassName,
@@ -13117,6 +13126,7 @@
13117
13126
  // storeKey,
13118
13127
  // });
13119
13128
 
13129
+ var X_SEARCH_CLIENT = 'ReactiveSearch Vue';
13120
13130
  var composeThemeObject = function composeThemeObject(ownTheme, userTheme) {
13121
13131
  if (ownTheme === void 0) {
13122
13132
  ownTheme = {};
@@ -13905,18 +13915,17 @@
13905
13915
  ResultCardsWrapper: ResultCardsWrapper
13906
13916
  },
13907
13917
  data: function data() {
13908
- var props = this.$props;
13909
13918
  var currentPageState = 0;
13919
+ var defaultPage = this.defaultPage || -1;
13910
13920
 
13911
- if (props.defaultPage >= 0) {
13912
- currentPageState = props.defaultPage;
13913
- } else if (props.currentPage) {
13914
- currentPageState = Math.max(props.currentPage - 1, 0);
13921
+ if (defaultPage >= 0) {
13922
+ currentPageState = defaultPage;
13923
+ } else if (this.currentPage) {
13924
+ currentPageState = Math.max(this.currentPage - 1, 0);
13915
13925
  }
13916
13926
 
13917
13927
  this.__state = {
13918
- from: currentPageState * props.size,
13919
- isLoading: true,
13928
+ from: currentPageState * this.size,
13920
13929
  currentPageState: currentPageState
13921
13930
  };
13922
13931
  return this.__state;
@@ -13945,8 +13954,10 @@
13945
13954
  console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
13946
13955
  }
13947
13956
 
13948
- if (this.defaultPage >= 0) {
13949
- this.currentPageState = this.defaultPage;
13957
+ var defaultPage = this.defaultPage || -1;
13958
+
13959
+ if (defaultPage >= 0) {
13960
+ this.currentPageState = defaultPage;
13950
13961
  this.from = this.currentPageState * this.$props.size;
13951
13962
  }
13952
13963
 
@@ -14414,7 +14425,7 @@
14414
14425
  if (this.stats.numberOfResults) {
14415
14426
  return h("p", {
14416
14427
  "class": resultStats + " " + getClassName$1(this.$props.innerClass, 'resultStats')
14417
- }, [this.stats.numberOfResults, " results found in ", this.stats.time, "ms"]);
14428
+ }, [this.stats.numberOfResults, " results found in ", this.stats.time || 0, "ms"]);
14418
14429
  }
14419
14430
 
14420
14431
  return null;
@@ -14547,7 +14558,7 @@
14547
14558
  return {
14548
14559
  data: this.withClickIds(filteredResults),
14549
14560
  aggregationData: this.withClickIds(aggregationData || []),
14550
- promotedData: this.withClickIds(promotedResults),
14561
+ promotedData: this.withClickIds(promotedResults || []),
14551
14562
  rawData: this.rawData,
14552
14563
  resultStats: this.stats,
14553
14564
  customData: customData
@@ -14559,7 +14570,7 @@
14559
14570
 
14560
14571
  var data = _extends({
14561
14572
  error: error,
14562
- loading: isLoading,
14573
+ loading: isLoading || false,
14563
14574
  loadMore: this.loadMore,
14564
14575
  // TODO: Remove in v2
14565
14576
  triggerAnalytics: this.triggerClickAnalytics,
@@ -14574,13 +14585,13 @@
14574
14585
 
14575
14586
  var mapStateToProps$1 = function mapStateToProps(state, props) {
14576
14587
  return {
14577
- defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1 || -1,
14588
+ defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
14578
14589
  hits: state.hits[props.componentId] && state.hits[props.componentId].hits,
14579
14590
  rawData: state.rawData[props.componentId],
14580
- aggregationData: state.compositeAggregations[props.componentId] || [],
14581
- promotedResults: state.promotedResults[props.componentId] || [],
14591
+ aggregationData: state.compositeAggregations[props.componentId],
14592
+ promotedResults: state.promotedResults[props.componentId],
14582
14593
  customData: state.customData[props.componentId],
14583
- time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
14594
+ time: state.hits[props.componentId] && state.hits[props.componentId].time,
14584
14595
  total: state.hits[props.componentId] && state.hits[props.componentId].total,
14585
14596
  hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
14586
14597
  analytics: state.config && state.config.analytics,
@@ -14589,7 +14600,7 @@
14589
14600
  error: state.error[props.componentId],
14590
14601
  afterKey: state.aggregations[props.componentId] && state.aggregations[props.componentId][props.aggregationField] && state.aggregations[props.componentId][props.aggregationField].after_key,
14591
14602
  componentProps: state.props[props.componentId],
14592
- isLoading: state.isLoading[props.componentId] || false
14603
+ isLoading: state.isLoading[props.componentId]
14593
14604
  };
14594
14605
  };
14595
14606
 
@@ -15313,562 +15324,6 @@
15313
15324
  }
15314
15325
  });
15315
15326
 
15316
- var at,
15317
- // The index of the current character
15318
- ch,
15319
- // The current character
15320
- escapee = {
15321
- '"': '"',
15322
- '\\': '\\',
15323
- '/': '/',
15324
- b: '\b',
15325
- f: '\f',
15326
- n: '\n',
15327
- r: '\r',
15328
- t: '\t'
15329
- },
15330
- text,
15331
- error = function error(m) {
15332
- // Call error when something is wrong.
15333
- throw {
15334
- name: 'SyntaxError',
15335
- message: m,
15336
- at: at,
15337
- text: text
15338
- };
15339
- },
15340
- next = function next(c) {
15341
- // If a c parameter is provided, verify that it matches the current character.
15342
- if (c && c !== ch) {
15343
- error("Expected '" + c + "' instead of '" + ch + "'");
15344
- } // Get the next character. When there are no more characters,
15345
- // return the empty string.
15346
-
15347
-
15348
- ch = text.charAt(at);
15349
- at += 1;
15350
- return ch;
15351
- },
15352
- number = function number() {
15353
- // Parse a number value.
15354
- var number,
15355
- string = '';
15356
-
15357
- if (ch === '-') {
15358
- string = '-';
15359
- next('-');
15360
- }
15361
-
15362
- while (ch >= '0' && ch <= '9') {
15363
- string += ch;
15364
- next();
15365
- }
15366
-
15367
- if (ch === '.') {
15368
- string += '.';
15369
-
15370
- while (next() && ch >= '0' && ch <= '9') {
15371
- string += ch;
15372
- }
15373
- }
15374
-
15375
- if (ch === 'e' || ch === 'E') {
15376
- string += ch;
15377
- next();
15378
-
15379
- if (ch === '-' || ch === '+') {
15380
- string += ch;
15381
- next();
15382
- }
15383
-
15384
- while (ch >= '0' && ch <= '9') {
15385
- string += ch;
15386
- next();
15387
- }
15388
- }
15389
-
15390
- number = +string;
15391
-
15392
- if (!isFinite(number)) {
15393
- error("Bad number");
15394
- } else {
15395
- return number;
15396
- }
15397
- },
15398
- string = function string() {
15399
- // Parse a string value.
15400
- var hex,
15401
- i,
15402
- string = '',
15403
- uffff; // When parsing for string values, we must look for " and \ characters.
15404
-
15405
- if (ch === '"') {
15406
- while (next()) {
15407
- if (ch === '"') {
15408
- next();
15409
- return string;
15410
- } else if (ch === '\\') {
15411
- next();
15412
-
15413
- if (ch === 'u') {
15414
- uffff = 0;
15415
-
15416
- for (i = 0; i < 4; i += 1) {
15417
- hex = parseInt(next(), 16);
15418
-
15419
- if (!isFinite(hex)) {
15420
- break;
15421
- }
15422
-
15423
- uffff = uffff * 16 + hex;
15424
- }
15425
-
15426
- string += String.fromCharCode(uffff);
15427
- } else if (typeof escapee[ch] === 'string') {
15428
- string += escapee[ch];
15429
- } else {
15430
- break;
15431
- }
15432
- } else {
15433
- string += ch;
15434
- }
15435
- }
15436
- }
15437
-
15438
- error("Bad string");
15439
- },
15440
- white = function white() {
15441
- // Skip whitespace.
15442
- while (ch && ch <= ' ') {
15443
- next();
15444
- }
15445
- },
15446
- word = function word() {
15447
- // true, false, or null.
15448
- switch (ch) {
15449
- case 't':
15450
- next('t');
15451
- next('r');
15452
- next('u');
15453
- next('e');
15454
- return true;
15455
-
15456
- case 'f':
15457
- next('f');
15458
- next('a');
15459
- next('l');
15460
- next('s');
15461
- next('e');
15462
- return false;
15463
-
15464
- case 'n':
15465
- next('n');
15466
- next('u');
15467
- next('l');
15468
- next('l');
15469
- return null;
15470
- }
15471
-
15472
- error("Unexpected '" + ch + "'");
15473
- },
15474
- value$1,
15475
- // Place holder for the value function.
15476
- array = function array() {
15477
- // Parse an array value.
15478
- var array = [];
15479
-
15480
- if (ch === '[') {
15481
- next('[');
15482
- white();
15483
-
15484
- if (ch === ']') {
15485
- next(']');
15486
- return array; // empty array
15487
- }
15488
-
15489
- while (ch) {
15490
- array.push(value$1());
15491
- white();
15492
-
15493
- if (ch === ']') {
15494
- next(']');
15495
- return array;
15496
- }
15497
-
15498
- next(',');
15499
- white();
15500
- }
15501
- }
15502
-
15503
- error("Bad array");
15504
- },
15505
- object = function object() {
15506
- // Parse an object value.
15507
- var key,
15508
- object = {};
15509
-
15510
- if (ch === '{') {
15511
- next('{');
15512
- white();
15513
-
15514
- if (ch === '}') {
15515
- next('}');
15516
- return object; // empty object
15517
- }
15518
-
15519
- while (ch) {
15520
- key = string();
15521
- white();
15522
- next(':');
15523
-
15524
- if (Object.hasOwnProperty.call(object, key)) {
15525
- error('Duplicate key "' + key + '"');
15526
- }
15527
-
15528
- object[key] = value$1();
15529
- white();
15530
-
15531
- if (ch === '}') {
15532
- next('}');
15533
- return object;
15534
- }
15535
-
15536
- next(',');
15537
- white();
15538
- }
15539
- }
15540
-
15541
- error("Bad object");
15542
- };
15543
-
15544
- value$1 = function value() {
15545
- // Parse a JSON value. It could be an object, an array, a string, a number,
15546
- // or a word.
15547
- white();
15548
-
15549
- switch (ch) {
15550
- case '{':
15551
- return object();
15552
-
15553
- case '[':
15554
- return array();
15555
-
15556
- case '"':
15557
- return string();
15558
-
15559
- case '-':
15560
- return number();
15561
-
15562
- default:
15563
- return ch >= '0' && ch <= '9' ? number() : word();
15564
- }
15565
- }; // Return the json_parse function. It will have access to all of the above
15566
- // functions and variables.
15567
-
15568
-
15569
- var parse = function parse(source, reviver) {
15570
- var result;
15571
- text = source;
15572
- at = 0;
15573
- ch = ' ';
15574
- result = value$1();
15575
- white();
15576
-
15577
- if (ch) {
15578
- error("Syntax error");
15579
- } // If there is a reviver function, we recursively walk the new structure,
15580
- // passing each name/value pair to the reviver function for possible
15581
- // transformation, starting with a temporary root object that holds the result
15582
- // in an empty key. If there is not a reviver function, we simply return the
15583
- // result.
15584
-
15585
-
15586
- return typeof reviver === 'function' ? function walk(holder, key) {
15587
- var k,
15588
- v,
15589
- value = holder[key];
15590
-
15591
- if (value && typeof value === 'object') {
15592
- for (k in value) {
15593
- if (Object.prototype.hasOwnProperty.call(value, k)) {
15594
- v = walk(value, k);
15595
-
15596
- if (v !== undefined) {
15597
- value[k] = v;
15598
- } else {
15599
- delete value[k];
15600
- }
15601
- }
15602
- }
15603
- }
15604
-
15605
- return reviver.call(holder, key, value);
15606
- }({
15607
- '': result
15608
- }, '') : result;
15609
- };
15610
-
15611
- var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
15612
- gap,
15613
- indent,
15614
- meta = {
15615
- // table of character substitutions
15616
- '\b': '\\b',
15617
- '\t': '\\t',
15618
- '\n': '\\n',
15619
- '\f': '\\f',
15620
- '\r': '\\r',
15621
- '"': '\\"',
15622
- '\\': '\\\\'
15623
- },
15624
- rep;
15625
-
15626
- function quote(string) {
15627
- // If the string contains no control characters, no quote characters, and no
15628
- // backslash characters, then we can safely slap some quotes around it.
15629
- // Otherwise we must also replace the offending characters with safe escape
15630
- // sequences.
15631
- escapable.lastIndex = 0;
15632
- return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
15633
- var c = meta[a];
15634
- return typeof c === 'string' ? c : "\\u" + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
15635
- }) + '"' : '"' + string + '"';
15636
- }
15637
-
15638
- function str(key, holder) {
15639
- // Produce a string from holder[key].
15640
- var i,
15641
- // The loop counter.
15642
- k,
15643
- // The member key.
15644
- v,
15645
- // The member value.
15646
- length,
15647
- mind = gap,
15648
- partial,
15649
- value = holder[key]; // If the value has a toJSON method, call it to obtain a replacement value.
15650
-
15651
- if (value && typeof value === 'object' && typeof value.toJSON === 'function') {
15652
- value = value.toJSON(key);
15653
- } // If we were called with a replacer function, then call the replacer to
15654
- // obtain a replacement value.
15655
-
15656
-
15657
- if (typeof rep === 'function') {
15658
- value = rep.call(holder, key, value);
15659
- } // What happens next depends on the value's type.
15660
-
15661
-
15662
- switch (typeof value) {
15663
- case 'string':
15664
- return quote(value);
15665
-
15666
- case 'number':
15667
- // JSON numbers must be finite. Encode non-finite numbers as null.
15668
- return isFinite(value) ? String(value) : 'null';
15669
-
15670
- case 'boolean':
15671
- case 'null':
15672
- // If the value is a boolean or null, convert it to a string. Note:
15673
- // typeof null does not produce 'null'. The case is included here in
15674
- // the remote chance that this gets fixed someday.
15675
- return String(value);
15676
-
15677
- case 'object':
15678
- if (!value) return 'null';
15679
- gap += indent;
15680
- partial = []; // Array.isArray
15681
-
15682
- if (Object.prototype.toString.apply(value) === '[object Array]') {
15683
- length = value.length;
15684
-
15685
- for (i = 0; i < length; i += 1) {
15686
- partial[i] = str(i, value) || 'null';
15687
- } // Join all of the elements together, separated with commas, and
15688
- // wrap them in brackets.
15689
-
15690
-
15691
- v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']';
15692
- gap = mind;
15693
- return v;
15694
- } // If the replacer is an array, use it to select the members to be
15695
- // stringified.
15696
-
15697
-
15698
- if (rep && typeof rep === 'object') {
15699
- length = rep.length;
15700
-
15701
- for (i = 0; i < length; i += 1) {
15702
- k = rep[i];
15703
-
15704
- if (typeof k === 'string') {
15705
- v = str(k, value);
15706
-
15707
- if (v) {
15708
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
15709
- }
15710
- }
15711
- }
15712
- } else {
15713
- // Otherwise, iterate through all of the keys in the object.
15714
- for (k in value) {
15715
- if (Object.prototype.hasOwnProperty.call(value, k)) {
15716
- v = str(k, value);
15717
-
15718
- if (v) {
15719
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
15720
- }
15721
- }
15722
- }
15723
- } // Join all of the member texts together, separated with commas,
15724
- // and wrap them in braces.
15725
-
15726
-
15727
- v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}';
15728
- gap = mind;
15729
- return v;
15730
- }
15731
- }
15732
-
15733
- var stringify = function stringify(value, replacer, space) {
15734
- var i;
15735
- gap = '';
15736
- indent = ''; // If the space parameter is a number, make an indent string containing that
15737
- // many spaces.
15738
-
15739
- if (typeof space === 'number') {
15740
- for (i = 0; i < space; i += 1) {
15741
- indent += ' ';
15742
- }
15743
- } // If the space parameter is a string, it will be used as the indent string.
15744
- else if (typeof space === 'string') {
15745
- indent = space;
15746
- } // If there is a replacer, it must be a function or an array.
15747
- // Otherwise, throw an error.
15748
-
15749
-
15750
- rep = replacer;
15751
-
15752
- if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) {
15753
- throw new Error('JSON.stringify');
15754
- } // Make a fake root object containing our value under the key of ''.
15755
- // Return the result of stringifying the value.
15756
-
15757
-
15758
- return str('', {
15759
- '': value
15760
- });
15761
- };
15762
-
15763
- var parse$1 = parse;
15764
- var stringify$1 = stringify;
15765
- var jsonify = {
15766
- parse: parse$1,
15767
- stringify: stringify$1
15768
- };
15769
-
15770
- var json = typeof JSON !== 'undefined' ? JSON : jsonify;
15771
-
15772
- var jsonStableStringify = function jsonStableStringify(obj, opts) {
15773
- if (!opts) opts = {};
15774
- if (typeof opts === 'function') opts = {
15775
- cmp: opts
15776
- };
15777
- var space = opts.space || '';
15778
- if (typeof space === 'number') space = Array(space + 1).join(' ');
15779
- var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
15780
-
15781
- var replacer = opts.replacer || function (key, value) {
15782
- return value;
15783
- };
15784
-
15785
- var cmp = opts.cmp && function (f) {
15786
- return function (node) {
15787
- return function (a, b) {
15788
- var aobj = {
15789
- key: a,
15790
- value: node[a]
15791
- };
15792
- var bobj = {
15793
- key: b,
15794
- value: node[b]
15795
- };
15796
- return f(aobj, bobj);
15797
- };
15798
- };
15799
- }(opts.cmp);
15800
-
15801
- var seen = [];
15802
- return function stringify(parent, key, node, level) {
15803
- var indent = space ? '\n' + new Array(level + 1).join(space) : '';
15804
- var colonSeparator = space ? ': ' : ':';
15805
-
15806
- if (node && node.toJSON && typeof node.toJSON === 'function') {
15807
- node = node.toJSON();
15808
- }
15809
-
15810
- node = replacer.call(parent, key, node);
15811
-
15812
- if (node === undefined) {
15813
- return;
15814
- }
15815
-
15816
- if (typeof node !== 'object' || node === null) {
15817
- return json.stringify(node);
15818
- }
15819
-
15820
- if (isArray$1(node)) {
15821
- var out = [];
15822
-
15823
- for (var i = 0; i < node.length; i++) {
15824
- var item = stringify(node, i, node[i], level + 1) || json.stringify(null);
15825
- out.push(indent + space + item);
15826
- }
15827
-
15828
- return '[' + out.join(',') + indent + ']';
15829
- } else {
15830
- if (seen.indexOf(node) !== -1) {
15831
- if (cycles) return json.stringify('__cycle__');
15832
- throw new TypeError('Converting circular structure to JSON');
15833
- } else seen.push(node);
15834
-
15835
- var keys = objectKeys(node).sort(cmp && cmp(node));
15836
- var out = [];
15837
-
15838
- for (var i = 0; i < keys.length; i++) {
15839
- var key = keys[i];
15840
- var value = stringify(node, key, node[key], level + 1);
15841
- if (!value) continue;
15842
- var keyValue = json.stringify(key) + colonSeparator + value;
15843
- out.push(indent + space + keyValue);
15844
- }
15845
-
15846
- seen.splice(seen.indexOf(node), 1);
15847
- return '{' + out.join(',') + indent + '}';
15848
- }
15849
- }({
15850
- '': obj
15851
- }, '', obj, 0);
15852
- };
15853
-
15854
- var isArray$1 = Array.isArray || function (x) {
15855
- return {}.toString.call(x) === '[object Array]';
15856
- };
15857
-
15858
- var objectKeys = Object.keys || function (obj) {
15859
- var has = Object.prototype.hasOwnProperty || function () {
15860
- return true;
15861
- };
15862
-
15863
- var keys = [];
15864
-
15865
- for (var key in obj) {
15866
- if (has.call(obj, key)) keys.push(key);
15867
- }
15868
-
15869
- return keys;
15870
- };
15871
-
15872
15327
  var _typeof$1 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
15873
15328
  return typeof obj;
15874
15329
  } : function (obj) {
@@ -15904,16 +15359,6 @@
15904
15359
  return output;
15905
15360
  }
15906
15361
 
15907
- function uuidv4() {
15908
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
15909
- var r = Math.random() * 16 | 0; // eslint-disable-line no-bitwise
15910
-
15911
- var v = c === 'x' ? r : r & 0x3 | 0x8; // eslint-disable-line no-bitwise
15912
-
15913
- return v.toString(16);
15914
- });
15915
- }
15916
-
15917
15362
  function validateRSQuery(query) {
15918
15363
  if (query && Object.prototype.toString.call(query) === '[object Array]') {
15919
15364
  for (var i = 0; i < query.length; i += 1) {
@@ -15976,24 +15421,6 @@
15976
15421
 
15977
15422
  return null;
15978
15423
  }
15979
- /**
15980
- * Send only when a connection is opened
15981
- * @param {Object} socket
15982
- * @param {Function} callback
15983
- */
15984
-
15985
-
15986
- function waitForSocketConnection(socket, callback) {
15987
- setTimeout(function () {
15988
- if (socket.readyState === 1) {
15989
- if (callback != null) {
15990
- callback();
15991
- }
15992
- } else {
15993
- waitForSocketConnection(socket, callback);
15994
- }
15995
- }, 5); // wait 5 ms for the connection...
15996
- }
15997
15424
 
15998
15425
  function encodeHeaders() {
15999
15426
  var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -16011,6 +15438,21 @@
16011
15438
 
16012
15439
  return encodedHeaders;
16013
15440
  }
15441
+
15442
+ function getTelemetryHeaders(enableTelemetry) {
15443
+ var headers = {};
15444
+ Object.assign(headers, {
15445
+ 'X-Search-Client': 'Appbase JS'
15446
+ });
15447
+
15448
+ if (enableTelemetry === false) {
15449
+ Object.assign(headers, {
15450
+ 'X-Enable-Telemetry': enableTelemetry
15451
+ });
15452
+ }
15453
+
15454
+ return headers;
15455
+ }
16014
15456
  /**
16015
15457
  * Returns an instance of Appbase client
16016
15458
  * @param {Object} config To configure properties
@@ -16019,6 +15461,7 @@
16019
15461
  * @param {String} config.credentials
16020
15462
  * @param {String} config.username
16021
15463
  * @param {String} config.password
15464
+ * @param {Boolean} config.enableTelemetry
16022
15465
  * A callback function which will be invoked before a fetch request made
16023
15466
  */
16024
15467
 
@@ -16045,7 +15488,7 @@
16045
15488
  }
16046
15489
 
16047
15490
  if (typeof protocol !== 'string' || protocol === '') {
16048
- throw new Error('Protocol is not present in url. URL should be of the form https://scalr.api.appbase.io');
15491
+ throw new Error('Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io');
16049
15492
  } // Parse url
16050
15493
 
16051
15494
 
@@ -16073,7 +15516,10 @@
16073
15516
  this.protocol = protocol;
16074
15517
  this.app = config.app;
16075
15518
  this.credentials = credentials;
16076
- this.headers = {};
15519
+
15520
+ if (typeof config.enableTelemetry === 'boolean') {
15521
+ this.enableTelemetry = config.enableTelemetry;
15522
+ }
16077
15523
  }
16078
15524
  /**
16079
15525
  * To perform fetch request
@@ -16082,6 +15528,7 @@
16082
15528
  * @param {String} args.path
16083
15529
  * @param {Object} args.params
16084
15530
  * @param {Object} args.body
15531
+ * @param {Object} args.headers
16085
15532
  * @param {boolean} args.isSuggestionsAPI
16086
15533
  */
16087
15534
 
@@ -16105,7 +15552,7 @@
16105
15552
  var headers = Object.assign({}, {
16106
15553
  Accept: 'application/json',
16107
15554
  'Content-Type': contentType
16108
- }, _this.headers);
15555
+ }, args.headers, _this.headers);
16109
15556
  var timestamp = Date.now();
16110
15557
 
16111
15558
  if (_this.credentials) {
@@ -16156,7 +15603,12 @@
16156
15603
  var transformedRequest = Object.assign({}, ts);
16157
15604
  var url = transformedRequest.url;
16158
15605
  delete transformedRequest.url;
16159
- return browserPonyfill$1(url || finalURL, transformedRequest).then(function (res) {
15606
+ return browserPonyfill$1(url || finalURL, Object.assign({}, transformedRequest, {
15607
+ // apply timestamp header for RS API
15608
+ headers: isRSAPI ? Object.assign({}, transformedRequest.headers, {
15609
+ 'x-timestamp': new Date().getTime()
15610
+ }) : transformedRequest.headers
15611
+ })).then(function (res) {
16160
15612
  if (res.status >= 500) {
16161
15613
  return reject(res);
16162
15614
  }
@@ -16225,180 +15677,6 @@
16225
15677
  }
16226
15678
  });
16227
15679
  }
16228
-
16229
- var WebSocket = typeof window !== 'undefined' ? window.WebSocket : require('ws');
16230
- /**
16231
- * To connect a web socket
16232
- * @param {Object} args
16233
- * @param {String} args.method
16234
- * @param {String} args.path
16235
- * @param {Object} args.params
16236
- * @param {Object} args.body
16237
- */
16238
-
16239
- function wsRequest(args, onData, onError, onClose) {
16240
- var _this = this;
16241
-
16242
- try {
16243
- var parsedArgs = removeUndefined(args);
16244
- var method = parsedArgs.method,
16245
- path = parsedArgs.path,
16246
- params = parsedArgs.params;
16247
- var bodyCopy = args.body;
16248
-
16249
- if (!bodyCopy || (typeof bodyCopy === 'undefined' ? 'undefined' : _typeof$1(bodyCopy)) !== 'object') {
16250
- bodyCopy = {};
16251
- }
16252
-
16253
- var init = function init() {
16254
- _this.ws = new WebSocket('wss://' + _this.url + '/' + _this.app);
16255
- _this.id = uuidv4();
16256
- _this.request = {
16257
- id: _this.id,
16258
- path: _this.app + '/' + path + '?' + querystring.stringify(params),
16259
- method: method,
16260
- body: bodyCopy
16261
- };
16262
-
16263
- if (_this.credentials) {
16264
- _this.request.authorization = 'Basic ' + btoa$1(_this.credentials);
16265
- }
16266
-
16267
- _this.result = {};
16268
-
16269
- _this.closeHandler = function () {
16270
- _this.wsClosed();
16271
- };
16272
-
16273
- _this.errorHandler = function (err) {
16274
- _this.processError.apply(_this, [err]);
16275
- };
16276
-
16277
- _this.messageHandler = function (message) {
16278
- var dataObj = JSON.parse(message.data);
16279
-
16280
- if (dataObj.body && dataObj.body.status >= 400) {
16281
- _this.processError.apply(_this, [dataObj]);
16282
- } else {
16283
- _this.processMessage.apply(_this, [dataObj]);
16284
- }
16285
- };
16286
-
16287
- _this.send = function (request) {
16288
- waitForSocketConnection(_this.ws, function () {
16289
- try {
16290
- _this.ws.send(JSON.stringify(request));
16291
- } catch (e) {
16292
- console.warn(e);
16293
- }
16294
- });
16295
- };
16296
-
16297
- _this.ws.onmessage = _this.messageHandler;
16298
- _this.ws.onerror = _this.errorHandler;
16299
- _this.ws.onclose = _this.closeHandler;
16300
-
16301
- _this.send(_this.request);
16302
-
16303
- _this.result.stop = _this.stop;
16304
- _this.result.reconnect = _this.reconnect;
16305
- return _this.result;
16306
- };
16307
-
16308
- this.wsClosed = function () {
16309
- if (onClose) {
16310
- onClose();
16311
- }
16312
- };
16313
-
16314
- this.stop = function () {
16315
- _this.ws.onmessage = undefined;
16316
- _this.ws.onclose = undefined;
16317
- _this.ws.onerror = undefined;
16318
-
16319
- _this.wsClosed();
16320
-
16321
- var unsubRequest = JSON.parse(JSON.stringify(_this.request));
16322
- unsubRequest.unsubscribe = true;
16323
-
16324
- if (_this.unsubscribed !== true) {
16325
- _this.send(unsubRequest);
16326
- }
16327
-
16328
- _this.unsubscribed = true;
16329
- };
16330
-
16331
- this.reconnect = function () {
16332
- _this.stop();
16333
-
16334
- return wsRequest(args, onData, onError, onClose);
16335
- };
16336
-
16337
- this.processError = function (err) {
16338
- if (onError) {
16339
- onError(err);
16340
- } else {
16341
- console.warn(err);
16342
- }
16343
- };
16344
-
16345
- this.processMessage = function (origDataObj) {
16346
- var dataObj = JSON.parse(JSON.stringify(origDataObj));
16347
-
16348
- if (!dataObj.id && dataObj.message) {
16349
- if (onError) {
16350
- onError(dataObj);
16351
- }
16352
-
16353
- return;
16354
- }
16355
-
16356
- if (dataObj.id === _this.id) {
16357
- if (dataObj.message) {
16358
- delete dataObj.id;
16359
-
16360
- if (onError) {
16361
- onError(dataObj);
16362
- }
16363
-
16364
- return;
16365
- }
16366
-
16367
- if (dataObj.query_id) {
16368
- _this.query_id = dataObj.query_id;
16369
- }
16370
-
16371
- if (dataObj.channel) {
16372
- _this.channel = dataObj.channel;
16373
- }
16374
-
16375
- if (dataObj.body && dataObj.body !== '') {
16376
- if (onData) {
16377
- onData(dataObj.body);
16378
- }
16379
- }
16380
-
16381
- return;
16382
- }
16383
-
16384
- if (!dataObj.id && dataObj.channel && dataObj.channel === _this.channel) {
16385
- if (onData) {
16386
- onData(dataObj.event);
16387
- }
16388
- }
16389
- };
16390
-
16391
- return init();
16392
- } catch (e) {
16393
- if (onError) {
16394
- onError(e);
16395
- } else {
16396
- console.warn(e);
16397
- }
16398
-
16399
- return null;
16400
- }
16401
- }
16402
15680
  /**
16403
15681
  * Index Service
16404
15682
  * @param {Object} args
@@ -16679,7 +15957,7 @@
16679
15957
  */
16680
15958
 
16681
15959
 
16682
- function reactiveSearchv3Api(query, settings) {
15960
+ function reactiveSearchApi(query, settings) {
16683
15961
  var parsedSettings = removeUndefined(settings); // Validate query
16684
15962
 
16685
15963
  var valid = validateRSQuery(query);
@@ -16694,251 +15972,42 @@
16694
15972
  };
16695
15973
  return this.performFetchRequest({
16696
15974
  method: 'POST',
16697
- path: '_reactivesearch.v3',
15975
+ path: '_reactivesearch',
16698
15976
  body: body,
15977
+ headers: getTelemetryHeaders(this.enableTelemetry),
16699
15978
  isRSAPI: true
16700
15979
  });
16701
15980
  }
16702
15981
  /**
16703
- * Stream Service
16704
- * @param {Object} args
16705
- * @param {String} args.type
16706
- * @param {Boolean} args.stream
16707
- * @param {String} args.id
16708
- * @param {Function} onData
16709
- * @param {Function} onError
16710
- * @param {Function} onClose
16711
- */
16712
-
16713
-
16714
- function getStream(args) {
16715
- var parsedArgs = removeUndefined(args); // Validate arguments
16716
-
16717
- var valid = validate(parsedArgs, {
16718
- type: 'string',
16719
- id: 'string|number'
16720
- });
16721
-
16722
- if (valid !== true) {
16723
- throw valid;
16724
- }
16725
-
16726
- var type = parsedArgs.type,
16727
- id = parsedArgs.id;
16728
- delete parsedArgs.type;
16729
- delete parsedArgs.id;
16730
- delete parsedArgs.stream;
16731
-
16732
- if (parsedArgs.stream === true) {
16733
- parsedArgs.stream = 'true';
16734
- } else {
16735
- delete parsedArgs.stream;
16736
- parsedArgs.streamonly = 'true';
16737
- }
16738
-
16739
- for (var _len = arguments.length, rest = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
16740
- rest[_key - 1] = arguments[_key];
16741
- }
16742
-
16743
- return this.performWsRequest.apply(this, [{
16744
- method: 'GET',
16745
- path: type + '/' + encodeURIComponent(id),
16746
- params: parsedArgs
16747
- }].concat(rest));
16748
- }
16749
- /**
16750
- * Search Stream
16751
- * @param {Object} args
16752
- * @param {String} args.type
16753
- * @param {Object} args.body
16754
- * @param {Boolean} args.stream
16755
- * @param {Function} onData
16756
- * @param {Function} onError
16757
- * @param {Function} onClose
16758
- */
16759
-
16760
-
16761
- function searchStreamApi(args) {
16762
- var parsedArgs = removeUndefined(args); // Validate arguments
16763
-
16764
- var valid = validate(parsedArgs, {
16765
- body: 'object'
16766
- });
16767
-
16768
- if (valid !== true) {
16769
- throw valid;
16770
- }
16771
-
16772
- if (parsedArgs.type === undefined || Array.isArray(parsedArgs.type) && parsedArgs.type.length === 0) {
16773
- throw new Error('Missing fields: type');
16774
- }
16775
-
16776
- var type = void 0;
16777
-
16778
- if (Array.isArray(parsedArgs.type)) {
16779
- type = parsedArgs.type.join();
16780
- } else {
16781
- type = parsedArgs.type;
16782
- }
16783
-
16784
- var body = parsedArgs.body;
16785
- delete parsedArgs.type;
16786
- delete parsedArgs.body;
16787
- delete parsedArgs.stream;
16788
- parsedArgs.streamonly = 'true';
16789
-
16790
- for (var _len = arguments.length, rest = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
16791
- rest[_key - 1] = arguments[_key];
16792
- }
16793
-
16794
- return this.performWsRequest.apply(this, [{
16795
- method: 'POST',
16796
- path: type + '/_search',
16797
- params: parsedArgs,
16798
- body: body
16799
- }].concat(rest));
16800
- }
16801
- /**
16802
- * Webhook Service
16803
- * @param {Object} args
16804
- * @param {String} args.type
16805
- * @param {Object} args.body
16806
- * @param {Object} webhook
16807
- * @param {Function} onData
16808
- * @param {Function} onError
16809
- * @param {Function} onClose
15982
+ * ReactiveSearch API Service for v3
15983
+ * @param {Array<Object>} query
15984
+ * @param {Object} settings
15985
+ * @param {boolean} settings.recordAnalytics
15986
+ * @param {boolean} settings.userId
15987
+ * @param {boolean} settings.enableQueryRules
15988
+ * @param {boolean} settings.customEvents
16810
15989
  */
16811
15990
 
16812
15991
 
16813
- function searchStreamToURLApi(args, webhook) {
16814
- for (var _len = arguments.length, rest = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
16815
- rest[_key - 2] = arguments[_key];
16816
- }
16817
-
16818
- var _this = this;
16819
-
16820
- var parsedArgs = removeUndefined(args);
16821
- var bodyCopy = parsedArgs.body;
16822
- var type = void 0;
16823
- var typeString = void 0; // Validate arguments
16824
-
16825
- var valid = validate(parsedArgs, {
16826
- body: 'object'
16827
- });
16828
-
16829
- if (valid !== true) {
16830
- throw valid;
16831
- }
16832
-
16833
- if (parsedArgs.type === undefined || !(typeof parsedArgs.type === 'string' || Array.isArray(parsedArgs.type)) || parsedArgs.type === '' || parsedArgs.type.length === 0) {
16834
- throw new Error('fields missing: type');
16835
- }
15992
+ function reactiveSearchv3Api(query, settings) {
15993
+ var parsedSettings = removeUndefined(settings); // Validate query
16836
15994
 
16837
- valid = validate(parsedArgs.body, {
16838
- query: 'object'
16839
- });
15995
+ var valid = validateRSQuery(query);
16840
15996
 
16841
15997
  if (valid !== true) {
16842
15998
  throw valid;
16843
15999
  }
16844
16000
 
16845
- if (Array.isArray(parsedArgs.type)) {
16846
- type = parsedArgs.type;
16847
- typeString = parsedArgs.type.join();
16848
- } else {
16849
- type = [parsedArgs.type];
16850
- typeString = parsedArgs.type;
16851
- }
16852
-
16853
- var webhooks = [];
16854
- var _bodyCopy = bodyCopy,
16855
- query = _bodyCopy.query;
16856
-
16857
- if (typeof webhook === 'string') {
16858
- var webHookObj = {};
16859
- webHookObj.url = webhook;
16860
- webHookObj.method = 'GET';
16861
- webhooks.push(webHookObj);
16862
- } else if (webhook.constructor === Array) {
16863
- webhooks = webhook;
16864
- } else if (webhook === Object(webhook)) {
16865
- webhooks.push(webhook);
16866
- } else {
16867
- throw new Error('fields missing: second argument(webhook) is necessary');
16868
- }
16869
-
16870
- var populateBody = function populateBody() {
16871
- bodyCopy = {};
16872
- bodyCopy.webhooks = webhooks;
16873
- bodyCopy.query = query;
16874
- bodyCopy.type = type;
16875
- };
16876
-
16877
- populateBody();
16878
- var encode64 = btoa$1(jsonStableStringify(query));
16879
- var path = '.percolator/webhooks-0-' + typeString + '-0-' + encode64;
16880
-
16881
- this.change = function () {
16882
- webhooks = [];
16883
-
16884
- if (typeof parsedArgs === 'string') {
16885
- var webhook2 = {};
16886
- webhook2.url = parsedArgs;
16887
- webhook2.method = 'POST';
16888
- webhooks.push(webhook2);
16889
- } else if (parsedArgs.constructor === Array) {
16890
- webhooks = parsedArgs;
16891
- } else if (parsedArgs === Object(parsedArgs)) {
16892
- webhooks.push(parsedArgs);
16893
- } else {
16894
- throw new Error('fields missing: one of webhook or url fields is required');
16895
- }
16896
-
16897
- populateBody();
16898
- return _this.performRequest('POST');
16899
- };
16900
-
16901
- this.stop = function () {
16902
- bodyCopy = undefined;
16903
- return _this.performRequest('DELETE');
16904
- };
16905
-
16906
- this.performRequest = function (method) {
16907
- var res = _this.performWsRequest.apply(_this, [{
16908
- method: method,
16909
- path: path,
16910
- body: bodyCopy
16911
- }].concat(rest));
16912
-
16913
- res.change = _this.change;
16914
- res.stop = _this.stop;
16915
- return res;
16001
+ var body = {
16002
+ settings: parsedSettings,
16003
+ query: query
16916
16004
  };
16917
-
16918
- return this.performRequest('POST');
16919
- }
16920
- /**
16921
- * To get types
16922
- */
16923
-
16924
-
16925
- function getTypesService() {
16926
- var _this = this;
16927
-
16928
- return new Promise(function (resolve, reject) {
16929
- try {
16930
- return _this.performFetchRequest({
16931
- method: 'GET',
16932
- path: '_mapping'
16933
- }).then(function (data) {
16934
- var types = Object.keys(data[_this.app].mappings).filter(function (type) {
16935
- return type !== '_default_';
16936
- });
16937
- return resolve(types);
16938
- });
16939
- } catch (e) {
16940
- return reject(e);
16941
- }
16005
+ return this.performFetchRequest({
16006
+ method: 'POST',
16007
+ path: '_reactivesearch.v3',
16008
+ body: body,
16009
+ headers: getTelemetryHeaders(this.enableTelemetry),
16010
+ isRSAPI: true
16942
16011
  });
16943
16012
  }
16944
16013
  /**
@@ -16980,15 +16049,15 @@
16980
16049
  method: 'POST',
16981
16050
  path: '_reactivesearch.v3',
16982
16051
  body: body,
16052
+ headers: getTelemetryHeaders(this.enableTelemetry),
16983
16053
  isRSAPI: true,
16984
16054
  isSuggestionsAPI: true
16985
16055
  });
16986
16056
  }
16987
16057
 
16988
- function index$2(config) {
16058
+ function appbasejs(config) {
16989
16059
  var client = new AppBase(config);
16990
16060
  AppBase.prototype.performFetchRequest = fetchRequest;
16991
- AppBase.prototype.performWsRequest = wsRequest;
16992
16061
  AppBase.prototype.index = indexApi;
16993
16062
  AppBase.prototype.get = getApi;
16994
16063
  AppBase.prototype.update = updateApi;
@@ -16996,12 +16065,9 @@
16996
16065
  AppBase.prototype.bulk = bulkApi;
16997
16066
  AppBase.prototype.search = searchApi;
16998
16067
  AppBase.prototype.msearch = msearchApi;
16068
+ AppBase.prototype.reactiveSearch = reactiveSearchApi;
16999
16069
  AppBase.prototype.reactiveSearchv3 = reactiveSearchv3Api;
17000
16070
  AppBase.prototype.getQuerySuggestions = getSuggestionsv3Api;
17001
- AppBase.prototype.getStream = getStream;
17002
- AppBase.prototype.searchStream = searchStreamApi;
17003
- AppBase.prototype.searchStreamToURL = searchStreamToURLApi;
17004
- AppBase.prototype.getTypes = getTypesService;
17005
16071
  AppBase.prototype.getMappings = getMappings;
17006
16072
 
17007
16073
  AppBase.prototype.setHeaders = function setHeaders() {
@@ -17780,6 +16846,23 @@
17780
16846
  }
17781
16847
  }
17782
16848
  },
16849
+ computed: {
16850
+ getHeaders: function getHeaders() {
16851
+ var _this$$props = this.$props,
16852
+ enableAppbase = _this$$props.enableAppbase,
16853
+ headers = _this$$props.headers,
16854
+ appbaseConfig = _this$$props.appbaseConfig;
16855
+
16856
+ var _ref = appbaseConfig || {},
16857
+ enableTelemetry = _ref.enableTelemetry;
16858
+
16859
+ return _extends({}, enableAppbase && _extends({
16860
+ 'X-Search-Client': X_SEARCH_CLIENT
16861
+ }, enableTelemetry === false && {
16862
+ 'X-Enable-Telemetry': false
16863
+ }), headers);
16864
+ }
16865
+ },
17783
16866
  methods: {
17784
16867
  updateState: function updateState(props) {
17785
16868
  this.setStore(props);
@@ -17832,10 +16915,8 @@
17832
16915
  } catch (e) {// Do not add to selectedValues if JSON parsing fails.
17833
16916
  }
17834
16917
  });
17835
- var _props$headers = props.headers,
17836
- headers = _props$headers === void 0 ? {} : _props$headers,
17837
- themePreset = props.themePreset;
17838
- var appbaseRef = index$2(config);
16918
+ var themePreset = props.themePreset;
16919
+ var appbaseRef = appbasejs(config);
17839
16920
 
17840
16921
  if (this.$props.transformRequest) {
17841
16922
  appbaseRef.transformRequest = this.$props.transformRequest;
@@ -17855,7 +16936,7 @@
17855
16936
  appbaseRef: appbaseRef,
17856
16937
  selectedValues: selectedValues,
17857
16938
  urlValues: urlValues,
17858
- headers: headers
16939
+ headers: this.getHeaders
17859
16940
  }, this.$props.initialState);
17860
16941
 
17861
16942
  this.store = configureStore(initialState);
@@ -17864,10 +16945,9 @@
17864
16945
  render: function render() {
17865
16946
  var h = arguments[0];
17866
16947
  var children = this.$slots["default"];
17867
- var _this$$props = this.$props,
17868
- headers = _this$$props.headers,
17869
- style = _this$$props.style,
17870
- className = _this$$props.className;
16948
+ var _this$$props2 = this.$props,
16949
+ style = _this$$props2.style,
16950
+ className = _this$$props2.className;
17871
16951
  return h(Provider, {
17872
16952
  "attrs": {
17873
16953
  "store": this.store
@@ -17875,7 +16955,7 @@
17875
16955
  }, [h(URLParamsProvider$1, {
17876
16956
  "attrs": {
17877
16957
  "as": this.$props.as,
17878
- "headers": headers,
16958
+ "headers": this.getHeaders,
17879
16959
  "className": className,
17880
16960
  "getSearchParams": this.getSearchParams,
17881
16961
  "setSearchParams": this.setSearchParams
@@ -20971,7 +20051,7 @@
20971
20051
  if (event.key === 'Enter' && highlightedIndex === null) {
20972
20052
  this.setValue(event.target.value, true);
20973
20053
  this.onValueSelectedHandler(event.target.value, lib_7.ENTER_PRESS);
20974
- } // TODO: Remove camelCase events in 2.0
20054
+ } // Need to review
20975
20055
 
20976
20056
 
20977
20057
  this.$emit('keyDown', event, this.triggerQuery);
@@ -24452,9 +23532,15 @@
24452
23532
  this.setQueryOptions(componentId, _extends({}, customQueryOptions, this.getAggsQuery()), false);
24453
23533
  } else this.setQueryOptions(componentId, this.getAggsQuery(), false);
24454
23534
 
23535
+ var queryToSet = query || null;
23536
+
23537
+ if (calcCustomQuery && calcCustomQuery.id) {
23538
+ queryToSet = calcCustomQuery;
23539
+ }
23540
+
24455
23541
  this.updateQuery({
24456
23542
  componentId: componentId,
24457
- query: query,
23543
+ queryToSet: queryToSet,
24458
23544
  value: this.selectedValue || null,
24459
23545
  label: filterLabel,
24460
23546
  showFilter: showFilter,
@@ -24468,6 +23554,12 @@
24468
23554
 
24469
23555
  if (options) {
24470
23556
  _this.setQueryOptions(props.componentId, _extends({}, options, _this.getAggsQuery()), false);
23557
+ }
23558
+
23559
+ var queryToBeSet = obj.query; // when enableAppbase is true, Backend throws error because of repeated query in request body
23560
+
23561
+ if (obj && obj.query && obj.query.query) {
23562
+ queryToBeSet = obj.query.query;
24471
23563
  } // Update customQuery field for RS API
24472
23564
 
24473
23565
 
@@ -24475,7 +23567,11 @@
24475
23567
  var customQueryCalc = _extends({}, options);
24476
23568
 
24477
23569
  if (obj && obj.query) {
24478
- customQueryCalc.query = obj.query;
23570
+ if (obj.query.id) {
23571
+ customQueryCalc = queryToBeSet;
23572
+ } else {
23573
+ customQueryCalc.query = obj.query;
23574
+ }
24479
23575
  }
24480
23576
 
24481
23577
  _this.setCustomQuery(props.componentId, customQueryCalc);
@@ -24506,9 +23602,15 @@
24506
23602
  this.setQueryOptions(this.internalComponent, _extends({}, queryOptions, this.getAggsQuery()), false);
24507
23603
  } else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false);
24508
23604
 
23605
+ var queryToSet = query || null;
23606
+
23607
+ if (!queryToSet && this.$defaultQuery && this.$defaultQuery.id) {
23608
+ queryToSet = this.$defaultQuery;
23609
+ }
23610
+
24509
23611
  this.updateQuery({
24510
23612
  componentId: this.internalComponent,
24511
- query: query || null
23613
+ query: queryToSet
24512
23614
  });
24513
23615
  }
24514
23616
  },
@@ -24567,9 +23669,15 @@
24567
23669
 
24568
23670
 
24569
23671
  updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, undefined);
23672
+ var queryToSet = query || null;
23673
+
23674
+ if (!queryToSet && this.$defaultQuery && this.$defaultQuery.id) {
23675
+ queryToSet = this.$defaultQuery;
23676
+ }
23677
+
24570
23678
  this.updateQuery({
24571
23679
  componentId: this.internalComponent,
24572
- query: query || null
23680
+ query: queryToSet
24573
23681
  });
24574
23682
  }
24575
23683
  },
@@ -24588,9 +23696,15 @@
24588
23696
 
24589
23697
 
24590
23698
  updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, undefined);
23699
+ var queryToSet = query || null;
23700
+
23701
+ if (this.$customQuery && this.$customQuery.id) {
23702
+ queryToSet = this.$customQuery;
23703
+ }
23704
+
24591
23705
  this.updateQuery({
24592
23706
  componentId: componentId,
24593
- query: query || null
23707
+ query: queryToSet
24594
23708
  });
24595
23709
  }
24596
23710
  }
@@ -25623,7 +24737,7 @@
25623
24737
  * Released under the MIT License.
25624
24738
  */
25625
24739
 
25626
- var index$3 = {
24740
+ var index$2 = {
25627
24741
  name: 'NoSsr',
25628
24742
  functional: true,
25629
24743
  props: {
@@ -25663,7 +24777,7 @@
25663
24777
  }) : h(false);
25664
24778
  }
25665
24779
  };
25666
- var vueNoSsr_common = index$3;
24780
+ var vueNoSsr_common = index$2;
25667
24781
 
25668
24782
  var _templateObject$m;
25669
24783
  var Slider = index$1('div')(_templateObject$m || (_templateObject$m = _taggedTemplateLiteralLoose(["\n\tmargin-top: 30px;\n\tpadding: 10px;\n\n\t/* component style */\n\t.vue-slider-disabled {\n\t\topacity: 0.5;\n\t\tcursor: not-allowed;\n\t}\n\n\t/* rail style */\n\t.vue-slider-rail {\n\t\tbackground-color: #ccc;\n\t\tborder-radius: 15px;\n\t\theight: 4px;\n\t}\n\n\t/* process style */\n\t.vue-slider-process {\n\t\tbackground-color: #0b6aff;\n\t\tborder-radius: 15px;\n\t}\n\n\t/* mark style */\n\t.vue-slider-mark {\n\t\tz-index: 4;\n\t}\n\n\t.vue-slider-mark:first-child .vue-slider-mark-step,\n\t.vue-slider-mark:last-child .vue-slider-mark-step {\n\t\tdisplay: none;\n\t}\n\n\t.vue-slider-mark-step {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tborder-radius: 50%;\n\t\tbackground-color: rgba(0, 0, 0, 0.16);\n\t}\n\n\t.vue-slider-mark-label {\n\t\tfont-size: 14px;\n\t\twhite-space: nowrap;\n\t}\n\n\t/* dot style */\n\t.vue-slider-dot{\n\t\tz-index: 2;\n\t}\n\n\t.vue-slider-dot-handle {\n\t\tcursor: pointer;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tborder-radius: 50%;\n\t\tbackground-color: #fff;\n\t\tbox-sizing: border-box;\n\t\tborder: 1px solid #9a9a9a;\n\t\tz-index: 2;\n\t}\n\n\t.vue-slider-dot-handle-disabled {\n\t\tcursor: not-allowed;\n\t\tbackground-color: #ccc;\n\t}\n\n\t.vue-slider-dot-tooltip-inner {\n\t\tfont-size: 14px;\n\t\twhite-space: nowrap;\n\t\tpadding: 2px 5px;\n\t\tmin-width: 20px;\n\t\ttext-align: center;\n\t\tcolor: #fff;\n\t\tborder-radius: 5px;\n\t\tborder-color: #000;\n\t\tbackground-color: #000;\n\t\tbox-sizing: content-box;\n\t}\n\n\t.vue-slider-dot-tooltip-inner::after {\n\t\tcontent: \"\";\n\t\tposition: absolute;\n\t}\n\n\t.vue-slider-dot -tooltip-inner-top::after {\n\t\ttop: 100%;\n\t\tleft: 50%;\n\t\ttransform: translate(-50%, 0);\n\t\theight: 0;\n\t\twidth: 0;\n\t\tborder-color: transparent;\n\t\tborder-style: solid;\n\t\tborder-width: 5px;\n\t\tborder-top-color: inherit;\n\t}\n\n\t.vue-slider-dot-tooltip-inner-bottom::after {\n\t\tbottom: 100%;\n\t\tleft: 50%;\n\t\ttransform: translate(-50%, 0);\n\t\theight: 0;\n\t\twidth: 0;\n\t\tborder-color: transparent;\n\t\tborder-style: solid;\n\t\tborder-width: 5px;\n\t\tborder-bottom-color: inherit;\n\t}\n\n\t.vue-slider-dot-tooltip-inner-left::after {\n\t\tleft: 100%;\n\t\ttop: 50%;\n\t\ttransform: translate(0, -50%);\n\t\theight: 0;\n\t\twidth: 0;\n\t\tborder-color: transparent;\n\t\tborder-style: solid;\n\t\tborder-width: 5px;\n\t\tborder-left-color: inherit;\n\t}\n\n\t.vue-slider-dot-tooltip-inner-right::after {\n\t\tright: 100%;\n\t\ttop: 50%;\n\t\ttransform: translate(0, -50%);\n\t\theight: 0;\n\t\twidth: 0;\n\t\tborder-color: transparent;\n\t\tborder-style: solid;\n\t\tborder-width: 5px;\n\t\tborder-right-color: inherit;\n\t}\n\n\t.vue-slider-dot-tooltip-wrapper {\n\t\topacity: 0;\n\t\ttransition: all 0.3s;\n\t}\n\t.vue-slider-dot-tooltip-wrapper-show {\n\t\topacity: 1;\n\t}\n\n\t.label-container {\n\t\tmargin: 10px 0;\n\t\twidth: 100%;\n\t}\n\n\t.range-label-right {\n\t\tfloat: right;\n\t}\n"])));
@@ -26475,7 +25589,7 @@
26475
25589
  watch: {
26476
25590
  searchState: function searchState(newVal, oldVal) {
26477
25591
  if (this.isStateChanged(newVal, oldVal)) {
26478
- this.$emit('change', newVal, oldVal);
25592
+ this.$emit('change', oldVal, newVal);
26479
25593
  }
26480
25594
  },
26481
25595
  selectedValues: function selectedValues(newVal, oldVal) {
@@ -33350,6 +32464,7 @@
33350
32464
  ReactiveGoogleMap.componentType = constants_1$1.reactiveMap;
33351
32465
 
33352
32466
  var _excluded$5 = ["aggs", "size"];
32467
+ var X_SEARCH_CLIENT$1 = 'ReactiveSearch Vue';
33353
32468
  var componentsWithHighlightQuery = [constants_1$1.dataSearch, constants_1$1.categorySearch];
33354
32469
  var componentsWithOptions = [constants_1$1.reactiveList, constants_1$1.reactiveMap, constants_1$1.singleList, constants_1$1.multiList, constants_1$1.tagCloud].concat(componentsWithHighlightQuery);
33355
32470
  var componentsWithoutFilters = [constants_1$1.numberBox, constants_1$1.ratingsFilter];
@@ -33407,6 +32522,14 @@
33407
32522
  function initReactivesearch(componentCollection, searchState, settings) {
33408
32523
  return new Promise(function (resolve, reject) {
33409
32524
  var credentials = settings.url && settings.url.trim() !== '' && !settings.credentials ? null : settings.credentials;
32525
+ var enableTelemetry = settings.appbaseConfig && settings.appbaseConfig.enableTelemetry !== undefined ? settings.appbaseConfig.enableTelemetry : true;
32526
+
32527
+ var headers = _extends({}, settings.enableAppbase && _extends({
32528
+ 'X-Search-Client': X_SEARCH_CLIENT$1
32529
+ }, enableTelemetry === false && {
32530
+ 'X-Enable-Telemetry': false
32531
+ }), settings.headers);
32532
+
33410
32533
  var config = {
33411
32534
  url: settings.url && settings.url.trim() !== '' ? settings.url : 'https://scalr.api.appbase.io',
33412
32535
  app: settings.app,
@@ -33415,10 +32538,10 @@
33415
32538
  type: settings.type ? settings.type : '*',
33416
32539
  transformResponse: settings.transformResponse || null,
33417
32540
  graphQLUrl: settings.graphQLUrl || '',
33418
- headers: settings.headers || {},
32541
+ headers: headers,
33419
32542
  analyticsConfig: settings.appbaseConfig || null
33420
32543
  };
33421
- var appbaseRef = index$2(config);
32544
+ var appbaseRef = appbasejs(config);
33422
32545
  var components = [];
33423
32546
  var selectedValues = {};
33424
32547
  var internalValues = {};
@@ -33637,8 +32760,9 @@
33637
32760
  appbaseQuery = _extends({}, appbaseQuery, (_extends3 = {}, _extends3[component.componentId] = query, _extends3), transform_1(state, component.componentId, orderOfQueries));
33638
32761
  }
33639
32762
  } else {
32763
+ var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + "_" + component : component;
33640
32764
  finalQuery = [].concat(finalQuery, [{
33641
- preference: component.componentId
32765
+ preference: preference
33642
32766
  }, currentQuery]);
33643
32767
  }
33644
32768
  }
@@ -33792,7 +32916,7 @@
33792
32916
  });
33793
32917
  }
33794
32918
 
33795
- var version = "1.16.0-alpha.20";
32919
+ var version = "1.16.0-alpha.24";
33796
32920
 
33797
32921
  var _templateObject$o, _templateObject2$b;
33798
32922
 
@@ -34120,7 +33244,7 @@
34120
33244
  if (typeof window !== 'undefined' && window.Vue) {
34121
33245
  install(window.Vue);
34122
33246
  }
34123
- var index$4 = {
33247
+ var index$3 = {
34124
33248
  version: version,
34125
33249
  install: install
34126
33250
  };
@@ -34144,7 +33268,7 @@
34144
33268
  exports.SingleRange = SingleRange;
34145
33269
  exports.StateProvider = StateProvider;
34146
33270
  exports.ToggleButton = ToggleButton;
34147
- exports.default = index$4;
33271
+ exports.default = index$3;
34148
33272
  exports.initReactivesearch = initReactivesearch;
34149
33273
  exports.install = install;
34150
33274
  exports.version = version;