@kumologica/sdk 3.0.0 → 3.0.3
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/cli/commands/doc-commands/html.js +21 -22
- package/cli/commands/doc.js +1 -1
- package/cli/commands/export-commands/cloudformation.js +36 -27
- package/cli/commands/export-commands/utils/validator.js +3 -3
- package/cli/commands/test-utils/TestSuiteController.js +5 -1
- package/cli/commands/test.js +53 -29
- package/package.json +4 -4
|
@@ -2,25 +2,23 @@ exports.command = 'html';
|
|
|
2
2
|
exports.desc = `Generates html documentation of kumologica flow.`;
|
|
3
3
|
|
|
4
4
|
exports.builder = {
|
|
5
|
-
"
|
|
6
|
-
describe: "
|
|
7
|
-
|
|
8
|
-
type: 'string',
|
|
5
|
+
"project-directory": {
|
|
6
|
+
describe: "\nThe root directory of kumologica project. Current working directory used if not provided.",
|
|
7
|
+
type: 'string',
|
|
9
8
|
alias: 'd',
|
|
10
9
|
nargs: 1
|
|
11
10
|
},
|
|
12
|
-
"
|
|
13
|
-
describe: "
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
alias: 'k',
|
|
11
|
+
"flow-file-name": {
|
|
12
|
+
describe: "\nThe name of kumologica flow file to be created, must end with .json extension. Auto search if not provided.",
|
|
13
|
+
type: 'string',
|
|
14
|
+
alias: 'f',
|
|
17
15
|
nargs: 1
|
|
18
16
|
},
|
|
19
|
-
"
|
|
20
|
-
describe: "
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
"documentation-directory": {
|
|
18
|
+
describe: "\nThe directory where documentation will be created.",
|
|
19
|
+
type: 'string',
|
|
20
|
+
alias: 'c',
|
|
21
|
+
default: 'docs',
|
|
24
22
|
nargs: 1
|
|
25
23
|
}
|
|
26
24
|
}
|
|
@@ -28,20 +26,20 @@ exports.builder = {
|
|
|
28
26
|
function validate(argv) {
|
|
29
27
|
const chalk = require('chalk');
|
|
30
28
|
|
|
31
|
-
if (!argv["
|
|
32
|
-
console.log(`${chalk.redBright("Validation Error:
|
|
29
|
+
if (argv["flow-file-name"] && !argv["flow-file-name"].endsWith('.json')) {
|
|
30
|
+
console.log(`${chalk.redBright("Validation Error: flow-file-name must end with .json extension.")}`);
|
|
33
31
|
process.exit(1);
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
function display(argv) {
|
|
37
35
|
console.log('Parameters:');
|
|
38
|
-
console.log(' documentation-directory:
|
|
39
|
-
console.log('
|
|
40
|
-
console.log('
|
|
36
|
+
console.log(' documentation-directory: %s', argv["documentation-directory"]||'');
|
|
37
|
+
console.log(' project-directory: %s', argv["project-directory"]||'');
|
|
38
|
+
console.log(' flow-file-name: %s', argv["flow-file-name"]||'');
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
exports.handler = async function (argv) {
|
|
44
|
-
console.log('\nGenerating documentation\n');
|
|
42
|
+
console.log('\nGenerating html documentation\n');
|
|
45
43
|
display(argv);
|
|
46
44
|
validate(argv);
|
|
47
45
|
|
|
@@ -49,8 +47,9 @@ exports.handler = async function (argv) {
|
|
|
49
47
|
|
|
50
48
|
try {
|
|
51
49
|
const { doc } = require('@kumologica/builder');
|
|
52
|
-
doc("html", argv);
|
|
53
|
-
console.log(chalk.greenBright('Documentation generated
|
|
50
|
+
const docsDirectory = doc("html", argv);
|
|
51
|
+
console.log(chalk.greenBright('Documentation generated successfully:'));
|
|
52
|
+
console.log(chalk.greenBright(docsDirectory));
|
|
54
53
|
|
|
55
54
|
process.exit(0);
|
|
56
55
|
} catch (e) {
|
package/cli/commands/doc.js
CHANGED
|
@@ -3,139 +3,148 @@ const { boolean } = require('yargs');
|
|
|
3
3
|
exports.command = 'cloudformation';
|
|
4
4
|
exports.desc = `Build aws cloud formation script. \n Parameters are equivalent of command: "aws lambda create-function"`;
|
|
5
5
|
|
|
6
|
-
exports.builder = {
|
|
6
|
+
exports.builder = {
|
|
7
|
+
|
|
8
|
+
"project-directory": {
|
|
9
|
+
describe: "\nThe location of kumologica project.\n Current working directory if not provided.",
|
|
10
|
+
type: 'string',
|
|
11
|
+
alias: 'd',
|
|
12
|
+
nargs: 1
|
|
13
|
+
},
|
|
7
14
|
"flow-file-name": {
|
|
8
|
-
describe: "
|
|
15
|
+
describe: "\nThe name of kumologica flow file.\n Auto search if not provided.",
|
|
9
16
|
type: 'string',
|
|
10
17
|
alias: 'f',
|
|
11
18
|
nargs: 1
|
|
12
19
|
},
|
|
13
20
|
"lambda-name": {
|
|
14
|
-
describe: "
|
|
21
|
+
describe: "\nThe name of lambda function,\n default to flow name",
|
|
15
22
|
type: 'string',
|
|
16
23
|
alias: 'l',
|
|
17
24
|
nargs: 1
|
|
18
25
|
},
|
|
19
26
|
"zip-file-name": {
|
|
20
|
-
describe: "
|
|
27
|
+
describe: "\nThe name of zip file of built lambda. The zip file may not exists until 'aws cloudformation package' command is called." ,
|
|
21
28
|
demandOption: "The name of zip file is required.",
|
|
22
29
|
type: 'string',
|
|
23
30
|
alias: 'z',
|
|
24
31
|
nargs: 1
|
|
25
32
|
},
|
|
26
33
|
"role-name": {
|
|
27
|
-
describe: "
|
|
34
|
+
describe: "\nThe name of lambda role, default to {lambda-name}-role",
|
|
28
35
|
type: 'string',
|
|
29
36
|
alias: 'o',
|
|
30
37
|
nargs: 1
|
|
31
38
|
},
|
|
32
39
|
"bucket-name": {
|
|
33
|
-
describe: "
|
|
40
|
+
describe: "\nThe name of bucket where zipped lambda is loaded from",
|
|
34
41
|
demandOption: "The name of s3 bucket is required.",
|
|
35
42
|
type: 'string',
|
|
36
43
|
alias: 'b',
|
|
37
44
|
nargs: 1
|
|
38
45
|
},
|
|
39
46
|
timeout: {
|
|
40
|
-
describe: "
|
|
47
|
+
describe: "\nThe time in seconds lambda is allowed to run, max: 900",
|
|
41
48
|
type: 'number',
|
|
49
|
+
default: 10,
|
|
42
50
|
alias: 't',
|
|
43
51
|
nargs: 1
|
|
44
52
|
},
|
|
45
53
|
"memory-size": {
|
|
46
|
-
describe: "
|
|
54
|
+
describe: "\nThe amount of memory allocated to function, default 128 (MB), must be multiple of 64 (MB), max 4096 (MB)",
|
|
47
55
|
type: 'number',
|
|
56
|
+
default: 128,
|
|
48
57
|
alias: 'm',
|
|
49
58
|
nargs: 1
|
|
50
59
|
},
|
|
51
60
|
description: {
|
|
52
|
-
describe: "
|
|
61
|
+
describe: "\nThe description of a function",
|
|
53
62
|
type: 'string',
|
|
54
|
-
alias: 'd',
|
|
55
63
|
nargs: 1
|
|
56
64
|
},
|
|
57
65
|
environment: {
|
|
58
|
-
describe:
|
|
66
|
+
describe: `\nEnvironment variables, JSON Syntax: '{"Variables": {"string": "string" ...}'}`,
|
|
59
67
|
type: 'string',
|
|
60
68
|
alias: 'e',
|
|
61
69
|
nargs: 1
|
|
62
70
|
},
|
|
63
71
|
tags: {
|
|
64
|
-
describe:
|
|
72
|
+
describe: `\nTags, JSON Syntax: '{"name": "value" ...}'`,
|
|
65
73
|
type: 'string',
|
|
66
74
|
alias: 'g',
|
|
67
75
|
nargs: 1
|
|
68
76
|
},
|
|
69
77
|
"tracing-config": {
|
|
70
|
-
describe:
|
|
78
|
+
describe: `\nX-Ray config, JSON Syntax: '{"Mode": "Active"|"PassThrough"}' `,
|
|
71
79
|
type: 'string',
|
|
72
80
|
alias: 'x',
|
|
73
81
|
nargs: 1
|
|
74
82
|
},
|
|
75
83
|
"kms-key-arn": {
|
|
76
|
-
describe: "
|
|
84
|
+
describe: "\nThe ARN of KMS key to encrypt env variables",
|
|
77
85
|
type: 'string',
|
|
78
86
|
alias: 'k',
|
|
79
87
|
nargs: 1
|
|
80
88
|
},
|
|
81
89
|
"vpc-config": {
|
|
82
|
-
describe:
|
|
90
|
+
describe: `\nThe list of security groups and subnets of VPC, JSON syntax: '{ "SubnetIds": ["string", ...],"SecurityGroupIds": ["string", ...]}'`,
|
|
83
91
|
type: 'string',
|
|
84
92
|
alias: 'v',
|
|
85
93
|
nargs: 1
|
|
86
94
|
},
|
|
87
95
|
architectures: {
|
|
88
|
-
describe: "
|
|
96
|
+
describe: "\nThe instruction set architecture that the function supports, a string array with one of x86_64, arm64. Default value: [x86_64].",
|
|
89
97
|
type: 'string',
|
|
90
98
|
nargs: 1
|
|
91
99
|
},
|
|
92
100
|
runtime: {
|
|
93
|
-
describe: "
|
|
101
|
+
describe: "\nThe runtime, only nodejs runtimes allowed: nodejs12.x | nodejs14.x | nodejs16.x | ...",
|
|
94
102
|
type: 'string',
|
|
103
|
+
default: 'nodejs14.x',
|
|
95
104
|
alias: 'r',
|
|
96
105
|
nargs: 1
|
|
97
106
|
},
|
|
98
107
|
"dead-letter-config": {
|
|
99
|
-
describe:
|
|
108
|
+
describe: `\nThe arn of the dead letter queue or topic JSON Syntax: '{"TargetArn": "string"}'`,
|
|
100
109
|
type: 'string',
|
|
101
110
|
alias: 'q',
|
|
102
111
|
nargs: 1
|
|
103
112
|
},
|
|
104
113
|
"file-system-configs": {
|
|
105
|
-
describe:
|
|
114
|
+
describe: `\nAWS EFS config details, JSON Syntax: '[{"Arn": "string","LocalMountPath": "string"} ...]'`,
|
|
106
115
|
type: 'string',
|
|
107
116
|
nargs: 1
|
|
108
117
|
},
|
|
109
118
|
"log-retention-days": {
|
|
110
|
-
describe: '
|
|
119
|
+
describe: '\nNumber of days logs to be retained',
|
|
111
120
|
type: 'number',
|
|
112
121
|
nargs: 1
|
|
113
122
|
},
|
|
114
123
|
"role-arn": {
|
|
115
|
-
describe:
|
|
124
|
+
describe: `\nThe arn of IAM role to assign to lambda, otherwise this command will generate role. \n Important!\n This parameter should only be used if this command is not able to generate sufficient role based on flow details.`,
|
|
116
125
|
type: 'string',
|
|
117
126
|
nargs: 1
|
|
118
127
|
},
|
|
119
128
|
"policy": {
|
|
120
|
-
describe:
|
|
129
|
+
describe: `\nAdditional iam policy to add to the role. It must be in valid aws policy format, for example: '{"Effect": "Allow", "Resource": ["*"],"Action": ["sns:Publish"]}'. if policy is invalid, cloudformation stack will fail. The value can be single policy statement or array of statements if required. This parameter is ignored if role-arn is provided.`,
|
|
121
130
|
type: 'string',
|
|
122
131
|
nargs: 1
|
|
123
132
|
},
|
|
124
133
|
"strict-mode": {
|
|
125
|
-
describe: '
|
|
134
|
+
describe: '\nFails script creation if insufficient resource definition is provided (string values or environment reference). If false, then resource will be substituted with "*" if missing.',
|
|
126
135
|
type: boolean,
|
|
127
136
|
nargs: 1,
|
|
128
137
|
default: true
|
|
129
138
|
},
|
|
130
139
|
triggers: {
|
|
131
|
-
describe:
|
|
140
|
+
describe: `\nArray of lambda triggers, JSON Syntax: '[{"api": {"apiId": "..",..}]'}
|
|
132
141
|
|
|
133
142
|
Supported triggers:
|
|
134
143
|
|
|
135
144
|
Cloudwatch Event:\n-----------------
|
|
136
145
|
* schedule - cron expression (minutes hours days-of-month month days-of-week year) or fixed rate expression, required.\n See more: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html
|
|
137
146
|
* name - the name of event, optional, default value: Event+timestamp if not provided
|
|
138
|
-
*
|
|
147
|
+
* reference - the reference property set for event listener node that should handle event. Optional
|
|
139
148
|
|
|
140
149
|
Examples:
|
|
141
150
|
1. Creates event trigger using cron expression that runs at 10am UTC every day:\n
|
|
@@ -144,8 +153,8 @@ Examples:
|
|
|
144
153
|
2. Creates event trigger using rate expression that runs every minute:\n
|
|
145
154
|
{"event": {"expression": "rate(1 minute)"}}\n
|
|
146
155
|
|
|
147
|
-
3. Creates event trigger using rate expression that runs every minute for event listener
|
|
148
|
-
{"event": {"expression": "rate(1 minute)", "
|
|
156
|
+
3. Creates event trigger using rate expression that runs every minute for event listener with reference "cleanup":\n
|
|
157
|
+
{"event": {"expression": "rate(1 minute)", "reference": "cleanup"}}\n
|
|
149
158
|
|
|
150
159
|
SQS:\n----
|
|
151
160
|
* queueArn - the ARN of sqs queue, required
|
|
@@ -29,9 +29,9 @@ const triggersSchema = {
|
|
|
29
29
|
"title": "Event name",
|
|
30
30
|
"type": "string"
|
|
31
31
|
},
|
|
32
|
-
"
|
|
33
|
-
"$id": "#root/items/event/
|
|
34
|
-
"title": "Event Listener
|
|
32
|
+
"reference": {
|
|
33
|
+
"$id": "#root/items/event/reference",
|
|
34
|
+
"title": "Event Listener reference",
|
|
35
35
|
"type": "string"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -323,13 +323,17 @@ class TestSuiteController {
|
|
|
323
323
|
// === Iterate over all the testCases ===
|
|
324
324
|
await this.runTestCases(testCases);
|
|
325
325
|
await this.waitForResults();
|
|
326
|
-
|
|
326
|
+
const errorsNum = this._testReporter.getFailedTestCases().length;
|
|
327
|
+
|
|
327
328
|
// === End the testSuite
|
|
328
329
|
this._appServer.events.emit('runtime-event', {
|
|
329
330
|
id: runtimeEvents.TEST_TESTSUITE_END,
|
|
330
331
|
payload: {},
|
|
331
332
|
});
|
|
333
|
+
|
|
334
|
+
return errorsNum;
|
|
332
335
|
}
|
|
336
|
+
|
|
333
337
|
async runTestCases(testCases) {
|
|
334
338
|
remainingTestCases = testCases.length;
|
|
335
339
|
const port = this._appServer._server.address().port;
|
package/cli/commands/test.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
exports.command = 'test';
|
|
2
|
-
exports.desc = `Run test suite`;
|
|
3
|
-
|
|
4
|
-
exports.builder = {
|
|
5
|
-
"flow-file-name": {
|
|
6
|
-
describe: "The name of kumologica flow file.\n Auto search if not provided.",
|
|
7
|
-
type: 'string',
|
|
8
|
-
alias: 'f',
|
|
9
|
-
nargs: 1
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
1
|
const chalk = require('chalk');
|
|
14
|
-
const
|
|
15
|
-
const
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const { logError } = require('./utils');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
16
6
|
const { AppServer } = require('@kumologica/runtime');
|
|
17
7
|
const { TestSuiteController } = require('./test-utils/TestSuiteController');
|
|
18
|
-
const path = require('path');
|
|
19
8
|
const { codegen } = require('@kumologica/builder');
|
|
9
|
+
|
|
10
|
+
const log = console.log;
|
|
11
|
+
const APP_SERVER_PORT = 1990;
|
|
20
12
|
|
|
21
13
|
async function runTest(flowFilePath) {
|
|
22
|
-
log(
|
|
14
|
+
log(`\n> Starting runtime on port ${APP_SERVER_PORT}...`);
|
|
23
15
|
|
|
24
16
|
let appServer = new AppServer({
|
|
25
|
-
projectDir:
|
|
17
|
+
projectDir: path.dirname(flowFilePath),
|
|
26
18
|
flowFilePath: flowFilePath,
|
|
27
19
|
port: APP_SERVER_PORT,
|
|
28
20
|
serverMode: AppServer.mode.HEADLESS_DEFAULT_EXPRESS,
|
|
@@ -33,10 +25,11 @@ async function runTest(flowFilePath) {
|
|
|
33
25
|
|
|
34
26
|
try {
|
|
35
27
|
await appServer.start();
|
|
36
|
-
log(
|
|
28
|
+
log(`> FlowFile to be tested: ${chalk.bold(path.resolve(flowFilePath))} \n`);
|
|
37
29
|
let testSuiteController = new TestSuiteController(appServer);
|
|
38
|
-
await testSuiteController.runTestSuite(); // no need to wait for response
|
|
39
|
-
|
|
30
|
+
const errors = await testSuiteController.runTestSuite(); // no need to wait for response
|
|
31
|
+
|
|
32
|
+
process.exit(errors > 0);
|
|
40
33
|
} catch (err) {
|
|
41
34
|
log(
|
|
42
35
|
chalk.red(
|
|
@@ -47,20 +40,51 @@ async function runTest(flowFilePath) {
|
|
|
47
40
|
}
|
|
48
41
|
}
|
|
49
42
|
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
function isDirectory(dir) {
|
|
44
|
+
try{
|
|
45
|
+
let stats = fs.statSync(dir);
|
|
46
|
+
return stats.isDirectory();
|
|
47
|
+
} catch (err) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.command = 'test [project_directory]';
|
|
55
|
+
exports.desc = `Run test suite`;
|
|
56
|
+
|
|
57
|
+
exports.builder = (yargs) => {
|
|
58
|
+
yargs.positional(`project_directory`, {
|
|
59
|
+
type: 'string',
|
|
60
|
+
describe: 'Path to a valid kumologica project directory or flow file. (Optional)'
|
|
61
|
+
})
|
|
53
62
|
}
|
|
54
63
|
|
|
55
|
-
exports.handler =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
exports.handler = ({ project_directory }) => {
|
|
65
|
+
let projectDirOrFile = project_directory || process.cwd();
|
|
66
|
+
let projectFlowPath = projectDirOrFile;
|
|
67
|
+
|
|
68
|
+
let isDir = isDirectory(projectDirOrFile);
|
|
69
|
+
if (isDir){
|
|
70
|
+
let flowFileName = codegen.findFlowFile(projectDirOrFile); // returns only the flowname
|
|
71
|
+
if (!flowFileName){
|
|
72
|
+
logError(`No flow found in directory: ${projectDirOrFile}`);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}else {
|
|
75
|
+
projectFlowPath = path.join(projectDirOrFile, flowFileName);
|
|
76
|
+
}
|
|
77
|
+
} else if (isDir === false){
|
|
78
|
+
// do nothing as it was assumed to be a file
|
|
79
|
+
} else {
|
|
80
|
+
logError(`Directory does not exist: ${project_directory}`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
59
83
|
|
|
60
84
|
try {
|
|
61
|
-
runTest(
|
|
85
|
+
runTest(projectFlowPath);
|
|
62
86
|
} catch (e) {
|
|
63
|
-
|
|
87
|
+
logError(e.message);
|
|
64
88
|
process.exit(1);
|
|
65
89
|
}
|
|
66
90
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"productName": "Kumologica Designer",
|
|
4
4
|
"copyright": "Copyright 2020 Kumologica Pty Ltd, All Rights Reserved.",
|
|
5
5
|
"author": "Kumologica Pty Ltd <contact@kumologica.com>",
|
|
6
|
-
"version": "3.0.
|
|
6
|
+
"version": "3.0.3",
|
|
7
7
|
"description": "Kumologica Designer, harnessing Serverless for your cloud integration needs",
|
|
8
8
|
"main": "src/app/main.js",
|
|
9
9
|
"files": [
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
},
|
|
65
65
|
"license": "Proprietary",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@kumologica/builder": "3.0.
|
|
68
|
-
"@kumologica/runtime": "3.0.
|
|
69
|
-
"@kumologica/devkit": "3.0.
|
|
67
|
+
"@kumologica/builder": "3.0.3",
|
|
68
|
+
"@kumologica/runtime": "3.0.3",
|
|
69
|
+
"@kumologica/devkit": "3.0.3",
|
|
70
70
|
"adm-zip": "^0.4.13",
|
|
71
71
|
"ajv": "^8.10.0",
|
|
72
72
|
"aws-sdk": "^2.513.0",
|