diff --git a/examples/messages/consumer/message-consumer.spec.ts b/examples/messages/consumer/message-consumer.spec.ts index f75bd4dc8..97383c8b7 100644 --- a/examples/messages/consumer/message-consumer.spec.ts +++ b/examples/messages/consumer/message-consumer.spec.ts @@ -35,7 +35,7 @@ describe('Message consumer tests', () => { }), }) .withMetadata({ - queue: 'animals', + queue: like('animals'), }) .verify(synchronousBodyHandler(dogApiHandler)); }); @@ -53,7 +53,7 @@ describe('Message consumer tests', () => { }), }) .withMetadata({ - queue: 'animals', + queue: like('animals'), }) .verify(synchronousBodyHandler(dogApiHandler)); }); diff --git a/examples/messages/package-lock.json b/examples/messages/package-lock.json index 1e8c94af4..ece468d3c 100644 --- a/examples/messages/package-lock.json +++ b/examples/messages/package-lock.json @@ -22,7 +22,7 @@ }, "../../dist": { "name": "@pact-foundation/pact", - "version": "12.1.2", + "version": "12.2.0", "dev": true, "license": "MIT", "dependencies": { @@ -41,7 +41,6 @@ "lodash.isnil": "4.0.0", "lodash.isundefined": "3.0.1", "lodash.omit": "^4.5.0", - "lodash.omitby": "4.6.0", "pkginfo": "^0.4.1", "ramda": "^0.28.0", "randexp": "^0.5.3" @@ -1649,7 +1648,6 @@ "lodash.isnil": "4.0.0", "lodash.isundefined": "3.0.1", "lodash.omit": "^4.5.0", - "lodash.omitby": "4.6.0", "mocha": "^9.1.1", "mocha-lcov-reporter": "^1.3.0", "mockery": "^2.1.0", diff --git a/package-lock.json b/package-lock.json index 3abea0491..a5fa0f4fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "12.2.0", "license": "MIT", "dependencies": { - "@pact-foundation/pact-core": "^14.1.1", + "@pact-foundation/pact-core": "^14.3.0", "@types/express": "^4.17.11", "axios": "^1.6.1", "body-parser": "^1.20.0", @@ -2014,9 +2014,9 @@ } }, "node_modules/@pact-foundation/pact-core": { - "version": "14.1.1", - "resolved": "https://registry.npmjs.org/@pact-foundation/pact-core/-/pact-core-14.1.1.tgz", - "integrity": "sha512-hblC2FrwOOX3lfTcYPXFlNfbX+yyafOeeBI2TR7BcaCn1DRAj40OGvw1UAS7f8uf21IHZlA7H39Gs18ik6FY8A==", + "version": "14.3.0", + "resolved": "https://registry.npmjs.org/@pact-foundation/pact-core/-/pact-core-14.3.0.tgz", + "integrity": "sha512-OwBUA0rBuwHx8sbQ5olY+mzxd03HUpqza/6zGmyQutSb/bc79OAmve7EDYVSfPDYPKOCiGomj61gGAJF8kt1kQ==", "cpu": [ "x64", "ia32", @@ -4579,13 +4579,14 @@ } }, "node_modules/es5-ext": { - "version": "0.10.62", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", - "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "version": "0.10.64", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", + "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", "hasInstallScript": true, "dependencies": { "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.3", + "esniff": "^2.0.1", "next-tick": "^1.1.0" }, "engines": { @@ -5125,6 +5126,25 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/esniff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz", + "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.62", + "event-emitter": "^0.3.5", + "type": "^2.7.2" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esniff/node_modules/type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + }, "node_modules/espree": { "version": "9.4.1", "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", @@ -12878,9 +12898,9 @@ } }, "@pact-foundation/pact-core": { - "version": "14.1.1", - "resolved": "https://registry.npmjs.org/@pact-foundation/pact-core/-/pact-core-14.1.1.tgz", - "integrity": "sha512-hblC2FrwOOX3lfTcYPXFlNfbX+yyafOeeBI2TR7BcaCn1DRAj40OGvw1UAS7f8uf21IHZlA7H39Gs18ik6FY8A==", + "version": "14.3.0", + "resolved": "https://registry.npmjs.org/@pact-foundation/pact-core/-/pact-core-14.3.0.tgz", + "integrity": "sha512-OwBUA0rBuwHx8sbQ5olY+mzxd03HUpqza/6zGmyQutSb/bc79OAmve7EDYVSfPDYPKOCiGomj61gGAJF8kt1kQ==", "requires": { "chalk": "4.1.2", "check-types": "7.3.0", @@ -14824,12 +14844,13 @@ } }, "es5-ext": { - "version": "0.10.62", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", - "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "version": "0.10.64", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", + "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", "requires": { "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.3", + "esniff": "^2.0.1", "next-tick": "^1.1.0" } }, @@ -15229,6 +15250,24 @@ "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true }, + "esniff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz", + "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==", + "requires": { + "d": "^1.0.1", + "es5-ext": "^0.10.62", + "event-emitter": "^0.3.5", + "type": "^2.7.2" + }, + "dependencies": { + "type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + } + } + }, "espree": { "version": "9.4.1", "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", diff --git a/package.json b/package.json index 66c88c23c..588411f3c 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ ] }, "dependencies": { - "@pact-foundation/pact-core": "^14.1.1", + "@pact-foundation/pact-core": "^14.3.0", "@types/express": "^4.17.11", "axios": "^1.6.1", "body-parser": "^1.20.0", diff --git a/src/dsl/matchers.ts b/src/dsl/matchers.ts index cd1aa583b..a893a6740 100644 --- a/src/dsl/matchers.ts +++ b/src/dsl/matchers.ts @@ -40,7 +40,7 @@ export interface ArrayMatcher extends Matcher { max?: number; } -export function isMatcher(x: AnyTemplate): x is Matcher { +export function isMatcher(x: unknown): x is Matcher { return x != null && (x as Matcher).getValue !== undefined; } diff --git a/src/dsl/message.ts b/src/dsl/message.ts index 5c8f5d59e..04ab35961 100644 --- a/src/dsl/message.ts +++ b/src/dsl/message.ts @@ -1,5 +1,6 @@ import { AnyJson } from '../common/jsonTypes'; import { Matcher } from './matchers'; +import { Matcher as MatcherV3 } from '../v3/matchers'; /** * Metadata is a map containing message context, @@ -8,7 +9,7 @@ import { Matcher } from './matchers'; * @module Message */ export interface Metadata { - [name: string]: string | Matcher; + [name: string]: string | Matcher | MatcherV3; } /** diff --git a/src/messageConsumerPact.ts b/src/messageConsumerPact.ts index 0f3efad3f..7ff1f617b 100644 --- a/src/messageConsumerPact.ts +++ b/src/messageConsumerPact.ts @@ -169,10 +169,7 @@ export class MessageConsumerPact { } forEachObjIndexed((v, k) => { - this.message.withMetadata( - `${k}`, - typeof v === 'string' ? v : v.getValue() - ); + this.message.withMetadata(`${k}`, JSON.stringify(v)); }, metadata); return this; diff --git a/src/v4/message/index.ts b/src/v4/message/index.ts index 6d5666dca..934de160f 100644 --- a/src/v4/message/index.ts +++ b/src/v4/message/index.ts @@ -28,6 +28,7 @@ import { generateMockServerError, } from '../../v3/display'; import logger from '../../common/logger'; +import { isMatcher as isV3Matcher } from '../../v3/matchers'; const defaultPactDir = './pacts'; @@ -188,10 +189,7 @@ export class SynchronousMessageWithResponseBuilder } forEachObjIndexed((v, k) => { - this.interaction.withMetadata( - `${k}`, - typeof v === 'string' ? v : v.getValue() - ); + this.interaction.withMetadata(`${k}`, JSON.stringify(v)); }, metadata); return this;