UNPKG

2.68 kBTypeScriptView Raw
1import { IRepoPlugin, IKeyValue, IModel, Repo, ICoordinator, ICoordinatorOptions, PluginEventType, IFinderPlugin, IModelMapper } from 'typestore';
2import { IndexedDBPlugin } from "./IndexedDBPlugin";
3import Dexie from "dexie";
4/**
5 * Super simple plain jain key for now
6 * what you send to the constructor comes out the
7 * other end
8 *
9 * just like poop!
10 */
11export declare class IndexedDBKeyValue implements IKeyValue {
12 args: any[];
13 indexedDBKey: boolean;
14 constructor(...args: any[]);
15}
16export declare class IndexedDBRepoPlugin<M extends IModel> implements IRepoPlugin<M>, IFinderPlugin {
17 private store;
18 repo: Repo<M>;
19 type: number;
20 supportedModels: any[];
21 private coordinator;
22 private keys;
23 /**
24 * Construct a new repo/store
25 * manager for a given repo/model
26 *
27 * @param store
28 * @param repo
29 */
30 constructor(store: IndexedDBPlugin, repo: Repo<M>);
31 /**
32 * Create a finder method with descriptor
33 * and signature
34 *
35 * @param repo
36 * @param finderKey
37 * @returns {any}
38 */
39 decorateFinder(repo: Repo<any>, finderKey: string): (...args: any[]) => Promise<M | M[]>;
40 /**
41 * Handle a plugin event
42 *
43 * @param eventType
44 * @param args
45 * @returns {boolean}
46 */
47 handle(eventType: PluginEventType, ...args: any[]): boolean | any;
48 /**
49 * Model mapper
50 *
51 * @returns {IModelMapper<M>}
52 */
53 readonly mapper: IModelMapper<M>;
54 /**
55 * Get dexie table
56 *
57 * @returns {Dexie.Table<any, any>}
58 */
59 readonly table: Dexie.Table<any, any>;
60 /**
61 * Get db ref
62 *
63 * @returns {Dexie}
64 */
65 readonly db: Dexie;
66 init(coordinator: ICoordinator, opts: ICoordinatorOptions): Promise<ICoordinator>;
67 start(): Promise<ICoordinator>;
68 stop(): Promise<ICoordinator>;
69 key(...args: any[]): IndexedDBKeyValue;
70 keyFromObject(o: any): IndexedDBKeyValue;
71 dbKeyFromKey(key: IndexedDBKeyValue): any;
72 get(key: IndexedDBKeyValue): Promise<M>;
73 save(model: M): Promise<M>;
74 /**
75 * Remove implementation
76 *
77 * @param key
78 * @returns {Promise<void>}
79 */
80 remove(key: IndexedDBKeyValue): Promise<any>;
81 count(): Promise<number>;
82 /**
83 * Bulk get
84 *
85 * @param keys
86 * @returns {any}
87 */
88 bulkGet(...keys: IndexedDBKeyValue[]): Promise<M[]>;
89 /**
90 * Bulk save/put
91 *
92 * @param models
93 * @returns {M[]}
94 */
95 bulkSave(...models: M[]): Promise<M[]>;
96 /**
97 * Bulk remove
98 *
99 * @param keys
100 * @returns {IndexedDBKeyValue[]}
101 */
102 bulkRemove(...keys: IndexedDBKeyValue[]): Promise<any[]>;
103}