@izara_project/izara-core-library-service-schemas 1.0.77 → 1.0.79

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.77",
3
+ "version": "1.0.79",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,16 +20,16 @@
20
20
  "testEnvironment": "node"
21
21
  },
22
22
  "dependencies": {
23
- "@aws-sdk/client-api-gateway": "^3.840.0",
24
- "@aws-sdk/client-lambda": "^3.840.0",
25
- "@aws-sdk/client-s3": "^3.842.0",
26
- "@aws-sdk/crc64-nvme-crt": "^3.840.0",
23
+ "@aws-sdk/client-api-gateway": "^3.848.0",
24
+ "@aws-sdk/client-lambda": "^3.848.0",
25
+ "@aws-sdk/client-s3": "^3.848.0",
26
+ "@aws-sdk/crc64-nvme-crt": "^3.848.0",
27
27
  "@izara_project/izara-core-library-core": "^1.0.19",
28
28
  "@izara_project/izara-core-library-external-request": "^1.0.20",
29
29
  "@izara_project/izara-core-library-lambda": "^1.0.4",
30
30
  "@izara_project/izara-core-library-logger": "^1.0.7",
31
31
  "@izara_project/izara-shared-core": "^1.0.2",
32
- "@izara_project/izara-shared-service-schemas": "^1.0.22",
32
+ "@izara_project/izara-shared-service-schemas": "^1.0.23",
33
33
  "glob": "^11.0.3",
34
34
  "lodash": "^4.17.21",
35
35
  "object-hash": "^3.0.0",
package/src/Consts.js CHANGED
@@ -348,7 +348,7 @@ module.exports = {
348
348
  LOCAL_OBJECT_SCHEMA_PATH: './src/schemas', // schema folder path in lambda environment
349
349
 
350
350
  OBJECT_SCHEMA_BUCKET_NAME: 'object-schema',
351
-
351
+ SUPPLY_SCHEMA_BUCKET_NAME: "schema-supply",
352
352
  DEFAULT_IDENTIFIER_DELIMINATOR: "_",
353
353
 
354
354
  PREFIX_PATH_S3,
@@ -39,6 +39,7 @@ const {
39
39
  getObjTypeHierarchy: getObjTypeHierarchyShared,
40
40
  getObjectSchemaForCreate: getObjectSchemaForCreateShared,
41
41
  getObjectSchemaForUpdate: getObjectSchemaForUpdateShared,
42
+ getFlowSchemaS3: getFlowSchemaS3Shared
42
43
  } = sharedServiceSchema.getObjectSchema;
43
44
  const { validateObjType, validateFlowType } = sharedServiceSchema.validateObjType;
44
45
  const {
@@ -56,11 +57,10 @@ const {
56
57
  // const dynamodbSharedLib = require('@izara_project/izara-shared/src/DynamodbSharedLib');
57
58
  // const Logger = require('@izara_project/izara-core-library-logger')
58
59
 
59
- const { getObjectS3, headObjectS3, getSchemaByNameWithCache } = require("./libs/s3Utils");
60
+ const { getObjectS3, headObjectS3, getSchemaByNameWithCache, getSchemaByName } = require("./libs/s3Utils");
60
61
  const { generateObjectSchemaForCombineFieldNames } = require("./libs/UploadUseCase");
61
62
 
62
63
  const {
63
- OBJECT_SCHEMA_BUCKET_NAME,
64
64
  LOCAL_OBJECT_SCHEMA_PATH,
65
65
 
66
66
  UPLOAD_PATH_S3,
@@ -471,7 +471,8 @@ async function getObjSchemaS3(
471
471
  objType,
472
472
  getExtendObType = false
473
473
  ) {
474
- return await getObjectSchemaS3Shared(getSchemaByNameWithCache, objType, getExtendObType).then(res => {
474
+
475
+ return await getObjectSchemaS3Shared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName, getExtendObType).then(res => {
475
476
  if (res.errorsFound.length && res.errorsFound.length > 0) {
476
477
  throw new NoRetryError(res.errorsFound.join(","))
477
478
  } else {
@@ -505,7 +506,7 @@ const getObjSchemaS3WithCache = inMemoryCacheLib(
505
506
  */
506
507
  async function getObjSchemaS3WithHierarchy(_izContext, objType) {
507
508
  // return await getObjSchemaS3WithCache(_izContext, objType, true)
508
- return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType).then(res => {
509
+ return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName).then(res => {
509
510
  if (res.errorsFound.length && res.errorsFound.length > 0) {
510
511
  throw new NoRetryError(res.errorsFound.join(","))
511
512
  } else {
@@ -522,7 +523,7 @@ async function getObjSchemaS3WithHierarchy(_izContext, objType) {
522
523
  */
523
524
  async function getObjSchemaS3WithoutHierarchy(_izContext, objType) {
524
525
  // return await getObjSchemaS3WithCache(_izContext, objType, false)
525
- return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType).then(res => {
526
+ return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName).then(res => {
526
527
  if (res.errorsFound.length && res.errorsFound.length > 0) {
527
528
  throw new NoRetryError(res.errorsFound.join(","))
528
529
  } else {
@@ -639,7 +640,7 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
639
640
  * @returns {Promise<Object>} - reference relationship schema of objType
640
641
  */
641
642
  async function getRefObjectRelationship(_izContext, objType) {
642
- return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType).then(res => {
643
+ return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName).then(res => {
643
644
  if (res.errorsFound.length && res.errorsFound.length > 0) {
644
645
  throw new NoRetryError(res.errorsFound.join(","))
645
646
  } else {
@@ -674,7 +675,7 @@ const getRefObjectRelationshipWithCache = inMemoryCacheLib(
674
675
  *
675
676
  */
676
677
  async function getRelationshipSchema(_izContext, relType) {
677
- return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType).then(res => {
678
+ return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType, process.env.iz_serviceSchemaBucketName).then(res => {
678
679
  if (res.errorsFound.length && res.errorsFound.length > 0) {
679
680
  throw new NoRetryError(res.errorsFound.join(","))
680
681
  } else {
@@ -701,7 +702,7 @@ const getRelationshipSchemaWithCache = inMemoryCacheLib(
701
702
 
702
703
 
703
704
  /**
704
- * get serviceTag of relatinshipTag data from s3
705
+ * get serviceTag of relationshipTag data from s3
705
706
  *
706
707
  * @param {Object} _izContext
707
708
  * @param {String} relationshipTag - needed relationshipTag
@@ -731,7 +732,7 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
731
732
  }
732
733
  );
733
734
 
734
- let relSchemaHeadData = await headObjectS3(_izContext, { Bucket: OBJECT_SCHEMA_BUCKET_NAME, Key: relTagPath })
735
+ let relSchemaHeadData = await headObjectS3(_izContext, { Bucket: process.env.iz_serviceSchemaBucketName, Key: relTagPath })
735
736
 
736
737
  // _izContext.logger.debug("relSchemaHeadData: ", relSchemaHeadData);
737
738
 
@@ -787,7 +788,7 @@ async function getObjectRelationship(
787
788
  overWriteBaseObjType,
788
789
  ) {
789
790
 
790
- return await getObjectRelationshipShared(getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType).then(res => {
791
+ return await getObjectRelationshipShared(getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType, process.env.iz_serviceSchemaBucketName).then(res => {
791
792
  if (res.errorsFound.length && res.errorsFound.length > 0) {
792
793
  throw new NoRetryError(res.errorsFound.join(","))
793
794
  } else {
@@ -808,7 +809,7 @@ const getObjectRelationshipWithCache = inMemoryCacheLib(
808
809
  { // setting
809
810
  max: 100, maxAge: 86400000, promise: true, profileName: 'getObjectRelationshipS3',
810
811
  normalizer: function (args) {
811
- return hash([args[1], args[2]])
812
+ return hash([args[1], args[2], args[3]])
812
813
  }
813
814
  }
814
815
  )
@@ -817,7 +818,7 @@ const getObjectRelationshipWithCache = inMemoryCacheLib(
817
818
 
818
819
  /**
819
820
  *
820
- * get requiredOnCreate link in realtionshipSchema of objType depend on specific relationshipTags
821
+ * get requiredOnCreate link in relationshipSchema of objType depend on specific relationshipTags
821
822
  *
822
823
  * @param {Object} _izContext
823
824
  * @param {Object} objType
@@ -837,7 +838,7 @@ async function getRequiredOnCreateLinks(
837
838
  specificRelTags,
838
839
  });
839
840
 
840
- return await getRequiredOnCreateLinksShared(getSchemaByNameWithCache, objType, specificRelTags).then(res => {
841
+ return await getRequiredOnCreateLinksShared(getSchemaByNameWithCache, objType, specificRelTags, process.env.iz_serviceSchemaBucketName).then(res => {
841
842
  if (res.errorsFound.length && res.errorsFound.length > 0) {
842
843
  throw new NoRetryError(res.errorsFound.join(","))
843
844
  } else {
@@ -880,10 +881,10 @@ async function getLinkConfig(_izContext, firstObjType, secondObjType, relType, d
880
881
  secondObjType,
881
882
  relType,
882
883
  direction,
883
- settings
884
+ settings,
884
885
  });
885
886
 
886
- return await getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings);
887
+ return await getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings, process.env.iz_serviceSchemaBucketName);
887
888
  }
888
889
 
889
890
  /**
@@ -910,17 +911,17 @@ const getLinkConfigWithCache = inMemoryCacheLib(
910
911
  * @param {String} relType.relationshipTag
911
912
  * @returns {Promise<{from:Object, to:Object}>}
912
913
  */
913
- async function getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings) {
914
+ async function getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction, settings = {}) {
914
915
 
915
916
  _izContext.logger.debug("getLinkConfigByLinkTypeId: ", {
916
917
  firstObjType,
917
918
  secondObjType,
918
919
  relType,
919
920
  direction,
920
- settings
921
+ settings,
921
922
  });
922
923
 
923
- return await getLinkConfigByLinkTypeIdShared(getSchemaByNameWithCache, firstObjType, secondObjType, relType, direction, settings).then(res => {
924
+ return await getLinkConfigByLinkTypeIdShared(getSchemaByNameWithCache, firstObjType, secondObjType, relType, direction, settings, process.env.iz_serviceSchemaBucketName).then(res => {
924
925
  if (res.errorsFound.length && res.errorsFound.length > 0) {
925
926
  throw new NoRetryError(res.errorsFound.join(","))
926
927
  } else {
@@ -957,7 +958,7 @@ const getLinkConfigByLinkTypeIdWithCache = inMemoryCacheLib(
957
958
  * @returns
958
959
  */
959
960
  async function mergeExtendObjSchema(_izContext, objectSchema) {
960
- let mergedObjectSchema = await mergeExtendObjSchemaShared(getSchemaByNameWithCache, objectSchema).then(res => {
961
+ let mergedObjectSchema = await mergeExtendObjSchemaShared(getSchemaByNameWithCache, objectSchema, process.env.iz_serviceSchemaBucketName).then(res => {
961
962
  if (res.errorsFound.length && res.errorsFound.length > 0) {
962
963
  throw new NoRetryError(`objectSchema.objectType: ${objectSchema.objectType} ${res.errorsFound}`)
963
964
  } else {
@@ -1047,19 +1048,14 @@ async function getFlowSchemaS3(
1047
1048
  _izContext,
1048
1049
  flowType,
1049
1050
  ) {
1050
- const validateFlowTypeResult = validateFlowType(flowType);
1051
- if (validateFlowTypeResult.errorsFound.length > 0) {
1052
- _izContext.logger.error("getFlowSchemaS3: Invalid flowType: ", validateFlowTypeResult.errorsFound);
1053
- throw new NoRetryError(`getFlowSchemaS3: Invalid flowType: ${JSON.stringify(flowType)}, ${validateFlowTypeResult.errorsFound.join(", ")}`);
1054
- }
1055
-
1056
- const getObjSchemaParam = {
1057
- Bucket: OBJECT_SCHEMA_BUCKET_NAME,
1058
- Key: UPLOAD_PATH_S3.flowSchema(_izContext, flowType)
1059
- };
1060
- let [flowSchema] = await getObjectS3(_izContext, getObjSchemaParam);
1061
1051
 
1062
- return flowSchema
1052
+ return await getFlowSchemaS3Shared(getSchemaByNameWithCache, flowType, process.env.iz_serviceSchemaBucketName).then(res => {
1053
+ if (res.errorsFound.length) {
1054
+ throw new NoRetryError(res.errorsFound.join(","))
1055
+ } else {
1056
+ return res.result
1057
+ }
1058
+ })
1063
1059
  }
1064
1060
 
1065
1061
  /**
@@ -1069,7 +1065,7 @@ async function getFlowSchemaS3(
1069
1065
  */
1070
1066
  const getFlowSchemaS3WithCache = inMemoryCacheLib(
1071
1067
  getFlowSchemaS3,
1072
- { //seting
1068
+ { //setting
1073
1069
  max: 100, maxAge: 8640000, promise: true, profileName: 'getFlowSchemaS3',
1074
1070
  normalizer: function (args) {
1075
1071
  return hash([args[1]])
@@ -1106,7 +1102,7 @@ function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = LOCA
1106
1102
  * @returns
1107
1103
  */
1108
1104
  async function getObjTypeHierarchy(_izContext, objType) {
1109
- return await getObjTypeHierarchyShared(getSchemaByNameWithCache, objType);
1105
+ return await getObjTypeHierarchyShared(getSchemaByNameWithCache, objType, objType, process.env.iz_serviceSchemaBucketName);
1110
1106
  }
1111
1107
 
1112
1108
  /**
@@ -1116,7 +1112,7 @@ async function getObjTypeHierarchy(_izContext, objType) {
1116
1112
  */
1117
1113
  const getObjTypeHierarchyWithCache = inMemoryCacheLib(
1118
1114
  getObjTypeHierarchy,
1119
- { //seting
1115
+ { //setting
1120
1116
  max: 100, maxAge: 8640000, promise: true, profileName: 'getObjTypeHierarchy',
1121
1117
  normalizer: function (args) {
1122
1118
  return hash([args[1]])
@@ -1125,11 +1121,11 @@ const getObjTypeHierarchyWithCache = inMemoryCacheLib(
1125
1121
  )
1126
1122
 
1127
1123
  async function getObjectSchemaForCreate(_izContext, objType) {
1128
- return await getObjectSchemaForCreateShared(getSchemaByNameWithCache, objType)
1124
+ return await getObjectSchemaForCreateShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
1129
1125
  }
1130
1126
 
1131
1127
  async function getObjectSchemaForUpdate(_izContext, objType) {
1132
- return await getObjectSchemaForUpdateShared(getSchemaByNameWithCache, objType)
1128
+ return await getObjectSchemaForUpdateShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
1133
1129
  }
1134
1130
 
1135
1131
  module.exports = {
@@ -51,14 +51,14 @@ function checkStorageTypeOfObjectSchemaIdentifiers(_izContext, objectSchema) {
51
51
 
52
52
 
53
53
  /**
54
- * create object of idenfifiers from baseObjInstance object
54
+ * create object of identifiers from baseObjInstance object
55
55
  *
56
56
  * @param {Object} _izContext
57
57
  * @param {Object} objType
58
58
  * @param {Object} objInstanceBase
59
59
  * @returns {Promise<Object>} - identifiersObject
60
60
  */
61
- async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBase) {
61
+ async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBase, bucketName = process.env.iz_serviceSchemaBucketName) {
62
62
  const validateObjTypeResult = validateObjType(objType);
63
63
  if (validateObjTypeResult.errorsFound.length > 0) {
64
64
  _izContext.logger.error("identifiersObjectFromBaseObjInstance: Invalid objType: ", validateObjTypeResult.errorsFound);
@@ -67,9 +67,9 @@ async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBa
67
67
 
68
68
  _izContext.logger.debug("identifiersObjectFromBaseObjInstance: ", { objType, baseObjInstance: objInstanceBase });
69
69
 
70
- const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
70
+ const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
71
71
 
72
- let deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema);
72
+ let deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema, bucketName);
73
73
  _izContext.logger.debug("deliminator: ", deliminatorTreeResult);
74
74
 
75
75
 
@@ -144,7 +144,7 @@ async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBa
144
144
  * @param {Object} identifiers
145
145
  * @returns {Promise<Object>} - concatIdentifiersObject
146
146
  */
147
- async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers) {
147
+ async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers, bucketName = process.env.iz_serviceSchemaBucketName) {
148
148
  const validateObjTypeResult = validateObjType(objType);
149
149
  if (validateObjTypeResult.errorsFound.length > 0) {
150
150
  _izContext.logger.error("identifiersBaseFromIdentifiers: Invalid objType: ", validateObjTypeResult.errorsFound);
@@ -153,7 +153,7 @@ async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers)
153
153
 
154
154
  _izContext.logger.debug("concatIdentifiersFromIdentifiersObject: ", { objType, identifiersObject: identifiers });
155
155
 
156
- const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
156
+ const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
157
157
 
158
158
 
159
159
  // validate identifiersObject
@@ -168,7 +168,7 @@ async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers)
168
168
  }
169
169
 
170
170
  // start to create concatIdentifiers
171
- const deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema);
171
+ const deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema, bucketName);
172
172
  _izContext.logger.debug("deliminator: ", deliminatorTreeResult);
173
173
 
174
174
 
@@ -200,14 +200,14 @@ async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers)
200
200
  * @param {Object} objInstance
201
201
  * @returns {Promise<Object>} - refactoredObjInstance
202
202
  */
203
- async function objInstanceFromobjInstanceBase(_izContext, objType, objInstance) {
203
+ async function objInstanceFromObjInstanceBase(_izContext, objType, objInstance, bucketName = process.env.iz_serviceSchemaBucketName) {
204
204
  const validateObjTypeResult = validateObjType(objType);
205
205
  if (validateObjTypeResult.errorsFound.length > 0) {
206
- _izContext.logger.error("objInstanceFromobjInstanceBase: Invalid objType: ", validateObjTypeResult.errorsFound);
207
- throw new NoRetryError(`objInstanceFromobjInstanceBase: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
206
+ _izContext.logger.error("objInstanceFromObjInstanceBase: Invalid objType: ", validateObjTypeResult.errorsFound);
207
+ throw new NoRetryError(`objInstanceFromObjInstanceBase: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
208
208
  }
209
209
 
210
- const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
210
+ const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
211
211
 
212
212
  const identifierNames = objSchema.identifiers.map(identifier => identifier.name || identifier.fieldName);
213
213
 
@@ -222,7 +222,7 @@ async function objInstanceFromobjInstanceBase(_izContext, objType, objInstance)
222
222
  refactoredObjInstance[baseObjProp] = objInstance[baseObjProp];
223
223
  }
224
224
 
225
- const identifiersObject = await identifiersFromObjInstanceBase(_izContext, objType, objInstance);
225
+ const identifiersObject = await identifiersFromObjInstanceBase(_izContext, objType, objInstance, bucketName);
226
226
  Object.assign(refactoredObjInstance, identifiersObject);
227
227
 
228
228
  return refactoredObjInstance;
@@ -235,7 +235,7 @@ async function objInstanceFromobjInstanceBase(_izContext, objType, objInstance)
235
235
  * @param {Object} identifiers
236
236
  * @returns {Promise<String>} - compositeIdentifier
237
237
  */
238
- async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers) {
238
+ async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers, bucketName = process.env.iz_serviceSchemaBucketName) {
239
239
  const validateObjTypeResult = validateObjType(objType);
240
240
  if (validateObjTypeResult.errorsFound.length > 0) {
241
241
  _izContext.logger.error("compositeIdentifierFromIdentifiersObject: Invalid objType: ", validateObjTypeResult.errorsFound);
@@ -244,13 +244,13 @@ async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers
244
244
 
245
245
  _izContext.logger.debug("compositeIdentifierFromIdentifiersObject: ", { objType, identifiersObject: identifiers });
246
246
 
247
- const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
247
+ const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
248
248
  _izContext.logger.debug("objSchema: ", objSchema);
249
249
 
250
250
 
251
251
  // validate identifiersObject
252
252
  // maybe validate with all deliminatorTree instead of identifiersName
253
- const identifiersNames = getUsedFieldNamesOfIdentifiers(_izContext, objSchema.identifiers);
253
+ const identifiersNames = getUsedFieldNamesOfIdentifiers(_izContext, objSchema.identifiers,);
254
254
  _izContext.logger.debug("identifiersNames: ", identifiersNames);
255
255
 
256
256
  for (const identifierName of identifiersNames) {
@@ -260,7 +260,7 @@ async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers
260
260
  }
261
261
 
262
262
  // start to create concatIdentifiers
263
- const deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema);
263
+ const deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema, bucketName);
264
264
  _izContext.logger.debug("deliminator: ", deliminatorTreeResult);
265
265
 
266
266
 
@@ -333,7 +333,7 @@ async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers
333
333
  * @param {String} identifiersConcat
334
334
  * @returns {Promise<Object>} - identifiersObject
335
335
  */
336
- async function identifiersFromIdentifiersConcat(_izContext, objType, identifiersConcat) {
336
+ async function identifiersFromIdentifiersConcat(_izContext, objType, identifiersConcat, bucketName = process.env.iz_serviceSchemaBucketName) {
337
337
  const validateObjTypeResult = validateObjType(objType);
338
338
  if (validateObjTypeResult.errorsFound.length > 0) {
339
339
  _izContext.logger.error("identifiersObjectFromCompositeIdentifier: Invalid objType: ", validateObjTypeResult.errorsFound);
@@ -342,9 +342,9 @@ async function identifiersFromIdentifiersConcat(_izContext, objType, identifiers
342
342
 
343
343
  _izContext.logger.debug("identifiersObjectFromCompositeIdentifier: ", { objType, compositeIdentifier: identifiersConcat });
344
344
 
345
- const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
345
+ const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
346
346
  _izContext.logger.debug("objSchema in identifiersObjectFromCompositeIdentifier", objSchema)
347
- let deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema);
347
+ let deliminatorTreeResult = await deliminatorTree.generateDeliminatorTreeIdentifier(_izContext, objSchema, bucketName);
348
348
  _izContext.logger.debug("deliminator: ", deliminatorTreeResult);
349
349
 
350
350
 
@@ -431,6 +431,7 @@ async function createNestedIdentifiersConcat(
431
431
  _izContext,
432
432
  objType,
433
433
  identifiersConcat,
434
+ bucketName = process.env.iz_serviceSchemaBucketName,
434
435
  prefixes = [],
435
436
  suffixes = [],
436
437
  level = 1,
@@ -453,10 +454,10 @@ async function createNestedIdentifiersConcat(
453
454
  throw new NoRetryError(`createConcatIdentifier: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
454
455
  }
455
456
 
456
- const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
457
+ const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
457
458
  _izContext.logger.debug("objSchema in createConcatIdentifier", objSchema);
458
459
 
459
- let deliminatorTreeCompositeIdentifier = await deliminatorTree.generateDeliminatorCompositeIdentifier(_izContext, objSchema);
460
+ let deliminatorTreeCompositeIdentifier = await deliminatorTree.generateDeliminatorCompositeIdentifier(_izContext, objSchema, bucketName);
460
461
  _izContext.logger.debug("deliminatorTreeCompositeIdentifier: ", deliminatorTreeCompositeIdentifier);
461
462
 
462
463
 
@@ -475,6 +476,7 @@ async function explodedNestedIdentifiersConcat(
475
476
  _izContext,
476
477
  objType,
477
478
  concatIdentifier,
479
+ bucketName = process.env.iz_serviceSchemaBucketName,
478
480
  level = 1,
479
481
  deliminator = DEFAULT_IDENTIFIER_DELIMINATOR,
480
482
  ) {
@@ -491,10 +493,10 @@ async function explodedNestedIdentifiersConcat(
491
493
  throw new NoRetryError(`explodedConcatIdentifier: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
492
494
  }
493
495
 
494
- const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
496
+ const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType, bucketName);
495
497
  _izContext.logger.debug("objSchema in explodedConcatIdentifier", objSchema);
496
498
 
497
- let deliminatorTreeCompositeIdentifier = await deliminatorTree.generateDeliminatorCompositeIdentifier(_izContext, objSchema);
499
+ let deliminatorTreeCompositeIdentifier = await deliminatorTree.generateDeliminatorCompositeIdentifier(_izContext, objSchema, bucketName);
498
500
  _izContext.logger.debug("deliminatorTreeCompositeIdentifier: ", deliminatorTreeCompositeIdentifier);
499
501
 
500
502
 
@@ -510,7 +512,7 @@ async function explodedNestedIdentifiersConcat(
510
512
  module.exports = {
511
513
  identifiersFromObjInstanceBase,
512
514
  identifiersBaseFromIdentifiers, // concatIdentifiersObjectFromIdentifiersObject
513
- objInstanceFromobjInstanceBase, // refactoredObjInstanceFromBaseObjInstance
515
+ objInstanceFromObjInstanceBase, // refactoredObjInstanceFromBaseObjInstance
514
516
  identifiersConcatFromIdentifiers, // compositeIdentifierFromIdentifiersObject
515
517
  identifiersFromIdentifiersConcat, // identifiersObjectFromCompositeIdentifier
516
518
 
@@ -37,12 +37,12 @@ const { getObjectS3 } = require("./libs/s3Utils")
37
37
  */
38
38
  async function getServiceName(
39
39
  _izContext,
40
- serviceTag,
40
+ serviceTag
41
41
  ) {
42
42
  _izContext.logger.debug("getServiceName: ", serviceTag)
43
43
 
44
44
  const getObjectParam = {
45
- Bucket: OBJECT_SCHEMA_BUCKET_NAME,
45
+ Bucket: process.env.iz_serviceSchemaBucketName,
46
46
  Key: UPLOAD_PATH_S3.serviceName(_izContext, serviceTag),
47
47
  };
48
48
  _izContext.logger.debug("getObjectParam", getObjectParam)
@@ -88,7 +88,7 @@ async function getGraphServiceTag(
88
88
  let [serverTags] = await getObjectS3(
89
89
  _izContext,
90
90
  {
91
- Bucket: OBJECT_SCHEMA_BUCKET_NAME,
91
+ Bucket: process.env.iz_serviceSchemaBucketName,
92
92
  Key: UPLOAD_PATH_S3.graphServerTagsConfig
93
93
  }
94
94
  );
@@ -77,7 +77,8 @@ async function _processNodeRelationships(
77
77
  newLinkRelSchema,
78
78
  storageResourceTags,
79
79
  objectRelationships,
80
- relationshipSchema
80
+ relationshipSchema,
81
+ bucketName
81
82
  ) {
82
83
  const { node, isBase, relationshipDirection } = nodeConfig;
83
84
  const results = [];
@@ -86,7 +87,7 @@ async function _processNodeRelationships(
86
87
 
87
88
  // Get object relationships from S3
88
89
  const getObjRelPathParam = {
89
- Bucket: OBJECT_SCHEMA_BUCKET_NAME,
90
+ Bucket: bucketName ? bucketName : OBJECT_SCHEMA_BUCKET_NAME,
90
91
  Key: UPLOAD_PATH_S3.objectRelationship(_izContext, node.objType)
91
92
  };
92
93
  _izContext.logger.debug('==> getObjRelPathParam:', getObjRelPathParam);
@@ -240,7 +241,7 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
240
241
  const [relationshipSchema, rawRelationshipSchema] = await getObjectS3(
241
242
  _izContext,
242
243
  {
243
- Bucket: OBJECT_SCHEMA_BUCKET_NAME,
244
+ Bucket: process.env.iz_serviceSchemaBucketName,
244
245
  Key: UPLOAD_PATH_S3.relationshipTag(_izContext, relType)
245
246
  }
246
247
  );
@@ -473,7 +474,8 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
473
474
  newLinkRelSchema,
474
475
  storageResourceTags,
475
476
  objectRelationships,
476
- relationshipSchema
477
+ relationshipSchema,
478
+ bucketName
477
479
  );
478
480
  results.push(...firstNodeResults);
479
481
  } catch (error) {
@@ -497,7 +499,8 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
497
499
  newLinkRelSchema,
498
500
  storageResourceTags,
499
501
  objectRelationships,
500
- relationshipSchema
502
+ relationshipSchema,
503
+ bucketName
501
504
  );
502
505
  results.push(...secondNodeResults);
503
506
  } catch (error) {
@@ -551,7 +554,8 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
551
554
  _izContext,
552
555
  relType.relationshipTag,
553
556
  objectLinksGroup,
554
- { depth: loopSetting.depth + 1 }
557
+ { depth: loopSetting.depth + 1 },
558
+ bucketName
555
559
  )
556
560
  }
557
561
 
@@ -598,7 +602,7 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
598
602
  uploadObjectToS3(
599
603
  _izContext,
600
604
  UPLOAD_PATH_S3.objectRelationship(_izContext, objType),
601
- relationships
605
+ relationships,
602
606
  )
603
607
  );
604
608
 
@@ -635,7 +639,8 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
635
639
  _izContext,
636
640
  relType.relationshipTag,
637
641
  objectLinksGroup,
638
- { depth: loopSetting.depth + 1 }
642
+ { depth: loopSetting.depth + 1 },
643
+ bucketName
639
644
  )
640
645
  }
641
646
  } catch (error) {
@@ -93,7 +93,7 @@ async function uploadObjectToS3(
93
93
  const Key = pathToUpload
94
94
 
95
95
  let data = {
96
- Bucket: OBJECT_SCHEMA_BUCKET_NAME,
96
+ Bucket: process.env.iz_serviceSchemaBucketName,
97
97
  Key,
98
98
  Body: buffer,
99
99
  ContentEncoding: 'base64',
@@ -163,13 +163,13 @@ async function emptyS3Path(
163
163
  *
164
164
  * @param {object} _izContext
165
165
  */
166
- async function uploadObjectSchemaByUseCase(_izContext) {
166
+ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
167
167
  let uploadList = [];
168
168
 
169
169
  const objectTypesForCreate = [];
170
170
 
171
171
  const allObjectSchemasResult = await getAllLocalObjectSchemasWithoutHierarchy(_izContext);
172
- console.log("allObjectSchemasResult: ", allObjectSchemasResult);
172
+ // console.log("allObjectSchemasResult: ", allObjectSchemasResult);
173
173
  const allObjectSchema = await allObjectSchemasResult.records;
174
174
  // const allObjectRelationships = getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_RELATIONSHIPS, LOCAL_OBJECT_SCHEMA_PATH, { fileLimit: 1 })[0] || [];
175
175
  // const allReferenceObjectRelationships = getDataFromPath(_izContext, LOCAL_FILENAME.REFERENCE_OBJECT_RELATIONSHIPS, LOCAL_OBJECT_SCHEMA_PATH, { fileLimit: 1 })[0] || [];
@@ -234,7 +234,7 @@ async function uploadObjectSchemaByUseCase(_izContext) {
234
234
  // end validate all schema
235
235
 
236
236
  // delete all file in servicePath before upload
237
- await emptyS3Path(_izContext, OBJECT_SCHEMA_BUCKET_NAME, `${PREFIX_PATH_S3.perServiceSchemas}/${process.env.iz_serviceTag}/`);
237
+ await emptyS3Path(_izContext, process.env.iz_serviceSchemaBucketName, `${PREFIX_PATH_S3.perServiceSchemas}/${process.env.iz_serviceTag}/`);
238
238
 
239
239
 
240
240
  if (lambdaFunctions) {
@@ -242,7 +242,8 @@ async function uploadObjectSchemaByUseCase(_izContext) {
242
242
  uploadObjectToS3(
243
243
  _izContext,
244
244
  UPLOAD_PATH_S3.lambdaFunctions(_izContext, process.env.iz_serviceTag),
245
- lambdaFunctions
245
+ lambdaFunctions,
246
+
246
247
  )
247
248
  );
248
249
  }
@@ -252,7 +253,8 @@ async function uploadObjectSchemaByUseCase(_izContext) {
252
253
  uploadObjectToS3(
253
254
  _izContext,
254
255
  UPLOAD_PATH_S3.serviceName(_izContext, process.env.iz_serviceTag),
255
- { serviceName: process.env.iz_serviceName }
256
+ { serviceName: process.env.iz_serviceName },
257
+
256
258
  )
257
259
  );
258
260
 
@@ -270,7 +272,8 @@ async function uploadObjectSchemaByUseCase(_izContext) {
270
272
  objectType: objSchema.objectType
271
273
  }
272
274
  ),
273
- objSchema
275
+ objSchema,
276
+
274
277
  )
275
278
  );
276
279
 
@@ -287,7 +290,8 @@ async function uploadObjectSchemaByUseCase(_izContext) {
287
290
  objectType: createFieldSchema.objectType
288
291
  }
289
292
  ),
290
- createFieldSchema
293
+ createFieldSchema,
294
+
291
295
  )
292
296
  );
293
297
 
@@ -306,14 +310,15 @@ async function uploadObjectSchemaByUseCase(_izContext) {
306
310
  objectType: createFieldSchema.objectType
307
311
  }
308
312
  ),
309
- updateFieldSchema
313
+ updateFieldSchema,
314
+
310
315
  )
311
316
  );
312
317
 
313
318
 
314
319
  // case schema combine fieldNames
315
320
  let combineFieldNamesObjectSchema = generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
316
- console.log("combineFieldNamesObjectSchema", combineFieldNamesObjectSchema)
321
+ // console.log("combineFieldNamesObjectSchema", combineFieldNamesObjectSchema)
317
322
  uploadList.push(
318
323
  uploadObjectToS3(
319
324
  _izContext,
@@ -324,17 +329,19 @@ async function uploadObjectSchemaByUseCase(_izContext) {
324
329
  objectType: combineFieldNamesObjectSchema.objectType
325
330
  }
326
331
  ),
327
- combineFieldNamesObjectSchema
332
+ combineFieldNamesObjectSchema,
333
+
328
334
  )
329
335
  );
330
336
 
331
337
  let apiLink = await getApiLinks();
332
- console.log("apiLink", apiLink)
338
+ // console.log("apiLink", apiLink)
333
339
  uploadList.push(
334
340
  uploadObjectToS3(
335
341
  _izContext,
336
342
  UPLOAD_PATH_S3.getEndpointPerObjectType(_izContext, { objectType: objSchema.objectType, serviceTag: process.env.iz_serviceTag }),
337
- apiLink
343
+ apiLink,
344
+
338
345
  )
339
346
  )
340
347
 
@@ -342,7 +349,8 @@ async function uploadObjectSchemaByUseCase(_izContext) {
342
349
  uploadObjectToS3(
343
350
  _izContext,
344
351
  UPLOAD_PATH_S3.getEndpointPerService(process.env.iz_serviceTag),
345
- apiLink
352
+ apiLink,
353
+
346
354
  )
347
355
  )
348
356
 
@@ -360,7 +368,8 @@ async function uploadObjectSchemaByUseCase(_izContext) {
360
368
  serviceTag: process.env.iz_serviceTag
361
369
  }
362
370
  ),
363
- existsRefObjectRel
371
+ existsRefObjectRel,
372
+
364
373
  )
365
374
  )
366
375
  } else {
@@ -379,7 +388,8 @@ async function uploadObjectSchemaByUseCase(_izContext) {
379
388
  serviceTag: process.env.iz_serviceTag
380
389
  }
381
390
  ),
382
- await refRelationshipPerObjectSchema(_izContext, objSchema)
391
+ await refRelationshipPerObjectSchema(_izContext, objSchema),
392
+
383
393
  )
384
394
  )
385
395
  }
@@ -392,7 +402,8 @@ async function uploadObjectSchemaByUseCase(_izContext) {
392
402
  uploadObjectToS3(
393
403
  _izContext,
394
404
  UPLOAD_PATH_S3.objectListAll(_izContext, process.env.iz_serviceTag),
395
- foundedObjectTypes
405
+ foundedObjectTypes,
406
+
396
407
  )
397
408
  );
398
409
 
@@ -502,7 +513,7 @@ async function uploadObjectSchemaByUseCase(_izContext) {
502
513
  {
503
514
  relationshipServiceTag: process.env.iz_serviceTag,
504
515
  ...relTagDetail[relationshipTag],
505
- }
516
+ },
506
517
  )
507
518
  );
508
519
 
@@ -559,7 +570,7 @@ async function uploadObjectSchemaByUseCase(_izContext) {
559
570
  }
560
571
 
561
572
 
562
- } // All objectRelaetionship
573
+ } // All objectRelationship
563
574
 
564
575
 
565
576
  // // upload refObjectRelationships
package/src/Utils.js CHANGED
@@ -279,7 +279,7 @@ function validateAddOnDataStructure(_izContext, objectSchema) {
279
279
 
280
280
  let errors = [];
281
281
  let fieldNameCollection = Object.keys(objectSchema.fieldNames || {});
282
- let attriutebuteTreeTags = [];
282
+ let attributeTreeTags = [];
283
283
 
284
284
  if (objectSchema.addOnDataStructure?.length) {
285
285
  for (const [idx, addOn] of objectSchema.addOnDataStructure.entries()) {
@@ -717,7 +717,7 @@ async function getApiLinks() {
717
717
  }
718
718
  }
719
719
  }
720
- console.log("apiGateway in function getApiLink", apiGateway)
720
+ // console.log("apiGateway in function getApiLink", apiGateway)
721
721
  return apiGateway
722
722
  } catch (err) {
723
723
  console.error("Error fetching API info:", err);
@@ -62,7 +62,8 @@ const {
62
62
  createValidationFieldNameForEachType,
63
63
  S3_UPLOAD_TYPE,
64
64
  FLOW_SCHEMA_HOOK_STATE,
65
- HANDLER
65
+ HANDLER,
66
+ OBJECT_SCHEMA_BUCKET_NAME
66
67
  } = require("./Consts");
67
68
  const { validateObjType } = require('@izara_project/izara-shared-service-schemas').validateObjType;
68
69
 
@@ -173,7 +174,7 @@ async function validatorSchemaTreeIdentifiers(_izContext, objectSchema, iter = 0
173
174
 
174
175
  let allValidatorTreeCompositeKey = {};
175
176
  for (let compositeKey of identifier.fieldNames) {
176
- let validatorTreeCompositeKey = await generateValidatorSchemaTreePerFieldName(_izContext, compositeKey, objectSchema.fieldNames[compositeKey]);
177
+ let validatorTreeCompositeKey = await generateValidatorSchemaTreePerFieldName(_izContext, compositeKey, objectSchema.fieldNames[compositeKey], bucketName);
177
178
  _izContext.logger.debug("validatorTreeCompositeKey: ", JSON.stringify(validatorTreeCompositeKey));
178
179
 
179
180
  Object.assign(allValidatorTreeCompositeKey, validatorTreeCompositeKey);
@@ -377,7 +378,7 @@ async function generateRelationshipValidatorSchemaForCreate(_izContext, objType)
377
378
  * @param {String[]} specificFieldNames
378
379
  * @returns
379
380
  */
380
- async function generateValidatorSchemaForCreate(_izContext, objType, specificFieldNames = []) {
381
+ async function generateValidatorSchemaForCreate(_izContext, objType, settings = { specificFieldNames: [] }) {
381
382
  const validateObjTypeResult = validateObjType(objType);
382
383
  if (validateObjTypeResult.errorsFound.length > 0) {
383
384
  _izContext.logger.error("generateValidatorSchemaForCreate validateObjTypeResult", validateObjTypeResult);
@@ -385,7 +386,7 @@ async function generateValidatorSchemaForCreate(_izContext, objType, specificFie
385
386
  }
386
387
  _izContext.logger.debug("Function:generateValidatorSchemaForCreate ", {
387
388
  objType,
388
- specificFieldNames
389
+ specificFieldNames: settings.specificFieldNames
389
390
  })
390
391
 
391
392
  const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
@@ -400,8 +401,8 @@ async function generateValidatorSchemaForCreate(_izContext, objType, specificFie
400
401
  requiredFieldNames.push(mainFieldName);
401
402
  Object.assign(usedFieldNamesData, { [mainFieldName]: objectSchema.fieldNames[mainFieldName] });
402
403
  } else if (objectSchema.fieldNames[mainFieldName].optionalOnCreate === true) {
403
- if (specificFieldNames.length) {
404
- if (specificFieldNames.includes(mainFieldName)) {
404
+ if (settings.specificFieldNames.length) {
405
+ if (settings.specificFieldNames.includes(mainFieldName)) {
405
406
  Object.assign(usedFieldNamesData, { [mainFieldName]: objectSchema.fieldNames[mainFieldName] });
406
407
  }
407
408
  } else {
@@ -426,8 +427,8 @@ async function generateValidatorSchemaForCreate(_izContext, objType, specificFie
426
427
  );
427
428
  } else if (versionedDataFieldSetting.optionalOnCreate === true) {
428
429
 
429
- if (specificFieldNames.length) {
430
- if (specificFieldNames.includes(versionedDataFieldName)) {
430
+ if (settings.specificFieldNames.length) {
431
+ if (settings.specificFieldNames.includes(versionedDataFieldName)) {
431
432
  Object.assign(
432
433
  usedFieldNamesData,
433
434
  { [versionedDataFieldName]: versionedDataFieldName }
@@ -453,7 +454,7 @@ async function generateValidatorSchemaForCreate(_izContext, objType, specificFie
453
454
  let validatorSchemaFieldName = await generateValidatorSchemaTreePerFieldName(
454
455
  _izContext,
455
456
  fieldName,
456
- usedFieldNamesData[fieldName]
457
+ usedFieldNamesData[fieldName],
457
458
  );
458
459
 
459
460
  Object.assign(allValidatorSchemaFieldNames, validatorSchemaFieldName);
@@ -493,17 +494,16 @@ async function generateValidatorSchemaForCreate(_izContext, objType, specificFie
493
494
 
494
495
 
495
496
  /*
496
- collect which field is requied and optional
497
+ collect which field is required and optional
497
498
  should require name of identifier instead of fieldName that part of identifiers
498
499
  Note : should add setting for api in this function
499
500
  */
500
- async function generateValidatorSchemaForUpdate(_izContext, objType, setting = {}) {
501
+ async function generateValidatorSchemaForUpdate(_izContext, objType, settings = { specificFieldNames: [] }) {
501
502
 
502
503
  _izContext.logger.debug("Function:generateValidatorSchemaForUpdate2 ", {
503
504
  objType,
504
- setting,
505
+ setting: settings,
505
506
  })
506
- setting.specificFieldNames = setting?.specificFieldNames ? setting.specificFieldNames : []
507
507
  // const objType = createObjType(objectType);
508
508
  const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
509
509
  _izContext.logger.debug("objectSchema", objectSchema)
@@ -530,9 +530,9 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, setting = {
530
530
  }
531
531
 
532
532
  // collect usedFieldNames
533
- if (setting?.specificFieldNames) {
534
- if (setting.specificFieldNames.length) {
535
- for (let specificFieldName of setting.specificFieldNames) {
533
+ if (settings?.specificFieldNames) {
534
+ if (settings.specificFieldNames.length) {
535
+ for (let specificFieldName of settings.specificFieldNames) {
536
536
  if (canUpdateFieldNames.includes(specificFieldName)) {
537
537
  usedFieldNames.push(specificFieldName);
538
538
  } else {
@@ -563,7 +563,7 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, setting = {
563
563
  properties: {
564
564
  identifiers: {
565
565
  type: "object",
566
- ... await filteredFieldNamesOfValidatorSchema(_izContext, objType, identifiersFieldNames, identifiersFieldNames)
566
+ ... await filteredFieldNamesOfValidatorSchema(_izContext, objType, identifiersFieldNames, identifiersFieldNames, settings.bucketName)
567
567
  },
568
568
  fields: {
569
569
  type: "object",
@@ -605,7 +605,7 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, setting = {
605
605
  }
606
606
 
607
607
 
608
- Object.assign(initialValidatorSchemaForUpdate.properties.objInstanceFull.properties.fields, await filteredFieldNamesOfValidatorSchema(_izContext, objType, [], defaultFieldNames))
608
+ Object.assign(initialValidatorSchemaForUpdate.properties.objInstanceFull.properties.fields, await filteredFieldNamesOfValidatorSchema(_izContext, objType, [], defaultFieldNames, settings.bucketName))
609
609
  Object.assign(initialValidatorSchemaForUpdate.properties.objInstanceFull.properties.fields.properties, versionedDataReturnInFieldsObjInstanceFull);
610
610
 
611
611
  _izContext.logger.debug("validatorSchema", initialValidatorSchemaForUpdate)
@@ -623,7 +623,7 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, setting = {
623
623
  *
624
624
  * @returns {object} json validator schema
625
625
  */
626
- async function generateValidatorSchemaForIdentifier(_izContext, objType) {
626
+ async function generateValidatorSchemaForIdentifier(_izContext, objType, settings = { bucketName: OBJECT_SCHEMA_BUCKET_NAME }) {
627
627
  const validateObjTypeResult = validateObjType(objType);
628
628
  if (validateObjTypeResult.errorsFound.length > 0) {
629
629
  _izContext.logger.error("generateValidatorSchemaForIdentifier validateObjTypeResult", validateObjTypeResult);
@@ -633,9 +633,9 @@ async function generateValidatorSchemaForIdentifier(_izContext, objType) {
633
633
  objType,
634
634
  })
635
635
 
636
- const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
636
+ const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType, settings.bucketName);
637
637
 
638
- let generatedIdentifiersValidatorSchema = await validatorSchemaTreeIdentifiersFieldNames(_izContext, objectSchema);
638
+ let generatedIdentifiersValidatorSchema = await validatorSchemaTreeIdentifiersFieldNames(_izContext, objectSchema, settings.bucketName);
639
639
  _izContext.logger.debug("generatedIdentifiersValidatorSchema: ", generatedIdentifiersValidatorSchema);
640
640
 
641
641
  return {
@@ -676,7 +676,7 @@ async function filteredFieldNamesOfValidatorSchema(_izContext, objType, required
676
676
  usedFieldNames
677
677
  });
678
678
 
679
- let allValidatorSchema = await generateValidatorSchemaForExplodedDataWithCache(_izContext, objType);
679
+ let allValidatorSchema = await generateValidatorSchemaForExplodedDataWithCache(_izContext, objType, process.env.iz_serviceSchemaBucketName);
680
680
  _izContext.logger.debug("filteredFieldNamesOfValidatorSchema allValidatorSchema : ", allValidatorSchema)
681
681
 
682
682
  allValidatorSchema.required = requiredFieldNames;
@@ -918,6 +918,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
918
918
  try {
919
919
  const serviceConfig = readYamlFile.sync(serviceConfigPath);
920
920
  const iz_serviceTag = serviceConfig.main_config.iz_serviceTag;
921
+ const iz_serviceSchemaBucketName = serviceConfig.main_config.iz_serviceSchemaBucketName
921
922
  console.log("schemasPath", schemasPath);
922
923
  console.log("serviceConfigPath", serviceConfigPath)
923
924
 
@@ -1208,14 +1209,13 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1208
1209
  // validate ref relationships in external path s3
1209
1210
  await Promise.all(
1210
1211
  allReferenceObjectRelationships.map(async (refRelSchema) => {
1211
- const relSchemaFromRef = await getRelationshipSchema
1212
- (
1213
- _izContext,
1214
- {
1215
- serviceTag: refRelSchema.relationshipServiceTag,
1216
- relationshipTag: refRelSchema.relationshipTag
1217
- }
1218
- )
1212
+ const relSchemaFromRef = await getRelationshipSchema(
1213
+ _izContext,
1214
+ {
1215
+ serviceTag: refRelSchema.relationshipServiceTag,
1216
+ relationshipTag: refRelSchema.relationshipTag
1217
+ }
1218
+ )
1219
1219
  if (!relSchemaFromRef) {
1220
1220
  validateStatus.status = false;
1221
1221
  validateStatus.referenceErrors.push(`Invalid reference relationship of objectType: '${refRelSchema.objectType}' >> relationshipTag: '${refRelSchema.relationshipTag}' not exists in service: '${refRelSchema.relationshipServiceTag}'`)
@@ -19,13 +19,12 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
19
19
  const { createRelTypeConcat, createLinkTypeId } = require('../Utils');
20
20
  const getObjectSchema = require('../GetObjectSchema');
21
21
  const serviceConfig = require('../ServiceConfig');
22
- const { STORAGE_TYPES } = require('../Consts')
22
+ const { STORAGE_TYPES, OBJECT_SCHEMA_BUCKET_NAME } = require('../Consts')
23
23
  const { getObjTypeHierarchy } = require('../GetObjectSchema')
24
24
 
25
- async function validateRequiredOnCreateLinks(_izContext, objType, relationships, settings = {}) {
25
+ async function validateRequiredOnCreateLinks(_izContext, objType, relationships = [], settings = {}) {
26
26
  _izContext.logger.debug("validateRequiredOnCreateLinks:::", { objType, relationships, settings })
27
27
 
28
-
29
28
  let objectHie = await getObjTypeHierarchy(_izContext, objType).then(objSchema => {
30
29
  if (objSchema.errorsFound.length > 0) {
31
30
  throw new NoRetryError(objSchema.errorsFound.join(","))
@@ -49,7 +48,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships,
49
48
 
50
49
  let errorsFound = [];
51
50
 
52
- let requiredOnCreateLinks = await getObjectSchema.getRequiredOnCreateLinksWithCache(_izContext, objType)
51
+ let requiredOnCreateLinks = await getObjectSchema.getRequiredOnCreateLinksWithCache(_izContext, objType, [])
53
52
  _izContext.logger.debug("requiredOnCreateLinks::", requiredOnCreateLinks)
54
53
 
55
54
  if (!requiredOnCreateLinks.length && relationships.length > 0) {
@@ -43,7 +43,7 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
43
43
  [fieldName]: {},
44
44
  };
45
45
 
46
- if (objType) {
46
+ if (Object.keys(objType).length) {
47
47
  Object.assign(deliminatorTree[fieldName], objType);
48
48
  }
49
49
 
@@ -57,7 +57,8 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
57
57
  {
58
58
  objectType: fieldNameSetting.fromObjectType,
59
59
  serviceTag: fieldNameSetting.fromServiceNameTag
60
- }
60
+ },
61
+ process.env.iz_serviceSchemaBucketName
61
62
  );
62
63
 
63
64
  if (!childObjectSchema) {
@@ -280,7 +280,9 @@ async function explodedDataForIdentifiers(_izContext, requestParams, objectSchem
280
280
  await deliminatorTree.generateDeliminatorTreePerFieldName(
281
281
  _izContext,
282
282
  identifierKey,
283
- objectSchema.fieldNames[identifierKey]
283
+ objectSchema.fieldNames[identifierKey],
284
+ {},
285
+ settings.bucketName
284
286
  )
285
287
  );
286
288
 
@@ -337,15 +339,14 @@ async function explodedDataForIdentifiers(_izContext, requestParams, objectSchem
337
339
  return explodedReqParams;
338
340
  }
339
341
 
340
- async function explodedDataForUpdate(_izContext, requestParams, objectSchema, setting) {
342
+ async function explodedDataForUpdate(_izContext, requestParams, objectSchema) {
341
343
  //validate requestParams
342
344
  _izContext.logger.debug("explodedDataForUpdate::",
343
345
  {
344
- requestParams, objectSchema, setting
346
+ requestParams, objectSchema, settings
345
347
  }
346
348
  )
347
-
348
- let errors = [];
349
+ let errorsFound = [];
349
350
 
350
351
  const propertiesTypeForUpdate = {
351
352
  objInstanceFull: {
@@ -370,16 +371,16 @@ async function explodedDataForUpdate(_izContext, requestParams, objectSchema, se
370
371
  for (let prop in propertiesTypeForUpdate) {
371
372
  if (propertiesTypeForUpdate[prop].required === true) {
372
373
  if (!requestParams.hasOwnProperty(prop)) {
373
- errors.push(`Missing require property: ${prop}`);
374
+ errorsFound.push(`Missing require property: ${prop}`);
374
375
  }
375
376
 
376
377
  if (requestParams.hasOwnProperty(prop)) {
377
378
  if (typeof (requestParams[prop]) !== propertiesTypeForUpdate[prop].type) {
378
- errors.push(`property ${prop} type should be ${propertiesTypeForUpdate[prop].type}`);
379
+ errorsFound.push(`property ${prop} type should be ${propertiesTypeForUpdate[prop].type}`);
379
380
  }
380
381
  }
381
382
  if (propertiesTypeForUpdate[prop].type === "object" && requestParams[prop] === null) {
382
- errors.push(`property: ${[prop]} type should be ${propertiesTypeForUpdate[prop].type}`)
383
+ errorsFound.push(`property: ${[prop]} type should be ${propertiesTypeForUpdate[prop].type}`)
383
384
  }
384
385
  }
385
386
  }
@@ -401,7 +402,7 @@ async function explodedDataForUpdate(_izContext, requestParams, objectSchema, se
401
402
  Object.entries(requestParams.objInstanceFull.identifiers).map(
402
403
  async ([reqPropKey, reqPropValue]) => {
403
404
  if (!deliminatorTreeFieldNames.hasOwnProperty(reqPropKey)) {
404
- errors.push(`property:${reqPropKey} not match with fieldNames of ObjectSchema`);
405
+ errorsFound.push(`property:${reqPropKey} not match with fieldNames of ObjectSchema`);
405
406
  }
406
407
 
407
408
  let explodedIdentifiers
@@ -415,7 +416,7 @@ async function explodedDataForUpdate(_izContext, requestParams, objectSchema, se
415
416
  }
416
417
  )
417
418
  } catch (err) {
418
- errors.push(err)
419
+ errorsFound.push(err)
419
420
  }
420
421
  _izContext.logger.debug("explodedIdentifiers", explodedIdentifiers)
421
422
  Object.assign(explodedReqParams.objInstanceFull.identifiers, explodedIdentifiers)
@@ -438,7 +439,7 @@ async function explodedDataForUpdate(_izContext, requestParams, objectSchema, se
438
439
  }
439
440
  )
440
441
  } catch (err) {
441
- errors.push(err)
442
+ errorsFound.push(err)
442
443
  }
443
444
  _izContext.logger.debug("explodedField", explodedField)
444
445
  Object.assign(explodedReqParams.objInstanceFull.fields, explodedField)
@@ -23,7 +23,7 @@ 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");
26
- const { getObjTypeHierarchy } = require('../GetObjectSchema')
26
+ const { getObjTypeHierarchy } = require('../GetObjectSchema');
27
27
  /**
28
28
  * helper function for find link of 2 objects in links and refactor each link
29
29
  *
@@ -52,14 +52,14 @@ async function findLinksByObjTypes(_izContext, objTypes, relationshipLinks) {
52
52
  const secondObjType = objTypes[1];
53
53
 
54
54
  // first create hierarchy of each objType
55
- const firstObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[0]).then(objSchema => {
55
+ const firstObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[0], process.env.iz_serviceSchemaBucketName).then(objSchema => {
56
56
  if (objSchema.errorsFound.length > 0) {
57
57
  throw new NoRetryError(objSchema.errorsFound.join(","))
58
58
  } else {
59
59
  return objSchema.result
60
60
  }
61
61
  });
62
- const secondObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[1]).then(objSchema => {
62
+ const secondObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[1], process.env.iz_serviceSchemaBucketName).then(objSchema => {
63
63
  if (objSchema.errorsFound.length > 0) {
64
64
  throw new NoRetryError(objSchema.errorsFound.join(","))
65
65
  } else {
@@ -60,6 +60,8 @@ async function getObjectS3Shared(param) {
60
60
  return object;
61
61
  }
62
62
 
63
+
64
+
63
65
  async function getSchemaByName(params) {
64
66
  if (!params.schemaName || !params.getParams) {
65
67
  throw new NoRetryError(`getSchemaByName invalid parameters`);
@@ -71,7 +73,7 @@ async function getSchemaByName(params) {
71
73
 
72
74
  // build params for getObjectS3
73
75
  let getDataParam = {
74
- Bucket: OBJECT_SCHEMA_BUCKET_NAME,
76
+ Bucket: process.env.iz_serviceSchemaBucketName,
75
77
  Key: SCHEMA_NAME_PER_S3_PATH[params.schemaName](params.getParams)
76
78
  };
77
79