import { h as ValidationViolation } from "./errors-CyuuoKx0.js"; import { a as FormField, i as FormDefinition, r as FormConfig, s as FormMailer } from "./types-Bv7XuMW0.js"; import { SQLiteColumnBuilderBase } from "drizzle-orm/sqlite-core"; //#region src/core/forms/columns.d.ts /** camelCase field key → snake_case column name (matches the framework tables: * `firstName` → `first_name`). */ declare function columnName(key: string): string; /** * Derive the full Drizzle column set for a form: an autoincrement `id`, one * column per field, and a `created_at` timestamp defaulting to now. The result * is spread into `sqliteTable(name, columns)`—identical in shape to the * hand-authored framework tables, so drizzle-kit generates a normal migration. */ declare function deriveFormColumns(fields: Record): Record; //#endregion //#region src/core/forms/defineForm.d.ts /** * Define a form. Returns the config plus everything derived from it—the * Drizzle `columns`/`table` and the `reviewColumns` the Settings renders. Pass the * result's `table` to `formRoute` (capture) and to the submissions review route. * * ```ts * const contact = defineForm({ * name: "inquiries", * fields: { * email: { type: "email", label: "Email", required: true }, * message: { type: "textarea", label: "Message", required: true, validation: (r) => r.max(5000) }, * }, * }); * ``` */ declare function defineForm(config: FormConfig): FormDefinition; //#endregion //#region src/core/forms/honeypot.d.ts /** * Whether autofill is likely to fill a field with this name: the name, split * into words on punctuation and camelCase, contains a word that browsers or * password managers match (`website`, `email`, `company`, `address`, …). A * honeypot with such a name catches real visitors whose browser fills it. */ declare function autofillProneName(name: string): boolean; //#endregion //#region src/core/forms/notify.d.ts /** Render a submission as a plain-text `key: value` block for an email/webhook. */ declare function renderSubmissionText(config: FormConfig, values: Record): string; /** * Fire a form's declared notifications for a submission. The webhook POSTs * `{ form, values }`; the email uses the site-supplied `mailer`. Errors are * reported with `reportDegraded` and otherwise swallowed (a notification * failure must never fail the submission the visitor already completed)—the * caller runs this via `ctx.waitUntil`. */ declare function notifySubmission(config: FormConfig, values: Record, mailer?: FormMailer): Promise; /** Which silent heuristic held a submission. */ type SpamVerdict = "honeypot" | "too-fast"; /** * Run the silent anti-spam heuristics on the raw body: a filled honeypot field, * or a submit sooner than `spam.minSeconds` after the render helper's * `louise_ts` stamp. Returns which one fired, or `null` when neither did. A * missing timestamp isn't a bot: a plain HTML form without the render helper * doesn't stamp one. * * A browser or password manager can fill a honeypot a person never sees, so a * verdict isn't proof of a bot. `formRoute` logs each one (or hands it to * `onSpam`) rather than dropping it without a trace. */ declare function spamVerdict(config: FormConfig, body: Record): SpamVerdict | null; /** Whether {@link spamVerdict} holds the submission. The route answers a * held submission with a fake success, so a bot can't tune. */ declare function looksLikeSpam(config: FormConfig, body: Record): boolean; //#endregion //#region src/core/forms/validate.d.ts /** How a field reads what people type. */ interface CoerceOptions { /** * The site's BCP 47 locale, from `FormConfig.locale`. With it, a `number` * field reads that locale's grouping and decimal separators, so `1,000` is * one thousand in `en-US` and `1.000,5` is a thousand and a half in `de-DE`. * Without it, a number must be written as `Number()` reads it. */ locale?: string; } /** * Coerce a raw submitted value to the field's stored shape: numbers to `number`, * checkboxes to `boolean`, everything else to a trimmed string (or `null` when * blank so an optional field stores NULL, not `""`). A `url` typed without a * scheme gains `https://`, and a `number` reads the grouping separators of * `options.locale` when there is one. */ declare function coerceFormValue(field: FormField, raw: unknown, options?: CoerceOptions): unknown; interface SubmissionResult { /** Coerced values keyed by field name (ready to store). */ values: Record; /** All validation violations (errors + warnings). */ violations: ValidationViolation[]; } /** * Validate one already-coerced field value: the `required` flag, the per-type * built-in checks (email/url format, select allowlist, number), and the field's * `validation` chain (via {@link validateValue}). `data` is the whole submission * (for cross-field custom validators). Shared by {@link validateSubmission} and * the TanStack Form adapter, so both run identical rules. */ declare function validateField(key: string, field: FormField, value: unknown, data?: Record): Promise; /** * Validate + coerce a raw submission (`data`) against a form's fields. Runs the * `required` flag, the per-type built-in checks, the select allowlist, and each * field's `validation` chain (via {@link validateValue}). Unknown keys in `data` * are ignored—only declared fields are read and stored. */ declare function validateSubmission(config: FormConfig, data: Record): Promise; //#endregion //#region src/core/forms/tanstack.d.ts /** A TanStack Form field-validator: returns an error string, or `undefined` when * valid. * * Async so DB-backed custom rules can be awaited—which is also why these * belong in TanStack's `onChangeAsync` / `onBlurAsync` / `onSubmitAsync` slots * rather than the sync ones. See {@link tanstackFieldValidator}. */ type TanstackFieldValidator = (args: { value: unknown; }) => Promise; /** * A TanStack Form validator for one field, backed by the shared engine. Coerces * like the server, runs {@link validateField}, and returns the first error's * message (TanStack shows one error per field) or `undefined`. * * **Wire it to an `*Async` slot.** These validators are async by contract (below), * and TanStack keys its slots on that: a promise-returning function in `onChange` * is stored *as the promise*, so `meta.errors` holds a pending Promise instead of * a string. Nothing throws—the message simply never renders and the submit * button never disables, which reads exactly like "validation isn't running". * * ```tsx * * ``` * * `onBlurAsync` and `onSubmitAsync` take the same function; pair with * `onChangeAsyncDebounceMs` if a rule hits the network. */ declare function tanstackFieldValidator(key: string, field: FormField, options?: CoerceOptions): TanstackFieldValidator; /** * Build a `{ [fieldName]: validator }` map for every field in a form, ready to * spread onto each ``. * Complex forms wire these into `@tanstack/solid-form` and keep Louise's one * validation definition. * * The map is FLAT, mirroring `FormConfig.fields`—`defineForm` has no array or * nested field type, since each field is one column. A form with repeating rows * builds its array with TanStack's own API and attaches these validators to the * leaves. */ declare function tanstackFormValidators(config: FormConfig): Record; //#endregion export { deriveFormColumns as _, SubmissionResult as a, validateSubmission as c, notifySubmission as d, renderSubmissionText as f, columnName as g, defineForm as h, CoerceOptions as i, SpamVerdict as l, autofillProneName as m, tanstackFieldValidator as n, coerceFormValue as o, spamVerdict as p, tanstackFormValidators as r, validateField as s, TanstackFieldValidator as t, looksLikeSpam as u };