@nathapp/nestjs-notification 2.1.4 → 3.0.0-rc.4

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 (123) hide show
  1. package/CLAUDE.md +21 -0
  2. package/UPGRADE-PLAN-PHASE7-8.md +307 -0
  3. package/UPGRADE-PLAN-PHASE9.md +361 -0
  4. package/UPGRADE-PLAN.md +425 -0
  5. package/dist/email/email.interface.d.ts +1 -1
  6. package/dist/email/email.provider.d.ts +2 -2
  7. package/dist/email/email.provider.js +7 -5
  8. package/dist/email/email.provider.js.map +1 -1
  9. package/dist/email/index.d.ts +1 -3
  10. package/dist/email/index.js +1 -6
  11. package/dist/email/index.js.map +1 -1
  12. package/dist/index.d.ts +4 -3
  13. package/dist/index.js +22 -3
  14. package/dist/index.js.map +1 -1
  15. package/dist/interface/index.d.ts +3 -3
  16. package/dist/interface/message.interface.d.ts +11 -4
  17. package/dist/interface/payload.interface.d.ts +71 -0
  18. package/dist/{push-notification/push-notification-module.interface.js → interface/payload.interface.js} +1 -2
  19. package/dist/interface/payload.interface.js.map +1 -0
  20. package/dist/interface/result.interface.d.ts +2 -1
  21. package/dist/notification/errors.d.ts +3 -0
  22. package/dist/notification/errors.js +11 -0
  23. package/dist/notification/errors.js.map +1 -0
  24. package/dist/notification/index.d.ts +6 -2
  25. package/dist/notification/index.js +7 -1
  26. package/dist/notification/index.js.map +1 -1
  27. package/dist/notification/notification-provider.factory.d.ts +5 -0
  28. package/dist/notification/notification-provider.factory.js +33 -0
  29. package/dist/notification/notification-provider.factory.js.map +1 -0
  30. package/dist/notification/notification.interceptor.d.ts +18 -0
  31. package/dist/notification/notification.interceptor.js +5 -0
  32. package/dist/notification/notification.interceptor.js.map +1 -0
  33. package/dist/notification/notification.module.d.ts +29 -19
  34. package/dist/notification/notification.module.js +338 -65
  35. package/dist/notification/notification.module.js.map +1 -1
  36. package/dist/notification/notification.service.d.ts +18 -2
  37. package/dist/notification/notification.service.js +277 -16
  38. package/dist/notification/notification.service.js.map +1 -1
  39. package/dist/notification/provider-config.d.ts +17 -0
  40. package/dist/{interface/payload.inteface.js → notification/provider-config.js} +1 -1
  41. package/dist/notification/provider-config.js.map +1 -0
  42. package/dist/push-notification/fcm-push-notification.provider.d.ts +3 -0
  43. package/dist/push-notification/fcm-push-notification.provider.js +17 -2
  44. package/dist/push-notification/fcm-push-notification.provider.js.map +1 -1
  45. package/dist/push-notification/firebase.interface.d.ts +1 -0
  46. package/dist/push-notification/index.d.ts +1 -4
  47. package/dist/push-notification/index.js +1 -5
  48. package/dist/push-notification/index.js.map +1 -1
  49. package/dist/push-notification/push-notification-provider.manager.d.ts +8 -3
  50. package/dist/push-notification/push-notification-provider.manager.js +12 -3
  51. package/dist/push-notification/push-notification-provider.manager.js.map +1 -1
  52. package/dist/push-notification/push-notification.provider.d.ts +1 -0
  53. package/dist/push-notification/push-notification.provider.js.map +1 -1
  54. package/dist/push-notification/push-notification.service.js +3 -2
  55. package/dist/push-notification/push-notification.service.js.map +1 -1
  56. package/dist/push-notification/user-token.store.js +7 -7
  57. package/dist/push-notification/user-token.store.js.map +1 -1
  58. package/dist/sms/constant.d.ts +1 -0
  59. package/dist/sms/constant.js +5 -0
  60. package/dist/sms/constant.js.map +1 -0
  61. package/dist/sms/index.d.ts +3 -2
  62. package/dist/sms/index.js +6 -2
  63. package/dist/sms/index.js.map +1 -1
  64. package/dist/sms/sms.provider.d.ts +9 -0
  65. package/dist/sms/sms.provider.js +7 -0
  66. package/dist/sms/sms.provider.js.map +1 -0
  67. package/dist/sms/sms.service.d.ts +8 -7
  68. package/dist/sms/sms.service.js +30 -2
  69. package/dist/sms/sms.service.js.map +1 -1
  70. package/dist/template/constant.d.ts +1 -0
  71. package/dist/template/constant.js +2 -1
  72. package/dist/template/constant.js.map +1 -1
  73. package/dist/template/engines/string-format.engine.d.ts +6 -0
  74. package/dist/template/engines/string-format.engine.js +17 -0
  75. package/dist/template/engines/string-format.engine.js.map +1 -0
  76. package/dist/template/fake-template.loader.js +14 -18
  77. package/dist/template/fake-template.loader.js.map +1 -1
  78. package/dist/template/index.d.ts +4 -2
  79. package/dist/template/index.js +4 -1
  80. package/dist/template/index.js.map +1 -1
  81. package/dist/template/template-engine.d.ts +5 -0
  82. package/dist/template/template-engine.js +3 -0
  83. package/dist/template/template-engine.js.map +1 -0
  84. package/dist/template/template.loader.d.ts +4 -1
  85. package/dist/template/template.loader.js +22 -14
  86. package/dist/template/template.loader.js.map +1 -1
  87. package/dist/whatsapp/constant.d.ts +2 -0
  88. package/dist/whatsapp/constant.js +6 -0
  89. package/dist/whatsapp/constant.js.map +1 -0
  90. package/dist/whatsapp/index.d.ts +3 -0
  91. package/dist/whatsapp/index.js +11 -0
  92. package/dist/whatsapp/index.js.map +1 -0
  93. package/dist/whatsapp/whatsapp.provider.d.ts +9 -0
  94. package/dist/whatsapp/whatsapp.provider.js +7 -0
  95. package/dist/whatsapp/whatsapp.provider.js.map +1 -0
  96. package/dist/whatsapp/whatsapp.service.d.ts +9 -0
  97. package/dist/whatsapp/whatsapp.service.js +35 -0
  98. package/dist/whatsapp/whatsapp.service.js.map +1 -0
  99. package/docs/20260214-fix-plan-notification.md +149 -0
  100. package/docs/20260214-fix-plan-post-refactor.md +118 -0
  101. package/docs/20260214-nestjs-notification-review.md +390 -0
  102. package/docs/20260214-review-post-refactor.md +285 -0
  103. package/docs/20260215-review-notification-post-fix.md +933 -0
  104. package/package.json +2 -1
  105. package/dist/email/email-provider.factory.d.ts +0 -5
  106. package/dist/email/email-provider.factory.js +0 -18
  107. package/dist/email/email-provider.factory.js.map +0 -1
  108. package/dist/email/email.module.d.ts +0 -27
  109. package/dist/email/email.module.js +0 -110
  110. package/dist/email/email.module.js.map +0 -1
  111. package/dist/interface/payload.inteface.d.ts +0 -22
  112. package/dist/interface/payload.inteface.js.map +0 -1
  113. package/dist/push-notification/push-notification-module.interface.d.ts +0 -33
  114. package/dist/push-notification/push-notification-module.interface.js.map +0 -1
  115. package/dist/push-notification/push-notification-provider-module.factory.d.ts +0 -5
  116. package/dist/push-notification/push-notification-provider-module.factory.js +0 -13
  117. package/dist/push-notification/push-notification-provider-module.factory.js.map +0 -1
  118. package/dist/push-notification/push-notification-provider.factory.d.ts +0 -5
  119. package/dist/push-notification/push-notification-provider.factory.js +0 -16
  120. package/dist/push-notification/push-notification-provider.factory.js.map +0 -1
  121. package/dist/push-notification/push-notification.module.d.ts +0 -15
  122. package/dist/push-notification/push-notification.module.js +0 -189
  123. package/dist/push-notification/push-notification.module.js.map +0 -1
