//#region src/core/schema/value-parsers.d.ts /** * Parse functions backing the sugar flag factories (`flag.url()`, * `flag.date()`, `flag.duration()`, `flag.bytes()`). * * Each parser converts a raw CLI/env/config value into a typed value and * throws a plain `Error` with a human-readable reason on invalid input. The * parse and resolve pipelines wrap thrown errors with flag context * (`Failed to parse flag --x: `), so parsers only describe the value * problem itself. * * @module dreamcli/core/schema/value-parsers */ /** Options accepted by `flag.url()`. */ interface UrlFlagOptions { /** * Allowed URL protocols, without the trailing colon (e.g. `['https']`). * @defaultValue `undefined` (any protocol) */ readonly protocols?: readonly string[]; } /** Options accepted by `flag.date()`. */ interface DateFlagOptions { /** * Inclusive earliest allowed date. * @defaultValue `undefined` (no lower bound) */ readonly min?: Date; /** * Inclusive latest allowed date. * @defaultValue `undefined` (no upper bound) */ readonly max?: Date; } /** * Parse a strict ISO-8601 date string into a `Date`. * * Rejects non-string input, non-ISO shapes, and calendar-invalid components * (`2026-02-31` does not silently roll over to March). Offset-less datetimes * are interpreted as UTC so results never depend on the machine's timezone. * * @param raw - Raw flag value. * @param options - Optional inclusive date bounds. * @returns The parsed `Date`. * @throws Error with a human-readable reason on invalid input. */ declare function parseDateValue(raw: unknown, options?: DateFlagOptions): Date; /** * Parse a URL string into a `URL`, optionally restricting protocols. * * @param raw - Raw flag value. * @param options - Optional protocol allowlist. * @returns The parsed `URL`. * @throws Error with a human-readable reason on invalid input. */ declare function parseUrlValue(raw: unknown, options?: UrlFlagOptions): URL; /** * Parse a human duration (`'30s'`, `'5m'`, `'1.5h'`, `'250ms'`, `'2d'`) into * milliseconds. A bare number (`'1500'`) is treated as milliseconds. Compound * values (`'1h30m'`) are supported. * * @param raw - Raw flag value. * @returns Duration in milliseconds. * @throws Error with a human-readable reason on invalid input. */ declare function parseDurationValue(raw: unknown): number; /** * Parse a human byte size (`'512mb'`, `'1.5gb'`, `'64kb'`, `'100b'`) into a * byte count. Units are binary (`1kb` = 1024 bytes) and case-insensitive; a * bare number is treated as bytes. * * @param raw - Raw flag value. * @returns Size in bytes. * @throws Error with a human-readable reason on invalid input. */ declare function parseBytesValue(raw: unknown): number; //#endregion export { type DateFlagOptions, type UrlFlagOptions, parseBytesValue, parseDateValue, parseDurationValue, parseUrlValue };