mockttp
Version:
Mock HTTP server for testing HTTP clients and stubbing webservices
121 lines • 6.09 kB
TypeScript
import { Writable } from 'stream';
import * as net from 'net';
import { OngoingRequest, OngoingResponse } from "../../types";
import { CustomError } from '@httptoolkit/util';
import { ClientServerChannel } from '../../serialization/serialization';
import { MockttpDeserializationOptions } from '../rule-deserialization';
import { ForwardingOptions, PassThroughLookupOptions } from '../passthrough-handling-definitions';
import { CallbackStep, CallbackRequestResult, CallbackResponseMessageResult, CallbackResponseResult, CloseConnectionStep, FileStep, JsonRpcResponseStep, PassThroughStep, PassThroughStepOptions, PassThroughResponse, RequestStepDefinition, RequestTransform, ResetConnectionStep, ResponseTransform, SerializedCallbackStepData, SerializedPassThroughData, SerializedStreamStepData, FixedResponseStep, StreamStep, TimeoutStep, DelayStep, WebhookStep, WaitForRequestBodyStep, InformationalResponseStep } from './request-step-definitions';
export { CallbackRequestResult, CallbackResponseMessageResult, CallbackResponseResult, ForwardingOptions, PassThroughResponse, PassThroughStepOptions, PassThroughLookupOptions, RequestTransform, ResponseTransform };
export declare class AbortError extends CustomError {
readonly code: string;
constructor(message: string, code: string);
}
export interface RequestStepImpl extends RequestStepDefinition {
handle(request: OngoingRequest, response: OngoingResponse, options: RequestStepOptions): Promise<undefined | {
continue: boolean;
}>;
}
export interface RequestStepOptions {
emitEventCallback?: (type: string, event: unknown) => void;
keyLogStream?: Writable;
debug: boolean;
}
export declare class FixedResponseStepImpl extends FixedResponseStep {
static readonly fromDefinition: (defn: RequestStepDefinition) => RequestStepImpl;
handle(_request: OngoingRequest, response: OngoingResponse): Promise<void>;
}
export declare class CallbackStepImpl extends CallbackStep {
static readonly fromDefinition: (defn: RequestStepDefinition) => RequestStepImpl;
handle(request: OngoingRequest, response: OngoingResponse): Promise<void>;
/**
* @internal
*/
static deserialize({ name }: SerializedCallbackStepData, channel: ClientServerChannel, options: MockttpDeserializationOptions): CallbackStep;
}
export declare class StreamStepImpl extends StreamStep {
static readonly fromDefinition: (defn: RequestStepDefinition) => RequestStepImpl;
handle(request: OngoingRequest, response: OngoingResponse): Promise<void>;
/**
* @internal
*/
static deserialize(stepData: SerializedStreamStepData, channel: ClientServerChannel): StreamStep;
}
export declare class FileStepImpl extends FileStep {
static readonly fromDefinition: (defn: RequestStepDefinition) => RequestStepImpl;
handle(_request: OngoingRequest, response: OngoingResponse): Promise<void>;
}
export declare class PassThroughStepImpl extends PassThroughStep {
static readonly fromDefinition: (defn: PassThroughStep) => PassThroughStepImpl & PassThroughStep;
protected outgoingSockets: Set<net.Socket>;
private _trustedCACertificates;
private trustedCACertificates;
handle(clientReq: OngoingRequest, clientRes: OngoingResponse, options: RequestStepOptions): Promise<void>;
/**
* @internal
*/
static deserialize(data: SerializedPassThroughData, channel: ClientServerChannel, { ruleParams, bodySerializer }: MockttpDeserializationOptions): PassThroughStep;
}
export declare class CloseConnectionStepImpl extends CloseConnectionStep {
static readonly fromDefinition: () => CloseConnectionStepImpl;
handle(request: OngoingRequest): Promise<void>;
}
export declare class ResetConnectionStepImpl extends ResetConnectionStep {
static readonly fromDefinition: () => ResetConnectionStepImpl;
constructor();
handle(request: OngoingRequest): Promise<void>;
/**
* @internal
*/
static deserialize(): ResetConnectionStep;
}
export declare class TimeoutStepImpl extends TimeoutStep {
static readonly fromDefinition: () => TimeoutStepImpl;
handle(): Promise<void>;
}
export declare class JsonRpcResponseStepImpl extends JsonRpcResponseStep {
static readonly fromDefinition: (defn: RequestStepDefinition) => RequestStepImpl;
handle(request: OngoingRequest, response: OngoingResponse): Promise<void>;
}
export declare class DelayStepImpl extends DelayStep {
static readonly fromDefinition: (defn: RequestStepDefinition) => RequestStepImpl;
handle(): Promise<{
continue: true;
}>;
}
export declare class WaitForRequestBodyStepImpl extends WaitForRequestBodyStep {
static readonly fromDefinition: () => WaitForRequestBodyStepImpl;
handle(request: OngoingRequest): Promise<{
continue: true;
}>;
}
export declare class InformationalResponseStepImpl extends InformationalResponseStep {
static readonly fromDefinition: (defn: RequestStepDefinition) => RequestStepImpl;
handle(_request: OngoingRequest, response: OngoingResponse): Promise<{
continue: true;
}>;
}
export declare class WebhookStepImpl extends WebhookStep {
static readonly fromDefinition: (defn: WebhookStep) => WebhookStepImpl;
protected outgoingSockets: Set<net.Socket>;
private sendEvent;
handle(request: OngoingRequest, response: OngoingResponse): Promise<{
continue: boolean;
}>;
}
export declare const StepLookup: {
simple: typeof FixedResponseStepImpl;
callback: typeof CallbackStepImpl;
stream: typeof StreamStepImpl;
file: typeof FileStepImpl;
passthrough: typeof PassThroughStepImpl;
'close-connection': typeof CloseConnectionStepImpl;
'reset-connection': typeof ResetConnectionStepImpl;
timeout: typeof TimeoutStepImpl;
'json-rpc-response': typeof JsonRpcResponseStepImpl;
delay: typeof DelayStepImpl;
'wait-for-request-body': typeof WaitForRequestBodyStepImpl;
webhook: typeof WebhookStepImpl;
'informational-response': typeof InformationalResponseStepImpl;
};
//# sourceMappingURL=request-step-impls.d.ts.map