Skip to content

Commit

Permalink
Merge pull request #1143 from pact-foundation/fix/issue-1133-remove-a…
Browse files Browse the repository at this point in the history
…nytemplate

Fix/issue 1133 remove `AnyTemplate`
  • Loading branch information
mefellows authored Dec 21, 2023
2 parents e832a3f + 33b6f07 commit 39ed445
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 21 deletions.
8 changes: 4 additions & 4 deletions scripts/ci/test-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the

echo "Running e2e examples build for node version $(node --version)"
for i in examples/*; do
[ -d "$i" ] || break # prevent failure if not a directory
[ -e "$i" ] || break # prevent failure if there are no examples
[ -d "$i" ] || continue # prevent failure if not a directory
[ -e "$i" ] || continue # prevent failure if there are no examples
echo "--> running tests for: $i"
pushd "$i"
# replace pact dependency with locally build version
Expand Down Expand Up @@ -42,8 +42,8 @@ echo "Running Vx examples build"
# trap "docker kill $BROKER_ID" EXIT

for i in examples/v*/*; do
[ -d "$i" ] || break # prevent failure if not a directory
[ -e "$i" ] || break # prevent failure if there are no examples
[ -d "$i" ] || continue # prevent failure if not a directory
[ -e "$i" ] || continue # prevent failure if there are no examples
echo "------------------------------------------------"
echo "------------> continuing to test V3/v$ example project: $i"
node --version
Expand Down
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 39ed445

Please sign in to comment.