import { Awaitable } from '@midway3-components/core'; import { SQL, SQLWrapper, DrizzleConfig as _DrizzleConfig } from 'drizzle-orm'; import * as op from 'drizzle-orm/sql/expressions/conditions'; import { MySQL2DataSourceOptions, PostgresDataSourceOptions, ProtocolType, SQLiteDataSourceOptions } from './dialects'; import { Query } from './query'; import { DrizzleColumn, RowOf, Schema, SelectedFields, SelectedResult, Table } from './types'; export { op }; export type Operations = typeof op; export type DrizzleConfig = _DrizzleConfig; export type DrizzleDataSourceOptions = SQLiteDataSourceOptions | MySQL2DataSourceOptions | PostgresDataSourceOptions | (DrizzleConfig & { connection?: `${ProtocolType}://${string}`; }); export interface Executable extends SQLWrapper { execute(): T | Promise; } export interface ConditionalExecutable extends Executable { where(where?: SQL): Omit; } export type QueryResultOf = T extends Query ? P extends object ? P : never : never; export interface SelectBuilder { from(from: TTable | SQLWrapper): Query : RowOf>; } export interface InsertBuilder { values(values: Partial>): Executable; } export interface UpdateBuilder { set(values: Partial>): ConditionalExecutable; } export type DeleteCommand = ConditionalExecutable; export interface Drizzle { readonly $client: { end?(): unknown; close?(): unknown; connect?(): unknown; }; select(): SelectBuilder; select(fields: T): SelectBuilder; insert(table: T): InsertBuilder; update(table: T): UpdateBuilder; delete(table: T): DeleteCommand; transaction(transaction: (tx: Drizzle) => Awaitable, config?: any): Promise; } export type DrizzleQueryResult = [ rows: Record[], columns: T[] ]; //# sourceMappingURL=drizzle.d.ts.map