@fireproof/core 0.17.1 → 0.17.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -2
- package/dist/browser/fireproof.cjs +3 -4
- package/dist/browser/fireproof.cjs.map +1 -1
- package/dist/browser/fireproof.d.cts +21 -24
- package/dist/browser/fireproof.d.ts +21 -24
- package/dist/browser/fireproof.global.js +15 -17
- package/dist/browser/fireproof.global.js.map +1 -1
- package/dist/browser/fireproof.js +3 -4
- package/dist/browser/fireproof.js.map +1 -1
- package/dist/browser/metafile-cjs.json +1 -1
- package/dist/browser/metafile-esm.json +1 -1
- package/dist/browser/metafile-iife.json +1 -1
- package/dist/memory/fireproof.cjs +3 -4
- package/dist/memory/fireproof.cjs.map +1 -1
- package/dist/memory/fireproof.d.cts +21 -24
- package/dist/memory/fireproof.d.ts +21 -24
- package/dist/memory/fireproof.global.js +15 -17
- package/dist/memory/fireproof.global.js.map +1 -1
- package/dist/memory/fireproof.js +3 -4
- package/dist/memory/fireproof.js.map +1 -1
- package/dist/memory/metafile-cjs.json +1 -1
- package/dist/memory/metafile-esm.json +1 -1
- package/dist/memory/metafile-iife.json +1 -1
- package/dist/node/fireproof.cjs +3 -4
- package/dist/node/fireproof.cjs.map +1 -1
- package/dist/node/fireproof.d.cts +21 -24
- package/dist/node/fireproof.d.ts +21 -24
- package/dist/node/fireproof.global.js +15 -17
- package/dist/node/fireproof.global.js.map +1 -1
- package/dist/node/fireproof.js +3 -4
- package/dist/node/fireproof.js.map +1 -1
- package/dist/node/metafile-cjs.json +1 -1
- package/dist/node/metafile-esm.json +1 -1
- package/dist/node/metafile-iife.json +1 -1
- package/package.json +3 -3
package/dist/node/fireproof.d.ts
CHANGED
@@ -17,13 +17,16 @@ type ClockHead = ClockLink[];
|
|
17
17
|
type DocFragment = Uint8Array | string | number | boolean | null | AnyLink | DocFragment[] | {
|
18
18
|
[key: string]: DocFragment;
|
19
19
|
};
|
20
|
-
type DocRecord =
|
21
|
-
|
20
|
+
type DocRecord<T> = {
|
21
|
+
[K in keyof T]: DocFragment;
|
22
|
+
};
|
23
|
+
type DocFiles = Record<string, DocFileMeta | File>;
|
22
24
|
type DocBase = {
|
23
25
|
_id?: string;
|
24
26
|
_files?: DocFiles;
|
25
27
|
_publicFiles?: DocFiles;
|
26
28
|
};
|
29
|
+
type Doc<T extends DocRecord<T> = {}> = DocBase & T;
|
27
30
|
type DocFileMeta = {
|
28
31
|
type: string;
|
29
32
|
size: number;
|
@@ -32,12 +35,6 @@ type DocFileMeta = {
|
|
32
35
|
url?: string;
|
33
36
|
file?: () => Promise<File>;
|
34
37
|
};
|
35
|
-
type DocFiles = Record<string, DocFileMeta | File>;
|
36
|
-
type DocBody<T extends DocRecord = {}> = {
|
37
|
-
_id?: string;
|
38
|
-
} & {
|
39
|
-
[K in Exclude<keyof T, keyof DocBase>]: DocFragment;
|
40
|
-
} & T;
|
41
38
|
type DocUpdate = {
|
42
39
|
key: string;
|
43
40
|
value?: Record<string, any>;
|
@@ -54,7 +51,7 @@ type IndexUpdate = {
|
|
54
51
|
value?: DocFragment;
|
55
52
|
del?: boolean;
|
56
53
|
};
|
57
|
-
type IndexRow<T extends DocRecord = {}> = {
|
54
|
+
type IndexRow<T extends DocRecord<T> = {}> = {
|
58
55
|
id: string;
|
59
56
|
key: IndexKey;
|
60
57
|
row?: DocFragment;
|
@@ -95,12 +92,12 @@ type AnyDecodedBlock = {
|
|
95
92
|
value: any;
|
96
93
|
};
|
97
94
|
type EmitFn = (k: DocFragment, v?: DocFragment) => void;
|
98
|
-
type MapFn = <T extends DocRecord = {}>(doc: Doc<T>, emit: EmitFn) => DocFragment | void;
|
95
|
+
type MapFn = <T extends DocRecord<T> = {}>(doc: Doc<T>, emit: EmitFn) => DocFragment | void;
|
99
96
|
type ChangesOptions = {
|
100
97
|
dirty?: boolean;
|
101
98
|
limit?: number;
|
102
99
|
};
|
103
|
-
type ChangesResponse<T extends DocRecord = {}> = {
|
100
|
+
type ChangesResponse<T extends DocRecord<T> = {}> = {
|
104
101
|
clock: ClockHead;
|
105
102
|
rows: {
|
106
103
|
key: string;
|
@@ -121,7 +118,7 @@ declare class IndexTree {
|
|
121
118
|
root: ProllyNode | null;
|
122
119
|
}
|
123
120
|
interface ProllyNode extends ProllyNode$1 {
|
124
|
-
getAllEntries<T extends DocRecord = {}>(): PromiseLike<{
|
121
|
+
getAllEntries<T extends DocRecord<T> = {}>(): PromiseLike<{
|
125
122
|
[x: string]: any;
|
126
123
|
result: IndexRow<T>[];
|
127
124
|
}>;
|
@@ -129,10 +126,10 @@ interface ProllyNode extends ProllyNode$1 {
|
|
129
126
|
[x: string]: any;
|
130
127
|
result: IndexKey[];
|
131
128
|
}>;
|
132
|
-
range<T extends DocRecord = {}>(a: IndexKey, b: IndexKey): Promise<{
|
129
|
+
range<T extends DocRecord<T> = {}>(a: IndexKey, b: IndexKey): Promise<{
|
133
130
|
result: IndexRow<T>[];
|
134
131
|
}>;
|
135
|
-
get<T extends DocRecord = {}>(key: string): Promise<{
|
132
|
+
get<T extends DocRecord<T> = {}>(key: string): Promise<{
|
136
133
|
result: IndexRow<T>[];
|
137
134
|
}>;
|
138
135
|
bulk(bulk: IndexUpdate[]): PromiseLike<{
|
@@ -159,8 +156,8 @@ declare class Index {
|
|
159
156
|
initError: Error | null;
|
160
157
|
ready: Promise<void>;
|
161
158
|
constructor(crdt: CRDT, name: string, mapFn?: MapFn, meta?: IdxMeta);
|
162
|
-
applyMapFn<T extends
|
163
|
-
query<T extends DocRecord = {}>(opts?: QueryOpts): Promise<{
|
159
|
+
applyMapFn<T extends DocRecord<T> = {}>(name: string, mapFn?: MapFn, meta?: IdxMeta): void;
|
160
|
+
query<T extends DocRecord<T> = {}>(opts?: QueryOpts): Promise<{
|
164
161
|
rows: IndexRow<T>[];
|
165
162
|
}>;
|
166
163
|
_resetIndex(): void;
|
@@ -263,18 +260,18 @@ declare class Database {
|
|
263
260
|
_writeQueue: WriteQueue;
|
264
261
|
blockstore: EncryptedBlockstore;
|
265
262
|
constructor(name?: string, opts?: ConfigOpts);
|
266
|
-
get<T extends DocRecord = {}>(id: string): Promise<Doc<T>>;
|
267
|
-
put<T extends DocRecord = {}>(doc: Doc<T>): Promise<DbResponse>;
|
263
|
+
get<T extends DocRecord<T> = {}>(id: string): Promise<Doc<T>>;
|
264
|
+
put<T extends DocRecord<T> = {}>(doc: Doc<T>): Promise<DbResponse>;
|
268
265
|
del(id: string): Promise<DbResponse>;
|
269
|
-
changes<T extends DocRecord = {}>(since?: ClockHead, opts?: ChangesOptions): Promise<ChangesResponse<T>>;
|
270
|
-
allDocs<T extends DocRecord = {}>(): Promise<{
|
266
|
+
changes<T extends DocRecord<T> = {}>(since?: ClockHead, opts?: ChangesOptions): Promise<ChangesResponse<T>>;
|
267
|
+
allDocs<T extends DocRecord<T> = {}>(): Promise<{
|
271
268
|
rows: {
|
272
269
|
key: string;
|
273
270
|
value: Doc<T>;
|
274
271
|
}[];
|
275
272
|
clock: ClockHead;
|
276
273
|
}>;
|
277
|
-
allDocuments<T extends DocRecord = {}>(): Promise<{
|
274
|
+
allDocuments<T extends DocRecord<T> = {}>(): Promise<{
|
278
275
|
rows: {
|
279
276
|
key: string;
|
280
277
|
value: Doc<T>;
|
@@ -282,17 +279,17 @@ declare class Database {
|
|
282
279
|
clock: ClockHead;
|
283
280
|
}>;
|
284
281
|
subscribe(listener: ListenerFn | NoUpdateListenerFn, updates?: boolean): () => void;
|
285
|
-
query<T extends DocRecord = {}>(field: string | MapFn, opts?: QueryOpts): Promise<{
|
282
|
+
query<T extends DocRecord<T> = {}>(field: string | MapFn, opts?: QueryOpts): Promise<{
|
286
283
|
rows: IndexRow<T>[];
|
287
284
|
}>;
|
288
285
|
compact(): Promise<void>;
|
289
286
|
_notify(updates: DocUpdate[]): Promise<void>;
|
290
287
|
_no_update_notify(): Promise<void>;
|
291
288
|
}
|
292
|
-
type UpdateListenerFn = <T extends DocRecord
|
289
|
+
type UpdateListenerFn = <T extends DocRecord<T>>(docs: Doc<T>[]) => Promise<void> | void;
|
293
290
|
type NoUpdateListenerFn = () => Promise<void> | void;
|
294
291
|
type ListenerFn = UpdateListenerFn | NoUpdateListenerFn;
|
295
292
|
declare function fireproof(name: string, opts?: ConfigOpts): Database;
|
296
293
|
|
297
|
-
export { type AnyBlock, type AnyDecodedBlock, type AnyLink, type CRDTMeta, type ChangesOptions, type ChangesResponse, type ClockHead, type ClockLink, type ConfigOpts, Database, type DbResponse, type Doc, type DocBase, type
|
294
|
+
export { type AnyBlock, type AnyDecodedBlock, type AnyLink, type CRDTMeta, type ChangesOptions, type ChangesResponse, type ClockHead, type ClockLink, type ConfigOpts, Database, type DbResponse, type Doc, type DocBase, type DocFileMeta, type DocFiles, type DocFragment, type DocRecord, type DocUpdate, type DocValue, type IdxMeta, type IdxMetaMap, type IndexKey, type IndexRow, type IndexUpdate, type MapFn, type QueryOpts, fireproof };
|
298
295
|
declare module '@fireproof/core'
|
@@ -10218,8 +10218,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10218
10218
|
}
|
10219
10219
|
async _commitInternal(t, done, opts = { noLoader: false, compact: false }) {
|
10220
10220
|
await this.ready;
|
10221
|
-
const
|
10222
|
-
const fp = this.makeCarHeader(header, this.carLog, !!opts.compact);
|
10221
|
+
const fp = this.makeCarHeader(done, this.carLog, !!opts.compact);
|
10223
10222
|
let roots = await this.prepareRoots(fp, t);
|
10224
10223
|
const { cid, bytes } = await this.prepareCarFile(roots[0], t, !!opts.public);
|
10225
10224
|
await this.carStore.save({ cid, bytes });
|
@@ -10250,10 +10249,9 @@ You can use close({ resize: true }) to resize header`);
|
|
10250
10249
|
}
|
10251
10250
|
async updateCarLog(cid, fp, compact) {
|
10252
10251
|
if (compact) {
|
10253
|
-
const
|
10254
|
-
|
10255
|
-
|
10256
|
-
this.carLog = [...uniqueCids([cid, ...this.carLog], this.seenCompacted)];
|
10252
|
+
const previousCompactCid = fp.compact[fp.compact.length - 1];
|
10253
|
+
fp.compact.map((c) => c.toString()).forEach(this.seenCompacted.add, this.seenCompacted);
|
10254
|
+
this.carLog = [...uniqueCids([...this.carLog, ...fp.cars, cid], this.seenCompacted)];
|
10257
10255
|
void this.removeCidsForCompact(previousCompactCid);
|
10258
10256
|
} else {
|
10259
10257
|
this.carLog.unshift(cid);
|
@@ -10267,13 +10265,14 @@ You can use close({ resize: true }) to resize header`);
|
|
10267
10265
|
await this.carStore.remove(cid2);
|
10268
10266
|
}
|
10269
10267
|
}
|
10270
|
-
async flushCars() {
|
10271
|
-
|
10272
|
-
|
10273
|
-
|
10274
|
-
|
10275
|
-
|
10276
|
-
}
|
10268
|
+
// async flushCars() {
|
10269
|
+
// await this.ready
|
10270
|
+
// // for each cid in car log, make a dbMeta
|
10271
|
+
// for (const cid of this.carLog) {
|
10272
|
+
// const dbMeta = { car: cid, key: this.key || null } as DbMeta
|
10273
|
+
// await this.remoteWAL!.enqueue(dbMeta, { public: false })
|
10274
|
+
// }
|
10275
|
+
// }
|
10277
10276
|
async *entries() {
|
10278
10277
|
await this.ready;
|
10279
10278
|
for (const [, block] of this.getBlockCache) {
|
@@ -28481,8 +28480,10 @@ ${key.data.toString("base64")}
|
|
28481
28480
|
|
28482
28481
|
// src/crdt-helpers.ts
|
28483
28482
|
function time(tag2) {
|
28483
|
+
console.time(tag2);
|
28484
28484
|
}
|
28485
28485
|
function timeEnd(tag2) {
|
28486
|
+
console.timeEnd(tag2);
|
28486
28487
|
}
|
28487
28488
|
async function applyBulkUpdateToCrdt(tblocks, head, updates) {
|
28488
28489
|
let result = null;
|
@@ -29249,7 +29250,7 @@ ${key.data.toString("base64")}
|
|
29249
29250
|
}
|
29250
29251
|
} else {
|
29251
29252
|
if (!mapFn) {
|
29252
|
-
mapFn =
|
29253
|
+
mapFn = (doc) => doc[name7] ?? void 0;
|
29253
29254
|
}
|
29254
29255
|
if (this.mapFnString) {
|
29255
29256
|
if (this.mapFnString !== mapFn.toString())
|
@@ -29390,9 +29391,6 @@ ${key.data.toString("base64")}
|
|
29390
29391
|
});
|
29391
29392
|
}
|
29392
29393
|
};
|
29393
|
-
function makeMapFnFromName(name7) {
|
29394
|
-
return (doc) => doc[name7] ?? void 0;
|
29395
|
-
}
|
29396
29394
|
|
29397
29395
|
// src/apply-head-queue.ts
|
29398
29396
|
function applyHeadQueue(worker) {
|