@izara_project/izara-core-library-service-schemas 1.0.62 → 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.62",
3
+ "version": "1.0.64",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,14 +20,15 @@
20
20
  "testEnvironment": "node"
21
21
  },
22
22
  "dependencies": {
23
- "@aws-sdk/client-lambda": "^3.812.0",
24
- "@aws-sdk/client-s3": "^3.815.0",
25
- "@aws-sdk/crc64-nvme-crt": "^3.815.0",
23
+ "@aws-sdk/client-lambda": "^3.787.0",
24
+ "@aws-sdk/client-s3": "^3.787.0",
25
+ "@aws-sdk/crc64-nvme-crt": "^3.787.0",
26
26
  "@izara_project/izara-core-library-core": "^1.0.19",
27
27
  "@izara_project/izara-core-library-external-request": "^1.0.20",
28
28
  "@izara_project/izara-core-library-lambda": "^1.0.4",
29
29
  "@izara_project/izara-core-library-logger": "^1.0.7",
30
- "@izara_project/izara-shared-service-schemas": "^1.0.12",
30
+ "@izara_project/izara-shared-core": "^1.0.2",
31
+ "@izara_project/izara-shared-service-schemas": "^1.0.13",
31
32
  "glob": "^11.0.2",
32
33
  "lodash": "^4.17.21",
33
34
  "object-hash": "^3.0.0",
@@ -20,9 +20,9 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
20
20
 
21
21
  const glob = require('glob')
22
22
  const path = require('path')
23
- const hash = require('object-hash');
24
23
  const lodash = require('lodash');
25
24
 
25
+ const hash = require('@izara_project/izara-shared-core').objectHash;
26
26
 
27
27
  const sharedServiceSchema = require("@izara_project/izara-shared-service-schemas");
28
28
  const {
@@ -17,7 +17,7 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- const hash = require("object-hash")
20
+ const hash = require('@izara_project/izara-shared-core').objectHash;
21
21
 
22
22
  const { inMemoryCacheLib } = require('@izara_project/izara-core-library-core');
23
23
 
@@ -17,7 +17,7 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- const hash = require('object-hash');
20
+ const hash = require('@izara_project/izara-shared-core').objectHash;
21
21
 
22
22
  const {
23
23
  validateGraphServerTags,
@@ -460,6 +460,7 @@ async function uploadObjectSchemaByUseCase(_izContext) {
460
460
  }
461
461
 
462
462
  // ------------ Upload Relationship ------------------
463
+ let setRelationships = new Set();
463
464
  if (allObjectRelationships) {
464
465
 
465
466
  // upload relationshipTag
@@ -499,7 +500,6 @@ async function uploadObjectSchemaByUseCase(_izContext) {
499
500
  }
500
501
 
501
502
  // send params to translateIds to create permission fpr query dynamoDB
502
- let setRelationships = new Set();
503
503
  for (const [storageResourceTag, storageResource] of Object.entries(relTagDetail[relationshipTag].storageResources)) {
504
504
  if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
505
505
  for (const link of relTagDetail[relationshipTag].links) {
@@ -514,17 +514,15 @@ async function uploadObjectSchemaByUseCase(_izContext) {
514
514
  }
515
515
  }
516
516
  }
517
- let arrayRelationships = [...setRelationships]
518
- await lambda.invokeSync(_izContext,
519
- await lambdaSharedLib.lambdaFunctionName(_izContext, "CreatePermissionHdrInv", "TranslateIds"),
520
- {
521
- relationships: arrayRelationships
522
- }
523
- )
524
-
525
517
  }// per relationshipTag
526
-
527
-
518
+
519
+ let arrayRelationships = [...setRelationships]
520
+ await lambda.invokeSync(_izContext,
521
+ await lambdaSharedLib.lambdaFunctionName(_izContext, "CreatePermissionHdrInv", "TranslateIds"),
522
+ {
523
+ relationships: arrayRelationships
524
+ }
525
+ )
528
526
 
529
527
  const linksPerObjectTyjpe = groupLinksPerObjectType(_izContext, allObjectRelationships, foundedObjectTypes)
530
528
 
package/src/Utils.js CHANGED
@@ -17,7 +17,7 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- const hash = require('object-hash');
20
+ const hash = require('@izara_project/izara-shared-core').objectHash;
21
21
  const {
22
22
  NoRetryError,
23
23
  validator: { validateObject }
@@ -18,7 +18,6 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
 
20
20
 
21
- const hash = require('object-hash');
22
21
  const readYamlFile = require('read-yaml-file');
23
22
  const lodash = require('lodash')
24
23
  const { inMemoryCacheLib, NoRetryError } = require('@izara_project/izara-core-library-core');
@@ -27,6 +26,7 @@ const uploadUseCase = require('./libs/UploadUseCase')
27
26
 
28
27
  const { getGraphServiceTag, getServiceName } = require('./ServiceConfig')
29
28
 
29
+ const hash = require('@izara_project/izara-shared-core').objectHash;
30
30
  const {
31
31
  validateObjectSchema,
32
32
  validateRelationshipSchema,
@@ -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
  }
@@ -17,9 +17,9 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- const hash = require("object-hash");
21
20
  const lodash = require("lodash");
22
21
 
22
+ const hash = require('@izara_project/izara-shared-core').objectHash;
23
23
  const { NoRetryError } = require('@izara_project/izara-core-library-core');
24
24
  const getObjectSchema = require("../GetObjectSchema");
25
25
  const { validateObjType: { validateObjType } } = require("@izara_project/izara-shared-service-schemas");
@@ -28,7 +28,7 @@ const {
28
28
  PutObjectCommand,
29
29
  } = require("@aws-sdk/client-s3");
30
30
 
31
- const hash = require('object-hash');
31
+ const hash = require('@izara_project/izara-shared-core').objectHash;
32
32
 
33
33
  const { NoRetryError, inMemoryCacheLib } = require('@izara_project/izara-core-library-core');
34
34
  const { SCHEMA_NAME_PER_S3_PATH } = require('@izara_project/izara-shared-service-schemas').consts;