1 | import Dexie from 'dexie';
|
2 | import { ICoordinator, ICoordinatorOptions, Repo, IModel, PluginType, IStorePlugin, IModelType, PluginEventType } from 'typestore';
|
3 |
|
4 |
|
5 |
|
6 | export interface IIndexedDBOptions {
|
7 | |
8 |
|
9 |
|
10 | databaseName?: string;
|
11 | provider?: {
|
12 | indexedDB: any;
|
13 | IDBKeyRange: any;
|
14 | };
|
15 | version?: number;
|
16 | }
|
17 |
|
18 |
|
19 |
|
20 | export declare const LocalStorageOptionDefaults: {
|
21 | databaseName: string;
|
22 | version: number;
|
23 | };
|
24 |
|
25 |
|
26 |
|
27 | export declare class IndexedDBPlugin implements IStorePlugin {
|
28 | private opts;
|
29 | type: PluginType;
|
30 | supportedModels: any[];
|
31 | private coordinator;
|
32 | private internalDb;
|
33 | private repoPlugins;
|
34 | private tables;
|
35 | constructor(opts?: IIndexedDBOptions, ...supportedModels: any[]);
|
36 | private newDexie();
|
37 | private open();
|
38 | readonly db: Dexie;
|
39 | handle(eventType: PluginEventType, ...args: any[]): boolean | any;
|
40 | table(modelType: IModelType): Dexie.Table<any, any>;
|
41 | init(coordinator: ICoordinator, opts: ICoordinatorOptions): Promise<ICoordinator>;
|
42 | start(): Promise<ICoordinator>;
|
43 | stop(): Promise<ICoordinator>;
|
44 | syncModels(): Promise<ICoordinator>;
|
45 | /**
|
46 | * Initialize a new repo
|
47 | * TODO: verify this logic works - just reading it makes me think we could be
|
48 | * asked to init a repo a second time with the same type and do nothing
|
49 | *
|
50 | * @param repo
|
51 | * @returns {T}
|
52 | */
|
53 | initRepo<T extends Repo<M>, M extends IModel>(repo: T): T;
|
54 | }
|