@trayio/cdk-runtime 3.13.1-unstable → 3.14.0-beta
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/dist/connector/operation/HttpOperationExecution.d.ts +0 -1
- package/dist/connector/operation/HttpOperationExecution.d.ts.map +1 -1
- package/dist/connector/operation/HttpOperationExecution.js +2 -20
- package/dist/connector/operation/OperationExecutionGateway.unit.test.d.ts.map +1 -1
- package/dist/connector/operation/OperationExecutionGateway.unit.test.js +0 -40
- package/package.json +5 -5
|
@@ -23,7 +23,6 @@ export declare class HttpOperationExecution<AUTH extends OperationHandlerAuth<un
|
|
|
23
23
|
private serializeAsFile;
|
|
24
24
|
private serializeEmptyBody;
|
|
25
25
|
private defaultErrorHandling;
|
|
26
|
-
private parseErrorResponse;
|
|
27
26
|
private parseResponse;
|
|
28
27
|
private parseBodyAsJson;
|
|
29
28
|
private parseEmptyBody;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationExecution.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAKlC,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EAGtB,oBAAoB,EACpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAGN,oBAAoB,EAMpB,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAW7D,OAAO,EAAQ,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2DAA2D,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,qBAAa,sBAAsB,CAClC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG,CACF,YAAW,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAE7C,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,mBAAmB,CAA4C;IACvE,WAAW,EAAE,oBAAoB,CAAC;gBAGjC,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,EAC5C,mBAAmB,EAAE,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,EAC9D,WAAW,EAAE,oBAAoB;IAU5B,OAAO,CACZ,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAClC,KAAK,EAAE,EAAE,GACP,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"HttpOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationExecution.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAKlC,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EAGtB,oBAAoB,EACpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAGN,oBAAoB,EAMpB,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAW7D,OAAO,EAAQ,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2DAA2D,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,qBAAa,sBAAsB,CAClC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG,CACF,YAAW,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAE7C,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,mBAAmB,CAA4C;IACvE,WAAW,EAAE,oBAAoB,CAAC;gBAGjC,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,EAC5C,mBAAmB,EAAE,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,EAC9D,WAAW,EAAE,oBAAoB;IAU5B,OAAO,CACZ,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAClC,KAAK,EAAE,EAAE,GACP,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAsDvC,OAAO,CAAC,eAAe;IAkCvB,OAAO,CAAC,6BAA6B;IAiCrC,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,oBAAoB;IAuD5B,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,aAAa;IAiCrB,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,eAAe;IA2CvB,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,qBAAqB;CAwC7B"}
|
|
@@ -63,7 +63,7 @@ class HttpOperationExecution {
|
|
|
63
63
|
const resultTE = this.httpClient.execute(operationRequest.method, operationRequest.path, httpRequestE.right);
|
|
64
64
|
const operationResponseTE = (0, function_1.pipe)(resultTE,
|
|
65
65
|
// get the dsl http response object
|
|
66
|
-
TE.map((response) => this.handler.responseHandler(ctx, input, new HttpOperationHandler_1.HttpOperationResponseBuilder(response, this.defaultErrorHandling(response.statusCode)
|
|
66
|
+
TE.map((response) => this.handler.responseHandler(ctx, input, new HttpOperationHandler_1.HttpOperationResponseBuilder(response, this.defaultErrorHandling(response.statusCode)))),
|
|
67
67
|
// interpret the dsl response object by mapping the low level http response to a connector response
|
|
68
68
|
TE.chain((operationResponse) => this.parseResponse(operationResponse)),
|
|
69
69
|
// handle errors during the execution of the http request or parsing or the http response
|
|
@@ -170,27 +170,9 @@ class HttpOperationExecution {
|
|
|
170
170
|
statusCode,
|
|
171
171
|
}));
|
|
172
172
|
}
|
|
173
|
-
parseErrorResponse(operationResponse) {
|
|
174
|
-
return (0, function_1.pipe)(operationResponse.contentType, O.fold(() => this.parseEmptyBody(operationResponse), (contentType) => {
|
|
175
|
-
switch (contentType) {
|
|
176
|
-
case Http_1.HttpContentType.Json:
|
|
177
|
-
const bufferTE = BufferExtensions_1.BufferExtensions.readableToArrayBuffer(operationResponse.response.body);
|
|
178
|
-
return (0, function_1.pipe)(bufferTE, TE.chain((buffer) => {
|
|
179
|
-
const deserializedBodyE = this.jsonSerialization.deserialize(buffer);
|
|
180
|
-
return TE.fromEither(deserializedBodyE);
|
|
181
|
-
}));
|
|
182
|
-
default:
|
|
183
|
-
return TE.right(undefined);
|
|
184
|
-
}
|
|
185
|
-
}));
|
|
186
|
-
}
|
|
187
173
|
parseResponse(operationResponse) {
|
|
188
174
|
if (operationResponse.response.statusCode >= 300) {
|
|
189
|
-
return
|
|
190
|
-
body: result,
|
|
191
|
-
statusCode: operationResponse.response.statusCode,
|
|
192
|
-
headers: operationResponse.response.headers,
|
|
193
|
-
}))));
|
|
175
|
+
return TE.right(operationResponse.errorHandling());
|
|
194
176
|
}
|
|
195
177
|
return (0, function_1.pipe)(operationResponse.contentType, O.map((contentType) => {
|
|
196
178
|
switch (contentType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationExecutionGateway.unit.test.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionGateway.unit.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OperationExecutionGateway.unit.test.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionGateway.unit.test.ts"],"names":[],"mappings":"AAyBA,OAAO,8BAA8B,CAAC"}
|
|
@@ -56,17 +56,6 @@ class TestControllerHttp {
|
|
|
56
56
|
});
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
|
-
{
|
|
60
|
-
path: `/error`,
|
|
61
|
-
method: Http_1.HttpMethod.Get,
|
|
62
|
-
execute: () => (_request) => T.of({
|
|
63
|
-
body: stream_1.Readable.from(JSON.stringify({
|
|
64
|
-
message: 'Error message',
|
|
65
|
-
})),
|
|
66
|
-
headers: {},
|
|
67
|
-
statusCode: 500,
|
|
68
|
-
}),
|
|
69
|
-
},
|
|
70
59
|
{
|
|
71
60
|
path: `/tokens`,
|
|
72
61
|
method: Http_1.HttpMethod.Get,
|
|
@@ -395,33 +384,4 @@ describe('OperationExecutionGateway', () => {
|
|
|
395
384
|
.finallyDoNothing())
|
|
396
385
|
.nothingAfterAll());
|
|
397
386
|
});
|
|
398
|
-
describe('it should an error using the body as the message', () => {
|
|
399
|
-
const getProductOperation = OperationHandlerSetup_1.OperationHandlerSetup.configureHandler((handler) => handler.usingHttp((http) => http
|
|
400
|
-
.get('http://localhost:3000/error')
|
|
401
|
-
.handleRequest((ctx, input, request) => request.addPathParameter('id', input.id.toString()).withoutBody())
|
|
402
|
-
.handleResponse((ctx, input, response) => response
|
|
403
|
-
.withJsonErrorHandling((errorResponse) => {
|
|
404
|
-
console.log(errorResponse.body);
|
|
405
|
-
return OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.apiError(errorResponse.body.message));
|
|
406
|
-
})
|
|
407
|
-
.parseWithBodyAsJson())));
|
|
408
|
-
OperationHandlerTest_1.OperationHandlerTestSetup.configureHandlerTest(getProductOperation, (handlerTest) => handlerTest
|
|
409
|
-
.usingHandlerContext('test')
|
|
410
|
-
.nothingBeforeAll()
|
|
411
|
-
.testCase('should get a product', (testCase) => testCase
|
|
412
|
-
.usingHandlerContext('test')
|
|
413
|
-
.givenNothing()
|
|
414
|
-
.when(() => ({ id: 2 }))
|
|
415
|
-
.then(({ output }) => {
|
|
416
|
-
const outputValue = OperationHandler_1.OperationHandlerResult.failure(output);
|
|
417
|
-
if (outputValue.isFailure && outputValue.error.isFailure) {
|
|
418
|
-
expect(outputValue.error.error.message).toEqual('Error message');
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
fail('Expected output to be a failure');
|
|
422
|
-
}
|
|
423
|
-
})
|
|
424
|
-
.finallyDoNothing())
|
|
425
|
-
.nothingAfterAll());
|
|
426
|
-
});
|
|
427
387
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-runtime",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0-beta",
|
|
4
4
|
"description": "A Runtime that executes connector operations defined using the CDK DSL",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"node": ">=18.x"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@trayio/axios": "3.
|
|
18
|
-
"@trayio/cdk-dsl": "3.
|
|
19
|
-
"@trayio/express": "3.
|
|
20
|
-
"@trayio/winston": "3.
|
|
17
|
+
"@trayio/axios": "3.14.0-beta",
|
|
18
|
+
"@trayio/cdk-dsl": "3.14.0-beta",
|
|
19
|
+
"@trayio/express": "3.14.0-beta",
|
|
20
|
+
"@trayio/winston": "3.14.0-beta",
|
|
21
21
|
"mime": "3.0.0",
|
|
22
22
|
"uuid": "9.0.0"
|
|
23
23
|
},
|