import { E as EmailOptions } from "../packem_shared/types.d-CyiC9uRC.js"; import { a as MockEmailEntry } from "../packem_shared/types.d-V_yuAOrx.js"; import { M as Mail } from "../packem_shared/mail.d-2u-30lWz.js"; import 'node:buffer'; import 'ical-generator'; import "../packem_shared/types.d-I-KeZ5w2.js"; import "../packem_shared/types.d-A1Eea-p_.js"; import "../packem_shared/types.d-Chhzb-48.js"; import "../packem_shared/provider.d-BLLbEuQ8.js"; /** * Returns the http(s) URLs in a message without duplicates, in this order: `href` targets of * anchor and area elements in the HTML, bare URLs in the visible HTML text, then bare URLs in the * plain text. * * Images, `link` and `base` elements, `script` and `style` contents, comments, and CSS `url()` * values are not links, so they are not returned. Entities are decoded in HTML only. Only absolute * http and https URLs are returned. * @param source A plain-text string, or an object with the message's `html` and/or `text`. Pass * markup as `{ html }`; a bare string is always treated as plain text. * @returns The matching URLs. * @example * ```ts * const [verifyUrl] = extractLinks(email.sent()[0]!.options); * ``` */ declare const extractLinks: (source: string | Pick) => string[]; /** * A test harness around the in-memory mock provider: a ready-to-use {@link Mail} instance plus * helpers to inspect, wait on, and reset the captured outbox. */ interface TestEmail { /** * The {@link Mail} instance wired to the mock provider. Use it exactly like a real one. */ mail: Mail; /** * Removes all captured messages. */ reset: () => void; /** * Returns the captured messages, oldest first. */ sent: () => ReadonlyArray; /** * Resolves with the first captured message matching `predicate`, polling until `timeout`. * @param predicate The match condition. * @param options Optional `timeout` (ms, default 1000) and `interval` (ms, default 10). * @param options.interval Poll interval in milliseconds. * @param options.timeout Maximum time to wait in milliseconds. */ waitFor: (predicate: (message: MockEmailEntry) => boolean, options?: { interval?: number; timeout?: number; }) => Promise; } /** * Creates a {@link TestEmail} harness backed by the in-memory mock provider. * * Nothing is sent over the network; every message is captured for assertion via the * {@link https://vitest.dev/ Vitest} matchers exported from `@visulima/email/test`. * @returns The test harness. See {@link TestEmail}. * @example * ```ts * const email = createTestEmail(); * await email.mail.send({ from: { email: "a@x.com" }, to: { email: "b@x.com" }, subject: "Hi", text: "yo" }); * expect(email).toHaveSentTo("b@x.com"); * ``` */ declare const createTestEmail: () => TestEmail; /** * The minimal result shape a Vitest/Jest matcher must return. */ interface MatcherResult { message: () => string; pass: boolean; } /** * A value the email matchers can assert against: a {@link TestEmail} harness or a raw list of captured * entries. */ type MatcherTarget = ReadonlyArray | TestEmail; /** * Asserts that at least one captured message was addressed to `address` (in To, Cc, or Bcc). * @param target The {@link TestEmail} harness or captured entries. * @param address The recipient address to look for (case-insensitive). * @returns The matcher result. */ declare const toHaveSentTo: (target: MatcherTarget, address: string) => MatcherResult; /** * Asserts that at least one captured message has a subject equal to (or matching) `expected`. * @param target The {@link TestEmail} harness or captured entries. * @param expected An exact subject string or a `RegExp`. * @returns The matcher result. */ declare const toHaveSentWithSubject: (target: MatcherTarget, expected: RegExp | string) => MatcherResult; /** * Asserts that at least one captured message carried an attachment (optionally with a given filename). * @param target The {@link TestEmail} harness or captured entries. * @param filename When provided, requires an attachment with this exact filename. * @returns The matcher result. */ declare const toHaveSentWithAttachment: (target: MatcherTarget, filename?: string) => MatcherResult; /** * Asserts that at least one captured message matches a predicate or a partial {@link EmailOptions}. * @param target The {@link TestEmail} harness or captured entries. * @param matcher A predicate over the sent options, or a partial options object to shallow-match. * @returns The matcher result. */ declare const toHaveSentMatching: (target: MatcherTarget, matcher: Partial | ((options: EmailOptions) => boolean)) => MatcherResult; /** * The matcher map, suitable for passing to Vitest/Jest `expect.extend(...)`. */ declare const emailMatchers: { toHaveSentMatching: typeof toHaveSentMatching; toHaveSentTo: typeof toHaveSentTo; toHaveSentWithAttachment: typeof toHaveSentWithAttachment; toHaveSentWithSubject: typeof toHaveSentWithSubject; }; /** * A Vitest/Jest-compatible `expect` exposing `.extend(...)`. */ interface ExpectLike { extend: (matchers: Record) => void; } /** * Registers the email matchers with a Vitest/Jest-compatible `expect`. * * Kept dependency-free by accepting `expect` as an argument rather than importing `vitest` into the * shipped bundle. Add the matching type augmentation to a `vitest.d.ts` in your project for typed * `expect(...).toHaveSentTo(...)` calls. * @param expectInstance The `expect` object exposing `.extend(...)`. * @example * ```ts * import { expect } from "vitest"; * import { registerEmailMatchers } from "@visulima/email/test"; * * registerEmailMatchers(expect); * ``` */ declare const registerEmailMatchers: (expectInstance: ExpectLike) => void; /** * A stable, snapshot-friendly view of a sent message — volatile fields (message id, timestamp) are * omitted so the snapshot doesn't churn between runs. */ interface EmailSnapshot { attachments?: { contentType?: string; filename: string; }[]; bcc?: string[]; cc?: string[]; from: string; headers?: Record; html?: string; replyTo?: string; subject: string; text?: string; to: string[]; } /** * Normalizes a captured message (a `createTestEmail` outbox entry or raw {@link EmailOptions}) into a * deterministic {@link EmailSnapshot} for use with Vitest/Jest `toMatchSnapshot()`. * @param source A mock-provider outbox entry or an `EmailOptions` object. * @returns The snapshot view. * @example * ```ts * expect(toEmailSnapshot(email.sent()[0])).toMatchSnapshot(); * ``` */ declare const toEmailSnapshot: (source: EmailOptions | MockEmailEntry) => EmailSnapshot; export { type EmailSnapshot, type MatcherResult, type MatcherTarget, type TestEmail, createTestEmail, emailMatchers, extractLinks, registerEmailMatchers, toEmailSnapshot, toHaveSentMatching, toHaveSentTo, toHaveSentWithAttachment, toHaveSentWithSubject };