@izara_project/izara-core-library-service-schemas 1.0.100 → 1.0.101

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.
@@ -18,55 +18,17 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
 
20
20
 
21
- const readYamlFile = require('read-yaml-file');
22
- const lodash = require('lodash')
23
- const { inMemoryCacheLib, NoRetryError, consts } = require('@izara_project/izara-core-library-core');
24
- const Logger = require('@izara_project/izara-core-library-logger');
25
- const uploadUseCase = require('./libs/UploadUseCase')
26
-
27
- const { getGraphServiceTag, getServiceName } = require('./ServiceConfig')
28
- const { createLinkTypeId, createFlowTypeConcat } = require('./Utils');
29
- const hash = require('@izara_project/izara-shared-core').objectHash;
30
- const {
31
- validateObjectSchema,
32
- validateRelationshipSchema,
33
- validateRefRelationshipSchema,
34
- findLinkByObjTypeV2,
35
- validateBasicFlowSchema,
36
-
37
- getUsedFieldNamesOfIdentifiers,
38
- createObjType,
39
- getIdentifierTypeByPriority,
40
- } = require("./Utils");
41
-
42
- const {
43
- getDataFromPath,
44
-
45
- getAllLocalObjectSchemasWithoutHierarchy,
46
- getLocalObjectSchemasWithHierarchy,
47
-
48
- getObjSchemaS3WithHierarchy,
49
-
50
- getRelationshipSchema,
51
- getObjSchemaS3WithCache,
52
-
53
- getAllLocalFlowSchemas,
54
- getAllLocalRefObjectRelationshipSchema,
55
- getAllLocalRelationshipSchema,
56
- getLocalRelationshipSchemas,
57
- getObjectSchemaCombineFieldNamesWithCache,
58
- } = require("./GetObjectSchema");
59
-
60
- const {
61
- LOCAL_FILENAME,
62
- STORAGE_TYPES,
63
- createValidationFieldNameForEachType,
64
- S3_UPLOAD_TYPE,
65
- FLOW_SCHEMA_HOOK_STATE,
66
- HANDLER,
67
- OBJECT_SCHEMA_BUCKET_NAME
68
- } = require("./Consts");
69
- const { validateObjType } = require('@izara_project/izara-shared-service-schemas').validateObjType;
21
+ import readYamlFile from 'read-yaml-file';
22
+ import { inMemoryCacheLib, NoRetryError } from '@izara_project/izara-core-library-core';
23
+ import { objectHash as hash } from '@izara_project/izara-shared-core';
24
+ import Logger from '@izara_project/izara-core-library-logger';
25
+ import uploadUseCase from './libs/UploadUseCase.js';
26
+
27
+ import serviceConfig from './ServiceConfig.js';
28
+ import utils from './Utils.js';
29
+ import getObjectSchema from './GetObjectSchema.js';
30
+ import consts from './Consts.js'
31
+ import { validateObjType } from '@izara_project/izara-shared-service-schemas';
70
32
 
71
33
  // module.exports.createFieldNameUniqueRequestId = (prefix = 'cache') => {
72
34
  // return prefix + "UniqueRequestId";
@@ -137,7 +99,7 @@ async function generateValidatorSchemaTreePerFieldName(_izContext, fieldName, fi
137
99
  }
138
100
  )
139
101
 
140
- let childObjectSchema = await getObjSchemaS3WithHierarchy(
102
+ let childObjectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
141
103
  _izContext,
142
104
  fieldNameSetting.fromObjType
143
105
  );
