@izara_project/izara-core-library-sns 1.0.3 → 1.0.5

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-sns",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Connecting with AWS SNS Resource",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,6 +20,6 @@
20
20
  "testEnvironment": "node"
21
21
  },
22
22
  "dependencies": {
23
- "@izara_project/izara-core-library-service-schemas": "^1.0.39"
23
+ "@izara_project/izara-core-library-service-schemas": "^1.0.49"
24
24
  }
25
25
  }
@@ -63,3 +63,32 @@ module.exports.extractTopicName = (topicArn) => {
63
63
  let topicName = topicArn.split(":")[5];
64
64
  return topicName
65
65
  }
66
+
67
+ /**
68
+ * Generate sns topic name for Flowschema
69
+ * @param {Object} _izContext
70
+ * @param {string} topicName
71
+ * @param {string} serviceTag
72
+ */
73
+ module.exports.snsTopicNameByFlowSchema = (_izContext, topicName, serviceTag = null) => {
74
+ if (!serviceTag) { // for owner service
75
+ return process.env.iz_serviceTag + "_" + process.env.iz_stage + "_" + topicName;
76
+ } else { // create table name for external service
77
+ return serviceTag + "_" + process.env.iz_stage + "_" + topicName;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Generate sns topic name
83
+ * @param {Object} _izContext
84
+ * @param {string} topicName
85
+ * @param {string} serviceTag
86
+ *
87
+ * @returns {string} deployed SNS resource name
88
+ */
89
+ module.exports.snsTopicArnByFlowSchema = async (_izContext, topicName, serviceTag = null) => {
90
+ const snsTopicArn = await this.snsTopicNameByFlowSchema(_izContext, topicName, serviceTag)
91
+ // concatenate with env stage setting
92
+ // arn:aws:sns:us-east-1:468568093265:GraphHandlerDevInChangeRelationshipType
93
+ return await `arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsTopicArn}`
94
+ }