nvent 0.4.4 → 0.5.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 (293) hide show
  1. package/dist/module.d.mts +4 -185
  2. package/dist/module.json +3 -3
  3. package/dist/module.mjs +451 -257
  4. package/dist/runtime/adapters/base/index.d.ts +6 -0
  5. package/dist/runtime/adapters/base/index.js +1 -0
  6. package/dist/runtime/adapters/base/store-validator.d.ts +48 -0
  7. package/dist/runtime/adapters/base/store-validator.js +147 -0
  8. package/dist/runtime/adapters/builtin/file-queue.d.ts +67 -0
  9. package/dist/runtime/adapters/builtin/file-queue.js +499 -0
  10. package/dist/runtime/adapters/builtin/file-store.d.ts +32 -0
  11. package/dist/runtime/adapters/builtin/file-store.js +206 -0
  12. package/dist/runtime/adapters/builtin/file-stream.d.ts +39 -0
  13. package/dist/runtime/adapters/builtin/file-stream.js +56 -0
  14. package/dist/runtime/adapters/builtin/index.d.ts +10 -0
  15. package/dist/runtime/adapters/builtin/index.js +5 -0
  16. package/dist/runtime/adapters/builtin/memory-queue.d.ts +52 -0
  17. package/dist/runtime/adapters/builtin/memory-queue.js +243 -0
  18. package/dist/runtime/adapters/builtin/memory-store.d.ts +68 -0
  19. package/dist/runtime/adapters/builtin/memory-store.js +333 -0
  20. package/dist/runtime/adapters/builtin/memory-stream.d.ts +21 -0
  21. package/dist/runtime/adapters/builtin/memory-stream.js +56 -0
  22. package/dist/runtime/adapters/factory.d.ts +31 -0
  23. package/dist/runtime/adapters/factory.js +134 -0
  24. package/dist/runtime/adapters/index.d.ts +8 -0
  25. package/dist/runtime/adapters/index.js +3 -0
  26. package/dist/runtime/adapters/interfaces/index.d.ts +11 -0
  27. package/dist/runtime/adapters/interfaces/index.js +3 -0
  28. package/dist/runtime/adapters/interfaces/queue.d.ts +150 -0
  29. package/dist/runtime/adapters/interfaces/store.d.ts +297 -0
  30. package/dist/runtime/adapters/interfaces/stream.d.ts +62 -0
  31. package/dist/runtime/adapters/registry.d.ts +85 -0
  32. package/dist/runtime/adapters/registry.js +161 -0
  33. package/dist/runtime/config/index.d.ts +29 -0
  34. package/dist/runtime/config/index.js +175 -0
  35. package/dist/runtime/config/types.d.ts +397 -0
  36. package/dist/runtime/config/types.js +0 -0
  37. package/dist/runtime/{server-utils/events → events}/eventBus.d.ts +1 -1
  38. package/dist/runtime/events/types.d.ts +145 -0
  39. package/dist/runtime/events/types.js +0 -0
  40. package/dist/runtime/events/utils/scheduleTrigger.d.ts +8 -0
  41. package/dist/runtime/events/utils/scheduleTrigger.js +69 -0
  42. package/dist/runtime/events/utils/stallDetector.d.ts +140 -0
  43. package/dist/runtime/events/utils/stallDetector.js +436 -0
  44. package/dist/runtime/events/utils/triggerRuntime.d.ts +58 -0
  45. package/dist/runtime/events/utils/triggerRuntime.js +212 -0
  46. package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.d.ts +12 -11
  47. package/dist/runtime/events/wiring/flowWiring.js +1020 -0
  48. package/dist/runtime/events/wiring/registry.d.ts +19 -0
  49. package/dist/runtime/events/wiring/registry.js +35 -0
  50. package/dist/runtime/events/wiring/stateWiring.d.ts +37 -0
  51. package/dist/runtime/events/wiring/stateWiring.js +92 -0
  52. package/dist/runtime/events/wiring/streamWiring.d.ts +36 -0
  53. package/dist/runtime/events/wiring/streamWiring.js +156 -0
  54. package/dist/runtime/events/wiring/triggerWiring.d.ts +21 -0
  55. package/dist/runtime/events/wiring/triggerWiring.js +412 -0
  56. package/dist/runtime/nitro/plugins/00.adapters.d.ts +14 -0
  57. package/dist/runtime/nitro/plugins/00.adapters.js +73 -0
  58. package/dist/runtime/nitro/plugins/02.workers.js +63 -0
  59. package/dist/runtime/nitro/plugins/03.triggers.d.ts +12 -0
  60. package/dist/runtime/nitro/plugins/03.triggers.js +55 -0
  61. package/dist/runtime/nitro/routes/webhook.await.d.ts +23 -0
  62. package/dist/runtime/nitro/routes/webhook.await.js +90 -0
  63. package/dist/runtime/nitro/routes/webhook.trigger.d.ts +69 -0
  64. package/dist/runtime/nitro/routes/webhook.trigger.js +64 -0
  65. package/dist/runtime/nitro/utils/adapters.d.ts +66 -0
  66. package/dist/runtime/nitro/utils/adapters.js +51 -0
  67. package/dist/runtime/nitro/utils/awaitPatterns/event.d.ts +15 -0
  68. package/dist/runtime/nitro/utils/awaitPatterns/event.js +120 -0
  69. package/dist/runtime/nitro/utils/awaitPatterns/index.d.ts +28 -0
  70. package/dist/runtime/nitro/utils/awaitPatterns/index.js +55 -0
  71. package/dist/runtime/nitro/utils/awaitPatterns/schedule.d.ts +16 -0
  72. package/dist/runtime/nitro/utils/awaitPatterns/schedule.js +78 -0
  73. package/dist/runtime/nitro/utils/awaitPatterns/time.d.ts +15 -0
  74. package/dist/runtime/nitro/utils/awaitPatterns/time.js +67 -0
  75. package/dist/runtime/nitro/utils/awaitPatterns/webhook.d.ts +15 -0
  76. package/dist/runtime/nitro/utils/awaitPatterns/webhook.js +120 -0
  77. package/dist/runtime/nitro/utils/defineFunction.d.ts +10 -0
  78. package/dist/runtime/nitro/utils/defineFunction.js +17 -0
  79. package/dist/runtime/nitro/utils/defineFunctionConfig.d.ts +310 -0
  80. package/dist/runtime/nitro/utils/defineFunctionConfig.js +3 -0
  81. package/dist/runtime/nitro/utils/defineHooks.d.ts +41 -0
  82. package/dist/runtime/nitro/utils/defineHooks.js +6 -0
  83. package/dist/runtime/nitro/utils/registerAdapter.d.ts +59 -0
  84. package/dist/runtime/nitro/utils/registerAdapter.js +13 -0
  85. package/dist/runtime/nitro/utils/useAwait.d.ts +71 -0
  86. package/dist/runtime/nitro/utils/useAwait.js +139 -0
  87. package/dist/runtime/{server-utils → nitro}/utils/useEventManager.d.ts +2 -2
  88. package/dist/runtime/{server-utils → nitro}/utils/useEventManager.js +1 -1
  89. package/dist/runtime/nitro/utils/useFlow.d.ts +68 -0
  90. package/dist/runtime/nitro/utils/useFlow.js +226 -0
  91. package/dist/runtime/nitro/utils/useHookRegistry.d.ts +34 -0
  92. package/dist/runtime/nitro/utils/useHookRegistry.js +25 -0
  93. package/dist/runtime/{server-utils → nitro}/utils/useNventLogger.js +2 -2
  94. package/dist/runtime/nitro/utils/useRunContext.d.ts +6 -0
  95. package/dist/runtime/nitro/utils/useRunContext.js +102 -0
  96. package/dist/runtime/nitro/utils/useStreamTopics.d.ts +83 -0
  97. package/dist/runtime/nitro/utils/useStreamTopics.js +94 -0
  98. package/dist/runtime/nitro/utils/useTrigger.d.ts +150 -0
  99. package/dist/runtime/nitro/utils/useTrigger.js +320 -0
  100. package/dist/runtime/scheduler/index.d.ts +33 -0
  101. package/dist/runtime/scheduler/index.js +38 -0
  102. package/dist/runtime/scheduler/scheduler.d.ts +113 -0
  103. package/dist/runtime/scheduler/scheduler.js +623 -0
  104. package/dist/runtime/scheduler/types.d.ts +116 -0
  105. package/dist/runtime/scheduler/types.js +0 -0
  106. package/dist/runtime/tsconfig.json +8 -0
  107. package/dist/runtime/worker/node/runner.d.ts +53 -0
  108. package/dist/runtime/worker/node/runner.js +327 -0
  109. package/dist/types.d.mts +2 -2
  110. package/package.json +16 -46
  111. package/LICENSE +0 -21
  112. package/README.md +0 -389
  113. package/dist/runtime/app/assets/vueflow.css +0 -1
  114. package/dist/runtime/app/components/ConfirmDialog.d.vue.ts +0 -33
  115. package/dist/runtime/app/components/ConfirmDialog.vue +0 -121
  116. package/dist/runtime/app/components/ConfirmDialog.vue.d.ts +0 -33
  117. package/dist/runtime/app/components/FlowDiagram.d.vue.ts +0 -64
  118. package/dist/runtime/app/components/FlowDiagram.vue +0 -338
  119. package/dist/runtime/app/components/FlowDiagram.vue.d.ts +0 -64
  120. package/dist/runtime/app/components/FlowNodeCard.d.vue.ts +0 -29
  121. package/dist/runtime/app/components/FlowNodeCard.vue +0 -156
  122. package/dist/runtime/app/components/FlowNodeCard.vue.d.ts +0 -29
  123. package/dist/runtime/app/components/FlowRunOverview.d.vue.ts +0 -9
  124. package/dist/runtime/app/components/FlowRunOverview.vue +0 -291
  125. package/dist/runtime/app/components/FlowRunOverview.vue.d.ts +0 -9
  126. package/dist/runtime/app/components/FlowRunStatusBadge.d.vue.ts +0 -14
  127. package/dist/runtime/app/components/FlowRunStatusBadge.vue +0 -60
  128. package/dist/runtime/app/components/FlowRunStatusBadge.vue.d.ts +0 -14
  129. package/dist/runtime/app/components/FlowRunTimeline.d.vue.ts +0 -12
  130. package/dist/runtime/app/components/FlowRunTimeline.vue +0 -127
  131. package/dist/runtime/app/components/FlowRunTimeline.vue.d.ts +0 -12
  132. package/dist/runtime/app/components/FlowScheduleDialog.d.vue.ts +0 -16
  133. package/dist/runtime/app/components/FlowScheduleDialog.vue +0 -226
  134. package/dist/runtime/app/components/FlowScheduleDialog.vue.d.ts +0 -16
  135. package/dist/runtime/app/components/FlowSchedulesList.d.vue.ts +0 -12
  136. package/dist/runtime/app/components/FlowSchedulesList.vue +0 -99
  137. package/dist/runtime/app/components/FlowSchedulesList.vue.d.ts +0 -12
  138. package/dist/runtime/app/components/JobScheduling.d.vue.ts +0 -6
  139. package/dist/runtime/app/components/JobScheduling.vue +0 -203
  140. package/dist/runtime/app/components/JobScheduling.vue.d.ts +0 -6
  141. package/dist/runtime/app/components/ListItem.d.vue.ts +0 -23
  142. package/dist/runtime/app/components/ListItem.vue +0 -70
  143. package/dist/runtime/app/components/ListItem.vue.d.ts +0 -23
  144. package/dist/runtime/app/components/QueueConfigDetails.d.vue.ts +0 -45
  145. package/dist/runtime/app/components/QueueConfigDetails.vue +0 -412
  146. package/dist/runtime/app/components/QueueConfigDetails.vue.d.ts +0 -45
  147. package/dist/runtime/app/components/StatCounter.d.vue.ts +0 -9
  148. package/dist/runtime/app/components/StatCounter.vue +0 -25
  149. package/dist/runtime/app/components/StatCounter.vue.d.ts +0 -9
  150. package/dist/runtime/app/components/TimelineList.d.vue.ts +0 -7
  151. package/dist/runtime/app/components/TimelineList.vue +0 -210
  152. package/dist/runtime/app/components/TimelineList.vue.d.ts +0 -7
  153. package/dist/runtime/app/components/nhealth/component-router.d.vue.ts +0 -46
  154. package/dist/runtime/app/components/nhealth/component-router.vue +0 -26
  155. package/dist/runtime/app/components/nhealth/component-router.vue.d.ts +0 -46
  156. package/dist/runtime/app/components/nhealth/component-shell.d.vue.ts +0 -24
  157. package/dist/runtime/app/components/nhealth/component-shell.vue +0 -89
  158. package/dist/runtime/app/components/nhealth/component-shell.vue.d.ts +0 -24
  159. package/dist/runtime/app/composables/useAnalyzedFlows.d.ts +0 -14
  160. package/dist/runtime/app/composables/useAnalyzedFlows.js +0 -8
  161. package/dist/runtime/app/composables/useComponentRouter.d.ts +0 -38
  162. package/dist/runtime/app/composables/useComponentRouter.js +0 -240
  163. package/dist/runtime/app/composables/useFlowRunTimeline.d.ts +0 -80
  164. package/dist/runtime/app/composables/useFlowRunTimeline.js +0 -68
  165. package/dist/runtime/app/composables/useFlowRuns.d.ts +0 -18
  166. package/dist/runtime/app/composables/useFlowRuns.js +0 -32
  167. package/dist/runtime/app/composables/useFlowRunsInfinite.d.ts +0 -24
  168. package/dist/runtime/app/composables/useFlowRunsInfinite.js +0 -123
  169. package/dist/runtime/app/composables/useFlowRunsPolling.d.ts +0 -9
  170. package/dist/runtime/app/composables/useFlowRunsPolling.js +0 -33
  171. package/dist/runtime/app/composables/useFlowState.d.ts +0 -125
  172. package/dist/runtime/app/composables/useFlowState.js +0 -211
  173. package/dist/runtime/app/composables/useFlowWebSocket.d.ts +0 -27
  174. package/dist/runtime/app/composables/useFlowWebSocket.js +0 -205
  175. package/dist/runtime/app/composables/useFlowsNavigation.d.ts +0 -10
  176. package/dist/runtime/app/composables/useFlowsNavigation.js +0 -58
  177. package/dist/runtime/app/composables/useQueueJobs.d.ts +0 -26
  178. package/dist/runtime/app/composables/useQueueJobs.js +0 -20
  179. package/dist/runtime/app/composables/useQueueUpdates.d.ts +0 -26
  180. package/dist/runtime/app/composables/useQueueUpdates.js +0 -122
  181. package/dist/runtime/app/composables/useQueues.d.ts +0 -45
  182. package/dist/runtime/app/composables/useQueues.js +0 -26
  183. package/dist/runtime/app/composables/useQueuesLive.d.ts +0 -19
  184. package/dist/runtime/app/composables/useQueuesLive.js +0 -143
  185. package/dist/runtime/app/pages/flows/index.d.vue.ts +0 -3
  186. package/dist/runtime/app/pages/flows/index.vue +0 -645
  187. package/dist/runtime/app/pages/flows/index.vue.d.ts +0 -3
  188. package/dist/runtime/app/pages/index.d.vue.ts +0 -3
  189. package/dist/runtime/app/pages/index.vue +0 -34
  190. package/dist/runtime/app/pages/index.vue.d.ts +0 -3
  191. package/dist/runtime/app/pages/queues/index.d.vue.ts +0 -3
  192. package/dist/runtime/app/pages/queues/index.vue +0 -229
  193. package/dist/runtime/app/pages/queues/index.vue.d.ts +0 -3
  194. package/dist/runtime/app/pages/queues/job.d.vue.ts +0 -3
  195. package/dist/runtime/app/pages/queues/job.vue +0 -262
  196. package/dist/runtime/app/pages/queues/job.vue.d.ts +0 -3
  197. package/dist/runtime/app/pages/queues/jobs.d.vue.ts +0 -3
  198. package/dist/runtime/app/pages/queues/jobs.vue +0 -291
  199. package/dist/runtime/app/pages/queues/jobs.vue.d.ts +0 -3
  200. package/dist/runtime/app/plugins/vueflow.client.d.ts +0 -2
  201. package/dist/runtime/app/plugins/vueflow.client.js +0 -11
  202. package/dist/runtime/constants.d.ts +0 -11
  203. package/dist/runtime/constants.js +0 -11
  204. package/dist/runtime/schema.d.ts +0 -37
  205. package/dist/runtime/schema.js +0 -20
  206. package/dist/runtime/server/api/_flows/[name]/clear-history.delete.d.ts +0 -10
  207. package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +0 -44
  208. package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +0 -7
  209. package/dist/runtime/server/api/_flows/[name]/runs.get.js +0 -53
  210. package/dist/runtime/server/api/_flows/[name]/schedule.post.js +0 -57
  211. package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.d.ts +0 -2
  212. package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +0 -42
  213. package/dist/runtime/server/api/_flows/[name]/schedules.get.d.ts +0 -2
  214. package/dist/runtime/server/api/_flows/[name]/schedules.get.js +0 -48
  215. package/dist/runtime/server/api/_flows/[name]/start.post.d.ts +0 -2
  216. package/dist/runtime/server/api/_flows/[name]/start.post.js +0 -9
  217. package/dist/runtime/server/api/_flows/index.get.d.ts +0 -6
  218. package/dist/runtime/server/api/_flows/index.get.js +0 -5
  219. package/dist/runtime/server/api/_flows/ws.d.ts +0 -60
  220. package/dist/runtime/server/api/_flows/ws.js +0 -188
  221. package/dist/runtime/server/api/_queues/[name]/job/[id].get.d.ts +0 -2
  222. package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +0 -9
  223. package/dist/runtime/server/api/_queues/[name]/job/index.get.d.ts +0 -2
  224. package/dist/runtime/server/api/_queues/[name]/job/index.get.js +0 -18
  225. package/dist/runtime/server/api/_queues/index.get.d.ts +0 -2
  226. package/dist/runtime/server/api/_queues/index.get.js +0 -63
  227. package/dist/runtime/server/api/_queues/ws.d.ts +0 -48
  228. package/dist/runtime/server/api/_queues/ws.js +0 -205
  229. package/dist/runtime/server/plugins/00.event-store.d.ts +0 -13
  230. package/dist/runtime/server/plugins/00.event-store.js +0 -16
  231. package/dist/runtime/server/plugins/flow-management.d.ts +0 -13
  232. package/dist/runtime/server/plugins/flow-management.js +0 -65
  233. package/dist/runtime/server/plugins/queue-management.d.ts +0 -2
  234. package/dist/runtime/server/plugins/queue-management.js +0 -27
  235. package/dist/runtime/server/plugins/state-cleanup.d.ts +0 -11
  236. package/dist/runtime/server/plugins/state-cleanup.js +0 -93
  237. package/dist/runtime/server/plugins/worker-management.d.ts +0 -2
  238. package/dist/runtime/server/plugins/worker-management.js +0 -33
  239. package/dist/runtime/server/tsconfig.json +0 -3
  240. package/dist/runtime/server-utils/events/adapters/fileAdapter.d.ts +0 -2
  241. package/dist/runtime/server-utils/events/adapters/fileAdapter.js +0 -382
  242. package/dist/runtime/server-utils/events/adapters/memoryAdapter.d.ts +0 -2
  243. package/dist/runtime/server-utils/events/adapters/memoryAdapter.js +0 -171
  244. package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.d.ts +0 -2
  245. package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.js +0 -348
  246. package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.d.ts +0 -30
  247. package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.js +0 -82
  248. package/dist/runtime/server-utils/events/eventStoreFactory.d.ts +0 -19
  249. package/dist/runtime/server-utils/events/eventStoreFactory.js +0 -44
  250. package/dist/runtime/server-utils/events/streamNames.d.ts +0 -17
  251. package/dist/runtime/server-utils/events/streamNames.js +0 -17
  252. package/dist/runtime/server-utils/events/types.d.ts +0 -63
  253. package/dist/runtime/server-utils/events/wiring/flowWiring.js +0 -409
  254. package/dist/runtime/server-utils/events/wiring/registry.d.ts +0 -10
  255. package/dist/runtime/server-utils/events/wiring/registry.js +0 -24
  256. package/dist/runtime/server-utils/queue/adapters/bullmq.d.ts +0 -18
  257. package/dist/runtime/server-utils/queue/adapters/bullmq.js +0 -164
  258. package/dist/runtime/server-utils/queue/queueFactory.d.ts +0 -3
  259. package/dist/runtime/server-utils/queue/queueFactory.js +0 -10
  260. package/dist/runtime/server-utils/queue/types.d.ts +0 -47
  261. package/dist/runtime/server-utils/state/adapters/redis.d.ts +0 -2
  262. package/dist/runtime/server-utils/state/adapters/redis.js +0 -42
  263. package/dist/runtime/server-utils/state/stateFactory.d.ts +0 -3
  264. package/dist/runtime/server-utils/state/stateFactory.js +0 -17
  265. package/dist/runtime/server-utils/state/types.d.ts +0 -23
  266. package/dist/runtime/server-utils/utils/defineQueueConfig.d.ts +0 -154
  267. package/dist/runtime/server-utils/utils/defineQueueConfig.js +0 -2
  268. package/dist/runtime/server-utils/utils/defineQueueWorker.d.ts +0 -10
  269. package/dist/runtime/server-utils/utils/defineQueueWorker.js +0 -17
  270. package/dist/runtime/server-utils/utils/useEventStore.d.ts +0 -20
  271. package/dist/runtime/server-utils/utils/useEventStore.js +0 -119
  272. package/dist/runtime/server-utils/utils/useFlowEngine.d.ts +0 -9
  273. package/dist/runtime/server-utils/utils/useFlowEngine.js +0 -44
  274. package/dist/runtime/server-utils/utils/useLogs.d.ts +0 -41
  275. package/dist/runtime/server-utils/utils/useLogs.js +0 -74
  276. package/dist/runtime/server-utils/utils/useQueue.d.ts +0 -31
  277. package/dist/runtime/server-utils/utils/useQueue.js +0 -24
  278. package/dist/runtime/server-utils/worker/adapter.d.ts +0 -4
  279. package/dist/runtime/server-utils/worker/adapter.js +0 -66
  280. package/dist/runtime/server-utils/worker/runner/node.d.ts +0 -27
  281. package/dist/runtime/server-utils/worker/runner/node.js +0 -196
  282. package/dist/runtime/types.d.ts +0 -132
  283. /package/dist/runtime/{server-utils/events/types.js → adapters/interfaces/queue.js} +0 -0
  284. /package/dist/runtime/{server-utils/queue/types.js → adapters/interfaces/store.js} +0 -0
  285. /package/dist/runtime/{server-utils/state/types.js → adapters/interfaces/stream.js} +0 -0
  286. /package/dist/runtime/{server-utils/events → events}/eventBus.js +0 -0
  287. /package/dist/runtime/{server/plugins/00.ws-lifecycle.d.ts → nitro/plugins/01.ws-lifecycle.d.ts} +0 -0
  288. /package/dist/runtime/{server/plugins/00.ws-lifecycle.js → nitro/plugins/01.ws-lifecycle.js} +0 -0
  289. /package/dist/runtime/{server/api/_flows/[name]/schedule.post.d.ts → nitro/plugins/02.workers.d.ts} +0 -0
  290. /package/dist/runtime/{server-utils → nitro}/utils/useNventLogger.d.ts +0 -0
  291. /package/dist/runtime/{server-utils → nitro}/utils/wsPeerManager.d.ts +0 -0
  292. /package/dist/runtime/{server-utils → nitro}/utils/wsPeerManager.js +0 -0
  293. /package/dist/runtime/{python → worker/python}/get_config.py +0 -0
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Scheduler Types
3
+ *
4
+ * Unified scheduling system for all time-based operations in nvent:
5
+ * - Stall detection
6
+ * - Await timeouts
7
+ * - Trigger schedules
8
+ * - Cleanup jobs
9
+ */
10
+ export interface ScheduledJob {
11
+ /**
12
+ * Unique job identifier
13
+ */
14
+ id: string;
15
+ /**
16
+ * Human-readable job name
17
+ */
18
+ name: string;
19
+ /**
20
+ * Job type
21
+ */
22
+ type: 'cron' | 'interval' | 'one-time';
23
+ /**
24
+ * Cron expression (for type: 'cron')
25
+ * @example '0 2 * * *' - Daily at 2 AM
26
+ * @example '* /5 * * * *' - Every 5 minutes
27
+ */
28
+ cron?: string;
29
+ /**
30
+ * Interval in milliseconds (for type: 'interval')
31
+ */
32
+ interval?: number;
33
+ /**
34
+ * Execution timestamp (for type: 'one-time')
35
+ */
36
+ executeAt?: number;
37
+ /**
38
+ * Job handler function
39
+ */
40
+ handler: () => Promise<void>;
41
+ /**
42
+ * Timezone for cron jobs
43
+ * @default 'UTC'
44
+ */
45
+ timezone?: string;
46
+ /**
47
+ * Whether the job is enabled
48
+ * @default true
49
+ */
50
+ enabled?: boolean;
51
+ /**
52
+ * Additional metadata
53
+ */
54
+ metadata?: Record<string, any>;
55
+ /**
56
+ * Last execution timestamp
57
+ */
58
+ lastRun?: number;
59
+ /**
60
+ * Next scheduled execution timestamp
61
+ */
62
+ nextRun?: number;
63
+ /**
64
+ * Total execution count
65
+ */
66
+ runCount?: number;
67
+ /**
68
+ * Failure count
69
+ */
70
+ failCount?: number;
71
+ }
72
+ export interface SchedulerAdapter {
73
+ /**
74
+ * Schedule a job with distributed locking support
75
+ */
76
+ schedule(job: ScheduledJob): Promise<string>;
77
+ /**
78
+ * Unschedule a job
79
+ */
80
+ unschedule(jobId: string): Promise<boolean>;
81
+ /**
82
+ * Start the scheduler (begins processing scheduled jobs)
83
+ */
84
+ start(): Promise<void>;
85
+ /**
86
+ * Stop the scheduler and release all locks
87
+ */
88
+ stop(): Promise<void>;
89
+ /**
90
+ * Get all scheduled jobs (in-memory, for this instance)
91
+ */
92
+ getScheduledJobs(): Promise<ScheduledJob[]>;
93
+ /**
94
+ * Get all persisted jobs from store (across all instances)
95
+ * Useful for debugging and monitoring in horizontal setups
96
+ */
97
+ getAllPersistedJobs(): Promise<ScheduledJob[]>;
98
+ /**
99
+ * Check if scheduler is healthy
100
+ */
101
+ isHealthy(): Promise<boolean>;
102
+ }
103
+ export interface SchedulerLock {
104
+ jobId: string;
105
+ instanceId: string;
106
+ acquiredAt: number;
107
+ expiresAt: number;
108
+ }
109
+ export interface SchedulerStats {
110
+ jobId: string;
111
+ lastRun: number;
112
+ nextRun?: number;
113
+ runCount: number;
114
+ failCount: number;
115
+ lastError?: string;
116
+ }
File without changes
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../../../playground/.nuxt/tsconfig.server.json",
3
+ "include": [
4
+ "./**/*.ts"
5
+ ],
6
+ "exclude": [
7
+ ]
8
+ }
@@ -0,0 +1,53 @@
1
+ import { useFlow } from '#imports';
2
+ /**
3
+ * Generic job interface that works with any queue adapter
4
+ * Adapters should provide jobs in this format
5
+ */
6
+ export interface QueueJob {
7
+ id: string;
8
+ name: string;
9
+ data: any;
10
+ attemptsMade?: number;
11
+ opts?: {
12
+ attempts?: number;
13
+ };
14
+ }
15
+ export interface RunLogger {
16
+ log: (level: 'debug' | 'info' | 'warn' | 'error', msg: string, meta?: any) => void;
17
+ }
18
+ export interface RunState {
19
+ get<T = any>(key: string): Promise<T | null>;
20
+ set<T = any>(key: string, value: T, opts?: {
21
+ ttl?: number;
22
+ }): Promise<void>;
23
+ delete(key: string): Promise<void>;
24
+ }
25
+ export interface RunContext {
26
+ jobId?: string;
27
+ queue?: string;
28
+ flowId?: string;
29
+ flowName?: string;
30
+ stepName?: string;
31
+ stepId?: string;
32
+ attempt?: number;
33
+ logger: RunLogger;
34
+ state: RunState;
35
+ flow: ReturnType<typeof useFlow>;
36
+ /**
37
+ * Resolved data from await pattern (awaitBefore only)
38
+ * Available when step resumes after await resolution
39
+ */
40
+ trigger?: any;
41
+ /**
42
+ * Current step's await configuration
43
+ * Useful for conditional logic based on await settings
44
+ */
45
+ awaitConfig?: any;
46
+ }
47
+ export declare function buildContext(partial?: Partial<RunContext>): RunContext;
48
+ export type NodeHandler = (input: any, ctx: RunContext) => Promise<any>;
49
+ /**
50
+ * Wraps a NodeHandler with full RunContext building and event emission
51
+ * Works with any queue adapter by accepting a job-like object
52
+ */
53
+ export declare function createJobProcessor(handler: NodeHandler, queueName: string): (job: QueueJob) => Promise<any>;
@@ -0,0 +1,327 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import {
3
+ useRuntimeConfig,
4
+ useFlow,
5
+ useEventManager,
6
+ useNventLogger,
7
+ $useFunctionRegistry,
8
+ useAwait,
9
+ useHookRegistry,
10
+ useStreamTopics,
11
+ useStateAdapter,
12
+ useStoreAdapter,
13
+ useRunContext
14
+ } from "#imports";
15
+ const logger = useNventLogger("node-runner");
16
+ const defaultState = {
17
+ async get() {
18
+ return null;
19
+ },
20
+ async set() {
21
+ },
22
+ async delete() {
23
+ }
24
+ };
25
+ function scopeKey(baseKey, flowId) {
26
+ if (!flowId) return baseKey;
27
+ return `flow:${flowId}:${baseKey}`;
28
+ }
29
+ export function buildContext(partial) {
30
+ const state = partial?.state || (() => {
31
+ try {
32
+ const stateAdapter = useStateAdapter();
33
+ const rc = useRuntimeConfig();
34
+ const cleanupCfg = rc?.nvent?.state?.cleanup || { strategy: "never" };
35
+ return {
36
+ async get(key) {
37
+ return stateAdapter.get(scopeKey(key, partial?.flowId));
38
+ },
39
+ async set(key, value, opts) {
40
+ const ttl = opts?.ttl ?? (cleanupCfg?.strategy === "ttl" ? cleanupCfg?.ttlMs : void 0);
41
+ return stateAdapter.set(scopeKey(key, partial?.flowId), value, ttl ? { ttl } : void 0);
42
+ },
43
+ async delete(key) {
44
+ return stateAdapter.delete(scopeKey(key, partial?.flowId));
45
+ }
46
+ };
47
+ } catch {
48
+ return defaultState;
49
+ }
50
+ })();
51
+ const logger2 = partial?.logger || (() => {
52
+ const eventManager = useEventManager();
53
+ return {
54
+ log: (level, msg, meta) => {
55
+ const runId = partial?.flowId || "unknown";
56
+ const flowName = meta?.flowName || "unknown";
57
+ void eventManager.publishBus({
58
+ type: "log",
59
+ runId,
60
+ flowName,
61
+ stepName: meta?.stepName,
62
+ stepId: meta?.stepId || meta?.stepRunId,
63
+ attempt: meta?.attempt,
64
+ data: { level, message: msg, ...meta }
65
+ });
66
+ }
67
+ };
68
+ })();
69
+ const baseFlowEngine = useFlow();
70
+ const flow = {
71
+ ...baseFlowEngine,
72
+ emit: async (trigger, payload = {}) => {
73
+ const enrichedPayload = {
74
+ ...payload,
75
+ flowId: payload.flowId || partial?.flowId,
76
+ flowName: payload.flowName || partial?.flowName,
77
+ stepName: payload.stepName || partial?.stepName
78
+ };
79
+ return baseFlowEngine.emit(trigger, enrichedPayload);
80
+ },
81
+ cancel: async () => {
82
+ if (!partial?.flowName || !partial?.flowId) {
83
+ throw new Error("Cannot cancel flow: flowName or flowId not available in context");
84
+ }
85
+ return baseFlowEngine.cancelFlow(partial.flowName, partial.flowId);
86
+ },
87
+ isRunning: async (flowName, runId) => {
88
+ const targetFlowName = flowName || partial?.flowName;
89
+ if (!targetFlowName) {
90
+ throw new Error("flowName is required to check if flow is running");
91
+ }
92
+ return baseFlowEngine.isRunning(targetFlowName, runId);
93
+ },
94
+ getRunningFlows: async (flowName) => {
95
+ const targetFlowName = flowName || partial?.flowName;
96
+ if (!targetFlowName) {
97
+ throw new Error("flowName is required to get running flows");
98
+ }
99
+ return baseFlowEngine.getRunningFlows(targetFlowName);
100
+ }
101
+ };
102
+ return {
103
+ jobId: partial?.jobId,
104
+ queue: partial?.queue,
105
+ flowId: partial?.flowId,
106
+ flowName: partial?.flowName,
107
+ stepName: partial?.stepName,
108
+ stepId: partial?.stepId,
109
+ attempt: partial?.attempt,
110
+ logger: logger2,
111
+ state,
112
+ flow,
113
+ trigger: partial?.trigger,
114
+ awaitConfig: partial?.awaitConfig
115
+ };
116
+ }
117
+ export function createJobProcessor(handler, queueName) {
118
+ return async function processor(job) {
119
+ const eventMgr = useEventManager();
120
+ const rc = useRuntimeConfig();
121
+ const autoScope = rc?.nvent?.store?.state?.autoScope || "always";
122
+ const providedFlow = job.data?.flowId;
123
+ const flowId = providedFlow || (autoScope === "always" ? randomUUID() : void 0);
124
+ const attempt = (job.attemptsMade || 0) + 1;
125
+ const maxAttempts = job.opts?.attempts || 1;
126
+ const isFinalAttempt = attempt >= maxAttempts;
127
+ const stepRunId = `${String(flowId || job.id)}__${job.name}__attempt-${attempt}`;
128
+ const flowName = job.data?.flowName || "unknown";
129
+ const registry = $useFunctionRegistry();
130
+ const flowRegistry = (registry?.flows || {})[flowName];
131
+ let stepMeta = flowRegistry?.steps?.[job.name];
132
+ if (!stepMeta && flowRegistry?.entry?.step === job.name) {
133
+ stepMeta = flowRegistry?.entry;
134
+ }
135
+ const awaitBefore = stepMeta?.awaitBefore;
136
+ const awaitAfter = stepMeta?.awaitAfter;
137
+ const isAwaitResume = job.data?.awaitResolved === true;
138
+ const awaitData = job.data?.awaitData;
139
+ if (awaitBefore && !isAwaitResume) {
140
+ const awaitLogger = useNventLogger("await-before");
141
+ awaitLogger.info("Step has awaitBefore, registering await pattern", {
142
+ flowName,
143
+ runId: flowId,
144
+ stepName: job.name,
145
+ awaitType: awaitBefore.type
146
+ });
147
+ try {
148
+ const { register } = useAwait();
149
+ const awaitResult = await register(
150
+ flowId || "unknown",
151
+ job.name,
152
+ flowName,
153
+ awaitBefore,
154
+ "before"
155
+ // Position: awaitBefore means wait before execution
156
+ );
157
+ const hookRegistry = useHookRegistry();
158
+ const hooks = hookRegistry.load(flowName, job.name);
159
+ if (hooks?.onAwaitRegister) {
160
+ try {
161
+ await hooks.onAwaitRegister(
162
+ awaitResult.webhookUrl || awaitResult.eventName || "",
163
+ job.data,
164
+ useRunContext({ flowId, flowName, stepName: job.name })
165
+ );
166
+ } catch (err) {
167
+ awaitLogger.error("onAwaitRegister hook failed", { error: err.message });
168
+ }
169
+ }
170
+ return {
171
+ awaiting: true,
172
+ awaitType: awaitBefore.type,
173
+ awaitConfig: awaitBefore
174
+ };
175
+ } catch (err) {
176
+ awaitLogger.error("Failed to register await pattern", {
177
+ error: err.message,
178
+ stack: err.stack
179
+ });
180
+ }
181
+ }
182
+ const ctx = buildContext({
183
+ jobId: job.id,
184
+ queue: queueName,
185
+ flowId,
186
+ flowName,
187
+ stepName: job.name,
188
+ stepId: stepRunId,
189
+ attempt,
190
+ trigger: isAwaitResume ? awaitData : void 0,
191
+ awaitConfig: awaitBefore || awaitAfter || void 0
192
+ });
193
+ const attemptLogger = {
194
+ log: (level, msg, meta) => {
195
+ const enriched = { ...meta || {}, stepName: job.name, attempt, stepRunId, flowName };
196
+ ctx.logger.log(level, msg, enriched);
197
+ }
198
+ };
199
+ try {
200
+ await eventMgr.publishBus({
201
+ type: "step.started",
202
+ runId: flowId || "unknown",
203
+ flowName,
204
+ stepName: job.name,
205
+ stepId: stepRunId,
206
+ attempt,
207
+ data: { jobId: job.id, name: job.name, queue: queueName }
208
+ });
209
+ } catch {
210
+ }
211
+ let result;
212
+ try {
213
+ const workerInput = job.data?.input !== void 0 ? job.data.input : job.data;
214
+ result = await handler(workerInput, { ...ctx, logger: attemptLogger });
215
+ } catch (err) {
216
+ logger.error(`[worker] Job failed: ${job.name} (${job.id})`, {
217
+ queue: queueName,
218
+ flowId,
219
+ flowName,
220
+ stepName: job.name,
221
+ error: err?.message || String(err),
222
+ stack: err?.stack
223
+ });
224
+ const willRetry = !isFinalAttempt;
225
+ if (willRetry) {
226
+ try {
227
+ await eventMgr.publishBus({
228
+ type: "step.retry",
229
+ runId: flowId || "unknown",
230
+ flowName,
231
+ stepName: job.name,
232
+ stepId: stepRunId,
233
+ attempt,
234
+ data: {
235
+ stepName: job.name,
236
+ queue: queueName,
237
+ attempt,
238
+ maxAttempts,
239
+ nextAttempt: attempt + 1,
240
+ error: String(err?.message || err),
241
+ stack: err?.stack
242
+ }
243
+ });
244
+ } catch {
245
+ }
246
+ } else {
247
+ try {
248
+ await eventMgr.publishBus({
249
+ type: "step.failed",
250
+ runId: flowId || "unknown",
251
+ flowName,
252
+ stepName: job.name,
253
+ stepId: stepRunId,
254
+ attempt,
255
+ data: {
256
+ error: String(err?.message || err),
257
+ stack: err?.stack
258
+ }
259
+ });
260
+ } catch {
261
+ }
262
+ }
263
+ throw err;
264
+ }
265
+ try {
266
+ const eventMgr2 = useEventManager();
267
+ await eventMgr2.publishBus({
268
+ type: "step.completed",
269
+ runId: flowId || "unknown",
270
+ flowName,
271
+ stepName: job.name,
272
+ stepId: stepRunId,
273
+ attempt,
274
+ data: { result }
275
+ });
276
+ } catch {
277
+ }
278
+ if (awaitAfter && !isAwaitResume) {
279
+ const awaitLogger = useNventLogger("await-after");
280
+ awaitLogger.info("Step has awaitAfter, registering await pattern", {
281
+ flowName,
282
+ runId: flowId,
283
+ stepName: job.name,
284
+ awaitType: awaitAfter.type
285
+ });
286
+ try {
287
+ const store = useStoreAdapter();
288
+ const { StoreSubjects } = useStreamTopics();
289
+ const streamName = StoreSubjects.flowRun(flowId || "unknown");
290
+ let _emitEvents = [];
291
+ if (store.stream.read) {
292
+ const recentEvents = await store.stream.read(streamName, { limit: 100 });
293
+ _emitEvents = recentEvents.filter(
294
+ (evt) => evt.type === "emit" && evt.stepName === job.name && evt.stepId === stepRunId
295
+ );
296
+ }
297
+ const { register } = useAwait();
298
+ const awaitResult = await register(
299
+ flowId || "unknown",
300
+ job.name,
301
+ flowName,
302
+ awaitAfter,
303
+ "after"
304
+ );
305
+ const hookRegistry = useHookRegistry();
306
+ const hooks = hookRegistry.load(flowName, job.name);
307
+ if (hooks?.onAwaitRegister) {
308
+ try {
309
+ await hooks.onAwaitRegister(
310
+ awaitResult.webhookUrl || awaitResult.eventName || "",
311
+ { ...job.data, result },
312
+ ctx
313
+ );
314
+ } catch (err) {
315
+ awaitLogger.error("onAwaitRegister hook failed", { error: err.message });
316
+ }
317
+ }
318
+ } catch (err) {
319
+ awaitLogger.error("Failed to register awaitAfter pattern", {
320
+ error: err.message,
321
+ stack: err.stack
322
+ });
323
+ }
324
+ }
325
+ return result;
326
+ };
327
+ }
package/dist/types.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- export { default } from './module.mjs'
1
+ export { type ModuleOptions } from '../dist/runtime/config/types.js'
2
2
 
