@igniter-js/mail 0.1.0 → 0.1.1

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/AGENTS.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @igniter-js/mail - AI Agent Instructions
2
2
 
3
- > **Package Version:** 0.1.0
4
- > **Last Updated:** 2025-01-13
3
+ > **Package Version:** 0.1.1
4
+ > **Last Updated:** 2025-01-22
5
5
  > **Status:** Ready for Publication
6
6
 
7
7
  ---
@@ -15,7 +15,8 @@
15
15
  ### Core Features
16
16
  - Type-safe email templates with React Email components
17
17
  - Runtime validation with StandardSchema support
18
- - Multiple provider adapters (Resend, Postmark, SendGrid, SMTP, Webhook)
18
+ - Multiple provider adapters (Resend, Postmark, SendGrid, SMTP)
19
+ - Mock adapter for unit testing
19
20
  - Queue integration for async email delivery
20
21
  - Lifecycle hooks for monitoring and logging
21
22
  - Builder pattern for fluent configuration
@@ -56,42 +57,46 @@ packages/mail/
56
57
  ├── src/
57
58
  │ ├── index.ts # Public exports
58
59
  │ │
59
- │ ├── core/
60
- │ │ └── igniter-mail.tsx # Core runtime logic
61
- │ │
62
- │ ├── builders/
63
- │ │ ├── igniter-mail.builder.ts # Main builder
64
- │ │ ├── mail-template.builder.ts # Template builder
65
- │ │ └── mail-provider.builder.ts # Provider builder
66
- │ │
67
60
  │ ├── adapters/
68
- │ │ ├── resend.adapter.ts # Resend provider
61
+ │ │ ├── index.ts # Adapters barrel
62
+ │ │ ├── mock.adapter.ts # In-memory mock adapter
63
+ │ │ ├── mock.adapter.spec.ts # Mock adapter tests
69
64
  │ │ ├── postmark.adapter.ts # Postmark provider
65
+ │ │ ├── postmark.adapter.spec.ts # Postmark adapter tests
66
+ │ │ ├── resend.adapter.ts # Resend provider
67
+ │ │ ├── resend.adapter.spec.ts # Resend adapter tests
70
68
  │ │ ├── sendgrid.adapter.ts # SendGrid provider
69
+ │ │ ├── sendgrid.adapter.spec.ts # SendGrid adapter tests
71
70
  │ │ ├── smtp.adapter.ts # SMTP provider
72
- │ │ ├── webhook.adapter.ts # Webhook testing adapter
73
- │ │ └── test.adapter.ts # In-memory test adapter
71
+ │ │ └── smtp.adapter.spec.ts # SMTP adapter tests
74
72
  │ │
75
- │ ├── errors/
76
- │ │ ├── igniter-mail.error.ts # Main error class
77
- │ │ └── mail-provider.error.ts # Provider-specific errors
73
+ │ ├── builders/
74
+ │ │ ├── main.builder.ts # Main builder
75
+ │ │ ├── main.builder.spec.ts # Builder tests
76
+ │ │ ├── template.builder.ts # Template builder
77
+ │ │ └── template.builder.spec.ts # Template builder tests
78
78
  │ │
79
- │ ├── interfaces/
80
- │ │ ├── adapter.interface.ts # Adapter contract (deprecated)
81
- │ │ └── provider.interface.ts # Provider contract (deprecated)
79
+ │ ├── core/
80
+ │ │ ├── manager.tsx # Core runtime logic
81
+ │ │ └── manager.spec.tsx # Core tests
82
+ │ │
83
+ │ ├── errors/
84
+ │ │ └── mail.error.ts # Main error class
82
85
  │ │
83
86
  │ ├── types/
84
87
  │ │ ├── adapter.ts # Adapter types
85
88
  │ │ ├── provider.ts # Provider types
89
+ │ │ ├── telemetry.ts # Telemetry types
86
90
  │ │ └── templates.ts # Template types
