@izara_project/izara-core-library-service-schemas 1.0.79 → 1.0.80

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.79",
3
+ "version": "1.0.80",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -504,9 +504,9 @@ const getObjSchemaS3WithCache = inMemoryCacheLib(
504
504
  * @see {@link getObjSchemaS3WithCache}
505
505
  *
506
506
  */
507
- async function getObjSchemaS3WithHierarchy(_izContext, objType) {
507
+ async function getObjSchemaS3WithHierarchy(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
508
508
  // return await getObjSchemaS3WithCache(_izContext, objType, true)
509
- return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName).then(res => {
509
+ return await getObjSchemaWithHierarchy(getSchemaByNameWithCache, objType, bucketName).then(res => {
510
510
  if (res.errorsFound.length && res.errorsFound.length > 0) {
511
511
  throw new NoRetryError(res.errorsFound.join(","))
512
512
  } else {
@@ -521,9 +521,9 @@ async function getObjSchemaS3WithHierarchy(_izContext, objType) {
521
521
  * @see {@link getObjSchemaS3}
522
522
  * @see {@link getObjSchemaS3WithCache}
523
523
  */
524
- async function getObjSchemaS3WithoutHierarchy(_izContext, objType) {
524
+ async function getObjSchemaS3WithoutHierarchy(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
525
525
  // return await getObjSchemaS3WithCache(_izContext, objType, false)
526
- return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName).then(res => {
526
+ return await getObjSchemaWithoutHierarchy(getSchemaByNameWithCache, objType, bucketName).then(res => {
527
527
  if (res.errorsFound.length && res.errorsFound.length > 0) {
528
528
  throw new NoRetryError(res.errorsFound.join(","))
529
529
  } else {
@@ -639,8 +639,8 @@ function getLocalRelationshipSchemas(_izContext, relationshipTags, objSchemaPath
639
639
  * @param {String} objType.serviceTag
640
640
  * @returns {Promise<Object>} - reference relationship schema of objType
641
641
  */
642
- async function getRefObjectRelationship(_izContext, objType) {
643
- return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType, process.env.iz_serviceSchemaBucketName).then(res => {
642
+ async function getRefObjectRelationship(_izContext, objType, bucketName = process.env.iz_serviceSchemaBucketName) {
643
+ return await getRefObjectRelationshipShared(getSchemaByNameWithCache, objType, bucketName).then(res => {
644
644
  if (res.errorsFound.length && res.errorsFound.length > 0) {
645
645
  throw new NoRetryError(res.errorsFound.join(","))
646
646
  } else {
@@ -674,8 +674,8 @@ const getRefObjectRelationshipWithCache = inMemoryCacheLib(
674
674
  * @returns {Promise<{item:object|null,location:string|null}>} - item: relationship data, location: actual serviceTag that relationship located
675
675
  *
676
676
  */
677
- async function getRelationshipSchema(_izContext, relType) {
678
- return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType, process.env.iz_serviceSchemaBucketName).then(res => {
677
+ async function getRelationshipSchema(_izContext, relType, bucketName = process.env.iz_serviceSchemaBucketName) {
678
+ return await getRelationshipSchemaShared(getSchemaByNameWithCache, relType, bucketName).then(res => {
679
679
  if (res.errorsFound.length && res.errorsFound.length > 0) {
680
680
  throw new NoRetryError(res.errorsFound.join(","))
681
681
  } else {
@@ -82,13 +82,14 @@ const getServiceNameWithCache = inMemoryCacheLib(
82
82
  async function getGraphServiceTag(
83
83
  _izContext,
84
84
  graphServerTag,
85
+ bucketName = process.env.iz_serviceSchemaBucketName
85
86
  ) {
86
87
 
87
88
  // get all graph serverTag
88
89
  let [serverTags] = await getObjectS3(
89
90
  _izContext,
90
91
  {
91
- Bucket: process.env.iz_serviceSchemaBucketName,
92
+ Bucket: bucketName,
92
93
  Key: UPLOAD_PATH_S3.graphServerTagsConfig
93
94
  }
94
95
  );
@@ -93,7 +93,7 @@ async function uploadObjectToS3(
93
93
  const Key = pathToUpload
94
94
 
95
95
  let data = {
96
- Bucket: process.env.iz_serviceSchemaBucketName,
96
+ Bucket: process.env.iz_serviceSchemaBucketName || OBJECT_SCHEMA_BUCKET_NAME,
97
97
  Key,
98
98
  Body: buffer,
99
99
  ContentEncoding: 'base64',
@@ -969,7 +969,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
969
969
  const storageResource = objSchema.storageResources[storageTag];
970
970
 
971
971
  if (storageResource.storageType === STORAGE_TYPES.graph) {
972
- const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag);
972
+ const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag, iz_serviceSchemaBucketName);
973
973
 
974
974
  if (!graphServiceTag) {
975
975
  validateStatus.status = false;
@@ -1040,7 +1040,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1040
1040
  const storageResource = relData.storageResources[storageTag];
1041
1041
 
1042
1042
  if (storageResource.storageType === STORAGE_TYPES.graph) {
1043
- const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag);
1043
+ const graphServiceTag = await getGraphServiceTag(_izContext, storageResource.graphServerTag, iz_serviceSchemaBucketName);
1044
1044
 
1045
1045
  if (!graphServiceTag) {
1046
1046
  validateStatus.status = false;
@@ -62,7 +62,7 @@ async function getObjectS3Shared(param) {
62
62
 
63
63
 
64
64
 
65
- async function getSchemaByName(params) {
65
+ async function getSchemaByName(params, bucketName) {
66
66
  if (!params.schemaName || !params.getParams) {
67
67
  throw new NoRetryError(`getSchemaByName invalid parameters`);
68
68
  }
@@ -73,7 +73,7 @@ async function getSchemaByName(params) {
73
73
 
74
74
  // build params for getObjectS3
75
75
  let getDataParam = {
76
- Bucket: process.env.iz_serviceSchemaBucketName,
76
+ Bucket: bucketName || process.env.iz_serviceSchemaBucketName || OBJECT_SCHEMA_BUCKET_NAME,
77
77
  Key: SCHEMA_NAME_PER_S3_PATH[params.schemaName](params.getParams)
78
78
  };
79
79