import { z } from "zod"; import { GenericId, GenericValidator, ValidatorJSON, Value } from "convex/values"; //#region src/querying/shared/contract.d.ts export declare function sharedNativeValidator(schema: z.core.$ZodType): GenericValidator | undefined; type RequiredSharedField = V extends { kind: 'string'; } ? z.ZodString : V extends { kind: 'float64'; } ? z.ZodNumber : V extends { kind: 'int64'; } ? z.ZodBigInt : V extends { kind: 'boolean'; } ? z.ZodBoolean : V extends { kind: 'null'; } ? z.ZodNull : V extends { kind: 'literal'; value: infer L extends string | number | bigint | boolean; } ? z.ZodLiteral : V extends { kind: 'id'; } ? z.ZodCustom>, string> : V extends { kind: 'union'; members: []; } ? z.ZodUnion<[]> : V extends { kind: 'union'; members: [infer A extends GenericValidator, ...infer R extends GenericValidator[]]; } ? z.ZodUnion, ...{ [K in keyof R]: SharedField; }]> : V extends { kind: 'union'; members: (infer E extends GenericValidator)[]; } ? [GenericValidator] extends [E] ? z.ZodUnion : z.ZodUnion[]> : never; export type SharedField = V extends { isOptional: 'optional'; } ? z.ZodOptional> : RequiredSharedField; type FieldSchemas> = { [K in keyof F]: SharedField; }; type FilterSide = 'input' | 'output'; type InputValue = V extends GenericId ? string : V; type Scalar = S extends 'input' ? InputValue> : Exclude; type Ordered = [GenericValidator] extends [V] ? false : V extends { kind: 'string' | 'float64' | 'int64'; } ? true : V extends { kind: 'literal'; } ? Exclude extends string | number | bigint ? true : false : V extends { kind: 'union'; members: infer M extends GenericValidator[]; } ? false extends Ordered ? false : true : false; type Predicate = Scalar | ({ eq?: Scalar; in?: Scalar[]; } & (Ordered extends true ? { gt?: Scalar; gte?: Scalar; lt?: Scalar; lte?: Scalar; } : {}) & (V['isOptional'] extends 'optional' ? { exists?: boolean; } : {})); type Fields, S extends FilterSide> = { [K in keyof F]?: Predicate; }; type Tail = D extends [1, ...infer R extends 1[]] ? R : []; export type SharedFilters, S extends FilterSide = 'output', D extends 1[] = [1, 1, 1, 1]> = Omit, 'and' | 'or' | 'not' | 'fields'> & { fields?: Fields; } & (D extends [] ? {} : { and?: SharedFilters>[]; or?: SharedFilters>[]; not?: SharedFilters>; }); export interface FilterDescriptor { field: string; kind: 'string' | 'number' | 'bigint' | 'boolean' | 'null' | 'id' | 'enum' | 'union'; optional: boolean; nullable: boolean; values?: readonly (string | number | bigint | boolean)[]; idTables: readonly string[]; operators: readonly string[]; members?: readonly FilterDescriptor[]; } export interface FilterContract> { readonly fields: FieldSchemas; readonly native: Readonly>; readonly schema: z.ZodType, SharedFilters>; describe(): readonly FilterDescriptor[]; evaluate(filters: SharedFilters, document: Record, accessible?: ReadonlySet): boolean | 'unknown'; readonly searchParam: { encode(value: SharedFilters): { success: true; value: string; } | { success: false; error: string; }; decode(value: string): { success: true; value: SharedFilters; } | { success: false; error: string; }; }; } /** Scalar-only contracts explicitly reject objects, arrays, relations and variants. */ export declare function defineFilterContract>(input: F): FilterContract; //#endregion //# sourceMappingURL=contract.d.mts.map