import { z } from "zod"; import { type AllowedFilter, type AllowedFilters, filterSchema, filtersParamSchema } from "./filters.js"; import { type AllowedSort, type AllowedSorts, sortSchema, sortsParamSchema } from "./sorts.js"; type AnyParamsSchema = z.ZodType; type ObjectShape = Record; export interface LimitParamDefinition { default?: number; max?: number; min?: number; description?: string; } export interface ParamsDefinitionOptions { schema: TSchema; filters?: TF; sorts?: TS; limit?: TL; } type AddFieldIfMissing = TKey extends keyof TShape ? {} : { [K in TKey]: TField; }; type FiltersField = TF extends AllowedFilters ? AddFieldIfMissing> : {}; type SortsField = TS extends AllowedSorts ? AddFieldIfMissing> : {}; type LimitField = TL extends LimitParamDefinition ? TL extends { default: number; } ? AddFieldIfMissing> : AddFieldIfMissing> : {}; type ParamsShape = TSchema extends z.ZodObject ? z.ZodObject & SortsField & LimitField> : TSchema; export interface ParamsDefinition { readonly kind: "params_definition"; readonly schema: ParamsShape; readonly controls: { readonly filters?: TF; readonly sorts?: TS; readonly limit?: TL; }; } export type ParamsLike = z.ZodType | ParamsDefinition; export type ParamsSchema

= P extends ParamsDefinition ? P["schema"] : P extends z.ZodType ? P : never; export type InferParams

= z.infer>; export declare function defineParams(options: ParamsDefinitionOptions): ParamsDefinition; export declare function isParamsDefinition(value: ParamsLike): value is ParamsDefinition; export declare function getParamsSchema

(params: P): ParamsSchema

; export declare function getParamsControls(params: ParamsLike): ParamsDefinition["controls"] | undefined; export declare function getTopLevelObjectShape(schema: z.ZodType): ObjectShape | undefined; export type { AllowedFilter, AllowedFilters, AllowedSort, AllowedSorts }; export { filterSchema, filtersParamSchema, sortSchema, sortsParamSchema }; //# sourceMappingURL=params.d.ts.map