@izara_project/izara-core-library-service-schemas 1.0.79 → 1.0.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-library-service-schemas",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.81",
|
|
4
4
|
"description": "Schemas for the service and objects it controls",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,7 +29,7 @@
|
|
|
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.24",
|
|
33
33
|
"glob": "^11.0.3",
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
35
|
"object-hash": "^3.0.0",
|
package/src/GetObjectSchema.js
CHANGED
|
@@ -504,9 +504,9 @@ const getObjSchemaS3WithCache = inMemoryCacheLib(
|
|
|
504
504
|
* @see {@link getObjSchemaS3WithCache}
|
|
505
505
|
*
|
|
506
506
|
*/
|
|
507
|
-
async function getObjSchemaS3WithHierarchy(_izContext, objType) {
|
|
507
|
+
async function getObjSchemaS3WithHierarchy(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
|
|
508
508
|
// return await getObjSchemaS3WithCache(_izContext, objType, true)
|
|
509
|
-
return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType,
|
|
509
|
+
return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType, bucketName).then(res => {
|
|
510
510
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
511
511
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
512
512
|
} else {
|
|
@@ -521,9 +521,9 @@ async function getObjSchemaS3WithHierarchy(_izContext, objType) {
|
|
|
521
521
|
* @see {@link getObjSchemaS3}
|
|
522
522
|
* @see {@link getObjSchemaS3WithCache}
|
|
523
523
|
*/
|
|
524
|
-
async function getObjSchemaS3WithoutHierarchy(_izContext, objType) {
|
|
524
|
+
async function getObjSchemaS3WithoutHierarchy(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
|
|
525
525
|
// return await getObjSchemaS3WithCache(_izContext, objType, false)
|
|
526
|
-
return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType,
|
|
526
|
+
return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType, bucketName).then(res => {
|
|
527
527
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
528
528
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
529
529
|
} else {
|
|
@@ -639,8 +639,8 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
|
|
|
639
639
|
* @param {String} objType.serviceTag
|
|
640
640
|
* @returns {Promise<Object>} - reference relationship schema of objType
|
|
641
641
|
*/
|
|
642
|
-
async function getRefObjectRelationship(_izContext, objType) {
|
|
643
|
-
return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType,
|
|
642
|
+
async function getRefObjectRelationship(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
|
|
643
|
+
return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType, bucketName).then(res => {
|
|
644
644
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
645
645
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
646
646
|
} else {
|
|
@@ -674,8 +674,8 @@ const getRefObjectRelationshipWithCache = inMemoryCacheLib(
|
|
|
674
674
|
* @returns {Promise<{item:object|null,location:string|null}>} - item: relationship data, location: actual serviceTag that relationship located
|
|
675
675
|
*
|
|
676
676
|
*/
|
|
677
|
-
async function getRelationshipSchema(_izContext, relType) {
|
|
678
|
-
return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType,
|
|
677
|
+
async function getRelationshipSchema(_izContext, relType, bucketName = process.env.iz_serviceSchemaBucketName) {
|
|
678
|
+
return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType, bucketName).then(res => {
|
|
679
679
|
if (res.errorsFound.length && res.errorsFound.length > 0) {
|
|
680
680
|
throw new NoRetryError(res.errorsFound.join(","))
|
|
681
681
|
} else {
|
package/src/ServiceConfig.js
CHANGED
|
@@ -82,13 +82,14 @@ const getServiceNameWithCache = inMemoryCacheLib(
|
|
|
82
82
|
async function getGraphServiceTag(
|
|
83
83
|
_izContext,
|
|
84
84
|
graphServerTag,
|
|
85
|
+
bucketName = process.env.iz_serviceSchemaBucketName
|
|
85
86
|
) {
|
|
86
87
|
|
|
87
88
|
// get all graph serverTag
|
|
88
89
|
let [serverTags] = await getObjectS3(
|
|
89
90
|
_izContext,
|
|
90
91
|
{
|
|
91
|
-
Bucket:
|
|
92
|
+
Bucket: bucketName,
|
|
92
93
|
Key: UPLOAD_PATH_S3.graphServerTagsConfig
|
|
93
94
|
}
|
|
94
95
|
);
|
package/src/SharedUtils.js
CHANGED
|
@@ -475,7 +475,7 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
|
|
|
475
475
|
storageResourceTags,
|
|
476
476
|
objectRelationships,
|
|
477
477
|
relationshipSchema,
|
|
478
|
-
|
|
478
|
+
process.env.iz_serviceSchemaBucketName
|
|
479
479
|
);
|
|
480
480
|
results.push(...firstNodeResults);
|
|
481
481
|
} catch (error) {
|
package/src/UploadObjSchema.js
CHANGED
|
@@ -93,7 +93,7 @@ async function uploadObjectToS3(
|
|
|
93
93
|
const Key = pathToUpload
|
|
94
94
|
|
|
95
95
|
let data = {
|
|
96
|
-
Bucket: process.env.iz_serviceSchemaBucketName,
|
|
96
|
+
Bucket: process.env.iz_serviceSchemaBucketName || OBJECT_SCHEMA_BUCKET_NAME,
|
|
97
97
|
Key,
|
|
98
98
|
Body: buffer,
|
|
99
99
|
ContentEncoding: 'base64',
|
package/src/ValidatorSchema.js
CHANGED
|
@@ -466,7 +466,7 @@ async function generateValidatorSchemaForCreate(_izContext, objType, settings =
|
|
|
466
466
|
// ------- create return validatorSchema -------
|
|
467
467
|
let validatorSchemaForCreate = {
|
|
468
468
|
type: "object",
|
|
469
|
-
required: ["fieldNames"],
|
|
469
|
+
required: ["fieldNames", "objectType"],
|
|
470
470
|
properties: {
|
|
471
471
|
fieldNames: {
|
|
472
472
|
additionalProperties: false,
|
|
@@ -476,6 +476,10 @@ async function generateValidatorSchemaForCreate(_izContext, objType, settings =
|
|
|
476
476
|
...allValidatorSchemaFieldNames
|
|
477
477
|
}
|
|
478
478
|
},
|
|
479
|
+
objectType: {
|
|
480
|
+
type: "string",
|
|
481
|
+
pattern: "^[a-zA-Z0-9_-]+$"
|
|
482
|
+
},
|
|
479
483
|
additionalParams: {
|
|
480
484
|
type: "object"
|
|
481
485
|
}
|
|
@@ -555,8 +559,12 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
|
|
|
555
559
|
|
|
556
560
|
let initialValidatorSchemaForUpdate = {
|
|
557
561
|
type: "object",
|
|
558
|
-
required: ["objInstanceFull"],
|
|
562
|
+
required: ["objInstanceFull", "objectType"],
|
|
559
563
|
properties: {
|
|
564
|
+
objectType: {
|
|
565
|
+
type: "string",
|
|
566
|
+
pattern: "^[a-zA-Z0-9_-]+$"
|
|
567
|
+
},
|
|
560
568
|
objInstanceFull: {
|
|
561
569
|
type: "object",
|
|
562
570
|
required: ["identifiers", "fields"],
|
|
@@ -640,8 +648,12 @@ async function generateValidatorSchemaForIdentifier(_izContext, objType, setting
|
|
|
640
648
|
|
|
641
649
|
return {
|
|
642
650
|
type: "object",
|
|
643
|
-
required: ["identifiers"],
|
|
651
|
+
required: ["identifiers", "objectType"],
|
|
644
652
|
properties: {
|
|
653
|
+
objectType: {
|
|
654
|
+
type: "string",
|
|
655
|
+
pattern: "^[a-zA-Z0-9_-]+$"
|
|
656
|
+
},
|
|
645
657
|
identifiers: {
|
|
646
658
|
type: "object",
|
|
647
659
|
required: Object.keys(generatedIdentifiersValidatorSchema),
|
|
@@ -969,7 +981,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
|
969
981
|
const storageResource = objSchema.storageResources[storageTag];
|
|
970
982
|
|
|
971
983
|
if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
972
|
-
const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag);
|
|
984
|
+
const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag, iz_serviceSchemaBucketName);
|
|
973
985
|
|
|
974
986
|
if (!graphServiceTag) {
|
|
975
987
|
validateStatus.status = false;
|
|
@@ -1040,7 +1052,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
|
1040
1052
|
const storageResource = relData.storageResources[storageTag];
|
|
1041
1053
|
|
|
1042
1054
|
if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
1043
|
-
const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag);
|
|
1055
|
+
const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag, iz_serviceSchemaBucketName);
|
|
1044
1056
|
|
|
1045
1057
|
if (!graphServiceTag) {
|
|
1046
1058
|
validateStatus.status = false;
|
|
@@ -43,11 +43,10 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
|
|
|
43
43
|
[fieldName]: {},
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
if (
|
|
46
|
+
if (objType) {
|
|
47
47
|
Object.assign(deliminatorTree[fieldName], objType);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
51
50
|
// ------- create tree first -------
|
|
52
51
|
|
|
53
52
|
if (fieldNameSetting.fromServiceNameTag && fieldNameSetting.fromObjectType) {
|
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, bucketName) {
|
|
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) {
|
|
|
73
73
|
|
|
74
74
|
// build params for getObjectS3
|
|
75
75
|
let getDataParam = {
|
|
76
|
-
Bucket: process.env.iz_serviceSchemaBucketName,
|
|
76
|
+
Bucket: bucketName || process.env.iz_serviceSchemaBucketName || OBJECT_SCHEMA_BUCKET_NAME,
|
|
77
77
|
Key: SCHEMA_NAME_PER_S3_PATH[params.schemaName](params.getParams)
|
|
78
78
|
};
|
|
79
79
|
|