import { SQLiteAsyncDatabase } from "./db.cjs";
import { entityKind } from "../../entity.cjs";
import { Query, SQL } from "../../sql/sql.cjs";
import { Logger } from "../../logger.cjs";
import { QueryPromise } from "../../query-promise.cjs";
import { MigrationConfig, MigrationMeta, MigratorInitFailResponse } from "../../migrator.cjs";
import { AnyRelations, EmptyRelations } from "../../relations.cjs";
import { WithCacheConfig } from "../../cache/core/types.cjs";
import { Cache } from "../../cache/core/cache.cjs";
import { SQLiteDialect } from "../dialect.cjs";
import { PreparedQueryConfig, SQLiteExecuteMethod, SQLitePreparedQuery, SQLiteSession, SQLiteTransactionConfig } from "../session.cjs";

//#region src/sqlite-core/async/session.d.ts
interface SQLiteAsyncPreparedQueryConfig extends PreparedQueryConfig {
  type: 'sync' | 'async';
}
type ExecuteResult<TType extends 'sync' | 'async', TResult> = TType extends 'async' ? Promise<TResult> : ExecuteResultSync<TResult>;
declare class ExecuteResultSync<T> extends QueryPromise<T> {
  private resultCb;
  static readonly [entityKind]: string;
  constructor(resultCb: () => T);
  execute(): Promise<T>;
  sync(): T;
}
type SQLiteQueryExecutors<TType extends 'sync' | 'async'> = Record<SQLiteExecuteMethod, (params: unknown[]) => Result<TType, any>>;
type Result<TKind extends 'sync' | 'async', TResult> = TKind extends 'async' ? Promise<TResult> : TResult;
declare class SQLiteAsyncPreparedQuery<T extends SQLiteAsyncPreparedQueryConfig> extends SQLitePreparedQuery {
  private resultKind;
  protected executors: SQLiteQueryExecutors<T['type']>;
  protected logger: Logger;
  protected cache: Cache | undefined;
  protected queryMetadata: {
    type: 'select' | 'update' | 'delete' | 'insert';
    tables: string[];
  } | undefined;
  protected cacheConfig: WithCacheConfig | undefined;
  static readonly [entityKind]: string;
  private fastPath;
  constructor(resultKind: 'sync' | 'async', executeMethod: SQLiteExecuteMethod | undefined, executors: SQLiteQueryExecutors<T['type']>, query: Query, mapper: ((rows: any[]) => any) | undefined, mode: 'arrays' | 'objects' | 'raw', logger: Logger, cache: Cache | undefined, queryMetadata: {
    type: 'select' | 'update' | 'delete' | 'insert';
    tables: string[];
  } | undefined, cacheConfig: WithCacheConfig | undefined);
  run(placeholderValues?: Record<string, unknown>): Result<T['type'], T['run']>;
  all(placeholderValues?: Record<string, unknown>): Result<T['type'], T['all']>;
  get(placeholderValues?: Record<string, unknown>): Result<T['type'], T['get']>;
  values(placeholderValues?: Record<string, unknown>): Result<T['type'], T['values']>;
  execute(placeholderValues?: Record<string, unknown>): ExecuteResult<T['type'], T['execute']>;
}
declare abstract class SQLiteAsyncSession<TResultKind extends 'sync' | 'async', TRunResult, TRelations extends AnyRelations = EmptyRelations> extends SQLiteSession<TRunResult, TRelations> {
  protected resultKind: TResultKind;
  static readonly [entityKind]: string;
  readonly dialect: SQLiteDialect;
  constructor(dialect: SQLiteDialect, resultKind: TResultKind);
  abstract prepareQuery(query: Query, mode: 'arrays' | 'objects' | 'raw', prepare: boolean, executeMethod?: SQLiteExecuteMethod, mapper?: (rows: any[]) => any, queryMetadata?: {
    type: 'select' | 'update' | 'delete' | 'insert';
    tables: string[];
  }, cacheConfig?: WithCacheConfig): SQLiteAsyncPreparedQuery<SQLiteAsyncPreparedQueryConfig & {
    type: TResultKind;
  }>;
  abstract transaction<T>(transaction: (tx: SQLiteAsyncTransaction<TResultKind, TRunResult, TRelations>) => Result<TResultKind, T>, config?: SQLiteTransactionConfig): Result<TResultKind, T>;
  run(query: SQL): Result<TResultKind, TRunResult>;
  objects<T = unknown>(query: SQL): Result<TResultKind, T[]>;
  object<T = unknown>(query: SQL): Result<TResultKind, T>;
  arrays<T extends any[] = unknown[]>(query: SQL): Result<TResultKind, T[]>;
  array<T extends any[] = unknown[]>(query: SQL): Result<TResultKind, T>;
}
declare abstract class SQLiteAsyncTransaction<TResultType extends 'sync' | 'async', TRunResult, TRelations extends AnyRelations = EmptyRelations> extends SQLiteAsyncDatabase<TResultType, TRunResult, TRelations> {
  protected readonly nestedIndex: number;
  static readonly [entityKind]: string;
  constructor(resultType: TResultType, dialect: SQLiteDialect, session: SQLiteAsyncSession<TResultType, TRunResult, TRelations>, relations: TRelations, nestedIndex?: number, forbidJsonb?: boolean);
  rollback(): never;
}
declare function migrateSync(migrations: MigrationMeta[], session: SQLiteAsyncSession<'sync', unknown, AnyRelations>, config?: string | Omit<MigrationConfig, 'migrationsFolder'>): void | MigratorInitFailResponse;
declare function migrateAsync(migrations: MigrationMeta[], db: SQLiteAsyncDatabase<'async', unknown, AnyRelations>, config?: string | Omit<MigrationConfig, 'migrationsFolder'>): Promise<void | MigratorInitFailResponse>;
//#endregion
export { ExecuteResult, ExecuteResultSync, Result, SQLiteAsyncPreparedQuery, SQLiteAsyncPreparedQueryConfig, SQLiteAsyncSession, SQLiteAsyncTransaction, SQLiteQueryExecutors, migrateAsync, migrateSync };
//# sourceMappingURL=session.d.cts.map