87
91
  │ │
92
+ │ ├── telemetry/
93
+ │ │ └── index.ts # Telemetry events
94
+ │ │
88
95
  │ ├── utils/
89
- │ │ ├── get-adapter.ts # Adapter resolution utility
90
- │ │ └── validate-standard-schema-input.ts # Schema validation
96
+ │ │ ├── schema.ts # StandardSchema utilities
97
+ │ │ └── schema.spec.ts # Schema tests
91
98
  │ │
92
- ├── mail.provider.tsx # Legacy provider (deprecated)
93
- │ ├── igniter-mail.spec.ts # Unit tests
94
- │ └── adapters.spec.ts # Adapter tests
99
+ └── shim.ts # Browser/client shim
95
100
 
96
101
  ├── package.json
97
102
  ├── tsconfig.json
@@ -113,9 +118,10 @@ The core class handles:
113
118
  - Template data validation using StandardSchema
114
119
  - React Email rendering (HTML + plain text)
115
120
  - Adapter orchestration
116
- - Queue integration for scheduled sends
121
+ - Queue integration for scheduled sends (requires queue adapter)
117
122
  - Lifecycle hooks (onSendStarted, onSendSuccess, onSendError)
118
123
  - Error handling and normalization
124
+ - Telemetry emission via `IgniterMailTelemetryEvents`
119
125
 
120
126
  **Key Invariants:**
121
127
  - All templates must have a `subject`, `schema`, and `render` function
@@ -155,18 +161,21 @@ Adapters **must**:
155
161
 
156
162
  ### Testing Strategy
157
163
 
158
- **Unit Tests** (`igniter-mail.spec.ts`):
159
- - Use `TestMailAdapter` for isolated core testing
164
+ **Unit Tests** (`src/core/manager.spec.tsx`):
165
+ - Use `MockMailAdapter` for isolated core testing
160
166
  - Test template validation (valid and invalid schemas)
161
167
  - Test hooks lifecycle (started, success, error)
162
- - Test queue integration (enqueue vs immediate send)
168
+ - Test queue integration (enqueue)
163
169
 
164
- **Adapter Tests** (`adapters.spec.ts`):
165
- - Test each adapter's builder and configuration
170
+ **Adapter Tests** (`src/adapters/*.spec.ts`):
171
+ - Test mock adapter tracking behavior
166
172
  - Mock provider APIs
167
173
  - Test error handling
168
174
 
169
- **Type Tests** (future):
175
+ **Builder Tests** (`src/builders/*.spec.ts`):
176
+ - Test chaining, hooks, and template builder validation
177
+
178
+ **Type Tests** (in manager spec):
170
179
  - Verify template key type inference
171
180
  - Verify payload type inference
172
181
  - Verify builder fluent API type safety
@@ -230,7 +239,7 @@ npm run test
230
239
  npm run test:watch
231
240
 
232
241
  # Run specific test file
233
- npm run test -- igniter-mail.spec.ts
242
+ npm run test -- src/core/manager.spec.tsx
234
243
  ```
235
244
 
236
245
  ### Building
@@ -271,10 +280,10 @@ While the package doesn't directly read environment variables, adapters typicall
271
280
  - `SENDGRID_API_KEY` - SendGrid API key
272
281
 
273
282
  **SMTP:**
274
- - `SMTP_HOST` - SMTP server host
275
- - `SMTP_PORT` - SMTP server port
276
- - `SMTP_USER` - SMTP username
277
- - `SMTP_PASS` - SMTP password
283
+ - Uses a connection URL passed via adapter credentials (e.g., `smtps://user:pass@host:465`)
284
+
285
+ **Validation:**
286
+ - Supports any validation library that implements `StandardSchemaV1` (Zod 3.23+ or compatible)
278
287
 
279
288
  ---
280
289
 
@@ -327,6 +336,7 @@ npm publish --access public
327
336
  | `MAIL_PROVIDER_TEMPLATE_DATA_INVALID` | Schema validation failed |
