@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.
- package/dist/@appbaseio/reactivesearch-vue.umd.js +16030 -13113
- package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
- package/dist/cjs/Button-446f819e.js +68 -0
- package/dist/cjs/{DownShift-966a58cb.js → CancelSvg-9f258f4f.js} +60 -16
- package/dist/cjs/Card-642547a8.js +30 -0
- package/dist/cjs/{ComponentWrapper-603848ed.js → ComponentWrapper-ad3dad02.js} +40 -21
- package/dist/cjs/{Container-6cdd3864.js → Container-daf30918.js} +3 -11
- package/dist/cjs/DataSearch-86914b10.js +2322 -0
- package/dist/cjs/DataSearch.js +18 -2151
- package/dist/cjs/{DropDown-f6224ac8.js → DropDown-5513ea77.js} +80 -95
- package/dist/cjs/DynamicRangeSlider.js +107 -43
- package/dist/cjs/Flex-aa517a13.js +52 -0
- package/dist/cjs/FormControlList-c195a592.js +47 -0
- package/dist/cjs/Input-e6603a7e.js +79 -0
- package/dist/cjs/ListItem-8c9e0d68.js +46 -0
- package/dist/cjs/MultiDropdownList.js +102 -68
- package/dist/cjs/MultiList.js +80 -50
- package/dist/cjs/MultiRange.js +21 -16
- package/dist/cjs/{Pagination-af399262.js → Pagination-fe5452fc.js} +14 -8
- package/dist/cjs/RangeInput.js +29 -45
- package/dist/cjs/RangeSlider.js +32 -30
- package/dist/cjs/ReactiveBase.js +87 -56
- package/dist/cjs/ReactiveComponent.js +75 -62
- package/dist/cjs/ReactiveGoogleMap.js +262 -191
- package/dist/cjs/ReactiveList.js +189 -241
- package/dist/cjs/ResultCard.js +8 -6
- package/dist/cjs/ResultList.js +8 -6
- package/dist/cjs/SelectedFilters.js +66 -34
- package/dist/cjs/SingleDropdownList.js +88 -60
- package/dist/cjs/SingleList.js +53 -35
- package/dist/cjs/SingleRange.js +19 -14
- package/dist/cjs/StateProvider.js +39 -10
- package/dist/cjs/{Title-65d39104.js → Title-1de7d0f4.js} +3 -11
- package/dist/cjs/ToggleButton.js +36 -16
- package/dist/cjs/{_rollupPluginBabelHelpers-4abdbfff.js → _rollupPluginBabelHelpers-c705cbe6.js} +2 -4
- package/dist/cjs/{index-baca18c4.js → index-6a167fe0.js} +99 -13
- package/dist/cjs/index.js +31 -25
- package/dist/cjs/initReactivesearch.js +178 -104
- package/dist/cjs/install-004c6aa4.js +1408 -0
- package/dist/cjs/install.js +42 -44
- package/dist/cjs/ssr-3027b848.js +39 -0
- package/dist/cjs/{utils-ea846a20.js → utils-d6a52588.js} +2 -2
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/{vueTypes-c21f265b.js → vueTypes-6de9d2a9.js} +9 -4
- package/dist/es/Button-d8bc15ea.js +59 -0
- package/dist/es/{DownShift-92347b5e.js → CancelSvg-4cfae5fd.js} +56 -17
- package/dist/es/Card-450683f1.js +23 -0
- package/dist/es/{ComponentWrapper-c4c91949.js → ComponentWrapper-424e86fd.js} +40 -21
- package/dist/es/Container-ba826e96.js +10 -0
- package/dist/es/DataSearch-e71a1014.js +2307 -0
- package/dist/es/DataSearch.js +17 -2150
- package/dist/es/{DropDown-3d4291f1.js → DropDown-7d9a15c1.js} +79 -94
- package/dist/es/DynamicRangeSlider.js +107 -43
- package/dist/es/Flex-1f0795c3.js +47 -0
- package/dist/es/FormControlList-c22d64f6.js +40 -0
- package/dist/es/Input-7a2a9fac.js +71 -0
- package/dist/es/ListItem-cad14c5e.js +39 -0
- package/dist/es/MultiDropdownList.js +102 -68
- package/dist/es/MultiList.js +80 -50
- package/dist/es/MultiRange.js +21 -16
- package/dist/es/{Pagination-c2a00175.js → Pagination-3f350098.js} +14 -8
- package/dist/es/RangeInput.js +29 -45
- package/dist/es/RangeSlider.js +32 -30
- package/dist/es/ReactiveBase.js +87 -56
- package/dist/es/ReactiveComponent.js +75 -62
- package/dist/es/ReactiveGoogleMap.js +262 -191
- package/dist/es/ReactiveList.js +189 -241
- package/dist/es/ResultCard.js +8 -6
- package/dist/es/ResultList.js +8 -6
- package/dist/es/SelectedFilters.js +66 -34
- package/dist/es/SingleDropdownList.js +88 -60
- package/dist/es/SingleList.js +53 -35
- package/dist/es/SingleRange.js +19 -14
- package/dist/es/StateProvider.js +39 -10
- package/dist/es/Title-3342664a.js +10 -0
- package/dist/es/ToggleButton.js +36 -16
- package/dist/es/{_rollupPluginBabelHelpers-ecf6c03c.js → _rollupPluginBabelHelpers-76660dab.js} +2 -4
- package/dist/es/{index-185b6266.js → index-7788a843.js} +95 -14
- package/dist/es/index.js +27 -22
- package/dist/es/initReactivesearch.js +179 -105
- package/dist/es/install-b7b604cc.js +1401 -0
- package/dist/es/install.js +40 -46
- package/dist/es/ssr-b2c0b401.js +33 -0
- package/dist/es/{utils-57cc8789.js → utils-9e68acee.js} +2 -2
- package/dist/es/version.js +1 -1
- package/dist/es/{vueTypes-98d938a9.js → vueTypes-9326e0be.js} +9 -4
- package/package.json +6 -4
- package/dist/cjs/Button-d48d4365.js +0 -146
- package/dist/cjs/Card-9748fbb2.js +0 -58
- package/dist/cjs/Flex-befd65fc.js +0 -160
- package/dist/cjs/FormControlList-f3857d4b.js +0 -105
- package/dist/cjs/Input-95cb19f8.js +0 -178
- package/dist/cjs/ListItem-84d185cf.js +0 -84
- package/dist/cjs/ssr-3ca8a14f.js +0 -47
- package/dist/es/Button-27cc8574.js +0 -137
- package/dist/es/Card-1f93780d.js +0 -51
- package/dist/es/Container-88c805ef.js +0 -18
- package/dist/es/Flex-16d1103a.js +0 -155
- package/dist/es/FormControlList-96d44e7b.js +0 -98
- package/dist/es/Input-1159c4b5.js +0 -170
- package/dist/es/ListItem-d22510c9.js +0 -77
- package/dist/es/Title-f0217338.js +0 -18
- package/dist/es/ssr-a710392b.js +0 -41
|
@@ -1,35 +1,46 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
4
|
-
import {
|
|
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
|
|
14
|
-
|
|
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 (
|
|
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
|
|
27
|
+
return {
|
|
28
|
+
value: parsedValue,
|
|
29
|
+
reference: 'URL'
|
|
30
|
+
};
|
|
26
31
|
} catch (error) {
|
|
27
32
|
// using react-dom-server for ssr
|
|
28
|
-
return
|
|
33
|
+
return {
|
|
34
|
+
value: state[id],
|
|
35
|
+
reference: 'URL'
|
|
36
|
+
};
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
|
|
32
|
-
return
|
|
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
|
|
78
|
+
return _extends({
|
|
79
|
+
query: extractQueryFromCustomQuery(customQuery)
|
|
80
|
+
}, getOptionsForCustomQuery(customQuery));
|
|
55
81
|
}
|
|
56
82
|
|
|
57
|
-
return component.source.defaultQuery ?
|
|
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:
|
|
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;
|
|
139
|
+
var isInternalComponentPresent = false;
|
|
103
140
|
|
|
104
|
-
if (component.
|
|
105
|
-
|
|
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
|
-
|
|
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
|
-
}); //
|
|
168
|
+
}); // Set custom and default queries
|
|
131
169
|
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
170
|
+
if (component.customQuery && typeof component.customQuery === 'function') {
|
|
171
|
+
customQueries[component.componentId] = component.customQuery(value, compProps);
|
|
172
|
+
}
|
|
135
173
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
174
|
+
if (component.defaultQuery && typeof component.defaultQuery === 'function') {
|
|
175
|
+
defaultQueries[component.componentId] = component.defaultQuery(value, compProps);
|
|
176
|
+
}
|
|
139
177
|
|
|
140
|
-
|
|
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
|
-
|
|
163
|
-
if (!otherQueryOptions) otherQueryOptions = {};
|
|
164
|
-
if (!highlightQuery) highlightQuery = {};
|
|
184
|
+
var highlightQuery = {};
|
|
165
185
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
186
|
+
if (component.source.highlightQuery) {
|
|
187
|
+
highlightQuery = component.source.highlightQuery(component);
|
|
188
|
+
}
|
|
169
189
|
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
206
|
+
if (otherQueryOptions && Object.keys(otherQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
|
|
207
|
+
if (!otherQueryOptions) otherQueryOptions = {};
|
|
208
|
+
if (!highlightQuery) highlightQuery = {};
|
|
180
209
|
|
|
181
|
-
|
|
182
|
-
|
|
210
|
+
var mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery, {
|
|
211
|
+
size: size
|
|
212
|
+
});
|
|
183
213
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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 (
|
|
217
|
-
var
|
|
218
|
-
|
|
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:
|
|
264
|
+
query: defaultQuery
|
|
224
265
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
}
|
|
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
|
|
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 ||
|
|
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(
|
|
327
|
+
var currentQuery = _extends({
|
|
271
328
|
query: _extends({}, queryObj)
|
|
272
|
-
},
|
|
329
|
+
}, componentQueryOptions, queryOptions[component.componentId]);
|
|
273
330
|
|
|
274
|
-
queryLog = _extends(
|
|
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(
|
|
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:
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
435
|
+
aggregations = _extends({}, aggregations, (_extends6 = {}, _extends6[component] = response.aggregations, _extends6));
|
|
366
436
|
}
|
|
367
437
|
|
|
368
|
-
|
|
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(
|
|
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
|
});
|