@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,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playground Service
|
|
3
|
+
*
|
|
4
|
+
* Handles API interactions for the Playground feature including
|
|
5
|
+
* session management, message handling, and polling for updates.
|
|
6
|
+
*
|
|
7
|
+
* @module services/playgroundService
|
|
8
|
+
*/
|
|
9
|
+
import type { PlaygroundSession, PlaygroundMessage, PlaygroundMessagesApiResponse, PlaygroundSessionStatus } from '../types/playground.js';
|
|
10
|
+
/**
|
|
11
|
+
* Playground Service class
|
|
12
|
+
*
|
|
13
|
+
* Provides methods to interact with the playground API endpoints
|
|
14
|
+
* including session management, message handling, and polling.
|
|
15
|
+
*/
|
|
16
|
+
export declare class PlaygroundService {
|
|
17
|
+
private static instance;
|
|
18
|
+
private pollingInterval;
|
|
19
|
+
private pollingSessionId;
|
|
20
|
+
private currentBackoff;
|
|
21
|
+
private lastMessageTimestamp;
|
|
22
|
+
private constructor();
|
|
23
|
+
/**
|
|
24
|
+
* Get the singleton instance of PlaygroundService
|
|
25
|
+
*
|
|
26
|
+
* @returns The PlaygroundService singleton instance
|
|
27
|
+
*/
|
|
28
|
+
static getInstance(): PlaygroundService;
|
|
29
|
+
/**
|
|
30
|
+
* Get the endpoint configuration
|
|
31
|
+
*
|
|
32
|
+
* @throws Error if endpoint configuration is not set
|
|
33
|
+
* @returns The endpoint configuration
|
|
34
|
+
*/
|
|
35
|
+
private getConfig;
|
|
36
|
+
/**
|
|
37
|
+
* Generic API request helper
|
|
38
|
+
*
|
|
39
|
+
* @param url - The URL to fetch
|
|
40
|
+
* @param options - Fetch options
|
|
41
|
+
* @returns The parsed JSON response
|
|
42
|
+
*/
|
|
43
|
+
private request;
|
|
44
|
+
/**
|
|
45
|
+
* List all playground sessions for a workflow
|
|
46
|
+
*
|
|
47
|
+
* @param workflowId - The workflow UUID
|
|
48
|
+
* @param options - Optional pagination parameters
|
|
49
|
+
* @returns Array of playground sessions
|
|
50
|
+
*/
|
|
51
|
+
listSessions(workflowId: string, options?: {
|
|
52
|
+
limit?: number;
|
|
53
|
+
offset?: number;
|
|
54
|
+
}): Promise<PlaygroundSession[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Create a new playground session
|
|
57
|
+
*
|
|
58
|
+
* @param workflowId - The workflow UUID
|
|
59
|
+
* @param name - Optional session name
|
|
60
|
+
* @param metadata - Optional session metadata
|
|
61
|
+
* @returns The created session
|
|
62
|
+
*/
|
|
63
|
+
createSession(workflowId: string, name?: string, metadata?: Record<string, unknown>): Promise<PlaygroundSession>;
|
|
64
|
+
/**
|
|
65
|
+
* Get a playground session by ID
|
|
66
|
+
*
|
|
67
|
+
* @param sessionId - The session UUID
|
|
68
|
+
* @returns The session details
|
|
69
|
+
*/
|
|
70
|
+
getSession(sessionId: string): Promise<PlaygroundSession>;
|
|
71
|
+
/**
|
|
72
|
+
* Delete a playground session
|
|
73
|
+
*
|
|
74
|
+
* @param sessionId - The session UUID
|
|
75
|
+
*/
|
|
76
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Get messages from a playground session
|
|
79
|
+
*
|
|
80
|
+
* @param sessionId - The session UUID
|
|
81
|
+
* @param since - Optional timestamp to fetch only newer messages (ISO 8601)
|
|
82
|
+
* @param limit - Maximum number of messages to return
|
|
83
|
+
* @returns Messages and session status
|
|
84
|
+
*/
|
|
85
|
+
getMessages(sessionId: string, since?: string, limit?: number): Promise<PlaygroundMessagesApiResponse>;
|
|
86
|
+
/**
|
|
87
|
+
* Send a message to a playground session
|
|
88
|
+
*
|
|
89
|
+
* @param sessionId - The session UUID
|
|
90
|
+
* @param content - The message content
|
|
91
|
+
* @param inputs - Optional additional inputs for workflow nodes
|
|
92
|
+
* @returns The created message
|
|
93
|
+
*/
|
|
94
|
+
sendMessage(sessionId: string, content: string, inputs?: Record<string, unknown>): Promise<PlaygroundMessage>;
|
|
95
|
+
/**
|
|
96
|
+
* Stop execution in a playground session
|
|
97
|
+
*
|
|
98
|
+
* @param sessionId - The session UUID
|
|
99
|
+
*/
|
|
100
|
+
stopExecution(sessionId: string): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Start polling for new messages
|
|
103
|
+
*
|
|
104
|
+
* @param sessionId - The session UUID to poll
|
|
105
|
+
* @param callback - Callback function to handle new messages
|
|
106
|
+
* @param interval - Polling interval in milliseconds (default: 1500)
|
|
107
|
+
* @param shouldStopPolling - Optional override for stop conditions (default: defaultShouldStopPolling)
|
|
108
|
+
*/
|
|
109
|
+
startPolling(sessionId: string, callback: (response: PlaygroundMessagesApiResponse) => void, interval?: number, shouldStopPolling?: (status: PlaygroundSessionStatus) => boolean): void;
|
|
110
|
+
/**
|
|
111
|
+
* Stop polling for messages
|
|
112
|
+
*/
|
|
113
|
+
stopPolling(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Check if polling is active
|
|
116
|
+
*
|
|
117
|
+
* @returns True if polling is active
|
|
118
|
+
*/
|
|
119
|
+
isPolling(): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Get the current polling session ID
|
|
122
|
+
*
|
|
123
|
+
* @returns The session ID being polled, or null
|
|
124
|
+
*/
|
|
125
|
+
getPollingSessionId(): string | null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Export singleton instance
|
|
129
|
+
*/
|
|
130
|
+
export declare const playgroundService: PlaygroundService;
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playground Service
|
|
3
|
+
*
|
|
4
|
+
* Handles API interactions for the Playground feature including
|
|
5
|
+
* session management, message handling, and polling for updates.
|
|
6
|
+
*
|
|
7
|
+
* @module services/playgroundService
|
|
8
|
+
*/
|
|
9
|
+
import { defaultShouldStopPolling } from '../types/playground.js';
|
|
10
|
+
import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
|
|
11
|
+
import { getEndpointConfig } from './api.js';
|
|
12
|
+
import { logger } from '../utils/logger.js';
|
|
13
|
+
/**
|
|
14
|
+
* Default polling interval in milliseconds
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_POLLING_INTERVAL = 1500;
|
|
17
|
+
/**
|
|
18
|
+
* Maximum polling backoff interval in milliseconds
|
|
19
|
+
*/
|
|
20
|
+
const MAX_POLLING_BACKOFF = 10000;
|
|
21
|
+
/**
|
|
22
|
+
* Playground Service class
|
|
23
|
+
*
|
|
24
|
+
* Provides methods to interact with the playground API endpoints
|
|
25
|
+
* including session management, message handling, and polling.
|
|
26
|
+
*/
|
|
27
|
+
export class PlaygroundService {
|
|
28
|
+
static instance;
|
|
29
|
+
pollingInterval = null;
|
|
30
|
+
pollingSessionId = null;
|
|
31
|
+
currentBackoff = DEFAULT_POLLING_INTERVAL;
|
|
32
|
+
lastMessageTimestamp = null;
|
|
33
|
+
constructor() { }
|
|
34
|
+
/**
|
|
35
|
+
* Get the singleton instance of PlaygroundService
|
|
36
|
+
*
|
|
37
|
+
* @returns The PlaygroundService singleton instance
|
|
38
|
+
*/
|
|
39
|
+
static getInstance() {
|
|
40
|
+
if (!PlaygroundService.instance) {
|
|
41
|
+
PlaygroundService.instance = new PlaygroundService();
|
|
42
|
+
}
|
|
43
|
+
return PlaygroundService.instance;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the endpoint configuration
|
|
47
|
+
*
|
|
48
|
+
* @throws Error if endpoint configuration is not set
|
|
49
|
+
* @returns The endpoint configuration
|
|
50
|
+
*/
|
|
51
|
+
getConfig() {
|
|
52
|
+
const config = getEndpointConfig();
|
|
53
|
+
if (!config) {
|
|
54
|
+
throw new Error('Endpoint configuration not set. Call setEndpointConfig() first.');
|
|
55
|
+
}
|
|
56
|
+
return config;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Generic API request helper
|
|
60
|
+
*
|
|
61
|
+
* @param url - The URL to fetch
|
|
62
|
+
* @param options - Fetch options
|
|
63
|
+
* @returns The parsed JSON response
|
|
64
|
+
*/
|
|
65
|
+
async request(url, options = {}) {
|
|
66
|
+
const config = this.getConfig();
|
|
67
|
+
const headers = getEndpointHeaders(config, 'playground');
|
|
68
|
+
const response = await fetch(url, {
|
|
69
|
+
...options,
|
|
70
|
+
headers: {
|
|
71
|
+
...headers,
|
|
72
|
+
...options.headers
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
const errorData = await response.json().catch(() => ({}));
|
|
77
|
+
const errorMessage = errorData.error ||
|
|
78
|
+
errorData.message ||
|
|
79
|
+
`HTTP ${response.status}: ${response.statusText}`;
|
|
80
|
+
throw new Error(errorMessage);
|
|
81
|
+
}
|
|
82
|
+
return response.json();
|
|
83
|
+
}
|
|
84
|
+
// =========================================================================
|
|
85
|
+
// Session Management
|
|
86
|
+
// =========================================================================
|
|
87
|
+
/**
|
|
88
|
+
* List all playground sessions for a workflow
|
|
89
|
+
*
|
|
90
|
+
* @param workflowId - The workflow UUID
|
|
91
|
+
* @param options - Optional pagination parameters
|
|
92
|
+
* @returns Array of playground sessions
|
|
93
|
+
*/
|
|
94
|
+
async listSessions(workflowId, options) {
|
|
95
|
+
const config = this.getConfig();
|
|
96
|
+
let url = buildEndpointUrl(config, config.endpoints.playground.listSessions, {
|
|
97
|
+
id: workflowId
|
|
98
|
+
});
|
|
99
|
+
// Add query parameters
|
|
100
|
+
const params = new URLSearchParams();
|
|
101
|
+
if (options?.limit !== undefined) {
|
|
102
|
+
params.append('limit', options.limit.toString());
|
|
103
|
+
}
|
|
104
|
+
if (options?.offset !== undefined) {
|
|
105
|
+
params.append('offset', options.offset.toString());
|
|
106
|
+
}
|
|
107
|
+
const queryString = params.toString();
|
|
108
|
+
if (queryString) {
|
|
109
|
+
url = `${url}?${queryString}`;
|
|
110
|
+
}
|
|
111
|
+
const response = await this.request(url);
|
|
112
|
+
return response.data ?? [];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a new playground session
|
|
116
|
+
*
|
|
117
|
+
* @param workflowId - The workflow UUID
|
|
118
|
+
* @param name - Optional session name
|
|
119
|
+
* @param metadata - Optional session metadata
|
|
120
|
+
* @returns The created session
|
|
121
|
+
*/
|
|
122
|
+
async createSession(workflowId, name, metadata) {
|
|
123
|
+
const config = this.getConfig();
|
|
124
|
+
const url = buildEndpointUrl(config, config.endpoints.playground.createSession, {
|
|
125
|
+
id: workflowId
|
|
126
|
+
});
|
|
127
|
+
const response = await this.request(url, {
|
|
128
|
+
method: 'POST',
|
|
129
|
+
body: JSON.stringify({ name, metadata })
|
|
130
|
+
});
|
|
131
|
+
if (!response.data) {
|
|
132
|
+
throw new Error('Failed to create session: No data returned');
|
|
133
|
+
}
|
|
134
|
+
return response.data;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get a playground session by ID
|
|
138
|
+
*
|
|
139
|
+
* @param sessionId - The session UUID
|
|
140
|
+
* @returns The session details
|
|
141
|
+
*/
|
|
142
|
+
async getSession(sessionId) {
|
|
143
|
+
const config = this.getConfig();
|
|
144
|
+
const url = buildEndpointUrl(config, config.endpoints.playground.getSession, {
|
|
145
|
+
sessionId
|
|
146
|
+
});
|
|
147
|
+
const response = await this.request(url);
|
|
148
|
+
if (!response.data) {
|
|
149
|
+
throw new Error('Session not found');
|
|
150
|
+
}
|
|
151
|
+
return response.data;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Delete a playground session
|
|
155
|
+
*
|
|
156
|
+
* @param sessionId - The session UUID
|
|
157
|
+
*/
|
|
158
|
+
async deleteSession(sessionId) {
|
|
159
|
+
const config = this.getConfig();
|
|
160
|
+
const url = buildEndpointUrl(config, config.endpoints.playground.deleteSession, {
|
|
161
|
+
sessionId
|
|
162
|
+
});
|
|
163
|
+
await this.request(url, {
|
|
164
|
+
method: 'DELETE'
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
// =========================================================================
|
|
168
|
+
// Message Handling
|
|
169
|
+
// =========================================================================
|
|
170
|
+
/**
|
|
171
|
+
* Get messages from a playground session
|
|
172
|
+
*
|
|
173
|
+
* @param sessionId - The session UUID
|
|
174
|
+
* @param since - Optional timestamp to fetch only newer messages (ISO 8601)
|
|
175
|
+
* @param limit - Maximum number of messages to return
|
|
176
|
+
* @returns Messages and session status
|
|
177
|
+
*/
|
|
178
|
+
async getMessages(sessionId, since, limit) {
|
|
179
|
+
const config = this.getConfig();
|
|
180
|
+
let url = buildEndpointUrl(config, config.endpoints.playground.getMessages, {
|
|
181
|
+
sessionId
|
|
182
|
+
});
|
|
183
|
+
// Add query parameters
|
|
184
|
+
const params = new URLSearchParams();
|
|
185
|
+
if (since) {
|
|
186
|
+
params.append('since', since);
|
|
187
|
+
}
|
|
188
|
+
if (limit !== undefined) {
|
|
189
|
+
params.append('limit', limit.toString());
|
|
190
|
+
}
|
|
191
|
+
const queryString = params.toString();
|
|
192
|
+
if (queryString) {
|
|
193
|
+
url = `${url}?${queryString}`;
|
|
194
|
+
}
|
|
195
|
+
return this.request(url);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Send a message to a playground session
|
|
199
|
+
*
|
|
200
|
+
* @param sessionId - The session UUID
|
|
201
|
+
* @param content - The message content
|
|
202
|
+
* @param inputs - Optional additional inputs for workflow nodes
|
|
203
|
+
* @returns The created message
|
|
204
|
+
*/
|
|
205
|
+
async sendMessage(sessionId, content, inputs) {
|
|
206
|
+
const config = this.getConfig();
|
|
207
|
+
const url = buildEndpointUrl(config, config.endpoints.playground.sendMessage, {
|
|
208
|
+
sessionId
|
|
209
|
+
});
|
|
210
|
+
const requestBody = { content };
|
|
211
|
+
if (inputs) {
|
|
212
|
+
requestBody.inputs = inputs;
|
|
213
|
+
}
|
|
214
|
+
const response = await this.request(url, {
|
|
215
|
+
method: 'POST',
|
|
216
|
+
body: JSON.stringify(requestBody)
|
|
217
|
+
});
|
|
218
|
+
if (!response.data) {
|
|
219
|
+
throw new Error('Failed to send message: No data returned');
|
|
220
|
+
}
|
|
221
|
+
return response.data;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Stop execution in a playground session
|
|
225
|
+
*
|
|
226
|
+
* @param sessionId - The session UUID
|
|
227
|
+
*/
|
|
228
|
+
async stopExecution(sessionId) {
|
|
229
|
+
const config = this.getConfig();
|
|
230
|
+
const url = buildEndpointUrl(config, config.endpoints.playground.stopExecution, {
|
|
231
|
+
sessionId
|
|
232
|
+
});
|
|
233
|
+
await this.request(url, {
|
|
234
|
+
method: 'POST'
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
// =========================================================================
|
|
238
|
+
// Polling
|
|
239
|
+
// =========================================================================
|
|
240
|
+
/**
|
|
241
|
+
* Start polling for new messages
|
|
242
|
+
*
|
|
243
|
+
* @param sessionId - The session UUID to poll
|
|
244
|
+
* @param callback - Callback function to handle new messages
|
|
245
|
+
* @param interval - Polling interval in milliseconds (default: 1500)
|
|
246
|
+
* @param shouldStopPolling - Optional override for stop conditions (default: defaultShouldStopPolling)
|
|
247
|
+
*/
|
|
248
|
+
startPolling(sessionId, callback, interval = DEFAULT_POLLING_INTERVAL, shouldStopPolling) {
|
|
249
|
+
// Stop any existing polling
|
|
250
|
+
this.stopPolling();
|
|
251
|
+
this.pollingSessionId = sessionId;
|
|
252
|
+
this.currentBackoff = interval;
|
|
253
|
+
this.lastMessageTimestamp = null;
|
|
254
|
+
const shouldStop = shouldStopPolling ?? defaultShouldStopPolling;
|
|
255
|
+
const poll = async () => {
|
|
256
|
+
if (this.pollingSessionId !== sessionId) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
const response = await this.getMessages(sessionId, this.lastMessageTimestamp ?? undefined);
|
|
261
|
+
// Update last message timestamp
|
|
262
|
+
if (response.data && response.data.length > 0) {
|
|
263
|
+
const lastMessage = response.data[response.data.length - 1];
|
|
264
|
+
this.lastMessageTimestamp = lastMessage.timestamp;
|
|
265
|
+
}
|
|
266
|
+
// Reset backoff on successful request
|
|
267
|
+
this.currentBackoff = interval;
|
|
268
|
+
// Call the callback with new messages
|
|
269
|
+
callback(response);
|
|
270
|
+
// Stop polling if the status matches the stop condition
|
|
271
|
+
if (response.sessionStatus && shouldStop(response.sessionStatus)) {
|
|
272
|
+
this.stopPolling();
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
logger.error('Polling error:', error);
|
|
278
|
+
// Exponential backoff on error
|
|
279
|
+
this.currentBackoff = Math.min(this.currentBackoff * 2, MAX_POLLING_BACKOFF);
|
|
280
|
+
}
|
|
281
|
+
// Schedule next poll
|
|
282
|
+
if (this.pollingSessionId === sessionId) {
|
|
283
|
+
this.pollingInterval = setTimeout(poll, this.currentBackoff);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
// Start polling immediately
|
|
287
|
+
poll();
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Stop polling for messages
|
|
291
|
+
*/
|
|
292
|
+
stopPolling() {
|
|
293
|
+
if (this.pollingInterval) {
|
|
294
|
+
clearTimeout(this.pollingInterval);
|
|
295
|
+
this.pollingInterval = null;
|
|
296
|
+
}
|
|
297
|
+
this.pollingSessionId = null;
|
|
298
|
+
this.lastMessageTimestamp = null;
|
|
299
|
+
this.currentBackoff = DEFAULT_POLLING_INTERVAL;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Check if polling is active
|
|
303
|
+
*
|
|
304
|
+
* @returns True if polling is active
|
|
305
|
+
*/
|
|
306
|
+
isPolling() {
|
|
307
|
+
return this.pollingSessionId !== null;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Get the current polling session ID
|
|
311
|
+
*
|
|
312
|
+
* @returns The session ID being polled, or null
|
|
313
|
+
*/
|
|
314
|
+
getPollingSessionId() {
|
|
315
|
+
return this.pollingSessionId;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Export singleton instance
|
|
320
|
+
*/
|
|
321
|
+
export const playgroundService = PlaygroundService.getInstance();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Port Configuration API Service
|
|
3
|
+
* Handles fetching port configuration from the backend
|
|
4
|
+
*/
|
|
5
|
+
import type { PortConfig } from '../types/index.js';
|
|
6
|
+
import type { EndpointConfig } from '../config/endpoints.js';
|
|
7
|
+
/**
|
|
8
|
+
* Fetch port configuration from API
|
|
9
|
+
*/
|
|
10
|
+
export declare function fetchPortConfig(endpointConfig: EndpointConfig): Promise<PortConfig>;
|
|
11
|
+
/**
|
|
12
|
+
* Validate port configuration structure
|
|
13
|
+
*/
|
|
14
|
+
export declare function validatePortConfig(config: PortConfig): boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Port Configuration API Service
|
|
3
|
+
* Handles fetching port configuration from the backend
|
|
4
|
+
*/
|
|
5
|
+
import { buildEndpointUrl } from '../config/endpoints.js';
|
|
6
|
+
import { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
|
|
7
|
+
import { logger } from '../utils/logger.js';
|
|
8
|
+
/**
|
|
9
|
+
* Fetch port configuration from API
|
|
10
|
+
*/
|
|
11
|
+
export async function fetchPortConfig(endpointConfig) {
|
|
12
|
+
try {
|
|
13
|
+
const url = buildEndpointUrl(endpointConfig, endpointConfig.endpoints.portConfig);
|
|
14
|
+
const response = await fetch(url, {
|
|
15
|
+
headers: { 'Content-Type': 'application/json' }
|
|
16
|
+
});
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
19
|
+
}
|
|
20
|
+
const data = await response.json();
|
|
21
|
+
const portConfig = data.data ?? data;
|
|
22
|
+
// Validate the configuration has required fields
|
|
23
|
+
if (!portConfig.dataTypes || !Array.isArray(portConfig.dataTypes)) {
|
|
24
|
+
logger.warn('Invalid port config received from API, using default');
|
|
25
|
+
return DEFAULT_PORT_CONFIG;
|
|
26
|
+
}
|
|
27
|
+
return portConfig;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
logger.error('Error fetching port configuration:', error);
|
|
31
|
+
return DEFAULT_PORT_CONFIG;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Validate port configuration structure
|
|
36
|
+
*/
|
|
37
|
+
export function validatePortConfig(config) {
|
|
38
|
+
if (!config || typeof config !== 'object') {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (!config.dataTypes || !Array.isArray(config.dataTypes)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (!config.defaultDataType || typeof config.defaultDataType !== 'string') {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
// Check that all data types have required fields
|
|
48
|
+
for (const dataType of config.dataTypes) {
|
|
49
|
+
if (!dataType.id || !dataType.name || !dataType.color) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings Service for FlowDrop
|
|
3
|
+
*
|
|
4
|
+
* Provides API operations for user preferences/settings using the
|
|
5
|
+
* configurable endpoint system. Integrates with settingsStore for
|
|
6
|
+
* hybrid localStorage + API persistence.
|
|
7
|
+
*
|
|
8
|
+
* @module services/settingsService
|
|
9
|
+
*/
|
|
10
|
+
import type { FlowDropSettings, PartialSettings } from '../types/settings.js';
|
|
11
|
+
import type { EndpointConfig } from '../config/endpoints.js';
|
|
12
|
+
/**
|
|
13
|
+
* Set the endpoint configuration for settings API calls
|
|
14
|
+
*
|
|
15
|
+
* @param config - Endpoint configuration
|
|
16
|
+
*/
|
|
17
|
+
export declare function setSettingsEndpointConfig(config: EndpointConfig): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get the current endpoint configuration
|
|
20
|
+
*
|
|
21
|
+
* @returns Current endpoint configuration or null
|
|
22
|
+
*/
|
|
23
|
+
export declare function getSettingsEndpointConfig(): EndpointConfig | null;
|
|
24
|
+
/**
|
|
25
|
+
* Settings API namespace
|
|
26
|
+
*/
|
|
27
|
+
export declare const settingsApi: {
|
|
28
|
+
/**
|
|
29
|
+
* Get user preferences from the backend
|
|
30
|
+
*
|
|
31
|
+
* @returns User's saved preferences
|
|
32
|
+
*/
|
|
33
|
+
getPreferences(): Promise<FlowDropSettings>;
|
|
34
|
+
/**
|
|
35
|
+
* Save user preferences to the backend
|
|
36
|
+
*
|
|
37
|
+
* @param settings - Complete settings to save
|
|
38
|
+
*/
|
|
39
|
+
savePreferences(settings: FlowDropSettings): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Partially update user preferences
|
|
42
|
+
*
|
|
43
|
+
* @param partial - Partial settings to merge
|
|
44
|
+
*/
|
|
45
|
+
patchPreferences(partial: PartialSettings): Promise<FlowDropSettings>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Settings service class for integration with settingsStore
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import { SettingsService } from "@flowdrop/flowdrop";
|
|
53
|
+
* import { setSettingsService } from "@flowdrop/flowdrop";
|
|
54
|
+
*
|
|
55
|
+
* const service = new SettingsService(endpointConfig);
|
|
56
|
+
* setSettingsService(service);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare class SettingsService {
|
|
60
|
+
private config;
|
|
61
|
+
/**
|
|
62
|
+
* Create a new settings service instance
|
|
63
|
+
*
|
|
64
|
+
* @param config - Endpoint configuration
|
|
65
|
+
*/
|
|
66
|
+
constructor(config: EndpointConfig);
|
|
67
|
+
/**
|
|
68
|
+
* Get user preferences from the backend
|
|
69
|
+
*
|
|
70
|
+
* @returns User's saved preferences
|
|
71
|
+
*/
|
|
72
|
+
getPreferences(): Promise<FlowDropSettings>;
|
|
73
|
+
/**
|
|
74
|
+
* Save user preferences to the backend
|
|
75
|
+
*
|
|
76
|
+
* @param settings - Complete settings to save
|
|
77
|
+
*/
|
|
78
|
+
savePreferences(settings: FlowDropSettings): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Partially update user preferences
|
|
81
|
+
*
|
|
82
|
+
* @param partial - Partial settings to merge
|
|
83
|
+
*/
|
|
84
|
+
patchPreferences(partial: PartialSettings): Promise<FlowDropSettings>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create a settings service instance
|
|
88
|
+
*
|
|
89
|
+
* @param config - Endpoint configuration
|
|
90
|
+
* @returns SettingsService instance
|
|
91
|
+
*/
|
|
92
|
+
export declare function createSettingsService(config: EndpointConfig): SettingsService;
|