import type { z } from "@zod/zod"; import type { Document, IndexDescription, ObjectId } from "mongodb"; /** * Type alias for Zod schema objects */ export type Schema = z.ZodObject; /** * Infer the TypeScript type from a Zod schema, including MongoDB Document */ export type Infer = z.infer & Document; /** * Infer the model type from a Zod schema, including MongoDB Document and ObjectId */ export type InferModel = Infer & { _id?: ObjectId; }; /** * Infer the input type for a Zod schema (handles defaults) */ export type Input = z.input; /** * Type for indexes that can be passed to the Model constructor */ export type Indexes = IndexDescription[]; /** * Complete definition of a model, including schema and indexes * * @example * ```ts * const userDef: ModelDef = { * schema: userSchema, * indexes: [ * { key: { email: 1 }, unique: true }, * { key: { name: 1 } } * ] * }; * ``` */ export type ModelDef = { schema: T; indexes?: Indexes; };