-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
types.ts
264 lines (233 loc) · 5.25 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
// This file contains the input and output types for the providers.
// Kept in a separate file for sharing between the handler and the provider constructs.
export const ASSERT_RESOURCE_TYPE = 'Custom::DeployAssert@AssertEquals';
export const SDK_RESOURCE_TYPE_PREFIX = 'Custom::DeployAssert@SdkCall';
export const HTTP_RESOURCE_TYPE = 'Custom::DeployAssert@HttpCall';
export interface HttpRequestParameters {
/**
* The url to fetch
*/
readonly url: string;
/**
* Options for fetch
*/
readonly fetchOptions?: FetchOptions;
}
/**
* Request to the HttpCall resource
*/
export interface HttpRequest {
/**
* Parameters from the custom resource
*/
readonly parameters: HttpRequestParameters;
}
/**
* Options to pass to the JavaScript fetch api
*/
export interface FetchOptions {
/**
* Request body
*
* @default - no body
*/
readonly body?: string;
/**
* Optional port
*
* @default default port for protocol
*/
readonly port?: number;
/**
* HTTP method
*
* @default GET
*/
readonly method?: string;
/**
* Optional request headers
*
* @default no headers
*/
readonly headers?: { [key: string]: string };
}
/**
* Response from the HttpCall resource
*/
export interface HttpResponseWrapper {
/**
* The Response from the fetch request
*/
readonly apiCallResponse: HttpResponse;
}
/**
* Response from fetch
*/
export interface HttpResponse {
/**
* Indicates whether the response was successful
*
* status range 200-299
*/
readonly ok?: boolean;
/**
* Status code of the response
*/
readonly status?: number;
/**
* The status message corresponding to the status code
*/
readonly statusText?: string;
/**
* The response, either as parsed JSON or a string literal.
*/
readonly body?: any;
/**
* Headers associated with the response
*/
readonly headers?: { [name: string]: any };
}
/**
* A AWS JavaScript SDK V2 request
*/
export interface AwsApiCallRequest {
/**
* The AWS service i.e. S3
*/
readonly service: string;
/**
* The AWS api call to make i.e. getBucketLifecycle
*/
readonly api: string;
/**
* Any parameters to pass to the api call
*
* @default - no parameters
*/
readonly parameters?: any;
/**
* Whether or not to flatten the response from the api call
*
* Valid values are 'true' or 'false' as strings
*
* Typically when using an SdkRequest you will be passing it as the
* `actual` value to an assertion provider so this would be set
* to 'false' (you want the actual response).
*
* If you are using the SdkRequest to perform more of a query to return
* a single value to use, then this should be set to 'true'. For example,
* you could make a StepFunctions.startExecution api call and retreive the
* `executionArn` from the response.
*
* @default 'false'
*/
readonly flattenResponse?: string;
/**
* Restrict the data returned by the API call to specific paths in
* the API response. Use this to limit the data returned by the custom
* resource if working with API calls that could potentially result in custom
* response objects exceeding the hard limit of 4096 bytes.
*
* @default - return all data
*/
readonly outputPaths?: string[];
}
/**
* The result from a SdkQuery
*/
export interface AwsApiCallResult {
/**
* The full api response
*/
readonly apiCallResponse: any;
}
/**
* The type of assertion to perform
*/
export enum AssertionType {
/**
* Assert that two values are equal
*/
EQUALS = 'equals',
/**
* The keys and their values must be present in the target but the target
* can be a superset.
*/
OBJECT_LIKE = 'objectLike',
/**
* Matches the specified pattern with the array
* The set of elements must be in the same order as would be found
*/
ARRAY_WITH = 'arrayWith',
}
/**
* A request to make an assertion that the
* actual value matches the expected
*/
export interface AssertionRequest {
/**
* The expected value to assert
*/
readonly expected: any;
/**
* The actual value received
*/
readonly actual: any;
/**
* Set this to true if a failed assertion should
* result in a CloudFormation deployment failure
*
* This is only necessary if assertions are being
* executed outside of `integ-runner`.
*
* @default false
*/
readonly failDeployment?: boolean;
}
/**
* The result of an Assertion
* wrapping the actual result data in another struct.
* Needed to access the whole message via getAtt() on the custom resource.
*/
export interface AssertionResult {
/**
* The result of an assertion
*/
readonly assertion: string;
/**
* Whether or not the assertion failed
*
* @default false
*/
readonly failed?: boolean;
}
/**
* The status of the assertion
*/
export enum Status {
/**
* The assertion passed
*/
PASS = 'pass',
/**
* The assertion failed
*/
FAIL = 'fail',
}
/**
* The result of an assertion
*/
export interface AssertionResultData {
/**
* The status of the assertion, i.e.
* pass or fail
*/
readonly status: Status;
/**
* Any message returned with the assertion result
* typically this will be the diff if there is any
*
* @default - none
*/
readonly message?: string;
}