328
337
  | `MAIL_PROVIDER_SEND_FAILED` | Failed to send email |
329
338
  | `MAIL_PROVIDER_SCHEDULE_DATE_INVALID` | Schedule date is in the past |
339
+ | `MAIL_PROVIDER_SCHEDULE_QUEUE_NOT_CONFIGURED` | Queue adapter is required |
330
340
  | `MAIL_PROVIDER_SCHEDULE_FAILED` | Failed to schedule email |
331
341
  | `MAIL_PROVIDER_FROM_REQUIRED` | FROM address not configured |
332
342
  | `MAIL_PROVIDER_ADAPTER_SECRET_REQUIRED` | Adapter secret not provided |
@@ -352,11 +362,14 @@ By design, this package does NOT:
352
362
  | File | Purpose |
353
363
  |------|---------|
354
364
  | `src/index.ts` | Public exports |
355
- | `src/core/igniter-mail.tsx` | Core runtime logic |
356
- | `src/builders/igniter-mail.builder.ts` | Builder API |
365
+ | `src/core/manager.tsx` | Core runtime logic |
366
+ | `src/builders/main.builder.ts` | Builder API |
367
+ | `src/builders/template.builder.ts` | Template builder |
357
368
  | `src/adapters/*.adapter.ts` | Provider adapters |
369
+ | `src/telemetry/index.ts` | Telemetry events |
370
+ | `src/shim.ts` | Browser/client shim |
358
371
  | `src/types/*.ts` | Public types |
359
- | `src/errors/*.ts` | Error classes |
372
+ | `src/errors/mail.error.ts` | Error classes |
360
373
 
361
374
  ### Key Commands
362
375
 
@@ -387,7 +400,7 @@ When working on this package:
387
400
  ### v0.1.0 (Initial Release)
388
401
  - Core email functionality with React Email
389
402
  - Type-safe templates with StandardSchema validation
390
- - Multiple adapters (Resend, Postmark, SendGrid, SMTP, Webhook, Test)
403
+ - Multiple adapters (Resend, Postmark, SendGrid, SMTP) and mock adapter for tests
391
404
  - Queue integration for scheduled sends
392
405
  - Lifecycle hooks
393
406
  - Builder pattern API
package/CHANGELOG.md CHANGED
@@ -5,13 +5,13 @@ All notable changes to `@igniter-js/mail` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [0.1.0] - 2025-01-13
8
+ ## [0.1.1] - 2025-12-22
9
9
 
10
- ### 🎉 Initial Release
10
+ ### Initial Release
11
11
 
12
12
  First public release of `@igniter-js/mail` - a type-safe email library for Igniter.js with React Email templates.
13
13
 
14
- ### Features
14
+ ### Features
15
15
 
16
16
  #### Core Functionality
17
17
  - **Type-Safe Templates** - Full TypeScript support with compile-time inference
@@ -33,8 +33,7 @@ First public release of `@igniter-js/mail` - a type-safe email library for Ignit
33
33
  - **Postmark Adapter** - Postmark email service
34
34
  - **SendGrid Adapter** - SendGrid email service
35
35
  - **SMTP Adapter** - Standard SMTP protocol support (Nodemailer)
36
- - **Webhook Adapter** - HTTP webhook for testing
37
- - **Test Adapter** - In-memory adapter for unit tests
36
+ - **Mock Adapter** - In-memory adapter for unit tests
38
37
 
39
38
  #### Developer Experience
40
39
  - **Comprehensive Error Handling** - Typed `IgniterMailError` with stable error codes
@@ -49,14 +48,14 @@ First public release of `@igniter-js/mail` - a type-safe email library for Ignit
49
48
  - **Hook System** - Extensible hooks for monitoring and analytics
50
49
  - **Legacy API Support** - Backwards compatibility with older initialization
51
50
 
52
- ### 📦 Package Configuration
51
+ ### Package Configuration
53
52
  - ESM and CJS exports
