@types/k6 0.54.0 → 0.54.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 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: Mon, 30 Sep 2024 10:08:47 GMT
11
+ * Last updated: Thu, 14 Nov 2024 14:35:31 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
k6/browser/index.d.ts CHANGED
@@ -393,19 +393,17 @@ export interface ScreenshotOptions {
393
393
  * - `mutation` - use a mutation observer
394
394
  * - `interval` - use a polling interval
395
395
  */
396
- export type PollingMethod = "raf" | "mutation" | "interval";
396
+ export type PollingMethod = number | "raf" | "mutation";
397
397
 
398
398
  export interface PollingOptions {
399
399
  /**
400
- * Polling method to use.
401
- * @default 'raf'
400
+ * If `polling` is `'raf'`, then `pageFunction` is constantly executed in
401
+ * `requestAnimationFrame` callback. If the `polling` is `'mutation'` it
402
+ * will be called when a change is made to the DOM tree. If `polling` is
403
+ * a number, then it is treated as an interval in milliseconds at which
404
+ * the function would be executed. Defaults to `raf`.
402
405
  */
403
- polling?: "raf" | "mutation" | "interval";
404
-
405
- /**
406
- * Polling interval in milliseconds if `polling` is set to `interval`.
407
- */
408
- interval?: number;
406
+ polling?: PollingMethod;
409
407
  }
410
408
 
411
409
  export interface ElementStateFilter {
@@ -938,6 +936,65 @@ export interface ConsoleMessage {
938
936
  type(): string;
939
937
  }
940
938
 
939
+ /**
940
+ * {@link MetricMessage} objects are dispatched by page via the
941
+ * `page.on('metric')` event. For each metric that it measured and emitted for
942
+ * the page, k6 browser delivers it to the registered handlers.
943
+ *
944
+ * ```js
945
+ * // Listen for all metric messages in the page and call its tag method to
946
+ * // tag matching URLs with the new tag name.
947
+ * page.on('metric', (metric) => {
948
+ * metric.tag({
949
+ * name: 'test',
950
+ * matches: [
951
+ * {url: /^https:\/\/test\.k6\.io\/\?q=[0-9a-z]+$/, method: 'GET'},
952
+ * ]
953
+ * });
954
+ * });
955
+ * ```
956
+ */
957
+ export interface MetricMessage {
958
+ /**
959
+ * tag will match the given `tagMatch.matches` with the current metric's URL
960
+ * and name tags. When a match is found it will use `tagMatch.name` to replace
961
+ * the existing URL and name tag values.
962
+ *
963
+ * Doing this helps group metrics with different URL and name tags that, in
964
+ * fact, reference the same resource, allowing for correlation over time and
965
+ * reducing the cardinality of the metrics.
966
+ * @param tagMatch
967
+ */
968
+ tag(tagMatch: {
969
+ /**
970
+ * The name value that replaces the current metric's URL and name
971
+ * tag values, if a match is found. Required, and must not be an
972
+ * empty string.
973
+ */
974
+ name: string;
975
+
976
+ /**
977
+ * An array of objects containing the matchers which will be used
978
+ * to match against the current metric's URL and name tags.
979
+ * Required.
980
+ */
981
+ matches: {
982
+ /**
983
+ * The regular expression used to find matches in the current
984
+ * metric's URL and name tags. Required.
985
+ */
986
+ url: RegExp;
987
+
988
+ /**
989
+ * Used to match the metric's method tag. It's optional, and when
990
+ * it's not set it will group all metrics regardless of the method
991
+ * tag.
992
+ */
993
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD" | "TRACE" | "CONNECT";
994
+ }[];
995
+ }): void;
996
+ }
997
+
941
998
  /**
942
999
  * {@link Cookie} represents a cookie in a {@link BrowserContext}.
943
1000
  *
@@ -2954,6 +3011,31 @@ export interface Page {
2954
3011
  */
2955
3012
  on(event: "console", listener: (consoleMessage: ConsoleMessage) => void): void;
2956
3013
 
3014
+ /**
3015
+ * page.on('metric') will register a background handler that will listen out
3016
+ * for metrics that are measured and emitted for the page.
3017
+ *
3018
+ * When a {@link MetricMessage} is received by the handler, it can be used to
3019
+ * group different metrics tagged with URL and name so that a correlation can
3020
+ * be found and to reduce the cardinality of the metrics.
3021
+ *
3022
+ * **Usage**
3023
+ *
3024
+ * ```js
3025
+ * // Listen for all metric messages in the page and call its tag method to
3026
+ * // tag matching URLs with the new tag name.
3027
+ * page.on('metric', (metric) => {
3028
+ * metric.tag({
3029
+ * name: 'test',
3030
+ * matches: [
3031
+ * {url: /^https:\/\/test\.k6\.io\/\?q=[0-9a-z]+$/, method: 'GET'},
3032
+ * ]
3033
+ * });
3034
+ * });
3035
+ * ```
3036
+ */
3037
+ on(event: "metric", listener: (metricMessage: MetricMessage) => void): void;
3038
+
2957
3039
  /**
2958
3040
  * Returns the page that opened the current page. The first page that is
2959
3041
  * navigated to will have a null opener.
@@ -3552,11 +3634,12 @@ export interface Page {
3552
3634
  options?: {
3553
3635
  /**
3554
3636
  * If `polling` is `'raf'`, then `pageFunction` is constantly executed in
3555
- * `requestAnimationFrame` callback. If `polling` is a number, then it is
3556
- * treated as an interval in milliseconds at which the function would be
3557
- * executed. Defaults to `raf`.
3637
+ * `requestAnimationFrame` callback. If the `polling` is `'mutation'` it
3638
+ * will be called when a change is made to the DOM tree. If `polling` is
3639
+ * a number, then it is treated as an interval in milliseconds at which
3640
+ * the function would be executed. Defaults to `raf`.
3558
3641
  */
3559
- polling?: number | "raf";
3642
+ polling?: PollingMethod;
3560
3643
 
3561
3644
  /**
3562
3645
  * Maximum time in milliseconds. Defaults to `30` seconds. Default is
@@ -43,7 +43,7 @@ export interface SubtleCrypto {
43
43
  * @returns A promise that resolves with the decrypted data (also known as "plaintext").
44
44
  */
45
45
  decrypt(
46
- algorithm: AesCtrParams | AesCbcParams | AesGcmParams,
46
+ algorithm: AesCtrParams | AesCbcParams | AesGcmParams | RsaOaepParams,
47
47
  key: CryptoKey,
48
48
  data: ArrayBuffer | ArrayBufferView | DataView,
49
49
  ): Promise<ArrayBuffer>;
@@ -80,7 +80,7 @@ export interface SubtleCrypto {
80
80
  * @returns A promise that resolves with the encrypted data (also known as "ciphertext").
81
81
  */
82
82
  encrypt(
83
- algorithm: AesCtrParams | AesCbcParams | AesGcmParams,
83
+ algorithm: AesCtrParams | AesCbcParams | AesGcmParams | RsaOaepParams,
84
84
  key: CryptoKey,
85
85
  data: ArrayBuffer | ArrayBufferView | DataView,
86
86
  ): Promise<ArrayBuffer>;
@@ -122,12 +122,12 @@ export interface SubtleCrypto {
122
122
  * @param extractable indicates whether it will be possible to export the key using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey`.
123
123
  * @param keyUsages indicates what can be done with the newly generated key.
124
124
  * @throws {SyntaxError} - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
125
- * @returns A promise that resolves with the newly generated CryptoKeyPair`.
125
+ * @returns A promise that resolves with the newly generated `CryptoKeyPair`.
126
126
  */
127
127
  generateKey(
128
- algorithm: EcKeyGenParams,
128
+ algorithm: EcKeyGenParams | RSAHashedKeyGenParams,
129
129
  extractable: boolean,
130
- keyUsages: Array<"sign" | "verify" | "deriveKey" | "deriveBits">,
130
+ keyUsages: Array<"sign" | "verify" | "deriveKey" | "deriveBits" | "encrypt" | "decrypt">,
131
131
  ): Promise<CryptoKeyPair>;
132
132
 
133
133
  /**
@@ -153,7 +153,8 @@ export interface SubtleCrypto {
153
153
  | "AES-GCM"
154
154
  | Algorithm<"AES-CBC" | "AES-CTR" | "AES-GCM">
155
155
  | HmacImportParams
156
- | EcKeyImportParams,
156
+ | EcKeyImportParams
157
+ | RsaHashedImportParams,
157
158
  extractable: boolean,
158
159
  keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify" | "deriveKey" | "deriveBits">,
159
160
  ): Promise<CryptoKey>;
@@ -171,7 +172,7 @@ export interface SubtleCrypto {
171
172
  * @returns A promise that resolves with the signature.
172
173
  */
173
174
  sign(
174
- algorithm: "HMAC" | Algorithm<"HMAC"> | EcdsaParams,
175
+ algorithm: "HMAC" | Algorithm<"HMAC"> | EcdsaParams | RsaPssParams,
175
176
  key: CryptoKey,
176
177
  data: ArrayBuffer | ArrayBufferView | DataView,
177
178
  ): Promise<ArrayBuffer>;
@@ -187,7 +188,7 @@ export interface SubtleCrypto {
187
188
  * @returns A promise that resolves with a boolean indicating whether the signature is valid.
188
189
  */
189
190
  verify(
190
- algorithm: "HMAC" | Algorithm<"HMAC"> | EcdsaParams,
191
+ algorithm: "HMAC" | Algorithm<"HMAC"> | EcdsaParams | RsaPssParams,
191
192
  key: CryptoKey,
192
193
  signature: ArrayBuffer | ArrayBufferView | DataView,
193
194
  data: ArrayBuffer | ArrayBufferView | DataView,
@@ -381,6 +382,24 @@ export interface AesGcmParams extends Algorithm<AlgorithmIdentifier> {
381
382
  tagLength?: number;
382
383
  }
383
384
 
385
+ /**
386
+ * The `RsaOaepParams` dictionary of the Web Crypto API represents the
387
+ * object that should be passed as the `algorithm` parameter of the
388
+ * `SubtleCrypto.encrypt()` and `SubtleCrypto.decrypt()` methods when
389
+ * using the RSA-OAEP algorithm.
390
+ */
391
+ export interface RsaOaepParams extends Algorithm<AlgorithmIdentifier> {
392
+ /**
393
+ * The name of the algorithm to use.
394
+ */
395
+ name: "RSA-OAEP";
396
+
397
+ /**
398
+ * The label to use. If not provided, it will default to an empty ArrayBuffer.
399
+ */
400
+ label?: ArrayBuffer | ArrayBufferView | DataView;
401
+ }
402
+
384
403
  /**
385
404
  * The `HmacKeyGenParams` dictionary of the Web Crypto API represents the
386
405
  * object that should be passed as the `algorithm` parameter of the
@@ -426,6 +445,34 @@ export interface EcKeyGenParams extends Algorithm<AlgorithmIdentifier> {
426
445
  namedCurve: "P-256" | "P-384" | "P-521";
427
446
  }
428
447
 
448
+ /**
449
+ * The RSAHashedKeyGenParams dictionary of the Web Crypto API represents the
450
+ * object that should be passed as the algorithm parameter into
451
+ * `SubtleCrypto.generateKey()`, when the algorithm is identified
452
+ * as either of RSASSA-PKCS1-v1_5, RSA-PSS or RSA-OAEP.
453
+ */
454
+ export interface RSAHashedKeyGenParams extends Algorithm<AlgorithmIdentifier> {
455
+ /**
456
+ * The name of the algorithm to use.
457
+ */
458
+ name: "RSASSA-PKCS1-v1_5" | "RSA-PSS" | "RSA-OAEP";
459
+
460
+ /**
461
+ * The modulus length, in bits.
462
+ */
463
+ modulusLength: number;
464
+
465
+ /**
466
+ * The public exponent.
467
+ */
468
+ publicExponent: Uint8Array;
469
+
470
+ /**
471
+ * The hash algorithm to use.
472
+ */
473
+ hash: HashAlgorithmIdentifier;
474
+ }
475
+
429
476
  /**
430
477
  * The `HmacImportParams` dictionary of the Web Crypto API represents the
431
478
  * object that should be passed as the `algorithm` parameter of the
@@ -471,6 +518,24 @@ export interface EcKeyImportParams extends Algorithm<AlgorithmIdentifier> {
471
518
  namedCurve: "P-256" | "P-384" | "P-521";
472
519
  }
473
520
 
521
+ /**
522
+ * The `RsaHashedImportParams` dictionary of the Web Crypto API represents
523
+ * the object that should be passed as the algorithm parameter
524
+ * into SubtleCrypto.importKey(), when the algorithm is identified
525
+ * as either of RSASSA-PKCS1-v1_5, RSA-PSS or RSA-OAEP.
526
+ */
527
+ export interface RsaHashedImportParams extends Algorithm<AlgorithmIdentifier> {
528
+ /**
529
+ * The name of the algorithm to use.
530
+ */
531
+ name: "RSASSA-PKCS1-v1_5" | "RSA-PSS" | "RSA-OAEP";
532
+
533
+ /**
534
+ * The hash algorithm to use.
535
+ */
536
+ hash: HashAlgorithmIdentifier;
537
+ }
538
+
474
539
  /**
475
540
  * The `EcdsaParams` dictionary of the Web Crypto API represents
476
541
  * the object that should be passed as the algorithm parameter
@@ -489,6 +554,24 @@ export interface EcdsaParams extends Algorithm<AlgorithmIdentifier> {
489
554
  hash: "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
490
555
  }
491
556
 
557
+ /**
558
+ * The `RsaPssParams` dictionary of the Web Crypto API represents
559
+ * the object that should be passed as the algorithm parameter
560
+ * into SubtleCrypto.sign() or SubtleCrypto.verify()
561
+ * when using the RSA-PSS algorithm.
562
+ */
563
+ export interface RsaPssParams extends Algorithm<AlgorithmIdentifier> {
564
+ /**
565
+ * The name of the algorithm to use.
566
+ */
567
+ name: "RSA-PSS";
568
+
569
+ /**
570
+ * The length of the salt to use.
571
+ */
572
+ saltLength: number;
573
+ }
574
+
492
575
  /**
493
576
  * The `EcdhKeyDeriveParams` dictionary of the Web Crypto API represents
494
577
  * the object that should be passed as the algorithm parameter
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "0.54.0",
3
+ "version": "0.54.2",
4
4
  "description": "TypeScript definitions for k6",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
6
6
  "license": "MIT",
@@ -61,6 +61,7 @@
61
61
  },
62
62
  "scripts": {},
63
63
  "dependencies": {},
64
- "typesPublisherContentHash": "117f96c1bd174240bb9f518388a69fc69bbb14dd874730e2db3ea53c0513b9c6",
65
- "typeScriptVersion": "4.8"
64
+ "peerDependencies": {},
65
+ "typesPublisherContentHash": "aede7a67bee3eb3043ddc67d2a133744bff86187b169592fa2e7dc057aebc948",
66
+ "typeScriptVersion": "4.9"
66
67
  }
@@ -1,208 +0,0 @@
1
- /**
2
- * This module provides ways to instrument k6 scripts HTTP calls with tracing information.
3
- *
4
- * It most notably exposes an `instrumentHTTP` function that can be used to wrap the `http` module's
5
- * function calls with tracing information. It also exposes a `Client` class that can be used to
6
- * instrument HTTP calls in a more fine-grained way.
7
- *
8
- * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/tracing/
9
- */
10
-
11
- import { RefinedParams, RefinedResponse, RequestBody, ResponseType } from "../../http/index.js";
12
-
13
- /**
14
- * The instrumentHTTP function instruments the k6 http module
15
- * with tracing capabilities. It will transparently replace each
16
- * of the k6 http module functions with its instrumented
17
- * counterpart, in place.
18
- *
19
- * instrumentHTTP can only be called in the init context of the script.
20
- *
21
- * @param options - The options to use when instrumenting the http module.
22
- */
23
- export function instrumentHTTP(options: Options): void;
24
-
25
- /**
26
- * Client is an HTTP client class that attaches tracing information
27
- * to its requests.
28
- *
29
- * It lets users include a tracing context in their HTTP requests
30
- * so that tracing backends (such as Grafana Tempo) can incorporate
31
- * their results.
32
- *
33
- * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/tracing/client/
34
- */
35
- export class Client {
36
- protected __brand: never;
37
-
38
- /**
39
- * Instantiates a new tracing Client.
40
- *
41
- * @param options - The options to use for this Client.
42
- */
43
- constructor(options: Options);
44
-
45
- /**
46
- * Performs a DELETE request instrumented with trace context
47
- * headers.
48
- *
49
- * @param url - Request URL.
50
- * @param body - Discouraged. Request body. Object form encoded.
51
- * @param params - Request parameters.
52
- * @returns Resulting response.
53
- */
54
- del<RT extends ResponseType | undefined>(
55
- url: string | HttpURL,
56
- body?: RequestBody | null,
57
- params?: RefinedParams<RT> | null,
58
- ): RefinedResponse<RT>;
59
-
60
- /**
61
- * Performs a HEAD request instrumented with trace context headers.
62
- *
63
- * @param url - Request URL.
64
- * @param params - Request parameters.
65
- * @returns Resulting response.
66
- */
67
- head<RT extends ResponseType | undefined>(
68
- url: string | HttpURL,
69
- params?: RefinedParams<RT> | null,
70
- ): RefinedResponse<RT>;
71
-
72
- /**
73
- * Performs a GET request instrumented with trace context headers.
74
- *
75
- * @param url - Request URL.
76
- * @param params - Request parameters.
77
- * @returns Resulting response.
78
- */
79
- get<RT extends ResponseType | undefined>(
80
- url: string | HttpURL,
81
- params?: RefinedParams<RT> | null,
82
- ): RefinedResponse<RT>;
83
-
84
- /**
85
- * Performs an OPTIONS request instrumented with trace context headers.
86
- *
87
- * @param url - Request URL.
88
- * @param body - Request body. Object form encoded.
89
- * @param params - Request parameters.
90
- * @returns Resulting response.
91
- */
92
- options<RT extends ResponseType | undefined>(
93
- url: string | HttpURL,
94
- body?: RequestBody | null,
95
- params?: RefinedParams<RT> | null,
96
- ): RefinedResponse<RT>;
97
-
98
- /**
99
- * Performs a PATCH request instrumented with trace context headers.
100
- *
101
- * @param url - Request URL.
102
- * @param body - Request body. Object form encoded.
103
- * @param params - Request parameters.
104
- * @returns Resulting response.
105
- */
106
- patch<RT extends ResponseType | undefined>(
107
- url: string | HttpURL,
108
- body?: RequestBody | null,
109
- params?: RefinedParams<RT> | null,
110
- ): RefinedResponse<RT>;
111
-
112
- /**
113
- * Performs a POST request instrumented with trace context headers.
114
- *
115
- * @param url - Request URL.
116
- * @param body - Request body. Object form encoded.
117
- * @param params - Request parameters.
118
- * @returns Resulting response.
119
- */
120
- post<RT extends ResponseType | undefined>(
121
- url: string | HttpURL,
122
- body?: RequestBody | null,
123
- params?: RefinedParams<RT> | null,
124
- ): RefinedResponse<RT>;
125
-
126
- /**
127
- * Performs a PUT request instrumented with trace context headers.
128
- *
129
- * @param url - Request URL.
130
- * @param body - Request body. Object form encoded.
131
- * @param params - Request parameters.
132
- * @returns Resulting response.
133
- */
134
- put<RT extends ResponseType | undefined>(
135
- url: string | HttpURL,
136
- body?: RequestBody | null,
137
- params?: RefinedParams<RT> | null,
138
- ): RefinedResponse<RT>;
139
-
140
- /**
141
- * Performs a HTTP request instrumented with trace context headers.
142
- *
143
- * @param method - HTTP method.
144
- * @param url - Request URL.
145
- * @param body - Request body. Object form encoded.
146
- * @param params - Request parameters.
147
- * @returns Resulting response.
148
- */
149
- request<RT extends ResponseType | undefined>(
150
- method: string,
151
- url: string | HttpURL,
152
- body?: RequestBody | null,
153
- params?: RefinedParams<RT> | null,
154
- ): RefinedResponse<RT>;
155
-
156
- /**
157
- * The asyncRequest method starts the process of performing a HTTP request
158
- * asynchronously, returning a promise which is fulfilled once the response
159
- * is available. The performed request is instrumented with trace context
160
- * headers.
161
- *
162
- * @param method - HTTP method.
163
- * @param url - Request URL.
164
- * @param body - Request body. Object form encoded.
165
- * @param params - Request parameters.
166
- * @returns Resulting response.
167
- */
168
- asyncRequest<RT extends ResponseType | undefined>(
169
- method: string,
170
- url: string | HttpURL,
171
- body?: RequestBody | null,
172
- params?: RefinedParams<RT> | null,
173
- ): Promise<RefinedResponse<RT>>;
174
- }
175
-
176
- /**
177
- * The Options object allows configuring the tracing instrumentation behavior.
178
- *
179
- * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/tracing/options/
180
- */
181
- export interface Options {
182
- /**
183
- * The trace context propagation format.
184
- *
185
- * Currently supported: `w3c` and `jaeger`.
186
- *
187
- * Defaults to `w3c`.
188
- */
189
- propagator: "w3c" | "jaeger";
190
-
191
- /**
192
- * The probability of each request having
193
- * its `sampled` flag set to true.
194
- * Its value should be within the `0 <= n <= 100` bounds.
195
- *
196
- * Defaults to `100`.
197
- */
198
- sampling?: number;
199
- }
200
-
201
- /**
202
- * Returned value from http.url method.
203
- */
204
- export interface HttpURL {
205
- __brand: "http-url";
206
- }
207
-
208
- export * as default from "k6/experimental/tracing";