/** Structured, display-ready view of an error: a headline + an optional cause. */ export interface ExtractedError { /** Primary line — the server's `message` (may be an i18n key) or a fallback. */ title: string; /** Secondary line — the specific cause: `details`, `error`, joined validation * `errors`, or a raw network/thrown message. Undefined when nothing more * specific than the title is available. */ description?: string; } /** * Pull the best available headline + cause out of an axios error, a raw * `{ success:false, ... }` response body, or a thrown Error/string. Pure — no * i18n, no toast — so it is unit-testable and reusable (dialogs, inline errors). * * Resolution: * title ← data.message (else the specific cause, so the toast is never * empty; else `fallbackTitle`) * description ← data.details → data.error → joined data.errors → raw err.message */ export declare function extractServerError(err: unknown, fallbackTitle: string): ExtractedError; /** i18n translator, tolerant of non-keys (returns `defaultValue`/the input). * Accepts arbitrary interpolation values (e.g. `label`, plus a code's `params`) * so `localizeFieldIssue` can pass `{{label}}` and friends through i18next. */ export type Translate = (key: string, opts?: { defaultValue?: string; [k: string]: unknown; }) => string; /** A single normalized validation issue for one field: either a machine `code` * (+ optional `params`) to localize, or a ready-to-show `message` string. */ export interface FieldIssue { code?: string; params?: Record; message?: string; } /** * Pull the per-field `errors` map out of an axios error (`err.response.data.errors`) * or a bare response body (`{ errors }`), normalizing each field's value to a * `FieldIssue[]`. A value may be a single entry or an array; string entries become * `{message}`, object entries `{code,params}`. Returns `undefined` when there is no * usable map (no `errors`, or nothing normalized). Pure — no i18n, no toast. */ export declare function extractFieldErrors(err: unknown): Record | undefined; /** * Localize a single `FieldIssue` to a human string using the field `label` and * the operator's language. A pre-localized `message` passes through verbatim. * Otherwise `code` is translated via `t('validation.'+key)` with a catalog * default (es unless `language` is `en` / `en-*`). */ export declare function localizeFieldIssue(issue: FieldIssue, label: string, t: Translate, language?: string): string; /** Localize a whole 422 `errors` map into `{ [field]: firstMessage }` using * optional per-key labels (already translated) and the current language. */ export declare function localizeFieldErrorMap(map: Record, t: Translate, opts?: { labels?: Record; language?: string; }): Record; /** * Toast a successful mutation/action response, LOCALIZED. The kernel/host often * returns a hardcoded English `message` ("Record created successfully"); echoing * it verbatim leaks English into a Spanish UI. So we only translate the server * message when it is an i18n KEY (dotted, e.g. "pos.rate.created"); a prose * message is dropped in favour of the localized `fallbackKey` (default * "common.success"). Pass the app's `t`. */ export declare function toastServerSuccess(data: unknown, opts?: { t?: Translate; fallbackKey?: string; }): void; /** * Toast a server/network error, surfacing the REAL cause as the description * instead of a bare generic line. A 422 `{errors:{field:[{code}]}}` bag is * localized per-field (never `[object Object]` / English "validation failed"). * Pass `language` (i18n.language) so catalogs match the operator's lang; * pass `labels` so field keys map to translated headers. */ export declare function toastServerError(err: unknown, opts?: { t?: Translate; fallback?: string; language?: string; labels?: Record; }): void; //# sourceMappingURL=server-error.d.ts.map