UNPKG

@pact-foundation/pact

Version:
95 lines (94 loc) 6.23 kB
import type { ConsumerPact, SynchronousMessage as PactCoreSynchronousMessage } from '@pact-foundation/pact-core'; import type { AnyJson, JsonMap } from '../../common/jsonTypes'; import type { Metadata } from '../../dsl/message'; import type { Rules } from '../../v3/types'; import type { PactV4Options } from '../http/types'; import type { Comment, AsynchronousMessage as ConcreteMessage, CustomComment, PluginConfig, SynchronousMessage, TransportConfig, V4MessageRequestBuilderFunc, V4MessageResponseBuilderFunc, V4SynchronousMessageWithPlugin, V4SynchronousMessageWithPluginContents, V4SynchronousMessageWithRequest, V4SynchronousMessageWithRequestBuilder, V4SynchronousMessageWithResponse, V4SynchronousMessageWithResponseBuilder, V4SynchronousMessageWithTransport, V4UnconfiguredSynchronousMessage } from './types'; export declare class UnconfiguredSynchronousMessage implements V4UnconfiguredSynchronousMessage { protected pact: ConsumerPact; protected interaction: PactCoreSynchronousMessage; protected opts: PactV4Options; protected cleanupFn: () => void; constructor(pact: ConsumerPact, interaction: PactCoreSynchronousMessage, opts: PactV4Options, cleanupFn: () => void); given(state: string, parameters?: JsonMap): V4UnconfiguredSynchronousMessage; pending(pending?: boolean): V4UnconfiguredSynchronousMessage; comment(comment: Comment | CustomComment): V4UnconfiguredSynchronousMessage; testName(name: string): V4UnconfiguredSynchronousMessage; reference(group: string, name: string, value: string): V4UnconfiguredSynchronousMessage; usingPlugin(config: PluginConfig): V4SynchronousMessageWithPlugin; withRequest(builder: V4MessageRequestBuilderFunc): V4SynchronousMessageWithRequest; } export declare class SynchronousMessageWithPlugin implements V4SynchronousMessageWithPlugin { protected pact: ConsumerPact; protected interaction: PactCoreSynchronousMessage; protected opts: PactV4Options; protected cleanupFn: () => void; constructor(pact: ConsumerPact, interaction: PactCoreSynchronousMessage, opts: PactV4Options, cleanupFn: () => void); usingPlugin(config: PluginConfig): V4SynchronousMessageWithPlugin; withPluginContents(contents: string, contentType: string): V4SynchronousMessageWithPluginContents; } export declare class SynchronousMessageWithRequestBuilder implements V4SynchronousMessageWithRequestBuilder { protected pact: ConsumerPact; protected interaction: PactCoreSynchronousMessage; protected opts: PactV4Options; constructor(pact: ConsumerPact, interaction: PactCoreSynchronousMessage, opts: PactV4Options); withContent(contentType: string, body: Buffer): V4SynchronousMessageWithRequestBuilder; withJSONContent(content: unknown): V4SynchronousMessageWithRequestBuilder; withMatchingRules(rules: Rules): V4SynchronousMessageWithRequestBuilder; } export declare class SynchronousMessageWithRequest implements V4SynchronousMessageWithRequest { protected pact: ConsumerPact; protected interaction: PactCoreSynchronousMessage; protected opts: PactV4Options; protected cleanupFn: () => void; constructor(pact: ConsumerPact, interaction: PactCoreSynchronousMessage, opts: PactV4Options, cleanupFn: () => void); withResponse(builder: V4MessageResponseBuilderFunc): V4SynchronousMessageWithResponse; } export declare class SynchronousMessageWithResponseBuilder implements V4SynchronousMessageWithResponseBuilder { protected pact: ConsumerPact; protected interaction: PactCoreSynchronousMessage; protected opts: PactV4Options; constructor(pact: ConsumerPact, interaction: PactCoreSynchronousMessage, opts: PactV4Options); withMetadata(metadata: Metadata): V4SynchronousMessageWithResponseBuilder; withContent(contentType: string, body: Buffer): V4SynchronousMessageWithResponseBuilder; withJSONContent(content: unknown): V4SynchronousMessageWithResponseBuilder; withMatchingRules(rules: Rules): V4SynchronousMessageWithResponseBuilder; } export declare class SynchronousMessageWithPluginContents implements V4SynchronousMessageWithPluginContents { protected pact: ConsumerPact; protected interaction: PactCoreSynchronousMessage; protected opts: PactV4Options; protected cleanupFn: () => void; constructor(pact: ConsumerPact, interaction: PactCoreSynchronousMessage, opts: PactV4Options, cleanupFn: () => void); executeTest<T>(integrationTest: (m: SynchronousMessage) => Promise<T>): Promise<T | undefined>; startTransport(transport: string, address: string, // IP Address or hostname config?: AnyJson): V4SynchronousMessageWithTransport; } export declare class SynchronousMessageWithTransport implements V4SynchronousMessageWithTransport { protected pact: ConsumerPact; protected interaction: PactCoreSynchronousMessage; protected opts: PactV4Options; protected port: number; protected address: string; protected cleanupFn: () => void; constructor(pact: ConsumerPact, interaction: PactCoreSynchronousMessage, opts: PactV4Options, port: number, address: string, cleanupFn: () => void); executeTest<T>(integrationTest: (tc: TransportConfig, m: SynchronousMessage) => Promise<T>): Promise<T | undefined>; } export declare class SynchronousMessageWithResponse implements V4SynchronousMessageWithResponse { protected pact: ConsumerPact; protected interaction: PactCoreSynchronousMessage; protected opts: PactV4Options; protected cleanupFn: () => void; constructor(pact: ConsumerPact, interaction: PactCoreSynchronousMessage, opts: PactV4Options, cleanupFn: () => void); executeTest<T>(integrationTest: (m: SynchronousMessage) => Promise<T>): Promise<T | undefined>; } /** * A Message Consumer is a function that will receive a message * from a given Message Provider. It is given the full Message * context during verification. * * @module Message */ export type V4MessageConsumer = (m: ConcreteMessage) => Promise<unknown>; export declare function v4SynchronousBodyHandler<R>(handler: (body: AnyJson | Buffer) => R): V4MessageConsumer; export declare function v4AsynchronousBodyHandler<R>(handler: (body: AnyJson | Buffer) => Promise<R>): V4MessageConsumer;