@nathapp/nestjs-notification 2.2.0 → 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 (92) hide show
  1. package/CLAUDE.md +21 -0
  2. package/dist/email/email.interface.d.ts +1 -1
  3. package/dist/email/email.provider.d.ts +2 -2
  4. package/dist/email/email.provider.js +7 -5
  5. package/dist/email/email.provider.js.map +1 -1
  6. package/dist/email/index.d.ts +1 -3
  7. package/dist/email/index.js +1 -6
  8. package/dist/email/index.js.map +1 -1
  9. package/dist/index.d.ts +4 -4
  10. package/dist/index.js +9 -8
  11. package/dist/index.js.map +1 -1
  12. package/dist/interface/index.d.ts +1 -1
  13. package/dist/interface/message.interface.d.ts +1 -2
  14. package/dist/interface/{payload.inteface.d.ts → payload.interface.d.ts} +3 -5
  15. package/dist/interface/{payload.inteface.js → payload.interface.js} +1 -1
  16. package/dist/interface/payload.interface.js.map +1 -0
  17. package/dist/interface/result.interface.d.ts +2 -1
  18. package/dist/notification/notification-provider.factory.js +2 -2
  19. package/dist/notification/notification-provider.factory.js.map +1 -1
  20. package/dist/notification/notification.module.d.ts +1 -1
  21. package/dist/notification/notification.module.js +33 -21
  22. package/dist/notification/notification.module.js.map +1 -1
  23. package/dist/notification/notification.service.js +5 -5
  24. package/dist/notification/notification.service.js.map +1 -1
  25. package/dist/notification/provider-config.d.ts +4 -4
  26. package/dist/push-notification/fcm-push-notification.provider.d.ts +3 -0
  27. package/dist/push-notification/fcm-push-notification.provider.js +17 -2
  28. package/dist/push-notification/fcm-push-notification.provider.js.map +1 -1
  29. package/dist/push-notification/firebase.interface.d.ts +1 -0
  30. package/dist/push-notification/index.d.ts +1 -4
  31. package/dist/push-notification/index.js +1 -5
  32. package/dist/push-notification/index.js.map +1 -1
  33. package/dist/push-notification/push-notification-provider.manager.d.ts +8 -3
  34. package/dist/push-notification/push-notification-provider.manager.js +12 -3
  35. package/dist/push-notification/push-notification-provider.manager.js.map +1 -1
  36. package/dist/push-notification/push-notification.provider.d.ts +1 -0
  37. package/dist/push-notification/push-notification.provider.js.map +1 -1
  38. package/dist/push-notification/push-notification.service.js +1 -1
  39. package/dist/push-notification/push-notification.service.js.map +1 -1
  40. package/dist/push-notification/user-token.store.js +7 -7
  41. package/dist/push-notification/user-token.store.js.map +1 -1
  42. package/dist/sms/constant.d.ts +1 -0
  43. package/dist/sms/constant.js +5 -0
  44. package/dist/sms/constant.js.map +1 -0
  45. package/dist/sms/index.d.ts +3 -2
  46. package/dist/sms/index.js +6 -2
  47. package/dist/sms/index.js.map +1 -1
  48. package/dist/sms/sms.provider.d.ts +9 -0
  49. package/dist/sms/sms.provider.js +7 -0
  50. package/dist/sms/sms.provider.js.map +1 -0
  51. package/dist/sms/sms.service.d.ts +8 -7
  52. package/dist/sms/sms.service.js +30 -2
  53. package/dist/sms/sms.service.js.map +1 -1
  54. package/dist/template/fake-template.loader.js +14 -18
  55. package/dist/template/fake-template.loader.js.map +1 -1
  56. package/dist/whatsapp/constant.d.ts +1 -0
  57. package/dist/whatsapp/constant.js +2 -1
  58. package/dist/whatsapp/constant.js.map +1 -1
  59. package/dist/whatsapp/index.d.ts +3 -2
  60. package/dist/whatsapp/index.js +8 -16
  61. package/dist/whatsapp/index.js.map +1 -1
  62. package/dist/whatsapp/whatsapp.provider.d.ts +9 -0
  63. package/dist/whatsapp/whatsapp.provider.js +7 -0
  64. package/dist/whatsapp/whatsapp.provider.js.map +1 -0
  65. package/dist/whatsapp/whatsapp.service.d.ts +7 -5
  66. package/dist/whatsapp/whatsapp.service.js +30 -2
  67. package/dist/whatsapp/whatsapp.service.js.map +1 -1
  68. package/docs/20260214-fix-plan-notification.md +149 -0
  69. package/docs/20260214-fix-plan-post-refactor.md +118 -0
  70. package/docs/20260214-nestjs-notification-review.md +390 -0
  71. package/docs/20260214-review-post-refactor.md +285 -0
  72. package/docs/20260215-review-notification-post-fix.md +933 -0
  73. package/package.json +1 -1
  74. package/dist/email/email-provider.factory.d.ts +0 -5
  75. package/dist/email/email-provider.factory.js +0 -18
  76. package/dist/email/email-provider.factory.js.map +0 -1
  77. package/dist/email/email.module.d.ts +0 -27
  78. package/dist/email/email.module.js +0 -110
  79. package/dist/email/email.module.js.map +0 -1
  80. package/dist/interface/payload.inteface.js.map +0 -1
  81. package/dist/push-notification/push-notification-module.interface.d.ts +0 -33
  82. package/dist/push-notification/push-notification-module.interface.js +0 -4
  83. package/dist/push-notification/push-notification-module.interface.js.map +0 -1
  84. package/dist/push-notification/push-notification-provider-module.factory.d.ts +0 -5
  85. package/dist/push-notification/push-notification-provider-module.factory.js +0 -13
  86. package/dist/push-notification/push-notification-provider-module.factory.js.map +0 -1
  87. package/dist/push-notification/push-notification-provider.factory.d.ts +0 -5
  88. package/dist/push-notification/push-notification-provider.factory.js +0 -16
  89. package/dist/push-notification/push-notification-provider.factory.js.map +0 -1
  90. package/dist/push-notification/push-notification.module.d.ts +0 -15
  91. package/dist/push-notification/push-notification.module.js +0 -189
  92. package/dist/push-notification/push-notification.module.js.map +0 -1
