@flowdrop/flowdrop 1.0.1 → 1.1.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 +50 -50
- package/dist/adapters/WorkflowAdapter.d.ts +1 -1
- package/dist/adapters/WorkflowAdapter.js +25 -25
- package/dist/adapters/agentspec/AgentSpecAdapter.d.ts +2 -2
- package/dist/adapters/agentspec/AgentSpecAdapter.js +133 -122
- package/dist/adapters/agentspec/agentAdapter.d.ts +2 -2
- package/dist/adapters/agentspec/agentAdapter.js +10 -10
- package/dist/adapters/agentspec/autoLayout.d.ts +1 -1
- package/dist/adapters/agentspec/autoLayout.js +2 -2
- package/dist/adapters/agentspec/componentTypeDefaults.d.ts +1 -1
- package/dist/adapters/agentspec/componentTypeDefaults.js +120 -120
- package/dist/adapters/agentspec/defaultNodeTypes.d.ts +2 -2
- package/dist/adapters/agentspec/defaultNodeTypes.js +307 -307
- package/dist/adapters/agentspec/index.d.ts +10 -10
- package/dist/adapters/agentspec/index.js +6 -6
- package/dist/adapters/agentspec/validator.d.ts +2 -2
- package/dist/adapters/agentspec/validator.js +22 -20
- package/dist/api/enhanced-client.d.ts +3 -3
- package/dist/api/enhanced-client.js +73 -72
- package/dist/components/App.svelte +1081 -961
- package/dist/components/App.svelte.d.ts +9 -6
- package/dist/components/CanvasBanner.stories.svelte +23 -20
- package/dist/components/CanvasBanner.stories.svelte.d.ts +1 -1
- package/dist/components/CanvasBanner.svelte +46 -46
- package/dist/components/ConfigForm.svelte +1164 -1065
- package/dist/components/ConfigForm.svelte.d.ts +2 -2
- package/dist/components/ConfigModal.svelte +180 -180
- package/dist/components/ConfigModal.svelte.d.ts +1 -1
- package/dist/components/ConfigPanel.stories.svelte +35 -35
- package/dist/components/ConfigPanel.stories.svelte.d.ts +1 -1
- package/dist/components/ConfigPanel.svelte +178 -167
- package/dist/components/ConfigPanel.svelte.d.ts +1 -1
- package/dist/components/ConnectionLine.svelte +25 -25
- package/dist/components/EdgeRefresher.svelte +26 -26
- package/dist/components/FlowDropEdge.stories.svelte +179 -143
- package/dist/components/FlowDropEdge.svelte +147 -147
- package/dist/components/FlowDropEdge.svelte.d.ts +1 -1
- package/dist/components/FlowDropZone.svelte +63 -60
- package/dist/components/FlowDropZone.svelte.d.ts +1 -1
- package/dist/components/LoadingSpinner.stories.svelte +19 -19
- package/dist/components/LoadingSpinner.stories.svelte.d.ts +1 -1
- package/dist/components/LoadingSpinner.svelte +21 -21
- package/dist/components/LoadingSpinner.svelte.d.ts +1 -1
- package/dist/components/Logo.stories.svelte +13 -13
- package/dist/components/Logo.stories.svelte.d.ts +1 -1
- package/dist/components/Logo.svelte +101 -95
- package/dist/components/LogsSidebar.svelte +553 -546
- package/dist/components/LogsSidebar.svelte.d.ts +1 -1
- package/dist/components/MarkdownDisplay.stories.svelte +29 -23
- package/dist/components/MarkdownDisplay.stories.svelte.d.ts +1 -1
- package/dist/components/MarkdownDisplay.svelte +16 -14
- package/dist/components/Navbar.stories.svelte +43 -38
- package/dist/components/Navbar.stories.svelte.d.ts +1 -1
- package/dist/components/Navbar.svelte +760 -706
- package/dist/components/Navbar.svelte.d.ts +1 -1
- package/dist/components/NodeSidebar.svelte +900 -746
- package/dist/components/NodeSidebar.svelte.d.ts +3 -1
- package/dist/components/NodeStatusOverlay.stories.svelte +82 -70
- package/dist/components/NodeStatusOverlay.stories.svelte.d.ts +1 -1
- package/dist/components/NodeStatusOverlay.svelte +295 -280
- package/dist/components/NodeStatusOverlay.svelte.d.ts +3 -3
- package/dist/components/PipelineStatus.svelte +326 -300
- package/dist/components/PipelineStatus.svelte.d.ts +4 -4
- package/dist/components/PortCoordinateTracker.svelte +49 -47
- package/dist/components/PortCoordinateTracker.svelte.d.ts +1 -1
- package/dist/components/ReadOnlyDetails.svelte +156 -156
- package/dist/components/SchemaForm.stories.svelte +106 -98
- package/dist/components/SchemaForm.stories.svelte.d.ts +1 -1
- package/dist/components/SchemaForm.svelte +490 -463
- package/dist/components/SchemaForm.svelte.d.ts +2 -2
- package/dist/components/SettingsModal.svelte +226 -223
- package/dist/components/SettingsModal.svelte.d.ts +1 -1
- package/dist/components/SettingsPanel.svelte +637 -601
- package/dist/components/SettingsPanel.svelte.d.ts +1 -1
- package/dist/components/StatusIcon.stories.svelte +62 -49
- package/dist/components/StatusIcon.stories.svelte.d.ts +1 -1
- package/dist/components/StatusIcon.svelte +87 -87
- package/dist/components/StatusIcon.svelte.d.ts +2 -2
- package/dist/components/StatusLabel.stories.svelte +12 -12
- package/dist/components/StatusLabel.stories.svelte.d.ts +1 -1
- package/dist/components/StatusLabel.svelte +19 -19
- package/dist/components/ThemeToggle.stories.svelte +16 -16
- package/dist/components/ThemeToggle.stories.svelte.d.ts +1 -1
- package/dist/components/ThemeToggle.svelte +180 -169
- package/dist/components/ThemeToggle.svelte.d.ts +1 -1
- package/dist/components/UniversalNode.svelte +150 -138
- package/dist/components/UniversalNode.svelte.d.ts +3 -3
- package/dist/components/WorkflowEditor.svelte +1069 -1014
- package/dist/components/WorkflowEditor.svelte.d.ts +4 -4
- package/dist/components/form/FormArray.svelte +1034 -973
- package/dist/components/form/FormArray.svelte.d.ts +1 -1
- package/dist/components/form/FormAutocomplete.svelte +1021 -978
- package/dist/components/form/FormAutocomplete.svelte.d.ts +1 -1
- package/dist/components/form/FormCheckboxGroup.stories.svelte +23 -20
- package/dist/components/form/FormCheckboxGroup.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormCheckboxGroup.svelte +136 -136
- package/dist/components/form/FormCodeEditor.svelte +452 -434
- package/dist/components/form/FormField.svelte +366 -355
- package/dist/components/form/FormField.svelte.d.ts +2 -2
- package/dist/components/form/FormFieldLight.svelte +400 -384
- package/dist/components/form/FormFieldLight.svelte.d.ts +1 -1
- package/dist/components/form/FormFieldWrapper.stories.svelte +42 -42
- package/dist/components/form/FormFieldWrapper.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormFieldWrapper.svelte +100 -93
- package/dist/components/form/FormFieldWrapper.svelte.d.ts +1 -1
- package/dist/components/form/FormFieldset.svelte +108 -108
- package/dist/components/form/FormFieldset.svelte.d.ts +2 -2
- package/dist/components/form/FormMarkdownEditor.svelte +758 -725
- package/dist/components/form/FormNumberField.stories.svelte +25 -25
- package/dist/components/form/FormNumberField.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormNumberField.svelte +88 -88
- package/dist/components/form/FormRangeField.stories.svelte +20 -20
- package/dist/components/form/FormRangeField.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormRangeField.svelte +234 -226
- package/dist/components/form/FormSelect.stories.svelte +38 -38
- package/dist/components/form/FormSelect.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormSelect.svelte +101 -101
- package/dist/components/form/FormSelect.svelte.d.ts +1 -1
- package/dist/components/form/FormTemplateEditor.svelte +847 -798
- package/dist/components/form/FormTemplateEditor.svelte.d.ts +1 -1
- package/dist/components/form/FormTextField.stories.svelte +29 -23
- package/dist/components/form/FormTextField.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormTextField.svelte +68 -68
- package/dist/components/form/FormTextarea.stories.svelte +28 -25
- package/dist/components/form/FormTextarea.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormTextarea.svelte +74 -74
- package/dist/components/form/FormToggle.stories.svelte +23 -20
- package/dist/components/form/FormToggle.stories.svelte.d.ts +1 -1
- package/dist/components/form/FormToggle.svelte +98 -98
- package/dist/components/form/FormUISchemaRenderer.svelte +120 -113
- package/dist/components/form/FormUISchemaRenderer.svelte.d.ts +3 -3
- package/dist/components/form/index.d.ts +19 -19
- package/dist/components/form/index.js +18 -18
- package/dist/components/form/templateAutocomplete.d.ts +2 -2
- package/dist/components/form/templateAutocomplete.js +64 -55
- package/dist/components/form/types.d.ts +6 -6
- package/dist/components/form/types.js +9 -4
- package/dist/components/icons/AlertCircleIcon.svelte +11 -0
- package/dist/components/icons/AlertCircleIcon.svelte.d.ts +26 -0
- package/dist/components/icons/CogIcon.svelte +11 -0
- package/dist/components/icons/CogIcon.svelte.d.ts +26 -0
- package/dist/components/interrupt/ChoicePrompt.stories.svelte +54 -38
- package/dist/components/interrupt/ChoicePrompt.stories.svelte.d.ts +1 -1
- package/dist/components/interrupt/ChoicePrompt.svelte +407 -383
- package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +1 -1
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte +48 -48
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte.d.ts +1 -1
- package/dist/components/interrupt/ConfirmationPrompt.svelte +280 -274
- package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +1 -1
- package/dist/components/interrupt/FormPrompt.svelte +223 -218
- package/dist/components/interrupt/FormPrompt.svelte.d.ts +1 -1
- package/dist/components/interrupt/InterruptBubble.svelte +617 -583
- package/dist/components/interrupt/InterruptBubble.svelte.d.ts +2 -2
- package/dist/components/interrupt/ReviewPrompt.stories.svelte +66 -56
- package/dist/components/interrupt/ReviewPrompt.stories.svelte.d.ts +1 -1
- package/dist/components/interrupt/ReviewPrompt.svelte +861 -841
- package/dist/components/interrupt/ReviewPrompt.svelte.d.ts +1 -1
- package/dist/components/interrupt/TextInputPrompt.stories.svelte +38 -33
- package/dist/components/interrupt/TextInputPrompt.stories.svelte.d.ts +1 -1
- package/dist/components/interrupt/TextInputPrompt.svelte +333 -328
- package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +1 -1
- package/dist/components/interrupt/index.d.ts +5 -5
- package/dist/components/interrupt/index.js +5 -5
- package/dist/components/layouts/MainLayout.svelte +724 -691
- package/dist/components/layouts/MainLayout.svelte.d.ts +6 -6
- package/dist/components/nodes/GatewayNode.stories.svelte +100 -99
- package/dist/components/nodes/GatewayNode.svelte +605 -571
- package/dist/components/nodes/GatewayNode.svelte.d.ts +3 -3
- package/dist/components/nodes/IdeaNode.stories.svelte +44 -43
- package/dist/components/nodes/IdeaNode.svelte +451 -437
- package/dist/components/nodes/IdeaNode.svelte.d.ts +1 -1
- package/dist/components/nodes/NotesNode.stories.svelte +65 -64
- package/dist/components/nodes/NotesNode.svelte +380 -369
- package/dist/components/nodes/NotesNode.svelte.d.ts +1 -1
- package/dist/components/nodes/SimpleNode.stories.svelte +145 -144
- package/dist/components/nodes/SimpleNode.svelte +486 -424
- package/dist/components/nodes/SimpleNode.svelte.d.ts +1 -1
- package/dist/components/nodes/SquareNode.stories.svelte +73 -73
- package/dist/components/nodes/SquareNode.svelte +439 -380
- package/dist/components/nodes/SquareNode.svelte.d.ts +1 -1
- package/dist/components/nodes/TerminalNode.stories.svelte +13 -13
- package/dist/components/nodes/TerminalNode.svelte +709 -670
- package/dist/components/nodes/TerminalNode.svelte.d.ts +1 -1
- package/dist/components/nodes/ToolNode.stories.svelte +181 -180
- package/dist/components/nodes/ToolNode.svelte +505 -447
- package/dist/components/nodes/ToolNode.svelte.d.ts +1 -1
- package/dist/components/nodes/WorkflowNode.stories.svelte +70 -46
- package/dist/components/nodes/WorkflowNode.svelte +621 -551
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +3 -3
- package/dist/components/playground/ChatPanel.svelte +945 -889
- package/dist/components/playground/ExecutionLogs.svelte +495 -472
- package/dist/components/playground/InputCollector.svelte +449 -428
- package/dist/components/playground/MessageBubble.stories.svelte +47 -47
- package/dist/components/playground/MessageBubble.stories.svelte.d.ts +1 -1
- package/dist/components/playground/MessageBubble.svelte +626 -610
- package/dist/components/playground/MessageBubble.svelte.d.ts +1 -1
- package/dist/components/playground/Playground.svelte +1088 -1057
- package/dist/components/playground/Playground.svelte.d.ts +3 -3
- package/dist/components/playground/PlaygroundModal.svelte +208 -204
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -3
- package/dist/components/playground/SessionManager.svelte +527 -521
- package/dist/components/playground/SessionManager.svelte.d.ts +1 -1
- package/dist/config/agentSpecEndpoints.d.ts +1 -1
- package/dist/config/agentSpecEndpoints.js +20 -20
- package/dist/config/constants.js +2 -2
- package/dist/config/defaultCategories.d.ts +1 -1
- package/dist/config/defaultCategories.js +86 -86
- package/dist/config/defaultPortConfig.d.ts +1 -1
- package/dist/config/defaultPortConfig.js +144 -144
- package/dist/config/endpoints.d.ts +4 -4
- package/dist/config/endpoints.js +65 -65
- package/dist/config/runtimeConfig.d.ts +2 -2
- package/dist/config/runtimeConfig.js +8 -8
- package/dist/core/index.d.ts +63 -59
- package/dist/core/index.js +35 -33
- package/dist/display/index.d.ts +2 -2
- package/dist/display/index.js +2 -2
- package/dist/editor/index.d.ts +62 -62
- package/dist/editor/index.js +53 -53
- package/dist/form/code.d.ts +5 -5
- package/dist/form/code.js +14 -14
- package/dist/form/fieldRegistry.d.ts +3 -3
- package/dist/form/fieldRegistry.js +11 -9
- package/dist/form/full.d.ts +8 -8
- package/dist/form/full.js +9 -9
- package/dist/form/index.d.ts +18 -18
- package/dist/form/index.js +16 -16
- package/dist/form/markdown.d.ts +4 -4
- package/dist/form/markdown.js +8 -8
- package/dist/helpers/proximityConnect.d.ts +3 -3
- package/dist/helpers/proximityConnect.js +34 -32
- package/dist/helpers/workflowEditorHelper.d.ts +5 -5
- package/dist/helpers/workflowEditorHelper.js +108 -96
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/mocks/app-environment.js +2 -2
- package/dist/mocks/app-forms.js +9 -9
- package/dist/mocks/app-navigation.js +11 -11
- package/dist/mocks/app-stores.js +8 -8
- package/dist/playground/index.d.ts +19 -19
- package/dist/playground/index.js +16 -16
- package/dist/playground/mount.d.ts +3 -3
- package/dist/playground/mount.js +24 -24
- package/dist/registry/builtinFormats.js +13 -13
- package/dist/registry/builtinNodes.d.ts +2 -2
- package/dist/registry/builtinNodes.js +77 -77
- package/dist/registry/index.d.ts +4 -4
- package/dist/registry/index.js +4 -4
- package/dist/registry/nodeComponentRegistry.d.ts +8 -8
- package/dist/registry/nodeComponentRegistry.js +11 -9
- package/dist/registry/plugin.d.ts +2 -2
- package/dist/registry/plugin.js +11 -11
- package/dist/registry/workflowFormatRegistry.d.ts +3 -3
- package/dist/registry/workflowFormatRegistry.js +2 -2
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.js +2 -2
- package/dist/schemas/v1/workflow.schema.json +22 -107
- package/dist/services/agentSpecExecutionService.d.ts +3 -3
- package/dist/services/agentSpecExecutionService.js +59 -55
- package/dist/services/api.d.ts +2 -2
- package/dist/services/api.js +37 -37
- package/dist/services/apiVariableService.d.ts +1 -1
- package/dist/services/apiVariableService.js +41 -34
- package/dist/services/autoSaveService.js +8 -8
- package/dist/services/categoriesApi.d.ts +2 -2
- package/dist/services/categoriesApi.js +8 -8
- package/dist/services/draftStorage.d.ts +1 -1
- package/dist/services/draftStorage.js +11 -11
- package/dist/services/dynamicSchemaService.d.ts +1 -1
- package/dist/services/dynamicSchemaService.js +41 -39
- package/dist/services/globalSave.d.ts +2 -2
- package/dist/services/globalSave.js +41 -38
- package/dist/services/historyService.d.ts +1 -1
- package/dist/services/historyService.js +8 -8
- package/dist/services/interruptService.d.ts +1 -1
- package/dist/services/interruptService.js +35 -29
- package/dist/services/nodeExecutionService.d.ts +1 -1
- package/dist/services/nodeExecutionService.js +45 -44
- package/dist/services/playgroundService.d.ts +1 -1
- package/dist/services/playgroundService.js +29 -29
- package/dist/services/portConfigApi.d.ts +2 -2
- package/dist/services/portConfigApi.js +8 -8
- package/dist/services/settingsService.d.ts +2 -2
- package/dist/services/settingsService.js +25 -19
- package/dist/services/toastService.d.ts +4 -4
- package/dist/services/toastService.js +33 -33
- package/dist/services/variableService.d.ts +1 -1
- package/dist/services/variableService.js +36 -36
- package/dist/services/workflowStorage.d.ts +2 -2
- package/dist/services/workflowStorage.js +13 -13
- package/dist/settings/index.d.ts +7 -7
- package/dist/settings/index.js +6 -6
- package/dist/skins/default.d.ts +2 -0
- package/dist/skins/default.js +1 -0
- package/dist/skins/index.d.ts +13 -0
- package/dist/skins/index.js +30 -0
- package/dist/skins/slate.d.ts +2 -0
- package/dist/skins/slate.js +78 -0
- package/dist/stores/categoriesStore.svelte.d.ts +1 -1
- package/dist/stores/categoriesStore.svelte.js +5 -5
- package/dist/stores/editorStateMachine.svelte.d.ts +2 -2
- package/dist/stores/editorStateMachine.svelte.js +65 -33
- package/dist/stores/historyStore.svelte.d.ts +4 -4
- package/dist/stores/historyStore.svelte.js +4 -4
- package/dist/stores/interruptStore.svelte.d.ts +3 -3
- package/dist/stores/interruptStore.svelte.js +21 -21
- package/dist/stores/playgroundStore.svelte.d.ts +2 -2
- package/dist/stores/playgroundStore.svelte.js +25 -18
- package/dist/stores/portCoordinateStore.svelte.d.ts +2 -2
- package/dist/stores/portCoordinateStore.svelte.js +15 -8
- package/dist/stores/settingsStore.svelte.d.ts +2 -2
- package/dist/stores/settingsStore.svelte.js +62 -57
- package/dist/stores/workflowStore.svelte.d.ts +3 -3
- package/dist/stores/workflowStore.svelte.js +50 -47
- package/dist/stories/CanvasDecorator.svelte +35 -32
- package/dist/stories/CanvasDecorator.svelte.d.ts +2 -2
- package/dist/stories/EdgeDecorator.svelte +102 -99
- package/dist/stories/EdgeDecorator.svelte.d.ts +1 -1
- package/dist/stories/NodeDecorator.svelte +59 -53
- package/dist/stories/NodeDecorator.svelte.d.ts +1 -1
- package/dist/stories/utils.d.ts +2 -2
- package/dist/stories/utils.js +105 -67
- package/dist/styles/base.css +599 -595
- package/dist/styles/toast.css +14 -14
- package/dist/styles/tokens.css +409 -378
- package/dist/svelte-app.d.ts +9 -9
- package/dist/svelte-app.js +39 -39
- package/dist/themes/default.d.ts +2 -0
- package/dist/themes/default.js +9 -0
- package/dist/themes/index.d.ts +13 -0
- package/dist/themes/index.js +44 -0
- package/dist/themes/minimal.d.ts +2 -0
- package/dist/themes/minimal.js +11 -0
- package/dist/types/agentspec.d.ts +18 -18
- package/dist/types/agentspec.js +2 -2
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/auth.js +6 -6
- package/dist/types/config.d.ts +6 -6
- package/dist/types/events.d.ts +2 -2
- package/dist/types/events.js +2 -2
- package/dist/types/index.d.ts +32 -32
- package/dist/types/index.js +6 -6
- package/dist/types/interrupt.d.ts +6 -6
- package/dist/types/interrupt.js +21 -21
- package/dist/types/interruptState.d.ts +12 -12
- package/dist/types/interruptState.js +66 -66
- package/dist/types/playground.d.ts +7 -7
- package/dist/types/playground.js +14 -14
- package/dist/types/settings.d.ts +5 -3
- package/dist/types/settings.js +25 -18
- package/dist/types/skin.d.ts +31 -0
- package/dist/types/skin.js +1 -0
- package/dist/types/theme.d.ts +35 -0
- package/dist/types/theme.js +1 -0
- package/dist/types/uischema.d.ts +4 -4
- package/dist/types/uischema.js +3 -3
- package/dist/utils/colors.d.ts +1 -1
- package/dist/utils/colors.js +97 -95
- package/dist/utils/config.d.ts +2 -2
- package/dist/utils/config.js +48 -48
- package/dist/utils/connections.d.ts +2 -2
- package/dist/utils/connections.js +15 -15
- package/dist/utils/errors.js +3 -3
- package/dist/utils/fetchWithAuth.d.ts +1 -1
- package/dist/utils/fetchWithAuth.js +2 -2
- package/dist/utils/handleIds.d.ts +2 -2
- package/dist/utils/handleIds.js +8 -8
- package/dist/utils/handlePositioning.d.ts +1 -1
- package/dist/utils/handlePositioning.js +2 -2
- package/dist/utils/icons.d.ts +1 -1
- package/dist/utils/icons.js +74 -74
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.js +7 -7
- package/dist/utils/nodeStatus.d.ts +1 -1
- package/dist/utils/nodeStatus.js +48 -48
- package/dist/utils/nodeTypes.d.ts +1 -1
- package/dist/utils/nodeTypes.js +21 -20
- package/dist/utils/nodeWrapper.d.ts +7 -7
- package/dist/utils/nodeWrapper.js +21 -19
- package/dist/utils/performanceUtils.d.ts +1 -1
- package/dist/utils/performanceUtils.js +2 -1
- package/dist/utils/sanitize.js +1 -1
- package/dist/utils/uischema.d.ts +2 -2
- package/dist/utils/uischema.js +8 -8
- package/dist/utils/validation.js +20 -8
- package/package.json +1 -1
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Follows the same singleton pattern as NodeExecutionService.
|
|
8
8
|
*/
|
|
9
|
-
import { buildAgentSpecUrl, getAgentSpecAuthHeaders } from
|
|
10
|
-
import { AgentSpecAdapter } from
|
|
11
|
-
import { logger } from
|
|
9
|
+
import { buildAgentSpecUrl, getAgentSpecAuthHeaders, } from "../config/agentSpecEndpoints.js";
|
|
10
|
+
import { AgentSpecAdapter } from "../adapters/agentspec/AgentSpecAdapter.js";
|
|
11
|
+
import { logger } from "../utils/logger.js";
|
|
12
12
|
/**
|
|
13
13
|
* Service for executing FlowDrop workflows on Agent Spec runtimes.
|
|
14
14
|
*
|
|
@@ -67,7 +67,7 @@ export class AgentSpecExecutionService {
|
|
|
67
67
|
const url = buildAgentSpecUrl(this.config, this.config.endpoints.health);
|
|
68
68
|
const response = await fetch(url, {
|
|
69
69
|
headers: getAgentSpecAuthHeaders(this.config),
|
|
70
|
-
signal: AbortSignal.timeout(5000)
|
|
70
|
+
signal: AbortSignal.timeout(5000),
|
|
71
71
|
});
|
|
72
72
|
return response.ok;
|
|
73
73
|
}
|
|
@@ -90,29 +90,29 @@ export class AgentSpecExecutionService {
|
|
|
90
90
|
// POST to runtime
|
|
91
91
|
const url = buildAgentSpecUrl(this.getConfig(), this.getConfig().endpoints.execute);
|
|
92
92
|
const response = await fetch(url, {
|
|
93
|
-
method:
|
|
93
|
+
method: "POST",
|
|
94
94
|
headers: getAgentSpecAuthHeaders(this.getConfig()),
|
|
95
95
|
body: JSON.stringify({
|
|
96
96
|
flow: agentSpecFlow,
|
|
97
|
-
inputs: inputs || {}
|
|
97
|
+
inputs: inputs || {},
|
|
98
98
|
}),
|
|
99
|
-
signal: AbortSignal.timeout(this.getConfig().timeout || 60000)
|
|
99
|
+
signal: AbortSignal.timeout(this.getConfig().timeout || 60000),
|
|
100
100
|
});
|
|
101
101
|
if (!response.ok) {
|
|
102
|
-
const errorText = await response.text().catch(() =>
|
|
102
|
+
const errorText = await response.text().catch(() => "Unknown error");
|
|
103
103
|
throw new Error(`Agent Spec runtime error (${response.status}): ${errorText}`);
|
|
104
104
|
}
|
|
105
105
|
const result = await response.json();
|
|
106
106
|
const executionId = result.execution_id || result.id;
|
|
107
107
|
if (!executionId) {
|
|
108
|
-
throw new Error(
|
|
108
|
+
throw new Error("Runtime did not return an execution ID");
|
|
109
109
|
}
|
|
110
110
|
// Track execution
|
|
111
111
|
const state = {
|
|
112
112
|
id: executionId,
|
|
113
|
-
status:
|
|
113
|
+
status: "running",
|
|
114
114
|
startedAt: new Date().toISOString(),
|
|
115
|
-
nodeStatuses: {}
|
|
115
|
+
nodeStatuses: {},
|
|
116
116
|
};
|
|
117
117
|
this.activeExecutions.set(executionId, state);
|
|
118
118
|
// Build node name → FlowDrop node ID mapping for status updates
|
|
@@ -135,10 +135,10 @@ export class AgentSpecExecutionService {
|
|
|
135
135
|
this.ensureConfigured();
|
|
136
136
|
try {
|
|
137
137
|
const url = buildAgentSpecUrl(this.getConfig(), this.getConfig().endpoints.status, {
|
|
138
|
-
id: executionId
|
|
138
|
+
id: executionId,
|
|
139
139
|
});
|
|
140
140
|
const response = await fetch(url, {
|
|
141
|
-
headers: getAgentSpecAuthHeaders(this.getConfig())
|
|
141
|
+
headers: getAgentSpecAuthHeaders(this.getConfig()),
|
|
142
142
|
});
|
|
143
143
|
if (!response.ok)
|
|
144
144
|
return null;
|
|
@@ -156,15 +156,15 @@ export class AgentSpecExecutionService {
|
|
|
156
156
|
this.ensureConfigured();
|
|
157
157
|
this.stopPolling(executionId);
|
|
158
158
|
const url = buildAgentSpecUrl(this.getConfig(), this.getConfig().endpoints.cancel, {
|
|
159
|
-
id: executionId
|
|
159
|
+
id: executionId,
|
|
160
160
|
});
|
|
161
161
|
await fetch(url, {
|
|
162
|
-
method:
|
|
163
|
-
headers: getAgentSpecAuthHeaders(this.getConfig())
|
|
162
|
+
method: "POST",
|
|
163
|
+
headers: getAgentSpecAuthHeaders(this.getConfig()),
|
|
164
164
|
});
|
|
165
165
|
const state = this.activeExecutions.get(executionId);
|
|
166
166
|
if (state) {
|
|
167
|
-
state.status =
|
|
167
|
+
state.status = "cancelled";
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
@@ -174,10 +174,10 @@ export class AgentSpecExecutionService {
|
|
|
174
174
|
this.ensureConfigured();
|
|
175
175
|
try {
|
|
176
176
|
const url = buildAgentSpecUrl(this.getConfig(), this.getConfig().endpoints.results, {
|
|
177
|
-
id: executionId
|
|
177
|
+
id: executionId,
|
|
178
178
|
});
|
|
179
179
|
const response = await fetch(url, {
|
|
180
|
-
headers: getAgentSpecAuthHeaders(this.getConfig())
|
|
180
|
+
headers: getAgentSpecAuthHeaders(this.getConfig()),
|
|
181
181
|
});
|
|
182
182
|
if (!response.ok)
|
|
183
183
|
return null;
|
|
@@ -195,12 +195,15 @@ export class AgentSpecExecutionService {
|
|
|
195
195
|
const agentSpecFlow = this.adapter.toAgentSpec(workflow);
|
|
196
196
|
const url = buildAgentSpecUrl(this.getConfig(), this.getConfig().endpoints.validate);
|
|
197
197
|
const response = await fetch(url, {
|
|
198
|
-
method:
|
|
198
|
+
method: "POST",
|
|
199
199
|
headers: getAgentSpecAuthHeaders(this.getConfig()),
|
|
200
|
-
body: JSON.stringify(agentSpecFlow)
|
|
200
|
+
body: JSON.stringify(agentSpecFlow),
|
|
201
201
|
});
|
|
202
202
|
if (!response.ok) {
|
|
203
|
-
return {
|
|
203
|
+
return {
|
|
204
|
+
valid: false,
|
|
205
|
+
errors: [`Runtime validation failed: ${response.status}`],
|
|
206
|
+
};
|
|
204
207
|
}
|
|
205
208
|
return await response.json();
|
|
206
209
|
}
|
|
@@ -218,7 +221,7 @@ export class AgentSpecExecutionService {
|
|
|
218
221
|
// ========================================================================
|
|
219
222
|
ensureConfigured() {
|
|
220
223
|
if (!this.config) {
|
|
221
|
-
throw new Error(
|
|
224
|
+
throw new Error("AgentSpecExecutionService not configured. Call configure() with runtime endpoint config first.");
|
|
222
225
|
}
|
|
223
226
|
}
|
|
224
227
|
/** Get the config, throwing if not configured */
|
|
@@ -234,10 +237,10 @@ export class AgentSpecExecutionService {
|
|
|
234
237
|
const poll = async () => {
|
|
235
238
|
try {
|
|
236
239
|
const url = buildAgentSpecUrl(this.getConfig(), this.getConfig().endpoints.status, {
|
|
237
|
-
id: executionId
|
|
240
|
+
id: executionId,
|
|
238
241
|
});
|
|
239
242
|
const response = await fetch(url, {
|
|
240
|
-
headers: getAgentSpecAuthHeaders(this.getConfig())
|
|
243
|
+
headers: getAgentSpecAuthHeaders(this.getConfig()),
|
|
241
244
|
});
|
|
242
245
|
if (!response.ok) {
|
|
243
246
|
throw new Error(`Status check failed: ${response.status}`);
|
|
@@ -253,26 +256,27 @@ export class AgentSpecExecutionService {
|
|
|
253
256
|
onNodeUpdate?.(nodeId, info);
|
|
254
257
|
}
|
|
255
258
|
// Check if execution is done
|
|
256
|
-
if (executionStatus ===
|
|
257
|
-
state.status =
|
|
259
|
+
if (executionStatus === "completed" || executionStatus === "success") {
|
|
260
|
+
state.status = "completed";
|
|
258
261
|
this.stopPolling(executionId);
|
|
259
262
|
const results = await this.getResults(executionId);
|
|
260
263
|
onComplete?.(results || {});
|
|
261
264
|
}
|
|
262
|
-
else if (executionStatus ===
|
|
263
|
-
|
|
265
|
+
else if (executionStatus === "failed" ||
|
|
266
|
+
executionStatus === "error") {
|
|
267
|
+
state.status = "failed";
|
|
264
268
|
this.stopPolling(executionId);
|
|
265
|
-
const errorMsg = data.error || data.message ||
|
|
269
|
+
const errorMsg = data.error || data.message || "Execution failed";
|
|
266
270
|
onError?.(new Error(errorMsg));
|
|
267
271
|
}
|
|
268
|
-
else if (executionStatus ===
|
|
269
|
-
state.status =
|
|
272
|
+
else if (executionStatus === "cancelled") {
|
|
273
|
+
state.status = "cancelled";
|
|
270
274
|
this.stopPolling(executionId);
|
|
271
275
|
}
|
|
272
276
|
}
|
|
273
277
|
catch (error) {
|
|
274
278
|
// Don't stop polling on transient errors — let it retry
|
|
275
|
-
logger.error(
|
|
279
|
+
logger.error("[AgentSpecExecution] Polling error:", error);
|
|
276
280
|
}
|
|
277
281
|
};
|
|
278
282
|
// Initial poll immediately, then at interval
|
|
@@ -295,38 +299,38 @@ export class AgentSpecExecutionService {
|
|
|
295
299
|
return result;
|
|
296
300
|
}
|
|
297
301
|
mapSingleNodeStatus(status) {
|
|
298
|
-
const runtimeStatus = (status.status || status.state ||
|
|
302
|
+
const runtimeStatus = (status.status || status.state || "idle");
|
|
299
303
|
return {
|
|
300
304
|
status: this.mapToFlowDropStatus(runtimeStatus),
|
|
301
305
|
executionCount: status.execution_count || 0,
|
|
302
|
-
isExecuting: runtimeStatus ===
|
|
306
|
+
isExecuting: runtimeStatus === "running" || runtimeStatus === "executing",
|
|
303
307
|
lastExecuted: status.started_at,
|
|
304
308
|
lastExecutionDuration: status.duration_ms,
|
|
305
|
-
lastError: status.error
|
|
309
|
+
lastError: status.error,
|
|
306
310
|
};
|
|
307
311
|
}
|
|
308
312
|
mapToFlowDropStatus(runtimeStatus) {
|
|
309
313
|
switch (runtimeStatus) {
|
|
310
|
-
case
|
|
311
|
-
case
|
|
312
|
-
return
|
|
313
|
-
case
|
|
314
|
-
case
|
|
315
|
-
case
|
|
316
|
-
return
|
|
317
|
-
case
|
|
318
|
-
case
|
|
319
|
-
return
|
|
320
|
-
case
|
|
321
|
-
case
|
|
322
|
-
return
|
|
323
|
-
case
|
|
324
|
-
case
|
|
325
|
-
return
|
|
326
|
-
case
|
|
327
|
-
return
|
|
314
|
+
case "running":
|
|
315
|
+
case "executing":
|
|
316
|
+
return "running";
|
|
317
|
+
case "completed":
|
|
318
|
+
case "success":
|
|
319
|
+
case "done":
|
|
320
|
+
return "completed";
|
|
321
|
+
case "failed":
|
|
322
|
+
case "error":
|
|
323
|
+
return "failed";
|
|
324
|
+
case "cancelled":
|
|
325
|
+
case "canceled":
|
|
326
|
+
return "cancelled";
|
|
327
|
+
case "pending":
|
|
328
|
+
case "queued":
|
|
329
|
+
return "pending";
|
|
330
|
+
case "skipped":
|
|
331
|
+
return "skipped";
|
|
328
332
|
default:
|
|
329
|
-
return
|
|
333
|
+
return "idle";
|
|
330
334
|
}
|
|
331
335
|
}
|
|
332
336
|
}
|
package/dist/services/api.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Client-side API service for FlowDrop
|
|
3
3
|
* Provides methods to interact with the backend APIs using configurable endpoints
|
|
4
4
|
*/
|
|
5
|
-
import type { NodeMetadata, Workflow } from
|
|
6
|
-
import type { EndpointConfig } from
|
|
5
|
+
import type { NodeMetadata, Workflow } from "../types/index.js";
|
|
6
|
+
import type { EndpointConfig } from "../config/endpoints.js";
|
|
7
7
|
/**
|
|
8
8
|
* Set the endpoint configuration at runtime
|
|
9
9
|
*/
|
package/dist/services/api.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Client-side API service for FlowDrop
|
|
3
3
|
* Provides methods to interact with the backend APIs using configurable endpoints
|
|
4
4
|
*/
|
|
5
|
-
import { buildEndpointUrl, getEndpointMethod, getEndpointHeaders } from
|
|
5
|
+
import { buildEndpointUrl, getEndpointMethod, getEndpointHeaders, } from "../config/endpoints.js";
|
|
6
6
|
let endpointConfig = null;
|
|
7
7
|
/**
|
|
8
8
|
* Set the endpoint configuration at runtime
|
|
@@ -21,7 +21,7 @@ export function getEndpointConfig() {
|
|
|
21
21
|
*/
|
|
22
22
|
async function apiRequest(endpointKey, endpointPath, params, options = {}) {
|
|
23
23
|
if (!endpointConfig) {
|
|
24
|
-
throw new Error(
|
|
24
|
+
throw new Error("Endpoint configuration not set. Call setEndpointConfig() first.");
|
|
25
25
|
}
|
|
26
26
|
const url = buildEndpointUrl(endpointConfig, endpointPath, params);
|
|
27
27
|
const method = getEndpointMethod(endpointConfig, endpointKey);
|
|
@@ -29,11 +29,11 @@ async function apiRequest(endpointKey, endpointPath, params, options = {}) {
|
|
|
29
29
|
const response = await fetch(url, {
|
|
30
30
|
method,
|
|
31
31
|
headers,
|
|
32
|
-
...options
|
|
32
|
+
...options,
|
|
33
33
|
});
|
|
34
34
|
// Check if response is JSON
|
|
35
|
-
const contentType = response.headers.get(
|
|
36
|
-
const isJson = contentType?.includes(
|
|
35
|
+
const contentType = response.headers.get("content-type");
|
|
36
|
+
const isJson = contentType?.includes("application/json");
|
|
37
37
|
if (!response.ok) {
|
|
38
38
|
// Try to get error details
|
|
39
39
|
let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
@@ -73,18 +73,18 @@ export const nodeApi = {
|
|
|
73
73
|
*/
|
|
74
74
|
async getNodes(options) {
|
|
75
75
|
if (!endpointConfig) {
|
|
76
|
-
throw new Error(
|
|
76
|
+
throw new Error("Endpoint configuration not set");
|
|
77
77
|
}
|
|
78
78
|
const params = new URLSearchParams();
|
|
79
79
|
if (options?.category)
|
|
80
|
-
params.append(
|
|
80
|
+
params.append("category", options.category);
|
|
81
81
|
if (options?.search)
|
|
82
|
-
params.append(
|
|
82
|
+
params.append("search", options.search);
|
|
83
83
|
if (options?.limit)
|
|
84
|
-
params.append(
|
|
84
|
+
params.append("limit", options.limit.toString());
|
|
85
85
|
if (options?.offset)
|
|
86
|
-
params.append(
|
|
87
|
-
const response = await apiRequest(
|
|
86
|
+
params.append("offset", options.offset.toString());
|
|
87
|
+
const response = await apiRequest("nodes.list", endpointConfig.endpoints.nodes.list + "?" + params.toString());
|
|
88
88
|
return response.data || [];
|
|
89
89
|
},
|
|
90
90
|
/**
|
|
@@ -92,14 +92,14 @@ export const nodeApi = {
|
|
|
92
92
|
*/
|
|
93
93
|
async getNode(id) {
|
|
94
94
|
if (!endpointConfig) {
|
|
95
|
-
throw new Error(
|
|
95
|
+
throw new Error("Endpoint configuration not set");
|
|
96
96
|
}
|
|
97
|
-
const response = await apiRequest(
|
|
97
|
+
const response = await apiRequest("nodes.get", endpointConfig.endpoints.nodes.get, { id });
|
|
98
98
|
if (!response.data) {
|
|
99
|
-
throw new Error(
|
|
99
|
+
throw new Error("Node not found");
|
|
100
100
|
}
|
|
101
101
|
return response.data;
|
|
102
|
-
}
|
|
102
|
+
},
|
|
103
103
|
};
|
|
104
104
|
/**
|
|
105
105
|
* Workflow API methods
|
|
@@ -110,16 +110,16 @@ export const workflowApi = {
|
|
|
110
110
|
*/
|
|
111
111
|
async getWorkflows(options) {
|
|
112
112
|
if (!endpointConfig) {
|
|
113
|
-
throw new Error(
|
|
113
|
+
throw new Error("Endpoint configuration not set");
|
|
114
114
|
}
|
|
115
115
|
const params = new URLSearchParams();
|
|
116
116
|
if (options?.search)
|
|
117
|
-
params.append(
|
|
117
|
+
params.append("search", options.search);
|
|
118
118
|
if (options?.limit)
|
|
119
|
-
params.append(
|
|
119
|
+
params.append("limit", options.limit.toString());
|
|
120
120
|
if (options?.offset)
|
|
121
|
-
params.append(
|
|
122
|
-
const response = await apiRequest(
|
|
121
|
+
params.append("offset", options.offset.toString());
|
|
122
|
+
const response = await apiRequest("workflows.list", endpointConfig.endpoints.workflows.list + "?" + params.toString());
|
|
123
123
|
return response.data || [];
|
|
124
124
|
},
|
|
125
125
|
/**
|
|
@@ -127,11 +127,11 @@ export const workflowApi = {
|
|
|
127
127
|
*/
|
|
128
128
|
async getWorkflow(id) {
|
|
129
129
|
if (!endpointConfig) {
|
|
130
|
-
throw new Error(
|
|
130
|
+
throw new Error("Endpoint configuration not set");
|
|
131
131
|
}
|
|
132
|
-
const response = await apiRequest(
|
|
132
|
+
const response = await apiRequest("workflows.get", endpointConfig.endpoints.workflows.get, { id });
|
|
133
133
|
if (!response.data) {
|
|
134
|
-
throw new Error(
|
|
134
|
+
throw new Error("Workflow not found");
|
|
135
135
|
}
|
|
136
136
|
return response.data;
|
|
137
137
|
},
|
|
@@ -140,18 +140,18 @@ export const workflowApi = {
|
|
|
140
140
|
*/
|
|
141
141
|
async createWorkflow(workflow) {
|
|
142
142
|
if (!endpointConfig) {
|
|
143
|
-
throw new Error(
|
|
143
|
+
throw new Error("Endpoint configuration not set");
|
|
144
144
|
}
|
|
145
145
|
// Apply the consumer-provided payload transform (e.g. Drupal's label mapping).
|
|
146
146
|
// The default is the identity function — no CMS-specific logic in the core library.
|
|
147
147
|
const transform = endpointConfig.transformWorkflowPayload ?? ((w) => w);
|
|
148
148
|
const body = transform(workflow);
|
|
149
|
-
const response = await apiRequest(
|
|
150
|
-
method:
|
|
151
|
-
body: JSON.stringify(body)
|
|
149
|
+
const response = await apiRequest("workflows.create", endpointConfig.endpoints.workflows.create, undefined, {
|
|
150
|
+
method: "POST",
|
|
151
|
+
body: JSON.stringify(body),
|
|
152
152
|
});
|
|
153
153
|
if (!response.data) {
|
|
154
|
-
throw new Error(
|
|
154
|
+
throw new Error("Failed to create workflow");
|
|
155
155
|
}
|
|
156
156
|
return response.data;
|
|
157
157
|
},
|
|
@@ -160,18 +160,18 @@ export const workflowApi = {
|
|
|
160
160
|
*/
|
|
161
161
|
async updateWorkflow(id, workflow) {
|
|
162
162
|
if (!endpointConfig) {
|
|
163
|
-
throw new Error(
|
|
163
|
+
throw new Error("Endpoint configuration not set");
|
|
164
164
|
}
|
|
165
165
|
// Apply the consumer-provided payload transform (e.g. Drupal's label mapping).
|
|
166
166
|
// The default is the identity function — no CMS-specific logic in the core library.
|
|
167
167
|
const transform = endpointConfig.transformWorkflowPayload ?? ((w) => w);
|
|
168
168
|
const body = transform(workflow);
|
|
169
|
-
const response = await apiRequest(
|
|
170
|
-
method:
|
|
171
|
-
body: JSON.stringify(body)
|
|
169
|
+
const response = await apiRequest("workflows.update", endpointConfig.endpoints.workflows.update, { id }, {
|
|
170
|
+
method: "PUT",
|
|
171
|
+
body: JSON.stringify(body),
|
|
172
172
|
});
|
|
173
173
|
if (!response.data) {
|
|
174
|
-
throw new Error(
|
|
174
|
+
throw new Error("Failed to update workflow");
|
|
175
175
|
}
|
|
176
176
|
return response.data;
|
|
177
177
|
},
|
|
@@ -180,9 +180,9 @@ export const workflowApi = {
|
|
|
180
180
|
*/
|
|
181
181
|
async deleteWorkflow(id) {
|
|
182
182
|
if (!endpointConfig) {
|
|
183
|
-
throw new Error(
|
|
183
|
+
throw new Error("Endpoint configuration not set");
|
|
184
184
|
}
|
|
185
|
-
await apiRequest(
|
|
185
|
+
await apiRequest("workflows.delete", endpointConfig.endpoints.workflows.delete, { id }, { method: "DELETE" });
|
|
186
186
|
},
|
|
187
187
|
/**
|
|
188
188
|
* Save workflow (create or update).
|
|
@@ -206,12 +206,12 @@ export const workflowApi = {
|
|
|
206
206
|
const { id, ...workflowData } = workflow;
|
|
207
207
|
return this.createWorkflow(workflowData);
|
|
208
208
|
}
|
|
209
|
-
}
|
|
209
|
+
},
|
|
210
210
|
};
|
|
211
211
|
/**
|
|
212
212
|
* Export the API service
|
|
213
213
|
*/
|
|
214
214
|
export const api = {
|
|
215
215
|
nodes: nodeApi,
|
|
216
|
-
workflows: workflowApi
|
|
216
|
+
workflows: workflowApi,
|
|
217
217
|
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module services/apiVariableService
|
|
7
7
|
*/
|
|
8
|
-
import type { VariableSchema, ApiVariablesConfig, AuthProvider } from
|
|
8
|
+
import type { VariableSchema, ApiVariablesConfig, AuthProvider } from "../types/index.js";
|
|
9
9
|
/**
|
|
10
10
|
* Context for variable API requests
|
|
11
11
|
*/
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module services/apiVariableService
|
|
7
7
|
*/
|
|
8
|
-
import { getEndpointConfig } from
|
|
9
|
-
import { logger } from
|
|
10
|
-
import { DEFAULT_CACHE_TTL_MS } from
|
|
8
|
+
import { getEndpointConfig } from "./api.js";
|
|
9
|
+
import { logger } from "../utils/logger.js";
|
|
10
|
+
import { DEFAULT_CACHE_TTL_MS } from "../config/constants.js";
|
|
11
11
|
/**
|
|
12
12
|
* Variable schema cache with TTL support
|
|
13
13
|
* Key format: `variables:{workflowId}:{nodeId}`
|
|
@@ -48,7 +48,7 @@ export function resolveEndpointUrl(template, context) {
|
|
|
48
48
|
* @returns A unique cache key string
|
|
49
49
|
*/
|
|
50
50
|
function generateVariableCacheKey(workflowId, nodeId) {
|
|
51
|
-
return `variables:${workflowId ||
|
|
51
|
+
return `variables:${workflowId || "unknown"}:${nodeId}`;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Checks if a cached variable schema is still valid (not expired).
|
|
@@ -71,7 +71,7 @@ function isCacheValid(entry, ttl = DEFAULT_VARIABLE_CACHE_TTL) {
|
|
|
71
71
|
function resolveBodyTemplates(body, context) {
|
|
72
72
|
const resolved = {};
|
|
73
73
|
for (const [key, value] of Object.entries(body)) {
|
|
74
|
-
if (typeof value ===
|
|
74
|
+
if (typeof value === "string") {
|
|
75
75
|
// Resolve template variables in string values
|
|
76
76
|
let resolvedValue = value;
|
|
77
77
|
if (context.workflowId) {
|
|
@@ -80,7 +80,9 @@ function resolveBodyTemplates(body, context) {
|
|
|
80
80
|
resolvedValue = resolvedValue.replace(/\{nodeId\}/g, encodeURIComponent(context.nodeId));
|
|
81
81
|
resolved[key] = resolvedValue;
|
|
82
82
|
}
|
|
83
|
-
else if (typeof value ===
|
|
83
|
+
else if (typeof value === "object" &&
|
|
84
|
+
value !== null &&
|
|
85
|
+
!Array.isArray(value)) {
|
|
84
86
|
// Recursively resolve nested objects
|
|
85
87
|
resolved[key] = resolveBodyTemplates(value, context);
|
|
86
88
|
}
|
|
@@ -129,27 +131,27 @@ export async function fetchVariableSchema(workflowId, nodeId, config, authProvid
|
|
|
129
131
|
return {
|
|
130
132
|
success: true,
|
|
131
133
|
schema: cached.schema,
|
|
132
|
-
fromCache: true
|
|
134
|
+
fromCache: true,
|
|
133
135
|
};
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
// Resolve the URL with template variables
|
|
137
139
|
let url = resolveEndpointUrl(endpoint.url, context);
|
|
138
140
|
// If URL is relative, prepend base URL from endpoint config
|
|
139
|
-
if (url.startsWith(
|
|
141
|
+
if (url.startsWith("/")) {
|
|
140
142
|
const currentConfig = getEndpointConfig();
|
|
141
143
|
if (currentConfig?.baseUrl) {
|
|
142
|
-
const baseUrl = currentConfig.baseUrl.replace(/\/$/,
|
|
144
|
+
const baseUrl = currentConfig.baseUrl.replace(/\/$/, "");
|
|
143
145
|
url = `${baseUrl}${url}`;
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
// Prepare request options
|
|
147
|
-
const method = endpoint.method ??
|
|
149
|
+
const method = endpoint.method ?? "GET";
|
|
148
150
|
const timeout = endpoint.timeout ?? 30000;
|
|
149
151
|
const headers = {
|
|
150
|
-
Accept:
|
|
151
|
-
|
|
152
|
-
...endpoint.headers
|
|
152
|
+
Accept: "application/json",
|
|
153
|
+
"Content-Type": "application/json",
|
|
154
|
+
...endpoint.headers,
|
|
153
155
|
};
|
|
154
156
|
// Add auth headers from AuthProvider if available
|
|
155
157
|
if (authProvider) {
|
|
@@ -158,19 +160,22 @@ export async function fetchVariableSchema(workflowId, nodeId, config, authProvid
|
|
|
158
160
|
Object.assign(headers, authHeaders);
|
|
159
161
|
}
|
|
160
162
|
catch (error) {
|
|
161
|
-
logger.warn(
|
|
163
|
+
logger.warn("Failed to get auth headers:", error);
|
|
162
164
|
}
|
|
163
165
|
}
|
|
164
166
|
// Add auth headers from endpoint config as fallback
|
|
165
167
|
const currentConfig = getEndpointConfig();
|
|
166
168
|
if (currentConfig?.auth) {
|
|
167
|
-
if (currentConfig.auth.type ===
|
|
168
|
-
headers[
|
|
169
|
+
if (currentConfig.auth.type === "bearer" && currentConfig.auth.token) {
|
|
170
|
+
headers["Authorization"] =
|
|
171
|
+
headers["Authorization"] ?? `Bearer ${currentConfig.auth.token}`;
|
|
169
172
|
}
|
|
170
|
-
else if (currentConfig.auth.type ===
|
|
171
|
-
|
|
173
|
+
else if (currentConfig.auth.type === "api_key" &&
|
|
174
|
+
currentConfig.auth.apiKey) {
|
|
175
|
+
headers["X-API-Key"] = headers["X-API-Key"] ?? currentConfig.auth.apiKey;
|
|
172
176
|
}
|
|
173
|
-
else if (currentConfig.auth.type ===
|
|
177
|
+
else if (currentConfig.auth.type === "custom" &&
|
|
178
|
+
currentConfig.auth.headers) {
|
|
174
179
|
Object.assign(headers, currentConfig.auth.headers);
|
|
175
180
|
}
|
|
176
181
|
}
|
|
@@ -178,10 +183,10 @@ export async function fetchVariableSchema(workflowId, nodeId, config, authProvid
|
|
|
178
183
|
const fetchOptions = {
|
|
179
184
|
method,
|
|
180
185
|
headers,
|
|
181
|
-
signal: AbortSignal.timeout(timeout)
|
|
186
|
+
signal: AbortSignal.timeout(timeout),
|
|
182
187
|
};
|
|
183
188
|
// Add body for non-GET requests
|
|
184
|
-
if (method !==
|
|
189
|
+
if (method !== "GET" && endpoint.body) {
|
|
185
190
|
const resolvedBody = resolveBodyTemplates(endpoint.body, context);
|
|
186
191
|
fetchOptions.body = JSON.stringify(resolvedBody);
|
|
187
192
|
}
|
|
@@ -192,7 +197,7 @@ export async function fetchVariableSchema(workflowId, nodeId, config, authProvid
|
|
|
192
197
|
return {
|
|
193
198
|
success: true,
|
|
194
199
|
schema: { variables: {} },
|
|
195
|
-
fromCache: false
|
|
200
|
+
fromCache: false,
|
|
196
201
|
};
|
|
197
202
|
}
|
|
198
203
|
if (!response.ok) {
|
|
@@ -207,13 +212,13 @@ export async function fetchVariableSchema(workflowId, nodeId, config, authProvid
|
|
|
207
212
|
}
|
|
208
213
|
return {
|
|
209
214
|
success: false,
|
|
210
|
-
error:
|
|
215
|
+
error: "Authentication failed",
|
|
211
216
|
};
|
|
212
217
|
}
|
|
213
218
|
const errorText = await response.text();
|
|
214
219
|
return {
|
|
215
220
|
success: false,
|
|
216
|
-
error: `HTTP ${response.status}: ${errorText || response.statusText}
|
|
221
|
+
error: `HTTP ${response.status}: ${errorText || response.statusText}`,
|
|
217
222
|
};
|
|
218
223
|
}
|
|
219
224
|
const data = await response.json();
|
|
@@ -223,15 +228,17 @@ export async function fetchVariableSchema(workflowId, nodeId, config, authProvid
|
|
|
223
228
|
// 3. Wrapped in { schema: { variables: {...} } }
|
|
224
229
|
// 4. Wrapped in { success: true, data: { variables: {...} } }
|
|
225
230
|
let schema;
|
|
226
|
-
if (data.variables && typeof data.variables ===
|
|
231
|
+
if (data.variables && typeof data.variables === "object") {
|
|
227
232
|
// Direct VariableSchema
|
|
228
233
|
schema = data;
|
|
229
234
|
}
|
|
230
|
-
else if (data.data?.variables &&
|
|
235
|
+
else if (data.data?.variables &&
|
|
236
|
+
typeof data.data.variables === "object") {
|
|
231
237
|
// Wrapped in { data: ... }
|
|
232
238
|
schema = data.data;
|
|
233
239
|
}
|
|
234
|
-
else if (data.schema?.variables &&
|
|
240
|
+
else if (data.schema?.variables &&
|
|
241
|
+
typeof data.schema.variables === "object") {
|
|
235
242
|
// Wrapped in { schema: ... }
|
|
236
243
|
schema = data.schema;
|
|
237
244
|
}
|
|
@@ -242,7 +249,7 @@ export async function fetchVariableSchema(workflowId, nodeId, config, authProvid
|
|
|
242
249
|
if (!schema) {
|
|
243
250
|
return {
|
|
244
251
|
success: false,
|
|
245
|
-
error:
|
|
252
|
+
error: "Invalid variable schema format received from endpoint",
|
|
246
253
|
};
|
|
247
254
|
}
|
|
248
255
|
// Cache the schema (if caching is enabled)
|
|
@@ -250,32 +257,32 @@ export async function fetchVariableSchema(workflowId, nodeId, config, authProvid
|
|
|
250
257
|
variableCache.set(cacheKey, {
|
|
251
258
|
schema,
|
|
252
259
|
cachedAt: Date.now(),
|
|
253
|
-
cacheKey
|
|
260
|
+
cacheKey,
|
|
254
261
|
});
|
|
255
262
|
}
|
|
256
263
|
return {
|
|
257
264
|
success: true,
|
|
258
265
|
schema,
|
|
259
|
-
fromCache: false
|
|
266
|
+
fromCache: false,
|
|
260
267
|
};
|
|
261
268
|
}
|
|
262
269
|
catch (error) {
|
|
263
270
|
// Handle specific error types
|
|
264
271
|
if (error instanceof Error) {
|
|
265
|
-
if (error.name ===
|
|
272
|
+
if (error.name === "AbortError" || error.name === "TimeoutError") {
|
|
266
273
|
return {
|
|
267
274
|
success: false,
|
|
268
|
-
error: `Request timed out after ${timeout}ms
|
|
275
|
+
error: `Request timed out after ${timeout}ms`,
|
|
269
276
|
};
|
|
270
277
|
}
|
|
271
278
|
return {
|
|
272
279
|
success: false,
|
|
273
|
-
error: error.message
|
|
280
|
+
error: error.message,
|
|
274
281
|
};
|
|
275
282
|
}
|
|
276
283
|
return {
|
|
277
284
|
success: false,
|
|
278
|
-
error:
|
|
285
|
+
error: "Unknown error occurred while fetching variable schema",
|
|
279
286
|
};
|
|
280
287
|
}
|
|
281
288
|
}
|