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.
Files changed (525) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +352 -0
  3. package/dist/src/api/ConsoleWebSocketManager.d.ts +57 -0
  4. package/dist/src/api/ConsoleWebSocketManager.js +206 -0
  5. package/dist/src/api/ConsoleWebSocketManager.js.map +1 -0
  6. package/dist/src/api/ErrorHandler.d.ts +52 -0
  7. package/dist/src/api/ErrorHandler.js +115 -0
  8. package/dist/src/api/ErrorHandler.js.map +1 -0
  9. package/dist/src/api/EventHistory.d.ts +73 -0
  10. package/dist/src/api/EventHistory.js +309 -0
  11. package/dist/src/api/EventHistory.js.map +1 -0
  12. package/dist/src/api/WebhookManager.d.ts +67 -0
  13. package/dist/src/api/WebhookManager.js +568 -0
  14. package/dist/src/api/WebhookManager.js.map +1 -0
  15. package/dist/src/api/docsPage.d.ts +1 -0
  16. package/dist/src/api/docsPage.js +321 -0
  17. package/dist/src/api/docsPage.js.map +1 -0
  18. package/dist/src/api/index.d.ts +8 -0
  19. package/dist/src/api/index.js +8 -0
  20. package/dist/src/api/index.js.map +1 -0
  21. package/dist/src/api/middleware/auth.d.ts +19 -0
  22. package/dist/src/api/middleware/auth.js +122 -0
  23. package/dist/src/api/middleware/auth.js.map +1 -0
  24. package/dist/src/api/middleware/index.d.ts +3 -0
  25. package/dist/src/api/middleware/index.js +3 -0
  26. package/dist/src/api/middleware/index.js.map +1 -0
  27. package/dist/src/api/middleware/rateLimit.d.ts +6 -0
  28. package/dist/src/api/middleware/rateLimit.js +69 -0
  29. package/dist/src/api/middleware/rateLimit.js.map +1 -0
  30. package/dist/src/api/middleware/rateLimitStore.d.ts +14 -0
  31. package/dist/src/api/middleware/rateLimitStore.js +44 -0
  32. package/dist/src/api/middleware/rateLimitStore.js.map +1 -0
  33. package/dist/src/api/middleware/rbac.d.ts +12 -0
  34. package/dist/src/api/middleware/rbac.js +120 -0
  35. package/dist/src/api/middleware/rbac.js.map +1 -0
  36. package/dist/src/api/openapi.d.ts +1917 -0
  37. package/dist/src/api/openapi.js +1758 -0
  38. package/dist/src/api/openapi.js.map +1 -0
  39. package/dist/src/api/playgroundPage.d.ts +1 -0
  40. package/dist/src/api/playgroundPage.js +765 -0
  41. package/dist/src/api/playgroundPage.js.map +1 -0
  42. package/dist/src/api/response.d.ts +22 -0
  43. package/dist/src/api/response.js +119 -0
  44. package/dist/src/api/response.js.map +1 -0
  45. package/dist/src/api/router.d.ts +17 -0
  46. package/dist/src/api/router.js +94 -0
  47. package/dist/src/api/router.js.map +1 -0
  48. package/dist/src/api/routes/analytics.d.ts +10 -0
  49. package/dist/src/api/routes/analytics.js +144 -0
  50. package/dist/src/api/routes/analytics.js.map +1 -0
  51. package/dist/src/api/routes/dlq.d.ts +3 -0
  52. package/dist/src/api/routes/dlq.js +248 -0
  53. package/dist/src/api/routes/dlq.js.map +1 -0
  54. package/dist/src/api/routes/eventHistory.d.ts +3 -0
  55. package/dist/src/api/routes/eventHistory.js +48 -0
  56. package/dist/src/api/routes/eventHistory.js.map +1 -0
  57. package/dist/src/api/routes/events.d.ts +3 -0
  58. package/dist/src/api/routes/events.js +205 -0
  59. package/dist/src/api/routes/events.js.map +1 -0
  60. package/dist/src/api/routes/functions.d.ts +3 -0
  61. package/dist/src/api/routes/functions.js +85 -0
  62. package/dist/src/api/routes/functions.js.map +1 -0
  63. package/dist/src/api/routes/instances.d.ts +3 -0
  64. package/dist/src/api/routes/instances.js +790 -0
  65. package/dist/src/api/routes/instances.js.map +1 -0
  66. package/dist/src/api/routes/templates.d.ts +3 -0
  67. package/dist/src/api/routes/templates.js +195 -0
  68. package/dist/src/api/routes/templates.js.map +1 -0
  69. package/dist/src/api/routes/webhooks.d.ts +3 -0
  70. package/dist/src/api/routes/webhooks.js +263 -0
  71. package/dist/src/api/routes/webhooks.js.map +1 -0
  72. package/dist/src/api/routes/workflows/analysis.d.ts +2 -0
  73. package/dist/src/api/routes/workflows/analysis.js +112 -0
  74. package/dist/src/api/routes/workflows/analysis.js.map +1 -0
  75. package/dist/src/api/routes/workflows/crud.d.ts +2 -0
  76. package/dist/src/api/routes/workflows/crud.js +140 -0
  77. package/dist/src/api/routes/workflows/crud.js.map +1 -0
  78. package/dist/src/api/routes/workflows/execution.d.ts +2 -0
  79. package/dist/src/api/routes/workflows/execution.js +204 -0
  80. package/dist/src/api/routes/workflows/execution.js.map +1 -0
  81. package/dist/src/api/routes/workflows/graph.d.ts +2 -0
  82. package/dist/src/api/routes/workflows/graph.js +51 -0
  83. package/dist/src/api/routes/workflows/graph.js.map +1 -0
  84. package/dist/src/api/routes/workflows/import.d.ts +2 -0
  85. package/dist/src/api/routes/workflows/import.js +238 -0
  86. package/dist/src/api/routes/workflows/import.js.map +1 -0
  87. package/dist/src/api/routes/workflows/index.d.ts +3 -0
  88. package/dist/src/api/routes/workflows/index.js +18 -0
  89. package/dist/src/api/routes/workflows/index.js.map +1 -0
  90. package/dist/src/api/routes/workflows/shared.d.ts +64 -0
  91. package/dist/src/api/routes/workflows/shared.js +304 -0
  92. package/dist/src/api/routes/workflows/shared.js.map +1 -0
  93. package/dist/src/api/routes/workflows/variables.d.ts +2 -0
  94. package/dist/src/api/routes/workflows/variables.js +34 -0
  95. package/dist/src/api/routes/workflows/variables.js.map +1 -0
  96. package/dist/src/api/routes/workflows/versioning.d.ts +2 -0
  97. package/dist/src/api/routes/workflows/versioning.js +235 -0
  98. package/dist/src/api/routes/workflows/versioning.js.map +1 -0
  99. package/dist/src/api/server.d.ts +13 -0
  100. package/dist/src/api/server.js +311 -0
  101. package/dist/src/api/server.js.map +1 -0
  102. package/dist/src/api/services/InstanceApplicationService.d.ts +74 -0
  103. package/dist/src/api/services/InstanceApplicationService.js +215 -0
  104. package/dist/src/api/services/InstanceApplicationService.js.map +1 -0
  105. package/dist/src/api/services/WorkflowApplicationService.d.ts +92 -0
  106. package/dist/src/api/services/WorkflowApplicationService.js +282 -0
  107. package/dist/src/api/services/WorkflowApplicationService.js.map +1 -0
  108. package/dist/src/api/services/index.d.ts +4 -0
  109. package/dist/src/api/services/index.js +3 -0
  110. package/dist/src/api/services/index.js.map +1 -0
  111. package/dist/src/api/types.d.ts +118 -0
  112. package/dist/src/api/types.js +2 -0
  113. package/dist/src/api/types.js.map +1 -0
  114. package/dist/src/api/utils/IdempotencyStore.d.ts +36 -0
  115. package/dist/src/api/utils/IdempotencyStore.js +121 -0
  116. package/dist/src/api/utils/IdempotencyStore.js.map +1 -0
  117. package/dist/src/api/utils/authConfig.d.ts +2 -0
  118. package/dist/src/api/utils/authConfig.js +25 -0
  119. package/dist/src/api/utils/authConfig.js.map +1 -0
  120. package/dist/src/api/utils/requestContext.d.ts +14 -0
  121. package/dist/src/api/utils/requestContext.js +31 -0
  122. package/dist/src/api/utils/requestContext.js.map +1 -0
  123. package/dist/src/api/utils/routeHelper.d.ts +25 -0
  124. package/dist/src/api/utils/routeHelper.js +30 -0
  125. package/dist/src/api/utils/routeHelper.js.map +1 -0
  126. package/dist/src/api/welcomePage.d.ts +1 -0
  127. package/dist/src/api/welcomePage.js +259 -0
  128. package/dist/src/api/welcomePage.js.map +1 -0
  129. package/dist/src/bootstrap.d.ts +20 -0
  130. package/dist/src/bootstrap.js +128 -0
  131. package/dist/src/bootstrap.js.map +1 -0
  132. package/dist/src/cli.d.ts +2 -0
  133. package/dist/src/cli.js +32 -0
  134. package/dist/src/cli.js.map +1 -0
  135. package/dist/src/config/AppConfig.d.ts +102 -0
  136. package/dist/src/config/AppConfig.js +452 -0
  137. package/dist/src/config/AppConfig.js.map +1 -0
  138. package/dist/src/config/redis.config.d.ts +6 -0
  139. package/dist/src/config/redis.config.js +9 -0
  140. package/dist/src/config/redis.config.js.map +1 -0
  141. package/dist/src/container.d.ts +29 -0
  142. package/dist/src/container.js +62 -0
  143. package/dist/src/container.js.map +1 -0
  144. package/dist/src/debug/BreakpointManager.d.ts +17 -0
  145. package/dist/src/debug/BreakpointManager.js +59 -0
  146. package/dist/src/debug/BreakpointManager.js.map +1 -0
  147. package/dist/src/debug/WorkflowDebugger.d.ts +34 -0
  148. package/dist/src/debug/WorkflowDebugger.js +117 -0
  149. package/dist/src/debug/WorkflowDebugger.js.map +1 -0
  150. package/dist/src/debug/index.d.ts +2 -0
  151. package/dist/src/debug/index.js +3 -0
  152. package/dist/src/debug/index.js.map +1 -0
  153. package/dist/src/demo/demoWorkflow.d.ts +3 -0
  154. package/dist/src/demo/demoWorkflow.js +82 -0
  155. package/dist/src/demo/demoWorkflow.js.map +1 -0
  156. package/dist/src/demo/exampleWorkflow.d.ts +36 -0
  157. package/dist/src/demo/exampleWorkflow.js +184 -0
  158. package/dist/src/demo/exampleWorkflow.js.map +1 -0
  159. package/dist/src/demo/index.d.ts +2 -0
  160. package/dist/src/demo/index.js +3 -0
  161. package/dist/src/demo/index.js.map +1 -0
  162. package/dist/src/dlq/DeadLetterQueue.d.ts +62 -0
  163. package/dist/src/dlq/DeadLetterQueue.js +342 -0
  164. package/dist/src/dlq/DeadLetterQueue.js.map +1 -0
  165. package/dist/src/dlq/index.d.ts +2 -0
  166. package/dist/src/dlq/index.js +2 -0
  167. package/dist/src/dlq/index.js.map +1 -0
  168. package/dist/src/dsl/DSLParser.d.ts +7 -0
  169. package/dist/src/dsl/DSLParser.js +252 -0
  170. package/dist/src/dsl/DSLParser.js.map +1 -0
  171. package/dist/src/dsl/WorkflowDSL.d.ts +40 -0
  172. package/dist/src/dsl/WorkflowDSL.js +2 -0
  173. package/dist/src/dsl/WorkflowDSL.js.map +1 -0
  174. package/dist/src/engine/CanaryReleaseManager.d.ts +39 -0
  175. package/dist/src/engine/CanaryReleaseManager.js +192 -0
  176. package/dist/src/engine/CanaryReleaseManager.js.map +1 -0
  177. package/dist/src/engine/ConcurrencyControl.d.ts +38 -0
  178. package/dist/src/engine/ConcurrencyControl.js +181 -0
  179. package/dist/src/engine/ConcurrencyControl.js.map +1 -0
  180. package/dist/src/engine/ContinueAsNewManager.d.ts +18 -0
  181. package/dist/src/engine/ContinueAsNewManager.js +29 -0
  182. package/dist/src/engine/ContinueAsNewManager.js.map +1 -0
  183. package/dist/src/engine/DataValidator.d.ts +15 -0
  184. package/dist/src/engine/DataValidator.js +121 -0
  185. package/dist/src/engine/DataValidator.js.map +1 -0
  186. package/dist/src/engine/DryRunExecutor.d.ts +48 -0
  187. package/dist/src/engine/DryRunExecutor.js +256 -0
  188. package/dist/src/engine/DryRunExecutor.js.map +1 -0
  189. package/dist/src/engine/ExecutionOrchestrator.d.ts +19 -0
  190. package/dist/src/engine/ExecutionOrchestrator.js +579 -0
  191. package/dist/src/engine/ExecutionOrchestrator.js.map +1 -0
  192. package/dist/src/engine/ExpressionEvaluator.d.ts +44 -0
  193. package/dist/src/engine/ExpressionEvaluator.js +1046 -0
  194. package/dist/src/engine/ExpressionEvaluator.js.map +1 -0
  195. package/dist/src/engine/HeartbeatManager.d.ts +42 -0
  196. package/dist/src/engine/HeartbeatManager.js +209 -0
  197. package/dist/src/engine/HeartbeatManager.js.map +1 -0
  198. package/dist/src/engine/InstanceManager.d.ts +21 -0
  199. package/dist/src/engine/InstanceManager.js +165 -0
  200. package/dist/src/engine/InstanceManager.js.map +1 -0
  201. package/dist/src/engine/InstanceSearch.d.ts +30 -0
  202. package/dist/src/engine/InstanceSearch.js +119 -0
  203. package/dist/src/engine/InstanceSearch.js.map +1 -0
  204. package/dist/src/engine/LifecycleManager.d.ts +18 -0
  205. package/dist/src/engine/LifecycleManager.js +82 -0
  206. package/dist/src/engine/LifecycleManager.js.map +1 -0
  207. package/dist/src/engine/ParallelExecutor.d.ts +26 -0
  208. package/dist/src/engine/ParallelExecutor.js +138 -0
  209. package/dist/src/engine/ParallelExecutor.js.map +1 -0
  210. package/dist/src/engine/SandboxEvaluator.d.ts +18 -0
  211. package/dist/src/engine/SandboxEvaluator.js +200 -0
  212. package/dist/src/engine/SandboxEvaluator.js.map +1 -0
  213. package/dist/src/engine/SchemaValidator.d.ts +30 -0
  214. package/dist/src/engine/SchemaValidator.js +630 -0
  215. package/dist/src/engine/SchemaValidator.js.map +1 -0
  216. package/dist/src/engine/SearchAttributeManager.d.ts +48 -0
  217. package/dist/src/engine/SearchAttributeManager.js +119 -0
  218. package/dist/src/engine/SearchAttributeManager.js.map +1 -0
  219. package/dist/src/engine/StateMachine.d.ts +13 -0
  220. package/dist/src/engine/StateMachine.js +66 -0
  221. package/dist/src/engine/StateMachine.js.map +1 -0
  222. package/dist/src/engine/StickyExecutionManager.d.ts +34 -0
  223. package/dist/src/engine/StickyExecutionManager.js +163 -0
  224. package/dist/src/engine/StickyExecutionManager.js.map +1 -0
  225. package/dist/src/engine/SubworkflowExecutor.d.ts +17 -0
  226. package/dist/src/engine/SubworkflowExecutor.js +157 -0
  227. package/dist/src/engine/SubworkflowExecutor.js.map +1 -0
  228. package/dist/src/engine/TaskExecutor.d.ts +12 -0
  229. package/dist/src/engine/TaskExecutor.js +124 -0
  230. package/dist/src/engine/TaskExecutor.js.map +1 -0
  231. package/dist/src/engine/TaskQueueManager.d.ts +42 -0
  232. package/dist/src/engine/TaskQueueManager.js +175 -0
  233. package/dist/src/engine/TaskQueueManager.js.map +1 -0
  234. package/dist/src/engine/WorkflowEngine.d.ts +117 -0
  235. package/dist/src/engine/WorkflowEngine.js +443 -0
  236. package/dist/src/engine/WorkflowEngine.js.map +1 -0
  237. package/dist/src/engine/WorkflowInstanceControl.d.ts +21 -0
  238. package/dist/src/engine/WorkflowInstanceControl.js +306 -0
  239. package/dist/src/engine/WorkflowInstanceControl.js.map +1 -0
  240. package/dist/src/engine/WorkflowPersistenceCoordinator.d.ts +12 -0
  241. package/dist/src/engine/WorkflowPersistenceCoordinator.js +93 -0
  242. package/dist/src/engine/WorkflowPersistenceCoordinator.js.map +1 -0
  243. package/dist/src/engine/WorkflowRegistry.d.ts +38 -0
  244. package/dist/src/engine/WorkflowRegistry.js +130 -0
  245. package/dist/src/engine/WorkflowRegistry.js.map +1 -0
  246. package/dist/src/engine/WorkflowVersionManager.d.ts +24 -0
  247. package/dist/src/engine/WorkflowVersionManager.js +121 -0
  248. package/dist/src/engine/WorkflowVersionManager.js.map +1 -0
  249. package/dist/src/engine/createEngine.d.ts +8 -0
  250. package/dist/src/engine/createEngine.js +21 -0
  251. package/dist/src/engine/createEngine.js.map +1 -0
  252. package/dist/src/engine/errors.d.ts +18 -0
  253. package/dist/src/engine/errors.js +37 -0
  254. package/dist/src/engine/errors.js.map +1 -0
  255. package/dist/src/engine/executors/ApprovalNodeExecutor.d.ts +12 -0
  256. package/dist/src/engine/executors/ApprovalNodeExecutor.js +68 -0
  257. package/dist/src/engine/executors/ApprovalNodeExecutor.js.map +1 -0
  258. package/dist/src/engine/executors/ConditionNodeExecutor.d.ts +16 -0
  259. package/dist/src/engine/executors/ConditionNodeExecutor.js +63 -0
  260. package/dist/src/engine/executors/ConditionNodeExecutor.js.map +1 -0
  261. package/dist/src/engine/executors/HttpNodeExecutor.d.ts +27 -0
  262. package/dist/src/engine/executors/HttpNodeExecutor.js +179 -0
  263. package/dist/src/engine/executors/HttpNodeExecutor.js.map +1 -0
  264. package/dist/src/engine/executors/JoinNodeExecutor.d.ts +13 -0
  265. package/dist/src/engine/executors/JoinNodeExecutor.js +37 -0
  266. package/dist/src/engine/executors/JoinNodeExecutor.js.map +1 -0
  267. package/dist/src/engine/executors/LoopNodeExecutor.d.ts +20 -0
  268. package/dist/src/engine/executors/LoopNodeExecutor.js +165 -0
  269. package/dist/src/engine/executors/LoopNodeExecutor.js.map +1 -0
  270. package/dist/src/engine/executors/NotificationNodeExecutor.d.ts +8 -0
  271. package/dist/src/engine/executors/NotificationNodeExecutor.js +33 -0
  272. package/dist/src/engine/executors/NotificationNodeExecutor.js.map +1 -0
  273. package/dist/src/engine/executors/QueueNodeExecutor.d.ts +23 -0
  274. package/dist/src/engine/executors/QueueNodeExecutor.js +87 -0
  275. package/dist/src/engine/executors/QueueNodeExecutor.js.map +1 -0
  276. package/dist/src/engine/executors/RouterNodeExecutor.d.ts +20 -0
  277. package/dist/src/engine/executors/RouterNodeExecutor.js +82 -0
  278. package/dist/src/engine/executors/RouterNodeExecutor.js.map +1 -0
  279. package/dist/src/engine/executors/SqlNodeExecutor.d.ts +27 -0
  280. package/dist/src/engine/executors/SqlNodeExecutor.js +74 -0
  281. package/dist/src/engine/executors/SqlNodeExecutor.js.map +1 -0
  282. package/dist/src/engine/executors/TransformNodeExecutor.d.ts +9 -0
  283. package/dist/src/engine/executors/TransformNodeExecutor.js +44 -0
  284. package/dist/src/engine/executors/TransformNodeExecutor.js.map +1 -0
  285. package/dist/src/engine/functions/collectionFunctions.d.ts +2 -0
  286. package/dist/src/engine/functions/collectionFunctions.js +129 -0
  287. package/dist/src/engine/functions/collectionFunctions.js.map +1 -0
  288. package/dist/src/engine/functions/customFunctions.d.ts +11 -0
  289. package/dist/src/engine/functions/customFunctions.js +42 -0
  290. package/dist/src/engine/functions/customFunctions.js.map +1 -0
  291. package/dist/src/engine/functions/dateFunctions.d.ts +2 -0
  292. package/dist/src/engine/functions/dateFunctions.js +71 -0
  293. package/dist/src/engine/functions/dateFunctions.js.map +1 -0
  294. package/dist/src/engine/functions/index.d.ts +14 -0
  295. package/dist/src/engine/functions/index.js +35 -0
  296. package/dist/src/engine/functions/index.js.map +1 -0
  297. package/dist/src/engine/functions/stringFunctions.d.ts +2 -0
  298. package/dist/src/engine/functions/stringFunctions.js +66 -0
  299. package/dist/src/engine/functions/stringFunctions.js.map +1 -0
  300. package/dist/src/engine/functions/typeFunctions.d.ts +2 -0
  301. package/dist/src/engine/functions/typeFunctions.js +70 -0
  302. package/dist/src/engine/functions/typeFunctions.js.map +1 -0
  303. package/dist/src/engine/functions/types.d.ts +6 -0
  304. package/dist/src/engine/functions/types.js +2 -0
  305. package/dist/src/engine/functions/types.js.map +1 -0
  306. package/dist/src/engine/index.d.ts +21 -0
  307. package/dist/src/engine/index.js +18 -0
  308. package/dist/src/engine/index.js.map +1 -0
  309. package/dist/src/engine/nodeDispatch/controlNodes.d.ts +2 -0
  310. package/dist/src/engine/nodeDispatch/controlNodes.js +208 -0
  311. package/dist/src/engine/nodeDispatch/controlNodes.js.map +1 -0
  312. package/dist/src/engine/nodeDispatch/helpers.d.ts +27 -0
  313. package/dist/src/engine/nodeDispatch/helpers.js +185 -0
  314. package/dist/src/engine/nodeDispatch/helpers.js.map +1 -0
  315. package/dist/src/engine/nodeDispatch/ioNodes.d.ts +2 -0
  316. package/dist/src/engine/nodeDispatch/ioNodes.js +89 -0
  317. package/dist/src/engine/nodeDispatch/ioNodes.js.map +1 -0
  318. package/dist/src/engine/nodeDispatch/types.d.ts +13 -0
  319. package/dist/src/engine/nodeDispatch/types.js +2 -0
  320. package/dist/src/engine/nodeDispatch/types.js.map +1 -0
  321. package/dist/src/engine/nodeDispatch/workflowNodes.d.ts +2 -0
  322. package/dist/src/engine/nodeDispatch/workflowNodes.js +33 -0
  323. package/dist/src/engine/nodeDispatch/workflowNodes.js.map +1 -0
  324. package/dist/src/engine/worker/ActionSandboxMessage.d.ts +29 -0
  325. package/dist/src/engine/worker/ActionSandboxMessage.js +7 -0
  326. package/dist/src/engine/worker/ActionSandboxMessage.js.map +1 -0
  327. package/dist/src/engine/worker/ActionSandboxPool.d.ts +34 -0
  328. package/dist/src/engine/worker/ActionSandboxPool.js +204 -0
  329. package/dist/src/engine/worker/ActionSandboxPool.js.map +1 -0
  330. package/dist/src/engine/worker/ActionSandboxWorker.d.ts +1 -0
  331. package/dist/src/engine/worker/ActionSandboxWorker.js +25 -0
  332. package/dist/src/engine/worker/ActionSandboxWorker.js.map +1 -0
  333. package/dist/src/engine/worker/WorkerMessage.d.ts +35 -0
  334. package/dist/src/engine/worker/WorkerMessage.js +7 -0
  335. package/dist/src/engine/worker/WorkerMessage.js.map +1 -0
  336. package/dist/src/engine/worker/WorkerPool.d.ts +42 -0
  337. package/dist/src/engine/worker/WorkerPool.js +273 -0
  338. package/dist/src/engine/worker/WorkerPool.js.map +1 -0
  339. package/dist/src/engine/worker/WorkerProcess.d.ts +1 -0
  340. package/dist/src/engine/worker/WorkerProcess.js +76 -0
  341. package/dist/src/engine/worker/WorkerProcess.js.map +1 -0
  342. package/dist/src/event/EventBus.d.ts +11 -0
  343. package/dist/src/event/EventBus.js +44 -0
  344. package/dist/src/event/EventBus.js.map +1 -0
  345. package/dist/src/event/EventCoordinator.d.ts +26 -0
  346. package/dist/src/event/EventCoordinator.js +205 -0
  347. package/dist/src/event/EventCoordinator.js.map +1 -0
  348. package/dist/src/event/EventDeduplicator.d.ts +31 -0
  349. package/dist/src/event/EventDeduplicator.js +100 -0
  350. package/dist/src/event/EventDeduplicator.js.map +1 -0
  351. package/dist/src/event/HookManager.d.ts +31 -0
  352. package/dist/src/event/HookManager.js +88 -0
  353. package/dist/src/event/HookManager.js.map +1 -0
  354. package/dist/src/event/MessageBus.d.ts +39 -0
  355. package/dist/src/event/MessageBus.js +131 -0
  356. package/dist/src/event/MessageBus.js.map +1 -0
  357. package/dist/src/event/index.d.ts +3 -0
  358. package/dist/src/event/index.js +4 -0
  359. package/dist/src/event/index.js.map +1 -0
  360. package/dist/src/index.d.ts +40 -0
  361. package/dist/src/index.js +33 -0
  362. package/dist/src/index.js.map +1 -0
  363. package/dist/src/lifecycle.d.ts +17 -0
  364. package/dist/src/lifecycle.js +84 -0
  365. package/dist/src/lifecycle.js.map +1 -0
  366. package/dist/src/metrics/AnalyticsCollector.d.ts +57 -0
  367. package/dist/src/metrics/AnalyticsCollector.js +140 -0
  368. package/dist/src/metrics/AnalyticsCollector.js.map +1 -0
  369. package/dist/src/metrics/AnomalyDetector.d.ts +21 -0
  370. package/dist/src/metrics/AnomalyDetector.js +120 -0
  371. package/dist/src/metrics/AnomalyDetector.js.map +1 -0
  372. package/dist/src/metrics/MetricsAggregator.d.ts +43 -0
  373. package/dist/src/metrics/MetricsAggregator.js +243 -0
  374. package/dist/src/metrics/MetricsAggregator.js.map +1 -0
  375. package/dist/src/metrics/SlaMonitor.d.ts +48 -0
  376. package/dist/src/metrics/SlaMonitor.js +130 -0
  377. package/dist/src/metrics/SlaMonitor.js.map +1 -0
  378. package/dist/src/metrics/index.d.ts +75 -0
  379. package/dist/src/metrics/index.js +293 -0
  380. package/dist/src/metrics/index.js.map +1 -0
  381. package/dist/src/model/Instance.d.ts +38 -0
  382. package/dist/src/model/Instance.js +12 -0
  383. package/dist/src/model/Instance.js.map +1 -0
  384. package/dist/src/model/RetryPolicy.d.ts +11 -0
  385. package/dist/src/model/RetryPolicy.js +30 -0
  386. package/dist/src/model/RetryPolicy.js.map +1 -0
  387. package/dist/src/model/Schedule.d.ts +34 -0
  388. package/dist/src/model/Schedule.js +50 -0
  389. package/dist/src/model/Schedule.js.map +1 -0
  390. package/dist/src/model/Workflow.d.ts +73 -0
  391. package/dist/src/model/Workflow.js +2 -0
  392. package/dist/src/model/Workflow.js.map +1 -0
  393. package/dist/src/model/WorkflowGraph.d.ts +32 -0
  394. package/dist/src/model/WorkflowGraph.js +267 -0
  395. package/dist/src/model/WorkflowGraph.js.map +1 -0
  396. package/dist/src/model/WorkflowSchema.d.ts +154 -0
  397. package/dist/src/model/WorkflowSchema.js +233 -0
  398. package/dist/src/model/WorkflowSchema.js.map +1 -0
  399. package/dist/src/model/WorkflowVariables.d.ts +15 -0
  400. package/dist/src/model/WorkflowVariables.js +77 -0
  401. package/dist/src/model/WorkflowVariables.js.map +1 -0
  402. package/dist/src/notification/NotificationChannel.d.ts +19 -0
  403. package/dist/src/notification/NotificationChannel.js +2 -0
  404. package/dist/src/notification/NotificationChannel.js.map +1 -0
  405. package/dist/src/notification/NotificationManager.d.ts +20 -0
  406. package/dist/src/notification/NotificationManager.js +59 -0
  407. package/dist/src/notification/NotificationManager.js.map +1 -0
  408. package/dist/src/notification/channels/DingtalkChannel.d.ts +7 -0
  409. package/dist/src/notification/channels/DingtalkChannel.js +18 -0
  410. package/dist/src/notification/channels/DingtalkChannel.js.map +1 -0
  411. package/dist/src/notification/channels/EmailChannel.d.ts +21 -0
  412. package/dist/src/notification/channels/EmailChannel.js +32 -0
  413. package/dist/src/notification/channels/EmailChannel.js.map +1 -0
  414. package/dist/src/notification/channels/FeishuChannel.d.ts +7 -0
  415. package/dist/src/notification/channels/FeishuChannel.js +18 -0
  416. package/dist/src/notification/channels/FeishuChannel.js.map +1 -0
  417. package/dist/src/notification/channels/SlackChannel.d.ts +7 -0
  418. package/dist/src/notification/channels/SlackChannel.js +18 -0
  419. package/dist/src/notification/channels/SlackChannel.js.map +1 -0
  420. package/dist/src/notification/channels/SmsChannel.d.ts +24 -0
  421. package/dist/src/notification/channels/SmsChannel.js +37 -0
  422. package/dist/src/notification/channels/SmsChannel.js.map +1 -0
  423. package/dist/src/notification/channels/WebhookChannel.d.ts +17 -0
  424. package/dist/src/notification/channels/WebhookChannel.js +61 -0
  425. package/dist/src/notification/channels/WebhookChannel.js.map +1 -0
  426. package/dist/src/notification/index.d.ts +24 -0
  427. package/dist/src/notification/index.js +61 -0
  428. package/dist/src/notification/index.js.map +1 -0
  429. package/dist/src/scheduler/CronScheduler.d.ts +20 -0
  430. package/dist/src/scheduler/CronScheduler.js +82 -0
  431. package/dist/src/scheduler/CronScheduler.js.map +1 -0
  432. package/dist/src/scheduler/EnhancedCronScheduler.d.ts +27 -0
  433. package/dist/src/scheduler/EnhancedCronScheduler.js +177 -0
  434. package/dist/src/scheduler/EnhancedCronScheduler.js.map +1 -0
  435. package/dist/src/storage/ArchiveManager.d.ts +21 -0
  436. package/dist/src/storage/ArchiveManager.js +140 -0
  437. package/dist/src/storage/ArchiveManager.js.map +1 -0
  438. package/dist/src/storage/LocalFileStorage.d.ts +64 -0
  439. package/dist/src/storage/LocalFileStorage.js +470 -0
  440. package/dist/src/storage/LocalFileStorage.js.map +1 -0
  441. package/dist/src/storage/MemoryStorage.d.ts +65 -0
  442. package/dist/src/storage/MemoryStorage.js +422 -0
  443. package/dist/src/storage/MemoryStorage.js.map +1 -0
  444. package/dist/src/storage/StorageProvider.d.ts +223 -0
  445. package/dist/src/storage/StorageProvider.js +2 -0
  446. package/dist/src/storage/StorageProvider.js.map +1 -0
  447. package/dist/src/storage/builtin-adapters.d.ts +1 -0
  448. package/dist/src/storage/builtin-adapters.js +20 -0
  449. package/dist/src/storage/builtin-adapters.js.map +1 -0
  450. package/dist/src/storage/index.d.ts +17 -0
  451. package/dist/src/storage/index.js +52 -0
  452. package/dist/src/storage/index.js.map +1 -0
  453. package/dist/src/storage/registry.d.ts +6 -0
  454. package/dist/src/storage/registry.js +23 -0
  455. package/dist/src/storage/registry.js.map +1 -0
  456. package/dist/src/telemetry/index.d.ts +53 -0
  457. package/dist/src/telemetry/index.js +73 -0
  458. package/dist/src/telemetry/index.js.map +1 -0
  459. package/dist/src/telemetry/spanRegistry.d.ts +9 -0
  460. package/dist/src/telemetry/spanRegistry.js +14 -0
  461. package/dist/src/telemetry/spanRegistry.js.map +1 -0
  462. package/dist/src/templates/AutoExtract.d.ts +2 -0
  463. package/dist/src/templates/AutoExtract.js +124 -0
  464. package/dist/src/templates/AutoExtract.js.map +1 -0
  465. package/dist/src/templates/TemplateGallery.d.ts +54 -0
  466. package/dist/src/templates/TemplateGallery.js +139 -0
  467. package/dist/src/templates/TemplateGallery.js.map +1 -0
  468. package/dist/src/templates/TemplateRegistry.d.ts +16 -0
  469. package/dist/src/templates/TemplateRegistry.js +92 -0
  470. package/dist/src/templates/TemplateRegistry.js.map +1 -0
  471. package/dist/src/templates/WorkflowTemplate.d.ts +24 -0
  472. package/dist/src/templates/WorkflowTemplate.js +2 -0
  473. package/dist/src/templates/WorkflowTemplate.js.map +1 -0
  474. package/dist/src/templates/builtin/HttpCallbackTemplate.d.ts +2 -0
  475. package/dist/src/templates/builtin/HttpCallbackTemplate.js +47 -0
  476. package/dist/src/templates/builtin/HttpCallbackTemplate.js.map +1 -0
  477. package/dist/src/templates/builtin/index.d.ts +3 -0
  478. package/dist/src/templates/builtin/index.js +11 -0
  479. package/dist/src/templates/builtin/index.js.map +1 -0
  480. package/dist/src/templates/index.d.ts +3 -0
  481. package/dist/src/templates/index.js +3 -0
  482. package/dist/src/templates/index.js.map +1 -0
  483. package/dist/src/testing/MutationTester.d.ts +27 -0
  484. package/dist/src/testing/MutationTester.js +157 -0
  485. package/dist/src/testing/MutationTester.js.map +1 -0
  486. package/dist/src/testing/TestGenerator.d.ts +31 -0
  487. package/dist/src/testing/TestGenerator.js +345 -0
  488. package/dist/src/testing/TestGenerator.js.map +1 -0
  489. package/dist/src/testing/index.d.ts +2 -0
  490. package/dist/src/testing/index.js +3 -0
  491. package/dist/src/testing/index.js.map +1 -0
  492. package/dist/src/testing/testWorkflow.d.ts +51 -0
  493. package/dist/src/testing/testWorkflow.js +167 -0
  494. package/dist/src/testing/testWorkflow.js.map +1 -0
  495. package/dist/src/utils/AuditLogger.d.ts +36 -0
  496. package/dist/src/utils/AuditLogger.js +148 -0
  497. package/dist/src/utils/AuditLogger.js.map +1 -0
  498. package/dist/src/utils/BoundedMap.d.ts +34 -0
  499. package/dist/src/utils/BoundedMap.js +125 -0
  500. package/dist/src/utils/BoundedMap.js.map +1 -0
  501. package/dist/src/utils/LeaseStore.d.ts +7 -0
  502. package/dist/src/utils/LeaseStore.js +102 -0
  503. package/dist/src/utils/LeaseStore.js.map +1 -0
  504. package/dist/src/utils/Logger.d.ts +26 -0
  505. package/dist/src/utils/Logger.js +279 -0
  506. package/dist/src/utils/Logger.js.map +1 -0
  507. package/dist/src/utils/SecretManager.d.ts +41 -0
  508. package/dist/src/utils/SecretManager.js +139 -0
  509. package/dist/src/utils/SecretManager.js.map +1 -0
  510. package/dist/src/utils/StructuredLogger.d.ts +45 -0
  511. package/dist/src/utils/StructuredLogger.js +118 -0
  512. package/dist/src/utils/StructuredLogger.js.map +1 -0
  513. package/dist/src/utils/concurrency.d.ts +3 -0
  514. package/dist/src/utils/concurrency.js +22 -0
  515. package/dist/src/utils/concurrency.js.map +1 -0
  516. package/dist/src/utils/env.d.ts +5 -0
  517. package/dist/src/utils/env.js +15 -0
  518. package/dist/src/utils/env.js.map +1 -0
  519. package/dist/src/utils/index.d.ts +5 -0
  520. package/dist/src/utils/index.js +4 -0
  521. package/dist/src/utils/index.js.map +1 -0
  522. package/dist/src/utils/secrets.d.ts +5 -0
  523. package/dist/src/utils/secrets.js +27 -0
  524. package/dist/src/utils/secrets.js.map +1 -0
  525. package/package.json +159 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sario
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,352 @@
1
+ # ts-workflow-engine-lite
2
+
3
+ A lightweight TypeScript workflow engine for embedded, single-process
4
+ applications. It includes workflow execution, a REST API, events, Cron
5
+ scheduling, retries, and local file persistence. Redis and databases are not
6
+ required for local use.
7
+
8
+ ## Install
9
+
10
+ Add the library to an existing TypeScript project:
11
+
12
+ ```bash
13
+ pnpm add ts-workflow-engine-lite
14
+ ```
15
+
16
+ Node.js 18 or newer is required.
17
+
18
+ The package is published as an ES module. Use ESM imports from JavaScript or
19
+ TypeScript:
20
+
21
+ ```js
22
+ import { bootstrap, destroyContainer } from "ts-workflow-engine-lite";
23
+ ```
24
+
25
+ TypeScript consumers can use either `moduleResolution: "NodeNext"` or
26
+ `"Bundler"`. This repository keeps extensionless relative imports in its
27
+ TypeScript source; the build step adds the required `.js` extensions only to
28
+ the generated `dist` files.
29
+
30
+ When working from this repository instead, install the development dependencies
31
+ and run the checked-in quick start:
32
+
33
+ ```bash
34
+ pnpm install
35
+ pnpm example:quickstart
36
+ ```
37
+
38
+ ## 5-minute TypeScript quick start
39
+
40
+ The package entry point is side-effect free. Importing it does not start a
41
+ server, register process handlers, or run a demo.
42
+
43
+ ```ts
44
+ import {
45
+ bootstrap,
46
+ destroyContainer,
47
+ type WorkflowDefinition,
48
+ } from "ts-workflow-engine-lite";
49
+
50
+ const workflow: WorkflowDefinition = {
51
+ id: "hello",
52
+ name: "Hello workflow",
53
+ startNode: "greet",
54
+ nodes: {
55
+ greet: {
56
+ id: "greet",
57
+ type: "action",
58
+ action: async (instance) => ({
59
+ message: `Hello, ${instance?.context?.name ?? "world"}!`,
60
+ }),
61
+ next: [],
62
+ },
63
+ },
64
+ };
65
+
66
+ const { engine, container } = await bootstrap({
67
+ skipGracefulShutdown: true,
68
+ logLevel: "WARN",
69
+ });
70
+
71
+ try {
72
+ await engine.register(workflow);
73
+ const instanceId = await engine.start("hello", { name: "Ada" });
74
+ const instance = await engine.waitForCompletion(instanceId);
75
+
76
+ console.log(instance.status); // completed
77
+ console.log(instance.state?.nodes?.greet?.output);
78
+ } finally {
79
+ engine.destroy();
80
+ await destroyContainer(container);
81
+ }
82
+ ```
83
+
84
+ `waitForCompletion()` returns when an instance is `completed`, `failed`, or
85
+ `cancelled`. It accepts `timeoutMs`, `pollIntervalMs`, and an `AbortSignal`.
86
+
87
+ ### Which initialization API should I use?
88
+
89
+ The package exposes two ways to get a running `WorkflowEngineV2`:
90
+
91
+ | API | Use when |
92
+ | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
93
+ | `bootstrap(options)` | **Default choice.** One call wires storage, secret manager, optional worker pool and archiving, and graceful shutdown, then returns `{ engine, container }`. Matches what the CLI and the quick start above use. |
94
+ | `createContainer(options)` + `setContainer(container)` + `createEngine(options)` | You need finer control over initialization order (e.g. registering workflows or a custom `SecretManager` between container and engine creation), or you're composing multiple engines against containers you manage yourself. `createEngine()` reads its container from the process-wide singleton set by `setContainer()` — call `createContainer` and `setContainer` first, or it throws `"Container not initialized"`. |
95
+
96
+ `bootstrap()` also calls `setContainer(container)` internally, so its
97
+ returned `container` is the same process-wide singleton `createEngine()`
98
+ reads from — you can still call `createEngine()` again afterwards (e.g. to
99
+ create a second engine sharing that container) without calling
100
+ `setContainer` yourself.
101
+
102
+ ## Run the examples
103
+
104
+ ```bash
105
+ pnpm example:quickstart # minimal embedded workflow
106
+ pnpm example:order # condition branch and multi-step order workflow
107
+ pnpm example:embedded-express # mounting createWorkflowRouter into a host Express app
108
+ pnpm example:error-handling # catching WorkflowNotFoundError / InstanceNotFoundError
109
+ pnpm dev # event-driven built-in demo
110
+ ```
111
+
112
+ ## Run the REST API
113
+
114
+ ```bash
115
+ pnpm dev:api
116
+ ```
117
+
118
+ The API starts on `http://localhost:3345` with local file storage:
119
+
120
+ ```bash
121
+ curl http://localhost:3345/workflow-api/v1/workflows
122
+ ```
123
+
124
+ Interactive OpenAPI documentation is available at:
125
+
126
+ ```text
127
+ http://localhost:3345/api-docs
128
+ ```
129
+
130
+ The CLI entry point creates `.env` from `.env.example` when needed. The
131
+ embedded `bootstrap()` API reads the current environment but does not create or
132
+ load an `.env` file automatically.
133
+
134
+ ### Mounting into an existing Express app
135
+
136
+ `startApiServer()` above creates and starts its own standalone `express()`
137
+ app — use it when this package should run as its own HTTP service. To
138
+ instead mount the workflow API as a router inside a host application's
139
+ existing Express app (sharing its port, body parser, and auth middleware),
140
+ use `createWorkflowRouter()`:
141
+
142
+ ```ts
143
+ import express from "express";
144
+ import { bootstrap, createWorkflowRouter } from "ts-workflow-engine-lite";
145
+
146
+ const { engine, container } = await bootstrap({ skipGracefulShutdown: true });
147
+
148
+ const app = express();
149
+ app.use(express.json());
150
+ // Apply your own auth/rate-limit middleware here if needed.
151
+ app.use(
152
+ "/workflow-api/v1",
153
+ await createWorkflowRouter(engine, container.storage),
154
+ );
155
+
156
+ app.listen(3000);
157
+ ```
158
+
159
+ The router exposes `/workflows`, `/instances`, `/events`, `/webhooks`,
160
+ `/dlq`, `/templates`, `/analytics`, `/functions`, `/health`, and (unless
161
+ `{ enableMetrics: false }` is passed) `/metrics`. It expects
162
+ `express.json()` to already have run, and does **not** include
163
+ `startApiServer`'s standalone-service concerns — helmet/CORS, rate
164
+ limiting, JWT auth, the welcome/docs pages, or the WebSocket console
165
+ stream. Add whatever of those the host app needs on its own app instance
166
+ before mounting this router.
167
+
168
+ ## Configuration
169
+
170
+ Set `WORKFLOW_ENGINE_LOG_LEVEL` to `DEBUG`, `INFO`, `WARN`, or `ERROR`.
171
+ Embedded applications can override it with `bootstrap({ logLevel: "WARN" })`
172
+ or change it later with `Logger.setLevel()`.
173
+
174
+ ### Storage modes
175
+
176
+ | Mode | Intended use | Restart recovery |
177
+ | -------- | ------------------------------------- | ---------------- |
178
+ | `file` | Default single-process runtime | Yes |
179
+ | `memory` | Tests and intentionally ephemeral use | No |
180
+
181
+ Local file persistence is enabled by default outside tests. Runtime state is
182
+ stored below `.ts-workflow-engine-data/` using one JSON file per record and atomic temp
183
+ file replacement:
184
+
185
+ ```bash
186
+ STORAGE_TYPE=file
187
+ STORAGE_DIR=.ts-workflow-engine-data
188
+ ```
189
+
190
+ The storage directory is organized by record type:
191
+
192
+ ```text
193
+ .ts-workflow-engine-data/
194
+ ├── instances/
195
+ ├── workflows/
196
+ ├── workflow-metadata/
197
+ ├── workflow-versions/
198
+ ├── waiting/
199
+ ├── metrics/
200
+ ├── events/
201
+ ├── heartbeats/
202
+ └── dlq/
203
+ ```
204
+
205
+ Each collection also has a `corrupt/` directory. A record that cannot be parsed
206
+ during startup is moved there so one damaged file does not prevent the engine
207
+ from starting. Inspect and recover quarantined files manually; they are not
208
+ loaded automatically.
209
+
210
+ ### Restart recovery
211
+
212
+ JSON/config-based workflow definitions are restored automatically. Workflow
213
+ definitions containing JavaScript functions or closures cannot be serialized,
214
+ so application code must register those definitions again before resuming
215
+ unfinished instances:
216
+
217
+ ```ts
218
+ const { engine } = await bootstrap({
219
+ storageType: "file",
220
+ resumeRunningInstances: false,
221
+ });
222
+
223
+ await engine.register(workflowWithFunctions);
224
+ await engine.resumeRunningInstancesFromStorage();
225
+ ```
226
+
227
+ `RESUME_ON_STARTUP=true` applies to API mode. Leave it disabled, or set
228
+ `resumeRunningInstances: false` in embedded use, when closure-based workflows
229
+ must be registered first. Embedded applications otherwise opt into recovery
230
+ with `resumeRunningInstances: true`.
231
+
232
+ ### Archive management
233
+
234
+ Terminal-instance archiving is disabled by default so completed instances stay
235
+ available to queries until normal TTL cleanup. To archive terminal instances
236
+ as date-partitioned local JSON and evict them from hot storage, opt in:
237
+
238
+ ```bash
239
+ ARCHIVE_ENABLED=true
240
+ ARCHIVE_DIR=./archive
241
+ ARCHIVE_RETENTION_DAYS=90
242
+ ARCHIVE_CLEANUP_INTERVAL_MS=21600000
243
+ ```
244
+
245
+ Archive files use `archive/YYYY-MM-DD/<instanceId>.json`. An instance is removed
246
+ from hot storage only after its archive file has been written successfully.
247
+ Expired date partitions are deleted according to `ARCHIVE_RETENTION_DAYS` on
248
+ startup and at the configured cleanup interval. Archived instances are cold
249
+ files: they are not automatically returned by normal instance queries or
250
+ restored into hot storage.
251
+
252
+ The equivalent embedded options are `storageType`, `storageDirectory`,
253
+ `enableArchiving`, `archiveDirectory`, and `archiveRetentionDays`.
254
+
255
+ ### Backup and restore
256
+
257
+ Back up `STORAGE_DIR` for active state and `ARCHIVE_DIR` separately when
258
+ archiving is enabled. For a consistent backup across collections, stop the
259
+ engine cleanly before copying the directories. Restore by copying them back to
260
+ the configured paths before startup. Do not edit active JSON files while the
261
+ engine is running.
262
+
263
+ ## Error handling
264
+
265
+ The engine throws named error classes (exported from the package root) for
266
+ the highest-frequency lookup/concurrency failure modes, so callers can
267
+ `instanceof`-check them instead of matching `Error.message` strings:
268
+
269
+ | Class | Thrown when |
270
+ | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
271
+ | `WorkflowNotFoundError` | `engine.start()` / `engine.dryRun()` / internal execution reference a `workflowId` (optionally a specific `version`) that isn't registered. Has `.workflowId` and `.version`. |
272
+ | `InstanceNotFoundError` | `engine.signal()` / `engine.query()` / `engine.update()` / `waitForCompletion()` reference an `instanceId` that doesn't resolve to a stored instance. Has `.instanceId`. |
273
+ | `ConcurrencyConflictError` | Optimistic concurrency control (CAS) exhausts its retry budget persisting an instance update — another writer kept winning the race on `instance.version`. Has `.instanceId` and `.attempts`. |
274
+ | `LockAcquisitionError` | `ConcurrencyControl.withLock()` fails to acquire a lock within its retry budget. Has `.resourceId`. |
275
+
276
+ Other failures (timeouts, invalid state transitions, the max-instances
277
+ limit, schema validation via `DataValidationError`) still throw plain
278
+ `Error` or their own existing error class — see
279
+ [`examples/error-handling.ts`](./examples/error-handling.ts) for a runnable
280
+ demonstration.
281
+
282
+ ## Supported workflow features
283
+
284
+ - Node types: `action`, `wait`, `event`, `rollback`, `subworkflow`, `condition`,
285
+ `router`, `loop`, `http`, `sql`, `queue`, `notification`, and `approval`
286
+ - Event bus, hooks, deduplication, Cron scheduling, retries, heartbeats, and
287
+ dead-letter queue handling
288
+ - REST API for workflows, instances, signals, queries, updates, templates,
289
+ webhooks, events, analytics, and the dead-letter queue
290
+ - Expression evaluation with built-in and custom functions
291
+
292
+ ## Scope and limitations
293
+
294
+ This project is intentionally single-process. Local file storage protects state
295
+ across ordinary process restarts, but it is not a transactional database and
296
+ the same `STORAGE_DIR` must never be shared by multiple engine processes.
297
+ Process-local leases, rate limits, idempotency keys, the event bus, and Cron
298
+ scheduling do not provide distributed coordination. The project also does not
299
+ provide clustering, multi-tenancy isolation, GraphQL, or a visual editor.
300
+
301
+ ## Development scripts
302
+
303
+ ```bash
304
+ pnpm build # clean and compile TypeScript to dist/
305
+ pnpm test # run Vitest
306
+ pnpm typecheck # type-check source, tests, and examples
307
+ pnpm lint # run oxlint checks
308
+ pnpm format:check # verify formatting
309
+ ```
310
+
311
+ ## Optional API layer
312
+
313
+ The REST API is optional. Core engine imports never pull in `express`, `cors`,
314
+ `helmet`, or any HTTP framework. If you only need the workflow engine, skip
315
+ those dependencies entirely:
316
+
317
+ ```bash
318
+ # Core only (no REST API)
319
+ pnpm add ts-workflow-engine-lite
320
+ ```
321
+
322
+ If you need the REST API, install the peer dependencies:
323
+
324
+ ```bash
325
+ # Full install with REST API
326
+ pnpm add ts-workflow-engine-lite express cors helmet morgan ws swagger-ui-dist
327
+ ```
328
+
329
+ API-related exports (`startApiServer`, `createWorkflowRouter`) use dynamic
330
+ `import()` internally and will throw a clear error if the HTTP packages
331
+ are not installed.
332
+
333
+ ## Examples
334
+
335
+ | Example | Script | Description |
336
+ | --------------------------------------------------------------- | ------------------------------- | ------------------------------------------------ |
337
+ | [quickstart.ts](./examples/quickstart.ts) | `pnpm example:quickstart` | Minimal workflow with condition routing |
338
+ | [order-processing.ts](./examples/order-processing.ts) | `pnpm example:order` | Multi-step order processing pipeline |
339
+ | [embedded-express-app.ts](./examples/embedded-express-app.ts) | `pnpm example:embedded-express` | Embed API in a host Express app |
340
+ | [error-handling.ts](./examples/error-handling.ts) | `pnpm example:error-handling` | Named error classes and retry handling |
341
+ | [multi-tenant-workflow.ts](./examples/multi-tenant-workflow.ts) | `pnpm example:multi-tenant` | Tenant-isolated workflows with condition routing |
342
+ | [approval-pipeline.ts](./examples/approval-pipeline.ts) | `pnpm example:approval` | Long-running approval with timeout |
343
+ | [http-orchestration.ts](./examples/http-orchestration.ts) | `pnpm example:http` | HTTP integration with conditional routing |
344
+ | [parallel-fan-out.ts](./examples/parallel-fan-out.ts) | `pnpm example:parallel` | Parallel processing with merge |
345
+ | [graceful-degradation.ts](./examples/graceful-degradation.ts) | `pnpm example:degradation` | Fallback paths and dead letter queues |
346
+ | [headless-engine.ts](./examples/headless-engine.ts) | `pnpm example:headless` | Pure programmatic usage, no API server |
347
+ | [worker-pool.ts](./examples/worker-pool.ts) | `pnpm example:worker-pool` | CPU-intensive tasks with worker threads |
348
+ | [cron-data-sync.ts](./examples/cron-data-sync.ts) | `pnpm example:cron-sync` | Scheduled data synchronization |
349
+
350
+ ## License
351
+
352
+ MIT
@@ -0,0 +1,57 @@
1
+ import type { IncomingMessage } from "http";
2
+ import type { WebSocket } from "ws";
3
+ import type { HookEventName, HookPayload } from "../event/HookManager.js";
4
+ import type { WorkflowInstance } from "../model/Instance.js";
5
+ import type { StorageProvider } from "../storage/StorageProvider.js";
6
+ export interface InstanceUpdate {
7
+ instanceId: string;
8
+ timestamp: number;
9
+ type: "status" | "node" | "error" | "completed";
10
+ data: Record<string, unknown>;
11
+ }
12
+ export interface ConsoleConnectedMessage {
13
+ type: "connected";
14
+ mode: "global" | "instance";
15
+ timestamp: number;
16
+ instanceId?: string;
17
+ instance?: WorkflowInstance | null;
18
+ message?: string;
19
+ }
20
+ export interface ConsolePongMessage {
21
+ type: "pong";
22
+ timestamp: number;
23
+ }
24
+ export type ConsoleHookData = HookPayload | (HookPayload & {
25
+ childInstanceId: string;
26
+ parentInstanceId: string;
27
+ });
28
+ export interface ConsoleHookMessage {
29
+ type: "hook";
30
+ event: HookEventName;
31
+ instanceId?: string;
32
+ workflowId?: string;
33
+ nodeId?: string;
34
+ status?: string;
35
+ timestamp: string;
36
+ data: ConsoleHookData;
37
+ }
38
+ export type ConsoleWebSocketMessage = ConsoleConnectedMessage | ConsolePongMessage | ConsoleHookMessage;
39
+ export declare class ConsoleWebSocketManager {
40
+ private globalConnections;
41
+ private instanceConnections;
42
+ private storage?;
43
+ constructor(storage?: StorageProvider);
44
+ handleGlobalConnection(ws: WebSocket, _req: IncomingMessage): void;
45
+ handleConnection(ws: WebSocket, instanceId: string, _req: IncomingMessage): void;
46
+ broadcastHook(payload: HookPayload): void;
47
+ broadcastUpdate(instanceId: string, update: InstanceUpdate): void;
48
+ private sendInitialState;
49
+ private sendMessage;
50
+ private removeInstanceConnection;
51
+ getStats(): {
52
+ globalConnections: number;
53
+ instanceConnections: number;
54
+ instanceCount: number;
55
+ };
56
+ shutdown(): void;
57
+ }
@@ -0,0 +1,206 @@
1
+ import { errorMessage, Logger } from "../utils/Logger.js";
2
+ const INSTANCE_UPDATE_EVENT_MAP = {
3
+ status: "workflow.started",
4
+ node: "node.started",
5
+ error: "workflow.failed",
6
+ completed: "workflow.completed",
7
+ };
8
+ export class ConsoleWebSocketManager {
9
+ globalConnections = new Set();
10
+ instanceConnections = new Map();
11
+ storage;
12
+ constructor(storage) {
13
+ this.storage = storage;
14
+ }
15
+ handleGlobalConnection(ws, _req) {
16
+ Logger.info("api", "console-ws", "New global WebSocket connection");
17
+ this.globalConnections.add(ws);
18
+ this.sendMessage(ws, {
19
+ type: "connected",
20
+ mode: "global",
21
+ timestamp: Date.now(),
22
+ });
23
+ ws.on("message", (message) => {
24
+ try {
25
+ const data = JSON.parse(message.toString());
26
+ if (data.type === "ping") {
27
+ this.sendMessage(ws, { type: "pong", timestamp: Date.now() });
28
+ }
29
+ }
30
+ catch {
31
+ }
32
+ });
33
+ ws.on("close", () => {
34
+ this.globalConnections.delete(ws);
35
+ Logger.info("api", "console-ws", "Global WebSocket connection closed");
36
+ });
37
+ ws.on("error", (error) => {
38
+ Logger.error("api", "console-ws", `Global WebSocket error: ${error.message}`);
39
+ this.globalConnections.delete(ws);
40
+ });
41
+ }
42
+ handleConnection(ws, instanceId, _req) {
43
+ Logger.info("api", "console-ws", `New instance WebSocket connection for ${instanceId}`);
44
+ if (!this.instanceConnections.has(instanceId)) {
45
+ this.instanceConnections.set(instanceId, new Set());
46
+ }
47
+ this.instanceConnections.get(instanceId).add(ws);
48
+ this.sendInitialState(ws, instanceId).catch((error) => {
49
+ Logger.error("api", "console-ws", `Failed to send initial state: ${errorMessage(error)}`);
50
+ });
51
+ ws.on("message", (message) => {
52
+ try {
53
+ const data = JSON.parse(message.toString());
54
+ if (data.type === "ping") {
55
+ this.sendMessage(ws, { type: "pong", timestamp: Date.now() });
56
+ }
57
+ }
58
+ catch {
59
+ }
60
+ });
61
+ ws.on("close", () => {
62
+ this.removeInstanceConnection(instanceId, ws);
63
+ });
64
+ ws.on("error", (error) => {
65
+ Logger.error("api", "console-ws", `Instance WebSocket error for ${instanceId}: ${error.message}`);
66
+ this.removeInstanceConnection(instanceId, ws);
67
+ });
68
+ }
69
+ broadcastHook(payload) {
70
+ const message = {
71
+ type: "hook",
72
+ event: payload.event,
73
+ instanceId: payload.instanceId,
74
+ workflowId: payload.workflowId,
75
+ nodeId: payload.nodeId,
76
+ status: payload.status,
77
+ timestamp: payload.timestamp ?? new Date().toISOString(),
78
+ data: payload,
79
+ };
80
+ for (const ws of this.globalConnections) {
81
+ this.sendMessage(ws, message);
82
+ }
83
+ if (payload.instanceId) {
84
+ const conns = this.instanceConnections.get(payload.instanceId);
85
+ if (conns) {
86
+ for (const ws of conns) {
87
+ this.sendMessage(ws, message);
88
+ }
89
+ }
90
+ if ((payload.event === "workflow.completed" ||
91
+ payload.event === "workflow.failed") &&
92
+ this.storage) {
93
+ void this.storage
94
+ .loadInstance(payload.instanceId)
95
+ .then((instance) => {
96
+ const parentId = instance?.parentInstanceId;
97
+ if (!parentId)
98
+ return;
99
+ const parentConns = this.instanceConnections.get(parentId);
100
+ if (!parentConns)
101
+ return;
102
+ const parentMessage = {
103
+ ...message,
104
+ type: "hook",
105
+ event: `subworkflow.${payload.event === "workflow.completed" ? "completed" : "failed"}`,
106
+ data: {
107
+ ...payload,
108
+ childInstanceId: payload.instanceId,
109
+ parentInstanceId: parentId,
110
+ },
111
+ };
112
+ for (const ws of parentConns) {
113
+ this.sendMessage(ws, parentMessage);
114
+ }
115
+ })
116
+ .catch(() => {
117
+ });
118
+ }
119
+ }
120
+ }
121
+ broadcastUpdate(instanceId, update) {
122
+ this.broadcastHook({
123
+ event: INSTANCE_UPDATE_EVENT_MAP[update.type],
124
+ instanceId,
125
+ workflowId: "",
126
+ timestamp: String(update.timestamp),
127
+ ...update.data,
128
+ });
129
+ }
130
+ async sendInitialState(ws, instanceId) {
131
+ if (!this.storage) {
132
+ this.sendMessage(ws, {
133
+ type: "connected",
134
+ mode: "instance",
135
+ instanceId,
136
+ message: "Storage not available – hook events only",
137
+ timestamp: Date.now(),
138
+ });
139
+ return;
140
+ }
141
+ try {
142
+ const instance = await this.storage.loadInstance(instanceId);
143
+ this.sendMessage(ws, {
144
+ type: "connected",
145
+ mode: "instance",
146
+ instanceId,
147
+ instance: instance ?? null,
148
+ timestamp: Date.now(),
149
+ });
150
+ }
151
+ catch (error) {
152
+ Logger.error("api", "console-ws", `Failed to load instance ${instanceId}: ${errorMessage(error)}`);
153
+ this.sendMessage(ws, {
154
+ type: "connected",
155
+ mode: "instance",
156
+ instanceId,
157
+ instance: null,
158
+ timestamp: Date.now(),
159
+ });
160
+ }
161
+ }
162
+ sendMessage(ws, message) {
163
+ if (ws.readyState === 1) {
164
+ try {
165
+ ws.send(JSON.stringify(message));
166
+ }
167
+ catch (error) {
168
+ Logger.error("api", "console-ws", `Failed to send message: ${errorMessage(error)}`);
169
+ }
170
+ }
171
+ }
172
+ removeInstanceConnection(instanceId, ws) {
173
+ const connections = this.instanceConnections.get(instanceId);
174
+ if (connections) {
175
+ connections.delete(ws);
176
+ if (connections.size === 0) {
177
+ this.instanceConnections.delete(instanceId);
178
+ }
179
+ }
180
+ }
181
+ getStats() {
182
+ let instanceConnections = 0;
183
+ for (const conns of this.instanceConnections.values()) {
184
+ instanceConnections += conns.size;
185
+ }
186
+ return {
187
+ globalConnections: this.globalConnections.size,
188
+ instanceConnections,
189
+ instanceCount: this.instanceConnections.size,
190
+ };
191
+ }
192
+ shutdown() {
193
+ for (const ws of this.globalConnections) {
194
+ ws.close();
195
+ }
196
+ this.globalConnections.clear();
197
+ for (const conns of this.instanceConnections.values()) {
198
+ for (const ws of conns) {
199
+ ws.close();
200
+ }
201
+ }
202
+ this.instanceConnections.clear();
203
+ Logger.info("api", "console-ws", "WebSocket manager shut down");
204
+ }
205
+ }
206
+ //# sourceMappingURL=ConsoleWebSocketManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleWebSocketManager.js","sourceRoot":"","sources":["../../../src/api/ConsoleWebSocketManager.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAuDvD,MAAM,yBAAyB,GAC7B;IACE,MAAM,EAAE,kBAAkB;IAC1B,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,iBAAiB;IACxB,SAAS,EAAE,oBAAoB;CAChC,CAAC;AAEJ,MAAM,OAAO,uBAAuB;IAE1B,iBAAiB,GAAmB,IAAI,GAAG,EAAE,CAAC;IAE9C,mBAAmB,GAAgC,IAAI,GAAG,EAAE,CAAC;IAC7D,OAAO,CAAmB;IAElC,YAAY,OAAyB;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAKD,sBAAsB,CAAC,EAAa,EAAE,IAAqB;QACzD,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,iCAAiC,CAAC,CAAC;QACpE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAE/B,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE;YACnB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC,CAAC;QAEH,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAe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