@lunora/mail 1.0.0-alpha.14 → 1.0.0-alpha.16

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.
@@ -0,0 +1,117 @@
1
+ import { ReactElement } from 'react';
2
+ /**
3
+ * Minimal projection of a Cloudflare Queue binding — accepts a JSON payload
4
+ * via `.send()`. Declared structurally so callers can pass either the real
5
+ * `Queue` binding or a unit-test double.
6
+ */
7
+ interface QueueLike {
8
+ send: (payload: unknown, options?: Record<string, unknown>) => Promise<void>;
9
+ }
10
+ /**
11
+ * Minimal projection of a transport adapter. Returning `{ id }` follows
12
+ * Resend's response shape; the real `@visulima/email` `MailManager` flattens
13
+ * provider responses to the same field for us.
14
+ */
15
+ interface MailTransport {
16
+ send: (payload: SendPayload) => Promise<{
17
+ id: string;
18
+ }>;
19
+ }
20
+ interface SendPayload {
21
+ bcc?: string[];
22
+ cc?: string[];
23
+ from?: string;
24
+ headers?: Record<string, string>;
25
+ html?: string;
26
+ replyTo?: string;
27
+ subject: string;
28
+ text?: string;
29
+ to: string | string[];
30
+ }
31
+ interface SendOptions {
32
+ bcc?: string[];
33
+ cc?: string[];
34
+ from?: string;
35
+ headers?: Record<string, string>;
36
+ html?: string;
37
+ react?: ReactElement;
38
+ replyTo?: string;
39
+ subject: string;
40
+ text?: string;
41
+ to: string | string[];
42
+ }
43
+ interface LunoraMailOptions {
44
+ /** API key for the Resend transport (bring-your-own-provider). Ignored when `transport` or `cloudflareSend` is set. */
45
+ apiKey?: string;
46
+ /**
47
+ * RFC 822 send callback bound to the Worker's `send_email` binding. When set
48
+ * (and no explicit `transport` is supplied) the default transport is
49
+ * Cloudflare Email Workers — Lunora's default provider. Ignored when
50
+ * `transport` is set.
51
+ */
52
+ cloudflareSend?: (from: string, to: string, raw: string) => Promise<void>;
53
+ /** Default sender (`Name &lt;addr@host>` or bare email). */
54
+ from: string;
55
+ /** Default queue binding for `mailer.queue()`. */
56
+ queue?: QueueLike;
57
+ /** Override the underlying transport. Useful for tests, the dev capture transport, + multi-provider setups. */
58
+ transport?: MailTransport;
59
+ }
60
+ interface Mailer {
61
+ queue: (options: SendOptions) => Promise<{
62
+ queued: true;
63
+ }>;
64
+ send: (options: SendOptions) => Promise<{
65
+ id: string;
66
+ }>;
67
+ }
68
+ /**
69
+ * One captured outbound message as persisted by the dev mail catcher. Extends
70
+ * the rendered, validated {@link SendPayload} with an `id` and a capture
71
+ * timestamp assigned by the sink (the root-shard mailbox), so the studio inbox
72
+ * can list and open it.
73
+ *
74
+ * **Canonical captured-mail wire type — single source of truth.** Every other
75
+ * representation of a captured message mirrors this shape; consumers import it
76
+ * directly wherever the package dependency direction allows.
77
+ *
78
+ * `@lunora/studio`'s `CapturedMail` re-exports this (type-only dep on
79
+ * `@lunora/mail`). `@lunora/do`'s `CapturedMailRow` / `RecordMailInput` are
80
+ * documented mirrors — the DO runtime stays free of any `@lunora/mail` *runtime*
81
+ * dep — guarded by a compile-time structural assertion against this type, so a
82
+ * field added here that isn't mirrored fails the `@lunora/do` build.
83
+ *
84
+ * Add or change a captured-mail field here first; the guards will point at the
85
+ * mirrors that need the matching change.
86
+ */
87
+ interface CapturedMail extends SendPayload {
88
+ /** Epoch-ms the message was captured. */
89
+ capturedAt: number;
90
+ /** Stable id assigned to the captured message. */
91
+ id: string;
92
+ }
93
+ /**
94
+ * Minimal projection of the persistence target the capture transport writes to
95
+ * (the studio's root-shard mailbox). Declared structurally — like
96
+ * {@link import("./types").QueueLike} — so `@lunora/mail` stays free of any
97
+ * Durable Object / runtime dependency. The registry scaffold supplies the
98
+ * concrete sink that POSTs to the root shard's `__lunora_admin__:recordMail` RPC.
99
+ */
100
+ interface MailboxSink {
101
+ record: (mail: SendPayload) => Promise<{
102
+ id: string;
103
+ }>;
104
+ }
105
+ /**
106
+ * Build a capture {@link MailTransport}: instead of delivering, it persists the
107
+ * fully rendered + validated payload to `sink` and returns the assigned id.
108
+ *
109
+ * Wired in dev by the mail registry scaffold so `lunora dev` shows every send in
110
+ * the studio's Mail inbox — including `@lunora/auth`'s verification and
111
+ * forgot-password mail — with no provider credentials and nothing leaving the
112
+ * machine. Address/header validation already ran in `createMailer.buildPayload`
113
+ * before the payload reaches here, so the captured message is the same one a
114
+ * real transport would have sent.
115
+ */
116
+ declare const createCaptureTransport: (sink: MailboxSink) => MailTransport;
117
+ export { CapturedMail as C, LunoraMailOptions as L, MailTransport as M, QueueLike as Q, SendOptions as S, Mailer as a, MailboxSink as b, SendPayload as c, createCaptureTransport as d };
@@ -11,24 +11,19 @@ interface ShardStubLike {
11
11
  }>;
