import type { CreateInvoiceBase64Result, CreateInvoiceOptions, CreateInvoiceResult, InvoiceData } from "./types.js"; /** * Creates a PDF invoice and returns a temporary download URL and calculations. * Requires an internet connection and is intended for server-side Node.js use. * The API validates invoice fields and calculates totals; this client keeps no invoice state. * * Use `.then()`/`.catch()` or `await` inside an async function. Top-level `await` * is also supported when the calling project's module and TypeScript settings allow it. * Each call has a 30-second deadline, including the PDF download for base64 output. * * @param data - Invoice fields and optional account key. Omitted or `undefined` data defaults to `{}`. * @param options - Client output selection. Defaults to a URL; use { output: "base64" } to download and encode. * @returns URL metadata by default, or a base64 PDF when explicitly requested. * @throws {TypeError} The promise rejects if arguments are invalid or cannot be serialized as JSON. * @throws {EasyInvoiceError} The promise rejects on HTTP errors, network failures, timeouts, or malformed responses. * * @example * import { createInvoice, saveInvoice } from "easyinvoice"; * * createInvoice({ * mode: "development", * products: [{ quantity: 2, description: "Consulting", taxRate: 8.25, price: 75 }], * settings: { currency: "USD", locale: "en-US" }, * }) * .then((result) => saveInvoice(result, "invoice.pdf")) * .catch((error) => console.error(error)); */ export declare function createInvoice(data?: InvoiceData, options?: { output?: "url"; }): Promise; export declare function createInvoice(data: InvoiceData | undefined, options: { output: "base64"; }): Promise; export declare function createInvoice(data: InvoiceData | undefined, options: CreateInvoiceOptions): Promise; /** * Downloads an existing invoice directly to a local file without base64 conversion. * The URL expires, so call this promptly after createInvoice(). * Streams into a temporary file beside the destination and replaces the destination only * after a complete download. A failed download leaves an existing destination untouched. * Each save has its own 30-second deadline and never creates another invoice. * * @param invoice - The URL result returned by createInvoice(). * @param filename - Destination path. Its parent directory must already exist. * @throws {EasyInvoiceError} On HTTP, network, timeout, and empty download failures. * @throws {Error} On filesystem failures, including a missing directory or denied access. */ export declare function saveInvoice(invoice: CreateInvoiceResult, filename: string): Promise;