@bts-soft/core 2.4.1 → 2.4.2

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 (2) hide show
  1. package/README.md +43 -100
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -167,130 +167,73 @@ await redisService.publish('system_updates', { status: 'OK', timestamp: Date.now
167
167
 
168
168
  ---
169
169
 
170
- ## Deep Dive: `@bts-soft/notifications`
170
+ ## Deep Dive: @bts-soft/notifications
171
171
 
172
- The notification module is a high-availability delivery engine designed to handle massive volumes of transactional and marketing messages across multiple protocols without slowing down your primary application.
172
+ The notification module is a high-availability delivery engine designed to handle massive volumes of transactional and marketing messages across multiple protocols without impacting primary application performance.
173
173
 
174
174
  ---
175
175
 
176
176
  ### Reliability Engineering: The Queue System
177
177
 
178
- All notifications are processed asynchronously using **BullMQ** and **Redis**. This architecture provides several critical benefits:
178
+ All notifications are processed asynchronously using BullMQ and Redis. This architecture provides several critical benefits:
179
179
 
180
- 1. **Non-Blocking**: Your API returns a 200 OK immediately after the job is queued, without waiting for external APIs (like Twilio or Firebase).
181
- 2. **Strict Retries**: If a provider is down, the system automatically retries with an exponential backoff policy.
182
- 3. **Concurrency Control**: You can limit the number of parallel notifications to avoid hitting external API rate limits.
183
-
184
- #### Backoff Configuration
185
- - **Max Attempts**: 3
186
- - **Strategy**: Exponential
187
- - **Initial Delay**: 5,000ms
188
- - **Progression**: 5s -> 10s -> 20s
180
+ 1. **Non-Blocking Execution**: The API returns a response immediately after the job is queued, decoupling user experience from external provider latency.
181
+ 2. **Categorized Error Handling**: Distinguishes between unrecoverable Client Errors (e.g., invalid data) and temporary Provider Errors (e.g., API downtime), optimizing retry resource allocation.
182
+ 3. **Global Retry Policies**: Integrated with exponential backoff strategies to handle temporary infrastructure failures gracefully.
189
183
 
190
184
  ---
191
185
 
192
- ### Channel Deep-Dive (8+ Integrated Channels)
186
+ ### Channel Capabilities (8+ Integrated Protocols)
193
187
 
194
- #### 1. Email (`EMAIL`)
188
+ #### 1. Email (EMAIL)
195
189
  - **Technology**: Nodemailer.
196
- - **Support**: SMTP, SES, Gmail, Outlook, Mailgun.
197
- - **Example Payload**:
198
- ```typescript
199
- await notificationService.send(ChannelType.EMAIL, {
200
- recipientId: 'user@example.com',
201
- subject: 'Welcome to BTS Soft',
202
- body: 'Thank you for joining our platform.',
203
- channelOptions: {
204
- html: '<h1>Welcome!</h1>', // Optional HTML
205
- attachments: [{ filename: 'terms.pdf', path: './docs/terms.pdf' }]
206
- }
207
- });
208
- ```
190
+ - **Support**: Standard SMTP, SES, Gmail, and custom transport configurations.
191
+ - **Dynamic Overrides**: Support for per-message SMTP configuration and attachments.
209
192
 
210
- #### 2. WhatsApp (`WHATSAPP`)
211
- - **Provider**: Twilio WhatsApp API.
212
- - **Normalizer**: Automatically handles Egyptian and international formats.
213
- - **Example Payload**:
214
- ```typescript
215
- await notificationService.send(ChannelType.WHATSAPP, {
216
- recipientId: '01012345678', // Auto-converts to whatsapp:+201012345678
217
- body: 'Your verification code is 4567'
218
- });
219
- ```
193
+ #### 2. WhatsApp (WHATSAPP)
194
+ - **Provider**: Twilio WhatsApp Business API.
195
+ - **Normalizer**: Automatic handling of regional phone number formats.
220
196
 
221
- #### 3. SMS (`SMS`)
197
+ #### 3. SMS (SMS)
222
198
  - **Provider**: Twilio SMS.
223
- - **Usage**:
224
- ```typescript
225
- await notificationService.send(ChannelType.SMS, {
226
- recipientId: '+201112223344',
227
- body: 'Critical security alert on your account.'
228
- });
229
- ```
199
+ - **Reliability**: Optimized for high-deliverability transactional messaging.
230
200
 
231
- #### 4. Telegram (`TELEGRAM`)
232
- - **Technology**: Telegraf (Telegram Bot API).
233
- - **Features**: Markdown support, link previews.
234
- - **Usage**:
235
- ```typescript
236
- await notificationService.send(ChannelType.TELEGRAM, {
237
- recipientId: 'chat_id_here',
238
- body: '*Important Update*\nClick [here](https://bts-soft.com) to view.',
239
- channelOptions: { parse_mode: 'MarkdownV2' }
240
- });
241
- ```
201
+ #### 4. Telegram (TELEGRAM)
202
+ - **Technology**: Telegram Bot API.
203
+ - **Features**: MarkdownV2 and HTML parsing support, real-time bot integration.
242
204
 
243
- #### 5. Firebase Push (`FIREBASE_FCM`)
205
+ #### 5. Firebase Push (FIREBASE_FCM)
244
206
  - **Technology**: Firebase Admin SDK.
245
- - **Support**: Android, iOS, and Web.
246
- - **Usage**:
247
- ```typescript
248
- await notificationService.send(ChannelType.FIREBASE_FCM, {
249
- recipientId: 'device_fcm_token',
250
- title: 'Order Delivered',
251
- body: 'Your package is at your doorstep.',
252
- channelOptions: {
253
- data: { orderId: '789' },
254
- options: { priority: 'high' }
255
- }
256
- });
257
- ```
207
+ - **Support**: Native Android/iOS push notifications and web push.
258
208
 
259
- #### 6. Discord (`DISCORD`)
260
- - **Logic**: Webhook-based integration.
261
- - **Usage**:
262
- ```typescript
263
- await notificationService.send(ChannelType.DISCORD, {
264
- body: 'New deployment successful!',
265
- channelOptions: {
266
- username: 'BTS Bot',
267
- embeds: [{ title: 'Build Info', color: 3066993 }]
268
- }
269
- });
270
- ```
209
+ #### 6. Discord (DISCORD)
210
+ - **Mechanism**: High-performance Webhook integration.
211
+ - **Customization**: Support for complex embeds and custom bot identities.
271
212
 
272
- #### 7. Microsoft Teams (`TEAMS`)
273
- - **Logic**: Incoming Webhooks (Message Cards).
274
- - **Usage**:
275
- ```typescript
276
- await notificationService.send(ChannelType.TEAMS, {
277
- body: 'New support ticket created.',
278
- channelOptions: { themeColor: '0078D4' }
279
- });
280
- ```
213
+ #### 7. Microsoft Teams (TEAMS)
214
+ - **Mechanism**: Incoming Webhooks using adaptive message cards.
281
215
 
282
- #### 8. Facebook Messenger (`MESSENGER`)
283
- - **Provider**: Graph API.
284
- - **Usage**:
285
- ```typescript
286
- await notificationService.send(ChannelType.MESSENGER, {
287
- recipientId: 'psid_here',
288
- body: 'Hello! How can we help you today?'
289
- });
290
- ```
216
+ #### 8. Facebook Messenger (MESSENGER)
217
+ - **Technology**: Meta Graph API.
218
+ - **Usage**: Support for Page-Scoped IDs (PSID) and standard messaging blocks.
219
+
220
+ ---
221
+
222
+ ### Enterprise Features
223
+
224
+ #### Templating and Localization
225
+ - **Handlebars Engine**: Centralized template rendering for all channels via TemplateService.
226
+ - **Dynamic I18n**: Support for per-recipient language resolution using nestjs-i18n.
227
+ - **Contextual Data**: Pass complex objects to templates for real-time personalization.
228
+
229
+ #### Architecture and Extensibility
230
+ - **Channel Registry**: A plugin-based system that allows for dynamic channel registration and discovery.
231
+ - **BullMQ Priority**: Native support for job priorities (1-100) to ensure critical alerts are processed before marketing broadcasts.
232
+ - **Comprehensive Testing**: Backed by a 100% coverage unit testing suite and standalone Docker-based E2E verification.
291
233
 
292
234
  ---
293
235
 
236
+
294
237
  ## Deep Dive: `@bts-soft/upload`
295
238
 
296
239
  The upload module is a production-hardened media orchestration service designed to handle the complexities of multi-part streams, file validation, and cross-provider storage management.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bts-soft/core",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "author": "Omar Sabry",
5
5
  "description": "All bts-soft packages - meta-package bundling common, cache, validation, upload, and notifications for NestJS.",
6
6
  "main": "dist/index.js",
@@ -14,7 +14,7 @@
14
14
  "prepublishOnly": "npm run build"
15
15
  },
16
16
  "dependencies": {
17
- "@bts-soft/notifications": "1.5.0",
17
+ "@bts-soft/notifications": "1.5.1",
18
18
  "@bts-soft/common": "1.2.8",
19
19
  "@bts-soft/cache": "1.0.9",
20
20
  "@bts-soft/validation": "1.1.4",