mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* k6: Document fail * k6: Remove docs link Complete docs are included in the doc comment. * k6: Document group * k6: Document sleep * k6: Order signature docs before remarks Renders more usefully in Visual Studio Code. * k6: Document check * k6: Space documented declarations * k6: Space section headers * k6: Document method releases * k6: Simplify check documentation * k6: Simplify fail documentation * k6: Simplify group documentation * k6: Document package * k6: Compress documentation * k6: Document Checker * k6: Document Checkers * k6: Link to check docs * k6: Link to fail docs * k6: Link to group docs * k6: Link to sleep docs * k6: Correct returns tag * k6: Document check type param * k6: Document group return type * k6: Document byte * k6: Document bytes * k6: Document JSON types * k6: Configure API Extractor Enables validating docs with: mkdir -p etc; api-extractor run -c api-extractor.json -l * k6: Ignore docs build * k6: Document doc comment validation * k6: Disable API report generation * k6: Disable doc model generation * k6: Disable .d.ts rollup generation * k6: Disable TSDoc metadata generation * k6: Document typeParam tag warnings * k6/global: Document module * k6/global: Normalize section comments * k6/global: Document open * k6/global: Document __ENV * k6/global: Refine __ENV type * k6/global: Document __VU * k6/global: Document __ITER * k6/global: Document console * k6/global: Normalize VU logic references * k6: Improve section header visibility * k6/crypto: Document module * k6/crypto: Document randomBytes * k6/crypto: Document hmac * k6/crypto: Document md4 * k6/crypto: Document md5 * k6/crypto: Document sha1 * k6/crypto: Document sha256 * k6/crypto: Document sha384 * k6/crypto: Document sha512 * k6/crypto: Document sha512_224 * k6/crypto: Document sha512_256 * k6/crypto: Document ripemd160 * k6/crypto: Document createHash * k6/crypto: Document createHMAC * k6/crypto: Link to createHash docs * k6/crypto: Document Algorithm * k6/crypto: Document StringEncoding * k6/crypto: Document BinaryEncoding * k6/crypto: Document OutputEncoding * k6/crypto: Document Output * k6/crypto: Document Hasher * k6/crypto: Document Hasher#update * k6/crypto: Document Hasher#digest * k6/crypto: Update formatting Repo formatter really wants it this way. * k6/encoding: Document module * k6/encoding: Document b64encode * k6/encoding: Document b64decode * k6/encoding: Document Base64Variant * k6/html: Document module * k6/html: Document parseHTML * k6/html: Add section headers * k6/html: Document Selection * k6: Disable redundant JSDoc check Incorrectly applies to our TSDoc doc comments. * k6/global: Add missing semicolon * k6/global: Correct test * k6/html: Update tests * k6/html: Accept overloads for documentation The overloads in these cases produce more natural IntelliSense rendering of the documentation. * k6/html: Document FormValue * k6/html: Document Tester * k6/html: Document Handler * k6/html: Document Mapper * k6/html: Qualify FormValue description * k6/html: Normalize section header language * k6/html: Document Attribute * k6/html: Document NodeType * k6/html: Document Element * k6/html: Document AnchorElement * k6/html: Document AreaElement * k6/html: Link to Element docs * k6/html: Document AudioElement * k6/html: Document BaseElement * k6/html: Document ButtonElement * k6/html: Document CanvasElement * k6/html: Document DataElement * k6/html: Document DataListElement * k6/html: Document DelElement * k6/html: Document EmbedElement * k6/html: Document FieldSetElement * k6/html: Document FormElement * k6/html: Document FormFieldElement * k6/html: Document HrefElement * k6/html: Document IFrameElement * k6/html: Document ImageElement * k6/html: Document InputElement * k6/html: Document InsElement * k6/html: Document KeygenElement * k6/html: Document LabelElement * k6/html: Document LegendElement * k6/html: Document LiElement * k6/html: Document LinkElement * k6/html: Document MapElement * k6/html: Document MediaElement * k6/html: Document MetaElement * k6/html: Document MeterElement * k6/html: Document ModElement * k6/html: Document ObjectElement * k6/html: Document OListElement * k6/html: Document OptGroupElement * k6/html: Document OptionElement * k6/html: Document OutputElement * k6/html: Document ParamElement * k6/html: Document PreElement * k6/html: Document ProgressElement * k6/html: QuoteElement * k6/html: Document ScriptElement * k6/html: Document SelectElement * k6/html: Document SourceElement * k6/html: Document StyleElement * k6/html: Document TableBodyElement * k6/html: Document TableCellElement * k6/html: Document TableColElement * k6/html: Document TableDataCellElement * k6/html: Document TableElement * k6/html: Document TableFootElement * k6/html: Document TableHeadElement * k6/html: Document TableHeaderCellElement * k6/html: Document TableRowElement * k6/html: Document TableSectionElement * k6/html: Document TextAreaElement * k6/html: Document TimeElement * k6/html: Document TitleElement * k6/html: Document TrackElement * k6/html: Correct MediaElement#textTracks return type * k6/html: Document UListElement * k6/html: Document VideoElement * k6/html: Update HrefElement test * k6/http: Document module * k6/http: Add section headers * k6/http: Normalize refined params type name * k6/http: Normalize refined batch request type names * k6/http: Remove generics justification * k6/http: Document del * k6/http: Document get * k6/http: Document options * k6/http: Document patch * k6/http: Document post * k6/http: Document put * k6/http: Document request * k6/http: Document batch * k6/http: Document file * k6/http: Document cookieJar * k6/http: Include release tags * k6/http: Document Params * k6/http: Document RefinedParams * k6/http: Document AuthMethod * k6/http: Document ResponseType * k6/http: Document ParamsCookieValue * k6/http: Document RequestBody * k6/http: Document StructuredRequestBody * k6/http: Document batch request types * k6/http: Document refined batch request types * k6/http: Document BatchResponses * k6/http: Document Response properties * k6/http: Document Response.html * k6/http: Document Response.json * k6/http: Document Response.clickLink * k6/http: Document Response.submitForm * k6/http: Define SSL/TLS version constants * k6/http: Define OCSP status constants * k6/http: Document OCSP reason constants * k6/http: Define CipherSuite * k6/http: Document Protocol * k6/http: Document CipherSuite * k6/http: Document RefinedResponse * k6/http: Document ResponseBody * k6/http: Document RefinedResponseBody * k6/http: Document RequestCookie * k6/http: Document ResponseCookie * k6/http: Correct Unix time specifications * k6/http: Document FileData * k6/http: Accept formatter changes * k6/http: Link to FileData docs * k6/http: Accept formatter changes * k6/http: Document CookieJar * k6/http: Document CookieJarCookies * k6/http: CookieOptions * k6/metrics: Document module * k6/metrics: Document Metric * k6/metrics: Document Counter * k6/metrics: Document Gauge * k6/metrics: Document Rate * k6/metrics: Document Trend * k6/ws: Document module * k6/ws: Add section headers * k6/ws: Document connect * k6/ws: Document Params * k6/ws: Document Executor * k6/ws: Document Response * k6/ws: Document Socket * k6/ws: Document EventType * k6/ws: Document TimerHandler * k6/ws: Document event handlers * k6/ws: Document WebSocketError * k6/options: Document module * k6/options: Document Options * k6/options: Document CollectorOptions * k6/options: Document Stage * k6/options: Document threshold specifications * k6/options: Document Certificate * k6: Remove API Extractor config No obvious way to get the repo test to accept it. To be restored when an approach is discovered.
234 lines
4.6 KiB
TypeScript
234 lines
4.6 KiB
TypeScript
/*
|
|
* WebSocket client.
|
|
* https://docs.k6.io/docs/k6-websocket-api
|
|
*/
|
|
|
|
// === Main ===
|
|
// ------------
|
|
|
|
/**
|
|
* Open WebSocket connection.
|
|
* https://docs.k6.io/docs/connect-url-params-func
|
|
* @param url - Request URL.
|
|
* @param callback - Logic to execute with socket.
|
|
* @returns HTTP response to connection request.
|
|
* @public
|
|
*/
|
|
export function connect(url: string, callback: Executor): Response;
|
|
|
|
/**
|
|
* Open WebSocket connection.
|
|
* https://docs.k6.io/docs/connect-url-params-func
|
|
* @param url - Request URL.
|
|
* @param params - Request parameters.
|
|
* @param callback - Logic to execute with socket.
|
|
* @returns HTTP response to connection request.
|
|
* @public
|
|
*/
|
|
export function connect(url: string, params: Params | null, callback: Executor): Response;
|
|
|
|
// === Parameters ===
|
|
// ------------------
|
|
|
|
/**
|
|
* Request parameters.
|
|
* @public
|
|
*/
|
|
export interface Params {
|
|
/** Request headers. */
|
|
headers?: { [name: string]: string };
|
|
|
|
/** Response time metric tags. */
|
|
tags?: { [name: string]: string };
|
|
}
|
|
|
|
/**
|
|
* Socket executor.
|
|
* @public
|
|
*/
|
|
export interface Executor {
|
|
/** @param socket - The opened socket. */
|
|
(socket: Socket): void;
|
|
}
|
|
|
|
// === Response ===
|
|
// ----------------
|
|
|
|
/**
|
|
* HTTP response to connection request.
|
|
* @public
|
|
*/
|
|
export interface Response {
|
|
/** Fetched URL. May differ from request URL due to redirects. */
|
|
url: string;
|
|
|
|
/** HTTP status code. */
|
|
status: number;
|
|
|
|
/** Response headers. */
|
|
headers: { [name: string]: string };
|
|
|
|
/** Response body. */
|
|
body: string;
|
|
|
|
/** Non-HTTP error message. */
|
|
error: string;
|
|
}
|
|
|
|
// === Socket ===
|
|
// --------------
|
|
|
|
/**
|
|
* Created socket.
|
|
* https://docs.k6.io/docs/socket
|
|
* @public
|
|
*/
|
|
export abstract class Socket {
|
|
protected __brand: never;
|
|
|
|
/**
|
|
* Close connection.
|
|
* https://docs.k6.io/docs/socketclose
|
|
* @param code - WebSocket status code.
|
|
*/
|
|
close(code?: number): void;
|
|
|
|
/**
|
|
* Listen to event.
|
|
* https://docs.k6.io/docs/socketon
|
|
* @param event - Event type.
|
|
* @param handler - Event handler.
|
|
*/
|
|
on<ET extends EventType>(event: ET, handler: EventHandler<ET>): void;
|
|
|
|
/**
|
|
* Send ping.
|
|
* https://docs.k6.io/docs/socketping
|
|
*/
|
|
ping(): void;
|
|
|
|
/**
|
|
* Send data.
|
|
* https://docs.k6.io/docs/socketsend
|
|
* @param data - Data to send.
|
|
*/
|
|
send(data: string): void;
|
|
|
|
/**
|
|
* Call a function repeatedly, while the WebSocket connection is open.
|
|
* https://docs.k6.io/docs/socketsetinterval
|
|
* @param handler - The function to call every `interval` milliseconds.
|
|
* @param interval - Milliseconds between two calls to `callback`.
|
|
*/
|
|
setInterval(handler: TimerHandler, interval: number): void;
|
|
|
|
/**
|
|
* Call a function at a later time,
|
|
* if the WebSocket connection is still open then.
|
|
* https://docs.k6.io/docs/socketsettimeout
|
|
* @param handler - The function to call when `delay` has expired.
|
|
* @param delay - Delay in milliseconds.
|
|
*/
|
|
setTimeout(handler: TimerHandler, delay: number): void;
|
|
}
|
|
|
|
/**
|
|
* Event type.
|
|
* @public
|
|
*/
|
|
export type EventType = 'close' | 'error' | 'message' | 'open' | 'ping' | 'pong';
|
|
|
|
/**
|
|
* Timer handler.
|
|
* @public
|
|
*/
|
|
export interface TimerHandler {
|
|
(): void;
|
|
}
|
|
|
|
// === Event handlers ===
|
|
// ----------------------
|
|
|
|
/**
|
|
* Event handler. Signature varies with event type.
|
|
* @public
|
|
*/
|
|
export type EventHandler<ET extends EventType> = ET extends 'close'
|
|
? CloseEventHandler
|
|
: ET extends 'error'
|
|
? ErrorEventHandler
|
|
: ET extends 'message'
|
|
? MessageEventHandler
|
|
: ET extends 'open'
|
|
? OpenEventHandler
|
|
: ET extends 'ping'
|
|
? PingEventHandler
|
|
: ET extends 'pong'
|
|
? PongEventHandler
|
|
: never;
|
|
|
|
/**
|
|
* Close event handler.
|
|
* @public
|
|
*/
|
|
export interface CloseEventHandler {
|
|
/** @param code - WebSocket status code. */
|
|
(code: number): void;
|
|
}
|
|
|
|
/**
|
|
* Error event handler.
|
|
* @public
|
|
*/
|
|
export interface ErrorEventHandler {
|
|
/** @param error - Error object. */
|
|
(error: WebSocketError): void;
|
|
}
|
|
|
|
/**
|
|
* Message event handler.
|
|
* @public
|
|
*/
|
|
export interface MessageEventHandler {
|
|
/** @param message - Message. */
|
|
(message: string): void;
|
|
}
|
|
|
|
/**
|
|
* Open event handler.
|
|
* @public
|
|
*/
|
|
export interface OpenEventHandler {
|
|
(): void;
|
|
}
|
|
|
|
/**
|
|
* Ping event handler.
|
|
* @public
|
|
*/
|
|
export interface PingEventHandler {
|
|
(): void;
|
|
}
|
|
|
|
/**
|
|
* Pong event handler.
|
|
* @public
|
|
*/
|
|
export interface PongEventHandler {
|
|
(): void;
|
|
}
|
|
|
|
// === Error ===
|
|
// -------------
|
|
|
|
/**
|
|
* Error.
|
|
* @public
|
|
*/
|
|
export abstract class WebSocketError {
|
|
protected __brand: never;
|
|
|
|
/** Error message. */
|
|
error(): string;
|
|
}
|