@izara_project/izara-shared-search-and-sort 1.0.2 → 1.0.4

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.
@@ -19,14 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  //* searchResultMain record
21
21
  import { objectHash as hash } from '@izara_project/izara-shared-core'; //const hash = require('@izara_project/izara-shared-core').objectHash;
22
- import { isEmpty as isEmpty } from 'lodash';
23
- import filtersSharedLib from './FiltersSharedLib'; //const filtersSharedLib = require('./FiltersSharedLib');
24
- import dataFieldsSharedLib from './DataFieldsSharedLib';
22
+ import lodash from 'lodash';
23
+ const { isEmpty } = lodash;
24
+ import filtersSharedLib from './FiltersSharedLib.js'; //const filtersSharedLib = require('./FiltersSharedLib');
25
+ import dataFieldsSharedLib from './DataFieldsSharedLib.js';
25
26
  import searchResultShared from '@izara_project/izara-core-library-search-result';
26
27
 
27
28
 
28
29
  function createSearchRequest(
29
- _izContext,
30
30
  objType,
31
31
  initialLogicalElementId,
32
32
  logicalElements,
@@ -37,7 +37,7 @@ function createSearchRequest(
37
37
  requiredDataLinkSteps,
38
38
  values
39
39
  ) {
40
- _izContext.logger.debug('createSearchResult: ', {
40
+ console.log('createSearchResult: ', {
41
41
  objType,
42
42
  initialLogicalElementId,
43
43
  logicalElements,
@@ -61,14 +61,13 @@ function createSearchRequest(
61
61
  complexErrorsObject,
62
62
  complexErrorsFound
63
63
  ] = filtersSharedLib.createFiltersRequest(
64
- _izContext,
65
64
  objType,
66
65
  initialLogicalElementId,
67
66
  logicalElements,
68
67
  values,
69
68
  []
70
69
  );
71
- _izContext.logger.debug('return createComplexFilter: ', {
70
+ console.log('return createComplexFilter: ', {
72
71
  complexFilterRequest,
73
72
  complexFilterStatus,
74
73
  complexErrorsObject,
@@ -81,7 +80,6 @@ function createSearchRequest(
81
80
  }
82
81
 
83
82
  let requiredData = dataFieldsSharedLib.createRequiredData(
84
- _izContext,
85
83
  objType,
86
84
  requiredDataFields,
87
85
  complexFilterCombinations,
@@ -90,7 +88,7 @@ function createSearchRequest(
90
88
  requiredDataLinkSteps,
91
89
  values,
92
90
  );
93
- _izContext.logger.debug('return create requiredData: ', requiredData);
91
+ console.log('return create requiredData: ', requiredData);
94
92
 
95
93
  if (requiredData.status === 'invalid' || requiredData.errorsFound.length > 0) {
96
94
  Object.assign(errorsObject, requiredData.errorsObject)
@@ -120,7 +118,7 @@ function createSearchRequest(
120
118
  Object.assign(filterElements, requiredData.filterElements);
121
119
  }
122
120
 
123
- _izContext.logger.debug("--------------------------- start create searchResult request -------------------------------", {
121
+ console.log("--------------------------- start create searchResult request -------------------------------", {
124
122
  complexFilterRequest,
125
123
  requiredData,
126
124
  filterElements
@@ -138,14 +136,13 @@ function createSearchRequest(
138
136
  linkPathObjects: requiredData.linkPathObjects,
139
137
  linkPathSteps: requiredData.linkPathSteps
140
138
  };
141
- _izContext.logger.debug("searchResultRequest: ", searchResultRequest);
139
+ console.log("searchResultRequest: ", searchResultRequest);
142
140
 
143
141
  return [searchResultRequest, status, errorsObject, errorsFound]
144
142
 
145
143
  }
146
144
 
147
145
  function createSortRequest(
148
- _izContext,
149
146
  objType,
150
147
  initialLogicalElementId,
151
148
  logicalElements,
@@ -157,7 +154,7 @@ function createSortRequest(
157
154
  sortFields,
158
155
  values
159
156
  ) {
160
- _izContext.logger.debug('createSortResult: ', {
157
+ console.log('createSortResult: ', {
161
158
  objType,
162
159
  initialLogicalElementId,
163
160
  logicalElements,
@@ -182,16 +179,16 @@ function createSortRequest(
182
179
  let requiredDataLinkStepObjectId = sortField.requiredDataLinkStepObjectId;
183
180
 
184
181
  let requiredDataLinkObject = requiredDataLinkStepObjects[requiredDataLinkStepObjectId];
185
- _izContext.logger.debug('requiredDataLinkObject', requiredDataLinkObject);
182
+ console.log('requiredDataLinkObject', requiredDataLinkObject);
186
183
 
187
184
  let requiredDataLinkStepsSortField = requiredDataLinkObject.linkSteps;
188
- _izContext.logger.debug('requiredDataLinkStepsSortField', requiredDataLinkStepsSortField);
185
+ console.log('requiredDataLinkStepsSortField', requiredDataLinkStepsSortField);
189
186
 
190
187
  let lastRequiredDataLinkStepId = requiredDataLinkStepsSortField[requiredDataLinkStepsSortField.length - 1];
191
- _izContext.logger.debug('lastRequiredDataLinkStepId', lastRequiredDataLinkStepId);
188
+ console.log('lastRequiredDataLinkStepId', lastRequiredDataLinkStepId);
192
189
 
193
190
  let linkStep = requiredDataLinkSteps[lastRequiredDataLinkStepId];
194
- _izContext.logger.debug('linkStep', linkStep);
191
+ console.log('linkStep', linkStep);
195
192
 
196
193
  sortFieldMain.push({
197
194
  fieldName: linkStep.fieldName,
@@ -199,10 +196,9 @@ function createSortRequest(
199
196
  });
200
197
 
201
198
  }
202
- _izContext.logger.debug("sortFieldMain: ", sortFieldMain)
199
+ console.log("sortFieldMain: ", sortFieldMain)
203
200
 
204
201
  let [searchResultRequest, status, errorsObject, errorsFound] = createSearchRequest(
205
- _izContext,
206
202
  objType,
207
203
  initialLogicalElementId,
208
204
  logicalElements,
@@ -213,7 +209,7 @@ function createSortRequest(
213
209
  requiredDataLinkSteps,
214
210
  values
215
211
  );
216
- _izContext.logger.debug('SearchResultRequest: ', {
212
+ console.log('SearchResultRequest: ', {
217
213
  searchResultRequest,
218
214
  status,
219
215
  errorsObject,
@@ -226,18 +222,19 @@ function createSortRequest(
226
222
 
227
223
  let searchResultId = searchResultRequest.searchResultId;
228
224
  let searchDetailId = searchResultRequest.searchDetailId;
229
- _izContext.logger.debug('searchResultMain: ', {
225
+ console.log('searchResultMain: ', {
230
226
  searchResultId,
231
227
  searchDetailId
232
228
  });
233
229
 
234
- let sortResultId = searchResultShared.createSortResultId(
235
- _izContext,
236
- searchResultId,
237
- searchDetailId,
238
- sortFieldMain
239
- );
240
- _izContext.logger.debug('sortResultId: ', sortResultId)
230
+ let sortFieldsHash = hash(sortFieldMain);
231
+ let sortResultId = searchResultId + '__' + searchDetailId + '__' + sortFieldsHash;
232
+ // let sortResultId = searchResultShared.createSortResultId(
233
+ // searchResultId,
234
+ // searchDetailId,
235
+ // sortFieldMain
236
+ // );
237
+ console.log('sortResultId: ', sortResultId)
241
238
 
242
239
  let sortRequest = {
243
240
  objType: objType,
@@ -250,9 +247,9 @@ function createSortRequest(
250
247
  linkPathSteps: searchResultRequest.linkPathSteps,
251
248
  sortFields: sortFieldMain
252
249
  };
253
- _izContext.logger.debug('sortRequest: ', sortRequest);
250
+ console.log('sortRequest: ', sortRequest);
254
251
 
255
- return [sortRequest, status, errorsObject, errorsFound]
252
+ return [sortResultId, sortRequest, status, errorsObject, errorsFound]
256
253
 
257
254
  }
258
255