@nest-omni/core 4.1.3-29 → 4.1.3-30

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 (51) hide show
  1. package/audit/interceptors/audit-action.interceptor.js +1 -1
  2. package/audit/services/audit-action.service.js +1 -1
  3. package/audit/services/operation-description.service.js +1 -1
  4. package/audit/services/transaction-audit.service.js +1 -1
  5. package/email-log/email-log.constants.d.ts +8 -0
  6. package/email-log/email-log.constants.js +11 -0
  7. package/email-log/email-log.module.d.ts +47 -0
  8. package/email-log/email-log.module.js +140 -0
  9. package/email-log/index.d.ts +11 -0
  10. package/email-log/index.js +48 -0
  11. package/email-log/interfaces/email-log-options.interface.d.ts +61 -0
  12. package/email-log/interfaces/email-log-options.interface.js +134 -0
  13. package/email-log/interfaces/email-log-transport.interface.d.ts +20 -0
  14. package/email-log/interfaces/email-log-transport.interface.js +2 -0
  15. package/email-log/interfaces/index.d.ts +2 -0
  16. package/email-log/interfaces/index.js +18 -0
  17. package/email-log/providers/email-provider.d.ts +42 -0
  18. package/email-log/providers/email-provider.js +127 -0
  19. package/email-log/providers/index.d.ts +1 -0
  20. package/email-log/providers/index.js +17 -0
  21. package/email-log/services/email-log-alert.service.d.ts +46 -0
  22. package/email-log/services/email-log-alert.service.js +162 -0
  23. package/email-log/services/email-log-formatter.service.d.ts +78 -0
  24. package/email-log/services/email-log-formatter.service.js +442 -0
  25. package/email-log/services/email-log-logger.service.d.ts +85 -0
  26. package/email-log/services/email-log-logger.service.js +168 -0
  27. package/email-log/services/email-log-rate-limiter.service.d.ts +42 -0
  28. package/email-log/services/email-log-rate-limiter.service.js +110 -0
  29. package/email-log/services/email-log-transport.service.d.ts +80 -0
  30. package/email-log/services/email-log-transport.service.js +271 -0
  31. package/email-log/services/index.d.ts +5 -0
  32. package/email-log/services/index.js +21 -0
  33. package/email-log/transports/index.d.ts +1 -0
  34. package/email-log/transports/index.js +17 -0
  35. package/email-log/transports/pino-email.transport.d.ts +56 -0
  36. package/email-log/transports/pino-email.transport.js +188 -0
  37. package/email-log/utils/index.d.ts +2 -0
  38. package/email-log/utils/index.js +18 -0
  39. package/email-log/utils/log-level.helper.d.ts +46 -0
  40. package/email-log/utils/log-level.helper.js +74 -0
  41. package/email-log/utils/pino-transport.utils.d.ts +135 -0
  42. package/email-log/utils/pino-transport.utils.js +238 -0
  43. package/filters/bad-request.filter.d.ts +9 -0
  44. package/filters/bad-request.filter.js +38 -12
  45. package/index.d.ts +1 -0
  46. package/index.js +2 -0
  47. package/package.json +3 -1
  48. package/setup/bootstrap.setup.js +1 -1
  49. package/shared/service-registry.module.js +14 -0
  50. package/shared/services/api-config.service.d.ts +41 -0
  51. package/shared/services/api-config.service.js +163 -6
@@ -127,7 +127,7 @@ let AuditActionInterceptor = AuditActionInterceptor_1 = class AuditActionInterce
127
127
  yield this.summaryRepository.save(summary);
128
128
  }
129
129
  catch (err) {
130
- this.logger.error('Failed to generate audit action summary:', err);
130
+ this.logger.error(`Failed to generate audit action summary: ${err.message}`, err.stack);
131
131
  }
132
132
  finally {
133
133
  // 清除审计动作上下文
@@ -150,7 +150,7 @@ let AuditActionService = AuditActionService_1 = class AuditActionService {
150
150
  });
151
151
  }
152
152
  catch (err) {
153
- this.logger.error('Failed to record audit action summary:', err);
153
+ this.logger.error(`Failed to record audit action summary: ${err.message}`, err.stack);
154
154
  }
155
155
  });
156
156
  }
@@ -304,7 +304,7 @@ let OperationDescriptionService = OperationDescriptionService_1 = class Operatio
304
304
  };
