@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.
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.100",
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.27",
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.4",
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,64 +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
- const hash = require('@izara_project/izara-shared-core').objectHash;
25
-
26
- const sharedServiceSchema = require("@izara_project/izara-shared-service-schemas");
27
- const {
28
- getObjSchemaS3: getObjectSchemaS3Shared,
29
- getObjSchemaWithHierarchy,
30
- getObjSchemaWithoutHierarchy,
31
- mergeExtendObjSchema: mergeExtendObjSchemaShared,
32
- // recursiveMergeExtendObjSchema: recursiveMergeExtendObjSchemaShared,
33
- getRefObjectRelationship: getRefObjectRelationshipShared,
34
- getRelationshipSchema: getRelationshipSchemaShared,
35
- getObjectRelationship: getObjectRelationshipShared,
36
- getRequiredOnCreateLinks: getRequiredOnCreateLinksShared,
37
- getLinkConfigByLinkTypeId: getLinkConfigByLinkTypeIdShared,
38
- getObjTypeHierarchy: getObjTypeHierarchyShared,
39
- getObjectSchemaForCreate: getObjectSchemaForCreateShared,
40
- getObjectSchemaForUpdate: getObjectSchemaForUpdateShared,
41
- getFlowSchemaS3: getFlowSchemaS3Shared
42
- } = sharedServiceSchema.getObjectSchema;
43
- const { validateObjType, validateFlowType } = sharedServiceSchema.validateObjType;
44
- const {
45
- basicFieldNameSchema,
46
- basicFieldNameSchemaForCombineFieldName
47
- } = sharedServiceSchema.basicValidatorSchema;
48
-
49
- const {
50
- inMemoryCacheLib,
51
- NoRetryError,
52
- validator: { validateObject },
53
- } = require('@izara_project/izara-core-library-core');
54
-
55
-
56
- // const dynamodbSharedLib = require('@izara_project/izara-shared/src/DynamodbSharedLib');
57
- // const Logger = require('@izara_project/izara-core-library-logger')
58
-
59
- const { getObjectS3, headObjectS3, getSchemaByNameWithCache, getSchemaByName } = require("./libs/s3Utils");
60
- const { generateObjectSchemaForCombineFieldNames } = require("./libs/UploadUseCase");
61
-
62
- const {
63
- LOCAL_OBJECT_SCHEMA_PATH,
64
-
65
- UPLOAD_PATH_S3,
66
-
67
- LOCAL_FILENAME,
68
- STORAGE_TYPES
69
- } = require('./Consts')
70
-
71
- const {
72
- findLinkByObjTypeV2,
73
- getUsedFieldNamesOfIdentifiers,
74
- createLinkTypeId
75
- } = require('./Utils');
76
-
77
-
78
- 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';
79
36
 
80
37
  /**
81
38
  * get array of data from specific path in local environment
@@ -144,7 +101,7 @@ function getDataFromPath(
144
101
 
145
102
  // const objectTypesData = getDataFromPath(
146
103
  // _izContext,
147
- // LOCAL_FILENAME.OBJECT_TYPES,
104
+ // consts.LOCAL_FILENAME.OBJECT_TYPES,
148
105
  // objSchemaPath,
149
106
  // {
150
107
  // fileLimit: 1,
@@ -165,7 +122,7 @@ function getDataFromPath(
165
122
  * @param {boolean} [getExtendObType = false] Optional default = false , If = true will get extendObjectType before return
166
123
  * @returns {Promise<object>} Return object schema of objectTypes
167
124
  */
168
- 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) {
169
126
  let errorsFound = [];
170
127
  // validate objectTypes
171
128
  if (!objectTypes) {
@@ -211,7 +168,7 @@ async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = LO
211
168
  // returnValue.fieldLookup[objectType] = null;
212
169
  }
213
170
 
214
- let allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
171
+ let allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
215
172
  .flat()
216
173
  .filter(schema => filteredObjectTypes.includes(schema.objectType))
217
174
  );
@@ -259,7 +216,7 @@ async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = LO
259
216
  *
260
217
  * @see {@link getLocalObjectSchemas}
261
218
  */
262
- async function getLocalObjectSchemasWithHierarchy(_izContext, objectTypes, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
219
+ async function getLocalObjectSchemasWithHierarchy(_izContext, objectTypes, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
263
220
  return await getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath, true)
264
221
  }
265
222
 
