@izara_project/izara-shared-search-and-sort 1.0.7 → 1.0.9
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/index.js +3 -1
- package/package.json +2 -7
- package/src/DataFieldsSharedLib.js +228 -47
- package/src/FiltersSharedLib.js +12 -25
- package/src/InitialSchemaLib.js +27 -0
- package/src/LogicalStructureSharedLib.js +29 -44
- package/src/SearchSortSharedLib.js +12 -20
package/index.js
CHANGED
|
@@ -20,10 +20,12 @@ import SearchSortSharedLib from './src/SearchSortSharedLib.js';
|
|
|
20
20
|
import FiltersSharedLib from './src/FiltersSharedLib.js'
|
|
21
21
|
import DataFieldsSharedLib from './src/DataFieldsSharedLib.js'
|
|
22
22
|
import LogicalStructureSharedLib from './src/LogicalStructureSharedLib.js';
|
|
23
|
+
import InitialSchemaLib from './src/InitialSchemaLib.js';
|
|
23
24
|
|
|
24
25
|
export {
|
|
25
26
|
SearchSortSharedLib,
|
|
26
27
|
FiltersSharedLib,
|
|
27
28
|
DataFieldsSharedLib,
|
|
28
|
-
LogicalStructureSharedLib
|
|
29
|
+
LogicalStructureSharedLib,
|
|
30
|
+
InitialSchemaLib
|
|
29
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-shared-search-and-sort",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Shared Libraries frontend/backend for Search and Sort stack",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,12 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"type": "module",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@izara_project/izara-core-library-
|
|
25
|
-
"@izara_project/izara-core-library-core": "^1.0.13",
|
|
26
|
-
"@izara_project/izara-core-library-external-request": "^1.0.13",
|
|
27
|
-
"@izara_project/izara-core-library-search-result": "^1.0.6",
|
|
28
|
-
"@izara_project/izara-core-library-service-schemas": "^1.0.105",
|
|
29
|
-
"@izara_project/izara-shared": "^1.0.109",
|
|
24
|
+
"@izara_project/izara-core-library-core": "^1.0.31",
|
|
30
25
|
"@izara_project/izara-shared-service-schemas": "^1.0.35",
|
|
31
26
|
"object-hash": "^3.0.0"
|
|
32
27
|
}
|
|
@@ -22,29 +22,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
22
22
|
// let { pattern } = validatorSchema.stringNotEmpty();
|
|
23
23
|
// export default [...]
|
|
24
24
|
|
|
25
|
-
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
25
|
+
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
26
26
|
import lodash from 'lodash';
|
|
27
27
|
const { isEmpty } = lodash;
|
|
28
|
-
import filtersSharedLib from './FiltersSharedLib.js';
|
|
28
|
+
import filtersSharedLib from './FiltersSharedLib.js';
|
|
29
|
+
import LogicalStructureSharedLib from './LogicalStructureSharedLib'
|
|
29
30
|
|
|
30
31
|
async function createRequiredData(
|
|
31
32
|
objType,
|
|
33
|
+
initialLogicalElementId,
|
|
34
|
+
logicalElements,
|
|
32
35
|
requiredDataFields,
|
|
33
36
|
complexFilterCombinations,
|
|
34
37
|
perParentCombinations,
|
|
35
38
|
requiredDataLinkStepObjects,
|
|
36
39
|
requiredDataLinkSteps,
|
|
37
40
|
values,
|
|
38
|
-
// getSchemaFn
|
|
39
41
|
) {
|
|
40
42
|
console.log('createRequiredData: ', {
|
|
41
43
|
objType,
|
|
44
|
+
initialLogicalElementId,
|
|
45
|
+
logicalElements,
|
|
42
46
|
requiredDataFields,
|
|
43
47
|
complexFilterCombinations,
|
|
44
48
|
perParentCombinations,
|
|
45
49
|
requiredDataLinkStepObjects,
|
|
50
|
+
requiredDataLinkSteps,
|
|
46
51
|
values,
|
|
47
|
-
// getSchemaFn
|
|
48
52
|
});
|
|
49
53
|
|
|
50
54
|
let errorsObject = {};
|
|
@@ -75,7 +79,6 @@ async function createRequiredData(
|
|
|
75
79
|
perParentCombinations,
|
|
76
80
|
complexFilterCombinations,
|
|
77
81
|
values,
|
|
78
|
-
// getSchemaFn,
|
|
79
82
|
errorsObject,
|
|
80
83
|
errorsFound
|
|
81
84
|
);
|
|
@@ -86,12 +89,9 @@ async function createRequiredData(
|
|
|
86
89
|
linkPathErrorsFound
|
|
87
90
|
});
|
|
88
91
|
|
|
89
|
-
if (linkPathErrorsFound.length > 0) {
|
|
92
|
+
if (linkPathErrorsFound.length > 0 || fieldName === null) {
|
|
90
93
|
Object.assign(errorsObject, linkPathErrorObject);
|
|
91
94
|
errorsFound = errorsFound.concat(linkPathErrorsFound);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
if (fieldName === null) {
|
|
95
95
|
return {
|
|
96
96
|
requiredDataHash: null,
|
|
97
97
|
requiredDataObject: requiredDataObject,
|
|
@@ -117,6 +117,8 @@ async function createRequiredData(
|
|
|
117
117
|
Object.assign(linkPathObjects, returnValue.sortFieldLinkPathObjects.linkPathObjects);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
console.log('returnValue.linkStepObjects: ', returnValue.linkStepObjects);
|
|
121
|
+
|
|
120
122
|
let pathObject = {
|
|
121
123
|
initialObjType: objType,
|
|
122
124
|
linkSteps: returnValue.linkSteps
|
|
@@ -131,16 +133,17 @@ async function createRequiredData(
|
|
|
131
133
|
linkPathObjectId: pathId
|
|
132
134
|
};
|
|
133
135
|
|
|
134
|
-
Object.assign(linkPathObjects, { [pathId]: pathObject });
|
|
135
|
-
|
|
136
136
|
let requiredFieldNameObject = {
|
|
137
|
-
fieldName: fieldName,
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
// fieldName: fieldName,
|
|
138
|
+
fieldName: setObject,
|
|
139
|
+
linkPathObjects: {
|
|
140
|
+
[pathId]: pathObject
|
|
141
|
+
},
|
|
142
|
+
linkPathSteps: returnValue.linkStepObjects
|
|
140
143
|
};
|
|
141
144
|
|
|
142
145
|
if (returnValue.hasOwnProperty('complexFilterCombinations')) {
|
|
143
|
-
requiredFieldNameObject.complexFilterCombinations = returnValue.complexFilterCombinations;
|
|
146
|
+
// requiredFieldNameObject.complexFilterCombinations = returnValue.complexFilterCombinations;
|
|
144
147
|
Object.assign(setComplexFilterCombinations, returnValue.complexFilterCombinations);
|
|
145
148
|
|
|
146
149
|
setObject.complexFilterCombinationIds = []
|
|
@@ -152,12 +155,12 @@ async function createRequiredData(
|
|
|
152
155
|
};
|
|
153
156
|
|
|
154
157
|
if (returnValue.hasOwnProperty('perParentCombinations')) {
|
|
155
|
-
requiredFieldNameObject.perParentCombinations = returnValue.perParentCombinations;
|
|
158
|
+
// requiredFieldNameObject.perParentCombinations = returnValue.perParentCombinations;
|
|
156
159
|
Object.assign(setPerParentCombinations, returnValue.perParentCombinations);
|
|
157
160
|
};
|
|
158
161
|
|
|
159
162
|
if (returnValue.hasOwnProperty('filterElements')) {
|
|
160
|
-
requiredFieldNameObject.filterElements = returnValue.filterElements;
|
|
163
|
+
// requiredFieldNameObject.filterElements = returnValue.filterElements;
|
|
161
164
|
Object.assign(setFilterElementsLink, returnValue.filterElements);
|
|
162
165
|
};
|
|
163
166
|
console.log('requiredFieldNameObject: ', requiredFieldNameObject);
|
|
@@ -174,6 +177,8 @@ async function createRequiredData(
|
|
|
174
177
|
requiredDataObject[requiredDataFieldNameId] = setObject;
|
|
175
178
|
};
|
|
176
179
|
|
|
180
|
+
Object.assign(linkPathObjects, { [pathId]: pathObject });
|
|
181
|
+
|
|
177
182
|
} else {
|
|
178
183
|
console.log("------- requiredData has only fieldName ---------");
|
|
179
184
|
|
|
@@ -269,7 +274,8 @@ async function createLinkPath(
|
|
|
269
274
|
perParentCombinations,
|
|
270
275
|
complexFilterCombinations,
|
|
271
276
|
values,
|
|
272
|
-
|
|
277
|
+
filtersStructure,
|
|
278
|
+
path,
|
|
273
279
|
errorsObject,
|
|
274
280
|
errorsFound,
|
|
275
281
|
index = 0,
|
|
@@ -283,6 +289,8 @@ async function createLinkPath(
|
|
|
283
289
|
perParentCombinations,
|
|
284
290
|
complexFilterCombinations,
|
|
285
291
|
values,
|
|
292
|
+
filtersStructure,
|
|
293
|
+
path,
|
|
286
294
|
errorsObject,
|
|
287
295
|
errorsFound,
|
|
288
296
|
index,
|
|
@@ -291,17 +299,8 @@ async function createLinkPath(
|
|
|
291
299
|
});
|
|
292
300
|
let fieldName = null;
|
|
293
301
|
let returnValue = {}; //* must return only linkPath params
|
|
294
|
-
// let linkPathSteps = [];
|
|
295
|
-
// let linkPathStepObjects = {};
|
|
296
|
-
// let filterElementsLink = {};
|
|
297
|
-
// let perParentCombination = {};
|
|
298
302
|
|
|
299
|
-
|
|
300
|
-
// let errorsFound = [];
|
|
301
|
-
|
|
302
|
-
// let childLinkStep = null
|
|
303
|
-
// let childLinkErrorObject = {};
|
|
304
|
-
// let childLinkErrors = []
|
|
303
|
+
let sortObj = null;
|
|
305
304
|
|
|
306
305
|
let linkStepId = linkSteps[index];
|
|
307
306
|
console.log('linkStepId: ', linkStepId);
|
|
@@ -313,12 +312,32 @@ async function createLinkPath(
|
|
|
313
312
|
// last link that has only fieldName
|
|
314
313
|
console.log('---------- is final link ----------', { index, linkStep });
|
|
315
314
|
|
|
316
|
-
|
|
315
|
+
let sortValueObj = null;
|
|
316
|
+
|
|
317
|
+
if (linkStep.hasOwnProperty("dataType")) {
|
|
318
|
+
|
|
319
|
+
sortValueObj = {
|
|
320
|
+
dataType: linkStep.dataType,
|
|
321
|
+
value: linkStep.value
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return [linkStep.fieldName, returnValue, errorsObject, errorsFound, sortValueObj]
|
|
317
327
|
|
|
318
328
|
} else {
|
|
319
329
|
// has nextLink
|
|
320
330
|
console.log('---------- is next link ----------', { index, linkStep });
|
|
321
331
|
|
|
332
|
+
if (linkStep.hasOwnProperty("pathLinkType")) {
|
|
333
|
+
path.push({
|
|
334
|
+
objType: objType,
|
|
335
|
+
pathLinkType: linkStep.pathLinkType
|
|
336
|
+
});
|
|
337
|
+
console.log("path", path);
|
|
338
|
+
// console.log('---------- is next link ----------', hhhh);
|
|
339
|
+
}
|
|
340
|
+
|
|
322
341
|
let conditionsPromise = checkConditionsLink(
|
|
323
342
|
// let [conditions, conditionErrObject, conditionErrFound] = await this.checkConditionsLink(
|
|
324
343
|
linkStep.pathLinkType.objType,
|
|
@@ -329,19 +348,20 @@ async function createLinkPath(
|
|
|
329
348
|
linkSteps,
|
|
330
349
|
requiredDataLinkStepObjects,
|
|
331
350
|
requiredDataLinkSteps,
|
|
332
|
-
|
|
351
|
+
path,
|
|
333
352
|
errorsObject,
|
|
334
353
|
errorsFound
|
|
335
354
|
);
|
|
336
355
|
|
|
337
|
-
[fieldName, returnValue, errorsObject, errorsFound] = await createLinkPath(
|
|
356
|
+
[fieldName, returnValue, errorsObject, errorsFound, sortObj] = await createLinkPath(
|
|
338
357
|
linkSteps,
|
|
339
358
|
requiredDataLinkStepObjects,
|
|
340
359
|
requiredDataLinkSteps,
|
|
341
360
|
perParentCombinations,
|
|
342
361
|
complexFilterCombinations,
|
|
343
362
|
values,
|
|
344
|
-
|
|
363
|
+
filtersStructure,
|
|
364
|
+
path,
|
|
345
365
|
errorsObject,
|
|
346
366
|
errorsFound,
|
|
347
367
|
index + 1
|
|
@@ -354,6 +374,10 @@ async function createLinkPath(
|
|
|
354
374
|
index
|
|
355
375
|
});
|
|
356
376
|
|
|
377
|
+
if (errorsFound.length > 0) {
|
|
378
|
+
return [null, null, errorsObject, errorsFound]
|
|
379
|
+
}
|
|
380
|
+
|
|
357
381
|
console.log('linkStep', linkStep);
|
|
358
382
|
|
|
359
383
|
let [conditions, conditionErrObject, conditionErrFound] = await conditionsPromise;
|
|
@@ -361,6 +385,8 @@ async function createLinkPath(
|
|
|
361
385
|
if (conditionErrFound.length > 0) {
|
|
362
386
|
Object.assign(errorsObject, conditionErrObject);
|
|
363
387
|
errorsFound = errorsFound.concat(conditionErrFound);
|
|
388
|
+
|
|
389
|
+
return [null, null, errorsObject, errorsFound]
|
|
364
390
|
};
|
|
365
391
|
|
|
366
392
|
if (!isEmpty(returnValue)) {
|
|
@@ -411,15 +437,37 @@ async function createLinkPath(
|
|
|
411
437
|
if (conditions.hasOwnProperty("setFilterCombinations") && !isEmpty(conditions.setFilterCombinations)) {
|
|
412
438
|
|
|
413
439
|
if (conditions.setFilterCombinations.hasOwnProperty('filterElements')) {
|
|
414
|
-
|
|
440
|
+
|
|
441
|
+
if (returnValue.hasOwnProperty("filterElements")) {
|
|
442
|
+
Object.assign(returnValue["filterElements"], conditions.setFilterCombinations.filterElements.filterElements);
|
|
443
|
+
} else {
|
|
444
|
+
returnValue.filterElements = {};
|
|
445
|
+
Object.assign(returnValue["filterElements"], conditions.setFilterCombinations.filterElements.filterElements);
|
|
446
|
+
}
|
|
447
|
+
|
|
415
448
|
}
|
|
416
449
|
|
|
417
450
|
if (conditions.setFilterCombinations.hasOwnProperty('perParentCombinations')) {
|
|
418
|
-
|
|
451
|
+
|
|
452
|
+
if (returnValue.hasOwnProperty("perParentCombinations")) {
|
|
453
|
+
Object.assign(returnValue["perParentCombinations"], conditions.setFilterCombinations.perParentCombinations);
|
|
454
|
+
} else {
|
|
455
|
+
returnValue.perParentCombinations = {};
|
|
456
|
+
Object.assign(returnValue["perParentCombinations"], conditions.setFilterCombinations.perParentCombinations);
|
|
457
|
+
}
|
|
458
|
+
|
|
419
459
|
};
|
|
420
460
|
|
|
421
461
|
if (conditions.setFilterCombinations.hasOwnProperty('complexFilterCombinations')) {
|
|
422
|
-
|
|
462
|
+
|
|
463
|
+
if (returnValue.hasOwnProperty("complexFilterCombinations")) {
|
|
464
|
+
Object.assign(returnValue['complexFilterCombinations'], conditions.setFilterCombinations.complexFilterCombinations);
|
|
465
|
+
} else {
|
|
466
|
+
returnValue.complexFilterCombinations = {};
|
|
467
|
+
Object.assign(returnValue["complexFilterCombinations"], conditions.setFilterCombinations.complexFilterCombinations);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
|
|
423
471
|
};
|
|
424
472
|
}
|
|
425
473
|
|
|
@@ -429,6 +477,7 @@ async function createLinkPath(
|
|
|
429
477
|
//* error
|
|
430
478
|
errorsObject[linkStepId] = `has linkPathObject but no data`;
|
|
431
479
|
errorsFound.push(`${linkStepId} no data in linkPathObject`)
|
|
480
|
+
return [null, null, errorsObject, errorsFound]
|
|
432
481
|
}
|
|
433
482
|
}
|
|
434
483
|
|
|
@@ -536,7 +585,8 @@ async function createLinkPath(
|
|
|
536
585
|
} else {
|
|
537
586
|
//* error
|
|
538
587
|
errorsObject[linkStepId] = `has linkPathObject but no data`;
|
|
539
|
-
errorsFound.push(`${linkStepId} no data in linkPathObject`)
|
|
588
|
+
errorsFound.push(`${linkStepId} no data in linkPathObject`);
|
|
589
|
+
return [null, null, errorsObject, errorsFound]
|
|
540
590
|
}
|
|
541
591
|
}
|
|
542
592
|
|
|
@@ -558,6 +608,16 @@ async function createLinkPath(
|
|
|
558
608
|
};
|
|
559
609
|
};
|
|
560
610
|
|
|
611
|
+
if (conditions.hasOwnProperty("comparison")) {
|
|
612
|
+
if (conditions.hasOwnProperty("comparisonSortField")) {
|
|
613
|
+
if (conditions.hasOwnProperty("comparisonValue")) {
|
|
614
|
+
linkStepObject.comparison = conditions.comparison;
|
|
615
|
+
linkStepObject.comparisonSortField = conditions.comparisonSortField;
|
|
616
|
+
linkStepObject.comparisonValue = conditions.comparisonValue;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
561
621
|
console.log('linkStepObject', linkStepObject);
|
|
562
622
|
let linkStepId = hash(linkStepObject);
|
|
563
623
|
console.log('linkStepId', linkStepId);
|
|
@@ -579,10 +639,11 @@ async function checkConditionsLink(
|
|
|
579
639
|
perParentCombinations,
|
|
580
640
|
complexFilterCombinations,
|
|
581
641
|
values,
|
|
642
|
+
filtersStructure,
|
|
582
643
|
linkSteps,
|
|
583
644
|
requiredDataLinkStepObjects,
|
|
584
645
|
requiredDataLinkSteps,
|
|
585
|
-
|
|
646
|
+
path,
|
|
586
647
|
errorsObject,
|
|
587
648
|
errorsFound
|
|
588
649
|
) {
|
|
@@ -592,24 +653,76 @@ async function checkConditionsLink(
|
|
|
592
653
|
perParentCombinations,
|
|
593
654
|
complexFilterCombinations,
|
|
594
655
|
values,
|
|
656
|
+
filtersStructure,
|
|
595
657
|
linkSteps,
|
|
596
658
|
requiredDataLinkStepObjects,
|
|
597
659
|
requiredDataLinkSteps,
|
|
598
|
-
|
|
660
|
+
path,
|
|
599
661
|
errorsObject,
|
|
600
662
|
errorsFound
|
|
601
663
|
});
|
|
602
664
|
|
|
603
665
|
|
|
604
|
-
let conditionLinkObject = {}
|
|
666
|
+
let conditionLinkObject = {};
|
|
667
|
+
let filterMainRequest = null
|
|
668
|
+
|
|
669
|
+
if (linkStepObject.hasOwnProperty("addFilterMain") && linkStepObject.addFilterMain === true) {
|
|
670
|
+
|
|
671
|
+
path.push({ objType: objType });
|
|
672
|
+
console.log('path', path);
|
|
673
|
+
|
|
674
|
+
let [filterStructureCurrent, filterErrorObject, filterErrorFound] = await LogicalStructureSharedLib.changeObjTypePath(
|
|
675
|
+
objType,
|
|
676
|
+
filtersStructure,
|
|
677
|
+
path
|
|
678
|
+
);
|
|
679
|
+
|
|
680
|
+
console.log('changeObjTypePath', {
|
|
681
|
+
filterStructureCurrent,
|
|
682
|
+
filterErrorObject,
|
|
683
|
+
filterErrorFound
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
if (filterErrorFound.length > 0) {
|
|
687
|
+
Object.assign(errorsObject, filterErrorObject);
|
|
688
|
+
errorsFound = errorsFound.concat('filterErrorFound');
|
|
689
|
+
} else {
|
|
690
|
+
filterMainRequest = filterStructureCurrent;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
}
|
|
605
694
|
|
|
606
695
|
if (linkStepObject.hasOwnProperty('filterElements')) {
|
|
607
696
|
console.log('------------ has filterElements ------------');
|
|
608
697
|
|
|
698
|
+
let filters = {};
|
|
699
|
+
|
|
700
|
+
if (filterMainRequest !== null) {
|
|
701
|
+
if (hash(filterMainRequest.objType) !== hash(linkStepObject.filterElements.objType)) {
|
|
702
|
+
errorsObject[linkStepObject.filterElements.objType.objectType] = 'this linkStep has error when combine filterMain in link';
|
|
703
|
+
errorsFound.push(`${linkStepObject.filterElements.objType.objectType}: this linkStep has error when combine filterMain in link`);
|
|
704
|
+
return [null, errorsObject, errorsFound];
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
filters = filtersSharedLib.combineLogicalElements(
|
|
708
|
+
filterMainRequest,
|
|
709
|
+
linkStepObject.filterElements
|
|
710
|
+
);
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
} else {
|
|
714
|
+
filters = {
|
|
715
|
+
objType: linkStepObject.filterElements.objType,
|
|
716
|
+
initialLogicalElementId: linkStepObject.filterElements.initialLogicalElementId,
|
|
717
|
+
logicalElements: linkStepObject.filterElements.logicalElements,
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
console.log('filters: ', filters);
|
|
721
|
+
|
|
609
722
|
let [complexFilterRequest, status, filterErrorsObject, filterErrorsFound] = filtersSharedLib.createFiltersRequest(
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
723
|
+
filters.objType,
|
|
724
|
+
filters.initialLogicalElementId,
|
|
725
|
+
filters.logicalElements,
|
|
613
726
|
values
|
|
614
727
|
);
|
|
615
728
|
console.log('return complexFilter for filterElements: ', {
|
|
@@ -623,14 +736,44 @@ async function checkConditionsLink(
|
|
|
623
736
|
Object.assign(errorsObject, filterErrorsObject)
|
|
624
737
|
errorsFound = errorsFound.concat(filterErrorsFound)
|
|
625
738
|
};
|
|
739
|
+
|
|
626
740
|
conditionLinkObject.filterElements = complexFilterRequest.filterElements;
|
|
627
741
|
console.log('conditionLinkObject in condition link: ', conditionLinkObject);
|
|
742
|
+
|
|
628
743
|
}
|
|
629
744
|
|
|
745
|
+
|
|
746
|
+
// if (linkStepObject.hasOwnProperty('filterElements')) {
|
|
747
|
+
// console.log('------------ has filterElements ------------');
|
|
748
|
+
|
|
749
|
+
// let [complexFilterRequest, status, filterErrorsObject, filterErrorsFound] = filtersSharedLib.createFiltersRequest(
|
|
750
|
+
// linkStepObject.filterElements.objType,
|
|
751
|
+
// linkStepObject.filterElements.initialLogicalElementId,
|
|
752
|
+
// linkStepObject.filterElements.logicalElements,
|
|
753
|
+
// values
|
|
754
|
+
// );
|
|
755
|
+
// console.log('return complexFilter for filterElements: ', {
|
|
756
|
+
// complexFilterRequest,
|
|
757
|
+
// status,
|
|
758
|
+
// filterErrorsObject,
|
|
759
|
+
// filterErrorsFound
|
|
760
|
+
// });
|
|
761
|
+
|
|
762
|
+
// if (filterErrorsFound.length > 0) {
|
|
763
|
+
// Object.assign(errorsObject, filterErrorsObject)
|
|
764
|
+
// errorsFound = errorsFound.concat(filterErrorsFound);
|
|
765
|
+
// return [null, errorsObject, errorsFound]
|
|
766
|
+
// };
|
|
767
|
+
// conditionLinkObject.filterElements = complexFilterRequest.filterElements;
|
|
768
|
+
// console.log('conditionLinkObject in condition link: ', conditionLinkObject);
|
|
769
|
+
// }
|
|
770
|
+
|
|
630
771
|
if (linkStepObject.hasOwnProperty('aggregate')) {
|
|
631
772
|
console.log('------------ has aggregate ------------');
|
|
632
773
|
if (!linkStepObject.hasOwnProperty('sortFields')) {
|
|
774
|
+
errorsObject[objType.objectType] = 'if has aggregate need to has sortFields, too';
|
|
633
775
|
errorsFound.push('if has aggregate need to has sortFields, too');
|
|
776
|
+
return [null, errorsObject, errorsFound]
|
|
634
777
|
};
|
|
635
778
|
conditionLinkObject.aggregate = linkStepObject.aggregate;
|
|
636
779
|
conditionLinkObject.sortFields = [];
|
|
@@ -668,7 +811,8 @@ async function checkConditionsLink(
|
|
|
668
811
|
perParentCombinations,
|
|
669
812
|
complexFilterCombinations,
|
|
670
813
|
values,
|
|
671
|
-
|
|
814
|
+
filtersStructure,
|
|
815
|
+
[],
|
|
672
816
|
errorsObject,
|
|
673
817
|
errorsFound
|
|
674
818
|
);
|
|
@@ -679,6 +823,12 @@ async function checkConditionsLink(
|
|
|
679
823
|
linkErrorsFound
|
|
680
824
|
});
|
|
681
825
|
|
|
826
|
+
if (linkErrorsFound > 0) {
|
|
827
|
+
Object.assign(errorsObject, linkErrorsObject);
|
|
828
|
+
errorsFound = errorsFound.concat(linkErrorsFound);
|
|
829
|
+
return [null, errorsObject, errorsFound]
|
|
830
|
+
}
|
|
831
|
+
|
|
682
832
|
if (!isEmpty(childLinkStep)) {
|
|
683
833
|
|
|
684
834
|
//* create linkPathObject from child
|
|
@@ -733,10 +883,19 @@ async function checkConditionsLink(
|
|
|
733
883
|
});
|
|
734
884
|
};
|
|
735
885
|
|
|
736
|
-
|
|
886
|
+
let sortObject = {
|
|
737
887
|
fieldName: fieldName,
|
|
738
|
-
dataType: sortField.dataType
|
|
739
|
-
}
|
|
888
|
+
// dataType: sortField.dataType
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
if (sortObj !== null) {
|
|
892
|
+
if (sortObj.dataType === "array") {
|
|
893
|
+
sortObject.dataType = sortObj.dataType
|
|
894
|
+
sortObject.values = sortObj.value;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
sortFieldObjects.push(sortObject);
|
|
740
899
|
console.log('sortFieldObjects: ', sortFieldObjects);
|
|
741
900
|
|
|
742
901
|
};
|
|
@@ -764,7 +923,9 @@ async function checkConditionsLink(
|
|
|
764
923
|
|
|
765
924
|
} else {
|
|
766
925
|
if (linkStepObject.hasOwnProperty('combine')) {
|
|
767
|
-
|
|
926
|
+
errorsObject[objType.objectType] = 'must set aggregate and sortFields';
|
|
927
|
+
errorsFound = errorsFound.concat('must set aggregate and sortFields')
|
|
928
|
+
return [null, errorsObject, errorsFound]
|
|
768
929
|
}
|
|
769
930
|
};
|
|
770
931
|
|
|
@@ -889,6 +1050,10 @@ async function checkConditionsLink(
|
|
|
889
1050
|
};
|
|
890
1051
|
};
|
|
891
1052
|
|
|
1053
|
+
if (errorsFound.length > 0) {
|
|
1054
|
+
return [null, errorsObject, errorsFound]
|
|
1055
|
+
}
|
|
1056
|
+
|
|
892
1057
|
console.log('perParentCombinations: ', {
|
|
893
1058
|
perParentCombinationIds,
|
|
894
1059
|
perParentCombinationObjects,
|
|
@@ -906,6 +1071,22 @@ async function checkConditionsLink(
|
|
|
906
1071
|
};
|
|
907
1072
|
console.log('conditionLinkObject: ', conditionLinkObject);
|
|
908
1073
|
}
|
|
1074
|
+
|
|
1075
|
+
if (linkStepObject.hasOwnProperty("comparison")) {
|
|
1076
|
+
console.log('------------ link has comparison ------------');
|
|
1077
|
+
|
|
1078
|
+
if (!linkStepObject.hasOwnProperty("comparisonSortField") || !linkStepObject.hasOwnProperty("comparisonValue")) {
|
|
1079
|
+
errorsObject[objType.objectType] = 'no comparisonSortField | comparisonValue';
|
|
1080
|
+
errorsFound.push(`${objType.objectType}: no comparisonSortField | comparisonValue`);
|
|
1081
|
+
return [null, errorsObject, errorsFound]
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
conditionLinkObject.comparison = linkStepObject.comparison;
|
|
1085
|
+
conditionLinkObject.comparisonSortField = linkStepObject.comparisonSortField;
|
|
1086
|
+
conditionLinkObject.comparisonValue = values[linkStepObject.comparisonValue].value;
|
|
1087
|
+
|
|
1088
|
+
}
|
|
1089
|
+
|
|
909
1090
|
console.log('conditionLinkObject', conditionLinkObject);
|
|
910
1091
|
return [conditionLinkObject, errorsObject, errorsFound];
|
|
911
1092
|
}
|
package/src/FiltersSharedLib.js
CHANGED
|
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
"use strict";
|
|
19
19
|
|
|
20
|
-
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
20
|
+
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
21
21
|
import lodash from 'lodash';
|
|
22
22
|
const { isEmpty } = lodash;
|
|
23
23
|
|
|
@@ -161,18 +161,6 @@ function createFiltersRequest(
|
|
|
161
161
|
};
|
|
162
162
|
console.log('complexFilterRequest: ', complexFilterRequest);
|
|
163
163
|
|
|
164
|
-
// let validate = validateFilterElement(
|
|
165
|
-
// complexFilterRequest.filterElements,
|
|
166
|
-
// logicalElements
|
|
167
|
-
// );
|
|
168
|
-
// _izContext.logger.debug('validate: ', validate);
|
|
169
|
-
|
|
170
|
-
// if (validate === false) {
|
|
171
|
-
// errorsObject[initialLogicalElementId] = 'filterElements has create fail';
|
|
172
|
-
// errorsFound.push("filterElements has create fail");
|
|
173
|
-
// return [null, "error", errorsObject, errorsFound]
|
|
174
|
-
// }
|
|
175
|
-
|
|
176
164
|
return [
|
|
177
165
|
complexFilterRequest,
|
|
178
166
|
status,
|
|
@@ -1004,7 +992,6 @@ function filterLogicalElements(
|
|
|
1004
992
|
|
|
1005
993
|
if (lastNextLogicalElementId !== null) {
|
|
1006
994
|
|
|
1007
|
-
// [runningFilterMainId, runningFilterObject, operation, operationErrorsFound] = complexFilterShared.validateOperation(
|
|
1008
995
|
[runningFilterMainId, runningFilterObject, operation, operationErrorsFound] = validateOperation(
|
|
1009
996
|
objType,
|
|
1010
997
|
runningFilterMainId,
|
|
@@ -1151,43 +1138,43 @@ function splitFilterElements(
|
|
|
1151
1138
|
// || runningFilterObject.filterElement.filterType === 'traversal'
|
|
1152
1139
|
// ) {}
|
|
1153
1140
|
|
|
1154
|
-
if (runningFilterObject.
|
|
1141
|
+
if (runningFilterObject.logicalElementType === 'operation') {
|
|
1155
1142
|
console.log('-------- operation ----------');
|
|
1156
1143
|
|
|
1157
1144
|
Object.assign(filterElements, runningFilterObject.filterElement.filterElements);
|
|
1158
|
-
delete runningFilterObject.filterElement.filterElements;
|
|
1145
|
+
// delete runningFilterObject.filterElement.filterElements;
|
|
1159
1146
|
filterElements[runningFilterMainId] = runningFilterObject;
|
|
1160
1147
|
|
|
1161
|
-
} else if (runningFilterObject.
|
|
1148
|
+
} else if (runningFilterObject.logicalElementType === 'childComplexFilter') {
|
|
1162
1149
|
console.log('-------- childComplexFilter ----------');
|
|
1163
1150
|
|
|
1164
1151
|
Object.assign(filterElements, runningFilterObject.filterElement.filterElements);
|
|
1165
|
-
delete runningFilterObject.filterElement.filterElements;
|
|
1152
|
+
// delete runningFilterObject.filterElement.filterElements;
|
|
1166
1153
|
filterElements[runningFilterMainId] = runningFilterObject;
|
|
1167
1154
|
|
|
1168
1155
|
} else {
|
|
1169
|
-
console.log(` -------- ${runningFilterObject.
|
|
1156
|
+
console.log(` -------- ${runningFilterObject.logicalElementType} ----------`);
|
|
1170
1157
|
//'logical'| 'identifiers'|'translateIds'|'traversal'
|
|
1171
1158
|
filterElements[runningFilterMainId] = runningFilterObject;
|
|
1172
1159
|
};
|
|
1173
1160
|
|
|
1174
1161
|
if (currentFilterObject !== null) {
|
|
1175
|
-
if (currentFilterObject.
|
|
1162
|
+
if (currentFilterObject.logicalElementType === 'operation') {
|
|
1176
1163
|
console.log('-------- operation ----------');
|
|
1177
1164
|
|
|
1178
1165
|
Object.assign(filterElements, currentFilterObject.filterElement.filterElements);
|
|
1179
|
-
delete currentFilterObject.filterElement.filterElements;
|
|
1166
|
+
// delete currentFilterObject.filterElement.filterElements;
|
|
1180
1167
|
filterElements[currentFilterMainId] = currentFilterObject;
|
|
1181
1168
|
|
|
1182
|
-
} else if (currentFilterObject.
|
|
1169
|
+
} else if (currentFilterObject.logicalElementType === 'childComplexFilter') {
|
|
1183
1170
|
console.log('-------- childComplexFilter ----------');
|
|
1184
1171
|
|
|
1185
1172
|
Object.assign(filterElements, currentFilterObject.filterElement.filterElements);
|
|
1186
|
-
delete currentFilterObject.filterElement.filterElements;
|
|
1173
|
+
// delete currentFilterObject.filterElement.filterElements;
|
|
1187
1174
|
filterElements[currentFilterMainId] = currentFilterObject;
|
|
1188
1175
|
|
|
1189
1176
|
} else {
|
|
1190
|
-
console.log(` -------- ${currentFilterObject.
|
|
1177
|
+
console.log(` -------- ${currentFilterObject.logicalElementType} ----------`);
|
|
1191
1178
|
//'logical'| 'identifiers'|'translateIds'|'traversal'
|
|
1192
1179
|
filterElements[currentFilterMainId] = currentFilterObject;
|
|
1193
1180
|
};
|
|
@@ -1202,7 +1189,7 @@ export default {
|
|
|
1202
1189
|
//* create filter
|
|
1203
1190
|
createFiltersRequest,
|
|
1204
1191
|
validateCombinationStructure,
|
|
1205
|
-
// validateOperation,
|
|
1206
1192
|
filterLogicalElements,
|
|
1193
|
+
// validateOperation,
|
|
1207
1194
|
// splitFilterElements,
|
|
1208
1195
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2025 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
import LogicalStructureSharedLib from './LogicalStructureSharedLib.js';
|
|
20
|
+
|
|
21
|
+
function initSchemaFn(getObjSchemaS3WithHierarchyShared, getObjectLinksShared) {
|
|
22
|
+
return LogicalStructureSharedLib.initSchemaFn(getObjSchemaS3WithHierarchyShared, getObjectLinksShared);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default {
|
|
26
|
+
initSchemaFn
|
|
27
|
+
}
|
|
@@ -18,14 +18,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
21
|
+
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
22
22
|
import lodash from 'lodash';
|
|
23
23
|
const { isEmpty } = lodash;
|
|
24
|
-
import { v4 as uuidV4 } from 'uuid';
|
|
25
|
-
import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
|
|
26
|
-
// import { getObjectSchema } from '@izara_project/izara-shared-service-schemas';
|
|
24
|
+
import { v4 as uuidV4 } from 'uuid';
|
|
27
25
|
const MAX_ITER = 4;
|
|
28
26
|
|
|
27
|
+
let getObjectSchema = {};
|
|
28
|
+
|
|
29
|
+
function initSchemaFn(getObjSchemaS3WithHierarchyShared, getObjectLinksShared) {
|
|
30
|
+
getObjectSchema = {
|
|
31
|
+
getObjSchemaS3WithHierarchyShared,
|
|
32
|
+
getObjectLinksShared
|
|
33
|
+
}
|
|
34
|
+
return getObjectSchema;
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
|
|
30
38
|
function combineLogicalStructure(
|
|
31
39
|
objType,
|
|
@@ -594,15 +602,13 @@ async function changeObjTypePath(
|
|
|
594
602
|
requiredObjType,
|
|
595
603
|
filtersStructure,
|
|
596
604
|
path = null,
|
|
597
|
-
|
|
598
|
-
PATHCONSTANCES = null,
|
|
605
|
+
PATHCONSTANCES = null
|
|
599
606
|
) {
|
|
600
607
|
try {
|
|
601
608
|
console.log('----- function validateSearchTypeFilterType -----', {
|
|
602
609
|
requiredObjType,
|
|
603
610
|
filtersStructure,
|
|
604
|
-
path
|
|
605
|
-
// getSchemaFn,
|
|
611
|
+
path
|
|
606
612
|
});
|
|
607
613
|
|
|
608
614
|
let filterLogicalStructure = {};
|
|
@@ -745,14 +751,9 @@ async function changeObjTypePath(
|
|
|
745
751
|
if (!childLogicalElement.hasOwnProperty('childLogicalElementId')) {
|
|
746
752
|
|
|
747
753
|
// let childSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
748
|
-
let childSchema = await getObjectSchema.
|
|
749
|
-
{},// _izContext, maybe delete
|
|
754
|
+
let childSchema = await getObjectSchema.getObjSchemaS3WithHierarchyShared(
|
|
750
755
|
childLogicalElement.objType
|
|
751
756
|
);
|
|
752
|
-
// let childSchema = await getObjectSchema.getObjSchemaWithoutHierarchy(
|
|
753
|
-
// getSchemaFn,
|
|
754
|
-
// childLogicalElement.objType
|
|
755
|
-
// );
|
|
756
757
|
console.log('childSchema: ', childSchema);
|
|
757
758
|
|
|
758
759
|
if (childSchema.hasOwnProperty('extendObjType')) {
|
|
@@ -768,7 +769,7 @@ async function changeObjTypePath(
|
|
|
768
769
|
};
|
|
769
770
|
} else {
|
|
770
771
|
checkChild = true;
|
|
771
|
-
}
|
|
772
|
+
}
|
|
772
773
|
|
|
773
774
|
if (checkChild) {
|
|
774
775
|
|
|
@@ -907,6 +908,9 @@ async function changeObjTypePath(
|
|
|
907
908
|
};
|
|
908
909
|
//###################################################################################################################################################################################
|
|
909
910
|
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
910
914
|
function createChildComplexFilterStructure(
|
|
911
915
|
logicalElements,
|
|
912
916
|
previousLogicalElementId,
|
|
@@ -956,21 +960,17 @@ function createChildComplexFilterStructure(
|
|
|
956
960
|
async function findObjTypePathToAnotherObjType(
|
|
957
961
|
fromObjType,
|
|
958
962
|
toObjType,
|
|
959
|
-
PATHCONSTANCES
|
|
960
|
-
// getSchemaFn
|
|
963
|
+
PATHCONSTANCES
|
|
961
964
|
) {
|
|
962
965
|
console.log('----- function findObjTypePathToAnotherObjType -----', {
|
|
963
966
|
fromObjType,
|
|
964
|
-
toObjType
|
|
965
|
-
PATHCONSTANCES,
|
|
966
|
-
// getSchemaFn
|
|
967
|
+
toObjType
|
|
967
968
|
});
|
|
968
969
|
|
|
969
970
|
let [path, errorsObject, errorsFound] = await recursiveFindObjTypeTypePathToAnotherObjType(
|
|
970
971
|
PATHCONSTANCES,
|
|
971
972
|
fromObjType,
|
|
972
973
|
toObjType,
|
|
973
|
-
// getSchemaFn
|
|
974
974
|
);
|
|
975
975
|
console.log('return path', {
|
|
976
976
|
path,
|
|
@@ -991,14 +991,12 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
|
|
|
991
991
|
PATHCONSTANCES,
|
|
992
992
|
fromObjType,
|
|
993
993
|
toObjType,
|
|
994
|
-
// getSchemaFn,
|
|
995
994
|
iter = 1
|
|
996
995
|
) {
|
|
997
996
|
console.log('----- function recursiveFindObjTypeTypePathToAnotherObjType -----', {
|
|
998
997
|
PATHCONSTANCES,
|
|
999
998
|
fromObjType,
|
|
1000
999
|
toObjType,
|
|
1001
|
-
// getSchemaFn,
|
|
1002
1000
|
iter
|
|
1003
1001
|
});
|
|
1004
1002
|
|
|
@@ -1027,15 +1025,9 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
|
|
|
1027
1025
|
return [null, errorsObject, errorsFound];
|
|
1028
1026
|
};
|
|
1029
1027
|
|
|
1030
|
-
|
|
1031
|
-
const objectRelationship = await getObjectSchema.getObjectRelationship(
|
|
1032
|
-
{}, //_izContext maybe delete
|
|
1028
|
+
const objectRelationship = await getObjectSchema.getObjectLinksShared(
|
|
1033
1029
|
fromObjType
|
|
1034
1030
|
);
|
|
1035
|
-
// const objectRelationship = await getObjectSchema.getObjectRelationship(
|
|
1036
|
-
// getSchemaFn,
|
|
1037
|
-
// fromObjType
|
|
1038
|
-
// )
|
|
1039
1031
|
console.log("objectRelationship: ", { fromObjType, objectRelationship });
|
|
1040
1032
|
|
|
1041
1033
|
let path = null;
|
|
@@ -1066,14 +1058,9 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
|
|
|
1066
1058
|
};
|
|
1067
1059
|
|
|
1068
1060
|
// const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
1069
|
-
const objectSchema = await getObjectSchema.
|
|
1070
|
-
{}, //_izContext maybe delete
|
|
1061
|
+
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchyShared(
|
|
1071
1062
|
toObjType,
|
|
1072
1063
|
);
|
|
1073
|
-
// const objectSchema = await getObjectSchema.getObjSchemaWithoutHierarchy(
|
|
1074
|
-
// getSchemaFn,
|
|
1075
|
-
// toObjType,
|
|
1076
|
-
// )
|
|
1077
1064
|
console.log('objectSchema: ', objectSchema);
|
|
1078
1065
|
console.log('before relationshipObject: ', {
|
|
1079
1066
|
from: fromObjType,
|
|
@@ -1103,7 +1090,6 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
|
|
|
1103
1090
|
PATHCONSTANCES,
|
|
1104
1091
|
otherObjType,
|
|
1105
1092
|
toObjType,
|
|
1106
|
-
// getSchemaFn,
|
|
1107
1093
|
iter + 1
|
|
1108
1094
|
);
|
|
1109
1095
|
console.log('return recursive path: ', {
|
|
@@ -1168,15 +1154,14 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
|
|
|
1168
1154
|
|
|
1169
1155
|
|
|
1170
1156
|
export default {
|
|
1171
|
-
|
|
1172
|
-
changeObjTypePath,
|
|
1173
|
-
findObjTypePathToAnotherObjType,
|
|
1174
|
-
|
|
1157
|
+
initSchemaFn,
|
|
1175
1158
|
|
|
1176
|
-
//* use in back-end
|
|
1177
1159
|
combineLogicalStructure,
|
|
1160
|
+
// combineOperation,
|
|
1161
|
+
// combineLogicalElements,
|
|
1162
|
+
|
|
1178
1163
|
checkAndCreateBracket,
|
|
1179
|
-
// changeObjTypePath,
|
|
1180
|
-
// findObjTypePathToAnotherObjType,
|
|
1181
1164
|
|
|
1165
|
+
changeObjTypePath,
|
|
1166
|
+
findObjTypePathToAnotherObjType
|
|
1182
1167
|
}
|
|
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
"use strict";
|
|
19
19
|
|
|
20
20
|
//* searchResultMain record
|
|
21
|
-
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
21
|
+
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
22
22
|
import lodash from 'lodash';
|
|
23
23
|
const { isEmpty } = lodash;
|
|
24
|
-
import filtersSharedLib from './FiltersSharedLib.js';
|
|
24
|
+
import filtersSharedLib from './FiltersSharedLib.js';
|
|
25
25
|
import dataFieldsSharedLib from './DataFieldsSharedLib.js';
|
|
26
26
|
|
|
27
27
|
|
|
@@ -35,7 +35,7 @@ async function createSearchRequest(
|
|
|
35
35
|
requiredDataLinkStepObjects,
|
|
36
36
|
requiredDataLinkSteps,
|
|
37
37
|
values,
|
|
38
|
-
|
|
38
|
+
getSchemaFn
|
|
39
39
|
) {
|
|
40
40
|
console.log('createSearchResult: ', {
|
|
41
41
|
objType,
|
|
@@ -46,8 +46,7 @@ async function createSearchRequest(
|
|
|
46
46
|
perParentCombinations,
|
|
47
47
|
requiredDataLinkStepObjects,
|
|
48
48
|
requiredDataLinkSteps,
|
|
49
|
-
values
|
|
50
|
-
// getSchemaFn
|
|
49
|
+
values
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
let filterElements = {};
|
|
@@ -55,6 +54,7 @@ async function createSearchRequest(
|
|
|
55
54
|
let errorsObject = {};
|
|
56
55
|
let errorsFound = [];
|
|
57
56
|
|
|
57
|
+
|
|
58
58
|
let requiredDataPromise = dataFieldsSharedLib.createRequiredData(
|
|
59
59
|
objType,
|
|
60
60
|
requiredDataFields,
|
|
@@ -63,7 +63,7 @@ async function createSearchRequest(
|
|
|
63
63
|
requiredDataLinkStepObjects,
|
|
64
64
|
requiredDataLinkSteps,
|
|
65
65
|
values,
|
|
66
|
-
|
|
66
|
+
getSchemaFn
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
//* create complexFilter normalize to send backend
|
|
@@ -91,6 +91,8 @@ async function createSearchRequest(
|
|
|
91
91
|
Object.assign(errorsObject, complexErrorsObject);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
filterElements = complexFilterRequest.filterElements;
|
|
95
|
+
|
|
94
96
|
// let requiredData = dataFieldsSharedLib.createRequiredData(
|
|
95
97
|
// objType,
|
|
96
98
|
// requiredDataFields,
|
|
@@ -113,8 +115,6 @@ async function createSearchRequest(
|
|
|
113
115
|
return [null, 'invalid', errorsObject, errorsFound]
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
filterElements = complexFilterRequest.filterElements;
|
|
117
|
-
|
|
118
118
|
if (!isEmpty(requiredData.perParentCombinations)) {
|
|
119
119
|
for (const filterObject of Object.values(requiredData.perParentCombinations)) {
|
|
120
120
|
Object.assign(filterElements, filterObject.filterElements);
|
|
@@ -166,7 +166,6 @@ async function createSortRequest(
|
|
|
166
166
|
requiredDataLinkSteps,
|
|
167
167
|
sortFields,
|
|
168
168
|
values,
|
|
169
|
-
// getSchemaFn
|
|
170
169
|
) {
|
|
171
170
|
console.log('createSortResult: ', {
|
|
172
171
|
objType,
|
|
@@ -178,8 +177,7 @@ async function createSortRequest(
|
|
|
178
177
|
requiredDataLinkStepObjects,
|
|
179
178
|
requiredDataLinkSteps,
|
|
180
179
|
sortFields,
|
|
181
|
-
values
|
|
182
|
-
// getSchemaFn
|
|
180
|
+
values
|
|
183
181
|
});
|
|
184
182
|
|
|
185
183
|
let sortFieldMain = []
|
|
@@ -222,8 +220,7 @@ async function createSortRequest(
|
|
|
222
220
|
perParentCombinations,
|
|
223
221
|
requiredDataLinkStepObjects,
|
|
224
222
|
requiredDataLinkSteps,
|
|
225
|
-
values
|
|
226
|
-
// getSchemaFn
|
|
223
|
+
values
|
|
227
224
|
);
|
|
228
225
|
console.log('SearchResultRequest: ', {
|
|
229
226
|
searchResultRequest,
|
|
@@ -233,7 +230,7 @@ async function createSortRequest(
|
|
|
233
230
|
});
|
|
234
231
|
|
|
235
232
|
if (errorsFound.length > 0) {
|
|
236
|
-
return [null, 'invalid', errorsObject, errorsFound]
|
|
233
|
+
return [null, null, 'invalid', errorsObject, errorsFound]
|
|
237
234
|
}
|
|
238
235
|
|
|
239
236
|
let searchResultId = searchResultRequest.searchResultId;
|
|
@@ -274,9 +271,4 @@ export default {
|
|
|
274
271
|
//* create request to backend to sort and search
|
|
275
272
|
createSearchRequest,
|
|
276
273
|
createSortRequest
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
// getSchemaFn = {
|
|
281
|
-
|
|
282
|
-
// }
|
|
274
|
+
}
|