@trayio/cdk-runtime 4.15.0 → 4.15.2-unstable
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.map +1 -1
- package/dist/connector/operation/HttpOperationExecution.js +37 -5
- package/dist/connector/operation/OperationExecutionGateway.d.ts.map +1 -1
- package/dist/connector/operation/OperationExecutionGateway.js +3 -0
- package/package.json +5 -5
|
@@ -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;
|
|
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;AAEtG,OAAO,EA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ler_1 = require("@trayio/cdk-dsl/connector/operation/Http
|
|
|
36
36
|
const Http_1 = require("@trayio/commons/http/Http");
|
|
37
37
|
const JsonSerialization_1 = require("@trayio/commons/serialization/JsonSerialization");
|
|
38
38
|
const BufferExtensions_1 = require("@trayio/commons/buffer/BufferExtensions");
|
|
39
|
+
const WinstonLogging_1 = require("@trayio/winston/logging/WinstonLogging");
|
|
39
40
|
const mime = require('mime');
|
|
41
|
+
const logger = (0, WinstonLogging_1.getLogger)({});
|
|
40
42
|
const { AWS_LAMBDA_FUNCTION_MEMORY_SIZE, CONNECTOR_MAX_ALLOCATED_RAM_MB } = process.env;
|
|
41
43
|
class HttpOperationExecution {
|
|
42
44
|
jsonSerialization;
|
|
@@ -63,7 +65,16 @@ class HttpOperationExecution {
|
|
|
63
65
|
const resultTE = this.httpClient.execute(operationRequest.method, operationRequest.path, httpRequestE.right);
|
|
64
66
|
const operationResponseTE = (0, function_1.pipe)(resultTE,
|
|
65
67
|
// get the dsl http response object
|
|
66
|
-
TE.map((response) =>
|
|
68
|
+
TE.map((response) => {
|
|
69
|
+
const errorContext = {
|
|
70
|
+
statusCode: response.statusCode,
|
|
71
|
+
method: operationRequest.method,
|
|
72
|
+
path: operationRequest.path,
|
|
73
|
+
httpPathParams: httpRequestE.right.pathParams,
|
|
74
|
+
};
|
|
75
|
+
const responseBuilder = new HttpOperationHandler_1.HttpOperationResponseBuilder(response, this.defaultErrorHandling(errorContext), O.none);
|
|
76
|
+
return this.handler.responseHandler(ctx, input, responseBuilder);
|
|
77
|
+
}),
|
|
67
78
|
// interpret the dsl response object by mapping the low level http response to a connector response
|
|
68
79
|
TE.chain((operationResponse) => this.parseResponse(operationResponse)),
|
|
69
80
|
// handle errors during the execution of the http request or parsing or the http response
|
|
@@ -124,6 +135,11 @@ class HttpOperationExecution {
|
|
|
124
135
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
125
136
|
}), TE.chain((response) => {
|
|
126
137
|
if (response.statusCode >= 300) {
|
|
138
|
+
logger.error('Failed to download file', {
|
|
139
|
+
// Log download failure
|
|
140
|
+
url: fileRef.url,
|
|
141
|
+
statusCode: response.statusCode,
|
|
142
|
+
});
|
|
127
143
|
return TE.left(Error('error downloading file from source'));
|
|
128
144
|
}
|
|
129
145
|
const parsedSized = Number.parseInt(response.headers.ContentLength ||
|
|
@@ -157,6 +173,10 @@ class HttpOperationExecution {
|
|
|
157
173
|
});
|
|
158
174
|
return (0, function_1.pipe)(downloadFilefromReference, TE.chain((response) => {
|
|
159
175
|
if (response.statusCode >= 300) {
|
|
176
|
+
logger.error('Failed to download file', {
|
|
177
|
+
statusCode: response.statusCode,
|
|
178
|
+
url: operationRequest.path,
|
|
179
|
+
});
|
|
160
180
|
return TE.left(Error('error downloading file from source'));
|
|
161
181
|
}
|
|
162
182
|
return TE.right(response.body);
|
|
@@ -165,10 +185,22 @@ class HttpOperationExecution {
|
|
|
165
185
|
serializeEmptyBody() {
|
|
166
186
|
return TE.right(BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)));
|
|
167
187
|
}
|
|
168
|
-
defaultErrorHandling(
|
|
169
|
-
return () =>
|
|
170
|
-
statusCode,
|
|
171
|
-
|
|
188
|
+
defaultErrorHandling(errorContext) {
|
|
189
|
+
return () => {
|
|
190
|
+
const { statusCode, method, path, httpPathParams } = errorContext;
|
|
191
|
+
const message = `API returned a status code of ${statusCode}`;
|
|
192
|
+
// context for logging
|
|
193
|
+
const logContext = {
|
|
194
|
+
detail: {
|
|
195
|
+
method,
|
|
196
|
+
statusCode: statusCode.toString(),
|
|
197
|
+
httpPathParams: JSON.stringify(httpPathParams),
|
|
198
|
+
},
|
|
199
|
+
timestamp: new Date().toISOString(),
|
|
200
|
+
};
|
|
201
|
+
logger.error(message, logContext);
|
|
202
|
+
return OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.apiError(message, { statusCode, method, path }));
|
|
203
|
+
};
|
|
172
204
|
}
|
|
173
205
|
parseErrorResponse(operationResponse) {
|
|
174
206
|
return (0, function_1.pipe)(operationResponse.contentType, O.fold(() => this.parseEmptyBody(operationResponse), (contentType) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationExecutionGateway.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionGateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,OAAO,EACN,oBAAoB,EAEpB,yBAAyB,EAGzB,MAAM,sDAAsD,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"OperationExecutionGateway.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionGateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,OAAO,EACN,oBAAoB,EAEpB,yBAAyB,EAGzB,MAAM,sDAAsD,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK1D,qBAAa,yBAAyB;IACrC,OAAO,CAAC,gBAAgB,CAA4B;IACpD,iCAAiC,EAAE,iCAAiC,CAAC;gBAEzD,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW;IA8B5D,MAAM,CAAC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,EAClE,gBAAgB,EAAE,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,EAC1D,cAAc,EAAE,OAAO,GACrB,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;CAQ9C"}
|
|
@@ -28,7 +28,9 @@ const O = __importStar(require("fp-ts/Option"));
|
|
|
28
28
|
const function_1 = require("fp-ts/function");
|
|
29
29
|
const OperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandler");
|
|
30
30
|
const OperationHandlerSetup_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerSetup");
|
|
31
|
+
const WinstonLogging_1 = require("@trayio/winston/logging/WinstonLogging");
|
|
31
32
|
const OperationExecutionFactory_1 = require("./OperationExecutionFactory");
|
|
33
|
+
const logger = (0, WinstonLogging_1.getLogger)({});
|
|
32
34
|
class OperationExecutionGateway {
|
|
33
35
|
executionFactory;
|
|
34
36
|
operationHandlerInvocationFactory;
|
|
@@ -41,6 +43,7 @@ class OperationExecutionGateway {
|
|
|
41
43
|
this.executionFactory = new OperationExecutionFactory_1.OperationExecutionFactory(httpClient, fileStorage, operationHandlerInvocationFactory);
|
|
42
44
|
}
|
|
43
45
|
lookup(handlerReference, includePrivate) {
|
|
46
|
+
logger.info('Looking up handler', { handlerName: handlerReference.name });
|
|
44
47
|
return (0, function_1.pipe)(OperationHandlerSetup_1.OperationHandlerRegistry.resolve(handlerReference), O.filter((handler) => includePrivate || !handler.isPrivate), O.map((handler) => this.executionFactory.executionFrom(handler)));
|
|
45
48
|
}
|
|
46
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-runtime",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.2-unstable",
|
|
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": "4.15.
|
|
18
|
-
"@trayio/cdk-dsl": "4.15.
|
|
19
|
-
"@trayio/express": "4.15.
|
|
20
|
-
"@trayio/winston": "4.15.
|
|
17
|
+
"@trayio/axios": "4.15.2-unstable",
|
|
18
|
+
"@trayio/cdk-dsl": "4.15.2-unstable",
|
|
19
|
+
"@trayio/express": "4.15.2-unstable",
|
|
20
|
+
"@trayio/winston": "4.15.2-unstable",
|
|
21
21
|
"mime": "3.0.0",
|
|
22
22
|
"uuid": "9.0.0"
|
|
23
23
|
},
|