@izara_project/izara-core-library-service-schemas 1.0.71 → 1.0.73

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.71",
3
+ "version": "1.0.73",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,22 +14,23 @@
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": "^29.7.0"
17
+ "jest": "^30.0.2"
18
18
  },
19
19
  "jest": {
20
20
  "testEnvironment": "node"
21
21
  },
22
22
  "dependencies": {
23
- "@aws-sdk/client-lambda": "^3.787.0",
24
- "@aws-sdk/client-s3": "^3.787.0",
25
- "@aws-sdk/crc64-nvme-crt": "^3.787.0",
23
+ "@aws-sdk/client-lambda": "^3.835.0",
24
+ "@aws-sdk/client-s3": "^3.835.0",
25
+ "@aws-sdk/crc64-nvme-crt": "^3.835.0",
26
+ "@aws-sdk/client-api-gateway": "^3.835.0",
26
27
  "@izara_project/izara-core-library-core": "^1.0.19",
27
28
  "@izara_project/izara-core-library-external-request": "^1.0.20",
28
29
  "@izara_project/izara-core-library-lambda": "^1.0.4",
29
30
  "@izara_project/izara-core-library-logger": "^1.0.7",
30
31
  "@izara_project/izara-shared-core": "^1.0.2",
31
- "@izara_project/izara-shared-service-schemas": "^1.0.16",
32
- "glob": "^11.0.2",
32
+ "@izara_project/izara-shared-service-schemas": "^1.0.19",
33
+ "glob": "^11.0.3",
33
34
  "lodash": "^4.17.21",
34
35
  "object-hash": "^3.0.0",
35
36
  "read-yaml-file": "^2.1.0"
package/src/Consts.js CHANGED
@@ -106,84 +106,109 @@ const PREFIX_PATH_S3 = {
106
106
  // --------- Upload path ---------------
107
107
 
108
108
  function relationshipTagPathS3(_izContext, relType) {
109
- validateRelType(relType);
109
+ const validateRelTypeResult = validateRelType(relType);
110
+ if (validateRelTypeResult.errorsFound.length > 0) {
111
+ throw new NoRetryError(`function relationshipTagPathS3: invalid relType ${relType.name} - ${validateRelTypeResult.errorsFound.join(", ")}`);
112
+ }
110
113
  return `${PREFIX_PATH_S3.perServiceSchemas}/${relType.serviceTag}/Relationships/RelationshipTags/${relType.relationshipTag}.json`
111
114
  }
112
115
 
113
116
  function objectRelationshipPathS3(_izContext, objType) {
114
- validateObjType(objType);
117
+ const validateObjTypeResult = validateObjType(objType);
118
+ if (validateObjTypeResult.errorsFound.length > 0) {
119
+ throw new NoRetryError(`function objectRelationshipPathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
120
+ }
115
121
  return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/Relationships/ObjectRelationships/${objType.objectType}.json`
116
122
  }
117
123
 
118
124
  function linkByLinkTypeIdPathS3(_izContext, serviceTag, linkTypeId) {
119
125
  if (!serviceTag || !linkTypeId || typeof (serviceTag) !== "string" || typeof (linkTypeId) !== "string") {
120
- throw new NoRetryError("invalid serviceTag or linkTypeId")
126
+ // throw new NoRetryError("invalid serviceTag or linkTypeId")
127
+ throw new NoRetryError("invalid serviceTag or linkTypeId");
121
128
  }
122
- return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/Relationships/LinkByLinkTypeId/${linkTypeId}.json`
129
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/Relationships/LinkByLinkTypeId/${linkTypeId}.json`;
123
130
  }
124
131
 
125
132
 
126
133
  function refObjectRelationshipPathS3(_izContext, objType) {
127
- validateObjType(objType);
128
- return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/Relationships/RefObjectRelationships/${objType.objectType}.json`
134
+ const validateObjTypeResult = validateObjType(objType);
135
+ if (validateObjTypeResult.errorsFound.length > 0) {
136
+ throw new NoRetryError(`function refObjectRelationshipPathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
137
+ }
138
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/Relationships/RefObjectRelationships/${objType.objectType}.json`;
129
139
  }
130
140
 
131
141
  function objectSchemaAllPathS3(_izContext, objType) {
132
- validateObjType(objType);
133
- return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/ObjectSchemaAll/${objType.objectType}.json`
142
+ const validateObjTypeResult = validateObjType(objType);
143
+ if (validateObjTypeResult.errorsFound.length > 0) {
144
+ throw new NoRetryError(`function objectSchemaAllPathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
145
+ }
146
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/ObjectSchemaAll/${objType.objectType}.json`;
134
147
  }
135
148
 
136
149
  function objectSchemaCreatePathS3(_izContext, objType) {
137
- validateObjType(objType);
138
- return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/ObjectSchemaCreate/${objType.objectType}.json`
150
+ const validateObjTypeResult = validateObjType(objType);
151
+ if (validateObjTypeResult.errorsFound.length > 0) {
152
+ throw new NoRetryError(`function objectSchemaCreatePathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
153
+ }
154
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/ObjectSchemaCreate/${objType.objectType}.json`;
139
155
  }
140
156
 
141
157
  function objectSchemaDisplayPathS3(_izContext, objType) {
142
- validateObjType(objType);
143
- return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/ObjectSchemaDisplay/${objType.objectType}.json`
158
+ const validateObjTypeResult = validateObjType(objType);
159
+ if (validateObjTypeResult.errorsFound.length > 0) {
160
+ throw new NoRetryError(`function objectSchemaDisplayPathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
161
+ }
162
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/ObjectSchemaDisplay/${objType.objectType}.json`;
144
163
  }
145
164
 
146
165
  function objectSchemaCombineFieldNamesPathS3(_izContext, objType) {
147
- validateObjType(objType);
148
- return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/ObjectSchemaCombineFieldNames/${objType.objectType}.json`
166
+ const validateObjTypeResult = validateObjType(objType);
167
+ if (validateObjTypeResult.errorsFound.length > 0) {
168
+ throw new NoRetryError(`function objectSchemaCombineFieldNamesPathS3: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
169
+ }
170
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/ObjectSchemaCombineFieldNames/${objType.objectType}.json`;
149
171
  }
150
172
 
151
173
  function objectListAllPathS3(_izContext, serviceTag) {
152
174
  if (!serviceTag || typeof (serviceTag) !== "string") {
153
- throw new NoRetryError("invalid serviceTag.")
175
+ throw new NoRetryError("invalid serviceTag.");
154
176
  }
155
- return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/ObjectListAll.json`
177
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/ObjectListAll.json`;
156
178
  }
157
179
 
158
180
  function objectListCreatePathS3(_izContext, serviceTag) {
159
181
  if (!serviceTag || typeof (serviceTag) !== "string") {
160
- throw new NoRetryError("invalid serviceTag.")
182
+ throw new NoRetryError("invalid serviceTag.");
161
183
  }
162
- return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/ObjectListCreate.json`
184
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/ObjectListCreate.json`;
163
185
  }
164
186
 
165
187
  function lambdaFunctionsPathS3(_izContext, serviceTag) {
166
188
  if (!serviceTag || typeof (serviceTag) !== "string") {
167
- throw new NoRetryError("invalid serviceTag.")
189
+ throw new NoRetryError("invalid serviceTag.");
168
190
  }
169
- return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/LambdaFunctions.json`
191
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/LambdaFunctions.json`;
170
192
  }
171
193
 
172
194
  function serviceNamePathS3(_izContext, serviceTag) {
173
195
  if (!serviceTag || typeof (serviceTag) !== "string") {
174
- throw new NoRetryError("invalid serviceTag.")
196
+ throw new NoRetryError("invalid serviceTag.");
175
197
  }
176
- return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/ServiceName.json`
198
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/ServiceName.json`;
177
199
  }
178
200
 
179
201
  function flowSchemaPathS3(_izContext, flowType) {
180
- validateFlowType(flowType);
181
- return `${PREFIX_PATH_S3.perServiceSchemas}/${flowType.serviceTag}/FlowSchema/${flowType.flowTag}.json`
202
+ const validateFlowTypeResult = validateFlowType(flowType);
203
+ if (validateFlowTypeResult.errorsFound.length > 0) {
204
+ throw new NoRetryError(`function flowSchemaPathS3: invalid flowType ${flowType.name} - ${validateFlowTypeResult.errorsFound.join(", ")}`);
205
+ }
206
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${flowType.serviceTag}/FlowSchema/${flowType.flowTag}.json`;
182
207
  }
183
208
 
184
209
  function coreFunctionNames(_izContext, prefix, stage) {
185
210
  if (!prefix || typeof (prefix) !== "string" && !stage || typeof (stage) !== "string") {
186
- throw new NoRetryError("invalid serviceTag or stage.")
211
+ throw new NoRetryError("invalid serviceTag or stage.");
187
212
  }
188
213
  const coreFunctionNames = [
189
214
  `${prefix}${stage}InitialSetup`,
@@ -272,7 +297,22 @@ function createValidationFieldNameForEachType(type, validation) {
272
297
  }[type]
273
298
  }
274
299
 
275
- const S3_UPLOAD_TYPE = ["image", "video", "csv", 'yaml']
300
+ function flowSchemaPathS3(_izContext, flowType) {
301
+ validateFlowType(flowType);
302
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${flowType.serviceTag}/FlowSchema/${flowType.flowTag}.json`
303
+ }
304
+
305
+ function getEndpointPerObjectType(_izContext, objType) {
306
+ validateObjType(objType);
307
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${objType.serviceTag}/FrontEnd/Endpoint/Endpoint_Get_${objType.objectType}.json`
308
+ }
309
+
310
+ function getEndpointPerService(serviceTag) {
311
+ if (typeof serviceTag !== "string" || !serviceTag) {
312
+ throw new NoRetryError("invalid serviceTag.")
313
+ }
314
+ return `${PREFIX_PATH_S3.perServiceSchemas}/${serviceTag}/FrontEnd/Endpoint/Endpoint_Get.json`
315
+ }
276
316
 
277
317
  const UPLOAD_PATH_S3 = {
278
318
  relationshipTag: relationshipTagPathS3,
@@ -294,19 +334,9 @@ const UPLOAD_PATH_S3 = {
294
334
 
295
335
  lambdaFunctions: lambdaFunctionsPathS3,
296
336
  serviceName: serviceNamePathS3,
297
- coreFunctionNames: coreFunctionNames
298
- }
299
-
300
- const FLOW_SCHEMA_HOOK_STATE = {
301
- beforeCreate: "before:Create",
302
- afterCreate: "after:Create",
303
- beforeCheckLimit: "before:CheckLimit",
304
- afterCheckLimit: "after:CheckLimit",
305
- beforeCreatePreSignedUrl: "before:CreatePreSignedUrl",
306
- afterCreatePreSignedUrl: "after:CreatePreSignedUrl",
307
- afterUploadS3: "after:UploadS3",
308
- beforeProcessCalculate: "before:ProcessCalculate",
309
- afterProcessCalculate: "after:ProcessCalculate"
337
+ coreFunctionNames: coreFunctionNames,
338
+ getEndpointPerObjectType: getEndpointPerObjectType,
339
+ getEndpointPerService: getEndpointPerService
310
340
  }
311
341
 
312
342
  // --------- End Upload path ---------------
@@ -337,6 +367,4 @@ module.exports = {
337
367
 
338
368
  LOCAL_FILENAME: LOCAL_FILENAME,
339
369
  createValidationFieldNameForEachType,
340
- S3_UPLOAD_TYPE,
341
- FLOW_SCHEMA_HOOK_STATE
342
370
  }
@@ -30,7 +30,7 @@ const {
30
30
  getObjSchemaWithHierarchy,
31
31
  getObjSchemaWithoutHierarchy,
32
32
  mergeExtendObjSchema: mergeExtendObjSchemaShared,
33
- recursiveMergeExtendObjSchema: recursiveMergeExtendObjSchemaShared,
33
+ // recursiveMergeExtendObjSchema: recursiveMergeExtendObjSchemaShared,
34
34
  getRefObjectRelationship: getRefObjectRelationshipShared,
35
35
  getRelationshipSchema: getRelationshipSchemaShared,
36
36
  getObjectRelationship: getObjectRelationshipShared,
@@ -38,7 +38,7 @@ const {
38
38
  getLinkConfigByLinkTypeId: getLinkConfigByLinkTypeIdShared,
39
39
  getObjTypeHierarchy: getObjTypeHierarchyShared
40
40
  } = sharedServiceSchema.getObjectSchema;
41
- const { validateObjType, validateRelType, validateFlowType } = sharedServiceSchema.validateObjType;
41
+ const { validateObjType, validateFlowType } = sharedServiceSchema.validateObjType;
42
42
  const {
43
43
  basicFieldNameSchema,
44
44
  basicFieldNameSchemaForCombineFieldName
@@ -165,9 +165,11 @@ function getDataFromPath(
165
165
  * @returns {Promise<object>} Return object schema of objectTypes
166
166
  */
167
167
  async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = LOCAL_OBJECT_SCHEMA_PATH, getExtendObType = false) {
168
+ let errorsFound = [];
168
169
  // validate objectTypes
169
170
  if (!objectTypes) {
170
- throw new NoRetryError("required objectTypes");
171
+ // throw new NoRetryError("required objectTypes");
172
+ errorsFound.push("getLocalObjectSchemas: Parameter 'objectTypes' is required but was not provided.");
171
173
  }
172
174
 
173
175
  if (typeof (objectTypes) === "string") {
@@ -175,11 +177,20 @@ async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = LO
175
177
  }
176
178
 
177
179
  if (!Array.isArray(objectTypes)) {
178
- throw new NoRetryError(`Unhandled objectTypes param: ${objectTypes}`);
180
+ // throw new NoRetryError(`Unhandled objectTypes param: ${objectTypes}`);
181
+ errorsFound.push(`getLocalObjectSchemas: Parameter 'objectTypes' must be an array, received: ${typeof objectTypes}`);
179
182
  }
180
183
 
181
184
  if (!objectTypes.length) {
182
- throw new NoRetryError(`ObjectTypes cannot empty`);
185
+ // throw new NoRetryError(`ObjectTypes cannot empty`);
186
+ errorsFound.push(`getLocalObjectSchemas: Parameter 'objectTypes' cannot be an empty array.`);
187
+ }
188
+
189
+ if (errorsFound.length > 0) {
190
+ return {
191
+ errorsFound: errorsFound,
192
+ result: null
193
+ }
183
194
  }
184
195
 
185
196
 
@@ -199,7 +210,7 @@ async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = LO
199
210
  // returnValue.fieldLookup[objectType] = null;
200
211
  }
201
212
 
202
- const allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
213
+ let allObjectSchemas = lodash.cloneDeep(getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_SCHEMA, objSchemaPath)
203
214
  .flat()
204
215
  .filter(schema => filteredObjectTypes.includes(schema.objectType))
205
216
  );
@@ -209,7 +220,12 @@ async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = LO
209
220
  if (getExtendObType) {
210
221
  await Promise.all(
211
222
  allObjectSchemas.map(async (objSchema, idx) => {
212
- allObjectSchemas[idx] = await mergeExtendObjSchema(_izContext, objSchema);
223
+ const mergeResult = await mergeExtendObjSchema(_izContext, objSchema)
224
+ if (mergeResult?.errorsFound?.length && mergeResult?.errorsFound?.length > 0) {
225
+ throw new NoRetryError(mergeResult.errorsFound)
226
+ } else {
227
+ allObjectSchemas[idx] = mergeResult;
228
+ }
213
229
  })
214
230
  )
215
231
  }
@@ -230,10 +246,10 @@ async function getLocalObjectSchemas(_izContext, objectTypes, objSchemaPath = LO
230
246
  throw new NoRetryError(`Found duplicate shortNameObjectType: '${objSchema.shortNameObjectType}' in file ObjectFieldSchema.js `);
231
247
  }
232
248
  }
233
-
234
249
  returnValue.records = allObjectSchemas;
235
250
 
236
- return returnValue;
251
+ return returnValue
252
+
237
253
  }
238
254
 
239
255
 
@@ -281,7 +297,6 @@ async function getAllLocalObjectSchemas(_izContext, objSchemaPath = LOCAL_OBJECT
281
297
  // .filter(schema => objectTypeList.includes(schema.objectType))
282
298
  );
283
299
 
284
-
285
300
  // check objectType that not found in ObjectFieldSchema.js
286
301
  // const remainingObjectTypes = objectTypeList.filter(objectType => !allObjectSchemas.some(schema => schema.objectType === objectType));
287
302
 
@@ -296,17 +311,22 @@ async function getAllLocalObjectSchemas(_izContext, objSchemaPath = LOCAL_OBJECT
296
311
  if (getExtendObType) {
297
312
  await Promise.all(
298
313
  allObjectSchemas.map(async (objSchema, idx) => {
299
- allObjectSchemas[idx] = await mergeExtendObjSchema(_izContext, objSchema)
314
+ const mergeResult = await mergeExtendObjSchema(_izContext, objSchema)
315
+
316
+ allObjectSchemas[idx] = mergeResult;
300
317
  })
301
318
  )
302
319
  }
303
-
304
320
  // add objectSchema to returnValue object
305
321
  for (let [idx, objSchema] of allObjectSchemas.entries()) {
306
322
  if (!returnValue.fieldLookup.hasOwnProperty(objSchema.objectType)) {
307
323
  returnValue.fieldLookup[objSchema.objectType] = idx;
308
324
  } else {
309
- throw new NoRetryError(`Found duplicate objectType: '${objSchema.objectType}' in file ObjectFieldSchema.js`);
325
+ // throw new NoRetryError(`Found duplicate objectType: '${objSchema.objectType}' in file ObjectFieldSchema.js`);
326
+ return {
327
+ errorsFound: [`getAllLocalObjectSchemas: Found duplicate objectType: '${objSchema.objectType}' in file ObjectFieldSchema.js`],
328
+ result: null
329
+ };
310
330
  }
311
331
  if (objSchema?.shortNameObjectType) {
312
332
  if (!returnValue.shortNameObjectTypeLookup.hasOwnProperty(objSchema.shortNameObjectType)) {
@@ -320,8 +340,7 @@ async function getAllLocalObjectSchemas(_izContext, objSchemaPath = LOCAL_OBJECT
320
340
 
321
341
  returnValue.records = allObjectSchemas;
322
342
 
323
- return returnValue;
324
-
343
+ return returnValue
325
344
  }
326
345
 
327
346
  /**
@@ -450,7 +469,13 @@ async function getObjSchemaS3(
450
469
  objType,
451
470
  getExtendObType = false
452
471
  ) {
453
- return await getObjectSchemaS3Shared(getSchemaByNameWithCache, objType, getExtendObType);
472
+ return await getObjectSchemaS3Shared(getSchemaByNameWithCache, objType, getExtendObType).then(res => {
473
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
474
+ throw new NoRetryError(res.errorsFound)
475
+ } else {
476
+ return res.result
477
+ }
478
+ });
454
479
  }
455
480
 
456
481
 
@@ -478,7 +503,13 @@ const getObjSchemaS3WithCache = inMemoryCacheLib(
478
503
  */
479
504
  async function getObjSchemaS3WithHierarchy(_izContext, objType) {
480
505
  // return await getObjSchemaS3WithCache(_izContext, objType, true)
481
- return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType)
506
+ return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType).then(res => {
507
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
508
+ throw new NoRetryError(res.errorsFound)
509
+ } else {
510
+ return res.result
511
+ }
512
+ });
482
513
  }
483
514
 
484
515
  /**
@@ -489,7 +520,13 @@ async function getObjSchemaS3WithHierarchy(_izContext, objType) {
489
520
  */
490
521
  async function getObjSchemaS3WithoutHierarchy(_izContext, objType) {
491
522
  // return await getObjSchemaS3WithCache(_izContext, objType, false)
492
- return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType)
523
+ return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType).then(res => {
524
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
525
+ throw new NoRetryError(res.errorsFound)
526
+ } else {
527
+ return res.result
528
+ }
529
+ });
493
530
  }
494
531
 
495
532
 
@@ -505,7 +542,11 @@ async function getObjSchemaS3WithoutHierarchy(_izContext, objType) {
505
542
  async function getObjectSchemaCombineFieldNames(_izContext, objType) {
506
543
 
507
544
  const objSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
508
- return generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
545
+ if (objSchema.errorsFound.length > 0) {
546
+ throw new NoRetryError(`getObjectSchemaCombineFieldNames: ${objSchema.errorsFound.join(', ')}`);
547
+ }
548
+ const combinedSchema = generateObjectSchemaForCombineFieldNames(_izContext, objSchema.result);
549
+ return combinedSchema
509
550
  }
510
551
 
511
552
  /**
@@ -599,7 +640,13 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
599
640
  * @returns {Promise<Object>} - reference relationship schema of objType
600
641
  */
601
642
  async function getRefObjectRelationship(_izContext, objType) {
602
- return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType)
643
+ return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType).then(res => {
644
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
645
+ throw new NoRetryError(res.errorsFound)
646
+ } else {
647
+ return res.result
648
+ }
649
+ })
603
650
  }
604
651
 
605
652
  /**
@@ -628,8 +675,13 @@ const getRefObjectRelationshipWithCache = inMemoryCacheLib(
628
675
  *
629
676
  */
630
677
  async function getRelationshipSchema(_izContext, relType) {
631
-
632
- return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType)
678
+ return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType).then(res => {
679
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
680
+ throw new NoRetryError(res.errorsFound)
681
+ } else {
682
+ return res.result
683
+ }
684
+ })
633
685
  }
