diff --git a/src/interfaces/absurd-sql.d.ts b/src/interfaces/absurd-sql.d.ts index d2b1969d..e113fe75 100644 --- a/src/interfaces/absurd-sql.d.ts +++ b/src/interfaces/absurd-sql.d.ts @@ -1,4 +1,4 @@ -import type { QueryExecResult as DbQueryExecResult, SqlValue } from "@/interfaces/database"; +import type { QueryExecResult, SqlValue } from "./database"; declare module "@jlongster/sql.js" { interface SQL { @@ -13,25 +13,22 @@ declare module "@jlongster/sql.js" { } interface AbsurdSqlDatabase { - exec: (sql: string, params?: unknown[]) => Promise; + exec: (sql: string, params?: SqlValue[]) => Promise; run: ( sql: string, - params?: unknown[], + params?: SqlValue[], ) => Promise<{ changes: number; lastId?: number }>; } - interface QueryExecResult { - columns: string[]; - values: unknown[][]; - } - - export default function initSqlJs(options?: { + const initSqlJs: (options?: { locateFile?: (file: string) => string; - }): Promise; + }) => Promise; + + export default initSqlJs; } declare module "absurd-sql" { - import { SQL } from "@jlongster/sql.js"; + import type { SQL } from "@jlongster/sql.js"; export class SQLiteFS { constructor(fs: any, backend: any); @@ -44,7 +41,7 @@ declare module "absurd-sql/dist/indexeddb-backend" { } } -declare module 'absurd-sql/dist/indexeddb-main-thread' { +declare module "absurd-sql/dist/indexeddb-main-thread" { export interface SQLiteOptions { filename?: string; autoLoad?: boolean; @@ -52,7 +49,7 @@ declare module 'absurd-sql/dist/indexeddb-main-thread' { } export interface SQLiteDatabase { - exec: (sql: string, params?: any[]) => Promise; + exec: (sql: string, params?: SqlValue[]) => Promise; close: () => Promise; } diff --git a/src/types/absurd-sql.d.ts b/src/types/absurd-sql.d.ts deleted file mode 100644 index 0d0ce697..00000000 --- a/src/types/absurd-sql.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -import type { QueryExecResult as DbQueryExecResult, SqlValue } from "../database"; - -declare module "@jlongster/sql.js" { - interface SQL { - Database: new (path: string, options?: { filename: boolean }) => AbsurdSqlDatabase; - FS: { - mkdir: (path: string) => void; - mount: (fs: any, options: any, path: string) => void; - open: (path: string, flags: string) => any; - close: (stream: any) => void; - }; - register_for_idb: (fs: any) => void; - } - - interface AbsurdSqlDatabase { - exec: (sql: string, params?: unknown[]) => Promise; - run: ( - sql: string, - params?: unknown[], - ) => Promise<{ changes: number; lastId?: number }>; - } - - interface QueryExecResult { - columns: string[]; - values: unknown[][]; - } - - export default function initSqlJs(options?: { - locateFile?: (file: string) => string; - }): Promise; -} - -declare module "absurd-sql" { - import { SQL } from "@jlongster/sql.js"; - - export class SQLiteFS { - constructor(fs: any, backend: any); - } -} - -declare module "absurd-sql/dist/indexeddb-backend" { - export default class IndexedDBBackend { - constructor(); - } -} - -declare module 'absurd-sql/dist/indexeddb-main-thread' { - export interface SQLiteOptions { - filename?: string; - autoLoad?: boolean; - debug?: boolean; - } - - export interface SQLiteDatabase { - exec: (sql: string, params?: any[]) => Promise; - close: () => Promise; - } - - export function initSqlJs(options?: any): Promise; - export function createDatabase(options?: SQLiteOptions): Promise; - export function openDatabase(options?: SQLiteOptions): Promise; -} \ No newline at end of file