/** * Parser for prisma-json-types-generator (PJTG) field annotations. * * PJTG carries two forms in a Prisma triple-slash comment: * * /// [TypeName] a reference to `.TypeName` * /// ![] an inline TypeScript type * * This module only *recognises* them. It converts nothing and emits nothing; * see `ts-type-to-zod.ts` for conversion and `resolver.ts` for the public API. * * The recognition rules are deliberately strict. A false positive here means a * generated schema built from prose, which would reject valid production data * at runtime. A false negative only means today's untyped behaviour is kept. * So an annotation must own its line: leading and trailing whitespace is fine, * anything else is not. That rejects markdown links `[text](url)`, markdown * images `![alt](url)`, prose in brackets, and unbalanced brackets. */ /** Which of PJTG's two forms was found. */ export type PjtgAnnotationKind = 'namespace-ref' | 'inline-type'; export interface PjtgAnnotation { kind: PjtgAnnotationKind; /** * For `namespace-ref`, the bare type name (`WorkflowNode`). * For `inline-type`, the TypeScript type text with the outer `![` `]` removed. */ value: string; /** The annotation exactly as it appeared, e.g. `[WorkflowNode]` or `![1 | 2]`. */ raw: string; /** Zero-based index of the documentation line the annotation starts on. */ line: number; } export interface PjtgAnnotationParseResult { /** The single annotation found, or null when there is none or more than one. */ annotation: PjtgAnnotation | null; /** True when the documentation carries any `@zod.` annotation. */ hasZodAnnotations: boolean; /** True when `@zod...custom.use(...)` is present, which replaces the base schema and wins. */ hasZodCustomUse: boolean; /** True when `@zod.custom({ ... })` is present, which also replaces the base schema. */ hasZodCustom: boolean; /** Non-fatal diagnostics worth surfacing to the user. */ warnings: string[]; /** The documentation with every recognised annotation line removed. */ strippedDocumentation: string; } /** * Parse a field's `documentation` for a PJTG annotation. * * Never throws. When the documentation is ambiguous (two different annotations) * the result carries a warning and no annotation, so the caller falls back to * today's behaviour rather than picking one. */ export declare function parsePjtgAnnotation(documentation: string | undefined | null): PjtgAnnotationParseResult; /** * Cheap yes/no for whether a field carries a PJTG annotation. * * Always agrees with `parsePjtgAnnotation(...).annotation !== null`. */ export declare function detectPjtgAnnotation(documentation: string | undefined | null): boolean;