@orieljs/mail 0.1.0-alpha.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/LICENSE +202 -0
- package/NOTICE +9 -0
- package/dist/index.d.ts +230 -0
- package/dist/index.js +546 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Oriel
|
|
2
|
+
Copyright 2026 meeeet-dev and Oriel contributors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by the Oriel project
|
|
5
|
+
(https://orieljs.vercel.app, https://github.com/orieljs).
|
|
6
|
+
|
|
7
|
+
Oriel is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
8
|
+
The Oriel name and logo are not covered by that license; see TRADEMARKS.md
|
|
9
|
+
(https://github.com/orieljs/framework/blob/main/TRADEMARKS.md).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import * as _orieljs_contracts from '@orieljs/contracts';
|
|
2
|
+
import { OrielError, Address, MailRecipient, MailTransport, OutgoingMessage, SentMessage, Content, Mailable as Mailable$1, Attachment, Envelope, Mailer, Job, PendingMail, MailManager as MailManager$1, Container } from '@orieljs/contracts';
|
|
3
|
+
import * as _orieljs_support from '@orieljs/support';
|
|
4
|
+
import { ServiceProvider } from '@orieljs/support';
|
|
5
|
+
|
|
6
|
+
declare class UnknownMailerError extends Error implements OrielError {
|
|
7
|
+
readonly kind: "Server";
|
|
8
|
+
readonly status = 500;
|
|
9
|
+
readonly name = "UnknownMailerError";
|
|
10
|
+
constructor(name: string);
|
|
11
|
+
}
|
|
12
|
+
declare class UnknownMailTransportError extends Error implements OrielError {
|
|
13
|
+
readonly kind: "Server";
|
|
14
|
+
readonly status = 500;
|
|
15
|
+
readonly name = "UnknownMailTransportError";
|
|
16
|
+
constructor(transport: string);
|
|
17
|
+
}
|
|
18
|
+
declare class MissingRecipientError extends Error implements OrielError {
|
|
19
|
+
readonly kind: "Server";
|
|
20
|
+
readonly status = 500;
|
|
21
|
+
readonly name = "MissingRecipientError";
|
|
22
|
+
constructor();
|
|
23
|
+
}
|
|
24
|
+
declare class MailQueueUnavailableError extends Error implements OrielError {
|
|
25
|
+
readonly kind: "Server";
|
|
26
|
+
readonly status = 500;
|
|
27
|
+
readonly name = "MailQueueUnavailableError";
|
|
28
|
+
constructor();
|
|
29
|
+
}
|
|
30
|
+
declare class ViewFactoryUnavailableError extends Error implements OrielError {
|
|
31
|
+
readonly kind: "Server";
|
|
32
|
+
readonly status = 500;
|
|
33
|
+
readonly name = "ViewFactoryUnavailableError";
|
|
34
|
+
constructor(view: string);
|
|
35
|
+
}
|
|
36
|
+
declare class AllMailersFailedError extends Error implements OrielError {
|
|
37
|
+
readonly mailers: string[];
|
|
38
|
+
readonly causes: unknown[];
|
|
39
|
+
readonly kind: "Server";
|
|
40
|
+
readonly status = 500;
|
|
41
|
+
readonly name = "AllMailersFailedError";
|
|
42
|
+
constructor(mailers: string[], causes: unknown[]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A MailRecipient is a bare string, an Address, or anything with `email` (+ optional `name`), such as a User model. */
|
|
46
|
+
declare function normalizeAddress(recipient: MailRecipient): Address;
|
|
47
|
+
declare function normalizeAddresses(recipients: MailRecipient | MailRecipient[] | undefined): Address[];
|
|
48
|
+
declare function formatAddress(address: Address): string;
|
|
49
|
+
|
|
50
|
+
/** In-memory transport backing the `array` mailer: never leaves the process, so tests can inspect `sent`. */
|
|
51
|
+
declare class ArrayTransport implements MailTransport {
|
|
52
|
+
readonly sent: OutgoingMessage[];
|
|
53
|
+
send(message: OutgoingMessage): Promise<SentMessage>;
|
|
54
|
+
flush(): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Writes the message through LogManager (a channel from config, or the default channel) when bound, else console.log. */
|
|
58
|
+
declare class LogTransport implements MailTransport {
|
|
59
|
+
private readonly channel?;
|
|
60
|
+
constructor(channel?: string | undefined);
|
|
61
|
+
send(message: OutgoingMessage): Promise<SentMessage>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Tries each transport in order, returning the first success (Laravel's `failover` mailer). */
|
|
65
|
+
declare class FailoverTransport implements MailTransport {
|
|
66
|
+
private readonly transports;
|
|
67
|
+
private readonly names;
|
|
68
|
+
constructor(transports: MailTransport[], names: string[]);
|
|
69
|
+
send(message: OutgoingMessage): Promise<SentMessage>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface SmtpConfig {
|
|
73
|
+
host: string;
|
|
74
|
+
port: number;
|
|
75
|
+
encryption?: 'tls' | 'ssl' | null;
|
|
76
|
+
username?: string;
|
|
77
|
+
password?: string;
|
|
78
|
+
}
|
|
79
|
+
/** The minimal nodemailer surface this transport needs — lets tests inject a fake without a real Transporter. */
|
|
80
|
+
interface MailTransporter {
|
|
81
|
+
sendMail(options: Record<string, unknown>): Promise<{
|
|
82
|
+
messageId: string;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
type TransporterFactory = (config: SmtpConfig) => MailTransporter;
|
|
86
|
+
declare class SmtpTransport implements MailTransport {
|
|
87
|
+
private readonly transporter;
|
|
88
|
+
constructor(config: SmtpConfig, factory?: TransporterFactory);
|
|
89
|
+
send(message: OutgoingMessage): Promise<SentMessage>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface RenderedContent {
|
|
93
|
+
html?: string;
|
|
94
|
+
text?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Renders a Mailable's content() into transport-ready HTML/text. A `view`/`text` name is resolved through
|
|
98
|
+
* ViewFactory (TSX); `htmlString`/`textString` are used as-is, with no View involved at all.
|
|
99
|
+
*/
|
|
100
|
+
declare function renderContent(content: Content): Promise<RenderedContent>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Laravel-style Mailable. New code overrides envelope()/content()/attachments() directly. Legacy (pre-Laravel-9)
|
|
104
|
+
* code overrides build() instead, and calls the fluent subject()/view()/text()/html()/from()/with()/attach()
|
|
105
|
+
* methods, which feed the default envelope()/content()/attachments() below. build() runs at most once.
|
|
106
|
+
*/
|
|
107
|
+
declare abstract class Mailable implements Mailable$1 {
|
|
108
|
+
protected mailSubject?: string;
|
|
109
|
+
protected mailView?: string;
|
|
110
|
+
protected mailTextView?: string;
|
|
111
|
+
protected mailHtml?: string;
|
|
112
|
+
protected mailFrom?: MailRecipient;
|
|
113
|
+
protected mailData: Record<string, unknown>;
|
|
114
|
+
protected mailAttachments: Attachment[];
|
|
115
|
+
private built;
|
|
116
|
+
/** Legacy hook: override this and call the fluent methods below instead of envelope()/content()/attachments(). */
|
|
117
|
+
build?(): void | Promise<void>;
|
|
118
|
+
subject(subject: string): this;
|
|
119
|
+
view(view: string): this;
|
|
120
|
+
text(view: string): this;
|
|
121
|
+
html(html: string): this;
|
|
122
|
+
from(address: MailRecipient): this;
|
|
123
|
+
with(key: string | Record<string, unknown>, value?: unknown): this;
|
|
124
|
+
attach(attachment: Attachment): this;
|
|
125
|
+
private ensureBuilt;
|
|
126
|
+
envelope(): Promise<Envelope>;
|
|
127
|
+
content(): Promise<Content>;
|
|
128
|
+
attachments(): Promise<Attachment[]>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The Queue/Bus protocol's shared marker (the "Queue/Bus protocol" section of the Queue/Bus design notes):
|
|
133
|
+
* `Symbol.for('oriel:bus.shouldQueue')` is a *global* registry key, so `Symbol.for` called here returns the
|
|
134
|
+
* literal same runtime symbol Bus's `Queueable` base class and `isQueueable()` use — genuinely shared state, with
|
|
135
|
+
* no import needed (and none allowed: Mail can't import `@orieljs/bus`).
|
|
136
|
+
*/
|
|
137
|
+
declare const SHOULD_QUEUE: unique symbol;
|
|
138
|
+
|
|
139
|
+
interface RecipientOverrides {
|
|
140
|
+
to?: Address[];
|
|
141
|
+
cc?: Address[];
|
|
142
|
+
bcc?: Address[];
|
|
143
|
+
}
|
|
144
|
+
/** Builds the queue job for a mailable. Decoupled from the concrete SendQueuedMailable class so this
|
|
145
|
+
* file has no forward reference to it, and so tests can inject a fake job. */
|
|
146
|
+
type QueuedMailableFactory = (mailerName: string | undefined, mailable: Mailable$1, overrides?: RecipientOverrides) => Job;
|
|
147
|
+
declare class MailerImpl implements Mailer {
|
|
148
|
+
private readonly name;
|
|
149
|
+
private readonly transport;
|
|
150
|
+
private readonly defaultFrom;
|
|
151
|
+
private readonly makeQueuedJob;
|
|
152
|
+
constructor(name: string, transport: MailTransport, defaultFrom: Address | undefined, makeQueuedJob: QueuedMailableFactory);
|
|
153
|
+
to(recipients: MailRecipient | MailRecipient[]): PendingMail;
|
|
154
|
+
send(mailable: Mailable$1, overrides?: RecipientOverrides): Promise<SentMessage | undefined>;
|
|
155
|
+
queue(mailable: Mailable$1, overrides?: RecipientOverrides): Promise<void>;
|
|
156
|
+
later(delaySeconds: number, mailable: Mailable$1, overrides?: RecipientOverrides): Promise<void>;
|
|
157
|
+
private dispatch;
|
|
158
|
+
/** Renders and delivers immediately, bypassing the queueable check. Used by send() and by the queued job's
|
|
159
|
+
* handle(), once it's already running on the worker. */
|
|
160
|
+
sendNow(mailable: Mailable$1, overrides?: RecipientOverrides): Promise<SentMessage>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Internal-only token. `SendQueuedMailable.handle()` runs on the worker, where the mailable's ShouldQueue fields
|
|
165
|
+
* are still set — calling the public `Mailer.send()` there would re-detect it as queueable and dispatch it again,
|
|
166
|
+
* forever. `MailServiceProvider` binds this to the *same* MailManager instance as the public `MailManager` token,
|
|
167
|
+
* so `sendNow()` here always delivers immediately.
|
|
168
|
+
*/
|
|
169
|
+
interface QueuedMailSender {
|
|
170
|
+
sendNow(mailerName: string | undefined, mailable: Mailable$1, overrides?: RecipientOverrides): Promise<SentMessage>;
|
|
171
|
+
}
|
|
172
|
+
declare const QueuedMailSender: _orieljs_contracts.Token<QueuedMailSender>;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Dispatched by MailerImpl.queue()/later()/send() (when queueable). Runs on the worker: renders and delivers the
|
|
176
|
+
* mailable through QueuedMailSender, bypassing the queueable check (it's already on the worker, not the request).
|
|
177
|
+
*
|
|
178
|
+
* Carries `SHOULD_QUEUE` on its own prototype, per the Queue/Bus protocol, so `BusDispatcher.dispatch()` — which
|
|
179
|
+
* re-decides queued-or-now on whatever job it's handed — actually enqueues it instead of running it inline; the
|
|
180
|
+
* mailable's own queueability (checked by MailerImpl) only decides whether to wrap it at all. Like Laravel's
|
|
181
|
+
* SendQueuedMailable, it forwards failed(), retryUntil(), middleware() and displayName() to the mailable.
|
|
182
|
+
*/
|
|
183
|
+
declare class SendQueuedMailable implements Job {
|
|
184
|
+
readonly mailerName: string | undefined;
|
|
185
|
+
readonly mailable: Mailable$1;
|
|
186
|
+
readonly to?: Address[] | undefined;
|
|
187
|
+
readonly cc?: Address[] | undefined;
|
|
188
|
+
readonly bcc?: Address[] | undefined;
|
|
189
|
+
connection?: string;
|
|
190
|
+
queue?: string;
|
|
191
|
+
delay?: number;
|
|
192
|
+
tries?: number;
|
|
193
|
+
backoff?: number | number[];
|
|
194
|
+
timeout?: number;
|
|
195
|
+
failOnTimeout?: boolean;
|
|
196
|
+
deleteWhenMissingModels?: boolean;
|
|
197
|
+
constructor(mailerName: string | undefined, mailable: Mailable$1, to?: Address[] | undefined, cc?: Address[] | undefined, bcc?: Address[] | undefined);
|
|
198
|
+
handle(): Promise<void>;
|
|
199
|
+
/** Called by Queue after the final failed attempt. */
|
|
200
|
+
failed(error: unknown): Promise<void>;
|
|
201
|
+
/** `failed_jobs` and `queue:failed` show the mailable's class, not the wrapper's. */
|
|
202
|
+
displayName(): string;
|
|
203
|
+
retryUntil(): unknown;
|
|
204
|
+
middleware(): unknown[];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
type TransportFactory = (config: Record<string, unknown>) => MailTransport;
|
|
208
|
+
declare class MailManager implements MailManager$1, QueuedMailSender {
|
|
209
|
+
private readonly container;
|
|
210
|
+
private readonly mailers;
|
|
211
|
+
private readonly drivers;
|
|
212
|
+
constructor(container: Container);
|
|
213
|
+
private config;
|
|
214
|
+
mailer(name?: string): MailerImpl;
|
|
215
|
+
private buildTransport;
|
|
216
|
+
to(recipients: MailRecipient | MailRecipient[]): PendingMail;
|
|
217
|
+
send(mailable: Mailable$1): Promise<SentMessage | undefined>;
|
|
218
|
+
queue(mailable: Mailable$1): Promise<void>;
|
|
219
|
+
/** QueuedMailSender: always delivers immediately (see QueuedMailSender.ts for why this must bypass send()). */
|
|
220
|
+
sendNow(mailerName: string | undefined, mailable: Mailable$1, overrides?: RecipientOverrides): Promise<SentMessage>;
|
|
221
|
+
extend(transport: string, factory: TransportFactory): void;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
declare const Mail: _orieljs_support.Facade<MailManager$1, object>;
|
|
225
|
+
|
|
226
|
+
declare class MailServiceProvider extends ServiceProvider {
|
|
227
|
+
register(): void;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export { AllMailersFailedError, ArrayTransport, FailoverTransport, LogTransport, Mail, MailManager, MailQueueUnavailableError, MailServiceProvider, type MailTransporter, Mailable, MailerImpl, MissingRecipientError, QueuedMailSender, type QueuedMailableFactory, type RecipientOverrides, type RenderedContent, SHOULD_QUEUE, SendQueuedMailable, type SmtpConfig, SmtpTransport, type TransporterFactory, UnknownMailTransportError, UnknownMailerError, ViewFactoryUnavailableError, formatAddress, normalizeAddress, normalizeAddresses, renderContent };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
// errors.ts
|
|
2
|
+
var UnknownMailerError = class extends Error {
|
|
3
|
+
kind = "Server";
|
|
4
|
+
status = 500;
|
|
5
|
+
name = "UnknownMailerError";
|
|
6
|
+
constructor(name) {
|
|
7
|
+
super(`Mailer [${name}] is not configured. Add it to config('mail.mailers').`);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var UnknownMailTransportError = class extends Error {
|
|
11
|
+
kind = "Server";
|
|
12
|
+
status = 500;
|
|
13
|
+
name = "UnknownMailTransportError";
|
|
14
|
+
constructor(transport) {
|
|
15
|
+
super(`Mail transport [${transport}] is not supported. Register it first with MailManager.extend().`);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var MissingRecipientError = class extends Error {
|
|
19
|
+
kind = "Server";
|
|
20
|
+
status = 500;
|
|
21
|
+
name = "MissingRecipientError";
|
|
22
|
+
constructor() {
|
|
23
|
+
super("Cannot send mail: no recipients. Set envelope().to, or call Mail.to(...).send(mailable).");
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var MailQueueUnavailableError = class extends Error {
|
|
27
|
+
kind = "Server";
|
|
28
|
+
status = 500;
|
|
29
|
+
name = "MailQueueUnavailableError";
|
|
30
|
+
constructor() {
|
|
31
|
+
super("Queueing mail requires the Bus component. Register BusDispatcher, or call send() instead of queue()/later().");
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var ViewFactoryUnavailableError = class extends Error {
|
|
35
|
+
kind = "Server";
|
|
36
|
+
status = 500;
|
|
37
|
+
name = "ViewFactoryUnavailableError";
|
|
38
|
+
constructor(view) {
|
|
39
|
+
super(`Cannot render the [${view}] mail view: the View component isn't registered (ViewFactory is unbound).`);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var AllMailersFailedError = class extends Error {
|
|
43
|
+
constructor(mailers, causes) {
|
|
44
|
+
super(`All failover mailers failed: ${mailers.join(", ")}. Last error: ${String(causes.at(-1))}`, {
|
|
45
|
+
cause: causes.at(-1)
|
|
46
|
+
});
|
|
47
|
+
this.mailers = mailers;
|
|
48
|
+
this.causes = causes;
|
|
49
|
+
}
|
|
50
|
+
mailers;
|
|
51
|
+
causes;
|
|
52
|
+
kind = "Server";
|
|
53
|
+
status = 500;
|
|
54
|
+
name = "AllMailersFailedError";
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// address.ts
|
|
58
|
+
function normalizeAddress(recipient) {
|
|
59
|
+
if (typeof recipient === "string") return { address: recipient };
|
|
60
|
+
if ("address" in recipient) return { address: recipient.address, name: recipient.name };
|
|
61
|
+
return { address: recipient.email, name: recipient.name };
|
|
62
|
+
}
|
|
63
|
+
function normalizeAddresses(recipients) {
|
|
64
|
+
if (recipients === void 0) return [];
|
|
65
|
+
const list = Array.isArray(recipients) ? recipients : [recipients];
|
|
66
|
+
return list.map(normalizeAddress);
|
|
67
|
+
}
|
|
68
|
+
function formatAddress(address) {
|
|
69
|
+
return address.name ? `${address.name} <${address.address}>` : address.address;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// transports/ArrayTransport.ts
|
|
73
|
+
import { randomUUID } from "crypto";
|
|
74
|
+
var ArrayTransport = class {
|
|
75
|
+
sent = [];
|
|
76
|
+
async send(message) {
|
|
77
|
+
this.sent.push(message);
|
|
78
|
+
return { messageId: randomUUID(), message };
|
|
79
|
+
}
|
|
80
|
+
flush() {
|
|
81
|
+
this.sent.length = 0;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// transports/LogTransport.ts
|
|
86
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
87
|
+
import { LogManager as LogManagerToken } from "@orieljs/contracts";
|
|
88
|
+
import { currentContainer } from "@orieljs/container";
|
|
89
|
+
var LogTransport = class {
|
|
90
|
+
constructor(channel) {
|
|
91
|
+
this.channel = channel;
|
|
92
|
+
}
|
|
93
|
+
channel;
|
|
94
|
+
async send(message) {
|
|
95
|
+
const dump = formatMessage(message);
|
|
96
|
+
const container = currentContainer();
|
|
97
|
+
if (container?.bound(LogManagerToken)) {
|
|
98
|
+
const manager = container.make(LogManagerToken);
|
|
99
|
+
const logger = this.channel ? manager.channel(this.channel) : manager;
|
|
100
|
+
logger.info(dump);
|
|
101
|
+
} else {
|
|
102
|
+
console.log(dump);
|
|
103
|
+
}
|
|
104
|
+
return { messageId: randomUUID2(), message };
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
function formatMessage(message) {
|
|
108
|
+
const lines = [
|
|
109
|
+
`To: ${message.to.map(formatAddress).join(", ")}`,
|
|
110
|
+
message.cc.length > 0 ? `Cc: ${message.cc.map(formatAddress).join(", ")}` : void 0,
|
|
111
|
+
message.bcc.length > 0 ? `Bcc: ${message.bcc.map(formatAddress).join(", ")}` : void 0,
|
|
112
|
+
`From: ${formatAddress(message.from)}`,
|
|
113
|
+
`Subject: ${message.subject}`,
|
|
114
|
+
"",
|
|
115
|
+
message.text ?? stripHtml(message.html ?? "")
|
|
116
|
+
];
|
|
117
|
+
return lines.filter((line) => line !== void 0).join("\n");
|
|
118
|
+
}
|
|
119
|
+
function stripHtml(html) {
|
|
120
|
+
return html.replace(/<[^>]*>/g, "");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// transports/FailoverTransport.ts
|
|
124
|
+
var FailoverTransport = class {
|
|
125
|
+
constructor(transports, names) {
|
|
126
|
+
this.transports = transports;
|
|
127
|
+
this.names = names;
|
|
128
|
+
}
|
|
129
|
+
transports;
|
|
130
|
+
names;
|
|
131
|
+
async send(message) {
|
|
132
|
+
const causes = [];
|
|
133
|
+
for (const transport of this.transports) {
|
|
134
|
+
try {
|
|
135
|
+
return await transport.send(message);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
causes.push(error);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
throw new AllMailersFailedError(this.names, causes);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// transports/SmtpTransport.ts
|
|
145
|
+
import nodemailer from "nodemailer";
|
|
146
|
+
var defaultFactory = (config) => nodemailer.createTransport({
|
|
147
|
+
host: config.host,
|
|
148
|
+
port: config.port,
|
|
149
|
+
secure: config.encryption === "ssl",
|
|
150
|
+
requireTLS: config.encryption === "tls",
|
|
151
|
+
auth: config.username ? { user: config.username, pass: config.password } : void 0
|
|
152
|
+
});
|
|
153
|
+
var SmtpTransport = class {
|
|
154
|
+
transporter;
|
|
155
|
+
constructor(config, factory = defaultFactory) {
|
|
156
|
+
this.transporter = factory(config);
|
|
157
|
+
}
|
|
158
|
+
async send(message) {
|
|
159
|
+
const info = await this.transporter.sendMail({
|
|
160
|
+
from: formatAddress(message.from),
|
|
161
|
+
to: message.to.map(formatAddress),
|
|
162
|
+
cc: message.cc.length > 0 ? message.cc.map(formatAddress) : void 0,
|
|
163
|
+
bcc: message.bcc.length > 0 ? message.bcc.map(formatAddress) : void 0,
|
|
164
|
+
replyTo: message.replyTo.length > 0 ? message.replyTo.map(formatAddress) : void 0,
|
|
165
|
+
subject: message.subject,
|
|
166
|
+
html: message.html,
|
|
167
|
+
text: message.text,
|
|
168
|
+
headers: message.headers,
|
|
169
|
+
attachments: message.attachments.map((attachment) => ({
|
|
170
|
+
filename: attachment.name,
|
|
171
|
+
path: attachment.path,
|
|
172
|
+
content: attachment.data,
|
|
173
|
+
contentType: attachment.mime
|
|
174
|
+
}))
|
|
175
|
+
});
|
|
176
|
+
return { messageId: info.messageId, message };
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// render.ts
|
|
181
|
+
import { ViewFactory as ViewFactoryToken } from "@orieljs/contracts";
|
|
182
|
+
import { currentContainer as currentContainer2 } from "@orieljs/container";
|
|
183
|
+
async function renderContent(content) {
|
|
184
|
+
const html = content.view !== void 0 ? await renderView(content.view, content.with) : content.htmlString;
|
|
185
|
+
const text = content.text !== void 0 ? await renderView(content.text, content.with) : content.textString;
|
|
186
|
+
return { html, text };
|
|
187
|
+
}
|
|
188
|
+
async function renderView(view, data) {
|
|
189
|
+
const container = currentContainer2();
|
|
190
|
+
if (!container?.bound(ViewFactoryToken)) throw new ViewFactoryUnavailableError(view);
|
|
191
|
+
return container.make(ViewFactoryToken).make(view, data).render();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Mailable.ts
|
|
195
|
+
var Mailable = class {
|
|
196
|
+
mailSubject;
|
|
197
|
+
mailView;
|
|
198
|
+
mailTextView;
|
|
199
|
+
mailHtml;
|
|
200
|
+
mailFrom;
|
|
201
|
+
mailData = {};
|
|
202
|
+
mailAttachments = [];
|
|
203
|
+
built = false;
|
|
204
|
+
subject(subject) {
|
|
205
|
+
this.mailSubject = subject;
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
view(view) {
|
|
209
|
+
this.mailView = view;
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
text(view) {
|
|
213
|
+
this.mailTextView = view;
|
|
214
|
+
return this;
|
|
215
|
+
}
|
|
216
|
+
html(html) {
|
|
217
|
+
this.mailHtml = html;
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
from(address) {
|
|
221
|
+
this.mailFrom = address;
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
with(key, value) {
|
|
225
|
+
if (typeof key === "string") this.mailData[key] = value;
|
|
226
|
+
else Object.assign(this.mailData, key);
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
attach(attachment) {
|
|
230
|
+
this.mailAttachments.push(attachment);
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
233
|
+
async ensureBuilt() {
|
|
234
|
+
if (this.built) return;
|
|
235
|
+
this.built = true;
|
|
236
|
+
await this.build?.();
|
|
237
|
+
}
|
|
238
|
+
async envelope() {
|
|
239
|
+
await this.ensureBuilt();
|
|
240
|
+
return { subject: this.mailSubject, from: this.mailFrom };
|
|
241
|
+
}
|
|
242
|
+
async content() {
|
|
243
|
+
await this.ensureBuilt();
|
|
244
|
+
return { view: this.mailView, text: this.mailTextView, htmlString: this.mailHtml, with: this.mailData };
|
|
245
|
+
}
|
|
246
|
+
async attachments() {
|
|
247
|
+
await this.ensureBuilt();
|
|
248
|
+
return this.mailAttachments;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// symbols.ts
|
|
253
|
+
var SHOULD_QUEUE = /* @__PURE__ */ Symbol.for("oriel:bus.shouldQueue");
|
|
254
|
+
|
|
255
|
+
// Mailer.ts
|
|
256
|
+
import {
|
|
257
|
+
BusDispatcher as BusDispatcherToken
|
|
258
|
+
} from "@orieljs/contracts";
|
|
259
|
+
import { currentContainer as currentContainer3 } from "@orieljs/container";
|
|
260
|
+
function isQueueableMailable(mailable) {
|
|
261
|
+
const record = mailable;
|
|
262
|
+
if (record[SHOULD_QUEUE] === true) return true;
|
|
263
|
+
return record.connection !== void 0 || record.queue !== void 0 || record.delay !== void 0 || record.tries !== void 0 || record.backoff !== void 0 || record.timeout !== void 0 || typeof record.uniqueId === "function" || typeof record.retryUntil === "function";
|
|
264
|
+
}
|
|
265
|
+
var MailerImpl = class {
|
|
266
|
+
constructor(name, transport, defaultFrom, makeQueuedJob) {
|
|
267
|
+
this.name = name;
|
|
268
|
+
this.transport = transport;
|
|
269
|
+
this.defaultFrom = defaultFrom;
|
|
270
|
+
this.makeQueuedJob = makeQueuedJob;
|
|
271
|
+
}
|
|
272
|
+
name;
|
|
273
|
+
transport;
|
|
274
|
+
defaultFrom;
|
|
275
|
+
makeQueuedJob;
|
|
276
|
+
to(recipients) {
|
|
277
|
+
return new PendingMail(this, normalizeAddresses(recipients));
|
|
278
|
+
}
|
|
279
|
+
async send(mailable, overrides) {
|
|
280
|
+
if (isQueueableMailable(mailable)) {
|
|
281
|
+
await this.queue(mailable, overrides);
|
|
282
|
+
return void 0;
|
|
283
|
+
}
|
|
284
|
+
return this.sendNow(mailable, overrides);
|
|
285
|
+
}
|
|
286
|
+
async queue(mailable, overrides) {
|
|
287
|
+
await this.dispatch(this.makeQueuedJob(this.name, mailable, overrides));
|
|
288
|
+
}
|
|
289
|
+
async later(delaySeconds, mailable, overrides) {
|
|
290
|
+
const job = this.makeQueuedJob(this.name, mailable, overrides);
|
|
291
|
+
job.delay = delaySeconds;
|
|
292
|
+
await this.dispatch(job);
|
|
293
|
+
}
|
|
294
|
+
async dispatch(job) {
|
|
295
|
+
const container = currentContainer3();
|
|
296
|
+
if (!container?.bound(BusDispatcherToken)) throw new MailQueueUnavailableError();
|
|
297
|
+
await container.make(BusDispatcherToken).dispatch(job);
|
|
298
|
+
}
|
|
299
|
+
/** Renders and delivers immediately, bypassing the queueable check. Used by send() and by the queued job's
|
|
300
|
+
* handle(), once it's already running on the worker. */
|
|
301
|
+
async sendNow(mailable, overrides) {
|
|
302
|
+
const envelope = await mailable.envelope();
|
|
303
|
+
const to = overrides?.to && overrides.to.length > 0 ? overrides.to : normalizeAddresses(envelope.to);
|
|
304
|
+
if (to.length === 0) throw new MissingRecipientError();
|
|
305
|
+
const cc = [...normalizeAddresses(envelope.cc), ...overrides?.cc ?? []];
|
|
306
|
+
const bcc = [...normalizeAddresses(envelope.bcc), ...overrides?.bcc ?? []];
|
|
307
|
+
const replyTo = normalizeAddresses(envelope.replyTo);
|
|
308
|
+
const from = envelope.from ? normalizeAddress(envelope.from) : this.defaultFrom;
|
|
309
|
+
if (!from) throw new MissingRecipientError();
|
|
310
|
+
const content = await mailable.content();
|
|
311
|
+
const rendered = await renderContent(content);
|
|
312
|
+
const attachments = await mailable.attachments?.() ?? [];
|
|
313
|
+
const message = {
|
|
314
|
+
from,
|
|
315
|
+
to,
|
|
316
|
+
cc,
|
|
317
|
+
bcc,
|
|
318
|
+
replyTo,
|
|
319
|
+
subject: envelope.subject ?? "",
|
|
320
|
+
html: rendered.html,
|
|
321
|
+
text: rendered.text,
|
|
322
|
+
attachments,
|
|
323
|
+
headers: {}
|
|
324
|
+
};
|
|
325
|
+
return this.transport.send(message);
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
var PendingMail = class {
|
|
329
|
+
constructor(mailer, toList) {
|
|
330
|
+
this.mailer = mailer;
|
|
331
|
+
this.toList = toList;
|
|
332
|
+
}
|
|
333
|
+
mailer;
|
|
334
|
+
toList;
|
|
335
|
+
ccList = [];
|
|
336
|
+
bccList = [];
|
|
337
|
+
cc(recipients) {
|
|
338
|
+
this.ccList.push(...normalizeAddresses(recipients));
|
|
339
|
+
return this;
|
|
340
|
+
}
|
|
341
|
+
bcc(recipients) {
|
|
342
|
+
this.bccList.push(...normalizeAddresses(recipients));
|
|
343
|
+
return this;
|
|
344
|
+
}
|
|
345
|
+
overrides() {
|
|
346
|
+
return { to: this.toList, cc: this.ccList, bcc: this.bccList };
|
|
347
|
+
}
|
|
348
|
+
async send(mailable) {
|
|
349
|
+
return this.mailer.send(mailable, this.overrides());
|
|
350
|
+
}
|
|
351
|
+
async queue(mailable) {
|
|
352
|
+
await this.mailer.queue(mailable, this.overrides());
|
|
353
|
+
}
|
|
354
|
+
async later(delaySeconds, mailable) {
|
|
355
|
+
await this.mailer.later(delaySeconds, mailable, this.overrides());
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
// QueuedMailSender.ts
|
|
360
|
+
import { token } from "@orieljs/contracts";
|
|
361
|
+
var QueuedMailSender = token("Mail.QueuedMailSender");
|
|
362
|
+
|
|
363
|
+
// Jobs/SendQueuedMailable.ts
|
|
364
|
+
import { inject } from "@orieljs/container";
|
|
365
|
+
var QUEUE_OPTIONS = [
|
|
366
|
+
"connection",
|
|
367
|
+
"queue",
|
|
368
|
+
"delay",
|
|
369
|
+
"tries",
|
|
370
|
+
"backoff",
|
|
371
|
+
"timeout",
|
|
372
|
+
"failOnTimeout",
|
|
373
|
+
"deleteWhenMissingModels"
|
|
374
|
+
];
|
|
375
|
+
function copyShouldQueueFields(target, source) {
|
|
376
|
+
const fields = source;
|
|
377
|
+
for (const option of QUEUE_OPTIONS) {
|
|
378
|
+
if (fields[option] !== void 0) target[option] = fields[option];
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
var SendQueuedMailable = class {
|
|
382
|
+
constructor(mailerName, mailable, to, cc, bcc) {
|
|
383
|
+
this.mailerName = mailerName;
|
|
384
|
+
this.mailable = mailable;
|
|
385
|
+
this.to = to;
|
|
386
|
+
this.cc = cc;
|
|
387
|
+
this.bcc = bcc;
|
|
388
|
+
copyShouldQueueFields(this, mailable);
|
|
389
|
+
}
|
|
390
|
+
mailerName;
|
|
391
|
+
mailable;
|
|
392
|
+
to;
|
|
393
|
+
cc;
|
|
394
|
+
bcc;
|
|
395
|
+
async handle() {
|
|
396
|
+
await inject(QueuedMailSender).sendNow(this.mailerName, this.mailable, { to: this.to, cc: this.cc, bcc: this.bcc });
|
|
397
|
+
}
|
|
398
|
+
/** Called by Queue after the final failed attempt. */
|
|
399
|
+
async failed(error) {
|
|
400
|
+
const hooks = this.mailable;
|
|
401
|
+
if (typeof hooks.failed === "function") await hooks.failed.call(this.mailable, error);
|
|
402
|
+
}
|
|
403
|
+
/** `failed_jobs` and `queue:failed` show the mailable's class, not the wrapper's. */
|
|
404
|
+
displayName() {
|
|
405
|
+
return this.mailable.constructor.name;
|
|
406
|
+
}
|
|
407
|
+
retryUntil() {
|
|
408
|
+
const hooks = this.mailable;
|
|
409
|
+
return typeof hooks.retryUntil === "function" ? hooks.retryUntil.call(this.mailable) : void 0;
|
|
410
|
+
}
|
|
411
|
+
middleware() {
|
|
412
|
+
const declared = this.mailable.middleware;
|
|
413
|
+
return (typeof declared === "function" ? declared.call(this.mailable) : declared) ?? [];
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
SendQueuedMailable.prototype[SHOULD_QUEUE] = true;
|
|
417
|
+
|
|
418
|
+
// MailManager.ts
|
|
419
|
+
import {
|
|
420
|
+
ConfigRepository
|
|
421
|
+
} from "@orieljs/contracts";
|
|
422
|
+
var MailManager = class {
|
|
423
|
+
constructor(container) {
|
|
424
|
+
this.container = container;
|
|
425
|
+
}
|
|
426
|
+
container;
|
|
427
|
+
mailers = /* @__PURE__ */ new Map();
|
|
428
|
+
drivers = /* @__PURE__ */ new Map([
|
|
429
|
+
["array", () => new ArrayTransport()],
|
|
430
|
+
["log", (config) => new LogTransport(config.channel)],
|
|
431
|
+
[
|
|
432
|
+
"smtp",
|
|
433
|
+
(config) => new SmtpTransport({
|
|
434
|
+
host: String(config.host ?? "127.0.0.1"),
|
|
435
|
+
port: Number(config.port ?? 2525),
|
|
436
|
+
encryption: config.encryption ?? null,
|
|
437
|
+
username: config.username,
|
|
438
|
+
password: config.password
|
|
439
|
+
})
|
|
440
|
+
]
|
|
441
|
+
]);
|
|
442
|
+
config() {
|
|
443
|
+
return this.container.make(ConfigRepository);
|
|
444
|
+
}
|
|
445
|
+
mailer(name) {
|
|
446
|
+
const mailerName = name ?? this.config().get("mail.default", "log");
|
|
447
|
+
const cached = this.mailers.get(mailerName);
|
|
448
|
+
if (cached) return cached;
|
|
449
|
+
const config = this.config().get(`mail.mailers.${mailerName}`);
|
|
450
|
+
if (!config) throw new UnknownMailerError(mailerName);
|
|
451
|
+
const transport = this.buildTransport(String(config.transport ?? ""), config);
|
|
452
|
+
const from = this.config().get("mail.from");
|
|
453
|
+
const impl = new MailerImpl(
|
|
454
|
+
mailerName,
|
|
455
|
+
transport,
|
|
456
|
+
from,
|
|
457
|
+
(mailerNameArg, mailable, overrides) => new SendQueuedMailable(mailerNameArg, mailable, overrides?.to, overrides?.cc, overrides?.bcc)
|
|
458
|
+
);
|
|
459
|
+
this.mailers.set(mailerName, impl);
|
|
460
|
+
return impl;
|
|
461
|
+
}
|
|
462
|
+
buildTransport(transportName, config) {
|
|
463
|
+
if (transportName === "failover") {
|
|
464
|
+
const names = config.mailers ?? [];
|
|
465
|
+
const transports = names.map((mailerName) => {
|
|
466
|
+
const mailerConfig = this.config().get(`mail.mailers.${mailerName}`);
|
|
467
|
+
if (!mailerConfig) throw new UnknownMailerError(mailerName);
|
|
468
|
+
return this.buildTransport(String(mailerConfig.transport ?? ""), mailerConfig);
|
|
469
|
+
});
|
|
470
|
+
return new FailoverTransport(transports, names);
|
|
471
|
+
}
|
|
472
|
+
const factory = this.drivers.get(transportName);
|
|
473
|
+
if (!factory) throw new UnknownMailTransportError(transportName);
|
|
474
|
+
return factory(config);
|
|
475
|
+
}
|
|
476
|
+
to(recipients) {
|
|
477
|
+
return this.mailer().to(recipients);
|
|
478
|
+
}
|
|
479
|
+
async send(mailable) {
|
|
480
|
+
return this.mailer().send(mailable);
|
|
481
|
+
}
|
|
482
|
+
async queue(mailable) {
|
|
483
|
+
await this.mailer().queue(mailable);
|
|
484
|
+
}
|
|
485
|
+
/** QueuedMailSender: always delivers immediately (see QueuedMailSender.ts for why this must bypass send()). */
|
|
486
|
+
async sendNow(mailerName, mailable, overrides) {
|
|
487
|
+
return this.mailer(mailerName).sendNow(mailable, overrides);
|
|
488
|
+
}
|
|
489
|
+
extend(transport, factory) {
|
|
490
|
+
this.drivers.set(transport, factory);
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
// facade.ts
|
|
495
|
+
import { MailManager as MailManagerToken } from "@orieljs/contracts";
|
|
496
|
+
import { facade } from "@orieljs/support";
|
|
497
|
+
var Mail = facade(MailManagerToken);
|
|
498
|
+
|
|
499
|
+
// MailServiceProvider.ts
|
|
500
|
+
import { ClassRegistry as ClassRegistryToken, MailManager as MailManagerToken2 } from "@orieljs/contracts";
|
|
501
|
+
import { ServiceProvider } from "@orieljs/support";
|
|
502
|
+
var MailServiceProvider = class extends ServiceProvider {
|
|
503
|
+
register() {
|
|
504
|
+
this.mergeConfigFrom(
|
|
505
|
+
{
|
|
506
|
+
default: "log",
|
|
507
|
+
mailers: {
|
|
508
|
+
smtp: { transport: "smtp", host: "127.0.0.1", port: 2525 },
|
|
509
|
+
log: { transport: "log" },
|
|
510
|
+
array: { transport: "array" },
|
|
511
|
+
failover: { transport: "failover", mailers: ["smtp", "log"] }
|
|
512
|
+
},
|
|
513
|
+
from: { address: "hello@example.com", name: "Example" }
|
|
514
|
+
},
|
|
515
|
+
"mail"
|
|
516
|
+
);
|
|
517
|
+
this.app.singleton(MailManagerToken2, (container) => new MailManager(container));
|
|
518
|
+
this.app.singleton(QueuedMailSender, (container) => container.make(MailManagerToken2));
|
|
519
|
+
this.app.make(ClassRegistryToken).register(SendQueuedMailable, "Mail.SendQueuedMailable");
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
export {
|
|
523
|
+
AllMailersFailedError,
|
|
524
|
+
ArrayTransport,
|
|
525
|
+
FailoverTransport,
|
|
526
|
+
LogTransport,
|
|
527
|
+
Mail,
|
|
528
|
+
MailManager,
|
|
529
|
+
MailQueueUnavailableError,
|
|
530
|
+
MailServiceProvider,
|
|
531
|
+
Mailable,
|
|
532
|
+
MailerImpl,
|
|
533
|
+
MissingRecipientError,
|
|
534
|
+
QueuedMailSender,
|
|
535
|
+
SHOULD_QUEUE,
|
|
536
|
+
SendQueuedMailable,
|
|
537
|
+
SmtpTransport,
|
|
538
|
+
UnknownMailTransportError,
|
|
539
|
+
UnknownMailerError,
|
|
540
|
+
ViewFactoryUnavailableError,
|
|
541
|
+
formatAddress,
|
|
542
|
+
normalizeAddress,
|
|
543
|
+
normalizeAddresses,
|
|
544
|
+
renderContent
|
|
545
|
+
};
|
|
546
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../errors.ts","../address.ts","../transports/ArrayTransport.ts","../transports/LogTransport.ts","../transports/FailoverTransport.ts","../transports/SmtpTransport.ts","../render.ts","../Mailable.ts","../symbols.ts","../Mailer.ts","../QueuedMailSender.ts","../Jobs/SendQueuedMailable.ts","../MailManager.ts","../facade.ts","../MailServiceProvider.ts"],"sourcesContent":["import type { OrielError } from '@orieljs/contracts'\n\nexport class UnknownMailerError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'UnknownMailerError'\n constructor(name: string) {\n super(`Mailer [${name}] is not configured. Add it to config('mail.mailers').`)\n }\n}\n\nexport class UnknownMailTransportError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'UnknownMailTransportError'\n constructor(transport: string) {\n super(`Mail transport [${transport}] is not supported. Register it first with MailManager.extend().`)\n }\n}\n\nexport class MissingRecipientError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'MissingRecipientError'\n constructor() {\n super('Cannot send mail: no recipients. Set envelope().to, or call Mail.to(...).send(mailable).')\n }\n}\n\nexport class MailQueueUnavailableError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'MailQueueUnavailableError'\n constructor() {\n super('Queueing mail requires the Bus component. Register BusDispatcher, or call send() instead of queue()/later().')\n }\n}\n\nexport class ViewFactoryUnavailableError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'ViewFactoryUnavailableError'\n constructor(view: string) {\n super(`Cannot render the [${view}] mail view: the View component isn't registered (ViewFactory is unbound).`)\n }\n}\n\nexport class AllMailersFailedError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'AllMailersFailedError'\n constructor(\n readonly mailers: string[],\n readonly causes: unknown[],\n ) {\n super(`All failover mailers failed: ${mailers.join(', ')}. Last error: ${String(causes.at(-1))}`, {\n cause: causes.at(-1),\n })\n }\n}\n","import type { Address, MailRecipient } from '@orieljs/contracts'\n\n/** A MailRecipient is a bare string, an Address, or anything with `email` (+ optional `name`), such as a User model. */\nexport function normalizeAddress(recipient: MailRecipient): Address {\n if (typeof recipient === 'string') return { address: recipient }\n if ('address' in recipient) return { address: recipient.address, name: recipient.name }\n return { address: recipient.email, name: recipient.name }\n}\n\nexport function normalizeAddresses(recipients: MailRecipient | MailRecipient[] | undefined): Address[] {\n if (recipients === undefined) return []\n const list = Array.isArray(recipients) ? recipients : [recipients]\n return list.map(normalizeAddress)\n}\n\nexport function formatAddress(address: Address): string {\n return address.name ? `${address.name} <${address.address}>` : address.address\n}\n","import { randomUUID } from 'node:crypto'\nimport type { MailTransport, OutgoingMessage, SentMessage } from '@orieljs/contracts'\n\n/** In-memory transport backing the `array` mailer: never leaves the process, so tests can inspect `sent`. */\nexport class ArrayTransport implements MailTransport {\n readonly sent: OutgoingMessage[] = []\n\n async send(message: OutgoingMessage): Promise<SentMessage> {\n this.sent.push(message)\n return { messageId: randomUUID(), message }\n }\n\n flush(): void {\n this.sent.length = 0\n }\n}\n","import { randomUUID } from 'node:crypto'\nimport { LogManager as LogManagerToken, type MailTransport, type OutgoingMessage, type SentMessage } from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport { formatAddress } from '../address'\n\n/** Writes the message through LogManager (a channel from config, or the default channel) when bound, else console.log. */\nexport class LogTransport implements MailTransport {\n constructor(private readonly channel?: string) {}\n\n async send(message: OutgoingMessage): Promise<SentMessage> {\n const dump = formatMessage(message)\n const container = currentContainer()\n if (container?.bound(LogManagerToken)) {\n const manager = container.make(LogManagerToken)\n const logger = this.channel ? manager.channel(this.channel) : manager\n logger.info(dump)\n } else {\n console.log(dump)\n }\n return { messageId: randomUUID(), message }\n }\n}\n\nfunction formatMessage(message: OutgoingMessage): string {\n const lines = [\n `To: ${message.to.map(formatAddress).join(', ')}`,\n message.cc.length > 0 ? `Cc: ${message.cc.map(formatAddress).join(', ')}` : undefined,\n message.bcc.length > 0 ? `Bcc: ${message.bcc.map(formatAddress).join(', ')}` : undefined,\n `From: ${formatAddress(message.from)}`,\n `Subject: ${message.subject}`,\n '',\n message.text ?? stripHtml(message.html ?? ''),\n ]\n return lines.filter((line): line is string => line !== undefined).join('\\n')\n}\n\nfunction stripHtml(html: string): string {\n return html.replace(/<[^>]*>/g, '')\n}\n","import type { MailTransport, OutgoingMessage, SentMessage } from '@orieljs/contracts'\nimport { AllMailersFailedError } from '../errors'\n\n/** Tries each transport in order, returning the first success (Laravel's `failover` mailer). */\nexport class FailoverTransport implements MailTransport {\n constructor(\n private readonly transports: MailTransport[],\n private readonly names: string[],\n ) {}\n\n async send(message: OutgoingMessage): Promise<SentMessage> {\n const causes: unknown[] = []\n for (const transport of this.transports) {\n try {\n return await transport.send(message)\n } catch (error) {\n causes.push(error)\n }\n }\n throw new AllMailersFailedError(this.names, causes)\n }\n}\n","import nodemailer from 'nodemailer'\nimport type { MailTransport, OutgoingMessage, SentMessage } from '@orieljs/contracts'\nimport { formatAddress } from '../address'\n\nexport interface SmtpConfig {\n host: string\n port: number\n encryption?: 'tls' | 'ssl' | null\n username?: string\n password?: string\n}\n\n/** The minimal nodemailer surface this transport needs — lets tests inject a fake without a real Transporter. */\nexport interface MailTransporter {\n sendMail(options: Record<string, unknown>): Promise<{ messageId: string }>\n}\n\nexport type TransporterFactory = (config: SmtpConfig) => MailTransporter\n\nconst defaultFactory: TransporterFactory = (config) =>\n nodemailer.createTransport({\n host: config.host,\n port: config.port,\n secure: config.encryption === 'ssl',\n requireTLS: config.encryption === 'tls',\n auth: config.username ? { user: config.username, pass: config.password } : undefined,\n })\n\nexport class SmtpTransport implements MailTransport {\n private readonly transporter: MailTransporter\n\n constructor(config: SmtpConfig, factory: TransporterFactory = defaultFactory) {\n this.transporter = factory(config)\n }\n\n async send(message: OutgoingMessage): Promise<SentMessage> {\n const info = await this.transporter.sendMail({\n from: formatAddress(message.from),\n to: message.to.map(formatAddress),\n cc: message.cc.length > 0 ? message.cc.map(formatAddress) : undefined,\n bcc: message.bcc.length > 0 ? message.bcc.map(formatAddress) : undefined,\n replyTo: message.replyTo.length > 0 ? message.replyTo.map(formatAddress) : undefined,\n subject: message.subject,\n html: message.html,\n text: message.text,\n headers: message.headers,\n attachments: message.attachments.map((attachment) => ({\n filename: attachment.name,\n path: attachment.path,\n content: attachment.data,\n contentType: attachment.mime,\n })),\n })\n return { messageId: info.messageId, message }\n }\n}\n","import { ViewFactory as ViewFactoryToken, type Content } from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport { ViewFactoryUnavailableError } from './errors'\n\nexport interface RenderedContent {\n html?: string\n text?: string\n}\n\n/**\n * Renders a Mailable's content() into transport-ready HTML/text. A `view`/`text` name is resolved through\n * ViewFactory (TSX); `htmlString`/`textString` are used as-is, with no View involved at all.\n */\nexport async function renderContent(content: Content): Promise<RenderedContent> {\n const html = content.view !== undefined ? await renderView(content.view, content.with) : content.htmlString\n const text = content.text !== undefined ? await renderView(content.text, content.with) : content.textString\n return { html, text }\n}\n\nasync function renderView(view: string, data: Record<string, unknown> | undefined): Promise<string> {\n const container = currentContainer()\n if (!container?.bound(ViewFactoryToken)) throw new ViewFactoryUnavailableError(view)\n return container.make(ViewFactoryToken).make(view, data).render()\n}\n","import type { Attachment, Content, Envelope, MailRecipient, Mailable as MailableContract } from '@orieljs/contracts'\n\n/**\n * Laravel-style Mailable. New code overrides envelope()/content()/attachments() directly. Legacy (pre-Laravel-9)\n * code overrides build() instead, and calls the fluent subject()/view()/text()/html()/from()/with()/attach()\n * methods, which feed the default envelope()/content()/attachments() below. build() runs at most once.\n */\nexport abstract class Mailable implements MailableContract {\n protected mailSubject?: string\n protected mailView?: string\n protected mailTextView?: string\n protected mailHtml?: string\n protected mailFrom?: MailRecipient\n protected mailData: Record<string, unknown> = {}\n protected mailAttachments: Attachment[] = []\n private built = false\n\n /** Legacy hook: override this and call the fluent methods below instead of envelope()/content()/attachments(). */\n build?(): void | Promise<void>\n\n subject(subject: string): this {\n this.mailSubject = subject\n return this\n }\n\n view(view: string): this {\n this.mailView = view\n return this\n }\n\n text(view: string): this {\n this.mailTextView = view\n return this\n }\n\n html(html: string): this {\n this.mailHtml = html\n return this\n }\n\n from(address: MailRecipient): this {\n this.mailFrom = address\n return this\n }\n\n with(key: string | Record<string, unknown>, value?: unknown): this {\n if (typeof key === 'string') this.mailData[key] = value\n else Object.assign(this.mailData, key)\n return this\n }\n\n attach(attachment: Attachment): this {\n this.mailAttachments.push(attachment)\n return this\n }\n\n private async ensureBuilt(): Promise<void> {\n if (this.built) return\n this.built = true\n await this.build?.()\n }\n\n async envelope(): Promise<Envelope> {\n await this.ensureBuilt()\n return { subject: this.mailSubject, from: this.mailFrom }\n }\n\n async content(): Promise<Content> {\n await this.ensureBuilt()\n return { view: this.mailView, text: this.mailTextView, htmlString: this.mailHtml, with: this.mailData }\n }\n\n async attachments(): Promise<Attachment[]> {\n await this.ensureBuilt()\n return this.mailAttachments\n }\n}\n","/**\n * The Queue/Bus protocol's shared marker (the \"Queue/Bus protocol\" section of the Queue/Bus design notes):\n * `Symbol.for('oriel:bus.shouldQueue')` is a *global* registry key, so `Symbol.for` called here returns the\n * literal same runtime symbol Bus's `Queueable` base class and `isQueueable()` use — genuinely shared state, with\n * no import needed (and none allowed: Mail can't import `@orieljs/bus`).\n */\nexport const SHOULD_QUEUE: unique symbol = Symbol.for('oriel:bus.shouldQueue')\n","import {\n BusDispatcher as BusDispatcherToken,\n type Address,\n type Job,\n type Mailable,\n type MailRecipient,\n type Mailer as MailerContract,\n type MailTransport,\n type OutgoingMessage,\n type PendingMail as PendingMailContract,\n type SentMessage,\n} from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport { normalizeAddress, normalizeAddresses } from './address'\nimport { MailQueueUnavailableError, MissingRecipientError } from './errors'\nimport { renderContent } from './render'\nimport { SHOULD_QUEUE } from './symbols'\n\nexport interface RecipientOverrides {\n to?: Address[]\n cc?: Address[]\n bcc?: Address[]\n}\n\n/** Builds the queue job for a mailable. Decoupled from the concrete SendQueuedMailable class so this\n * file has no forward reference to it, and so tests can inject a fake job. */\nexport type QueuedMailableFactory = (\n mailerName: string | undefined,\n mailable: Mailable,\n overrides?: RecipientOverrides,\n) => Job\n\n/**\n * Matches the Queue/Bus protocol's `isQueueable()` exactly: true when the mailable carries\n * `SHOULD_QUEUE === true`, or has a defined value for any of ShouldQueue's fields, or declares a\n * `uniqueId()`/`retryUntil()` method. `implements ShouldQueue` itself leaves no trace at runtime. Call\n * queue()/later() explicitly to queue a mailable that declares none of these.\n */\nfunction isQueueableMailable(mailable: Mailable): boolean {\n const record = mailable as unknown as Record<PropertyKey, unknown>\n if (record[SHOULD_QUEUE] === true) return true\n return (\n record.connection !== undefined ||\n record.queue !== undefined ||\n record.delay !== undefined ||\n record.tries !== undefined ||\n record.backoff !== undefined ||\n record.timeout !== undefined ||\n typeof record.uniqueId === 'function' ||\n typeof record.retryUntil === 'function'\n )\n}\n\nexport class MailerImpl implements MailerContract {\n constructor(\n private readonly name: string,\n private readonly transport: MailTransport,\n private readonly defaultFrom: Address | undefined,\n private readonly makeQueuedJob: QueuedMailableFactory,\n ) {}\n\n to(recipients: MailRecipient | MailRecipient[]): PendingMailContract {\n return new PendingMail(this, normalizeAddresses(recipients))\n }\n\n async send(mailable: Mailable, overrides?: RecipientOverrides): Promise<SentMessage | undefined> {\n if (isQueueableMailable(mailable)) {\n await this.queue(mailable, overrides)\n return undefined\n }\n return this.sendNow(mailable, overrides)\n }\n\n async queue(mailable: Mailable, overrides?: RecipientOverrides): Promise<void> {\n await this.dispatch(this.makeQueuedJob(this.name, mailable, overrides))\n }\n\n async later(delaySeconds: number, mailable: Mailable, overrides?: RecipientOverrides): Promise<void> {\n const job = this.makeQueuedJob(this.name, mailable, overrides)\n job.delay = delaySeconds\n await this.dispatch(job)\n }\n\n private async dispatch(job: Job): Promise<void> {\n const container = currentContainer()\n if (!container?.bound(BusDispatcherToken)) throw new MailQueueUnavailableError()\n await container.make(BusDispatcherToken).dispatch(job)\n }\n\n /** Renders and delivers immediately, bypassing the queueable check. Used by send() and by the queued job's\n * handle(), once it's already running on the worker. */\n async sendNow(mailable: Mailable, overrides?: RecipientOverrides): Promise<SentMessage> {\n const envelope = await mailable.envelope()\n const to = overrides?.to && overrides.to.length > 0 ? overrides.to : normalizeAddresses(envelope.to)\n if (to.length === 0) throw new MissingRecipientError()\n const cc = [...normalizeAddresses(envelope.cc), ...(overrides?.cc ?? [])]\n const bcc = [...normalizeAddresses(envelope.bcc), ...(overrides?.bcc ?? [])]\n const replyTo = normalizeAddresses(envelope.replyTo)\n const from = envelope.from ? normalizeAddress(envelope.from) : this.defaultFrom\n if (!from) throw new MissingRecipientError()\n const content = await mailable.content()\n const rendered = await renderContent(content)\n const attachments = (await mailable.attachments?.()) ?? []\n const message: OutgoingMessage = {\n from,\n to,\n cc,\n bcc,\n replyTo,\n subject: envelope.subject ?? '',\n html: rendered.html,\n text: rendered.text,\n attachments,\n headers: {},\n }\n return this.transport.send(message)\n }\n}\n\nclass PendingMail implements PendingMailContract {\n private readonly ccList: Address[] = []\n private readonly bccList: Address[] = []\n\n constructor(\n private readonly mailer: MailerImpl,\n private readonly toList: Address[],\n ) {}\n\n cc(recipients: MailRecipient | MailRecipient[]): this {\n this.ccList.push(...normalizeAddresses(recipients))\n return this\n }\n\n bcc(recipients: MailRecipient | MailRecipient[]): this {\n this.bccList.push(...normalizeAddresses(recipients))\n return this\n }\n\n private overrides(): RecipientOverrides {\n return { to: this.toList, cc: this.ccList, bcc: this.bccList }\n }\n\n async send(mailable: Mailable): Promise<SentMessage | undefined> {\n return this.mailer.send(mailable, this.overrides())\n }\n\n async queue(mailable: Mailable): Promise<void> {\n await this.mailer.queue(mailable, this.overrides())\n }\n\n async later(delaySeconds: number, mailable: Mailable): Promise<void> {\n await this.mailer.later(delaySeconds, mailable, this.overrides())\n }\n}\n","import { token, type Mailable, type SentMessage } from '@orieljs/contracts'\nimport type { RecipientOverrides } from './Mailer'\n\n/**\n * Internal-only token. `SendQueuedMailable.handle()` runs on the worker, where the mailable's ShouldQueue fields\n * are still set — calling the public `Mailer.send()` there would re-detect it as queueable and dispatch it again,\n * forever. `MailServiceProvider` binds this to the *same* MailManager instance as the public `MailManager` token,\n * so `sendNow()` here always delivers immediately.\n */\nexport interface QueuedMailSender {\n sendNow(mailerName: string | undefined, mailable: Mailable, overrides?: RecipientOverrides): Promise<SentMessage>\n}\nexport const QueuedMailSender = token<QueuedMailSender>('Mail.QueuedMailSender')\n","import type { Address, Job, Mailable } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { QueuedMailSender } from '../QueuedMailSender'\nimport { SHOULD_QUEUE } from '../symbols'\n\n/** The ShouldQueue options copied from the mailable onto the wrapper job. */\nconst QUEUE_OPTIONS = [\n 'connection',\n 'queue',\n 'delay',\n 'tries',\n 'backoff',\n 'timeout',\n 'failOnTimeout',\n 'deleteWhenMissingModels',\n] as const\n\n/** The job hooks Queue reads off a job instance, when the wrapped mailable defines them. */\ninterface JobHooks {\n failed?: (error: unknown) => unknown\n retryUntil?: () => unknown\n middleware?: unknown[] | (() => unknown[])\n}\n\n/** Copies the mailable's own ShouldQueue fields onto the wrapper job (when set), so once Queue actually runs the\n * job, its delay/retry/backoff/connection routing reflects what the app developer put on the Mailable. Uses\n * `declare` fields on the class (no runtime auto-initialization to `undefined`), so a field is a genuinely own\n * property only when the mailable actually set it. */\nfunction copyShouldQueueFields(target: Record<PropertyKey, unknown>, source: object): void {\n const fields = source as Record<string, unknown>\n for (const option of QUEUE_OPTIONS) {\n if (fields[option] !== undefined) target[option] = fields[option]\n }\n}\n\n/**\n * Dispatched by MailerImpl.queue()/later()/send() (when queueable). Runs on the worker: renders and delivers the\n * mailable through QueuedMailSender, bypassing the queueable check (it's already on the worker, not the request).\n *\n * Carries `SHOULD_QUEUE` on its own prototype, per the Queue/Bus protocol, so `BusDispatcher.dispatch()` — which\n * re-decides queued-or-now on whatever job it's handed — actually enqueues it instead of running it inline; the\n * mailable's own queueability (checked by MailerImpl) only decides whether to wrap it at all. Like Laravel's\n * SendQueuedMailable, it forwards failed(), retryUntil(), middleware() and displayName() to the mailable.\n */\nexport class SendQueuedMailable implements Job {\n declare connection?: string\n declare queue?: string\n declare delay?: number\n declare tries?: number\n declare backoff?: number | number[]\n declare timeout?: number\n declare failOnTimeout?: boolean\n declare deleteWhenMissingModels?: boolean\n\n constructor(\n readonly mailerName: string | undefined,\n readonly mailable: Mailable,\n readonly to?: Address[],\n readonly cc?: Address[],\n readonly bcc?: Address[],\n ) {\n copyShouldQueueFields(this as unknown as Record<PropertyKey, unknown>, mailable)\n }\n\n async handle(): Promise<void> {\n await inject(QueuedMailSender).sendNow(this.mailerName, this.mailable, { to: this.to, cc: this.cc, bcc: this.bcc })\n }\n\n /** Called by Queue after the final failed attempt. */\n async failed(error: unknown): Promise<void> {\n const hooks = this.mailable as unknown as JobHooks\n if (typeof hooks.failed === 'function') await hooks.failed.call(this.mailable, error)\n }\n\n /** `failed_jobs` and `queue:failed` show the mailable's class, not the wrapper's. */\n displayName(): string {\n return this.mailable.constructor.name\n }\n\n retryUntil(): unknown {\n const hooks = this.mailable as unknown as JobHooks\n return typeof hooks.retryUntil === 'function' ? hooks.retryUntil.call(this.mailable) : undefined\n }\n\n middleware(): unknown[] {\n const declared = (this.mailable as unknown as JobHooks).middleware\n return (typeof declared === 'function' ? declared.call(this.mailable) : declared) ?? []\n }\n}\n;(SendQueuedMailable.prototype as unknown as Record<PropertyKey, unknown>)[SHOULD_QUEUE] = true\n","import {\n ConfigRepository,\n type Address,\n type Container,\n type Mailable,\n type MailManager as MailManagerContract,\n type MailRecipient,\n type MailTransport,\n type PendingMail,\n type SentMessage,\n} from '@orieljs/contracts'\nimport { ArrayTransport } from './transports/ArrayTransport'\nimport { FailoverTransport } from './transports/FailoverTransport'\nimport { LogTransport } from './transports/LogTransport'\nimport { SmtpTransport, type SmtpConfig } from './transports/SmtpTransport'\nimport { UnknownMailerError, UnknownMailTransportError } from './errors'\nimport { MailerImpl, type RecipientOverrides } from './Mailer'\nimport { SendQueuedMailable } from './Jobs/SendQueuedMailable'\nimport type { QueuedMailSender } from './QueuedMailSender'\n\ntype TransportFactory = (config: Record<string, unknown>) => MailTransport\n\nexport class MailManager implements MailManagerContract, QueuedMailSender {\n private readonly mailers = new Map<string, MailerImpl>()\n private readonly drivers = new Map<string, TransportFactory>([\n ['array', () => new ArrayTransport()],\n ['log', (config) => new LogTransport(config.channel as string | undefined)],\n [\n 'smtp',\n (config) =>\n new SmtpTransport({\n host: String(config.host ?? '127.0.0.1'),\n port: Number(config.port ?? 2525),\n encryption: (config.encryption as SmtpConfig['encryption']) ?? null,\n username: config.username as string | undefined,\n password: config.password as string | undefined,\n }),\n ],\n ])\n\n constructor(private readonly container: Container) {}\n\n private config(): ConfigRepository {\n return this.container.make(ConfigRepository)\n }\n\n mailer(name?: string): MailerImpl {\n const mailerName = name ?? this.config().get<string>('mail.default', 'log')\n const cached = this.mailers.get(mailerName)\n if (cached) return cached\n const config = this.config().get<Record<string, unknown> | undefined>(`mail.mailers.${mailerName}`)\n if (!config) throw new UnknownMailerError(mailerName)\n const transport = this.buildTransport(String(config.transport ?? ''), config)\n const from = this.config().get<Address | undefined>('mail.from')\n const impl = new MailerImpl(mailerName, transport, from, (mailerNameArg, mailable, overrides) =>\n new SendQueuedMailable(mailerNameArg, mailable, overrides?.to, overrides?.cc, overrides?.bcc),\n )\n this.mailers.set(mailerName, impl)\n return impl\n }\n\n private buildTransport(transportName: string, config: Record<string, unknown>): MailTransport {\n if (transportName === 'failover') {\n const names = (config.mailers as string[] | undefined) ?? []\n const transports = names.map((mailerName) => {\n const mailerConfig = this.config().get<Record<string, unknown> | undefined>(`mail.mailers.${mailerName}`)\n if (!mailerConfig) throw new UnknownMailerError(mailerName)\n return this.buildTransport(String(mailerConfig.transport ?? ''), mailerConfig)\n })\n return new FailoverTransport(transports, names)\n }\n const factory = this.drivers.get(transportName)\n if (!factory) throw new UnknownMailTransportError(transportName)\n return factory(config)\n }\n\n to(recipients: MailRecipient | MailRecipient[]): PendingMail {\n return this.mailer().to(recipients)\n }\n\n async send(mailable: Mailable): Promise<SentMessage | undefined> {\n return this.mailer().send(mailable)\n }\n\n async queue(mailable: Mailable): Promise<void> {\n await this.mailer().queue(mailable)\n }\n\n /** QueuedMailSender: always delivers immediately (see QueuedMailSender.ts for why this must bypass send()). */\n async sendNow(mailerName: string | undefined, mailable: Mailable, overrides?: RecipientOverrides): Promise<SentMessage> {\n return this.mailer(mailerName).sendNow(mailable, overrides)\n }\n\n extend(transport: string, factory: TransportFactory): void {\n this.drivers.set(transport, factory)\n }\n}\n","import type { MailManager as MailManagerContract } from '@orieljs/contracts'\nimport { MailManager as MailManagerToken } from '@orieljs/contracts'\nimport { facade } from '@orieljs/support'\n\nexport const Mail = facade<MailManagerContract>(MailManagerToken)\n","import { ClassRegistry as ClassRegistryToken, MailManager as MailManagerToken } from '@orieljs/contracts'\nimport { ServiceProvider } from '@orieljs/support'\nimport { SendQueuedMailable } from './Jobs/SendQueuedMailable'\nimport { MailManager } from './MailManager'\nimport { QueuedMailSender } from './QueuedMailSender'\n\nexport class MailServiceProvider extends ServiceProvider {\n override register(): void {\n this.mergeConfigFrom(\n {\n default: 'log',\n mailers: {\n smtp: { transport: 'smtp', host: '127.0.0.1', port: 2525 },\n log: { transport: 'log' },\n array: { transport: 'array' },\n failover: { transport: 'failover', mailers: ['smtp', 'log'] },\n },\n from: { address: 'hello@example.com', name: 'Example' },\n },\n 'mail',\n )\n this.app.singleton(MailManagerToken, (container) => new MailManager(container))\n // Same instance under a second, internal token — see QueuedMailSender.ts for why. The token is typed with the\n // MailManager contract, which has no sendNow(), so narrow it to the concrete class bound just above.\n this.app.singleton(QueuedMailSender, (container) => container.make(MailManagerToken) as MailManager)\n // Namespaced name, registered in register() (not boot()) — the Queue/Bus protocol rule for wrapper classes.\n // ClassRegistry is safe to use here: Application's own constructor binds it before any provider registers.\n this.app.make(ClassRegistryToken).register(SendQueuedMailable, 'Mail.SendQueuedMailable')\n }\n}\n"],"mappings":";AAEO,IAAM,qBAAN,cAAiC,MAA4B;AAAA,EACzD,OAAO;AAAA,EACP,SAAS;AAAA,EACA,OAAO;AAAA,EACzB,YAAY,MAAc;AACxB,UAAM,WAAW,IAAI,wDAAwD;AAAA,EAC/E;AACF;AAEO,IAAM,4BA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AAS;AAAA,EAC5D;AAAA,EAEA,OAAO,WAAmB,SAAiC;AACzD,SAAK,QAAQ,IAAI,WAAW,OAAO;AAAA,EACrC;AACF;;;AC/FA,SAAS,eAAe,wBAAwB;AAChD,SAAS,cAAc;AAEhB,IAAM,OAAO,OAA4B,gBAAgB;;;ACJhE,SAAS,iBAAiB,oBAAoB,eAAeC,yBAAwB;AACrF,SAAS,uBAAuB;AAKzB,IAAM,sBAAN,cAAkC,gBAAgB;AAAA,EAC9C,WAAiB;AACxB,SAAK;AAAA,MACH;AAAA,QACE,SAAS;AAAA,QACT,SAAS;AAAA,UACP,MAAM,EAAE,WAAW,QAAQ,MAAM,aAAa,MAAM,KAAK;AAAA,UACzD,KAAK,EAAE,WAAW,MAAM;AAAA,UACxB,OAAO,EAAE,WAAW,QAAQ;AAAA,UAC5B,UAAU,EAAE,WAAW,YAAY,SAAS,CAAC,QAAQ,KAAK,EAAE;AAAA,QAC9D;AAAA,QACA,MAAM,EAAE,SAAS,qBAAqB,MAAM,UAAU;AAAA,MACxD;AAAA,MACA;AAAA,IACF;AACA,SAAK,IAAI,UAAUC,mBAAkB,CAAC,cAAc,IAAI,YAAY,SAAS,CAAC;AAG9E,SAAK,IAAI,UAAU,kBAAkB,CAAC,cAAc,UAAU,KAAKA,iBAAgB,CAAgB;AAGnG,SAAK,IAAI,KAAK,kBAAkB,EAAE,SAAS,oBAAoB,yBAAyB;AAAA,EAC1F;AACF;","names":["randomUUID","randomUUID","currentContainer","currentContainer","currentContainer","currentContainer","MailManagerToken","MailManagerToken"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orieljs/mail",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "The Oriel Mail component.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/orieljs/framework.git",
|
|
11
|
+
"directory": "src/Oriel/Mail"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=22"
|
|
15
|
+
},
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"NOTICE"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"nodemailer": "10.0.10",
|
|
33
|
+
"@orieljs/contracts": "0.1.0-alpha.1",
|
|
34
|
+
"@orieljs/container": "0.1.0-alpha.1",
|
|
35
|
+
"@orieljs/support": "0.1.0-alpha.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/nodemailer": "8.0.2"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup && node ../../../scripts/copy-license.mjs"
|
|
42
|
+
}
|
|
43
|
+
}
|