@fireproof/core 0.20.0-dev-preview-40 → 0.20.0-dev-preview-50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/deno/index.js +2 -2
- package/deno/index.js.map +1 -1
- package/deno.json +3 -2
- package/index.cjs +955 -599
- package/index.cjs.map +1 -1
- package/index.d.cts +334 -127
- package/index.d.ts +334 -127
- package/index.js +939 -582
- package/index.js.map +1 -1
- package/indexeddb/index.cjs.map +1 -1
- package/indexeddb/index.js.map +1 -1
- package/indexeddb/metafile-cjs.json +1 -1
- package/indexeddb/metafile-esm.json +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +7 -5
- package/react/index.cjs +17 -9
- package/react/index.cjs.map +1 -1
- package/react/index.d.cts +5 -4
- package/react/index.d.ts +5 -4
- package/react/index.js +17 -9
- package/react/index.js.map +1 -1
- package/react/metafile-cjs.json +1 -1
- package/react/metafile-esm.json +1 -1
- package/tests/blockstore/interceptor-gateway.test.ts +15 -1
- package/tests/blockstore/keyed-crypto-indexeddb-file.test.ts +8 -18
- package/tests/blockstore/keyed-crypto.test.ts +31 -53
- package/tests/blockstore/loader.test.ts +21 -19
- package/tests/blockstore/store.test.ts +52 -56
- package/tests/blockstore/transaction.test.ts +13 -11
- package/tests/fireproof/all-gateway.test.ts +53 -50
- package/tests/fireproof/attachable.test.ts +356 -0
- package/tests/fireproof/crdt.test.ts +100 -60
- package/tests/fireproof/database.test.ts +95 -54
- package/tests/fireproof/fireproof.test.ts +58 -55
- package/tests/fireproof/hello.test.ts +4 -4
- package/tests/fireproof/indexer.test.ts +44 -44
- package/tests/fireproof/stable-cid.test.ts +69 -0
- package/tests/fireproof/utils.test.ts +21 -10
- package/tests/gateway/file/loader-config.test.ts +25 -25
- package/tests/gateway/fp-envelope-serialize.test.ts +8 -8
- package/tests/gateway/indexeddb/loader-config.test.ts +6 -6
- package/tests/helpers.ts +81 -2
- package/tests/react/useFireproof.test.tsx +59 -17
package/index.d.ts
CHANGED
@@ -1,36 +1,13 @@
|
|
1
|
-
import { Logger, Future, Result, ResolveOnce, URI, ResolveSeq, CoerceURI, CryptoRuntime, CTCryptoKey, EnvFactoryOpts, Env, runtimeFn } from '@adviser/cement';
|
1
|
+
import { Logger, Future, Result, ResolveOnce, URI, ResolveSeq, CoerceURI, CryptoRuntime, CTCryptoKey, LRUSet, EnvFactoryOpts, Env, runtimeFn } from '@adviser/cement';
|
2
2
|
import { EventLink } from '@fireproof/vendor/@web3-storage/pail/clock/api';
|
3
3
|
import { Operation } from '@fireproof/vendor/@web3-storage/pail/crdt/api';
|
4
|
-
import {
|
4
|
+
import { Version, Block as Block$1, UnknownLink, CID, ByteView, ArrayBufferView, Link, MultihashHasher, BlockView } from 'multiformats';
|
5
5
|
import { BlockFetcher as BlockFetcher$1 } from '@fireproof/vendor/@web3-storage/pail/api';
|
6
6
|
import { EventBlock } from '@fireproof/vendor/@web3-storage/pail/clock';
|
7
|
-
import { CarReader } from '@ipld/car';
|
8
7
|
import { ProllyNode as ProllyNode$1 } from 'prolly-trees/db-index';
|
9
|
-
import { CarReader as CarReader$1 } from '@ipld/car/reader';
|
10
8
|
import { SuperThis as SuperThis$1 } from '@fireproof/core';
|
11
9
|
import { Block as Block$2 } from 'multiformats/block';
|
12
10
|
|
13
|
-
interface BlockEncoder<Code extends number, T> {
|
14
|
-
name: string;
|
15
|
-
code: Code;
|
16
|
-
encode(data: T): ByteView<T> | PromiseLike<ByteView<T>>;
|
17
|
-
}
|
18
|
-
interface BlockDecoder<Code extends number, T> {
|
19
|
-
code: Code;
|
20
|
-
decode(bytes: ByteView<T> | ArrayBufferView<T>): T | PromiseLike<T>;
|
21
|
-
}
|
22
|
-
interface BlockCodec<Code extends number, T> extends BlockEncoder<Code, T>, BlockDecoder<Code, T> {
|
23
|
-
}
|
24
|
-
|
25
|
-
declare const codecInterface_ArrayBufferView: typeof ArrayBufferView;
|
26
|
-
type codecInterface_BlockCodec<Code extends number, T> = BlockCodec<Code, T>;
|
27
|
-
type codecInterface_BlockDecoder<Code extends number, T> = BlockDecoder<Code, T>;
|
28
|
-
type codecInterface_BlockEncoder<Code extends number, T> = BlockEncoder<Code, T>;
|
29
|
-
declare const codecInterface_ByteView: typeof ByteView;
|
30
|
-
declare namespace codecInterface {
|
31
|
-
export { codecInterface_ArrayBufferView as ArrayBufferView, type codecInterface_BlockCodec as BlockCodec, type codecInterface_BlockDecoder as BlockDecoder, type codecInterface_BlockEncoder as BlockEncoder, codecInterface_ByteView as ByteView };
|
32
|
-
}
|
33
|
-
|
34
11
|
type BlockFetcher = BlockFetcher$1;
|
35
12
|
interface CarTransactionOpts {
|
36
13
|
readonly add: boolean;
|
@@ -44,6 +21,7 @@ declare class CarTransactionImpl implements CarMakeable, CarTransaction {
|
|
44
21
|
superGet(cid: AnyLink): Promise<AnyBlock | undefined>;
|
45
22
|
put(cid: AnyLink, block: Uint8Array): Promise<void>;
|
46
23
|
putSync(cid: UnknownLink, bytes: Uint8Array<ArrayBufferLike>): void;
|
24
|
+
unshift(cid: UnknownLink, bytes: Uint8Array<ArrayBufferLike>): void;
|
47
25
|
entries(): AsyncIterableIterator<AnyBlock>;
|
48
26
|
}
|
49
27
|
declare class BaseBlockstoreImpl implements BlockFetcher {
|
@@ -201,14 +179,19 @@ declare namespace keyBag {
|
|
201
179
|
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, type keyBag_KeyBagRuntime as KeyBagRuntime, type keyBag_KeysItem as KeysItem, type keyBag_V1StorageKeyItem as V1StorageKeyItem, type keyBag_V2StorageKeyItem as V2StorageKeyItem, keyBag_defaultKeyBagOpts as defaultKeyBagOpts, keyBag_defaultKeyBagUrl as defaultKeyBagUrl, keyBag_getKeyBag as getKeyBag, keyBag_keysByFingerprint as keysByFingerprint, keyBag_registerKeyBagProviderFactory as registerKeyBagProviderFactory, keyBag_toKeyWithFingerPrint as toKeyWithFingerPrint };
|
202
180
|
}
|
203
181
|
|
182
|
+
interface TaskManagerParams {
|
183
|
+
readonly removeAfter: number;
|
184
|
+
readonly retryTimeout: number;
|
185
|
+
}
|
204
186
|
declare class TaskManager {
|
205
187
|
private readonly eventsWeHandled;
|
206
188
|
private queue;
|
207
189
|
private isProcessing;
|
208
190
|
readonly logger: Logger;
|
209
|
-
readonly
|
210
|
-
|
211
|
-
|
191
|
+
readonly params: TaskManagerParams;
|
192
|
+
readonly callback: (dbMeta: DbMeta, store: ActiveStore) => Promise<void>;
|
193
|
+
constructor(sthis: SuperThis, callback: (dbMeta: DbMeta, store: ActiveStore) => Promise<void>, params: TaskManagerParams);
|
194
|
+
handleEvent(cid: CarClockLink, parents: CarClockHead, dbMeta: DbMeta, store: ActiveStore): Promise<void>;
|
212
195
|
private processQueue;
|
213
196
|
}
|
214
197
|
|
@@ -218,7 +201,8 @@ declare function ensureSuperLog(sthis: SuperThis, componentName: string, ctx?: R
|
|
218
201
|
declare function ensureLogger(sthis: SuperThis, componentName: string, ctx?: Record<string, unknown>): Logger;
|
219
202
|
type Joiner = (...toJoin: string[]) => string;
|
220
203
|
interface Store {
|
221
|
-
readonly
|
204
|
+
readonly pathPart: "data" | "wal" | "meta";
|
205
|
+
readonly fromUrl: StoreType;
|
222
206
|
readonly name: string;
|
223
207
|
}
|
224
208
|
declare function getStore(url: URI, sthis: SuperThis, joiner: Joiner): Store;
|
@@ -235,6 +219,11 @@ declare function toSortedArray(set?: Record<string, unknown>): Record<string, un
|
|
235
219
|
declare function coerceIntoUint8(raw: ToUInt8): Result<Uint8Array>;
|
236
220
|
declare function coercePromiseIntoUint8(raw: PromiseToUInt8): Promise<Result<Uint8Array>>;
|
237
221
|
declare function makeName(fnString: string): string;
|
222
|
+
declare function storeType2DataMetaWal(store: StoreType): "data" | "wal" | "meta";
|
223
|
+
declare function ensureURIDefaults(sthis: SuperThis, name: string, curi: CoerceURI | undefined, uri: URI, store: StoreType, ctx?: Partial<{
|
224
|
+
readonly idx: boolean;
|
225
|
+
readonly file: boolean;
|
226
|
+
}>): URI;
|
238
227
|
|
239
228
|
declare const FPEnvelopeTypes: {
|
240
229
|
readonly CAR: "car";
|
@@ -390,9 +379,56 @@ declare class Context {
|
|
390
379
|
delete(key: string): void;
|
391
380
|
}
|
392
381
|
|
382
|
+
interface BlockEncoder<Code extends number, T> {
|
383
|
+
readonly name: string;
|
384
|
+
readonly code: Code;
|
385
|
+
bytesToHash?(data: T): ByteView<unknown>;
|
386
|
+
encode(data: T): ByteView<T>;
|
387
|
+
}
|
388
|
+
interface AsyncBlockEncoder<Code extends number, T> {
|
389
|
+
readonly name: string;
|
390
|
+
readonly code: Code;
|
391
|
+
bytesToHash?(data: T): Promise<ByteView<unknown>>;
|
392
|
+
encode(data: T): PromiseLike<ByteView<T>>;
|
393
|
+
}
|
394
|
+
interface BlockDecoder<Code extends number, T> {
|
395
|
+
readonly code: Code;
|
396
|
+
valueToHashBytes?(value: T): ByteView<unknown>;
|
397
|
+
decode(bytes: ByteView<unknown>): T;
|
398
|
+
}
|
399
|
+
interface AsyncBlockDecoder<Code extends number, T> {
|
400
|
+
readonly code: Code;
|
401
|
+
valueToHashBytes?(value: T): Promise<ByteView<unknown>>;
|
402
|
+
decode(bytes: ByteView<unknown>): PromiseLike<T>;
|
403
|
+
}
|
404
|
+
interface BlockCodec<Code extends number, E, D> extends BlockEncoder<Code, E>, BlockDecoder<Code, D> {
|
405
|
+
}
|
406
|
+
interface AsyncBlockCodec<Code extends number, E, D> extends AsyncBlockEncoder<Code, E>, AsyncBlockDecoder<Code, D> {
|
407
|
+
}
|
408
|
+
|
409
|
+
declare const codecInterface_ArrayBufferView: typeof ArrayBufferView;
|
410
|
+
type codecInterface_AsyncBlockCodec<Code extends number, E, D> = AsyncBlockCodec<Code, E, D>;
|
411
|
+
type codecInterface_AsyncBlockDecoder<Code extends number, T> = AsyncBlockDecoder<Code, T>;
|
412
|
+
type codecInterface_AsyncBlockEncoder<Code extends number, T> = AsyncBlockEncoder<Code, T>;
|
413
|
+
type codecInterface_BlockCodec<Code extends number, E, D> = BlockCodec<Code, E, D>;
|
414
|
+
type codecInterface_BlockDecoder<Code extends number, T> = BlockDecoder<Code, T>;
|
415
|
+
type codecInterface_BlockEncoder<Code extends number, T> = BlockEncoder<Code, T>;
|
416
|
+
declare const codecInterface_ByteView: typeof ByteView;
|
417
|
+
declare namespace codecInterface {
|
418
|
+
export { codecInterface_ArrayBufferView as ArrayBufferView, type codecInterface_AsyncBlockCodec as AsyncBlockCodec, type codecInterface_AsyncBlockDecoder as AsyncBlockDecoder, type codecInterface_AsyncBlockEncoder as AsyncBlockEncoder, type codecInterface_BlockCodec as BlockCodec, type codecInterface_BlockDecoder as BlockDecoder, type codecInterface_BlockEncoder as BlockEncoder, codecInterface_ByteView as ByteView };
|
419
|
+
}
|
420
|
+
|
393
421
|
type AnyLink = Link<unknown, number, number, Version>;
|
394
422
|
type CarGroup = AnyLink[];
|
395
|
-
type
|
423
|
+
type FroozenCarLog = CarGroup[];
|
424
|
+
declare class CarLog {
|
425
|
+
readonly _logs: CarGroup[];
|
426
|
+
get length(): number;
|
427
|
+
last(): AnyLink[];
|
428
|
+
xunshift(logs: CarGroup): void;
|
429
|
+
update(logs: FroozenCarLog): void;
|
430
|
+
asArray(): FroozenCarLog;
|
431
|
+
}
|
396
432
|
type AnyAnyLink = Link<unknown, number, number, Version>;
|
397
433
|
type AnyLinkFn = (cid: AnyLink) => Promise<AnyBlock | undefined>;
|
398
434
|
interface AnyBlock {
|
@@ -433,8 +469,8 @@ interface CarMakeable {
|
|
433
469
|
get(cid: AnyLink): Promise<AnyBlock | undefined>;
|
434
470
|
}
|
435
471
|
interface CarHeader<T> {
|
436
|
-
readonly cars:
|
437
|
-
readonly compact:
|
472
|
+
readonly cars: FroozenCarLog;
|
473
|
+
readonly compact: FroozenCarLog;
|
438
474
|
readonly meta: T;
|
439
475
|
}
|
440
476
|
interface TransactionWrapper<M extends TransactionMeta> {
|
@@ -481,7 +517,7 @@ interface CryptoAction {
|
|
481
517
|
iv: Uint8Array;
|
482
518
|
tagLength: number;
|
483
519
|
};
|
484
|
-
codec(iv?: Uint8Array, codecOpts?: Partial<CodecOpts>):
|
520
|
+
codec(iv?: Uint8Array, codecOpts?: Partial<CodecOpts>): AsyncBlockCodec<24, Uint8Array, IvKeyIdData>;
|
485
521
|
_decrypt(data: IvAndKeyAndBytes): Promise<Uint8Array>;
|
486
522
|
_encrypt(data: BytesAndKeyWithIv): Promise<Uint8Array>;
|
487
523
|
}
|
@@ -489,9 +525,6 @@ interface BlobLike {
|
|
489
525
|
stream: () => ReadableStream;
|
490
526
|
}
|
491
527
|
interface StoreFactory {
|
492
|
-
makeMetaStore?: (loader: Loadable) => Promise<MetaStore>;
|
493
|
-
makeDataStore?: (loader: Loadable) => Promise<DataStore>;
|
494
|
-
makeWALStore?: (loader: Loadable) => Promise<WALStore>;
|
495
528
|
encodeFile?: (blob: BlobLike) => Promise<{
|
496
529
|
cid: AnyLink;
|
497
530
|
blocks: AnyBlock[];
|
@@ -500,7 +533,8 @@ interface StoreFactory {
|
|
500
533
|
}
|
501
534
|
interface StoreUrls {
|
502
535
|
readonly meta: CoerceURI;
|
503
|
-
readonly
|
536
|
+
readonly car: CoerceURI;
|
537
|
+
readonly file: CoerceURI;
|
504
538
|
readonly wal: CoerceURI;
|
505
539
|
}
|
506
540
|
interface StoreEnDeFile {
|
@@ -517,7 +551,7 @@ interface StoreUrlsOpts {
|
|
517
551
|
}
|
518
552
|
interface StoreURIs {
|
519
553
|
readonly meta: URI;
|
520
|
-
readonly
|
554
|
+
readonly car: URI;
|
521
555
|
readonly file: URI;
|
522
556
|
readonly wal: URI;
|
523
557
|
}
|
@@ -525,15 +559,16 @@ interface StoreURIRuntime {
|
|
525
559
|
readonly data: StoreURIs;
|
526
560
|
readonly idx: StoreURIs;
|
527
561
|
}
|
528
|
-
interface
|
562
|
+
interface UrlAndInterceptor {
|
529
563
|
readonly url: URI;
|
530
564
|
readonly gatewayInterceptor?: SerdeGatewayInterceptor;
|
565
|
+
}
|
566
|
+
interface StoreFactoryItem {
|
567
|
+
readonly byStore: GatewayUrls;
|
531
568
|
readonly loader: Loadable;
|
532
569
|
}
|
533
570
|
interface StoreRuntime {
|
534
|
-
|
535
|
-
makeDataStore(sfi: StoreFactoryItem): Promise<DataStore>;
|
536
|
-
makeWALStore(sfi: StoreFactoryItem): Promise<WALStore>;
|
571
|
+
makeStores(sfi: StoreFactoryItem): Promise<DataAndMetaAndWalStore>;
|
537
572
|
encodeFile(blob: BlobLike): Promise<{
|
538
573
|
cid: AnyLink;
|
539
574
|
blocks: AnyBlock[];
|
@@ -544,6 +579,19 @@ interface CommitOpts {
|
|
544
579
|
readonly noLoader?: boolean;
|
545
580
|
readonly compact?: boolean;
|
546
581
|
}
|
582
|
+
interface WriteableDataAndMetaStore {
|
583
|
+
file: FileStore;
|
584
|
+
car: CarStore;
|
585
|
+
meta: MetaStore;
|
586
|
+
}
|
587
|
+
type DataAndMetaStore = Readonly<WriteableDataAndMetaStore>;
|
588
|
+
interface WriteableDataAndMetaAndWalStore extends WriteableDataAndMetaStore {
|
589
|
+
wal?: WALStore;
|
590
|
+
}
|
591
|
+
type DataAndMetaAndWalStore = Readonly<WriteableDataAndMetaAndWalStore>;
|
592
|
+
type LocalDataAndMetaAndWalStore = Readonly<Omit<WriteableDataAndMetaAndWalStore, "wal">> & {
|
593
|
+
readonly wal: WALStore;
|
594
|
+
};
|
547
595
|
interface DbMeta {
|
548
596
|
readonly cars: CarGroup;
|
549
597
|
}
|
@@ -562,14 +610,13 @@ interface Connection {
|
|
562
610
|
interface BaseStore {
|
563
611
|
readonly storeType: StoreType;
|
564
612
|
readonly realGateway: SerdeGateway;
|
613
|
+
readonly logger: Logger;
|
565
614
|
url(): URI;
|
566
|
-
onStarted(fn: () => void): void;
|
567
|
-
onClosed(fn: () => void): void;
|
568
615
|
keyedCrypto(): Promise<CryptoAction>;
|
569
616
|
close(): Promise<Result<void>>;
|
570
617
|
destroy(): Promise<Result<void>>;
|
571
618
|
readonly ready?: () => Promise<void>;
|
572
|
-
start(): Promise<Result<URI>>;
|
619
|
+
start(dam: DataAndMetaStore): Promise<Result<URI>>;
|
573
620
|
}
|
574
621
|
interface DbMetaEvent {
|
575
622
|
readonly eventCid: CarClockLink;
|
@@ -586,8 +633,14 @@ interface MetaStore extends BaseStore {
|
|
586
633
|
interface DataSaveOpts {
|
587
634
|
readonly public: boolean;
|
588
635
|
}
|
589
|
-
interface
|
590
|
-
readonly storeType: "
|
636
|
+
interface CarStore extends BaseStore {
|
637
|
+
readonly storeType: "car";
|
638
|
+
load(cid: AnyLink): Promise<AnyBlock>;
|
639
|
+
save(car: AnyBlock, opts?: DataSaveOpts): Promise<void>;
|
640
|
+
remove(cid: AnyLink): Promise<Result<void>>;
|
641
|
+
}
|
642
|
+
interface FileStore extends BaseStore {
|
643
|
+
readonly storeType: "file";
|
591
644
|
load(cid: AnyLink): Promise<AnyBlock>;
|
592
645
|
save(car: AnyBlock, opts?: DataSaveOpts): Promise<void>;
|
593
646
|
remove(cid: AnyLink): Promise<Result<void>>;
|
@@ -634,6 +687,7 @@ interface BlockstoreParams {
|
|
634
687
|
readonly keyBag: KeyBagRuntime;
|
635
688
|
readonly storeUrls: StoreURIs;
|
636
689
|
readonly storeRuntime: StoreRuntime;
|
690
|
+
readonly taskManager: TaskManagerParams;
|
637
691
|
}
|
638
692
|
type BlockstoreOpts = Partial<BlockstoreParams> & {
|
639
693
|
readonly keyBag: KeyBagRuntime;
|
@@ -650,30 +704,102 @@ interface BlockstoreRuntime {
|
|
650
704
|
readonly keyBag: KeyBagRuntime;
|
651
705
|
readonly storeUrls: StoreURIs;
|
652
706
|
readonly gatewayInterceptor?: SerdeGatewayInterceptor;
|
707
|
+
readonly taskManager: TaskManagerParams;
|
653
708
|
readonly meta?: DbMeta;
|
654
709
|
readonly threshold: number;
|
655
710
|
}
|
711
|
+
type LocalActiveStore = Omit<ActiveStore, "active"> & {
|
712
|
+
readonly active: LocalDataAndMetaAndWalStore;
|
713
|
+
};
|
714
|
+
interface AttachedStores {
|
715
|
+
local(): LocalActiveStore;
|
716
|
+
forRemotes(actionFn: (store: ActiveStore) => Promise<unknown>): Promise<void>;
|
717
|
+
remotes(): ActiveStore[];
|
718
|
+
activate(store: DataAndMetaStore | CoerceURI): ActiveStore;
|
719
|
+
attach(attached: Attachable): Promise<Attached>;
|
720
|
+
detach(): Promise<void>;
|
721
|
+
}
|
722
|
+
interface BaseAttachedStores {
|
723
|
+
local(): BaseStore;
|
724
|
+
remotes(): BaseStore[];
|
725
|
+
}
|
726
|
+
interface CarAttachedStores extends BaseAttachedStores {
|
727
|
+
local(): CarStore;
|
728
|
+
remotes(): CarStore[];
|
729
|
+
}
|
730
|
+
declare abstract class BaseActiveStore {
|
731
|
+
abstract readonly ref: ActiveStore;
|
732
|
+
abstract readonly active: BaseStore;
|
733
|
+
abstract local(): BaseStore;
|
734
|
+
abstract remotes(): BaseStore[];
|
735
|
+
protected abstract readonly xattached: BaseAttachedStores;
|
736
|
+
}
|
737
|
+
interface FileAttachedStores extends BaseAttachedStores {
|
738
|
+
local(): FileStore;
|
739
|
+
remotes(): FileStore[];
|
740
|
+
}
|
741
|
+
declare abstract class CarActiveStore extends BaseActiveStore {
|
742
|
+
protected abstract readonly xattached: CarAttachedStores;
|
743
|
+
abstract local(): CarStore;
|
744
|
+
abstract remotes(): CarStore[];
|
745
|
+
}
|
746
|
+
declare abstract class FileActiveStore extends BaseActiveStore {
|
747
|
+
protected abstract readonly xattached: FileAttachedStores;
|
748
|
+
abstract local(): FileStore;
|
749
|
+
abstract remotes(): FileStore[];
|
750
|
+
}
|
751
|
+
type CIDActiveStore = CarActiveStore | FileActiveStore;
|
752
|
+
interface MetaAttachedStores extends BaseAttachedStores {
|
753
|
+
local(): MetaStore;
|
754
|
+
remotes(): MetaStore[];
|
755
|
+
}
|
756
|
+
declare abstract class MetaActiveStore extends BaseActiveStore {
|
757
|
+
protected abstract readonly xattached: MetaAttachedStores;
|
758
|
+
abstract local(): MetaStore;
|
759
|
+
abstract remotes(): MetaStore[];
|
760
|
+
}
|
761
|
+
interface WALAttachedStores extends BaseAttachedStores {
|
762
|
+
local(): WALStore;
|
763
|
+
remotes(): WALStore[];
|
764
|
+
}
|
765
|
+
declare abstract class WALActiveStore extends BaseActiveStore {
|
766
|
+
protected abstract readonly xattached: WALAttachedStores;
|
767
|
+
abstract local(): WALStore;
|
768
|
+
abstract remotes(): WALStore[];
|
769
|
+
}
|
770
|
+
interface ActiveStore {
|
771
|
+
readonly active: DataAndMetaAndWalStore;
|
772
|
+
baseStores(): BaseStore[];
|
773
|
+
carStore(): CarActiveStore;
|
774
|
+
fileStore(): FileActiveStore;
|
775
|
+
metaStore(): MetaActiveStore;
|
776
|
+
walStore(): WALActiveStore;
|
777
|
+
local(): LocalActiveStore;
|
778
|
+
remotes(): ActiveStore[];
|
779
|
+
readonly xattached: AttachedStores;
|
780
|
+
}
|
781
|
+
interface CarCacheItem {
|
782
|
+
readonly type: "car" | "block";
|
783
|
+
readonly cid: AnyLink;
|
784
|
+
readonly blocks: AnyBlock[];
|
785
|
+
readonly roots: CID[];
|
786
|
+
}
|
656
787
|
interface Loadable {
|
657
788
|
readonly sthis: SuperThis;
|
658
789
|
readonly ebOpts: BlockstoreRuntime;
|
659
|
-
carLog: CarLog;
|
660
|
-
|
661
|
-
|
662
|
-
remoteCarStore?: DataStore;
|
790
|
+
readonly carLog: CarLog;
|
791
|
+
readonly attachedStores: AttachedStores;
|
792
|
+
attach(attached: Attachable): Promise<Attached>;
|
663
793
|
readonly taskManager: TaskManager;
|
664
794
|
ready(): Promise<void>;
|
665
795
|
close(): Promise<void>;
|
666
796
|
keyBag(): Promise<KeyBag>;
|
667
|
-
|
668
|
-
fileStore(): Promise<DataStore>;
|
669
|
-
WALStore(): Promise<WALStore>;
|
670
|
-
carStore(): Promise<DataStore>;
|
671
|
-
handleDbMetasFromStore(metas: DbMeta[]): Promise<void>;
|
797
|
+
handleDbMetasFromStore(metas: DbMeta[], store: ActiveStore): Promise<void>;
|
672
798
|
commit<T = TransactionMeta>(t: CarTransaction, done: T, opts: CommitOpts): Promise<CarGroup>;
|
673
799
|
destroy(): Promise<void>;
|
674
|
-
getBlock(cid: AnyLink): Promise<AnyBlock | Falsy>;
|
675
|
-
loadFileCar(cid: AnyLink): Promise<
|
676
|
-
loadCar(cid: AnyLink): Promise<
|
800
|
+
getBlock(cid: AnyLink, store: ActiveStore): Promise<AnyBlock | Falsy>;
|
801
|
+
loadFileCar(cid: AnyLink, store: ActiveStore): Promise<CarCacheItem>;
|
802
|
+
loadCar(cid: AnyLink, store: ActiveStore): Promise<CarCacheItem>;
|
677
803
|
commitFiles(t: CarTransaction, done: TransactionMeta): Promise<CarGroup>;
|
678
804
|
entries(cache?: boolean): AsyncIterableIterator<AnyBlock>;
|
679
805
|
}
|
@@ -755,80 +881,73 @@ declare function registerStoreProtocol(item: SerdeOrGatewayFactoryItem): () => v
|
|
755
881
|
declare function getGatewayFactoryItem(protocol: string): SerdeGatewayFactoryItem | undefined;
|
756
882
|
declare function defaultGatewayFactoryItem(): SerdeGatewayFactoryItem;
|
757
883
|
|
884
|
+
declare function createAttachedStores(urlOrGup: CoerceURI | GatewayUrlsParam, arOrLoadable: AttachedStores | Loadable, name?: string): Promise<Attached>;
|
885
|
+
declare class AttachedRemotesImpl implements AttachedStores {
|
886
|
+
private readonly _remotes;
|
887
|
+
readonly loadable: Loadable;
|
888
|
+
_local?: Attached;
|
889
|
+
constructor(loadable: Loadable);
|
890
|
+
forRemotes(action: (store: ActiveStore) => Promise<unknown>): Promise<void>;
|
891
|
+
remotes(): ActiveStore[];
|
892
|
+
local(): LocalActiveStore;
|
893
|
+
activate(store: DataAndMetaStore | CoerceURI): ActiveStore;
|
894
|
+
detach(): Promise<void>;
|
895
|
+
attach(attached: Attachable): Promise<Attached>;
|
896
|
+
}
|
897
|
+
|
758
898
|
declare class Loader implements Loadable {
|
759
899
|
readonly ebOpts: BlockstoreRuntime;
|
900
|
+
readonly logger: Logger;
|
760
901
|
readonly commitQueue: CommitQueue<CarGroup>;
|
761
|
-
|
762
|
-
readonly
|
763
|
-
readonly
|
764
|
-
readonly
|
902
|
+
isCompacting: boolean;
|
903
|
+
private readonly cidCache;
|
904
|
+
private readonly maxConcurrentCarReader;
|
905
|
+
private readonly maxConcurrentWrite;
|
906
|
+
readonly seenCompacted: LRUSet<string>;
|
765
907
|
readonly sthis: SuperThis;
|
766
908
|
readonly taskManager: TaskManager;
|
767
|
-
carLog: CarLog;
|
768
|
-
|
769
|
-
|
770
|
-
remoteFileStore?: DataStore;
|
771
|
-
private getBlockCache;
|
909
|
+
readonly carLog: CarLog;
|
910
|
+
readonly attachedStores: AttachedStores;
|
911
|
+
attach(attached: Attachable): Promise<Attached>;
|
772
912
|
private seenMeta;
|
773
|
-
private writeLimit;
|
774
|
-
private readonly _carStore;
|
775
|
-
carStore(): Promise<DataStore>;
|
776
|
-
private readonly _fileStore;
|
777
|
-
fileStore(): Promise<DataStore>;
|
778
|
-
private readonly _WALStore;
|
779
|
-
WALStore(): Promise<WALStore>;
|
780
|
-
private readonly _metaStore;
|
781
|
-
metaStore(): Promise<MetaStore>;
|
782
913
|
keyBag(): Promise<KeyBag>;
|
783
914
|
private readonly onceReady;
|
784
915
|
ready(): Promise<void>;
|
785
916
|
close(): Promise<void>;
|
786
917
|
destroy(): Promise<void>;
|
787
|
-
readonly logger: Logger;
|
788
918
|
constructor(sthis: SuperThis, ebOpts: BlockstoreOpts);
|
789
|
-
handleDbMetasFromStore(metas: DbMeta[]): Promise<void>;
|
790
|
-
mergeDbMetaIntoClock(meta: DbMeta): Promise<void>;
|
791
|
-
loadCarHeaderFromMeta<T>(
|
919
|
+
handleDbMetasFromStore(metas: DbMeta[], activeStore: ActiveStore): Promise<void>;
|
920
|
+
mergeDbMetaIntoClock(meta: DbMeta, activeStore: ActiveStore): Promise<void>;
|
921
|
+
loadCarHeaderFromMeta<T>(dbm: DbMeta, astore: ActiveStore): Promise<CarHeader<T>>;
|
792
922
|
commitFiles(t: CarTransaction, done: TransactionMeta): Promise<CarGroup>;
|
793
|
-
loadFileCar(cid: AnyLink): Promise<
|
923
|
+
loadFileCar(cid: AnyLink, store: ActiveStore): Promise<CarCacheItem>;
|
794
924
|
commit<T = TransactionMeta>(t: CarTransaction, done: T, opts?: CommitOpts): Promise<CarGroup>;
|
795
|
-
updateCarLog<T>(cids: CarGroup,
|
925
|
+
updateCarLog<T>(cids: CarGroup, cHeader: CarHeader<T>, compact: boolean): Promise<void>;
|
796
926
|
cacheTransaction(t: CarTransaction): Promise<void>;
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
protected
|
804
|
-
protected getMoreReaders(cids: AnyLink[]): Promise<void>;
|
927
|
+
removeCidsForCompact(cid: AnyLink, store: ActiveStore): Promise<void>;
|
928
|
+
entries(): AsyncIterableIterator<AnyBlock>;
|
929
|
+
getBlock(cid: AnyLink, store: ActiveStore): Promise<AnyBlock | Falsy>;
|
930
|
+
loadCar(cid: AnyLink, store: ActiveStore): Promise<CarCacheItem>;
|
931
|
+
private makeDecoderAndCarReader;
|
932
|
+
protected storesLoadCar(carCid: AnyLink, store: CIDActiveStore): Promise<CarCacheItem>;
|
933
|
+
protected getMoreReaders(cids: AnyLink[], store: ActiveStore): Promise<void>;
|
805
934
|
}
|
806
935
|
|
807
|
-
declare function parseCarFile<T>(reader:
|
808
|
-
|
809
|
-
declare abstract class ConnectionBase implements Connection {
|
810
|
-
private loader?;
|
811
|
-
taskManager?: TaskManager;
|
812
|
-
readonly context: Context;
|
813
|
-
readonly url: URI;
|
814
|
-
readonly logger: Logger;
|
815
|
-
constructor(url: URI, logger: Logger);
|
816
|
-
private readonly _loaded;
|
817
|
-
private _metaIsLoading;
|
818
|
-
loaded(): Future<void>;
|
819
|
-
refresh(): Promise<void>;
|
820
|
-
connect(refl: RefLoadable | RefBlockstore): Promise<void>;
|
821
|
-
connectMeta(refl: RefLoadable | RefBlockstore): Promise<void>;
|
822
|
-
abstract onConnect(): Promise<void>;
|
823
|
-
connectStorage(refl: RefLoadable | RefBlockstore): Promise<void>;
|
824
|
-
}
|
936
|
+
declare function parseCarFile<T>(reader: CarCacheItem, logger: Logger): Promise<CarHeader<T>>;
|
825
937
|
|
938
|
+
type index$5_ActiveStore = ActiveStore;
|
826
939
|
type index$5_AnyAnyBlock = AnyAnyBlock;
|
827
940
|
type index$5_AnyAnyLink = AnyAnyLink;
|
828
941
|
type index$5_AnyBlock = AnyBlock;
|
829
942
|
type index$5_AnyDecodedBlock = AnyDecodedBlock;
|
830
943
|
type index$5_AnyLink = AnyLink;
|
831
944
|
type index$5_AnyLinkFn = AnyLinkFn;
|
945
|
+
type index$5_AttachedRemotesImpl = AttachedRemotesImpl;
|
946
|
+
declare const index$5_AttachedRemotesImpl: typeof AttachedRemotesImpl;
|
947
|
+
type index$5_AttachedStores = AttachedStores;
|
948
|
+
type index$5_BaseActiveStore = BaseActiveStore;
|
949
|
+
declare const index$5_BaseActiveStore: typeof BaseActiveStore;
|
950
|
+
type index$5_BaseAttachedStores = BaseAttachedStores;
|
832
951
|
type index$5_BaseBlockstoreImpl = BaseBlockstoreImpl;
|
833
952
|
declare const index$5_BaseBlockstoreImpl: typeof BaseBlockstoreImpl;
|
834
953
|
type index$5_BaseStore = BaseStore;
|
@@ -838,14 +957,21 @@ type index$5_BlockstoreOpts = BlockstoreOpts;
|
|
838
957
|
type index$5_BlockstoreParams = BlockstoreParams;
|
839
958
|
type index$5_BlockstoreRuntime = BlockstoreRuntime;
|
840
959
|
type index$5_BytesAndKeyWithIv = BytesAndKeyWithIv;
|
960
|
+
type index$5_CIDActiveStore = CIDActiveStore;
|
841
961
|
type index$5_CIDBlock = CIDBlock;
|
842
962
|
declare const index$5_Car2FPMsg: typeof Car2FPMsg;
|
963
|
+
type index$5_CarActiveStore = CarActiveStore;
|
964
|
+
declare const index$5_CarActiveStore: typeof CarActiveStore;
|
965
|
+
type index$5_CarAttachedStores = CarAttachedStores;
|
966
|
+
type index$5_CarCacheItem = CarCacheItem;
|
843
967
|
type index$5_CarClockHead = CarClockHead;
|
844
968
|
type index$5_CarClockLink = CarClockLink;
|
845
969
|
type index$5_CarGroup = CarGroup;
|
846
970
|
type index$5_CarHeader<T> = CarHeader<T>;
|
847
971
|
type index$5_CarLog = CarLog;
|
972
|
+
declare const index$5_CarLog: typeof CarLog;
|
848
973
|
type index$5_CarMakeable = CarMakeable;
|
974
|
+
type index$5_CarStore = CarStore;
|
849
975
|
type index$5_CarTransactionImpl = CarTransactionImpl;
|
850
976
|
declare const index$5_CarTransactionImpl: typeof CarTransactionImpl;
|
851
977
|
type index$5_CarTransactionOpts = CarTransactionOpts;
|
@@ -856,11 +982,10 @@ type index$5_CompactFn = CompactFn;
|
|
856
982
|
type index$5_CompactionFetcher = CompactionFetcher;
|
857
983
|
declare const index$5_CompactionFetcher: typeof CompactionFetcher;
|
858
984
|
type index$5_Connection = Connection;
|
859
|
-
type index$5_ConnectionBase = ConnectionBase;
|
860
|
-
declare const index$5_ConnectionBase: typeof ConnectionBase;
|
861
985
|
type index$5_CryptoAction = CryptoAction;
|
986
|
+
type index$5_DataAndMetaAndWalStore = DataAndMetaAndWalStore;
|
987
|
+
type index$5_DataAndMetaStore = DataAndMetaStore;
|
862
988
|
type index$5_DataSaveOpts = DataSaveOpts;
|
863
|
-
type index$5_DataStore = DataStore;
|
864
989
|
type index$5_DbMeta = DbMeta;
|
865
990
|
type index$5_DbMetaBinary = DbMetaBinary;
|
866
991
|
type index$5_DbMetaEvent = DbMetaEvent;
|
@@ -879,6 +1004,11 @@ declare const index$5_FPEnvelopeTypes: typeof FPEnvelopeTypes;
|
|
879
1004
|
type index$5_FPEnvelopeWAL = FPEnvelopeWAL;
|
880
1005
|
type index$5_FPWALCarsOps = FPWALCarsOps;
|
881
1006
|
declare const index$5_File2FPMsg: typeof File2FPMsg;
|
1007
|
+
type index$5_FileActiveStore = FileActiveStore;
|
1008
|
+
declare const index$5_FileActiveStore: typeof FileActiveStore;
|
1009
|
+
type index$5_FileAttachedStores = FileAttachedStores;
|
1010
|
+
type index$5_FileStore = FileStore;
|
1011
|
+
type index$5_FroozenCarLog = FroozenCarLog;
|
882
1012
|
type index$5_Gateway = Gateway;
|
883
1013
|
type index$5_GatewayOpts = GatewayOpts;
|
884
1014
|
type index$5_GetResult = GetResult;
|
@@ -894,6 +1024,11 @@ type index$5_LoadHandler = LoadHandler;
|
|
894
1024
|
type index$5_Loadable = Loadable;
|
895
1025
|
type index$5_Loader = Loader;
|
896
1026
|
declare const index$5_Loader: typeof Loader;
|
1027
|
+
type index$5_LocalActiveStore = LocalActiveStore;
|
1028
|
+
type index$5_LocalDataAndMetaAndWalStore = LocalDataAndMetaAndWalStore;
|
1029
|
+
type index$5_MetaActiveStore = MetaActiveStore;
|
1030
|
+
declare const index$5_MetaActiveStore: typeof MetaActiveStore;
|
1031
|
+
type index$5_MetaAttachedStores = MetaAttachedStores;
|
897
1032
|
type index$5_MetaStore = MetaStore;
|
898
1033
|
type index$5_PassThroughGateway = PassThroughGateway;
|
899
1034
|
declare const index$5_PassThroughGateway: typeof PassThroughGateway;
|
@@ -932,12 +1067,22 @@ type index$5_StoreURIRuntime = StoreURIRuntime;
|
|
932
1067
|
type index$5_StoreURIs = StoreURIs;
|
933
1068
|
type index$5_StoreUrls = StoreUrls;
|
934
1069
|
type index$5_StoreUrlsOpts = StoreUrlsOpts;
|
1070
|
+
type index$5_TaskManager = TaskManager;
|
1071
|
+
declare const index$5_TaskManager: typeof TaskManager;
|
1072
|
+
type index$5_TaskManagerParams = TaskManagerParams;
|
935
1073
|
type index$5_TransactionMeta = TransactionMeta;
|
936
1074
|
type index$5_TransactionWrapper<M extends TransactionMeta> = TransactionWrapper<M>;
|
937
1075
|
type index$5_UnsubscribeResult = UnsubscribeResult;
|
1076
|
+
type index$5_UrlAndInterceptor = UrlAndInterceptor;
|
938
1077
|
type index$5_VoidResult = VoidResult;
|
1078
|
+
type index$5_WALActiveStore = WALActiveStore;
|
1079
|
+
declare const index$5_WALActiveStore: typeof WALActiveStore;
|
1080
|
+
type index$5_WALAttachedStores = WALAttachedStores;
|
939
1081
|
type index$5_WALState = WALState;
|
940
1082
|
type index$5_WALStore = WALStore;
|
1083
|
+
type index$5_WriteableDataAndMetaAndWalStore = WriteableDataAndMetaAndWalStore;
|
1084
|
+
type index$5_WriteableDataAndMetaStore = WriteableDataAndMetaStore;
|
1085
|
+
declare const index$5_createAttachedStores: typeof createAttachedStores;
|
941
1086
|
declare const index$5_createDbMetaEvent: typeof createDbMetaEvent;
|
942
1087
|
declare const index$5_defaultGatewayFactoryItem: typeof defaultGatewayFactoryItem;
|
943
1088
|
declare const index$5_ensureStoreEnDeFile: typeof ensureStoreEnDeFile;
|
@@ -949,7 +1094,7 @@ declare const index$5_registerStoreProtocol: typeof registerStoreProtocol;
|
|
949
1094
|
declare const index$5_toCIDBlock: typeof toCIDBlock;
|
950
1095
|
declare const index$5_toStoreRuntime: typeof toStoreRuntime;
|
951
1096
|
declare namespace index$5 {
|
952
|
-
export { type index$5_AnyAnyBlock as AnyAnyBlock, type index$5_AnyAnyLink as AnyAnyLink, type index$5_AnyBlock as AnyBlock, type index$5_AnyDecodedBlock as AnyDecodedBlock, type index$5_AnyLink as AnyLink, type index$5_AnyLinkFn as AnyLinkFn, index$5_BaseBlockstoreImpl as BaseBlockstoreImpl, type index$5_BaseStore as BaseStore, type index$5_BlobLike as BlobLike, type index$5_BlockFetcher as BlockFetcher, type index$5_BlockstoreOpts as BlockstoreOpts, type index$5_BlockstoreParams as BlockstoreParams, type index$5_BlockstoreRuntime as BlockstoreRuntime, type index$5_BytesAndKeyWithIv as BytesAndKeyWithIv, type index$5_CIDBlock as CIDBlock, index$5_Car2FPMsg as Car2FPMsg, type index$5_CarClockHead as CarClockHead, type index$5_CarClockLink as CarClockLink, type index$5_CarGroup as CarGroup, type index$5_CarHeader as CarHeader,
|
1097
|
+
export { type index$5_ActiveStore as ActiveStore, type index$5_AnyAnyBlock as AnyAnyBlock, type index$5_AnyAnyLink as AnyAnyLink, type index$5_AnyBlock as AnyBlock, type index$5_AnyDecodedBlock as AnyDecodedBlock, type index$5_AnyLink as AnyLink, type index$5_AnyLinkFn as AnyLinkFn, index$5_AttachedRemotesImpl as AttachedRemotesImpl, type index$5_AttachedStores as AttachedStores, index$5_BaseActiveStore as BaseActiveStore, type index$5_BaseAttachedStores as BaseAttachedStores, index$5_BaseBlockstoreImpl as BaseBlockstoreImpl, type index$5_BaseStore as BaseStore, type index$5_BlobLike as BlobLike, type index$5_BlockFetcher as BlockFetcher, type index$5_BlockstoreOpts as BlockstoreOpts, type index$5_BlockstoreParams as BlockstoreParams, type index$5_BlockstoreRuntime as BlockstoreRuntime, type index$5_BytesAndKeyWithIv as BytesAndKeyWithIv, type index$5_CIDActiveStore as CIDActiveStore, type index$5_CIDBlock as CIDBlock, index$5_Car2FPMsg as Car2FPMsg, index$5_CarActiveStore as CarActiveStore, type index$5_CarAttachedStores as CarAttachedStores, type index$5_CarCacheItem as CarCacheItem, type index$5_CarClockHead as CarClockHead, type index$5_CarClockLink as CarClockLink, type index$5_CarGroup as CarGroup, type index$5_CarHeader as CarHeader, index$5_CarLog as CarLog, type index$5_CarMakeable as CarMakeable, type index$5_CarStore as CarStore, index$5_CarTransactionImpl as CarTransactionImpl, type index$5_CarTransactionOpts as CarTransactionOpts, type index$5_CodecOpts as CodecOpts, type index$5_CommitOpts as CommitOpts, type index$5_CompactFetcher as CompactFetcher, type index$5_CompactFn as CompactFn, index$5_CompactionFetcher as CompactionFetcher, type index$5_Connection as Connection, type index$5_CryptoAction as CryptoAction, type index$5_DataAndMetaAndWalStore as DataAndMetaAndWalStore, type index$5_DataAndMetaStore as DataAndMetaStore, type index$5_DataSaveOpts as DataSaveOpts, type index$5_DbMeta as DbMeta, type index$5_DbMetaBinary as DbMetaBinary, type index$5_DbMetaEvent as DbMetaEvent, type index$5_DbMetaEventBlock as DbMetaEventBlock, index$5_DbMetaEventEqual as DbMetaEventEqual, index$5_DbMetaEventsEqual as DbMetaEventsEqual, type index$5_EncryptedBlock as EncryptedBlock, index$5_EncryptedBlockstore as EncryptedBlockstore, type index$5_FPEnvelope as FPEnvelope, type index$5_FPEnvelopeCar as FPEnvelopeCar, type index$5_FPEnvelopeFile as FPEnvelopeFile, type index$5_FPEnvelopeMeta as FPEnvelopeMeta, type index$5_FPEnvelopeType as FPEnvelopeType, index$5_FPEnvelopeTypes as FPEnvelopeTypes, type index$5_FPEnvelopeWAL as FPEnvelopeWAL, type index$5_FPWALCarsOps as FPWALCarsOps, index$5_File2FPMsg as File2FPMsg, index$5_FileActiveStore as FileActiveStore, type index$5_FileAttachedStores as FileAttachedStores, type index$5_FileStore as FileStore, type index$5_FroozenCarLog as FroozenCarLog, type index$5_Gateway as Gateway, type index$5_GatewayOpts as GatewayOpts, type index$5_GetResult as GetResult, index$5_InterceptorGateway as InterceptorGateway, type index$5_IvAndKeyAndBytes as IvAndKeyAndBytes, type index$5_IvKeyIdData as IvKeyIdData, type index$5_KeyMaterial as KeyMaterial, type index$5_KeyUpsertResult as KeyUpsertResult, type index$5_KeyWithFingerPrint as KeyWithFingerPrint, type index$5_KeysByFingerprint as KeysByFingerprint, type index$5_LoadHandler as LoadHandler, type index$5_Loadable as Loadable, index$5_Loader as Loader, type index$5_LocalActiveStore as LocalActiveStore, type index$5_LocalDataAndMetaAndWalStore as LocalDataAndMetaAndWalStore, index$5_MetaActiveStore as MetaActiveStore, type index$5_MetaAttachedStores as MetaAttachedStores, type index$5_MetaStore as MetaStore, index$5_PassThroughGateway as PassThroughGateway, type index$5_RefBlockstore as RefBlockstore, type index$5_RefLoadable as RefLoadable, type index$5_SerdeGateway as SerdeGateway, type index$5_SerdeGatewayBuildUrlOp as SerdeGatewayBuildUrlOp, type index$5_SerdeGatewayBuildUrlReturn as SerdeGatewayBuildUrlReturn, type index$5_SerdeGatewayCloseOp as SerdeGatewayCloseOp, type index$5_SerdeGatewayCloseReturn as SerdeGatewayCloseReturn, type index$5_SerdeGatewayCtx as SerdeGatewayCtx, type index$5_SerdeGatewayDeleteOp as SerdeGatewayDeleteOp, type index$5_SerdeGatewayDeleteReturn as SerdeGatewayDeleteReturn, type index$5_SerdeGatewayDestroyOp as SerdeGatewayDestroyOp, type index$5_SerdeGatewayDestroyReturn as SerdeGatewayDestroyReturn, type index$5_SerdeGatewayFactoryItem as SerdeGatewayFactoryItem, type index$5_SerdeGatewayGetOp as SerdeGatewayGetOp, type index$5_SerdeGatewayGetReturn as SerdeGatewayGetReturn, type index$5_SerdeGatewayInterceptor as SerdeGatewayInterceptor, type index$5_SerdeGatewayOpts as SerdeGatewayOpts, type index$5_SerdeGatewayPutOp as SerdeGatewayPutOp, type index$5_SerdeGatewayPutReturn as SerdeGatewayPutReturn, type index$5_SerdeGatewayReturn as SerdeGatewayReturn, type index$5_SerdeGatewayStartOp as SerdeGatewayStartOp, type index$5_SerdeGatewayStartReturn as SerdeGatewayStartReturn, type index$5_SerdeGatewaySubscribeOp as SerdeGatewaySubscribeOp, type index$5_SerdeGatewaySubscribeReturn as SerdeGatewaySubscribeReturn, type index$5_SerdeGetResult as SerdeGetResult, type index$5_SerdeOrGatewayFactoryItem as SerdeOrGatewayFactoryItem, type index$5_StoreEnDeFile as StoreEnDeFile, type index$5_StoreFactory as StoreFactory, type index$5_StoreFactoryItem as StoreFactoryItem, type index$5_StoreRuntime as StoreRuntime, type index$5_StoreRuntimeUrls as StoreRuntimeUrls, type index$5_StoreURIRuntime as StoreURIRuntime, type index$5_StoreURIs as StoreURIs, type index$5_StoreUrls as StoreUrls, type index$5_StoreUrlsOpts as StoreUrlsOpts, index$5_TaskManager as TaskManager, type index$5_TaskManagerParams as TaskManagerParams, type index$5_TransactionMeta as TransactionMeta, type index$5_TransactionWrapper as TransactionWrapper, type index$5_UnsubscribeResult as UnsubscribeResult, type index$5_UrlAndInterceptor as UrlAndInterceptor, type index$5_VoidResult as VoidResult, index$5_WALActiveStore as WALActiveStore, type index$5_WALAttachedStores as WALAttachedStores, type index$5_WALState as WALState, type index$5_WALStore as WALStore, type index$5_WriteableDataAndMetaAndWalStore as WriteableDataAndMetaAndWalStore, type index$5_WriteableDataAndMetaStore as WriteableDataAndMetaStore, index$5_createAttachedStores as createAttachedStores, index$5_createDbMetaEvent as createDbMetaEvent, index$5_defaultGatewayFactoryItem as defaultGatewayFactoryItem, index$5_ensureStoreEnDeFile as ensureStoreEnDeFile, index$5_getDefaultURI as getDefaultURI, index$5_getGatewayFactoryItem as getGatewayFactoryItem, index$5_getStartedGateway as getStartedGateway, index$5_parseCarFile as parseCarFile, index$5_registerStoreProtocol as registerStoreProtocol, index$5_toCIDBlock as toCIDBlock, index$5_toStoreRuntime as toStoreRuntime };
|
953
1098
|
}
|
954
1099
|
|
955
1100
|
interface WriteQueueParams {
|
@@ -1034,11 +1179,16 @@ declare const PARAM: {
|
|
1034
1179
|
FRAG_HEAD: string;
|
1035
1180
|
EXTRACTKEY: string;
|
1036
1181
|
SELF_REFLECT: string;
|
1182
|
+
CAR_PARALLEL: string;
|
1183
|
+
CAR_CACHE_SIZE: string;
|
1184
|
+
CAR_COMPACT_CACHE_SIZE: string;
|
1185
|
+
CAR_META_CACHE_SIZE: string;
|
1186
|
+
GENESIS_CID: string;
|
1037
1187
|
};
|
1038
1188
|
type PARAMS = (typeof PARAM)[keyof typeof PARAM];
|
1039
1189
|
declare function throwFalsy<T>(value: T | Falsy): T;
|
1040
1190
|
declare function falsyToUndef<T>(value: T | Falsy): T | undefined;
|
1041
|
-
type StoreType = "
|
1191
|
+
type StoreType = "car" | "file" | "wal" | "meta";
|
1042
1192
|
interface FPStats {
|
1043
1193
|
isFile(): boolean;
|
1044
1194
|
isDirectory(): boolean;
|
@@ -1268,6 +1418,7 @@ interface CarTransaction {
|
|
1268
1418
|
readonly parent: BaseBlockstore;
|
1269
1419
|
get<T, C extends number, A extends number, V extends Version>(cid: AnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
1270
1420
|
superGet(cid: AnyLink): Promise<AnyBlock | undefined>;
|
1421
|
+
unshift(cid: UnknownLink, bytes: Uint8Array<ArrayBufferLike>): void;
|
1271
1422
|
putSync(cid: UnknownLink, bytes: Uint8Array<ArrayBufferLike>): void;
|
1272
1423
|
put(cid: UnknownLink, bytes: Uint8Array<ArrayBufferLike>): Promise<void>;
|
1273
1424
|
entries(): AsyncIterableIterator<AnyBlock>;
|
@@ -1331,6 +1482,40 @@ interface ReadyCloseDestroy {
|
|
1331
1482
|
destroy(): Promise<void>;
|
1332
1483
|
ready(): Promise<void>;
|
1333
1484
|
}
|
1485
|
+
interface CoerceURIandInterceptor {
|
1486
|
+
readonly url: CoerceURI;
|
1487
|
+
readonly gatewayInterceptor?: SerdeGatewayInterceptor;
|
1488
|
+
}
|
1489
|
+
interface GatewayUrlsParam {
|
1490
|
+
readonly car: CoerceURIandInterceptor;
|
1491
|
+
readonly file: CoerceURIandInterceptor;
|
1492
|
+
readonly meta: CoerceURIandInterceptor;
|
1493
|
+
readonly wal?: CoerceURIandInterceptor;
|
1494
|
+
}
|
1495
|
+
interface GatewayUrls {
|
1496
|
+
readonly car: UrlAndInterceptor;
|
1497
|
+
readonly file: UrlAndInterceptor;
|
1498
|
+
readonly meta: UrlAndInterceptor;
|
1499
|
+
readonly wal?: UrlAndInterceptor;
|
1500
|
+
}
|
1501
|
+
interface Attachable {
|
1502
|
+
readonly name: string;
|
1503
|
+
prepare(): Promise<GatewayUrlsParam>;
|
1504
|
+
}
|
1505
|
+
declare class DataAndMetaAndWalAndBaseStore implements DataAndMetaAndWalStore {
|
1506
|
+
readonly wal?: WALStore | undefined;
|
1507
|
+
readonly file: FileStore;
|
1508
|
+
readonly car: CarStore;
|
1509
|
+
readonly meta: MetaStore;
|
1510
|
+
readonly baseStores: BaseStore[];
|
1511
|
+
constructor(dam: DataAndMetaAndWalStore);
|
1512
|
+
}
|
1513
|
+
interface Attached {
|
1514
|
+
readonly gatewayUrls: GatewayUrls;
|
1515
|
+
readonly stores: DataAndMetaAndWalAndBaseStore;
|
1516
|
+
detach(): Promise<void>;
|
1517
|
+
status(): "attached" | "loading" | "loaded" | "error" | "detached" | "syncing" | "idle";
|
1518
|
+
}
|
1334
1519
|
interface Database extends ReadyCloseDestroy, HasLogger, HasSuperThis {
|
1335
1520
|
readonly ledger: Ledger;
|
1336
1521
|
readonly logger: Logger;
|
@@ -1338,6 +1523,7 @@ interface Database extends ReadyCloseDestroy, HasLogger, HasSuperThis {
|
|
1338
1523
|
readonly id: string;
|
1339
1524
|
readonly name: string;
|
1340
1525
|
onClosed(fn: () => void): void;
|
1526
|
+
attach(a: Attachable): Promise<Attached>;
|
1341
1527
|
get<T extends DocTypes>(id: string): Promise<DocWithId<T>>;
|
1342
1528
|
put<T extends DocTypes>(doc: DocSet<T>): Promise<DocResponse>;
|
1343
1529
|
bulk<T extends DocTypes>(docs: DocSet<T>[]): Promise<BulkResponse>;
|
@@ -1378,6 +1564,7 @@ interface Ledger extends HasCRDT {
|
|
1378
1564
|
readonly name: string;
|
1379
1565
|
readonly context: Context;
|
1380
1566
|
onClosed(fn: () => void): () => void;
|
1567
|
+
attach(a: Attachable): Promise<Attached>;
|
1381
1568
|
close(): Promise<void>;
|
1382
1569
|
destroy(): Promise<void>;
|
1383
1570
|
ready(): Promise<void>;
|
@@ -1392,6 +1579,7 @@ declare class LedgerShell implements Ledger {
|
|
1392
1579
|
readonly writeQueue: WriteQueue<DocUpdate<DocTypes>>;
|
1393
1580
|
readonly name: string;
|
1394
1581
|
constructor(ref: LedgerImpl);
|
1582
|
+
attach(a: Attachable): Promise<Attached>;
|
1395
1583
|
get opts(): LedgerOpts;
|
1396
1584
|
get context(): Context;
|
1397
1585
|
get id(): string;
|
@@ -1426,6 +1614,7 @@ declare class LedgerImpl implements Ledger {
|
|
1426
1614
|
readonly sthis: SuperThis;
|
1427
1615
|
readonly id: string;
|
1428
1616
|
constructor(sthis: SuperThis, opts: LedgerOpts);
|
1617
|
+
attach(a: Attachable): Promise<Attached>;
|
1429
1618
|
subscribe<T extends DocTypes>(listener: ListenerFn<T>, updates?: boolean): () => void;
|
1430
1619
|
private _notify;
|
1431
1620
|
private _no_update_notify;
|
@@ -1444,6 +1633,7 @@ declare class DatabaseImpl implements Database {
|
|
1444
1633
|
readonly sthis: SuperThis;
|
1445
1634
|
readonly id: string;
|
1446
1635
|
constructor(ledger: Ledger);
|
1636
|
+
attach(a: Attachable): Promise<Attached>;
|
1447
1637
|
get name(): string;
|
1448
1638
|
get<T extends DocTypes>(id: string): Promise<DocWithId<T>>;
|
1449
1639
|
put<T extends DocTypes>(doc: DocSet<T>): Promise<DocResponse>;
|
@@ -1474,6 +1664,7 @@ declare class CRDTImpl implements CRDT {
|
|
1474
1664
|
readonly crdt: CRDT;
|
1475
1665
|
constructor(sthis: SuperThis, opts: LedgerOpts);
|
1476
1666
|
bulk<T extends DocTypes>(updates: DocUpdate<T>[]): Promise<CRDTMeta>;
|
1667
|
+
_bulk<T extends DocTypes>(updates: DocUpdate<T>[]): Promise<CRDTMeta>;
|
1477
1668
|
readonly onceReady: ResolveOnce<void>;
|
1478
1669
|
ready(): Promise<void>;
|
1479
1670
|
close(): Promise<void>;
|
@@ -1507,15 +1698,17 @@ declare namespace files {
|
|
1507
1698
|
export { files_decodeFile as decodeFile, files_encodeFile as encodeFile };
|
1508
1699
|
}
|
1509
1700
|
|
1510
|
-
declare class BlockIvKeyIdCodec implements
|
1511
|
-
readonly code =
|
1701
|
+
declare class BlockIvKeyIdCodec implements AsyncBlockCodec<24, Uint8Array, IvKeyIdData> {
|
1702
|
+
readonly code = 24;
|
1512
1703
|
readonly name = "Fireproof@encrypted-block:aes-gcm";
|
1513
1704
|
readonly ko: CryptoAction;
|
1514
1705
|
readonly iv?: Uint8Array;
|
1515
1706
|
readonly opts: Partial<CodecOpts>;
|
1516
1707
|
constructor(ko: CryptoAction, iv?: Uint8Array, opts?: CodecOpts);
|
1708
|
+
valueToHashBytes(value: IvKeyIdData): Promise<ByteView<unknown>>;
|
1709
|
+
bytesToHash(data: Uint8Array): Promise<ByteView<unknown>>;
|
1517
1710
|
encode(data: Uint8Array): Promise<Uint8Array>;
|
1518
|
-
decode(abytes: Uint8Array | ArrayBuffer): Promise<
|
1711
|
+
decode(abytes: Uint8Array | ArrayBuffer): Promise<IvKeyIdData>;
|
1519
1712
|
}
|
1520
1713
|
declare function keyedCryptoFactory(url: URI, kb: KeyBag, sthis: SuperThis): Promise<CryptoAction>;
|
1521
1714
|
|
@@ -1528,17 +1721,27 @@ declare namespace keyedCrypto {
|
|
1528
1721
|
|
1529
1722
|
declare const Block: typeof Block$2;
|
1530
1723
|
interface DecodeInput<T, Code extends number, Alg extends number> {
|
1531
|
-
bytes: ByteView<
|
1532
|
-
codec: BlockDecoder<Code, T>;
|
1533
|
-
hasher: MultihashHasher<Alg>;
|
1724
|
+
readonly bytes: ByteView<unknown>;
|
1725
|
+
readonly codec: BlockDecoder<Code, T>;
|
1726
|
+
readonly hasher: MultihashHasher<Alg>;
|
1534
1727
|
}
|
1535
|
-
|
1728
|
+
interface AsyncDecodeInput<T, Code extends number, Alg extends number> {
|
1729
|
+
readonly bytes: ByteView<unknown>;
|
1730
|
+
readonly codec: AsyncBlockDecoder<Code, T>;
|
1731
|
+
readonly hasher: MultihashHasher<Alg>;
|
1732
|
+
}
|
1733
|
+
declare function decode<T, Code extends number, Alg extends number>({ bytes, codec, hasher, }: AsyncDecodeInput<T, Code, Alg> | DecodeInput<T, Code, Alg>): Promise<BlockView<T, Code, Alg>>;
|
1536
1734
|
interface EncodeInput<T, Code extends number, Alg extends number> {
|
1537
|
-
value: T;
|
1538
|
-
codec: BlockEncoder<Code, T>;
|
1539
|
-
hasher: MultihashHasher<Alg>;
|
1735
|
+
readonly value: T;
|
1736
|
+
readonly codec: BlockEncoder<Code, T>;
|
1737
|
+
readonly hasher: MultihashHasher<Alg>;
|
1738
|
+
}
|
1739
|
+
interface AsyncEncodeInput<T, Code extends number, Alg extends number> {
|
1740
|
+
readonly value: T;
|
1741
|
+
readonly codec: AsyncBlockEncoder<Code, T>;
|
1742
|
+
readonly hasher: MultihashHasher<Alg>;
|
1540
1743
|
}
|
1541
|
-
declare function encode<T, Code extends number, Alg extends number>({ value, codec, hasher, }: EncodeInput<T, Code, Alg>): Promise<BlockView<T, Code, Alg>>;
|
1744
|
+
declare function encode<T, Code extends number, Alg extends number>({ value, codec, hasher, }: AsyncEncodeInput<T, Code, Alg> | EncodeInput<T, Code, Alg>): Promise<BlockView<T, Code, Alg>>;
|
1542
1745
|
interface CreateInput<T, Code extends number, Alg extends number, V extends Version> {
|
1543
1746
|
bytes: ByteView<T>;
|
1544
1747
|
cid: Link<T, Code, Alg, V>;
|
@@ -1559,13 +1762,17 @@ type CreateUnsafeInput<T, Code extends number, Alg extends number, V extends Ver
|
|
1559
1762
|
};
|
1560
1763
|
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>>;
|
1561
1764
|
|
1765
|
+
type block_AsyncDecodeInput<T, Code extends number, Alg extends number> = AsyncDecodeInput<T, Code, Alg>;
|
1766
|
+
type block_AsyncEncodeInput<T, Code extends number, Alg extends number> = AsyncEncodeInput<T, Code, Alg>;
|
1562
1767
|
declare const block_Block: typeof Block;
|
1768
|
+
type block_DecodeInput<T, Code extends number, Alg extends number> = DecodeInput<T, Code, Alg>;
|
1769
|
+
type block_EncodeInput<T, Code extends number, Alg extends number> = EncodeInput<T, Code, Alg>;
|
1563
1770
|
declare const block_create: typeof create;
|
1564
1771
|
declare const block_createUnsafe: typeof createUnsafe;
|
1565
1772
|
declare const block_decode: typeof decode;
|
1566
1773
|
declare const block_encode: typeof encode;
|
1567
1774
|
declare namespace block {
|
1568
|
-
export { block_Block as Block, block_create as create, block_createUnsafe as createUnsafe, block_decode as decode, block_encode as encode };
|
1775
|
+
export { type block_AsyncDecodeInput as AsyncDecodeInput, type block_AsyncEncodeInput as AsyncEncodeInput, block_Block as Block, type block_DecodeInput as DecodeInput, type block_EncodeInput as EncodeInput, block_create as create, block_createUnsafe as createUnsafe, block_decode as decode, block_encode as encode };
|
1569
1776
|
}
|
1570
1777
|
|
1571
1778
|
declare const index$3_block: typeof block;
|
@@ -1688,5 +1895,5 @@ declare namespace index {
|
|
1688
1895
|
|
1689
1896
|
declare const PACKAGE_VERSION: string;
|
1690
1897
|
|
1691
|
-
export { type AllDocsQueryOpts, type AllDocsResponse, type BaseBlockstore, type BulkResponse, type CRDT, type CRDTClock, type CRDTEntry, CRDTImpl, type CRDTMeta, type CarTransaction, type ChangesOptions, type ChangesResponse, type ChangesResponseRow, type ClockHead, type ClockLink, type ConfigOpts, type Database, DatabaseImpl, type DbMeta, 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 FPStats, type Falsy, type FileTransactionMeta, type HasCRDT, type HasLogger, type HasSuperThis, type IdxMeta, type IdxMetaMap, Index, type IndexKey, type IndexKeyType, type IndexRow, type IndexRows, type IndexTransactionMeta, type IndexUpdate, type IndexUpdateString, type Joiner, type KeyLiteral, type Ledger, LedgerFactory, type LedgerOpts, LedgerShell, type ListenerFn, type MapFn, type MetaType, type NoUpdateListenerFn, NotFoundError, PACKAGE_VERSION, PARAM, type PARAMS, type PathOps, type PromiseToUInt8, type QueryOpts, type ReadyCloseDestroy, type RefLedger, type Store, type StoreType, type SuperThis, type SuperThisOpts, type SysFileSystem, type TextEndeCoder, type ToUInt8, UInt8ArrayEqual, type UnReg, type UnknownDoc, type UpdateListenerFn, type VoidFn, type WriteQueue, index$5 as blockstore, index$5 as bs, coerceIntoUint8, coercePromiseIntoUint8, defaultWriteQueueOpts, ensureLogger, ensureSuperLog, ensureSuperThis, exceptionWrapper, falsyToUndef, fireproof, getKey, getName, getStore, index$4 as index, inplaceFilter, isDatabase, isFalsy, isLedger, isNotFoundError, keyConfigOpts, makeName, onSuperThis, index as rt, index as runtime, throwFalsy, toSortedArray, toStoreURIRuntime };
|
1898
|
+
export { type AllDocsQueryOpts, type AllDocsResponse, type Attachable, type Attached, type BaseBlockstore, type BulkResponse, type CRDT, type CRDTClock, type CRDTEntry, CRDTImpl, type CRDTMeta, type CarTransaction, type ChangesOptions, type ChangesResponse, type ChangesResponseRow, type ClockHead, type ClockLink, type CoerceURIandInterceptor, type ConfigOpts, DataAndMetaAndWalAndBaseStore, type Database, DatabaseImpl, type DbMeta, 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 FPStats, type Falsy, type FileTransactionMeta, type GatewayUrls, type GatewayUrlsParam, type HasCRDT, type HasLogger, type HasSuperThis, type IdxMeta, type IdxMetaMap, Index, type IndexKey, type IndexKeyType, type IndexRow, type IndexRows, type IndexTransactionMeta, type IndexUpdate, type IndexUpdateString, type Joiner, type KeyLiteral, type Ledger, LedgerFactory, type LedgerOpts, LedgerShell, type ListenerFn, type MapFn, type MetaType, type NoUpdateListenerFn, NotFoundError, PACKAGE_VERSION, PARAM, type PARAMS, type PathOps, type PromiseToUInt8, type QueryOpts, type ReadyCloseDestroy, type RefLedger, type Store, type StoreType, type SuperThis, type SuperThisOpts, type SysFileSystem, type TextEndeCoder, type ToUInt8, UInt8ArrayEqual, type UnReg, type UnknownDoc, type UpdateListenerFn, type VoidFn, type WriteQueue, index$5 as blockstore, index$5 as bs, coerceIntoUint8, coercePromiseIntoUint8, defaultWriteQueueOpts, ensureLogger, ensureSuperLog, ensureSuperThis, ensureURIDefaults, exceptionWrapper, falsyToUndef, fireproof, getKey, getName, getStore, index$4 as index, inplaceFilter, isDatabase, isFalsy, isLedger, isNotFoundError, keyConfigOpts, makeName, onSuperThis, index as rt, index as runtime, storeType2DataMetaWal, throwFalsy, toSortedArray, toStoreURIRuntime };
|
1692
1899
|
declare module '@fireproof/core'
|