import type { BaseAdapter } from './base.js';
import { AdapterType } from './types.js';
import { z } from 'zod';
/**
 * Supported comparison operators for database queries
 */
export type Operator = '==' | '!=' | '<' | '<=' | '>' | '>=' | 'in' | 'not-in' | 'array-contains' | 'array-contains-any';
/**
 * Schema for validating query operators
 */
export declare const operatorSchema: z.ZodUnion<[z.ZodLiteral<"==">, z.ZodLiteral<"!=">, z.ZodLiteral<"<">, z.ZodLiteral<"<=">, z.ZodLiteral<">">, z.ZodLiteral<">=">, z.ZodLiteral<"in">, z.ZodLiteral<"not-in">, z.ZodLiteral<"array-contains">, z.ZodLiteral<"array-contains-any">]>;
/**
 * Represents a filter condition for database queries
 */
export interface QueryFilter<T = unknown> {
    /** The field to filter on */
    field: string;
    /** The comparison operator */
    operator: Operator;
    /** The value to compare against */
    value: T;
}
/**
 * Schema for validating query filters
 */
export declare const queryFilterSchema: z.ZodObject<{
    field: z.ZodString;
    operator: z.ZodUnion<[z.ZodLiteral<"==">, z.ZodLiteral<"!=">, z.ZodLiteral<"<">, z.ZodLiteral<"<=">, z.ZodLiteral<">">, z.ZodLiteral<">=">, z.ZodLiteral<"in">, z.ZodLiteral<"not-in">, z.ZodLiteral<"array-contains">, z.ZodLiteral<"array-contains-any">]>;
    value: z.ZodAny;
}, "strip", z.ZodTypeAny, {
    field: string;
    operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any";
    value?: any;
}, {
    field: string;
    operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any";
    value?: any;
}>;
/**
 * Options for database adapter queries
 * @template T - Type of the document being queried
 */
export interface DatabaseAdapterQueryOptions<T = unknown> {
    /** Filter conditions */
    where?: QueryFilter[];
    /** Sorting order as [field, direction] */
    orderBy?: [string, 'asc' | 'desc'];
    /** Maximum number of results to return */
    limit?: number;
    /** Cursor for pagination - start after this document */
    startAfter?: unknown;
    /** Cursor for pagination - end before this document */
    endBefore?: unknown;
    /** Fields to include in the result */
    select?: (keyof T)[];
    /** Number of documents to skip */
    offset?: number;
}
/**
 * Schema for validating database query options
 */
export declare const databaseQueryOptionsSchema: z.ZodObject<{
    where: z.ZodOptional<z.ZodArray<z.ZodObject<{
        field: z.ZodString;
        operator: z.ZodUnion<[z.ZodLiteral<"==">, z.ZodLiteral<"!=">, z.ZodLiteral<"<">, z.ZodLiteral<"<=">, z.ZodLiteral<">">, z.ZodLiteral<">=">, z.ZodLiteral<"in">, z.ZodLiteral<"not-in">, z.ZodLiteral<"array-contains">, z.ZodLiteral<"array-contains-any">]>;
        value: z.ZodAny;
    }, "strip", z.ZodTypeAny, {
        field: string;
        operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any";
        value?: any;
    }, {
        field: string;
        operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any";
        value?: any;
    }>, "many">>;
    orderBy: z.ZodOptional<z.ZodTuple<[z.ZodString, z.ZodEnum<["asc", "desc"]>], null>>;
    limit: z.ZodOptional<z.ZodNumber>;
    startAfter: z.ZodOptional<z.ZodAny>;
    endBefore: z.ZodOptional<z.ZodAny>;
    select: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
    offset: z.ZodOptional<z.ZodNumber>;
}, "strict", z.ZodTypeAny, {
    where?: {
        field: string;
        operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any";
        value?: any;
    }[] | undefined;
    orderBy?: [string, "asc" | "desc"] | undefined;
    limit?: number | undefined;
    startAfter?: any;
    endBefore?: any;
    select?: any[] | undefined;
    offset?: number | undefined;
}, {
    where?: {
        field: string;
        operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any";
        value?: any;
    }[] | undefined;
    orderBy?: [string, "asc" | "desc"] | undefined;
    limit?: number | undefined;
    startAfter?: any;
    endBefore?: any;
    select?: any[] | undefined;
    offset?: number | undefined;
}>;
/**
 * Options for database transactions
 */
