@izara_project/izara-core-library-service-schemas 1.0.107 → 1.0.109

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.107",
3
+ "version": "1.0.109",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Consts.js CHANGED
@@ -353,6 +353,98 @@ function firstLetterLowerCase(str) {
353
353
 
354
354
  // --------- End Upload path ---------------
355
355
 
356
+
357
+
358
+ const PREFIX = {
359
+ updateRel: 'updateRelationshipEndpoint',
360
+ createRel: 'createRelationshipEndpoint',
361
+ deleteRel: 'deleteRelationshipEndpoint',
362
+ updateNode: 'updateNodeEndpoint',
363
+ createNode: 'createNodeEndpoint',
364
+ getRel: 'getRelationshipEndpoint',
365
+ changeRel: 'changeRelationshipEndpoint',
366
+ ONE: 'one',
367
+ MANY: 'many',
368
+ CREATE_OBJECT_ASYNC: 'createObjectAsync',
369
+ CREATE_OBJECT_ASYNC_COMPLETE: 'createObjectAsyncComplete',
370
+ CREATE_OBJECT_EXTERNAL_TOPIC: 'createObjectExternalTopic'
371
+ };
372
+
373
+ const TOPIC_NAME_GRAPH_HANDLER = {
374
+ inUpdateRel: 'UpdateRelationship_In',
375
+ inCreateRel: 'CreateRelationship_In',
376
+ outUpdateRel: 'UpdateRelationship_Out',
377
+ outCreateRel: 'CreateRelationship_Out',
378
+ inDeleteRel: 'DeleteRelationship_In',
379
+ outDeleteRel: 'DeleteRelationship_Out',
380
+ inUpdateNode: 'UpdateNode_In',
381
+ outUpdateNode: 'UpdateNode_Out',
382
+ inCreateNode: 'CreateNode_In',
383
+ outCreateNode: 'CreateNode_Out',
384
+ inDeleteNode: 'DeleteNode_In',
385
+ outDeleteNode: 'DeleteNode_Out',
386
+ inChangeRelationship: 'ChangeRelationshipType_In',
387
+ outChangeRelationship: 'ChangeRelationshipType_Out',
388
+ inMoveRelationship: 'MoveRelationship_In',
389
+ outMoveRelationship: 'MoveRelationship_Out'
390
+ };
391
+
392
+ const TOPIC_NAME_GENERATE_CODE = {
393
+ updateRelComplete: 'UpdateRelationshipComplete',
394
+ createRelComplete: 'CreateRelationshipComplete',
395
+ deleteRelComplete: 'DeleteRelationshipComplete',
396
+ getRelComplete: 'GetRelationshipComplete',
397
+ outUpdateRelComplete: 'UpdateRelationshipComplete_Out',
398
+ outCreateRelComplete: 'CreateRelationshipComplete_Out',
399
+ outDeleteRelComplete: 'DeleteRelationshipComplete_Out',
400
+ outGetRelComplete: 'GetRelationshipComplete_Out',
401
+ updateNodeComplete: 'UpdateNodeComplete',
402
+ outUpdateNodeComplete: 'UpdateNodeComplete_Out',
403
+ createNodeComplete: 'CreateObjectComplete',
404
+ outCreateNodeComplete: 'CreateObjectComplete_Out',
405
+ deleteNodeComplete: 'DeleteNodeComplete',
406
+ outDeleteNodeComplete: 'DeleteNodeComplete_Out',
407
+ getNodeComplete: 'GetNodeComplete',
408
+ outGetNodeComplete: 'GetNodeComplete_Out',
409
+ reservedLimitComplete: 'ReservedLimitComplete',
410
+ createPresignUrl: 'CreatePresignUrl',
411
+ flowSchemaOwnTopicComplete: 'FlowSchemaOwnTopicComplete',
412
+ flowSchemaOwnTopicEndpointComplete: 'FlowSchemaOwnTopicEndpointComplete',
413
+ createRecordComplete: 'CreateRecordComplete',
414
+ changeRelationshipComplete: 'ChangeRelationshipComplete',
415
+ outChangeRelationshipComplete: 'ChangeRelationshipComplete_Out',
416
+ moveRelationshipComplete: 'MoveRelationshipComplete',
417
+ outMoveRelationshipComplete: 'MoveRelationshipComplete_Out'
418
+ };
419
+
420
+ const GRAPH_HANDLER_SERVICE_NAME = {
421
+ graphHandler: 'GraphHandler'
422
+ };
423
+
424
+ const ACCOUNTLIMIT_TAG = {
425
+ staticLimit: 'staticLimit',
426
+ reservedDynamic: 'reservedDynamic'
427
+ };
428
+
429
+ const LIMIT_TAG = {
430
+ uploadImage: 'uploadImageS3',
431
+ uploadData: 'uploadDataS3'
432
+ };
433
+
434
+ const RBAC_TYPE = {
435
+ appLevel: 'AppLevel',
436
+ userLevel: 'UserLevel'
437
+ };
438
+
439
+ const TOPIC_NAME_EXTERNAL_SERVICE = {
440
+ staticLimitProcessComplete: 'StaticLimitProcessComplete_Out',
441
+ reservedDynamicUsageComplete: 'ReservedDynamicUsageComplete_Out'
442
+ };
443
+
444
+ const EXTERNAL_SERVICE_NAME = {
445
+ accountLimits: 'AccountLimits'
446
+ };
447
+
356
448
  export default {
357
449
  LOCAL_OBJECT_SCHEMA_PATH: './src/schemas', // schema folder path in lambda environment
358
450
 
@@ -381,5 +473,15 @@ export default {
381
473
  createValidationFieldNameForEachType,
382
474
 
383
475
  firstLetterUpperCase,
384
- firstLetterLowerCase
476
+ firstLetterLowerCase,
477
+
478
+ TOPIC_NAME_GENERATE_CODE,
479
+ TOPIC_NAME_GRAPH_HANDLER,
480
+ PREFIX,
481
+ GRAPH_HANDLER_SERVICE_NAME,
482
+ ACCOUNTLIMIT_TAG,
483
+ LIMIT_TAG,
484
+ RBAC_TYPE,
485
+ TOPIC_NAME_EXTERNAL_SERVICE,
486
+ EXTERNAL_SERVICE_NAME
385
487
  }
@@ -473,6 +473,24 @@ async function getObjSchemaS3WithHierarchy(_izContext, objType, bucketName = pro
473
473
  });
474
474
  }
