/** * Zod schemas and validation utilities for resource operations. * * Every resource extends `basePropsSchema` which defines the `id`, * `createdAt`, and `updatedAt` fields common to all database records. * * @module */ import { z } from 'zod'; /** * Base Zod schema with the three fields every resource row must have: * `id` (UUID), `createdAt` (ISO datetime), and `updatedAt` (ISO datetime). */ export declare const basePropsSchema: z.ZodObject<{ id: z.ZodString; createdAt: z.ZodString; updatedAt: z.ZodString; }, z.core.$strip>; /** * TypeScript type inferred from `basePropsSchema`, containing `id`, `createdAt`, and `updatedAt`. */ export type BaseProps = z.infer; /** * Creates a Zod schema for the standard `{ statusCode, body }` response * returned by resource CRUD operations. * * @param propsSchema - The Zod schema for the resource's props (e.g. `userPropsSchema`). * @returns A Zod schema that validates `{ statusCode: number, body: { props? } | T[] }`. */ export declare const responseSchema: (propsSchema: T) => z.ZodTypeAny; /** * Creates a Zod schema that validates a resource descriptor object * (`{ name, tableName, schema }`). * * @param _propsSchema - The Zod schema for the resource's props (used for type inference only). * @returns A Zod schema that validates the resource descriptor shape. */ export declare const resourceSchema: (_propsSchema: T) => z.ZodTypeAny; /** * Validates data against a Zod schema, throwing an `Error` with a * human-readable message listing all validation failures if invalid. * * @param schema - The Zod schema to validate against. * @param data - The data to validate. * @returns The parsed and typed data if validation succeeds. * @throws {Error} Error with comma-separated validation issue descriptions. */ export declare const validate: (schema: z.ZodSchema, data: unknown) => T; /** * Validates data against a Zod schema without throwing. Returns a discriminated * union: `{ success: true, data }` on success or `{ success: false, error }` on failure. * * @param schema - The Zod schema to validate against. * @param data - The data to validate. * @returns A discriminated union indicating success with parsed data, or failure with a `ZodError`. */ export declare const safeParse: (schema: z.ZodSchema, data: unknown) => { success: true; data: T; } | { success: false; error: z.ZodError; }; /** * Creates a schema where all fields are optional, suitable for validating * partial update payloads where only changed fields are sent. * * @param schema - The Zod object schema to make partial. * @returns A new Zod schema with all fields marked optional. */ export declare const partial: (schema: z.ZodObject) => z.ZodObject<{ [K in keyof T]: z.ZodOptional; }>; /** * Creates a schema with only the specified fields, useful for create payloads * where only a subset of the full props should be provided by the client. * * @param schema - The Zod object schema to pick from. * @param keys - The field names to include in the new schema. * @returns A new Zod schema containing only the picked fields. */ export declare const pick: (schema: z.ZodObject, keys: readonly K[]) => z.ZodObject>; //# sourceMappingURL=schema.d.ts.map