Skip to content

Commit

Permalink
fix(types): remove AnyTemplate references from DSL
Browse files Browse the repository at this point in the history
Fixes #1133
  • Loading branch information
mefellows committed Dec 20, 2023
1 parent e832a3f commit 4aa5c9b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/dsl/message.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -30,7 +30,7 @@ export interface Message {
providerStates?: ProviderState[];
description?: string;
metadata?: Metadata;
contents: AnyTemplate | Buffer;
contents: unknown | Buffer;
}

export interface ConcreteMessage {
Expand Down
3 changes: 1 addition & 2 deletions src/messageConsumerPact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.'
Expand Down
9 changes: 2 additions & 7 deletions src/v4/message/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable */
import { Metadata } from '../../dsl/message';
import { AnyTemplate } from '../../v3/matchers';
import { AnyJson, JsonMap } from '../../common/jsonTypes';
import {
PluginConfig,
Expand Down Expand Up @@ -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.'
Expand Down Expand Up @@ -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.'
Expand Down
7 changes: 2 additions & 5 deletions src/v4/message/types.ts
Original file line number Diff line number Diff line change
@@ -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 }

Expand Down Expand Up @@ -61,7 +60,7 @@ export interface V4SynchronousMessageWithRequestBuilder {
contentType: string,
body: Buffer
): V4SynchronousMessageWithRequestBuilder;
withJSONContent(content: AnyTemplate): V4SynchronousMessageWithRequestBuilder;
withJSONContent(content: unknown): V4SynchronousMessageWithRequestBuilder;
}

export interface V4SynchronousMessageWithRequest {
Expand All @@ -76,9 +75,7 @@ export interface V4SynchronousMessageWithResponseBuilder {
contentType: string,
body: Buffer
): V4SynchronousMessageWithResponseBuilder;
withJSONContent(
content: AnyTemplate
): V4SynchronousMessageWithResponseBuilder;
withJSONContent(content: unknown): V4SynchronousMessageWithResponseBuilder;
}

export interface V4SynchronousMessageWithPluginContents {
Expand Down
1 change: 0 additions & 1 deletion src/v4/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { V4UnconfiguredSynchronousMessage } from './message/types';

export interface V4ConsumerPact {
addInteraction(): V4UnconfiguredInteraction;
addAsynchronousInteraction(): V4UnconfiguredAsynchronousMessage;
addSynchronousInteraction(
description: string
): V4UnconfiguredSynchronousMessage;
Expand Down

0 comments on commit 4aa5c9b

Please sign in to comment.