475
475
 
476
+ /**
477
+ * Retrieves specific object schema from S3, with hierarchical data
478
+ * use this inside share function of frtontend
479
+ *
480
+ * @see {@link getObjSchemaS3}
481
+ * @see {@link getObjSchemaS3WithHierarchy}
482
+ *
483
+ */
484
+ async function getObjSchemaS3WithHierarchyShared(objType, bucketName = process.env.iz_serviceSchemaBucketName) {
485
+ return await getObjectSchema.getObjSchemaWithHierarchy(s3Utils.getSchemaByNameWithCache, objType, bucketName).then(res => {
486
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
487
+ throw new NoRetryError(res.errorsFound.join(","))
488
+ } else {
489
+ return res.result
490
+ }
491
+ });
492
+ }
493
+
476
494
  /**
477
495
  * Retrieves specific object schema from S3, without hierarchical data
478
496
  *
@@ -757,6 +775,35 @@ async function getObjectRelationship(
757
775
 
758
776
 
759
777
 
778
+ /**
779
+ *
780
+ * get relationshipSchema of objType depend on specific relationshipTags
781
+ *
782
+ * @see {@link getObjectRelationship}
783
+ * @param {Object} objType
784
+ * @param {String} objType.objectType
785
+ * @param {String} objType.serviceTag
786
+ * @param {String[]} [specificRelTags] - optional array of relationshipTags that need to find
787
+ * @returns {Promise<Object>} - reference relationship data of objType
788
+ */
789
+ async function getObjectLinksShared(
790
+ objType,
791
+ specificRelTags,
792
+ overWriteBaseObjType,
793
+ ) {
794
+
795
+ return await getObjectSchema.getObjectRelationship(s3Utils.getSchemaByNameWithCache, objType, specificRelTags, overWriteBaseObjType, process.env.iz_serviceSchemaBucketName).then(res => {
796
+ if (res.errorsFound.length && res.errorsFound.length > 0) {
797
+ throw new NoRetryError(res.errorsFound.join(","))
798
+ } else {
799
+ return res.result
800
+ }
801
+ })
802
+ }
803
+
804
+
805
+
806
+
760
807
  /**
761
808
  * Caches the getObjectRelationship function
762
809
  *
@@ -1138,6 +1185,7 @@ export default {
1138
1185
  getObjSchemaS3,
1139
1186
  getObjSchemaS3WithCache,
1140
1187
  getObjSchemaS3WithHierarchy,
1188
+ getObjSchemaS3WithHierarchyShared,
1141
1189
  getObjSchemaS3WithoutHierarchy,
1142
1190
 
1143
1191
  getObjectSchemaCombineFieldNames,
@@ -1160,6 +1208,7 @@ export default {
1160
1208
 
1161
1209
  getObjectRelationship,
1162
1210
  getObjectRelationshipWithCache,
1211
+ getObjectLinksShared, // will rename getObjectRelationship to getObjectLinks further
1163
1212
 
1164
1213
  getRequiredOnCreateLinks,
1165
1214
  getRequiredOnCreateLinksWithCache,
@@ -17,7 +17,7 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- import { NoRetryError } from '@izara_project/izara-core-library-core';
20
+ import { NoRetryError, inMemoryCacheLib } from '@izara_project/izara-core-library-core';
21
21
  import { validateObjType } from '@izara_project/izara-shared-service-schemas';
22
22
 
23
23
  import deliminatorTree from './libs/DeliminatorTree.js';
package/src/Utils.js CHANGED
@@ -835,6 +835,14 @@ async function messageToDlq(record, messageFailError, queueUrl) {
835
835
  }
836
836
 
837
837
 
838
+ function firstLetterUpperCase(str) {
839
+ return str.charAt(0).toUpperCase() + str.slice(1)
840
+ }
841
+
842
+ function firstLetterLowerCase(str) {
843
+ return str.charAt(0).toLowerCase() + str.slice(1)
844
+ }
845
+
838
846
  export default {
839
847
  createObjType,
840
848
  getIdentifierTypeByPriority,
@@ -864,5 +872,8 @@ export default {
864
872
  getApiLinksV2,
865
873
 
866
874
  createFieldForUpdateDynamoDb,
867
- messageToDlq
875
+ messageToDlq,
876
+
877
+ firstLetterUpperCase,
878
+ firstLetterLowerCase,
868
879
  }
@@ -18,6 +18,7 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
18
18
  import { NoRetryError } from "@izara_project/izara-core-library-core";
19
19
  import serviceConfig from "../ServiceConfig.js";
20
20
  import utils from "../Utils.js";
21
+ import consts from '../Consts.js'
21
22
 
22
23
  /**
23
24
  * helper function for get endpoint
@@ -78,7 +79,7 @@ async function createGetDataDetails(
78
79
  }
79
80
  }
80
81
 
81
- if (storageData.storageType === coreConsts.STORAGE_TYPES.graph) {
82
+ if (storageData.storageType === consts.STORAGE_TYPES.graph) {
82
83
  let useStorageTag = storageTag;
83
84
  let graphServiceTag = await serviceConfig.getGraphServiceTagWithCache(
84
85
  _izContext,
@@ -132,7 +133,7 @@ async function createGetDataDetails(
132
133
  });
133
134
  }
134
135
  }
135
- } else if (storageData.storageType === coreConsts.STORAGE_TYPES.dynamoDB) {
136
+ } else if (storageData.storageType === consts.STORAGE_TYPES.dynamoDB) {
136
137
  let serviceTag = storageData.serviceTag || process.env.iz_serviceTag;
137
138
  Object.assign(getDynamoDbDataDetails, {
138
139
  [storageTag]: {
@@ -285,7 +286,7 @@ function collectGetData(
285
286
  }
286
287
 
287
288
  // this process will add result from graph and dynamo to collectedData object by add identifiers and fieldName from getData
288
- if (getDataDetail.storageType === coreConsts.STORAGE_TYPES.graph) {
289
+ if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
289
290
  if (
290
291
  getData.returnValue.queryResults.refactoredNodes.objInstanceFull &&
291
292
  Object.keys(
@@ -336,7 +337,7 @@ function collectGetData(
336
337
  );
337
338
  }
338
339
  } else if (
339
- getDataDetail.storageType === coreConsts.STORAGE_TYPES.dynamoDB
340
+ getDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB
340
341
  ) {
341
342
  for (const getDetailFieldName of getDataDetail.fieldNames) {
342
343
  if (addedFieldNames.has(getDetailFieldName)) {
@@ -394,7 +395,7 @@ async function createUpdateDataDetail(
394
395
  }
395
396
  }
396
397
  }
397
- if (storageProperties.storageType === coreConsts.STORAGE_TYPES.graph) {
398
+ if (storageProperties.storageType === consts.STORAGE_TYPES.graph) {
398
399
  let graphStorageTagPerGraphServiceTag = {};
399
400
  let useStorageTag = storageTag;
400
401
  let graphServiceName = await serviceConfig.getGraphServiceTagWithCache(
@@ -428,7 +429,7 @@ async function createUpdateDataDetail(
428
429
  ];
429
430
  }
430
431
  } else if (
431
- storageProperties.storageType === coreConsts.STORAGE_TYPES.dynamoDB
432
+ storageProperties.storageType === consts.STORAGE_TYPES.dynamoDB
432
433
  ) {
433
434
  let serviceTag =
434
435
  storageProperties.serviceTag || process.env.iz_serviceTag;
@@ -468,7 +469,7 @@ async function createDataDetailsLib(
468
469
  _izContext.logger.debug('Lib: createDataDetailsLib:', {
469
470
  objectSchemas: objectSchemas
470
471
  });
471
-
472
+
472
473
  let createDataDetails = {};
473
474
 
474
475
  let storageResources = objectSchemas.storageResources;
@@ -487,7 +488,7 @@ async function createDataDetailsLib(
487
488
  } else {
488
489
  if (
489
490
  storageResources[eachStorageResourceTag].storageType ==
490
- coreConsts.STORAGE_TYPES.dynamoDB
491
+ consts.STORAGE_TYPES.dynamoDB
491
492
  ) {
492
493
  if (createDataDetails.hasOwnProperty(eachStorageResourceTag)) {
493
494
  // _izContext.logger.debug("SAME STG DB", eachStorageResourceTag);
@@ -497,7 +498,7 @@ async function createDataDetailsLib(
497
498
  } else {
498
499
  Object.assign(createDataDetails, {
499
500
  [eachStorageResourceTag]: {
500
- storageType: coreConsts.STORAGE_TYPES.dynamoDB,
501
+ storageType: consts.STORAGE_TYPES.dynamoDB,
501
502
  tableName: storageResources[eachStorageResourceTag].tableName,
502
503
  serviceTag:
503
504
  storageResources[eachStorageResourceTag].serviceTag ||
@@ -520,7 +521,7 @@ async function createDataDetailsLib(
520
521
  }
521
522
  } else if (
522
523
  storageResources[eachStorageResourceTag].storageType ==
523
- coreConsts.STORAGE_TYPES.graph
524
+ consts.STORAGE_TYPES.graph
524
525
  ) {
525
526
  let checkGraphServerTags =
526
527
  await serviceConfig.getGraphServiceTagWithCache(
@@ -538,7 +539,7 @@ async function createDataDetailsLib(
538
539
  // _izContext.logger.debug("NEW STG", checkGraphServerTags);
539
540
  Object.assign(createDataDetails, {
540
541
  [checkGraphServerTags]: {
541
- storageType: coreConsts.STORAGE_TYPES.graph,
542
+ storageType: consts.STORAGE_TYPES.graph,
542
543
  fieldNames: [keyFieldName]
543
544
  }
544
545
  });
@@ -546,7 +547,7 @@ async function createDataDetailsLib(
546
547
  }
547
548
  } else if (
548
549
  storageResources[eachStorageResourceTag].storageType ===
549
- coreConsts.STORAGE_TYPES.externalTopic
550
+ consts.STORAGE_TYPES.externalTopic
550
551
  ) {
551
552
  let topicName =
552
553
  storageResources[eachStorageResourceTag].serviceTag +
@@ -554,7 +555,7 @@ async function createDataDetailsLib(
554
555
  storageResources[eachStorageResourceTag].topicName;
555
556
  Object.assign(createDataDetails, {
556
557
  [topicName]: {
557
- storageType: coreConsts.STORAGE_TYPES.externalTopic,
558
+ storageType: consts.STORAGE_TYPES.externalTopic,
558
559
  fieldNames: [keyFieldName],
559
560
  accountId: storageResources[eachStorageResourceTag].accountId,
560
561
  region: storageResources[eachStorageResourceTag].region,
@@ -582,7 +583,7 @@ async function createDeleteDataDetail(
582
583
  for (let [storageTag, storageProperties] of Object.entries(
583
584
  objectSchema.storageResources
584
585
  )) {
585
- if (storageProperties.storageType === coreConsts.STORAGE_TYPES.dynamoDB) {
586
+ if (storageProperties.storageType === consts.STORAGE_TYPES.dynamoDB) {
586
587
  let serviceTag =
587
588
  storageProperties.serviceTag || process.env.iz_serviceTag;
588
589
  Object.assign(deleteDynamoDataDetail, {
@@ -598,7 +599,7 @@ async function createDeleteDataDetail(
598
599
  });
599
600
  }
600
601
  } else if (
601
- storageProperties.storageType === coreConsts.STORAGE_TYPES.graph
602
+ storageProperties.storageType === consts.STORAGE_TYPES.graph
602
603
  ) {
603
604
  let dataDetailPerGraphStorage = {};
604
605
  let useStorageTag = storageTag;