54
53
  - TypeScript declaration files
55
54
  - Tree-shakeable exports
56
55
  - Peer dependencies for adapters (optional)
57
56
  - Source maps included
58
57
 
59
- ### 📚 Documentation
58
+ ### Documentation
60
59
  - Comprehensive README with examples
61
60
  - API reference documentation
62
61
  - Adapter configuration guides
@@ -65,7 +64,7 @@ First public release of `@igniter-js/mail` - a type-safe email library for Ignit
65
64
  - Type inference guide
66
65
  - AGENTS.md for AI agent development
67
66
 
68
- ### 🧪 Testing
67
+ ### Testing
69
68
  - Unit tests for core functionality
70
69
  - Adapter-specific tests
71
70
  - Template validation tests
package/README.md CHANGED
@@ -9,8 +9,10 @@ Type-safe email library for Igniter.js applications with React Email templates a
9
9
 
10
10
  - ✅ **Type-Safe Templates** - Full TypeScript inference with template payload validation
11
11
  - ✅ **React Email** - Build beautiful emails with React components
12
- - ✅ **Multiple Providers** - Resend, Postmark, SendGrid, SMTP, Webhook
13
- - ✅ **Schema Validation** - Runtime validation with StandardSchema support
12
+ - ✅ **Multiple Providers** - Resend, Postmark, SendGrid, SMTP
13
+ - ✅ **Mock Adapter** - In-memory adapter for unit testing
14
+ - ✅ **Schema Validation** - Runtime validation with StandardSchema (Zod 3.23+ or any StandardSchemaV1-compatible lib)
15
+ - ✅ **Telemetry Ready** - Optional integration with `@igniter-js/telemetry`
14
16
  - ✅ **Queue Integration** - Schedule emails with BullMQ or custom queues
15
17
  - ✅ **Lifecycle Hooks** - React to send events (started, success, error)
16
18
  - ✅ **Builder Pattern** - Fluent API for configuration
@@ -41,19 +43,21 @@ Install the adapter you need:
41
43
  npm install resend
42
44
  ```
43
45
 
44
- **Postmark:**
46
+ **SMTP:**
45
47
  ```bash
46
- npm install postmark
48
+ npm install nodemailer @types/nodemailer
47
49
  ```
48
50
 
49
- **SendGrid:**
51
+ ### Optional Dependencies
52
+
53
+ **Telemetry:**
50
54
  ```bash
51
- npm install sendgrid
55
+ npm install @igniter-js/telemetry
52
56
  ```
53
57
 
54
- **SMTP:**
58
+ **Validation (StandardSchemaV1-compatible):**
55
59
  ```bash
56
- npm install nodemailer @types/nodemailer
60
+ npm install zod
57
61
  ```
58
62
 
59
63
  ## Quick Start
@@ -117,7 +121,7 @@ await mail.send({
117
121
  },
118
122
  })
119
123
 
120
- // Schedule for later
124
+ // Schedule for later (requires withQueue configured)
121
125
  await mail.schedule(
122
126
  {
123
127
  to: 'user@example.com',
@@ -143,7 +147,7 @@ import { z } from 'zod'
143
147
 
144
148
  const mail = IgniterMail.create()
145
149
  .withFrom('no-reply@example.com')
146
- .withAdapter('resend', process.env.RESEND_API_KEY!)
150
+ .withAdapter('resend', process.env.IGNITER_MAIL_SECRET!)
147
151
  .addTemplate('resetPassword', {
148
152
  subject: 'Reset Your Password',
149
153
  schema: z.object({
@@ -197,7 +201,7 @@ await mail.send({
197
201
 
198
202
  ### Schema Validation
199
203
 
200
- Templates support StandardSchema for runtime validation:
204
+ Templates support StandardSchemaV1 for runtime validation (Zod 3.23+ or any compatible library):
201
205
 
202
206
  ```typescript
203
207
  import { z } from 'zod'
