@appbaseio/reactivesearch-vue 1.16.0-alpha.6 → 1.16.0-alpha.62

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 (105) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +16030 -13113
  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/Button-446f819e.js +68 -0
  6. package/dist/cjs/{DownShift-966a58cb.js → CancelSvg-9f258f4f.js} +60 -16
  7. package/dist/cjs/Card-642547a8.js +30 -0
  8. package/dist/cjs/{ComponentWrapper-603848ed.js → ComponentWrapper-ad3dad02.js} +40 -21
  9. package/dist/cjs/{Container-6cdd3864.js → Container-daf30918.js} +3 -11
  10. package/dist/cjs/DataSearch-86914b10.js +2322 -0
  11. package/dist/cjs/DataSearch.js +18 -2151
  12. package/dist/cjs/{DropDown-f6224ac8.js → DropDown-5513ea77.js} +80 -95
  13. package/dist/cjs/DynamicRangeSlider.js +107 -43
  14. package/dist/cjs/Flex-aa517a13.js +52 -0
  15. package/dist/cjs/FormControlList-c195a592.js +47 -0
  16. package/dist/cjs/Input-e6603a7e.js +79 -0
  17. package/dist/cjs/ListItem-8c9e0d68.js +46 -0
  18. package/dist/cjs/MultiDropdownList.js +102 -68
  19. package/dist/cjs/MultiList.js +80 -50
  20. package/dist/cjs/MultiRange.js +21 -16
  21. package/dist/cjs/{Pagination-af399262.js → Pagination-fe5452fc.js} +14 -8
  22. package/dist/cjs/RangeInput.js +29 -45
  23. package/dist/cjs/RangeSlider.js +32 -30
  24. package/dist/cjs/ReactiveBase.js +87 -56
  25. package/dist/cjs/ReactiveComponent.js +75 -62
  26. package/dist/cjs/ReactiveGoogleMap.js +262 -191
  27. package/dist/cjs/ReactiveList.js +189 -241
  28. package/dist/cjs/ResultCard.js +8 -6
  29. package/dist/cjs/ResultList.js +8 -6
  30. package/dist/cjs/SelectedFilters.js +66 -34
  31. package/dist/cjs/SingleDropdownList.js +88 -60
  32. package/dist/cjs/SingleList.js +53 -35
  33. package/dist/cjs/SingleRange.js +19 -14
  34. package/dist/cjs/StateProvider.js +39 -10
  35. package/dist/cjs/{Title-65d39104.js → Title-1de7d0f4.js} +3 -11
  36. package/dist/cjs/ToggleButton.js +36 -16
  37. package/dist/cjs/{_rollupPluginBabelHelpers-4abdbfff.js → _rollupPluginBabelHelpers-c705cbe6.js} +2 -4
  38. package/dist/cjs/{index-baca18c4.js → index-6a167fe0.js} +99 -13
  39. package/dist/cjs/index.js +31 -25
  40. package/dist/cjs/initReactivesearch.js +178 -104
  41. package/dist/cjs/install-004c6aa4.js +1408 -0
  42. package/dist/cjs/install.js +42 -44
  43. package/dist/cjs/ssr-3027b848.js +39 -0
  44. package/dist/cjs/{utils-ea846a20.js → utils-d6a52588.js} +2 -2
  45. package/dist/cjs/version.js +1 -1
  46. package/dist/cjs/{vueTypes-c21f265b.js → vueTypes-6de9d2a9.js} +9 -4
  47. package/dist/es/Button-d8bc15ea.js +59 -0
  48. package/dist/es/{DownShift-92347b5e.js → CancelSvg-4cfae5fd.js} +56 -17
  49. package/dist/es/Card-450683f1.js +23 -0
  50. package/dist/es/{ComponentWrapper-c4c91949.js → ComponentWrapper-424e86fd.js} +40 -21
  51. package/dist/es/Container-ba826e96.js +10 -0
  52. package/dist/es/DataSearch-e71a1014.js +2307 -0
  53. package/dist/es/DataSearch.js +17 -2150
  54. package/dist/es/{DropDown-3d4291f1.js → DropDown-7d9a15c1.js} +79 -94
  55. package/dist/es/DynamicRangeSlider.js +107 -43
  56. package/dist/es/Flex-1f0795c3.js +47 -0
  57. package/dist/es/FormControlList-c22d64f6.js +40 -0
  58. package/dist/es/Input-7a2a9fac.js +71 -0
  59. package/dist/es/ListItem-cad14c5e.js +39 -0
  60. package/dist/es/MultiDropdownList.js +102 -68
  61. package/dist/es/MultiList.js +80 -50
  62. package/dist/es/MultiRange.js +21 -16
  63. package/dist/es/{Pagination-c2a00175.js → Pagination-3f350098.js} +14 -8
  64. package/dist/es/RangeInput.js +29 -45
  65. package/dist/es/RangeSlider.js +32 -30
  66. package/dist/es/ReactiveBase.js +87 -56
  67. package/dist/es/ReactiveComponent.js +75 -62
  68. package/dist/es/ReactiveGoogleMap.js +262 -191
  69. package/dist/es/ReactiveList.js +189 -241
  70. package/dist/es/ResultCard.js +8 -6
  71. package/dist/es/ResultList.js +8 -6
  72. package/dist/es/SelectedFilters.js +66 -34
  73. package/dist/es/SingleDropdownList.js +88 -60
  74. package/dist/es/SingleList.js +53 -35
  75. package/dist/es/SingleRange.js +19 -14
  76. package/dist/es/StateProvider.js +39 -10
  77. package/dist/es/Title-3342664a.js +10 -0
  78. package/dist/es/ToggleButton.js +36 -16
  79. package/dist/es/{_rollupPluginBabelHelpers-ecf6c03c.js → _rollupPluginBabelHelpers-76660dab.js} +2 -4
  80. package/dist/es/{index-185b6266.js → index-7788a843.js} +95 -14
  81. package/dist/es/index.js +27 -22
  82. package/dist/es/initReactivesearch.js +179 -105
  83. package/dist/es/install-b7b604cc.js +1401 -0
  84. package/dist/es/install.js +40 -46
  85. package/dist/es/ssr-b2c0b401.js +33 -0
  86. package/dist/es/{utils-57cc8789.js → utils-9e68acee.js} +2 -2
  87. package/dist/es/version.js +1 -1
  88. package/dist/es/{vueTypes-98d938a9.js → vueTypes-9326e0be.js} +9 -4
  89. package/package.json +6 -4
  90. package/dist/cjs/Button-d48d4365.js +0 -146
  91. package/dist/cjs/Card-9748fbb2.js +0 -58
  92. package/dist/cjs/Flex-befd65fc.js +0 -160
  93. package/dist/cjs/FormControlList-f3857d4b.js +0 -105
  94. package/dist/cjs/Input-95cb19f8.js +0 -178
  95. package/dist/cjs/ListItem-84d185cf.js +0 -84
  96. package/dist/cjs/ssr-3ca8a14f.js +0 -47
  97. package/dist/es/Button-27cc8574.js +0 -137
  98. package/dist/es/Card-1f93780d.js +0 -51
  99. package/dist/es/Container-88c805ef.js +0 -18
  100. package/dist/es/Flex-16d1103a.js +0 -155
  101. package/dist/es/FormControlList-96d44e7b.js +0 -98
  102. package/dist/es/Input-1159c4b5.js +0 -170
  103. package/dist/es/ListItem-d22510c9.js +0 -77
  104. package/dist/es/Title-f0217338.js +0 -18
  105. package/dist/es/ssr-a710392b.js +0 -41
