@flusys/nestjs-email 1.1.0-beta → 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 (100) hide show
  1. package/README.md +604 -0
  2. package/cjs/config/email.constants.js +0 -18
  3. package/cjs/config/index.js +0 -1
  4. package/cjs/controllers/email-config.controller.js +46 -4
  5. package/cjs/controllers/email-send.controller.js +13 -26
  6. package/cjs/controllers/email-template.controller.js +60 -11
  7. package/cjs/docs/email-swagger.config.js +18 -80
  8. package/cjs/dtos/email-config.dto.js +6 -106
  9. package/cjs/dtos/email-send.dto.js +101 -123
  10. package/cjs/dtos/email-template.dto.js +41 -103
  11. package/cjs/entities/email-config-with-company.entity.js +2 -2
  12. package/cjs/entities/email-config.entity.js +91 -3
  13. package/cjs/entities/email-template-with-company.entity.js +5 -3
  14. package/cjs/entities/email-template.entity.js +119 -3
  15. package/cjs/entities/index.js +34 -19
  16. package/cjs/index.js +1 -0
  17. package/cjs/interfaces/email-provider.interface.js +1 -3
  18. package/cjs/modules/email.module.js +50 -104
  19. package/cjs/providers/email-factory.service.js +37 -109
  20. package/cjs/providers/email-provider.registry.js +5 -15
  21. package/cjs/providers/mailgun-provider.js +54 -58
  22. package/cjs/providers/sendgrid-provider.js +68 -92
  23. package/cjs/providers/smtp-provider.js +58 -69
  24. package/cjs/{config → services}/email-config.service.js +9 -32
  25. package/cjs/services/email-datasource.provider.js +17 -104
  26. package/cjs/services/email-provider-config.service.js +28 -58
  27. package/cjs/services/email-send.service.js +120 -125
  28. package/cjs/services/email-template.service.js +62 -85
  29. package/cjs/services/index.js +2 -1
  30. package/cjs/utils/email-templates.util.js +64 -0
  31. package/cjs/utils/index.js +18 -0
  32. package/config/email.constants.d.ts +0 -9
  33. package/config/index.d.ts +0 -1
  34. package/controllers/email-send.controller.d.ts +5 -12
  35. package/controllers/email-template.controller.d.ts +5 -7
  36. package/dtos/email-config.dto.d.ts +5 -13
  37. package/dtos/email-send.dto.d.ts +17 -21
  38. package/dtos/email-template.dto.d.ts +5 -16
  39. package/entities/email-config-with-company.entity.d.ts +2 -2
  40. package/entities/email-config.entity.d.ts +9 -2
  41. package/entities/email-template-with-company.entity.d.ts +2 -2
  42. package/entities/email-template.entity.d.ts +13 -2
  43. package/entities/index.d.ts +9 -3
  44. package/fesm/config/email.constants.js +0 -9
  45. package/fesm/config/index.js +0 -1
  46. package/fesm/controllers/email-config.controller.js +49 -7
  47. package/fesm/controllers/email-send.controller.js +13 -26
  48. package/fesm/controllers/email-template.controller.js +61 -12
  49. package/fesm/docs/email-swagger.config.js +21 -86
  50. package/fesm/dtos/email-config.dto.js +9 -115
  51. package/fesm/dtos/email-send.dto.js +103 -139
  52. package/fesm/dtos/email-template.dto.js +43 -111
  53. package/fesm/entities/email-config-with-company.entity.js +2 -2
  54. package/fesm/entities/email-config.entity.js +92 -4
  55. package/fesm/entities/email-template-with-company.entity.js +5 -3
  56. package/fesm/entities/email-template.entity.js +120 -4
  57. package/fesm/entities/index.js +22 -16
  58. package/fesm/index.js +1 -0
  59. package/fesm/interfaces/email-config.interface.js +1 -3
  60. package/fesm/interfaces/email-module-options.interface.js +1 -3
  61. package/fesm/interfaces/email-provider.interface.js +1 -5
  62. package/fesm/interfaces/email-template.interface.js +1 -3
  63. package/fesm/modules/email.module.js +52 -106
  64. package/fesm/providers/email-factory.service.js +38 -69
  65. package/fesm/providers/email-provider.registry.js +6 -19
  66. package/fesm/providers/mailgun-provider.js +55 -63
  67. package/fesm/providers/sendgrid-provider.js +69 -97
  68. package/fesm/providers/smtp-provider.js +59 -73
  69. package/fesm/{config → services}/email-config.service.js +9 -32
  70. package/fesm/services/email-datasource.provider.js +18 -64
  71. package/fesm/services/email-provider-config.service.js +26 -56
  72. package/fesm/services/email-send.service.js +118 -123
  73. package/fesm/services/email-template.service.js +60 -83
  74. package/fesm/services/index.js +2 -1
  75. package/fesm/utils/email-templates.util.js +47 -0
  76. package/fesm/utils/index.js +1 -0
  77. package/index.d.ts +1 -0
  78. package/interfaces/email-config.interface.d.ts +6 -0
  79. package/interfaces/email-module-options.interface.d.ts +0 -5
  80. package/modules/email.module.d.ts +1 -2
  81. package/package.json +9 -4
  82. package/providers/email-factory.service.d.ts +4 -7
  83. package/providers/mailgun-provider.d.ts +6 -2
  84. package/providers/sendgrid-provider.d.ts +6 -2
  85. package/providers/smtp-provider.d.ts +7 -2
  86. package/services/email-config.service.d.ts +12 -0
  87. package/services/email-datasource.provider.d.ts +3 -6
  88. package/services/email-provider-config.service.d.ts +3 -3
  89. package/services/email-send.service.d.ts +11 -3
  90. package/services/email-template.service.d.ts +5 -4
  91. package/services/index.d.ts +2 -1
  92. package/utils/email-templates.util.d.ts +2 -0
  93. package/utils/index.d.ts +1 -0
  94. package/cjs/entities/email-config-base.entity.js +0 -111
  95. package/cjs/entities/email-template-base.entity.js +0 -134
  96. package/config/email-config.service.d.ts +0 -13
  97. package/entities/email-config-base.entity.d.ts +0 -11
  98. package/entities/email-template-base.entity.d.ts +0 -14
  99. package/fesm/entities/email-config-base.entity.js +0 -101
  100. package/fesm/entities/email-template-base.entity.js +0 -124
