alepha 0.10.5 → 0.10.7

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/email.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import * as _alepha_core1 from "alepha";
2
- import { Descriptor, KIND, Service, Static, TSchema } from "alepha";
3
- import * as _alepha_logger1 from "alepha/logger";
2
+ import * as _alepha_logger0 from "alepha/logger";
4
3
  import { Transporter } from "nodemailer";
5
4
 
6
5
  //#region src/providers/EmailProvider.d.ts
@@ -13,230 +12,15 @@ declare abstract class EmailProvider {
13
12
  /**
14
13
  * Send an email.
15
14
  *
16
- * @param to The recipient email address.
17
- * @param subject The email subject.
18
- * @param body The email body (HTML content).
19
- *
20
15
  * @return Promise that resolves when the email is sent.
21
16
  */
22
- abstract send(to: string, subject: string, body: string): Promise<void>;
17
+ abstract send(options: EmailSendOptions): Promise<void>;
23
18
  }
24
- //#endregion
25
- //#region src/providers/MemoryEmailProvider.d.ts
26
- interface EmailRecord {
27
- to: string;
19
+ type EmailSendOptions = {
20
+ to: string | string[];
28
21
  subject: string;
29
22
  body: string;
30
- sentAt: Date;
31
- }
32
- declare class MemoryEmailProvider implements EmailProvider {
33
- protected readonly log: _alepha_logger1.Logger;
34
- protected emails: EmailRecord[];
35
- send(to: string, subject: string, body: string): Promise<void>;
36
- /**
37
- * Get all emails sent through this provider (for testing purposes).
38
- */
39
- getEmails(): EmailRecord[];
40
- /**
41
- * Clear all stored emails (for testing purposes).
42
- */
43
- clearEmails(): void;
44
- /**
45
- * Get the last email sent (for testing purposes).
46
- */
47
- getLastEmail(): EmailRecord | undefined;
48
- }
49
- //#endregion
50
- //#region src/services/TemplateService.d.ts
51
- /**
52
- * Minimal template service with Handlebars-like syntax for email templating.
53
- * Supports simple variable substitution with {{variableName}} syntax.
54
- */
55
- declare class TemplateService {
56
- /**
57
- * Compile a template string with the provided values.
58
- *
59
- * @param template Template string with {{variableName}} placeholders
60
- * @param values Object containing values to substitute
61
- * @returns Compiled template string with values substituted
62
- *
63
- * @example
64
- * ```ts
65
- * const service = new TemplateService();
66
- * const result = service.compile("Hello {{name}}!", { name: "John" });
67
- * // Result: "Hello John!"
68
- * ```
69
- */
70
- compile(template: string, values: Record<string, unknown>): string;
71
- /**
72
- * Validate that all required template variables are provided.
73
- *
74
- * @param template Template string
75
- * @param values Values object
76
- * @returns Array of missing variable names
77
- */
78
- validateTemplate(template: string, values: Record<string, unknown>): string[];
79
- /**
80
- * Extract all variable names from a template.
81
- *
82
- * @param template Template string
83
- * @returns Array of variable names found in the template
84
- */
85
- extractVariables(template: string): string[];
86
- }
87
- //#endregion
88
- //#region src/descriptors/$email.d.ts
89
- /**
90
- * Creates an email descriptor for sending type-safe templated emails.
91
- *
92
- * The $email descriptor provides a powerful templating system for creating and sending emails
93
- * with full type safety and validation. It supports multiple email providers, template variable
94
- * validation, and automatic HTML rendering.
95
- *
96
- * **Template Engine**
97
- * - Simple {{variable}} syntax for dynamic content
98
- * - Automatic template variable validation at runtime
99
- * - Support for nested object properties in templates
100
- * - HTML email support with rich formatting
101
- *
102
- * **Type Safety**
103
- * - Full TypeScript support with schema validation using TypeBox
104
- * - Compile-time type checking for template variables
105
- * - Runtime validation of email data before sending
106
- * - Automatic type inference from schema definitions
107
- *
108
- * **Provider Flexibility**
109
- * - Memory provider for development and testing
110
- * - Support for SMTP, SendGrid, AWS SES, and other providers
111
- * - Custom provider implementation for specialized services
112
- * - Automatic fallback and error handling
113
- *
114
- * **Template Management**
115
- * - Reusable email templates across your application
116
- * - Centralized template configuration and maintenance
117
- * - Template variable documentation through schemas
118
- * - Easy testing and preview capabilities
119
- *
120
- * **Development Experience**
121
- * - Clear error messages for missing template variables
122
- * - Comprehensive logging for debugging email delivery
123
- * - Memory provider captures emails for testing
124
- * - Template validation before sending
125
- *
126
- * @example Welcome email template
127
- * ```typescript
128
- * const welcomeEmail = $email({
129
- * subject: "Welcome to {{companyName}}, {{firstName}}!",
130
- * body: `
131
- * <h1>Welcome {{firstName}} {{lastName}}!</h1>
132
- * <p>Thank you for joining {{companyName}}.</p>
133
- * <p>Your account role is: <strong>{{role}}</strong></p>
134
- * <p>Get started by visiting your <a href="{{dashboardUrl}}">dashboard</a>.</p>
135
- * `,
136
- * schema: t.object({
137
- * firstName: t.text(),
138
- * lastName: t.text(),
139
- * companyName: t.text(),
140
- * role: t.enum(["admin", "user", "manager"]),
141
- * dashboardUrl: t.text()
142
- * })
143
- * });
144
- *
145
- * // Send with full type safety
146
- * await welcomeEmail.send("user@example.com", {
147
- * firstName: "John",
148
- * lastName: "Doe",
149
- * companyName: "Acme Corp",
150
- * role: "user",
151
- * dashboardUrl: "https://app.acme.com/dashboard"
152
- * });
153
- * ```
154
- *
155
- * @example Order confirmation email
156
- * ```typescript
157
- * const orderConfirmation = $email({
158
- * subject: "Order #{{orderNumber}} confirmed - {{totalAmount}}",
159
- * body: `
160
- * <h1>Order Confirmed!</h1>
161
- * <p>Hi {{customerName}},</p>
162
- * <p>Your order #{{orderNumber}} has been confirmed.</p>
163
- * <h2>Order Details:</h2>
164
- * <p><strong>Total: {{totalAmount}}</strong></p>
165
- * <p>Estimated delivery: {{deliveryDate}}</p>
166
- * `,
167
- * schema: t.object({
168
- * customerName: t.text(),
169
- * orderNumber: t.text(),
170
- * totalAmount: t.text(),
171
- * deliveryDate: t.text()
172
- * })
173
- * });
174
- * ```
175
- *
176
- * @example Development with memory provider
177
- * ```typescript
178
- * const testEmail = $email({
179
- * subject: "Test: {{subject}}",
180
- * body: "<p>{{message}}</p>",
181
- * provider: "memory", // Captures emails for testing
182
- * schema: t.object({
183
- * subject: t.text(),
184
- * message: t.text()
185
- * })
186
- * });
187
- *
188
- * // In tests - emails are captured, not actually sent
189
- * await testEmail.send("test@example.com", {
190
- * subject: "Unit Test",
191
- * message: "This email was captured for testing"
192
- * });
193
- * ```
194
- */
195
- declare const $email: {
196
- <T extends TSchema>(options: EmailDescriptorOptions<T>): EmailDescriptor<T>;
197
- [KIND]: typeof EmailDescriptor;
198
23
  };
199
- interface EmailDescriptorOptions<T extends TSchema> {
200
- /**
201
- * Email subject template. Supports {{variableName}} syntax.
202
- */
203
- subject: string;
204
- /**
205
- * Email body template (HTML content). Supports {{variableName}} syntax.
206
- */
207
- body: string;
208
- /**
209
- * Schema defining the structure of template variables.
210
- */
211
- schema: T;
212
- /**
213
- * Optional name of the email template.
214
- * @default Descriptor key
215
- */
216
- name?: string;
217
- /**
218
- * Optional description of the email template.
219
- */
220
- description?: string;
221
- /**
222
- * Email provider to use. If not provided, the default provider will be used.
223
- */
224
- provider?: Service<EmailProvider> | "memory";
225
- }
226
- declare class EmailDescriptor<T extends TSchema> extends Descriptor<EmailDescriptorOptions<T>> {
227
- protected readonly log: _alepha_logger1.Logger;
228
- protected readonly templateService: TemplateService;
229
- readonly provider: EmailProvider | MemoryEmailProvider;
230
- get name(): string;
231
- /**
232
- * Send an email using the template with the provided values.
233
- *
234
- * @param to Recipient email address
235
- * @param values Template variable values
236
- */
237
- send(to: string, values: Static<T>): Promise<void>;
238
- protected $provider(): EmailProvider | MemoryEmailProvider;
239
- }
240
24
  //#endregion
241
25
  //#region src/errors/EmailError.d.ts
242
26
  declare class EmailError extends Error {
@@ -247,17 +31,38 @@ declare class EmailError extends Error {
247
31
  interface LocalEmailProviderOptions {
248
32
  /**
249
33
  * Directory to save email files.
250
- * @default "email" (relative to project root)
34
+ * @default "node_modules/.email" (relative to project root)
251
35
  */
252
36
  directory?: string;
253
37
  }
254
38
  declare class LocalEmailProvider implements EmailProvider {
255
- protected readonly log: _alepha_logger1.Logger;
39
+ protected readonly log: _alepha_logger0.Logger;
256
40
  protected readonly directory: string;
257
41
  constructor(options?: LocalEmailProviderOptions);
258
- send(to: string, subject: string, body: string): Promise<void>;
259
- protected createEmailHtml(to: string, subject: string, body: string): string;
260
- protected escapeHtml(text: string): string;
42
+ send(options: EmailSendOptions): Promise<void>;
43
+ createEmailHtml(options: {
44
+ to: string;
45
+ subject: string;
46
+ body: string;
47
+ }): string;
48
+ escapeHtml(text: string): string;
49
+ }
50
+ //#endregion
51
+ //#region src/providers/MemoryEmailProvider.d.ts
52
+ interface EmailRecord {
53
+ to: string;
54
+ subject: string;
55
+ body: string;
56
+ sentAt: Date;
57
+ }
58
+ declare class MemoryEmailProvider implements EmailProvider {
59
+ protected readonly log: _alepha_logger0.Logger;
60
+ records: EmailRecord[];
61
+ send(options: EmailSendOptions): Promise<void>;
62
+ /**
63
+ * Get the last email sent (for testing purposes).
64
+ */
65
+ get last(): EmailRecord | undefined;
261
66
  }
262
67
  //#endregion
263
68
  //#region src/providers/NodemailerEmailProvider.d.ts
@@ -292,12 +97,12 @@ declare class NodemailerEmailProvider implements EmailProvider {
292
97
  EMAIL_FROM: string;
293
98
  EMAIL_SECURE: boolean;
294
99
  };
295
- protected readonly log: _alepha_logger1.Logger;
100
+ protected readonly log: _alepha_logger0.Logger;
296
101
  protected transporter: Transporter;
297
102
  protected fromAddress: string;
298
103
  readonly options: NodemailerEmailProviderOptions;
299
104
  constructor();
300
- send(to: string, subject: string, body: string): Promise<void>;
105
+ send(options: EmailSendOptions): Promise<void>;
301
106
  protected createTransporter(): Transporter;
302
107
  /**
303
108
  * Verify the connection to the email server.
@@ -312,6 +117,17 @@ declare class NodemailerEmailProvider implements EmailProvider {
312
117
  }
313
118
  //#endregion
314
119
  //#region src/index.d.ts
120
+ declare module "alepha" {
121
+ interface Hooks {
122
+ "email:sending": {
123
+ to: string | string[];
124
+ template: string;
125
+ variables: Record<string, unknown>;
126
+ provider: EmailProvider;
127
+ abort(): void;
128
+ };
129
+ }
130
+ }
315
131
  /**
316
132
  * Provides email sending capabilities for Alepha applications with multiple provider backends.
317
133
  *
@@ -324,5 +140,5 @@ declare class NodemailerEmailProvider implements EmailProvider {
324
140
  */
325
141
  declare const AlephaEmail: _alepha_core1.Service<_alepha_core1.Module<{}>>;
326
142
  //#endregion
327
- export { $email, AlephaEmail, EmailDescriptor, EmailDescriptorOptions, EmailError, EmailProvider, EmailRecord, LocalEmailProvider, LocalEmailProviderOptions, MemoryEmailProvider, NodemailerEmailProvider, NodemailerEmailProviderOptions, TemplateService };
143
+ export { AlephaEmail, EmailError, EmailProvider, EmailRecord, EmailSendOptions, LocalEmailProvider, LocalEmailProviderOptions, MemoryEmailProvider, NodemailerEmailProvider, NodemailerEmailProviderOptions };
328
144
  //# sourceMappingURL=index.d.ts.map
package/lock.d.ts CHANGED
@@ -273,7 +273,7 @@ declare const $lock: {
273
273
  <TFunc extends AsyncFn>(options: LockDescriptorOptions<TFunc>): LockDescriptor<TFunc>;
274
274
  [KIND]: typeof LockDescriptor;
275
275
  };
276
- interface LockDescriptorOptions<TFunc extends AsyncFn> {
276
+ interface LockDescriptorOptions<TFunc$1 extends AsyncFn> {
277
277
  /**
278
278
  * The function to execute when the lock is successfully acquired.
279
279
  *
@@ -308,7 +308,7 @@ interface LockDescriptorOptions<TFunc extends AsyncFn> {
308
308
  * }
309
309
  * ```
310
310
  */
311
- handler: TFunc;
311
+ handler: TFunc$1;
312
312
  /**
313
313
  * Whether the lock should wait for other instances to complete before giving up.
314
314
  *
@@ -388,7 +388,7 @@ interface LockDescriptorOptions<TFunc extends AsyncFn> {
388
388
  * });
389
389
  * ```
390
390
  */
391
- name?: string | ((...args: Parameters<TFunc>) => string);
391
+ name?: string | ((...args: Parameters<TFunc$1>) => string);
392
392
  /**
393
393
  * Maximum duration the lock can be held before it expires automatically.
394
394
  *
@@ -474,7 +474,7 @@ interface LockDescriptorOptions<TFunc extends AsyncFn> {
474
474
  * });
475
475
  * ```
476
476
  */
477
- gracePeriod?: ((...args: Parameters<TFunc>) => DurationLike | undefined) | DurationLike;
477
+ gracePeriod?: ((...args: Parameters<TFunc$1>) => DurationLike | undefined) | DurationLike;
478
478
  }
479
479
  declare const envSchema: _alepha_core1.TObject<{
480
480
  LOCK_PREFIX_KEY: _alepha_core1.TString;
@@ -482,7 +482,7 @@ declare const envSchema: _alepha_core1.TObject<{
482
482
  declare module "alepha" {
483
483
  interface Env extends Partial<Static<typeof envSchema>> {}
484
484
  }
485
- declare class LockDescriptor<TFunc extends AsyncFn> extends Descriptor<LockDescriptorOptions<TFunc>> {
485
+ declare class LockDescriptor<TFunc$1 extends AsyncFn> extends Descriptor<LockDescriptorOptions<TFunc$1>> {
486
486
  protected readonly log: _alepha_logger0.Logger;
487
487
  protected readonly provider: LockProvider;
488
488
  protected readonly env: {
@@ -496,14 +496,14 @@ declare class LockDescriptor<TFunc extends AsyncFn> extends Descriptor<LockDescr
496
496
  name: _alepha_core1.TString;
497
497
  }>;
498
498
  }>;
499
- run(...args: Parameters<TFunc>): Promise<void>;
499
+ run(...args: Parameters<TFunc$1>): Promise<void>;
500
500
  /**
501
501
  * Set the lock for the given key.
502
502
  */
503
503
  protected lock(key: string): Promise<LockResult>;
504
- protected setGracePeriod(key: string, lock: LockResult, ...args: Parameters<TFunc>): Promise<void>;
504
+ protected setGracePeriod(key: string, lock: LockResult, ...args: Parameters<TFunc$1>): Promise<void>;
505
505
  protected wait(key: string, maxDuration: DurationLike): Promise<void>;
506
- protected key(...args: Parameters<TFunc>): string;
506
+ protected key(...args: Parameters<TFunc$1>): string;
507
507
  protected parse(value: string): LockResult;
508
508
  }
509
509
  interface LockResult {
package/logger.d.ts CHANGED
@@ -269,7 +269,6 @@ declare module "alepha" {
269
269
  }
270
270
  }
271
271
  //# sourceMappingURL=index.d.ts.map
272
-
273
272
  //#endregion
274
273
  export { $logger, AlephaLogger, ConsoleColorProvider, ConsoleDestinationProvider, JsonFormatterProvider, LogDestinationProvider, LogEntry, LogFormatterProvider, Logger, LoggerDescriptorOptions, MemoryDestinationProvider, SimpleFormatterProvider, logEntrySchema };
275
274
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alepha",
3
- "version": "0.10.5",
3
+ "version": "0.10.7",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -15,55 +15,58 @@
15
15
  "main": "./core.js",
16
16
  "types": "./core.d.ts",
17
17
  "dependencies": {
18
- "@alepha/api-files": "0.10.5",
19
- "@alepha/api-jobs": "0.10.5",
20
- "@alepha/api-users": "0.10.5",
21
- "@alepha/batch": "0.10.5",
22
- "@alepha/bucket": "0.10.5",
23
- "@alepha/cache": "0.10.5",
24
- "@alepha/cache-redis": "0.10.5",
25
- "@alepha/command": "0.10.5",
26
- "@alepha/core": "0.10.5",
27
- "@alepha/datetime": "0.10.5",
28
- "@alepha/devtools": "0.10.5",
29
- "@alepha/email": "0.10.5",
30
- "@alepha/file": "0.10.5",
31
- "@alepha/lock": "0.10.5",
32
- "@alepha/lock-redis": "0.10.5",
33
- "@alepha/logger": "0.10.5",
34
- "@alepha/postgres": "0.10.5",
35
- "@alepha/queue": "0.10.5",
36
- "@alepha/queue-redis": "0.10.5",
37
- "@alepha/react": "0.10.5",
38
- "@alepha/react-auth": "0.10.5",
39
- "@alepha/react-form": "0.10.5",
40
- "@alepha/react-head": "0.10.5",
41
- "@alepha/react-i18n": "0.10.5",
42
- "@alepha/redis": "0.10.5",
43
- "@alepha/retry": "0.10.5",
44
- "@alepha/router": "0.10.5",
45
- "@alepha/scheduler": "0.10.5",
46
- "@alepha/security": "0.10.5",
47
- "@alepha/server": "0.10.5",
48
- "@alepha/server-cache": "0.10.5",
49
- "@alepha/server-compress": "0.10.5",
50
- "@alepha/server-cookies": "0.10.5",
51
- "@alepha/server-cors": "0.10.5",
52
- "@alepha/server-health": "0.10.5",
53
- "@alepha/server-helmet": "0.10.5",
54
- "@alepha/server-links": "0.10.5",
55
- "@alepha/server-metrics": "0.10.5",
56
- "@alepha/server-multipart": "0.10.5",
57
- "@alepha/server-proxy": "0.10.5",
58
- "@alepha/server-security": "0.10.5",
59
- "@alepha/server-static": "0.10.5",
60
- "@alepha/server-swagger": "0.10.5",
61
- "@alepha/topic": "0.10.5",
62
- "@alepha/topic-redis": "0.10.5",
63
- "@alepha/vite": "0.10.5"
18
+ "@alepha/api-files": "0.10.7",
19
+ "@alepha/api-jobs": "0.10.7",
20
+ "@alepha/api-notifications": "0.10.7",
21
+ "@alepha/api-users": "0.10.7",
22
+ "@alepha/api-verifications": "0.10.7",
23
+ "@alepha/batch": "0.10.7",
24
+ "@alepha/bucket": "0.10.7",
25
+ "@alepha/cache": "0.10.7",
26
+ "@alepha/cache-redis": "0.10.7",
27
+ "@alepha/command": "0.10.7",
28
+ "@alepha/core": "0.10.7",
29
+ "@alepha/datetime": "0.10.7",
30
+ "@alepha/devtools": "0.10.7",
31
+ "@alepha/email": "0.10.7",
32
+ "@alepha/file": "0.10.7",
33
+ "@alepha/lock": "0.10.7",
34
+ "@alepha/lock-redis": "0.10.7",
35
+ "@alepha/logger": "0.10.7",
36
+ "@alepha/postgres": "0.10.7",
37
+ "@alepha/queue": "0.10.7",
38
+ "@alepha/queue-redis": "0.10.7",
39
+ "@alepha/react": "0.10.7",
40
+ "@alepha/react-auth": "0.10.7",
41
+ "@alepha/react-form": "0.10.7",
42
+ "@alepha/react-head": "0.10.7",
43
+ "@alepha/react-i18n": "0.10.7",
44
+ "@alepha/redis": "0.10.7",
45
+ "@alepha/retry": "0.10.7",
46
+ "@alepha/router": "0.10.7",
47
+ "@alepha/scheduler": "0.10.7",
48
+ "@alepha/security": "0.10.7",
49
+ "@alepha/server": "0.10.7",
50
+ "@alepha/server-cache": "0.10.7",
51
+ "@alepha/server-compress": "0.10.7",
52
+ "@alepha/server-cookies": "0.10.7",
53
+ "@alepha/server-cors": "0.10.7",
54
+ "@alepha/server-health": "0.10.7",
55
+ "@alepha/server-helmet": "0.10.7",
56
+ "@alepha/server-links": "0.10.7",
57
+ "@alepha/server-metrics": "0.10.7",
58
+ "@alepha/server-multipart": "0.10.7",
59
+ "@alepha/server-proxy": "0.10.7",
60
+ "@alepha/server-security": "0.10.7",
61
+ "@alepha/server-static": "0.10.7",
62
+ "@alepha/server-swagger": "0.10.7",
63
+ "@alepha/topic": "0.10.7",
64
+ "@alepha/topic-redis": "0.10.7",
65
+ "@alepha/ui": "0.10.7",
66
+ "@alepha/vite": "0.10.7"
64
67
  },
65
68
  "devDependencies": {
66
- "tsdown": "^0.15.6"
69
+ "tsdown": "^0.15.9"
67
70
  },
68
71
  "scripts": {
69
72
  "build": "node build.ts"
@@ -101,11 +104,21 @@
101
104
  "require": "./api/jobs.cjs",
102
105
  "types": "./api/jobs.d.ts"
103
106
  },
107
+ "./api/notifications": {
108
+ "import": "./api/notifications.js",
109
+ "require": "./api/notifications.cjs",
110
+ "types": "./api/notifications.d.ts"
111
+ },
104
112
  "./api/users": {
105
113
  "import": "./api/users.js",
106
114
  "require": "./api/users.cjs",
107
115
  "types": "./api/users.d.ts"
108
116
  },
117
+ "./api/verifications": {
118
+ "import": "./api/verifications.js",
119
+ "require": "./api/verifications.cjs",
120
+ "types": "./api/verifications.d.ts"
121
+ },
109
122
  "./batch": {
110
123
  "import": "./batch.js",
111
124
  "require": "./batch.cjs",
@@ -316,6 +329,11 @@
316
329
  "require": "./topic/redis.cjs",
317
330
  "types": "./topic/redis.d.ts"
318
331
  },
332
+ "./ui": {
333
+ "import": "./ui.js",
334
+ "require": "./ui.cjs",
335
+ "types": "./ui.d.ts"
336
+ },
319
337
  "./vite": {
320
338
  "import": "./vite.js",
321
339
  "require": "./vite.cjs",
@@ -326,7 +344,9 @@
326
344
  "alepha",
327
345
  "api-files",
328
346
  "api-jobs",
347
+ "api-notifications",
329
348
  "api-users",
349
+ "api-verifications",
330
350
  "batch",
331
351
  "bucket",
332
352
  "cache",
@@ -369,6 +389,7 @@
369
389
  "server-swagger",
370
390
  "topic",
371
391
  "topic-redis",
392
+ "ui",
372
393
  "vite"
373
394
  ]
374
395
  }