@mbc-cqrs-serverless/core 1.2.6 → 1.3.0
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/dist/decorators/constants.d.ts +1 -0
- package/dist/decorators/constants.js +2 -1
- package/dist/decorators/constants.js.map +1 -1
- package/dist/decorators/index.d.ts +1 -0
- package/dist/decorators/index.js +1 -0
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/notification-transport.decorator.d.ts +6 -0
- package/dist/decorators/notification-transport.decorator.js +14 -0
- package/dist/decorators/notification-transport.decorator.js.map +1 -0
- package/dist/env.validation.d.ts +19 -0
- package/dist/env.validation.js +22 -1
- package/dist/env.validation.js.map +1 -1
- package/dist/notification-env.validation.d.ts +8 -0
- package/dist/notification-env.validation.js +36 -0
- package/dist/notification-env.validation.js.map +1 -0
- package/dist/notifications/appsync-events.service.d.ts +44 -0
- package/dist/notifications/appsync-events.service.js +147 -0
- package/dist/notifications/appsync-events.service.js.map +1 -0
- package/dist/notifications/appsync.service.d.ts +3 -2
- package/dist/notifications/appsync.service.js +20 -12
- package/dist/notifications/appsync.service.js.map +1 -1
- package/dist/notifications/enums/index.d.ts +1 -0
- package/dist/notifications/enums/index.js +18 -0
- package/dist/notifications/enums/index.js.map +1 -0
- package/dist/notifications/enums/notification-transport.enum.d.ts +4 -0
- package/dist/notifications/enums/notification-transport.enum.js +9 -0
- package/dist/notifications/enums/notification-transport.enum.js.map +1 -0
- package/dist/notifications/event/notification.event.handler.d.ts +13 -5
- package/dist/notifications/event/notification.event.handler.js +31 -7
- package/dist/notifications/event/notification.event.handler.js.map +1 -1
- package/dist/notifications/index.d.ts +3 -0
- package/dist/notifications/index.js +3 -0
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/interfaces/index.d.ts +1 -0
- package/dist/notifications/interfaces/index.js +18 -0
- package/dist/notifications/interfaces/index.js.map +1 -0
- package/dist/notifications/interfaces/notification-transport.interface.d.ts +7 -0
- package/dist/notifications/interfaces/notification-transport.interface.js +5 -0
- package/dist/notifications/interfaces/notification-transport.interface.js.map +1 -0
- package/dist/notifications/notification.module.js +12 -2
- package/dist/notifications/notification.module.js.map +1 -1
- package/dist/services/explorer.service.d.ts +3 -0
- package/dist/services/explorer.service.js +5 -0
- package/dist/services/explorer.service.js.map +1 -1
- package/package.json +4 -4
|
@@ -3,3 +3,4 @@ export declare const EVENT_HANDLER_METADATA = "__eventHandler__";
|
|
|
3
3
|
export declare const EVENT_FACTORY_METADATA = "__eventFactory__";
|
|
4
4
|
export declare const DATA_SYNC_HANDLER_METADATA = "__dataSyncHandler__";
|
|
5
5
|
export declare const ROLE_METADATA = "__allowedRoles__";
|
|
6
|
+
export declare const NOTIFICATION_TRANSPORT_METADATA = "__notificationTransport__";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ROLE_METADATA = exports.DATA_SYNC_HANDLER_METADATA = exports.EVENT_FACTORY_METADATA = exports.EVENT_HANDLER_METADATA = exports.EVENT_METADATA = void 0;
|
|
3
|
+
exports.NOTIFICATION_TRANSPORT_METADATA = exports.ROLE_METADATA = exports.DATA_SYNC_HANDLER_METADATA = exports.EVENT_FACTORY_METADATA = exports.EVENT_HANDLER_METADATA = exports.EVENT_METADATA = void 0;
|
|
4
4
|
exports.EVENT_METADATA = '__event__';
|
|
5
5
|
exports.EVENT_HANDLER_METADATA = '__eventHandler__';
|
|
6
6
|
exports.EVENT_FACTORY_METADATA = '__eventFactory__';
|
|
7
7
|
exports.DATA_SYNC_HANDLER_METADATA = '__dataSyncHandler__';
|
|
8
8
|
exports.ROLE_METADATA = '__allowedRoles__';
|
|
9
|
+
exports.NOTIFICATION_TRANSPORT_METADATA = '__notificationTransport__';
|
|
9
10
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/decorators/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,WAAW,CAAA;AAC5B,QAAA,sBAAsB,GAAG,kBAAkB,CAAA;AAC3C,QAAA,sBAAsB,GAAG,kBAAkB,CAAA;AAC3C,QAAA,0BAA0B,GAAG,qBAAqB,CAAA;AAClD,QAAA,aAAa,GAAG,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/decorators/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,WAAW,CAAA;AAC5B,QAAA,sBAAsB,GAAG,kBAAkB,CAAA;AAC3C,QAAA,sBAAsB,GAAG,kBAAkB,CAAA;AAC3C,QAAA,0BAA0B,GAAG,qBAAqB,CAAA;AAClD,QAAA,aAAa,GAAG,kBAAkB,CAAA;AAClC,QAAA,+BAA+B,GAAG,2BAA2B,CAAA"}
|
|
@@ -4,5 +4,6 @@ export * from './context.decorator';
|
|
|
4
4
|
export * from './data-sync-handler.decorator';
|
|
5
5
|
export * from './event-factory.decorator';
|
|
6
6
|
export * from './event-handler.decorator';
|
|
7
|
+
export * from './notification-transport.decorator';
|
|
7
8
|
export * from './roles.decorator';
|
|
8
9
|
export * from './swagger-response.decorator';
|
package/dist/decorators/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./context.decorator"), exports);
|
|
|
20
20
|
__exportStar(require("./data-sync-handler.decorator"), exports);
|
|
21
21
|
__exportStar(require("./event-factory.decorator"), exports);
|
|
22
22
|
__exportStar(require("./event-handler.decorator"), exports);
|
|
23
|
+
__exportStar(require("./notification-transport.decorator"), exports);
|
|
23
24
|
__exportStar(require("./roles.decorator"), exports);
|
|
24
25
|
__exportStar(require("./swagger-response.decorator"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,8CAA2B;AAC3B,sDAAmC;AACnC,gEAA6C;AAC7C,4DAAyC;AACzC,4DAAyC;AACzC,oDAAiC;AACjC,+DAA4C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,8CAA2B;AAC3B,sDAAmC;AACnC,gEAA6C;AAC7C,4DAAyC;AACzC,4DAAyC;AACzC,qEAAkD;AAClD,oDAAiC;AACjC,+DAA4C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decorator to register a class as a Notification Transport.
|
|
3
|
+
* Automatically marks the class as an @Injectable() provider.
|
|
4
|
+
* @param name The unique identifier for this transport (e.g., 'pusher', 'appsync-event')
|
|
5
|
+
*/
|
|
6
|
+
export declare function NotificationTransport(name: string): ClassDecorator;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationTransport = NotificationTransport;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
/**
|
|
7
|
+
* Decorator to register a class as a Notification Transport.
|
|
8
|
+
* Automatically marks the class as an @Injectable() provider.
|
|
9
|
+
* @param name The unique identifier for this transport (e.g., 'pusher', 'appsync-event')
|
|
10
|
+
*/
|
|
11
|
+
function NotificationTransport(name) {
|
|
12
|
+
return (0, common_1.applyDecorators)((0, common_1.SetMetadata)(constants_1.NOTIFICATION_TRANSPORT_METADATA, name), (0, common_1.Injectable)());
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=notification-transport.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-transport.decorator.js","sourceRoot":"","sources":["../../src/decorators/notification-transport.decorator.ts"],"names":[],"mappings":";;AASA,sDAKC;AAdD,2CAAyE;AAEzE,2CAA6D;AAE7D;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,IAAY;IAChD,OAAO,IAAA,wBAAe,EACpB,IAAA,oBAAW,EAAC,2CAA+B,EAAE,IAAI,CAAC,EAClD,IAAA,mBAAU,GAAE,CACK,CAAA;AACrB,CAAC"}
|
package/dist/env.validation.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ClassConstructor } from 'class-transformer';
|
|
2
|
+
export { BUILTIN_NOTIFICATION_TRANSPORT_ENV, parseNotificationTransports, validateBuiltinNotificationTransportEnv, } from './notification-env.validation';
|
|
2
3
|
export declare enum Environment {
|
|
3
4
|
Local = "local",
|
|
4
5
|
Development = "dev",
|
|
@@ -22,7 +23,25 @@ export declare class EnvironmentVariables {
|
|
|
22
23
|
SFN_COMMAND_ARN: string;
|
|
23
24
|
SNS_ENDPOINT: string;
|
|
24
25
|
SNS_REGION: string;
|
|
26
|
+
/**
|
|
27
|
+
* Comma-separated list of active notification transport names.
|
|
28
|
+
* Supported built-in values: 'appsync-graphql' | 'appsync-event'
|
|
29
|
+
* Defaults to 'appsync-graphql' when not set.
|
|
30
|
+
*
|
|
31
|
+
* Examples:
|
|
32
|
+
* NOTIFICATION_TRANSPORTS=appsync-graphql
|
|
33
|
+
* NOTIFICATION_TRANSPORTS=appsync-event
|
|
34
|
+
* NOTIFICATION_TRANSPORTS=appsync-graphql,appsync-event
|
|
35
|
+
*/
|
|
36
|
+
NOTIFICATION_TRANSPORTS: string;
|
|
25
37
|
APPSYNC_ENDPOINT: string;
|
|
38
|
+
APPSYNC_EVENTS_ENDPOINT: string;
|
|
39
|
+
/**
|
|
40
|
+
* Channel namespace name — must match the pre-created namespace in the
|
|
41
|
+
* AppSync Event API (segment 1 of every channel path).
|
|
42
|
+
* Defaults to 'default'.
|
|
43
|
+
*/
|
|
44
|
+
APPSYNC_EVENTS_NAMESPACE: string;
|
|
26
45
|
SES_ENDPOINT: string;
|
|
27
46
|
SES_REGION: string;
|
|
28
47
|
SES_FROM_EMAIL: string;
|
package/dist/env.validation.js
CHANGED
|
@@ -9,10 +9,15 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EnvironmentVariables = exports.Environment = void 0;
|
|
12
|
+
exports.EnvironmentVariables = exports.Environment = exports.validateBuiltinNotificationTransportEnv = exports.parseNotificationTransports = exports.BUILTIN_NOTIFICATION_TRANSPORT_ENV = void 0;
|
|
13
13
|
exports.getValidateConfig = getValidateConfig;
|
|
14
14
|
const class_transformer_1 = require("class-transformer");
|
|
15
15
|
const class_validator_1 = require("class-validator");
|
|
16
|
+
const notification_env_validation_1 = require("./notification-env.validation");
|
|
17
|
+
var notification_env_validation_2 = require("./notification-env.validation");
|
|
18
|
+
Object.defineProperty(exports, "BUILTIN_NOTIFICATION_TRANSPORT_ENV", { enumerable: true, get: function () { return notification_env_validation_2.BUILTIN_NOTIFICATION_TRANSPORT_ENV; } });
|
|
19
|
+
Object.defineProperty(exports, "parseNotificationTransports", { enumerable: true, get: function () { return notification_env_validation_2.parseNotificationTransports; } });
|
|
20
|
+
Object.defineProperty(exports, "validateBuiltinNotificationTransportEnv", { enumerable: true, get: function () { return notification_env_validation_2.validateBuiltinNotificationTransportEnv; } });
|
|
16
21
|
var Environment;
|
|
17
22
|
(function (Environment) {
|
|
18
23
|
Environment["Local"] = "local";
|
|
@@ -96,11 +101,26 @@ __decorate([
|
|
|
96
101
|
(0, class_validator_1.IsOptional)(),
|
|
97
102
|
__metadata("design:type", String)
|
|
98
103
|
], EnvironmentVariables.prototype, "SNS_REGION", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, class_validator_1.IsString)(),
|
|
106
|
+
(0, class_validator_1.IsOptional)(),
|
|
107
|
+
__metadata("design:type", String)
|
|
108
|
+
], EnvironmentVariables.prototype, "NOTIFICATION_TRANSPORTS", void 0);
|
|
99
109
|
__decorate([
|
|
100
110
|
(0, class_validator_1.IsString)(),
|
|
101
111
|
(0, class_validator_1.IsOptional)(),
|
|
102
112
|
__metadata("design:type", String)
|
|
103
113
|
], EnvironmentVariables.prototype, "APPSYNC_ENDPOINT", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, class_validator_1.IsString)(),
|
|
116
|
+
(0, class_validator_1.IsOptional)(),
|
|
117
|
+
__metadata("design:type", String)
|
|
118
|
+
], EnvironmentVariables.prototype, "APPSYNC_EVENTS_ENDPOINT", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, class_validator_1.IsString)(),
|
|
121
|
+
(0, class_validator_1.IsOptional)(),
|
|
122
|
+
__metadata("design:type", String)
|
|
123
|
+
], EnvironmentVariables.prototype, "APPSYNC_EVENTS_NAMESPACE", void 0);
|
|
104
124
|
__decorate([
|
|
105
125
|
(0, class_validator_1.IsString)(),
|
|
106
126
|
(0, class_validator_1.IsOptional)(),
|
|
@@ -136,6 +156,7 @@ function getValidateConfig(cls) {
|
|
|
136
156
|
if (errors.length > 0) {
|
|
137
157
|
throw new Error(errors.toString());
|
|
138
158
|
}
|
|
159
|
+
(0, notification_env_validation_1.validateBuiltinNotificationTransportEnv)(validatedConfig);
|
|
139
160
|
return validatedConfig;
|
|
140
161
|
};
|
|
141
162
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.validation.js","sourceRoot":"","sources":["../src/env.validation.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"env.validation.js","sourceRoot":"","sources":["../src/env.validation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgIA,8CAyBC;AAzJD,yDAAqE;AACrE,qDAQwB;AAExB,+EAAuF;AAEvF,6EAIsC;AAHpC,iJAAA,kCAAkC,OAAA;AAClC,0IAAA,2BAA2B,OAAA;AAC3B,sJA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AAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qEACkB;AAS/B;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;sEACmB;AAMhC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;0DACO;AAGpB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wDACK;AAElB;IADC,IAAA,0BAAQ,GAAE;;4DACW;AAItB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qEACkB;AAI/B;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qEACkB;AAGjC,SAAgB,iBAAiB,CAC/B,GAAyB;IAEzB,OAAO,SAAS,QAAQ,CAAC,MAA+B;QACtD,MAAM,eAAe,GAAG,IAAA,mCAAe,EACrC,GAAG,IAAI,oBAAoB,EAC3B,MAAM,EACN;YACE,wBAAwB,EAAE,IAAI;SAC/B,CACF,CAAA;QACD,MAAM,MAAM,GAAG,IAAA,8BAAY,EAAC,eAAe,EAAE;YAC3C,qBAAqB,EAAE,KAAK;SAC7B,CAAC,CAAA;QAEF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;QACpC,CAAC;QAED,IAAA,qEAAuC,EACrC,eAAqD,CACtD,CAAA;QAED,OAAO,eAAe,CAAA;IACxB,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Built-in transports and their required endpoint environment variables. */
|
|
2
|
+
export declare const BUILTIN_NOTIFICATION_TRANSPORT_ENV: Record<string, string>;
|
|
3
|
+
/**
|
|
4
|
+
* Parses NOTIFICATION_TRANSPORTS the same way as NotificationEventHandler.
|
|
5
|
+
* Defaults to appsync-graphql when unset or empty.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseNotificationTransports(raw: string | undefined): string[];
|
|
8
|
+
export declare function validateBuiltinNotificationTransportEnv(config: Record<string, unknown>): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BUILTIN_NOTIFICATION_TRANSPORT_ENV = void 0;
|
|
4
|
+
exports.parseNotificationTransports = parseNotificationTransports;
|
|
5
|
+
exports.validateBuiltinNotificationTransportEnv = validateBuiltinNotificationTransportEnv;
|
|
6
|
+
const enums_1 = require("./notifications/enums");
|
|
7
|
+
/** Built-in transports and their required endpoint environment variables. */
|
|
8
|
+
exports.BUILTIN_NOTIFICATION_TRANSPORT_ENV = {
|
|
9
|
+
[enums_1.NotificationTransports.APPSYNC_GRAPHQL]: 'APPSYNC_ENDPOINT',
|
|
10
|
+
[enums_1.NotificationTransports.APPSYNC_EVENT]: 'APPSYNC_EVENTS_ENDPOINT',
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Parses NOTIFICATION_TRANSPORTS the same way as NotificationEventHandler.
|
|
14
|
+
* Defaults to appsync-graphql when unset or empty.
|
|
15
|
+
*/
|
|
16
|
+
function parseNotificationTransports(raw) {
|
|
17
|
+
const names = (raw ?? '')
|
|
18
|
+
.split(',')
|
|
19
|
+
.map((s) => s.trim())
|
|
20
|
+
.filter(Boolean);
|
|
21
|
+
return names.length > 0 ? names : [enums_1.NotificationTransports.APPSYNC_GRAPHQL];
|
|
22
|
+
}
|
|
23
|
+
function validateBuiltinNotificationTransportEnv(config) {
|
|
24
|
+
const active = parseNotificationTransports(config.NOTIFICATION_TRANSPORTS);
|
|
25
|
+
for (const name of active) {
|
|
26
|
+
const envKey = exports.BUILTIN_NOTIFICATION_TRANSPORT_ENV[name];
|
|
27
|
+
if (!envKey) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const value = config[envKey];
|
|
31
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
32
|
+
throw new Error(`Notification transport "${name}" is enabled (NOTIFICATION_TRANSPORTS) but ${envKey} is not set.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=notification-env.validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-env.validation.js","sourceRoot":"","sources":["../src/notification-env.validation.ts"],"names":[],"mappings":";;;AAYA,kEAMC;AAED,0FAoBC;AAxCD,iDAA8D;AAE9D,6EAA6E;AAChE,QAAA,kCAAkC,GAA2B;IACxE,CAAC,8BAAsB,CAAC,eAAe,CAAC,EAAE,kBAAkB;IAC5D,CAAC,8BAAsB,CAAC,aAAa,CAAC,EAAE,yBAAyB;CAClE,CAAA;AAED;;;GAGG;AACH,SAAgB,2BAA2B,CAAC,GAAuB;IACjE,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC;SACtB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,CAAA;IAClB,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,8BAAsB,CAAC,eAAe,CAAC,CAAA;AAC5E,CAAC;AAED,SAAgB,uCAAuC,CACrD,MAA+B;IAE/B,MAAM,MAAM,GAAG,2BAA2B,CACxC,MAAM,CAAC,uBAA6C,CACrD,CAAA;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,0CAAkC,CAAC,IAAI,CAAC,CAAA;QACvD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,SAAQ;QACV,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;QAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CACb,2BAA2B,IAAI,8CAA8C,MAAM,cAAc,CAClG,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { INotification } from '../interfaces';
|
|
3
|
+
import { INotificationTransport } from './interfaces';
|
|
4
|
+
export declare class AppSyncEventsService implements INotificationTransport {
|
|
5
|
+
private readonly config;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
private readonly url;
|
|
8
|
+
private readonly namespace;
|
|
9
|
+
private readonly signer;
|
|
10
|
+
constructor(config: ConfigService);
|
|
11
|
+
/**
|
|
12
|
+
* Publish INotification to an AppSync Events channel via IAM SigV4.
|
|
13
|
+
*
|
|
14
|
+
* Channel structure (max 5 segments, seg 1 = namespace):
|
|
15
|
+
* /{namespace}/{tenantCode}/{action}/{sanitizedId}
|
|
16
|
+
*
|
|
17
|
+
* Client subscription options (wildcard /* catches all sub-channels):
|
|
18
|
+
* /{namespace}/{tenantCode}/* — all events for tenant
|
|
19
|
+
* /{namespace}/{tenantCode}/{action}/* — filtered by action
|
|
20
|
+
* /{namespace}/{tenantCode}/{action}/{id} — specific command
|
|
21
|
+
*
|
|
22
|
+
* Requires: Lambda execution role must have appsync:EventPublish permission.
|
|
23
|
+
*/
|
|
24
|
+
sendMessage(notification: INotification): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the most specific channel path for a notification.
|
|
27
|
+
* Non-alphanumeric characters (e.g. #, @) are sanitized to dashes
|
|
28
|
+
* since AppSync Events channel segments only allow [a-zA-Z0-9-].
|
|
29
|
+
*/
|
|
30
|
+
resolveChannel(notification: INotification): string;
|
|
31
|
+
/**
|
|
32
|
+
* Formats a string to comply with AppSync Events API channel segment rules:
|
|
33
|
+
* 1. Only alphanumeric characters and dashes.
|
|
34
|
+
* 2. Cannot start or end with a dash.
|
|
35
|
+
* 3. Maximum length of 50 characters.
|
|
36
|
+
*/
|
|
37
|
+
private sanitizeSegment;
|
|
38
|
+
private postToChannel;
|
|
39
|
+
/**
|
|
40
|
+
* Builds and signs an HttpRequest for the given channel and notification.
|
|
41
|
+
* Separating signing from the fetch call makes each step independently testable.
|
|
42
|
+
*/
|
|
43
|
+
private signRequest;
|
|
44
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var AppSyncEventsService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.AppSyncEventsService = void 0;
|
|
17
|
+
const node_crypto_1 = require("node:crypto");
|
|
18
|
+
const sha256_js_1 = require("@aws-crypto/sha256-js");
|
|
19
|
+
const credential_provider_node_1 = require("@aws-sdk/credential-provider-node");
|
|
20
|
+
const common_1 = require("@nestjs/common");
|
|
21
|
+
const config_1 = require("@nestjs/config");
|
|
22
|
+
const protocol_http_1 = require("@smithy/protocol-http");
|
|
23
|
+
const signature_v4_1 = require("@smithy/signature-v4");
|
|
24
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
25
|
+
const decorators_1 = require("../decorators");
|
|
26
|
+
const enums_1 = require("./enums");
|
|
27
|
+
/** Default headers required for AppSync Events API requests */
|
|
28
|
+
const DEFAULT_HEADERS = {
|
|
29
|
+
accept: 'application/json, text/javascript',
|
|
30
|
+
'content-encoding': 'amz-1.0',
|
|
31
|
+
'content-type': 'application/json; charset=UTF-8',
|
|
32
|
+
};
|
|
33
|
+
let AppSyncEventsService = AppSyncEventsService_1 = class AppSyncEventsService {
|
|
34
|
+
constructor(config) {
|
|
35
|
+
this.config = config;
|
|
36
|
+
this.logger = new common_1.Logger(AppSyncEventsService_1.name);
|
|
37
|
+
const endpoint = config.get('APPSYNC_EVENTS_ENDPOINT');
|
|
38
|
+
this.namespace = config.get('APPSYNC_EVENTS_NAMESPACE') ?? 'default';
|
|
39
|
+
if (endpoint) {
|
|
40
|
+
this.url = new URL(endpoint);
|
|
41
|
+
// Region is parsed from the hostname automatically:
|
|
42
|
+
// <id>.appsync-api.<region>.amazonaws.com → region
|
|
43
|
+
// Falls back to AWS_REGION env var (always set in Lambda runtime).
|
|
44
|
+
const match = this.url.hostname.match(/\w+\.appsync-api\.([\w-]+)\.amazonaws\.com/);
|
|
45
|
+
const region = match?.[1] ?? process.env.AWS_REGION ?? 'ap-northeast-1';
|
|
46
|
+
this.signer = new signature_v4_1.SignatureV4({
|
|
47
|
+
credentials: (0, credential_provider_node_1.defaultProvider)(),
|
|
48
|
+
service: 'appsync',
|
|
49
|
+
region,
|
|
50
|
+
sha256: sha256_js_1.Sha256,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Publish INotification to an AppSync Events channel via IAM SigV4.
|
|
56
|
+
*
|
|
57
|
+
* Channel structure (max 5 segments, seg 1 = namespace):
|
|
58
|
+
* /{namespace}/{tenantCode}/{action}/{sanitizedId}
|
|
59
|
+
*
|
|
60
|
+
* Client subscription options (wildcard /* catches all sub-channels):
|
|
61
|
+
* /{namespace}/{tenantCode}/* — all events for tenant
|
|
62
|
+
* /{namespace}/{tenantCode}/{action}/* — filtered by action
|
|
63
|
+
* /{namespace}/{tenantCode}/{action}/{id} — specific command
|
|
64
|
+
*
|
|
65
|
+
* Requires: Lambda execution role must have appsync:EventPublish permission.
|
|
66
|
+
*/
|
|
67
|
+
async sendMessage(notification) {
|
|
68
|
+
if (!this.url || !this.signer) {
|
|
69
|
+
this.logger.warn('APPSYNC_EVENTS_ENDPOINT not set, skipping');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const channel = this.resolveChannel(notification);
|
|
73
|
+
this.logger.debug(`sendMessage:: channel=${channel}`);
|
|
74
|
+
await this.postToChannel(channel, notification);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolves the most specific channel path for a notification.
|
|
78
|
+
* Non-alphanumeric characters (e.g. #, @) are sanitized to dashes
|
|
79
|
+
* since AppSync Events channel segments only allow [a-zA-Z0-9-].
|
|
80
|
+
*/
|
|
81
|
+
resolveChannel(notification) {
|
|
82
|
+
const namespace = this.sanitizeSegment(this.namespace);
|
|
83
|
+
const tenantCode = this.sanitizeSegment(notification.tenantCode);
|
|
84
|
+
const action = this.sanitizeSegment(notification.action);
|
|
85
|
+
const id = this.sanitizeSegment(notification.id);
|
|
86
|
+
return `/${namespace}/${tenantCode}/${action}/${id}`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Formats a string to comply with AppSync Events API channel segment rules:
|
|
90
|
+
* 1. Only alphanumeric characters and dashes.
|
|
91
|
+
* 2. Cannot start or end with a dash.
|
|
92
|
+
* 3. Maximum length of 50 characters.
|
|
93
|
+
*/
|
|
94
|
+
sanitizeSegment(segment) {
|
|
95
|
+
if (!segment)
|
|
96
|
+
return 'none';
|
|
97
|
+
// Replace any non-alphanumeric character (like _, %, =) with a dash
|
|
98
|
+
let s = segment.replace(/[^a-zA-Z0-9]/g, '-');
|
|
99
|
+
// Truncate to AWS's strict 50 character limit
|
|
100
|
+
s = s.substring(0, 50);
|
|
101
|
+
// Strip out any dashes from the very beginning or end
|
|
102
|
+
s = s.replace(/^-+|-+$/g, '');
|
|
103
|
+
// Fallback if the string became empty after trimming
|
|
104
|
+
return s || 'none';
|
|
105
|
+
}
|
|
106
|
+
async postToChannel(channel, notification) {
|
|
107
|
+
const signedReq = await this.signRequest(channel, notification);
|
|
108
|
+
const res = await (0, node_fetch_1.default)(this.url.toString(), {
|
|
109
|
+
method: signedReq.method,
|
|
110
|
+
headers: signedReq.headers,
|
|
111
|
+
body: signedReq.body,
|
|
112
|
+
});
|
|
113
|
+
if (!res.ok) {
|
|
114
|
+
const text = await res.text();
|
|
115
|
+
throw new Error(`AppSync Events publish failed [${res.status}] on channel ${channel}: ${text}`);
|
|
116
|
+
}
|
|
117
|
+
this.logger.debug(`sendMessage:: published successfully to ${channel}`);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Builds and signs an HttpRequest for the given channel and notification.
|
|
121
|
+
* Separating signing from the fetch call makes each step independently testable.
|
|
122
|
+
*/
|
|
123
|
+
async signRequest(channel, notification) {
|
|
124
|
+
const body = JSON.stringify({
|
|
125
|
+
id: (0, node_crypto_1.randomUUID)(),
|
|
126
|
+
channel,
|
|
127
|
+
events: [JSON.stringify(notification)],
|
|
128
|
+
});
|
|
129
|
+
const httpRequest = new protocol_http_1.HttpRequest({
|
|
130
|
+
method: 'POST',
|
|
131
|
+
headers: {
|
|
132
|
+
...DEFAULT_HEADERS,
|
|
133
|
+
host: this.url.hostname,
|
|
134
|
+
},
|
|
135
|
+
body,
|
|
136
|
+
hostname: this.url.hostname,
|
|
137
|
+
path: this.url.pathname,
|
|
138
|
+
});
|
|
139
|
+
return this.signer.sign(httpRequest);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
exports.AppSyncEventsService = AppSyncEventsService;
|
|
143
|
+
exports.AppSyncEventsService = AppSyncEventsService = AppSyncEventsService_1 = __decorate([
|
|
144
|
+
(0, decorators_1.NotificationTransport)(enums_1.NotificationTransports.APPSYNC_EVENT),
|
|
145
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
146
|
+
], AppSyncEventsService);
|
|
147
|
+
//# sourceMappingURL=appsync-events.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appsync-events.service.js","sourceRoot":"","sources":["../../src/notifications/appsync-events.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAAwC;AAExC,qDAA8C;AAC9C,gFAAmE;AACnE,2CAAuC;AACvC,2CAA8C;AAC9C,yDAAmD;AACnD,uDAAkD;AAClD,4DAA8B;AAE9B,8CAAqD;AAErD,mCAAgD;AAGhD,+DAA+D;AAC/D,MAAM,eAAe,GAAG;IACtB,MAAM,EAAE,mCAAmC;IAC3C,kBAAkB,EAAE,SAAS;IAC7B,cAAc,EAAE,iCAAiC;CAClD,CAAA;AAGM,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAO/B,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QANjC,WAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAA;QAO7D,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAS,yBAAyB,CAAC,CAAA;QAC9D,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,CAAS,0BAA0B,CAAC,IAAI,SAAS,CAAA;QAE5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAA;YAE5B,oDAAoD;YACpD,qDAAqD;YACrD,mEAAmE;YACnE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CACnC,4CAA4C,CAC7C,CAAA;YACD,MAAM,MAAM,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI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AM,WAAW,GAAG,IAAI,2BAAW,CAAC;YAClC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,GAAG,eAAe;gBAClB,IAAI,EAAE,IAAI,CAAC,GAAI,CAAC,QAAQ;aACzB;YACD,IAAI;YACJ,QAAQ,EAAE,IAAI,CAAC,GAAI,CAAC,QAAQ;YAC5B,IAAI,EAAE,IAAI,CAAC,GAAI,CAAC,QAAQ;SACzB,CAAC,CAAA;QAEF,OAAO,IAAI,CAAC,MAAO,CAAC,IAAI,CAAC,WAAW,CAAyB,CAAA;IAC/D,CAAC;CACF,CAAA;AA5IY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,kCAAqB,EAAC,8BAAsB,CAAC,aAAa,CAAC;qCAQrB,sBAAa;GAPvC,oBAAoB,CA4IhC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConfigService } from '@nestjs/config';
|
|
2
2
|
import { INotification } from '../interfaces';
|
|
3
|
-
|
|
3
|
+
import { INotificationTransport } from './interfaces';
|
|
4
|
+
export declare class AppSyncService implements INotificationTransport {
|
|
4
5
|
private readonly config;
|
|
5
6
|
private readonly logger;
|
|
6
7
|
private readonly endpoint;
|
|
@@ -9,5 +10,5 @@ export declare class AppSyncService {
|
|
|
9
10
|
private readonly region;
|
|
10
11
|
private readonly signer;
|
|
11
12
|
constructor(config: ConfigService);
|
|
12
|
-
sendMessage(
|
|
13
|
+
sendMessage(notification: INotification): Promise<void>;
|
|
13
14
|
}
|
|
@@ -20,6 +20,8 @@ const signature_v4_1 = require("@aws-sdk/signature-v4");
|
|
|
20
20
|
const common_1 = require("@nestjs/common");
|
|
21
21
|
const config_1 = require("@nestjs/config");
|
|
22
22
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
23
|
+
const decorators_1 = require("../decorators");
|
|
24
|
+
const enums_1 = require("./enums");
|
|
23
25
|
const query = /* GraphQL */ `
|
|
24
26
|
mutation SEND_MESSAGE($message: AWSJSON!) {
|
|
25
27
|
sendMessage(message: $message) {
|
|
@@ -37,18 +39,24 @@ let AppSyncService = AppSyncService_1 = class AppSyncService {
|
|
|
37
39
|
constructor(config) {
|
|
38
40
|
this.config = config;
|
|
39
41
|
this.logger = new common_1.Logger(AppSyncService_1.name);
|
|
40
|
-
this.endpoint = config.get('APPSYNC_ENDPOINT');
|
|
41
|
-
this.apiKey = config.get('APPSYNC_API_KEY');
|
|
42
|
+
this.endpoint = config.get('APPSYNC_ENDPOINT') ?? '';
|
|
43
|
+
this.apiKey = config.get('APPSYNC_API_KEY') ?? '';
|
|
42
44
|
this.region = 'ap-northeast-1';
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
if (this.endpoint) {
|
|
46
|
+
this.hostname = new URL(this.endpoint).hostname;
|
|
47
|
+
this.signer = new signature_v4_1.SignatureV4({
|
|
48
|
+
credentials: (0, credential_provider_node_1.defaultProvider)(),
|
|
49
|
+
region: this.region,
|
|
50
|
+
service: 'appsync',
|
|
51
|
+
sha256: sha256_js_1.Sha256,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
50
54
|
}
|
|
51
|
-
async sendMessage(
|
|
55
|
+
async sendMessage(notification) {
|
|
56
|
+
if (!this.endpoint?.trim() || !this.hostname) {
|
|
57
|
+
this.logger.warn('APPSYNC_ENDPOINT is not set, skipping.');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
52
60
|
const headers = {
|
|
53
61
|
'Content-Type': 'application/json',
|
|
54
62
|
host: this.hostname,
|
|
@@ -56,7 +64,7 @@ let AppSyncService = AppSyncService_1 = class AppSyncService {
|
|
|
56
64
|
const body = JSON.stringify({
|
|
57
65
|
query,
|
|
58
66
|
variables: {
|
|
59
|
-
message: JSON.stringify(
|
|
67
|
+
message: JSON.stringify(notification),
|
|
60
68
|
},
|
|
61
69
|
});
|
|
62
70
|
const method = 'POST';
|
|
@@ -96,7 +104,7 @@ let AppSyncService = AppSyncService_1 = class AppSyncService {
|
|
|
96
104
|
};
|
|
97
105
|
exports.AppSyncService = AppSyncService;
|
|
98
106
|
exports.AppSyncService = AppSyncService = AppSyncService_1 = __decorate([
|
|
99
|
-
(0,
|
|
107
|
+
(0, decorators_1.NotificationTransport)(enums_1.NotificationTransports.APPSYNC_GRAPHQL),
|
|
100
108
|
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
101
109
|
], AppSyncService);
|
|
102
110
|
//# sourceMappingURL=appsync.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appsync.service.js","sourceRoot":"","sources":["../../src/notifications/appsync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAA8C;AAC9C,gFAAmE;AACnE,wDAAmD;AACnD,
|
|
1
|
+
{"version":3,"file":"appsync.service.js","sourceRoot":"","sources":["../../src/notifications/appsync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAA8C;AAC9C,gFAAmE;AACnE,wDAAmD;AACnD,2CAAuC;AACvC,2CAA8C;AAC9C,4DAA4C;AAE5C,8CAAqD;AAErD,mCAAgD;AAEhD,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;CAY3B,CAAA;AAGM,IAAM,cAAc,sBAApB,MAAM,cAAc;IASzB,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QARjC,WAAM,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAA;QASvD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAS,kBAAkB,CAAC,IAAI,EAAE,CAAA;QAC5D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAS,iBAAiB,CAAC,IAAI,EAAE,CAAA;QACzD,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAA;QAE9B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG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,CAAC,MAAM;gBACnB,OAAO,EAAE,SAAS;aACnB,CAAA;YACD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE;gBACpD,WAAW,EAAE,IAAI,IAAI,EAAE;aACxB,CAAC,CAAA;YACF,GAAG,GAAG,MAAM,IAAA,oBAAK,EAAC,IAAI,CAAC,QAAQ,EAAE;gBAC/B,MAAM,EAAE,aAAa,CAAC,MAAM;gBAC5B,OAAO,EAAE,aAAa,CAAC,OAAO;gBAC9B,IAAI,EAAE,aAAa,CAAC,IAAI;aACzB,CAAC,CAAA;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sCAAsC,EAAE,IAAI,CAAC,CAAA;QAE/D,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AA3EY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,kCAAqB,EAAC,8BAAsB,CAAC,eAAe,CAAC;qCAUvB,sBAAa;GATvC,cAAc,CA2E1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './notification-transport.enum';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./notification-transport.enum"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/notifications/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA6C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationTransports = void 0;
|
|
4
|
+
var NotificationTransports;
|
|
5
|
+
(function (NotificationTransports) {
|
|
6
|
+
NotificationTransports["APPSYNC_GRAPHQL"] = "appsync-graphql";
|
|
7
|
+
NotificationTransports["APPSYNC_EVENT"] = "appsync-event";
|
|
8
|
+
})(NotificationTransports || (exports.NotificationTransports = NotificationTransports = {}));
|
|
9
|
+
//# sourceMappingURL=notification-transport.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-transport.enum.js","sourceRoot":"","sources":["../../../src/notifications/enums/notification-transport.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,6DAAmC,CAAA;IACnC,yDAA+B,CAAA;AACjC,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import { ModuleRef } from '@nestjs/core';
|
|
1
4
|
import { IEventHandler } from '../../interfaces';
|
|
2
|
-
import {
|
|
5
|
+
import { ExplorerService } from '../../services';
|
|
3
6
|
import { NotificationEvent } from './notification.event';
|
|
4
|
-
export declare class NotificationEventHandler implements IEventHandler<NotificationEvent
|
|
5
|
-
private readonly
|
|
7
|
+
export declare class NotificationEventHandler implements IEventHandler<NotificationEvent>, OnModuleInit {
|
|
8
|
+
private readonly moduleRef;
|
|
9
|
+
private readonly explorerService;
|
|
10
|
+
private readonly config;
|
|
6
11
|
private readonly logger;
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
private readonly transports;
|
|
13
|
+
private readonly activeTransportNames;
|
|
14
|
+
constructor(moduleRef: ModuleRef, explorerService: ExplorerService, config: ConfigService);
|
|
15
|
+
onModuleInit(): void;
|
|
16
|
+
execute(event: NotificationEvent): Promise<void>;
|
|
9
17
|
}
|
|
@@ -12,24 +12,48 @@ var NotificationEventHandler_1;
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.NotificationEventHandler = void 0;
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
|
+
const config_1 = require("@nestjs/config");
|
|
16
|
+
const core_1 = require("@nestjs/core");
|
|
15
17
|
const decorators_1 = require("../../decorators");
|
|
16
|
-
const
|
|
18
|
+
const notification_env_validation_1 = require("../../notification-env.validation");
|
|
19
|
+
const services_1 = require("../../services");
|
|
17
20
|
const notification_event_1 = require("./notification.event");
|
|
18
21
|
let NotificationEventHandler = NotificationEventHandler_1 = class NotificationEventHandler {
|
|
19
|
-
constructor(
|
|
20
|
-
this.
|
|
22
|
+
constructor(moduleRef, explorerService, config) {
|
|
23
|
+
this.moduleRef = moduleRef;
|
|
24
|
+
this.explorerService = explorerService;
|
|
25
|
+
this.config = config;
|
|
21
26
|
this.logger = new common_1.Logger(NotificationEventHandler_1.name);
|
|
27
|
+
this.transports = new Map();
|
|
28
|
+
this.activeTransportNames = (0, notification_env_validation_1.parseNotificationTransports)(this.config.get('NOTIFICATION_TRANSPORTS'));
|
|
29
|
+
}
|
|
30
|
+
onModuleInit() {
|
|
31
|
+
this.logger.debug('Finding notification transports from decorators');
|
|
32
|
+
const { notificationTransports } = this.explorerService.exploreNotificationTransports();
|
|
33
|
+
for (const TransportClass of notificationTransports) {
|
|
34
|
+
const name = Reflect.getMetadata(decorators_1.NOTIFICATION_TRANSPORT_METADATA, TransportClass);
|
|
35
|
+
if (this.activeTransportNames.includes(name)) {
|
|
36
|
+
const instance = this.moduleRef.get(TransportClass, { strict: false });
|
|
37
|
+
// Give the instance its decorator name automatically if it isn't set
|
|
38
|
+
if (!instance.name) {
|
|
39
|
+
instance.name = name;
|
|
40
|
+
}
|
|
41
|
+
this.transports.set(name, instance);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
this.logger.debug(`Initialized active transports: [${[...this.transports.keys()].join(', ')}]`);
|
|
22
45
|
}
|
|
23
46
|
async execute(event) {
|
|
24
|
-
this.logger.debug('notification event executing:: ', event);
|
|
25
|
-
//send to appsync
|
|
26
47
|
const body = JSON.parse(event.body);
|
|
27
|
-
|
|
48
|
+
this.logger.debug(`execute:: broadcasting via ${this.transports.size} transport(s)`);
|
|
49
|
+
await Promise.all([...this.transports.values()].map((t) => t.sendMessage(body)));
|
|
28
50
|
}
|
|
29
51
|
};
|
|
30
52
|
exports.NotificationEventHandler = NotificationEventHandler;
|
|
31
53
|
exports.NotificationEventHandler = NotificationEventHandler = NotificationEventHandler_1 = __decorate([
|
|
32
54
|
(0, decorators_1.EventHandler)(notification_event_1.NotificationEvent),
|
|
33
|
-
__metadata("design:paramtypes", [
|
|
55
|
+
__metadata("design:paramtypes", [core_1.ModuleRef,
|
|
56
|
+
services_1.ExplorerService,
|
|
57
|
+
config_1.ConfigService])
|
|
34
58
|
], NotificationEventHandler);
|
|
35
59
|
//# sourceMappingURL=notification.event.handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.event.handler.js","sourceRoot":"","sources":["../../../src/notifications/event/notification.event.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"notification.event.handler.js","sourceRoot":"","sources":["../../../src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AI,EAAE,QAAQ,CAAC,CAAA;YACrC,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,mCAAmC,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC7E,CAAA;IACH,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAwB;QACpC,MAAM,IAAI,GAAkB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAElD,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,8BAA8B,IAAI,CAAC,UAAU,CAAC,IAAI,eAAe,CAClE,CAAA;QAED,MAAM,OAAO,CAAC,GAAG,CACf,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAC9D,CAAA;IACH,CAAC;CACF,CAAA;AA5DY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,yBAAY,EAAC,sCAAiB,CAAC;qCASA,gBAAS;QACH,0BAAe;QACxB,sBAAa;GAV7B,wBAAwB,CA4DpC"}
|
|
@@ -15,7 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./appsync.service"), exports);
|
|
18
|
+
__exportStar(require("./appsync-events.service"), exports);
|
|
18
19
|
__exportStar(require("./email.service"), exports);
|
|
20
|
+
__exportStar(require("./enums"), exports);
|
|
19
21
|
__exportStar(require("./event"), exports);
|
|
22
|
+
__exportStar(require("./interfaces"), exports);
|
|
20
23
|
__exportStar(require("./notification.module"), exports);
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,kDAA+B;AAC/B,0CAAuB;AACvB,wDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,2DAAwC;AACxC,kDAA+B;AAC/B,0CAAuB;AACvB,0CAAuB;AACvB,+CAA4B;AAC5B,wDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './notification-transport.interface';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./notification-transport.interface"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/notifications/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAkD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { INotification } from '../../interfaces';
|
|
2
|
+
export declare const NOTIFICATION_TRANSPORT = "NOTIFICATION_TRANSPORT";
|
|
3
|
+
export interface INotificationTransport {
|
|
4
|
+
name?: string;
|
|
5
|
+
sendMessage(notification: INotification): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export type NotificationTransportMap = Map<string, INotificationTransport>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-transport.interface.js","sourceRoot":"","sources":["../../../src/notifications/interfaces/notification-transport.interface.ts"],"names":[],"mappings":";;;AAEa,QAAA,sBAAsB,GAAG,wBAAwB,CAAA"}
|
|
@@ -8,7 +8,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.NotificationModule = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
|
+
const config_1 = require("@nestjs/config");
|
|
12
|
+
const services_1 = require("../services");
|
|
11
13
|
const appsync_service_1 = require("./appsync.service");
|
|
14
|
+
const appsync_events_service_1 = require("./appsync-events.service");
|
|
12
15
|
const email_service_1 = require("./email.service");
|
|
13
16
|
const notification_event_handler_1 = require("./event/notification.event.handler");
|
|
14
17
|
let NotificationModule = class NotificationModule {
|
|
@@ -17,8 +20,15 @@ exports.NotificationModule = NotificationModule;
|
|
|
17
20
|
exports.NotificationModule = NotificationModule = __decorate([
|
|
18
21
|
(0, common_1.Global)(),
|
|
19
22
|
(0, common_1.Module)({
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
imports: [config_1.ConfigModule],
|
|
24
|
+
providers: [
|
|
25
|
+
services_1.ExplorerService,
|
|
26
|
+
email_service_1.EmailService,
|
|
27
|
+
notification_event_handler_1.NotificationEventHandler,
|
|
28
|
+
appsync_service_1.AppSyncService,
|
|
29
|
+
appsync_events_service_1.AppSyncEventsService,
|
|
30
|
+
],
|
|
31
|
+
exports: [email_service_1.EmailService, appsync_service_1.AppSyncService, appsync_events_service_1.AppSyncEventsService],
|
|
22
32
|
})
|
|
23
33
|
], NotificationModule);
|
|
24
34
|
//# sourceMappingURL=notification.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.module.js","sourceRoot":"","sources":["../../src/notifications/notification.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA+C;
|
|
1
|
+
{"version":3,"file":"notification.module.js","sourceRoot":"","sources":["../../src/notifications/notification.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA+C;AAC/C,2CAA6C;AAE7C,0CAA6C;AAC7C,uDAAkD;AAClD,qEAA+D;AAC/D,mDAA8C;AAC9C,mFAA6E;AActE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAZ9B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,qBAAY,CAAC;QACvB,SAAS,EAAE;YACT,0BAAe;YACf,4BAAY;YACZ,qDAAwB;YACxB,gCAAc;YACd,6CAAoB;SACrB;QACD,OAAO,EAAE,CAAC,4BAAY,EAAE,gCAAc,EAAE,6CAAoB,CAAC;KAC9D,CAAC;GACW,kBAAkB,CAAG"}
|
|
@@ -14,6 +14,9 @@ export declare class ExplorerService {
|
|
|
14
14
|
exploreDataSyncHandlers(commandTableName: string): {
|
|
15
15
|
dataSyncHandlers: Type<IDataSyncHandler<any, any>>[];
|
|
16
16
|
};
|
|
17
|
+
exploreNotificationTransports(): {
|
|
18
|
+
notificationTransports: Type<any>[];
|
|
19
|
+
};
|
|
17
20
|
flatMap<T>(modules: Module[], callback: (instance: InstanceWrapper) => Type<any> | undefined): Type<T>[];
|
|
18
21
|
filterProvider(wrapper: InstanceWrapper, metadataKey: string, metadataValue?: string): Type<any> | undefined;
|
|
19
22
|
extractMetadata(instance: Record<string, any>, metadataKey: string, metadataValue?: string): Type<any>;
|
|
@@ -30,6 +30,11 @@ let ExplorerService = ExplorerService_1 = class ExplorerService {
|
|
|
30
30
|
const dataSyncHandlers = this.flatMap(modules, (instance) => this.filterProvider(instance, decorators_1.DATA_SYNC_HANDLER_METADATA, commandTableName));
|
|
31
31
|
return { dataSyncHandlers };
|
|
32
32
|
}
|
|
33
|
+
exploreNotificationTransports() {
|
|
34
|
+
const modules = [...this.modulesContainer.values()];
|
|
35
|
+
const notificationTransports = this.flatMap(modules, (instance) => this.filterProvider(instance, decorators_1.NOTIFICATION_TRANSPORT_METADATA));
|
|
36
|
+
return { notificationTransports };
|
|
37
|
+
}
|
|
33
38
|
flatMap(modules, callback) {
|
|
34
39
|
const items = modules
|
|
35
40
|
.map((module) => [...module.providers.values()].map(callback))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explorer.service.js","sourceRoot":"","sources":["../../src/services/explorer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAyD;AAGzD,+EAA0E;AAE1E,
|
|
1
|
+
{"version":3,"file":"explorer.service.js","sourceRoot":"","sources":["../../src/services/explorer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAyD;AAGzD,+EAA0E;AAE1E,8CAKsB;AAIf,IAAM,eAAe,uBAArB,MAAM,eAAe;IAG1B,YAA6B,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAF9C,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAA;IAEQ,CAAC;IAEnE,OAAO;QACL,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAA;QAEnD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAgB,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAC/D,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,mCAAsB,CAAC,CACtD,CAAA;QACD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAgB,OAA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IAC1D,CAAC;IAED,cAAc,CACZ,OAAwB,EACxB,WAAmB,EACnB,aAAsB;QAEtB,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;QAC5B,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,CAAC,CAAA;IACnE,CAAC;IAED,eAAe,CACb,QAA6B,EAC7B,WAAmB,EACnB,aAAsB;QAEtB,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC1B,OAAM;QACR,CAAC;QACD,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;QACvE,IAAI,CAAC,QAAQ,IAAI,CAAC,aAAa,IAAI,QAAQ,KAAK,aAAa,CAAC,EAAE,CAAC;YAC/D,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,OAAO,QAAQ,CAAC,WAAwB,CAAA;IAC1C,CAAC;CACF,CAAA;AA3EY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAIoC,oCAAgB;GAHpD,eAAe,CA2E3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbc-cqrs-serverless/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "CQRS and event base core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mbc",
|
|
@@ -62,14 +62,14 @@
|
|
|
62
62
|
"class-validator": "^0.14.0",
|
|
63
63
|
"jwt-decode": "^4.0.0",
|
|
64
64
|
"node-fetch": "^2.7.0",
|
|
65
|
-
"nodemailer": "^
|
|
65
|
+
"nodemailer": "^8.0.5",
|
|
66
66
|
"reflect-metadata": "^0.2.2",
|
|
67
67
|
"ulid": "^2.3.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/nodemailer": "^6.4.17",
|
|
71
71
|
"serverless": "^3.40.0",
|
|
72
|
-
"serverless-dynamodb": "^0.2.
|
|
72
|
+
"serverless-dynamodb": "^0.2.58",
|
|
73
73
|
"serverless-localstack": "^1.1.2",
|
|
74
74
|
"serverless-offline": "^13.3.2",
|
|
75
75
|
"serverless-offline-aws-eventbridge": "^2.1.0",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"serverless-step-functions-local": "^0.5.1",
|
|
89
89
|
"supertest": "^7.0.0"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "3e6f1b6d57bf38433d5f63dfb9f5e03a4c9bb25d"
|
|
92
92
|
}
|