import type FavaLibMediator from '../FavaLibMediator.mjs'; import type Command from '../Command/BaseCommand.mjs'; import { type SyncCommand } from '../interfaces/CommandTypes.mjs'; import type { DeviceId } from '../interfaces/BrandedTypes.mjs'; /** * Manages the execution, undo, and redo of commands. */ declare class CommandManager { private readonly mediator; private executedCommands; private undoneCommands; private remoteCommandQueue; private processedCommandIds; private unsupportedCommandIds; /** * Constructs a new CommandManager instance. * @param mediator - The mediator for accessing other components. */ constructor(mediator: FavaLibMediator); private get syncManager(); private get log(); /** * Executes a command and manages its state. * @param command - The command to execute. */ execute(command: Command): Promise; /** * Undoes the last executed command. */ undo(): Promise; /** * Redoes the last undone command. */ redo(): Promise; /** * Processes all commands in the remote command queue. * @returns An array of the IDs of the succesfully executed commands. */ processRemoteCommands(): Promise; /** * Receives a remote command and enqueues it for processing. * * A command whose major version is newer than this build understands is * dropped with a warning and is never reported as executed, so the server * keeps it queued and redelivers it once this device is upgraded. SyncManager * authenticates and drains one command at a time, so each command sees the * peer list left by the previous one. * @param remoteCommand - The remote command to process. * @param fromDeviceId - The peer whose signature the caller verified over * this command. Passed down so a command can act on WHO sent it, not just on * what it says: enrolment records its introducer, and a rename is refused * unless the sender is the device being renamed. * @throws {InvalidCommandError} If the command type is unknown or data is invalid. */ receiveRemoteCommand(remoteCommand: SyncCommand, fromDeviceId?: DeviceId): void; /** * Checks whether a remote command's protocol version is one this build can * apply, logging a warning the first time a command is dropped. * @param remoteCommand - The remote command to check. * @returns True when the command should be processed. */ private commandVersionIsSupported; private sendCommandToOtherInstances; } export default CommandManager;