@midsummer-ai/sdk 0.1.0-staging.3494 → 0.1.0-staging.3500

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/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  The handles a Midsummer app's code uses for its Database, Storage, Queues, Vector DB, AI, Email and Agents, each with a stand-in for tests.
4
4
 
5
- Docs: https://docs.midsummer.new
5
+ Docs: https://docs.staging.midsummer.new
@@ -1,4 +1,4 @@
1
- import { BatchResult, CheckedMessage, EmailEngine, EmailErrorCode, SentMessage } from "./index.mjs";
1
+ import { i as EmailEngine, m as SentMessage, n as CheckedMessage, o as EmailErrorCode, t as BatchResult } from "../index-m0wtx22n.mjs";
2
2
  //#region src/email/client.d.ts
3
3
  declare const MESSAGES_PATH = "/email/messages";
4
4
  type Fetch = (url: string, init: RequestInit) => Promise<Response>;
package/email/client.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { d as MESSAGES_PATH, f as boundEmail, h as serveMessages, m as serveBound, p as client } from "../email-4iedeyjF.mjs";
1
+ import { C as serveMessages, S as serveBound, b as boundEmail, x as client, y as MESSAGES_PATH } from "../email-ynNo0HqT.mjs";
2
2
  export { MESSAGES_PATH, boundEmail, client, serveBound, serveMessages };
@@ -1,4 +1,4 @@
1
- import { Email } from "./index.mjs";
1
+ import { r as Email, x as Inbox } from "../index-m0wtx22n.mjs";
2
2
  //#region src/email/contract.d.ts
3
3
  declare const CONTRACT_DOMAIN = "mail.acme.dev";
4
4
  declare const CONTRACT_SUPPRESSED = "suppressed@example.com";
@@ -9,5 +9,18 @@ interface ContractCase {
9
9
  run(email: Email): Promise<void>;
10
10
  }
11
11
  declare const emailContract: ReadonlyArray<ContractCase>;
12
+ /**
13
+ * The inbox's fixture: an inbox at `CONTRACT_INBOX` whose one thread has one message that arrived, from
14
+ * `ada@example.com`, with the subject `Hello` and the text `Hi there`.
15
+ *
16
+ * const engine = inboxStandIn({ address: CONTRACT_INBOX }); engine.arrive({ from: "Ada <ada@example.com>", subject: "Hello", text: "Hi there" })
17
+ * for (const c of inboxContract) test(c.name, () => c.run(inbox("support", engine)))
18
+ */
19
+ declare const CONTRACT_INBOX = "support.acme@mail.example";
20
+ interface InboxContractCase {
21
+ readonly name: string;
22
+ run(inbox: Inbox): Promise<void>;
23
+ }
24
+ declare const inboxContract: ReadonlyArray<InboxContractCase>;
12
25
  //#endregion
13
- export { CONTRACT_DOMAIN, CONTRACT_NOW, CONTRACT_SUPPRESSED, ContractCase, emailContract };
26
+ export { CONTRACT_DOMAIN, CONTRACT_INBOX, CONTRACT_NOW, CONTRACT_SUPPRESSED, ContractCase, InboxContractCase, emailContract, inboxContract };
@@ -1,4 +1,4 @@
1
- import { t as EmailError } from "../email-4iedeyjF.mjs";
1
+ import { t as EmailError } from "../email-ynNo0HqT.mjs";
2
2
  //#region src/email/contract.ts
3
3
  /**
4
4
  * Email's contract: what every engine promises, as cases any test runner can run. The Stand-in runs
@@ -190,6 +190,65 @@ const emailContract = [
190
190
  }
191
191
  }
192
192
  ];
193
+ /**
194
+ * The inbox's fixture: an inbox at `CONTRACT_INBOX` whose one thread has one message that arrived, from
195
+ * `ada@example.com`, with the subject `Hello` and the text `Hi there`.
196
+ *
197
+ * const engine = inboxStandIn({ address: CONTRACT_INBOX }); engine.arrive({ from: "Ada <ada@example.com>", subject: "Hello", text: "Hi there" })
198
+ * for (const c of inboxContract) test(c.name, () => c.run(inbox("support", engine)))
199
+ */
200
+ const CONTRACT_INBOX = "support.acme@mail.example";
201
+ const inboxContract = [
202
+ {
203
+ name: "an inbox lists its threads, last active first, and shows one with its messages",
204
+ async run(inbox) {
205
+ const threads = await inbox.threads();
206
+ equal(threads.map((thread) => [
207
+ thread.subject,
208
+ thread.participants,
209
+ thread.messages
210
+ ]), [[
211
+ "Hello",
212
+ ["ada@example.com"],
213
+ 1
214
+ ]], "the threads");
215
+ equal((await inbox.thread(threads[0].id)).items.map((item) => [
216
+ item.status,
217
+ item.subject,
218
+ item.text
219
+ ]), [[
220
+ "received",
221
+ "Hello",
222
+ "Hi there"
223
+ ]], "the thread's messages");
224
+ }
225
+ },
226
+ {
227
+ name: "a reply goes in its thread to whoever wrote last, and the same key sends it once",
228
+ async run(inbox) {
229
+ const [thread] = await inbox.threads({ limit: 1 });
230
+ const reply = await inbox.reply(thread.id, {
231
+ text: "Thanks, on it.",
232
+ key: "ack-hello"
233
+ });
234
+ equal([reply.threadId, reply.to], [thread.id, ["ada@example.com"]], "the reply's thread and recipient");
235
+ equal((await inbox.reply(thread.id, {
236
+ text: "Thanks, on it.",
237
+ key: "ack-hello"
238
+ })).id, reply.id, "the id of the same key sent again");
239
+ equal((await inbox.thread(thread.id)).messages, 2, "the thread's messages after one reply");
240
+ }
241
+ },
242
+ {
243
+ name: "a thread the inbox doesn't have, a reply without text and a page past 100 are refused as invalid",
244
+ async run(inbox) {
245
+ await refuses(() => inbox.thread("thr_nowhere"), "invalid");
246
+ const [thread] = await inbox.threads();
247
+ await refuses(() => inbox.reply(thread.id, { text: " " }), "invalid");
248
+ await refuses(() => inbox.threads({ limit: 101 }), "invalid");
249
+ }
250
+ }
251
+ ];
193
252
  function equal(actual, expected, what) {
194
253
  if (JSON.stringify(actual) !== JSON.stringify(expected)) throw new Error(`${what}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`);
195
254
  }
@@ -203,4 +262,4 @@ async function refuses(call, code) {
203
262
  throw new Error(`expected ${code}, but it was sent`);
204
263
  }
