export { createAuthPlugin } from "./types.js"; export { logger } from "./logger.js"; /** * @template {t.YHubConfig} [Conf=t.YHubConfig] */ export class YHub; deletes: Y.IdMap; }) => undefined; } | undefined; worker?: { events?: { docUpdate?: ((doctable: t.DocTable<{ gc: true; nongc: true; contentmap: true; contentids: true; }>) => void) | undefined; taskStart?: ((event: { room: t.Room; timestamp: number; }) => void) | undefined; taskComplete?: ((event: { room: t.Room; duration: number; error: Error | null; }) => void) | undefined; } | undefined; taskConcurrency: number; } | null | undefined; server?: { maxDocSize?: number | undefined; port: number; auth: t.AuthPlugin; } | null | undefined; redis: { taskDebounce?: number | undefined; minMessageLifetime?: number | undefined; cacheTtl?: number | undefined; clientOptions?: Omit, "url"> | undefined; socket?: import("@redis/client/dist/lib/client/socket.js").RedisSocketOptions | undefined; url: string; prefix: string; }; postgres: string; persistence: t.PersistencePlugin[]; }> { /** * @param {Conf} conf * @param {strm.Stream} str * @param {p.Persistence} pers */ constructor(conf: Conf, str: strm.Stream, pers: p.Persistence); conf: Conf; stream: strm.Stream; persistence: p.Persistence; /** * @type {Conf['server'] extends null ? null : server.YHubServer} */ server: Conf["server"] extends null ? null : server.YHubServer; computePool: { maxPoolSize: number; workers: Array<{ pool: /*elided*/ any; worker: import("worker_threads").Worker; isComputing: boolean; isDead: boolean; taskStart: number; taskEnd: number; lastUsed: number; _cbResolve: ((value: any) => void) | null; _cbReject: ((reason: any) => void) | null; _logContext: { [x: string]: any; } | null; run(task: ComputeTask, transferList: Array, logContext: { [x: string]: any; }, resolve: (value: any) => void, reject: (reason: any) => void): void; terminate(): Promise; }>; queue: { task: import("./compute.js").ComputeTask; transferList: ArrayBuffer[]; logContext: { [x: string]: any; }; resolve: (value: any) => void; reject: (reason: any) => void; }[]; run(task: ComputeTask, transferList: Array, logContext: { [x: string]: any; }): Promise; mergeUpdates(gc: boolean, updates: Array>, logContext?: { [x: string]: any; }, prune?: Uint8Array): Promise>; computePruneSet(opts: { contentmapBin: Uint8Array; from?: number | undefined; to?: number | undefined; by?: string | undefined; contentIds?: Uint8Array | undefined; withCustomAttributions?: { k: string; v: string; }[] | null | undefined; }, logContext?: { [x: string]: any; }): Promise | null>; computeStateVector(update: Uint8Array, logContext?: { [x: string]: any; }): Promise>; changeset(opts: { nongcDoc: Uint8Array; contentmapBin: Uint8Array; from: number | null; to: number | null; by: string; withCustomAttributions: Array<{ k: string; v: string; }> | null; includeYdoc: boolean; includeDelta: boolean; includeAttributions: boolean; }, logContext?: { [x: string]: any; }): Promise>; activity(opts: { nongcDoc: Uint8Array; contentmapBin: Uint8Array; from: number; to: number; by: string; contentIds?: Uint8Array | undefined; withCustomAttributions: Array<{ k: string; v: string; }> | null; includeCustomAttributions: boolean; includeDelta: boolean; includeYdoc: boolean; includeAttributions: boolean; limit: number; reverse: boolean; group: boolean; groupMaxGap: number; groupMaxDuration: number; }, logContext?: { [x: string]: any; }): Promise>; patchYdoc(opts: { update: Uint8Array; currentDoc: Uint8Array; userid: string; customAttributions: Array<{ k: string; v: string; }>; }, logContext?: { [x: string]: any; }): Promise<{ update: Uint8Array; contentmap: Uint8Array; } | null>; rollback(opts: { nongcDoc: Uint8Array; contentmapBin: Uint8Array; from?: number | undefined; to?: number | undefined; by?: string | undefined; contentIds?: Uint8Array | undefined; withCustomAttributions?: { k: string; v: string; }[] | null | undefined; userid: string; customAttributions: Array<{ k: string; v: string; }>; }, logContext?: { [x: string]: any; }): Promise<{ update: Uint8Array; contentmap: Uint8Array; }>; destroy(): Promise; }; _workerCtx: { shouldRun: boolean; }; startWorker(): Promise; _ctx: { shouldRun: boolean; } | undefined; stopWorker(): void; /** * @template {{ gc?: boolean, nongc?: boolean, contentmap?: boolean, references?: boolean, contentids?: boolean, awareness?: boolean }} Include * @param {t.Room} room * @param {Include} includeContent * @param {object} opts * @param {boolean} [opts.gcOnMerge] whether to gc when merging updates. (default: true) * @param {{ messages: Array, lastClock: string }} [opts.cachedMessages] pre-fetched stream messages, to avoid pulling the redis stream again * @return {Promise>} */ getDoc(room: t.Room, includeContent: Include, { gcOnMerge, cachedMessages: prefetched }?: { gcOnMerge?: boolean | undefined; cachedMessages?: { messages: Array; lastClock: string; } | undefined; }): Promise>; /** * Permanently prunes churned history: content that was both inserted and deleted within the * filtered range is garbage-collected and removed from the activity history. This is * irreversible. The prune is distributed as a directive on the redis stream and baked into * persistence the next time the document is compacted. * * @param {t.Room} room * @param {object} filters * @param {number} [filters.from] * @param {number} [filters.to] * @param {string} [filters.by] * @param {Uint8Array} [filters.contentIds] * @param {Array<{k: string, v: string}>|null} [filters.withCustomAttributions] * @returns {Promise} */ pruneDoc(room: t.Room, filters: { from?: number | undefined; to?: number | undefined; by?: string | undefined; contentIds?: Uint8Array | undefined; withCustomAttributions?: { k: string; v: string; }[] | null | undefined; }): Promise; /** * Attribute and persist a document directly to the database, without distributing it via redis. * * Changes won't be synced to users connected via websocket until they reconnect. * * @param {t.Room} room * @param {Uint8Array} ydoc * @param {{ by?: string }} attributions */ unsafePersistDoc(room: t.Room, ydoc: Uint8Array, { by }: { by?: string; }): Promise; /** * @template R * @param {t.Room} room * @param {import('./agents.js').AgentTaskOptions} opts * @param {(ydoc: Y.Doc, awareness: import('@y/protocols/awareness').Awareness) => Promise | R} handler * @returns {Promise} */ agentTask(room: t.Room, opts: import("./agents.js").AgentTaskOptions, handler: (ydoc: Y.Doc, awareness: import("@y/protocols/awareness").Awareness) => Promise | R): Promise; } export function createYHub(conf: Conf): Promise>; import * as t from './types.js'; import * as Y from '@y/y'; import * as strm from './stream.js'; import * as p from './persistence.js'; import * as server from './server.js'; //# sourceMappingURL=index.d.ts.map