@types/k6 0.44.1 → 0.44.3

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,101 @@
1
+ import { ResourceType, ResourceTiming } from './';
2
+ import { Response } from './response';
3
+ import { Frame } from './frame';
4
+
5
+ /**
6
+ * Request class represents requests which are sent by a page.
7
+ */
8
+ export class Request {
9
+ /**
10
+ * An object with HTTP headers associated with the request. All header names are
11
+ * lower-case.
12
+ * @returns The headers object.
13
+ */
14
+ allHeaders(): Record<string, string>;
15
+
16
+ /**
17
+ * @returns the Frame that initiated this request
18
+ */
19
+ frame(): Frame;
20
+
21
+ /**
22
+ * An object with HTTP headers associated with the request. All header names are
23
+ * lower-case.
24
+ * @returns An object with HTTP headers associated with the request.
25
+ */
26
+ headers(): Record<string, string>;
27
+
28
+ /**
29
+ * An array with all the request HTTP headers. Unlike `Request.allHeaders()`,
30
+ * header names are not lower-cased. Headers with multiple entries, such as
31
+ * `Set-Cookie`, appear in the array multiple times.
32
+ * @returns An array of all the request HTTP headers.
33
+ */
34
+ headersArray(): Array<{ name: string; value: string }>;
35
+
36
+ /**
37
+ * Retuns the value of the header matching the name. The name is case insensitive.
38
+ * @param name Header name to retrieve value for.
39
+ * @returns The value of the header matching the name.
40
+ */
41
+ headerValue(name: string): string | null;
42
+
43
+ /**
44
+ * @returns a boolean stating whether the request is for a navigation
45
+ */
46
+ isNavigationRequest(): boolean;
47
+
48
+ /**
49
+ * Request's method (GET, POST, etc.)
50
+ * @returns request's method name
51
+ */
52
+ method(): string;
53
+
54
+ /**
55
+ * Contains the request's post body, if any.
56
+ * @returns request's post body
57
+ */
58
+ postData(): string;
59
+
60
+ /**
61
+ * Request's post body in a binary form, if any.
62
+ * @returns an ArrayBuffer with request's post data
63
+ */
64
+ postDataBuffer(): ArrayBuffer | null;
65
+
66
+ /**
67
+ * Contains the request's resource type as it was perceived by the rendering engine.
68
+ * ResourceType will be one of the following: `document`, `stylesheet`, `image`,
69
+ * `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`,
70
+ * `websocket`, `manifest`, `other`.
71
+ * @returns resource type name
72
+ */
73
+ resourceType(): ResourceType;
74
+
75
+ /**
76
+ * Returns the matching `Response` object, or `null` if the response was not received
77
+ * due to error.
78
+ * @returns The `Response` object, or `null` if the response was not received due to error.
79
+ */
80
+ response(): Response | null;
81
+
82
+ /**
83
+ * Returns resource size information for given request.
84
+ * @returns Resource size information for given request.
85
+ */
86
+ size(): { body: number; headers: number };
87
+
88
+ /**
89
+ * Returns resource timing information for given request. Most of the timing values
90
+ * become available upon the response, `responseEnd` becomes available when request
91
+ * finishes.
92
+ * @returns Resource timing information for given request.
93
+ */
94
+ timing(): ResourceTiming;
95
+
96
+ /**
97
+ * URL of the request.
98
+ * @returns request URL
99
+ */
100
+ url(): string;
101
+ }
@@ -0,0 +1,115 @@
1
+ import { SecurityDetailsObject } from './';
2
+ import { Request } from './request';
3
+ import { Frame } from './frame';
4
+
5
+ /**
6
+ * Response class represents responses which are received by page.
7
+ */
8
+ export class Response {
9
+ /**
10
+ * An object with HTTP headers associated with the response. All header names are
11
+ * lower-case.
12
+ * @returns The headers object.
13
+ */
14
+ allHeaders(): Record<string, string>;
15
+
16
+ /**
17
+ * Returns the response body.
18
+ * @returns A buffer with response body.
19
+ */
20
+ body(): ArrayBuffer;
21
+
22
+ /**
23
+ * @returns the Frame that initiated this response
24
+ */
25
+ frame(): Frame;
26
+
27
+ /**
28
+ * An object with HTTP headers associated with the response. All header names are
29
+ * lower-case.
30
+ * @returns The headers object.
31
+ */
32
+ headers(): Record<string, string>;
33
+
34
+ /**
35
+ * An array with all the request HTTP response headers. Unlike `Response.headers()`, header
36
+ * names are not lower-cased. Headers with multiple entries, such as `Set-Cookie`,
37
+ * appear in the array multiple times.
38
+ * @returns An array of all the request HTTP headers.
39
+ */
40
+ headersArray(): Array<{ name: string; value: string }>;
41
+
42
+ /**
43
+ * Returns the value of the header matching the name. The name is case insensitive.
44
+ * If multiple headers have the same name (except `Set-Cookie`), they are returned
45
+ * as a list separated by ``,``. For `Set-Cookie`, the `\n` separator is used. If
46
+ * no headers are found, `null` is returned.
47
+ * @param name Header name to retrieve value for.
48
+ * @returns The header value for the given name.
49
+ */
50
+ headerValue(name: string): string | null;
51
+
52
+ /**
53
+ * Returns all values of the headers matching the name, for example `set-cookie`.
54
+ * The name is case insensitive.
55
+ * @param name Header name to retrieve values for.
56
+ * @returns An array of header values for the given name.
57
+ */
58
+ headerValues(name: string): string[];
59
+
60
+ /**
61
+ * Returns the JSON representation of response body. Throws if response body is not
62
+ * parsable via `JSON.parse`.
63
+ * @returns JSON representation of response body.
64
+ */
65
+ json(): any;
66
+
67
+ /**
68
+ * Contains a boolean stating whether the response was successful (status in the
69
+ * range 200-299) or not.
70
+ * @returns a boolean stating whether the response was successful
71
+ */
72
+ ok(): boolean;
73
+
74
+ /**
75
+ * The request that was used to produce the response.
76
+ * @returns the matching `Request` object
77
+ */
78
+ request(): Request;
79
+
80
+ /**
81
+ * Security details associated with this response.
82
+ * @returns A matching `SecurityDetailsObject`
83
+ */
84
+ securityDetails(): SecurityDetailsObject | null;
85
+
86
+ /**
87
+ * Returns the IP address and port of the server for this response.
88
+ * @returns The IP address and port of the server
89
+ */
90
+ serverAddr(): { ipAddress: string; port: number } | null;
91
+
92
+ /**
93
+ * Contains the status code of the response (e.g., 200 for a success).
94
+ * @returns the status code of the response
95
+ */
96
+ status(): number;
97
+
98
+ /**
99
+ * Contains the status text of the response (e.g. usually an "OK" for a success).
100
+ * @returns the status text of the response
101
+ */
102
+ statusText(): string;
103
+
104
+ /**
105
+ * The size of the response body and the headers.
106
+ * @returns The size of the response body and the headers.
107
+ */
108
+ size(): { body: number; headers: number };
109
+
110
+ /**
111
+ * Contains the URL of the response.
112
+ * @returns the URL of the response
113
+ */
114
+ url(): string;
115
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Touchscreen provides an api for interacting with a virtual touchscreen. It
3
+ * operates in main-frame CSS pixels relative to the top-left corner of the
4
+ * viewport.
5
+ */
6
+ export class Touchscreen {
7
+ /**
8
+ * Taps on the specified position (`x`,`y`), which internally dispatches a `touchstart` and `touchend` event.
9
+ * @param x The x position.
10
+ * @param y The y position.
11
+ */
12
+ tap(x: number, y: number): void;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { PageFunction } from '.';
2
+ import { JSHandle } from './js_handle';
3
+
4
+ /**
5
+ * The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
6
+ */
7
+ export class Worker {
8
+ /**
9
+ * Get the URL of the web worker.
10
+ * @return The URL of the web worker.
11
+ */
12
+ url(): string;
13
+ }
@@ -54,7 +54,7 @@ export class Client {
54
54
  del<RT extends ResponseType | undefined>(
55
55
  url: string | HttpURL,
56
56
  body?: RequestBody | null,
57
- params?: RefinedParams<RT> | null
57
+ params?: RefinedParams<RT> | null,
58
58
  ): RefinedResponse<RT>;
59
59
 
60
60
  /**
@@ -66,7 +66,7 @@ export class Client {
66
66
  */
67
67
  head<RT extends ResponseType | undefined>(
68
68
  url: string | HttpURL,
69
- params?: RefinedParams<RT> | null
69
+ params?: RefinedParams<RT> | null,
70
70
  ): RefinedResponse<RT>;
71
71
 
72
72
  /**
@@ -78,7 +78,7 @@ export class Client {
78
78
  */
79
79
  get<RT extends ResponseType | undefined>(
80
80
  url: string | HttpURL,
81
- params?: RefinedParams<RT> | null
81
+ params?: RefinedParams<RT> | null,
82
82
  ): RefinedResponse<RT>;
83
83
 
84
84
  /**
@@ -92,7 +92,7 @@ export class Client {
92
92
  options<RT extends ResponseType | undefined>(
93
93
  url: string | HttpURL,
94
94
  body?: RequestBody | null,
95
- params?: RefinedParams<RT> | null
95
+ params?: RefinedParams<RT> | null,
96
96
  ): RefinedResponse<RT>;
97
97
 
98
98
  /**
@@ -106,7 +106,7 @@ export class Client {
106
106
  patch<RT extends ResponseType | undefined>(
107
107
  url: string | HttpURL,
108
108
  body?: RequestBody | null,
109
- params?: RefinedParams<RT> | null
109
+ params?: RefinedParams<RT> | null,
110
110
  ): RefinedResponse<RT>;
111
111
 
112
112
  /**
@@ -120,7 +120,7 @@ export class Client {
120
120
  post<RT extends ResponseType | undefined>(
121
121
  url: string | HttpURL,
122
122
  body?: RequestBody | null,
123
- params?: RefinedParams<RT> | null
123
+ params?: RefinedParams<RT> | null,
124
124
  ): RefinedResponse<RT>;
125
125
 
126
126
  /**
@@ -134,7 +134,7 @@ export class Client {
134
134
  put<RT extends ResponseType | undefined>(
135
135
  url: string | HttpURL,
136
136
  body?: RequestBody | null,
137
- params?: RefinedParams<RT> | null
137
+ params?: RefinedParams<RT> | null,
138
138
  ): RefinedResponse<RT>;
139
139
 
140
140
  /**
@@ -150,7 +150,7 @@ export class Client {
150
150
  method: string,
151
151
  url: string | HttpURL,
152
152
  body?: RequestBody | null,
153
- params?: RefinedParams<RT> | null
153
+ params?: RefinedParams<RT> | null,
154
154
  ): RefinedResponse<RT>;
155
155
 
156
156
  /**
@@ -169,7 +169,7 @@ export class Client {
169
169
  method: string,
170
170
  url: string | HttpURL,
171
171
  body?: RequestBody | null,
172
- params?: RefinedParams<RT> | null
172
+ params?: RefinedParams<RT> | null,
173
173
  ): Promise<RefinedResponse<RT>>;
174
174
  }
175
175
 
@@ -202,5 +202,5 @@ export interface Options {
202
202
  * Returned value from http.url method.
203
203
  */
204
204
  export interface HttpURL {
205
- __brand: "http-url";
205
+ __brand: 'http-url';
206
206
  }
@@ -46,7 +46,7 @@ export interface SubtleCrypto {
46
46
  decrypt(
47
47
  algorithm: AesCtrParams | AesCbcParams | AesGcmParams,
48
48
  key: CryptoKey,
49
- data: ArrayBuffer | ArrayBufferView | DataView
49
+ data: ArrayBuffer | ArrayBufferView | DataView,
50
50
  ): Promise<ArrayBuffer>;
51
51
 
52
52
  /**
@@ -67,7 +67,7 @@ export interface SubtleCrypto {
67
67
  */
68
68
  digest(
69
69
  algorithm: HashAlgorithmIdentifier | Algorithm<HashAlgorithmIdentifier>,
70
- data: ArrayBuffer | ArrayBufferView | DataView
70
+ data: ArrayBuffer | ArrayBufferView | DataView,
71
71
  ): Promise<ArrayBuffer>;
72
72
 
73
73
  /**
@@ -83,7 +83,7 @@ export interface SubtleCrypto {
83
83
  encrypt(
84
84
  algorithm: AesCtrParams | AesCbcParams | AesGcmParams,
85
85
  key: CryptoKey,
86
- data: ArrayBuffer | ArrayBufferView | DataView
86
+ data: ArrayBuffer | ArrayBufferView | DataView,
87
87
  ): Promise<ArrayBuffer>;
88
88
 
89
89
  /**
@@ -99,10 +99,7 @@ export interface SubtleCrypto {
99
99
  * @throws {TypeError} - when trying to use an invalid format.
100
100
  * @returns A promise that resolves with the exported key.
101
101
  */
102
- exportKey(
103
- format: "raw",
104
- key: CryptoKey
105
- ): Promise<ArrayBuffer>;
102
+ exportKey(format: 'raw', key: CryptoKey): Promise<ArrayBuffer>;
106
103
 
107
104
  /**
108
105
  * Use the `generateKey()` method to generate a new key (for symmetric
@@ -117,7 +114,7 @@ export interface SubtleCrypto {
117
114
  generateKey(
118
115
  algorithm: AesKeyGenParams | HmacKeyGenParams,
119
116
  extractable: boolean,
120
- keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify">
117
+ keyUsages: Array<'encrypt' | 'decrypt' | 'sign' | 'verify'>,
121
118
  ): Promise<CryptoKey>;
122
119
 
123
120
  /**
@@ -135,11 +132,11 @@ export interface SubtleCrypto {
135
132
  * @returns A promise that resolves with the imported `CryptoKey`.
136
133
  */
137
134
  importKey(
138
- format: "raw",
135
+ format: 'raw',
139
136
  keyData: ArrayBuffer | ArrayBufferView | DataView,
140
- algorithm: "AES-CBC" | "AES-CTR" | "AES-GCM" | Algorithm<"AES-CBC" | "AES-CTR" | "AES-GCM"> | HmacImportParams,
137
+ algorithm: 'AES-CBC' | 'AES-CTR' | 'AES-GCM' | Algorithm<'AES-CBC' | 'AES-CTR' | 'AES-GCM'> | HmacImportParams,
141
138
  extractable: boolean,
142
- keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify">
139
+ keyUsages: Array<'encrypt' | 'decrypt' | 'sign' | 'verify'>,
143
140
  ): Promise<CryptoKey>;
144
141
 
145
142
  /**
@@ -155,9 +152,9 @@ export interface SubtleCrypto {
155
152
  * @returns A promise that resolves with the signature.
156
153
  */
157
154
  sign(
158
- algorithm: "HMAC" | Algorithm<"HMAC">,
155
+ algorithm: 'HMAC' | Algorithm<'HMAC'>,
159
156
  key: CryptoKey,
160
- data: ArrayBuffer | ArrayBufferView | DataView
157
+ data: ArrayBuffer | ArrayBufferView | DataView,
161
158
  ): Promise<ArrayBuffer>;
162
159
 
163
160
  /**
@@ -171,10 +168,10 @@ export interface SubtleCrypto {
171
168
  * @returns A promise that resolves with a boolean indicating whether the signature is valid.
172
169
  */
173
170
  verify(
174
- algorithm: "HMAC" | Algorithm<"HMAC">,
171
+ algorithm: 'HMAC' | Algorithm<'HMAC'>,
175
172
  key: CryptoKey,
176
173
  signature: ArrayBuffer | ArrayBufferView | DataView,
177
- data: ArrayBuffer | ArrayBufferView | DataView
174
+ data: ArrayBuffer | ArrayBufferView | DataView,
178
175
  ): Promise<boolean>;
179
176
  }
180
177
 
@@ -182,7 +179,7 @@ export interface CryptoKey {
182
179
  /**
183
180
  * The type of key the object represents.
184
181
  */
185
- readonly type: "secret" | "private" | "public";
182
+ readonly type: 'secret' | 'private' | 'public';
186
183
 
187
184
  /**
188
185
  * A boolean value indicating whether or not the
@@ -200,7 +197,7 @@ export interface CryptoKey {
200
197
  /**
201
198
  * An array of strings, indicating what can be done with the key.
202
199
  */
203
- readonly usages: Array<"encrypt" | "decrypt" | "sign" | "verify">;
200
+ readonly usages: Array<'encrypt' | 'decrypt' | 'sign' | 'verify'>;
204
201
  }
205
202
 
206
203
  /**
@@ -225,7 +222,7 @@ export type AlgorithmIdentifier = string;
225
222
  * The `HashAlgorithmIdentifier` type of the Web Crypto API represents
226
223
  * the name of a hash algorithm.
227
224
  */
228
- export type HashAlgorithmIdentifier = "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
225
+ export type HashAlgorithmIdentifier = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
229
226
 
230
227
  /**
231
228
  * The `AesKeyGenParams` dictionary of the Web Crypto API represents the
@@ -236,7 +233,7 @@ export interface AesKeyGenParams extends Algorithm<AlgorithmIdentifier> {
236
233
  /**
237
234
  * The name of the algorithm to use.
238
235
  */
239
- name: "AES-GCM" | "AES-CBC" | "AES-CTR" | "AES-CFB" | "AES-KW";
236
+ name: 'AES-GCM' | 'AES-CBC' | 'AES-CTR' | 'AES-CFB' | 'AES-KW';
240
237
 
241
238
  /**
242
239
  * The length of the key, in bits.
@@ -254,7 +251,7 @@ export interface AesCtrParams extends Algorithm<AlgorithmIdentifier> {
254
251
  /**
255
252
  * The name of the algorithm to use.
256
253
  */
257
- name: "AES-CTR";
254
+ name: 'AES-CTR';
258
255
 
259
256
  /**
260
257
  * The initial value of the counter block. This must be 16-byte
@@ -283,7 +280,7 @@ export interface AesCbcParams extends Algorithm<AlgorithmIdentifier> {
283
280
  /**
284
281
  * The name of the algorithm to use.
285
282
  */
286
- name: "AES-CBC";
283
+ name: 'AES-CBC';
287
284
 
288
285
  /**
289
286
  * The initialization vector to use for the operation.
@@ -304,7 +301,7 @@ export interface AesGcmParams extends Algorithm<AlgorithmIdentifier> {
304
301
  /**
305
302
  * The name of the algorithm to use.
306
303
  */
307
- name: "AES-GCM";
304
+ name: 'AES-GCM';
308
305
 
309
306
  /**
310
307
  * The initialization vector to use for the operation.
@@ -341,12 +338,12 @@ export interface HmacKeyGenParams extends Algorithm<AlgorithmIdentifier> {
341
338
  /**
342
339
  * The name of the algorithm to use.
343
340
  */
344
- name: "HMAC";
341
+ name: 'HMAC';
345
342
 
346
343
  /**
347
344
  * A string representing the name of the digest function to use.
348
345
  */
349
- hash: "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
346
+ hash: 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
350
347
 
351
348
  /**
352
349
  * The length of the key, in bits. If the length is not specified,
@@ -366,7 +363,7 @@ export interface HmacImportParams extends Algorithm<AlgorithmIdentifier> {
366
363
  /**
367
364
  * The name of the algorithm to use.
368
365
  */
369
- name: "HMAC";
366
+ name: 'HMAC';
370
367
 
371
368
  /**
372
369
  * The name of the digest function to use.
@@ -176,11 +176,11 @@ export enum ReadyState {
176
176
  * BinaryType describes the possible types of binary data that can be
177
177
  * transmitted over a Websocket connection.
178
178
  */
179
- export enum BinaryType {
179
+ export enum BinaryType {
180
180
  /**
181
181
  * Binary data is returned in ArrayBuffer form. k6 supports only this type.
182
182
  */
183
- ArrayBuffer = 'ArrayBuffer'
183
+ ArrayBuffer = 'ArrayBuffer',
184
184
  }
185
185
 
186
186
  /**
@@ -296,10 +296,10 @@ export interface ErrorEvent {
296
296
  /**
297
297
  * CompressionAlgorithm describes the possible compression algorithms.
298
298
  */
299
- export enum CompressionAlgorithm {
299
+ export enum CompressionAlgorithm {
300
300
  /**
301
301
  * Deflate compression algorithm.
302
302
  * k6 supports only this compression algorithm.
303
303
  */
304
- Deflate = 'deflate'
304
+ Deflate = 'deflate',
305
305
  }