@izara_project/izara-core-library-service-schemas 1.0.99 → 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.
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  /*
2
3
  Copyright (C) 2021 Sven Mason <http://izara.io>
3
4
 
@@ -16,23 +17,40 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
  */
17
18
 
18
19
  'use strict';
20
+ // .src
21
+
22
+ import deliminatorTree from './src/libs/DeliminatorTree.js';
23
+ import explodedReqParams from './src/libs/ExplodedReqParams.js';
24
+ import uploadUseCase from './src/libs/UploadUseCase.js';
25
+ import relSchemaLib from './src/libs/RelSchemaLib.js';
26
+ import s3Utils from './src/libs/s3Utils.js';
27
+ import createNodeLib from './src/libs/CreateNodeLib.js';
28
+
29
+ import consts from './src/Consts.js';
30
+ import getObjectSchema from './src/GetObjectSchema.js';
31
+ import uploadObjSchema from './src/UploadObjSchema.js';
32
+ import validator from './src/ValidatorSchema.js';
33
+ import serviceConfig from './src/ServiceConfig.js';
34
+ import utils from './src/Utils.js';
35
+ import identifiersObject from './src/IdentifiersObject.js';
36
+ import sharedUtils from './src/SharedUtils.js';
37
+
38
+ export {
39
+ // ./src/lib/
40
+ deliminatorTree,
41
+ explodedReqParams,
42
+ uploadUseCase,
43
+ relSchemaLib,
44
+ s3Utils,
45
+ createNodeLib,
19
46
 
20
- module.exports = {
21
- // .src/libs
22
- deliminatorTree: require('./src/libs/DeliminatorTree'),
23
- explodedReqParams: require('./src/libs/ExplodedReqParams'),
24
- uploadUseCase: require('./src/libs/UploadUseCase'),
25
- relSchemaLib: require('./src/libs/RelSchemaLib'),
26
- s3Utils: require('./src/libs/s3Utils'),
27
- createNodeLib: require('./src/libs/CreateNodeLib'),
28
-
29
- // .src
30
- consts: require('./src/Consts'),
31
- getObjectSchema: require('./src/GetObjectSchema'),
32
- uploadObjSchema: require('./src/UploadObjSchema'),
33
- validator: require('./src/ValidatorSchema'),
34
- serviceConfig: require('./src/ServiceConfig'),
35
- utils: require('./src/Utils'),
36
- identifiersObject: require('./src/IdentifiersObject'),
37
- sharedUtils: require('./src/SharedUtils'),
38
- }
47
+ // ./src/
48
+ consts,
49
+ getObjectSchema,
50
+ uploadObjSchema,
51
+ validator,
52
+ serviceConfig,
53
+ utils,
54
+ identifiersObject,
55
+ sharedUtils,
56
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-library-service-schemas",
3
- "version": "1.0.99",
3
+ "version": "1.0.101",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,26 +14,26 @@
14
14
  "license": "AGPL-3.0-or-later",
15
15
  "homepage": "https://bitbucket.org/izara-core-libraries/izara-core-library-service-schemas/src/master/README.md",
16
16
  "devDependencies": {
17
- "jest": "^30.0.5"
17
+ "jest": "^30.2.0"
18
18
  },
19
19
  "jest": {
20
20
  "testEnvironment": "node"
21
21
  },
22
+ "type": "module",
22
23
  "dependencies": {
23
- "@aws-sdk/client-api-gateway": "^3.862.0",
24
- "@aws-sdk/client-apigatewayv2": "^3.862.0",
25
- "@aws-sdk/client-lambda": "^3.862.0",
26
- "@aws-sdk/client-s3": "^3.862.0",
27
- "@aws-sdk/crc64-nvme-crt": "^3.862.0",
28
- "@izara_project/izara-core-library-core": "^1.0.24",
29
- "@izara_project/izara-core-library-external-request": "^1.0.21",
30
- "@izara_project/izara-core-library-lambda": "^1.0.5",
31
- "@izara_project/izara-core-library-logger": "^1.0.7",
32
- "@izara_project/izara-shared-core": "^1.0.2",
33
- "@izara_project/izara-shared-service-schemas": "^1.0.32",
24
+ "@aws-sdk/client-api-gateway": "^3.932.0",
25
+ "@aws-sdk/client-apigatewayv2": "^3.932.0",
26
+ "@aws-sdk/client-lambda": "^3.932.0",
27
+ "@aws-sdk/client-s3": "^3.932.0",
28
+ "@aws-sdk/crc64-nvme-crt": "^3.932.0",
29
+ "@izara_project/izara-core-library-core": "^1.0.28",
30
+ "@izara_project/izara-core-library-external-request": "^1.0.22",
31
+ "@izara_project/izara-core-library-lambda": "^1.0.6",
32
+ "@izara_project/izara-core-library-logger": "^1.0.8",
33
+ "@izara_project/izara-shared-core": "^1.0.5",
34
+ "@izara_project/izara-shared-service-schemas": "^1.0.33",
34
35
  "glob": "^11.0.3",
35
36
  "lodash": "^4.17.21",
36
- "object-hash": "^3.0.0",
37
37
  "read-yaml-file": "^2.1.0"
38
38
  }
39
39
  }
