Host load and commit contract for versioned workbook persistence.
Examples
See also
Members 3
load
commit
commitBatch Commit an atomic batch at versions baseVersion + 1 through baseVersion + versionOperationCounts.length.
Commit an atomic batch at versions `baseVersion + 1` through
`baseVersion + versionOperationCounts.length`. Apply every member or none,
publish every member with its `batch` position, and acknowledge with the
last version. `SyncCoordinator` rejects a local transaction that needs more
than one version when the adapter does not implement this method.
Declaration
View full TypeScript declaration
export interface PersistenceAdapter {
Referenced by
Workspace packages depending on @sheetwrite/core
@sheetwrite/benchdependency
@sheetwrite/docs-startdependency
@sheetwrite/reactdependency
@sheetwrite/sveltedependency
@sheetwrite/vuedependency
@sheetwrite/xlsxdependency
Public exports naming PersistenceAdapter
class MemoryPersistenceAdapter class MemoryPersistenceAdapter class MemoryPersistenceAdapter Executable database-neutral reference adapter for tests, demos, and local workflows. API reference → interface PersistenceAdapter interface PersistenceAdapter interface PersistenceAdapter Host load and commit contract for versioned workbook persistence. @example import { MemoryPersistenceAdapter, type PersistenceAdapter, type WorkbookSnapshot } from "@sheetwrite/core"; async function loadLocal(snapshot: WorkbookSnapshot) { if (!snapshot.documentId) throw new Error("A document ID is required"); const adapter: PersistenceAdapter = new MemoryPersistenceAdapter(snapshot); return adapter.load(snapshot.documentId); }@see MemoryPersistenceAdapter *@see SyncCoordinatorAPI reference → interface WorkbookSnapshot interface WorkbookSnapshot interface WorkbookSnapshot Schema-versioned serializable workbook document. API reference → function loadLocal(snapshot: WorkbookSnapshot): Promise<WorkbookSnapshot> function loadLocal (
snapshot : WorkbookSnapshot ,
) : Promise < WorkbookSnapshot > function loadLocal (
snapshot : WorkbookSnapshot ,
) : Promise < WorkbookSnapshot > API reference → snapshot: WorkbookSnapshot let snapshot : WorkbookSnapshot let snapshot : WorkbookSnapshot API reference → WorkbookSnapshot.documentId?: string | undefined interface WorkbookSnapshot {
documentId ?: string | undefined ;
} interface WorkbookSnapshot {
documentId ?: string | undefined ;
} API reference → var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+2 overloads) var Error : ErrorConstructor
new ( message ?: string , options ?: ErrorOptions ) => Error ( + 2 overloads) var Error : ErrorConstructor
new ( message ?: string , options ?: ErrorOptions ) => Error ( + 2 overloads) new MemoryPersistenceAdapter(...snapshots: readonly WorkbookSnapshot[]): MemoryPersistenceAdapter new MemoryPersistenceAdapter ( ... snapshots: readonly WorkbookSnapshot[]): MemoryPersistenceAdapter new MemoryPersistenceAdapter ( ... snapshots: readonly WorkbookSnapshot[]): MemoryPersistenceAdapter Executable database-neutral reference adapter for tests, demos, and local workflows. API reference → const adapter: PersistenceAdapter const adapter : PersistenceAdapter const adapter : PersistenceAdapter API reference → PersistenceAdapter.load(documentId: string, signal?: AbortSignal): Promise<WorkbookSnapshot> PersistenceAdapter. load (documentId: string, signal ?: AbortSignal): Promise < WorkbookSnapshot > PersistenceAdapter. load (documentId: string, signal ?: AbortSignal): Promise < WorkbookSnapshot > WorkbookSnapshot.documentId?: string interface WorkbookSnapshot {
documentId ?: string ;
} interface WorkbookSnapshot {
documentId ?: string ;
} API reference → interface WorkbookSnapshot {
schemaVersion: 1;
documentId?: string;
version?: number;
workbook: {
activeSheet: SheetId;
namedRanges?: NamedRangeSnapshot[];
};
sheets: SheetSnapshot[];
} interface WorkbookSnapshot {
schemaVersion : 1 ;
documentId ?: string ;
version ?: number ;
workbook : {
activeSheet : SheetId ;
namedRanges ?: NamedRangeSnapshot [];
};
sheets : SheetSnapshot [];
} interface WorkbookSnapshot {
schemaVersion : 1 ;
documentId ?: string ;
version ?: number ;
workbook : {
activeSheet : SheetId ;
namedRanges ?: NamedRangeSnapshot [];
};
sheets : SheetSnapshot [];
} Schema-versioned serializable workbook document. API reference → interface PersistenceCommitRequest {
signal?: AbortSignal;
documentId: string;
baseVersion: number;
clientMutationId: string;
readonly operations: readonly DocumentOp[];
readonly versionOperationCounts?: readonly number[];
} interface PersistenceCommitRequest {
signal ?: AbortSignal ;
documentId : string ;
baseVersion : number ;
clientMutationId : string ;
readonly operations : readonly DocumentOp [];
readonly versionOperationCounts ?: readonly number [];
} interface PersistenceCommitRequest {
signal ?: AbortSignal ;
documentId : string ;
baseVersion : number ;
clientMutationId : string ;
readonly operations : readonly DocumentOp [];
readonly versionOperationCounts ?: readonly number [];
} Cancellable pending commit submitted to a persistence adapter. API reference → type PersistenceCommitResponse =
| { status: "applied"; version: number; clientMutationId: string }
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
operationsSinceBase?: readonly VersionedOperation[];
snapshot?: WorkbookSnapshot;
}; type PersistenceCommitResponse =
| { status : "applied" ; version : number ; clientMutationId : string }
| {
status : "duplicate" ;
version : number ;
clientMutationId : string ;
}
| {
status : "conflict" ;
currentVersion : number ;
operationsSinceBase ?: readonly VersionedOperation [];
snapshot ?: WorkbookSnapshot ;
}; type PersistenceCommitResponse =
| {
status : "applied" ;
version : number ;
clientMutationId : string ;
}
| {
status : "duplicate" ;
version : number ;
clientMutationId : string ;
}
| {
status : "conflict" ;
currentVersion : number ;
operationsSinceBase ?: readonly VersionedOperation [];
snapshot ?: WorkbookSnapshot ;
}; Applied, duplicate, or conflict acknowledgement from persistence. applied confirms the submitted operations unchanged; normalization must conflict. API reference → interface PersistenceBatchCommitRequest {
readonly versionOperationCounts: readonly number[];
documentId: string;
baseVersion: number;
clientMutationId: string;
readonly operations: readonly DocumentOp[];
signal?: AbortSignal;
} interface PersistenceBatchCommitRequest {
readonly versionOperationCounts : readonly number [];
documentId : string ;
baseVersion : number ;
clientMutationId : string ;
readonly operations : readonly DocumentOp [];
signal ?: AbortSignal ;
} interface PersistenceBatchCommitRequest {
readonly versionOperationCounts : readonly number [];
documentId : string ;
baseVersion : number ;
clientMutationId : string ;
readonly operations : readonly DocumentOp [];
signal ?: AbortSignal ;
} Cancellable commit of one atomic batch that spans several server versions. API reference →