import type { TuplePaths } from '@baseplate-dev/utils'; import { z } from 'zod'; import type { DefinitionEntityType } from '#src/index.js'; import type { PluginSpecStore } from '#src/plugins/index.js'; import type { DefinitionEntityInput, DefinitionReferenceInput } from './definition-ref-builder.js'; import type { ExpressionParserRef } from './expression-parser-ref.js'; import type { ExpressionSlotMap } from './expression-types.js'; import type { RefContextSlotDefinition, RefContextSlotMap } from './ref-context-slot.js'; import { RefExpressionParser } from './expression-types.js'; type ZodTypeWithOptional = T extends z.ZodOptional ? z.ZodOptional, z.input>> : T extends z.ZodDefault ? z.ZodDefault, z.input>> : T extends z.ZodPrefault ? z.ZodPrefault, z.input>> : z.ZodType, z.input>; export type WithRefType = (reference: DefinitionReferenceInput) => z.ZodType; export type WithEntType = > | undefined = undefined>(schema: TType, entity: DefinitionEntityInput, TEntityType, TIdPath>) => ZodTypeWithOptional; /** * Creates ref context slots for use within a schema definition. * Slots provide type-safe context for parent-child entity relationships. */ export type RefContextType = (slotDefinition: TSlotDef, schemaBuilder: (slots: RefContextSlotMap) => TSchema) => ZodTypeWithOptional; /** * Wraps a value with a ref expression parser for deferred validation. * The parser handles all parsing, validation, and rename handling. * * If the parser declares required slots (via TRequiredSlots), they must be * provided as the second argument. TypeScript enforces this at compile time. */ export interface WithExpressionType { (parser: RefExpressionParser): z.ZodType; >(parser: RefExpressionParser, slots: ExpressionSlotMap): z.ZodType; (parserRef: ExpressionParserRef): z.ZodType; >(parserRef: ExpressionParserRef, slots: ExpressionSlotMap): z.ZodType; } /** * Creates a string schema annotated as a reference to another entity. * * Can be used standalone: * ```typescript * withRef({ type: modelEnumEntityType, onDelete: 'RESTRICT' }) * ``` * * Or on the parser context: * ```typescript * ctx.withRef({ type: modelEnumEntityType, onDelete: 'RESTRICT' }) * ``` */ export declare function withRef(reference: DefinitionReferenceInput): z.ZodType; /** * Creates a schema decorator that marks a schema as defining an entity. * * Can be used with `.apply()`: * ```typescript * schema.apply(withEnt({ type: modelEntityType, provides: modelSlot })) * ``` * * Or via the parser context (2-arg legacy form): * ```typescript * ctx.withEnt(schema, { type: modelEntityType, provides: modelSlot }) * ``` * * @param entity - The entity definition input * @returns A function that decorates a schema with entity metadata */ export declare function withEnt(entity: DefinitionEntityInput): (schema: TType) => ZodTypeWithOptional; export declare function extendParserContextWithRefs(plugins?: PluginSpecStore): { withRef: WithRefType; withEnt: WithEntType; refContext: RefContextType; withExpression: WithExpressionType; }; export {}; //# sourceMappingURL=extend-parser-context-with-refs.d.ts.map