@nathapp/nestjs-notification 1.0.0-rc.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.
Files changed (50) hide show
  1. package/.eslintrc.js +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +11 -0
  4. package/dist/email/constant.d.ts +3 -0
  5. package/dist/email/constant.js +6 -0
  6. package/dist/email/email-provider.factory.d.ts +5 -0
  7. package/dist/email/email-provider.factory.js +17 -0
  8. package/dist/email/email.interface.d.ts +23 -0
  9. package/dist/email/email.interface.js +2 -0
  10. package/dist/email/email.module.d.ts +24 -0
  11. package/dist/email/email.module.js +95 -0
  12. package/dist/email/email.provider.d.ts +19 -0
  13. package/dist/email/email.provider.js +87 -0
  14. package/dist/email/email.service.d.ts +8 -0
  15. package/dist/email/email.service.js +34 -0
  16. package/dist/email/index.d.ts +7 -0
  17. package/dist/email/index.js +16 -0
  18. package/dist/index.d.ts +5 -0
  19. package/dist/index.js +21 -0
  20. package/dist/interface/index.d.ts +2 -0
  21. package/dist/interface/index.js +2 -0
  22. package/dist/interface/message.interface.d.ts +15 -0
  23. package/dist/interface/message.interface.js +2 -0
  24. package/dist/interface/result.interface.d.ts +6 -0
  25. package/dist/interface/result.interface.js +2 -0
  26. package/dist/notification/constant.d.ts +3 -0
  27. package/dist/notification/constant.js +6 -0
  28. package/dist/notification/index.d.ts +4 -0
  29. package/dist/notification/index.js +11 -0
  30. package/dist/notification/notification.module.d.ts +23 -0
  31. package/dist/notification/notification.module.js +83 -0
  32. package/dist/notification/notification.service.d.ts +10 -0
  33. package/dist/notification/notification.service.js +49 -0
  34. package/dist/sms/index.d.ts +2 -0
  35. package/dist/sms/index.js +5 -0
  36. package/dist/sms/sms.service.d.ts +8 -0
  37. package/dist/sms/sms.service.js +6 -0
  38. package/dist/template/constant.d.ts +1 -0
  39. package/dist/template/constant.js +4 -0
  40. package/dist/template/fake-template.loader.d.ts +6 -0
  41. package/dist/template/fake-template.loader.js +23 -0
  42. package/dist/template/index.d.ts +5 -0
  43. package/dist/template/index.js +13 -0
  44. package/dist/template/template.loader.d.ts +29 -0
  45. package/dist/template/template.loader.js +78 -0
  46. package/dist/template/template.service.d.ts +6 -0
  47. package/dist/template/template.service.js +32 -0
  48. package/index.d.ts +1 -0
  49. package/index.js +6 -0
  50. package/package.json +56 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ parser: '@typescript-eslint/parser',
