@nathapp/nestjs-notify 0.0.0-stage → 1.1.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 (124) hide show
  1. package/README.md +181 -2
  2. package/dist/constant/index.d.ts +1 -0
  3. package/dist/constant/index.js +18 -0
  4. package/dist/constant/index.js.map +1 -0
  5. package/dist/constant/tokens.d.ts +15 -0
  6. package/dist/constant/tokens.js +28 -0
  7. package/dist/constant/tokens.js.map +1 -0
  8. package/dist/delivery/console-delivery.channel.d.ts +8 -0
  9. package/dist/delivery/console-delivery.channel.js +31 -0
  10. package/dist/delivery/console-delivery.channel.js.map +1 -0
  11. package/dist/delivery/delivery-channel.registry.d.ts +11 -0
  12. package/dist/delivery/delivery-channel.registry.js +35 -0
  13. package/dist/delivery/delivery-channel.registry.js.map +1 -0
  14. package/dist/delivery/index.d.ts +2 -0
  15. package/dist/delivery/index.js +19 -0
  16. package/dist/delivery/index.js.map +1 -0
  17. package/dist/error/index.d.ts +1 -0
  18. package/dist/error/index.js +18 -0
  19. package/dist/error/index.js.map +1 -0
  20. package/dist/error/permanent-notification.error.d.ts +5 -0
  21. package/dist/error/permanent-notification.error.js +52 -0
  22. package/dist/error/permanent-notification.error.js.map +1 -0
  23. package/dist/event/index.d.ts +7 -0
  24. package/dist/event/index.js +10 -0
  25. package/dist/event/index.js.map +1 -0
  26. package/dist/exception/index.d.ts +2 -0
  27. package/dist/exception/index.js +19 -0
  28. package/dist/exception/index.js.map +1 -0
  29. package/dist/exception/notify-exception-code.d.ts +11 -0
  30. package/dist/exception/notify-exception-code.js +28 -0
  31. package/dist/exception/notify-exception-code.js.map +1 -0
  32. package/dist/exception/notify.exception.d.ts +6 -0
  33. package/dist/exception/notify.exception.js +28 -0
  34. package/dist/exception/notify.exception.js.map +1 -0
  35. package/dist/index.d.ts +10 -0
  36. package/dist/index.js +27 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/interface/index.d.ts +4 -0
  39. package/dist/interface/index.js +21 -0
  40. package/dist/interface/index.js.map +1 -0
  41. package/dist/interface/models/delivery-log.interface.d.ts +30 -0
  42. package/dist/interface/models/delivery-log.interface.js +12 -0
  43. package/dist/interface/models/delivery-log.interface.js.map +1 -0
  44. package/dist/interface/models/dlq-job.interface.d.ts +8 -0
  45. package/dist/interface/models/dlq-job.interface.js +3 -0
  46. package/dist/interface/models/dlq-job.interface.js.map +1 -0
  47. package/dist/interface/models/index.d.ts +4 -0
  48. package/dist/interface/models/index.js +21 -0
  49. package/dist/interface/models/index.js.map +1 -0
  50. package/dist/interface/models/preference.interface.d.ts +28 -0
  51. package/dist/interface/models/preference.interface.js +11 -0
  52. package/dist/interface/models/preference.interface.js.map +1 -0
  53. package/dist/interface/models/template.interface.d.ts +29 -0
  54. package/dist/interface/models/template.interface.js +3 -0
  55. package/dist/interface/models/template.interface.js.map +1 -0
  56. package/dist/interface/providers/delivery-channel-provider.interface.d.ts +7 -0
  57. package/dist/interface/providers/delivery-channel-provider.interface.js +3 -0
  58. package/dist/interface/providers/delivery-channel-provider.interface.js.map +1 -0
  59. package/dist/interface/providers/index.d.ts +2 -0
  60. package/dist/interface/providers/index.js +19 -0
  61. package/dist/interface/providers/index.js.map +1 -0
  62. package/dist/interface/providers/provider-event-normalizer.interface.d.ts +4 -0
  63. package/dist/interface/providers/provider-event-normalizer.interface.js +10 -0
  64. package/dist/interface/providers/provider-event-normalizer.interface.js.map +1 -0
  65. package/dist/interface/repositories/delivery-log-repository.interface.d.ts +9 -0
  66. package/dist/interface/repositories/delivery-log-repository.interface.js +3 -0
  67. package/dist/interface/repositories/delivery-log-repository.interface.js.map +1 -0
  68. package/dist/interface/repositories/index.d.ts +3 -0
  69. package/dist/interface/repositories/index.js +20 -0
  70. package/dist/interface/repositories/index.js.map +1 -0
  71. package/dist/interface/repositories/preference-repository.interface.d.ts +7 -0
  72. package/dist/interface/repositories/preference-repository.interface.js +3 -0
  73. package/dist/interface/repositories/preference-repository.interface.js.map +1 -0
  74. package/dist/interface/repositories/template-repository.interface.d.ts +7 -0
  75. package/dist/interface/repositories/template-repository.interface.js +3 -0
  76. package/dist/interface/repositories/template-repository.interface.js.map +1 -0
  77. package/dist/interface/services/delivery-tracker.interface.d.ts +20 -0
  78. package/dist/interface/services/delivery-tracker.interface.js +15 -0
  79. package/dist/interface/services/delivery-tracker.interface.js.map +1 -0
  80. package/dist/interface/services/dlq-service.interface.d.ts +8 -0
  81. package/dist/interface/services/dlq-service.interface.js +3 -0
  82. package/dist/interface/services/dlq-service.interface.js.map +1 -0
  83. package/dist/interface/services/index.d.ts +48 -0
  84. package/dist/interface/services/index.js +19 -0
  85. package/dist/interface/services/index.js.map +1 -0
  86. package/dist/module/index.d.ts +30 -0
  87. package/dist/module/index.js +191 -0
  88. package/dist/module/index.js.map +1 -0
  89. package/dist/processor/index.d.ts +1 -0
  90. package/dist/processor/index.js +18 -0
  91. package/dist/processor/index.js.map +1 -0
  92. package/dist/processor/notification.processor.d.ts +14 -0
  93. package/dist/processor/notification.processor.js +101 -0
  94. package/dist/processor/notification.processor.js.map +1 -0
  95. package/dist/service/default-delivery-tracker.service.d.ts +11 -0
  96. package/dist/service/default-delivery-tracker.service.js +124 -0
  97. package/dist/service/default-delivery-tracker.service.js.map +1 -0
  98. package/dist/service/default-dlq.service.d.ts +16 -0
  99. package/dist/service/default-dlq.service.js +86 -0
  100. package/dist/service/default-dlq.service.js.map +1 -0
  101. package/dist/service/default-notify.service.d.ts +23 -0
  102. package/dist/service/default-notify.service.js +168 -0
  103. package/dist/service/default-notify.service.js.map +1 -0
  104. package/dist/service/default-preference.service.d.ts +15 -0
  105. package/dist/service/default-preference.service.js +57 -0
  106. package/dist/service/default-preference.service.js.map +1 -0
  107. package/dist/service/default-template.service.d.ts +36 -0
  108. package/dist/service/default-template.service.js +142 -0
  109. package/dist/service/default-template.service.js.map +1 -0
  110. package/dist/service/index.d.ts +5 -0
  111. package/dist/service/index.js +22 -0
  112. package/dist/service/index.js.map +1 -0
  113. package/dist/template/handlebars-template.engine.d.ts +8 -0
  114. package/dist/template/handlebars-template.engine.js +37 -0
  115. package/dist/template/handlebars-template.engine.js.map +1 -0
  116. package/dist/template/index.d.ts +15 -0
  117. package/dist/template/index.js +50 -0
  118. package/dist/template/index.js.map +1 -0
  119. package/dist/template/template-cache.d.ts +27 -0
  120. package/dist/template/template-cache.js +65 -0
  121. package/dist/template/template-cache.js.map +1 -0
  122. package/i18n/en/notify.json +14 -0
  123. package/i18n/zh/notify.json +14 -0
  124. package/package.json +49 -4
