@lunora/mail 1.0.0-alpha.7 → 1.0.0-alpha.71
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 +6 -0
- package/dist/inbound/index.d.mts +322 -78
- package/dist/inbound/index.d.ts +322 -78
- package/dist/inbound/index.mjs +1 -2
- package/dist/index.d.mts +122 -94
- package/dist/index.d.ts +122 -94
- package/dist/index.mjs +1 -7
- package/dist/packem_shared/address-soPj2Z0j.mjs +3 -0
- package/dist/packem_shared/authenticatesFrom-xpKAFMRN.mjs +1 -0
- package/dist/packem_shared/capture-transport.d-BD67fxbB.d.mts +130 -0
- package/dist/packem_shared/capture-transport.d-BD67fxbB.d.ts +130 -0
- package/dist/packem_shared/consumeQueuedSend-CRfALnCU.mjs +1 -0
- package/dist/packem_shared/createCaptureSink-CeV0DSsT.mjs +1 -0
- package/dist/packem_shared/createCaptureTransport-CKc6NpZR.mjs +1 -0
- package/dist/packem_shared/createCloudflareTransport-DpfCxn16.mjs +1 -0
- package/dist/packem_shared/createInboundEmailHandler-Bh10YPyJ.mjs +1 -0
- package/dist/packem_shared/createMailer-CjQmT7Ln.mjs +1 -0
- package/dist/packem_shared/createResendTransport-DDkOitck.mjs +1 -0
- package/dist/packem_shared/provider-transport-CR4w-R0A.mjs +1 -0
- package/dist/packem_shared/renderEmail-BOUnr6i3.mjs +1 -0
- package/dist/packem_shared/shard-CRhAKK93.mjs +1 -0
- package/dist/packem_shared/shard.d-DVADjmEJ.d.mts +29 -0
- package/dist/packem_shared/shard.d-DVADjmEJ.d.ts +29 -0
- package/dist/testing.d.mts +9 -9
- package/dist/testing.d.ts +9 -9
- package/dist/testing.mjs +1 -63
- package/package.json +5 -5
- 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-Di-5AJUs.mjs +0 -65
- package/dist/packem_shared/createCaptureTransport-Crz_8822.mjs +0 -11
- package/dist/packem_shared/createCloudflareTransport-DXh1nUNi.mjs +0 -28
- package/dist/packem_shared/createInboundEmailHandler-BW_s0-Vc.mjs +0 -84
- package/dist/packem_shared/createMailer-B4Z_Cgiu.mjs +0 -81
- package/dist/packem_shared/createResendTransport-CMQWjZoi.mjs +0 -16
- package/dist/packem_shared/parseInboundEmail-6lafQBT1.mjs +0 -72
- package/dist/packem_shared/provider-transport-C0xHi3oy.mjs +0 -48
- package/dist/packem_shared/renderEmail-hyS1bpVP.mjs +0 -8
- package/dist/packem_shared/shard-CJ-TvmfT.mjs +0 -13
- package/dist/packem_shared/shard.d-CL2Lmliv.d.mts +0 -39
- package/dist/packem_shared/shard.d-CL2Lmliv.d.ts +0 -39
|
@@ -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,13 +0,0 @@
|
|
|
1
|
-
const applyJurisdiction = (namespace, jurisdiction) => {
|
|
2
|
-
if (jurisdiction === void 0) {
|
|
3
|
-
return namespace;
|
|
4
|
-
}
|
|
5
|
-
if (typeof namespace.jurisdiction !== "function") {
|
|
6
|
-
throw new TypeError(
|
|
7
|
-
`@lunora/mail: Durable Object namespace does not support jurisdiction("${jurisdiction}") — update @cloudflare/workers-types or remove the jurisdiction option`
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
return namespace.jurisdiction(jurisdiction);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export { applyJurisdiction as a };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structural projections of the `SHARD` Durable Object namespace + one shard
|
|
3
|
-
* stub, shared by the inbound dispatcher. Mirrors the shapes the outbound dev
|
|
4
|
-
* capture sink uses (`packages/mail/src/from-env.ts`) so inbound dispatch routes
|
|
5
|
-
* a parsed message into a Lunora function over the exact same admin-RPC-over-shard
|
|
6
|
-
* path — without importing any Cloudflare types into `@lunora/mail`.
|
|
7
|
-
*/
|
|
8
|
-
/** Structural projection of one shard stub — only `fetch` returning something with `.json()`. */
|
|
9
|
-
interface ShardStubLike {
|
|
10
|
-
fetch: (input: string, init?: {
|
|
11
|
-
body?: string;
|
|
12
|
-
headers?: Record<string, string>;
|
|
13
|
-
method?: string;
|
|
14
|
-
}) => Promise<{
|
|
15
|
-
json: () => Promise<unknown>;
|
|
16
|
-
}>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Cloudflare Durable Object data-residency jurisdiction. Widening union —
|
|
20
|
-
* Cloudflare adds values over time.
|
|
21
|
-
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
22
|
-
*/
|
|
23
|
-
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
24
|
-
/** Structural projection of the `SHARD` Durable Object namespace. */
|
|
25
|
-
interface ShardNamespaceLike {
|
|
26
|
-
get: (id: unknown) => ShardStubLike;
|
|
27
|
-
idFromName: (name: string) => unknown;
|
|
28
|
-
/**
|
|
29
|
-
* Derive a jurisdiction-restricted subnamespace. Optional because older
|
|
30
|
-
* workers-types releases (and test doubles) may not expose it.
|
|
31
|
-
*/
|
|
32
|
-
jurisdiction?: (jurisdiction: DurableObjectJurisdiction) => ShardNamespaceLike;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Return a jurisdiction-restricted view of `namespace`, or `namespace`
|
|
36
|
-
* unchanged when no jurisdiction is configured. Fail-closed when the binding
|
|
37
|
-
* lacks `.jurisdiction()` so a residency constraint is never silently dropped.
|
|
38
|
-
*/
|
|
39
|
-
export { DurableObjectJurisdiction as D, ShardNamespaceLike as S, ShardStubLike as a };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structural projections of the `SHARD` Durable Object namespace + one shard
|
|
3
|
-
* stub, shared by the inbound dispatcher. Mirrors the shapes the outbound dev
|
|
4
|
-
* capture sink uses (`packages/mail/src/from-env.ts`) so inbound dispatch routes
|
|
5
|
-
* a parsed message into a Lunora function over the exact same admin-RPC-over-shard
|
|
6
|
-
* path — without importing any Cloudflare types into `@lunora/mail`.
|
|
7
|
-
*/
|
|
8
|
-
/** Structural projection of one shard stub — only `fetch` returning something with `.json()`. */
|
|
9
|
-
interface ShardStubLike {
|
|
10
|
-
fetch: (input: string, init?: {
|
|
11
|
-
body?: string;
|
|
12
|
-
headers?: Record<string, string>;
|
|
13
|
-
method?: string;
|
|
14
|
-
}) => Promise<{
|
|
15
|
-
json: () => Promise<unknown>;
|
|
16
|
-
}>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Cloudflare Durable Object data-residency jurisdiction. Widening union —
|
|
20
|
-
* Cloudflare adds values over time.
|
|
21
|
-
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
22
|
-
*/
|
|
23
|
-
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
24
|
-
/** Structural projection of the `SHARD` Durable Object namespace. */
|
|
25
|
-
interface ShardNamespaceLike {
|
|
26
|
-
get: (id: unknown) => ShardStubLike;
|
|
27
|
-
idFromName: (name: string) => unknown;
|
|
28
|
-
/**
|
|
29
|
-
* Derive a jurisdiction-restricted subnamespace. Optional because older
|
|
30
|
-
* workers-types releases (and test doubles) may not expose it.
|
|
31
|
-
*/
|
|
32
|
-
jurisdiction?: (jurisdiction: DurableObjectJurisdiction) => ShardNamespaceLike;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Return a jurisdiction-restricted view of `namespace`, or `namespace`
|
|
36
|
-
* unchanged when no jurisdiction is configured. Fail-closed when the binding
|
|
37
|
-
* lacks `.jurisdiction()` so a residency constraint is never silently dropped.
|
|
38
|
-
*/
|
|
39
|
-
export { DurableObjectJurisdiction as D, ShardNamespaceLike as S, ShardStubLike as a };
|