import { Log, ISortFunction, LogOptions, Identity, CanAppend, Change, TrimToByteLengthOption, TrimToLengthOption, Change2, EntryType } from "@dao-xyz/peerbit-log"; import { Encoding, EncryptionTemplateMaybeEncrypted } from "@dao-xyz/peerbit-log"; import { Entry } from "@dao-xyz/peerbit-log"; import { BlockStore } from "@dao-xyz/libp2p-direct-block"; import Cache from "@dao-xyz/lazy-level"; import { PublicKeyEncryptionResolver, SignatureWithKey } from "@dao-xyz/peerbit-crypto"; import { EntryWithRefs } from "./entry-with-refs.js"; export declare const logger: import("pino").Logger; export declare class CachedValue { } export type AddOperationOptions = { skipCanAppendCheck?: boolean; identity?: Identity; signers?: ((data: Uint8Array) => Promise)[]; nexts?: Entry[]; reciever?: EncryptionTemplateMaybeEncrypted; type?: EntryType; }; export declare class CID { hash: string; constructor(opts?: { hash: string; }); } export declare class CachePath { path: string; constructor(path: string); } export declare class UnsfinishedReplication { hashes: string[]; constructor(opts?: { hashes: string[]; }); } export declare class HeadsCache { heads: string[]; last?: string; counter: bigint; constructor(heads: string[], counter: bigint, last?: string); } export interface IStoreOptions { /** * f set to true, will throw an error if the database can't be found locally. (Default: false) */ localOnly?: boolean; /** * The directory where data will be stored */ directory?: string; onWrite?: (store: Store, change: Entry) => void; onUpdate?: (change: Change) => void; onClose?: (store: Store) => void; onDrop?: (store: Store) => void; onLoad?: (store: Store) => void; onLoadProgress?: (store: Store, entry: Entry) => void; onOpen?: (store: Store) => Promise; encryption?: PublicKeyEncryptionResolver; replicationConcurrency?: number; sortFn?: ISortFunction; trim?: TrimToByteLengthOption | TrimToLengthOption; } export interface IInitializationOptions extends IStoreOptions, IInitializationOptionsDefault { resolveCache: (store: Store) => Promise | Cache; replicator?: (gid: string) => Promise; replicatorsCacheId?: () => string; } interface IInitializationOptionsDefault { replicationConcurrency?: number; cacheId: string; } export declare const DefaultOptions: IInitializationOptionsDefault; export interface Initiable { init?(blockstore: BlockStore, identity: Identity, options: IInitializationOptions): Promise; } export declare class Store implements Initiable { _storeIndex: number; _canAppend?: CanAppend; _onUpdate?: (change: Change) => Promise | void; _onUpdateOption?: (change: Change) => Promise | void; private _options; identity: Identity; private _headsPathCounter; headsPath: string; private _lastHeadsPath?; private _lastHeadsCount; removedHeadsPath: string; private _lastRemovedHeadsPath?; private _lastRemovedHeadsCount; snapshotPath: string; initialized: boolean; encoding: Encoding; private _store; private _cache; private _oplog; private _cacheWriteQueue; private _key; private _saveFile; private _loadFile; private _loaded; constructor(properties?: { storeIndex: number; }); setup(properties: { encoding: Encoding; canAppend: CanAppend; onUpdate: (change: Change) => void; }): void; init(store: BlockStore, identity: Identity, options: IInitializationOptions): Promise; private _updateCachedHeads; idle(): Promise; getCachedHeads(lastHeadsPath?: string | undefined, lastRemovedHeadsPath?: string | undefined): Promise; get id(): string; get oplog(): Log; get key(): string; get store(): BlockStore; get options(): IInitializationOptions; get logOptions(): LogOptions; get cache(): Cache; setIdentity(identity: Identity): void; set canAppend(canAppend: CanAppend | undefined); get canAppend(): CanAppend | undefined; set onUpdate(onUpdate: (change: Change) => void); get closed(): boolean; close(): Promise; /** * Drops a database and removes local data */ drop(): Promise; private loadHeads; load(opts?: { fetchEntryTimeout?: number; } & ({ amount?: number; } | { heads?: true; })): Promise; loadLastHeadsPath(): Promise; getCachedHeadsCount(headPath?: string): Promise; private waitForHeads; append(data: T, options?: AddOperationOptions): Promise<{ entry: Entry; removed: Entry[]; }>; private removeEntry; remove(entry: Entry | Entry[], options?: { recursively?: boolean; }): Promise>; /** * * @param entries * @returns change */ sync(entries: (EntryWithRefs | Entry | string)[], options?: { canAppend?: CanAppend; onChange?: (change: Change2) => void | Promise; timeout?: number; }): Promise; saveSnapshot(): Promise; loadFromSnapshot(): Promise; _updateIndex(change: Change): Promise; _onLoadProgress(entry: Entry): void; clone(): Store; } export {};