@trayio/cdk-runtime 5.33.0 → 5.35.0-unstable.fd7158a
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 +86 -68
- 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 +4 -28
- package/dist/connector/operation/OperationExecutionGateway.unit.test.d.ts.map +1 -1
- package/dist/connector/operation/OperationExecutionGateway.unit.test.js +44 -34
- package/dist/connector/operation/OperationExecutionTestRunner.d.ts.map +1 -1
- package/dist/connector/operation/OperationExecutionTestRunner.js +4 -29
- 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 +2 -26
- package/dist/connector/polling/PollingServiceClient.d.ts.map +1 -1
- package/dist/connector/polling/PollingServiceClient.integration.test.js +17 -7
- package/dist/connector/polling/PollingServiceClient.js +3 -26
- package/dist/connector/polling/PollingServiceClient.unit.test.js +20 -40
- 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,GAC9B,aAAa,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,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isPollingLifecycle = void 0;
|
|
4
|
+
exports.runTriggerPollDedup = runTriggerPollDedup;
|
|
5
|
+
exports.runPollingRegisterOrDeregister = runPollingRegisterOrDeregister;
|
|
4
6
|
const OperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandler");
|
|
5
7
|
const PollingTypes_1 = require("@trayio/cdk-dsl/connector/operation/PollingTypes");
|
|
6
8
|
/**
|
|
@@ -123,7 +125,6 @@ async function runTriggerPollDedup(args) {
|
|
|
123
125
|
return mapCaughtError(error);
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
|
-
exports.runTriggerPollDedup = runTriggerPollDedup;
|
|
127
128
|
function runPollingRegisterOrDeregister(args) {
|
|
128
129
|
const { ctx, handlerType, operationName: registeredHandlerName, pollingInput, pollingServiceClient, } = args;
|
|
129
130
|
switch (handlerType) {
|
|
@@ -160,4 +161,3 @@ function runPollingRegisterOrDeregister(args) {
|
|
|
160
161
|
throw new Error(`polling lifecycle called for non-polling handler type: ${String(handlerType)}`);
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
|
-
exports.runPollingRegisterOrDeregister = runPollingRegisterOrDeregister;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Option } from 'effect';
|
|
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: Option.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":"AAAA,OAAO,EAAkB,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAMtD,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,CAAiD;IAC5E,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,MAAM,CAAC,MAAM,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,EACnE,WAAW,EAAE,oBAAoB;IAW5B,OAAO,CACZ,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAClC,KAAK,EAAE,EAAE,GACP,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAyDvC,OAAO,CAAC,eAAe;IAkCvB,OAAO,CAAC,6BAA6B;IAiCrC,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,oBAAoB;IA4E5B,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,kBAAkB;IAyC1B,OAAO,CAAC,aAAa;IAsDrB,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,eAAe;IA8CvB,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,qBAAqB;CAwC7B"}
|
|
@@ -15,24 +15,30 @@ 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) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
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
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
39
|
exports.HttpOperationExecution = void 0;
|
|
40
|
+
const effect_1 = require("effect");
|
|
30
41
|
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");
|
|
36
42
|
const uuid_1 = require("uuid");
|
|
37
43
|
const querystring = __importStar(require("querystring"));
|
|
38
44
|
const OperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandler");
|
|
@@ -60,24 +66,33 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
60
66
|
this.handlerType = handlerType;
|
|
61
67
|
}
|
|
62
68
|
async execute(ctx, input) {
|
|
63
|
-
const request = (0,
|
|
69
|
+
const request = (0, effect_1.pipe)(this.globalConfiguration, effect_1.Option.match({
|
|
70
|
+
onNone: () => this.handler.request,
|
|
71
|
+
onSome: (globalConfig) => this.decorateRequest(globalConfig, this.handler.request, ctx),
|
|
72
|
+
}));
|
|
64
73
|
const operationRequest = this.handler.requestHandler(ctx, input, request);
|
|
65
|
-
const httpRequestE = await this.operationRequestToHttpRequest(operationRequest)
|
|
66
|
-
if (
|
|
74
|
+
const httpRequestE = await effect_1.Effect.runPromise(effect_1.Effect.either(this.operationRequestToHttpRequest(operationRequest)));
|
|
75
|
+
if (effect_1.Either.isLeft(httpRequestE)) {
|
|
67
76
|
return OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.connectorError(httpRequestE.left.message));
|
|
68
77
|
}
|
|
69
78
|
const resultTE = this.httpClient.execute(operationRequest.method, operationRequest.path, httpRequestE.right);
|
|
70
|
-
const operationResponseTE = (0,
|
|
79
|
+
const operationResponseTE = (0, effect_1.pipe)(resultTE,
|
|
71
80
|
// get the dsl http response object
|
|
72
|
-
|
|
81
|
+
effect_1.Effect.map((response) => this.handler.responseHandler(ctx, input, new HttpOperationHandler_1.HttpOperationResponseBuilder(response, this.defaultErrorHandling(response.statusCode), effect_1.Option.none()))),
|
|
73
82
|
// interpret the dsl response object by mapping the low level http response to a connector response
|
|
74
|
-
|
|
83
|
+
effect_1.Effect.flatMap((operationResponse) => this.parseResponse(operationResponse)),
|
|
75
84
|
// handle errors during the execution of the http request or parsing or the http response
|
|
76
|
-
|
|
77
|
-
return
|
|
85
|
+
effect_1.Effect.mapError((error) => OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.connectorError(error.message))));
|
|
86
|
+
return effect_1.Effect.runPromise(effect_1.Effect.merge(operationResponseTE));
|
|
78
87
|
}
|
|
79
88
|
decorateRequest(globalConfig, operationRequest, ctx) {
|
|
80
|
-
return (0,
|
|
89
|
+
return (0, effect_1.pipe)(globalConfig.baseUrl, effect_1.Option.match({
|
|
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) => {
|
|
81
96
|
if (headers.length === 0) {
|
|
82
97
|
return request;
|
|
83
98
|
}
|
|
@@ -88,7 +103,7 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
88
103
|
}));
|
|
89
104
|
}
|
|
90
105
|
operationRequestToHttpRequest(operationRequest) {
|
|
91
|
-
return (0,
|
|
106
|
+
return (0, effect_1.pipe)(operationRequest.contentType, effect_1.Option.map((contentType) => {
|
|
92
107
|
switch (contentType) {
|
|
93
108
|
case Http_1.HttpContentType.Json:
|
|
94
109
|
return this.serializeAsJson(operationRequest.body);
|
|
@@ -103,39 +118,39 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
103
118
|
default:
|
|
104
119
|
return this.serializeAsJson(operationRequest.body);
|
|
105
120
|
}
|
|
106
|
-
}),
|
|
121
|
+
}), effect_1.Option.getOrElse(() => this.serializeEmptyBody()), effect_1.Effect.map((serializedBody) => ({
|
|
107
122
|
...operationRequest.request,
|
|
108
123
|
body: serializedBody,
|
|
109
124
|
})));
|
|
110
125
|
}
|
|
111
126
|
serializeAsJson(body) {
|
|
112
127
|
const serializedBody = this.jsonSerialization.serialize(body);
|
|
113
|
-
return
|
|
128
|
+
return effect_1.Effect.succeed(BufferExtensions_1.BufferExtensions.arrayBufferToReadable(serializedBody));
|
|
114
129
|
}
|
|
115
130
|
serializeAsFormUrlEncoded(body) {
|
|
116
131
|
const serializedBody = querystring.stringify(body);
|
|
117
|
-
return
|
|
132
|
+
return effect_1.Effect.succeed(BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new TextEncoder().encode(serializedBody)));
|
|
118
133
|
}
|
|
119
134
|
serializeAsText(body) {
|
|
120
135
|
const serializedBody = new TextEncoder().encode(body);
|
|
121
|
-
return
|
|
136
|
+
return effect_1.Effect.succeed(BufferExtensions_1.BufferExtensions.arrayBufferToReadable(serializedBody));
|
|
122
137
|
}
|
|
123
138
|
serializeAsMultipart(body) {
|
|
124
139
|
const fileStreamsFromReferencesTasks = Object.keys(body.files).map((fileKey) => {
|
|
125
140
|
const fileRef = body.files[fileKey];
|
|
126
141
|
if (fileRef.url) {
|
|
127
|
-
return (0,
|
|
142
|
+
return (0, effect_1.pipe)(this.httpClient.execute(Http_1.HttpMethod.Get, fileRef.url, Http_1.HttpRequest.create({
|
|
128
143
|
headers: {},
|
|
129
144
|
pathParams: {},
|
|
130
145
|
queryString: {},
|
|
131
146
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
132
|
-
})),
|
|
147
|
+
})), effect_1.Effect.flatMap((response) => {
|
|
133
148
|
if (response.statusCode >= 300) {
|
|
134
|
-
return
|
|
149
|
+
return effect_1.Effect.fail(Error('error downloading file from source'));
|
|
135
150
|
}
|
|
136
151
|
const parsedSized = Number.parseInt(response.headers.ContentLength ||
|
|
137
152
|
response.headers['content-length'], 10);
|
|
138
|
-
return
|
|
153
|
+
return effect_1.Effect.succeed({
|
|
139
154
|
reference: {
|
|
140
155
|
_tag: 'FileDescriptor',
|
|
141
156
|
key: fileKey,
|
|
@@ -148,7 +163,7 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
148
163
|
});
|
|
149
164
|
}));
|
|
150
165
|
}
|
|
151
|
-
return
|
|
166
|
+
return effect_1.Effect.succeed({
|
|
152
167
|
reference: {
|
|
153
168
|
_tag: 'FileDescriptor',
|
|
154
169
|
key: fileKey,
|
|
@@ -160,11 +175,11 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
160
175
|
content: stream_1.Readable.from(fileRef.content),
|
|
161
176
|
});
|
|
162
177
|
});
|
|
163
|
-
const filesTask =
|
|
164
|
-
return (0,
|
|
178
|
+
const filesTask = effect_1.Effect.all(fileStreamsFromReferencesTasks);
|
|
179
|
+
return (0, effect_1.pipe)(filesTask, effect_1.Effect.map((files) => files.reduce((acc, file) => {
|
|
165
180
|
acc[file.reference.key] = file;
|
|
166
181
|
return acc;
|
|
167
|
-
}, {})),
|
|
182
|
+
}, {})), effect_1.Effect.map((multipartFiles) => ({
|
|
168
183
|
fields: body.fields,
|
|
169
184
|
files: multipartFiles,
|
|
170
185
|
})));
|
|
@@ -176,15 +191,15 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
176
191
|
queryString: {},
|
|
177
192
|
body: BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)),
|
|
178
193
|
}));
|
|
179
|
-
return (0,
|
|
194
|
+
return (0, effect_1.pipe)(downloadFilefromReference, effect_1.Effect.flatMap((response) => {
|
|
180
195
|
if (response.statusCode >= 300) {
|
|
181
|
-
return
|
|
196
|
+
return effect_1.Effect.fail(Error('error downloading file from source'));
|
|
182
197
|
}
|
|
183
|
-
return
|
|
198
|
+
return effect_1.Effect.succeed(response.body);
|
|
184
199
|
}));
|
|
185
200
|
}
|
|
186
201
|
serializeEmptyBody() {
|
|
187
|
-
return
|
|
202
|
+
return effect_1.Effect.succeed(BufferExtensions_1.BufferExtensions.arrayBufferToReadable(new ArrayBuffer(0)));
|
|
188
203
|
}
|
|
189
204
|
defaultErrorHandling(statusCode) {
|
|
190
205
|
return () => OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.apiError(`API returned a status code of ${statusCode}`, {
|
|
@@ -192,43 +207,46 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
192
207
|
}));
|
|
193
208
|
}
|
|
194
209
|
parseErrorResponse(operationResponse) {
|
|
195
|
-
return (0,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
return
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
return
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
return (0, effect_1.pipe)(operationResponse.errorContentType, effect_1.Option.match({
|
|
211
|
+
onNone: () => effect_1.Effect.succeed(undefined),
|
|
212
|
+
onSome: (contentType) => {
|
|
213
|
+
switch (contentType) {
|
|
214
|
+
case Http_1.HttpContentType.Json:
|
|
215
|
+
const bufferTE = BufferExtensions_1.BufferExtensions.readableToArrayBuffer(operationResponse.response.body);
|
|
216
|
+
return (0, effect_1.pipe)(bufferTE, effect_1.Effect.flatMap((buffer) => {
|
|
217
|
+
const deserializedBodyE = this.jsonSerialization.deserialize(buffer);
|
|
218
|
+
return deserializedBodyE;
|
|
219
|
+
}));
|
|
220
|
+
case Http_1.HttpContentType.Text:
|
|
221
|
+
const textBufferTE = BufferExtensions_1.BufferExtensions.readableToArrayBuffer(operationResponse.response.body);
|
|
222
|
+
return (0, effect_1.pipe)(textBufferTE, effect_1.Effect.map((arrayBuffer) => {
|
|
223
|
+
const text = new TextDecoder().decode(arrayBuffer);
|
|
224
|
+
return text || undefined;
|
|
225
|
+
}));
|
|
226
|
+
default:
|
|
227
|
+
return effect_1.Effect.succeed(undefined);
|
|
228
|
+
}
|
|
229
|
+
},
|
|
212
230
|
}));
|
|
213
231
|
}
|
|
214
232
|
parseResponse(operationResponse) {
|
|
215
233
|
if (operationResponse.response.statusCode >= 300) {
|
|
216
|
-
return (0,
|
|
234
|
+
return (0, effect_1.pipe)(this.parseErrorResponse(operationResponse), effect_1.Effect.flatMap((result) => effect_1.Effect.succeed(operationResponse.errorHandling(result))));
|
|
217
235
|
}
|
|
218
|
-
return (0,
|
|
236
|
+
return (0, effect_1.pipe)(operationResponse.contentType, effect_1.Option.map((contentType) => {
|
|
219
237
|
switch (contentType) {
|
|
220
238
|
case Http_1.HttpContentType.Json:
|
|
221
239
|
return this.parseBodyAsJson(operationResponse);
|
|
222
240
|
case Http_1.HttpContentType.OctetStream:
|
|
223
241
|
return this.parseBodyAsFile(operationResponse);
|
|
224
242
|
case Http_1.HttpContentType.MultipartRequestBody:
|
|
225
|
-
return
|
|
243
|
+
return effect_1.Effect.succeed(OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.connectorError(`Invalid Response Type ${contentType}`)));
|
|
226
244
|
case Http_1.HttpContentType.Text:
|
|
227
245
|
return this.parseBodyAsText(operationResponse);
|
|
228
246
|
default:
|
|
229
247
|
return this.parseBodyAsJson(operationResponse);
|
|
230
248
|
}
|
|
231
|
-
}),
|
|
249
|
+
}), effect_1.Option.getOrElse(() => this.parseEmptyBody(operationResponse)), effect_1.Effect.map((parsedResponse) => {
|
|
232
250
|
try {
|
|
233
251
|
this.validateOperationResponse(parsedResponse);
|
|
234
252
|
}
|
|
@@ -243,20 +261,20 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
243
261
|
}
|
|
244
262
|
parseBodyAsJson(operationResponse) {
|
|
245
263
|
const bufferTE = BufferExtensions_1.BufferExtensions.readableToArrayBuffer(operationResponse.response.body);
|
|
246
|
-
return (0,
|
|
264
|
+
return (0, effect_1.pipe)(bufferTE, effect_1.Effect.flatMap((buffer) => {
|
|
247
265
|
const deserializedBodyE = this.jsonSerialization.deserialize(buffer);
|
|
248
|
-
return
|
|
249
|
-
}),
|
|
266
|
+
return deserializedBodyE;
|
|
267
|
+
}), effect_1.Effect.map((deserializedBody) => operationResponse.responseParser(deserializedBody)));
|
|
250
268
|
}
|
|
251
269
|
parseEmptyBody(operationResponse) {
|
|
252
|
-
return
|
|
270
|
+
return effect_1.Effect.succeed(operationResponse.responseParser(undefined));
|
|
253
271
|
}
|
|
254
272
|
parseBodyAsFile(operationResponse) {
|
|
255
273
|
const contentType = (operationResponse.response.headers[Http_1.HttpHeader.ContentType.toLowerCase()]);
|
|
256
274
|
const fileExtension = mime.getExtension(contentType);
|
|
257
275
|
const contentLength = (operationResponse.response.headers[Http_1.HttpHeader.ContentLength.toLowerCase()]);
|
|
258
276
|
const uploadOptions = this.generateUploadOptions(contentLength);
|
|
259
|
-
return (0,
|
|
277
|
+
return (0, effect_1.pipe)(this.fileStorage.write({
|
|
260
278
|
content: operationResponse.response.body,
|
|
261
279
|
reference: {
|
|
262
280
|
_tag: 'FileDescriptor',
|
|
@@ -267,7 +285,7 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
267
285
|
contentType,
|
|
268
286
|
},
|
|
269
287
|
},
|
|
270
|
-
},
|
|
288
|
+
}, effect_1.Option.some(uploadOptions)), effect_1.Effect.flatMap((file) => (0, effect_1.pipe)(this.fileStorage.getSharedUrl(file.reference.key), effect_1.Effect.map((sharedUrl) => operationResponse.responseParser({
|
|
271
289
|
name: file.reference.key,
|
|
272
290
|
url: sharedUrl.url,
|
|
273
291
|
mime_type: file.reference.metadata.contentType ?? '',
|
|
@@ -276,9 +294,9 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
276
294
|
}
|
|
277
295
|
parseBodyAsText(operationResponse) {
|
|
278
296
|
const arrayBufferTE = BufferExtensions_1.BufferExtensions.readableToArrayBuffer(operationResponse.response.body);
|
|
279
|
-
return (0,
|
|
297
|
+
return (0, effect_1.pipe)(arrayBufferTE, effect_1.Effect.flatMap((arrayBuffer) => {
|
|
280
298
|
const deserializeBody = new TextDecoder().decode(arrayBuffer);
|
|
281
|
-
return
|
|
299
|
+
return effect_1.Effect.succeed(operationResponse.responseParser(deserializeBody));
|
|
282
300
|
}));
|
|
283
301
|
}
|
|
284
302
|
// This method is used to respect lambda memory limits as per the old falfel implementation
|
|
@@ -298,7 +316,7 @@ class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
|
298
316
|
const uploadOptions = {
|
|
299
317
|
// 8MB (minimum) * 4 parallel = upto 32MB/s RAM usage
|
|
300
318
|
partSize: targetSize,
|
|
301
|
-
queueSize: 4,
|
|
319
|
+
queueSize: 4, // Ensures at least up to 1/4 of the RAM is utilised
|
|
302
320
|
acl: 'bucket-owner-full-control',
|
|
303
321
|
};
|
|
304
322
|
if (!contentLength) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { OperationHandlerAuth, OperationHandlerType } from '@trayio/cdk-dsl/connector/operation/OperationHandler';
|
|
2
|
+
import { Option } from 'effect';
|
|
2
3
|
import { HttpOperationHandler } from '@trayio/cdk-dsl/connector/operation/HttpOperationHandler';
|
|
3
4
|
import { HttpClient } from '@trayio/commons/http/HttpClient';
|
|
4
5
|
import { FileStorage } from '@trayio/commons/dist/file/File';
|
|
5
6
|
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: Option.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,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,
|
|
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,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,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,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,MAAM,CAAC,MAAM,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,EACnE,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';
|
|
2
1
|
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): Option.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,EACN,oBAAoB,EAEpB,yBAAyB,EAGzB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAEtC,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;IAgC5D,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,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;CAOnD"}
|
|
@@ -1,32 +1,8 @@
|
|
|
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
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.OperationExecutionGateway = void 0;
|
|
27
|
-
const O = __importStar(require("fp-ts/Option"));
|
|
28
|
-
const function_1 = require("fp-ts/function");
|
|
29
4
|
const OperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandler");
|
|
5
|
+
const effect_1 = require("effect");
|
|
30
6
|
const OperationHandlerSetup_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerSetup");
|
|
31
7
|
const OperationExecutionFactory_1 = require("./OperationExecutionFactory");
|
|
32
8
|
class OperationExecutionGateway {
|
|
@@ -34,14 +10,14 @@ class OperationExecutionGateway {
|
|
|
34
10
|
operationHandlerInvocationFactory;
|
|
35
11
|
constructor(httpClient, fileStorage) {
|
|
36
12
|
const operationHandlerInvocationFactory = (ctx) => (handlerReference) => (input) => {
|
|
37
|
-
const result = (0,
|
|
38
|
-
return
|
|
13
|
+
const result = (0, effect_1.pipe)(this.lookup(handlerReference, true), effect_1.Option.map((handlerExecution) => handlerExecution.execute(ctx, input)));
|
|
14
|
+
return effect_1.Option.getOrElse(() => Promise.resolve(OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.connectorError(`Handler for reference ${handlerReference.name} not found`))))(result);
|
|
39
15
|
};
|
|
40
16
|
this.operationHandlerInvocationFactory = operationHandlerInvocationFactory;
|
|
41
17
|
this.executionFactory = new OperationExecutionFactory_1.OperationExecutionFactory(httpClient, fileStorage, operationHandlerInvocationFactory);
|
|
42
18
|
}
|
|
43
19
|
lookup(handlerReference, includePrivate) {
|
|
44
|
-
return (0,
|
|
20
|
+
return (0, effect_1.pipe)(OperationHandlerSetup_1.OperationHandlerRegistry.resolve(handlerReference), effect_1.Option.filter((handler) => includePrivate || !handler.isPrivate), effect_1.Option.map((handler) => this.executionFactory.executionFrom(handler)));
|
|
45
21
|
}
|
|
46
22
|
}
|
|
47
23
|
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":"AAyBA,OAAO,8BAA8B,CAAC"}
|
|
@@ -15,23 +15,30 @@ 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) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
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
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const effect_1 = require("effect");
|
|
29
40
|
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"));
|
|
33
41
|
const querystring = __importStar(require("querystring"));
|
|
34
|
-
const function_1 = require("fp-ts/function");
|
|
35
42
|
const just_permutations_1 = __importDefault(require("just-permutations"));
|
|
36
43
|
const OperationHandlerSetup_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerSetup");
|
|
37
44
|
const OperationHandlerTest_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerTest");
|
|
@@ -50,7 +57,7 @@ class TestControllerHttp {
|
|
|
50
57
|
method: Http_1.HttpMethod.Get,
|
|
51
58
|
execute: () => (request) => {
|
|
52
59
|
const { id } = request.pathParams;
|
|
53
|
-
return
|
|
60
|
+
return effect_1.Effect.succeed({
|
|
54
61
|
body: stream_1.Readable.from(JSON.stringify({
|
|
55
62
|
id: parseInt(id, 10),
|
|
56
63
|
title: 'test',
|
|
@@ -65,7 +72,7 @@ class TestControllerHttp {
|
|
|
65
72
|
method: Http_1.HttpMethod.Get,
|
|
66
73
|
execute: () => (request) => {
|
|
67
74
|
const { ids } = request.queryString;
|
|
68
|
-
return
|
|
75
|
+
return effect_1.Effect.succeed({
|
|
69
76
|
body: stream_1.Readable.from(JSON.stringify({
|
|
70
77
|
id: ids,
|
|
71
78
|
title: 'test',
|
|
@@ -78,7 +85,7 @@ class TestControllerHttp {
|
|
|
78
85
|
{
|
|
79
86
|
path: `/error`,
|
|
80
87
|
method: Http_1.HttpMethod.Get,
|
|
81
|
-
execute: () => (_request) =>
|
|
88
|
+
execute: () => (_request) => effect_1.Effect.succeed({
|
|
82
89
|
body: stream_1.Readable.from(JSON.stringify({
|
|
83
90
|
message: 'Error message',
|
|
84
91
|
})),
|
|
@@ -94,7 +101,7 @@ class TestControllerHttp {
|
|
|
94
101
|
execute: () => (request) => {
|
|
95
102
|
const token = request.headers.authorization;
|
|
96
103
|
if (token === 'Bearer valid') {
|
|
97
|
-
return
|
|
104
|
+
return effect_1.Effect.succeed({
|
|
98
105
|
body: stream_1.Readable.from(JSON.stringify({
|
|
99
106
|
success: true,
|
|
100
107
|
})),
|
|
@@ -111,13 +118,13 @@ class TestControllerHttp {
|
|
|
111
118
|
execute: () => (request) => {
|
|
112
119
|
const { body } = request;
|
|
113
120
|
if (body instanceof stream_1.Readable) {
|
|
114
|
-
return
|
|
121
|
+
return effect_1.Effect.succeed({
|
|
115
122
|
body,
|
|
116
123
|
headers: {},
|
|
117
124
|
statusCode: 200,
|
|
118
125
|
});
|
|
119
126
|
}
|
|
120
|
-
return
|
|
127
|
+
return effect_1.Effect.succeed({
|
|
121
128
|
body: stream_1.Readable.from(JSON.stringify({
|
|
122
129
|
success: false,
|
|
123
130
|
})),
|
|
@@ -131,7 +138,7 @@ class TestControllerHttp {
|
|
|
131
138
|
method: Http_1.HttpMethod.Post,
|
|
132
139
|
execute: () => (request) => {
|
|
133
140
|
const { body } = request;
|
|
134
|
-
return (0,
|
|
141
|
+
return (0, effect_1.pipe)(fileStorage.write({
|
|
135
142
|
content: body,
|
|
136
143
|
reference: {
|
|
137
144
|
_tag: 'FileDescriptor',
|
|
@@ -140,19 +147,22 @@ class TestControllerHttp {
|
|
|
140
147
|
name: 'test.ico',
|
|
141
148
|
},
|
|
142
149
|
},
|
|
143
|
-
}),
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
}), effect_1.Effect.matchEffect({
|
|
151
|
+
onFailure: () => effect_1.Effect.succeed({
|
|
152
|
+
body: stream_1.Readable.from(JSON.stringify({
|
|
153
|
+
success: false,
|
|
154
|
+
})),
|
|
155
|
+
headers: {},
|
|
156
|
+
statusCode: 500,
|
|
157
|
+
}),
|
|
158
|
+
onSuccess: () => effect_1.Effect.succeed({
|
|
159
|
+
body: stream_1.Readable.from(JSON.stringify({
|
|
160
|
+
success: true,
|
|
161
|
+
})),
|
|
162
|
+
headers: {},
|
|
163
|
+
statusCode: 200,
|
|
164
|
+
}),
|
|
165
|
+
}));
|
|
156
166
|
},
|
|
157
167
|
},
|
|
158
168
|
{
|
|
@@ -166,7 +176,7 @@ class TestControllerHttp {
|
|
|
166
176
|
'test-image': expect.any(Object),
|
|
167
177
|
}),
|
|
168
178
|
}));
|
|
169
|
-
return
|
|
179
|
+
return effect_1.Effect.succeed({
|
|
170
180
|
body: stream_1.Readable.from(JSON.stringify({
|
|
171
181
|
success: true,
|
|
172
182
|
})),
|
|
@@ -186,7 +196,7 @@ class TestControllerHttp {
|
|
|
186
196
|
'test-text': expect.any(Object),
|
|
187
197
|
}),
|
|
188
198
|
}));
|
|
189
|
-
return
|
|
199
|
+
return effect_1.Effect.succeed({
|
|
190
200
|
body: stream_1.Readable.from(JSON.stringify({
|
|
191
201
|
success: true,
|
|
192
202
|
})),
|
|
@@ -197,7 +207,7 @@ class TestControllerHttp {
|
|
|
197
207
|
},
|
|
198
208
|
];
|
|
199
209
|
}
|
|
200
|
-
const testHttpController = new ExpressHttpController_1.ExpressHttpController(new TestControllerHttp(), '/tmp',
|
|
210
|
+
const testHttpController = new ExpressHttpController_1.ExpressHttpController(new TestControllerHttp(), '/tmp', effect_1.Option.none());
|
|
201
211
|
function permutativeTest(configMethods, setupMethod, callback) {
|
|
202
212
|
const configMethodPermutations = (0, just_permutations_1.default)(configMethods);
|
|
203
213
|
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;AAI9D,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;CAiCP"}
|
|
@@ -1,33 +1,8 @@
|
|
|
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
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.OperationExecutionTestRunner = void 0;
|
|
4
|
+
const effect_1 = require("effect");
|
|
27
5
|
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");
|
|
31
6
|
const OperationExecutionTest_1 = require("./OperationExecutionTest");
|
|
32
7
|
class OperationExecutionTestRunner {
|
|
33
8
|
operationExecutionGateway;
|
|
@@ -35,9 +10,9 @@ class OperationExecutionTestRunner {
|
|
|
35
10
|
this.operationExecutionGateway = operationExecutionGateway;
|
|
36
11
|
}
|
|
37
12
|
runTestFor(handlerReference) {
|
|
38
|
-
const executionE = (0,
|
|
39
|
-
const executionTestE = (0,
|
|
40
|
-
(0,
|
|
13
|
+
const executionE = (0, effect_1.pipe)(this.operationExecutionGateway.lookup(handlerReference, true), effect_1.Either.fromOption(() => new Error(`OperationHandler for ${handlerReference.name} not found`)));
|
|
14
|
+
const executionTestE = (0, effect_1.pipe)(OperationHandlerTest_1.OperationHandlerTestRegistry.resolve(handlerReference), effect_1.Option.map((handlerTest) => new OperationExecutionTest_1.OperationExecutionTest(handlerTest, this.operationExecutionGateway.operationHandlerInvocationFactory)), effect_1.Either.fromOption(() => new Error(`OperationHandlerTest for ${handlerReference.name} not found`)));
|
|
15
|
+
(0, effect_1.pipe)(executionTestE, effect_1.Either.bindTo('executionTest'), effect_1.Either.bind('execution', () => executionE), effect_1.Either.map(({ executionTest, execution }) => executionTest.test(execution)));
|
|
41
16
|
}
|
|
42
17
|
}
|
|
43
18
|
exports.OperationExecutionTestRunner = OperationExecutionTestRunner;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Option } from 'effect';
|
|
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: Option.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,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AACtC,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,MAAM,CAAC,MAAM,CAClC,0BAA0B,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CACzC,GACC,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;CAUpC"}
|
|
@@ -1,35 +1,11 @@
|
|
|
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
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.OperationExecutionValidationFactory = void 0;
|
|
27
|
-
const
|
|
28
|
-
const function_1 = require("fp-ts/function");
|
|
4
|
+
const effect_1 = require("effect");
|
|
29
5
|
const OperationExecutionValidation_1 = require("./OperationExecutionValidation");
|
|
30
6
|
class OperationExecutionValidationFactory {
|
|
31
7
|
decorateExecution(execution, handlerValidationOpt) {
|
|
32
|
-
return (0,
|
|
8
|
+
return (0, effect_1.pipe)(handlerValidationOpt, effect_1.Option.map((handlerValidation) => new OperationExecutionValidation_1.OperationExecutionValidation(handlerValidation, execution)), effect_1.Option.getOrElse(() => execution));
|
|
33
9
|
}
|
|
34
10
|
}
|
|
35
11
|
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;CAuCtB"}
|
|
@@ -15,13 +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) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
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
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
const http = __importStar(require("http"));
|
|
27
37
|
const AxiosHttpClient_1 = require("@trayio/axios/http/AxiosHttpClient");
|
|
@@ -1,30 +1,7 @@
|
|
|
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
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.PollingServiceClient = void 0;
|
|
27
|
-
const
|
|
4
|
+
const effect_1 = require("effect");
|
|
28
5
|
const BufferExtensions_1 = require("@trayio/commons/buffer/BufferExtensions");
|
|
29
6
|
const Http_1 = require("@trayio/commons/http/Http");
|
|
30
7
|
const PollingTypes_1 = require("@trayio/cdk-dsl/connector/operation/PollingTypes");
|
|
@@ -127,8 +104,8 @@ class PollingServiceClient {
|
|
|
127
104
|
},
|
|
128
105
|
body: BufferExtensions_1.BufferExtensions.bufferToArrayBuffer(bodyBuffer),
|
|
129
106
|
});
|
|
130
|
-
const responseE = await this.httpClient.execute(method, url, request)
|
|
131
|
-
if (
|
|
107
|
+
const responseE = await effect_1.Effect.runPromise(effect_1.Effect.either(this.httpClient.execute(method, url, request)));
|
|
108
|
+
if (effect_1.Either.isLeft(responseE)) {
|
|
132
109
|
throw responseE.left;
|
|
133
110
|
}
|
|
134
111
|
const response = responseE.right;
|
|
@@ -1,30 +1,7 @@
|
|
|
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
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const effect_1 = require("effect");
|
|
26
4
|
const stream_1 = require("stream");
|
|
27
|
-
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
28
5
|
const Http_1 = require("@trayio/commons/http/Http");
|
|
29
6
|
const PollingTypes_1 = require("@trayio/cdk-dsl/connector/operation/PollingTypes");
|
|
30
7
|
const PollingServiceClient_1 = require("./PollingServiceClient");
|
|
@@ -32,21 +9,24 @@ const BASE_URL = 'https://polling.example.test';
|
|
|
32
9
|
const ENDPOINT_PATH = '/triggers/register';
|
|
33
10
|
const ENV_VAR = 'TRAY_POLLING_SERVICE_URL';
|
|
34
11
|
const createMockHttpClient = (capture) => ({
|
|
35
|
-
execute: jest.fn().mockImplementation((method, url, request) =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
12
|
+
execute: jest.fn().mockImplementation((method, url, request) => effect_1.Effect.tryPromise({
|
|
13
|
+
try: async () => {
|
|
14
|
+
const raw = Buffer.from(request.body).toString('utf8');
|
|
15
|
+
capture.push({
|
|
16
|
+
method,
|
|
17
|
+
url,
|
|
18
|
+
headers: request.headers,
|
|
19
|
+
body: raw.length > 0 ? JSON.parse(raw) : undefined,
|
|
20
|
+
bodyByteLength: Buffer.byteLength(raw, 'utf8'),
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
statusCode: 200,
|
|
24
|
+
headers: {},
|
|
25
|
+
body: stream_1.Readable.from(''),
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
catch: (reason) => new Error(String(reason)),
|
|
29
|
+
})),
|
|
50
30
|
});
|
|
51
31
|
const minimalRegister = (overrides = {}) => ({
|
|
52
32
|
connectorName: 'x',
|
|
@@ -211,7 +191,7 @@ describe('PollingServiceClient', () => {
|
|
|
211
191
|
});
|
|
212
192
|
it('throws when PS returns a non-2xx status', async () => {
|
|
213
193
|
const errorClient = {
|
|
214
|
-
execute: () =>
|
|
194
|
+
execute: () => effect_1.Effect.succeed({
|
|
215
195
|
statusCode: 500,
|
|
216
196
|
headers: {},
|
|
217
197
|
body: stream_1.Readable.from(''),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-runtime",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.35.0-unstable.fd7158a",
|
|
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": "5.
|
|
18
|
-
"@trayio/cdk-dsl": "5.
|
|
19
|
-
"@trayio/commons": "5.
|
|
20
|
-
"@trayio/express": "5.
|
|
21
|
-
"@trayio/winston": "5.
|
|
22
|
-
"
|
|
17
|
+
"@trayio/axios": "5.35.0-unstable.fd7158a",
|
|
18
|
+
"@trayio/cdk-dsl": "5.35.0-unstable.fd7158a",
|
|
19
|
+
"@trayio/commons": "5.35.0-unstable.fd7158a",
|
|
20
|
+
"@trayio/express": "5.35.0-unstable.fd7158a",
|
|
21
|
+
"@trayio/winston": "5.35.0-unstable.fd7158a",
|
|
22
|
+
"effect": "3.22.2",
|
|
23
23
|
"lodash": "4.18.1",
|
|
24
24
|
"mime": "3.0.0",
|
|
25
25
|
"uuid": "9.0.0"
|