3
+ parserOptions: {
4
+ project: 'tsconfig.json',
5
+ sourceType: 'module',
6
+ },
7
+ plugins: ['@typescript-eslint/eslint-plugin'],
8
+ extends: [
9
+ 'plugin:@typescript-eslint/recommended',
10
+ 'plugin:prettier/recommended',
11
+ ],
12
+ root: true,
13
+ env: {
14
+ node: true,
15
+ jest: true,
16
+ },
17
+ ignorePatterns: ['.eslintrc.js'],
18
+ rules: {
19
+ '@typescript-eslint/interface-name-prefix': 'off',
20
+ '@typescript-eslint/explicit-function-return-type': 'off',
21
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
22
+ '@typescript-eslint/no-explicit-any': 'off',
23
+ },
24
+ };
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 KnowYourself
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # nestjs-notification Library
2
+
3
+
4
+ # Template Loader is using string-format to format args to value
5
+
6
+
7
+ # For CachableTemplateLoader is using nestjs native caching which required CacheModule.Register & install cache-manager
8
+
9
+ ```
10
+ npm install @nestjs/cache-manager cache-manager
11
+ ```
@@ -0,0 +1,3 @@
1
+ export declare const EMAIL_OPTIONS = "EMAIL_OPTIONS";
2
+ export declare const EMAIL_PROVIDER = "EMAIL_PROVIDER";
3
+ export declare const EMAIL_SERVICE = "EMAIL_SERVICE";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMAIL_SERVICE = exports.EMAIL_PROVIDER = exports.EMAIL_OPTIONS = void 0;
4
+ exports.EMAIL_OPTIONS = 'EMAIL_OPTIONS';
5
+ exports.EMAIL_PROVIDER = 'EMAIL_PROVIDER';
6
+ exports.EMAIL_SERVICE = 'EMAIL_SERVICE';
@@ -0,0 +1,5 @@
1
+ import { EmailModuleOptions, EmailModuleOptionsWithoutProvider } from "./email.module";
2
+ import { EmailProvider } from "./email.provider";
3
+ export declare class EmailProviderFactory {
4
+ static createProvider(options: EmailModuleOptions | EmailModuleOptionsWithoutProvider): EmailProvider;
5
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailProviderFactory = void 0;
4
+ const email_provider_1 = require("./email.provider");
5
+ class EmailProviderFactory {
6
+ static createProvider(options) {
7
+ const { option: emailOption } = options;
8
+ const { type } = emailOption;
9
+ switch (type) {
10
+ case "smtp":
11
+ return new email_provider_1.SmtpEmailProvider(emailOption["options"]);
12
+ default:
13
+ throw new Error(`Invalid emailOption.type ${type}`);
14
+ }
15
+ }
16
+ }
17
+ exports.EmailProviderFactory = EmailProviderFactory;
@@ -0,0 +1,23 @@
1
+ import { Type } from "@nestjs/common";
2
+ import { EmailProvider } from "./email.provider";
3
+ export type EmailOption = SmtpOption | CustomEmailOption;
4
+ export type SmtpOption = {
5
+ type: "smtp";
6
+ options: SmtpHostOption | SmtpUriOption;
7
+ };
8
+ export type CustomEmailOption = {
9
+ type: "custom";
10
+ provider: Type<EmailProvider>;
11
+ };
12
+ export interface SmtpHostOption {
13
+ host: string;
14
+ port: string;
15
+ secure: boolean;
16
+ from: string;
17
+ username: string;
18
+ password: string;
19
+ }
20
+ export interface SmtpUriOption {
21
+ url: string;
22
+ from: string;
23
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,24 @@
1
+ import { DynamicModule, ModuleMetadata, Type } from '@nestjs/common';
2
+ import { EmailOption } from './email.interface';
3
+ export declare class EmailModule {
4
+ static forRoot(options: EmailModuleOptions): DynamicModule;
5
+ static forRootAsync(options: EmailModuleAsyncOptions): DynamicModule;
6
+ private static santitizeOptions;
7
+ private static createEmailProvider;
8
+ private static createAsyncOptionsProviders;
9
+ private static createAsyncOptionsProvider;
10
+ }
11
+ export type EmailModuleOptionsWithoutProvider = Omit<EmailModuleOptions, 'emailProvider'>;
12
+ export interface EmailModuleOptions {
13
+ option: EmailOption;
14
+ }
15
+ export interface EmailModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
16
+ name?: string;
17
+ useExisting?: Type<EmailModuleOptionsFactory>;
18
+ useClass?: Type<EmailModuleOptionsFactory>;
19
+ useFactory?: (...args: any[]) => Promise<EmailModuleOptionsWithoutProvider> | EmailModuleOptionsWithoutProvider;
20
+ inject?: any[];
21
+ }
22
+ export interface EmailModuleOptionsFactory {
23
+ createOptions(): EmailModuleOptionsWithoutProvider | Promise<EmailModuleOptionsWithoutProvider>;
24
+ }
@@ -0,0 +1,95 @@
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 EmailModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.EmailModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const email_service_1 = require("./email.service");
13
+ const constant_1 = require("./constant");
14
+ const email_provider_factory_1 = require("./email-provider.factory");
15
+ let EmailModule = EmailModule_1 = class EmailModule {
16
+ static forRoot(options) {
17
+ options = this.santitizeOptions(options);
18
+ const emailProvider = this.createEmailProvider(options);
19
+ const emailOptions = {
20
+ provide: constant_1.EMAIL_OPTIONS,
21
+ useValue: options,
22
+ };
23
+ const emailService = {
24
+ provide: email_service_1.EmailService,
25
+ useClass: email_service_1.EmailService,
26
+ };
27
+ return {
28
+ module: EmailModule_1,
29
+ providers: [emailOptions, emailProvider, emailService],
30
+ exports: [constant_1.EMAIL_OPTIONS, emailService],
31
+ };
32
+ }
33
+ static forRootAsync(options) {
34
+ options = this.santitizeOptions(options);
35
+ const asyncOptionsProviders = this.createAsyncOptionsProviders(options);
36
+ const emailProvider = this.createEmailProvider(options);
37
+ const emailService = {
38
+ provide: constant_1.EMAIL_SERVICE,
39
+ useClass: email_service_1.EmailService,
40
+ };
41
+ return {
42
+ module: EmailModule_1,
43
+ imports: options.imports || [],
44
+ providers: [...asyncOptionsProviders, emailProvider, emailService],
45
+ exports: [constant_1.EMAIL_OPTIONS, constant_1.EMAIL_SERVICE],
46
+ };
47
+ }
48
+ static santitizeOptions(options) {
49
+ return options;
50
+ }
51
+ static createEmailProvider(options) {
52
+ return {
53
+ provide: constant_1.EMAIL_PROVIDER,
54
+ useFactory: (moduleOption) => {
55
+ if (moduleOption.option.type == "custom") {
56
+ return moduleOption.option.provider;
57
+ }
58
+ return email_provider_factory_1.EmailProviderFactory.createProvider(moduleOption);
59
+ },
60
+ inject: [constant_1.EMAIL_OPTIONS],
61
+ };
62
+ }
63
+ static createAsyncOptionsProviders(options) {
64
+ if (options.useExisting || options.useFactory) {
65
+ return [this.createAsyncOptionsProvider(options)];
66
+ }
67
+ return [
68
+ this.createAsyncOptionsProvider(options),
69
+ {
70
+ provide: options.useClass,
71
+ useClass: options.useClass,
72
+ },
73
+ ];
74
+ }
75
+ static createAsyncOptionsProvider(options) {
76
+ if (options.useFactory) {
77
+ return {
78
+ provide: constant_1.EMAIL_OPTIONS,
79
+ useFactory: async (...args) => {
80
+ return this.santitizeOptions((await options.useFactory(...args)));
81
+ },
82
+ inject: options.inject || [],
83
+ };
84
+ }
85
+ return {
86
+ provide: constant_1.EMAIL_OPTIONS,
87
+ useFactory: async (optionsFactory) => this.santitizeOptions((await optionsFactory.createOptions())),
88
+ inject: [options.useClass || options.useExisting],
89
+ };
90
+ }
91
+ };
92
+ EmailModule = EmailModule_1 = __decorate([
93
+ (0, common_1.Module)({})
94
+ ], EmailModule);
95
+ exports.EmailModule = EmailModule;
@@ -0,0 +1,19 @@
1
+ import { EmailMessage } from "../interface";
2
+ import { SendResult } from "../interface/result.interface";
3
+ import { SmtpOption } from "./email.interface";
4
+ export interface IEmailProvider {
5
+ send(message: EmailMessage): Promise<SendResult>;
6
+ }
7
+ export declare abstract class EmailProvider implements IEmailProvider {
8
+ abstract send(message: EmailMessage): Promise<SendResult>;
9
+ }
10
+ export declare class SmtpEmailProvider extends EmailProvider {
11
+ private readonly option;
12
+ private readonly logger;
13
+ private readonly transporter;
14
+ constructor(option: SmtpOption["options"]);
15
+ send(message: EmailMessage): Promise<SendResult>;
16
+ private createSmtpOptions;
17
+ private isSmtpUriOption;
18
+ private createMailOption;
19
+ }
@@ -0,0 +1,87 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.SmtpEmailProvider = exports.EmailProvider = void 0;
27
+ const common_1 = require("@nestjs/common");
28
+ const nodemailer = __importStar(require("nodemailer"));
29
+ class EmailProvider {
30
+ }
31
+ exports.EmailProvider = EmailProvider;
32
+ class SmtpEmailProvider extends EmailProvider {
33
+ constructor(option) {
34
+ super();
35
+ this.option = option;
36
+ this.logger = new common_1.Logger(SmtpEmailProvider.name);
37
+ this.transporter = nodemailer.createTransport(this.createSmtpOptions());
38
+ }
39
+ async send(message) {
40
+ try {
41
+ const result = await this.transporter
42
+ .sendMail(this.createMailOption(message));
43
+ this.logger.log(`email sent. response: ${result.response}`);
44
+ const { messageId } = result.response;
45
+ return {
46
+ success: true,
47
+ requestId: result.messageId || messageId,
48
+ };
49
+ }
50
+ catch (err) {
51
+ this.logger.error(`email failed to send. `, err);
52
+ return {
53
+ success: false,
54
+ message: JSON.stringify(err),
55
+ };
56
+ }
57
+ }
58
+ createSmtpOptions() {
59
+ if (this.isSmtpUriOption(this.option)) {
60
+ return this.option.url;
61
+ }
62
+ const { host, port, secure, username, password } = this.option;
63
+ return {
64
+ host,
65
+ port: parseInt(port),
66
+ secure,
67
+ auth: {
68
+ user: username,
69
+ pass: password,
70
+ },
71
+ };
72
+ }
73
+ isSmtpUriOption(object) {
74
+ return "url" in object;
75
+ }
76
+ createMailOption(emailMessage) {
77
+ const { from } = this.option;
78
+ const { recipient, subject, message } = emailMessage;
79
+ return {
80
+ from,
81
+ to: recipient,
82
+ subject: subject,
83
+ html: message,
84
+ };
85
+ }
86
+ }
87
+ exports.SmtpEmailProvider = SmtpEmailProvider;
@@ -0,0 +1,8 @@
1
+ import { EmailProvider } from './email.provider';
2
+ import { EmailMessage } from '../interface';
3
+ export declare class EmailService {
4
+ private readonly emailProvider;
5
+ private readonly logger;
6
+ constructor(emailProvider: EmailProvider);
7
+ send(message: EmailMessage): Promise<import("../interface/result.interface").SendResult>;
8
+ }
@@ -0,0 +1,34 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var EmailService_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.EmailService = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const email_provider_1 = require("./email.provider");
19
+ const constant_1 = require("./constant");
20
+ let EmailService = EmailService_1 = class EmailService {
21
+ constructor(emailProvider) {
22
+ this.emailProvider = emailProvider;
23
+ this.logger = new common_1.Logger(EmailService_1.name);
24
+ }
25
+ send(message) {
26
+ return this.emailProvider.send(message);
27
+ }
28
+ };
29
+ EmailService = EmailService_1 = __decorate([
30
+ (0, common_1.Injectable)(),
31
+ __param(0, (0, common_1.Inject)(constant_1.EMAIL_PROVIDER)),
32
+ __metadata("design:paramtypes", [email_provider_1.EmailProvider])
33
+ ], EmailService);
34
+ exports.EmailService = EmailService;
@@ -0,0 +1,7 @@
1
+ import { EMAIL_OPTIONS, EMAIL_PROVIDER, EMAIL_SERVICE } from "./constant";
2
+ import { EmailProviderFactory } from "./email-provider.factory";
3
+ import { EmailOption, SmtpOption, SmtpHostOption, SmtpUriOption, CustomEmailOption } from "./email.interface";
4
+ import { EmailModule, EmailModuleOptionsWithoutProvider, EmailModuleOptions, EmailModuleAsyncOptions, EmailModuleOptionsFactory } from "./email.module";
5
+ import { EmailProvider, SmtpEmailProvider } from "./email.provider";
6
+ import { EmailService } from "./email.service";
7
+ export { EMAIL_OPTIONS, EMAIL_PROVIDER, EMAIL_SERVICE, EmailOption, SmtpOption, SmtpHostOption, SmtpUriOption, CustomEmailOption, EmailModule, EmailModuleOptionsWithoutProvider, EmailModuleOptions, EmailModuleAsyncOptions, EmailModuleOptionsFactory, EmailService, EmailProvider, SmtpEmailProvider, EmailProviderFactory, };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailProviderFactory = exports.SmtpEmailProvider = exports.EmailProvider = exports.EmailService = exports.EmailModule = exports.EMAIL_SERVICE = exports.EMAIL_PROVIDER = exports.EMAIL_OPTIONS = void 0;
4
+ const constant_1 = require("./constant");
5
+ Object.defineProperty(exports, "EMAIL_OPTIONS", { enumerable: true, get: function () { return constant_1.EMAIL_OPTIONS; } });
6
+ Object.defineProperty(exports, "EMAIL_PROVIDER", { enumerable: true, get: function () { return constant_1.EMAIL_PROVIDER; } });
7
+ Object.defineProperty(exports, "EMAIL_SERVICE", { enumerable: true, get: function () { return constant_1.EMAIL_SERVICE; } });
8
+ const email_provider_factory_1 = require("./email-provider.factory");
9
+ Object.defineProperty(exports, "EmailProviderFactory", { enumerable: true, get: function () { return email_provider_factory_1.EmailProviderFactory; } });
10
+ const email_module_1 = require("./email.module");
11
+ Object.defineProperty(exports, "EmailModule", { enumerable: true, get: function () { return email_module_1.EmailModule; } });
12
+ const email_provider_1 = require("./email.provider");
13
+ Object.defineProperty(exports, "EmailProvider", { enumerable: true, get: function () { return email_provider_1.EmailProvider; } });
14
+ Object.defineProperty(exports, "SmtpEmailProvider", { enumerable: true, get: function () { return email_provider_1.SmtpEmailProvider; } });
15
+ const email_service_1 = require("./email.service");
16
+ Object.defineProperty(exports, "EmailService", { enumerable: true, get: function () { return email_service_1.EmailService; } });
@@ -0,0 +1,5 @@
1
+ export * from "./email";
2
+ export * from "./interface";
3
+ export * from "./notification";
4
+ export * from "./sms";
5
+ export * from "./template";
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
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("./email"), exports);
18
+ __exportStar(require("./interface"), exports);
19
+ __exportStar(require("./notification"), exports);
20
+ __exportStar(require("./sms"), exports);
21
+ __exportStar(require("./template"), exports);
@@ -0,0 +1,2 @@
1
+ import { BaseMessage, SmsMessage, EmailMessage, PushMessage, Message } from "./message.interface";
2
+ export { BaseMessage, SmsMessage, EmailMessage, PushMessage, Message, };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ export interface BaseMessage {
2
+ recipient: string;
3
+ message: string;
4
+ }
5
+ export interface SmsMessage extends BaseMessage {
6
+ countryIso2?: string;
7
+ dialCode?: string;
8
+ }
9
+ export interface EmailMessage extends BaseMessage {
10
+ subject: string;
11
+ }
12
+ export interface PushMessage extends BaseMessage {
13
+ subject: string;
14
+ }
15
+ export type Message = SmsMessage | EmailMessage | PushMessage;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export interface SendResult {
2
+ success: boolean;
3
+ message?: string;
4
+ requestId?: string;
5
+ extra?: any;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export declare const NOTIFICATION_OPTIONS = "NOTIFICATION_OPTIONS";
2
+ export declare const NOTIFICATION_SERVICE = "NOTIFICATION_SERVICE";
3
+ export declare const TEMPLATE_SERVICE = "TEMPLATE_SERVICE";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEMPLATE_SERVICE = exports.NOTIFICATION_SERVICE = exports.NOTIFICATION_OPTIONS = void 0;
4
+ exports.NOTIFICATION_OPTIONS = "NOTIFICATION_OPTIONS";
5
+ exports.NOTIFICATION_SERVICE = "NOTIFICATION_SERVICE";
6
+ exports.TEMPLATE_SERVICE = "TEMPLATE_SERVICE";
@@ -0,0 +1,4 @@
1
+ import { NOTIFICATION_OPTIONS, NOTIFICATION_SERVICE, TEMPLATE_SERVICE } from "./constant";
2
+ import { NotificationModule, NotificationModuleAsyncOptions, NotificationModuleOptions, NotificationModuleOptionsFactory } from "./notification.module";
3
+ import { NotificationService } from "./notification.service";
4
+ export { NOTIFICATION_OPTIONS, NOTIFICATION_SERVICE, TEMPLATE_SERVICE, NotificationModule, NotificationModuleOptions, NotificationModuleAsyncOptions, NotificationModuleOptionsFactory, NotificationService, };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationService = exports.NotificationModule = exports.TEMPLATE_SERVICE = exports.NOTIFICATION_SERVICE = exports.NOTIFICATION_OPTIONS = void 0;
4
+ const constant_1 = require("./constant");
5
+ Object.defineProperty(exports, "NOTIFICATION_OPTIONS", { enumerable: true, get: function () { return constant_1.NOTIFICATION_OPTIONS; } });
6
+ Object.defineProperty(exports, "NOTIFICATION_SERVICE", { enumerable: true, get: function () { return constant_1.NOTIFICATION_SERVICE; } });
7
+ Object.defineProperty(exports, "TEMPLATE_SERVICE", { enumerable: true, get: function () { return constant_1.TEMPLATE_SERVICE; } });
8
+ const notification_module_1 = require("./notification.module");
9
+ Object.defineProperty(exports, "NotificationModule", { enumerable: true, get: function () { return notification_module_1.NotificationModule; } });
10
+ const notification_service_1 = require("./notification.service");
11
+ Object.defineProperty(exports, "NotificationService", { enumerable: true, get: function () { return notification_service_1.NotificationService; } });
@@ -0,0 +1,23 @@
1
+ import { DynamicModule, ModuleMetadata, Type } from '@nestjs/common';
2
+ import { EmailModuleOptions } from '../email';
3
+ import { TemplateLoader } from '../template';
4
+ export declare class NotificationModule {
5
+ static forRoot(options: NotificationModuleOptions): DynamicModule;
6
+ private static santitizeOptions;
7
+ private static createAsyncOptionsProviders;
8
+ private static createAsyncOptionsProvider;
9
+ }
10
+ export interface NotificationModuleOptions {
11
+ emailOptions?: EmailModuleOptions;
12
+ templateLoader: Type<TemplateLoader>;
13
+ }
14
+ export interface NotificationModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
15
+ name?: string;
16
+ useExisting?: Type<NotificationModuleOptionsFactory>;
17
+ useClass?: Type<NotificationModuleOptionsFactory>;
18
+ useFactory?: (...args: any[]) => Promise<NotificationModuleOptions> | NotificationModuleOptions;
19
+ inject?: any[];
20
+ }
21
+ export interface NotificationModuleOptionsFactory {
22
+ createOptions(): NotificationModuleOptions | Promise<NotificationModuleOptions>;
23
+ }
@@ -0,0 +1,83 @@
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 NotificationModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.NotificationModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const email_1 = require("../email");
13
+ const constant_1 = require("./constant");
14
+ const template_1 = require("../template");
15
+ const template_service_1 = require("../template/template.service");
16
+ const notification_service_1 = require("./notification.service");
17
+ let NotificationModule = NotificationModule_1 = class NotificationModule {
18
+ static forRoot(options) {
19
+ options = this.santitizeOptions(options);
20
+ const modules = [];
21
+ const { emailOptions } = options;
22
+ if (emailOptions) {
23
+ modules.push(email_1.EmailModule.forRoot(emailOptions));
24
+ }
25
+ const moduleOptions = {
26
+ provide: constant_1.NOTIFICATION_OPTIONS,
27
+ useValue: options,
28
+ };
29
+ const templateLoader = {
30
+ provide: template_1.TEMPLATE_LOADER,
31
+ useClass: options.templateLoader || template_1.FakeTemplateLoader,
32
+ };
33
+ const templateService = {
34
+ provide: template_service_1.TemplateService,
35
+ useClass: template_service_1.TemplateService
36
+ };
37
+ const notificationService = {
38
+ provide: notification_service_1.NotificationService,
39
+ useClass: notification_service_1.NotificationService,
40
+ };
41
+ return {
42
+ module: NotificationModule_1,
43
+ imports: [...modules],
44
+ providers: [moduleOptions, templateLoader, templateService, notificationService],
45
+ exports: [...modules, constant_1.NOTIFICATION_OPTIONS, template_1.TEMPLATE_LOADER, templateService, notificationService],
46
+ };
47
+ }
48
+ static santitizeOptions(options) {
49
+ return options;
50
+ }
51
+ static createAsyncOptionsProviders(options) {
52
+ if (options.useExisting || options.useFactory) {
53
+ return [this.createAsyncOptionsProvider(options)];
54
+ }
55
+ return [
56
+ this.createAsyncOptionsProvider(options),
57
+ {
58
+ provide: options.useClass,
59
+ useClass: options.useClass,
60
+ },
61
+ ];
62
+ }
63
+ static createAsyncOptionsProvider(options) {
64
+ if (options.useFactory) {
65
+ return {
66
+ provide: constant_1.NOTIFICATION_OPTIONS,
67
+ useFactory: async (...args) => {
68
+ return this.santitizeOptions((await options.useFactory(...args)));
69
+ },
70
+ inject: options.inject || [],
71
+ };
72
+ }
73
+ return {
74
+ provide: constant_1.NOTIFICATION_OPTIONS,
75
+ useFactory: async (optionsFactory) => this.santitizeOptions((await optionsFactory.createOptions())),
76
+ inject: [options.useClass || options.useExisting],
77
+ };
78
+ }
79
+ };
80
+ NotificationModule = NotificationModule_1 = __decorate([
81
+ (0, common_1.Module)({})
82
+ ], NotificationModule);
83
+ exports.NotificationModule = NotificationModule;
@@ -0,0 +1,10 @@
1
+ import { ResolveOption, TemplateLoader } from "../template";
2
+ import { EmailService } from "../email";
3
+ import { SendResult } from "../interface/result.interface";
4
+ export declare class NotificationService {
5
+ private readonly templateLoader;
6
+ private readonly emailService;
7
+ private readonly logger;
8
+ constructor(templateLoader: TemplateLoader, emailService: EmailService);
9
+ sendEmail(templateCode: string, email: string, resolveOption: ResolveOption): Promise<SendResult>;
10
+ }
@@ -0,0 +1,49 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.NotificationService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const template_1 = require("../template");
18
+ const email_1 = require("../email");
19
+ let NotificationService = class NotificationService {
20
+ constructor(templateLoader, emailService) {
21
+ this.templateLoader = templateLoader;
22
+ this.emailService = emailService;
23
+ this.logger = new common_1.Logger(NotificationService.name);
24
+ }
25
+ async sendEmail(templateCode, email, resolveOption) {
26
+ if (!this.emailService) {
27
+ this.logger.error("Email Service is load configure..please configure the email option");
28
+ return null;
29
+ }
30
+ const templateMessage = await this.templateLoader.resolve(templateCode, resolveOption);
31
+ if (!templateMessage) {
32
+ this.logger.error(`Template ${templateCode} Load Failed. Please make sure the template has set`);
33
+ return null;
34
+ }
35
+ return this.emailService.send({
36
+ recipient: email,
37
+ subject: templateMessage.subject || "",
38
+ message: templateMessage.content,
39
+ });
40
+ }
41
+ };
42
+ NotificationService = __decorate([
43
+ __param(0, (0, common_1.Inject)(template_1.TEMPLATE_LOADER)),
44
+ __param(1, (0, common_1.Optional)()),
45
+ __param(1, (0, common_1.Inject)(email_1.EmailService)),
46
+ __metadata("design:paramtypes", [template_1.TemplateLoader,
47
+ email_1.EmailService])
48
+ ], NotificationService);
49
+ exports.NotificationService = NotificationService;
@@ -0,0 +1,2 @@
1
+ import { SmsService } from "./sms.service";
2
+ export { SmsService };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmsService = void 0;
4
+ const sms_service_1 = require("./sms.service");
5
+ Object.defineProperty(exports, "SmsService", { enumerable: true, get: function () { return sms_service_1.SmsService; } });
@@ -0,0 +1,8 @@
1
+ import { Message } from "../interface";
2
+ import { SendResult } from "../interface/result.interface";
3
+ export interface ISmsService {
4
+ send(message: Message): Promise<SendResult>;
5
+ }
6
+ export declare abstract class SmsService implements ISmsService {
7
+ abstract send(message: Message): Promise<SendResult>;
8
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmsService = void 0;
4
+ class SmsService {
5
+ }
6
+ exports.SmsService = SmsService;
@@ -0,0 +1 @@
1
+ export declare const TEMPLATE_LOADER = "TEMPLATE_LOADER";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEMPLATE_LOADER = void 0;
4
+ exports.TEMPLATE_LOADER = "TEMPLATE_LOADER";
@@ -0,0 +1,6 @@
1
+ import { MessageTemplate, TemplateLoader } from "./template.loader";
2
+ export declare class FakeTemplateLoader extends TemplateLoader {
3
+ private readonly logger;
4
+ constructor();
5
+ getTemplate(templateCode: string, locale: string, fallbackLocale?: string): Promise<MessageTemplate>;
6
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FakeTemplateLoader = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const template_loader_1 = require("./template.loader");
6
+ class FakeTemplateLoader extends template_loader_1.TemplateLoader {
7
+ constructor() {
8
+ super();
9
+ this.logger = new common_1.Logger(FakeTemplateLoader.name);
10
+ this.logger.warn("this is a fake template loader. is mainly for testing purposes only. please make sure you are using it correctly");
11
+ }
12
+ getTemplate(templateCode, locale, fallbackLocale) {
13
+ return new Promise((resolve, reject) => {
14
+ resolve({
15
+ code: templateCode,
16
+ content: `${templateCode} content`,
17
+ subject: `${templateCode} subject`,
18
+ locale,
19
+ });
20
+ });
21
+ }
22
+ }
23
+ exports.FakeTemplateLoader = FakeTemplateLoader;
@@ -0,0 +1,5 @@
1
+ import { TEMPLATE_LOADER } from "./constant";
2
+ import { FakeTemplateLoader } from "./fake-template.loader";
3
+ import { CacheOptions, MessageTemplate, ResolveOption, TemplateLoader, CachableTemplateLoader } from "./template.loader";
4
+ import { TemplateService } from "./template.service";
5
+ export { CacheOptions, MessageTemplate, ResolveOption, TemplateLoader, CachableTemplateLoader, TEMPLATE_LOADER, TemplateService, FakeTemplateLoader, };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FakeTemplateLoader = exports.TemplateService = exports.TEMPLATE_LOADER = exports.CachableTemplateLoader = exports.TemplateLoader = exports.MessageTemplate = void 0;
4
+ const constant_1 = require("./constant");
5
+ Object.defineProperty(exports, "TEMPLATE_LOADER", { enumerable: true, get: function () { return constant_1.TEMPLATE_LOADER; } });
6
+ const fake_template_loader_1 = require("./fake-template.loader");
7
+ Object.defineProperty(exports, "FakeTemplateLoader", { enumerable: true, get: function () { return fake_template_loader_1.FakeTemplateLoader; } });
8
+ const template_loader_1 = require("./template.loader");
9
+ Object.defineProperty(exports, "MessageTemplate", { enumerable: true, get: function () { return template_loader_1.MessageTemplate; } });
10
+ Object.defineProperty(exports, "TemplateLoader", { enumerable: true, get: function () { return template_loader_1.TemplateLoader; } });
11
+ Object.defineProperty(exports, "CachableTemplateLoader", { enumerable: true, get: function () { return template_loader_1.CachableTemplateLoader; } });
12
+ const template_service_1 = require("./template.service");
13
+ Object.defineProperty(exports, "TemplateService", { enumerable: true, get: function () { return template_service_1.TemplateService; } });
@@ -0,0 +1,29 @@
1
+ import { Cache } from "cache-manager";
2
+ export interface CacheOptions {
3
+ cacheKey: string;
4
+ ttl: number;
5
+ }
6
+ export declare class MessageTemplate {
7
+ code: string;
8
+ locale?: string;
9
+ subject?: string;
10
+ content: string;
11
+ }
12
+ export interface ResolveOption {
13
+ locale?: string;
14
+ fallbackLocale?: string;
15
+ args?: Array<({
16
+ [k: string]: any;
17
+ } | string)>;
18
+ }
19
+ export declare abstract class TemplateLoader {
20
+ abstract getTemplate(templateCode: string, locale: string, fallbackLocale?: string): Promise<MessageTemplate>;
21
+ resolve(templateCode: string, options?: ResolveOption): Promise<MessageTemplate>;
22
+ }
23
+ export declare abstract class CachableTemplateLoader extends TemplateLoader {
24
+ private cacheManager;
25
+ private readonly cacheOptions;
26
+ constructor(cacheManager: Cache, cacheOptions?: CacheOptions);
27
+ resolve(templateCode: string, options?: ResolveOption): Promise<MessageTemplate>;
28
+ protected getTemplateCacheKey(templateCode: string, locale: string): string;
29
+ }
@@ -0,0 +1,78 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CachableTemplateLoader = exports.TemplateLoader = exports.MessageTemplate = void 0;
19
+ const string_format_1 = __importDefault(require("string-format"));
20
+ const cache_manager_1 = require("@nestjs/cache-manager");
21
+ const common_1 = require("@nestjs/common");
22
+ const DEFAULT_EXPIRATION_MS = 10 * 60 * 1000;
23
+ const DEFAULT_CACHE_KEY = "MESSAGE_TEMPLATE_CACHE.";
24
+ class MessageTemplate {
25
+ }
26
+ exports.MessageTemplate = MessageTemplate;
27
+ class TemplateLoader {
28
+ async resolve(templateCode, options = {}) {
29
+ const { fallbackLocale, args, locale } = options;
30
+ const unresolveTemplate = await this.getTemplate(templateCode, locale, fallbackLocale);
31
+ const { subject, content } = unresolveTemplate;
32
+ return {
33
+ ...unresolveTemplate,
34
+ subject: subject && (0, string_format_1.default)(subject, args),
35
+ content: content && (0, string_format_1.default)(content, args),
36
+ };
37
+ }
38
+ }
39
+ exports.TemplateLoader = TemplateLoader;
40
+ let CachableTemplateLoader = class CachableTemplateLoader extends TemplateLoader {
41
+ constructor(cacheManager, cacheOptions) {
42
+ super();
43
+ this.cacheManager = cacheManager;
44
+ this.cacheOptions = Object.assign({
45
+ cacheKey: DEFAULT_CACHE_KEY,
46
+ ttl: DEFAULT_EXPIRATION_MS,
47
+ }, cacheOptions);
48
+ }
49
+ async resolve(templateCode, options = {}) {
50
+ const { fallbackLocale, args, locale } = options;
51
+ const { ttl } = this.cacheOptions;
52
+ const TEMPLATE_CACHE_KEY = this.getTemplateCacheKey(templateCode, locale);
53
+ const cachedItem = await this.cacheManager.get(TEMPLATE_CACHE_KEY);
54
+ let unresolveTemplate;
55
+ if (cachedItem) {
56
+ unresolveTemplate = cachedItem;
57
+ }
58
+ else {
59
+ unresolveTemplate = await this.getTemplate(templateCode, locale, fallbackLocale);
60
+ await this.cacheManager.set(TEMPLATE_CACHE_KEY, unresolveTemplate, ttl);
61
+ }
62
+ const { subject, content } = unresolveTemplate;
63
+ return {
64
+ ...unresolveTemplate,
65
+ subject: subject && (0, string_format_1.default)(subject, args),
66
+ content: content && (0, string_format_1.default)(content, args),
67
+ };
68
+ }
69
+ getTemplateCacheKey(templateCode, locale) {
70
+ const { cacheKey, ttl } = this.cacheOptions;
71
+ return `${cacheKey}.${templateCode}.${locale}`;
72
+ }
73
+ };
74
+ CachableTemplateLoader = __decorate([
75
+ __param(0, (0, common_1.Inject)(cache_manager_1.CACHE_MANAGER)),
76
+ __metadata("design:paramtypes", [Object, Object])
77
+ ], CachableTemplateLoader);
78
+ exports.CachableTemplateLoader = CachableTemplateLoader;
@@ -0,0 +1,6 @@
1
+ import { MessageTemplate, ResolveOption, TemplateLoader } from "./template.loader";
2
+ export declare class TemplateService {
3
+ private readonly templateLoader;
4
+ constructor(templateLoader: TemplateLoader);
5
+ resolveTemplate(code: string, options?: ResolveOption): Promise<MessageTemplate>;
6
+ }
@@ -0,0 +1,32 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.TemplateService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const template_loader_1 = require("./template.loader");
18
+ const constant_1 = require("./constant");
19
+ let TemplateService = class TemplateService {
20
+ constructor(templateLoader) {
21
+ this.templateLoader = templateLoader;
22
+ }
23
+ resolveTemplate(code, options = {}) {
24
+ return this.templateLoader.resolve(code, options);
25
+ }
26
+ };
27
+ TemplateService = __decorate([
28
+ (0, common_1.Injectable)(),
29
+ __param(0, (0, common_1.Inject)(constant_1.TEMPLATE_LOADER)),
30
+ __metadata("design:paramtypes", [template_loader_1.TemplateLoader])
31
+ ], TemplateService);
32
+ exports.TemplateService = TemplateService;
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./dist";
package/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ function __export(m) {
3
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
+ }
5
+ exports.__esModule = true;
6
+ __export(require("./dist"));
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@nathapp/nestjs-notification",
3
+ "version": "1.0.0-rc.5",
4
+ "description": "Notification Module",
5
+ "scripts": {
6
+ "build": "rimraf dist && tsc -p tsconfig.json",
7
+ "precommit": "lint-staged",
8
+ "test": "jest --config ./test/jest-test.json",
9
+ "test:cov": "jest --config ./test/jest-test.json --coverage",
10
+ "test:watch": "jest --config ./test/jest-test.json --watch",
11
+ "lint": "eslint -c .eslintrc.js"
12
+ },
13
+ "author": "William Khoo",
14
+ "license": "ISC",
15
+ "engines": {
16
+ "node": ">=16"
17
+ },
18
+ "devDependencies": {
19
+ "@golevelup/ts-jest": "^0.3.7",
20
+ "@nestjs/platform-express": "^10.0.0",
21
+ "@nestjs/testing": "^10.0.0",
22
+ "@types/jest": "^29.5.2",
23
+ "@types/node": "^17.0.22",
24
+ "@types/nodemailer": "^6.4.11",
25
+ "@types/string-format": "^2.0.1",
26
+ "@types/supertest": "^2.0.12",
27
+ "@typescript-eslint/eslint-plugin": "^4",
28
+ "@typescript-eslint/parser": "^4",
29
+ "eslint": "*",
30
+ "eslint-config-prettier": "^6",
31
+ "eslint-plugin-prettier": "^3",
32
+ "jest": "^29.5.0",
33
+ "prettier": "^2",
34
+ "supertest": "^6.3.3",
35
+ "ts-jest": "^29.1.0",
36
+ "typescript": "^4"
37
+ },
38
+ "types": "./index.d.ts",
39
+ "main": "index.js",
40
+ "directories": {
41
+ "lib": "lib"
42
+ },
43
+ "dependencies": {
44
+ "nodemailer": "^6.9.6",
45
+ "string-format": "^2.0.0"
46
+ },
47
+ "peerDependencies": {
48
+ "@nestjs/cache-manager": "^2.1.0",
49
+ "@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0",
50
+ "@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0",
51
+ "cache-manager": "^5.0.0",
52
+ "class-transformer": "*",
53
+ "class-validator": "*",
54
+ "rxjs": "*"
55
+ }
56
+ }