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

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.108",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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';