12
12
  }
13
13
  /**
14
- * Cloudflare Durable Object data-residency jurisdiction. Widening union —
15
- * Cloudflare adds values over time.
16
- * @see https://developers.cloudflare.com/durable-objects/reference/data-location/
17
- */
14
+ * Cloudflare Durable Object data-residency jurisdiction. Widening union —
15
+ * Cloudflare adds values over time.
16
+ * @see https://developers.cloudflare.com/durable-objects/reference/data-location/
17
+ */
18
18
  type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
19
19
  /** Structural projection of the `SHARD` Durable Object namespace. */
20
20
  interface ShardNamespaceLike {
21
21
  get: (id: unknown) => ShardStubLike;
22
22
  idFromName: (name: string) => unknown;
23
23
  /**
24
- * Derive a jurisdiction-restricted subnamespace. Optional because older
25
- * workers-types releases (and test doubles) may not expose it.
26
- */
24
+ * Derive a jurisdiction-restricted subnamespace. Optional because older
25
+ * workers-types releases (and test doubles) may not expose it.
26
+ */
27
27
  jurisdiction?: (jurisdiction: DurableObjectJurisdiction) => ShardNamespaceLike;
28
28
  }
29
- /**
30
- * Return a jurisdiction-restricted view of `namespace`, or `namespace`
31
- * unchanged when no jurisdiction is configured. Fail-closed when the binding
32
- * lacks `.jurisdiction()` so a residency constraint is never silently dropped.
33
- */
34
29
  export { DurableObjectJurisdiction as D, ShardNamespaceLike as S, ShardStubLike as a };
@@ -11,24 +11,19 @@ interface ShardStubLike {
11
11
  }>;
12
12
  }
13
13
  /**
14
- * Cloudflare Durable Object data-residency jurisdiction. Widening union —
15
- * Cloudflare adds values over time.
16
- * @see https://developers.cloudflare.com/durable-objects/reference/data-location/
17
- */
14
+ * Cloudflare Durable Object data-residency jurisdiction. Widening union —
15
+ * Cloudflare adds values over time.
16
+ * @see https://developers.cloudflare.com/durable-objects/reference/data-location/
17
+ */
18
18
  type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
19
19
  /** Structural projection of the `SHARD` Durable Object namespace. */