3
- export { type ModuleOptions } from './module.mjs'
3
+ export { default } from './module.mjs'
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "nvent",
3
- "version": "0.4.4",
4
- "description": "Nuxt queue service based on Bullmq",
5
- "repository": "DevJoghurt/nuxt-queue",
3
+ "version": "0.5.0",
4
+ "description": "Event-driven workflows for Nuxt",
5
+ "repository": "DevJoghurt/nvent",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "exports": {
@@ -12,64 +12,34 @@
12
12
  }
13
13
  },
14
14
  "main": "./dist/module.mjs",
15
+ "types": "./dist/types.d.mts",
15
16
  "files": [
16
17
  "dist"
17
18
  ],
18
19
  "scripts": {
19
- "build": "yarn dev:prepare && nuxt-module-build build",
20
- "dev": "nuxi dev playground",
21
- "dev:build": "nuxi build playground",
22
- "dev:preview": "nuxi preview playground",
23
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
24
- "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
25
- "test": "vitest",
26
- "lint": "eslint --ext .ts,.js,.mjs,.cjs,.vue .",
27
- "cleanup": "rimraf dist*/ **/node_modules .nuxt* playground/.data",
28
- "bumpp": "bumpp"
20
+ "build": "nuxt-module-build build",
21
+ "dev": "nuxt-module-build build --stub",
22
+ "prepack": "pnpm build"
29
23
  },
