@nathapp/nestjs-notification 2.1.1 → 2.2.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.
Files changed (57) hide show
  1. package/UPGRADE-PLAN-PHASE7-8.md +307 -0
  2. package/UPGRADE-PLAN-PHASE9.md +361 -0
  3. package/UPGRADE-PLAN.md +425 -0
  4. package/dist/index.d.ts +3 -2
  5. package/dist/index.js +20 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/interface/index.d.ts +3 -3
  8. package/dist/interface/message.interface.d.ts +10 -2
  9. package/dist/interface/payload.inteface.d.ts +51 -0
  10. package/dist/notification/errors.d.ts +3 -0
  11. package/dist/notification/errors.js +11 -0
  12. package/dist/notification/errors.js.map +1 -0
  13. package/dist/notification/index.d.ts +6 -2
  14. package/dist/notification/index.js +7 -1
  15. package/dist/notification/index.js.map +1 -1
  16. package/dist/notification/notification-provider.factory.d.ts +5 -0
  17. package/dist/notification/notification-provider.factory.js +33 -0
  18. package/dist/notification/notification-provider.factory.js.map +1 -0
  19. package/dist/notification/notification.interceptor.d.ts +18 -0
  20. package/dist/notification/notification.interceptor.js +5 -0
  21. package/dist/notification/notification.interceptor.js.map +1 -0
  22. package/dist/notification/notification.module.d.ts +28 -18
  23. package/dist/notification/notification.module.js +324 -63
  24. package/dist/notification/notification.module.js.map +1 -1
  25. package/dist/notification/notification.service.d.ts +18 -2
  26. package/dist/notification/notification.service.js +274 -13
  27. package/dist/notification/notification.service.js.map +1 -1
  28. package/dist/notification/provider-config.d.ts +17 -0
  29. package/dist/notification/provider-config.js +3 -0
  30. package/dist/notification/provider-config.js.map +1 -0
  31. package/dist/push-notification/push-notification.service.js +2 -1
  32. package/dist/push-notification/push-notification.service.js.map +1 -1
  33. package/dist/template/constant.d.ts +1 -0
  34. package/dist/template/constant.js +2 -1
  35. package/dist/template/constant.js.map +1 -1
  36. package/dist/template/engines/string-format.engine.d.ts +6 -0
  37. package/dist/template/engines/string-format.engine.js +17 -0
  38. package/dist/template/engines/string-format.engine.js.map +1 -0
  39. package/dist/template/index.d.ts +4 -2
  40. package/dist/template/index.js +4 -1
  41. package/dist/template/index.js.map +1 -1
  42. package/dist/template/template-engine.d.ts +5 -0
  43. package/dist/template/template-engine.js +3 -0
  44. package/dist/template/template-engine.js.map +1 -0
  45. package/dist/template/template.loader.d.ts +4 -1
  46. package/dist/template/template.loader.js +22 -14
  47. package/dist/template/template.loader.js.map +1 -1
  48. package/dist/whatsapp/constant.d.ts +1 -0
  49. package/dist/whatsapp/constant.js +5 -0
  50. package/dist/whatsapp/constant.js.map +1 -0
  51. package/dist/whatsapp/index.d.ts +2 -0
  52. package/dist/whatsapp/index.js +19 -0
  53. package/dist/whatsapp/index.js.map +1 -0
  54. package/dist/whatsapp/whatsapp.service.d.ts +7 -0
  55. package/dist/whatsapp/whatsapp.service.js +7 -0
  56. package/dist/whatsapp/whatsapp.service.js.map +1 -0
  57. package/package.json +2 -1
@@ -11,35 +11,41 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
- var __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
14
  Object.defineProperty(exports, "__esModule", { value: true });
18
15
  exports.CachableTemplateLoader = exports.TemplateLoader = exports.MessageTemplate = void 0;
19
- const string_format_1 = __importDefault(require("string-format"));
20
16
  const cache_manager_1 = require("@nestjs/cache-manager");
21
17
  const common_1 = require("@nestjs/common");
18
+ const string_format_engine_1 = require("./engines/string-format.engine");
19
+ const constant_1 = require("./constant");
22
20
  const DEFAULT_EXPIRATION_MS = 10 * 60 * 1000;
23
21
  const DEFAULT_CACHE_KEY = "MESSAGE_TEMPLATE_CACHE.";
24
22
  class MessageTemplate {
25
23
  }
26
24
  exports.MessageTemplate = MessageTemplate;
27
- class TemplateLoader {
25
+ let TemplateLoader = class TemplateLoader {
26
+ constructor(engine) {
27
+ this.engine = engine || new string_format_engine_1.StringFormatEngine();
28
+ }
28
29
  async resolve(templateCode, options = {}) {
29
30
  const { fallbackLocale, args, locale } = options;
30
31
  const unresolveTemplate = await this.getTemplate(templateCode, locale, fallbackLocale);
31
32
  const { subject, content } = unresolveTemplate;
32
33
  return {
33
34
  ...unresolveTemplate,
34
- subject: subject && (0, string_format_1.default)(subject, args),
35
- content: content && (0, string_format_1.default)(content, args),
35
+ subject: subject && this.engine.render(subject, args),
36
+ content: content && this.engine.render(content, args),
36
37
  };
37
38
  }
38
- }
39
+ };
39
40
  exports.TemplateLoader = TemplateLoader;
