@fireproof/core 0.20.0-dev-preview-39 → 0.20.0-dev-preview-41

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.
Files changed (38) hide show
  1. package/README.md +6 -4
  2. package/deno/index.js +2 -2
  3. package/deno/index.js.map +1 -1
  4. package/index.cjs +499 -370
  5. package/index.cjs.map +1 -1
  6. package/index.d.cts +162 -64
  7. package/index.d.ts +162 -64
  8. package/index.js +473 -344
  9. package/index.js.map +1 -1
  10. package/metafile-cjs.json +1 -1
  11. package/metafile-esm.json +1 -1
  12. package/package.json +3 -3
  13. package/react/index.cjs +28 -11
  14. package/react/index.cjs.map +1 -1
  15. package/react/index.d.cts +2 -1
  16. package/react/index.d.ts +2 -1
  17. package/react/index.js +29 -12
  18. package/react/index.js.map +1 -1
  19. package/react/metafile-cjs.json +1 -1
  20. package/react/metafile-esm.json +1 -1
  21. package/tests/blockstore/interceptor-gateway.test.ts +5 -1
  22. package/tests/blockstore/keyed-crypto-indexeddb-file.test.ts +8 -18
  23. package/tests/blockstore/keyed-crypto.test.ts +7 -30
  24. package/tests/blockstore/loader.test.ts +19 -17
  25. package/tests/blockstore/store.test.ts +48 -51
  26. package/tests/blockstore/transaction.test.ts +13 -11
  27. package/tests/fireproof/all-gateway.test.ts +49 -46
  28. package/tests/fireproof/attachable.test.ts +82 -0
  29. package/tests/fireproof/crdt.test.ts +49 -48
  30. package/tests/fireproof/database.test.ts +40 -40
  31. package/tests/fireproof/fireproof.test.ts +43 -42
  32. package/tests/fireproof/hello.test.ts +4 -4
  33. package/tests/fireproof/indexer.test.ts +44 -44
  34. package/tests/fireproof/utils.test.ts +4 -3
  35. package/tests/gateway/file/loader-config.test.ts +17 -17
  36. package/tests/gateway/indexeddb/loader-config.test.ts +4 -4
  37. package/tests/helpers.ts +80 -2
  38. package/tests/react/useFireproof.test.tsx +79 -4
package/index.d.ts CHANGED
@@ -206,9 +206,9 @@ declare class TaskManager {
206
206
  private queue;
207
207
  private isProcessing;
208
208
  readonly logger: Logger;
209
- readonly callback: (dbMeta: DbMeta) => Promise<void>;
210
- constructor(sthis: SuperThis, callback: (dbMeta: DbMeta) => Promise<void>);
211
- handleEvent(cid: CarClockLink, parents: CarClockHead, dbMeta: DbMeta): Promise<void>;
209
+ readonly callback: (dbMeta: DbMeta, store: ActiveStore) => Promise<void>;
210
+ constructor(sthis: SuperThis, callback: (dbMeta: DbMeta, store: ActiveStore) => Promise<void>);
211
+ handleEvent(cid: CarClockLink, parents: CarClockHead, dbMeta: DbMeta, store: ActiveStore): Promise<void>;
212
212
  private processQueue;
213
213
  }
214
214
 
@@ -517,7 +517,7 @@ interface StoreUrlsOpts {
517
517
  }
518
518
  interface StoreURIs {
519
519
  readonly meta: URI;
520
- readonly data: URI;
520
+ readonly car: URI;
521
521
  readonly file: URI;
522
522
  readonly wal: URI;
523
523
  }
@@ -525,15 +525,16 @@ interface StoreURIRuntime {
525
525
  readonly data: StoreURIs;
526
526
  readonly idx: StoreURIs;
527
527
  }