package/README.md ADDED
@@ -0,0 +1,604 @@
1
+ # Email Package Guide
2
+
3
+ > **Package:** `@flusys/nestjs-email`
4
+ > **Version:** 1.1.0
5
+ > **Type:** Email sending with templates, multiple providers, and multi-tenant support
6
+
7
+ ## Table of Contents
8
+
9
+ - [Overview](#overview)
10
+ - [Installation](#installation)
11
+ - [Constants](#constants)
12
+ - [Module Setup](#module-setup)
13
+ - [Entities](#entities)
14
+ - [Email Providers](#email-providers)
15
+ - [Email Configuration](#email-configuration)
16
+ - [Email Templates](#email-templates)
17
+ - [Email Sending](#email-sending)
18
+ - [API Endpoints](#api-endpoints)
19
+ - [Multi-Tenant Support](#multi-tenant-support)
20
+ - [Best Practices](#best-practices)
21
+
22
+ ---
23
+
24
+ ## Overview
25
+
26
+ `@flusys/nestjs-email` provides:
27
+
28
+ - **Multiple Providers** - SMTP, SendGrid, Mailgun with dynamic registration
29
+ - **Email Templates** - Variable interpolation with `{{variableName}}` syntax
30
+ - **HTML/Plain Text** - Support via `isHtml` toggle
31
+ - **Multi-Tenant Support** - Company-scoped configurations and templates
32
+ - **Attachments** - File attachment support
33
+
34
+ ### Package Hierarchy
35
+
36
+ ```
37
+ @flusys/nestjs-core ← Foundation
38
+
39
+ @flusys/nestjs-shared ← Shared utilities
40
+
41
+ @flusys/nestjs-email ← Email system (THIS PACKAGE)
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ npm install @flusys/nestjs-email
50
+
51
+ # Provider-specific packages (install as needed)
52
+ npm install nodemailer # For SMTP
53
+ npm install @sendgrid/mail # For SendGrid
54
+ npm install mailgun.js form-data # For Mailgun
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Constants
60
+
61
+ ```typescript
62
+ // Injection Token
63
+ export const EMAIL_MODULE_OPTIONS = 'EMAIL_MODULE_OPTIONS';
64
+
65
+ // Default Configuration
66
+ export const DEFAULT_FROM_NAME = 'FLUSYS';
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Module Setup
72
+
73
+ ### Basic Setup
74
+
75
+ ```typescript
76
+ import { EmailModule } from '@flusys/nestjs-email';
77
+
78
+ @Module({
79
+ imports: [
80
+ EmailModule.forRoot({
81
+ global: true,
82
+ includeController: true,
83
+ bootstrapAppConfig: {
84
+ databaseMode: 'single',
85
+ enableCompanyFeature: false,
86
+ },
87
+ config: {
88
+ defaultDatabaseConfig: {
89
+ type: 'postgres',
90
+ host: 'localhost',
91
+ port: 5432,
92
+ username: 'user',
93
+ password: 'password',
94
+ database: 'myapp',
95
+ },
96
+ },
97
+ }),
98
+ ],
99
+ })
100
+ export class AppModule {}
101
+ ```
102
+
103
+ ### With Company Feature
104
+
105
+ ```typescript
106
+ EmailModule.forRoot({
107
+ global: true,
108
+ includeController: true,
109
+ bootstrapAppConfig: {
110
+ databaseMode: 'single',
111
+ enableCompanyFeature: true,
112
+ },
113
+ config: {
114
+ defaultDatabaseConfig: { ... },
115
+ },
116
+ });
117
+ ```
118
+
119
+ ### Async Configuration
120
+
121
+ ```typescript
122
+ EmailModule.forRootAsync({
123
+ global: true,
124
+ includeController: true,
125
+ bootstrapAppConfig: {
126
+ databaseMode: 'single',
127
+ enableCompanyFeature: true,
128
+ },
129
+ imports: [ConfigModule],
130
+ useFactory: async (configService: ConfigService) => ({
131
+ defaultDatabaseConfig: configService.getDatabaseConfig(),
132
+ }),
133
+ inject: [ConfigService],
134
+ });
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Entities
140
+
141
+ ### Entity Groups
142
+
143
+ ```typescript
144
+ // Core entities (no company feature)
145
+ export const EmailCoreEntities = [EmailConfig, EmailTemplate];
146
+
147
+ // Company-specific entities
148
+ export const EmailCompanyEntities = [EmailConfigWithCompany, EmailTemplateWithCompany];
149
+
150
+ // Helper function
151
+ export function getEmailEntitiesByConfig(enableCompanyFeature: boolean): any[] {
152
+ return enableCompanyFeature ? EmailCompanyEntities : EmailCoreEntities;
153
+ }
154
+
155
+ // Base type aliases for backwards compatibility
156
+ export { EmailConfig as EmailConfigBase } from './email-config.entity';
157
+ export { EmailTemplate as EmailTemplateBase } from './email-template.entity';
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Email Providers
163
+
164
+ ### Provider Types
165
+
166
+ ```typescript
167
+ enum EmailProviderTypeEnum {
168
+ SMTP = 'smtp',
169
+ SENDGRID = 'sendgrid',
170
+ MAILGUN = 'mailgun',
171
+ }
172
+ ```
173
+
174
+ Providers are auto-registered at module load via `EmailProviderRegistry`.
175
+
176
+ ### SMTP Configuration
177
+
178
+ ```typescript
179
+ {
180
+ provider: 'smtp',
181
+ config: {
182
+ host: 'smtp.gmail.com',
183
+ port: 587,
184
+ secure: false,
185
+ auth: { user: 'your@gmail.com', pass: 'app-password' },
186
+ }
187
+ }
188
+ ```
189
+
190
+ ### SendGrid Configuration
191
+
192
+ ```typescript
193
+ // Requires: npm install @sendgrid/mail
194
+ {
195
+ provider: 'sendgrid',
196
+ config: { apiKey: 'SG.xxxxxxxxxxxx' }
197
+ }
198
+ ```
199
+
200
+ ### Mailgun Configuration
201
+
202
+ ```typescript
203
+ // Requires: npm install mailgun.js form-data
204
+ {
205
+ provider: 'mailgun',
206
+ config: {
207
+ apiKey: 'key-xxxxxxxx',
208
+ domain: 'mail.yourdomain.com',
209
+ region: 'us', // 'us' or 'eu'
210
+ }
211
+ }
212
+ ```
213
+
214
+ ### Provider Interface
215
+
216
+ ```typescript
217
+ interface IEmailProvider {
218
+ sendEmail(options: IEmailSendOptions): Promise<IEmailSendResult>;
219
+ sendBulkEmails(options: IEmailSendOptions[]): Promise<IEmailSendResult[]>;
220
+ healthCheck(): Promise<boolean>;
221
+ initialize?(config: any): Promise<void>;
222
+ close?(): Promise<void>;
223
+ }
224
+
225
+ interface IEmailSendOptions {
226
+ to: string | string[];
227
+ cc?: string | string[];
228
+ bcc?: string | string[];
229
+ subject: string;
230
+ html?: string;
231
+ text?: string;
232
+ from?: string;
233
+ fromName?: string;
234
+ replyTo?: string;
235
+ attachments?: IEmailAttachment[];
236
+ }
237
+
238
+ interface IEmailSendResult {
239
+ success: boolean;
240
+ messageId?: string;
241
+ error?: string;
242
+ }
243
+ ```
244
+
245
+ ---
246
+
247
+ ## Email Configuration
248
+
249
+ ### EmailConfig Entity
250
+
251
+ ```typescript
252
+ interface IEmailConfig {
253
+ id: string;
254
+ name: string; // e.g., 'default', 'marketing'
255
+ provider: EmailProviderTypeEnum;
256
+ config: Record<string, any>; // Provider-specific config
257
+ fromEmail: string | null;
258
+ fromName: string | null;
259
+ isActive: boolean;
260
+ isDefault: boolean; // Auto-selected when emailConfigId not provided
261
+ companyId?: string | null; // When company feature enabled
262
+ }
263
+ ```
264
+
265
+ ### Default Configuration Resolution
266
+
267
+ When `emailConfigId` is not provided:
268
+ 1. Find config with `isDefault: true` and `isActive: true`
269
+ 2. Fall back to oldest active config
270
+
271
+ ### Creating Configurations
272
+
273
+ ```typescript
274
+ import { EmailProviderConfigService } from '@flusys/nestjs-email';
275
+
276
+ await emailConfigService.insert({
277
+ name: 'default',
278
+ provider: 'smtp',
279
+ fromEmail: 'noreply@example.com',
280
+ fromName: 'My App',
281
+ config: {
282
+ host: 'smtp.gmail.com',
283
+ port: 587,
284
+ auth: { user: '...', pass: '...' },
285
+ },
286
+ isActive: true,
287
+ isDefault: true,
288
+ }, user);
289
+ ```
290
+
291
+ ---
292
+
293
+ ## Email Templates
294
+
295
+ ### EmailTemplate Entity
296
+
297
+ ```typescript
298
+ interface IEmailTemplate {
299
+ id: string;
300
+ name: string;
301
+ slug: string; // URL-friendly identifier
302
+ description: string | null;
303
+ subject: string; // Supports {{variables}}
304
+ schema: Record<string, unknown>;
305
+ htmlContent: string;
306
+ textContent: string | null;
307
+ schemaVersion: number; // Auto-incremented on schema change
308
+ isActive: boolean;
309
+ isHtml: boolean; // true=HTML, false=plain text
310
+ metadata: Record<string, unknown> | null;
311
+ companyId?: string | null;
312
+ }
313
+ ```
314
+
315
+ ### Creating Templates
316
+
317
+ ```typescript
318
+ import { EmailTemplateService } from '@flusys/nestjs-email';
319
+
320
+ await templateService.insert({
321
+ name: 'Welcome Email',
322
+ slug: 'welcome-email',
323
+ subject: 'Welcome to {{appName}}, {{userName}}!',
324
+ isHtml: true,
325
+ htmlContent: `
326
+ <h1>Welcome, {{userName}}!</h1>
327
+ <p>Thank you for joining {{appName}}.</p>
328
+ <a href="{{verificationLink}}">Verify Email</a>
329
+ `,
330
+ textContent: 'Welcome! Verify: {{verificationLink}}',
331
+ schema: {},
332
+ isActive: true,
333
+ }, user);
334
+ ```
335
+
336
+ ### Variable Interpolation
337
+
338
+ ```typescript
339
+ // Template: "Hello {{userName}}, your order #{{orderId}} is {{status}}."
340
+ // Variables: { userName: "John", orderId: "12345", status: "shipped" }
341
+ // Result: "Hello John, your order #12345 is shipped."
342
+ ```
343
+
344
+ ### isHtml Toggle
345
+
346
+ - **`isHtml: true`** - Sends `htmlContent` as HTML, `textContent` as fallback
347
+ - **`isHtml: false`** - Sends `textContent` only (no HTML)
348
+
349
+ ---
350
+
351
+ ## Email Sending
352
+
353
+ ### EmailSendService
354
+
355
+ ```typescript
356
+ import { EmailSendService } from '@flusys/nestjs-email';
357
+
358
+ // Send direct email
359
+ const result = await emailSendService.sendEmail({
360
+ to: 'user@example.com',
361
+ subject: 'Hello!',
362
+ html: '<h1>Hello World</h1>',
363
+ text: 'Hello World',
364
+ emailConfigId: 'config-uuid', // Optional - uses default
365
+ }, user);
366
+
367
+ // Send using template
368
+ const result = await emailSendService.sendTemplateEmail({
369
+ templateSlug: 'welcome-email',
370
+ to: 'user@example.com',
371
+ variables: {
372
+ userName: 'John',
373
+ appName: 'My App',
374
+ },
375
+ }, user);
376
+
377
+ // Send with attachments
378
+ const result = await emailSendService.sendEmail({
379
+ to: 'user@example.com',
380
+ subject: 'Your Invoice',
381
+ html: '<p>Invoice attached.</p>',
382
+ attachments: [{
383
+ filename: 'invoice.pdf',
384
+ content: base64Content,
385
+ contentType: 'application/pdf',
386
+ }],
387
+ }, user);
388
+ ```
389
+
390
+ ---
391
+
392
+ ## API Endpoints
393
+
394
+ All endpoints use POST (RPC pattern) and require JWT authentication.
395
+
396
+ ### Email Configuration
397
+
398
+ | Endpoint | Description |
399
+ |----------|-------------|
400
+ | `POST /email/email-config/insert` | Create configuration |
401
+ | `POST /email/email-config/get/:id` | Get by ID |
402
+ | `POST /email/email-config/get-all` | Get all (paginated) |
403
+ | `POST /email/email-config/update` | Update |
404
+ | `POST /email/email-config/delete` | Delete |
405
+
406
+ ### Email Templates
407
+
408
+ | Endpoint | Description |
409
+ |----------|-------------|
410
+ | `POST /email/email-template/insert` | Create template |
411
+ | `POST /email/email-template/get/:id` | Get by ID |
412
+ | `POST /email/email-template/get-all` | Get all (paginated) |
413
+ | `POST /email/email-template/get-by-slug` | Get by slug |
414
+ | `POST /email/email-template/update` | Update |
415
+ | `POST /email/email-template/delete` | Delete |
416
+
417
+ ### Email Sending
418
+
419
+ | Endpoint | Description |
420
+ |----------|-------------|
421
+ | `POST /email/send/direct` | Send direct email |
422
+ | `POST /email/send/template` | Send using template |
423
+ | `POST /email/send/test` | Test configuration |
424
+
425
+ ### Example Requests
426
+
427
+ ```bash
428
+ # Send template email
429
+ curl -X POST http://localhost:3000/email/send/template \
430
+ -H "Authorization: Bearer <token>" \
431
+ -H "Content-Type: application/json" \
432
+ -d '{
433
+ "templateSlug": "welcome-email",
434
+ "to": "user@example.com",
435
+ "variables": { "userName": "John" }
436
+ }'
437
+
438
+ # Test configuration
439
+ curl -X POST http://localhost:3000/email/send/test \
440
+ -H "Authorization: Bearer <token>" \
441
+ -d '{ "emailConfigId": "uuid", "recipient": "test@example.com" }'
442
+ ```
443
+
444
+ ---
445
+
446
+ ## Multi-Tenant Support
447
+
448
+ ### Company Isolation
449
+
450
+ When `enableCompanyFeature: true`:
451
+ - Email configs are company-scoped
452
+ - Templates are company-scoped
453
+ - Users can only access their company's resources
454
+
455
+ ### Company Filtering
456
+
457
+ Services automatically filter by `companyId`:
458
+
459
+ ```typescript
460
+ // In EmailTemplateService
461
+ if (this.emailConfig.isCompanyFeatureEnabled() && user?.companyId) {
462
+ query.andWhere('emailTemplate.companyId = :companyId', {
463
+ companyId: user.companyId,
464
+ });
465
+ }
466
+ ```
467
+
468
+ ### Dynamic Entity Selection
469
+
470
+ ```typescript
471
+ protected resolveEntity(): EntityTarget<EmailTemplateBase> {
472
+ return this.emailConfig.isCompanyFeatureEnabled()
473
+ ? EmailTemplateWithCompany
474
+ : EmailTemplate;
475
+ }
476
+ ```
477
+
478
+ ---
479
+
480
+ ## Best Practices
481
+
482
+ ### 1. Use Template Slugs
483
+
484
+ ```typescript
485
+ // Use slug for stable references
486
+ await emailSendService.sendTemplateEmail({
487
+ templateSlug: 'welcome-email', // Stable
488
+ ...
489
+ });
490
+
491
+ // Avoid hardcoded IDs
492
+ templateId: 'f47ac10b-58cc-4372-a567-...' // May change
493
+ ```
494
+
495
+ ### 2. Provide Both HTML and Text
496
+
497
+ ```typescript
498
+ await templateService.insert({
499
+ isHtml: true,
500
+ htmlContent: '<h1>Thank you!</h1>',
501
+ textContent: 'Thank you!', // For clients that don't render HTML
502
+ });
503
+ ```
504
+
505
+ ### 3. Test Before Production
506
+
507
+ ```typescript
508
+ const result = await emailSendService.sendTestEmail(
509
+ configId,
510
+ 'admin@example.com',
511
+ user,
512
+ );
513
+ if (!result.success) throw new Error(result.error);
514
+ ```
515
+
516
+ ### 4. Use Variables for Personalization
517
+
518
+ ```typescript
519
+ // Template
520
+ subject: 'Hello {{userName}}!'
521
+
522
+ // Sending
523
+ variables: { userName: 'John' }
524
+ ```
525
+
526
+ ---
527
+
528
+ ## API Reference
529
+
530
+ ### Main Exports
531
+
532
+ ```typescript
533
+ // Module
534
+ import { EmailModule } from '@flusys/nestjs-email';
535
+
536
+ // Services
537
+ import {
538
+ EmailConfigService, // Module configuration service
539
+ EmailProviderConfigService, // CRUD for email provider configs
540
+ EmailTemplateService,
541
+ EmailSendService,
542
+ EmailDataSourceProvider,
543
+ } from '@flusys/nestjs-email/services';
544
+
545
+ // Entities
546
+ import {
547
+ EmailConfig,
548
+ EmailConfigBase,
549
+ EmailConfigWithCompany,
550
+ EmailTemplate,
551
+ EmailTemplateBase,
552
+ EmailTemplateWithCompany,
553
+ EmailCoreEntities,
554
+ EmailCompanyEntities,
555
+ getEmailEntitiesByConfig,
556
+ } from '@flusys/nestjs-email/entities';
557
+
558
+ // DTOs
559
+ import {
560
+ CreateEmailConfigDto,
561
+ UpdateEmailConfigDto,
562
+ EmailConfigResponseDto,
563
+ CreateEmailTemplateDto,
564
+ UpdateEmailTemplateDto,
565
+ EmailTemplateResponseDto,
566
+ EmailAttachmentDto,
567
+ SendEmailDto,
568
+ SendTemplateEmailDto,
569
+ TestEmailDto,
570
+ EmailSendResultDto,
571
+ } from '@flusys/nestjs-email/dtos';
572
+
573
+ // Interfaces
574
+ import {
575
+ IEmailProvider,
576
+ IEmailSendOptions,
577
+ IEmailSendResult,
578
+ IEmailConfig,
579
+ IEmailTemplate,
580
+ EmailModuleOptions,
581
+ } from '@flusys/nestjs-email/interfaces';
582
+
583
+ // Providers
584
+ import {
585
+ EmailProviderRegistry,
586
+ EmailFactoryService,
587
+ SmtpProvider,
588
+ SendGridProvider,
589
+ MailgunProvider,
590
+ } from '@flusys/nestjs-email/providers';
591
+
592
+ // Enums
593
+ import { EmailProviderTypeEnum } from '@flusys/nestjs-email/enums';
594
+
595
+ // Constants
596
+ import {
597
+ EMAIL_MODULE_OPTIONS,
598
+ DEFAULT_FROM_NAME,
599
+ } from '@flusys/nestjs-email/config';
600
+ ```
601
+
602
+ ---
603
+
604
+ **Last Updated:** 2026-02-23
@@ -14,27 +14,9 @@ _export(exports, {
14
14
  get DEFAULT_FROM_NAME () {
15
15
  return DEFAULT_FROM_NAME;
16
16
  },
17
- get EMAIL_CONFIG_SERVICE () {
18
- return EMAIL_CONFIG_SERVICE;
19
- },
20
- get EMAIL_DATA_SOURCE_PROVIDER () {
21
- return EMAIL_DATA_SOURCE_PROVIDER;
22
- },
23
17
  get EMAIL_MODULE_OPTIONS () {
24
18
  return EMAIL_MODULE_OPTIONS;
25
- },
26
- get EMAIL_VALIDATION_MESSAGES () {
27
- return EMAIL_VALIDATION_MESSAGES;
28
19
  }
29
20
  });
30
21
  const EMAIL_MODULE_OPTIONS = 'EMAIL_MODULE_OPTIONS';
31
- const EMAIL_CONFIG_SERVICE = 'EMAIL_CONFIG_SERVICE';
32
- const EMAIL_DATA_SOURCE_PROVIDER = 'EMAIL_DATA_SOURCE_PROVIDER';
33
22
  const DEFAULT_FROM_NAME = 'FLUSYS';
34
- const EMAIL_VALIDATION_MESSAGES = {
35
- INVALID_RECIPIENT: 'Invalid email recipient',
36
- TEMPLATE_NOT_FOUND: 'Email template not found',
37
- CONFIG_NOT_FOUND: 'Email configuration not found',
38
- PROVIDER_NOT_AVAILABLE: 'Email provider not available',
39
- SEND_FAILED: 'Failed to send email'
40
- };
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  _export_star(require("./email.constants"), exports);
6
- _export_star(require("./email-config.service"), exports);
7
6
  function _export_star(from, to) {
8
7
  Object.keys(from).forEach(function(k) {
9
8
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "EmailConfigController", {
8
8
  return EmailConfigController;
9
9
  }
10
10
  });
11
- const _guards = require("@flusys/nestjs-shared/guards");
12
11
  const _classes = require("@flusys/nestjs-shared/classes");
13
12
  const _common = require("@nestjs/common");
14
13
  const _swagger = require("@nestjs/swagger");
@@ -41,16 +40,59 @@ function _ts_param(paramIndex, decorator) {
41
40
  decorator(target, key, paramIndex);
42
41
  };
43
42
  }
44
- let EmailConfigController = class EmailConfigController extends (0, _classes.createApiController)(_dtos.CreateEmailConfigDto, _dtos.UpdateEmailConfigDto, _dtos.EmailConfigResponseDto) {
43
+ let EmailConfigController = class EmailConfigController extends (0, _classes.createApiController)(_dtos.CreateEmailConfigDto, _dtos.UpdateEmailConfigDto, _dtos.EmailConfigResponseDto, {
44
+ security: {
45
+ insert: {
46
+ level: 'permission',
47
+ permissions: [
48
+ _classes.EMAIL_CONFIG_PERMISSIONS.CREATE
49
+ ]
50
+ },
51
+ insertMany: {
52
+ level: 'permission',
53
+ permissions: [
54
+ _classes.EMAIL_CONFIG_PERMISSIONS.CREATE
55
+ ]
56
+ },
57
+ getById: {
58
+ level: 'permission',
59
+ permissions: [
60
+ _classes.EMAIL_CONFIG_PERMISSIONS.READ
61
+ ]
62
+ },
63
+ getAll: {
64
+ level: 'permission',
65
+ permissions: [
66
+ _classes.EMAIL_CONFIG_PERMISSIONS.READ
67
+ ]
68
+ },
69
+ update: {
70
+ level: 'permission',
71
+ permissions: [
72
+ _classes.EMAIL_CONFIG_PERMISSIONS.UPDATE
73
+ ]
74
+ },
75
+ updateMany: {
76
+ level: 'permission',
77
+ permissions: [
78
+ _classes.EMAIL_CONFIG_PERMISSIONS.UPDATE
79
+ ]
80
+ },
81
+ delete: {
82
+ level: 'permission',
83
+ permissions: [
84
+ _classes.EMAIL_CONFIG_PERMISSIONS.DELETE
85
+ ]
86
+ }
87
+ }
88
+ }) {
45
89
  constructor(emailConfigService){
46
90
  super(emailConfigService), _define_property(this, "emailConfigService", void 0), this.emailConfigService = emailConfigService;
47
91
  }
48
92
  };
49
93
  EmailConfigController = _ts_decorate([
50
94
  (0, _swagger.ApiTags)('Email Config'),
51
- (0, _swagger.ApiBearerAuth)(),
52
95
  (0, _common.Controller)('email/email-config'),
53
- (0, _common.UseGuards)(_guards.JwtAuthGuard),
54
96
  _ts_param(0, (0, _common.Inject)(_services.EmailProviderConfigService)),
55
97
  _ts_metadata("design:type", Function),
56
98
  _ts_metadata("design:paramtypes", [