ts-workflow-engine-lite 2.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/LICENSE +21 -0
- package/README.md +352 -0
- package/dist/src/api/ConsoleWebSocketManager.d.ts +57 -0
- package/dist/src/api/ConsoleWebSocketManager.js +206 -0
- package/dist/src/api/ConsoleWebSocketManager.js.map +1 -0
- package/dist/src/api/ErrorHandler.d.ts +52 -0
- package/dist/src/api/ErrorHandler.js +115 -0
- package/dist/src/api/ErrorHandler.js.map +1 -0
- package/dist/src/api/EventHistory.d.ts +73 -0
- package/dist/src/api/EventHistory.js +309 -0
- package/dist/src/api/EventHistory.js.map +1 -0
- package/dist/src/api/WebhookManager.d.ts +67 -0
- package/dist/src/api/WebhookManager.js +568 -0
- package/dist/src/api/WebhookManager.js.map +1 -0
- package/dist/src/api/docsPage.d.ts +1 -0
- package/dist/src/api/docsPage.js +321 -0
- package/dist/src/api/docsPage.js.map +1 -0
- package/dist/src/api/index.d.ts +8 -0
- package/dist/src/api/index.js +8 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/api/middleware/auth.d.ts +19 -0
- package/dist/src/api/middleware/auth.js +122 -0
- package/dist/src/api/middleware/auth.js.map +1 -0
- package/dist/src/api/middleware/index.d.ts +3 -0
- package/dist/src/api/middleware/index.js +3 -0
- package/dist/src/api/middleware/index.js.map +1 -0
- package/dist/src/api/middleware/rateLimit.d.ts +6 -0
- package/dist/src/api/middleware/rateLimit.js +69 -0
- package/dist/src/api/middleware/rateLimit.js.map +1 -0
- package/dist/src/api/middleware/rateLimitStore.d.ts +14 -0
- package/dist/src/api/middleware/rateLimitStore.js +44 -0
- package/dist/src/api/middleware/rateLimitStore.js.map +1 -0
- package/dist/src/api/middleware/rbac.d.ts +12 -0
- package/dist/src/api/middleware/rbac.js +120 -0
- package/dist/src/api/middleware/rbac.js.map +1 -0
- package/dist/src/api/openapi.d.ts +1917 -0
- package/dist/src/api/openapi.js +1758 -0
- package/dist/src/api/openapi.js.map +1 -0
- package/dist/src/api/playgroundPage.d.ts +1 -0
- package/dist/src/api/playgroundPage.js +765 -0
- package/dist/src/api/playgroundPage.js.map +1 -0
- package/dist/src/api/response.d.ts +22 -0
- package/dist/src/api/response.js +119 -0
- package/dist/src/api/response.js.map +1 -0
- package/dist/src/api/router.d.ts +17 -0
- package/dist/src/api/router.js +94 -0
- package/dist/src/api/router.js.map +1 -0
- package/dist/src/api/routes/analytics.d.ts +10 -0
- package/dist/src/api/routes/analytics.js +144 -0
- package/dist/src/api/routes/analytics.js.map +1 -0
- package/dist/src/api/routes/dlq.d.ts +3 -0
- package/dist/src/api/routes/dlq.js +248 -0
- package/dist/src/api/routes/dlq.js.map +1 -0
- package/dist/src/api/routes/eventHistory.d.ts +3 -0
- package/dist/src/api/routes/eventHistory.js +48 -0
- package/dist/src/api/routes/eventHistory.js.map +1 -0
- package/dist/src/api/routes/events.d.ts +3 -0
- package/dist/src/api/routes/events.js +205 -0
- package/dist/src/api/routes/events.js.map +1 -0
- package/dist/src/api/routes/functions.d.ts +3 -0
- package/dist/src/api/routes/functions.js +85 -0
- package/dist/src/api/routes/functions.js.map +1 -0
- package/dist/src/api/routes/instances.d.ts +3 -0
- package/dist/src/api/routes/instances.js +790 -0
- package/dist/src/api/routes/instances.js.map +1 -0
- package/dist/src/api/routes/templates.d.ts +3 -0
- package/dist/src/api/routes/templates.js +195 -0
- package/dist/src/api/routes/templates.js.map +1 -0
- package/dist/src/api/routes/webhooks.d.ts +3 -0
- package/dist/src/api/routes/webhooks.js +263 -0
- package/dist/src/api/routes/webhooks.js.map +1 -0
- package/dist/src/api/routes/workflows/analysis.d.ts +2 -0
- package/dist/src/api/routes/workflows/analysis.js +112 -0
- package/dist/src/api/routes/workflows/analysis.js.map +1 -0
- package/dist/src/api/routes/workflows/crud.d.ts +2 -0
- package/dist/src/api/routes/workflows/crud.js +140 -0
- package/dist/src/api/routes/workflows/crud.js.map +1 -0
- package/dist/src/api/routes/workflows/execution.d.ts +2 -0
- package/dist/src/api/routes/workflows/execution.js +204 -0
- package/dist/src/api/routes/workflows/execution.js.map +1 -0
- package/dist/src/api/routes/workflows/graph.d.ts +2 -0
- package/dist/src/api/routes/workflows/graph.js +51 -0
- package/dist/src/api/routes/workflows/graph.js.map +1 -0
- package/dist/src/api/routes/workflows/import.d.ts +2 -0
- package/dist/src/api/routes/workflows/import.js +238 -0
- package/dist/src/api/routes/workflows/import.js.map +1 -0
- package/dist/src/api/routes/workflows/index.d.ts +3 -0
- package/dist/src/api/routes/workflows/index.js +18 -0
- package/dist/src/api/routes/workflows/index.js.map +1 -0
- package/dist/src/api/routes/workflows/shared.d.ts +64 -0
- package/dist/src/api/routes/workflows/shared.js +304 -0
- package/dist/src/api/routes/workflows/shared.js.map +1 -0
- package/dist/src/api/routes/workflows/variables.d.ts +2 -0
- package/dist/src/api/routes/workflows/variables.js +34 -0
- package/dist/src/api/routes/workflows/variables.js.map +1 -0
- package/dist/src/api/routes/workflows/versioning.d.ts +2 -0
- package/dist/src/api/routes/workflows/versioning.js +235 -0
- package/dist/src/api/routes/workflows/versioning.js.map +1 -0
- package/dist/src/api/server.d.ts +13 -0
- package/dist/src/api/server.js +311 -0
- package/dist/src/api/server.js.map +1 -0
- package/dist/src/api/services/InstanceApplicationService.d.ts +74 -0
- package/dist/src/api/services/InstanceApplicationService.js +215 -0
- package/dist/src/api/services/InstanceApplicationService.js.map +1 -0
- package/dist/src/api/services/WorkflowApplicationService.d.ts +92 -0
- package/dist/src/api/services/WorkflowApplicationService.js +282 -0
- package/dist/src/api/services/WorkflowApplicationService.js.map +1 -0
- package/dist/src/api/services/index.d.ts +4 -0
- package/dist/src/api/services/index.js +3 -0
- package/dist/src/api/services/index.js.map +1 -0
- package/dist/src/api/types.d.ts +118 -0
- package/dist/src/api/types.js +2 -0
- package/dist/src/api/types.js.map +1 -0
- package/dist/src/api/utils/IdempotencyStore.d.ts +36 -0
- package/dist/src/api/utils/IdempotencyStore.js +121 -0
- package/dist/src/api/utils/IdempotencyStore.js.map +1 -0
- package/dist/src/api/utils/authConfig.d.ts +2 -0
- package/dist/src/api/utils/authConfig.js +25 -0
- package/dist/src/api/utils/authConfig.js.map +1 -0
- package/dist/src/api/utils/requestContext.d.ts +14 -0
- package/dist/src/api/utils/requestContext.js +31 -0
- package/dist/src/api/utils/requestContext.js.map +1 -0
- package/dist/src/api/utils/routeHelper.d.ts +25 -0
- package/dist/src/api/utils/routeHelper.js +30 -0
- package/dist/src/api/utils/routeHelper.js.map +1 -0
- package/dist/src/api/welcomePage.d.ts +1 -0
- package/dist/src/api/welcomePage.js +259 -0
- package/dist/src/api/welcomePage.js.map +1 -0
- package/dist/src/bootstrap.d.ts +20 -0
- package/dist/src/bootstrap.js +128 -0
- package/dist/src/bootstrap.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +32 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/config/AppConfig.d.ts +102 -0
- package/dist/src/config/AppConfig.js +452 -0
- package/dist/src/config/AppConfig.js.map +1 -0
- package/dist/src/config/redis.config.d.ts +6 -0
- package/dist/src/config/redis.config.js +9 -0
- package/dist/src/config/redis.config.js.map +1 -0
- package/dist/src/container.d.ts +29 -0
- package/dist/src/container.js +62 -0
- package/dist/src/container.js.map +1 -0
- package/dist/src/debug/BreakpointManager.d.ts +17 -0
- package/dist/src/debug/BreakpointManager.js +59 -0
- package/dist/src/debug/BreakpointManager.js.map +1 -0
- package/dist/src/debug/WorkflowDebugger.d.ts +34 -0
- package/dist/src/debug/WorkflowDebugger.js +117 -0
- package/dist/src/debug/WorkflowDebugger.js.map +1 -0
- package/dist/src/debug/index.d.ts +2 -0
- package/dist/src/debug/index.js +3 -0
- package/dist/src/debug/index.js.map +1 -0
- package/dist/src/demo/demoWorkflow.d.ts +3 -0
- package/dist/src/demo/demoWorkflow.js +82 -0
- package/dist/src/demo/demoWorkflow.js.map +1 -0
- package/dist/src/demo/exampleWorkflow.d.ts +36 -0
- package/dist/src/demo/exampleWorkflow.js +184 -0
- package/dist/src/demo/exampleWorkflow.js.map +1 -0
- package/dist/src/demo/index.d.ts +2 -0
- package/dist/src/demo/index.js +3 -0
- package/dist/src/demo/index.js.map +1 -0
- package/dist/src/dlq/DeadLetterQueue.d.ts +62 -0
- package/dist/src/dlq/DeadLetterQueue.js +342 -0
- package/dist/src/dlq/DeadLetterQueue.js.map +1 -0
- package/dist/src/dlq/index.d.ts +2 -0
- package/dist/src/dlq/index.js +2 -0
- package/dist/src/dlq/index.js.map +1 -0
- package/dist/src/dsl/DSLParser.d.ts +7 -0
- package/dist/src/dsl/DSLParser.js +252 -0
- package/dist/src/dsl/DSLParser.js.map +1 -0
- package/dist/src/dsl/WorkflowDSL.d.ts +40 -0
- package/dist/src/dsl/WorkflowDSL.js +2 -0
- package/dist/src/dsl/WorkflowDSL.js.map +1 -0
- package/dist/src/engine/CanaryReleaseManager.d.ts +39 -0
- package/dist/src/engine/CanaryReleaseManager.js +192 -0
- package/dist/src/engine/CanaryReleaseManager.js.map +1 -0
- package/dist/src/engine/ConcurrencyControl.d.ts +38 -0
- package/dist/src/engine/ConcurrencyControl.js +181 -0
- package/dist/src/engine/ConcurrencyControl.js.map +1 -0
- package/dist/src/engine/ContinueAsNewManager.d.ts +18 -0
- package/dist/src/engine/ContinueAsNewManager.js +29 -0
- package/dist/src/engine/ContinueAsNewManager.js.map +1 -0
- package/dist/src/engine/DataValidator.d.ts +15 -0
- package/dist/src/engine/DataValidator.js +121 -0
- package/dist/src/engine/DataValidator.js.map +1 -0
- package/dist/src/engine/DryRunExecutor.d.ts +48 -0
- package/dist/src/engine/DryRunExecutor.js +256 -0
- package/dist/src/engine/DryRunExecutor.js.map +1 -0
- package/dist/src/engine/ExecutionOrchestrator.d.ts +19 -0
- package/dist/src/engine/ExecutionOrchestrator.js +579 -0
- package/dist/src/engine/ExecutionOrchestrator.js.map +1 -0
- package/dist/src/engine/ExpressionEvaluator.d.ts +44 -0
- package/dist/src/engine/ExpressionEvaluator.js +1046 -0
- package/dist/src/engine/ExpressionEvaluator.js.map +1 -0
- package/dist/src/engine/HeartbeatManager.d.ts +42 -0
- package/dist/src/engine/HeartbeatManager.js +209 -0
- package/dist/src/engine/HeartbeatManager.js.map +1 -0
- package/dist/src/engine/InstanceManager.d.ts +21 -0
- package/dist/src/engine/InstanceManager.js +165 -0
- package/dist/src/engine/InstanceManager.js.map +1 -0
- package/dist/src/engine/InstanceSearch.d.ts +30 -0
- package/dist/src/engine/InstanceSearch.js +119 -0
- package/dist/src/engine/InstanceSearch.js.map +1 -0
- package/dist/src/engine/LifecycleManager.d.ts +18 -0
- package/dist/src/engine/LifecycleManager.js +82 -0
- package/dist/src/engine/LifecycleManager.js.map +1 -0
- package/dist/src/engine/ParallelExecutor.d.ts +26 -0
- package/dist/src/engine/ParallelExecutor.js +138 -0
- package/dist/src/engine/ParallelExecutor.js.map +1 -0
- package/dist/src/engine/SandboxEvaluator.d.ts +18 -0
- package/dist/src/engine/SandboxEvaluator.js +200 -0
- package/dist/src/engine/SandboxEvaluator.js.map +1 -0
- package/dist/src/engine/SchemaValidator.d.ts +30 -0
- package/dist/src/engine/SchemaValidator.js +630 -0
- package/dist/src/engine/SchemaValidator.js.map +1 -0
- package/dist/src/engine/SearchAttributeManager.d.ts +48 -0
- package/dist/src/engine/SearchAttributeManager.js +119 -0
- package/dist/src/engine/SearchAttributeManager.js.map +1 -0
- package/dist/src/engine/StateMachine.d.ts +13 -0
- package/dist/src/engine/StateMachine.js +66 -0
- package/dist/src/engine/StateMachine.js.map +1 -0
- package/dist/src/engine/StickyExecutionManager.d.ts +34 -0
- package/dist/src/engine/StickyExecutionManager.js +163 -0
- package/dist/src/engine/StickyExecutionManager.js.map +1 -0
- package/dist/src/engine/SubworkflowExecutor.d.ts +17 -0
- package/dist/src/engine/SubworkflowExecutor.js +157 -0
- package/dist/src/engine/SubworkflowExecutor.js.map +1 -0
- package/dist/src/engine/TaskExecutor.d.ts +12 -0
- package/dist/src/engine/TaskExecutor.js +124 -0
- package/dist/src/engine/TaskExecutor.js.map +1 -0
- package/dist/src/engine/TaskQueueManager.d.ts +42 -0
- package/dist/src/engine/TaskQueueManager.js +175 -0
- package/dist/src/engine/TaskQueueManager.js.map +1 -0
- package/dist/src/engine/WorkflowEngine.d.ts +117 -0
- package/dist/src/engine/WorkflowEngine.js +443 -0
- package/dist/src/engine/WorkflowEngine.js.map +1 -0
- package/dist/src/engine/WorkflowInstanceControl.d.ts +21 -0
- package/dist/src/engine/WorkflowInstanceControl.js +306 -0
- package/dist/src/engine/WorkflowInstanceControl.js.map +1 -0
- package/dist/src/engine/WorkflowPersistenceCoordinator.d.ts +12 -0
- package/dist/src/engine/WorkflowPersistenceCoordinator.js +93 -0
- package/dist/src/engine/WorkflowPersistenceCoordinator.js.map +1 -0
- package/dist/src/engine/WorkflowRegistry.d.ts +38 -0
- package/dist/src/engine/WorkflowRegistry.js +130 -0
- package/dist/src/engine/WorkflowRegistry.js.map +1 -0
- package/dist/src/engine/WorkflowVersionManager.d.ts +24 -0
- package/dist/src/engine/WorkflowVersionManager.js +121 -0
- package/dist/src/engine/WorkflowVersionManager.js.map +1 -0
- package/dist/src/engine/createEngine.d.ts +8 -0
- package/dist/src/engine/createEngine.js +21 -0
- package/dist/src/engine/createEngine.js.map +1 -0
- package/dist/src/engine/errors.d.ts +18 -0
- package/dist/src/engine/errors.js +37 -0
- package/dist/src/engine/errors.js.map +1 -0
- package/dist/src/engine/executors/ApprovalNodeExecutor.d.ts +12 -0
- package/dist/src/engine/executors/ApprovalNodeExecutor.js +68 -0
- package/dist/src/engine/executors/ApprovalNodeExecutor.js.map +1 -0
- package/dist/src/engine/executors/ConditionNodeExecutor.d.ts +16 -0
- package/dist/src/engine/executors/ConditionNodeExecutor.js +63 -0
- package/dist/src/engine/executors/ConditionNodeExecutor.js.map +1 -0
- package/dist/src/engine/executors/HttpNodeExecutor.d.ts +27 -0
- package/dist/src/engine/executors/HttpNodeExecutor.js +179 -0
- package/dist/src/engine/executors/HttpNodeExecutor.js.map +1 -0
- package/dist/src/engine/executors/JoinNodeExecutor.d.ts +13 -0
- package/dist/src/engine/executors/JoinNodeExecutor.js +37 -0
- package/dist/src/engine/executors/JoinNodeExecutor.js.map +1 -0
- package/dist/src/engine/executors/LoopNodeExecutor.d.ts +20 -0
- package/dist/src/engine/executors/LoopNodeExecutor.js +165 -0
- package/dist/src/engine/executors/LoopNodeExecutor.js.map +1 -0
- package/dist/src/engine/executors/NotificationNodeExecutor.d.ts +8 -0
- package/dist/src/engine/executors/NotificationNodeExecutor.js +33 -0
- package/dist/src/engine/executors/NotificationNodeExecutor.js.map +1 -0
- package/dist/src/engine/executors/QueueNodeExecutor.d.ts +23 -0
- package/dist/src/engine/executors/QueueNodeExecutor.js +87 -0
- package/dist/src/engine/executors/QueueNodeExecutor.js.map +1 -0
- package/dist/src/engine/executors/RouterNodeExecutor.d.ts +20 -0
- package/dist/src/engine/executors/RouterNodeExecutor.js +82 -0
- package/dist/src/engine/executors/RouterNodeExecutor.js.map +1 -0
- package/dist/src/engine/executors/SqlNodeExecutor.d.ts +27 -0
- package/dist/src/engine/executors/SqlNodeExecutor.js +74 -0
- package/dist/src/engine/executors/SqlNodeExecutor.js.map +1 -0
- package/dist/src/engine/executors/TransformNodeExecutor.d.ts +9 -0
- package/dist/src/engine/executors/TransformNodeExecutor.js +44 -0
- package/dist/src/engine/executors/TransformNodeExecutor.js.map +1 -0
- package/dist/src/engine/functions/collectionFunctions.d.ts +2 -0
- package/dist/src/engine/functions/collectionFunctions.js +129 -0
- package/dist/src/engine/functions/collectionFunctions.js.map +1 -0
- package/dist/src/engine/functions/customFunctions.d.ts +11 -0
- package/dist/src/engine/functions/customFunctions.js +42 -0
- package/dist/src/engine/functions/customFunctions.js.map +1 -0
- package/dist/src/engine/functions/dateFunctions.d.ts +2 -0
- package/dist/src/engine/functions/dateFunctions.js +71 -0
- package/dist/src/engine/functions/dateFunctions.js.map +1 -0
- package/dist/src/engine/functions/index.d.ts +14 -0
- package/dist/src/engine/functions/index.js +35 -0
- package/dist/src/engine/functions/index.js.map +1 -0
- package/dist/src/engine/functions/stringFunctions.d.ts +2 -0
- package/dist/src/engine/functions/stringFunctions.js +66 -0
- package/dist/src/engine/functions/stringFunctions.js.map +1 -0
- package/dist/src/engine/functions/typeFunctions.d.ts +2 -0
- package/dist/src/engine/functions/typeFunctions.js +70 -0
- package/dist/src/engine/functions/typeFunctions.js.map +1 -0
- package/dist/src/engine/functions/types.d.ts +6 -0
- package/dist/src/engine/functions/types.js +2 -0
- package/dist/src/engine/functions/types.js.map +1 -0
- package/dist/src/engine/index.d.ts +21 -0
- package/dist/src/engine/index.js +18 -0
- package/dist/src/engine/index.js.map +1 -0
- package/dist/src/engine/nodeDispatch/controlNodes.d.ts +2 -0
- package/dist/src/engine/nodeDispatch/controlNodes.js +208 -0
- package/dist/src/engine/nodeDispatch/controlNodes.js.map +1 -0
- package/dist/src/engine/nodeDispatch/helpers.d.ts +27 -0
- package/dist/src/engine/nodeDispatch/helpers.js +185 -0
- package/dist/src/engine/nodeDispatch/helpers.js.map +1 -0
- package/dist/src/engine/nodeDispatch/ioNodes.d.ts +2 -0
- package/dist/src/engine/nodeDispatch/ioNodes.js +89 -0
- package/dist/src/engine/nodeDispatch/ioNodes.js.map +1 -0
- package/dist/src/engine/nodeDispatch/types.d.ts +13 -0
- package/dist/src/engine/nodeDispatch/types.js +2 -0
- package/dist/src/engine/nodeDispatch/types.js.map +1 -0
- package/dist/src/engine/nodeDispatch/workflowNodes.d.ts +2 -0
- package/dist/src/engine/nodeDispatch/workflowNodes.js +33 -0
- package/dist/src/engine/nodeDispatch/workflowNodes.js.map +1 -0
- package/dist/src/engine/worker/ActionSandboxMessage.d.ts +29 -0
- package/dist/src/engine/worker/ActionSandboxMessage.js +7 -0
- package/dist/src/engine/worker/ActionSandboxMessage.js.map +1 -0
- package/dist/src/engine/worker/ActionSandboxPool.d.ts +34 -0
- package/dist/src/engine/worker/ActionSandboxPool.js +204 -0
- package/dist/src/engine/worker/ActionSandboxPool.js.map +1 -0
- package/dist/src/engine/worker/ActionSandboxWorker.d.ts +1 -0
- package/dist/src/engine/worker/ActionSandboxWorker.js +25 -0
- package/dist/src/engine/worker/ActionSandboxWorker.js.map +1 -0
- package/dist/src/engine/worker/WorkerMessage.d.ts +35 -0
- package/dist/src/engine/worker/WorkerMessage.js +7 -0
- package/dist/src/engine/worker/WorkerMessage.js.map +1 -0
- package/dist/src/engine/worker/WorkerPool.d.ts +42 -0
- package/dist/src/engine/worker/WorkerPool.js +273 -0
- package/dist/src/engine/worker/WorkerPool.js.map +1 -0
- package/dist/src/engine/worker/WorkerProcess.d.ts +1 -0
- package/dist/src/engine/worker/WorkerProcess.js +76 -0
- package/dist/src/engine/worker/WorkerProcess.js.map +1 -0
- package/dist/src/event/EventBus.d.ts +11 -0
- package/dist/src/event/EventBus.js +44 -0
- package/dist/src/event/EventBus.js.map +1 -0
- package/dist/src/event/EventCoordinator.d.ts +26 -0
- package/dist/src/event/EventCoordinator.js +205 -0
- package/dist/src/event/EventCoordinator.js.map +1 -0
- package/dist/src/event/EventDeduplicator.d.ts +31 -0
- package/dist/src/event/EventDeduplicator.js +100 -0
- package/dist/src/event/EventDeduplicator.js.map +1 -0
- package/dist/src/event/HookManager.d.ts +31 -0
- package/dist/src/event/HookManager.js +88 -0
- package/dist/src/event/HookManager.js.map +1 -0
- package/dist/src/event/MessageBus.d.ts +39 -0
- package/dist/src/event/MessageBus.js +131 -0
- package/dist/src/event/MessageBus.js.map +1 -0
- package/dist/src/event/index.d.ts +3 -0
- package/dist/src/event/index.js +4 -0
- package/dist/src/event/index.js.map +1 -0
- package/dist/src/index.d.ts +40 -0
- package/dist/src/index.js +33 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lifecycle.d.ts +17 -0
- package/dist/src/lifecycle.js +84 -0
- package/dist/src/lifecycle.js.map +1 -0
- package/dist/src/metrics/AnalyticsCollector.d.ts +57 -0
- package/dist/src/metrics/AnalyticsCollector.js +140 -0
- package/dist/src/metrics/AnalyticsCollector.js.map +1 -0
- package/dist/src/metrics/AnomalyDetector.d.ts +21 -0
- package/dist/src/metrics/AnomalyDetector.js +120 -0
- package/dist/src/metrics/AnomalyDetector.js.map +1 -0
- package/dist/src/metrics/MetricsAggregator.d.ts +43 -0
- package/dist/src/metrics/MetricsAggregator.js +243 -0
- package/dist/src/metrics/MetricsAggregator.js.map +1 -0
- package/dist/src/metrics/SlaMonitor.d.ts +48 -0
- package/dist/src/metrics/SlaMonitor.js +130 -0
- package/dist/src/metrics/SlaMonitor.js.map +1 -0
- package/dist/src/metrics/index.d.ts +75 -0
- package/dist/src/metrics/index.js +293 -0
- package/dist/src/metrics/index.js.map +1 -0
- package/dist/src/model/Instance.d.ts +38 -0
- package/dist/src/model/Instance.js +12 -0
- package/dist/src/model/Instance.js.map +1 -0
- package/dist/src/model/RetryPolicy.d.ts +11 -0
- package/dist/src/model/RetryPolicy.js +30 -0
- package/dist/src/model/RetryPolicy.js.map +1 -0
- package/dist/src/model/Schedule.d.ts +34 -0
- package/dist/src/model/Schedule.js +50 -0
- package/dist/src/model/Schedule.js.map +1 -0
- package/dist/src/model/Workflow.d.ts +73 -0
- package/dist/src/model/Workflow.js +2 -0
- package/dist/src/model/Workflow.js.map +1 -0
- package/dist/src/model/WorkflowGraph.d.ts +32 -0
- package/dist/src/model/WorkflowGraph.js +267 -0
- package/dist/src/model/WorkflowGraph.js.map +1 -0
- package/dist/src/model/WorkflowSchema.d.ts +154 -0
- package/dist/src/model/WorkflowSchema.js +233 -0
- package/dist/src/model/WorkflowSchema.js.map +1 -0
- package/dist/src/model/WorkflowVariables.d.ts +15 -0
- package/dist/src/model/WorkflowVariables.js +77 -0
- package/dist/src/model/WorkflowVariables.js.map +1 -0
- package/dist/src/notification/NotificationChannel.d.ts +19 -0
- package/dist/src/notification/NotificationChannel.js +2 -0
- package/dist/src/notification/NotificationChannel.js.map +1 -0
- package/dist/src/notification/NotificationManager.d.ts +20 -0
- package/dist/src/notification/NotificationManager.js +59 -0
- package/dist/src/notification/NotificationManager.js.map +1 -0
- package/dist/src/notification/channels/DingtalkChannel.d.ts +7 -0
- package/dist/src/notification/channels/DingtalkChannel.js +18 -0
- package/dist/src/notification/channels/DingtalkChannel.js.map +1 -0
- package/dist/src/notification/channels/EmailChannel.d.ts +21 -0
- package/dist/src/notification/channels/EmailChannel.js +32 -0
- package/dist/src/notification/channels/EmailChannel.js.map +1 -0
- package/dist/src/notification/channels/FeishuChannel.d.ts +7 -0
- package/dist/src/notification/channels/FeishuChannel.js +18 -0
- package/dist/src/notification/channels/FeishuChannel.js.map +1 -0
- package/dist/src/notification/channels/SlackChannel.d.ts +7 -0
- package/dist/src/notification/channels/SlackChannel.js +18 -0
- package/dist/src/notification/channels/SlackChannel.js.map +1 -0
- package/dist/src/notification/channels/SmsChannel.d.ts +24 -0
- package/dist/src/notification/channels/SmsChannel.js +37 -0
- package/dist/src/notification/channels/SmsChannel.js.map +1 -0
- package/dist/src/notification/channels/WebhookChannel.d.ts +17 -0
- package/dist/src/notification/channels/WebhookChannel.js +61 -0
- package/dist/src/notification/channels/WebhookChannel.js.map +1 -0
- package/dist/src/notification/index.d.ts +24 -0
- package/dist/src/notification/index.js +61 -0
- package/dist/src/notification/index.js.map +1 -0
- package/dist/src/scheduler/CronScheduler.d.ts +20 -0
- package/dist/src/scheduler/CronScheduler.js +82 -0
- package/dist/src/scheduler/CronScheduler.js.map +1 -0
- package/dist/src/scheduler/EnhancedCronScheduler.d.ts +27 -0
- package/dist/src/scheduler/EnhancedCronScheduler.js +177 -0
- package/dist/src/scheduler/EnhancedCronScheduler.js.map +1 -0
- package/dist/src/storage/ArchiveManager.d.ts +21 -0
- package/dist/src/storage/ArchiveManager.js +140 -0
- package/dist/src/storage/ArchiveManager.js.map +1 -0
- package/dist/src/storage/LocalFileStorage.d.ts +64 -0
- package/dist/src/storage/LocalFileStorage.js +470 -0
- package/dist/src/storage/LocalFileStorage.js.map +1 -0
- package/dist/src/storage/MemoryStorage.d.ts +65 -0
- package/dist/src/storage/MemoryStorage.js +422 -0
- package/dist/src/storage/MemoryStorage.js.map +1 -0
- package/dist/src/storage/StorageProvider.d.ts +223 -0
- package/dist/src/storage/StorageProvider.js +2 -0
- package/dist/src/storage/StorageProvider.js.map +1 -0
- package/dist/src/storage/builtin-adapters.d.ts +1 -0
- package/dist/src/storage/builtin-adapters.js +20 -0
- package/dist/src/storage/builtin-adapters.js.map +1 -0
- package/dist/src/storage/index.d.ts +17 -0
- package/dist/src/storage/index.js +52 -0
- package/dist/src/storage/index.js.map +1 -0
- package/dist/src/storage/registry.d.ts +6 -0
- package/dist/src/storage/registry.js +23 -0
- package/dist/src/storage/registry.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +53 -0
- package/dist/src/telemetry/index.js +73 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/telemetry/spanRegistry.d.ts +9 -0
- package/dist/src/telemetry/spanRegistry.js +14 -0
- package/dist/src/telemetry/spanRegistry.js.map +1 -0
- package/dist/src/templates/AutoExtract.d.ts +2 -0
- package/dist/src/templates/AutoExtract.js +124 -0
- package/dist/src/templates/AutoExtract.js.map +1 -0
- package/dist/src/templates/TemplateGallery.d.ts +54 -0
- package/dist/src/templates/TemplateGallery.js +139 -0
- package/dist/src/templates/TemplateGallery.js.map +1 -0
- package/dist/src/templates/TemplateRegistry.d.ts +16 -0
- package/dist/src/templates/TemplateRegistry.js +92 -0
- package/dist/src/templates/TemplateRegistry.js.map +1 -0
- package/dist/src/templates/WorkflowTemplate.d.ts +24 -0
- package/dist/src/templates/WorkflowTemplate.js +2 -0
- package/dist/src/templates/WorkflowTemplate.js.map +1 -0
- package/dist/src/templates/builtin/HttpCallbackTemplate.d.ts +2 -0
- package/dist/src/templates/builtin/HttpCallbackTemplate.js +47 -0
- package/dist/src/templates/builtin/HttpCallbackTemplate.js.map +1 -0
- package/dist/src/templates/builtin/index.d.ts +3 -0
- package/dist/src/templates/builtin/index.js +11 -0
- package/dist/src/templates/builtin/index.js.map +1 -0
- package/dist/src/templates/index.d.ts +3 -0
- package/dist/src/templates/index.js +3 -0
- package/dist/src/templates/index.js.map +1 -0
- package/dist/src/testing/MutationTester.d.ts +27 -0
- package/dist/src/testing/MutationTester.js +157 -0
- package/dist/src/testing/MutationTester.js.map +1 -0
- package/dist/src/testing/TestGenerator.d.ts +31 -0
- package/dist/src/testing/TestGenerator.js +345 -0
- package/dist/src/testing/TestGenerator.js.map +1 -0
- package/dist/src/testing/index.d.ts +2 -0
- package/dist/src/testing/index.js +3 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/testWorkflow.d.ts +51 -0
- package/dist/src/testing/testWorkflow.js +167 -0
- package/dist/src/testing/testWorkflow.js.map +1 -0
- package/dist/src/utils/AuditLogger.d.ts +36 -0
- package/dist/src/utils/AuditLogger.js +148 -0
- package/dist/src/utils/AuditLogger.js.map +1 -0
- package/dist/src/utils/BoundedMap.d.ts +34 -0
- package/dist/src/utils/BoundedMap.js +125 -0
- package/dist/src/utils/BoundedMap.js.map +1 -0
- package/dist/src/utils/LeaseStore.d.ts +7 -0
- package/dist/src/utils/LeaseStore.js +102 -0
- package/dist/src/utils/LeaseStore.js.map +1 -0
- package/dist/src/utils/Logger.d.ts +26 -0
- package/dist/src/utils/Logger.js +279 -0
- package/dist/src/utils/Logger.js.map +1 -0
- package/dist/src/utils/SecretManager.d.ts +41 -0
- package/dist/src/utils/SecretManager.js +139 -0
- package/dist/src/utils/SecretManager.js.map +1 -0
- package/dist/src/utils/StructuredLogger.d.ts +45 -0
- package/dist/src/utils/StructuredLogger.js +118 -0
- package/dist/src/utils/StructuredLogger.js.map +1 -0
- package/dist/src/utils/concurrency.d.ts +3 -0
- package/dist/src/utils/concurrency.js +22 -0
- package/dist/src/utils/concurrency.js.map +1 -0
- package/dist/src/utils/env.d.ts +5 -0
- package/dist/src/utils/env.js +15 -0
- package/dist/src/utils/env.js.map +1 -0
- package/dist/src/utils/index.d.ts +5 -0
- package/dist/src/utils/index.js +4 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/secrets.d.ts +5 -0
- package/dist/src/utils/secrets.js +27 -0
- package/dist/src/utils/secrets.js.map +1 -0
- package/package.json +159 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Logger } from "../../utils/Logger.js";
|
|
2
|
+
export async function execute(config, instance) {
|
|
3
|
+
if (!config?.waitFor ||
|
|
4
|
+
!Array.isArray(config.waitFor) ||
|
|
5
|
+
config.waitFor.length === 0) {
|
|
6
|
+
throw new Error("Join node requires a non-empty config.waitFor array");
|
|
7
|
+
}
|
|
8
|
+
const mode = config.mode ?? "all";
|
|
9
|
+
const nodes = instance.state?.nodes ?? {};
|
|
10
|
+
const results = {};
|
|
11
|
+
const missing = [];
|
|
12
|
+
for (const nodeId of config.waitFor) {
|
|
13
|
+
const nodeState = nodes[nodeId];
|
|
14
|
+
if (nodeState && nodeState.output !== undefined) {
|
|
15
|
+
results[nodeId] = nodeState.output;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
missing.push(nodeId);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (mode === "all" && missing.length > 0) {
|
|
22
|
+
const message = `Join node is missing output from: ${missing.join(", ")} (waitFor=[${config.waitFor.join(", ")}])`;
|
|
23
|
+
Logger.error(instance.instanceId, "join-node", message);
|
|
24
|
+
throw new Error(message);
|
|
25
|
+
}
|
|
26
|
+
if (mode === "any" && Object.keys(results).length === 0) {
|
|
27
|
+
const message = `Join node (mode=any) found no completed branches among: ${config.waitFor.join(", ")}`;
|
|
28
|
+
Logger.error(instance.instanceId, "join-node", message);
|
|
29
|
+
throw new Error(message);
|
|
30
|
+
}
|
|
31
|
+
Logger.log(instance.instanceId, "join-node", `Join resolved (mode=${mode}): ${Object.keys(results).length}/${config.waitFor.length} branches`, { resolved: Object.keys(results), missing });
|
|
32
|
+
return { results, missing };
|
|
33
|
+
}
|
|
34
|
+
export const JoinNodeExecutor = {
|
|
35
|
+
execute,
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=JoinNodeExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JoinNodeExecutor.js","sourceRoot":"","sources":["../../../../src/engine/executors/JoinNodeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AA4C5C,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,MAAsB,EACtB,QAA0B;IAE1B,IACE,CAAC,MAAM,EAAE,OAAO;QAChB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAC9B,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAC3B,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC;IAClC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC;IAE1C,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChD,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,IAAI,IAAI,KAAK,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,qCAAqC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QACnH,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,IAAI,KAAK,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxD,MAAM,OAAO,GAAG,2DAA2D,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACvG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,GAAG,CACR,QAAQ,CAAC,UAAU,EACnB,WAAW,EACX,uBAAuB,IAAI,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,WAAW,EAChG,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAC5C,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO;CACR,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { WorkflowInstance } from "../../model/Instance.js";
|
|
2
|
+
export interface LoopNodeConfig {
|
|
3
|
+
collection: string;
|
|
4
|
+
itemVariable: string;
|
|
5
|
+
indexVariable?: string;
|
|
6
|
+
body: string;
|
|
7
|
+
parallel?: boolean;
|
|
8
|
+
maxConcurrency?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface LoopNodeOutput {
|
|
11
|
+
iterations: number;
|
|
12
|
+
results: any[];
|
|
13
|
+
duration: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function getBodyNode(config: LoopNodeConfig): string;
|
|
16
|
+
export declare function execute(config: LoopNodeConfig, instance: WorkflowInstance, executeBody: (itemContext: Record<string, any>, index: number) => Promise<any>): Promise<LoopNodeOutput>;
|
|
17
|
+
export declare const LoopNodeExecutor: {
|
|
18
|
+
execute: typeof execute;
|
|
19
|
+
getBodyNode: typeof getBodyNode;
|
|
20
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { parseEnvInt } from "../../utils/env.js";
|
|
2
|
+
import { Logger } from "../../utils/Logger.js";
|
|
3
|
+
import { getConcurrencyControl } from "../ConcurrencyControl.js";
|
|
4
|
+
import { evaluate, interpolateObject } from "../ExpressionEvaluator.js";
|
|
5
|
+
function getMaxLoopIterations() {
|
|
6
|
+
return parseEnvInt(process.env.MAX_LOOP_ITERATIONS, 10_000, { min: 1 });
|
|
7
|
+
}
|
|
8
|
+
function evaluateCollection(collectionExpr, instance) {
|
|
9
|
+
const evaluationContext = {
|
|
10
|
+
...instance.context,
|
|
11
|
+
context: instance.context || {},
|
|
12
|
+
state: instance.state || {},
|
|
13
|
+
};
|
|
14
|
+
if (instance.state?.nodes) {
|
|
15
|
+
for (const [nodeId, nodeState] of Object.entries(instance.state.nodes)) {
|
|
16
|
+
if (nodeState.output !== undefined) {
|
|
17
|
+
evaluationContext[nodeId] = nodeState.output;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const result = evaluate(collectionExpr, evaluationContext);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
Logger.error(instance.instanceId, "loop-node", `Error evaluating collection expression: ${collectionExpr}`, error?.stack);
|
|
27
|
+
throw new Error(`Invalid collection expression: ${error.message}`, {
|
|
28
|
+
cause: error,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function executeSequential(collection, config, instance, executeBody) {
|
|
33
|
+
const results = [];
|
|
34
|
+
for (let i = 0; i < collection.length; i++) {
|
|
35
|
+
const item = collection[i];
|
|
36
|
+
Logger.log(instance.instanceId, "loop-node", `Executing iteration ${i + 1}/${collection.length}`);
|
|
37
|
+
const itemContext = {
|
|
38
|
+
[config.itemVariable]: item,
|
|
39
|
+
};
|
|
40
|
+
if (config.indexVariable) {
|
|
41
|
+
itemContext[config.indexVariable] = i;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const result = await executeBody(itemContext, i);
|
|
45
|
+
results.push(result);
|
|
46
|
+
Logger.log(instance.instanceId, "loop-node", `Iteration ${i + 1}/${collection.length} completed`);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
Logger.error(instance.instanceId, "loop-node", `Iteration ${i + 1}/${collection.length} failed: ${error.message}`, error?.stack);
|
|
50
|
+
throw new Error(`Loop iteration ${i} failed: ${error.message}`, {
|
|
51
|
+
cause: error,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return results;
|
|
56
|
+
}
|
|
57
|
+
async function executeParallel(collection, config, instance, executeBody) {
|
|
58
|
+
const configuredConcurrency = config.maxConcurrency ??
|
|
59
|
+
getConcurrencyControl().getConfig().maxConcurrentNodesPerInstance;
|
|
60
|
+
const maxConcurrency = Number.isFinite(configuredConcurrency) && configuredConcurrency >= 1
|
|
61
|
+
? Math.trunc(configuredConcurrency)
|
|
62
|
+
: collection.length;
|
|
63
|
+
Logger.log(instance.instanceId, "loop-node", `Executing ${collection.length} iterations in parallel (max concurrency: ${maxConcurrency})`);
|
|
64
|
+
if (maxConcurrency >= collection.length) {
|
|
65
|
+
const promises = collection.map(async (item, i) => {
|
|
66
|
+
const itemContext = {
|
|
67
|
+
[config.itemVariable]: item,
|
|
68
|
+
};
|
|
69
|
+
if (config.indexVariable) {
|
|
70
|
+
itemContext[config.indexVariable] = i;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const result = await executeBody(itemContext, i);
|
|
74
|
+
Logger.log(instance.instanceId, "loop-node", `Parallel iteration ${i + 1}/${collection.length} completed`);
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
Logger.error(instance.instanceId, "loop-node", `Parallel iteration ${i + 1}/${collection.length} failed: ${error.message}`, error?.stack);
|
|
79
|
+
throw new Error(`Loop iteration ${i} failed: ${error.message}`, {
|
|
80
|
+
cause: error,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return await Promise.all(promises);
|
|
85
|
+
}
|
|
86
|
+
const results = Array.from({ length: collection.length });
|
|
87
|
+
const executing = new Set();
|
|
88
|
+
let firstError;
|
|
89
|
+
for (let index = 0; index < collection.length; index++) {
|
|
90
|
+
if (firstError)
|
|
91
|
+
break;
|
|
92
|
+
const itemContext = {
|
|
93
|
+
[config.itemVariable]: collection[index],
|
|
94
|
+
};
|
|
95
|
+
if (config.indexVariable) {
|
|
96
|
+
itemContext[config.indexVariable] = index;
|
|
97
|
+
}
|
|
98
|
+
const promise = executeBody(itemContext, index)
|
|
99
|
+
.then((result) => {
|
|
100
|
+
results[index] = result;
|
|
101
|
+
Logger.log(instance.instanceId, "loop-node", `Parallel iteration ${index + 1}/${collection.length} completed`);
|
|
102
|
+
})
|
|
103
|
+
.catch((error) => {
|
|
104
|
+
Logger.error(instance.instanceId, "loop-node", `Parallel iteration ${index + 1}/${collection.length} failed: ${error.message}`, error?.stack);
|
|
105
|
+
firstError ??= new Error(`Loop iteration ${index} failed: ${error.message}`, { cause: error });
|
|
106
|
+
})
|
|
107
|
+
.finally(() => {
|
|
108
|
+
executing.delete(promise);
|
|
109
|
+
});
|
|
110
|
+
executing.add(promise);
|
|
111
|
+
if (executing.size >= maxConcurrency) {
|
|
112
|
+
await Promise.race(executing);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
await Promise.all(executing);
|
|
116
|
+
if (firstError)
|
|
117
|
+
throw firstError;
|
|
118
|
+
return results;
|
|
119
|
+
}
|
|
120
|
+
export function getBodyNode(config) {
|
|
121
|
+
return config.body;
|
|
122
|
+
}
|
|
123
|
+
export async function execute(config, instance, executeBody) {
|
|
124
|
+
const startTime = Date.now();
|
|
125
|
+
const context = {
|
|
126
|
+
context: instance.context || {},
|
|
127
|
+
state: instance.state || {},
|
|
128
|
+
};
|
|
129
|
+
const evaluatedConfig = interpolateObject(config, context, instance.state);
|
|
130
|
+
Logger.log(instance.instanceId, "loop-node", `Evaluating collection expression: ${evaluatedConfig.collection}`);
|
|
131
|
+
try {
|
|
132
|
+
const collection = evaluateCollection(evaluatedConfig.collection, instance);
|
|
133
|
+
if (!Array.isArray(collection)) {
|
|
134
|
+
throw new Error(`Collection expression must return an array, got ${typeof collection} ` +
|
|
135
|
+
`(expression: ${evaluatedConfig.collection})`);
|
|
136
|
+
}
|
|
137
|
+
const maxIterations = getMaxLoopIterations();
|
|
138
|
+
if (collection.length > maxIterations) {
|
|
139
|
+
throw new Error(`Loop iteration count ${collection.length} exceeds the limit of ${maxIterations}`);
|
|
140
|
+
}
|
|
141
|
+
Logger.log(instance.instanceId, "loop-node", `Starting loop with ${collection.length} iterations (mode: ${evaluatedConfig.parallel ? "parallel" : "sequential"})`);
|
|
142
|
+
const results = evaluatedConfig.parallel
|
|
143
|
+
? await executeParallel(collection, evaluatedConfig, instance, executeBody)
|
|
144
|
+
: await executeSequential(collection, evaluatedConfig, instance, executeBody);
|
|
145
|
+
const duration = Date.now() - startTime;
|
|
146
|
+
Logger.log(instance.instanceId, "loop-node", `Loop completed: ${collection.length} iterations in ${duration}ms`);
|
|
147
|
+
return {
|
|
148
|
+
iterations: collection.length,
|
|
149
|
+
results,
|
|
150
|
+
duration,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
const duration = Date.now() - startTime;
|
|
155
|
+
Logger.error(instance.instanceId, "loop-node", `Loop execution failed after ${duration}ms: ${error.message}`, error?.stack);
|
|
156
|
+
throw new Error(`Loop execution failed: ${error.message}`, {
|
|
157
|
+
cause: error,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
export const LoopNodeExecutor = {
|
|
162
|
+
execute,
|
|
163
|
+
getBodyNode,
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=LoopNodeExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoopNodeExecutor.js","sourceRoot":"","sources":["../../../../src/engine/executors/LoopNodeExecutor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGrE,SAAS,oBAAoB;IAC3B,OAAO,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAC1E,CAAC;AAkCD,SAAS,kBAAkB,CACzB,cAAsB,EACtB,QAA0B;IAG1B,MAAM,iBAAiB,GAAwB;QAE7C,GAAG,QAAQ,CAAC,OAAO;QAEnB,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,EAAE;QAE/B,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE;KAC5B,CAAC;IAGF,IAAI,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC;QAC1B,KAAK,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACvE,IAAI,SAA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,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,GAAG,CACrH,CAAC;QAGF,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ;YACtC,CAAC,CAAC,MAAM,eAAe,CACnB,UAAU,EACV,eAAe,EACf,QAAQ,EACR,WAAW,CACZ;YACH,CAAC,CAAC,MAAM,iBAAiB,CACrB,UAAU,EACV,eAAe,EACf,QAAQ,EACR,WAAW,CACZ,CAAC;QAEN,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAExC,MAAM,CAAC,GAAG,CACR,QAAQ,CAAC,UAAU,EACnB,WAAW,EACX,mBAAmB,UAAU,CAAC,MAAM,kBAAkB,QAAQ,IAAI,CACnE,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,UAAU,CAAC,MAAM;YAC7B,OAAO;YACP,QAAQ;SACT,CAAC;IACJ,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAExC,MAAM,CAAC,KAAK,CACV,QAAQ,CAAC,UAAU,EACnB,WAAW,EACX,+BAA+B,QAAQ,OAAO,KAAK,CAAC,OAAO,EAAE,EAC7D,KAAK,EAAE,KAAK,CACb,CAAC;QAEF,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,CAAC,OAAO,EAAE,EAAE;YACzD,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO;IACP,WAAW;CACZ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorkflowInstance } from "../../model/Instance.js";
|
|
2
|
+
import type { NotificationNodeConfig } from "../../model/Workflow.js";
|
|
3
|
+
import type { NotificationResult } from "../../notification/NotificationChannel.js";
|
|
4
|
+
import { type NotificationManager } from "../../notification/NotificationManager.js";
|
|
5
|
+
export declare function execute(config: NotificationNodeConfig, instance: WorkflowInstance, manager?: NotificationManager): Promise<NotificationResult>;
|
|
6
|
+
export declare const NotificationNodeExecutor: {
|
|
7
|
+
execute: typeof execute;
|
|
8
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { notificationManager, } from "../../notification/NotificationManager.js";
|
|
2
|
+
import { Logger } from "../../utils/Logger.js";
|
|
3
|
+
function buildTemplateContext(instance) {
|
|
4
|
+
return {
|
|
5
|
+
...instance.context,
|
|
6
|
+
context: instance.context ?? {},
|
|
7
|
+
state: instance.state ?? {},
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export async function execute(config, instance, manager = notificationManager) {
|
|
11
|
+
const templateContext = buildTemplateContext(instance);
|
|
12
|
+
const message = manager.renderMessage({
|
|
13
|
+
target: config.target,
|
|
14
|
+
subject: config.subject,
|
|
15
|
+
body: config.template,
|
|
16
|
+
severity: config.severity,
|
|
17
|
+
data: config.data,
|
|
18
|
+
}, templateContext, instance.state);
|
|
19
|
+
Logger.info(instance.instanceId, "notification", "Sending notification", {
|
|
20
|
+
channel: config.channel,
|
|
21
|
+
target: message.target,
|
|
22
|
+
severity: message.severity ?? "info",
|
|
23
|
+
});
|
|
24
|
+
const result = await manager.send(config.channel, message);
|
|
25
|
+
if (!result.ok) {
|
|
26
|
+
throw new Error(result.error ?? `Notification channel ${config.channel} send failed`);
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
export const NotificationNodeExecutor = {
|
|
31
|
+
execute,
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=NotificationNodeExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationNodeExecutor.js","sourceRoot":"","sources":["../../../../src/engine/executors/NotificationNodeExecutor.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,mBAAmB,GACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,MAAM,EAA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
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WorkflowInstance } from "../../model/Instance.js";
|
|
2
|
+
export interface QueueNodeConfig {
|
|
3
|
+
operation: "publish" | "consume";
|
|
4
|
+
queue: string;
|
|
5
|
+
message?: unknown;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface QueueNodeOutput {
|
|
9
|
+
messageId?: string;
|
|
10
|
+
message?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface QueueProvider {
|
|
13
|
+
publish(queue: string, message: unknown): Promise<string>;
|
|
14
|
+
consume(queue: string, timeout?: number): Promise<unknown>;
|
|
15
|
+
close?(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare function registerQueueProvider(name: string, provider: QueueProvider): void;
|
|
18
|
+
export declare function unregisterQueueProvider(name: string): void;
|
|
19
|
+
export declare function getQueueProvider(name: string): QueueProvider | undefined;
|
|
20
|
+
export declare function execute(config: QueueNodeConfig, instance: WorkflowInstance): Promise<QueueNodeOutput>;
|
|
21
|
+
export declare const QueueNodeExecutor: {
|
|
22
|
+
execute: typeof execute;
|
|
23
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { errorMessage, errorStack, Logger } from "../../utils/Logger.js";
|
|
2
|
+
import { interpolateObject } from "../ExpressionEvaluator.js";
|
|
3
|
+
const queueProviders = new Map();
|
|
4
|
+
export function registerQueueProvider(name, provider) {
|
|
5
|
+
queueProviders.set(name, provider);
|
|
6
|
+
Logger.info("queue-node", "provider-registered", `Queue provider registered: ${name}`);
|
|
7
|
+
}
|
|
8
|
+
export function unregisterQueueProvider(name) {
|
|
9
|
+
const provider = queueProviders.get(name);
|
|
10
|
+
if (provider?.close) {
|
|
11
|
+
provider.close().catch((error) => {
|
|
12
|
+
Logger.error("queue-node", "provider-close-error", `Error closing queue provider ${name}`, errorStack(error));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
queueProviders.delete(name);
|
|
16
|
+
Logger.info("queue-node", "provider-unregistered", `Queue provider unregistered: ${name}`);
|
|
17
|
+
}
|
|
18
|
+
export function getQueueProvider(name) {
|
|
19
|
+
return queueProviders.get(name);
|
|
20
|
+
}
|
|
21
|
+
async function withTimeout(work, ms, message) {
|
|
22
|
+
let timeoutId;
|
|
23
|
+
const timeout = new Promise((_, reject) => {
|
|
24
|
+
timeoutId = setTimeout(() => reject(new Error(message)), ms);
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
return await Promise.race([work, timeout]);
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
if (timeoutId)
|
|
31
|
+
clearTimeout(timeoutId);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function executePublish(provider, queue, message) {
|
|
35
|
+
return await provider.publish(queue, message);
|
|
36
|
+
}
|
|
37
|
+
async function executeConsume(provider, queue, timeout) {
|
|
38
|
+
if (!timeout) {
|
|
39
|
+
return await provider.consume(queue);
|
|
40
|
+
}
|
|
41
|
+
return await withTimeout(provider.consume(queue, timeout), timeout, `Queue consume timeout after ${timeout}ms`);
|
|
42
|
+
}
|
|
43
|
+
export async function execute(config, instance) {
|
|
44
|
+
const startTime = Date.now();
|
|
45
|
+
const context = {
|
|
46
|
+
context: instance.context || {},
|
|
47
|
+
state: instance.state || {},
|
|
48
|
+
};
|
|
49
|
+
const evaluatedConfig = interpolateObject(config, context, instance.state);
|
|
50
|
+
Logger.log(instance.instanceId, "queue-node", `Executing queue ${evaluatedConfig.operation} operation on queue: ${evaluatedConfig.queue}`);
|
|
51
|
+
try {
|
|
52
|
+
const provider = queueProviders.get("default");
|
|
53
|
+
if (!provider) {
|
|
54
|
+
throw new Error("Queue provider not found. " +
|
|
55
|
+
`Please register a queue provider using registerQueueProvider('default', provider).`);
|
|
56
|
+
}
|
|
57
|
+
let result;
|
|
58
|
+
if (evaluatedConfig.operation === "publish") {
|
|
59
|
+
if (evaluatedConfig.message === undefined) {
|
|
60
|
+
throw new Error("Queue publish operation requires a message");
|
|
61
|
+
}
|
|
62
|
+
const messageId = await executePublish(provider, evaluatedConfig.queue, evaluatedConfig.message);
|
|
63
|
+
result = { messageId };
|
|
64
|
+
const duration = Date.now() - startTime;
|
|
65
|
+
Logger.log(instance.instanceId, "queue-node", `Message published to queue ${evaluatedConfig.queue}: ${messageId} in ${duration}ms`);
|
|
66
|
+
}
|
|
67
|
+
else if (evaluatedConfig.operation === "consume") {
|
|
68
|
+
const message = await executeConsume(provider, evaluatedConfig.queue, evaluatedConfig.timeout);
|
|
69
|
+
result = { message };
|
|
70
|
+
const duration = Date.now() - startTime;
|
|
71
|
+
Logger.log(instance.instanceId, "queue-node", `Message consumed from queue ${evaluatedConfig.queue} in ${duration}ms`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
throw new Error(`Invalid queue operation: ${evaluatedConfig.operation}. Must be 'publish' or 'consume'.`);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const duration = Date.now() - startTime;
|
|
80
|
+
Logger.error(instance.instanceId, "queue-node", `Queue ${config.operation} operation failed after ${duration}ms: ${errorMessage(error)}`, errorStack(error));
|
|
81
|
+
throw new Error(`Queue ${config.operation} operation failed: ${errorMessage(error)}`, { cause: error });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export const QueueNodeExecutor = {
|
|
85
|
+
execute,
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=QueueNodeExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueNodeExecutor.js","sourceRoot":"","sources":["../../../../src/engine/executors/QueueNodeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAkC3D,MAAM,cAAc,GAAG,IAAI,GAAG,EAAyB,CAAC;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AG,EAAE,GAAG,SAAS,CAAC;QAExC,MAAM,CAAC,KAAK,CACV,QAAQ,CAAC,UAAU,EACnB,YAAY,EACZ,SAAS,MAAM,CAAC,SAAS,2BAA2B,QAAQ,OAAO,YAAY,CAAC,KAAK,CAAC,EAAE,EACxF,UAAU,CAAC,KAAK,CAAC,CAClB,CAAC;QAEF,MAAM,IAAI,KAAK,CACb,SAAS,MAAM,CAAC,SAAS,sBAAsB,YAAY,CAAC,KAAK,CAAC,EAAE,EACpE,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO;CACR,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { WorkflowInstance } from "../../model/Instance.js";
|
|
2
|
+
export interface RouterRoute {
|
|
3
|
+
condition: string;
|
|
4
|
+
target: string;
|
|
5
|
+
priority?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface RouterNodeConfig {
|
|
8
|
+
routes: RouterRoute[];
|
|
9
|
+
defaultTarget?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RouterNodeOutput {
|
|
12
|
+
matchedRoute: number;
|
|
13
|
+
target: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function getNextNode(output: RouterNodeOutput): string;
|
|
16
|
+
export declare function execute(config: RouterNodeConfig, instance: WorkflowInstance): Promise<RouterNodeOutput>;
|
|
17
|
+
export declare const RouterNodeExecutor: {
|
|
18
|
+
execute: typeof execute;
|
|
19
|
+
getNextNode: typeof getNextNode;
|
|
20
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { errorMessage, errorStack, Logger } from "../../utils/Logger.js";
|
|
2
|
+
import { evaluate, interpolateObject } from "../ExpressionEvaluator.js";
|
|
3
|
+
function evaluateCondition(condition, instance) {
|
|
4
|
+
const evaluationContext = {
|
|
5
|
+
...instance.context,
|
|
6
|
+
context: instance.context || {},
|
|
7
|
+
state: instance.state || {},
|
|
8
|
+
};
|
|
9
|
+
if (instance.state?.nodes) {
|
|
10
|
+
for (const [nodeId, nodeState] of Object.entries(instance.state.nodes)) {
|
|
11
|
+
if (nodeState.output !== undefined) {
|
|
12
|
+
evaluationContext[nodeId] = nodeState.output;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const result = evaluate(condition, evaluationContext);
|
|
18
|
+
return Boolean(result);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
Logger.error(instance.instanceId, "router-node", `Error evaluating condition expression: ${condition}`, errorStack(error));
|
|
22
|
+
throw new Error(`Invalid condition expression: ${errorMessage(error)}`, {
|
|
23
|
+
cause: error,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function getNextNode(output) {
|
|
28
|
+
return output.target;
|
|
29
|
+
}
|
|
30
|
+
export async function execute(config, instance) {
|
|
31
|
+
const startTime = Date.now();
|
|
32
|
+
const context = {
|
|
33
|
+
context: instance.context || {},
|
|
34
|
+
state: instance.state || {},
|
|
35
|
+
};
|
|
36
|
+
const evaluatedConfig = interpolateObject(config, context, instance.state);
|
|
37
|
+
Logger.log(instance.instanceId, "router-node", `Evaluating ${evaluatedConfig.routes.length} routes`);
|
|
38
|
+
try {
|
|
39
|
+
const sortedRoutes = [...evaluatedConfig.routes].sort((a, b) => {
|
|
40
|
+
const priorityA = a.priority ?? Number.MAX_SAFE_INTEGER;
|
|
41
|
+
const priorityB = b.priority ?? Number.MAX_SAFE_INTEGER;
|
|
42
|
+
return priorityA - priorityB;
|
|
43
|
+
});
|
|
44
|
+
for (let i = 0; i < sortedRoutes.length; i++) {
|
|
45
|
+
const route = sortedRoutes[i];
|
|
46
|
+
const originalIndex = evaluatedConfig.routes.indexOf(route);
|
|
47
|
+
Logger.log(instance.instanceId, "router-node", `Evaluating route ${i} (priority ${route.priority ?? "default"}): ${route.condition}`);
|
|
48
|
+
const conditionResult = evaluateCondition(route.condition, instance);
|
|
49
|
+
if (conditionResult) {
|
|
50
|
+
const duration = Date.now() - startTime;
|
|
51
|
+
Logger.log(instance.instanceId, "router-node", `Route ${originalIndex} matched, routing to ${route.target} in ${duration}ms`);
|
|
52
|
+
return {
|
|
53
|
+
matchedRoute: originalIndex,
|
|
54
|
+
target: route.target,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (evaluatedConfig.defaultTarget) {
|
|
59
|
+
const duration = Date.now() - startTime;
|
|
60
|
+
Logger.log(instance.instanceId, "router-node", `No routes matched, using default target ${evaluatedConfig.defaultTarget} in ${duration}ms`);
|
|
61
|
+
return {
|
|
62
|
+
matchedRoute: -1,
|
|
63
|
+
target: evaluatedConfig.defaultTarget,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const duration = Date.now() - startTime;
|
|
67
|
+
Logger.error(instance.instanceId, "router-node", `No routes matched and no default target configured after ${duration}ms`);
|
|
68
|
+
throw new Error("No routes matched and no default target configured");
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
const duration = Date.now() - startTime;
|
|
72
|
+
Logger.error(instance.instanceId, "router-node", `Router evaluation failed after ${duration}ms: ${errorMessage(error)}`, errorStack(error));
|
|
73
|
+
throw new Error(`Router evaluation failed: ${errorMessage(error)}`, {
|
|
74
|
+
cause: error,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export const RouterNodeExecutor = {
|
|
79
|
+
execute,
|
|
80
|
+
getNextNode,
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=RouterNodeExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouterNodeExecutor.js","sourceRoot":"","sources":["../../../../src/engine/executors/RouterNodeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;A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AK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO;IACP,WAAW;CACZ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WorkflowInstance } from "../../model/Instance.js";
|
|
2
|
+
export interface SqlNodeConfig {
|
|
3
|
+
connection: string;
|
|
4
|
+
query: string;
|
|
5
|
+
parameters?: unknown[];
|
|
6
|
+
timeout?: number;
|
|
7
|
+
database?: "postgres" | "mysql" | "sqlite" | "mssql" | "generic";
|
|
8
|
+
}
|
|
9
|
+
export interface SqlNodeOutput {
|
|
10
|
+
rows: unknown[];
|
|
11
|
+
rowCount: number;
|
|
12
|
+
duration: number;
|
|
13
|
+
}
|
|
14
|
+
export interface SqlConnectionPool {
|
|
15
|
+
query(sql: string, params?: unknown[]): Promise<{
|
|
16
|
+
rows: unknown[];
|
|
17
|
+
rowCount: number;
|
|
18
|
+
}>;
|
|
19
|
+
close?(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare function registerSqlConnectionPool(name: string, pool: SqlConnectionPool): void;
|
|
22
|
+
export declare function unregisterSqlConnectionPool(name: string): void;
|
|
23
|
+
export declare function getSqlConnectionPool(name: string): SqlConnectionPool | undefined;
|
|
24
|
+
export declare function execute(config: SqlNodeConfig, instance: WorkflowInstance): Promise<SqlNodeOutput>;
|
|
25
|
+
export declare const SqlNodeExecutor: {
|
|
26
|
+
execute: typeof execute;
|
|
27
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { errorMessage, errorStack, Logger } from "../../utils/Logger.js";
|
|
2
|
+
import { interpolateObject } from "../ExpressionEvaluator.js";
|
|
3
|
+
const connectionPools = new Map();
|
|
4
|
+
export function registerSqlConnectionPool(name, pool) {
|
|
5
|
+
connectionPools.set(name, pool);
|
|
6
|
+
Logger.info("sql-node", "pool-registered", `SQL connection pool registered: ${name}`);
|
|
7
|
+
}
|
|
8
|
+
export function unregisterSqlConnectionPool(name) {
|
|
9
|
+
const pool = connectionPools.get(name);
|
|
10
|
+
if (pool?.close) {
|
|
11
|
+
pool.close().catch((error) => {
|
|
12
|
+
Logger.error("sql-node", "pool-close-error", `Error closing connection pool ${name}`, errorStack(error));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
connectionPools.delete(name);
|
|
16
|
+
Logger.info("sql-node", "pool-unregistered", `SQL connection pool unregistered: ${name}`);
|
|
17
|
+
}
|
|
18
|
+
export function getSqlConnectionPool(name) {
|
|
19
|
+
return connectionPools.get(name);
|
|
20
|
+
}
|
|
21
|
+
async function withTimeout(work, ms, message) {
|
|
22
|
+
let timeoutId;
|
|
23
|
+
const timeout = new Promise((_, reject) => {
|
|
24
|
+
timeoutId = setTimeout(() => reject(new Error(message)), ms);
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
return await Promise.race([work, timeout]);
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
if (timeoutId)
|
|
31
|
+
clearTimeout(timeoutId);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function executeWithTimeout(pool, query, parameters, timeout) {
|
|
35
|
+
if (!timeout) {
|
|
36
|
+
return await pool.query(query, parameters);
|
|
37
|
+
}
|
|
38
|
+
return await withTimeout(pool.query(query, parameters), timeout, `SQL query timeout after ${timeout}ms`);
|
|
39
|
+
}
|
|
40
|
+
export async function execute(config, instance) {
|
|
41
|
+
const startTime = Date.now();
|
|
42
|
+
const context = {
|
|
43
|
+
context: instance.context || {},
|
|
44
|
+
state: instance.state || {},
|
|
45
|
+
};
|
|
46
|
+
const evaluatedConfig = interpolateObject(config, context, instance.state);
|
|
47
|
+
Logger.log(instance.instanceId, "sql-node", `Executing SQL query on connection: ${evaluatedConfig.connection}`);
|
|
48
|
+
try {
|
|
49
|
+
const pool = connectionPools.get(evaluatedConfig.connection);
|
|
50
|
+
if (!pool) {
|
|
51
|
+
throw new Error(`SQL connection pool not found: ${evaluatedConfig.connection}. ` +
|
|
52
|
+
"Please register the connection pool using registerSqlConnectionPool().");
|
|
53
|
+
}
|
|
54
|
+
const result = await executeWithTimeout(pool, evaluatedConfig.query, evaluatedConfig.parameters, evaluatedConfig.timeout);
|
|
55
|
+
const duration = Date.now() - startTime;
|
|
56
|
+
Logger.log(instance.instanceId, "sql-node", `SQL query completed: ${result.rowCount} rows affected/returned in ${duration}ms`);
|
|
57
|
+
return {
|
|
58
|
+
rows: result.rows,
|
|
59
|
+
rowCount: result.rowCount,
|
|
60
|
+
duration,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
const duration = Date.now() - startTime;
|
|
65
|
+
Logger.error(instance.instanceId, "sql-node", `SQL query failed after ${duration}ms: ${errorMessage(error)}`, errorStack(error));
|
|
66
|
+
throw new Error(`SQL query failed: ${errorMessage(error)}`, {
|
|
67
|
+
cause: error,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export const SqlNodeExecutor = {
|
|
72
|
+
execute,
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=SqlNodeExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlNodeExecutor.js","sourceRoot":"","sources":["../../../../src/engine/executors/SqlNodeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAsC3D,MAAM,eAAe,GAAG,IAAI,GAAG,EAA6B,CAAC;AAO7D,MAAM,UAAU,yBAAyB,CACvC,IAAY,EACZ,IAAuB;IAEvB,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChC,MAAM,CAAC,IAAI,CACT,UAAU,EACV,iBAAiB,EACjB,mCAAmC,IAAI,EAAE,CAC1C,CAAC;AACJ,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AAM,CAAC,QAAQ,8BAA8B,QAAQ,IAAI,CAClF,CAAC;QAEF,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ;SACT,CAAC;IACJ,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAExC,MAAM,CAAC,KAAK,CACV,QAAQ,CAAC,UAAU,EACnB,UAAU,EACV,0BAA0B,QAAQ,OAAO,YAAY,CAAC,KAAK,CAAC,EAAE,EAC9D,UAAU,CAAC,KAAK,CAAC,CAClB,CAAC;QAEF,MAAM,IAAI,KAAK,CAAC,qBAAqB,YAAY,CAAC,KAAK,CAAC,EAAE,EAAE;YAC1D,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO;CACR,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WorkflowInstance } from "../../model/Instance.js";
|
|
2
|
+
export interface TransformNodeConfig {
|
|
3
|
+
output: Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
export type TransformNodeOutput = Record<string, unknown>;
|
|
6
|
+
export declare function execute(config: TransformNodeConfig, instance: WorkflowInstance): Promise<TransformNodeOutput>;
|
|
7
|
+
export declare const TransformNodeExecutor: {
|
|
8
|
+
execute: typeof execute;
|
|
9
|
+
};
|