@@ -1,35 +1,46 @@
1
- import { b as _objectWithoutPropertiesLoose, a as _extends } from './_rollupPluginBabelHelpers-ecf6c03c.js';
1
+ import { a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-76660dab.js';
2
2
  import { validProps, componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
3
- import { getRSQuery, extractPropsFromState, getDependentQueries } from '@appbaseio/reactivecore/lib/utils/transform';
4
- import { pushToAndClause, buildQuery } from '@appbaseio/reactivecore/lib/utils/helper';
3
+ import { pushToAndClause, buildQuery, extractQueryFromCustomQuery, getOptionsForCustomQuery } from '@appbaseio/reactivecore/lib/utils/helper';
4
+ import { isSearchComponent, getRSQuery, extractPropsFromState, getDependentQueries } from '@appbaseio/reactivecore/lib/utils/transform';
5
5
  import Appbase from 'appbase-js';
6
6
  import valueReducer from '@appbaseio/reactivecore/lib/reducers/valueReducer';
7
7
  import queryReducer from '@appbaseio/reactivecore/lib/reducers/queryReducer';
8
8
  import queryOptionsReducer from '@appbaseio/reactivecore/lib/reducers/queryOptionsReducer';
9
+ import compositeAggsReducer from '@appbaseio/reactivecore/lib/reducers/compositeAggsReducer';
10
+ import { UPDATE_COMPOSITE_AGGS } from '@appbaseio/reactivecore/lib/constants';
9
11
  import dependencyTreeReducer from '@appbaseio/reactivecore/lib/reducers/dependencyTreeReducer';
10
12
  import fetchGraphQL from '@appbaseio/reactivecore/lib/utils/graphQL';
11
13
  import { isPropertyDefined } from '@appbaseio/reactivecore/lib/actions/utils';
12
14
 
13
- var componentsWithHighlightQuery = [componentTypes.dataSearch, componentTypes.categorySearch];
14
- var componentsWithOptions = [componentTypes.reactiveList, componentTypes.reactiveMap, componentTypes.singleList, componentTypes.multiList, componentTypes.tagCloud].concat(componentsWithHighlightQuery);
15
+ var _excluded = ["aggs", "size"],
16
+ _excluded2 = ["query"],
17
+ _excluded3 = ["query"];
18
+ var X_SEARCH_CLIENT = 'ReactiveSearch Vue';
15
19
  var componentsWithoutFilters = [componentTypes.numberBox, componentTypes.ratingsFilter];
16
20
  var resultComponents = [componentTypes.reactiveList, componentTypes.reactiveMap];
17
21
 
18
22
  function getValue(state, id, defaultValue) {
19
- if (!state) return defaultValue;
20
-
21
- if (state[id]) {
23
+ if (state && state[id]) {
22
24
  try {
23
25
  // parsing for next.js - since it uses extra set of quotes to wrap params
24
26
  var parsedValue = JSON.parse(state[id]);
25
- return parsedValue;
27
+ return {
28
+ value: parsedValue,
29
+ reference: 'URL'
30
+ };
26
31
  } catch (error) {
27
32
  // using react-dom-server for ssr
28
- return state[id] || defaultValue;
33
+ return {
34
+ value: state[id],
35
+ reference: 'URL'
36
+ };
29
37
  }
30
38
  }
31
39
 
32
- return defaultValue;
40
+ return {
41
+ value: defaultValue,
42
+ reference: 'DEFAULT'
43
+ };
33
44
  }
34
45
 
35
46
  function parseValue(value, component) {
@@ -38,28 +49,53 @@ function parseValue(value, component) {
38
49
  }
39
50
 
40
51
  return value;
41
- }
52
+ } // Returns query DSL with query property and other options
42
53
 
43
- function getQuery(component, value, componentType) {
44
- // get default query of result components
45
- if (resultComponents.includes(componentType)) {
46
- return component.defaultQuery ? component.defaultQuery() : {};
47
- } // get custom or default query of sensor components
48
54
 
55
+ function getDefaultQuery(component, value) {
56
+ // get custom or default query of sensor components
57
+ var currentValue = parseValue(value, component); // get default query of result components
58
+
59
+ if (component.defaultQuery) {
60
+ var defaultQuery = component.defaultQuery(currentValue, component);
61
+ return _extends({
62
+ query: extractQueryFromCustomQuery(defaultQuery)
63
+ }, getOptionsForCustomQuery(defaultQuery));
64
+ }
65
+
66
+ return component.source.defaultQuery ? {
67
+ query: component.source.defaultQuery(currentValue, component)
68
+ } : {};
69
+ } // Only results the query part
49
70
 
71
+
72
+ function getCustomQuery(component, value) {
73
+ // get custom or default query of sensor components
50
74
  var currentValue = parseValue(value, component);
51
75
 
52
76
  if (component.customQuery) {
53
77
  var customQuery = component.customQuery(currentValue, component);
54
- return customQuery && customQuery.query;
78
+ return _extends({
79
+ query: extractQueryFromCustomQuery(customQuery)
80
+ }, getOptionsForCustomQuery(customQuery));
55
81
  }
56
82
 
57
- return component.source.defaultQuery ? component.source.defaultQuery(currentValue, component) : {};
83
+ return component.source.defaultQuery ? {
84
+ query: component.source.defaultQuery(currentValue, component)
85
+ } : null;
58
86
  }
59
87
 
60
88
  function initReactivesearch(componentCollection, searchState, settings) {
61
89
  return new Promise(function (resolve, reject) {
62
90
  var credentials = settings.url && settings.url.trim() !== '' && !settings.credentials ? null : settings.credentials;
91
+ var enableTelemetry = settings.appbaseConfig && settings.appbaseConfig.enableTelemetry !== undefined ? settings.appbaseConfig.enableTelemetry : true;
92
+
93
+ var headers = _extends({}, settings.enableAppbase && _extends({
94
+ 'X-Search-Client': X_SEARCH_CLIENT
95
+ }, enableTelemetry === false && {
96
+ 'X-Enable-Telemetry': false
97
+ }), settings.headers);
98
+
63
99
  var config = {
64
100
  url: settings.url && settings.url.trim() !== '' ? settings.url : 'https://scalr.api.appbase.io',
65
101
  app: settings.app,
@@ -68,7 +104,7 @@ function initReactivesearch(componentCollection, searchState, settings) {
68
104
  type: settings.type ? settings.type : '*',
69
105
  transformResponse: settings.transformResponse || null,
70
106
  graphQLUrl: settings.graphQLUrl || '',
71
- headers: settings.headers || {},
107
+ headers: headers,
72
108
  analyticsConfig: settings.appbaseConfig || null
73
109
  };
74
110
  var appbaseRef = Appbase(config);
@@ -85,6 +121,7 @@ function initReactivesearch(componentCollection, searchState, settings) {
85
121
  var orderOfQueries = [];
86
122
  var hits = {};
87
123
  var aggregations = {};
124
+ var compositeAggregations = {};
88
125
  var state = {};
89
126
  var customQueries = {};
90
127
  var defaultQueries = {};
@@ -99,20 +136,20 @@ function initReactivesearch(componentCollection, searchState, settings) {
99
136
  compProps[key] = component[key];
100
137
  }
101
138
  });
102
- var isInternalComponentPresent = false; // Set custom and default queries
139
+ var isInternalComponentPresent = false;
103
140
 
104
- if (component.customQuery && typeof component.customQuery === 'function') {
105
- customQueries[component.componentId] = component.customQuery(component.value, compProps);
106
- }
107
-
108
- if (component.defaultQuery && typeof component.defaultQuery === 'function') {
109
- defaultQueries[component.componentId] = component.defaultQuery(component.value, compProps);
141
+ if (component.source.hasInternalComponent) {
142
+ isInternalComponentPresent = component.source.hasInternalComponent(component);
110
143
  }
111
144
 
112
145
  var isResultComponent = resultComponents.includes(componentType);
113
146
  var internalComponent = component.componentId + "__internal";
114
147
  var label = component.filterLabel || component.componentId;
115
- var value = getValue(searchState, component.componentId, component.value || component.defaultValue); // [1] set selected values
148
+
149
+ var _getValue = getValue(searchState, component.componentId, component.value || component.defaultValue),
150
+ value = _getValue.value,
151
+ reference = _getValue.reference; // [1] set selected values
152
+
116
153
 
117
154
  var showFilter = component.showFilter !== undefined ? component.showFilter : true;
118
155
 
@@ -125,75 +162,77 @@ function initReactivesearch(componentCollection, searchState, settings) {
125
162
  component: component.componentId,
126
163
  label: label,
127
164
  value: value,
165
+ reference: reference,
128
166
  showFilter: showFilter,
129
167
  URLParams: component.URLParams || false
130
- }); // [2] set query options - main component query (valid for result components)
168
+ }); // Set custom and default queries
131
169
 
132
- if (componentsWithOptions.includes(componentType)) {
133
- var options = component.source.generateQueryOptions ? component.source.generateQueryOptions(component) : null;
134
- var highlightQuery = {};
170
+ if (component.customQuery && typeof component.customQuery === 'function') {
171
+ customQueries[component.componentId] = component.customQuery(value, compProps);
172
+ }
135
173
 
136
- if (componentsWithHighlightQuery.includes(componentType) && component.highlight) {
137
- highlightQuery = component.source.highlightQuery(component);
138
- }
174
+ if (component.defaultQuery && typeof component.defaultQuery === 'function') {
175
+ defaultQueries[component.componentId] = component.defaultQuery(value, compProps);
176
+ }
139
177
 
140
- if (options && Object.keys(options).length || highlightQuery && Object.keys(highlightQuery).length) {
141
- // eslint-disable-next-line
142
- var _ref = options || {},
143
- aggs = _ref.aggs,
144
- size = _ref.size,
145
- otherQueryOptions = _objectWithoutPropertiesLoose(_ref, ["aggs", "size"]);
146
-
147
- if (aggs && Object.keys(aggs).length) {
148
- isInternalComponentPresent = true; // query should be applied on the internal component
149
- // to enable feeding the data to parent component
150
-
151
- queryOptions = queryOptionsReducer(queryOptions, {
152
- type: 'SET_QUERY_OPTIONS',
153
- component: internalComponent,
154
- options: {
155
- aggs: aggs,
156
- size: typeof size === 'undefined' ? 100 : size
157
- }
158
- });
159
- } // sort, highlight, size, from - query should be applied on the main component
178
+ var componentQueryOptions = {}; // [2] set query options - main component query (valid for result components)
160
179
 
180
+ if (component && component.source.generateQueryOptions) {
181
+ componentQueryOptions = _extends({}, componentQueryOptions, component.source.generateQueryOptions(component));
182
+ }
161
183
 
162
- if (otherQueryOptions && Object.keys(otherQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
163
- if (!otherQueryOptions) otherQueryOptions = {};
164
- if (!highlightQuery) highlightQuery = {};
184
+ var highlightQuery = {};
165
185
 
166
- var mainQueryOptions = _extends(_extends(_extends({}, otherQueryOptions), highlightQuery), {}, {
167
- size: size
168
- });
186
+ if (component.source.highlightQuery) {
187
+ highlightQuery = component.source.highlightQuery(component);
188
+ }
169
189
 
170
- if (isInternalComponentPresent) {
171
- mainQueryOptions = _extends(_extends({}, otherQueryOptions), highlightQuery);
172
- }
190
+ if (componentQueryOptions && Object.keys(componentQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
191
+ // eslint-disable-next-line
192
+ var _ref = componentQueryOptions || {},
193
+ aggs = _ref.aggs,
194
+ size = _ref.size,
195
+ otherQueryOptions = _objectWithoutPropertiesLoose(_ref, _excluded);
196
+
197
+ if (aggs && Object.keys(aggs).length) {
198
+ isInternalComponentPresent = true;
199
+ componentQueryOptions = _extends({}, componentQueryOptions, {
200
+ aggs: aggs,
201
+ size: typeof size === 'undefined' ? 100 : size
202
+ });
203
+ } // sort, highlight, size, from - query should be applied on the main component
173
204
 
174
- if (isResultComponent) {
175
- var currentPage = component.currentPage ? component.currentPage - 1 : 0;
176
205
 
177
- if (selectedValues[component.componentId] && selectedValues[component.componentId].value) {
178
- currentPage = selectedValues[component.componentId].value - 1 || 0;
179
- }
206
+ if (otherQueryOptions && Object.keys(otherQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
207
+ if (!otherQueryOptions) otherQueryOptions = {};
208
+ if (!highlightQuery) highlightQuery = {};
180
209
 
181
- var resultSize = component.size || 10;
182
- var from = currentPage * resultSize; // Update props for RS API
210
+ var mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery, {
211
+ size: size
212
+ });
183
213
 
184
- compProps.from = from;
185
- mainQueryOptions = _extends(_extends(_extends({}, mainQueryOptions), highlightQuery), {}, {
186
- size: resultSize,
187
- from: from
188
- });
214
+ if (isInternalComponentPresent) {
215
+ mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery);
216
+ }
217
+
218
+ if (isResultComponent) {
219
+ var currentPage = component.currentPage ? component.currentPage - 1 : 0;
220
+
221
+ if (selectedValues[component.componentId] && selectedValues[component.componentId].value) {
222
+ currentPage = selectedValues[component.componentId].value - 1 || 0;
189
223
  }
190
224
 
191
- queryOptions = queryOptionsReducer(queryOptions, {
192
- type: 'SET_QUERY_OPTIONS',
193
- component: component.componentId,
194
- options: _extends({}, mainQueryOptions)
225
+ var resultSize = component.size || 10;
226
+ var from = currentPage * resultSize; // Update props for RS API
227
+
228
+ compProps.from = from;
229
+ mainQueryOptions = _extends({}, mainQueryOptions, highlightQuery, {
230
+ size: resultSize,
231
+ from: from
195
232
  });
196
233
  }
234
+
235
+ componentQueryOptions = _extends({}, componentQueryOptions, mainQueryOptions);
197
236
  }
198
237
  } // [3] set dependency tree
199
238
 
@@ -211,25 +250,42 @@ function initReactivesearch(componentCollection, searchState, settings) {
211
250
  react: react
212
251
  });
213
252
  } // [4] set query list
253
+ // Do not set default query for suggestions
214
254
 
215
255
 
216
- if (isResultComponent) {
217
- var _getQuery = getQuery(component, null, componentType),
218
- query = _getQuery.query;
256
+ if (isInternalComponentPresent && !isSearchComponent(component.componentType)) {
257
+ var _ref2 = getDefaultQuery(component, value) || {},
258
+ defaultQuery = _ref2.query,
259
+ defaultQueryOptions = _objectWithoutPropertiesLoose(_ref2, _excluded2);
219
260
 
220
261
  queryList = queryReducer(queryList, {
221
262
  type: 'SET_QUERY',
222
263
  component: internalComponent,
223
- query: query
264
+ query: defaultQuery
224
265
  });
225
- } else {
226
- queryList = queryReducer(queryList, {
227
- type: 'SET_QUERY',
228
- component: component.componentId,
229
- query: getQuery(component, value, componentType)
266
+ queryOptions = queryOptionsReducer(queryOptions, {
267
+ type: 'SET_QUERY_OPTIONS',
268
+ component: internalComponent,
269
+ options: _extends({}, componentQueryOptions, defaultQueryOptions)
230
270
  });
231
- } // Set component type in component props
271
+ }
272
+
273
+ var _ref3 = getCustomQuery(component, value) || {},
274
+ query = _ref3.query,
275
+ options = _objectWithoutPropertiesLoose(_ref3, _excluded3);
276
+
277
+ var customQuery = query; // set custom query for main component
232
278
 
279
+ queryList = queryReducer(queryList, {
280
+ type: 'SET_QUERY',
281
+ component: component.componentId,
282
+ query: customQuery
283
+ });
284
+ queryOptions = queryOptionsReducer(queryOptions, {
285
+ type: 'SET_QUERY_OPTIONS',
286
+ component: component.componentId,
287
+ options: _extends({}, options)
288
+ }); // Set component type in component props
233
289
 
234
290
  compProps.componentType = componentType;
235
291
  componentProps[component.componentId] = compProps;
@@ -252,9 +308,10 @@ function initReactivesearch(componentCollection, searchState, settings) {
252
308
  queryObj = _buildQuery.queryObj,
253
309
  options = _buildQuery.options;
254
310
 
255
- var validOptions = ['aggs', 'from', 'sort']; // check if query or options are valid - non-empty
311
+ var componentQueryOptions = options;
312
+ var validOptions = ['aggs', 'from', 'sort']; // check if query or componentQueryOptions are valid - non-empty
256
313
 
257
- if (queryObj && !!Object.keys(queryObj).length || options && Object.keys(options).some(function (item) {
314
+ if (queryObj && !!Object.keys(queryObj).length || componentQueryOptions && Object.keys(componentQueryOptions).some(function (item) {
258
315
  return validOptions.includes(item);
259
316
  })) {
260
317
  var _extends2;
@@ -267,14 +324,14 @@ function initReactivesearch(componentCollection, searchState, settings) {
267
324
 
268
325
  orderOfQueries = [].concat(orderOfQueries, [component.componentId]);
269
326
 
270
- var currentQuery = _extends(_extends({
327
+ var currentQuery = _extends({
271
328
  query: _extends({}, queryObj)
272
- }, options), queryOptions[component.componentId]);
329
+ }, componentQueryOptions, queryOptions[component.componentId]);
273
330
 
274
- queryLog = _extends(_extends({}, queryLog), {}, (_extends2 = {}, _extends2[component.componentId] = currentQuery, _extends2));
331
+ queryLog = _extends({}, queryLog, (_extends2 = {}, _extends2[component.componentId] = currentQuery, _extends2));
275
332
 
276
333
  if (settings.enableAppbase) {
277
- var query = getRSQuery(component.componentId, extractPropsFromState(state, component.componentId, queryOptions && queryOptions[component.componentId] ? {
334
+ var query = getRSQuery(component.componentId, extractPropsFromState(state, component.componentId, queryOptions && Object.keys(queryOptions[component.componentId]).length ? {
278
335
  from: queryOptions[component.componentId].from
279
336
  } : null));
280
337
 
@@ -282,11 +339,12 @@ function initReactivesearch(componentCollection, searchState, settings) {
282
339
  var _extends3;
283
340
 
284
341
  // Apply dependent queries
285
- appbaseQuery = _extends(_extends(_extends({}, appbaseQuery), (_extends3 = {}, _extends3[component.componentId] = query, _extends3)), getDependentQueries(state, component.componentId, orderOfQueries));
342
+ appbaseQuery = _extends({}, appbaseQuery, (_extends3 = {}, _extends3[component.componentId] = query, _extends3), getDependentQueries(state, component.componentId, orderOfQueries));
286
343
  }
287
344
  } else {
345
+ var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + "_" + component : component;
288
346
  finalQuery = [].concat(finalQuery, [{
289
- preference: component.componentId
347
+ preference: preference
290
348
  }, currentQuery]);
291
349
  }
292
350
  }
@@ -312,10 +370,15 @@ function initReactivesearch(componentCollection, searchState, settings) {
312
370
  if (response.aggregations) {
313
371
  var _extends4;
314
372
 
315
- aggregations = _extends(_extends({}, aggregations), {}, (_extends4 = {}, _extends4[component] = response.aggregations, _extends4));
373
+ aggregations = _extends({}, aggregations, (_extends4 = {}, _extends4[component] = response.aggregations, _extends4));
374
+ compositeAggregations = compositeAggsReducer(compositeAggregations, {
375
+ type: UPDATE_COMPOSITE_AGGS,
376
+ aggregations: response.aggregations,
377
+ append: false
378
+ });
316
379
  }
317
380
 
318
- hits = _extends(_extends({}, hits), {}, (_extends5 = {}, _extends5[component] = {
381
+ hits = _extends({}, hits, (_extends5 = {}, _extends5[component] = {
319
382
  hits: response.hits.hits,
320
383
  total: typeof response.hits.total === 'object' ? response.hits.total.value : response.hits.total,
321
384
  time: response.took
@@ -327,7 +390,7 @@ function initReactivesearch(componentCollection, searchState, settings) {
327
390
  });
328
391
  });
329
392
  Promise.all(allPromises).then(function () {
330
- state = _extends(_extends({}, state), {}, {
393
+ state = _extends({}, state, {
331
394
  hits: hits,
332
395
  aggregations: aggregations
333
396
  });
@@ -339,6 +402,8 @@ function initReactivesearch(componentCollection, searchState, settings) {
339
402
  var promotedResults = {};
340
403
  var rawData = {};
341
404
  var customData = {};
405
+ var settingsResponse = {};
406
+ var timestamp = {};
342
407
  var allPromises = orderOfQueries.map(function (component) {
343
408
  return new Promise(function (responseResolve, responseReject) {
344
409
  handleTransformResponse(res[component], component).then(function (response) {
@@ -347,7 +412,7 @@ function initReactivesearch(componentCollection, searchState, settings) {
347
412
 
348
413
  if (response.promoted) {
349
414
  promotedResults[component] = response.promoted.map(function (promoted) {
350
- return _extends(_extends({}, promoted.doc), {}, {
415
+ return _extends({}, promoted.doc, {
351
416
  _position: promoted.position
352
417
  });
353
418
  });
@@ -357,15 +422,21 @@ function initReactivesearch(componentCollection, searchState, settings) {
357
422
 
358
423
  if (response.customData) {
359
424
  customData[component] = response.customData;
425
+ } // Update settings
426
+
427
+
428
+ if (response.settings) {
429
+ settingsResponse[component] = response.settings;
360
430
  }
361
431
 
362
432
  if (response.aggregations) {
363
433
  var _extends6;
364
434
 
365
- aggregations = _extends(_extends({}, aggregations), {}, (_extends6 = {}, _extends6[component] = response.aggregations, _extends6));
435
+ aggregations = _extends({}, aggregations, (_extends6 = {}, _extends6[component] = response.aggregations, _extends6));
366
436
  }
367
437
 
368
- hits = _extends(_extends({}, hits), {}, (_extends7 = {}, _extends7[component] = {
438
+ timestamp[component] = res._timestamp;
439
+ hits = _extends({}, hits, (_extends7 = {}, _extends7[component] = {
369
440
  hits: response.hits.hits,
370
441
  total: typeof response.hits.total === 'object' ? response.hits.total.value : response.hits.total,
371
442
  time: response.took
@@ -378,10 +449,13 @@ function initReactivesearch(componentCollection, searchState, settings) {
378
449
  });
379
450
  });
380
451
  Promise.all(allPromises).then(function () {
381
- state = _extends(_extends({}, state), {}, {
452
+ state = _extends({}, state, {
382
453
  hits: hits,
454
+ timestamp: timestamp,
383
455
  aggregations: aggregations,
456
+ compositeAggregations: compositeAggregations,
384
457
  promotedResults: promotedResults,
458
+ settings: settingsResponse,
385
459
  customData: customData,
386
460
  rawData: rawData
387
461
  });