UNPKG

1.62 kBTypeScriptView Raw
1import { Map as ImmutableMap } from 'immutable';
2export declare type StateId = KeyType;
3export declare type BranchId = KeyType;
4export declare type StateHash = string;
5export interface IConfiguration<T> {
6 debug?: boolean;
7 actionFilter?: (actionType: string) => boolean;
8 stateEqualityPredicate?: (s1: T, s2: T) => boolean;
9 stateKeyGenerator?: (state: T) => StateHash;
10 loadActionType?: string;
11 clearActionType?: string;
12 undoActionType?: string;
13 redoActionType?: string;
14 jumpToStateActionType?: string;
15 jumpToBranchActionType?: string;
16 jumpToLatestOnBranchActionType?: string;
17 createBranchActionType?: string;
18 renameBranchActionType?: string;
19 renameStateActionType?: string;
20 squashActionType?: string;
21 initialBranchName?: string;
22 initialStateName?: string;
23 skipToStartActionType?: string;
24 skipToEndActionType?: string;
25 actionName?: (state: any, stateId: StateId) => string;
26 branchName?: (oldBranch: BranchId, newBranch: BranchId, actionName: string) => string;
27 canHandleAction?: (action: any) => boolean;
28 handleAction?: (action: any, history: IDagHistory<T>) => IDagHistory<T>;
29}
30export interface IDagHistory<T> {
31 current: T;
32 lastStateId: StateId;
33 lastBranchId: BranchId;
34 stateHash: Map<StateHash, StateId>;
35 chronologicalStates: StateId[];
36 graph: ImmutableMap<any, any>;
37}
38export interface StateIdGenerator {
39 (lastStateId: StateId): StateId;
40}
41export interface StateNameGenerator {
42 (state: any, id: StateId): string;
43}
44export interface RenameBranchPayload {
45 branch: BranchId;
46 name: string;
47}