@pact-foundation/pact-core 13.5.1 → 13.6.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 +24 -0
- package/binding.gyp +141 -0
- package/build/Makefile +334 -0
- package/build/binding.Makefile +6 -0
- package/build/copy_release_artifacts.target.mk +47 -0
- package/build/pact.target.mk +174 -0
- package/build/set_osx_install_name.target.mk +18 -0
- package/ffi/{v0.0.3-libpact_ffi-osx-aarch64-apple-darwin.dylib → libpact_ffi.dylib} +0 -0
- package/ffi/{v0.0.3-libpact_ffi-linux-x86_64.so → libpact_ffi.so} +0 -0
- package/ffi/libpact_ffi.so.gz +0 -0
- package/ffi/{v0.0.3-libpact_ffi-osx-x86_64.dylib → osxaarch64/libpact_ffi.dylib} +0 -0
- package/ffi/pact-cpp.h +2344 -0
- package/ffi/{v0.0.3-pact.h → pact.h} +667 -119
- package/ffi/{v0.0.3-pact_ffi-windows-x86_64.dll → pact_ffi.dll} +0 -0
- package/ffi/pact_ffi.dll.lib +0 -0
- package/native/addon.cc +68 -0
- package/native/consumer.cc +1570 -0
- package/native/consumer.h +124 -0
- package/native/ffi.cc +148 -0
- package/native/ffi.h +18 -0
- package/native/plugin.cc +6 -0
- package/native/plugin.h +7 -0
- package/native/provider.cc +815 -0
- package/native/provider.h +38 -0
- package/package.json +12 -9
- package/src/consumer/checkErrors.d.ts +7 -0
- package/src/consumer/checkErrors.js +41 -0
- package/src/consumer/checkErrors.js.map +1 -0
- package/src/consumer/index.d.ts +5 -0
- package/src/consumer/index.js +222 -0
- package/src/consumer/index.js.map +1 -0
- package/src/consumer/types.d.ts +132 -0
- package/src/{ffi/internals → consumer}/types.js +0 -0
- package/src/{ffi/internals → consumer}/types.js.map +0 -0
- package/src/ffi/index.d.ts +4 -3
- package/src/ffi/index.js +6 -9
- package/src/ffi/index.js.map +1 -1
- package/src/ffi/internals/index.d.ts +0 -2
- package/src/ffi/internals/index.js +1 -11
- package/src/ffi/internals/index.js.map +1 -1
- package/src/ffi/types.d.ts +100 -0
- package/src/ffi/types.js +70 -0
- package/src/ffi/types.js.map +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/index.js.map +1 -1
- package/src/logger/index.d.ts +5 -2
- package/src/logger/index.js +15 -2
- package/src/logger/index.js.map +1 -1
- package/src/verifier/argumentMapper/arguments.js +8 -0
- package/src/verifier/argumentMapper/arguments.js.map +1 -1
- package/src/verifier/index.js +1 -7
- package/src/verifier/index.js.map +1 -1
- package/src/verifier/nativeVerifier.js +74 -15
- package/src/verifier/nativeVerifier.js.map +1 -1
- package/src/verifier/types.d.ts +10 -2
- package/test.js +52 -0
- package/src/ffi/declarations.d.ts +0 -136
- package/src/ffi/declarations.js +0 -92
- package/src/ffi/declarations.js.map +0 -1
- package/src/ffi/internals/types.d.ts +0 -23
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#include <napi.h>
|
|
2
|
+
|
|
3
|
+
Napi::Value PactffiVerifierNewForApplication(const Napi::CallbackInfo& info);
|
|
4
|
+
Napi::Value PactffiVerifierExecute(const Napi::CallbackInfo& info);
|
|
5
|
+
Napi::Value PactffiVerifierShutdown(const Napi::CallbackInfo& info);
|
|
6
|
+
Napi::Value PactffiVerifierSetProviderInfo(const Napi::CallbackInfo& info);
|
|
7
|
+
Napi::Value PactffiVerifierSetFilterInfo(const Napi::CallbackInfo& info);
|
|
8
|
+
Napi::Value PactffiVerifierSetProviderState(const Napi::CallbackInfo& info);
|
|
9
|
+
Napi::Value PactffiVerifierSetVerificationOptions(const Napi::CallbackInfo& info);
|
|
10
|
+
Napi::Value PactffiVerifierSetPublishOptions(const Napi::CallbackInfo& info);
|
|
11
|
+
Napi::Value PactffiVerifierSetConsumerFilters(const Napi::CallbackInfo& info);
|
|
12
|
+
Napi::Value PactffiVerifierAddCustomHeader(const Napi::CallbackInfo& info);
|
|
13
|
+
Napi::Value PactffiVerifierAddFileSource(const Napi::CallbackInfo& info);
|
|
14
|
+
Napi::Value PactffiVerifierAddDirectorySource(const Napi::CallbackInfo& info);
|
|
15
|
+
Napi::Value PactffiVerifierUrlSource(const Napi::CallbackInfo& info);
|
|
16
|
+
// Napi::Value PactffiVerifierBrokerSource(const Napi::CallbackInfo& info);
|
|
17
|
+
Napi::Value PactffiVerifierBrokerSourceWithSelectors(const Napi::CallbackInfo& info);
|
|
18
|
+
// Unimplemented
|
|
19
|
+
// Napi::Value PactffiVerifierShutdown(const Napi::CallbackInfo& info);
|
|
20
|
+
// Napi::Value PactffiVerifierNewForApplication(const Napi::CallbackInfo& info);
|
|
21
|
+
// Napi::Value PactffiVerifierNew(const Napi::CallbackInfo& info);
|
|
22
|
+
// Napi::Value PactffiVerifierShutdown(const Napi::CallbackInfo& info);
|
|
23
|
+
// Napi::Value PactffiVerifierNewForApplication(const Napi::CallbackInfo& info);
|
|
24
|
+
// Napi::Value PactffiVerifierShutdown(const Napi::CallbackInfo& info);
|
|
25
|
+
// Napi::Value PactffiVerifierSetProviderInfo(const Napi::CallbackInfo& info);
|
|
26
|
+
// Napi::Value PactffiVerifierSetFilterInfo(const Napi::CallbackInfo& info);
|
|
27
|
+
// Napi::Value PactffiVerifierSetProviderState(const Napi::CallbackInfo& info);
|
|
28
|
+
// Napi::Value PactffiVerifierSetVerificationOptions(const Napi::CallbackInfo& info);
|
|
29
|
+
// Napi::Value PactffiVerifierSetConsumerFilters(const Napi::CallbackInfo& info);
|
|
30
|
+
// Napi::Value PactffiVerifierAddFileSource(const Napi::CallbackInfo& info);
|
|
31
|
+
// Napi::Value PactffiVerifierAddDirectorySource(const Napi::CallbackInfo& info);
|
|
32
|
+
// Napi::Value PactffiVerifierUrlSource(const Napi::CallbackInfo& info);
|
|
33
|
+
// Napi::Value PactffiVerifierBrokerSource(const Napi::CallbackInfo& info);
|
|
34
|
+
// Napi::Value PactffiVerifierBrokerSourceWithSelectors(const Napi::CallbackInfo& info);
|
|
35
|
+
// Napi::Value PactffiVerifierExecute(const Napi::CallbackInfo& info);
|
|
36
|
+
// Napi::Value PactffiVerifierCliArgs(const Napi::CallbackInfo& info);
|
|
37
|
+
// Napi::Value PactffiVerifierLogs(const Napi::CallbackInfo& info);
|
|
38
|
+
// Napi::Value PactffiVerifierLogsForProvider(const Napi::CallbackInfo& info);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pact-foundation/pact-core",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.6.0",
|
|
4
4
|
"description": "Core of @pact-foundation/pact. You almost certainly don't want to depend on this directly.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"homepage": "https://github.com/pact-foundation/pact-js-core#readme",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"provider",
|
|
40
40
|
"verifier"
|
|
41
41
|
],
|
|
42
|
-
"author": "
|
|
42
|
+
"author": "Matt Fellows <m@onegeek.com.au> (http://www.onegeek.com.au)",
|
|
43
43
|
"contributors": [
|
|
44
|
-
"
|
|
44
|
+
"Michel Boudreau <michelboudreau@gmail.com> (codinghitchhiker.com)"
|
|
45
45
|
],
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"bugs": {
|
|
@@ -53,17 +53,16 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@types/needle": "2.5.2",
|
|
55
55
|
"@types/pino": "6.3.11",
|
|
56
|
+
"bindings": "^1.5.0",
|
|
56
57
|
"chalk": "4.1.2",
|
|
57
58
|
"check-types": "7.3.0",
|
|
58
59
|
"cross-spawn": "7.0.3",
|
|
59
|
-
"ffi-napi": "^4.0.3",
|
|
60
60
|
"mkdirp": "1.0.0",
|
|
61
61
|
"needle": "2.8.0",
|
|
62
|
+
"node-addon-api": "^4.2.0",
|
|
62
63
|
"pino": "6.13.1",
|
|
63
64
|
"pino-pretty": "^6.0.0",
|
|
64
65
|
"promise-timeout": "1.3.0",
|
|
65
|
-
"ref-napi": "^3.0.3",
|
|
66
|
-
"ref-struct-di": "^1.1.1",
|
|
67
66
|
"rimraf": "2.6.2",
|
|
68
67
|
"underscore": "1.12.1",
|
|
69
68
|
"unixify": "1.0.0"
|
|
@@ -71,6 +70,7 @@
|
|
|
71
70
|
"devDependencies": {
|
|
72
71
|
"@pact-foundation/pact-js-prettier-config": "^1.0.0",
|
|
73
72
|
"@types/basic-auth": "^1.1.2",
|
|
73
|
+
"@types/bindings": "^1.5.1",
|
|
74
74
|
"@types/chai": "4.1.2",
|
|
75
75
|
"@types/chai-as-promised": "7.1.0",
|
|
76
76
|
"@types/check-types": "^7.3.2",
|
|
@@ -78,7 +78,6 @@
|
|
|
78
78
|
"@types/cross-spawn": "^6.0.1",
|
|
79
79
|
"@types/decompress": "^4.2.3",
|
|
80
80
|
"@types/express": "4.11.1",
|
|
81
|
-
"@types/ffi-napi": "^2.4.3",
|
|
82
81
|
"@types/jest": "^27.0.2",
|
|
83
82
|
"@types/mkdirp": "^0.5.2",
|
|
84
83
|
"@types/mocha": "9.0.0",
|
|
@@ -89,10 +88,10 @@
|
|
|
89
88
|
"@types/tar": "^4.0.3",
|
|
90
89
|
"@types/underscore": "1.8.7",
|
|
91
90
|
"@types/unixify": "^1.0.0",
|
|
92
|
-
"@types/unzipper": "^0.10.2",
|
|
93
91
|
"@types/url-join": "^4.0.0",
|
|
94
92
|
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
|
95
93
|
"@typescript-eslint/parser": "^5.2.0",
|
|
94
|
+
"axios": "^0.24.0",
|
|
96
95
|
"basic-auth": "2.0.0",
|
|
97
96
|
"body-parser": "1.18.2",
|
|
98
97
|
"chai": "4.1.2",
|
|
@@ -103,10 +102,12 @@
|
|
|
103
102
|
"eslint": "^8.1.0",
|
|
104
103
|
"eslint-config-prettier": "^8.3.0",
|
|
105
104
|
"express": "4.16.2",
|
|
105
|
+
"form-data": "^4.0.0",
|
|
106
106
|
"jest": "^27.3.1",
|
|
107
107
|
"mocha": "^9.1.3",
|
|
108
108
|
"nodemon": "^2.0.4",
|
|
109
109
|
"prettier": "^2.3.0",
|
|
110
|
+
"protobufjs": "^6.11.2",
|
|
110
111
|
"sinon": "9.2.4",
|
|
111
112
|
"snyk": "^1.747.0",
|
|
112
113
|
"standard-version": "^9.1.0",
|
|
@@ -125,7 +126,9 @@
|
|
|
125
126
|
"snyk-protect": "snyk protect",
|
|
126
127
|
"format:base": "prettier --parser typescript",
|
|
127
128
|
"format:check": "npm run format:base -- --list-different \"{src,standalone,bin,test}/**/*.{ts,tsx}\"",
|
|
128
|
-
"format:fix": "npm run format:base -- --write \"{src,standalone,bin,test}/**/*.{ts,tsx}\""
|
|
129
|
+
"format:fix": "npm run format:base -- --write \"{src,standalone,bin,test}/**/*.{ts,tsx}\"",
|
|
130
|
+
"postinstall": "npm run native",
|
|
131
|
+
"native": "node-gyp rebuild -v"
|
|
129
132
|
},
|
|
130
133
|
"prettier": "@pact-foundation/pact-js-prettier-config",
|
|
131
134
|
"standard-version": {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const wrapWithCheck: <F extends (...args: never[]) => boolean>(f: BooleanFunction<F>, contextMessage: string) => (...args: Parameters<F>) => boolean;
|
|
2
|
+
declare type BooleanFunction<T> = T extends (...args: infer A) => boolean ? (...args: A) => boolean : never;
|
|
3
|
+
declare type BooleanFunctions<T> = {
|
|
4
|
+
[key in keyof T]: BooleanFunction<T[key]>;
|
|
5
|
+
};
|
|
6
|
+
export declare const wrapAllWithCheck: <T extends BooleanFunctions<T>>(o: T) => BooleanFunctions<T>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.wrapAllWithCheck = exports.wrapWithCheck = void 0;
|
|
15
|
+
var logger_1 = require("../logger");
|
|
16
|
+
var wrapWithCheck = function (f, contextMessage) {
|
|
17
|
+
return function () {
|
|
18
|
+
var args = [];
|
|
19
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
20
|
+
args[_i] = arguments[_i];
|
|
21
|
+
}
|
|
22
|
+
var result = f.apply(void 0, args);
|
|
23
|
+
if (!result) {
|
|
24
|
+
logger_1.default.pactCrash("The pact consumer core returned false at '" + contextMessage + "'. This\nshould only happen if the core methods were invoked out of order");
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
exports.wrapWithCheck = wrapWithCheck;
|
|
30
|
+
var wrapAllWithCheck = function (o) {
|
|
31
|
+
return Object.keys(o)
|
|
32
|
+
.map(function (key) {
|
|
33
|
+
var _a;
|
|
34
|
+
return (_a = {},
|
|
35
|
+
_a[key] = exports.wrapWithCheck(o[key], key),
|
|
36
|
+
_a);
|
|
37
|
+
})
|
|
38
|
+
.reduce(function (acc, curr) { return (__assign(__assign({}, acc), curr)); }, {});
|
|
39
|
+
};
|
|
40
|
+
exports.wrapAllWithCheck = wrapAllWithCheck;
|
|
41
|
+
//# sourceMappingURL=checkErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkErrors.js","sourceRoot":"","sources":["checkErrors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oCAA+B;AAExB,IAAM,aAAa,GACxB,UACE,CAAqB,EACrB,cAAsB;IAExB,OAAA;QAAC,cAAsB;aAAtB,UAAsB,EAAtB,qBAAsB,EAAtB,IAAsB;YAAtB,yBAAsB;;QACrB,IAAM,MAAM,GAAG,CAAC,eAAI,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,MAAM,EAAE;YACX,gBAAM,CAAC,SAAS,CACd,+CAA6C,cAAc,8EAA2E,CACvI,CAAC;SACH;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;AARD,CAQC,CAAC;AAbS,QAAA,aAAa,iBAatB;AAUG,IAAM,gBAAgB,GAAG,UAC9B,CAAI;IAEJ,OAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;SACX,GAAG,CAAC,UAAC,GAAW;;QAAK,OAAA;YACpB,GAAC,GAAG,IAAG,qBAAa,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;eACjC;IAFoB,CAEpB,CAAC;SACF,MAAM,CAAC,UAAC,GAAG,EAAE,IAAI,IAAK,OAAA,uBAAM,GAAG,GAAK,IAAI,EAAG,EAArB,CAAqB,EAAE,EAAE,CAAM;AAJxD,CAIwD,CAAC;AAP9C,QAAA,gBAAgB,oBAO8B"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FfiSpecificationVersion } from '../ffi/types';
|
|
2
|
+
import { ConsumerMessagePact, ConsumerPact } from './types';
|
|
3
|
+
export declare const makeConsumerPact: (consumer: string, provider: string, version?: FfiSpecificationVersion, logLevel?: import("..").LogLevel) => ConsumerPact;
|
|
4
|
+
export declare const makeConsumerAsyncMessagePact: (consumer: string, provider: string, version?: FfiSpecificationVersion, logLevel?: import("..").LogLevel) => ConsumerMessagePact;
|
|
5
|
+
export * from './types';
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.makeConsumerAsyncMessagePact = exports.makeConsumerPact = void 0;
|
|
25
|
+
var types_1 = require("../ffi/types");
|
|
26
|
+
var logger_1 = require("../logger");
|
|
27
|
+
var checkErrors_1 = require("./checkErrors");
|
|
28
|
+
var ffi_1 = require("../ffi");
|
|
29
|
+
var makeConsumerPact = function (consumer, provider, version, logLevel) {
|
|
30
|
+
if (version === void 0) { version = 3; }
|
|
31
|
+
if (logLevel === void 0) { logLevel = logger_1.getLogLevel(); }
|
|
32
|
+
var ffi = ffi_1.getFfiLib(logLevel);
|
|
33
|
+
if (logLevel) {
|
|
34
|
+
logger_1.setLogLevel(logLevel);
|
|
35
|
+
}
|
|
36
|
+
var pactPtr = ffi.pactffiNewPact(consumer, provider);
|
|
37
|
+
if (!ffi.pactffiWithSpecification(pactPtr, version)) {
|
|
38
|
+
throw new Error("Unable to set core spec version. The pact FfiSpecificationVersion '" + version + "' may be invalid (note this is not the same as the pact spec version)");
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
addPlugin: function (name, version) {
|
|
42
|
+
ffi.pactffiUsingPlugin(pactPtr, name, version);
|
|
43
|
+
},
|
|
44
|
+
cleanupPlugins: function () {
|
|
45
|
+
ffi.pactffiCleanupPlugins(pactPtr);
|
|
46
|
+
},
|
|
47
|
+
createMockServer: function (address, requestedPort, tls) {
|
|
48
|
+
if (tls === void 0) { tls = false; }
|
|
49
|
+
var port = ffi.pactffiCreateMockServerForPact(pactPtr, address + ":" + (requestedPort ? requestedPort : 0), tls);
|
|
50
|
+
var error = Object.keys(types_1.CREATE_MOCK_SERVER_ERRORS).find(function (key) { return types_1.CREATE_MOCK_SERVER_ERRORS[key] === port; });
|
|
51
|
+
if (error) {
|
|
52
|
+
if (error === 'ADDRESS_NOT_VALID') {
|
|
53
|
+
logger_1.logErrorAndThrow("Unable to start mock server at '" + address + "'. Is the address and port valid?");
|
|
54
|
+
}
|
|
55
|
+
if (error === 'TLS_CONFIG') {
|
|
56
|
+
logger_1.logErrorAndThrow("Unable to create TLS configuration with self-signed certificate");
|
|
57
|
+
}
|
|
58
|
+
logger_1.logCrashAndThrow("The pact core couldn't create the mock server because of an error described by '" + error + "'");
|
|
59
|
+
}
|
|
60
|
+
if (port <= 0) {
|
|
61
|
+
logger_1.logCrashAndThrow("The pact core returned an unhandled error code '" + port + "'");
|
|
62
|
+
}
|
|
63
|
+
return port;
|
|
64
|
+
},
|
|
65
|
+
mockServerMatchedSuccessfully: function (port) {
|
|
66
|
+
return ffi.pactffiMockServerMatched(port);
|
|
67
|
+
},
|
|
68
|
+
mockServerMismatches: function (port) {
|
|
69
|
+
var results = JSON.parse(ffi.pactffiMockServerMismatches(port));
|
|
70
|
+
return results.map(function (result) { return (__assign(__assign({}, result), ('mismatches' in result
|
|
71
|
+
? {
|
|
72
|
+
mismatches: result.mismatches.map(function (m) {
|
|
73
|
+
return typeof m === 'string' ? JSON.parse(m) : m;
|
|
74
|
+
}),
|
|
75
|
+
}
|
|
76
|
+
: {}))); });
|
|
77
|
+
},
|
|
78
|
+
cleanupMockServer: function (port) {
|
|
79
|
+
return checkErrors_1.wrapWithCheck(function (port) { return ffi.pactffiCleanupMockServer(port); }, 'cleanupMockServer')(port);
|
|
80
|
+
},
|
|
81
|
+
writePactFile: function (dir, merge) {
|
|
82
|
+
if (merge === void 0) { merge = true; }
|
|
83
|
+
return writePact(ffi, pactPtr, dir, merge);
|
|
84
|
+
},
|
|
85
|
+
addMetadata: function (namespace, name, value) {
|
|
86
|
+
return ffi.pactffiWithPactMetadata(pactPtr, namespace, name, value);
|
|
87
|
+
},
|
|
88
|
+
newInteraction: function (description) {
|
|
89
|
+
var interactionPtr = ffi.pactffiNewInteraction(pactPtr, description);
|
|
90
|
+
return checkErrors_1.wrapAllWithCheck({
|
|
91
|
+
uponReceiving: function (description) {
|
|
92
|
+
return ffi.pactffiUponReceiving(interactionPtr, description);
|
|
93
|
+
},
|
|
94
|
+
given: function (state) {
|
|
95
|
+
return ffi.pactffiGiven(interactionPtr, state);
|
|
96
|
+
},
|
|
97
|
+
givenWithParam: function (state, name, value) {
|
|
98
|
+
return ffi.pactffiGivenWithParam(interactionPtr, state, name, value);
|
|
99
|
+
},
|
|
100
|
+
withRequest: function (method, path) {
|
|
101
|
+
return ffi.pactffiWithRequest(interactionPtr, method, path);
|
|
102
|
+
},
|
|
103
|
+
withQuery: function (name, index, value) {
|
|
104
|
+
return ffi.pactffiWithQueryParameter(interactionPtr, name, index, value);
|
|
105
|
+
},
|
|
106
|
+
withRequestHeader: function (name, index, value) {
|
|
107
|
+
return ffi.pactffiWithHeader(interactionPtr, types_1.INTERACTION_PART_REQUEST, name, index, value);
|
|
108
|
+
},
|
|
109
|
+
withRequestBody: function (body, contentType) {
|
|
110
|
+
return ffi.pactffiWithBody(interactionPtr, types_1.INTERACTION_PART_REQUEST, contentType, body);
|
|
111
|
+
},
|
|
112
|
+
withRequestBinaryBody: function (body, contentType) {
|
|
113
|
+
return ffi.pactffiWithBinaryFile(interactionPtr, types_1.INTERACTION_PART_REQUEST, contentType, body, body.length);
|
|
114
|
+
},
|
|
115
|
+
withRequestMultipartBody: function (contentType, filename, mimePartName) {
|
|
116
|
+
return (ffi.pactffiWithMultipartFile(interactionPtr, types_1.INTERACTION_PART_REQUEST, contentType, filename, mimePartName) === undefined);
|
|
117
|
+
},
|
|
118
|
+
withResponseHeader: function (name, index, value) {
|
|
119
|
+
return ffi.pactffiWithHeader(interactionPtr, types_1.INTERACTION_PART_RESPONSE, name, index, value);
|
|
120
|
+
},
|
|
121
|
+
withResponseBody: function (body, contentType) {
|
|
122
|
+
return ffi.pactffiWithBody(interactionPtr, types_1.INTERACTION_PART_RESPONSE, contentType, body);
|
|
123
|
+
},
|
|
124
|
+
withResponseBinaryBody: function (body, contentType) {
|
|
125
|
+
return ffi.pactffiWithBinaryFile(interactionPtr, types_1.INTERACTION_PART_RESPONSE, contentType, body, body.length);
|
|
126
|
+
},
|
|
127
|
+
withResponseMultipartBody: function (contentType, filename, mimePartName) {
|
|
128
|
+
return (ffi.pactffiWithMultipartFile(interactionPtr, types_1.INTERACTION_PART_RESPONSE, contentType, filename, mimePartName) === undefined);
|
|
129
|
+
},
|
|
130
|
+
withStatus: function (status) {
|
|
131
|
+
return ffi.pactffiResponseStatus(interactionPtr, status);
|
|
132
|
+
},
|
|
133
|
+
withPluginRequestInteractionContents: function (contentType, contents) {
|
|
134
|
+
ffi.pactffiPluginInteractionContents(interactionPtr, types_1.INTERACTION_PART_REQUEST, contentType, contents);
|
|
135
|
+
return true;
|
|
136
|
+
},
|
|
137
|
+
withPluginResponseInteractionContents: function (contentType, contents) {
|
|
138
|
+
ffi.pactffiPluginInteractionContents(interactionPtr, types_1.INTERACTION_PART_RESPONSE, contentType, contents);
|
|
139
|
+
return true;
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
exports.makeConsumerPact = makeConsumerPact;
|
|
146
|
+
var makeConsumerAsyncMessagePact = function (consumer, provider, version, logLevel) {
|
|
147
|
+
if (version === void 0) { version = 4; }
|
|
148
|
+
if (logLevel === void 0) { logLevel = logger_1.getLogLevel(); }
|
|
149
|
+
var ffi = ffi_1.getFfiLib(logLevel);
|
|
150
|
+
if (logLevel) {
|
|
151
|
+
logger_1.setLogLevel(logLevel);
|
|
152
|
+
}
|
|
153
|
+
var pactPtr = ffi.pactffiNewPact(consumer, provider);
|
|
154
|
+
if (!ffi.pactffiWithSpecification(pactPtr, version) || version < 4) {
|
|
155
|
+
throw new Error("Unable to set core spec version. The pact FfiSpecificationVersion '" + version + "' may be invalid (note this is not the same as the pact spec version). It should be set to at least 3");
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
addPlugin: function (name, version) {
|
|
159
|
+
ffi.pactffiUsingPlugin(pactPtr, name, version);
|
|
160
|
+
},
|
|
161
|
+
cleanupPlugins: function () {
|
|
162
|
+
ffi.pactffiCleanupPlugins(pactPtr);
|
|
163
|
+
},
|
|
164
|
+
writePactFile: function (dir, merge) {
|
|
165
|
+
if (merge === void 0) { merge = true; }
|
|
166
|
+
return writePact(ffi, pactPtr, dir, merge);
|
|
167
|
+
},
|
|
168
|
+
addMetadata: function (namespace, name, value) {
|
|
169
|
+
return ffi.pactffiWithPactMetadata(pactPtr, namespace, name, value);
|
|
170
|
+
},
|
|
171
|
+
newMessage: function (description) {
|
|
172
|
+
var interactionPtr = ffi.pactffiNewAsyncMessage(pactPtr, description);
|
|
173
|
+
return {
|
|
174
|
+
withPluginRequestInteractionContents: function (contentType, contents) {
|
|
175
|
+
ffi.pactffiPluginInteractionContents(interactionPtr, types_1.INTERACTION_PART_REQUEST, contentType, contents);
|
|
176
|
+
return true;
|
|
177
|
+
},
|
|
178
|
+
withPluginResponseInteractionContents: function (contentType, contents) {
|
|
179
|
+
ffi.pactffiPluginInteractionContents(interactionPtr, types_1.INTERACTION_PART_RESPONSE, contentType, contents);
|
|
180
|
+
return true;
|
|
181
|
+
},
|
|
182
|
+
expectsToReceive: function (description) {
|
|
183
|
+
return ffi.pactffiMessageExpectsToReceive(interactionPtr, description);
|
|
184
|
+
},
|
|
185
|
+
given: function (state) {
|
|
186
|
+
return ffi.pactffiMessageGiven(interactionPtr, state);
|
|
187
|
+
},
|
|
188
|
+
givenWithParam: function (state, name, value) {
|
|
189
|
+
return ffi.pactffiMessageGivenWithParam(interactionPtr, state, name, value);
|
|
190
|
+
},
|
|
191
|
+
withContents: function (body, contentType) {
|
|
192
|
+
return ffi.pactffiMessageWithContents(interactionPtr, contentType, body, body.length);
|
|
193
|
+
},
|
|
194
|
+
reifyMessage: function () {
|
|
195
|
+
return ffi.pactffiMessageReify(interactionPtr);
|
|
196
|
+
},
|
|
197
|
+
withMetadata: function (name, value) {
|
|
198
|
+
return ffi.pactffiMessageWithMetadata(interactionPtr, name, value);
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
exports.makeConsumerAsyncMessagePact = makeConsumerAsyncMessagePact;
|
|
205
|
+
var writePact = function (ffi, pactPtr, dir, merge) {
|
|
206
|
+
if (merge === void 0) { merge = true; }
|
|
207
|
+
var result = ffi.pactffiWritePactFile(pactPtr, dir, !merge);
|
|
208
|
+
switch (result) {
|
|
209
|
+
case types_1.FfiWritePactResponse.SUCCESS:
|
|
210
|
+
return;
|
|
211
|
+
case types_1.FfiWritePactResponse.UNABLE_TO_WRITE_PACT_FILE:
|
|
212
|
+
logger_1.logErrorAndThrow('The pact core was unable to write the pact file');
|
|
213
|
+
case types_1.FfiWritePactResponse.GENERAL_PANIC:
|
|
214
|
+
logger_1.logCrashAndThrow('The pact core panicked while writing the pact file');
|
|
215
|
+
case types_1.FfiWritePactResponse.MOCK_SERVER_NOT_FOUND:
|
|
216
|
+
logger_1.logCrashAndThrow('The pact core was asked to write a pact file from a mock server that appears not to exist');
|
|
217
|
+
default:
|
|
218
|
+
logger_1.logCrashAndThrow("The pact core returned an unknown error code (" + result + ") instead of writing the pact");
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
__exportStar(require("./types"), exports);
|
|
222
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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type MatchingResult = MatchingResultSuccess | MatchingResultRequestMismatch | MatchingResultRequestNotFound | MatchingResultMissingRequest;
|
|
3
|
+
export declare type MatchingResultSuccess = {
|
|
4
|
+
type: 'request-match';
|
|
5
|
+
};
|
|
6
|
+
export declare type MatchingResultRequestMismatch = {
|
|
7
|
+
type: 'request-mismatch';
|
|
8
|
+
method: string;
|
|
9
|
+
path: string;
|
|
10
|
+
mismatches: Mismatch[];
|
|
11
|
+
};
|
|
12
|
+
export declare type MatchingResultRequestNotFound = {
|
|
13
|
+
type: 'request-not-found';
|
|
14
|
+
method: string;
|
|
15
|
+
path: string;
|
|
16
|
+
request: RequestMismatch;
|
|
17
|
+
};
|
|
18
|
+
export declare type MatchingResultMissingRequest = {
|
|
19
|
+
type: 'missing-request';
|
|
20
|
+
method: string;
|
|
21
|
+
path: string;
|
|
22
|
+
request: RequestMismatch;
|
|
23
|
+
};
|
|
24
|
+
export declare type Mismatch = MethodMismatch | PathMismatch | StatusMismatch | QueryMismatch | HeaderMismatch | BodyTypeMismatch | BodyMismatch | MetadataMismatch;
|
|
25
|
+
export declare type MethodMismatch = {
|
|
26
|
+
type: 'MethodMismatch';
|
|
27
|
+
expected: string;
|
|
28
|
+
actual: string;
|
|
29
|
+
};
|
|
30
|
+
export declare type PathMismatch = {
|
|
31
|
+
type: 'PathMismatch';
|
|
32
|
+
expected: string;
|
|
33
|
+
actual: string;
|
|
34
|
+
mismatch: string;
|
|
35
|
+
};
|
|
36
|
+
export declare type StatusMismatch = {
|
|
37
|
+
type: 'StatusMismatch';
|
|
38
|
+
expected: string;
|
|
39
|
+
actual: string;
|
|
40
|
+
mismatch: string;
|
|
41
|
+
};
|
|
42
|
+
export declare type QueryMismatch = {
|
|
43
|
+
type: 'QueryMismatch';
|
|
44
|
+
parameter: string;
|
|
45
|
+
expected: string;
|
|
46
|
+
actual: string;
|
|
47
|
+
mismatch: string;
|
|
48
|
+
};
|
|
49
|
+
export declare type HeaderMismatch = {
|
|
50
|
+
type: 'HeaderMismatch';
|
|
51
|
+
key: string;
|
|
52
|
+
expected: string;
|
|
53
|
+
actual: string;
|
|
54
|
+
mismatch: string;
|
|
55
|
+
};
|
|
56
|
+
export declare type BodyTypeMismatch = {
|
|
57
|
+
type: 'BodyTypeMismatch';
|
|
58
|
+
expected: string;
|
|
59
|
+
actual: string;
|
|
60
|
+
mismatch: string;
|
|
61
|
+
expectedBody?: string;
|
|
62
|
+
actualBody?: string;
|
|
63
|
+
};
|
|
64
|
+
export declare type BodyMismatch = {
|
|
65
|
+
type: 'BodyMismatch';
|
|
66
|
+
path: string;
|
|
67
|
+
expected?: string;
|
|
68
|
+
actual?: string;
|
|
69
|
+
mismatch: string;
|
|
70
|
+
};
|
|
71
|
+
export declare type MetadataMismatch = {
|
|
72
|
+
type: 'MetadataMismatch';
|
|
73
|
+
key: string;
|
|
74
|
+
expected: string;
|
|
75
|
+
actual: string;
|
|
76
|
+
mismatch: string;
|
|
77
|
+
};
|
|
78
|
+
export declare type RequestMismatch = {
|
|
79
|
+
method?: string;
|
|
80
|
+
path?: string;
|
|
81
|
+
headers?: Record<string, Array<string>>;
|
|
82
|
+
query?: Record<string, Array<string>>;
|
|
83
|
+
body?: string;
|
|
84
|
+
};
|
|
85
|
+
export declare type PluginInteraction = {
|
|
86
|
+
withPluginRequestInteractionContents: (contentType: string, contents: string) => boolean;
|
|
87
|
+
withPluginResponseInteractionContents: (contentType: string, contents: string) => boolean;
|
|
88
|
+
};
|
|
89
|
+
export declare type PluginPact = {
|
|
90
|
+
addPlugin: (plugin: string, version: string) => void;
|
|
91
|
+
cleanupPlugins: () => void;
|
|
92
|
+
};
|
|
93
|
+
export declare type ConsumerInteraction = PluginInteraction & {
|
|
94
|
+
uponReceiving: (description: string) => boolean;
|
|
95
|
+
given: (state: string) => boolean;
|
|
96
|
+
givenWithParam: (state: string, name: string, value: string) => boolean;
|
|
97
|
+
withRequest: (method: string, path: string) => boolean;
|
|
98
|
+
withQuery: (name: string, index: number, value: string) => boolean;
|
|
99
|
+
withStatus: (status: number) => boolean;
|
|
100
|
+
withRequestHeader: (name: string, index: number, value: string) => boolean;
|
|
101
|
+
withRequestBody: (body: string, contentType: string) => boolean;
|
|
102
|
+
withRequestBinaryBody: (body: Buffer, contentType: string) => boolean;
|
|
103
|
+
withRequestMultipartBody: (contentType: string, filename: string, mimePartName: string) => boolean;
|
|
104
|
+
withResponseHeader: (name: string, index: number, value: string) => boolean;
|
|
105
|
+
withResponseBody: (body: string, contentType: string) => boolean;
|
|
106
|
+
withResponseBinaryBody: (body: Buffer, contentType: string) => boolean;
|
|
107
|
+
withResponseMultipartBody: (contentType: string, filename: string, mimePartName: string) => boolean;
|
|
108
|
+
withPluginRequestInteractionContents: (contentType: string, contents: string) => void;
|
|
109
|
+
withPluginResponseInteractionContents: (contentType: string, contents: string) => void;
|
|
110
|
+
};
|
|
111
|
+
export declare type ConsumerPact = PluginPact & {
|
|
112
|
+
newInteraction: (description: string) => ConsumerInteraction;
|
|
113
|
+
createMockServer: (address: string, port?: number, tls?: boolean) => number;
|
|
114
|
+
mockServerMismatches: (port: number) => MatchingResult[];
|
|
115
|
+
cleanupMockServer: (port: number) => boolean;
|
|
116
|
+
writePactFile: (dir: string, merge?: boolean) => void;
|
|
117
|
+
mockServerMatchedSuccessfully: (port: number) => boolean;
|
|
118
|
+
addMetadata: (namespace: string, name: string, value: string) => boolean;
|
|
119
|
+
};
|
|
120
|
+
export declare type ConsumerMessage = PluginInteraction & {
|
|
121
|
+
given: (state: string) => void;
|
|
122
|
+
givenWithParam: (state: string, name: string, value: string) => void;
|
|
123
|
+
expectsToReceive: (description: string) => void;
|
|
124
|
+
withMetadata: (name: string, value: string) => void;
|
|
125
|
+
withContents: (body: Buffer, contentType: string) => void;
|
|
126
|
+
reifyMessage: () => string;
|
|
127
|
+
};
|
|
128
|
+
export declare type ConsumerMessagePact = PluginPact & {
|
|
129
|
+
newMessage: (description: string) => ConsumerMessage;
|
|
130
|
+
writePactFile: (dir: string, overwrite?: boolean) => void;
|
|
131
|
+
addMetadata: (namespace: string, name: string, value: string) => boolean;
|
|
132
|
+
};
|
|
File without changes
|
|
File without changes
|
package/src/ffi/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FfiBinding } from './internals/types';
|
|
2
1
|
import { LogLevel } from '../logger/types';
|
|
3
|
-
import {
|
|
4
|
-
declare
|
|
2
|
+
import { Ffi } from './types';
|
|
3
|
+
declare const ffiLib: Ffi;
|
|
4
|
+
export declare const PACT_FFI_VERSION = "0.2.4";
|
|
5
|
+
declare let ffi: typeof ffiLib;
|
|
5
6
|
export declare const getFfiLib: (logLevel?: LogLevel) => typeof ffi;
|
|
6
7
|
export {};
|
package/src/ffi/index.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFfiLib = void 0;
|
|
4
|
-
var internals_1 = require("./internals");
|
|
3
|
+
exports.getFfiLib = exports.PACT_FFI_VERSION = void 0;
|
|
5
4
|
var logger_1 = require("../logger");
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
5
|
+
var bindings = require("bindings");
|
|
6
|
+
var ffiLib = bindings('pact.node');
|
|
7
|
+
exports.PACT_FFI_VERSION = '0.2.4';
|
|
9
8
|
var ffi;
|
|
10
9
|
var ffiLogLevel;
|
|
11
10
|
var initialiseFfi = function (logLevel) {
|
|
12
11
|
logger_1.default.debug("Initalising native core at log level '" + logLevel + "'");
|
|
13
|
-
process.env[LOG_ENV_VAR_NAME] = logLevel.toUpperCase();
|
|
14
12
|
ffiLogLevel = logLevel;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return lib;
|
|
13
|
+
ffiLib.pactffiInitWithLogLevel(logLevel);
|
|
14
|
+
return ffiLib;
|
|
18
15
|
};
|
|
19
16
|
var getFfiLib = function (logLevel) {
|
|
20
17
|
if (logLevel === void 0) { logLevel = logger_1.DEFAULT_LOG_LEVEL; }
|
package/src/ffi/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,oCAAsD;AAGtD,mCAAsC;AAEtC,IAAM,MAAM,GAAQ,QAAQ,CAAC,WAAW,CAAC,CAAC;AAE7B,QAAA,gBAAgB,GAAG,OAAO,CAAC;AAExC,IAAI,GAAkB,CAAC;AACvB,IAAI,WAAqB,CAAC;AAE1B,IAAM,aAAa,GAAG,UAAC,QAAkB;IACvC,gBAAM,CAAC,KAAK,CAAC,2CAAyC,QAAQ,MAAG,CAAC,CAAC;IACnE,WAAW,GAAG,QAAQ,CAAC;IACvB,MAAM,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAEzC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEK,IAAM,SAAS,GAAG,UACvB,QAAsC;IAAtC,yBAAA,EAAA,WAAqB,0BAAiB;IAEtC,IAAI,CAAC,GAAG,EAAE;QACR,gBAAM,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACpD,GAAG,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;KAC/B;SAAM;QACL,gBAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACvE,IAAI,QAAQ,KAAK,WAAW,EAAE;YAC5B,gBAAM,CAAC,IAAI,CACT,qEAAmE,WAAW,MAAG,CAClF,CAAC;YACF,gBAAM,CAAC,IAAI,CAAC,kCAAgC,QAAQ,sBAAmB,CAAC,CAAC;SAC1E;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAhBW,QAAA,SAAS,aAgBpB"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { FfiBinding } from './types';
|
|
3
|
-
export declare const createFfi: <T>(filename: string, description: T) => FfiBinding<T>;
|
|
4
2
|
export declare const libName: (library: string, version: string, processArch?: string, processPlatform?: NodeJS.Platform) => string;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.libName =
|
|
4
|
-
var ffi = require("ffi-napi");
|
|
5
|
-
var path = require("path");
|
|
6
|
-
var logger_1 = require("../../logger");
|
|
3
|
+
exports.libName = void 0;
|
|
7
4
|
var PLATFORM_LOOKUP = {
|
|
8
5
|
linux: 'linux',
|
|
9
6
|
darwin: 'osx',
|
|
@@ -21,13 +18,6 @@ var EXTENSION_LOOKUP = {
|
|
|
21
18
|
'linux-x86_64': 'so',
|
|
22
19
|
'windows-x86_64': 'dll',
|
|
23
20
|
};
|
|
24
|
-
var createFfi = function (filename, description) {
|
|
25
|
-
logger_1.default.trace("Native core located at '" + filename + "'");
|
|
26
|
-
var lib = ffi.Library(path.resolve(__dirname, '..', '..', '..', 'ffi', filename), description);
|
|
27
|
-
logger_1.default.trace("Native core linked successfully");
|
|
28
|
-
return lib;
|
|
29
|
-
};
|
|
30
|
-
exports.createFfi = createFfi;
|
|
31
21
|
var libName = function (library, version, processArch, processPlatform) {
|
|
32
22
|
if (processArch === void 0) { processArch = process.arch; }
|
|
33
23
|
if (processPlatform === void 0) { processPlatform = process.platform; }
|