@@ -9,4 +9,5 @@ export declare abstract class PushNotificationProvider implements IPushNotificat
9
9
  abstract readonly type: PushNotificationPlatform;
10
10
  abstract send(message: PushMessage): Promise<SendResult>;
11
11
  abstract sendMulticast(tokens: string[], message: PushMessageOnly): Promise<BatchSendResult>;
12
+ abstract get supportsAttachments(): boolean;
12
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"push-notification.provider.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification.provider.ts"],"names":[],"mappings":";;;AAaA,MAAsB,wBAAwB;CAQ7C;AARD,4DAQC"}
1
+ {"version":3,"file":"push-notification.provider.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification.provider.ts"],"names":[],"mappings":";;;AAyCA,MAAsB,wBAAwB;CAgB7C;AAhBD,4DAgBC"}
@@ -28,7 +28,8 @@ let PushNotificationService = class PushNotificationService {
28
28
  return this.userTokenStore.getUserDeviceTokens(userId);
29
29
  }
30
30
  send(message) {
31
- return this.providerManager.getProvider(message.paltform).send(message);
31
+ const platform = message.platform || message.paltform;
32
+ return this.providerManager.getProvider(platform).send(message);
32
33
  }
33
34
  async sendMulticast(tokens, message) {
34
35
  const groupedKeys = this.groupDevicesToken(tokens);
@@ -46,7 +47,7 @@ let PushNotificationService = class PushNotificationService {
46
47
  successCount: a.successCount + b.successCount,
47
48
  failureCount: a.failureCount + b.failureCount,
48
49
  };
49
- });
50
+ }, { successCount: 0, failureCount: 0, results: [] });
50
51
  }
