@izara_project/izara-core-library-service-schemas 1.0.78 → 1.0.79
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 +5 -5
- package/src/GetObjectSchema.js +37 -44
- package/src/IdentifiersObject.js +8 -8
- package/src/ServiceConfig.js +3 -5
- package/src/SharedUtils.js +4 -4
- package/src/UploadObjSchema.js +17 -22
- package/src/ValidatorSchema.js +27 -31
- package/src/libs/CreateNodeLib.js +6 -7
- package/src/libs/DeliminatorTree.js +11 -12
- package/src/libs/ExplodedReqParams.js +5 -6
- package/src/libs/RelSchemaLib.js +3 -4
- package/src/libs/s3Utils.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-library-service-schemas",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.79",
|
|
4
4
|
"description": "Schemas for the service and objects it controls",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"testEnvironment": "node"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/client-api-gateway": "^3.
|
|
24
|
-
"@aws-sdk/client-lambda": "^3.
|
|
25
|
-
"@aws-sdk/client-s3": "^3.
|
|
26
|
-
"@aws-sdk/crc64-nvme-crt": "^3.
|
|
23
|
+
"@aws-sdk/client-api-gateway": "^3.848.0",
|
|
24
|
+
"@aws-sdk/client-lambda": "^3.848.0",
|
|
25
|
+
"@aws-sdk/client-s3": "^3.848.0",
|
|
26
|
+
"@aws-sdk/crc64-nvme-crt": "^3.848.0",
|
|
27
27
|
"@izara_project/izara-core-library-core": "^1.0.19",
|
|
28
28
|
"@izara_project/izara-core-library-external-request": "^1.0.20",
|
|
29
29
|
"@izara_project/izara-core-library-lambda": "^1.0.4",
|
package/src/GetObjectSchema.js
CHANGED
|
@@ -61,7 +61,6 @@ const { getObjectS3, headObjectS3, getSchemaByNameWithCache, getSchemaByName } =
|
|
|
61
61
|
const { generateObjectSchemaForCombineFieldNames } = require("./libs/UploadUseCase");
|
|
62
62
|
|
|
63
63
|
const {
|
|
64
|
-
OBJECT_SCHEMA_BUCKET_NAME,
|
|
65
64
|
LOCAL_OBJECT_SCHEMA_PATH,
|
|
66
65
|
|
|
67
66
|
UPLOAD_PATH_S3,
|
|
@@ -470,11 +469,10 @@ async function getLambdaFunctionNames(_izContext) {
|
|
|
470
469
|
async function getObjSchemaS3(
|
|
471
470
|
_izContext,
|
|
472
471
|
objType,
|
|
473
|
-
bucketName = OBJECT_SCHEMA_BUCKET_NAME,
|
|
474
472
|
getExtendObType = false
|
|
475
473
|
) {
|
|
476
474
|
|
|
477
|
-
return await getObjectSchemaS3Shared(getSchemaByNameWithCache, objType,
|
|
475
|
+
return await getObjectSchemaS3Shared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName, getExtendObType).then(res => {
|
|
478
476
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
479
477
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
480
478
|
} else {
|
|
@@ -494,7 +492,7 @@ const getObjSchemaS3WithCache = inMemoryCacheLib(
|
|
|
494
492
|
{ // setting
|
|
495
493
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getObjSchemaS3',
|
|
496
494
|
normalizer: function (args) {
|
|
497
|
-
return hash([args[1], args[2]
|
|
495
|
+
return hash([args[1], args[2]])
|
|
498
496
|
}
|
|
499
497
|
}
|
|
500
498
|
)
|
|
@@ -506,9 +504,9 @@ const getObjSchemaS3WithCache = inMemoryCacheLib(
|
|
|
506
504
|
* @see {@link getObjSchemaS3WithCache}
|
|
507
505
|
*
|
|
508
506
|
*/
|
|
509
|
-
async function getObjSchemaS3WithHierarchy(_izContext, objType
|
|
507
|
+
async function getObjSchemaS3WithHierarchy(_izContext, objType) {
|
|
510
508
|
// return await getObjSchemaS3WithCache(_izContext, objType, true)
|
|
511
|
-
return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType,
|
|
509
|
+
return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName).then(res => {
|
|
512
510
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
513
511
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
514
512
|
} else {
|
|
@@ -523,9 +521,9 @@ async function getObjSchemaS3WithHierarchy(_izContext, objType, bucketName = OBJ
|
|
|
523
521
|
* @see {@link getObjSchemaS3}
|
|
524
522
|
* @see {@link getObjSchemaS3WithCache}
|
|
525
523
|
*/
|
|
526
|
-
async function getObjSchemaS3WithoutHierarchy(_izContext, objType
|
|
524
|
+
async function getObjSchemaS3WithoutHierarchy(_izContext, objType) {
|
|
527
525
|
// return await getObjSchemaS3WithCache(_izContext, objType, false)
|
|
528
|
-
return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType,
|
|
526
|
+
return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName).then(res => {
|
|
529
527
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
530
528
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
531
529
|
} else {
|
|
@@ -544,9 +542,9 @@ async function getObjSchemaS3WithoutHierarchy(_izContext, objType, bucketName =
|
|
|
544
542
|
* @param {String} objType.objectType
|
|
545
543
|
* @return {Promise<Object>} - object schema for graph handler
|
|
546
544
|
*/
|
|
547
|
-
async function getObjectSchemaCombineFieldNames(_izContext, objType
|
|
545
|
+
async function getObjectSchemaCombineFieldNames(_izContext, objType) {
|
|
548
546
|
|
|
549
|
-
const objSchema = await getObjSchemaS3WithHierarchy(_izContext, objType
|
|
547
|
+
const objSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
550
548
|
const combinedSchema = generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
|
|
551
549
|
return combinedSchema
|
|
552
550
|
}
|
|
@@ -561,7 +559,7 @@ const getObjectSchemaCombineFieldNamesWithCache = inMemoryCacheLib(
|
|
|
561
559
|
{ // setting
|
|
562
560
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getObjectSchemaCombineFieldNames',
|
|
563
561
|
normalizer: function (args) {
|
|
564
|
-
return hash([args[1]
|
|
562
|
+
return hash([args[1]])
|
|
565
563
|
}
|
|
566
564
|
}
|
|
567
565
|
);
|
|
@@ -641,8 +639,8 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
|
|
|
641
639
|
* @param {String} objType.serviceTag
|
|
642
640
|
* @returns {Promise<Object>} - reference relationship schema of objType
|
|
643
641
|
*/
|
|
644
|
-
async function getRefObjectRelationship(_izContext, objType
|
|
645
|
-
return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType,
|
|
642
|
+
async function getRefObjectRelationship(_izContext, objType) {
|
|
643
|
+
return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName).then(res => {
|
|
646
644
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
647
645
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
648
646
|
} else {
|
|
@@ -661,7 +659,7 @@ const getRefObjectRelationshipWithCache = inMemoryCacheLib(
|
|
|
661
659
|
{ // setting
|
|
662
660
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getRefObjectRelationship',
|
|
663
661
|
normalizer: function (args) {
|
|
664
|
-
return hash([args[1]]
|
|
662
|
+
return hash([args[1]]);
|
|
665
663
|
}
|
|
666
664
|
}
|
|
667
665
|
);
|
|
@@ -676,8 +674,8 @@ const getRefObjectRelationshipWithCache = inMemoryCacheLib(
|
|
|
676
674
|
* @returns {Promise<{item:object|null,location:string|null}>} - item: relationship data, location: actual serviceTag that relationship located
|
|
677
675
|
*
|
|
678
676
|
*/
|
|
679
|
-
async function getRelationshipSchema(_izContext, relType
|
|
680
|
-
return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType,
|
|
677
|
+
async function getRelationshipSchema(_izContext, relType) {
|
|
678
|
+
return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType, process.env.iz_serviceSchemaBucketName).then(res => {
|
|
681
679
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
682
680
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
683
681
|
} else {
|
|
@@ -697,7 +695,7 @@ const getRelationshipSchemaWithCache = inMemoryCacheLib(
|
|
|
697
695
|
{ // setting
|
|
698
696
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getRelationshipSchema',
|
|
699
697
|
normalizer: function (args) {
|
|
700
|
-
return hash([args[1]
|
|
698
|
+
return hash([args[1]])
|
|
701
699
|
}
|
|
702
700
|
}
|
|
703
701
|
);
|
|
@@ -714,7 +712,7 @@ const getRelationshipSchemaWithCache = inMemoryCacheLib(
|
|
|
714
712
|
* @returns {Promise<{item:object|null,location:string|null}>} - item: relationship data, location: actual serviceTag that relationship located
|
|
715
713
|
*
|
|
716
714
|
*/
|
|
717
|
-
async function getRelationshipServiceTag(_izContext, relationshipTag, objType
|
|
715
|
+
async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
|
|
718
716
|
_izContext.logger.debug("getRelationshipServiceTag: ", {
|
|
719
717
|
relationshipTag,
|
|
720
718
|
objType,
|
|
@@ -734,7 +732,7 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType, b
|
|
|
734
732
|
}
|
|
735
733
|
);
|
|
736
734
|
|
|
737
|
-
let relSchemaHeadData = await headObjectS3(_izContext, { Bucket:
|
|
735
|
+
let relSchemaHeadData = await headObjectS3(_izContext, { Bucket: process.env.iz_serviceSchemaBucketName, Key: relTagPath })
|
|
738
736
|
|
|
739
737
|
// _izContext.logger.debug("relSchemaHeadData: ", relSchemaHeadData);
|
|
740
738
|
|
|
@@ -743,7 +741,7 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType, b
|
|
|
743
741
|
return objType.serviceTag;
|
|
744
742
|
} else {
|
|
745
743
|
// const refObjRel = await getRefObjectRelationship(_izContext, objType);
|
|
746
|
-
const getRefObjRelWithCacheResult = await getRefObjectRelationshipWithCache(_izContext, objType
|
|
744
|
+
const getRefObjRelWithCacheResult = await getRefObjectRelationshipWithCache(_izContext, objType);
|
|
747
745
|
const refObjRel = getRefObjRelWithCacheResult.records;
|
|
748
746
|
if (refObjRel.hasOwnProperty(relationshipTag)) {
|
|
749
747
|
return refObjRel[relationshipTag].relationshipServiceTag
|
|
@@ -764,7 +762,7 @@ const getRelationshipServiceTagWithCache = inMemoryCacheLib(
|
|
|
764
762
|
{ // setting
|
|
765
763
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getRelationshipServiceTag',
|
|
766
764
|
normalizer: function (args) {
|
|
767
|
-
return hash([args[1], args[2]
|
|
765
|
+
return hash([args[1], args[2]])
|
|
768
766
|
}
|
|
769
767
|
}
|
|
770
768
|
);
|
|
@@ -788,10 +786,9 @@ async function getObjectRelationship(
|
|
|
788
786
|
objType,
|
|
789
787
|
specificRelTags,
|
|
790
788
|
overWriteBaseObjType,
|
|
791
|
-
bucketName = OBJECT_SCHEMA_BUCKET_NAME
|
|
792
789
|
) {
|
|
793
790
|
|
|
794
|
-
return await getObjectRelationshipShared(getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType,
|
|
791
|
+
return await getObjectRelationshipShared(getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType, process.env.iz_serviceSchemaBucketName).then(res => {
|
|
795
792
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
796
793
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
797
794
|
} else {
|
|
@@ -834,7 +831,6 @@ async function getRequiredOnCreateLinks(
|
|
|
834
831
|
_izContext,
|
|
835
832
|
objType,
|
|
836
833
|
specificRelTags,
|
|
837
|
-
bucketName = OBJECT_SCHEMA_BUCKET_NAME,
|
|
838
834
|
) {
|
|
839
835
|
|
|
840
836
|
_izContext.logger.debug("Function getRequiredOnCreateLinks: ", {
|
|
@@ -842,7 +838,7 @@ async function getRequiredOnCreateLinks(
|
|
|
842
838
|
specificRelTags,
|
|
843
839
|
});
|
|
844
840
|
|
|
845
|
-
return await getRequiredOnCreateLinksShared(getSchemaByNameWithCache, objType, specificRelTags,
|
|
841
|
+
return await getRequiredOnCreateLinksShared(getSchemaByNameWithCache, objType, specificRelTags, process.env.iz_serviceSchemaBucketName).then(res => {
|
|
846
842
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
847
843
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
848
844
|
} else {
|
|
@@ -862,7 +858,7 @@ const getRequiredOnCreateLinksWithCache = inMemoryCacheLib(
|
|
|
862
858
|
{ // setting
|
|
863
859
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getRequiredOnCreateLinks',
|
|
864
860
|
normalizer: function (args) {
|
|
865
|
-
return hash([args[1], args[2]
|
|
861
|
+
return hash([args[1], args[2]])
|
|
866
862
|
}
|
|
867
863
|
}
|
|
868
864
|
);
|
|
@@ -879,17 +875,16 @@ const getRequiredOnCreateLinksWithCache = inMemoryCacheLib(
|
|
|
879
875
|
* @param {String} relationshipTag
|
|
880
876
|
* @returns {Promise<{from:Object, to:Object}>}
|
|
881
877
|
*/
|
|
882
|
-
async function getLinkConfig(_izContext, firstObjType, secondObjType, relType, direction, settings = {}
|
|
878
|
+
async function getLinkConfig(_izContext, firstObjType, secondObjType, relType, direction, settings = {}) {
|
|
883
879
|
_izContext.logger.debug("getLinkConfig: ", {
|
|
884
880
|
firstObjType,
|
|
885
881
|
secondObjType,
|
|
886
882
|
relType,
|
|
887
883
|
direction,
|
|
888
884
|
settings,
|
|
889
|
-
bucketName,
|
|
890
885
|
});
|
|
891
886
|
|
|
892
|
-
return await getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings,
|
|
887
|
+
return await getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings, process.env.iz_serviceSchemaBucketName);
|
|
893
888
|
}
|
|
894
889
|
|
|
895
890
|
/**
|
|
@@ -916,7 +911,7 @@ const getLinkConfigWithCache = inMemoryCacheLib(
|
|
|
916
911
|
* @param {String} relType.relationshipTag
|
|
917
912
|
* @returns {Promise<{from:Object, to:Object}>}
|
|
918
913
|
*/
|
|
919
|
-
async function getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings = {}
|
|
914
|
+
async function getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings = {}) {
|
|
920
915
|
|
|
921
916
|
_izContext.logger.debug("getLinkConfigByLinkTypeId: ", {
|
|
922
917
|
firstObjType,
|
|
@@ -924,10 +919,9 @@ async function getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType
|
|
|
924
919
|
relType,
|
|
925
920
|
direction,
|
|
926
921
|
settings,
|
|
927
|
-
bucketName
|
|
928
922
|
});
|
|
929
923
|
|
|
930
|
-
return await getLinkConfigByLinkTypeIdShared(getSchemaByNameWithCache, firstObjType, secondObjType, relType, direction, settings,
|
|
924
|
+
return await getLinkConfigByLinkTypeIdShared(getSchemaByNameWithCache, firstObjType, secondObjType, relType, direction, settings, process.env.iz_serviceSchemaBucketName).then(res => {
|
|
931
925
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
932
926
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
933
927
|
} else {
|
|
@@ -946,7 +940,7 @@ const getLinkConfigByLinkTypeIdWithCache = inMemoryCacheLib(
|
|
|
946
940
|
{ // setting
|
|
947
941
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getLinkConfigByLinkTypeId',
|
|
948
942
|
normalizer: function (args) {
|
|
949
|
-
return hash([args[1], args[2], args[3], args[4]
|
|
943
|
+
return hash([args[1], args[2], args[3], args[4]]);
|
|
950
944
|
}
|
|
951
945
|
}
|
|
952
946
|
);
|
|
@@ -963,8 +957,8 @@ const getLinkConfigByLinkTypeIdWithCache = inMemoryCacheLib(
|
|
|
963
957
|
* @param {object} objectSchema
|
|
964
958
|
* @returns
|
|
965
959
|
*/
|
|
966
|
-
async function mergeExtendObjSchema(_izContext, objectSchema
|
|
967
|
-
let mergedObjectSchema = await mergeExtendObjSchemaShared(getSchemaByNameWithCache, objectSchema,
|
|
960
|
+
async function mergeExtendObjSchema(_izContext, objectSchema) {
|
|
961
|
+
let mergedObjectSchema = await mergeExtendObjSchemaShared(getSchemaByNameWithCache, objectSchema, process.env.iz_serviceSchemaBucketName).then(res => {
|
|
968
962
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
969
963
|
throw new NoRetryError(`objectSchema.objectType: ${objectSchema.objectType} ${res.errorsFound}`)
|
|
970
964
|
} else {
|
|
@@ -1053,10 +1047,9 @@ async function getLocalFlowSchemas(_izContext, flowTags, flowSchemaPath = LOCAL_
|
|
|
1053
1047
|
async function getFlowSchemaS3(
|
|
1054
1048
|
_izContext,
|
|
1055
1049
|
flowType,
|
|
1056
|
-
bucketName = OBJECT_SCHEMA_BUCKET_NAME
|
|
1057
1050
|
) {
|
|
1058
1051
|
|
|
1059
|
-
return await getFlowSchemaS3Shared(getSchemaByNameWithCache, flowType,
|
|
1052
|
+
return await getFlowSchemaS3Shared(getSchemaByNameWithCache, flowType, process.env.iz_serviceSchemaBucketName).then(res => {
|
|
1060
1053
|
if (res.errorsFound.length) {
|
|
1061
1054
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
1062
1055
|
} else {
|
|
@@ -1075,7 +1068,7 @@ const getFlowSchemaS3WithCache = inMemoryCacheLib(
|
|
|
1075
1068
|
{ //setting
|
|
1076
1069
|
max: 100, maxAge: 8640000, promise: true, profileName: 'getFlowSchemaS3',
|
|
1077
1070
|
normalizer: function (args) {
|
|
1078
|
-
return hash([args[1]
|
|
1071
|
+
return hash([args[1]])
|
|
1079
1072
|
}
|
|
1080
1073
|
}
|
|
1081
1074
|
)
|
|
@@ -1108,8 +1101,8 @@ function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = LOCA
|
|
|
1108
1101
|
* @param {number} iter
|
|
1109
1102
|
* @returns
|
|
1110
1103
|
*/
|
|
1111
|
-
async function getObjTypeHierarchy(_izContext, objType
|
|
1112
|
-
return await getObjTypeHierarchyShared(getSchemaByNameWithCache, objType, objType,
|
|
1104
|
+
async function getObjTypeHierarchy(_izContext, objType) {
|
|
1105
|
+
return await getObjTypeHierarchyShared(getSchemaByNameWithCache, objType, objType, process.env.iz_serviceSchemaBucketName);
|
|
1113
1106
|
}
|
|
1114
1107
|
|
|
1115
1108
|
/**
|
|
@@ -1127,12 +1120,12 @@ const getObjTypeHierarchyWithCache = inMemoryCacheLib(
|
|
|
1127
1120
|
}
|
|
1128
1121
|
)
|
|
1129
1122
|
|
|
1130
|
-
async function getObjectSchemaForCreate(_izContext, objType
|
|
1131
|
-
return await getObjectSchemaForCreateShared(getSchemaByNameWithCache, objType,
|
|
1123
|
+
async function getObjectSchemaForCreate(_izContext, objType) {
|
|
1124
|
+
return await getObjectSchemaForCreateShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
|
|
1132
1125
|
}
|
|
1133
1126
|
|
|
1134
|
-
async function getObjectSchemaForUpdate(_izContext, objType
|
|
1135
|
-
return await getObjectSchemaForUpdateShared(getSchemaByNameWithCache, objType,
|
|
1127
|
+
async function getObjectSchemaForUpdate(_izContext, objType) {
|
|
1128
|
+
return await getObjectSchemaForUpdateShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
|
|
1136
1129
|
}
|
|
1137
1130
|
|
|
1138
1131
|
module.exports = {
|
package/src/IdentifiersObject.js
CHANGED
|
@@ -23,7 +23,7 @@ const { validateObjType } = require('@izara_project/izara-shared-service-schemas
|
|
|
23
23
|
const deliminatorTree = require('./libs/DeliminatorTree');
|
|
24
24
|
const getSchema = require('./GetObjectSchema')
|
|
25
25
|
const { getUsedFieldNamesOfIdentifiers } = require('./Utils');
|
|
26
|
-
const { STORAGE_TYPES, STORAGE_IDENTIFIER_TYPES, DEFAULT_IDENTIFIER_DELIMINATOR
|
|
26
|
+
const { STORAGE_TYPES, STORAGE_IDENTIFIER_TYPES, DEFAULT_IDENTIFIER_DELIMINATOR } = require('./Consts');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -58,7 +58,7 @@ function checkStorageTypeOfObjectSchemaIdentifiers(_izContext, objectSchema) {
|
|
|
58
58
|
* @param {Object} objInstanceBase
|
|
59
59
|
* @returns {Promise<Object>} - identifiersObject
|
|
60
60
|
*/
|
|
61
|
-
async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBase, bucketName =
|
|
61
|
+
async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBase, bucketName = process.env.iz_serviceSchemaBucketName) {
|
|
62
62
|
const validateObjTypeResult = validateObjType(objType);
|
|
63
63
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
64
64
|
_izContext.logger.error("identifiersObjectFromBaseObjInstance: Invalid objType: ", validateObjTypeResult.errorsFound);
|
|
@@ -144,7 +144,7 @@ async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBa
|
|
|
144
144
|
* @param {Object} identifiers
|
|
145
145
|
* @returns {Promise<Object>} - concatIdentifiersObject
|
|
146
146
|
*/
|
|
147
|
-
async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers, bucketName =
|
|
147
|
+
async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers, bucketName = process.env.iz_serviceSchemaBucketName) {
|
|
148
148
|
const validateObjTypeResult = validateObjType(objType);
|
|
149
149
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
150
150
|
_izContext.logger.error("identifiersBaseFromIdentifiers: Invalid objType: ", validateObjTypeResult.errorsFound);
|
|
@@ -200,7 +200,7 @@ async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers,
|
|
|
200
200
|
* @param {Object} objInstance
|
|
201
201
|
* @returns {Promise<Object>} - refactoredObjInstance
|
|
202
202
|
*/
|
|
203
|
-
async function objInstanceFromObjInstanceBase(_izContext, objType, objInstance, bucketName =
|
|
203
|
+
async function objInstanceFromObjInstanceBase(_izContext, objType, objInstance, bucketName = process.env.iz_serviceSchemaBucketName) {
|
|
204
204
|
const validateObjTypeResult = validateObjType(objType);
|
|
205
205
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
206
206
|
_izContext.logger.error("objInstanceFromObjInstanceBase: Invalid objType: ", validateObjTypeResult.errorsFound);
|
|
@@ -235,7 +235,7 @@ async function objInstanceFromObjInstanceBase(_izContext, objType, objInstance,
|
|
|
235
235
|
* @param {Object} identifiers
|
|
236
236
|
* @returns {Promise<String>} - compositeIdentifier
|
|
237
237
|
*/
|
|
238
|
-
async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers, bucketName =
|
|
238
|
+
async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers, bucketName = process.env.iz_serviceSchemaBucketName) {
|
|
239
239
|
const validateObjTypeResult = validateObjType(objType);
|
|
240
240
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
241
241
|
_izContext.logger.error("compositeIdentifierFromIdentifiersObject: Invalid objType: ", validateObjTypeResult.errorsFound);
|
|
@@ -333,7 +333,7 @@ async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers
|
|
|
333
333
|
* @param {String} identifiersConcat
|
|
334
334
|
* @returns {Promise<Object>} - identifiersObject
|
|
335
335
|
*/
|
|
336
|
-
async function identifiersFromIdentifiersConcat(_izContext, objType, identifiersConcat, bucketName =
|
|
336
|
+
async function identifiersFromIdentifiersConcat(_izContext, objType, identifiersConcat, bucketName = process.env.iz_serviceSchemaBucketName) {
|
|
337
337
|
const validateObjTypeResult = validateObjType(objType);
|
|
338
338
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
339
339
|
_izContext.logger.error("identifiersObjectFromCompositeIdentifier: Invalid objType: ", validateObjTypeResult.errorsFound);
|
|
@@ -431,7 +431,7 @@ async function createNestedIdentifiersConcat(
|
|
|
431
431
|
_izContext,
|
|
432
432
|
objType,
|
|
433
433
|
identifiersConcat,
|
|
434
|
-
bucketName =
|
|
434
|
+
bucketName = process.env.iz_serviceSchemaBucketName,
|
|
435
435
|
prefixes = [],
|
|
436
436
|
suffixes = [],
|
|
437
437
|
level = 1,
|
|
@@ -476,7 +476,7 @@ async function explodedNestedIdentifiersConcat(
|
|
|
476
476
|
_izContext,
|
|
477
477
|
objType,
|
|
478
478
|
concatIdentifier,
|
|
479
|
-
bucketName =
|
|
479
|
+
bucketName = process.env.iz_serviceSchemaBucketName,
|
|
480
480
|
level = 1,
|
|
481
481
|
deliminator = DEFAULT_IDENTIFIER_DELIMINATOR,
|
|
482
482
|
) {
|
package/src/ServiceConfig.js
CHANGED
|
@@ -37,13 +37,12 @@ const { getObjectS3 } = require("./libs/s3Utils")
|
|
|
37
37
|
*/
|
|
38
38
|
async function getServiceName(
|
|
39
39
|
_izContext,
|
|
40
|
-
serviceTag
|
|
41
|
-
bucketName
|
|
40
|
+
serviceTag
|
|
42
41
|
) {
|
|
43
42
|
_izContext.logger.debug("getServiceName: ", serviceTag)
|
|
44
43
|
|
|
45
44
|
const getObjectParam = {
|
|
46
|
-
Bucket:
|
|
45
|
+
Bucket: process.env.iz_serviceSchemaBucketName,
|
|
47
46
|
Key: UPLOAD_PATH_S3.serviceName(_izContext, serviceTag),
|
|
48
47
|
};
|
|
49
48
|
_izContext.logger.debug("getObjectParam", getObjectParam)
|
|
@@ -83,14 +82,13 @@ const getServiceNameWithCache = inMemoryCacheLib(
|
|
|
83
82
|
async function getGraphServiceTag(
|
|
84
83
|
_izContext,
|
|
85
84
|
graphServerTag,
|
|
86
|
-
bucketName
|
|
87
85
|
) {
|
|
88
86
|
|
|
89
87
|
// get all graph serverTag
|
|
90
88
|
let [serverTags] = await getObjectS3(
|
|
91
89
|
_izContext,
|
|
92
90
|
{
|
|
93
|
-
Bucket:
|
|
91
|
+
Bucket: process.env.iz_serviceSchemaBucketName,
|
|
94
92
|
Key: UPLOAD_PATH_S3.graphServerTagsConfig
|
|
95
93
|
}
|
|
96
94
|
);
|
package/src/SharedUtils.js
CHANGED
|
@@ -215,7 +215,7 @@ async function _processNodeRelationships(
|
|
|
215
215
|
* @param {number} loopSetting.depth - Current depth of recursion
|
|
216
216
|
* @returns {Promise<Object>} - Result of the processing
|
|
217
217
|
*/
|
|
218
|
-
async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinksGroup, loopSetting = { depth: 0 }
|
|
218
|
+
async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinksGroup, loopSetting = { depth: 0 }) {
|
|
219
219
|
// ** == initialize variables ==
|
|
220
220
|
const depthLimit = 4;
|
|
221
221
|
const results = [];
|
|
@@ -241,7 +241,7 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
|
|
|
241
241
|
const [relationshipSchema, rawRelationshipSchema] = await getObjectS3(
|
|
242
242
|
_izContext,
|
|
243
243
|
{
|
|
244
|
-
Bucket:
|
|
244
|
+
Bucket: process.env.iz_serviceSchemaBucketName,
|
|
245
245
|
Key: UPLOAD_PATH_S3.relationshipTag(_izContext, relType)
|
|
246
246
|
}
|
|
247
247
|
);
|
|
@@ -283,8 +283,8 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
|
|
|
283
283
|
_izContext.logger.debug('createObjectRelationshipConfig:', createObjectRelationshipConfig);
|
|
284
284
|
|
|
285
285
|
// ** get object schema for firstNode and secondNode
|
|
286
|
-
let firstNodeObjSchema = await getObjSchemaS3WithCache(_izContext, firstNode.objType
|
|
287
|
-
let secondNodeObjSchema = await getObjSchemaS3WithCache(_izContext, secondNode.objType
|
|
286
|
+
let firstNodeObjSchema = await getObjSchemaS3WithCache(_izContext, firstNode.objType);
|
|
287
|
+
let secondNodeObjSchema = await getObjSchemaS3WithCache(_izContext, secondNode.objType);
|
|
288
288
|
_izContext.logger.debug(`
|
|
289
289
|
firstNodeObjSchema: ${JSON.stringify(firstNodeObjSchema, null, 2)}
|
|
290
290
|
, secondNodeObjSchema: ${JSON.stringify(secondNodeObjSchema, null, 2)}`);
|
package/src/UploadObjSchema.js
CHANGED
|
@@ -86,7 +86,6 @@ async function uploadObjectToS3(
|
|
|
86
86
|
_izContext,
|
|
87
87
|
pathToUpload,
|
|
88
88
|
objectToUpload,
|
|
89
|
-
bucketName = OBJECT_SCHEMA_BUCKET_NAME,
|
|
90
89
|
additionalOptions = {}
|
|
91
90
|
) {
|
|
92
91
|
|
|
@@ -94,7 +93,7 @@ async function uploadObjectToS3(
|
|
|
94
93
|
const Key = pathToUpload
|
|
95
94
|
|
|
96
95
|
let data = {
|
|
97
|
-
Bucket:
|
|
96
|
+
Bucket: process.env.iz_serviceSchemaBucketName,
|
|
98
97
|
Key,
|
|
99
98
|
Body: buffer,
|
|
100
99
|
ContentEncoding: 'base64',
|
|
@@ -164,7 +163,7 @@ async function emptyS3Path(
|
|
|
164
163
|
*
|
|
165
164
|
* @param {object} _izContext
|
|
166
165
|
*/
|
|
167
|
-
async function uploadObjectSchemaByUseCase(_izContext, bucketName
|
|
166
|
+
async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
168
167
|
let uploadList = [];
|
|
169
168
|
|
|
170
169
|
const objectTypesForCreate = [];
|
|
@@ -235,7 +234,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
235
234
|
// end validate all schema
|
|
236
235
|
|
|
237
236
|
// delete all file in servicePath before upload
|
|
238
|
-
await emptyS3Path(_izContext,
|
|
237
|
+
await emptyS3Path(_izContext, process.env.iz_serviceSchemaBucketName, `${PREFIX_PATH_S3.perServiceSchemas}/${process.env.iz_serviceTag}/`);
|
|
239
238
|
|
|
240
239
|
|
|
241
240
|
if (lambdaFunctions) {
|
|
@@ -244,7 +243,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
244
243
|
_izContext,
|
|
245
244
|
UPLOAD_PATH_S3.lambdaFunctions(_izContext, process.env.iz_serviceTag),
|
|
246
245
|
lambdaFunctions,
|
|
247
|
-
|
|
246
|
+
|
|
248
247
|
)
|
|
249
248
|
);
|
|
250
249
|
}
|
|
@@ -255,7 +254,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
255
254
|
_izContext,
|
|
256
255
|
UPLOAD_PATH_S3.serviceName(_izContext, process.env.iz_serviceTag),
|
|
257
256
|
{ serviceName: process.env.iz_serviceName },
|
|
258
|
-
|
|
257
|
+
|
|
259
258
|
)
|
|
260
259
|
);
|
|
261
260
|
|
|
@@ -274,7 +273,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
274
273
|
}
|
|
275
274
|
),
|
|
276
275
|
objSchema,
|
|
277
|
-
|
|
276
|
+
|
|
278
277
|
)
|
|
279
278
|
);
|
|
280
279
|
|
|
@@ -292,7 +291,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
292
291
|
}
|
|
293
292
|
),
|
|
294
293
|
createFieldSchema,
|
|
295
|
-
|
|
294
|
+
|
|
296
295
|
)
|
|
297
296
|
);
|
|
298
297
|
|
|
@@ -312,7 +311,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
312
311
|
}
|
|
313
312
|
),
|
|
314
313
|
updateFieldSchema,
|
|
315
|
-
|
|
314
|
+
|
|
316
315
|
)
|
|
317
316
|
);
|
|
318
317
|
|
|
@@ -331,7 +330,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
331
330
|
}
|
|
332
331
|
),
|
|
333
332
|
combineFieldNamesObjectSchema,
|
|
334
|
-
|
|
333
|
+
|
|
335
334
|
)
|
|
336
335
|
);
|
|
337
336
|
|
|
@@ -342,7 +341,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
342
341
|
_izContext,
|
|
343
342
|
UPLOAD_PATH_S3.getEndpointPerObjectType(_izContext, { objectType: objSchema.objectType, serviceTag: process.env.iz_serviceTag }),
|
|
344
343
|
apiLink,
|
|
345
|
-
|
|
344
|
+
|
|
346
345
|
)
|
|
347
346
|
)
|
|
348
347
|
|
|
@@ -351,7 +350,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
351
350
|
_izContext,
|
|
352
351
|
UPLOAD_PATH_S3.getEndpointPerService(process.env.iz_serviceTag),
|
|
353
352
|
apiLink,
|
|
354
|
-
|
|
353
|
+
|
|
355
354
|
)
|
|
356
355
|
)
|
|
357
356
|
|
|
@@ -370,7 +369,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
370
369
|
}
|
|
371
370
|
),
|
|
372
371
|
existsRefObjectRel,
|
|
373
|
-
|
|
372
|
+
|
|
374
373
|
)
|
|
375
374
|
)
|
|
376
375
|
} else {
|
|
@@ -390,7 +389,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
390
389
|
}
|
|
391
390
|
),
|
|
392
391
|
await refRelationshipPerObjectSchema(_izContext, objSchema),
|
|
393
|
-
|
|
392
|
+
|
|
394
393
|
)
|
|
395
394
|
)
|
|
396
395
|
}
|
|
@@ -404,7 +403,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
404
403
|
_izContext,
|
|
405
404
|
UPLOAD_PATH_S3.objectListAll(_izContext, process.env.iz_serviceTag),
|
|
406
405
|
foundedObjectTypes,
|
|
407
|
-
|
|
406
|
+
|
|
408
407
|
)
|
|
409
408
|
);
|
|
410
409
|
|
|
@@ -515,7 +514,6 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
515
514
|
relationshipServiceTag: process.env.iz_serviceTag,
|
|
516
515
|
...relTagDetail[relationshipTag],
|
|
517
516
|
},
|
|
518
|
-
bucketName
|
|
519
517
|
)
|
|
520
518
|
);
|
|
521
519
|
|
|
@@ -527,8 +525,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
527
525
|
uploadObjectToS3(
|
|
528
526
|
_izContext,
|
|
529
527
|
UPLOAD_PATH_S3.linkByLinkTypeId(_izContext, process.env.iz_serviceTag, linkTypeId),
|
|
530
|
-
link
|
|
531
|
-
bucketName
|
|
528
|
+
link
|
|
532
529
|
)
|
|
533
530
|
);
|
|
534
531
|
}
|
|
@@ -567,8 +564,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
567
564
|
uploadObjectToS3(
|
|
568
565
|
_izContext,
|
|
569
566
|
UPLOAD_PATH_S3.objectRelationship(_izContext, { serviceTag: process.env.iz_serviceTag, objectType: relObjectType }),
|
|
570
|
-
relTagsData
|
|
571
|
-
bucketName
|
|
567
|
+
relTagsData
|
|
572
568
|
)
|
|
573
569
|
);
|
|
574
570
|
}
|
|
@@ -603,8 +599,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName = OBJECT_SCHEM
|
|
|
603
599
|
flowTag: flowSchema.flowTag
|
|
604
600
|
}
|
|
605
601
|
),
|
|
606
|
-
flowSchema
|
|
607
|
-
bucketName
|
|
602
|
+
flowSchema
|
|
608
603
|
)
|
|
609
604
|
)
|
|
610
605
|
}
|
package/src/ValidatorSchema.js
CHANGED
|
@@ -77,7 +77,7 @@ const { validateObjType } = require('@izara_project/izara-shared-service-schemas
|
|
|
77
77
|
* @param {Number} iter iterate count
|
|
78
78
|
* @returns
|
|
79
79
|
*/
|
|
80
|
-
async function generateValidatorSchemaTreePerFieldName(_izContext, fieldName, fieldNameSetting,
|
|
80
|
+
async function generateValidatorSchemaTreePerFieldName(_izContext, fieldName, fieldNameSetting, iter = 0) {
|
|
81
81
|
if (iter > 50) {
|
|
82
82
|
throw new NoRetryError("generateValidatorSchemaPerFieldName reach max iteration limit")
|
|
83
83
|
} else {
|
|
@@ -105,8 +105,7 @@ async function generateValidatorSchemaTreePerFieldName(_izContext, fieldName, fi
|
|
|
105
105
|
{
|
|
106
106
|
objectType: fieldNameSetting.fromObjectType,
|
|
107
107
|
serviceTag: fieldNameSetting.fromServiceNameTag
|
|
108
|
-
}
|
|
109
|
-
bucketName
|
|
108
|
+
}
|
|
110
109
|
);
|
|
111
110
|
|
|
112
111
|
if (!childObjectSchema) {
|
|
@@ -131,7 +130,6 @@ async function generateValidatorSchemaTreePerFieldName(_izContext, fieldName, fi
|
|
|
131
130
|
{ logger: Logger },
|
|
132
131
|
eachKey, // fieldName
|
|
133
132
|
childObjectSchema.fieldNames[eachKey], // fieldName setting
|
|
134
|
-
bucketName,
|
|
135
133
|
iter
|
|
136
134
|
);
|
|
137
135
|
|
|
@@ -155,7 +153,7 @@ async function generateValidatorSchemaTreePerFieldName(_izContext, fieldName, fi
|
|
|
155
153
|
return validatorTree;
|
|
156
154
|
}
|
|
157
155
|
|
|
158
|
-
async function validatorSchemaTreeIdentifiers(_izContext, objectSchema,
|
|
156
|
+
async function validatorSchemaTreeIdentifiers(_izContext, objectSchema, iter = 0) {
|
|
159
157
|
if (iter > 50) {
|
|
160
158
|
throw new NoRetryError("generateValidatorSchemaPerFieldName reach max iteration limit")
|
|
161
159
|
} else {
|
|
@@ -185,7 +183,7 @@ async function validatorSchemaTreeIdentifiers(_izContext, objectSchema, bucketNa
|
|
|
185
183
|
Object.assign(validatorSchemaTree, { [identifierName]: allValidatorTreeCompositeKey });
|
|
186
184
|
|
|
187
185
|
} else {
|
|
188
|
-
let validatorTreeIdentifier = await generateValidatorSchemaTreePerFieldName(_izContext, identifierName, objectSchema.fieldNames[identifierName]
|
|
186
|
+
let validatorTreeIdentifier = await generateValidatorSchemaTreePerFieldName(_izContext, identifierName, objectSchema.fieldNames[identifierName])
|
|
189
187
|
_izContext.logger.debug("validatorTreeIdentifier: ", JSON.stringify(validatorTreeIdentifier))
|
|
190
188
|
|
|
191
189
|
Object.assign(validatorSchemaTree, validatorTreeIdentifier);
|
|
@@ -199,7 +197,7 @@ async function validatorSchemaTreeIdentifiers(_izContext, objectSchema, bucketNa
|
|
|
199
197
|
}
|
|
200
198
|
|
|
201
199
|
|
|
202
|
-
async function validatorSchemaTreeIdentifiersFieldNames(_izContext, objectSchema,
|
|
200
|
+
async function validatorSchemaTreeIdentifiersFieldNames(_izContext, objectSchema, iter = 0) {
|
|
203
201
|
if (iter > 50) {
|
|
204
202
|
throw new NoRetryError("generateValidatorSchemaPerFieldName reach max iteration limit")
|
|
205
203
|
} else {
|
|
@@ -218,7 +216,7 @@ async function validatorSchemaTreeIdentifiersFieldNames(_izContext, objectSchema
|
|
|
218
216
|
await Promise.all(
|
|
219
217
|
identifierFieldNames.map(
|
|
220
218
|
async (identifierFieldName) => {
|
|
221
|
-
let validatorTreeIdentifierFieldName = await generateValidatorSchemaTreePerFieldName(_izContext, identifierFieldName, objectSchema.fieldNames[identifierFieldName]
|
|
219
|
+
let validatorTreeIdentifierFieldName = await generateValidatorSchemaTreePerFieldName(_izContext, identifierFieldName, objectSchema.fieldNames[identifierFieldName]);
|
|
222
220
|
_izContext.logger.debug("validatorTreeIdentifierFieldName: ", validatorTreeIdentifierFieldName);
|
|
223
221
|
|
|
224
222
|
Object.assign(validatorSchemaTree, validatorTreeIdentifierFieldName);
|
|
@@ -243,7 +241,7 @@ async function validatorSchemaTreeIdentifiersFieldNames(_izContext, objectSchema
|
|
|
243
241
|
* @param {String} objType.objectType
|
|
244
242
|
* @param {String} objType.serviceTag
|
|
245
243
|
*/
|
|
246
|
-
async function generateRelationshipValidatorSchemaForCreate(_izContext, objType
|
|
244
|
+
async function generateRelationshipValidatorSchemaForCreate(_izContext, objType) {
|
|
247
245
|
const validateObjTypeResult = validateObjType(objType);
|
|
248
246
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
249
247
|
_izContext.logger.error("generateRelationshipValidatorSchemaForCreate validateObjTypeResult", validateObjTypeResult);
|
|
@@ -300,7 +298,7 @@ async function generateRelationshipValidatorSchemaForCreate(_izContext, objType,
|
|
|
300
298
|
&& parent.linkConfig.requiredOnCreate === true
|
|
301
299
|
) {
|
|
302
300
|
|
|
303
|
-
let parentObjSchema = await getObjSchemaS3WithHierarchy(_izContext, parent.objType
|
|
301
|
+
let parentObjSchema = await getObjSchemaS3WithHierarchy(_izContext, parent.objType);
|
|
304
302
|
|
|
305
303
|
if (!parentObjSchema) {
|
|
306
304
|
throw new NoRetryError(`Not found parent ${JSON.stringify(parent.objType)} in relationship:${relTag}`);
|
|
@@ -380,7 +378,7 @@ async function generateRelationshipValidatorSchemaForCreate(_izContext, objType,
|
|
|
380
378
|
* @param {String[]} specificFieldNames
|
|
381
379
|
* @returns
|
|
382
380
|
*/
|
|
383
|
-
async function generateValidatorSchemaForCreate(_izContext, objType, settings = { specificFieldNames: []
|
|
381
|
+
async function generateValidatorSchemaForCreate(_izContext, objType, settings = { specificFieldNames: [] }) {
|
|
384
382
|
const validateObjTypeResult = validateObjType(objType);
|
|
385
383
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
386
384
|
_izContext.logger.error("generateValidatorSchemaForCreate validateObjTypeResult", validateObjTypeResult);
|
|
@@ -391,7 +389,7 @@ async function generateValidatorSchemaForCreate(_izContext, objType, settings =
|
|
|
391
389
|
specificFieldNames: settings.specificFieldNames
|
|
392
390
|
})
|
|
393
391
|
|
|
394
|
-
const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType
|
|
392
|
+
const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
395
393
|
_izContext.logger.debug("objectSchema in generateValidatorSchemaForCreate", objectSchema)
|
|
396
394
|
let usedFieldNamesData = {};
|
|
397
395
|
let requiredFieldNames = [];
|
|
@@ -457,7 +455,6 @@ async function generateValidatorSchemaForCreate(_izContext, objType, settings =
|
|
|
457
455
|
_izContext,
|
|
458
456
|
fieldName,
|
|
459
457
|
usedFieldNamesData[fieldName],
|
|
460
|
-
settings.bucketName
|
|
461
458
|
);
|
|
462
459
|
|
|
463
460
|
Object.assign(allValidatorSchemaFieldNames, validatorSchemaFieldName);
|
|
@@ -501,14 +498,14 @@ async function generateValidatorSchemaForCreate(_izContext, objType, settings =
|
|
|
501
498
|
should require name of identifier instead of fieldName that part of identifiers
|
|
502
499
|
Note : should add setting for api in this function
|
|
503
500
|
*/
|
|
504
|
-
async function generateValidatorSchemaForUpdate(_izContext, objType, settings = { specificFieldNames: []
|
|
501
|
+
async function generateValidatorSchemaForUpdate(_izContext, objType, settings = { specificFieldNames: [] }) {
|
|
505
502
|
|
|
506
503
|
_izContext.logger.debug("Function:generateValidatorSchemaForUpdate2 ", {
|
|
507
504
|
objType,
|
|
508
505
|
setting: settings,
|
|
509
506
|
})
|
|
510
507
|
// const objType = createObjType(objectType);
|
|
511
|
-
const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType
|
|
508
|
+
const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
512
509
|
_izContext.logger.debug("objectSchema", objectSchema)
|
|
513
510
|
|
|
514
511
|
const objectSchemas = await uploadUseCase.generateObjectSchemaForCombineFieldNames(_izContext, objectSchema)
|
|
@@ -667,7 +664,7 @@ async function generateValidatorSchemaForIdentifier(_izContext, objType, setting
|
|
|
667
664
|
* @param {string[]} usedFieldNames
|
|
668
665
|
* @returns
|
|
669
666
|
*/
|
|
670
|
-
async function filteredFieldNamesOfValidatorSchema(_izContext, objType, requiredFieldNames, usedFieldNames
|
|
667
|
+
async function filteredFieldNamesOfValidatorSchema(_izContext, objType, requiredFieldNames, usedFieldNames) {
|
|
671
668
|
const validateObjTypeResult = validateObjType(objType);
|
|
672
669
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
673
670
|
_izContext.logger.error("filteredFieldNamesOfValidatorSchema validateObjTypeResult", validateObjTypeResult);
|
|
@@ -679,7 +676,7 @@ async function filteredFieldNamesOfValidatorSchema(_izContext, objType, required
|
|
|
679
676
|
usedFieldNames
|
|
680
677
|
});
|
|
681
678
|
|
|
682
|
-
let allValidatorSchema = await generateValidatorSchemaForExplodedDataWithCache(_izContext, objType,
|
|
679
|
+
let allValidatorSchema = await generateValidatorSchemaForExplodedDataWithCache(_izContext, objType, process.env.iz_serviceSchemaBucketName);
|
|
683
680
|
_izContext.logger.debug("filteredFieldNamesOfValidatorSchema allValidatorSchema : ", allValidatorSchema)
|
|
684
681
|
|
|
685
682
|
allValidatorSchema.required = requiredFieldNames;
|
|
@@ -713,7 +710,7 @@ async function filteredFieldNamesOfValidatorSchema(_izContext, objType, required
|
|
|
713
710
|
* 2 >> create validatorSchema of fieldName and identifier
|
|
714
711
|
* 3 >> not required, Use for validate only
|
|
715
712
|
*/
|
|
716
|
-
async function generateValidatorSchemaForExplodedData(_izContext, objType
|
|
713
|
+
async function generateValidatorSchemaForExplodedData(_izContext, objType) {
|
|
717
714
|
const validateObjTypeResult = validateObjType(objType);
|
|
718
715
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
719
716
|
_izContext.logger.error("generateValidatorSchemaForExplodedData validateObjTypeResult", validateObjTypeResult);
|
|
@@ -726,10 +723,10 @@ async function generateValidatorSchemaForExplodedData(_izContext, objType, bucke
|
|
|
726
723
|
properties: {}
|
|
727
724
|
};
|
|
728
725
|
|
|
729
|
-
let objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType
|
|
726
|
+
let objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
730
727
|
// generate validatorSchema for each fieldName
|
|
731
728
|
for (let [fieldName, fieldData] of Object.entries(objectSchema.fieldNames)) {
|
|
732
|
-
let fieldNameValidator = await generateValidatorFieldNameWithCache(_izContext, fieldName, fieldData
|
|
729
|
+
let fieldNameValidator = await generateValidatorFieldNameWithCache(_izContext, fieldName, fieldData);
|
|
733
730
|
Object.assign(validatorSchema.properties, fieldNameValidator);
|
|
734
731
|
}
|
|
735
732
|
|
|
@@ -813,7 +810,7 @@ const generateValidatorFieldNameWithCache = inMemoryCacheLib(
|
|
|
813
810
|
* @param {Object} fieldData
|
|
814
811
|
* @returns
|
|
815
812
|
*/
|
|
816
|
-
async function generateValidatorFieldName(_izContext, fieldName, fieldData
|
|
813
|
+
async function generateValidatorFieldName(_izContext, fieldName, fieldData) {
|
|
817
814
|
|
|
818
815
|
if (fieldData.hasOwnProperty("fromObjectType") || fieldData.hasOwnProperty("fromServiceNameTag")) {
|
|
819
816
|
// validate reference
|
|
@@ -826,8 +823,7 @@ async function generateValidatorFieldName(_izContext, fieldName, fieldData, buck
|
|
|
826
823
|
{
|
|
827
824
|
serviceTag: fieldData.fromServiceNameTag,
|
|
828
825
|
objectType: fieldData.fromObjectType
|
|
829
|
-
}
|
|
830
|
-
bucketName
|
|
826
|
+
}
|
|
831
827
|
);
|
|
832
828
|
|
|
833
829
|
let usedIdentifier = null
|
|
@@ -858,7 +854,7 @@ async function generateValidatorFieldName(_izContext, fieldName, fieldData, buck
|
|
|
858
854
|
throw new Error(`Invalid reference fieldName:${compositeKey}`);
|
|
859
855
|
}
|
|
860
856
|
|
|
861
|
-
let childValidator = await generateValidatorFieldNameWithCache(_izContext, compositeKey, objectSchemaChild.fieldNames[compositeKey]
|
|
857
|
+
let childValidator = await generateValidatorFieldNameWithCache(_izContext, compositeKey, objectSchemaChild.fieldNames[compositeKey]);
|
|
862
858
|
|
|
863
859
|
Object.assign(returnValidator, childValidator)
|
|
864
860
|
|
|
@@ -918,10 +914,11 @@ async function generateValidatorFieldName(_izContext, fieldName, fieldData, buck
|
|
|
918
914
|
* @param {String} serviceConfigPath - path that config file of service located
|
|
919
915
|
* @returns
|
|
920
916
|
*/
|
|
921
|
-
async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath
|
|
917
|
+
async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
922
918
|
try {
|
|
923
919
|
const serviceConfig = readYamlFile.sync(serviceConfigPath);
|
|
924
920
|
const iz_serviceTag = serviceConfig.main_config.iz_serviceTag;
|
|
921
|
+
const iz_serviceSchemaBucketName = serviceConfig.main_config.iz_serviceSchemaBucketName
|
|
925
922
|
console.log("schemasPath", schemasPath);
|
|
926
923
|
console.log("serviceConfigPath", serviceConfigPath)
|
|
927
924
|
|
|
@@ -972,7 +969,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath, b
|
|
|
972
969
|
const storageResource = objSchema.storageResources[storageTag];
|
|
973
970
|
|
|
974
971
|
if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
975
|
-
const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag
|
|
972
|
+
const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag);
|
|
976
973
|
|
|
977
974
|
if (!graphServiceTag) {
|
|
978
975
|
validateStatus.status = false;
|
|
@@ -1043,7 +1040,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath, b
|
|
|
1043
1040
|
const storageResource = relData.storageResources[storageTag];
|
|
1044
1041
|
|
|
1045
1042
|
if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
1046
|
-
const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag
|
|
1043
|
+
const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag);
|
|
1047
1044
|
|
|
1048
1045
|
if (!graphServiceTag) {
|
|
1049
1046
|
validateStatus.status = false;
|
|
@@ -1126,7 +1123,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath, b
|
|
|
1126
1123
|
}
|
|
1127
1124
|
return res.records[0]
|
|
1128
1125
|
})
|
|
1129
|
-
: await getObjSchemaS3WithHierarchy(_izContext, link.from.objType
|
|
1126
|
+
: await getObjSchemaS3WithHierarchy(_izContext, link.from.objType);
|
|
1130
1127
|
|
|
1131
1128
|
const toObjectSchema = (link.to.objType.serviceTag === iz_serviceTag)
|
|
1132
1129
|
? await getLocalObjectSchemasWithHierarchy(_izContext, link.to.objType.objectType, schemasPath)
|
|
@@ -1137,7 +1134,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath, b
|
|
|
1137
1134
|
}
|
|
1138
1135
|
return res.records[0]
|
|
1139
1136
|
})
|
|
1140
|
-
: await getObjSchemaS3WithHierarchy(_izContext, link.to.objType
|
|
1137
|
+
: await getObjSchemaS3WithHierarchy(_izContext, link.to.objType);
|
|
1141
1138
|
|
|
1142
1139
|
|
|
1143
1140
|
if (!validateStatus.validateErrors.length) {
|
|
@@ -1217,8 +1214,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath, b
|
|
|
1217
1214
|
{
|
|
1218
1215
|
serviceTag: refRelSchema.relationshipServiceTag,
|
|
1219
1216
|
relationshipTag: refRelSchema.relationshipTag
|
|
1220
|
-
}
|
|
1221
|
-
bucketName
|
|
1217
|
+
}
|
|
1222
1218
|
)
|
|
1223
1219
|
if (!relSchemaFromRef) {
|
|
1224
1220
|
validateStatus.status = false;
|
|
@@ -22,11 +22,10 @@ const serviceConfig = require('../ServiceConfig');
|
|
|
22
22
|
const { STORAGE_TYPES, OBJECT_SCHEMA_BUCKET_NAME } = require('../Consts')
|
|
23
23
|
const { getObjTypeHierarchy } = require('../GetObjectSchema')
|
|
24
24
|
|
|
25
|
-
async function validateRequiredOnCreateLinks(_izContext, objType, relationships = [], settings = {
|
|
25
|
+
async function validateRequiredOnCreateLinks(_izContext, objType, relationships = [], settings = {}) {
|
|
26
26
|
_izContext.logger.debug("validateRequiredOnCreateLinks:::", { objType, relationships, settings })
|
|
27
27
|
|
|
28
|
-
let
|
|
29
|
-
let objectHie = await getObjTypeHierarchy(_izContext, objType, settings.bucketName).then(objSchema => {
|
|
28
|
+
let objectHie = await getObjTypeHierarchy(_izContext, objType).then(objSchema => {
|
|
30
29
|
if (objSchema.errorsFound.length > 0) {
|
|
31
30
|
throw new NoRetryError(objSchema.errorsFound.join(","))
|
|
32
31
|
} else {
|
|
@@ -36,7 +35,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
|
|
|
36
35
|
_izContext.logger.debug("objectHierarchy::", objectHie)
|
|
37
36
|
|
|
38
37
|
if (relationships.length) {
|
|
39
|
-
let targetHierarchy = await getObjTypeHierarchy(_izContext, relationships[0].targetObjType
|
|
38
|
+
let targetHierarchy = await getObjTypeHierarchy(_izContext, relationships[0].targetObjType).then(objSchema => {
|
|
40
39
|
if (objSchema.errorsFound.length > 0) {
|
|
41
40
|
throw new NoRetryError(objSchema.errorsFound.join(","))
|
|
42
41
|
} else {
|
|
@@ -49,7 +48,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
|
|
|
49
48
|
|
|
50
49
|
let errorsFound = [];
|
|
51
50
|
|
|
52
|
-
let requiredOnCreateLinks = await getObjectSchema.getRequiredOnCreateLinksWithCache(_izContext, objType, []
|
|
51
|
+
let requiredOnCreateLinks = await getObjectSchema.getRequiredOnCreateLinksWithCache(_izContext, objType, [])
|
|
53
52
|
_izContext.logger.debug("requiredOnCreateLinks::", requiredOnCreateLinks)
|
|
54
53
|
|
|
55
54
|
if (!requiredOnCreateLinks.length && relationships.length > 0) {
|
|
@@ -64,7 +63,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
|
|
|
64
63
|
requiredOnCreateLink.storageResourceTags.map(async (storageTag) => {
|
|
65
64
|
let storageResource = requiredOnCreateLink.storageResources[storageTag];
|
|
66
65
|
if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
67
|
-
return await serviceConfig.getGraphServiceTagWithCache(_izContext, storageResource.graphServerTag
|
|
66
|
+
return await serviceConfig.getGraphServiceTagWithCache(_izContext, storageResource.graphServerTag)
|
|
68
67
|
}
|
|
69
68
|
})
|
|
70
69
|
);
|
|
@@ -102,7 +101,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
|
|
|
102
101
|
|
|
103
102
|
for (let link of usedLinkGroup) {
|
|
104
103
|
// check other with targetObjType, check linkType of other should be 'one',
|
|
105
|
-
let targetObjTypeHierarchy = await getObjTypeHierarchy(_izContext, relationship.targetObjType
|
|
104
|
+
let targetObjTypeHierarchy = await getObjTypeHierarchy(_izContext, relationship.targetObjType).then(objSchema => {
|
|
106
105
|
if (objSchema.errorsFound.length > 0) {
|
|
107
106
|
throw new NoRetryError(objSchema.errorsFound.join(","))
|
|
108
107
|
} else {
|
|
@@ -20,7 +20,7 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
20
20
|
const { NoRetryError } = require('@izara_project/izara-core-library-core');
|
|
21
21
|
|
|
22
22
|
const { getObjSchemaS3WithHierarchy } = require("../GetObjectSchema");
|
|
23
|
-
const { DEFAULT_IDENTIFIER_DELIMINATOR
|
|
23
|
+
const { DEFAULT_IDENTIFIER_DELIMINATOR } = require("../Consts");
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -31,7 +31,7 @@ const { DEFAULT_IDENTIFIER_DELIMINATOR, OBJECT_SCHEMA_BUCKET_NAME } = require(".
|
|
|
31
31
|
* @param {Object} fieldNameSetting
|
|
32
32
|
* @param {Object} [objType] use to store objType of child
|
|
33
33
|
*/
|
|
34
|
-
async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldNameSetting, objType,
|
|
34
|
+
async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldNameSetting, objType, iter = 0) {
|
|
35
35
|
|
|
36
36
|
if (iter > 50) {
|
|
37
37
|
throw new NoRetryError("generateValidatorSchemaPerFieldName reach max iteration limit")
|
|
@@ -58,7 +58,7 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
|
|
|
58
58
|
objectType: fieldNameSetting.fromObjectType,
|
|
59
59
|
serviceTag: fieldNameSetting.fromServiceNameTag
|
|
60
60
|
},
|
|
61
|
-
|
|
61
|
+
process.env.iz_serviceSchemaBucketName
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
if (!childObjectSchema) {
|
|
@@ -94,7 +94,6 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
|
|
|
94
94
|
objectType: fieldNameSetting.fromObjectType,
|
|
95
95
|
serviceTag: fieldNameSetting.fromServiceNameTag
|
|
96
96
|
},
|
|
97
|
-
bucketName,
|
|
98
97
|
iter
|
|
99
98
|
);
|
|
100
99
|
_izContext.logger.debug("childDeliminator: ", childDeliminator)
|
|
@@ -138,7 +137,7 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
|
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
|
|
141
|
-
async function generateDeliminatorTreeAllFieldNames(_izContext, objectSchema
|
|
140
|
+
async function generateDeliminatorTreeAllFieldNames(_izContext, objectSchema) {
|
|
142
141
|
let deliminatorTreeFieldNames = {};
|
|
143
142
|
let deliminatorTreePromises = [];
|
|
144
143
|
|
|
@@ -147,7 +146,7 @@ async function generateDeliminatorTreeAllFieldNames(_izContext, objectSchema, bu
|
|
|
147
146
|
async () => {
|
|
148
147
|
Object.assign(
|
|
149
148
|
deliminatorTreeFieldNames,
|
|
150
|
-
await generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldNameData
|
|
149
|
+
await generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldNameData))
|
|
151
150
|
}
|
|
152
151
|
)
|
|
153
152
|
}
|
|
@@ -164,7 +163,7 @@ async function generateDeliminatorTreeAllFieldNames(_izContext, objectSchema, bu
|
|
|
164
163
|
async () => {
|
|
165
164
|
Object.assign(
|
|
166
165
|
deliminatorTreeFieldNames,
|
|
167
|
-
await generateDeliminatorTreePerFieldName(_izContext, versionedFieldName, versionedDataFieldSetting
|
|
166
|
+
await generateDeliminatorTreePerFieldName(_izContext, versionedFieldName, versionedDataFieldSetting))
|
|
168
167
|
}
|
|
169
168
|
)
|
|
170
169
|
}
|
|
@@ -186,7 +185,7 @@ async function generateDeliminatorTreeAllFieldNames(_izContext, objectSchema, bu
|
|
|
186
185
|
* @param {Object} objectSchema
|
|
187
186
|
* @returns
|
|
188
187
|
*/
|
|
189
|
-
async function generateDeliminatorTreeIdentifier(_izContext, objectSchema
|
|
188
|
+
async function generateDeliminatorTreeIdentifier(_izContext, objectSchema) {
|
|
190
189
|
|
|
191
190
|
let identifiersDeliminatorTree = {};
|
|
192
191
|
|
|
@@ -201,7 +200,7 @@ async function generateDeliminatorTreeIdentifier(_izContext, objectSchema, bucke
|
|
|
201
200
|
|
|
202
201
|
// collect deliminatorTree of composite key
|
|
203
202
|
await Promise.all(identifier.fieldNames.map(async (compositeKey) => {
|
|
204
|
-
let compositeKeyDeliminatortree = await generateDeliminatorTreePerFieldName(_izContext, compositeKey, objectSchema.fieldNames[compositeKey]
|
|
203
|
+
let compositeKeyDeliminatortree = await generateDeliminatorTreePerFieldName(_izContext, compositeKey, objectSchema.fieldNames[compositeKey]);
|
|
205
204
|
_izContext.logger.debug("compositeKeyDeliminatortree each fieldname: ", compositeKeyDeliminatortree);
|
|
206
205
|
Object.assign(compositeKeysDeliminatorTree, compositeKeyDeliminatortree);
|
|
207
206
|
}));
|
|
@@ -239,7 +238,7 @@ async function generateDeliminatorTreeIdentifier(_izContext, objectSchema, bucke
|
|
|
239
238
|
);
|
|
240
239
|
|
|
241
240
|
} else {
|
|
242
|
-
let identifierFieldNameDeliminatorTree = await generateDeliminatorTreePerFieldName(_izContext, identifierName, objectSchema.fieldNames[identifierName]
|
|
241
|
+
let identifierFieldNameDeliminatorTree = await generateDeliminatorTreePerFieldName(_izContext, identifierName, objectSchema.fieldNames[identifierName]);
|
|
243
242
|
Object.assign(identifiersDeliminatorTree, identifierFieldNameDeliminatorTree);
|
|
244
243
|
}
|
|
245
244
|
}
|
|
@@ -249,9 +248,9 @@ async function generateDeliminatorTreeIdentifier(_izContext, objectSchema, bucke
|
|
|
249
248
|
return identifiersDeliminatorTree
|
|
250
249
|
}
|
|
251
250
|
|
|
252
|
-
async function generateDeliminatorCompositeIdentifier(_izContext, objSchema
|
|
251
|
+
async function generateDeliminatorCompositeIdentifier(_izContext, objSchema) {
|
|
253
252
|
|
|
254
|
-
let deliminatorTreeResult = await generateDeliminatorTreeIdentifier(_izContext, objSchema
|
|
253
|
+
let deliminatorTreeResult = await generateDeliminatorTreeIdentifier(_izContext, objSchema);
|
|
255
254
|
_izContext.logger.debug("deliminator: ", deliminatorTreeResult);
|
|
256
255
|
|
|
257
256
|
|
|
@@ -20,7 +20,6 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
20
20
|
const { NoRetryError } = require('@izara_project/izara-core-library-core');
|
|
21
21
|
|
|
22
22
|
const deliminatorTree = require("./DeliminatorTree");
|
|
23
|
-
const { OBJECT_SCHEMA_BUCKET_NAME } = require('../Consts');
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
/**
|
|
@@ -123,7 +122,7 @@ function explodeDataField(
|
|
|
123
122
|
* @param {Object} requestParams
|
|
124
123
|
* @param {Object} objType
|
|
125
124
|
*/
|
|
126
|
-
async function explodedDataForCreate(_izContext, requestParams, objectSchema
|
|
125
|
+
async function explodedDataForCreate(_izContext, requestParams, objectSchema) {
|
|
127
126
|
|
|
128
127
|
// ------- validate requestParams -------
|
|
129
128
|
let errors = [];
|
|
@@ -163,7 +162,7 @@ async function explodedDataForCreate(_izContext, requestParams, objectSchema, se
|
|
|
163
162
|
fieldNames: {}
|
|
164
163
|
};
|
|
165
164
|
|
|
166
|
-
let deliminatorTreeFieldNames = await deliminatorTree.generateDeliminatorTreeAllFieldNames(_izContext, objectSchema
|
|
165
|
+
let deliminatorTreeFieldNames = await deliminatorTree.generateDeliminatorTreeAllFieldNames(_izContext, objectSchema);
|
|
167
166
|
_izContext.logger.debug("deliminatorTreeFieldNames: ", deliminatorTreeFieldNames);
|
|
168
167
|
|
|
169
168
|
await Promise.all(
|
|
@@ -226,7 +225,7 @@ async function explodedDataForCreate(_izContext, requestParams, objectSchema, se
|
|
|
226
225
|
* @param {Object} requestParams
|
|
227
226
|
* @param {Object} objType
|
|
228
227
|
*/
|
|
229
|
-
async function explodedDataForIdentifiers(_izContext, requestParams, objectSchema
|
|
228
|
+
async function explodedDataForIdentifiers(_izContext, requestParams, objectSchema) {
|
|
230
229
|
_izContext.logger.debug("explodedDataForIdentifiers: ",
|
|
231
230
|
{ requestParams, objectSchema }
|
|
232
231
|
);
|
|
@@ -340,7 +339,7 @@ async function explodedDataForIdentifiers(_izContext, requestParams, objectSchem
|
|
|
340
339
|
return explodedReqParams;
|
|
341
340
|
}
|
|
342
341
|
|
|
343
|
-
async function explodedDataForUpdate(_izContext, requestParams, objectSchema
|
|
342
|
+
async function explodedDataForUpdate(_izContext, requestParams, objectSchema) {
|
|
344
343
|
//validate requestParams
|
|
345
344
|
_izContext.logger.debug("explodedDataForUpdate::",
|
|
346
345
|
{
|
|
@@ -396,7 +395,7 @@ async function explodedDataForUpdate(_izContext, requestParams, objectSchema, se
|
|
|
396
395
|
versionedDataIds: {}
|
|
397
396
|
}
|
|
398
397
|
|
|
399
|
-
let deliminatorTreeFieldNames = await deliminatorTree.generateDeliminatorTreeAllFieldNames(_izContext, objectSchema
|
|
398
|
+
let deliminatorTreeFieldNames = await deliminatorTree.generateDeliminatorTreeAllFieldNames(_izContext, objectSchema)
|
|
400
399
|
_izContext.logger.debug("deliminatorTreeFieldNames", deliminatorTreeFieldNames);
|
|
401
400
|
|
|
402
401
|
await Promise.all(
|
package/src/libs/RelSchemaLib.js
CHANGED
|
@@ -24,7 +24,6 @@ const { NoRetryError } = require('@izara_project/izara-core-library-core');
|
|
|
24
24
|
const getObjectSchema = require("../GetObjectSchema");
|
|
25
25
|
const { validateObjType: { validateObjType } } = require("@izara_project/izara-shared-service-schemas");
|
|
26
26
|
const { getObjTypeHierarchy } = require('../GetObjectSchema');
|
|
27
|
-
const { OBJECT_SCHEMA_BUCKET_NAME } = require("../Consts");
|
|
28
27
|
/**
|
|
29
28
|
* helper function for find link of 2 objects in links and refactor each link
|
|
30
29
|
*
|
|
@@ -32,7 +31,7 @@ const { OBJECT_SCHEMA_BUCKET_NAME } = require("../Consts");
|
|
|
32
31
|
* @param {object[]} objTypes - 2 objType in array
|
|
33
32
|
* @param {object[]} relationshipLinks - links inside relationshipSchema
|
|
34
33
|
*/
|
|
35
|
-
async function findLinksByObjTypes(_izContext, objTypes, relationshipLinks
|
|
34
|
+
async function findLinksByObjTypes(_izContext, objTypes, relationshipLinks) {
|
|
36
35
|
|
|
37
36
|
if (!Array.isArray(relationshipLinks)) {
|
|
38
37
|
throw new NoRetryError("relationshipLinks should be array");
|
|
@@ -53,14 +52,14 @@ async function findLinksByObjTypes(_izContext, objTypes, relationshipLinks, buck
|
|
|
53
52
|
const secondObjType = objTypes[1];
|
|
54
53
|
|
|
55
54
|
// first create hierarchy of each objType
|
|
56
|
-
const firstObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[0],
|
|
55
|
+
const firstObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[0], process.env.iz_serviceSchemaBucketName).then(objSchema => {
|
|
57
56
|
if (objSchema.errorsFound.length > 0) {
|
|
58
57
|
throw new NoRetryError(objSchema.errorsFound.join(","))
|
|
59
58
|
} else {
|
|
60
59
|
return objSchema.result
|
|
61
60
|
}
|
|
62
61
|
});
|
|
63
|
-
const secondObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[1],
|
|
62
|
+
const secondObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[1], process.env.iz_serviceSchemaBucketName).then(objSchema => {
|
|
64
63
|
if (objSchema.errorsFound.length > 0) {
|
|
65
64
|
throw new NoRetryError(objSchema.errorsFound.join(","))
|
|
66
65
|
} else {
|
package/src/libs/s3Utils.js
CHANGED
|
@@ -62,7 +62,7 @@ async function getObjectS3Shared(param) {
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
async function getSchemaByName(params
|
|
65
|
+
async function getSchemaByName(params) {
|
|
66
66
|
if (!params.schemaName || !params.getParams) {
|
|
67
67
|
throw new NoRetryError(`getSchemaByName invalid parameters`);
|
|
68
68
|
}
|
|
@@ -73,7 +73,7 @@ async function getSchemaByName(params, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
|
73
73
|
|
|
74
74
|
// build params for getObjectS3
|
|
75
75
|
let getDataParam = {
|
|
76
|
-
Bucket:
|
|
76
|
+
Bucket: process.env.iz_serviceSchemaBucketName,
|
|
77
77
|
Key: SCHEMA_NAME_PER_S3_PATH[params.schemaName](params.getParams)
|
|
78
78
|
};
|
|
79
79
|
|