@@ -4,19 +4,34 @@ exports.FCMPushNotificationProvider = void 0;
4
4
  const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
5
5
  const push_notification_provider_1 = require("./push-notification.provider");
6
6
  const common_1 = require("@nathapp/common");
7
+ const crypto_1 = require("crypto");
7
8
  class FCMPushNotificationProvider extends push_notification_provider_1.PushNotificationProvider {
8
9
  constructor(option) {
9
10
  super();
10
11
  const Firebase = (0, load_package_util_1.loadPackage)('firebase-admin', FCMPushNotificationProvider.name, () => require('firebase-admin'));
11
12
  this.option = option;
13
+ this.appName = `fcm-${(0, crypto_1.randomUUID)()}`;
14
+ let serviceAccountData;
15
+ try {
16
+ serviceAccountData = JSON.parse(option.serviceAccount);
17
+ }
18
+ catch (error) {
19
+ throw new Error(`Invalid Firebase service account JSON: failed to parse (${error.message}). Verify the JSON format of your service account configuration.`);
20
+ }
12
21
  this.client = Firebase.initializeApp({
13
- credential: Firebase.credential.cert(JSON.parse(option.serviceAccount)),
22
+ credential: Firebase.credential.cert(serviceAccountData),
14
23
  databaseURL: option.databaseUrl,
15
- });
24
+ }, this.appName);
16
25
  }
17
26
  get type() {
18
27
  return "firebase";
19
28
  }
