@curl-runner/cli 1.16.0 → 1.16.2
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.
- package/package.json +2 -2
- package/src/ci-exit.test.ts +0 -216
- package/src/cli.ts +0 -1351
- package/src/commands/upgrade.ts +0 -262
- package/src/diff/baseline-manager.test.ts +0 -181
- package/src/diff/baseline-manager.ts +0 -266
- package/src/diff/diff-formatter.ts +0 -316
- package/src/diff/index.ts +0 -3
- package/src/diff/response-differ.test.ts +0 -330
- package/src/diff/response-differ.ts +0 -489
- package/src/executor/max-concurrency.test.ts +0 -139
- package/src/executor/profile-executor.test.ts +0 -132
- package/src/executor/profile-executor.ts +0 -167
- package/src/executor/request-executor.ts +0 -663
- package/src/parser/yaml.test.ts +0 -480
- package/src/parser/yaml.ts +0 -271
- package/src/snapshot/index.ts +0 -3
- package/src/snapshot/snapshot-differ.test.ts +0 -358
- package/src/snapshot/snapshot-differ.ts +0 -296
- package/src/snapshot/snapshot-formatter.ts +0 -170
- package/src/snapshot/snapshot-manager.test.ts +0 -204
- package/src/snapshot/snapshot-manager.ts +0 -342
- package/src/types/bun-yaml.d.ts +0 -11
- package/src/types/config.ts +0 -638
- package/src/utils/colors.ts +0 -30
- package/src/utils/condition-evaluator.test.ts +0 -415
- package/src/utils/condition-evaluator.ts +0 -327
- package/src/utils/curl-builder.test.ts +0 -165
- package/src/utils/curl-builder.ts +0 -209
- package/src/utils/installation-detector.test.ts +0 -52
- package/src/utils/installation-detector.ts +0 -123
- package/src/utils/logger.ts +0 -856
- package/src/utils/response-store.test.ts +0 -213
- package/src/utils/response-store.ts +0 -108
- package/src/utils/stats.test.ts +0 -161
- package/src/utils/stats.ts +0 -151
- package/src/utils/version-checker.ts +0 -158
- package/src/version.ts +0 -43
- package/src/watcher/file-watcher.test.ts +0 -186
- package/src/watcher/file-watcher.ts +0 -140
package/src/types/config.ts
DELETED
|
@@ -1,638 +0,0 @@
|
|
|
1
|
-
export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
|
2
|
-
export interface JsonObject {
|
|
3
|
-
[key: string]: JsonValue;
|
|
4
|
-
}
|
|
5
|
-
export interface JsonArray extends Array<JsonValue> {}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Configuration for a file attachment in a form data request.
|
|
9
|
-
*
|
|
10
|
-
* Examples:
|
|
11
|
-
* - `{ file: "./image.png" }` - Simple file attachment
|
|
12
|
-
* - `{ file: "./doc.pdf", filename: "document.pdf" }` - With custom filename
|
|
13
|
-
* - `{ file: "./data.json", contentType: "application/json" }` - With explicit content type
|
|
14
|
-
*/
|
|
15
|
-
export interface FileAttachment {
|
|
16
|
-
/** Path to the file (relative to YAML file or absolute) */
|
|
17
|
-
file: string;
|
|
18
|
-
/** Custom filename to send (defaults to actual filename) */
|
|
19
|
-
filename?: string;
|
|
20
|
-
/** Explicit content type (curl will auto-detect if not specified) */
|
|
21
|
-
contentType?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A form field value can be a string, number, boolean, or a file attachment.
|
|
26
|
-
*/
|
|
27
|
-
export type FormFieldValue = string | number | boolean | FileAttachment;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Configuration for form data (multipart/form-data) requests.
|
|
31
|
-
* Each key is a form field name, and the value can be a simple value or a file attachment.
|
|
32
|
-
*
|
|
33
|
-
* Examples:
|
|
34
|
-
* ```yaml
|
|
35
|
-
* formData:
|
|
36
|
-
* name: "John Doe"
|
|
37
|
-
* age: 30
|
|
38
|
-
* avatar:
|
|
39
|
-
* file: "./avatar.png"
|
|
40
|
-
* document:
|
|
41
|
-
* file: "./report.pdf"
|
|
42
|
-
* filename: "quarterly-report.pdf"
|
|
43
|
-
* contentType: "application/pdf"
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export type FormDataConfig = Record<string, FormFieldValue>;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Configuration for storing response values as variables for subsequent requests.
|
|
50
|
-
* Maps a variable name to a JSON path in the response.
|
|
51
|
-
*
|
|
52
|
-
* Examples:
|
|
53
|
-
* - `{ "userId": "body.id" }` - Store response body's id field as ${store.userId}
|
|
54
|
-
* - `{ "token": "body.data.token" }` - Store nested field
|
|
55
|
-
* - `{ "statusCode": "status" }` - Store HTTP status code
|
|
56
|
-
* - `{ "contentType": "headers.content-type" }` - Store response header
|
|
57
|
-
*/
|
|
58
|
-
export type StoreConfig = Record<string, string>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Operators for conditional expressions.
|
|
62
|
-
*/
|
|
63
|
-
export type ConditionOperator =
|
|
64
|
-
| '=='
|
|
65
|
-
| '!='
|
|
66
|
-
| '>'
|
|
67
|
-
| '<'
|
|
68
|
-
| '>='
|
|
69
|
-
| '<='
|
|
70
|
-
| 'contains'
|
|
71
|
-
| 'matches'
|
|
72
|
-
| 'exists'
|
|
73
|
-
| 'not-exists';
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* A single condition expression comparing a store value against an expected value.
|
|
77
|
-
*
|
|
78
|
-
* Examples:
|
|
79
|
-
* - `{ left: "store.status", operator: "==", right: 200 }`
|
|
80
|
-
* - `{ left: "store.userId", operator: "exists" }`
|
|
81
|
-
* - `{ left: "store.body.type", operator: "contains", right: "user" }`
|
|
82
|
-
*/
|
|
83
|
-
export interface ConditionExpression {
|
|
84
|
-
/** Left operand - typically a store path like "store.status" or "store.body.id" */
|
|
85
|
-
left: string;
|
|
86
|
-
/** Comparison operator */
|
|
87
|
-
operator: ConditionOperator;
|
|
88
|
-
/** Right operand - the value to compare against. Optional for exists/not-exists. */
|
|
89
|
-
right?: string | number | boolean;
|
|
90
|
-
/** Case-sensitive comparison for string operators. Default: false (case-insensitive) */
|
|
91
|
-
caseSensitive?: boolean;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Configuration for conditional request execution.
|
|
96
|
-
* Supports single conditions, AND (all), and OR (any) compound conditions.
|
|
97
|
-
*
|
|
98
|
-
* Examples:
|
|
99
|
-
* ```yaml
|
|
100
|
-
* # Single condition
|
|
101
|
-
* when:
|
|
102
|
-
* left: store.status
|
|
103
|
-
* operator: "=="
|
|
104
|
-
* right: 200
|
|
105
|
-
*
|
|
106
|
-
* # AND condition (all must be true)
|
|
107
|
-
* when:
|
|
108
|
-
* all:
|
|
109
|
-
* - left: store.status
|
|
110
|
-
* operator: "=="
|
|
111
|
-
* right: 200
|
|
112
|
-
* - left: store.userId
|
|
113
|
-
* operator: exists
|
|
114
|
-
*
|
|
115
|
-
* # OR condition (any must be true)
|
|
116
|
-
* when:
|
|
117
|
-
* any:
|
|
118
|
-
* - left: store.type
|
|
119
|
-
* operator: "=="
|
|
120
|
-
* right: "admin"
|
|
121
|
-
* - left: store.type
|
|
122
|
-
* operator: "=="
|
|
123
|
-
* right: "superuser"
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
export interface WhenCondition {
|
|
127
|
-
/** All conditions must be true (AND logic) */
|
|
128
|
-
all?: ConditionExpression[];
|
|
129
|
-
/** Any condition must be true (OR logic) */
|
|
130
|
-
any?: ConditionExpression[];
|
|
131
|
-
/** Single condition - left operand */
|
|
132
|
-
left?: string;
|
|
133
|
-
/** Single condition - operator */
|
|
134
|
-
operator?: ConditionOperator;
|
|
135
|
-
/** Single condition - right operand */
|
|
136
|
-
right?: string | number | boolean;
|
|
137
|
-
/** Case-sensitive comparison for string operators. Default: false */
|
|
138
|
-
caseSensitive?: boolean;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* SSL/TLS certificate configuration options.
|
|
143
|
-
*
|
|
144
|
-
* Examples:
|
|
145
|
-
* - `{ verify: false }` - Disable SSL verification (equivalent to insecure: true)
|
|
146
|
-
* - `{ ca: "./certs/ca.pem" }` - Use custom CA certificate
|
|
147
|
-
* - `{ cert: "./certs/client.pem", key: "./certs/client-key.pem" }` - Mutual TLS (mTLS)
|
|
148
|
-
*/
|
|
149
|
-
export interface SSLConfig {
|
|
150
|
-
/** Whether to verify SSL certificates. Defaults to true. */
|
|
151
|
-
verify?: boolean;
|
|
152
|
-
/** Path to CA certificate file for custom certificate authorities. */
|
|
153
|
-
ca?: string;
|
|
154
|
-
/** Path to client certificate file for mutual TLS authentication. */
|
|
155
|
-
cert?: string;
|
|
156
|
-
/** Path to client private key file for mutual TLS authentication. */
|
|
157
|
-
key?: string;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export interface RequestConfig {
|
|
161
|
-
name?: string;
|
|
162
|
-
url: string;
|
|
163
|
-
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
164
|
-
headers?: Record<string, string>;
|
|
165
|
-
params?: Record<string, string>;
|
|
166
|
-
sourceFile?: string; // Source YAML file for better output organization
|
|
167
|
-
body?: JsonValue;
|
|
168
|
-
/**
|
|
169
|
-
* Form data for multipart/form-data requests.
|
|
170
|
-
* Use this for file uploads or when you need to send form fields.
|
|
171
|
-
* Cannot be used together with 'body'.
|
|
172
|
-
*
|
|
173
|
-
* @example
|
|
174
|
-
* formData:
|
|
175
|
-
* username: "john"
|
|
176
|
-
* avatar:
|
|
177
|
-
* file: "./avatar.png"
|
|
178
|
-
*/
|
|
179
|
-
formData?: FormDataConfig;
|
|
180
|
-
timeout?: number;
|
|
181
|
-
followRedirects?: boolean;
|
|
182
|
-
maxRedirects?: number;
|
|
183
|
-
auth?: {
|
|
184
|
-
type: 'basic' | 'bearer';
|
|
185
|
-
username?: string;
|
|
186
|
-
password?: string;
|
|
187
|
-
token?: string;
|
|
188
|
-
};
|
|
189
|
-
proxy?: string;
|
|
190
|
-
insecure?: boolean;
|
|
191
|
-
/**
|
|
192
|
-
* SSL/TLS certificate configuration.
|
|
193
|
-
* Use this for custom CA certificates or mutual TLS (mTLS) authentication.
|
|
194
|
-
*
|
|
195
|
-
* @example
|
|
196
|
-
* ssl:
|
|
197
|
-
* verify: true
|
|
198
|
-
* ca: "./certs/ca.pem"
|
|
199
|
-
* cert: "./certs/client.pem"
|
|
200
|
-
* key: "./certs/client-key.pem"
|
|
201
|
-
*/
|
|
202
|
-
ssl?: SSLConfig;
|
|
203
|
-
output?: string;
|
|
204
|
-
retry?: {
|
|
205
|
-
count: number;
|
|
206
|
-
delay?: number;
|
|
207
|
-
/** Exponential backoff multiplier. Default is 1 (no backoff).
|
|
208
|
-
* Example: with delay=1000 and backoff=2, delays are: 1000ms, 2000ms, 4000ms, 8000ms... */
|
|
209
|
-
backoff?: number;
|
|
210
|
-
};
|
|
211
|
-
variables?: Record<string, string>;
|
|
212
|
-
/**
|
|
213
|
-
* Store response values as variables for subsequent requests.
|
|
214
|
-
* Use JSON path syntax to extract values from the response.
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* store:
|
|
218
|
-
* userId: body.id
|
|
219
|
-
* token: body.data.accessToken
|
|
220
|
-
* statusCode: status
|
|
221
|
-
* contentType: headers.content-type
|
|
222
|
-
*/
|
|
223
|
-
store?: StoreConfig;
|
|
224
|
-
/**
|
|
225
|
-
* Conditional execution - skip/run request based on previous results.
|
|
226
|
-
* Only works in sequential execution mode.
|
|
227
|
-
*
|
|
228
|
-
* @example
|
|
229
|
-
* # Object syntax
|
|
230
|
-
* when:
|
|
231
|
-
* left: store.status
|
|
232
|
-
* operator: "=="
|
|
233
|
-
* right: 200
|
|
234
|
-
*
|
|
235
|
-
* # String shorthand
|
|
236
|
-
* when: "store.status == 200"
|
|
237
|
-
*
|
|
238
|
-
* # Compound conditions
|
|
239
|
-
* when:
|
|
240
|
-
* all:
|
|
241
|
-
* - left: store.userId
|
|
242
|
-
* operator: exists
|
|
243
|
-
* - left: store.status
|
|
244
|
-
* operator: "<"
|
|
245
|
-
* right: 400
|
|
246
|
-
*/
|
|
247
|
-
when?: WhenCondition | string;
|
|
248
|
-
expect?: {
|
|
249
|
-
failure?: boolean; // If true, expect the request to fail (for negative testing)
|
|
250
|
-
status?: number | number[];
|
|
251
|
-
headers?: Record<string, string>;
|
|
252
|
-
body?: JsonValue;
|
|
253
|
-
responseTime?: string; // Response time validation like "< 1000", "> 500, < 2000"
|
|
254
|
-
};
|
|
255
|
-
/**
|
|
256
|
-
* Snapshot configuration for this request.
|
|
257
|
-
* Use `true` to enable with defaults, or provide detailed config.
|
|
258
|
-
*/
|
|
259
|
-
snapshot?: SnapshotConfig | boolean;
|
|
260
|
-
/**
|
|
261
|
-
* Response diffing configuration for this request.
|
|
262
|
-
* Use `true` to enable with defaults, or provide detailed config.
|
|
263
|
-
*/
|
|
264
|
-
diff?: DiffConfig | boolean;
|
|
265
|
-
sourceOutputConfig?: {
|
|
266
|
-
verbose?: boolean;
|
|
267
|
-
showHeaders?: boolean;
|
|
268
|
-
showBody?: boolean;
|
|
269
|
-
showMetrics?: boolean;
|
|
270
|
-
format?: 'json' | 'pretty' | 'raw';
|
|
271
|
-
prettyLevel?: 'minimal' | 'standard' | 'detailed';
|
|
272
|
-
saveToFile?: string;
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export interface CollectionConfig {
|
|
277
|
-
name: string;
|
|
278
|
-
description?: string;
|
|
279
|
-
variables?: Record<string, string>;
|
|
280
|
-
defaults?: Partial<RequestConfig>;
|
|
281
|
-
requests: RequestConfig[];
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* CI exit code configuration options.
|
|
286
|
-
* These options control how curl-runner exits in CI/CD pipelines.
|
|
287
|
-
*/
|
|
288
|
-
export interface CIExitConfig {
|
|
289
|
-
/**
|
|
290
|
-
* When true, exit with code 1 if any validation failures occur,
|
|
291
|
-
* regardless of the continueOnError setting.
|
|
292
|
-
* This is useful for CI/CD pipelines that need strict validation.
|
|
293
|
-
*/
|
|
294
|
-
strictExit?: boolean;
|
|
295
|
-
/**
|
|
296
|
-
* Maximum number of failures allowed before exiting with code 1.
|
|
297
|
-
* If set to 0, any failure will cause a non-zero exit.
|
|
298
|
-
* If undefined and strictExit is true, any failure causes non-zero exit.
|
|
299
|
-
*/
|
|
300
|
-
failOn?: number;
|
|
301
|
-
/**
|
|
302
|
-
* Maximum percentage of failures allowed before exiting with code 1.
|
|
303
|
-
* Value should be between 0 and 100.
|
|
304
|
-
* If set to 10, up to 10% of requests can fail without causing a non-zero exit.
|
|
305
|
-
*/
|
|
306
|
-
failOnPercentage?: number;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
export interface GlobalConfig {
|
|
310
|
-
execution?: 'sequential' | 'parallel';
|
|
311
|
-
/**
|
|
312
|
-
* Maximum number of concurrent requests when using parallel execution.
|
|
313
|
-
* If not set, all requests will execute simultaneously.
|
|
314
|
-
* Useful for avoiding rate limiting or overwhelming target servers.
|
|
315
|
-
*/
|
|
316
|
-
maxConcurrency?: number;
|
|
317
|
-
continueOnError?: boolean;
|
|
318
|
-
/**
|
|
319
|
-
* CI/CD exit code configuration.
|
|
320
|
-
* Controls when curl-runner should exit with non-zero status codes.
|
|
321
|
-
*/
|
|
322
|
-
ci?: CIExitConfig;
|
|
323
|
-
/**
|
|
324
|
-
* Global SSL/TLS certificate configuration.
|
|
325
|
-
* Applied to all requests unless overridden at the request level.
|
|
326
|
-
*/
|
|
327
|
-
ssl?: SSLConfig;
|
|
328
|
-
/**
|
|
329
|
-
* Watch mode configuration.
|
|
330
|
-
* Automatically re-runs requests when YAML files change.
|
|
331
|
-
*/
|
|
332
|
-
watch?: WatchConfig;
|
|
333
|
-
/**
|
|
334
|
-
* Performance profiling mode configuration.
|
|
335
|
-
* Runs requests multiple times to collect p50/p95/p99 latency stats.
|
|
336
|
-
*/
|
|
337
|
-
profile?: ProfileConfig;
|
|
338
|
-
/**
|
|
339
|
-
* Snapshot testing configuration.
|
|
340
|
-
* Saves response snapshots and compares future runs against them.
|
|
341
|
-
*/
|
|
342
|
-
snapshot?: GlobalSnapshotConfig;
|
|
343
|
-
/**
|
|
344
|
-
* Response diffing configuration.
|
|
345
|
-
* Compare responses between environments or runs to detect API drift.
|
|
346
|
-
*/
|
|
347
|
-
diff?: GlobalDiffConfig;
|
|
348
|
-
variables?: Record<string, string>;
|
|
349
|
-
output?: {
|
|
350
|
-
verbose?: boolean;
|
|
351
|
-
showHeaders?: boolean;
|
|
352
|
-
showBody?: boolean;
|
|
353
|
-
showMetrics?: boolean;
|
|
354
|
-
format?: 'json' | 'pretty' | 'raw';
|
|
355
|
-
prettyLevel?: 'minimal' | 'standard' | 'detailed';
|
|
356
|
-
saveToFile?: string;
|
|
357
|
-
};
|
|
358
|
-
defaults?: Partial<RequestConfig>;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
export interface YamlFile {
|
|
362
|
-
version?: string;
|
|
363
|
-
global?: GlobalConfig;
|
|
364
|
-
collection?: CollectionConfig;
|
|
365
|
-
requests?: RequestConfig[];
|
|
366
|
-
request?: RequestConfig;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
export interface ExecutionResult {
|
|
370
|
-
request: RequestConfig;
|
|
371
|
-
success: boolean;
|
|
372
|
-
status?: number;
|
|
373
|
-
headers?: Record<string, string>;
|
|
374
|
-
body?: JsonValue;
|
|
375
|
-
error?: string;
|
|
376
|
-
metrics?: {
|
|
377
|
-
duration: number;
|
|
378
|
-
size?: number;
|
|
379
|
-
dnsLookup?: number;
|
|
380
|
-
tcpConnection?: number;
|
|
381
|
-
tlsHandshake?: number;
|
|
382
|
-
firstByte?: number;
|
|
383
|
-
download?: number;
|
|
384
|
-
};
|
|
385
|
-
/** Snapshot comparison result (if snapshot testing enabled). */
|
|
386
|
-
snapshotResult?: SnapshotCompareResult;
|
|
387
|
-
/** Diff comparison result (if response diffing enabled). */
|
|
388
|
-
diffResult?: DiffCompareResult;
|
|
389
|
-
/** Whether this request was skipped due to a `when` condition. */
|
|
390
|
-
skipped?: boolean;
|
|
391
|
-
/** Reason the request was skipped (condition that failed). */
|
|
392
|
-
skipReason?: string;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
export interface ExecutionSummary {
|
|
396
|
-
total: number;
|
|
397
|
-
successful: number;
|
|
398
|
-
failed: number;
|
|
399
|
-
skipped: number;
|
|
400
|
-
duration: number;
|
|
401
|
-
results: ExecutionResult[];
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Context for storing response values between sequential requests.
|
|
406
|
-
* Values are stored as strings and can be referenced using ${store.variableName} syntax.
|
|
407
|
-
*/
|
|
408
|
-
export type ResponseStoreContext = Record<string, string>;
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Configuration for watch mode.
|
|
412
|
-
* Watch mode automatically re-runs requests when YAML files change.
|
|
413
|
-
*/
|
|
414
|
-
export interface WatchConfig {
|
|
415
|
-
/** Enable watch mode. Default: false */
|
|
416
|
-
enabled?: boolean;
|
|
417
|
-
/** Debounce delay in milliseconds. Default: 300 */
|
|
418
|
-
debounce?: number;
|
|
419
|
-
/** Clear screen between runs. Default: true */
|
|
420
|
-
clear?: boolean;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Configuration for performance profiling mode.
|
|
425
|
-
* Runs requests multiple times to collect latency statistics.
|
|
426
|
-
*/
|
|
427
|
-
export interface ProfileConfig {
|
|
428
|
-
/** Number of iterations to run. Default: 10 */
|
|
429
|
-
iterations: number;
|
|
430
|
-
/** Number of warmup iterations to exclude from stats. Default: 1 */
|
|
431
|
-
warmup?: number;
|
|
432
|
-
/** Number of concurrent iterations. Default: 1 (sequential) */
|
|
433
|
-
concurrency?: number;
|
|
434
|
-
/** Show ASCII histogram in output. Default: false */
|
|
435
|
-
histogram?: boolean;
|
|
436
|
-
/** Export raw timings to file (JSON or CSV based on extension) */
|
|
437
|
-
exportFile?: string;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Statistics computed from profile run timings.
|
|
442
|
-
*/
|
|
443
|
-
export interface ProfileStats {
|
|
444
|
-
/** Total iterations run (excluding warmup) */
|
|
445
|
-
iterations: number;
|
|
446
|
-
/** Warmup iterations excluded */
|
|
447
|
-
warmup: number;
|
|
448
|
-
/** Minimum latency in ms */
|
|
449
|
-
min: number;
|
|
450
|
-
/** Maximum latency in ms */
|
|
451
|
-
max: number;
|
|
452
|
-
/** Mean latency in ms */
|
|
453
|
-
mean: number;
|
|
454
|
-
/** Median latency in ms (same as p50) */
|
|
455
|
-
median: number;
|
|
456
|
-
/** 50th percentile latency in ms */
|
|
457
|
-
p50: number;
|
|
458
|
-
/** 95th percentile latency in ms */
|
|
459
|
-
p95: number;
|
|
460
|
-
/** 99th percentile latency in ms */
|
|
461
|
-
p99: number;
|
|
462
|
-
/** Standard deviation in ms */
|
|
463
|
-
stdDev: number;
|
|
464
|
-
/** Number of failed iterations */
|
|
465
|
-
failures: number;
|
|
466
|
-
/** Failure rate as percentage */
|
|
467
|
-
failureRate: number;
|
|
468
|
-
/** Raw timing values (for export) */
|
|
469
|
-
timings: number[];
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Result of a profiled request execution.
|
|
474
|
-
*/
|
|
475
|
-
export interface ProfileResult {
|
|
476
|
-
request: RequestConfig;
|
|
477
|
-
stats: ProfileStats;
|
|
478
|
-
/** Individual results from each iteration */
|
|
479
|
-
iterations: ExecutionResult[];
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Configuration for snapshot testing.
|
|
484
|
-
* Snapshots save response data and compare future runs against them.
|
|
485
|
-
*/
|
|
486
|
-
export interface SnapshotConfig {
|
|
487
|
-
/** Enable snapshot testing for this request. */
|
|
488
|
-
enabled?: boolean;
|
|
489
|
-
/** Custom snapshot name (defaults to request name). */
|
|
490
|
-
name?: string;
|
|
491
|
-
/** What to include in snapshot. Default: ['body'] */
|
|
492
|
-
include?: ('body' | 'status' | 'headers')[];
|
|
493
|
-
/** Paths to exclude from comparison (e.g., 'body.timestamp'). */
|
|
494
|
-
exclude?: string[];
|
|
495
|
-
/** Match rules for dynamic values (path -> '*' or 'regex:pattern'). */
|
|
496
|
-
match?: Record<string, string>;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Global snapshot configuration.
|
|
501
|
-
*/
|
|
502
|
-
export interface GlobalSnapshotConfig extends SnapshotConfig {
|
|
503
|
-
/** Directory for snapshot files. Default: '__snapshots__' */
|
|
504
|
-
dir?: string;
|
|
505
|
-
/** Update mode: 'none' | 'all' | 'failing'. Default: 'none' */
|
|
506
|
-
updateMode?: 'none' | 'all' | 'failing';
|
|
507
|
-
/** CI mode: fail if snapshot is missing. Default: false */
|
|
508
|
-
ci?: boolean;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Stored snapshot data for a single request.
|
|
513
|
-
*/
|
|
514
|
-
export interface Snapshot {
|
|
515
|
-
status?: number;
|
|
516
|
-
headers?: Record<string, string>;
|
|
517
|
-
body?: JsonValue;
|
|
518
|
-
hash: string;
|
|
519
|
-
updatedAt: string;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* Snapshot file format.
|
|
524
|
-
*/
|
|
525
|
-
export interface SnapshotFile {
|
|
526
|
-
version: number;
|
|
527
|
-
snapshots: Record<string, Snapshot>;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* Result of comparing a response against a snapshot.
|
|
532
|
-
*/
|
|
533
|
-
export interface SnapshotDiff {
|
|
534
|
-
path: string;
|
|
535
|
-
expected: unknown;
|
|
536
|
-
received: unknown;
|
|
537
|
-
type: 'added' | 'removed' | 'changed' | 'type_mismatch';
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Result of snapshot comparison.
|
|
542
|
-
*/
|
|
543
|
-
export interface SnapshotCompareResult {
|
|
544
|
-
match: boolean;
|
|
545
|
-
isNew: boolean;
|
|
546
|
-
updated: boolean;
|
|
547
|
-
differences: SnapshotDiff[];
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
/**
|
|
551
|
-
* Configuration for response diffing at request level.
|
|
552
|
-
*/
|
|
553
|
-
export interface DiffConfig {
|
|
554
|
-
/** Enable diffing for this request. */
|
|
555
|
-
enabled?: boolean;
|
|
556
|
-
/** Paths to exclude from comparison (e.g., 'body.timestamp'). */
|
|
557
|
-
exclude?: string[];
|
|
558
|
-
/** Match rules for dynamic values (path -> '*' or 'regex:pattern'). */
|
|
559
|
-
match?: Record<string, string>;
|
|
560
|
-
/** Include timing differences in comparison. Default: false */
|
|
561
|
-
includeTimings?: boolean;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Global configuration for response diffing.
|
|
566
|
-
*/
|
|
567
|
-
export interface GlobalDiffConfig extends DiffConfig {
|
|
568
|
-
/** Directory for baseline files. Default: '__baselines__' */
|
|
569
|
-
dir?: string;
|
|
570
|
-
/** Label for current run (e.g., 'staging', 'production'). */
|
|
571
|
-
label?: string;
|
|
572
|
-
/** Label to compare against. */
|
|
573
|
-
compareWith?: string;
|
|
574
|
-
/** Save current run as baseline. */
|
|
575
|
-
save?: boolean;
|
|
576
|
-
/** Output format for diff results. Default: 'terminal' */
|
|
577
|
-
outputFormat?: 'terminal' | 'json' | 'markdown';
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
/**
|
|
581
|
-
* Stored baseline data for a single request.
|
|
582
|
-
*/
|
|
583
|
-
export interface Baseline {
|
|
584
|
-
status?: number;
|
|
585
|
-
headers?: Record<string, string>;
|
|
586
|
-
body?: JsonValue;
|
|
587
|
-
timing?: number;
|
|
588
|
-
hash: string;
|
|
589
|
-
capturedAt: string;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* Baseline file format.
|
|
594
|
-
*/
|
|
595
|
-
export interface BaselineFile {
|
|
596
|
-
version: number;
|
|
597
|
-
label: string;
|
|
598
|
-
capturedAt: string;
|
|
599
|
-
baselines: Record<string, Baseline>;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* Single difference in response comparison.
|
|
604
|
-
*/
|
|
605
|
-
export interface ResponseDiff {
|
|
606
|
-
path: string;
|
|
607
|
-
baseline: unknown;
|
|
608
|
-
current: unknown;
|
|
609
|
-
type: 'added' | 'removed' | 'changed' | 'type_mismatch';
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
* Result of comparing a response against a baseline.
|
|
614
|
-
*/
|
|
615
|
-
export interface DiffCompareResult {
|
|
616
|
-
requestName: string;
|
|
617
|
-
hasDifferences: boolean;
|
|
618
|
-
isNewBaseline: boolean;
|
|
619
|
-
baselineLabel: string;
|
|
620
|
-
currentLabel: string;
|
|
621
|
-
differences: ResponseDiff[];
|
|
622
|
-
timingDiff?: {
|
|
623
|
-
baseline: number;
|
|
624
|
-
current: number;
|
|
625
|
-
changePercent: number;
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Summary of diff comparison across all requests.
|
|
631
|
-
*/
|
|
632
|
-
export interface DiffSummary {
|
|
633
|
-
totalRequests: number;
|
|
634
|
-
unchanged: number;
|
|
635
|
-
changed: number;
|
|
636
|
-
newBaselines: number;
|
|
637
|
-
results: DiffCompareResult[];
|
|
638
|
-
}
|
package/src/utils/colors.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const colors = {
|
|
2
|
-
reset: '\x1b[0m',
|
|
3
|
-
bright: '\x1b[1m',
|
|
4
|
-
dim: '\x1b[2m',
|
|
5
|
-
underscore: '\x1b[4m',
|
|
6
|
-
|
|
7
|
-
black: '\x1b[30m',
|
|
8
|
-
red: '\x1b[31m',
|
|
9
|
-
green: '\x1b[32m',
|
|
10
|
-
yellow: '\x1b[33m',
|
|
11
|
-
blue: '\x1b[34m',
|
|
12
|
-
magenta: '\x1b[35m',
|
|
13
|
-
cyan: '\x1b[36m',
|
|
14
|
-
white: '\x1b[37m',
|
|
15
|
-
|
|
16
|
-
bgBlack: '\x1b[40m',
|
|
17
|
-
bgRed: '\x1b[41m',
|
|
18
|
-
bgGreen: '\x1b[42m',
|
|
19
|
-
bgYellow: '\x1b[43m',
|
|
20
|
-
bgBlue: '\x1b[44m',
|
|
21
|
-
bgMagenta: '\x1b[45m',
|
|
22
|
-
bgCyan: '\x1b[46m',
|
|
23
|
-
bgWhite: '\x1b[47m',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export function color(text: string, colorName: keyof typeof colors): string {
|
|
27
|
-
return `${colors[colorName]}${text}${colors.reset}`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type Color = keyof typeof colors;
|