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

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-shared-search-and-sort",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Shared Libraries frontend/backend for Search and Sort stack",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,6 +35,7 @@ async function createRequiredData(
35
35
  requiredDataLinkStepObjects,
36
36
  requiredDataLinkSteps,
37
37
  values,
38
+ // getSchemaFn
38
39
  ) {
39
40
  console.log('createRequiredData: ', {
40
41
  objType,
@@ -43,6 +44,7 @@ async function createRequiredData(
43
44
  perParentCombinations,
44
45
  requiredDataLinkStepObjects,
45
46
  values,
47
+ // getSchemaFn
46
48
  });
47
49
 
48
50
  let errorsObject = {};
@@ -73,6 +75,7 @@ async function createRequiredData(
73
75
  perParentCombinations,
74
76
  complexFilterCombinations,
75
77
  values,
78
+ // getSchemaFn,
76
79
  errorsObject,
77
80
  errorsFound
78
81
  );
@@ -266,6 +269,7 @@ async function createLinkPath(
266
269
  perParentCombinations,
267
270
  complexFilterCombinations,
268
271
  values,
272
+ // getSchemaFn,
269
273
  errorsObject,
270
274
  errorsFound,
271
275
  index = 0,
@@ -325,6 +329,7 @@ async function createLinkPath(
325
329
  linkSteps,
326
330
  requiredDataLinkStepObjects,
327
331
  requiredDataLinkSteps,
332
+ // getSchemaFn,
328
333
  errorsObject,
329
334
  errorsFound
330
335
  );
@@ -336,6 +341,7 @@ async function createLinkPath(
336
341
  perParentCombinations,
337
342
  complexFilterCombinations,
338
343
  values,
344
+ // getSchemaFn,
339
345
  errorsObject,
340
346
  errorsFound,
341
347
  index + 1
@@ -576,6 +582,7 @@ async function checkConditionsLink(
576
582
  linkSteps,
577
583
  requiredDataLinkStepObjects,
578
584
  requiredDataLinkSteps,
585
+ // getSchemaFn,
579
586
  errorsObject,
580
587
  errorsFound
581
588
  ) {
@@ -588,6 +595,7 @@ async function checkConditionsLink(
588
595
  linkSteps,
589
596
  requiredDataLinkStepObjects,
590
597
  requiredDataLinkSteps,
598
+ // getSchemaFn,
591
599
  errorsObject,
592
600
  errorsFound
593
601
  });
@@ -660,6 +668,7 @@ async function checkConditionsLink(
660
668
  perParentCombinations,
661
669
  complexFilterCombinations,
662
670
  values,
671
+ // getSchemaFn,
663
672
  errorsObject,
664
673
  errorsFound
665
674
  );
@@ -20,7 +20,6 @@ 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';
24
23
 
25
24
  function validateFilterElement(
26
25
  filterElements,
@@ -23,6 +23,7 @@ import lodash from 'lodash';
23
23
  const { isEmpty } = lodash;
24
24
  import { v4 as uuidV4 } from 'uuid'; //const { v4: uuidv4 } = require('uuid');
25
25
  import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
26
+ // import { getObjectSchema } from '@izara_project/izara-shared-service-schemas';
26
27
  const MAX_ITER = 4;
27
28
 
28
29
 
@@ -593,12 +594,15 @@ async function changeObjTypePath(
593
594
  requiredObjType,
594
595
  filtersStructure,
595
596
  path = null,
597
+ // getSchemaFn,
598
+ PATHCONSTANCES = null,
596
599
  ) {
597
600
  try {
598
601
  console.log('----- function validateSearchTypeFilterType -----', {
599
602
  requiredObjType,
600
603
  filtersStructure,
601
- path
604
+ path,
605
+ // getSchemaFn,
602
606
  });
603
607
 
604
608
  let filterLogicalStructure = {};
@@ -733,27 +737,37 @@ async function changeObjTypePath(
733
737
 
734
738
  //* delete level of objType
735
739
  let checkChild = false;
736
- for (const objType of PATHCONSTANCES.objTypes) {
737
- if (checkObjType(objType, childLogicalElement.objType) === true) {
738
- if (!childLogicalElement.hasOwnProperty('childLogicalElementId')) {
739
-
740
- // let childSchema = await getObjectSchema.getObjSchemaS3(
741
- let childSchema = await getObjectSchema.getObjSchemaS3WithoutHierarchy(
742
- {}, //_izContext maybe delete
743
- childLogicalElement.objType
744
- );
745
- console.log('childSchema: ', childSchema);
746
-
747
- if (childSchema.hasOwnProperty('extendObjType')) {
748
- if (checkObjType(requiredObjType, childSchema.extendObjType) === true) {
749
- checkChild = false;
750
- break;
740
+
741
+ if (PATHCONSTANCES != null) {
742
+
743
+ for (const objType of PATHCONSTANCES.objTypes) {
744
+ if (checkObjType(objType, childLogicalElement.objType) === true) {
745
+ if (!childLogicalElement.hasOwnProperty('childLogicalElementId')) {
746
+
747
+ // let childSchema = await getObjectSchema.getObjSchemaS3WithCache(
748
+ let childSchema = await getObjectSchema.getObjSchemaS3WithoutHierarchy(
749
+ {},// _izContext, maybe delete
750
+ childLogicalElement.objType
751
+ );
752
+ // let childSchema = await getObjectSchema.getObjSchemaWithoutHierarchy(
753
+ // getSchemaFn,
754
+ // childLogicalElement.objType
755
+ // );
756
+ console.log('childSchema: ', childSchema);
757
+
758
+ if (childSchema.hasOwnProperty('extendObjType')) {
759
+ if (checkObjType(requiredObjType, childSchema.extendObjType) === true) {
760
+ checkChild = false;
761
+ break;
762
+ };
751
763
  };
752
764
  };
765
+ checkChild = true;
766
+ break;
753
767
  };
754
- checkChild = true;
755
- break;
756
768
  };
769
+ } else {
770
+ checkChild = true;
757
771
  };
758
772
 
759
773
  if (checkChild) {
@@ -794,7 +808,6 @@ async function changeObjTypePath(
794
808
 
795
809
  let logicalStructure = {};
796
810
  [previousLogicalElementId, previousLogicalElement, logicalStructure, errorsFound] = createChildComplexFilterStructure(
797
- _izContext,
798
811
  logicalElements,
799
812
  previousLogicalElementId,
800
813
  previousLogicalElement,
@@ -844,7 +857,6 @@ async function changeObjTypePath(
844
857
  let logicalStructure = {};
845
858
  // change function name ==> set logicalElementId
846
859
  [previousLogicalElementId, previousLogicalElement, logicalStructure, errorsFound] = createChildComplexFilterStructure(
847
- _izContext,
848
860
  logicalElements,
849
861
  previousLogicalElementId,
850
862
  previousLogicalElement,
@@ -888,7 +900,7 @@ async function changeObjTypePath(
888
900
  return [filterLogicalStructure, errorsObject, errorsFound];
889
901
 
890
902
  } catch (err) {
891
- _izContext.logger.error('error ValidateSearchTypeFilterType: ', err)
903
+ console.log('error ValidateSearchTypeFilterType: ', err)
892
904
  throw (err);
893
905
  };
894
906
 
@@ -944,17 +956,21 @@ function createChildComplexFilterStructure(
944
956
  async function findObjTypePathToAnotherObjType(
945
957
  fromObjType,
946
958
  toObjType,
947
- PATHCONSTANCES
959
+ PATHCONSTANCES,
960
+ // getSchemaFn
948
961
  ) {
949
962
  console.log('----- function findObjTypePathToAnotherObjType -----', {
950
963
  fromObjType,
951
- toObjType
964
+ toObjType,
965
+ PATHCONSTANCES,
966
+ // getSchemaFn
952
967
  });
953
968
 
954
969
  let [path, errorsObject, errorsFound] = await recursiveFindObjTypeTypePathToAnotherObjType(
955
970
  PATHCONSTANCES,
956
971
  fromObjType,
957
972
  toObjType,
973
+ // getSchemaFn
958
974
  );
959
975
  console.log('return path', {
960
976
  path,
@@ -975,12 +991,14 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
975
991
  PATHCONSTANCES,
976
992
  fromObjType,
977
993
  toObjType,
994
+ // getSchemaFn,
978
995
  iter = 1
979
996
  ) {
980
997
  console.log('----- function recursiveFindObjTypeTypePathToAnotherObjType -----', {
981
998
  PATHCONSTANCES,
982
999
  fromObjType,
983
1000
  toObjType,
1001
+ // getSchemaFn,
984
1002
  iter
985
1003
  });
986
1004
 
@@ -1014,6 +1032,10 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
1014
1032
  {}, //_izContext maybe delete
1015
1033
  fromObjType
1016
1034
  );
1035
+ // const objectRelationship = await getObjectSchema.getObjectRelationship(
1036
+ // getSchemaFn,
1037
+ // fromObjType
1038
+ // )
1017
1039
  console.log("objectRelationship: ", { fromObjType, objectRelationship });
1018
1040
 
1019
1041
  let path = null;
@@ -1048,6 +1070,10 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
1048
1070
  {}, //_izContext maybe delete
1049
1071
  toObjType,
1050
1072
  );
1073
+ // const objectSchema = await getObjectSchema.getObjSchemaWithoutHierarchy(
1074
+ // getSchemaFn,
1075
+ // toObjType,
1076
+ // )
1051
1077
  console.log('objectSchema: ', objectSchema);
1052
1078
  console.log('before relationshipObject: ', {
1053
1079
  from: fromObjType,
@@ -1077,6 +1103,7 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
1077
1103
  PATHCONSTANCES,
1078
1104
  otherObjType,
1079
1105
  toObjType,
1106
+ // getSchemaFn,
1080
1107
  iter + 1
1081
1108
  );
1082
1109
  console.log('return recursive path: ', {
@@ -1141,12 +1168,15 @@ async function recursiveFindObjTypeTypePathToAnotherObjType(
1141
1168
 
1142
1169
 
1143
1170
  export default {
1144
- combineLogicalStructure,
1145
- // combineOperation,
1146
- // combineLogicalElements,
1171
+ //* front-end
1172
+ changeObjTypePath,
1173
+ findObjTypePathToAnotherObjType,
1174
+
1147
1175
 
1176
+ //* use in back-end
1177
+ combineLogicalStructure,
1148
1178
  checkAndCreateBracket,
1179
+ // changeObjTypePath,
1180
+ // findObjTypePathToAnotherObjType,
1149
1181
 
1150
- changeObjTypePath,
1151
- findObjTypePathToAnotherObjType
1152
1182
  }
@@ -34,7 +34,8 @@ async function createSearchRequest(
34
34
  perParentCombinations,
35
35
  requiredDataLinkStepObjects,
36
36
  requiredDataLinkSteps,
37
- values
37
+ values,
38
+ // getSchemaFn
38
39
  ) {
39
40
  console.log('createSearchResult: ', {
40
41
  objType,
@@ -45,7 +46,8 @@ async function createSearchRequest(
45
46
  perParentCombinations,
46
47
  requiredDataLinkStepObjects,
47
48
  requiredDataLinkSteps,
48
- values
49
+ values,
50
+ // getSchemaFn
49
51
  });
50
52
 
51
53
  let filterElements = {};
@@ -61,6 +63,7 @@ async function createSearchRequest(
61
63
  requiredDataLinkStepObjects,
62
64
  requiredDataLinkSteps,
63
65
  values,
66
+ // getSchemaFn
64
67
  );
65
68
 
66
69
  //* create complexFilter normalize to send backend
@@ -162,7 +165,8 @@ async function createSortRequest(
162
165
  requiredDataLinkStepObjects,
163
166
  requiredDataLinkSteps,
164
167
  sortFields,
165
- values
168
+ values,
169
+ // getSchemaFn
166
170
  ) {
167
171
  console.log('createSortResult: ', {
168
172
  objType,
@@ -174,7 +178,8 @@ async function createSortRequest(
174
178
  requiredDataLinkStepObjects,
175
179
  requiredDataLinkSteps,
176
180
  sortFields,
177
- values
181
+ values,
182
+ // getSchemaFn
178
183
  });
179
184
 
180
185
  let sortFieldMain = []
@@ -217,7 +222,8 @@ async function createSortRequest(
217
222
  perParentCombinations,
218
223
  requiredDataLinkStepObjects,
219
224
  requiredDataLinkSteps,
220
- values
225
+ values,
226
+ // getSchemaFn
221
227
  );
222
228
  console.log('SearchResultRequest: ', {
223
229
  searchResultRequest,
@@ -268,4 +274,9 @@ export default {
268
274
  //* create request to backend to sort and search
269
275
  createSearchRequest,
270
276
  createSortRequest
271
- }
277
+ }
278
+
279
+
280
+ // getSchemaFn = {
281
+
282
+ // }