29
+ get supportsAttachments() {
30
+ return false;
31
+ }
32
+ async destroy() {
33
+ await this.client.delete();
34
+ }
20
35
  async send(message) {
21
36
  const firebaseMessage = this.generateMessage(message);
22
37
  const messageId = await this.client.messaging().send(firebaseMessage);
@@ -1 +1 @@
1
- {"version":3,"file":"fcm-push-notification.provider.js","sourceRoot":"","sources":["../../lib/push-notification/fcm-push-notification.provider.ts"],"names":[],"mappings":";;;AAEA,8EAAqE;AACrE,6EAAwE;AAExE,4CAA2D;AAK3D,MAAa,2BAA4B,SAAQ,qDAAwB;IAGvE,YAAY,MAAiC;QAC3C,KAAK,EAAE,CAAC;QACR,MAAM,QAAQ,GAAG,IAAA,+BAAW,EAAC,gBAAgB,EAAE,2BAA2B,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAClH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC;YACnC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YACvE,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI;QACN,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC9B,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACtE,OAAO;YACJ,OAAO,EAAE,CAA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AAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO;gBACL,GAAG,cAAc;gBACjB,MAAM,EAAE,KAAK;aACd,CAAA;QACH,CAAC;QACD,OAAO;YACL,GAAG,cAAc;YACjB,KAAK,EAAE,KAAK;SACb,CAAA;IACH,CAAC;CACF;AA/ED,kEA+EC"}
1
+ {"version":3,"file":"fcm-push-notification.provider.js","sourceRoot":"","sources":["../../lib/push-notification/fcm-push-notification.provider.ts"],"names":[],"mappings":";;;AAEA,8EAAqE;AACrE,6EAAwE;AAExE,4CAA2D;AAC3D,mCAAoC;AAKpC,MAAa,2BAA4B,SAAQ,qDAAwB;IAKvE,YAAY,MAAiC;QAC3C,KAAK,EAAE,CAAC;QACR,MAAM,QAAQ,GAAG,IAAA,+BAAW,EAAC,gBAAgB,EAAE,2BAA2B,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAClH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAA,mBAAU,GAAE,EAAE,CAAC;QAErC,IAAI,kBAAkB,CAAC;QACvB,IAAI,CAAC;YACH,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEf,MAAM,IAAI,KAAK,CAAC,2DAA2D,KAAK,CAAC,OAAO,kEAAkE,CAAC,CAAC;QAC9J,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC;YACnC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC;YACxD,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,mB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AC,KAAwB,EAAE,WAA0C;QAE7F,MAAM,cAAc,GAAyB;YAC3C,YAAY,EAAE;gBACV,KAAK,EAAE,WAAW,CAAC,OAAO;gBAC1B,IAAI,EAAE,WAAW,CAAC,OAAO;aAC5B;YACD,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE;gBACF,OAAO,EAAE;oBACL,GAAG,EAAE;wBACD,cAAc,EAAE,IAAI;wBACpB,gBAAgB,EAAE,IAAI;wBACtB,YAAY,EAAE,YAAY;qBAC7B;iBAEJ;aACF;SACJ,CAAC;QAEF,IAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO;gBACL,GAAG,cAAc;gBACjB,MAAM,EAAE,KAAK;aACd,CAAA;QACH,CAAC;QACD,OAAO;YACL,GAAG,cAAc;YACjB,KAAK,EAAE,KAAK;SACb,CAAA;IACH,CAAC;CACF;AAvGD,kEAuGC"}
@@ -5,6 +5,7 @@ export interface FirebaseMessaging {
5
5
  }
6
6
  export interface FirebaseApp {
7
7
  messaging(): FirebaseMessaging;
8
+ delete(): Promise<void>;
8
9
  }
9
10
  export interface BaseMessage {
10
11
  data?: {
@@ -1,11 +1,8 @@
1
1
  import { PUSH_NOTIFICATION_PROVIDERS } from "./constant";
2
2
  import { FCMPushNotificationProvider } from "./fcm-push-notification.provider";
3
- import { PushNotificationModuleAsyncOptions, PushNotificationModuleOptions, PushNotificationProviderAsyncOptions, PushNotificationProviderModuleOptionsFactory, PushNotificationProviderOptions } from "./push-notification-module.interface";
4
3
  import { DeviceToken, FCMPushNotificationOption, PlatformOS, PushNotificationOption, PushNotificationPlatform } from "./push-notification.interface";
5
- import { PushNotificationModule } from "./push-notification.module";
6
4
  import { PushNotificationProvider } from "./push-notification.provider";
7
5
  import { DefaultProviderManager, ProviderManager } from "./push-notification-provider.manager";
8
6
  import { PushNotificationService } from "./push-notification.service";
9
- import { DefaultFirebasePushNotificationProviderModuleOptionsFactory } from "./push-notification-provider-module.factory";
10
7
  import { IUserTokenStore, InMemoryUserTokenStore, TokenId, UserTokenStore } from "./user-token.store";
11
- export { PushNotificationService, FCMPushNotificationOption, PushNotificationOption, FCMPushNotificationProvider, PushNotificationProvider, PushNotificationPlatform, PlatformOS, ProviderManager, PushNotificationProviderOptions, PushNotificationModuleOptions, PushNotificationProviderModuleOptionsFactory, PushNotificationProviderAsyncOptions, PushNotificationModuleAsyncOptions, PUSH_NOTIFICATION_PROVIDERS, PushNotificationModule, DefaultProviderManager, DeviceToken, DefaultFirebasePushNotificationProviderModuleOptionsFactory, TokenId, IUserTokenStore, UserTokenStore, InMemoryUserTokenStore, };
8
+ export { PushNotificationService, FCMPushNotificationOption, PushNotificationOption, FCMPushNotificationProvider, PushNotificationProvider, PushNotificationPlatform, PlatformOS, ProviderManager, PUSH_NOTIFICATION_PROVIDERS, DefaultProviderManager, DeviceToken, TokenId, IUserTokenStore, UserTokenStore, InMemoryUserTokenStore, };
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InMemoryUserTokenStore = exports.UserTokenStore = exports.DefaultFirebasePushNotificationProviderModuleOptionsFactory = exports.DefaultProviderManager = exports.PushNotificationModule = exports.PUSH_NOTIFICATION_PROVIDERS = exports.ProviderManager = exports.PlatformOS = exports.PushNotificationProvider = exports.FCMPushNotificationProvider = exports.PushNotificationService = void 0;
3
+ exports.InMemoryUserTokenStore = exports.UserTokenStore = exports.DefaultProviderManager = exports.PUSH_NOTIFICATION_PROVIDERS = exports.ProviderManager = exports.PlatformOS = exports.PushNotificationProvider = exports.FCMPushNotificationProvider = exports.PushNotificationService = void 0;
4
4
  const constant_1 = require("./constant");
5
5
  Object.defineProperty(exports, "PUSH_NOTIFICATION_PROVIDERS", { enumerable: true, get: function () { return constant_1.PUSH_NOTIFICATION_PROVIDERS; } });
6
6
  const fcm_push_notification_provider_1 = require("./fcm-push-notification.provider");
7
7
  Object.defineProperty(exports, "FCMPushNotificationProvider", { enumerable: true, get: function () { return fcm_push_notification_provider_1.FCMPushNotificationProvider; } });
8
8
  const push_notification_interface_1 = require("./push-notification.interface");
9
9
  Object.defineProperty(exports, "PlatformOS", { enumerable: true, get: function () { return push_notification_interface_1.PlatformOS; } });
10
- const push_notification_module_1 = require("./push-notification.module");
11
- Object.defineProperty(exports, "PushNotificationModule", { enumerable: true, get: function () { return push_notification_module_1.PushNotificationModule; } });
12
10
  const push_notification_provider_1 = require("./push-notification.provider");
13
11
  Object.defineProperty(exports, "PushNotificationProvider", { enumerable: true, get: function () { return push_notification_provider_1.PushNotificationProvider; } });
14
12
  const push_notification_provider_manager_1 = require("./push-notification-provider.manager");
@@ -16,8 +14,6 @@ Object.defineProperty(exports, "DefaultProviderManager", { enumerable: true, get
16
14
  Object.defineProperty(exports, "ProviderManager", { enumerable: true, get: function () { return push_notification_provider_manager_1.ProviderManager; } });
17
15
  const push_notification_service_1 = require("./push-notification.service");
18
16
  Object.defineProperty(exports, "PushNotificationService", { enumerable: true, get: function () { return push_notification_service_1.PushNotificationService; } });
19
- const push_notification_provider_module_factory_1 = require("./push-notification-provider-module.factory");
20
- Object.defineProperty(exports, "DefaultFirebasePushNotificationProviderModuleOptionsFactory", { enumerable: true, get: function () { return push_notification_provider_module_factory_1.DefaultFirebasePushNotificationProviderModuleOptionsFactory; } });
21
17
  const user_token_store_1 = require("./user-token.store");
22
18
  Object.defineProperty(exports, "InMemoryUserTokenStore", { enumerable: true, get: function () { return user_token_store_1.InMemoryUserTokenStore; } });
23
19
  Object.defineProperty(exports, "UserTokenStore", { enumerable: true, get: function () { return user_token_store_1.UserTokenStore; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/push-notification/index.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AAyBvD,4GAzBO,sCAA2B,OAyBP;AAxB7B,qFAA+E;AAc7E,4GAdO,4DAA2B,OAcP;AAZ7B,+EAAqJ;AAenJ,2FAf+C,wCAAU,OAe/C;AAdZ,yEAAoE;AAsBlE,uGAtBO,iDAAsB,OAsBP;AArBxB,6EAAwE;AAWtE,yGAXO,qDAAwB,OAWP;AAV1B,6FAA+F;AAqB7F,uGArBO,2DAAsB,OAqBP;AARtB,gGAb+B,oDAAe,OAa/B;AAZjB,2EAAsE;AAKpE,wGALO,mDAAuB,OAKP;AAJzB,2GAA0H;AAqBxH,4IArBO,uGAA2D,OAqBP;AApB7D,yDAAsG;AAwBpG,uGAxBwB,yCAAsB,OAwBxB;AADtB,+FAvByD,iCAAc,OAuBzD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/push-notification/index.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AAiBvD,4GAjBO,sCAA2B,OAiBP;AAhB7B,qFAA+E;AAW7E,4GAXO,4DAA2B,OAWP;AAV7B,+EAAqJ;AAanJ,2FAb+C,wCAAU,OAa/C;AAZZ,6EAAwE;AAUtE,yGAVO,qDAAwB,OAUP;AAT1B,6FAA+F;AAc7F,uGAdO,2DAAsB,OAcP;AAFtB,gGAZ+B,oDAAe,OAY/B;AAXjB,2EAAsE;AAIpE,wGAJO,mDAAuB,OAIP;AAHzB,yDAAsG;AAiBpG,uGAjBwB,yCAAsB,OAiBxB;AADtB,+FAhByD,iCAAc,OAgBzD"}
@@ -1,13 +1,18 @@
1
+ import { OnModuleDestroy } from "@nestjs/common";
1
2
  import { PushNotificationProvider } from "./push-notification.provider";
2
3
  import { PlatformOS } from "./push-notification.interface";
3
4
  export declare abstract class ProviderManager {
4
- abstract getProvider(paltform?: PlatformOS): PushNotificationProvider;
5
+ abstract getProvider(platform?: PlatformOS): PushNotificationProvider;
5
6
  abstract get defaultProvider(): PushNotificationProvider;
7
+ abstract destroy(): Promise<void>;
6
8
  }
7
- export declare class DefaultProviderManager extends ProviderManager {
9
+ export declare class DefaultProviderManager extends ProviderManager implements OnModuleDestroy {
8
10
  private readonly _defaultProvider;
9
11
  private readonly keysProviders;
12
+ private readonly allProviders;
10
13
  constructor(providers: PushNotificationProvider[]);
11
14
  get defaultProvider(): PushNotificationProvider;
12
- getProvider(paltform?: PlatformOS): PushNotificationProvider;
15
+ getProvider(platform?: PlatformOS): PushNotificationProvider;
16
+ destroy(): Promise<void>;
17
+ onModuleDestroy(): Promise<void>;
13
18
  }
@@ -13,6 +13,7 @@ class DefaultProviderManager extends ProviderManager {
13
13
  throw new Error("please provide at lease one PushNotificationProvider");
14
14
  }
15
15
  this._defaultProvider = providers[0];
16
+ this.allProviders = providers;
16
17
  providers.forEach(item => {
17
18
  this.keysProviders[item.type] = item;
18
19
  });
@@ -20,12 +21,12 @@ class DefaultProviderManager extends ProviderManager {
20
21
  get defaultProvider() {
21
22
  return this._defaultProvider;
22
23
  }
23
- getProvider(paltform) {
24
+ getProvider(platform) {
24
25
  let provider = undefined;
25
- if (paltform == push_notification_interface_1.PlatformOS.android || paltform == push_notification_interface_1.PlatformOS.ios) {
26
+ if (platform == push_notification_interface_1.PlatformOS.android || platform == push_notification_interface_1.PlatformOS.ios) {
26
27
  provider = this.keysProviders["firebase"];
27
28
  }
28
- else if (paltform == "huawei") {
29
+ else if (platform == "huawei") {
29
30
  provider = this.keysProviders["hms"];
30
31
  }
31
32
  if (!provider) {
@@ -33,6 +34,14 @@ class DefaultProviderManager extends ProviderManager {
33
34
  }
34
35
  return provider;
35
36
  }
37
+ async destroy() {
38
+ await Promise.allSettled(this.allProviders
39
+ .filter(p => typeof p.destroy === 'function')
40
+ .map(p => p.destroy()));
41
+ }
42
+ async onModuleDestroy() {
43
+ await this.destroy();
44
+ }
36
45
  }
37
46
  exports.DefaultProviderManager = DefaultProviderManager;
38
47
  //# sourceMappingURL=push-notification-provider.manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"push-notification-provider.manager.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification-provider.manager.ts"],"names":[],"mappings":";;;AAEA,+EAA2D;AAG3D,MAAsB,eAAe;CAMpC;AAND,0CAMC;AAED,MAAa,sBAAuB,SAAQ,eAAe;IAMzD,YAAY,SAAqC;QAC/C,KAAK,EAAE,CAAC;QAHO,kBAAa,GAA6C,EAAE,CAAC;QAI5E,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACrC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACvB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,WAAW,CAAC,QAAqB;QAC/B,IAAI,QAAQ,GAA6B,SAAS,CAAC;QAEnD,IAAI,QAAQ,IAAI,wCAAU,CAAC,OAAO,IAAI,QAAQ,IAAI,wCAAU,CAAC,GAAG,EAAE,CAAC;YACjE,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;aAAM,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;YAChC,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;QAClC,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CAGF;AArCD,wDAqCC"}
1
+ {"version":3,"file":"push-notification-provider.manager.js","sourceRoot":"","sources":["../../lib/push-notification/push-notification-provider.manager.ts"],"names":[],"mappings":";;;AAGA,+EAA2D;AAG3D,MAAsB,eAAe;CASpC;AATD,0CASC;AAED,MAAa,sBAAuB,SAAQ,eAAe;IAOzD,YAAY,SAAqC;QAC/C,KAAK,EAAE,CAAC;QAJ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eAAe;QACnB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;CAEF;AApDD,wDAoDC"}
@@ -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"}
@@ -47,7 +47,7 @@ let PushNotificationService = class PushNotificationService {
47
47
  successCount: a.successCount + b.successCount,
48
48
  failureCount: a.failureCount + b.failureCount,
49
49
  };
50
- });
50
+ }, { successCount: 0, failureCount: 0, results: [] });
51
51
  }
52
52
  groupDevicesToken(tokens) {
53
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,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AAY,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;AAtDY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;qCAGmC,oDAAe,EAAmC,iCAAc;GAFnG,uBAAuB,CAsDnC"}
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,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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"}
@@ -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 +1,2 @@
1
+ export declare const WHATSAPP_PROVIDER = "WHATSAPP_PROVIDER";
1
2
  export declare const WHATSAPP_SERVICE = "WHATSAPP_SERVICE";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WHATSAPP_SERVICE = void 0;
3
+ exports.WHATSAPP_SERVICE = exports.WHATSAPP_PROVIDER = void 0;
4
+ exports.WHATSAPP_PROVIDER = 'WHATSAPP_PROVIDER';
4
5
  exports.WHATSAPP_SERVICE = 'WHATSAPP_SERVICE';
5
6
  //# sourceMappingURL=constant.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../lib/whatsapp/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,kBAAkB,CAAC"}
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"}
@@ -1,2 +1,3 @@
1
- export * from './whatsapp.service';
2
- export * from './constant';
1
+ export { WhatsAppProvider } from './whatsapp.provider';
2
+ export { WhatsAppService } from './whatsapp.service';
3
+ export { WHATSAPP_PROVIDER, WHATSAPP_SERVICE } from './constant';
@@ -1,19 +1,11 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./whatsapp.service"), exports);
18
- __exportStar(require("./constant"), exports);
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; } });
19
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/whatsapp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,6CAA2B"}
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"}
@@ -1,7 +1,9 @@
1
- import { WhatsAppMessage, SendResult } from '../interface';
2
- export interface IWhatsAppService {
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);
3
8
  send(message: WhatsAppMessage): Promise<SendResult>;
4
9
  }
5
- export declare abstract class WhatsAppService implements IWhatsAppService {
6
- abstract send(message: WhatsAppMessage): Promise<SendResult>;
7
- }
@@ -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 WhatsAppService_1;
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.WhatsAppService = void 0;
4
- class WhatsAppService {
5
- }
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
+ };
6
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);
7
35
  //# sourceMappingURL=whatsapp.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"whatsapp.service.js","sourceRoot":"","sources":["../../lib/whatsapp/whatsapp.service.ts"],"names":[],"mappings":";;;AAMA,MAAsB,eAAe;CAEpC;AAFD,0CAEC"}
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"}