import z from 'zod'; /** * Defines how "canonical" timezone names are determined. * * - `'iana'` (default): Uses a strict IANA-compliant list where only the latest canonical names are accepted. * Provides consistent behavior across all environments. * * - `'runtime'`: Uses the runtime's `Intl` implementation to determine canonical names. * Results may vary between environments (e.g., Chromium considers `Asia/Calcutta` * canonical, while Node.js and Firefox use `Asia/Kolkata`). */ type CanonicalMode = 'runtime' | 'iana'; /** * A tuple representing a custom timezone mapping. * [0] - The non-canonical name (will be matched case-insensitively) * [1] - The canonical name to map to (preserved as-is, treated as canonical) */ type TimezoneMapping = readonly [ nonCanonical: string, canonical: string ]; interface TimezoneSchemaOptions { /** * Determines how canonical timezone names are resolved. * @default 'iana' */ canonicalMode?: CanonicalMode; /** * Custom timezone mappings that override built-in mappings. * Array of tuples: [nonCanonicalName, canonicalName] * * Keys are matched case-insensitively. * Values are treated as canonical names — if the value doesn't exist * in the built-in canonical sets, it becomes a new valid canonical name. */ customMappings?: TimezoneMapping[]; } /** * Creates a set of timezone validation schemas with the given configuration. * * @example * ```typescript * import { createTimezoneSchemas } from 'zod-timezone-validation'; * * // Default: IANA mode, no custom mappings * const { CoercedCanonicalTimezoneSchema } = createTimezoneSchemas(); * * // Runtime mode with custom mappings * const { CanonicalTimezoneSchema } = createTimezoneSchemas({ * canonicalMode: 'runtime', * customMappings: [ * ['Asia/Calcutta', 'Asia/Kolkata'], * ['legacy/zone', 'My/New/Canonical'], * ], * }); * ``` */ declare function createTimezoneSchemas(options?: TimezoneSchemaOptions): { /** Validates and transforms to canonical form (e.g. `US/Eastern` → `America/New_York`). */ CoercedCanonicalTimezoneSchema: z.core.$ZodBranded>, "CanonicalTimezone", "out">; /** Accepts only strictly canonical names. Rejects valid but non-canonical aliases. */ CanonicalTimezoneSchema: z.core.$ZodBranded>, "CanonicalTimezone", "out">; /** Accepts any valid timezone — canonical or non-canonical — without transformation. */ TimezoneSchema: z.core.$ZodBranded>, "Timezone", "out">; }; /** The return type of `createTimezoneSchemas`. */ type TimezoneSchemas = ReturnType; /** Branded string type for a canonical timezone (inferred from schema output). */ type CanonicalTimezone = z.infer; /** Branded string type for any valid timezone (inferred from schema output). */ type Timezone = z.infer; export { type CanonicalMode, type CanonicalTimezone, type Timezone, type TimezoneMapping, type TimezoneSchemaOptions, type TimezoneSchemas, createTimezoneSchemas };