From 4aa5c9bf186e3608f01e7875993a7479d30dbd15 Mon Sep 17 00:00:00 2001 From: mefellows Date: Wed, 20 Dec 2023 12:06:54 +1100 Subject: [PATCH] fix(types): remove AnyTemplate references from DSL Fixes #1133 --- src/dsl/message.ts | 4 ++-- src/messageConsumerPact.ts | 3 +-- src/v4/message/index.ts | 9 ++------- src/v4/message/types.ts | 7 ++----- src/v4/types.ts | 1 - 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/dsl/message.ts b/src/dsl/message.ts index e8e6d18e6..5c8f5d59e 100644 --- a/src/dsl/message.ts +++ b/src/dsl/message.ts @@ -1,5 +1,5 @@ import { AnyJson } from '../common/jsonTypes'; -import { Matcher, AnyTemplate } from './matchers'; +import { Matcher } from './matchers'; /** * Metadata is a map containing message context, @@ -30,7 +30,7 @@ export interface Message { providerStates?: ProviderState[]; description?: string; metadata?: Metadata; - contents: AnyTemplate | Buffer; + contents: unknown | Buffer; } export interface ConcreteMessage { diff --git a/src/messageConsumerPact.ts b/src/messageConsumerPact.ts index d1fbc3bef..7ef9cf2c1 100644 --- a/src/messageConsumerPact.ts +++ b/src/messageConsumerPact.ts @@ -10,7 +10,6 @@ import serviceFactory, { } from '@pact-foundation/pact-core'; import { forEachObjIndexed } from 'ramda'; import { AnyJson } from './common/jsonTypes'; -import { AnyTemplate } from './dsl/matchers'; import { Metadata, Message, @@ -109,7 +108,7 @@ export class MessageConsumerPact { * @param {string} content - A description of the Message to be received * @returns {Message} MessageConsumer */ - public withContent(content: AnyTemplate): MessageConsumerPact { + public withContent(content: unknown): MessageConsumerPact { if (isEmpty(content)) { throw new ConfigurationError( 'You must provide a valid JSON document or primitive for the Message.' diff --git a/src/v4/message/index.ts b/src/v4/message/index.ts index 4e34be767..6ffbcc712 100644 --- a/src/v4/message/index.ts +++ b/src/v4/message/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import { Metadata } from '../../dsl/message'; -import { AnyTemplate } from '../../v3/matchers'; import { AnyJson, JsonMap } from '../../common/jsonTypes'; import { PluginConfig, @@ -129,9 +128,7 @@ export class SynchronousMessageWithRequestBuilder return this; } - withJSONContent( - content: AnyTemplate - ): V4SynchronousMessageWithRequestBuilder { + withJSONContent(content: unknown): V4SynchronousMessageWithRequestBuilder { if (isEmpty(content)) { throw new ConfigurationError( 'You must provide a valid JSON document or primitive for the Message.' @@ -211,9 +208,7 @@ export class SynchronousMessageWithResponseBuilder return this; } - withJSONContent( - content: AnyTemplate - ): V4SynchronousMessageWithResponseBuilder { + withJSONContent(content: unknown): V4SynchronousMessageWithResponseBuilder { if (isEmpty(content)) { throw new ConfigurationError( 'You must provide a valid JSON document or primitive for the Message.' diff --git a/src/v4/message/types.ts b/src/v4/message/types.ts index d4fb9a9e9..53ab97433 100644 --- a/src/v4/message/types.ts +++ b/src/v4/message/types.ts @@ -1,6 +1,5 @@ import { AnyJson, JsonMap } from '../../common/jsonTypes'; import { Metadata } from '../../dsl/message'; -import { AnyTemplate } from '../../v3/matchers'; export type MessageContents = unknown; // TODO { contents: Buffer } @@ -61,7 +60,7 @@ export interface V4SynchronousMessageWithRequestBuilder { contentType: string, body: Buffer ): V4SynchronousMessageWithRequestBuilder; - withJSONContent(content: AnyTemplate): V4SynchronousMessageWithRequestBuilder; + withJSONContent(content: unknown): V4SynchronousMessageWithRequestBuilder; } export interface V4SynchronousMessageWithRequest { @@ -76,9 +75,7 @@ export interface V4SynchronousMessageWithResponseBuilder { contentType: string, body: Buffer ): V4SynchronousMessageWithResponseBuilder; - withJSONContent( - content: AnyTemplate - ): V4SynchronousMessageWithResponseBuilder; + withJSONContent(content: unknown): V4SynchronousMessageWithResponseBuilder; } export interface V4SynchronousMessageWithPluginContents { diff --git a/src/v4/types.ts b/src/v4/types.ts index ec734cf09..3c7d639e6 100644 --- a/src/v4/types.ts +++ b/src/v4/types.ts @@ -3,7 +3,6 @@ import { V4UnconfiguredSynchronousMessage } from './message/types'; export interface V4ConsumerPact { addInteraction(): V4UnconfiguredInteraction; - addAsynchronousInteraction(): V4UnconfiguredAsynchronousMessage; addSynchronousInteraction( description: string ): V4UnconfiguredSynchronousMessage;