@sheetwrite/coreclass
Coordinates listing and restoring host-owned workbook revisions.
- Package
@sheetwrite/core- Source
packages/core/src/collaboration.ts#L274
Members 7
constructor
constructor(adapter: RevisionAdapterinterface RevisionAdapter {
listRevisions(
documentId: string,
signal?: AbortSignal,
): Promise<readonly RevisionSummary[]>;
loadRevision(
documentId: string,
version: number,
signal?: AbortSignal,
): Promise<unknown>;
restoreRevision(
request: RevisionRestoreRequest,
): Promise<RevisionRestoreResponse>;
}interface RevisionAdapter {
listRevisions(
documentId: string,
signal?: AbortSignal,
): Promise<readonly RevisionSummary[]>;
loadRevision(
documentId: string,
version: number,
signal?: AbortSignal,
): Promise<unknown>;
restoreRevision(
request: RevisionRestoreRequest,
): Promise<RevisionRestoreResponse>;
}interface RevisionAdapter {
listRevisions(
documentId: string,
signal?: AbortSignal,
): Promise<
readonly RevisionSummary[]
>;
loadRevision(
documentId: string,
version: number,
signal?: AbortSignal,
): Promise<unknown>;
restoreRevision(
request: RevisionRestoreRequest,
): Promise<RevisionRestoreResponse>;
}Host persistence contract for revision history and restore.API reference →, options: RevisionCoordinatorOptionsinterface RevisionCoordinatorOptions {
documentId: string;
serverVersion: number;
migrateSnapshot?: (snapshot: unknown) => unknown;
}interface RevisionCoordinatorOptions {
documentId: string;
serverVersion: number;
migrateSnapshot?: (snapshot: unknown) => unknown;
}interface RevisionCoordinatorOptions {
documentId: string;
serverVersion: number;
migrateSnapshot?: (
snapshot: unknown,
) => unknown;
}Document identity and version options for revision coordination.API reference →);destroy
destroy: () => void;list
list: () => Promise<readonly RevisionSummaryinterface RevisionSummary {
version: number;
createdAt: string;
actor?: PresenceActor;
label?: string;
}interface RevisionSummary {
version: number;
createdAt: string;
actor?: PresenceActor;
label?: string;
}interface RevisionSummary {
version: number;
createdAt: string;
actor?: PresenceActor;
label?: string;
}Host-provided metadata describing a saved workbook revision.API reference →[]>;on
on: (listener: RevisionListener) => () => void;preview
preview: (host: HTMLElement, version: number, options?: SnapshotGridOptionstype SnapshotGridOptions = Omit<
GridOptions,
"workbook" | "data"
> & { snapshotResourceLimits?: Partial<SnapshotResourceLimits> };type SnapshotGridOptions = Omit<
GridOptions,
"workbook" | "data"
> & { snapshotResourceLimits?: Partial<SnapshotResourceLimits> };type SnapshotGridOptions = Omit<
GridOptions,
"workbook" | "data"
> & {
snapshotResourceLimits?: Partial<SnapshotResourceLimits>;
};Grid creation options accepted when hydrating a validated snapshot.API reference →) => Promise<Gridinterface Grid {
readonly store: Store;
readonly actions: GridActions;
setActiveSheet(id: SheetId): void;
scrollToCell(addr: CellAddress): void;
getCellAtPoint(
clientX: number,
clientY: number,
): CellAddress | null;
getActiveSheet(): SheetId;
getCellInput(row: number, col: number): CellInputSnapshot | null;
getSelection(): Selection | null;
setSelection(sel: Selection | null): void;
setTheme(theme: Partial<Theme>): void;
replaceTheme(theme: Partial<Theme> | undefined): void;
// … 106 more lines — see the API reference
}interface Grid {
readonly store: Store;
readonly actions: GridActions;
setActiveSheet(id: SheetId): void;
scrollToCell(addr: CellAddress): void;
getCellAtPoint(
clientX: number,
clientY: number,
): CellAddress | null;
getActiveSheet(): SheetId;
getCellInput(row: number, col: number): CellInputSnapshot | null;
getSelection(): Selection | null;
setSelection(sel: Selection | null): void;
setTheme(theme: Partial<Theme>): void;
replaceTheme(theme: Partial<Theme> | undefined): void;
// … 106 more lines — see the API reference
}interface Grid {
readonly store: Store;
readonly actions: GridActions;
setActiveSheet(
id: SheetId,
): void;
scrollToCell(
addr: CellAddress,
): void;
getCellAtPoint(
clientX: number,
clientY: number,
): CellAddress | null;
getActiveSheet(): SheetId;
getCellInput(
row: number,
col: number,
): CellInputSnapshot | null;
getSelection(): Selection | null;
// … 229 more lines — see the API reference
}Imperative grid handle for document commands, events, rendering, and teardown.API reference →>;restore
restore: (targetVersion: number, clientMutationId: string) => Promise<RevisionRestoreResponsetype RevisionRestoreResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
snapshot: WorkbookSnapshot;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type RevisionRestoreResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
snapshot: WorkbookSnapshot;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type RevisionRestoreResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
snapshot: WorkbookSnapshot;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
};Applied or conflict acknowledgement for a revision restore.API reference →>;serverVersion
serverVersion: numberDeclaration
View full TypeScript declaration
class RevisionCoordinator { constructor(adapter: RevisionAdapterinterface RevisionAdapter {
listRevisions(
documentId: string,
signal?: AbortSignal,
): Promise<readonly RevisionSummary[]>;
loadRevision(
documentId: string,
version: number,
signal?: AbortSignal,
): Promise<unknown>;
restoreRevision(
request: RevisionRestoreRequest,
): Promise<RevisionRestoreResponse>;
}interface RevisionAdapter {
listRevisions(
documentId: string,
signal?: AbortSignal,
): Promise<readonly RevisionSummary[]>;
loadRevision(
documentId: string,
version: number,
signal?: AbortSignal,
): Promise<unknown>;
restoreRevision(
request: RevisionRestoreRequest,
): Promise<RevisionRestoreResponse>;
}interface RevisionAdapter {
listRevisions(
documentId: string,
signal?: AbortSignal,
): Promise<
readonly RevisionSummary[]
>;
loadRevision(
documentId: string,
version: number,
signal?: AbortSignal,
): Promise<unknown>;
restoreRevision(
request: RevisionRestoreRequest,
): Promise<RevisionRestoreResponse>;
}Host persistence contract for revision history and restore.API reference →, options: RevisionCoordinatorOptionsinterface RevisionCoordinatorOptions {
documentId: string;
serverVersion: number;
migrateSnapshot?: (snapshot: unknown) => unknown;
}interface RevisionCoordinatorOptions {
documentId: string;
serverVersion: number;
migrateSnapshot?: (snapshot: unknown) => unknown;
}interface RevisionCoordinatorOptions {
documentId: string;
serverVersion: number;
migrateSnapshot?: (
snapshot: unknown,
) => unknown;
}Document identity and version options for revision coordination.API reference →); destroy: () => void; list: () => Promise<readonly RevisionSummaryinterface RevisionSummary {
version: number;
createdAt: string;
actor?: PresenceActor;
label?: string;
}interface RevisionSummary {
version: number;
createdAt: string;
actor?: PresenceActor;
label?: string;
}interface RevisionSummary {
version: number;
createdAt: string;
actor?: PresenceActor;
label?: string;
}Host-provided metadata describing a saved workbook revision.API reference →[]>; on: (listener: RevisionListener) => () => void; preview: ( host: HTMLElement, version: number, options?: SnapshotGridOptionstype SnapshotGridOptions = Omit<
GridOptions,
"workbook" | "data"
> & { snapshotResourceLimits?: Partial<SnapshotResourceLimits> };type SnapshotGridOptions = Omit<
GridOptions,
"workbook" | "data"
> & { snapshotResourceLimits?: Partial<SnapshotResourceLimits> };type SnapshotGridOptions = Omit<
GridOptions,
"workbook" | "data"
> & {
snapshotResourceLimits?: Partial<SnapshotResourceLimits>;
};Grid creation options accepted when hydrating a validated snapshot.API reference →, ) => Promise<Gridinterface Grid {
readonly store: Store;
readonly actions: GridActions;
setActiveSheet(id: SheetId): void;
scrollToCell(addr: CellAddress): void;
getCellAtPoint(
clientX: number,
clientY: number,
): CellAddress | null;
getActiveSheet(): SheetId;
getCellInput(row: number, col: number): CellInputSnapshot | null;
getSelection(): Selection | null;
setSelection(sel: Selection | null): void;
setTheme(theme: Partial<Theme>): void;
replaceTheme(theme: Partial<Theme> | undefined): void;
// … 106 more lines — see the API reference
}interface Grid {
readonly store: Store;
readonly actions: GridActions;
setActiveSheet(id: SheetId): void;
scrollToCell(addr: CellAddress): void;
getCellAtPoint(
clientX: number,
clientY: number,
): CellAddress | null;
getActiveSheet(): SheetId;
getCellInput(row: number, col: number): CellInputSnapshot | null;
getSelection(): Selection | null;
setSelection(sel: Selection | null): void;
setTheme(theme: Partial<Theme>): void;
replaceTheme(theme: Partial<Theme> | undefined): void;
// … 106 more lines — see the API reference
}interface Grid {
readonly store: Store;
readonly actions: GridActions;
setActiveSheet(
id: SheetId,
): void;
scrollToCell(
addr: CellAddress,
): void;
getCellAtPoint(
clientX: number,
clientY: number,
): CellAddress | null;
getActiveSheet(): SheetId;
getCellInput(
row: number,
col: number,
): CellInputSnapshot | null;
getSelection(): Selection | null;
// … 229 more lines — see the API reference
}Imperative grid handle for document commands, events, rendering, and teardown.API reference →>; restore: ( targetVersion: number, clientMutationId: string, ) => Promise<RevisionRestoreResponsetype RevisionRestoreResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
snapshot: WorkbookSnapshot;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type RevisionRestoreResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
snapshot: WorkbookSnapshot;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type RevisionRestoreResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
snapshot: WorkbookSnapshot;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
};Applied or conflict acknowledgement for a revision restore.API reference →>; serverVersion: number;}