import type { Say } from '../say.js'; import type { ImportIssue } from '../types.js'; /** * Cell parsers: one pure function for each kind of value (§ 4.5, point 5). * * A parser gets the text of one cell **after** `prepareText`: trimmed, not * blank, escaped where REST escapes. It returns the value in the form the * services want (§ 4.1) or a failure that says what is wrong. It does not know * the column or the row; `cellIssue` adds them. */ export interface CellFailure { ok: false; code: 'INVALID_VALUE' | 'INVALID_JSON'; params: Record; /** Ends the sentence `The value in column "x" …`. */ problem: string; } export type CellResult = { ok: true; value: T; } | CellFailure; export declare const accept: (value: T) => CellResult; export declare const refuse: (code: CellFailure["code"], params: Record, problem: Say | string) => CellFailure; /** The failure as a sentence that can be said in another language. */ export declare function sentenceOf(failure: CellFailure): Say; /** The limits of ALL-20: what the database column can hold. */ export declare const MAX_QTY = 2147483647; export declare const MAX_POSITION = 32767; /** `decimal(12,4)` holds less than this; `price` and `weight` stay below it. */ export declare const DECIMAL_BELOW = 100000000; /** The sentence of an issue about a cell: `The value in column "x" …`. */ export declare function cellMessage(column: string, failure: CellFailure): Say; export declare function cellIssue(failure: CellFailure, where: { rowNumber: number; column: string; value?: string; }): ImportIssue; /** `1`, `0`, `true`, `false` in any letter case (ALL-10). */ export declare function parseBoolean(text: string): CellResult<0 | 1>; /** * Digits only, from 0 to `max` (ALL-20). The result is a string: the core * patterns check strings, and a number would pass them unchecked (§ 4.1). * Leading zeros are removed. */ export declare function parseWholeNumber(text: string, max: number): CellResult; /** * A price or a weight: digits, and a point with one or two decimals (the * pattern of the core schema), below 100,000,000 (ALL-20). A string, see * `parseWholeNumber`. Leading zeros of the whole part are removed. */ export declare function parseDecimal(text: string): CellResult; /** `YYYY-MM-DD`, a day that exists (`2026-02-30` does not). */ export declare function parseDate(text: string): CellResult; /** `#RRGGBB`, in any letter case (the pattern of core's `compileField`). */ export declare function parseColor(text: string): CellResult; /** * Splits a list on `|`. Every item is trimmed and an empty item is dropped * (`a||b` and `a|b|` are two items), so this never fails; an empty list means * the same as a blank cell. */ export declare function parseList(text: string): string[]; export type JsonShape = 'object' | 'array' | 'any'; /** A JSON cell (ALL-11). `expect` also checks the kind of the top-level value. */ export declare function parseJson(text: string, expect: JsonShape): CellResult; /** * An `http` or `https` address (IMG-01), returned as written: the image's * destination in storage comes from this text (§ 5.8). Spaces and control * characters are refused; the URL parser would quietly drop or encode them. */ export declare function parseHttpUrl(text: string): CellResult; /** * The old path of a redirect (PRD-23): starts with `/`, no space, no `?`, no * `#`. It is stored as written; the storefront compares it exactly. */ export declare function parseRedirectPath(text: string): CellResult; /** * The shape of a bcrypt hash that `compareSync` can read (CUS-06, § 5.4.1). The * cost is at most 15: the work doubles with each step, and a hash of cost 31 * would keep the single process of the store busy for days at the first login of * that customer, with no password needed to ask for it. */ export declare function parseBcryptHash(text: string): CellResult; /** * The longest e-mail address (RFC 5321). Core accepts a longer one, but the * expression below backtracks on a long run of letters, and a cell can hold 64 * KiB, so a longer address is refused before the expression runs. */ export declare const MAX_EMAIL_LENGTH = 254; /** An e-mail address, as core's schema accepts it (CUS-01). */ export declare function parseEmail(text: string): CellResult;