@apipass/event-notification 0.0.57 → 0.0.59
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AWSEventNotificationOptions } from "./event-notification-options";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { EventNotificationService } from './event-notification-service-factory';
|
|
3
|
+
import { MessageAttributeValue } from "@aws-sdk/client-sns/dist-types/models/models_0";
|
|
4
|
+
export declare class AWSEventNotificationService implements EventNotificationService {
|
|
4
5
|
private readonly logger;
|
|
5
6
|
private readonly region;
|
|
6
7
|
private readonly accountId;
|
|
@@ -8,7 +9,7 @@ export declare class AWSEventNotificationService implements EventNotificationSer
|
|
|
8
9
|
private readonly s3BucketName?;
|
|
9
10
|
private readonly s3Client;
|
|
10
11
|
constructor(options: AWSEventNotificationOptions);
|
|
11
|
-
notifyEvent(eventName: string, content?: any): Promise<void>;
|
|
12
|
+
notifyEvent(eventName: string, content?: any, attributes?: Record<string, MessageAttributeValue>): Promise<void>;
|
|
12
13
|
private createTopic;
|
|
13
14
|
private sendMessage;
|
|
14
15
|
private buildMessageBody;
|
|
@@ -38,15 +38,15 @@ let AWSEventNotificationService = AWSEventNotificationService_1 = class AWSEvent
|
|
|
38
38
|
this.s3BucketName = options.s3BucketName;
|
|
39
39
|
this.s3Client = new client_s3_1.S3Client({ region: this.region });
|
|
40
40
|
}
|
|
41
|
-
notifyEvent(eventName, content) {
|
|
41
|
+
notifyEvent(eventName, content, attributes) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
try {
|
|
44
|
-
yield this.sendMessage(eventName, content);
|
|
44
|
+
yield this.sendMessage(eventName, content, attributes);
|
|
45
45
|
}
|
|
46
46
|
catch (e) {
|
|
47
47
|
if (e.Code === 'NotFound') {
|
|
48
48
|
yield this.createTopic(eventName);
|
|
49
|
-
yield this.sendMessage(eventName, content);
|
|
49
|
+
yield this.sendMessage(eventName, content, attributes);
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
52
|
throw e;
|
|
@@ -63,13 +63,14 @@ let AWSEventNotificationService = AWSEventNotificationService_1 = class AWSEvent
|
|
|
63
63
|
yield snsClient.send(new client_sns_1.CreateTopicCommand(params));
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
sendMessage(eventName, content) {
|
|
66
|
+
sendMessage(eventName, content, attributes) {
|
|
67
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
68
|
const TopicArn = AWSEventNotificationService_1.getTopicArn(eventName, this.region, this.accountId, this.environment);
|
|
69
69
|
const messageString = yield this.buildMessageBody(eventName, content);
|
|
70
70
|
yield new client_sns_1.SNSClient({ region: this.region }).send(new client_sns_1.PublishCommand({
|
|
71
71
|
TopicArn: TopicArn,
|
|
72
|
-
Message: messageString
|
|
72
|
+
Message: messageString,
|
|
73
|
+
MessageAttributes: attributes
|
|
73
74
|
}));
|
|
74
75
|
this.logger.warn(`Message send to topic: ${TopicArn}`);
|
|
75
76
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws-event-notification.service.js","sourceRoot":"","sources":["../src/aws-event-notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,iFAA2E;AAC3E,6EAA2E;AAE3E,oDAAkF;AAClF,kDAAgE;AAChE,mCAAoC;
|
|
1
|
+
{"version":3,"file":"aws-event-notification.service.js","sourceRoot":"","sources":["../src/aws-event-notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,iFAA2E;AAC3E,6EAA2E;AAE3E,oDAAkF;AAClF,kDAAgE;AAChE,mCAAoC;AAI7B,IAAM,2BAA2B,mCAAjC,MAAM,2BAA2B;IASpC,YAA+C,OAAoC;QARlE,WAAM,GAAG,IAAI,eAAM,CAAC,6BAA2B,CAAC,IAAI,CAAC,CAAC;QASnE,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ACV,WAAW,EAAE,kBAAkB;aAClC,CAAC,CAAC,CAAC;YAEJ,MAAM,OAAO,GAAG;gBACZ,kBAAkB;gBAClB;oBACI,YAAY,EAAE,IAAI,CAAC,YAAY;oBAC/B,KAAK,EAAE,GAAG;iBACb;aACJ,CAAC;YACF,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;KAAA;IAEO,UAAU,CAAC,SAAiB;QAChC,MAAM,EAAE,GAAG,IAAA,mBAAU,GAAE,CAAC;QACxB,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC1D,OAAO,GAAG,IAAI,CAAC,WAAW,IAAI,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC;IAC/D,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,SAAiB,EAAE,MAAc,EAAE,SAAiB,EAAE,WAAmB;QACxF,OAAO,eAAe,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,WAAW,EAAE,CAAA;IAC3E,CAAC;CAEJ,CAAA;AA9FY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,mBAAU,GAAE;IAUI,WAAA,IAAA,eAAM,EAAC,wDAAyB,CAAC,CAAA;qCAAU,wDAA2B;GAT1E,2BAA2B,CA8FvC"}
|
|
@@ -2,5 +2,5 @@ export declare class EventNotificationServiceFactory {
|
|
|
2
2
|
static createInstance(type: string): any;
|
|
3
3
|
}
|
|
4
4
|
export interface EventNotificationService {
|
|
5
|
-
notifyEvent(eventName: string, message?: any): any;
|
|
5
|
+
notifyEvent(eventName: string, message?: any, attributes?: any): any;
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apipass/event-notification",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.59",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Nathan Lemos <nathan@apipass.com.br>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"tsc": "tsc"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "8d89f3009d1b7d5fc91e5957675cf3c365b10a5b"
|
|
32
32
|
}
|