@types/k6 0.44.2 → 0.45.0

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.
@@ -1,101 +1,101 @@
1
- import { ResourceType, ResourceTiming } from "./";
2
- import { Response } from "./response";
3
- import { Frame } from "./frame";
1
+ import { ResourceType, ResourceTiming } from './';
2
+ import { Response } from './response';
3
+ import { Frame } from './frame';
4
4
 
5
5
  /**
6
6
  * Request class represents requests which are sent by a page.
7
7
  */
8
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>;
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
15
 
16
- /**
17
- * @returns the Frame that initiated this request
18
- */
19
- frame(): Frame;
16
+ /**
17
+ * @returns the Frame that initiated this request
18
+ */
19
+ frame(): Frame;
20
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>;
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
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 }>;
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
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;
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
42
 
43
- /**
44
- * @returns a boolean stating whether the request is for a navigation
45
- */
46
- isNavigationRequest(): boolean;
43
+ /**
44
+ * @returns a boolean stating whether the request is for a navigation
45
+ */
46
+ isNavigationRequest(): boolean;
47
47
 
48
- /**
49
- * Request's method (GET, POST, etc.)
50
- * @returns request's method name
51
- */
52
- method(): string;
48
+ /**
49
+ * Request's method (GET, POST, etc.)
50
+ * @returns request's method name
51
+ */
52
+ method(): string;
53
53
 
54
- /**
55
- * Contains the request's post body, if any.
56
- * @returns request's post body
57
- */
58
- postData(): string;
54
+ /**
55
+ * Contains the request's post body, if any.
56
+ * @returns request's post body
57
+ */
58
+ postData(): string;
59
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;
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
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;
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
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;
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
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 };
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
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;
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
95
 
96
- /**
97
- * URL of the request.
98
- * @returns request URL
99
- */
100
- url(): string;
96
+ /**
97
+ * URL of the request.
98
+ * @returns request URL
99
+ */
100
+ url(): string;
101
101
  }
@@ -1,115 +1,115 @@
1
1
  import { SecurityDetailsObject } from './';
2
- import { Request } from "./request";
3
- import { Frame } from "./frame";
2
+ import { Request } from './request';
3
+ import { Frame } from './frame';
4
4
 
5
5
  /**
6
6
  * Response class represents responses which are received by page.
7
7
  */
8
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;
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
115
  }
@@ -4,10 +4,10 @@
4
4
  * viewport.
5
5
  */
6
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;
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
13
  }
@@ -1,13 +1,13 @@
1
- import { PageFunction } from ".";
2
- import { JSHandle } from "./js_handle";
1
+ import { PageFunction } from '.';
2
+ import { JSHandle } from './js_handle';
3
3
 
4
4
  /**
5
5
  * The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
6
6
  */
7
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;
8
+ /**
9
+ * Get the URL of the web worker.
10
+ * @return The URL of the web worker.
11
+ */
12
+ url(): string;
13
13
  }
@@ -0,0 +1,154 @@
1
+ // === Response ===
2
+ // ----------------
3
+
4
+ /**
5
+ * gRPC response.
6
+ */
7
+ export interface Response {
8
+ status: number;
9
+
10
+ message: object;
11
+
12
+ headers: object;
13
+
14
+ trailers: object;
15
+
16
+ error: object;
17
+ }
18
+
19
+ export interface ConnectParams {
20
+ plaintext?: boolean;
21
+
22
+ reflect?: boolean;
23
+
24
+ timeout?: string | number;
25
+
26
+ maxReceiveSize?: number;
27
+
28
+ maxSendSize?: number;
29
+ }
30
+
31
+ export interface Params {
32
+ /**
33
+ * @deprecated Use metadata instead.
34
+ */
35
+ headers?: object;
36
+
37
+ metadata?: object;
38
+
39
+ tags?: object;
40
+
41
+ timeout?: string | number;
42
+ }
43
+
44
+ export interface GrpcError {
45
+ code: number;
46
+ details: string[] | object[];
47
+ message: string;
48
+ }
49
+
50
+ /**
51
+ * This module provides classes for Remote Procedure Calls over HTTP/2.
52
+ * https://k6.io/docs/javascript-api/k6-experimental/grpc/
53
+ */
54
+ declare namespace grpc {
55
+ /**
56
+ * gRPC client to interact with a gRPC server.
57
+ * https://k6.io/docs/javascript-api/k6-experimental/grpc/client/
58
+ */
59
+ class Client {
60
+ protected __brand: never;
61
+
62
+ constructor();
63
+
64
+ /** Opens a connection to a gRPC server. */
65
+ connect(address: string, params?: ConnectParams): void;
66
+
67
+ /** Loads and parses the protocol buffer descriptors. */
68
+ load(importPaths: string[], ...protoFiles: string[]): void;
69
+
70
+ /** Loads a protoset and parses the protocol buffer descriptors */
71
+ loadProtoset(protosetPath: string): void;
72
+
73
+ /** Invokes an unary RPC request. */
74
+ invoke(url: string, request: object, params?: Params): Response;
75
+
76
+ /** Close the connection. */
77
+ close(): void;
78
+ }
79
+
80
+ /**
81
+ * StreamEvent describes the possible events that can be emitted
82
+ * by a gRPC stream.
83
+ */
84
+ enum StreamEvent {
85
+ /**
86
+ * Event fired when data has been received from the server.
87
+ */
88
+ Data = 'data',
89
+
90
+ /**
91
+ * Event fired when a stream has been closed due to an error.
92
+ */
93
+ Error = 'error',
94
+
95
+ /**
96
+ * Event fired when the stream closes.
97
+ */
98
+ End = 'end',
99
+ }
100
+
101
+ /**
102
+ * Stream allows you to use streaming RPCs.
103
+ */
104
+ class Stream {
105
+ /**
106
+ * The gRPC stream constructor, representing a single gRPC stream.
107
+ *
108
+ * @param client - the gRPC client to use, it must be connected.
109
+ * @param url - the RPC method to call.
110
+ * @param params - the parameters to use for the RPC call.
111
+ */
112
+ constructor(client: Client, url: string, params?: Params);
113
+
114
+ /**
115
+ * Set up handler functions for various events on the gRPC stream.
116
+ *
117
+ * @param event - the event to listen for
118
+ * @param listener - the callback to invoke when the event is emitted
119
+ */
120
+ on(event: StreamEvent, listener: (data: object | GrpcError | undefined) => void): void;
121
+
122
+ /**
123
+ * Writes a request to the stream.
124
+ *
125
+ * @param request - the request (message) to send to the server
126
+ */
127
+ write(request: object): void;
128
+
129
+ /**
130
+ * Signals to the server that the client has finished sending messages.
131
+ */
132
+ end(): void;
133
+ }
134
+
135
+ const StatusOK: number;
136
+ const StatusCanceled: number;
137
+ const StatusUnknown: number;
138
+ const StatusInvalidArgument: number;
139
+ const StatusDeadlineExceeded: number;
140
+ const StatusNotFound: number;
141
+ const StatusAlreadyExists: number;
142
+ const StatusPermissionDenied: number;
143
+ const StatusResourceExhausted: number;
144
+ const StatusFailedPrecondition: number;
145
+ const StatusAborted: number;
146
+ const StatusOutOfRange: number;
147
+ const StatusUnimplemented: number;
148
+ const StatusInternal: number;
149
+ const StatusUnavailable: number;
150
+ const StatusDataLoss: number;
151
+ const StatusUnauthenticated: number;
152
+ }
153
+
154
+ export default grpc;