@izara_project/izara-shared-search-and-sort 1.0.7 → 1.0.8

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 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.7",
3
+ "version": "1.0.8",
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-complex-filter": "^1.0.8",
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
  }
@@ -35,7 +35,7 @@ async function createRequiredData(
35
35
  requiredDataLinkStepObjects,
36
36
  requiredDataLinkSteps,
37
37
  values,
38
- // getSchemaFn
38
+ getSchemaFn
39
39
  ) {
40
40
  console.log('createRequiredData: ', {
41
41
  objType,
@@ -44,7 +44,7 @@ async function createRequiredData(
44
44
  perParentCombinations,
45
45
  requiredDataLinkStepObjects,
46
46
  values,
47
- // getSchemaFn
47
+ getSchemaFn
48
48
  });
49
49
 
50
50
  let errorsObject = {};
@@ -75,7 +75,6 @@ async function createRequiredData(
75
75
  perParentCombinations,
76
76
  complexFilterCombinations,
77
77
  values,
78
- // getSchemaFn,
79
78
  errorsObject,
80
79
  errorsFound
81
80
  );
@@ -86,12 +85,9 @@ async function createRequiredData(
86
85
  linkPathErrorsFound
87
86
  });
88
87
 
89
- if (linkPathErrorsFound.length > 0) {
88
+ if (linkPathErrorsFound.length > 0 || fieldName === null) {
90
89
  Object.assign(errorsObject, linkPathErrorObject);
91
90
  errorsFound = errorsFound.concat(linkPathErrorsFound);
92
- };
93
-
94
- if (fieldName === null) {
95
91
  return {
96
92
  requiredDataHash: null,
97
93
  requiredDataObject: requiredDataObject,
@@ -117,6 +113,8 @@ async function createRequiredData(
117
113
  Object.assign(linkPathObjects, returnValue.sortFieldLinkPathObjects.linkPathObjects);
118
114
  }
119
115
 
116
+ console.log('returnValue.linkStepObjects: ', returnValue.linkStepObjects);
117
+
120
118
  let pathObject = {
121
119
  initialObjType: objType,
122
120
  linkSteps: returnValue.linkSteps
@@ -131,16 +129,17 @@ async function createRequiredData(
131
129
  linkPathObjectId: pathId
132
130
  };
133
131
 
134
- Object.assign(linkPathObjects, { [pathId]: pathObject });
135
-
136
132
  let requiredFieldNameObject = {
137
- fieldName: fieldName,
138
- linkPathObjects: linkPathObjects,
139
- linkPathSteps: linkPathSteps
133
+ // fieldName: fieldName,
134
+ fieldName: setObject,
135
+ linkPathObjects: {
136
+ [pathId]: pathObject
137
+ },
138
+ linkPathSteps: returnValue.linkStepObjects
140
139
  };
141
140
 
142
141
  if (returnValue.hasOwnProperty('complexFilterCombinations')) {
143
- requiredFieldNameObject.complexFilterCombinations = returnValue.complexFilterCombinations;
142
+ // requiredFieldNameObject.complexFilterCombinations = returnValue.complexFilterCombinations;
144
143
  Object.assign(setComplexFilterCombinations, returnValue.complexFilterCombinations);
145
144
 
146
145
  setObject.complexFilterCombinationIds = []
@@ -152,12 +151,12 @@ async function createRequiredData(
152
151
  };
153
152
 
154
153
  if (returnValue.hasOwnProperty('perParentCombinations')) {
155
- requiredFieldNameObject.perParentCombinations = returnValue.perParentCombinations;
154
+ // requiredFieldNameObject.perParentCombinations = returnValue.perParentCombinations;
156
155
  Object.assign(setPerParentCombinations, returnValue.perParentCombinations);
157
156
  };
158
157
 
159
158
  if (returnValue.hasOwnProperty('filterElements')) {
160
- requiredFieldNameObject.filterElements = returnValue.filterElements;
159
+ // requiredFieldNameObject.filterElements = returnValue.filterElements;
161
160
  Object.assign(setFilterElementsLink, returnValue.filterElements);
162
161
  };
163
162
  console.log('requiredFieldNameObject: ', requiredFieldNameObject);
@@ -174,6 +173,8 @@ async function createRequiredData(
174
173
  requiredDataObject[requiredDataFieldNameId] = setObject;
175
174
  };
176
175
 
176
+ Object.assign(linkPathObjects, { [pathId]: pathObject });
177
+
177
178
  } else {
178
179
  console.log("------- requiredData has only fieldName ---------");
179
180
 
@@ -269,7 +270,6 @@ async function createLinkPath(
269
270
  perParentCombinations,
270
271
  complexFilterCombinations,
271
272
  values,
272
- // getSchemaFn,
273
273
  errorsObject,
274
274
  errorsFound,
275
275
  index = 0,
@@ -291,17 +291,6 @@ async function createLinkPath(
291
291
  });
292
292
  let fieldName = null;
293
293
  let returnValue = {}; //* must return only linkPath params
294
- // let linkPathSteps = [];
295
- // let linkPathStepObjects = {};
296
- // let filterElementsLink = {};
297
- // let perParentCombination = {};
298
-
299
- // let errorsObject = {}
300
- // let errorsFound = [];
301
-
302
- // let childLinkStep = null
303
- // let childLinkErrorObject = {};
304
- // let childLinkErrors = []
305
294
 
306
295
  let linkStepId = linkSteps[index];
307
296
  console.log('linkStepId: ', linkStepId);
@@ -329,7 +318,6 @@ async function createLinkPath(
329
318
  linkSteps,
330
319
  requiredDataLinkStepObjects,
331
320
  requiredDataLinkSteps,
332
- // getSchemaFn,
333
321
  errorsObject,
334
322
  errorsFound
335
323
  );
@@ -341,7 +329,6 @@ async function createLinkPath(
341
329
  perParentCombinations,
342
330
  complexFilterCombinations,
343
331
  values,
344
- // getSchemaFn,
345
332
  errorsObject,
346
333
  errorsFound,
347
334
  index + 1
@@ -354,6 +341,10 @@ async function createLinkPath(
354
341
  index
355
342
  });
356
343
 
344
+ if (errorsFound.length > 0) {
345
+ return [null, null, errorsObject, errorsFound]
346
+ }
347
+
357
348
  console.log('linkStep', linkStep);
358
349
 
359
350
  let [conditions, conditionErrObject, conditionErrFound] = await conditionsPromise;
@@ -361,6 +352,8 @@ async function createLinkPath(
361
352
  if (conditionErrFound.length > 0) {
362
353
  Object.assign(errorsObject, conditionErrObject);
363
354
  errorsFound = errorsFound.concat(conditionErrFound);
355
+
356
+ return [null, null, errorsObject, errorsFound]
364
357
  };
365
358
 
366
359
  if (!isEmpty(returnValue)) {
@@ -411,15 +404,37 @@ async function createLinkPath(
411
404
  if (conditions.hasOwnProperty("setFilterCombinations") && !isEmpty(conditions.setFilterCombinations)) {
412
405
 
413
406
  if (conditions.setFilterCombinations.hasOwnProperty('filterElements')) {
414
- Object.assign(returnValue["filterElements"], conditions.setFilterCombinations.filterElements.filterElements);
407
+
408
+ if (returnValue.hasOwnProperty("filterElements")) {
409
+ Object.assign(returnValue["filterElements"], conditions.setFilterCombinations.filterElements.filterElements);
410
+ } else {
411
+ returnValue.filterElements = {};
412
+ Object.assign(returnValue["filterElements"], conditions.setFilterCombinations.filterElements.filterElements);
413
+ }
414
+
415
415
  }
416
416
 
417
417
  if (conditions.setFilterCombinations.hasOwnProperty('perParentCombinations')) {
418
- Object.assign(returnValue["perParentCombinations"], conditions.setFilterCombinations.perParentCombinations);
418
+
419
+ if (returnValue.hasOwnProperty("perParentCombinations")) {
420
+ Object.assign(returnValue["perParentCombinations"], conditions.setFilterCombinations.perParentCombinations);
421
+ } else {
422
+ returnValue.perParentCombinations = {};
423
+ Object.assign(returnValue["perParentCombinations"], conditions.setFilterCombinations.perParentCombinations);
424
+ }
425
+
419
426
  };
420
427
 
421
428
  if (conditions.setFilterCombinations.hasOwnProperty('complexFilterCombinations')) {
422
- Object.assign(returnValue['complexFilterCombinations'], conditions.setFilterCombinations.complexFilterCombinations);
429
+
430
+ if (returnValue.hasOwnProperty("complexFilterCombinations")) {
431
+ Object.assign(returnValue['complexFilterCombinations'], conditions.setFilterCombinations.complexFilterCombinations);
432
+ } else {
433
+ returnValue.complexFilterCombinations = {};
434
+ Object.assign(returnValue["complexFilterCombinations"], conditions.setFilterCombinations.complexFilterCombinations);
435
+ }
436
+
437
+
423
438
  };
424
439
  }
425
440
 
@@ -429,6 +444,7 @@ async function createLinkPath(
429
444
  //* error
430
445
  errorsObject[linkStepId] = `has linkPathObject but no data`;
431
446
  errorsFound.push(`${linkStepId} no data in linkPathObject`)
447
+ return [null, null, errorsObject, errorsFound]
432
448
  }
433
449
  }
434
450
 
@@ -536,7 +552,8 @@ async function createLinkPath(
536
552
  } else {
537
553
  //* error
538
554
  errorsObject[linkStepId] = `has linkPathObject but no data`;
539
- errorsFound.push(`${linkStepId} no data in linkPathObject`)
555
+ errorsFound.push(`${linkStepId} no data in linkPathObject`);
556
+ return [null, null, errorsObject, errorsFound]
540
557
  }
541
558
  }
542
559
 
@@ -558,6 +575,16 @@ async function createLinkPath(
558
575
  };
559
576
  };
560
577
 
578
+ if (conditions.hasOwnProperty("comparison")) {
579
+ if (conditions.hasOwnProperty("comparisonSortField")) {
580
+ if (conditions.hasOwnProperty("comparisonValue")) {
581
+ linkStepObject.comparison = conditions.comparison;
582
+ linkStepObject.comparisonSortField = conditions.comparisonSortField;
583
+ linkStepObject.comparisonValue = conditions.comparisonValue;
584
+ }
585
+ }
586
+ }
587
+
561
588
  console.log('linkStepObject', linkStepObject);
562
589
  let linkStepId = hash(linkStepObject);
563
590
  console.log('linkStepId', linkStepId);
@@ -582,7 +609,6 @@ async function checkConditionsLink(
582
609
  linkSteps,
583
610
  requiredDataLinkStepObjects,
584
611
  requiredDataLinkSteps,
585
- // getSchemaFn,
586
612
  errorsObject,
587
613
  errorsFound
588
614
  ) {
@@ -595,7 +621,6 @@ async function checkConditionsLink(
595
621
  linkSteps,
596
622
  requiredDataLinkStepObjects,
597
623
  requiredDataLinkSteps,
598
- // getSchemaFn,
599
624
  errorsObject,
600
625
  errorsFound
601
626
  });
@@ -621,7 +646,8 @@ async function checkConditionsLink(
621
646
 
622
647
  if (filterErrorsFound.length > 0) {
623
648
  Object.assign(errorsObject, filterErrorsObject)
624
- errorsFound = errorsFound.concat(filterErrorsFound)
649
+ errorsFound = errorsFound.concat(filterErrorsFound);
650
+ return [null, errorsObject, errorsFound]
625
651
  };
626
652
  conditionLinkObject.filterElements = complexFilterRequest.filterElements;
627
653
  console.log('conditionLinkObject in condition link: ', conditionLinkObject);
@@ -630,7 +656,9 @@ async function checkConditionsLink(
630
656
  if (linkStepObject.hasOwnProperty('aggregate')) {
631
657
  console.log('------------ has aggregate ------------');
632
658
  if (!linkStepObject.hasOwnProperty('sortFields')) {
659
+ errorsObject[objType.objectType] = 'if has aggregate need to has sortFields, too';
633
660
  errorsFound.push('if has aggregate need to has sortFields, too');
661
+ return [null, errorsObject, errorsFound]
634
662
  };
635
663
  conditionLinkObject.aggregate = linkStepObject.aggregate;
636
664
  conditionLinkObject.sortFields = [];
@@ -668,7 +696,6 @@ async function checkConditionsLink(
668
696
  perParentCombinations,
669
697
  complexFilterCombinations,
670
698
  values,
671
- // getSchemaFn,
672
699
  errorsObject,
673
700
  errorsFound
674
701
  );
@@ -679,6 +706,12 @@ async function checkConditionsLink(
679
706
  linkErrorsFound
680
707
  });
681
708
 
709
+ if (linkErrorsFound > 0) {
710
+ Object.assign(errorsObject, linkErrorsObject);
711
+ errorsFound = errorsFound.concat(linkErrorsFound);
712
+ return [null, errorsObject, errorsFound]
713
+ }
714
+
682
715
  if (!isEmpty(childLinkStep)) {
683
716
 
684
717
  //* create linkPathObject from child
@@ -764,7 +797,9 @@ async function checkConditionsLink(
764
797
 
765
798
  } else {
766
799
  if (linkStepObject.hasOwnProperty('combine')) {
767
- errorsFound.push('this link set combine must set aggregate and sortFields, too');
800
+ errorsObject[objType.objectType] = 'must set aggregate and sortFields';
801
+ errorsFound = errorsFound.concat('must set aggregate and sortFields')
802
+ return [null, errorsObject, errorsFound]
768
803
  }
769
804
  };
770
805
 
@@ -889,6 +924,10 @@ async function checkConditionsLink(
889
924
  };
890
925
  };
891
926
 
927
+ if (errorsFound.length > 0) {
928
+ return [null, errorsObject, errorsFound]
929
+ }
930
+
892
931
  console.log('perParentCombinations: ', {
893
932
  perParentCombinationIds,
894
933
  perParentCombinationObjects,
@@ -906,6 +945,22 @@ async function checkConditionsLink(
906
945
  };
907
946
  console.log('conditionLinkObject: ', conditionLinkObject);
908
947
  }
948
+
949
+ if (linkStepObject.hasOwnProperty("comparison")) {
950
+ console.log('------------ link has comparison ------------');
951
+
952
+ if (!linkStepObject.hasOwnProperty("comparisonSortField") || !linkStepObject.hasOwnProperty("comparisonValue")) {
953
+ errorsObject[objType.objectType] = 'no comparisonSortField | comparisonValue';
954
+ errorsFound.push(`${objType.objectType}: no comparisonSortField | comparisonValue`);
955
+ return [null, errorsObject, errorsFound]
956
+ }
957
+
958
+ conditionLinkObject.comparison = linkStepObject.comparison;
959
+ conditionLinkObject.comparisonSortField = linkStepObject.comparisonSortField;
960
+ conditionLinkObject.comparisonValue = values[linkStepObject.comparisonValue].value;
961
+
962
+ }
963
+
909
964
  console.log('conditionLinkObject', conditionLinkObject);
910
965
  return [conditionLinkObject, errorsObject, errorsFound];
911
966
  }
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  import { objectHash as hash } from '@izara_project/izara-shared-core'; //const hash = require('@izara_project/izara-shared-core').objectHash;
21
21
  import lodash from 'lodash';
22
22
  const { isEmpty } = lodash;
23
+ import complexFilterShared from '@izara_project/izara-core-library-complex-filter';
23
24
 
24
25
  function validateFilterElement(
25
26
  filterElements,
@@ -1151,43 +1152,43 @@ function splitFilterElements(
1151
1152
  // || runningFilterObject.filterElement.filterType === 'traversal'
1152
1153
  // ) {}
1153
1154
 
1154
- if (runningFilterObject.filterElement.filterType === 'operation') {
1155
+ if (runningFilterObject.logicalElementType === 'operation') {
1155
1156
  console.log('-------- operation ----------');
1156
1157
 
1157
1158
  Object.assign(filterElements, runningFilterObject.filterElement.filterElements);
1158
- delete runningFilterObject.filterElement.filterElements;
1159
+ // delete runningFilterObject.filterElement.filterElements;
1159
1160
  filterElements[runningFilterMainId] = runningFilterObject;
1160
1161
 
1161
- } else if (runningFilterObject.filterElement.filterType === 'childComplexFilter') {
1162
+ } else if (runningFilterObject.logicalElementType === 'childComplexFilter') {
1162
1163
  console.log('-------- childComplexFilter ----------');
1163
1164
 
1164
1165
  Object.assign(filterElements, runningFilterObject.filterElement.filterElements);
1165
- delete runningFilterObject.filterElement.filterElements;
1166
+ // delete runningFilterObject.filterElement.filterElements;
1166
1167
  filterElements[runningFilterMainId] = runningFilterObject;
1167
1168
 
1168
1169
  } else {
1169
- console.log(` -------- ${runningFilterObject.filterElement.filterType} ----------`);
1170
+ console.log(` -------- ${runningFilterObject.logicalElementType} ----------`);
1170
1171
  //'logical'| 'identifiers'|'translateIds'|'traversal'
1171
1172
  filterElements[runningFilterMainId] = runningFilterObject;
1172
1173
  };
1173
1174
 
1174
1175
  if (currentFilterObject !== null) {
1175
- if (currentFilterObject.filterElement.filterType === 'operation') {
1176
+ if (currentFilterObject.logicalElementType === 'operation') {
1176
1177
  console.log('-------- operation ----------');
1177
1178
 
1178
1179
  Object.assign(filterElements, currentFilterObject.filterElement.filterElements);
1179
- delete currentFilterObject.filterElement.filterElements;
1180
+ // delete currentFilterObject.filterElement.filterElements;
1180
1181
  filterElements[currentFilterMainId] = currentFilterObject;
1181
1182
 
1182
- } else if (currentFilterObject.filterElement.filterType === 'childComplexFilter') {
1183
+ } else if (currentFilterObject.logicalElementType === 'childComplexFilter') {
1183
1184
  console.log('-------- childComplexFilter ----------');
1184
1185
 
1185
1186
  Object.assign(filterElements, currentFilterObject.filterElement.filterElements);
1186
- delete currentFilterObject.filterElement.filterElements;
1187
+ // delete currentFilterObject.filterElement.filterElements;
1187
1188
  filterElements[currentFilterMainId] = currentFilterObject;
1188
1189
 
1189
1190
  } else {
1190
- console.log(` -------- ${currentFilterObject.filterElement.filterType} ----------`);
1191
+ console.log(` -------- ${currentFilterObject.logicalElementType} ----------`);
1191
1192
  //'logical'| 'identifiers'|'translateIds'|'traversal'
1192
1193
  filterElements[currentFilterMainId] = currentFilterObject;
1193
1194
  };
@@ -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(getObjSchemaS3WithoutHierarchy, getObjectRelationship) { //getObjectLinks
22
+ return LogicalStructureSharedLib.initSchemaFn(getObjSchemaS3WithoutHierarchy, getObjectRelationship);
23
+ }
24
+
25
+ export default {
26
+ initSchemaFn
27
+ }
@@ -22,10 +22,19 @@ import { objectHash as hash } from '@izara_project/izara-shared-core'; //const
22
22
  import lodash from 'lodash';
23
23
  const { isEmpty } = lodash;
24
24
  import { v4 as uuidV4 } from 'uuid'; //const { v4: uuidv4 } = require('uuid');
25
- import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
26
- // import { getObjectSchema } from '@izara_project/izara-shared-service-schemas';
25
+ // import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
27
26
  const MAX_ITER = 4;
28
27
 
28
+ let getObjectSchema = {};
29
+
30
+ function initSchemaFn(getObjSchemaS3WithoutHierarchy, getObjectRelationship) { //getObjectLinks
31
+ getObjectSchema = {
32
+ getObjSchemaS3WithoutHierarchy,
33
+ getObjectRelationship: getObjectRelationship // getObjectRelationship: getObjectLinks
34
+ }
35
+
36
+ return getObjectSchema;
37
+ }
29
38
 
30
39
  function combineLogicalStructure(
31
40
  objType,
@@ -594,15 +603,13 @@ async function changeObjTypePath(
594
603
  requiredObjType,
595
604
  filtersStructure,
596
605
  path = null,
597
- // getSchemaFn,
598
- PATHCONSTANCES = null,
606
+ PATHCONSTANCES = null
599
607
  ) {
600
608
  try {
601
609
  console.log('----- function validateSearchTypeFilterType -----', {
602
610
  requiredObjType,
603
611
  filtersStructure,
604
- path,
605
- // getSchemaFn,
612
+ path
606
613
  });
607
614
 
608
615
  let filterLogicalStructure = {};
@@ -745,14 +752,9 @@ async function changeObjTypePath(
745
752
  if (!childLogicalElement.hasOwnProperty('childLogicalElementId')) {
746
753
 
747
754
  // let childSchema = await getObjectSchema.getObjSchemaS3WithCache(
748
- let childSchema = await getObjectSchema.getObjSchemaS3WithoutHierarchy(
749
- {},// _izContext, maybe delete
755
+ let childSchema = await getObjectSchema.getObjSchemaS3WithoutHierarchyV2(
750
756
  childLogicalElement.objType
751
757
  );
752
- // let childSchema = await getObjectSchema.getObjSchemaWithoutHierarchy(
753
- // getSchemaFn,
754
- // childLogicalElement.objType
755
- // );
756
758
  console.log('childSchema: ', childSchema);
757
759
 
758
760
  if (childSchema.hasOwnProperty('extendObjType')) {
@@ -768,7 +770,7 @@ async function changeObjTypePath(
768
770
  };
769
771
  } else {
770
772
  checkChild = true;
771
- };
773
+ }
772
774
 
773
775
  if (checkChild) {
774
776
 
@@ -808,6 +810,7 @@ async function changeObjTypePath(
808
810
 
809
811
  let logicalStructure = {};
810
812
  [previousLogicalElementId, previousLogicalElement, logicalStructure, errorsFound] = createChildComplexFilterStructure(
813
+ _izContext,
811
814
  logicalElements,
812
815
  previousLogicalElementId,
813
816
  previousLogicalElement,
@@ -857,6 +860,7 @@ async function changeObjTypePath(
857
860
  let logicalStructure = {};
858
861
  // change function name ==> set logicalElementId
859
862
  [previousLogicalElementId, previousLogicalElement, logicalStructure, errorsFound] = createChildComplexFilterStructure(
863
+ _izContext,
860
864
  logicalElements,
861
865
  previousLogicalElementId,
862
866
  previousLogicalElement,
@@ -907,6 +911,9 @@ async function changeObjTypePath(
907
911
  };
908
912
  //###################################################################################################################################################################################
909
913
 
914
+
915
+
916
+
910
917
  function createChildComplexFilterStructure(
911
918
  logicalElements,
912
919
  previousLogicalElementId,
@@ -956,21 +963,17 @@ function createChildComplexFilterStructure(
956
963
  async function findObjTypePathToAnotherObjType(
957
964
  fromObjType,
958
965
  toObjType,
959
- PATHCONSTANCES,
960
- // getSchemaFn
966
+ PATHCONSTANCES
961
967
  ) {
962
968
  console.log('----- function findObjTypePathToAnotherObjType -----', {
963
969
  fromObjType,
964
- toObjType,
965
- PATHCONSTANCES,
966
- // getSchemaFn
970
+ toObjType
967
971
  });
968
972
 
969
973
  let [path, errorsObject, errorsFound] = await recursiveFindObjTypeTypePathToAnotherObjType(
970
974
  PATHCONSTANCES,
971
975
  fromObjType,
972
976
  toObjType,
973
- // getSchemaFn
974
977
  );
975
978
  console.log('return path', {
976
979
  path,
@@ -991,14 +994,12 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
991
994
  PATHCONSTANCES,
992
995
  fromObjType,
993
996
  toObjType,
994
- // getSchemaFn,
995
997
  iter = 1
996
998
  ) {
997
999
  console.log('----- function recursiveFindObjTypeTypePathToAnotherObjType -----', {
998
1000
  PATHCONSTANCES,
999
1001
  fromObjType,
1000
1002
  toObjType,
1001
- // getSchemaFn,
1002
1003
  iter
1003
1004
  });
1004
1005
 
@@ -1032,10 +1033,6 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
1032
1033
  {}, //_izContext maybe delete
1033
1034
  fromObjType
1034
1035
  );
1035
- // const objectRelationship = await getObjectSchema.getObjectRelationship(
1036
- // getSchemaFn,
1037
- // fromObjType
1038
- // )
1039
1036
  console.log("objectRelationship: ", { fromObjType, objectRelationship });
1040
1037
 
1041
1038
  let path = null;
@@ -1070,10 +1067,6 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
1070
1067
  {}, //_izContext maybe delete
1071
1068
  toObjType,
1072
1069
  );
1073
- // const objectSchema = await getObjectSchema.getObjSchemaWithoutHierarchy(
1074
- // getSchemaFn,
1075
- // toObjType,
1076
- // )
1077
1070
  console.log('objectSchema: ', objectSchema);
1078
1071
  console.log('before relationshipObject: ', {
1079
1072
  from: fromObjType,
@@ -1103,7 +1096,6 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
1103
1096
  PATHCONSTANCES,
1104
1097
  otherObjType,
1105
1098
  toObjType,
1106
- // getSchemaFn,
1107
1099
  iter + 1
1108
1100
  );
1109
1101
  console.log('return recursive path: ', {
@@ -1168,15 +1160,14 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
1168
1160
 
1169
1161
 
1170
1162
  export default {
1171
- //* front-end
1172
- changeObjTypePath,
1173
- findObjTypePathToAnotherObjType,
1174
-
1163
+ initSchemaFn,
1175
1164
 
1176
- //* use in back-end
1177
1165
  combineLogicalStructure,
1166
+ // combineOperation,
1167
+ // combineLogicalElements,
1168
+
1178
1169
  checkAndCreateBracket,
1179
- // changeObjTypePath,
1180
- // findObjTypePathToAnotherObjType,
1181
1170
 
1171
+ changeObjTypePath,
1172
+ findObjTypePathToAnotherObjType
1182
1173
  }
@@ -23,7 +23,7 @@ import lodash from 'lodash';
23
23
  const { isEmpty } = lodash;
24
24
  import filtersSharedLib from './FiltersSharedLib.js'; //const filtersSharedLib = require('./FiltersSharedLib');
25
25
  import dataFieldsSharedLib from './DataFieldsSharedLib.js';
26
-
26
+ import LogicalStructureSharedLib from './LogicalStructureSharedLib.js';
27
27
 
28
28
  async function createSearchRequest(
29
29
  objType,
@@ -35,7 +35,7 @@ async function createSearchRequest(
35
35
  requiredDataLinkStepObjects,
36
36
  requiredDataLinkSteps,
37
37
  values,
38
- // getSchemaFn
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
- // getSchemaFn
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,
@@ -103,18 +105,16 @@ async function createSearchRequest(
103
105
  let requiredData = await requiredDataPromise;
104
106
  console.log('return create requiredData: ', requiredData);
105
107
 
106
- if (requiredData.status === 'invalid' || requiredData.errorsFound.length > 0) {
107
- Object.assign(errorsObject, requiredData.errorsObject)
108
- errorsFound.push('requiredData cannot create');
109
- errorsFound = errorsFound.concat(requiredData.errorsFound);
110
- }
108
+ // if (requiredData.status === 'invalid' || requiredData.errorsFound.length > 0) {
109
+ // Object.assign(errorsObject, requiredData.errorsObject)
110
+ // errorsFound.push('requiredData cannot create');
111
+ // errorsFound = errorsFound.concat(requiredData.errorsFound);
112
+ // }
111
113
 
112
114
  if (errorsFound.length > 0) {
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
+ }