Add project command API
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import type { AppendedProjectRevision } from "./project-revision.store.js";
|
||||
import type { ProjectHistoryState } from "./project-history.store.js";
|
||||
|
||||
export interface ExecuteUserProjectCommandInput {
|
||||
projectId: string;
|
||||
expectedRevision: number;
|
||||
description?: string;
|
||||
actorId?: string;
|
||||
command: unknown;
|
||||
}
|
||||
|
||||
export interface ExecuteProjectHistoryCommandInput {
|
||||
projectId: string;
|
||||
expectedRevision: number;
|
||||
actorId?: string;
|
||||
}
|
||||
|
||||
export interface ExecutedProjectCommand {
|
||||
revision: AppendedProjectRevision;
|
||||
history: ProjectHistoryState;
|
||||
}
|
||||
|
||||
export interface ProjectCommandExecutor {
|
||||
executeUser(
|
||||
input: ExecuteUserProjectCommandInput
|
||||
): ExecutedProjectCommand;
|
||||
undo(
|
||||
input: ExecuteProjectHistoryCommandInput
|
||||
): ExecutedProjectCommand;
|
||||
redo(
|
||||
input: ExecuteProjectHistoryCommandInput
|
||||
): ExecutedProjectCommand;
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
import type { SerializedProjectCommand } from "../models/project-command.model.js";
|
||||
|
||||
export type ProjectHistoryDirection = "undo" | "redo";
|
||||
|
||||
export interface ProjectHistoryState {
|
||||
projectId: string;
|
||||
currentRevision: number;
|
||||
@@ -7,6 +11,15 @@ export interface ProjectHistoryState {
|
||||
redoChangeSetId: string | null;
|
||||
}
|
||||
|
||||
export interface ProjectHistoryCommand {
|
||||
changeSetId: string;
|
||||
command: SerializedProjectCommand;
|
||||
}
|
||||
|
||||
export interface ProjectHistoryStore {
|
||||
getState(projectId: string): ProjectHistoryState | null;
|
||||
getNextCommand(
|
||||
projectId: string,
|
||||
direction: ProjectHistoryDirection
|
||||
): ProjectHistoryCommand | null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user