@trayio/cdk-runtime 5.35.0-unstable.fd7158a → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connector/operation/CompositeOperationExecutionPolling.d.ts.map +1 -1
- package/dist/connector/operation/CompositeOperationExecutionPolling.js +3 -3
- package/dist/connector/operation/HttpOperationExecution.d.ts +2 -2
- package/dist/connector/operation/HttpOperationExecution.d.ts.map +1 -1
- package/dist/connector/operation/HttpOperationExecution.js +68 -86
- package/dist/connector/operation/HttpOperationExecutionFactory.d.ts +2 -2
- package/dist/connector/operation/HttpOperationExecutionFactory.d.ts.map +1 -1
- package/dist/connector/operation/OperationExecutionGateway.d.ts +2 -2
- package/dist/connector/operation/OperationExecutionGateway.d.ts.map +1 -1
- package/dist/connector/operation/OperationExecutionGateway.js +28 -4
- package/dist/connector/operation/OperationExecutionGateway.unit.test.d.ts.map +1 -1
- package/dist/connector/operation/OperationExecutionGateway.unit.test.js +34 -44
- package/dist/connector/operation/OperationExecutionTestRunner.d.ts.map +1 -1
- package/dist/connector/operation/OperationExecutionTestRunner.js +29 -4
- package/dist/connector/operation/OperationExecutionValidationFactory.d.ts +2 -2
- package/dist/connector/operation/OperationExecutionValidationFactory.d.ts.map +1 -1
- package/dist/connector/operation/OperationExecutionValidationFactory.js +26 -2
- package/dist/connector/polling/PollingServiceClient.d.ts.map +1 -1
- package/dist/connector/polling/PollingServiceClient.integration.test.js +7 -17
- package/dist/connector/polling/PollingServiceClient.js +26 -3
- package/dist/connector/polling/PollingServiceClient.unit.test.js +40 -20
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeOperationExecutionPolling.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/CompositeOperationExecutionPolling.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EAEvB,sBAAsB,EAEtB,oBAAoB,EAEpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+DAA+D,CAAC;AAC1G,OAAO,EAEN,mBAAmB,EACnB,MAAM,kDAAkD,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,MAAM,MAAM,6BAA6B,GAAG,mBAAmB,GAAG;IACjE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAiGF,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"CompositeOperationExecutionPolling.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/CompositeOperationExecutionPolling.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EAEvB,sBAAsB,EAEtB,oBAAoB,EAEpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+DAA+D,CAAC;AAC1G,OAAO,EAEN,mBAAmB,EACnB,MAAM,kDAAkD,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,MAAM,MAAM,6BAA6B,GAAG,mBAAmB,GAAG;IACjE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAiGF,eAAO,MAAM,kBAAkB,gBACjB,oBAAoB,KAC/B,OAEqD,CAAC;AAoCzD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACxC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG,EACF,IAAI,EAAE;IACP,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,EAAE,EAAE,CAAC;IACV,OAAO,EAAE,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IAClD,wBAAwB,EAAE,iCAAiC,CAAC;IAC5D,yBAAyB,EAAE,CAAC,CAAC,EAAE,sBAAsB,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IACpE,cAAc,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,sBAAsB,CAAC,GAAG,CAAC,CAAC;CAC5D,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAiCvC;AAED,wBAAgB,8BAA8B,CAC7C,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EAClD,IAAI,EAAE;IACP,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACnC,WAAW,EACR,oBAAoB,CAAC,iBAAiB,GACtC,oBAAoB,CAAC,kBAAkB,CAAC;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,6BAA6B,CAAC;IAC5C,oBAAoB,EAAE,oBAAoB,CAAC;CAC3C,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDhB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPollingLifecycle = void 0;
|
|
4
|
-
exports.runTriggerPollDedup = runTriggerPollDedup;
|
|
5
|
-
exports.runPollingRegisterOrDeregister = runPollingRegisterOrDeregister;
|
|
3
|
+
exports.runPollingRegisterOrDeregister = exports.runTriggerPollDedup = exports.isPollingLifecycle = void 0;
|
|
6
4
|
const OperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandler");
|
|
7
5
|
const PollingTypes_1 = require("@trayio/cdk-dsl/connector/operation/PollingTypes");
|
|
8
6
|
/**
|
|
@@ -125,6 +123,7 @@ async function runTriggerPollDedup(args) {
|
|
|
125
123
|
return mapCaughtError(error);
|
|
126
124
|
}
|
|
127
125
|
}
|
|
126
|
+
exports.runTriggerPollDedup = runTriggerPollDedup;
|
|
128
127
|
function runPollingRegisterOrDeregister(args) {
|
|
129
128
|
const { ctx, handlerType, operationName: registeredHandlerName, pollingInput, pollingServiceClient, } = args;
|
|
130
129
|
switch (handlerType) {
|
|
@@ -161,3 +160,4 @@ function runPollingRegisterOrDeregister(args) {
|
|
|
161
160
|
throw new Error(`polling lifecycle called for non-polling handler type: ${String(handlerType)}`);
|
|
162
161
|
}
|
|
163
162
|
}
|
|
163
|
+
exports.runPollingRegisterOrDeregister = runPollingRegisterOrDeregister;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as O from 'fp-ts/Option';
|
|
2
2
|
import { OperationHandlerAuth, OperationHandlerContext, OperationHandlerResult, OperationHandlerType } from '@trayio/cdk-dsl/connector/operation/OperationHandler';
|
|
3
3
|
import { HttpOperationHandler } from '@trayio/cdk-dsl/connector/operation/HttpOperationHandler';
|
|
4
4
|
import { HttpClient } from '@trayio/commons/http/HttpClient';
|
|
@@ -12,7 +12,7 @@ export declare class HttpOperationExecution<AUTH extends OperationHandlerAuth<un
|
|
|
12
12
|
private fileStorage;
|
|
13
13
|
private globalConfiguration;
|
|
14
14
|
handlerType: OperationHandlerType;
|
|
15
|
-
constructor(httpClient: HttpClient, fileStorage: FileStorage, handler: HttpOperationHandler<AUTH, IN, OUT>, globalConfiguration:
|
|
15
|
+
constructor(httpClient: HttpClient, fileStorage: FileStorage, handler: HttpOperationHandler<AUTH, IN, OUT>, globalConfiguration: O.Option<OperationGlobalConfigHttp<AUTH>>, handlerType: OperationHandlerType);
|
|
16
16
|
execute(ctx: OperationHandlerContext<AUTH>, input: IN): Promise<OperationHandlerResult<OUT>>;
|
|
17
17
|
private decorateRequest;
|
|
18
18
|
private operationRequestToHttpRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationExecution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HttpOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationExecution.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAMlC,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EAItB,oBAAoB,EACpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAGN,oBAAoB,EAMpB,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAY7D,OAAO,EAAQ,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2DAA2D,CAAC;AAEtG,OAAO,0BAA0B,MAAM,8BAA8B,CAAC;AAOtE,qBAAa,sBAAsB,CAClC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG,CACF,SAAQ,0BAA0B,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAClD,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;IAW5B,OAAO,CACZ,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAClC,KAAK,EAAE,EAAE,GACP,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAuDvC,OAAO,CAAC,eAAe;IAkCvB,OAAO,CAAC,6BAA6B;IAiCrC,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,oBAAoB;IA4E5B,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,kBAAkB;IAyC1B,OAAO,CAAC,aAAa;IAoDrB,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,eAAe;IA8CvB,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,qBAAqB;CAwC7B"}
|
|
@@ -15,30 +15,24 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
27
|
};
|
|
38
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
29
|
exports.HttpOperationExecution = void 0;
|
|
40
|
-
const effect_1 = require("effect");
|
|
41
30
|
const stream_1 = require("stream");
|
|
31
|
+
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
32
|
+
const E = __importStar(require("fp-ts/Either"));
|
|
33
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
34
|
+
const function_1 = require("fp-ts/function");
|
|
35
|
+
const Array_1 = require("fp-ts/Array");
|
|
42
36
|
const uuid_1 = require("uuid");
|
|
43
37
|
const querystring = __importStar(require("querystring"));
|
|
44
38
|
const OperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandler");
|
|
@@ -66,33 +60,24 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
66
60
|
this.handlerType = handlerType;
|
|
67
61
|
}
|
|
68
62
|
async execute(ctx, input) {
|
|
69
|
-
const request = (0,
|
|
70
|
-
onNone: () => this.handler.request,
|
|
71
|
-
onSome: (globalConfig) => this.decorateRequest(globalConfig, this.handler.request, ctx),
|
|
72
|
-
}));
|
|
63
|
+
const request = (0, function_1.pipe)(this.globalConfiguration, O.match(() => this.handler.request, (globalConfig) => this.decorateRequest(globalConfig, this.handler.request, ctx)));
|
|
73
64
|
const operationRequest = this.handler.requestHandler(ctx, input, request);
|
|
74
|
-
const httpRequestE = await
|
|
75
|
-
if (
|
|
65
|
+
const httpRequestE = await this.operationRequestToHttpRequest(operationRequest)();
|
|
66
|
+
if (E.isLeft(httpRequestE)) {
|
|
76
67
|
return OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.connectorError(httpRequestE.left.message));
|
|
77
68
|
}
|
|
78
69
|
const resultTE = this.httpClient.execute(operationRequest.method, operationRequest.path, httpRequestE.right);
|
|
79
|
-
const operationResponseTE = (0,
|
|
70
|
+
const operationResponseTE = (0, function_1.pipe)(resultTE,
|
|
80
71
|
// get the dsl http response object
|
|
81
|
-
|
|
72
|
+
TE.map((response) => this.handler.responseHandler(ctx, input, new HttpOperationHandler_1.HttpOperationResponseBuilder(response, this.defaultErrorHandling(response.statusCode), O.none))),
|
|
82
73
|
// interpret the dsl response object by mapping the low level http response to a connector response
|
|
83
|
-
|
|
74
|
+
TE.chain((operationResponse) => this.parseResponse(operationResponse)),
|
|
84
75
|
// handle errors during the execution of the http request or parsing or the http response
|
|
85
|
-
|
|
86
|
-
return
|
|
76
|
+
TE.mapLeft((error) => OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.connectorError(error.message))));
|
|
77
|
+
return TE.toUnion(operationResponseTE)();
|
|
87
78
|
}
|
|
88
79
|
decorateRequest(globalConfig, operationRequest, ctx) {
|
|
89
|
-
return (0,
|
|
90
|
-
onNone: () => operationRequest,
|
|
91
|
-
onSome: (baseUrl) => operationRequest.withUrl(`${baseUrl(ctx)}${operationRequest.path}`),
|
|
92
|
-
}), (request) => (0, effect_1.pipe)(globalConfig.bearerToken, effect_1.Option.match({
|
|
93
|
-
onNone: () => request,
|
|
94
|
-
onSome: (bearerToken) => request.withBearerToken(bearerToken(ctx)),
|
|
95
|
-
})), (request) => (0, effect_1.pipe)(globalConfig.headers, (headers) => {
|
|
80
|
+
return (0, function_1.pipe)(globalConfig.baseUrl, O.fold(() => operationRequest, (baseUrl) => operationRequest.withUrl(`${baseUrl(ctx)}${operationRequest.path}`)), (request) => (0, function_1.pipe)(globalConfig.bearerToken, O.fold(() => request, (bearerToken) => request.withBearerToken(bearerToken(ctx)))), (request) => (0, function_1.pipe)(globalConfig.headers, (headers) => {
|
|
96
81
|
if (headers.length === 0) {
|
|
97
82
|
return request;
|
|
98
83
|
}
|
|
@@ -103,7 +88,7 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
103
88
|
}));
|
|
104
89
|
}
|
|
105
90
|
operationRequestToHttpRequest(operationRequest) {
|
|
106
|
-
return (0,
|
|
91
|
+
return (0, function_1.pipe)(operationRequest.contentType, O.map((contentType) => {
|
|
107
92
|
switch (contentType) {
|
|
108
93
|
case Http_1.HttpContentType.Json:
|
|
109
94
|
return this.serializeAsJson(operationRequest.body);
|
|
@@ -118,39 +103,39 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
118
103
|
default:
|
|
119
104
|
return this.serializeAsJson(operationRequest.body);
|
|
120
105
|
}
|
|
121
|
-
}),
|
|
106
|
+
}), O.getOrElse(() => this.serializeEmptyBody()), TE.map((serializedBody) => ({
|
|
122
107
|
...operationRequest.request,
|
|
123
108
|
body: serializedBody,
|
|
124
109
|
})));
|
|
125
110
|
}
|
|
126
111
|
serializeAsJson(body) {
|
|
127
112
|
const serializedBody = this.jsonSerialization.serialize(body);
|
|
128
|
-
return
|
|
113
|
+
return TE.right(BufferExtensions_1.BufferExtensions.arrayBufferToReadable(serializedBody));
|
|
129
114
|
}
|
|
130
115
|
serializeAsFormUrlEncoded(body) {
|
|
131
116
|
const serializedBody = querystring.stringify(body);
|
|
132
|
-
return
|
|
117
|
+
return TE.right(BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new TextEncoder().encode(serializedBody)));
|
|
133
118
|
}
|
|
134
119
|
serializeAsText(body) {
|
|
135
120
|
const serializedBody = new TextEncoder().encode(body);
|
|
136
|
-
return
|
|
121
|
+
return TE.right(BufferExtensions_1.BufferExtensions.arrayBufferToReadable(serializedBody));
|
|
137
122
|
}
|
|
138
123
|
serializeAsMultipart(body) {
|
|
139
124
|
const fileStreamsFromReferencesTasks = Object.keys(body.files).map((fileKey) => {
|
|
140
125
|
const fileRef = body.files[fileKey];
|
|
141
126
|
if (fileRef.url) {
|
|
142
|
-
return (0,
|
|
127
|
+
return (0, function_1.pipe)(this.httpClient.execute(Http_1.HttpMethod.Get, fileRef.url, Http_1.HttpRequest.create({
|
|
143
128
|
headers: {},
|
|
144
129
|
pathParams: {},
|
|
145
130
|
queryString: {},
|
|
146
131
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
147
|
-
})),
|
|
132
|
+
})), TE.chain((response) => {
|
|
148
133
|
if (response.statusCode >= 300) {
|
|
149
|
-
return
|
|
134
|
+
return TE.left(Error('error downloading file from source'));
|
|
150
135
|
}
|
|
151
136
|
const parsedSized = Number.parseInt(response.headers.ContentLength ||
|
|
152
137
|
response.headers['content-length'], 10);
|
|
153
|
-
return
|
|
138
|
+
return TE.right({
|
|
154
139
|
reference: {
|
|
155
140
|
_tag: 'FileDescriptor',
|
|
156
141
|
key: fileKey,
|
|
@@ -163,7 +148,7 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
163
148
|
});
|
|
164
149
|
}));
|
|
165
150
|
}
|
|
166
|
-
return
|
|
151
|
+
return TE.right({
|
|
167
152
|
reference: {
|
|
168
153
|
_tag: 'FileDescriptor',
|
|
169
154
|
key: fileKey,
|
|
@@ -175,11 +160,11 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
175
160
|
content: stream_1.Readable.from(fileRef.content),
|
|
176
161
|
});
|
|
177
162
|
});
|
|
178
|
-
const filesTask =
|
|
179
|
-
return (0,
|
|
163
|
+
const filesTask = (0, Array_1.sequence)(TE.MonadTask)(fileStreamsFromReferencesTasks);
|
|
164
|
+
return (0, function_1.pipe)(filesTask, TE.map((files) => files.reduce((acc, file) => {
|
|
180
165
|
acc[file.reference.key] = file;
|
|
181
166
|
return acc;
|
|
182
|
-
}, {})),
|
|
167
|
+
}, {})), TE.map((multipartFiles) => ({
|
|
183
168
|
fields: body.fields,
|
|
184
169
|
files: multipartFiles,
|
|
185
170
|
})));
|
|
@@ -191,15 +176,15 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
191
176
|
queryString: {},
|
|
192
177
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
193
178
|
}));
|
|
194
|
-
return (0,
|
|
179
|
+
return (0, function_1.pipe)(downloadFilefromReference, TE.chain((response) => {
|
|
195
180
|
if (response.statusCode >= 300) {
|
|
196
|
-
return
|
|
181
|
+
return TE.left(Error('error downloading file from source'));
|
|
197
182
|
}
|
|
198
|
-
return
|
|
183
|
+
return TE.right(response.body);
|
|
199
184
|
}));
|
|
200
185
|
}
|
|
201
186
|
serializeEmptyBody() {
|
|
202
|
-
return
|
|
187
|
+
return TE.right(BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)));
|
|
203
188
|
}
|
|
204
189
|
defaultErrorHandling(statusCode) {
|
|
205
190
|
return () => OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.apiError(`API returned a status code of ${statusCode}`, {
|
|
@@ -207,46 +192,43 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
207
192
|
}));
|
|
208
193
|
}
|
|
209
194
|
parseErrorResponse(operationResponse) {
|
|
210
|
-
return (0,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
return
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
return
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
return effect_1.Effect.succeed(undefined);
|
|
228
|
-
}
|
|
229
|
-
},
|
|
195
|
+
return (0, function_1.pipe)(operationResponse.errorContentType, O.fold(() => TE.right(undefined), (contentType) => {
|
|
196
|
+
switch (contentType) {
|
|
197
|
+
case Http_1.HttpContentType.Json:
|
|
198
|
+
const bufferTE = BufferExtensions_1.BufferExtensions.readableToArrayBuffer(operationResponse.response.body);
|
|
199
|
+
return (0, function_1.pipe)(bufferTE, TE.chain((buffer) => {
|
|
200
|
+
const deserializedBodyE = this.jsonSerialization.deserialize(buffer);
|
|
201
|
+
return TE.fromEither(deserializedBodyE);
|
|
202
|
+
}));
|
|
203
|
+
case Http_1.HttpContentType.Text:
|
|
204
|
+
const textBufferTE = BufferExtensions_1.BufferExtensions.readableToArrayBuffer(operationResponse.response.body);
|
|
205
|
+
return (0, function_1.pipe)(textBufferTE, TE.map((arrayBuffer) => {
|
|
206
|
+
const text = new TextDecoder().decode(arrayBuffer);
|
|
207
|
+
return text || undefined;
|
|
208
|
+
}));
|
|
209
|
+
default:
|
|
210
|
+
return TE.right(undefined);
|
|
211
|
+
}
|
|
230
212
|
}));
|
|
231
213
|
}
|
|
232
214
|
parseResponse(operationResponse) {
|
|
233
215
|
if (operationResponse.response.statusCode >= 300) {
|
|
234
|
-
return (0,
|
|
216
|
+
return (0, function_1.pipe)(this.parseErrorResponse(operationResponse), TE.chain((result) => TE.right(operationResponse.errorHandling(result))));
|
|
235
217
|
}
|
|
236
|
-
return (0,
|
|
218
|
+
return (0, function_1.pipe)(operationResponse.contentType, O.map((contentType) => {
|
|
237
219
|
switch (contentType) {
|
|
238
220
|
case Http_1.HttpContentType.Json:
|
|
239
221
|
return this.parseBodyAsJson(operationResponse);
|
|
240
222
|
case Http_1.HttpContentType.OctetStream:
|
|
241
223
|
return this.parseBodyAsFile(operationResponse);
|
|
242
224
|
case Http_1.HttpContentType.MultipartRequestBody:
|
|
243
|
-
return
|
|
225
|
+
return TE.right(OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.connectorError(`Invalid Response Type ${contentType}`)));
|
|
244
226
|
case Http_1.HttpContentType.Text:
|
|
245
227
|
return this.parseBodyAsText(operationResponse);
|
|
246
228
|
default:
|
|
247
229
|
return this.parseBodyAsJson(operationResponse);
|
|
248
230
|
}
|
|
249
|
-
}),
|
|
231
|
+
}), O.getOrElse(() => this.parseEmptyBody(operationResponse)), TE.map((parsedResponse) => {
|
|
250
232
|
try {
|
|
251
233
|
this.validateOperationResponse(parsedResponse);
|
|
252
234
|
}
|
|
@@ -261,20 +243,20 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
261
243
|
}
|
|
262
244
|
parseBodyAsJson(operationResponse) {
|
|
263
245
|
const bufferTE = BufferExtensions_1.BufferExtensions.readableToArrayBuffer(operationResponse.response.body);
|
|
264
|
-
return (0,
|
|
246
|
+
return (0, function_1.pipe)(bufferTE, TE.chain((buffer) => {
|
|
265
247
|
const deserializedBodyE = this.jsonSerialization.deserialize(buffer);
|
|
266
|
-
return deserializedBodyE;
|
|
267
|
-
}),
|
|
248
|
+
return TE.fromEither(deserializedBodyE);
|
|
249
|
+
}), TE.map((deserializedBody) => operationResponse.responseParser(deserializedBody)));
|
|
268
250
|
}
|
|
269
251
|
parseEmptyBody(operationResponse) {
|
|
270
|
-
return
|
|
252
|
+
return TE.right(operationResponse.responseParser(undefined));
|
|
271
253
|
}
|
|
272
254
|
parseBodyAsFile(operationResponse) {
|
|
273
255
|
const contentType = (operationResponse.response.headers[Http_1.HttpHeader.ContentType.toLowerCase()]);
|
|
274
256
|
const fileExtension = mime.getExtension(contentType);
|
|
275
257
|
const contentLength = (operationResponse.response.headers[Http_1.HttpHeader.ContentLength.toLowerCase()]);
|
|
276
258
|
const uploadOptions = this.generateUploadOptions(contentLength);
|
|
277
|
-
return (0,
|
|
259
|
+
return (0, function_1.pipe)(this.fileStorage.write({
|
|
278
260
|
content: operationResponse.response.body,
|
|
279
261
|
reference: {
|
|
280
262
|
_tag: 'FileDescriptor',
|
|
@@ -285,7 +267,7 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
285
267
|
contentType,
|
|
286
268
|
},
|
|
287
269
|
},
|
|
288
|
-
},
|
|
270
|
+
}, O.some(uploadOptions)), TE.chain((file) => (0, function_1.pipe)(this.fileStorage.getSharedUrl(file.reference.key), TE.map((sharedUrl) => operationResponse.responseParser({
|
|
289
271
|
name: file.reference.key,
|
|
290
272
|
url: sharedUrl.url,
|
|
291
273
|
mime_type: file.reference.metadata.contentType ?? '',
|
|
@@ -294,9 +276,9 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
294
276
|
}
|
|
295
277
|
parseBodyAsText(operationResponse) {
|
|
296
278
|
const arrayBufferTE = BufferExtensions_1.BufferExtensions.readableToArrayBuffer(operationResponse.response.body);
|
|
297
|
-
return (0,
|
|
279
|
+
return (0, function_1.pipe)(arrayBufferTE, TE.chain((arrayBuffer) => {
|
|
298
280
|
const deserializeBody = new TextDecoder().decode(arrayBuffer);
|
|
299
|
-
return
|
|
281
|
+
return TE.right(operationResponse.responseParser(deserializeBody));
|
|
300
282
|
}));
|
|
301
283
|
}
|
|
302
284
|
// This method is used to respect lambda memory limits as per the old falfel implementation
|
|
@@ -316,7 +298,7 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
316
298
|
const uploadOptions = {
|
|
317
299
|
// 8MB (minimum) * 4 parallel = upto 32MB/s RAM usage
|
|
318
300
|
partSize: targetSize,
|
|
319
|
-
queueSize: 4,
|
|
301
|
+
queueSize: 4,
|
|
320
302
|
acl: 'bucket-owner-full-control',
|
|
321
303
|
};
|
|
322
304
|
if (!contentLength) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { OperationHandlerAuth, OperationHandlerType } from '@trayio/cdk-dsl/connector/operation/OperationHandler';
|
|
2
|
-
import { Option } from 'effect';
|
|
3
2
|
import { HttpOperationHandler } from '@trayio/cdk-dsl/connector/operation/HttpOperationHandler';
|
|
4
3
|
import { HttpClient } from '@trayio/commons/http/HttpClient';
|
|
5
4
|
import { FileStorage } from '@trayio/commons/dist/file/File';
|
|
6
5
|
import { OperationGlobalConfigHttp } from '@trayio/cdk-dsl/connector/operation/OperationGlobalConfig';
|
|
6
|
+
import * as O from 'fp-ts/Option';
|
|
7
7
|
import { OperationExecution } from './OperationExecution';
|
|
8
8
|
export declare class HttpOperationExecutionFactory {
|
|
9
9
|
private httpClient;
|
|
10
10
|
private fileStorage;
|
|
11
11
|
constructor(httpClient: HttpClient, fileStorage: FileStorage);
|
|
12
|
-
executionFrom<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT>(handler: HttpOperationHandler<AUTH, IN, OUT>, globalConfiguration:
|
|
12
|
+
executionFrom<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT>(handler: HttpOperationHandler<AUTH, IN, OUT>, globalConfiguration: O.Option<OperationGlobalConfigHttp<AUTH>>, handlerType: OperationHandlerType): OperationExecution<AUTH, IN, OUT>;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=HttpOperationExecutionFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpOperationExecutionFactory.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationExecutionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,oBAAoB,EACpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"HttpOperationExecutionFactory.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationExecutionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,oBAAoB,EACpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2DAA2D,CAAC;AACtG,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,qBAAa,6BAA6B;IAExC,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,WAAW;gBADX,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW;IAGjC,aAAa,CAAC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,EACzE,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,GAC/B,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;CASpC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import * as O from 'fp-ts/Option';
|
|
1
2
|
import { OperationHandlerAuth, OperationHandlerReference } from '@trayio/cdk-dsl/connector/operation/OperationHandler';
|
|
2
|
-
import { Option } from 'effect';
|
|
3
3
|
import { HttpClient } from '@trayio/commons/http/HttpClient';
|
|
4
4
|
import { FileStorage } from '@trayio/commons/file/File';
|
|
5
5
|
import { OperationHandlerInvocationFactory } from './OperationHandlerInvocationFactory';
|
|
@@ -8,6 +8,6 @@ export declare class OperationExecutionGateway {
|
|
|
8
8
|
private executionFactory;
|
|
9
9
|
operationHandlerInvocationFactory: OperationHandlerInvocationFactory;
|
|
10
10
|
constructor(httpClient: HttpClient, fileStorage: FileStorage);
|
|
11
|
-
lookup<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT>(handlerReference: OperationHandlerReference<AUTH, IN, OUT>, includePrivate: boolean):
|
|
11
|
+
lookup<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT>(handlerReference: OperationHandlerReference<AUTH, IN, OUT>, includePrivate: boolean): O.Option<OperationExecution<AUTH, IN, OUT>>;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=OperationExecutionGateway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationExecutionGateway.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionGateway.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;AACxD,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,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;CAO9C"}
|
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.OperationExecutionGateway = void 0;
|
|
27
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
28
|
+
const function_1 = require("fp-ts/function");
|
|
4
29
|
const OperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandler");
|
|
5
|
-
const effect_1 = require("effect");
|
|
6
30
|
const OperationHandlerSetup_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerSetup");
|
|
7
31
|
const OperationExecutionFactory_1 = require("./OperationExecutionFactory");
|
|
8
32
|
class OperationExecutionGateway {
|
|
@@ -10,14 +34,14 @@ class OperationExecutionGateway {
|
|
|
10
34
|
operationHandlerInvocationFactory;
|
|
11
35
|
constructor(httpClient, fileStorage) {
|
|
12
36
|
const operationHandlerInvocationFactory = (ctx) => (handlerReference) => (input) => {
|
|
13
|
-
const result = (0,
|
|
14
|
-
return
|
|
37
|
+
const result = (0, function_1.pipe)(this.lookup(handlerReference, true), O.map((handlerExecution) => handlerExecution.execute(ctx, input)));
|
|
38
|
+
return O.getOrElse(() => Promise.resolve(OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.connectorError(`Handler for reference ${handlerReference.name} not found`))))(result);
|
|
15
39
|
};
|
|
16
40
|
this.operationHandlerInvocationFactory = operationHandlerInvocationFactory;
|
|
17
41
|
this.executionFactory = new OperationExecutionFactory_1.OperationExecutionFactory(httpClient, fileStorage, operationHandlerInvocationFactory);
|
|
18
42
|
}
|
|
19
43
|
lookup(handlerReference, includePrivate) {
|
|
20
|
-
return (0,
|
|
44
|
+
return (0, function_1.pipe)(OperationHandlerSetup_1.OperationHandlerRegistry.resolve(handlerReference), O.filter((handler) => includePrivate || !handler.isPrivate), O.map((handler) => this.executionFactory.executionFrom(handler)));
|
|
21
45
|
}
|
|
22
46
|
}
|
|
23
47
|
exports.OperationExecutionGateway = OperationExecutionGateway;
|
|
@@ -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":"AA4BA,OAAO,8BAA8B,CAAC"}
|
|
@@ -15,30 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
27
|
};
|
|
38
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const effect_1 = require("effect");
|
|
40
29
|
const stream_1 = require("stream");
|
|
30
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
31
|
+
const T = __importStar(require("fp-ts/Task"));
|
|
32
|
+
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
41
33
|
const querystring = __importStar(require("querystring"));
|
|
34
|
+
const function_1 = require("fp-ts/function");
|
|
42
35
|
const just_permutations_1 = __importDefault(require("just-permutations"));
|
|
43
36
|
const OperationHandlerSetup_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerSetup");
|
|
44
37
|
const OperationHandlerTest_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerTest");
|
|
@@ -57,7 +50,7 @@ class TestControllerHttp {
|
|
|
57
50
|
method: Http_1.HttpMethod.Get,
|
|
58
51
|
execute: () => (request) => {
|
|
59
52
|
const { id } = request.pathParams;
|
|
60
|
-
return
|
|
53
|
+
return T.of({
|
|
61
54
|
body: stream_1.Readable.from(JSON.stringify({
|
|
62
55
|
id: parseInt(id, 10),
|
|
63
56
|
title: 'test',
|
|
@@ -72,7 +65,7 @@ class TestControllerHttp {
|
|
|
72
65
|
method: Http_1.HttpMethod.Get,
|
|
73
66
|
execute: () => (request) => {
|
|
74
67
|
const { ids } = request.queryString;
|
|
75
|
-
return
|
|
68
|
+
return T.of({
|
|
76
69
|
body: stream_1.Readable.from(JSON.stringify({
|
|
77
70
|
id: ids,
|
|
78
71
|
title: 'test',
|
|
@@ -85,7 +78,7 @@ class TestControllerHttp {
|
|
|
85
78
|
{
|
|
86
79
|
path: `/error`,
|
|
87
80
|
method: Http_1.HttpMethod.Get,
|
|
88
|
-
execute: () => (_request) =>
|
|
81
|
+
execute: () => (_request) => T.of({
|
|
89
82
|
body: stream_1.Readable.from(JSON.stringify({
|
|
90
83
|
message: 'Error message',
|
|
91
84
|
})),
|
|
@@ -101,7 +94,7 @@ class TestControllerHttp {
|
|
|
101
94
|
execute: () => (request) => {
|
|
102
95
|
const token = request.headers.authorization;
|
|
103
96
|
if (token === 'Bearer valid') {
|
|
104
|
-
return
|
|
97
|
+
return T.of({
|
|
105
98
|
body: stream_1.Readable.from(JSON.stringify({
|
|
106
99
|
success: true,
|
|
107
100
|
})),
|
|
@@ -118,13 +111,13 @@ class TestControllerHttp {
|
|
|
118
111
|
execute: () => (request) => {
|
|
119
112
|
const { body } = request;
|
|
120
113
|
if (body instanceof stream_1.Readable) {
|
|
121
|
-
return
|
|
114
|
+
return T.of({
|
|
122
115
|
body,
|
|
123
116
|
headers: {},
|
|
124
117
|
statusCode: 200,
|
|
125
118
|
});
|
|
126
119
|
}
|
|
127
|
-
return
|
|
120
|
+
return T.of({
|
|
128
121
|
body: stream_1.Readable.from(JSON.stringify({
|
|
129
122
|
success: false,
|
|
130
123
|
})),
|
|
@@ -138,7 +131,7 @@ class TestControllerHttp {
|
|
|
138
131
|
method: Http_1.HttpMethod.Post,
|
|
139
132
|
execute: () => (request) => {
|
|
140
133
|
const { body } = request;
|
|
141
|
-
return (0,
|
|
134
|
+
return (0, function_1.pipe)(fileStorage.write({
|
|
142
135
|
content: body,
|
|
143
136
|
reference: {
|
|
144
137
|
_tag: 'FileDescriptor',
|
|
@@ -147,22 +140,19 @@ class TestControllerHttp {
|
|
|
147
140
|
name: 'test.ico',
|
|
148
141
|
},
|
|
149
142
|
},
|
|
150
|
-
}),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
statusCode: 200,
|
|
164
|
-
}),
|
|
165
|
-
}));
|
|
143
|
+
}), TE.fold(() => T.of({
|
|
144
|
+
body: stream_1.Readable.from(JSON.stringify({
|
|
145
|
+
success: false,
|
|
146
|
+
})),
|
|
147
|
+
headers: {},
|
|
148
|
+
statusCode: 500,
|
|
149
|
+
}), () => T.of({
|
|
150
|
+
body: stream_1.Readable.from(JSON.stringify({
|
|
151
|
+
success: true,
|
|
152
|
+
})),
|
|
153
|
+
headers: {},
|
|
154
|
+
statusCode: 200,
|
|
155
|
+
})));
|
|
166
156
|
},
|
|
167
157
|
},
|
|
168
158
|
{
|
|
@@ -176,7 +166,7 @@ class TestControllerHttp {
|
|
|
176
166
|
'test-image': expect.any(Object),
|
|
177
167
|
}),
|
|
178
168
|
}));
|
|
179
|
-
return
|
|
169
|
+
return T.of({
|
|
180
170
|
body: stream_1.Readable.from(JSON.stringify({
|
|
181
171
|
success: true,
|
|
182
172
|
})),
|
|
@@ -196,7 +186,7 @@ class TestControllerHttp {
|
|
|
196
186
|
'test-text': expect.any(Object),
|
|
197
187
|
}),
|
|
198
188
|
}));
|
|
199
|
-
return
|
|
189
|
+
return T.of({
|
|
200
190
|
body: stream_1.Readable.from(JSON.stringify({
|
|
201
191
|
success: true,
|
|
202
192
|
})),
|
|
@@ -207,7 +197,7 @@ class TestControllerHttp {
|
|
|
207
197
|
},
|
|
208
198
|
];
|
|
209
199
|
}
|
|
210
|
-
const testHttpController = new ExpressHttpController_1.ExpressHttpController(new TestControllerHttp(), '/tmp',
|
|
200
|
+
const testHttpController = new ExpressHttpController_1.ExpressHttpController(new TestControllerHttp(), '/tmp', O.none);
|
|
211
201
|
function permutativeTest(configMethods, setupMethod, callback) {
|
|
212
202
|
const configMethodPermutations = (0, just_permutations_1.default)(configMethods);
|
|
213
203
|
configMethodPermutations.forEach((configMethodPermutation) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationExecutionTestRunner.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionTestRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,yBAAyB,EACzB,MAAM,sDAAsD,CAAC;
|
|
1
|
+
{"version":3,"file":"OperationExecutionTestRunner.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionTestRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,yBAAyB,EACzB,MAAM,sDAAsD,CAAC;AAM9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,qBAAa,4BAA4B;IACxC,OAAO,CAAC,yBAAyB,CAA4B;gBAEjD,yBAAyB,EAAE,yBAAyB;IAIhE,UAAU,CAAC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,EACtE,gBAAgB,EAAE,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,GACxD,IAAI;CA+BP"}
|
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.OperationExecutionTestRunner = void 0;
|
|
4
|
-
const effect_1 = require("effect");
|
|
5
27
|
const OperationHandlerTest_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerTest");
|
|
28
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
29
|
+
const E = __importStar(require("fp-ts/Either"));
|
|
30
|
+
const function_1 = require("fp-ts/function");
|
|
6
31
|
const OperationExecutionTest_1 = require("./OperationExecutionTest");
|
|
7
32
|
class OperationExecutionTestRunner {
|
|
8
33
|
operationExecutionGateway;
|
|
@@ -10,9 +35,9 @@ class OperationExecutionTestRunner {
|
|
|
10
35
|
this.operationExecutionGateway = operationExecutionGateway;
|
|
11
36
|
}
|
|
12
37
|
runTestFor(handlerReference) {
|
|
13
|
-
const executionE = (0,
|
|
14
|
-
const executionTestE = (0,
|
|
15
|
-
(0,
|
|
38
|
+
const executionE = (0, function_1.pipe)(this.operationExecutionGateway.lookup(handlerReference, true), E.fromOption(() => new Error(`OperationHandler for ${handlerReference.name} not found`)));
|
|
39
|
+
const executionTestE = (0, function_1.pipe)(OperationHandlerTest_1.OperationHandlerTestRegistry.resolve(handlerReference), O.map((handlerTest) => new OperationExecutionTest_1.OperationExecutionTest(handlerTest, this.operationExecutionGateway.operationHandlerInvocationFactory)), E.fromOption(() => new Error(`OperationHandlerTest for ${handlerReference.name} not found`)));
|
|
40
|
+
(0, function_1.pipe)(executionTestE, E.bindTo('executionTest'), E.bind('execution', () => executionE), E.map(({ executionTest, execution }) => executionTest.test(execution)));
|
|
16
41
|
}
|
|
17
42
|
}
|
|
18
43
|
exports.OperationExecutionTestRunner = OperationExecutionTestRunner;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as O from 'fp-ts/Option';
|
|
2
2
|
import { OperationHandlerAuth } from '@trayio/cdk-dsl/connector/operation/OperationHandler';
|
|
3
3
|
import { OperationHandlerValidation } from '@trayio/cdk-dsl/connector/operation/OperationHandlerValidation';
|
|
4
4
|
import { OperationExecution } from './OperationExecution';
|
|
5
5
|
export declare class OperationExecutionValidationFactory {
|
|
6
|
-
decorateExecution<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT>(execution: OperationExecution<AUTH, IN, OUT>, handlerValidationOpt:
|
|
6
|
+
decorateExecution<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT>(execution: OperationExecution<AUTH, IN, OUT>, handlerValidationOpt: O.Option<OperationHandlerValidation<AUTH, IN, OUT>>): OperationExecution<AUTH, IN, OUT>;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=OperationExecutionValidationFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationExecutionValidationFactory.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionValidationFactory.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"OperationExecutionValidationFactory.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionValidationFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sDAAsD,CAAC;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,gEAAgE,CAAC;AAC5G,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,qBAAa,mCAAmC;IAC/C,iBAAiB,CAChB,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG,EAEH,SAAS,EAAE,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,EAC5C,oBAAoB,EAAE,CAAC,CAAC,MAAM,CAAC,0BAA0B,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,GACvE,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;CAUpC"}
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.OperationExecutionValidationFactory = void 0;
|
|
4
|
-
const
|
|
27
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
28
|
+
const function_1 = require("fp-ts/function");
|
|
5
29
|
const OperationExecutionValidation_1 = require("./OperationExecutionValidation");
|
|
6
30
|
class OperationExecutionValidationFactory {
|
|
7
31
|
decorateExecution(execution, handlerValidationOpt) {
|
|
8
|
-
return (0,
|
|
32
|
+
return (0, function_1.pipe)(handlerValidationOpt, O.map((handlerValidation) => new OperationExecutionValidation_1.OperationExecutionValidation(handlerValidation, execution)), O.getOrElse(() => execution));
|
|
9
33
|
}
|
|
10
34
|
}
|
|
11
35
|
exports.OperationExecutionValidationFactory = OperationExecutionValidationFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PollingServiceClient.d.ts","sourceRoot":"","sources":["../../../src/connector/polling/PollingServiceClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EAGN,eAAe,EAEf,MAAM,kDAAkD,CAAC;AAuB1D,MAAM,MAAM,6BAA6B,GAAG;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;;OAKG;IACH,cAAc,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,cAAc,EAAE,OAAO,CAAC;CACxB,CAAC;AAyBF;;;;GAIG;AACH,qBAAa,oBAAoB;IACpB,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEpC,QAAQ,CACb,OAAO,EAAE,6BAA6B,EACtC,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;IAmCV,UAAU,CACf,OAAO,EAAE,+BAA+B,EACxC,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;YAaF,QAAQ;
|
|
1
|
+
{"version":3,"file":"PollingServiceClient.d.ts","sourceRoot":"","sources":["../../../src/connector/polling/PollingServiceClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EAGN,eAAe,EAEf,MAAM,kDAAkD,CAAC;AAuB1D,MAAM,MAAM,6BAA6B,GAAG;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;;OAKG;IACH,cAAc,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,cAAc,EAAE,OAAO,CAAC;CACxB,CAAC;AAyBF;;;;GAIG;AACH,qBAAa,oBAAoB;IACpB,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEpC,QAAQ,CACb,OAAO,EAAE,6BAA6B,EACtC,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;IAmCV,UAAU,CACf,OAAO,EAAE,+BAA+B,EACxC,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;YAaF,QAAQ;CAqCtB"}
|
|
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
26
|
const http = __importStar(require("http"));
|
|
37
27
|
const AxiosHttpClient_1 = require("@trayio/axios/http/AxiosHttpClient");
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.PollingServiceClient = void 0;
|
|
4
|
-
const
|
|
27
|
+
const E = __importStar(require("fp-ts/Either"));
|
|
5
28
|
const BufferExtensions_1 = require("@trayio/commons/buffer/BufferExtensions");
|
|
6
29
|
const Http_1 = require("@trayio/commons/http/Http");
|
|
7
30
|
const PollingTypes_1 = require("@trayio/cdk-dsl/connector/operation/PollingTypes");
|
|
@@ -104,8 +127,8 @@ class PollingServiceClient {
|
|
|
104
127
|
},
|
|
105
128
|
body: BufferExtensions_1.BufferExtensions.bufferToArrayBuffer(bodyBuffer),
|
|
106
129
|
});
|
|
107
|
-
const responseE = await
|
|
108
|
-
if (
|
|
130
|
+
const responseE = await this.httpClient.execute(method, url, request)();
|
|
131
|
+
if (E.isLeft(responseE)) {
|
|
109
132
|
throw responseE.left;
|
|
110
133
|
}
|
|
111
134
|
const response = responseE.right;
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const effect_1 = require("effect");
|
|
4
26
|
const stream_1 = require("stream");
|
|
27
|
+
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
5
28
|
const Http_1 = require("@trayio/commons/http/Http");
|
|
6
29
|
const PollingTypes_1 = require("@trayio/cdk-dsl/connector/operation/PollingTypes");
|
|
7
30
|
const PollingServiceClient_1 = require("./PollingServiceClient");
|
|
@@ -9,24 +32,21 @@ const BASE_URL = 'https://polling.example.test';
|
|
|
9
32
|
const ENDPOINT_PATH = '/triggers/register';
|
|
10
33
|
const ENV_VAR = 'TRAY_POLLING_SERVICE_URL';
|
|
11
34
|
const createMockHttpClient = (capture) => ({
|
|
12
|
-
execute: jest.fn().mockImplementation((method, url, request) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
catch: (reason) => new Error(String(reason)),
|
|
29
|
-
})),
|
|
35
|
+
execute: jest.fn().mockImplementation((method, url, request) => TE.tryCatch(async () => {
|
|
36
|
+
const raw = Buffer.from(request.body).toString('utf8');
|
|
37
|
+
capture.push({
|
|
38
|
+
method,
|
|
39
|
+
url,
|
|
40
|
+
headers: request.headers,
|
|
41
|
+
body: raw.length > 0 ? JSON.parse(raw) : undefined,
|
|
42
|
+
bodyByteLength: Buffer.byteLength(raw, 'utf8'),
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
statusCode: 200,
|
|
46
|
+
headers: {},
|
|
47
|
+
body: stream_1.Readable.from(''),
|
|
48
|
+
};
|
|
49
|
+
}, (reason) => new Error(String(reason)))),
|
|
30
50
|
});
|
|
31
51
|
const minimalRegister = (overrides = {}) => ({
|
|
32
52
|
connectorName: 'x',
|
|
@@ -191,7 +211,7 @@ describe('PollingServiceClient', () => {
|
|
|
191
211
|
});
|
|
192
212
|
it('throws when PS returns a non-2xx status', async () => {
|
|
193
213
|
const errorClient = {
|
|
194
|
-
execute: () =>
|
|
214
|
+
execute: () => TE.right({
|
|
195
215
|
statusCode: 500,
|
|
196
216
|
headers: {},
|
|
197
217
|
body: stream_1.Readable.from(''),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-runtime",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "A Runtime that executes connector operations defined using the CDK DSL",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"node": ">=18.x"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@trayio/axios": "
|
|
18
|
-
"@trayio/cdk-dsl": "
|
|
19
|
-
"@trayio/commons": "
|
|
20
|
-
"@trayio/express": "
|
|
21
|
-
"@trayio/winston": "
|
|
22
|
-
"
|
|
17
|
+
"@trayio/axios": "6.0.0",
|
|
18
|
+
"@trayio/cdk-dsl": "6.0.0",
|
|
19
|
+
"@trayio/commons": "6.0.0",
|
|
20
|
+
"@trayio/express": "6.0.0",
|
|
21
|
+
"@trayio/winston": "6.0.0",
|
|
22
|
+
"fp-ts": "2.12.3",
|
|
23
23
|
"lodash": "4.18.1",
|
|
24
24
|
"mime": "3.0.0",
|
|
25
25
|
"uuid": "9.0.0"
|