205
264
  //#endregion
206
- export { CONTRACT_DOMAIN, CONTRACT_NOW, CONTRACT_SUPPRESSED, emailContract };
265
+ export { CONTRACT_DOMAIN, CONTRACT_INBOX, CONTRACT_NOW, CONTRACT_SUPPRESSED, emailContract, inboxContract };
@@ -0,0 +1,2 @@
1
+ import { A as ReceivedMail, C as InboxEngine, D as InboxThreadWithMessages, E as InboxThread, F as inbox, I as serveInbox, M as boundInbox, N as checkPage, O as MAX_REPLY, P as checkReply, S as InboxCall, T as InboxReply, b as INBOX_HEADER, j as ThreadCursor, k as MAX_THREADS, w as InboxMessage, x as Inbox, y as BoundInboxAnswer } from "../index-m0wtx22n.mjs";
2
+ export { BoundInboxAnswer, INBOX_HEADER, Inbox, InboxCall, InboxEngine, InboxMessage, InboxReply, InboxThread, InboxThreadWithMessages, MAX_REPLY, MAX_THREADS, ReceivedMail, ThreadCursor, boundInbox, checkPage, checkReply, inbox, serveInbox };
@@ -0,0 +1,2 @@
1
+ import { _ as inbox, d as INBOX_HEADER, f as MAX_REPLY, g as checkReply, h as checkPage, m as boundInbox, p as MAX_THREADS, v as serveInbox } from "../email-ynNo0HqT.mjs";
2
+ export { INBOX_HEADER, MAX_REPLY, MAX_THREADS, boundInbox, checkPage, checkReply, inbox, serveInbox };
package/email/index.d.mts CHANGED
@@ -1,145 +1,2 @@
1
- //#region src/email/index.d.ts
2
- /**
3
- * Email from a Project's code: Messages sent from the sending domains its environment binds.
4
- *
5
- * import { email } from "@midsummer-ai/sdk/email"
6
- *
7
- * const sent = await email().send({ from: "Acme <hi@mail.acme.dev>", to: "ada@example.com", subject: "Welcome", text: "Hello", key: "welcome-ada" })
8
- * await email().send({ from: "billing@mail.acme.dev", to: "ada@example.com", template: "invoice-paid", variables: { name: "Ada", total: "$40" },
9
- * attachments: [{ filename: "invoice.pdf", content: pdfBytes }], key: "invoice-1043" })
10
- * await email().batch(people.map((person) => ({ from: "news@mail.acme.dev", to: person.email, template: "digest", variables: { name: person.name },
11
- * stream: "broadcast", topic: "digest", key: `digest-2026-11-${person.id}` })))
12
- *
13
- * With no engine, `email()` sends from a deployment, in any framework, with nothing to connect.
14
- * Otherwise `engine` is where Messages go: the Stand-in (`@midsummer-ai/sdk/email/stand-in`) in tests,
15
- * or code outside Midsummer with an email key (`email(client(origin, { key }))` from
16
- * `@midsummer-ai/sdk/email/client`). Every engine is held to the cases in `@midsummer-ai/sdk/email/contract`.
17
- *
18
- * Addresses, files and the Message's shape are checked here, before anything leaves the caller. Reuse
19
- * a Message's `key` to retry while the original Message is retained for thirty days. After that
20
- * Message is purged, the same key can send another Message. A suppressed recipient (one that bounced
21
- * or complained, or left a broadcast's topic) is left out and named in `suppressed`; a Message with
22
- * nobody left is `suppressed`. A Message with `sendAt` is `queued` until then. `test: true` sends to
23
- * no one: each recipient's outcome is its address's (`bounce@…`, `soft-bounce@…`, `complaint@…`, else
24
- * delivered), told to your webhooks as a real one would be. Every failure is an `EmailError`, whose
25
- * `code` tells you which kind.
26
- *
27
- * Delivery events reach a Project's webhooks signed as Standard Webhooks says, as every webhook
28
- * Midsummer sends is; `verifyWebhook` checks one with the endpoint's secret.
29
- */
30
- type EmailErrorCode = "invalid" | "unverified" | "forbidden" | "unavailable";
31
- declare class EmailError extends Error {
32
- readonly code: EmailErrorCode;
33
- constructor(code: EmailErrorCode, message: string);
34
- }
35
- /** A file a Message carries: its bytes (or base64 of them), its name, and a content id to show it inline (`<img src="cid:logo">`). */
36
- interface OutgoingAttachment {
37
- readonly filename: string;
38
- readonly content: Uint8Array | string;
39
- /** From the name's extension when left out. */
40
- readonly contentType?: string;
41
- readonly contentId?: string;
42
- }
43
- /** An address is `ada@example.com` or `Ada <ada@example.com>`. */
44
- interface OutgoingMessage {
45
- readonly from: string;
46
- readonly to: string | ReadonlyArray<string>;
47
- readonly cc?: ReadonlyArray<string>;
48
- readonly bcc?: ReadonlyArray<string>;
49
- readonly replyTo?: string;
50
- /** Needed unless `template` gives it. */
51
- readonly subject?: string;
52
- readonly text?: string;
53
- readonly html?: string;
54
- /**
55
- * Reuse the key to retry while the original Message is retained for thirty days. After that
56
- * Message is purged, the same key can send another Message.
57
- */
58
- readonly key?: string;
59
- /** At most 20 files, each at most 10 MB, the Message with them at most 18 MB; programs and scripts are refused. */
60
- readonly attachments?: ReadonlyArray<OutgoingAttachment>;
61
- /** A Template of the Team's, by name: its subject, text and HTML, filled from `variables` (every `{{name}}` it has, and no other). */
62
- readonly template?: string;
63
- readonly variables?: Readonly<Record<string, string | number>>;
64
- /** When to send it, up to thirty days ahead. */
65
- readonly sendAt?: Date | number;
66
- /** `broadcast` for what you send to many, with a `topic` its one recipient can leave in one click. */
67
- readonly stream?: "transactional" | "broadcast";
68
- readonly topic?: string;
69
- readonly tag?: string;
70
- readonly metadata?: Readonly<Record<string, string>>;
71
- readonly track?: {
72
- readonly opens?: boolean;
73
- readonly clicks?: boolean;
74
- };
75
- /** Send it to no one, recorded and told to webhooks as if sent. */
76
- readonly test?: boolean;
77
- }
78
- /** A Message as the engine takes it: `to` always a list, files in base64, `sendAt` in milliseconds. */
79
- interface CheckedMessage extends Omit<OutgoingMessage, "to" | "attachments" | "sendAt"> {
80
- readonly to: ReadonlyArray<string>;
81
- readonly attachments?: ReadonlyArray<{
82
- readonly filename: string;
83
- readonly content: string;
84
- readonly contentType?: string;
85
- readonly contentId?: string;
86
- }>;
87
- readonly sendAt?: number;
88
- }
89
- interface SentMessage {
90
- readonly id: string;
91
- /** `queued` while the send is still under way, or until `sendAt`; `failed` when it was refused, with `error`. */
92
- readonly state: "sent" | "queued" | "suppressed" | "failed";
93
- readonly suppressed: ReadonlyArray<string>;
94
- readonly error?: string;
95
- /** When it is to be sent, while it waits for that. */
96
- readonly sendAt?: number;
97
- }
98
- /** One Message of a batch: sent, or refused with why, the rest going on regardless. */
99
- type BatchResult = {
100
- readonly message: SentMessage;
101
- } | {
102
- readonly error: {
103
- readonly code: EmailErrorCode;
104
- readonly message: string;
105
- };
106
- };
107
- /** Where Messages go: the Seam under `email()`. The Stand-in and the real Capability are its Adapters; one without `batch` sends a batch one Message at a time. */
108
- interface EmailEngine {
109
- send(message: CheckedMessage): Promise<SentMessage>;
110
- batch?(messages: ReadonlyArray<CheckedMessage>): Promise<ReadonlyArray<BatchResult>>;
111
- }
112
- interface Email {
113
- send(message: OutgoingMessage): Promise<SentMessage>;
114
- /** Up to 100 Messages, each its own with its own key; none carries files. Returns each one's result in order. */
115
- batch(messages: ReadonlyArray<OutgoingMessage>): Promise<ReadonlyArray<BatchResult>>;
116
- }
117
- /** The bare address of `Ada <ada@acme.dev>` or `ada@acme.dev`, lowercase; `invalid` when it is none. */
118
- declare function addressOf(value: string): string;
119
- /** At most this many recipients, to, cc and bcc together. */
120
- declare const MAX_RECIPIENTS = 50;
121
- /** At most this many files a Message, each at most `MAX_ATTACHMENT_BYTES`, and the Message with them at most `MAX_MESSAGE_BYTES`. */
122
- declare const MAX_ATTACHMENTS = 20;
123
- declare const MAX_ATTACHMENT_BYTES: number;
124
- declare const MAX_MESSAGE_BYTES: number;
125
- /** At most this many Messages a batch. */
126
- declare const MAX_BATCH = 100;
127
- /** A Message checked as the engine takes it; throws `EmailError("invalid")` saying what is wrong. */
128
- declare function checkMessage(message: OutgoingMessage): CheckedMessage;
129
- declare function email(given?: EmailEngine): Email;
130
- /**
131
- * Whether a webhook delivery Midsummer sent is genuine: signed as Standard Webhooks says, as every
132
- * webhook Midsummer sends is (email delivery events, Inbox rules' `email.received`, a Team's or an
133
- * agent's endpoints, an installed app's events). Give the request's headers (`webhook-id`,
134
- * `webhook-timestamp`, `webhook-signature`), the body exactly as it arrived, and the endpoint's
135
- * secret (`whsec_…`, shown when it was made or rotated). A delivery older than five minutes, or
136
- * ahead of the clock by as much, is refused. After a rotation both secrets sign for a day, and either
137
- * passing is enough. Deliveries are at least once: drop a repeat by its `webhook-id`.
138
- *
139
- * if (!(await verifyWebhook(request.headers, body, process.env.MIDSUMMER_WEBHOOK_SECRET!))) return new Response(null, { status: 401 })
140
- */
141
- declare function verifyWebhook(headers: Headers | Readonly<Record<string, string | undefined>>, body: string, secret: string, options?: {
142
- readonly now?: number;
143
- }): Promise<boolean>;
144
- //#endregion
145
- export { BatchResult, CheckedMessage, Email, EmailEngine, EmailError, EmailErrorCode, MAX_ATTACHMENTS, MAX_ATTACHMENT_BYTES, MAX_BATCH, MAX_MESSAGE_BYTES, MAX_RECIPIENTS, OutgoingAttachment, OutgoingMessage, SentMessage, addressOf, checkMessage, email, verifyWebhook };
1
+ import { A as ReceivedMail, C as InboxEngine, D as InboxThreadWithMessages, E as InboxThread, F as inbox, T as InboxReply, _ as email, a as EmailError, b as INBOX_HEADER, c as MAX_ATTACHMENT_BYTES, d as MAX_RECIPIENTS, f as OutgoingAttachment, g as checkMessage, h as addressOf, i as EmailEngine, j as ThreadCursor, k as MAX_THREADS, l as MAX_BATCH, m as SentMessage, n as CheckedMessage, o as EmailErrorCode, p as OutgoingMessage, r as Email, s as MAX_ATTACHMENTS, t as BatchResult, u as MAX_MESSAGE_BYTES, v as verifyWebhook, w as InboxMessage, x as Inbox } from "../index-m0wtx22n.mjs";
2
+ export { BatchResult, CheckedMessage, Email, EmailEngine, EmailError, EmailErrorCode, INBOX_HEADER, type Inbox, type InboxEngine, type InboxMessage, type InboxReply, type InboxThread, type InboxThreadWithMessages, MAX_ATTACHMENTS, MAX_ATTACHMENT_BYTES, MAX_BATCH, MAX_MESSAGE_BYTES, MAX_RECIPIENTS, MAX_THREADS, OutgoingAttachment, OutgoingMessage, type ReceivedMail, SentMessage, type ThreadCursor, addressOf, checkMessage, email, inbox, verifyWebhook };
package/email/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as MAX_MESSAGE_BYTES, c as checkMessage, i as MAX_BATCH, l as email, n as MAX_ATTACHMENTS, o as MAX_RECIPIENTS, r as MAX_ATTACHMENT_BYTES, s as addressOf, t as EmailError, u as verifyWebhook } from "../email-4iedeyjF.mjs";
2
- export { EmailError, MAX_ATTACHMENTS, MAX_ATTACHMENT_BYTES, MAX_BATCH, MAX_MESSAGE_BYTES, MAX_RECIPIENTS, addressOf, checkMessage, email, verifyWebhook };
1
+ import { _ as inbox, a as MAX_MESSAGE_BYTES, c as checkMessage, d as INBOX_HEADER, i as MAX_BATCH, l as email, n as MAX_ATTACHMENTS, o as MAX_RECIPIENTS, p as MAX_THREADS, r as MAX_ATTACHMENT_BYTES, s as addressOf, t as EmailError, u as verifyWebhook } from "../email-ynNo0HqT.mjs";
2
+ export { EmailError, INBOX_HEADER, MAX_ATTACHMENTS, MAX_ATTACHMENT_BYTES, MAX_BATCH, MAX_MESSAGE_BYTES, MAX_RECIPIENTS, MAX_THREADS, addressOf, checkMessage, email, inbox, verifyWebhook };
package/email/smtp.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { CheckedMessage, SentMessage } from "./index.mjs";
1
+ import { m as SentMessage, n as CheckedMessage } from "../index-m0wtx22n.mjs";
2
2
  //#region src/email/smtp.d.ts
