@izara_project/izara-core-library-sns 1.0.6 → 1.0.7
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/index.js +2 -8
- package/package.json +4 -5
- package/src/SnsSharedLib.js +17 -10
package/index.js
CHANGED
|
@@ -18,13 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
20
|
// Import the SnS shared library functions
|
|
21
|
-
|
|
21
|
+
import snsSharedLib from './src/SnsSharedLib.js';
|
|
22
22
|
|
|
23
23
|
// Export all the functions
|
|
24
|
-
|
|
25
|
-
snsTopicName: SnsSharedLib.snsTopicName,
|
|
26
|
-
snsTopicArn: SnsSharedLib.snsTopicArn,
|
|
27
|
-
extractTopicName: SnsSharedLib.extractTopicName,
|
|
28
|
-
snsTopicNameByFlowSchema: SnsSharedLib.snsTopicNameByFlowSchema,
|
|
29
|
-
snsTopicArnByFlowSchema: SnsSharedLib.snsTopicArnByFlowSchema
|
|
30
|
-
};
|
|
24
|
+
export default snsSharedLib;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-library-sns",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Connecting with AWS SNS Resource",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,12 +14,11 @@
|
|
|
14
14
|
"license": "AGPL-3.0-or-later",
|
|
15
15
|
"homepage": "https://bitbucket.org/izara-core-libraries/izara-core-library-sns/src/master/README.md",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"jest": "^
|
|
17
|
+
"jest": "^30.2.0"
|
|
18
18
|
},
|
|
19
19
|
"jest": {
|
|
20
20
|
"testEnvironment": "node"
|
|
21
21
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
}
|
|
22
|
+
"type": "module",
|
|
23
|
+
"dependencies": {}
|
|
25
24
|
}
|
package/src/SnsSharedLib.js
CHANGED
|
@@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
// const { getServiceNameWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
21
20
|
/**
|
|
22
21
|
* Generate sns topic name
|
|
23
22
|
* @param {Object} _izContext
|
|
@@ -26,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
26
25
|
*
|
|
27
26
|
* @returns {string} deployed SNS resource name
|
|
28
27
|
*/
|
|
29
|
-
|
|
28
|
+
function snsTopicName(_izContext, topicName, serviceTag = null) {
|
|
30
29
|
// concatenate with env stage setting
|
|
31
30
|
// return serviceName + process.env.iz_stage + topicName
|
|
32
31
|
|
|
@@ -46,11 +45,11 @@ module.exports.snsTopicName = async (_izContext, topicName, serviceTag = null) =
|
|
|
46
45
|
*
|
|
47
46
|
* @returns {string} deployed SNS resource name
|
|
48
47
|
*/
|
|
49
|
-
|
|
50
|
-
const snsTopicArn =
|
|
48
|
+
function snsTopicArn(_izContext, topicName, serviceTag = null) {
|
|
49
|
+
const snsTopicArn = snsTopicName(_izContext, topicName, serviceTag)
|
|
51
50
|
// concatenate with env stage setting
|
|
52
51
|
// arn:aws:sns:us-east-1:468568093265:GraphHandlerDevInChangeRelationshipType
|
|
53
|
-
return
|
|
52
|
+
return `arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsTopicArn}`
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
/**
|
|
@@ -59,7 +58,7 @@ module.exports.snsTopicArn = async (_izContext, topicName, serviceTag = null) =>
|
|
|
59
58
|
*
|
|
60
59
|
* @returns {string} deployed SNS resource name
|
|
61
60
|
*/
|
|
62
|
-
|
|
61
|
+
function extractTopicName(topicArn) {
|
|
63
62
|
let topicName = topicArn.split(":")[5];
|
|
64
63
|
return topicName
|
|
65
64
|
}
|
|
@@ -70,7 +69,7 @@ module.exports.extractTopicName = (topicArn) => {
|
|
|
70
69
|
* @param {string} topicName
|
|
71
70
|
* @param {string} serviceTag
|
|
72
71
|
*/
|
|
73
|
-
|
|
72
|
+
function snsTopicNameByFlowSchema(_izContext, topicName, serviceTag = null) {
|
|
74
73
|
if (!serviceTag) { // for owner service
|
|
75
74
|
return process.env.iz_serviceTag + "_" + process.env.iz_stage + "_" + topicName;
|
|
76
75
|
} else { // create table name for external service
|
|
@@ -86,9 +85,17 @@ module.exports.snsTopicNameByFlowSchema = (_izContext, topicName, serviceTag = n
|
|
|
86
85
|
*
|
|
87
86
|
* @returns {string} deployed SNS resource name
|
|
88
87
|
*/
|
|
89
|
-
|
|
90
|
-
const snsTopicArn =
|
|
88
|
+
function snsTopicArnByFlowSchema(_izContext, topicName, serviceTag = null) {
|
|
89
|
+
const snsTopicArn = snsTopicNameByFlowSchema(_izContext, topicName, serviceTag)
|
|
91
90
|
// concatenate with env stage setting
|
|
92
91
|
// arn:aws:sns:us-east-1:468568093265:GraphHandlerDevInChangeRelationshipType
|
|
93
|
-
return
|
|
92
|
+
return `arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsTopicArn}`
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default {
|
|
96
|
+
snsTopicName,
|
|
97
|
+
snsTopicArn,
|
|
98
|
+
extractTopicName,
|
|
99
|
+
snsTopicNameByFlowSchema,
|
|
100
|
+
snsTopicArnByFlowSchema
|
|
94
101
|
}
|