@kumologica/sdk 3.4.0 → 3.5.0-beta2

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.
Files changed (51) hide show
  1. package/cli/commands/create-commands/openapi.js +42 -0
  2. package/cli/commands/create.js +17 -8
  3. package/cli/commands/login.js +87 -0
  4. package/package.json +18 -7
  5. package/src/app/lib/ai/layout.js +75 -0
  6. package/src/app/lib/ai/openai.js +108 -0
  7. package/src/app/lib/ai/prompt.txt +583 -0
  8. package/src/app/lib/aws/ca-cloudwatch-api.js +2 -10
  9. package/src/app/lib/aws/ca-dynamodb-api.js +6 -10
  10. package/src/app/lib/aws/ca-elb-api.js +4 -24
  11. package/src/app/lib/aws/ca-events-api.js +5 -12
  12. package/src/app/lib/aws/ca-iot-api.js +3 -87
  13. package/src/app/lib/aws/ca-s3-api.js +17 -62
  14. package/src/app/lib/aws/ca-sns-api.js +6 -15
  15. package/src/app/lib/aws/ca-sqs-api.js +9 -6
  16. package/src/app/lib/aws/index.js +70 -86
  17. package/src/app/lib/aws/kl-apigw-api.js +40 -0
  18. package/src/app/lib/aws/kl-iam-api.js +5 -5
  19. package/src/app/lib/github/index.js +0 -17
  20. package/src/app/lib/serverless/index.js +1 -1
  21. package/src/app/lib/stores/settings-cloud-store.js +35 -2
  22. package/src/app/main.js +34 -32
  23. package/src/app/preload.js +36 -28
  24. package/src/app/ui/editor-client/public/red/red.js +924 -458
  25. package/src/app/ui/editor-client/public/red/red.min.js +2 -2
  26. package/src/app/ui/editor-client/public/red/style.min.css +1 -1
  27. package/src/app/ui/editor-client/src/js/nodes.js +19 -18
  28. package/src/app/ui/editor-client/src/js/red.js +6 -3
  29. package/src/app/ui/editor-client/src/js/ui/editor.js +70 -70
  30. package/src/app/ui/editor-client/src/js/ui/footer.js +143 -0
  31. package/src/app/ui/editor-client/src/js/ui/search.js +43 -34
  32. package/src/app/ui/editor-client/src/js/ui/sidebar.js +26 -24
  33. package/src/app/ui/editor-client/src/js/ui/signup.js +56 -0
  34. package/src/app/ui/editor-client/src/js/ui/tab-ai.js +210 -0
  35. package/src/app/ui/editor-client/src/js/ui/tab-awsDeploy.js +30 -5
  36. package/src/app/ui/editor-client/src/js/ui/tab-test.js +120 -99
  37. package/src/app/ui/editor-client/src/js/ui/update-panel.js +0 -1
  38. package/src/app/ui/editor-client/src/js/ui/view.js +201 -202
  39. package/src/app/ui/editor-client/src/sass/editor.scss +715 -645
  40. package/src/app/ui/editor-client/src/sass/sidebar.scss +21 -12
  41. package/src/app/ui/editor-client/src/sass/style.scss +101 -0
  42. package/src/app/ui/editor-client/src/sass/tab-ai.scss +68 -0
  43. package/src/app/ui/editor-client/src/sass/workspace.scss +12 -2
  44. package/src/app/ui/editor-client/templates/index.mst +41 -7
  45. package/src/server/DesignerServer.js +2 -1
  46. package/cli/.DS_Store +0 -0
  47. package/fixtures/.DS_Store +0 -0
  48. package/src/app/lib/aws/ca-apigw-api.js +0 -216
  49. package/src/app/lib/aws/ca-codecommit-api.js +0 -63
  50. package/src/app/lib/aws/kl-rekognition-api.js +0 -66
  51. package/src/app/lib/aws/kl-ssm-api.js +0 -24
