import { GarbageCollector } from "./GarbageCollector.js"; import { ClockOffset } from "./ClockOffset.js"; import type { CoID } from "./coValue.js"; import type { RawCoValue } from "./coValue.js"; import { type AvailableCoValueCore, CoValueCore } from "./coValueCore/coValueCore.js"; import { type CoValueHeader, type CoValueUniqueness } from "./coValueCore/verifiedState.js"; import { AccountMeta, ControlledAccountOrAgent, InvalidAccountAgentIDError, RawAccount, RawAccountID, RawAccountMigration, RawProfile } from "./coValues/account.js"; import { type InviteSecret, type RawGroup } from "./coValues/group.js"; import { AgentSecret, CryptoProvider } from "./crypto/crypto.js"; import { AgentID, RawCoID, SessionID } from "./ids.js"; import { StorageAPI } from "./storage/index.js"; import { Peer, PeerID, SyncManager, type LocalStoreDurabilityListener, type SyncWhen } from "./sync.js"; /** A `LocalNode` represents a local view of a set of loaded `CoValue`s, from the perspective of a particular account (or primitive cryptographic agent). A `LocalNode` can have peers that it syncs to, for example some form of local persistence, or a sync server, such as `cloud.jazz.tools` (Jazz Cloud). @example You typically get hold of a `LocalNode` using `jazz-react`'s `useJazz()`: ```typescript const { localNode } = useJazz(); ``` */ export declare class LocalNode { #private; readonly syncWhen?: SyncWhen | undefined; /** @internal */ crypto: CryptoProvider; /** @internal */ private readonly coValues; /** @category 3. Low-level */ readonly currentSessionID: SessionID; readonly agentSecret: AgentSecret; /** @category 3. Low-level */ syncManager: SyncManager; readonly clockOffset: ClockOffset; garbageCollector: GarbageCollector | undefined; crashed: Error | undefined; storage?: StorageAPI; /** @category 3. Low-level */ constructor(agentSecret: AgentSecret, currentSessionID: SessionID, crypto: CryptoProvider, syncWhen?: SyncWhen | undefined, enableFullStorageReconciliation?: boolean, options?: { experimental_clockSyncFromServerPings?: boolean; onLocalStoreDurabilityChange?: LocalStoreDurabilityListener; }); stampNow(): number; getClockOffsetDiagnostics(): { currentOffset: number; sampleCount: number; }; enableGarbageCollector(): void; setStorage(storage: StorageAPI): void; removeStorage(): void; /** * Enable background erasure of deleted coValues (space reclamation). * * Deleted coValues are immediately blocked from syncing via tombstones; this feature * only reclaims local storage space by deleting historical content while preserving * the tombstone (header + delete session). * * This is opt-in and affects only the currently configured storage (if any) * * @category 3. Low-level */ enableDeletedCoValuesErasure(): void; hasCoValue(id: RawCoID): boolean; isCoValueInMemory(id: RawCoID): boolean; getCoValue(id: RawCoID): CoValueCore; allCoValues(): MapIterator; /** * Simple delete of a CoValue from memory. * Used for testing and forced cleanup scenarios. * @internal */ internalDeleteCoValue(id: RawCoID): void; /** * Unmount a CoValue from memory, keeping a shell with cached knownState. * This enables accurate LOAD requests during peer reconciliation. * * @returns true if the coValue was successfully unmounted, false otherwise */ internalUnmountCoValue(id: RawCoID): boolean; getCurrentAccountOrAgentID(): RawAccountID | AgentID; _cachedCurrentAgent: ControlledAccountOrAgent | undefined; getCurrentAgent(): ControlledAccountOrAgent; expectCurrentAccountID(reason: string): RawAccountID; expectCurrentAccount(reason: string): RawAccount; static internalCreateAccount(opts: { crypto: CryptoProvider; initialAgentSecret?: AgentSecret; peers?: Peer[]; syncWhen?: SyncWhen; storage?: StorageAPI; enableFullStorageReconciliation?: boolean; experimental_clockSyncFromServerPings?: boolean; onLocalStoreDurabilityChange?: LocalStoreDurabilityListener; }): RawAccount; /** @category 2. Node Creation */ static withNewlyCreatedAccount({ creationProps, peers, syncWhen, migration, crypto, initialAgentSecret, storage, enableFullStorageReconciliation, experimental_clockSyncFromServerPings, onLocalStoreDurabilityChange, }: { creationProps: { name: string; }; peers?: Peer[]; syncWhen?: SyncWhen; migration?: RawAccountMigration; crypto: CryptoProvider; initialAgentSecret?: AgentSecret; storage?: StorageAPI; enableFullStorageReconciliation?: boolean; experimental_clockSyncFromServerPings?: boolean; onLocalStoreDurabilityChange?: LocalStoreDurabilityListener; }): Promise<{ node: LocalNode; accountID: RawAccountID; accountSecret: AgentSecret; sessionID: SessionID; }>; /** @category 2. Node Creation */ static withLoadedAccount({ accountID, accountSecret, sessionID, peers, syncWhen, crypto, migration, storage, enableFullStorageReconciliation, experimental_clockSyncFromServerPings, onLocalStoreDurabilityChange, }: { accountID: RawAccountID; accountSecret: AgentSecret; sessionID: SessionID | undefined; peers: Peer[]; syncWhen?: SyncWhen; crypto: CryptoProvider; migration?: RawAccountMigration; storage?: StorageAPI; enableFullStorageReconciliation?: boolean; experimental_clockSyncFromServerPings?: boolean; onLocalStoreDurabilityChange?: LocalStoreDurabilityListener; }): Promise; /** @internal */ createCoValue(header: CoValueHeader): AvailableCoValueCore; /** @internal */ loadCoValueCore(id: RawCoID, skipLoadingFromPeer?: PeerID, skipRetry?: boolean): Promise; /** * Loads a CoValue's content, syncing from peers as necessary and resolving the returned * promise once a first version has been loaded. See `coValue.subscribe()` and `node.useTelepathicData()` * for listening to subsequent updates to the CoValue. * * @category 3. Low-level */ load(id: CoID, skipRetry?: boolean): Promise; /** * Loads a branch from a group coValue, creating a new one if it doesn't exist. * * Returns "unavailable" in case of errors or missing source. */ checkoutBranch(id: CoID | RawCoID, branchName: string, branchOwnerID?: RawCoID): Promise; getLoaded(id: CoID): T | undefined; /** @category 3. Low-level */ subscribe(id: CoID, callback: (update: T | "unavailable") => void, skipRetry?: boolean): () => void; acceptInvite(groupOrOwnedValueID: CoID, inviteSecret: InviteSecret): Promise; /** @internal */ expectCoValueLoaded(id: RawCoID, expectation?: string): AvailableCoValueCore; /** @internal */ expectProfileLoaded(id: RawAccountID, expectation?: string): RawProfile; /** @internal */ resolveAccountAgent(id: RawAccountID | AgentID, expectation?: string): { value: `sealer_z${string}/signer_z${string}`; error: undefined; } | { value: undefined; error: unknown; }; createGroup(uniqueness?: CoValueUniqueness, options?: { name?: string; }): RawGroup; loadCoValueAsDifferentAgent(id: RawCoID, secret: AgentSecret, accountId?: RawAccountID | AgentID): Promise; /** @internal */ loadVerifiedStateFrom(otherNode: LocalNode, id: RawCoID): Promise; /** * Closes all the peer connections, drains all the queues and closes the storage. * * @returns Promise of the current pending store operation, if any. */ gracefulShutdown(): Promise; } export type LoadCoValueCoreError = { type: "ErrorLoadingCoValueCore"; error: unknown; expectation?: string; id: RawAccountID; }; export type AccountUnavailableFromAllPeersError = { type: "AccountUnavailableFromAllPeers"; expectation?: string; id: RawAccountID; }; export type UnexpectedlyNotAccountError = { type: "UnexpectedlyNotAccount"; expectation?: string; id: RawAccountID; }; export type ResolveAccountAgentError = InvalidAccountAgentIDError | LoadCoValueCoreError | AccountUnavailableFromAllPeersError | UnexpectedlyNotAccountError; //# sourceMappingURL=localNode.d.ts.map