@izara_project/izara-core-library-service-schemas 1.0.76 → 1.0.78
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 +6 -6
- package/src/Consts.js +1 -1
- package/src/GetObjectSchema.js +59 -56
- package/src/IdentifiersObject.js +27 -25
- package/src/ServiceConfig.js +4 -2
- package/src/SharedUtils.js +16 -11
- package/src/UploadObjSchema.js +38 -22
- package/src/Utils.js +2 -2
- package/src/ValidatorSchema.js +56 -52
- package/src/libs/CreateNodeLib.js +8 -8
- package/src/libs/DeliminatorTree.js +14 -12
- package/src/libs/ExplodedReqParams.js +17 -15
- package/src/libs/RelSchemaLib.js +5 -4
- package/src/libs/UploadUseCase.js +4 -0
- package/src/libs/s3Utils.js +4 -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.78",
|
|
4
4
|
"description": "Schemas for the service and objects it controls",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,16 +20,16 @@
|
|
|
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.846.0",
|
|
24
|
+
"@aws-sdk/client-lambda": "^3.846.0",
|
|
25
|
+
"@aws-sdk/client-s3": "^3.846.0",
|
|
26
|
+
"@aws-sdk/crc64-nvme-crt": "^3.846.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",
|
|
30
30
|
"@izara_project/izara-core-library-logger": "^1.0.7",
|
|
31
31
|
"@izara_project/izara-shared-core": "^1.0.2",
|
|
32
|
-
"@izara_project/izara-shared-service-schemas": "^1.0.
|
|
32
|
+
"@izara_project/izara-shared-service-schemas": "^1.0.23",
|
|
33
33
|
"glob": "^11.0.3",
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
35
|
"object-hash": "^3.0.0",
|
package/src/Consts.js
CHANGED
|
@@ -348,7 +348,7 @@ module.exports = {
|
|
|
348
348
|
LOCAL_OBJECT_SCHEMA_PATH: './src/schemas', // schema folder path in lambda environment
|
|
349
349
|
|
|
350
350
|
OBJECT_SCHEMA_BUCKET_NAME: 'object-schema',
|
|
351
|
-
|
|
351
|
+
SUPPLY_SCHEMA_BUCKET_NAME: "schema-supply",
|
|
352
352
|
DEFAULT_IDENTIFIER_DELIMINATOR: "_",
|
|
353
353
|
|
|
354
354
|
PREFIX_PATH_S3,
|
package/src/GetObjectSchema.js
CHANGED
|
@@ -39,6 +39,7 @@ const {
|
|
|
39
39
|
getObjTypeHierarchy: getObjTypeHierarchyShared,
|
|
40
40
|
getObjectSchemaForCreate: getObjectSchemaForCreateShared,
|
|
41
41
|
getObjectSchemaForUpdate: getObjectSchemaForUpdateShared,
|
|
42
|
+
getFlowSchemaS3: getFlowSchemaS3Shared
|
|
42
43
|
} = sharedServiceSchema.getObjectSchema;
|
|
43
44
|
const { validateObjType, validateFlowType } = sharedServiceSchema.validateObjType;
|
|
44
45
|
const {
|
|
@@ -56,7 +57,7 @@ const {
|
|
|
56
57
|
// const dynamodbSharedLib = require('@izara_project/izara-shared/src/DynamodbSharedLib');
|
|
57
58
|
// const Logger = require('@izara_project/izara-core-library-logger')
|
|
58
59
|
|
|
59
|
-
const { getObjectS3, headObjectS3, getSchemaByNameWithCache } = require("./libs/s3Utils");
|
|
60
|
+
const { getObjectS3, headObjectS3, getSchemaByNameWithCache, getSchemaByName } = require("./libs/s3Utils");
|
|
60
61
|
const { generateObjectSchemaForCombineFieldNames } = require("./libs/UploadUseCase");
|
|
61
62
|
|
|
62
63
|
const {
|
|
@@ -469,9 +470,11 @@ async function getLambdaFunctionNames(_izContext) {
|
|
|
469
470
|
async function getObjSchemaS3(
|
|
470
471
|
_izContext,
|
|
471
472
|
objType,
|
|
473
|
+
bucketName = OBJECT_SCHEMA_BUCKET_NAME,
|
|
472
474
|
getExtendObType = false
|
|
473
475
|
) {
|
|
474
|
-
|
|
476
|
+
|
|
477
|
+
return await getObjectSchemaS3Shared(getSchemaByNameWithCache, objType, bucketName, getExtendObType).then(res => {
|
|
475
478
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
476
479
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
477
480
|
} else {
|
|
@@ -491,7 +494,7 @@ const getObjSchemaS3WithCache = inMemoryCacheLib(
|
|
|
491
494
|
{ // setting
|
|
492
495
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getObjSchemaS3',
|
|
493
496
|
normalizer: function (args) {
|
|
494
|
-
return hash([args[1], args[2]])
|
|
497
|
+
return hash([args[1], args[2], args[3]])
|
|
495
498
|
}
|
|
496
499
|
}
|
|
497
500
|
)
|
|
@@ -503,9 +506,9 @@ const getObjSchemaS3WithCache = inMemoryCacheLib(
|
|
|
503
506
|
* @see {@link getObjSchemaS3WithCache}
|
|
504
507
|
*
|
|
505
508
|
*/
|
|
506
|
-
async function getObjSchemaS3WithHierarchy(_izContext, objType) {
|
|
509
|
+
async function getObjSchemaS3WithHierarchy(_izContext, objType, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
507
510
|
// return await getObjSchemaS3WithCache(_izContext, objType, true)
|
|
508
|
-
return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType).then(res => {
|
|
511
|
+
return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType, bucketName).then(res => {
|
|
509
512
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
510
513
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
511
514
|
} else {
|
|
@@ -520,9 +523,9 @@ async function getObjSchemaS3WithHierarchy(_izContext, objType) {
|
|
|
520
523
|
* @see {@link getObjSchemaS3}
|
|
521
524
|
* @see {@link getObjSchemaS3WithCache}
|
|
522
525
|
*/
|
|
523
|
-
async function getObjSchemaS3WithoutHierarchy(_izContext, objType) {
|
|
526
|
+
async function getObjSchemaS3WithoutHierarchy(_izContext, objType, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
524
527
|
// return await getObjSchemaS3WithCache(_izContext, objType, false)
|
|
525
|
-
return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType).then(res => {
|
|
528
|
+
return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType, bucketName).then(res => {
|
|
526
529
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
527
530
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
528
531
|
} else {
|
|
@@ -541,9 +544,9 @@ async function getObjSchemaS3WithoutHierarchy(_izContext, objType) {
|
|
|
541
544
|
* @param {String} objType.objectType
|
|
542
545
|
* @return {Promise<Object>} - object schema for graph handler
|
|
543
546
|
*/
|
|
544
|
-
async function getObjectSchemaCombineFieldNames(_izContext, objType) {
|
|
547
|
+
async function getObjectSchemaCombineFieldNames(_izContext, objType, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
545
548
|
|
|
546
|
-
const objSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
549
|
+
const objSchema = await getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
|
|
547
550
|
const combinedSchema = generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
|
|
548
551
|
return combinedSchema
|
|
549
552
|
}
|
|
@@ -558,7 +561,7 @@ const getObjectSchemaCombineFieldNamesWithCache = inMemoryCacheLib(
|
|
|
558
561
|
{ // setting
|
|
559
562
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getObjectSchemaCombineFieldNames',
|
|
560
563
|
normalizer: function (args) {
|
|
561
|
-
return hash([args[1]])
|
|
564
|
+
return hash([args[1], args[2]])
|
|
562
565
|
}
|
|
563
566
|
}
|
|
564
567
|
);
|
|
@@ -638,8 +641,8 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
|
|
|
638
641
|
* @param {String} objType.serviceTag
|
|
639
642
|
* @returns {Promise<Object>} - reference relationship schema of objType
|
|
640
643
|
*/
|
|
641
|
-
async function getRefObjectRelationship(_izContext, objType) {
|
|
642
|
-
return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType).then(res => {
|
|
644
|
+
async function getRefObjectRelationship(_izContext, objType, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
645
|
+
return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType, bucketName).then(res => {
|
|
643
646
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
644
647
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
645
648
|
} else {
|
|
@@ -658,7 +661,7 @@ const getRefObjectRelationshipWithCache = inMemoryCacheLib(
|
|
|
658
661
|
{ // setting
|
|
659
662
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getRefObjectRelationship',
|
|
660
663
|
normalizer: function (args) {
|
|
661
|
-
return hash([args[1]]);
|
|
664
|
+
return hash([args[1]], args[2]);
|
|
662
665
|
}
|
|
663
666
|
}
|
|
664
667
|
);
|
|
@@ -673,8 +676,8 @@ const getRefObjectRelationshipWithCache = inMemoryCacheLib(
|
|
|
673
676
|
* @returns {Promise<{item:object|null,location:string|null}>} - item: relationship data, location: actual serviceTag that relationship located
|
|
674
677
|
*
|
|
675
678
|
*/
|
|
676
|
-
async function getRelationshipSchema(_izContext, relType) {
|
|
677
|
-
return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType).then(res => {
|
|
679
|
+
async function getRelationshipSchema(_izContext, relType, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
680
|
+
return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType, bucketName).then(res => {
|
|
678
681
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
679
682
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
680
683
|
} else {
|
|
@@ -694,14 +697,14 @@ const getRelationshipSchemaWithCache = inMemoryCacheLib(
|
|
|
694
697
|
{ // setting
|
|
695
698
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getRelationshipSchema',
|
|
696
699
|
normalizer: function (args) {
|
|
697
|
-
return hash([args[1]])
|
|
700
|
+
return hash([args[1], args[2]])
|
|
698
701
|
}
|
|
699
702
|
}
|
|
700
703
|
);
|
|
701
704
|
|
|
702
705
|
|
|
703
706
|
/**
|
|
704
|
-
* get serviceTag of
|
|
707
|
+
* get serviceTag of relationshipTag data from s3
|
|
705
708
|
*
|
|
706
709
|
* @param {Object} _izContext
|
|
707
710
|
* @param {String} relationshipTag - needed relationshipTag
|
|
@@ -711,7 +714,7 @@ const getRelationshipSchemaWithCache = inMemoryCacheLib(
|
|
|
711
714
|
* @returns {Promise<{item:object|null,location:string|null}>} - item: relationship data, location: actual serviceTag that relationship located
|
|
712
715
|
*
|
|
713
716
|
*/
|
|
714
|
-
async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
|
|
717
|
+
async function getRelationshipServiceTag(_izContext, relationshipTag, objType, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
715
718
|
_izContext.logger.debug("getRelationshipServiceTag: ", {
|
|
716
719
|
relationshipTag,
|
|
717
720
|
objType,
|
|
@@ -731,7 +734,7 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
|
|
|
731
734
|
}
|
|
732
735
|
);
|
|
733
736
|
|
|
734
|
-
let relSchemaHeadData = await headObjectS3(_izContext, { Bucket:
|
|
737
|
+
let relSchemaHeadData = await headObjectS3(_izContext, { Bucket: bucketName, Key: relTagPath })
|
|
735
738
|
|
|
736
739
|
// _izContext.logger.debug("relSchemaHeadData: ", relSchemaHeadData);
|
|
737
740
|
|
|
@@ -740,7 +743,7 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
|
|
|
740
743
|
return objType.serviceTag;
|
|
741
744
|
} else {
|
|
742
745
|
// const refObjRel = await getRefObjectRelationship(_izContext, objType);
|
|
743
|
-
const getRefObjRelWithCacheResult = await getRefObjectRelationshipWithCache(_izContext, objType);
|
|
746
|
+
const getRefObjRelWithCacheResult = await getRefObjectRelationshipWithCache(_izContext, objType, bucketName);
|
|
744
747
|
const refObjRel = getRefObjRelWithCacheResult.records;
|
|
745
748
|
if (refObjRel.hasOwnProperty(relationshipTag)) {
|
|
746
749
|
return refObjRel[relationshipTag].relationshipServiceTag
|
|
@@ -761,7 +764,7 @@ const getRelationshipServiceTagWithCache = inMemoryCacheLib(
|
|
|
761
764
|
{ // setting
|
|
762
765
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getRelationshipServiceTag',
|
|
763
766
|
normalizer: function (args) {
|
|
764
|
-
return hash([args[1], args[2]])
|
|
767
|
+
return hash([args[1], args[2], args[3]])
|
|
765
768
|
}
|
|
766
769
|
}
|
|
767
770
|
);
|
|
@@ -785,9 +788,10 @@ async function getObjectRelationship(
|
|
|
785
788
|
objType,
|
|
786
789
|
specificRelTags,
|
|
787
790
|
overWriteBaseObjType,
|
|
791
|
+
bucketName = OBJECT_SCHEMA_BUCKET_NAME
|
|
788
792
|
) {
|
|
789
793
|
|
|
790
|
-
return await getObjectRelationshipShared(getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType).then(res => {
|
|
794
|
+
return await getObjectRelationshipShared(getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType, bucketName).then(res => {
|
|
791
795
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
792
796
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
793
797
|
} else {
|
|
@@ -808,7 +812,7 @@ const getObjectRelationshipWithCache = inMemoryCacheLib(
|
|
|
808
812
|
{ // setting
|
|
809
813
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getObjectRelationshipS3',
|
|
810
814
|
normalizer: function (args) {
|
|
811
|
-
return hash([args[1], args[2]])
|
|
815
|
+
return hash([args[1], args[2], args[3]])
|
|
812
816
|
}
|
|
813
817
|
}
|
|
814
818
|
)
|
|
@@ -817,7 +821,7 @@ const getObjectRelationshipWithCache = inMemoryCacheLib(
|
|
|
817
821
|
|
|
818
822
|
/**
|
|
819
823
|
*
|
|
820
|
-
* get requiredOnCreate link in
|
|
824
|
+
* get requiredOnCreate link in relationshipSchema of objType depend on specific relationshipTags
|
|
821
825
|
*
|
|
822
826
|
* @param {Object} _izContext
|
|
823
827
|
* @param {Object} objType
|
|
@@ -830,6 +834,7 @@ async function getRequiredOnCreateLinks(
|
|
|
830
834
|
_izContext,
|
|
831
835
|
objType,
|
|
832
836
|
specificRelTags,
|
|
837
|
+
bucketName = OBJECT_SCHEMA_BUCKET_NAME,
|
|
833
838
|
) {
|
|
834
839
|
|
|
835
840
|
_izContext.logger.debug("Function getRequiredOnCreateLinks: ", {
|
|
@@ -837,7 +842,7 @@ async function getRequiredOnCreateLinks(
|
|
|
837
842
|
specificRelTags,
|
|
838
843
|
});
|
|
839
844
|
|
|
840
|
-
return await getRequiredOnCreateLinksShared(getSchemaByNameWithCache, objType, specificRelTags).then(res => {
|
|
845
|
+
return await getRequiredOnCreateLinksShared(getSchemaByNameWithCache, objType, specificRelTags, bucketName).then(res => {
|
|
841
846
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
842
847
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
843
848
|
} else {
|
|
@@ -857,7 +862,7 @@ const getRequiredOnCreateLinksWithCache = inMemoryCacheLib(
|
|
|
857
862
|
{ // setting
|
|
858
863
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getRequiredOnCreateLinks',
|
|
859
864
|
normalizer: function (args) {
|
|
860
|
-
return hash([args[1], args[2]])
|
|
865
|
+
return hash([args[1], args[2], args[3]])
|
|
861
866
|
}
|
|
862
867
|
}
|
|
863
868
|
);
|
|
@@ -874,16 +879,17 @@ const getRequiredOnCreateLinksWithCache = inMemoryCacheLib(
|
|
|
874
879
|
* @param {String} relationshipTag
|
|
875
880
|
* @returns {Promise<{from:Object, to:Object}>}
|
|
876
881
|
*/
|
|
877
|
-
async function getLinkConfig(_izContext, firstObjType, secondObjType, relType, direction, settings = {}) {
|
|
882
|
+
async function getLinkConfig(_izContext, firstObjType, secondObjType, relType, direction, settings = {}, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
878
883
|
_izContext.logger.debug("getLinkConfig: ", {
|
|
879
884
|
firstObjType,
|
|
880
885
|
secondObjType,
|
|
881
886
|
relType,
|
|
882
887
|
direction,
|
|
883
|
-
settings
|
|
888
|
+
settings,
|
|
889
|
+
bucketName,
|
|
884
890
|
});
|
|
885
891
|
|
|
886
|
-
return await getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings);
|
|
892
|
+
return await getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings, bucketName);
|
|
887
893
|
}
|
|
888
894
|
|
|
889
895
|
/**
|
|
@@ -910,17 +916,18 @@ const getLinkConfigWithCache = inMemoryCacheLib(
|
|
|
910
916
|
* @param {String} relType.relationshipTag
|
|
911
917
|
* @returns {Promise<{from:Object, to:Object}>}
|
|
912
918
|
*/
|
|
913
|
-
async function getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings) {
|
|
919
|
+
async function getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings = {}, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
914
920
|
|
|
915
921
|
_izContext.logger.debug("getLinkConfigByLinkTypeId: ", {
|
|
916
922
|
firstObjType,
|
|
917
923
|
secondObjType,
|
|
918
924
|
relType,
|
|
919
925
|
direction,
|
|
920
|
-
settings
|
|
926
|
+
settings,
|
|
927
|
+
bucketName
|
|
921
928
|
});
|
|
922
929
|
|
|
923
|
-
return await getLinkConfigByLinkTypeIdShared(getSchemaByNameWithCache, firstObjType, secondObjType, relType, direction, settings).then(res => {
|
|
930
|
+
return await getLinkConfigByLinkTypeIdShared(getSchemaByNameWithCache, firstObjType, secondObjType, relType, direction, settings, bucketName).then(res => {
|
|
924
931
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
925
932
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
926
933
|
} else {
|
|
@@ -939,7 +946,7 @@ const getLinkConfigByLinkTypeIdWithCache = inMemoryCacheLib(
|
|
|
939
946
|
{ // setting
|
|
940
947
|
max: 100, maxAge: 86400000, promise: true, profileName: 'getLinkConfigByLinkTypeId',
|
|
941
948
|
normalizer: function (args) {
|
|
942
|
-
return hash([args[1], args[2], args[3], args[4]]);
|
|
949
|
+
return hash([args[1], args[2], args[3], args[4], args[5]]);
|
|
943
950
|
}
|
|
944
951
|
}
|
|
945
952
|
);
|
|
@@ -956,8 +963,8 @@ const getLinkConfigByLinkTypeIdWithCache = inMemoryCacheLib(
|
|
|
956
963
|
* @param {object} objectSchema
|
|
957
964
|
* @returns
|
|
958
965
|
*/
|
|
959
|
-
async function mergeExtendObjSchema(_izContext, objectSchema) {
|
|
960
|
-
let mergedObjectSchema = await mergeExtendObjSchemaShared(getSchemaByNameWithCache, objectSchema).then(res => {
|
|
966
|
+
async function mergeExtendObjSchema(_izContext, objectSchema, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
967
|
+
let mergedObjectSchema = await mergeExtendObjSchemaShared(getSchemaByNameWithCache, objectSchema, bucketName).then(res => {
|
|
961
968
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
962
969
|
throw new NoRetryError(`objectSchema.objectType: ${objectSchema.objectType} ${res.errorsFound}`)
|
|
963
970
|
} else {
|
|
@@ -1046,20 +1053,16 @@ async function getLocalFlowSchemas(_izContext, flowTags, flowSchemaPath = LOCAL_
|
|
|
1046
1053
|
async function getFlowSchemaS3(
|
|
1047
1054
|
_izContext,
|
|
1048
1055
|
flowType,
|
|
1056
|
+
bucketName = OBJECT_SCHEMA_BUCKET_NAME
|
|
1049
1057
|
) {
|
|
1050
|
-
const validateFlowTypeResult = validateFlowType(flowType);
|
|
1051
|
-
if (validateFlowTypeResult.errorsFound.length > 0) {
|
|
1052
|
-
_izContext.logger.error("getFlowSchemaS3: Invalid flowType: ", validateFlowTypeResult.errorsFound);
|
|
1053
|
-
throw new NoRetryError(`getFlowSchemaS3: Invalid flowType: ${JSON.stringify(flowType)}, ${validateFlowTypeResult.errorsFound.join(", ")}`);
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
const getObjSchemaParam = {
|
|
1057
|
-
Bucket: OBJECT_SCHEMA_BUCKET_NAME,
|
|
1058
|
-
Key: UPLOAD_PATH_S3.flowSchema(_izContext, flowType)
|
|
1059
|
-
};
|
|
1060
|
-
let [flowSchema] = await getObjectS3(_izContext, getObjSchemaParam);
|
|
1061
1058
|
|
|
1062
|
-
return
|
|
1059
|
+
return await getFlowSchemaS3Shared(getSchemaByNameWithCache, flowType, bucketName).then(res => {
|
|
1060
|
+
if (res.errorsFound.length) {
|
|
1061
|
+
throw new NoRetryError(res.errorsFound.join(","))
|
|
1062
|
+
} else {
|
|
1063
|
+
return res.result
|
|
1064
|
+
}
|
|
1065
|
+
})
|
|
1063
1066
|
}
|
|
1064
1067
|
|
|
1065
1068
|
/**
|
|
@@ -1069,10 +1072,10 @@ async function getFlowSchemaS3(
|
|
|
1069
1072
|
*/
|
|
1070
1073
|
const getFlowSchemaS3WithCache = inMemoryCacheLib(
|
|
1071
1074
|
getFlowSchemaS3,
|
|
1072
|
-
{ //
|
|
1075
|
+
{ //setting
|
|
1073
1076
|
max: 100, maxAge: 8640000, promise: true, profileName: 'getFlowSchemaS3',
|
|
1074
1077
|
normalizer: function (args) {
|
|
1075
|
-
return hash([args[1]])
|
|
1078
|
+
return hash([args[1], args[2]])
|
|
1076
1079
|
}
|
|
1077
1080
|
}
|
|
1078
1081
|
)
|
|
@@ -1105,8 +1108,8 @@ function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = LOCA
|
|
|
1105
1108
|
* @param {number} iter
|
|
1106
1109
|
* @returns
|
|
1107
1110
|
*/
|
|
1108
|
-
async function getObjTypeHierarchy(_izContext, objType) {
|
|
1109
|
-
return await getObjTypeHierarchyShared(getSchemaByNameWithCache, objType);
|
|
1111
|
+
async function getObjTypeHierarchy(_izContext, objType, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
1112
|
+
return await getObjTypeHierarchyShared(getSchemaByNameWithCache, objType, objType, bucketName);
|
|
1110
1113
|
}
|
|
1111
1114
|
|
|
1112
1115
|
/**
|
|
@@ -1116,7 +1119,7 @@ async function getObjTypeHierarchy(_izContext, objType) {
|
|
|
1116
1119
|
*/
|
|
1117
1120
|
const getObjTypeHierarchyWithCache = inMemoryCacheLib(
|
|
1118
1121
|
getObjTypeHierarchy,
|
|
1119
|
-
{ //
|
|
1122
|
+
{ //setting
|
|
1120
1123
|
max: 100, maxAge: 8640000, promise: true, profileName: 'getObjTypeHierarchy',
|
|
1121
1124
|
normalizer: function (args) {
|
|
1122
1125
|
return hash([args[1]])
|
|
@@ -1124,12 +1127,12 @@ const getObjTypeHierarchyWithCache = inMemoryCacheLib(
|
|
|
1124
1127
|
}
|
|
1125
1128
|
)
|
|
1126
1129
|
|
|
1127
|
-
async function getObjectSchemaForCreate(_izContext, objType) {
|
|
1128
|
-
return await getObjectSchemaForCreateShared(getSchemaByNameWithCache, objType)
|
|
1130
|
+
async function getObjectSchemaForCreate(_izContext, objType, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
1131
|
+
return await getObjectSchemaForCreateShared(getSchemaByNameWithCache, objType, bucketName)
|
|
1129
1132
|
}
|
|
1130
1133
|
|
|
1131
|
-
async function getObjectSchemaForUpdate(_izContext, objType) {
|
|
1132
|
-
return await getObjectSchemaForUpdateShared(getSchemaByNameWithCache, objType)
|
|
1134
|
+
async function getObjectSchemaForUpdate(_izContext, objType, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
1135
|
+
return await getObjectSchemaForUpdateShared(getSchemaByNameWithCache, objType, bucketName)
|
|
1133
1136
|
}
|
|
1134
1137
|
|
|
1135
1138
|
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 } = require('./Consts');
|
|
26
|
+
const { STORAGE_TYPES, STORAGE_IDENTIFIER_TYPES, DEFAULT_IDENTIFIER_DELIMINATOR, OBJECT_SCHEMA_BUCKET_NAME } = require('./Consts');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -51,14 +51,14 @@ function checkStorageTypeOfObjectSchemaIdentifiers(_izContext, objectSchema) {
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* create object of
|
|
54
|
+
* create object of identifiers from baseObjInstance object
|
|
55
55
|
*
|
|
56
56
|
* @param {Object} _izContext
|
|
57
57
|
* @param {Object} objType
|
|
58
58
|
* @param {Object} objInstanceBase
|
|
59
59
|
* @returns {Promise<Object>} - identifiersObject
|
|
60
60
|
*/
|
|
61
|
-
async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBase) {
|
|
61
|
+
async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBase, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
62
62
|
const validateObjTypeResult = validateObjType(objType);
|
|
63
63
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
64
64
|
_izContext.logger.error("identifiersObjectFromBaseObjInstance: Invalid objType: ", validateObjTypeResult.errorsFound);
|
|
@@ -67,9 +67,9 @@ async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBa
|
|
|
67
67
|
|
|
68
68
|
_izContext.logger.debug("identifiersObjectFromBaseObjInstance: ", { objType, baseObjInstance: objInstanceBase });
|
|
69
69
|
|
|
70
|
-
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
70
|
+
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
|
|
71
71
|
|
|
72
|
-
let deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema);
|
|
72
|
+
let deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema, bucketName);
|
|
73
73
|
_izContext.logger.debug("deliminator: ", deliminatorTreeResult);
|
|
74
74
|
|
|
75
75
|
|
|
@@ -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) {
|
|
147
|
+
async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
148
148
|
const validateObjTypeResult = validateObjType(objType);
|
|
149
149
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
150
150
|
_izContext.logger.error("identifiersBaseFromIdentifiers: Invalid objType: ", validateObjTypeResult.errorsFound);
|
|
@@ -153,7 +153,7 @@ async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers)
|
|
|
153
153
|
|
|
154
154
|
_izContext.logger.debug("concatIdentifiersFromIdentifiersObject: ", { objType, identifiersObject: identifiers });
|
|
155
155
|
|
|
156
|
-
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
156
|
+
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
|
|
157
157
|
|
|
158
158
|
|
|
159
159
|
// validate identifiersObject
|
|
@@ -168,7 +168,7 @@ async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers)
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
// start to create concatIdentifiers
|
|
171
|
-
const deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema);
|
|
171
|
+
const deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema, bucketName);
|
|
172
172
|
_izContext.logger.debug("deliminator: ", deliminatorTreeResult);
|
|
173
173
|
|
|
174
174
|
|
|
@@ -200,14 +200,14 @@ async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers)
|
|
|
200
200
|
* @param {Object} objInstance
|
|
201
201
|
* @returns {Promise<Object>} - refactoredObjInstance
|
|
202
202
|
*/
|
|
203
|
-
async function
|
|
203
|
+
async function objInstanceFromObjInstanceBase(_izContext, objType, objInstance, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
204
204
|
const validateObjTypeResult = validateObjType(objType);
|
|
205
205
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
206
|
-
_izContext.logger.error("
|
|
207
|
-
throw new NoRetryError(`
|
|
206
|
+
_izContext.logger.error("objInstanceFromObjInstanceBase: Invalid objType: ", validateObjTypeResult.errorsFound);
|
|
207
|
+
throw new NoRetryError(`objInstanceFromObjInstanceBase: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
210
|
+
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
|
|
211
211
|
|
|
212
212
|
const identifierNames = objSchema.identifiers.map(identifier => identifier.name || identifier.fieldName);
|
|
213
213
|
|
|
@@ -222,7 +222,7 @@ async function objInstanceFromobjInstanceBase(_izContext, objType, objInstance)
|
|
|
222
222
|
refactoredObjInstance[baseObjProp] = objInstance[baseObjProp];
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
const identifiersObject = await identifiersFromObjInstanceBase(_izContext, objType, objInstance);
|
|
225
|
+
const identifiersObject = await identifiersFromObjInstanceBase(_izContext, objType, objInstance, bucketName);
|
|
226
226
|
Object.assign(refactoredObjInstance, identifiersObject);
|
|
227
227
|
|
|
228
228
|
return refactoredObjInstance;
|
|
@@ -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) {
|
|
238
|
+
async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
239
239
|
const validateObjTypeResult = validateObjType(objType);
|
|
240
240
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
241
241
|
_izContext.logger.error("compositeIdentifierFromIdentifiersObject: Invalid objType: ", validateObjTypeResult.errorsFound);
|
|
@@ -244,13 +244,13 @@ async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers
|
|
|
244
244
|
|
|
245
245
|
_izContext.logger.debug("compositeIdentifierFromIdentifiersObject: ", { objType, identifiersObject: identifiers });
|
|
246
246
|
|
|
247
|
-
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
247
|
+
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
|
|
248
248
|
_izContext.logger.debug("objSchema: ", objSchema);
|
|
249
249
|
|
|
250
250
|
|
|
251
251
|
// validate identifiersObject
|
|
252
252
|
// maybe validate with all deliminatorTree instead of identifiersName
|
|
253
|
-
const identifiersNames = getUsedFieldNamesOfIdentifiers(_izContext, objSchema.identifiers);
|
|
253
|
+
const identifiersNames = getUsedFieldNamesOfIdentifiers(_izContext, objSchema.identifiers,);
|
|
254
254
|
_izContext.logger.debug("identifiersNames: ", identifiersNames);
|
|
255
255
|
|
|
256
256
|
for (const identifierName of identifiersNames) {
|
|
@@ -260,7 +260,7 @@ async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
// start to create concatIdentifiers
|
|
263
|
-
const deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema);
|
|
263
|
+
const deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema, bucketName);
|
|
264
264
|
_izContext.logger.debug("deliminator: ", deliminatorTreeResult);
|
|
265
265
|
|
|
266
266
|
|
|
@@ -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) {
|
|
336
|
+
async function identifiersFromIdentifiersConcat(_izContext, objType, identifiersConcat, bucketName = OBJECT_SCHEMA_BUCKET_NAME) {
|
|
337
337
|
const validateObjTypeResult = validateObjType(objType);
|
|
338
338
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
339
339
|
_izContext.logger.error("identifiersObjectFromCompositeIdentifier: Invalid objType: ", validateObjTypeResult.errorsFound);
|
|
@@ -342,9 +342,9 @@ async function identifiersFromIdentifiersConcat(_izContext, objType, identifiers
|
|
|
342
342
|
|
|
343
343
|
_izContext.logger.debug("identifiersObjectFromCompositeIdentifier: ", { objType, compositeIdentifier: identifiersConcat });
|
|
344
344
|
|
|
345
|
-
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
345
|
+
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
|
|
346
346
|
_izContext.logger.debug("objSchema in identifiersObjectFromCompositeIdentifier", objSchema)
|
|
347
|
-
let deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema);
|
|
347
|
+
let deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema, bucketName);
|
|
348
348
|
_izContext.logger.debug("deliminator: ", deliminatorTreeResult);
|
|
349
349
|
|
|
350
350
|
|
|
@@ -431,6 +431,7 @@ async function createNestedIdentifiersConcat(
|
|
|
431
431
|
_izContext,
|
|
432
432
|
objType,
|
|
433
433
|
identifiersConcat,
|
|
434
|
+
bucketName = OBJECT_SCHEMA_BUCKET_NAME,
|
|
434
435
|
prefixes = [],
|
|
435
436
|
suffixes = [],
|
|
436
437
|
level = 1,
|
|
@@ -453,10 +454,10 @@ async function createNestedIdentifiersConcat(
|
|
|
453
454
|
throw new NoRetryError(`createConcatIdentifier: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
|
|
454
455
|
}
|
|
455
456
|
|
|
456
|
-
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
457
|
+
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
|
|
457
458
|
_izContext.logger.debug("objSchema in createConcatIdentifier", objSchema);
|
|
458
459
|
|
|
459
|
-
let deliminatorTreeCompositeIdentifier = await deliminatorTree.generateDeliminatorCompositeIdentifier(_izContext, objSchema);
|
|
460
|
+
let deliminatorTreeCompositeIdentifier = await deliminatorTree.generateDeliminatorCompositeIdentifier(_izContext, objSchema, bucketName);
|
|
460
461
|
_izContext.logger.debug("deliminatorTreeCompositeIdentifier: ", deliminatorTreeCompositeIdentifier);
|
|
461
462
|
|
|
462
463
|
|
|
@@ -475,6 +476,7 @@ async function explodedNestedIdentifiersConcat(
|
|
|
475
476
|
_izContext,
|
|
476
477
|
objType,
|
|
477
478
|
concatIdentifier,
|
|
479
|
+
bucketName = OBJECT_SCHEMA_BUCKET_NAME,
|
|
478
480
|
level = 1,
|
|
479
481
|
deliminator = DEFAULT_IDENTIFIER_DELIMINATOR,
|
|
480
482
|
) {
|
|
@@ -491,10 +493,10 @@ async function explodedNestedIdentifiersConcat(
|
|
|
491
493
|
throw new NoRetryError(`explodedConcatIdentifier: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
|
|
492
494
|
}
|
|
493
495
|
|
|
494
|
-
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
496
|
+
const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
|
|
495
497
|
_izContext.logger.debug("objSchema in explodedConcatIdentifier", objSchema);
|
|
496
498
|
|
|
497
|
-
let deliminatorTreeCompositeIdentifier = await deliminatorTree.generateDeliminatorCompositeIdentifier(_izContext, objSchema);
|
|
499
|
+
let deliminatorTreeCompositeIdentifier = await deliminatorTree.generateDeliminatorCompositeIdentifier(_izContext, objSchema, bucketName);
|
|
498
500
|
_izContext.logger.debug("deliminatorTreeCompositeIdentifier: ", deliminatorTreeCompositeIdentifier);
|
|
499
501
|
|
|
500
502
|
|
|
@@ -510,7 +512,7 @@ async function explodedNestedIdentifiersConcat(
|
|
|
510
512
|
module.exports = {
|
|
511
513
|
identifiersFromObjInstanceBase,
|
|
512
514
|
identifiersBaseFromIdentifiers, // concatIdentifiersObjectFromIdentifiersObject
|
|
513
|
-
|
|
515
|
+
objInstanceFromObjInstanceBase, // refactoredObjInstanceFromBaseObjInstance
|
|
514
516
|
identifiersConcatFromIdentifiers, // compositeIdentifierFromIdentifiersObject
|
|
515
517
|
identifiersFromIdentifiersConcat, // identifiersObjectFromCompositeIdentifier
|
|
516
518
|
|
package/src/ServiceConfig.js
CHANGED
|
@@ -38,11 +38,12 @@ const { getObjectS3 } = require("./libs/s3Utils")
|
|
|
38
38
|
async function getServiceName(
|
|
39
39
|
_izContext,
|
|
40
40
|
serviceTag,
|
|
41
|
+
bucketName
|
|
41
42
|
) {
|
|
42
43
|
_izContext.logger.debug("getServiceName: ", serviceTag)
|
|
43
44
|
|
|
44
45
|
const getObjectParam = {
|
|
45
|
-
Bucket: OBJECT_SCHEMA_BUCKET_NAME,
|
|
46
|
+
Bucket: bucketName ? bucketName : OBJECT_SCHEMA_BUCKET_NAME,
|
|
46
47
|
Key: UPLOAD_PATH_S3.serviceName(_izContext, serviceTag),
|
|
47
48
|
};
|
|
48
49
|
_izContext.logger.debug("getObjectParam", getObjectParam)
|
|
@@ -82,13 +83,14 @@ const getServiceNameWithCache = inMemoryCacheLib(
|
|
|
82
83
|
async function getGraphServiceTag(
|
|
83
84
|
_izContext,
|
|
84
85
|
graphServerTag,
|
|
86
|
+
bucketName
|
|
85
87
|
) {
|
|
86
88
|
|
|
87
89
|
// get all graph serverTag
|
|
88
90
|
let [serverTags] = await getObjectS3(
|
|
89
91
|
_izContext,
|
|
90
92
|
{
|
|
91
|
-
Bucket: OBJECT_SCHEMA_BUCKET_NAME,
|
|
93
|
+
Bucket: bucketName ? bucketName : OBJECT_SCHEMA_BUCKET_NAME,
|
|
92
94
|
Key: UPLOAD_PATH_S3.graphServerTagsConfig
|
|
93
95
|
}
|
|
94
96
|
);
|