Skip to content

Commit 26ee772

Browse files
author
Chris Wiechmann
committed
Now using new API-Builder SDK to solve a number of sec-issues
1 parent 801d1b9 commit 26ee772

8 files changed

Lines changed: 3759 additions & 1768 deletions

File tree

api-builder-plugin-fn-foreach/Changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## [Unreleased]
7+
## [2.0.0] 2021-05-31
8+
### Security
9+
- Now using new API-Builder SDK to solve a number of security issues
810

911
## [1.0.3] 2020-03-30
1012
### Security

api-builder-plugin-fn-foreach/package-lock.json

Lines changed: 3593 additions & 1609 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api-builder-plugin-fn-foreach/package.json

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@axway-api-builder-ext/api-builder-plugin-fn-foreach",
3-
"version": "1.0.3",
3+
"version": "2.0.0",
44
"description": "For each flow node",
55
"author": "bladedancer",
66
"license": "Apache-2.0",
@@ -30,23 +30,22 @@
3030
"flows"
3131
],
3232
"dependencies": {
33-
"axway-flow-sdk": "^2.0.0"
34-
},
35-
"peerDependencies": {
36-
"@axway/api-builder-runtime": "^4.5.0"
33+
"@axway/api-builder-sdk": "^1.1.6",
34+
"@axway/api-builder-runtime": "^4.66.0"
3735
},
3836
"devDependencies": {
39-
"chai": "^4.2.0",
40-
"check-node-version": "^4.0.2",
41-
"cross-env": "^5.0.5",
42-
"eslint": "^6.8.0",
43-
"eslint-config-axway": "^2.0.7",
44-
"eslint-plugin-chai-friendly": "^0.4.1",
45-
"eslint-plugin-mocha": "^4.11.0",
46-
"mocha": "^6.2.3",
37+
"@axway/api-builder-test-utils": "^1.1.13",
38+
"chai": "^4.3.4",
39+
"check-node-version": "^4.1.0",
40+
"cross-env": "^7.0.3",
41+
"eslint": "^7.27.0",
42+
"eslint-config-axway": "^6.0.2",
43+
"eslint-plugin-chai-friendly": "^0.7.1",
44+
"eslint-plugin-mocha": "^8.2.0",
45+
"mocha": "^8.4.0",
4746
"mock-require": "^3.0.2",
48-
"nyc": "^15.0.0",
49-
"rimraf": "^2.6.2",
47+
"nyc": "^15.1.0",
48+
"rimraf": "^3.0.2",
5049
"simple-mock": "^0.8.0"
5150
},
5251
"scripts": {
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
const APIBuilder = require('@axway/api-builder-runtime');
22

3-
exports = module.exports = async function (req, cb) {
3+
async function flowforeach(params, options) {
44
const server = APIBuilder.getGlobal();
55

6-
const flowName = req.params.flow;
7-
const items = req.params.items || [];
6+
const flowName = params.flow;
7+
const items = params.items || [];
88

99
if (!server.getFlow(flowName)) {
10-
return cb.flowNotFound(null, flowName);
10+
return options.setOutput('flowNotFound', `The flow with name: '${flowName}' could not be found.`);
1111
}
12-
1312
try {
1413
const results = [];
1514
for (let i = 0; i < items.length; ++i) {
16-
results[i] = await server.flowManager.flow(flowName, items[i], { logger: server.logger });
15+
results[i] = await server.flowManager.flow(flowName, items[i], { options });
1716
}
18-
return cb.next(null, results);
17+
return results;
1918
} catch (ex) {
20-
return cb.error(null, ex);
19+
throw ex;
2120
}
2221
};
22+
23+
module.exports = {
24+
flowforeach
25+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
flow-nodes:
2+
foreach:
3+
name: For Each
4+
icon: icon.svg
5+
description: Loop over items and execute specified flow.
6+
category: extension
7+
methods:
8+
flowforeach:
9+
name: Flow
10+
description: Execute a flow for each item.
11+
parameters:
12+
flow:
13+
name: Flow name
14+
description: The flow to execute.
15+
required: true
16+
initialType: string
17+
schema:
18+
type: string
19+
items:
20+
name: Items
21+
description: The list of inputs to the flow.
22+
required: false
23+
initialType: array
24+
schema:
25+
type: array
26+
outputs:
27+
next:
28+
name: Next
29+
description: The list of results
30+
context: $.results
31+
schema:
32+
type: array
33+
flowNotFound:
34+
name: Flow not found
35+
description: Returned error contains an error message.
36+
context: $.error
37+
schema:
38+
type: string
39+
error:
40+
name: Error
41+
description: error
42+
context: $.error
43+
schema:
44+
type: object
File renamed without changes.
Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,21 @@
1-
const sdk = require('axway-flow-sdk');
2-
const action = require('./action');
1+
const path = require('path');
2+
const { SDK } = require('@axway/api-builder-sdk');
3+
const actions = require('./actions');
34

4-
function getFlowNodes() {
5-
const flownodes = sdk.init(module);
6-
7-
flownodes.add('foreach', {
8-
category: 'extension',
9-
name: 'For Each',
10-
icon: 'icon.svg',
11-
description: 'Loop over items and execute specified flow.'
12-
})
13-
.method('flowforeach', {
14-
name: 'Flow',
15-
description: 'Execute a flow for each item.'
16-
})
17-
.parameter('flow', {
18-
description: 'The flow to execute.',
19-
type: 'string'
20-
}, true)
21-
.parameter('items', {
22-
description: 'The list of inputs to the flow.',
23-
type: 'array'
24-
}, true)
25-
.output('next', {
26-
name: 'Next',
27-
description: 'The list of results',
28-
context: '$.results',
29-
schema: {
30-
type: 'array'
31-
}
32-
})
33-
.output('flowNotFound', {
34-
name: 'Flow not found',
35-
context: '$.error',
36-
schema: {
37-
type: 'string'
38-
}
39-
})
40-
.output('error', {
41-
name: 'Error',
42-
context: '$.error',
43-
schema: {}
44-
})
45-
.action(action);
46-
47-
return Promise.resolve(flownodes);
5+
/**
6+
* Resolves the API Builder plugin.
7+
* @param {object} pluginConfig - The service configuration for this plugin
8+
* from API Builder config.pluginConfig['api-builder-plugin-pluginName']
9+
* @param {string} pluginConfig.proxy - The configured API-builder proxy server
10+
* @param {object} options - Additional options and configuration provided by API Builder
11+
* @param {string} options.appDir - The current directory of the service using the plugin
12+
* @param {string} options.logger - An API Builder logger scoped for this plugin
13+
* @returns {object} An API Builder plugin.
14+
*/
15+
async function getPlugin(pluginConfig, options) {
16+
const sdk = new SDK({ pluginConfig });
17+
sdk.load(path.resolve(__dirname, 'flow-nodes.yml'), actions);
18+
return sdk.getPlugin();
4819
}
4920

50-
exports = module.exports = getFlowNodes;
21+
module.exports = getPlugin;

0 commit comments

Comments
 (0)