//#region src/core/extract/zod-version.d.ts /** * The zod release a schema was built by, and whether this compiler can stand * in for it. * * Compiled validators reproduce zod 4.5's semantics byte-for-byte: the * absent-key `expected: "nonoptional"` rule that 4.4 introduced, the * code-point string lengths and tuple issue order of 4.5, the 4.5 format * regexes. That fidelity is the contract, and it cuts both ways — a validator * compiled here but installed on a schema from zod 4.3 accepts and rejects * differently from the zod the application actually calls everywhere else, * with nothing to say so. The peer range (`^4.5.0`) is meant to prevent that * pairing, but only npm treats a violated peer range as an error; pnpm, yarn * and bun warn and install anyway. This guard is the second line: one check at * the root of extraction, which every entry point (CLI, build plugin, register * hook, `jit()`) passes through, so an unsupported zod is refused with an * explanation instead of compiled into subtly different validators. * * The version is read off the SCHEMA INSTANCE — `_zod.version`, which * `$ZodType.init` stamps on every schema, classic and mini alike, since 4.0 — * rather than off an imported zod module. A project can hold two zod copies * (a hoisted one and a nested one, or a build-time and a runtime one), and the * copy that built the schema is the one whose semantics its validator must * match. A schema with no version at all is refused too: every zod 4 stamps * one, so its absence means a zod older than this compiler has ever targeted. * A value that is not a zod schema in the first place (no `_zod.def`) is not * this guard's to judge — extraction reports it the way it always has, and * calling it a version problem would send the user chasing the wrong fix. */ /** Lowest zod release whose semantics the emitted validators reproduce. */ declare const MIN_ZOD_VERSION: { readonly major: 4; readonly minor: 5; }; interface ZodVersion { major: number; minor: number; patch: number; } /** * `name` of the error {@link assertSupportedZod} throws. Matched by name, not * by identity, so a second copy of this module in the graph still recognises it. */ declare const UNSUPPORTED_ZOD_VERSION_ERROR = "UnsupportedZodVersionError"; /** The `_zod.version` a schema carries, or `undefined` when it has none (or is not a schema). */ declare function zodVersionOf(schema: unknown): ZodVersion | undefined; /** * Within the peer range: the same major, at or past the minimum minor. A * hypothetical zod 5 is refused as well — its semantics are unknown here, and * the promise is exactness, not best effort. */ declare function isSupportedZodVersion(version: ZodVersion | undefined): boolean; declare function unsupportedZodVersionMessage(version: ZodVersion | undefined): string; /** * Throw a recognisable error (see {@link isUnsupportedZodVersionError}) when * `schema` is a zod schema from an unsupported zod. Anything that is not a zod * schema at all passes through untouched, for the caller's own error path. */ declare function assertSupportedZod(schema: unknown): void; /** * The predicate's target is deliberately narrower than `Error`: a caller that * already holds an `Error` keeps it on the negative branch (a bare `error is * Error` would leave `never` there). */ declare function isUnsupportedZodVersionError(error: unknown): error is Error & { name: typeof UNSUPPORTED_ZOD_VERSION_ERROR; }; /** * Print the refusal once per process. Every schema in an application fails the * guard the same way, so one explanation is the useful amount — and the paths * that call this (`jit()` at module scope, the plugin's per-export failure * hook, the hoist compiler's catch-all) would otherwise either say nothing or * say it once per export. */ declare function warnUnsupportedZodOnce(message: string): void; //#endregion export { MIN_ZOD_VERSION, UNSUPPORTED_ZOD_VERSION_ERROR, ZodVersion, assertSupportedZod, isSupportedZodVersion, isUnsupportedZodVersionError, unsupportedZodVersionMessage, warnUnsupportedZodOnce, zodVersionOf }; //# sourceMappingURL=zod-version.d.ts.map