UNPKG

1.05 kBTypeScriptView Raw
1/**
2 * Interface that should be implemented in order to define a command
3 * @remarks Since 1.5.0
4 * @public
5 */
6export interface ICommand<Model extends object, Real, RunResult, CheckAsync extends boolean = false> {
7 /**
8 * Check if the model is in the right state to apply the command
9 *
10 * WARNING: does not change the model
11 *
12 * @param m - Model, simplified or schematic representation of real system
13 *
14 * @remarks Since 1.5.0
15 */
16 check(m: Readonly<Model>): CheckAsync extends false ? boolean : Promise<boolean>;
17 /**
18 * Receive the non-updated model and the real or system under test.
19 * Perform the checks post-execution - Throw in case of invalid state.
20 * Update the model accordingly
21 *
22 * @param m - Model, simplified or schematic representation of real system
23 * @param r - Sytem under test
24 *
25 * @remarks Since 1.5.0
26 */
27 run(m: Model, r: Real): RunResult;
28 /**
29 * Name of the command
30 * @remarks Since 1.5.0
31 */
32 toString(): string;
33}