30
24
  "dependencies": {
31
- "@babel/parser": "^7.28.5",
32
- "@iconify-json/devicon": "^1.2.46",
33
- "@iconify-json/heroicons": "1.2.3",
34
- "@iconify-json/lucide": "^1.2.72",
35
25
  "@nuxt/kit": "4.2.1",
36
- "@vue-flow/background": "^1.3.2",
37
- "@vue-flow/controls": "^1.1.3",
38
- "@vue-flow/core": "^1.47.0",
39
- "@vue-flow/minimap": "^1.5.4",
40
- "bullmq": "^5.63.0",
41
- "chokidar": "^4.0.3",
26
+ "chokidar": "^5.0.0",
27
+ "cron": "^4.3.5",
28
+ "cron-parser": "^5.4.0",
42
29
  "defu": "^6.1.4",
43
- "globby": "15.0.0",
44
- "ioredis": "^5.8.2",
45
- "json-editor-vue": "^0.18.1",
30
+ "fastq": "^1.19.1",
31
+ "globby": "16.0.0",
46
32
  "magicast": "^0.5.1",
47
- "mlly": "^1.8.0",
48
- "node-ts": "8.0.8",
49
33
  "nuxt": "4.2.1",
50
34
  "pathe": "^2.0.3",
51
35
  "perfect-debounce": "^2.0.0",
52
- "pkg-types": "^2.3.0",
53
- "semver": "^7.7.3",
54
- "zod": "^4.1.12"
36
+ "zod": "^4.1.13"
55
37
  },
56
38
  "devDependencies": {
57
- "@nuxt/devtools": "^3.0.1",
58
- "@nuxt/eslint-config": "^1.10.0",
59
39
  "@nuxt/module-builder": "^1.0.2",
60
40
  "@nuxt/schema": "4.2.1",
61
- "@nuxt/test-utils": "^3.20.1",
62
- "@nuxt/ui": "4.1.0",
63
- "@types/node": "^24.10.0",
64
- "bumpp": "10.3.1",
65
- "changelogen": "^0.6.2",
66
- "eslint": "^9.39.1",
67
- "nuxi": "^3.30.0",
68
- "nuxt-mcp": "0.2.6",
69
- "rimraf": "^6.1.0",
41
+ "@types/node": "^24.10.1",
70
42
  "typescript": "latest",
71
- "vitest": "^4.0.7",
72
- "vue-tsc": "^3.1.3"
73
- },
74
- "packageManager": "yarn@4.10.3"
43
+ "vitest": "^4.0.15"
44
+ }
75
45
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Johannes Hof
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.