@@ -1,14 +1,9 @@
1
- const AWS = require('aws-sdk');
2
-
3
- /*
4
- * AWS JS API:
5
- * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ELB.html
6
- */
7
1
  class CAElb {
8
2
 
9
3
  constructor(log) {
10
4
  this.log = log;
11
- this.elbv2 = new AWS.ELBv2();
5
+ const { ElasticLoadBalancingV2Client } = require("@aws-sdk/client-elastic-load-balancing-v2");
6
+ this.elbv2 = new ElasticLoadBalancingV2Client(config);
12
7
  }
13
8
 
14
9
  /**
@@ -16,29 +11,14 @@ class CAElb {
16
11
  */
17
12
  async listElbs() {
18
13
 
19
- const response = await this.elbv2.describeLoadBalancers({}).promise();
14
+ const { DescribeLoadBalancersCommand } = require("@aws-sdk/client-elastic-load-balancing-v2");
15
+ const response = await this.elbv2.send(new DescribeLoadBalancersCommand({}));
20
16
 
21
17
  return response.LoadBalancers.map(function(v) {
22
18
  return {id: v.LoadBalancerName, name: v.DNSName, arn: v.DNSName};
23
19
  });
24
20
  }
25
21
 
26
- /**
27
- * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ELBv2.html#describeListeners-property
28
- *
29
- * @param {string} albName
30
- */
31
- async listListeners(albName) {
32
- var params = {
33
- LoadBalancerArn: `'${albName}'`
34
- };
35
-
36
- const response = await this.elbv2.describeListeners(params).promise();
37
-
38
- return response.Listeners.map(function(v) {
39
- return {id: v.ListenerArn, name: v.Protocol + ':' + v.Port, arn: v.ListenerArn};
40
- });
41
- }
42
22
  }
43
23
 
44
24
  module.exports = CAElb;