@@ -269,8 +273,6 @@ const mail = IgniterMail.create()
269
273
  ### Postmark
270
274
 
271
275
  ```typescript
272
- import { PostmarkMailAdapterBuilder } from '@igniter-js/mail'
273
-
274
276
  const mail = IgniterMail.create()
275
277
  .withFrom('no-reply@example.com')
276
278
  .withAdapter('postmark', process.env.POSTMARK_SERVER_TOKEN!)
@@ -303,25 +305,14 @@ const mail = IgniterMail.create()
303
305
  .build()
304
306
  ```
305
307
 
306
- ### Webhook
307
-
308
- For testing or custom integrations:
309
-
310
- ```typescript
311
- const mail = IgniterMail.create()
312
- .withFrom('no-reply@example.com')
313
- .withAdapter('webhook', 'https://webhook.site/your-unique-url')
314
- .build()
315
- ```
316
-
317
- ### Test Adapter
308
+ ### Mock Adapter
318
309
 
319
310
  For unit tests:
320
311
 
321
312
  ```typescript
322
- import { TestMailAdapter } from '@igniter-js/mail'
313
+ import { MockMailAdapter } from '@igniter-js/mail/adapters'
323
314
 
324
- const adapter = new TestMailAdapter()
315
+ const adapter = MockMailAdapter.create()
325
316
 
326
317
  const mail = IgniterMail.create()
327
318
  .withFrom('no-reply@example.com')
@@ -356,8 +347,8 @@ const mail = IgniterMail.create()
356
347
  .withFrom('no-reply@example.com')
357
348
  .withAdapter('resend', process.env.RESEND_API_KEY!)
358
349
  .withQueue(queueAdapter, {
359
- namespace: 'mail',
360
- task: 'send',
350
+ queue: 'mail',
351
+ job: 'send',
361
352
  attempts: 3,
362
353
  removeOnComplete: true,
363
354
  })
@@ -383,20 +374,39 @@ React to email sending events:
383
374
  const mail = IgniterMail.create()
384
375
  .withFrom('no-reply@example.com')
385
376
  .withAdapter('resend', process.env.RESEND_API_KEY!)
386
- .withOnSendStarted(async (params) => {
377
+ .onSendStarted(async (params) => {
387
378
  console.log('Starting to send email:', params.template)
388
379
  })
389
- .withOnSendSuccess(async (params) => {
380
+ .onSendSuccess(async (params) => {
390
381
  console.log('Email sent successfully:', params.template)
391
382
  // Log to analytics, update database, etc.
392
383
  })
393
- .withOnSendError(async (params, error) => {
384
+ .onSendError(async (params, error) => {
394
385
  console.error('Failed to send email:', error)
395
386
  // Log error, send alert, etc.
396
387
  })
397
388
  .build()
398
389
  ```
399
390
 
391
+ ## Telemetry Integration
392
+
393
+ Use `@igniter-js/telemetry` to capture mail events with a typed schema:
394
+
395
+ ```typescript
396
+ import { IgniterTelemetry } from '@igniter-js/telemetry'
397
+ import { IgniterMailTelemetryEvents } from '@igniter-js/mail/telemetry'
398
+
399
+ const telemetry = IgniterTelemetry.create()
400
+ .withService('my-api')
401
+ .addEvents(IgniterMailTelemetryEvents)
402
+ .build()
403
+
404
+ const mail = IgniterMail.create()
405
+ .withTelemetry(telemetry)
406
+ // ...
407
+ .build()
408
+ ```
409
+
400
410
  ## API Reference
401
411
 
402
412
  ### IgniterMail
