@fireproof/core 0.19.8-dev-getcon → 0.19.9-dev-frag
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -0
- package/chunk-7EWIAXTM.js +7 -0
- package/chunk-7EWIAXTM.js.map +1 -0
- package/chunk-JO5AVWG7.js +67 -0
- package/chunk-JO5AVWG7.js.map +1 -0
- package/chunk-PB4BKL4O.js +7 -0
- package/chunk-PB4BKL4O.js.map +1 -0
- package/chunk-YS4GL6OK.js +266 -0
- package/chunk-YS4GL6OK.js.map +1 -0
- package/{store-indexdb-WLRSICCB.js → gateway-IZRHJWPE.js} +48 -80
- package/gateway-IZRHJWPE.js.map +1 -0
- package/gateway-YSNUK2L3.js +145 -0
- package/gateway-YSNUK2L3.js.map +1 -0
- package/index.cjs +2132 -1783
- package/index.cjs.map +1 -1
- package/index.d.cts +613 -513
- package/index.d.ts +613 -513
- package/index.global.js +19367 -20108
- package/index.global.js.map +1 -1
- package/index.js +1512 -1022
- package/index.js.map +1 -1
- package/key-bag-file-NMEBFSPM.js +54 -0
- package/key-bag-file-NMEBFSPM.js.map +1 -0
- package/key-bag-indexdb-X5V6GNBZ.js +50 -0
- package/key-bag-indexdb-X5V6GNBZ.js.map +1 -0
- package/mem-filesystem-B6C6QOIP.js +41 -0
- package/mem-filesystem-B6C6QOIP.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-5JLBSHKQ.js +41 -0
- package/node-filesystem-5JLBSHKQ.js.map +1 -0
- package/package.json +8 -7
- package/tests/blockstore/fragment-gateway.test.ts +107 -0
- package/tests/blockstore/keyed-crypto.test.ts +302 -0
- package/tests/blockstore/loader.test.ts +24 -19
- package/tests/blockstore/store.test.ts +34 -28
- package/tests/blockstore/transaction.test.ts +19 -15
- 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 +6 -4
- package/tests/fireproof/indexer.test.ts +34 -27
- package/tests/fireproof/utils.test.ts +65 -0
- package/tests/helpers.ts +25 -57
- package/utils-IZPK4QS7.js +14 -0
- package/utils-IZPK4QS7.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.cts
CHANGED
@@ -1,137 +1,161 @@
|
|
1
|
-
import
|
1
|
+
import * as _adviser_cement from '@adviser/cement';
|
2
|
+
import { Logger, URI, Result, CoerceURI, ResolveOnce, ResolveSeq, CryptoRuntime, Future, CTCryptoKey, EnvFactoryOpts, Env } from '@adviser/cement';
|
2
3
|
export { Logger, Result } from '@adviser/cement';
|
3
4
|
import { EventLink } from '@web3-storage/pail/clock/api';
|
4
5
|
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';
|
6
|
+
import { ByteView, ArrayBufferView, Version, Block as Block$1, Link, CID, BlockView, MultihashHasher } from 'multiformats';
|
8
7
|
import { MemoryBlockstore } from '@web3-storage/pail/block';
|
9
8
|
import { BlockFetcher as BlockFetcher$1 } from '@web3-storage/pail/api';
|
9
|
+
import * as _ipld_car_dist_src_reader_browser_js from '@ipld/car/dist/src/reader-browser.js';
|
10
|
+
import { IDBPDatabase } from 'idb';
|
11
|
+
import { CarReader } from '@ipld/car';
|
12
|
+
import { PathLike, MakeDirectoryOptions, Stats } from 'fs';
|
10
13
|
import { ProllyNode as ProllyNode$1 } from 'prolly-trees/db-index';
|
11
14
|
import { EventBlock } from '@web3-storage/pail/clock';
|
12
|
-
import {
|
15
|
+
import { Block as Block$2 } from 'multiformats/block';
|
13
16
|
|
14
|
-
interface
|
15
|
-
|
17
|
+
interface BlockEncoder<Code extends number, T> {
|
18
|
+
name: string;
|
19
|
+
code: Code;
|
20
|
+
encode(data: T): ByteView<T> | PromiseLike<ByteView<T>>;
|
21
|
+
}
|
22
|
+
interface BlockDecoder<Code extends number, T> {
|
23
|
+
code: Code;
|
24
|
+
decode(bytes: ByteView<T> | ArrayBufferView<T>): T | PromiseLike<T>;
|
25
|
+
}
|
26
|
+
interface BlockCodec<Code extends number, T> extends BlockEncoder<Code, T>, BlockDecoder<Code, T> {
|
27
|
+
}
|
28
|
+
|
29
|
+
declare const codecInterface_ArrayBufferView: typeof ArrayBufferView;
|
30
|
+
type codecInterface_BlockCodec<Code extends number, T> = BlockCodec<Code, T>;
|
31
|
+
type codecInterface_BlockDecoder<Code extends number, T> = BlockDecoder<Code, T>;
|
32
|
+
type codecInterface_BlockEncoder<Code extends number, T> = BlockEncoder<Code, T>;
|
33
|
+
declare const codecInterface_ByteView: typeof ByteView;
|
34
|
+
declare namespace codecInterface {
|
35
|
+
export { codecInterface_ArrayBufferView as ArrayBufferView, type codecInterface_BlockCodec as BlockCodec, type codecInterface_BlockDecoder as BlockDecoder, type codecInterface_BlockEncoder as BlockEncoder, codecInterface_ByteView as ByteView };
|
36
|
+
}
|
37
|
+
|
38
|
+
declare function ensureSuperThis(osthis?: Partial<SuperThisOpts>): SuperThis;
|
39
|
+
declare function ensureSuperLog(sthis: SuperThis, componentName: string, ctx?: Record<string, unknown>): SuperThis;
|
40
|
+
declare function ensureLogger(sthis: SuperThis, componentName: string, ctx?: Record<string, unknown>): Logger;
|
41
|
+
type Joiner = (...toJoin: string[]) => string;
|
42
|
+
interface Store {
|
43
|
+
readonly store: StoreType;
|
44
|
+
readonly name: string;
|
16
45
|
}
|
46
|
+
declare function getStore(url: URI, sthis: SuperThis, joiner: Joiner): Store;
|
47
|
+
declare function getKey(url: URI, logger: Logger): string;
|
48
|
+
declare function getName(sthis: SuperThis, url: URI): string;
|
49
|
+
declare function exception2Result<T = void>(fn: () => Promise<T>): Promise<Result<T>>;
|
50
|
+
declare function exceptionWrapper<T, E extends Error>(fn: () => Promise<Result<T, E>>): Promise<Result<T, E>>;
|
17
51
|
declare class NotFoundError extends Error {
|
18
52
|
readonly code = "ENOENT";
|
19
53
|
}
|
20
54
|
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
|
-
}
|
55
|
+
declare function dataDir(sthis: SuperThis, name?: string, base?: CoerceURI): URI;
|
56
|
+
declare function UInt8ArrayEqual(a: Uint8Array, b: Uint8Array): boolean;
|
32
57
|
|
33
|
-
|
34
|
-
|
35
|
-
readonly
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
58
|
+
interface KeyBagCtx {
|
59
|
+
readonly dirName: string;
|
60
|
+
readonly sysFS: SysFileSystem;
|
61
|
+
readonly fName: string;
|
62
|
+
}
|
63
|
+
declare class KeyBagProviderFile implements KeyBagProvider {
|
64
|
+
_prepare(id: string): Promise<KeyBagCtx>;
|
65
|
+
private readonly url;
|
66
|
+
readonly logger: Logger;
|
67
|
+
readonly sthis: SuperThis;
|
68
|
+
constructor(url: URI, sthis: SuperThis);
|
69
|
+
get(id: string): Promise<KeyItem | undefined>;
|
70
|
+
set(id: string, item: KeyItem): Promise<void>;
|
41
71
|
}
|
42
|
-
|
43
|
-
|
44
|
-
readonly
|
45
|
-
readonly
|
46
|
-
readonly
|
47
|
-
ready(): Promise<void>;
|
48
|
-
close(): Promise<void>;
|
49
|
-
destroy(): Promise<void>;
|
72
|
+
|
73
|
+
declare class KeyBagProviderIndexDB implements KeyBagProvider {
|
74
|
+
readonly _db: ResolveOnce<IDBPDatabase<unknown>, void>;
|
75
|
+
readonly dbName: string;
|
76
|
+
readonly url: URI;
|
50
77
|
readonly logger: Logger;
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
entries(): AsyncIterableIterator<AnyBlock>;
|
78
|
+
readonly sthis: SuperThis;
|
79
|
+
constructor(url: URI, sthis: SuperThis);
|
80
|
+
_prepare(): Promise<IDBPDatabase<unknown>>;
|
81
|
+
get(id: string): Promise<KeyItem | undefined>;
|
82
|
+
set(id: string, item: KeyItem): Promise<void>;
|
57
83
|
}
|
58
|
-
|
59
|
-
|
60
|
-
readonly
|
61
|
-
ready(): Promise<void>;
|
62
|
-
close(): Promise<void>;
|
63
|
-
destroy(): Promise<void>;
|
64
|
-
compacting: boolean;
|
84
|
+
|
85
|
+
declare class KeyBag {
|
86
|
+
readonly rt: KeyBagRuntime;
|
65
87
|
readonly logger: Logger;
|
66
|
-
constructor(
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
88
|
+
constructor(rt: KeyBagRuntime);
|
89
|
+
subtleKey(key: string): Promise<_adviser_cement.CTCryptoKey>;
|
90
|
+
ensureKeyFromUrl(url: URI, keyFactory: () => string): Promise<Result<URI>>;
|
91
|
+
toKeyWithFingerPrint(keyStr: string): Promise<Result<KeyWithFingerPrint>>;
|
92
|
+
readonly _seq: ResolveSeq<Result<KeyWithFingerPrint, Error>, void>;
|
93
|
+
setNamedKey(name: string, key: string): Promise<Result<KeyWithFingerPrint>>;
|
94
|
+
_setNamedKey(name: string, key: string): Promise<Result<KeyWithFingerPrint>>;
|
95
|
+
getNamedKey(name: string, failIfNotFound?: boolean): Promise<Result<KeyWithFingerPrint>>;
|
96
|
+
}
|
97
|
+
interface KeyItem {
|
98
|
+
readonly name: string;
|
99
|
+
readonly key: string;
|
75
100
|
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
101
|
+
type KeyBagFile = Record<string, KeyItem>;
|
102
|
+
interface KeyBagOpts {
|
103
|
+
readonly url: CoerceURI;
|
104
|
+
readonly crypto: CryptoRuntime;
|
105
|
+
readonly keyLength: number;
|
106
|
+
readonly keyRuntime: KeyBagRuntime;
|
81
107
|
}
|
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;
|
108
|
+
interface KeyBagProvider {
|
109
|
+
get(id: string): Promise<KeyItem | undefined>;
|
110
|
+
set(id: string, item: KeyItem): Promise<void>;
|
94
111
|
}
|
95
|
-
interface
|
112
|
+
interface KeyBagRuntime {
|
113
|
+
readonly url: URI;
|
114
|
+
readonly crypto: CryptoRuntime;
|
96
115
|
readonly logger: Logger;
|
97
|
-
readonly
|
98
|
-
readonly
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
readonly
|
105
|
-
readonly
|
106
|
-
readonly
|
116
|
+
readonly sthis: SuperThis;
|
117
|
+
readonly keyLength: number;
|
118
|
+
getBag(): Promise<KeyBagProvider>;
|
119
|
+
id(): string;
|
120
|
+
}
|
121
|
+
type KeyBackProviderFactory = (url: URI, sthis: SuperThis) => Promise<KeyBagProvider>;
|
122
|
+
interface KeyBagProviderFactoryItem {
|
123
|
+
readonly protocol: string;
|
124
|
+
readonly override?: boolean;
|
125
|
+
readonly factory: KeyBackProviderFactory;
|
126
|
+
}
|
127
|
+
declare function registerKeyBagProviderFactory(item: KeyBagProviderFactoryItem): void;
|
128
|
+
declare function getKeyBag(sthis: SuperThis, kbo?: Partial<KeyBagOpts>): Promise<KeyBag>;
|
129
|
+
|
130
|
+
type keyBag_KeyBackProviderFactory = KeyBackProviderFactory;
|
131
|
+
type keyBag_KeyBag = KeyBag;
|
132
|
+
declare const keyBag_KeyBag: typeof KeyBag;
|
133
|
+
type keyBag_KeyBagFile = KeyBagFile;
|
134
|
+
type keyBag_KeyBagOpts = KeyBagOpts;
|
135
|
+
type keyBag_KeyBagProvider = KeyBagProvider;
|
136
|
+
type keyBag_KeyBagProviderFactoryItem = KeyBagProviderFactoryItem;
|
137
|
+
type keyBag_KeyBagProviderFile = KeyBagProviderFile;
|
138
|
+
declare const keyBag_KeyBagProviderFile: typeof KeyBagProviderFile;
|
139
|
+
type keyBag_KeyBagProviderIndexDB = KeyBagProviderIndexDB;
|
140
|
+
declare const keyBag_KeyBagProviderIndexDB: typeof KeyBagProviderIndexDB;
|
141
|
+
type keyBag_KeyBagRuntime = KeyBagRuntime;
|
142
|
+
type keyBag_KeyItem = KeyItem;
|
143
|
+
declare const keyBag_getKeyBag: typeof getKeyBag;
|
144
|
+
declare const keyBag_registerKeyBagProviderFactory: typeof registerKeyBagProviderFactory;
|
145
|
+
declare namespace keyBag {
|
146
|
+
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 };
|
107
147
|
}
|
108
148
|
|
109
|
-
type QueueFunction = () => Promise<
|
149
|
+
type QueueFunction<T = void> = () => Promise<T>;
|
110
150
|
declare class CommitQueue<T = void> {
|
111
|
-
readonly queue: QueueFunction[];
|
151
|
+
readonly queue: QueueFunction<void>[];
|
112
152
|
processing: boolean;
|
113
|
-
|
153
|
+
readonly _waitIdleItems: Set<Future<void>>;
|
154
|
+
waitIdle(): Promise<void>;
|
155
|
+
enqueue(fn: QueueFunction<T>): Promise<T>;
|
114
156
|
processNext(): void;
|
115
157
|
}
|
116
158
|
|
117
|
-
type AbstractRemoteMetaStore = MetaStore & {
|
118
|
-
handleByteHeads(byteHeads: Uint8Array[], branch?: string): Promise<DbMeta[]>;
|
119
|
-
};
|
120
|
-
declare abstract class Loadable {
|
121
|
-
name: string;
|
122
|
-
abstract readonly logger: Logger;
|
123
|
-
abstract readonly ebOpts: BlockstoreRuntime;
|
124
|
-
remoteCarStore?: DataStore;
|
125
|
-
abstract carStore(): Promise<DataStore>;
|
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>;
|
134
|
-
}
|
135
159
|
declare class Loader implements Loadable {
|
136
160
|
readonly name: string;
|
137
161
|
readonly ebOpts: BlockstoreRuntime;
|
@@ -140,134 +164,131 @@ declare class Loader implements Loadable {
|
|
140
164
|
readonly carReaders: Map<string, Promise<CarReader>>;
|
141
165
|
readonly seenCompacted: Set<string>;
|
142
166
|
readonly processedCars: Set<string>;
|
167
|
+
readonly sthis: SuperThis;
|
143
168
|
carLog: CarLog;
|
144
|
-
key?: string;
|
145
|
-
keyId?: string;
|
146
|
-
remoteMetaStore?: AbstractRemoteMetaStore;
|
147
169
|
remoteCarStore?: DataStore;
|
148
170
|
remoteFileStore?: DataStore;
|
149
171
|
private getBlockCache;
|
150
172
|
private seenMeta;
|
151
173
|
private writeLimit;
|
174
|
+
keyBag(): Promise<KeyBag>;
|
152
175
|
carStore(): Promise<DataStore>;
|
153
176
|
fileStore(): Promise<DataStore>;
|
154
|
-
|
177
|
+
WALStore(): Promise<WALStore>;
|
155
178
|
metaStore(): Promise<MetaStore>;
|
156
179
|
readonly onceReady: ResolveOnce<void, void>;
|
157
180
|
ready(): Promise<void>;
|
158
181
|
close(): Promise<void>;
|
159
182
|
destroy(): Promise<void>;
|
160
183
|
readonly logger: Logger;
|
161
|
-
constructor(name: string, ebOpts: BlockstoreOpts);
|
184
|
+
constructor(name: string, ebOpts: BlockstoreOpts, sthis: SuperThis);
|
162
185
|
handleDbMetasFromStore(metas: DbMeta[]): Promise<void>;
|
163
186
|
mergeDbMetaIntoClock(meta: DbMeta): Promise<void>;
|
164
|
-
protected ingestKeyFromMeta(meta: DbMeta): Promise<void>;
|
165
187
|
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>;
|
188
|
+
commitFiles(t: CarTransaction, done: TransactionMeta): Promise<CarGroup>;
|
189
|
+
loadFileCar(cid: AnyLink): Promise<CarReader>;
|
170
190
|
commit<T = TransactionMeta>(t: CarTransaction, done: T, opts?: CommitOpts): Promise<CarGroup>;
|
191
|
+
updateCarLog<T>(cids: CarGroup, fp: CarHeader<T>, compact: boolean): Promise<void>;
|
171
192
|
cacheTransaction(t: CarTransaction): Promise<void>;
|
172
193
|
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
194
|
removeCidsForCompact(cid: AnyLink): Promise<void>;
|
186
195
|
entries(cache?: boolean): AsyncIterableIterator<AnyBlock>;
|
187
196
|
getBlock(cid: AnyLink): Promise<AnyBlock | Falsy>;
|
188
|
-
protected makeCarHeader<T>(meta: T, cars: CarLog, compact?: boolean): CarHeader<T>;
|
189
197
|
loadCar(cid: AnyLink): Promise<CarReader>;
|
190
|
-
|
191
|
-
protected
|
192
|
-
protected setKey(key: string): Promise<void>;
|
198
|
+
makeDecoderAndCarReader(cid: AnyLink, local: DataStore, remote?: DataStore): Promise<_ipld_car_dist_src_reader_browser_js.CarReader>;
|
199
|
+
protected storesLoadCar(cid: AnyLink, local: DataStore, remote?: DataStore): Promise<CarReader>;
|
193
200
|
protected getMoreReaders(cids: AnyLink[]): Promise<void>;
|
194
201
|
}
|
195
202
|
|
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>>;
|
203
|
+
type BlockFetcher = BlockFetcher$1;
|
204
|
+
interface CarTransactionOpts {
|
205
|
+
readonly add: boolean;
|
206
|
+
readonly noLoader: boolean;
|
219
207
|
}
|
220
|
-
|
221
|
-
readonly
|
208
|
+
declare class CarTransaction extends MemoryBlockstore implements CarMakeable {
|
209
|
+
readonly parent: BaseBlockstore;
|
210
|
+
constructor(parent: BaseBlockstore, opts?: CarTransactionOpts);
|
211
|
+
get<T, C extends number, A extends number, V extends Version>(cid: AnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
212
|
+
superGet(cid: AnyLink): Promise<AnyBlock | undefined>;
|
222
213
|
}
|
223
|
-
declare class
|
224
|
-
readonly
|
225
|
-
readonly
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
214
|
+
declare class BaseBlockstore implements BlockFetcher {
|
215
|
+
readonly transactions: Set<CarTransaction>;
|
216
|
+
readonly ebOpts: BlockstoreRuntime;
|
217
|
+
readonly sthis: SuperThis;
|
218
|
+
readonly loader?: Loader;
|
219
|
+
readonly name?: string;
|
220
|
+
ready(): Promise<void>;
|
221
|
+
close(): Promise<void>;
|
222
|
+
destroy(): Promise<void>;
|
223
|
+
readonly logger: Logger;
|
224
|
+
constructor(ebOpts?: BlockstoreOpts);
|
225
|
+
get<T, C extends number, A extends number, V extends Version>(cid: AnyAnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
226
|
+
put(cid: AnyAnyLink, block: Uint8Array): Promise<void>;
|
227
|
+
lastTxMeta?: unknown;
|
228
|
+
transaction<M extends TransactionMeta>(fn: (t: CarTransaction) => Promise<M>, _opts?: CarTransactionOpts): Promise<TransactionWrapper<M>>;
|
229
|
+
entries(): AsyncIterableIterator<AnyBlock>;
|
233
230
|
}
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
231
|
+
declare class EncryptedBlockstore extends BaseBlockstore {
|
232
|
+
readonly name: string;
|
233
|
+
readonly loader: Loader;
|
234
|
+
ready(): Promise<void>;
|
235
|
+
close(): Promise<void>;
|
236
|
+
destroy(): Promise<void>;
|
237
|
+
compacting: boolean;
|
238
|
+
readonly logger: Logger;
|
239
|
+
constructor(sthis: SuperThis, ebOpts: BlockstoreOpts);
|
240
|
+
get<T, C extends number, A extends number, V extends Version>(cid: AnyAnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
241
|
+
transaction<M extends TransactionMeta>(fn: (t: CarTransaction) => Promise<M>, opts?: {
|
242
|
+
noLoader: boolean;
|
243
|
+
}): Promise<TransactionWrapper<M>>;
|
244
|
+
getFile(car: AnyLink, cid: AnyLink): Promise<Uint8Array>;
|
245
|
+
compact(): Promise<void>;
|
246
|
+
defaultCompact(blocks: CompactionFetcher, logger: Logger): Promise<TransactionMeta>;
|
247
|
+
entries(): AsyncIterableIterator<AnyBlock>;
|
241
248
|
}
|
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>;
|
249
|
+
declare class CompactionFetcher implements BlockFetcher {
|
250
|
+
readonly blockstore: EncryptedBlockstore;
|
251
|
+
readonly loggedBlocks: CarTransaction;
|
252
|
+
constructor(blocks: EncryptedBlockstore);
|
253
|
+
get<T, C extends number, A extends number, V extends Version>(cid: AnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
261
254
|
}
|
262
255
|
|
263
256
|
type AnyLink = Link<unknown, number, number, Version>;
|
264
257
|
type CarGroup = AnyLink[];
|
265
258
|
type CarLog = CarGroup[];
|
266
259
|
type AnyAnyLink = Link<unknown, number, number, Version>;
|
260
|
+
type AnyLinkFn = (cid: AnyLink) => Promise<AnyBlock | undefined>;
|
267
261
|
interface AnyBlock {
|
268
262
|
readonly cid: Link<unknown, number, number, Version>;
|
269
263
|
readonly bytes: Uint8Array;
|
270
264
|
}
|
265
|
+
interface CIDBlock {
|
266
|
+
readonly cid: CID<unknown, number, number, Version>;
|
267
|
+
readonly bytes: Uint8Array;
|
268
|
+
}
|
269
|
+
declare function toCIDBlock(block: AnyBlock): CIDBlock;
|
270
|
+
interface AnyAnyBlock {
|
271
|
+
readonly cid: AnyAnyLink;
|
272
|
+
readonly bytes: Uint8Array;
|
273
|
+
}
|
274
|
+
interface IvKeyIdData {
|
275
|
+
readonly iv: Uint8Array;
|
276
|
+
readonly keyId: Uint8Array;
|
277
|
+
readonly data: Uint8Array;
|
278
|
+
}
|
279
|
+
interface IvAndBytes {
|
280
|
+
readonly bytes: Uint8Array;
|
281
|
+
readonly iv: Uint8Array;
|
282
|
+
}
|
283
|
+
interface BytesWithIv {
|
284
|
+
readonly bytes: Uint8Array;
|
285
|
+
readonly iv?: Uint8Array;
|
286
|
+
}
|
287
|
+
interface AnyDecodedBlock {
|
288
|
+
readonly cid: AnyLink;
|
289
|
+
readonly bytes: Uint8Array;
|
290
|
+
readonly value: Uint8Array;
|
291
|
+
}
|
271
292
|
interface CarMakeable {
|
272
293
|
entries(): Iterable<AnyBlock>;
|
273
294
|
get(cid: AnyLink): Promise<AnyBlock | undefined>;
|
@@ -283,77 +304,31 @@ interface TransactionWrapper<M extends TransactionMeta> {
|
|
283
304
|
t: CarTransaction;
|
284
305
|
}
|
285
306
|
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;
|
307
|
+
interface EncryptedBlock {
|
308
|
+
readonly value: IvAndBytes;
|
310
309
|
}
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
}
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
}
|
319
|
-
interface
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
type FPKeyType = "private" | "public" | "secret";
|
327
|
-
interface FPCryptoKey {
|
328
|
-
readonly algorithm: FPAlgorithm;
|
329
|
-
readonly extractable: boolean;
|
330
|
-
readonly type: FPKeyType;
|
331
|
-
readonly usages: FPKeyUsage[];
|
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: {
|
310
|
+
interface KeyWithFingerPrint {
|
311
|
+
readonly fingerPrint: string;
|
312
|
+
readonly key: CTCryptoKey;
|
313
|
+
}
|
314
|
+
interface CodecOpts {
|
315
|
+
readonly ivCalc: "random" | "hash";
|
316
|
+
readonly noIVVerify: boolean;
|
317
|
+
}
|
318
|
+
interface KeyedCrypto {
|
319
|
+
readonly ivLength: number;
|
320
|
+
readonly logger: Logger;
|
321
|
+
readonly crypto: CryptoRuntime;
|
322
|
+
readonly url: URI;
|
323
|
+
fingerPrint(): Promise<string>;
|
324
|
+
algo(iv?: Uint8Array): {
|
351
325
|
name: string;
|
352
326
|
iv: Uint8Array;
|
353
327
|
tagLength: number;
|
354
|
-
}
|
355
|
-
|
356
|
-
|
328
|
+
};
|
329
|
+
codec(iv?: Uint8Array, codecOpts?: Partial<CodecOpts>): BlockCodec<number, Uint8Array>;
|
330
|
+
_decrypt(data: IvAndBytes): Promise<Uint8Array>;
|
331
|
+
_encrypt(data: BytesWithIv): Promise<Uint8Array>;
|
357
332
|
}
|
358
333
|
interface BlobLike {
|
359
334
|
stream: () => ReadableStream;
|
@@ -361,7 +336,7 @@ interface BlobLike {
|
|
361
336
|
interface StoreFactory {
|
362
337
|
makeMetaStore?: (loader: Loadable) => Promise<MetaStore>;
|
363
338
|
makeDataStore?: (loader: Loadable) => Promise<DataStore>;
|
364
|
-
|
339
|
+
makeWALStore?: (loader: Loadable) => Promise<WALStore>;
|
365
340
|
encodeFile?: (blob: BlobLike) => Promise<{
|
366
341
|
cid: AnyLink;
|
367
342
|
blocks: AnyBlock[];
|
@@ -371,20 +346,17 @@ interface StoreFactory {
|
|
371
346
|
interface StoreOpts extends StoreFactory {
|
372
347
|
readonly isIndex?: string;
|
373
348
|
readonly stores?: {
|
374
|
-
readonly base?:
|
375
|
-
readonly meta?:
|
376
|
-
readonly data?:
|
377
|
-
readonly index?:
|
378
|
-
readonly
|
349
|
+
readonly base?: CoerceURI;
|
350
|
+
readonly meta?: CoerceURI;
|
351
|
+
readonly data?: CoerceURI;
|
352
|
+
readonly index?: CoerceURI;
|
353
|
+
readonly wal?: CoerceURI;
|
379
354
|
};
|
380
355
|
}
|
381
|
-
interface TestStore {
|
382
|
-
get(url: URL, key: string): Promise<Uint8Array>;
|
383
|
-
}
|
384
356
|
interface StoreRuntime {
|
385
357
|
makeMetaStore(loader: Loadable): Promise<MetaStore>;
|
386
358
|
makeDataStore(loader: Loadable): Promise<DataStore>;
|
387
|
-
|
359
|
+
makeWALStore(loader: Loadable): Promise<WALStore>;
|
388
360
|
encodeFile(blob: BlobLike): Promise<{
|
389
361
|
cid: AnyLink;
|
390
362
|
blocks: AnyBlock[];
|
@@ -394,47 +366,167 @@ interface StoreRuntime {
|
|
394
366
|
interface CommitOpts {
|
395
367
|
readonly noLoader?: boolean;
|
396
368
|
readonly compact?: boolean;
|
397
|
-
readonly public?: boolean;
|
398
369
|
}
|
399
370
|
interface DbMeta {
|
400
371
|
readonly cars: CarGroup;
|
401
|
-
key?: string;
|
402
|
-
}
|
403
|
-
interface UploadMetaFnParams {
|
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
372
|
}
|
373
|
+
type LoadHandler = (dbMetas: DbMeta[]) => Promise<void>;
|
423
374
|
interface Connection {
|
424
375
|
readonly loader?: Loadable;
|
425
376
|
readonly loaded: Promise<void>;
|
426
|
-
|
377
|
+
connectMeta_X({ loader }: {
|
427
378
|
loader?: Loadable;
|
428
379
|
}): void;
|
429
|
-
|
380
|
+
connectStorage_X({ loader }: {
|
430
381
|
loader?: Loadable;
|
431
382
|
}): void;
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
383
|
+
}
|
384
|
+
interface BaseStore {
|
385
|
+
readonly storeType: StoreType;
|
386
|
+
url(): URI;
|
387
|
+
readonly name: string;
|
388
|
+
onStarted(fn: () => void): void;
|
389
|
+
onClosed(fn: () => void): void;
|
390
|
+
keyedCrypto(): Promise<KeyedCrypto>;
|
391
|
+
close(): Promise<Result<void>>;
|
392
|
+
destroy(): Promise<Result<void>>;
|
393
|
+
readonly ready?: () => Promise<void>;
|
394
|
+
start(): Promise<Result<URI>>;
|
395
|
+
}
|
396
|
+
interface MetaStore extends BaseStore {
|
397
|
+
readonly storeType: "meta";
|
398
|
+
load(branch?: string): Promise<DbMeta[] | Falsy>;
|
399
|
+
save(meta: DbMeta, branch?: string): Promise<Result<void>>;
|
400
|
+
}
|
401
|
+
interface RemoteMetaStore extends MetaStore {
|
402
|
+
handleByteHeads(byteHeads: Uint8Array[], branch?: string): Promise<DbMeta[]>;
|
403
|
+
}
|
404
|
+
interface DataSaveOpts {
|
405
|
+
readonly public: boolean;
|
406
|
+
}
|
407
|
+
interface DataStore extends BaseStore {
|
408
|
+
readonly storeType: "data";
|
409
|
+
load(cid: AnyLink): Promise<AnyBlock>;
|
410
|
+
save(car: AnyBlock, opts?: DataSaveOpts): Promise<void>;
|
411
|
+
remove(cid: AnyLink): Promise<Result<void>>;
|
412
|
+
}
|
413
|
+
interface WALState {
|
414
|
+
operations: DbMeta[];
|
415
|
+
noLoaderOps: DbMeta[];
|
416
|
+
fileOperations: {
|
417
|
+
readonly cid: AnyLink;
|
418
|
+
readonly public: boolean;
|
419
|
+
}[];
|
420
|
+
}
|
421
|
+
interface WALStore extends BaseStore {
|
422
|
+
readonly storeType: "wal";
|
423
|
+
ready: () => Promise<void>;
|
424
|
+
readonly processing?: Promise<void> | undefined;
|
425
|
+
readonly processQueue: CommitQueue<void>;
|
426
|
+
process(): Promise<void>;
|
427
|
+
enqueue(dbMeta: DbMeta, opts: CommitOpts): Promise<void>;
|
428
|
+
enqueueFile(fileCid: AnyLink): Promise<void>;
|
429
|
+
load(): Promise<WALState | Falsy>;
|
430
|
+
save(state: WALState): Promise<void>;
|
431
|
+
}
|
432
|
+
type CompactFetcher = BlockFetcher & {
|
433
|
+
readonly loggedBlocks: CarTransaction;
|
434
|
+
};
|
435
|
+
type CompactFn = (blocks: CompactFetcher) => Promise<TransactionMeta>;
|
436
|
+
type BlockstoreOpts = Partial<{
|
437
|
+
readonly logger: Logger;
|
438
|
+
readonly applyMeta: (meta: TransactionMeta, snap?: boolean) => Promise<void>;
|
439
|
+
readonly compact: CompactFn;
|
440
|
+
readonly autoCompact: number;
|
441
|
+
readonly crypto: CryptoRuntime;
|
442
|
+
readonly store: StoreOpts;
|
443
|
+
readonly keyBag: KeyBagOpts;
|
444
|
+
readonly public: boolean;
|
445
|
+
readonly meta: DbMeta;
|
446
|
+
readonly name: string;
|
447
|
+
readonly threshold: number;
|
448
|
+
}>;
|
449
|
+
interface BlockstoreRuntime {
|
450
|
+
readonly logger: Logger;
|
451
|
+
readonly applyMeta: (meta: TransactionMeta, snap?: boolean) => Promise<void>;
|
452
|
+
readonly compact: CompactFn;
|
453
|
+
readonly autoCompact: number;
|
454
|
+
readonly crypto: CryptoRuntime;
|
455
|
+
readonly store: StoreOpts;
|
456
|
+
readonly storeRuntime: StoreRuntime;
|
457
|
+
readonly keyBag: Partial<KeyBagOpts>;
|
458
|
+
readonly meta?: DbMeta;
|
459
|
+
readonly name?: string;
|
460
|
+
readonly threshold: number;
|
461
|
+
}
|
462
|
+
interface Loadable {
|
463
|
+
readonly name: string;
|
464
|
+
readonly sthis: SuperThis;
|
465
|
+
readonly ebOpts: BlockstoreRuntime;
|
466
|
+
remoteCarStore?: DataStore;
|
467
|
+
carStore(): Promise<DataStore>;
|
468
|
+
carLog: CarLog;
|
469
|
+
remoteMetaStore?: RemoteMetaStore;
|
470
|
+
remoteFileStore?: DataStore;
|
471
|
+
ready(): Promise<void>;
|
472
|
+
close(): Promise<void>;
|
473
|
+
fileStore(): Promise<DataStore>;
|
474
|
+
WALStore(): Promise<WALStore>;
|
475
|
+
handleDbMetasFromStore(metas: DbMeta[]): Promise<void>;
|
476
|
+
}
|
477
|
+
|
478
|
+
interface GatewayOpts {
|
479
|
+
readonly gateway: Gateway;
|
480
|
+
}
|
481
|
+
type GetResult = Result<Uint8Array, NotFoundError | Error>;
|
482
|
+
type VoidResult = Result<void>;
|
483
|
+
interface TestGateway {
|
484
|
+
get(url: URI, key: string): Promise<Uint8Array>;
|
485
|
+
}
|
486
|
+
interface Gateway {
|
487
|
+
buildUrl(baseUrl: URI, key: string): Promise<Result<URI>>;
|
488
|
+
start(baseUrl: URI): Promise<Result<URI>>;
|
489
|
+
close(baseUrl: URI): Promise<VoidResult>;
|
490
|
+
destroy(baseUrl: URI): Promise<VoidResult>;
|
491
|
+
put(url: URI, body: Uint8Array): Promise<VoidResult>;
|
492
|
+
get(url: URI): Promise<GetResult>;
|
493
|
+
delete(url: URI): Promise<VoidResult>;
|
494
|
+
}
|
495
|
+
|
496
|
+
interface GatewayFactoryItem {
|
497
|
+
readonly protocol: string;
|
498
|
+
readonly overrideBaseURL?: string;
|
499
|
+
readonly overrideRegistration?: boolean;
|
500
|
+
readonly gateway: (sthis: SuperThis) => Promise<Gateway>;
|
501
|
+
readonly test: (sthis: SuperThis) => Promise<TestGateway>;
|
502
|
+
}
|
503
|
+
interface GatewayReady {
|
504
|
+
readonly gateway: Gateway;
|
505
|
+
readonly test: TestGateway;
|
506
|
+
}
|
507
|
+
declare function getGatewayFromURL(url: URI, sthis: SuperThis): Promise<GatewayReady | undefined>;
|
508
|
+
declare function registerStoreProtocol(item: GatewayFactoryItem): () => void;
|
509
|
+
declare function testStoreFactory(url: URI, sthis: SuperThis): Promise<TestGateway>;
|
510
|
+
declare function ensureStart<T>(store: T & {
|
511
|
+
start: () => Promise<Result<URI>>;
|
512
|
+
}, logger: Logger): Promise<T>;
|
513
|
+
declare function toStoreRuntime(opts: StoreOpts, sthis: SuperThis): StoreRuntime;
|
514
|
+
|
515
|
+
declare class FragmentGateway implements Gateway {
|
516
|
+
readonly sthis: SuperThis;
|
517
|
+
readonly logger: Logger;
|
518
|
+
readonly fidLength = 4;
|
519
|
+
readonly innerGW: Gateway;
|
520
|
+
headerSize: number;
|
521
|
+
constructor(sthis: SuperThis, innerGW: Gateway);
|
522
|
+
slicer(url: URI, body: Uint8Array): Promise<VoidResult>[];
|
523
|
+
buildUrl(baseUrl: URI, key: string): Promise<Result<URI>>;
|
524
|
+
destroy(iurl: URI): Promise<Result<void>>;
|
525
|
+
start(url: URI): Promise<Result<URI>>;
|
526
|
+
close(url: URI): Promise<VoidResult>;
|
527
|
+
put(url: URI, body: Uint8Array): Promise<VoidResult>;
|
528
|
+
get(url: URI): Promise<GetResult>;
|
529
|
+
delete(url: URI): Promise<VoidResult>;
|
438
530
|
}
|
439
531
|
|
440
532
|
declare class TaskManager {
|
@@ -443,7 +535,7 @@ declare class TaskManager {
|
|
443
535
|
private queue;
|
444
536
|
private isProcessing;
|
445
537
|
readonly logger: Logger;
|
446
|
-
constructor(loader:
|
538
|
+
constructor(loader: Loadable);
|
447
539
|
handleEvent(eventBlock: DbMetaEventBlock): Promise<void>;
|
448
540
|
private processQueue;
|
449
541
|
}
|
@@ -452,7 +544,7 @@ type CarClockHead = Link<DbMetaEventBlock, number, number, Version>[];
|
|
452
544
|
interface Connectable {
|
453
545
|
readonly blockstore: {
|
454
546
|
readonly loader?: Loader;
|
455
|
-
readonly ebOpts:
|
547
|
+
readonly ebOpts: BlockstoreRuntime;
|
456
548
|
};
|
457
549
|
readonly name?: string;
|
458
550
|
}
|
@@ -462,25 +554,20 @@ declare abstract class ConnectionBase implements Connection {
|
|
462
554
|
loader?: Loadable;
|
463
555
|
taskManager?: TaskManager;
|
464
556
|
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>;
|
557
|
+
readonly url: URI;
|
471
558
|
readonly logger: Logger;
|
472
|
-
constructor(logger: Logger);
|
559
|
+
constructor(url: URI, logger: Logger);
|
473
560
|
refresh(): Promise<void>;
|
474
|
-
|
475
|
-
loader?:
|
476
|
-
}): void
|
477
|
-
|
478
|
-
loader?:
|
479
|
-
}): void
|
480
|
-
onConnect(): Promise<void>;
|
481
|
-
|
482
|
-
loader?:
|
483
|
-
}): void
|
561
|
+
connect_X({ loader }: {
|
562
|
+
readonly loader?: Loadable;
|
563
|
+
}): Promise<void>;
|
564
|
+
connectMeta_X({ loader }: {
|
565
|
+
loader?: Loadable;
|
566
|
+
}): Promise<void>;
|
567
|
+
abstract onConnect(): Promise<void>;
|
568
|
+
connectStorage_X({ loader }: {
|
569
|
+
loader?: Loadable;
|
570
|
+
}): Promise<void>;
|
484
571
|
createEventBlock(bytes: Uint8Array): Promise<DbMetaEventBlock>;
|
485
572
|
decodeEventBlock(bytes: Uint8Array): Promise<DbMetaEventBlock>;
|
486
573
|
}
|
@@ -488,107 +575,142 @@ type DbMetaEventBlock = EventBlock<{
|
|
488
575
|
dbMeta: Uint8Array;
|
489
576
|
}>;
|
490
577
|
|
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>;
|
509
|
-
}
|
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
|
-
|
514
578
|
declare function parseCarFile<T>(reader: CarReader, logger: Logger): Promise<CarHeader<T>>;
|
515
579
|
|
516
|
-
type index$
|
517
|
-
type index$
|
518
|
-
type index$
|
519
|
-
type index$
|
520
|
-
|
521
|
-
type index$
|
522
|
-
type index$
|
523
|
-
|
524
|
-
type index$
|
525
|
-
type index$
|
526
|
-
|
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
|
-
|
538
|
-
type index$
|
539
|
-
|
540
|
-
type index$
|
541
|
-
type index$
|
542
|
-
type index$
|
543
|
-
|
544
|
-
type index$
|
545
|
-
|
546
|
-
type index$
|
547
|
-
|
548
|
-
type index$
|
549
|
-
type index$
|
550
|
-
|
551
|
-
type index$
|
552
|
-
|
553
|
-
type index$
|
554
|
-
declare const index$
|
555
|
-
type index$
|
556
|
-
declare const index$
|
557
|
-
type index$
|
558
|
-
|
559
|
-
type index$
|
560
|
-
type index$
|
561
|
-
type index$
|
562
|
-
type index$
|
563
|
-
type index$
|
564
|
-
type index$
|
565
|
-
type index$
|
566
|
-
type index$
|
567
|
-
type index$
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
580
|
+
type index$3_AnyAnyBlock = AnyAnyBlock;
|
581
|
+
type index$3_AnyAnyLink = AnyAnyLink;
|
582
|
+
type index$3_AnyBlock = AnyBlock;
|
583
|
+
type index$3_AnyDecodedBlock = AnyDecodedBlock;
|
584
|
+
type index$3_AnyLink = AnyLink;
|
585
|
+
type index$3_AnyLinkFn = AnyLinkFn;
|
586
|
+
type index$3_BaseBlockstore = BaseBlockstore;
|
587
|
+
declare const index$3_BaseBlockstore: typeof BaseBlockstore;
|
588
|
+
type index$3_BaseStore = BaseStore;
|
589
|
+
type index$3_BlobLike = BlobLike;
|
590
|
+
type index$3_BlockFetcher = BlockFetcher;
|
591
|
+
type index$3_BlockstoreOpts = BlockstoreOpts;
|
592
|
+
type index$3_BlockstoreRuntime = BlockstoreRuntime;
|
593
|
+
type index$3_BytesWithIv = BytesWithIv;
|
594
|
+
type index$3_CIDBlock = CIDBlock;
|
595
|
+
type index$3_CarClockHead = CarClockHead;
|
596
|
+
type index$3_CarGroup = CarGroup;
|
597
|
+
type index$3_CarHeader<T> = CarHeader<T>;
|
598
|
+
type index$3_CarLog = CarLog;
|
599
|
+
type index$3_CarMakeable = CarMakeable;
|
600
|
+
type index$3_CarTransaction = CarTransaction;
|
601
|
+
declare const index$3_CarTransaction: typeof CarTransaction;
|
602
|
+
type index$3_CodecOpts = CodecOpts;
|
603
|
+
type index$3_CommitOpts = CommitOpts;
|
604
|
+
type index$3_CompactFetcher = CompactFetcher;
|
605
|
+
type index$3_CompactFn = CompactFn;
|
606
|
+
type index$3_CompactionFetcher = CompactionFetcher;
|
607
|
+
declare const index$3_CompactionFetcher: typeof CompactionFetcher;
|
608
|
+
type index$3_Connectable = Connectable;
|
609
|
+
type index$3_Connection = Connection;
|
610
|
+
type index$3_ConnectionBase = ConnectionBase;
|
611
|
+
declare const index$3_ConnectionBase: typeof ConnectionBase;
|
612
|
+
type index$3_DataSaveOpts = DataSaveOpts;
|
613
|
+
type index$3_DataStore = DataStore;
|
614
|
+
type index$3_DbMeta = DbMeta;
|
615
|
+
type index$3_DbMetaEventBlock = DbMetaEventBlock;
|
616
|
+
type index$3_EncryptedBlock = EncryptedBlock;
|
617
|
+
type index$3_EncryptedBlockstore = EncryptedBlockstore;
|
618
|
+
declare const index$3_EncryptedBlockstore: typeof EncryptedBlockstore;
|
619
|
+
type index$3_FragmentGateway = FragmentGateway;
|
620
|
+
declare const index$3_FragmentGateway: typeof FragmentGateway;
|
621
|
+
type index$3_Gateway = Gateway;
|
622
|
+
type index$3_GatewayFactoryItem = GatewayFactoryItem;
|
623
|
+
type index$3_GatewayOpts = GatewayOpts;
|
624
|
+
type index$3_GetResult = GetResult;
|
625
|
+
type index$3_IvAndBytes = IvAndBytes;
|
626
|
+
type index$3_IvKeyIdData = IvKeyIdData;
|
627
|
+
type index$3_KeyWithFingerPrint = KeyWithFingerPrint;
|
628
|
+
type index$3_KeyedCrypto = KeyedCrypto;
|
629
|
+
type index$3_LoadHandler = LoadHandler;
|
630
|
+
type index$3_Loadable = Loadable;
|
631
|
+
type index$3_Loader = Loader;
|
632
|
+
declare const index$3_Loader: typeof Loader;
|
633
|
+
type index$3_MetaStore = MetaStore;
|
634
|
+
type index$3_RemoteMetaStore = RemoteMetaStore;
|
635
|
+
type index$3_StoreFactory = StoreFactory;
|
636
|
+
type index$3_StoreOpts = StoreOpts;
|
637
|
+
type index$3_StoreRuntime = StoreRuntime;
|
638
|
+
type index$3_TestGateway = TestGateway;
|
639
|
+
type index$3_TransactionMeta = TransactionMeta;
|
640
|
+
type index$3_TransactionWrapper<M extends TransactionMeta> = TransactionWrapper<M>;
|
641
|
+
type index$3_VoidResult = VoidResult;
|
642
|
+
type index$3_WALState = WALState;
|
643
|
+
type index$3_WALStore = WALStore;
|
644
|
+
declare const index$3_ensureStart: typeof ensureStart;
|
645
|
+
declare const index$3_getGatewayFromURL: typeof getGatewayFromURL;
|
646
|
+
declare const index$3_parseCarFile: typeof parseCarFile;
|
647
|
+
declare const index$3_registerStoreProtocol: typeof registerStoreProtocol;
|
648
|
+
declare const index$3_testStoreFactory: typeof testStoreFactory;
|
649
|
+
declare const index$3_toCIDBlock: typeof toCIDBlock;
|
650
|
+
declare const index$3_toStoreRuntime: typeof toStoreRuntime;
|
651
|
+
declare namespace index$3 {
|
652
|
+
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_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_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_RemoteMetaStore as RemoteMetaStore, 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_VoidResult as VoidResult, type index$3_WALState as WALState, type index$3_WALStore as WALStore, index$3_ensureStart as ensureStart, index$3_getGatewayFromURL as getGatewayFromURL, index$3_parseCarFile as parseCarFile, index$3_registerStoreProtocol as registerStoreProtocol, index$3_testStoreFactory as testStoreFactory, index$3_toCIDBlock as toCIDBlock, index$3_toStoreRuntime as toStoreRuntime };
|
577
653
|
}
|
578
654
|
|
579
655
|
type Falsy = false | null | undefined;
|
580
656
|
declare function isFalsy(value: unknown): value is Falsy;
|
581
657
|
declare function throwFalsy<T>(value: T | Falsy): T;
|
582
658
|
declare function falsyToUndef<T>(value: T | Falsy): T | undefined;
|
583
|
-
|
659
|
+
type StoreType = "data" | "wal" | "meta";
|
660
|
+
interface SysFileSystem {
|
661
|
+
start(): Promise<SysFileSystem>;
|
662
|
+
mkdir(path: PathLike, options?: {
|
663
|
+
recursive: boolean;
|
664
|
+
}): Promise<string | undefined>;
|
665
|
+
readdir(path: PathLike, options?: unknown): Promise<string[]>;
|
666
|
+
rm(path: PathLike, options?: MakeDirectoryOptions & {
|
667
|
+
recursive: boolean;
|
668
|
+
}): Promise<void>;
|
669
|
+
copyFile(source: PathLike, destination: PathLike): Promise<void>;
|
670
|
+
readfile(path: PathLike, options?: {
|
671
|
+
encoding: BufferEncoding;
|
672
|
+
flag?: string;
|
673
|
+
}): Promise<Uint8Array>;
|
674
|
+
stat(path: PathLike): Promise<Stats>;
|
675
|
+
unlink(path: PathLike): Promise<void>;
|
676
|
+
writefile(path: PathLike, data: Uint8Array | string): Promise<void>;
|
677
|
+
}
|
678
|
+
interface PathOps {
|
679
|
+
join(...args: string[]): string;
|
680
|
+
dirname(path: string): string;
|
681
|
+
}
|
682
|
+
interface TextEndeCoder {
|
683
|
+
encode(input: string): Uint8Array;
|
684
|
+
decode(input: Uint8Array): string;
|
685
|
+
}
|
686
|
+
interface SuperThisOpts {
|
687
|
+
readonly logger: Logger;
|
688
|
+
readonly pathOps: PathOps;
|
689
|
+
readonly crypto: CryptoRuntime;
|
690
|
+
readonly env: EnvFactoryOpts;
|
691
|
+
readonly txt: TextEndeCoder;
|
692
|
+
readonly ctx: Record<string, unknown>;
|
693
|
+
}
|
694
|
+
interface SuperThis {
|
695
|
+
readonly logger: Logger;
|
696
|
+
readonly env: Env;
|
697
|
+
readonly pathOps: PathOps;
|
698
|
+
readonly ctx: Record<string, unknown>;
|
699
|
+
readonly txt: TextEndeCoder;
|
700
|
+
nextId(bytes?: number): {
|
701
|
+
str: string;
|
702
|
+
bin: Uint8Array;
|
703
|
+
};
|
704
|
+
start(): Promise<void>;
|
705
|
+
clone(override: Partial<SuperThisOpts>): SuperThis;
|
706
|
+
}
|
707
|
+
interface ConfigOpts extends Partial<SuperThisOpts> {
|
584
708
|
readonly public?: boolean;
|
585
709
|
readonly meta?: DbMeta;
|
586
710
|
readonly persistIndexes?: boolean;
|
587
711
|
readonly autoCompact?: number;
|
588
|
-
readonly crypto?: CryptoOpts;
|
589
712
|
readonly store?: StoreOpts;
|
590
713
|
readonly threshold?: number;
|
591
|
-
readonly logger?: Logger;
|
592
714
|
}
|
593
715
|
type ClockLink = EventLink<Operation>;
|
594
716
|
type ClockHead = ClockLink[];
|
@@ -744,16 +866,16 @@ interface ProllyNode<K extends IndexKeyType, T extends DocFragment> extends Prol
|
|
744
866
|
}>;
|
745
867
|
bulk(bulk: (IndexUpdate<K> | IndexUpdateString)[]): PromiseLike<{
|
746
868
|
readonly root?: ProllyNode<K, T>;
|
747
|
-
readonly blocks: Block[];
|
869
|
+
readonly blocks: Block$1[];
|
748
870
|
}>;
|
749
871
|
readonly address: Promise<Link>;
|
750
872
|
readonly distance: number;
|
751
873
|
compare: (a: unknown, b: unknown) => number;
|
752
874
|
readonly cache: unknown;
|
753
|
-
readonly block: Promise<Block>;
|
875
|
+
readonly block: Promise<Block$1>;
|
754
876
|
}
|
755
877
|
|
756
|
-
declare function index$
|
878
|
+
declare function index$2<K extends IndexKeyType = string, T extends DocTypes = NonNullable<unknown>, R extends DocFragment = T>(sthis: SuperThis, { _crdt }: {
|
757
879
|
_crdt: CRDT<T> | CRDT<NonNullable<unknown>>;
|
758
880
|
}, name: string, mapFn?: MapFn<T>, meta?: IdxMeta): Index<K, T, R>;
|
759
881
|
declare class Index<K extends IndexKeyType, T extends DocTypes, R extends DocFragment = T> {
|
@@ -771,7 +893,7 @@ declare class Index<K extends IndexKeyType, T extends DocTypes, R extends DocFra
|
|
771
893
|
close(): Promise<void>;
|
772
894
|
destroy(): Promise<void>;
|
773
895
|
readonly logger: Logger;
|
774
|
-
constructor(crdt: CRDT<T> | CRDT<NonNullable<unknown>>, name: string, mapFn?: MapFn<T>, meta?: IdxMeta);
|
896
|
+
constructor(sthis: SuperThis, crdt: CRDT<T> | CRDT<NonNullable<unknown>>, name: string, mapFn?: MapFn<T>, meta?: IdxMeta);
|
775
897
|
applyMapFn(name: string, mapFn?: MapFn<T>, meta?: IdxMeta): void;
|
776
898
|
query(opts?: QueryOpts<K>): Promise<IndexRows<K, T, R>>;
|
777
899
|
_resetIndex(): void;
|
@@ -817,23 +939,24 @@ declare class CRDTClock<T extends DocTypes> {
|
|
817
939
|
declare class CRDT<T extends DocTypes> {
|
818
940
|
readonly name?: string;
|
819
941
|
readonly opts: ConfigOpts;
|
820
|
-
readonly onceReady: ResolveOnce<void, void>;
|
821
|
-
ready(): Promise<void>;
|
822
|
-
close(): Promise<void>;
|
823
|
-
destroy(): Promise<void>;
|
824
942
|
readonly blockstore: BaseBlockstore;
|
825
943
|
readonly indexBlockstore: BaseBlockstore;
|
826
944
|
readonly indexers: Map<string, Index<IndexKeyType, {}, {}>>;
|
827
945
|
readonly clock: CRDTClock<T>;
|
828
946
|
readonly logger: Logger;
|
829
|
-
|
947
|
+
readonly sthis: SuperThis;
|
948
|
+
constructor(sthis: SuperThis, name?: string, opts?: ConfigOpts);
|
830
949
|
bulk(updates: DocUpdate<T>[]): Promise<CRDTMeta>;
|
950
|
+
readonly onceReady: ResolveOnce<void, void>;
|
951
|
+
ready(): Promise<void>;
|
952
|
+
close(): Promise<void>;
|
953
|
+
destroy(): Promise<void>;
|
831
954
|
allDocs(): Promise<{
|
832
955
|
result: DocUpdate<T>[];
|
833
956
|
head: ClockHead;
|
834
957
|
}>;
|
835
958
|
vis(): Promise<string>;
|
836
|
-
getBlock(cidString: string): Promise<Block>;
|
959
|
+
getBlock(cidString: string): Promise<Block$1>;
|
837
960
|
get(key: string): Promise<DocValue<T> | Falsy>;
|
838
961
|
changes(since?: ClockHead, opts?: ChangesOptions): Promise<{
|
839
962
|
result: DocUpdate<T>[];
|
@@ -857,6 +980,7 @@ declare class Database<DT extends DocTypes = NonNullable<unknown>> implements Co
|
|
857
980
|
readonly _ready: ResolveOnce<void, void>;
|
858
981
|
ready(): Promise<void>;
|
859
982
|
readonly logger: Logger;
|
983
|
+
readonly sthis: SuperThis;
|
860
984
|
constructor(name?: string, opts?: ConfigOpts);
|
861
985
|
get<T extends DocTypes>(id: string): Promise<DocWithId<T>>;
|
862
986
|
put<T extends DocTypes>(doc: DocSet<T>): Promise<DocResponse>;
|
@@ -878,95 +1002,10 @@ declare class Database<DT extends DocTypes = NonNullable<unknown>> implements Co
|
|
878
1002
|
}
|
879
1003
|
declare function fireproof(name: string, opts?: ConfigOpts): Database;
|
880
1004
|
|
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
|
-
}
|
1005
|
+
declare function getFileSystem(url: URI): Promise<SysFileSystem>;
|
1006
|
+
declare function getPath(url: URI, sthis: SuperThis): string;
|
1007
|
+
declare function getFileName(url: URI, sthis: SuperThis): string;
|
1008
|
+
declare function toArrayBuffer(buffer: Buffer | string): Uint8Array;
|
970
1009
|
|
971
1010
|
declare function encodeFile(blob: BlobLike): Promise<{
|
972
1011
|
cid: AnyLink;
|
@@ -980,27 +1019,88 @@ declare namespace files {
|
|
980
1019
|
export { files_decodeFile as decodeFile, files_encodeFile as encodeFile };
|
981
1020
|
}
|
982
1021
|
|
1022
|
+
declare class BlockIvKeyIdCodec implements BlockCodec<0x300539, Uint8Array> {
|
1023
|
+
readonly code = 3147065;
|
1024
|
+
readonly name = "Fireproof@encrypted-block:aes-gcm";
|
1025
|
+
readonly ko: KeyedCrypto;
|
1026
|
+
readonly iv?: Uint8Array;
|
1027
|
+
readonly opts: Partial<CodecOpts>;
|
1028
|
+
constructor(ko: KeyedCrypto, iv?: Uint8Array, opts?: CodecOpts);
|
1029
|
+
encode(data: Uint8Array): Promise<Uint8Array>;
|
1030
|
+
decode(abytes: Uint8Array | ArrayBuffer): Promise<Uint8Array>;
|
1031
|
+
}
|
1032
|
+
declare function keyedCryptoFactory(url: URI, kb: KeyBag, sthis: SuperThis): Promise<KeyedCrypto>;
|
1033
|
+
|
1034
|
+
type keyedCrypto_BlockIvKeyIdCodec = BlockIvKeyIdCodec;
|
1035
|
+
declare const keyedCrypto_BlockIvKeyIdCodec: typeof BlockIvKeyIdCodec;
|
1036
|
+
declare const keyedCrypto_keyedCryptoFactory: typeof keyedCryptoFactory;
|
1037
|
+
declare namespace keyedCrypto {
|
1038
|
+
export { keyedCrypto_BlockIvKeyIdCodec as BlockIvKeyIdCodec, keyedCrypto_keyedCryptoFactory as keyedCryptoFactory };
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
declare const Block: typeof Block$2;
|
1042
|
+
interface DecodeInput<T, Code extends number, Alg extends number> {
|
1043
|
+
bytes: ByteView<T>;
|
1044
|
+
codec: BlockDecoder<Code, T>;
|
1045
|
+
hasher: MultihashHasher<Alg>;
|
1046
|
+
}
|
1047
|
+
declare function decode<T, Code extends number, Alg extends number>({ bytes, codec, hasher, }: DecodeInput<T, Code, Alg>): Promise<BlockView<T, Code, Alg>>;
|
1048
|
+
interface EncodeInput<T, Code extends number, Alg extends number> {
|
1049
|
+
value: T;
|
1050
|
+
codec: BlockEncoder<Code, T>;
|
1051
|
+
hasher: MultihashHasher<Alg>;
|
1052
|
+
}
|
1053
|
+
declare function encode<T, Code extends number, Alg extends number>({ value, codec, hasher, }: EncodeInput<T, Code, Alg>): Promise<BlockView<T, Code, Alg>>;
|
1054
|
+
interface CreateInput<T, Code extends number, Alg extends number, V extends Version> {
|
1055
|
+
bytes: ByteView<T>;
|
1056
|
+
cid: Link<T, Code, Alg, V>;
|
1057
|
+
hasher: MultihashHasher<Alg>;
|
1058
|
+
codec: BlockDecoder<Code, T>;
|
1059
|
+
}
|
1060
|
+
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>>;
|
1061
|
+
type CreateUnsafeInput<T, Code extends number, Alg extends number, V extends Version> = {
|
1062
|
+
cid: Link<T, Code, Alg, V>;
|
1063
|
+
value: T;
|
1064
|
+
codec?: BlockDecoder<Code, T>;
|
1065
|
+
bytes: ByteView<T>;
|
1066
|
+
} | {
|
1067
|
+
cid: Link<T, Code, Alg, V>;
|
1068
|
+
value?: undefined;
|
1069
|
+
codec: BlockDecoder<Code, T>;
|
1070
|
+
bytes: ByteView<T>;
|
1071
|
+
};
|
1072
|
+
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>>;
|
1073
|
+
|
1074
|
+
declare const block_Block: typeof Block;
|
1075
|
+
declare const block_create: typeof create;
|
1076
|
+
declare const block_createUnsafe: typeof createUnsafe;
|
1077
|
+
declare const block_decode: typeof decode;
|
1078
|
+
declare const block_encode: typeof encode;
|
1079
|
+
declare namespace block {
|
1080
|
+
export { block_Block as Block, block_create as create, block_createUnsafe as createUnsafe, block_decode as decode, block_encode as encode };
|
1081
|
+
}
|
1082
|
+
|
1083
|
+
declare const index$1_block: typeof block;
|
1084
|
+
declare namespace index$1 {
|
1085
|
+
export { index$1_block as block, codecInterface as codec };
|
1086
|
+
}
|
1087
|
+
|
983
1088
|
declare const FILESTORE_VERSION = "v0.19-file";
|
984
1089
|
|
985
1090
|
declare const INDEXDB_VERSION = "v0.19-indexdb";
|
986
1091
|
|
987
1092
|
declare const index_FILESTORE_VERSION: typeof FILESTORE_VERSION;
|
988
1093
|
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
1094
|
declare const index_files: typeof files;
|
996
1095
|
declare const index_getFileName: typeof getFileName;
|
1096
|
+
declare const index_getFileSystem: typeof getFileSystem;
|
997
1097
|
declare const index_getPath: typeof getPath;
|
998
|
-
declare const
|
1098
|
+
declare const index_toArrayBuffer: typeof toArrayBuffer;
|
999
1099
|
declare namespace index {
|
1000
|
-
export { index_FILESTORE_VERSION as FILESTORE_VERSION, index_INDEXDB_VERSION as INDEXDB_VERSION,
|
1100
|
+
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_toArrayBuffer as toArrayBuffer };
|
1001
1101
|
}
|
1002
1102
|
|
1003
1103
|
declare const PACKAGE_VERSION: string;
|
1004
1104
|
|
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
|
1105
|
+
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 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, exception2Result, exceptionWrapper, falsyToUndef, fireproof, getKey, getName, getStore, index$2 as index, isFalsy, isNotFoundError, index as rt, index as runtime, throwFalsy };
|
1006
1106
|
declare module '@fireproof/core'
|