@fireproof/core 0.5.7 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/fireproof.d.ts +109 -104
- package/dist/src/fireproof.js +309 -235
- package/dist/src/fireproof.js.map +1 -1
- package/dist/src/fireproof.mjs +309 -235
- package/dist/src/fireproof.mjs.map +1 -1
- package/package.json +1 -1
- package/src/blockstore.js +4 -1
- package/src/clock.js +41 -9
- package/src/database.js +33 -12
- package/src/db-index.js +14 -3
- package/src/fireproof.js +2 -2
- package/src/prolly.js +82 -48
- package/src/sync.js +23 -12
- package/src/valet.js +1 -1
package/dist/src/fireproof.d.ts
CHANGED
@@ -1,101 +1,6 @@
|
|
1
1
|
import * as multiformats from 'multiformats';
|
2
2
|
import { CID } from 'multiformats';
|
3
3
|
|
4
|
-
/**
|
5
|
-
* Represents an DbIndex for a Fireproof database.
|
6
|
-
*
|
7
|
-
* @class DbIndex
|
8
|
-
* @classdesc An DbIndex can be used to order and filter the documents in a Fireproof database.
|
9
|
-
*
|
10
|
-
* @param {Database} database - The Fireproof database instance to DbIndex.
|
11
|
-
* @param {Function} mapFn - The map function to apply to each entry in the database.
|
12
|
-
*
|
13
|
-
*/
|
14
|
-
declare class DbIndex {
|
15
|
-
static registerWithDatabase(inIndex: any, database: any): void;
|
16
|
-
static fromJSON(database: any, { code, clock, name }: {
|
17
|
-
code: any;
|
18
|
-
clock: any;
|
19
|
-
name: any;
|
20
|
-
}): DbIndex;
|
21
|
-
constructor(database: any, name: any, mapFn: any, clock?: any, opts?: {});
|
22
|
-
database: any;
|
23
|
-
mapFnString: any;
|
24
|
-
mapFn: any;
|
25
|
-
name: any;
|
26
|
-
indexById: {
|
27
|
-
root: any;
|
28
|
-
cid: any;
|
29
|
-
};
|
30
|
-
indexByKey: {
|
31
|
-
root: any;
|
32
|
-
cid: any;
|
33
|
-
};
|
34
|
-
dbHead: any;
|
35
|
-
instanceId: string;
|
36
|
-
updateIndexPromise: Promise<any>;
|
37
|
-
makeName(): any;
|
38
|
-
toJSON(): {
|
39
|
-
name: any;
|
40
|
-
code: any;
|
41
|
-
clock: {
|
42
|
-
db: any;
|
43
|
-
byId: any;
|
44
|
-
byKey: any;
|
45
|
-
};
|
46
|
-
};
|
47
|
-
/**
|
48
|
-
* JSDoc for Query type.
|
49
|
-
* @typedef {Object} DbQuery
|
50
|
-
* @property {string[]} [range] - The range to query.
|
51
|
-
* @memberof DbIndex
|
52
|
-
*/
|
53
|
-
/**
|
54
|
-
* Query object can have {range}
|
55
|
-
* @param {DbQuery} query - the query range to use
|
56
|
-
* @returns {Promise<{proof: {}, rows: Array<{id: string, key: string, value: any}>}>}
|
57
|
-
* @memberof DbIndex
|
58
|
-
* @instance
|
59
|
-
*/
|
60
|
-
query(query?: {
|
61
|
-
/**
|
62
|
-
* - The range to query.
|
63
|
-
*/
|
64
|
-
range?: string[];
|
65
|
-
}, update?: boolean): Promise<{
|
66
|
-
proof: {};
|
67
|
-
rows: Array<{
|
68
|
-
id: string;
|
69
|
-
key: string;
|
70
|
-
value: any;
|
71
|
-
}>;
|
72
|
-
}>;
|
73
|
-
/**
|
74
|
-
* Update the DbIndex with the latest changes
|
75
|
-
* @private
|
76
|
-
* @returns {Promise<void>}
|
77
|
-
*/
|
78
|
-
private updateIndex;
|
79
|
-
innerUpdateIndex(inBlocks: any): Promise<any>;
|
80
|
-
}
|
81
|
-
/**
|
82
|
-
* JDoc for the result row type.
|
83
|
-
*/
|
84
|
-
type ChangeEvent = {
|
85
|
-
/**
|
86
|
-
* - The key of the document.
|
87
|
-
*/
|
88
|
-
key: string;
|
89
|
-
/**
|
90
|
-
* - The new value of the document.
|
91
|
-
*/
|
92
|
-
value: any;
|
93
|
-
/**
|
94
|
-
* - Is the row deleted?
|
95
|
-
*/
|
96
|
-
del?: boolean;
|
97
|
-
};
|
98
|
-
|
99
4
|
/**
|
100
5
|
* @class Fireproof
|
101
6
|
* @classdesc Fireproof stores data in IndexedDB and provides a Merkle clock.
|
@@ -111,12 +16,14 @@ type ChangeEvent = {
|
|
111
16
|
declare class Database$1 {
|
112
17
|
constructor(blocks: any, clock: any, config?: {});
|
113
18
|
listeners: Set<any>;
|
19
|
+
indexes: Map<any, any>;
|
20
|
+
rootCache: any;
|
21
|
+
eventsCache: Map<any, any>;
|
114
22
|
name: any;
|
115
23
|
instanceId: string;
|
116
24
|
blocks: any;
|
117
25
|
clock: any;
|
118
26
|
config: {};
|
119
|
-
indexes: Map<any, any>;
|
120
27
|
/**
|
121
28
|
* Renders the Fireproof instance as a JSON object.
|
122
29
|
* @returns {Object} - The JSON representation of the Fireproof instance. Includes clock heads for the database and its indexes.
|
@@ -265,16 +172,8 @@ declare class Database$1 {
|
|
265
172
|
result?: undefined;
|
266
173
|
}, unknown>;
|
267
174
|
visTree(): Promise<{
|
268
|
-
cids: any;
|
269
|
-
result: any; /**
|
270
|
-
// * Advances the clock to the specified event and updates the root CID
|
271
|
-
// * Will be used by replication
|
272
|
-
// */
|
273
|
-
vis?: undefined;
|
274
|
-
} | {
|
275
175
|
vis: string;
|
276
176
|
cids: any;
|
277
|
-
result?: undefined;
|
278
177
|
}>;
|
279
178
|
visClock(): Promise<{
|
280
179
|
vis: string;
|
@@ -292,6 +191,112 @@ declare class Database$1 {
|
|
292
191
|
setRemoteBlockReader(remoteBlockReaderFn: any): void;
|
293
192
|
}
|
294
193
|
|
194
|
+
/**
|
195
|
+
* Represents an DbIndex for a Fireproof database.
|
196
|
+
*
|
197
|
+
* @class DbIndex
|
198
|
+
* @classdesc An DbIndex can be used to order and filter the documents in a Fireproof database.
|
199
|
+
*
|
200
|
+
* @param {Database} database - The Fireproof database instance to DbIndex.
|
201
|
+
* @param {Function} mapFn - The map function to apply to each entry in the database.
|
202
|
+
*
|
203
|
+
*/
|
204
|
+
declare class DbIndex {
|
205
|
+
static registerWithDatabase(inIndex: any, database: any): void;
|
206
|
+
static fromJSON(database: any, { code, clock, name }: {
|
207
|
+
code: any;
|
208
|
+
clock: any;
|
209
|
+
name: any;
|
210
|
+
}): DbIndex;
|
211
|
+
/**
|
212
|
+
* @param {Database} database
|
213
|
+
*/
|
214
|
+
constructor(database: Database$1, name: any, mapFn: any, clock?: any, opts?: {});
|
215
|
+
database: Database$1;
|
216
|
+
mapFnString: any;
|
217
|
+
mapFn: any;
|
218
|
+
name: any;
|
219
|
+
indexById: {
|
220
|
+
root: any;
|
221
|
+
cid: any;
|
222
|
+
};
|
223
|
+
indexByKey: {
|
224
|
+
root: any;
|
225
|
+
cid: any;
|
226
|
+
};
|
227
|
+
dbHead: any;
|
228
|
+
instanceId: string;
|
229
|
+
updateIndexPromise: Promise<any>;
|
230
|
+
makeName(): any;
|
231
|
+
toJSON(): {
|
232
|
+
name: any;
|
233
|
+
code: any;
|
234
|
+
clock: {
|
235
|
+
db: any;
|
236
|
+
byId: any;
|
237
|
+
byKey: any;
|
238
|
+
};
|
239
|
+
};
|
240
|
+
visKeyTree(): Promise<{
|
241
|
+
vis: string;
|
242
|
+
cids: any;
|
243
|
+
}>;
|
244
|
+
visIdTree(): Promise<{
|
245
|
+
vis: string;
|
246
|
+
cids: any;
|
247
|
+
}>;
|
248
|
+
/**
|
249
|
+
* JSDoc for Query type.
|
250
|
+
* @typedef {Object} DbQuery
|
251
|
+
* @property {string[]} [range] - The range to query.
|
252
|
+
* @memberof DbIndex
|
253
|
+
*/
|
254
|
+
/**
|
255
|
+
* Query object can have {range}
|
256
|
+
* @param {DbQuery} query - the query range to use
|
257
|
+
* @returns {Promise<{proof: {}, rows: Array<{id: string, key: string, value: any}>}>}
|
258
|
+
* @memberof DbIndex
|
259
|
+
* @instance
|
260
|
+
*/
|
261
|
+
query(query?: {
|
262
|
+
/**
|
263
|
+
* - The range to query.
|
264
|
+
*/
|
265
|
+
range?: string[];
|
266
|
+
}, update?: boolean): Promise<{
|
267
|
+
proof: {};
|
268
|
+
rows: Array<{
|
269
|
+
id: string;
|
270
|
+
key: string;
|
271
|
+
value: any;
|
272
|
+
}>;
|
273
|
+
}>;
|
274
|
+
/**
|
275
|
+
* Update the DbIndex with the latest changes
|
276
|
+
* @private
|
277
|
+
* @returns {Promise<void>}
|
278
|
+
*/
|
279
|
+
private updateIndex;
|
280
|
+
innerUpdateIndex(inBlocks: any): Promise<any>;
|
281
|
+
}
|
282
|
+
/**
|
283
|
+
* JDoc for the result row type.
|
284
|
+
*/
|
285
|
+
type ChangeEvent = {
|
286
|
+
/**
|
287
|
+
* - The key of the document.
|
288
|
+
*/
|
289
|
+
key: string;
|
290
|
+
/**
|
291
|
+
* - The new value of the document.
|
292
|
+
*/
|
293
|
+
value: any;
|
294
|
+
/**
|
295
|
+
* - Is the row deleted?
|
296
|
+
*/
|
297
|
+
del?: boolean;
|
298
|
+
};
|
299
|
+
|
295
300
|
/**
|
296
301
|
* A Fireproof database Listener allows you to react to events in the database.
|
297
302
|
*
|