@igniter-js/mail 0.1.11 → 0.1.13
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 +418 -302
- package/dist/adapters/index.d.mts +1 -229
- package/dist/adapters/index.d.ts +1 -229
- package/dist/index-CbiH0sth.d.mts +286 -0
- package/dist/index-CbiH0sth.d.ts +286 -0
- package/dist/index.d.mts +5 -12
- package/dist/index.d.ts +5 -12
- package/dist/index.js +36 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -23
- package/dist/index.mjs.map +1 -1
- package/dist/telemetry/index.d.mts +74 -8
- package/dist/telemetry/index.d.ts +74 -8
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/adapter-BhnIsrlh.d.mts +0 -60
- package/dist/adapter-BhnIsrlh.d.ts +0 -60
|
@@ -0,0 +1,286 @@
|
|
|
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
|
+
/**
|
|
61
|
+
* Postmark adapter.
|
|
62
|
+
*
|
|
63
|
+
* Notes:
|
|
64
|
+
* - This implementation uses `fetch` (no SDK dependency).
|
|
65
|
+
* - Designed to be extracted to `@igniter-js/mail/adapters/postmark`.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const adapter = PostmarkMailAdapter.create({
|
|
70
|
+
* secret: process.env.POSTMARK_SERVER_TOKEN,
|
|
71
|
+
* from: 'no-reply@example.com',
|
|
72
|
+
* })
|
|
73
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hello', html: '<p>Hi</p>', text: 'Hi' })
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare class PostmarkMailAdapter implements IgniterMailAdapter {
|
|
77
|
+
private readonly credentials;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new adapter instance.
|
|
80
|
+
*
|
|
81
|
+
* @param credentials - Provider credentials (secret/from).
|
|
82
|
+
* @returns A Postmark adapter instance.
|
|
83
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const adapter = PostmarkMailAdapter.create({ secret: 'token', from: 'no-reply@acme.com' })
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
static create(credentials: IgniterMailAdapterCredentials): PostmarkMailAdapter;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a new adapter instance.
|
|
92
|
+
*
|
|
93
|
+
* @param credentials - Provider credentials (secret/from).
|
|
94
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
95
|
+
*/
|
|
96
|
+
constructor(credentials?: IgniterMailAdapterCredentials);
|
|
97
|
+
/**
|
|
98
|
+
* Sends an email using Postmark (HTTP API).
|
|
99
|
+
*
|
|
100
|
+
* @param params - Normalized email parameters.
|
|
101
|
+
* @returns A promise that resolves when the email is accepted.
|
|
102
|
+
* @throws {IgniterMailError} When configuration is invalid or Postmark rejects the request.
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hello', html: '<p>Hi</p>', text: 'Hi' })
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
send(params: IgniterMailAdapterSendParams): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Resend adapter implementation.
|
|
113
|
+
*
|
|
114
|
+
* Notes:
|
|
115
|
+
* - Uses the Resend SDK.
|
|
116
|
+
* - Designed to be extracted to `@igniter-js/mail/adapters/resend`.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const adapter = ResendMailAdapter.create({
|
|
121
|
+
* secret: process.env.RESEND_API_KEY,
|
|
122
|
+
* from: 'no-reply@example.com',
|
|
123
|
+
* })
|
|
124
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hi', html: '<p>Hi</p>', text: 'Hi' })
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
declare class ResendMailAdapter implements IgniterMailAdapter {
|
|
128
|
+
private readonly credentials;
|
|
129
|
+
/**
|
|
130
|
+
* Creates a new adapter instance.
|
|
131
|
+
*
|
|
132
|
+
* @param credentials - Adapter credentials including API secret and default from.
|
|
133
|
+
* @returns A configured Resend adapter.
|
|
134
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* const adapter = ResendMailAdapter.create({ secret: 'token', from: 'no-reply@acme.com' })
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
static create(credentials: IgniterMailAdapterCredentials): ResendMailAdapter;
|
|
141
|
+
/**
|
|
142
|
+
* Creates an adapter with credentials.
|
|
143
|
+
*
|
|
144
|
+
* @param credentials - Adapter credentials including API secret and default from.
|
|
145
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
146
|
+
*/
|
|
147
|
+
constructor(credentials?: IgniterMailAdapterCredentials);
|
|
148
|
+
/**
|
|
149
|
+
* Sends an email using Resend.
|
|
150
|
+
*
|
|
151
|
+
* @param params - Email payload to send.
|
|
152
|
+
* @returns Resolves when the email is accepted by Resend.
|
|
153
|
+
* @throws {IgniterMailError} When credentials are missing or Resend rejects the request.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Welcome', html: '<p>Hi</p>', text: 'Hi' })
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
send(params: IgniterMailAdapterSendParams): Promise<void>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* SendGrid adapter implementation.
|
|
165
|
+
*
|
|
166
|
+
* Notes:
|
|
167
|
+
* - This implementation uses `fetch` (no SDK dependency).
|
|
168
|
+
* - Designed to be extracted to `@igniter-js/mail/adapters/sendgrid`.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* const adapter = SendGridMailAdapter.create({
|
|
173
|
+
* secret: process.env.SENDGRID_API_KEY,
|
|
174
|
+
* from: 'no-reply@example.com',
|
|
175
|
+
* })
|
|
176
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hello', html: '<p>Hi</p>', text: 'Hi' })
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
declare class SendGridMailAdapter implements IgniterMailAdapter {
|
|
180
|
+
private readonly credentials;
|
|
181
|
+
/**
|
|
182
|
+
* Creates a new adapter instance.
|
|
183
|
+
*
|
|
184
|
+
* @param credentials - Adapter credentials including API secret and default from.
|
|
185
|
+
* @returns A configured SendGrid adapter.
|
|
186
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* const adapter = SendGridMailAdapter.create({ secret: 'token', from: 'no-reply@acme.com' })
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
static create(credentials: IgniterMailAdapterCredentials): SendGridMailAdapter;
|
|
193
|
+
/**
|
|
194
|
+
* Creates an adapter with credentials.
|
|
195
|
+
*
|
|
196
|
+
* @param credentials - Adapter credentials including API secret and default from.
|
|
197
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
198
|
+
*/
|
|
199
|
+
constructor(credentials?: IgniterMailAdapterCredentials);
|
|
200
|
+
/**
|
|
201
|
+
* Sends an email using SendGrid (HTTP API).
|
|
202
|
+
*
|
|
203
|
+
* @param params - Email payload to send.
|
|
204
|
+
* @returns Resolves when the email is accepted by SendGrid.
|
|
205
|
+
* @throws {IgniterMailError} When credentials are missing or the API fails.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hi', html: '<p>Hi</p>', text: 'Hi' })
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
send(params: IgniterMailAdapterSendParams): Promise<void>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* SMTP adapter implementation.
|
|
217
|
+
*
|
|
218
|
+
* Notes:
|
|
219
|
+
* - Uses Nodemailer.
|
|
220
|
+
* - `credentials.secret` must be an SMTP connection URL.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* const adapter = SmtpMailAdapter.create({
|
|
225
|
+
* secret: 'smtps://user:pass@host:465',
|
|
226
|
+
* from: 'no-reply@example.com',
|
|
227
|
+
* })
|
|
228
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hi', html: '<p>Hi</p>', text: 'Hi' })
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
declare class SmtpMailAdapter implements IgniterMailAdapter {
|
|
232
|
+
private readonly credentials;
|
|
233
|
+
/**
|
|
234
|
+
* Creates a new adapter instance.
|
|
235
|
+
*
|
|
236
|
+
* @param credentials - Adapter credentials including SMTP URL and default from.
|
|
237
|
+
* @returns A configured SMTP adapter.
|
|
238
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* const adapter = SmtpMailAdapter.create({ secret: 'smtps://user:pass@host:465', from: 'no-reply@acme.com' })
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
static create(credentials: IgniterMailAdapterCredentials): SmtpMailAdapter;
|
|
245
|
+
/**
|
|
246
|
+
* Creates an adapter with credentials.
|
|
247
|
+
*
|
|
248
|
+
* @param credentials - Adapter credentials including SMTP URL and default from.
|
|
249
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
250
|
+
*/
|
|
251
|
+
constructor(credentials?: IgniterMailAdapterCredentials);
|
|
252
|
+
/**
|
|
253
|
+
* Sends an email using Nodemailer over SMTP.
|
|
254
|
+
*
|
|
255
|
+
* @param params - Email payload to send.
|
|
256
|
+
* @returns Resolves when the email is sent.
|
|
257
|
+
* @throws {IgniterMailError} When credentials are missing or the SMTP send fails.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hi', html: '<p>Hi</p>', text: 'Hi' })
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
send(params: IgniterMailAdapterSendParams): Promise<void>;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* In-memory mock adapter for `@igniter-js/mail`.
|
|
269
|
+
*
|
|
270
|
+
* Use this in tests to avoid real provider calls.
|
|
271
|
+
*/
|
|
272
|
+
declare class MockMailAdapter implements IgniterMailAdapter {
|
|
273
|
+
/** Creates a new mock adapter instance. */
|
|
274
|
+
static create(): MockMailAdapter;
|
|
275
|
+
/** Tracks all send calls. */
|
|
276
|
+
readonly sent: IgniterMailAdapterSendParams[];
|
|
277
|
+
/** Tracks method call counts. */
|
|
278
|
+
readonly calls: {
|
|
279
|
+
send: number;
|
|
280
|
+
};
|
|
281
|
+
send(params: IgniterMailAdapterSendParams): Promise<void>;
|
|
282
|
+
/** Clears all tracked state. */
|
|
283
|
+
clear(): void;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export { type IgniterMailAdapter as I, MockMailAdapter as M, PostmarkMailAdapter as P, ResendMailAdapter as R, SendGridMailAdapter as S, type IgniterMailAdapterSendParams as a, type IgniterMailAdapterCredentials as b, SmtpMailAdapter as c };
|
|
@@ -0,0 +1,286 @@
|
|
|
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
|
+
/**
|
|
61
|
+
* Postmark adapter.
|
|
62
|
+
*
|
|
63
|
+
* Notes:
|
|
64
|
+
* - This implementation uses `fetch` (no SDK dependency).
|
|
65
|
+
* - Designed to be extracted to `@igniter-js/mail/adapters/postmark`.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const adapter = PostmarkMailAdapter.create({
|
|
70
|
+
* secret: process.env.POSTMARK_SERVER_TOKEN,
|
|
71
|
+
* from: 'no-reply@example.com',
|
|
72
|
+
* })
|
|
73
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hello', html: '<p>Hi</p>', text: 'Hi' })
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare class PostmarkMailAdapter implements IgniterMailAdapter {
|
|
77
|
+
private readonly credentials;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new adapter instance.
|
|
80
|
+
*
|
|
81
|
+
* @param credentials - Provider credentials (secret/from).
|
|
82
|
+
* @returns A Postmark adapter instance.
|
|
83
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const adapter = PostmarkMailAdapter.create({ secret: 'token', from: 'no-reply@acme.com' })
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
static create(credentials: IgniterMailAdapterCredentials): PostmarkMailAdapter;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a new adapter instance.
|
|
92
|
+
*
|
|
93
|
+
* @param credentials - Provider credentials (secret/from).
|
|
94
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
95
|
+
*/
|
|
96
|
+
constructor(credentials?: IgniterMailAdapterCredentials);
|
|
97
|
+
/**
|
|
98
|
+
* Sends an email using Postmark (HTTP API).
|
|
99
|
+
*
|
|
100
|
+
* @param params - Normalized email parameters.
|
|
101
|
+
* @returns A promise that resolves when the email is accepted.
|
|
102
|
+
* @throws {IgniterMailError} When configuration is invalid or Postmark rejects the request.
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hello', html: '<p>Hi</p>', text: 'Hi' })
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
send(params: IgniterMailAdapterSendParams): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Resend adapter implementation.
|
|
113
|
+
*
|
|
114
|
+
* Notes:
|
|
115
|
+
* - Uses the Resend SDK.
|
|
116
|
+
* - Designed to be extracted to `@igniter-js/mail/adapters/resend`.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const adapter = ResendMailAdapter.create({
|
|
121
|
+
* secret: process.env.RESEND_API_KEY,
|
|
122
|
+
* from: 'no-reply@example.com',
|
|
123
|
+
* })
|
|
124
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hi', html: '<p>Hi</p>', text: 'Hi' })
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
declare class ResendMailAdapter implements IgniterMailAdapter {
|
|
128
|
+
private readonly credentials;
|
|
129
|
+
/**
|
|
130
|
+
* Creates a new adapter instance.
|
|
131
|
+
*
|
|
132
|
+
* @param credentials - Adapter credentials including API secret and default from.
|
|
133
|
+
* @returns A configured Resend adapter.
|
|
134
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* const adapter = ResendMailAdapter.create({ secret: 'token', from: 'no-reply@acme.com' })
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
static create(credentials: IgniterMailAdapterCredentials): ResendMailAdapter;
|
|
141
|
+
/**
|
|
142
|
+
* Creates an adapter with credentials.
|
|
143
|
+
*
|
|
144
|
+
* @param credentials - Adapter credentials including API secret and default from.
|
|
145
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
146
|
+
*/
|
|
147
|
+
constructor(credentials?: IgniterMailAdapterCredentials);
|
|
148
|
+
/**
|
|
149
|
+
* Sends an email using Resend.
|
|
150
|
+
*
|
|
151
|
+
* @param params - Email payload to send.
|
|
152
|
+
* @returns Resolves when the email is accepted by Resend.
|
|
153
|
+
* @throws {IgniterMailError} When credentials are missing or Resend rejects the request.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Welcome', html: '<p>Hi</p>', text: 'Hi' })
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
send(params: IgniterMailAdapterSendParams): Promise<void>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* SendGrid adapter implementation.
|
|
165
|
+
*
|
|
166
|
+
* Notes:
|
|
167
|
+
* - This implementation uses `fetch` (no SDK dependency).
|
|
168
|
+
* - Designed to be extracted to `@igniter-js/mail/adapters/sendgrid`.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* const adapter = SendGridMailAdapter.create({
|
|
173
|
+
* secret: process.env.SENDGRID_API_KEY,
|
|
174
|
+
* from: 'no-reply@example.com',
|
|
175
|
+
* })
|
|
176
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hello', html: '<p>Hi</p>', text: 'Hi' })
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
declare class SendGridMailAdapter implements IgniterMailAdapter {
|
|
180
|
+
private readonly credentials;
|
|
181
|
+
/**
|
|
182
|
+
* Creates a new adapter instance.
|
|
183
|
+
*
|
|
184
|
+
* @param credentials - Adapter credentials including API secret and default from.
|
|
185
|
+
* @returns A configured SendGrid adapter.
|
|
186
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* const adapter = SendGridMailAdapter.create({ secret: 'token', from: 'no-reply@acme.com' })
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
static create(credentials: IgniterMailAdapterCredentials): SendGridMailAdapter;
|
|
193
|
+
/**
|
|
194
|
+
* Creates an adapter with credentials.
|
|
195
|
+
*
|
|
196
|
+
* @param credentials - Adapter credentials including API secret and default from.
|
|
197
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
198
|
+
*/
|
|
199
|
+
constructor(credentials?: IgniterMailAdapterCredentials);
|
|
200
|
+
/**
|
|
201
|
+
* Sends an email using SendGrid (HTTP API).
|
|
202
|
+
*
|
|
203
|
+
* @param params - Email payload to send.
|
|
204
|
+
* @returns Resolves when the email is accepted by SendGrid.
|
|
205
|
+
* @throws {IgniterMailError} When credentials are missing or the API fails.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hi', html: '<p>Hi</p>', text: 'Hi' })
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
send(params: IgniterMailAdapterSendParams): Promise<void>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* SMTP adapter implementation.
|
|
217
|
+
*
|
|
218
|
+
* Notes:
|
|
219
|
+
* - Uses Nodemailer.
|
|
220
|
+
* - `credentials.secret` must be an SMTP connection URL.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* const adapter = SmtpMailAdapter.create({
|
|
225
|
+
* secret: 'smtps://user:pass@host:465',
|
|
226
|
+
* from: 'no-reply@example.com',
|
|
227
|
+
* })
|
|
228
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hi', html: '<p>Hi</p>', text: 'Hi' })
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
declare class SmtpMailAdapter implements IgniterMailAdapter {
|
|
232
|
+
private readonly credentials;
|
|
233
|
+
/**
|
|
234
|
+
* Creates a new adapter instance.
|
|
235
|
+
*
|
|
236
|
+
* @param credentials - Adapter credentials including SMTP URL and default from.
|
|
237
|
+
* @returns A configured SMTP adapter.
|
|
238
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* const adapter = SmtpMailAdapter.create({ secret: 'smtps://user:pass@host:465', from: 'no-reply@acme.com' })
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
static create(credentials: IgniterMailAdapterCredentials): SmtpMailAdapter;
|
|
245
|
+
/**
|
|
246
|
+
* Creates an adapter with credentials.
|
|
247
|
+
*
|
|
248
|
+
* @param credentials - Adapter credentials including SMTP URL and default from.
|
|
249
|
+
* @throws {IgniterMailError} Does not throw on creation; errors surface on send.
|
|
250
|
+
*/
|
|
251
|
+
constructor(credentials?: IgniterMailAdapterCredentials);
|
|
252
|
+
/**
|
|
253
|
+
* Sends an email using Nodemailer over SMTP.
|
|
254
|
+
*
|
|
255
|
+
* @param params - Email payload to send.
|
|
256
|
+
* @returns Resolves when the email is sent.
|
|
257
|
+
* @throws {IgniterMailError} When credentials are missing or the SMTP send fails.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* await adapter.send({ to: 'user@example.com', subject: 'Hi', html: '<p>Hi</p>', text: 'Hi' })
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
send(params: IgniterMailAdapterSendParams): Promise<void>;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* In-memory mock adapter for `@igniter-js/mail`.
|
|
269
|
+
*
|
|
270
|
+
* Use this in tests to avoid real provider calls.
|
|
271
|
+
*/
|
|
272
|
+
declare class MockMailAdapter implements IgniterMailAdapter {
|
|
273
|
+
/** Creates a new mock adapter instance. */
|
|
274
|
+
static create(): MockMailAdapter;
|
|
275
|
+
/** Tracks all send calls. */
|
|
276
|
+
readonly sent: IgniterMailAdapterSendParams[];
|
|
277
|
+
/** Tracks method call counts. */
|
|
278
|
+
readonly calls: {
|
|
279
|
+
send: number;
|
|
280
|
+
};
|
|
281
|
+
send(params: IgniterMailAdapterSendParams): Promise<void>;
|
|
282
|
+
/** Clears all tracked state. */
|
|
283
|
+
clear(): void;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export { type IgniterMailAdapter as I, MockMailAdapter as M, PostmarkMailAdapter as P, ResendMailAdapter as R, SendGridMailAdapter as S, type IgniterMailAdapterSendParams as a, type IgniterMailAdapterCredentials as b, SmtpMailAdapter as c };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { StandardSchemaV1, JobLimiter, IgniterLogger, IgniterJobQueueAdapter, IgniterError } from '@igniter-js/core';
|
|
2
|
-
import { I as IgniterMailAdapter } from './
|
|
3
|
-
export { b as IgniterMailAdapterCredentials, a as IgniterMailAdapterSendParams } from './
|
|
4
|
-
import { IgniterTelemetryManager } from '@igniter-js/telemetry';
|
|
5
|
-
import { IgniterMailTelemetryEvents } from './telemetry/index.mjs';
|
|
2
|
+
import { I as IgniterMailAdapter } from './index-CbiH0sth.mjs';
|
|
3
|
+
export { b as IgniterMailAdapterCredentials, a as IgniterMailAdapterSendParams, M as MockMailAdapter, P as PostmarkMailAdapter, R as ResendMailAdapter, S as SendGridMailAdapter, c as SmtpMailAdapter } from './index-CbiH0sth.mjs';
|
|
6
4
|
import { ReactElement } from 'react';
|
|
7
|
-
import '
|
|
8
|
-
|
|
9
|
-
type IgniterMailTelemetryRegistry = {
|
|
10
|
-
[K in IgniterMailTelemetryEvents["namespace"]]: IgniterMailTelemetryEvents["events"];
|
|
11
|
-
};
|
|
12
|
-
type IgniterMailTelemetry = IgniterTelemetryManager<IgniterMailTelemetryRegistry>;
|
|
5
|
+
import { IgniterTelemetryManager } from '@igniter-js/telemetry';
|
|
13
6
|
|
|
14
7
|
/**
|
|
15
8
|
* Email template definition used by {@link IgniterMail}.
|
|
@@ -127,7 +120,7 @@ interface IgniterMailOptions<TTemplates extends object = Record<string, IgniterM
|
|
|
127
120
|
/** Optional logger used for debug/info/error logging. */
|
|
128
121
|
logger?: IgniterLogger;
|
|
129
122
|
/** Optional telemetry instance for observability. */
|
|
130
|
-
telemetry?:
|
|
123
|
+
telemetry?: IgniterTelemetryManager<any>;
|
|
131
124
|
/** Optional queue configuration for asynchronous delivery. */
|
|
132
125
|
queue?: IgniterMailQueueConfig;
|
|
133
126
|
}
|
|
@@ -171,7 +164,7 @@ declare class IgniterMailBuilder<TTemplates extends Record<string, IgniterMailTe
|
|
|
171
164
|
/** Attaches a logger instance. */
|
|
172
165
|
withLogger(logger: IgniterLogger): this;
|
|
173
166
|
/** Attaches a telemetry instance for observability. */
|
|
174
|
-
withTelemetry(telemetry:
|
|
167
|
+
withTelemetry(telemetry: IgniterTelemetryManager<any>): this;
|
|
175
168
|
/**
|
|
176
169
|
* Enables queue delivery.
|
|
177
170
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { StandardSchemaV1, JobLimiter, IgniterLogger, IgniterJobQueueAdapter, IgniterError } from '@igniter-js/core';
|
|
2
|
-
import { I as IgniterMailAdapter } from './
|
|
3
|
-
export { b as IgniterMailAdapterCredentials, a as IgniterMailAdapterSendParams } from './
|
|
4
|
-
import { IgniterTelemetryManager } from '@igniter-js/telemetry';
|
|
5
|
-
import { IgniterMailTelemetryEvents } from './telemetry/index.js';
|
|
2
|
+
import { I as IgniterMailAdapter } from './index-CbiH0sth.js';
|
|
3
|
+
export { b as IgniterMailAdapterCredentials, a as IgniterMailAdapterSendParams, M as MockMailAdapter, P as PostmarkMailAdapter, R as ResendMailAdapter, S as SendGridMailAdapter, c as SmtpMailAdapter } from './index-CbiH0sth.js';
|
|
6
4
|
import { ReactElement } from 'react';
|
|
7
|
-
import '
|
|
8
|
-
|
|
9
|
-
type IgniterMailTelemetryRegistry = {
|
|
10
|
-
[K in IgniterMailTelemetryEvents["namespace"]]: IgniterMailTelemetryEvents["events"];
|
|
11
|
-
};
|
|
12
|
-
type IgniterMailTelemetry = IgniterTelemetryManager<IgniterMailTelemetryRegistry>;
|
|
5
|
+
import { IgniterTelemetryManager } from '@igniter-js/telemetry';
|
|
13
6
|
|
|
14
7
|
/**
|
|
15
8
|
* Email template definition used by {@link IgniterMail}.
|
|
@@ -127,7 +120,7 @@ interface IgniterMailOptions<TTemplates extends object = Record<string, IgniterM
|
|
|
127
120
|
/** Optional logger used for debug/info/error logging. */
|
|
128
121
|
logger?: IgniterLogger;
|
|
129
122
|
/** Optional telemetry instance for observability. */
|
|
130
|
-
telemetry?:
|
|
123
|
+
telemetry?: IgniterTelemetryManager<any>;
|
|
131
124
|
/** Optional queue configuration for asynchronous delivery. */
|
|
132
125
|
queue?: IgniterMailQueueConfig;
|
|
133
126
|
}
|
|
@@ -171,7 +164,7 @@ declare class IgniterMailBuilder<TTemplates extends Record<string, IgniterMailTe
|
|
|
171
164
|
/** Attaches a logger instance. */
|
|
172
165
|
withLogger(logger: IgniterLogger): this;
|
|
173
166
|
/** Attaches a telemetry instance for observability. */
|
|
174
|
-
withTelemetry(telemetry:
|
|
167
|
+
withTelemetry(telemetry: IgniterTelemetryManager<any>): this;
|
|
175
168
|
/**
|
|
176
169
|
* Enables queue delivery.
|
|
177
170
|
*
|