@searsuite/sear-assembly-commands
Command dispatch
A host or input handler requests a change by running a feature-owned command. The command definition identifies the operation; the registered handler builds the state owner's operations. The Sheet core stages those operations and commits them as one change. Rendering and observers then see the committed result rather than a partial step.
SheetCommandDispatcher and DocCommandBus are dispatch contracts, not alternate state stores. Use the typed
command exported by the feature that owns the behavior. For selection, SelectRangeCommand changes the selected
range and GetSelection reads it afterward.
Use when: changing editor state from application code or wiring a host event. Read-only questions belong to a query; ongoing notifications belong to observations. Neither should mutate committed state.
- classDocCommandBus
-
The supported execution entry point for document user and program actions.
constructor DocCommandBus(platform?: Platform): DocCommandBusCreates a command bus that reports boundary diagnostics through the host platform.
property readonly symbol: typeof symbolstaticDI token for resolving the command bus bound to one document editor instance.
method bind(context: DocCommandContext): voidBinds the command bus to the runtime services for one editor instance.
method destroy(): voidClears editor binding, listeners, and command registrations during teardown.
method enforceRegistrationBoundary(assertWrite: (): void): voidCloses setup-time command registration after the editor is assembled.
method getRegisteredCommandIds(): readonly string[]Returns a stable snapshot of all document commands exposed by this editor instance.
method getRegisteredCommands(): readonly DocCommandDefinition<unknown, DocCommandResult>[]Returns the typed definitions registered on this editor instance.
method has(definition: string | DocCommandDefinition<unknown, DocCommandResult>): booleanReturns whether this editor instance currently exposes a document command id.
method isExecuting(): booleanWhether this editor's command bus is currently dispatching a command.
method register<Definition>(definition: Definition, factory: DocCommandFactory<Definition>): (): voidRegisters one feature-owned command factory. The returned function must be called by lifecycle cleanup when a feature registers dynamically.
method run<Definition>(definition: Definition, input: DocCommandInput<Definition>): DocCommandDefinitionResult<Definition>Executes a registered command through its feature-owned typed definition.
method runWithoutMutationAuthority<Value>(callback: (): Value): ValueInvokes external observers without inheriting this editor's command write authority.
method subscribe(listener: DocCommandListener): (): voidSubscribes to document command lifecycle events and returns an unsubscribe function.
- classDocCommandDispatcher
-
Executes document command objects against one command context.
constructor DocCommandDispatcher(): DocCommandDispatchermethod execute<Result>(context: DocCommandContext, command: DocEditorCommand<Result>): ResultRuns a command, validates its result and applies its operation/effects.
- classSheetCommandBus
-
The only supported execution entry point for sheet user and program actions. Hosts bind it to one editor instance after the Core has been created.
constructor SheetCommandBus(platform?: Platform): SheetCommandBusCreates a command bus that reports boundary diagnostics through the host platform.
property readonly symbol: typeof symbolstaticDI token for resolving the command bus bound to one editor instance.
method bind(context: SheetCommandContext): voidBinds the command bus to the runtime services for one editor instance.
method destroy(): voidClears editor binding, listeners and command registrations during teardown.
method enforceRegistrationBoundary(assertWrite: (): void): voidCloses setup-time command registration after the editor is assembled.
method getRegisteredCommandIds(): readonly string[]Returns a stable snapshot of all commands exposed by this editor instance.
method getRegisteredCommands(): readonly SheetCommandDefinition<unknown, SheetCommandResult>[]Returns the typed definitions registered on this editor instance.
method has(definition: string | SheetCommandDefinition<unknown, SheetCommandResult>): booleanReturns whether this editor instance currently exposes a command id.
method isExecuting(): booleanWhether this editor's command bus is currently dispatching a command.
method register<Definition>(definition: Definition, factory: SheetCommandFactory<Definition>): (): voidRegisters one feature-owned command factory. The returned function must be called by the feature's lifecycle cleanup when it registers dynamically.
method run<Definition>(definition: Definition, input: SheetCommandInput<Definition>): SheetCommandDefinitionResult<Definition>Executes a registered command through its feature-owned typed definition.
method runWithoutMutationAuthority<Value>(callback: (): Value): ValueInvokes external observers without inheriting this editor's command write authority.
method subscribe(listener: SheetCommandListener): (): voidSubscribes to command lifecycle events and returns an unsubscribe function.
- classSheetCommandDispatcher
-
Executes command objects against one command context.
constructor SheetCommandDispatcher(): SheetCommandDispatchermethod execute<Result>(context: SheetCommandContext, command: SheetCommand<Result>): ResultRuns a command, validates its result and applies its pipeline/effects.
- interfaceDocCommandContext
-
Runtime services exposed to document commands while they execute.
method applyEffect(effect: DocCommandEffect): voidApplies a local UI/runtime effect after the operation has been committed.
method executePipeline(pipeline: Pipeline): voidExecutes command-owned work through the document core's shared pipeline boundary. Implementations commit document state before rendering.
- interfaceDocCommandDefinition
-
interface DocCommandDefinition<Input, Result>A stable document command identifier carrying its input and result contract.
property readonly [docCommandInputType]: InputPhantom field that preserves the command input type for callers.
property readonly [docCommandResultType]: ResultPhantom field that preserves the command result type for callers.
property readonly id: stringGlobally stable command id owned by the document feature package that defines it.
- interfaceDocCommandEvent
-
Lifecycle event emitted by the document command bus for diagnostics and host UI.
property readonly error?: unknownOriginal thrown value when the command failed.
property readonly id: stringStable command id being executed.
property readonly phase: CommandExecutionPhaseExecution phase represented by this event.
property readonly result?: DocCommandResultResult returned by a completed command.
- interfaceDocCommandResult
-
Standard command result that document Core can execute and observe.
property readonly effects?: readonly DocCommandEffect[]Optional local effects requested after operation execution.
property readonly pipeline: PipelineCommand-owned pipeline containing mutation, render and local-action steps.
- interfaceDocEditorCommand
-
interface DocEditorCommand<Result>Executable unit behind a typed document command definition.
property readonly id: stringStable, domain-owned command identifier for observability and automation.
method execute(context: DocCommandContext): ResultRuns command logic and returns a pipeline-backed result.
- interfaceSheetCommand
-
interface SheetCommand<Result>Executable unit behind a typed command definition.
property readonly id: stringStable, domain-owned command identifier for observability and automation.
method execute(context: SheetCommandContext): ResultRuns command logic and returns a pipeline-backed result.
- interfaceSheetCommandContext
-
Runtime services exposed to commands while they execute.
method applyEffect(effect: SheetCommandEffect): voidApplies a local UI/runtime effect after pipeline execution.
method executePipeline(pipeline: Pipeline): voidApplies the command-produced pipeline through the core transaction boundary.
- interfaceSheetCommandDefinition
-
interface SheetCommandDefinition<Input, Result>A stable command identifier carrying its input and result contract.
property readonly [sheetCommandInputType]: InputPhantom field that preserves the command input type for callers.
property readonly [sheetCommandResultType]: ResultPhantom field that preserves the command result type for callers.
property readonly id: stringGlobally stable command id owned by the feature package that defines it.
- interfaceSheetCommandEvent
-
Lifecycle event emitted by the command bus for diagnostics and host UI.
property readonly error?: unknownOriginal thrown value when the command failed.
property readonly id: stringStable command id being executed.
property readonly phase: CommandExecutionPhaseExecution phase represented by this event.
property readonly result?: SheetCommandResultSuccessfully executed command result, present only for the completed phase.
- interfaceSheetCommandResult
-
Standard command result that Core can execute and observe.
property readonly completion?: Promise<unknown>Optional asynchronous completion of a command-owned external effect.
property readonly effects?: readonly SheetCommandEffect[]Optional local effects requested after pipeline execution.
property readonly historyGroup?: { id: string; phase: "end" | "begin" }Optional identifier for combining two committed commands into one undo entry.
property readonly pipeline: PipelinePipeline containing transaction, render, interaction and local-action steps.
- typeCommandExecutionPhase
-
type CommandExecutionPhase = typeof CommandExecutionPhase[keyof typeof CommandExecutionPhase]CommandExecutionPhase: { Completed: "completed"; Failed: "failed"; Started: "started" }Public string union for command lifecycle event phases.
- typeDocCommandDefinitionResult
-
type DocCommandDefinitionResult = conditionalExtracts the result contract from a typed document command definition.
- typeDocCommandEffect
-
type DocCommandEffect = { type: "focus-document" } | { type: "reset-caret-blink" }Local runtime effects that document commands can request outside document state.
- typeDocCommandFactory
-
type DocCommandFactory = (input: DocCommandInput<Definition>): DocEditorCommand<DocCommandDefinitionResult<Definition>>Factory installed by a document feature plugin to create a command from typed input.
- typeDocCommandInput
-
type DocCommandInput = conditionalExtracts the input contract from a typed document command definition.
- typeDocCommandListener
-
type DocCommandListener = (event: DocCommandEvent): voidObserver invoked when document command execution starts, completes, or fails.
- typeSheetCommandDefinitionResult
-
type SheetCommandDefinitionResult = conditionalExtracts the result contract from a typed command definition.
- typeSheetCommandFactory
-
type SheetCommandFactory = (input: SheetCommandInput<Definition>): SheetCommand<SheetCommandDefinitionResult<Definition>>Factory installed by a feature plugin to create a command from typed input.
- typeSheetCommandInput
-
type SheetCommandInput = conditionalExtracts the input contract from a typed command definition.
- typeSheetCommandListener
-
type SheetCommandListener = (event: SheetCommandEvent): voidObserver invoked when command execution starts, completes or fails.
- functiondefineDocCommand
-
defineDocCommand<Input, Result>(id: string): DocCommandDefinition<Input, Result>Creates an immutable, feature-owned document command contract.
- functiondefineSheetCommand
-
defineSheetCommand<Input, Result>(id: string): SheetCommandDefinition<Input, Result>Creates an immutable, feature-owned command contract.
Transactions
A command can stage several owner-specific operations in one pipeline. If preparation or staging fails, the transaction does not publish a partial document. Successful commits advance history and collaboration through the owning feature's adapters; local interaction and render updates follow the commit boundary.
Command definitions, transaction factories, and handlers work together: definitions provide typed inputs and results, handlers decide which operations to make, and state owners define how those operations change their own data. This is why an optional plugin can add a command without expanding a central command switch.
- classEffectCommand
-
class EffectCommand extends SheetCommand<SheetCommandResult>Command that emits local effects without mutating OT state.
constructor EffectCommand(effects: readonly SheetCommandEffect[]): EffectCommandCreates an effect-only command.
property readonly id: "effect.apply"Stable id for effect-only command execution.
method execute(_context: SheetCommandContext): SheetCommandResultReturns an empty pipeline plus the local effects to apply.
- classLocalActionCommand
-
class LocalActionCommand extends SheetCommand<SheetCommandResult>Runs a local, command-owned action that does not produce an OT transaction.
constructor LocalActionCommand(id: string, run: (): void): LocalActionCommandCreates a command that schedules one local action in a pipeline.
property readonly id: stringStable, domain-owned command identifier for observability and automation.
method execute(_context: SheetCommandContext): SheetCommandResultReturns a pipeline containing only the local action step.
- classPipelineExecutionCommand
-
class PipelineExecutionCommand extends SheetCommand<SheetCommandResult>Executes a complete, named pipeline through the command bus.
constructor PipelineExecutionCommand(id: string, pipeline: Pipeline): PipelineExecutionCommandCreates a command around an existing named pipeline.
property readonly id: stringStable, domain-owned command identifier for observability and automation.
method execute(_context: SheetCommandContext): SheetCommandResultReturns the provided pipeline unchanged.
- classTransactionPipelineCommand
-
class TransactionPipelineCommand extends SheetCommand<SheetCommandResult>Executes an already-created transaction through the pipeline command boundary.
constructor TransactionPipelineCommand(id: string, transaction: Transaction): TransactionPipelineCommandCreates a command around an existing transaction.
property readonly id: stringStable, domain-owned command identifier for observability and automation.
method execute(_context: SheetCommandContext): SheetCommandResultConverts the provided transaction into a pipeline result.
- functioncreateSheetTransaction
-
createSheetTransaction<OperationType>(target: PluginKey, operations: readonly OperationType[], meta?: Readonly<Record<string, unknown>>): TransactionCreates a transaction for command factories that need to produce pipeline transactions internally.
Selection
- interfaceExtendSelectionCommandInput
-
Input required to extend a sheet selection by keyboard navigation.
property readonly cursor: SelectionPointCurrent moving edge before this navigation step.
property readonly direction: SelectionMoveDirectionDirection requested by the user.
property readonly findMerge: (point: SelectionPoint): { end: SelectionPoint; start: SelectionPoint } | undefinedLookup for merged ranges that should be selected as a whole.
property readonly jumpToEdge?: booleanWhether navigation should jump to the sheet edge.
property readonly lastCol: numberLast valid column index.
property readonly lastRow: numberLast valid row index.
property readonly origin: SelectionPointFixed selection anchor where extension began.
- interfaceMoveSelectionCommandInput
- interfaceMoveSelectionCommandResult
-
property readonly anchor: [number, number]property readonly focus: [number, number] - interfaceSelectRangeCommandInput
- interfaceSelectRangeCommandResult
-
property readonly anchor: [number, number]property readonly focus: [number, number] - typeSelectionMoveDirection
-
type SelectionMoveDirection = typeof SelectionMoveDirection[keyof typeof SelectionMoveDirection]SelectionMoveDirection: { Down: "down"; Left: "left"; Right: "right"; Up: "up" } - functionextendSelection
-
extendSelection(input: ExtendSelectionCommandInput): { anchor: [number, number]; cursor: [number, number]; focus: [number, number] }Extends a selection by one keyboard navigation step.
ReturnsNormalized selection range and updated moving cursor.
inputCurrent selection extension state.
- functionmoveSelection
-
moveSelection(input: MoveSelectionCommandInput): MoveSelectionCommandResultResolves navigation as a sheet interaction, including merged-range boundaries.
- functionselectRange
-
selectRange(input: SelectRangeCommandInput): SelectRangeCommandResultNormalizes pointer or test-provided ranges so intersected merged cells are selected whole.
Sheet structure
Insert, delete, and move commands create row or column operations that the editor can commit together.
- classSheetAxisMoveBoundsError
-
class SheetAxisMoveBoundsError extends SearErrorA requested block or insertion boundary falls outside its axis.
constructor SheetAxisMoveBoundsError(input: SheetMoveAxisInput, size: number): SheetAxisMoveBoundsErrorproperty readonly code: "SHEET_AXIS_MOVE_BOUNDS"Stable machine-readable identifier for this error category.
Inherited members 9
Inherited from SearError.
- interfaceSheetDeleteColumnsInput
-
Public input for deleting columns starting at
index.property readonly count?: numberproperty readonly index: number - interfaceSheetDeleteRowsInput
-
Public input for deleting rows starting at
index.property readonly count?: numberproperty readonly index: number - interfaceSheetInsertColumnsInput
-
Public input for inserting columns before
index.property readonly count?: numberproperty readonly index: number - interfaceSheetInsertRowsInput
-
Public input for inserting rows before
index.property readonly count?: numberproperty readonly index: number - interfaceSheetMoveAxisInput
-
Moves a contiguous block before a boundary in the original axis (0 through size).
- interfaceSheetStructureCommandDataSource
-
interface SheetStructureCommandDataSource<Cell>Sheet matrix access used by structure commands without depending on a concrete data package.
property readonly target: PluginKeyPlugin key that owns the persisted sheet data matrix.
method getColumnCount(): numberCurrent column count.
method getRowCount(): numberCurrent row count.
method readColumn(index: number): Cell | null[]Reads a dense column payload for invertible column deletion.
method readRow(index: number): Cell | null[]Reads a dense row payload for invertible row deletion.
- variableDeleteColumnCommand
-
DeleteColumnCommand: SheetCommandDefinition<SheetDeleteColumnsInput, SheetCommandResult>Deletes one or more columns starting at the requested column index.
- variableDeleteRowCommand
-
DeleteRowCommand: SheetCommandDefinition<SheetDeleteRowsInput, SheetCommandResult>Deletes one or more rows starting at the requested row index.
- variableInsertColumnCommand
-
InsertColumnCommand: SheetCommandDefinition<SheetInsertColumnsInput, SheetCommandResult>Inserts one or more columns before the requested column index.
- variableInsertRowCommand
-
InsertRowCommand: SheetCommandDefinition<SheetInsertRowsInput, SheetCommandResult>Inserts one or more rows before the requested row index.
- variableMoveColumnsCommand
-
MoveColumnsCommand: SheetCommandDefinition<SheetMoveAxisInput, SheetCommandResult>Reorders complete columns without overwriting their neighbors.
- variableMoveRowsCommand
-
MoveRowsCommand: SheetCommandDefinition<SheetMoveAxisInput, SheetCommandResult>Reorders complete rows without overwriting their neighbors.
- functioncreateDeleteColumnOperations
-
createDeleteColumnOperations(input: SheetDeleteColumnsInput, dataSource: Pick<SheetStructureCommandDataSource, "getColumnCount" | "readColumn">): DeleteColOTOperation<unknown>[]Creates ColDelete operations from public command input, ordered from right to left.
- functioncreateDeleteRowOperations
-
createDeleteRowOperations(input: SheetDeleteRowsInput, dataSource: Pick<SheetStructureCommandDataSource, "getRowCount" | "readRow">): DeleteRowOTOperation<unknown>[]Creates RowDelete operations from public command input, ordered from bottom to top.
- functioncreateInsertColumnOperations
-
createInsertColumnOperations(input: SheetInsertColumnsInput, dataSource: Pick<SheetStructureCommandDataSource, "getRowCount">): InsertColOTOperation<unknown>[]Creates ColInsert operations from public command input.
- functioncreateInsertRowOperations
-
createInsertRowOperations(input: SheetInsertRowsInput, dataSource: Pick<SheetStructureCommandDataSource, "getColumnCount">): InsertRowOTOperation<unknown>[]Creates RowInsert operations from public command input.
- functioncreateMoveColumnsOperations
-
createMoveColumnsOperations(input: SheetMoveAxisInput, size: number): MoveColOTOperation<unknown>[]Creates column swaps implementing insertion at an original column boundary.
- functioncreateMoveRowsOperations
-
createMoveRowsOperations(input: SheetMoveAxisInput, size: number): MoveRowOTOperation<unknown>[]Creates row swaps implementing insertion at an original row boundary.
- functionregisterSheetStructureCommands
-
registerSheetStructureCommands(commands: SheetCommandBus, dataSource: SheetStructureCommandDataSource, moves?: SheetStructureMoveRegistry): voidRegisters the default sheet row/column structure commands.
Cell ranges
- interfaceSheetClearRangeContentsCommandDataSource
-
interface SheetClearRangeContentsCommandDataSource<Cell>Sheet cell data required to create clear-contents operations.
property readonly target: PluginKeyPlugin key that owns the persisted sheet data matrix.
method getColumnCount(): numberCurrent column count.
method getRowCount(): numberCurrent row count.
method readCell(row: number, column: number): Cell | nullReads the current cell value at
row,column. - interfaceSheetClearRangeContentsInput
-
interface SheetClearRangeContentsInput extends SheetRangeInputPublic input for clearing persisted contents in a range.
- interfaceSheetRangeBounds
-
Normalized rectangular sheet range bounds expressed as inclusive cell coordinates.
property readonly end: SheetCellPointInclusive bottom-right cell coordinate.
property readonly start: SheetCellPointInclusive top-left cell coordinate.
- interfaceSheetRangeInput
-
Common range input accepted by explicit range commands.
property readonly anchor: SheetCellPointOne corner of the target range.
property readonly focus: SheetCellPointOpposite corner of the target range.
- typeSheetCellPoint
-
type SheetCellPoint = readonly [number, number]A zero-based sheet cell coordinate expressed as
[row, column]. - typeSheetRangeCommandDataSource
-
type SheetRangeCommandDataSource = SheetClearRangeContentsCommandDataSource<Cell>Data source for the built-in clear-contents command.
- variableClearRangeContentsCommand
-
ClearRangeContentsCommand: SheetCommandDefinition<SheetClearRangeContentsInput, SheetCommandResult>Clears persisted cell contents in an explicit rectangular range.
- functioncreateClearRangeContentsOperations
-
createClearRangeContentsOperations<Cell>(input: SheetClearRangeContentsInput, dataSource: SheetClearRangeContentsCommandDataSource<Cell>): UpdateCellOTOperation<Cell>[]Creates UpdateCell operations that clear non-empty cells inside a range.
- functionregisterSheetRangeCommands
-
registerSheetRangeCommands(commands: SheetCommandBus, dataSource: SheetRangeCommandDataSource): voidRegisters the built-in range commands on one sheet command bus.
Queries
Queries read the current editor state through the command surface without committing a change.
- classSheetQueryRegistry
-
Editor-local registry for typed, side-effect-free sheet queries.
constructor SheetQueryRegistry(): SheetQueryRegistryproperty readonly symbol: typeof symbolstaticmethod destroy(): voidmethod enforceWriteBoundary(assertWrite: (): void): voidRequires editor command dispatch for registration changes after assembly.
method getRegisteredQueryIds(): readonly string[]method has(definition: string | SheetQueryDefinition<unknown, unknown>): booleanmethod register<Definition>(definition: Definition, handler: SheetQueryHandler<SheetQueryInput<Definition>, SheetQueryResult<Definition>>): (): voidmethod run<Definition>(definition: Definition, input: SheetQueryInput<Definition>): SheetQueryResult<Definition> - interfaceSheetQueryDefinition
-
interface SheetQueryDefinition<Input, Result>A stable query identifier carrying its input and result contract.
property readonly __input?: Inputproperty readonly __result?: Resultproperty readonly id: stringproperty readonly resultMode?: "reader"Reader queries return a live, read-only projection instead of a data snapshot.
- typeSheetQueryHandler
-
type SheetQueryHandler = (input: Input): Result - typeSheetQueryInput
-
type SheetQueryInput = conditional - typeSheetQueryResult
-
type SheetQueryResult = conditional - functiondefineSheetQuery
-
defineSheetQuery<Input, Result>(id: string): SheetQueryDefinition<Input, Result>Creates an immutable, feature-owned query contract.
- functiondefineSheetReaderQuery
-
defineSheetReaderQuery<Input, Result>(id: string): SheetQueryDefinition<Input, Result>Defines a live reader whose methods own detached values at their read boundary.
- classSheetQueryBus
-
Editor-local registry for typed, side-effect-free sheet queries.
constructor SheetQueryRegistry(): SheetQueryRegistryproperty readonly symbol: typeof symbolstaticmethod destroy(): voidmethod enforceWriteBoundary(assertWrite: (): void): voidRequires editor command dispatch for registration changes after assembly.
method getRegisteredQueryIds(): readonly string[]method has(definition: string | SheetQueryDefinition<unknown, unknown>): booleanmethod register<Definition>(definition: Definition, handler: SheetQueryHandler<SheetQueryInput<Definition>, SheetQueryResult<Definition>>): (): voidmethod run<Definition>(definition: Definition, input: SheetQueryInput<Definition>): SheetQueryResult<Definition>
No matching API entries.