20
20
  interface ShardNamespaceLike {
21
21
  get: (id: unknown) => ShardStubLike;
22
22
  idFromName: (name: string) => unknown;
23
23
  /**
24
- * Derive a jurisdiction-restricted subnamespace. Optional because older
25
- * workers-types releases (and test doubles) may not expose it.
26
- */
24
+ * Derive a jurisdiction-restricted subnamespace. Optional because older
25
+ * workers-types releases (and test doubles) may not expose it.
26
+ */
27
27
  jurisdiction?: (jurisdiction: DurableObjectJurisdiction) => ShardNamespaceLike;
28
28
  }
29
- /**
30
- * Return a jurisdiction-restricted view of `namespace`, or `namespace`
31
- * unchanged when no jurisdiction is configured. Fail-closed when the binding
32
- * lacks `.jurisdiction()` so a residency constraint is never silently dropped.
33
- */
34
29
  export { DurableObjectJurisdiction as D, ShardNamespaceLike as S, ShardStubLike as a };
@@ -1,4 +1,4 @@
1
- import { C as CapturedMail } from "./packem_shared/capture-transport.d-ChnhdPO2.mjs";
1
+ import { C as CapturedMail } from "./packem_shared/capture-transport.d-BJ__iWzS.mjs";
2
2
  import 'react';
3
3
  /** Minimal `fetch` projection so a test can inject a stub. */
