@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/index.d.ts CHANGED
@@ -17,28 +17,7 @@
17
17
  * @packageDocumentation
18
18
  */
19
19
 
20
- import "./global"; // Type global environment
21
-
22
- // Expose everything to autoimport
23
- import "./browser";
24
- import "./crypto";
25
- import "./data";
26
- import "./encoding";
27
- import "./execution";
28
- import "./html";
29
- import "./http";
30
- import "./metrics";
31
- import "./options";
32
- import "./experimental/browser";
33
- import "./experimental/fs";
34
- import "./experimental/redis";
35
- import "./experimental/timers";
36
- import "./experimental/tracing";
37
- import "./experimental/webcrypto";
38
- import "./experimental/websockets";
39
- import "./timers";
40
- import "./ws";
41
- import "./net/grpc";
20
+ import "./global.js"; // Type global environment
42
21
 
43
22
  // === Main ===
44
23
  // ------------
@@ -143,3 +122,5 @@ export interface JSONArray extends Array<JSONValue> {}
143
122
  export interface JSONObject {
144
123
  [key: string]: JSONValue;
145
124
  }
125
+
126
+ export * as default from "k6";
k6/net/grpc/index.d.ts ADDED
@@ -0,0 +1,196 @@
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
+ /**
21
+ * If `true` will connect to the gRPC server using plaintext i.e. insecure.
22
+ */
23
+ plaintext?: boolean;
24
+
25
+ /**
26
+ * If `true` connection will try to use the gRPC server reflection protocol.
27
+ * https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
28
+ */
29
+ reflect?: boolean;
30
+
31
+ /**
32
+ * Metadata to send with reflection request.
33
+ */
34
+ reflectMetadata?: object;
35
+
36
+ /**
37
+ * Connection timeout to use.
38
+ */
39
+ timeout?: string | number;
40
+
41
+ /**
42
+ * Maximum message size in bytes the client can receive.
43
+ */
44
+ maxReceiveSize?: number;
45
+
46
+ /**
47
+ * Maximum message size in bytes the client can send.
48
+ */
49
+ maxSendSize?: number;
50
+
51
+ /**
52
+ * TLS settings of the connection.
53
+ */
54
+ tls?: TLSParams;
55
+ }
56
+
57
+ export interface TLSParams {
58
+ /**
59
+ * PEM formatted client certificate.
60
+ */
61
+ cert: string;
62
+
63
+ /**
64
+ * PEM formatted client private key.
65
+ */
66
+ key: string;
67
+
68
+ /**
69
+ * Password for decrypting the client's private key.
70
+ */
71
+ password?: string;
72
+
73
+ /**
74
+ * PEM formatted string/strings of the certificate authorities.
75
+ */
76
+ cacerts?: string | string[];
77
+ }
78
+
79
+ export interface Params {
80
+ /**
81
+ * @deprecated Use metadata instead.
82
+ */
83
+ headers?: object;
84
+
85
+ metadata?: object;
86
+
87
+ tags?: object;
88
+
89
+ timeout?: string | number;
90
+ }
91
+
92
+ export interface GrpcError {
93
+ code: number;
94
+ details: string[] | object[];
95
+ message: string;
96
+ }
97
+
98
+ /**
99
+ * gRPC client to interact with a gRPC server.
100
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-net-grpc/client/
101
+ */
102
+ export class Client {
103
+ protected __brand: never;
104
+
105
+ constructor();
106
+
107
+ /** Opens a connection to a gRPC server. */
108
+ connect(address: string, params?: ConnectParams): void;
109
+
110
+ /** Loads and parses the protocol buffer descriptors. */
111
+ load(importPaths: string[], ...protoFiles: string[]): void;
112
+
113
+ /** Loads a protoset and parses the protocol buffer descriptors */
114
+ loadProtoset(protosetPath: string): void;
115
+
116
+ /** Invokes an unary RPC request. */
117
+ invoke(url: string, request: object, params?: Params): Response;
118
+
119
+ /** Asynchronously invokes an unary RPC request. */
120
+ asyncInvoke(url: string, request: object, params?: Params): Promise<Response>;
121
+
122
+ /** Close the connection. */
123
+ close(): void;
124
+ }
125
+
126
+ /**
127
+ * StreamEvent describes the possible events that can be emitted
128
+ * by a gRPC stream.
129
+ */
130
+ export type StreamEvent =
131
+ /**
132
+ * Event fired when data has been received from the server.
133
+ */
134
+ | "data"
135
+ /**
136
+ * Event fired when a stream has been closed due to an error.
137
+ */
138
+ | "error"
139
+ /**
140
+ * Event fired when the stream closes.
141
+ */
142
+ | "end";
143
+
144
+ /**
145
+ * Stream allows you to use streaming RPCs.
146
+ */
147
+ export class Stream {
148
+ /**
149
+ * The gRPC stream constructor, representing a single gRPC stream.
150
+ *
151
+ * @param client - the gRPC client to use, it must be connected.
152
+ * @param url - the RPC method to call.
153
+ * @param params - the parameters to use for the RPC call.
154
+ */
155
+ constructor(client: Client, url: string, params?: Params);
156
+
157
+ /**
158
+ * Set up handler functions for various events on the gRPC stream.
159
+ *
160
+ * @param event - the event to listen for
161
+ * @param listener - the callback to invoke when the event is emitted
162
+ */
163
+ on(event: StreamEvent, listener: (data: object | GrpcError | undefined) => void): void;
164
+
165
+ /**
166
+ * Writes a request to the stream.
167
+ *
168
+ * @param request - the request (message) to send to the server
169
+ */
170
+ write(request: object): void;
171
+
172
+ /**
173
+ * Signals to the server that the client has finished sending messages.
174
+ */
175
+ end(): void;
176
+ }
177
+
178
+ export const StatusOK: number;
179
+ export const StatusCanceled: number;
180
+ export const StatusUnknown: number;
181
+ export const StatusInvalidArgument: number;
182
+ export const StatusDeadlineExceeded: number;
183
+ export const StatusNotFound: number;
184
+ export const StatusAlreadyExists: number;
185
+ export const StatusPermissionDenied: number;
186
+ export const StatusResourceExhausted: number;
187
+ export const StatusFailedPrecondition: number;
188
+ export const StatusAborted: number;
189
+ export const StatusOutOfRange: number;
190
+ export const StatusUnimplemented: number;
191
+ export const StatusInternal: number;
192
+ export const StatusUnavailable: number;
193
+ export const StatusDataLoss: number;
194
+ export const StatusUnauthenticated: number;
195
+
196
+ export * as default from "k6/net/grpc";
@@ -3,7 +3,7 @@
3
3
  * https://grafana.com/docs/k6/latest/using-k6/k6-options/