@@ -173,7 +135,7 @@ async function generateValidatorSchemaTreePerFieldName(_izContext, fieldName, fi
173
135
  } else {
174
136
  Object.assign(
175
137
  validatorTree[fieldName],
176
- createValidationFieldNameForEachType(
138
+ consts.createValidationFieldNameForEachType(
177
139
  fieldNameSetting.type,
178
140
  fieldNameSetting.validation
179
141
  )
@@ -276,7 +238,7 @@ async function validatorSchemaTreeIdentifiersFieldNames(_izContext, objectSchema
276
238
  * @param {String} objType.serviceTag
277
239
  */
278
240
  async function generateRelationshipValidatorSchemaForCreate(_izContext, objType) {
279
- const validateObjTypeResult = validateObjType(objType);
241
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
280
242
  if (validateObjTypeResult.errorsFound.length > 0) {
281
243
  _izContext.logger.error("generateRelationshipValidatorSchemaForCreate validateObjTypeResult", validateObjTypeResult);
282
244
  throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
@@ -332,7 +294,7 @@ async function generateRelationshipValidatorSchemaForCreate(_izContext, objType)
332
294
  && parent.linkConfig.requiredOnCreate === true
333
295
  ) {
334
296
 
335
- let parentObjSchema = await getObjSchemaS3WithHierarchy(_izContext, parent.objType);
297
+ let parentObjSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, parent.objType);
336
298
 
337
299
  if (!parentObjSchema) {
338
300
  throw new NoRetryError(`Not found parent ${JSON.stringify(parent.objType)} in relationship:${relTag}`);
@@ -413,7 +375,7 @@ async function generateRelationshipValidatorSchemaForCreate(_izContext, objType)
413
375
  * @returns
414
376
  */
415
377
  async function generateValidatorSchemaForCreate(_izContext, objType, settings = { specificFieldNames: [] }) {
416
- const validateObjTypeResult = validateObjType(objType);
378
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
417
379
  if (validateObjTypeResult.errorsFound.length > 0) {
418
380
  _izContext.logger.error("generateValidatorSchemaForCreate validateObjTypeResult", validateObjTypeResult);
419
381
  throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
@@ -423,7 +385,7 @@ async function generateValidatorSchemaForCreate(_izContext, objType, settings =
423
385
  settings
424
386
  })
425
387
 
426
- const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
388
+ const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
427
389
  _izContext.logger.debug("objectSchema in generateValidatorSchemaForCreate", objectSchema)
428
390
  let usedFieldNamesData = {};
429
391
  let requiredFieldNames = [];
@@ -539,17 +501,17 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
539
501
  objType,
540
502
  setting: settings,
541
503
  })
542
- // const objType = createObjType(objectType);
543
- const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
504
+ // const objType = utils.createObjType(objectType);
505
+ const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
544
506
  // _izContext.logger.debug("objectSchema", objectSchema)
545
507
 
546
508
  const objectSchemas = await uploadUseCase.generateObjectSchemaForCombineFieldNames(_izContext, objectSchema)
547
509
  // _izContext.logger.debug("objectSchemas", objectSchemas)
548
510
 
549
- let usedIdentifierTypes = getIdentifierTypeByPriority(_izContext, [], objectSchema);
511
+ let usedIdentifierTypes = utils.getIdentifierTypeByPriority(_izContext, [], objectSchema);
550
512
  _izContext.logger.debug({ usedIdentifierTypes });
551
513
  // collect requiredFieldNames by fieldName that includes in identifiers
552
- let identifiersFieldNames = getUsedFieldNamesOfIdentifiers(_izContext, objectSchemas.identifiers, usedIdentifierTypes);
514
+ let identifiersFieldNames = utils.getUsedFieldNamesOfIdentifiers(_izContext, objectSchemas.identifiers, usedIdentifierTypes);
553
515
  // _izContext.logger.debug("identifiersFieldNames", identifiersFieldNames)
554
516
  let fieldNameCanUpdates = [];
555
517
  let versionedDataFieldNameCanUpdates = [];
@@ -674,7 +636,7 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
674
636
  // let versionedDataLabel = versionedDataFieldNameSetting.versionedDataLabel
675
637
  // if (versionedDataFieldNameSetting.hasOwnProperty("versionedDataLabel") && defaultFieldNames.includes(versionedDataFieldName)) {
676
638
  // Object.assign(versionedDataReturnInFieldsObjInstanceFull, {
677
- // [versionedDataFieldName]: createValidationFieldNameForEachType(
639
+ // [versionedDataFieldName]: consts.createValidationFieldNameForEachType(
678
640
  // versionedDataFieldNameSetting.type,
679
641
  // versionedDataFieldNameSetting.validation
680
642
  // )
@@ -715,8 +677,8 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
715
677
  *
716
678
  * @returns {object} json validator schema
717
679
  */
718
- async function generateValidatorSchemaForIdentifier(_izContext, objType, settings = { bucketName: OBJECT_SCHEMA_BUCKET_NAME }) {
719
- const validateObjTypeResult = validateObjType(objType);
680
+ async function generateValidatorSchemaForIdentifier(_izContext, objType, settings = { bucketName: consts.OBJECT_SCHEMA_BUCKET_NAME }) {
681
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
720
682
  if (validateObjTypeResult.errorsFound.length > 0) {
721
683
  _izContext.logger.error("generateValidatorSchemaForIdentifier validateObjTypeResult", validateObjTypeResult);
722
684
  throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
@@ -725,7 +687,7 @@ async function generateValidatorSchemaForIdentifier(_izContext, objType, setting
725
687
  objType,
726
688
  })
727
689
 
728
- const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType, settings.bucketName);
690
+ const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType, settings.bucketName);
729
691
 
730
692
  let generatedIdentifiersValidatorSchema = await validatorSchemaTreeIdentifiersFieldNames(_izContext, objectSchema, settings.bucketName);
731
693
  _izContext.logger.debug("generatedIdentifiersValidatorSchema: ", generatedIdentifiersValidatorSchema);
@@ -758,7 +720,7 @@ async function generateValidatorSchemaForIdentifier(_izContext, objType, setting
758
720
  * @returns
759
721
  */
760
722
  async function filteredFieldNamesOfValidatorSchema(_izContext, objType, requiredFieldNames, usedFieldNames) {
761
- const validateObjTypeResult = validateObjType(objType);
723
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
762
724
  if (validateObjTypeResult.errorsFound.length > 0) {
763
725
  _izContext.logger.error("filteredFieldNamesOfValidatorSchema validateObjTypeResult", validateObjTypeResult);
764
726
  throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
@@ -806,7 +768,7 @@ async function filteredFieldNamesOfValidatorSchema(_izContext, objType, required
806
768
  * 3 >> not required, Use for validate only
807
769
  */
808
770
  async function generateValidatorSchemaForExplodedData(_izContext, objType) {
809
- const validateObjTypeResult = validateObjType(objType);
771
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
810
772
  if (validateObjTypeResult.errorsFound.length > 0) {
811
773
  _izContext.logger.error("generateValidatorSchemaForExplodedData validateObjTypeResult", validateObjTypeResult);
812
774
  throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
@@ -818,7 +780,7 @@ async function generateValidatorSchemaForExplodedData(_izContext, objType) {
818
780
  properties: {}
819
781
  };
820
782
 
821
- let objectSchema = await getObjectSchemaCombineFieldNamesWithCache(_izContext, objType);
783
+ let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, objType);
822
784
  // generate validatorSchema for each fieldName
823
785
  for (let [fieldName, fieldData] of Object.entries(objectSchema.fieldNames)) {
824
786
  let fieldNameValidator = await generateValidatorFieldNameWithCache(_izContext, fieldName, fieldData);
@@ -914,7 +876,7 @@ async function generateValidatorFieldName(_izContext, fieldName, fieldData) {
914
876
  throw new Error(`Invalid reference fieldName:${fieldName}`);
915
877
  }
916
878
 
917
- let objectSchemaChild = await getObjSchemaS3WithHierarchy(
879
+ let objectSchemaChild = await getObjectSchema.getObjSchemaS3WithHierarchy(
918
880
  _izContext,
919
881
  // {
920
882
  // serviceTag: fieldData.fromServiceNameTag,
@@ -964,7 +926,7 @@ async function generateValidatorFieldName(_izContext, fieldName, fieldData) {
964
926
  // })
965
927
  // }
966
928
  Object.assign(returnValidator, {
967
- [compositeKey]: createValidationFieldNameForEachType(
929
+ [compositeKey]: consts.createValidationFieldNameForEachType(
968
930
  validateType,
969
931
  fieldValidation
970
932
  )
@@ -991,7 +953,7 @@ async function generateValidatorFieldName(_izContext, fieldName, fieldData) {
991
953
  // ...fieldValidation
992
954
  // }
993
955
  [fieldName]:
994
- createValidationFieldNameForEachType(
956
+ consts.createValidationFieldNameForEachType(
995
957
  validateType,
996
958
  fieldValidation
997
959
  )
@@ -1009,9 +971,9 @@ async function generateValidatorFieldName(_izContext, fieldName, fieldData) {
1009
971
  */
1010
972
  async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1011
973
  try {
1012
- const serviceConfig = readYamlFile.sync(serviceConfigPath);
1013
- const iz_serviceTag = serviceConfig.main_config.iz_serviceTag;
1014
- const iz_serviceSchemaBucketName = serviceConfig.main_config.iz_serviceSchemaBucketName
974
+ const config = readYamlFile.sync(serviceConfigPath);
975
+ const iz_serviceTag = config.main_config.iz_serviceTag;
976
+ const iz_serviceSchemaBucketName = config.main_config.iz_serviceSchemaBucketName
1015
977
  console.log("schemasPath", schemasPath);
1016
978
  console.log("serviceConfigPath", serviceConfigPath)
1017
979
 
@@ -1020,7 +982,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1020
982
  let objSchema
1021
983
  let errorMessage
1022
984
  if (objType.serviceTag === iz_serviceTag) {
1023
- objSchema = await getLocalObjectSchemasWithHierarchy(_izContext, objType.objectType, schemasPath)
985
+ objSchema = await getObjectSchema.getLocalObjectSchemasWithHierarchy(_izContext, objType.objectType, schemasPath)
1024
986
  .then(res => {
1025
987
  return res.records[0]
1026
988
  })
@@ -1029,7 +991,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1029
991
  errorMessage = "local not exists"
1030
992
  }
1031
993
  } else {
1032
- objSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
994
+ objSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
1033
995
  errorMessage = "s3 not exists"
1034
996
  }
1035
997
  return [objSchema, errorMessage]
@@ -1060,14 +1022,14 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1060
1022
  return validateStatus;
1061
1023
  }
1062
1024
 
1063
- const allObjectSchema = await getAllLocalObjectSchemasWithoutHierarchy(_izContext, schemasPath).then(res => res.records);
1064
- const allObjectRelationships = getAllLocalRelationshipSchema(_izContext, schemasPath);
1065
- const allReferenceObjectRelationships = getAllLocalRefObjectRelationshipSchema(_izContext, schemasPath);
1066
- const allFlowSchemas = await getAllLocalFlowSchemas(_izContext, schemasPath).then(res => res.records);
1025
+ const allObjectSchema = await getObjectSchema.getAllLocalObjectSchemasWithoutHierarchy(_izContext, schemasPath).then(res => res.records);
1026
+ const allObjectRelationships = getObjectSchema.getAllLocalRelationshipSchema(_izContext, schemasPath);
1027
+ const allReferenceObjectRelationships = getObjectSchema.getAllLocalRefObjectRelationshipSchema(_izContext, schemasPath);
1028
+ const allFlowSchemas = await getObjectSchema.getAllLocalFlowSchemas(_izContext, schemasPath).then(res => res.records);
1067
1029
 
1068
1030
  // validate all schema
1069
1031
  for (const objSchema of allObjectSchema) {
1070
- const [status, errors] = validateObjectSchema(_izContext, objSchema);
1032
+ const [status, errors] = utils.validateObjectSchema(_izContext, objSchema);
1071
1033
 
1072
1034
  if (!status) {
1073
1035
  validateStatus.status = false;
@@ -1081,8 +1043,8 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1081
1043
  for (const storageTag in objSchema.storageResources) {
1082
1044
  const storageResource = objSchema.storageResources[storageTag];
1083
1045
 
1084
- if (storageResource.storageType === STORAGE_TYPES.graph) {
1085
- const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag, iz_serviceSchemaBucketName);
1046
+ if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
1047
+ const graphServiceTag = await serviceConfig.getGraphServiceTag(_izContext, storageResource.graphServerTag, iz_serviceSchemaBucketName);
1086
1048
 
1087
1049
  if (!graphServiceTag) {
1088
1050
  validateStatus.status = false;
@@ -1090,7 +1052,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1090
1052
  }
1091
1053
  }
1092
1054
  // validate storageResource TableName should not be the same in all objectSchema
1093
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
1055
+ if (storageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
1094
1056
  if (tableNameList.has(storageResource.tableName)) {
1095
1057
  validateStatus.status = false;
1096
1058
  validateStatus.validateErrors.push(`objectType:${objSchema.objectType} storageResources. Should not have duplicate tableName inside storageResources`);
@@ -1134,7 +1096,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1134
1096
 
1135
1097
  // validate relationships schema
1136
1098
  for (const relSchema of allObjectRelationships) {
1137
- const [status, errors] = validateRelationshipSchema(_izContext, relSchema);
1099
+ const [status, errors] = utils.validateRelationshipSchema(_izContext, relSchema);
1138
1100
 
1139
1101
  if (!status) {
1140
1102
  validateStatus.status = false;
@@ -1152,8 +1114,8 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1152
1114
  for (const storageTag in relData.storageResources) {
1153
1115
  const storageResource = relData.storageResources[storageTag];
1154
1116
 
1155
- if (storageResource.storageType === STORAGE_TYPES.graph) {
1156
- const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag, iz_serviceSchemaBucketName);
1117
+ if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
1118
+ const graphServiceTag = await serviceConfig.getGraphServiceTag(_izContext, storageResource.graphServerTag, iz_serviceSchemaBucketName);
1157
1119
 
1158
1120
  if (!graphServiceTag) {
1159
1121
  validateStatus.status = false;
@@ -1162,7 +1124,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1162
1124
  }
1163
1125
 
1164
1126
 
1165
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
1127
+ if (storageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
1166
1128
  if (tableNameList.has(storageResource.tableName)) {
1167
1129
  validateStatus.status = false;
1168
1130
  validateStatus.validateErrors.push(`relationshipTag:${relTagName} storageResources. Should not have duplicate tableName inside storageResources`);
@@ -1191,7 +1153,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1191
1153
  // canChangeToRelSchema = canChangeRelSchemaLocal[relData.canChangeToRelType.relationshipTag]
1192
1154
  // }
1193
1155
  // } else {
1194
- // canChangeToRelSchema = await getRelationshipSchema(_izContext, { relationshipTag: relData.canChangeToRelType.relationshipTag, serviceTag: relData.canChangeToRelType.serviceTag }) // return {}
1156
+ // canChangeToRelSchema = await getObjectSchema.getRelationshipSchema(_izContext, { relationshipTag: relData.canChangeToRelType.relationshipTag, serviceTag: relData.canChangeToRelType.serviceTag }) // return {}
1195
1157
  // }
1196
1158
 
1197
1159
  // if (!canChangeToRelSchema || !Object.keys(canChangeToRelSchema).length) {
@@ -1274,7 +1236,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1274
1236
 
1275
1237
  // validate reference relationship
1276
1238
  for (let refRelSchema of allReferenceObjectRelationships) {
1277
- const [status, errors] = validateRefRelationshipSchema(_izContext, refRelSchema, iz_serviceTag);
1239
+ const [status, errors] = utils.validateRefRelationshipSchema(_izContext, refRelSchema, iz_serviceTag);
1278
1240
  if (!status) {
1279
1241
  validateStatus.status = false;
1280
1242
  validateStatus.validateErrors.push(errors);
@@ -1290,7 +1252,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1290
1252
 
1291
1253
  if (allFlowSchemas) {
1292
1254
  for (const flowSchema of allFlowSchemas) {
1293
- const [status, errors] = validateBasicFlowSchema(_izContext, flowSchema)
1255
+ const [status, errors] = utils.validateBasicFlowSchema(_izContext, flowSchema)
1294
1256
 
1295
1257
  if (!flowSchema.hasOwnProperty("objType")) {
1296
1258
  validateStatus.status = false;
@@ -1306,7 +1268,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1306
1268
  let dynamoDBStorageTags = [];
1307
1269
 
1308
1270
  for (const [storageTag, storageResource] of Object.entries(objSchema.storageResources)) {
1309
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
1271
+ if (storageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
1310
1272
  dynamoDBStorageTags.push(storageTag)
1311
1273
  }
1312
1274
  }
@@ -1317,7 +1279,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1317
1279
  } else {
1318
1280
 
1319
1281
  if (flowSchema.statusType === "statusField") {
1320
- let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), 'statusField'))
1282
+ let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(utils.createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), 'statusField'))
1321
1283
 
1322
1284
  for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1323
1285
  if (objSchema.fieldNames.hasOwnProperty(specificFieldName)) {
@@ -1333,7 +1295,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1333
1295
 
1334
1296
 
1335
1297
  } else if (flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
1336
- let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), "cacheTable"))
1298
+ let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(utils.createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), "cacheTable"))
1337
1299
 
1338
1300
  for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1339
1301
  if (objSchema.fieldNames.hasOwnProperty(specificFieldName)) {
@@ -1368,7 +1330,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1368
1330
  // validate ref relationships in external path s3
1369
1331
  await Promise.all(
1370
1332
  allReferenceObjectRelationships.map(async (refRelSchema) => {
1371
- const relSchemaFromRef = await getRelationshipSchema(
1333
+ const relSchemaFromRef = await getObjectSchema.getRelationshipSchema(
1372
1334
  _izContext,
1373
1335
  {
1374
1336
  serviceTag: refRelSchema.relationshipServiceTag,
@@ -1380,7 +1342,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1380
1342
  validateStatus.referenceErrors.push(`Invalid reference relationship of objectType: '${refRelSchema.objectType}' >> relationshipTag: '${refRelSchema.relationshipTag}' not exists in service: '${refRelSchema.relationshipServiceTag}'`)
1381
1343
  } else {
1382
1344
 
1383
- const linkRecords = findLinkByObjTypeV2(
1345
+ const linkRecords = utils.findLinkByObjTypeV2(
1384
1346
  _izContext,
1385
1347
  {
1386
1348
  objectType: refRelSchema.objectType,
@@ -1410,7 +1372,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1410
1372
  }
1411
1373
  }
1412
1374
 
1413
- module.exports = {
1375
+ export default {
1414
1376
  generateValidatorSchemaForCreate,
1415
1377
  generateValidatorSchemaForUpdate,
1416
1378
  generateValidatorSchemaForIdentifier,
@@ -16,16 +16,15 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
- const { createRelTypeConcat, createLinkTypeId } = require('../Utils');
20
- const getObjectSchema = require('../GetObjectSchema');
21
- const serviceConfig = require('../ServiceConfig');
22
- const { STORAGE_TYPES, OBJECT_SCHEMA_BUCKET_NAME } = require('../Consts')
23
- const { getObjTypeHierarchy } = require('../GetObjectSchema')
19
+ import utils from '../Utils.js';
20
+ import getObjectSchema from '../GetObjectSchema.js';
21
+ import serviceConfig from '../ServiceConfig.js';
22
+ import consts from '../Consts.js';
24
23
 
25
24
  async function validateRequiredOnCreateLinks(_izContext, objType, relationships = [], settings = {}) {
26
25
  _izContext.logger.debug("validateRequiredOnCreateLinks:::", { objType, relationships, settings })
27
26
 
28
- let objectHie = await getObjTypeHierarchy(_izContext, objType).then(objSchema => {
27
+ let objectHie = await getObjectSchema.getObjTypeHierarchy(_izContext, objType).then(objSchema => {
29
28
  if (objSchema.errorsFound.length > 0) {
30
29
  throw new NoRetryError(objSchema.errorsFound.join(","))
31
30
  } else {
@@ -35,7 +34,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
35
34
  _izContext.logger.debug("objectHierarchy::", objectHie)
36
35
 
37
36
  if (relationships.length) {
38
- let targetHierarchy = await getObjTypeHierarchy(_izContext, relationships[0].targetObjType).then(objSchema => {
37
+ let targetHierarchy = await getObjectSchema.getObjTypeHierarchy(_izContext, relationships[0].targetObjType).then(objSchema => {
39
38
  if (objSchema.errorsFound.length > 0) {
40
39
  throw new NoRetryError(objSchema.errorsFound.join(","))
41
40
  } else {
@@ -62,7 +61,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
62
61
  const serviceTags = await Promise.all(
63
62
  requiredOnCreateLink.storageResourceTags.map(async (storageTag) => {
64
63
  let storageResource = requiredOnCreateLink.storageResources[storageTag];
65
- if (storageResource.storageType === STORAGE_TYPES.graph) {
64
+ if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
66
65
  return await serviceConfig.getGraphServiceTagWithCache(_izContext, storageResource.graphServerTag)
67
66
  }
68
67
  })
@@ -84,7 +83,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
84
83
  _izContext.logger.debug("start validate relationship from requestParams")
85
84
  for (const relationship of relationships) {
86
85
  // validate all relationship in requestParams
87
- let relTypeConcat = createRelTypeConcat(_izContext, relationship.relType)
86
+ let relTypeConcat = utils.createRelTypeConcat(_izContext, relationship.relType)
88
87
 
89
88
  if (!requiredOnCreateLinkGroups[relTypeConcat]) {
90
89
  errorsFound.push(`cannot create relationship ${relTypeConcat}`)
@@ -101,7 +100,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
101
100
 
102
101
  for (let link of usedLinkGroup) {
103
102
  // check other with targetObjType, check linkType of other should be 'one',
104
- let targetObjTypeHierarchy = await getObjTypeHierarchy(_izContext, relationship.targetObjType).then(objSchema => {
103
+ let targetObjTypeHierarchy = await getObjectSchema.getObjTypeHierarchy(_izContext, relationship.targetObjType).then(objSchema => {
105
104
  if (objSchema.errorsFound.length > 0) {
106
105
  throw new NoRetryError(objSchema.errorsFound.join(","))
107
106
  } else {
@@ -144,7 +143,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
144
143
  function groupRequiredOnCreateLink(_izContext, relationshipSchemas) {
145
144
  let groupLink = {};
146
145
  for (let relationshipSchema of relationshipSchemas) {
147
- let relTypeConcat = createRelTypeConcat(_izContext, relationshipSchema.relType);
146
+ let relTypeConcat = utils.createRelTypeConcat(_izContext, relationshipSchema.relType);
148
147
  if (!groupLink.hasOwnProperty(relTypeConcat)) {
149
148
  Object.assign(groupLink, {
150
149
  [relTypeConcat]: {
@@ -184,10 +183,9 @@ function createLinkTypeIdFromLinkGroup(_izContext, linkGroup) {
184
183
  let linkTypeIds = new Set();
185
184
  for (const objectRelationshipGroup of Object.values(linkGroup)) {
186
185
  for (const direction of Object.keys(objectRelationshipGroup)) {
187
- let objectRelationshipByDirection = objectRelationshipGroup[direction]
188
186
  if (objectRelationshipGroup[direction].length) {
189
187
  for (const objectRelLink of objectRelationshipGroup[direction]) {
190
- linkTypeIds.add(createLinkTypeId(
188
+ linkTypeIds.add(utils.createLinkTypeId(
191
189
  _izContext,
192
190
  objectRelLink?.base?.objType,
193
191
  objectRelLink?.other?.objType,
@@ -210,7 +208,7 @@ function switchDirection(direction) {
210
208
  }
211
209
  }
212
210
 
213
- module.exports = {
211
+ export default {
214
212
  validateRequiredOnCreateLinks,
215
213
  groupRequiredOnCreateLink,
216
214
  createLinkTypeIdFromLinkGroup,
@@ -17,10 +17,10 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- const { NoRetryError } = require('@izara_project/izara-core-library-core');
20
+ import { NoRetryError } from '@izara_project/izara-core-library-core';
21
21
 
22
- const { getObjSchemaS3WithHierarchy } = require("../GetObjectSchema");
23
- const { DEFAULT_IDENTIFIER_DELIMINATOR } = require("../Consts");
22
+ import getObjectSchema from "../GetObjectSchema.js";
23
+ import consts from "../Consts.js";
24
24
 
25
25
 
26
26
  /**
@@ -51,7 +51,7 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
51
51
 
52
52
  if (fieldNameSetting.fromObjType) {
53
53
 
54
- let childObjectSchema = await getObjSchemaS3WithHierarchy(
54
+ let childObjectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
55
55
  _izContext,
56
56
  // {
57
57
  // objectType: fieldNameSetting.fromObjectType,
@@ -120,7 +120,7 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
120
120
 
121
121
  // add deliminator and deliminatorList to deliminatorTree
122
122
  if (isConcatCompositeKey) {
123
- deliminatorTree[fieldName].deliminator = usedIdentifier.deliminator || DEFAULT_IDENTIFIER_DELIMINATOR;
123
+ deliminatorTree[fieldName].deliminator = usedIdentifier.deliminator || consts.DEFAULT_IDENTIFIER_DELIMINATOR;
124
124
  }
125
125
 
126
126
  if (childDeliminatorList.hasOwnProperty(deliminatorTree[fieldName].deliminator)) {
@@ -304,7 +304,7 @@ async function generateDeliminatorCompositeIdentifier(_izContext, objSchema) {
304
304
  }
305
305
  }
306
306
 
307
- module.exports = {
307
+ export default {
308
308
  generateDeliminatorTreePerFieldName,
309
309
  generateDeliminatorTreeAllFieldNames,
310
310
  generateDeliminatorTreeIdentifier,
@@ -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 { NoRetryError } = require('@izara_project/izara-core-library-core');
20
+ import { NoRetryError } from '@izara_project/izara-core-library-core';
21
21
 
22
- const deliminatorTree = require("./DeliminatorTree");
22
+ import deliminatorTree from "./DeliminatorTree.js";
23
23
 
24
24
 
25
25
  /**
@@ -474,7 +474,7 @@ async function explodedDataForUpdate(_izContext, requestParams, objectSchema, se
474
474
  return explodedReqParams
475
475
  }
476
476
 
477
- module.exports = {
477
+ export default {
478
478
  explodeDataField,
479
479
  explodedDataForCreate,
480
480
  explodedDataForIdentifiers,
@@ -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 { LambdaClient, ListFunctionsCommand } = require('@aws-sdk/client-lambda');
20
+ import { LambdaClient, ListFunctionsCommand } from '@aws-sdk/client-lambda';
21
21
 
22
22
  /**
23
23
  * List all lambda functions
@@ -38,6 +38,4 @@ async function listLambdaFunctions(_izContext, param) {
38
38
  }
39
39
  }
40
40
 
41
- module.exports = {
42
- listLambdaFunctions,
43
- };
41
+ export default listLambdaFunctions;
@@ -17,13 +17,12 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- const lodash = require("lodash");
20
+ import lodash from "lodash";
21
+ import { NoRetryError } from '@izara_project/izara-core-library-core';
22
+ import { objectHash as hash } from '@izara_project/izara-shared-core';
23
+ import getObjectSchema from "../GetObjectSchema.js";
24
+ import { validateObjType } from "@izara_project/izara-shared-service-schemas";
21
25
 
22
- const hash = require('@izara_project/izara-shared-core').objectHash;
23
- const { NoRetryError } = require('@izara_project/izara-core-library-core');
24
- const getObjectSchema = require("../GetObjectSchema");
25
- const { validateObjType: { validateObjType } } = require("@izara_project/izara-shared-service-schemas");
26
- const { getObjTypeHierarchy } = require('../GetObjectSchema');
27
26
  /**
28
27
  * helper function for find link of 2 objects in links and refactor each link
29
28
  *
@@ -42,7 +41,7 @@ async function findLinksByObjTypes(_izContext, objTypes, relationshipLinks) {
42
41
  }
43
42
 
44
43
  for (const objType of objTypes) {
45
- const validateObjTypeResult = validateObjType(objType);
44
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
46
45
  if (validateObjTypeResult.errorsFound.length > 0) {
47
46
  throw NoRetryError(`function checkLinkValid: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
48
47
  }
@@ -52,14 +51,14 @@ async function findLinksByObjTypes(_izContext, objTypes, relationshipLinks) {
52
51
  const secondObjType = objTypes[1];
53
52
 
54
53
  // first create hierarchy of each objType
55
- const firstObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[0], process.env.iz_serviceSchemaBucketName).then(objSchema => {
54
+ const firstObjTypeTree = await getObjectSchema.getObjTypeHierarchy(_izContext, objTypes[0], process.env.iz_serviceSchemaBucketName).then(objSchema => {
56
55
  if (objSchema.errorsFound.length > 0) {
57
56
  throw new NoRetryError(objSchema.errorsFound.join(","))
58
57
  } else {
59
58
  return objSchema.result
60
59
  }
61
60
  });
62
- const secondObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[1], process.env.iz_serviceSchemaBucketName).then(objSchema => {
61
+ const secondObjTypeTree = await getObjectSchema.getObjTypeHierarchy(_izContext, objTypes[1], process.env.iz_serviceSchemaBucketName).then(objSchema => {
63
62
  if (objSchema.errorsFound.length > 0) {
64
63
  throw new NoRetryError(objSchema.errorsFound.join(","))
65
64
  } else {
@@ -113,6 +112,4 @@ async function findLinksByObjTypes(_izContext, objTypes, relationshipLinks) {
113
112
  return foundLinks;
114
113
  }
115
114
 
116
- module.exports = {
117
- findLinksByObjTypes
118
- }
115
+ export default { findLinksByObjTypes }
@@ -211,7 +211,7 @@ function getStorageResources(relationshipSchema, storageResourceTags) {
211
211
  return result;
212
212
  }
213
213
 
214
- module.exports = {
214
+ export default {
215
215
  validateObjectLinksInput,
216
216
  validateGraphServerTags,
217
217
  mergeStorageResources,