← All packages

API reference

@searsuite/sear-plugin-export

Versioned export envelopes, document-state codec registries, and durable persistence boundaries.

16 exportsderived from source

classDocumentStateCodecRegistrysource ↗
class DocumentStateCodecRegistry<TState>

Registry that composes document-state modules without central field enumeration.

constructorconstructor
DocumentStateCodecRegistry<TState>(): DocumentStateCodecRegistry<TState>
methoddeserialize
deserialize(modules: readonly SearDocumentStateModuleFile[], path: string): Partial<TState>

Deserializes registered modules into one partial document state.

modules: readonly SearDocumentStateModuleFile[]
path: string
methodregister
register(codec: DocumentStateCodec<TState>): this

Registers a module codec. Duplicate keys are rejected.

codec: DocumentStateCodec<TState>
methodregisterContribution
registerContribution(contribution: DocumentStateModuleContribution<unknown, object>): this

Registers the codec from a plugin-owned document-state contribution.

contribution: DocumentStateModuleContribution<unknown, object>
methodserialize
serialize(state: TState): SearDocumentStateModuleFile[]

Serializes every registered module whose codec returns a payload.

state: TState
classExportErrorsource ↗
class ExportError extends SearError

Error thrown when a persisted workbook payload cannot be encoded or decoded.

constructorconstructor
ExportError(code: ExportErrorCode, message: string, details?: SearErrorDetails): ExportError

Creates an ExportError instance.

code: ExportErrorCode
message: string
details: SearErrorDetails
propertycode
readonly code: ExportErrorCode

Stable machine-readable error code.

Inherited members 9

Inherited from SearError.

interfaceDocumentStateCodecsource ↗
interface DocumentStateCodec<TState>

Codec contributed by the owner of one document-state module.

propertykey
readonly key: string

Stable module key written to persisted files.

methoddeserialize
deserialize(payload: JsonValue, path: string): Partial<TState>

Restores the module-owned part of a document state.

payload: JsonValue
path: string
methodserialize
serialize(state: TState): unknown

Serializes the module-owned part of a document state.

state: TState
interfaceDocumentStateModuleContributionsource ↗
interface DocumentStateModuleContribution<TOwnerState, TDocumentState>

Export contribution owned by one document-state owner.

propertycodec
readonly codec: DocumentStateCodec<TDocumentState>

JSON codec used for this module in stable export files.

propertykey
readonly key: string

Stable module key written to persisted files.

methodcapture
capture(ownerState: TOwnerState): Partial<TDocumentState> | undefined

Captures this owner state into the aggregate document-state snapshot.

ownerState: TOwnerState
interfaceSearDocumentStateModuleFilesource ↗
interface SearDocumentStateModuleFile

One registered document-state module in a stable export file.

propertykey
readonly key: string

Stable module key owned by the state owner, such as sheet.data.

propertypayload
readonly payload: JsonValue

Module-owned JSON payload.

interfaceSearFormulaBindingFilesource ↗
interface SearFormulaBindingFile

One formula cell's workbook-qualified reference targets.

propertycol
readonly col: number
propertyformula
readonly formula: string
propertyreferences
readonly references: readonly { sheetId: string; sheetName: string }[]
propertyrow
readonly row: number
propertysheetId
readonly sheetId: string
interfaceSearSheetDocumentFilesource ↗
interface SearSheetDocumentFile

Stable persisted representation of one Sheet document state.

propertykind
readonly kind: "sheet"

Sheet payload kind.

propertymodules
readonly modules: readonly SearDocumentStateModuleFile[]

Registered document-state modules.

interfaceSearWorkbookFilesource ↗
interface SearWorkbookFile<TSheetDescriptor>

Stable persisted representation of a Workbook document state.

propertyformat
readonly format: "searsuite.workbook"

Stable file-format identifier.

propertyworkbook
readonly workbook: { formulaBindings?: readonly SearFormulaBindingFile[]; id: string; metadata?: Readonly<Record<string, JsonValue>>; sheets: readonly TSheetDescriptor[]; sheetStates: Readonly<Record<string, SearSheetDocumentFile>> }

Persisted workbook document state.

typeExportErrorCodesource ↗
type ExportErrorCode = typeof ExportErrorCode[keyof typeof ExportErrorCode]

Machine-readable export error code type.

typeJsonValuesource ↗
type JsonValue = null | boolean | number | string | readonly JsonValue[] | { }

JSON-compatible scalar or object value.

variableExportErrorCodesource ↗
ExportErrorCode: { codecNotFound: "SEAR_EXPORT_CODEC_NOT_FOUND"; duplicateCodec: "SEAR_EXPORT_DUPLICATE_CODEC"; invalidFormat: "SEAR_EXPORT_INVALID_FORMAT" }

Stable machine-readable error codes owned by the export plugin.

variableSearWorkbookFileFormatsource ↗
SearWorkbookFileFormat: "searsuite.workbook"

Current stable workbook JSON format identifier.

functioncloneJsonRecordsource ↗
cloneJsonRecord(value: Readonly<Record<string, unknown>> | undefined, path: string): Readonly<Record<string, JsonValue>> | undefined

Narrows a runtime value to a JSON-compatible metadata record.

value: Readonly<Record<string, unknown>> | undefined
path: string
functioncloneJsonValuesource ↗
cloneJsonValue<TValue>(value: TValue, path?: string): TValue

Clones a JSON-compatible value and rejects values that cannot be persisted as JSON.

value: TValue
path: string
functionreadRecordsource ↗
readRecord(value: unknown, path: string): Record<string, unknown>

Narrows a runtime value to a plain object.

value: unknown
path: string
variableExportErrorCodeValuesource ↗
ExportErrorCodeValue: { codecNotFound: "SEAR_EXPORT_CODEC_NOT_FOUND"; duplicateCodec: "SEAR_EXPORT_DUPLICATE_CODEC"; invalidFormat: "SEAR_EXPORT_INVALID_FORMAT" }

Stable machine-readable error codes owned by the export plugin.