@bts-soft/core 2.4.1 → 2.4.3
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.
- package/README.md +45 -100
- package/package.json +3 -3
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:
|
|
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
|
|
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
|
|
178
|
+
All notifications are processed asynchronously using BullMQ and Redis. This architecture provides several critical benefits:
|
|
179
179
|
|
|
180
|
-
1. **Non-Blocking**:
|
|
181
|
-
2. **
|
|
182
|
-
3. **
|
|
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
|
|
186
|
+
### Channel Capabilities (8+ Integrated Protocols)
|
|
193
187
|
|
|
194
|
-
#### 1. Email (
|
|
188
|
+
#### 1. Email (EMAIL)
|
|
195
189
|
- **Technology**: Nodemailer.
|
|
196
|
-
- **Support**: SMTP, SES, Gmail,
|
|
197
|
-
- **
|
|
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 (
|
|
211
|
-
- **Provider**: Twilio WhatsApp API.
|
|
212
|
-
- **Normalizer**:
|
|
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 (
|
|
197
|
+
#### 3. SMS (SMS)
|
|
222
198
|
- **Provider**: Twilio SMS.
|
|
223
|
-
- **
|
|
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 (
|
|
232
|
-
- **Technology**:
|
|
233
|
-
- **Features**:
|
|
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 (
|
|
205
|
+
#### 5. Firebase Push (FIREBASE_FCM)
|
|
244
206
|
- **Technology**: Firebase Admin SDK.
|
|
245
|
-
- **Support**: Android
|
|
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 (
|
|
260
|
-
- **
|
|
261
|
-
- **
|
|
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 (
|
|
273
|
-
- **
|
|
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 (
|
|
283
|
-
- **
|
|
284
|
-
- **Usage**:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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.
|
|
@@ -322,9 +265,11 @@ The system enforces strict validation for file extensions and sizes. Limits can
|
|
|
322
265
|
| **Videos** | `mp4`, `webm`, `avi`, `mov` | 100 MB | Chunked upload support with duration extraction. |
|
|
323
266
|
| **Audio** | `mp3`, `wav`, `ogg`, `m4a` | 50 MB | Optimized for playback and metadata extraction. |
|
|
324
267
|
| **Raw Files** | `pdf`, `doc`, `zip`, `txt` | 10 MB | Stored as 'raw' binary with original headers. |
|
|
268
|
+
| **3D Models** | `glb`, `gltf`, `fbx`, `obj`, `stl` | 100 MB | Stored as binary models with high-capacity limits. |
|
|
325
269
|
|
|
326
270
|
### Configuration Reference
|
|
327
271
|
|
|
272
|
+
|
|
328
273
|
```env
|
|
329
274
|
# Provider Selection
|
|
330
275
|
UPLOAD_PROVIDER=cloudinary # or 'local'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bts-soft/core",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
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,11 +14,11 @@
|
|
|
14
14
|
"prepublishOnly": "npm run build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@bts-soft/notifications": "1.5.
|
|
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",
|
|
21
|
-
"@bts-soft/upload": "1.4.
|
|
21
|
+
"@bts-soft/upload": "1.4.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@nestjs/common": ">=11.0.0",
|