@trayio/cdk-runtime 0.0.5 → 0.0.6
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/CompositeOperationExecution.d.ts +11 -0
- package/dist/connector/operation/CompositeOperationExecution.d.ts.map +1 -0
- package/dist/connector/operation/CompositeOperationExecution.js +25 -0
- package/dist/connector/operation/CompositeOperationExecutionFactory.d.ts +9 -0
- package/dist/connector/operation/CompositeOperationExecutionFactory.d.ts.map +1 -0
- package/dist/connector/operation/CompositeOperationExecutionFactory.js +13 -0
- package/dist/connector/operation/HttpOperationExecution.d.ts +11 -0
- package/dist/connector/operation/HttpOperationExecution.d.ts.map +1 -0
- package/dist/connector/operation/HttpOperationExecution.js +34 -0
- package/dist/connector/operation/HttpOperationExecutionFactory.d.ts +9 -0
- package/dist/connector/operation/HttpOperationExecutionFactory.d.ts.map +1 -0
- package/dist/connector/operation/HttpOperationExecutionFactory.js +13 -0
- package/dist/connector/operation/OperationExecution.d.ts +5 -0
- package/dist/connector/operation/OperationExecution.d.ts.map +1 -0
- package/dist/connector/operation/OperationExecution.js +2 -0
- package/dist/connector/operation/OperationExecutionFactory.d.ts +11 -0
- package/dist/connector/operation/OperationExecutionFactory.d.ts.map +1 -0
- package/dist/connector/operation/OperationExecutionFactory.js +23 -0
- package/dist/connector/operation/OperationExecutionGateway.d.ts +12 -0
- package/dist/connector/operation/OperationExecutionGateway.d.ts.map +1 -0
- package/dist/connector/operation/OperationExecutionGateway.js +45 -0
- package/dist/connector/operation/OperationExecutionGateway.test.d.ts +2 -0
- package/dist/connector/operation/OperationExecutionGateway.test.d.ts.map +1 -0
- package/dist/connector/operation/OperationExecutionGateway.test.js +30 -0
- package/dist/connector/operation/OperationExecutionTest.d.ts +10 -0
- package/dist/connector/operation/OperationExecutionTest.d.ts.map +1 -0
- package/dist/connector/operation/OperationExecutionTest.js +75 -0
- package/dist/connector/operation/OperationExecutionTestRunner.d.ts +8 -0
- package/dist/connector/operation/OperationExecutionTestRunner.d.ts.map +1 -0
- package/dist/connector/operation/OperationExecutionTestRunner.js +42 -0
- package/dist/connector/operation/OperationHandlerInvocationFactory.d.ts +3 -0
- package/dist/connector/operation/OperationHandlerInvocationFactory.d.ts.map +1 -0
- package/dist/connector/operation/OperationHandlerInvocationFactory.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OperationHandlerResult } from '@trayio/cdk-dsl/connector/operation/OperationHandlerResult';
|
|
2
|
+
import { CompositeOperationHandler } from '@trayio/cdk-dsl/connector/operation/CompositeOperationHandler';
|
|
3
|
+
import { OperationExecution } from './OperationExecution';
|
|
4
|
+
import { OperationHandlerInvocationFactory } from './OperationHandlerInvocationFactory';
|
|
5
|
+
export declare class CompositeOperationExecution<AUTH, IN, OUT> implements OperationExecution<AUTH, IN, OUT> {
|
|
6
|
+
private handlerInvocationFactory;
|
|
7
|
+
private handler;
|
|
8
|
+
constructor(handlerInvocationFactory: OperationHandlerInvocationFactory, handler: CompositeOperationHandler<AUTH, IN, OUT>);
|
|
9
|
+
execute(auth: AUTH, input: IN): Promise<OperationHandlerResult<OUT>>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=CompositeOperationExecution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompositeOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/CompositeOperationExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAC;AACpG,OAAO,EAAE,yBAAyB,EAAE,MAAM,+DAA+D,CAAC;AAC1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,qBAAa,2BAA2B,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CACrD,YAAW,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAE5C,OAAO,CAAC,wBAAwB,CAAoC;IACpE,OAAO,CAAC,OAAO,CAA2C;gBAGzD,wBAAwB,EAAE,iCAAiC,EAC3D,OAAO,EAAE,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAM5C,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;CAI1E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CompositeOperationExecution = void 0;
|
|
13
|
+
class CompositeOperationExecution {
|
|
14
|
+
constructor(handlerInvocationFactory, handler) {
|
|
15
|
+
this.handlerInvocationFactory = handlerInvocationFactory;
|
|
16
|
+
this.handler = handler;
|
|
17
|
+
}
|
|
18
|
+
execute(auth, input) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const handlerInvocation = this.handlerInvocationFactory(auth);
|
|
21
|
+
return this.handler.handlerFunction(auth, input, handlerInvocation);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.CompositeOperationExecution = CompositeOperationExecution;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CompositeOperationHandler } from '@trayio/cdk-dsl/connector/operation/CompositeOperationHandler';
|
|
2
|
+
import { OperationExecution } from './OperationExecution';
|
|
3
|
+
import { OperationHandlerInvocationFactory } from './OperationHandlerInvocationFactory';
|
|
4
|
+
export declare class CompositeOperationExecutionFactory {
|
|
5
|
+
private handlerInvocationFactory;
|
|
6
|
+
constructor(handlerInvocationFactory: OperationHandlerInvocationFactory);
|
|
7
|
+
executionFrom<AUTH, IN, OUT>(handler: CompositeOperationHandler<AUTH, IN, OUT>): OperationExecution<AUTH, IN, OUT>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=CompositeOperationExecutionFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompositeOperationExecutionFactory.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/CompositeOperationExecutionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+DAA+D,CAAC;AAC1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,qBAAa,kCAAkC;IAC9C,OAAO,CAAC,wBAAwB,CAAoC;gBAExD,wBAAwB,EAAE,iCAAiC;IAIvE,aAAa,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EAC1B,OAAO,EAAE,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,GAC/C,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;CAMpC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompositeOperationExecutionFactory = void 0;
|
|
4
|
+
const CompositeOperationExecution_1 = require("./CompositeOperationExecution");
|
|
5
|
+
class CompositeOperationExecutionFactory {
|
|
6
|
+
constructor(handlerInvocationFactory) {
|
|
7
|
+
this.handlerInvocationFactory = handlerInvocationFactory;
|
|
8
|
+
}
|
|
9
|
+
executionFrom(handler) {
|
|
10
|
+
return new CompositeOperationExecution_1.CompositeOperationExecution(this.handlerInvocationFactory, handler);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.CompositeOperationExecutionFactory = CompositeOperationExecutionFactory;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OperationHandlerResult } from '@trayio/cdk-dsl/connector/operation/OperationHandlerResult';
|
|
2
|
+
import { HttpOperationHandler } from '@trayio/cdk-dsl/connector/operation/HttpOperationHandler';
|
|
3
|
+
import { HttpClient } from '@trayio/tray-commons/http/HttpClient';
|
|
4
|
+
import { OperationExecution } from './OperationExecution';
|
|
5
|
+
export declare class HttpOperationExecution<AUTH, IN, OUT> implements OperationExecution<AUTH, IN, OUT> {
|
|
6
|
+
private httpClient;
|
|
7
|
+
private handler;
|
|
8
|
+
constructor(httpClient: HttpClient, handler: HttpOperationHandler<AUTH, IN, OUT>);
|
|
9
|
+
execute(auth: AUTH, input: IN): Promise<OperationHandlerResult<OUT>>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=HttpOperationExecution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EAGtB,MAAM,4DAA4D,CAAC;AACpE,OAAO,EACN,oBAAoB,EAEpB,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,sBAAsB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAChD,YAAW,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAE5C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,OAAO,CAAsC;gBAGpD,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAMvC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;CAoB1E"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.HttpOperationExecution = void 0;
|
|
13
|
+
const OperationHandlerResult_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerResult");
|
|
14
|
+
const HttpOperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/HttpOperationHandler");
|
|
15
|
+
class HttpOperationExecution {
|
|
16
|
+
constructor(httpClient, handler) {
|
|
17
|
+
this.httpClient = httpClient;
|
|
18
|
+
this.handler = handler;
|
|
19
|
+
}
|
|
20
|
+
execute(auth, input) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const finalRequest = this.handler.requestHandler(auth, input, this.handler.request);
|
|
23
|
+
const resultE = yield this.httpClient.execute(finalRequest.method, finalRequest.path, finalRequest.request)();
|
|
24
|
+
const result = OperationHandlerResult_1.OperationHandlerResultInternal.fromEitherWithSimpleError(resultE);
|
|
25
|
+
if (result.isFailure) {
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
const successResult = result;
|
|
29
|
+
const response = new HttpOperationHandler_1.HttpOperationResponse(successResult.value);
|
|
30
|
+
return this.handler.responseHandler(response);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.HttpOperationExecution = HttpOperationExecution;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HttpOperationHandler } from '@trayio/cdk-dsl/connector/operation/HttpOperationHandler';
|
|
2
|
+
import { HttpClient } from '@trayio/tray-commons/http/HttpClient';
|
|
3
|
+
import { OperationExecution } from './OperationExecution';
|
|
4
|
+
export declare class HttpOperationExecutionFactory {
|
|
5
|
+
private httpClient;
|
|
6
|
+
constructor(httpClient: HttpClient);
|
|
7
|
+
executionFrom<AUTH, IN, OUT>(handler: HttpOperationHandler<AUTH, IN, OUT>): OperationExecution<AUTH, IN, OUT>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=HttpOperationExecutionFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpOperationExecutionFactory.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationExecutionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,qBAAa,6BAA6B;IACzC,OAAO,CAAC,UAAU,CAAa;gBAEnB,UAAU,EAAE,UAAU;IAIlC,aAAa,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EAC1B,OAAO,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,GAC1C,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;CAGpC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpOperationExecutionFactory = void 0;
|
|
4
|
+
const HttpOperationExecution_1 = require("./HttpOperationExecution");
|
|
5
|
+
class HttpOperationExecutionFactory {
|
|
6
|
+
constructor(httpClient) {
|
|
7
|
+
this.httpClient = httpClient;
|
|
8
|
+
}
|
|
9
|
+
executionFrom(handler) {
|
|
10
|
+
return new HttpOperationExecution_1.HttpOperationExecution(this.httpClient, handler);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.HttpOperationExecutionFactory = HttpOperationExecutionFactory;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { OperationHandlerResult } from '@trayio/cdk-dsl/connector/operation/OperationHandlerResult';
|
|
2
|
+
export interface OperationExecution<AUTH, IN, OUT> {
|
|
3
|
+
execute(auth: AUTH, input: IN): Promise<OperationHandlerResult<OUT>>;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=OperationExecution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAC;AAEpG,MAAM,WAAW,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG;IAChD,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC;CACrE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OperationHandler } from '@trayio/cdk-dsl/connector/operation/OperationHandler';
|
|
2
|
+
import { HttpClient } from '@trayio/tray-commons/http/HttpClient';
|
|
3
|
+
import { OperationExecution } from './OperationExecution';
|
|
4
|
+
import { OperationHandlerInvocationFactory } from './OperationHandlerInvocationFactory';
|
|
5
|
+
export declare class OperationExecutionFactory {
|
|
6
|
+
private httpOperationExecutionFactory;
|
|
7
|
+
private compositeOperationExecutionFactory;
|
|
8
|
+
constructor(httpClient: HttpClient, operationHandlerInvocationFactory: OperationHandlerInvocationFactory);
|
|
9
|
+
executionFrom<AUTH, IN, OUT>(handler: OperationHandler<AUTH, IN, OUT>): OperationExecution<AUTH, IN, OUT>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=OperationExecutionFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationExecutionFactory.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sDAAsD,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,qBAAa,yBAAyB;IACrC,OAAO,CAAC,6BAA6B,CAAgC;IACrE,OAAO,CAAC,kCAAkC,CAAqC;gBAG9E,UAAU,EAAE,UAAU,EACtB,iCAAiC,EAAE,iCAAiC;IASrE,aAAa,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EAC1B,OAAO,EAAE,gBAAgB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,GACtC,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;CAgBpC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationExecutionFactory = void 0;
|
|
4
|
+
const HttpOperationExecutionFactory_1 = require("./HttpOperationExecutionFactory");
|
|
5
|
+
const CompositeOperationExecutionFactory_1 = require("./CompositeOperationExecutionFactory");
|
|
6
|
+
class OperationExecutionFactory {
|
|
7
|
+
constructor(httpClient, operationHandlerInvocationFactory) {
|
|
8
|
+
this.httpOperationExecutionFactory = new HttpOperationExecutionFactory_1.HttpOperationExecutionFactory(httpClient);
|
|
9
|
+
this.compositeOperationExecutionFactory =
|
|
10
|
+
new CompositeOperationExecutionFactory_1.CompositeOperationExecutionFactory(operationHandlerInvocationFactory);
|
|
11
|
+
}
|
|
12
|
+
executionFrom(handler) {
|
|
13
|
+
// TODO add validation and execution decorations
|
|
14
|
+
const { implementation } = handler;
|
|
15
|
+
switch (implementation._tag) {
|
|
16
|
+
case 'HttpOperationHandler':
|
|
17
|
+
return this.httpOperationExecutionFactory.executionFrom(implementation);
|
|
18
|
+
case 'CompositeOperationHandler':
|
|
19
|
+
return this.compositeOperationExecutionFactory.executionFrom(implementation);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.OperationExecutionFactory = OperationExecutionFactory;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OperationHandlerReference } from '@trayio/cdk-dsl/connector/operation/OperationHandlerReference';
|
|
2
|
+
import { HttpClient } from '@trayio/tray-commons/http/HttpClient';
|
|
3
|
+
import * as O from 'fp-ts/Option';
|
|
4
|
+
import { OperationHandlerInvocationFactory } from './OperationHandlerInvocationFactory';
|
|
5
|
+
import { OperationExecution } from './OperationExecution';
|
|
6
|
+
export declare class OperationExecutionGateway {
|
|
7
|
+
private executionFactory;
|
|
8
|
+
operationHandlerInvocationFactory: OperationHandlerInvocationFactory;
|
|
9
|
+
constructor(httpClient: HttpClient);
|
|
10
|
+
lookup<AUTH, IN, OUT>(handlerReference: OperationHandlerReference<AUTH, IN, OUT>, includePrivate: boolean): O.Option<OperationExecution<AUTH, IN, OUT>>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=OperationExecutionGateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationExecutionGateway.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionGateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+DAA+D,CAAC;AAE1G,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,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;IAyBlC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EACnB,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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.OperationExecutionGateway = void 0;
|
|
27
|
+
const OperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandler");
|
|
28
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
29
|
+
const function_1 = require("fp-ts/function");
|
|
30
|
+
const OperationHandlerResult_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerResult");
|
|
31
|
+
const OperationExecutionFactory_1 = require("./OperationExecutionFactory");
|
|
32
|
+
class OperationExecutionGateway {
|
|
33
|
+
constructor(httpClient) {
|
|
34
|
+
const operationHandlerInvocationFactory = (auth) => (handlerReference) => (input) => {
|
|
35
|
+
const result = (0, function_1.pipe)(this.lookup(handlerReference, true), O.map((handlerExecution) => handlerExecution.execute(auth, input)));
|
|
36
|
+
return O.getOrElse(() => Promise.resolve(OperationHandlerResult_1.OperationHandlerResult.failure(`Handler for reference ${handlerReference.name} not found`)))(result);
|
|
37
|
+
};
|
|
38
|
+
this.operationHandlerInvocationFactory = operationHandlerInvocationFactory;
|
|
39
|
+
this.executionFactory = new OperationExecutionFactory_1.OperationExecutionFactory(httpClient, operationHandlerInvocationFactory);
|
|
40
|
+
}
|
|
41
|
+
lookup(handlerReference, includePrivate) {
|
|
42
|
+
return (0, function_1.pipe)(OperationHandler_1.OperationHandlerRegistry.resolve(handlerReference), O.filter((handler) => includePrivate || !handler.isPrivate), O.map((handler) => this.executionFactory.executionFrom(handler)));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.OperationExecutionGateway = OperationExecutionGateway;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationExecutionGateway.test.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionGateway.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const OperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandler");
|
|
4
|
+
const OperationHandlerTest_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerTest");
|
|
5
|
+
const AxiosHttpClient_1 = require("@trayio/tray-axios/http/AxiosHttpClient");
|
|
6
|
+
const OperationExecutionGateway_1 = require("./OperationExecutionGateway");
|
|
7
|
+
const OperationExecutionTestRunner_1 = require("./OperationExecutionTestRunner");
|
|
8
|
+
const getProductOperation = OperationHandler_1.OperationHandlerSetup.configureHandler('get-product', (handler) => handler.usingHttp((http) => http
|
|
9
|
+
.get('https://fakestoreapi.com/products/:id')
|
|
10
|
+
.handleRequest((auth, input, request) => request.addPathParameter('id', input.id.toString()))
|
|
11
|
+
.handleResponse((response) => response.withBodyAsJson())));
|
|
12
|
+
OperationHandlerTest_1.OperationHandlerTestSetup.configureHandlerTest(getProductOperation, (handlerTest) => handlerTest
|
|
13
|
+
.usingAuth({})
|
|
14
|
+
.nothingBeforeAll()
|
|
15
|
+
.testCase('should get a product', (testCase) => testCase
|
|
16
|
+
.givenNoContext()
|
|
17
|
+
.when(() => ({ id: 2 }))
|
|
18
|
+
.then(({ output }) => {
|
|
19
|
+
switch (output.isSuccess) {
|
|
20
|
+
case false:
|
|
21
|
+
fail(`Error getting the product ${output.error}`);
|
|
22
|
+
case true:
|
|
23
|
+
expect(output.value.id).toEqual(2);
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
.finallyDoNothing())
|
|
27
|
+
.nothingAfterAll());
|
|
28
|
+
const executionGateway = new OperationExecutionGateway_1.OperationExecutionGateway(new AxiosHttpClient_1.AxiosHttpClient());
|
|
29
|
+
const testRunner = new OperationExecutionTestRunner_1.OperationExecutionTestRunner(executionGateway);
|
|
30
|
+
testRunner.runTestFor(getProductOperation);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OperationHandlerTest } from '@trayio/cdk-dsl/connector/operation/OperationHandlerTest';
|
|
2
|
+
import { OperationExecution } from './OperationExecution';
|
|
3
|
+
import { OperationHandlerInvocationFactory } from './OperationHandlerInvocationFactory';
|
|
4
|
+
export declare class OperationExecutionTest<AUTH, IN, OUT> {
|
|
5
|
+
private handlerTest;
|
|
6
|
+
private handlerInvocationFactory;
|
|
7
|
+
constructor(handlerTest: OperationHandlerTest<AUTH, IN, OUT, unknown>, handlerInvocationFactory: OperationHandlerInvocationFactory);
|
|
8
|
+
test(execution: OperationExecution<AUTH, IN, OUT>): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=OperationExecutionTest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationExecutionTest.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAQxF,qBAAa,sBAAsB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG;IAChD,OAAO,CAAC,WAAW,CAA+C;IAClE,OAAO,CAAC,wBAAwB,CAAoC;gBAGnE,WAAW,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,EACzD,wBAAwB,EAAE,iCAAiC;IAM5D,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,GAAG,IAAI;CAiFxD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OperationExecutionTest = void 0;
|
|
13
|
+
// TODO move this to tray-typescript-modules, newer versions of jest removed the "fail" method but left it in the types package.
|
|
14
|
+
function fail(reason) {
|
|
15
|
+
throw new Error(reason);
|
|
16
|
+
}
|
|
17
|
+
global.fail = fail;
|
|
18
|
+
class OperationExecutionTest {
|
|
19
|
+
constructor(handlerTest, handlerInvocationFactory) {
|
|
20
|
+
this.handlerTest = handlerTest;
|
|
21
|
+
this.handlerInvocationFactory = handlerInvocationFactory;
|
|
22
|
+
}
|
|
23
|
+
test(execution) {
|
|
24
|
+
describe(`Operation ${this.handlerTest.handlerReference.name} Test`, () => {
|
|
25
|
+
const defaultAuth = this.handlerTest.auth;
|
|
26
|
+
const defaultInvoke = this.handlerInvocationFactory(defaultAuth);
|
|
27
|
+
let testContext;
|
|
28
|
+
beforeAll(() => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const beforeAllResult = yield this.handlerTest.beforeAllFunction(defaultAuth, defaultInvoke);
|
|
30
|
+
switch (beforeAllResult.isSuccess) {
|
|
31
|
+
case false:
|
|
32
|
+
fail(`BeforeAll has failed with the following error ${beforeAllResult.error}`);
|
|
33
|
+
case true:
|
|
34
|
+
testContext = beforeAllResult.value;
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
this.handlerTest.testCaseFactories.forEach((testCaseFactory) => {
|
|
38
|
+
it(testCaseFactory.description, () => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const testCase = testCaseFactory.testCase(testContext);
|
|
40
|
+
const { auth } = testCase;
|
|
41
|
+
const invoke = this.handlerInvocationFactory(auth);
|
|
42
|
+
const givenResult = yield testCase.givenFunction(auth, testContext, invoke);
|
|
43
|
+
let testCaseContext;
|
|
44
|
+
switch (givenResult.isSuccess) {
|
|
45
|
+
case false:
|
|
46
|
+
fail(`Given has failed with the following error ${givenResult.error}`);
|
|
47
|
+
case true:
|
|
48
|
+
testCaseContext = givenResult.value;
|
|
49
|
+
}
|
|
50
|
+
const input = testCase.whenFunction(auth, testContext, testCaseContext);
|
|
51
|
+
const output = yield execution.execute(auth, input);
|
|
52
|
+
const testCaseResult = {
|
|
53
|
+
auth,
|
|
54
|
+
testContext,
|
|
55
|
+
testCaseContext,
|
|
56
|
+
input,
|
|
57
|
+
output,
|
|
58
|
+
};
|
|
59
|
+
testCase.thenFunction(testCaseResult);
|
|
60
|
+
const finallyResult = yield testCase.finallyFunction(testCaseResult, invoke);
|
|
61
|
+
if (finallyResult.isFailure) {
|
|
62
|
+
fail(`Finally has failed with the following error ${finallyResult.error}`);
|
|
63
|
+
}
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
afterAll(() => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const afterAllResult = yield this.handlerTest.afterAllFunction(defaultAuth, testContext, defaultInvoke);
|
|
68
|
+
if (afterAllResult.isFailure) {
|
|
69
|
+
fail(`AfterAll has failed with the following error ${afterAllResult.error}`);
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.OperationExecutionTest = OperationExecutionTest;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OperationHandlerReference } from '@trayio/cdk-dsl/connector/operation/OperationHandlerReference';
|
|
2
|
+
import { OperationExecutionGateway } from './OperationExecutionGateway';
|
|
3
|
+
export declare class OperationExecutionTestRunner {
|
|
4
|
+
private operationExecutionGateway;
|
|
5
|
+
constructor(operationExecutionGateway: OperationExecutionGateway);
|
|
6
|
+
runTestFor<AUTH, IN, OUT>(handlerReference: OperationHandlerReference<AUTH, IN, OUT>): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=OperationExecutionTestRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationExecutionTestRunner.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationExecutionTestRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+DAA+D,CAAC;AAM1G,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,qBAAa,4BAA4B;IACxC,OAAO,CAAC,yBAAyB,CAA4B;gBAEjD,yBAAyB,EAAE,yBAAyB;IAIhE,UAAU,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EACvB,gBAAgB,EAAE,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,GACxD,IAAI;CA+BP"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.OperationExecutionTestRunner = void 0;
|
|
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");
|
|
31
|
+
const OperationExecutionTest_1 = require("./OperationExecutionTest");
|
|
32
|
+
class OperationExecutionTestRunner {
|
|
33
|
+
constructor(operationExecutionGateway) {
|
|
34
|
+
this.operationExecutionGateway = operationExecutionGateway;
|
|
35
|
+
}
|
|
36
|
+
runTestFor(handlerReference) {
|
|
37
|
+
const executionE = (0, function_1.pipe)(this.operationExecutionGateway.lookup(handlerReference, true), E.fromOption(() => new Error(`OperationHandler for ${handlerReference.name} not found`)));
|
|
38
|
+
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`)));
|
|
39
|
+
(0, function_1.pipe)(executionTestE, E.bindTo('executionTest'), E.bind('execution', () => executionE), E.map(({ executionTest, execution }) => executionTest.test(execution)));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.OperationExecutionTestRunner = OperationExecutionTestRunner;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { OperationHandlerInvocation } from '@trayio/cdk-dsl/connector/operation/OperationHandlerInvocation';
|
|
2
|
+
export type OperationHandlerInvocationFactory = <AUTH>(auth: AUTH) => OperationHandlerInvocation<AUTH>;
|
|
3
|
+
//# sourceMappingURL=OperationHandlerInvocationFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationHandlerInvocationFactory.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandlerInvocationFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gEAAgE,CAAC;AAE5G,MAAM,MAAM,iCAAiC,GAAG,CAAC,IAAI,EACpD,IAAI,EAAE,IAAI,KACN,0BAA0B,CAAC,IAAI,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-runtime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "CDK Runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"author": "Tray.io",
|
|
9
9
|
"license": "Proprietary",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@trayio/cdk-dsl": "0.0.
|
|
11
|
+
"@trayio/cdk-dsl": "0.0.6",
|
|
12
12
|
"@trayio/tray-axios": "*"
|
|
13
13
|
},
|
|
14
14
|
"typesVersions": {
|