@izara_project/izara-core-library-service-schemas 1.0.63 → 1.0.64

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.63",
3
+ "version": "1.0.64",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -52,7 +52,8 @@ const {
52
52
 
53
53
  getAllLocalFlowSchemas,
54
54
  getAllLocalRefObjectRelationshipSchema,
55
- getAllLocalRelationshipSchema
55
+ getAllLocalRelationshipSchema,
56
+ getLocalRelationshipSchemas
56
57
  } = require("./GetObjectSchema");
57
58
 
58
59
  const {
@@ -925,13 +926,10 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
925
926
  }
926
927
 
927
928
  const allObjectSchema = await getAllLocalObjectSchemasWithoutHierarchy(_izContext, schemasPath).then(res => res.records);
928
- // const allObjectRelationships = getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_RELATIONSHIPS, schemasPath, { fileLimit: 1 })[0] || [];
929
- // const allReferenceObjectRelationships = getDataFromPath(_izContext, LOCAL_FILENAME.REFERENCE_OBJECT_RELATIONSHIPS, schemasPath, { fileLimit: 1 })[0] || [];
930
929
  const allObjectRelationships = getAllLocalRelationshipSchema(_izContext, schemasPath);
931
930
  const allReferenceObjectRelationships = getAllLocalRefObjectRelationshipSchema(_izContext, schemasPath);
932
931
  const allFlowSchemas = await getAllLocalFlowSchemas(_izContext, schemasPath).then(res => res.records);
933
- console.log("allFlowSchemas", allFlowSchemas);
934
-
932
+ console.log("allObjectRelationships", allObjectRelationships)
935
933
 
936
934
  // validate all schema
937
935
  for (const objSchema of allObjectSchema) {
@@ -1050,6 +1048,33 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1050
1048
  }
1051
1049
  }
1052
1050
 
1051
+ if (relData.canChangeToRelType) {
1052
+ let canChangeToRelSchema = null
1053
+ if (relData.canChangeToRelType.serviceTag === iz_serviceTag) {
1054
+ let canChangeRelSchemaLocal = await getLocalRelationshipSchemas(_izContext, [relData.canChangeToRelType.relationshipTag], schemasPath)
1055
+ if (Object.keys(canChangeRelSchemaLocal).length) {
1056
+ canChangeToRelSchema = canChangeRelSchemaLocal[relData.canChangeToRelType.relationshipTag]
1057
+ }
1058
+ } else {
1059
+ canChangeToRelSchema = await getRelationshipSchema(_izContext, { relationshipTag: relData.canChangeToRelType.relationshipTag, serviceTag: relData.canChangeToRelType.serviceTag }) // return {}
1060
+ }
1061
+
1062
+ if (!canChangeToRelSchema || !Object.keys(canChangeToRelSchema).length) {
1063
+ validateStatus.status = false;
1064
+ validateStatus.validateErrors.push(`Relationship:${relTagName}/canChangeToRelType targetRelType ${JSON.stringify(relData.canChangeToRelType)} not exist`);
1065
+ } else {
1066
+ if (!canChangeToRelSchema.hasOwnProperty("canChangeToRelType")) {
1067
+ validateStatus.status = false;
1068
+ validateStatus.validateErrors.push(`RelType:${JSON.stringify(relData.canChangeToRelType)} not have setting canChangeToRelType`);
1069
+ } else {
1070
+ if (canChangeToRelSchema.canChangeToRelType.serviceTag !== iz_serviceTag || canChangeToRelSchema.canChangeToRelType.relationshipTag !== relTagName) {
1071
+ validateStatus.status = false;
1072
+ validateStatus.validateErrors.push(`RelType:${JSON.stringify(relData.canChangeToRelType)} not have reference to RelType:${JSON.stringify({ serviceTag: iz_serviceTag, relationshipTag: relTagName })} `);
1073
+ }
1074
+ }
1075
+ }
1076
+ }
1077
+
1053
1078
 