305
305
  }
306
306
  catch (error) {
307
- this.logger.error(`Failed to get description for transaction ${transaction.id}:`, error);
307
+ this.logger.error(`Failed to get description for transaction ${transaction.id}: ${error.message}`, error.stack);
308
308
  }
309
309
  }
310
310
  return results;
@@ -184,7 +184,7 @@ let TransactionAuditService = TransactionAuditService_1 = class TransactionAudit
184
184
  yield this.rollbackSingleEntity(manager, entity, connectionName);
185
185
  }
186
186
  catch (error) {
187
- this.logger.error(`Failed to rollback entity ${entity.entityType}:${entity.entityId} in connection ${connectionName}:`, error);
187
+ this.logger.error(`Failed to rollback entity ${entity.entityType}:${entity.entityId} in connection ${connectionName}: ${error.message}`, error.stack);
188
188
  throw error;
189
189
  }
190
190
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Email log module dependency injection tokens
3
+ */
4
+ export declare const EMAIL_LOG_OPTIONS: unique symbol;
5
+ export declare const EMAIL_LOG_TRANSPORT: unique symbol;
6
+ export declare const EMAIL_LOG_RATE_LIMITER: unique symbol;
7
+ export declare const EMAIL_LOG_FORMATTER: unique symbol;
8
+ export declare const EMAIL_LOG_ALERT: unique symbol;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * Email log module dependency injection tokens
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EMAIL_LOG_ALERT = exports.EMAIL_LOG_FORMATTER = exports.EMAIL_LOG_RATE_LIMITER = exports.EMAIL_LOG_TRANSPORT = exports.EMAIL_LOG_OPTIONS = void 0;
7
+ exports.EMAIL_LOG_OPTIONS = Symbol('EMAIL_LOG_OPTIONS');
8
+ exports.EMAIL_LOG_TRANSPORT = Symbol('EMAIL_LOG_TRANSPORT');
9
+ exports.EMAIL_LOG_RATE_LIMITER = Symbol('EMAIL_LOG_RATE_LIMITER');
10
+ exports.EMAIL_LOG_FORMATTER = Symbol('EMAIL_LOG_FORMATTER');
11
+ exports.EMAIL_LOG_ALERT = Symbol('EMAIL_LOG_ALERT');
@@ -0,0 +1,47 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { EmailLogOptions } from './interfaces';
3
+ /**
4
+ * Email log module for Pino transport
5
+ *
6
+ * Follows CacheModule pattern:
7
+ * - forRoot() and forRootAsync() static methods
8
+ * - Global module decorator
9
+ * - Async factory with dependency injection
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // In service-registry.module.ts
14
+ * if (process.env.EMAIL_LOG_ENABLED) {
15
+ * modules.push(
16
+ * EmailLogModule.forRootAsync({
17
+ * inject: [ApiConfigService],
18
+ * useFactory: (config: ApiConfigService) => ({
19
+ * enabled: true,
20
+ * to: config.getString('EMAIL_LOG_TO').split(','),
21
+ * from: config.getString('EMAIL_LOG_FROM'),
22
+ * smtpHost: config.getString('EMAIL_LOG_SMTP_HOST'),
23
+ * level: config.getString('EMAIL_LOG_LEVEL', 'error'),
24
+ * }),
25
+ * }),
26
+ * );
27
+ * }
28
+ * ```
29
+ */
30
+ export declare class EmailLogModule {
31
+ /**
32
+ * Register email log module with options
33
+ */
34
+ static forRoot(options: EmailLogOptions): DynamicModule;
35
+ /**
36
+ * Register email log module asynchronously
37
+ */
38
+ static forRootAsync(asyncOptions: {
39
+ inject?: any[];
40
+ useFactory: ((...args: any[]) => Promise<EmailLogOptions>) | ((...args: any[]) => EmailLogOptions);
41
+ isGlobal?: boolean;
42
+ }): DynamicModule;
43
+ /**
44
+ * Create providers for the module
45
+ */
46
+ private static createProviders;
47
+ }
@@ -0,0 +1,140 @@
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 EmailLogModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.EmailLogModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const email_log_transport_service_1 = require("./services/email-log-transport.service");
13
+ const email_log_formatter_service_1 = require("./services/email-log-formatter.service");
14
+ const email_log_rate_limiter_service_1 = require("./services/email-log-rate-limiter.service");
15
+ const email_log_alert_service_1 = require("./services/email-log-alert.service");
16
+ const email_log_constants_1 = require("./email-log.constants");
17
+ /**
18
+ * Email log module for Pino transport
19
+ *
20
+ * Follows CacheModule pattern:
21
+ * - forRoot() and forRootAsync() static methods
22
+ * - Global module decorator
23
+ * - Async factory with dependency injection
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // In service-registry.module.ts
28
+ * if (process.env.EMAIL_LOG_ENABLED) {
29
+ * modules.push(
30
+ * EmailLogModule.forRootAsync({
31
+ * inject: [ApiConfigService],
32
+ * useFactory: (config: ApiConfigService) => ({
33
+ * enabled: true,
34
+ * to: config.getString('EMAIL_LOG_TO').split(','),
35
+ * from: config.getString('EMAIL_LOG_FROM'),
36
+ * smtpHost: config.getString('EMAIL_LOG_SMTP_HOST'),
37
+ * level: config.getString('EMAIL_LOG_LEVEL', 'error'),
38
+ * }),
39
+ * }),
40
+ * );
41
+ * }
42
+ * ```
43
+ */
44
+ let EmailLogModule = EmailLogModule_1 = class EmailLogModule {
45
+ /**
46
+ * Register email log module with options
47
+ */
48
+ static forRoot(options) {
49
+ return {
50
+ module: EmailLogModule_1,
51
+ providers: this.createProviders(options),
52
+ exports: [
53
+ email_log_constants_1.EMAIL_LOG_TRANSPORT,
54
+ email_log_constants_1.EMAIL_LOG_ALERT,
55
+ ],
56
+ };
57
+ }
58
+ /**
59
+ * Register email log module asynchronously
60
+ */
61
+ static forRootAsync(asyncOptions) {
62
+ const optionsProvider = {
63
+ provide: email_log_constants_1.EMAIL_LOG_OPTIONS,
64
+ useFactory: asyncOptions.useFactory,
65
+ inject: asyncOptions.inject || [],
66
+ };
67
+ return {
68
+ module: EmailLogModule_1,
69
+ imports: [],
70
+ providers: [
71
+ optionsProvider,
72
+ // Rate limiter service (must be first as other services depend on it)
73
+ {
74
+ provide: email_log_constants_1.EMAIL_LOG_RATE_LIMITER,
75
+ useFactory: (options) => {
76
+ return new email_log_rate_limiter_service_1.EmailLogRateLimiterService(options.rateLimitMaxEmails || 10, options.rateLimitWindowMs || 60000, options.rateLimitBurstSize || 3);
77
+ },
78
+ inject: [email_log_constants_1.EMAIL_LOG_OPTIONS],
79
+ },
80
+ // Formatter service
81
+ {
82
+ provide: email_log_constants_1.EMAIL_LOG_FORMATTER,
83
+ useClass: email_log_formatter_service_1.EmailLogFormatterService,
84
+ },
85
+ // Transport service (depends on rate limiter and formatter)
86
+ {
87
+ provide: email_log_constants_1.EMAIL_LOG_TRANSPORT,
88
+ useClass: email_log_transport_service_1.EmailLogTransportService,
89
+ },
90
+ // Alert service (also depends on rate limiter and formatter)
91
+ {
92
+ provide: email_log_constants_1.EMAIL_LOG_ALERT,
93
+ useClass: email_log_alert_service_1.EmailLogAlertService,
94
+ },
95
+ ],
96
+ exports: [
97
+ email_log_constants_1.EMAIL_LOG_TRANSPORT,
98
+ email_log_constants_1.EMAIL_LOG_ALERT,
99
+ ],
100
+ };
101
+ }
102
+ /**
103
+ * Create providers for the module
104
+ */
105
+ static createProviders(options) {
106
+ return [
107
+ {
108
+ provide: email_log_constants_1.EMAIL_LOG_OPTIONS,
109
+ useValue: options,
110
+ },
111
+ // Rate limiter service
112
+ {
113
+ provide: email_log_constants_1.EMAIL_LOG_RATE_LIMITER,
114
+ useFactory: () => {
115
+ return new email_log_rate_limiter_service_1.EmailLogRateLimiterService(options.rateLimitMaxEmails || 10, options.rateLimitWindowMs || 60000, options.rateLimitBurstSize || 3);
116
+ },
117
+ },
118
+ // Formatter service
119
+ {
120
+ provide: email_log_constants_1.EMAIL_LOG_FORMATTER,
121
+ useClass: email_log_formatter_service_1.EmailLogFormatterService,
122
+ },
123
+ // Transport service
124
+ {
125
+ provide: email_log_constants_1.EMAIL_LOG_TRANSPORT,
126
+ useClass: email_log_transport_service_1.EmailLogTransportService,
127
+ },
128
+ // Alert service
129
+ {
130
+ provide: email_log_constants_1.EMAIL_LOG_ALERT,
131
+ useClass: email_log_alert_service_1.EmailLogAlertService,
132
+ },
133
+ ];
134
+ }
135
+ };
136
+ exports.EmailLogModule = EmailLogModule;
137
+ exports.EmailLogModule = EmailLogModule = EmailLogModule_1 = __decorate([
138
+ (0, common_1.Global)(),
139
+ (0, common_1.Module)({})
140
+ ], EmailLogModule);
@@ -0,0 +1,11 @@
1
+ export { EmailLogModule } from './email-log.module';
2
+ export { EmailLogTransportService } from './services/email-log-transport.service';
3
+ export { EmailLogFormatterService } from './services/email-log-formatter.service';
4
+ export { EmailLogRateLimiterService } from './services/email-log-rate-limiter.service';
5
+ export { EmailLogAlertService } from './services/email-log-alert.service';
6
+ export { EmailLogLogger, createEmailLogger } from './services/email-log-logger.service';
7
+ export { PinoEmailTransport, createPinoEmailTransport } from './transports';
8
+ export * from './utils';
9
+ export { EmailLogOptions } from './interfaces/email-log-options.interface';
10
+ export type { IEmailLogTransport } from './interfaces/email-log-transport.interface';
11
+ export { EMAIL_LOG_OPTIONS, EMAIL_LOG_TRANSPORT, EMAIL_LOG_RATE_LIMITER, EMAIL_LOG_FORMATTER, EMAIL_LOG_ALERT, } from './email-log.constants';
@@ -0,0 +1,48 @@
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
+ exports.EMAIL_LOG_ALERT = exports.EMAIL_LOG_FORMATTER = exports.EMAIL_LOG_RATE_LIMITER = exports.EMAIL_LOG_TRANSPORT = exports.EMAIL_LOG_OPTIONS = exports.EmailLogOptions = exports.createPinoEmailTransport = exports.PinoEmailTransport = exports.createEmailLogger = exports.EmailLogLogger = exports.EmailLogAlertService = exports.EmailLogRateLimiterService = exports.EmailLogFormatterService = exports.EmailLogTransportService = exports.EmailLogModule = void 0;
18
+ // Module
19
+ var email_log_module_1 = require("./email-log.module");
20
+ Object.defineProperty(exports, "EmailLogModule", { enumerable: true, get: function () { return email_log_module_1.EmailLogModule; } });
21
+ // Services
22
+ var email_log_transport_service_1 = require("./services/email-log-transport.service");
23
+ Object.defineProperty(exports, "EmailLogTransportService", { enumerable: true, get: function () { return email_log_transport_service_1.EmailLogTransportService; } });
24
+ var email_log_formatter_service_1 = require("./services/email-log-formatter.service");
25
+ Object.defineProperty(exports, "EmailLogFormatterService", { enumerable: true, get: function () { return email_log_formatter_service_1.EmailLogFormatterService; } });
26
+ var email_log_rate_limiter_service_1 = require("./services/email-log-rate-limiter.service");
27
+ Object.defineProperty(exports, "EmailLogRateLimiterService", { enumerable: true, get: function () { return email_log_rate_limiter_service_1.EmailLogRateLimiterService; } });
28
+ var email_log_alert_service_1 = require("./services/email-log-alert.service");
29
+ Object.defineProperty(exports, "EmailLogAlertService", { enumerable: true, get: function () { return email_log_alert_service_1.EmailLogAlertService; } });
30
+ var email_log_logger_service_1 = require("./services/email-log-logger.service");
31
+ Object.defineProperty(exports, "EmailLogLogger", { enumerable: true, get: function () { return email_log_logger_service_1.EmailLogLogger; } });
32
+ Object.defineProperty(exports, "createEmailLogger", { enumerable: true, get: function () { return email_log_logger_service_1.createEmailLogger; } });
33
+ // Transports (for direct Pino usage)
34
+ var transports_1 = require("./transports");
35
+ Object.defineProperty(exports, "PinoEmailTransport", { enumerable: true, get: function () { return transports_1.PinoEmailTransport; } });
36
+ Object.defineProperty(exports, "createPinoEmailTransport", { enumerable: true, get: function () { return transports_1.createPinoEmailTransport; } });
37
+ // Utils
38
+ __exportStar(require("./utils"), exports);
39
+ // Interfaces
40
+ var email_log_options_interface_1 = require("./interfaces/email-log-options.interface");
41
+ Object.defineProperty(exports, "EmailLogOptions", { enumerable: true, get: function () { return email_log_options_interface_1.EmailLogOptions; } });
42
+ // Constants
43
+ var email_log_constants_1 = require("./email-log.constants");
44
+ Object.defineProperty(exports, "EMAIL_LOG_OPTIONS", { enumerable: true, get: function () { return email_log_constants_1.EMAIL_LOG_OPTIONS; } });
45
+ Object.defineProperty(exports, "EMAIL_LOG_TRANSPORT", { enumerable: true, get: function () { return email_log_constants_1.EMAIL_LOG_TRANSPORT; } });
46
+ Object.defineProperty(exports, "EMAIL_LOG_RATE_LIMITER", { enumerable: true, get: function () { return email_log_constants_1.EMAIL_LOG_RATE_LIMITER; } });
47
+ Object.defineProperty(exports, "EMAIL_LOG_FORMATTER", { enumerable: true, get: function () { return email_log_constants_1.EMAIL_LOG_FORMATTER; } });
48
+ Object.defineProperty(exports, "EMAIL_LOG_ALERT", { enumerable: true, get: function () { return email_log_constants_1.EMAIL_LOG_ALERT; } });
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Email logging transport configuration options
3
+ * Follows libs/core pattern from CacheModuleOptions
4
+ */
5
+ export declare class EmailLogOptions {
6
+ /**
7
+ * Enable email log transport
8
+ * @default false
9
+ */
10
+ enabled: boolean;
11
+ /**
12
+ * Minimum log level to trigger email
13
+ * Uses Pino log levels: 'trace', 'debug', 'info', 'warn', 'error', 'fatal'
14
+ * @default 'error'
15
+ */
16
+ level: string;
17
+ /**
18
+ * Recipient email addresses
19
+ */
20
+ to: string[];
21
+ /**
22
+ * CC recipient email addresses (optional)
23
+ */
24
+ cc?: string[];
25
+ /**
26
+ * Sender email address
27
+ */
28
+ from: string;
29
+ /**
30
+ * Email subject prefix
31
+ * Final subject: "[prefix] appName - log level"
32
+ * @default '[Log Alert]'
33
+ */
34
+ subjectPrefix?: string;
35
+ /**
36
+ * SMTP configuration
37
+ */
38
+ smtpHost: string;
39
+ smtpPort?: number;
40
+ smtpUsername?: string;
41
+ smtpPassword?: string;
42
+ smtpSecure?: boolean;
43
+ smtpIgnoreTLSError?: boolean;
44
+ /**
45
+ * Rate limiting configuration
46
+ */
47
+ rateLimitMaxEmails?: number;
48
+ rateLimitWindowMs?: number;
49
+ rateLimitBurstSize?: number;
50
+ /**
51
+ * Email formatting options
52
+ */
53
+ useHtmlFormat?: boolean;
54
+ /**
55
+ * Filtering options
56
+ */
57
+ includeApps?: string[];
58
+ excludeApps?: string[];
59
+ includeErrors?: string[];
60
+ excludeErrors?: string[];
61
+ }
@@ -0,0 +1,134 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EmailLogOptions = void 0;
13
+ const decorators_1 = require("../../decorators");
14
+ /**
15
+ * Email logging transport configuration options
16
+ * Follows libs/core pattern from CacheModuleOptions
17
+ */
18
+ class EmailLogOptions {
19
+ }
20
+ exports.EmailLogOptions = EmailLogOptions;
21
+ __decorate([
22
+ (0, decorators_1.StringField)({ fieldLabel: { zh: '启用邮件日志', en: 'Enable Email Log' } }),
23
+ __metadata("design:type", Boolean)
24
+ ], EmailLogOptions.prototype, "enabled", void 0);
25
+ __decorate([
26
+ (0, decorators_1.StringField)({ fieldLabel: { zh: '日志级别', en: 'Log Level' } }),
27
+ __metadata("design:type", String)
28
+ ], EmailLogOptions.prototype, "level", void 0);
29
+ __decorate([
30
+ (0, decorators_1.EmailField)({ each: true, fieldLabel: { zh: '收件人', en: 'Recipients' } }),
31
+ __metadata("design:type", Array)
32
+ ], EmailLogOptions.prototype, "to", void 0);
33
+ __decorate([
34
+ (0, decorators_1.EmailFieldOptional)({
35
+ each: true,
36
+ fieldLabel: { zh: '抄送', en: 'CC Recipients' },
37
+ }),
38
+ __metadata("design:type", Array)
39
+ ], EmailLogOptions.prototype, "cc", void 0);
40
+ __decorate([
41
+ (0, decorators_1.EmailField)({ fieldLabel: { zh: '发件人', en: 'Sender Email' } }),
42
+ __metadata("design:type", String)
43
+ ], EmailLogOptions.prototype, "from", void 0);
44
+ __decorate([
45
+ (0, decorators_1.StringFieldOptional)({
46
+ fieldLabel: { zh: '邮件主题前缀', en: 'Subject Prefix' },
47
+ }),
48
+ __metadata("design:type", String)
49
+ ], EmailLogOptions.prototype, "subjectPrefix", void 0);
50
+ __decorate([
51
+ (0, decorators_1.StringField)({ fieldLabel: { zh: 'SMTP主机', en: 'SMTP Host' } }),
52
+ __metadata("design:type", String)
53
+ ], EmailLogOptions.prototype, "smtpHost", void 0);
54
+ __decorate([
55
+ (0, decorators_1.NumberFieldOptional)({ fieldLabel: { zh: 'SMTP端口', en: 'SMTP Port' } }),
56
+ __metadata("design:type", Number)
57
+ ], EmailLogOptions.prototype, "smtpPort", void 0);
58
+ __decorate([
59
+ (0, decorators_1.StringFieldOptional)({
60
+ fieldLabel: { zh: 'SMTP用户名', en: 'SMTP Username' },
61
+ }),
62
+ __metadata("design:type", String)
63
+ ], EmailLogOptions.prototype, "smtpUsername", void 0);
64
+ __decorate([
65
+ (0, decorators_1.StringFieldOptional)({
66
+ fieldLabel: { zh: 'SMTP密码', en: 'SMTP Password' },
67
+ sensitive: true,
68
+ }),
69
+ __metadata("design:type", String)
70
+ ], EmailLogOptions.prototype, "smtpPassword", void 0);
71
+ __decorate([
72
+ (0, decorators_1.BooleanFieldOptional)({
73
+ fieldLabel: { zh: 'SSL/TLS加密', en: 'SMTP Secure' },
74
+ }),
75
+ __metadata("design:type", Boolean)
76
+ ], EmailLogOptions.prototype, "smtpSecure", void 0);
77
+ __decorate([
78
+ (0, decorators_1.BooleanFieldOptional)({
79
+ fieldLabel: { zh: '忽略TLS错误', en: 'Ignore TLS Error' },
80
+ }),
81
+ __metadata("design:type", Boolean)
82
+ ], EmailLogOptions.prototype, "smtpIgnoreTLSError", void 0);
83
+ __decorate([
84
+ (0, decorators_1.NumberFieldOptional)({
85
+ fieldLabel: { zh: '速率限制最大邮件数', en: 'Rate Limit Max Emails' },
86
+ }),
87
+ __metadata("design:type", Number)
88
+ ], EmailLogOptions.prototype, "rateLimitMaxEmails", void 0);
89
+ __decorate([
90
+ (0, decorators_1.NumberFieldOptional)({
91
+ fieldLabel: { zh: '速率限制时间窗口(毫秒)', en: 'Rate Limit Window MS' },
92
+ }),
93
+ __metadata("design:type", Number)
94
+ ], EmailLogOptions.prototype, "rateLimitWindowMs", void 0);
95
+ __decorate([
96
+ (0, decorators_1.NumberFieldOptional)({
97
+ fieldLabel: { zh: '突发大小', en: 'Rate Limit Burst Size' },
98
+ }),
99
+ __metadata("design:type", Number)
100
+ ], EmailLogOptions.prototype, "rateLimitBurstSize", void 0);
101
+ __decorate([
102
+ (0, decorators_1.BooleanFieldOptional)({
103
+ fieldLabel: { zh: 'HTML格式', en: 'Use HTML Format' },
104
+ }),
105
+ __metadata("design:type", Boolean)
106
+ ], EmailLogOptions.prototype, "useHtmlFormat", void 0);
107
+ __decorate([
108
+ (0, decorators_1.StringFieldOptional)({
109
+ each: true,
110
+ fieldLabel: { zh: '包含应用', en: 'Include Apps' },
111
+ }),
112
+ __metadata("design:type", Array)
113
+ ], EmailLogOptions.prototype, "includeApps", void 0);
114
+ __decorate([
115
+ (0, decorators_1.StringFieldOptional)({
116
+ each: true,
117
+ fieldLabel: { zh: '排除应用', en: 'Exclude Apps' },
118
+ }),
119
+ __metadata("design:type", Array)
120
+ ], EmailLogOptions.prototype, "excludeApps", void 0);
121
+ __decorate([
122
+ (0, decorators_1.StringFieldOptional)({
123
+ each: true,
124
+ fieldLabel: { zh: '包含错误类型', en: 'Include Errors' },
125
+ }),
126
+ __metadata("design:type", Array)
127
+ ], EmailLogOptions.prototype, "includeErrors", void 0);
128
+ __decorate([
129
+ (0, decorators_1.StringFieldOptional)({
130
+ each: true,
131
+ fieldLabel: { zh: '排除错误类型', en: 'Exclude Errors' },
132
+ }),
133
+ __metadata("design:type", Array)
134
+ ], EmailLogOptions.prototype, "excludeErrors", void 0);
@@ -0,0 +1,20 @@
1
+ import { LogDescriptor } from 'pino';
2
+ /**
3
+ * Email log transport contract
4
+ * Defines the interface for Pino email transport
5
+ */
6
+ export interface IEmailLogTransport {
7
+ /**
8
+ * Write log entry to email transport
9
+ * Implements Writable stream interface for Pino
10
+ */
11
+ write(data: LogDescriptor): void;
12
+ /**
13
+ * Flush any pending emails
14
+ */
15
+ flush?(): Promise<void>;
16
+ /**
17
+ * Check if transport is enabled for given log level
18
+ */
19
+ shouldSend(level: string): boolean;
20
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './email-log-options.interface';
2
+ export * from './email-log-transport.interface';
@@ -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("./email-log-options.interface"), exports);
18
+ __exportStar(require("./email-log-transport.interface"), exports);
@@ -0,0 +1,42 @@
1
+ interface EmailLogProviderOptions {
2
+ smtpHost: string;
3
+ smtpPort?: number;
4
+ smtpUsername?: string;
5
+ smtpPassword?: string;
6
+ smtpSecure?: boolean;
7
+ smtpIgnoreTLSError?: boolean;
8
+ }
9
+ /**
10
+ * Email provider for log alerts
11
+ * Wraps nodemailer for SMTP email sending
12
+ */
13
+ export declare class EmailLogProvider {
14
+ private readonly options;
15
+ private readonly logger;
16
+ private transporter;
17
+ constructor(options: EmailLogProviderOptions);
18
+ /**
19
+ * Initialize nodemailer transporter
20
+ */
21
+ private initializeTransporter;
22
+ /**
23
+ * Verify SMTP connection (useful for health checks)
24
+ */
25
+ verifyConnection(): Promise<boolean>;
26
+ /**
27
+ * Send log email
28
+ */
29
+ sendLogEmail(params: {
30
+ to: string[];
31
+ cc?: string[];
32
+ from: string;
33
+ subject: string;
34
+ html?: string;
35
+ text?: string;
36
+ }): Promise<void>;
37
+ /**
38
+ * Close the transporter connection
39
+ */
40
+ close(): Promise<void>;
41
+ }
42
+ export {};