import type { ReadonlyJSONValue } from '../../../shared/src/json.ts';
import type { Schema } from '../../../zero-types/src/schema.ts';
import type { SchemaQuery } from '../mutate/custom.ts';
import type { Query } from './query.ts';
export type QueryFn<TContext, TTakesContext extends boolean, TArg extends ReadonlyJSONValue[], TReturnQuery extends Query<any, any, any>> = TTakesContext extends false ? {
    (...args: TArg): TReturnQuery;
} : {
    (context: TContext, ...args: TArg): TReturnQuery;
};
export type SyncedQuery<TName extends string, TContext, TTakesContext extends boolean, TArg extends ReadonlyJSONValue[], TReturnQuery extends Query<any, any, any>> = QueryFn<TContext, TTakesContext, TArg, TReturnQuery> & {
    queryName: TName;
    parse: ParseFn<TArg> | undefined;
    takesContext: TTakesContext;
};
export declare function syncedQuery<TName extends string, TArg extends ReadonlyJSONValue[], TReturnQuery extends Query<any, any, any>>(name: TName, parser: ParseFn<TArg> | HasParseFn<TArg> | undefined, fn: QueryFn<unknown, false, TArg, TReturnQuery>): SyncedQuery<TName, unknown, false, TArg, TReturnQuery>;
export declare function syncedQueryWithContext<TName extends string, TContext, TArg extends ReadonlyJSONValue[], TReturnQuery extends Query<any, any, any>>(name: TName, parser: ParseFn<TArg> | HasParseFn<TArg> | undefined, fn: QueryFn<TContext, true, TArg, TReturnQuery>): SyncedQuery<TName, TContext, true, TArg, TReturnQuery>;
export declare function withValidation<T extends SyncedQuery<any, any, any, any, any>>(fn: T): T extends SyncedQuery<infer N, infer C, any, any, infer R> ? SyncedQuery<N, C, true, ReadonlyJSONValue[], R> : never;
export type ParseFn<T extends ReadonlyJSONValue[]> = (args: unknown[]) => T;
export type HasParseFn<T extends ReadonlyJSONValue[]> = {
    parse: ParseFn<T>;
};
export type Parser<T extends ReadonlyJSONValue[]> = ParseFn<T> | HasParseFn<T>;
export type CustomQueryID = {
    name: string;
    args: ReadonlyArray<ReadonlyJSONValue>;
};
/**
 * Returns a set of query builders for the given schema.
 */
export declare function createBuilder<S extends Schema>(s: S): SchemaQuery<S>;
//# sourceMappingURL=named.d.ts.map