@fireproof/core 0.16.1 → 0.16.3
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/README.md +14 -7
- package/dist/browser/fireproof.cjs +251 -34623
- package/dist/browser/fireproof.cjs.map +1 -7
- package/dist/browser/fireproof.d.cts +286 -0
- package/dist/browser/fireproof.d.ts +286 -0
- package/dist/browser/fireproof.global.js +21282 -0
- package/dist/browser/fireproof.global.js.map +1 -0
- package/dist/browser/fireproof.js +1114 -0
- package/dist/browser/fireproof.js.map +1 -0
- package/dist/browser/metafile-cjs.json +1 -0
- package/dist/browser/metafile-esm.json +1 -0
- package/dist/browser/metafile-iife.json +1 -0
- package/dist/memory/fireproof.cjs +1143 -0
- package/dist/memory/fireproof.cjs.map +1 -0
- package/dist/memory/fireproof.d.cts +286 -0
- package/dist/memory/fireproof.d.ts +286 -0
- package/dist/memory/fireproof.global.js +21282 -0
- package/dist/memory/fireproof.global.js.map +1 -0
- package/dist/memory/fireproof.js +1114 -0
- package/dist/memory/fireproof.js.map +1 -0
- package/dist/memory/metafile-cjs.json +1 -0
- package/dist/memory/metafile-esm.json +1 -0
- package/dist/memory/metafile-iife.json +1 -0
- package/dist/node/fireproof.cjs +210 -43910
- package/dist/node/fireproof.cjs.map +1 -7
- package/dist/node/fireproof.d.cts +286 -0
- package/dist/node/fireproof.d.ts +286 -0
- package/dist/node/fireproof.global.js +21338 -0
- package/dist/node/fireproof.global.js.map +1 -0
- package/dist/node/fireproof.js +1114 -0
- package/dist/node/fireproof.js.map +1 -0
- package/dist/node/metafile-cjs.json +1 -0
- package/dist/node/metafile-esm.json +1 -0
- package/dist/node/metafile-iife.json +1 -0
- package/package.json +38 -33
- package/dist/browser/fireproof.esm.js +0 -35509
- package/dist/browser/fireproof.esm.js.map +0 -7
- package/dist/browser/fireproof.iife.js +0 -35517
- package/dist/browser/fireproof.iife.js.map +0 -7
- package/dist/node/fireproof.esm.js +0 -44848
- package/dist/node/fireproof.esm.js.map +0 -7
- package/dist/types/apply-head-queue.d.ts +0 -15
- package/dist/types/crdt-clock.d.ts +0 -20
- package/dist/types/crdt-helpers.d.ts +0 -14
- package/dist/types/crdt.d.ts +0 -27
- package/dist/types/database.d.ts +0 -48
- package/dist/types/eb-edge.d.ts +0 -0
- package/dist/types/eb-node.d.ts +0 -3
- package/dist/types/eb-web.d.ts +0 -3
- package/dist/types/files.d.ts +0 -12
- package/dist/types/fireproof.d.ts +0 -3
- package/dist/types/index.d.ts +0 -31
- package/dist/types/indexer-helpers.d.ts +0 -57
- package/dist/types/types.d.ts +0 -136
- package/dist/types/version.d.ts +0 -1
- package/dist/types/write-queue.d.ts +0 -7
@@ -1,15 +0,0 @@
|
|
1
|
-
import { ClockHead, DocUpdate } from './types';
|
2
|
-
type ApplyHeadWorkerFunction = (newHead: ClockHead, prevHead: ClockHead) => Promise<void>;
|
3
|
-
type ApplyHeadTask = {
|
4
|
-
newHead: ClockHead;
|
5
|
-
prevHead: ClockHead;
|
6
|
-
updates: DocUpdate[] | null;
|
7
|
-
};
|
8
|
-
export type ApplyHeadQueue = {
|
9
|
-
push(task: ApplyHeadTask): AsyncGenerator<{
|
10
|
-
updates: DocUpdate[];
|
11
|
-
all: boolean;
|
12
|
-
}, void, unknown>;
|
13
|
-
};
|
14
|
-
export declare function applyHeadQueue(worker: ApplyHeadWorkerFunction): ApplyHeadQueue;
|
15
|
-
export {};
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import type { EncryptedBlockstore } from '@fireproof/encrypted-blockstore';
|
2
|
-
import type { DocUpdate, ClockHead } from './types';
|
3
|
-
import { ApplyHeadQueue } from './apply-head-queue';
|
4
|
-
export declare class CRDTClock {
|
5
|
-
head: ClockHead;
|
6
|
-
zoomers: Set<() => void>;
|
7
|
-
watchers: Set<(updates: DocUpdate[]) => void>;
|
8
|
-
emptyWatchers: Set<() => void>;
|
9
|
-
blockstore: EncryptedBlockstore | null;
|
10
|
-
applyHeadQueue: ApplyHeadQueue;
|
11
|
-
constructor();
|
12
|
-
setHead(head: ClockHead): void;
|
13
|
-
applyHead(newHead: ClockHead, prevHead: ClockHead, updates?: DocUpdate[] | null): Promise<void>;
|
14
|
-
processUpdates(updatesAcc: DocUpdate[], all: boolean, prevHead: ClockHead): Promise<void>;
|
15
|
-
notifyWatchers(updates: DocUpdate[]): void;
|
16
|
-
onTick(fn: (updates: DocUpdate[]) => void): void;
|
17
|
-
onTock(fn: () => void): void;
|
18
|
-
onZoom(fn: () => void): void;
|
19
|
-
int_applyHead(newHead: ClockHead, prevHead: ClockHead): Promise<void>;
|
20
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { Block } from 'multiformats/block';
|
2
|
-
import { type EncryptedBlockstore, type CompactionFetcher, CarTransaction, BlockFetcher } from '@fireproof/encrypted-blockstore';
|
3
|
-
import type { DocUpdate, ClockHead, DocValue, CRDTMeta, ChangesOptions } from './types';
|
4
|
-
export declare function applyBulkUpdateToCrdt(tblocks: CarTransaction, head: ClockHead, updates: DocUpdate[], options?: object): Promise<CRDTMeta>;
|
5
|
-
export declare function getValueFromCrdt(blocks: EncryptedBlockstore, head: ClockHead, key: string): Promise<DocValue>;
|
6
|
-
export declare function readFiles(blocks: EncryptedBlockstore, { doc }: DocValue): void;
|
7
|
-
export declare function clockChangesSince(blocks: BlockFetcher, head: ClockHead, since: ClockHead, opts: ChangesOptions): Promise<{
|
8
|
-
result: DocUpdate[];
|
9
|
-
head: ClockHead;
|
10
|
-
}>;
|
11
|
-
export declare function getAllEntries(blocks: BlockFetcher, head: ClockHead): AsyncGenerator<DocUpdate, void, unknown>;
|
12
|
-
export declare function clockVis(blocks: EncryptedBlockstore, head: ClockHead): AsyncGenerator<string, void, unknown>;
|
13
|
-
export declare function doCompact(blockLog: CompactionFetcher, head: ClockHead): Promise<void>;
|
14
|
-
export declare function getBlock(blocks: BlockFetcher, cidString: string): Promise<Block<unknown, 113, 18, 1>>;
|
package/dist/types/crdt.d.ts
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
import { EncryptedBlockstore } from '@fireproof/encrypted-blockstore';
|
2
|
-
import type { DocUpdate, CRDTMeta, ClockHead, ConfigOpts, ChangesOptions } from './types';
|
3
|
-
import { type Index } from './index';
|
4
|
-
import { CRDTClock } from './crdt-clock';
|
5
|
-
export declare class CRDT {
|
6
|
-
name: string | null;
|
7
|
-
opts: ConfigOpts;
|
8
|
-
ready: Promise<void>;
|
9
|
-
blockstore: EncryptedBlockstore;
|
10
|
-
indexBlockstore: EncryptedBlockstore;
|
11
|
-
indexers: Map<string, Index>;
|
12
|
-
clock: CRDTClock;
|
13
|
-
constructor(name?: string, opts?: ConfigOpts);
|
14
|
-
bulk(updates: DocUpdate[], options?: object): Promise<CRDTMeta>;
|
15
|
-
allDocs(): Promise<{
|
16
|
-
result: DocUpdate[];
|
17
|
-
head: ClockHead;
|
18
|
-
}>;
|
19
|
-
vis(): Promise<string>;
|
20
|
-
getBlock(cidString: string): Promise<import("multiformats/dist/types/src/block").Block<unknown, 113, 18, 1>>;
|
21
|
-
get(key: string): Promise<import("./types").DocValue | null>;
|
22
|
-
changes(since?: ClockHead, opts?: ChangesOptions): Promise<{
|
23
|
-
result: DocUpdate[];
|
24
|
-
head: ClockHead;
|
25
|
-
}>;
|
26
|
-
compact(): Promise<void>;
|
27
|
-
}
|
package/dist/types/database.d.ts
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
import { WriteQueue } from './write-queue';
|
2
|
-
import { CRDT } from './crdt';
|
3
|
-
import type { DocUpdate, ClockHead, Doc, ConfigOpts, MapFn, QueryOpts, ChangesOptions } from './types';
|
4
|
-
import { DbResponse, ChangesResponse } from './types';
|
5
|
-
import { EncryptedBlockstore } from '@fireproof/encrypted-blockstore';
|
6
|
-
type DbName = string | null;
|
7
|
-
export declare class Database {
|
8
|
-
static databases: Map<string, Database>;
|
9
|
-
name: DbName;
|
10
|
-
opts: ConfigOpts;
|
11
|
-
_listening: boolean;
|
12
|
-
_listeners: Set<ListenerFn>;
|
13
|
-
_noupdate_listeners: Set<ListenerFn>;
|
14
|
-
_crdt: CRDT;
|
15
|
-
_writeQueue: WriteQueue;
|
16
|
-
blockstore: EncryptedBlockstore;
|
17
|
-
constructor(name?: string, opts?: ConfigOpts);
|
18
|
-
get(id: string): Promise<Doc>;
|
19
|
-
put(doc: Doc): Promise<DbResponse>;
|
20
|
-
del(id: string): Promise<DbResponse>;
|
21
|
-
changes(since?: ClockHead, opts?: ChangesOptions): Promise<ChangesResponse>;
|
22
|
-
allDocs(): Promise<{
|
23
|
-
rows: {
|
24
|
-
key: string;
|
25
|
-
value: Doc;
|
26
|
-
}[];
|
27
|
-
clock: ClockHead;
|
28
|
-
}>;
|
29
|
-
allDocuments(): Promise<{
|
30
|
-
rows: {
|
31
|
-
key: string;
|
32
|
-
value: Doc;
|
33
|
-
}[];
|
34
|
-
clock: ClockHead;
|
35
|
-
}>;
|
36
|
-
subscribe(listener: ListenerFn | NoUpdateListenerFn, updates?: boolean): () => void;
|
37
|
-
query(field: string | MapFn, opts?: QueryOpts): Promise<{
|
38
|
-
rows: import("./types").IndexRow[];
|
39
|
-
}>;
|
40
|
-
compact(): Promise<void>;
|
41
|
-
_notify(updates: DocUpdate[]): Promise<void>;
|
42
|
-
_no_update_notify(): Promise<void>;
|
43
|
-
}
|
44
|
-
type UpdateListenerFn = (docs: Doc[]) => Promise<void> | void;
|
45
|
-
type NoUpdateListenerFn = () => Promise<void> | void;
|
46
|
-
type ListenerFn = UpdateListenerFn | NoUpdateListenerFn;
|
47
|
-
export declare function fireproof(name: string, opts?: ConfigOpts): Database;
|
48
|
-
export {};
|
package/dist/types/eb-edge.d.ts
DELETED
File without changes
|
package/dist/types/eb-node.d.ts
DELETED
package/dist/types/eb-web.d.ts
DELETED
package/dist/types/files.d.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
import { AnyBlock, AnyLink, DocFileMeta } from './types';
|
2
|
-
export declare function encodeFile(blob: BlobLike): Promise<{
|
3
|
-
cid: AnyLink;
|
4
|
-
blocks: AnyBlock[];
|
5
|
-
}>;
|
6
|
-
export declare function decodeFile(blocks: unknown, cid: AnyLink, meta: DocFileMeta): Promise<File>;
|
7
|
-
export interface BlobLike {
|
8
|
-
/**
|
9
|
-
* Returns a ReadableStream which yields the Blob data.
|
10
|
-
*/
|
11
|
-
stream: () => ReadableStream;
|
12
|
-
}
|
package/dist/types/index.d.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import type { ClockHead, MapFn, QueryOpts, IdxMeta } from './types';
|
2
|
-
import { EncryptedBlockstore } from '@fireproof/encrypted-blockstore';
|
3
|
-
import { IndexTree } from './indexer-helpers';
|
4
|
-
import { CRDT } from './crdt';
|
5
|
-
export declare function index({ _crdt }: {
|
6
|
-
_crdt: CRDT;
|
7
|
-
}, name: string, mapFn?: MapFn, meta?: IdxMeta): Index;
|
8
|
-
export declare class Index {
|
9
|
-
blockstore: EncryptedBlockstore;
|
10
|
-
crdt: CRDT;
|
11
|
-
name: string | null;
|
12
|
-
mapFn: MapFn | null;
|
13
|
-
mapFnString: string;
|
14
|
-
byKey: IndexTree;
|
15
|
-
byId: IndexTree;
|
16
|
-
indexHead: ClockHead | undefined;
|
17
|
-
includeDocsDefault: boolean;
|
18
|
-
initError: Error | null;
|
19
|
-
ready: Promise<void>;
|
20
|
-
constructor(crdt: CRDT, name: string, mapFn?: MapFn, meta?: IdxMeta);
|
21
|
-
applyMapFn(name: string, mapFn?: MapFn, meta?: IdxMeta): void;
|
22
|
-
query(opts?: QueryOpts): Promise<{
|
23
|
-
rows: import("./types").IndexRow[];
|
24
|
-
}>;
|
25
|
-
_resetIndex(): void;
|
26
|
-
_hydrateIndex(): Promise<void>;
|
27
|
-
_updateIndex(): Promise<import("@fireproof/encrypted-blockstore/dist/types/types").TransactionMeta | {
|
28
|
-
byId: IndexTree;
|
29
|
-
byKey: IndexTree;
|
30
|
-
}>;
|
31
|
-
}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import type { Block, Link } from 'multiformats';
|
2
|
-
import { ProllyNode as BaseNode } from 'prolly-trees/base';
|
3
|
-
import { AnyLink, DocUpdate, MapFn, DocFragment, IndexKey, IndexUpdate, QueryOpts, IndexRow } from './types';
|
4
|
-
import { CarTransaction, BlockFetcher } from '@fireproof/encrypted-blockstore';
|
5
|
-
import { CRDT } from './crdt';
|
6
|
-
export declare class IndexTree {
|
7
|
-
cid: AnyLink | null;
|
8
|
-
root: ProllyNode | null;
|
9
|
-
}
|
10
|
-
export declare const byKeyOpts: StaticProllyOptions;
|
11
|
-
export declare const byIdOpts: StaticProllyOptions;
|
12
|
-
export declare function indexEntriesForChanges(changes: DocUpdate[], mapFn: MapFn): {
|
13
|
-
key: [string, string];
|
14
|
-
value: DocFragment;
|
15
|
-
}[];
|
16
|
-
export declare function bulkIndex(tblocks: CarTransaction, inIndex: IndexTree, indexEntries: IndexUpdate[], opts: StaticProllyOptions): Promise<IndexTree>;
|
17
|
-
export declare function loadIndex(tblocks: BlockFetcher, cid: AnyLink, opts: StaticProllyOptions): Promise<ProllyNode>;
|
18
|
-
export declare function applyQuery(crdt: CRDT, resp: {
|
19
|
-
result: IndexRow[];
|
20
|
-
}, query: QueryOpts): Promise<{
|
21
|
-
rows: IndexRow[];
|
22
|
-
}>;
|
23
|
-
export declare function encodeRange(range: [DocFragment, DocFragment]): [IndexKey, IndexKey];
|
24
|
-
export declare function encodeKey(key: DocFragment): string;
|
25
|
-
interface ProllyNode extends BaseNode {
|
26
|
-
getAllEntries(): PromiseLike<{
|
27
|
-
[x: string]: any;
|
28
|
-
result: IndexRow[];
|
29
|
-
}>;
|
30
|
-
getMany(removeIds: string[]): Promise<{
|
31
|
-
[x: string]: any;
|
32
|
-
result: IndexKey[];
|
33
|
-
}>;
|
34
|
-
range(a: IndexKey, b: IndexKey): Promise<{
|
35
|
-
result: IndexRow[];
|
36
|
-
}>;
|
37
|
-
get(key: string): Promise<{
|
38
|
-
result: IndexRow[];
|
39
|
-
}>;
|
40
|
-
bulk(bulk: IndexUpdate[]): PromiseLike<{
|
41
|
-
root: ProllyNode | null;
|
42
|
-
blocks: Block[];
|
43
|
-
}>;
|
44
|
-
address: Promise<Link>;
|
45
|
-
distance: number;
|
46
|
-
compare: (a: any, b: any) => number;
|
47
|
-
cache: any;
|
48
|
-
block: Promise<Block>;
|
49
|
-
}
|
50
|
-
interface StaticProllyOptions {
|
51
|
-
cache: any;
|
52
|
-
chunker: (entry: any, distance: number) => boolean;
|
53
|
-
codec: any;
|
54
|
-
hasher: any;
|
55
|
-
compare: (a: any, b: any) => number;
|
56
|
-
}
|
57
|
-
export {};
|
package/dist/types/types.d.ts
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
import type { Link } from 'multiformats'
|
2
|
-
import type { EventLink } from '@alanshaw/pail/clock'
|
3
|
-
import type { EventData } from '@alanshaw/pail/crdt'
|
4
|
-
|
5
|
-
import type { DbMeta } from '@fireproof/encrypted-blockstore'
|
6
|
-
|
7
|
-
export type ConfigOpts = {
|
8
|
-
public?: boolean
|
9
|
-
meta?: DbMeta
|
10
|
-
persistIndexes?: boolean
|
11
|
-
}
|
12
|
-
|
13
|
-
// ts-unused-exports:disable-next-line
|
14
|
-
export type ClockLink = EventLink<EventData>
|
15
|
-
|
16
|
-
export type ClockHead = ClockLink[]
|
17
|
-
|
18
|
-
export type DocFragment =
|
19
|
-
| Uint8Array
|
20
|
-
| string
|
21
|
-
| number
|
22
|
-
| boolean
|
23
|
-
| null
|
24
|
-
| AnyLink
|
25
|
-
| DocFragment[]
|
26
|
-
| { [key: string]: DocFragment }
|
27
|
-
|
28
|
-
export type Doc = DocBody & DocBase
|
29
|
-
|
30
|
-
export type DocBase = {
|
31
|
-
_id?: string
|
32
|
-
_files?: DocFiles
|
33
|
-
_publicFiles?: DocFiles
|
34
|
-
}
|
35
|
-
|
36
|
-
export type DocFileMeta = {
|
37
|
-
type: string
|
38
|
-
size: number
|
39
|
-
cid: AnyLink
|
40
|
-
car?: AnyLink
|
41
|
-
url?: string
|
42
|
-
file?: () => Promise<File>
|
43
|
-
}
|
44
|
-
|
45
|
-
export type DocFiles = Record<string, DocFileMeta | File>;
|
46
|
-
|
47
|
-
type DocBody = Record<string, DocFragment> & {
|
48
|
-
_files?: DocFiles;
|
49
|
-
_publicFiles?: DocFiles;
|
50
|
-
}
|
51
|
-
|
52
|
-
// type DocMeta = {
|
53
|
-
// proof?: DocFragment
|
54
|
-
// clock?: ClockHead
|
55
|
-
// }
|
56
|
-
|
57
|
-
export type DocUpdate = {
|
58
|
-
key: string
|
59
|
-
value?: { [key: string]: any }
|
60
|
-
del?: boolean
|
61
|
-
clock?: AnyLink
|
62
|
-
}
|
63
|
-
// todo merge into above
|
64
|
-
export type DocValue = {
|
65
|
-
doc?: DocBody
|
66
|
-
del?: boolean
|
67
|
-
}
|
68
|
-
|
69
|
-
export type IndexKey = [string, string] | string
|
70
|
-
|
71
|
-
export type IndexUpdate = {
|
72
|
-
key: IndexKey
|
73
|
-
value?: DocFragment
|
74
|
-
del?: boolean
|
75
|
-
}
|
76
|
-
|
77
|
-
export type IndexRow = {
|
78
|
-
id: string
|
79
|
-
key: IndexKey
|
80
|
-
row?: DocFragment
|
81
|
-
doc?: Doc | null
|
82
|
-
value?: DocFragment
|
83
|
-
del?: boolean
|
84
|
-
}
|
85
|
-
|
86
|
-
export type CRDTMeta = {
|
87
|
-
head: ClockHead
|
88
|
-
}
|
89
|
-
|
90
|
-
// export type FileMeta = {
|
91
|
-
// files: { [key: string]: DocFileMeta }
|
92
|
-
// }
|
93
|
-
|
94
|
-
export type IdxMeta = {
|
95
|
-
byId: AnyLink
|
96
|
-
byKey: AnyLink
|
97
|
-
map: string
|
98
|
-
name: string
|
99
|
-
head: ClockHead
|
100
|
-
}
|
101
|
-
|
102
|
-
export type IdxMetaMap = {
|
103
|
-
indexes: Map<string, IdxMeta>
|
104
|
-
}
|
105
|
-
|
106
|
-
export type QueryOpts = {
|
107
|
-
descending?: boolean
|
108
|
-
limit?: number
|
109
|
-
includeDocs?: boolean
|
110
|
-
range?: [IndexKey, IndexKey]
|
111
|
-
key?: DocFragment
|
112
|
-
keys?: DocFragment[]
|
113
|
-
prefix?: DocFragment | [DocFragment]
|
114
|
-
}
|
115
|
-
|
116
|
-
export type AnyLink = Link<unknown, number, number, 1 | 0>
|
117
|
-
export type AnyBlock = { cid: AnyLink; bytes: Uint8Array }
|
118
|
-
export type AnyDecodedBlock = { cid: AnyLink; bytes: Uint8Array; value: any }
|
119
|
-
|
120
|
-
type EmitFn = (k: DocFragment, v?: DocFragment) => void
|
121
|
-
export type MapFn = (doc: Doc, emit: EmitFn) => DocFragment | void
|
122
|
-
|
123
|
-
export type ChangesOptions = {
|
124
|
-
dirty?: boolean
|
125
|
-
limit?: number
|
126
|
-
}
|
127
|
-
|
128
|
-
export type ChangesResponse = {
|
129
|
-
clock: ClockHead
|
130
|
-
rows: { key: string; value: Doc }[]
|
131
|
-
}
|
132
|
-
|
133
|
-
export type DbResponse = {
|
134
|
-
id: string
|
135
|
-
clock: ClockHead
|
136
|
-
}
|
package/dist/types/version.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export declare const PACKAGE_VERSION = "0.16.1";
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { CRDTMeta, DocUpdate } from './types';
|
2
|
-
type WorkerFunction = (tasks: DocUpdate[]) => Promise<CRDTMeta>;
|
3
|
-
export type WriteQueue = {
|
4
|
-
push(task: DocUpdate): Promise<CRDTMeta>;
|
5
|
-
};
|
6
|
-
export declare function writeQueue(worker: WorkerFunction, payload?: number, unbounded?: boolean): WriteQueue;
|
7
|
-
export {};
|