41
+ exports.TemplateLoader = TemplateLoader = __decorate([
42
+ __param(0, (0, common_1.Optional)()),
43
+ __param(0, (0, common_1.Inject)(constant_1.TEMPLATE_ENGINE)),
44
+ __metadata("design:paramtypes", [Object])
45
+ ], TemplateLoader);
40
46
  let CachableTemplateLoader = class CachableTemplateLoader extends TemplateLoader {
41
- constructor(cacheManager, cacheOptions) {
42
- super();
47
+ constructor(cacheManager, cacheOptions, engine) {
48
+ super(engine);
43
49
  this.cacheManager = cacheManager;
44
50
  this.cacheOptions = Object.assign({
45
51
  cacheKey: DEFAULT_CACHE_KEY,
@@ -62,18 +68,20 @@ let CachableTemplateLoader = class CachableTemplateLoader extends TemplateLoader
62
68
  const { subject, content } = unresolveTemplate;
63
69
  return {
64
70
  ...unresolveTemplate,
65
- subject: subject && (0, string_format_1.default)(subject, args),
66
- content: content && (0, string_format_1.default)(content, args),
71
+ subject: subject && this.engine.render(subject, args),
72
+ content: content && this.engine.render(content, args),
67
73
  };
68
74
  }
69
75
  getTemplateCacheKey(templateCode, locale) {
70
- const { cacheKey, ttl } = this.cacheOptions;
76
+ const { cacheKey } = this.cacheOptions;
71
77
  return `${cacheKey}.${templateCode}.${locale}`;
72
78
  }
73
79
  };
74
80
  exports.CachableTemplateLoader = CachableTemplateLoader;
75
81
  exports.CachableTemplateLoader = CachableTemplateLoader = __decorate([
76
82
  __param(0, (0, common_1.Inject)(cache_manager_1.CACHE_MANAGER)),
77
- __metadata("design:paramtypes", [Object, Object])
83
+ __param(2, (0, common_1.Optional)()),
84
+ __param(2, (0, common_1.Inject)(constant_1.TEMPLATE_ENGINE)),
85
+ __metadata("design:paramtypes", [Object, Object, Object])
78
86
  ], CachableTemplateLoader);
79
87
  //# sourceMappingURL=template.loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"template.loader.js","sourceRoot":"","sources":["../../lib/template/template.loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kEAAmC;AACnC,yDAAsD;AACtD,2CAAwC;AAGxC,MAAM,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC7C,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AAQpD,MAAa,eAAe;CAK3B;AALD,0CAKC;AAUD,MAAsB,cAAc;IAIlC,KAAK,CAAC,OAAO,CAAC,YAAoB,EAAE,UAAyB,EAAE;QAC7D,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QACjD,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;QACvF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC;QAC/C,OAAO;YACL,GAAG,iBAAiB;YACpB,OAAO,EAAE,OAAO,IAAI,IAAA,uBAAM,EAAC,OAAO,EAAE,IAAI,CAAC;YACzC,OAAO,EAAE,OAAO,IAAI,IAAA,uBAAM,EAAC,OAAO,EAAE,IAAI,CAAC;SAC1C,CAAA;IACH,CAAC;CACF;AAdD,wCAcC;AAED,IAAsB,sBAAsB,GAA5C,MAAsB,sBAAuB,SAAQ,cAAc;IAIjE,YAA2C,YAAmB,EAAE,YAA2B;QACzF,KAAK,EAAE,CAAC;QADiC,iBAAY,GAAZ,YAAY,CAAO;QAE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,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC;SACtD,CAAA;IACH,CAAC;IAES,mBAAmB,CAAC,YAAoB,EAAE,MAAc;QAChE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;QACxC,OAAO,GAAG,QAAQ,IAAI,YAAY,IAAI,MAAM,EAAE,CAAC;IAChD,CAAC;CAEF,CAAA;AA1CqB,wDAAsB;iCAAtB,sBAAsB;IAKvC,WAAA,IAAA,eAAM,EAAC,6BAAa,CAAC,CAAA;IAErB,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,0BAAe,CAAC,CAAA;;GAPlB,sBAAsB,CA0C3C"}
@@ -0,0 +1 @@
1
+ export declare const WHATSAPP_SERVICE = "WHATSAPP_SERVICE";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WHATSAPP_SERVICE = void 0;
4
+ exports.WHATSAPP_SERVICE = 'WHATSAPP_SERVICE';
5
+ //# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../lib/whatsapp/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './whatsapp.service';
2
+ export * from './constant';
@@ -0,0 +1,19 @@
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("./whatsapp.service"), exports);
18
+ __exportStar(require("./constant"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/whatsapp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,6CAA2B"}
@@ -0,0 +1,7 @@
1
+ import { WhatsAppMessage, SendResult } from '../interface';
2
+ export interface IWhatsAppService {
3
+ send(message: WhatsAppMessage): Promise<SendResult>;
4
+ }
5
+ export declare abstract class WhatsAppService implements IWhatsAppService {
6
+ abstract send(message: WhatsAppMessage): Promise<SendResult>;
7
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WhatsAppService = void 0;
4
+ class WhatsAppService {
5
+ }
6
+ exports.WhatsAppService = WhatsAppService;
7
+ //# sourceMappingURL=whatsapp.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whatsapp.service.js","sourceRoot":"","sources":["../../lib/whatsapp/whatsapp.service.ts"],"names":[],"mappings":";;;AAMA,MAAsB,eAAe;CAEpC;AAFD,0CAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathapp/nestjs-notification",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "Notification Module",
5
5
  "scripts": {
6
6
  "clean": "rimraf dist/ .turbo/",
@@ -20,6 +20,7 @@
20
20
  "@types/nodemailer": "^7.0.3",
21
21
  "@types/string-format": "^2.0.1",
22
22
  "eslint": "^8.57.0",
23
+ "firebase-admin": "^12.1.0",
23
24
  "nodemailer": "^7.0.10",
24
25
  "typescript": "^5"
25
26
  },