@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.
- package/cli/commands/create-commands/openapi.js +42 -0
- package/cli/commands/create.js +17 -8
- package/cli/commands/login.js +87 -0
- package/package.json +18 -7
- package/src/app/lib/ai/layout.js +75 -0
- package/src/app/lib/ai/openai.js +108 -0
- package/src/app/lib/ai/prompt.txt +583 -0
- package/src/app/lib/aws/ca-cloudwatch-api.js +2 -10
- package/src/app/lib/aws/ca-dynamodb-api.js +6 -10
- package/src/app/lib/aws/ca-elb-api.js +4 -24
- package/src/app/lib/aws/ca-events-api.js +5 -12
- package/src/app/lib/aws/ca-iot-api.js +3 -87
- package/src/app/lib/aws/ca-s3-api.js +17 -62
- package/src/app/lib/aws/ca-sns-api.js +6 -15
- package/src/app/lib/aws/ca-sqs-api.js +9 -6
- package/src/app/lib/aws/index.js +70 -86
- package/src/app/lib/aws/kl-apigw-api.js +40 -0
- package/src/app/lib/aws/kl-iam-api.js +5 -5
- package/src/app/lib/github/index.js +0 -17
- package/src/app/lib/serverless/index.js +1 -1
- package/src/app/lib/stores/settings-cloud-store.js +35 -2
- package/src/app/main.js +34 -32
- package/src/app/preload.js +36 -28
- package/src/app/ui/editor-client/public/red/red.js +924 -458
- package/src/app/ui/editor-client/public/red/red.min.js +2 -2
- package/src/app/ui/editor-client/public/red/style.min.css +1 -1
- package/src/app/ui/editor-client/src/js/nodes.js +19 -18
- package/src/app/ui/editor-client/src/js/red.js +6 -3
- package/src/app/ui/editor-client/src/js/ui/editor.js +70 -70
- package/src/app/ui/editor-client/src/js/ui/footer.js +143 -0
- package/src/app/ui/editor-client/src/js/ui/search.js +43 -34
- package/src/app/ui/editor-client/src/js/ui/sidebar.js +26 -24
- package/src/app/ui/editor-client/src/js/ui/signup.js +56 -0
- package/src/app/ui/editor-client/src/js/ui/tab-ai.js +210 -0
- package/src/app/ui/editor-client/src/js/ui/tab-awsDeploy.js +30 -5
- package/src/app/ui/editor-client/src/js/ui/tab-test.js +120 -99
- package/src/app/ui/editor-client/src/js/ui/update-panel.js +0 -1
- package/src/app/ui/editor-client/src/js/ui/view.js +201 -202
- package/src/app/ui/editor-client/src/sass/editor.scss +715 -645
- package/src/app/ui/editor-client/src/sass/sidebar.scss +21 -12
- package/src/app/ui/editor-client/src/sass/style.scss +101 -0
- package/src/app/ui/editor-client/src/sass/tab-ai.scss +68 -0
- package/src/app/ui/editor-client/src/sass/workspace.scss +12 -2
- package/src/app/ui/editor-client/templates/index.mst +41 -7
- package/src/server/DesignerServer.js +2 -1
- package/cli/.DS_Store +0 -0
- package/fixtures/.DS_Store +0 -0
- package/src/app/lib/aws/ca-apigw-api.js +0 -216
- package/src/app/lib/aws/ca-codecommit-api.js +0 -63
- package/src/app/lib/aws/kl-rekognition-api.js +0 -66
- package/src/app/lib/aws/kl-ssm-api.js +0 -24
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
right: 50px;
|
|
28
28
|
bottom: 0px;
|
|
29
29
|
width: 435px;
|
|
30
|
-
min-width:435px;
|
|
30
|
+
min-width: 435px;
|
|
31
31
|
background: #fff;
|
|
32
32
|
z-index: 10;
|
|
33
33
|
border-left: 1px solid #ddd;
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
#sidebar-views {
|
|
38
38
|
display: flex;
|
|
39
39
|
flex-direction: column;
|
|
40
|
-
height: 100
|
|
40
|
+
height: calc(100% - 23px);
|
|
41
41
|
background: #f3f3f3;
|
|
42
42
|
user-select: none;
|
|
43
43
|
width: 100%
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
#sidebar-shortcuts {
|
|
47
|
-
position:absolute;
|
|
47
|
+
position: absolute;
|
|
48
48
|
right: 0px;
|
|
49
49
|
top: 0px;
|
|
50
50
|
height: 100vh;
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
border-top-left-radius: 0px !important;
|
|
73
73
|
border-top-right-radius: 0px !important;
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
}
|
|
76
76
|
|
|
77
77
|
#sidebar.closing {
|
|
78
78
|
// background: #eee;
|
|
@@ -102,23 +102,27 @@
|
|
|
102
102
|
z-index: 11;
|
|
103
103
|
background: $background-color url(images/grip.png) no-repeat 50% 50%;
|
|
104
104
|
cursor: col-resize;
|
|
105
|
-
border-left:4px solid #f3f3f3;
|
|
105
|
+
border-left: 4px solid #f3f3f3;
|
|
106
106
|
height: 100%;
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
|
|
108
|
+
&:hover {
|
|
109
|
+
border-left: 4px solid #2979ff;
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
.sidebar-closed
|
|
113
|
+
.sidebar-closed>#sidebar {
|
|
113
114
|
display: none;
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
|
|
117
|
+
.sidebar-closed>#sidebar-separator {
|
|
116
118
|
// display: none;
|
|
117
119
|
}
|
|
118
|
-
|
|
120
|
+
|
|
121
|
+
.sidebar-closed>#workspace {
|
|
119
122
|
right: 49px !important;
|
|
120
123
|
}
|
|
121
|
-
|
|
124
|
+
|
|
125
|
+
.sidebar-closed>#editor-stack {
|
|
122
126
|
right: 8px !important;
|
|
123
127
|
}
|
|
124
128
|
|
|
@@ -149,21 +153,25 @@
|
|
|
149
153
|
.sidebar-footer-button {
|
|
150
154
|
@include component-footer-button;
|
|
151
155
|
}
|
|
156
|
+
|
|
152
157
|
.sidebar-footer-button-toggle {
|
|
153
158
|
@include component-footer-button-toggle;
|
|
154
159
|
}
|
|
160
|
+
|
|
155
161
|
.sidebar-header-button {
|
|
156
162
|
@include workspace-button;
|
|
157
163
|
font-size: 13px;
|
|
158
164
|
line-height: 13px;
|
|
159
165
|
padding: 5px 8px;
|
|
160
166
|
}
|
|
167
|
+
|
|
161
168
|
.sidebar-header-button-toggle {
|
|
162
169
|
@include workspace-button-toggle;
|
|
163
170
|
font-size: 13px;
|
|
164
171
|
line-height: 13px;
|
|
165
172
|
padding: 5px 8px;
|
|
166
173
|
}
|
|
174
|
+
|
|
167
175
|
.sidebar-header-button:not(:first-child) {
|
|
168
176
|
//border-left: none;
|
|
169
177
|
}
|
|
@@ -192,10 +200,11 @@
|
|
|
192
200
|
border-top-left-radius: 5px;
|
|
193
201
|
border-bottom-left-radius: 5px;
|
|
194
202
|
}
|
|
203
|
+
|
|
195
204
|
.sidebar-control-left {
|
|
196
205
|
display: none !important;
|
|
197
206
|
@include sidebar-control;
|
|
198
207
|
left: calc(100%);
|
|
199
208
|
border-top-right-radius: 5px;
|
|
200
209
|
border-bottom-right-radius: 5px;
|
|
201
|
-
}
|
|
210
|
+
}
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
@import 'tab-info';
|
|
49
49
|
@import 'tab-test';
|
|
50
50
|
@import 'tab-git';
|
|
51
|
+
@import 'tab-ai';
|
|
51
52
|
@import 'popover';
|
|
52
53
|
@import 'flow';
|
|
53
54
|
@import 'palette-editor';
|
|
@@ -170,3 +171,103 @@ blockquote {
|
|
|
170
171
|
color: #777;
|
|
171
172
|
}
|
|
172
173
|
}
|
|
174
|
+
|
|
175
|
+
// Footer
|
|
176
|
+
#footer {
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: row;
|
|
179
|
+
background: #f3f3f3;
|
|
180
|
+
position: absolute;
|
|
181
|
+
border-top: 1px solid #ddd;
|
|
182
|
+
bottom: 0px;
|
|
183
|
+
height: 23px;
|
|
184
|
+
width: 100%;
|
|
185
|
+
z-index: 30;
|
|
186
|
+
color: #605d5d;
|
|
187
|
+
|
|
188
|
+
#footer-core {
|
|
189
|
+
display: flex;
|
|
190
|
+
flex-direction: row;
|
|
191
|
+
width: 90%;
|
|
192
|
+
|
|
193
|
+
#launch-node-library {
|
|
194
|
+
padding: 2px 16px;
|
|
195
|
+
color: whitesmoke;
|
|
196
|
+
background-color: #333333;
|
|
197
|
+
|
|
198
|
+
&:hover {
|
|
199
|
+
cursor: pointer !important;
|
|
200
|
+
background-color: #59d894;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
#footer-runtime-ver {
|
|
205
|
+
padding: 2px 16px;
|
|
206
|
+
|
|
207
|
+
&:hover {
|
|
208
|
+
cursor: default;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
#footer-server {
|
|
213
|
+
padding: 2px 16px;
|
|
214
|
+
|
|
215
|
+
&:hover {
|
|
216
|
+
cursor: default;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
#footer-server-value {
|
|
220
|
+
padding-left: 4px;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
#footer-test {
|
|
225
|
+
padding: 2px 16px;
|
|
226
|
+
|
|
227
|
+
&:hover {
|
|
228
|
+
cursor: pointer !important;
|
|
229
|
+
background-color: white;
|
|
230
|
+
|
|
231
|
+
#footer-test-ico {
|
|
232
|
+
color: #1ac567;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
#footer-ai {
|
|
239
|
+
display: flex;
|
|
240
|
+
flex-direction: row;
|
|
241
|
+
width: 30%;
|
|
242
|
+
justify-content: flex-end;
|
|
243
|
+
padding-right: 20px;
|
|
244
|
+
|
|
245
|
+
#ask-configure-ai {
|
|
246
|
+
padding: 2px 16px;
|
|
247
|
+
color: #2979ff;
|
|
248
|
+
|
|
249
|
+
&:hover {
|
|
250
|
+
cursor: pointer !important;
|
|
251
|
+
background-color: white;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
#footer-services {
|
|
257
|
+
display: flex;
|
|
258
|
+
width: 10%;
|
|
259
|
+
justify-content: flex-end;
|
|
260
|
+
padding-right: 7px;
|
|
261
|
+
|
|
262
|
+
#footer-terminal {
|
|
263
|
+
display: flex;
|
|
264
|
+
align-items: center;
|
|
265
|
+
padding: 8px;
|
|
266
|
+
|
|
267
|
+
&:hover {
|
|
268
|
+
cursor: pointer !important;
|
|
269
|
+
background-color: white;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
.sidebar-ai-title-wrapper {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
padding-right: 13px !important;
|
|
5
|
+
height: calc(100% - 35px);
|
|
6
|
+
font-size: 14px;
|
|
7
|
+
font-weight: 600;
|
|
8
|
+
display: flex;
|
|
9
|
+
padding: 12px 0px 18px 13px;
|
|
10
|
+
|
|
11
|
+
#sidebar-title-wrapper {
|
|
12
|
+
font-size: 14px;
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#sidebar-ai-body {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
height: 80vh;
|
|
20
|
+
margin-top: 10px;
|
|
21
|
+
|
|
22
|
+
#sidebar-ai-response-wrapper {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
padding-top: 15px;
|
|
26
|
+
|
|
27
|
+
#sidebar-ai-response-message {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
background-color: white;
|
|
31
|
+
border-radius: 5px;
|
|
32
|
+
padding: 10px;
|
|
33
|
+
|
|
34
|
+
#sidebar-ai-response-action-wrapper {
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: flex-end;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#sidebar-ai-prompt {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
justify-content: flex-end;
|
|
47
|
+
height: 20vh;
|
|
48
|
+
|
|
49
|
+
#sidebar-ai-prompt-message-wrapper {
|
|
50
|
+
width: 100%;
|
|
51
|
+
|
|
52
|
+
#sidebar-ai-prompt-message {
|
|
53
|
+
width: 100%;
|
|
54
|
+
resize: none;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#sidebar-ai-prompt-actions {
|
|
59
|
+
display: flex;
|
|
60
|
+
justify-content: space-between;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#sidebar-ai-prompt-noactions {
|
|
64
|
+
display: flex;
|
|
65
|
+
justify-content: flex-end;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
padding: 4px 4px;
|
|
64
64
|
border: none;
|
|
65
65
|
}
|
|
66
|
+
|
|
66
67
|
.workspace-footer-button-toggle {
|
|
67
68
|
@include component-footer-button-toggle;
|
|
68
69
|
height: 30px;
|
|
@@ -71,12 +72,13 @@
|
|
|
71
72
|
padding: 4px 4px;
|
|
72
73
|
border: none;
|
|
73
74
|
}
|
|
75
|
+
|
|
74
76
|
#workspace-footer {
|
|
75
77
|
display: flex;
|
|
76
78
|
height: fit-content;
|
|
77
79
|
width: fit-content;
|
|
78
80
|
flex-direction: column;
|
|
79
|
-
margin-top: -
|
|
81
|
+
margin-top: -150px;
|
|
80
82
|
margin-left: 20px;
|
|
81
83
|
z-index: 2;
|
|
82
84
|
box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.1);
|
|
@@ -84,11 +86,14 @@
|
|
|
84
86
|
.button-group:not(:last-child) {
|
|
85
87
|
margin-right: 5px;
|
|
86
88
|
}
|
|
89
|
+
|
|
87
90
|
position: relative;
|
|
91
|
+
|
|
88
92
|
#btn-zoom-out {
|
|
89
93
|
border-top-left-radius: 6px;
|
|
90
94
|
border-top-right-radius: 6px;
|
|
91
95
|
}
|
|
96
|
+
|
|
92
97
|
#btn-navigate {
|
|
93
98
|
// border-bottom-left-radius: 6px;
|
|
94
99
|
// border-bottom-right-radius: 6px;
|
|
@@ -97,13 +102,16 @@
|
|
|
97
102
|
|
|
98
103
|
#workspace-tabs:not(.workspace-focussed) {
|
|
99
104
|
opacity: 0.8;
|
|
105
|
+
|
|
100
106
|
li.red-ui-tab.active a {
|
|
101
107
|
color: #666;
|
|
102
108
|
}
|
|
103
109
|
}
|
|
110
|
+
|
|
104
111
|
.workspace-disabled-icon {
|
|
105
112
|
display: none;
|
|
106
113
|
}
|
|
114
|
+
|
|
107
115
|
.workspace-disabled {
|
|
108
116
|
&.red-ui-tab {
|
|
109
117
|
border-top-style: dashed;
|
|
@@ -114,12 +122,14 @@
|
|
|
114
122
|
font-style: italic;
|
|
115
123
|
color: #aaa !important;
|
|
116
124
|
}
|
|
125
|
+
|
|
117
126
|
&.active a {
|
|
118
127
|
font-weight: normal;
|
|
119
128
|
color: #999 !important;
|
|
120
129
|
}
|
|
130
|
+
|
|
121
131
|
.workspace-disabled-icon {
|
|
122
132
|
display: inline;
|
|
123
133
|
}
|
|
124
134
|
}
|
|
125
|
-
}
|
|
135
|
+
}
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
<input type="text" placeholder="Filter nodes"></input>
|
|
164
164
|
</div>
|
|
165
165
|
<div id="palette-container" class="palette-scroll hide"></div>
|
|
166
|
-
|
|
166
|
+
<!--
|
|
167
167
|
<div id="palette-footer" style="display:flex; height: 40px; border:none; justify-content: center; overflow: hidden;">
|
|
168
168
|
<div style="display: flex; width:90%;height: 32px; padding-top:3px;">
|
|
169
169
|
<a id="launch-node-library" class="sidebar-header-button" style="padding: 8px 20px; width: 100%;" href="#">
|
|
@@ -172,6 +172,7 @@
|
|
|
172
172
|
</a>
|
|
173
173
|
</div>
|
|
174
174
|
</div>
|
|
175
|
+
-->
|
|
175
176
|
</div>
|
|
176
177
|
<div id="palette-shade" class="hide"></div>
|
|
177
178
|
</div>
|
|
@@ -259,16 +260,49 @@
|
|
|
259
260
|
<ul id="sidebar-tabs"></ul>
|
|
260
261
|
</div>
|
|
261
262
|
|
|
263
|
+
|
|
264
|
+
<div id="footer">
|
|
265
|
+
<div id="footer-core" style="display:flex; flex-direction: row">
|
|
266
|
+
<div id="launch-node-library">
|
|
267
|
+
<i class="fa fa-plus"></i>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<div id="footer-runtime-ver">
|
|
271
|
+
<i class="icofont-plugin"></i>
|
|
272
|
+
<span id="footer-runtime-value">3.5.1-beta1</span>
|
|
273
|
+
</div>
|
|
274
|
+
|
|
275
|
+
<div id="footer-server">
|
|
276
|
+
|
|
277
|
+
<i class="icofont-computer" style="font-size:14px;font-weight:bold"></i>
|
|
278
|
+
<span id="footer-server-value"> localhost:1880<span>
|
|
279
|
+
</div>
|
|
280
|
+
|
|
281
|
+
<div id="footer-test">
|
|
282
|
+
<i id="footer-test-ico" class="fa fa-play"></i>
|
|
283
|
+
<span style="padding-left: 4px"></span>
|
|
284
|
+
<span id="footer-test-value">No TestCase selected</span>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
<div id="footer-ai" style="display:none">
|
|
288
|
+
<div id="ask-configure-ai" style="display:none"><i class="fa fa-magic" aria-hidden="true"></i> Configure AI</div>
|
|
289
|
+
<div id="generate-code-ai" style="display:none">Generate Code</div>
|
|
290
|
+
<div id="explain-code-ai" style="display:none">Explain</div>
|
|
291
|
+
<div id="fix-code-ai" style="display:none">Fix</div>
|
|
292
|
+
</div>
|
|
293
|
+
<div id="footer-services">
|
|
294
|
+
<div id="footer-terminal">
|
|
295
|
+
<i class="icofont-terminal" style="font-size:16px;font-weight:bold"></i>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
</div>
|
|
300
|
+
|
|
262
301
|
</div>
|
|
263
302
|
|
|
264
303
|
<div id="full-shade" class="hide"></div>
|
|
265
|
-
|
|
266
304
|
<div id="notifications"></div>
|
|
267
|
-
|
|
268
|
-
<div id="dropTarget">
|
|
269
|
-
<div><br/><i class="fa fa-download"></i></div>
|
|
270
|
-
</div>
|
|
271
|
-
-->
|
|
305
|
+
|
|
272
306
|
<div id="update-panel">
|
|
273
307
|
<p id="update-panel-message">message here</p>
|
|
274
308
|
<div class="update-panel-buttons">
|
|
@@ -20,6 +20,7 @@ class DesignerServer {
|
|
|
20
20
|
* @param {Object} options.cliParams - Command line parameters as an object.
|
|
21
21
|
* @param {Object} options.editorApi - API object for the editor.
|
|
22
22
|
* @param {Object} options.startupEmitter - EventEmitter object for handling events.
|
|
23
|
+
* @param {string} options.platform - The platform to run on. Default LOCAL.
|
|
23
24
|
*/
|
|
24
25
|
constructor(options) {
|
|
25
26
|
|
|
@@ -35,7 +36,7 @@ class DesignerServer {
|
|
|
35
36
|
|
|
36
37
|
this.config = ConfigBuilder.getInstance().buildConfig(
|
|
37
38
|
options.flowPath,
|
|
38
|
-
PLATFORMS.LOCAL,
|
|
39
|
+
options.platform || PLATFORMS.LOCAL,
|
|
39
40
|
options.cliParams
|
|
40
41
|
);
|
|
41
42
|
}
|
package/cli/.DS_Store
DELETED
|
Binary file
|
package/fixtures/.DS_Store
DELETED
|
Binary file
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
const AWS = require('aws-sdk');
|
|
2
|
-
const jp = require('jsonpath');
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* Follow link:
|
|
6
|
-
* https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
|
|
7
|
-
*
|
|
8
|
-
* AWS JS API:
|
|
9
|
-
* https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html
|
|
10
|
-
*/
|
|
11
|
-
class CAAWSApiGateway {
|
|
12
|
-
|
|
13
|
-
constructor(log) {
|
|
14
|
-
this.log = log;
|
|
15
|
-
this.triggerStage = "";
|
|
16
|
-
this.apigateway = new AWS.APIGateway();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {} event
|
|
22
|
-
* @param {} lambdaName
|
|
23
|
-
* @param {} lambdaArn
|
|
24
|
-
*/
|
|
25
|
-
async addTrigger(event, lambdaName, lambdaArn) {
|
|
26
|
-
try {
|
|
27
|
-
this.log(`Adding trigger to the api gateway: ${event.api} ...`);
|
|
28
|
-
|
|
29
|
-
var api;
|
|
30
|
-
if (event.api == "create new") {
|
|
31
|
-
api = await this.createApi(lambdaName, lambdaName);
|
|
32
|
-
event.api = api.id;
|
|
33
|
-
}
|
|
34
|
-
const proxyId = await this.defineResource(event);
|
|
35
|
-
|
|
36
|
-
await this.defineMethod(event.api, proxyId, event.security || 'NONE', 'ANY');
|
|
37
|
-
await this.putIntegration(event.api, proxyId, 'ANY', lambdaArn);
|
|
38
|
-
await this.createDeployment(event.api, event.stage);
|
|
39
|
-
|
|
40
|
-
} catch (Error) {
|
|
41
|
-
this.log(` `, false);
|
|
42
|
-
this.log(` API Gateway Error:`, false);
|
|
43
|
-
this.log(` Unable to create trigger for api gateway: ${event.api}`, false);
|
|
44
|
-
this.log(` Stage: ${this.triggerStage}`, false);
|
|
45
|
-
this.log(` Code: ${Error.code}`, false);
|
|
46
|
-
this.log(` Message: ${Error.message}`, false);
|
|
47
|
-
this.log(` `, false);
|
|
48
|
-
throw Error;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (api) {
|
|
52
|
-
return api.id;
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async defineResource(event) {
|
|
58
|
-
const resources = await this.getResources(event);
|
|
59
|
-
const root = jp.query(resources, `items[?(@.path=='/')]`);
|
|
60
|
-
if (!root || !root.length) {
|
|
61
|
-
this.log(`Error: Unable to find root: '/' resource.`);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
var proxyId;
|
|
66
|
-
const proxy = jp.query(resources, `items[?(@.pathPart=='{proxy+}')]`);
|
|
67
|
-
|
|
68
|
-
if (!proxy || !proxy.length) {
|
|
69
|
-
proxyId = await this.createResource(root[0].id, '{proxy+}', event.api);
|
|
70
|
-
proxyId = proxyId.id;
|
|
71
|
-
} else {
|
|
72
|
-
proxyId = proxy[0].id;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return proxyId;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#getResources-property
|
|
80
|
-
*
|
|
81
|
-
* @param {} event
|
|
82
|
-
*/
|
|
83
|
-
async getResources(event) {
|
|
84
|
-
this.triggerStage = "Getting information about api gateway.";
|
|
85
|
-
return this.apigateway.getResources({ restApiId: event.api }).promise();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* AWS API:
|
|
90
|
-
* https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#createResource-property
|
|
91
|
-
*
|
|
92
|
-
* @param {} path
|
|
93
|
-
*/
|
|
94
|
-
async createResource(parentId, path, restApiId) {
|
|
95
|
-
|
|
96
|
-
this.triggerStage = `Creating api gateway resource: ${path}`;
|
|
97
|
-
var request = {
|
|
98
|
-
parentId: parentId,
|
|
99
|
-
pathPart: path,
|
|
100
|
-
restApiId: restApiId
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return this.apigateway.createResource(request).promise();
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* API Doc:
|
|
107
|
-
* https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#getMethod-property
|
|
108
|
-
*
|
|
109
|
-
* @param {} restApiId
|
|
110
|
-
* @param {} resourceId
|
|
111
|
-
* @param {} httpMethod
|
|
112
|
-
*/
|
|
113
|
-
async getMethod(restApiId, resourceId, httpMethod) {
|
|
114
|
-
var request = {
|
|
115
|
-
httpMethod: httpMethod,
|
|
116
|
-
resourceId: resourceId,
|
|
117
|
-
restApiId: restApiId
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
this.triggerStage = `Searching for http method: ${httpMethod} for resource: ${resourceId}`;
|
|
121
|
-
|
|
122
|
-
try {
|
|
123
|
-
const res = await this.apigateway.getMethod(request).promise();
|
|
124
|
-
return res;
|
|
125
|
-
} catch (NotFoundException) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* API Doc:
|
|
133
|
-
* https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#putMethod-property
|
|
134
|
-
*
|
|
135
|
-
* @param {} method='ANY'
|
|
136
|
-
*/
|
|
137
|
-
async defineMethod(restApiId, resourceId, authorizationType, httpMethod) {
|
|
138
|
-
|
|
139
|
-
// const method e
|
|
140
|
-
if (!await this.getMethod(restApiId, resourceId, httpMethod)) {
|
|
141
|
-
|
|
142
|
-
var request = {
|
|
143
|
-
authorizationType: authorizationType,
|
|
144
|
-
httpMethod: httpMethod,
|
|
145
|
-
resourceId: resourceId,
|
|
146
|
-
restApiId: restApiId
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
this.triggerStage = `Defining http method: ${httpMethod} ${resourceId}`;
|
|
150
|
-
return this.apigateway.putMethod(request).promise();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* API Doc:
|
|
155
|
-
* https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#putIntegration-property
|
|
156
|
-
*
|
|
157
|
-
* @param {} restApiId
|
|
158
|
-
* @param {} resourceId
|
|
159
|
-
* @param {} authorizationType
|
|
160
|
-
* @param {} method
|
|
161
|
-
* @param {} lambdaArn
|
|
162
|
-
*/
|
|
163
|
-
async putIntegration(restApiId, resourceId, httpMethod, lambdaArn) {
|
|
164
|
-
//arn:aws:lambda:ap-southeast-2:640233474616:function:kumologica-aws-inbound-test-flow-lambda
|
|
165
|
-
const region = lambdaArn.split(':')[3];
|
|
166
|
-
|
|
167
|
-
var request = {
|
|
168
|
-
httpMethod: httpMethod,
|
|
169
|
-
resourceId: resourceId,
|
|
170
|
-
restApiId: restApiId,
|
|
171
|
-
type: 'AWS_PROXY', //HTTP | AWS | MOCK | HTTP_PROXY | AWS_PROXY
|
|
172
|
-
integrationHttpMethod: 'POST',
|
|
173
|
-
uri: `arn:aws:apigateway:${region}:lambda:path/2015-03-31/functions/${lambdaArn}/invocations`
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
this.triggerStage = `Creating aws proxy integration`;
|
|
177
|
-
return this.apigateway.putIntegration(request).promise();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
async createDeployment(restApiId, stage) {
|
|
181
|
-
// aws apigateway create-deployment --rest-api-id te6si5ach7 --stage-name test
|
|
182
|
-
|
|
183
|
-
this.triggerStage = "Creating api gateway deployment";
|
|
184
|
-
|
|
185
|
-
var request = {
|
|
186
|
-
restApiId: restApiId,
|
|
187
|
-
stageName: stage
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
return this.apigateway.createDeployment(request).promise();
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
async getApiGateways() {
|
|
194
|
-
const api = await this.apigateway.getRestApis({}).promise();
|
|
195
|
-
|
|
196
|
-
return api.items.map(function(v) {
|
|
197
|
-
return {id: v.id, name: v.name, arn: `arn-ccc`}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
async createApi(name, description) {
|
|
202
|
-
var params = {
|
|
203
|
-
name: name,
|
|
204
|
-
apiKeySource: "HEADER",
|
|
205
|
-
description: description,
|
|
206
|
-
endpointConfiguration: {
|
|
207
|
-
types: [
|
|
208
|
-
"REGIONAL"
|
|
209
|
-
]
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
return this.apigateway.createRestApi(params).promise();
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
module.exports = CAAWSApiGateway;
|