@buenojs/bueno 0.8.3 → 0.8.5
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 +136 -16
- package/dist/cli/{index.js → bin.js} +3036 -1421
- package/dist/container/index.js +250 -0
- package/dist/context/index.js +219 -0
- package/dist/database/index.js +493 -0
- package/dist/frontend/index.js +7697 -0
- package/dist/health/index.js +364 -0
- package/dist/i18n/index.js +345 -0
- package/dist/index.js +11043 -6482
- package/dist/jobs/index.js +819 -0
- package/dist/lock/index.js +367 -0
- package/dist/logger/index.js +281 -0
- package/dist/metrics/index.js +289 -0
- package/dist/middleware/index.js +77 -0
- package/dist/migrations/index.js +571 -0
- package/dist/modules/index.js +3346 -0
- package/dist/notification/index.js +484 -0
- package/dist/observability/index.js +331 -0
- package/dist/openapi/index.js +776 -0
- package/dist/orm/index.js +1356 -0
- package/dist/router/index.js +886 -0
- package/dist/rpc/index.js +691 -0
- package/dist/schema/index.js +400 -0
- package/dist/telemetry/index.js +595 -0
- package/dist/template/index.js +640 -0
- package/dist/templates/index.js +640 -0
- package/dist/testing/index.js +1111 -0
- package/dist/types/index.js +60 -0
- package/package.json +121 -27
- package/src/cache/index.ts +2 -1
- package/src/cli/bin.ts +2 -2
- package/src/cli/commands/build.ts +183 -165
- package/src/cli/commands/dev.ts +96 -89
- package/src/cli/commands/generate.ts +142 -111
- package/src/cli/commands/help.ts +20 -16
- package/src/cli/commands/index.ts +3 -6
- package/src/cli/commands/migration.ts +124 -105
- package/src/cli/commands/new.ts +392 -438
- package/src/cli/commands/start.ts +81 -79
- package/src/cli/core/args.ts +68 -50
- package/src/cli/core/console.ts +89 -95
- package/src/cli/core/index.ts +4 -4
- package/src/cli/core/prompt.ts +65 -62
- package/src/cli/core/spinner.ts +23 -20
- package/src/cli/index.ts +46 -38
- package/src/cli/templates/database/index.ts +61 -0
- package/src/cli/templates/database/mysql.ts +14 -0
- package/src/cli/templates/database/none.ts +16 -0
- package/src/cli/templates/database/postgresql.ts +14 -0
- package/src/cli/templates/database/sqlite.ts +14 -0
- package/src/cli/templates/deploy.ts +29 -26
- package/src/cli/templates/docker.ts +41 -30
- package/src/cli/templates/frontend/index.ts +63 -0
- package/src/cli/templates/frontend/none.ts +17 -0
- package/src/cli/templates/frontend/react.ts +140 -0
- package/src/cli/templates/frontend/solid.ts +134 -0
- package/src/cli/templates/frontend/svelte.ts +131 -0
- package/src/cli/templates/frontend/vue.ts +130 -0
- package/src/cli/templates/generators/index.ts +339 -0
- package/src/cli/templates/generators/types.ts +56 -0
- package/src/cli/templates/index.ts +35 -2
- package/src/cli/templates/project/api.ts +81 -0
- package/src/cli/templates/project/default.ts +140 -0
- package/src/cli/templates/project/fullstack.ts +111 -0
- package/src/cli/templates/project/index.ts +95 -0
- package/src/cli/templates/project/minimal.ts +45 -0
- package/src/cli/templates/project/types.ts +94 -0
- package/src/cli/templates/project/website.ts +263 -0
- package/src/cli/utils/fs.ts +55 -41
- package/src/cli/utils/index.ts +3 -2
- package/src/cli/utils/strings.ts +47 -33
- package/src/cli/utils/version.ts +47 -0
- package/src/config/env-validation.ts +100 -0
- package/src/config/env.ts +169 -41
- package/src/config/index.ts +28 -20
- package/src/config/loader.ts +25 -16
- package/src/config/merge.ts +21 -10
- package/src/config/types.ts +545 -25
- package/src/config/validation.ts +215 -7
- package/src/container/forward-ref.ts +22 -22
- package/src/container/index.ts +34 -12
- package/src/context/index.ts +11 -1
- package/src/database/index.ts +7 -190
- package/src/database/orm/builder.ts +457 -0
- package/src/database/orm/casts/index.ts +130 -0
- package/src/database/orm/casts/types.ts +25 -0
- package/src/database/orm/compiler.ts +304 -0
- package/src/database/orm/hooks/index.ts +114 -0
- package/src/database/orm/index.ts +61 -0
- package/src/database/orm/model-registry.ts +59 -0
- package/src/database/orm/model.ts +821 -0
- package/src/database/orm/relationships/base.ts +146 -0
- package/src/database/orm/relationships/belongs-to-many.ts +179 -0
- package/src/database/orm/relationships/belongs-to.ts +56 -0
- package/src/database/orm/relationships/has-many.ts +45 -0
- package/src/database/orm/relationships/has-one.ts +41 -0
- package/src/database/orm/relationships/index.ts +11 -0
- package/src/database/orm/scopes/index.ts +55 -0
- package/src/events/__tests__/event-system.test.ts +235 -0
- package/src/events/config.ts +238 -0
- package/src/events/example-usage.ts +185 -0
- package/src/events/index.ts +278 -0
- package/src/events/manager.ts +385 -0
- package/src/events/registry.ts +182 -0
- package/src/events/types.ts +124 -0
- package/src/frontend/api-routes.ts +65 -23
- package/src/frontend/bundler.ts +76 -34
- package/src/frontend/console-client.ts +2 -2
- package/src/frontend/console-stream.ts +94 -38
- package/src/frontend/dev-server.ts +94 -46
- package/src/frontend/file-router.ts +61 -19
- package/src/frontend/frameworks/index.ts +37 -10
- package/src/frontend/frameworks/react.ts +10 -8
- package/src/frontend/frameworks/solid.ts +11 -9
- package/src/frontend/frameworks/svelte.ts +15 -9
- package/src/frontend/frameworks/vue.ts +13 -11
- package/src/frontend/hmr-client.ts +12 -10
- package/src/frontend/hmr.ts +146 -103
- package/src/frontend/index.ts +14 -5
- package/src/frontend/islands.ts +41 -22
- package/src/frontend/isr.ts +59 -37
- package/src/frontend/layout.ts +36 -21
- package/src/frontend/ssr/react.ts +74 -27
- package/src/frontend/ssr/solid.ts +54 -20
- package/src/frontend/ssr/svelte.ts +48 -14
- package/src/frontend/ssr/vue.ts +50 -18
- package/src/frontend/ssr.ts +83 -39
- package/src/frontend/types.ts +91 -56
- package/src/health/index.ts +21 -9
- package/src/i18n/engine.ts +305 -0
- package/src/i18n/index.ts +38 -0
- package/src/i18n/loader.ts +218 -0
- package/src/i18n/middleware.ts +164 -0
- package/src/i18n/negotiator.ts +162 -0
- package/src/i18n/types.ts +158 -0
- package/src/index.ts +179 -27
- package/src/jobs/drivers/memory.ts +315 -0
- package/src/jobs/drivers/redis.ts +459 -0
- package/src/jobs/index.ts +30 -0
- package/src/jobs/queue.ts +281 -0
- package/src/jobs/types.ts +295 -0
- package/src/jobs/worker.ts +380 -0
- package/src/logger/index.ts +1 -3
- package/src/logger/transports/index.ts +62 -22
- package/src/metrics/index.ts +25 -16
- package/src/migrations/index.ts +9 -0
- package/src/modules/filters.ts +13 -17
- package/src/modules/guards.ts +49 -26
- package/src/modules/index.ts +409 -298
- package/src/modules/interceptors.ts +58 -20
- package/src/modules/lazy.ts +11 -19
- package/src/modules/lifecycle.ts +15 -7
- package/src/modules/metadata.ts +15 -5
- package/src/modules/pipes.ts +94 -72
- package/src/notification/channels/base.ts +68 -0
- package/src/notification/channels/email.ts +105 -0
- package/src/notification/channels/push.ts +104 -0
- package/src/notification/channels/sms.ts +105 -0
- package/src/notification/channels/whatsapp.ts +104 -0
- package/src/notification/index.ts +48 -0
- package/src/notification/service.ts +354 -0
- package/src/notification/types.ts +344 -0
- package/src/observability/__tests__/observability.test.ts +483 -0
- package/src/observability/breadcrumbs.ts +114 -0
- package/src/observability/index.ts +136 -0
- package/src/observability/interceptor.ts +85 -0
- package/src/observability/service.ts +303 -0
- package/src/observability/trace.ts +37 -0
- package/src/observability/types.ts +196 -0
- package/src/openapi/__tests__/decorators.test.ts +335 -0
- package/src/openapi/__tests__/document-builder.test.ts +285 -0
- package/src/openapi/__tests__/route-scanner.test.ts +334 -0
- package/src/openapi/__tests__/schema-generator.test.ts +275 -0
- package/src/openapi/decorators.ts +328 -0
- package/src/openapi/document-builder.ts +274 -0
- package/src/openapi/index.ts +112 -0
- package/src/openapi/metadata.ts +112 -0
- package/src/openapi/route-scanner.ts +289 -0
- package/src/openapi/schema-generator.ts +256 -0
- package/src/openapi/swagger-module.ts +166 -0
- package/src/openapi/types.ts +398 -0
- package/src/orm/index.ts +10 -0
- package/src/rpc/index.ts +3 -1
- package/src/schema/index.ts +9 -0
- package/src/security/index.ts +15 -6
- package/src/ssg/index.ts +9 -8
- package/src/telemetry/index.ts +76 -22
- package/src/template/index.ts +7 -0
- package/src/templates/engine.ts +224 -0
- package/src/templates/index.ts +9 -0
- package/src/templates/loader.ts +331 -0
- package/src/templates/renderers/markdown.ts +212 -0
- package/src/templates/renderers/simple.ts +269 -0
- package/src/templates/types.ts +154 -0
- package/src/testing/index.ts +100 -27
- package/src/types/optional-deps.d.ts +347 -187
- package/src/validation/index.ts +92 -2
- package/src/validation/schemas.ts +536 -0
- package/tests/integration/fullstack.test.ts +4 -4
- package/tests/unit/database.test.ts +2 -72
- package/tests/unit/env-validation.test.ts +166 -0
- package/tests/unit/events.test.ts +910 -0
- package/tests/unit/i18n.test.ts +455 -0
- package/tests/unit/jobs.test.ts +493 -0
- package/tests/unit/notification.test.ts +988 -0
- package/tests/unit/observability.test.ts +453 -0
- package/tests/unit/orm/builder.test.ts +323 -0
- package/tests/unit/orm/casts.test.ts +179 -0
- package/tests/unit/orm/compiler.test.ts +220 -0
- package/tests/unit/orm/eager-loading.test.ts +285 -0
- package/tests/unit/orm/hooks.test.ts +191 -0
- package/tests/unit/orm/model.test.ts +373 -0
- package/tests/unit/orm/relationships.test.ts +303 -0
- package/tests/unit/orm/scopes.test.ts +74 -0
- package/tests/unit/templates-simple.test.ts +53 -0
- package/tests/unit/templates.test.ts +454 -0
- package/tests/unit/validation.test.ts +18 -24
- package/tsconfig.json +11 -3
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification System Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Flexible multi-channel notification system with support for email, SMS,
|
|
5
|
+
* WhatsApp, push notifications, and custom channels. Uses registry pattern
|
|
6
|
+
* for dynamic channel registration.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// ============= Core Channel Types =============
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Supported notification channels
|
|
13
|
+
*/
|
|
14
|
+
export type NotificationChannel =
|
|
15
|
+
| "email"
|
|
16
|
+
| "sms"
|
|
17
|
+
| "whatsapp"
|
|
18
|
+
| "push"
|
|
19
|
+
| string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Base notification message interface
|
|
23
|
+
* All notification types must extend this
|
|
24
|
+
*/
|
|
25
|
+
export interface NotificationMessage {
|
|
26
|
+
/** Channel identifier */
|
|
27
|
+
channel: NotificationChannel;
|
|
28
|
+
/** Recipient identifier (email, phone, device ID, etc) */
|
|
29
|
+
recipient: string;
|
|
30
|
+
/** Optional metadata */
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ============= Template Reference Type =============
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Reference to a template file with rendering data.
|
|
38
|
+
* Used in message fields that support template rendering.
|
|
39
|
+
* The NotificationService will resolve this to a rendered string before sending.
|
|
40
|
+
*/
|
|
41
|
+
export interface TemplateRef {
|
|
42
|
+
/** Template identifier (path without extension, e.g. "emails/welcome") */
|
|
43
|
+
templateId: string;
|
|
44
|
+
/** Data to pass to the template renderer */
|
|
45
|
+
data: Record<string, unknown>;
|
|
46
|
+
/** Optional variant override (e.g. "email", "sms"). Auto-detected from channel if omitted. */
|
|
47
|
+
variant?: string;
|
|
48
|
+
/** Output format: "html" or "text". Defaults based on field context. */
|
|
49
|
+
outputFormat?: "html" | "text";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Type guard for TemplateRef
|
|
54
|
+
*/
|
|
55
|
+
export function isTemplateRef(value: unknown): value is TemplateRef {
|
|
56
|
+
return typeof value === "object" && value !== null && "templateId" in value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ============= Email Channel Types =============
|
|
60
|
+
|
|
61
|
+
export interface EmailRecipient {
|
|
62
|
+
name?: string;
|
|
63
|
+
email: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type EmailRecipients =
|
|
67
|
+
| string
|
|
68
|
+
| EmailRecipient
|
|
69
|
+
| (string | EmailRecipient)[];
|
|
70
|
+
|
|
71
|
+
export interface EmailAttachment {
|
|
72
|
+
filename: string;
|
|
73
|
+
content: string | Buffer;
|
|
74
|
+
contentType?: string;
|
|
75
|
+
encoding?: string;
|
|
76
|
+
contentDisposition?: "attachment" | "inline";
|
|
77
|
+
cid?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface EmailMessage extends NotificationMessage {
|
|
81
|
+
channel: "email";
|
|
82
|
+
recipient: string; // email address
|
|
83
|
+
subject: string;
|
|
84
|
+
html?: string | TemplateRef;
|
|
85
|
+
text?: string | TemplateRef;
|
|
86
|
+
cc?: EmailRecipients;
|
|
87
|
+
bcc?: EmailRecipients;
|
|
88
|
+
replyTo?: string;
|
|
89
|
+
from?: string;
|
|
90
|
+
attachments?: EmailAttachment[];
|
|
91
|
+
headers?: Record<string, string>;
|
|
92
|
+
messageId?: string;
|
|
93
|
+
references?: string[];
|
|
94
|
+
inReplyTo?: string;
|
|
95
|
+
tags?: string[];
|
|
96
|
+
priority?: "high" | "normal" | "low";
|
|
97
|
+
scheduledAt?: Date;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ============= SMS Channel Types =============
|
|
101
|
+
|
|
102
|
+
export interface SMSMessage extends NotificationMessage {
|
|
103
|
+
channel: "sms";
|
|
104
|
+
recipient: string; // phone number
|
|
105
|
+
message: string | TemplateRef; // Max 160 chars typically
|
|
106
|
+
senderId?: string;
|
|
107
|
+
scheduledAt?: Date;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ============= WhatsApp Channel Types =============
|
|
111
|
+
|
|
112
|
+
export interface WhatsAppMessage extends NotificationMessage {
|
|
113
|
+
channel: "whatsapp";
|
|
114
|
+
recipient: string; // phone number with country code
|
|
115
|
+
templateId: string;
|
|
116
|
+
parameters?: Record<string, string>;
|
|
117
|
+
mediaUrl?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ============= Push Notification Channel Types =============
|
|
121
|
+
|
|
122
|
+
export interface PushNotificationMessage extends NotificationMessage {
|
|
123
|
+
channel: "push";
|
|
124
|
+
recipient: string; // device token or user ID
|
|
125
|
+
title: string | TemplateRef;
|
|
126
|
+
body: string | TemplateRef;
|
|
127
|
+
actionUrl?: string;
|
|
128
|
+
imageUrl?: string;
|
|
129
|
+
data?: Record<string, unknown>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ============= Union Type =============
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Union of all built-in notification types
|
|
136
|
+
*/
|
|
137
|
+
export type BuiltInNotification =
|
|
138
|
+
| EmailMessage
|
|
139
|
+
| SMSMessage
|
|
140
|
+
| WhatsAppMessage
|
|
141
|
+
| PushNotificationMessage;
|
|
142
|
+
|
|
143
|
+
// ============= Mailable/Notifiable Interface =============
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Interface for composable notification messages
|
|
147
|
+
* Implement this interface to create reusable notification templates
|
|
148
|
+
*/
|
|
149
|
+
export interface Notifiable {
|
|
150
|
+
/**
|
|
151
|
+
* Build notification message(s)
|
|
152
|
+
* Can return single message or array of messages for multi-channel
|
|
153
|
+
* @returns NotificationMessage or Promise<NotificationMessage>
|
|
154
|
+
*/
|
|
155
|
+
build(
|
|
156
|
+
channel?: NotificationChannel,
|
|
157
|
+
): NotificationMessage | Promise<NotificationMessage>;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Optional: Build multiple channel notifications at once
|
|
161
|
+
*/
|
|
162
|
+
buildAll?(): Record<
|
|
163
|
+
NotificationChannel,
|
|
164
|
+
NotificationMessage | Promise<NotificationMessage>
|
|
165
|
+
>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ============= Channel Service Types =============
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Health status for channel services
|
|
172
|
+
*/
|
|
173
|
+
export interface ChannelHealth {
|
|
174
|
+
status: "healthy" | "degraded" | "unhealthy";
|
|
175
|
+
message: string;
|
|
176
|
+
checkedAt: Date;
|
|
177
|
+
error?: string;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Base interface for all channel services
|
|
182
|
+
*/
|
|
183
|
+
export interface ChannelService<
|
|
184
|
+
T extends NotificationMessage = NotificationMessage,
|
|
185
|
+
> {
|
|
186
|
+
/** Channel name/identifier */
|
|
187
|
+
readonly name: NotificationChannel;
|
|
188
|
+
|
|
189
|
+
/** Configuration schema validator (optional) */
|
|
190
|
+
readonly configSchema?: StandardSchema;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Validate message structure at runtime
|
|
194
|
+
* Should throw if message is invalid
|
|
195
|
+
*/
|
|
196
|
+
validate(message: unknown): asserts message is T;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Send a notification message
|
|
200
|
+
* @returns Message ID or undefined if not trackable
|
|
201
|
+
*/
|
|
202
|
+
send(message: T): Promise<string | undefined>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get channel health status
|
|
206
|
+
*/
|
|
207
|
+
getHealth?(): Promise<ChannelHealth>;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Get channel metrics (optional)
|
|
211
|
+
*/
|
|
212
|
+
getMetrics?(): Promise<ChannelMetrics>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ============= Channel Configuration Types =============
|
|
216
|
+
|
|
217
|
+
export interface BaseChannelConfig {
|
|
218
|
+
/** Enable this channel */
|
|
219
|
+
enabled?: boolean;
|
|
220
|
+
/** Dry-run mode (log instead of sending) */
|
|
221
|
+
dryRun?: boolean;
|
|
222
|
+
/** Enable metrics collection */
|
|
223
|
+
enableMetrics?: boolean;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface EmailChannelConfig extends BaseChannelConfig {
|
|
227
|
+
driver: "smtp" | "sendgrid" | "brevo" | "resend";
|
|
228
|
+
from: string;
|
|
229
|
+
fromName?: string;
|
|
230
|
+
smtp?: {
|
|
231
|
+
host: string;
|
|
232
|
+
port: number;
|
|
233
|
+
secure?: boolean;
|
|
234
|
+
username?: string;
|
|
235
|
+
password?: string;
|
|
236
|
+
};
|
|
237
|
+
apiKey?: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface SMSChannelConfig extends BaseChannelConfig {
|
|
241
|
+
driver: "twilio" | "aws-sns" | "custom";
|
|
242
|
+
accountSid?: string;
|
|
243
|
+
authToken?: string;
|
|
244
|
+
fromNumber?: string;
|
|
245
|
+
apiKey?: string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface WhatsAppChannelConfig extends BaseChannelConfig {
|
|
249
|
+
driver: "twilio" | "custom";
|
|
250
|
+
accountSid?: string;
|
|
251
|
+
authToken?: string;
|
|
252
|
+
businessPhoneNumber?: string;
|
|
253
|
+
apiKey?: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface PushChannelConfig extends BaseChannelConfig {
|
|
257
|
+
driver: "firebase" | "apns" | "custom";
|
|
258
|
+
serverKey?: string;
|
|
259
|
+
certificatePath?: string;
|
|
260
|
+
apiKey?: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export type ChannelConfig =
|
|
264
|
+
| EmailChannelConfig
|
|
265
|
+
| SMSChannelConfig
|
|
266
|
+
| WhatsAppChannelConfig
|
|
267
|
+
| PushChannelConfig
|
|
268
|
+
| Record<string, unknown>;
|
|
269
|
+
|
|
270
|
+
// ============= Notification Service Configuration =============
|
|
271
|
+
|
|
272
|
+
export interface NotificationServiceConfig {
|
|
273
|
+
/** Channels configuration */
|
|
274
|
+
channels?: Record<NotificationChannel, ChannelConfig>;
|
|
275
|
+
/** Default channel for sending */
|
|
276
|
+
defaultChannel?: NotificationChannel;
|
|
277
|
+
/** Queue system for async sending */
|
|
278
|
+
queue?: boolean;
|
|
279
|
+
/** Enable metrics collection */
|
|
280
|
+
enableMetrics?: boolean;
|
|
281
|
+
/** Optional template engine for rendering TemplateRef fields */
|
|
282
|
+
templateEngine?: import("../templates/engine").TemplateEngine;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// ============= Metrics Types =============
|
|
286
|
+
|
|
287
|
+
export interface ChannelMetrics {
|
|
288
|
+
/** Total messages sent */
|
|
289
|
+
sent: number;
|
|
290
|
+
/** Total messages failed */
|
|
291
|
+
failed: number;
|
|
292
|
+
/** Successful send rate (0-1) */
|
|
293
|
+
successRate: number;
|
|
294
|
+
/** Average send time in ms */
|
|
295
|
+
avgSendTime: number;
|
|
296
|
+
/** Total time spent sending */
|
|
297
|
+
totalSendTime: number;
|
|
298
|
+
/** Last updated timestamp */
|
|
299
|
+
updatedAt: Date;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// ============= Event Types =============
|
|
303
|
+
|
|
304
|
+
export type NotificationEventType =
|
|
305
|
+
| "notification.sent"
|
|
306
|
+
| "notification.failed"
|
|
307
|
+
| "notification.queued"
|
|
308
|
+
| "notification.bounced"
|
|
309
|
+
| "notification.delivered";
|
|
310
|
+
|
|
311
|
+
export interface NotificationEvent {
|
|
312
|
+
type: NotificationEventType;
|
|
313
|
+
channel: NotificationChannel;
|
|
314
|
+
messageId?: string;
|
|
315
|
+
recipient?: string;
|
|
316
|
+
timestamp: Date;
|
|
317
|
+
data?: Record<string, unknown>;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// ============= Validation Result =============
|
|
321
|
+
|
|
322
|
+
export interface NotificationValidationResult {
|
|
323
|
+
valid: boolean;
|
|
324
|
+
errors: string[];
|
|
325
|
+
warnings: string[];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// ============= Standard Schema (for config validation) =============
|
|
329
|
+
|
|
330
|
+
export interface StandardSchema<T = unknown> {
|
|
331
|
+
"~standard": {
|
|
332
|
+
version: number;
|
|
333
|
+
types?: {
|
|
334
|
+
input: unknown;
|
|
335
|
+
output: T;
|
|
336
|
+
};
|
|
337
|
+
validate: (value: unknown) => Promise<{
|
|
338
|
+
issues?: Array<{
|
|
339
|
+
message: string;
|
|
340
|
+
path?: Array<PropertyKey | { key: PropertyKey }>;
|
|
341
|
+
}>;
|
|
342
|
+
}>;
|
|
343
|
+
};
|
|
344
|
+
}
|