import type { LogContext } from '@rocicorp/logger'; import type { Enum } from '../../../shared/src/enum.ts'; import * as valita from '../../../shared/src/valita.ts'; import type { Read, Store, Write } from '../dag/store.ts'; import { Commit, type SnapshotMetaDD31 } from '../db/commit.ts'; import type { DeletedClients } from '../deleted-clients.ts'; import * as FormatVersion from '../format-version-enum.ts'; import { type Hash } from '../hash.ts'; import { type IndexDefinitions } from '../index-defs.ts'; import { type ClientGroupID, type ClientID } from '../sync/ids.ts'; import { type ClientGroup } from './client-groups.ts'; type FormatVersion = Enum; export type ClientMap = ReadonlyMap; declare const clientV5Schema: valita.ObjectType; headHash: valita.Type; /** * The hash of a commit we are in the middle of refreshing into this client's * memdag. */ tempRefreshHash: valita.Type; /** * ID of this client's perdag client group. This needs to be sent in pull * request (to enable syncing all last mutation ids in the client group). */ clientGroupID: valita.Type; }>, undefined>; export type ClientV5 = valita.Infer; declare const clientV6Schema: valita.ObjectType; /** * A set of hashes, which contains: * 1. The hash of the last commit this client refreshed from its client group * (this is the commit it bootstrapped from until it completes its first * refresh). * 2. One or more hashes that were added to retain chunks of a commit while it * was being refreshed into this client's memdag. (This can be one or more * because refresh's cleanup step is a separate transaction and can fail). * Upon refresh completing and successfully running its clean up step, this * set will contain a single hash: the hash of the last commit this client * refreshed. */ refreshHashes: valita.Type; /** * The hash of the last snapshot commit persisted by this client to this * client's client group, or null if has never persisted a snapshot. */ persistHash: valita.Type; /** * ID of this client's perdag client group. This needs to be sent in pull * request (to enable syncing all last mutation ids in the client group). */ clientGroupID: valita.Type; }>, undefined>; export type ClientV6 = valita.Infer; export type Client = ClientV5 | ClientV6; export declare const CLIENTS_HEAD_NAME = "clients"; export declare function assertClientV6(value: unknown): asserts value is ClientV6; export declare function getClients(dagRead: Read): Promise; /** * Used to signal that a client does not exist. Maybe it was garbage collected? */ export declare class ClientStateNotFoundError extends Error { name: string; readonly id: string; constructor(id: ClientID); } /** * Throws a `ClientStateNotFoundError` if the client does not exist. */ export declare function assertHasClientState(id: ClientID, dagRead: Read): Promise; export declare function hasClientState(id: ClientID, dagRead: Read): Promise; export declare function getClient(id: ClientID, dagRead: Read): Promise; export declare function mustGetClient(id: ClientID, dagRead: Read): Promise; type InitClientV6Result = [ client: ClientV6, hash: Hash, clientMap: ClientMap, newClientGroup: boolean ]; export declare function initClientV6(newClientID: ClientID, lc: LogContext, perdag: Store, mutatorNames: string[], indexes: IndexDefinitions, formatVersion: FormatVersion, enableClientGroupForking: boolean): Promise; export declare const FIND_MATCHING_CLIENT_TYPE_NEW = 0; export declare const FIND_MATCHING_CLIENT_TYPE_FORK = 1; export declare const FIND_MATCHING_CLIENT_TYPE_HEAD = 2; export type FindMatchingClientResult = { type: typeof FIND_MATCHING_CLIENT_TYPE_NEW; } | { type: typeof FIND_MATCHING_CLIENT_TYPE_FORK; snapshot: Commit; } | { type: typeof FIND_MATCHING_CLIENT_TYPE_HEAD; clientGroupID: ClientGroupID; headHash: Hash; }; export declare function findMatchingClient(dagRead: Read, mutatorNames: string[], indexes: IndexDefinitions): Promise; export declare function getClientGroupForClient(clientID: ClientID, read: Read): Promise; export declare function getClientGroupIDForClient(clientID: ClientID, read: Read): Promise; /** * Adds a Client to the ClientMap and updates the 'clients' head to point at * the updated clients. */ export declare function setClient(clientID: ClientID, client: Client, dagWrite: Write): Promise; /** * Sets the ClientMap and updates the 'clients' head top point at the new * clients. */ export declare function setClients(clients: ClientMap, dagWrite: Write): Promise; /** * Callback function for when Replicache has deleted one or more clients. */ export type OnClientsDeleted = (deletedClients: DeletedClients) => Promise; export {}; //# sourceMappingURL=clients.d.ts.map