import { IndexCondition, NativePagination } from "./querying/filters.mjs"; import { EnginePaginationResult } from "./zod-table.mjs"; import { ExactGroupSelection, FieldGroupRequest, RelationDeclarations, RelationFilterSelection, RelationFilters, RelationGroupSelection, RelationQueryRow, RelationRegistry, RelationSelection, RelationTables } from "./relations.mjs"; import { ManagedBudgets, ManagedQueryContext, ManagedScope, ManagedSecurityConfig } from "./querying/security.mjs"; import { CursorCodecConfig, CursorError, ScopedCursorCodec, ScopedCursorOptions } from "./querying/cursors.mjs"; import { SearchError, SearchPaginationResult } from "./querying/search.mjs"; import { queryFailureContract } from "./querying/failures.mjs"; import { DataModelFromSchemaDefinition, GenericDatabaseReader, GenericSchema, SchemaDefinition } from "convex/server"; import { z } from "zod"; import { GenericId, Value } from "convex/values"; //#region src/querying.d.ts type FullMask = { [K in keyof S]-?: NonNullable extends true ? true : FullMask, true>>; }; type Paths = L extends readonly [1, ...infer Rest extends 1[]] ? { [K in keyof D[T] & string]: (D[T][K]['cardinality'] extends 'many' ? K : never) | `${K}.${Paths}`; }[keyof D[T] & string] : never; type PathTarget = P extends `${infer Head}.${infer Rest}` ? PathTarget : D[T][P]['target']; type PathScope = P extends `${infer Head}.${infer Rest}` ? PathScope : Extract['tag'], string>; type RemainingDepth

= L extends readonly [1, ...infer Rest extends 1[]] ? P extends `${string}.${infer Tail}` ? RemainingDepth : Rest : []; type EngineArgs = NativePagination & { filters?: RelationFilters>>; order?: 'asc' | 'desc'; }; /** Typed declarative chain returned by the engine; named for consumer declaration emission. */ export interface TableQuery = SchemaDefinition, G = {}, Root extends boolean = true> { search: Root extends true ? (index: Extract[Extract]['searchIndexes'], string>, text: string) => SearchQuery : never; include>(groups: Groups & Record>, never>): TableQuery & { fieldGroups: Groups; }, Root>; orderBy(index: Exclude[Extract]['indexes'], string>, 'by_id' | 'by_creation_time'>): TableQuery; when(value: IndexCondition['value'], index: string): TableQuery; where(spec: NonNullable['filters']>): TableQuery; with, const Groups extends RelationGroupSelection = {}>(selection: Selection & { [K in keyof Selection]: K extends keyof RelationSelection ? Selection[K] : never; }, groups?: ExactGroupSelection): TableQuery & Groups, Root>; relation>>(parent: GenericId, path: P): Omit, P>, keyof Tables>, {}, RemainingDepth, PathScope, P>, Schema, {}, false>, 'relation'>; paginate(args: EngineArgs): Promise>>; } export interface SearchQuery = SchemaDefinition, G = {}> { include>(groups: Groups & Record>, never>): SearchQuery & { fieldGroups: Groups; }>; where(spec: NonNullable['filters']>): SearchQuery; with, const Groups extends RelationGroupSelection = {}>(selection: Selection & { [K in keyof Selection]: K extends keyof RelationSelection ? Selection[K] : never; }, groups?: ExactGroupSelection): SearchQuery & Groups>; paginate(args: Omit, 'order' | 'endCursor' | 'maximumRowsRead' | 'maximumBytesRead' | 'onEmptyBudget'> & { scanLimit?: number; }): Promise>>; } export interface QueryEngineDeclaration, Tables extends RelationTables, D extends RelationDeclarations> { schema: Schema; relations: RelationRegistry; } /** Advanced server configuration, separate from the normal schema/relations declaration. */ export interface QueryEngineOptions, Tables extends RelationTables = RelationTables> { /** Explicit codecs validate at creation. Otherwise environment keys load at first paginate. */ cursor?: CursorCodecConfig; budgets?: Partial; maxPageSize?: number; policyVersion?: string; engineVersion?: string; trustedAdapter?: ManagedSecurityConfig>['trustedAdapter']; fieldGroups?: { [T in keyof Tables]?: { [G in keyof NonNullable]?: (ctx: FieldGroupPolicyContext) => boolean | Promise; }; }; } export interface FieldGroupPolicyContext> { readonly db: GenericDatabaseReader>; readonly scope: ManagedScope; } export declare class FieldGroupError extends Error { readonly code = "FIELD_GROUP_DENIED"; constructor(); } /** @deprecated Use QueryEngineDeclaration and optional QueryEngineOptions separately. */ export interface QueryEngineConfig, Tables extends RelationTables, D extends RelationDeclarations> extends QueryEngineDeclaration, QueryEngineOptions { cursor: CursorCodecConfig; } type QueryEngine, Tables extends RelationTables, D extends RelationDeclarations> = { (ctx: ManagedQueryContext>): { [T in keyof Tables]: TableQuery; }; /** Opens prove integrity only; native consumers must enforce current row authorization. */ cursorCodec>(ctx: ManagedQueryContext>, options: ScopedCursorOptions): ScopedCursorCodec; tables: RelationRegistry['tables']; }; /** Central facade. Endpoint chains carry declarative constraints and explicit relationships. */ export declare function createQueryEngine, const Tables extends RelationTables, const D extends RelationDeclarations>(config: QueryEngineDeclaration, options?: QueryEngineOptions): QueryEngine; /** @deprecated Pass advanced fields in the optional second argument. */ export declare function createQueryEngine, const Tables extends RelationTables, const D extends RelationDeclarations>(config: QueryEngineDeclaration & QueryEngineOptions & { cursor: CursorCodecConfig; }): QueryEngine; //#endregion export { CursorError, type ScopedCursorCodec, type ScopedCursorOptions, SearchError, type SearchPaginationResult, queryFailureContract }; //# sourceMappingURL=querying.d.mts.map