@fireproof/core 0.19.8-dev-global → 0.19.8-dev-series-1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +34 -0
- package/chunk-7EWIAXTM.js +7 -0
- package/chunk-7EWIAXTM.js.map +1 -0
- package/chunk-OFGPKRCM.js +290 -0
- package/chunk-OFGPKRCM.js.map +1 -0
- package/chunk-PB4BKL4O.js +7 -0
- package/chunk-PB4BKL4O.js.map +1 -0
- package/chunk-WS3YRPIA.js +75 -0
- package/chunk-WS3YRPIA.js.map +1 -0
- package/deno.json +20 -0
- package/gateway-5FCWPX5W.js +144 -0
- package/gateway-5FCWPX5W.js.map +1 -0
- package/{store-indexdb-WLRSICCB.js → gateway-H7UD6TNB.js} +49 -82
- package/gateway-H7UD6TNB.js.map +1 -0
- package/index.cjs +2317 -1838
- package/index.cjs.map +1 -1
- package/index.d.cts +663 -535
- package/index.d.ts +663 -535
- package/index.global.js +26290 -20732
- package/index.global.js.map +1 -1
- package/index.js +1618 -1032
- package/index.js.map +1 -1
- package/key-bag-file-WADZBHYG.js +54 -0
- package/key-bag-file-WADZBHYG.js.map +1 -0
- package/key-bag-indexdb-PGVAI3FJ.js +50 -0
- package/key-bag-indexdb-PGVAI3FJ.js.map +1 -0
- package/mem-filesystem-YPPJV7Q2.js +41 -0
- package/mem-filesystem-YPPJV7Q2.js.map +1 -0
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/metafile-iife.json +1 -1
- package/node-filesystem-INX4ZTHE.js +45 -0
- package/node-filesystem-INX4ZTHE.js.map +1 -0
- package/package.json +12 -8
- package/tests/blockstore/fragment-gateway.test.ts +107 -0
- package/tests/blockstore/keyed-crypto.test.ts +332 -0
- package/tests/blockstore/loader.test.ts +24 -19
- package/tests/blockstore/store.test.ts +51 -40
- package/tests/blockstore/transaction.test.ts +19 -15
- package/tests/fireproof/all-gateway.test.ts +394 -0
- package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.car +0 -0
- package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.ts +316 -0
- package/tests/fireproof/config.test.ts +94 -78
- package/tests/fireproof/crdt.test.ts +34 -28
- package/tests/fireproof/database.test.ts +22 -14
- package/tests/fireproof/fireproof.test.fixture.ts +133 -0
- package/tests/fireproof/fireproof.test.ts +331 -219
- package/tests/fireproof/hello.test.ts +34 -18
- package/tests/fireproof/indexer.test.ts +34 -27
- package/tests/fireproof/utils.test.ts +84 -0
- package/tests/helpers.ts +28 -57
- package/tests/www/todo-local.html +1 -1
- package/tests/www/todo.html +12 -15
- package/utils-QO2HIWGI.js +14 -0
- package/utils-QO2HIWGI.js.map +1 -0
- package/chunk-BNL4PVBF.js +0 -314
- package/chunk-BNL4PVBF.js.map +0 -1
- package/chunk-JW2QT6BF.js +0 -184
- package/chunk-JW2QT6BF.js.map +0 -1
- package/node-sys-container-MIEX6ELJ.js +0 -29
- package/node-sys-container-MIEX6ELJ.js.map +0 -1
- package/store-file-VJ6BI4II.js +0 -191
- package/store-file-VJ6BI4II.js.map +0 -1
- package/store-indexdb-WLRSICCB.js.map +0 -1
package/index.d.ts
CHANGED
@@ -1,137 +1,171 @@
|
|
1
|
-
import {
|
1
|
+
import { Future, Logger, URI, Result, CoerceURI, ResolveOnce, ResolveSeq, CryptoRuntime, CTCryptoKey, EnvFactoryOpts, Env, runtimeFn } from '@adviser/cement';
|
2
2
|
export { Logger, Result } from '@adviser/cement';
|
3
3
|
import { EventLink } from '@web3-storage/pail/clock/api';
|
4
4
|
import { Operation } from '@web3-storage/pail/crdt/api';
|
5
|
-
import { Version, Block, Link } from 'multiformats';
|
6
|
-
import { ToString } from '@ipld/dag-json';
|
7
|
-
import { CarReader } from '@ipld/car';
|
5
|
+
import { ByteView, ArrayBufferView, Version, Block as Block$1, Link, CID, BlockView, MultihashHasher } from 'multiformats';
|
8
6
|
import { MemoryBlockstore } from '@web3-storage/pail/block';
|
9
7
|
import { BlockFetcher as BlockFetcher$1 } from '@web3-storage/pail/api';
|
10
|
-
import {
|
8
|
+
import { CarReader } from '@ipld/car';
|
9
|
+
import { IDBPDatabase } from 'idb';
|
11
10
|
import { EventBlock } from '@web3-storage/pail/clock';
|
12
|
-
import { PathLike, MakeDirectoryOptions, Stats
|
11
|
+
import { PathLike, MakeDirectoryOptions, Stats } from 'fs';
|
12
|
+
import { ProllyNode as ProllyNode$1 } from 'prolly-trees/db-index';
|
13
|
+
import { Block as Block$2 } from 'multiformats/block';
|
13
14
|
|
14
|
-
interface
|
15
|
-
|
15
|
+
interface BlockEncoder<Code extends number, T> {
|
16
|
+
name: string;
|
17
|
+
code: Code;
|
18
|
+
encode(data: T): ByteView<T> | PromiseLike<ByteView<T>>;
|
19
|
+
}
|
20
|
+
interface BlockDecoder<Code extends number, T> {
|
21
|
+
code: Code;
|
22
|
+
decode(bytes: ByteView<T> | ArrayBufferView<T>): T | PromiseLike<T>;
|
23
|
+
}
|
24
|
+
interface BlockCodec<Code extends number, T> extends BlockEncoder<Code, T>, BlockDecoder<Code, T> {
|
25
|
+
}
|
26
|
+
|
27
|
+
declare const codecInterface_ArrayBufferView: typeof ArrayBufferView;
|
28
|
+
type codecInterface_BlockCodec<Code extends number, T> = BlockCodec<Code, T>;
|
29
|
+
type codecInterface_BlockDecoder<Code extends number, T> = BlockDecoder<Code, T>;
|
30
|
+
type codecInterface_BlockEncoder<Code extends number, T> = BlockEncoder<Code, T>;
|
31
|
+
declare const codecInterface_ByteView: typeof ByteView;
|
32
|
+
declare namespace codecInterface {
|
33
|
+
export { codecInterface_ArrayBufferView as ArrayBufferView, type codecInterface_BlockCodec as BlockCodec, type codecInterface_BlockDecoder as BlockDecoder, type codecInterface_BlockEncoder as BlockEncoder, codecInterface_ByteView as ByteView };
|
34
|
+
}
|
35
|
+
|
36
|
+
type QueueFunction<T = void> = () => Promise<T>;
|
37
|
+
declare class CommitQueue<T = void> {
|
38
|
+
readonly queue: QueueFunction<void>[];
|
39
|
+
processing: boolean;
|
40
|
+
readonly _waitIdleItems: Set<Future<void>>;
|
41
|
+
waitIdle(): Promise<void>;
|
42
|
+
enqueue(fn: QueueFunction<T>): Promise<T>;
|
43
|
+
processNext(): void;
|
44
|
+
}
|
45
|
+
|
46
|
+
declare function ensureSuperThis(osthis?: Partial<SuperThisOpts>): SuperThis;
|
47
|
+
declare function ensureSuperLog(sthis: SuperThis, componentName: string, ctx?: Record<string, unknown>): SuperThis;
|
48
|
+
declare function ensureLogger(sthis: SuperThis, componentName: string, ctx?: Record<string, unknown>): Logger;
|
49
|
+
type Joiner = (...toJoin: string[]) => string;
|
50
|
+
interface Store {
|
51
|
+
readonly store: StoreType;
|
52
|
+
readonly name: string;
|
16
53
|
}
|
54
|
+
declare function getStore(url: URI, sthis: SuperThis, joiner: Joiner): Store;
|
55
|
+
declare function getKey(url: URI, logger: Logger): string;
|
56
|
+
declare function getName(sthis: SuperThis, url: URI): string;
|
57
|
+
declare function exceptionWrapper<T, E extends Error>(fn: () => Promise<Result<T, E>>): Promise<Result<T, E>>;
|
17
58
|
declare class NotFoundError extends Error {
|
18
59
|
readonly code = "ENOENT";
|
19
60
|
}
|
20
61
|
declare function isNotFoundError(e: Error | Result<unknown> | unknown): e is NotFoundError;
|
21
|
-
|
22
|
-
|
23
|
-
interface Gateway {
|
24
|
-
buildUrl(baseUrl: URL, key: string): Promise<Result<URL>>;
|
25
|
-
start(baseUrl: URL): Promise<VoidResult>;
|
26
|
-
close(baseUrl: URL): Promise<VoidResult>;
|
27
|
-
destroy(baseUrl: URL): Promise<VoidResult>;
|
28
|
-
put(url: URL, body: Uint8Array): Promise<VoidResult>;
|
29
|
-
get(url: URL): Promise<GetResult>;
|
30
|
-
delete(url: URL): Promise<VoidResult>;
|
31
|
-
}
|
62
|
+
declare function dataDir(sthis: SuperThis, name?: string, base?: CoerceURI): URI;
|
63
|
+
declare function UInt8ArrayEqual(a: Uint8Array, b: Uint8Array): boolean;
|
32
64
|
|
33
|
-
|
34
|
-
|
35
|
-
readonly
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
65
|
+
interface KeyBagCtx {
|
66
|
+
readonly dirName: string;
|
67
|
+
readonly sysFS: SysFileSystem;
|
68
|
+
readonly fName: string;
|
69
|
+
}
|
70
|
+
declare class KeyBagProviderFile implements KeyBagProvider {
|
71
|
+
_prepare(id: string): Promise<KeyBagCtx>;
|
72
|
+
private readonly url;
|
73
|
+
readonly logger: Logger;
|
74
|
+
readonly sthis: SuperThis;
|
75
|
+
constructor(url: URI, sthis: SuperThis);
|
76
|
+
get(id: string): Promise<KeyItem | undefined>;
|
77
|
+
set(id: string, item: KeyItem): Promise<void>;
|
41
78
|
}
|
42
|
-
|
43
|
-
|
44
|
-
readonly
|
45
|
-
readonly
|
46
|
-
readonly
|
47
|
-
ready(): Promise<void>;
|
48
|
-
close(): Promise<void>;
|
49
|
-
destroy(): Promise<void>;
|
79
|
+
|
80
|
+
declare class KeyBagProviderIndexDB implements KeyBagProvider {
|
81
|
+
readonly _db: ResolveOnce<IDBPDatabase<unknown>>;
|
82
|
+
readonly dbName: string;
|
83
|
+
readonly url: URI;
|
50
84
|
readonly logger: Logger;
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
entries(): AsyncIterableIterator<AnyBlock>;
|
85
|
+
readonly sthis: SuperThis;
|
86
|
+
constructor(url: URI, sthis: SuperThis);
|
87
|
+
_prepare(): Promise<IDBPDatabase<unknown>>;
|
88
|
+
get(id: string): Promise<KeyItem | undefined>;
|
89
|
+
set(id: string, item: KeyItem): Promise<void>;
|
57
90
|
}
|
58
|
-
|
59
|
-
|
60
|
-
readonly
|
61
|
-
ready(): Promise<void>;
|
62
|
-
close(): Promise<void>;
|
63
|
-
destroy(): Promise<void>;
|
64
|
-
compacting: boolean;
|
91
|
+
|
92
|
+
declare class KeyBag {
|
93
|
+
readonly rt: KeyBagRuntime;
|
65
94
|
readonly logger: Logger;
|
66
|
-
constructor(
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
95
|
+
constructor(rt: KeyBagRuntime);
|
96
|
+
readonly _warnOnce: ResolveOnce<void>;
|
97
|
+
subtleKey(key: string): Promise<CryptoKey>;
|
98
|
+
ensureKeyFromUrl(url: URI, keyFactory: () => string): Promise<Result<URI>>;
|
99
|
+
toKeyWithFingerPrint(keyStr: string): Promise<Result<KeyWithFingerPrint>>;
|
100
|
+
readonly _seq: ResolveSeq<Result<KeyWithFingerPrint>>;
|
101
|
+
setNamedKey(name: string, key: string): Promise<Result<KeyWithFingerPrint>>;
|
102
|
+
_setNamedKey(name: string, key: string): Promise<Result<KeyWithFingerPrint>>;
|
103
|
+
getNamedExtractableKey(name: string, failIfNotFound?: boolean): Promise<Result<KeyWithFingerExtract>>;
|
104
|
+
getNamedKey(name: string, failIfNotFound?: boolean): Promise<Result<KeyWithFingerPrint>>;
|
105
|
+
}
|
106
|
+
interface KeyItem {
|
107
|
+
readonly name: string;
|
108
|
+
readonly key: string;
|
75
109
|
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
110
|
+
type KeyBagFile = Record<string, KeyItem>;
|
111
|
+
interface KeyBagOpts {
|
112
|
+
readonly url: CoerceURI;
|
113
|
+
readonly crypto: CryptoRuntime;
|
114
|
+
readonly keyLength: number;
|
115
|
+
readonly keyRuntime: KeyBagRuntime;
|
81
116
|
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
readonly applyMeta?: (meta: TransactionMeta, snap?: boolean) => Promise<void>;
|
86
|
-
readonly compact?: CompactFn;
|
87
|
-
readonly autoCompact?: number;
|
88
|
-
readonly crypto?: CryptoOpts;
|
89
|
-
readonly store?: StoreOpts;
|
90
|
-
readonly public?: boolean;
|
91
|
-
readonly meta?: DbMeta;
|
92
|
-
readonly name?: string;
|
93
|
-
readonly threshold?: number;
|
117
|
+
interface KeyBagProvider {
|
118
|
+
get(id: string): Promise<KeyItem | undefined>;
|
119
|
+
set(id: string, item: KeyItem): Promise<void>;
|
94
120
|
}
|
95
|
-
interface
|
121
|
+
interface KeyBagRuntime {
|
122
|
+
readonly url: URI;
|
123
|
+
readonly crypto: CryptoRuntime;
|
96
124
|
readonly logger: Logger;
|
97
|
-
readonly
|
98
|
-
readonly
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
readonly
|
105
|
-
readonly
|
106
|
-
readonly
|
125
|
+
readonly sthis: SuperThis;
|
126
|
+
readonly keyLength: number;
|
127
|
+
getBag(): Promise<KeyBagProvider>;
|
128
|
+
id(): string;
|
129
|
+
}
|
130
|
+
type KeyBackProviderFactory = (url: URI, sthis: SuperThis) => Promise<KeyBagProvider>;
|
131
|
+
interface KeyBagProviderFactoryItem {
|
132
|
+
readonly protocol: string;
|
133
|
+
readonly override?: boolean;
|
134
|
+
readonly factory: KeyBackProviderFactory;
|
107
135
|
}
|
136
|
+
declare function registerKeyBagProviderFactory(item: KeyBagProviderFactoryItem): void;
|
137
|
+
declare function getKeyBag(sthis: SuperThis, kbo?: Partial<KeyBagOpts>): Promise<KeyBag>;
|
108
138
|
|
109
|
-
type
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
139
|
+
type keyBag_KeyBackProviderFactory = KeyBackProviderFactory;
|
140
|
+
type keyBag_KeyBag = KeyBag;
|
141
|
+
declare const keyBag_KeyBag: typeof KeyBag;
|
142
|
+
type keyBag_KeyBagFile = KeyBagFile;
|
143
|
+
type keyBag_KeyBagOpts = KeyBagOpts;
|
144
|
+
type keyBag_KeyBagProvider = KeyBagProvider;
|
145
|
+
type keyBag_KeyBagProviderFactoryItem = KeyBagProviderFactoryItem;
|
146
|
+
type keyBag_KeyBagProviderFile = KeyBagProviderFile;
|
147
|
+
declare const keyBag_KeyBagProviderFile: typeof KeyBagProviderFile;
|
148
|
+
type keyBag_KeyBagProviderIndexDB = KeyBagProviderIndexDB;
|
149
|
+
declare const keyBag_KeyBagProviderIndexDB: typeof KeyBagProviderIndexDB;
|
150
|
+
type keyBag_KeyBagRuntime = KeyBagRuntime;
|
151
|
+
type keyBag_KeyItem = KeyItem;
|
152
|
+
declare const keyBag_getKeyBag: typeof getKeyBag;
|
153
|
+
declare const keyBag_registerKeyBagProviderFactory: typeof registerKeyBagProviderFactory;
|
154
|
+
declare namespace keyBag {
|
155
|
+
export { type keyBag_KeyBackProviderFactory as KeyBackProviderFactory, keyBag_KeyBag as KeyBag, type keyBag_KeyBagFile as KeyBagFile, type keyBag_KeyBagOpts as KeyBagOpts, type keyBag_KeyBagProvider as KeyBagProvider, type keyBag_KeyBagProviderFactoryItem as KeyBagProviderFactoryItem, keyBag_KeyBagProviderFile as KeyBagProviderFile, keyBag_KeyBagProviderIndexDB as KeyBagProviderIndexDB, type keyBag_KeyBagRuntime as KeyBagRuntime, type keyBag_KeyItem as KeyItem, keyBag_getKeyBag as getKeyBag, keyBag_registerKeyBagProviderFactory as registerKeyBagProviderFactory };
|
115
156
|
}
|
116
157
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
carLog: CarLog;
|
127
|
-
remoteMetaStore?: AbstractRemoteMetaStore;
|
128
|
-
remoteFileStore?: DataStore;
|
129
|
-
abstract ready(): Promise<void>;
|
130
|
-
abstract close(): Promise<void>;
|
131
|
-
abstract fileStore(): Promise<DataStore>;
|
132
|
-
abstract remoteWAL(): Promise<RemoteWAL>;
|
133
|
-
abstract handleDbMetasFromStore(metas: DbMeta[]): Promise<void>;
|
158
|
+
declare class TaskManager {
|
159
|
+
private readonly eventsWeHandled;
|
160
|
+
private queue;
|
161
|
+
private isProcessing;
|
162
|
+
readonly logger: Logger;
|
163
|
+
readonly callback: (dbMeta: DbMeta) => Promise<void>;
|
164
|
+
constructor(sthis: SuperThis, callback: (dbMeta: DbMeta) => Promise<void>);
|
165
|
+
handleEvent(cid: CarClockLink, parents: string[], dbMeta: DbMeta): Promise<void>;
|
166
|
+
private processQueue;
|
134
167
|
}
|
168
|
+
|
135
169
|
declare class Loader implements Loadable {
|
136
170
|
readonly name: string;
|
137
171
|
readonly ebOpts: BlockstoreRuntime;
|
@@ -140,134 +174,133 @@ declare class Loader implements Loadable {
|
|
140
174
|
readonly carReaders: Map<string, Promise<CarReader>>;
|
141
175
|
readonly seenCompacted: Set<string>;
|
142
176
|
readonly processedCars: Set<string>;
|
177
|
+
readonly sthis: SuperThis;
|
178
|
+
readonly taskManager?: TaskManager;
|
143
179
|
carLog: CarLog;
|
144
|
-
|
145
|
-
keyId?: string;
|
146
|
-
remoteMetaStore?: AbstractRemoteMetaStore;
|
180
|
+
remoteMetaStore?: MetaStore;
|
147
181
|
remoteCarStore?: DataStore;
|
148
182
|
remoteFileStore?: DataStore;
|
149
183
|
private getBlockCache;
|
150
184
|
private seenMeta;
|
151
185
|
private writeLimit;
|
186
|
+
keyBag(): Promise<KeyBag>;
|
152
187
|
carStore(): Promise<DataStore>;
|
153
188
|
fileStore(): Promise<DataStore>;
|
154
|
-
|
189
|
+
WALStore(): Promise<WALStore>;
|
155
190
|
metaStore(): Promise<MetaStore>;
|
156
|
-
readonly onceReady: ResolveOnce<void
|
191
|
+
readonly onceReady: ResolveOnce<void>;
|
157
192
|
ready(): Promise<void>;
|
158
193
|
close(): Promise<void>;
|
159
194
|
destroy(): Promise<void>;
|
160
195
|
readonly logger: Logger;
|
161
|
-
constructor(name: string, ebOpts: BlockstoreOpts);
|
196
|
+
constructor(name: string, ebOpts: BlockstoreOpts, sthis: SuperThis);
|
162
197
|
handleDbMetasFromStore(metas: DbMeta[]): Promise<void>;
|
163
198
|
mergeDbMetaIntoClock(meta: DbMeta): Promise<void>;
|
164
|
-
protected ingestKeyFromMeta(meta: DbMeta): Promise<void>;
|
165
199
|
loadCarHeaderFromMeta<T>({ cars: cids }: DbMeta): Promise<CarHeader<T>>;
|
166
|
-
|
167
|
-
|
168
|
-
_commitInternalFiles(t: CarTransaction, done: TransactionMeta, opts?: CommitOpts): Promise<CarGroup>;
|
169
|
-
loadFileCar(cid: AnyLink, isPublic?: boolean): Promise<CarReader>;
|
200
|
+
commitFiles(t: CarTransaction, done: TransactionMeta): Promise<CarGroup>;
|
201
|
+
loadFileCar(cid: AnyLink): Promise<CarReader>;
|
170
202
|
commit<T = TransactionMeta>(t: CarTransaction, done: T, opts?: CommitOpts): Promise<CarGroup>;
|
203
|
+
updateCarLog<T>(cids: CarGroup, fp: CarHeader<T>, compact: boolean): Promise<void>;
|
171
204
|
cacheTransaction(t: CarTransaction): Promise<void>;
|
172
205
|
cacheCarReader(carCidStr: string, reader: CarReader): Promise<void>;
|
173
|
-
_commitInternal<T>(t: CarTransaction, done: T, opts?: CommitOpts): Promise<CarGroup>;
|
174
|
-
prepareCarFilesFiles(roots: AnyLink[], t: CarTransaction, isPublic: boolean): Promise<{
|
175
|
-
cid: AnyLink;
|
176
|
-
bytes: Uint8Array;
|
177
|
-
}[]>;
|
178
|
-
prepareCarFiles(rootBlock: AnyBlock, t: CarTransaction, isPublic: boolean): Promise<{
|
179
|
-
cid: AnyLink;
|
180
|
-
bytes: Uint8Array;
|
181
|
-
}[]>;
|
182
|
-
private createCarFile;
|
183
|
-
protected makeFileCarHeader(result: FileTransactionMeta): TransactionMeta;
|
184
|
-
updateCarLog<T>(cids: CarGroup, fp: CarHeader<T>, compact: boolean): Promise<void>;
|
185
206
|
removeCidsForCompact(cid: AnyLink): Promise<void>;
|
186
207
|
entries(cache?: boolean): AsyncIterableIterator<AnyBlock>;
|
187
208
|
getBlock(cid: AnyLink): Promise<AnyBlock | Falsy>;
|
188
|
-
protected makeCarHeader<T>(meta: T, cars: CarLog, compact?: boolean): CarHeader<T>;
|
189
209
|
loadCar(cid: AnyLink): Promise<CarReader>;
|
190
|
-
|
191
|
-
protected
|
192
|
-
protected setKey(key: string): Promise<void>;
|
210
|
+
makeDecoderAndCarReader(cid: AnyLink, local: DataStore, remote?: DataStore): Promise<CarReader>;
|
211
|
+
protected storesLoadCar(cid: AnyLink, local: DataStore, remote?: DataStore): Promise<CarReader>;
|
193
212
|
protected getMoreReaders(cids: AnyLink[]): Promise<void>;
|
194
213
|
}
|
195
214
|
|
196
|
-
|
197
|
-
|
198
|
-
readonly
|
199
|
-
readonly
|
200
|
-
constructor(name: string, url: URL, logger: Logger);
|
201
|
-
readonly _onStarted: (() => void)[];
|
202
|
-
onStarted(fn: () => void): void;
|
203
|
-
abstract start(): Promise<Result<void>>;
|
204
|
-
readonly _onClosed: (() => void)[];
|
205
|
-
onClosed(fn: () => void): void;
|
206
|
-
abstract close(): Promise<Result<void>>;
|
207
|
-
}
|
208
|
-
declare class MetaStore extends VersionedStore {
|
209
|
-
readonly tag: string;
|
210
|
-
readonly gateway: Gateway;
|
211
|
-
constructor(name: string, url: URL, logger: Logger, gateway: Gateway);
|
212
|
-
makeHeader({ cars, key }: DbMeta): ToString<DbMeta>;
|
213
|
-
parseHeader(headerData: ToString<DbMeta>): DbMeta;
|
214
|
-
start(): Promise<Result<void>>;
|
215
|
-
load(branch?: string): Promise<DbMeta[] | Falsy>;
|
216
|
-
save(meta: DbMeta, branch?: string): Promise<void>;
|
217
|
-
close(): Promise<Result<void>>;
|
218
|
-
destroy(): Promise<Result<void>>;
|
215
|
+
type BlockFetcher = BlockFetcher$1;
|
216
|
+
interface CarTransactionOpts {
|
217
|
+
readonly add: boolean;
|
218
|
+
readonly noLoader: boolean;
|
219
219
|
}
|
220
|
-
|
221
|
-
readonly
|
220
|
+
declare class CarTransaction extends MemoryBlockstore implements CarMakeable {
|
221
|
+
readonly parent: BaseBlockstore;
|
222
|
+
constructor(parent: BaseBlockstore, opts?: CarTransactionOpts);
|
223
|
+
get<T, C extends number, A extends number, V extends Version>(cid: AnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
224
|
+
superGet(cid: AnyLink): Promise<AnyBlock | undefined>;
|
222
225
|
}
|
223
|
-
declare class
|
224
|
-
readonly
|
225
|
-
readonly
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
226
|
+
declare class BaseBlockstore implements BlockFetcher {
|
227
|
+
readonly transactions: Set<CarTransaction>;
|
228
|
+
readonly ebOpts: BlockstoreRuntime;
|
229
|
+
readonly sthis: SuperThis;
|
230
|
+
readonly loader?: Loader;
|
231
|
+
readonly name?: string;
|
232
|
+
ready(): Promise<void>;
|
233
|
+
close(): Promise<void>;
|
234
|
+
destroy(): Promise<void>;
|
235
|
+
readonly logger: Logger;
|
236
|
+
constructor(ebOpts?: BlockstoreOpts);
|
237
|
+
get<T, C extends number, A extends number, V extends Version>(cid: AnyAnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
238
|
+
put(cid: AnyAnyLink, block: Uint8Array): Promise<void>;
|
239
|
+
lastTxMeta?: unknown;
|
240
|
+
transaction<M extends TransactionMeta>(fn: (t: CarTransaction) => Promise<M>, _opts?: CarTransactionOpts): Promise<TransactionWrapper<M>>;
|
241
|
+
entries(): AsyncIterableIterator<AnyBlock>;
|
233
242
|
}
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
243
|
+
declare class EncryptedBlockstore extends BaseBlockstore {
|
244
|
+
readonly name: string;
|
245
|
+
readonly loader: Loader;
|
246
|
+
ready(): Promise<void>;
|
247
|
+
close(): Promise<void>;
|
248
|
+
destroy(): Promise<void>;
|
249
|
+
compacting: boolean;
|
250
|
+
readonly logger: Logger;
|
251
|
+
constructor(sthis: SuperThis, ebOpts: BlockstoreOpts);
|
252
|
+
get<T, C extends number, A extends number, V extends Version>(cid: AnyAnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
253
|
+
transaction<M extends TransactionMeta>(fn: (t: CarTransaction) => Promise<M>, opts?: {
|
254
|
+
noLoader: boolean;
|
255
|
+
}): Promise<TransactionWrapper<M>>;
|
256
|
+
getFile(car: AnyLink, cid: AnyLink): Promise<Uint8Array>;
|
257
|
+
compact(): Promise<void>;
|
258
|
+
defaultCompact(blocks: CompactionFetcher, logger: Logger): Promise<TransactionMeta>;
|
259
|
+
entries(): AsyncIterableIterator<AnyBlock>;
|
241
260
|
}
|
242
|
-
declare class
|
243
|
-
readonly
|
244
|
-
readonly
|
245
|
-
|
246
|
-
|
247
|
-
walState: WALState;
|
248
|
-
readonly processing: Promise<void> | undefined;
|
249
|
-
readonly processQueue: CommitQueue<void>;
|
250
|
-
readonly gateway: Gateway;
|
251
|
-
constructor(loader: Loadable, url: URL, logger: Logger, gateway: Gateway);
|
252
|
-
enqueue(dbMeta: DbMeta, opts: CommitOpts): Promise<void>;
|
253
|
-
enqueueFile(fileCid: AnyLink, publicFile?: boolean): Promise<void>;
|
254
|
-
_process(): Promise<void>;
|
255
|
-
_doProcess(): Promise<void>;
|
256
|
-
start(): Promise<VoidResult>;
|
257
|
-
load(): Promise<WALState | Falsy>;
|
258
|
-
save(state: WALState): Promise<void>;
|
259
|
-
close(): Promise<Result<undefined, Error>>;
|
260
|
-
destroy(): Promise<VoidResult>;
|
261
|
+
declare class CompactionFetcher implements BlockFetcher {
|
262
|
+
readonly blockstore: EncryptedBlockstore;
|
263
|
+
readonly loggedBlocks: CarTransaction;
|
264
|
+
constructor(blocks: EncryptedBlockstore);
|
265
|
+
get<T, C extends number, A extends number, V extends Version>(cid: AnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
261
266
|
}
|
262
267
|
|
263
268
|
type AnyLink = Link<unknown, number, number, Version>;
|
264
269
|
type CarGroup = AnyLink[];
|
265
270
|
type CarLog = CarGroup[];
|
266
271
|
type AnyAnyLink = Link<unknown, number, number, Version>;
|
272
|
+
type AnyLinkFn = (cid: AnyLink) => Promise<AnyBlock | undefined>;
|
267
273
|
interface AnyBlock {
|
268
274
|
readonly cid: Link<unknown, number, number, Version>;
|
269
275
|
readonly bytes: Uint8Array;
|
270
276
|
}
|
277
|
+
interface CIDBlock {
|
278
|
+
readonly cid: CID<unknown, number, number, Version>;
|
279
|
+
readonly bytes: Uint8Array;
|
280
|
+
}
|
281
|
+
declare function toCIDBlock(block: AnyBlock): CIDBlock;
|
282
|
+
interface AnyAnyBlock {
|
283
|
+
readonly cid: AnyAnyLink;
|
284
|
+
readonly bytes: Uint8Array;
|
285
|
+
}
|
286
|
+
interface IvKeyIdData {
|
287
|
+
readonly iv: Uint8Array;
|
288
|
+
readonly keyId: Uint8Array;
|
289
|
+
readonly data: Uint8Array;
|
290
|
+
}
|
291
|
+
interface IvAndBytes {
|
292
|
+
readonly bytes: Uint8Array;
|
293
|
+
readonly iv: Uint8Array;
|
294
|
+
}
|
295
|
+
interface BytesWithIv {
|
296
|
+
readonly bytes: Uint8Array;
|
297
|
+
readonly iv?: Uint8Array;
|
298
|
+
}
|
299
|
+
interface AnyDecodedBlock {
|
300
|
+
readonly cid: AnyLink;
|
301
|
+
readonly bytes: Uint8Array;
|
302
|
+
readonly value: Uint8Array;
|
303
|
+
}
|
271
304
|
interface CarMakeable {
|
272
305
|
entries(): Iterable<AnyBlock>;
|
273
306
|
get(cid: AnyLink): Promise<AnyBlock | undefined>;
|
@@ -283,77 +316,38 @@ interface TransactionWrapper<M extends TransactionMeta> {
|
|
283
316
|
t: CarTransaction;
|
284
317
|
}
|
285
318
|
type TransactionMeta = unknown;
|
286
|
-
interface
|
287
|
-
|
288
|
-
crv?: string;
|
289
|
-
d?: string;
|
290
|
-
dp?: string;
|
291
|
-
dq?: string;
|
292
|
-
e?: string;
|
293
|
-
ext?: boolean;
|
294
|
-
k?: string;
|
295
|
-
key_ops?: string[];
|
296
|
-
kty?: string;
|
297
|
-
n?: string;
|
298
|
-
oth?: RsaOtherPrimesInfo[];
|
299
|
-
p?: string;
|
300
|
-
q?: string;
|
301
|
-
qi?: string;
|
302
|
-
use?: string;
|
303
|
-
x?: string;
|
304
|
-
y?: string;
|
305
|
-
}
|
306
|
-
type FPKeyFormat = "jwk" | "pkcs8" | "raw" | "spki";
|
307
|
-
type FPKeyUsage = "decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey";
|
308
|
-
interface FPAlgorithm {
|
309
|
-
name: string;
|
319
|
+
interface EncryptedBlock {
|
320
|
+
readonly value: IvAndBytes;
|
310
321
|
}
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
}
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
}
|
319
|
-
interface
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
}
|
326
|
-
|
327
|
-
|
328
|
-
readonly
|
329
|
-
readonly
|
330
|
-
readonly
|
331
|
-
|
332
|
-
|
333
|
-
interface FPArrayBufferTypes {
|
334
|
-
ArrayBuffer: ArrayBuffer;
|
335
|
-
}
|
336
|
-
type FPArrayBufferLike = FPArrayBufferTypes[keyof FPArrayBufferTypes];
|
337
|
-
interface FPArrayBufferView {
|
338
|
-
buffer: FPArrayBufferLike;
|
339
|
-
byteLength: number;
|
340
|
-
byteOffset: number;
|
341
|
-
}
|
342
|
-
type FPBufferSource = FPArrayBufferView | ArrayBuffer;
|
343
|
-
interface CryptoOpts {
|
344
|
-
importKey(format: FPKeyFormat, keyData: FPJsonWebKey | FPBufferSource, algorithm: FPAlgorithmIdentifier | FPRsaHashedImportParams | FPEcKeyImportParams | FPHmacImportParams | FPAesKeyAlgorithm, extractable: boolean, keyUsages: FPKeyUsage[]): Promise<FPCryptoKey>;
|
345
|
-
readonly decrypt: (algo: {
|
346
|
-
name: string;
|
347
|
-
iv: Uint8Array;
|
348
|
-
tagLength: number;
|
349
|
-
}, key: FPCryptoKey, data: Uint8Array) => Promise<ArrayBuffer>;
|
350
|
-
readonly encrypt: (algo: {
|
322
|
+
interface KeyMaterial {
|
323
|
+
readonly key: Uint8Array;
|
324
|
+
readonly keyStr: string;
|
325
|
+
}
|
326
|
+
interface KeyWithFingerPrint {
|
327
|
+
readonly fingerPrint: string;
|
328
|
+
readonly key: CTCryptoKey;
|
329
|
+
}
|
330
|
+
interface KeyWithFingerExtract extends KeyWithFingerPrint {
|
331
|
+
extract(): Promise<KeyMaterial>;
|
332
|
+
}
|
333
|
+
interface CodecOpts {
|
334
|
+
readonly ivCalc: "random" | "hash";
|
335
|
+
readonly noIVVerify: boolean;
|
336
|
+
}
|
337
|
+
interface KeyedCrypto {
|
338
|
+
readonly ivLength: number;
|
339
|
+
readonly logger: Logger;
|
340
|
+
readonly crypto: CryptoRuntime;
|
341
|
+
readonly url: URI;
|
342
|
+
fingerPrint(): Promise<string>;
|
343
|
+
algo(iv?: Uint8Array): {
|
351
344
|
name: string;
|
352
345
|
iv: Uint8Array;
|
353
346
|
tagLength: number;
|
354
|
-
}
|
355
|
-
|
356
|
-
|
347
|
+
};
|
348
|
+
codec(iv?: Uint8Array, codecOpts?: Partial<CodecOpts>): BlockCodec<number, Uint8Array>;
|
349
|
+
_decrypt(data: IvAndBytes): Promise<Uint8Array>;
|
350
|
+
_encrypt(data: BytesWithIv): Promise<Uint8Array>;
|
357
351
|
}
|
358
352
|
interface BlobLike {
|
359
353
|
stream: () => ReadableStream;
|
@@ -361,7 +355,7 @@ interface BlobLike {
|
|
361
355
|
interface StoreFactory {
|
362
356
|
makeMetaStore?: (loader: Loadable) => Promise<MetaStore>;
|
363
357
|
makeDataStore?: (loader: Loadable) => Promise<DataStore>;
|
364
|
-
|
358
|
+
makeWALStore?: (loader: Loadable) => Promise<WALStore>;
|
365
359
|
encodeFile?: (blob: BlobLike) => Promise<{
|
366
360
|
cid: AnyLink;
|
367
361
|
blocks: AnyBlock[];
|
@@ -371,20 +365,17 @@ interface StoreFactory {
|
|
371
365
|
interface StoreOpts extends StoreFactory {
|
372
366
|
readonly isIndex?: string;
|
373
367
|
readonly stores?: {
|
374
|
-
readonly base?:
|
375
|
-
readonly meta?:
|
376
|
-
readonly data?:
|
377
|
-
readonly index?:
|
378
|
-
readonly
|
368
|
+
readonly base?: CoerceURI;
|
369
|
+
readonly meta?: CoerceURI;
|
370
|
+
readonly data?: CoerceURI;
|
371
|
+
readonly index?: CoerceURI;
|
372
|
+
readonly wal?: CoerceURI;
|
379
373
|
};
|
380
374
|
}
|
381
|
-
interface TestStore {
|
382
|
-
get(url: URL, key: string): Promise<Uint8Array>;
|
383
|
-
}
|
384
375
|
interface StoreRuntime {
|
385
376
|
makeMetaStore(loader: Loadable): Promise<MetaStore>;
|
386
377
|
makeDataStore(loader: Loadable): Promise<DataStore>;
|
387
|
-
|
378
|
+
makeWALStore(loader: Loadable): Promise<WALStore>;
|
388
379
|
encodeFile(blob: BlobLike): Promise<{
|
389
380
|
cid: AnyLink;
|
390
381
|
blocks: AnyBlock[];
|
@@ -394,201 +385,354 @@ interface StoreRuntime {
|
|
394
385
|
interface CommitOpts {
|
395
386
|
readonly noLoader?: boolean;
|
396
387
|
readonly compact?: boolean;
|
397
|
-
readonly public?: boolean;
|
398
388
|
}
|
399
389
|
interface DbMeta {
|
400
390
|
readonly cars: CarGroup;
|
401
391
|
key?: string;
|
402
392
|
}
|
403
|
-
|
404
|
-
readonly name: string;
|
405
|
-
readonly branch: string;
|
406
|
-
}
|
407
|
-
type FnParamTypes = "data" | "file";
|
408
|
-
interface UploadDataFnParams {
|
409
|
-
readonly type: FnParamTypes;
|
410
|
-
readonly name: string;
|
411
|
-
readonly car: string;
|
412
|
-
readonly size: string;
|
413
|
-
}
|
414
|
-
interface DownloadDataFnParams {
|
415
|
-
readonly type: FnParamTypes;
|
416
|
-
readonly name: string;
|
417
|
-
readonly car: string;
|
418
|
-
}
|
419
|
-
interface DownloadMetaFnParams {
|
420
|
-
readonly name: string;
|
421
|
-
readonly branch: string;
|
422
|
-
}
|
393
|
+
type LoadHandler = (dbMetas: DbMeta[]) => Promise<void>;
|
423
394
|
interface Connection {
|
424
395
|
readonly loader?: Loadable;
|
425
396
|
readonly loaded: Promise<void>;
|
426
|
-
|
397
|
+
connectMeta_X({ loader }: {
|
427
398
|
loader?: Loadable;
|
428
399
|
}): void;
|
429
|
-
|
400
|
+
connectStorage_X({ loader }: {
|
430
401
|
loader?: Loadable;
|
431
402
|
}): void;
|
432
|
-
metaUpload(bytes: Uint8Array, params: UploadMetaFnParams): Promise<Uint8Array[] | Falsy>;
|
433
|
-
dataUpload(bytes: Uint8Array, params: UploadDataFnParams, opts?: {
|
434
|
-
public?: boolean;
|
435
|
-
}): Promise<void>;
|
436
|
-
metaDownload(params: DownloadMetaFnParams): Promise<Uint8Array[] | Falsy>;
|
437
|
-
dataDownload(params: DownloadDataFnParams): Promise<Uint8Array | Falsy>;
|
438
403
|
}
|
404
|
+
interface BaseStore {
|
405
|
+
readonly storeType: StoreType;
|
406
|
+
url(): URI;
|
407
|
+
readonly name: string;
|
408
|
+
onStarted(fn: () => void): void;
|
409
|
+
onClosed(fn: () => void): void;
|
410
|
+
keyedCrypto(): Promise<KeyedCrypto>;
|
411
|
+
close(): Promise<Result<void>>;
|
412
|
+
destroy(): Promise<Result<void>>;
|
413
|
+
readonly ready?: () => Promise<void>;
|
414
|
+
start(): Promise<Result<URI>>;
|
415
|
+
}
|
416
|
+
interface MetaStore extends BaseStore {
|
417
|
+
readonly storeType: "meta";
|
418
|
+
load(branch?: string): Promise<DbMeta[] | Falsy>;
|
419
|
+
save(meta: DbMeta, branch?: string): Promise<Result<void>>;
|
420
|
+
handleByteHeads(byteHeads: Uint8Array, branch?: string): Promise<{
|
421
|
+
eventCid: CarClockLink;
|
422
|
+
dbMeta: DbMeta;
|
423
|
+
}[]>;
|
424
|
+
}
|
425
|
+
interface DataSaveOpts {
|
426
|
+
readonly public: boolean;
|
427
|
+
}
|
428
|
+
interface DataStore extends BaseStore {
|
429
|
+
readonly storeType: "data";
|
430
|
+
load(cid: AnyLink): Promise<AnyBlock>;
|
431
|
+
save(car: AnyBlock, opts?: DataSaveOpts): Promise<void>;
|
432
|
+
remove(cid: AnyLink): Promise<Result<void>>;
|
433
|
+
}
|
434
|
+
interface WALState {
|
435
|
+
operations: DbMeta[];
|
436
|
+
noLoaderOps: DbMeta[];
|
437
|
+
fileOperations: {
|
438
|
+
readonly cid: AnyLink;
|
439
|
+
readonly public: boolean;
|
440
|
+
}[];
|
441
|
+
}
|
442
|
+
interface WALStore extends BaseStore {
|
443
|
+
readonly storeType: "wal";
|
444
|
+
ready(): Promise<void>;
|
445
|
+
readonly processing?: Promise<void> | undefined;
|
446
|
+
readonly processQueue: CommitQueue<void>;
|
447
|
+
process(): Promise<void>;
|
448
|
+
enqueue(dbMeta: DbMeta, opts: CommitOpts): Promise<void>;
|
449
|
+
enqueueFile(fileCid: AnyLink): Promise<void>;
|
450
|
+
load(): Promise<WALState | Falsy>;
|
451
|
+
save(state: WALState): Promise<void>;
|
452
|
+
}
|
453
|
+
type CompactFetcher = BlockFetcher & {
|
454
|
+
readonly loggedBlocks: CarTransaction;
|
455
|
+
};
|
456
|
+
type CompactFn = (blocks: CompactFetcher) => Promise<TransactionMeta>;
|
457
|
+
type BlockstoreOpts = Partial<{
|
458
|
+
readonly logger: Logger;
|
459
|
+
readonly applyMeta: (meta: TransactionMeta, snap?: boolean) => Promise<void>;
|
460
|
+
readonly compact: CompactFn;
|
461
|
+
readonly autoCompact: number;
|
462
|
+
readonly crypto: CryptoRuntime;
|
463
|
+
readonly store: StoreOpts;
|
464
|
+
readonly keyBag: KeyBagOpts;
|
465
|
+
readonly public: boolean;
|
466
|
+
readonly meta: DbMeta;
|
467
|
+
readonly name: string;
|
468
|
+
readonly threshold: number;
|
469
|
+
}>;
|
470
|
+
interface BlockstoreRuntime {
|
471
|
+
readonly logger: Logger;
|
472
|
+
readonly applyMeta: (meta: TransactionMeta, snap?: boolean) => Promise<void>;
|
473
|
+
readonly compact: CompactFn;
|
474
|
+
readonly autoCompact: number;
|
475
|
+
readonly crypto: CryptoRuntime;
|
476
|
+
readonly store: StoreOpts;
|
477
|
+
readonly storeRuntime: StoreRuntime;
|
478
|
+
readonly keyBag: Partial<KeyBagOpts>;
|
479
|
+
readonly meta?: DbMeta;
|
480
|
+
readonly name?: string;
|
481
|
+
readonly threshold: number;
|
482
|
+
}
|
483
|
+
interface Loadable {
|
484
|
+
readonly name: string;
|
485
|
+
readonly sthis: SuperThis;
|
486
|
+
readonly ebOpts: BlockstoreRuntime;
|
487
|
+
remoteCarStore?: DataStore;
|
488
|
+
carStore(): Promise<DataStore>;
|
489
|
+
carLog: CarLog;
|
490
|
+
remoteMetaStore?: MetaStore;
|
491
|
+
remoteFileStore?: DataStore;
|
492
|
+
taskManager?: TaskManager;
|
493
|
+
ready(): Promise<void>;
|
494
|
+
close(): Promise<void>;
|
495
|
+
fileStore(): Promise<DataStore>;
|
496
|
+
WALStore(): Promise<WALStore>;
|
497
|
+
handleDbMetasFromStore(metas: DbMeta[]): Promise<void>;
|
498
|
+
}
|
499
|
+
type DbMetaEventBlock = EventBlock<{
|
500
|
+
dbMeta: Uint8Array;
|
501
|
+
}>;
|
502
|
+
type CarClockLink = Link<DbMetaEventBlock, number, number, Version>;
|
503
|
+
type CarClockHead = CarClockLink[];
|
439
504
|
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
505
|
+
interface GatewayOpts {
|
506
|
+
readonly gateway: Gateway;
|
507
|
+
}
|
508
|
+
type GetResult = Result<Uint8Array, NotFoundError | Error>;
|
509
|
+
type VoidResult = Result<void>;
|
510
|
+
interface TestGateway {
|
511
|
+
get(url: URI, key: string): Promise<Uint8Array>;
|
512
|
+
}
|
513
|
+
type UnsubscribeResult = Result<() => void>;
|
514
|
+
interface Gateway {
|
515
|
+
buildUrl(baseUrl: URI, key: string): Promise<Result<URI>>;
|
516
|
+
start(baseUrl: URI): Promise<Result<URI>>;
|
517
|
+
close(baseUrl: URI): Promise<VoidResult>;
|
518
|
+
destroy(baseUrl: URI): Promise<VoidResult>;
|
519
|
+
put(url: URI, body: Uint8Array): Promise<VoidResult>;
|
520
|
+
get(url: URI): Promise<GetResult>;
|
521
|
+
delete(url: URI): Promise<VoidResult>;
|
522
|
+
subscribe?(url: URI, callback: (meta: Uint8Array) => void): Promise<UnsubscribeResult>;
|
523
|
+
}
|
524
|
+
|
525
|
+
interface GatewayFactoryItem {
|
526
|
+
readonly protocol: string;
|
527
|
+
readonly overrideBaseURL?: string;
|
528
|
+
readonly overrideRegistration?: boolean;
|
529
|
+
readonly gateway: (sthis: SuperThis) => Promise<Gateway>;
|
530
|
+
readonly test: (sthis: SuperThis) => Promise<TestGateway>;
|
531
|
+
}
|
532
|
+
interface GatewayReady {
|
533
|
+
readonly gateway: Gateway;
|
534
|
+
readonly test: TestGateway;
|
535
|
+
}
|
536
|
+
declare function getGatewayFromURL(url: URI, sthis: SuperThis): Promise<GatewayReady | undefined>;
|
537
|
+
declare function registerStoreProtocol(item: GatewayFactoryItem): () => void;
|
538
|
+
declare function testStoreFactory(url: URI, sthis: SuperThis): Promise<TestGateway>;
|
539
|
+
declare function ensureStart<T>(store: T & {
|
540
|
+
start: () => Promise<Result<URI>>;
|
541
|
+
}, logger: Logger): Promise<T>;
|
542
|
+
declare function toStoreRuntime(opts: StoreOpts, sthis: SuperThis): StoreRuntime;
|
543
|
+
|
544
|
+
declare class FragmentGateway implements Gateway {
|
545
|
+
readonly sthis: SuperThis;
|
445
546
|
readonly logger: Logger;
|
446
|
-
|
447
|
-
|
448
|
-
|
547
|
+
readonly fidLength = 4;
|
548
|
+
readonly innerGW: Gateway;
|
549
|
+
headerSize: number;
|
550
|
+
constructor(sthis: SuperThis, innerGW: Gateway);
|
551
|
+
slicer(url: URI, body: Uint8Array): Promise<VoidResult>[];
|
552
|
+
buildUrl(baseUrl: URI, key: string): Promise<Result<URI>>;
|
553
|
+
destroy(iurl: URI): Promise<Result<void>>;
|
554
|
+
start(url: URI): Promise<Result<URI>>;
|
555
|
+
close(url: URI): Promise<VoidResult>;
|
556
|
+
put(url: URI, body: Uint8Array): Promise<VoidResult>;
|
557
|
+
get(url: URI): Promise<GetResult>;
|
558
|
+
subscribe(url: URI, callback: (msg: Uint8Array) => void): Promise<UnsubscribeResult>;
|
559
|
+
delete(url: URI): Promise<VoidResult>;
|
449
560
|
}
|
450
561
|
|
451
|
-
type CarClockHead = Link<DbMetaEventBlock, number, number, Version>[];
|
452
562
|
interface Connectable {
|
453
563
|
readonly blockstore: {
|
454
564
|
readonly loader?: Loader;
|
455
|
-
readonly ebOpts:
|
565
|
+
readonly ebOpts: BlockstoreRuntime;
|
456
566
|
};
|
457
567
|
readonly name?: string;
|
458
568
|
}
|
459
569
|
declare abstract class ConnectionBase implements Connection {
|
460
|
-
readonly eventBlocks: MemoryBlockstore;
|
461
|
-
parents: CarClockHead;
|
462
570
|
loader?: Loadable;
|
463
571
|
taskManager?: TaskManager;
|
464
572
|
loaded: Promise<void>;
|
465
|
-
|
466
|
-
abstract dataUpload(bytes: Uint8Array, params: UploadDataFnParams, opts?: {
|
467
|
-
public?: boolean;
|
468
|
-
}): Promise<void>;
|
469
|
-
abstract metaDownload(params: DownloadMetaFnParams): Promise<Uint8Array[] | Falsy>;
|
470
|
-
abstract dataDownload(params: DownloadDataFnParams): Promise<Uint8Array | Falsy>;
|
573
|
+
readonly url: URI;
|
471
574
|
readonly logger: Logger;
|
472
|
-
constructor(logger: Logger);
|
575
|
+
constructor(url: URI, logger: Logger);
|
473
576
|
refresh(): Promise<void>;
|
474
|
-
|
475
|
-
loader?:
|
476
|
-
}): void
|
477
|
-
|
478
|
-
loader?:
|
479
|
-
}): void
|
480
|
-
onConnect(): Promise<void>;
|
481
|
-
|
482
|
-
loader?:
|
483
|
-
}): void
|
484
|
-
createEventBlock(bytes: Uint8Array): Promise<DbMetaEventBlock>;
|
485
|
-
decodeEventBlock(bytes: Uint8Array): Promise<DbMetaEventBlock>;
|
486
|
-
}
|
487
|
-
type DbMetaEventBlock = EventBlock<{
|
488
|
-
dbMeta: Uint8Array;
|
489
|
-
}>;
|
490
|
-
|
491
|
-
declare class ConnectREST extends ConnectionBase {
|
492
|
-
readonly baseUrl: URL;
|
493
|
-
constructor(base: string, logger: Logger);
|
494
|
-
dataUpload(bytes: Uint8Array, params: UploadDataFnParams): Promise<void>;
|
495
|
-
dataDownload(params: DownloadDataFnParams): Promise<Uint8Array | undefined>;
|
496
|
-
metaUpload(bytes: Uint8Array, params: UploadMetaFnParams): Promise<undefined>;
|
497
|
-
metaDownload(params: DownloadMetaFnParams): Promise<never[]>;
|
498
|
-
}
|
499
|
-
|
500
|
-
declare function toURL(pathOrUrl: string | URL, isIndex?: string): URL;
|
501
|
-
interface StoreFactoryItem {
|
502
|
-
readonly protocol: string;
|
503
|
-
readonly overrideBaseURL?: string;
|
504
|
-
readonly overrideRegistration?: boolean;
|
505
|
-
readonly data: (logger: Logger) => Promise<Gateway>;
|
506
|
-
readonly meta: (logger: Logger) => Promise<Gateway>;
|
507
|
-
readonly wal: (logger: Logger) => Promise<Gateway>;
|
508
|
-
readonly test: (logger: Logger) => Promise<TestStore>;
|
577
|
+
connect_X({ loader }: {
|
578
|
+
readonly loader?: Loadable;
|
579
|
+
}): Promise<void>;
|
580
|
+
connectMeta_X({ loader }: {
|
581
|
+
loader?: Loadable;
|
582
|
+
}): Promise<void>;
|
583
|
+
abstract onConnect(): Promise<void>;
|
584
|
+
connectStorage_X({ loader }: {
|
585
|
+
loader?: Loadable;
|
586
|
+
}): Promise<void>;
|
509
587
|
}
|
510
|
-
declare function registerStoreProtocol(item: StoreFactoryItem): () => void;
|
511
|
-
declare function testStoreFactory(url: URL, ilogger?: Logger): Promise<TestStore>;
|
512
|
-
declare function toStoreRuntime(opts: StoreOpts, ilogger: Logger): StoreRuntime;
|
513
588
|
|
514
589
|
declare function parseCarFile<T>(reader: CarReader, logger: Logger): Promise<CarHeader<T>>;
|
515
590
|
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
type index$
|
520
|
-
|
521
|
-
type index$
|
522
|
-
type index$
|
523
|
-
type index$
|
524
|
-
type index$
|
525
|
-
type index$
|
526
|
-
declare const index$
|
527
|
-
type index$
|
528
|
-
type index$
|
529
|
-
|
530
|
-
type index$
|
531
|
-
|
532
|
-
type index$
|
533
|
-
type index$
|
534
|
-
type index$
|
535
|
-
|
536
|
-
type index$
|
537
|
-
type index$
|
538
|
-
type index$
|
539
|
-
|
540
|
-
type index$
|
541
|
-
|
542
|
-
type index$
|
543
|
-
type index$
|
544
|
-
type index$
|
545
|
-
|
546
|
-
type index$
|
547
|
-
|
548
|
-
type index$
|
549
|
-
type index$
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
type index$
|
554
|
-
|
555
|
-
type index$
|
556
|
-
|
557
|
-
type index$
|
558
|
-
declare const index$
|
559
|
-
type index$
|
560
|
-
|
561
|
-
type index$
|
562
|
-
type index$
|
563
|
-
type index$
|
564
|
-
type index$
|
565
|
-
type index$
|
566
|
-
type index$
|
567
|
-
type index$
|
568
|
-
type index$
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
declare const index$
|
575
|
-
|
576
|
-
|
591
|
+
declare function setCryptoKeyFromGatewayMetaPayload(uri: URI, sthis: SuperThis, data: Uint8Array): Promise<Result<DbMeta | undefined>>;
|
592
|
+
declare function addCryptoKeyToGatewayMetaPayload(uri: URI, sthis: SuperThis, body: Uint8Array): Promise<Result<Uint8Array>>;
|
593
|
+
|
594
|
+
type index$3_AnyAnyBlock = AnyAnyBlock;
|
595
|
+
type index$3_AnyAnyLink = AnyAnyLink;
|
596
|
+
type index$3_AnyBlock = AnyBlock;
|
597
|
+
type index$3_AnyDecodedBlock = AnyDecodedBlock;
|
598
|
+
type index$3_AnyLink = AnyLink;
|
599
|
+
type index$3_AnyLinkFn = AnyLinkFn;
|
600
|
+
type index$3_BaseBlockstore = BaseBlockstore;
|
601
|
+
declare const index$3_BaseBlockstore: typeof BaseBlockstore;
|
602
|
+
type index$3_BaseStore = BaseStore;
|
603
|
+
type index$3_BlobLike = BlobLike;
|
604
|
+
type index$3_BlockFetcher = BlockFetcher;
|
605
|
+
type index$3_BlockstoreOpts = BlockstoreOpts;
|
606
|
+
type index$3_BlockstoreRuntime = BlockstoreRuntime;
|
607
|
+
type index$3_BytesWithIv = BytesWithIv;
|
608
|
+
type index$3_CIDBlock = CIDBlock;
|
609
|
+
type index$3_CarClockHead = CarClockHead;
|
610
|
+
type index$3_CarClockLink = CarClockLink;
|
611
|
+
type index$3_CarGroup = CarGroup;
|
612
|
+
type index$3_CarHeader<T> = CarHeader<T>;
|
613
|
+
type index$3_CarLog = CarLog;
|
614
|
+
type index$3_CarMakeable = CarMakeable;
|
615
|
+
type index$3_CarTransaction = CarTransaction;
|
616
|
+
declare const index$3_CarTransaction: typeof CarTransaction;
|
617
|
+
type index$3_CodecOpts = CodecOpts;
|
618
|
+
type index$3_CommitOpts = CommitOpts;
|
619
|
+
type index$3_CompactFetcher = CompactFetcher;
|
620
|
+
type index$3_CompactFn = CompactFn;
|
621
|
+
type index$3_CompactionFetcher = CompactionFetcher;
|
622
|
+
declare const index$3_CompactionFetcher: typeof CompactionFetcher;
|
623
|
+
type index$3_Connectable = Connectable;
|
624
|
+
type index$3_Connection = Connection;
|
625
|
+
type index$3_ConnectionBase = ConnectionBase;
|
626
|
+
declare const index$3_ConnectionBase: typeof ConnectionBase;
|
627
|
+
type index$3_DataSaveOpts = DataSaveOpts;
|
628
|
+
type index$3_DataStore = DataStore;
|
629
|
+
type index$3_DbMeta = DbMeta;
|
630
|
+
type index$3_DbMetaEventBlock = DbMetaEventBlock;
|
631
|
+
type index$3_EncryptedBlock = EncryptedBlock;
|
632
|
+
type index$3_EncryptedBlockstore = EncryptedBlockstore;
|
633
|
+
declare const index$3_EncryptedBlockstore: typeof EncryptedBlockstore;
|
634
|
+
type index$3_FragmentGateway = FragmentGateway;
|
635
|
+
declare const index$3_FragmentGateway: typeof FragmentGateway;
|
636
|
+
type index$3_Gateway = Gateway;
|
637
|
+
type index$3_GatewayFactoryItem = GatewayFactoryItem;
|
638
|
+
type index$3_GatewayOpts = GatewayOpts;
|
639
|
+
type index$3_GetResult = GetResult;
|
640
|
+
type index$3_IvAndBytes = IvAndBytes;
|
641
|
+
type index$3_IvKeyIdData = IvKeyIdData;
|
642
|
+
type index$3_KeyMaterial = KeyMaterial;
|
643
|
+
type index$3_KeyWithFingerExtract = KeyWithFingerExtract;
|
644
|
+
type index$3_KeyWithFingerPrint = KeyWithFingerPrint;
|
645
|
+
type index$3_KeyedCrypto = KeyedCrypto;
|
646
|
+
type index$3_LoadHandler = LoadHandler;
|
647
|
+
type index$3_Loadable = Loadable;
|
648
|
+
type index$3_Loader = Loader;
|
649
|
+
declare const index$3_Loader: typeof Loader;
|
650
|
+
type index$3_MetaStore = MetaStore;
|
651
|
+
type index$3_StoreFactory = StoreFactory;
|
652
|
+
type index$3_StoreOpts = StoreOpts;
|
653
|
+
type index$3_StoreRuntime = StoreRuntime;
|
654
|
+
type index$3_TestGateway = TestGateway;
|
655
|
+
type index$3_TransactionMeta = TransactionMeta;
|
656
|
+
type index$3_TransactionWrapper<M extends TransactionMeta> = TransactionWrapper<M>;
|
657
|
+
type index$3_UnsubscribeResult = UnsubscribeResult;
|
658
|
+
type index$3_VoidResult = VoidResult;
|
659
|
+
type index$3_WALState = WALState;
|
660
|
+
type index$3_WALStore = WALStore;
|
661
|
+
declare const index$3_addCryptoKeyToGatewayMetaPayload: typeof addCryptoKeyToGatewayMetaPayload;
|
662
|
+
declare const index$3_ensureStart: typeof ensureStart;
|
663
|
+
declare const index$3_getGatewayFromURL: typeof getGatewayFromURL;
|
664
|
+
declare const index$3_parseCarFile: typeof parseCarFile;
|
665
|
+
declare const index$3_registerStoreProtocol: typeof registerStoreProtocol;
|
666
|
+
declare const index$3_setCryptoKeyFromGatewayMetaPayload: typeof setCryptoKeyFromGatewayMetaPayload;
|
667
|
+
declare const index$3_testStoreFactory: typeof testStoreFactory;
|
668
|
+
declare const index$3_toCIDBlock: typeof toCIDBlock;
|
669
|
+
declare const index$3_toStoreRuntime: typeof toStoreRuntime;
|
670
|
+
declare namespace index$3 {
|
671
|
+
export { type index$3_AnyAnyBlock as AnyAnyBlock, type index$3_AnyAnyLink as AnyAnyLink, type index$3_AnyBlock as AnyBlock, type index$3_AnyDecodedBlock as AnyDecodedBlock, type index$3_AnyLink as AnyLink, type index$3_AnyLinkFn as AnyLinkFn, index$3_BaseBlockstore as BaseBlockstore, type index$3_BaseStore as BaseStore, type index$3_BlobLike as BlobLike, type index$3_BlockFetcher as BlockFetcher, type index$3_BlockstoreOpts as BlockstoreOpts, type index$3_BlockstoreRuntime as BlockstoreRuntime, type index$3_BytesWithIv as BytesWithIv, type index$3_CIDBlock as CIDBlock, type index$3_CarClockHead as CarClockHead, type index$3_CarClockLink as CarClockLink, type index$3_CarGroup as CarGroup, type index$3_CarHeader as CarHeader, type index$3_CarLog as CarLog, type index$3_CarMakeable as CarMakeable, index$3_CarTransaction as CarTransaction, type index$3_CodecOpts as CodecOpts, type index$3_CommitOpts as CommitOpts, type index$3_CompactFetcher as CompactFetcher, type index$3_CompactFn as CompactFn, index$3_CompactionFetcher as CompactionFetcher, type index$3_Connectable as Connectable, type index$3_Connection as Connection, index$3_ConnectionBase as ConnectionBase, type index$3_DataSaveOpts as DataSaveOpts, type index$3_DataStore as DataStore, type index$3_DbMeta as DbMeta, type index$3_DbMetaEventBlock as DbMetaEventBlock, type index$3_EncryptedBlock as EncryptedBlock, index$3_EncryptedBlockstore as EncryptedBlockstore, index$3_FragmentGateway as FragmentGateway, type index$3_Gateway as Gateway, type index$3_GatewayFactoryItem as GatewayFactoryItem, type index$3_GatewayOpts as GatewayOpts, type index$3_GetResult as GetResult, type index$3_IvAndBytes as IvAndBytes, type index$3_IvKeyIdData as IvKeyIdData, type index$3_KeyMaterial as KeyMaterial, type index$3_KeyWithFingerExtract as KeyWithFingerExtract, type index$3_KeyWithFingerPrint as KeyWithFingerPrint, type index$3_KeyedCrypto as KeyedCrypto, type index$3_LoadHandler as LoadHandler, type index$3_Loadable as Loadable, index$3_Loader as Loader, type index$3_MetaStore as MetaStore, type index$3_StoreFactory as StoreFactory, type index$3_StoreOpts as StoreOpts, type index$3_StoreRuntime as StoreRuntime, type index$3_TestGateway as TestGateway, type index$3_TransactionMeta as TransactionMeta, type index$3_TransactionWrapper as TransactionWrapper, type index$3_UnsubscribeResult as UnsubscribeResult, type index$3_VoidResult as VoidResult, type index$3_WALState as WALState, type index$3_WALStore as WALStore, index$3_addCryptoKeyToGatewayMetaPayload as addCryptoKeyToGatewayMetaPayload, index$3_ensureStart as ensureStart, index$3_getGatewayFromURL as getGatewayFromURL, index$3_parseCarFile as parseCarFile, index$3_registerStoreProtocol as registerStoreProtocol, index$3_setCryptoKeyFromGatewayMetaPayload as setCryptoKeyFromGatewayMetaPayload, index$3_testStoreFactory as testStoreFactory, index$3_toCIDBlock as toCIDBlock, index$3_toStoreRuntime as toStoreRuntime };
|
577
672
|
}
|
578
673
|
|
579
674
|
type Falsy = false | null | undefined;
|
580
675
|
declare function isFalsy(value: unknown): value is Falsy;
|
581
676
|
declare function throwFalsy<T>(value: T | Falsy): T;
|
582
677
|
declare function falsyToUndef<T>(value: T | Falsy): T | undefined;
|
583
|
-
|
678
|
+
type StoreType = "data" | "wal" | "meta";
|
679
|
+
interface SysFileSystem {
|
680
|
+
start(): Promise<SysFileSystem>;
|
681
|
+
mkdir(path: PathLike, options?: {
|
682
|
+
recursive: boolean;
|
683
|
+
}): Promise<string | undefined>;
|
684
|
+
readdir(path: PathLike, options?: unknown): Promise<string[]>;
|
685
|
+
rm(path: PathLike, options?: MakeDirectoryOptions & {
|
686
|
+
recursive: boolean;
|
687
|
+
}): Promise<void>;
|
688
|
+
copyFile(source: PathLike, destination: PathLike): Promise<void>;
|
689
|
+
readfile(path: PathLike, options?: {
|
690
|
+
encoding: BufferEncoding;
|
691
|
+
flag?: string;
|
692
|
+
}): Promise<Uint8Array>;
|
693
|
+
stat(path: PathLike): Promise<Stats>;
|
694
|
+
unlink(path: PathLike): Promise<void>;
|
695
|
+
writefile(path: PathLike, data: Uint8Array | string): Promise<void>;
|
696
|
+
}
|
697
|
+
interface PathOps {
|
698
|
+
join(...args: string[]): string;
|
699
|
+
dirname(path: string): string;
|
700
|
+
}
|
701
|
+
interface TextEndeCoder {
|
702
|
+
encode(input: string): Uint8Array;
|
703
|
+
decode(input: Uint8Array): string;
|
704
|
+
}
|
705
|
+
interface SuperThisOpts {
|
706
|
+
readonly logger: Logger;
|
707
|
+
readonly pathOps: PathOps;
|
708
|
+
readonly crypto: CryptoRuntime;
|
709
|
+
readonly env: EnvFactoryOpts;
|
710
|
+
readonly txt: TextEndeCoder;
|
711
|
+
readonly ctx: Record<string, unknown>;
|
712
|
+
}
|
713
|
+
interface SuperThis {
|
714
|
+
readonly logger: Logger;
|
715
|
+
readonly env: Env;
|
716
|
+
readonly pathOps: PathOps;
|
717
|
+
readonly ctx: Record<string, unknown>;
|
718
|
+
readonly txt: TextEndeCoder;
|
719
|
+
nextId(bytes?: number): {
|
720
|
+
str: string;
|
721
|
+
bin: Uint8Array;
|
722
|
+
};
|
723
|
+
timeOrderedNextId(time?: number): {
|
724
|
+
str: string;
|
725
|
+
};
|
726
|
+
start(): Promise<void>;
|
727
|
+
clone(override: Partial<SuperThisOpts>): SuperThis;
|
728
|
+
}
|
729
|
+
interface ConfigOpts extends Partial<SuperThisOpts> {
|
584
730
|
readonly public?: boolean;
|
585
731
|
readonly meta?: DbMeta;
|
586
732
|
readonly persistIndexes?: boolean;
|
587
733
|
readonly autoCompact?: number;
|
588
|
-
readonly crypto?: CryptoOpts;
|
589
734
|
readonly store?: StoreOpts;
|
590
735
|
readonly threshold?: number;
|
591
|
-
readonly logger?: Logger;
|
592
736
|
}
|
593
737
|
type ClockLink = EventLink<Operation>;
|
594
738
|
type ClockHead = ClockLink[];
|
@@ -714,6 +858,11 @@ interface DocResponse {
|
|
714
858
|
type UpdateListenerFn<T extends DocTypes> = (docs: DocWithId<T>[]) => Promise<void> | void;
|
715
859
|
type NoUpdateListenerFn = () => Promise<void> | void;
|
716
860
|
type ListenerFn<T extends DocTypes> = UpdateListenerFn<T> | NoUpdateListenerFn;
|
861
|
+
interface CRDTEntry {
|
862
|
+
data: string;
|
863
|
+
parents: string[];
|
864
|
+
cid: string;
|
865
|
+
}
|
717
866
|
|
718
867
|
interface WriteQueue<T extends DocTypes> {
|
719
868
|
push(task: DocUpdate<T>): Promise<MetaType>;
|
@@ -744,16 +893,16 @@ interface ProllyNode<K extends IndexKeyType, T extends DocFragment> extends Prol
|
|
744
893
|
}>;
|
745
894
|
bulk(bulk: (IndexUpdate<K> | IndexUpdateString)[]): PromiseLike<{
|
746
895
|
readonly root?: ProllyNode<K, T>;
|
747
|
-
readonly blocks: Block[];
|
896
|
+
readonly blocks: Block$1[];
|
748
897
|
}>;
|
749
898
|
readonly address: Promise<Link>;
|
750
899
|
readonly distance: number;
|
751
900
|
compare: (a: unknown, b: unknown) => number;
|
752
901
|
readonly cache: unknown;
|
753
|
-
readonly block: Promise<Block>;
|
902
|
+
readonly block: Promise<Block$1>;
|
754
903
|
}
|
755
904
|
|
756
|
-
declare function index$
|
905
|
+
declare function index$2<K extends IndexKeyType = string, T extends DocTypes = NonNullable<unknown>, R extends DocFragment = T>(sthis: SuperThis, { _crdt }: {
|
757
906
|
_crdt: CRDT<T> | CRDT<NonNullable<unknown>>;
|
758
907
|
}, name: string, mapFn?: MapFn<T>, meta?: IdxMeta): Index<K, T, R>;
|
759
908
|
declare class Index<K extends IndexKeyType, T extends DocTypes, R extends DocFragment = T> {
|
@@ -771,7 +920,7 @@ declare class Index<K extends IndexKeyType, T extends DocTypes, R extends DocFra
|
|
771
920
|
close(): Promise<void>;
|
772
921
|
destroy(): Promise<void>;
|
773
922
|
readonly logger: Logger;
|
774
|
-
constructor(crdt: CRDT<T> | CRDT<NonNullable<unknown>>, name: string, mapFn?: MapFn<T>, meta?: IdxMeta);
|
923
|
+
constructor(sthis: SuperThis, crdt: CRDT<T> | CRDT<NonNullable<unknown>>, name: string, mapFn?: MapFn<T>, meta?: IdxMeta);
|
775
924
|
applyMapFn(name: string, mapFn?: MapFn<T>, meta?: IdxMeta): void;
|
776
925
|
query(opts?: QueryOpts<K>): Promise<IndexRows<K, T, R>>;
|
777
926
|
_resetIndex(): void;
|
@@ -799,7 +948,7 @@ declare class CRDTClock<T extends DocTypes> {
|
|
799
948
|
readonly emptyWatchers: Set<() => void>;
|
800
949
|
readonly blockstore: BaseBlockstore;
|
801
950
|
readonly applyHeadQueue: ApplyHeadQueue<T>;
|
802
|
-
readonly _ready: ResolveOnce<void
|
951
|
+
readonly _ready: ResolveOnce<void>;
|
803
952
|
ready(): Promise<void>;
|
804
953
|
close(): Promise<void>;
|
805
954
|
readonly logger: Logger;
|
@@ -817,23 +966,24 @@ declare class CRDTClock<T extends DocTypes> {
|
|
817
966
|
declare class CRDT<T extends DocTypes> {
|
818
967
|
readonly name?: string;
|
819
968
|
readonly opts: ConfigOpts;
|
820
|
-
readonly onceReady: ResolveOnce<void, void>;
|
821
|
-
ready(): Promise<void>;
|
822
|
-
close(): Promise<void>;
|
823
|
-
destroy(): Promise<void>;
|
824
969
|
readonly blockstore: BaseBlockstore;
|
825
970
|
readonly indexBlockstore: BaseBlockstore;
|
826
|
-
readonly indexers: Map<string, Index<IndexKeyType,
|
971
|
+
readonly indexers: Map<string, Index<IndexKeyType, NonNullable<unknown>>>;
|
827
972
|
readonly clock: CRDTClock<T>;
|
828
973
|
readonly logger: Logger;
|
829
|
-
|
974
|
+
readonly sthis: SuperThis;
|
975
|
+
constructor(sthis: SuperThis, name?: string, opts?: ConfigOpts);
|
830
976
|
bulk(updates: DocUpdate<T>[]): Promise<CRDTMeta>;
|
977
|
+
readonly onceReady: ResolveOnce<void>;
|
978
|
+
ready(): Promise<void>;
|
979
|
+
close(): Promise<void>;
|
980
|
+
destroy(): Promise<void>;
|
831
981
|
allDocs(): Promise<{
|
832
982
|
result: DocUpdate<T>[];
|
833
983
|
head: ClockHead;
|
834
984
|
}>;
|
835
985
|
vis(): Promise<string>;
|
836
|
-
getBlock(cidString: string): Promise<Block>;
|
986
|
+
getBlock(cidString: string): Promise<Block$1>;
|
837
987
|
get(key: string): Promise<DocValue<T> | Falsy>;
|
838
988
|
changes(since?: ClockHead, opts?: ChangesOptions): Promise<{
|
839
989
|
result: DocUpdate<T>[];
|
@@ -843,7 +993,7 @@ declare class CRDT<T extends DocTypes> {
|
|
843
993
|
}
|
844
994
|
|
845
995
|
declare class Database<DT extends DocTypes = NonNullable<unknown>> implements Connectable {
|
846
|
-
static databases: Map<string, Database
|
996
|
+
static databases: Map<string, Database>;
|
847
997
|
readonly name?: string;
|
848
998
|
readonly opts: ConfigOpts;
|
849
999
|
_listening: boolean;
|
@@ -854,9 +1004,10 @@ declare class Database<DT extends DocTypes = NonNullable<unknown>> implements Co
|
|
854
1004
|
readonly blockstore: BaseBlockstore;
|
855
1005
|
close(): Promise<void>;
|
856
1006
|
destroy(): Promise<void>;
|
857
|
-
readonly _ready: ResolveOnce<void
|
1007
|
+
readonly _ready: ResolveOnce<void>;
|
858
1008
|
ready(): Promise<void>;
|
859
1009
|
readonly logger: Logger;
|
1010
|
+
readonly sthis: SuperThis;
|
860
1011
|
constructor(name?: string, opts?: ConfigOpts);
|
861
1012
|
get<T extends DocTypes>(id: string): Promise<DocWithId<T>>;
|
862
1013
|
put<T extends DocTypes>(doc: DocSet<T>): Promise<DocResponse>;
|
@@ -878,95 +1029,10 @@ declare class Database<DT extends DocTypes = NonNullable<unknown>> implements Co
|
|
878
1029
|
}
|
879
1030
|
declare function fireproof(name: string, opts?: ConfigOpts): Database;
|
880
1031
|
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
isReactNative: boolean;
|
886
|
-
}
|
887
|
-
declare function runtimeFn(): Runtime;
|
888
|
-
interface NodeMap {
|
889
|
-
state: "seeded" | "browser" | "node";
|
890
|
-
join: (...args: string[]) => string;
|
891
|
-
dirname: (path: string) => string;
|
892
|
-
homedir: () => string;
|
893
|
-
fileURLToPath: (url: string | URL) => string;
|
894
|
-
mkdir: (path: PathLike, options?: {
|
895
|
-
recursive: boolean;
|
896
|
-
}) => Promise<string | undefined>;
|
897
|
-
readdir: (path: PathLike, options?: unknown) => Promise<unknown[]>;
|
898
|
-
rm: (path: PathLike, options?: MakeDirectoryOptions & {
|
899
|
-
recursive: boolean;
|
900
|
-
}) => Promise<void>;
|
901
|
-
copyFile: (source: PathLike, destination: PathLike) => Promise<void>;
|
902
|
-
readfile: (path: PathLike, options?: {
|
903
|
-
encoding: BufferEncoding;
|
904
|
-
flag?: string;
|
905
|
-
}) => Promise<string>;
|
906
|
-
stat: (path: PathLike) => Promise<Stats>;
|
907
|
-
unlink: (path: PathLike) => Promise<void>;
|
908
|
-
writefile: (path: PathLike, data: Uint8Array | string) => Promise<void>;
|
909
|
-
}
|
910
|
-
declare function join(...paths: string[]): string;
|
911
|
-
declare class sysContainer {
|
912
|
-
freight: NodeMap;
|
913
|
-
readonly id: string;
|
914
|
-
start(): Promise<void>;
|
915
|
-
readdir(path: PathLike, options?: (ObjectEncodingOptions & {
|
916
|
-
withFileTypes?: false | undefined;
|
917
|
-
recursive?: boolean;
|
918
|
-
}) | BufferEncoding | null | undefined): Promise<string[]>;
|
919
|
-
readdirent(path: PathLike, options: (ObjectEncodingOptions & {
|
920
|
-
withFileTypes: true;
|
921
|
-
recursive?: boolean;
|
922
|
-
}) | BufferEncoding | null | undefined): Promise<Dirent[]>;
|
923
|
-
readfile(path: PathLike, options?: {
|
924
|
-
encoding: BufferEncoding;
|
925
|
-
flag?: string;
|
926
|
-
}): Promise<Buffer>;
|
927
|
-
mkdir(path: PathLike, options: {
|
928
|
-
recursive: boolean;
|
929
|
-
}): Promise<string | undefined>;
|
930
|
-
rm(path: PathLike, options: MakeDirectoryOptions & {
|
931
|
-
recursive: boolean;
|
932
|
-
}): Promise<void>;
|
933
|
-
unlink(path: PathLike): Promise<void>;
|
934
|
-
writefile(path: PathLike, data: Uint8Array | string): Promise<void>;
|
935
|
-
copyFile(source: PathLike, destination: PathLike): Promise<void>;
|
936
|
-
stat(path: PathLike): Promise<Stats>;
|
937
|
-
fileURLToPath(url: string | URL): string;
|
938
|
-
dirname(path: string): string;
|
939
|
-
join(...args: string[]): string;
|
940
|
-
homedir: () => string;
|
941
|
-
logSeeded(method: string): void;
|
942
|
-
readonly runtime: typeof runtimeFn;
|
943
|
-
readonly env: EnvImpl;
|
944
|
-
}
|
945
|
-
declare const SysContainer: sysContainer;
|
946
|
-
|
947
|
-
declare function dataDir(name?: string, base?: string | URL): string;
|
948
|
-
|
949
|
-
interface LoggerOpts {
|
950
|
-
readonly logger?: Logger;
|
951
|
-
}
|
952
|
-
declare function ensureLogger(optsOrLogger: Partial<LoggerOpts> | Logger, componentName: string, ctx?: Record<string, unknown>): Logger;
|
953
|
-
type Joiner = (...toJoin: string[]) => string;
|
954
|
-
declare function getStore(url: URL, logger: Logger, joiner: Joiner): string;
|
955
|
-
declare function getKey(url: URL, logger: Logger): string;
|
956
|
-
declare function getName(url: URL, logger: Logger): string;
|
957
|
-
declare function exception2Result<T = void>(fn: () => Promise<T>): Promise<Result<T>>;
|
958
|
-
declare function exceptionWrapper<T, E extends Error>(fn: () => Promise<Result<T, E>>): Promise<Result<T, E>>;
|
959
|
-
|
960
|
-
declare function getPath(url: URL, logger: Logger): Promise<string>;
|
961
|
-
declare function getFileName(url: URL, key: string, logger: Logger): string;
|
962
|
-
declare function ensureIndexName(url: URL, name: string): string;
|
963
|
-
|
964
|
-
declare function toCryptoOpts(cryptoOpts?: Partial<CryptoOpts>): CryptoOpts;
|
965
|
-
|
966
|
-
declare const crypto_toCryptoOpts: typeof toCryptoOpts;
|
967
|
-
declare namespace crypto {
|
968
|
-
export { crypto_toCryptoOpts as toCryptoOpts };
|
969
|
-
}
|
1032
|
+
declare function getFileSystem(url: URI): Promise<SysFileSystem>;
|
1033
|
+
declare function getPath(url: URI, sthis: SuperThis): string;
|
1034
|
+
declare function getFileName(url: URI, sthis: SuperThis): string;
|
1035
|
+
declare function toArrayBuffer(buffer: Buffer | string): Uint8Array;
|
970
1036
|
|
971
1037
|
declare function encodeFile(blob: BlobLike): Promise<{
|
972
1038
|
cid: AnyLink;
|
@@ -980,27 +1046,89 @@ declare namespace files {
|
|
980
1046
|
export { files_decodeFile as decodeFile, files_encodeFile as encodeFile };
|
981
1047
|
}
|
982
1048
|
|
1049
|
+
declare class BlockIvKeyIdCodec implements BlockCodec<0x300539, Uint8Array> {
|
1050
|
+
readonly code = 3147065;
|
1051
|
+
readonly name = "Fireproof@encrypted-block:aes-gcm";
|
1052
|
+
readonly ko: KeyedCrypto;
|
1053
|
+
readonly iv?: Uint8Array;
|
1054
|
+
readonly opts: Partial<CodecOpts>;
|
1055
|
+
constructor(ko: KeyedCrypto, iv?: Uint8Array, opts?: CodecOpts);
|
1056
|
+
encode(data: Uint8Array): Promise<Uint8Array>;
|
1057
|
+
decode(abytes: Uint8Array | ArrayBuffer): Promise<Uint8Array>;
|
1058
|
+
}
|
1059
|
+
declare function keyedCryptoFactory(url: URI, kb: KeyBag, sthis: SuperThis): Promise<KeyedCrypto>;
|
1060
|
+
|
1061
|
+
type keyedCrypto_BlockIvKeyIdCodec = BlockIvKeyIdCodec;
|
1062
|
+
declare const keyedCrypto_BlockIvKeyIdCodec: typeof BlockIvKeyIdCodec;
|
1063
|
+
declare const keyedCrypto_keyedCryptoFactory: typeof keyedCryptoFactory;
|
1064
|
+
declare namespace keyedCrypto {
|
1065
|
+
export { keyedCrypto_BlockIvKeyIdCodec as BlockIvKeyIdCodec, keyedCrypto_keyedCryptoFactory as keyedCryptoFactory };
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
declare const Block: typeof Block$2;
|
1069
|
+
interface DecodeInput<T, Code extends number, Alg extends number> {
|
1070
|
+
bytes: ByteView<T>;
|
1071
|
+
codec: BlockDecoder<Code, T>;
|
1072
|
+
hasher: MultihashHasher<Alg>;
|
1073
|
+
}
|
1074
|
+
declare function decode<T, Code extends number, Alg extends number>({ bytes, codec, hasher, }: DecodeInput<T, Code, Alg>): Promise<BlockView<T, Code, Alg>>;
|
1075
|
+
interface EncodeInput<T, Code extends number, Alg extends number> {
|
1076
|
+
value: T;
|
1077
|
+
codec: BlockEncoder<Code, T>;
|
1078
|
+
hasher: MultihashHasher<Alg>;
|
1079
|
+
}
|
1080
|
+
declare function encode<T, Code extends number, Alg extends number>({ value, codec, hasher, }: EncodeInput<T, Code, Alg>): Promise<BlockView<T, Code, Alg>>;
|
1081
|
+
interface CreateInput<T, Code extends number, Alg extends number, V extends Version> {
|
1082
|
+
bytes: ByteView<T>;
|
1083
|
+
cid: Link<T, Code, Alg, V>;
|
1084
|
+
hasher: MultihashHasher<Alg>;
|
1085
|
+
codec: BlockDecoder<Code, T>;
|
1086
|
+
}
|
1087
|
+
declare function create<T, Code extends number, Alg extends number, V extends Version>({ bytes, cid, hasher, codec, }: CreateInput<T, Code, Alg, V>): Promise<BlockView<T, Code, Alg, V>>;
|
1088
|
+
type CreateUnsafeInput<T, Code extends number, Alg extends number, V extends Version> = {
|
1089
|
+
cid: Link<T, Code, Alg, V>;
|
1090
|
+
value: T;
|
1091
|
+
codec?: BlockDecoder<Code, T>;
|
1092
|
+
bytes: ByteView<T>;
|
1093
|
+
} | {
|
1094
|
+
cid: Link<T, Code, Alg, V>;
|
1095
|
+
value?: undefined;
|
1096
|
+
codec: BlockDecoder<Code, T>;
|
1097
|
+
bytes: ByteView<T>;
|
1098
|
+
};
|
1099
|
+
declare function createUnsafe<T, Code extends number, Alg extends number, V extends Version>({ bytes, cid, value: maybeValue, codec, }: CreateUnsafeInput<T, Code, Alg, V>): Promise<BlockView<T, Code, Alg, V>>;
|
1100
|
+
|
1101
|
+
declare const block_Block: typeof Block;
|
1102
|
+
declare const block_create: typeof create;
|
1103
|
+
declare const block_createUnsafe: typeof createUnsafe;
|
1104
|
+
declare const block_decode: typeof decode;
|
1105
|
+
declare const block_encode: typeof encode;
|
1106
|
+
declare namespace block {
|
1107
|
+
export { block_Block as Block, block_create as create, block_createUnsafe as createUnsafe, block_decode as decode, block_encode as encode };
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
declare const index$1_block: typeof block;
|
1111
|
+
declare namespace index$1 {
|
1112
|
+
export { index$1_block as block, codecInterface as codec };
|
1113
|
+
}
|
1114
|
+
|
983
1115
|
declare const FILESTORE_VERSION = "v0.19-file";
|
984
1116
|
|
985
1117
|
declare const INDEXDB_VERSION = "v0.19-indexdb";
|
986
1118
|
|
987
1119
|
declare const index_FILESTORE_VERSION: typeof FILESTORE_VERSION;
|
988
1120
|
declare const index_INDEXDB_VERSION: typeof INDEXDB_VERSION;
|
989
|
-
type index_NodeMap = NodeMap;
|
990
|
-
type index_Runtime = Runtime;
|
991
|
-
declare const index_SysContainer: typeof SysContainer;
|
992
|
-
declare const index_crypto: typeof crypto;
|
993
|
-
declare const index_dataDir: typeof dataDir;
|
994
|
-
declare const index_ensureIndexName: typeof ensureIndexName;
|
995
1121
|
declare const index_files: typeof files;
|
996
1122
|
declare const index_getFileName: typeof getFileName;
|
1123
|
+
declare const index_getFileSystem: typeof getFileSystem;
|
997
1124
|
declare const index_getPath: typeof getPath;
|
998
|
-
declare const
|
1125
|
+
declare const index_runtimeFn: typeof runtimeFn;
|
1126
|
+
declare const index_toArrayBuffer: typeof toArrayBuffer;
|
999
1127
|
declare namespace index {
|
1000
|
-
export { index_FILESTORE_VERSION as FILESTORE_VERSION, index_INDEXDB_VERSION as INDEXDB_VERSION,
|
1128
|
+
export { index_FILESTORE_VERSION as FILESTORE_VERSION, index_INDEXDB_VERSION as INDEXDB_VERSION, index_files as files, index_getFileName as getFileName, index_getFileSystem as getFileSystem, index_getPath as getPath, keyBag as kb, keyedCrypto as kc, index$1 as mf, index_runtimeFn as runtimeFn, index_toArrayBuffer as toArrayBuffer };
|
1001
1129
|
}
|
1002
1130
|
|
1003
1131
|
declare const PACKAGE_VERSION: string;
|
1004
1132
|
|
1005
|
-
export { type AllDocsQueryOpts, type AllDocsResponse, CRDT, type CRDTMeta, type ChangesOptions, type ChangesResponse, type ChangesResponseRow, type ClockHead, type ClockLink, type ConfigOpts, Database, type DocBase, type DocFileMeta, type DocFiles, type DocFragment, type DocLiteral, type DocObject, type DocRecord, type DocResponse, type DocSet, type DocTypes, type DocUpdate, type DocValue, type DocWithId, type Falsy, type FileTransactionMeta, type IdxMeta, type IdxMetaMap, Index, type IndexKey, type IndexKeyType, type IndexRow, type IndexRows, type IndexTransactionMeta, type IndexUpdate, type IndexUpdateString, type Joiner, type KeyLiteral, type ListenerFn, type
|
1133
|
+
export { type AllDocsQueryOpts, type AllDocsResponse, CRDT, type CRDTEntry, type CRDTMeta, type ChangesOptions, type ChangesResponse, type ChangesResponseRow, type ClockHead, type ClockLink, type ConfigOpts, type Connectable, Database, type DocBase, type DocFileMeta, type DocFiles, type DocFragment, type DocLiteral, type DocObject, type DocRecord, type DocResponse, type DocSet, type DocTypes, type DocUpdate, type DocValue, type DocWithId, type Falsy, type FileTransactionMeta, type IdxMeta, type IdxMetaMap, Index, type IndexKey, type IndexKeyType, type IndexRow, type IndexRows, type IndexTransactionMeta, type IndexUpdate, type IndexUpdateString, type Joiner, type KeyLiteral, type ListenerFn, type MapFn, type MetaType, type NoUpdateListenerFn, NotFoundError, PACKAGE_VERSION, type PathOps, type QueryOpts, type Store, type StoreType, type SuperThis, type SuperThisOpts, type SysFileSystem, type TextEndeCoder, UInt8ArrayEqual, type UnknownDoc, type UpdateListenerFn, index$3 as blockstore, index$3 as bs, dataDir, ensureLogger, ensureSuperLog, ensureSuperThis, exceptionWrapper, falsyToUndef, fireproof, getKey, getName, getStore, index$2 as index, isFalsy, isNotFoundError, index as rt, index as runtime, throwFalsy };
|
1006
1134
|
declare module '@fireproof/core'
|