New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@trayio/cdk-runtime

Package Overview
Dependencies
Maintainers
0
Versions
204
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trayio/cdk-runtime - npm Package Compare versions

Comparing version 4.29.0 to 4.30.0

146

dist/connector/operation/OperationExecutionGateway.unit.test.js

@@ -25,2 +25,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -33,2 +36,3 @@ const stream_1 = require("stream");

const function_1 = require("fp-ts/function");
const just_permutations_1 = __importDefault(require("just-permutations"));
const OperationHandlerSetup_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerSetup");

@@ -165,2 +169,21 @@ const OperationHandlerTest_1 = require("@trayio/cdk-dsl/connector/operation/OperationHandlerTest");

const testHttpController = new ExpressHttpController_1.ExpressHttpController(new TestControllerHttp(), '/tmp', O.none);
function permutativeTest(configMethods, setupMethod, callback) {
const configMethodPermutations = (0, just_permutations_1.default)(configMethods);
configMethodPermutations.forEach((configMethodPermutation) => {
const configMethodOrderNames = [];
const operationToExecute = OperationHandlerSetup_1.OperationHandlerSetup.configureHandler((handler) => {
let configuredHandler = handler;
configMethodPermutation.forEach((configMethodPair) => {
configMethodOrderNames.push(configMethodPair.method);
configuredHandler = configuredHandler[configMethodPair.method](
// @ts-ignore: A spread argument must either have a tuple type or be passed to a rest parameter.
...configMethodPair.input);
});
return configuredHandler[setupMethod.method](
// @ts-ignore: A spread argument must either have a tuple type or be passed to a rest parameter.
...setupMethod.input);
});
callback(operationToExecute, configMethodOrderNames.join('->'));
});
}
describe('OperationExecutionGateway', () => {

@@ -206,31 +229,47 @@ let server;

const globalConfig = OperationGlobalConfig_1.OperationGlobalConfigHttp.create().withBaseUrl(() => 'http://localhost:3000');
const getProductOperation = OperationHandlerSetup_1.OperationHandlerSetup.configureHandler((handler) => handler
.addInputValidation((inputValidation) => inputValidation
.condition((ctx, input) => input.id > 0)
.errorMessage(() => 'id must be bigger than zero'))
.withGlobalConfiguration(globalConfig)
.usingHttp((http) => http
.get('/posts/:id')
.handleRequest((ctx, input, request) => request.addPathParameter('id', input.id.toString()).withoutBody())
.handleResponse((ctx, input, response) => response.parseWithBodyAsJson())));
OperationHandlerTest_1.OperationHandlerTestSetup.configureHandlerTest(getProductOperation, (handlerTest) => handlerTest
.usingHandlerContext('test')
.nothingBeforeAll()
.testCase('should get a product', (testCase) => testCase
.usingHandlerContext('test')
.givenNothing()
.when(() => ({ id: 2 }))
.then(({ output }) => {
const outputValue = OperationHandler_1.OperationHandlerResult.getSuccessfulValueOrFail(output);
expect(outputValue.id).toEqual(2);
})
.finallyDoNothing())
.testCase('should validate id', (testCase) => testCase
.givenNothing()
.when(() => ({ id: -1 }))
.then(({ output }) => {
expect(output.isFailure).toBe(true);
})
.finallyDoNothing())
.nothingAfterAll());
permutativeTest([
{
method: 'withGlobalConfiguration',
input: [globalConfig],
},
{
method: 'addInputValidation',
input: [
(inputValidation) => inputValidation
.condition((_ctx, input) => input.id > 0)
.errorMessage(() => 'id must be bigger than zero'),
],
},
], {
method: 'usingHttp',
input: [
(http) => http
.get('/posts/:id')
.handleRequest((_ctx, input, request) => request
.addPathParameter('id', input.id.toString())
.withoutBody())
.handleResponse((_ctx, _input, response) => response.parseWithBodyAsJson()),
],
}, (getProductOperation, identifier) => {
OperationHandlerTest_1.OperationHandlerTestSetup.configureHandlerTest(getProductOperation, (handlerTest) => handlerTest
.usingHandlerContext('test')
.nothingBeforeAll()
.testCase(`should get a product - ${identifier}`, (testCase) => testCase
.usingHandlerContext('test')
.givenNothing()
.when(() => ({ id: 2 }))
.then(({ output }) => {
const outputValue = OperationHandler_1.OperationHandlerResult.getSuccessfulValueOrFail(output);
expect(outputValue.id).toEqual(2);
})
.finallyDoNothing())
.testCase(`should validate id - ${identifier}`, (testCase) => testCase
.givenNothing()
.when(() => ({ id: -1 }))
.then(({ output }) => {
expect(output.isFailure).toBe(true);
})
.finallyDoNothing())
.nothingAfterAll());
});
});

@@ -282,2 +321,51 @@ describe('set a bearer token via globalConfig', () => {

});
describe('config method order is agnostic', () => {
const globalConfig = OperationGlobalConfig_1.OperationGlobalConfigHttp.create().withBaseUrl(() => 'http://localhost:3000');
permutativeTest([
{
method: 'withGlobalConfiguration',
input: [globalConfig],
},
{
method: 'addInputValidation',
input: [
(inputValidation) => inputValidation
.condition((_ctx, input) => input.id > 0)
.errorMessage(() => 'id must be bigger than zero'),
],
},
{
method: 'addOutputValidation',
input: [
(outputValidation) => outputValidation
.condition((_ctx, output) => output.id > 0)
.errorMessage(() => 'id must be bigger than zero'),
],
},
], {
method: 'usingHttp',
input: [
(http) => http
.get('/posts/:id')
.handleRequest((_ctx, input, request) => request
.addPathParameter('id', input.id.toString())
.withoutBody())
.handleResponse((_ctx, _input, response) => response.parseWithBodyAsJson()),
],
}, (getProductOperation, identifier) => {
OperationHandlerTest_1.OperationHandlerTestSetup.configureHandlerTest(getProductOperation, (handlerTest) => handlerTest
.usingHandlerContext('test')
.nothingBeforeAll()
.testCase(`should get a product with permutation: ${identifier}`, (testCase) => testCase
.usingHandlerContext('test')
.givenNothing()
.when(() => ({ id: 2 }))
.then(({ output }) => {
const outputValue = OperationHandler_1.OperationHandlerResult.getSuccessfulValueOrFail(output);
expect(outputValue.id).toEqual(2);
})
.finallyDoNothing())
.nothingAfterAll());
});
});
describe('get a product as text', () => {

@@ -284,0 +372,0 @@ const getProductOperationAsText = OperationHandlerSetup_1.OperationHandlerSetup.configureHandler((handler) => handler

15

package.json
{
"name": "@trayio/cdk-runtime",
"version": "4.29.0",
"version": "4.30.0",
"description": "A Runtime that executes connector operations defined using the CDK DSL",

@@ -17,6 +17,6 @@ "exports": {

"dependencies": {
"@trayio/axios": "4.29.0",
"@trayio/cdk-dsl": "4.29.0",
"@trayio/express": "4.29.0",
"@trayio/winston": "4.29.0",
"@trayio/axios": "4.30.0",
"@trayio/cdk-dsl": "4.30.0",
"@trayio/express": "4.30.0",
"@trayio/winston": "4.30.0",
"mime": "3.0.0",

@@ -35,3 +35,6 @@ "uuid": "9.0.0"

"/dist"
]
],
"devDependencies": {
"just-permutations": "^2.2.1"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc