import { type ResolvedTypedJsonConfig, type TypedJsonTypeResolution } from '../config/typed-json'; /** * The `declare global` emitter for `typedJson.emitNamespace`. * * What it is for: prisma-json-types-generator reads `namespace PrismaJson` and types the * Prisma Client from it, which means the shape is authored twice, once as a TypeScript * type and once as a Zod schema. Emitting the namespace from the schemas removes the * second copy: the Zod schema is authored, the type is `z.infer` of it, and they cannot * drift. * * What it is not: this does not type the Prisma Client. PJTG works by rewriting the * client's `index.d.ts`; a `declare global` block alone does nothing to it. PJTG stays in * the toolchain for that, and after this there is still exactly one authored definition. * * A namespace that does not compile is worse than none, so anything this module cannot * derive confidently is skipped with a warning rather than guessed at. Skipping costs the * user one `PrismaJson.X` they have to write themselves; guessing costs them a type that * silently disagrees with the schema validating the same data. * * This module writes one standalone declaration file and touches no other emitted output. */ /** * First line of every file this module writes, and the marker that lets a rerun tell its * own output apart from a file the user wrote. */ export declare const GENERATED_BANNER = "Generated by prisma-zod-generator. Do not edit."; /** One annotated field's contribution to the namespace. */ export interface TypedJsonNamespaceBinding { /** The `[TypeName]` written in the annotation. */ typeName: string; /** Model the annotation was found on, for traceability and clash reporting. */ model: string; /** Field the annotation was found on. */ field: string; /** * How that type name resolved, from `resolveTypedJsonType`. * * Passed in rather than recomputed here: the reader has already decided what schema it * used for the field, and the namespace must declare *that*, not a second opinion. */ resolution: TypedJsonTypeResolution; } export interface BuildTypedJsonNamespaceInput { bindings: TypedJsonNamespaceBinding[]; config: ResolvedTypedJsonConfig; /** * Directory that a relative `schemaModule` and a relative `namespaceOutput` are * resolved against, normally the generator output directory. */ baseDir: string; /** Module `z` is imported from. Defaults to `zod`; follows `zodImportTarget`. */ zodImportSpecifier?: string; /** * Extension appended to a relative import specifier, for example `.js`. * * Defaults to whatever the `prisma-client` generator block implies, which is what every * other file this generator writes uses. It has to be the same answer: under * `moduleResolution: nodenext` a relative ESM import without an extension is * `error TS2835`, so one file disagreeing with the rest stops the whole emitted tree * compiling. Empty for everyone not on NodeNext, which is the unchanged default. */ importExtension?: string; } /** A type name annotated twice, resolving to two different schemas. */ export interface TypedJsonNamespaceConflict { typeName: string; /** The binding that was declared. */ used: TypedJsonNamespaceBinding; /** Bindings ignored because they disagreed with it. */ ignored: TypedJsonNamespaceBinding[]; } export interface TypedJsonNamespaceResult { /** The file's contents, or `null` when there is nothing to declare. */ content: string | null; /** Absolute path the file would be written to. */ filePath: string; /** Type names declared, in emitted order. */ declared: string[]; /** Type names left out, with the reason. */ skipped: Array<{ typeName: string; reason: string; }>; conflicts: TypedJsonNamespaceConflict[]; warnings: string[]; } /** Where the namespace file goes for a given output directory. */ export declare function typedJsonNamespacePath(config: ResolvedTypedJsonConfig, baseDir: string): string; /** * Build the `declare global` file. * * Returns `content: null` when nothing survives - no annotated fields at all, or none * whose type could be derived. Callers must write no file in that case: an empty * declaration file is a file the user has to explain to themselves later. */ export declare function buildTypedJsonNamespace(input: BuildTypedJsonNamespaceInput): TypedJsonNamespaceResult; export interface WriteTypedJsonNamespaceResult { /** Where the file was written, or `null` when nothing was written. */ filePath: string | null; /** Set when an existing file blocked the write, so "nothing to write" stays distinct. */ refusedPath: string | null; declared: string[]; skipped: Array<{ typeName: string; reason: string; }>; conflicts: TypedJsonNamespaceConflict[]; warnings: string[]; } /** * Write the namespace file, creating whatever directories `namespaceOutput` needs. * * Writes nothing when `emitNamespace` is off or there is nothing to declare, and returns * `filePath: null` so the caller can tell the difference between "wrote it" and "there * was nothing to write". * * `namespaceOutput` is the one path here that is meant to point *outside* the output * directory, because the declaration is only useful where the consumer's tsconfig already * looks - normally `src/`. Nothing else in the pipeline guards that path, and the safe * cleanup machinery does not cover it, so a file this module did not write is left alone * and reported instead of overwritten. Refusing costs a warning; the alternative costs * someone their file. */ export declare function writeTypedJsonNamespace(input: BuildTypedJsonNamespaceInput): Promise;