On this page
Executable database-neutral reference adapter for tests, demos, and local workflows.
Members 4
constructor
commit
commitBatch Validate every member version against the default sync limits, apply the members in order to one scratch store, and publish all of them only when every member applied.
load
Declaration
View full TypeScript declaration
Referenced by
Workspace packages depending on @sheetwrite/core
@sheetwrite/benchdependency
@sheetwrite/docs-startdependency
@sheetwrite/reactdependency
@sheetwrite/sveltedependency
@sheetwrite/vuedependency
@sheetwrite/xlsxdependency
Public exports naming MemoryPersistenceAdapter
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 →interface PersistenceAdapter {
load(
documentId: string,
signal?: AbortSignal,
): Promise<WorkbookSnapshot>;
commit(
request: PersistenceCommitRequest,
): Promise<PersistenceCommitResponse>;
commitBatch?(
request: PersistenceBatchCommitRequest,
): Promise<PersistenceCommitResponse>;
}interface PersistenceAdapter {
load(
documentId: string,
signal?: AbortSignal,
): Promise<WorkbookSnapshot>;
commit(
request: PersistenceCommitRequest,
): Promise<PersistenceCommitResponse>;
commitBatch?(
request: PersistenceBatchCommitRequest,
): Promise<PersistenceCommitResponse>;
}interface PersistenceAdapter {
load(
documentId: string,
signal?: AbortSignal,
): Promise<WorkbookSnapshot>;
commit(
request: PersistenceCommitRequest,
): Promise<PersistenceCommitResponse>;
commitBatch?(
request: PersistenceBatchCommitRequest,
): Promise<PersistenceCommitResponse>;
}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 →