634
686
 
635
687
 
@@ -666,7 +718,11 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
666
718
  objType,
667
719
  });
668
720
 
669
- validateObjType(objType);
721
+ const validateObjTypeResult = validateObjType(objType);
722
+ if (validateObjTypeResult.errorsFound.length > 0) {
723
+ _izContext.logger.error("getRelationshipServiceTag: Invalid objType: ", validateObjTypeResult.errorsFound);
724
+ throw new NoRetryError(`getRelationshipServiceTag: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
725
+ }
670
726
 
671
727
  const relTagPath = UPLOAD_PATH_S3.relationshipTag(
672
728
  _izContext,
@@ -684,8 +740,9 @@ async function getRelationshipServiceTag(_izContext, relationshipTag, objType) {
684
740
  if (relSchemaHeadData) {
685
741
  return objType.serviceTag;
686
742
  } else {
687
- const refObjRel = await getRefObjectRelationship(_izContext, objType);
688
-
743
+ // const refObjRel = await getRefObjectRelationship(_izContext, objType);
744
+ const getRefObjRelWithCacheResult = await getRefObjectRelationshipWithCache(_izContext, objType);
745
+ const refObjRel = getRefObjRelWithCacheResult.records;
689
746
  if (refObjRel.hasOwnProperty(relationshipTag)) {
690
747
  return refObjRel[relationshipTag].relationshipServiceTag
691
748
  } else {
@@ -715,7 +772,7 @@ const getRelationshipServiceTagWithCache = inMemoryCacheLib(
715
772
 
716
773
  /**
717
774
  *
718
- * get realtionshipSchema of objType depend on specific relationshipTags
775
+ * get relationshipSchema of objType depend on specific relationshipTags
719
776
  *
720
777
  * @param {Object} _izContext
721
778
  * @param {Object} objType
@@ -731,7 +788,13 @@ async function getObjectRelationship(
731
788
  overWriteBaseObjType,
732
789
  ) {
733
790
 
734
- return await getObjectRelationshipShared(getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType)
791
+ return await getObjectRelationshipShared(getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType).then(res => {
792
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
793
+ throw new NoRetryError(res.errorsFound)
794
+ } else {
795
+ return res.result
796
+ }
797
+ })
735
798
  }
736
799
 
737
800
 
@@ -775,7 +838,13 @@ async function getRequiredOnCreateLinks(
775
838
  specificRelTags,
776
839
  });
777
840
 
778
- return await getRequiredOnCreateLinksShared(getSchemaByNameWithCache, objType, specificRelTags)
841
+ return await getRequiredOnCreateLinksShared(getSchemaByNameWithCache, objType, specificRelTags).then(res => {
842
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
843
+ throw new NoRetryError(res.errorsFound)
844
+ } else {
845
+ return res.result
846
+ }
847
+ })
779
848
  }
780
849
 
781
850
 
@@ -851,7 +920,13 @@ async function getLinkConfigByLinkTypeId(_izContext, firstObjType, secondObjType
851
920
  settings
852
921
  });
853
922
 
854
- return await getLinkConfigByLinkTypeIdShared(getSchemaByNameWithCache, firstObjType, secondObjType, relType, direction, settings);
923
+ await getLinkConfigByLinkTypeIdShared(getSchemaByNameWithCache, firstObjType, secondObjType, relType, direction, settings).then(res => {
924
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
925
+ throw new NoRetryError(res.errorsFound)
926
+ } else {
927
+ return res.result
928
+ }
929
+ });
855
930
  }
856
931
 
857
932
  /**
@@ -882,8 +957,14 @@ const getLinkConfigByLinkTypeIdWithCache = inMemoryCacheLib(
882
957
  * @returns
883
958
  */
884
959
  async function mergeExtendObjSchema(_izContext, objectSchema) {
885
- // return mergedObjectSchema;
886
- return await mergeExtendObjSchemaShared(getSchemaByNameWithCache, objectSchema);
960
+ let mergedObjectSchema = await mergeExtendObjSchemaShared(getSchemaByNameWithCache, objectSchema).then(res => {
961
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
962
+ throw new NoRetryError(`objectSchema.objectType: ${objectSchema.objectType} ${res.errorsFound}`)
963
+ } else {
964
+ return res.result
965
+ }
966
+ });
967
+ return mergedObjectSchema
887
968
  }
888
969
 
889
970
 
@@ -966,7 +1047,11 @@ async function getFlowSchemaS3(
966
1047
  _izContext,
967
1048
  flowType,
968
1049
  ) {
969
- validateFlowType(flowType);
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
+ }
970
1055
 
971
1056
  const getObjSchemaParam = {
972
1057
  Bucket: OBJECT_SCHEMA_BUCKET_NAME,
@@ -59,7 +59,12 @@ function checkStorageTypeOfObjectSchemaIdentifiers(_izContext, objectSchema) {
59
59
  * @returns {Promise<Object>} - identifiersObject
60
60
  */
61
61
  async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBase) {
62
- validateObjType(objType);
62
+ const validateObjTypeResult = validateObjType(objType);
63
+ if (validateObjTypeResult.errorsFound.length > 0) {
64
+ _izContext.logger.error("identifiersObjectFromBaseObjInstance: Invalid objType: ", validateObjTypeResult.errorsFound);
65
+ throw new NoRetryError(`identifiersObjectFromBaseObjInstance: Invalid objType: ${validateObjTypeResult.errorsFound.join(', ')}`);
66
+ }
67
+
63
68
  _izContext.logger.debug("identifiersObjectFromBaseObjInstance: ", { objType, baseObjInstance: objInstanceBase });
64
69
 
65
70
  const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
@@ -140,7 +145,12 @@ async function identifiersFromObjInstanceBase(_izContext, objType, objInstanceBa
140
145
  * @returns {Promise<Object>} - concatIdentifiersObject
141
146
  */
142
147
  async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers) {
143
- validateObjType(objType);
148
+ const validateObjTypeResult = validateObjType(objType);
149
+ if (validateObjTypeResult.errorsFound.length > 0) {
150
+ _izContext.logger.error("identifiersBaseFromIdentifiers: Invalid objType: ", validateObjTypeResult.errorsFound);
151
+ throw new NoRetryError(`identifiersBaseFromIdentifiers: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
152
+ }
153
+
144
154
  _izContext.logger.debug("concatIdentifiersFromIdentifiersObject: ", { objType, identifiersObject: identifiers });
145
155
 
146
156
  const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
@@ -191,7 +201,11 @@ async function identifiersBaseFromIdentifiers(_izContext, objType, identifiers)
191
201
  * @returns {Promise<Object>} - refactoredObjInstance
192
202
  */
193
203
  async function objInstanceFromobjInstanceBase(_izContext, objType, objInstance) {
194
- validateObjType(objType)
204
+ const validateObjTypeResult = validateObjType(objType);
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(", ")}`);
208
+ }
195
209
 
196
210
  const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
197
211
 
@@ -222,7 +236,12 @@ async function objInstanceFromobjInstanceBase(_izContext, objType, objInstance)
222
236
  * @returns {Promise<String>} - compositeIdentifier
223
237
  */
224
238
  async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers) {
225
- validateObjType(objType);
239
+ const validateObjTypeResult = validateObjType(objType);
240
+ if (validateObjTypeResult.errorsFound.length > 0) {
241
+ _izContext.logger.error("compositeIdentifierFromIdentifiersObject: Invalid objType: ", validateObjTypeResult.errorsFound);
242
+ throw new NoRetryError(`compositeIdentifierFromIdentifiersObject: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
243
+ }
244
+
226
245
  _izContext.logger.debug("compositeIdentifierFromIdentifiersObject: ", { objType, identifiersObject: identifiers });
