import { EventEmitter } from "node:events"; export type ConnectionState = { queue: Promise; rootSessions: Set; lease?: { operations: Promise; release: () => void; savePointName: string; socket: import("ws").WebSocket; }; }; export default class SharedTransactionBroker extends EventEmitter { connections: Record; secret: string; accepting: boolean; /** @type {Map} */ connectionStates: Map; /** @type {Set} */ sessions: Set; /** @type {Map>} */ sessionCleanup: Map>; /** @type {Array} */ cleanupErrors: Array; /** @type {Promise | undefined} */ closePromise: Promise | undefined; /** @type {Map Promise>) => Promise>>} */ connectionCoordinators: Map Promise>) => Promise>>; /** @type {Map} */ connectionCoordinatorOwners: Map; physicalConnections: Map; httpServer: import("node:http").Server; websocketServer: import("ws").Server; /** * Creates a broker around parent-owned physical connections. * @param {{connections: Record}} args - Parent-owned physical connections. */ constructor({ connections }: { connections: Record; }); /** * Installs serialization ownership for a newly enrolled physical connection. * @param {object} connection - Parent-owned physical connection. * @returns {void} */ installConnectionCoordinator(connection: object): void; /** * Enrolls one exact physical database identity in this capability's rollback set. * @param {{connection: object, databaseIdentifier: string, reuseKey: string}} args - Physical connection identity. * @returns {void} */ enrollConnection({ connection, databaseIdentifier, reuseKey }: { connection: object; databaseIdentifier: string; reuseKey: string; }): void; /** * Starts a broker on an ephemeral loopback port. * @param {{connections: Record}} args - Parent-owned physical connections. * @returns {Promise} - Listening broker. */ static start(args: { connections: Record; }): Promise; /** * Gets the loopback websocket address. * @returns {string} - Loopback websocket address. */ address(): string; /** * Gets the per-attempt unguessable capability. * @returns {string} - Per-attempt unguessable capability. */ capability(): string; /** * Validates and handles one request. * @param {import("ws").WebSocket} socket - Calling session. * @param {string} serialized - Request JSON. * @returns {Promise} - Resolves after responding. */ handleRequest(socket: import("ws").WebSocket, serialized: string): Promise; /** * Adds the broker owner to public driver methods that re-enter coordinated query work. * @param {{args: Array>, connection: object, method: string}} args - Physical invocation. * @returns {Array | {operationOwner: symbol}>} - Owned method arguments. */ ownedMethodArgs({ args, connection, method }: { args: Array>; connection: object; method: string; }): Array | { operationOwner: symbol; }>; /** * Gets mutable serialization state for one physical connection. * @param {object} connection - Physical connection. * @returns {ConnectionState} - Connection state. */ connectionState(connection: object): ConnectionState; /** * Runs a validated request with root transaction lease semantics. * @template T * @param {{connection: object, method: string, savePointName: string | undefined, socket: import("ws").WebSocket}} args - Request identity. * @param {() => Promise} callback - Physical operation. * @returns {Promise} - Operation result. */ runConnectionRequest({ connection, method, savePointName, socket }: { connection: object; method: string; savePointName: string | undefined; socket: import("ws").WebSocket; }, callback: () => Promise): Promise; /** * Acquires the FIFO physical connection lease and holds the queue until end. * @template T * @param {{callback: () => Promise, savePointName: string, state: ConnectionState, socket: import("ws").WebSocket}} args - Lease request. * @returns {Promise} - Root savepoint start result. */ startRootLease({ callback, savePointName, state, socket }: { callback: () => Promise; savePointName: string; state: ConnectionState; socket: import("ws").WebSocket; }): Promise; /** * Finishes the calling session's root lease. * @template T * @param {{callback: () => Promise, savePointName: string | undefined, state: ConnectionState, socket: import("ws").WebSocket}} args - Lease end request. * @returns {Promise} - Savepoint end result. */ finishRootLease({ callback, savePointName, state, socket }: { callback: () => Promise; savePointName: string | undefined; state: ConnectionState; socket: import("ws").WebSocket; }): Promise; /** * Serializes operations belonging to the active lease holder. * @template T * @param {{operations: Promise}} lease - Active lease. * @param {() => Promise} callback - Operation. * @returns {Promise} - Result. */ serializeLease(lease: { operations: Promise; }, callback: () => Promise): Promise; /** * Rolls back leases abandoned by a disconnected session. * @param {import("ws").WebSocket} socket - Disconnected session. * @returns {Promise} - Resolves after all owned leases release. */ releaseDisconnectedLeases(socket: import("ws").WebSocket): Promise; /** * Tracks detached socket cleanup and records its failure for close(). * @param {import("ws").WebSocket} socket - Closed session. * @returns {Promise} - Settled tracked cleanup. */ scheduleSessionCleanup(socket: import("ws").WebSocket): Promise; /** * Rolls back and removes a root savepoint so it cannot remain beneath the next lease. * @param {object} connection - Parent physical connection. * @param {string} savePointName - Root savepoint name. * @returns {Promise} - Resolves after rollback and release. */ rollbackRootSavePoint(connection: object, savePointName: string): Promise; /** * Serializes ordinary non-holder work through the connection FIFO. * @template T * @param {ConnectionState} state - Connection state. * @param {() => Promise} callback - Work. * @returns {Promise} - Work result. */ serialize(state: ConnectionState, callback: () => Promise): Promise; /** * Stops admission, revokes capability, rejects clients, and drains active work. * @returns {Promise} - Resolves after transport shutdown. */ close(): Promise; /** Revokes admission without interrupting already accepted work. */ revoke(): void; /** Drains all work accepted before capability revocation. */ drain(): Promise; /** * Performs deterministic transport shutdown and reports cleanup failures last. * @returns {Promise} - Resolves after shutdown or rejects with cleanup errors. */ closeTransport(): Promise; } //# sourceMappingURL=shared-transaction-broker.d.ts.map