@@ -1,22 +1,15 @@
1
- const AWS = require('aws-sdk');
2
-
3
- /*
4
- * AWS JS API:
5
- *
6
- */
7
1
  class CAEvents {
8
2
 
9
- constructor(log) {
3
+ constructor(config, log) {
10
4
  this.log = log;
11
- this.cloudwatchevents = new AWS.CloudWatchEvents();
5
+ const { CloudWatchEventsClient } = require("@aws-sdk/client-cloudwatch-events");
6
+ this.cloudwatchevents = new CloudWatchEventsClient(config);
12
7
  }
13
8
 
14
- /**
15
- * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchEvents.html#listRules-property
16
- */
17
9
  async listRules() {
18
10
 
19
- const response = await this.cloudwatchevents.listRules({}).promise();
11
+ const { ListRulesCommand } = require("@aws-sdk/client-cloudwatch-events");
12
+ const response = await this.cloudwatchevents.send(new ListRulesCommand({}));
20
13
 
21
14
  return response.Rules.map(function(v) {
22
15
  return {id: v.Arn, name: v.Name, arn: v.Arn};
@@ -1,100 +1,16 @@
1
- const AWS = require('aws-sdk');
2
1
  const jp = require('jsonpath');
3
2
 
4
3
  class CAAWSIot {
5
4
 
6
5
  constructor(log) {
7
6
  this.log = log;
8
- this.iot = new AWS.Iot();
7
+ const { IoTClient } = require("@aws-sdk/client-iot");
9
8
  }
10
9
 
11
- /**
12
- * Returns IOT Event Rule
13
- * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Iot.html#getTopicRule-property
14
- * @param {} event IOT Event configuration
15
- *
16
- * @returns {JSON} Topic rule definition
17
- */
18
- async getTopicRule(event) {
19
- var rule;
20
- try {
21
- rule = await this.iot.getTopicRule({ruleName: event.rule}).promise();
22
- } catch (UnauthorizedException) {
23
- // rule doesnt exists
24
- }
25
- return rule;
26
- }
27
- /**
28
- *
29
- * @param {} event
30
- * @param {} lambdaName
31
- * @param {} lambdaArn
32
- */
33
- async addTrigger(event, lambdaName, lambdaArn) {
34
- this.log(`Adding trigger to the rule: ${event.rule} ...`);
35
-
36
- var rule = await this.getTopicRule(event);
37
-
38
- if (!rule && !event.query) {
39
- this.log(`Error: Unable to add trigger to the iot rule, rule ${event.rule} doesn't exists.`);
40
- this.log(" If you wish to create iot rule please provide query parameter and re-run deploy. Iot rule will be created and trigger will be added.");
41
- return;
42
- }
43
-
44
- if (rule) {
45
- var lambdaRule = jp.query(rule, `rule.actions[?(@.lambda.functionArn=='${lambdaArn}')]`);
46
- if (lambdaRule.length == 0) {
47
- await this.iot.replaceTopicRule(this.replaceTopicRuleRequest(rule, lambdaArn)).promise();
48
- return rule;
49
- }
50
-
51
- } else {
52
- await this.iot.createTopicRule(this.createTopicRuleRequest(event, lambdaArn)).promise();
53
- return this.getTopicRule(event);
54
- }
55
- }
56
-
57
- replaceTopicRuleRequest(rule, lambdaArn) {
58
-
59
- rule.rule.actions.push({
60
- lambda: {
61
- functionArn: lambdaArn
62
- }
63
- });
64
-
65
- return {
66
- ruleName: rule.rule.ruleName,
67
- topicRulePayload: {
68
- actions: rule.rule.actions,
69
- sql: rule.rule.sql,
70
- awsIotSqlVersion: rule.rule.awsIotSqlVersion,
71
- description: rule.rule.description,
72
- errorAction: rule.rule.errorAction,
73
- ruleDisabled: rule.rule.ruleDisabled
74
- }
75
- }
76
- }
77
- /**
78
- * @param {} event IOT Event configuration
79
- * @param {} lambdaArn The ARN of lambda function the topic rule is attached
80
- */
81
- createTopicRuleRequest(event, lambdaArn) {
82
- return {
83
- ruleName: event.rule,
84
- topicRulePayload: {
85
- sql: event.query,
86
- ruleDisabled: false,
87
- actions: [{
88
- lambda: {
89
- functionArn: lambdaArn
90
- }
91
- }]
92
- }
93
- }
94
- }
95
10
 
96
11
  async listTopicRules() {
97
- const response = await this.iot.listTopicRules({}).promise();
12
+ const { ListTopicRulesCommand } = require("@aws-sdk/client-iot");
13
+ const response = await this.iot.send(new ListTopicRulesCommand({}));
98
14
 
99
15
  return response.rules.map(function(v) {
100
16
  return {id: v.ruleName, name: v.ruleName, arn: v.ruleArn};
@@ -1,18 +1,9 @@
1
- const AWS = require('aws-sdk');
2
-
3
- /*
4
- * Follow link:
5
- * https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
6
- *
7
- * AWS JS API:
8
- * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html
9
- */
10
1
  class CAS3 {
11
2
 
12
-
13
- constructor(log) {
3
+ constructor(config, log) {
14
4
  this.log = log;
15
- this.s3 = new AWS.S3();
5
+ const { S3Client } = require("@aws-sdk/client-s3");
6
+ this.s3 = new S3Client(config);
16
7
  }
17
8
 
18
9
  /*
@@ -23,7 +14,8 @@ class CAS3 {
23
14
  this.log(`Creating deployment bucket...`);
24
15
 
25
16
  try {
26
- await this.s3.createBucket({Bucket: bucketName}).promise();
17
+ const { CreateBucketCommand } = require("@aws-sdk/client-s3");
18
+ await this.s3.send(new CreateBucketCommand({Bucket: bucketName}));
27
19
 
28
20
  } catch (error) {
29
21
  if (error.code != "BucketAlreadyOwnedByYou") { // ignore bucket already exists
@@ -33,27 +25,27 @@ class CAS3 {
33
25
  }
34
26
 
35
27
  async upload(settings) {
36
- return this.s3.upload(settings).promise();
37
- }
38
-
39
- async putBucketNotificationConfiguration(settings) {
40
- return this.s3.putBucketNotificationConfiguration(settings).promise();
28
+ const { PutObjectCommand } = require("@aws-sdk/client-s3");
29
+
30
+ return this.s3.send(new PutObjectCommand(settings));
41
31
  }
42
32
 
43
33
  async deleteS3Objects(bucketName, key) {
44
34
 
45
- var items = await this.s3.listObjectsV2({Bucket: bucketName, Prefix: key}).promise();
35
+ const { ListObjectsV2Command } = require("@aws-sdk/client-s3");
36
+ const items = await this.s3.send(new ListObjectsV2Command({Bucket: bucketName, Prefix: key}));
46
37
 
47
38
  if (!items || !items.Contents || items.Contents.length == 0) {
48
39
  return;
49
40
  }
50
41
 
51
- var keys = items.Contents.map(function(i) {
42
+ const keys = items.Contents.map(function(i) {
52
43
  return {Key: i.Key};
53
44
  });
54
45
 
55
46
  if (keys) {
56
- await this.s3.deleteObjects({Bucket: bucketName, Delete: {Objects: keys}}).promise();
47
+ const { DeleteObjectsCommand } = require("@aws-sdk/client-s3");
48
+ await this.s3.send(new DeleteObjectsCommand({Bucket: bucketName, Delete: {Objects: keys}}));
57
49
  }
58
50
 
59
51
  }
@@ -64,52 +56,15 @@ class CAS3 {
64
56
  *
65
57
  */
66
58
  async getBuckets() {
67
- const b = await this.s3.listBuckets({}).promise();
59
+
60
+ const { ListBucketsCommand } = require("@aws-sdk/client-s3");
61
+
62
+ const b = await this.s3.send(new ListBucketsCommand({}));
68
63
 
69
64
  return b.Buckets.map(function(v) {
70
65
  return {id: v.Name, name: v.CreationDate, arn: `arn-ccc`}
71
66
  });
72
67
  }
73
-
74
- async bucketNotificationConfiguration (lambdaArn, bucket, eventType, prefix, suffix) {
75
-
76
- let configuration = await this.s3.getBucketNotificationConfiguration({Bucket: bucket}).promise();
77
-
78
- let idx = configuration.LambdaFunctionConfigurations.findIndex(c => c.LambdaFunctionArn == lambdaArn);
79
- if (idx != -1) {
80
- configuration.LambdaFunctionConfigurations.splice(idx, 1);
81
- }
82
-
83
- let lambdaConfiguration = {
84
- Events: [ eventType ],
85
- LambdaFunctionArn: lambdaArn
86
- };
87
- let filterRules = [];
88
-
89
- if (prefix) {
90
- filterRules.push({ Name: "prefix", Value: prefix });
91
- };
92
-
93
- if (suffix) {
94
- filterRules.push({ Name: "suffix", Value: suffix });
95
- }
96
-
97
- if (filterRules.length) {
98
- lambdaConfiguration.Filter = {
99
- Key: {
100
- FilterRules: filterRules
101
- }
102
- };
103
- }
104
-
105
- configuration.LambdaFunctionConfigurations.push(lambdaConfiguration);
106
- let params = {
107
- Bucket: bucket,
108
- NotificationConfiguration: configuration
109
- };
110
-
111
- return this.s3.putBucketNotificationConfiguration(params).promise();
112
- }
113
68
  }
114
69
 
115
70
  module.exports = CAS3;
@@ -1,32 +1,23 @@
1
- const AWS = require('aws-sdk');
2
-
3
1
  /*
4
2
  * AWS JS API:
5
3
  * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html
6
4
  */
7
5
  class CASNS {
8
6
 
9
- constructor(log) {
7
+ constructor(config, log) {
10
8
  this.log = log;
11
- this.sns = new AWS.SNS();
9
+ const { SNSClient } = require("@aws-sdk/client-sns");
10
+ this.sns = new SNSClient(config);
12
11
  }
13
12
 
14
- async subscribe(topic, lambdaArn) {
15
- const params = {
16
- Protocol: 'lambda',
17
- TopicArn: topic,
18
- Endpoint: lambdaArn
19
- };
20
-
21
- return this.sns.subscribe(params).promise();
22
- }
23
13
 
24
14
  /**
25
15
  *
26
16
  */
27
17
  async getTopics() {
28
-
29
- const topics = await this.sns.listTopics({}).promise();
18
+
19
+ const { ListTopicsCommand } = require("@aws-sdk/client-sns");
20
+ const topics = await this.sns.send(new ListTopicsCommand({}));
30
21
 
31
22
  return topics.Topics.map(function(v) {
32
23
  const parts = v.TopicArn.split(':');
@@ -1,14 +1,14 @@
1
- const AWS = require('aws-sdk');
2
-
3
1
  /*
4
2
  * AWS JS API:
5
3
  * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html
6
4
  */
7
5
  class CASQS {
8
6
 
9
- constructor(log) {
7
+ constructor(config, log) {
10
8
  this.log = log;
11
- this.sqs = new AWS.SQS();
9
+
10
+ const { SQSClient } = require("@aws-sdk/client-sqs");
11
+ this.sqs = new SQSClient(config);
12
12
  }
13
13
 
14
14
  /**
@@ -23,7 +23,9 @@ class CASQS {
23
23
  AttributeNames: [ "QueueArn" ]
24
24
  };
25
25
 
26
- var response = await this.sqs.getQueueAttributes(params).promise();
26
+ const { GetQueueAttributesCommand } = require("@aws-sdk/client-sqs");
27
+
28
+ const response = await this.sqs.send(new GetQueueAttributesCommand(params));
27
29
 
28
30
  return response.Attributes.QueueArn;
29
31
  }
@@ -33,7 +35,8 @@ class CASQS {
33
35
  */
34
36
  async getQueues() {
35
37
 
36
- const queues = await this.sqs.listQueues({}).promise();
38
+ const { ListQueuesCommand } = require("@aws-sdk/client-sqs");
39
+ const queues = await this.sqs.send(new ListQueuesCommand({}));
37
40
 
38
41
  if (queues && queues.QueueUrls) {
39
42
  return queues.QueueUrls.map(function(v) {