@izara_project/izara-core-library-service-schemas 1.0.65 → 1.0.67
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 +59 -59
- package/src/Utils.js +10 -0
- 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.67",
|
|
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
|
@@ -256,76 +256,75 @@ async function uploadObjectSchemaByUseCase(_izContext) {
|
|
|
256
256
|
|
|
257
257
|
for (let objSchema of allObjectSchema) {
|
|
258
258
|
// ignore objSchema that not has properties in fieldNames
|
|
259
|
-
if (objSchema.hasOwnProperty("fieldNames") && Object.keys(objSchema.fieldNames).length) {
|
|
260
259
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
// case All
|
|
261
|
+
uploadList.push(
|
|
262
|
+
uploadObjectToS3(
|
|
263
|
+
_izContext,
|
|
264
|
+
UPLOAD_PATH_S3.objectSchemaAll(
|
|
264
265
|
_izContext,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
)
|
|
274
|
-
);
|
|
266
|
+
{
|
|
267
|
+
serviceTag: process.env.iz_serviceTag,
|
|
268
|
+
objectType: objSchema.objectType
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
objSchema
|
|
272
|
+
)
|
|
273
|
+
);
|
|
275
274
|
|
|
276
275
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
276
|
+
// case create
|
|
277
|
+
let createFieldSchema = generateObjectSchemaForCreate(_izContext, objSchema);
|
|
278
|
+
uploadList.push(
|
|
279
|
+
uploadObjectToS3(
|
|
280
|
+
_izContext,
|
|
281
|
+
UPLOAD_PATH_S3.objectSchemaCreate(
|
|
281
282
|
_izContext,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
)
|
|
291
|
-
);
|
|
283
|
+
{
|
|
284
|
+
serviceTag: process.env.iz_serviceTag,
|
|
285
|
+
objectType: createFieldSchema.objectType
|
|
286
|
+
}
|
|
287
|
+
),
|
|
288
|
+
createFieldSchema
|
|
289
|
+
)
|
|
290
|
+
);
|
|
292
291
|
|
|
293
|
-
|
|
292
|
+
objectTypesForCreate.push(createFieldSchema.objectType);
|
|
294
293
|
|
|
295
294
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
295
|
+
// case update and display
|
|
296
|
+
let updateFieldSchema = generateObjectSchemaForUpdate(_izContext, objSchema);
|
|
297
|
+
uploadList.push(
|
|
298
|
+
uploadObjectToS3(
|
|
299
|
+
_izContext,
|
|
300
|
+
UPLOAD_PATH_S3.objectSchemaDisplay(
|
|
300
301
|
_izContext,
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
)
|
|
310
|
-
);
|
|
302
|
+
{
|
|
303
|
+
serviceTag: process.env.iz_serviceTag,
|
|
304
|
+
objectType: createFieldSchema.objectType
|
|
305
|
+
}
|
|
306
|
+
),
|
|
307
|
+
updateFieldSchema
|
|
308
|
+
)
|
|
309
|
+
);
|
|
311
310
|
|
|
312
311
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
312
|
+
// case schema combine fieldNames
|
|
313
|
+
let combineFieldNamesObjectSchema = generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
|
|
314
|
+
uploadList.push(
|
|
315
|
+
uploadObjectToS3(
|
|
316
|
+
_izContext,
|
|
317
|
+
UPLOAD_PATH_S3.objectSchemaCombineFieldNames(
|
|
317
318
|
_izContext,
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
);
|
|
328
|
-
}
|
|
319
|
+
{
|
|
320
|
+
serviceTag: process.env.iz_serviceTag,
|
|
321
|
+
objectType: combineFieldNamesObjectSchema.objectType
|
|
322
|
+
}
|
|
323
|
+
),
|
|
324
|
+
combineFieldNamesObjectSchema
|
|
325
|
+
)
|
|
326
|
+
);
|
|
327
|
+
|
|
329
328
|
|
|
330
329
|
// upload to refObjectRelationships for each objectType that have createBy at UserAccount Service and belongTo
|
|
331
330
|
let existsRefObjectRel = refRelationshipPerObjectType[objSchema.objectType];
|
|
@@ -392,11 +391,12 @@ async function uploadObjectSchemaByUseCase(_izContext) {
|
|
|
392
391
|
}
|
|
393
392
|
}
|
|
394
393
|
|
|
394
|
+
let serviceTag = objectSchema.extendObjType ? objectSchema.extendObjType.serviceTag : process.env.iz_serviceTag;
|
|
395
395
|
if (graphServerTags.size) {
|
|
396
396
|
createdBys.push({
|
|
397
397
|
objType: {
|
|
398
398
|
objectType: objectSchema.objectType,
|
|
399
|
-
serviceTag:
|
|
399
|
+
serviceTag: serviceTag
|
|
400
400
|
},
|
|
401
401
|
graphServerTags: [...graphServerTags]
|
|
402
402
|
})
|
package/src/Utils.js
CHANGED
|
@@ -339,6 +339,16 @@ function validateFieldNamesWithStorageResources(_izContext, objectSchema) {
|
|
|
339
339
|
* @returns {[boolean, string[]]} - [status, errors], errors will return when status=false
|
|
340
340
|
*/
|
|
341
341
|
function validateObjectSchema(_izContext, objectSchema) {
|
|
342
|
+
|
|
343
|
+
for (const storageResourceTag in objectSchema.storageResources) {
|
|
344
|
+
let storageResource = objectSchema.storageResources[storageResourceTag]
|
|
345
|
+
if (storageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
346
|
+
if (!storageResource.serviceTag) {
|
|
347
|
+
Object.assign(objectSchema.storageResources[storageResourceTag], { serviceTag: process.env.iz_serviceTag })
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
342
352
|
if (objectSchema.hasOwnProperty("extendObjType")) {
|
|
343
353
|
return validateExtendObjectSchema(_izContext, objectSchema)
|
|
344
354
|
} else {
|
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}`)
|