1054
1079
  /*
1055
1080
  Note!: this process not need to validate objectSchema bc already validate above
@@ -1072,7 +1097,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1072
1097
  .then(res => {
1073
1098
  if (!res.records[0]) {
1074
1099
  validateStatus.status = false;
1075
- validateStatus.validateErrors.push(`Relationship:${relTagName}/links/${linkIdx}/from/objType > Not found objectSchema of objectType:${link.from.objType.objectType} in local service`);
1100
+ validateStatus.validateErrors.push(`Relationship:${relTagName} /links/${linkIdx} /from/objType > Not found objectSchema of objectType:${link.from.objType.objectType} in local service`);
1076
1101
  }
1077
1102
  return res.records[0]
1078
1103
  })
@@ -1083,7 +1108,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1083
1108
  .then(res => {
1084
1109
  if (!res.records[0]) {
1085
1110
  validateStatus.status = false;
1086
- validateStatus.validateErrors.push(`Relationship:${relTagName}/links/${linkIdx}/to/objType > Not found objectSchema of objectType:${link.to.objType.objectType} in local service`);
1111
+ validateStatus.validateErrors.push(`Relationship:${relTagName} /links/${linkIdx} /to/objType > Not found objectSchema of objectType:${link.to.objType.objectType} in local service`);
1087
1112
  }
1088
1113
  return res.records[0]
1089
1114
  })
@@ -1093,12 +1118,12 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1093
1118
  if (!validateStatus.validateErrors.length) {
1094
1119
  if (!fromObjectSchema) {
1095
1120
  validateStatus.status = false;
1096
- validateStatus.referenceErrors.push(`Relationship:${relTagName}/links/${linkIdx}/from/objType > Not found objectSchema of ${JSON.stringify(link.from.objType)}`);
1121
+ validateStatus.referenceErrors.push(`Relationship:${relTagName} /links/${linkIdx} /from/objType > Not found objectSchema of ${JSON.stringify(link.from.objType)} `);
1097
1122
  }
1098
1123
 
1099
1124
  if (!toObjectSchema) {
1100
1125
  validateStatus.status = false;
1101
- validateStatus.referenceErrors.push(`Relationship:${relTagName}/links/${linkIdx}/from/objType > Not found objectSchema ${JSON.stringify(link.to.objType)}`);
1126
+ validateStatus.referenceErrors.push(`Relationship:${relTagName} /links/${linkIdx} /from/objType > Not found objectSchema ${JSON.stringify(link.to.objType)} `);
1102
1127
  }
1103
1128
  }
1104
1129
  })
@@ -1225,7 +1250,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1225
1250
  )
1226
1251
  if (!relSchemaFromRef) {
1227
1252
  validateStatus.status = false;
1228
- validateStatus.referenceErrors.push(`Invalid reference relationship of objectType:'${refRelSchema.objectType}' >> relationshipTag:'${refRelSchema.relationshipTag}' not exists in service:'${refRelSchema.relationshipServiceTag}'`)
1253
+ validateStatus.referenceErrors.push(`Invalid reference relationship of objectType: '${refRelSchema.objectType}' >> relationshipTag: '${refRelSchema.relationshipTag}' not exists in service: '${refRelSchema.relationshipServiceTag}'`)
1229
1254
  } else {
1230
1255
 
1231
1256
  const linkRecords = findLinkByObjTypeV2(
@@ -1243,7 +1268,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1243
1268
 
1244
1269
  if (!linkRecords.length) {
1245
1270
  validateStatus.status = false;
1246
- validateStatus.referenceErrors.push(`relationshipTag:'${refRelSchema.relationshipTag}' in service:'${refRelSchema.relationshipServiceTag}' not have objectType:'${refRelSchema.objectType} 'in links`);
1271
+ validateStatus.referenceErrors.push(`relationshipTag: '${refRelSchema.relationshipTag}' in service: '${refRelSchema.relationshipServiceTag}' not have objectType: '${refRelSchema.objectType} ' in links`);
1247
1272
  }
1248
1273
 
1249
1274
  }