@kumologica/sdk 3.0.0
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/README.md +1 -0
- package/bin/kl.js +3 -0
- package/cli/cli.js +6 -0
- package/cli/commands/build-commands/aws.js +49 -0
- package/cli/commands/build-commands/azure.js +43 -0
- package/cli/commands/build-commands/kumohub.js +7 -0
- package/cli/commands/build.js +6 -0
- package/cli/commands/create.js +32 -0
- package/cli/commands/deploy-commands/kumohub.js +114 -0
- package/cli/commands/deploy.js +6 -0
- package/cli/commands/doc-commands/html.js +61 -0
- package/cli/commands/doc.js +6 -0
- package/cli/commands/export-commands/cloudformation.js +338 -0
- package/cli/commands/export-commands/serverless.js +164 -0
- package/cli/commands/export-commands/terraform-commands/aws.js +193 -0
- package/cli/commands/export-commands/terraform-commands/azure.js +148 -0
- package/cli/commands/export-commands/terraform.js +6 -0
- package/cli/commands/export-commands/utils/validator.js +152 -0
- package/cli/commands/export.js +6 -0
- package/cli/commands/import-commands/mulesoft.js +61 -0
- package/cli/commands/import.js +6 -0
- package/cli/commands/open.js +46 -0
- package/cli/commands/test-utils/TestSuiteController.js +359 -0
- package/cli/commands/test-utils/TestSuiteController.test.js +171 -0
- package/cli/commands/test-utils/fixtures/example3-flow.json +148 -0
- package/cli/commands/test-utils/fixtures/package.json +6 -0
- package/cli/commands/test-utils/fixtures/s3-event.js +43 -0
- package/cli/commands/test-utils/util/output.js +14 -0
- package/cli/commands/test-utils/util/updates/index.js +17 -0
- package/cli/commands/test-utils/util/updates/pkg.js +13 -0
- package/cli/commands/test-utils/util/updates/templates/default-settings.js +209 -0
- package/cli/commands/test.js +66 -0
- package/cli/commands/utils.js +14 -0
- package/package.json +158 -0
- package/src/app/lib/aws/aws-profile.js +43 -0
- package/src/app/lib/aws/ca-alexa-api.js +29 -0
- package/src/app/lib/aws/ca-apigw-api.js +216 -0
- package/src/app/lib/aws/ca-cloudwatch-api.js +78 -0
- package/src/app/lib/aws/ca-codecommit-api.js +63 -0
- package/src/app/lib/aws/ca-dynamodb-api.js +27 -0
- package/src/app/lib/aws/ca-elb-api.js +44 -0
- package/src/app/lib/aws/ca-events-api.js +27 -0
- package/src/app/lib/aws/ca-iot-api.js +105 -0
- package/src/app/lib/aws/ca-s3-api.js +115 -0
- package/src/app/lib/aws/ca-sns-api.js +38 -0
- package/src/app/lib/aws/ca-sqs-api.js +51 -0
- package/src/app/lib/aws/cf.js +439 -0
- package/src/app/lib/aws/index.js +970 -0
- package/src/app/lib/aws/kl-iam-api.js +27 -0
- package/src/app/lib/aws/kl-rekognition-api.js +66 -0
- package/src/app/lib/aws/kl-ssm-api.js +24 -0
- package/src/app/lib/azure/index.js +80 -0
- package/src/app/lib/dependencies.js +50 -0
- package/src/app/lib/kumohub/index.js +201 -0
- package/src/app/lib/runtime-loader/index.js +42 -0
- package/src/app/lib/serverless/index.js +318 -0
- package/src/app/lib/stores/aws-cloud-config-store.js +35 -0
- package/src/app/lib/stores/azure-config-store.js +24 -0
- package/src/app/lib/stores/kumohub-config-store.js +24 -0
- package/src/app/lib/stores/project-info-config-store.js +26 -0
- package/src/app/lib/stores/settings-cloud-store.js +117 -0
- package/src/app/lib/stores/settings-cloud-store.spec.js +26 -0
- package/src/app/lib/stores/settings-network-store.js +119 -0
- package/src/app/lib/stores/settings-network-store.spec.js +27 -0
- package/src/app/lib/stores/store.js +97 -0
- package/src/app/lib/stores/test-config-store.js +26 -0
- package/src/app/lib/stores/user-preference-store.js +44 -0
- package/src/app/lib/utils/editor.js +98 -0
- package/src/app/lib/utils/fix-path.js +15 -0
- package/src/app/main-process/favicon.ico +0 -0
- package/src/app/main-process/main-window.js +209 -0
- package/src/app/main-process/menu.js +219 -0
- package/src/app/main-process/modal-home.js +118 -0
- package/src/app/main-process/modal-newproject.js +119 -0
- package/src/app/main-process/modal-nodelibrary.js +90 -0
- package/src/app/main-process/modal-welcome.js +114 -0
- package/src/app/main-process/runtime-manager.js +141 -0
- package/src/app/main.js +590 -0
- package/src/app/preload.js +633 -0
- package/src/app/ui/editor-api/lib/admin/context.js +42 -0
- package/src/app/ui/editor-api/lib/admin/flow.js +55 -0
- package/src/app/ui/editor-api/lib/admin/flows.js +53 -0
- package/src/app/ui/editor-api/lib/admin/index.js +155 -0
- package/src/app/ui/editor-api/lib/admin/nodes.js +164 -0
- package/src/app/ui/editor-api/lib/auth/clients.js +17 -0
- package/src/app/ui/editor-api/lib/auth/index.js +267 -0
- package/src/app/ui/editor-api/lib/auth/permissions.js +51 -0
- package/src/app/ui/editor-api/lib/auth/strategies.js +144 -0
- package/src/app/ui/editor-api/lib/auth/tokens.js +138 -0
- package/src/app/ui/editor-api/lib/auth/users.js +122 -0
- package/src/app/ui/editor-api/lib/editor/comms.js +247 -0
- package/src/app/ui/editor-api/lib/editor/credentials.js +22 -0
- package/src/app/ui/editor-api/lib/editor/index.js +234 -0
- package/src/app/ui/editor-api/lib/editor/library.js +69 -0
- package/src/app/ui/editor-api/lib/editor/locales.js +37 -0
- package/src/app/ui/editor-api/lib/editor/projects.js +497 -0
- package/src/app/ui/editor-api/lib/editor/settings.js +118 -0
- package/src/app/ui/editor-api/lib/editor/sshkeys.js +87 -0
- package/src/app/ui/editor-api/lib/editor/theme.js +184 -0
- package/src/app/ui/editor-api/lib/editor/ui.js +149 -0
- package/src/app/ui/editor-api/lib/index.js +149 -0
- package/src/app/ui/editor-api/lib/runner/index.js +81 -0
- package/src/app/ui/editor-api/lib/util.js +51 -0
- package/src/app/ui/editor-client/README.md +10 -0
- package/src/app/ui/editor-client/constants.js +5 -0
- package/src/app/ui/editor-client/index.js +3 -0
- package/src/app/ui/editor-client/public/favicon.ico +0 -0
- package/src/app/ui/editor-client/public/red/images/bolt.png +0 -0
- package/src/app/ui/editor-client/public/red/images/debugger/continue-full.png +0 -0
- package/src/app/ui/editor-client/public/red/images/debugger/continue-outline.png +0 -0
- package/src/app/ui/editor-client/public/red/images/debugger/pause.png +0 -0
- package/src/app/ui/editor-client/public/red/images/debugger/restart.png +0 -0
- package/src/app/ui/editor-client/public/red/images/debugger/stepover.png +0 -0
- package/src/app/ui/editor-client/public/red/images/debugger/stop.png +0 -0
- package/src/app/ui/editor-client/public/red/images/deploy-flows-o.png +0 -0
- package/src/app/ui/editor-client/public/red/images/deploy-flows.png +0 -0
- package/src/app/ui/editor-client/public/red/images/deploy-full-o.png +0 -0
- package/src/app/ui/editor-client/public/red/images/deploy-full.png +0 -0
- package/src/app/ui/editor-client/public/red/images/deploy-nodes-o.png +0 -0
- package/src/app/ui/editor-client/public/red/images/deploy-nodes.png +0 -0
- package/src/app/ui/editor-client/public/red/images/deploy-reload.png +0 -0
- package/src/app/ui/editor-client/public/red/images/grip.png +0 -0
- package/src/app/ui/editor-client/public/red/images/icons/arrow-in.png +0 -0
- package/src/app/ui/editor-client/public/red/images/icons/bolt.png +0 -0
- package/src/app/ui/editor-client/public/red/images/icons/node-changed.png +0 -0
- package/src/app/ui/editor-client/public/red/images/icons/node-error.png +0 -0
- package/src/app/ui/editor-client/public/red/images/icons/node-play.png +0 -0
- package/src/app/ui/editor-client/public/red/images/kumologica-app.png +0 -0
- package/src/app/ui/editor-client/public/red/images/node-red-256.png +0 -0
- package/src/app/ui/editor-client/public/red/images/node-red-icon-black.svg +9 -0
- package/src/app/ui/editor-client/public/red/images/node-red-icon.svg +33 -0
- package/src/app/ui/editor-client/public/red/images/node-red.png +0 -0
- package/src/app/ui/editor-client/public/red/images/pw_maze_white.png +0 -0
- package/src/app/ui/editor-client/public/red/images/spin.svg +41 -0
- package/src/app/ui/editor-client/public/red/images/spinner.gif +0 -0
- package/src/app/ui/editor-client/public/red/images/subflow_tab.png +0 -0
- package/src/app/ui/editor-client/public/red/images/test-icon.png +0 -0
- package/src/app/ui/editor-client/public/red/images/typedInput/09.png +0 -0
- package/src/app/ui/editor-client/public/red/images/typedInput/az.png +0 -0
- package/src/app/ui/editor-client/public/red/images/typedInput/bin.png +0 -0
- package/src/app/ui/editor-client/public/red/images/typedInput/bool.png +0 -0
- package/src/app/ui/editor-client/public/red/images/typedInput/env.png +0 -0
- package/src/app/ui/editor-client/public/red/images/typedInput/expr.png +0 -0
- package/src/app/ui/editor-client/public/red/images/typedInput/json.png +0 -0
- package/src/app/ui/editor-client/public/red/images/typedInput/re.png +0 -0
- package/src/app/ui/editor-client/public/red/keymap.json +54 -0
- package/src/app/ui/editor-client/public/red/main-modals.js +14 -0
- package/src/app/ui/editor-client/public/red/main-modals.min.js +16 -0
- package/src/app/ui/editor-client/public/red/main.js +10 -0
- package/src/app/ui/editor-client/public/red/main.min.js +16 -0
- package/src/app/ui/editor-client/public/red/red.js +44903 -0
- package/src/app/ui/editor-client/public/red/red.min.js +16 -0
- package/src/app/ui/editor-client/public/red/style.min.css +24 -0
- package/src/app/ui/editor-client/public/vendor/ace/LICENSE +24 -0
- package/src/app/ui/editor-client/public/vendor/ace/ace.js +17 -0
- package/src/app/ui/editor-client/public/vendor/ace/ext-language_tools.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/ext-searchbox.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-css.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-handlebars.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-html.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-javascript.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-json.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-jsonata.js +1 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-markdown.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-properties.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-python.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-sql.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-swift.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-text.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-xml.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/mode-yaml.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/css.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/handlebars.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/html.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/javascript.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/json.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/jsonata.js +1 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/markdown.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/properties.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/python.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/sql.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/swift.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/text.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/xml.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/snippets/yaml.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/theme-chrome.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/theme-tomorrow.js +8 -0
- package/src/app/ui/editor-client/public/vendor/ace/worker-css.js +1 -0
- package/src/app/ui/editor-client/public/vendor/ace/worker-html.js +1 -0
- package/src/app/ui/editor-client/public/vendor/ace/worker-javascript.js +1 -0
- package/src/app/ui/editor-client/public/vendor/ace/worker-json.js +1 -0
- package/src/app/ui/editor-client/public/vendor/ace/worker-jsonata.js +2140 -0
- package/src/app/ui/editor-client/public/vendor/ace/worker-xml.js +1 -0
- package/src/app/ui/editor-client/public/vendor/beautifyjs/beautify.min.js +1 -0
- package/src/app/ui/editor-client/public/vendor/bootstrap/css/bootstrap.min.css +9 -0
- package/src/app/ui/editor-client/public/vendor/bootstrap/img/glyphicons-halflings-white.png +0 -0
- package/src/app/ui/editor-client/public/vendor/bootstrap/img/glyphicons-halflings.png +0 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/addon/active-line.js +72 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/addon/coffeescript-lint.js +47 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/addon/javascript-hint.js +157 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/addon/javascript-lint.js +63 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/addon/jshint.js +29591 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/addon/lint.css +73 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/addon/lint.js +252 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/addon/show-hint.css +36 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/addon/show-hint.js +460 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/addon/sql-hint.js +304 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/lib/codemirror.css +350 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/lib/codemirror.js +9800 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/mode/javascript.js +927 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/mode/sql.js +494 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/theme/base16-dark.css +38 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/theme/monokai.css +42 -0
- package/src/app/ui/editor-client/public/vendor/code-mirror/theme/solarized.css +168 -0
- package/src/app/ui/editor-client/public/vendor/d3-context-menu/d3-context-menu.css +43 -0
- package/src/app/ui/editor-client/public/vendor/d3-context-menu/d3-context-menu.js +87 -0
- package/src/app/ui/editor-client/public/vendor/easy-json-schema/index.js +88 -0
- package/src/app/ui/editor-client/public/vendor/font-awesome/css/font-awesome.min.css +4 -0
- package/src/app/ui/editor-client/public/vendor/font-awesome/fonts/FontAwesome.otf +0 -0
- package/src/app/ui/editor-client/public/vendor/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- package/src/app/ui/editor-client/public/vendor/font-awesome/fonts/fontawesome-webfont.svg +2671 -0
- package/src/app/ui/editor-client/public/vendor/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- package/src/app/ui/editor-client/public/vendor/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- package/src/app/ui/editor-client/public/vendor/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- package/src/app/ui/editor-client/public/vendor/icofont/fonts/icofont.eot +0 -0
- package/src/app/ui/editor-client/public/vendor/icofont/fonts/icofont.svg +2105 -0
- package/src/app/ui/editor-client/public/vendor/icofont/fonts/icofont.ttf +0 -0
- package/src/app/ui/editor-client/public/vendor/icofont/fonts/icofont.woff +0 -0
- package/src/app/ui/editor-client/public/vendor/icofont/fonts/icofont.woff2 +0 -0
- package/src/app/ui/editor-client/public/vendor/icofont/icofont.min.css +7 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/animated-overlay.gif +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- package/src/app/ui/editor-client/public/vendor/jquery/css/smoothness/jquery-ui-1.10.3.custom.min.css +5 -0
- package/src/app/ui/editor-client/public/vendor/jsonata/jsonata.min.js +183 -0
- package/src/app/ui/editor-client/public/vendor/misc/toggleswitch.css +181 -0
- package/src/app/ui/editor-client/public/vendor/misc/toggleswitch.js +48 -0
- package/src/app/ui/editor-client/public/vendor/simplemde/simplemde.min.css +7 -0
- package/src/app/ui/editor-client/public/vendor/simplemde/simplemde.min.js +15 -0
- package/src/app/ui/editor-client/public/vendor/vendor.css +0 -0
- package/src/app/ui/editor-client/public/vendor/vendor.js +125 -0
- package/src/app/ui/editor-client/public/vendor/xterm/lib/xterm.js +2 -0
- package/src/app/ui/editor-client/src/ace/README.md +50 -0
- package/src/app/ui/editor-client/src/ace/mode/nrjavascript.js +35 -0
- package/src/app/ui/editor-client/src/ace/mode/nrjavascript_worker.js +189 -0
- package/src/app/ui/editor-client/src/favicon.ico +0 -0
- package/src/app/ui/editor-client/src/images/bolt.png +0 -0
- package/src/app/ui/editor-client/src/images/debugger/continue-full.png +0 -0
- package/src/app/ui/editor-client/src/images/debugger/continue-outline.png +0 -0
- package/src/app/ui/editor-client/src/images/debugger/pause.png +0 -0
- package/src/app/ui/editor-client/src/images/debugger/restart.png +0 -0
- package/src/app/ui/editor-client/src/images/debugger/stepover.png +0 -0
- package/src/app/ui/editor-client/src/images/debugger/stop.png +0 -0
- package/src/app/ui/editor-client/src/images/deploy-flows-o.png +0 -0
- package/src/app/ui/editor-client/src/images/deploy-flows.png +0 -0
- package/src/app/ui/editor-client/src/images/deploy-full-o.png +0 -0
- package/src/app/ui/editor-client/src/images/deploy-full.png +0 -0
- package/src/app/ui/editor-client/src/images/deploy-nodes-o.png +0 -0
- package/src/app/ui/editor-client/src/images/deploy-nodes.png +0 -0
- package/src/app/ui/editor-client/src/images/deploy-reload.png +0 -0
- package/src/app/ui/editor-client/src/images/grip.png +0 -0
- package/src/app/ui/editor-client/src/images/icons/arrow-in.png +0 -0
- package/src/app/ui/editor-client/src/images/icons/bolt.png +0 -0
- package/src/app/ui/editor-client/src/images/icons/node-changed.png +0 -0
- package/src/app/ui/editor-client/src/images/icons/node-error.png +0 -0
- package/src/app/ui/editor-client/src/images/icons/node-play.png +0 -0
- package/src/app/ui/editor-client/src/images/kumologica-app.png +0 -0
- package/src/app/ui/editor-client/src/images/node-red-256.png +0 -0
- package/src/app/ui/editor-client/src/images/node-red-icon-black.svg +9 -0
- package/src/app/ui/editor-client/src/images/node-red-icon.svg +33 -0
- package/src/app/ui/editor-client/src/images/node-red.png +0 -0
- package/src/app/ui/editor-client/src/images/pw_maze_white.png +0 -0
- package/src/app/ui/editor-client/src/images/spin.svg +41 -0
- package/src/app/ui/editor-client/src/images/spinner.gif +0 -0
- package/src/app/ui/editor-client/src/images/subflow_tab.png +0 -0
- package/src/app/ui/editor-client/src/images/test-icon.png +0 -0
- package/src/app/ui/editor-client/src/images/typedInput/09.png +0 -0
- package/src/app/ui/editor-client/src/images/typedInput/az.png +0 -0
- package/src/app/ui/editor-client/src/images/typedInput/bin.png +0 -0
- package/src/app/ui/editor-client/src/images/typedInput/bool.png +0 -0
- package/src/app/ui/editor-client/src/images/typedInput/env.png +0 -0
- package/src/app/ui/editor-client/src/images/typedInput/expr.png +0 -0
- package/src/app/ui/editor-client/src/images/typedInput/json.png +0 -0
- package/src/app/ui/editor-client/src/images/typedInput/re.png +0 -0
- package/src/app/ui/editor-client/src/js/comms.js +174 -0
- package/src/app/ui/editor-client/src/js/events.js +39 -0
- package/src/app/ui/editor-client/src/js/font-awesome.js +818 -0
- package/src/app/ui/editor-client/src/js/history.js +337 -0
- package/src/app/ui/editor-client/src/js/i18n.js +81 -0
- package/src/app/ui/editor-client/src/js/jquery-addons.js +21 -0
- package/src/app/ui/editor-client/src/js/keymap.json +54 -0
- package/src/app/ui/editor-client/src/js/main-modals.js +14 -0
- package/src/app/ui/editor-client/src/js/main.js +10 -0
- package/src/app/ui/editor-client/src/js/modals/modal-home.js +162 -0
- package/src/app/ui/editor-client/src/js/modals/modal-new-project.js +86 -0
- package/src/app/ui/editor-client/src/js/modals/modal-node-library.js +255 -0
- package/src/app/ui/editor-client/src/js/modals/modal-welcome.js +102 -0
- package/src/app/ui/editor-client/src/js/nodes.js +1736 -0
- package/src/app/ui/editor-client/src/js/red.js +704 -0
- package/src/app/ui/editor-client/src/js/settings.js +275 -0
- package/src/app/ui/editor-client/src/js/text/bidi.js +116 -0
- package/src/app/ui/editor-client/src/js/text/format.js +1316 -0
- package/src/app/ui/editor-client/src/js/ui/actions.js +39 -0
- package/src/app/ui/editor-client/src/js/ui/clipboard.js +510 -0
- package/src/app/ui/editor-client/src/js/ui/common/checkboxSet.js +117 -0
- package/src/app/ui/editor-client/src/js/ui/common/editableList.js +322 -0
- package/src/app/ui/editor-client/src/js/ui/common/menu.js +277 -0
- package/src/app/ui/editor-client/src/js/ui/common/panels.js +104 -0
- package/src/app/ui/editor-client/src/js/ui/common/popover.js +268 -0
- package/src/app/ui/editor-client/src/js/ui/common/searchBox.js +98 -0
- package/src/app/ui/editor-client/src/js/ui/common/stack.js +184 -0
- package/src/app/ui/editor-client/src/js/ui/common/tabs.js +730 -0
- package/src/app/ui/editor-client/src/js/ui/common/treeList.js +170 -0
- package/src/app/ui/editor-client/src/js/ui/common/typedInput.js +819 -0
- package/src/app/ui/editor-client/src/js/ui/common/typedInputLong.js +829 -0
- package/src/app/ui/editor-client/src/js/ui/deploy.js +422 -0
- package/src/app/ui/editor-client/src/js/ui/diff.js +2225 -0
- package/src/app/ui/editor-client/src/js/ui/editor.js +3020 -0
- package/src/app/ui/editor-client/src/js/ui/editors/buffer.js +195 -0
- package/src/app/ui/editor-client/src/js/ui/editors/expression.js +627 -0
- package/src/app/ui/editor-client/src/js/ui/editors/js.js +89 -0
- package/src/app/ui/editor-client/src/js/ui/editors/json.js +107 -0
- package/src/app/ui/editor-client/src/js/ui/editors/markdown.js +267 -0
- package/src/app/ui/editor-client/src/js/ui/editors/string.js +75 -0
- package/src/app/ui/editor-client/src/js/ui/event-log.js +107 -0
- package/src/app/ui/editor-client/src/js/ui/header.js +372 -0
- package/src/app/ui/editor-client/src/js/ui/keyboard.js +565 -0
- package/src/app/ui/editor-client/src/js/ui/library.js +570 -0
- package/src/app/ui/editor-client/src/js/ui/logviewer.js +116 -0
- package/src/app/ui/editor-client/src/js/ui/notifications.js +282 -0
- package/src/app/ui/editor-client/src/js/ui/palette-editor.js +1061 -0
- package/src/app/ui/editor-client/src/js/ui/palette.js +788 -0
- package/src/app/ui/editor-client/src/js/ui/project-info.js +232 -0
- package/src/app/ui/editor-client/src/js/ui/projects/projectSettings.js +1651 -0
- package/src/app/ui/editor-client/src/js/ui/projects/projectUserSettings.js +404 -0
- package/src/app/ui/editor-client/src/js/ui/projects/projects.js +2395 -0
- package/src/app/ui/editor-client/src/js/ui/projects/tab-versionControl.js +1383 -0
- package/src/app/ui/editor-client/src/js/ui/search.js +366 -0
- package/src/app/ui/editor-client/src/js/ui/sidebar.js +409 -0
- package/src/app/ui/editor-client/src/js/ui/state.js +14 -0
- package/src/app/ui/editor-client/src/js/ui/subflow.js +748 -0
- package/src/app/ui/editor-client/src/js/ui/tab-awsDeploy.js +1427 -0
- package/src/app/ui/editor-client/src/js/ui/tab-azure.js +852 -0
- package/src/app/ui/editor-client/src/js/ui/tab-config.js +452 -0
- package/src/app/ui/editor-client/src/js/ui/tab-context.js +406 -0
- package/src/app/ui/editor-client/src/js/ui/tab-info.js +661 -0
- package/src/app/ui/editor-client/src/js/ui/tab-kumohub.js +800 -0
- package/src/app/ui/editor-client/src/js/ui/tab-nodeInfo.js +60 -0
- package/src/app/ui/editor-client/src/js/ui/tab-test.js +915 -0
- package/src/app/ui/editor-client/src/js/ui/terminal.js +240 -0
- package/src/app/ui/editor-client/src/js/ui/touch/radialMenu.js +170 -0
- package/src/app/ui/editor-client/src/js/ui/tray.js +411 -0
- package/src/app/ui/editor-client/src/js/ui/typeSearch.js +411 -0
- package/src/app/ui/editor-client/src/js/ui/ui-settings.js +422 -0
- package/src/app/ui/editor-client/src/js/ui/update-panel.js +84 -0
- package/src/app/ui/editor-client/src/js/ui/userSettings.js +673 -0
- package/src/app/ui/editor-client/src/js/ui/utils.js +1287 -0
- package/src/app/ui/editor-client/src/js/ui/view-navigator.js +169 -0
- package/src/app/ui/editor-client/src/js/ui/view-tools.js +123 -0
- package/src/app/ui/editor-client/src/js/ui/view.js +5333 -0
- package/src/app/ui/editor-client/src/js/ui/workspaces.js +498 -0
- package/src/app/ui/editor-client/src/js/user.js +282 -0
- package/src/app/ui/editor-client/src/js/validators.js +54 -0
- package/src/app/ui/editor-client/src/kumologica-app.png +0 -0
- package/src/app/ui/editor-client/src/sass/ace.scss +29 -0
- package/src/app/ui/editor-client/src/sass/bootstrap.scss +21 -0
- package/src/app/ui/editor-client/src/sass/colors.scss +76 -0
- package/src/app/ui/editor-client/src/sass/debug.scss +383 -0
- package/src/app/ui/editor-client/src/sass/diff.scss +695 -0
- package/src/app/ui/editor-client/src/sass/dragdrop.scss +37 -0
- package/src/app/ui/editor-client/src/sass/dropdownMenu.scss +93 -0
- package/src/app/ui/editor-client/src/sass/editor.scss +683 -0
- package/src/app/ui/editor-client/src/sass/flow.scss +330 -0
- package/src/app/ui/editor-client/src/sass/forms.scss +1093 -0
- package/src/app/ui/editor-client/src/sass/header.scss +502 -0
- package/src/app/ui/editor-client/src/sass/jquery.scss +152 -0
- package/src/app/ui/editor-client/src/sass/keyboard.scss +136 -0
- package/src/app/ui/editor-client/src/sass/library.scss +54 -0
- package/src/app/ui/editor-client/src/sass/mixins.scss +283 -0
- package/src/app/ui/editor-client/src/sass/modals/modalHome.scss +138 -0
- package/src/app/ui/editor-client/src/sass/modals/modalNewProject.scss +96 -0
- package/src/app/ui/editor-client/src/sass/modals/modalNodeLibrary.scss +131 -0
- package/src/app/ui/editor-client/src/sass/modals/modalWelcome.scss +102 -0
- package/src/app/ui/editor-client/src/sass/notifications.scss +118 -0
- package/src/app/ui/editor-client/src/sass/palette-editor.scss +275 -0
- package/src/app/ui/editor-client/src/sass/palette.scss +279 -0
- package/src/app/ui/editor-client/src/sass/panels.scss +61 -0
- package/src/app/ui/editor-client/src/sass/popover.scss +166 -0
- package/src/app/ui/editor-client/src/sass/project-info.scss +74 -0
- package/src/app/ui/editor-client/src/sass/projects.scss +875 -0
- package/src/app/ui/editor-client/src/sass/search.scss +201 -0
- package/src/app/ui/editor-client/src/sass/sidebar.scss +201 -0
- package/src/app/ui/editor-client/src/sass/style.scss +170 -0
- package/src/app/ui/editor-client/src/sass/tab-azure.scss +68 -0
- package/src/app/ui/editor-client/src/sass/tab-cloud.scss +67 -0
- package/src/app/ui/editor-client/src/sass/tab-config.scss +100 -0
- package/src/app/ui/editor-client/src/sass/tab-context.scss +54 -0
- package/src/app/ui/editor-client/src/sass/tab-info.scss +307 -0
- package/src/app/ui/editor-client/src/sass/tab-kumohub.scss +68 -0
- package/src/app/ui/editor-client/src/sass/tab-test.scss +257 -0
- package/src/app/ui/editor-client/src/sass/tabs.scss +395 -0
- package/src/app/ui/editor-client/src/sass/terminal.scss +246 -0
- package/src/app/ui/editor-client/src/sass/ui/common/checkboxSet.scss +29 -0
- package/src/app/ui/editor-client/src/sass/ui/common/editableList.scss +81 -0
- package/src/app/ui/editor-client/src/sass/ui/common/nodeList.scss +65 -0
- package/src/app/ui/editor-client/src/sass/ui/common/searchBox.scss +77 -0
- package/src/app/ui/editor-client/src/sass/ui/common/stack.scss +26 -0
- package/src/app/ui/editor-client/src/sass/ui/common/treeList.scss +108 -0
- package/src/app/ui/editor-client/src/sass/ui/common/typedInput.scss +181 -0
- package/src/app/ui/editor-client/src/sass/ui/common/typedInputLong.scss +183 -0
- package/src/app/ui/editor-client/src/sass/ui-settings.scss +119 -0
- package/src/app/ui/editor-client/src/sass/update-panel.scss +18 -0
- package/src/app/ui/editor-client/src/sass/userSettings.scss +93 -0
- package/src/app/ui/editor-client/src/sass/widgetStyle.scss +23 -0
- package/src/app/ui/editor-client/src/sass/workspace.scss +123 -0
- package/src/app/ui/editor-client/src/sass/workspaceToolbar.scss +85 -0
- package/src/app/ui/editor-client/src/vendor/ace/LICENSE +24 -0
- package/src/app/ui/editor-client/src/vendor/ace/ace.js +17 -0
- package/src/app/ui/editor-client/src/vendor/ace/ext-language_tools.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/ext-searchbox.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-css.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-handlebars.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-html.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-javascript.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-json.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-markdown.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-properties.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-python.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-sql.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-swift.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-text.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-xml.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/mode-yaml.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/css.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/handlebars.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/html.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/javascript.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/json.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/markdown.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/properties.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/python.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/sql.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/swift.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/text.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/xml.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/snippets/yaml.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/theme-chrome.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/theme-tomorrow.js +8 -0
- package/src/app/ui/editor-client/src/vendor/ace/worker-css.js +1 -0
- package/src/app/ui/editor-client/src/vendor/ace/worker-html.js +1 -0
- package/src/app/ui/editor-client/src/vendor/ace/worker-javascript.js +1 -0
- package/src/app/ui/editor-client/src/vendor/ace/worker-json.js +1 -0
- package/src/app/ui/editor-client/src/vendor/ace/worker-xml.js +1 -0
- package/src/app/ui/editor-client/src/vendor/beautifyjs/beautify.min.js +1 -0
- package/src/app/ui/editor-client/src/vendor/bootstrap/css/bootstrap.css +5406 -0
- package/src/app/ui/editor-client/src/vendor/bootstrap/css/bootstrap.min.css +9 -0
- package/src/app/ui/editor-client/src/vendor/bootstrap/img/glyphicons-halflings-white.png +0 -0
- package/src/app/ui/editor-client/src/vendor/bootstrap/img/glyphicons-halflings.png +0 -0
- package/src/app/ui/editor-client/src/vendor/bootstrap/js/bootstrap.min.js +6 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/addon/active-line.js +72 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/addon/coffeescript-lint.js +47 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/addon/javascript-hint.js +157 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/addon/javascript-lint.js +63 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/addon/jshint.js +29591 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/addon/lint.css +73 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/addon/lint.js +252 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/addon/show-hint.css +36 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/addon/show-hint.js +460 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/addon/sql-hint.js +304 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/lib/codemirror.css +350 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/lib/codemirror.js +9800 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/mode/javascript.js +927 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/mode/sql.js +494 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/theme/base16-dark.css +38 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/theme/monokai.css +42 -0
- package/src/app/ui/editor-client/src/vendor/code-mirror/theme/solarized.css +168 -0
- package/src/app/ui/editor-client/src/vendor/d3/d3.v3.min.js +4 -0
- package/src/app/ui/editor-client/src/vendor/d3/d3.v4.min.js +2 -0
- package/src/app/ui/editor-client/src/vendor/d3-context-menu/d3-context-menu.css +43 -0
- package/src/app/ui/editor-client/src/vendor/d3-context-menu/d3-context-menu.js +87 -0
- package/src/app/ui/editor-client/src/vendor/easy-json-schema/index.js +88 -0
- package/src/app/ui/editor-client/src/vendor/font-awesome/css/font-awesome.min.css +4 -0
- package/src/app/ui/editor-client/src/vendor/font-awesome/fonts/FontAwesome.otf +0 -0
- package/src/app/ui/editor-client/src/vendor/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- package/src/app/ui/editor-client/src/vendor/font-awesome/fonts/fontawesome-webfont.svg +2671 -0
- package/src/app/ui/editor-client/src/vendor/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- package/src/app/ui/editor-client/src/vendor/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- package/src/app/ui/editor-client/src/vendor/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- package/src/app/ui/editor-client/src/vendor/i18next/i18next.min.js +5 -0
- package/src/app/ui/editor-client/src/vendor/icofont/fonts/icofont.eot +0 -0
- package/src/app/ui/editor-client/src/vendor/icofont/fonts/icofont.svg +2105 -0
- package/src/app/ui/editor-client/src/vendor/icofont/fonts/icofont.ttf +0 -0
- package/src/app/ui/editor-client/src/vendor/icofont/fonts/icofont.woff +0 -0
- package/src/app/ui/editor-client/src/vendor/icofont/fonts/icofont.woff2 +0 -0
- package/src/app/ui/editor-client/src/vendor/icofont/icofont.min.css +7 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/animated-overlay.gif +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- package/src/app/ui/editor-client/src/vendor/jquery/css/smoothness/jquery-ui-1.10.3.custom.min.css +5 -0
- package/src/app/ui/editor-client/src/vendor/jquery/js/jquery-1.11.3.min.js +5 -0
- package/src/app/ui/editor-client/src/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js +7 -0
- package/src/app/ui/editor-client/src/vendor/jquery/js/jquery.ui.touch-punch.min.js +11 -0
- package/src/app/ui/editor-client/src/vendor/jsonata/formatter.js +183 -0
- package/src/app/ui/editor-client/src/vendor/jsonata/mode-jsonata.js +134 -0
- package/src/app/ui/editor-client/src/vendor/jsonata/snippets-jsonata.js +11 -0
- package/src/app/ui/editor-client/src/vendor/jsonata/worker-jsonata.js +2140 -0
- package/src/app/ui/editor-client/src/vendor/marked/marked.min.js +6 -0
- package/src/app/ui/editor-client/src/vendor/misc/toggleswitch.css +181 -0
- package/src/app/ui/editor-client/src/vendor/misc/toggleswitch.js +48 -0
- package/src/app/ui/editor-client/templates/index.mst +314 -0
- package/src/app/ui/editor-client/templates/modals/modalHome.mst +107 -0
- package/src/app/ui/editor-client/templates/modals/modalNewProject.mst +104 -0
- package/src/app/ui/editor-client/templates/modals/modalNodeLibrary.mst +72 -0
- package/src/app/ui/editor-client/templates/modals/modalWelcome.mst +111 -0
- package/src/assets/eula.txt +170 -0
- package/src/assets/icon.icns +0 -0
- package/src/assets/kumologica-app.png +0 -0
- package/src/assets/license_en.txt +170 -0
|
@@ -0,0 +1,970 @@
|
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const AWS = require('aws-sdk');
|
|
4
|
+
const AdmZip = require('adm-zip');
|
|
5
|
+
const util = require('util');
|
|
6
|
+
const exec = util.promisify(require('child_process').exec);
|
|
7
|
+
const rimraf = require('rimraf');
|
|
8
|
+
const { codegen } = require('@kumologica/builder');
|
|
9
|
+
const AWSCFTemplate = require('./cf');
|
|
10
|
+
const CAAWSCloudWatch = require('./ca-cloudwatch-api');
|
|
11
|
+
const CAAWSIot = require('./ca-iot-api');
|
|
12
|
+
const CAS3 = require('./ca-s3-api');
|
|
13
|
+
const CASNS = require('./ca-sns-api');
|
|
14
|
+
const CASQS = require('./ca-sqs-api');
|
|
15
|
+
const CAAWSApiGateway = require('./ca-apigw-api');
|
|
16
|
+
const CADynamoDb = require('./ca-dynamodb-api');
|
|
17
|
+
const CAElb = require('./ca-elb-api');
|
|
18
|
+
const CAEvents = require('./ca-events-api');
|
|
19
|
+
const CAAlexa = require('./ca-alexa-api');
|
|
20
|
+
const CACodeCommit = require('./ca-codecommit-api');
|
|
21
|
+
const AWSProfile = require('./aws-profile');
|
|
22
|
+
const KLIAM = require('./kl-iam-api');
|
|
23
|
+
const { openFileOnEditor } = require('../utils/editor');
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* sample events:
|
|
27
|
+
* https://docs.aws.amazon.com/lambda/latest/dg/lambda-services.html
|
|
28
|
+
*/
|
|
29
|
+
class AWSDeployer {
|
|
30
|
+
constructor(terminal) {
|
|
31
|
+
this.term = terminal;
|
|
32
|
+
this.awsProfile = new AWSProfile();
|
|
33
|
+
|
|
34
|
+
AWS.config.apiVersions = {
|
|
35
|
+
cloudformation: '2010-05-15',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async initAWS(profile) {
|
|
40
|
+
AWS.config.credentials = new AWS.SharedIniFileCredentials({profile: profile});
|
|
41
|
+
AWS.config.profile = profile; // this is not AWS property
|
|
42
|
+
|
|
43
|
+
const region = await this.awsProfile.getRegion(profile);
|
|
44
|
+
AWS.config.update({region: region});
|
|
45
|
+
|
|
46
|
+
this.cw = false;
|
|
47
|
+
|
|
48
|
+
this.iot = new CAAWSIot(this.log.bind(this));
|
|
49
|
+
this.apiGateway = new CAAWSApiGateway(this.log.bind(this));
|
|
50
|
+
this.dynamoDb = new CADynamoDb(this.log.bind(this));
|
|
51
|
+
this.cf = new AWS.CloudFormation();
|
|
52
|
+
this.s3 = new CAS3(this.log.bind(this));
|
|
53
|
+
this.sns = new CASNS(this.log.bind(this));
|
|
54
|
+
this.sqs = new CASQS(this.log.bind(this));
|
|
55
|
+
this.lambdaApi = new AWS.Lambda();
|
|
56
|
+
this.cfTemplate = new AWSCFTemplate();
|
|
57
|
+
this.cwLogs = new CAAWSCloudWatch(this.logCloud.bind(this));
|
|
58
|
+
this.cwevents = new AWS.CloudWatchEvents();
|
|
59
|
+
this.cognito = new AWS.CognitoIdentityServiceProvider();
|
|
60
|
+
this.elb = new CAElb(this.log.bind(this));
|
|
61
|
+
this.events = new CAEvents(this.log.bind(this));
|
|
62
|
+
this.alexa = new CAAlexa(this.log.bind(this));
|
|
63
|
+
this.codecommit = new CACodeCommit(this.log.bind(this));
|
|
64
|
+
this.iam = new KLIAM(this.log.bind(this));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
chalk(c, t) {
|
|
68
|
+
if (c == 'whiteBright') {
|
|
69
|
+
c = '#FFFFFF';
|
|
70
|
+
} else if (c == 'redBright') {
|
|
71
|
+
c = '#FF0000';
|
|
72
|
+
} else if (c == 'yellowBright') {
|
|
73
|
+
c = '#FFFF00';
|
|
74
|
+
} else if (c == 'greenBright') {
|
|
75
|
+
c = '#00FF00';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return `<span style="color: ${c}">${t}</span>`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
log(text, calog = true) {
|
|
82
|
+
var t = text;
|
|
83
|
+
|
|
84
|
+
if (calog && this.chalk) {
|
|
85
|
+
t = `Kumologica: ${this.chalk('#F5DEB3', text)}`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (this.term) {
|
|
89
|
+
this.term.emit('terminal-output', t);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
logCloud(text) {
|
|
94
|
+
if (this.term) {
|
|
95
|
+
this.term.emit('terminal-cloud', `${text}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
sanitizeLambdaName(name) {
|
|
100
|
+
|
|
101
|
+
return name
|
|
102
|
+
.replace('.json', '')
|
|
103
|
+
.trim()
|
|
104
|
+
.replace(/^@/, '')
|
|
105
|
+
.replace(/[^a-zA-Z0-9-]/g, '-')
|
|
106
|
+
.substr(0, 140);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
prepare(projectDir, flowFileName, originaLambdaName) {
|
|
110
|
+
const deployDir = projectDir + '/deploy';
|
|
111
|
+
|
|
112
|
+
const flowName = flowFileName.replace('.json', '');
|
|
113
|
+
|
|
114
|
+
// setup deployment directory
|
|
115
|
+
fs.ensureDirSync(deployDir);
|
|
116
|
+
fs.emptyDirSync(deployDir);
|
|
117
|
+
fs.ensureDirSync(deployDir + '/node_modules');
|
|
118
|
+
|
|
119
|
+
// copy project files
|
|
120
|
+
codegen.generateProjectCode(
|
|
121
|
+
deployDir,
|
|
122
|
+
flowFileName
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
this.processPackageJson(projectDir, deployDir);
|
|
126
|
+
|
|
127
|
+
const zipFileName = `${flowName}/lambda${Date.now()}.zip`;
|
|
128
|
+
const lambdaName = this.sanitizeLambdaName(originaLambdaName);
|
|
129
|
+
|
|
130
|
+
const functionName = `kumologica-${lambdaName}-lambda`;
|
|
131
|
+
const stackName = `kumologica-${lambdaName}-stack`;
|
|
132
|
+
const roleName = `kumologica-${lambdaName}-role`;
|
|
133
|
+
return {
|
|
134
|
+
deployDir,
|
|
135
|
+
flowName,
|
|
136
|
+
zipFileName,
|
|
137
|
+
functionName,
|
|
138
|
+
stackName,
|
|
139
|
+
roleName,
|
|
140
|
+
lambdaName,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
processPackageJson(projectDir, deployDir) {
|
|
145
|
+
|
|
146
|
+
const pckg = this.loadJsonFile(path.join(projectDir, 'package.json'));
|
|
147
|
+
|
|
148
|
+
// ensure dependencies contain runtime
|
|
149
|
+
if (!pckg.dependencies["@kumologica/runtime"]) {
|
|
150
|
+
pckg.dependencies["@kumologica/runtime"] = `^${pckg.version.substr(0, 1)}`;
|
|
151
|
+
this.createFile(deployDir, 'package.json', JSON.stringify(pckg));
|
|
152
|
+
|
|
153
|
+
} else {
|
|
154
|
+
fs.copySync(
|
|
155
|
+
path.join(projectDir, 'package.json'),
|
|
156
|
+
path.join(deployDir, 'package.json')
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (pckg.files) {
|
|
161
|
+
pckg.files.forEach(f => {
|
|
162
|
+
|
|
163
|
+
if (!["node_modules/**/*", "lambda.js" ].includes(f)) {
|
|
164
|
+
fs.copySync(
|
|
165
|
+
path.join(projectDir, f),
|
|
166
|
+
path.join(deployDir, f)
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
*
|
|
175
|
+
* @param {String} flowName
|
|
176
|
+
*/
|
|
177
|
+
async prepareS3Bucket(flowName) {
|
|
178
|
+
let bucketName = undefined;
|
|
179
|
+
|
|
180
|
+
// find bucket
|
|
181
|
+
const buckets = await this.s3.getBuckets();
|
|
182
|
+
|
|
183
|
+
if (buckets) {
|
|
184
|
+
bucketName = buckets.find(function (b) {
|
|
185
|
+
return b.id.startsWith('kumologica-designer-deploy');
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
// if not found create bucket
|
|
189
|
+
|
|
190
|
+
if (!bucketName) {
|
|
191
|
+
const ts = Date.now();
|
|
192
|
+
let uniqueId = Math.random().toString(36).substring(2) + ts.toString(36);
|
|
193
|
+
bucketName = `kumologica-designer-deploy-${uniqueId}-${ts}`;
|
|
194
|
+
await this.s3.createS3Bucket(bucketName);
|
|
195
|
+
} else {
|
|
196
|
+
bucketName = bucketName.id;
|
|
197
|
+
await this.s3.deleteS3Objects(bucketName, `${flowName}/`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return bucketName;
|
|
201
|
+
}
|
|
202
|
+
/*
|
|
203
|
+
* Main function orchestrating build and deployment of lambda to aws.
|
|
204
|
+
*/
|
|
205
|
+
async deploy(projectInfo, params, profile) {
|
|
206
|
+
if (!profile) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
'AWS profile has not been provided, unable to deploy kumologica flow into AWS. Select correct profile from list.'
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const deploymentStart = Date.now();
|
|
213
|
+
var lambdaArn;
|
|
214
|
+
|
|
215
|
+
this.log(`Deployment to AWS Started:`);
|
|
216
|
+
this.log(` ${this.chalk('#F5DEB3', 'flow:')} ${this.chalk('whiteBright', projectInfo.projectFlowName)}`, false);
|
|
217
|
+
this.log(` ${this.chalk('#F5DEB3', 'working directory:')} ${this.chalk('whiteBright', projectInfo.projectDir + "/deploy")}`, false);
|
|
218
|
+
this.log(` ${this.chalk('#F5DEB3', 'lambda parameters:')} ${this.chalk('whiteBright', JSON.stringify(params))}`, false);
|
|
219
|
+
this.log(` ${this.chalk('#F5DEB3', 'AWS profile:')} ${this.chalk('whiteBright', AWS.config.profile)}`, false);
|
|
220
|
+
|
|
221
|
+
await this.initAWS(profile);
|
|
222
|
+
this.log(` ${this.chalk('#F5DEB3', 'AWS region:')} ${this.chalk('whiteBright', AWS.config.region)}`, false);
|
|
223
|
+
this.log('', false);
|
|
224
|
+
|
|
225
|
+
const settings = this.prepare(
|
|
226
|
+
projectInfo.projectDir,
|
|
227
|
+
projectInfo.projectFlowName,
|
|
228
|
+
params.functionName
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
let flowListeners = null;
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
settings.deploymentBucketName = await this.prepareS3Bucket(
|
|
235
|
+
settings.flowName
|
|
236
|
+
);
|
|
237
|
+
await this.buildLambda(settings);
|
|
238
|
+
|
|
239
|
+
const nodes = this.loadJsonFile(
|
|
240
|
+
path.join(projectInfo.projectDir, projectInfo.projectFlowName)
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
flowListeners = this.processFlow(nodes);
|
|
244
|
+
|
|
245
|
+
const stackDetails = await this.executeStack(
|
|
246
|
+
settings,
|
|
247
|
+
params,
|
|
248
|
+
deploymentStart,
|
|
249
|
+
nodes
|
|
250
|
+
);
|
|
251
|
+
lambdaArn = stackDetails.Stacks[0].Outputs[0].OutputValue;
|
|
252
|
+
|
|
253
|
+
this.log(`${this.chalk('greenBright', 'Deployment successful.')}`);
|
|
254
|
+
this.log(
|
|
255
|
+
` ${this.chalk('#F5DEB3', 'StackId:')} ${this.chalk('whiteBright',
|
|
256
|
+
stackDetails.Stacks[0].StackId
|
|
257
|
+
)}`,
|
|
258
|
+
false
|
|
259
|
+
);
|
|
260
|
+
this.log(` ${this.chalk('#F5DEB3', 'LambdaArn:')} ${this.chalk('whiteBright',lambdaArn)}`, false);
|
|
261
|
+
this.log('', false);
|
|
262
|
+
|
|
263
|
+
// this call to be moved out to the terminals panel
|
|
264
|
+
/*if (this.cw == false) {
|
|
265
|
+
this.cwLogs.startCWLogs(settings.functionName, AWS.config.region);
|
|
266
|
+
this.cw = true;
|
|
267
|
+
}*/
|
|
268
|
+
} catch (error) {
|
|
269
|
+
this.log(`${this.chalk('redBright', 'Deployment failed.')}`);
|
|
270
|
+
this.log(` ${this.chalk('redBright', error)}`);
|
|
271
|
+
} finally {
|
|
272
|
+
//this.s3.deleteS3Bucket(deploymentBucketName);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
let response = {};
|
|
276
|
+
if (lambdaArn) {
|
|
277
|
+
try {
|
|
278
|
+
response = await this.runTriggers(params, settings, lambdaArn);
|
|
279
|
+
if (response) {
|
|
280
|
+
const url = `https://${response.apiId}.execute-api.${AWS.config.region}.amazonaws.com/${response.stage}`;
|
|
281
|
+
this.printSignature(url, flowListeners);
|
|
282
|
+
}
|
|
283
|
+
} catch (error) {
|
|
284
|
+
this.log(`${this.chalk('redBright', 'Trigger creation failed.')}`);
|
|
285
|
+
this.log(` ${this.chalk('redBright', error)}`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return response;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
printSignature(url, s) {
|
|
292
|
+
this.log(' ')
|
|
293
|
+
if (s.api && s.api.length > 0) {
|
|
294
|
+
this.log('API Gateway:');
|
|
295
|
+
s.api.forEach(a => this.log(` ${(' ' + a.verb.toUpperCase()).slice(-6)} ${url}${a.url}`), this);
|
|
296
|
+
this.log('');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (s.dynamodb && s.dynamodb.length > 0) {
|
|
300
|
+
this.log('DynamoDB Streams:');
|
|
301
|
+
s.dynamodb.forEach(a => this.log(` ${a.startingPosition} ${a.stream}`), this);
|
|
302
|
+
this.log('');
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (s.s3 && s.s3.length > 0) {
|
|
306
|
+
this.log('S3:');
|
|
307
|
+
s.s3.forEach(a => this.log(` ${a.eventType} ${a.bucket}`), this);
|
|
308
|
+
this.log('');
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (s.sns && s.sns.length > 0) {
|
|
312
|
+
this.log('SNS Topics:');
|
|
313
|
+
s.sns.forEach(a => this.log(` ${a.topic}`), this);
|
|
314
|
+
this.log('');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (s.iot && s.iot.length > 0) {
|
|
318
|
+
this.log('IOT:');
|
|
319
|
+
s.iot.forEach(a => this.log(` ${a.rule} ${a.query}`), this);
|
|
320
|
+
this.log('');
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (s.alb && s.alb.length > 0) {
|
|
324
|
+
this.log('Application Load Balancer:');
|
|
325
|
+
s.alb.forEach(a => this.log(` ${a.alb} ${a.listener}`), this);
|
|
326
|
+
this.log('');
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (s.sqs && s.sqs.length > 0) {
|
|
330
|
+
this.log('SQS URL:');
|
|
331
|
+
s.sqs.forEach(a => this.log(` ${a.queueUrl}`), this);
|
|
332
|
+
this.log('');
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (s.alexa && s.alexa.length > 0) {
|
|
336
|
+
this.log('Alexa Skills:');
|
|
337
|
+
s.alexa.forEach(a => this.log(` ${a.skillId}`), this);
|
|
338
|
+
this.log('');
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (s.kinesis && s.kinesis.length > 0) {
|
|
342
|
+
this.log('Kinesis:');
|
|
343
|
+
s.kinesis.forEach(a => this.log(` ${a.startingPosition} ${a.stream}`), this);
|
|
344
|
+
this.log('');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (s.cwevents && s.cwevents.length > 0) {
|
|
348
|
+
this.log('Cloud Watch Events Rules:');
|
|
349
|
+
s.cwevents.forEach(a => this.log(` ${a.rule}`), this);
|
|
350
|
+
this.log('');
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
processFlow(flow) {
|
|
355
|
+
|
|
356
|
+
const listener = flow.filter(i => i.type == "EventListener");
|
|
357
|
+
if (!listener || listener.length == 0) {
|
|
358
|
+
throw new Error("Flow has no EventListener defined, unable to deploy to aws account.");
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const nonAWSlisteners = flow.filter(i => i.type == "EventListener" && i.provider != "aws");
|
|
362
|
+
if (nonAWSlisteners && nonAWSlisteners.length > 0) {
|
|
363
|
+
const names = nonAWSlisteners.map(l => l.name).concat();
|
|
364
|
+
this.log(`${this.chalk('yellowBright', `Warning (Invalid provider): Kumohub API Gateway Event Listeners found ${names} for AWS Account deployment.`)}`);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (nonAWSlisteners && nonAWSlisteners.length >= 0 && listener.length == nonAWSlisteners.length) {
|
|
368
|
+
throw new Error("Flow has no EventListener for AWS defined, unable to deploy to aws account.");
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// api
|
|
372
|
+
const apis = listener.filter(i => i.eventSource == 'api' && i.provider == 'aws')
|
|
373
|
+
.map(a => {return {url: a.apiUrl, verb: a.apiMethod}});
|
|
374
|
+
|
|
375
|
+
// validate if aws nodes got explicit credentials only
|
|
376
|
+
/*const awsNodes = flow.filter(i => ['Rekognition', 'S3', 'SQS', 'Cloudwatch', 'Dynamo DB', 'SNS', 'SES', 'SSM'].includes(i.type));
|
|
377
|
+
if (awsNodes && awsNodes.length > 0) {
|
|
378
|
+
awsNodes.forEach(n => {
|
|
379
|
+
if (!n.securitytype || n.securitytype != 'Credentials') {
|
|
380
|
+
throw new Error (`AWS Node ${n.name} must have explicit credentials set. Open this node and choose Credentials option.`);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}*/
|
|
384
|
+
|
|
385
|
+
const dynamodb = listener.filter(i => i.eventSource == 'dynamodb')
|
|
386
|
+
.map(a => {return {stream: a.stream, startingPosition: a.startingPosition}});
|
|
387
|
+
const s3 = listener.filter(i => i.eventSource == 's3')
|
|
388
|
+
.map(a => {return {bucket: a.bucket, eventType: a.eventType}});
|
|
389
|
+
const sns = listener.filter(i => i.eventSource == 'sns')
|
|
390
|
+
.map(a => {return {topic: a.topic}});
|
|
391
|
+
const iot = listener.filter(i => i.eventSource == 'iot')
|
|
392
|
+
.map(a => {return {rule: a.rule, query: a.query}});
|
|
393
|
+
const alb = listener.filter(i => i.eventSource == 'alb')
|
|
394
|
+
.map(a => {return {alb: a.alb, listener: a.listener}});
|
|
395
|
+
const sqs = listener.filter(i => i.eventSource == 'sqs')
|
|
396
|
+
.map(a => {return {queueUrl: a.stream}});
|
|
397
|
+
const alexa = listener.filter(i => i.eventSource == 'alexa')
|
|
398
|
+
.map(a => {return {skillId: a.skillId}});
|
|
399
|
+
const kinesis = listener.filter(i => i.eventSource == 'kinesis')
|
|
400
|
+
.map(a => {return {stream: a.stream, startingPosition: a.startingPosition}});
|
|
401
|
+
const cwevents = listener.filter(i => i.eventSource == 'cwevents')
|
|
402
|
+
.map(a => {return {rule: a.rule}});
|
|
403
|
+
|
|
404
|
+
return {
|
|
405
|
+
api: apis,
|
|
406
|
+
dynamodb: dynamodb,
|
|
407
|
+
s3: s3,
|
|
408
|
+
sns: sns,
|
|
409
|
+
iot: iot,
|
|
410
|
+
alb: alb,
|
|
411
|
+
sqs: sqs,
|
|
412
|
+
alexa: alexa,
|
|
413
|
+
kinesis: kinesis,
|
|
414
|
+
cwevents: cwevents
|
|
415
|
+
// cron: listener.filter(l => l.eventSource == 'cwevents')
|
|
416
|
+
// .map(l => {return {type: "cron", expression: l.cronexpression, id: l.id}})
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
async generateScript(projectInfo, params, profile) {
|
|
421
|
+
if (!profile) {
|
|
422
|
+
throw new Error(
|
|
423
|
+
'AWS profile has not been provided, unable to generate cloud formation script. Select correct profile from list.'
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
try {
|
|
428
|
+
this.log('Generating cloud formation script');
|
|
429
|
+
this.log(
|
|
430
|
+
` ${this.chalk('#F5DEB3', 'AWS profile:')} ${this.chalk('whiteBright', AWS.config.profile)}`,
|
|
431
|
+
false
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
await this.initAWS(profile);
|
|
435
|
+
|
|
436
|
+
this.log(` ${this.chalk('#F5DEB3', 'AWS region:')} ${this.chalk('whiteBright', AWS.config.region)}`, false);
|
|
437
|
+
|
|
438
|
+
const settings = this.prepare(projectInfo.projectDir, projectInfo.projectFlowName, params.functionName, params.description);
|
|
439
|
+
const nodes = await this.prepareNodes(this.loadJsonFile(path.join(projectInfo.projectDir, projectInfo.projectFlowName)));
|
|
440
|
+
|
|
441
|
+
settings.deploymentBucketName = await this.prepareS3Bucket(
|
|
442
|
+
settings.flowName
|
|
443
|
+
);
|
|
444
|
+
|
|
445
|
+
const lambdaCfTemplate = JSON.stringify(
|
|
446
|
+
this.cfTemplate.createCfTemplate(
|
|
447
|
+
params,
|
|
448
|
+
settings,
|
|
449
|
+
nodes,
|
|
450
|
+
AWS.config.region
|
|
451
|
+
),
|
|
452
|
+
null,
|
|
453
|
+
2
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
this.createFile(
|
|
457
|
+
settings.deployDir,
|
|
458
|
+
`cf-${projectInfo.projectFlowName}`,
|
|
459
|
+
lambdaCfTemplate
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
const scriptFileName = path.join(
|
|
463
|
+
settings.deployDir,
|
|
464
|
+
`cf-${projectInfo.projectFlowName}`
|
|
465
|
+
);
|
|
466
|
+
this.log(`Cloud formation script created: ${scriptFileName}`);
|
|
467
|
+
openFileOnEditor(scriptFileName);
|
|
468
|
+
} catch (Error) {
|
|
469
|
+
this.log(`${this.chalk('redBright', 'Script creation failed.')}`);
|
|
470
|
+
this.log(` ${this.chalk('redBright', Error)}`);
|
|
471
|
+
throw Error;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
/*
|
|
477
|
+
* Builds lambda and zips all sources.
|
|
478
|
+
*/
|
|
479
|
+
async buildLambda(settings) {
|
|
480
|
+
this.log('Building lambda...');
|
|
481
|
+
|
|
482
|
+
const npmCmd = `npm install --production --prefix "${settings.deployDir}"`;
|
|
483
|
+
const response = await exec(npmCmd, { cwd: settings.deployDir });
|
|
484
|
+
|
|
485
|
+
if (response) {
|
|
486
|
+
this.log('', false);
|
|
487
|
+
const lines = response.stdout.split('\n');
|
|
488
|
+
for (var i = 0; i < lines.length; i++) {
|
|
489
|
+
if (lines[i]) {
|
|
490
|
+
this.log(lines[i], false);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
this.log('', false);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
this.log('Excluding optional dependencies...');
|
|
497
|
+
// Remove aws-sdk library as it is provided by aws nodejs runtime.
|
|
498
|
+
// Reducing the resulting lambda zip file by more than 70%
|
|
499
|
+
rimraf.sync(path.join(settings.deployDir, 'node_modules', 'aws-sdk'));
|
|
500
|
+
|
|
501
|
+
this.log('Zipping lambda...');
|
|
502
|
+
const zip = new AdmZip();
|
|
503
|
+
zip.addLocalFolder(settings.deployDir);
|
|
504
|
+
zip.writeZip(path.join(settings.deployDir, settings.zipFileName));
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/*
|
|
508
|
+
* Uploads lambda zip file to s3 bucket, creates cloud formation template for lambda
|
|
509
|
+
* and executes create or update stack.
|
|
510
|
+
* Returns stack id
|
|
511
|
+
*/
|
|
512
|
+
async executeStack(settings, params, deploymentStartTimestamp, nodes) {
|
|
513
|
+
this.log(`Uploading zip file to bucket...`);
|
|
514
|
+
var body = fs.createReadStream(
|
|
515
|
+
path.join(settings.deployDir, settings.zipFileName)
|
|
516
|
+
);
|
|
517
|
+
|
|
518
|
+
await this.s3.upload({
|
|
519
|
+
Bucket: settings.deploymentBucketName,
|
|
520
|
+
Key: settings.zipFileName,
|
|
521
|
+
Body: body,
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
params = await this.prepareParams(params);
|
|
525
|
+
nodes = await this.prepareNodes(nodes);
|
|
526
|
+
|
|
527
|
+
const lambdaCfTemplate = this.cfTemplate.createCfTemplate(
|
|
528
|
+
params,
|
|
529
|
+
settings,
|
|
530
|
+
nodes,
|
|
531
|
+
AWS.config.region
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
const stackParams = {
|
|
535
|
+
StackName: settings.stackName,
|
|
536
|
+
Capabilities: ['CAPABILITY_NAMED_IAM'],
|
|
537
|
+
TemplateBody: JSON.stringify(lambdaCfTemplate),
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
this.log('Starting cloudformation stack...');
|
|
541
|
+
|
|
542
|
+
let stack = {};
|
|
543
|
+
try {
|
|
544
|
+
stack = await this.cf.createStack(stackParams).promise();
|
|
545
|
+
this.log('Waiting for stack create complete...');
|
|
546
|
+
await this.cf
|
|
547
|
+
.waitFor('stackCreateComplete', { StackName: stackParams.StackName })
|
|
548
|
+
.promise();
|
|
549
|
+
} catch (error) {
|
|
550
|
+
if (error.code == 'AlreadyExistsException') {
|
|
551
|
+
stack = await this.cf.updateStack(stackParams).promise();
|
|
552
|
+
this.log('Waiting for stack update complete...');
|
|
553
|
+
|
|
554
|
+
try {
|
|
555
|
+
await this.cf
|
|
556
|
+
.waitFor('stackUpdateComplete', {
|
|
557
|
+
StackName: stackParams.StackName,
|
|
558
|
+
})
|
|
559
|
+
.promise();
|
|
560
|
+
} catch (error) {
|
|
561
|
+
await this.describeStackEvents(
|
|
562
|
+
stackParams.StackName,
|
|
563
|
+
deploymentStartTimestamp
|
|
564
|
+
);
|
|
565
|
+
throw Error(error);
|
|
566
|
+
}
|
|
567
|
+
} else {
|
|
568
|
+
await this.describeStackEvents(
|
|
569
|
+
stackParams.StackName,
|
|
570
|
+
deploymentStartTimestamp
|
|
571
|
+
);
|
|
572
|
+
throw Error(error);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return this.describeStack(stackParams.StackName);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Function links additional details for parameters that are not needed
|
|
581
|
+
* in ui but are required by cloud formation
|
|
582
|
+
*
|
|
583
|
+
* @param {*} params
|
|
584
|
+
*/
|
|
585
|
+
async prepareParams(params) {
|
|
586
|
+
for (var i = 0; i < params.events.length; i++) {
|
|
587
|
+
if (params.events[i].source === 'sqs') {
|
|
588
|
+
if (!params.events[i].stream) {
|
|
589
|
+
throw Error(`Missing Trigger Parameter: SQS Queue Url.`);
|
|
590
|
+
}
|
|
591
|
+
params.events[i].stream = await this.sqs.getQueueArn(
|
|
592
|
+
params.events[i].stream
|
|
593
|
+
);
|
|
594
|
+
} else if (params.events[i].source === 'codecommit') {
|
|
595
|
+
if (!params.events[i].repository) {
|
|
596
|
+
throw Error(`Missing Trigger Parameter: CodeCommit Repository.`);
|
|
597
|
+
}
|
|
598
|
+
const repository = await this.codecommit.getRepository(
|
|
599
|
+
params.events[i].repository
|
|
600
|
+
);
|
|
601
|
+
params.events[i].repositoryArn = repository.Arn;
|
|
602
|
+
params.events[i].account = repository.accountId;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return params;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
async prepareNodes(nodes) {
|
|
609
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
610
|
+
if (nodes[i].type === 'SQS') {
|
|
611
|
+
if (!nodes[i].QueueUrl) {
|
|
612
|
+
throw Error(`Missing Node Parameter: SQS Queue Url.`);
|
|
613
|
+
}
|
|
614
|
+
nodes[i].QueueArn = await this.sqs.getQueueArn(nodes[i].QueueUrl);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return nodes;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
async runTriggers(params, settings, lambdaArn) {
|
|
621
|
+
let response = {};
|
|
622
|
+
|
|
623
|
+
if (params.events) {
|
|
624
|
+
this.log('Adding flow triggers ...');
|
|
625
|
+
|
|
626
|
+
for (var i = 0; i < params.events.length; i++) {
|
|
627
|
+
if (params.events[i].source === 's3') {
|
|
628
|
+
await this.addS3Event(
|
|
629
|
+
params.events[i],
|
|
630
|
+
settings.functionName,
|
|
631
|
+
lambdaArn
|
|
632
|
+
);
|
|
633
|
+
} else if (params.events[i].source === 'sns') {
|
|
634
|
+
await this.addSNSEvent(
|
|
635
|
+
params.events[i],
|
|
636
|
+
settings.functionName,
|
|
637
|
+
lambdaArn
|
|
638
|
+
);
|
|
639
|
+
} else if (params.events[i].source === 'cwevents') {
|
|
640
|
+
await this.addCWEvent(
|
|
641
|
+
params.events[i],
|
|
642
|
+
settings.functionName,
|
|
643
|
+
lambdaArn
|
|
644
|
+
);
|
|
645
|
+
} else if (params.events[i].source === 'cwlogs') {
|
|
646
|
+
await this.addCWLogsEvent(
|
|
647
|
+
params.events[i],
|
|
648
|
+
settings.functionName,
|
|
649
|
+
lambdaArn
|
|
650
|
+
);
|
|
651
|
+
} else if (params.events[i].source === 'cognito') {
|
|
652
|
+
await this.addCognitoEvent(
|
|
653
|
+
params.events[i],
|
|
654
|
+
settings.functionName,
|
|
655
|
+
lambdaArn
|
|
656
|
+
);
|
|
657
|
+
} else if (params.events[i].source === 'alexa') {
|
|
658
|
+
await this.addAlexaEvent(
|
|
659
|
+
params.events[i],
|
|
660
|
+
settings.functionName,
|
|
661
|
+
lambdaArn
|
|
662
|
+
);
|
|
663
|
+
} else if (params.events[i].source === 'codecommit') {
|
|
664
|
+
await this.addCodeCommitEvent(
|
|
665
|
+
params.events[i],
|
|
666
|
+
settings.functionName,
|
|
667
|
+
lambdaArn
|
|
668
|
+
);
|
|
669
|
+
} else if (params.events[i].source === 'iot') {
|
|
670
|
+
var rule = await this.iot.addTrigger(
|
|
671
|
+
params.events[i],
|
|
672
|
+
settings.functionName,
|
|
673
|
+
lambdaArn
|
|
674
|
+
);
|
|
675
|
+
if (rule) {
|
|
676
|
+
await this.addLambdaPermission(
|
|
677
|
+
'iot.amazonaws.com',
|
|
678
|
+
settings.functionName,
|
|
679
|
+
null,
|
|
680
|
+
rule.ruleArn
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
} else if (params.events[i].source === 'api') {
|
|
684
|
+
const newApiId = await this.apiGateway.addTrigger(
|
|
685
|
+
params.events[i],
|
|
686
|
+
settings.functionName,
|
|
687
|
+
lambdaArn
|
|
688
|
+
);
|
|
689
|
+
|
|
690
|
+
response.apiId = newApiId? newApiId: params.events[i].api;
|
|
691
|
+
response.stage = params.events[i].stage;
|
|
692
|
+
|
|
693
|
+
//arn:aws:lambda:ap-southeast-2:640233474616:function:kumologica-aws-inbound-test-flow-lambda
|
|
694
|
+
const lambdaArnParts = lambdaArn.split(':');
|
|
695
|
+
const apiArn = `arn:aws:execute-api:${lambdaArnParts[3]}:${lambdaArnParts[4]}:${params.events[i].api}/*/*/{proxy+}`;
|
|
696
|
+
await this.addLambdaPermission(
|
|
697
|
+
'apigateway.amazonaws.com',
|
|
698
|
+
settings.functionName,
|
|
699
|
+
null,
|
|
700
|
+
apiArn
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
this.log(`${this.chalk('greenBright', 'All triggers added successfully:')}`);
|
|
705
|
+
}
|
|
706
|
+
return response;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
async describeStack(stackName) {
|
|
710
|
+
return this.cf.describeStacks({ StackName: stackName }).promise();
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/*
|
|
714
|
+
* Returns events created by cloud formation for current run.
|
|
715
|
+
*/
|
|
716
|
+
async describeStackEvents(stackName, deploymentStartTimestamp) {
|
|
717
|
+
this.log('Calling describe stack events...');
|
|
718
|
+
|
|
719
|
+
const events = await this.cf
|
|
720
|
+
.describeStackEvents({ StackName: stackName })
|
|
721
|
+
.promise();
|
|
722
|
+
if (!events || events == undefined) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
var deploymentEvents = events.StackEvents.filter(
|
|
727
|
+
(event) => event.Timestamp > deploymentStartTimestamp
|
|
728
|
+
).sort((a, b) => a.Timestamp - b.Timestamp);
|
|
729
|
+
if (deploymentEvents == undefined || deploymentEvents.length == 0) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
const formatStatus = function (status, chalk) {
|
|
734
|
+
if (['CREATE_COMPLETE', 'UPDATE_COMPLETE'].includes(status)) {
|
|
735
|
+
return chalk('greenBright', status);
|
|
736
|
+
} else if (status.endsWith('_FAILED') || status.includes('ROLLBACK')) {
|
|
737
|
+
return chalk('redBright', status);
|
|
738
|
+
} else {
|
|
739
|
+
return status;
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
this.log('', false);
|
|
744
|
+
for (var i = 0; i < deploymentEvents.length; i++) {
|
|
745
|
+
this.log(
|
|
746
|
+
`${deploymentEvents[i].Timestamp.toLocaleTimeString()} - ${formatStatus(
|
|
747
|
+
deploymentEvents[i].ResourceStatus
|
|
748
|
+
, this.chalk.bind(this))} - ${deploymentEvents[i].ResourceType || ''} - ${
|
|
749
|
+
deploymentEvents[i].ResourceStatusReason || ''
|
|
750
|
+
}`,
|
|
751
|
+
false
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
this.log('', false);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
loadJsonFile(flowFileName) {
|
|
758
|
+
return JSON.parse(fs.readFileSync(flowFileName));
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
createFile(baseDir, fileName, content) {
|
|
762
|
+
fs.outputFileSync(path.join(baseDir, fileName), content, 'utf-8');
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
async addLambdaPermission(
|
|
766
|
+
principal,
|
|
767
|
+
lambdaName,
|
|
768
|
+
sourceAccount,
|
|
769
|
+
sourceArn,
|
|
770
|
+
eventSourceToken
|
|
771
|
+
) {
|
|
772
|
+
var request = {
|
|
773
|
+
Action: 'lambda:InvokeFunction',
|
|
774
|
+
FunctionName: lambdaName,
|
|
775
|
+
Principal: principal,
|
|
776
|
+
SourceAccount: sourceAccount,
|
|
777
|
+
SourceArn: sourceArn,
|
|
778
|
+
EventSourceToken: eventSourceToken,
|
|
779
|
+
StatementId: `${lambdaName}-${Date.now()}`,
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
// wait for response, the subsequent calls require permissions to be present.
|
|
783
|
+
await this.lambdaApi.addPermission(request).promise();
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
async addS3Event(event, lambdaName, lambdaArn) {
|
|
787
|
+
if (!event.bucket) {
|
|
788
|
+
throw Error(`Missing Trigger Parameter: Bucket Name.`);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
this.log(
|
|
792
|
+
`Setting lambda execution permissions for bucket ${event.bucket} ...`
|
|
793
|
+
);
|
|
794
|
+
await this.addLambdaPermission(
|
|
795
|
+
's3.amazonaws.com',
|
|
796
|
+
lambdaName,
|
|
797
|
+
event.sourceAccount,
|
|
798
|
+
`arn:aws:s3:::${event.bucket}`
|
|
799
|
+
);
|
|
800
|
+
|
|
801
|
+
await this.s3.bucketNotificationConfiguration(
|
|
802
|
+
lambdaArn,
|
|
803
|
+
event.bucket,
|
|
804
|
+
event.eventType,
|
|
805
|
+
event.prefix,
|
|
806
|
+
event.suffix
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
async addAlexaEvent(event, lambdaName, lambdaArn) {
|
|
811
|
+
this.log(`Setting configuration for alexa skill id ${event.skillID} ...`);
|
|
812
|
+
await this.addLambdaPermission(
|
|
813
|
+
'alexa-appkit.amazon.com',
|
|
814
|
+
lambdaName,
|
|
815
|
+
null,
|
|
816
|
+
null,
|
|
817
|
+
event.skillID
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
async addCodeCommitEvent(event, lambdaName, lambdaArn) {
|
|
822
|
+
this.log(
|
|
823
|
+
`Setting configuration for code commit repository ${event.repository} ...`
|
|
824
|
+
);
|
|
825
|
+
|
|
826
|
+
await this.addLambdaPermission(
|
|
827
|
+
'codecommit.amazon.com',
|
|
828
|
+
lambdaName,
|
|
829
|
+
event.account,
|
|
830
|
+
event.repositoryArn
|
|
831
|
+
);
|
|
832
|
+
|
|
833
|
+
this.log('Adding permissions for lambda to call codecommit.');
|
|
834
|
+
await this.codecommit.addLambdaPermissions(event, lambdaArn);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
async addSNSEvent(event, lambdaName, lambdaArn) {
|
|
838
|
+
await this.addLambdaPermission(
|
|
839
|
+
'sns.amazonaws.com',
|
|
840
|
+
lambdaName,
|
|
841
|
+
null,
|
|
842
|
+
event.topic
|
|
843
|
+
);
|
|
844
|
+
|
|
845
|
+
this.log(`Setting notification configuration for topic ${event.topic} ...`);
|
|
846
|
+
await this.sns.subscribe(event.topic, lambdaArn);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
async addCWEvent(event, lambdaName, lambdaArn) {
|
|
850
|
+
await this.addLambdaPermission(
|
|
851
|
+
'events.amazonaws.com',
|
|
852
|
+
lambdaName,
|
|
853
|
+
null,
|
|
854
|
+
event.rule
|
|
855
|
+
);
|
|
856
|
+
|
|
857
|
+
const ruleName = event.rule.split('rule/').pop();
|
|
858
|
+
|
|
859
|
+
this.log(
|
|
860
|
+
`Setting notification configuration for cloudwatch event ${ruleName} ...`
|
|
861
|
+
);
|
|
862
|
+
|
|
863
|
+
var params = {
|
|
864
|
+
Rule: ruleName,
|
|
865
|
+
Targets: [
|
|
866
|
+
{
|
|
867
|
+
Arn: lambdaArn,
|
|
868
|
+
Id: `${lambdaName}`,
|
|
869
|
+
},
|
|
870
|
+
],
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
await this.cwevents.putTargets(params).promise();
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchLogs.html#putSubscriptionFilter-property
|
|
878
|
+
*
|
|
879
|
+
* @param {*} event
|
|
880
|
+
* @param {*} lambdaName
|
|
881
|
+
* @param {*} lambdaArn
|
|
882
|
+
*/
|
|
883
|
+
async addCWLogsEvent(event, lambdaName, lambdaArn) {
|
|
884
|
+
//await this.addLambdaPermission("events.amazonaws.com",
|
|
885
|
+
// lambdaName, null, event.rule);
|
|
886
|
+
|
|
887
|
+
/*this.log(`Setting notification configuration for cloudwatch event ${ruleName} ...`);
|
|
888
|
+
var params = {
|
|
889
|
+
destinationArn: 'STRING_VALUE', // required
|
|
890
|
+
filterName: 'STRING_VALUE', // required
|
|
891
|
+
filterPattern: 'STRING_VALUE', // required
|
|
892
|
+
logGroupName: 'STRING_VALUE', // required
|
|
893
|
+
distribution: Random | ByLogStream,
|
|
894
|
+
roleArn: 'STRING_VALUE'
|
|
895
|
+
};*/
|
|
896
|
+
await this.cwLogs.putSubscriptionFilter(params).promise();
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
async addCognitoEvent(event, lambdaName, lambdaArn) {
|
|
900
|
+
await this.addLambdaPermission(
|
|
901
|
+
'cognito-idp.amazonaws.com',
|
|
902
|
+
lambdaName,
|
|
903
|
+
null,
|
|
904
|
+
event.identityPool
|
|
905
|
+
);
|
|
906
|
+
|
|
907
|
+
const ruleName = event.rule.split('rule/').pop();
|
|
908
|
+
|
|
909
|
+
// TODO: add cognito implementation
|
|
910
|
+
//this.log(`Setting notification configuration for cloudwatch event ${ruleName} ...`);
|
|
911
|
+
var params = {};
|
|
912
|
+
|
|
913
|
+
await this.cognito.updateUserPool(params).promise();
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
async listServices(type, profile) {
|
|
917
|
+
if (!profile) {
|
|
918
|
+
throw new Error(
|
|
919
|
+
`AWS profile has not been provided, unable to return list of ${type}. Select correct profile from list.`
|
|
920
|
+
);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
await this.initAWS(profile);
|
|
924
|
+
|
|
925
|
+
let res = null;
|
|
926
|
+
switch (type) {
|
|
927
|
+
case 'api':
|
|
928
|
+
res = await this.apiGateway.getApiGateways();
|
|
929
|
+
break;
|
|
930
|
+
case 's3':
|
|
931
|
+
res = await this.s3.getBuckets();
|
|
932
|
+
break;
|
|
933
|
+
case 'sns':
|
|
934
|
+
res = await this.sns.getTopics();
|
|
935
|
+
break;
|
|
936
|
+
case 'sqs':
|
|
937
|
+
res = await this.sqs.getQueues();
|
|
938
|
+
break;
|
|
939
|
+
case 'dynamodb':
|
|
940
|
+
res = await this.dynamoDb.listStreams();
|
|
941
|
+
break;
|
|
942
|
+
case 'cwlogs':
|
|
943
|
+
res = await this.cwLogs.listLogGroups();
|
|
944
|
+
break;
|
|
945
|
+
case 'alb':
|
|
946
|
+
res = await this.elb.listElbs();
|
|
947
|
+
break;
|
|
948
|
+
case 'cwevents':
|
|
949
|
+
res = await this.events.listRules();
|
|
950
|
+
break;
|
|
951
|
+
case 'iot':
|
|
952
|
+
res = await this.iot.listTopicRules();
|
|
953
|
+
break;
|
|
954
|
+
case 'alexa':
|
|
955
|
+
res = await this.alexa.listSkills();
|
|
956
|
+
break;
|
|
957
|
+
case 'codecommit':
|
|
958
|
+
res = await this.codecommit.listRepositories();
|
|
959
|
+
break;
|
|
960
|
+
case 'iamroles':
|
|
961
|
+
res = await this.iam.listRoles();
|
|
962
|
+
break;
|
|
963
|
+
default:
|
|
964
|
+
res = [];
|
|
965
|
+
}
|
|
966
|
+
return res;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
module.exports = AWSDeployer;
|