@appthrust/kest 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,134 @@
1
+ interface BaseEvent<
2
+ Kind extends string,
3
+ Data extends Record<string, unknown> = Record<string, never>,
4
+ > {
5
+ readonly kind: Kind;
6
+ readonly data: Data;
7
+ }
8
+
9
+ export type Event =
10
+ | ScenarioStartedEvent
11
+ | CommandRunEvent
12
+ | CommandResultEvent
13
+ | RetryEvent
14
+ | ActionEvent
15
+ | RevertingsEvent
16
+ | BDDEvent;
17
+
18
+ export type ScenarioStartedEvent = BaseEvent<
19
+ "ScenarioStarted",
20
+ {
21
+ readonly name: string;
22
+ }
23
+ >;
24
+
25
+ export type RetryEvent =
26
+ | RetryStartEvent
27
+ | RetryAttemptEvent
28
+ | RetryFailureEvent
29
+ | RetryEndEvent;
30
+
31
+ export interface ErrorSummary {
32
+ readonly name?: undefined | string;
33
+ readonly message: string;
34
+ }
35
+
36
+ export type RetryStartEvent = BaseEvent<"RetryStart", Record<string, never>>;
37
+
38
+ export type RetryAttemptEvent = BaseEvent<
39
+ "RetryAttempt",
40
+ {
41
+ readonly attempt: number;
42
+ }
43
+ >;
44
+
45
+ export type RetryFailureEvent = BaseEvent<
46
+ "RetryFailure",
47
+ {
48
+ readonly attempt: number;
49
+ readonly error: ErrorSummary;
50
+ }
51
+ >;
52
+
53
+ export type RetryEndEvent = BaseEvent<
54
+ "RetryEnd",
55
+ | {
56
+ readonly attempts: number;
57
+ readonly success: true;
58
+ readonly reason: "success";
59
+ }
60
+ | {
61
+ readonly attempts: number;
62
+ readonly success: false;
63
+ readonly reason: "timeout";
64
+ readonly error: ErrorSummary;
65
+ }
66
+ >;
67
+
68
+ export type CommandRunEvent = BaseEvent<
69
+ "CommandRun",
70
+ {
71
+ readonly cmd: string;
72
+ readonly args: ReadonlyArray<string>;
73
+ readonly stdin?: undefined | string;
74
+ readonly stdinLanguage?: undefined | string;
75
+ }
76
+ >;
77
+
78
+ export type CommandResultEvent = BaseEvent<
79
+ "CommandResult",
80
+ {
81
+ readonly exitCode: number;
82
+ readonly stdout: string;
83
+ readonly stderr: string;
84
+ readonly stdoutLanguage?: undefined | string;
85
+ readonly stderrLanguage?: undefined | string;
86
+ }
87
+ >;
88
+
89
+ export type ActionEvent = ActionStartEvent | ActionEndEvent;
90
+
91
+ export type ActionPhase = "mutate" | "revert" | "query";
92
+
93
+ export type ActionStartEvent = BaseEvent<
94
+ "ActionStart",
95
+ {
96
+ readonly action: string; // e.g. "CreateNamespaceAction"
97
+ readonly phase: ActionPhase;
98
+ readonly input?: undefined | Readonly<Record<string, unknown>>;
99
+ }
100
+ >;
101
+
102
+ export type ActionEndEvent = BaseEvent<
103
+ "ActionEnd",
104
+ {
105
+ readonly action: string; // e.g. "CreateNamespaceAction"
106
+ readonly phase: ActionPhase;
107
+ readonly ok: boolean;
108
+ readonly error?: undefined | ErrorSummary;
109
+ readonly output?: undefined | Readonly<Record<string, unknown>>;
110
+ }
111
+ >;
112
+
113
+ export type RevertingsEvent = RevertingsStartEvent | RevertingsEndEvent;
114
+ export type RevertingsStartEvent = BaseEvent<"RevertingsStart">;
115
+ export type RevertingsEndEvent = BaseEvent<"RevertingsEnd">;
116
+
117
+ export type BDDEvent = BaseEvent<
118
+ "BDDGiven" | "BDDWhen" | "BDDThen" | "BDDAnd" | "BDBut",
119
+ {
120
+ readonly description: string;
121
+ }
122
+ >;
123
+
124
+ export class Recorder {
125
+ private readonly events: Array<Event> = [];
126
+
127
+ record<T extends Event>(kind: T["kind"], data: T["data"]) {
128
+ this.events.push({ kind, data } as T);
129
+ }
130
+
131
+ getEvents(): Array<Event> {
132
+ return this.events;
133
+ }
134
+ }
File without changes
@@ -0,0 +1,5 @@
1
+ import type { Event } from "../recording";
2
+
3
+ export interface Reporter {
4
+ report(events: ReadonlyArray<Event>): Promise<string>;
5
+ }