227
246
 
228
247
  const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
@@ -315,7 +334,12 @@ async function identifiersConcatFromIdentifiers(_izContext, objType, identifiers
315
334
  * @returns {Promise<Object>} - identifiersObject
316
335
  */
317
336
  async function identifiersFromIdentifiersConcat(_izContext, objType, identifiersConcat) {
318
- validateObjType(objType);
337
+ const validateObjTypeResult = validateObjType(objType);
338
+ if (validateObjTypeResult.errorsFound.length > 0) {
339
+ _izContext.logger.error("identifiersObjectFromCompositeIdentifier: Invalid objType: ", validateObjTypeResult.errorsFound);
340
+ throw new NoRetryError(`identifiersObjectFromCompositeIdentifier: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
341
+ }
342
+
319
343
  _izContext.logger.debug("identifiersObjectFromCompositeIdentifier: ", { objType, compositeIdentifier: identifiersConcat });
320
344
 
321
345
  const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
@@ -423,8 +447,11 @@ async function createNestedIdentifiersConcat(
423
447
  throw new NoRetryError(`one of prefixes and suffixes should exists`);
424
448
  }
425
449
 
426
- validateObjType(objType);
427
-
450
+ const validateObjTypeResult = validateObjType(objType);
451
+ if (validateObjTypeResult.errorsFound.length > 0) {
452
+ _izContext.logger.error("createConcatIdentifier: Invalid objType: ", validateObjTypeResult.errorsFound);
453
+ throw new NoRetryError(`createConcatIdentifier: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
454
+ }
428
455
 
429
456
  const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
430
457
  _izContext.logger.debug("objSchema in createConcatIdentifier", objSchema);
@@ -458,8 +485,11 @@ async function explodedNestedIdentifiersConcat(
458
485
  throw new NoRetryError(`invalid compositeIdentifier`);
459
486
  }
460
487
 
461
- validateObjType(objType);
462
-
488
+ const validateObjTypeResult = validateObjType(objType);
489
+ if (validateObjTypeResult.errorsFound.length > 0) {
490
+ _izContext.logger.error("explodedConcatIdentifier: Invalid objType: ", validateObjTypeResult.errorsFound);
491
+ throw new NoRetryError(`explodedConcatIdentifier: Invalid objType: ${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
492
+ }
463
493
 
464
494
  const objSchema = await getSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
465
495
  _izContext.logger.debug("objSchema in explodedConcatIdentifier", objSchema);
@@ -48,7 +48,8 @@ const {
48
48
  validateObjectSchema,
49
49
  validateRelationshipSchema,
50
50
  validateRefRelationshipSchema,
51
- validateBasicFlowSchema
51
+ validateBasicFlowSchema,
52
+ getApiLinks
52
53
  } = require('./Utils')
53
54
 
54
55
  const {
@@ -311,6 +312,7 @@ async function uploadObjectSchemaByUseCase(_izContext) {
311
312
 
312
313
  // case schema combine fieldNames
313
314
  let combineFieldNamesObjectSchema = generateObjectSchemaForCombineFieldNames(_izContext, objSchema);
315
+ console.log("combineFieldNamesObjectSchema", combineFieldNamesObjectSchema)
314
316
  uploadList.push(
315
317
  uploadObjectToS3(
316
318
  _izContext,
@@ -325,6 +327,23 @@ async function uploadObjectSchemaByUseCase(_izContext) {
325
327
  )
326
328
  );
327
329
 
330
+ let apiLink = await getApiLinks();
331
+ console.log("apiLink", apiLink)
332
+ uploadList.push(
333
+ uploadObjectToS3(
334
+ _izContext,
335
+ UPLOAD_PATH_S3.getEndpointPerObjectType(_izContext, { objectType: objSchema.objectType, serviceTag: process.env.iz_serviceTag }),
336
+ apiLink
337
+ )
338
+ )
339
+
340
+ uploadList.push(
341
+ uploadObjectToS3(
342
+ _izContext,
343
+ UPLOAD_PATH_S3.getEndpointPerService(process.env.iz_serviceTag),
344
+ apiLink
345
+ )
346
+ )
328
347
 
329
348
  // upload to refObjectRelationships for each objectType that have createBy at UserAccount Service and belongTo
330
349
  let existsRefObjectRel = refRelationshipPerObjectType[objSchema.objectType];
package/src/Utils.js CHANGED
@@ -42,6 +42,13 @@ const consts = require('./Consts');
42
42
  // const getSchema = require('./GetObjectSchema');
43
43
  // const deliminatorTree = require('./libs/DeliminatorTree');
44
44
 
45
+ const {
46
+ APIGatewayClient,
47
+ GetRestApisCommand,
48
+ GetResourcesCommand,
49
+ GetMethodCommand,
50
+ } = require("@aws-sdk/client-api-gateway");
51
+
45
52
  function createObjType(objectType, serviceTag) {
46
53
  if (!process.env.iz_serviceTag && !serviceTag) {
47
54
  throw new NoRetryError('serviceNameTag not defined and iz_serviceNameTag not defined in environment variables');
@@ -348,6 +355,9 @@ function validateObjectSchema(_izContext, objectSchema) {
348
355
  }
349
356
  }
350
357
  }
358
+ if (!objectSchema.hasOwnProperty("generatedBy")) {
359
+ objectSchema["generatedBy"] = "userGenerated"
360
+ };
351
361
 
352
362
  if (objectSchema.hasOwnProperty("extendObjType")) {
353
363
  return validateExtendObjectSchema(_izContext, objectSchema)
@@ -448,7 +458,11 @@ function validateRefRelationshipSchema(_izContext, refRelationshipSchema, servic
448
458
  * @returns
449
459
  */
450
460
  function findLinkByObjType(_izContext, objType, relationshipSchema) {
451
- validateObjType(objType)
461
+ const validateObjTypeResult = validateObjType(objType);
462
+ if (validateObjTypeResult.errorsFound.length > 0) {
463
+ _izContext.logger.error(`findLinkByObjType: invalid objType: ${JSON.stringify(objType)}`);
464
+ throw new NoRetryError(`findLinkByObjType: invalid objType: ${JSON.stringify(objType)}`);
465
+ }
452
466
  let linkFounds = 0;
453
467
  let linkRecords = [];
454
468
 
@@ -495,7 +509,11 @@ function findLinkByObjType(_izContext, objType, relationshipSchema) {
495
509
  * @returns
496
510
  */
497
511
  function findLinkByObjTypeV2(_izContext, objType, relType, relationshipSchema) {
498
- validateObjType(objType)
512
+ const validateObjTypeResult = validateObjType(objType);
513
+ if (validateObjTypeResult.errorsFound.length > 0) {
514
+ _izContext.logger.error(`findLinkByObjTypeV2: invalid objType: ${JSON.stringify(objType)}`);
515
+ throw new NoRetryError(`findLinkByObjTypeV2: invalid objType: ${JSON.stringify(objType)}`);
516
+ }
499
517
 
500
518
  const initialLinkData = {
501
519
  relType: {
@@ -555,8 +573,12 @@ function findLinkByObjTypeV2(_izContext, objType, relType, relationshipSchema) {
555
573
 
556
574
 
557
575
  function createObjTypeConcat(_izContext, objType) {
558
- validateObjType(objType)
559
- return `${objType.serviceTag}_${objType.objectType}`
576
+ const validateObjTypeResult = validateObjType(objType);
577
+ if (validateObjTypeResult.errorsFound.length > 0) {
578
+ _izContext.logger.error("createObjTypeConcat validateObjTypeResult", validateObjTypeResult);
579
+ throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
580
+ }
581
+ return `${objType.serviceTag}_${objType.objectType}`;
560
582
  }
561
583
 
562
584
  function explodedObjTypeConcat(_izContext, objectTypeId) {
@@ -564,8 +586,12 @@ function explodedObjTypeConcat(_izContext, objectTypeId) {
564
586
  }
565
587
 
566
588
  function createRelTypeConcat(_izContext, relType) {
567
- validateRelType(relType)
568
- return `${relType.serviceTag}_${relType.relationshipTag}`
589
+ const validateRelTypeResult = validateRelType(relType);
590
+ if (validateRelTypeResult.errorsFound.length > 0) {
591
+ _izContext.logger.error("createRelTypeConcat validateRelTypeResult", validateRelTypeResult);
592
+ throw new NoRetryError(`Invalid relType:${JSON.stringify(relType)}, ${validateRelTypeResult.errorsFound.join(", ")}`);
593
+ }
594
+ return `${relType.serviceTag}_${relType.relationshipTag}`;
569
595
  }
570
596
 
571
597
  function explodedRelTypeConcat(_izContext, relationshipTypeId) {
@@ -573,8 +599,12 @@ function explodedRelTypeConcat(_izContext, relationshipTypeId) {
573
599
  }
574
600
 
575
601
  function createFlowTypeConcat(_izContext, flowType) {
576
- validateFlowType(flowType);
577
- return `${flowType.serviceTag}_${flowType.flowTag}`
602
+ const validateFlowTypeResult = validateFlowType(flowType);
603
+ if (validateFlowTypeResult.errorsFound.length > 0) {
604
+ _izContext.logger.error("createFlowTypeConcat validateFlowTypeResult", validateFlowTypeResult);
605
+ throw new NoRetryError(`Invalid flowType:${JSON.stringify(flowType)}, ${validateFlowTypeResult.errorsFound.join(", ")}`);
606
+ }
607
+ return `${flowType.serviceTag}_${flowType.flowTag}`;
578
608
  }
579
609
 
580
610
  function explodedFlowTypeConcat(_izContext, flowTypeId) {
@@ -583,11 +613,25 @@ function explodedFlowTypeConcat(_izContext, flowTypeId) {
583
613
 
584
614
  function createLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction) {
585
615
  // validate objType
586
- validateObjType(firstObjType);
587
- validateObjType(secondObjType);
616
+ let validateObjTypeResult = validateObjType(firstObjType);
617
+ if (validateObjTypeResult.errorsFound.length > 0) {
618
+ _izContext.logger.error("createLinkTypeId validateObjTypeResult", validateObjTypeResult);
619
+ throw new NoRetryError(`Invalid objType:${JSON.stringify(firstObjType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
620
+ }
621
+
622
+ validateObjTypeResult = validateObjType(secondObjType);
623
+ if (validateObjTypeResult.errorsFound.length > 0) {
624
+ _izContext.logger.error("createLinkTypeId validateObjTypeResult", validateObjTypeResult);
625
+ throw new NoRetryError(`Invalid objType:${JSON.stringify(secondObjType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
626
+ }
588
627
 
589
628
  // validate relType
590
- validateRelType(relType);
629
+ let validateRelTypeResult = validateRelType(relType);
630
+
631
+ if (validateRelTypeResult.errorsFound.length > 0) {
632
+ _izContext.logger.error("createLinkTypeId validateRelTypeResult", validateRelTypeResult);
633
+ throw new NoRetryError(`Invalid relType:${JSON.stringify(relType)}, ${validateRelTypeResult.errorsFound.join(", ")}`);
634
+ }
591
635
 
592
636
  if (!direction || typeof direction !== "string" || (direction !== "from" && direction !== "to")) {
593
637
  throw new NoRetryError('getLinkConfigByLinkTypeId invalid direction');
@@ -631,6 +675,51 @@ function switchDirection(direction) {
631
675
  }
632
676
  }
633
677
 
678
+ async function getApiLinks() {
679
+ try {
680
+ let apiGateway = {}
681
+ let position;
682
+ let foundApi;
683
+ const client = new APIGatewayClient({ region: process.env.iz_region });
684
+
685
+ do {
686
+ const apisRes = await client.send(new GetRestApisCommand({ position }));
687
+ // foundApi = apisRes.items.find(api => api.name === "Test-GCTpBas");
688
+ foundApi = apisRes.items.find(api => api.name === `${process.env.iz_stage}-${process.env.iz_serviceTag}`);
689
+
690
+ if (foundApi) break;
691
+ position = apisRes.position;
692
+ } while (position);
693
+
694
+ if (!foundApi) {
695
+ console.error("API not found");
696
+ return;
697
+ }
698
+
699
+ const resourcesRes = await client.send(
700
+ new GetResourcesCommand({ restApiId: foundApi.id })
701
+ );
702
+
703
+ for (const resource of resourcesRes.items) {
704
+ if (resource.resourceMethods) {
705
+ const methods = Object.keys(resource.resourceMethods);
706
+ for (const method of methods) {
707
+ const fullUrl = `https://${foundApi.id}.execute-api.${process.env.iz_region}.amazonaws.com/${process.env.iz_stage}${resource.path}`;
708
+ if (fullUrl.endsWith("Get") && (method === "POST")) {
709
+ Object.assign(apiGateway, {
710
+ Url: fullUrl
711
+ })
712
+ }
713
+ }
714
+ }
715
+ }
716
+ console.log("apiGateway in function getApiLink", apiGateway)
717
+ return apiGateway
718
+ } catch (err) {
719
+ console.error("Error fetching API info:", err);
720
+ }
721
+ }
722
+
634
723
  module.exports = {
635
724
  createObjType,
636
725
  getIdentifierTypeByPriority,
@@ -656,4 +745,5 @@ module.exports = {
656
745
  explodedFlowTypeConcat,
657
746
 
658
747
  createLinkTypeId,
748
+ getApiLinks
659
749
  }
@@ -241,7 +241,11 @@ async function validatorSchemaTreeIdentifiersFieldNames(_izContext, objectSchema
241
241
  * @param {String} objType.serviceTag
242
242
  */
243
243
  async function generateRelationshipValidatorSchemaForCreate(_izContext, objType) {
244
- validateObjType(objType);
244
+ const validateObjTypeResult = validateObjType(objType);
245
+ if (validateObjTypeResult.errorsFound.length > 0) {
246
+ _izContext.logger.error("generateRelationshipValidatorSchemaForCreate validateObjTypeResult", validateObjTypeResult);
247
+ throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
248
+ }
245
249
 
246
250
  let relValidatorSchemas = {
247
251
  type: "array",
@@ -374,7 +378,11 @@ async function generateRelationshipValidatorSchemaForCreate(_izContext, objType)
374
378
  * @returns
375
379
  */
376
380
  async function generateValidatorSchemaForCreate(_izContext, objType, specificFieldNames = []) {
377
- validateObjType(objType);
381
+ const validateObjTypeResult = validateObjType(objType);
382
+ if (validateObjTypeResult.errorsFound.length > 0) {
383
+ _izContext.logger.error("generateValidatorSchemaForCreate validateObjTypeResult", validateObjTypeResult);
384
+ throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
385
+ }
378
386
  _izContext.logger.debug("Function:generateValidatorSchemaForCreate ", {
379
387
  objType,
380
388
  specificFieldNames
@@ -616,7 +624,11 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, setting = {
616
624
  * @returns {object} json validator schema
617
625
  */
618
626
  async function generateValidatorSchemaForIdentifier(_izContext, objType) {
619
- validateObjType(objType);
627
+ const validateObjTypeResult = validateObjType(objType);
628
+ if (validateObjTypeResult.errorsFound.length > 0) {
629
+ _izContext.logger.error("generateValidatorSchemaForIdentifier validateObjTypeResult", validateObjTypeResult);
630
+ throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
631
+ }
620
632
  _izContext.logger.debug("Function:generateValidatorSchemaForIdentifier ", {
621
633
  objType,
622
634
  })
@@ -653,7 +665,11 @@ async function generateValidatorSchemaForIdentifier(_izContext, objType) {
653
665
  * @returns
654
666
  */
655
667
  async function filteredFieldNamesOfValidatorSchema(_izContext, objType, requiredFieldNames, usedFieldNames) {
656
- validateObjType(objType);
668
+ const validateObjTypeResult = validateObjType(objType);
669
+ if (validateObjTypeResult.errorsFound.length > 0) {
670
+ _izContext.logger.error("filteredFieldNamesOfValidatorSchema validateObjTypeResult", validateObjTypeResult);
671
+ throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
672
+ }
657
673
  _izContext.logger.debug("Function filteredFieldNamesOfValidatorSchema : ", {
658
674
  objType,
659
675
  requiredFieldNames,
@@ -695,7 +711,12 @@ async function filteredFieldNamesOfValidatorSchema(_izContext, objType, required
695
711
  * 3 >> not required, Use for validate only
696
712
  */
697
713
  async function generateValidatorSchemaForExplodedData(_izContext, objType) {
698
- validateObjType(objType)
714
+ const validateObjTypeResult = validateObjType(objType);
715
+ if (validateObjTypeResult.errorsFound.length > 0) {
716
+ _izContext.logger.error("generateValidatorSchemaForExplodedData validateObjTypeResult", validateObjTypeResult);
717
+ throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
718
+ }
719
+
699
720
  let validatorSchema = {
700
721
  type: "object",
701
722
  required: [],
@@ -1128,15 +1149,14 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1128
1149
  }
1129
1150
  })
1130
1151
  )
1131
- // validate dulicate link
1152
+ // validate duplicate link
1132
1153
  let relSchemaLinkType = new Set();
1133
1154
  for (let link of relData.links) {
1134
- console.log("link", link)
1135
- let linkTypeRelSchema = createLinkTypeId(_izContext,
1155
+ let linkTypeRelSchema = hash([
1136
1156
  link.from.objType,
1137
1157
  link.to.objType,
1138
- { relationshipTag: relTagName, serviceTag: iz_serviceTag},
1139
- "from"
1158
+ { relationshipTag: relTagName, serviceTag: iz_serviceTag },
1159
+ "from"]
1140
1160
  )
1141
1161
 
1142
1162
  if (!relSchemaLinkType.has(linkTypeRelSchema)) {
@@ -34,15 +34,18 @@ const { getObjTypeHierarchy } = require('../GetObjectSchema')
34
34
  async function findLinksByObjTypes(_izContext, objTypes, relatoinshipLinks) {
35
35
 
36
36
  if (!Array.isArray(relatoinshipLinks)) {
37
- throw NoRetryError("relatoinshipLinks should be array");
37
+ throw new NoRetryError("relatoinshipLinks should be array");
38
38
  }
39
39
 
40
40
  if (!objTypes || !Array.isArray(objTypes) || objTypes.length !== 2) {
41
- throw NoRetryError("function checkLinkValid: invalid objTypes");
41
+ throw new NoRetryError("function checkLinkValid: invalid objTypes");
42
42
  }
43
43
 
44
44
  for (const objType of objTypes) {
45
- validateObjType(objType);
45
+ const validateObjTypeResult = validateObjType(objType);
46
+ if (validateObjTypeResult.errorsFound.length > 0) {
47
+ throw NoRetryError(`function checkLinkValid: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
48
+ }
46
49
  }
47
50
 
48
51
  const firstObjType = objTypes[0];
@@ -61,7 +61,6 @@ async function getObjectS3Shared(param) {
61
61
  }
62
62
 
63
63
  async function getSchemaByName(params) {
64
-
65
64
  if (!params.schemaName || !params.getParams) {
66
65
  throw new NoRetryError(`getSchemaByName invalid parameters`);
67
66
  }
@@ -76,7 +75,10 @@ async function getSchemaByName(params) {
76
75
  Key: SCHEMA_NAME_PER_S3_PATH[params.schemaName](params.getParams)
77
76
  };
78
77
 
79
- let [objectSchema] = await getObjectS3Shared(getDataParam);
78
+ let [objectSchema] = await getObjectS3Shared({
79
+ Bucket: getDataParam.Bucket,
80
+ Key: getDataParam.Key.result
81
+ });
80
82
 
81
83
 
82
84
  return objectSchema;