@types/k6 0.52.0 → 0.53.1
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 +1 -1
- k6/crypto.d.ts +1 -3
- k6/experimental/streams.d.ts +198 -0
- k6/experimental/websockets.d.ts +24 -5
- k6/global.d.ts +0 -2
- k6/http.d.ts +4 -4
- k6/index.d.ts +0 -5
- k6/package.json +2 -2
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:
|
|
11
|
+
* Last updated: Fri, 23 Aug 2024 08:10:16 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
|
|
14
14
|
# Credits
|
k6/crypto.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { bytes } from ".";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Generate random bytes.
|
|
5
3
|
* @param size - Number of bytes to generate.
|
|
@@ -181,7 +179,7 @@ export type OutputEncoding = StringEncoding | BinaryEncoding;
|
|
|
181
179
|
* @template OE - Output encoding.
|
|
182
180
|
*/
|
|
183
181
|
export type Output<OE extends OutputEncoding> = OE extends StringEncoding ? string
|
|
184
|
-
: OE extends BinaryEncoding ?
|
|
182
|
+
: OE extends BinaryEncoding ? ArrayBuffer
|
|
185
183
|
: never;
|
|
186
184
|
|
|
187
185
|
/**
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides an experimental implementation of the Streams API
|
|
3
|
+
* for k6.
|
|
4
|
+
*
|
|
5
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The ReadableStream object provides the API for creating and managing readable
|
|
10
|
+
* streams of raw data, bit by bit, as soon as it is available, without needing to generate a buffer, string, or blob.
|
|
11
|
+
*/
|
|
12
|
+
export class ReadableStream {
|
|
13
|
+
/**
|
|
14
|
+
* The ReadableStream constructor returns a newly created ReadableStream object.
|
|
15
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestream/
|
|
16
|
+
*
|
|
17
|
+
* @param underlyingSource - defines the source of data for the stream.
|
|
18
|
+
* @param queuingStrategy - defines the queuing strategy to adopt for the stream.
|
|
19
|
+
*/
|
|
20
|
+
constructor(underlyingSource?: UnderlyingSource, queuingStrategy?: QueuingStrategy);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Closes the stream and signals a reason for the closure.
|
|
24
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestream/cancel/
|
|
25
|
+
*
|
|
26
|
+
* Used when you’ve completely finished with the stream and don’t need any more data from it,
|
|
27
|
+
* even if chunks are enqueued waiting to be read.
|
|
28
|
+
*
|
|
29
|
+
* That data is lost after cancel is called, and the stream is not readable anymore.
|
|
30
|
+
* To close the stream without getting rid of enqueued chunks, use `ReadableStreamDefaultController.close()`.
|
|
31
|
+
*
|
|
32
|
+
* It returns a promise that is resolved with `undefined` when the stream is canceled.
|
|
33
|
+
*
|
|
34
|
+
* @param reason - the reason for canceling the stream.
|
|
35
|
+
*/
|
|
36
|
+
cancel(reason: any): Promise<void>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a reader and locks the stream to it.
|
|
40
|
+
* While the stream is locked, no other reader can be acquired until this one is released.
|
|
41
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestream/getreader/
|
|
42
|
+
*/
|
|
43
|
+
getReader(): ReadableStreamDefaultReader;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The object that defines the source of data for the stream.
|
|
48
|
+
*/
|
|
49
|
+
export interface UnderlyingSource {
|
|
50
|
+
/**
|
|
51
|
+
* Called when the stream is created.
|
|
52
|
+
* It can be used to perform any setup tasks.
|
|
53
|
+
* The content of this method is to be defined by the user.
|
|
54
|
+
*/
|
|
55
|
+
start?: (controller: ReadableStreamDefaultController) => void | Promise<void>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Called repeatedly to fetch and queue data into the stream,
|
|
59
|
+
* until it reaches its high watermark.
|
|
60
|
+
* If `pull()` returns a promise, it won’t be called again until the promise is resolved.
|
|
61
|
+
*/
|
|
62
|
+
pull?: (controller: ReadableStreamDefaultController) => void | Promise<void>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Called when the stream is canceled.
|
|
66
|
+
* It can be used to release access to the stream source and perform any cleanup tasks.
|
|
67
|
+
* The reason parameter passed to this method is an optional human-readable value
|
|
68
|
+
* that represents the reason for canceling the stream.
|
|
69
|
+
*/
|
|
70
|
+
cancel?: (reason?: any) => void | Promise<void>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Specifies the type of the underlying source.
|
|
74
|
+
* It can currently only receive the value 'default' which is its default value.
|
|
75
|
+
*/
|
|
76
|
+
type?: "default";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The object that allows the user to control a ReadableStream’s state and internal queue.
|
|
81
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultcontroller/
|
|
82
|
+
*/
|
|
83
|
+
export interface ReadableStreamDefaultController {
|
|
84
|
+
/**
|
|
85
|
+
* Closes the associated stream.
|
|
86
|
+
* Readers can still read any previously enqueued chunks from the stream.
|
|
87
|
+
* Once those chunks are read, the stream closes, and no more data is available.
|
|
88
|
+
*/
|
|
89
|
+
close: () => void;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Enqueues a chunk of data into the associated stream.
|
|
93
|
+
*/
|
|
94
|
+
enqueue: (chunk: any) => void;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Makes any future interactions with the associated stream to error.
|
|
98
|
+
*/
|
|
99
|
+
error: (reason: any) => void;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The object that defines the queuing strategy to adopt for the stream.
|
|
104
|
+
*
|
|
105
|
+
* Although the user can define a custom queueing strategy, the default behavior and recommended way
|
|
106
|
+
* to use the `ReadableStream` is to use a `CountQueuingStrategy` object.
|
|
107
|
+
*/
|
|
108
|
+
export interface QueuingStrategy {
|
|
109
|
+
/**
|
|
110
|
+
* Represents the maximum number of chunks that the stream can hold in its internal queue.
|
|
111
|
+
* The default value is 1.
|
|
112
|
+
*/
|
|
113
|
+
highWaterMark?: number;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Returns the size of the chunk passed as an argument.
|
|
117
|
+
* The default value is a function that returns 1.
|
|
118
|
+
*/
|
|
119
|
+
size?(chunk: any): number;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The CountQueuingStrategy object is the default QueuingStrategy for ReadableStream.
|
|
124
|
+
* It counts the number of chunks in the queue.
|
|
125
|
+
*/
|
|
126
|
+
export class CountQueuingStrategy {
|
|
127
|
+
/**
|
|
128
|
+
* The CountQueuingStrategy constructor returns a newly created CountQueuingStrategy object.
|
|
129
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestream/countqueuingstrategy/
|
|
130
|
+
*
|
|
131
|
+
* @param options - an object with optional property `highWaterMark` that determines
|
|
132
|
+
* the maximum number of chunks that the queue can contain.
|
|
133
|
+
*/
|
|
134
|
+
constructor(options?: { highWaterMark?: number });
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Represents the maximum number of chunks that the stream can hold in its internal queue.
|
|
138
|
+
* The default value is 1.
|
|
139
|
+
*/
|
|
140
|
+
readonly highWaterMark: number;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Returns the size of the chunk passed as an argument.
|
|
144
|
+
* The default value is a function that returns 1.
|
|
145
|
+
*/
|
|
146
|
+
size(chunk: any): number;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The object used to read stream data.
|
|
151
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultreader/
|
|
152
|
+
*/
|
|
153
|
+
export class ReadableStreamDefaultReader {
|
|
154
|
+
/**
|
|
155
|
+
* The ReadableStreamDefaultReader constructor returns a newly created ReadableStreamDefaultReader object.
|
|
156
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultreader/
|
|
157
|
+
*
|
|
158
|
+
* @param stream - defines the stream the reader will own.
|
|
159
|
+
*/
|
|
160
|
+
constructor(stream: ReadableStream);
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Closes the reader and signals a reason for the closure.
|
|
164
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultreader/cancel/
|
|
165
|
+
*
|
|
166
|
+
* Used when you’ve completely finished with the stream and don’t need any more data from it,
|
|
167
|
+
* even if chunks are enqueued waiting to be read.
|
|
168
|
+
* That data is lost after cancel is called, and the stream is not readable anymore.
|
|
169
|
+
* To close the stream without getting rid of enqueued chunks, use `ReadableStreamDefaultController.close()`.
|
|
170
|
+
*
|
|
171
|
+
* It returns a promise that is resolved with `undefined` when the stream is canceled.
|
|
172
|
+
*
|
|
173
|
+
* @param reason - the reason for canceling the stream.
|
|
174
|
+
*/
|
|
175
|
+
cancel(reason: any): Promise<void>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Returns a promise providing access to the next chunk in the stream’s internal queue.
|
|
179
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultreader/read/
|
|
180
|
+
*
|
|
181
|
+
* - If the stream is closed and no more data is available, the promise resolves with an object of the form:
|
|
182
|
+
* `{ done: true, value: undefined }`.
|
|
183
|
+
* - If the stream is errored, the promise rejects with the error that caused the stream to error.
|
|
184
|
+
*/
|
|
185
|
+
read(): Promise<{ done: false; value: any } | { done: true; value: undefined }>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Releases the reader’s lock on the stream.
|
|
189
|
+
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultreader/releaselock/
|
|
190
|
+
*
|
|
191
|
+
* If the associated stream is errored as the lock is released, the reader will be errored as well.
|
|
192
|
+
* This method is useful when done with the stream and want to release the lock on it.
|
|
193
|
+
*
|
|
194
|
+
* If the reader’s lock is released as pending read operations are still in progress,
|
|
195
|
+
* the reader’s `ReadableStreamDefaultReader.read()` calls are immediately rejected with a `TypeError`.
|
|
196
|
+
*/
|
|
197
|
+
readonly releaseLock: () => void;
|
|
198
|
+
}
|
k6/experimental/websockets.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CookieJar } from "../http";
|
|
2
|
+
import { ReadableStream } from "./streams";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* This module provides an experimental implementation of the WebSocket API
|
|
@@ -55,7 +56,7 @@ export class WebSocket {
|
|
|
55
56
|
*
|
|
56
57
|
* @param data - the data to send to the server
|
|
57
58
|
*/
|
|
58
|
-
send(data: string | ArrayBuffer): void;
|
|
59
|
+
send(data: string | ArrayBuffer | Blob): void;
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* Bind event names to event handlers to be executed when their
|
|
@@ -123,6 +124,26 @@ export class WebSocket {
|
|
|
123
124
|
onpong: () => void;
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
export type BlobPart = ArrayBuffer | ArrayBufferView | Blob | string;
|
|
128
|
+
|
|
129
|
+
export interface BlobOptions {
|
|
130
|
+
type?: string | undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The Blob represents binary data and can be used to interact with it.
|
|
135
|
+
*/
|
|
136
|
+
export class Blob {
|
|
137
|
+
readonly type: string;
|
|
138
|
+
readonly size: number;
|
|
139
|
+
constructor(blobParts?: BlobPart[], options?: BlobOptions);
|
|
140
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
141
|
+
bytes(): Promise<Uint8Array>;
|
|
142
|
+
slice(start?: number, end?: number): Blob;
|
|
143
|
+
stream(): ReadableStream;
|
|
144
|
+
text(): Promise<string>;
|
|
145
|
+
}
|
|
146
|
+
|
|
126
147
|
/**
|
|
127
148
|
* k6 specific WebSocket parameters.
|
|
128
149
|
* https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/websockets/params/
|
|
@@ -177,9 +198,7 @@ export enum ReadyState {
|
|
|
177
198
|
* transmitted over a Websocket connection.
|
|
178
199
|
*/
|
|
179
200
|
export enum BinaryType {
|
|
180
|
-
|
|
181
|
-
* Binary data is returned in ArrayBuffer form. k6 supports only this type.
|
|
182
|
-
*/
|
|
201
|
+
Blob = "blob",
|
|
183
202
|
ArrayBuffer = "arraybuffer",
|
|
184
203
|
}
|
|
185
204
|
|
|
@@ -226,7 +245,7 @@ export interface MessageEvent {
|
|
|
226
245
|
/**
|
|
227
246
|
* The data sent by the message emitter.
|
|
228
247
|
*/
|
|
229
|
-
data: string | ArrayBuffer;
|
|
248
|
+
data: string | ArrayBuffer | Blob;
|
|
230
249
|
|
|
231
250
|
/**
|
|
232
251
|
* the type of the event.
|
k6/global.d.ts
CHANGED
k6/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JSONValue } from ".";
|
|
2
2
|
import { Selection } from "./html";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -185,7 +185,7 @@ export function batch<Q extends BatchRequests>(requests: Q): BatchResponses<Q>;
|
|
|
185
185
|
* console.log(f.content_type);
|
|
186
186
|
* }
|
|
187
187
|
*/
|
|
188
|
-
export function file(data: string |
|
|
188
|
+
export function file(data: string | ArrayBuffer, filename?: string, contentType?: string): FileData;
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
191
|
* Get active cookie jar.
|
|
@@ -688,7 +688,7 @@ export abstract class FileData {
|
|
|
688
688
|
protected __brand: never;
|
|
689
689
|
|
|
690
690
|
/** File data. */
|
|
691
|
-
data: string |
|
|
691
|
+
data: string | ArrayBuffer;
|
|
692
692
|
|
|
693
693
|
/** Filename to include in MIME message. */
|
|
694
694
|
filename?: string;
|
|
@@ -992,7 +992,7 @@ declare namespace http {
|
|
|
992
992
|
* console.log(f.content_type);
|
|
993
993
|
* }
|
|
994
994
|
*/
|
|
995
|
-
function file(data: string |
|
|
995
|
+
function file(data: string | ArrayBuffer, filename?: string, contentType?: string): FileData;
|
|
996
996
|
|
|
997
997
|
/**
|
|
998
998
|
* Get active cookie jar.
|
k6/index.d.ts
CHANGED
|
@@ -124,11 +124,6 @@ export interface Checkers<VT> {
|
|
|
124
124
|
// === Common types ===
|
|
125
125
|
// --------------------
|
|
126
126
|
|
|
127
|
-
/**
|
|
128
|
-
* Array of numbers. The number range is from 0 to 255.
|
|
129
|
-
*/
|
|
130
|
-
export type bytes = number[];
|
|
131
|
-
|
|
132
127
|
// === JSON ===
|
|
133
128
|
// ------------
|
|
134
129
|
|
k6/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/k6",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.1",
|
|
4
4
|
"description": "TypeScript definitions for k6",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
},
|
|
61
61
|
"scripts": {},
|
|
62
62
|
"dependencies": {},
|
|
63
|
-
"typesPublisherContentHash": "
|
|
63
|
+
"typesPublisherContentHash": "51f2f592838cc27d3b1784aa8140db6d7c0e256577c0d8f960419afa871ee531",
|
|
64
64
|
"typeScriptVersion": "4.8"
|
|
65
65
|
}
|