4
4
  */
5
5
 
6
- import { CipherSuite } from "./http";
6
+ import { CipherSuite } from "k6/http";
7
7
 
8
8
  /**
9
9
  * Program options.
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "0.53.1",
3
+ "version": "0.53.2",
4
4
  "description": "TypeScript definitions for k6",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
6
6
  "license": "MIT",
@@ -51,6 +51,7 @@
51
51
  "url": "https://github.com/joanlopez"
52
52
  }
53
53
  ],
54
+ "type": "module",
54
55
  "main": "",
55
56
  "types": "index.d.ts",
56
57
  "repository": {
@@ -60,6 +61,6 @@
60
61
  },
61
62
  "scripts": {},
62
63
  "dependencies": {},
63
- "typesPublisherContentHash": "51f2f592838cc27d3b1784aa8140db6d7c0e256577c0d8f960419afa871ee531",
64
+ "typesPublisherContentHash": "157d18815426920cc271f8668e306138a0c10336ba1266c5cacd6af2b8bff05b",
64
65
  "typeScriptVersion": "4.8"
65
66
  }
@@ -1,4 +1,4 @@
1
- import { CookieJar } from "./http";
1
+ import { CookieJar } from "k6/http";
2
2
 
3
3
  /**
4
4
  * Open WebSocket connection.
@@ -280,43 +280,4 @@ export abstract class WebSocketError {
280
280
  error(): string;
281
281
  }
282
282
 
283
- /**
284
- * This module provides a WebSocket client implementing the WebSocket protocol.
285
- * https://grafana.com/docs/k6/latest/javascript-api/k6-ws/
286
- */
287
- declare namespace ws {
288
- /**
289
- * Open WebSocket connection.
290
- * https://grafana.com/docs/k6/latest/javascript-api/k6-ws/connect/
291
- * @param url - Request URL.
292
- * @param callback - Logic to execute with socket.
293
- * @returns HTTP response to connection request.
294
- * @example
295
- * let res = ws.connect(url, function(socket) {
296
- * socket.on('open', function() {
297
- * console.log('WebSocket connection established!');
298
- * socket.close();
299
- * });
300
- * });
301
- */
302
- function connect(url: string, callback: Executor): Response;
303
-
304
- /**
305
- * Open WebSocket connection.
306
- * https://grafana.com/docs/k6/latest/javascript-api/k6-ws/connect/
307
- * @param url - Request URL.
308
- * @param params - Request parameters.
309
- * @param callback - Logic to execute with socket.
310
- * @returns HTTP response to connection request.
311
- * @example
312
- * let res = ws.connect(url, { param1: true } , function(socket) {
313
- * socket.on('open', function() {
314
- * console.log('WebSocket connection established!');
315
- * socket.close();
316
- * });
317
- * });
318
- */
319
- function connect(url: string, params: Params | null, callback: Executor): Response;
320
- }
321
-
322
- export default ws;
283
+ export * as default from "k6/ws";
k6/encoding.d.ts DELETED
@@ -1,90 +0,0 @@
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
- /**
47
- * The encoding module provides base64 encoding/decoding.
48
- * https://grafana.com/docs/k6/latest/javascript-api/k6-encoding/
49
- */
50
- declare namespace encoding {
51
- /**
52
- * Base64 decode a string.
53
- * https://grafana.com/docs/k6/latest/javascript-api/k6-encoding/b64decode/
54
- * @param input - The string to base64 decode.
55
- * @param encoding - Base64 variant.
56
- * @returns The base64 decoded version of the input string in either string or ArrayBuffer format, depending on the `format` parameter.
57
- * @example
58
- * encoding.b64decode(str)
59
- * encoding.b64decode(str, 'rawstd')
60
- * const decBuffer = encoding.b64decode(str, 'rawurl')
61
- * let decBin = new Uint8Array(decBuffer);
62
- */
63
- function b64decode(input: string, encoding?: Base64Variant): ArrayBuffer;
64
- /**
65
- * Base64 decode a string.
66
- * https://grafana.com/docs/k6/latest/javascript-api/k6-encoding/b64decode/
67
- * @param input - The string to base64 decode.
68
- * @param encoding - Base64 variant.
69
- * @param format - If 's' return the data as a string, otherwise an ArrayBuffer object .
70
- * @returns The base64 decoded version of the input string in either string or ArrayBuffer format, depending on the `format` parameter.
71
- * @example
72
- * encoding.b64decode(str)
73
- * encoding.b64decode(str, 'rawstd')
74
- * const decodedString = encoding.b64decode(str, 'rawurl', 's')
75
- */
76
- function b64decode(input: string, encoding: Base64Variant, format: "s"): string;
77
- /**
78
- * Base64 decode a string.
79
- * https://grafana.com/docs/k6/latest/javascript-api/k6-encoding/b64decode/
80
- * @param input - Base64 encoded string or ArrayBuffer object.
81
- * @param encoding - Base64 variant.
82
- * @returns Decoded string.
83
- * @example
84
- * encoding.b64encode(str)
85
- * encoding.b64encode(str, 'rawstd')
86
- */
87
- function b64encode(input: string | ArrayBuffer, encoding?: Base64Variant): string;
88
- }
89
-
90
- export default encoding;
k6/execution.d.ts DELETED
@@ -1,121 +0,0 @@
1
- import { Options } from "./options";
2
-
3
- /*
4
- * The execution module provides information about the current test execution state.
5
- * https://grafana.com/docs/k6/latest/javascript-api/k6-execution/
6
- */
7
- declare namespace execution {
8
- /**
9
- * Information about the current scenario.
10
- */
11
- const scenario: {
12
- /**
13
- * The assigned name of the running scenario.
14
- */
15
- name: string;
16
- /**
17
- * The name of the running Executor type.
18
- */
19
- executor: string;
20
- /**
21
- * The Unix timestamp in milliseconds when the scenario started.
22
- */
23
- startTime: number;
24
- /**
25
- * Percentage in a 0 to 1 interval of the scenario progress.
26
- */
27
- progress: number;
28
- /**
29
- * The unique and zero-based sequential number of the current iteration in the scenario, across the current instance.
30
- */
31
- iterationInInstance: number;
32
- /**
33
- * The unique and zero-based sequential number of the current iteration in the scenario.
34
- */
35
- iterationInTest: number;
36
- };
37
-
38
- /**
39
- * Information about the current load generator instance.
40
- */
41
- const instance: {
42
- /**
43
- * The number of prematurely interrupted iterations in the current instance.
44
- */
45
- iterationsInterrupted: number;
46
- /**
47
- * The number of completed iterations in the current instance.
48
- */
49
- iterationsCompleted: number;
50
- /**
51
- * The number of active VUs.
52
- */
53
- vusActive: number;
54
- /**
55
- * The number of currently initialized VUs.
56
- */
57
- vusInitialized: number;
58
- /**
59
- * The time passed from the start of the current test run in milliseconds.
60
- */
61
- currentTestRunDuration: number;
62
- };
63
-
64
- /**
65
- * Control the test execution.
66
- */
67
- const test: {
68
- /**
69
- * Aborts the test run with the exit code 108.
70
- * https://grafana.com/docs/k6/latest/javascript-api/k6-execution/#test
71
- * @param input - Aborted message.
72
- * @example
73
- * import exec from "k6/execution";
74
- * exec.test.abort();
75
- * exec.test.abort('this is the reason');
76
- */
77
- abort(input?: string): void;
78
-
79
- options: Options;
80
- };
81
-
82
- /**
83
- * Information about the current virtual user.
84
- */
85
- const vu: {
86
- /**
87
- * The identifier of the iteration in the current instance.
88
- */
89
- iterationInInstance: number;
90
- /**
91
- * The identifier of the iteration in the current scenario.
92
- */
93
- iterationInScenario: number;
94
- /**
95
- * The identifier of the VU across the instance.
96
- */
97
- idInInstance: number;
98
- /**
99
- * The globally unique (across the whole test run) identifier of the VU.
100
- */
101
- idInTest: number;
102
-
103
- /**
104
- * Map to set or get VU tags.
105
- * @deprecated should use `metrics.tags` instead of just `tags`
106
- */
107
- tags: Record<string, number | string | boolean>;
108
- metrics: {
109
- /**
110
- * Map to set or get VU tags.
111
- */
112
- tags: Record<string, number | string | boolean>;
113
- /**
114
- * Map to set or get VU metadata.
115
- */
116
- metadata: Record<string, number | string | boolean>;
117
- };
118
- };
119
- }
120
-
121
- export default execution;