@gatling.io/http 3.14.302 → 3.14.304

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gatling.io/http",
3
- "version": "3.14.302",
3
+ "version": "3.14.304",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://gatling.io",
6
6
  "repository": "github:gatling/gatling-js",
@@ -20,15 +20,15 @@
20
20
  "main": "target/index.js",
21
21
  "types": "target/index.d.ts",
22
22
  "dependencies": {
23
- "@gatling.io/jvm-types": "3.14.302",
24
- "@gatling.io/core": "3.14.302"
23
+ "@gatling.io/jvm-types": "3.14.304",
24
+ "@gatling.io/core": "3.14.304"
25
25
  },
26
26
  "devDependencies": {
27
- "@types/jest": "29.5.14",
28
- "jest": "29.7.0",
29
- "prettier": "3.5.3",
27
+ "@types/jest": "30.0.0",
28
+ "jest": "30.0.4",
29
+ "prettier": "3.6.2",
30
30
  "rimraf": "6.0.1",
31
- "ts-jest": "29.3.4",
31
+ "ts-jest": "29.4.0",
32
32
  "ts-node": "10.9.2",
33
33
  "typescript": "5.8.3"
34
34
  },
package/target/index.d.ts CHANGED
@@ -13,6 +13,8 @@ export * from "./protocol";
13
13
  export * from "./proxy";
14
14
  export * from "./request";
15
15
  export * from "./response";
16
+ export * from "./ws";
17
+ export * from "./sse";
16
18
  import JvmRequest = io.gatling.http.client.Request;
17
19
  import JvmResponse = io.gatling.http.response.Response;
18
20
  import JvmSession = io.gatling.javaapi.core.Session;
package/target/index.js CHANGED
@@ -32,6 +32,8 @@ __exportStar(require("./protocol"), exports);
32
32
  __exportStar(require("./proxy"), exports);
33
33
  __exportStar(require("./request"), exports);
34
34
  __exportStar(require("./response"), exports);
35
+ __exportStar(require("./ws"), exports);
36
+ __exportStar(require("./sse"), exports);
35
37
  const underlyingRequestTransform = (f) => (jvmRequest, jvmSession) => f((0, request_1.wrapRequest)(jvmRequest), (0, core_1.wrapSession)(jvmSession))._underlying;
36
38
  exports.underlyingRequestTransform = underlyingRequestTransform;
37
39
  const underlyingResponseTransform = (f) => (jvmResponse, jvmSession) => f((0, response_1.wrapResponse)(jvmResponse), (0, core_1.wrapSession)(jvmSession))._underlying;
@@ -536,6 +536,63 @@ export interface HttpProtocolBuilder extends ProtocolBuilder {
536
536
  * @returns a new HttpProtocolBuilder instance
537
537
  */
538
538
  nameInferredHtmlResourcesAfterLastPathElement(): HttpProtocolBuilder;
539
+ /**
540
+ * Define a baseUrl that will be used as a prefix for all relative WebSocket urls.
541
+ *
542
+ * @param url - the base url
543
+ * @returns a new HttpProtocolBuilder instance
544
+ */
545
+ wsBaseUrl(url: string): HttpProtocolBuilder;
546
+ /**
547
+ * Define multiple baseUrls that will be used as a prefix for all relative WebSocket urls.
548
+ * Assigned once per virtual user based on a round-robin strategy.
549
+ *
550
+ * @param urls - the base urls
551
+ * @returns a new HttpProtocolBuilder instance
552
+ */
553
+ wsBaseUrls(...urls: string[]): HttpProtocolBuilder;
554
+ /**
555
+ * Automatically reconnect disconnected WebSockets
556
+ *
557
+ * @returns a new HttpProtocolBuilder instance
558
+ */
559
+ wsReconnect(): HttpProtocolBuilder;
560
+ /**
561
+ * Define a maximum number of times a WebSocket can be automatically reconnected
562
+ *
563
+ * @param max - the limit
564
+ * @returns a new HttpProtocolBuilder instance
565
+ */
566
+ wsMaxReconnects(max: number): HttpProtocolBuilder;
567
+ /**
568
+ * Automatically reply to a TEXT frame with another TEXT frame.
569
+ *
570
+ * @param f - the function
571
+ * @returns a new HttpProtocolBuilder instance
572
+ */
573
+ wsAutoReplyTextFrame(f: (frame: string) => string): HttpProtocolBuilder;
574
+ /**
575
+ * Automatically reply to a SocketIo4 ping TEXT frame with the corresponding pong TEXT frame.
576
+ *
577
+ * @returns a new HttpProtocolBuilder instance
578
+ */
579
+ wsAutoReplySocketIo4(): HttpProtocolBuilder;
580
+ /**
581
+ * Set the max size of the buffer for unmatched/unchecked inbound WebSocket messages. 0 by
582
+ * default, meaning such messages are not buffered.
583
+ *
584
+ * @param max - the max size
585
+ * @returns a new HttpProtocolBuilder instance
586
+ */
587
+ wsUnmatchedInboundMessageBufferSize(max: number): HttpProtocolBuilder;
588
+ /**
589
+ * Set the max size of the buffer for unmatched/unchecked inbound SSE messages. 0 by default,
590
+ * meaning such messages are not buffered.
591
+ *
592
+ * @param max - the max size
593
+ * @returns a new HttpProtocolBuilder instance
594
+ */
595
+ sseUnmatchedInboundMessageBufferSize(max: number): HttpProtocolBuilder;
539
596
  /**
540
597
  * Define a Proxy to be used for all requests
541
598
  *
@@ -588,8 +645,8 @@ export interface HttpProtocolBuilder extends ProtocolBuilder {
588
645
  /**
589
646
  * Define some aliases to bypass DNS name resolution
590
647
  *
591
- * @param aliases the aliases
592
- * @return a new HttpProtocolBuilder instance
648
+ * @param aliases - the aliases
649
+ * @returns a new HttpProtocolBuilder instance
593
650
  */
594
651
  hostNameAliases(aliases: Record<string, string[]>): HttpProtocolBuilder;
595
652
  /**
@@ -108,6 +108,16 @@ const wrapHttpProtocolBuilder = (_underlying) => ({
108
108
  nameInferredHtmlResourcesAfterRelativeUrl: () => (0, exports.wrapHttpProtocolBuilder)(_underlying.nameInferredHtmlResourcesAfterRelativeUrl()),
109
109
  nameInferredHtmlResourcesAfterPath: () => (0, exports.wrapHttpProtocolBuilder)(_underlying.nameInferredHtmlResourcesAfterPath()),
110
110
  nameInferredHtmlResourcesAfterLastPathElement: () => (0, exports.wrapHttpProtocolBuilder)(_underlying.nameInferredHtmlResourcesAfterLastPathElement()),
111
+ // WebSockets part
112
+ wsBaseUrl: (url) => (0, exports.wrapHttpProtocolBuilder)(_underlying.wsBaseUrl(url)),
113
+ wsBaseUrls: (...urls) => (0, exports.wrapHttpProtocolBuilder)(_underlying.wsBaseUrls(urls)),
114
+ wsReconnect: () => (0, exports.wrapHttpProtocolBuilder)(_underlying.wsReconnect()),
115
+ wsMaxReconnects: (max) => (0, exports.wrapHttpProtocolBuilder)(_underlying.wsMaxReconnects(max)),
116
+ wsAutoReplyTextFrame: (f) => (0, exports.wrapHttpProtocolBuilder)(_underlying.wsAutoReplyTextFrame(f)),
117
+ wsAutoReplySocketIo4: () => (0, exports.wrapHttpProtocolBuilder)(_underlying.wsAutoReplySocketIo4()),
118
+ wsUnmatchedInboundMessageBufferSize: (max) => (0, exports.wrapHttpProtocolBuilder)(_underlying.wsUnmatchedInboundMessageBufferSize(max)),
119
+ // SSE Part
120
+ sseUnmatchedInboundMessageBufferSize: (max) => (0, exports.wrapHttpProtocolBuilder)(_underlying.sseUnmatchedInboundMessageBufferSize(max)),
111
121
  // Proxy part
112
122
  proxy: (proxy) => (0, exports.wrapHttpProtocolBuilder)(_underlying.proxy(proxy._underlying)),
113
123
  noProxyFor: (...hosts) => (0, exports.wrapHttpProtocolBuilder)(_underlying.noProxyFor(...hosts)),
@@ -1,10 +1,12 @@
1
1
  import { ActionBuilder, Body, CheckBuilder, Condition, Duration, Session } from "@gatling.io/core";
2
2
  import { BodyPart } from "../bodyPart";
3
3
  import { Proxy } from "../proxy";
4
+ import JvmRequestActionBuilder = io.gatling.javaapi.http.RequestActionBuilder;
5
+ import JvmRequestWithBodyActionBuilder = io.gatling.javaapi.http.RequestWithBodyActionBuilder;
4
6
  import JvmHttpRequestActionBuilder = io.gatling.javaapi.http.HttpRequestActionBuilder;
5
7
  export * from "./body";
6
8
  export * from "./request";
7
- export interface RequestWithParamsActionBuilder<T> {
9
+ export interface RequestActionBuilder<T> {
8
10
  /**
9
11
  * Set some query parameter
10
12
  *
@@ -253,6 +255,7 @@ export interface RequestWithParamsActionBuilder<T> {
253
255
  */
254
256
  signWithOAuth1(consumerKey: (session: Session) => string, clientSharedSecret: (session: Session) => string, token: (session: Session) => string, tokenSecret: (session: Session) => string): T;
255
257
  }
