@izara_project/izara-core-library-service-schemas 1.0.64 → 1.0.66
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 +2 -2
- package/src/UploadObjSchema.js +12 -9
- package/src/ValidatorSchema.js +36 -97
- package/src/libs/CreateNodeLib.js +19 -1
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.66",
|
|
4
4
|
"description": "Schemas for the service and objects it controls",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@izara_project/izara-core-library-lambda": "^1.0.4",
|
|
29
29
|
"@izara_project/izara-core-library-logger": "^1.0.7",
|
|
30
30
|
"@izara_project/izara-shared-core": "^1.0.2",
|
|
31
|
-
"@izara_project/izara-shared-service-schemas": "^1.0.
|
|
31
|
+
"@izara_project/izara-shared-service-schemas": "^1.0.15",
|
|
32
32
|
"glob": "^11.0.2",
|
|
33
33
|
"lodash": "^4.17.21",
|
|
34
34
|
"object-hash": "^3.0.0",
|
package/src/UploadObjSchema.js
CHANGED
|
@@ -392,11 +392,12 @@ async function uploadObjectSchemaByUseCase(_izContext) {
|
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
let serviceTag = objectSchema.extendObjType ? objectSchema.extendObjType.serviceTag : process.env.iz_serviceTag;
|
|
395
396
|
if (graphServerTags.size) {
|
|
396
397
|
createdBys.push({
|
|
397
398
|
objType: {
|
|
398
399
|
objectType: objectSchema.objectType,
|
|
399
|
-
serviceTag:
|
|
400
|
+
serviceTag: serviceTag
|
|
400
401
|
},
|
|
401
402
|
graphServerTags: [...graphServerTags]
|
|
402
403
|
})
|
|
@@ -515,14 +516,16 @@ async function uploadObjectSchemaByUseCase(_izContext) {
|
|
|
515
516
|
}
|
|
516
517
|
}
|
|
517
518
|
}// per relationshipTag
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
await
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
519
|
+
|
|
520
|
+
if (setRelationships.size > 0) {
|
|
521
|
+
let arrayRelationships = [...setRelationships]
|
|
522
|
+
await lambda.invokeSync(_izContext,
|
|
523
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, "CreatePermissionHdrInv", "TranslateIds"),
|
|
524
|
+
{
|
|
525
|
+
relationships: arrayRelationships
|
|
526
|
+
}
|
|
527
|
+
)
|
|
528
|
+
}
|
|
526
529
|
|
|
527
530
|
const linksPerObjectTyjpe = groupLinksPerObjectType(_izContext, allObjectRelationships, foundedObjectTypes)
|
|
528
531
|
|
package/src/ValidatorSchema.js
CHANGED
|
@@ -976,7 +976,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
|
976
976
|
}
|
|
977
977
|
for (const [fieldName, fieldNameSetting] of Object.entries(objSchema.fieldNames)) {
|
|
978
978
|
if (fieldNameSetting.type === "string" || fieldNameSetting.type === "object" || fieldNameSetting.type === "number") {
|
|
979
|
-
if (fieldNameSetting
|
|
979
|
+
if (fieldNameSetting?.validation?.hasOwnProperty("itemValidation")) {
|
|
980
980
|
validateStatus.status = false;
|
|
981
981
|
validateStatus.validateErrors.push(`fieldName: ${fieldName} should not have itemValidation for ${fieldNameSetting.type} type`);
|
|
982
982
|
}
|
|
@@ -1048,32 +1048,33 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
|
1048
1048
|
}
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
}
|
|
1051
|
+
//! reject no more cross check
|
|
1052
|
+
// if (relData.canChangeToRelType) {
|
|
1053
|
+
// let canChangeToRelSchema = null
|
|
1054
|
+
// if (relData.canChangeToRelType.serviceTag === iz_serviceTag) {
|
|
1055
|
+
// let canChangeRelSchemaLocal = await getLocalRelationshipSchemas(_izContext, [relData.canChangeToRelType.relationshipTag], schemasPath)
|
|
1056
|
+
// if (Object.keys(canChangeRelSchemaLocal).length) {
|
|
1057
|
+
// canChangeToRelSchema = canChangeRelSchemaLocal[relData.canChangeToRelType.relationshipTag]
|
|
1058
|
+
// }
|
|
1059
|
+
// } else {
|
|
1060
|
+
// canChangeToRelSchema = await getRelationshipSchema(_izContext, { relationshipTag: relData.canChangeToRelType.relationshipTag, serviceTag: relData.canChangeToRelType.serviceTag }) // return {}
|
|
1061
|
+
// }
|
|
1062
|
+
|
|
1063
|
+
// if (!canChangeToRelSchema || !Object.keys(canChangeToRelSchema).length) {
|
|
1064
|
+
// validateStatus.status = false;
|
|
1065
|
+
// validateStatus.validateErrors.push(`Relationship:${relTagName}/canChangeToRelType targetRelType ${JSON.stringify(relData.canChangeToRelType)} not exist`);
|
|
1066
|
+
// } else {
|
|
1067
|
+
// if (!canChangeToRelSchema.hasOwnProperty("canChangeToRelType")) {
|
|
1068
|
+
// validateStatus.status = false;
|
|
1069
|
+
// validateStatus.validateErrors.push(`RelType:${JSON.stringify(relData.canChangeToRelType)} not have setting canChangeToRelType`);
|
|
1070
|
+
// } else {
|
|
1071
|
+
// if (canChangeToRelSchema.canChangeToRelType.serviceTag !== iz_serviceTag || canChangeToRelSchema.canChangeToRelType.relationshipTag !== relTagName) {
|
|
1072
|
+
// validateStatus.status = false;
|
|
1073
|
+
// validateStatus.validateErrors.push(`RelType:${JSON.stringify(relData.canChangeToRelType)} not have reference to RelType:${JSON.stringify({ serviceTag: iz_serviceTag, relationshipTag: relTagName })} `);
|
|
1074
|
+
// }
|
|
1075
|
+
// }
|
|
1076
|
+
// }
|
|
1077
|
+
// }
|
|
1077
1078
|
|
|
1078
1079
|
|
|
1079
1080
|
/*
|
|
@@ -1150,83 +1151,21 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
|
1150
1151
|
if (allFlowSchemas) {
|
|
1151
1152
|
for (const flowSchema of allFlowSchemas) {
|
|
1152
1153
|
const [status, errors] = validateBasicFlowSchema(_izContext, flowSchema)
|
|
1153
|
-
if (flowSchema.hasOwnProperty("uploadS3") && flowSchema.uploadS3 === true) {
|
|
1154
|
-
if (!flowSchema.hasOwnProperty("objType")) {
|
|
1155
|
-
validateStatus.status = false;
|
|
1156
|
-
validateStatus.validateErrors.push(
|
|
1157
|
-
`${flowSchema.flowTag} have uploadS3 case must have objType`
|
|
1158
|
-
)
|
|
1159
|
-
}
|
|
1160
|
-
if (!flowSchema.hasOwnProperty("uploadType")) {
|
|
1161
|
-
validateStatus.status = false;
|
|
1162
|
-
validateStatus.validateErrors.push(
|
|
1163
|
-
`${flowSchema.flowTag} must have upload type`
|
|
1164
|
-
)
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
1154
|
|
|
1168
|
-
if (flowSchema.
|
|
1169
|
-
if (flowSchema.
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
validateStatus.validateErrors.push(
|
|
1173
|
-
`${flowSchema.flowTag} must have storageResource to get result`
|
|
1174
|
-
)
|
|
1175
|
-
}
|
|
1155
|
+
if (flowSchema.handleObj === "multi") {
|
|
1156
|
+
if (flowSchema.outputTopic === true) {
|
|
1157
|
+
validateStatus.status = false;
|
|
1158
|
+
validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} should not have outputTopic if handleObj === true`)
|
|
1176
1159
|
}
|
|
1177
1160
|
}
|
|
1178
1161
|
|
|
1179
|
-
if (flowSchema.
|
|
1180
|
-
if (
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
validateStatus.validateErrors.push(
|
|
1184
|
-
`${flowSchema.flowTag} must have uploadS3 setting true to select uploadType`
|
|
1185
|
-
)
|
|
1186
|
-
}
|
|
1162
|
+
if (flowSchema.statusType === "storedCache" || flowSchema.statusType === "statusField" || flowSchema.statusType === "triggerCache") {
|
|
1163
|
+
if (!flowSchema.hasOwnProperty("objType")) {
|
|
1164
|
+
validateStatus.status = false;
|
|
1165
|
+
validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} must have objType`)
|
|
1187
1166
|
}
|
|
1188
1167
|
}
|
|
1189
1168
|
|
|
1190
|
-
if (flowSchema.hook) {
|
|
1191
|
-
await Promise.all(
|
|
1192
|
-
Object.entries(flowSchema.hook).map(async ([hookName, hookProperties]) => {
|
|
1193
|
-
if (!(Object.values(FLOW_SCHEMA_HOOK_STATE).includes(hookName))) {
|
|
1194
|
-
validateStatus.status = false;
|
|
1195
|
-
validateStatus.validateErrors.push(
|
|
1196
|
-
`${hookName} is invalid`
|
|
1197
|
-
);
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
await Promise.all(
|
|
1201
|
-
hookProperties.functionList.map(async (hookFunction) => {
|
|
1202
|
-
if (hookFunction.event.handlerType === HANDLER.hdrSqs) {
|
|
1203
|
-
if (!hookFunction.event.hasOwnProperty("topicName")) {
|
|
1204
|
-
validateStatus.status = false;
|
|
1205
|
-
validateStatus.validateErrors.push(
|
|
1206
|
-
`${hookName}.${hookFunction.functionName} must have topicName`
|
|
1207
|
-
);
|
|
1208
|
-
}
|
|
1209
|
-
} else if (hookFunction.event.handlerType === HANDLER.hdrDsq) {
|
|
1210
|
-
if (!hookFunction.event.hasOwnProperty("queueName")) {
|
|
1211
|
-
validateStatus.status = false;
|
|
1212
|
-
validateStatus.validateErrors.push(
|
|
1213
|
-
`${hookName}.${hookFunction.functionName} must have queueName`
|
|
1214
|
-
);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
if (hookFunction.event.hasOwnProperty("topicName") && hookFunction.event.hasOwnProperty("queueName")) {
|
|
1219
|
-
validateStatus.status = false;
|
|
1220
|
-
validateStatus.validateErrors.push(
|
|
1221
|
-
`${hookName}.${hookFunction.functionName} must have only one of topicName or queueName`
|
|
1222
|
-
);
|
|
1223
|
-
}
|
|
1224
|
-
})
|
|
1225
|
-
);
|
|
1226
|
-
})
|
|
1227
|
-
);
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
1169
|
if (!status) {
|
|
1231
1170
|
validateStatus.status = false;
|
|
1232
1171
|
validateStatus.validateErrors.push(errors);
|
|
@@ -20,9 +20,21 @@ const { createRelTypeConcat, createLinkTypeId } = require('../Utils');
|
|
|
20
20
|
const getObjectSchema = require('../GetObjectSchema');
|
|
21
21
|
const serviceConfig = require('../ServiceConfig');
|
|
22
22
|
const { STORAGE_TYPES } = require('../Consts')
|
|
23
|
+
const { createObjTypeHierarchy } = require('../libs/RelSchemaLib')
|
|
23
24
|
|
|
24
25
|
async function validateRequiredOnCreateLinks(_izContext, objType, relationships, settings = {}) {
|
|
25
26
|
_izContext.logger.debug("validateRequiredOnCreateLinks:::", { objType, relationships, settings })
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
let objectHie = await createObjTypeHierarchy(_izContext, objType);
|
|
30
|
+
_izContext.logger.debug("objectHierarchy::", objectHie)
|
|
31
|
+
|
|
32
|
+
if (relationships.length) {
|
|
33
|
+
let targetHierarchy = await createObjTypeHierarchy(_izContext, relationships[0].targetObjType);
|
|
34
|
+
_izContext.logger.debug("targetHierarchy::", targetHierarchy)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
26
38
|
let errorFound = [];
|
|
27
39
|
|
|
28
40
|
let requiredOnCreateLinks = await getObjectSchema.getRequiredOnCreateLinksWithCache(_izContext, objType)
|
|
@@ -78,7 +90,13 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships,
|
|
|
78
90
|
|
|
79
91
|
for (let link of usedLinkGroup) {
|
|
80
92
|
// check other with targetObjType, check linkType of other should be 'one',
|
|
81
|
-
|
|
93
|
+
let targetObjTypeHierarchy = await createObjTypeHierarchy(_izContext, relationship.targetObjType);
|
|
94
|
+
_izContext.logger.debug(" ::", targetObjTypeHierarchy)
|
|
95
|
+
|
|
96
|
+
// if (link.other.objType.objectType === relationship.targetObjType.objectType) {
|
|
97
|
+
if (targetObjTypeHierarchy.some(objType =>
|
|
98
|
+
objType.objectType === link.other.objType.objectType && objType.serviceTag === link.other.objType.serviceTag)
|
|
99
|
+
) {
|
|
82
100
|
if (link.other.linkType === "one") {
|
|
83
101
|
if (!validateOnCreateRelationships.has(`${relTypeConcat}_${relationship.relationshipDirection}`)) {
|
|
84
102
|
validateOnCreateRelationships.add(`${relTypeConcat}_${relationship.relationshipDirection}`)
|