@contract-case/case-connector 0.8.4 → 0.10.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 +51 -0
- package/README.md +4 -4
- package/dist/package.json +5 -5
- package/dist/src/connectors/case-boundary/internals/boundary/ITriggerFunction.d.ts +14 -1
- package/dist/src/connectors/case-boundary/internals/boundary/ITriggerFunction.d.ts.map +1 -1
- package/dist/src/connectors/case-boundary/internals/mappers/Result/handleResult.d.ts +1 -1
- package/dist/src/connectors/case-boundary/internals/mappers/Result/handleResult.d.ts.map +1 -1
- package/dist/src/connectors/case-boundary/internals/mappers/Result/handleResult.js +1 -7
- package/dist/src/connectors/case-boundary/internals/mappers/Result/handleResult.js.map +1 -1
- package/dist/src/connectors/case-boundary/internals/mappers/invokeableFunction.d.ts +1 -1
- package/dist/src/connectors/case-boundary/internals/mappers/invokeableFunction.d.ts.map +1 -1
- package/dist/src/connectors/case-boundary/internals/mappers/invokeableFunction.js +16 -1
- package/dist/src/connectors/case-boundary/internals/mappers/invokeableFunction.js.map +1 -1
- package/dist/src/connectors/case-boundary/internals/mappers/triggers.d.ts +3 -2
- package/dist/src/connectors/case-boundary/internals/mappers/triggers.d.ts.map +1 -1
- package/dist/src/connectors/case-boundary/internals/mappers/triggers.js +20 -3
- package/dist/src/connectors/case-boundary/internals/mappers/triggers.js.map +1 -1
- package/dist/src/connectors/grpc/contractDefinition.d.ts.map +1 -1
- package/dist/src/connectors/grpc/contractDefinition.js +36 -13
- package/dist/src/connectors/grpc/contractDefinition.js.map +1 -1
- package/dist/src/connectors/grpc/contractVerification.d.ts.map +1 -1
- package/dist/src/connectors/grpc/contractVerification.js +32 -12
- package/dist/src/connectors/grpc/contractVerification.js.map +1 -1
- package/dist/src/connectors/grpc/functionRegistry/functionRegistry.d.ts +3 -0
- package/dist/src/connectors/grpc/functionRegistry/functionRegistry.d.ts.map +1 -0
- package/dist/src/connectors/grpc/functionRegistry/functionRegistry.js +15 -0
- package/dist/src/connectors/grpc/functionRegistry/functionRegistry.js.map +1 -0
- package/dist/src/connectors/grpc/functionRegistry/index.d.ts +2 -0
- package/dist/src/connectors/grpc/functionRegistry/index.d.ts.map +1 -0
- package/dist/src/connectors/grpc/functionRegistry/index.js +2 -0
- package/dist/src/connectors/grpc/functionRegistry/index.js.map +1 -0
- package/dist/src/connectors/grpc/functionRegistry/types.d.ts +22 -0
- package/dist/src/connectors/grpc/functionRegistry/types.d.ts.map +1 -0
- package/dist/src/connectors/grpc/functionRegistry/types.js +2 -0
- package/dist/src/connectors/grpc/functionRegistry/types.js.map +1 -0
- package/dist/src/connectors/grpc/printers.d.ts.map +1 -1
- package/dist/src/connectors/grpc/printers.js +5 -5
- package/dist/src/connectors/grpc/printers.js.map +1 -1
- package/dist/src/connectors/grpc/promiseHandler/promiseHandler.d.ts +3 -1
- package/dist/src/connectors/grpc/promiseHandler/promiseHandler.d.ts.map +1 -1
- package/dist/src/connectors/grpc/promiseHandler/promiseHandler.js +4 -2
- package/dist/src/connectors/grpc/promiseHandler/promiseHandler.js.map +1 -1
- package/dist/src/connectors/grpc/requestMappers/config/config.d.ts +2 -1
- package/dist/src/connectors/grpc/requestMappers/config/config.d.ts.map +1 -1
- package/dist/src/connectors/grpc/requestMappers/config/config.js +29 -14
- package/dist/src/connectors/grpc/requestMappers/config/config.js.map +1 -1
- package/dist/src/connectors/grpc/requestMappers/config/stateHandlers.d.ts.map +1 -1
- package/dist/src/connectors/grpc/requestMappers/config/stateHandlers.js +1 -1
- package/dist/src/connectors/grpc/requestMappers/config/stateHandlers.js.map +1 -1
- package/dist/src/connectors/grpc/requestMappers/invokeableFunctions.d.ts.map +1 -1
- package/dist/src/connectors/grpc/requestMappers/invokeableFunctions.js +1 -1
- package/dist/src/connectors/grpc/requestMappers/invokeableFunctions.js.map +1 -1
- package/dist/src/connectors/grpc/requestMappers/result.d.ts.map +1 -1
- package/dist/src/connectors/grpc/requestMappers/result.js +3 -3
- package/dist/src/connectors/grpc/requestMappers/result.js.map +1 -1
- package/dist/src/connectors/grpc/responseMappers/json.d.ts +2 -0
- package/dist/src/connectors/grpc/responseMappers/json.d.ts.map +1 -1
- package/dist/src/connectors/grpc/responseMappers/json.js +2 -0
- package/dist/src/connectors/grpc/responseMappers/json.js.map +1 -1
- package/dist/src/connectors/grpc/responseMappers/result.d.ts.map +1 -1
- package/dist/src/connectors/grpc/responseMappers/result.js +5 -6
- package/dist/src/connectors/grpc/responseMappers/result.js.map +1 -1
- package/dist/src/connectors/grpc/sendContractResponse.d.ts +2 -1
- package/dist/src/connectors/grpc/sendContractResponse.d.ts.map +1 -1
- package/dist/src/connectors/grpc/sendContractResponse.js +4 -4
- package/dist/src/connectors/grpc/sendContractResponse.js.map +1 -1
- package/dist/src/domain/define.d.ts.map +1 -1
- package/dist/src/domain/define.js +2 -0
- package/dist/src/domain/define.js.map +1 -1
- package/dist/src/domain/maintainerLog.d.ts +2 -0
- package/dist/src/domain/maintainerLog.d.ts.map +1 -1
- package/dist/src/domain/maintainerLog.js +19 -6
- package/dist/src/domain/maintainerLog.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package/case-connector.js +2 -2
- package/package/case-connector.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.10.0](https://github.com/case-contract-testing/contract-case/compare/@contract-case/case-connector-v0.9.0...@contract-case/case-connector-v0.10.0) (2024-10-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* Replace the config object in triggers with a clearer SetupInfo type, allowing cross-language function calls as mocks. Note that the function calls now always return json strings, user-facing DSLs will need to parse the strings
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* Accurately include version numbers at runtime ([cca80e3](https://github.com/case-contract-testing/contract-case/commit/cca80e32f2dd055388e3cadd0239c883d556bb49))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Code Refactoring
|
|
16
|
+
|
|
17
|
+
* Replace the config object in triggers with a clearer SetupInfo type, allowing cross-language function calls as mocks. Note that the function calls now always return json strings, user-facing DSLs will need to parse the strings ([c9ddd93](https://github.com/case-contract-testing/contract-case/commit/c9ddd93782b5e11cd5925ea76e089e0d779fdc11))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Dependencies
|
|
21
|
+
|
|
22
|
+
* The following workspace dependencies were updated
|
|
23
|
+
* dependencies
|
|
24
|
+
* @contract-case/case-core bumped from 0.17.1 to 0.18.0
|
|
25
|
+
* @contract-case/case-connector-proto bumped from 0.8.0 to 0.9.0
|
|
26
|
+
* @contract-case/case-entities-internal bumped from 0.17.1 to 0.18.0
|
|
27
|
+
|
|
28
|
+
## [0.9.0](https://github.com/case-contract-testing/contract-case/compare/@contract-case/case-connector-v0.8.4...@contract-case/case-connector-v0.9.0) (2024-10-08)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### ⚠ BREAKING CHANGES
|
|
32
|
+
|
|
33
|
+
* The gRRPC SuccessWithAny type now contains a json string instead of a struct, for ease of mapping
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* Improve error message if the invokeable function's return value fails to parse ([3634d5d](https://github.com/case-contract-testing/contract-case/commit/3634d5d5fba4ccfc27b479911322fbe2847c0dba))
|
|
38
|
+
* Substantially improve maintainer logging ([30a882b](https://github.com/case-contract-testing/contract-case/commit/30a882b69e971b44285ef74e6da76ccef1a8a1ad))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Code Refactoring
|
|
42
|
+
|
|
43
|
+
* The gRRPC SuccessWithAny type now contains a json string instead of a struct, for ease of mapping ([adf66dd](https://github.com/case-contract-testing/contract-case/commit/adf66dd6e42eb85b5c5ece2d06405cb677e684e8))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Dependencies
|
|
47
|
+
|
|
48
|
+
* The following workspace dependencies were updated
|
|
49
|
+
* dependencies
|
|
50
|
+
* @contract-case/case-core bumped from 0.17.0 to 0.17.1
|
|
51
|
+
* @contract-case/case-connector-proto bumped from 0.7.6 to 0.8.0
|
|
52
|
+
* @contract-case/case-entities-internal bumped from 0.17.0 to 0.17.1
|
|
53
|
+
|
|
3
54
|
## [0.8.4](https://github.com/case-contract-testing/contract-case/compare/@contract-case/case-connector-v0.8.3...@contract-case/case-connector-v0.8.4) (2024-10-02)
|
|
4
55
|
|
|
5
56
|
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Case-Connector
|
|
2
2
|
|
|
3
|
-
[](https://github.com/case-contract-testing/case/actions/workflows/build-and-test.yml)
|
|
4
|
-
[](https://github.com/case-contract-testing/contract-case/actions/workflows/build-and-test.yml)
|
|
4
|
+
[](https://snyk.io/test/github/case-contract-testing/contract-case?targetFile=packages/case-connector/package.json)
|
|
5
5
|
|
|
6
|
-
This is the server connector (
|
|
6
|
+
This is the server connector (formerly case-boundary) to allow ContractCase to be run as a server.
|
|
7
7
|
|
|
8
8
|
If you're wanting to learn about ContractCase, [start here instead](https://case.contract-testing.io/docs/intro)
|
|
9
9
|
|
|
@@ -12,4 +12,4 @@ Don't depend on this directly unless you are writing a custom wrapper for Contra
|
|
|
12
12
|
This package exists to work around [this JSii](https://github.com/aws/jsii/issues/4133)
|
|
13
13
|
bug, by exposing the communication layer as a gRPC service.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
For details of the protocol schema, see the case-connector-proto package.
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contract-case/case-connector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Connector to allow ContractCase to run as a server. Use only if you're creating a custom wrapper for a new language",
|
|
6
6
|
"author": "Timothy Jones <timothy.l.jones@gmail.com> (https://github.com/TimothyJones)",
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"rimraf": "^6.0.1",
|
|
45
45
|
"source-map-loader": "^5.0.0",
|
|
46
46
|
"terser-webpack-plugin": "^5.3.10",
|
|
47
|
-
"ts-jest": "^29.
|
|
47
|
+
"ts-jest": "^29.2.5",
|
|
48
48
|
"ts-node": "^10.9.2",
|
|
49
49
|
"webpack": "^5.94.0",
|
|
50
50
|
"webpack-cli": "^5.1.4"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@contract-case/case-core": "0.
|
|
54
|
-
"@contract-case/case-connector-proto": "0.
|
|
55
|
-
"@contract-case/case-entities-internal": "0.
|
|
53
|
+
"@contract-case/case-core": "0.18.0",
|
|
54
|
+
"@contract-case/case-connector-proto": "0.9.0",
|
|
55
|
+
"@contract-case/case-entities-internal": "0.18.0",
|
|
56
56
|
"@grpc/grpc-js": "^1.11.1",
|
|
57
57
|
"@grpc/proto-loader": "^0.7.10",
|
|
58
58
|
"get-port": "^7.1.0",
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { BoundaryResult } from './Result/index.js';
|
|
2
|
+
export type BoundaryCoreFunction = (...args: string[]) => Promise<BoundaryResult>;
|
|
3
|
+
export type BoundarySetupInfo = {
|
|
4
|
+
stateVariables: Record<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
* Functions defined or registered in the core,
|
|
7
|
+
* that can be called by host wrappers.
|
|
8
|
+
* These functions are never-fail - they always return a successful promise.
|
|
9
|
+
*/
|
|
10
|
+
functions: Record<string, BoundaryCoreFunction>;
|
|
11
|
+
mock: Record<string, string>;
|
|
12
|
+
};
|
|
2
13
|
/**
|
|
3
14
|
* Interface called by ContractCase to invoke user's test code.
|
|
4
15
|
*
|
|
@@ -8,12 +19,14 @@ export interface ITriggerFunction {
|
|
|
8
19
|
/**
|
|
9
20
|
* Trigger the user's test code and test the response from it.
|
|
10
21
|
*
|
|
22
|
+
* @param setup - The information about the setup for this test
|
|
23
|
+
*
|
|
11
24
|
* @returns BoundarySuccess when successful; BoundaryFailure with
|
|
12
25
|
* kind=BoundaryFailureKindConstants.CASE_TRIGGER_ERROR if the trigger fails;
|
|
13
26
|
* BoundaryFailure with
|
|
14
27
|
* kind=BoundaryFailureKindConstants.CASE_VERIFY_RETURN_ERROR if the
|
|
15
28
|
* verification function fails.
|
|
16
29
|
*/
|
|
17
|
-
trigger(
|
|
30
|
+
trigger(setup: BoundarySetupInfo): Promise<BoundaryResult>;
|
|
18
31
|
}
|
|
19
32
|
//# sourceMappingURL=ITriggerFunction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ITriggerFunction.d.ts","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/boundary/ITriggerFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"ITriggerFunction.d.ts","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/boundary/ITriggerFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,MAAM,oBAAoB,GAAG,CACjC,GAAG,IAAI,EAAE,MAAM,EAAE,KACd,OAAO,CAAC,cAAc,CAAC,CAAC;AAE7B,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAChD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BoundaryResult } from '../../boundary/index.js';
|
|
2
2
|
import { ErrorType } from './types.js';
|
|
3
3
|
export declare const handleVoidResult: (result: BoundaryResult, defaultError: ErrorType) => void;
|
|
4
|
-
export declare const handleSuccessAnyResult: (result: BoundaryResult, defaultError: ErrorType) =>
|
|
4
|
+
export declare const handleSuccessAnyResult: (result: BoundaryResult, defaultError: ErrorType) => string;
|
|
5
5
|
//# sourceMappingURL=handleResult.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleResult.d.ts","sourceRoot":"","sources":["../../../../../../../src/connectors/case-boundary/internals/mappers/Result/handleResult.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,eAAO,MAAM,gBAAgB,WACnB,cAAc,gBACR,SAAS,KACtB,IAUF,CAAC;AAEF,eAAO,MAAM,sBAAsB,WACzB,cAAc,gBACR,SAAS,KACtB,
|
|
1
|
+
{"version":3,"file":"handleResult.d.ts","sourceRoot":"","sources":["../../../../../../../src/connectors/case-boundary/internals/mappers/Result/handleResult.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,eAAO,MAAM,gBAAgB,WACnB,cAAc,gBACR,SAAS,KACtB,IAUF,CAAC;AAEF,eAAO,MAAM,sBAAsB,WACzB,cAAc,gBACR,SAAS,KACtB,MAWF,CAAC"}
|
|
@@ -13,13 +13,7 @@ export const handleVoidResult = (result, defaultError) => {
|
|
|
13
13
|
};
|
|
14
14
|
export const handleSuccessAnyResult = (result, defaultError) => {
|
|
15
15
|
if (result.resultType === RESULT_SUCCESS_HAS_ANY_PAYLOAD) {
|
|
16
|
-
|
|
17
|
-
return JSON.parse(result.payload);
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
maintainerLog('Error parsing successAny: ', e, 'result was', result);
|
|
21
|
-
throw new CaseCoreError('Was unable to parse the payload returned by a success any result. This is probably a bug in the language-specific wrapper.');
|
|
22
|
-
}
|
|
16
|
+
return result.payload;
|
|
23
17
|
}
|
|
24
18
|
if (result.resultType === RESULT_FAILURE) {
|
|
25
19
|
throw failureToJsError(result, defaultError);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleResult.js","sourceRoot":"","sources":["../../../../../../../src/connectors/case-boundary/internals/mappers/Result/handleResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACL,cAAc,EACd,cAAc,EAEd,8BAA8B,GAE/B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,MAAsB,EACtB,YAAuB,EACjB,EAAE;IACR,IAAI,MAAM,CAAC,UAAU,KAAK,cAAc,EAAE,CAAC;QACzC,OAAO;IACT,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,cAAc,EAAE,CAAC;QACzC,MAAM,gBAAgB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,IAAI,aAAa,CACrB,0CAA0C,MAAM,CAAC,UAAU,EAAE,CAC9D,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,MAAsB,EACtB,YAAuB,
|
|
1
|
+
{"version":3,"file":"handleResult.js","sourceRoot":"","sources":["../../../../../../../src/connectors/case-boundary/internals/mappers/Result/handleResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACL,cAAc,EACd,cAAc,EAEd,8BAA8B,GAE/B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,MAAsB,EACtB,YAAuB,EACjB,EAAE;IACR,IAAI,MAAM,CAAC,UAAU,KAAK,cAAc,EAAE,CAAC;QACzC,OAAO;IACT,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,cAAc,EAAE,CAAC;QACzC,MAAM,gBAAgB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,IAAI,aAAa,CACrB,0CAA0C,MAAM,CAAC,UAAU,EAAE,CAC9D,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,MAAsB,EACtB,YAAuB,EACf,EAAE;IACV,IAAI,MAAM,CAAC,UAAU,KAAK,8BAA8B,EAAE,CAAC;QACzD,OAAQ,MAAiC,CAAC,OAAO,CAAC;IACpD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,cAAc,EAAE,CAAC;QACzC,MAAM,gBAAgB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC/C,CAAC;IACD,aAAa,CAAC,iDAAiD,EAAE,MAAM,CAAC,CAAC;IACzE,MAAM,IAAI,aAAa,CACrB,0CAA0C,MAAM,CAAC,UAAU,EAAE,CAC9D,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BoundaryInvokableFunction } from '../types.js';
|
|
2
|
-
type Fn = (...args: unknown[]) => Promise<
|
|
2
|
+
type Fn = (...args: unknown[]) => Promise<string>;
|
|
3
3
|
export declare const mapInvokableFunction: (invokeableFn: BoundaryInvokableFunction) => Fn;
|
|
4
4
|
export declare const mapInvokableFunctions: (invokeableFns: Record<string, BoundaryInvokableFunction>) => Record<string, Fn>;
|
|
5
5
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invokeableFunction.d.ts","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/mappers/invokeableFunction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invokeableFunction.d.ts","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/mappers/invokeableFunction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAIxD,KAAK,EAAE,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAElD,eAAO,MAAM,oBAAoB,iBAChB,yBAAyB,KAAG,EAyBrC,CAAC;AAET,eAAO,MAAM,qBAAqB,kBACjB,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,KACvD,MAAM,CAAC,MAAM,EAAE,EAAE,CAOjB,CAAC"}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
import { CaseCoreError } from '@contract-case/case-core';
|
|
1
2
|
import { handleSuccessAnyResult } from './Result/index.js';
|
|
3
|
+
import { maintainerLog } from '../../../../domain/maintainerLog.js';
|
|
2
4
|
export const mapInvokableFunction = (invokeableFn) => (...args) => Promise.resolve()
|
|
3
5
|
.then(() => invokeableFn(...args.map((arg) => JSON.stringify(arg))))
|
|
4
|
-
.then((result) => handleSuccessAnyResult(result, 'CaseConfigurationError'))
|
|
6
|
+
.then((result) => handleSuccessAnyResult(result, 'CaseConfigurationError'))
|
|
7
|
+
.then((resultString) => {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(resultString);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
maintainerLog('Error parsing response from invokeableFunction: ', e, 'result was', resultString);
|
|
13
|
+
throw new CaseCoreError(`Unable to parse the payload returned by the invokeableFunction.
|
|
14
|
+
|
|
15
|
+
This is probably a bug in your invokeable function, or the language-specific wrapper (${e?.message}).
|
|
16
|
+
|
|
17
|
+
The string that failed to parse was: ${resultString}`);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
5
20
|
export const mapInvokableFunctions = (invokeableFns) => Object.entries(invokeableFns).reduce((acc, [key, fn]) => ({
|
|
6
21
|
...acc,
|
|
7
22
|
[key]: mapInvokableFunction(fn),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invokeableFunction.js","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/mappers/invokeableFunction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invokeableFunction.js","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/mappers/invokeableFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAIpE,MAAM,CAAC,MAAM,oBAAoB,GAC/B,CAAC,YAAuC,EAAM,EAAE,CAChD,CAAC,GAAG,IAAe,EAAmB,EAAE,CACtC,OAAO,CAAC,OAAO,EAAE;KACd,IAAI,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KACnE,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CACf,sBAAsB,CAAC,MAAM,EAAE,wBAAwB,CAAC,CACzD;KACA,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE;IACrB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,aAAa,CACX,kDAAkD,EAClD,CAAC,EACD,YAAY,EACZ,YAAY,CACb,CAAC;QACF,MAAM,IAAI,aAAa,CACrB;;oGAEyF,CAAuB,EAAE,OAAO;;mDAElF,YAAY,EAAE,CACtD,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAET,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,aAAwD,EACpC,EAAE,CACtB,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,MAAM,CAClC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACnB,GAAG,GAAG;IACN,CAAC,GAAG,CAAC,EAAE,oBAAoB,CAAC,EAAE,CAAC;CAChC,CAAC,EACF,EAAwB,CACzB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { BaseSetupInfo } from '@contract-case/case-core';
|
|
1
2
|
import { ITriggerFunction } from '../boundary/index.js';
|
|
2
|
-
export declare const mapTrigger: (trigger: ITriggerFunction) => (config:
|
|
3
|
-
export declare const mapTriggers: (triggers: Record<string, ITriggerFunction>) => Record<string, (config:
|
|
3
|
+
export declare const mapTrigger: (trigger: ITriggerFunction) => (config: BaseSetupInfo) => Promise<void>;
|
|
4
|
+
export declare const mapTriggers: (triggers: Record<string, ITriggerFunction>) => Record<string, (config: BaseSetupInfo) => Promise<void>>;
|
|
4
5
|
//# sourceMappingURL=triggers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/mappers/triggers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/mappers/triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAEL,gBAAgB,EAKjB,MAAM,sBAAsB,CAAC;AA2B9B,eAAO,MAAM,UAAU,YACX,gBAAgB,cAEjB,aAAa,KAAG,OAAO,CAAC,IAAI,CAajC,CAAC;AAEP,eAAO,MAAM,WAAW,aACZ,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAEzC,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAMrD,CAAC"}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import { CaseCoreError } from '@contract-case/case-core';
|
|
2
|
-
import { RESULT_SUCCESS, RESULT_FAILURE, RESULT_SUCCESS_HAS_MAP_PAYLOAD, } from '../boundary/index.js';
|
|
3
|
-
import { failureToJsError } from './Result/index.js';
|
|
2
|
+
import { RESULT_SUCCESS, RESULT_FAILURE, RESULT_SUCCESS_HAS_MAP_PAYLOAD, BoundarySuccessWithAny, } from '../boundary/index.js';
|
|
3
|
+
import { failureToJsError, jsErrorToFailure } from './Result/index.js';
|
|
4
|
+
const mapSetupInfo = ({ stateVariables, functions, mock, }) => ({
|
|
5
|
+
stateVariables,
|
|
6
|
+
mock,
|
|
7
|
+
functions: Object.entries(functions)
|
|
8
|
+
.map(([name, fn]) => [
|
|
9
|
+
name,
|
|
10
|
+
(...args) => {
|
|
11
|
+
try {
|
|
12
|
+
return new BoundarySuccessWithAny(fn(...args));
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
return jsErrorToFailure(e);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
])
|
|
19
|
+
.reduce((acc, [name, fn]) => ({ ...acc, [name]: fn }), {}),
|
|
20
|
+
});
|
|
4
21
|
export const mapTrigger = (trigger) =>
|
|
5
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
(config) => trigger.trigger(config).then((result) => {
|
|
23
|
+
(config) => trigger.trigger(mapSetupInfo(config)).then((result) => {
|
|
7
24
|
switch (result.resultType) {
|
|
8
25
|
case RESULT_SUCCESS:
|
|
9
26
|
case RESULT_SUCCESS_HAS_MAP_PAYLOAD:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggers.js","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/mappers/triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"triggers.js","sourceRoot":"","sources":["../../../../../../src/connectors/case-boundary/internals/mappers/triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,0BAA0B,CAAC;AACxE,OAAO,EACL,cAAc,EAEd,cAAc,EACd,8BAA8B,EAE9B,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,YAAY,GAAG,CAAC,EACpB,cAAc,EACd,SAAS,EACT,IAAI,GACU,EAAqB,EAAE,CAAC,CAAC;IACvC,cAAc;IACd,IAAI;IACJ,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;SACjC,GAAG,CACF,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CACb;QACE,IAAI;QACJ,CAAC,GAAG,IAAc,EAAE,EAAE;YACpB,IAAI,CAAC;gBACH,OAAO,IAAI,sBAAsB,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YACjD,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;KACO,CACb;SACA,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;CAC7D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GACrB,CAAC,OAAyB,EAAE,EAAE;AAC9B,8DAA8D;AAC9D,CAAC,MAAqB,EAAiB,EAAE,CACvC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;IACpD,QAAQ,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1B,KAAK,cAAc,CAAC;QACpB,KAAK,8BAA8B;YACjC,OAAO;QACT,KAAK,cAAc;YACjB,MAAM,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACjC;YACE,MAAM,IAAI,aAAa,CACrB,wBAAwB,MAAM,CAAC,UAAU,0BAA0B,CACpE,CAAC;IACN,CAAC;AACH,CAAC,CAAC,CAAC;AAEP,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,QAA0C,EAEgB,EAAE,CAC5D,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;KACrB,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KAC1D,MAAM,CACL,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC,EACpC,EAAyC,CAC1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractDefinition.d.ts","sourceRoot":"","sources":["../../../../src/connectors/grpc/contractDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EACL,iBAAiB,IAAI,qBAAqB,EAC1C,gBAAgB,IAAI,oBAAoB,EACzC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"contractDefinition.d.ts","sourceRoot":"","sources":["../../../../src/connectors/grpc/contractDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EACL,iBAAiB,IAAI,qBAAqB,EAC1C,gBAAgB,IAAI,oBAAoB,EACzC,MAAM,qCAAqC,CAAC;AAyC7C,eAAO,MAAM,kBAAkB,SACvB,kBAAkB,CAAC,qBAAqB,EAAE,oBAAoB,CAAC,KACpE,IA2TF,CAAC"}
|
|
@@ -6,10 +6,11 @@ import { beginDefinition, endRecord, registerFunction, runExample, runRejectingE
|
|
|
6
6
|
import { makeInvokeFunction, mapConfig, mapJson, mapResult, } from './requestMappers/index.js';
|
|
7
7
|
import { resolveById } from './promiseHandler/promiseHandler.js';
|
|
8
8
|
import { makeSendContractResponse } from './sendContractResponse.js';
|
|
9
|
-
import { maintainerLog } from '../../domain/maintainerLog.js';
|
|
9
|
+
import { connectorDebugLog, maintainerLog, } from '../../domain/maintainerLog.js';
|
|
10
10
|
import { makeLogPrinter, makeResultPrinter } from './printers.js';
|
|
11
11
|
import { makeResultResponse } from './responseMappers/index.js';
|
|
12
12
|
import { loadPlugin } from '../../domain/loadPlugin.js';
|
|
13
|
+
import { makeFunctionRegistry } from './functionRegistry/index.js';
|
|
13
14
|
const getId = (request) => {
|
|
14
15
|
const id = request.getId();
|
|
15
16
|
if (id === undefined) {
|
|
@@ -22,9 +23,10 @@ export const contractDefinition = (call) => {
|
|
|
22
23
|
const sendUnexpectedError = (request, e, location) => {
|
|
23
24
|
// This should never happen, so we log a lot
|
|
24
25
|
maintainerLog(`!!!Unexpected error!!! At ${location}`, e, '!!!During request', request);
|
|
25
|
-
sendContractResponse(request.getId()?.getValue() || '', makeResultResponse(new BoundaryFailure(BoundaryFailureKindConstants.CASE_CORE_ERROR, `[${e.name}] ${e.message}`, e.stack ?? 'ContractCase Connector')));
|
|
26
|
+
sendContractResponse('maintainerDebug', request.getId()?.getValue() || '', makeResultResponse(new BoundaryFailure(BoundaryFailureKindConstants.CASE_CORE_ERROR, `[${e.name}] ${e.message}`, e.stack ?? 'ContractCase Connector')));
|
|
26
27
|
};
|
|
27
28
|
let definitionId;
|
|
29
|
+
const functionRegistry = makeFunctionRegistry();
|
|
28
30
|
call.on('data', (request) => {
|
|
29
31
|
maintainerLog('[RECEIVED]', JSON.stringify(request.toObject(), null, 2));
|
|
30
32
|
const type = request.getKindCase();
|
|
@@ -38,15 +40,15 @@ export const contractDefinition = (call) => {
|
|
|
38
40
|
throw new ConnectorError('Begin definition was called with something that returned an undefined getBeginDefinition');
|
|
39
41
|
}
|
|
40
42
|
try {
|
|
41
|
-
definitionId = beginDefinition(mapConfig(beginDefinitionRequest.getConfig(), sendContractResponse), makeLogPrinter(sendContractResponse), makeResultPrinter(sendContractResponse), beginDefinitionRequest
|
|
43
|
+
definitionId = beginDefinition(mapConfig(beginDefinitionRequest.getConfig(), sendContractResponse, functionRegistry), makeLogPrinter(sendContractResponse), makeResultPrinter(sendContractResponse), beginDefinitionRequest
|
|
42
44
|
.getCallerVersionsList()
|
|
43
45
|
.map((s) => s != null ? s.getValue() : 'missing-version-value'));
|
|
44
46
|
}
|
|
45
47
|
catch (e) {
|
|
46
|
-
sendContractResponse(getId(request), makeResultResponse(new BoundaryFailure(BoundaryFailureKindConstants.CASE_CORE_ERROR, `Unable to create definer: ${e.message}`, 'ContractCase Connector')));
|
|
48
|
+
sendContractResponse('maintainerDebug', getId(request), makeResultResponse(new BoundaryFailure(BoundaryFailureKindConstants.CASE_CORE_ERROR, `Unable to create definer: ${e.message}`, 'ContractCase Connector')));
|
|
47
49
|
return;
|
|
48
50
|
}
|
|
49
|
-
sendContractResponse(getId(request), makeResultResponse(new BoundarySuccess()));
|
|
51
|
+
sendContractResponse('maintainerDebug', getId(request), makeResultResponse(new BoundarySuccess()));
|
|
50
52
|
}
|
|
51
53
|
break;
|
|
52
54
|
case WireDefinitionRequest.KindCase.END_DEFINITION: {
|
|
@@ -57,7 +59,7 @@ export const contractDefinition = (call) => {
|
|
|
57
59
|
if (definitionId === undefined) {
|
|
58
60
|
throw new ConnectorError('end definition was called before begin definition');
|
|
59
61
|
}
|
|
60
|
-
endRecord(definitionId).then((result) => sendContractResponse(getId(request), makeResultResponse(result)));
|
|
62
|
+
endRecord(definitionId).then((result) => sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result)));
|
|
61
63
|
break;
|
|
62
64
|
}
|
|
63
65
|
case WireDefinitionRequest.KindCase.RUN_EXAMPLE: {
|
|
@@ -68,7 +70,7 @@ export const contractDefinition = (call) => {
|
|
|
68
70
|
if (definitionId === undefined) {
|
|
69
71
|
throw new ConnectorError('runExample was called before begin definition');
|
|
70
72
|
}
|
|
71
|
-
runExample(definitionId, mapJson(runExampleRequest.getExampleDefinition()), mapConfig(runExampleRequest.getConfig(), sendContractResponse)).then((result) => sendContractResponse(getId(request), makeResultResponse(result)));
|
|
73
|
+
runExample(definitionId, mapJson(runExampleRequest.getExampleDefinition()), mapConfig(runExampleRequest.getConfig(), sendContractResponse, functionRegistry)).then((result) => sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result)));
|
|
72
74
|
break;
|
|
73
75
|
}
|
|
74
76
|
case WireDefinitionRequest.KindCase.RUN_REJECTING_EXAMPLE: {
|
|
@@ -79,7 +81,7 @@ export const contractDefinition = (call) => {
|
|
|
79
81
|
if (definitionId === undefined) {
|
|
80
82
|
throw new ConnectorError('runExample was called before begin definition');
|
|
81
83
|
}
|
|
82
|
-
runRejectingExample(definitionId, mapJson(runRejectingExampleRequest.getExampleDefinition()), mapConfig(runRejectingExampleRequest.getConfig(), sendContractResponse)).then((result) => sendContractResponse(getId(request), makeResultResponse(result)));
|
|
84
|
+
runRejectingExample(definitionId, mapJson(runRejectingExampleRequest.getExampleDefinition()), mapConfig(runRejectingExampleRequest.getConfig(), sendContractResponse, functionRegistry)).then((result) => sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result)));
|
|
83
85
|
break;
|
|
84
86
|
}
|
|
85
87
|
case WireDefinitionRequest.KindCase.STRIP_MATCHERS: {
|
|
@@ -90,17 +92,20 @@ export const contractDefinition = (call) => {
|
|
|
90
92
|
if (definitionId === undefined) {
|
|
91
93
|
throw new ConnectorError('stripMatchers was called before begin definition');
|
|
92
94
|
}
|
|
93
|
-
sendContractResponse(getId(request), makeResultResponse(stripMatchers(definitionId, mapJson(stripMatchersRequest.getMatcherOrData()))));
|
|
95
|
+
sendContractResponse('maintainerDebug', getId(request), makeResultResponse(stripMatchers(definitionId, mapJson(stripMatchersRequest.getMatcherOrData()))));
|
|
94
96
|
break;
|
|
95
97
|
}
|
|
96
98
|
case WireDefinitionRequest.KindCase.RESULT_RESPONSE:
|
|
97
|
-
{
|
|
99
|
+
try {
|
|
98
100
|
const resultPrinterResponse = request.getResultResponse();
|
|
99
101
|
if (resultPrinterResponse == null) {
|
|
100
102
|
throw new ConnectorError('Result response was called with an undefined request');
|
|
101
103
|
}
|
|
102
104
|
resolveById(getId(request), mapResult(resultPrinterResponse.getResult()));
|
|
103
105
|
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
connectorDebugLog('maintainerDebug', 'Exploded with:', e);
|
|
108
|
+
}
|
|
104
109
|
break;
|
|
105
110
|
case WireDefinitionRequest.KindCase.LOAD_PLUGIN:
|
|
106
111
|
{
|
|
@@ -108,14 +113,14 @@ export const contractDefinition = (call) => {
|
|
|
108
113
|
if (loadPluginRequest == null) {
|
|
109
114
|
throw new ConnectorError('loadPlugin called with something that returned an undefined request');
|
|
110
115
|
}
|
|
111
|
-
loadPlugin(mapConfig(loadPluginRequest.getConfig(), sendContractResponse), makeLogPrinter(sendContractResponse), makeResultPrinter(sendContractResponse), loadPluginRequest
|
|
116
|
+
loadPlugin(mapConfig(loadPluginRequest.getConfig(), sendContractResponse, functionRegistry), makeLogPrinter(sendContractResponse), makeResultPrinter(sendContractResponse), loadPluginRequest
|
|
112
117
|
.getCallerVersionsList()
|
|
113
118
|
.map((s) => (s != null ? s.getValue() : 'missing-version-value')), loadPluginRequest.getModuleNamesList().map((s, index) => {
|
|
114
119
|
if (s == null) {
|
|
115
120
|
throw new ConnectorError(`loadPlugin called with a null module name at position '${index}'`);
|
|
116
121
|
}
|
|
117
122
|
return s.getValue();
|
|
118
|
-
})).then((result) => sendContractResponse(getId(request), makeResultResponse(result)));
|
|
123
|
+
})).then((result) => sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result)));
|
|
119
124
|
}
|
|
120
125
|
break;
|
|
121
126
|
case WireDefinitionRequest.KindCase.REGISTER_FUNCTION:
|
|
@@ -132,12 +137,30 @@ export const contractDefinition = (call) => {
|
|
|
132
137
|
throw new ConnectorError('Handle was missing a value');
|
|
133
138
|
}
|
|
134
139
|
registerFunction(definitionId, handle, makeInvokeFunction(handle, sendContractResponse))
|
|
135
|
-
.then((result) => sendContractResponse(getId(request), makeResultResponse(result)))
|
|
140
|
+
.then((result) => sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result)))
|
|
136
141
|
.catch((e) => {
|
|
137
142
|
sendUnexpectedError(request, e, 'load plugin');
|
|
138
143
|
});
|
|
139
144
|
}
|
|
140
145
|
break;
|
|
146
|
+
case WireDefinitionRequest.KindCase.INVOKE_FUNCTION:
|
|
147
|
+
{
|
|
148
|
+
const invokeFunctionRequest = request.getInvokeFunction();
|
|
149
|
+
if (invokeFunctionRequest == null) {
|
|
150
|
+
throw new ConnectorError('invokeFunction called with something that returned an undefined request');
|
|
151
|
+
}
|
|
152
|
+
const handle = invokeFunctionRequest.getHandle()?.getValue();
|
|
153
|
+
if (handle == null) {
|
|
154
|
+
throw new ConnectorError('Handle was missing a value');
|
|
155
|
+
}
|
|
156
|
+
const args = invokeFunctionRequest
|
|
157
|
+
.getArgumentsList()
|
|
158
|
+
.map((s) => s.getValue());
|
|
159
|
+
Promise.resolve(functionRegistry.getCoreFunction(handle)(...args)).then((result) => {
|
|
160
|
+
sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result));
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
141
164
|
default:
|
|
142
165
|
throw new UnreachableError(type);
|
|
143
166
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractDefinition.js","sourceRoot":"","sources":["../../../../src/connectors/grpc/contractDefinition.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,IAAI,qBAAqB,GAE3C,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,eAAe,GAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EACL,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,
|
|
1
|
+
{"version":3,"file":"contractDefinition.js","sourceRoot":"","sources":["../../../../src/connectors/grpc/contractDefinition.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,IAAI,qBAAqB,GAE3C,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,eAAe,GAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EACL,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,SAAS,GACV,MAAM,2BAA2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AAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractVerification.d.ts","sourceRoot":"","sources":["../../../../src/connectors/grpc/contractVerification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EACL,mBAAmB,IAAI,uBAAuB,EAC9C,gBAAgB,IAAI,oBAAoB,EAEzC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"contractVerification.d.ts","sourceRoot":"","sources":["../../../../src/connectors/grpc/contractVerification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EACL,mBAAmB,IAAI,uBAAuB,EAC9C,gBAAgB,IAAI,oBAAoB,EAEzC,MAAM,qCAAqC,CAAC;AA2C7C,eAAO,MAAM,oBAAoB,SACzB,kBAAkB,CAAC,uBAAuB,EAAE,oBAAoB,CAAC,KACtE,IAkVF,CAAC"}
|
|
@@ -11,6 +11,7 @@ import { makeSendContractResponse } from './sendContractResponse.js';
|
|
|
11
11
|
import { makeLogPrinter, makeResultPrinter } from './printers.js';
|
|
12
12
|
import { makeResultResponse } from './responseMappers/index.js';
|
|
13
13
|
import { loadPlugin } from '../../domain/loadPlugin.js';
|
|
14
|
+
import { makeFunctionRegistry } from './functionRegistry/index.js';
|
|
14
15
|
const getId = (request) => {
|
|
15
16
|
const id = request.getId();
|
|
16
17
|
if (id === undefined) {
|
|
@@ -23,9 +24,10 @@ export const contractVerification = (call) => {
|
|
|
23
24
|
const sendUnexpectedError = (request, e, location) => {
|
|
24
25
|
// This should never happen, so we log a lot
|
|
25
26
|
maintainerLog(`!!!Unexpected error!!! At ${location}`, e, '!!!During request', request);
|
|
26
|
-
sendContractResponse(request.getId()?.getValue() || '', makeResultResponse(new BoundaryFailure(BoundaryFailureKindConstants.CASE_CORE_ERROR, `[${e.name}] ${e.message}`, e.stack ?? 'ContractCase Connector')));
|
|
27
|
+
sendContractResponse('maintainerDebug', request.getId()?.getValue() || '', makeResultResponse(new BoundaryFailure(BoundaryFailureKindConstants.CASE_CORE_ERROR, `[${e.name}] ${e.message}`, e.stack ?? 'ContractCase Connector')));
|
|
27
28
|
};
|
|
28
29
|
let verificationId;
|
|
30
|
+
const functionRegistry = makeFunctionRegistry();
|
|
29
31
|
call.on('data', (request) => {
|
|
30
32
|
maintainerLog('[RECEIVED]', JSON.stringify(request.toObject(), null, 2));
|
|
31
33
|
const type = request.getKindCase();
|
|
@@ -40,19 +42,19 @@ export const contractVerification = (call) => {
|
|
|
40
42
|
throw new ConnectorError('Begin definition was called with something that returned an undefined getBeginDefinition');
|
|
41
43
|
}
|
|
42
44
|
try {
|
|
43
|
-
verificationId = beginVerification(mapConfig(beginVerificationRequest.getConfig(), sendContractResponse), {
|
|
45
|
+
verificationId = beginVerification(mapConfig(beginVerificationRequest.getConfig(), sendContractResponse, functionRegistry), {
|
|
44
46
|
runTest: (testName, invoker) => {
|
|
45
47
|
const invokerId = makeResolvableId(async () => { }, (result) => {
|
|
46
48
|
// TODO: Replace this with a nice 'isBoundarySuccessWithAny' function
|
|
47
49
|
if (result.resultType === 'SuccessAny') {
|
|
48
50
|
const id = `${result.payload}`;
|
|
49
51
|
invoker.verify().then((verificationResult) => {
|
|
50
|
-
sendContractResponse(id, makeResultResponse(verificationResult));
|
|
52
|
+
sendContractResponse('maintainerDebug', id, makeResultResponse(verificationResult));
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
return result;
|
|
54
56
|
});
|
|
55
|
-
return waitForResolution(makeResolvableId((id) => sendContractResponse(id, new WireContractResponse().setStartTestEvent(new WireStartTestEvent()
|
|
57
|
+
return waitForResolution(makeResolvableId((id) => sendContractResponse('maintainerDebug', id, new WireContractResponse().setStartTestEvent(new WireStartTestEvent()
|
|
56
58
|
.setTestName(new StringValue().setValue(testName))
|
|
57
59
|
.setInvokerId(new StringValue().setValue(invokerId))))));
|
|
58
60
|
},
|
|
@@ -61,10 +63,10 @@ export const contractVerification = (call) => {
|
|
|
61
63
|
.map((s) => s != null ? s.getValue() : 'missing-version-value'));
|
|
62
64
|
}
|
|
63
65
|
catch (e) {
|
|
64
|
-
sendContractResponse(getId(request), makeResultResponse(new BoundaryFailure(BoundaryFailureKindConstants.CASE_CORE_ERROR, `Unable to create verifier: ${e.message}`, 'ContractCase Connector')));
|
|
66
|
+
sendContractResponse('maintainerDebug', getId(request), makeResultResponse(new BoundaryFailure(BoundaryFailureKindConstants.CASE_CORE_ERROR, `Unable to create verifier: ${e.message}`, 'ContractCase Connector')));
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
67
|
-
sendContractResponse(getId(request), makeResultResponse(new BoundarySuccess()));
|
|
69
|
+
sendContractResponse('maintainerDebug', getId(request), makeResultResponse(new BoundarySuccess()));
|
|
68
70
|
}
|
|
69
71
|
break;
|
|
70
72
|
case WireVerificationRequest.KindCase.AVAILABLE_CONTRACT_DEFINITIONS: {
|
|
@@ -72,7 +74,7 @@ export const contractVerification = (call) => {
|
|
|
72
74
|
throw new ConnectorError('availableContractDefinitions was called before beginVerification');
|
|
73
75
|
}
|
|
74
76
|
availableContractDescriptions(verificationId)
|
|
75
|
-
.then((result) => sendContractResponse(getId(request), makeResultResponse(result)))
|
|
77
|
+
.then((result) => sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result)))
|
|
76
78
|
.catch((e) => {
|
|
77
79
|
sendUnexpectedError(request, e, 'Available contract descriptions');
|
|
78
80
|
});
|
|
@@ -86,8 +88,8 @@ export const contractVerification = (call) => {
|
|
|
86
88
|
if (verificationId === undefined) {
|
|
87
89
|
throw new ConnectorError('runVerification was called before beginVerification');
|
|
88
90
|
}
|
|
89
|
-
runVerification(verificationId, mapConfig(runVerificationRequest.getConfig(), sendContractResponse))
|
|
90
|
-
.then((result) => sendContractResponse(getId(request), makeResultResponse(result)))
|
|
91
|
+
runVerification(verificationId, mapConfig(runVerificationRequest.getConfig(), sendContractResponse, functionRegistry))
|
|
92
|
+
.then((result) => sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result)))
|
|
91
93
|
.catch((e) => {
|
|
92
94
|
sendUnexpectedError(request, e, 'Run verification');
|
|
93
95
|
});
|
|
@@ -126,7 +128,7 @@ export const contractVerification = (call) => {
|
|
|
126
128
|
throw new ConnectorError('loadPlugin called with something that returned an undefined request');
|
|
127
129
|
}
|
|
128
130
|
Promise.resolve()
|
|
129
|
-
.then(() => loadPlugin(mapConfig(loadPluginRequest.getConfig(), sendContractResponse), makeLogPrinter(sendContractResponse), makeResultPrinter(sendContractResponse), loadPluginRequest
|
|
131
|
+
.then(() => loadPlugin(mapConfig(loadPluginRequest.getConfig(), sendContractResponse, functionRegistry), makeLogPrinter(sendContractResponse), makeResultPrinter(sendContractResponse), loadPluginRequest
|
|
130
132
|
.getCallerVersionsList()
|
|
131
133
|
.map((s) => s != null ? s.getValue() : 'missing-version-value'), loadPluginRequest.getModuleNamesList().map((s, index) => {
|
|
132
134
|
if (s == null) {
|
|
@@ -134,7 +136,7 @@ export const contractVerification = (call) => {
|
|
|
134
136
|
}
|
|
135
137
|
return s.getValue();
|
|
136
138
|
})))
|
|
137
|
-
.then((result) => sendContractResponse(getId(request), makeResultResponse(result)))
|
|
139
|
+
.then((result) => sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result)))
|
|
138
140
|
.catch((e) => {
|
|
139
141
|
sendUnexpectedError(request, e, 'load plugin');
|
|
140
142
|
});
|
|
@@ -154,12 +156,30 @@ export const contractVerification = (call) => {
|
|
|
154
156
|
throw new ConnectorError('Handle was missing a value');
|
|
155
157
|
}
|
|
156
158
|
registerFunction(verificationId, handle, makeInvokeFunction(handle, sendContractResponse))
|
|
157
|
-
.then((result) => sendContractResponse(getId(request), makeResultResponse(result)))
|
|
159
|
+
.then((result) => sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result)))
|
|
158
160
|
.catch((e) => {
|
|
159
161
|
sendUnexpectedError(request, e, 'load plugin');
|
|
160
162
|
});
|
|
161
163
|
}
|
|
162
164
|
break;
|
|
165
|
+
case WireVerificationRequest.KindCase.INVOKE_FUNCTION:
|
|
166
|
+
{
|
|
167
|
+
const invokeFunctionRequest = request.getInvokeFunction();
|
|
168
|
+
if (invokeFunctionRequest == null) {
|
|
169
|
+
throw new ConnectorError('invokeFunction called with something that returned an undefined request');
|
|
170
|
+
}
|
|
171
|
+
const handle = invokeFunctionRequest.getHandle()?.getValue();
|
|
172
|
+
if (handle == null) {
|
|
173
|
+
throw new ConnectorError('Handle was missing a value');
|
|
174
|
+
}
|
|
175
|
+
const args = invokeFunctionRequest
|
|
176
|
+
.getArgumentsList()
|
|
177
|
+
.map((s) => s.getValue());
|
|
178
|
+
Promise.resolve(functionRegistry.getCoreFunction(handle)(...args)).then((result) => {
|
|
179
|
+
sendContractResponse('maintainerDebug', getId(request), makeResultResponse(result));
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
163
183
|
default:
|
|
164
184
|
throw new UnreachableError(type);
|
|
165
185
|
}
|