258
+ export declare const requestActionBuilderImpl: <T, J extends JvmRequestActionBuilder<J, any>>(jvmBuilder: J, wrap: (_underlying: J) => T) => RequestActionBuilder<T>;
256
259
  export interface RequestWithBodyActionBuilder<T> {
257
260
  /**
258
261
  * Define a request body
@@ -452,53 +455,55 @@ export interface RequestWithBodyActionBuilder<T> {
452
455
  */
453
456
  asXml(): T;
454
457
  }
455
- export interface RequestActionBuilder<T> {
458
+ export declare const requestWithBodyActionBuilderImpl: <T, J extends JvmRequestWithBodyActionBuilder<J, any>>(jvmBuilder: J, wrap: (_underlying: J) => T) => RequestWithBodyActionBuilder<T>;
459
+ export interface HttpRequestActionBuilder extends RequestWithBodyActionBuilder<HttpRequestActionBuilder>, RequestActionBuilder<HttpRequestActionBuilder>, ActionBuilder {
460
+ _underlying: JvmHttpRequestActionBuilder;
456
461
  /**
457
462
  * Apply some checks
458
463
  *
459
464
  * @param checks - the checks
460
465
  * @returns a new HttpRequestActionBuilder instance
461
466
  */
462
- check(...checks: CheckBuilder[]): T;
467
+ check(...checks: CheckBuilder[]): HttpRequestActionBuilder;
463
468
  /**
464
469
  * Apply some checks if some condition holds true
465
470
  *
466
471
  * @param condition - the condition, expressed as a function
467
472
  * @returns the next DSL step
468
473
  */
469
- checkIf(condition: string): Condition<T>;
474
+ checkIf(condition: string): Condition<HttpRequestActionBuilder>;
470
475
  /**
471
476
  * Apply some checks if some condition holds true
472
477
  *
473
478
  * @param condition - the condition, expressed as a function
474
479
  * @returns the next DSL step
475
480
  */
476
- checkIf(condition: (session: Session) => boolean): Condition<T>;
481
+ checkIf(condition: (session: Session) => boolean): Condition<HttpRequestActionBuilder>;
477
482
  /**
478
483
  * Have this request ignore the common checks defined on the HTTP protocol configuration
479
484
  *
480
485
  * @returns a new HttpRequestActionBuilder instance
481
486
  */
482
- ignoreProtocolChecks(): T;
487
+ ignoreProtocolChecks(): HttpRequestActionBuilder;
483
488
  /**
484
489
  * Have this request ignore the common checks defined on the HTTP protocol configuration
485
490
  *
486
491
  * @returns a new HttpRequestActionBuilder instance
487
492
  */
488
- silent(): T;
493
+ silent(): HttpRequestActionBuilder;
489
494
  /**
490
495
  * Instruct the reporting engine to forcefully report stats about this request, ignoring HTTP
491
496
  * protocol configuration
492
497
  *
493
498
  * @returns a new HttpRequestActionBuilder instance
494
499
  */
495
- notSilent(): T;
500
+ notSilent(): HttpRequestActionBuilder;
496
501
  /**
497
502
  * Disable automatic redirect following
498
503
  *
499
504
  * @returns a new HttpRequestActionBuilder instance
500
505
  */
501
- disableFollowRedirect(): T;
506
+ disableFollowRedirect(): HttpRequestActionBuilder;
502
507
  /**
503
508
  * Set some resources to be fetched concurrently after the main request. Next action in the
504
509
  * Scenario will be performed once all resources are fetched.
@@ -506,16 +511,13 @@ export interface RequestActionBuilder<T> {
506
511
  * @param res - the resources
507
512
  * @returns a new HttpRequestActionBuilder instance
508
513
  */
509
- resources(...res: HttpRequestActionBuilder[]): T;
514
+ resources(...res: HttpRequestActionBuilder[]): HttpRequestActionBuilder;
510
515
  /**
511
516
  * Override the default request timeout defined in gatling.conf
512
517
  *
513
518
  * @param timeout - timeout the timeout
514
519
  * @returns a new HttpRequestActionBuilder instance
515
520
  */
516
- requestTimeout(timeout: Duration): T;
517
- }
518
- export interface HttpRequestActionBuilder extends RequestWithParamsActionBuilder<HttpRequestActionBuilder>, RequestWithBodyActionBuilder<HttpRequestActionBuilder>, RequestActionBuilder<HttpRequestActionBuilder>, ActionBuilder {
519
- _underlying: JvmHttpRequestActionBuilder;
521
+ requestTimeout(timeout: Duration): HttpRequestActionBuilder;
520
522
  }
521
523
  export declare const wrapHttpRequestActionBuilder: (_underlying: JvmHttpRequestActionBuilder) => HttpRequestActionBuilder;
@@ -14,11 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.wrapHttpRequestActionBuilder = void 0;
17
+ exports.wrapHttpRequestActionBuilder = exports.requestWithBodyActionBuilderImpl = exports.requestActionBuilderImpl = void 0;
18
18
  const core_1 = require("@gatling.io/core");
19
19
  __exportStar(require("./body"), exports);
20
20
  __exportStar(require("./request"), exports);
21
- const requestWithParamsActionBuilderImpl = (jvmBuilder, wrap) => ({
21
+ const requestActionBuilderImpl = (jvmBuilder, wrap) => ({
22
22
  queryParam: (name, value) => {
23
23
  if (typeof name === "function") {
24
24
  if (typeof value === "function") {
@@ -108,6 +108,7 @@ const requestWithParamsActionBuilderImpl = (jvmBuilder, wrap) => ({
108
108
  ? jvmBuilder.signWithOAuth1((0, core_1.underlyingSessionTo)(consumerKey), (0, core_1.underlyingSessionTo)(clientSharedSecret), (0, core_1.underlyingSessionTo)(token), (0, core_1.underlyingSessionTo)(tokenSecret))
109
109
  : jvmBuilder.signWithOAuth1(consumerKey, clientSharedSecret, token, tokenSecret))
110
110
  });
111
+ exports.requestActionBuilderImpl = requestActionBuilderImpl;
111
112
  const requestWithBodyActionBuilderImpl = (jvmBuilder, wrap) => ({
112
113
  body: (body) => wrap(jvmBuilder.body(body._underlying)),
113
114
  bodyPart: (part) => wrap(jvmBuilder.bodyPart(part._underlying)),
@@ -180,24 +181,22 @@ const requestWithBodyActionBuilderImpl = (jvmBuilder, wrap) => ({
180
181
  asJson: () => wrap(jvmBuilder.asJson()),
181
182
  asXml: () => wrap(jvmBuilder.asXml())
182
183
  });
183
- const requestActionBuilderImpl = (jvmBuilder, wrap) => ({
184
- check: (...checks) => wrap(jvmBuilder.check(checks.map((c) => c._underlying))),
184
+ exports.requestWithBodyActionBuilderImpl = requestWithBodyActionBuilderImpl;
185
+ const wrapHttpRequestActionBuilder = (_underlying) => ({
186
+ _underlying,
187
+ ...(0, exports.requestActionBuilderImpl)(_underlying, exports.wrapHttpRequestActionBuilder),
188
+ ...(0, exports.requestWithBodyActionBuilderImpl)(_underlying, exports.wrapHttpRequestActionBuilder),
189
+ check: (...checks) => (0, exports.wrapHttpRequestActionBuilder)(_underlying.check(checks.map((c) => c._underlying))),
185
190
  checkIf: (condition) => (0, core_1.wrapCondition)(typeof condition === "string"
186
- ? jvmBuilder.checkIf(condition)
187
- : jvmBuilder.checkIf((0, core_1.underlyingSessionTo)(condition)), wrap),
188
- ignoreProtocolChecks: () => wrap(jvmBuilder.ignoreProtocolChecks()),
189
- silent: () => wrap(jvmBuilder.silent()),
190
- notSilent: () => wrap(jvmBuilder.notSilent()),
191
- disableFollowRedirect: () => wrap(jvmBuilder.disableFollowRedirect()),
191
+ ? _underlying.checkIf(condition)
192
+ : _underlying.checkIf((0, core_1.underlyingSessionTo)(condition)), exports.wrapHttpRequestActionBuilder),
193
+ ignoreProtocolChecks: () => (0, exports.wrapHttpRequestActionBuilder)(_underlying.ignoreProtocolChecks()),
194
+ silent: () => (0, exports.wrapHttpRequestActionBuilder)(_underlying.silent()),
195
+ notSilent: () => (0, exports.wrapHttpRequestActionBuilder)(_underlying.notSilent()),
196
+ disableFollowRedirect: () => (0, exports.wrapHttpRequestActionBuilder)(_underlying.disableFollowRedirect()),
192
197
  // TODO transformResponse: (f: (response: Response, session: Session) => Response): T =>
193
198
  // wrap(jvmBuilder.transformResponse(wrapBiCallback(underlyingResponseTransform(f))))
194
- resources: (...res) => wrap(jvmBuilder.resources(res.map((r) => r._underlying))),
195
- requestTimeout: (duration) => wrap(jvmBuilder.requestTimeout((0, core_1.toJvmDuration)(duration)))
196
- });
197
- const wrapHttpRequestActionBuilder = (_underlying) => ({
198
- _underlying,
199
- ...requestWithParamsActionBuilderImpl(_underlying, exports.wrapHttpRequestActionBuilder),
200
- ...requestWithBodyActionBuilderImpl(_underlying, exports.wrapHttpRequestActionBuilder),
201
- ...requestActionBuilderImpl(_underlying, exports.wrapHttpRequestActionBuilder)
199
+ resources: (...res) => (0, exports.wrapHttpRequestActionBuilder)(_underlying.resources(res.map((r) => r._underlying))),
200
+ requestTimeout: (duration) => (0, exports.wrapHttpRequestActionBuilder)(_underlying.requestTimeout((0, core_1.toJvmDuration)(duration)))
202
201
  });
203
202
  exports.wrapHttpRequestActionBuilder = wrapHttpRequestActionBuilder;
@@ -0,0 +1,214 @@
1
+ import { ActionBuilder, CheckBuilder, Duration, Session, SessionTo, Wrapper } from "@gatling.io/core";
2
+ import { RequestActionBuilder, RequestWithBodyActionBuilder } from "./request";
3
+ import JvmSseConnectActionBuilder = io.gatling.javaapi.http.SseConnectActionBuilder;
4
+ import JvmSseMessageCheck = io.gatling.javaapi.http.SseMessageCheck;
5
+ import JvmSseSetCheckActionBuilder = io.gatling.javaapi.http.SseSetCheckActionBuilder;
6
+ export interface SseUntypedCondition {
7
+ /**
8
+ * Define the checks to apply on inbound messages when a condition holds true.
9
+ *
10
+ * @param thenChecks - the checks
11
+ * @returns a new Text instance
12
+ */
13
+ then(...thenChecks: Array<CheckBuilder>): SseMessageCheck;
14
+ }
15
+ export interface SseTypedCondition {
16
+ /**
17
+ * Define the checks to apply when the condition holds true.
18
+ *
19
+ * @param thenChecks - the checks
20
+ * @returns a new Text instance
21
+ */
22
+ then(...thenChecks: Array<CheckBuilder>): SseMessageCheck;
23
+ }
24
+ export interface SseMessageCheck extends Wrapper<JvmSseMessageCheck> {
25
+ /**
26
+ * Define conditions that have to hold true to match inbound messages and apply the checks on them
27
+ *
28
+ * @param newMatchConditions - the conditions to match
29
+ * @returns a new SseMessageCheck instance
30
+ */
31
+ matching(...newMatchConditions: Array<CheckBuilder>): SseMessageCheck;
32
+ /**
33
+ * Define the checks to apply on inbound messages
34
+ *
35
+ * @param checks - the checks
36
+ * @returns a new SseMessageCheck instance
37
+ */
38
+ check(...checks: Array<CheckBuilder>): SseMessageCheck;
39
+ /**
40
+ * Define the checks to apply on inbound messages when a condition holds true.
41
+ *
42
+ * @param condition - a condition, expressed as a function
43
+ * @returns the next DSL step
44
+ */
45
+ checkIf(condition: (session: Session) => boolean): SseUntypedCondition;
46
+ /**
47
+ * Define the checks to apply on inbound messages when a condition holds true.
48
+ *
49
+ * @param condition - a condition, expressed as a Gatling Expression Language String
50
+ * @returns the next DSL step
51
+ */
52
+ checkIf(condition: string): SseUntypedCondition;
53
+ /**
54
+ * Define the checks to apply on inbound messages when a condition holds true.
55
+ *
56
+ * @param condition - a condition, expressed as a function that's aware of the HTTP response and the
57
+ * Session
58
+ * @returns the next DSL step
59
+ */
60
+ checkIf(condition: (response: string, session: Session) => boolean): SseTypedCondition;
61
+ }
62
+ export interface SseAwaitActionBuilderOn<T> {
63
+ /**
64
+ * Define the checks to wait on
65
+ *
66
+ * @param checks - the checks
67
+ * @returns a usable ActionBuilder
68
+ */
69
+ on(...checks: Array<SseMessageCheck>): T;
70
+ }
71
+ export interface SseAwaitActionBuilder<T> {
72
+ /**
73
+ * Boostrap a check that waits for a given duration
74
+ *
75
+ * @param timeout - the static wait duration
76
+ * @returns the next DSL step
77
+ */
78
+ await(timeout: Duration): SseAwaitActionBuilderOn<T>;
79
+ /**
80
+ * Boostrap a check that waits for a given duration
81
+ *
82
+ * @param timeout - the wait duration, expressed as a Gatling Expression Language String
83
+ * @returns the next DSL step
84
+ */
85
+ await(timeout: string): SseAwaitActionBuilderOn<T>;
86
+ /**
87
+ * Boostrap a check that waits for a given duration
88
+ *
89
+ * @param timeout - the wait duration, expressed as a function
90
+ * @returns the next DSL step
91
+ */
92
+ await(timeout: SessionTo<Duration>): SseAwaitActionBuilderOn<T>;
93
+ }
94
+ export interface SseConnectActionBuilder extends SseAwaitActionBuilder<SseConnectActionBuilder>, RequestWithBodyActionBuilder<SseConnectActionBuilder>, RequestActionBuilder<SseConnectActionBuilder>, ActionBuilder {
95
+ _underlying: JvmSseConnectActionBuilder;
96
+ }
97
+ export declare const wrapSseConnectActionBuilder: (_underlying: JvmSseConnectActionBuilder) => SseConnectActionBuilder;
98
+ export interface SseInboundMessage {
99
+ message(): string;
100
+ timestamp(): number;
101
+ }
102
+ export interface SseSetCheckActionBuilder extends SseAwaitActionBuilder<SseSetCheckActionBuilder>, ActionBuilder {
103
+ _underlying: JvmSseSetCheckActionBuilder;
104
+ }
105
+ export declare const wrapSseSetCheckActionBuilder: (_underlying: JvmSseSetCheckActionBuilder) => SseSetCheckActionBuilder;
106
+ /**
107
+ * DSL for building <a
108
+ * href="https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events">SSE</a>
109
+ * configurations
110
+ *
111
+ * <p>Immutable, so all methods return a new occurrence and leave the original unmodified.
112
+ */
113
+ export interface Sse {
114
+ /**
115
+ * Define a custom stream name so multiple SSEs for the same virtual users don't conflict
116
+ *
117
+ * @param sseName - the name, expressed as a Gatling Expression Language String
118
+ * @returns a new Sse instance
119
+ */
120
+ sseName(sseName: string): Sse;
121
+ /**
122
+ * Define a custom stream name so multiple SSEs for the same virtual users don't conflict
123
+ *
124
+ * @param sseName - the name, expressed as a function
125
+ * @returns a new Sse instance
126
+ */
127
+ sseName(sseName: (session: Session) => string): Sse;
128
+ /**
129
+ * Boostrap an action to connect the SSE with a GET request
130
+ *
131
+ * @param url - the url to connect to, expressed as a Gatling Expression Language String
132
+ * @returns the next DSL step
133
+ */
134
+ get(url: string): SseConnectActionBuilder;
135
+ /**
136
+ * Boostrap an action to connect the SSE with a POST request
137
+ *
138
+ * @param url - the url to connect to, expressed as a Gatling Expression Language String
139
+ * @returns the next DSL step
140
+ */
141
+ post(url: string): SseConnectActionBuilder;
142
+ /**
143
+ * Boostrap an action to connect the SSE with a GET request
144
+ *
145
+ * @param url - the url to connect to, expressed as a Gatling Expression Language String
146
+ * @returns the next DSL step
147
+ */
148
+ get(url: (session: Session) => string): SseConnectActionBuilder;
149
+ /**
150
+ * Boostrap an action to connect the SSE with a POST request
151
+ *
152
+ * @param url - the url to connect to, expressed as a Gatling Expression Language String
153
+ * @returns the next DSL step
154
+ */
155
+ post(url: (session: Session) => string): SseConnectActionBuilder;
156
+ /**
157
+ * Boostrap an action to set a check
158
+ *
159
+ * @returns the next DSL step
160
+ */
161
+ setCheck(): SseSetCheckActionBuilder;
162
+ /**
163
+ * Create an action to close the stream
164
+ *
165
+ * @returns an ActionBuilder
166
+ */
167
+ close(): ActionBuilder;
168
+ }
169
+ export interface SseApply {
170
+ /**
171
+ * Bootstrap a <a
172
+ * href="https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events">SSE</a> request
173
+ * configuration
174
+ *
175
+ * @param name - the SSE request name, expressed as a Gatling Expression Language String
176
+ * @param sseName - the name of the SSE stream so multiple SSE streams for the same virtual users
177
+ * don't conflict, expressed as a Gatling Expression Language String
178
+ * @returns the next DSL step
179
+ */
180
+ (name: string, sseName?: string): Sse;
181
+ }
182
+ export interface SsePrefix {
183
+ /**
184
+ * Boostrap a SSE check
185
+ *
186
+ * @param name - the name of the check
187
+ * @returns the next DSL step
188
+ */
189
+ checkMessage(name: string): SseMessageCheck;
190
+ /**
191
+ * Process the currently buffered inbound SSE messages and empty the buffer
192
+ *
193
+ * @param f - the function to process the buffered messages
194
+ * @returns an ActionBuilder
195
+ */
196
+ processUnmatchedMessages(f: (messages: Array<SseInboundMessage>, session: Session) => Session): ActionBuilder;
197
+ /**
198
+ * Process the currently buffered inbound SSE messages and empty the buffer
199
+ *
200
+ * @param sseName - the name of the SSE stream, expressed as a Gatling Expression Language String
201
+ * @param f - the function to process the buffered messages
202
+ * @returns an ActionBuilder
203
+ */
204
+ processUnmatchedMessages(sseName: string, f: (messages: Array<SseInboundMessage>, session: Session) => Session): ActionBuilder;
205
+ /**
206
+ * Process the currently buffered inbound SSE messages and empty the buffer
207
+ *
208
+ * @param sseName - the name of the SSE stream, expressed as a function
209
+ * @param f - the function to process the buffered messages
210
+ * @returns an ActionBuilder
211
+ */
212
+ processUnmatchedMessages(sseName: (session: Session) => string, f: (messages: Array<SseInboundMessage>, session: Session) => Session): ActionBuilder;
213
+ }
214
+ export declare const sse: SseApply & SsePrefix;
package/target/sse.js ADDED
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sse = exports.wrapSseSetCheckActionBuilder = exports.wrapSseConnectActionBuilder = void 0;
4
+ const core_1 = require("@gatling.io/core");
5
+ const jvm_types_1 = require("@gatling.io/jvm-types");
6
+ const request_1 = require("./request");
7
+ const wrapUntypedCondition = (_underlying) => ({
8
+ then: (...thenChecks) => wrapSseMessageCheck(_underlying.then(thenChecks.map((cb) => cb._underlying)))
9
+ });
10
+ const wrapTypedCondition = (_underlying) => ({
11
+ then: (...thenChecks) => wrapSseMessageCheck(_underlying.then(thenChecks.map((cb) => cb._underlying)))
12
+ });
13
+ const wrapSseMessageCheck = (_underlying) => ({
14
+ _underlying,
15
+ matching: (...newMatchConditions) => wrapSseMessageCheck(_underlying.matching(newMatchConditions.map((cb) => cb._underlying))),
16
+ check: (...checks) => wrapSseMessageCheck(_underlying.check(checks.map((cb) => cb._underlying))),
17
+ checkIf: (condition) => {
18
+ if (typeof condition === "string") {
19
+ return wrapUntypedCondition(_underlying.checkIf(condition));
20
+ }
21
+ else if (typeof condition === "function") {
22
+ if (condition.length === 1) {
23
+ return wrapUntypedCondition(_underlying.checkIf((0, core_1.underlyingSessionTo)(condition)));
24
+ }
25
+ else if (condition.length === 2) {
26
+ return wrapTypedCondition(_underlying.checkIf((0, core_1.underlyingXWithSessionTo)(condition)));
27
+ }
28
+ }
29
+ throw Error(`checkIf() called with invalid argument ${condition}`);
30
+ }
31
+ });
32
+ const wrapSseAwaitActionBuilderOn = (jvmOn, wrap) => ({
33
+ on: (...checks) => wrap(jvmOn.on(checks.map((c) => c._underlying)))
34
+ });
35
+ const sseAwaitActionBuilderImpl = (jvmBuilder, wrap) => ({
36
+ await: (timeout) => {
37
+ if (typeof timeout === "string") {
38
+ return wrapSseAwaitActionBuilderOn(jvmBuilder.await(timeout), wrap);
39
+ }
40
+ else if (typeof timeout === "function") {
41
+ return wrapSseAwaitActionBuilderOn(jvmBuilder.await((0, core_1.underlyingSessionToDuration)(timeout)), wrap);
42
+ }
43
+ else if ((0, core_1.isDuration)(timeout)) {
44
+ return wrapSseAwaitActionBuilderOn(jvmBuilder.await((0, core_1.toJvmDuration)(timeout)), wrap);
45
+ }
46
+ throw Error(`await() called with invalid argument ${timeout}`);
47
+ }
48
+ });
49
+ const wrapSseConnectActionBuilder = (_underlying) => ({
50
+ _underlying,
51
+ ...(0, request_1.requestActionBuilderImpl)(_underlying, exports.wrapSseConnectActionBuilder),
52
+ ...(0, request_1.requestWithBodyActionBuilderImpl)(_underlying, exports.wrapSseConnectActionBuilder),
53
+ ...sseAwaitActionBuilderImpl(_underlying, exports.wrapSseConnectActionBuilder)
54
+ });
55
+ exports.wrapSseConnectActionBuilder = wrapSseConnectActionBuilder;
56
+ const wrapSseSetCheckActionBuilder = (_underlying) => ({
57
+ _underlying,
58
+ ...sseAwaitActionBuilderImpl(_underlying, exports.wrapSseSetCheckActionBuilder)
59
+ });
60
+ exports.wrapSseSetCheckActionBuilder = wrapSseSetCheckActionBuilder;
61
+ const wrapSse = (jvmSse) => ({
62
+ sseName: (sseName) => wrapSse(typeof sseName === "function" ? jvmSse.sseName((0, core_1.underlyingSessionTo)(sseName)) : jvmSse.sseName(sseName)),
63
+ get: (url) => (0, exports.wrapSseConnectActionBuilder)(typeof url === "function" ? jvmSse.get((0, core_1.underlyingSessionTo)(url)) : jvmSse.get(url)),
64
+ post: (url) => (0, exports.wrapSseConnectActionBuilder)(typeof url === "function" ? jvmSse.post((0, core_1.underlyingSessionTo)(url)) : jvmSse.post(url)),
65
+ setCheck: () => (0, exports.wrapSseSetCheckActionBuilder)(jvmSse.setCheck()),
66
+ close: () => (0, core_1.wrapActionBuilder)(jvmSse.close())
67
+ });
68
+ const sseApply = (name, sseName) => {
69
+ // Handle overloading
70
+ const jvmSse = typeof sseName === "undefined" ? jvm_types_1.HttpDsl.sse(name) : jvm_types_1.HttpDsl.sse(name, sseName);
71
+ return wrapSse(jvmSse);
72
+ };
73
+ const jvmSsePrefix = jvm_types_1.Sse$Prefix.INSTANCE;
74
+ const ssePrefix = {
75
+ checkMessage: (name) => wrapSseMessageCheck(jvmSsePrefix.checkMessage(name)),
76
+ processUnmatchedMessages: (arg0, arg1) => {
77
+ if (arg1 !== undefined) {
78
+ // arg1 is the SseProcessUnmatchedMessagesCallback if it is defined
79
+ // arg0 is the sseName
80
+ const f = arg1;
81
+ if (typeof arg0 === "string") {
82
+ const sseName = arg0;
83
+ return (0, core_1.wrapActionBuilder)(jvmSsePrefix.processUnmatchedMessages(sseName, (0, core_1.underlyingXWithSessionToSession)(f)));
84
+ }
85
+ else if (typeof arg0 === "function") {
86
+ const sseName = arg0;
87
+ return (0, core_1.wrapActionBuilder)(jvmSsePrefix.processUnmatchedMessages((0, core_1.underlyingSessionTo)(sseName), (0, core_1.underlyingXWithSessionToSession)(f)));
88
+ }
89
+ }
90
+ else if (typeof arg0 === "function") {
91
+ // arg0 is the SseProcessUnmatchedMessagesCallback is arg1 is undefined
92
+ const f = arg0;
93
+ return (0, core_1.wrapActionBuilder)(jvmSsePrefix.processUnmatchedMessages((0, core_1.underlyingXWithSessionToSession)(f)));
94
+ }
95
+ throw Error(`processUnmatchedMessages() called with invalid arguments ${arg0}, ${arg1}`);
96
+ }
97
+ };
98
+ exports.sse = Object.assign(sseApply, ssePrefix);
package/target/ws.d.ts ADDED
@@ -0,0 +1,377 @@
1
+ import { ActionBuilder, ChainBuilder, CheckBuilder, Duration, Session, Wrapper } from "@gatling.io/core";
2
+ import { RequestActionBuilder } from "./request";
3
+ import JvmWsFrameCheckBinary = io.gatling.javaapi.http.WsFrameCheck$Binary;
4
+ import JvmWsFrameCheckText = io.gatling.javaapi.http.WsFrameCheck$Text;
5
+ /**
6
+ * DSL for building WebSocket configurations
7
+ *
8
+ * <p>Immutable, so all methods return a new occurrence and leave the original unmodified.
9
+ */
10
+ export interface Ws {
11
+ /**
12
+ * Define a custom WebSocket name so multiple WebSockets for the same virtual users don't conflict
13
+ *
14
+ * @param wsName - the name, expressed as a Gatling Expression Language String
15
+ * @returns a new Ws instance
16
+ */
17
+ wsName(wsName: string): Ws;
18
+ /**
19
+ * Define a custom WebSocket name so multiple WebSockets for the same virtual users don't conflict
20
+ *
21
+ * @param wsName - the name, expressed as a function
22
+ * @returns a new Ws instance
23
+ */
24
+ wsName(wsName: (session: Session) => string): Ws;
25
+ /**
26
+ * Boostrap an action to connect the WebSocket
27
+ *
28
+ * @param url - the url to connect to, expressed as a Gatling Expression Language String
29
+ * @returns the next DSL step
30
+ */
31
+ connect(url: string): WsConnectActionBuilder;
32
+ /**
33
+ * Boostrap an action to connect the WebSocket
34
+ *
35
+ * @param url - the url to connect to, expressed as a function
36
+ * @returns the next DSL step
37
+ */
38
+ connect(url: (session: Session) => string): WsConnectActionBuilder;
39
+ /**
40
+ * Boostrap an action to send a TEXT frame
41
+ *
42
+ * @param text - the text to send, expressed as a Gatling Expression Language String
43
+ * @returns the next DSL step
44
+ */
45
+ sendText(text: string): WsSendTextActionBuilder;
46
+ /**
47
+ * Boostrap an action to send a TEXT frame
48
+ *
49
+ * @param text - the text to send, expressed as a function
50
+ * @returns the next DSL step
51
+ */
52
+ sendText(text: (session: Session) => string): WsSendTextActionBuilder;
53
+ /**
54
+ * Boostrap an action to send a BINARY frame
55
+ *
56
+ * @param bytes - the static bytes to send
57
+ * @returns the next DSL step
58
+ */
59
+ sendBytes(bytes: number[]): WsSendBinaryActionBuilder;
60
+ /**
61
+ * Boostrap an action to send a BINARY frame
62
+ *
63
+ * @param bytes - the bytes to send, expressed as a Gatling Expression Language String
64
+ * @returns the next DSL step
65
+ */
66
+ sendBytes(bytes: string): WsSendBinaryActionBuilder;
67
+ /**
68
+ * Boostrap an action to send a BINARY frame
69
+ *
70
+ * @param bytes - the bytes to send, expressed as a function
71
+ * @returns the next DSL step
72
+ */
73
+ sendBytes(bytes: (session: Session) => number[]): WsSendBinaryActionBuilder;
74
+ /**
75
+ * Boostrap an action to send a CLOSE frame with the default 1000 status code
76
+ *
77
+ * @returns the next DSL step
78
+ */
79
+ close(): ActionBuilder;
80
+ /**
81
+ * Boostrap an action to send a CLOSE frame with specified status and reason
82
+ *
83
+ * @param statusCode - the close frame status code
84
+ * @param reason - the close frame reason
85
+ * @returns the next DSL step
86
+ */
87
+ close(statusCode: number, reason: string): ActionBuilder;
88
+ }
89
+ type WsProcessUnmatchedMessagesCallback = (messages: WsInboundMessage[], session: Session) => Session;
90
+ export interface WsPrefix {
91
+ /**
92
+ * Bootstrap a check on inbound TEXT frames
93
+ *
94
+ * @param name - the name of the check, expressed as a Gatling Expression Language String
95
+ * @returns the next DSL step
96
+ */
97
+ checkTextMessage(name: string): WsFrameCheckText;
98
+ /**
99
+ * Bootstrap a check on inbound TEXT frames
100
+ *
101
+ * @param name - the name of the check, expressed as a function
102
+ * @returns the next DSL step
103
+ */
104
+ checkTextMessage(name: (session: Session) => string): WsFrameCheckText;
105
+ /**
106
+ * Bootstrap a check on inbound BINARY frames
107
+ *
108
+ * @param name - the name of the check, expressed as a Gatling Expression Language String
109
+ * @returns the next DSL step
110
+ */
111
+ checkBinaryMessage(name: string): WsFrameCheckBinary;
112
+ /**
113
+ * Bootstrap a check on inbound BINARY frames
114
+ *
115
+ * @param name - the name of the check, expressed as a function
116
+ * @returns the next DSL step
117
+ */
118
+ checkBinaryMessage(name: (session: Session) => string): WsFrameCheckBinary;
119
+ /**
120
+ * Process the currently buffered inbound WebSocket messages and empty the buffer
121
+ *
122
+ * @param f - the function to process the buffered messages
123
+ * @returns an ActionBuilder
124
+ */
125
+ processUnmatchedMessages(f: WsProcessUnmatchedMessagesCallback): ActionBuilder;
126
+ /**
127
+ * Process the currently buffered inbound WebSocket messages and empty the buffer
128
+ *
129
+ * @param wsName - the name of the WebSocket, expressed as a Gatling Expression Language String
130
+ * @param f - the function to process the buffered messages
131
+ * @returns an ActionBuilder
132
+ */
133
+ processUnmatchedMessages(wsName: string, f: WsProcessUnmatchedMessagesCallback): ActionBuilder;
134
+ /**
135
+ * Process the currently buffered inbound WebSocket messages and empty the buffer
136
+ *
137
+ * @param wsName - the name of the WebSocket, expressed as a function
138
+ * @param f - the function to process the buffered messages
139
+ * @returns an ActionBuilder
140
+ */
141
+ processUnmatchedMessages(wsName: (session: Session) => string, f: WsProcessUnmatchedMessagesCallback): ActionBuilder;
142
+ }
143
+ export interface WsAwaitActionBuilder<T> {
144
+ /**
145
+ * Boostrap a check that waits for a given duration
146
+ *
147
+ * @param timeout - the static wait duration
148
+ * @returns the next DSL step
149
+ */
150
+ await(timeout: Duration): WsAwaitActionBuilderOn<T>;
151
+ /**
152
+ * Boostrap a check that waits for a given duration
153
+ *
154
+ * @param timeout - the wait duration, expressed as a Gatling Expression Language String
155
+ * @returns the next DSL step
156
+ */
157
+ await(timeout: string): WsAwaitActionBuilderOn<T>;
158
+ /**
159
+ * Boostrap a check that waits for a given duration
160
+ *
161
+ * @param timeout - the wait duration, expressed as a function
162
+ * @returns the next DSL step
163
+ */
164
+ await(timeout: (session: Session) => Duration): WsAwaitActionBuilderOn<T>;
165
+ }
166
+ export interface WsAwaitActionBuilderOn<T> {
167
+ /**
168
+ * Define the checks to wait on
169
+ *
170
+ * @param checks - the checks
171
+ * @returns a usable ActionBuilder
172
+ */
173
+ on(...checks: WsFrameCheck[]): T;
174
+ }
175
+ /**
176
+ * DSL for building WebSocket connect actions
177
+ *
178
+ * <p>Immutable, so all methods return a new occurrence and leave the original unmodified.
179
+ */
180
+ export interface WsConnectActionBuilder extends RequestActionBuilder<WsConnectActionBuilder>, WsAwaitActionBuilder<WsConnectActionBuilder>, ActionBuilder {
181
+ /**
182
+ * Define a WebSocket subprotocol
183
+ *
184
+ * @param sub - the subprotocol, expressed as a Gatling Expression Language String
185
+ * @returns a new WsConnectActionBuilder instance
186
+ */
187
+ subprotocol(sub: string): WsConnectActionBuilder;
188
+ /**
189
+ * Define a WebSocket subprotocol
190
+ *
191
+ * @param sub - the subprotocol, expressed as a function
192
+ * @returns a new WsConnectActionBuilder instance
193
+ */
194
+ subprotocol(sub: (session: Session) => string): WsConnectActionBuilder;
195
+ /**
196
+ * Define a chain to execute when the WebSocket gets connected or re-connected
197
+ *
198
+ * @param chain - the chain
199
+ * @returns a new WsConnectActionBuilder instance
200
+ */
201
+ onConnected(chain: ChainBuilder): WsConnectActionBuilder;
202
+ }
203
+ /**
204
+ * DSL for building actions to send TEXT frames
205
+ *
206
+ * <p>Immutable, so all methods return a new occurrence and leave the original unmodified.
207
+ */
208
+ export interface WsSendTextActionBuilder extends WsAwaitActionBuilder<WsSendTextActionBuilder>, ActionBuilder {
209
+ }
210
+ /**
211
+ * DSL for building actions to send BINARY frames
212
+ *
213
+ * <p>Immutable, so all methods return a new occurrence and leave the original unmodified.
214
+ */
215
+ export interface WsSendBinaryActionBuilder extends WsAwaitActionBuilder<WsSendBinaryActionBuilder>, ActionBuilder {
216
+ }
217
+ export type WsFrameCheck = WsFrameCheckBinary | WsFrameCheckText;
218
+ /**
219
+ * DSL for building WebSocket BINARY frames checks
220
+ *
221
+ * <p>Immutable, so all methods return a new occurrence and leave the original unmodified.
222
+ */
223
+ export interface WsFrameCheckBinary extends Wrapper<JvmWsFrameCheckBinary> {
224
+ /**
225
+ * Define conditions that have to hold true to match inbound messages and apply the checks on
226
+ * them
227
+ *
228
+ * @param newMatchConditions - the conditions to match
229
+ * @returns a new Binary instance
230
+ */
231
+ matching(...newMatchConditions: CheckBuilder[]): WsFrameCheckBinary;
232
+ /**
233
+ * Define the checks to apply on inbound messages
234
+ *
235
+ * @param checks - the checks
236
+ * @returns a new Binary instance
237
+ */
238
+ check(...checks: CheckBuilder[]): WsFrameCheckBinary;
239
+ /**
240
+ * Define the checks to apply on inbound messages when a condition holds true.
241
+ *
242
+ * @param condition - a condition, expressed as a function
243
+ * @returns the next DSL step
244
+ */
245
+ checkIf(condition: (session: Session) => boolean): WsFrameCheckBinaryUntypedCondition;
246
+ /**
247
+ * Define the checks to apply on inbound messages when a condition holds true.
248
+ *
249
+ * @param condition - a condition, expressed as a Gatling Expression Language String
250
+ * @returns the next DSL step
251
+ */
252
+ checkIf(condition: string): WsFrameCheckBinaryUntypedCondition;
253
+ /**
254
+ * Define the checks to apply on inbound messages when a condition holds true.
255
+ *
256
+ * @param condition - a condition, expressed as a function that's aware of the HTTP response and
257
+ * the Session
258
+ * @returns the next DSL step
259
+ */
260
+ checkIf(condition: (response: number[], session: Session) => boolean): WsFrameCheckBinaryTypedCondition;
261
+ /**
262
+ * Make the check silent, not logged by the reporting engine
263
+ *
264
+ * @returns a new Binary instance
265
+ */
266
+ silent(): WsFrameCheckBinary;
267
+ }
268
+ export interface WsFrameCheckBinaryUntypedCondition {
269
+ /**
270
+ * Define the checks to apply on inbound messages when a condition holds true.
271
+ *
272
+ * @param thenChecks - the checks
273
+ * @returns a new Binary instance
274
+ */
275
+ then(...thenChecks: CheckBuilder[]): WsFrameCheckBinary;
276
+ }
277
+ export interface WsFrameCheckBinaryTypedCondition {
278
+ /**
279
+ * Define the checks to apply when the condition holds true.
280
+ *
281
+ * @param thenChecks - the checks
282
+ * @returns a new Binary instance
283
+ */
284
+ then(...thenChecks: CheckBuilder[]): WsFrameCheckBinary;
285
+ }
286
+ /**
287
+ * DSL for building WebSocket TEXT frames checks
288
+ *
289
+ * <p>Immutable, so all methods return a new occurrence and leave the original unmodified.
290
+ */
291
+ export interface WsFrameCheckText extends Wrapper<JvmWsFrameCheckText> {
292
+ /**
293
+ * Define conditions that have to hold true to match inbound messages and apply the checks on
294
+ * them
295
+ *
296
+ * @param newMatchConditions - the conditions to match
297
+ * @returns a new Text instance
298
+ */
299
+ matching(...newMatchConditions: CheckBuilder[]): WsFrameCheckText;
300
+ /**
301
+ * Define the checks to apply on inbound messages
302
+ *
303
+ * @param checks - the checks
304
+ * @returns a new Text instance
305
+ */
306
+ check(...checks: CheckBuilder[]): WsFrameCheckText;
307
+ /**
308
+ * Define the checks to apply on inbound messages when a condition holds true.
309
+ *
310
+ * @param condition - a condition, expressed as a function
311
+ * @returns the next DSL step
312
+ */
313
+ checkIf(condition: (session: Session) => boolean): WsFrameCheckTextUntypedCondition;
314
+ /**
315
+ * Define the checks to apply on inbound messages when a condition holds true.
316
+ *
317
+ * @param condition - a condition, expressed as a Gatling Expression Language String
318
+ * @returns the next DSL step
319
+ */
320
+ checkIf(condition: string): WsFrameCheckTextUntypedCondition;
321
+ /**
322
+ * Define the checks to apply on inbound messages when a condition holds true.
323
+ *
324
+ * @param condition - a condition, expressed as a function that's aware of the HTTP response and
325
+ * the Session
326
+ * @returns the next DSL step
327
+ */
328
+ checkIf(condition: (response: string, session: Session) => boolean): WsFrameCheckTextTypedCondition;
329
+ /**
330
+ * Make the check silent, not logged by the reporting engine
331
+ *
332
+ * @returns a new Text instance
333
+ */
334
+ silent(): WsFrameCheckText;
335
+ }
336
+ export interface WsFrameCheckTextUntypedCondition {
337
+ /**
338
+ * Define the checks to apply on inbound messages when a condition holds true.
339
+ *
340
+ * @param thenChecks - the checks
341
+ * @returns a new Text instance
342
+ */
343
+ then(...thenChecks: CheckBuilder[]): WsFrameCheckText;
344
+ }
345
+ export interface WsFrameCheckTextTypedCondition {
346
+ /**
347
+ * Define the checks to apply when the condition holds true.
348
+ *
349
+ * @param thenChecks - the checks
350
+ * @returns a new Text instance
351
+ */
352
+ then(...thenChecks: CheckBuilder[]): WsFrameCheckText;
353
+ }
354
+ export type WsInboundMessage = WsInboundMessageBinary | WsInboundMessageText;
355
+ export interface WsInboundMessageBinary {
356
+ timestamp(): number;
357
+ message(): number[];
358
+ }
359
+ export declare const isWsInboundMessageBinary: (message: WsInboundMessage) => message is WsInboundMessageBinary;
360
+ export interface WsInboundMessageText {
361
+ timestamp(): number;
362
+ message(): string;
363
+ }
364
+ export declare const isWsInboundMessageText: (message: WsInboundMessage) => message is WsInboundMessageText;
365
+ export interface WsApply {
366
+ /**
367
+ * Bootstrap a WebSocket request configuration
368
+ *
369
+ * @param name - the WebSocket request name, expressed as a Gatling Expression Language String
370
+ * @param wsName - the name of the WebSocket so multiple WebSockets for the same virtual users don't
371
+ * conflict, expressed as a Gatling Expression Language String
372
+ * @returns the next DSL step
373
+ */
374
+ (name: string, wsName?: string): Ws;
375
+ }
376
+ export declare const ws: WsApply & WsPrefix;
377
+ export {};
package/target/ws.js ADDED
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ws = exports.isWsInboundMessageText = exports.isWsInboundMessageBinary = void 0;
4
+ const core_1 = require("@gatling.io/core");
5
+ const jvm_types_1 = require("@gatling.io/jvm-types");
6
+ const request_1 = require("./request");
7
+ const jvmWsPrefix = jvm_types_1.Ws$Prefix.INSTANCE;
8
+ const wsPrefix = {
9
+ checkBinaryMessage: (name) => wrapWsFrameCheckBinary(typeof name === "function"
10
+ ? jvmWsPrefix.checkBinaryMessage((0, core_1.underlyingSessionTo)(name))
11
+ : jvmWsPrefix.checkBinaryMessage(name)),
12
+ checkTextMessage: (name) => wrapWsFrameCheckText(typeof name === "function"
13
+ ? jvmWsPrefix.checkTextMessage((0, core_1.underlyingSessionTo)(name))
14
+ : jvmWsPrefix.checkTextMessage(name)),
15
+ processUnmatchedMessages: (arg0, arg1) => {
16
+ if (arg1 !== undefined) {
17
+ // arg1 is the WsProcessUnmatchedMessagesCallback if it is defined
18
+ // arg0 is the sseName
19
+ const f = arg1;
20
+ if (typeof arg0 === "string") {
21
+ const sseName = arg0;
22
+ return (0, core_1.wrapActionBuilder)(jvmWsPrefix.processUnmatchedMessages(sseName, (0, core_1.underlyingXWithSessionToSession)(f)));
23
+ }
24
+ else if (typeof arg0 === "function") {
25
+ const sseName = arg0;
26
+ return (0, core_1.wrapActionBuilder)(jvmWsPrefix.processUnmatchedMessages((0, core_1.underlyingSessionTo)(sseName), (0, core_1.underlyingXWithSessionToSession)(f)));
27
+ }
28
+ }
29
+ else if (typeof arg0 === "function") {
30
+ // arg0 is the SseProcessUnmatchedMessagesCallback if arg1 is undefined
31
+ const f = arg0;
32
+ return (0, core_1.wrapActionBuilder)(jvmWsPrefix.processUnmatchedMessages((0, core_1.underlyingXWithSessionToSession)(f)));
33
+ }
34
+ throw Error(`processUnmatchedMessages() called with invalid arguments ${arg0}, ${arg1}`);
35
+ }
36
+ };
37
+ const wsAwaitActionBuilderImpl = (jvmBuilder, wrap) => ({
38
+ await: (timeout) => wrapWsAwaitActionBuilderOn((0, core_1.isDuration)(timeout)
39
+ ? jvmBuilder.await((0, core_1.toJvmDuration)(timeout))
40
+ : typeof timeout === "function"
41
+ ? jvmBuilder.await((0, core_1.underlyingSessionToDuration)(timeout))
42
+ : jvmBuilder.await(timeout), wrap)
43
+ });
44
+ const wrapWsAwaitActionBuilderOn = (jvmOn, wrap) => ({
45
+ on: (...checks) => wrap(jvmOn.on(checks.map((c) => c._underlying)))
46
+ });
47
+ const wrapWsConnectActionBuilder = (_underlying) => ({
48
+ _underlying,
49
+ subprotocol: (sub) => wrapWsConnectActionBuilder(typeof sub === "function" ? _underlying.subprotocol((0, core_1.underlyingSessionTo)(sub)) : _underlying.subprotocol(sub)),
50
+ onConnected: (chain) => wrapWsConnectActionBuilder(_underlying.onConnected(chain._underlying)),
51
+ ...(0, request_1.requestActionBuilderImpl)(_underlying, wrapWsConnectActionBuilder),
52
+ ...wsAwaitActionBuilderImpl(_underlying, wrapWsConnectActionBuilder)
53
+ });
54
+ const wrapWsSendTextActionBuilder = (_underlying) => ({
55
+ _underlying,
56
+ ...wsAwaitActionBuilderImpl(_underlying, wrapWsSendTextActionBuilder)
57
+ });
58
+ const wrapWsSendBinaryActionBuilder = (_underlying) => ({
59
+ _underlying,
60
+ ...wsAwaitActionBuilderImpl(_underlying, wrapWsSendBinaryActionBuilder)
61
+ });
62
+ const wrapWsFrameCheckBinary = (_underlying) => ({
63
+ _underlying,
64
+ matching: (...newMatchConditions) => wrapWsFrameCheckBinary(_underlying.check(newMatchConditions.map((cb) => cb._underlying))),
65
+ check: (...checks) => wrapWsFrameCheckBinary(_underlying.check(checks.map((cb) => cb._underlying))),
66
+ checkIf: (condition) => {
67
+ if (typeof condition === "function") {
68
+ if (condition.length === 1) {
69
+ return wrapWsFrameCheckBinaryUntypedCondition(_underlying.checkIf((0, core_1.underlyingSessionTo)(condition)));
70
+ }
71
+ else {
72
+ return wrapWsFrameCheckBinaryTypedCondition(_underlying.checkIf((0, core_1.underlyingXWithSessionTo)(condition)));
73
+ }
74
+ }
75
+ else {
76
+ return wrapWsFrameCheckBinaryUntypedCondition(_underlying.checkIf(condition));
77
+ }
78
+ },
79
+ silent: () => wrapWsFrameCheckBinary(_underlying.silent())
80
+ });
81
+ const wrapWsFrameCheckBinaryUntypedCondition = (_underlying) => ({
82
+ then: (...thenChecks) => wrapWsFrameCheckBinary(_underlying.then(thenChecks.map((cb) => cb._underlying)))
83
+ });
84
+ const wrapWsFrameCheckBinaryTypedCondition = (_underlying) => ({
85
+ then: (...thenChecks) => wrapWsFrameCheckBinary(_underlying.then(thenChecks.map((cb) => cb._underlying)))
86
+ });
87
+ const wrapWsFrameCheckText = (_underlying) => ({
88
+ _underlying,
89
+ matching: (...newMatchConditions) => wrapWsFrameCheckText(_underlying.check(newMatchConditions.map((cb) => cb._underlying))),
90
+ check: (...checks) => wrapWsFrameCheckText(_underlying.check(checks.map((cb) => cb._underlying))),
91
+ checkIf: (condition) => {
92
+ if (typeof condition === "function") {
93
+ if (condition.length === 1) {
94
+ return wrapWsFrameCheckTextUntypedCondition(_underlying.checkIf((0, core_1.underlyingSessionTo)(condition)));
95
+ }
96
+ else {
97
+ return wrapWsFrameCheckTextTypedCondition(_underlying.checkIf((0, core_1.underlyingXWithSessionTo)(condition)));
98
+ }
99
+ }
100
+ else {
101
+ return wrapWsFrameCheckTextUntypedCondition(_underlying.checkIf(condition));
102
+ }
103
+ },
104
+ silent: () => wrapWsFrameCheckText(_underlying.silent())
105
+ });
106
+ const wrapWsFrameCheckTextUntypedCondition = (_underlying) => ({
107
+ then: (...thenChecks) => wrapWsFrameCheckText(_underlying.then(thenChecks.map((cb) => cb._underlying)))
108
+ });
109
+ const wrapWsFrameCheckTextTypedCondition = (_underlying) => ({
110
+ then: (...thenChecks) => wrapWsFrameCheckText(_underlying.then(thenChecks.map((cb) => cb._underlying)))
111
+ });
112
+ const isWsInboundMessageBinary = (message) => typeof message.message() !== "string";
113
+ exports.isWsInboundMessageBinary = isWsInboundMessageBinary;
114
+ const isWsInboundMessageText = (message) => typeof message.message() === "string";
115
+ exports.isWsInboundMessageText = isWsInboundMessageText;
116
+ const wrapWs = (jvmWs) => ({
117
+ wsName: (wsName) => wrapWs(typeof wsName === "function" ? jvmWs.wsName((0, core_1.underlyingSessionTo)(wsName)) : jvmWs.wsName(wsName)),
118
+ connect: (url) => wrapWsConnectActionBuilder(typeof url === "function" ? jvmWs.connect((0, core_1.underlyingSessionTo)(url)) : jvmWs.connect(url)),
119
+ sendText: (text) => wrapWsSendTextActionBuilder(typeof text === "function" ? jvmWs.sendText((0, core_1.underlyingSessionTo)(text)) : jvmWs.sendText(text)),
120
+ sendBytes: (bytes) => wrapWsSendBinaryActionBuilder(typeof bytes === "function"
121
+ ? jvmWs.sendBytes((0, core_1.underlyingSessionTo)(bytes))
122
+ : typeof bytes === "string"
123
+ ? jvmWs.sendBytes(bytes)
124
+ : jvmWs.sendBytes(bytes)),
125
+ close: () => (0, core_1.wrapActionBuilder)(jvmWs.close())
126
+ });
127
+ const wsApply = (name, wsName) => {
128
+ const jvmWs = wsName === undefined ? jvm_types_1.HttpDsl.ws(name) : jvm_types_1.HttpDsl.ws(name, wsName);
129
+ return wrapWs(jvmWs);
130
+ };
131
+ exports.ws = Object.assign(wsApply, wsPrefix);