528
- interface StoreFactoryItem {
528
+ interface UrlAndInterceptor {
529
529
  readonly url: URI;
530
530
  readonly gatewayInterceptor?: SerdeGatewayInterceptor;
531
+ }
532
+ interface StoreFactoryItem {
533
+ readonly byStore: GatewayUrls;
531
534
  readonly loader: Loadable;
532
535
  }
533
536
  interface StoreRuntime {
534
- makeMetaStore(sfi: StoreFactoryItem): Promise<MetaStore>;
535
- makeDataStore(sfi: StoreFactoryItem): Promise<DataStore>;
536
- makeWALStore(sfi: StoreFactoryItem): Promise<WALStore>;
537
+ makeStores(sfi: StoreFactoryItem): Promise<DataAndMetaAndWalStore>;
537
538
  encodeFile(blob: BlobLike): Promise<{
538
539
  cid: AnyLink;
539
540
  blocks: AnyBlock[];
@@ -544,6 +545,19 @@ interface CommitOpts {
544
545
  readonly noLoader?: boolean;
545
546
  readonly compact?: boolean;
546
547
  }
548
+ interface WriteableDataAndMetaStore {
549
+ file: DataStore;
550
+ car: DataStore;
551
+ meta: MetaStore;
552
+ }
553
+ type DataAndMetaStore = Readonly<WriteableDataAndMetaStore>;
554
+ interface WriteableDataAndMetaAndWalStore extends WriteableDataAndMetaStore {
555
+ wal?: WALStore;
556
+ }
557
+ type DataAndMetaAndWalStore = Readonly<WriteableDataAndMetaAndWalStore>;
558
+ type LocalDataAndMetaAndWalStore = Readonly<Omit<WriteableDataAndMetaAndWalStore, "wal">> & {
559
+ readonly wal: WALStore;
560
+ };
547
561
  interface DbMeta {
548
562
  readonly cars: CarGroup;
549
563
  }
@@ -562,14 +576,13 @@ interface Connection {
562
576
  interface BaseStore {
563
577
  readonly storeType: StoreType;
564
578
  readonly realGateway: SerdeGateway;
579
+ readonly logger: Logger;
565
580
  url(): URI;
566
- onStarted(fn: () => void): void;
567
- onClosed(fn: () => void): void;
568
581
  keyedCrypto(): Promise<CryptoAction>;
569
582
  close(): Promise<Result<void>>;
570
583
  destroy(): Promise<Result<void>>;
571
584
  readonly ready?: () => Promise<void>;
572
- start(): Promise<Result<URI>>;
585
+ start(dam: DataAndMetaStore): Promise<Result<URI>>;
573
586
  }
574
587
  interface DbMetaEvent {
575
588
  readonly eventCid: CarClockLink;
@@ -653,27 +666,69 @@ interface BlockstoreRuntime {
653
666
  readonly meta?: DbMeta;
654
667
  readonly threshold: number;
655
668
  }
669
+ type LocalActiveStore = Omit<ActiveStore, "active"> & {
670
+ readonly active: LocalDataAndMetaAndWalStore;
671
+ };
672
+ interface AttachedStores {
673
+ local(): LocalActiveStore;
674
+ forRemotes(actionFn: (store: ActiveStore) => Promise<unknown>): Promise<void>;
675
+ remotes(): ActiveStore[];
676
+ activate(store: DataAndMetaStore): ActiveStore;
677
+ attach(attached: Attachable): Promise<Attached>;
678
+ detach(): Promise<void>;
679
+ }
680
+ interface DataAttachedStores {
681
+ local(): DataStore;
682
+ remotes(): DataStore[];
683
+ }
684
+ interface DataActiveStore {
685
+ readonly ref: ActiveStore;
686
+ readonly active: DataStore;
687
+ readonly attached: DataAttachedStores;
688
+ }
689
+ interface MetaAttachedStores {
690
+ local(): MetaStore;
691
+ remotes(): MetaStore[];
692
+ }
693
+ interface MetaActiveStore {
694
+ readonly ref: ActiveStore;
695
+ readonly active: MetaStore;
696
+ readonly attached: MetaAttachedStores;
697
+ }
698
+ interface WALAttachedStores {
699
+ local(): WALStore;
700
+ remotes(): WALStore[];
701
+ }
702
+ interface WALActiveStore {
703
+ readonly ref: ActiveStore;
704
+ readonly active: WALStore;
705
+ readonly attached: WALAttachedStores;
706
+ }
707
+ interface ActiveStore {
708
+ readonly active: DataAndMetaAndWalStore;
709
+ baseStores(): BaseStore[];
710
+ carStore(): DataActiveStore;
711
+ fileStore(): DataActiveStore;
712
+ metaStore(): MetaActiveStore;
713
+ walStore(): WALActiveStore;
714
+ readonly attached: AttachedStores;
715
+ }
656
716
  interface Loadable {
657
717
  readonly sthis: SuperThis;
658
718
  readonly ebOpts: BlockstoreRuntime;
659
719
  carLog: CarLog;
660
- remoteMetaStore?: MetaStore;
661
- remoteFileStore?: DataStore;
662
- remoteCarStore?: DataStore;
720
+ readonly attachedStores: AttachedStores;
721
+ attach(attached: Attachable): Promise<Attached>;
663
722
  readonly taskManager: TaskManager;
664
723
  ready(): Promise<void>;
665
724
  close(): Promise<void>;
666
725
  keyBag(): Promise<KeyBag>;
667
- metaStore(): Promise<MetaStore>;
668
- fileStore(): Promise<DataStore>;
669
- WALStore(): Promise<WALStore>;
670
- carStore(): Promise<DataStore>;
671
- handleDbMetasFromStore(metas: DbMeta[]): Promise<void>;
726
+ handleDbMetasFromStore(metas: DbMeta[], store: ActiveStore): Promise<void>;
672
727
  commit<T = TransactionMeta>(t: CarTransaction, done: T, opts: CommitOpts): Promise<CarGroup>;
673
728
  destroy(): Promise<void>;
674
- getBlock(cid: AnyLink): Promise<AnyBlock | Falsy>;
675
- loadFileCar(cid: AnyLink): Promise<CarReader>;
676
- loadCar(cid: AnyLink): Promise<CarReader>;
729
+ getBlock(cid: AnyLink, store: ActiveStore): Promise<AnyBlock | Falsy>;
730
+ loadFileCar(cid: AnyLink, store: ActiveStore): Promise<CarReader>;
731
+ loadCar(cid: AnyLink, store: ActiveStore): Promise<CarReader>;
677
732
  commitFiles(t: CarTransaction, done: TransactionMeta): Promise<CarGroup>;
678
733
  entries(cache?: boolean): AsyncIterableIterator<AnyBlock>;
679
734
  }
@@ -755,6 +810,20 @@ declare function registerStoreProtocol(item: SerdeOrGatewayFactoryItem): () => v
755
810
  declare function getGatewayFactoryItem(protocol: string): SerdeGatewayFactoryItem | undefined;
756
811
  declare function defaultGatewayFactoryItem(): SerdeGatewayFactoryItem;
757
812
 
813
+ declare function createAttachedStores(urlOrGup: CoerceURI | GatewayUrlsParam, arOrLoadable: AttachedStores | Loadable, name?: string): Promise<Attached>;
814
+ declare class AttachedRemotesImpl implements AttachedStores {
815
+ private readonly _remotes;
816
+ readonly loadable: Loadable;
817
+ _local?: Attached;
818
+ constructor(loadable: Loadable);
819
+ forRemotes(action: (store: ActiveStore) => Promise<unknown>): Promise<void>;
820
+ remotes(): ActiveStore[];
821
+ local(): LocalActiveStore;
822
+ activate(store: DataAndMetaStore | CoerceURI): ActiveStore;
823
+ detach(): Promise<void>;
824
+ attach(attached: Attachable): Promise<Attached>;
825
+ }
826
+
758
827
  declare class Loader implements Loadable {
759
828
  readonly ebOpts: BlockstoreRuntime;
760
829
  readonly commitQueue: CommitQueue<CarGroup>;
@@ -765,20 +834,11 @@ declare class Loader implements Loadable {
765
834
  readonly sthis: SuperThis;
766
835
  readonly taskManager: TaskManager;
767
836
  carLog: CarLog;
768
- remoteMetaStore?: MetaStore;
769
- remoteCarStore?: DataStore;
770
- remoteFileStore?: DataStore;
837
+ readonly attachedStores: AttachedStores;
838
+ attach(attached: Attachable): Promise<Attached>;
771
839
  private getBlockCache;
772
840
  private seenMeta;
773
841
  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
842
  keyBag(): Promise<KeyBag>;
783
843
  private readonly onceReady;
784
844
  ready(): Promise<void>;
@@ -786,49 +846,36 @@ declare class Loader implements Loadable {
786
846
  destroy(): Promise<void>;
787
847
  readonly logger: Logger;
788
848
  constructor(sthis: SuperThis, ebOpts: BlockstoreOpts);
789
- handleDbMetasFromStore(metas: DbMeta[]): Promise<void>;
790
- mergeDbMetaIntoClock(meta: DbMeta): Promise<void>;
791
- loadCarHeaderFromMeta<T>({ cars: cids }: DbMeta): Promise<CarHeader<T>>;
849
+ handleDbMetasFromStore(metas: DbMeta[], activeStore: ActiveStore): Promise<void>;
850
+ mergeDbMetaIntoClock(meta: DbMeta, activeStore: ActiveStore): Promise<void>;
851
+ loadCarHeaderFromMeta<T>(dbm: DbMeta, astore: ActiveStore): Promise<CarHeader<T>>;
792
852
  commitFiles(t: CarTransaction, done: TransactionMeta): Promise<CarGroup>;
793
- loadFileCar(cid: AnyLink): Promise<CarReader$1>;
853
+ loadFileCar(cid: AnyLink, store: ActiveStore): Promise<CarReader$1>;
794
854
  commit<T = TransactionMeta>(t: CarTransaction, done: T, opts?: CommitOpts): Promise<CarGroup>;
795
855
  updateCarLog<T>(cids: CarGroup, fp: CarHeader<T>, compact: boolean): Promise<void>;
796
856
  cacheTransaction(t: CarTransaction): Promise<void>;
797
857
  cacheCarReader(carCidStr: string, reader: CarReader$1): Promise<void>;
798
- removeCidsForCompact(cid: AnyLink): Promise<void>;
858
+ removeCidsForCompact(cid: AnyLink, store: ActiveStore): Promise<void>;
799
859
  entries(cache?: boolean): AsyncIterableIterator<AnyBlock>;
800
- getBlock(cid: AnyLink): Promise<AnyBlock | Falsy>;
801
- loadCar(cid: AnyLink): Promise<CarReader$1>;
802
- makeDecoderAndCarReader(cid: AnyLink, local: DataStore, remote?: DataStore): Promise<CarReader$1>;
803
- protected storesLoadCar(cid: AnyLink, local: DataStore, remote?: DataStore): Promise<CarReader$1>;
804
- protected getMoreReaders(cids: AnyLink[]): Promise<void>;
860
+ getBlock(cid: AnyLink, store: ActiveStore): Promise<AnyBlock | Falsy>;
861
+ loadCar(cid: AnyLink, store: ActiveStore): Promise<CarReader$1>;
862
+ makeDecoderAndCarReader(cid: AnyLink, store: DataActiveStore): Promise<CarReader$1>;
863
+ protected storesLoadCar(cid: AnyLink, store: DataActiveStore): Promise<CarReader$1>;
864
+ protected getMoreReaders(cids: AnyLink[], store: ActiveStore): Promise<void>;
805
865
  }
806
866
 
807
867
  declare function parseCarFile<T>(reader: CarReader$1, logger: Logger): Promise<CarHeader<T>>;
808
868
 
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
- }
825
-
869
+ type index$5_ActiveStore = ActiveStore;
826
870
  type index$5_AnyAnyBlock = AnyAnyBlock;
827
871
  type index$5_AnyAnyLink = AnyAnyLink;
828
872
  type index$5_AnyBlock = AnyBlock;
829
873
  type index$5_AnyDecodedBlock = AnyDecodedBlock;
830
874
  type index$5_AnyLink = AnyLink;
831
875
  type index$5_AnyLinkFn = AnyLinkFn;
876
+ type index$5_AttachedRemotesImpl = AttachedRemotesImpl;
877
+ declare const index$5_AttachedRemotesImpl: typeof AttachedRemotesImpl;
878
+ type index$5_AttachedStores = AttachedStores;
832
879
  type index$5_BaseBlockstoreImpl = BaseBlockstoreImpl;
833
880
  declare const index$5_BaseBlockstoreImpl: typeof BaseBlockstoreImpl;
834
881
  type index$5_BaseStore = BaseStore;
@@ -856,9 +903,11 @@ type index$5_CompactFn = CompactFn;
856
903
  type index$5_CompactionFetcher = CompactionFetcher;
857
904
  declare const index$5_CompactionFetcher: typeof CompactionFetcher;
858
905
  type index$5_Connection = Connection;
859
- type index$5_ConnectionBase = ConnectionBase;
860
- declare const index$5_ConnectionBase: typeof ConnectionBase;
861
906
  type index$5_CryptoAction = CryptoAction;
907
+ type index$5_DataActiveStore = DataActiveStore;
908
+ type index$5_DataAndMetaAndWalStore = DataAndMetaAndWalStore;
909
+ type index$5_DataAndMetaStore = DataAndMetaStore;
910
+ type index$5_DataAttachedStores = DataAttachedStores;
862
911
  type index$5_DataSaveOpts = DataSaveOpts;
863
912
  type index$5_DataStore = DataStore;
864
913
  type index$5_DbMeta = DbMeta;
@@ -894,6 +943,10 @@ type index$5_LoadHandler = LoadHandler;
894
943
  type index$5_Loadable = Loadable;
895
944
  type index$5_Loader = Loader;
896
945
  declare const index$5_Loader: typeof Loader;
946
+ type index$5_LocalActiveStore = LocalActiveStore;
947
+ type index$5_LocalDataAndMetaAndWalStore = LocalDataAndMetaAndWalStore;
948
+ type index$5_MetaActiveStore = MetaActiveStore;
949
+ type index$5_MetaAttachedStores = MetaAttachedStores;
897
950
  type index$5_MetaStore = MetaStore;
898
951
  type index$5_PassThroughGateway = PassThroughGateway;
899
952
  declare const index$5_PassThroughGateway: typeof PassThroughGateway;
@@ -935,9 +988,15 @@ type index$5_StoreUrlsOpts = StoreUrlsOpts;
935
988
  type index$5_TransactionMeta = TransactionMeta;
936
989
  type index$5_TransactionWrapper<M extends TransactionMeta> = TransactionWrapper<M>;
937
990
  type index$5_UnsubscribeResult = UnsubscribeResult;
991
+ type index$5_UrlAndInterceptor = UrlAndInterceptor;
938
992
  type index$5_VoidResult = VoidResult;
993
+ type index$5_WALActiveStore = WALActiveStore;
994
+ type index$5_WALAttachedStores = WALAttachedStores;
939
995
  type index$5_WALState = WALState;
940
996
  type index$5_WALStore = WALStore;
997
+ type index$5_WriteableDataAndMetaAndWalStore = WriteableDataAndMetaAndWalStore;
998
+ type index$5_WriteableDataAndMetaStore = WriteableDataAndMetaStore;
999
+ declare const index$5_createAttachedStores: typeof createAttachedStores;
941
1000
  declare const index$5_createDbMetaEvent: typeof createDbMetaEvent;
942
1001
  declare const index$5_defaultGatewayFactoryItem: typeof defaultGatewayFactoryItem;
943
1002
  declare const index$5_ensureStoreEnDeFile: typeof ensureStoreEnDeFile;
@@ -949,7 +1008,7 @@ declare const index$5_registerStoreProtocol: typeof registerStoreProtocol;
949
1008
  declare const index$5_toCIDBlock: typeof toCIDBlock;
950
1009
  declare const index$5_toStoreRuntime: typeof toStoreRuntime;
951
1010
  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, type index$5_CarLog as CarLog, type index$5_CarMakeable as CarMakeable, 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, index$5_ConnectionBase as ConnectionBase, type index$5_CryptoAction as CryptoAction, type index$5_DataSaveOpts as DataSaveOpts, type index$5_DataStore as DataStore, 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, 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_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, type index$5_TransactionMeta as TransactionMeta, type index$5_TransactionWrapper as TransactionWrapper, type index$5_UnsubscribeResult as UnsubscribeResult, type index$5_VoidResult as VoidResult, type index$5_WALState as WALState, type index$5_WALStore as WALStore, 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 };
1011
+ 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_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, type index$5_CarLog as CarLog, type index$5_CarMakeable as CarMakeable, 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_DataActiveStore as DataActiveStore, type index$5_DataAndMetaAndWalStore as DataAndMetaAndWalStore, type index$5_DataAndMetaStore as DataAndMetaStore, type index$5_DataAttachedStores as DataAttachedStores, type index$5_DataSaveOpts as DataSaveOpts, type index$5_DataStore as DataStore, 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, 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, type 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, 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, type 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
1012
  }
954
1013
 
955
1014
  interface WriteQueueParams {
@@ -1331,6 +1390,40 @@ interface ReadyCloseDestroy {
1331
1390
  destroy(): Promise<void>;
1332
1391
  ready(): Promise<void>;
1333
1392
  }
1393
+ interface CoerceURIandInterceptor {
1394
+ readonly url: CoerceURI;
1395
+ readonly gatewayInterceptor?: SerdeGatewayInterceptor;
1396
+ }
1397
+ interface GatewayUrlsParam {
1398
+ readonly car: CoerceURIandInterceptor;
1399
+ readonly file: CoerceURIandInterceptor;
1400
+ readonly meta: CoerceURIandInterceptor;
1401
+ readonly wal?: CoerceURIandInterceptor;
1402
+ }
1403
+ interface GatewayUrls {
1404
+ readonly car: UrlAndInterceptor;
1405
+ readonly file: UrlAndInterceptor;
1406
+ readonly meta: UrlAndInterceptor;
1407
+ readonly wal?: UrlAndInterceptor;
1408
+ }
1409
+ interface Attachable {
1410
+ readonly name: string;
1411
+ prepare(): Promise<GatewayUrlsParam>;
1412
+ }
1413
+ declare class DataAndMetaAndWalAndBaseStore implements DataAndMetaAndWalStore {
1414
+ readonly wal?: WALStore | undefined;
1415
+ readonly file: DataStore;
1416
+ readonly car: DataStore;
1417
+ readonly meta: MetaStore;
1418
+ readonly baseStores: BaseStore[];
1419
+ constructor(dam: DataAndMetaAndWalStore);
1420
+ }
1421
+ interface Attached {
1422
+ readonly gatewayUrls: GatewayUrls;
1423
+ readonly stores: DataAndMetaAndWalAndBaseStore;
1424
+ detach(): Promise<void>;
1425
+ status(): "attached" | "loading" | "loaded" | "error" | "detached" | "syncing" | "idle";
1426
+ }
1334
1427
  interface Database extends ReadyCloseDestroy, HasLogger, HasSuperThis {
1335
1428
  readonly ledger: Ledger;
1336
1429
  readonly logger: Logger;
@@ -1338,6 +1431,7 @@ interface Database extends ReadyCloseDestroy, HasLogger, HasSuperThis {
1338
1431
  readonly id: string;
1339
1432
  readonly name: string;
1340
1433
  onClosed(fn: () => void): void;
1434
+ attach(a: Attachable): Promise<Attached>;
1341
1435
  get<T extends DocTypes>(id: string): Promise<DocWithId<T>>;
1342
1436
  put<T extends DocTypes>(doc: DocSet<T>): Promise<DocResponse>;
1343
1437
  bulk<T extends DocTypes>(docs: DocSet<T>[]): Promise<BulkResponse>;
@@ -1378,6 +1472,7 @@ interface Ledger extends HasCRDT {
1378
1472
  readonly name: string;
1379
1473
  readonly context: Context;
1380
1474
  onClosed(fn: () => void): () => void;
1475
+ attach(a: Attachable): Promise<Attached>;
1381
1476
  close(): Promise<void>;
1382
1477
  destroy(): Promise<void>;
1383
1478
  ready(): Promise<void>;
@@ -1392,6 +1487,7 @@ declare class LedgerShell implements Ledger {
1392
1487
  readonly writeQueue: WriteQueue<DocUpdate<DocTypes>>;
1393
1488
  readonly name: string;
1394
1489
  constructor(ref: LedgerImpl);
1490
+ attach(a: Attachable): Promise<Attached>;
1395
1491
  get opts(): LedgerOpts;
1396
1492
  get context(): Context;
1397
1493
  get id(): string;
@@ -1426,6 +1522,7 @@ declare class LedgerImpl implements Ledger {
1426
1522
  readonly sthis: SuperThis;
1427
1523
  readonly id: string;
1428
1524
  constructor(sthis: SuperThis, opts: LedgerOpts);
1525
+ attach(a: Attachable): Promise<Attached>;
1429
1526
  subscribe<T extends DocTypes>(listener: ListenerFn<T>, updates?: boolean): () => void;
1430
1527
  private _notify;
1431
1528
  private _no_update_notify;
@@ -1444,6 +1541,7 @@ declare class DatabaseImpl implements Database {
1444
1541
  readonly sthis: SuperThis;
1445
1542
  readonly id: string;
1446
1543
  constructor(ledger: Ledger);
1544
+ attach(a: Attachable): Promise<Attached>;
1447
1545
  get name(): string;
1448
1546
  get<T extends DocTypes>(id: string): Promise<DocWithId<T>>;
1449
1547
  put<T extends DocTypes>(doc: DocSet<T>): Promise<DocResponse>;
@@ -1688,5 +1786,5 @@ declare namespace index {
1688
1786
 
1689
1787
  declare const PACKAGE_VERSION: string;
1690
1788
 
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 };
1789
+ 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, 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 };
1692
1790
  declare module '@fireproof/core'