/** * Dexie proxy type */ export abstract class DexieLike { constructor(name: string) {} version(n: number) { return { stores(schema: object) {}, }; } } export type DexieIndexableTypePart = | string | number | Date | ArrayBuffer | ArrayBufferView | DataView | Array>; export type DexieIndexableTypeArray = Array; export type DexieIndexableTypeArrayReadonly = ReadonlyArray; export type DexieIndexableType = DexieIndexableTypePart | DexieIndexableTypeArrayReadonly; export interface DexiePromiseExtended extends Promise { then( onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null, ): DexiePromiseExtended; catch( onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null, ): DexiePromiseExtended; catch( ErrorConstructor: Function, onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null, ): DexiePromiseExtended; catch( errorName: string, onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null, ): DexiePromiseExtended; finally(onFinally?: () => U | PromiseLike): DexiePromiseExtended; timeout(ms: number, msg?: string): DexiePromiseExtended; } /** * Dexie Table like structure */ export interface DexieTableLike { toCollection(): { get primaryKeys(): { (): DexiePromiseExtended>; (thenShortcut: DexieThenShortcut, R>): DexiePromiseExtended; }; }; get(key: TKey): DexiePromiseExtended; bulkGet(keys: Array): DexiePromiseExtended>; put(item: T, key?: TKey): DexiePromiseExtended; bulkPut( items: readonly T[], keys?: DexieIndexableTypeArrayReadonly, options?: { allKeys: boolean; }, ): DexiePromiseExtended; clear(): DexiePromiseExtended; where(index: string | string[]): DexieWhereClause; toArray(): DexiePromiseExtended>; orderBy(index: string | string[]): DexieCollection; } export interface DexieCollection { first(): DexiePromiseExtended; or(indexOrPrimayKey: string): DexieWhereClause; toArray(): DexiePromiseExtended>; reverse(): DexieCollection; sortBy(keyPath: string): DexiePromiseExtended; limit(n: number): DexieCollection; delete(): DexiePromiseExtended; } export interface DexieWhereClause { startsWithIgnoreCase(key: string): DexieCollection; below(key: any): DexieCollection; between(lower: any, upper: any, includeLower?: boolean, includeUpper?: boolean): DexieCollection; } export type DexieThenShortcut = (value: T) => TResult | PromiseLike;