@searsuite/sear-domain-workbook
Workbook state
WorkbookDocumentState holds stable Sheet identities, order, names, visibility, and each Sheet's document state.
WorkbookSessionState holds local values needed to remount the active Sheet. Internal references use stable
sheetId values so renaming a Sheet changes its label without changing its identity.
The Workbook assembly mounts one active Sheet editor. Before switching, it captures that Sheet's document and local session, tears down the editor, and mounts the next Sheet. Switching back restores the captured session; viewport state does not become durable Workbook content.
addWorkbookSheet(), moveWorkbookSheet(), and related operations describe structural changes. The Workbook
assembly stages add, remove, move, rename, hide, and unhide commands as Workbook transactions, with history
separate from edits inside a mounted Sheet.
Use when: managing several Sheets or resolving references across them. Keep structural reads and identity in the Workbook domain; use the active Sheet editor and its feature commands for cell content or appearance. Formula references and collaboration channels use stable Sheet identities rather than mutable display names.
- functioncreateWorkbookDocumentState
-
createWorkbookDocumentState<SheetState>(input: CreateWorkbookDocumentStateInput<SheetState>): WorkbookDocumentState<SheetState>Creates a validated workbook state using array order as the sheet tab order.
- classWorkbookError
-
class WorkbookError extends SearErrorError thrown when workbook state or workbook references violate their domain contract.
constructor WorkbookError(code: WorkbookErrorCode, message: string, details?: SearErrorDetails): WorkbookErrorproperty readonly code: WorkbookErrorCodeStable machine-readable error code.
Inherited members 9
Inherited from SearError.
- interfaceAddWorkbookSheetInput
-
interface AddWorkbookSheetInput<SheetState>Input accepted by
addWorkbookSheet.property readonly index?: numberOptional insertion index; defaults to appending after the current last sheet.
property readonly sheet: WorkbookSheetDescriptorDescriptor for the sheet being inserted.
property readonly sheetState: SheetStateInitial state payload for the inserted sheet.
- interfaceCreateWorkbookDocumentStateInput
-
interface CreateWorkbookDocumentStateInput<SheetState>Input accepted by
createWorkbookDocumentState.property readonly id: stringStable workbook id used by persistence and collaboration rooms.
property readonly metadata?: Readonly<Record<string, unknown>>Extension-owned serializable metadata copied onto the workbook state.
property readonly sheets: readonly WorkbookSheetDescriptor[]Ordered sheet descriptors.
property readonly sheetStates: WorkbookSheetStateMap<SheetState>Per-sheet state payloads keyed by sheet id.
- interfaceMoveWorkbookSheetInput
-
Input accepted by
moveWorkbookSheet.property readonly sheetId: stringSheet id to move.
property readonly toIndex: numberDestination index in
WorkbookDocumentState.sheets. - interfaceRemoveWorkbookSheetInput
-
Input accepted by
removeWorkbookSheet.property readonly sheetId: stringSheet id to remove.
- interfaceRenameWorkbookSheetInput
-
Input accepted by
renameWorkbookSheet.property readonly name: stringNew user-facing sheet name.
property readonly sheetId: stringSheet id to rename.
- interfaceUpdateWorkbookSheetStateInput
-
interface UpdateWorkbookSheetStateInput<SheetState>Input accepted by
updateWorkbookSheetState.property readonly sheetId: stringSheet id whose state payload should be replaced.
property readonly sheetState: SheetStateReplacement sheet state payload.
- interfaceWorkbookDocumentState
-
interface WorkbookDocumentState<SheetState>Workbook state containing sheet metadata plus per-sheet state payloads.
SheetStateis generic so this package stays independent from sheet, render, formula, and assembly packages.property readonly id: stringStable workbook id used by persistence and collaboration rooms.
property readonly metadata?: Readonly<Record<string, unknown>>Extension-owned serializable metadata that does not affect core workbook semantics.
property readonly sheets: readonly WorkbookSheetDescriptor[]Ordered sheet descriptors; array order is the persisted tab order.
property readonly sheetStates: WorkbookSheetStateMap<SheetState>Per-sheet state payloads keyed by stable sheet id.
- interfaceWorkbookSheetDescriptor
-
Workbook-level sheet metadata.
The containing
WorkbookDocumentState.sheetsarray is the only source of sheet order; descriptors intentionally do not carry a separate order field.property readonly color?: stringOptional UI tab color owned by the workbook host.
property readonly id: stringStable sheet id used by workbook state, collaboration envelopes, and formula dependencies.
property readonly metadata?: Readonly<Record<string, unknown>>Extension-owned serializable metadata that does not affect core workbook semantics.
property readonly name: stringUnique user-facing sheet name used when displaying formula references.
- typeWorkbookErrorCode
-
type WorkbookErrorCode = typeof WorkbookErrorCode[keyof typeof WorkbookErrorCode]WorkbookErrorCode: { cannotHideAllSheets: "SEAR_WORKBOOK_CANNOT_HIDE_ALL_SHEETS"; cannotRemoveLastSheet: "SEAR_WORKBOOK_CANNOT_REMOVE_LAST_SHEET"; duplicateSheetId: "SEAR_WORKBOOK_DUPLICATE_SHEET_ID"; duplicateSheetName: "SEAR_WORKBOOK_DUPLICATE_SHEET_NAME"; invalidCellKey: "SEAR_WORKBOOK_INVALID_CELL_KEY"; invalidReference: "SEAR_WORKBOOK_INVALID_REFERENCE"; invalidSheetIndex: "SEAR_WORKBOOK_INVALID_SHEET_INDEX"; invalidSheetName: "SEAR_WORKBOOK_INVALID_SHEET_NAME"; … }Machine-readable workbook error code type.
- typeWorkbookId
-
type WorkbookId = stringStable workbook identifier used by host-level workbook registries.
- typeWorkbookSheetId
-
type WorkbookSheetId = stringStable sheet identifier used inside workbook metadata and cross-sheet references.
- typeWorkbookSheetStateMap
-
type WorkbookSheetStateMap = Readonly<Record<WorkbookSheetId, SheetState>>Map from workbook sheet id to the host-selected sheet state payload.
- functionaddWorkbookSheet
-
addWorkbookSheet<SheetState>(state: WorkbookDocumentState<SheetState>, input: AddWorkbookSheetInput<SheetState>): WorkbookDocumentState<SheetState>Adds a sheet descriptor and its initial state payload without mutating the source workbook.
- functiongetWorkbookSheetDescriptor
-
getWorkbookSheetDescriptor<SheetState>(state: WorkbookDocumentState<SheetState>, sheetId: string): WorkbookSheetDescriptor | nullReturns the descriptor for a sheet id, or null when the sheet is absent.
- functiongetWorkbookSheetState
-
getWorkbookSheetState<SheetState>(state: WorkbookDocumentState<SheetState>, sheetId: string): SheetState | nullReturns one sheet state payload, or null when the sheet is absent.
- functionmoveWorkbookSheet
-
moveWorkbookSheet<SheetState>(state: WorkbookDocumentState<SheetState>, input: MoveWorkbookSheetInput): WorkbookDocumentState<SheetState>Moves a sheet descriptor to a new tab index without mutating the source workbook.
- functionquoteWorkbookSheetName
-
quoteWorkbookSheetName(name: string): stringReturns a formula-safe display name for a workbook sheet.
- functionremoveWorkbookSheet
-
removeWorkbookSheet<SheetState>(state: WorkbookDocumentState<SheetState>, input: RemoveWorkbookSheetInput): WorkbookDocumentState<SheetState>Removes a sheet descriptor and its state payload without mutating the source workbook.
- functionrenameWorkbookSheet
-
renameWorkbookSheet<SheetState>(state: WorkbookDocumentState<SheetState>, input: RenameWorkbookSheetInput): WorkbookDocumentState<SheetState>Renames a workbook sheet without mutating the source workbook.
- functionupdateWorkbookSheetState
-
updateWorkbookSheetState<SheetState>(state: WorkbookDocumentState<SheetState>, input: UpdateWorkbookSheetStateInput<SheetState>): WorkbookDocumentState<SheetState>Replaces one sheet state payload without mutating the source workbook.
- functionvalidateWorkbookDocumentState
-
validateWorkbookDocumentState<SheetState>(state: WorkbookDocumentState<SheetState>): voidValidates the workbook structural invariants shared by commands and persistence.
- variableWorkbookErrorCodeValue
-
WorkbookErrorCodeValue: { cannotHideAllSheets: "SEAR_WORKBOOK_CANNOT_HIDE_ALL_SHEETS"; cannotRemoveLastSheet: "SEAR_WORKBOOK_CANNOT_REMOVE_LAST_SHEET"; duplicateSheetId: "SEAR_WORKBOOK_DUPLICATE_SHEET_ID"; duplicateSheetName: "SEAR_WORKBOOK_DUPLICATE_SHEET_NAME"; invalidCellKey: "SEAR_WORKBOOK_INVALID_CELL_KEY"; invalidReference: "SEAR_WORKBOOK_INVALID_REFERENCE"; invalidSheetIndex: "SEAR_WORKBOOK_INVALID_SHEET_INDEX"; invalidSheetName: "SEAR_WORKBOOK_INVALID_SHEET_NAME"; … }Stable machine-readable error codes owned by the workbook domain package.
References
- interfaceParsedWorkbookFormulaReference
-
Parsed workbook formula reference bound to a stable sheet id.
property readonly range: WorkbookRangeReferenceNormalized workbook range. Single-cell references use the same start and end coordinate.
property readonly sheetId: stringStable sheet id resolved from the user-facing formula sheet name.
- interfaceWorkbookCellReference
-
Qualified cell reference used by workbook-level formulas and dependency graphs.
property readonly col: numberZero-based column index.
property readonly row: numberZero-based row index.
property readonly sheetId: stringStable sheet id containing the referenced cell.
- interfaceWorkbookColumnRangeReference
-
Qualified whole-column range reference used by workbook-level formulas.
property readonly endCol: numberZero-based end column index.
property readonly sheetId: stringStable sheet id containing the referenced columns.
property readonly startCol: numberZero-based start column index.
- interfaceWorkbookRangeReference
-
Qualified rectangular range reference used by workbook-level formulas.
property readonly end: readonly [number, number]Zero-based bottom-right coordinate.
property readonly sheetId: stringStable sheet id containing the referenced range.
property readonly start: readonly [number, number]Zero-based top-left coordinate.
- interfaceWorkbookRowRangeReference
-
Qualified whole-row range reference used by workbook-level formulas.
property readonly endRow: numberZero-based end row index.
property readonly sheetId: stringStable sheet id containing the referenced rows.
property readonly startRow: numberZero-based start row index.
- typeWorkbookCellKey
-
type WorkbookCellKey = stringSerialized key for a workbook-qualified formula cell.
- typeWorkbookCoordinateAxis
-
type WorkbookCoordinateAxis = typeof WorkbookCoordinateAxis[keyof typeof WorkbookCoordinateAxis]WorkbookCoordinateAxis: { col: "col"; row: "row" }Stable workbook coordinate axis-name type.
- typeWorkbookFormulaReference
-
type WorkbookFormulaReference = WorkbookCellReference | WorkbookRangeReference | WorkbookColumnRangeReference | WorkbookRowRangeReferenceAny workbook-qualified formula reference supported by the workbook protocol.
- typeWorkbookReferenceDiagnosticField
-
type WorkbookReferenceDiagnosticField = WorkbookReferenceField | templateLiteral | templateLiteralDiagnostic field path emitted by workbook reference validation errors.
- typeWorkbookReferenceField
-
type WorkbookReferenceField = typeof WorkbookReferenceField[keyof typeof WorkbookReferenceField]WorkbookReferenceField: { col: "col"; end: "end"; endCol: "endCol"; endRow: "endRow"; row: "row"; sheetId: "sheetId"; start: "start"; startCol: "startCol"; … }Stable workbook reference property-name type.
- variableWorkbookCoordinateIndex
-
WorkbookCoordinateIndex: { col: 1; row: 0 }Tuple positions for workbook range coordinates.
- functioncreateWorkbookCellKey
-
createWorkbookCellKey(reference: WorkbookCellReference): stringCreates a stable string key for a workbook-qualified cell reference.
- functionformatParsedWorkbookFormulaReference
-
formatParsedWorkbookFormulaReference(reference: ParsedWorkbookFormulaReference, sheets: readonly WorkbookSheetDescriptor[]): stringFormats a parsed workbook formula reference with the current user-facing sheet name.
- functionformatWorkbookCellReference
-
formatWorkbookCellReference(reference: WorkbookCellReference, sheetName: string): stringFormats a workbook-qualified cell reference using a caller-provided sheet name.
- functionformatWorkbookRangeReference
-
formatWorkbookRangeReference(reference: WorkbookRangeReference, sheetName: string): stringFormats a workbook-qualified rectangular range reference using a caller-provided sheet name.
- functionisValidWorkbookReference
-
isValidWorkbookReference(reference: unknown): referenceReports whether an unknown value is any valid workbook-qualified formula reference.
- functionisWorkbookCellReference
-
isWorkbookCellReference(reference: unknown): referenceReports whether an unknown value is a valid workbook-qualified cell reference.
- functionisWorkbookColumnRangeReference
-
isWorkbookColumnRangeReference(reference: unknown): referenceReports whether an unknown value is a valid workbook-qualified whole-column range reference.
- functionisWorkbookRangeReference
-
isWorkbookRangeReference(reference: unknown): referenceReports whether an unknown value is a valid workbook-qualified rectangular range reference.
- functionisWorkbookRowRangeReference
-
isWorkbookRowRangeReference(reference: unknown): referenceReports whether an unknown value is a valid workbook-qualified whole-row range reference.
- functionnormalizeWorkbookColumnRangeReference
-
normalizeWorkbookColumnRangeReference(reference: WorkbookColumnRangeReference): WorkbookColumnRangeReferenceNormalizes a whole-column reference so the start column is before the end column.
- functionnormalizeWorkbookRangeReference
-
normalizeWorkbookRangeReference(reference: WorkbookRangeReference): WorkbookRangeReferenceNormalizes a range reference so start is top-left and end is bottom-right.
- functionnormalizeWorkbookRowRangeReference
-
normalizeWorkbookRowRangeReference(reference: WorkbookRowRangeReference): WorkbookRowRangeReferenceNormalizes a whole-row reference so the start row is before the end row.
- functionparseWorkbookCellKey
-
parseWorkbookCellKey(key: string): WorkbookCellReferenceParses a string produced by
createWorkbookCellKeyback into a cell reference. - functionparseWorkbookFormulaReference
-
parseWorkbookFormulaReference(reference: string, sheets: readonly WorkbookSheetDescriptor[]): ParsedWorkbookFormulaReferenceParses a displayed workbook reference such as Sheet2!A1 or Sheet2!A1:B5 into a stable sheet-id range.
- variableWorkbookCoordinateAxisValue
-
WorkbookCoordinateAxisValue: { col: "col"; row: "row" }Stable coordinate axis names used by tuple-backed workbook range references.
- variableWorkbookReferenceFieldValue
-
WorkbookReferenceFieldValue: { col: "col"; end: "end"; endCol: "endCol"; endRow: "endRow"; row: "row"; sheetId: "sheetId"; start: "start"; startCol: "startCol"; … }Stable property names used by workbook-qualified formula references.
No matching API entries.