@@ -6,19 +6,19 @@ import { Headers, CompletedRequest, Method, MockedEndpoint, Trailers } from "../
66import type { RequestRuleData } from "./request-rule" ;
77
88import {
9- SimpleHandlerDefinition ,
10- PassThroughHandlerDefinition ,
11- CallbackHandlerDefinition ,
9+ SimpleStepDefinition ,
10+ PassThroughStepDefinition ,
11+ CallbackStepDefinition ,
1212 CallbackResponseResult ,
13- StreamHandlerDefinition ,
14- CloseConnectionHandlerDefinition ,
15- TimeoutHandlerDefinition ,
16- PassThroughHandlerOptions ,
17- FileHandlerDefinition ,
18- JsonRpcResponseHandlerDefinition ,
19- ResetConnectionHandlerDefinition ,
13+ StreamStepDefinition ,
14+ CloseConnectionStepDefinition ,
15+ TimeoutStepDefinition ,
16+ PassThroughStepOptions ,
17+ FileStepDefinition ,
18+ JsonRpcResponseStepDefinition ,
19+ ResetConnectionStepDefinition ,
2020 CallbackResponseMessageResult
21- } from "./request-handler -definitions" ;
21+ } from "./request-step -definitions" ;
2222import { byteLength } from "../../util/util" ;
2323import { BaseRuleBuilder } from "../base-rule-builder" ;
2424import { MethodMatcher , RegexPathMatcher , SimplePathMatcher , WildcardMatcher } from "../matchers" ;
@@ -141,13 +141,13 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
141141
142142 const rule : RequestRuleData = {
143143 ...this . buildBaseRuleData ( ) ,
144- handler : new SimpleHandlerDefinition (
144+ steps : [ new SimpleStepDefinition (
145145 status ,
146146 statusMessage ,
147147 data ,
148148 headers ,
149149 trailers
150- )
150+ ) ]
151151 } ;
152152
153153 return this . addRule ( rule ) ;
@@ -184,7 +184,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
184184
185185 const rule : RequestRuleData = {
186186 ...this . buildBaseRuleData ( ) ,
187- handler : new SimpleHandlerDefinition ( status , undefined , jsonData , headers )
187+ steps : [ new SimpleStepDefinition ( status , undefined , jsonData , headers ) ]
188188 } ;
189189
190190 return this . addRule ( rule ) ;
@@ -218,7 +218,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
218218 ) : Promise < MockedEndpoint > {
219219 const rule : RequestRuleData = {
220220 ...this . buildBaseRuleData ( ) ,
221- handler : new CallbackHandlerDefinition ( callback )
221+ steps : [ new CallbackStepDefinition ( callback ) ]
222222 }
223223
224224 return this . addRule ( rule ) ;
@@ -247,7 +247,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
247247 thenStream ( status : number , stream : Readable , headers ?: Headers ) : Promise < MockedEndpoint > {
248248 const rule : RequestRuleData = {
249249 ...this . buildBaseRuleData ( ) ,
250- handler : new StreamHandlerDefinition ( status , stream , headers )
250+ steps : [ new StreamStepDefinition ( status , stream , headers ) ]
251251 }
252252
253253 return this . addRule ( rule ) ;
@@ -296,7 +296,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
296296
297297 const rule : RequestRuleData = {
298298 ...this . buildBaseRuleData ( ) ,
299- handler : new FileHandlerDefinition ( status , statusMessage , path , headers )
299+ steps : [ new FileStepDefinition ( status , statusMessage , path , headers ) ]
300300 } ;
301301
302302 return this . addRule ( rule ) ;
@@ -308,7 +308,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
308308 * an error.
309309 *
310310 * This method takes options to configure how the request is passed
311- * through. See {@link PassThroughHandlerOptions } for the full details
311+ * through. See {@link PassThroughStepOptions } for the full details
312312 * of the options available.
313313 *
314314 * Calling this method registers the rule with the server, so it
@@ -321,10 +321,10 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
321321 *
322322 * @category Responses
323323 */
324- thenPassThrough ( options ?: PassThroughHandlerOptions ) : Promise < MockedEndpoint > {
324+ thenPassThrough ( options ?: PassThroughStepOptions ) : Promise < MockedEndpoint > {
325325 const rule : RequestRuleData = {
326326 ...this . buildBaseRuleData ( ) ,
327- handler : new PassThroughHandlerDefinition ( options )
327+ steps : [ new PassThroughStepDefinition ( options ) ]
328328 } ;
329329
330330 return this . addRule ( rule ) ;
@@ -341,7 +341,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
341341 * of the original request URL will be used instead.
342342 *
343343 * This method takes options to configure how the request is passed
344- * through. See {@link PassThroughHandlerOptions } for the full details
344+ * through. See {@link PassThroughStepOptions } for the full details
345345 * of the options available.
346346 *
347347 * Calling this method registers the rule with the server, so it
@@ -356,19 +356,19 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
356356 */
357357 async thenForwardTo (
358358 forwardToLocation : string ,
359- options : Omit < PassThroughHandlerOptions , 'forwarding' > & {
360- forwarding ?: Omit < PassThroughHandlerOptions [ 'forwarding' ] , 'targetHost' >
359+ options : Omit < PassThroughStepOptions , 'forwarding' > & {
360+ forwarding ?: Omit < PassThroughStepOptions [ 'forwarding' ] , 'targetHost' >
361361 } = { }
362362 ) : Promise < MockedEndpoint > {
363363 const rule : RequestRuleData = {
364364 ...this . buildBaseRuleData ( ) ,
365- handler : new PassThroughHandlerDefinition ( {
365+ steps : [ new PassThroughStepDefinition ( {
366366 ...options ,
367367 forwarding : {
368368 ...options . forwarding ,
369369 targetHost : forwardToLocation
370370 }
371- } )
371+ } ) ]
372372 } ;
373373
374374 return this . addRule ( rule ) ;
@@ -391,7 +391,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
391391 thenCloseConnection ( ) : Promise < MockedEndpoint > {
392392 const rule : RequestRuleData = {
393393 ...this . buildBaseRuleData ( ) ,
394- handler : new CloseConnectionHandlerDefinition ( )
394+ steps : [ new CloseConnectionStepDefinition ( ) ]
395395 } ;
396396
397397 return this . addRule ( rule ) ;
@@ -418,7 +418,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
418418 thenResetConnection ( ) : Promise < MockedEndpoint > {
419419 const rule : RequestRuleData = {
420420 ...this . buildBaseRuleData ( ) ,
421- handler : new ResetConnectionHandlerDefinition ( )
421+ steps : [ new ResetConnectionStepDefinition ( ) ]
422422 } ;
423423
424424 return this . addRule ( rule ) ;
@@ -441,7 +441,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
441441 thenTimeout ( ) : Promise < MockedEndpoint > {
442442 const rule : RequestRuleData = {
443443 ...this . buildBaseRuleData ( ) ,
444- handler : new TimeoutHandlerDefinition ( )
444+ steps : [ new TimeoutStepDefinition ( ) ]
445445 } ;
446446
447447 return this . addRule ( rule ) ;
@@ -457,7 +457,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
457457 thenSendJsonRpcResult ( result : any ) {
458458 const rule = {
459459 ...this . buildBaseRuleData ( ) ,
460- handler : new JsonRpcResponseHandlerDefinition ( { result } )
460+ steps : [ new JsonRpcResponseStepDefinition ( { result } ) ]
461461 } ;
462462
463463 return this . addRule ( rule ) ;
@@ -473,7 +473,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
473473 thenSendJsonRpcError ( error : any ) {
474474 const rule = {
475475 ...this . buildBaseRuleData ( ) ,
476- handler : new JsonRpcResponseHandlerDefinition ( { error } )
476+ steps : [ new JsonRpcResponseStepDefinition ( { error } ) ]
477477 } ;
478478
479479 return this . addRule ( rule ) ;
0 commit comments