@types/k6 0.53.1 → 0.53.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.
- k6/README.md +1 -1
- k6/{crypto.d.ts → crypto/index.d.ts} +1 -162
- k6/encoding/index.d.ts +46 -0
- k6/execution/index.d.ts +115 -0
- k6/experimental/{fs.d.ts → fs/index.d.ts} +2 -0
- k6/experimental/{redis.d.ts → redis/index.d.ts} +5 -0
- k6/experimental/{tracing.d.ts → tracing/index.d.ts} +3 -1
- k6/experimental/{websockets.d.ts → websockets/index.d.ts} +2 -2
- k6/global.d.ts +11 -3
- k6/{http.d.ts → http/index.d.ts} +14 -227
- k6/index.d.ts +3 -22
- k6/net/grpc/index.d.ts +196 -0
- k6/{options.d.ts → options/index.d.ts} +1 -1
- k6/package.json +3 -2
- k6/{ws.d.ts → ws/index.d.ts} +2 -41
- k6/encoding.d.ts +0 -90
- k6/execution.d.ts +0 -121
- k6/net/grpc.d.ts +0 -202
- /k6/{browser.d.ts → browser/index.d.ts} +0 -0
- /k6/{data.d.ts → data/index.d.ts} +0 -0
- /k6/experimental/{browser.d.ts → browser/index.d.ts} +0 -0
- /k6/experimental/{streams.d.ts → streams/index.d.ts} +0 -0
- /k6/experimental/{timers.d.ts → timers/index.d.ts} +0 -0
- /k6/experimental/{webcrypto.d.ts → webcrypto/index.d.ts} +0 -0
- /k6/{html.d.ts → html/index.d.ts} +0 -0
- /k6/{metrics.d.ts → metrics/index.d.ts} +0 -0
- /k6/{timers.d.ts → timers/index.d.ts} +0 -0
k6/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for k6 (https://grafana.com/docs/k6/lates
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Tue, 17 Sep 2024 08:09:49 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
|
|
14
14
|
# Credits
|
|
@@ -215,165 +215,4 @@ export abstract class Hasher {
|
|
|
215
215
|
digest<OE extends OutputEncoding>(outputEncoding: OE): Output<OE>;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
|
|
219
|
-
* This module provides common hashing functionality available in the GoLang crypto package.
|
|
220
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/
|
|
221
|
-
*/
|
|
222
|
-
declare namespace crypto {
|
|
223
|
-
/**
|
|
224
|
-
* Generate random bytes.
|
|
225
|
-
* @param size - Number of bytes to generate.
|
|
226
|
-
* @returns An ArrayBuffer with cryptographically random bytes.
|
|
227
|
-
* @example
|
|
228
|
-
* const bytes = crypto.randomBytes(42);
|
|
229
|
-
* const view = new Uint8Array(bytes);
|
|
230
|
-
* console.log(view); // 156,71,245,191,56,...
|
|
231
|
-
*/
|
|
232
|
-
function randomBytes(size: number): ArrayBuffer;
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Produce HMAC.
|
|
236
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/hmac/
|
|
237
|
-
* @param algorithm - Hash algorithm.
|
|
238
|
-
* @param secret - Shared secret.
|
|
239
|
-
* @param input - Input data.
|
|
240
|
-
* @param outputEncoding - Output encoding.
|
|
241
|
-
* @returns Produced HMAC.
|
|
242
|
-
* @example
|
|
243
|
-
* crypto.hmac('sha256', 'mysecret', 'hello world!', 'hex')
|
|
244
|
-
*/
|
|
245
|
-
function hmac<OE extends OutputEncoding>(
|
|
246
|
-
algorithm: Algorithm,
|
|
247
|
-
secret: string | ArrayBuffer,
|
|
248
|
-
input: string | ArrayBuffer,
|
|
249
|
-
outputEncoding: OE,
|
|
250
|
-
): Output<OE>;
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Hash with MD4.
|
|
254
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/md4/
|
|
255
|
-
* @param input - Data to hash.
|
|
256
|
-
* @param outputEncoding - Output encoding.
|
|
257
|
-
* @returns MD4 digest.
|
|
258
|
-
* @example
|
|
259
|
-
* crypto.md4('hello world!', 'hex')
|
|
260
|
-
*/
|
|
261
|
-
function md4<OE extends OutputEncoding>(input: string | ArrayBuffer, outputEncoding: OE): Output<OE>;
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Hash with MD5.
|
|
265
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/md5/
|
|
266
|
-
* @param input - Data to hash.
|
|
267
|
-
* @param outputEncoding - Output encoding.
|
|
268
|
-
* @returns MD5 digest.
|
|
269
|
-
* @example
|
|
270
|
-
* crypto.md5("hello world!", "hex")
|
|
271
|
-
*/
|
|
272
|
-
function md5<OE extends OutputEncoding>(input: string | ArrayBuffer, outputEncoding: OE): Output<OE>;
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Hash with SHA-1.
|
|
276
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/sha1/
|
|
277
|
-
* @param input - Data to hash.
|
|
278
|
-
* @param outputEncoding - Output encoding.
|
|
279
|
-
* @returns SHA-1 digest.
|
|
280
|
-
* @example
|
|
281
|
-
* crypto.sha1('hello world!', 'hex')
|
|
282
|
-
*/
|
|
283
|
-
function sha1<OE extends OutputEncoding>(input: string | ArrayBuffer, outputEncoding: OE): Output<OE>;
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Hash with SHA-256.
|
|
287
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/sha256/
|
|
288
|
-
* @param input - Data to hash.
|
|
289
|
-
* @param outputEncoding - Output encoding.
|
|
290
|
-
* @returns SHA-256 digest.
|
|
291
|
-
* @example
|
|
292
|
-
* crypto.sha256('hello world!', 'hex')
|
|
293
|
-
*/
|
|
294
|
-
function sha256<OE extends OutputEncoding>(input: string | ArrayBuffer, outputEncoding: OE): Output<OE>;
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Hash with SHA-384.
|
|
298
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/sha384/
|
|
299
|
-
* @param input - Data to hash.
|
|
300
|
-
* @param outputEncoding - Output encoding.
|
|
301
|
-
* @returns SHA-384 digest.
|
|
302
|
-
* @example
|
|
303
|
-
* crypto.sha384('hello world!', 'hex')
|
|
304
|
-
*/
|
|
305
|
-
function sha384<OE extends OutputEncoding>(input: string | ArrayBuffer, outputEncoding: OE): Output<OE>;
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Hash with SHA-512.
|
|
309
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/sha512/
|
|
310
|
-
* @param input - Data to hash.
|
|
311
|
-
* @param outputEncoding - Output encoding.
|
|
312
|
-
* @returns SHA-512 digest.
|
|
313
|
-
* @example
|
|
314
|
-
* crypto.sha512('hello world!', 'hex')
|
|
315
|
-
*/
|
|
316
|
-
function sha512<OE extends OutputEncoding>(input: string | ArrayBuffer, outputEncoding: OE): Output<OE>;
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Hash with SHA-512/224.
|
|
320
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/sha512_224/
|
|
321
|
-
* @param input - Data to hash.
|
|
322
|
-
* @param outputEncoding - Output encoding.
|
|
323
|
-
* @returns SHA-512/224 digest.
|
|
324
|
-
* @example
|
|
325
|
-
* crypto.sha512_224('hello world!', 'hex')
|
|
326
|
-
*/
|
|
327
|
-
function sha512_224<OE extends OutputEncoding>(input: string | ArrayBuffer, outputEncoding: OE): Output<OE>;
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Hash with SHA-512/256.
|
|
331
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/sha512_256/
|
|
332
|
-
* @param input - Data to hash.
|
|
333
|
-
* @param outputEncoding - Output encoding.
|
|
334
|
-
* @returns SHA-512/256 digest.
|
|
335
|
-
* @example
|
|
336
|
-
* crypto.sha512_256('hello world!', 'hex')
|
|
337
|
-
*/
|
|
338
|
-
function sha512_256<OE extends OutputEncoding>(input: string | ArrayBuffer, outputEncoding: OE): Output<OE>;
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Hash with RIPEMD-160.
|
|
342
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/ripemd160/
|
|
343
|
-
* @param input - Data to hash.
|
|
344
|
-
* @param outputEncoding - Output encoding.
|
|
345
|
-
* @returns RIPEMD-160 digest.
|
|
346
|
-
* @example
|
|
347
|
-
* crypto.ripemd160('hello world!', 'hex')
|
|
348
|
-
*/
|
|
349
|
-
function ripemd160<OE extends OutputEncoding>(input: string | ArrayBuffer, outputEncoding: OE): Output<OE>;
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Create a hashing object.
|
|
353
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/createhash/
|
|
354
|
-
* @param algorithm - Hash algorithm.
|
|
355
|
-
* @returns Hashing object.
|
|
356
|
-
* @example
|
|
357
|
-
* let hasher = crypto.createHash('sha256');
|
|
358
|
-
* hasher.update('hello ');
|
|
359
|
-
* hasher.update('world!');
|
|
360
|
-
* console.log(hasher.digest('hex'));
|
|
361
|
-
*/
|
|
362
|
-
function createHash(algorithm: Algorithm): Hasher;
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Create an HMAC hashing object.
|
|
366
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-crypto/createhmac/
|
|
367
|
-
* @param algorithm - Hash algorithm.
|
|
368
|
-
* @param secret - Shared secret.
|
|
369
|
-
* @returns HMAC hashing object.
|
|
370
|
-
* @example
|
|
371
|
-
* let hasher = crypto.createHMAC('sha256', 'a secret');
|
|
372
|
-
* hasher.update('hello ');
|
|
373
|
-
* hasher.update('world!');
|
|
374
|
-
* console.log(hasher.digest('hex'));
|
|
375
|
-
*/
|
|
376
|
-
function createHMAC(algorithm: Algorithm, secret: string | ArrayBuffer): Hasher;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
export default crypto;
|
|
218
|
+
export * as default from "k6/crypto";
|
k6/encoding/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base64 decode a string.
|
|
3
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-encoding/b64decode/
|
|
4
|
+
* @param input - The string to base64 decode.
|
|
5
|
+
* @param encoding - Base64 variant.
|
|
6
|
+
* @returns The base64 decoded version of the input string in either string or ArrayBuffer format, depending on the `format` parameter.
|
|
7
|
+
* @example
|
|
8
|
+
* encoding.b64decode(str)
|
|
9
|
+
* encoding.b64decode(str, 'rawstd')
|
|
10
|
+
* const decBuffer = encoding.b64decode(str, 'rawurl')
|
|
11
|
+
* let decBin = new Uint8Array(decBuffer);
|
|
12
|
+
*/
|
|
13
|
+
export function b64decode(input: string, encoding?: Base64Variant): ArrayBuffer;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Base64 decode a string.
|
|
17
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-encoding/b64decode/
|
|
18
|
+
* @param input - The string to base64 decode.
|
|
19
|
+
* @param encoding - Base64 variant.
|
|
20
|
+
* @param format - If 's' return the data as a string, otherwise an ArrayBuffer object .
|
|
21
|
+
* @returns The base64 decoded version of the input string in either string or ArrayBuffer format, depending on the `format` parameter.
|
|
22
|
+
* @example
|
|
23
|
+
* encoding.b64decode(str)
|
|
24
|
+
* encoding.b64decode(str, 'rawstd')
|
|
25
|
+
* const decodedString = encoding.b64decode(str, 'rawurl', 's')
|
|
26
|
+
*/
|
|
27
|
+
export function b64decode(input: string, encoding: Base64Variant, format: "s"): string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Base64 encode a string.
|
|
31
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-encoding/b64encode/
|
|
32
|
+
* @param input - String to encode or ArrayBuffer object.
|
|
33
|
+
* @param encoding - Base64 variant.
|
|
34
|
+
* @returns Base64 encoded string.
|
|
35
|
+
* @example
|
|
36
|
+
* encoding.b64encode(str)
|
|
37
|
+
* encoding.b64encode(str, 'rawstd')
|
|
38
|
+
*/
|
|
39
|
+
export function b64encode(input: string | ArrayBuffer, encoding?: Base64Variant): string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Base64 variant.
|
|
43
|
+
*/
|
|
44
|
+
export type Base64Variant = "std" | "rawstd" | "url" | "rawurl";
|
|
45
|
+
|
|
46
|
+
export * as default from "k6/encoding";
|
k6/execution/index.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Options } from "./../options/index.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Information about the current scenario.
|
|
5
|
+
*/
|
|
6
|
+
export const scenario: {
|
|
7
|
+
/**
|
|
8
|
+
* The assigned name of the running scenario.
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* The name of the running Executor type.
|
|
13
|
+
*/
|
|
14
|
+
executor: string;
|
|
15
|
+
/**
|
|
16
|
+
* The Unix timestamp in milliseconds when the scenario started.
|
|
17
|
+
*/
|
|
18
|
+
startTime: number;
|
|
19
|
+
/**
|
|
20
|
+
* Percentage in a 0 to 1 interval of the scenario progress.
|
|
21
|
+
*/
|
|
22
|
+
progress: number;
|
|
23
|
+
/**
|
|
24
|
+
* The unique and zero-based sequential number of the current iteration in the scenario, across the current instance.
|
|
25
|
+
*/
|
|
26
|
+
iterationInInstance: number;
|
|
27
|
+
/**
|
|
28
|
+
* The unique and zero-based sequential number of the current iteration in the scenario.
|
|
29
|
+
*/
|
|
30
|
+
iterationInTest: number;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Information about the current load generator instance.
|
|
35
|
+
*/
|
|
36
|
+
export const instance: {
|
|
37
|
+
/**
|
|
38
|
+
* The number of prematurely interrupted iterations in the current instance.
|
|
39
|
+
*/
|
|
40
|
+
iterationsInterrupted: number;
|
|
41
|
+
/**
|
|
42
|
+
* The number of completed iterations in the current instance.
|
|
43
|
+
*/
|
|
44
|
+
iterationsCompleted: number;
|
|
45
|
+
/**
|
|
46
|
+
* The number of active VUs.
|
|
47
|
+
*/
|
|
48
|
+
vusActive: number;
|
|
49
|
+
/**
|
|
50
|
+
* The number of currently initialized VUs.
|
|
51
|
+
*/
|
|
52
|
+
vusInitialized: number;
|
|
53
|
+
/**
|
|
54
|
+
* The time passed from the start of the current test run in milliseconds.
|
|
55
|
+
*/
|
|
56
|
+
currentTestRunDuration: number;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Control the test execution.
|
|
61
|
+
*/
|
|
62
|
+
export const test: {
|
|
63
|
+
/**
|
|
64
|
+
* Aborts the test run with the exit code 108.
|
|
65
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-execution/#test
|
|
66
|
+
* @param input - Aborted message.
|
|
67
|
+
* @example
|
|
68
|
+
* import exec from "k6/execution";
|
|
69
|
+
* exec.test.abort();
|
|
70
|
+
* exec.test.abort('this is the reason');
|
|
71
|
+
*/
|
|
72
|
+
abort(input?: string): void;
|
|
73
|
+
|
|
74
|
+
options: Options;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Information about the current virtual user.
|
|
79
|
+
*/
|
|
80
|
+
export const vu: {
|
|
81
|
+
/**
|
|
82
|
+
* The identifier of the iteration in the current instance.
|
|
83
|
+
*/
|
|
84
|
+
iterationInInstance: number;
|
|
85
|
+
/**
|
|
86
|
+
* The identifier of the iteration in the current scenario.
|
|
87
|
+
*/
|
|
88
|
+
iterationInScenario: number;
|
|
89
|
+
/**
|
|
90
|
+
* The identifier of the VU across the instance.
|
|
91
|
+
*/
|
|
92
|
+
idInInstance: number;
|
|
93
|
+
/**
|
|
94
|
+
* The globally unique (across the whole test run) identifier of the VU.
|
|
95
|
+
*/
|
|
96
|
+
idInTest: number;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Map to set or get VU tags.
|
|
100
|
+
* @deprecated should use `metrics.tags` instead of just `tags`
|
|
101
|
+
*/
|
|
102
|
+
tags: Record<string, number | string | boolean>;
|
|
103
|
+
metrics: {
|
|
104
|
+
/**
|
|
105
|
+
* Map to set or get VU tags.
|
|
106
|
+
*/
|
|
107
|
+
tags: Record<string, number | string | boolean>;
|
|
108
|
+
/**
|
|
109
|
+
* Map to set or get VU metadata.
|
|
110
|
+
*/
|
|
111
|
+
metadata: Record<string, number | string | boolean>;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export * as default from "k6/execution";
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/tracing/
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { RefinedParams, RefinedResponse, RequestBody, ResponseType } from "
|
|
11
|
+
import { RefinedParams, RefinedResponse, RequestBody, ResponseType } from "../../http/index.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The instrumentHTTP function instruments the k6 http module
|
|
@@ -204,3 +204,5 @@ export interface Options {
|
|
|
204
204
|
export interface HttpURL {
|
|
205
205
|
__brand: "http-url";
|
|
206
206
|
}
|
|
207
|
+
|
|
208
|
+
export * as default from "k6/experimental/tracing";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CookieJar } from "
|
|
2
|
-
import { ReadableStream } from "
|
|
1
|
+
import { CookieJar } from "../../http/index.js";
|
|
2
|
+
import { ReadableStream } from "../streams/index.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* This module provides an experimental implementation of the WebSocket API
|
k6/global.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ declare global {
|
|
|
56
56
|
* Environment variables.
|
|
57
57
|
* https://grafana.com/docs/k6/latest/using-k6/environment-variables/
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
var __ENV: { [name: string]: string };
|
|
60
60
|
|
|
61
61
|
// === VU logic only ===
|
|
62
62
|
// ---------------------
|
|
@@ -65,11 +65,19 @@ declare global {
|
|
|
65
65
|
* Current VU number.
|
|
66
66
|
* https://grafana.com/docs/k6/latest/using-k6/execution-context-variables/
|
|
67
67
|
*/
|
|
68
|
-
|
|
68
|
+
var __VU: number;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Current iteration number.
|
|
72
72
|
* https://grafana.com/docs/k6/latest/using-k6/execution-context-variables/
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
var __ITER: number;
|
|
75
|
+
|
|
76
|
+
interface ImportMeta {
|
|
77
|
+
/**
|
|
78
|
+
* Resolve a path to a URL string in the same way an import statement does.
|
|
79
|
+
* https://grafana.com/docs/k6/latest/javascript-api/import.meta/resolve/
|
|
80
|
+
*/
|
|
81
|
+
resolve(specifier: string): string;
|
|
82
|
+
}
|
|
75
83
|
}
|
k6/{http.d.ts → http/index.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Selection } from "../html/index.js";
|
|
2
|
+
import { JSONValue } from "../index.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Make DELETE request.
|
|
@@ -143,6 +143,17 @@ export function asyncRequest<RT extends ResponseType | undefined>(
|
|
|
143
143
|
params?: RefinedParams<RT> | null,
|
|
144
144
|
): Promise<RefinedResponse<RT>>;
|
|
145
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Creates a URL with set name tag.
|
|
148
|
+
* https://grafana.com/docs/k6/latest/using-k6/http-requests/#url-grouping
|
|
149
|
+
* @param strings - Passed string values.
|
|
150
|
+
* @param args - Tagged template expressions.
|
|
151
|
+
* @returns HTTP URL object.
|
|
152
|
+
* @example
|
|
153
|
+
* http.get(http.url`http://example.com/posts/${id}`) // tags.name="http://example.com/posts/${}",
|
|
154
|
+
*/
|
|
155
|
+
export function url(strings: TemplateStringsArray, ...args: Array<string | number | boolean>): HttpURL;
|
|
156
|
+
|
|
146
157
|
/**
|
|
147
158
|
* Batch multiple HTTP requests together,
|
|
148
159
|
* to issue them in parallel over multiple TCP connections.
|
|
@@ -792,228 +803,4 @@ interface HttpURL {
|
|
|
792
803
|
__brand: "http-url";
|
|
793
804
|
}
|
|
794
805
|
|
|
795
|
-
|
|
796
|
-
* The http module contains functionality for performing HTTP transactions.
|
|
797
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/
|
|
798
|
-
*/
|
|
799
|
-
declare namespace http {
|
|
800
|
-
/**
|
|
801
|
-
* Make DELETE request.
|
|
802
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/del/
|
|
803
|
-
* @param url - Request URL.
|
|
804
|
-
* @param body - Discouraged. Request body. Object form encoded.
|
|
805
|
-
* @param params - Request parameters.
|
|
806
|
-
* @returns Resulting response.
|
|
807
|
-
*/
|
|
808
|
-
function del<RT extends ResponseType | undefined>(
|
|
809
|
-
url: string | HttpURL,
|
|
810
|
-
body?: RequestBody | null,
|
|
811
|
-
params?: RefinedParams<RT> | null,
|
|
812
|
-
): RefinedResponse<RT>;
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* Make HEAD request.
|
|
816
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/head/
|
|
817
|
-
* @param url - Request URL.
|
|
818
|
-
* @param params - Request parameters.
|
|
819
|
-
* @returns Resulting response.
|
|
820
|
-
* @example
|
|
821
|
-
* http.head('https://test.k6.io')
|
|
822
|
-
*/
|
|
823
|
-
function head<RT extends ResponseType | undefined>(
|
|
824
|
-
url: string | HttpURL,
|
|
825
|
-
params?: RefinedParams<RT> | null,
|
|
826
|
-
): RefinedResponse<RT>;
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
* Make GET request.
|
|
830
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/get/
|
|
831
|
-
* @param url - Request URL.
|
|
832
|
-
* @param params - Request parameters.
|
|
833
|
-
* @returns Resulting response.
|
|
834
|
-
* @example
|
|
835
|
-
* http.get('https://k6.io')
|
|
836
|
-
*/
|
|
837
|
-
function get<RT extends ResponseType | undefined>(
|
|
838
|
-
url: string | HttpURL,
|
|
839
|
-
params?: RefinedParams<RT> | null,
|
|
840
|
-
): RefinedResponse<RT>;
|
|
841
|
-
|
|
842
|
-
/**
|
|
843
|
-
* Make OPTIONS request.
|
|
844
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/options/
|
|
845
|
-
* @param url - Request URL.
|
|
846
|
-
* @param body - Request body. Object form encoded.
|
|
847
|
-
* @param params - Request parameters.
|
|
848
|
-
* @returns Resulting response.
|
|
849
|
-
*/
|
|
850
|
-
function options<RT extends ResponseType | undefined>(
|
|
851
|
-
url: string | HttpURL,
|
|
852
|
-
body?: RequestBody | null,
|
|
853
|
-
params?: RefinedParams<RT> | null,
|
|
854
|
-
): RefinedResponse<RT>;
|
|
855
|
-
|
|
856
|
-
/**
|
|
857
|
-
* Make PATCH request.
|
|
858
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/patch/
|
|
859
|
-
* @param url - Request URL.
|
|
860
|
-
* @param body - Request body. Object form encoded.
|
|
861
|
-
* @param params - Request parameters.
|
|
862
|
-
* @returns Resulting response.
|
|
863
|
-
*/
|
|
864
|
-
function patch<RT extends ResponseType | undefined>(
|
|
865
|
-
url: string | HttpURL,
|
|
866
|
-
body?: RequestBody | null,
|
|
867
|
-
params?: RefinedParams<RT> | null,
|
|
868
|
-
): RefinedResponse<RT>;
|
|
869
|
-
|
|
870
|
-
/**
|
|
871
|
-
* Make POST request.
|
|
872
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/post/
|
|
873
|
-
* @param url - Request URL.
|
|
874
|
-
* @param body - Request body. Object form encoded.
|
|
875
|
-
* @param params - Request parameters.
|
|
876
|
-
* @returns Resulting response.
|
|
877
|
-
* @example
|
|
878
|
-
* let formData = {name: 'k6'};
|
|
879
|
-
* let headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
880
|
-
* http.post(url, formData, { headers: headers });
|
|
881
|
-
*/
|
|
882
|
-
function post<RT extends ResponseType | undefined>(
|
|
883
|
-
url: string | HttpURL,
|
|
884
|
-
body?: RequestBody | null,
|
|
885
|
-
params?: RefinedParams<RT> | null,
|
|
886
|
-
): RefinedResponse<RT>;
|
|
887
|
-
|
|
888
|
-
/**
|
|
889
|
-
* Make PUT request.
|
|
890
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/put/
|
|
891
|
-
* @param url - Request URL.
|
|
892
|
-
* @param body - Request body. Object form encoded.
|
|
893
|
-
* @param params - Request parameters.
|
|
894
|
-
* @returns Resulting response.
|
|
895
|
-
*/
|
|
896
|
-
function put<RT extends ResponseType | undefined>(
|
|
897
|
-
url: string | HttpURL,
|
|
898
|
-
body?: RequestBody | null,
|
|
899
|
-
params?: RefinedParams<RT> | null,
|
|
900
|
-
): RefinedResponse<RT>;
|
|
901
|
-
|
|
902
|
-
/**
|
|
903
|
-
* Make request.
|
|
904
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/request/
|
|
905
|
-
* @param method - HTTP method.
|
|
906
|
-
* @param url - Request URL.
|
|
907
|
-
* @param body - Request body. Object form encoded.
|
|
908
|
-
* @param params - Request parameters.
|
|
909
|
-
* @returns Resulting response.
|
|
910
|
-
* @example
|
|
911
|
-
* let formData = {name: 'k6'};
|
|
912
|
-
* let headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
913
|
-
* http.request('POST', url, formData, { headers: headers });
|
|
914
|
-
*/
|
|
915
|
-
function request<RT extends ResponseType | undefined>(
|
|
916
|
-
method: string,
|
|
917
|
-
url: string | HttpURL,
|
|
918
|
-
body?: RequestBody | null,
|
|
919
|
-
params?: RefinedParams<RT> | null,
|
|
920
|
-
): RefinedResponse<RT>;
|
|
921
|
-
|
|
922
|
-
/**
|
|
923
|
-
* Make async request.
|
|
924
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/asyncrequest/
|
|
925
|
-
* @param method - HTTP method.
|
|
926
|
-
* @param url - Request URL.
|
|
927
|
-
* @param body - Request body. Object form encoded.
|
|
928
|
-
* @param params - Request parameters.
|
|
929
|
-
* @returns Resulting response.
|
|
930
|
-
* @example
|
|
931
|
-
* let formData = {name: 'k6'};
|
|
932
|
-
* let headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
933
|
-
* http.asyncRequest('POST', url, formData, { headers: headers });
|
|
934
|
-
*/
|
|
935
|
-
function asyncRequest<RT extends ResponseType | undefined>(
|
|
936
|
-
method: string,
|
|
937
|
-
url: string | HttpURL,
|
|
938
|
-
body?: RequestBody | null,
|
|
939
|
-
params?: RefinedParams<RT> | null,
|
|
940
|
-
): Promise<RefinedResponse<RT>>;
|
|
941
|
-
|
|
942
|
-
/**
|
|
943
|
-
* Creates a URL with set name tag.
|
|
944
|
-
* https://grafana.com/docs/k6/latest/using-k6/http-requests/#url-grouping
|
|
945
|
-
* @param strings - Passed string values.
|
|
946
|
-
* @param args - Tagged template expressions.
|
|
947
|
-
* @returns HTTP URL object.
|
|
948
|
-
* @example
|
|
949
|
-
* http.get(http.url`http://example.com/posts/${id}`) // tags.name="http://example.com/posts/${}",
|
|
950
|
-
*/
|
|
951
|
-
function url(strings: TemplateStringsArray, ...args: Array<string | number | boolean>): HttpURL;
|
|
952
|
-
|
|
953
|
-
/**
|
|
954
|
-
* Batch multiple HTTP requests together,
|
|
955
|
-
* to issue them in parallel over multiple TCP connections.
|
|
956
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/batch/
|
|
957
|
-
* @param requests - Request specifications.
|
|
958
|
-
* @returns Resulting responses.
|
|
959
|
-
* @example
|
|
960
|
-
* let req1 = {
|
|
961
|
-
* method: 'GET',
|
|
962
|
-
* url: 'https://httpbin.org/get',
|
|
963
|
-
* };
|
|
964
|
-
* let req2 = {
|
|
965
|
-
* method: 'POST',
|
|
966
|
-
* url: 'https://httpbin.org/post',
|
|
967
|
-
* body: {
|
|
968
|
-
* hello: 'world!',
|
|
969
|
-
* },
|
|
970
|
-
* params: {
|
|
971
|
-
* headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
972
|
-
* },
|
|
973
|
-
* };
|
|
974
|
-
* let responses = http.batch([req1, req2]);
|
|
975
|
-
*/
|
|
976
|
-
function batch<Q extends BatchRequests>(requests: Q): BatchResponses<Q>;
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Create a file object used for building multipart requests (file uploads).
|
|
980
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/file/
|
|
981
|
-
* @param data - File data.
|
|
982
|
-
* @param filename - Filename. Included in MIME message.
|
|
983
|
-
* @param contentType - Content type. Included in MIME message.
|
|
984
|
-
* @returns File data object.
|
|
985
|
-
* @example
|
|
986
|
-
* let binFile = open('/path/to/file.bin', 'b');
|
|
987
|
-
*
|
|
988
|
-
* export default function() {
|
|
989
|
-
* let f = http.file(binFile, 'test.bin');
|
|
990
|
-
* console.log(md5(f.data, 'hex'));
|
|
991
|
-
* console.log(f.filename);
|
|
992
|
-
* console.log(f.content_type);
|
|
993
|
-
* }
|
|
994
|
-
*/
|
|
995
|
-
function file(data: string | ArrayBuffer, filename?: string, contentType?: string): FileData;
|
|
996
|
-
|
|
997
|
-
/**
|
|
998
|
-
* Get active cookie jar.
|
|
999
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/cookiejar/
|
|
1000
|
-
* @returns Active cookie jar.
|
|
1001
|
-
* @example
|
|
1002
|
-
* let jar = http.cookieJar();
|
|
1003
|
-
*/
|
|
1004
|
-
function cookieJar(): CookieJar;
|
|
1005
|
-
/**
|
|
1006
|
-
* Returns a callback to be used with setResponseCallback to mark responses
|
|
1007
|
-
* as expected based only on their status codes.
|
|
1008
|
-
* https://staging.k6.io/docs/javascript-api/k6-http/expectedstatuses-statuses/
|
|
1009
|
-
*/
|
|
1010
|
-
function expectedStatuses(...param: Array<number | ExpectedStatusesObject>): ExpectedStatusesCallback;
|
|
1011
|
-
|
|
1012
|
-
/**
|
|
1013
|
-
* Set the response callback to be called to determine if a response was expected/successful or not.
|
|
1014
|
-
* https://grafana.com/docs/k6/latest/javascript-api/k6-http/setresponsecallback/
|
|
1015
|
-
*/
|
|
1016
|
-
function setResponseCallback(responseCallback: ExpectedStatusesCallback): void;
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
export default http;
|
|
806
|
+
export * as default from "k6/http";
|