import type { z } from 'zod'; import type { DefinitionEntityNameResolver } from './definition-ref-builder.js'; import type { ExpressionSlotMap, RefExpressionParser } from './expression-types.js'; import type { RefContextSlot } from './ref-context-slot.js'; import type { DefinitionEntityType, ReferenceOnDeleteAction, ReferencePath } from './types.js'; export interface EntitySchemaMeta { readonly kind: 'entity'; readonly type: DefinitionEntityType; readonly idPath: ReferencePath; readonly getNameResolver?: (value: any) => DefinitionEntityNameResolver | string; readonly parentSlot?: RefContextSlot; readonly provides?: RefContextSlot; /** When true, arrays of this entity type are sorted by name during serialization for deterministic output. */ readonly sortByName?: boolean; } export interface ReferenceSchemaMeta { readonly kind: 'reference'; readonly type: DefinitionEntityType; readonly onDelete: ReferenceOnDeleteAction; readonly parentSlot?: RefContextSlot; readonly provides?: RefContextSlot; } export interface ExpressionSchemaMeta { readonly kind: 'expression'; readonly parser: RefExpressionParser; readonly slots?: ExpressionSlotMap; } export interface RefContextSchemaMeta { readonly kind: 'ref-context'; readonly slots: RefContextSlot[]; } /** * An entity annotation collected during the schema walk. * Represents a single entity instance found in the parsed data. */ export interface DefinitionEntityAnnotation { path: ReferencePath; id: string; idPath: ReferencePath; type: DefinitionEntityType; nameResolver: DefinitionEntityNameResolver | string; parentSlot?: RefContextSlot; provides?: RefContextSlot; } /** * A reference annotation collected during the schema walk. */ export interface DefinitionReferenceAnnotation { path: ReferencePath; type: DefinitionEntityType; onDelete: ReferenceOnDeleteAction; parentSlot?: RefContextSlot; provides?: RefContextSlot; } /** * A slot annotation collected during the schema walk. */ export interface DefinitionSlotAnnotation { path: ReferencePath; slot: RefContextSlot; } /** * An expression annotation collected during the schema walk. */ export interface DefinitionExpressionAnnotation { path: ReferencePath; value: unknown; parser: RefExpressionParser; slots?: ExpressionSlotMap; } /** * All annotations collected during a single schema+data walk. */ export interface CollectedRefs { entities: DefinitionEntityAnnotation[]; references: DefinitionReferenceAnnotation[]; slots: DefinitionSlotAnnotation[]; expressions: DefinitionExpressionAnnotation[]; } /** * Discriminated union of all Baseplate schema metadata types. * * New metadata types can be added by: * 1. Adding a new interface with a unique `kind` * 2. Adding it to this union * 3. Implementing a `SchemaWalkerCollector` that handles the new kind */ export type DefinitionRefMeta = EntitySchemaMeta | ReferenceSchemaMeta | ExpressionSchemaMeta | RefContextSchemaMeta; /** * Global registry that stores Baseplate metadata on Zod schema instances. * * Uses a plain WeakMap to avoid Zod's `$replace` type substitution * which causes "type instantiation excessively deep" errors with complex unions. * * Stores an array of metadata per schema to support schemas that carry multiple * annotations (e.g. a schema that is both an `entity` and a `ref-context`). * * Used by `withEnt`, `withRef`, `withExpression`, and `refContext` to attach * metadata to schema nodes. The parallel schema+data walker reads this registry * to extract entity/reference/expression information after validation. */ export declare const definitionRefRegistry: { add(schema: z.ZodType, meta: DefinitionRefMeta): void; getAll(schema: z.ZodType): DefinitionRefMeta[]; has(schema: z.ZodType): boolean; }; //# sourceMappingURL=definition-ref-registry.d.ts.map