/**
 * Typed database mock factory for testing.
 *
 * Provides type-safe mocks for Drizzle database operations used throughout the codebase.
 * Replaces the need for `as any` casts when setting up database spies.
 *
 * @example
 * ```typescript
 * import { createMockDbOperations, setupDbSpies } from '@levelcode/common/testing/mocks/database'
 *
 * // Option 1: Create mock operations object
 * const dbOps = createMockDbOperations()
 *
 * // Option 2: Setup spies on actual db module
 * const spies = setupDbSpies(db)
 * await runTest()
 * spies.restore()
 * ```
 */
import { spyOn } from 'bun:test';
import type { Mock } from 'bun:test';
/**
 * Type for the chainable insert result.
 */
export interface MockInsertResult<T = unknown> {
    values: Mock<(data: T | T[]) => Promise<{
        id: string;
    }>>;
    returning: Mock<() => Promise<T[]>>;
    onConflictDoNothing: Mock<() => MockInsertResult<T>>;
    onConflictDoUpdate: Mock<(config: {
        target: unknown;
        set: unknown;
    }) => MockInsertResult<T>>;
}
/**
 * Type for the chainable update result.
 */
export interface MockUpdateResult<T = unknown> {
    set: Mock<(data: Partial<T>) => MockUpdateSetResult>;
}
/**
 * Type for the update.set result.
 */
export interface MockUpdateSetResult {
    where: Mock<(condition: unknown) => Promise<void>>;
    returning: Mock<() => Promise<unknown[]>>;
}
/**
 * Type for the chainable select result.
 */
export interface MockSelectResult<T = unknown> {
    from: Mock<(table: unknown) => MockSelectFromResult<T>>;
}
/**
 * Type for the select.from result.
 */
export interface MockSelectFromResult<T = unknown> {
    where: Mock<(condition: unknown) => MockSelectWhereResult<T>>;
    leftJoin: Mock<(table: unknown, condition: unknown) => MockSelectFromResult<T>>;
    innerJoin: Mock<(table: unknown, condition: unknown) => MockSelectFromResult<T>>;
    orderBy: Mock<(...columns: unknown[]) => MockSelectFromResult<T>>;
    limit: Mock<(n: number) => MockSelectFromResult<T>>;
    offset: Mock<(n: number) => MockSelectFromResult<T>>;
    then: Mock<(resolve: (value: T[]) => void) => Promise<T[]>>;
}
/**
 * Type for the select.from.where result.
 */
export interface MockSelectWhereResult<T = unknown> {
    then: Mock<(resolve: (value: T[]) => void) => Promise<T[]>>;
    leftJoin: Mock<(table: unknown, condition: unknown) => MockSelectWhereResult<T>>;
    innerJoin: Mock<(table: unknown, condition: unknown) => MockSelectWhereResult<T>>;
    orderBy: Mock<(...columns: unknown[]) => MockSelectWhereResult<T>>;
    limit: Mock<(n: number) => MockSelectWhereResult<T>>;
    offset: Mock<(n: number) => MockSelectWhereResult<T>>;
}
/**
 * Type for the chainable delete result.
 */
export interface MockDeleteResult {
    where: Mock<(condition: unknown) => Promise<void>>;
}
/**
 * Interface for the complete mock database operations.
 */
export interface MockDbOperations {
    insert: Mock<(table: unknown) => MockInsertResult>;
    update: Mock<(table: unknown) => MockUpdateResult>;
    select: Mock<(columns?: unknown) => MockSelectResult>;
    delete: Mock<(table: unknown) => MockDeleteResult>;
    transaction: Mock<(<T>(fn: (tx: MockDbOperations) => Promise<T>) => Promise<T>)>;
}
/**
 * Options for creating mock database operations.
 */
export interface CreateMockDbOptions {
    /**
     * Default data to return from select queries.
     */
    defaultSelectData?: unknown[];
    /**
     * Default ID to return from insert operations.
     */
    defaultInsertId?: string;
}
/**
 * Creates type-safe mock database operations for testing.
 *
 * @param options - Configuration options for the mock
 * @returns A mock database operations object
 *
 * @example
 * ```typescript
 * const dbOps = createMockDbOperations({
 *   defaultSelectData: [{ id: '1', name: 'Test' }],
 *   defaultInsertId: 'new-id',
 * })
 *
 * // The mocks are chainable just like real Drizzle
 * await dbOps.insert(users).values({ name: 'Test' })
 * await dbOps.select().from(users).where(eq(users.id, '1'))
 * ```
 */
export declare function createMockDbOperations(options?: CreateMockDbOptions): MockDbOperations;
/**
 * Result of setting up database spies.
 */
export interface DbSpies {
    /** Spy on insert operations */
    insert: ReturnType<typeof spyOn>;
    /** Spy on update operations */
    update: ReturnType<typeof spyOn>;
    /** Restore all spies */
    restore: () => void;
    /** Clear all spy call history */
    clear: () => void;
}
/**
 * Sets up spies on a database module for insert and update operations.
 * This is the most common pattern used in tests.
 *
 * @param db - The database module to spy on
 * @param options - Configuration options
 * @returns Object containing the spies and cleanup utilities
 *
 * @example
 * ```typescript
 * import db from '@levelcode/internal/db'
 *
 * describe('my test', () => {
 *   let dbSpies: DbSpies
 *
 *   beforeEach(() => {
 *     dbSpies = setupDbSpies(db)
 *   })
 *
 *   afterEach(() => {
 *     dbSpies.restore()
 *   })
 *
 *   it('inserts data', async () => {
 *     await createUser({ name: 'Test' })
 *     expect(dbSpies.insert).toHaveBeenCalled()
 *   })
 * })
 * ```
 */
/**
 * Sets up spies on a database module for insert and update operations.
 * Accepts any object with insert and update methods.
 */
export declare function setupDbSpies(db: {
    insert: unknown;
    update: unknown;
}, options?: CreateMockDbOptions): DbSpies;
/**
 * Creates a mock for a database query builder chain that returns specific data.
 *
 * @param data - The data to return from the query
 * @returns A thenable mock that resolves to the data
 *
 * @example
 * ```typescript
 * const mockQuery = createMockQueryResult([
 *   { id: '1', name: 'User 1' },
 *   { id: '2', name: 'User 2' },
 * ])
 *
 * spyOn(userService, 'findAll').mockReturnValue(mockQuery)
 * ```
 */
export declare function createMockQueryResult<T>(data: T[]): Promise<T[]> & {
    where: Mock<() => Promise<T[]>>;
    orderBy: Mock<() => Promise<T[]>>;
    limit: Mock<() => Promise<T[]>>;
};