51
52
  groupDevicesToken(tokens) {
52
53
  return tokens.reduce((group, item) => {
@@ -1 +1 @@
1
- {"version":3,"file":"push-notification.service.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAG5C,6FAAuE;AACvE,yDAA6D;AAGtD,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAElC,YAA6B,eAAgC,EAAmB,cAA8B;QAAjF,oBAAe,GAAf,eAAe,CAAiB;QAAmB,mBAAc,GAAd,cAAc,CAAgB;IAC9G,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,MAAuB,EACvB,KAAkB;QAElB,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,MAAuB;QAC9C,OAAO,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IACD,KAAK,CAAC,mBAAmB,CAAC,MAAuB;QAC/C,OAAO,IAAI,CAAC,cAAc,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,CAAC,OAAoB;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAAqB,EAAE,OAAwB;QACjE,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,GAAiB,CAAC,CAAC;YACrE,MAAM,MAAM,GAAG,KAAK,CAAC;YACrB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC7D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAkB,EAAE,CAAkB,EAAE,EAAE;YAC/D,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,CAAA;YAC5C,OAAO;gBACL,OAAO;gBACP,YAAY,EAAE,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY;gBAC7C,YAAY,EAAE,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY;aAC9C,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,iBAAiB,CAAC,MAAqB;QAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAkC,EAAE,IAAI,EAAE,EAAE;YAChE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACxB,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF,CAAA;AApDY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;qCAGmC,oDAAe,EAAmC,iCAAc;GAFnG,uBAAuB,CAoDnC"}
1
+ {"version":3,"file":"push-notification.service.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAG5C,6FAAuE;AACvE,yDAA6D;AAGtD,IAAM,uBAA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C,CAAC;QACvB,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAkB,EAAE,CAAkB,EAAE,EAAE;YAC/D,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,CAAA;YAC5C,OAAO;gBACL,OAAO;gBACP,YAAY,EAAE,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY;gBAC7C,YAAY,EAAE,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY;aAC9C,CAAA;QACH,CAAC,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAA;IACvD,CAAC;IAEO,iBAAiB,CAAC,MAAqB;QAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAkC,EAAE,IAAI,EAAE,EAAE;YAChE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACxB,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF,CAAA;AAtDY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;qCAGmC,oDAAe,EAAmC,iCAAc;GAFnG,uBAAuB,CAsDnC"}
@@ -20,20 +20,20 @@ let InMemoryUserTokenStore = class InMemoryUserTokenStore extends UserTokenStore
20
20
  this.cache = {};
21
21
  }
22
22
  async saveUserToken(userId, token) {
23
- this.cache[userId] = token;
23
+ if (!this.cache[userId]) {
24
+ this.cache[userId] = [];
25
+ }
26
+ this.cache[userId].push(token);
24
27
  return userId;
25
28
  }
26
29
  async getUserDeviceToken(userId) {
27
- if (this.cache[userId]) {
28
- return this.cache[userId];
30
+ if (this.cache[userId] && this.cache[userId].length > 0) {
31
+ return this.cache[userId][0];
29
32
  }
30
33
  return null;
31
34
  }
32
35
  async getUserDeviceTokens(userId) {
33
- if (this.cache[userId]) {
34
- return [this.cache[userId]];
35
- }
36
- return [];
36
+ return this.cache[userId] || [];
37
37
  }
38
38
  };
39
39
  exports.InMemoryUserTokenStore = InMemoryUserTokenStore;
@@ -1 +1 @@
1
- {"version":3,"file":"user-token.store.js","sourceRoot":"","sources":["../../lib/push-notification/user-token.store.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAa5C,MAAsB,cAAc;CASnC;AATD,wCASC;AAMM,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,cAAc;IAGxD;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,MAAuB,EACvB,KAAkB;QAElB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,MAAuB;QAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,mBAAmB,CAAC,MAAuB;QAC/C,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAA;AA5BY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;;GACA,sBAAsB,CA4BlC"}
1
+ {"version":3,"file":"user-token.store.js","sourceRoot":"","sources":["../../lib/push-notification/user-token.store.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAa5C,MAAsB,cAAc;CASnC;AATD,wCASC;AAMM,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,cAAc;IAGxD;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,MAAuB,EACvB,KAAkB;QAElB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAC1B,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,MAAuB;QAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,mBAAmB,CAAC,MAAuB;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAClC,CAAC;CACF,CAAA;AA5BY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;;GACA,sBAAsB,CA4BlC"}
@@ -0,0 +1 @@
1
+ export declare const SMS_PROVIDER = "SMS_PROVIDER";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SMS_PROVIDER = void 0;
4
+ exports.SMS_PROVIDER = 'SMS_PROVIDER';
5
+ //# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../lib/sms/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,cAAc,CAAC"}
@@ -1,2 +1,3 @@
1
- import { SmsService } from "./sms.service";
2
- export { SmsService };
1
+ export { SmsProvider } from './sms.provider';
2
+ export { SmsService } from './sms.service';
3
+ export { SMS_PROVIDER } from './constant';
package/dist/sms/index.js CHANGED
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SmsService = void 0;
4
- const sms_service_1 = require("./sms.service");
3
+ exports.SMS_PROVIDER = exports.SmsService = exports.SmsProvider = void 0;
4
+ var sms_provider_1 = require("./sms.provider");
5
+ Object.defineProperty(exports, "SmsProvider", { enumerable: true, get: function () { return sms_provider_1.SmsProvider; } });
6
+ var sms_service_1 = require("./sms.service");
5
7
  Object.defineProperty(exports, "SmsService", { enumerable: true, get: function () { return sms_service_1.SmsService; } });
8
+ var constant_1 = require("./constant");
9
+ Object.defineProperty(exports, "SMS_PROVIDER", { enumerable: true, get: function () { return constant_1.SMS_PROVIDER; } });
6
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/sms/index.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAElC,2FAFA,wBAAU,OAEA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/sms/index.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA"}
@@ -0,0 +1,9 @@
1
+ import { SmsMessage } from '../interface';
2
+ import { SendResult } from '../interface/result.interface';
3
+ export interface ISmsProvider {
4
+ send(message: SmsMessage): Promise<SendResult>;
5
+ }
6
+ export declare abstract class SmsProvider implements ISmsProvider {
7
+ abstract send(message: SmsMessage): Promise<SendResult>;
8
+ abstract get supportsAttachments(): boolean;
9
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmsProvider = void 0;
4
+ class SmsProvider {
5
+ }
6
+ exports.SmsProvider = SmsProvider;
7
+ //# sourceMappingURL=sms.provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sms.provider.js","sourceRoot":"","sources":["../../lib/sms/sms.provider.ts"],"names":[],"mappings":";;;AAqBA,MAAsB,WAAW;CAIhC;AAJD,kCAIC"}
@@ -1,8 +1,9 @@
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>;
1
+ import { SmsMessage } from '../interface';
2
+ import { SendResult } from '../interface/result.interface';
3
+ import { SmsProvider } from './sms.provider';
4
+ export declare class SmsService {
5
+ private readonly smsProvider;
6
+ private readonly logger;
7
+ constructor(smsProvider: SmsProvider);
8
+ send(message: SmsMessage): Promise<SendResult>;
8
9
  }
@@ -1,7 +1,35 @@
1
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 SmsService_1;
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.SmsService = void 0;
4
- class SmsService {
5
- }
17
+ const common_1 = require("@nestjs/common");
18
+ const sms_provider_1 = require("./sms.provider");
19
+ const constant_1 = require("./constant");
20
+ let SmsService = SmsService_1 = class SmsService {
21
+ constructor(smsProvider) {
22
+ this.smsProvider = smsProvider;
23
+ this.logger = new common_1.Logger(SmsService_1.name);
24
+ }
25
+ send(message) {
26
+ return this.smsProvider.send(message);
27
+ }
28
+ };
6
29
  exports.SmsService = SmsService;
30
+ exports.SmsService = SmsService = SmsService_1 = __decorate([
31
+ (0, common_1.Injectable)(),
32
+ __param(0, (0, common_1.Inject)(constant_1.SMS_PROVIDER)),
33
+ __metadata("design:paramtypes", [sms_provider_1.SmsProvider])
34
+ ], SmsService);
7
35
  //# sourceMappingURL=sms.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sms.service.js","sourceRoot":"","sources":["../../lib/sms/sms.service.ts"],"names":[],"mappings":";;;AAQA,MAAsB,UAAU;CAE/B;AAFD,gCAEC"}
1
+ {"version":3,"file":"sms.service.js","sourceRoot":"","sources":["../../lib/sms/sms.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAG5D,iDAA6C;AAC7C,yCAA0C;AAGnC,IAAM,UAAU,kBAAhB,MAAM,UAAU;IAGrB,YAAkC,WAAyC;QAAxB,gBAAW,GAAX,WAAW,CAAa;QAF1D,WAAM,GAAG,IAAI,eAAM,CAAC,YAAU,CAAC,IAAI,CAAC,CAAC;IAEwB,CAAC;IAExE,IAAI,CAAC,OAAmB;QAC7B,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AARY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;IAIE,WAAA,IAAA,eAAM,EAAC,uBAAY,CAAC,CAAA;qCAA+B,0BAAW;GAHhE,UAAU,CAQtB"}
@@ -1 +1,2 @@
1
1
  export declare const TEMPLATE_LOADER = "TEMPLATE_LOADER";
2
+ export declare const TEMPLATE_ENGINE = "TEMPLATE_ENGINE";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEMPLATE_LOADER = void 0;
3
+ exports.TEMPLATE_ENGINE = exports.TEMPLATE_LOADER = void 0;
4
4
  exports.TEMPLATE_LOADER = "TEMPLATE_LOADER";
5
+ exports.TEMPLATE_ENGINE = "TEMPLATE_ENGINE";
5
6
  //# sourceMappingURL=constant.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../lib/template/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,iBAAiB,CAAA"}
1
+ {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../lib/template/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,iBAAiB,CAAA;AACnC,QAAA,eAAe,GAAG,iBAAiB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { TemplateEngine } from '../template-engine';
2
+ export declare class StringFormatEngine implements TemplateEngine {
3
+ render(template: string, context: Array<{
4
+ [k: string]: any;
5
+ } | string>): string;
6
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StringFormatEngine = void 0;
7
+ const string_format_1 = __importDefault(require("string-format"));
8
+ class StringFormatEngine {
9
+ render(template, context) {
10
+ if (!context || context.length === 0) {
11
+ return template;
12
+ }
13
+ return (0, string_format_1.default)(template, ...context);
14
+ }
15
+ }
16
+ exports.StringFormatEngine = StringFormatEngine;
17
+ //# sourceMappingURL=string-format.engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-format.engine.js","sourceRoot":"","sources":["../../../lib/template/engines/string-format.engine.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAmC;AAGnC,MAAa,kBAAkB;IAC7B,MAAM,CAAC,QAAgB,EAAE,OAA6C;QACpE,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,IAAA,uBAAM,EAAC,QAAQ,EAAE,GAAG,OAAO,CAAC,CAAC;IACtC,CAAC;CACF;AAPD,gDAOC"}
@@ -9,28 +9,24 @@ class FakeTemplateLoader extends template_loader_1.TemplateLoader {
9
9
  this.logger = new common_1.Logger(FakeTemplateLoader.name);
10
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
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
- });
12
+ async getTemplate(templateCode, locale, fallbackLocale) {
13
+ return {
14
+ code: templateCode,
15
+ content: `${templateCode} content`,
16
+ subject: `${templateCode} subject`,
17
+ locale,
18
+ };
21
19
  }
22
20
  }
23
21
  exports.FakeTemplateLoader = FakeTemplateLoader;
24
22
  class EmptyTemplateLoader extends template_loader_1.TemplateLoader {
25
- getTemplate(templateCode, locale, fallbackLocale) {
26
- return new Promise((resolve, reject) => {
27
- resolve({
28
- code: templateCode,
29
- content: '',
30
- subject: '',
31
- locale,
32
- });
33
- });
23
+ async getTemplate(templateCode, locale, fallbackLocale) {
24
+ return {
25
+ code: templateCode,
26
+ content: '',
27
+ subject: '',
28
+ locale,
29
+ };
34
30
  }
35
31
  }
36
32
  exports.EmptyTemplateLoader = EmptyTemplateLoader;
@@ -1 +1 @@
1
- {"version":3,"file":"fake-template.loader.js","sourceRoot":"","sources":["../../lib/template/fake-template.loader.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,uDAAoE;AAEpE,MAAa,kBAAmB,SAAQ,gCAAc;IAEpD;QACE,KAAK,EAAE,CAAC;QAFO,WAAM,GAAG,IAAI,eAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAG5D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kHAAkH,CAAC,CAAC;IACvI,CAAC;IAED,WAAW,CAAC,YAAoB,EAAE,MAAc,EAAE,cAAuB;QACxE,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACvD,OAAO,CAAC;gBACN,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,GAAG,YAAY,UAAU;gBAClC,OAAO,EAAE,GAAG,YAAY,UAAU;gBAClC,MAAM;aACP,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CAEF;AAlBD,gDAkBC;AAED,MAAa,mBAAoB,SAAQ,gCAAc;IACrD,WAAW,CAAC,YAAoB,EAAE,MAAc,EAAE,cAAuB;QACvE,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtD,OAAO,CAAC;gBACN,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAC,EAAE;gBACV,OAAO,EAAC,EAAE;gBACV,MAAM;aACP,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACN,CAAC;CAEF;AAZD,kDAYC"}
1
+ {"version":3,"file":"fake-template.loader.js","sourceRoot":"","sources":["../../lib/template/fake-template.loader.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,uDAAoE;AAEpE,MAAa,kBAAmB,SAAQ,gCAAc;IAEpD;QACE,KAAK,EAAE,CAAC;QAFO,WAAM,GAAG,IAAI,eAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAG5D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kHAAkH,CAAC,CAAC;IACvI,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,YAAoB,EAAE,MAAc,EAAE,cAAuB;QAC7E,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,GAAG,YAAY,UAAU;YAClC,OAAO,EAAE,GAAG,YAAY,UAAU;YAClC,MAAM;SACP,CAAC;IACJ,CAAC;CAEF;AAhBD,gDAgBC;AAED,MAAa,mBAAoB,SAAQ,gCAAc;IACrD,KAAK,CAAC,WAAW,CAAC,YAAoB,EAAE,MAAc,EAAE,cAAuB;QAC7E,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,OAAO,EAAC,EAAE;YACV,OAAO,EAAC,EAAE;YACV,MAAM;SACP,CAAC;IACJ,CAAC;CAEF;AAVD,kDAUC"}
@@ -1,5 +1,7 @@
1
- import { TEMPLATE_LOADER } from "./constant";
1
+ import { TEMPLATE_LOADER, TEMPLATE_ENGINE } from "./constant";
2
2
  import { EmptyTemplateLoader, FakeTemplateLoader } from "./fake-template.loader";
3
3
  import { CacheOptions, MessageTemplate, ResolveOption, TemplateLoader, CachableTemplateLoader } from "./template.loader";
4
4
  import { TemplateService } from "./template.service";
5
- export { CacheOptions, MessageTemplate, ResolveOption, TemplateLoader, CachableTemplateLoader, TEMPLATE_LOADER, TemplateService, FakeTemplateLoader, EmptyTemplateLoader, };
5
+ import { TemplateEngine } from "./template-engine";
6
+ import { StringFormatEngine } from "./engines/string-format.engine";
7
+ export { CacheOptions, MessageTemplate, ResolveOption, TemplateLoader, CachableTemplateLoader, TEMPLATE_LOADER, TEMPLATE_ENGINE, TemplateService, FakeTemplateLoader, EmptyTemplateLoader, TemplateEngine, StringFormatEngine, };
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmptyTemplateLoader = exports.FakeTemplateLoader = exports.TemplateService = exports.TEMPLATE_LOADER = exports.CachableTemplateLoader = exports.TemplateLoader = exports.MessageTemplate = void 0;
3
+ exports.StringFormatEngine = exports.EmptyTemplateLoader = exports.FakeTemplateLoader = exports.TemplateService = exports.TEMPLATE_ENGINE = exports.TEMPLATE_LOADER = exports.CachableTemplateLoader = exports.TemplateLoader = exports.MessageTemplate = void 0;
4
4
  const constant_1 = require("./constant");
5
5
  Object.defineProperty(exports, "TEMPLATE_LOADER", { enumerable: true, get: function () { return constant_1.TEMPLATE_LOADER; } });
6
+ Object.defineProperty(exports, "TEMPLATE_ENGINE", { enumerable: true, get: function () { return constant_1.TEMPLATE_ENGINE; } });
6
7
  const fake_template_loader_1 = require("./fake-template.loader");
7
8
  Object.defineProperty(exports, "EmptyTemplateLoader", { enumerable: true, get: function () { return fake_template_loader_1.EmptyTemplateLoader; } });
8
9
  Object.defineProperty(exports, "FakeTemplateLoader", { enumerable: true, get: function () { return fake_template_loader_1.FakeTemplateLoader; } });
@@ -12,4 +13,6 @@ Object.defineProperty(exports, "TemplateLoader", { enumerable: true, get: functi
12
13
  Object.defineProperty(exports, "CachableTemplateLoader", { enumerable: true, get: function () { return template_loader_1.CachableTemplateLoader; } });
13
14
  const template_service_1 = require("./template.service");
14
15
  Object.defineProperty(exports, "TemplateService", { enumerable: true, get: function () { return template_service_1.TemplateService; } });
16
+ const string_format_engine_1 = require("./engines/string-format.engine");
17
+ Object.defineProperty(exports, "StringFormatEngine", { enumerable: true, get: function () { return string_format_engine_1.StringFormatEngine; } });
15
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/template/index.ts"],"names":[],"mappings":";;;AAAA,yCAA6C;AAW3C,gGAXO,0BAAe,OAWP;AAVjB,iEAAiF;AAa/E,oGAbO,0CAAmB,OAaP;AADnB,mGAZ4B,yCAAkB,OAY5B;AAXpB,uDAAyH;AAKvH,gGALqB,iCAAe,OAKrB;AAEf,+FAPqD,gCAAc,OAOrD;AACd,uGARqE,wCAAsB,OAQrE;AAPxB,yDAAqD;AASnD,gGATO,kCAAe,OASP"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/template/index.ts"],"names":[],"mappings":";;;AAAA,yCAA8D;AAa5D,gGAbO,0BAAe,OAaP;AACf,gGAdwB,0BAAe,OAcxB;AAbjB,iEAAiF;AAgB/E,oGAhBO,0CAAmB,OAgBP;AADnB,mGAf4B,yCAAkB,OAe5B;AAdpB,uDAAyH;AAOvH,gGAPqB,iCAAe,OAOrB;AAEf,+FATqD,gCAAc,OASrD;AACd,uGAVqE,wCAAsB,OAUrE;AATxB,yDAAqD;AAYnD,gGAZO,kCAAe,OAYP;AAVjB,yEAAoE;AAclE,mGAdO,yCAAkB,OAcP"}
@@ -0,0 +1,5 @@
1
+ export interface TemplateEngine {
2
+ render(template: string, context: Array<{
3
+ [k: string]: any;
4
+ } | string>): string;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=template-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-engine.js","sourceRoot":"","sources":["../../lib/template/template-engine.ts"],"names":[],"mappings":""}
@@ -1,4 +1,5 @@
1
1
  import { Cache } from "cache-manager";
2
+ import { TemplateEngine } from './template-engine';
2
3
  export interface CacheOptions {
3
4
  cacheKey: string;
4
5
  ttl: number;
@@ -17,13 +18,15 @@ export interface ResolveOption {
17
18
  } | string)>;
18
19
  }
19
20
  export declare abstract class TemplateLoader {
21
+ protected engine: TemplateEngine;
22
+ constructor(engine?: TemplateEngine);
20
23
  abstract getTemplate(templateCode: string, locale: string, fallbackLocale?: string): Promise<MessageTemplate>;
21
24
  resolve(templateCode: string, options?: ResolveOption): Promise<MessageTemplate>;
22
25
  }
23
26
  export declare abstract class CachableTemplateLoader extends TemplateLoader {
24
27
  private cacheManager;
25
28
  private readonly cacheOptions;
26
- constructor(cacheManager: Cache, cacheOptions?: CacheOptions);
29
+ constructor(cacheManager: Cache, cacheOptions?: CacheOptions, engine?: TemplateEngine);
27
30
  resolve(templateCode: string, options?: ResolveOption): Promise<MessageTemplate>;
28
31
  protected getTemplateCacheKey(templateCode: string, locale: string): string;
29
32
  }
@@ -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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CAAA;;GAPlB,sBAAsB,CA0C3C"}
@@ -0,0 +1,2 @@
1
+ export declare const WHATSAPP_PROVIDER = "WHATSAPP_PROVIDER";
2
+ export declare const WHATSAPP_SERVICE = "WHATSAPP_SERVICE";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WHATSAPP_SERVICE = exports.WHATSAPP_PROVIDER = void 0;
4
+ exports.WHATSAPP_PROVIDER = 'WHATSAPP_PROVIDER';
5
+ exports.WHATSAPP_SERVICE = 'WHATSAPP_SERVICE';
6
+ //# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../lib/whatsapp/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,gBAAgB,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { WhatsAppProvider } from './whatsapp.provider';
2
+ export { WhatsAppService } from './whatsapp.service';
3
+ export { WHATSAPP_PROVIDER, WHATSAPP_SERVICE } from './constant';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WHATSAPP_SERVICE = exports.WHATSAPP_PROVIDER = exports.WhatsAppService = exports.WhatsAppProvider = void 0;
4
+ var whatsapp_provider_1 = require("./whatsapp.provider");
5
+ Object.defineProperty(exports, "WhatsAppProvider", { enumerable: true, get: function () { return whatsapp_provider_1.WhatsAppProvider; } });
6
+ var whatsapp_service_1 = require("./whatsapp.service");
7
+ Object.defineProperty(exports, "WhatsAppService", { enumerable: true, get: function () { return whatsapp_service_1.WhatsAppService; } });
8
+ var constant_1 = require("./constant");
9
+ Object.defineProperty(exports, "WHATSAPP_PROVIDER", { enumerable: true, get: function () { return constant_1.WHATSAPP_PROVIDER; } });
10
+ Object.defineProperty(exports, "WHATSAPP_SERVICE", { enumerable: true, get: function () { return constant_1.WHATSAPP_SERVICE; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/whatsapp/index.ts"],"names":[],"mappings":";;;AAAA,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AACxB,uCAAiE;AAAxD,6GAAA,iBAAiB,OAAA;AAAE,4GAAA,gBAAgB,OAAA"}
@@ -0,0 +1,9 @@
1
+ import { WhatsAppMessage } from '../interface';
2
+ import { SendResult } from '../interface/result.interface';
3
+ export interface IWhatsAppProvider {
4
+ send(message: WhatsAppMessage): Promise<SendResult>;
5
+ }
6
+ export declare abstract class WhatsAppProvider implements IWhatsAppProvider {
7
+ abstract send(message: WhatsAppMessage): Promise<SendResult>;
8
+ abstract get supportsAttachments(): boolean;
9
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WhatsAppProvider = void 0;
4
+ class WhatsAppProvider {
5
+ }
6
+ exports.WhatsAppProvider = WhatsAppProvider;
7
+ //# sourceMappingURL=whatsapp.provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whatsapp.provider.js","sourceRoot":"","sources":["../../lib/whatsapp/whatsapp.provider.ts"],"names":[],"mappings":";;;AAiBA,MAAsB,gBAAgB;CAIrC;AAJD,4CAIC"}
@@ -0,0 +1,9 @@
1
+ import { WhatsAppMessage } from '../interface';
2
+ import { SendResult } from '../interface/result.interface';
3
+ import { WhatsAppProvider } from './whatsapp.provider';
4
+ export declare class WhatsAppService {
5
+ private readonly whatsAppProvider;
6
+ private readonly logger;
7
+ constructor(whatsAppProvider: WhatsAppProvider);
8
+ send(message: WhatsAppMessage): Promise<SendResult>;
9
+ }
@@ -0,0 +1,35 @@
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 WhatsAppService_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.WhatsAppService = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const whatsapp_provider_1 = require("./whatsapp.provider");
19
+ const constant_1 = require("./constant");
20
+ let WhatsAppService = WhatsAppService_1 = class WhatsAppService {
21
+ constructor(whatsAppProvider) {
22
+ this.whatsAppProvider = whatsAppProvider;
23
+ this.logger = new common_1.Logger(WhatsAppService_1.name);
24
+ }
25
+ send(message) {
26
+ return this.whatsAppProvider.send(message);
27
+ }
28
+ };
29
+ exports.WhatsAppService = WhatsAppService;
30
+ exports.WhatsAppService = WhatsAppService = WhatsAppService_1 = __decorate([
31
+ (0, common_1.Injectable)(),
32
+ __param(0, (0, common_1.Inject)(constant_1.WHATSAPP_PROVIDER)),
33
+ __metadata("design:paramtypes", [whatsapp_provider_1.WhatsAppProvider])
34
+ ], WhatsAppService);
35
+ //# sourceMappingURL=whatsapp.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whatsapp.service.js","sourceRoot":"","sources":["../../lib/whatsapp/whatsapp.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAG5D,2DAAuD;AACvD,yCAA+C;AAGxC,IAAM,eAAe,uBAArB,MAAM,eAAe;IAG1B,YAAuC,gBAAmD;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAFzE,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IAEkC,CAAC;IAEvF,IAAI,CAAC,OAAwB;QAClC,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AARY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAIE,WAAA,IAAA,eAAM,EAAC,4BAAiB,CAAC,CAAA;qCAAoC,oCAAgB;GAH/E,eAAe,CAQ3B"}