4
4
  type FetchLike = (input: string, init?: {
@@ -33,16 +33,16 @@ interface WaitForMailOptions extends InboxOptions {
33
33
  /** Read the captured-mail inbox (newest first). */
34
34
  declare const listCapturedMail: (options: InboxOptions) => Promise<CapturedMail[]>;
35
35
  /**
36
- * Poll the captured-mail inbox until a message addressed to `to` (optionally
37
- * matching `subjectMatch`) appears, then return it. Throws on timeout. Entries
38
- * are newest-first, so the most recent matching message wins.
39
- */
36
+ * Poll the captured-mail inbox until a message addressed to `to` (optionally
37
+ * matching `subjectMatch`) appears, then return it. Throws on timeout. Entries
38
+ * are newest-first, so the most recent matching message wins.
39
+ */
40
40
  declare const waitForMail: (options: WaitForMailOptions) => Promise<CapturedMail>;
41
41
  /**
42
- * Pull the first link out of a captured message — html first, then text. Pass
43
- * `match` to require the URL contain a substring (e.g. `"/reset-password"`),
44
- * which disambiguates the action link from a logo/footer URL.
45
- */
42
+ * Pull the first link out of a captured message — html first, then text. Pass
43
+ * `match` to require the URL contain a substring (e.g. `"/reset-password"`),
44
+ * which disambiguates the action link from a logo/footer URL.
45
+ */
46
46
  declare const extractLink: (mail: CapturedMail, options?: {
47
47
  match?: string;
48
48
  }) => string;
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CapturedMail } from "./packem_shared/capture-transport.d-ChnhdPO2.js";
1
+ import { C as CapturedMail } from "./packem_shared/capture-transport.d-BJ__iWzS.js";
2
2
  import 'react';
3
3
  /** Minimal `fetch` projection so a test can inject a stub. */
4
4
  type FetchLike = (input: string, init?: {
@@ -33,16 +33,16 @@ interface WaitForMailOptions extends InboxOptions {
33
33
  /** Read the captured-mail inbox (newest first). */
34
34
  declare const listCapturedMail: (options: InboxOptions) => Promise<CapturedMail[]>;
35
35
  /**
36
- * Poll the captured-mail inbox until a message addressed to `to` (optionally
37
- * matching `subjectMatch`) appears, then return it. Throws on timeout. Entries
38
- * are newest-first, so the most recent matching message wins.
39
- */
36
+ * Poll the captured-mail inbox until a message addressed to `to` (optionally
37
+ * matching `subjectMatch`) appears, then return it. Throws on timeout. Entries
38
+ * are newest-first, so the most recent matching message wins.
39
+ */
40
40
  declare const waitForMail: (options: WaitForMailOptions) => Promise<CapturedMail>;
41
41
  /**
42
- * Pull the first link out of a captured message — html first, then text. Pass
43
- * `match` to require the URL contain a substring (e.g. `"/reset-password"`),
44
- * which disambiguates the action link from a logo/footer URL.
45
- */
42
+ * Pull the first link out of a captured message — html first, then text. Pass
43
+ * `match` to require the URL contain a substring (e.g. `"/reset-password"`),
44
+ * which disambiguates the action link from a logo/footer URL.
45
+ */
46
46
  declare const extractLink: (mail: CapturedMail, options?: {
47
47
  match?: string;
48
48
  }) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/mail",
3
- "version": "1.0.0-alpha.14",
3
+ "version": "1.0.0-alpha.16",
4
4
  "description": "Email for Lunora: Resend adapter, TSX templates, and queue-backed sends",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -54,9 +54,9 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "@lunora/errors": "1.0.0-alpha.4",
58
- "@react-email/render": "2.0.10",
59
- "@visulima/email": "1.0.0",
57
+ "@lunora/errors": "1.0.0-alpha.6",
58
+ "@react-email/render": "2.1.0",
59
+ "@visulima/email": "2.1.1",
60
60
  "postal-mime": "2.7.5"
61
61
  },
62
62
  "peerDependencies": {
@@ -1,117 +0,0 @@
1
- import { ReactElement } from 'react';
2
- /**
3
- * Minimal projection of a Cloudflare Queue binding — accepts a JSON payload
4
- * via `.send()`. Declared structurally so callers can pass either the real
5
- * `Queue` binding or a unit-test double.
6
- */
7
- interface QueueLike {
8
- send: (payload: unknown, options?: Record<string, unknown>) => Promise<void>;
9
- }
10
- /**
11
- * Minimal projection of a transport adapter. Returning `{ id }` follows
12
- * Resend's response shape; the real `@visulima/email` `MailManager` flattens
13
- * provider responses to the same field for us.
14
- */
15
- interface MailTransport {
16
- send: (payload: SendPayload) => Promise<{
17
- id: string;
18
- }>;
19
- }
20
- interface SendPayload {
21
- bcc?: string[];
22
- cc?: string[];
23
- from?: string;
24
- headers?: Record<string, string>;
25
- html?: string;
26
- replyTo?: string;
27
- subject: string;
28
- text?: string;
29
- to: string | string[];
30
- }
31
- interface SendOptions {
32
- bcc?: string[];
33
- cc?: string[];
34
- from?: string;
35
- headers?: Record<string, string>;
36
- html?: string;
37
- react?: ReactElement;
38
- replyTo?: string;
39
- subject: string;
40
- text?: string;
41
- to: string | string[];
42
- }
43
- interface LunoraMailOptions {
44
- /** API key for the Resend transport (bring-your-own-provider). Ignored when `transport` or `cloudflareSend` is set. */
45
- apiKey?: string;
46
- /**
47
- * RFC 822 send callback bound to the Worker's `send_email` binding. When set
48
- * (and no explicit `transport` is supplied) the default transport is
49
- * Cloudflare Email Workers — Lunora's default provider. Ignored when
50
- * `transport` is set.
51
- */
52
- cloudflareSend?: (from: string, to: string, raw: string) => Promise<void>;
53
- /** Default sender (`Name &lt;addr@host>` or bare email). */
54
- from: string;
55
- /** Default queue binding for `mailer.queue()`. */
56
- queue?: QueueLike;
57
- /** Override the underlying transport. Useful for tests, the dev capture transport, + multi-provider setups. */
58
- transport?: MailTransport;
59
- }
60
- interface Mailer {
61
- queue: (options: SendOptions) => Promise<{
62
- queued: true;
63
- }>;
64
- send: (options: SendOptions) => Promise<{
65
- id: string;
66
- }>;
67
- }
68
- /**
69
- * One captured outbound message as persisted by the dev mail catcher. Extends
70
- * the rendered, validated {@link SendPayload} with an `id` and a capture
71
- * timestamp assigned by the sink (the root-shard mailbox), so the studio inbox
72
- * can list and open it.
73
- *
74
- * **Canonical captured-mail wire type — single source of truth.** Every other
75
- * representation of a captured message mirrors this shape; consumers import it
76
- * directly wherever the package dependency direction allows.
77
- *
78
- * `@lunora/studio`'s `CapturedMail` re-exports this (type-only dep on
79
- * `@lunora/mail`). `@lunora/do`'s `CapturedMailRow` / `RecordMailInput` are
80
- * documented mirrors — the DO runtime stays free of any `@lunora/mail` *runtime*
81
- * dep — guarded by a compile-time structural assertion against this type, so a
82
- * field added here that isn't mirrored fails the `@lunora/do` build.
83
- *
84
- * Add or change a captured-mail field here first; the guards will point at the
85
- * mirrors that need the matching change.
86
- */
87
- interface CapturedMail extends SendPayload {
88
- /** Epoch-ms the message was captured. */
89
- capturedAt: number;
90
- /** Stable id assigned to the captured message. */
91
- id: string;
92
- }
93
- /**
94
- * Minimal projection of the persistence target the capture transport writes to
95
- * (the studio's root-shard mailbox). Declared structurally — like
96
- * {@link import("./types").QueueLike} — so `@lunora/mail` stays free of any
97
- * Durable Object / runtime dependency. The registry scaffold supplies the
98
- * concrete sink that POSTs to the root shard's `__lunora_admin__:recordMail` RPC.
99
- */
100
- interface MailboxSink {
101
- record: (mail: SendPayload) => Promise<{
102
- id: string;
103
- }>;
104
- }
105
- /**
106
- * Build a capture {@link MailTransport}: instead of delivering, it persists the
107
- * fully rendered + validated payload to `sink` and returns the assigned id.
108
- *
109
- * Wired in dev by the mail registry scaffold so `lunora dev` shows every send in
110
- * the studio's Mail inbox — including `@lunora/auth`'s verification and
111
- * forgot-password mail — with no provider credentials and nothing leaving the
112
- * machine. Address/header validation already ran in `createMailer.buildPayload`
113
- * before the payload reaches here, so the captured message is the same one a
114
- * real transport would have sent.
115
- */
116
- declare const createCaptureTransport: (sink: MailboxSink) => MailTransport;
117
- export { CapturedMail as C, LunoraMailOptions as L, MailTransport as M, QueueLike as Q, SendOptions as S, Mailer as a, MailboxSink as b, SendPayload as c, createCaptureTransport as d };
@@ -1,117 +0,0 @@
1
- import { ReactElement } from 'react';
2
- /**
3
- * Minimal projection of a Cloudflare Queue binding — accepts a JSON payload
4
- * via `.send()`. Declared structurally so callers can pass either the real
5
- * `Queue` binding or a unit-test double.
6
- */
7
- interface QueueLike {
8
- send: (payload: unknown, options?: Record<string, unknown>) => Promise<void>;
9
- }
10
- /**
11
- * Minimal projection of a transport adapter. Returning `{ id }` follows
12
- * Resend's response shape; the real `@visulima/email` `MailManager` flattens
13
- * provider responses to the same field for us.
14
- */
15
- interface MailTransport {
16
- send: (payload: SendPayload) => Promise<{
17
- id: string;
18
- }>;
19
- }
20
- interface SendPayload {
21
- bcc?: string[];
22
- cc?: string[];
23
- from?: string;
24
- headers?: Record<string, string>;
25
- html?: string;
26
- replyTo?: string;
27
- subject: string;
28
- text?: string;
29
- to: string | string[];
30
- }
31
- interface SendOptions {
32
- bcc?: string[];
33
- cc?: string[];
34
- from?: string;
35
- headers?: Record<string, string>;
36
- html?: string;
37
- react?: ReactElement;
38
- replyTo?: string;
39
- subject: string;
40
- text?: string;
41
- to: string | string[];
42
- }
43
- interface LunoraMailOptions {
44
- /** API key for the Resend transport (bring-your-own-provider). Ignored when `transport` or `cloudflareSend` is set. */
45
- apiKey?: string;
46
- /**
47
- * RFC 822 send callback bound to the Worker's `send_email` binding. When set
48
- * (and no explicit `transport` is supplied) the default transport is
49
- * Cloudflare Email Workers — Lunora's default provider. Ignored when
50
- * `transport` is set.
51
- */
52
- cloudflareSend?: (from: string, to: string, raw: string) => Promise<void>;
53
- /** Default sender (`Name &lt;addr@host>` or bare email). */
54
- from: string;
55
- /** Default queue binding for `mailer.queue()`. */
56
- queue?: QueueLike;
57
- /** Override the underlying transport. Useful for tests, the dev capture transport, + multi-provider setups. */
58
- transport?: MailTransport;
59
- }
60
- interface Mailer {
61
- queue: (options: SendOptions) => Promise<{
62
- queued: true;
63
- }>;
64
- send: (options: SendOptions) => Promise<{
65
- id: string;
66
- }>;
67
- }
68
- /**
69
- * One captured outbound message as persisted by the dev mail catcher. Extends
70
- * the rendered, validated {@link SendPayload} with an `id` and a capture
71
- * timestamp assigned by the sink (the root-shard mailbox), so the studio inbox
72
- * can list and open it.
73
- *
74
- * **Canonical captured-mail wire type — single source of truth.** Every other
75
- * representation of a captured message mirrors this shape; consumers import it
76
- * directly wherever the package dependency direction allows.
77
- *
78
- * `@lunora/studio`'s `CapturedMail` re-exports this (type-only dep on
79
- * `@lunora/mail`). `@lunora/do`'s `CapturedMailRow` / `RecordMailInput` are
80
- * documented mirrors — the DO runtime stays free of any `@lunora/mail` *runtime*
81
- * dep — guarded by a compile-time structural assertion against this type, so a
82
- * field added here that isn't mirrored fails the `@lunora/do` build.
83
- *
84
- * Add or change a captured-mail field here first; the guards will point at the
85
- * mirrors that need the matching change.
86
- */
87
- interface CapturedMail extends SendPayload {
88
- /** Epoch-ms the message was captured. */
89
- capturedAt: number;
90
- /** Stable id assigned to the captured message. */
91
- id: string;
92
- }
93
- /**
94
- * Minimal projection of the persistence target the capture transport writes to
95
- * (the studio's root-shard mailbox). Declared structurally — like
96
- * {@link import("./types").QueueLike} — so `@lunora/mail` stays free of any
97
- * Durable Object / runtime dependency. The registry scaffold supplies the
98
- * concrete sink that POSTs to the root shard's `__lunora_admin__:recordMail` RPC.
99
- */
100
- interface MailboxSink {
101
- record: (mail: SendPayload) => Promise<{
102
- id: string;
103
- }>;
104
- }
105
- /**
106
- * Build a capture {@link MailTransport}: instead of delivering, it persists the
107
- * fully rendered + validated payload to `sink` and returns the assigned id.
108
- *
109
- * Wired in dev by the mail registry scaffold so `lunora dev` shows every send in
110
- * the studio's Mail inbox — including `@lunora/auth`'s verification and
111
- * forgot-password mail — with no provider credentials and nothing leaving the
112
- * machine. Address/header validation already ran in `createMailer.buildPayload`
113
- * before the payload reaches here, so the captured message is the same one a
114
- * real transport would have sent.
115
- */
116
- declare const createCaptureTransport: (sink: MailboxSink) => MailTransport;
117
- export { CapturedMail as C, LunoraMailOptions as L, MailTransport as M, QueueLike as Q, SendOptions as S, Mailer as a, MailboxSink as b, SendPayload as c, createCaptureTransport as d };