export interface TransactionOptions {
    /** Maximum number of retry attempts */
    maxAttempts?: number;
    /** Whether to allow writes in the transaction */
    readOnly?: boolean;
    /** Transaction timeout in milliseconds */
    timeout?: number;
}
/**
 * Schema for validating transaction options
 */
export declare const transactionOptionsSchema: z.ZodObject<{
    maxAttempts: z.ZodOptional<z.ZodNumber>;
    readOnly: z.ZodOptional<z.ZodBoolean>;
    timeout: z.ZodOptional<z.ZodNumber>;
}, "strict", z.ZodTypeAny, {
    maxAttempts?: number | undefined;
    readOnly?: boolean | undefined;
    timeout?: number | undefined;
}, {
    maxAttempts?: number | undefined;
    readOnly?: boolean | undefined;
    timeout?: number | undefined;
}>;
/**
 * Interface for database adapters
 * @template T - Default document type
 * @template TConfig - Type of the configuration object
 */
export interface DatabaseAdapter<T = unknown, TConfig = unknown> extends BaseAdapter<TConfig> {
    readonly type: AdapterType.DATABASE;
    /**
     * Creates a new document in the specified collection
     * @param collection - The name of the collection
     * @param data - The document data (without ID)
     * @returns A promise that resolves to the created document with ID
     * @throws {DatabaseError} If the operation fails
     */
    create(collection: string, data: Omit<T, 'id'>): Promise<T & {
        id: string;
    }>;
    /**
     * Finds multiple documents matching the query options
     * @param collection - The name of the collection
     * @param options - Query options for filtering, sorting, and pagination
     * @returns A promise that resolves to an array of matching documents
     * @throws {DatabaseError} If the operation fails
     */
    findMany(collection: string, options?: DatabaseAdapterQueryOptions<T>): Promise<T[]>;
    /**
     * Reads a document by ID
     * @param collection - The name of the collection
     * @param id - The document ID
     * @returns A promise that resolves to the document, or null if not found
     * @throws {DatabaseError} If the operation fails
     */
    read(collection: string, id: string): Promise<T | null>;
    /**
     * Updates a document
     * @param collection - The name of the collection
     * @param id - The document ID
     * @param data - The fields to update
     * @returns A promise that resolves to the updated document
     * @throws {DatabaseError} If the operation fails
     */
    update(collection: string, id: string, data: Partial<T>): Promise<T>;
    /**
     * Deletes a document
     * @param collection - The name of the collection
     * @param id - The document ID
     * @returns A promise that resolves when the operation completes
     * @throws {DatabaseError} If the operation fails
     */
    delete(collection: string, id: string): Promise<void>;
    /**
     * Finds documents matching the query options
     * @template TQuery - Type of the document being queried
     * @param collection - The name of the collection
     * @param options - Query options
     * @returns A promise that resolves to an array of matching documents
     * @throws {DatabaseError} If the operation fails
     */
    find<TQuery = T>(collection: string, options?: DatabaseAdapterQueryOptions<TQuery>): Promise<TQuery[]>;
    /**
     * Finds a single document by ID with optional query options
     * @template TQuery - Type of the document being queried
     * @param collection - The name of the collection
     * @param id - The document ID
     * @param options - Additional query options
     * @returns A promise that resolves to the document, or null if not found
     * @throws {DatabaseError} If the operation fails
     */
    findOne<TQuery = T>(collection: string, id: string, options?: Omit<DatabaseAdapterQueryOptions<TQuery>, 'limit' | 'offset'>): Promise<TQuery | null>;
    /**
     * Counts documents matching the query criteria
     * @template TQuery - Type of the document being queried
     * @param collection - The name of the collection
     * @param options - Query options
     * @returns A promise that resolves to the count of matching documents
     * @throws {DatabaseError} If the operation fails
     */
    count<TQuery = T>(collection: string, options?: Pick<DatabaseAdapterQueryOptions<TQuery>, 'where'>): Promise<number>;
    subscribe(collection: string, callback: (data: T[]) => void, options?: DatabaseAdapterQueryOptions<T>): () => void;
    transaction<U>(updateFunction: (transaction: any) => Promise<U>): Promise<U>;
}
//# sourceMappingURL=database.d.ts.map