3
3
  /** A `send` that hands each message to Email at `origin` (the API's), with the client's key. */
4
4
  declare function relayTo(origin: string, options?: {
package/email/smtp.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { l as email, p as client, t as EmailError } from "../email-4iedeyjF.mjs";
1
+ import { l as email, t as EmailError, x as client } from "../email-ynNo0HqT.mjs";
2
2
  import { createServer } from "node:net";
3
3
  import { createServer as createServer$1 } from "node:tls";
4
4
  //#region src/email/smtp.ts
@@ -1,4 +1,4 @@
1
- import { CheckedMessage, EmailEngine } from "./index.mjs";
1
+ import { C as InboxEngine, i as EmailEngine, n as CheckedMessage, w as InboxMessage } from "../index-m0wtx22n.mjs";
2
2
  //#region src/email/stand-in.d.ts
3
3
  declare function standIn(options: {
4
4
  readonly domains: ReadonlyArray<string>;
@@ -12,5 +12,25 @@ declare function standIn(options: {
12
12
  }>;
13
13
  suppress(address: string): void;
14
14
  };
15
+ /**
16
+ * An inbox's Stand-in, for tests of code that uses `inbox()`: the mail it keeps in memory, `address` its own. `arrive`
17
+ * puts a message in it as mail that arrived, in a new thread or in reply in one (`thread`), and returns it; a reply is
18
+ * kept as sent and goes nowhere. It passes the inbox contract (`inboxContract`) except durability and delivery.
19
+ *
20
+ * const engine = inboxStandIn({ address: "support.acme@mail.example" })
21
+ * engine.arrive({ from: "ada@example.com", subject: "Hello", text: "Hi there" })
22
+ * await inbox("support", engine).threads()
23
+ */
24
+ declare function inboxStandIn(options: {
25
+ readonly address: string;
26
+ readonly clock?: () => number;
27
+ }): InboxEngine & {
28
+ arrive(mail: {
29
+ readonly from: string;
30
+ readonly subject: string;
31
+ readonly text: string;
32
+ readonly thread?: string;
33
+ }): InboxMessage;
34
+ };
15
35
  //#endregion
16
- export { standIn };
36
+ export { inboxStandIn, standIn };
@@ -1,4 +1,4 @@
1
- import { s as addressOf, t as EmailError } from "../email-4iedeyjF.mjs";
1
+ import { s as addressOf, t as EmailError } from "../email-ynNo0HqT.mjs";
2
2
  //#region src/email/stand-in.ts
3
3
  /**
4
4
  * Email's Stand-in: the Capability's behaviour in memory, for `midsummer dev` and tests. It sends
@@ -57,5 +57,93 @@ function standIn(options) {
57
57
  }
58
58
  };
59
59
  }
60
+ /**
61
+ * An inbox's Stand-in, for tests of code that uses `inbox()`: the mail it keeps in memory, `address` its own. `arrive`
62
+ * puts a message in it as mail that arrived, in a new thread or in reply in one (`thread`), and returns it; a reply is
63
+ * kept as sent and goes nowhere. It passes the inbox contract (`inboxContract`) except durability and delivery.
64
+ *
65
+ * const engine = inboxStandIn({ address: "support.acme@mail.example" })
66
+ * engine.arrive({ from: "ada@example.com", subject: "Hello", text: "Hi there" })
67
+ * await inbox("support", engine).threads()
68
+ */
69
+ function inboxStandIn(options) {
70
+ const own = addressOf(options.address);
71
+ const clock = options.clock ?? Date.now;
72
+ const threads = /* @__PURE__ */ new Map();
73
+ const byKey = /* @__PURE__ */ new Map();
74
+ let count = 0;
75
+ const shown = (id) => {
76
+ const thread = threads.get(id);
77
+ const participants = [...new Set(thread.items.flatMap((item) => [item.from, ...item.to].map(addressOf)))].filter((address) => address !== own);
78
+ return {
79
+ id,
80
+ subject: thread.subject,
81
+ participants,
82
+ labels: [],
83
+ messages: thread.items.length,
84
+ lastAt: thread.items.at(-1).at,
85
+ createdAt: thread.createdAt,
86
+ items: [...thread.items]
87
+ };
88
+ };
89
+ const add = (threadId, message) => {
90
+ const at = clock();
91
+ const id = threadId ?? `thr_${++count}`;
92
+ const thread = threads.get(id) ?? {
93
+ subject: message.subject.replace(/^\s*re\s*:\s*/i, ""),
94
+ createdAt: at,
95
+ items: []
96
+ };
97
+ threads.set(id, thread);
98
+ const kept = {
99
+ ...message,
100
+ id: `msg_${++count}`,
101
+ threadId: id,
102
+ messageId: `${count}@stand-in.invalid`,
103
+ at
104
+ };
105
+ thread.items.push(kept);
106
+ return kept;
107
+ };
108
+ return {
109
+ arrive: (mail) => {
110
+ if (mail.thread !== void 0 && !threads.has(mail.thread)) throw new EmailError("invalid", `No thread ${mail.thread} in this inbox`);
111
+ return add(mail.thread, {
112
+ status: "received",
113
+ from: mail.from,
114
+ to: [own],
115
+ cc: [],
116
+ subject: mail.subject,
117
+ text: mail.text
118
+ });
119
+ },
120
+ async threads({ limit, before }) {
121
+ const all = [...threads.keys()].map(shown).sort((a, b) => b.lastAt - a.lastAt || b.id.localeCompare(a.id));
122
+ return (before ? all.filter((thread) => thread.lastAt < before.lastAt || thread.lastAt === before.lastAt && thread.id < before.id) : all).slice(0, limit).map(({ items: _items, ...thread }) => thread);
123
+ },
124
+ async thread(id) {
125
+ if (!threads.has(id)) throw new EmailError("invalid", `No thread ${id} in this inbox`);
126
+ return shown(id);
127
+ },
128
+ async reply(id, reply) {
129
+ const thread = threads.get(id);
130
+ if (!thread) throw new EmailError("invalid", `No thread ${id} in this inbox`);
131
+ const earlier = reply.key !== void 0 ? byKey.get(`${id}:${reply.key}`) : void 0;
132
+ if (earlier) return earlier;
133
+ const last = [...thread.items].reverse().find((item) => item.status === "received");
134
+ const sent = add(id, {
135
+ status: "sent",
136
+ from: own,
137
+ to: last ? [addressOf(last.from)] : [],
138
+ cc: [],
139
+ subject: `Re: ${thread.subject}`,
140
+ text: reply.text,
141
+ ...reply.html !== void 0 ? { html: reply.html } : {}
142
+ });
143
+ if (reply.key !== void 0) byKey.set(`${id}:${reply.key}`, sent);
144
+ return sent;
145
+ }
146
+ };
147
+ }
60
148
  //#endregion
61
- export { standIn };
149
+ export { inboxStandIn, standIn };
@@ -159,6 +159,139 @@ function isMessage(value) {
159
159
  return typeof m.from === "string" && strings(m.to) && (m.cc === void 0 || strings(m.cc)) && (m.bcc === void 0 || strings(m.bcc)) && optional(m.subject) && optional(m.replyTo) && optional(m.text) && optional(m.html) && optional(m.key) && optional(m.template) && optional(m.topic) && optional(m.tag) && (m.attachments === void 0 || Array.isArray(m.attachments) && m.attachments.every(file)) && record(m.variables, (item) => typeof item === "string" || typeof item === "number") && record(m.metadata, (item) => typeof item === "string") && (m.sendAt === void 0 || typeof m.sendAt === "number") && (m.stream === void 0 || m.stream === "transactional" || m.stream === "broadcast") && (m.track === void 0 || record(m.track, (item) => typeof item === "boolean")) && (m.test === void 0 || typeof m.test === "boolean");
160
160
  }
161
161
  //#endregion
162
+ //#region src/email/inbox.ts
163
+ /**
164
+ * An inbox from a project's code: read the mail an inbox keeps, reply in its threads, and hear of each message as it
165
+ * arrives. The inbox is one the environment binds under a name (`midsummer env binding set acme/web support --kind
166
+ * inbox --resource support`), so the code holds no key, and it is kept apart from sending: `email()` sends from the
167
+ * sending domains the environment binds, `inbox()` reads the mail an inbox receives and replies to it.
168
+ *
169
+ * import { inbox } from "@midsummer-ai/sdk/email"
170
+ *
171
+ * const support = inbox("support")
172
+ * const [latest] = await support.threads({ limit: 10 })
173
+ * const thread = await support.thread(latest.id)
174
+ * await support.reply(thread.id, { text: "Thanks, we're on it.", key: `ack-${thread.id}` })
175
+ *
176
+ * Each message that arrives is posted to the path midsummer.json's `consumers` names for the binding, in production
177
+ * (`"consumers": { "support": "/api/mail" }`), at least once. `received` reads one such delivery, or returns undefined
178
+ * for any other request: Midsummer checks a delivery's signature before your code sees it, and only a checked one
179
+ * carries the binding's name.
180
+ *
181
+ * if (request.method === "POST") { const mail = await support.received(request); if (mail) ... }
182
+ *
183
+ * Outside a deployment, give it an engine: the Stand-in (`inboxStandIn` from `@midsummer-ai/sdk/email/stand-in`) in
184
+ * tests. Every engine is held to the cases in `@midsummer-ai/sdk/email/contract` (`inboxContract`). Every failure is
185
+ * an `EmailError`.
186
+ */
187
+ /** A binding name: 3 to 63 lowercase letters, digits and dashes. */
188
+ const BINDING = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;
189
+ /** The header a checked delivery carries: the name of the binding it is for. */
190
+ const INBOX_HEADER = "midsummer-inbox";
191
+ const MAX_THREADS = 100;
192
+ /** A reply's text and HTML, each at most this many characters. */
193
+ const MAX_REPLY = 65536;
194
+ /** A reply checked as the engine takes it; throws `EmailError("invalid")` saying what is wrong. */
195
+ function checkReply(reply) {
196
+ if (typeof reply?.text !== "string" || !reply.text.trim()) throw new EmailError("invalid", "a reply needs text");
197
+ if (reply.text.length > 65536 || reply.html !== void 0 && reply.html.length > 65536) throw new EmailError("invalid", `a reply's text and html are each at most ${MAX_REPLY} characters`);
198
+ if (reply.key !== void 0 && (typeof reply.key !== "string" || !reply.key || reply.key.length > 200)) throw new EmailError("invalid", "a reply's key is 1 to 200 characters");
199
+ return {
200
+ text: reply.text,
201
+ ...reply.html !== void 0 ? { html: reply.html } : {},
202
+ ...reply.key !== void 0 ? { key: reply.key } : {}
203
+ };
204
+ }
205
+ /** The page asked for, checked; throws `EmailError("invalid")`. */
206
+ function checkPage(options = {}) {
207
+ const limit = options.limit ?? 20;
208
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100) throw new EmailError("invalid", `a page holds 1 to 100 threads`);
209
+ const before = options.before;
210
+ if (before !== void 0 && (typeof before.id !== "string" || typeof before.lastAt !== "number")) throw new EmailError("invalid", "before is the last thread of the page before: { lastAt, id }");
211
+ return {
212
+ limit,
213
+ ...before ? { before: {
214
+ lastAt: before.lastAt,
215
+ id: before.id
216
+ } } : {}
217
+ };
218
+ }
219
+ function inbox(binding, given) {
220
+ if (!BINDING.test(binding)) throw new EmailError("invalid", `"${binding}" is not a binding name: 3 to 63 lowercase letters, digits and dashes`);
221
+ const engine = given ?? late(() => {
222
+ const handle = here()?.inbox;
223
+ if (handle) return boundInbox(handle, binding);
224
+ throw new EmailError("forbidden", `This code runs outside a deployment, so it reaches no inbox. In tests, give inbox("${binding}") an engine: the Stand-in from @midsummer-ai/sdk/email/stand-in.`);
225
+ });
226
+ return {
227
+ threads: async (options) => engine.threads(checkPage(options)),
228
+ async thread(id) {
229
+ if (typeof id !== "string" || !id) throw new EmailError("invalid", "name the thread by its id");
230
+ return engine.thread(id);
231
+ },
232
+ async reply(thread, reply) {
233
+ if (typeof thread !== "string" || !thread) throw new EmailError("invalid", "name the thread to reply in by its id");
234
+ return engine.reply(thread, checkReply(reply));
235
+ },
236
+ async received(request) {
237
+ if (request.method !== "POST" || request.headers.get("midsummer-inbox") !== binding) return void 0;
238
+ const body = await request.json().catch(() => void 0);
239
+ return body?.type === "email.received" && body.data?.message ? body.data : void 0;
240
+ }
241
+ };
242
+ }
243
+ /** What Midsummer hands a deployment as `context.inbox`: each call carries the binding's name, and the platform reads the inbox the environment binds under it. */
244
+ function boundInbox(handle, binding) {
245
+ const call = async (op, input) => {
246
+ let answer;
247
+ try {
248
+ answer = await handle.call(binding, op, input);
249
+ } catch {
250
+ throw new EmailError("unavailable", "The inbox could not be reached");
251
+ }
252
+ if ("value" in answer) return answer.value;
253
+ throw new EmailError(answer.error.code, answer.error.message);
254
+ };
255
+ return {
256
+ threads: async (filter) => await call("threads", filter),
257
+ thread: async (id) => await call("thread", { id }),
258
+ reply: async (thread, reply) => await call("reply", {
259
+ thread,
260
+ ...reply
261
+ })
262
+ };
263
+ }
264
+ /**
265
+ * The platform's side of a bound handle: checks each call again, as it comes from another Worker's code, and hands it
266
+ * to `engine`, the inbox the environment binds under that name (none: refused as forbidden). A refusal is returned as data.
267
+ */
268
+ function serveInbox(engineFor) {
269
+ return async (binding, op, input) => {
270
+ try {
271
+ if (typeof binding !== "string" || !BINDING.test(binding)) throw new EmailError("invalid", "name the inbox by the name your environment binds it under");
272
+ const given = typeof input === "object" && input !== null ? input : {};
273
+ const engine = await engineFor(binding);
274
+ if (!engine) throw new EmailError("forbidden", `This environment binds no inbox named ${binding}. Bind one: midsummer env binding set <team>/<project> ${binding} --kind inbox --resource <inbox>`);
275
+ if (op === "threads") return { value: await engine.threads(checkPage(given)) };
276
+ if (op === "thread") {
277
+ if (typeof given.id !== "string" || !given.id) throw new EmailError("invalid", "name the thread by its id");
278
+ return { value: await engine.thread(given.id) };
279
+ }
280
+ if (op === "reply") {
281
+ if (typeof given.thread !== "string" || !given.thread) throw new EmailError("invalid", "name the thread to reply in by its id");
282
+ return { value: await engine.reply(given.thread, checkReply(given)) };
283
+ }
284
+ throw new EmailError("invalid", "an inbox takes threads, thread and reply");
285
+ } catch (error) {
286
+ if (error instanceof EmailError) return { error: {
287
+ code: error.code,
288
+ message: error.message
289
+ } };
290
+ throw error;
291
+ }
292
+ };
293
+ }
294
+ //#endregion
162
295
  //#region src/email/index.ts
163
296
  /**
164
297
  * Email from a Project's code: Messages sent from the sending domains its environment binds.
@@ -185,6 +318,9 @@ function isMessage(value) {
185
318
  * delivered), told to your webhooks as a real one would be. Every failure is an `EmailError`, whose
186
319
  * `code` tells you which kind.
187
320
  *
321
+ * Reading the mail an inbox receives, and replying to it, is `inbox()` (`./inbox.ts`), apart from sending: an
322
+ * inbox binding is an inbox, and an email binding is a sending domain.
323
+ *
188
324
  * Delivery events reach a Project's webhooks signed as Standard Webhooks says, as every webhook
189
325
  * Midsummer sends is; `verifyWebhook` checks one with the endpoint's secret.
190
326
  */
@@ -334,4 +470,4 @@ function verifyWebhook(headers, body, secret, options = {}) {
334
470
  return verifyEvent(headers, body, secret, options.now ?? Date.now());
335
471
  }
336
472
  //#endregion
337
- export { MAX_MESSAGE_BYTES as a, checkMessage as c, MESSAGES_PATH as d, boundEmail as f, serveMessages as h, MAX_BATCH as i, email as l, serveBound as m, MAX_ATTACHMENTS as n, MAX_RECIPIENTS as o, client as p, MAX_ATTACHMENT_BYTES as r, addressOf as s, EmailError as t, verifyWebhook as u };
473
+ export { serveMessages as C, serveBound as S, inbox as _, MAX_MESSAGE_BYTES as a, boundEmail as b, checkMessage as c, INBOX_HEADER as d, MAX_REPLY as f, checkReply as g, checkPage as h, MAX_BATCH as i, email as l, boundInbox as m, MAX_ATTACHMENTS as n, MAX_RECIPIENTS as o, MAX_THREADS as p, MAX_ATTACHMENT_BYTES as r, addressOf as s, EmailError as t, verifyWebhook as u, serveInbox as v, client as x, MESSAGES_PATH as y };
@@ -0,0 +1,228 @@
1
+ //#region src/email/inbox.d.ts
2
+ /** A thread, as a list shows it: its first message's subject, who wrote in it, and when it was last active. */
3
+ interface InboxThread {
4
+ readonly id: string;
5
+ readonly subject: string;
6
+ /** Every address that wrote in it or was written to, the inbox's own left out. */
7
+ readonly participants: ReadonlyArray<string>;
8
+ readonly labels: ReadonlyArray<string>;
9
+ readonly messages: number;
10
+ readonly lastAt: number;
11
+ readonly createdAt: number;
12
+ }
13
+ /** One message of a thread: one that arrived (`received`), or one the inbox sent, `sending` until it has gone out. */
14
+ interface InboxMessage {
15
+ readonly id: string;
16
+ readonly threadId: string;
17
+ readonly status: "received" | "sending" | "sent" | "failed";
18
+ /** Its `Message-ID` header, without the angle brackets. */
19
+ readonly messageId: string;
20
+ readonly from: string;
21
+ readonly to: ReadonlyArray<string>;
22
+ readonly cc: ReadonlyArray<string>;
23
+ readonly subject: string;
24
+ readonly text: string;
25
+ readonly html?: string;
26
+ readonly at: number;
27
+ readonly error?: string;
28
+ }
29
+ interface InboxThreadWithMessages extends InboxThread {
30
+ /** In the order they arrived or were sent. */
31
+ readonly items: ReadonlyArray<InboxMessage>;
32
+ }
33
+ /** Where a page of threads goes on from: the last thread of the page before. */
34
+ interface ThreadCursor {
35
+ readonly lastAt: number;
36
+ readonly id: string;
37
+ }
38
+ /** A reply as the engine takes it. Reuse its `key` to retry: the same key sends one reply. */
39
+ interface InboxReply {
40
+ readonly text: string;
41
+ readonly html?: string;
42
+ readonly key?: string;
43
+ }
44
+ /** A message that arrived, as its delivery posts it: the inbox, its thread and the message, `truncated` when it was cut to fit. */
45
+ interface ReceivedMail {
46
+ readonly inbox: {
47
+ readonly id: string;
48
+ readonly address: string;
49
+ };
50
+ readonly thread: InboxThread;
51
+ readonly message: InboxMessage;
52
+ readonly truncated?: true;
53
+ }
54
+ /** Where an inbox's calls go: the Seam under `inbox()`. The Stand-in and the real Capability are its Adapters. */
55
+ interface InboxEngine {
56
+ threads(filter: {
57
+ readonly limit: number;
58
+ readonly before?: ThreadCursor;
59
+ }): Promise<ReadonlyArray<InboxThread>>;
60
+ thread(id: string): Promise<InboxThreadWithMessages>;
61
+ reply(thread: string, reply: InboxReply): Promise<InboxMessage>;
62
+ }
63
+ interface Inbox {
64
+ /** Its threads, last active first, at most `limit` (20 unless said, at most 100), after `before`. */
65
+ threads(options?: {
66
+ readonly limit?: number;
67
+ readonly before?: ThreadCursor;
68
+ }): Promise<ReadonlyArray<InboxThread>>;
69
+ /** One thread with its messages. Refused as invalid for one this inbox doesn't have. */
70
+ thread(id: string): Promise<InboxThreadWithMessages>;
71
+ /** Replies in a thread to whoever wrote its last message received; the same `key` sends one reply. */
72
+ reply(thread: string, reply: InboxReply): Promise<InboxMessage>;
73
+ /** The message a delivery to this binding posts, checked by Midsummer; undefined for any other request. Reads the body. */
74
+ received(request: Request): Promise<ReceivedMail | undefined>;
75
+ }
76
+ /** The header a checked delivery carries: the name of the binding it is for. */
77
+ declare const INBOX_HEADER = "midsummer-inbox";
78
+ declare const MAX_THREADS = 100;
79
+ /** A reply's text and HTML, each at most this many characters. */
80
+ declare const MAX_REPLY = 65536;
81
+ /** A reply checked as the engine takes it; throws `EmailError("invalid")` saying what is wrong. */
82
+ declare function checkReply(reply: InboxReply): InboxReply;
83
+ /** The page asked for, checked; throws `EmailError("invalid")`. */
84
+ declare function checkPage(options?: {
85
+ readonly limit?: number;
86
+ readonly before?: ThreadCursor;
87
+ }): {
88
+ readonly limit: number;
89
+ readonly before?: ThreadCursor;
90
+ };
91
+ declare function inbox(binding: string, given?: InboxEngine): Inbox;
92
+ /** What a bound inbox handle returns: the value asked for, or the refusal, which crosses a Service Binding as data. */
93
+ type BoundInboxAnswer = {
94
+ readonly value: unknown;
95
+ } | {
96
+ readonly error: {
97
+ readonly code: EmailErrorCode;
98
+ readonly message: string;
99
+ };
100
+ };
101
+ type InboxCall = "threads" | "thread" | "reply";
102
+ /** What Midsummer hands a deployment as `context.inbox`: each call carries the binding's name, and the platform reads the inbox the environment binds under it. */
103
+ declare function boundInbox(handle: {
104
+ call(binding: string, op: InboxCall, input: unknown): Promise<BoundInboxAnswer>;
105
+ }, binding: string): InboxEngine;
106
+ /**
107
+ * The platform's side of a bound handle: checks each call again, as it comes from another Worker's code, and hands it
108
+ * to `engine`, the inbox the environment binds under that name (none: refused as forbidden). A refusal is returned as data.
109
+ */
110
+ declare function serveInbox(engineFor: (binding: string) => Promise<InboxEngine | undefined>): (binding: unknown, op: unknown, input: unknown) => Promise<BoundInboxAnswer>;
111
+ //#endregion
112
+ //#region src/email/index.d.ts
113
+ type EmailErrorCode = "invalid" | "unverified" | "forbidden" | "unavailable";
114
+ declare class EmailError extends Error {
115
+ readonly code: EmailErrorCode;
116
+ constructor(code: EmailErrorCode, message: string);
117
+ }
118
+ /** A file a Message carries: its bytes (or base64 of them), its name, and a content id to show it inline (`<img src="cid:logo">`). */
119
+ interface OutgoingAttachment {
120
+ readonly filename: string;
121
+ readonly content: Uint8Array | string;
122
+ /** From the name's extension when left out. */
123
+ readonly contentType?: string;
124
+ readonly contentId?: string;
125
+ }
126
+ /** An address is `ada@example.com` or `Ada <ada@example.com>`. */
127
+ interface OutgoingMessage {
128
+ readonly from: string;
129
+ readonly to: string | ReadonlyArray<string>;
130
+ readonly cc?: ReadonlyArray<string>;
131
+ readonly bcc?: ReadonlyArray<string>;
132
+ readonly replyTo?: string;
133
+ /** Needed unless `template` gives it. */
134
+ readonly subject?: string;
135
+ readonly text?: string;
136
+ readonly html?: string;
137
+ /**
138
+ * Reuse the key to retry while the original Message is retained for thirty days. After that
139
+ * Message is purged, the same key can send another Message.
140
+ */
141
+ readonly key?: string;
142
+ /** At most 20 files, each at most 10 MB, the Message with them at most 18 MB; programs and scripts are refused. */
143
+ readonly attachments?: ReadonlyArray<OutgoingAttachment>;
144
+ /** A Template of the Team's, by name: its subject, text and HTML, filled from `variables` (every `{{name}}` it has, and no other). */
145
+ readonly template?: string;
146
+ readonly variables?: Readonly<Record<string, string | number>>;
147
+ /** When to send it, up to thirty days ahead. */
148
+ readonly sendAt?: Date | number;
149
+ /** `broadcast` for what you send to many, with a `topic` its one recipient can leave in one click. */
150
+ readonly stream?: "transactional" | "broadcast";
151
+ readonly topic?: string;
152
+ readonly tag?: string;
153
+ readonly metadata?: Readonly<Record<string, string>>;
154
+ readonly track?: {
155
+ readonly opens?: boolean;
156
+ readonly clicks?: boolean;
157
+ };
158
+ /** Send it to no one, recorded and told to webhooks as if sent. */
159
+ readonly test?: boolean;
160
+ }
161
+ /** A Message as the engine takes it: `to` always a list, files in base64, `sendAt` in milliseconds. */
162
+ interface CheckedMessage extends Omit<OutgoingMessage, "to" | "attachments" | "sendAt"> {
163
+ readonly to: ReadonlyArray<string>;
164
+ readonly attachments?: ReadonlyArray<{
165
+ readonly filename: string;
166
+ readonly content: string;
167
+ readonly contentType?: string;
168
+ readonly contentId?: string;
169
+ }>;
170
+ readonly sendAt?: number;
171
+ }
172
+ interface SentMessage {
173
+ readonly id: string;
174
+ /** `queued` while the send is still under way, or until `sendAt`; `failed` when it was refused, with `error`. */
175
+ readonly state: "sent" | "queued" | "suppressed" | "failed";
176
+ readonly suppressed: ReadonlyArray<string>;
177
+ readonly error?: string;
178
+ /** When it is to be sent, while it waits for that. */
179
+ readonly sendAt?: number;
180
+ }
181
+ /** One Message of a batch: sent, or refused with why, the rest going on regardless. */
182
+ type BatchResult = {
183
+ readonly message: SentMessage;
184
+ } | {
185
+ readonly error: {
186
+ readonly code: EmailErrorCode;
187
+ readonly message: string;
188
+ };
189
+ };
190
+ /** Where Messages go: the Seam under `email()`. The Stand-in and the real Capability are its Adapters; one without `batch` sends a batch one Message at a time. */
191
+ interface EmailEngine {
192
+ send(message: CheckedMessage): Promise<SentMessage>;
193
+ batch?(messages: ReadonlyArray<CheckedMessage>): Promise<ReadonlyArray<BatchResult>>;
194
+ }
195
+ interface Email {
196
+ send(message: OutgoingMessage): Promise<SentMessage>;
197
+ /** Up to 100 Messages, each its own with its own key; none carries files. Returns each one's result in order. */
198
+ batch(messages: ReadonlyArray<OutgoingMessage>): Promise<ReadonlyArray<BatchResult>>;
199
+ }
200
+ /** The bare address of `Ada <ada@acme.dev>` or `ada@acme.dev`, lowercase; `invalid` when it is none. */
201
+ declare function addressOf(value: string): string;
202
+ /** At most this many recipients, to, cc and bcc together. */
203
+ declare const MAX_RECIPIENTS = 50;
204
+ /** At most this many files a Message, each at most `MAX_ATTACHMENT_BYTES`, and the Message with them at most `MAX_MESSAGE_BYTES`. */
205
+ declare const MAX_ATTACHMENTS = 20;
206
+ declare const MAX_ATTACHMENT_BYTES: number;
207
+ declare const MAX_MESSAGE_BYTES: number;
208
+ /** At most this many Messages a batch. */
209
+ declare const MAX_BATCH = 100;
210
+ /** A Message checked as the engine takes it; throws `EmailError("invalid")` saying what is wrong. */
211
+ declare function checkMessage(message: OutgoingMessage): CheckedMessage;
212
+ declare function email(given?: EmailEngine): Email;
213
+ /**
214
+ * Whether a webhook delivery Midsummer sent is genuine: signed as Standard Webhooks says, as every
215
+ * webhook Midsummer sends is (email delivery events, Inbox rules' `email.received`, a Team's or an
216
+ * agent's endpoints, an installed app's events). Give the request's headers (`webhook-id`,
217
+ * `webhook-timestamp`, `webhook-signature`), the body exactly as it arrived, and the endpoint's
218
+ * secret (`whsec_…`, shown when it was made or rotated). A delivery older than five minutes, or
219
+ * ahead of the clock by as much, is refused. After a rotation both secrets sign for a day, and either
220
+ * passing is enough. Deliveries are at least once: drop a repeat by its `webhook-id`.
221
+ *
222
+ * if (!(await verifyWebhook(request.headers, body, process.env.MIDSUMMER_WEBHOOK_SECRET!))) return new Response(null, { status: 401 })
223
+ */
224
+ declare function verifyWebhook(headers: Headers | Readonly<Record<string, string | undefined>>, body: string, secret: string, options?: {
225
+ readonly now?: number;
226
+ }): Promise<boolean>;
227
+ //#endregion
228
+ export { ReceivedMail as A, InboxEngine as C, InboxThreadWithMessages as D, InboxThread as E, inbox as F, serveInbox as I, boundInbox as M, checkPage as N, MAX_REPLY as O, checkReply as P, InboxCall as S, InboxReply as T, email as _, EmailError as a, INBOX_HEADER as b, MAX_ATTACHMENT_BYTES as c, MAX_RECIPIENTS as d, OutgoingAttachment as f, checkMessage as g, addressOf as h, EmailEngine as i, ThreadCursor as j, MAX_THREADS as k, MAX_BATCH as l, SentMessage as m, CheckedMessage as n, EmailErrorCode as o, OutgoingMessage as p, Email as r, MAX_ATTACHMENTS as s, BatchResult as t, MAX_MESSAGE_BYTES as u, verifyWebhook as v, InboxMessage as w, Inbox as x, BoundInboxAnswer as y };
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@midsummer-ai/sdk",
3
- "version": "0.1.0-staging.3494",
3
+ "version": "0.1.0-staging.3500",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Midsummer's handles for an app's code: its Database, Storage, Queues, Vector DB, AI, Email and Agents, with stand-ins for tests.",
7
7
  "repository": {
8
8
  "type": "sol",
9
- "url": "https://midsummer.new/orbit/midsummer/midsummer",
9
+ "url": "https://staging.midsummer.new/orbit/midsummer/midsummer",
10
10
  "directory": "platform/sdk"
11
11
  },
12
- "homepage": "https://docs.midsummer.new",
12
+ "homepage": "https://docs.staging.midsummer.new",
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./index.d.mts",
@@ -135,6 +135,10 @@
135
135
  "types": "./email/client.d.mts",
136
136
  "import": "./email/client.mjs"
137
137
  },
138
+ "./email/inbox": {
139
+ "types": "./email/inbox.d.mts",
140
+ "import": "./email/inbox.mjs"
141
+ },
138
142
  "./email/smtp": {
139
143
  "types": "./email/smtp.d.mts",
140
144
  "import": "./email/smtp.mjs"
@@ -265,6 +269,9 @@
265
269
  "email/client": [
266
270
  "./email/client.d.mts"
267
271
  ],
272
+ "email/inbox": [
273
+ "./email/inbox.d.mts"
274
+ ],
268
275
  "email/smtp": [
269
276
  "./email/smtp.d.mts"
270
277
  ],