@izara_project/izara-core-library-service-schemas 1.0.101 → 1.0.102
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/GetObjectSchema.js +22 -25
- package/src/Utils.js +5 -5
- package/src/ValidatorSchema.js +3 -3
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.102",
|
|
4
4
|
"description": "Schemas for the service and objects it controls",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
},
|
|
22
22
|
"type": "module",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@aws-sdk/client-api-gateway": "^3.
|
|
25
|
-
"@aws-sdk/client-apigatewayv2": "^3.
|
|
26
|
-
"@aws-sdk/client-lambda": "^3.
|
|
27
|
-
"@aws-sdk/client-s3": "^3.
|
|
24
|
+
"@aws-sdk/client-api-gateway": "^3.933.0",
|
|
25
|
+
"@aws-sdk/client-apigatewayv2": "^3.933.0",
|
|
26
|
+
"@aws-sdk/client-lambda": "^3.933.0",
|
|
27
|
+
"@aws-sdk/client-s3": "^3.933.0",
|
|
28
28
|
"@aws-sdk/crc64-nvme-crt": "^3.932.0",
|
|
29
29
|
"@izara_project/izara-core-library-core": "^1.0.28",
|
|
30
30
|
"@izara_project/izara-core-library-external-request": "^1.0.22",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@izara_project/izara-core-library-logger": "^1.0.8",
|
|
33
33
|
"@izara_project/izara-shared-core": "^1.0.5",
|
|
34
34
|
"@izara_project/izara-shared-service-schemas": "^1.0.33",
|
|
35
|
-
"glob": "^
|
|
35
|
+
"glob": "^12.0.0",
|
|
36
36
|
"lodash": "^4.17.21",
|
|
37
37
|
"read-yaml-file": "^2.1.0"
|
|
38
38
|
}
|
package/src/GetObjectSchema.js
CHANGED
|
@@ -20,6 +20,7 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
20
20
|
|
|
21
21
|
import { glob } from 'glob';
|
|
22
22
|
import path from 'path';
|
|
23
|
+
import { pathToFileURL } from 'url';
|
|
23
24
|
import lodash from 'lodash';
|
|
24
25
|
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
25
26
|
import { getObjectSchema, validateObjType } from "@izara_project/izara-shared-service-schemas";
|
|
@@ -45,7 +46,7 @@ import lambdaUtils from './libs/LambdaUtils.js';
|
|
|
45
46
|
* @param {Boolean} setting.onNotFoundError - optional, default = false -- if true will throw error when not find any file
|
|
46
47
|
* @returns - array of data
|
|
47
48
|
*/
|
|
48
|
-
function getDataFromPath(
|
|
49
|
+
async function getDataFromPath(
|
|
49
50
|
_izContext,
|
|
50
51
|
fileName,
|
|
51
52
|
fileStoragePath,
|
|
@@ -69,7 +70,7 @@ function getDataFromPath(
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
// list exists file path from fileStoragePath path
|
|
72
|
-
const allFilePath = glob
|
|
73
|
+
const allFilePath = await glob(`**/${fileName}`, { cwd: fileStoragePath, dot: true });
|
|
73
74
|
|
|
74
75
|
// validate fileLimit
|
|
75
76
|
if (fileLimit && allFilePath.length > fileLimit) {
|
|
@@ -77,8 +78,13 @@ function getDataFromPath(
|
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
if (allFilePath.length > 0) {
|
|
80
|
-
const allFileData = allFilePath.map(file => require(path.join(fileStoragePath, file)));
|
|
81
|
-
|
|
81
|
+
// const allFileData = allFilePath.map(file => require(path.join(fileStoragePath, file)));
|
|
82
|
+
const allFileData = await Promise.all(allFilePath.map(async (file) => {
|
|
83
|
+
let data = await import(pathToFileURL(path.join(fileStoragePath, file)).href);
|
|
84
|
+
data = data.default;
|
|
85
|
+
return data;
|
|
86
|
+
}))
|
|
87
|
+
return allFileData.flat();
|
|
82
88
|
} else {
|
|
83
89
|
|
|
84
90
|
if (onNotFoundError === true) {
|
|
@@ -89,7 +95,7 @@ function getDataFromPath(
|
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
|
|
92
|
-
//
|
|
98
|
+
// currently not use
|
|
93
99
|
// /**
|
|
94
100
|
// * get data from file ObjectTypes.js depend on path
|
|
95
101
|
// *
|
|
@@ -168,12 +174,10 @@ async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = co
|
|
|
168
174
|
// returnValue.fieldLookup[objectType] = null;
|
|
169
175
|
}
|
|
170
176
|
|
|
171
|
-
let allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
|
|
172
|
-
.flat()
|
|
177
|
+
let allObjectSchemas = lodash.cloneDeep((await getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)).flat()
|
|
173
178
|
.filter(schema => filteredObjectTypes.includes(schema.objectType))
|
|
174
179
|
);
|
|
175
180
|
|
|
176
|
-
|
|
177
181
|
// add extendObjectType before assign to returnValue object
|
|
178
182
|
if (getExtendObType) {
|
|
179
183
|
await Promise.all(
|
|
@@ -250,11 +254,9 @@ async function getAllLocalObjectSchemas(_izContext, objSchemaPath = consts.LOCAL
|
|
|
250
254
|
|
|
251
255
|
// const objectTypeList = getObjectTypes(_izContext, objSchemaPath)
|
|
252
256
|
|
|
253
|
-
const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
|
|
254
|
-
.flat()
|
|
257
|
+
const allObjectSchemas = lodash.cloneDeep((await getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)).flat()
|
|
255
258
|
// .filter(schema => objectTypeList.includes(schema.objectType))
|
|
256
259
|
);
|
|
257
|
-
|
|
258
260
|
// check objectType that not found in ObjectFieldSchema.js
|
|
259
261
|
// const remainingObjectTypes = objectTypeList.filter(objectType => !allObjectSchemas.some(schema => schema.objectType === objectType));
|
|
260
262
|
|
|
@@ -327,7 +329,7 @@ async function getLambdaFunctionNames(_izContext) {
|
|
|
327
329
|
try {
|
|
328
330
|
_izContext.logger.debug("-- function getLambdaFunctionNames --");
|
|
329
331
|
|
|
330
|
-
const LambdaFunctions = getDataFromPath(_izContext, consts.LOCAL_FILENAME.LAMBDA_FUNCTIONS, consts.LOCAL_OBJECT_SCHEMA_PATH, {
|
|
332
|
+
const LambdaFunctions = await getDataFromPath(_izContext, consts.LOCAL_FILENAME.LAMBDA_FUNCTIONS, consts.LOCAL_OBJECT_SCHEMA_PATH, {
|
|
331
333
|
fileLimit: 1
|
|
332
334
|
})[0];
|
|
333
335
|
_izContext.logger.debug("LambdaFunctions: ", LambdaFunctions);
|
|
@@ -537,7 +539,7 @@ const getObjectSchemaCombineFieldNamesWithCache = inMemoryCacheLib(
|
|
|
537
539
|
* @param {String} [objSchemaPath] - Optional default = './src/schemas', need objSchemaPath if use in local machine
|
|
538
540
|
* @returns {Object} - specific relationship schema
|
|
539
541
|
*/
|
|
540
|
-
function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
|
|
542
|
+
async function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
|
|
541
543
|
|
|
542
544
|
// validate objectTypes
|
|
543
545
|
if (!relationshipTags) {
|
|
@@ -553,7 +555,7 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
|
|
|
553
555
|
}
|
|
554
556
|
|
|
555
557
|
|
|
556
|
-
const objectRelationshipDatas = getDataFromPath(
|
|
558
|
+
const objectRelationshipDatas = await getDataFromPath(
|
|
557
559
|
_izContext,
|
|
558
560
|
consts.LOCAL_FILENAME.OBJECT_RELATIONSHIPS,
|
|
559
561
|
objSchemaPath,
|
|
@@ -932,7 +934,7 @@ async function getAllLocalFlowSchemas(_izContext, flowSchemaPath = consts.LOCAL_
|
|
|
932
934
|
fieldLookup: {}
|
|
933
935
|
}
|
|
934
936
|
|
|
935
|
-
const allFlowSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.FLOW_SCHEMA, flowSchemaPath).flat());
|
|
937
|
+
const allFlowSchemas = lodash.cloneDeep((await getDataFromPath(_izContext, consts.LOCAL_FILENAME.FLOW_SCHEMA, flowSchemaPath)).flat());
|
|
936
938
|
_izContext.logger.debug("allFlowSchemas::", allFlowSchemas)
|
|
937
939
|
for (let [idx, flowSchema] of allFlowSchemas.entries()) {
|
|
938
940
|
if (!returnValue.fieldLookup.hasOwnProperty(flowSchema.flowTag)) {
|
|
@@ -973,8 +975,7 @@ async function getLocalFlowSchemas(_izContext, flowTags, flowSchemaPath = consts
|
|
|
973
975
|
filteredFlowTags.push(flowTag)
|
|
974
976
|
}
|
|
975
977
|
|
|
976
|
-
const filterFlowSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.FLOW_SCHEMA, flowSchemaPath)
|
|
977
|
-
.flat()
|
|
978
|
+
const filterFlowSchemas = lodash.cloneDeep((await getDataFromPath(_izContext, consts.LOCAL_FILENAME.FLOW_SCHEMA, flowSchemaPath)).flat()
|
|
978
979
|
.filter(schema => filteredFlowTags.includes(schema.flowTag))
|
|
979
980
|
);
|
|
980
981
|
_izContext.logger.debug("filterFlowSchemas::", filterFlowSchemas)
|
|
@@ -1029,20 +1030,16 @@ const getFlowSchemaS3WithCache = inMemoryCacheLib(
|
|
|
1029
1030
|
}
|
|
1030
1031
|
)
|
|
1031
1032
|
|
|
1032
|
-
function getAllLocalRelationshipSchema(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
|
|
1033
|
+
async function getAllLocalRelationshipSchema(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
|
|
1033
1034
|
|
|
1034
|
-
const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_RELATIONSHIPS, objSchemaPath)
|
|
1035
|
-
.flat()
|
|
1036
|
-
);
|
|
1035
|
+
const allObjectSchemas = lodash.cloneDeep((await getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_RELATIONSHIPS, objSchemaPath)).flat());
|
|
1037
1036
|
|
|
1038
1037
|
return allObjectSchemas
|
|
1039
1038
|
}
|
|
1040
1039
|
|
|
1041
|
-
function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
|
|
1040
|
+
async function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
|
|
1042
1041
|
|
|
1043
|
-
const allRefObjectRelationshipSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.REFERENCE_OBJECT_RELATIONSHIPS, objSchemaPath)
|
|
1044
|
-
.flat()
|
|
1045
|
-
);
|
|
1042
|
+
const allRefObjectRelationshipSchemas = lodash.cloneDeep((await getDataFromPath(_izContext, consts.LOCAL_FILENAME.REFERENCE_OBJECT_RELATIONSHIPS, objSchemaPath)).flat());
|
|
1046
1043
|
|
|
1047
1044
|
return allRefObjectRelationshipSchemas
|
|
1048
1045
|
|
package/src/Utils.js
CHANGED
|
@@ -117,7 +117,7 @@ function getUsedFieldNamesOfIdentifiers(_izContext, identifiers, identifierTypes
|
|
|
117
117
|
|
|
118
118
|
function validateBasicObjectSchema(_izContext, objectSchema) {
|
|
119
119
|
|
|
120
|
-
const validateStatus = validator
|
|
120
|
+
const validateStatus = validator(basicValidatorSchema.basicObjectSchema, objectSchema, null, { strict: false });
|
|
121
121
|
|
|
122
122
|
if (validateStatus.pass) {
|
|
123
123
|
let errors = []
|
|
@@ -235,7 +235,7 @@ function validateBasicObjectSchema(_izContext, objectSchema) {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
function validateExtendObjectSchema(_izContext, extendObjectSchema) {
|
|
238
|
-
let validateStatus = validator
|
|
238
|
+
let validateStatus = validator(basicValidatorSchema.basicExtendObjectSchema, extendObjectSchema, null, { strict: false });
|
|
239
239
|
|
|
240
240
|
if (validateStatus.pass) {
|
|
241
241
|
let errors = []
|
|
@@ -364,7 +364,7 @@ function validateObjectSchema(_izContext, objectSchema) {
|
|
|
364
364
|
|
|
365
365
|
|
|
366
366
|
function validateRelationshipSchema(_izContext, relationshipSchema) {
|
|
367
|
-
let validateStatus = validator
|
|
367
|
+
let validateStatus = validator(basicValidatorSchema.relationshipBasicSchema, relationshipSchema, null, { strict: false });
|
|
368
368
|
|
|
369
369
|
const relationshipTag = Object.keys(relationshipSchema)[0];
|
|
370
370
|
_izContext.logger.debug("relationshipSchema: ", relationshipSchema);
|
|
@@ -418,7 +418,7 @@ function validateRelationshipSchema(_izContext, relationshipSchema) {
|
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
function validateRefRelationshipSchema(_izContext, refRelationshipSchema, serviceTag) {
|
|
421
|
-
let validateStatus = validator
|
|
421
|
+
let validateStatus = validator(basicValidatorSchema.refRelationshipBasicSchema, refRelationshipSchema, null, { strict: false });
|
|
422
422
|
if (validateStatus.pass) {
|
|
423
423
|
if (!serviceTag) {
|
|
424
424
|
serviceTag = process.env.iz_serviceTag
|
|
@@ -646,7 +646,7 @@ function createLinkTypeId(_izContext, firstObjType, secondObjType, relType, dire
|
|
|
646
646
|
}
|
|
647
647
|
|
|
648
648
|
function validateBasicFlowSchema(_izContext, flowSchema) {
|
|
649
|
-
const validateStatus = validator
|
|
649
|
+
const validateStatus = validator(basicValidatorSchema.basicFlowSchema, flowSchema, null, { strict: false });
|
|
650
650
|
|
|
651
651
|
if (validateStatus.pass) {
|
|
652
652
|
let errors = [];
|
package/src/ValidatorSchema.js
CHANGED
|
@@ -1023,10 +1023,10 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
|
1023
1023
|
}
|
|
1024
1024
|
|
|
1025
1025
|
const allObjectSchema = await getObjectSchema.getAllLocalObjectSchemasWithoutHierarchy(_izContext, schemasPath).then(res => res.records);
|
|
1026
|
-
const allObjectRelationships = getObjectSchema.getAllLocalRelationshipSchema(_izContext, schemasPath);
|
|
1027
|
-
const allReferenceObjectRelationships = getObjectSchema.getAllLocalRefObjectRelationshipSchema(_izContext, schemasPath);
|
|
1026
|
+
const allObjectRelationships = await getObjectSchema.getAllLocalRelationshipSchema(_izContext, schemasPath);
|
|
1027
|
+
const allReferenceObjectRelationships = await getObjectSchema.getAllLocalRefObjectRelationshipSchema(_izContext, schemasPath);
|
|
1028
1028
|
const allFlowSchemas = await getObjectSchema.getAllLocalFlowSchemas(_izContext, schemasPath).then(res => res.records);
|
|
1029
|
-
|
|
1029
|
+
// console.log({ allObjectSchema, allObjectRelationships, allReferenceObjectRelationships, allFlowSchemas })
|
|
1030
1030
|
// validate all schema
|
|
1031
1031
|
for (const objSchema of allObjectSchema) {
|
|
1032
1032
|
const [status, errors] = utils.validateObjectSchema(_izContext, objSchema);
|