import { EmailAction } from "../action.js";

//#region src/core/email.d.ts
declare const EMAIL_ERROR_CODES: readonly ["NOT_FOUND", "INVALID_INPUT", "CREDITS_EXHAUSTED", "RATE_LIMITED", "DAILY_LIMIT_REACHED", "SENDER_UNAVAILABLE", "BLOCKED", "PROVIDER_REJECTED", "UNAVAILABLE"];
type EmailErrorCode = (typeof EMAIL_ERROR_CODES)[number];
interface EmailSendInit {
  /** Ignored when the action declares its own. */
  to?: ReadonlyArray<string>;
  /** Ignored when the action declares its own `cc` or `to`. */
  cc?: ReadonlyArray<string>;
  /** Ignored when the action declares its own `bcc` or `to`. */
  bcc?: ReadonlyArray<string>;
  /** Ignored when the action declares its own. */
  replyTo?: string;
  subject: string;
  /** Plain text or HTML. */
  body: string;
}
interface EmailSent {
  /** Null when the mail provider did not report one; the email was still sent. */
  messageId: string | null;
}
/**
 * Thrown when Softr did not send the email. `code` says why:
 *
 * - `NOT_FOUND`: no such action, or the caller is not in its audience.
 * - `INVALID_INPUT`: the call's inputs were refused; the message says which.
 * - `CREDITS_EXHAUSTED`: the workspace has no workflow credits left.
 * - `RATE_LIMITED`: the caller or the app sent too many emails lately; try again later.
 * - `DAILY_LIMIT_REACHED`: Softr's own address sent the app's emails for today.
 * - `SENDER_UNAVAILABLE`: the chosen sender is missing or not confirmed, or the action leaves `to` open and would send from Softr's address.
 * - `BLOCKED`: Softr paused the app's emails for a day because one looked like phishing.
 * - `PROVIDER_REJECTED`: the mail provider refused the email.
 * - `UNAVAILABLE`: Softr could not send it right now, or could not be reached.
 */
declare class EmailError extends Error {
  readonly status: number;
  readonly code: EmailErrorCode;
  constructor(status: number, code: EmailErrorCode, message: string);
}
/** Sends one email through the action. Never retries by itself. */
declare function sendEmail(action: EmailAction, init: EmailSendInit): Promise<EmailSent>;
declare const email: {
  send: typeof sendEmail;
};
//#endregion
export { EmailError, EmailErrorCode, EmailSendInit, EmailSent, email };