import { IDBCreator, IDBDatabaseLike } from './idb-types.js'; import '@firtoz/idb-collections'; interface CreateTableOperation { type: "createTable"; name: string; keyPath?: string; autoIncrement?: boolean; indexes?: Array<{ name: string; keyPath: string | string[]; unique?: boolean; }>; } interface DeleteTableOperation { type: "deleteTable"; name: string; } interface CreateIndexOperation { type: "createIndex"; tableName: string; indexName: string; keyPath: string | string[]; unique?: boolean; } interface DeleteIndexOperation { type: "deleteIndex"; tableName: string; indexName: string; } type MigrationOperation = CreateTableOperation | DeleteTableOperation | CreateIndexOperation | DeleteIndexOperation; /** A migration is an array of operations to perform */ type Migration = MigrationOperation[]; /** * Runs IndexedDB migrations using declarative migration arrays. * Version = total migrations + 1. * * Example usage: * ```typescript * const migrations: Migration[] = [ * [ * { type: "createTable", name: "todo", keyPath: "id", indexes: [ * { name: "todo_user_id", keyPath: "user_id" } * ]} * ], * [ * { type: "createTable", name: "user", keyPath: "id" } * ] * ]; * * const db = await migrateIndexedDBWithFunctions('my-db', migrations); * ``` */ declare function migrateIndexedDBWithFunctions(dbName: string, migrations: Migration[], debug?: boolean, dbCreator?: IDBCreator): Promise; export { type CreateIndexOperation, type CreateTableOperation, type DeleteIndexOperation, type DeleteTableOperation, type Migration, type MigrationOperation, migrateIndexedDBWithFunctions };