@kumologica/sdk 3.0.1 → 3.0.4

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.
@@ -2,25 +2,23 @@ exports.command = 'html';
2
2
  exports.desc = `Generates html documentation of kumologica flow.`;
3
3
 
4
4
  exports.builder = {
5
- "documentation-directory": {
6
- describe: "The directory where documentation will be created.",
7
- demandOption: "The documentation directory is required.",
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
- "kumologica-project-directory": {
13
- describe: "The directory where kumologica project to be created",
14
- demandOption: "The kumologica project directory is required.",
15
- type: 'string',
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
- "kumologica-flow-file-name": {
20
- describe: "The name of kumologica flow file to be created, must end with .json extension",
21
- demandOption: "The kumologica flow file name is required.",
22
- type: 'string',
23
- alias: 'f',
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["kumologica-flow-file-name"].endsWith('.json')) {
32
- console.log(`${chalk.redBright("Validation Error: kumologica-flow-file-name must end with .json extension.")}`);
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: %s', argv["documentation-directory"]||'');
39
- console.log(' kumologica-project-directory: %s', argv["kumologica-project-directory"]||'');
40
- console.log(' kumologica-flow-file-name: %s', argv["kumologica-flow-file-name"]||'');
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 succesfully.'));
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) {
@@ -1,4 +1,4 @@
1
- exports.command = 'doc'
1
+ exports.command = 'doc <format>'
2
2
  exports.desc = 'Generate documentation for kumologica flow'
3
3
  exports.builder = function (yargs) {
4
4
  return yargs.commandDir('doc-commands')
@@ -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: "The name of kumologica flow file.\n Auto search if not provided.",
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: "The name of lambda function,\n default to flow name",
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: "The name of zip file of built lambda",
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: "The name of lambda role, default to {lambda-name}-role",
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: "The name of bucket where zipped lambda is loaded from",
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: "The time in seconds flow lambda is allowed to run, default: 3, max: 900",
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: "The amount of memory allocated to function, default 128 (MB), must be multiple of 64 (MB)",
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: "The description of a function",
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: `Environment variables, JSON Syntax: '{"Variables": {"string": "string" ...}'}`,
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: `Tags, JSON Syntax: '{"string": "string" ...}'`,
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: `X-Ray config, JSON Syntax: '{"Mode": "Active"|"PassThrough"}' `,
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: "The ARN of KMS key to encrypt env variables",
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: `The list of security groups and subnets of VPC, JSON syntax: '{ "SubnetIds": ["string", ...],"SecurityGroupIds": ["string", ...]}'`,
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: "The instruction set architecture that the function supports, a string array with one of x86_64, arm64. The default value is [x86_64]",
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: "The runtime, only nodejs runtimes allowed: nodejs|nodejs4.3|nodejs6.10|nodejs8.10|nodejs10.x|nodejs12.x|...",
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: `The arn of the dead letter queue or topic JSON Syntax: '{"TargetArn": "string"}'`,
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: `AWS EFS config details, JSON Syntax: '[{"Arn": "string","LocalMountPath": "string"} ...]'`,
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: 'Number of days logs to be retained',
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: `The ARM 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.`,
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: `Additional iam policy to add to the role. It must be 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.`,
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: 'Fails script creation if insufficient resource definition is provided (string values or environment reference). If false, then resource will be substituted with "*" if missing.',
126
- type: boolean,
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.',
135
+ type: 'boolean',
127
136
  nargs: 1,
128
137
  default: true
129
138
  },
130
139
  triggers: {
131
- describe: `Array of lambda triggers, JSON Syntax: '[{"api": {"apiId": "..",..}]'}
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
- * nodeId - the id of event listener node that should handle event. Optional
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 id "53bdf34.df2dfa42":\n
148
- {"event": {"expression": "rate(1 minute)", "nodeId": "53bdf34.df2dfa42"}}\n
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
- "nodeId": {
33
- "$id": "#root/items/event/nodeId",
34
- "title": "Event Listener node id",
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;
@@ -27,8 +27,9 @@ async function runTest(flowFilePath) {
27
27
  await appServer.start();
28
28
  log(`> FlowFile to be tested: ${chalk.bold(path.resolve(flowFilePath))} \n`);
29
29
  let testSuiteController = new TestSuiteController(appServer);
30
- await testSuiteController.runTestSuite(); // no need to wait for response
31
- process.exit(0);
30
+ const errors = await testSuiteController.runTestSuite(); // no need to wait for response
31
+
32
+ process.exit(errors > 0);
32
33
  } catch (err) {
33
34
  log(
34
35
  chalk.red(
@@ -50,18 +51,18 @@ function isDirectory(dir) {
50
51
 
51
52
  }
52
53
 
53
- exports.command = 'test [project_dir]';
54
+ exports.command = 'test [project_directory]';
54
55
  exports.desc = `Run test suite`;
55
56
 
56
57
  exports.builder = (yargs) => {
57
- yargs.positional(`project_dir`, {
58
+ yargs.positional(`project_directory`, {
58
59
  type: 'string',
59
60
  describe: 'Path to a valid kumologica project directory or flow file. (Optional)'
60
61
  })
61
62
  }
62
63
 
63
- exports.handler = ({ project_dir }) => {
64
- let projectDirOrFile = project_dir || process.cwd();
64
+ exports.handler = ({ project_directory }) => {
65
+ let projectDirOrFile = project_directory || process.cwd();
65
66
  let projectFlowPath = projectDirOrFile;
66
67
 
67
68
  let isDir = isDirectory(projectDirOrFile);
@@ -76,14 +77,14 @@ exports.handler = ({ project_dir }) => {
76
77
  } else if (isDir === false){
77
78
  // do nothing as it was assumed to be a file
78
79
  } else {
79
- logError(`Directory does not exist: ${project_dir}`);
80
+ logError(`Directory does not exist: ${project_directory}`);
80
81
  process.exit(1);
81
82
  }
82
83
 
83
84
  try {
84
85
  runTest(projectFlowPath);
85
86
  } catch (e) {
86
- console.log(`${e.message}`);
87
+ logError(e.message);
87
88
  process.exit(1);
88
89
  }
89
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.1",
6
+ "version": "3.0.4",
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.1",
68
- "@kumologica/runtime": "3.0.1",
69
- "@kumologica/devkit": "3.0.1",
67
+ "@kumologica/builder": "3.0.4",
68
+ "@kumologica/runtime": "3.0.4",
69
+ "@kumologica/devkit": "3.0.4",
70
70
  "adm-zip": "^0.4.13",
71
71
  "ajv": "^8.10.0",
72
72
  "aws-sdk": "^2.513.0",