@pact-foundation/pact 16.3.1 → 16.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +22 -12
- package/package.json +26 -47
- package/scripts/ci/build-and-test.sh +0 -3
- package/scripts/install-plugins.js +104 -0
- package/src/common/graphQL/configurationError.js +2 -22
- package/src/common/graphQL/configurationError.js.map +1 -1
- package/src/common/graphQL/graphQL.d.ts +2 -2
- package/src/common/graphQL/graphQL.js +11 -14
- package/src/common/graphQL/graphQL.js.map +1 -1
- package/src/common/graphQL/graphQLQueryError.js +2 -22
- package/src/common/graphQL/graphQLQueryError.js.map +1 -1
- package/src/common/logger.js +9 -9
- package/src/common/logger.js.map +1 -1
- package/src/common/matchingRules.d.ts +7 -1
- package/src/common/matchingRules.js +42 -22
- package/src/common/matchingRules.js.map +1 -1
- package/src/common/net.js +36 -42
- package/src/common/net.js.map +1 -1
- package/src/common/net.spec.js +39 -87
- package/src/common/net.spec.js.map +1 -1
- package/src/common/request.js +33 -82
- package/src/common/request.js.map +1 -1
- package/src/common/request.spec.js +29 -73
- package/src/common/request.spec.js.map +1 -1
- package/src/common/spec.js +3 -4
- package/src/common/spec.js.map +1 -1
- package/src/dsl/apolloGraphql.js +7 -25
- package/src/dsl/apolloGraphql.js.map +1 -1
- package/src/dsl/apolloGraphql.spec.js +21 -58
- package/src/dsl/apolloGraphql.spec.js.map +1 -1
- package/src/dsl/graphql.d.ts +2 -2
- package/src/dsl/graphql.js +29 -48
- package/src/dsl/graphql.js.map +1 -1
- package/src/dsl/graphql.spec.js +92 -117
- package/src/dsl/graphql.spec.js.map +1 -1
- package/src/dsl/interaction.d.ts +2 -2
- package/src/dsl/interaction.js +41 -48
- package/src/dsl/interaction.js.map +1 -1
- package/src/dsl/interaction.spec.js +109 -132
- package/src/dsl/interaction.spec.js.map +1 -1
- package/src/dsl/matchers.d.ts +2 -3
- package/src/dsl/matchers.js +19 -31
- package/src/dsl/matchers.js.map +1 -1
- package/src/dsl/matchers.spec.js +279 -289
- package/src/dsl/matchers.spec.js.map +1 -1
- package/src/dsl/message.d.ts +3 -3
- package/src/dsl/options.d.ts +3 -3
- package/src/dsl/verifier/proxy/hooks.d.ts +2 -2
- package/src/dsl/verifier/proxy/hooks.js +42 -112
- package/src/dsl/verifier/proxy/hooks.js.map +1 -1
- package/src/dsl/verifier/proxy/hooks.spec.js +86 -199
- package/src/dsl/verifier/proxy/hooks.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/messages.d.ts +2 -2
- package/src/dsl/verifier/proxy/messages.js +88 -106
- package/src/dsl/verifier/proxy/messages.js.map +1 -1
- package/src/dsl/verifier/proxy/parseBody.d.ts +1 -1
- package/src/dsl/verifier/proxy/parseBody.js +3 -3
- package/src/dsl/verifier/proxy/parseBody.js.map +1 -1
- package/src/dsl/verifier/proxy/parseBody.spec.js +35 -113
- package/src/dsl/verifier/proxy/parseBody.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/proxy.d.ts +2 -2
- package/src/dsl/verifier/proxy/proxy.js +22 -26
- package/src/dsl/verifier/proxy/proxy.js.map +1 -1
- package/src/dsl/verifier/proxy/proxy.spec.js +11 -53
- package/src/dsl/verifier/proxy/proxy.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/proxyRequest.d.ts +3 -3
- package/src/dsl/verifier/proxy/proxyRequest.js +7 -7
- package/src/dsl/verifier/proxy/proxyRequest.js.map +1 -1
- package/src/dsl/verifier/proxy/proxyRequest.spec.js +54 -104
- package/src/dsl/verifier/proxy/proxyRequest.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/stateHandler/setupStates.d.ts +3 -3
- package/src/dsl/verifier/proxy/stateHandler/setupStates.js +14 -18
- package/src/dsl/verifier/proxy/stateHandler/setupStates.js.map +1 -1
- package/src/dsl/verifier/proxy/stateHandler/setupStates.spec.js +76 -193
- package/src/dsl/verifier/proxy/stateHandler/setupStates.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.d.ts +2 -2
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.js +23 -72
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.js.map +1 -1
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.spec.js +37 -122
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/tracer.d.ts +1 -1
- package/src/dsl/verifier/proxy/tracer.js +42 -35
- package/src/dsl/verifier/proxy/tracer.js.map +1 -1
- package/src/dsl/verifier/proxy/types.d.ts +5 -5
- package/src/dsl/verifier/types.d.ts +3 -3
- package/src/dsl/verifier/verifier.d.ts +5 -1
- package/src/dsl/verifier/verifier.js +53 -60
- package/src/dsl/verifier/verifier.js.map +1 -1
- package/src/dsl/verifier/verifier.spec.js +84 -151
- package/src/dsl/verifier/verifier.spec.js.map +1 -1
- package/src/errors/configurationError.js +2 -22
- package/src/errors/configurationError.js.map +1 -1
- package/src/errors/graphQLQueryError.js +2 -22
- package/src/errors/graphQLQueryError.js.map +1 -1
- package/src/errors/matcherError.js +2 -22
- package/src/errors/matcherError.js.map +1 -1
- package/src/errors/verificationError.js +2 -22
- package/src/errors/verificationError.js.map +1 -1
- package/src/httpPact/ffi.d.ts +2 -2
- package/src/httpPact/ffi.js +28 -29
- package/src/httpPact/ffi.js.map +1 -1
- package/src/httpPact/ffi.spec.js +40 -83
- package/src/httpPact/ffi.spec.js.map +1 -1
- package/src/httpPact/index.d.ts +3 -3
- package/src/httpPact/index.js +92 -149
- package/src/httpPact/index.js.map +1 -1
- package/src/httpPact/index.spec.js +102 -195
- package/src/httpPact/index.spec.js.map +1 -1
- package/src/httpPact/tracing.js +20 -28
- package/src/httpPact/tracing.js.map +1 -1
- package/src/index.d.ts +25 -25
- package/src/index.js +29 -29
- package/src/index.js.map +1 -1
- package/src/messageConsumerPact.d.ts +5 -5
- package/src/messageConsumerPact.js +59 -53
- package/src/messageConsumerPact.js.map +1 -1
- package/src/messageConsumerPact.spec.js +55 -97
- package/src/messageConsumerPact.spec.js.map +1 -1
- package/src/messageProviderPact.d.ts +3 -3
- package/src/messageProviderPact.js +68 -85
- package/src/messageProviderPact.js.map +1 -1
- package/src/messageProviderPact.spec.js +96 -123
- package/src/messageProviderPact.spec.js.map +1 -1
- package/src/pact.integration.spec.js +242 -351
- package/src/pact.integration.spec.js.map +1 -1
- package/src/v3/display.d.ts +1 -1
- package/src/v3/display.js +44 -58
- package/src/v3/display.js.map +1 -1
- package/src/v3/ffi.js +20 -16
- package/src/v3/ffi.js.map +1 -1
- package/src/v3/ffi.spec.js +7 -42
- package/src/v3/ffi.spec.js.map +1 -1
- package/src/v3/graphql/graphQL.d.ts +4 -4
- package/src/v3/graphql/graphQL.js +50 -75
- package/src/v3/graphql/graphQL.js.map +1 -1
- package/src/v3/graphql/index.d.ts +1 -1
- package/src/v3/graphql/index.js +1 -1
- package/src/v3/graphql/index.js.map +1 -1
- package/src/v3/index.d.ts +4 -12
- package/src/v3/index.js +4 -12
- package/src/v3/index.js.map +1 -1
- package/src/v3/matchers.d.ts +15 -3
- package/src/v3/matchers.js +131 -148
- package/src/v3/matchers.js.map +1 -1
- package/src/v3/matchers.spec.js +281 -232
- package/src/v3/matchers.spec.js.map +1 -1
- package/src/v3/pact.d.ts +2 -2
- package/src/v3/pact.js +108 -151
- package/src/v3/pact.js.map +1 -1
- package/src/v3/pact.spec.js +94 -0
- package/src/v3/pact.spec.js.map +1 -0
- package/src/v3/types.d.ts +19 -3
- package/src/v3/types.js +22 -1
- package/src/v3/types.js.map +1 -1
- package/src/v4/graphql/graphQLInteractionWithRequest.d.ts +4 -4
- package/src/v4/graphql/graphQLInteractionWithRequest.js +21 -17
- package/src/v4/graphql/graphQLInteractionWithRequest.js.map +1 -1
- package/src/v4/graphql/graphQLRequestBuilder.d.ts +3 -3
- package/src/v4/graphql/graphQLRequestBuilder.js +18 -20
- package/src/v4/graphql/graphQLRequestBuilder.js.map +1 -1
- package/src/v4/graphql/index.d.ts +6 -6
- package/src/v4/graphql/index.js +21 -17
- package/src/v4/graphql/index.js.map +1 -1
- package/src/v4/graphql/types.d.ts +5 -5
- package/src/v4/http/index.d.ts +2 -2
- package/src/v4/http/index.js +53 -93
- package/src/v4/http/index.js.map +1 -1
- package/src/v4/http/index.spec.d.ts +1 -0
- package/src/v4/http/index.spec.js +73 -0
- package/src/v4/http/index.spec.js.map +1 -0
- package/src/v4/http/interactionWithCompleteRequest.d.ts +4 -7
- package/src/v4/http/interactionWithCompleteRequest.js +6 -10
- package/src/v4/http/interactionWithCompleteRequest.js.map +1 -1
- package/src/v4/http/interactionWithPlugin.d.ts +3 -3
- package/src/v4/http/interactionWithPlugin.js +14 -11
- package/src/v4/http/interactionWithPlugin.js.map +1 -1
- package/src/v4/http/interactionWithPluginRequest.d.ts +4 -3
- package/src/v4/http/interactionWithPluginRequest.js +17 -9
- package/src/v4/http/interactionWithPluginRequest.js.map +1 -1
- package/src/v4/http/interactionWithPluginResponse.d.ts +2 -2
- package/src/v4/http/interactionWithPluginResponse.js +10 -48
- package/src/v4/http/interactionWithPluginResponse.js.map +1 -1
- package/src/v4/http/interactionWithRequest.d.ts +4 -3
- package/src/v4/http/interactionWithRequest.js +17 -9
- package/src/v4/http/interactionWithRequest.js.map +1 -1
- package/src/v4/http/interactionWithRequest.spec.d.ts +1 -0
- package/src/v4/http/interactionWithRequest.spec.js +82 -0
- package/src/v4/http/interactionWithRequest.spec.js.map +1 -0
- package/src/v4/http/interactionWithResponse.d.ts +2 -2
- package/src/v4/http/interactionWithResponse.js +10 -48
- package/src/v4/http/interactionWithResponse.js.map +1 -1
- package/src/v4/http/requestBuilder.d.ts +4 -3
- package/src/v4/http/requestBuilder.js +36 -34
- package/src/v4/http/requestBuilder.js.map +1 -1
- package/src/v4/http/requestBuilder.spec.d.ts +1 -0
- package/src/v4/http/requestBuilder.spec.js +42 -0
- package/src/v4/http/requestBuilder.spec.js.map +1 -0
- package/src/v4/http/requestWithPluginBuilder.d.ts +3 -2
- package/src/v4/http/requestWithPluginBuilder.js +30 -46
- package/src/v4/http/requestWithPluginBuilder.js.map +1 -1
- package/src/v4/http/requestWithPluginBuilder.spec.d.ts +1 -0
- package/src/v4/http/requestWithPluginBuilder.spec.js +34 -0
- package/src/v4/http/requestWithPluginBuilder.spec.js.map +1 -0
- package/src/v4/http/responseBuilder.d.ts +4 -3
- package/src/v4/http/responseBuilder.js +28 -25
- package/src/v4/http/responseBuilder.js.map +1 -1
- package/src/v4/http/responseBuilder.spec.d.ts +1 -0
- package/src/v4/http/responseBuilder.spec.js +42 -0
- package/src/v4/http/responseBuilder.spec.js.map +1 -0
- package/src/v4/http/responseWithPluginBuilder.d.ts +1 -1
- package/src/v4/http/responseWithPluginBuilder.js +5 -25
- package/src/v4/http/responseWithPluginBuilder.js.map +1 -1
- package/src/v4/http/responseWithPluginBuilder.spec.d.ts +1 -0
- package/src/v4/http/responseWithPluginBuilder.spec.js +34 -0
- package/src/v4/http/responseWithPluginBuilder.spec.js.map +1 -0
- package/src/v4/http/types.d.ts +13 -4
- package/src/v4/http/unconfiguredInteraction.d.ts +6 -5
- package/src/v4/http/unconfiguredInteraction.js +31 -26
- package/src/v4/http/unconfiguredInteraction.js.map +1 -1
- package/src/v4/index.d.ts +6 -5
- package/src/v4/index.js +32 -35
- package/src/v4/index.js.map +1 -1
- package/src/v4/message/asynchronousMessage.d.ts +7 -6
- package/src/v4/message/asynchronousMessage.js +157 -190
- package/src/v4/message/asynchronousMessage.js.map +1 -1
- package/src/v4/message/index.d.ts +7 -6
- package/src/v4/message/index.js +188 -217
- package/src/v4/message/index.js.map +1 -1
- package/src/v4/message/types.d.ts +5 -3
- package/src/v4/types.d.ts +3 -3
- package/src/xml/index.d.ts +4 -0
- package/src/xml/index.js +21 -0
- package/src/xml/index.js.map +1 -0
- package/src/{v3/xml → xml}/xmlBuilder.d.ts +1 -3
- package/src/{v3/xml → xml}/xmlBuilder.js +7 -9
- package/src/xml/xmlBuilder.js.map +1 -0
- package/src/{v3/xml → xml}/xmlElement.d.ts +2 -2
- package/src/xml/xmlElement.js +73 -0
- package/src/xml/xmlElement.js.map +1 -0
- package/src/xml/xmlElement.spec.d.ts +1 -0
- package/src/xml/xmlElement.spec.js +107 -0
- package/src/xml/xmlElement.spec.js.map +1 -0
- package/src/xml/xmlNode.js +7 -0
- package/src/xml/xmlNode.js.map +1 -0
- package/src/{v3/xml → xml}/xmlText.d.ts +1 -1
- package/src/xml/xmlText.js +15 -0
- package/src/xml/xmlText.js.map +1 -0
- package/scripts/install-plugins +0 -106
- package/src/v3/xml/xmlBuilder.js.map +0 -1
- package/src/v3/xml/xmlElement.js +0 -90
- package/src/v3/xml/xmlElement.js.map +0 -1
- package/src/v3/xml/xmlElement.spec.js +0 -113
- package/src/v3/xml/xmlElement.spec.js.map +0 -1
- package/src/v3/xml/xmlNode.js +0 -10
- package/src/v3/xml/xmlNode.js.map +0 -1
- package/src/v3/xml/xmlText.js +0 -31
- package/src/v3/xml/xmlText.js.map +0 -1
- /package/src/v3/{xml/xmlElement.spec.d.ts → pact.spec.d.ts} +0 -0
- /package/src/{v3/xml → xml}/xmlNode.d.ts +0 -0
package/src/v4/http/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JsonMap } from '../../common/jsonTypes';
|
|
2
|
-
import { Matcher, Path, Rules, SpecificationVersion, TemplateHeaders, TemplateQuery, V3MockServer, V3ProviderState, V3Request, V3Response } from '../../v3';
|
|
1
|
+
import type { JsonMap } from '../../common/jsonTypes';
|
|
2
|
+
import type { Matcher, Path, Rules, SpecificationVersion, StatusCodeMatcher, TemplateHeaders, TemplateQuery, V3MockServer, V3ProviderState, V3Request, V3Response } from '../../v3';
|
|
3
3
|
export type V4ProviderState = V3ProviderState;
|
|
4
4
|
export type V4MockServer = V3MockServer;
|
|
5
5
|
export type V4Request = V3Request;
|
|
@@ -37,6 +37,10 @@ export interface PactV4Options {
|
|
|
37
37
|
* The host to run the mock service, defaults to 127.0.0.1
|
|
38
38
|
*/
|
|
39
39
|
host?: string;
|
|
40
|
+
/**
|
|
41
|
+
* If the mock server should handle CORS pre-flight requests. Defaults to true
|
|
42
|
+
*/
|
|
43
|
+
cors?: boolean;
|
|
40
44
|
}
|
|
41
45
|
export type TemplateHeaderArrayValue = string[] | Matcher<string>[];
|
|
42
46
|
export type Comment = string;
|
|
@@ -50,6 +54,7 @@ export interface V4UnconfiguredInteraction {
|
|
|
50
54
|
pending(pending?: boolean): V4UnconfiguredInteraction;
|
|
51
55
|
comment(comment: Comment | CustomComment): V4UnconfiguredInteraction;
|
|
52
56
|
testName(name: string): V4UnconfiguredInteraction;
|
|
57
|
+
reference(group: string, name: string, value: string): V4UnconfiguredInteraction;
|
|
53
58
|
withCompleteRequest(request: V4Request): V4InteractionWithCompleteRequest;
|
|
54
59
|
withRequest(method: string, path: Path, builder?: V4RequestBuilderFunc): V4InteractionWithRequest;
|
|
55
60
|
usingPlugin(config: PluginConfig): V4InteractionWithPlugin;
|
|
@@ -58,13 +63,14 @@ export interface V4InteractionWithCompleteRequest {
|
|
|
58
63
|
withCompleteResponse(response: V4Response): V4InteractionWithResponse;
|
|
59
64
|
}
|
|
60
65
|
export interface V4InteractionWithRequest {
|
|
61
|
-
willRespondWith(status: number
|
|
66
|
+
willRespondWith(status: number | StatusCodeMatcher<number>, builder?: V4ResponseBuilderFunc): V4InteractionWithResponse;
|
|
62
67
|
}
|
|
63
68
|
export type V4RequestBuilderFunc = (builder: V4RequestBuilder) => void;
|
|
64
69
|
export interface V4RequestBuilder {
|
|
65
70
|
query(query: TemplateQuery): V4RequestBuilder;
|
|
66
71
|
headers(headers: TemplateHeaders): V4RequestBuilder;
|
|
67
72
|
jsonBody(body: unknown): V4RequestBuilder;
|
|
73
|
+
xmlBody(body: unknown): V4RequestBuilder;
|
|
68
74
|
binaryFile(contentType: string, file: string): V4RequestBuilder;
|
|
69
75
|
multipartBody(contentType: string, filename: string, mimePartName: string, boundary?: string): V4RequestBuilder;
|
|
70
76
|
matchingRules(rules: Rules): V4RequestBuilder;
|
|
@@ -73,6 +79,7 @@ export interface V4RequestBuilder {
|
|
|
73
79
|
export interface V4ResponseBuilder {
|
|
74
80
|
headers(headers: TemplateHeaders): V4ResponseBuilder;
|
|
75
81
|
jsonBody(body: unknown): V4ResponseBuilder;
|
|
82
|
+
xmlBody(body: unknown): V4ResponseBuilder;
|
|
76
83
|
binaryFile(contentType: string, file: string): V4ResponseBuilder;
|
|
77
84
|
multipartBody(contentType: string, filename: string, mimePartName: string, boundary?: string): V4ResponseBuilder;
|
|
78
85
|
matchingRules(rules: Rules): V4ResponseBuilder;
|
|
@@ -93,12 +100,13 @@ export interface V4InteractionWithPlugin {
|
|
|
93
100
|
withRequest(method: string, path: Path, builder?: V4PluginRequestBuilderFunc): V4InteractionWithPluginRequest;
|
|
94
101
|
}
|
|
95
102
|
export interface V4InteractionWithPluginRequest {
|
|
96
|
-
willRespondWith(status: number
|
|
103
|
+
willRespondWith(status: number | StatusCodeMatcher<number>, builder?: V4PluginResponseBuilderFunc): V4InteractionWithPluginResponse;
|
|
97
104
|
}
|
|
98
105
|
export interface V4RequestWithPluginBuilder {
|
|
99
106
|
query(query: TemplateQuery): V4RequestWithPluginBuilder;
|
|
100
107
|
headers(headers: TemplateHeaders): V4RequestWithPluginBuilder;
|
|
101
108
|
jsonBody(body: unknown): V4RequestWithPluginBuilder;
|
|
109
|
+
xmlBody(body: unknown): V4RequestWithPluginBuilder;
|
|
102
110
|
binaryFile(contentType: string, file: string): V4RequestWithPluginBuilder;
|
|
103
111
|
multipartBody(contentType: string, filename: string, mimePartName: string, boundary?: string): V4RequestWithPluginBuilder;
|
|
104
112
|
body(contentType: string, body: Buffer): V4RequestWithPluginBuilder;
|
|
@@ -108,6 +116,7 @@ export interface V4RequestWithPluginBuilder {
|
|
|
108
116
|
export interface V4ResponseWithPluginBuilder {
|
|
109
117
|
headers(headers: TemplateHeaders): V4ResponseBuilder;
|
|
110
118
|
jsonBody(body: unknown): V4ResponseBuilder;
|
|
119
|
+
xmlBody(body: unknown): V4ResponseBuilder;
|
|
111
120
|
binaryFile(contentType: string, file: string): V4ResponseBuilder;
|
|
112
121
|
multipartBody(contentType: string, filename: string, mimePartName: string, boundary?: string): V4ResponseBuilder;
|
|
113
122
|
matchingRules(rules: Rules): V4ResponseBuilder;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JsonMap } from '../../common/jsonTypes';
|
|
3
|
-
import { Path } from '../../v3';
|
|
4
|
-
import {
|
|
1
|
+
import type { ConsumerInteraction, ConsumerPact } from '@pact-foundation/pact-core';
|
|
2
|
+
import type { JsonMap } from '../../common/jsonTypes';
|
|
3
|
+
import type { Path } from '../../v3';
|
|
4
|
+
import type { Comment, CustomComment, PactV4Options, PluginConfig, V4InteractionWithCompleteRequest, V4InteractionWithPlugin, V4InteractionWithRequest, V4Request, V4RequestBuilderFunc, V4UnconfiguredInteraction } from './types';
|
|
5
5
|
export declare class UnconfiguredInteraction implements V4UnconfiguredInteraction {
|
|
6
6
|
protected pact: ConsumerPact;
|
|
7
7
|
protected interaction: ConsumerInteraction;
|
|
@@ -13,7 +13,8 @@ export declare class UnconfiguredInteraction implements V4UnconfiguredInteractio
|
|
|
13
13
|
pending(pending?: boolean): V4UnconfiguredInteraction;
|
|
14
14
|
comment(comment: Comment | CustomComment): V4UnconfiguredInteraction;
|
|
15
15
|
testName(name: string): V4UnconfiguredInteraction;
|
|
16
|
-
|
|
16
|
+
reference(group: string, name: string, value: string): V4UnconfiguredInteraction;
|
|
17
|
+
withCompleteRequest(_request: V4Request): V4InteractionWithCompleteRequest;
|
|
17
18
|
withRequest(method: string, path: Path, builder?: V4RequestBuilderFunc): V4InteractionWithRequest;
|
|
18
19
|
usingPlugin(config: PluginConfig): V4InteractionWithPlugin;
|
|
19
20
|
}
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UnconfiguredInteraction = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const matchers_1 = require("../../v3/matchers");
|
|
5
|
+
const interactionWithPlugin_1 = require("./interactionWithPlugin");
|
|
6
|
+
const interactionWithRequest_1 = require("./interactionWithRequest");
|
|
7
|
+
const requestBuilder_1 = require("./requestBuilder");
|
|
8
|
+
class UnconfiguredInteraction {
|
|
9
|
+
pact;
|
|
10
|
+
interaction;
|
|
11
|
+
opts;
|
|
12
|
+
cleanupFn;
|
|
9
13
|
// tslint:disable:no-empty-function
|
|
10
|
-
|
|
14
|
+
constructor(pact, interaction, opts, cleanupFn) {
|
|
11
15
|
this.pact = pact;
|
|
12
16
|
this.interaction = interaction;
|
|
13
17
|
this.opts = opts;
|
|
14
18
|
this.cleanupFn = cleanupFn;
|
|
15
19
|
}
|
|
16
|
-
|
|
20
|
+
uponReceiving(description) {
|
|
17
21
|
this.interaction.uponReceiving(description);
|
|
18
22
|
return this;
|
|
19
|
-
}
|
|
20
|
-
|
|
23
|
+
}
|
|
24
|
+
given(state, parameters) {
|
|
21
25
|
if (parameters) {
|
|
22
26
|
this.interaction.givenWithParams(state, JSON.stringify(parameters));
|
|
23
27
|
}
|
|
@@ -25,40 +29,41 @@ var UnconfiguredInteraction = /** @class */ (function () {
|
|
|
25
29
|
this.interaction.given(state);
|
|
26
30
|
}
|
|
27
31
|
return this;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (pending === void 0) { pending = true; }
|
|
32
|
+
}
|
|
33
|
+
pending(pending = true) {
|
|
31
34
|
this.interaction.setPending(pending);
|
|
32
35
|
return this;
|
|
33
|
-
}
|
|
34
|
-
|
|
36
|
+
}
|
|
37
|
+
comment(comment) {
|
|
35
38
|
if (typeof comment === 'string') {
|
|
36
39
|
this.interaction.addTextComment(comment);
|
|
37
40
|
return this;
|
|
38
41
|
}
|
|
39
42
|
this.interaction.setComment(comment.key, comment.value);
|
|
40
43
|
return this;
|
|
41
|
-
}
|
|
42
|
-
|
|
44
|
+
}
|
|
45
|
+
testName(name) {
|
|
43
46
|
this.interaction.setInteractionTestName(name);
|
|
44
47
|
return this;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
}
|
|
49
|
+
reference(group, name, value) {
|
|
50
|
+
this.interaction.addInteractionReference(group, name, value);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
withCompleteRequest(_request) {
|
|
48
54
|
throw new Error('withCompleteRequest is not implemented');
|
|
49
|
-
}
|
|
50
|
-
|
|
55
|
+
}
|
|
56
|
+
withRequest(method, path, builder) {
|
|
51
57
|
this.interaction.withRequest(method, (0, matchers_1.matcherValueOrString)(path));
|
|
52
58
|
if (builder) {
|
|
53
59
|
builder(new requestBuilder_1.RequestBuilder(this.interaction));
|
|
54
60
|
}
|
|
55
61
|
return new interactionWithRequest_1.InteractionWithRequest(this.pact, this.interaction, this.opts, this.cleanupFn);
|
|
56
|
-
}
|
|
57
|
-
|
|
62
|
+
}
|
|
63
|
+
usingPlugin(config) {
|
|
58
64
|
this.pact.addPlugin(config.plugin, config.version);
|
|
59
65
|
return new interactionWithPlugin_1.InteractionWithPlugin(this.pact, this.interaction, this.opts, this.cleanupFn);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
}());
|
|
66
|
+
}
|
|
67
|
+
}
|
|
63
68
|
exports.UnconfiguredInteraction = UnconfiguredInteraction;
|
|
64
69
|
//# sourceMappingURL=unconfiguredInteraction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unconfiguredInteraction.js","sourceRoot":"","sources":["../../../../src/v4/http/unconfiguredInteraction.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"unconfiguredInteraction.js","sourceRoot":"","sources":["../../../../src/v4/http/unconfiguredInteraction.ts"],"names":[],"mappings":";;;AAMA,gDAA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AC;QAE9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS,CACP,KAAa,EACb,IAAY,EACZ,KAAa;QAEb,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAE7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mBAAmB,CAAC,QAAmB;QACrC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,WAAW,CACT,MAAc,EACd,IAAU,EACV,OAA8B;QAE9B,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,IAAA,+BAAoB,EAAC,IAAI,CAAC,CAAC,CAAC;QAEjE,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,+BAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,+CAAsB,CAC/B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,SAAS,CACf,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,MAAoB;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAEnD,OAAO,IAAI,6CAAqB,CAC9B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,SAAS,CACf,CAAC;IACJ,CAAC;CACF;AA1FD,0DA0FC"}
|
package/src/v4/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { V4UnconfiguredAsynchronousMessage, V4UnconfiguredSynchronousMessage } from './message/types';
|
|
4
|
-
import {
|
|
1
|
+
import type { V4UnconfiguredGraphQLInteraction } from './graphql/types';
|
|
2
|
+
import { PactV4Options, type V4UnconfiguredInteraction } from './http/types';
|
|
3
|
+
import type { V4UnconfiguredAsynchronousMessage, V4UnconfiguredSynchronousMessage } from './message/types';
|
|
4
|
+
import type { V4ConsumerPact } from './types';
|
|
5
5
|
export declare class PactV4 implements V4ConsumerPact {
|
|
6
6
|
private opts;
|
|
7
7
|
private pact;
|
|
@@ -12,6 +12,7 @@ export declare class PactV4 implements V4ConsumerPact {
|
|
|
12
12
|
addAsynchronousInteraction(): V4UnconfiguredAsynchronousMessage;
|
|
13
13
|
addGraphQLInteraction(): V4UnconfiguredGraphQLInteraction;
|
|
14
14
|
}
|
|
15
|
-
export
|
|
15
|
+
export * from '../xml';
|
|
16
16
|
export * from './graphql';
|
|
17
17
|
export * from './message/index';
|
|
18
|
+
export { PactV4 as Pact, PactV4Options as PactOptions };
|
package/src/v4/index.js
CHANGED
|
@@ -15,63 +15,60 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Pact = exports.PactV4 = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
const pact_core_1 = require("@pact-foundation/pact-core");
|
|
19
|
+
const package_json_1 = require("../../package.json");
|
|
20
|
+
const v3_1 = require("../v3");
|
|
21
|
+
const graphql_1 = require("./graphql");
|
|
22
|
+
const unconfiguredInteraction_1 = require("./http/unconfiguredInteraction");
|
|
23
|
+
const message_1 = require("./message");
|
|
24
|
+
const asynchronousMessage_1 = require("./message/asynchronousMessage");
|
|
25
|
+
class PactV4 {
|
|
26
|
+
opts;
|
|
27
|
+
pact;
|
|
28
|
+
constructor(opts) {
|
|
27
29
|
this.opts = opts;
|
|
28
30
|
this.setup();
|
|
31
|
+
}
|
|
32
|
+
setup() {
|
|
33
|
+
this.pact = (0, pact_core_1.makeConsumerPact)(this.opts.consumer, this.opts.provider, this.opts.spec ?? v3_1.SpecificationVersion.SPECIFICATION_VERSION_V4, this.opts.logLevel ?? 'info');
|
|
29
34
|
this.pact.addMetadata('pact-js', 'version', package_json_1.version);
|
|
30
35
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.pact = (0, pact_core_1.makeConsumerPact)(this.opts.consumer, this.opts.provider, (_a = this.opts.spec) !== null && _a !== void 0 ? _a : v3_1.SpecificationVersion.SPECIFICATION_VERSION_V4, (_b = this.opts.logLevel) !== null && _b !== void 0 ? _b : 'info');
|
|
34
|
-
};
|
|
35
|
-
PactV4.prototype.addInteraction = function () {
|
|
36
|
-
var _this = this;
|
|
37
|
-
return new unconfiguredInteraction_1.UnconfiguredInteraction(this.pact, this.pact.newInteraction(''), this.opts, function () {
|
|
36
|
+
addInteraction() {
|
|
37
|
+
return new unconfiguredInteraction_1.UnconfiguredInteraction(this.pact, this.pact.newInteraction(''), this.opts, () => {
|
|
38
38
|
// This function needs to be called if the PactV4 object is to be re-used (commonly expected by users)
|
|
39
39
|
// Because of the type-state model used here, it's a bit awkward as we need to thread this through
|
|
40
40
|
// to children, ultimately to be called on the "executeTest" stage.
|
|
41
|
-
|
|
41
|
+
this.setup();
|
|
42
42
|
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return new message_1.UnconfiguredSynchronousMessage(this.pact, this.pact.newSynchronousMessage(description), this.opts, function () {
|
|
43
|
+
}
|
|
44
|
+
addSynchronousInteraction(description) {
|
|
45
|
+
return new message_1.UnconfiguredSynchronousMessage(this.pact, this.pact.newSynchronousMessage(description), this.opts, () => {
|
|
47
46
|
// This function needs to be called if the PactV4 object is to be re-used (commonly expected by users)
|
|
48
47
|
// Because of the type-state model used here, it's a bit awkward as we need to thread this through
|
|
49
48
|
// to children, ultimately to be called on the "executeTest" stage.
|
|
50
|
-
|
|
49
|
+
this.setup();
|
|
51
50
|
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return new asynchronousMessage_1.UnconfiguredAsynchronousMessage(this.pact, this.pact.newAsynchronousMessage(''), this.opts, function () {
|
|
51
|
+
}
|
|
52
|
+
addAsynchronousInteraction() {
|
|
53
|
+
return new asynchronousMessage_1.UnconfiguredAsynchronousMessage(this.pact, this.pact.newAsynchronousMessage(''), this.opts, () => {
|
|
56
54
|
// This function needs to be called if the PactV4 object is to be re-used (commonly expected by users)
|
|
57
55
|
// Because of the type-state model used here, it's a bit awkward as we need to thread this through
|
|
58
56
|
// to children, ultimately to be called on the "executeTest" stage.
|
|
59
|
-
|
|
57
|
+
this.setup();
|
|
60
58
|
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return new graphql_1.UnconfiguredGraphQLInteraction(this.pact, this.pact.newInteraction(''), this.opts, function () {
|
|
59
|
+
}
|
|
60
|
+
addGraphQLInteraction() {
|
|
61
|
+
return new graphql_1.UnconfiguredGraphQLInteraction(this.pact, this.pact.newInteraction(''), this.opts, () => {
|
|
65
62
|
// This function needs to be called if the PactV4 object is to be re-used (commonly expected by users)
|
|
66
63
|
// Because of the type-state model used here, it's a bit awkward as we need to thread this through
|
|
67
64
|
// to children, ultimately to be called on the "executeTest" stage.
|
|
68
|
-
|
|
65
|
+
this.setup();
|
|
69
66
|
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
73
69
|
exports.PactV4 = PactV4;
|
|
74
70
|
exports.Pact = PactV4;
|
|
71
|
+
__exportStar(require("../xml"), exports);
|
|
75
72
|
__exportStar(require("./graphql"), exports);
|
|
76
73
|
__exportStar(require("./message/index"), exports);
|
|
77
74
|
//# sourceMappingURL=index.js.map
|
package/src/v4/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v4/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
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AC;IACJ,CAAC;IAED,0BAA0B;QACxB,OAAO,IAAI,qDAA+B,CACxC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,EAAE,CAAC,EACpC,IAAI,CAAC,IAAI,EACT,GAAG,EAAE;YACH,sGAAsG;YACtG,kGAAkG;YAClG,mEAAmE;YACnE,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC,CACF,CAAC;IACJ,CAAC;IAED,qBAAqB;QACnB,OAAO,IAAI,wCAA8B,CACvC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,EAC5B,IAAI,CAAC,IAAI,EACT,GAAG,EAAE;YACH,sGAAsG;YACtG,kGAAkG;YAClG,mEAAmE;YACnE,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AA1ED,wBA0EC;AAKkB,sBAAI;AAHvB,yCAAuB;AACvB,4CAA0B;AAC1B,kDAAgC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AnyJson, JsonMap } from '../../common/jsonTypes';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { PactV4Options } from '../http/types';
|
|
6
|
-
import {
|
|
1
|
+
import type { ConsumerPact, AsynchronousMessage as PactCoreAsynchronousMessage } from '@pact-foundation/pact-core';
|
|
2
|
+
import type { AnyJson, JsonMap } from '../../common/jsonTypes';
|
|
3
|
+
import type { Metadata } from '../../dsl/message';
|
|
4
|
+
import type { Rules } from '../../v3/types';
|
|
5
|
+
import type { PactV4Options } from '../http/types';
|
|
6
|
+
import type { AsynchronousMessage, Comment, CustomComment, PluginConfig, TransportConfig, V4AsynchronousMessageBuilder, V4AsynchronousMessageBuilderFunc, V4AsynchronousMessageWithContent, V4AsynchronousMessageWithPlugin, V4AsynchronousMessageWithPluginContents, V4AsynchronousMessageWithTransport, V4UnconfiguredAsynchronousMessage } from './types';
|
|
7
7
|
type Message = {
|
|
8
8
|
requestIsBinary: boolean;
|
|
9
9
|
interaction: PactCoreAsynchronousMessage;
|
|
@@ -20,6 +20,7 @@ export declare class UnconfiguredAsynchronousMessage implements V4UnconfiguredAs
|
|
|
20
20
|
pending(pending?: boolean): V4UnconfiguredAsynchronousMessage;
|
|
21
21
|
comment(comment: Comment | CustomComment): V4UnconfiguredAsynchronousMessage;
|
|
22
22
|
testName(name: string): V4UnconfiguredAsynchronousMessage;
|
|
23
|
+
reference(group: string, name: string, value: string): V4UnconfiguredAsynchronousMessage;
|
|
23
24
|
usingPlugin(config: PluginConfig): V4AsynchronousMessageWithPlugin;
|
|
24
25
|
}
|
|
25
26
|
export declare class AsynchronousMessageWithPlugin implements V4AsynchronousMessageWithPlugin {
|