@@ -420,7 +430,7 @@ await mail.send({
420
430
 
421
431
  ##### `schedule(params, date)`
422
432
 
423
- Schedules an email for a future date. Uses queue if configured, otherwise `setTimeout`.
433
+ Schedules an email for a future date. Requires a queue adapter.
424
434
 
425
435
  ```typescript
426
436
  await mail.schedule(
@@ -482,8 +492,8 @@ Enables queue-based delivery.
482
492
 
483
493
  ```typescript
484
494
  builder.withQueue(queueAdapter, {
485
- namespace: 'mail',
486
- task: 'send',
495
+ queue: 'mail',
496
+ job: 'send',
487
497
  attempts: 3,
488
498
  })
489
499
  ```
@@ -500,32 +510,32 @@ builder.addTemplate('welcome', {
500
510
  })
501
511
  ```
502
512
 
503
- ##### `withOnSendStarted(hook)`
513
+ ##### `onSendStarted(hook)`
504
514
 
505
515
  Registers a hook for send start events.
506
516
 
507
517
  ```typescript
508
- builder.withOnSendStarted(async (params) => {
518
+ builder.onSendStarted(async (params) => {
509
519
  console.log('Sending:', params.template)
510
520
  })
511
521
  ```
512
522
 
513
- ##### `withOnSendSuccess(hook)`
523
+ ##### `onSendSuccess(hook)`
514
524
 
515
525
  Registers a hook for send success events.
516
526
 
517
527
  ```typescript
518
- builder.withOnSendSuccess(async (params) => {
528
+ builder.onSendSuccess(async (params) => {
519
529
  console.log('Sent:', params.template)
520
530
  })
521
531
  ```
522
532
 
523
- ##### `withOnSendError(hook)`
533
+ ##### `onSendError(hook)`
524
534
 
525
535
  Registers a hook for send error events.
526
536
 
527
537
  ```typescript
528
- builder.withOnSendError(async (params, error) => {
538
+ builder.onSendError(async (params, error) => {
529
539
  console.error('Failed:', error)
530
540
  })
531
541
  ```
@@ -560,6 +570,7 @@ try {
560
570
  - `MAIL_PROVIDER_TEMPLATE_DATA_INVALID` - Schema validation failed
561
571
  - `MAIL_PROVIDER_SEND_FAILED` - Failed to send email
562
572
  - `MAIL_PROVIDER_SCHEDULE_DATE_INVALID` - Schedule date is in the past
573
+ - `MAIL_PROVIDER_SCHEDULE_QUEUE_NOT_CONFIGURED` - Queue adapter is required for scheduling
563
574
  - `MAIL_PROVIDER_SCHEDULE_FAILED` - Failed to schedule email
564
575
  - `MAIL_ADAPTER_CONFIGURATION_INVALID` - Adapter configuration error
565
576
 
@@ -591,7 +602,7 @@ type SendInput = typeof mail.$Infer.SendInput // Union of all send params
591
602
  2. **Use Schema Validation** - Always provide schemas for runtime safety
592
603
  3. **Leverage Hooks** - Use hooks for logging, analytics, and error tracking
593
604
  4. **Queue Heavy Loads** - Use queue integration for high-volume sending
594
- 5. **Test Adapter First** - Use TestAdapter in unit tests before deploying
605
+ 5. **Mock Adapter First** - Use MockMailAdapter in unit tests before deploying
595
606
  6. **Environment Variables** - Store API keys and secrets in environment variables
596
607
  7. **Preview Emails** - Use React Email's preview feature during development
597
608
 
@@ -649,8 +660,8 @@ const mail = IgniterMail.create()
649
660
  .withFrom('orders@example.com')
650
661
  .withAdapter('postmark', process.env.POSTMARK_TOKEN!)
651
662
  .withQueue(queueAdapter, {
652
- namespace: 'mail',
653
- task: 'send',
663
+ queue: 'mail',
664
+ job: 'send',
654
665
  attempts: 5,
655
666
  priority: 10,
656
667
  })
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Parameters used by a mail adapter to send an email.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * await adapter.send({
7
+ * to: 'user@example.com',
8
+ * subject: 'Welcome',
9
+ * html: '<p>Hello</p>',
10
+ * text: 'Hello',
11
+ * })
12
+ * ```
13
+ */
14
+ interface IgniterMailAdapterSendParams {
15
+ /** Recipient email address. */
16
+ to: string;
17
+ /** Email subject. */
18
+ subject: string;
19
+ /** HTML body. */
20
+ html: string;
21
+ /** Plain-text body. */
22
+ text: string;
23
+ /** Optional provider-level scheduled send date. */
24
+ scheduledAt?: Date;
25
+ }
26
+ /**
27
+ * Credentials required by mail adapters.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const credentials = { secret: process.env.RESEND_API_KEY, from: 'no-reply@acme.com' }
32
+ * ```
33
+ */
34
+ interface IgniterMailAdapterCredentials {
35
+ /** Provider secret, token, or connection URL. */
36
+ secret?: string;
37
+ /** Default FROM address used by the provider. */
38
+ from?: string;
39
+ }
40
+ /**
41
+ * Adapter interface used by {@link IgniterMail}.
42
+ *
43
+ * Adapters will eventually be imported from `@igniter-js/mail/adapters`.
44
+ */
45
+ interface IgniterMailAdapter {
46
+ /**
47
+ * Sends an email using the underlying provider.
48
+ *
49
+ * @param params - Normalized send parameters.
50
+ * @returns A promise that resolves when the provider accepts the email.
51
+ * @throws IgniterMailError When configuration is invalid or provider call fails.
52
+ * @example
53
+ * ```ts
54
+ * await adapter.send({ to: 'a@b.com', subject: 'Hi', html: '<p>x</p>', text: 'x' })
55
+ * ```
56
+ */
57
+ send: (params: IgniterMailAdapterSendParams) => Promise<void>;
58
+ }
59
+
60
+ export type { IgniterMailAdapter as I, IgniterMailAdapterSendParams as a, IgniterMailAdapterCredentials as b };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Parameters used by a mail adapter to send an email.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * await adapter.send({
7
+ * to: 'user@example.com',
8
+ * subject: 'Welcome',
9
+ * html: '<p>Hello</p>',
10
+ * text: 'Hello',
11
+ * })
12
+ * ```
13
+ */
14
+ interface IgniterMailAdapterSendParams {
15
+ /** Recipient email address. */
16
+ to: string;
17
+ /** Email subject. */
18
+ subject: string;
19
+ /** HTML body. */
20
+ html: string;
21
+ /** Plain-text body. */
22
+ text: string;
23
+ /** Optional provider-level scheduled send date. */
24
+ scheduledAt?: Date;
25
+ }
26
+ /**
27
+ * Credentials required by mail adapters.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const credentials = { secret: process.env.RESEND_API_KEY, from: 'no-reply@acme.com' }
32
+ * ```
33
+ */
34
+ interface IgniterMailAdapterCredentials {
35
+ /** Provider secret, token, or connection URL. */
36
+ secret?: string;
37
+ /** Default FROM address used by the provider. */
38
+ from?: string;
39
+ }
40
+ /**
41
+ * Adapter interface used by {@link IgniterMail}.
42
+ *
43
+ * Adapters will eventually be imported from `@igniter-js/mail/adapters`.
44
+ */
45
+ interface IgniterMailAdapter {
46
+ /**
47
+ * Sends an email using the underlying provider.
48
+ *
49
+ * @param params - Normalized send parameters.
50
+ * @returns A promise that resolves when the provider accepts the email.
51
+ * @throws IgniterMailError When configuration is invalid or provider call fails.
52
+ * @example
53
+ * ```ts
54
+ * await adapter.send({ to: 'a@b.com', subject: 'Hi', html: '<p>x</p>', text: 'x' })
55
+ * ```
56
+ */
57
+ send: (params: IgniterMailAdapterSendParams) => Promise<void>;
58
+ }
59
+
60
+ export type { IgniterMailAdapter as I, IgniterMailAdapterSendParams as a, IgniterMailAdapterCredentials as b };