import { ActionBuilder, CheckBuilder, Duration, Session, SessionTo, Wrapper } from "@gatling.io/core"; import { RequestActionBuilder, RequestWithBodyActionBuilder } from "./request"; import JvmSseConnectActionBuilder = io.gatling.javaapi.http.SseConnectActionBuilder; import JvmSseMessageCheck = io.gatling.javaapi.http.SseMessageCheck; import JvmSseSetCheckActionBuilder = io.gatling.javaapi.http.SseSetCheckActionBuilder; export interface SseUntypedCondition { /** * Define the checks to apply on inbound messages when a condition holds true. * * @param thenChecks - the checks * @returns a new Text instance */ then(...thenChecks: Array): SseMessageCheck; } export interface SseTypedCondition { /** * Define the checks to apply when the condition holds true. * * @param thenChecks - the checks * @returns a new Text instance */ then(...thenChecks: Array): SseMessageCheck; } export interface SseMessageCheck extends Wrapper { /** * Define conditions that have to hold true to match inbound messages and apply the checks on them * * @param newMatchConditions - the conditions to match * @returns a new SseMessageCheck instance */ matching(...newMatchConditions: Array): SseMessageCheck; /** * Define the checks to apply on inbound messages * * @param checks - the checks * @returns a new SseMessageCheck instance */ check(...checks: Array): SseMessageCheck; /** * Define the checks to apply on inbound messages when a condition holds true. * * @param condition - a condition, expressed as a function * @returns the next DSL step */ checkIf(condition: (session: Session) => boolean): SseUntypedCondition; /** * Define the checks to apply on inbound messages when a condition holds true. * * @param condition - a condition, expressed as a Gatling Expression Language String * @returns the next DSL step */ checkIf(condition: string): SseUntypedCondition; /** * Define the checks to apply on inbound messages when a condition holds true. * * @param condition - a condition, expressed as a function that's aware of the HTTP response and the * Session * @returns the next DSL step */ checkIf(condition: (response: string, session: Session) => boolean): SseTypedCondition; } export interface SseAwaitActionBuilderOn { /** * Define the checks to wait on * * @param checks - the checks * @returns a usable ActionBuilder */ on(...checks: Array): T; } export interface SseAwaitActionBuilder { /** * Boostrap a check that waits for a given duration * * @param timeout - the static wait duration * @returns the next DSL step */ await(timeout: Duration): SseAwaitActionBuilderOn; /** * Boostrap a check that waits for a given duration * * @param timeout - the wait duration, expressed as a Gatling Expression Language String * @returns the next DSL step */ await(timeout: string): SseAwaitActionBuilderOn; /** * Boostrap a check that waits for a given duration * * @param timeout - the wait duration, expressed as a function * @returns the next DSL step */ await(timeout: SessionTo): SseAwaitActionBuilderOn; } export interface SseConnectActionBuilder extends SseAwaitActionBuilder, RequestWithBodyActionBuilder, RequestActionBuilder, ActionBuilder { _underlying: JvmSseConnectActionBuilder; } export interface SseSetCheckActionBuilder extends SseAwaitActionBuilder, ActionBuilder { _underlying: JvmSseSetCheckActionBuilder; } /** * DSL for building SSE * configurations * *

Immutable, so all methods return a new occurrence and leave the original unmodified. */ export interface Sse { /** * Define a custom stream name so multiple SSEs for the same virtual users don't conflict * * @param sseName - the name, expressed as a Gatling Expression Language String * @returns a new Sse instance */ sseName(sseName: string): Sse; /** * Define a custom stream name so multiple SSEs for the same virtual users don't conflict * * @param sseName - the name, expressed as a function * @returns a new Sse instance */ sseName(sseName: (session: Session) => string): Sse; /** * Boostrap an action to connect the SSE with a GET request * * @param url - the url to connect to, expressed as a Gatling Expression Language String * @returns the next DSL step */ get(url: string): SseConnectActionBuilder; /** * Boostrap an action to connect the SSE with a POST request * * @param url - the url to connect to, expressed as a Gatling Expression Language String * @returns the next DSL step */ post(url: string): SseConnectActionBuilder; /** * Boostrap an action to connect the SSE with a GET request * * @param url - the url to connect to, expressed as a Gatling Expression Language String * @returns the next DSL step */ get(url: (session: Session) => string): SseConnectActionBuilder; /** * Boostrap an action to connect the SSE with a POST request * * @param url - the url to connect to, expressed as a Gatling Expression Language String * @returns the next DSL step */ post(url: (session: Session) => string): SseConnectActionBuilder; /** * Boostrap an action to set a check * * @returns the next DSL step */ setCheck(): SseSetCheckActionBuilder; /** * Create an action to close the stream * * @returns an ActionBuilder */ close(): ActionBuilder; } export interface SseApply { /** * Bootstrap a SSE request * configuration * * @param name - the SSE request name, expressed as a Gatling Expression Language String * @param sseName - the name of the SSE stream so multiple SSE streams for the same virtual users * don't conflict, expressed as a Gatling Expression Language String * @returns the next DSL step */ (name: string, sseName?: string): Sse; } export interface SseInboundMessage { message(): string; timestamp(): number; } export interface SsePrefix { /** * Boostrap a SSE check * * @param name - the name of the check * @returns the next DSL step */ checkMessage(name: string): SseMessageCheck; /** * Process the currently buffered inbound SSE messages and empty the buffer * * @param f - the function to process the buffered messages * @returns an ActionBuilder */ processUnmatchedMessages(f: (messages: Array, session: Session) => Session): ActionBuilder; /** * Process the currently buffered inbound SSE messages and empty the buffer * * @param sseName - the name of the SSE stream, expressed as a Gatling Expression Language String * @param f - the function to process the buffered messages * @returns an ActionBuilder */ processUnmatchedMessages(sseName: string, f: (messages: Array, session: Session) => Session): ActionBuilder; /** * Process the currently buffered inbound SSE messages and empty the buffer * * @param sseName - the name of the SSE stream, expressed as a function * @param f - the function to process the buffered messages * @returns an ActionBuilder */ processUnmatchedMessages(sseName: (session: Session) => string, f: (messages: Array, session: Session) => Session): ActionBuilder; } export declare const sse: SseApply & SsePrefix;