6 changed files with 152 additions and 3 deletions
			
			
		@ -0,0 +1,45 @@ | 
				
			|||||
 | 
					declare module 'absurd-sql/dist/indexeddb-backend' { | 
				
			||||
 | 
					  export default class IndexedDBBackend { | 
				
			||||
 | 
					    constructor(options?: { | 
				
			||||
 | 
					      dbName?: string; | 
				
			||||
 | 
					      storeName?: string; | 
				
			||||
 | 
					      onReady?: () => void; | 
				
			||||
 | 
					      onError?: (error: Error) => void; | 
				
			||||
 | 
					    }); | 
				
			||||
 | 
					    init(): Promise<void>; | 
				
			||||
 | 
					    exec(sql: string, params?: any[]): Promise<any>; | 
				
			||||
 | 
					    close(): Promise<void>; | 
				
			||||
 | 
					  } | 
				
			||||
 | 
					} | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					declare module 'absurd-sql/dist/indexeddb-main-thread' { | 
				
			||||
 | 
					  export function initBackend(worker: Worker): Promise<void>; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					  export default class IndexedDBMainThread { | 
				
			||||
 | 
					    constructor(options?: { | 
				
			||||
 | 
					      dbName?: string; | 
				
			||||
 | 
					      storeName?: string; | 
				
			||||
 | 
					      onReady?: () => void; | 
				
			||||
 | 
					      onError?: (error: Error) => void; | 
				
			||||
 | 
					    }); | 
				
			||||
 | 
					    init(): Promise<void>; | 
				
			||||
 | 
					    exec(sql: string, params?: any[]): Promise<any>; | 
				
			||||
 | 
					    close(): Promise<void>; | 
				
			||||
 | 
					  } | 
				
			||||
 | 
					} | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					declare module 'absurd-sql' { | 
				
			||||
 | 
					  export class SQLiteFS { | 
				
			||||
 | 
					    constructor(fs: unknown, backend: IndexedDBBackend); | 
				
			||||
 | 
					    init(): Promise<void>; | 
				
			||||
 | 
					    close(): Promise<void>; | 
				
			||||
 | 
					    exec(sql: string, params?: any[]): Promise<any>; | 
				
			||||
 | 
					    prepare(sql: string): Promise<any>; | 
				
			||||
 | 
					    run(sql: string, params?: any[]): Promise<any>; | 
				
			||||
 | 
					    get(sql: string, params?: any[]): Promise<any>; | 
				
			||||
 | 
					    all(sql: string, params?: any[]): Promise<any[]>; | 
				
			||||
 | 
					  } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					  export * from 'absurd-sql/dist/indexeddb-backend'; | 
				
			||||
 | 
					  export * from 'absurd-sql/dist/indexeddb-main-thread'; | 
				
			||||
 | 
					}  | 
				
			||||
@ -0,0 +1,36 @@ | 
				
			|||||
 | 
					import type { QueryExecResult, SqlValue } from "./database"; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					declare module '@jlongster/sql.js' { | 
				
			||||
 | 
					  interface SQL { | 
				
			||||
 | 
					    Database: new (path: string, options?: { filename: boolean }) => Database; | 
				
			||||
 | 
					    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 Database { | 
				
			||||
 | 
					    exec: (sql: string, params?: unknown[]) => Promise<QueryExecResult[]>; | 
				
			||||
 | 
					    run: (sql: string, params?: unknown[]) => Promise<{ changes: number; lastId?: number }>; | 
				
			||||
 | 
					    get: (sql: string, params?: unknown[]) => Promise<SqlValue[]>; | 
				
			||||
 | 
					    all: (sql: string, params?: unknown[]) => Promise<SqlValue[][]>; | 
				
			||||
 | 
					    prepare: (sql: string) => Promise<Statement>; | 
				
			||||
 | 
					    close: () => void; | 
				
			||||
 | 
					  } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					  interface Statement { | 
				
			||||
 | 
					    run: (params?: unknown[]) => Promise<{ changes: number; lastId?: number }>; | 
				
			||||
 | 
					    get: (params?: unknown[]) => Promise<SqlValue[]>; | 
				
			||||
 | 
					    all: (params?: unknown[]) => Promise<SqlValue[][]>; | 
				
			||||
 | 
					    finalize: () => void; | 
				
			||||
 | 
					  } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					  const initSqlJs: (options?: { | 
				
			||||
 | 
					    locateFile?: (file: string) => string; | 
				
			||||
 | 
					  }) => Promise<SQL>; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					  export default initSqlJs; | 
				
			||||
 | 
					}  | 
				
			||||
@ -0,0 +1,67 @@ | 
				
			|||||
 | 
					import type { QueryExecResult, SqlValue } from "./database"; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					declare module '@jlongster/sql.js' { | 
				
			||||
 | 
					  interface SQL { | 
				
			||||
 | 
					    Database: new (path: string, options?: { filename: boolean }) => Database; | 
				
			||||
 | 
					    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 Database { | 
				
			||||
 | 
					    exec: (sql: string, params?: unknown[]) => Promise<QueryExecResult[]>; | 
				
			||||
 | 
					    run: (sql: string, params?: unknown[]) => Promise<{ changes: number; lastId?: number }>; | 
				
			||||
 | 
					    get: (sql: string, params?: unknown[]) => Promise<SqlValue[]>; | 
				
			||||
 | 
					    all: (sql: string, params?: unknown[]) => Promise<SqlValue[][]>; | 
				
			||||
 | 
					    prepare: (sql: string) => Promise<Statement>; | 
				
			||||
 | 
					    close: () => void; | 
				
			||||
 | 
					  } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					  interface Statement { | 
				
			||||
 | 
					    run: (params?: unknown[]) => Promise<{ changes: number; lastId?: number }>; | 
				
			||||
 | 
					    get: (params?: unknown[]) => Promise<SqlValue[]>; | 
				
			||||
 | 
					    all: (params?: unknown[]) => Promise<SqlValue[][]>; | 
				
			||||
 | 
					    finalize: () => void; | 
				
			||||
 | 
					  } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					  const initSqlJs: (options?: { | 
				
			||||
 | 
					    locateFile?: (file: string) => string; | 
				
			||||
 | 
					  }) => Promise<SQL>; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					  export default initSqlJs; | 
				
			||||
 | 
					} | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					declare module 'absurd-sql' { | 
				
			||||
 | 
					  import type { 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' { | 
				
			||||
 | 
					  import type { QueryExecResult } from './database'; | 
				
			||||
 | 
					  export interface SQLiteOptions { | 
				
			||||
 | 
					    filename?: string; | 
				
			||||
 | 
					    autoLoad?: boolean; | 
				
			||||
 | 
					    debug?: boolean; | 
				
			||||
 | 
					  } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					  export interface SQLiteDatabase { | 
				
			||||
 | 
					    exec: (sql: string, params?: unknown[]) => Promise<QueryExecResult[]>; | 
				
			||||
 | 
					    close: () => Promise<void>; | 
				
			||||
 | 
					  } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					  export function initSqlJs(options?: any): Promise<any>; | 
				
			||||
 | 
					  export function createDatabase(options?: SQLiteOptions): Promise<SQLiteDatabase>; | 
				
			||||
 | 
					  export function openDatabase(options?: SQLiteOptions): Promise<SQLiteDatabase>; | 
				
			||||
 | 
					}  | 
				
			||||
					Loading…
					
					
				
		Reference in new issue