package/src/Consts.js CHANGED
@@ -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 { validateRelType, validateObjType, validateFlowType } = require('@izara_project/izara-shared-service-schemas').validateObjType;
22
+ import { validateObjType } from '@izara_project/izara-shared-service-schemas';
23
23
 
24
24
  const FIELDNAME_TYPES = {
25
25
  string: "string",
@@ -107,7 +107,7 @@ const PREFIX_PATH_S3 = {
107
107
  // --------- Upload path ---------------
108
108
 
109
109
  function relationshipTagPathS3(_izContext, relType) {
110
- const validateRelTypeResult = validateRelType(relType);
110
+ const validateRelTypeResult = validateObjType.validateRelType(relType);
111
111
  if (validateRelTypeResult.errorsFound.length > 0) {
112
112
  throw new NoRetryError(`function relationshipTagPathS3: invalid relType ${relType.name} - ${validateRelTypeResult.errorsFound.join(", ")}`);
113
113
  }
@@ -115,7 +115,7 @@ function relationshipTagPathS3(_izContext, relType) {
115
115
  }
116
116
 
117
117
  function objectRelationshipPathS3(_izContext, objType) {
118
- const validateObjTypeResult = validateObjType(objType);
118
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
119
119
  if (validateObjTypeResult.errorsFound.length > 0) {
120
120
  throw new NoRetryError(`function objectRelationshipPathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
121
121
  }
@@ -132,7 +132,7 @@ function linkByLinkTypeIdPathS3(_izContext, serviceTag, linkTypeId) {
132
132
 
133
133
 
134
134
  function refObjectRelationshipPathS3(_izContext, objType) {
135
- const validateObjTypeResult = validateObjType(objType);
135
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
136
136
  if (validateObjTypeResult.errorsFound.length > 0) {
137
137
  throw new NoRetryError(`function refObjectRelationshipPathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
138
138
  }
@@ -140,7 +140,7 @@ function refObjectRelationshipPathS3(_izContext, objType) {
140
140
  }
141
141
 
142
142
  function objectSchemaAllPathS3(_izContext, objType) {
143
- const validateObjTypeResult = validateObjType(objType);
143
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
144
144
  if (validateObjTypeResult.errorsFound.length > 0) {
145
145
  throw new NoRetryError(`function objectSchemaAllPathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
146
146
  }
@@ -148,7 +148,7 @@ function objectSchemaAllPathS3(_izContext, objType) {
148
148
  }
149
149
 
150
150
  function objectSchemaCreatePathS3(_izContext, objType) {
151
- const validateObjTypeResult = validateObjType(objType);
151
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
152
152
  if (validateObjTypeResult.errorsFound.length > 0) {
153
153
  throw new NoRetryError(`function objectSchemaCreatePathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
154
154
  }
@@ -156,7 +156,7 @@ function objectSchemaCreatePathS3(_izContext, objType) {
156
156
  }
157
157
 
158
158
  function objectSchemaDisplayPathS3(_izContext, objType) {
159
- const validateObjTypeResult = validateObjType(objType);
159
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
160
160
  if (validateObjTypeResult.errorsFound.length > 0) {
161
161
  throw new NoRetryError(`function objectSchemaDisplayPathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
162
162
  }
@@ -164,7 +164,7 @@ function objectSchemaDisplayPathS3(_izContext, objType) {
164
164
  }
165
165
 
166
166
  function objectSchemaCombineFieldNamesPathS3(_izContext, objType) {
167
- const validateObjTypeResult = validateObjType(objType);
167
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
168
168
  if (validateObjTypeResult.errorsFound.length > 0) {
169
169
  throw new NoRetryError(`function objectSchemaCombineFieldNamesPathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
170
170
  }
@@ -200,7 +200,7 @@ function serviceNamePathS3(_izContext, serviceTag) {
200
200
  }
201
201
 
202
202
  function flowSchemaPathS3(_izContext, flowType) {
203
- const validateFlowTypeResult = validateFlowType(flowType);
203
+ const validateFlowTypeResult = validateObjType.validateFlowType(flowType);
204
204
  if (validateFlowTypeResult.errorsFound.length > 0) {
205
205
  throw new NoRetryError(`function flowSchemaPathS3: invalid flowType ${flowType.name} - ${validateFlowTypeResult.errorsFound.join(", ")}`);
206
206
  }
@@ -304,7 +304,7 @@ function createValidationFieldNameForEachType(type, validation) {
304
304
  // }
305
305
 
306
306
  function getEndpointPerObjectType(_izContext, objType) {
307
- let validateObjTypeResult = validateObjType(objType);
307
+ let validateObjTypeResult = validateObjType.validateObjType(objType);
308
308
  if (validateObjTypeResult.errorsFound.length > 0) {
309
309
  throw new NoRetryError(`function flowSchemaPathS3: invalid flowType ${flowType.name} - ${validateFlowTypeResult.errorsFound.join(", ")}`);
310
310
  }
@@ -353,7 +353,7 @@ function firstLetterLowerCase(str) {
353
353
 
354
354
  // --------- End Upload path ---------------
355
355
 
356
- module.exports = {
356
+ export default {
357
357
  LOCAL_OBJECT_SCHEMA_PATH: './src/schemas', // schema folder path in lambda environment
358
358
 
359
359
  OBJECT_SCHEMA_BUCKET_NAME: 'object-schema',
@@ -18,65 +18,21 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
 
20
20
 
21
- const glob = require('glob')
22
- const path = require('path')
23
- const lodash = require('lodash');
24
-
25
- const hash = require('@izara_project/izara-shared-core').objectHash;
26
-
27
- const sharedServiceSchema = require("@izara_project/izara-shared-service-schemas");
28
- const {
29
- getObjSchemaS3: getObjectSchemaS3Shared,
30
- getObjSchemaWithHierarchy,
31
- getObjSchemaWithoutHierarchy,
32
- mergeExtendObjSchema: mergeExtendObjSchemaShared,
33
- // recursiveMergeExtendObjSchema: recursiveMergeExtendObjSchemaShared,
34
- getRefObjectRelationship: getRefObjectRelationshipShared,
35
- getRelationshipSchema: getRelationshipSchemaShared,
36
- getObjectRelationship: getObjectRelationshipShared,
37
- getRequiredOnCreateLinks: getRequiredOnCreateLinksShared,
38
- getLinkConfigByLinkTypeId: getLinkConfigByLinkTypeIdShared,
39
- getObjTypeHierarchy: getObjTypeHierarchyShared,
40
- getObjectSchemaForCreate: getObjectSchemaForCreateShared,
41
- getObjectSchemaForUpdate: getObjectSchemaForUpdateShared,
42
- getFlowSchemaS3: getFlowSchemaS3Shared
43
- } = sharedServiceSchema.getObjectSchema;
44
- const { validateObjType, validateFlowType } = sharedServiceSchema.validateObjType;
45
- const {
46
- basicFieldNameSchema,
47
- basicFieldNameSchemaForCombineFieldName
48
- } = sharedServiceSchema.basicValidatorSchema;
49
-
50
- const {
51
- inMemoryCacheLib,
52
- NoRetryError,
53
- validator: { validateObject },
54
- } = require('@izara_project/izara-core-library-core');
55
-
56
-
57
- // const dynamodbSharedLib = require('@izara_project/izara-shared/src/DynamodbSharedLib');
58
- // const Logger = require('@izara_project/izara-core-library-logger')
59
-
60
- const { getObjectS3, headObjectS3, getSchemaByNameWithCache, getSchemaByName } = require("./libs/s3Utils");
61
- const { generateObjectSchemaForCombineFieldNames } = require("./libs/UploadUseCase");
62
-
63
- const {
64
- LOCAL_OBJECT_SCHEMA_PATH,
65
-
66
- UPLOAD_PATH_S3,
67
-
68
- LOCAL_FILENAME,
69
- STORAGE_TYPES
70
- } = require('./Consts')
71
-
72
- const {
73
- findLinkByObjTypeV2,
74
- getUsedFieldNamesOfIdentifiers,
75
- createLinkTypeId
76
- } = require('./Utils');
77
-
78
-
79
- const { listLambdaFunctions } = require('./libs/LambdaUtils');
21
+ import { glob } from 'glob';
22
+ import path from 'path';
23
+ import lodash from 'lodash';
24
+ import { objectHash as hash } from '@izara_project/izara-shared-core';
25
+ import { getObjectSchema, validateObjType } from "@izara_project/izara-shared-service-schemas";
26
+ import { inMemoryCacheLib, NoRetryError } from '@izara_project/izara-core-library-core';
27
+
28
+
29
+ // import dynamodbSharedLib from ('@izara_project/izara-shared/src/DynamodbSharedLib');
30
+ // import Logger from ('@izara_project/izara-core-library-logger')
31
+
32
+ import s3Utils from "./libs/s3Utils.js";
33
+ import uploadUseCase from "./libs/UploadUseCase.js"
34
+ import consts from './Consts.js'
35
+ import lambdaUtils from './libs/LambdaUtils.js';
80
36
 
81
37
  /**
82
38
  * get array of data from specific path in local environment
@@ -145,7 +101,7 @@ function getDataFromPath(
145
101
 
146
102
  // const objectTypesData = getDataFromPath(
147
103
  // _izContext,
148
- // LOCAL_FILENAME.OBJECT_TYPES,
104
+ // consts.LOCAL_FILENAME.OBJECT_TYPES,
149
105
  // objSchemaPath,
150
106
  // {
151
107
  // fileLimit: 1,
@@ -166,7 +122,7 @@ function getDataFromPath(
166
122
  * @param {boolean} [getExtendObType = false] Optional default = false , If = true will get extendObjectType before return
167
123
  * @returns {Promise<object>} Return object schema of objectTypes
168
124
  */
169
- async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH, getExtendObType = false) {
125
+ async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH, getExtendObType = false) {
170
126
  let errorsFound = [];
171
127
  // validate objectTypes
172
128
  if (!objectTypes) {
@@ -212,7 +168,7 @@ async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = LO
212
168
  // returnValue.fieldLookup[objectType] = null;
213
169
  }
214
170
 
215
- let allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
171
+ let allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
216
172
  .flat()
217
173
  .filter(schema => filteredObjectTypes.includes(schema.objectType))
218
174
  );
@@ -260,7 +216,7 @@ async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = LO
260
216
  *
261
217
  * @see {@link getLocalObjectSchemas}
262
218
  */
263
- async function getLocalObjectSchemasWithHierarchy(_izContext, objectTypes, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
219
+ async function getLocalObjectSchemasWithHierarchy(_izContext, objectTypes, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
264
220
  return await getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath, true)
265
221
  }
266
222
 
@@ -270,7 +226,7 @@ async function getLocalObjectSchemasWithHierarchy(_izContext, objectTypes, objSc
270
226
  *
271
227
  * @see {@link getLocalObjectSchemas}
272
228
  */
273
- async function getLocalObjectSchemasWithoutHierarchy(_izContext, objectTypes, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
229
+ async function getLocalObjectSchemasWithoutHierarchy(_izContext, objectTypes, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
274
230
  return await getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath, false)
275
231
  }
276
232
 
@@ -283,7 +239,7 @@ async function getLocalObjectSchemasWithoutHierarchy(_izContext, objectTypes, ob
283
239
  * @param {boolean} [getExtendObType = false] - Optional default = false , If = true will get extendObjectType before return
284
240
  * @returns {Promise<object>} - Return all objectSchema from local service
285
241
  */
286
- async function getAllLocalObjectSchemas(_izContext, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH, getExtendObType = false) {
242
+ async function getAllLocalObjectSchemas(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH, getExtendObType = false) {
287
243
 
288
244
  //initial return value
289
245
  let returnValue = {
@@ -294,7 +250,7 @@ async function getAllLocalObjectSchemas(_izContext, objSchemaPath = LOCAL_OBJECT
294
250
 
295
251
  // const objectTypeList = getObjectTypes(_izContext, objSchemaPath)
296
252
 
297
- const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
253
+ const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
298
254
  .flat()
299
255
  // .filter(schema => objectTypeList.includes(schema.objectType))
300
256
  );
@@ -350,7 +306,7 @@ async function getAllLocalObjectSchemas(_izContext, objSchemaPath = LOCAL_OBJECT
350
306
  *
351
307
  * @see {@link getAllLocalObjectSchemas}
352
308
  */
353
- async function getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
309
+ async function getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
354
310
  return await getAllLocalObjectSchemas(_izContext, objSchemaPath, true)
355
311
  }
356
312
 
@@ -359,7 +315,7 @@ async function getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath =
359
315
  *
360
316
  * @see {@link getAllLocalObjectSchemas}
361
317
  */
362
- async function getAllLocalObjectSchemasWithoutHierarchy(_izContext, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
318
+ async function getAllLocalObjectSchemasWithoutHierarchy(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
363
319
  return await getAllLocalObjectSchemas(_izContext, objSchemaPath, false)
364
320
  }
365
321
 
@@ -371,7 +327,7 @@ async function getLambdaFunctionNames(_izContext) {
371
327
  try {
372
328
  _izContext.logger.debug("-- function getLambdaFunctionNames --");
373
329
 
374
- const LambdaFunctions = getDataFromPath(_izContext, LOCAL_FILENAME.LAMBDA_FUNCTIONS, LOCAL_OBJECT_SCHEMA_PATH, {
330
+ const LambdaFunctions = getDataFromPath(_izContext, consts.LOCAL_FILENAME.LAMBDA_FUNCTIONS, consts.LOCAL_OBJECT_SCHEMA_PATH, {
375
331
  fileLimit: 1
376
332
  })[0];
377
333
  _izContext.logger.debug("LambdaFunctions: ", LambdaFunctions);
@@ -384,7 +340,7 @@ async function getLambdaFunctionNames(_izContext) {
384
340
 
385
341
  try {
386
342
  do {
387
- const { Functions, NextMarker } = await listLambdaFunctions(_izContext, { Marker: marker });
343
+ const { Functions, NextMarker } = await lambdaUtils(_izContext, { Marker: marker });
388
344
 
389
345
  const filteredNames = Functions
390
346
  .map(func => func.FunctionName)
@@ -472,7 +428,7 @@ async function getObjSchemaS3(
472
428
  getExtendObType = false
473
429
  ) {
474
430
 
475
- return await getObjectSchemaS3Shared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName, getExtendObType).then(res => {
431
+ return await getObjectSchema.getObjSchemaS3(s3Utils.getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName, getExtendObType).then(res => {
476
432
  if (res.errorsFound.length && res.errorsFound.length > 0) {
477
433
  throw new NoRetryError(res.errorsFound.join(","))
478
434
  } else {
@@ -506,7 +462,7 @@ const getObjSchemaS3WithCache = inMemoryCacheLib(
506
462
  */
507
463
  async function getObjSchemaS3WithHierarchy(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
508
464
  // return await getObjSchemaS3WithCache(_izContext, objType, true)
509
- return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType, bucketName).then(res => {
465
+ return await getObjectSchema.getObjSchemaWithHierarchy(s3Utils.getSchemaByNameWithCache, objType, bucketName).then(res => {
510
466
  if (res.errorsFound.length && res.errorsFound.length > 0) {
511
467
  throw new NoRetryError(res.errorsFound.join(","))
512
468
  } else {
@@ -523,7 +479,7 @@ async function getObjSchemaS3WithHierarchy(_izContext, objType, bucketName = pro
523
479
  */
524
480
  async function getObjSchemaS3WithoutHierarchy(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
525
481
  // return await getObjSchemaS3WithCache(_izContext, objType, false)
526
- return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType, bucketName).then(res => {
482
+ return await getObjectSchema.getObjSchemaWithoutHierarchy(s3Utils.getSchemaByNameWithCache, objType, bucketName).then(res => {
527
483
  if (res.errorsFound.length && res.errorsFound.length > 0) {
528
484
  throw new NoRetryError(res.errorsFound.join(","))
529
485
  } else {
@@ -545,7 +501,7 @@ async function getObjSchemaS3WithoutHierarchy(_izContext, objType, bucketName =
545
501
  async function getObjectSchemaCombineFieldNames(_izContext, objType) {
546
502
 
547
503
  const objSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
548
- const combinedSchema = generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
504
+ const combinedSchema = uploadUseCase.generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
549
505
  return combinedSchema
550
506
  }
551
507
 
@@ -581,7 +537,7 @@ const getObjectSchemaCombineFieldNamesWithCache = inMemoryCacheLib(
581
537
  * @param {String} [objSchemaPath] - Optional default = './src/schemas', need objSchemaPath if use in local machine
582
538
  * @returns {Object} - specific relationship schema
583
539
  */
584
- function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
540
+ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
585
541
 
586
542
  // validate objectTypes
587
543
  if (!relationshipTags) {
@@ -599,7 +555,7 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
599
555
 
600
556
  const objectRelationshipDatas = getDataFromPath(
601
557
  _izContext,
602
- LOCAL_FILENAME.OBJECT_RELATIONSHIPS,
558
+ consts.LOCAL_FILENAME.OBJECT_RELATIONSHIPS,
603
559
  objSchemaPath,
604
560
  {
605
561
  fileLimit: 1,
@@ -640,7 +596,7 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
640
596
  * @returns {Promise<Object>} - reference relationship schema of objType
641
597
  */
642
598
  async function getRefObjectRelationship(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
643
- return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType, bucketName).then(res => {
599
+ return await getObjectSchema.getRefObjectRelationship(s3Utils.getSchemaByNameWithCache, objType, bucketName).then(res => {
644
600
  if (res.errorsFound.length && res.errorsFound.length > 0) {
645
601
  throw new NoRetryError(res.errorsFound.join(","))
646
602
  } else {
@@ -675,7 +631,7 @@ const getRefObjectRelationshipWithCache = inMemoryCacheLib(
675
631
  *
676
632
  */
677
633
  async function getRelationshipSchema(_izContext, relType, bucketName = process.env.iz_serviceSchemaBucketName) {
678
- return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType, bucketName).then(res => {
634
+ return await getObjectSchema.getRelationshipSchema(s3Utils.getSchemaByNameWithCache, relType, bucketName).then(res => {
679
635
  if (res.errorsFound.length && res.errorsFound.length > 0) {
680
636
  throw new NoRetryError(res.errorsFound.join(","))
681
637
  } else {
@@ -718,13 +674,13 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
718
674
  objType,
719
675
  });
720
676
 
721
- const validateObjTypeResult = validateObjType(objType);
677
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
722
678
  if (validateObjTypeResult.errorsFound.length > 0) {
723
679
  _izContext.logger.error("getRelationshipServiceTag: Invalid objType: ", validateObjTypeResult.errorsFound);
724
680
  throw new NoRetryError(`getRelationshipServiceTag: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
725
681
  }
726
682
 
727
- const relTagPath = UPLOAD_PATH_S3.relationshipTag(
683
+ const relTagPath = consts.UPLOAD_PATH_S3.relationshipTag(
728
684
  _izContext,
729
685
  { // relType
730
686
  serviceTag: objType.serviceTag,
@@ -732,7 +688,7 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
732
688
  }
733
689
  );
734
690
 
735
- let relSchemaHeadData = await headObjectS3(_izContext, { Bucket: process.env.iz_serviceSchemaBucketName, Key: relTagPath })
691
+ let relSchemaHeadData = await s3Util.headObjectS3(_izContext, { Bucket: process.env.iz_serviceSchemaBucketName, Key: relTagPath })
736
692
 
737
693
  // _izContext.logger.debug("relSchemaHeadData: ", relSchemaHeadData);
738
694
 
@@ -788,7 +744,7 @@ async function getObjectRelationship(
788
744
  overWriteBaseObjType,
789
745
  ) {
790
746
 
791
- return await getObjectRelationshipShared(getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType, process.env.iz_serviceSchemaBucketName).then(res => {
747
+ return await getObjectSchema.getObjectRelationship(s3Utils.getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType, process.env.iz_serviceSchemaBucketName).then(res => {
792
748
  if (res.errorsFound.length && res.errorsFound.length > 0) {
793
749
  throw new NoRetryError(res.errorsFound.join(","))
794
750
  } else {
@@ -838,7 +794,7 @@ async function getRequiredOnCreateLinks(
838
794
  specificRelTags,
839
795
  });
840
796
 
841
- return await getRequiredOnCreateLinksShared(getSchemaByNameWithCache, objType, specificRelTags, process.env.iz_serviceSchemaBucketName).then(res => {
797
+ return await getObjectSchema.getRequiredOnCreateLinks(s3Utils.getSchemaByNameWithCache, objType, specificRelTags, process.env.iz_serviceSchemaBucketName).then(res => {
842
798
  if (res.errorsFound.length && res.errorsFound.length > 0) {
843
799
  throw new NoRetryError(res.errorsFound.join(","))
844
800
  } else {
@@ -921,7 +877,7 @@ async function getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType
921
877
  settings,
922
878
  });
923
879
 
924
- return await getLinkConfigByLinkTypeIdShared(getSchemaByNameWithCache, firstObjType, secondObjType, relType, direction, settings, process.env.iz_serviceSchemaBucketName).then(res => {
880
+ return await getObjectSchema.getLinkConfigByLinkTypeId(s3Utils.getSchemaByNameWithCache, firstObjType, secondObjType, relType, direction, settings, process.env.iz_serviceSchemaBucketName).then(res => {
925
881
  if (res.errorsFound.length && res.errorsFound.length > 0) {
926
882
  throw new NoRetryError(res.errorsFound.join(","))
927
883
  } else {
@@ -958,7 +914,7 @@ const getLinkConfigByLinkTypeIdWithCache = inMemoryCacheLib(
958
914
  * @returns
959
915
  */
960
916
  async function mergeExtendObjSchema(_izContext, objectSchema) {
961
- let mergedObjectSchema = await mergeExtendObjSchemaShared(getSchemaByNameWithCache, objectSchema, process.env.iz_serviceSchemaBucketName).then(res => {
917
+ let mergedObjectSchema = await getObjectSchema.mergeExtendObjSchema(s3Utils.getSchemaByNameWithCache, objectSchema, process.env.iz_serviceSchemaBucketName).then(res => {
962
918
  if (res.errorsFound.length && res.errorsFound.length > 0) {
963
919
  throw new NoRetryError(`objectSchema.objectType: ${objectSchema.objectType} ${res.errorsFound}`)
964
920
  } else {
@@ -969,14 +925,14 @@ async function mergeExtendObjSchema(_izContext, objectSchema) {
969
925
  }
970
926
 
971
927
 
972
- async function getAllLocalFlowSchemas(_izContext, flowSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
928
+ async function getAllLocalFlowSchemas(_izContext, flowSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
973
929
  // initial return Value
974
930
  let returnValue = {
975
931
  records: [],
976
932
  fieldLookup: {}
977
933
  }
978
934
 
979
- const allFlowSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.FLOW_SCHEMA, flowSchemaPath).flat());
935
+ const allFlowSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.FLOW_SCHEMA, flowSchemaPath).flat());
980
936
  _izContext.logger.debug("allFlowSchemas::", allFlowSchemas)
981
937
  for (let [idx, flowSchema] of allFlowSchemas.entries()) {
982
938
  if (!returnValue.fieldLookup.hasOwnProperty(flowSchema.flowTag)) {
@@ -990,7 +946,7 @@ async function getAllLocalFlowSchemas(_izContext, flowSchemaPath = LOCAL_OBJECT_
990
946
  return returnValue
991
947
  }
992
948
 
993
- async function getLocalFlowSchemas(_izContext, flowTags, flowSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
949
+ async function getLocalFlowSchemas(_izContext, flowTags, flowSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
994
950
  if (!flowTags) {
995
951
  throw new NoRetryError("required flowTags");
996
952
  }
@@ -1017,7 +973,7 @@ async function getLocalFlowSchemas(_izContext, flowTags, flowSchemaPath = LOCAL_
1017
973
  filteredFlowTags.push(flowTag)
1018
974
  }
1019
975
 
1020
- const filterFlowSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.FLOW_SCHEMA, flowSchemaPath)
976
+ const filterFlowSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.FLOW_SCHEMA, flowSchemaPath)
1021
977
  .flat()
1022
978
  .filter(schema => filteredFlowTags.includes(schema.flowTag))
1023
979
  );
@@ -1049,7 +1005,7 @@ async function getFlowSchemaS3(
1049
1005
  flowType,
1050
1006
  ) {
1051
1007
 
1052
- return await getFlowSchemaS3Shared(getSchemaByNameWithCache, flowType, process.env.iz_serviceSchemaBucketName).then(res => {
1008
+ return await getObjectSchema.getFlowSchemaS3(s3Utils.getSchemaByNameWithCache, flowType, process.env.iz_serviceSchemaBucketName).then(res => {
1053
1009
  if (res.errorsFound.length) {
1054
1010
  throw new NoRetryError(res.errorsFound.join(","))
1055
1011
  } else {
@@ -1073,18 +1029,18 @@ const getFlowSchemaS3WithCache = inMemoryCacheLib(
1073
1029
  }
1074
1030
  )
1075
1031
 
1076
- function getAllLocalRelationshipSchema(_izContext, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
1032
+ function getAllLocalRelationshipSchema(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
1077
1033
 
1078
- const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_RELATIONSHIPS, objSchemaPath)
1034
+ const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_RELATIONSHIPS, objSchemaPath)
1079
1035
  .flat()
1080
1036
  );
1081
1037
 
1082
1038
  return allObjectSchemas
1083
1039
  }
1084
1040
 
1085
- function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
1041
+ function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
1086
1042
 
1087
- const allRefObjectRelationshipSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.REFERENCE_OBJECT_RELATIONSHIPS, objSchemaPath)
1043
+ const allRefObjectRelationshipSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.REFERENCE_OBJECT_RELATIONSHIPS, objSchemaPath)
1088
1044
  .flat()
1089
1045
  );
1090
1046
 
@@ -1102,7 +1058,7 @@ function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = LOCA
1102
1058
  * @returns
1103
1059
  */
1104
1060
  async function getObjTypeHierarchy(_izContext, objType) {
1105
- return await getObjTypeHierarchyShared(getSchemaByNameWithCache, objType, objType, process.env.iz_serviceSchemaBucketName);
1061
+ return await getObjectSchema.getObjTypeHierarchy(s3Utils.getSchemaByNameWithCache, objType, objType, process.env.iz_serviceSchemaBucketName);
1106
1062
  }
1107
1063
 
1108
1064
  /**
@@ -1121,14 +1077,54 @@ const getObjTypeHierarchyWithCache = inMemoryCacheLib(
1121
1077
  )
1122
1078
 
1123
1079
  async function getObjectSchemaForCreate(_izContext, objType) {
1124
- return await getObjectSchemaForCreateShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
1080
+ return await getObjectSchema.getObjectSchemaForCreate(s3Utils.getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
1125
1081
  }
1126
1082
 
1127
1083
  async function getObjectSchemaForUpdate(_izContext, objType) {
1128
- return await getObjectSchemaForUpdateShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
1084
+ return await getObjectSchema.getObjectSchemaForUpdate(s3Utils.getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
1085
+ }
1086
+
1087
+
1088
+ // collect dynamoDB storageResources of objType in flowType
1089
+ async function getTableNamesByFlowType(_izContext, flowType) {
1090
+ let tableNamesStorageResource = [];
1091
+ const flowSchema = await getFlowSchemaS3WithCache(_izContext, flowType);
1092
+
1093
+ // validate flowSchema
1094
+ if (!flowSchema) {
1095
+ throw new NoRetryError(`Flow schema not found for flowType: ${JSON.stringify(flowType)}`);
1096
+ }
1097
+
1098
+ // validate flowSchema
1099
+ if (!flowSchema.objType) {
1100
+ throw new NoRetryError(`Invalid Flow schema not have objType: ${JSON.stringify(flowType)}`);
1101
+ }
1102
+
1103
+
1104
+ const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, flowSchema.objType);
1105
+
1106
+ // validate objectSchemaTriggerCache
1107
+ if (!objectSchema) {
1108
+ throw new NoRetryError(`Object schema not found for flowType: ${JSON.stringify(flowType)}, objType: ${JSON.stringify(flowSchema.objType)}`);
1109
+ }
1110
+
1111
+ //collect storageResourceDynamoDB
1112
+ for (const storageTag in objectSchema.storageResources) {
1113
+ const storageResource = objectSchema.storageResources[storageTag];
1114
+ if (storageResource.storageType === 'dynamoDB') {
1115
+
1116
+ tableNamesStorageResource.push({
1117
+ ...storageResource,
1118
+ storageTag
1119
+ })
1120
+ }
1121
+ }
1122
+
1123
+ return tableNamesStorageResource;
1129
1124
  }
1130
1125
 
1131
- module.exports = {
1126
+
1127
+ export default {
1132
1128
  // getObjectTypes,
1133
1129
  getDataFromPath,
1134
1130
 
@@ -1186,6 +1182,8 @@ module.exports = {
1186
1182
 
1187
1183
  getObjectSchemaForCreate,
1188
1184
  getObjectSchemaForUpdate,
1185
+
1186
+ getTableNamesByFlowType
1189
1187
  }
1190
1188
 
1191
1189