1- import { IoMessageCode } from '../io-message' ;
1+ import { IoMessageCode , IoMessageLevel } from '../io-message' ;
2+
3+ /**
4+ * Information for each IO Message Code.
5+ */
6+ export interface CodeInfo {
7+ /**
8+ * The message code.
9+ */
10+ code : IoMessageCode ;
11+
12+ /**
13+ * A brief description of the meaning of this IO Message.
14+ */
15+ description : string ;
16+
17+ /**
18+ * The message level
19+ */
20+ level : IoMessageLevel ;
21+
22+ /**
23+ * The name of the payload interface, if applicable.
24+ * Some Io Messages include a payload, with a specific interface. The name of
25+ * the interface is specified here so that it can be linked with the message
26+ * when documentation is generated.
27+ *
28+ * The interface _must_ be exposed directly from toolkit-lib, so that it will
29+ * have a documentation page generated (that can be linked to).
30+ */
31+ interface ?: string ;
32+ }
33+
34+ function codeInfo ( info : CodeInfo ) : CodeInfo {
35+ return info ;
36+ }
237
338/**
439 * We have a rough system by which we assign message codes:
@@ -8,55 +43,162 @@ import { IoMessageCode } from '../io-message';
843 */
944export const CODES = {
1045 // 1: Synth
11- CDK_TOOLKIT_I1000 : 'Provides synthesis times' ,
12- CDK_TOOLKIT_I1901 : 'Provides stack data' ,
13- CDK_TOOLKIT_I1902 : 'Successfully deployed stacks' ,
46+ CDK_TOOLKIT_I1000 : codeInfo ( {
47+ code : 'CDK_TOOLKIT_I1000' ,
48+ description : 'Provides synthesis times.' ,
49+ level : 'info' ,
50+ } ) ,
51+ CDK_TOOLKIT_I1901 : codeInfo ( {
52+ code : 'CDK_TOOLKIT_I1901' ,
53+ description : 'Provides stack data' ,
54+ level : 'result' ,
55+ interface : 'StackData' ,
56+ } ) ,
57+ CDK_TOOLKIT_I1902 : codeInfo ( {
58+ code : 'CDK_TOOLKIT_I1902' ,
59+ description : 'Successfully deployed stacks' ,
60+ level : 'result' ,
61+ interface : 'AssemblyData' ,
62+ } ) ,
1463
1564 // 2: List
16- CDK_TOOLKIT_I2901 : 'Provides details on the selected stacks and their dependencies' ,
65+ CDK_TOOLKIT_I2901 : codeInfo ( {
66+ code : 'CDK_TOOLKIT_I2901' ,
67+ description : 'Provides details on the selected stacks and their dependencies' ,
68+ level : 'result' ,
69+ } ) ,
1770
1871 // 3: Import & Migrate
19- CDK_TOOLKIT_E3900 : 'Resource import failed' ,
72+ CDK_TOOLKIT_E3900 : codeInfo ( {
73+ code : 'CDK_TOOLKIT_E3900' ,
74+ description : 'Resource import failed' ,
75+ level : 'error' ,
76+ } ) ,
2077
2178 // 4: Diff
2279
2380 // 5: Deploy & Watch
24- CDK_TOOLKIT_I5000 : 'Provides deployment times' ,
25- CDK_TOOLKIT_I5001 : 'Provides total time in deploy action, including synth and rollback' ,
26- CDK_TOOLKIT_I5002 : 'Provides time for resource migration' ,
27- CDK_TOOLKIT_I5031 : 'Informs about any log groups that are traced as part of the deployment' ,
28- CDK_TOOLKIT_I5050 : 'Confirm rollback during deployment' ,
29- CDK_TOOLKIT_I5060 : 'Confirm deploy security sensitive changes' ,
30- CDK_TOOLKIT_I5900 : 'Deployment results on success' ,
81+ CDK_TOOLKIT_I5000 : codeInfo ( {
82+ code : 'CDK_TOOLKIT_I5000' ,
83+ description : 'Provides deployment times' ,
84+ level : 'info' ,
85+ } ) ,
86+ CDK_TOOLKIT_I5001 : codeInfo ( {
87+ code : 'CDK_TOOLKIT_I5001' ,
88+ description : 'Provides total time in deploy action, including synth and rollback' ,
89+ level : 'info' ,
90+ interface : 'Duration' ,
91+ } ) ,
92+ CDK_TOOLKIT_I5002 : codeInfo ( {
93+ code : 'CDK_TOOLKIT_I5002' ,
94+ description : 'Provides time for resource migration' ,
95+ level : 'info' ,
96+ } ) ,
97+ CDK_TOOLKIT_I5031 : codeInfo ( {
98+ code : 'CDK_TOOLKIT_I5031' ,
99+ description : 'Informs about any log groups that are traced as part of the deployment' ,
100+ level : 'info' ,
101+ } ) ,
102+ CDK_TOOLKIT_I5050 : codeInfo ( {
103+ code : 'CDK_TOOLKIT_I5050' ,
104+ description : 'Confirm rollback during deployment' ,
105+ level : 'info' ,
106+ } ) ,
107+ CDK_TOOLKIT_I5060 : codeInfo ( {
108+ code : 'CDK_TOOLKIT_I5060' ,
109+ description : 'Confirm deploy security sensitive changes' ,
110+ level : 'info' ,
111+ } ) ,
112+ CDK_TOOLKIT_I5900 : codeInfo ( {
113+ code : 'CDK_TOOLKIT_I5900' ,
114+ description : 'Deployment results on success' ,
115+ level : 'result' ,
116+ interface : 'SuccessfulDeployStackResult' ,
117+ } ) ,
31118
32- CDK_TOOLKIT_E5001 : 'No stacks found' ,
119+ CDK_TOOLKIT_E5001 : codeInfo ( {
120+ code : 'CDK_TOOLKIT_E5001' ,
121+ description : 'No stacks found' ,
122+ level : 'error' ,
123+ } ) ,
33124
34125 // 6: Rollback
35- CDK_TOOLKIT_I6000 : 'Provides rollback times' ,
126+ CDK_TOOLKIT_I6000 : codeInfo ( {
127+ code : 'CDK_TOOLKIT_I6000' ,
128+ description : 'Provides rollback times' ,
129+ level : 'info' ,
130+ } ) ,
36131
37- CDK_TOOLKIT_E6001 : 'No stacks found' ,
38- CDK_TOOLKIT_E6900 : 'Rollback failed' ,
132+ CDK_TOOLKIT_E6001 : codeInfo ( {
133+ code : 'CDK_TOOLKIT_E6001' ,
134+ description : 'No stacks found' ,
135+ level : 'error' ,
136+ } ) ,
137+ CDK_TOOLKIT_E6900 : codeInfo ( {
138+ code : 'CDK_TOOLKIT_E6900' ,
139+ description : 'Rollback failed' ,
140+ level : 'error' ,
141+ } ) ,
39142
40143 // 7: Destroy
41- CDK_TOOLKIT_I7000 : 'Provides destroy times' ,
42- CDK_TOOLKIT_I7010 : 'Confirm destroy stacks' ,
144+ CDK_TOOLKIT_I7000 : codeInfo ( {
145+ code : 'CDK_TOOLKIT_I7000' ,
146+ description : 'Provides destroy times' ,
147+ level : 'info' ,
148+ } ) ,
149+ CDK_TOOLKIT_I7010 : codeInfo ( {
150+ code : 'CDK_TOOLKIT_I7010' ,
151+ description : 'Confirm destroy stacks' ,
152+ level : 'info' ,
153+ } ) ,
43154
44- CDK_TOOLKIT_E7010 : 'Action was aborted due to negative confirmation of request' ,
45- CDK_TOOLKIT_E7900 : 'Stack deletion failed' ,
155+ CDK_TOOLKIT_E7010 : codeInfo ( {
156+ code : 'CDK_TOOLKIT_E7010' ,
157+ description : 'Action was aborted due to negative confirmation of request' ,
158+ level : 'error' ,
159+ } ) ,
160+ CDK_TOOLKIT_E7900 : codeInfo ( {
161+ code : 'CDK_TOOLKIT_E7900' ,
162+ description : 'Stack deletion failed' ,
163+ level : 'error' ,
164+ } ) ,
46165
47166 // 9: Bootstrap
48167
49168 // Assembly codes
50- CDK_ASSEMBLY_I0042 : 'Writing updated context' ,
51- CDK_ASSEMBLY_I0241 : 'Fetching missing context' ,
52- CDK_ASSEMBLY_I1000 : 'Cloud assembly output starts' ,
53- CDK_ASSEMBLY_I1001 : 'Output lines emitted by the cloud assembly to stdout' ,
54- CDK_ASSEMBLY_E1002 : 'Output lines emitted by the cloud assembly to stderr' ,
55- CDK_ASSEMBLY_I1003 : 'Cloud assembly output finished' ,
56- CDK_ASSEMBLY_E1111 : 'Incompatible CDK CLI version. Upgrade needed.' ,
169+ CDK_ASSEMBLY_I0042 : codeInfo ( {
170+ code : 'CDK_ASSEMBLY_I0042' ,
171+ description : 'Writing updated context' ,
172+ level : 'debug' ,
173+ } ) ,
174+ CDK_ASSEMBLY_I0241 : codeInfo ( {
175+ code : 'CDK_ASSEMBLY_I0241' ,
176+ description : 'Fetching missing context' ,
177+ level : 'debug' ,
178+ } ) ,
179+ CDK_ASSEMBLY_I1000 : codeInfo ( {
180+ code : 'CDK_ASSEMBLY_I1000' ,
181+ description : 'Cloud assembly output starts' ,
182+ level : 'debug' ,
183+ } ) ,
184+ CDK_ASSEMBLY_I1001 : codeInfo ( {
185+ code : 'CDK_ASSEMBLY_I1001' ,
186+ description : 'Output lines emitted by the cloud assembly to stdout' ,
187+ level : 'info' ,
188+ } ) ,
189+ CDK_ASSEMBLY_E1002 : codeInfo ( {
190+ code : 'CDK_ASSEMBLY_E1002' ,
191+ description : 'Output lines emitted by the cloud assembly to stderr' ,
192+ level : 'error' ,
193+ } ) ,
194+ CDK_ASSEMBLY_I1003 : codeInfo ( {
195+ code : 'CDK_ASSEMBLY_I1003' ,
196+ description : 'Cloud assembly output finished' ,
197+ level : 'info' ,
198+ } ) ,
199+ CDK_ASSEMBLY_E1111 : codeInfo ( {
200+ code : 'CDK_ASSEMBLY_E1111' ,
201+ description : 'Incompatible CDK CLI version. Upgrade needed.' ,
202+ level : 'error' ,
203+ } ) ,
57204} ;
58-
59- // If we give CODES a type with key: IoMessageCode,
60- // this dynamically generated type will generalize to allow all IoMessageCodes.
61- // Instead, we will validate that VALID_CODE must be IoMessageCode with the '&'.
62- export type VALID_CODE = keyof typeof CODES & IoMessageCode ;
0 commit comments