@flowdrop/flowdrop 1.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/LICENSE +21 -0
- package/README.md +252 -0
- package/dist/adapters/WorkflowAdapter.d.ts +167 -0
- package/dist/adapters/WorkflowAdapter.js +368 -0
- package/dist/adapters/agentspec/AgentSpecAdapter.d.ts +96 -0
- package/dist/adapters/agentspec/AgentSpecAdapter.js +626 -0
- package/dist/adapters/agentspec/agentAdapter.d.ts +59 -0
- package/dist/adapters/agentspec/agentAdapter.js +91 -0
- package/dist/adapters/agentspec/autoLayout.d.ts +34 -0
- package/dist/adapters/agentspec/autoLayout.js +127 -0
- package/dist/adapters/agentspec/componentTypeDefaults.d.ts +73 -0
- package/dist/adapters/agentspec/componentTypeDefaults.js +238 -0
- package/dist/adapters/agentspec/defaultNodeTypes.d.ts +53 -0
- package/dist/adapters/agentspec/defaultNodeTypes.js +561 -0
- package/dist/adapters/agentspec/index.d.ts +37 -0
- package/dist/adapters/agentspec/index.js +39 -0
- package/dist/adapters/agentspec/validator.d.ts +34 -0
- package/dist/adapters/agentspec/validator.js +169 -0
- package/dist/api/enhanced-client.d.ts +183 -0
- package/dist/api/enhanced-client.js +430 -0
- package/dist/components/App.svelte +981 -0
- package/dist/components/App.svelte.d.ts +54 -0
- package/dist/components/CanvasBanner.stories.svelte +29 -0
- package/dist/components/CanvasBanner.stories.svelte.d.ts +27 -0
- package/dist/components/CanvasBanner.svelte +57 -0
- package/dist/components/CanvasBanner.svelte.d.ts +8 -0
- package/dist/components/ConfigForm.svelte +1138 -0
- package/dist/components/ConfigForm.svelte.d.ts +44 -0
- package/dist/components/ConfigModal.svelte +188 -0
- package/dist/components/ConfigModal.svelte.d.ts +13 -0
- package/dist/components/ConfigPanel.stories.svelte +47 -0
- package/dist/components/ConfigPanel.stories.svelte.d.ts +27 -0
- package/dist/components/ConfigPanel.svelte +182 -0
- package/dist/components/ConfigPanel.svelte.d.ts +32 -0
- package/dist/components/ConnectionLine.svelte +32 -0
- package/dist/components/ConnectionLine.svelte.d.ts +3 -0
- package/dist/components/EdgeRefresher.svelte +41 -0
- package/dist/components/EdgeRefresher.svelte.d.ts +9 -0
- package/dist/components/FlowDropZone.svelte +83 -0
- package/dist/components/FlowDropZone.svelte.d.ts +13 -0
- package/dist/components/LoadingSpinner.stories.svelte +30 -0
- package/dist/components/LoadingSpinner.stories.svelte.d.ts +27 -0
- package/dist/components/LoadingSpinner.svelte +36 -0
- package/dist/components/LoadingSpinner.svelte.d.ts +8 -0
- package/dist/components/Logo.stories.svelte +22 -0
- package/dist/components/Logo.stories.svelte.d.ts +27 -0
- package/dist/components/Logo.svelte +102 -0
- package/dist/components/Logo.svelte.d.ts +26 -0
- package/dist/components/LogsSidebar.svelte +563 -0
- package/dist/components/LogsSidebar.svelte.d.ts +17 -0
- package/dist/components/MarkdownDisplay.stories.svelte +36 -0
- package/dist/components/MarkdownDisplay.stories.svelte.d.ts +27 -0
- package/dist/components/MarkdownDisplay.svelte +29 -0
- package/dist/components/MarkdownDisplay.svelte.d.ts +7 -0
- package/dist/components/Navbar.stories.svelte +53 -0
- package/dist/components/Navbar.stories.svelte.d.ts +27 -0
- package/dist/components/Navbar.svelte +726 -0
- package/dist/components/Navbar.svelte.d.ts +29 -0
- package/dist/components/NodeSidebar.svelte +762 -0
- package/dist/components/NodeSidebar.svelte.d.ts +9 -0
- package/dist/components/NodeStatusOverlay.stories.svelte +85 -0
- package/dist/components/NodeStatusOverlay.stories.svelte.d.ts +27 -0
- package/dist/components/NodeStatusOverlay.svelte +327 -0
- package/dist/components/NodeStatusOverlay.svelte.d.ts +11 -0
- package/dist/components/PipelineStatus.svelte +314 -0
- package/dist/components/PipelineStatus.svelte.d.ts +20 -0
- package/dist/components/PortCoordinateTracker.svelte +58 -0
- package/dist/components/PortCoordinateTracker.svelte.d.ts +12 -0
- package/dist/components/ReadOnlyDetails.svelte +170 -0
- package/dist/components/ReadOnlyDetails.svelte.d.ts +25 -0
- package/dist/components/SchemaForm.stories.svelte +116 -0
- package/dist/components/SchemaForm.stories.svelte.d.ts +27 -0
- package/dist/components/SchemaForm.svelte +536 -0
- package/dist/components/SchemaForm.svelte.d.ts +83 -0
- package/dist/components/SettingsModal.svelte +279 -0
- package/dist/components/SettingsModal.svelte.d.ts +23 -0
- package/dist/components/SettingsPanel.svelte +638 -0
- package/dist/components/SettingsPanel.svelte.d.ts +21 -0
- package/dist/components/StatusIcon.stories.svelte +60 -0
- package/dist/components/StatusIcon.stories.svelte.d.ts +27 -0
- package/dist/components/StatusIcon.svelte +119 -0
- package/dist/components/StatusIcon.svelte.d.ts +10 -0
- package/dist/components/StatusLabel.stories.svelte +17 -0
- package/dist/components/StatusLabel.stories.svelte.d.ts +27 -0
- package/dist/components/StatusLabel.svelte +33 -0
- package/dist/components/StatusLabel.svelte.d.ts +7 -0
- package/dist/components/ThemeToggle.stories.svelte +25 -0
- package/dist/components/ThemeToggle.stories.svelte.d.ts +27 -0
- package/dist/components/ThemeToggle.svelte +185 -0
- package/dist/components/ThemeToggle.svelte.d.ts +14 -0
- package/dist/components/UniversalNode.svelte +155 -0
- package/dist/components/UniversalNode.svelte.d.ts +15 -0
- package/dist/components/WorkflowEditor.svelte +1035 -0
- package/dist/components/WorkflowEditor.svelte.d.ts +23 -0
- package/dist/components/form/FormArray.svelte +1049 -0
- package/dist/components/form/FormArray.svelte.d.ts +22 -0
- package/dist/components/form/FormAutocomplete.svelte +1009 -0
- package/dist/components/form/FormAutocomplete.svelte.d.ts +25 -0
- package/dist/components/form/FormCheckboxGroup.stories.svelte +28 -0
- package/dist/components/form/FormCheckboxGroup.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormCheckboxGroup.svelte +155 -0
- package/dist/components/form/FormCheckboxGroup.svelte.d.ts +17 -0
- package/dist/components/form/FormCodeEditor.svelte +458 -0
- package/dist/components/form/FormCodeEditor.svelte.d.ts +25 -0
- package/dist/components/form/FormField.svelte +417 -0
- package/dist/components/form/FormField.svelte.d.ts +29 -0
- package/dist/components/form/FormFieldLight.svelte +425 -0
- package/dist/components/form/FormFieldLight.svelte.d.ts +18 -0
- package/dist/components/form/FormFieldWrapper.stories.svelte +53 -0
- package/dist/components/form/FormFieldWrapper.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormFieldWrapper.svelte +125 -0
- package/dist/components/form/FormFieldWrapper.svelte.d.ts +18 -0
- package/dist/components/form/FormFieldset.svelte +142 -0
- package/dist/components/form/FormFieldset.svelte.d.ts +11 -0
- package/dist/components/form/FormMarkdownEditor.svelte +752 -0
- package/dist/components/form/FormMarkdownEditor.svelte.d.ts +33 -0
- package/dist/components/form/FormNumberField.stories.svelte +36 -0
- package/dist/components/form/FormNumberField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormNumberField.svelte +112 -0
- package/dist/components/form/FormNumberField.svelte.d.ts +25 -0
- package/dist/components/form/FormRangeField.stories.svelte +31 -0
- package/dist/components/form/FormRangeField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormRangeField.svelte +246 -0
- package/dist/components/form/FormRangeField.svelte.d.ts +23 -0
- package/dist/components/form/FormSelect.stories.svelte +50 -0
- package/dist/components/form/FormSelect.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormSelect.svelte +129 -0
- package/dist/components/form/FormSelect.svelte.d.ts +20 -0
- package/dist/components/form/FormTemplateEditor.svelte +825 -0
- package/dist/components/form/FormTemplateEditor.svelte.d.ts +41 -0
- package/dist/components/form/FormTextField.stories.svelte +30 -0
- package/dist/components/form/FormTextField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormTextField.svelte +91 -0
- package/dist/components/form/FormTextField.svelte.d.ts +19 -0
- package/dist/components/form/FormTextarea.stories.svelte +34 -0
- package/dist/components/form/FormTextarea.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormTextarea.svelte +97 -0
- package/dist/components/form/FormTextarea.svelte.d.ts +21 -0
- package/dist/components/form/FormToggle.stories.svelte +30 -0
- package/dist/components/form/FormToggle.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormToggle.svelte +126 -0
- package/dist/components/form/FormToggle.svelte.d.ts +19 -0
- package/dist/components/form/FormUISchemaRenderer.svelte +136 -0
- package/dist/components/form/FormUISchemaRenderer.svelte.d.ts +32 -0
- package/dist/components/form/index.d.ts +50 -0
- package/dist/components/form/index.js +54 -0
- package/dist/components/form/templateAutocomplete.d.ts +29 -0
- package/dist/components/form/templateAutocomplete.js +254 -0
- package/dist/components/form/types.d.ts +485 -0
- package/dist/components/form/types.js +73 -0
- package/dist/components/interrupt/ChoicePrompt.stories.svelte +52 -0
- package/dist/components/interrupt/ChoicePrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ChoicePrompt.svelte +401 -0
- package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte +71 -0
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte +292 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +25 -0
- package/dist/components/interrupt/FormPrompt.svelte +236 -0
- package/dist/components/interrupt/FormPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/InterruptBubble.svelte +601 -0
- package/dist/components/interrupt/InterruptBubble.svelte.d.ts +16 -0
- package/dist/components/interrupt/ReviewPrompt.stories.svelte +67 -0
- package/dist/components/interrupt/ReviewPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ReviewPrompt.svelte +861 -0
- package/dist/components/interrupt/ReviewPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/TextInputPrompt.stories.svelte +47 -0
- package/dist/components/interrupt/TextInputPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/TextInputPrompt.svelte +346 -0
- package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/index.d.ts +13 -0
- package/dist/components/interrupt/index.js +15 -0
- package/dist/components/layouts/MainLayout.svelte +718 -0
- package/dist/components/layouts/MainLayout.svelte.d.ts +62 -0
- package/dist/components/nodes/GatewayNode.stories.svelte +108 -0
- package/dist/components/nodes/GatewayNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/GatewayNode.svelte +591 -0
- package/dist/components/nodes/GatewayNode.svelte.d.ts +15 -0
- package/dist/components/nodes/IdeaNode.stories.svelte +52 -0
- package/dist/components/nodes/IdeaNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/IdeaNode.svelte +455 -0
- package/dist/components/nodes/IdeaNode.svelte.d.ts +24 -0
- package/dist/components/nodes/NotesNode.stories.svelte +76 -0
- package/dist/components/nodes/NotesNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/NotesNode.svelte +378 -0
- package/dist/components/nodes/NotesNode.svelte.d.ts +24 -0
- package/dist/components/nodes/SimpleNode.stories.svelte +159 -0
- package/dist/components/nodes/SimpleNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/SimpleNode.svelte +451 -0
- package/dist/components/nodes/SimpleNode.svelte.d.ts +25 -0
- package/dist/components/nodes/SquareNode.stories.svelte +82 -0
- package/dist/components/nodes/SquareNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/SquareNode.svelte +407 -0
- package/dist/components/nodes/SquareNode.svelte.d.ts +25 -0
- package/dist/components/nodes/TerminalNode.stories.svelte +25 -0
- package/dist/components/nodes/TerminalNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/TerminalNode.svelte +690 -0
- package/dist/components/nodes/TerminalNode.svelte.d.ts +25 -0
- package/dist/components/nodes/ToolNode.stories.svelte +189 -0
- package/dist/components/nodes/ToolNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/ToolNode.svelte +471 -0
- package/dist/components/nodes/ToolNode.svelte.d.ts +36 -0
- package/dist/components/nodes/WorkflowNode.stories.svelte +55 -0
- package/dist/components/nodes/WorkflowNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/WorkflowNode.svelte +571 -0
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +15 -0
- package/dist/components/playground/ChatPanel.svelte +905 -0
- package/dist/components/playground/ChatPanel.svelte.d.ts +46 -0
- package/dist/components/playground/ExecutionLogs.svelte +488 -0
- package/dist/components/playground/ExecutionLogs.svelte.d.ts +14 -0
- package/dist/components/playground/InputCollector.svelte +444 -0
- package/dist/components/playground/InputCollector.svelte.d.ts +16 -0
- package/dist/components/playground/MessageBubble.stories.svelte +62 -0
- package/dist/components/playground/MessageBubble.stories.svelte.d.ts +27 -0
- package/dist/components/playground/MessageBubble.svelte +633 -0
- package/dist/components/playground/MessageBubble.svelte.d.ts +24 -0
- package/dist/components/playground/Playground.svelte +1075 -0
- package/dist/components/playground/Playground.svelte.d.ts +25 -0
- package/dist/components/playground/PlaygroundModal.svelte +220 -0
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +25 -0
- package/dist/components/playground/SessionManager.svelte +538 -0
- package/dist/components/playground/SessionManager.svelte.d.ts +20 -0
- package/dist/config/agentSpecEndpoints.d.ts +70 -0
- package/dist/config/agentSpecEndpoints.js +65 -0
- package/dist/config/constants.d.ts +43 -0
- package/dist/config/constants.js +31 -0
- package/dist/config/defaultCategories.d.ts +7 -0
- package/dist/config/defaultCategories.js +126 -0
- package/dist/config/defaultPortConfig.d.ts +6 -0
- package/dist/config/defaultPortConfig.js +201 -0
- package/dist/config/endpoints.d.ts +160 -0
- package/dist/config/endpoints.js +146 -0
- package/dist/config/runtimeConfig.d.ts +47 -0
- package/dist/config/runtimeConfig.js +80 -0
- package/dist/core/index.d.ts +75 -0
- package/dist/core/index.js +92 -0
- package/dist/display/index.d.ts +29 -0
- package/dist/display/index.js +36 -0
- package/dist/editor/index.d.ts +95 -0
- package/dist/editor/index.js +138 -0
- package/dist/form/code.d.ts +101 -0
- package/dist/form/code.js +168 -0
- package/dist/form/fieldRegistry.d.ts +169 -0
- package/dist/form/fieldRegistry.js +152 -0
- package/dist/form/full.d.ts +56 -0
- package/dist/form/full.js +80 -0
- package/dist/form/index.d.ts +77 -0
- package/dist/form/index.js +91 -0
- package/dist/form/markdown.d.ts +69 -0
- package/dist/form/markdown.js +103 -0
- package/dist/helpers/nodeLayoutHelper.d.ts +14 -0
- package/dist/helpers/nodeLayoutHelper.js +19 -0
- package/dist/helpers/proximityConnect.d.ts +94 -0
- package/dist/helpers/proximityConnect.js +314 -0
- package/dist/helpers/workflowEditorHelper.d.ts +183 -0
- package/dist/helpers/workflowEditorHelper.js +595 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +64 -0
- package/dist/mocks/app-environment.d.ts +8 -0
- package/dist/mocks/app-environment.js +16 -0
- package/dist/mocks/app-forms.d.ts +2 -0
- package/dist/mocks/app-forms.js +22 -0
- package/dist/mocks/app-navigation.d.ts +5 -0
- package/dist/mocks/app-navigation.js +36 -0
- package/dist/mocks/app-stores.d.ts +14 -0
- package/dist/mocks/app-stores.js +26 -0
- package/dist/playground/index.d.ts +131 -0
- package/dist/playground/index.js +172 -0
- package/dist/playground/mount.d.ts +203 -0
- package/dist/playground/mount.js +235 -0
- package/dist/registry/BaseRegistry.d.ts +92 -0
- package/dist/registry/BaseRegistry.js +124 -0
- package/dist/registry/builtinFormats.d.ts +23 -0
- package/dist/registry/builtinFormats.js +70 -0
- package/dist/registry/builtinNodes.d.ts +77 -0
- package/dist/registry/builtinNodes.js +211 -0
- package/dist/registry/index.d.ts +8 -0
- package/dist/registry/index.js +12 -0
- package/dist/registry/nodeComponentRegistry.d.ts +276 -0
- package/dist/registry/nodeComponentRegistry.js +262 -0
- package/dist/registry/plugin.d.ts +215 -0
- package/dist/registry/plugin.js +249 -0
- package/dist/registry/workflowFormatRegistry.d.ts +122 -0
- package/dist/registry/workflowFormatRegistry.js +96 -0
- package/dist/schema/index.d.ts +23 -0
- package/dist/schema/index.js +23 -0
- package/dist/schemas/v1/workflow.schema.json +1078 -0
- package/dist/services/agentSpecExecutionService.d.ts +106 -0
- package/dist/services/agentSpecExecutionService.js +334 -0
- package/dist/services/api.d.ts +115 -0
- package/dist/services/api.js +214 -0
- package/dist/services/apiVariableService.d.ts +114 -0
- package/dist/services/apiVariableService.js +338 -0
- package/dist/services/autoSaveService.d.ts +112 -0
- package/dist/services/autoSaveService.js +227 -0
- package/dist/services/categoriesApi.d.ts +14 -0
- package/dist/services/categoriesApi.js +49 -0
- package/dist/services/draftStorage.d.ts +171 -0
- package/dist/services/draftStorage.js +299 -0
- package/dist/services/dynamicSchemaService.d.ts +108 -0
- package/dist/services/dynamicSchemaService.js +444 -0
- package/dist/services/globalSave.d.ts +69 -0
- package/dist/services/globalSave.js +248 -0
- package/dist/services/historyService.d.ts +208 -0
- package/dist/services/historyService.js +321 -0
- package/dist/services/interruptService.d.ts +133 -0
- package/dist/services/interruptService.js +280 -0
- package/dist/services/nodeExecutionService.d.ts +63 -0
- package/dist/services/nodeExecutionService.js +266 -0
- package/dist/services/playgroundService.d.ts +130 -0
- package/dist/services/playgroundService.js +321 -0
- package/dist/services/portConfigApi.d.ts +14 -0
- package/dist/services/portConfigApi.js +54 -0
- package/dist/services/settingsService.d.ts +92 -0
- package/dist/services/settingsService.js +196 -0
- package/dist/services/toastService.d.ts +156 -0
- package/dist/services/toastService.js +265 -0
- package/dist/services/variableService.d.ts +141 -0
- package/dist/services/variableService.js +463 -0
- package/dist/services/workflowStorage.d.ts +37 -0
- package/dist/services/workflowStorage.js +116 -0
- package/dist/settings/index.d.ts +25 -0
- package/dist/settings/index.js +33 -0
- package/dist/stores/categoriesStore.svelte.d.ts +32 -0
- package/dist/stores/categoriesStore.svelte.js +77 -0
- package/dist/stores/editorStateMachine.svelte.d.ts +42 -0
- package/dist/stores/editorStateMachine.svelte.js +132 -0
- package/dist/stores/historyStore.svelte.d.ts +136 -0
- package/dist/stores/historyStore.svelte.js +207 -0
- package/dist/stores/interruptStore.svelte.d.ts +179 -0
- package/dist/stores/interruptStore.svelte.js +346 -0
- package/dist/stores/playgroundStore.svelte.d.ts +230 -0
- package/dist/stores/playgroundStore.svelte.js +515 -0
- package/dist/stores/portCoordinateStore.svelte.d.ts +66 -0
- package/dist/stores/portCoordinateStore.svelte.js +186 -0
- package/dist/stores/settingsStore.svelte.d.ts +158 -0
- package/dist/stores/settingsStore.svelte.js +544 -0
- package/dist/stores/workflowStore.svelte.d.ts +260 -0
- package/dist/stores/workflowStore.svelte.js +649 -0
- package/dist/stories/CanvasDecorator.svelte +49 -0
- package/dist/stories/CanvasDecorator.svelte.d.ts +8 -0
- package/dist/stories/NodeDecorator.svelte +73 -0
- package/dist/stories/NodeDecorator.svelte.d.ts +8 -0
- package/dist/stories/utils.d.ts +93 -0
- package/dist/stories/utils.js +122 -0
- package/dist/styles/base.css +1300 -0
- package/dist/styles/toast.css +35 -0
- package/dist/styles/tokens.css +475 -0
- package/dist/svelte-app.d.ts +150 -0
- package/dist/svelte-app.js +295 -0
- package/dist/types/agentspec.d.ts +318 -0
- package/dist/types/agentspec.js +48 -0
- package/dist/types/auth.d.ts +263 -0
- package/dist/types/auth.js +229 -0
- package/dist/types/config.d.ts +151 -0
- package/dist/types/config.js +7 -0
- package/dist/types/events.d.ts +190 -0
- package/dist/types/events.js +30 -0
- package/dist/types/index.d.ts +1234 -0
- package/dist/types/index.js +27 -0
- package/dist/types/interrupt.d.ts +390 -0
- package/dist/types/interrupt.js +145 -0
- package/dist/types/interruptState.d.ts +211 -0
- package/dist/types/interruptState.js +308 -0
- package/dist/types/playground.d.ts +351 -0
- package/dist/types/playground.js +95 -0
- package/dist/types/settings.d.ts +189 -0
- package/dist/types/settings.js +97 -0
- package/dist/types/uischema.d.ts +144 -0
- package/dist/types/uischema.js +51 -0
- package/dist/utils/colors.d.ts +288 -0
- package/dist/utils/colors.js +548 -0
- package/dist/utils/config.d.ts +37 -0
- package/dist/utils/config.js +226 -0
- package/dist/utils/connections.d.ts +125 -0
- package/dist/utils/connections.js +414 -0
- package/dist/utils/errors.d.ts +28 -0
- package/dist/utils/errors.js +44 -0
- package/dist/utils/fetchWithAuth.d.ts +25 -0
- package/dist/utils/fetchWithAuth.js +34 -0
- package/dist/utils/handleIds.d.ts +35 -0
- package/dist/utils/handleIds.js +58 -0
- package/dist/utils/handlePositioning.d.ts +31 -0
- package/dist/utils/handlePositioning.js +35 -0
- package/dist/utils/icons.d.ts +106 -0
- package/dist/utils/icons.js +157 -0
- package/dist/utils/logger.d.ts +47 -0
- package/dist/utils/logger.js +72 -0
- package/dist/utils/nodeStatus.d.ts +53 -0
- package/dist/utils/nodeStatus.js +183 -0
- package/dist/utils/nodeTypes.d.ts +117 -0
- package/dist/utils/nodeTypes.js +244 -0
- package/dist/utils/nodeWrapper.d.ts +39 -0
- package/dist/utils/nodeWrapper.js +62 -0
- package/dist/utils/performanceUtils.d.ts +30 -0
- package/dist/utils/performanceUtils.js +108 -0
- package/dist/utils/sanitize.d.ts +19 -0
- package/dist/utils/sanitize.js +31 -0
- package/dist/utils/uischema.d.ts +52 -0
- package/dist/utils/uischema.js +88 -0
- package/dist/utils/validation.d.ts +29 -0
- package/dist/utils/validation.js +39 -0
- package/package.json +292 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variable Service
|
|
3
|
+
* Derives available template variables from connected upstream nodes' output schemas.
|
|
4
|
+
* Used by the template editor for autocomplete suggestions.
|
|
5
|
+
*
|
|
6
|
+
* @module services/variableService
|
|
7
|
+
*/
|
|
8
|
+
import type { WorkflowNode, WorkflowEdge, VariableSchema, TemplateVariable, TemplateVariablesConfig, AuthProvider } from '../types/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Options for deriving available variables.
|
|
11
|
+
*/
|
|
12
|
+
export interface GetAvailableVariablesOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Filter to only include variables from specific input ports.
|
|
15
|
+
* If not specified, all input ports with connections are used.
|
|
16
|
+
* If specified as an empty array, no variables will be available.
|
|
17
|
+
*/
|
|
18
|
+
targetPortIds?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Whether to include the port name as a prefix for variables.
|
|
21
|
+
* When true, variables are named like `data.user` instead of just `user`.
|
|
22
|
+
* When false (default), schema properties are unpacked as top-level variables.
|
|
23
|
+
*/
|
|
24
|
+
includePortName?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Derives available template variables from connected upstream nodes.
|
|
28
|
+
* Variables are extracted from the output schemas of nodes connected to
|
|
29
|
+
* the current node's input ports.
|
|
30
|
+
*
|
|
31
|
+
* @param node - The current node being configured
|
|
32
|
+
* @param nodes - All nodes in the workflow
|
|
33
|
+
* @param edges - All edges in the workflow
|
|
34
|
+
* @param options - Optional configuration for filtering variables
|
|
35
|
+
* @returns A VariableSchema containing all available variables
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // Get variables from all connected ports
|
|
40
|
+
* const variableSchema = getAvailableVariables(currentNode, allNodes, allEdges);
|
|
41
|
+
*
|
|
42
|
+
* // Get variables only from specific input ports
|
|
43
|
+
* const filteredSchema = getAvailableVariables(currentNode, allNodes, allEdges, {
|
|
44
|
+
* targetPortIds: ["data", "context"]
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function getAvailableVariables(node: WorkflowNode, nodes: WorkflowNode[], edges: WorkflowEdge[], options?: GetAvailableVariablesOptions): VariableSchema;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the child variables for a given path in the variable schema.
|
|
51
|
+
* Used for drilling down into nested objects and arrays.
|
|
52
|
+
*
|
|
53
|
+
* @param schema - The variable schema
|
|
54
|
+
* @param path - The path to the parent variable (e.g., "user", "user.address")
|
|
55
|
+
* @returns Array of child variables, or empty array if none found
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* // For path "user" with schema containing user.name, user.email, user.address
|
|
60
|
+
* getChildVariables(schema, "user");
|
|
61
|
+
* // Returns: [{ name: "name", ... }, { name: "email", ... }, { name: "address", ... }]
|
|
62
|
+
*
|
|
63
|
+
* // For path "user.address" with schema containing city, country
|
|
64
|
+
* getChildVariables(schema, "user.address");
|
|
65
|
+
* // Returns: [{ name: "city", ... }, { name: "country", ... }]
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function getChildVariables(schema: VariableSchema, path: string): TemplateVariable[];
|
|
69
|
+
/**
|
|
70
|
+
* Gets suggestions for array index access.
|
|
71
|
+
* Returns common index options like [0], [1], [2], and [*] for all items.
|
|
72
|
+
*
|
|
73
|
+
* @param maxIndex - Maximum index to suggest (default: 2)
|
|
74
|
+
* @returns Array of index suggestion strings
|
|
75
|
+
*/
|
|
76
|
+
export declare function getArrayIndexSuggestions(maxIndex?: number): string[];
|
|
77
|
+
/**
|
|
78
|
+
* Checks if a variable at the given path is an array.
|
|
79
|
+
*
|
|
80
|
+
* @param schema - The variable schema
|
|
81
|
+
* @param path - The path to check (e.g., "items", "user.orders")
|
|
82
|
+
* @returns True if the variable is an array type
|
|
83
|
+
*/
|
|
84
|
+
export declare function isArrayVariable(schema: VariableSchema, path: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Checks if a variable at the given path has child properties.
|
|
87
|
+
*
|
|
88
|
+
* @param schema - The variable schema
|
|
89
|
+
* @param path - The path to check
|
|
90
|
+
* @returns True if the variable has children that can be drilled into
|
|
91
|
+
*/
|
|
92
|
+
export declare function hasChildren(schema: VariableSchema, path: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Merges two variable schemas together.
|
|
95
|
+
* Variables from the primary schema take precedence over the secondary schema.
|
|
96
|
+
*
|
|
97
|
+
* @param primary - The primary variable schema (takes precedence)
|
|
98
|
+
* @param secondary - The secondary variable schema
|
|
99
|
+
* @returns A merged VariableSchema
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const apiSchema = { variables: { apiKey: {...}, endpoint: {...} } };
|
|
104
|
+
* const staticSchema = { variables: { env: {...}, config: {...} } };
|
|
105
|
+
* const merged = mergeVariableSchemas(apiSchema, staticSchema);
|
|
106
|
+
* // Result: { variables: { apiKey, endpoint, env, config } }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare function mergeVariableSchemas(primary: VariableSchema, secondary: VariableSchema): VariableSchema;
|
|
110
|
+
/**
|
|
111
|
+
* Gets variable schema using the appropriate mode (API, schema-based, or hybrid).
|
|
112
|
+
* This is the main orchestration function that determines how to fetch variables
|
|
113
|
+
* based on the configuration.
|
|
114
|
+
*
|
|
115
|
+
* @param node - The current node being configured
|
|
116
|
+
* @param nodes - All nodes in the workflow
|
|
117
|
+
* @param edges - All edges in the workflow
|
|
118
|
+
* @param config - Template variables configuration
|
|
119
|
+
* @param workflowId - Optional workflow ID for API context
|
|
120
|
+
* @param authProvider - Optional auth provider for API requests
|
|
121
|
+
* @returns A promise that resolves to the variable schema
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* // Schema-based mode (existing behavior)
|
|
126
|
+
* const config = { ports: ["data"], schema: {...} };
|
|
127
|
+
* const schema = await getVariableSchema(node, nodes, edges, config);
|
|
128
|
+
*
|
|
129
|
+
* // API mode
|
|
130
|
+
* const config = { api: { endpoint: { url: "/api/variables/{workflowId}/{nodeId}" } } };
|
|
131
|
+
* const schema = await getVariableSchema(node, nodes, edges, config, workflowId, authProvider);
|
|
132
|
+
*
|
|
133
|
+
* // Hybrid mode (API + static schema)
|
|
134
|
+
* const config = {
|
|
135
|
+
* schema: {...},
|
|
136
|
+
* api: { endpoint: {...}, mergeWithSchema: true }
|
|
137
|
+
* };
|
|
138
|
+
* const schema = await getVariableSchema(node, nodes, edges, config, workflowId, authProvider);
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare function getVariableSchema(node: WorkflowNode, nodes: WorkflowNode[], edges: WorkflowEdge[], config: TemplateVariablesConfig, workflowId?: string, authProvider?: AuthProvider): Promise<VariableSchema>;
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variable Service
|
|
3
|
+
* Derives available template variables from connected upstream nodes' output schemas.
|
|
4
|
+
* Used by the template editor for autocomplete suggestions.
|
|
5
|
+
*
|
|
6
|
+
* @module services/variableService
|
|
7
|
+
*/
|
|
8
|
+
import { logger } from '../utils/logger.js';
|
|
9
|
+
/**
|
|
10
|
+
* Converts a JSON Schema property type to a TemplateVariableType.
|
|
11
|
+
*
|
|
12
|
+
* @param schemaType - The type from JSON Schema
|
|
13
|
+
* @returns The corresponding TemplateVariableType
|
|
14
|
+
*/
|
|
15
|
+
function toTemplateVariableType(schemaType) {
|
|
16
|
+
switch (schemaType) {
|
|
17
|
+
case 'string':
|
|
18
|
+
return 'string';
|
|
19
|
+
case 'number':
|
|
20
|
+
return 'number';
|
|
21
|
+
case 'integer':
|
|
22
|
+
return 'integer';
|
|
23
|
+
case 'boolean':
|
|
24
|
+
return 'boolean';
|
|
25
|
+
case 'array':
|
|
26
|
+
return 'array';
|
|
27
|
+
case 'object':
|
|
28
|
+
return 'object';
|
|
29
|
+
case 'float':
|
|
30
|
+
return 'float';
|
|
31
|
+
default:
|
|
32
|
+
return 'mixed';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Converts a JSON Schema property to a TemplateVariable.
|
|
37
|
+
* Recursively processes nested objects and arrays.
|
|
38
|
+
*
|
|
39
|
+
* @param name - The property name
|
|
40
|
+
* @param property - The JSON Schema property definition
|
|
41
|
+
* @param sourcePort - Optional source port ID
|
|
42
|
+
* @param sourceNode - Optional source node ID
|
|
43
|
+
* @returns A TemplateVariable representing the property
|
|
44
|
+
*/
|
|
45
|
+
function propertyToTemplateVariable(name, property, sourcePort, sourceNode) {
|
|
46
|
+
const variable = {
|
|
47
|
+
name,
|
|
48
|
+
label: property.title ?? name,
|
|
49
|
+
description: property.description,
|
|
50
|
+
type: toTemplateVariableType(property.type),
|
|
51
|
+
sourcePort,
|
|
52
|
+
sourceNode
|
|
53
|
+
};
|
|
54
|
+
// Handle nested object properties
|
|
55
|
+
if (property.type === 'object' && property.properties) {
|
|
56
|
+
variable.properties = {};
|
|
57
|
+
for (const [propName, propValue] of Object.entries(property.properties)) {
|
|
58
|
+
variable.properties[propName] = propertyToTemplateVariable(propName, propValue, sourcePort, sourceNode);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Handle array items
|
|
62
|
+
if (property.type === 'array' && property.items) {
|
|
63
|
+
variable.items = propertyToTemplateVariable('item', property.items, sourcePort, sourceNode);
|
|
64
|
+
}
|
|
65
|
+
return variable;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a TemplateVariable from a NodePort.
|
|
69
|
+
* Uses the port's schema if available, otherwise creates a basic variable.
|
|
70
|
+
*
|
|
71
|
+
* @param port - The output port to convert
|
|
72
|
+
* @param sourceNode - The source node ID
|
|
73
|
+
* @returns A TemplateVariable representing the port's data
|
|
74
|
+
*/
|
|
75
|
+
function portToTemplateVariable(port, sourceNode) {
|
|
76
|
+
// If the port has a schema, use it to build a detailed variable
|
|
77
|
+
if (port.schema && port.schema.properties) {
|
|
78
|
+
const variable = {
|
|
79
|
+
name: port.id,
|
|
80
|
+
label: port.name,
|
|
81
|
+
description: port.description,
|
|
82
|
+
type: 'object',
|
|
83
|
+
sourcePort: port.id,
|
|
84
|
+
sourceNode,
|
|
85
|
+
properties: {}
|
|
86
|
+
};
|
|
87
|
+
for (const [propName, propValue] of Object.entries(port.schema.properties)) {
|
|
88
|
+
variable.properties[propName] = propertyToTemplateVariable(propName, propValue, port.id, sourceNode);
|
|
89
|
+
}
|
|
90
|
+
return variable;
|
|
91
|
+
}
|
|
92
|
+
// Otherwise, create a basic variable based on dataType
|
|
93
|
+
return {
|
|
94
|
+
name: port.id,
|
|
95
|
+
label: port.name,
|
|
96
|
+
description: port.description,
|
|
97
|
+
type: toTemplateVariableType(port.dataType),
|
|
98
|
+
sourcePort: port.id,
|
|
99
|
+
sourceNode
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Extracts the port ID from a handle ID.
|
|
104
|
+
* Handle IDs follow the format: {nodeId}-{input|output}-{portId}
|
|
105
|
+
*
|
|
106
|
+
* @param handleId - The handle ID (e.g., "http_request.1-output-json")
|
|
107
|
+
* @returns The port ID (e.g., "json") or the original handleId if parsing fails
|
|
108
|
+
*/
|
|
109
|
+
function extractPortIdFromHandle(handleId) {
|
|
110
|
+
if (!handleId)
|
|
111
|
+
return undefined;
|
|
112
|
+
// Handle format: {nodeId}-{input|output}-{portId}
|
|
113
|
+
// Example: "http_request.1-output-json" -> "json"
|
|
114
|
+
const outputMatch = handleId.match(/-output-(.+)$/);
|
|
115
|
+
if (outputMatch) {
|
|
116
|
+
return outputMatch[1];
|
|
117
|
+
}
|
|
118
|
+
const inputMatch = handleId.match(/-input-(.+)$/);
|
|
119
|
+
if (inputMatch) {
|
|
120
|
+
return inputMatch[1];
|
|
121
|
+
}
|
|
122
|
+
// Fallback: return the handle ID as-is (might be a simple port ID)
|
|
123
|
+
return handleId;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Finds all upstream connections to a node.
|
|
127
|
+
* Returns information about each connection including source node and ports.
|
|
128
|
+
*
|
|
129
|
+
* @param node - The node to find upstream connections for
|
|
130
|
+
* @param nodes - All nodes in the workflow
|
|
131
|
+
* @param edges - All edges in the workflow
|
|
132
|
+
* @returns Array of upstream connection information
|
|
133
|
+
*/
|
|
134
|
+
function findUpstreamConnections(node, nodes, edges) {
|
|
135
|
+
const connections = [];
|
|
136
|
+
// Find all edges that target this node
|
|
137
|
+
const incomingEdges = edges.filter((edge) => edge.target === node.id);
|
|
138
|
+
for (const edge of incomingEdges) {
|
|
139
|
+
// Find the source node
|
|
140
|
+
const sourceNode = nodes.find((n) => n.id === edge.source);
|
|
141
|
+
if (!sourceNode)
|
|
142
|
+
continue;
|
|
143
|
+
// Extract port IDs from handle IDs
|
|
144
|
+
// Handle format: {nodeId}-{input|output}-{portId}
|
|
145
|
+
const sourcePortId = extractPortIdFromHandle(edge.sourceHandle);
|
|
146
|
+
const targetPortId = extractPortIdFromHandle(edge.targetHandle);
|
|
147
|
+
// Find the source output port
|
|
148
|
+
const sourcePort = sourceNode.data.metadata.outputs.find((p) => p.id === sourcePortId);
|
|
149
|
+
// Find the target input port
|
|
150
|
+
const targetPort = node.data.metadata.inputs.find((p) => p.id === targetPortId);
|
|
151
|
+
connections.push({
|
|
152
|
+
edge,
|
|
153
|
+
sourceNode,
|
|
154
|
+
sourcePort,
|
|
155
|
+
targetPort
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return connections;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Derives available template variables from connected upstream nodes.
|
|
162
|
+
* Variables are extracted from the output schemas of nodes connected to
|
|
163
|
+
* the current node's input ports.
|
|
164
|
+
*
|
|
165
|
+
* @param node - The current node being configured
|
|
166
|
+
* @param nodes - All nodes in the workflow
|
|
167
|
+
* @param edges - All edges in the workflow
|
|
168
|
+
* @param options - Optional configuration for filtering variables
|
|
169
|
+
* @returns A VariableSchema containing all available variables
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* // Get variables from all connected ports
|
|
174
|
+
* const variableSchema = getAvailableVariables(currentNode, allNodes, allEdges);
|
|
175
|
+
*
|
|
176
|
+
* // Get variables only from specific input ports
|
|
177
|
+
* const filteredSchema = getAvailableVariables(currentNode, allNodes, allEdges, {
|
|
178
|
+
* targetPortIds: ["data", "context"]
|
|
179
|
+
* });
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export function getAvailableVariables(node, nodes, edges, options) {
|
|
183
|
+
const variables = {};
|
|
184
|
+
const { targetPortIds, includePortName } = options ?? {};
|
|
185
|
+
// Find all upstream connections
|
|
186
|
+
const connections = findUpstreamConnections(node, nodes, edges);
|
|
187
|
+
for (const connection of connections) {
|
|
188
|
+
const { sourceNode, sourcePort, targetPort } = connection;
|
|
189
|
+
// Skip trigger ports - they don't carry data
|
|
190
|
+
if (sourcePort?.dataType === 'trigger')
|
|
191
|
+
continue;
|
|
192
|
+
if (targetPort?.dataType === 'trigger')
|
|
193
|
+
continue;
|
|
194
|
+
// Get the target port ID for filtering
|
|
195
|
+
const targetPortId = targetPort?.id ?? sourcePort?.id ?? 'data';
|
|
196
|
+
// Filter by target port IDs if specified
|
|
197
|
+
if (targetPortIds !== undefined) {
|
|
198
|
+
if (!targetPortIds.includes(targetPortId))
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (!sourcePort)
|
|
202
|
+
continue;
|
|
203
|
+
// If the source port has a schema with top-level properties,
|
|
204
|
+
// unpack them as top-level variables (unless includePortName is true)
|
|
205
|
+
if (sourcePort.schema?.properties && !includePortName) {
|
|
206
|
+
// Unpack schema properties as top-level variables
|
|
207
|
+
for (const [propName, propValue] of Object.entries(sourcePort.schema.properties)) {
|
|
208
|
+
// Skip if we already have a variable with this name
|
|
209
|
+
if (variables[propName])
|
|
210
|
+
continue;
|
|
211
|
+
variables[propName] = propertyToTemplateVariable(propName, propValue, sourcePort.id, sourceNode.id);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
// No schema or includePortName is true - use port name as the variable
|
|
216
|
+
const variableName = includePortName ? targetPortId : targetPortId;
|
|
217
|
+
// Skip if we already have a variable with this name
|
|
218
|
+
if (variables[variableName])
|
|
219
|
+
continue;
|
|
220
|
+
const variable = portToTemplateVariable(sourcePort, sourceNode.id);
|
|
221
|
+
variable.name = variableName;
|
|
222
|
+
variable.label = targetPort?.name ?? sourcePort.name;
|
|
223
|
+
variables[variableName] = variable;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return { variables };
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Gets the child variables for a given path in the variable schema.
|
|
230
|
+
* Used for drilling down into nested objects and arrays.
|
|
231
|
+
*
|
|
232
|
+
* @param schema - The variable schema
|
|
233
|
+
* @param path - The path to the parent variable (e.g., "user", "user.address")
|
|
234
|
+
* @returns Array of child variables, or empty array if none found
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* // For path "user" with schema containing user.name, user.email, user.address
|
|
239
|
+
* getChildVariables(schema, "user");
|
|
240
|
+
* // Returns: [{ name: "name", ... }, { name: "email", ... }, { name: "address", ... }]
|
|
241
|
+
*
|
|
242
|
+
* // For path "user.address" with schema containing city, country
|
|
243
|
+
* getChildVariables(schema, "user.address");
|
|
244
|
+
* // Returns: [{ name: "city", ... }, { name: "country", ... }]
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
export function getChildVariables(schema, path) {
|
|
248
|
+
const parts = path.split('.');
|
|
249
|
+
let current;
|
|
250
|
+
// Navigate to the target variable
|
|
251
|
+
for (let i = 0; i < parts.length; i++) {
|
|
252
|
+
const part = parts[i];
|
|
253
|
+
// Handle array index access (e.g., "items[0]")
|
|
254
|
+
const arrayMatch = part.match(/^(\w+)\[(\d+|\*)\]$/);
|
|
255
|
+
if (arrayMatch) {
|
|
256
|
+
const [, varName] = arrayMatch;
|
|
257
|
+
if (i === 0) {
|
|
258
|
+
current = schema.variables[varName];
|
|
259
|
+
}
|
|
260
|
+
else if (current?.properties) {
|
|
261
|
+
current = current.properties[varName];
|
|
262
|
+
}
|
|
263
|
+
// After array access, move to items schema
|
|
264
|
+
if (current?.items) {
|
|
265
|
+
current = current.items;
|
|
266
|
+
}
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
// Regular property access
|
|
270
|
+
if (i === 0) {
|
|
271
|
+
current = schema.variables[part];
|
|
272
|
+
}
|
|
273
|
+
else if (current?.properties) {
|
|
274
|
+
current = current.properties[part];
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
return [];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Return child properties if available
|
|
281
|
+
if (current?.properties) {
|
|
282
|
+
return Object.values(current.properties);
|
|
283
|
+
}
|
|
284
|
+
return [];
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Gets suggestions for array index access.
|
|
288
|
+
* Returns common index options like [0], [1], [2], and [*] for all items.
|
|
289
|
+
*
|
|
290
|
+
* @param maxIndex - Maximum index to suggest (default: 2)
|
|
291
|
+
* @returns Array of index suggestion strings
|
|
292
|
+
*/
|
|
293
|
+
export function getArrayIndexSuggestions(maxIndex = 2) {
|
|
294
|
+
const suggestions = [];
|
|
295
|
+
for (let i = 0; i <= maxIndex; i++) {
|
|
296
|
+
suggestions.push(`${i}]`);
|
|
297
|
+
}
|
|
298
|
+
// Add wildcard for "all items"
|
|
299
|
+
suggestions.push('*]');
|
|
300
|
+
return suggestions;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Checks if a variable at the given path is an array.
|
|
304
|
+
*
|
|
305
|
+
* @param schema - The variable schema
|
|
306
|
+
* @param path - The path to check (e.g., "items", "user.orders")
|
|
307
|
+
* @returns True if the variable is an array type
|
|
308
|
+
*/
|
|
309
|
+
export function isArrayVariable(schema, path) {
|
|
310
|
+
const parts = path.split('.');
|
|
311
|
+
let current;
|
|
312
|
+
for (let i = 0; i < parts.length; i++) {
|
|
313
|
+
const part = parts[i];
|
|
314
|
+
// Handle array index access
|
|
315
|
+
const arrayMatch = part.match(/^(\w+)\[(\d+|\*)\]$/);
|
|
316
|
+
if (arrayMatch) {
|
|
317
|
+
const [, varName] = arrayMatch;
|
|
318
|
+
if (i === 0) {
|
|
319
|
+
current = schema.variables[varName];
|
|
320
|
+
}
|
|
321
|
+
else if (current?.properties) {
|
|
322
|
+
current = current.properties[varName];
|
|
323
|
+
}
|
|
324
|
+
if (current?.items) {
|
|
325
|
+
current = current.items;
|
|
326
|
+
}
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (i === 0) {
|
|
330
|
+
current = schema.variables[part];
|
|
331
|
+
}
|
|
332
|
+
else if (current?.properties) {
|
|
333
|
+
current = current.properties[part];
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return current?.type === 'array';
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Checks if a variable at the given path has child properties.
|
|
343
|
+
*
|
|
344
|
+
* @param schema - The variable schema
|
|
345
|
+
* @param path - The path to check
|
|
346
|
+
* @returns True if the variable has children that can be drilled into
|
|
347
|
+
*/
|
|
348
|
+
export function hasChildren(schema, path) {
|
|
349
|
+
const children = getChildVariables(schema, path);
|
|
350
|
+
return children.length > 0;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Merges two variable schemas together.
|
|
354
|
+
* Variables from the primary schema take precedence over the secondary schema.
|
|
355
|
+
*
|
|
356
|
+
* @param primary - The primary variable schema (takes precedence)
|
|
357
|
+
* @param secondary - The secondary variable schema
|
|
358
|
+
* @returns A merged VariableSchema
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```typescript
|
|
362
|
+
* const apiSchema = { variables: { apiKey: {...}, endpoint: {...} } };
|
|
363
|
+
* const staticSchema = { variables: { env: {...}, config: {...} } };
|
|
364
|
+
* const merged = mergeVariableSchemas(apiSchema, staticSchema);
|
|
365
|
+
* // Result: { variables: { apiKey, endpoint, env, config } }
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
export function mergeVariableSchemas(primary, secondary) {
|
|
369
|
+
// Create a shallow copy of secondary variables
|
|
370
|
+
const mergedVariables = { ...secondary.variables };
|
|
371
|
+
// Overlay primary variables (they take precedence)
|
|
372
|
+
for (const [key, value] of Object.entries(primary.variables)) {
|
|
373
|
+
mergedVariables[key] = value;
|
|
374
|
+
}
|
|
375
|
+
return { variables: mergedVariables };
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Gets variable schema using the appropriate mode (API, schema-based, or hybrid).
|
|
379
|
+
* This is the main orchestration function that determines how to fetch variables
|
|
380
|
+
* based on the configuration.
|
|
381
|
+
*
|
|
382
|
+
* @param node - The current node being configured
|
|
383
|
+
* @param nodes - All nodes in the workflow
|
|
384
|
+
* @param edges - All edges in the workflow
|
|
385
|
+
* @param config - Template variables configuration
|
|
386
|
+
* @param workflowId - Optional workflow ID for API context
|
|
387
|
+
* @param authProvider - Optional auth provider for API requests
|
|
388
|
+
* @returns A promise that resolves to the variable schema
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```typescript
|
|
392
|
+
* // Schema-based mode (existing behavior)
|
|
393
|
+
* const config = { ports: ["data"], schema: {...} };
|
|
394
|
+
* const schema = await getVariableSchema(node, nodes, edges, config);
|
|
395
|
+
*
|
|
396
|
+
* // API mode
|
|
397
|
+
* const config = { api: { endpoint: { url: "/api/variables/{workflowId}/{nodeId}" } } };
|
|
398
|
+
* const schema = await getVariableSchema(node, nodes, edges, config, workflowId, authProvider);
|
|
399
|
+
*
|
|
400
|
+
* // Hybrid mode (API + static schema)
|
|
401
|
+
* const config = {
|
|
402
|
+
* schema: {...},
|
|
403
|
+
* api: { endpoint: {...}, mergeWithSchema: true }
|
|
404
|
+
* };
|
|
405
|
+
* const schema = await getVariableSchema(node, nodes, edges, config, workflowId, authProvider);
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
export async function getVariableSchema(node, nodes, edges, config, workflowId, authProvider) {
|
|
409
|
+
let resultSchema = { variables: {} };
|
|
410
|
+
// Try API mode first (if configured)
|
|
411
|
+
if (config.api) {
|
|
412
|
+
try {
|
|
413
|
+
// Import API variable service dynamically to avoid circular dependencies
|
|
414
|
+
const { fetchVariableSchema } = await import('./apiVariableService.js');
|
|
415
|
+
const apiResult = await fetchVariableSchema(workflowId, node.id, config.api, authProvider);
|
|
416
|
+
if (apiResult.success && apiResult.schema) {
|
|
417
|
+
resultSchema = apiResult.schema;
|
|
418
|
+
// Merge with static schema if configured
|
|
419
|
+
if (config.api.mergeWithSchema !== false && config.schema) {
|
|
420
|
+
resultSchema = mergeVariableSchemas(resultSchema, config.schema);
|
|
421
|
+
}
|
|
422
|
+
// Merge with port-derived variables if configured
|
|
423
|
+
if (config.api.mergeWithPorts) {
|
|
424
|
+
const portSchema = getAvailableVariables(node, nodes, edges, {
|
|
425
|
+
targetPortIds: config.ports,
|
|
426
|
+
includePortName: config.includePortName
|
|
427
|
+
});
|
|
428
|
+
resultSchema = mergeVariableSchemas(resultSchema, portSchema);
|
|
429
|
+
}
|
|
430
|
+
return resultSchema;
|
|
431
|
+
}
|
|
432
|
+
else if (!config.api.fallbackOnError) {
|
|
433
|
+
// API failed and fallback is disabled - return empty schema
|
|
434
|
+
logger.error('Failed to fetch variables from API:', apiResult.error);
|
|
435
|
+
return { variables: {} };
|
|
436
|
+
}
|
|
437
|
+
// If fallback is enabled (default), continue to schema-based mode below
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
logger.error('Error fetching variables from API:', error);
|
|
441
|
+
// If fallback is disabled, return empty schema
|
|
442
|
+
if (config.api.fallbackOnError === false) {
|
|
443
|
+
return { variables: {} };
|
|
444
|
+
}
|
|
445
|
+
// Otherwise, continue to schema-based mode below
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
// Schema-based mode (existing behavior)
|
|
449
|
+
// This is the fallback when API mode is not configured or fails
|
|
450
|
+
// Start with port-derived variables (if ports are configured or no API mode)
|
|
451
|
+
if (config.ports !== undefined || !config.api) {
|
|
452
|
+
const portSchema = getAvailableVariables(node, nodes, edges, {
|
|
453
|
+
targetPortIds: config.ports,
|
|
454
|
+
includePortName: config.includePortName
|
|
455
|
+
});
|
|
456
|
+
resultSchema = portSchema;
|
|
457
|
+
}
|
|
458
|
+
// Merge with static schema (if configured)
|
|
459
|
+
if (config.schema) {
|
|
460
|
+
resultSchema = mergeVariableSchemas(config.schema, resultSchema);
|
|
461
|
+
}
|
|
462
|
+
return resultSchema;
|
|
463
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory workflow storage service
|
|
3
|
+
* This can be replaced with a database implementation later
|
|
4
|
+
*/
|
|
5
|
+
import type { Workflow } from '../types/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Save a workflow
|
|
8
|
+
*/
|
|
9
|
+
export declare function saveWorkflow(workflow: Omit<Workflow, 'id'>): Promise<Workflow>;
|
|
10
|
+
/**
|
|
11
|
+
* Update an existing workflow
|
|
12
|
+
*/
|
|
13
|
+
export declare function updateWorkflow(id: string, workflow: Partial<Workflow>): Promise<Workflow | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Get a workflow by ID
|
|
16
|
+
*/
|
|
17
|
+
export declare function getWorkflow(id: string): Promise<Workflow | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Get all workflows with optional filtering
|
|
20
|
+
*/
|
|
21
|
+
export declare function getWorkflows(options?: {
|
|
22
|
+
search?: string;
|
|
23
|
+
limit?: number;
|
|
24
|
+
offset?: number;
|
|
25
|
+
}): Promise<Workflow[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete a workflow
|
|
28
|
+
*/
|
|
29
|
+
export declare function deleteWorkflow(id: string): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Get workflow count
|
|
32
|
+
*/
|
|
33
|
+
export declare function getWorkflowCount(): Promise<number>;
|
|
34
|
+
/**
|
|
35
|
+
* Initialize with sample workflows (for development)
|
|
36
|
+
*/
|
|
37
|
+
export declare function initializeSampleWorkflows(): Promise<void>;
|