@types/k6 0.32.1 → 0.34.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.
Files changed (7) hide show
  1. k6/README.md +2 -2
  2. k6/data.d.ts +1 -1
  3. k6/execution.d.ts +85 -0
  4. k6/http.d.ts +42 -20
  5. k6/index.d.ts +8 -6
  6. k6/metrics.d.ts +3 -0
  7. k6/package.json +26 -21
k6/README.md CHANGED
@@ -8,9 +8,9 @@ This package contains type definitions for k6 (https://k6.io/docs/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Fri, 25 Jun 2021 11:31:14 GMT
11
+ * Last updated: Wed, 20 Oct 2021 10:31:23 GMT
12
12
  * Dependencies: none
13
13
  * Global values: none
14
14
 
15
15
  # Credits
16
- These definitions were written by [MajorBreakfast](https://github.com/MajorBreakfast), [Book Moons](https://github.com/bookmoons), [na--](https://github.com/na--), [Pepe Cano](https://github.com/ppcano), [Simon Aronsson](https://github.com/simskij), and [Ivan Mirić](https://github.com/imiric).
16
+ These definitions were written by [na--](https://github.com/na--), [Ivan Mirić](https://github.com/imiric), [Mihail Stoykov](https://github.com/MStoykov), [Ivan](https://github.com/codebien), [Inanc Gumus](https://github.com/inancgumus), [yorugac](https://github.com/yorugac), and [Pepe Cano](https://github.com/ppcano).
k6/data.d.ts CHANGED
@@ -7,5 +7,5 @@ export const SharedArray: {
7
7
  * Given a name and a function that returns an array, the SharedArray constructor returns the same array but sharing the array memory between VUs.
8
8
  * https://k6.io/docs/javascript-api/k6-data/sharedarray/
9
9
  */
10
- new(name: string, callback: () => []): [];
10
+ new<T>(name: string, callback: () => T[]): T[];
11
11
  };
k6/execution.d.ts ADDED
@@ -0,0 +1,85 @@
1
+ /*
2
+ * The execution module provides information about the current test execution state.
3
+ * https://k6.io/docs/javascript-api/k6-execution/
4
+ */
5
+ declare namespace execution {
6
+ /**
7
+ * Information about the current scenario.
8
+ */
9
+ const scenario: {
10
+ /**
11
+ * The assigned name of the running scenario.
12
+ */
13
+ name: string;
14
+ /**
15
+ * The name of the running Executor type.
16
+ */
17
+ executor: string;
18
+ /**
19
+ * The Unix timestamp in milliseconds when the scenario started.
20
+ */
21
+ startTime: number;
22
+ /**
23
+ * Percentage in a 0 to 1 interval of the scenario progress.
24
+ */
25
+ progress: number;
26
+ /**
27
+ * The unique and zero-based sequential number of the current iteration in the scenario, across the current instance.
28
+ */
29
+ iterationInInstance: number;
30
+ /**
31
+ * The unique and zero-based sequential number of the current iteration in the scenario.
32
+ */
33
+ iterationInTest: number;
34
+ };
35
+
36
+ /**
37
+ * Information about the current load generator instance.
38
+ */
39
+ const instance: {
40
+ /**
41
+ * The number of prematurely interrupted iterations in the current instance.
42
+ */
43
+ iterationsInterrupted: number;
44
+ /**
45
+ * The number of completed iterations in the current instance.
46
+ */
47
+ iterationsCompleted: number;
48
+ /**
49
+ * The number of active VUs.
50
+ */
51
+ vusActive: number;
52
+ /**
53
+ * The number of currently initialized VUs.
54
+ */
55
+ vusInitialized: number;
56
+ /**
57
+ * The time passed from the start of the current test run in milliseconds.
58
+ */
59
+ currentTestRunDuration: number;
60
+ };
61
+
62
+ /**
63
+ * Information about the current virtual user.
64
+ */
65
+ const vu: {
66
+ /**
67
+ * The identifier of the iteration in the current instance.
68
+ */
69
+ iterationInInstance: number;
70
+ /**
71
+ * The identifier of the iteration in the current scenario.
72
+ */
73
+ iterationInScenario: number;
74
+ /**
75
+ * The identifier of the VU across the instance.
76
+ */
77
+ idInInstance: number;
78
+ /**
79
+ * The globally unique (across the whole test run) identifier of the VU.
80
+ */
81
+ idInTest: number;
82
+ };
83
+ }
84
+
85
+ export default execution;
k6/http.d.ts CHANGED
@@ -10,7 +10,7 @@ import { Selection } from './html';
10
10
  * @returns Resulting response.
11
11
  */
12
12
  export function del<RT extends ResponseType | undefined>(
13
- url: string,
13
+ url: string | HttpURL,
14
14
  body?: RequestBody | null,
15
15
  params?: RefinedParams<RT> | null
16
16
  ): RefinedResponse<RT>;
@@ -25,7 +25,7 @@ export function del<RT extends ResponseType | undefined>(
25
25
  * http.get('https://k6.io')
26
26
  */
27
27
  export function get<RT extends ResponseType | undefined>(
28
- url: string,
28
+ url: string | HttpURL,
29
29
  params?: RefinedParams<RT> | null
30
30
  ): RefinedResponse<RT>;
31
31
 
@@ -38,7 +38,7 @@ export function get<RT extends ResponseType | undefined>(
38
38
  * @returns Resulting response.
39
39
  */
40
40
  export function options<RT extends ResponseType | undefined>(
41
- url: string,
41
+ url: string | HttpURL,
42
42
  body?: RequestBody | null,
43
43
  params?: RefinedParams<RT> | null
44
44
  ): RefinedResponse<RT>;
@@ -52,7 +52,7 @@ export function options<RT extends ResponseType | undefined>(
52
52
  * @returns Resulting response.
53
53
  */
54
54
  export function patch<RT extends ResponseType | undefined>(
55
- url: string,
55
+ url: string | HttpURL,
56
56
  body?: RequestBody | null,
57
57
  params?: RefinedParams<RT> | null
58
58
  ): RefinedResponse<RT>;
@@ -70,7 +70,7 @@ export function patch<RT extends ResponseType | undefined>(
70
70
  * http.post(url, formData, { headers: headers });
71
71
  */
72
72
  export function post<RT extends ResponseType | undefined>(
73
- url: string,
73
+ url: string | HttpURL,
74
74
  body?: RequestBody | null,
75
75
  params?: RefinedParams<RT> | null
76
76
  ): RefinedResponse<RT>;
@@ -84,7 +84,7 @@ export function post<RT extends ResponseType | undefined>(
84
84
  * @returns Resulting response.
85
85
  */
86
86
  export function put<RT extends ResponseType | undefined>(
87
- url: string,
87
+ url: string | HttpURL,
88
88
  body?: RequestBody | null,
89
89
  params?: RefinedParams<RT> | null
90
90
  ): RefinedResponse<RT>;
@@ -104,7 +104,7 @@ export function put<RT extends ResponseType | undefined>(
104
104
  */
105
105
  export function request<RT extends ResponseType | undefined>(
106
106
  method: string,
107
- url: string,
107
+ url: string | HttpURL,
108
108
  body?: RequestBody | null,
109
109
  params?: RefinedParams<RT> | null
110
110
  ): RefinedResponse<RT>;
@@ -307,12 +307,12 @@ export interface StructuredRequestBody {
307
307
  * Batch request specification.
308
308
  * https://k6.io/docs/javascript-api/k6-http/batch-requests
309
309
  */
310
- export type BatchRequest = string | ArrayBatchRequest | ObjectBatchRequest;
310
+ export type BatchRequest = string | HttpURL | ArrayBatchRequest | ObjectBatchRequest;
311
311
 
312
312
  /**
313
313
  * Array form batch request specification.
314
314
  */
315
- export type ArrayBatchRequest = [ string, string, (RequestBody | null)?, (Params | null)? ];
315
+ export type ArrayBatchRequest = [ string, string | HttpURL, (RequestBody | null)?, (Params | null)? ];
316
316
 
317
317
  /**
318
318
  * Object form batch request specification.
@@ -322,7 +322,7 @@ export interface ObjectBatchRequest {
322
322
  method: string;
323
323
 
324
324
  /** Request URL. */
325
- url: string;
325
+ url: string | HttpURL;
326
326
 
327
327
  /** Request body. */
328
328
  body?: RequestBody | null;
@@ -345,6 +345,7 @@ export type BatchRequests = BatchRequest[] | { [name: string]: BatchRequest };
345
345
  */
346
346
  export type RefinedBatchRequest<RT extends ResponseType | undefined> =
347
347
  | string
348
+ | HttpURL
348
349
  | ArrayRefinedBatchRequest<RT>
349
350
  | ObjectRefinedBatchRequest<RT>;
350
351
 
@@ -353,7 +354,7 @@ export type RefinedBatchRequest<RT extends ResponseType | undefined> =
353
354
  */
354
355
  export type ArrayRefinedBatchRequest<RT extends ResponseType | undefined> = [
355
356
  string,
356
- string,
357
+ string | HttpURL ,
357
358
  (RequestBody | null)?,
358
359
  (RefinedParams<RT> | null)?
359
360
  ];
@@ -363,7 +364,7 @@ export type ArrayRefinedBatchRequest<RT extends ResponseType | undefined> = [
363
364
  */
364
365
  export interface ObjectRefinedBatchRequest<RT extends ResponseType | undefined> {
365
366
  method: string;
366
- url: string;
367
+ url: string | HttpURL;
367
368
  body?: RequestBody | null;
368
369
  params?: RefinedParams<RT> | null;
369
370
  }
@@ -520,7 +521,7 @@ export interface Response {
520
521
  * let res = http.get(url);
521
522
  * res.json();
522
523
  */
523
- json(selector?: string): JSONValue | undefined;
524
+ json(selector?: string): JSONValue;
524
525
 
525
526
  /**
526
527
  * Submit form on page.
@@ -734,6 +735,16 @@ export interface ExpectedStatusesObject {
734
735
  max: number;
735
736
  }
736
737
 
738
+ // === HTTP URL ===
739
+ // -----------------------
740
+
741
+ /**
742
+ * Returned value from http.url method.
743
+ */
744
+ interface HttpURL {
745
+ __brand: "http-url";
746
+ }
747
+
737
748
  /**
738
749
  * The http module contains functionality for performing HTTP transactions.
739
750
  * https://k6.io/docs/javascript-api/k6-http/
@@ -748,7 +759,7 @@ declare namespace http {
748
759
  * @returns Resulting response.
749
760
  */
750
761
  function del<RT extends ResponseType | undefined>(
751
- url: string,
762
+ url: string | HttpURL,
752
763
  body?: RequestBody | null,
753
764
  params?: RefinedParams<RT> | null
754
765
  ): RefinedResponse<RT>;
@@ -763,7 +774,7 @@ declare namespace http {
763
774
  * http.get('https://k6.io')
764
775
  */
765
776
  function get<RT extends ResponseType | undefined>(
766
- url: string,
777
+ url: string | HttpURL,
767
778
  params?: RefinedParams<RT> | null
768
779
  ): RefinedResponse<RT>;
769
780
 
@@ -776,7 +787,7 @@ declare namespace http {
776
787
  * @returns Resulting response.
777
788
  */
778
789
  function options<RT extends ResponseType | undefined>(
779
- url: string,
790
+ url: string | HttpURL,
780
791
  body?: RequestBody | null,
781
792
  params?: RefinedParams<RT> | null
782
793
  ): RefinedResponse<RT>;
@@ -790,7 +801,7 @@ declare namespace http {
790
801
  * @returns Resulting response.
791
802
  */
792
803
  function patch<RT extends ResponseType | undefined>(
793
- url: string,
804
+ url: string | HttpURL,
794
805
  body?: RequestBody | null,
795
806
  params?: RefinedParams<RT> | null
796
807
  ): RefinedResponse<RT>;
@@ -808,7 +819,7 @@ declare namespace http {
808
819
  * http.post(url, formData, { headers: headers });
809
820
  */
810
821
  function post<RT extends ResponseType | undefined>(
811
- url: string,
822
+ url: string | HttpURL,
812
823
  body?: RequestBody | null,
813
824
  params?: RefinedParams<RT> | null
814
825
  ): RefinedResponse<RT>;
@@ -822,7 +833,7 @@ declare namespace http {
822
833
  * @returns Resulting response.
823
834
  */
824
835
  function put<RT extends ResponseType | undefined>(
825
- url: string,
836
+ url: string | HttpURL,
826
837
  body?: RequestBody | null,
827
838
  params?: RefinedParams<RT> | null
828
839
  ): RefinedResponse<RT>;
@@ -842,11 +853,22 @@ declare namespace http {
842
853
  */
843
854
  function request<RT extends ResponseType | undefined>(
844
855
  method: string,
845
- url: string,
856
+ url: string | HttpURL,
846
857
  body?: RequestBody | null,
847
858
  params?: RefinedParams<RT> | null
848
859
  ): RefinedResponse<RT>;
849
860
 
861
+ /**
862
+ * Creates a URL with set name tag.
863
+ * https://k6.io/docs/using-k6/http-requests/#url-grouping
864
+ * @param strings - Passed string values.
865
+ * @param args - Tagged template expressions.
866
+ * @returns HTTP URL object.
867
+ * @example
868
+ * http.get(http.url`http://example.com/posts/${id}`) // tags.name="http://example.com/posts/${}",
869
+ */
870
+ function url(strings: TemplateStringsArray, ...args: Array<string | number | boolean>): HttpURL;
871
+
850
872
  /**
851
873
  * Batch multiple HTTP requests together,
852
874
  * to issue them in parallel over multiple TCP connections.
k6/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- // Type definitions for k6 0.32
1
+ // Type definitions for k6 0.34
2
2
  // Project: https://k6.io/docs/
3
- // Definitions by: MajorBreakfast <https://github.com/MajorBreakfast>
4
- // Book Moons <https://github.com/bookmoons>
5
- // na-- <https://github.com/na-->
6
- // Pepe Cano <https://github.com/ppcano>
7
- // Simon Aronsson <https://github.com/simskij>
3
+ // Definitions by: na-- <https://github.com/na-->
8
4
  // Ivan Mirić <https://github.com/imiric>
5
+ // Mihail Stoykov <https://github.com/MStoykov>
6
+ // Ivan <https://github.com/codebien>
7
+ // Inanc Gumus <https://github.com/inancgumus>
8
+ // yorugac <https://github.com/yorugac>
9
+ // Pepe Cano <https://github.com/ppcano>
9
10
  // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10
11
  // TypeScript Version: 3.4
11
12
 
@@ -34,6 +35,7 @@ import './global'; // Type global environment
34
35
  import './crypto';
35
36
  import './data';
36
37
  import './encoding';
38
+ import './execution';
37
39
  import './html';
38
40
  import './http';
39
41
  import './metrics';
k6/metrics.d.ts CHANGED
@@ -15,6 +15,9 @@ export abstract class Metric {
15
15
  */
16
16
  constructor(name: string, isTime?: boolean);
17
17
 
18
+ /** The name of the custom metric. */
19
+ name: string;
20
+
18
21
  /**
19
22
  * Add value.
20
23
  * @param value - Value to add.
k6/package.json CHANGED
@@ -1,39 +1,44 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "0.32.1",
3
+ "version": "0.34.2",
4
4
  "description": "TypeScript definitions for k6",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
6
6
  "license": "MIT",
7
7
  "contributors": [
8
8
  {
9
- "name": "MajorBreakfast",
10
- "url": "https://github.com/MajorBreakfast",
11
- "githubUsername": "MajorBreakfast"
9
+ "name": "na--",
10
+ "url": "https://github.com/na--",
11
+ "githubUsername": "na--"
12
12
  },
13
13
  {
14
- "name": "Book Moons",
15
- "url": "https://github.com/bookmoons",
16
- "githubUsername": "bookmoons"
14
+ "name": "Ivan Mirić",
15
+ "url": "https://github.com/imiric",
16
+ "githubUsername": "imiric"
17
17
  },
18
18
  {
19
- "name": "na--",
20
- "url": "https://github.com/na--",
21
- "githubUsername": "na--"
19
+ "name": "Mihail Stoykov",
20
+ "url": "https://github.com/MStoykov",
21
+ "githubUsername": "MStoykov"
22
22
  },
23
23
  {
24
- "name": "Pepe Cano",
25
- "url": "https://github.com/ppcano",
26
- "githubUsername": "ppcano"
24
+ "name": "Ivan",
25
+ "url": "https://github.com/codebien",
26
+ "githubUsername": "codebien"
27
27
  },
28
28
  {
29
- "name": "Simon Aronsson",
30
- "url": "https://github.com/simskij",
31
- "githubUsername": "simskij"
29
+ "name": "Inanc Gumus",
30
+ "url": "https://github.com/inancgumus",
31
+ "githubUsername": "inancgumus"
32
32
  },
33
33
  {
34
- "name": "Ivan Mirić",
35
- "url": "https://github.com/imiric",
36
- "githubUsername": "imiric"
34
+ "name": "yorugac",
35
+ "url": "https://github.com/yorugac",
36
+ "githubUsername": "yorugac"
37
+ },
38
+ {
39
+ "name": "Pepe Cano",
40
+ "url": "https://github.com/ppcano",
41
+ "githubUsername": "ppcano"
37
42
  }
38
43
  ],
39
44
  "main": "",
@@ -45,6 +50,6 @@
45
50
  },
46
51
  "scripts": {},
47
52
  "dependencies": {},
48
- "typesPublisherContentHash": "ed5e70f6d3f6e90e131b3958cfb61c328e44ed91ee4a74fbb56d5e6be96d4ca7",
49
- "typeScriptVersion": "3.6"
53
+ "typesPublisherContentHash": "a0c95f6bb3f3029894f1263b00b2b0a0fe8d331c94d0f78ea2db2e4c7990c1d4",
54
+ "typeScriptVersion": "3.7"
50
55
  }