@trayio/cdk-runtime 4.16.3 → 4.17.1
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/AbstractOperationExecution.d.ts +8 -0
- package/dist/connector/operation/AbstractOperationExecution.d.ts.map +1 -0
- package/dist/connector/operation/AbstractOperationExecution.js +37 -0
- package/dist/connector/operation/CompositeOperationExecution.d.ts +2 -2
- package/dist/connector/operation/CompositeOperationExecution.d.ts.map +1 -1
- package/dist/connector/operation/CompositeOperationExecution.js +7 -1
- 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 +18 -2
- package/dist/connector/operation/OperationExecutionGateway.unit.test.d.ts.map +1 -1
- package/dist/connector/operation/OperationExecutionGateway.unit.test.js +96 -2
- package/package.json +5 -5
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OperationHandlerAuth, OperationHandlerContext, OperationHandlerResult, OperationHandlerType } from '@trayio/cdk-dsl/connector/operation/OperationHandler';
|
|
2
|
+
import { OperationExecution } from './OperationExecution';
|
|
3
|
+
export default abstract class AbstractOperationExecution<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> implements OperationExecution<AUTH, IN, OUT> {
|
|
4
|
+
abstract handlerType: OperationHandlerType;
|
|
5
|
+
abstract execute(ctx: OperationHandlerContext<AUTH>, input: IN): Promise<OperationHandlerResult<OUT>>;
|
|
6
|
+
protected validateOperationResponse<T>(operationResult: OperationHandlerResult<T>): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=AbstractOperationExecution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/AbstractOperationExecution.ts"],"names":[],"mappings":"AASA,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,sDAAsD,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAyB1D,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,0BAA0B,CACvD,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG,CACF,YAAW,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC;IAE7C,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAE3C,QAAQ,CAAC,OAAO,CACf,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAClC,KAAK,EAAE,EAAE,GACP,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAEvC,SAAS,CAAC,yBAAyB,CAAC,CAAC,EACpC,eAAe,EAAE,sBAAsB,CAAC,CAAC,CAAC;CAe3C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const lodash_1 = require("lodash");
|
|
4
|
+
function getType(target) {
|
|
5
|
+
if ((0, lodash_1.isString)(target)) {
|
|
6
|
+
return 'string';
|
|
7
|
+
}
|
|
8
|
+
if ((0, lodash_1.isNumber)(target)) {
|
|
9
|
+
return 'number';
|
|
10
|
+
}
|
|
11
|
+
if ((0, lodash_1.isBoolean)(target)) {
|
|
12
|
+
return 'boolean';
|
|
13
|
+
}
|
|
14
|
+
if ((0, lodash_1.isNull)(target)) {
|
|
15
|
+
return 'null';
|
|
16
|
+
}
|
|
17
|
+
if ((0, lodash_1.isPlainObject)(target)) {
|
|
18
|
+
return 'object';
|
|
19
|
+
}
|
|
20
|
+
if ((0, lodash_1.isArray)(target)) {
|
|
21
|
+
return 'array';
|
|
22
|
+
}
|
|
23
|
+
return 'non-object';
|
|
24
|
+
}
|
|
25
|
+
class AbstractOperationExecution {
|
|
26
|
+
validateOperationResponse(operationResult) {
|
|
27
|
+
if (operationResult.isSuccess) {
|
|
28
|
+
if (!(0, lodash_1.isPlainObject)(operationResult.value)) {
|
|
29
|
+
const errorMessage = process.env.NODE_ENV === 'test'
|
|
30
|
+
? `Invalid operation response; operations must always return an object. Received ${getType(operationResult.value)}. Wrap non-objects into an object.`
|
|
31
|
+
: 'Invalid operation response. Please contact support.';
|
|
32
|
+
throw new Error(errorMessage);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.default = AbstractOperationExecution;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OperationHandlerAuth, OperationHandlerContext, OperationHandlerResult, OperationHandlerType } from '@trayio/cdk-dsl/connector/operation/OperationHandler';
|
|
2
2
|
import { CompositeOperationHandler } from '@trayio/cdk-dsl/connector/operation/CompositeOperationHandler';
|
|
3
|
-
import
|
|
3
|
+
import AbstractOperationExecution from './AbstractOperationExecution';
|
|
4
4
|
import { OperationHandlerInvocationFactory } from './OperationHandlerInvocationFactory';
|
|
5
|
-
export declare class CompositeOperationExecution<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT>
|
|
5
|
+
export declare class CompositeOperationExecution<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> extends AbstractOperationExecution<AUTH, IN, OUT> {
|
|
6
6
|
private handlerInvocationFactory;
|
|
7
7
|
private handler;
|
|
8
8
|
handlerType: OperationHandlerType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/CompositeOperationExecution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CompositeOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/CompositeOperationExecution.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EAEtB,oBAAoB,EACpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+DAA+D,CAAC;AAE1G,OAAO,0BAA0B,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,qBAAa,2BAA2B,CACvC,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,wBAAwB,CAAoC;IACpE,OAAO,CAAC,OAAO,CAA2C;IAC1D,WAAW,EAAE,oBAAoB,CAAC;gBAGjC,wBAAwB,EAAE,iCAAiC,EAC3D,OAAO,EAAE,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,EACjD,WAAW,EAAE,oBAAoB;IAQ5B,OAAO,CACZ,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAClC,KAAK,EAAE,EAAE,GACP,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAgCvC,OAAO,CAAC,OAAO;CAQf"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.CompositeOperationExecution = void 0;
|
|
4
7
|
const OperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandler");
|
|
5
|
-
|
|
8
|
+
const AbstractOperationExecution_1 = __importDefault(require("./AbstractOperationExecution"));
|
|
9
|
+
class CompositeOperationExecution extends AbstractOperationExecution_1.default {
|
|
6
10
|
handlerInvocationFactory;
|
|
7
11
|
handler;
|
|
8
12
|
handlerType;
|
|
9
13
|
constructor(handlerInvocationFactory, handler, handlerType) {
|
|
14
|
+
super();
|
|
10
15
|
this.handlerInvocationFactory = handlerInvocationFactory;
|
|
11
16
|
this.handler = handler;
|
|
12
17
|
this.handlerType = handlerType;
|
|
@@ -15,6 +20,7 @@ class CompositeOperationExecution {
|
|
|
15
20
|
const handlerInvocation = this.handlerInvocationFactory(ctx);
|
|
16
21
|
try {
|
|
17
22
|
const result = await this.handler.handlerFunction(ctx, input, handlerInvocation);
|
|
23
|
+
this.validateOperationResponse(result);
|
|
18
24
|
return result;
|
|
19
25
|
}
|
|
20
26
|
catch (error) {
|
|
@@ -4,8 +4,8 @@ import { HttpOperationHandler } from '@trayio/cdk-dsl/connector/operation/HttpOp
|
|
|
4
4
|
import { HttpClient } from '@trayio/commons/http/HttpClient';
|
|
5
5
|
import { FileStorage } from '@trayio/commons/file/File';
|
|
6
6
|
import { OperationGlobalConfigHttp } from '@trayio/cdk-dsl/connector/operation/OperationGlobalConfig';
|
|
7
|
-
import
|
|
8
|
-
export declare class HttpOperationExecution<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT>
|
|
7
|
+
import AbstractOperationExecution from './AbstractOperationExecution';
|
|
8
|
+
export declare class HttpOperationExecution<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> extends AbstractOperationExecution<AUTH, IN, OUT> {
|
|
9
9
|
private jsonSerialization;
|
|
10
10
|
private httpClient;
|
|
11
11
|
private handler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationExecution.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"HttpOperationExecution.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/HttpOperationExecution.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAOlC,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EAGtB,oBAAoB,EACpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAGN,oBAAoB,EAMpB,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAW7D,OAAO,EAAQ,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2DAA2D,CAAC;AAGtG,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;IAOvB,OAAO,CAAC,oBAAoB;IAuD5B,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,kBAAkB;IA8B1B,OAAO,CAAC,aAAa;IAoDrB,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,eAAe;IA2CvB,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,qBAAqB;CAwC7B"}
|
|
@@ -22,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.HttpOperationExecution = void 0;
|
|
27
30
|
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
@@ -36,9 +39,10 @@ const HttpOperationHandler_1 = require("@trayio/cdk-dsl/connector/operation/Http
|
|
|
36
39
|
const Http_1 = require("@trayio/commons/http/Http");
|
|
37
40
|
const JsonSerialization_1 = require("@trayio/commons/serialization/JsonSerialization");
|
|
38
41
|
const BufferExtensions_1 = require("@trayio/commons/buffer/BufferExtensions");
|
|
42
|
+
const AbstractOperationExecution_1 = __importDefault(require("./AbstractOperationExecution"));
|
|
39
43
|
const mime = require('mime');
|
|
40
44
|
const { AWS_LAMBDA_FUNCTION_MEMORY_SIZE, CONNECTOR_MAX_ALLOCATED_RAM_MB } = process.env;
|
|
41
|
-
class HttpOperationExecution {
|
|
45
|
+
class HttpOperationExecution extends AbstractOperationExecution_1.default {
|
|
42
46
|
jsonSerialization;
|
|
43
47
|
httpClient;
|
|
44
48
|
handler;
|
|
@@ -46,6 +50,7 @@ class HttpOperationExecution {
|
|
|
46
50
|
globalConfiguration;
|
|
47
51
|
handlerType;
|
|
48
52
|
constructor(httpClient, fileStorage, handler, globalConfiguration, handlerType) {
|
|
53
|
+
super();
|
|
49
54
|
this.jsonSerialization = new JsonSerialization_1.JsonSerialization();
|
|
50
55
|
this.httpClient = httpClient;
|
|
51
56
|
this.fileStorage = fileStorage;
|
|
@@ -201,7 +206,18 @@ class HttpOperationExecution {
|
|
|
201
206
|
default:
|
|
202
207
|
return this.parseBodyAsJson(operationResponse);
|
|
203
208
|
}
|
|
204
|
-
}), O.getOrElse(() => this.parseEmptyBody(operationResponse)))
|
|
209
|
+
}), O.getOrElse(() => this.parseEmptyBody(operationResponse)), TE.map((parsedResponse) => {
|
|
210
|
+
try {
|
|
211
|
+
this.validateOperationResponse(parsedResponse);
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
const errorMessage = error instanceof Error
|
|
215
|
+
? error.message
|
|
216
|
+
: 'Operation failed with unknown error';
|
|
217
|
+
return OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.connectorError(errorMessage));
|
|
218
|
+
}
|
|
219
|
+
return parsedResponse;
|
|
220
|
+
}));
|
|
205
221
|
}
|
|
206
222
|
parseBodyAsJson(operationResponse) {
|
|
207
223
|
const bufferTE = BufferExtensions_1.BufferExtensions.readableToArrayBuffer(operationResponse.response.body);
|
|
@@ -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":"AA2BA,OAAO,8BAA8B,CAAC"}
|
|
@@ -316,7 +316,7 @@ describe('OperationExecutionGateway', () => {
|
|
|
316
316
|
id: input.id,
|
|
317
317
|
title: input.title,
|
|
318
318
|
}))
|
|
319
|
-
.handleResponse((ctx, input, response) => response.parseWithBodyAsText((text) => OperationHandler_1.OperationHandlerResult.success(text)))));
|
|
319
|
+
.handleResponse((ctx, input, response) => response.parseWithBodyAsText((text) => OperationHandler_1.OperationHandlerResult.success({ result: text })))));
|
|
320
320
|
OperationHandlerTest_1.OperationHandlerTestSetup.configureHandlerTest(postProductOperation, (handlerTest) => handlerTest
|
|
321
321
|
.usingHandlerContext('test')
|
|
322
322
|
.nothingBeforeAll()
|
|
@@ -326,7 +326,7 @@ describe('OperationExecutionGateway', () => {
|
|
|
326
326
|
.when(() => ({ id: 2, title: 'test' }))
|
|
327
327
|
.then(({ output }) => {
|
|
328
328
|
const outputValue = OperationHandler_1.OperationHandlerResult.getSuccessfulValueOrFail(output);
|
|
329
|
-
const parsedOutput = querystring.parse(outputValue);
|
|
329
|
+
const parsedOutput = querystring.parse(outputValue.result);
|
|
330
330
|
expect(parsedOutput.id).toEqual('2');
|
|
331
331
|
expect(parsedOutput.title).toEqual('test');
|
|
332
332
|
})
|
|
@@ -455,4 +455,98 @@ describe('OperationExecutionGateway', () => {
|
|
|
455
455
|
.finallyDoNothing())
|
|
456
456
|
.nothingAfterAll());
|
|
457
457
|
});
|
|
458
|
+
describe('should error for invalid operation response (i.e. not object)', () => {
|
|
459
|
+
describe('http handler', () => {
|
|
460
|
+
['test', 123, true, false, null, [], () => { }].forEach((invalidResponse) => {
|
|
461
|
+
OperationHandlerTest_1.OperationHandlerTestSetup.configureHandlerTest(OperationHandlerSetup_1.OperationHandlerSetup.configureHandler((handler) => handler.usingHttp((http) => http
|
|
462
|
+
.get('http://localhost:3000/posts/:id')
|
|
463
|
+
.handleRequest((_ctx, input, request) => request
|
|
464
|
+
.addPathParameter('id', input.id.toString())
|
|
465
|
+
.withoutBody())
|
|
466
|
+
.handleResponse((_ctx, _input, response) => response.parseWithBodyAsJson(() => OperationHandler_1.OperationHandlerResult.success(invalidResponse))))), (handlerTest) => handlerTest
|
|
467
|
+
.usingHandlerContext('test')
|
|
468
|
+
.nothingBeforeAll()
|
|
469
|
+
.testCase(`should error for ${invalidResponse !== null
|
|
470
|
+
? invalidResponse.toString()
|
|
471
|
+
: 'null'}`, (testCase) => testCase
|
|
472
|
+
.usingHandlerContext('test')
|
|
473
|
+
.givenNothing()
|
|
474
|
+
.when(() => ({ id: 2 }))
|
|
475
|
+
.then(({ output }) => {
|
|
476
|
+
expect(output.isFailure).toBeTruthy();
|
|
477
|
+
expect(output).toEqual(expect.objectContaining({
|
|
478
|
+
error: expect.objectContaining({
|
|
479
|
+
message: expect.stringContaining('Invalid operation response'),
|
|
480
|
+
}),
|
|
481
|
+
}));
|
|
482
|
+
})
|
|
483
|
+
.finallyDoNothing())
|
|
484
|
+
.nothingAfterAll());
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
describe('composite handler', () => {
|
|
488
|
+
['test', 123, true, false, null, [], () => { }].forEach((invalidResponse) => {
|
|
489
|
+
OperationHandlerTest_1.OperationHandlerTestSetup.configureHandlerTest(OperationHandlerSetup_1.OperationHandlerSetup.configureHandler((handler) => handler.usingComposite(async (_ctx, _input, _invoke) => OperationHandler_1.OperationHandlerResult.success(invalidResponse))), (handlerTest) => handlerTest
|
|
490
|
+
.usingHandlerContext('test')
|
|
491
|
+
.nothingBeforeAll()
|
|
492
|
+
.testCase(`should error for ${invalidResponse !== null
|
|
493
|
+
? invalidResponse.toString()
|
|
494
|
+
: 'null'}`, (testCase) => testCase
|
|
495
|
+
.usingHandlerContext('test')
|
|
496
|
+
.givenNothing()
|
|
497
|
+
.when(() => ({ id: 2 }))
|
|
498
|
+
.then(({ output }) => {
|
|
499
|
+
expect(output.isFailure).toBeTruthy();
|
|
500
|
+
expect(output).toEqual(expect.objectContaining({
|
|
501
|
+
error: expect.objectContaining({
|
|
502
|
+
message: expect.stringContaining('Invalid operation response'),
|
|
503
|
+
}),
|
|
504
|
+
}));
|
|
505
|
+
})
|
|
506
|
+
.finallyDoNothing())
|
|
507
|
+
.nothingAfterAll());
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
describe('should change error message based on NODE_ENV', () => {
|
|
511
|
+
afterAll(() => {
|
|
512
|
+
process.env['NODE_ENV'] = 'test';
|
|
513
|
+
});
|
|
514
|
+
OperationHandlerTest_1.OperationHandlerTestSetup.configureHandlerTest(OperationHandlerSetup_1.OperationHandlerSetup.configureHandler((handler) => handler.usingComposite(async (_ctx, _input, _invoke) => OperationHandler_1.OperationHandlerResult.success([]))), (handlerTest) => handlerTest
|
|
515
|
+
.usingHandlerContext('test')
|
|
516
|
+
.nothingBeforeAll()
|
|
517
|
+
.testCase(`should give test error`, (testCase) => testCase
|
|
518
|
+
.usingHandlerContext('test')
|
|
519
|
+
.givenNothing()
|
|
520
|
+
.when(() => {
|
|
521
|
+
process.env.NODE_ENV = 'test';
|
|
522
|
+
return { id: 2 };
|
|
523
|
+
})
|
|
524
|
+
.then(({ output }) => {
|
|
525
|
+
expect(output.isFailure).toBeTruthy();
|
|
526
|
+
expect(output).toEqual(expect.objectContaining({
|
|
527
|
+
error: expect.objectContaining({
|
|
528
|
+
message: expect.stringContaining('Invalid operation response; operations must always return an object. Received array. Wrap non-objects into an object.'),
|
|
529
|
+
}),
|
|
530
|
+
}));
|
|
531
|
+
})
|
|
532
|
+
.finallyDoNothing())
|
|
533
|
+
.testCase(`should give production error`, (testCase) => testCase
|
|
534
|
+
.usingHandlerContext('test')
|
|
535
|
+
.givenNothing()
|
|
536
|
+
.when(() => {
|
|
537
|
+
process.env.NODE_ENV = 'production';
|
|
538
|
+
return { id: 2 };
|
|
539
|
+
})
|
|
540
|
+
.then(({ output }) => {
|
|
541
|
+
expect(output.isFailure).toBeTruthy();
|
|
542
|
+
expect(output).toEqual(expect.objectContaining({
|
|
543
|
+
error: expect.objectContaining({
|
|
544
|
+
message: expect.stringContaining('Invalid operation response. Please contact support.'),
|
|
545
|
+
}),
|
|
546
|
+
}));
|
|
547
|
+
})
|
|
548
|
+
.finallyDoNothing())
|
|
549
|
+
.nothingAfterAll());
|
|
550
|
+
});
|
|
551
|
+
});
|
|
458
552
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-runtime",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.1",
|
|
4
4
|
"description": "A Runtime that executes connector operations defined using the CDK DSL",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"node": ">=18.x"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@trayio/axios": "4.
|
|
18
|
-
"@trayio/cdk-dsl": "4.
|
|
19
|
-
"@trayio/express": "4.
|
|
20
|
-
"@trayio/winston": "4.
|
|
17
|
+
"@trayio/axios": "4.17.1",
|
|
18
|
+
"@trayio/cdk-dsl": "4.17.1",
|
|
19
|
+
"@trayio/express": "4.17.1",
|
|
20
|
+
"@trayio/winston": "4.17.1",
|
|
21
21
|
"mime": "3.0.0",
|
|
22
22
|
"uuid": "9.0.0"
|
|
23
23
|
},
|