@pact-foundation/pact 15.0.0 → 16.0.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.
Files changed (116) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +1 -2
  3. package/package.json +38 -34
  4. package/scripts/ci/release.sh +2 -1
  5. package/src/common/graphQL/configurationError.d.ts +2 -0
  6. package/src/common/graphQL/configurationError.js +27 -0
  7. package/src/common/graphQL/configurationError.js.map +1 -0
  8. package/src/common/graphQL/graphQL.d.ts +15 -0
  9. package/src/common/graphQL/graphQL.js +50 -0
  10. package/src/common/graphQL/graphQL.js.map +1 -0
  11. package/src/common/graphQL/graphQLQueryError.d.ts +2 -0
  12. package/src/common/graphQL/graphQLQueryError.js +27 -0
  13. package/src/common/graphQL/graphQLQueryError.js.map +1 -0
  14. package/src/common/graphQL/types.d.ts +4 -0
  15. package/src/common/graphQL/types.js +9 -0
  16. package/src/common/graphQL/types.js.map +1 -0
  17. package/src/dsl/graphql.d.ts +1 -3
  18. package/src/dsl/graphql.js +4 -8
  19. package/src/dsl/graphql.js.map +1 -1
  20. package/src/dsl/interaction.d.ts +4 -4
  21. package/src/dsl/interaction.js.map +1 -1
  22. package/src/dsl/matchers.d.ts +26 -26
  23. package/src/dsl/matchers.js +6 -6
  24. package/src/dsl/matchers.js.map +1 -1
  25. package/src/dsl/message.d.ts +4 -3
  26. package/src/dsl/options.d.ts +4 -4
  27. package/src/dsl/verifier/proxy/messages.js +55 -1
  28. package/src/dsl/verifier/proxy/messages.js.map +1 -1
  29. package/src/dsl/verifier/proxy/proxy.js +2 -2
  30. package/src/dsl/verifier/proxy/proxy.js.map +1 -1
  31. package/src/httpPact/ffi.js.map +1 -1
  32. package/src/httpPact/index.d.ts +7 -7
  33. package/src/httpPact/index.js +1 -1
  34. package/src/httpPact/index.js.map +1 -1
  35. package/src/httpPact/index.spec.js.map +1 -1
  36. package/src/index.d.ts +17 -4
  37. package/src/index.js +19 -5
  38. package/src/index.js.map +1 -1
  39. package/src/messageProviderPact.js +1 -1
  40. package/src/messageProviderPact.js.map +1 -1
  41. package/src/pact.integration.spec.js +0 -1
  42. package/src/pact.integration.spec.js.map +1 -1
  43. package/src/v3/graphql/graphQL.d.ts +90 -0
  44. package/src/v3/graphql/graphQL.js +175 -0
  45. package/src/v3/graphql/graphQL.js.map +1 -0
  46. package/src/v3/graphql/index.d.ts +4 -0
  47. package/src/v3/graphql/index.js +21 -0
  48. package/src/v3/graphql/index.js.map +1 -0
  49. package/src/v3/index.d.ts +1 -0
  50. package/src/v3/index.js +1 -0
  51. package/src/v3/index.js.map +1 -1
  52. package/src/v3/matchers.js +6 -6
  53. package/src/v3/matchers.js.map +1 -1
  54. package/src/v3/matchers.spec.js +33 -14
  55. package/src/v3/matchers.spec.js.map +1 -1
  56. package/src/v3/types.d.ts +1 -12
  57. package/src/v4/graphql/graphQLInteractionWithRequest.d.ts +35 -0
  58. package/src/v4/graphql/graphQLInteractionWithRequest.js +57 -0
  59. package/src/v4/graphql/graphQLInteractionWithRequest.js.map +1 -0
  60. package/src/v4/graphql/graphQLRequestBuilder.d.ts +9 -0
  61. package/src/v4/graphql/graphQLRequestBuilder.js +42 -0
  62. package/src/v4/graphql/graphQLRequestBuilder.js.map +1 -0
  63. package/src/v4/graphql/index.d.ts +19 -0
  64. package/src/v4/graphql/index.js +47 -0
  65. package/src/v4/graphql/index.js.map +1 -0
  66. package/src/v4/graphql/types.d.ts +30 -0
  67. package/src/v4/graphql/types.js +9 -0
  68. package/src/v4/graphql/types.js.map +1 -0
  69. package/src/v4/http/index.d.ts +4 -88
  70. package/src/v4/http/index.js +3 -271
  71. package/src/v4/http/index.js.map +1 -1
  72. package/src/v4/http/interactionWithCompleteRequest.d.ts +10 -0
  73. package/src/v4/http/interactionWithCompleteRequest.js +19 -0
  74. package/src/v4/http/interactionWithCompleteRequest.js.map +1 -0
  75. package/src/v4/http/interactionWithPlugin.d.ts +12 -0
  76. package/src/v4/http/interactionWithPlugin.js +30 -0
  77. package/src/v4/http/interactionWithPlugin.js.map +1 -0
  78. package/src/v4/http/interactionWithPluginRequest.d.ts +10 -0
  79. package/src/v4/http/interactionWithPluginRequest.js +24 -0
  80. package/src/v4/http/interactionWithPluginRequest.js.map +1 -0
  81. package/src/v4/http/interactionWithPluginResponse.d.ts +9 -0
  82. package/src/v4/http/interactionWithPluginResponse.js +58 -0
  83. package/src/v4/http/interactionWithPluginResponse.js.map +1 -0
  84. package/src/v4/http/interactionWithRequest.d.ts +10 -0
  85. package/src/v4/http/interactionWithRequest.js +24 -0
  86. package/src/v4/http/interactionWithRequest.js.map +1 -0
  87. package/src/v4/http/interactionWithResponse.d.ts +9 -0
  88. package/src/v4/http/interactionWithResponse.js +58 -0
  89. package/src/v4/http/interactionWithResponse.js.map +1 -0
  90. package/src/v4/http/requestBuilder.d.ts +13 -0
  91. package/src/v4/http/requestBuilder.js +60 -0
  92. package/src/v4/http/requestBuilder.js.map +1 -0
  93. package/src/v4/http/requestWithPluginBuilder.d.ts +12 -0
  94. package/src/v4/http/requestWithPluginBuilder.js +56 -0
  95. package/src/v4/http/requestWithPluginBuilder.js.map +1 -0
  96. package/src/v4/http/responseBuilder.d.ts +12 -0
  97. package/src/v4/http/responseBuilder.js +38 -0
  98. package/src/v4/http/responseBuilder.js.map +1 -0
  99. package/src/v4/http/responseWithPluginBuilder.d.ts +5 -0
  100. package/src/v4/http/responseWithPluginBuilder.js +32 -0
  101. package/src/v4/http/responseWithPluginBuilder.js.map +1 -0
  102. package/src/v4/http/types.d.ts +4 -3
  103. package/src/v4/http/unconfiguredInteraction.d.ts +16 -0
  104. package/src/v4/http/unconfiguredInteraction.js +47 -0
  105. package/src/v4/http/unconfiguredInteraction.js.map +1 -0
  106. package/src/v4/index.d.ts +7 -1
  107. package/src/v4/index.js +40 -3
  108. package/src/v4/index.js.map +1 -1
  109. package/src/v4/message/asynchronousMessage.d.ts +68 -0
  110. package/src/v4/message/asynchronousMessage.js +278 -0
  111. package/src/v4/message/asynchronousMessage.js.map +1 -0
  112. package/src/v4/message/index.d.ts +13 -3
  113. package/src/v4/message/index.js +50 -8
  114. package/src/v4/message/index.js.map +1 -1
  115. package/src/v4/message/types.d.ts +37 -5
  116. package/src/v4/types.d.ts +4 -1
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphQLInteractionWithRequest = void 0;
4
+ var lodash_1 = require("lodash");
5
+ var ramda_1 = require("ramda");
6
+ var graphQL_1 = require("../../common/graphQL/graphQL");
7
+ var interactionWithRequest_1 = require("../http/interactionWithRequest");
8
+ var types_1 = require("./types");
9
+ var matchers_1 = require("../../v3/matchers");
10
+ var GraphQLInteractionWithRequest = /** @class */ (function () {
11
+ // tslint:disable:no-empty-function
12
+ function GraphQLInteractionWithRequest(pact, interaction, opts, cleanupFn, graphQLRequest) {
13
+ this.pact = pact;
14
+ this.interaction = interaction;
15
+ this.opts = opts;
16
+ this.cleanupFn = cleanupFn;
17
+ this.graphQLRequest = graphQLRequest;
18
+ }
19
+ /**
20
+ * The actual GraphQL query as a string.
21
+ *
22
+ * NOTE: spaces are not important, Pact will auto-generate a space-insensitive matcher
23
+ *
24
+ * e.g. the value for the "query" field in the GraphQL HTTP payload:
25
+ * '{ "query": "{
26
+ * Category(id:7) {
27
+ * id,
28
+ * name,
29
+ * subcategories {
30
+ * id,
31
+ * name
32
+ * }
33
+ * }
34
+ * }"
35
+ * }'
36
+ * @param query {string|ASTNode} parsed or unparsed query
37
+ * @return this object
38
+ */
39
+ GraphQLInteractionWithRequest.prototype.withQuery = function (query) {
40
+ return this.setQueryDetails(query, types_1.OperationType.Query);
41
+ };
42
+ GraphQLInteractionWithRequest.prototype.withMutation = function (mutation) {
43
+ return this.setQueryDetails(mutation, types_1.OperationType.Mutation);
44
+ };
45
+ GraphQLInteractionWithRequest.prototype.setQueryDetails = function (query, type) {
46
+ var validatedQuery = (0, graphQL_1.validateQuery)(query, type);
47
+ this.interaction.withRequestBody(JSON.stringify((0, ramda_1.reject)(lodash_1.isUndefined, {
48
+ operationName: this.graphQLRequest.operation,
49
+ query: (0, matchers_1.regex)((0, graphQL_1.escapeGraphQlQuery)(validatedQuery), validatedQuery),
50
+ variables: this.graphQLRequest.variables,
51
+ })), 'application/json');
52
+ return new interactionWithRequest_1.InteractionWithRequest(this.pact, this.interaction, this.opts, this.cleanupFn);
53
+ };
54
+ return GraphQLInteractionWithRequest;
55
+ }());
56
+ exports.GraphQLInteractionWithRequest = GraphQLInteractionWithRequest;
57
+ //# sourceMappingURL=graphQLInteractionWithRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphQLInteractionWithRequest.js","sourceRoot":"","sources":["../../../../src/v4/graphql/graphQLInteractionWithRequest.ts"],"names":[],"mappings":";;;AAEA,iCAAqC;AACrC,+BAA+B;AAE/B,wDAGsC;AACtC,yEAAwE;AAExE,iCAIiB;AACjB,8CAA0C;AAE1C;IAGE,mCAAmC;IACnC,uCACY,IAAkB,EAClB,WAAgC,EAChC,IAAmB,EACnB,SAAqB,EACrB,cAA8B;QAJ9B,SAAI,GAAJ,IAAI,CAAc;QAClB,gBAAW,GAAX,WAAW,CAAqB;QAChC,SAAI,GAAJ,IAAI,CAAe;QACnB,cAAS,GAAT,SAAS,CAAY;QACrB,mBAAc,GAAd,cAAc,CAAgB;IACvC,CAAC;IAEJ;;;;;;;;;;;;;;;;;;;OAmBG;IACH,iDAAS,GAAT,UAAU,KAAuB;QAC/B,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,qBAAa,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;IAED,oDAAY,GAAZ,UAAa,QAA0B;QACrC,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,qBAAa,CAAC,QAAQ,CAAC,CAAC;IAChE,CAAC;IAEO,uDAAe,GAAvB,UACE,KAAuB,EACvB,IAAmB;QAEnB,IAAM,cAAc,GAAG,IAAA,uBAAa,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAElD,IAAI,CAAC,WAAW,CAAC,eAAe,CAC9B,IAAI,CAAC,SAAS,CACZ,IAAA,cAAM,EAAC,oBAAW,EAAE;YAClB,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,SAAS;YAC5C,KAAK,EAAE,IAAA,gBAAK,EAAC,IAAA,4BAAkB,EAAC,cAAc,CAAC,EAAE,cAAc,CAAC;YAChE,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,SAAS;SACzC,CAAC,CACH,EACD,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,+CAAsB,CAC/B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,SAAS,CACf,CAAC;IACJ,CAAC;IACH,oCAAC;AAAD,CAAC,AAhED,IAgEC;AAhEY,sEAA6B"}
@@ -0,0 +1,9 @@
1
+ import { ConsumerInteraction } from '@pact-foundation/pact-core';
2
+ import { TemplateQuery, TemplateHeaders } from '../../v3';
3
+ import { V4GraphQLRequestBuilder } from './types';
4
+ export declare class GraphQLRequestBuilder implements V4GraphQLRequestBuilder {
5
+ protected interaction: ConsumerInteraction;
6
+ constructor(interaction: ConsumerInteraction);
7
+ query(query: TemplateQuery): V4GraphQLRequestBuilder;
8
+ headers(headers: TemplateHeaders): V4GraphQLRequestBuilder;
9
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphQLRequestBuilder = void 0;
4
+ var ramda_1 = require("ramda");
5
+ var matchers_1 = require("../../v3/matchers");
6
+ var GraphQLRequestBuilder = /** @class */ (function () {
7
+ // tslint:disable:no-empty-function
8
+ function GraphQLRequestBuilder(interaction) {
9
+ this.interaction = interaction;
10
+ }
11
+ GraphQLRequestBuilder.prototype.query = function (query) {
12
+ var _this = this;
13
+ (0, ramda_1.forEachObjIndexed)(function (v, k) {
14
+ if (Array.isArray(v)) {
15
+ v.forEach(function (vv, i) {
16
+ _this.interaction.withQuery(k, i, (0, matchers_1.matcherValueOrString)(vv));
17
+ });
18
+ }
19
+ else {
20
+ _this.interaction.withQuery(k, 0, (0, matchers_1.matcherValueOrString)(v));
21
+ }
22
+ }, query);
23
+ return this;
24
+ };
25
+ GraphQLRequestBuilder.prototype.headers = function (headers) {
26
+ var _this = this;
27
+ (0, ramda_1.forEachObjIndexed)(function (v, k) {
28
+ if (Array.isArray(v)) {
29
+ v.forEach(function (header, index) {
30
+ _this.interaction.withRequestHeader("".concat(k), index, (0, matchers_1.matcherValueOrString)(header));
31
+ });
32
+ }
33
+ else {
34
+ _this.interaction.withRequestHeader("".concat(k), 0, (0, matchers_1.matcherValueOrString)(v));
35
+ }
36
+ }, headers);
37
+ return this;
38
+ };
39
+ return GraphQLRequestBuilder;
40
+ }());
41
+ exports.GraphQLRequestBuilder = GraphQLRequestBuilder;
42
+ //# sourceMappingURL=graphQLRequestBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphQLRequestBuilder.js","sourceRoot":"","sources":["../../../../src/v4/graphql/graphQLRequestBuilder.ts"],"names":[],"mappings":";;;AACA,+BAA0C;AAE1C,8CAAyD;AAIzD;IACE,mCAAmC;IACnC,+BAAsB,WAAgC;QAAhC,gBAAW,GAAX,WAAW,CAAqB;IAAG,CAAC;IAE1D,qCAAK,GAAL,UAAM,KAAoB;QAA1B,iBAYC;QAXC,IAAA,yBAAiB,EAAC,UAAC,CAAC,EAAE,CAAC;YACrB,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,CAAe,CAAC,OAAO,CAAC,UAAC,EAAE,EAAE,CAAC;oBAC7B,KAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAA,+BAAoB,EAAC,EAAE,CAAC,CAAC,CAAC;gBAC7D,CAAC,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,KAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAA,+BAAoB,EAAC,CAAC,CAAC,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC,EAAE,KAAK,CAAC,CAAC;QAEV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uCAAO,GAAP,UAAQ,OAAwB;QAAhC,iBAkBC;QAjBC,IAAA,yBAAiB,EAAC,UAAC,CAAC,EAAE,CAAC;YACrB,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,CAA8B,CAAC,OAAO,CACrC,UAAC,MAAgC,EAAE,KAAa;oBAC9C,KAAI,CAAC,WAAW,CAAC,iBAAiB,CAChC,UAAG,CAAC,CAAE,EACN,KAAK,EACL,IAAA,+BAAoB,EAAC,MAAM,CAAC,CAC7B,CAAC;gBACJ,CAAC,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,KAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,UAAG,CAAC,CAAE,EAAE,CAAC,EAAE,IAAA,+BAAoB,EAAC,CAAC,CAAC,CAAC,CAAC;YACzE,CAAC;QACH,CAAC,EAAE,OAAO,CAAC,CAAC;QAEZ,OAAO,IAAI,CAAC;IACd,CAAC;IACH,4BAAC;AAAD,CAAC,AArCD,IAqCC;AArCY,sDAAqB"}
@@ -0,0 +1,19 @@
1
+ import { ConsumerInteraction, ConsumerPact } from '@pact-foundation/pact-core';
2
+ import { V4GraphQLInteractionWithRequest, V4GraphQLRequestBuilderFunc, V4UnconfiguredGraphQLInteraction } from './types';
3
+ import { PactV4Options } from '../http/types';
4
+ import { JsonMap } from '../../common/jsonTypes';
5
+ import { Path } from '../../v3';
6
+ import { GraphQLVariables } from '../../common/graphQL/graphQL';
7
+ export declare class UnconfiguredGraphQLInteraction implements V4UnconfiguredGraphQLInteraction {
8
+ protected pact: ConsumerPact;
9
+ protected interaction: ConsumerInteraction;
10
+ protected opts: PactV4Options;
11
+ protected cleanupFn: () => void;
12
+ private graphQLRequest;
13
+ constructor(pact: ConsumerPact, interaction: ConsumerInteraction, opts: PactV4Options, cleanupFn: () => void);
14
+ withOperation(operation: string): V4UnconfiguredGraphQLInteraction;
15
+ withVariables(variables: GraphQLVariables): V4UnconfiguredGraphQLInteraction;
16
+ uponReceiving(description: string): V4UnconfiguredGraphQLInteraction;
17
+ given(state: string, parameters?: JsonMap): V4UnconfiguredGraphQLInteraction;
18
+ withRequest(method: string, path: Path, builder?: V4GraphQLRequestBuilderFunc): V4GraphQLInteractionWithRequest;
19
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnconfiguredGraphQLInteraction = void 0;
4
+ var matchers_1 = require("../../v3/matchers");
5
+ var graphQLRequestBuilder_1 = require("./graphQLRequestBuilder");
6
+ var graphQLInteractionWithRequest_1 = require("./graphQLInteractionWithRequest");
7
+ var UnconfiguredGraphQLInteraction = /** @class */ (function () {
8
+ // tslint:disable:no-empty-function
9
+ function UnconfiguredGraphQLInteraction(pact, interaction, opts, cleanupFn) {
10
+ this.pact = pact;
11
+ this.interaction = interaction;
12
+ this.opts = opts;
13
+ this.cleanupFn = cleanupFn;
14
+ this.graphQLRequest = {};
15
+ }
16
+ UnconfiguredGraphQLInteraction.prototype.withOperation = function (operation) {
17
+ this.graphQLRequest.operation = operation;
18
+ return this;
19
+ };
20
+ UnconfiguredGraphQLInteraction.prototype.withVariables = function (variables) {
21
+ this.graphQLRequest.variables = variables;
22
+ return this;
23
+ };
24
+ UnconfiguredGraphQLInteraction.prototype.uponReceiving = function (description) {
25
+ this.interaction.uponReceiving(description);
26
+ return this;
27
+ };
28
+ UnconfiguredGraphQLInteraction.prototype.given = function (state, parameters) {
29
+ if (parameters) {
30
+ this.interaction.givenWithParams(state, JSON.stringify(parameters));
31
+ }
32
+ else {
33
+ this.interaction.given(state);
34
+ }
35
+ return this;
36
+ };
37
+ UnconfiguredGraphQLInteraction.prototype.withRequest = function (method, path, builder) {
38
+ this.interaction.withRequest(method, (0, matchers_1.matcherValueOrString)(path));
39
+ if (builder) {
40
+ builder(new graphQLRequestBuilder_1.GraphQLRequestBuilder(this.interaction));
41
+ }
42
+ return new graphQLInteractionWithRequest_1.GraphQLInteractionWithRequest(this.pact, this.interaction, this.opts, this.cleanupFn, this.graphQLRequest);
43
+ };
44
+ return UnconfiguredGraphQLInteraction;
45
+ }());
46
+ exports.UnconfiguredGraphQLInteraction = UnconfiguredGraphQLInteraction;
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/v4/graphql/index.ts"],"names":[],"mappings":";;;AAWA,8CAAyD;AAEzD,iEAAgE;AAChE,iFAAgF;AAEhF;IAKE,mCAAmC;IACnC,wCACY,IAAkB,EAClB,WAAgC,EAChC,IAAmB,EACnB,SAAqB;QAHrB,SAAI,GAAJ,IAAI,CAAc;QAClB,gBAAW,GAAX,WAAW,CAAqB;QAChC,SAAI,GAAJ,IAAI,CAAe;QACnB,cAAS,GAAT,SAAS,CAAY;QAE/B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;IAC3B,CAAC;IAED,sDAAa,GAAb,UAAc,SAAiB;QAC7B,IAAI,CAAC,cAAc,CAAC,SAAS,GAAG,SAAS,CAAC;QAE1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sDAAa,GAAb,UAAc,SAA2B;QACvC,IAAI,CAAC,cAAc,CAAC,SAAS,GAAG,SAAS,CAAC;QAE1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sDAAa,GAAb,UAAc,WAAmB;QAC/B,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAE5C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8CAAK,GAAL,UAAM,KAAa,EAAE,UAAoB;QACvC,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;QACtE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oDAAW,GAAX,UACE,MAAc,EACd,IAAU,EACV,OAAqC;QAErC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,IAAA,+BAAoB,EAAC,IAAI,CAAC,CAAC,CAAC;QAEjE,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,6CAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,IAAI,6DAA6B,CACtC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,cAAc,CACpB,CAAC;IACJ,CAAC;IACH,qCAAC;AAAD,CAAC,AA7DD,IA6DC;AA7DY,wEAA8B"}
@@ -0,0 +1,30 @@
1
+ import { ASTNode } from 'graphql';
2
+ import { JsonMap } from '../../common/jsonTypes';
3
+ import { Path, TemplateHeaders, TemplateQuery } from '../../v3';
4
+ import { V4InteractionWithRequest } from '../http/types';
5
+ import { GraphQLVariables } from '../../common/graphQL/graphQL';
6
+ export declare enum OperationType {
7
+ Mutation = "Mutation",
8
+ Query = "Query"
9
+ }
10
+ export interface V4UnconfiguredGraphQLInteraction {
11
+ given(state: string, parameters?: JsonMap): V4UnconfiguredGraphQLInteraction;
12
+ uponReceiving(description: string): V4UnconfiguredGraphQLInteraction;
13
+ withOperation(operation: string): V4UnconfiguredGraphQLInteraction;
14
+ withVariables(variables: GraphQLVariables): V4UnconfiguredGraphQLInteraction;
15
+ withRequest(method: string, path: Path, builder?: V4GraphQLRequestBuilderFunc): V4GraphQLInteractionWithRequest;
16
+ }
17
+ export interface V4GraphQLInteractionWithRequest {
18
+ withQuery(query: string | ASTNode): V4InteractionWithRequest;
19
+ withMutation(mutation: string | ASTNode): V4InteractionWithRequest;
20
+ }
21
+ export type V4GraphQLRequestBuilderFunc = (builder: V4GraphQLRequestBuilder) => void;
22
+ export interface V4GraphQLRequestBuilder {
23
+ query(query: TemplateQuery): V4GraphQLRequestBuilder;
24
+ headers(headers: TemplateHeaders): V4GraphQLRequestBuilder;
25
+ }
26
+ export type GraphqlRequest = {
27
+ operation?: string;
28
+ mutation?: string;
29
+ variables?: GraphQLVariables;
30
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OperationType = void 0;
4
+ var OperationType;
5
+ (function (OperationType) {
6
+ OperationType["Mutation"] = "Mutation";
7
+ OperationType["Query"] = "Query";
8
+ })(OperationType || (exports.OperationType = OperationType = {}));
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/v4/graphql/types.ts"],"names":[],"mappings":";;;AAMA,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
@@ -1,88 +1,4 @@
1
- import { ConsumerInteraction, ConsumerPact } from '@pact-foundation/pact-core';
2
- import { JsonMap } from '../../common/jsonTypes';
3
- import { Path, TemplateHeaders, TemplateQuery } from '../../v3';
4
- import { PactV4Options, PluginConfig, V4InteractionWithCompleteRequest, V4InteractionWithPlugin, V4InteractionwithRequest, V4InteractionWithResponse, V4MockServer, V4Request, V4RequestBuilder, V4RequestBuilderFunc, V4ResponseBuilder, V4ResponseBuilderFunc, V4UnconfiguredInteraction, V4Response, V4InteractionWithPluginRequest, V4PluginResponseBuilderFunc, V4InteractionWithPluginResponse, V4RequestWithPluginBuilder, V4ResponseWithPluginBuilder, V4PluginRequestBuilderFunc, TestFunction } from './types';
5
- export declare class UnconfiguredInteraction implements V4UnconfiguredInteraction {
6
- protected pact: ConsumerPact;
7
- protected interaction: ConsumerInteraction;
8
- protected opts: PactV4Options;
9
- protected cleanupFn: () => void;
10
- constructor(pact: ConsumerPact, interaction: ConsumerInteraction, opts: PactV4Options, cleanupFn: () => void);
11
- uponReceiving(description: string): V4UnconfiguredInteraction;
12
- given(state: string, parameters?: JsonMap): V4UnconfiguredInteraction;
13
- withCompleteRequest(request: V4Request): V4InteractionWithCompleteRequest;
14
- withRequest(method: string, path: Path, builder?: V4RequestBuilderFunc): V4InteractionwithRequest;
15
- usingPlugin(config: PluginConfig): V4InteractionWithPlugin;
16
- }
17
- export declare class InteractionWithCompleteRequest implements V4InteractionWithCompleteRequest {
18
- private pact;
19
- private interaction;
20
- private opts;
21
- protected cleanupFn: () => void;
22
- constructor(pact: ConsumerPact, interaction: ConsumerInteraction, opts: PactV4Options, cleanupFn: () => void);
23
- withCompleteResponse(response: V4Response): V4InteractionWithResponse;
24
- }
25
- export declare class InteractionwithRequest implements V4InteractionwithRequest {
26
- private pact;
27
- private interaction;
28
- private opts;
29
- protected cleanupFn: () => void;
30
- constructor(pact: ConsumerPact, interaction: ConsumerInteraction, opts: PactV4Options, cleanupFn: () => void);
31
- willRespondWith(status: number, builder?: V4ResponseBuilderFunc): InteractionWithResponse;
32
- }
33
- export declare class RequestBuilder implements V4RequestBuilder {
34
- protected interaction: ConsumerInteraction;
35
- constructor(interaction: ConsumerInteraction);
36
- query(query: TemplateQuery): this;
37
- headers(headers: TemplateHeaders): this;
38
- jsonBody(body: unknown): this;
39
- binaryFile(contentType: string, file: string): this;
40
- multipartBody(contentType: string, file: string, mimePartName: string): this;
41
- body(contentType: string, body: Buffer): this;
42
- }
43
- export declare class ResponseBuilder implements V4ResponseBuilder {
44
- protected interaction: ConsumerInteraction;
45
- constructor(interaction: ConsumerInteraction);
46
- headers(headers: TemplateHeaders): this;
47
- jsonBody(body: unknown): this;
48
- binaryFile(contentType: string, file: string): this;
49
- multipartBody(contentType: string, file: string, mimePartName: string): this;
50
- body(contentType: string, body: Buffer): this;
51
- }
52
- export declare class InteractionWithResponse implements V4InteractionWithResponse {
53
- private pact;
54
- private opts;
55
- protected cleanupFn: () => void;
56
- constructor(pact: ConsumerPact, opts: PactV4Options, cleanupFn: () => void);
57
- executeTest<T>(testFn: TestFunction<T>): Promise<T | undefined>;
58
- }
59
- export declare class InteractionWithPlugin implements V4InteractionWithPlugin {
60
- private pact;
61
- private interaction;
62
- private opts;
63
- protected cleanupFn: () => void;
64
- constructor(pact: ConsumerPact, interaction: ConsumerInteraction, opts: PactV4Options, cleanupFn: () => void);
65
- usingPlugin(config: PluginConfig): V4InteractionWithPlugin;
66
- withRequest(method: string, path: Path, builder?: V4PluginRequestBuilderFunc): V4InteractionWithPluginRequest;
67
- }
68
- export declare class InteractionWithPluginRequest implements V4InteractionWithPluginRequest {
69
- private pact;
70
- private interaction;
71
- private opts;
72
- protected cleanupFn: () => void;
73
- constructor(pact: ConsumerPact, interaction: ConsumerInteraction, opts: PactV4Options, cleanupFn: () => void);
74
- willRespondWith(status: number, builder?: V4PluginResponseBuilderFunc): V4InteractionWithPluginResponse;
75
- }
76
- export declare class RequestWithPluginBuilder extends RequestBuilder implements V4RequestWithPluginBuilder {
77
- pluginContents(contentType: string, contents: string): V4RequestWithPluginBuilder;
78
- }
79
- export declare class ResponseWithPluginBuilder extends ResponseBuilder implements V4ResponseWithPluginBuilder {
80
- pluginContents(contentType: string, contents: string): V4ResponseBuilder;
81
- }
82
- export declare class InteractionWithPluginResponse implements V4InteractionWithPluginResponse {
83
- private pact;
84
- private opts;
85
- protected cleanupFn: () => void;
86
- constructor(pact: ConsumerPact, opts: PactV4Options, cleanupFn: () => void);
87
- executeTest<T>(testFn: (mockServer: V4MockServer) => Promise<T>): Promise<T | undefined>;
88
- }
1
+ import { ConsumerPact } from '@pact-foundation/pact-core';
2
+ import { PactV4Options, TestFunction } from './types';
3
+ export declare const readBinaryData: (file: string) => Buffer;
4
+ export declare const executeTest: <T>(pact: ConsumerPact, opts: PactV4Options, testFn: TestFunction<T>, cleanupFn: () => void) => Promise<T | undefined>;
@@ -1,19 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -54,265 +39,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
54
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
55
40
  };
56
41
  Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.InteractionWithPluginResponse = exports.ResponseWithPluginBuilder = exports.RequestWithPluginBuilder = exports.InteractionWithPluginRequest = exports.InteractionWithPlugin = exports.InteractionWithResponse = exports.ResponseBuilder = exports.RequestBuilder = exports.InteractionwithRequest = exports.InteractionWithCompleteRequest = exports.UnconfiguredInteraction = void 0;
58
- var ramda_1 = require("ramda");
59
- var matchers_1 = require("../../v3/matchers");
42
+ exports.executeTest = exports.readBinaryData = void 0;
60
43
  var fs = require("fs");
61
44
  var display_1 = require("../../v3/display");
62
45
  var logger_1 = __importDefault(require("../../common/logger"));
63
- var UnconfiguredInteraction = /** @class */ (function () {
64
- // tslint:disable:no-empty-function
65
- function UnconfiguredInteraction(pact, interaction, opts, cleanupFn) {
66
- this.pact = pact;
67
- this.interaction = interaction;
68
- this.opts = opts;
69
- this.cleanupFn = cleanupFn;
70
- }
71
- UnconfiguredInteraction.prototype.uponReceiving = function (description) {
72
- this.interaction.uponReceiving(description);
73
- return this;
74
- };
75
- UnconfiguredInteraction.prototype.given = function (state, parameters) {
76
- if (parameters) {
77
- this.interaction.givenWithParams(state, JSON.stringify(parameters));
78
- }
79
- else {
80
- this.interaction.given(state);
81
- }
82
- return this;
83
- };
84
- UnconfiguredInteraction.prototype.withCompleteRequest = function (request) {
85
- return new InteractionWithCompleteRequest(this.pact, this.interaction, this.opts, this.cleanupFn);
86
- };
87
- UnconfiguredInteraction.prototype.withRequest = function (method, path, builder) {
88
- this.interaction.withRequest(method, (0, matchers_1.matcherValueOrString)(path));
89
- if (builder) {
90
- builder(new RequestBuilder(this.interaction));
91
- }
92
- return new InteractionwithRequest(this.pact, this.interaction, this.opts, this.cleanupFn);
93
- };
94
- UnconfiguredInteraction.prototype.usingPlugin = function (config) {
95
- this.pact.addPlugin(config.plugin, config.version);
96
- return new InteractionWithPlugin(this.pact, this.interaction, this.opts, this.cleanupFn);
97
- };
98
- return UnconfiguredInteraction;
99
- }());
100
- exports.UnconfiguredInteraction = UnconfiguredInteraction;
101
- var InteractionWithCompleteRequest = /** @class */ (function () {
102
- function InteractionWithCompleteRequest(pact, interaction, opts, cleanupFn) {
103
- this.pact = pact;
104
- this.interaction = interaction;
105
- this.opts = opts;
106
- this.cleanupFn = cleanupFn;
107
- throw Error('V4InteractionWithCompleteRequest is unimplemented');
108
- }
109
- InteractionWithCompleteRequest.prototype.withCompleteResponse = function (response) {
110
- return new InteractionWithResponse(this.pact, this.opts, this.cleanupFn);
111
- };
112
- return InteractionWithCompleteRequest;
113
- }());
114
- exports.InteractionWithCompleteRequest = InteractionWithCompleteRequest;
115
- var InteractionwithRequest = /** @class */ (function () {
116
- // tslint:disable:no-empty-function
117
- function InteractionwithRequest(pact, interaction, opts, cleanupFn) {
118
- this.pact = pact;
119
- this.interaction = interaction;
120
- this.opts = opts;
121
- this.cleanupFn = cleanupFn;
122
- }
123
- InteractionwithRequest.prototype.willRespondWith = function (status, builder) {
124
- this.interaction.withStatus(status);
125
- if (typeof builder === 'function') {
126
- builder(new ResponseBuilder(this.interaction));
127
- }
128
- return new InteractionWithResponse(this.pact, this.opts, this.cleanupFn);
129
- };
130
- return InteractionwithRequest;
131
- }());
132
- exports.InteractionwithRequest = InteractionwithRequest;
133
- var RequestBuilder = /** @class */ (function () {
134
- // tslint:disable:no-empty-function
135
- function RequestBuilder(interaction) {
136
- this.interaction = interaction;
137
- }
138
- RequestBuilder.prototype.query = function (query) {
139
- var _this = this;
140
- (0, ramda_1.forEachObjIndexed)(function (v, k) {
141
- if (Array.isArray(v)) {
142
- v.forEach(function (vv, i) {
143
- _this.interaction.withQuery(k, i, (0, matchers_1.matcherValueOrString)(vv));
144
- });
145
- }
146
- else {
147
- _this.interaction.withQuery(k, 0, (0, matchers_1.matcherValueOrString)(v));
148
- }
149
- }, query);
150
- return this;
151
- };
152
- RequestBuilder.prototype.headers = function (headers) {
153
- var _this = this;
154
- (0, ramda_1.forEachObjIndexed)(function (v, k) {
155
- if (Array.isArray(v)) {
156
- v.forEach(function (header, index) {
157
- _this.interaction.withRequestHeader("".concat(k), index, (0, matchers_1.matcherValueOrString)(header));
158
- });
159
- }
160
- else {
161
- _this.interaction.withRequestHeader("".concat(k), 0, (0, matchers_1.matcherValueOrString)(v));
162
- }
163
- }, headers);
164
- return this;
165
- };
166
- RequestBuilder.prototype.jsonBody = function (body) {
167
- this.interaction.withRequestBody((0, matchers_1.matcherValueOrString)(body), 'application/json');
168
- return this;
169
- };
170
- RequestBuilder.prototype.binaryFile = function (contentType, file) {
171
- var body = readBinaryData(file);
172
- this.interaction.withRequestBinaryBody(body, contentType);
173
- return this;
174
- };
175
- RequestBuilder.prototype.multipartBody = function (contentType, file, mimePartName) {
176
- this.interaction.withRequestMultipartBody(contentType, file, mimePartName);
177
- return this;
178
- };
179
- RequestBuilder.prototype.body = function (contentType, body) {
180
- this.interaction.withRequestBinaryBody(body, contentType);
181
- return this;
182
- };
183
- return RequestBuilder;
184
- }());
185
- exports.RequestBuilder = RequestBuilder;
186
- var ResponseBuilder = /** @class */ (function () {
187
- function ResponseBuilder(interaction) {
188
- this.interaction = interaction;
189
- }
190
- ResponseBuilder.prototype.headers = function (headers) {
191
- var _this = this;
192
- (0, ramda_1.forEachObjIndexed)(function (v, k) {
193
- _this.interaction.withResponseHeader("".concat(k), 0, (0, matchers_1.matcherValueOrString)(v));
194
- }, headers);
195
- return this;
196
- };
197
- ResponseBuilder.prototype.jsonBody = function (body) {
198
- this.interaction.withResponseBody((0, matchers_1.matcherValueOrString)(body), 'application/json');
199
- return this;
200
- };
201
- ResponseBuilder.prototype.binaryFile = function (contentType, file) {
202
- var body = readBinaryData(file);
203
- this.interaction.withResponseBinaryBody(body, contentType);
204
- return this;
205
- };
206
- ResponseBuilder.prototype.multipartBody = function (contentType, file, mimePartName) {
207
- this.interaction.withResponseMultipartBody(contentType, file, mimePartName);
208
- return this;
209
- };
210
- ResponseBuilder.prototype.body = function (contentType, body) {
211
- this.interaction.withResponseBinaryBody(body, contentType);
212
- return this;
213
- };
214
- return ResponseBuilder;
215
- }());
216
- exports.ResponseBuilder = ResponseBuilder;
217
- var InteractionWithResponse = /** @class */ (function () {
218
- // tslint:disable:no-empty-function
219
- function InteractionWithResponse(pact, opts, cleanupFn) {
220
- this.pact = pact;
221
- this.opts = opts;
222
- this.cleanupFn = cleanupFn;
223
- }
224
- InteractionWithResponse.prototype.executeTest = function (testFn) {
225
- return __awaiter(this, void 0, void 0, function () {
226
- return __generator(this, function (_a) {
227
- return [2 /*return*/, executeTest(this.pact, this.opts, testFn, this.cleanupFn)];
228
- });
229
- });
230
- };
231
- return InteractionWithResponse;
232
- }());
233
- exports.InteractionWithResponse = InteractionWithResponse;
234
- var InteractionWithPlugin = /** @class */ (function () {
235
- // tslint:disable:no-empty-function
236
- function InteractionWithPlugin(pact, interaction, opts, cleanupFn) {
237
- this.pact = pact;
238
- this.interaction = interaction;
239
- this.opts = opts;
240
- this.cleanupFn = cleanupFn;
241
- }
242
- // Multiple plugins are allowed
243
- InteractionWithPlugin.prototype.usingPlugin = function (config) {
244
- this.pact.addPlugin(config.plugin, config.version);
245
- return this;
246
- };
247
- InteractionWithPlugin.prototype.withRequest = function (method, path, builder) {
248
- this.interaction.withRequest(method, (0, matchers_1.matcherValueOrString)(path));
249
- if (typeof builder === 'function') {
250
- builder(new RequestWithPluginBuilder(this.interaction));
251
- }
252
- return new InteractionWithPluginRequest(this.pact, this.interaction, this.opts, this.cleanupFn);
253
- };
254
- return InteractionWithPlugin;
255
- }());
256
- exports.InteractionWithPlugin = InteractionWithPlugin;
257
- var InteractionWithPluginRequest = /** @class */ (function () {
258
- // tslint:disable:no-empty-function
259
- function InteractionWithPluginRequest(pact, interaction, opts, cleanupFn) {
260
- this.pact = pact;
261
- this.interaction = interaction;
262
- this.opts = opts;
263
- this.cleanupFn = cleanupFn;
264
- }
265
- InteractionWithPluginRequest.prototype.willRespondWith = function (status, builder) {
266
- this.interaction.withStatus(status);
267
- if (typeof builder === 'function') {
268
- builder(new ResponseWithPluginBuilder(this.interaction));
269
- }
270
- return new InteractionWithPluginResponse(this.pact, this.opts, this.cleanupFn);
271
- };
272
- return InteractionWithPluginRequest;
273
- }());
274
- exports.InteractionWithPluginRequest = InteractionWithPluginRequest;
275
- var RequestWithPluginBuilder = /** @class */ (function (_super) {
276
- __extends(RequestWithPluginBuilder, _super);
277
- function RequestWithPluginBuilder() {
278
- return _super !== null && _super.apply(this, arguments) || this;
279
- }
280
- RequestWithPluginBuilder.prototype.pluginContents = function (contentType, contents) {
281
- this.interaction.withPluginRequestInteractionContents(contentType, contents);
282
- return this;
283
- };
284
- return RequestWithPluginBuilder;
285
- }(RequestBuilder));
286
- exports.RequestWithPluginBuilder = RequestWithPluginBuilder;
287
- var ResponseWithPluginBuilder = /** @class */ (function (_super) {
288
- __extends(ResponseWithPluginBuilder, _super);
289
- function ResponseWithPluginBuilder() {
290
- return _super !== null && _super.apply(this, arguments) || this;
291
- }
292
- ResponseWithPluginBuilder.prototype.pluginContents = function (contentType, contents) {
293
- this.interaction.withPluginResponseInteractionContents(contentType, contents);
294
- return this;
295
- };
296
- return ResponseWithPluginBuilder;
297
- }(ResponseBuilder));
298
- exports.ResponseWithPluginBuilder = ResponseWithPluginBuilder;
299
- var InteractionWithPluginResponse = /** @class */ (function () {
300
- // tslint:disable:no-empty-function
301
- function InteractionWithPluginResponse(pact, opts, cleanupFn) {
302
- this.pact = pact;
303
- this.opts = opts;
304
- this.cleanupFn = cleanupFn;
305
- }
306
- InteractionWithPluginResponse.prototype.executeTest = function (testFn) {
307
- return __awaiter(this, void 0, void 0, function () {
308
- return __generator(this, function (_a) {
309
- return [2 /*return*/, executeTest(this.pact, this.opts, testFn, this.cleanupFn)];
310
- });
311
- });
312
- };
313
- return InteractionWithPluginResponse;
314
- }());
315
- exports.InteractionWithPluginResponse = InteractionWithPluginResponse;
316
46
  var readBinaryData = function (file) {
317
47
  try {
318
48
  var body = fs.readFileSync(file);
@@ -322,6 +52,7 @@ var readBinaryData = function (file) {
322
52
  throw new Error("unable to read file for binary payload : ".concat(e.message));
323
53
  }
324
54
  };
55
+ exports.readBinaryData = readBinaryData;
325
56
  var cleanup = function (success, pact, opts, server, cleanupFn) {
326
57
  if (success) {
327
58
  pact.writePactFile(opts.dir || './pacts');
@@ -381,4 +112,5 @@ var executeTest = function (pact, opts, testFn, cleanupFn) { return __awaiter(vo
381
112
  }
382
113
  });
383
114
  }); };
115
+ exports.executeTest = executeTest;
384
116
  //# sourceMappingURL=index.js.map