import type { KyselyPlugin } from "kysely"; import { type IGenericSqlite, type OnCreateConnection, type Promisable, parseBigInt, buildQueryFn, GenericSqliteDialect, } from "kysely-generic-sqlite"; import { SqliteConnection } from "./SqliteConnection"; import type { Features } from "../Connection"; export type GenericSqliteConnectionConfig = { name: string; additionalPlugins?: KyselyPlugin[]; excludeTables?: string[]; onCreateConnection?: OnCreateConnection; supports?: Partial; }; export { parseBigInt, buildQueryFn, GenericSqliteDialect, type IGenericSqlite }; export class GenericSqliteConnection extends SqliteConnection { override name = "generic-sqlite"; constructor( db: DB, executor: () => Promisable, config?: GenericSqliteConnectionConfig, ) { super({ dialect: GenericSqliteDialect, dialectArgs: [executor, config?.onCreateConnection], additionalPlugins: config?.additionalPlugins, excludeTables: config?.excludeTables, }); this.client = db; if (config?.name) { this.name = config.name; } if (config?.supports) { for (const [key, value] of Object.entries(config.supports)) { if (value) { this.supported[key] = value; } } } } }