package/README.md CHANGED
@@ -1,3 +1,182 @@
1
- # Temporary Holding Version
1
+ # @nathapp/nestjs-notify
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Notification **management** for NestJS: templates, per-user/per-tenant preferences,
4
+ delivery channels, and delivery tracking. It orchestrates *when* and *how* a
5
+ notification is sent; the actual transport (email/SMS/push) is provided by a
6
+ delivery channel — either one you register, or `ConsoleDeliveryChannel` for
7
+ development.
8
+
9
+ - **Templates** — register and render content with a pluggable `ITemplateEngine`
10
+ (an HTML-escaping `SimpleTemplateEngine` ships by default).
11
+ - **Preferences** — per `(userId, tenantId, channel)` opt-in/out, with a
12
+ `metadata` bag for richer state (e.g. consent).
13
+ - **Delivery channels** — pluggable adapters keyed by a channel string. The
14
+ package ships no transport of its own except a dev-only console logger.
15
+ - **Delivery tracking** — `IDeliveryTracker` records normalized delivery events
16
+ you feed it from provider webhooks.
17
+
18
+ This package is ORM-agnostic: the core defines repository interfaces, and the
19
+ `@nathapp/nestjs-notify-prisma` package supplies Prisma implementations.
20
+
21
+ ## Built-in channels
22
+
23
+ `NotificationChannel` enumerates four channels. Note the **lowercase** string
24
+ values:
25
+
26
+ | Member | Value | Delivery adapter shipped? |
27
+ | --- | --- | --- |
28
+ | `NotificationChannel.EMAIL` | `'email'` | No transport in this package |
29
+ | `NotificationChannel.PUSH` | `'push'` | No transport in this package |
30
+ | `NotificationChannel.SMS` | `'sms'` | No transport in this package |
31
+ | `NotificationChannel.IN_APP` | `'in_app'` | **No** — in-app delivery is entirely the consumer's concern |
32
+
33
+ `IN_APP` ships **no** delivery adapter. If you send on `IN_APP` you must register
34
+ your own channel for it (or accept the `CHANNEL_NOT_REGISTERED` error).
35
+
36
+ `ConsoleDeliveryChannel` is a development/testing adapter that logs the channel
37
+ name and template code to stdout instead of sending. It reads no recipient or
38
+ rendered content. It **defaults to `EMAIL`** (`new ConsoleDeliveryChannel()`
39
+ registers as `'email'`), but the constructor accepts any channel name, e.g.
40
+ `new ConsoleDeliveryChannel('sms')`. Do not register it in production.
41
+
42
+ ## Registering a custom channel
43
+
44
+ A channel is any `@Injectable()` class implementing `IDeliveryChannel` — a
45
+ `channel` name plus a `send()` method. Register it under `deliveryChannels`,
46
+ passing an `IDeliveryChannelProvider` (`{ channel, provider }`) so Nest can
47
+ instantiate it with full DI:
48
+
49
+ ```ts
50
+ import {
51
+ IDeliveryChannel,
52
+ NotificationChannelLike,
53
+ NotifyModule,
54
+ SendNotificationPayload,
55
+ } from '@nathapp/nestjs-notify';
56
+ import { Injectable, Module } from '@nestjs/common';
57
+
58
+ @Injectable()
59
+ export class WechatMpDeliveryChannel implements IDeliveryChannel {
60
+ readonly channel: NotificationChannelLike = 'wechat_mp';
61
+
62
+ async send(
63
+ payload: SendNotificationPayload,
64
+ renderedContent: string,
65
+ renderedSubject?: string,
66
+ ): Promise<void> {
67
+ // call the WeChat subscribeMessage API
68
+ }
69
+ }
70
+
71
+ @Module({
72
+ imports: [
73
+ NotifyModule.register({
74
+ deliveryChannels: [{ channel: 'wechat_mp', provider: WechatMpDeliveryChannel }],
75
+ }),
76
+ ],
77
+ })
78
+ export class AppModule {}
79
+ ```
80
+
81
+ `channel` on the instance and `channel` in the provider entry must be the same
82
+ string; the module uses the provider entry to build the DI injection token and
83
+ the instance's own `channel` as the registry key.
84
+
85
+ ## Case sensitivity
86
+
87
+ Channel keys are **case- and separator-sensitive, end to end**. The DI token key
88
+ (`getDeliveryChannelToken`) and the `DeliveryChannelRegistry` `Map` key are both
89
+ the **raw channel string**, byte for byte. Therefore:
90
+
91
+ - `'EMAIL'` and `'email'` are **two different channels** with two different DI
92
+ tokens and two different registry entries.
93
+ - `'wechat-mp'` and `'wechat_mp'` are **two different channels** (as they always
94
+ were — the separator is never normalized).
95
+
96
+ History: `getDeliveryChannelToken` previously upper-cased the channel when
97
+ building its cache key, which folded **case** variants onto a single token
98
+ (`'EMAIL'` and `'email'` both became `DELIVERY_CHANNEL_EMAIL`). That case folding
99
+ has been fixed to raw-string keying. Separator variants were never collapsed.
100
+ Prefer the `NotificationChannel` enum members or a single lower-case convention
101
+ in your own code.
102
+
103
+ ## The typo hazard
104
+
105
+ Because `NotificationChannelLike` is `NotificationChannel | (string & Record<never, never>)`, a
106
+ mistyped channel name is **no longer a compile error** — the widened type
107
+ deliberately accepts arbitrary strings. Two failure modes follow:
108
+
109
+ 1. **At send time:** sending on an unregistered channel throws
110
+ `NotifyException(NotifyExceptionCode.CHANNEL_NOT_REGISTERED)` → HTTP **400**.
111
+ 2. **Worse, silently:** `DefaultPreferenceService.updatePreference` delegates to
112
+ `IPreferenceRepository.upsertByUserAndChannel`, whose Prisma implementation
113
+ uses `update: { enabled }`. Saving a preference under a wrong channel does not
114
+ error — it upserts a row for that (wrong) channel key, and on a subsequent
115
+ call with the same wrong key **overwrites** the existing row's `enabled`
116
+ rather than surfacing the mistake.
117
+
118
+ If your code accepts **user-supplied** channel names, validate them against the
119
+ registry before persisting or sending:
120
+
121
+ ```ts
122
+ import { BadRequestException, Inject } from '@nestjs/common';
123
+ import { DELIVERY_CHANNEL_REGISTRY, DeliveryChannelRegistry } from '@nathapp/nestjs-notify';
124
+
125
+ constructor(
126
+ @Inject(DELIVERY_CHANNEL_REGISTRY) private readonly registry: DeliveryChannelRegistry,
127
+ ) {}
128
+
129
+ setPreference(userId: string, tenantId: string, channel: string, enabled: boolean) {
130
+ if (!this.registry.has(channel)) {
131
+ throw new BadRequestException(`Unknown notification channel: ${channel}`);
132
+ }
133
+ return this.preferenceService.updatePreference(userId, tenantId, channel, enabled);
134
+ }
135
+ ```
136
+
137
+ ## Preferences
138
+
139
+ A preference is keyed by `@@unique([userId, tenantId, channel])`, so there is at
140
+ most one row per user, tenant, and channel. Each row carries an `enabled: boolean`
141
+ and an optional `metadata: Record<string, any>`.
142
+
143
+ `metadata` is where **consent state** belongs. A boolean `enabled` alone cannot
144
+ model consent-gated transports: WeChat mini-program subscribe messages, for
145
+ example, require per-message user consent that can be `pending`, `granted`, or
146
+ `revoked`, and often carries a consent timestamp or scope token. Store that in
147
+ `metadata` alongside `enabled`.
148
+
149
+ Note: the shipped defaults **ignore `metadata` on write** —
150
+ `DefaultPreferenceService.updatePreference` hardcodes `metadata: {}`, and the
151
+ Prisma repository's `upsertByUserAndChannel` updates only `{ enabled }`. To
152
+ persist consent state in `metadata`, override the default preference service
153
+ (and/or repository) with an implementation that accepts and writes it.
154
+
155
+ ## No controllers ship
156
+
157
+ This package exposes services, module registration, and interfaces only. It
158
+ ships **no controllers and no DTOs**. Validating a channel name, authorizing the
159
+ caller, shaping request bodies, and deciding which channels a user may configure
160
+ are all the consumer's responsibility.
161
+
162
+ ## Queue processing
163
+
164
+ When enabling the notification processor, import the configured queue module
165
+ inside NotifyModule so its QueueService can resolve in the notification module.
166
+ A sibling import alone does not expose a non-global queue provider.
167
+
168
+ ```ts
169
+ const queue = QueueModule.register({
170
+ provider: QueueProviderType.BULLMQ,
171
+ options: { connection: { host: 'localhost', port: 6379 } },
172
+ });
173
+
174
+ NotifyModule.register({
175
+ enableProcessor: true,
176
+ imports: [queue],
177
+ });
178
+ ```
179
+
180
+ Import QueueModule and QueueProviderType from `@nathapp/nestjs-queue`.
181
+ For asynchronous registration, pass the same module in
182
+ `NotifyModule.registerAsync({ imports: [queue], ... })`.
@@ -0,0 +1 @@
1
+ export * from './tokens';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./tokens"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/constant/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
@@ -0,0 +1,15 @@
1
+ import type { NotificationChannelLike } from '../interface/models';
2
+ export declare const TEMPLATE_REPOSITORY: unique symbol;
3
+ export declare const PREFERENCE_REPOSITORY: unique symbol;
4
+ export declare const DELIVERY_LOG_REPOSITORY: unique symbol;
5
+ export declare const NOTIFY_SERVICE: unique symbol;
6
+ export declare const TEMPLATE_SERVICE: unique symbol;
7
+ export declare const TEMPLATE_ENGINE: unique symbol;
8
+ export declare const PREFERENCE_SERVICE: unique symbol;
9
+ export declare const DLQ_SERVICE: unique symbol;
10
+ export declare const DELIVERY_CHANNEL_REGISTRY: unique symbol;
11
+ export declare const DELIVERY_TRACKER: unique symbol;
12
+ export declare const PROVIDER_EVENT_NORMALIZER: unique symbol;
13
+ export declare const NOTIFICATION_QUEUE_NAME = "notifications";
14
+ export declare const NOTIFY_MODULE_OPTIONS: unique symbol;
15
+ export declare function getDeliveryChannelToken(channel: NotificationChannelLike): symbol;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NOTIFY_MODULE_OPTIONS = exports.NOTIFICATION_QUEUE_NAME = exports.PROVIDER_EVENT_NORMALIZER = exports.DELIVERY_TRACKER = exports.DELIVERY_CHANNEL_REGISTRY = exports.DLQ_SERVICE = exports.PREFERENCE_SERVICE = exports.TEMPLATE_ENGINE = exports.TEMPLATE_SERVICE = exports.NOTIFY_SERVICE = exports.DELIVERY_LOG_REPOSITORY = exports.PREFERENCE_REPOSITORY = exports.TEMPLATE_REPOSITORY = void 0;
4
+ exports.getDeliveryChannelToken = getDeliveryChannelToken;
5
+ exports.TEMPLATE_REPOSITORY = Symbol('TEMPLATE_REPOSITORY');
6
+ exports.PREFERENCE_REPOSITORY = Symbol('PREFERENCE_REPOSITORY');
7
+ exports.DELIVERY_LOG_REPOSITORY = Symbol('DELIVERY_LOG_REPOSITORY');
8
+ exports.NOTIFY_SERVICE = Symbol('NOTIFY_SERVICE');
9
+ exports.TEMPLATE_SERVICE = Symbol('TEMPLATE_SERVICE');
10
+ exports.TEMPLATE_ENGINE = Symbol('TEMPLATE_ENGINE');
11
+ exports.PREFERENCE_SERVICE = Symbol('PREFERENCE_SERVICE');
12
+ exports.DLQ_SERVICE = Symbol('DLQ_SERVICE');
13
+ exports.DELIVERY_CHANNEL_REGISTRY = Symbol('DELIVERY_CHANNEL_REGISTRY');
14
+ exports.DELIVERY_TRACKER = Symbol('DELIVERY_TRACKER');
15
+ exports.PROVIDER_EVENT_NORMALIZER = Symbol('PROVIDER_EVENT_NORMALIZER');
16
+ exports.NOTIFICATION_QUEUE_NAME = 'notifications';
17
+ exports.NOTIFY_MODULE_OPTIONS = Symbol('NOTIFY_MODULE_OPTIONS');
18
+ const deliveryChannelTokenCache = new Map();
19
+ function getDeliveryChannelToken(channel) {
20
+ const key = `DELIVERY_CHANNEL_${channel}`;
21
+ let token = deliveryChannelTokenCache.get(key);
22
+ if (!token) {
23
+ token = Symbol(key);
24
+ deliveryChannelTokenCache.set(key, token);
25
+ }
26
+ return token;
27
+ }
28
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../lib/constant/tokens.ts"],"names":[],"mappings":";;;AAkCA,0DAQC;AAxCY,QAAA,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AACpD,QAAA,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AACxD,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAE5D,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC1C,QAAA,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAC9C,QAAA,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAC5C,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAClD,QAAA,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AACpC,QAAA,yBAAyB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAChE,QAAA,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAC9C,QAAA,yBAAyB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAEhE,QAAA,uBAAuB,GAAG,eAAe,CAAC;AAE1C,QAAA,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAErE,MAAM,yBAAyB,GAAG,IAAI,GAAG,EAAkB,CAAC;AAe5D,SAAgB,uBAAuB,CAAC,OAAgC;IACtE,MAAM,GAAG,GAAG,oBAAoB,OAAO,EAAE,CAAC;IAC1C,IAAI,KAAK,GAAG,yBAAyB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QACpB,yBAAyB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { NotificationChannelLike } from '../interface/models';
2
+ import type { IDeliveryChannel, SendNotificationPayload } from '../interface/services';
3
+ export declare class ConsoleDeliveryChannel implements IDeliveryChannel {
4
+ readonly channel: NotificationChannelLike;
5
+ private readonly logger;
6
+ constructor(channel?: NotificationChannelLike);
7
+ send(payload: SendNotificationPayload, _renderedContent: string, _renderedSubject?: string): Promise<void>;
8
+ }
@@ -0,0 +1,31 @@
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 ConsoleDeliveryChannel_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ConsoleDeliveryChannel = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const models_1 = require("../interface/models");
16
+ let ConsoleDeliveryChannel = ConsoleDeliveryChannel_1 = class ConsoleDeliveryChannel {
17
+ constructor(channel = models_1.NotificationChannel.EMAIL) {
18
+ this.logger = new common_1.Logger(ConsoleDeliveryChannel_1.name);
19
+ this.channel = channel;
20
+ }
21
+ async send(payload, _renderedContent, _renderedSubject) {
22
+ var _a;
23
+ this.logger.log(`[${payload.channel}] template: ${(_a = payload.templateCode) !== null && _a !== void 0 ? _a : '(none)'}`);
24
+ }
25
+ };
26
+ exports.ConsoleDeliveryChannel = ConsoleDeliveryChannel;
27
+ exports.ConsoleDeliveryChannel = ConsoleDeliveryChannel = ConsoleDeliveryChannel_1 = __decorate([
28
+ (0, common_1.Injectable)(),
29
+ __metadata("design:paramtypes", [String])
30
+ ], ConsoleDeliveryChannel);
31
+ //# sourceMappingURL=console-delivery.channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-delivery.channel.js","sourceRoot":"","sources":["../../lib/delivery/console-delivery.channel.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,gDAA0D;AAcnD,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAIjC,YAAY,UAAmC,4BAAmB,CAAC,KAAK;QAFvD,WAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;QAGhE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI,CACR,OAAgC,EAChC,gBAAwB,EACxB,gBAAyB;;QAEzB,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,IAAI,OAAO,CAAC,OAAO,eAAe,MAAA,OAAO,CAAC,YAAY,mCAAI,QAAQ,EAAE,CACrE,CAAC;IACJ,CAAC;CACF,CAAA;AAjBY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;;GACA,sBAAsB,CAiBlC"}
@@ -0,0 +1,11 @@
1
+ import { Logger } from '@nestjs/common';
2
+ import type { IDeliveryChannel } from '../interface/services';
3
+ import type { NotificationChannelLike } from '../interface/models';
4
+ export declare class DeliveryChannelRegistry {
5
+ protected readonly logger: Logger;
6
+ private readonly channels;
7
+ register(channel: IDeliveryChannel): void;
8
+ get(channel: NotificationChannelLike): IDeliveryChannel | undefined;
9
+ has(channel: NotificationChannelLike): boolean;
10
+ getAll(): IDeliveryChannel[];
11
+ }
@@ -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 DeliveryChannelRegistry_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.DeliveryChannelRegistry = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ let DeliveryChannelRegistry = DeliveryChannelRegistry_1 = class DeliveryChannelRegistry {
13
+ constructor() {
14
+ this.logger = new common_1.Logger(DeliveryChannelRegistry_1.name);
15
+ this.channels = new Map();
16
+ }
17
+ register(channel) {
18
+ this.channels.set(channel.channel, channel);
19
+ this.logger.log(`Registered delivery channel: ${channel.channel}`);
20
+ }
21
+ get(channel) {
22
+ return this.channels.get(channel);
23
+ }
24
+ has(channel) {
25
+ return this.channels.has(channel);
26
+ }
27
+ getAll() {
28
+ return Array.from(this.channels.values());
29
+ }
30
+ };
31
+ exports.DeliveryChannelRegistry = DeliveryChannelRegistry;
32
+ exports.DeliveryChannelRegistry = DeliveryChannelRegistry = DeliveryChannelRegistry_1 = __decorate([
33
+ (0, common_1.Injectable)()
34
+ ], DeliveryChannelRegistry);
35
+ //# sourceMappingURL=delivery-channel.registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-channel.registry.js","sourceRoot":"","sources":["../../lib/delivery/delivery-channel.registry.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAK7C,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IAA7B;QACc,WAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;QACpD,aAAQ,GAAG,IAAI,GAAG,EAA6C,CAAC;IAkBnF,CAAC;IAhBC,QAAQ,CAAC,OAAyB;QAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gCAAgC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,GAAG,CAAC,OAAgC;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,GAAG,CAAC,OAAgC;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF,CAAA;AApBY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;GACA,uBAAuB,CAoBnC"}
@@ -0,0 +1,2 @@
1
+ export * from './console-delivery.channel';
2
+ export * from './delivery-channel.registry';
@@ -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("./console-delivery.channel"), exports);
18
+ __exportStar(require("./delivery-channel.registry"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/delivery/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,8DAA4C"}
@@ -0,0 +1 @@
1
+ export * from './permanent-notification.error';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./permanent-notification.error"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C"}
@@ -0,0 +1,5 @@
1
+ export declare class PermanentNotificationError extends Error {
2
+ readonly originalError?: Error | undefined;
3
+ constructor(message: string, originalError?: Error | undefined);
4
+ }
5
+ export declare function isRetryableError(error: Error): boolean;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PermanentNotificationError = void 0;
4
+ exports.isRetryableError = isRetryableError;
5
+ class PermanentNotificationError extends Error {
6
+ constructor(message, originalError) {
7
+ super(message);
8
+ this.originalError = originalError;
9
+ this.name = 'PermanentNotificationError';
10
+ Object.setPrototypeOf(this, PermanentNotificationError.prototype);
11
+ }
12
+ }
13
+ exports.PermanentNotificationError = PermanentNotificationError;
14
+ function isRetryableError(error) {
15
+ if (error instanceof PermanentNotificationError) {
16
+ return false;
17
+ }
18
+ const message = error.message.toLowerCase();
19
+ const permanentPatterns = [
20
+ 'invalid email',
21
+ 'invalid phone',
22
+ 'validation failed',
23
+ 'missing required field',
24
+ 'invalid template',
25
+ 'unauthorized',
26
+ 'forbidden',
27
+ 'invalid api key',
28
+ ];
29
+ for (const pattern of permanentPatterns) {
30
+ if (message.includes(pattern)) {
31
+ return false;
32
+ }
33
+ }
34
+ const retryablePatterns = [
35
+ 'timeout',
36
+ 'rate limit',
37
+ 'too many requests',
38
+ 'service unavailable',
39
+ 'connection refused',
40
+ 'econnrefused',
41
+ 'etimedout',
42
+ 'network error',
43
+ 'temporary failure',
44
+ ];
45
+ for (const pattern of retryablePatterns) {
46
+ if (message.includes(pattern)) {
47
+ return true;
48
+ }
49
+ }
50
+ return true;
51
+ }
52
+ //# sourceMappingURL=permanent-notification.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permanent-notification.error.js","sourceRoot":"","sources":["../../lib/error/permanent-notification.error.ts"],"names":[],"mappings":";;;AAgCA,4CA+CC;AA3ED,MAAa,0BAA2B,SAAQ,KAAK;IACnD,YACE,OAAe,EACC,aAAqB;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,kBAAa,GAAb,aAAa,CAAQ;QAGrC,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,0BAA0B,CAAC,SAAS,CAAC,CAAC;IACpE,CAAC;CACF;AATD,gEASC;AAmBD,SAAgB,gBAAgB,CAAC,KAAY;IAE3C,IAAI,KAAK,YAAY,0BAA0B,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IAG5C,MAAM,iBAAiB,GAAG;QACxB,eAAe;QACf,eAAe;QACf,mBAAmB;QACnB,wBAAwB;QACxB,kBAAkB;QAClB,cAAc;QACd,WAAW;QACX,iBAAiB;KAClB,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACxC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAGD,MAAM,iBAAiB,GAAG;QACxB,SAAS;QACT,YAAY;QACZ,mBAAmB;QACnB,qBAAqB;QACrB,oBAAoB;QACpB,cAAc;QACd,WAAW;QACX,eAAe;QACf,mBAAmB;KACpB,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACxC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAGD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const NotifyEvents: {
2
+ readonly NOTIFICATION_SENT: "notify.notification.sent";
3
+ readonly NOTIFICATION_FAILED: "notify.notification.failed";
4
+ readonly NOTIFICATION_DELIVERED: "notify.notification.delivered";
5
+ readonly NOTIFICATION_BOUNCED: "notify.notification.bounced";
6
+ };
7
+ export type NotifyEventName = (typeof NotifyEvents)[keyof typeof NotifyEvents];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotifyEvents = void 0;
4
+ exports.NotifyEvents = {
5
+ NOTIFICATION_SENT: 'notify.notification.sent',
6
+ NOTIFICATION_FAILED: 'notify.notification.failed',
7
+ NOTIFICATION_DELIVERED: 'notify.notification.delivered',
8
+ NOTIFICATION_BOUNCED: 'notify.notification.bounced',
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/event/index.ts"],"names":[],"mappings":";;;AAIa,QAAA,YAAY,GAAG;IAC1B,iBAAiB,EAAE,0BAA0B;IAC7C,mBAAmB,EAAE,4BAA4B;IACjD,sBAAsB,EAAE,+BAA+B;IACvD,oBAAoB,EAAE,6BAA6B;CAC3C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './notify-exception-code';
2
+ export * from './notify.exception';
@@ -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("./notify-exception-code"), exports);
18
+ __exportStar(require("./notify.exception"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/exception/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,qDAAmC"}
@@ -0,0 +1,11 @@
1
+ export declare enum NotifyExceptionCode {
2
+ TEMPLATE_NOT_FOUND = 23001,
3
+ TEMPLATE_INVALID_SYNTAX = 23002,
4
+ TEMPLATE_RENDER_FAILED = 23003,
5
+ PREFERENCE_NOT_FOUND = 23011,
6
+ CHANNEL_DISABLED = 23012,
7
+ CHANNEL_NOT_REGISTERED = 23013,
8
+ DELIVERY_FAILED = 23021,
9
+ DELIVERY_PERMANENT_FAILURE = 23022,
10
+ TENANT_MISMATCH = 23031
11
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotifyExceptionCode = void 0;
4
+ var NotifyExceptionCode;
5
+ (function (NotifyExceptionCode) {
6
+ NotifyExceptionCode[NotifyExceptionCode["TEMPLATE_NOT_FOUND"] = 23001] = "TEMPLATE_NOT_FOUND";
7
+ NotifyExceptionCode[NotifyExceptionCode["TEMPLATE_INVALID_SYNTAX"] = 23002] = "TEMPLATE_INVALID_SYNTAX";
8
+ NotifyExceptionCode[NotifyExceptionCode["TEMPLATE_RENDER_FAILED"] = 23003] = "TEMPLATE_RENDER_FAILED";
9
+ NotifyExceptionCode[NotifyExceptionCode["PREFERENCE_NOT_FOUND"] = 23011] = "PREFERENCE_NOT_FOUND";
10
+ NotifyExceptionCode[NotifyExceptionCode["CHANNEL_DISABLED"] = 23012] = "CHANNEL_DISABLED";
11
+ NotifyExceptionCode[NotifyExceptionCode["CHANNEL_NOT_REGISTERED"] = 23013] = "CHANNEL_NOT_REGISTERED";
12
+ NotifyExceptionCode[NotifyExceptionCode["DELIVERY_FAILED"] = 23021] = "DELIVERY_FAILED";
13
+ NotifyExceptionCode[NotifyExceptionCode["DELIVERY_PERMANENT_FAILURE"] = 23022] = "DELIVERY_PERMANENT_FAILURE";
14
+ NotifyExceptionCode[NotifyExceptionCode["TENANT_MISMATCH"] = 23031] = "TENANT_MISMATCH";
15
+ })(NotifyExceptionCode || (exports.NotifyExceptionCode = NotifyExceptionCode = {}));
16
+ const _EXHAUSTIVE_CHECK = {
17
+ [NotifyExceptionCode.TEMPLATE_NOT_FOUND]: true,
18
+ [NotifyExceptionCode.TEMPLATE_INVALID_SYNTAX]: true,
19
+ [NotifyExceptionCode.TEMPLATE_RENDER_FAILED]: true,
20
+ [NotifyExceptionCode.PREFERENCE_NOT_FOUND]: true,
21
+ [NotifyExceptionCode.CHANNEL_DISABLED]: true,
22
+ [NotifyExceptionCode.CHANNEL_NOT_REGISTERED]: true,
23
+ [NotifyExceptionCode.DELIVERY_FAILED]: true,
24
+ [NotifyExceptionCode.DELIVERY_PERMANENT_FAILURE]: true,
25
+ [NotifyExceptionCode.TENANT_MISMATCH]: true,
26
+ };
27
+ void _EXHAUSTIVE_CHECK;
28
+ //# sourceMappingURL=notify-exception-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notify-exception-code.js","sourceRoot":"","sources":["../../lib/exception/notify-exception-code.ts"],"names":[],"mappings":";;;AAAA,IAAY,mBAiBX;AAjBD,WAAY,mBAAmB;IAE7B,6FAA0B,CAAA;IAC1B,uGAA+B,CAAA;IAC/B,qGAA8B,CAAA;IAG9B,iGAA4B,CAAA;IAC5B,yFAAwB,CAAA;IACxB,qGAA8B,CAAA;IAG9B,uFAAuB,CAAA;IACvB,6GAAkC,CAAA;IAGlC,uFAAuB,CAAA;AACzB,CAAC,EAjBW,mBAAmB,mCAAnB,mBAAmB,QAiB9B;AAED,MAAM,iBAAiB,GAAsC;IAC3D,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,IAAI;IAC9C,CAAC,mBAAmB,CAAC,uBAAuB,CAAC,EAAE,IAAI;IACnD,CAAC,mBAAmB,CAAC,sBAAsB,CAAC,EAAE,IAAI;IAClD,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,EAAE,IAAI;IAChD,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,IAAI;IAC5C,CAAC,mBAAmB,CAAC,sBAAsB,CAAC,EAAE,IAAI;IAClD,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE,IAAI;IAC3C,CAAC,mBAAmB,CAAC,0BAA0B,CAAC,EAAE,IAAI;IACtD,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE,IAAI;CAC5C,CAAC;AACF,KAAK,iBAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { AppException, AppExceptionArgs } from '@nathapp/nestjs-common';
2
+ import { NotifyExceptionCode } from './notify-exception-code';
3
+ export declare const NOTIFY_I18N_PREFIX = "notify";
4
+ export declare class NotifyException extends AppException {
5
+ constructor(code: NotifyExceptionCode, args?: AppExceptionArgs);
6
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotifyException = exports.NOTIFY_I18N_PREFIX = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const nestjs_common_1 = require("@nathapp/nestjs-common");
6
+ const notify_exception_code_1 = require("./notify-exception-code");
7
+ exports.NOTIFY_I18N_PREFIX = 'notify';
8
+ const NOTIFY_HTTP_STATUS = {
9
+ [notify_exception_code_1.NotifyExceptionCode.TEMPLATE_NOT_FOUND]: common_1.HttpStatus.NOT_FOUND,
10
+ [notify_exception_code_1.NotifyExceptionCode.TEMPLATE_INVALID_SYNTAX]: common_1.HttpStatus.BAD_REQUEST,
11
+ [notify_exception_code_1.NotifyExceptionCode.TEMPLATE_RENDER_FAILED]: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
12
+ [notify_exception_code_1.NotifyExceptionCode.PREFERENCE_NOT_FOUND]: common_1.HttpStatus.NOT_FOUND,
13
+ [notify_exception_code_1.NotifyExceptionCode.CHANNEL_DISABLED]: common_1.HttpStatus.BAD_REQUEST,
14
+ [notify_exception_code_1.NotifyExceptionCode.CHANNEL_NOT_REGISTERED]: common_1.HttpStatus.BAD_REQUEST,
15
+ [notify_exception_code_1.NotifyExceptionCode.DELIVERY_FAILED]: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
16
+ [notify_exception_code_1.NotifyExceptionCode.DELIVERY_PERMANENT_FAILURE]: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
17
+ [notify_exception_code_1.NotifyExceptionCode.TENANT_MISMATCH]: common_1.HttpStatus.FORBIDDEN,
18
+ };
19
+ const _HTTP_STATUS_EXHAUSTIVE = NOTIFY_HTTP_STATUS;
20
+ void _HTTP_STATUS_EXHAUSTIVE;
21
+ class NotifyException extends nestjs_common_1.AppException {
22
+ constructor(code, args) {
23
+ var _a;
24
+ super(code, args, exports.NOTIFY_I18N_PREFIX, (_a = NOTIFY_HTTP_STATUS[code]) !== null && _a !== void 0 ? _a : common_1.HttpStatus.INTERNAL_SERVER_ERROR);
25
+ }
26
+ }
27
+ exports.NotifyException = NotifyException;
28
+ //# sourceMappingURL=notify.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notify.exception.js","sourceRoot":"","sources":["../../lib/exception/notify.exception.ts"],"names":[],"mappings":";;;AAAA,2CAA4C;AAC5C,0DAAwE;AACxE,mEAA8D;AAEjD,QAAA,kBAAkB,GAAG,QAAQ,CAAC;AAE3C,MAAM,kBAAkB,GAAwC;IAC9D,CAAC,2CAAmB,CAAC,kBAAkB,CAAC,EAAE,mBAAU,CAAC,SAAS;IAC9D,CAAC,2CAAmB,CAAC,uBAAuB,CAAC,EAAE,mBAAU,CAAC,WAAW;IACrE,CAAC,2CAAmB,CAAC,sBAAsB,CAAC,EAAE,mBAAU,CAAC,qBAAqB;IAE9E,CAAC,2CAAmB,CAAC,oBAAoB,CAAC,EAAE,mBAAU,CAAC,SAAS;IAChE,CAAC,2CAAmB,CAAC,gBAAgB,CAAC,EAAE,mBAAU,CAAC,WAAW;IAC9D,CAAC,2CAAmB,CAAC,sBAAsB,CAAC,EAAE,mBAAU,CAAC,WAAW;IAEpE,CAAC,2CAAmB,CAAC,eAAe,CAAC,EAAE,mBAAU,CAAC,qBAAqB;IACvE,CAAC,2CAAmB,CAAC,0BAA0B,CAAC,EAAE,mBAAU,CAAC,qBAAqB;IAElF,CAAC,2CAAmB,CAAC,eAAe,CAAC,EAAE,mBAAU,CAAC,SAAS;CAC5D,CAAC;AAEF,MAAM,uBAAuB,GAAwC,kBAAkB,CAAC;AACxF,KAAK,uBAAuB,CAAC;AAE7B,MAAa,eAAgB,SAAQ,4BAAY;IAC/C,YAAY,IAAyB,EAAE,IAAuB;;QAC5D,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,0BAAkB,EAAE,MAAA,kBAAkB,CAAC,IAAI,CAAC,mCAAI,mBAAU,CAAC,qBAAqB,CAAC,CAAC;IACtG,CAAC;CACF;AAJD,0CAIC"}
@@ -0,0 +1,10 @@
1
+ export * from './interface';
2
+ export * from './constant';
3
+ export * from './exception';
4
+ export * from './event';
5
+ export * from './service';
6
+ export * from './delivery';
7
+ export * from './template';
8
+ export * from './processor';
9
+ export * from './module';
10
+ export * from './error';