@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,1736 @@
|
|
|
1
|
+
RED.nodes = (function () {
|
|
2
|
+
var node_defs = {};
|
|
3
|
+
var nodes = [];
|
|
4
|
+
var configNodes = {};
|
|
5
|
+
var links = [];
|
|
6
|
+
var defaultWorkspace;
|
|
7
|
+
var workspaces = {};
|
|
8
|
+
var workspacesOrder = [];
|
|
9
|
+
var subflows = {};
|
|
10
|
+
var loadedFlowVersion = null;
|
|
11
|
+
|
|
12
|
+
var initialLoad;
|
|
13
|
+
|
|
14
|
+
var dirty = false;
|
|
15
|
+
|
|
16
|
+
function setDirty(d) {
|
|
17
|
+
dirty = d;
|
|
18
|
+
RED.events.emit('nodes:change', { dirty: dirty });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var registry = (function () {
|
|
22
|
+
var moduleList = {};
|
|
23
|
+
var nodeList = [];
|
|
24
|
+
var nodeSets = {};
|
|
25
|
+
var typeToId = {};
|
|
26
|
+
var nodeDefinitions = {};
|
|
27
|
+
var iconSets = {};
|
|
28
|
+
|
|
29
|
+
nodeDefinitions['tab'] = {
|
|
30
|
+
defaults: {
|
|
31
|
+
label: { value: '' },
|
|
32
|
+
disabled: { value: false },
|
|
33
|
+
info: { value: '' },
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var exports = {
|
|
38
|
+
setModulePendingUpdated: function (module, version) {
|
|
39
|
+
moduleList[module].pending_version = version;
|
|
40
|
+
RED.events.emit('registry:module-updated', {
|
|
41
|
+
module: module,
|
|
42
|
+
version: version,
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
getModule: function (module) {
|
|
46
|
+
return moduleList[module];
|
|
47
|
+
},
|
|
48
|
+
getNodeSetForType: function (nodeType) {
|
|
49
|
+
return exports.getNodeSet(typeToId[nodeType]);
|
|
50
|
+
},
|
|
51
|
+
getModuleList: function () {
|
|
52
|
+
return moduleList;
|
|
53
|
+
},
|
|
54
|
+
getNodeList: function () {
|
|
55
|
+
return nodeList;
|
|
56
|
+
},
|
|
57
|
+
getNodeTypes: function () {
|
|
58
|
+
return Object.keys(nodeDefinitions);
|
|
59
|
+
},
|
|
60
|
+
setNodeList: function (list) {
|
|
61
|
+
nodeList = [];
|
|
62
|
+
for (var i = 0; i < list.length; i++) {
|
|
63
|
+
var ns = list[i];
|
|
64
|
+
exports.addNodeSet(ns);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
addNodeSet: function (ns) {
|
|
68
|
+
ns.added = false;
|
|
69
|
+
nodeSets[ns.id] = ns;
|
|
70
|
+
for (var j = 0; j < ns.types.length; j++) {
|
|
71
|
+
typeToId[ns.types[j]] = ns.id;
|
|
72
|
+
}
|
|
73
|
+
nodeList.push(ns);
|
|
74
|
+
|
|
75
|
+
moduleList[ns.module] = moduleList[ns.module] || {
|
|
76
|
+
name: ns.module,
|
|
77
|
+
version: ns.version,
|
|
78
|
+
local: ns.local,
|
|
79
|
+
sets: {},
|
|
80
|
+
};
|
|
81
|
+
if (ns.pending_version) {
|
|
82
|
+
moduleList[ns.module].pending_version = ns.pending_version;
|
|
83
|
+
}
|
|
84
|
+
moduleList[ns.module].sets[ns.name] = ns;
|
|
85
|
+
RED.events.emit('registry:node-set-added', ns);
|
|
86
|
+
},
|
|
87
|
+
removeNodeSet: function (id) {
|
|
88
|
+
var ns = nodeSets[id];
|
|
89
|
+
for (var j = 0; j < ns.types.length; j++) {
|
|
90
|
+
delete typeToId[ns.types[j]];
|
|
91
|
+
}
|
|
92
|
+
delete nodeSets[id];
|
|
93
|
+
for (var i = 0; i < nodeList.length; i++) {
|
|
94
|
+
if (nodeList[i].id === id) {
|
|
95
|
+
nodeList.splice(i, 1);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
delete moduleList[ns.module].sets[ns.name];
|
|
100
|
+
if (Object.keys(moduleList[ns.module].sets).length === 0) {
|
|
101
|
+
delete moduleList[ns.module];
|
|
102
|
+
}
|
|
103
|
+
RED.events.emit('registry:node-set-removed', ns);
|
|
104
|
+
return ns;
|
|
105
|
+
},
|
|
106
|
+
getNodeSet: function (id) {
|
|
107
|
+
return nodeSets[id];
|
|
108
|
+
},
|
|
109
|
+
enableNodeSet: function (id) {
|
|
110
|
+
var ns = nodeSets[id];
|
|
111
|
+
ns.enabled = true;
|
|
112
|
+
RED.events.emit('registry:node-set-enabled', ns);
|
|
113
|
+
},
|
|
114
|
+
disableNodeSet: function (id) {
|
|
115
|
+
var ns = nodeSets[id];
|
|
116
|
+
ns.enabled = false;
|
|
117
|
+
RED.events.emit('registry:node-set-disabled', ns);
|
|
118
|
+
},
|
|
119
|
+
registerNodeType: function (nt, def) {
|
|
120
|
+
nodeDefinitions[nt] = def;
|
|
121
|
+
def.type = nt;
|
|
122
|
+
if (nt.substring(0, 8) != 'subflow:') {
|
|
123
|
+
def.set = nodeSets[typeToId[nt]];
|
|
124
|
+
nodeSets[typeToId[nt]].added = true;
|
|
125
|
+
nodeSets[typeToId[nt]].enabled = true;
|
|
126
|
+
|
|
127
|
+
var ns;
|
|
128
|
+
if (def.set.module === 'kumologica-core') {
|
|
129
|
+
ns = 'kumologica-core';
|
|
130
|
+
} else {
|
|
131
|
+
ns = def.set.id;
|
|
132
|
+
}
|
|
133
|
+
def['_'] = function () {
|
|
134
|
+
var args = Array.prototype.slice.call(arguments, 0);
|
|
135
|
+
var original = args[0];
|
|
136
|
+
if (args[0].indexOf(':') === -1) {
|
|
137
|
+
args[0] = ns + ':' + args[0];
|
|
138
|
+
}
|
|
139
|
+
var result = RED._.apply(null, args);
|
|
140
|
+
if (result === args[0]) {
|
|
141
|
+
result = original;
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// TODO: too tightly coupled into palette UI
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
RED.events.emit('registry:node-type-added', nt);
|
|
150
|
+
|
|
151
|
+
},
|
|
152
|
+
removeNodeType: function (nt) {
|
|
153
|
+
if (nt.substring(0, 8) != 'subflow:') {
|
|
154
|
+
// NON-NLS - internal debug message
|
|
155
|
+
throw new Error('this api is subflow only. called with:', nt);
|
|
156
|
+
}
|
|
157
|
+
delete nodeDefinitions[nt];
|
|
158
|
+
RED.events.emit('registry:node-type-removed', nt);
|
|
159
|
+
},
|
|
160
|
+
getNodeType: function (nt) {
|
|
161
|
+
return nodeDefinitions[nt];
|
|
162
|
+
},
|
|
163
|
+
setIconSets: function (sets) {
|
|
164
|
+
iconSets = sets;
|
|
165
|
+
iconSets['font-awesome'] = RED.nodes.fontAwesome.getIconList();
|
|
166
|
+
},
|
|
167
|
+
getIconSets: function () {
|
|
168
|
+
return iconSets;
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
return exports;
|
|
172
|
+
})();
|
|
173
|
+
|
|
174
|
+
function getID() {
|
|
175
|
+
return (1 + Math.random() * 4294967295).toString(16);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function addNode(n) {
|
|
179
|
+
if (n.type.indexOf('subflow') !== 0) {
|
|
180
|
+
n['_'] = n._def._;
|
|
181
|
+
} else {
|
|
182
|
+
n['_'] = RED._;
|
|
183
|
+
}
|
|
184
|
+
if (n._def.category == 'config') {
|
|
185
|
+
configNodes[n.id] = n;
|
|
186
|
+
} else {
|
|
187
|
+
n.ports = [];
|
|
188
|
+
if (n.wires && n.wires.length > n.outputs) {
|
|
189
|
+
n.outputs = n.wires.length;
|
|
190
|
+
}
|
|
191
|
+
if (n.outputs) {
|
|
192
|
+
for (var i = 0; i < n.outputs; i++) {
|
|
193
|
+
n.ports.push(i);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
n.dirty = true;
|
|
197
|
+
updateConfigNodeUsers(n);
|
|
198
|
+
if (n._def.category == 'subflows' && typeof n.i === 'undefined') {
|
|
199
|
+
var nextId = 0;
|
|
200
|
+
RED.nodes.eachNode(function (node) {
|
|
201
|
+
nextId = Math.max(nextId, node.i || 0);
|
|
202
|
+
});
|
|
203
|
+
n.i = nextId + 1;
|
|
204
|
+
}
|
|
205
|
+
nodes.push(n);
|
|
206
|
+
}
|
|
207
|
+
RED.events.emit('nodes:add', n);
|
|
208
|
+
}
|
|
209
|
+
function addLink(l) {
|
|
210
|
+
links.push(l);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function getNode(id) {
|
|
214
|
+
if (id in configNodes) {
|
|
215
|
+
return configNodes[id];
|
|
216
|
+
} else {
|
|
217
|
+
for (var n in nodes) {
|
|
218
|
+
if (nodes[n].id == id) {
|
|
219
|
+
return nodes[n];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function removeNode(id) {
|
|
227
|
+
var removedLinks = [];
|
|
228
|
+
var removedNodes = [];
|
|
229
|
+
var node;
|
|
230
|
+
if (id in configNodes) {
|
|
231
|
+
node = configNodes[id];
|
|
232
|
+
delete configNodes[id];
|
|
233
|
+
RED.events.emit('nodes:remove', node);
|
|
234
|
+
RED.workspaces.refresh();
|
|
235
|
+
} else {
|
|
236
|
+
node = getNode(id);
|
|
237
|
+
if (node) {
|
|
238
|
+
nodes.splice(nodes.indexOf(node), 1);
|
|
239
|
+
removedLinks = links.filter(function (l) {
|
|
240
|
+
return l.source === node || l.target === node;
|
|
241
|
+
});
|
|
242
|
+
removedLinks.forEach(function (l) {
|
|
243
|
+
links.splice(links.indexOf(l), 1);
|
|
244
|
+
});
|
|
245
|
+
var updatedConfigNode = false;
|
|
246
|
+
for (var d in node._def.defaults) {
|
|
247
|
+
if (node._def.defaults.hasOwnProperty(d)) {
|
|
248
|
+
var property = node._def.defaults[d];
|
|
249
|
+
if (property.type) {
|
|
250
|
+
var type = registry.getNodeType(property.type);
|
|
251
|
+
if (type && type.category == 'config') {
|
|
252
|
+
var configNode = configNodes[node[d]];
|
|
253
|
+
if (configNode) {
|
|
254
|
+
updatedConfigNode = true;
|
|
255
|
+
if (configNode._def.exclusive) {
|
|
256
|
+
removeNode(node[d]);
|
|
257
|
+
removedNodes.push(configNode);
|
|
258
|
+
} else {
|
|
259
|
+
var users = configNode.users;
|
|
260
|
+
users.splice(users.indexOf(node), 1);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (updatedConfigNode) {
|
|
268
|
+
RED.workspaces.refresh();
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
if (node._def.oneditdelete) {
|
|
272
|
+
node._def.oneditdelete.call(node);
|
|
273
|
+
}
|
|
274
|
+
} catch (err) {
|
|
275
|
+
console.log('oneditdelete', node.id, node.type, err.toString());
|
|
276
|
+
}
|
|
277
|
+
RED.events.emit('nodes:remove', node);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (node && node._def.onremove) {
|
|
281
|
+
// Deprecated: never documented but used by some early nodes
|
|
282
|
+
console.log(
|
|
283
|
+
'Deprecated API warning: node type ',
|
|
284
|
+
node.type,
|
|
285
|
+
' has an onremove function - should be oneditremove - please report'
|
|
286
|
+
);
|
|
287
|
+
node._def.onremove.call(n);
|
|
288
|
+
}
|
|
289
|
+
return { links: removedLinks, nodes: removedNodes };
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function removeLink(l) {
|
|
293
|
+
var index = links.indexOf(l);
|
|
294
|
+
if (index != -1) {
|
|
295
|
+
links.splice(index, 1);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function addWorkspace(ws, targetIndex) {
|
|
300
|
+
workspaces[ws.id] = ws;
|
|
301
|
+
ws._def = RED.nodes.getType('tab');
|
|
302
|
+
if (targetIndex === undefined) {
|
|
303
|
+
workspacesOrder.push(ws.id);
|
|
304
|
+
} else {
|
|
305
|
+
workspacesOrder.splice(targetIndex, 0, ws.id);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function getWorkspace(id) {
|
|
309
|
+
return workspaces[id];
|
|
310
|
+
}
|
|
311
|
+
function removeWorkspace(id) {
|
|
312
|
+
delete workspaces[id];
|
|
313
|
+
workspacesOrder.splice(workspacesOrder.indexOf(id), 1);
|
|
314
|
+
|
|
315
|
+
var removedNodes = [];
|
|
316
|
+
var removedLinks = [];
|
|
317
|
+
var n;
|
|
318
|
+
var node;
|
|
319
|
+
for (n = 0; n < nodes.length; n++) {
|
|
320
|
+
node = nodes[n];
|
|
321
|
+
if (node.z == id) {
|
|
322
|
+
removedNodes.push(node);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
for (n in configNodes) {
|
|
326
|
+
if (configNodes.hasOwnProperty(n)) {
|
|
327
|
+
node = configNodes[n];
|
|
328
|
+
if (node.z == id) {
|
|
329
|
+
removedNodes.push(node);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
for (n = 0; n < removedNodes.length; n++) {
|
|
334
|
+
var result = removeNode(removedNodes[n].id);
|
|
335
|
+
removedLinks = removedLinks.concat(result.links);
|
|
336
|
+
}
|
|
337
|
+
return { nodes: removedNodes, links: removedLinks };
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function addSubflow(sf, createNewIds) {
|
|
341
|
+
if (createNewIds) {
|
|
342
|
+
var subflowNames = Object.keys(subflows).map(function (sfid) {
|
|
343
|
+
return subflows[sfid].name;
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
subflowNames.sort();
|
|
347
|
+
var copyNumber = 1;
|
|
348
|
+
var subflowName = sf.name;
|
|
349
|
+
subflowNames.forEach(function (name) {
|
|
350
|
+
if (subflowName == name) {
|
|
351
|
+
copyNumber++;
|
|
352
|
+
subflowName = sf.name + ' (' + copyNumber + ')';
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
sf.name = subflowName;
|
|
356
|
+
}
|
|
357
|
+
subflows[sf.id] = sf;
|
|
358
|
+
RED.nodes.registerType('subflow:' + sf.id, {
|
|
359
|
+
defaults: {
|
|
360
|
+
name: { value: '' },
|
|
361
|
+
env: { value: [] },
|
|
362
|
+
},
|
|
363
|
+
icon: function () {
|
|
364
|
+
return sf.icon || 'subflow.png';
|
|
365
|
+
},
|
|
366
|
+
category: sf.category || 'subflows',
|
|
367
|
+
inputs: sf.in.length,
|
|
368
|
+
outputs: sf.out.length,
|
|
369
|
+
color: '#da9',
|
|
370
|
+
label: function () {
|
|
371
|
+
return this.name || RED.nodes.subflow(sf.id).name;
|
|
372
|
+
},
|
|
373
|
+
labelStyle: function () {
|
|
374
|
+
return this.name ? 'node_label_italic' : '';
|
|
375
|
+
},
|
|
376
|
+
paletteLabel: function () {
|
|
377
|
+
return RED.nodes.subflow(sf.id).name;
|
|
378
|
+
},
|
|
379
|
+
inputLabels: function (i) {
|
|
380
|
+
return sf.inputLabels ? sf.inputLabels[i] : null;
|
|
381
|
+
},
|
|
382
|
+
outputLabels: function (i) {
|
|
383
|
+
return sf.outputLabels ? sf.outputLabels[i] : null;
|
|
384
|
+
},
|
|
385
|
+
oneditresize: function (size) {
|
|
386
|
+
var rows = $('#dialog-form>div:not(.node-input-env-container-row)');
|
|
387
|
+
var height = size.height;
|
|
388
|
+
for (var i = 0; i < rows.size(); i++) {
|
|
389
|
+
height -= $(rows[i]).outerHeight(true);
|
|
390
|
+
}
|
|
391
|
+
var editorRow = $('#dialog-form>div.node-input-env-container-row');
|
|
392
|
+
height -=
|
|
393
|
+
parseInt(editorRow.css('marginTop')) +
|
|
394
|
+
parseInt(editorRow.css('marginBottom'));
|
|
395
|
+
$('#node-input-env-container').editableList('height', height - 80);
|
|
396
|
+
},
|
|
397
|
+
set: {
|
|
398
|
+
module: 'kumologica-core',
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
sf._def = RED.nodes.getType('subflow:' + sf.id);
|
|
402
|
+
}
|
|
403
|
+
function getSubflow(id) {
|
|
404
|
+
return subflows[id];
|
|
405
|
+
}
|
|
406
|
+
function removeSubflow(sf) {
|
|
407
|
+
delete subflows[sf.id];
|
|
408
|
+
registry.removeNodeType('subflow:' + sf.id);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function subflowContains(sfid, nodeid) {
|
|
412
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
413
|
+
var node = nodes[i];
|
|
414
|
+
if (node.z === sfid) {
|
|
415
|
+
var m = /^subflow:(.+)$/.exec(node.type);
|
|
416
|
+
if (m) {
|
|
417
|
+
if (m[1] === nodeid) {
|
|
418
|
+
return true;
|
|
419
|
+
} else {
|
|
420
|
+
var result = subflowContains(m[1], nodeid);
|
|
421
|
+
if (result) {
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function getAllFlowNodes(node) {
|
|
432
|
+
var visited = {};
|
|
433
|
+
visited[node.id] = true;
|
|
434
|
+
var nns = [node];
|
|
435
|
+
var stack = [node];
|
|
436
|
+
while (stack.length !== 0) {
|
|
437
|
+
var n = stack.shift();
|
|
438
|
+
var childLinks = links.filter(function (d) {
|
|
439
|
+
return d.source === n || d.target === n;
|
|
440
|
+
});
|
|
441
|
+
for (var i = 0; i < childLinks.length; i++) {
|
|
442
|
+
var child =
|
|
443
|
+
childLinks[i].source === n
|
|
444
|
+
? childLinks[i].target
|
|
445
|
+
: childLinks[i].source;
|
|
446
|
+
var id = child.id;
|
|
447
|
+
if (!id) {
|
|
448
|
+
id = child.direction + ':' + child.i;
|
|
449
|
+
}
|
|
450
|
+
if (!visited[id]) {
|
|
451
|
+
visited[id] = true;
|
|
452
|
+
nns.push(child);
|
|
453
|
+
stack.push(child);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return nns;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function convertWorkspace(n) {
|
|
461
|
+
var node = {};
|
|
462
|
+
node.id = n.id;
|
|
463
|
+
node.type = n.type;
|
|
464
|
+
for (var d in n._def.defaults) {
|
|
465
|
+
if (n._def.defaults.hasOwnProperty(d)) {
|
|
466
|
+
node[d] = n[d];
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return node;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Converts a node to an exportable JSON Object
|
|
473
|
+
**/
|
|
474
|
+
function convertNode(n, exportCreds) {
|
|
475
|
+
if (n.type === 'tab') {
|
|
476
|
+
return convertWorkspace(n);
|
|
477
|
+
}
|
|
478
|
+
exportCreds = exportCreds || false;
|
|
479
|
+
var node = {};
|
|
480
|
+
node.id = n.id;
|
|
481
|
+
node.type = n.type;
|
|
482
|
+
node.z = n.z;
|
|
483
|
+
|
|
484
|
+
if (node.type == 'unknown') {
|
|
485
|
+
for (var p in n._orig) {
|
|
486
|
+
if (n._orig.hasOwnProperty(p)) {
|
|
487
|
+
node[p] = n._orig[p];
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
} else {
|
|
491
|
+
for (var d in n._def.defaults) {
|
|
492
|
+
if (n._def.defaults.hasOwnProperty(d)) {
|
|
493
|
+
node[d] = n[d];
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
if (exportCreds && n.credentials) {
|
|
497
|
+
var credentialSet = {};
|
|
498
|
+
node.credentials = {};
|
|
499
|
+
for (var cred in n._def.credentials) {
|
|
500
|
+
if (n._def.credentials.hasOwnProperty(cred)) {
|
|
501
|
+
if (n._def.credentials[cred].type == 'password') {
|
|
502
|
+
if (
|
|
503
|
+
!n.credentials._ ||
|
|
504
|
+
n.credentials['has_' + cred] !=
|
|
505
|
+
n.credentials._['has_' + cred] ||
|
|
506
|
+
(n.credentials['has_' + cred] && n.credentials[cred])
|
|
507
|
+
) {
|
|
508
|
+
credentialSet[cred] = n.credentials[cred];
|
|
509
|
+
}
|
|
510
|
+
} else if (
|
|
511
|
+
n.credentials[cred] != null &&
|
|
512
|
+
(!n.credentials._ || n.credentials[cred] != n.credentials._[cred])
|
|
513
|
+
) {
|
|
514
|
+
credentialSet[cred] = n.credentials[cred];
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
if (Object.keys(credentialSet).length > 0) {
|
|
519
|
+
node.credentials = credentialSet;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
if (n._def.category != 'config') {
|
|
524
|
+
node.x = n.x;
|
|
525
|
+
node.y = n.y;
|
|
526
|
+
node.wires = [];
|
|
527
|
+
for (var i = 0; i < n.outputs; i++) {
|
|
528
|
+
node.wires.push([]);
|
|
529
|
+
}
|
|
530
|
+
var wires = links.filter(function (d) {
|
|
531
|
+
return d.source === n;
|
|
532
|
+
});
|
|
533
|
+
for (var j = 0; j < wires.length; j++) {
|
|
534
|
+
var w = wires[j];
|
|
535
|
+
if (w.target.type != 'subflow') {
|
|
536
|
+
if (w.sourcePort < node.wires.length) {
|
|
537
|
+
node.wires[w.sourcePort].push(w.target.id);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (
|
|
543
|
+
n.inputs > 0 &&
|
|
544
|
+
n.inputLabels &&
|
|
545
|
+
!/^\s*$/.test(n.inputLabels.join(''))
|
|
546
|
+
) {
|
|
547
|
+
node.inputLabels = n.inputLabels.slice();
|
|
548
|
+
}
|
|
549
|
+
if (
|
|
550
|
+
n.outputs > 0 &&
|
|
551
|
+
n.outputLabels &&
|
|
552
|
+
!/^\s*$/.test(n.outputLabels.join(''))
|
|
553
|
+
) {
|
|
554
|
+
node.outputLabels = n.outputLabels.slice();
|
|
555
|
+
}
|
|
556
|
+
if (
|
|
557
|
+
(!n._def.defaults || !n._def.defaults.hasOwnProperty('icon')) &&
|
|
558
|
+
n.icon
|
|
559
|
+
) {
|
|
560
|
+
var defIcon = RED.utils.getDefaultNodeIcon(n._def, n);
|
|
561
|
+
if (n.icon !== defIcon.module + '/' + defIcon.file) {
|
|
562
|
+
node.icon = n.icon;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (
|
|
566
|
+
(!n._def.defaults || !n._def.defaults.hasOwnProperty('l')) &&
|
|
567
|
+
n.hasOwnProperty('l')
|
|
568
|
+
) {
|
|
569
|
+
|
|
570
|
+
// var isLink = /^link (in|out)$/.test(node.type);
|
|
571
|
+
// if (isLink == n.l) {
|
|
572
|
+
// node.l = n.l;
|
|
573
|
+
// }
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (n.info) {
|
|
577
|
+
node.info = n.info;
|
|
578
|
+
}
|
|
579
|
+
if (n._def.set) {
|
|
580
|
+
if (n._def.set.name) {
|
|
581
|
+
node.caname = n._def.set.name;
|
|
582
|
+
}
|
|
583
|
+
if (n._def.category) {
|
|
584
|
+
node.category = n._def.category;
|
|
585
|
+
}
|
|
586
|
+
} else {
|
|
587
|
+
node.caname = '_error_unknown';
|
|
588
|
+
node.category = '_error_unknown'
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return node;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function convertSubflow(n) {
|
|
595
|
+
var node = {};
|
|
596
|
+
node.id = n.id;
|
|
597
|
+
node.type = n.type;
|
|
598
|
+
node.name = n.name;
|
|
599
|
+
node.info = n.info;
|
|
600
|
+
node.category = n.category;
|
|
601
|
+
node.in = [];
|
|
602
|
+
node.out = [];
|
|
603
|
+
node.env = n.env;
|
|
604
|
+
|
|
605
|
+
n.in.forEach(function (p) {
|
|
606
|
+
var nIn = { x: p.x, y: p.y, wires: [] };
|
|
607
|
+
var wires = links.filter(function (d) {
|
|
608
|
+
return d.source === p;
|
|
609
|
+
});
|
|
610
|
+
for (var i = 0; i < wires.length; i++) {
|
|
611
|
+
var w = wires[i];
|
|
612
|
+
if (w.target.type != 'subflow') {
|
|
613
|
+
nIn.wires.push({ id: w.target.id });
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
node.in.push(nIn);
|
|
617
|
+
});
|
|
618
|
+
n.out.forEach(function (p, c) {
|
|
619
|
+
var nOut = { x: p.x, y: p.y, wires: [] };
|
|
620
|
+
var wires = links.filter(function (d) {
|
|
621
|
+
return d.target === p;
|
|
622
|
+
});
|
|
623
|
+
for (i = 0; i < wires.length; i++) {
|
|
624
|
+
if (wires[i].source.type != 'subflow') {
|
|
625
|
+
nOut.wires.push({
|
|
626
|
+
id: wires[i].source.id,
|
|
627
|
+
port: wires[i].sourcePort,
|
|
628
|
+
});
|
|
629
|
+
} else {
|
|
630
|
+
nOut.wires.push({ id: n.id, port: 0 });
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
node.out.push(nOut);
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
if (
|
|
637
|
+
node.in.length > 0 &&
|
|
638
|
+
n.inputLabels &&
|
|
639
|
+
!/^\s*$/.test(n.inputLabels.join(''))
|
|
640
|
+
) {
|
|
641
|
+
node.inputLabels = n.inputLabels.slice();
|
|
642
|
+
}
|
|
643
|
+
if (
|
|
644
|
+
node.out.length > 0 &&
|
|
645
|
+
n.outputLabels &&
|
|
646
|
+
!/^\s*$/.test(n.outputLabels.join(''))
|
|
647
|
+
) {
|
|
648
|
+
node.outputLabels = n.outputLabels.slice();
|
|
649
|
+
}
|
|
650
|
+
if (n.icon) {
|
|
651
|
+
if (n.icon !== 'kumologica-core/subflow.png') {
|
|
652
|
+
node.icon = n.icon;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
if (n.status) {
|
|
656
|
+
node.status = { x: n.status.x, y: n.status.y, wires: [] };
|
|
657
|
+
links.forEach(function (d) {
|
|
658
|
+
if (d.target === n.status) {
|
|
659
|
+
if (d.source.type != 'subflow') {
|
|
660
|
+
node.status.wires.push({ id: d.source.id, port: d.sourcePort });
|
|
661
|
+
} else {
|
|
662
|
+
node.status.wires.push({ id: n.id, port: 0 });
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
return node;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Converts the current node selection to an exportable JSON Object
|
|
672
|
+
**/
|
|
673
|
+
function createExportableNodeSet(set, exportedSubflows, exportedConfigNodes) {
|
|
674
|
+
var nns = [];
|
|
675
|
+
exportedConfigNodes = exportedConfigNodes || {};
|
|
676
|
+
exportedSubflows = exportedSubflows || {};
|
|
677
|
+
for (var n = 0; n < set.length; n++) {
|
|
678
|
+
var node = set[n];
|
|
679
|
+
if (node.type.substring(0, 8) == 'subflow:') {
|
|
680
|
+
var subflowId = node.type.substring(8);
|
|
681
|
+
if (!exportedSubflows[subflowId]) {
|
|
682
|
+
exportedSubflows[subflowId] = true;
|
|
683
|
+
var subflow = getSubflow(subflowId);
|
|
684
|
+
var subflowSet = [subflow];
|
|
685
|
+
RED.nodes.eachNode(function (n) {
|
|
686
|
+
if (n.z == subflowId) {
|
|
687
|
+
subflowSet.push(n);
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
var exportableSubflow = createExportableNodeSet(
|
|
691
|
+
subflowSet,
|
|
692
|
+
exportedSubflows,
|
|
693
|
+
exportedConfigNodes
|
|
694
|
+
);
|
|
695
|
+
nns = exportableSubflow.concat(nns);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
if (node.type != 'subflow') {
|
|
699
|
+
var convertedNode = RED.nodes.convertNode(node);
|
|
700
|
+
for (var d in node._def.defaults) {
|
|
701
|
+
if (node._def.defaults[d].type && node[d] in configNodes) {
|
|
702
|
+
var confNode = configNodes[node[d]];
|
|
703
|
+
var exportable = registry.getNodeType(node._def.defaults[d].type)
|
|
704
|
+
.exportable;
|
|
705
|
+
if (exportable == null || exportable) {
|
|
706
|
+
if (!(node[d] in exportedConfigNodes)) {
|
|
707
|
+
exportedConfigNodes[node[d]] = true;
|
|
708
|
+
set.push(confNode);
|
|
709
|
+
}
|
|
710
|
+
} else {
|
|
711
|
+
convertedNode[d] = '';
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
nns.push(convertedNode);
|
|
716
|
+
} else {
|
|
717
|
+
var convertedSubflow = convertSubflow(node);
|
|
718
|
+
nns.push(convertedSubflow);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return nns;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function createCompleteNodeSet(exportCredentials) {
|
|
725
|
+
if (exportCredentials === undefined) {
|
|
726
|
+
exportCredentials = true;
|
|
727
|
+
}
|
|
728
|
+
var nns = [];
|
|
729
|
+
var i;
|
|
730
|
+
|
|
731
|
+
for (i = 0; i < workspacesOrder.length; i++) {
|
|
732
|
+
if (workspaces[workspacesOrder[i]].type == 'tab') {
|
|
733
|
+
nns.push(convertWorkspace(workspaces[workspacesOrder[i]]));
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
for (i in subflows) {
|
|
737
|
+
if (subflows.hasOwnProperty(i)) {
|
|
738
|
+
nns.push(convertSubflow(subflows[i]));
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
for (i in configNodes) {
|
|
742
|
+
if (configNodes.hasOwnProperty(i)) {
|
|
743
|
+
nns.push(convertNode(configNodes[i], exportCredentials));
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
for (i = 0; i < nodes.length; i++) {
|
|
747
|
+
var node = nodes[i];
|
|
748
|
+
let n = convertNode(node, exportCredentials);
|
|
749
|
+
// check if we need to report an error with node convertion
|
|
750
|
+
if (n.caname === '_error_unknown' && n.category === '_error_unknown'){
|
|
751
|
+
RED.notify(`<strong>Error</strong>: Invalid flow due to node type unknown [${n.type}]`, 'error');
|
|
752
|
+
}
|
|
753
|
+
nns.push(n);
|
|
754
|
+
}
|
|
755
|
+
return nns;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
function checkForMatchingSubflow(subflow, subflowNodes) {
|
|
759
|
+
subflowNodes = subflowNodes || [];
|
|
760
|
+
var i;
|
|
761
|
+
var match = null;
|
|
762
|
+
RED.nodes.eachSubflow(function (sf) {
|
|
763
|
+
if (
|
|
764
|
+
sf.name != subflow.name ||
|
|
765
|
+
sf.info != subflow.info ||
|
|
766
|
+
sf.in.length != subflow.in.length ||
|
|
767
|
+
sf.out.length != subflow.out.length
|
|
768
|
+
) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
var sfNodes = RED.nodes.filterNodes({ z: sf.id });
|
|
772
|
+
if (sfNodes.length != subflowNodes.length) {
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
var subflowNodeSet = [subflow].concat(subflowNodes);
|
|
777
|
+
var sfNodeSet = [sf].concat(sfNodes);
|
|
778
|
+
|
|
779
|
+
var exportableSubflowNodes = JSON.stringify(subflowNodeSet);
|
|
780
|
+
var exportableSFNodes = JSON.stringify(
|
|
781
|
+
createExportableNodeSet(sfNodeSet)
|
|
782
|
+
);
|
|
783
|
+
var nodeMap = {};
|
|
784
|
+
for (i = 0; i < sfNodes.length; i++) {
|
|
785
|
+
exportableSubflowNodes = exportableSubflowNodes.replace(
|
|
786
|
+
new RegExp('"' + subflowNodes[i].id + '"', 'g'),
|
|
787
|
+
'"' + sfNodes[i].id + '"'
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
exportableSubflowNodes = exportableSubflowNodes.replace(
|
|
791
|
+
new RegExp('"' + subflow.id + '"', 'g'),
|
|
792
|
+
'"' + sf.id + '"'
|
|
793
|
+
);
|
|
794
|
+
|
|
795
|
+
if (exportableSubflowNodes !== exportableSFNodes) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
match = sf;
|
|
800
|
+
return false;
|
|
801
|
+
});
|
|
802
|
+
return match;
|
|
803
|
+
}
|
|
804
|
+
function compareNodes(nodeA, nodeB, idMustMatch) {
|
|
805
|
+
if (idMustMatch && nodeA.id != nodeB.id) {
|
|
806
|
+
return false;
|
|
807
|
+
}
|
|
808
|
+
if (nodeA.type != nodeB.type) {
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
var def = nodeA._def;
|
|
812
|
+
for (var d in def.defaults) {
|
|
813
|
+
if (def.defaults.hasOwnProperty(d)) {
|
|
814
|
+
var vA = nodeA[d];
|
|
815
|
+
var vB = nodeB[d];
|
|
816
|
+
if (typeof vA !== typeof vB) {
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
if (vA === null || typeof vA === 'string' || typeof vA === 'number') {
|
|
820
|
+
if (vA !== vB) {
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
} else {
|
|
824
|
+
if (JSON.stringify(vA) !== JSON.stringify(vB)) {
|
|
825
|
+
return false;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
return true;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
function importNodes(newNodesObj, createNewIds, createMissingWorkspace) {
|
|
834
|
+
var i;
|
|
835
|
+
var n;
|
|
836
|
+
var newNodes;
|
|
837
|
+
var nodeZmap = {};
|
|
838
|
+
if (typeof newNodesObj === 'string') {
|
|
839
|
+
if (newNodesObj === '') {
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
try {
|
|
843
|
+
newNodes = JSON.parse(newNodesObj);
|
|
844
|
+
} catch (err) {
|
|
845
|
+
var e = new Error(`Invalid flow: ${err.message}`);
|
|
846
|
+
e.code = 'NODE_RED';
|
|
847
|
+
throw e;
|
|
848
|
+
}
|
|
849
|
+
} else {
|
|
850
|
+
newNodes = newNodesObj;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
if (!$.isArray(newNodes)) {
|
|
854
|
+
newNodes = [newNodes];
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// Scan for any duplicate nodes and remove them. This is a temporary
|
|
858
|
+
// fix to help resolve corrupted flows caused by 0.20.0 where multiple
|
|
859
|
+
// copies of the flow would get loaded at the same time.
|
|
860
|
+
// If the user hit deploy they would have saved those duplicates.
|
|
861
|
+
var seenIds = {};
|
|
862
|
+
newNodes = newNodes.filter(function (n) {
|
|
863
|
+
if (seenIds[n.id]) {
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
seenIds[n.id] = true;
|
|
867
|
+
return true;
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
var isInitialLoad = false;
|
|
871
|
+
if (!initialLoad) {
|
|
872
|
+
isInitialLoad = true;
|
|
873
|
+
initialLoad = JSON.parse(JSON.stringify(newNodes));
|
|
874
|
+
}
|
|
875
|
+
var unknownTypes = [];
|
|
876
|
+
for (i = 0; i < newNodes.length; i++) {
|
|
877
|
+
n = newNodes[i];
|
|
878
|
+
// TODO: remove workspace in next release+1
|
|
879
|
+
if (
|
|
880
|
+
n.type != 'workspace' &&
|
|
881
|
+
n.type != 'tab' &&
|
|
882
|
+
n.type != 'subflow' &&
|
|
883
|
+
!registry.getNodeType(n.type) &&
|
|
884
|
+
n.type.substring(0, 8) != 'subflow:' &&
|
|
885
|
+
unknownTypes.indexOf(n.type) == -1
|
|
886
|
+
) {
|
|
887
|
+
unknownTypes.push(n.type);
|
|
888
|
+
}
|
|
889
|
+
if (n.z) {
|
|
890
|
+
nodeZmap[n.z] = nodeZmap[n.z] || [];
|
|
891
|
+
nodeZmap[n.z].push(n);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
if (!isInitialLoad && unknownTypes.length > 0) {
|
|
895
|
+
var typeList = '<ul><li>' + unknownTypes.join('</li><li>') + '</li></ul>';
|
|
896
|
+
RED.notify(
|
|
897
|
+
'<p>' +
|
|
898
|
+
'Imported unrecognised type:' +
|
|
899
|
+
'</p>' +
|
|
900
|
+
typeList,
|
|
901
|
+
'error',
|
|
902
|
+
false,
|
|
903
|
+
10000
|
|
904
|
+
);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
var activeWorkspace = RED.workspaces.active();
|
|
908
|
+
//TODO: check the z of the subflow instance and check _that_ if it exists
|
|
909
|
+
var activeSubflow = getSubflow(activeWorkspace);
|
|
910
|
+
for (i = 0; i < newNodes.length; i++) {
|
|
911
|
+
var m = /^subflow:(.+)$/.exec(newNodes[i].type);
|
|
912
|
+
if (m) {
|
|
913
|
+
var subflowId = m[1];
|
|
914
|
+
var parent = getSubflow(newNodes[i].z || activeWorkspace);
|
|
915
|
+
if (parent) {
|
|
916
|
+
var err;
|
|
917
|
+
if (subflowId === parent.id) {
|
|
918
|
+
err = new Error('Cannot add subflow to itself');
|
|
919
|
+
}
|
|
920
|
+
if (subflowContains(subflowId, parent.id)) {
|
|
921
|
+
err = new Error('Cannot add subflow - circular reference detected');
|
|
922
|
+
}
|
|
923
|
+
if (err) {
|
|
924
|
+
// TODO: standardise error codes
|
|
925
|
+
err.code = 'NODE_RED';
|
|
926
|
+
throw err;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
var new_workspaces = [];
|
|
933
|
+
var workspace_map = {};
|
|
934
|
+
var new_subflows = [];
|
|
935
|
+
var subflow_map = {};
|
|
936
|
+
var subflow_blacklist = {};
|
|
937
|
+
var node_map = {};
|
|
938
|
+
var new_nodes = [];
|
|
939
|
+
var new_links = [];
|
|
940
|
+
var nid;
|
|
941
|
+
var def;
|
|
942
|
+
var configNode;
|
|
943
|
+
var missingWorkspace = null;
|
|
944
|
+
var d;
|
|
945
|
+
|
|
946
|
+
// Find all tabs and subflow templates
|
|
947
|
+
for (i = 0; i < newNodes.length; i++) {
|
|
948
|
+
n = newNodes[i];
|
|
949
|
+
// TODO: remove workspace in next release+1
|
|
950
|
+
if (n.type === 'workspace' || n.type === 'tab') {
|
|
951
|
+
if (n.type === 'workspace') {
|
|
952
|
+
n.type = 'tab';
|
|
953
|
+
}
|
|
954
|
+
if (defaultWorkspace == null) {
|
|
955
|
+
defaultWorkspace = n;
|
|
956
|
+
}
|
|
957
|
+
if (createNewIds) {
|
|
958
|
+
nid = getID();
|
|
959
|
+
workspace_map[n.id] = nid;
|
|
960
|
+
n.id = nid;
|
|
961
|
+
}
|
|
962
|
+
addWorkspace(n);
|
|
963
|
+
RED.workspaces.add(n);
|
|
964
|
+
new_workspaces.push(n);
|
|
965
|
+
} else if (n.type === 'subflow') {
|
|
966
|
+
var matchingSubflow = checkForMatchingSubflow(n, nodeZmap[n.id]);
|
|
967
|
+
if (matchingSubflow) {
|
|
968
|
+
subflow_blacklist[n.id] = matchingSubflow;
|
|
969
|
+
} else {
|
|
970
|
+
subflow_map[n.id] = n;
|
|
971
|
+
if (createNewIds) {
|
|
972
|
+
nid = getID();
|
|
973
|
+
n.id = nid;
|
|
974
|
+
}
|
|
975
|
+
// TODO: handle createNewIds - map old to new subflow ids
|
|
976
|
+
n.in.forEach(function (input, i) {
|
|
977
|
+
input.type = 'subflow';
|
|
978
|
+
input.direction = 'in';
|
|
979
|
+
input.z = n.id;
|
|
980
|
+
input.i = i;
|
|
981
|
+
input.id = getID();
|
|
982
|
+
});
|
|
983
|
+
n.out.forEach(function (output, i) {
|
|
984
|
+
output.type = 'subflow';
|
|
985
|
+
output.direction = 'out';
|
|
986
|
+
output.z = n.id;
|
|
987
|
+
output.i = i;
|
|
988
|
+
output.id = getID();
|
|
989
|
+
});
|
|
990
|
+
if (n.status) {
|
|
991
|
+
n.status.type = 'subflow';
|
|
992
|
+
n.status.direction = 'status';
|
|
993
|
+
n.status.z = n.id;
|
|
994
|
+
n.status.id = getID();
|
|
995
|
+
}
|
|
996
|
+
new_subflows.push(n);
|
|
997
|
+
addSubflow(n, createNewIds);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// Add a tab if there isn't one there already
|
|
1003
|
+
if (defaultWorkspace == null) {
|
|
1004
|
+
defaultWorkspace = {
|
|
1005
|
+
type: 'tab',
|
|
1006
|
+
id: getID(),
|
|
1007
|
+
disabled: false,
|
|
1008
|
+
info: '',
|
|
1009
|
+
label: `Flow ${number}`,
|
|
1010
|
+
};
|
|
1011
|
+
addWorkspace(defaultWorkspace);
|
|
1012
|
+
RED.workspaces.add(defaultWorkspace);
|
|
1013
|
+
new_workspaces.push(defaultWorkspace);
|
|
1014
|
+
activeWorkspace = RED.workspaces.active();
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// Find all config nodes and add them
|
|
1018
|
+
for (i = 0; i < newNodes.length; i++) {
|
|
1019
|
+
n = newNodes[i];
|
|
1020
|
+
def = registry.getNodeType(n.type);
|
|
1021
|
+
if (def && def.category == 'config') {
|
|
1022
|
+
var existingConfigNode = null;
|
|
1023
|
+
if (createNewIds) {
|
|
1024
|
+
if (n.z) {
|
|
1025
|
+
if (subflow_blacklist[n.z]) {
|
|
1026
|
+
continue;
|
|
1027
|
+
} else if (subflow_map[n.z]) {
|
|
1028
|
+
n.z = subflow_map[n.z].id;
|
|
1029
|
+
} else {
|
|
1030
|
+
n.z = workspace_map[n.z];
|
|
1031
|
+
if (!workspaces[n.z]) {
|
|
1032
|
+
if (createMissingWorkspace) {
|
|
1033
|
+
if (missingWorkspace === null) {
|
|
1034
|
+
missingWorkspace = RED.workspaces.add(null, true);
|
|
1035
|
+
new_workspaces.push(missingWorkspace);
|
|
1036
|
+
}
|
|
1037
|
+
n.z = missingWorkspace.id;
|
|
1038
|
+
} else {
|
|
1039
|
+
n.z = activeWorkspace;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
existingConfigNode = RED.nodes.node(n.id);
|
|
1045
|
+
if (existingConfigNode) {
|
|
1046
|
+
if (n.z && existingConfigNode.z !== n.z) {
|
|
1047
|
+
existingConfigNode = null;
|
|
1048
|
+
// Check the config nodes on n.z
|
|
1049
|
+
for (var cn in configNodes) {
|
|
1050
|
+
if (configNodes.hasOwnProperty(cn)) {
|
|
1051
|
+
if (
|
|
1052
|
+
configNodes[cn].z === n.z &&
|
|
1053
|
+
compareNodes(configNodes[cn], n, false)
|
|
1054
|
+
) {
|
|
1055
|
+
existingConfigNode = configNodes[cn];
|
|
1056
|
+
node_map[n.id] = configNodes[cn];
|
|
1057
|
+
break;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
if (!existingConfigNode || existingConfigNode._def.exclusive) {
|
|
1066
|
+
//} || !compareNodes(existingConfigNode,n,true) || existingConfigNode.z !== n.z) {
|
|
1067
|
+
configNode = {
|
|
1068
|
+
id: n.id,
|
|
1069
|
+
z: n.z,
|
|
1070
|
+
type: n.type,
|
|
1071
|
+
info: n.info,
|
|
1072
|
+
users: [],
|
|
1073
|
+
_config: {},
|
|
1074
|
+
};
|
|
1075
|
+
for (d in def.defaults) {
|
|
1076
|
+
if (def.defaults.hasOwnProperty(d)) {
|
|
1077
|
+
configNode[d] = n[d];
|
|
1078
|
+
configNode._config[d] = JSON.stringify(n[d]);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
if (
|
|
1082
|
+
def.hasOwnProperty('credentials') &&
|
|
1083
|
+
n.hasOwnProperty('credentials')
|
|
1084
|
+
) {
|
|
1085
|
+
configNode.credentials = {};
|
|
1086
|
+
for (d in def.credentials) {
|
|
1087
|
+
if (
|
|
1088
|
+
def.credentials.hasOwnProperty(d) &&
|
|
1089
|
+
n.credentials.hasOwnProperty(d)
|
|
1090
|
+
) {
|
|
1091
|
+
configNode.credentials[d] = n.credentials[d];
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
configNode.label = def.label;
|
|
1096
|
+
configNode._def = def;
|
|
1097
|
+
if (createNewIds) {
|
|
1098
|
+
configNode.id = getID();
|
|
1099
|
+
}
|
|
1100
|
+
node_map[n.id] = configNode;
|
|
1101
|
+
new_nodes.push(configNode);
|
|
1102
|
+
RED.nodes.add(configNode);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// Find regular flow nodes and subflow instances
|
|
1108
|
+
for (i = 0; i < newNodes.length; i++) {
|
|
1109
|
+
n = newNodes[i];
|
|
1110
|
+
// TODO: remove workspace in next release+1
|
|
1111
|
+
if (n.type !== 'workspace' && n.type !== 'tab' && n.type !== 'subflow') {
|
|
1112
|
+
def = registry.getNodeType(n.type);
|
|
1113
|
+
if (!def || def.category != 'config') {
|
|
1114
|
+
var node = {
|
|
1115
|
+
x: parseFloat(n.x || 0),
|
|
1116
|
+
y: parseFloat(n.y || 0),
|
|
1117
|
+
z: n.z,
|
|
1118
|
+
type: 0,
|
|
1119
|
+
wires: n.wires || [],
|
|
1120
|
+
inputLabels: n.inputLabels,
|
|
1121
|
+
outputLabels: n.outputLabels,
|
|
1122
|
+
icon: n.icon,
|
|
1123
|
+
info: n.info,
|
|
1124
|
+
changed: false,
|
|
1125
|
+
_config: {},
|
|
1126
|
+
};
|
|
1127
|
+
// if (n.hasOwnProperty('l')) {
|
|
1128
|
+
// node.l = n.l;
|
|
1129
|
+
// }
|
|
1130
|
+
if (createNewIds) {
|
|
1131
|
+
if (subflow_blacklist[n.z]) {
|
|
1132
|
+
continue;
|
|
1133
|
+
} else if (subflow_map[node.z]) {
|
|
1134
|
+
node.z = subflow_map[node.z].id;
|
|
1135
|
+
} else {
|
|
1136
|
+
node.z = workspace_map[node.z];
|
|
1137
|
+
if (!workspaces[node.z]) {
|
|
1138
|
+
if (createMissingWorkspace) {
|
|
1139
|
+
if (missingWorkspace === null) {
|
|
1140
|
+
missingWorkspace = RED.workspaces.add(null, true);
|
|
1141
|
+
new_workspaces.push(missingWorkspace);
|
|
1142
|
+
}
|
|
1143
|
+
node.z = missingWorkspace.id;
|
|
1144
|
+
} else {
|
|
1145
|
+
node.z = activeWorkspace;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
node.id = getID();
|
|
1150
|
+
} else {
|
|
1151
|
+
node.id = n.id;
|
|
1152
|
+
if (
|
|
1153
|
+
node.z == null ||
|
|
1154
|
+
(!workspaces[node.z] && !subflow_map[node.z])
|
|
1155
|
+
) {
|
|
1156
|
+
if (createMissingWorkspace) {
|
|
1157
|
+
if (missingWorkspace === null) {
|
|
1158
|
+
missingWorkspace = RED.workspaces.add(null, true);
|
|
1159
|
+
new_workspaces.push(missingWorkspace);
|
|
1160
|
+
}
|
|
1161
|
+
node.z = missingWorkspace.id;
|
|
1162
|
+
} else {
|
|
1163
|
+
node.z = activeWorkspace;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
node.type = n.type;
|
|
1168
|
+
node._def = def;
|
|
1169
|
+
if (n.type.substring(0, 7) === 'subflow') {
|
|
1170
|
+
var parentId = n.type.split(':')[1];
|
|
1171
|
+
var subflow =
|
|
1172
|
+
subflow_blacklist[parentId] ||
|
|
1173
|
+
subflow_map[parentId] ||
|
|
1174
|
+
getSubflow(parentId);
|
|
1175
|
+
if (createNewIds) {
|
|
1176
|
+
parentId = subflow.id;
|
|
1177
|
+
node.type = 'subflow:' + parentId;
|
|
1178
|
+
node._def = registry.getNodeType(node.type);
|
|
1179
|
+
delete node.i;
|
|
1180
|
+
}
|
|
1181
|
+
node.name = n.name;
|
|
1182
|
+
node.outputs = subflow.out.length;
|
|
1183
|
+
node.inputs = subflow.in.length;
|
|
1184
|
+
node.env = n.env;
|
|
1185
|
+
} else {
|
|
1186
|
+
if (!node._def) {
|
|
1187
|
+
if (node.x && node.y) {
|
|
1188
|
+
node._def = {
|
|
1189
|
+
color: '#fee',
|
|
1190
|
+
defaults: {},
|
|
1191
|
+
label: 'unknown: ' + n.type,
|
|
1192
|
+
labelStyle: 'node_label_italic',
|
|
1193
|
+
outputs: n.outputs || n.wires.length,
|
|
1194
|
+
set: registry.getNodeSet('kumologica-core/unknown'),
|
|
1195
|
+
};
|
|
1196
|
+
} else {
|
|
1197
|
+
node._def = {
|
|
1198
|
+
category: 'config',
|
|
1199
|
+
set: registry.getNodeSet('kumologica-core/unknown'),
|
|
1200
|
+
};
|
|
1201
|
+
node.users = [];
|
|
1202
|
+
// This is a config node, so delete the default
|
|
1203
|
+
// non-config node properties
|
|
1204
|
+
delete node.x;
|
|
1205
|
+
delete node.y;
|
|
1206
|
+
delete node.wires;
|
|
1207
|
+
delete node.inputLabels;
|
|
1208
|
+
delete node.outputLabels;
|
|
1209
|
+
}
|
|
1210
|
+
var orig = {};
|
|
1211
|
+
for (var p in n) {
|
|
1212
|
+
if (
|
|
1213
|
+
n.hasOwnProperty(p) &&
|
|
1214
|
+
p != 'x' &&
|
|
1215
|
+
p != 'y' &&
|
|
1216
|
+
p != 'z' &&
|
|
1217
|
+
p != 'id' &&
|
|
1218
|
+
p != 'wires'
|
|
1219
|
+
) {
|
|
1220
|
+
orig[p] = n[p];
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
node._orig = orig;
|
|
1224
|
+
node.name = n.type;
|
|
1225
|
+
node.type = 'unknown';
|
|
1226
|
+
}
|
|
1227
|
+
if (node._def.category != 'config') {
|
|
1228
|
+
if (n.hasOwnProperty('inputs')) {
|
|
1229
|
+
node.inputs = n.inputs;
|
|
1230
|
+
node._config.inputs = JSON.stringify(n.inputs);
|
|
1231
|
+
} else {
|
|
1232
|
+
node.inputs = node._def.inputs;
|
|
1233
|
+
}
|
|
1234
|
+
if (n.hasOwnProperty('outputs')) {
|
|
1235
|
+
node.outputs = n.outputs;
|
|
1236
|
+
node._config.outputs = JSON.stringify(n.outputs);
|
|
1237
|
+
} else {
|
|
1238
|
+
node.outputs = node._def.outputs;
|
|
1239
|
+
}
|
|
1240
|
+
if (
|
|
1241
|
+
node.hasOwnProperty('wires') &&
|
|
1242
|
+
node.wires.length > node.outputs
|
|
1243
|
+
) {
|
|
1244
|
+
if (
|
|
1245
|
+
!node._def.defaults.hasOwnProperty('outputs') ||
|
|
1246
|
+
!isNaN(parseInt(n.outputs))
|
|
1247
|
+
) {
|
|
1248
|
+
// If 'wires' is longer than outputs, clip wires
|
|
1249
|
+
console.log(
|
|
1250
|
+
'Warning: node.wires longer than node.outputs - trimming wires:',
|
|
1251
|
+
node.id,
|
|
1252
|
+
' wires:',
|
|
1253
|
+
node.wires.length,
|
|
1254
|
+
' outputs:',
|
|
1255
|
+
node.outputs
|
|
1256
|
+
);
|
|
1257
|
+
node.wires = node.wires.slice(0, node.outputs);
|
|
1258
|
+
} else {
|
|
1259
|
+
// The node declares outputs in its defaults, but has not got a valid value
|
|
1260
|
+
// Defer to the length of the wires array
|
|
1261
|
+
node.outputs = node.wires.length;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
for (d in node._def.defaults) {
|
|
1265
|
+
if (
|
|
1266
|
+
node._def.defaults.hasOwnProperty(d) &&
|
|
1267
|
+
d !== 'inputs' &&
|
|
1268
|
+
d !== 'outputs'
|
|
1269
|
+
) {
|
|
1270
|
+
node[d] = n[d];
|
|
1271
|
+
node._config[d] = JSON.stringify(n[d]);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
node._config.x = node.x;
|
|
1275
|
+
node._config.y = node.y;
|
|
1276
|
+
if (
|
|
1277
|
+
node._def.hasOwnProperty('credentials') &&
|
|
1278
|
+
n.hasOwnProperty('credentials')
|
|
1279
|
+
) {
|
|
1280
|
+
node.credentials = {};
|
|
1281
|
+
for (d in node._def.credentials) {
|
|
1282
|
+
if (
|
|
1283
|
+
node._def.credentials.hasOwnProperty(d) &&
|
|
1284
|
+
n.credentials.hasOwnProperty(d)
|
|
1285
|
+
) {
|
|
1286
|
+
node.credentials[d] = n.credentials[d];
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
addNode(node);
|
|
1293
|
+
RED.editor.validateNode(node);
|
|
1294
|
+
node_map[n.id] = node;
|
|
1295
|
+
// If an 'unknown' config node, it will not have been caught by the
|
|
1296
|
+
// proper config node handling, so needs adding to new_nodes here
|
|
1297
|
+
if (node.type === 'unknown' || node._def.category !== 'config') {
|
|
1298
|
+
new_nodes.push(node);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
// TODO: make this a part of the node definition so it doesn't have to
|
|
1304
|
+
// be hardcoded here
|
|
1305
|
+
var nodeTypeArrayReferences = {
|
|
1306
|
+
catch: 'scope',
|
|
1307
|
+
status: 'scope',
|
|
1308
|
+
'link in': 'links',
|
|
1309
|
+
'link out': 'links',
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1312
|
+
// Remap all wires and config node references
|
|
1313
|
+
for (i = 0; i < new_nodes.length; i++) {
|
|
1314
|
+
n = new_nodes[i];
|
|
1315
|
+
if (n.wires) {
|
|
1316
|
+
for (var w1 = 0; w1 < n.wires.length; w1++) {
|
|
1317
|
+
var wires =
|
|
1318
|
+
n.wires[w1] instanceof Array ? n.wires[w1] : [n.wires[w1]];
|
|
1319
|
+
for (var w2 = 0; w2 < wires.length; w2++) {
|
|
1320
|
+
if (node_map.hasOwnProperty(wires[w2])) {
|
|
1321
|
+
if (n.z === node_map[wires[w2]].z) {
|
|
1322
|
+
var link = {
|
|
1323
|
+
source: n,
|
|
1324
|
+
sourcePort: w1,
|
|
1325
|
+
target: node_map[wires[w2]],
|
|
1326
|
+
};
|
|
1327
|
+
addLink(link);
|
|
1328
|
+
new_links.push(link);
|
|
1329
|
+
} else {
|
|
1330
|
+
console.log(
|
|
1331
|
+
'Warning: dropping link that crosses tabs:',
|
|
1332
|
+
n.id,
|
|
1333
|
+
'->',
|
|
1334
|
+
node_map[wires[w2]].id
|
|
1335
|
+
);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
delete n.wires;
|
|
1341
|
+
}
|
|
1342
|
+
for (var d3 in n._def.defaults) {
|
|
1343
|
+
if (n._def.defaults.hasOwnProperty(d3)) {
|
|
1344
|
+
if (n._def.defaults[d3].type && node_map[n[d3]]) {
|
|
1345
|
+
n[d3] = node_map[n[d3]].id;
|
|
1346
|
+
configNode = RED.nodes.node(n[d3]);
|
|
1347
|
+
if (configNode && configNode.users.indexOf(n) === -1) {
|
|
1348
|
+
configNode.users.push(n);
|
|
1349
|
+
}
|
|
1350
|
+
} else if (
|
|
1351
|
+
nodeTypeArrayReferences.hasOwnProperty(n.type) &&
|
|
1352
|
+
nodeTypeArrayReferences[n.type] === d3 &&
|
|
1353
|
+
n[d3] !== undefined &&
|
|
1354
|
+
n[d3] !== null
|
|
1355
|
+
) {
|
|
1356
|
+
for (var j = 0; j < n[d3].length; j++) {
|
|
1357
|
+
if (node_map[n[d3][j]]) {
|
|
1358
|
+
n[d3][j] = node_map[n[d3][j]].id;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
// If importing into a subflow, ensure an outbound-link doesn't
|
|
1365
|
+
// get added
|
|
1366
|
+
if (activeSubflow && /^link /.test(n.type) && n.links) {
|
|
1367
|
+
n.links = n.links.filter(function (id) {
|
|
1368
|
+
var otherNode = RED.nodes.node(id);
|
|
1369
|
+
return otherNode && otherNode.z === activeWorkspace;
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
// With all properties now remapped to point at valid nodes,
|
|
1374
|
+
// we can validate the node
|
|
1375
|
+
RED.editor.validateNode(n);
|
|
1376
|
+
}
|
|
1377
|
+
for (i = 0; i < new_subflows.length; i++) {
|
|
1378
|
+
n = new_subflows[i];
|
|
1379
|
+
n.in.forEach(function (input) {
|
|
1380
|
+
input.wires.forEach(function (wire) {
|
|
1381
|
+
var link = {
|
|
1382
|
+
source: input,
|
|
1383
|
+
sourcePort: 0,
|
|
1384
|
+
target: node_map[wire.id],
|
|
1385
|
+
};
|
|
1386
|
+
addLink(link);
|
|
1387
|
+
new_links.push(link);
|
|
1388
|
+
});
|
|
1389
|
+
delete input.wires;
|
|
1390
|
+
});
|
|
1391
|
+
n.out.forEach(function (output) {
|
|
1392
|
+
output.wires.forEach(function (wire) {
|
|
1393
|
+
var link;
|
|
1394
|
+
if (subflow_map[wire.id] && subflow_map[wire.id].id == n.id) {
|
|
1395
|
+
link = {
|
|
1396
|
+
source: n.in[wire.port],
|
|
1397
|
+
sourcePort: wire.port,
|
|
1398
|
+
target: output,
|
|
1399
|
+
};
|
|
1400
|
+
} else {
|
|
1401
|
+
link = {
|
|
1402
|
+
source: node_map[wire.id] || subflow_map[wire.id],
|
|
1403
|
+
sourcePort: wire.port,
|
|
1404
|
+
target: output,
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
addLink(link);
|
|
1408
|
+
new_links.push(link);
|
|
1409
|
+
});
|
|
1410
|
+
delete output.wires;
|
|
1411
|
+
});
|
|
1412
|
+
if (n.status) {
|
|
1413
|
+
n.status.wires.forEach(function (wire) {
|
|
1414
|
+
var link;
|
|
1415
|
+
if (subflow_map[wire.id] && subflow_map[wire.id].id == n.id) {
|
|
1416
|
+
link = {
|
|
1417
|
+
source: n.in[wire.port],
|
|
1418
|
+
sourcePort: wire.port,
|
|
1419
|
+
target: n.status,
|
|
1420
|
+
};
|
|
1421
|
+
} else {
|
|
1422
|
+
link = {
|
|
1423
|
+
source: node_map[wire.id] || subflow_map[wire.id],
|
|
1424
|
+
sourcePort: wire.port,
|
|
1425
|
+
target: n.status,
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
addLink(link);
|
|
1429
|
+
new_links.push(link);
|
|
1430
|
+
});
|
|
1431
|
+
delete n.status.wires;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
RED.workspaces.refresh();
|
|
1436
|
+
return [
|
|
1437
|
+
new_nodes,
|
|
1438
|
+
new_links,
|
|
1439
|
+
new_workspaces,
|
|
1440
|
+
new_subflows,
|
|
1441
|
+
missingWorkspace,
|
|
1442
|
+
];
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
// TODO: supports properties: "z", "type", "selected"
|
|
1446
|
+
function filterNodes(filter) {
|
|
1447
|
+
var result = [];
|
|
1448
|
+
|
|
1449
|
+
for (var n = 0; n < nodes.length; n++) {
|
|
1450
|
+
var node = nodes[n];
|
|
1451
|
+
if (
|
|
1452
|
+
(filter.hasOwnProperty('z') && node.z !== filter.z) ||
|
|
1453
|
+
(filter.hasOwnProperty('type') && node.type !== filter.type) ||
|
|
1454
|
+
(filter.hasOwnProperty('selected') && node.selected !== filter.selected) ||
|
|
1455
|
+
(filter.hasOwnProperty('id') && !filter.id.includes(node.id))
|
|
1456
|
+
) {
|
|
1457
|
+
continue;
|
|
1458
|
+
}
|
|
1459
|
+
result.push(node);
|
|
1460
|
+
}
|
|
1461
|
+
return result;
|
|
1462
|
+
}
|
|
1463
|
+
function filterLinks(filter) {
|
|
1464
|
+
var result = [];
|
|
1465
|
+
|
|
1466
|
+
for (var n = 0; n < links.length; n++) {
|
|
1467
|
+
var link = links[n];
|
|
1468
|
+
if (filter.source) {
|
|
1469
|
+
if (
|
|
1470
|
+
filter.source.hasOwnProperty('id') &&
|
|
1471
|
+
link.source.id !== filter.source.id
|
|
1472
|
+
) {
|
|
1473
|
+
continue;
|
|
1474
|
+
}
|
|
1475
|
+
if (
|
|
1476
|
+
filter.source.hasOwnProperty('z') &&
|
|
1477
|
+
link.source.z !== filter.source.z
|
|
1478
|
+
) {
|
|
1479
|
+
continue;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
if (filter.target) {
|
|
1483
|
+
if (
|
|
1484
|
+
filter.target.hasOwnProperty('id') &&
|
|
1485
|
+
link.target.id !== filter.target.id
|
|
1486
|
+
) {
|
|
1487
|
+
continue;
|
|
1488
|
+
}
|
|
1489
|
+
if (
|
|
1490
|
+
filter.target.hasOwnProperty('z') &&
|
|
1491
|
+
link.target.z !== filter.target.z
|
|
1492
|
+
) {
|
|
1493
|
+
continue;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
if (
|
|
1497
|
+
filter.hasOwnProperty('sourcePort') &&
|
|
1498
|
+
link.sourcePort !== filter.sourcePort
|
|
1499
|
+
) {
|
|
1500
|
+
continue;
|
|
1501
|
+
}
|
|
1502
|
+
result.push(link);
|
|
1503
|
+
}
|
|
1504
|
+
return result;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
// Update any config nodes referenced by the provided node to ensure their 'users' list is correct
|
|
1508
|
+
function updateConfigNodeUsers(n) {
|
|
1509
|
+
for (var d in n._def.defaults) {
|
|
1510
|
+
if (n._def.defaults.hasOwnProperty(d)) {
|
|
1511
|
+
var property = n._def.defaults[d];
|
|
1512
|
+
if (property.type) {
|
|
1513
|
+
var type = registry.getNodeType(property.type);
|
|
1514
|
+
if (type && type.category == 'config') {
|
|
1515
|
+
var configNode = configNodes[n[d]];
|
|
1516
|
+
if (configNode) {
|
|
1517
|
+
if (configNode.users.indexOf(n) === -1) {
|
|
1518
|
+
configNode.users.push(n);
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
function flowVersion(version) {
|
|
1528
|
+
if (version !== undefined) {
|
|
1529
|
+
loadedFlowVersion = version;
|
|
1530
|
+
} else {
|
|
1531
|
+
return loadedFlowVersion;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
function clear() {
|
|
1536
|
+
nodes = [];
|
|
1537
|
+
links = [];
|
|
1538
|
+
configNodes = {};
|
|
1539
|
+
workspacesOrder = [];
|
|
1540
|
+
var subflowIds = Object.keys(subflows);
|
|
1541
|
+
subflowIds.forEach(function (id) {
|
|
1542
|
+
RED.subflow.removeSubflow(id);
|
|
1543
|
+
});
|
|
1544
|
+
var workspaceIds = Object.keys(workspaces);
|
|
1545
|
+
workspaceIds.forEach(function (id) {
|
|
1546
|
+
RED.workspaces.remove(workspaces[id]);
|
|
1547
|
+
});
|
|
1548
|
+
defaultWorkspace = null;
|
|
1549
|
+
initialLoad = null;
|
|
1550
|
+
RED.nodes.dirty(false);
|
|
1551
|
+
RED.view.redraw(true);
|
|
1552
|
+
RED.palette.refresh();
|
|
1553
|
+
RED.workspaces.refresh();
|
|
1554
|
+
RED.sidebar.config.refresh();
|
|
1555
|
+
RED.sidebar.info.refresh();
|
|
1556
|
+
|
|
1557
|
+
// var node_defs = {};
|
|
1558
|
+
// var nodes = [];
|
|
1559
|
+
// var configNodes = {};
|
|
1560
|
+
// var links = [];
|
|
1561
|
+
// var defaultWorkspace;
|
|
1562
|
+
// var workspaces = {};
|
|
1563
|
+
// var workspacesOrder =[];
|
|
1564
|
+
// var subflows = {};
|
|
1565
|
+
// var loadedFlowVersion = null;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
return {
|
|
1569
|
+
init: function () {
|
|
1570
|
+
RED.events.on('registry:node-type-added', function (type) {
|
|
1571
|
+
var def = registry.getNodeType(type);
|
|
1572
|
+
var replaced = false;
|
|
1573
|
+
var replaceNodes = {};
|
|
1574
|
+
RED.nodes.eachNode(function (n) {
|
|
1575
|
+
if (n.type === 'unknown' && n.name === type) {
|
|
1576
|
+
replaceNodes[n.id] = n;
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
RED.nodes.eachConfig(function (n) {
|
|
1580
|
+
if (n.type === 'unknown' && n.name === type) {
|
|
1581
|
+
replaceNodes[n.id] = n;
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
|
|
1585
|
+
var replaceNodeIds = Object.keys(replaceNodes);
|
|
1586
|
+
if (replaceNodeIds.length > 0) {
|
|
1587
|
+
var reimportList = [];
|
|
1588
|
+
replaceNodeIds.forEach(function (id) {
|
|
1589
|
+
var n = replaceNodes[id];
|
|
1590
|
+
if (configNodes.hasOwnProperty(n.id)) {
|
|
1591
|
+
delete configNodes[n.id];
|
|
1592
|
+
} else {
|
|
1593
|
+
nodes.splice(nodes.indexOf(n), 1);
|
|
1594
|
+
}
|
|
1595
|
+
reimportList.push(convertNode(n));
|
|
1596
|
+
});
|
|
1597
|
+
|
|
1598
|
+
// Remove any links between nodes that are going to be reimported.
|
|
1599
|
+
// This prevents a duplicate link from being added.
|
|
1600
|
+
var removeLinks = [];
|
|
1601
|
+
RED.nodes.eachLink(function (l) {
|
|
1602
|
+
if (
|
|
1603
|
+
replaceNodes.hasOwnProperty(l.source.id) &&
|
|
1604
|
+
replaceNodes.hasOwnProperty(l.target.id)
|
|
1605
|
+
) {
|
|
1606
|
+
removeLinks.push(l);
|
|
1607
|
+
}
|
|
1608
|
+
});
|
|
1609
|
+
removeLinks.forEach(removeLink);
|
|
1610
|
+
|
|
1611
|
+
RED.view.redraw(true);
|
|
1612
|
+
var result = importNodes(reimportList, false);
|
|
1613
|
+
var newNodeMap = {};
|
|
1614
|
+
result[0].forEach(function (n) {
|
|
1615
|
+
newNodeMap[n.id] = n;
|
|
1616
|
+
});
|
|
1617
|
+
RED.nodes.eachLink(function (l) {
|
|
1618
|
+
if (newNodeMap.hasOwnProperty(l.source.id)) {
|
|
1619
|
+
l.source = newNodeMap[l.source.id];
|
|
1620
|
+
}
|
|
1621
|
+
if (newNodeMap.hasOwnProperty(l.target.id)) {
|
|
1622
|
+
l.target = newNodeMap[l.target.id];
|
|
1623
|
+
}
|
|
1624
|
+
});
|
|
1625
|
+
RED.view.redraw(true);
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
},
|
|
1629
|
+
registry: registry,
|
|
1630
|
+
setNodeList: registry.setNodeList,
|
|
1631
|
+
|
|
1632
|
+
getNodeSet: registry.getNodeSet,
|
|
1633
|
+
addNodeSet: registry.addNodeSet,
|
|
1634
|
+
removeNodeSet: registry.removeNodeSet,
|
|
1635
|
+
enableNodeSet: registry.enableNodeSet,
|
|
1636
|
+
disableNodeSet: registry.disableNodeSet,
|
|
1637
|
+
|
|
1638
|
+
setIconSets: registry.setIconSets,
|
|
1639
|
+
getIconSets: registry.getIconSets,
|
|
1640
|
+
|
|
1641
|
+
registerType: registry.registerNodeType,
|
|
1642
|
+
getType: registry.getNodeType,
|
|
1643
|
+
convertNode: convertNode,
|
|
1644
|
+
|
|
1645
|
+
add: addNode,
|
|
1646
|
+
remove: removeNode,
|
|
1647
|
+
clear: clear,
|
|
1648
|
+
|
|
1649
|
+
addLink: addLink,
|
|
1650
|
+
removeLink: removeLink,
|
|
1651
|
+
|
|
1652
|
+
addWorkspace: addWorkspace,
|
|
1653
|
+
removeWorkspace: removeWorkspace,
|
|
1654
|
+
getWorkspaceOrder: function () {
|
|
1655
|
+
return workspacesOrder;
|
|
1656
|
+
},
|
|
1657
|
+
setWorkspaceOrder: function (order) {
|
|
1658
|
+
workspacesOrder = order;
|
|
1659
|
+
},
|
|
1660
|
+
workspace: getWorkspace,
|
|
1661
|
+
|
|
1662
|
+
addSubflow: addSubflow,
|
|
1663
|
+
removeSubflow: removeSubflow,
|
|
1664
|
+
subflow: getSubflow,
|
|
1665
|
+
subflowContains: subflowContains,
|
|
1666
|
+
|
|
1667
|
+
eachNode: function (cb) {
|
|
1668
|
+
for (var n = 0; n < nodes.length; n++) {
|
|
1669
|
+
if (cb(nodes[n]) === false) {
|
|
1670
|
+
break;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
},
|
|
1674
|
+
eachLink: function (cb) {
|
|
1675
|
+
for (var l = 0; l < links.length; l++) {
|
|
1676
|
+
if (cb(links[l]) === false) {
|
|
1677
|
+
break;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
},
|
|
1681
|
+
eachConfig: function (cb) {
|
|
1682
|
+
for (var id in configNodes) {
|
|
1683
|
+
if (configNodes.hasOwnProperty(id)) {
|
|
1684
|
+
if (cb(configNodes[id]) === false) {
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
},
|
|
1690
|
+
eachSubflow: function (cb) {
|
|
1691
|
+
for (var id in subflows) {
|
|
1692
|
+
if (subflows.hasOwnProperty(id)) {
|
|
1693
|
+
if (cb(subflows[id]) === false) {
|
|
1694
|
+
break;
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
},
|
|
1699
|
+
eachWorkspace: function (cb) {
|
|
1700
|
+
for (var i = 0; i < workspacesOrder.length; i++) {
|
|
1701
|
+
if (cb(workspaces[workspacesOrder[i]]) === false) {
|
|
1702
|
+
break;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
},
|
|
1706
|
+
|
|
1707
|
+
node: getNode,
|
|
1708
|
+
|
|
1709
|
+
version: flowVersion,
|
|
1710
|
+
originalFlow: function (flow) {
|
|
1711
|
+
if (flow === undefined) {
|
|
1712
|
+
return initialLoad;
|
|
1713
|
+
} else {
|
|
1714
|
+
initialLoad = flow;
|
|
1715
|
+
}
|
|
1716
|
+
},
|
|
1717
|
+
|
|
1718
|
+
filterNodes: filterNodes,
|
|
1719
|
+
filterLinks: filterLinks,
|
|
1720
|
+
|
|
1721
|
+
import: importNodes,
|
|
1722
|
+
|
|
1723
|
+
getAllFlowNodes: getAllFlowNodes,
|
|
1724
|
+
createExportableNodeSet: createExportableNodeSet,
|
|
1725
|
+
createCompleteNodeSet: createCompleteNodeSet,
|
|
1726
|
+
updateConfigNodeUsers: updateConfigNodeUsers,
|
|
1727
|
+
id: getID,
|
|
1728
|
+
dirty: function (d) {
|
|
1729
|
+
if (d == null) {
|
|
1730
|
+
return dirty;
|
|
1731
|
+
} else {
|
|
1732
|
+
setDirty(d);
|
|
1733
|
+
}
|
|
1734
|
+
},
|
|
1735
|
+
};
|
|
1736
|
+
})();
|