@izara_project/izara-core-library-service-schemas 1.0.91 → 1.0.94
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 +4 -4
- package/src/UploadObjSchema.js +52 -52
- package/src/ValidatorSchema.js +45 -38
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.94",
|
|
4
4
|
"description": "Schemas for the service and objects it controls",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@aws-sdk/client-lambda": "^3.862.0",
|
|
26
26
|
"@aws-sdk/client-s3": "^3.862.0",
|
|
27
27
|
"@aws-sdk/crc64-nvme-crt": "^3.862.0",
|
|
28
|
-
"@izara_project/izara-core-library-core": "^1.0.
|
|
29
|
-
"@izara_project/izara-core-library-external-request": "^1.0.
|
|
30
|
-
"@izara_project/izara-core-library-lambda": "^1.0.
|
|
28
|
+
"@izara_project/izara-core-library-core": "^1.0.24",
|
|
29
|
+
"@izara_project/izara-core-library-external-request": "^1.0.21",
|
|
30
|
+
"@izara_project/izara-core-library-lambda": "^1.0.5",
|
|
31
31
|
"@izara_project/izara-core-library-logger": "^1.0.7",
|
|
32
32
|
"@izara_project/izara-shared-core": "^1.0.2",
|
|
33
33
|
"@izara_project/izara-shared-service-schemas": "^1.0.30",
|
package/src/UploadObjSchema.js
CHANGED
|
@@ -275,58 +275,58 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
275
275
|
);
|
|
276
276
|
|
|
277
277
|
|
|
278
|
-
// case create
|
|
279
|
-
let createFieldSchema = generateObjectSchemaForCreate(_izContext, objSchema);
|
|
280
|
-
uploadList.push(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
);
|
|
293
|
-
|
|
294
|
-
objectTypesForCreate.push(createFieldSchema.objectType);
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
// case update and display
|
|
298
|
-
let updateFieldSchema = generateObjectSchemaForUpdate(_izContext, objSchema);
|
|
299
|
-
uploadList.push(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
// case schema combine fieldNames
|
|
315
|
-
let combineFieldNamesObjectSchema = generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
|
|
316
|
-
// console.log("combineFieldNamesObjectSchema", combineFieldNamesObjectSchema)
|
|
317
|
-
uploadList.push(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
);
|
|
278
|
+
// // case create
|
|
279
|
+
// let createFieldSchema = generateObjectSchemaForCreate(_izContext, objSchema);
|
|
280
|
+
// uploadList.push(
|
|
281
|
+
// uploadObjectToS3(
|
|
282
|
+
// _izContext,
|
|
283
|
+
// UPLOAD_PATH_S3.objectSchemaCreate(
|
|
284
|
+
// _izContext,
|
|
285
|
+
// {
|
|
286
|
+
// serviceTag: process.env.iz_serviceTag,
|
|
287
|
+
// objectType: createFieldSchema.objectType
|
|
288
|
+
// }
|
|
289
|
+
// ),
|
|
290
|
+
// createFieldSchema
|
|
291
|
+
// )
|
|
292
|
+
// );
|
|
293
|
+
|
|
294
|
+
// objectTypesForCreate.push(createFieldSchema.objectType);
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
// // case update and display
|
|
298
|
+
// let updateFieldSchema = generateObjectSchemaForUpdate(_izContext, objSchema);
|
|
299
|
+
// uploadList.push(
|
|
300
|
+
// uploadObjectToS3(
|
|
301
|
+
// _izContext,
|
|
302
|
+
// UPLOAD_PATH_S3.objectSchemaDisplay(
|
|
303
|
+
// _izContext,
|
|
304
|
+
// {
|
|
305
|
+
// serviceTag: process.env.iz_serviceTag,
|
|
306
|
+
// objectType: createFieldSchema.objectType
|
|
307
|
+
// }
|
|
308
|
+
// ),
|
|
309
|
+
// updateFieldSchema
|
|
310
|
+
// )
|
|
311
|
+
// );
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
// // case schema combine fieldNames
|
|
315
|
+
// let combineFieldNamesObjectSchema = generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
|
|
316
|
+
// // console.log("combineFieldNamesObjectSchema", combineFieldNamesObjectSchema)
|
|
317
|
+
// uploadList.push(
|
|
318
|
+
// uploadObjectToS3(
|
|
319
|
+
// _izContext,
|
|
320
|
+
// UPLOAD_PATH_S3.objectSchemaCombineFieldNames(
|
|
321
|
+
// _izContext,
|
|
322
|
+
// {
|
|
323
|
+
// serviceTag: process.env.iz_serviceTag,
|
|
324
|
+
// objectType: combineFieldNamesObjectSchema.objectType
|
|
325
|
+
// }
|
|
326
|
+
// ),
|
|
327
|
+
// combineFieldNamesObjectSchema
|
|
328
|
+
// )
|
|
329
|
+
// );
|
|
330
330
|
|
|
331
331
|
// upload to refObjectRelationships for each objectType that have createBy at UserAccount Service and belongTo
|
|
332
332
|
let existsRefObjectRel = refRelationshipPerObjectType[objSchema.objectType];
|
package/src/ValidatorSchema.js
CHANGED
|
@@ -533,7 +533,7 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
|
|
|
533
533
|
})
|
|
534
534
|
// const objType = createObjType(objectType);
|
|
535
535
|
const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
536
|
-
_izContext.logger.debug("objectSchema", objectSchema)
|
|
536
|
+
// _izContext.logger.debug("objectSchema", objectSchema)
|
|
537
537
|
|
|
538
538
|
const objectSchemas = await uploadUseCase.generateObjectSchemaForCombineFieldNames(_izContext, objectSchema)
|
|
539
539
|
_izContext.logger.debug("objectSchemas", objectSchemas)
|
|
@@ -573,7 +573,7 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
|
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
575
|
|
|
576
|
-
_izContext.logger.debug("canUpdate::::", { canUpdateFieldNames, canUpdateProperties });
|
|
576
|
+
// _izContext.logger.debug("canUpdate::::", { canUpdateFieldNames, canUpdateProperties });
|
|
577
577
|
|
|
578
578
|
// collect usedFieldNames
|
|
579
579
|
if (settings?.specificFieldNames) {
|
|
@@ -594,10 +594,10 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
|
|
|
594
594
|
|
|
595
595
|
let defaultFieldNames = usedFieldNames.filter(fieldName => !identifiersFieldNames.includes(fieldName));
|
|
596
596
|
|
|
597
|
-
_izContext.logger.debug('identifiersFieldNames : ', identifiersFieldNames);
|
|
598
|
-
_izContext.logger.debug('usedFieldNames : ', usedFieldNames); // all fieldName
|
|
599
|
-
_izContext.logger.debug("defaultFieldNames :", defaultFieldNames);
|
|
600
|
-
_izContext.logger.debug("versionedDataFieldNames :", versionedDataFieldNames);
|
|
597
|
+
// _izContext.logger.debug('identifiersFieldNames : ', identifiersFieldNames);
|
|
598
|
+
// _izContext.logger.debug('usedFieldNames : ', usedFieldNames); // all fieldName
|
|
599
|
+
// _izContext.logger.debug("defaultFieldNames :", defaultFieldNames);
|
|
600
|
+
// _izContext.logger.debug("versionedDataFieldNames :", versionedDataFieldNames);
|
|
601
601
|
|
|
602
602
|
let initialValidatorSchemaForUpdate = {
|
|
603
603
|
type: "object",
|
|
@@ -658,8 +658,8 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
|
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
660
|
|
|
661
|
-
console.debug("versionedDataReturnInFieldsObjInstanceFull::::", versionedDataReturnInFieldsObjInstanceFull);
|
|
662
|
-
console.debug("initialValidatorSchemaForUpdate:::::", initialValidatorSchemaForUpdate);
|
|
661
|
+
// console.debug("versionedDataReturnInFieldsObjInstanceFull::::", versionedDataReturnInFieldsObjInstanceFull);
|
|
662
|
+
// console.debug("initialValidatorSchemaForUpdate:::::", initialValidatorSchemaForUpdate);
|
|
663
663
|
Object.assign(
|
|
664
664
|
initialValidatorSchemaForUpdate.properties.objInstanceFull.properties.fields.properties,
|
|
665
665
|
{
|
|
@@ -668,7 +668,7 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
|
|
|
668
668
|
}
|
|
669
669
|
);
|
|
670
670
|
|
|
671
|
-
_izContext.logger.debug("validatorSchema-update::", initialValidatorSchemaForUpdate);
|
|
671
|
+
// _izContext.logger.debug("validatorSchema-update::", initialValidatorSchemaForUpdate);
|
|
672
672
|
return initialValidatorSchemaForUpdate;
|
|
673
673
|
}
|
|
674
674
|
|
|
@@ -983,6 +983,26 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
|
983
983
|
console.log("schemasPath", schemasPath);
|
|
984
984
|
console.log("serviceConfigPath", serviceConfigPath)
|
|
985
985
|
|
|
986
|
+
// helper function for getObjectSchema function in s3 or local
|
|
987
|
+
async function getLocalOrS3ObjectSchema(objType) {
|
|
988
|
+
let objSchema
|
|
989
|
+
let errorMessage
|
|
990
|
+
if (objType.serviceTag === iz_serviceTag) {
|
|
991
|
+
objSchema = await getLocalObjectSchemasWithHierarchy(_izContext, objType.objectType, schemasPath)
|
|
992
|
+
.then(res => {
|
|
993
|
+
return res.records[0]
|
|
994
|
+
})
|
|
995
|
+
|
|
996
|
+
if (!objSchema) {
|
|
997
|
+
errorMessage = "local not exists"
|
|
998
|
+
}
|
|
999
|
+
} else {
|
|
1000
|
+
objSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
1001
|
+
errorMessage = "s3 not exists"
|
|
1002
|
+
}
|
|
1003
|
+
return [objSchema, errorMessage]
|
|
1004
|
+
}
|
|
1005
|
+
|
|
986
1006
|
let validateStatus = {
|
|
987
1007
|
status: true,
|
|
988
1008
|
validateErrors: [],
|
|
@@ -1174,29 +1194,19 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
|
1174
1194
|
// validate objType of each link
|
|
1175
1195
|
await Promise.all(
|
|
1176
1196
|
relData.links.map(async (link, linkIdx) => {
|
|
1197
|
+
const [fromObjectSchema, fromErrorMessage] = await getLocalOrS3ObjectSchema(link.from.objType);
|
|
1177
1198
|
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
validateStatus.status = false;
|
|
1183
|
-
validateStatus.validateErrors.push(`Relationship:${relTagName} /links/${linkIdx} /from/objType > Not found objectSchema of objectType:${link.from.objType.objectType} in local service`);
|
|
1184
|
-
}
|
|
1185
|
-
return res.records[0]
|
|
1186
|
-
})
|
|
1187
|
-
: await getObjSchemaS3WithHierarchy(_izContext, link.from.objType);
|
|
1188
|
-
|
|
1189
|
-
const toObjectSchema = (link.to.objType.serviceTag === iz_serviceTag)
|
|
1190
|
-
? await getLocalObjectSchemasWithHierarchy(_izContext, link.to.objType.objectType, schemasPath)
|
|
1191
|
-
.then(res => {
|
|
1192
|
-
if (!res.records[0]) {
|
|
1193
|
-
validateStatus.status = false;
|
|
1194
|
-
validateStatus.validateErrors.push(`Relationship:${relTagName} /links/${linkIdx} /to/objType > Not found objectSchema of objectType:${link.to.objType.objectType} in local service`);
|
|
1195
|
-
}
|
|
1196
|
-
return res.records[0]
|
|
1197
|
-
})
|
|
1198
|
-
: await getObjSchemaS3WithHierarchy(_izContext, link.to.objType);
|
|
1199
|
+
if (!fromObjectSchema && fromErrorMessage === "local not exists") {
|
|
1200
|
+
validateStatus.status = false;
|
|
1201
|
+
validateStatus.validateErrors.push(`Relationship:${relTagName} /links/${linkIdx} /from/objType > Not found objectSchema of objectType:${link.from.objType.objectType} in local service`);
|
|
1202
|
+
}
|
|
1199
1203
|
|
|
1204
|
+
const [toObjectSchema, toErrorMessage] = await getLocalOrS3ObjectSchema(link.to.objType);
|
|
1205
|
+
|
|
1206
|
+
if (!fromObjectSchema && toErrorMessage === "local not exists") {
|
|
1207
|
+
validateStatus.status = false;
|
|
1208
|
+
validateStatus.validateErrors.push(`Relationship:${relTagName} /links/${linkIdx} /to/objType > Not found objectSchema of objectType:${link.to.objType.objectType} in local service`);
|
|
1209
|
+
}
|
|
1200
1210
|
|
|
1201
1211
|
if (!validateStatus.validateErrors.length) {
|
|
1202
1212
|
if (!fromObjectSchema) {
|
|
@@ -1255,10 +1265,10 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
|
1255
1265
|
validateStatus.status = false;
|
|
1256
1266
|
validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} must have objType`)
|
|
1257
1267
|
} else {
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1268
|
+
|
|
1269
|
+
let [objSchema] = await getLocalOrS3ObjectSchema(flowSchema.objType);
|
|
1270
|
+
|
|
1271
|
+
console.log("objSchema: ", objSchema)
|
|
1262
1272
|
|
|
1263
1273
|
if (!objSchema) {
|
|
1264
1274
|
validateStatus.status = false;
|
|
@@ -1300,10 +1310,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
|
|
|
1300
1310
|
validateStatus.status = false;
|
|
1301
1311
|
validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} must have objType`)
|
|
1302
1312
|
} else {
|
|
1303
|
-
let objSchema = await
|
|
1304
|
-
objectType: flowSchema.objType.objectType,
|
|
1305
|
-
serviceTag: flowSchema.objType.serviceTag
|
|
1306
|
-
})
|
|
1313
|
+
let [objSchema] = await getLocalOrS3ObjectSchema(flowSchema.objType);
|
|
1307
1314
|
|
|
1308
1315
|
if (!objSchema) {
|
|
1309
1316
|
validateStatus.status = false;
|