@lunora/mail 1.0.0-alpha.14 → 1.0.0-alpha.141
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.md +201 -104
- package/README.md +3 -3
- package/dist/inbound/index.d.mts +340 -89
- package/dist/inbound/index.d.ts +340 -89
- package/dist/inbound/index.mjs +1 -2
- package/dist/index.d.mts +279 -97
- package/dist/index.d.ts +279 -97
- package/dist/index.mjs +1 -7
- package/dist/packem_shared/MailSendError-BYih5mnM.mjs +1 -0
- package/dist/packem_shared/assertValidIdempotencyKey-CyJq0nZq.mjs +3 -0
- package/dist/packem_shared/authenticatesFrom-UBe_EgRT.mjs +1 -0
- package/dist/packem_shared/capture-transport.d-G-OVrGhG.d.mts +170 -0
- package/dist/packem_shared/capture-transport.d-G-OVrGhG.d.ts +170 -0
- package/dist/packem_shared/consumeQueuedSend-BwNGdlaG.mjs +1 -0
- package/dist/packem_shared/createCaptureSink-BCAMuG4n.mjs +1 -0
- package/dist/packem_shared/createCaptureTransport-DZhMUmaI.mjs +1 -0
- package/dist/packem_shared/createCloudflareTransport-Dxjf_b6q.mjs +1 -0
- package/dist/packem_shared/createInboundEmailHandler-ByzpfcEI.mjs +1 -0
- package/dist/packem_shared/createMailer-Cv1B9wYq.mjs +1 -0
- package/dist/packem_shared/createResendTransport-CsJfCLAP.mjs +1 -0
- package/dist/packem_shared/provider-transport-Ce2xVUuM.mjs +1 -0
- package/dist/packem_shared/renderEmail-xypKDdux.mjs +1 -0
- package/dist/packem_shared/shard-Bgo7dYFl.mjs +1 -0
- package/dist/packem_shared/{shard.d-C4kxvfmd.d.mts → shard.d-DVADjmEJ.d.mts} +7 -12
- package/dist/packem_shared/{shard.d-C4kxvfmd.d.ts → shard.d-DVADjmEJ.d.ts} +7 -12
- package/dist/testing.d.mts +9 -9
- package/dist/testing.d.ts +9 -9
- package/dist/testing.mjs +1 -65
- package/package.json +7 -6
- package/dist/packem_shared/address-vSUAVU2T.mjs +0 -64
- package/dist/packem_shared/capture-transport.d-ChnhdPO2.d.mts +0 -117
- package/dist/packem_shared/capture-transport.d-ChnhdPO2.d.ts +0 -117
- package/dist/packem_shared/consumeQueuedSend-B9hTDOZ6.mjs +0 -77
- package/dist/packem_shared/createCaptureSink-B0c7fQJf.mjs +0 -77
- package/dist/packem_shared/createCaptureTransport-Crz_8822.mjs +0 -11
- package/dist/packem_shared/createCloudflareTransport-DXh1nUNi.mjs +0 -28
- package/dist/packem_shared/createInboundEmailHandler-BMB5t-qh.mjs +0 -74
- package/dist/packem_shared/createMailer-B4Z_Cgiu.mjs +0 -81
- package/dist/packem_shared/createResendTransport-CMQWjZoi.mjs +0 -16
- package/dist/packem_shared/parseInboundEmail-DXVOH0wz.mjs +0 -73
- package/dist/packem_shared/provider-transport-C0xHi3oy.mjs +0 -48
- package/dist/packem_shared/renderEmail-hyS1bpVP.mjs +0 -8
- package/dist/packem_shared/shard-DEDcQoFg.mjs +0 -36
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { LunoraError } from '@lunora/errors';
|
|
2
|
-
import { t as toAddressList, c as toAddress } from './address-vSUAVU2T.mjs';
|
|
3
|
-
|
|
4
|
-
const reasonOf = (rawError) => {
|
|
5
|
-
if (rawError instanceof Error) {
|
|
6
|
-
return rawError.message;
|
|
7
|
-
}
|
|
8
|
-
if (rawError === null || rawError === void 0) {
|
|
9
|
-
return "send failed";
|
|
10
|
-
}
|
|
11
|
-
if (typeof rawError === "string") {
|
|
12
|
-
return rawError;
|
|
13
|
-
}
|
|
14
|
-
if (typeof rawError === "number" || typeof rawError === "boolean" || typeof rawError === "bigint") {
|
|
15
|
-
return rawError.toString();
|
|
16
|
-
}
|
|
17
|
-
return JSON.stringify(rawError) ?? "send failed";
|
|
18
|
-
};
|
|
19
|
-
const requireRecipients = (to) => {
|
|
20
|
-
const list = toAddressList(to);
|
|
21
|
-
const [first] = list ?? [];
|
|
22
|
-
if (!list || first === void 0) {
|
|
23
|
-
throw new LunoraError("INTERNAL", "@lunora/mail: at least one recipient is required");
|
|
24
|
-
}
|
|
25
|
-
return { first, list };
|
|
26
|
-
};
|
|
27
|
-
const toProviderEmail = (payload, defaultFrom, to) => {
|
|
28
|
-
return {
|
|
29
|
-
bcc: toAddressList(payload.bcc),
|
|
30
|
-
cc: toAddressList(payload.cc),
|
|
31
|
-
from: toAddress(payload.from ?? defaultFrom),
|
|
32
|
-
headers: payload.headers,
|
|
33
|
-
html: payload.html,
|
|
34
|
-
replyTo: payload.replyTo ? toAddress(payload.replyTo) : void 0,
|
|
35
|
-
subject: payload.subject,
|
|
36
|
-
text: payload.text,
|
|
37
|
-
to
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
const interpretSendResult = (result) => {
|
|
41
|
-
if (!result.success || !result.data) {
|
|
42
|
-
console.error(`@lunora/mail: send failed: ${reasonOf(result.error)}`);
|
|
43
|
-
throw new LunoraError("INTERNAL", "@lunora/mail: send failed");
|
|
44
|
-
}
|
|
45
|
-
return { id: result.data.messageId };
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export { interpretSendResult as i, requireRecipients as r, toProviderEmail as t };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { render } from '@react-email/render';
|
|
2
|
-
|
|
3
|
-
const renderEmail = async (element) => {
|
|
4
|
-
const [html, text] = await Promise.all([render(element, { pretty: false }), render(element, { plainText: true })]);
|
|
5
|
-
return { html, text };
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export { renderEmail as default };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { LunoraError } from '@lunora/errors';
|
|
2
|
-
|
|
3
|
-
const DEFAULT_ROOT_SHARD = "__root__";
|
|
4
|
-
const applyJurisdiction = (namespace, jurisdiction) => {
|
|
5
|
-
if (jurisdiction === void 0) {
|
|
6
|
-
return namespace;
|
|
7
|
-
}
|
|
8
|
-
if (typeof namespace.jurisdiction !== "function") {
|
|
9
|
-
throw new TypeError(
|
|
10
|
-
`@lunora/mail: Durable Object namespace does not support jurisdiction("${jurisdiction}") — update @cloudflare/workers-types or remove the jurisdiction option`
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
return namespace.jurisdiction(jurisdiction);
|
|
14
|
-
};
|
|
15
|
-
const postShardRpc = async (namespace, options) => {
|
|
16
|
-
const scoped = applyJurisdiction(namespace, options.jurisdiction);
|
|
17
|
-
const stub = scoped.get(scoped.idFromName(options.shardKey));
|
|
18
|
-
const response = await stub.fetch("https://shard.internal/rpc", {
|
|
19
|
-
body: JSON.stringify(options.envelope),
|
|
20
|
-
headers: { authorization: `Bearer ${options.adminToken}`, "content-type": "application/json" },
|
|
21
|
-
method: "POST"
|
|
22
|
-
});
|
|
23
|
-
if (response.ok === false) {
|
|
24
|
-
throw new LunoraError("INTERNAL", `${options.label} failed (HTTP ${String(response.status ?? "?")}).`);
|
|
25
|
-
}
|
|
26
|
-
const body = await response.json();
|
|
27
|
-
if (typeof body === "object" && body !== null && "error" in body) {
|
|
28
|
-
const { error } = body;
|
|
29
|
-
if (error !== void 0 && error !== null) {
|
|
30
|
-
throw new LunoraError("INTERNAL", `${options.label} returned an error: ${JSON.stringify(error)}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return body;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export { DEFAULT_ROOT_SHARD as D, postShardRpc as p };
|