@@ -269,7 +226,7 @@ async function getLocalObjectSchemasWithHierarchy(_izContext, objectTypes, objSc
269
226
  *
270
227
  * @see {@link getLocalObjectSchemas}
271
228
  */
272
- async function getLocalObjectSchemasWithoutHierarchy(_izContext, objectTypes, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
229
+ async function getLocalObjectSchemasWithoutHierarchy(_izContext, objectTypes, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
273
230
  return await getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath, false)
274
231
  }
275
232
 
@@ -282,7 +239,7 @@ async function getLocalObjectSchemasWithoutHierarchy(_izContext, objectTypes, ob
282
239
  * @param {boolean} [getExtendObType = false] - Optional default = false , If = true will get extendObjectType before return
283
240
  * @returns {Promise<object>} - Return all objectSchema from local service
284
241
  */
285
- async function getAllLocalObjectSchemas(_izContext, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH, getExtendObType = false) {
242
+ async function getAllLocalObjectSchemas(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH, getExtendObType = false) {
286
243
 
287
244
  //initial return value
288
245
  let returnValue = {
@@ -293,7 +250,7 @@ async function getAllLocalObjectSchemas(_izContext, objSchemaPath = LOCAL_OBJECT
293
250
 
294
251
  // const objectTypeList = getObjectTypes(_izContext, objSchemaPath)
295
252
 
296
- const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
253
+ const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
297
254
  .flat()
298
255
  // .filter(schema => objectTypeList.includes(schema.objectType))
299
256
  );
@@ -349,7 +306,7 @@ async function getAllLocalObjectSchemas(_izContext, objSchemaPath = LOCAL_OBJECT
349
306
  *
350
307
  * @see {@link getAllLocalObjectSchemas}
351
308
  */
352
- async function getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
309
+ async function getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
353
310
  return await getAllLocalObjectSchemas(_izContext, objSchemaPath, true)
354
311
  }
355
312
 
@@ -358,7 +315,7 @@ async function getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath =
358
315
  *
359
316
  * @see {@link getAllLocalObjectSchemas}
360
317
  */
361
- async function getAllLocalObjectSchemasWithoutHierarchy(_izContext, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
318
+ async function getAllLocalObjectSchemasWithoutHierarchy(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
362
319
  return await getAllLocalObjectSchemas(_izContext, objSchemaPath, false)
363
320
  }
364
321
 
@@ -370,7 +327,7 @@ async function getLambdaFunctionNames(_izContext) {
370
327
  try {
371
328
  _izContext.logger.debug("-- function getLambdaFunctionNames --");
372
329
 
373
- 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, {
374
331
  fileLimit: 1
375
332
  })[0];
376
333
  _izContext.logger.debug("LambdaFunctions: ", LambdaFunctions);
@@ -383,7 +340,7 @@ async function getLambdaFunctionNames(_izContext) {
383
340
 
384
341
  try {
385
342
  do {
386
- const { Functions, NextMarker } = await listLambdaFunctions(_izContext, { Marker: marker });
343
+ const { Functions, NextMarker } = await lambdaUtils(_izContext, { Marker: marker });
387
344
 
388
345
  const filteredNames = Functions
389
346
  .map(func => func.FunctionName)
@@ -471,7 +428,7 @@ async function getObjSchemaS3(
471
428
  getExtendObType = false
472
429
  ) {
473
430
 
474
- 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 => {
475
432
  if (res.errorsFound.length && res.errorsFound.length > 0) {
476
433
  throw new NoRetryError(res.errorsFound.join(","))
477
434
  } else {
@@ -505,7 +462,7 @@ const getObjSchemaS3WithCache = inMemoryCacheLib(
505
462
  */
506
463
  async function getObjSchemaS3WithHierarchy(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
507
464
  // return await getObjSchemaS3WithCache(_izContext, objType, true)
508
- return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType, bucketName).then(res => {
465
+ return await getObjectSchema.getObjSchemaWithHierarchy(s3Utils.getSchemaByNameWithCache, objType, bucketName).then(res => {
509
466
  if (res.errorsFound.length && res.errorsFound.length > 0) {
510
467
  throw new NoRetryError(res.errorsFound.join(","))
511
468
  } else {
@@ -522,7 +479,7 @@ async function getObjSchemaS3WithHierarchy(_izContext, objType, bucketName = pro
522
479
  */
523
480
  async function getObjSchemaS3WithoutHierarchy(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
524
481
  // return await getObjSchemaS3WithCache(_izContext, objType, false)
525
- return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType, bucketName).then(res => {
482
+ return await getObjectSchema.getObjSchemaWithoutHierarchy(s3Utils.getSchemaByNameWithCache, objType, bucketName).then(res => {
526
483
  if (res.errorsFound.length && res.errorsFound.length > 0) {
527
484
  throw new NoRetryError(res.errorsFound.join(","))
528
485
  } else {
@@ -544,7 +501,7 @@ async function getObjSchemaS3WithoutHierarchy(_izContext, objType, bucketName =
544
501
  async function getObjectSchemaCombineFieldNames(_izContext, objType) {
545
502
 
546
503
  const objSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
547
- const combinedSchema = generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
504
+ const combinedSchema = uploadUseCase.generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
548
505
  return combinedSchema
549
506
  }
550
507
 
@@ -580,7 +537,7 @@ const getObjectSchemaCombineFieldNamesWithCache = inMemoryCacheLib(
580
537
  * @param {String} [objSchemaPath] - Optional default = './src/schemas', need objSchemaPath if use in local machine
581
538
  * @returns {Object} - specific relationship schema
582
539
  */
583
- function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
540
+ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
584
541
 
585
542
  // validate objectTypes
586
543
  if (!relationshipTags) {
@@ -598,7 +555,7 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
598
555
 
599
556
  const objectRelationshipDatas = getDataFromPath(
600
557
  _izContext,
601
- LOCAL_FILENAME.OBJECT_RELATIONSHIPS,
558
+ consts.LOCAL_FILENAME.OBJECT_RELATIONSHIPS,
602
559
  objSchemaPath,
603
560
  {
604
561
  fileLimit: 1,
@@ -639,7 +596,7 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
639
596
  * @returns {Promise<Object>} - reference relationship schema of objType
640
597
  */
641
598
  async function getRefObjectRelationship(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
642
- return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType, bucketName).then(res => {
599
+ return await getObjectSchema.getRefObjectRelationship(s3Utils.getSchemaByNameWithCache, objType, bucketName).then(res => {
643
600
  if (res.errorsFound.length && res.errorsFound.length > 0) {
644
601
  throw new NoRetryError(res.errorsFound.join(","))
645
602
  } else {
@@ -674,7 +631,7 @@ const getRefObjectRelationshipWithCache = inMemoryCacheLib(
674
631
  *
675
632
  */
676
633
  async function getRelationshipSchema(_izContext, relType, bucketName = process.env.iz_serviceSchemaBucketName) {
677
- return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType, bucketName).then(res => {
634
+ return await getObjectSchema.getRelationshipSchema(s3Utils.getSchemaByNameWithCache, relType, bucketName).then(res => {
678
635
  if (res.errorsFound.length && res.errorsFound.length > 0) {
679
636
  throw new NoRetryError(res.errorsFound.join(","))
680
637
  } else {
@@ -717,13 +674,13 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
717
674
  objType,
718
675
  });
719
676
 
720
- const validateObjTypeResult = validateObjType(objType);
677
+ const validateObjTypeResult = validateObjType.validateObjType(objType);
721
678
  if (validateObjTypeResult.errorsFound.length > 0) {
722
679
  _izContext.logger.error("getRelationshipServiceTag: Invalid objType: ", validateObjTypeResult.errorsFound);
723
680
  throw new NoRetryError(`getRelationshipServiceTag: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
724
681
  }
725
682
 
726
- const relTagPath = UPLOAD_PATH_S3.relationshipTag(
683
+ const relTagPath = consts.UPLOAD_PATH_S3.relationshipTag(
727
684
  _izContext,
728
685
  { // relType
729
686
  serviceTag: objType.serviceTag,
@@ -731,7 +688,7 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
731
688
  }
732
689
  );
733
690
 
734
- 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 })
735
692
 
736
693
  // _izContext.logger.debug("relSchemaHeadData: ", relSchemaHeadData);
737
694
 
@@ -787,7 +744,7 @@ async function getObjectRelationship(
787
744
  overWriteBaseObjType,
788
745
  ) {
789
746
 
790
- 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 => {
791
748
  if (res.errorsFound.length && res.errorsFound.length > 0) {
792
749
  throw new NoRetryError(res.errorsFound.join(","))
793
750
  } else {
@@ -837,7 +794,7 @@ async function getRequiredOnCreateLinks(
837
794
  specificRelTags,
838
795
  });
839
796
 
840
- 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 => {
841
798
  if (res.errorsFound.length && res.errorsFound.length > 0) {
842
799
  throw new NoRetryError(res.errorsFound.join(","))
843
800
  } else {
@@ -920,7 +877,7 @@ async function getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType
920
877
  settings,
921
878
  });
922
879
 
923
- 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 => {
924
881
  if (res.errorsFound.length && res.errorsFound.length > 0) {
925
882
  throw new NoRetryError(res.errorsFound.join(","))
926
883
  } else {
@@ -957,7 +914,7 @@ const getLinkConfigByLinkTypeIdWithCache = inMemoryCacheLib(
957
914
  * @returns
958
915
  */
959
916
  async function mergeExtendObjSchema(_izContext, objectSchema) {
960
- 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 => {
961
918
  if (res.errorsFound.length && res.errorsFound.length > 0) {
962
919
  throw new NoRetryError(`objectSchema.objectType: ${objectSchema.objectType} ${res.errorsFound}`)
963
920
  } else {
@@ -968,14 +925,14 @@ async function mergeExtendObjSchema(_izContext, objectSchema) {
968
925
  }
969
926
 
970
927
 
971
- async function getAllLocalFlowSchemas(_izContext, flowSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
928
+ async function getAllLocalFlowSchemas(_izContext, flowSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
972
929
  // initial return Value
973
930
  let returnValue = {
974
931
  records: [],
975
932
  fieldLookup: {}
976
933
  }
977
934
 
978
- 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());
979
936
  _izContext.logger.debug("allFlowSchemas::", allFlowSchemas)
980
937
  for (let [idx, flowSchema] of allFlowSchemas.entries()) {
981
938
  if (!returnValue.fieldLookup.hasOwnProperty(flowSchema.flowTag)) {
@@ -989,7 +946,7 @@ async function getAllLocalFlowSchemas(_izContext, flowSchemaPath = LOCAL_OBJECT_
989
946
  return returnValue
990
947
  }
991
948
 
992
- async function getLocalFlowSchemas(_izContext, flowTags, flowSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
949
+ async function getLocalFlowSchemas(_izContext, flowTags, flowSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
993
950
  if (!flowTags) {
994
951
  throw new NoRetryError("required flowTags");
995
952
  }
@@ -1016,7 +973,7 @@ async function getLocalFlowSchemas(_izContext, flowTags, flowSchemaPath = LOCAL_
1016
973
  filteredFlowTags.push(flowTag)
1017
974
  }
1018
975
 
1019
- const filterFlowSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.FLOW_SCHEMA, flowSchemaPath)
976
+ const filterFlowSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.FLOW_SCHEMA, flowSchemaPath)
1020
977
  .flat()
1021
978
  .filter(schema => filteredFlowTags.includes(schema.flowTag))
1022
979
  );
@@ -1048,7 +1005,7 @@ async function getFlowSchemaS3(
1048
1005
  flowType,
1049
1006
  ) {
1050
1007
 
1051
- 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 => {
1052
1009
  if (res.errorsFound.length) {
1053
1010
  throw new NoRetryError(res.errorsFound.join(","))
1054
1011
  } else {
@@ -1072,18 +1029,18 @@ const getFlowSchemaS3WithCache = inMemoryCacheLib(
1072
1029
  }
1073
1030
  )
1074
1031
 
1075
- function getAllLocalRelationshipSchema(_izContext, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
1032
+ function getAllLocalRelationshipSchema(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
1076
1033
 
1077
- const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_RELATIONSHIPS, objSchemaPath)
1034
+ const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_RELATIONSHIPS, objSchemaPath)
1078
1035
  .flat()
1079
1036
  );
1080
1037
 
1081
1038
  return allObjectSchemas
1082
1039
  }
1083
1040
 
1084
- function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH) {
1041
+ function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = consts.LOCAL_OBJECT_SCHEMA_PATH) {
1085
1042
 
1086
- 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)
1087
1044
  .flat()
1088
1045
  );
1089
1046
 
@@ -1101,7 +1058,7 @@ function getAllLocalRefObjectRelationshipSchema(_izContext, objSchemaPath = LOCA
1101
1058
  * @returns
1102
1059
  */
1103
1060
  async function getObjTypeHierarchy(_izContext, objType) {
1104
- return await getObjTypeHierarchyShared(getSchemaByNameWithCache, objType, objType, process.env.iz_serviceSchemaBucketName);
1061
+ return await getObjectSchema.getObjTypeHierarchy(s3Utils.getSchemaByNameWithCache, objType, objType, process.env.iz_serviceSchemaBucketName);
1105
1062
  }
1106
1063
 
1107
1064
  /**
@@ -1120,11 +1077,11 @@ const getObjTypeHierarchyWithCache = inMemoryCacheLib(
1120
1077
  )
1121
1078
 
1122
1079
  async function getObjectSchemaForCreate(_izContext, objType) {
1123
- return await getObjectSchemaForCreateShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
1080
+ return await getObjectSchema.getObjectSchemaForCreate(s3Utils.getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
1124
1081
  }
1125
1082
 
1126
1083
  async function getObjectSchemaForUpdate(_izContext, objType) {
1127
- return await getObjectSchemaForUpdateShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
1084
+ return await getObjectSchema.getObjectSchemaForUpdate(s3Utils.getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName)
1128
1085
  }
1129
1086
 
1130
1087
 
@@ -1167,7 +1124,7 @@ async function getTableNamesByFlowType(_izContext, flowType) {
1167
1124
  }
1168
1125
 
1169
1126
 
1170
- module.exports = {
1127
+ export default {
1171
1128
  // getObjectTypes,
1172
1129
  getDataFromPath,
1173
1130