import * as i0 from '@angular/core'; import { InjectionToken, ModuleWithProviders } from '@angular/core'; import { Observable } from 'rxjs'; interface DBConfig { name: string; version?: number; objectStoresMeta: ObjectStoreMeta[]; migrationFactory?: () => { [key: number]: (db: IDBDatabase, transaction: IDBTransaction) => void; }; isDefault?: boolean; } interface ObjectStoreMeta { store: string; storeConfig: { keyPath: string | string[]; autoIncrement: boolean; [key: string]: any; }; storeSchema: ObjectStoreSchema[]; } interface ObjectStoreSchema { name: string; keypath: string | string[]; options: { unique: boolean; [key: string]: any; }; } interface IndexDetails { indexName: string; order: string; } interface RequestEvent extends Event { target: RequestEventTarget; } interface RequestEventTarget extends EventTarget { result: T | T[]; } declare enum DBMode { readonly = "readonly", readwrite = "readwrite" } type WithID = { id: number; }; type IndexKey

= { readonly primaryKey: P; readonly key: K; }; type Modify = Omit & R; type NgxIDBCursor

= Modify; }>; type NgxIDBCursorWithValue = NgxIDBCursor & { value: V; }; declare const CONFIG_TOKEN: InjectionToken>; declare const INDEXED_DB: InjectionToken; /** * Token used to inject the indexed db implementation on the server */ declare const SERVER_INDEXED_DB: InjectionToken; declare class NgxIndexedDBModule { static forRoot(...dbConfigs: DBConfig[]): ModuleWithProviders; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } declare class NgxIndexedDBService { private dbConfigs; private indexedDB; private defaultDatabaseName?; private selectedDb; constructor(dbConfigs: Record, indexedDB: IDBFactory); private instanciateConfig; private get dbConfig(); /** * The function return the current version of database * * @Return the current version of database as number */ getDatabaseVersion(): Observable; /** * Selects a database for the current context. * @param {string} [databaseName=undefined] Database name to select. */ selectDb(databaseName?: string): void; /** * Allows to create a new object store ad-hoc * @param storeName The name of the store to be created * @param migrationFactory The migration factory if exists */ createObjectStore(storeSchema: ObjectStoreMeta, migrationFactory?: () => { [key: number]: (db: IDBDatabase, transaction: IDBTransaction) => void; }): Promise; /** * Create dynamic store if not already without incrementing version * For Dynamic store * @param storeName The name of the store to create */ createDynamicObjectStore(storeSchema: ObjectStoreMeta, migrationFactory?: () => { [key: number]: (db: IDBDatabase, transaction: IDBTransaction) => void; }): Promise; /** * Adds new entry in the store and returns its key * @param storeName The name of the store to add the item * @param value The entry to be added * @param key The optional key for the entry */ add(storeName: string, value: T, key?: any): Observable; /** * Adds new entries in the store and returns its key * @param storeName The name of the store to add the item * @param values The entries to be added containing optional key attribute */ bulkAdd(storeName: string, values: Array): Observable; /** * Delete entries in the store and returns current entries in the store * @param storeName The name of the store to add the item * @param keys The keys to be deleted */ bulkDelete(storeName: string, keys: IDBValidKey[]): Observable; /** * Returns entry by key. * @param storeName The name of the store to query * @param key The entry key */ getByKey(storeName: string, key: IDBValidKey): Observable; /** * Retrieve multiple entries in the store * @param storeName The name of the store to retrieve the items * @param keys The ids entries to be retrieve */ bulkGet(storeName: string, keys: Array): Observable; /** * Returns entry by id. * @param storeName The name of the store to query * @param id The entry id */ getByID(storeName: string, id: string | number): Observable; /** * Returns entry by index. * @param storeName The name of the store to query * @param indexName The index name to filter * @param key The entry key. */ getByIndex(storeName: string, indexName: string, key: IDBValidKey): Observable; /** * Return all elements from one store * @param storeName The name of the store to select the items */ getAll(storeName: string): Observable; /** * Adds or updates a record in store with the given value and key. Return all items present in the store * @param storeName The name of the store to update * @param value The new value for the entry */ update(storeName: string, value: T): Observable; /** * Adds or updates a record in store with the given value and key. Return all items present in the store * @param storeName The name of the store to update * @param items The values to update in the DB * * @Return The return value is an Observable with the primary key of the object that was last in given array * * @error If the call to bulkPut fails the transaction will be aborted and previously inserted entities will be deleted */ bulkPut(storeName: string, items: T[]): Observable; /** * Returns all items from the store after delete. * @param storeName The name of the store to have the entry deleted * @param query The key or key range criteria to apply */ delete(storeName: string, query: IDBValidKey | IDBKeyRange): Observable; /** * Returns after a successful delete. * @param storeName The name of the store to have the entry deleted * @param query The key or key range criteria to apply */ deleteByKey(storeName: string, query: IDBValidKey | IDBKeyRange): Observable; /** * Delete all items by an index. * @param storeName The name of the store to query * @param indexName The index name to filter * @param query The key or key range criteria to apply * @param direction A string telling the cursor which direction to travel. */ deleteAllByIndex(storeName: string, indexName: string, query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): Observable; /** * Clear the data in the objectStore. * @param storeName The name of the store to have the entries deleted */ clear(storeName: string): Observable; /** * Delete database. */ deleteDatabase(): Observable; /** * Returns the open cursor * If no matching data are present, the observable is completed immediately. * @param options The options to open the cursor * @param options.storeName The name of the store to have the entries deleted * @param options.query The key or key range criteria to apply * @param options.direction A string telling the cursor which direction to travel * @param options.mode The transaction mode. */ openCursor(options: { storeName: string; query?: IDBValidKey | IDBKeyRange | null; direction?: IDBCursorDirection; mode: DBMode; }): Observable>; /** * Open a cursor by index filter * If no matching data are present, the observable is completed immediately. * @param options The options to open the cursor * @param options.storeName The name of the store to query * @param options.indexName The index name to filter * @param options.query The key or key range criteria to apply * @param options.direction A string telling the cursor which direction to travel * @param options.mode The transaction mode. */ openCursorByIndex(options: { storeName: string; indexName: string; query?: IDBValidKey | IDBKeyRange | null; direction?: IDBCursorDirection; mode?: DBMode; }): Observable>; /** * Returns all items by an index. * @param storeName The name of the store to query * @param indexName The index name to filter * @param query The key or key range criteria to apply * @param direction A string telling the cursor which direction to travel. */ getAllByIndex(storeName: string, indexName: string, query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): Observable; /** * Returns all primary keys by an index. * @param storeName The name of the store to query * @param query The key or key range criteria to apply * @param direction A string telling the cursor which direction to travel. */ getAllKeysByIndex

(storeName: string, indexName: string, query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): Observable[]>; /** * Returns the number of rows in a store. * @param storeName The name of the store to query * @param query The key or key range criteria to apply. */ count(storeName: string, query?: IDBValidKey | IDBKeyRange): Observable; /** * Returns the number of records within a key range. * @param storeName The name of the store to query * @param indexName The index name to filter * @param query The key or key range criteria to apply. */ countByIndex(storeName: string, indexName: string, query?: IDBValidKey | IDBKeyRange): Observable; /** * Delete the store by name. * @param storeName The name of the store to query */ deleteObjectStore(storeName: string): Observable; /** * Get all object store names. */ getAllObjectStoreNames(): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare const provideIndexedDb: (...dbConfigs: DBConfig[]) => i0.EnvironmentProviders; export { CONFIG_TOKEN, DBMode, INDEXED_DB, NgxIndexedDBModule, NgxIndexedDBService, SERVER_INDEXED_DB, provideIndexedDb }; export type { DBConfig, IndexDetails, IndexKey, NgxIDBCursor, NgxIDBCursorWithValue, ObjectStoreMeta, ObjectStoreSchema, RequestEvent, RequestEventTarget, WithID };