@fireproof/core 0.20.0-dev-preview-06 → 0.20.0-dev-preview-10
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +9 -9
- package/index.cjs +3227 -3166
- package/index.cjs.map +1 -1
- package/index.d.cts +245 -189
- package/index.d.ts +245 -189
- package/index.js +3217 -3156
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +3 -3
- package/react/index.cjs +1 -1
- package/react/index.cjs.map +1 -1
- package/react/index.js +1 -1
- 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 +1 -1
- package/tests/blockstore/loader.test.ts +6 -6
- package/tests/blockstore/transaction.test.ts +8 -8
- package/tests/fireproof/all-gateway.test.ts +7 -7
- package/tests/fireproof/crdt.test.ts +35 -45
- package/tests/fireproof/database.test.ts +34 -33
- package/tests/fireproof/fireproof.test.ts +66 -68
- package/tests/fireproof/hello.test.ts +8 -8
- package/tests/fireproof/indexer.test.ts +37 -36
- package/tests/fireproof/{multiple-database.test.ts → multiple-ledger.test.ts} +1 -1
- package/tests/gateway/file/loader-config.test.ts +21 -21
- package/tests/gateway/indexdb/loader-config.test.ts +6 -6
- package/tests/www/gallery.html +2 -2
- package/tests/www/todo-aws.html +1 -1
- package/tests/www/todo-ipfs.html +1 -1
- package/tests/www/todo-local.html +1 -1
- package/tests/www/todo.html +1 -1
package/index.d.cts
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
import { Logger, Future, ResolveOnce, URI, Result, ResolveSeq, CoerceURI, CryptoRuntime, CTCryptoKey, 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 { ByteView, ArrayBufferView, Version, Block as Block$1, CID, Link, BlockView, MultihashHasher } from 'multiformats';
|
5
|
-
import { MemoryBlockstore } from '@fireproof/vendor/@web3-storage/pail/block';
|
4
|
+
import { ByteView, ArrayBufferView, Version, Block as Block$1, UnknownLink, CID, Link, BlockView, MultihashHasher } from 'multiformats';
|
6
5
|
import { BlockFetcher as BlockFetcher$1 } from '@fireproof/vendor/@web3-storage/pail/api';
|
7
6
|
import { EventBlock } from '@fireproof/vendor/@web3-storage/pail/clock';
|
8
7
|
import { CarReader } from '@fireproof/vendor/@ipld/car';
|
9
8
|
import { ProllyNode as ProllyNode$1 } from 'prolly-trees/db-index';
|
10
|
-
import { SuperThis as SuperThis$1 } from '@fireproof/core';
|
11
9
|
import { CarReader as CarReader$1 } from '@fireproof/vendor/@ipld/car/reader';
|
10
|
+
import { SuperThis as SuperThis$1 } from '@fireproof/core';
|
12
11
|
import { Block as Block$2 } from 'multiformats/block';
|
13
12
|
|
14
13
|
interface BlockEncoder<Code extends number, T> {
|
@@ -37,17 +36,17 @@ interface CarTransactionOpts {
|
|
37
36
|
readonly add: boolean;
|
38
37
|
readonly noLoader: boolean;
|
39
38
|
}
|
40
|
-
|
41
|
-
|
42
|
-
readonly noLoader: boolean;
|
43
|
-
}
|
44
|
-
declare class CarTransaction extends MemoryBlockstore implements CarMakeable {
|
39
|
+
declare class CarTransactionImpl implements CarMakeable, CarTransaction {
|
40
|
+
#private;
|
45
41
|
readonly parent: BaseBlockstore;
|
46
42
|
constructor(parent: BaseBlockstore, opts?: CarTransactionOpts);
|
47
43
|
get<T, C extends number, A extends number, V extends Version>(cid: AnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
48
44
|
superGet(cid: AnyLink): Promise<AnyBlock | undefined>;
|
45
|
+
put(cid: AnyLink, block: Uint8Array): Promise<void>;
|
46
|
+
putSync(cid: UnknownLink, bytes: Uint8Array<ArrayBufferLike>): void;
|
47
|
+
entries(): AsyncIterableIterator<AnyBlock>;
|
49
48
|
}
|
50
|
-
declare class
|
49
|
+
declare class BaseBlockstoreImpl implements BlockFetcher {
|
51
50
|
readonly transactions: Set<CarTransaction>;
|
52
51
|
readonly ebOpts: BlockstoreRuntime;
|
53
52
|
readonly sthis: SuperThis;
|
@@ -66,7 +65,7 @@ declare class BaseBlockstore implements BlockFetcher {
|
|
66
65
|
commitTransaction<M extends TransactionMeta>(t: CarTransaction, done: M, opts: CarTransactionOpts): Promise<TransactionWrapper<M>>;
|
67
66
|
entries(): AsyncIterableIterator<AnyBlock>;
|
68
67
|
}
|
69
|
-
declare class EncryptedBlockstore extends
|
68
|
+
declare class EncryptedBlockstore extends BaseBlockstoreImpl {
|
70
69
|
ready(): Promise<void>;
|
71
70
|
close(): Promise<void>;
|
72
71
|
destroy(): Promise<void>;
|
@@ -198,6 +197,7 @@ declare function inplaceFilter<T>(i: T[], pred: (i: T, idx: number) => boolean):
|
|
198
197
|
declare function toSortedArray(set?: Record<string, unknown>): Record<string, unknown>[];
|
199
198
|
declare function coerceIntoUint8(raw: ToUInt8): Result<Uint8Array>;
|
200
199
|
declare function coercePromiseIntoUint8(raw: PromiseToUInt8): Promise<Result<Uint8Array>>;
|
200
|
+
declare function makeName(fnString: string): string;
|
201
201
|
|
202
202
|
declare enum FPEnvelopeType {
|
203
203
|
CAR = "car",
|
@@ -332,7 +332,7 @@ interface AnyDecodedBlock {
|
|
332
332
|
readonly value: Uint8Array;
|
333
333
|
}
|
334
334
|
interface CarMakeable {
|
335
|
-
entries():
|
335
|
+
entries(): AsyncIterable<AnyBlock>;
|
336
336
|
get(cid: AnyLink): Promise<AnyBlock | undefined>;
|
337
337
|
}
|
338
338
|
interface CarHeader<T> {
|
@@ -593,15 +593,15 @@ interface GatewayOpts {
|
|
593
593
|
}
|
594
594
|
type GetResult = Result<Uint8Array, NotFoundError | Error>;
|
595
595
|
interface Gateway {
|
596
|
-
buildUrl(baseUrl: URI, key: string, sthis: SuperThis
|
597
|
-
start(baseUrl: URI, sthis: SuperThis
|
598
|
-
close(baseUrl: URI, sthis: SuperThis
|
599
|
-
destroy(baseUrl: URI, sthis: SuperThis
|
600
|
-
put(url: URI, body: Uint8Array, sthis: SuperThis
|
601
|
-
get(url: URI, sthis: SuperThis
|
602
|
-
delete(url: URI, sthis: SuperThis
|
603
|
-
subscribe?(url: URI, callback: (meta: Uint8Array) => void, sthis: SuperThis
|
604
|
-
getPlain(url: URI, key: string, sthis: SuperThis
|
596
|
+
buildUrl(baseUrl: URI, key: string, sthis: SuperThis): Promise<Result<URI>>;
|
597
|
+
start(baseUrl: URI, sthis: SuperThis): Promise<Result<URI>>;
|
598
|
+
close(baseUrl: URI, sthis: SuperThis): Promise<VoidResult>;
|
599
|
+
destroy(baseUrl: URI, sthis: SuperThis): Promise<VoidResult>;
|
600
|
+
put(url: URI, body: Uint8Array, sthis: SuperThis): Promise<VoidResult>;
|
601
|
+
get(url: URI, sthis: SuperThis): Promise<GetResult>;
|
602
|
+
delete(url: URI, sthis: SuperThis): Promise<VoidResult>;
|
603
|
+
subscribe?(url: URI, callback: (meta: Uint8Array) => void, sthis: SuperThis): Promise<UnsubscribeResult>;
|
604
|
+
getPlain(url: URI, key: string, sthis: SuperThis): Promise<Result<Uint8Array>>;
|
605
605
|
}
|
606
606
|
|
607
607
|
declare class PassThroughGateway implements SerdeGatewayInterceptor {
|
@@ -720,8 +720,8 @@ type index$5_AnyBlock = AnyBlock;
|
|
720
720
|
type index$5_AnyDecodedBlock = AnyDecodedBlock;
|
721
721
|
type index$5_AnyLink = AnyLink;
|
722
722
|
type index$5_AnyLinkFn = AnyLinkFn;
|
723
|
-
type index$
|
724
|
-
declare const index$
|
723
|
+
type index$5_BaseBlockstoreImpl = BaseBlockstoreImpl;
|
724
|
+
declare const index$5_BaseBlockstoreImpl: typeof BaseBlockstoreImpl;
|
725
725
|
type index$5_BaseStore = BaseStore;
|
726
726
|
type index$5_BlobLike = BlobLike;
|
727
727
|
type index$5_BlockFetcher = BlockFetcher;
|
@@ -737,8 +737,9 @@ type index$5_CarGroup = CarGroup;
|
|
737
737
|
type index$5_CarHeader<T> = CarHeader<T>;
|
738
738
|
type index$5_CarLog = CarLog;
|
739
739
|
type index$5_CarMakeable = CarMakeable;
|
740
|
-
type index$
|
741
|
-
declare const index$
|
740
|
+
type index$5_CarTransactionImpl = CarTransactionImpl;
|
741
|
+
declare const index$5_CarTransactionImpl: typeof CarTransactionImpl;
|
742
|
+
type index$5_CarTransactionOpts = CarTransactionOpts;
|
742
743
|
type index$5_CodecOpts = CodecOpts;
|
743
744
|
type index$5_CommitOpts = CommitOpts;
|
744
745
|
type index$5_CompactFetcher = CompactFetcher;
|
@@ -837,7 +838,63 @@ declare const index$5_registerStoreProtocol: typeof registerStoreProtocol;
|
|
837
838
|
declare const index$5_toCIDBlock: typeof toCIDBlock;
|
838
839
|
declare const index$5_toStoreRuntime: typeof toStoreRuntime;
|
839
840
|
declare namespace index$5 {
|
840
|
-
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$
|
841
|
+
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_BytesWithIv as BytesWithIv, 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_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, index$5_FPEnvelopeType as FPEnvelopeType, 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_IvAndBytes as IvAndBytes, type index$5_IvKeyIdData as IvKeyIdData, type index$5_KeyMaterial as KeyMaterial, type index$5_KeyWithFingerExtract as KeyWithFingerExtract, type index$5_KeyWithFingerPrint as KeyWithFingerPrint, type index$5_KeyedCrypto as KeyedCrypto, 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_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 };
|
842
|
+
}
|
843
|
+
|
844
|
+
declare class IndexTree<K extends IndexKeyType, R extends DocFragment> {
|
845
|
+
cid?: AnyLink;
|
846
|
+
root?: ProllyNode<K, R>;
|
847
|
+
}
|
848
|
+
interface ProllyIndexRow<K extends IndexKeyType, T extends DocFragment> {
|
849
|
+
readonly id: string;
|
850
|
+
readonly key: IndexKey<K>;
|
851
|
+
readonly value: T;
|
852
|
+
}
|
853
|
+
interface ProllyNode<K extends IndexKeyType, T extends DocFragment> extends ProllyNode$1 {
|
854
|
+
getAllEntries(): PromiseLike<{
|
855
|
+
[x: string]: unknown;
|
856
|
+
result: ProllyIndexRow<K, T>[];
|
857
|
+
}>;
|
858
|
+
getMany<KI extends IndexKeyType>(removeIds: KI[]): Promise<{
|
859
|
+
result: IndexKey<K>[];
|
860
|
+
}>;
|
861
|
+
range(a: string, b: string): Promise<{
|
862
|
+
result: ProllyIndexRow<K, T>[];
|
863
|
+
}>;
|
864
|
+
get(key: string): Promise<{
|
865
|
+
result: ProllyIndexRow<K, T>[];
|
866
|
+
}>;
|
867
|
+
bulk(bulk: (IndexUpdate<K> | IndexUpdateString)[]): PromiseLike<{
|
868
|
+
readonly root?: ProllyNode<K, T>;
|
869
|
+
readonly blocks: Block$1[];
|
870
|
+
}>;
|
871
|
+
readonly address: Promise<Link>;
|
872
|
+
readonly distance: number;
|
873
|
+
compare: (a: unknown, b: unknown) => number;
|
874
|
+
readonly cache: unknown;
|
875
|
+
readonly block: Promise<Block$1>;
|
876
|
+
}
|
877
|
+
|
878
|
+
declare function index$4<K extends IndexKeyType = string, T extends DocTypes = NonNullable<unknown>, R extends DocFragment = T>(refDb: HasLogger & HasSuperThis & (HasCRDT | RefLedger), name: string, mapFn?: MapFn<T>, meta?: IdxMeta): Index<K, T, R>;
|
879
|
+
declare class Index<K extends IndexKeyType, T extends DocTypes, R extends DocFragment = T> {
|
880
|
+
readonly blockstore: BaseBlockstore;
|
881
|
+
readonly crdt: CRDT;
|
882
|
+
readonly name: string;
|
883
|
+
mapFn?: MapFn<T>;
|
884
|
+
mapFnString: string;
|
885
|
+
byKey: IndexTree<K, R>;
|
886
|
+
byId: IndexTree<K, R>;
|
887
|
+
indexHead?: ClockHead;
|
888
|
+
includeDocsDefault: boolean;
|
889
|
+
initError?: Error;
|
890
|
+
ready(): Promise<void>;
|
891
|
+
readonly logger: Logger;
|
892
|
+
constructor(sthis: SuperThis, crdt: CRDT, name: string, mapFn?: MapFn<T>, meta?: IdxMeta);
|
893
|
+
applyMapFn(name: string, mapFn?: MapFn<T>, meta?: IdxMeta): void;
|
894
|
+
query(opts?: QueryOpts<K>): Promise<IndexRows<K, T, R>>;
|
895
|
+
_resetIndex(): void;
|
896
|
+
_hydrateIndex(): Promise<void>;
|
897
|
+
_updateIndex(): Promise<IndexTransactionMeta>;
|
841
898
|
}
|
842
899
|
|
843
900
|
type Falsy = false | null | undefined;
|
@@ -1078,159 +1135,91 @@ interface CRDTEntry {
|
|
1078
1135
|
readonly parents: string[];
|
1079
1136
|
readonly cid: string;
|
1080
1137
|
}
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1138
|
+
type VoidFn = () => void;
|
1139
|
+
type UnReg = () => void;
|
1140
|
+
interface CRDTClock {
|
1141
|
+
readonly head: ClockHead;
|
1142
|
+
onTock(fn: VoidFn): UnReg;
|
1143
|
+
onTick(fn: (updates: DocUpdate<DocTypes>[]) => void): UnReg;
|
1144
|
+
applyHead(newHead: ClockHead, prevHead: ClockHead, updates?: DocUpdate<DocTypes>[]): Promise<void>;
|
1145
|
+
onZoom(fn: VoidFn): UnReg;
|
1085
1146
|
close(): Promise<void>;
|
1086
|
-
}
|
1087
|
-
interface WriteQueueParams {
|
1088
|
-
readonly chunkSize: number;
|
1089
|
-
}
|
1090
|
-
declare function defaultWriteQueueOpts(opts?: Partial<WriteQueueParams>): WriteQueueParams;
|
1091
|
-
|
1092
|
-
declare class IndexTree<K extends IndexKeyType, R extends DocFragment> {
|
1093
|
-
cid?: AnyLink;
|
1094
|
-
root?: ProllyNode<K, R>;
|
1095
|
-
}
|
1096
|
-
interface ProllyIndexRow<K extends IndexKeyType, T extends DocFragment> {
|
1097
|
-
readonly id: string;
|
1098
|
-
readonly key: IndexKey<K>;
|
1099
|
-
readonly value: T;
|
1100
|
-
}
|
1101
|
-
interface ProllyNode<K extends IndexKeyType, T extends DocFragment> extends ProllyNode$1 {
|
1102
|
-
getAllEntries(): PromiseLike<{
|
1103
|
-
[x: string]: unknown;
|
1104
|
-
result: ProllyIndexRow<K, T>[];
|
1105
|
-
}>;
|
1106
|
-
getMany<KI extends IndexKeyType>(removeIds: KI[]): Promise<{
|
1107
|
-
result: IndexKey<K>[];
|
1108
|
-
}>;
|
1109
|
-
range(a: string, b: string): Promise<{
|
1110
|
-
result: ProllyIndexRow<K, T>[];
|
1111
|
-
}>;
|
1112
|
-
get(key: string): Promise<{
|
1113
|
-
result: ProllyIndexRow<K, T>[];
|
1114
|
-
}>;
|
1115
|
-
bulk(bulk: (IndexUpdate<K> | IndexUpdateString)[]): PromiseLike<{
|
1116
|
-
readonly root?: ProllyNode<K, T>;
|
1117
|
-
readonly blocks: Block$1[];
|
1118
|
-
}>;
|
1119
|
-
readonly address: Promise<Link>;
|
1120
|
-
readonly distance: number;
|
1121
|
-
compare: (a: unknown, b: unknown) => number;
|
1122
|
-
readonly cache: unknown;
|
1123
|
-
readonly block: Promise<Block$1>;
|
1124
|
-
}
|
1125
|
-
|
1126
|
-
declare function index$4<K extends IndexKeyType = string, T extends DocTypes = NonNullable<unknown>, R extends DocFragment = T>(refDb: HasCRDT<T>, name: string, mapFn?: MapFn<T>, meta?: IdxMeta): Index<K, T, R>;
|
1127
|
-
declare class Index<K extends IndexKeyType, T extends DocTypes, R extends DocFragment = T> {
|
1128
|
-
readonly blockstore: BaseBlockstore;
|
1129
|
-
readonly crdt: CRDT<T>;
|
1130
|
-
readonly name: string;
|
1131
|
-
mapFn?: MapFn<T>;
|
1132
|
-
mapFnString: string;
|
1133
|
-
byKey: IndexTree<K, R>;
|
1134
|
-
byId: IndexTree<K, R>;
|
1135
|
-
indexHead?: ClockHead;
|
1136
|
-
includeDocsDefault: boolean;
|
1137
|
-
initError?: Error;
|
1138
1147
|
ready(): Promise<void>;
|
1139
|
-
readonly logger: Logger;
|
1140
|
-
constructor(sthis: SuperThis, crdt: CRDT<T> | CRDT<NonNullable<unknown>>, name: string, mapFn?: MapFn<T>, meta?: IdxMeta);
|
1141
|
-
applyMapFn(name: string, mapFn?: MapFn<T>, meta?: IdxMeta): void;
|
1142
|
-
query(opts?: QueryOpts<K>): Promise<IndexRows<K, T, R>>;
|
1143
|
-
_resetIndex(): void;
|
1144
|
-
_hydrateIndex(): Promise<void>;
|
1145
|
-
_updateIndex(): Promise<IndexTransactionMeta>;
|
1146
1148
|
}
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
push(task: ApplyHeadTask<T>): AsyncGenerator<{
|
1155
|
-
readonly updates: DocUpdate<T>[];
|
1156
|
-
readonly all: boolean;
|
1157
|
-
}, void, unknown>;
|
1158
|
-
size(): number;
|
1149
|
+
interface CarTransaction {
|
1150
|
+
readonly parent: BaseBlockstore;
|
1151
|
+
get<T, C extends number, A extends number, V extends Version>(cid: AnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
1152
|
+
superGet(cid: AnyLink): Promise<AnyBlock | undefined>;
|
1153
|
+
putSync(cid: UnknownLink, bytes: Uint8Array<ArrayBufferLike>): void;
|
1154
|
+
put(cid: UnknownLink, bytes: Uint8Array<ArrayBufferLike>): Promise<void>;
|
1155
|
+
entries(): AsyncIterableIterator<AnyBlock>;
|
1159
1156
|
}
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
readonly
|
1164
|
-
readonly
|
1165
|
-
readonly emptyWatchers: Set<() => void>;
|
1166
|
-
readonly blockstore: BaseBlockstore;
|
1167
|
-
readonly applyHeadQueue: ApplyHeadQueue<T>;
|
1168
|
-
transaction?: CarTransaction;
|
1169
|
-
readonly _ready: ResolveOnce<void>;
|
1157
|
+
interface BaseBlockstore {
|
1158
|
+
readonly transactions: Set<CarTransaction>;
|
1159
|
+
readonly sthis: SuperThis;
|
1160
|
+
readonly loader: Loadable;
|
1161
|
+
readonly ebOpts: BlockstoreRuntime;
|
1170
1162
|
ready(): Promise<void>;
|
1171
1163
|
close(): Promise<void>;
|
1164
|
+
destroy(): Promise<void>;
|
1165
|
+
compact(): Promise<void>;
|
1172
1166
|
readonly logger: Logger;
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
onTock(fn: () => void): void;
|
1180
|
-
onZoom(fn: () => void): void;
|
1181
|
-
int_applyHead(newHead: ClockHead, prevHead: ClockHead, localUpdates: boolean): Promise<void>;
|
1182
|
-
}
|
1183
|
-
|
1184
|
-
interface HasCRDT<T extends DocTypes> {
|
1185
|
-
readonly crdt: CRDT<T> | CRDT<NonNullable<unknown>>;
|
1167
|
+
get<T, C extends number, A extends number, V extends Version>(cid: AnyLink): Promise<Block$1<T, C, A, V> | undefined>;
|
1168
|
+
put(cid: UnknownLink, bytes: Uint8Array<ArrayBufferLike>): Promise<void>;
|
1169
|
+
transaction<M extends TransactionMeta>(fn: (t: CarTransaction) => Promise<M>, _opts?: CarTransactionOpts): Promise<TransactionWrapper<M>>;
|
1170
|
+
openTransaction(opts: CarTransactionOpts): CarTransaction;
|
1171
|
+
commitTransaction<M extends TransactionMeta>(t: CarTransaction, done: M, opts: CarTransactionOpts): Promise<TransactionWrapper<M>>;
|
1172
|
+
entries(): AsyncIterableIterator<AnyBlock>;
|
1186
1173
|
}
|
1187
|
-
|
1188
|
-
readonly opts: DatabaseOpts;
|
1189
|
-
readonly blockstore: BaseBlockstore;
|
1190
|
-
readonly indexBlockstore: BaseBlockstore;
|
1191
|
-
readonly indexers: Map<string, Index<IndexKeyType, NonNullable<unknown>>>;
|
1192
|
-
readonly clock: CRDTClock<T>;
|
1174
|
+
interface CRDT extends ReadyCloseDestroy, HasLogger, HasSuperThis, HasCRDT {
|
1193
1175
|
readonly logger: Logger;
|
1194
1176
|
readonly sthis: SuperThis;
|
1195
|
-
|
1196
|
-
|
1197
|
-
readonly
|
1177
|
+
readonly crdt: CRDT;
|
1178
|
+
readonly clock: CRDTClock;
|
1179
|
+
readonly blockstore: BaseBlockstore;
|
1180
|
+
readonly indexBlockstore: BaseBlockstore;
|
1181
|
+
readonly indexers: Map<string, Index<IndexKeyType, DocTypes>>;
|
1182
|
+
bulk<T extends DocTypes>(updates: DocUpdate<T>[]): Promise<CRDTMeta>;
|
1198
1183
|
ready(): Promise<void>;
|
1199
1184
|
close(): Promise<void>;
|
1200
1185
|
destroy(): Promise<void>;
|
1201
|
-
allDocs(): Promise<{
|
1186
|
+
allDocs<T extends DocTypes>(): Promise<{
|
1202
1187
|
result: DocUpdate<T>[];
|
1203
1188
|
head: ClockHead;
|
1204
1189
|
}>;
|
1205
1190
|
vis(): Promise<string>;
|
1206
1191
|
getBlock(cidString: string): Promise<Block$1>;
|
1207
|
-
get(key: string): Promise<DocValue<
|
1208
|
-
changes(since?: ClockHead, opts?: ChangesOptions): Promise<{
|
1192
|
+
get(key: string): Promise<DocValue<DocTypes> | Falsy>;
|
1193
|
+
changes<T extends DocTypes>(since?: ClockHead, opts?: ChangesOptions): Promise<{
|
1209
1194
|
result: DocUpdate<T>[];
|
1210
1195
|
head: ClockHead;
|
1211
1196
|
}>;
|
1212
1197
|
compact(): Promise<void>;
|
1213
1198
|
}
|
1214
|
-
|
1215
|
-
|
1216
|
-
interface DatabaseOpts {
|
1217
|
-
readonly name?: string;
|
1218
|
-
readonly meta?: DbMeta;
|
1219
|
-
readonly gatewayInterceptor?: SerdeGatewayInterceptor;
|
1220
|
-
readonly writeQueue: WriteQueueParams;
|
1221
|
-
readonly storeUrls: StoreURIRuntime;
|
1222
|
-
readonly storeEnDe: StoreEnDeFile;
|
1223
|
-
readonly keyBag: KeyBagRuntime;
|
1199
|
+
interface HasCRDT {
|
1200
|
+
readonly crdt: CRDT;
|
1224
1201
|
}
|
1225
|
-
interface
|
1202
|
+
interface RefLedger {
|
1203
|
+
readonly ledger: Ledger;
|
1204
|
+
}
|
1205
|
+
interface HasLogger {
|
1226
1206
|
readonly logger: Logger;
|
1207
|
+
}
|
1208
|
+
interface HasSuperThis {
|
1227
1209
|
readonly sthis: SuperThis;
|
1228
|
-
|
1229
|
-
|
1230
|
-
onClosed(fn: () => void): void;
|
1210
|
+
}
|
1211
|
+
interface ReadyCloseDestroy {
|
1231
1212
|
close(): Promise<void>;
|
1232
1213
|
destroy(): Promise<void>;
|
1233
1214
|
ready(): Promise<void>;
|
1215
|
+
}
|
1216
|
+
interface Database extends ReadyCloseDestroy, HasLogger, HasSuperThis {
|
1217
|
+
readonly ledger: Ledger;
|
1218
|
+
readonly logger: Logger;
|
1219
|
+
readonly sthis: SuperThis;
|
1220
|
+
readonly id: string;
|
1221
|
+
readonly name: string;
|
1222
|
+
onClosed(fn: () => void): void;
|
1234
1223
|
get<T extends DocTypes>(id: string): Promise<DocWithId<T>>;
|
1235
1224
|
put<T extends DocTypes>(doc: DocSet<T>): Promise<DocResponse>;
|
1236
1225
|
bulk<T extends DocTypes>(docs: DocSet<T>[]): Promise<BulkResponse>;
|
@@ -1248,57 +1237,99 @@ interface Database<DT extends DocTypes = NonNullable<unknown>> extends HasCRDT<D
|
|
1248
1237
|
query<K extends IndexKeyType, T extends DocTypes, R extends DocFragment = T>(field: string | MapFn<T>, opts?: QueryOpts<K>): Promise<IndexRows<K, T, R>>;
|
1249
1238
|
compact(): Promise<void>;
|
1250
1239
|
}
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1240
|
+
interface WriteQueue<T extends DocUpdate<S>, S extends DocTypes = DocTypes> {
|
1241
|
+
push(task: T): Promise<MetaType>;
|
1242
|
+
bulk(tasks: T[]): Promise<MetaType>;
|
1243
|
+
close(): Promise<void>;
|
1244
|
+
}
|
1245
|
+
interface Ledger extends HasCRDT {
|
1246
|
+
readonly writeQueue: WriteQueue<DocUpdate<DocTypes>>;
|
1247
|
+
readonly logger: Logger;
|
1248
|
+
readonly sthis: SuperThis;
|
1249
|
+
readonly id: string;
|
1250
|
+
readonly name: string;
|
1251
|
+
onClosed(fn: () => void): () => void;
|
1252
|
+
close(): Promise<void>;
|
1253
|
+
destroy(): Promise<void>;
|
1254
|
+
ready(): Promise<void>;
|
1255
|
+
subscribe<T extends DocTypes>(listener: ListenerFn<T>, updates?: boolean): () => void;
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
interface WriteQueueParams {
|
1259
|
+
readonly chunkSize: number;
|
1260
|
+
}
|
1261
|
+
declare function defaultWriteQueueOpts(opts?: Partial<WriteQueueParams>): WriteQueueParams;
|
1262
|
+
|
1263
|
+
declare function keyConfigOpts(sthis: SuperThis, name?: string, opts?: ConfigOpts): string;
|
1264
|
+
interface LedgerOpts {
|
1265
|
+
readonly name?: string;
|
1266
|
+
readonly meta?: DbMeta;
|
1267
|
+
readonly gatewayInterceptor?: SerdeGatewayInterceptor;
|
1268
|
+
readonly writeQueue: WriteQueueParams;
|
1269
|
+
readonly storeUrls: StoreURIRuntime;
|
1270
|
+
readonly storeEnDe: StoreEnDeFile;
|
1271
|
+
readonly keyBag: KeyBagRuntime;
|
1272
|
+
}
|
1273
|
+
declare function isLedger(db: unknown): db is Ledger;
|
1274
|
+
declare function LedgerFactory(name: string | undefined, opts?: ConfigOpts): Ledger;
|
1275
|
+
declare class LedgerShell implements Ledger {
|
1276
|
+
readonly ref: LedgerImpl;
|
1277
|
+
readonly writeQueue: WriteQueue<DocUpdate<DocTypes>>;
|
1278
|
+
readonly name: string;
|
1279
|
+
constructor(ref: LedgerImpl);
|
1256
1280
|
get id(): string;
|
1257
1281
|
get logger(): Logger;
|
1258
1282
|
get sthis(): SuperThis;
|
1259
|
-
get crdt(): CRDT
|
1260
|
-
|
1261
|
-
onClosed(fn: () => void): void;
|
1283
|
+
get crdt(): CRDT;
|
1284
|
+
onClosed(fn: () => void): () => void;
|
1262
1285
|
close(): Promise<void>;
|
1263
1286
|
destroy(): Promise<void>;
|
1264
1287
|
ready(): Promise<void>;
|
1265
|
-
get<T extends DocTypes>(id: string): Promise<DocWithId<T>>;
|
1266
|
-
put<T extends DocTypes>(doc: DocSet<T>): Promise<DocResponse>;
|
1267
|
-
bulk<T extends DocTypes>(docs: DocSet<T>[]): Promise<BulkResponse>;
|
1268
|
-
del(id: string): Promise<DocResponse>;
|
1269
|
-
changes<T extends DocTypes>(since?: ClockHead, opts?: ChangesOptions): Promise<ChangesResponse<T>>;
|
1270
|
-
allDocs<T extends DocTypes>(opts?: AllDocsQueryOpts): Promise<AllDocsResponse<T>>;
|
1271
|
-
allDocuments<T extends DocTypes>(): Promise<{
|
1272
|
-
rows: {
|
1273
|
-
key: string;
|
1274
|
-
value: DocWithId<T>;
|
1275
|
-
}[];
|
1276
|
-
clock: ClockHead;
|
1277
|
-
}>;
|
1278
1288
|
subscribe<T extends DocTypes>(listener: ListenerFn<T>, updates?: boolean): () => void;
|
1279
|
-
query<K extends IndexKeyType, T extends DocTypes, R extends DocFragment = T>(field: string | MapFn<T>, opts?: QueryOpts<K>): Promise<IndexRows<K, T, R>>;
|
1280
|
-
compact(): Promise<void>;
|
1281
1289
|
}
|
1282
|
-
declare class
|
1283
|
-
readonly opts:
|
1290
|
+
declare class LedgerImpl implements Ledger {
|
1291
|
+
readonly opts: LedgerOpts;
|
1284
1292
|
_listening: boolean;
|
1285
|
-
readonly _listeners: Set<ListenerFn<
|
1286
|
-
readonly _noupdate_listeners: Set<ListenerFn<
|
1287
|
-
readonly crdt: CRDT
|
1288
|
-
readonly
|
1289
|
-
readonly shells: Set<
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
+
readonly _listeners: Set<ListenerFn<{}>>;
|
1294
|
+
readonly _noupdate_listeners: Set<ListenerFn<{}>>;
|
1295
|
+
readonly crdt: CRDT;
|
1296
|
+
readonly writeQueue: WriteQueue<DocUpdate<DocTypes>>;
|
1297
|
+
readonly shells: Set<LedgerShell>;
|
1298
|
+
get name(): string;
|
1299
|
+
addShell(shell: LedgerShell): void;
|
1300
|
+
readonly _onClosedFns: Map<string, () => void>;
|
1301
|
+
onClosed(fn: () => void): () => void;
|
1293
1302
|
close(): Promise<void>;
|
1294
|
-
shellClose(db:
|
1303
|
+
shellClose(db: LedgerShell): Promise<void>;
|
1295
1304
|
destroy(): Promise<void>;
|
1296
1305
|
readonly _ready: ResolveOnce<void>;
|
1297
1306
|
ready(): Promise<void>;
|
1298
1307
|
readonly logger: Logger;
|
1299
1308
|
readonly sthis: SuperThis;
|
1300
1309
|
readonly id: string;
|
1301
|
-
constructor(sthis: SuperThis, opts:
|
1310
|
+
constructor(sthis: SuperThis, opts: LedgerOpts);
|
1311
|
+
subscribe<T extends DocTypes>(listener: ListenerFn<T>, updates?: boolean): () => void;
|
1312
|
+
private _notify;
|
1313
|
+
private _no_update_notify;
|
1314
|
+
}
|
1315
|
+
declare function toStoreURIRuntime(sthis: SuperThis, name?: string, sopts?: StoreUrlsOpts): StoreURIRuntime;
|
1316
|
+
declare class Fireproof {
|
1317
|
+
Ledger(name: string, opts?: ConfigOpts): Ledger;
|
1318
|
+
DB(name: string, opts?: ConfigOpts): Database;
|
1319
|
+
}
|
1320
|
+
declare const fireproof: Fireproof;
|
1321
|
+
|
1322
|
+
declare function isDatabase(db: unknown): db is Database;
|
1323
|
+
declare class DatabaseImpl implements Database {
|
1324
|
+
onClosed(fn: () => void): void;
|
1325
|
+
close(): Promise<void>;
|
1326
|
+
destroy(): Promise<void>;
|
1327
|
+
ready(): Promise<void>;
|
1328
|
+
readonly ledger: Ledger;
|
1329
|
+
readonly logger: Logger;
|
1330
|
+
readonly sthis: SuperThis;
|
1331
|
+
readonly id: string;
|
1332
|
+
constructor(ledger: Ledger);
|
1302
1333
|
get name(): string;
|
1303
1334
|
get<T extends DocTypes>(id: string): Promise<DocWithId<T>>;
|
1304
1335
|
put<T extends DocTypes>(doc: DocSet<T>): Promise<DocResponse>;
|
@@ -1316,11 +1347,36 @@ declare class DatabaseImpl<DT extends DocTypes = NonNullable<unknown>> implement
|
|
1316
1347
|
subscribe<T extends DocTypes>(listener: ListenerFn<T>, updates?: boolean): () => void;
|
1317
1348
|
query<K extends IndexKeyType, T extends DocTypes, R extends DocFragment = T>(field: string | MapFn<T>, opts?: QueryOpts<K>): Promise<IndexRows<K, T, R>>;
|
1318
1349
|
compact(): Promise<void>;
|
1319
|
-
_notify(updates: DocUpdate<NonNullable<unknown>>[]): Promise<void>;
|
1320
|
-
_no_update_notify(): Promise<void>;
|
1321
1350
|
}
|
1322
|
-
|
1323
|
-
declare
|
1351
|
+
|
1352
|
+
declare class CRDTImpl implements CRDT {
|
1353
|
+
readonly opts: LedgerOpts;
|
1354
|
+
readonly blockstore: BaseBlockstore;
|
1355
|
+
readonly indexBlockstore: BaseBlockstore;
|
1356
|
+
readonly indexers: Map<string, Index<IndexKeyType, {}, {}>>;
|
1357
|
+
readonly clock: CRDTClock;
|
1358
|
+
readonly logger: Logger;
|
1359
|
+
readonly sthis: SuperThis;
|
1360
|
+
readonly crdt: CRDT;
|
1361
|
+
constructor(sthis: SuperThis, opts: LedgerOpts);
|
1362
|
+
bulk<T extends DocTypes>(updates: DocUpdate<T>[]): Promise<CRDTMeta>;
|
1363
|
+
readonly onceReady: ResolveOnce<void>;
|
1364
|
+
ready(): Promise<void>;
|
1365
|
+
close(): Promise<void>;
|
1366
|
+
destroy(): Promise<void>;
|
1367
|
+
allDocs<T extends DocTypes>(): Promise<{
|
1368
|
+
result: DocUpdate<T>[];
|
1369
|
+
head: ClockHead;
|
1370
|
+
}>;
|
1371
|
+
vis(): Promise<string>;
|
1372
|
+
getBlock(cidString: string): Promise<Block$1>;
|
1373
|
+
get(key: string): Promise<DocValue<DocTypes> | Falsy>;
|
1374
|
+
changes<T extends DocTypes>(since?: ClockHead, opts?: ChangesOptions): Promise<{
|
1375
|
+
result: DocUpdate<T>[];
|
1376
|
+
head: ClockHead;
|
1377
|
+
}>;
|
1378
|
+
compact(): Promise<void>;
|
1379
|
+
}
|
1324
1380
|
|
1325
1381
|
declare function getPath(url: URI, sthis: SuperThis$1): string;
|
1326
1382
|
declare function getFileName(url: URI, sthis: SuperThis$1): string;
|
@@ -1517,5 +1573,5 @@ declare namespace index {
|
|
1517
1573
|
|
1518
1574
|
declare const PACKAGE_VERSION: string;
|
1519
1575
|
|
1520
|
-
export { type AllDocsQueryOpts, type AllDocsResponse, type BulkResponse, CRDT, type CRDTEntry, type CRDTMeta, type ChangesOptions, type ChangesResponse, type ChangesResponseRow, type ClockHead, type ClockLink, type ConfigOpts, type Database,
|
1576
|
+
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 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 };
|
1521
1577
|
declare module '@fireproof/core'
|