nvent 0.4.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 (192) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +389 -0
  3. package/dist/module.d.mts +193 -0
  4. package/dist/module.json +9 -0
  5. package/dist/module.mjs +974 -0
  6. package/dist/runtime/app/components/ConfirmDialog.d.vue.ts +33 -0
  7. package/dist/runtime/app/components/ConfirmDialog.vue +121 -0
  8. package/dist/runtime/app/components/ConfirmDialog.vue.d.ts +33 -0
  9. package/dist/runtime/app/components/FlowDiagram.d.vue.ts +64 -0
  10. package/dist/runtime/app/components/FlowDiagram.vue +338 -0
  11. package/dist/runtime/app/components/FlowDiagram.vue.d.ts +64 -0
  12. package/dist/runtime/app/components/FlowNodeCard.d.vue.ts +29 -0
  13. package/dist/runtime/app/components/FlowNodeCard.vue +156 -0
  14. package/dist/runtime/app/components/FlowNodeCard.vue.d.ts +29 -0
  15. package/dist/runtime/app/components/FlowRunOverview.d.vue.ts +9 -0
  16. package/dist/runtime/app/components/FlowRunOverview.vue +291 -0
  17. package/dist/runtime/app/components/FlowRunOverview.vue.d.ts +9 -0
  18. package/dist/runtime/app/components/FlowRunStatusBadge.d.vue.ts +14 -0
  19. package/dist/runtime/app/components/FlowRunStatusBadge.vue +60 -0
  20. package/dist/runtime/app/components/FlowRunStatusBadge.vue.d.ts +14 -0
  21. package/dist/runtime/app/components/FlowRunTimeline.d.vue.ts +12 -0
  22. package/dist/runtime/app/components/FlowRunTimeline.vue +127 -0
  23. package/dist/runtime/app/components/FlowRunTimeline.vue.d.ts +12 -0
  24. package/dist/runtime/app/components/FlowScheduleDialog.d.vue.ts +16 -0
  25. package/dist/runtime/app/components/FlowScheduleDialog.vue +226 -0
  26. package/dist/runtime/app/components/FlowScheduleDialog.vue.d.ts +16 -0
  27. package/dist/runtime/app/components/FlowSchedulesList.d.vue.ts +12 -0
  28. package/dist/runtime/app/components/FlowSchedulesList.vue +99 -0
  29. package/dist/runtime/app/components/FlowSchedulesList.vue.d.ts +12 -0
  30. package/dist/runtime/app/components/JobScheduling.d.vue.ts +6 -0
  31. package/dist/runtime/app/components/JobScheduling.vue +203 -0
  32. package/dist/runtime/app/components/JobScheduling.vue.d.ts +6 -0
  33. package/dist/runtime/app/components/ListItem.d.vue.ts +23 -0
  34. package/dist/runtime/app/components/ListItem.vue +70 -0
  35. package/dist/runtime/app/components/ListItem.vue.d.ts +23 -0
  36. package/dist/runtime/app/components/QueueConfigDetails.d.vue.ts +45 -0
  37. package/dist/runtime/app/components/QueueConfigDetails.vue +412 -0
  38. package/dist/runtime/app/components/QueueConfigDetails.vue.d.ts +45 -0
  39. package/dist/runtime/app/components/StatCounter.d.vue.ts +9 -0
  40. package/dist/runtime/app/components/StatCounter.vue +25 -0
  41. package/dist/runtime/app/components/StatCounter.vue.d.ts +9 -0
  42. package/dist/runtime/app/components/TimelineList.d.vue.ts +7 -0
  43. package/dist/runtime/app/components/TimelineList.vue +210 -0
  44. package/dist/runtime/app/components/TimelineList.vue.d.ts +7 -0
  45. package/dist/runtime/app/components/nhealth/component-router.d.vue.ts +46 -0
  46. package/dist/runtime/app/components/nhealth/component-router.vue +26 -0
  47. package/dist/runtime/app/components/nhealth/component-router.vue.d.ts +46 -0
  48. package/dist/runtime/app/components/nhealth/component-shell.d.vue.ts +24 -0
  49. package/dist/runtime/app/components/nhealth/component-shell.vue +89 -0
  50. package/dist/runtime/app/components/nhealth/component-shell.vue.d.ts +24 -0
  51. package/dist/runtime/app/composables/useAnalyzedFlows.d.ts +14 -0
  52. package/dist/runtime/app/composables/useAnalyzedFlows.js +7 -0
  53. package/dist/runtime/app/composables/useComponentRouter.d.ts +38 -0
  54. package/dist/runtime/app/composables/useComponentRouter.js +240 -0
  55. package/dist/runtime/app/composables/useFlowRunTimeline.d.ts +15 -0
  56. package/dist/runtime/app/composables/useFlowRunTimeline.js +66 -0
  57. package/dist/runtime/app/composables/useFlowRuns.d.ts +11 -0
  58. package/dist/runtime/app/composables/useFlowRuns.js +31 -0
  59. package/dist/runtime/app/composables/useFlowRunsInfinite.d.ts +24 -0
  60. package/dist/runtime/app/composables/useFlowRunsInfinite.js +123 -0
  61. package/dist/runtime/app/composables/useFlowRunsPolling.d.ts +8 -0
  62. package/dist/runtime/app/composables/useFlowRunsPolling.js +26 -0
  63. package/dist/runtime/app/composables/useFlowState.d.ts +125 -0
  64. package/dist/runtime/app/composables/useFlowState.js +211 -0
  65. package/dist/runtime/app/composables/useFlowWebSocket.d.ts +27 -0
  66. package/dist/runtime/app/composables/useFlowWebSocket.js +205 -0
  67. package/dist/runtime/app/composables/useFlowsNavigation.d.ts +10 -0
  68. package/dist/runtime/app/composables/useFlowsNavigation.js +57 -0
  69. package/dist/runtime/app/composables/useQueueJobs.d.ts +20 -0
  70. package/dist/runtime/app/composables/useQueueJobs.js +20 -0
  71. package/dist/runtime/app/composables/useQueueUpdates.d.ts +26 -0
  72. package/dist/runtime/app/composables/useQueueUpdates.js +122 -0
  73. package/dist/runtime/app/composables/useQueues.d.ts +43 -0
  74. package/dist/runtime/app/composables/useQueues.js +26 -0
  75. package/dist/runtime/app/composables/useQueuesLive.d.ts +19 -0
  76. package/dist/runtime/app/composables/useQueuesLive.js +143 -0
  77. package/dist/runtime/app/pages/flows/index.d.vue.ts +3 -0
  78. package/dist/runtime/app/pages/flows/index.vue +645 -0
  79. package/dist/runtime/app/pages/flows/index.vue.d.ts +3 -0
  80. package/dist/runtime/app/pages/index.d.vue.ts +3 -0
  81. package/dist/runtime/app/pages/index.vue +34 -0
  82. package/dist/runtime/app/pages/index.vue.d.ts +3 -0
  83. package/dist/runtime/app/pages/queues/index.d.vue.ts +3 -0
  84. package/dist/runtime/app/pages/queues/index.vue +229 -0
  85. package/dist/runtime/app/pages/queues/index.vue.d.ts +3 -0
  86. package/dist/runtime/app/pages/queues/job.d.vue.ts +3 -0
  87. package/dist/runtime/app/pages/queues/job.vue +262 -0
  88. package/dist/runtime/app/pages/queues/job.vue.d.ts +3 -0
  89. package/dist/runtime/app/pages/queues/jobs.d.vue.ts +3 -0
  90. package/dist/runtime/app/pages/queues/jobs.vue +291 -0
  91. package/dist/runtime/app/pages/queues/jobs.vue.d.ts +3 -0
  92. package/dist/runtime/app/plugins/vueflow.client.d.ts +6 -0
  93. package/dist/runtime/app/plugins/vueflow.client.js +15 -0
  94. package/dist/runtime/constants.d.ts +11 -0
  95. package/dist/runtime/constants.js +11 -0
  96. package/dist/runtime/python/get_config.py +64 -0
  97. package/dist/runtime/schema.d.ts +37 -0
  98. package/dist/runtime/schema.js +20 -0
  99. package/dist/runtime/server/api/_flows/[name]/clear-history.delete.d.ts +10 -0
  100. package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +44 -0
  101. package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +7 -0
  102. package/dist/runtime/server/api/_flows/[name]/runs.get.js +53 -0
  103. package/dist/runtime/server/api/_flows/[name]/schedule.post.d.ts +2 -0
  104. package/dist/runtime/server/api/_flows/[name]/schedule.post.js +57 -0
  105. package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.d.ts +2 -0
  106. package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +42 -0
  107. package/dist/runtime/server/api/_flows/[name]/schedules.get.d.ts +2 -0
  108. package/dist/runtime/server/api/_flows/[name]/schedules.get.js +48 -0
  109. package/dist/runtime/server/api/_flows/[name]/start.post.d.ts +2 -0
  110. package/dist/runtime/server/api/_flows/[name]/start.post.js +9 -0
  111. package/dist/runtime/server/api/_flows/index.get.d.ts +6 -0
  112. package/dist/runtime/server/api/_flows/index.get.js +5 -0
  113. package/dist/runtime/server/api/_flows/ws.d.ts +60 -0
  114. package/dist/runtime/server/api/_flows/ws.js +183 -0
  115. package/dist/runtime/server/api/_queues/[name]/job/[id].get.d.ts +2 -0
  116. package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +9 -0
  117. package/dist/runtime/server/api/_queues/[name]/job/index.get.d.ts +2 -0
  118. package/dist/runtime/server/api/_queues/[name]/job/index.get.js +18 -0
  119. package/dist/runtime/server/api/_queues/index.get.d.ts +2 -0
  120. package/dist/runtime/server/api/_queues/index.get.js +63 -0
  121. package/dist/runtime/server/api/_queues/ws.d.ts +48 -0
  122. package/dist/runtime/server/api/_queues/ws.js +200 -0
  123. package/dist/runtime/server/events/adapters/fileAdapter.d.ts +2 -0
  124. package/dist/runtime/server/events/adapters/fileAdapter.js +382 -0
  125. package/dist/runtime/server/events/adapters/memoryAdapter.d.ts +2 -0
  126. package/dist/runtime/server/events/adapters/memoryAdapter.js +171 -0
  127. package/dist/runtime/server/events/adapters/redis/redisAdapter.d.ts +2 -0
  128. package/dist/runtime/server/events/adapters/redis/redisAdapter.js +348 -0
  129. package/dist/runtime/server/events/adapters/redis/redisPubSubGateway.d.ts +29 -0
  130. package/dist/runtime/server/events/adapters/redis/redisPubSubGateway.js +82 -0
  131. package/dist/runtime/server/events/eventBus.d.ts +20 -0
  132. package/dist/runtime/server/events/eventBus.js +35 -0
  133. package/dist/runtime/server/events/eventStoreFactory.d.ts +19 -0
  134. package/dist/runtime/server/events/eventStoreFactory.js +44 -0
  135. package/dist/runtime/server/events/streamNames.d.ts +17 -0
  136. package/dist/runtime/server/events/streamNames.js +17 -0
  137. package/dist/runtime/server/events/types.d.ts +63 -0
  138. package/dist/runtime/server/events/types.js +0 -0
  139. package/dist/runtime/server/events/wiring/flowWiring.d.ts +33 -0
  140. package/dist/runtime/server/events/wiring/flowWiring.js +406 -0
  141. package/dist/runtime/server/events/wiring/registry.d.ts +10 -0
  142. package/dist/runtime/server/events/wiring/registry.js +24 -0
  143. package/dist/runtime/server/plugins/00.event-store.d.ts +13 -0
  144. package/dist/runtime/server/plugins/00.event-store.js +16 -0
  145. package/dist/runtime/server/plugins/00.ws-lifecycle.d.ts +5 -0
  146. package/dist/runtime/server/plugins/00.ws-lifecycle.js +66 -0
  147. package/dist/runtime/server/plugins/flow-management.d.ts +13 -0
  148. package/dist/runtime/server/plugins/flow-management.js +65 -0
  149. package/dist/runtime/server/plugins/queue-management.d.ts +2 -0
  150. package/dist/runtime/server/plugins/queue-management.js +27 -0
  151. package/dist/runtime/server/plugins/state-cleanup.d.ts +11 -0
  152. package/dist/runtime/server/plugins/state-cleanup.js +93 -0
  153. package/dist/runtime/server/plugins/worker-management.d.ts +2 -0
  154. package/dist/runtime/server/plugins/worker-management.js +33 -0
  155. package/dist/runtime/server/queue/adapters/bullmq.d.ts +17 -0
  156. package/dist/runtime/server/queue/adapters/bullmq.js +164 -0
  157. package/dist/runtime/server/queue/queueFactory.d.ts +3 -0
  158. package/dist/runtime/server/queue/queueFactory.js +10 -0
  159. package/dist/runtime/server/queue/types.d.ts +47 -0
  160. package/dist/runtime/server/queue/types.js +0 -0
  161. package/dist/runtime/server/state/adapters/redis.d.ts +2 -0
  162. package/dist/runtime/server/state/adapters/redis.js +42 -0
  163. package/dist/runtime/server/state/stateFactory.d.ts +3 -0
  164. package/dist/runtime/server/state/stateFactory.js +17 -0
  165. package/dist/runtime/server/state/types.d.ts +23 -0
  166. package/dist/runtime/server/state/types.js +0 -0
  167. package/dist/runtime/server/tsconfig.json +3 -0
  168. package/dist/runtime/server/utils/defineQueueConfig.d.ts +154 -0
  169. package/dist/runtime/server/utils/defineQueueConfig.js +2 -0
  170. package/dist/runtime/server/utils/defineQueueWorker.d.ts +10 -0
  171. package/dist/runtime/server/utils/defineQueueWorker.js +17 -0
  172. package/dist/runtime/server/utils/useEventManager.d.ts +15 -0
  173. package/dist/runtime/server/utils/useEventManager.js +26 -0
  174. package/dist/runtime/server/utils/useEventStore.d.ts +20 -0
  175. package/dist/runtime/server/utils/useEventStore.js +119 -0
  176. package/dist/runtime/server/utils/useFlowEngine.d.ts +9 -0
  177. package/dist/runtime/server/utils/useFlowEngine.js +44 -0
  178. package/dist/runtime/server/utils/useLogs.d.ts +41 -0
  179. package/dist/runtime/server/utils/useLogs.js +74 -0
  180. package/dist/runtime/server/utils/useQueue.d.ts +31 -0
  181. package/dist/runtime/server/utils/useQueue.js +24 -0
  182. package/dist/runtime/server/utils/useServerLogger.d.ts +42 -0
  183. package/dist/runtime/server/utils/useServerLogger.js +54 -0
  184. package/dist/runtime/server/utils/wsPeerManager.d.ts +34 -0
  185. package/dist/runtime/server/utils/wsPeerManager.js +23 -0
  186. package/dist/runtime/server/worker/adapter.d.ts +4 -0
  187. package/dist/runtime/server/worker/adapter.js +65 -0
  188. package/dist/runtime/server/worker/runner/node.d.ts +27 -0
  189. package/dist/runtime/server/worker/runner/node.js +196 -0
  190. package/dist/runtime/types.d.ts +132 -0
  191. package/dist/types.d.mts +3 -0
  192. package/package.json +75 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
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.
package/README.md ADDED
@@ -0,0 +1,389 @@
1
+ # Nuxt Queue
2
+
3
+ Event-sourced queue and flow orchestration for Nuxt. Built on BullMQ with integrated real-time monitoring and multi-step workflow support.
4
+
5
+ ## ✨ Features
6
+
7
+ - 🔄 **Queue Management**: Reliable job processing with BullMQ
8
+ - 🎭 **Flow Orchestration**: Multi-step workflows with event sourcing
9
+ - ⏰ **Flow Scheduling**: Cron-based and delayed flow execution
10
+ - ⚡ **Real-time Updates**: Redis Pub/Sub for <100ms latency monitoring
11
+ - 📊 **Event Sourcing**: Complete audit trail of all flow operations
12
+ - 🎨 **Development UI**: Visual flow diagrams, timeline, and scheduling
13
+ - 🔌 **Worker Context**: Rich runtime with state, logging, and events
14
+ - 📦 **Auto-discovery**: Filesystem-based worker registry
15
+ - 🚀 **Horizontal Scaling**: Stateless architecture for easy scaling
16
+ - 🔍 **Full Observability**: Real-time logs, metrics, and event streams
17
+
18
+
19
+ ---
20
+
21
+ **Version**: v0.4.0
22
+ **Status**: ✅ Current Implementation
23
+ **Last Updated**: 2025-11-07
24
+ ✅ Core queue and flow functionality
25
+ ✅ Event sourcing with Redis Streams
26
+ ✅ Real-time monitoring UI with Vue Flow diagrams
27
+ ✅ Flow scheduling (cron patterns and delays)
28
+ ✅ Worker context with state, logging, and events
29
+ ✅ Auto-discovery and flow analysis
30
+ 🚧 Comprehensive trigger system (planned v0.5)
31
+ 🚧 Python workers (planned v0.5)
32
+ 🚧 Postgres adapters (planned v0.6)
33
+
34
+
35
+ ## 🗃️ Event Schema & Storage
36
+
37
+ All flow operations are event-sourced and stored in Redis Streams (`nq:flow:<runId>`). Events are immutable, type-safe, and provide a complete audit trail.
38
+
39
+ **Event types:**
40
+
41
+ - `flow.start`, `flow.completed`, `flow.failed`
42
+ - `step.started`, `step.completed`, `step.failed`, `step.retry`
43
+ - `log`, `emit`, `state`
44
+
45
+ See [Event Schema](./specs/v0.4/event-schema.md) for full details and field definitions.
46
+
47
+ ## 🏆 Best Practices
48
+
49
+ - Keep steps small and focused
50
+ - Use state for shared data between steps
51
+ - Use `ctx.flow.emit()` to trigger downstream steps
52
+ - Log with context using `ctx.logger.log()`
53
+ - Set concurrency based on resource needs
54
+ - Use `on-complete` state cleanup for automatic state management
55
+ - Document schedules with metadata for maintainability
56
+
57
+ ## ⚠️ Limitations (v0.4)
58
+
59
+ 1. **TypeScript only**: Python workers not yet implemented (planned for v0.5)
60
+ 2. **No complex triggers**: Only basic scheduling available (v0.5 will add triggers)
61
+ 3. **No await patterns**: Pausing flows for time/events planned for v0.5
62
+ 4. **Redis only**: No Postgres adapter yet (planned for v0.6)
63
+ 5. **State separate from events**: Not unified with stream store (planned for v0.6)
64
+ 6. **Basic logging**: No advanced logger adapters (planned for v0.7)
65
+ 7. **No schedule editing**: Must delete and recreate schedules (v0.5 will add full trigger management)
66
+
67
+
68
+ ## 🚀 Quick Start
69
+
70
+ ### Installation
71
+
72
+ ```sh
73
+ npx nuxi@latest module add nuxt-queue
74
+ ```
75
+
76
+ ### Configuration
77
+
78
+ ```ts
79
+ // nuxt.config.ts
80
+ export default defineNuxtConfig({
81
+ modules: ['nuxt-queue'],
82
+ queue: {
83
+ ui: true, // Enable dev UI
84
+ // Shortcut: Configure all backends with one setting
85
+ store: {
86
+ adapter: 'redis',
87
+ redis: {
88
+ host: '127.0.0.1',
89
+ port: 6379,
90
+ },
91
+ },
92
+ // Or configure individually:
93
+ // queue: {
94
+ // adapter: 'redis',
95
+ // redis: { host: '127.0.0.1', port: 6379 },
96
+ // defaultConfig: { concurrency: 2 }
97
+ // },
98
+ // state: {
99
+ // adapter: 'redis',
100
+ // redis: { host: '127.0.0.1', port: 6379 }
101
+ // },
102
+ // eventStore: {
103
+ // adapter: 'memory' // Use memory for events
104
+ // },
105
+ },
106
+ })
107
+ ```
108
+
109
+ ### Create Your First Worker
110
+
111
+ ```typescript
112
+ // server/queues/example/process.ts
113
+ export default defineQueueWorker(async (job, ctx) => {
114
+ // Access job data
115
+ const { message } = job.data
116
+
117
+ // Log to stream
118
+ ctx.logger.log('info', 'Processing message', { message })
119
+
120
+ // Store state
121
+ await ctx.state.set('processedAt', new Date().toISOString())
122
+
123
+ // Return result
124
+ return { success: true, processed: message }
125
+ })
126
+
127
+ export const config = defineQueueConfig({
128
+ concurrency: 5,
129
+ })
130
+ ```
131
+
132
+ ### Enqueue a Job
133
+
134
+ ```typescript
135
+ // API route or wherever
136
+ const queueProvider = useQueueProvider()
137
+ await queueProvider.enqueue('process', {
138
+ name: 'process',
139
+ data: { message: 'Hello World' }
140
+ })
141
+ ```
142
+
143
+ ### Create a Flow
144
+
145
+ Multi-step workflows with event-driven orchestration:
146
+
147
+ ```typescript
148
+ // server/queues/my-flow/start.ts
149
+ export default defineQueueWorker(async (job, ctx) => {
150
+ ctx.logger.log('info', 'Flow started')
151
+ const prepared = { step: 1, data: job.data }
152
+
153
+ // Emit event to trigger next steps
154
+ ctx.flow.emit('data.prepared', prepared)
155
+
156
+ return prepared
157
+ })
158
+
159
+ export const config = defineQueueConfig({
160
+ flow: {
161
+ names: ['my-flow'],
162
+ role: 'entry',
163
+ step: 'start',
164
+ emits: ['data.prepared']
165
+ }
166
+ })
167
+
168
+ // server/queues/my-flow/process.ts
169
+ export default defineQueueWorker(async (job, ctx) => {
170
+ const result = await processData(job.data)
171
+
172
+ // Emit to trigger next step
173
+ ctx.flow.emit('data.processed', result)
174
+
175
+ return result
176
+ })
177
+
178
+ export const config = defineQueueConfig({
179
+ flow: {
180
+ names: ['my-flow'],
181
+ role: 'step',
182
+ step: 'process',
183
+ subscribes: ['data.prepared'], // Triggered by start
184
+ emits: ['data.processed']
185
+ }
186
+ })
187
+
188
+ // server/queues/my-flow/validate.ts
189
+ export default defineQueueWorker(async (job, ctx) => {
190
+ const validated = await validate(job.data)
191
+ ctx.flow.emit('validation.complete', validated)
192
+ return validated
193
+ })
194
+
195
+ export const config = defineQueueConfig({
196
+ flow: {
197
+ names: ['my-flow'],
198
+ role: 'step',
199
+ step: 'validate',
200
+ subscribes: ['data.prepared'], // Also triggered by start (parallel with process)
201
+ emits: ['validation.complete']
202
+ }
203
+ })
204
+ ```
205
+
206
+ **Start the flow:**
207
+ ```typescript
208
+ const { startFlow } = useFlowEngine()
209
+ await startFlow('my-flow', { input: 'data' })
210
+ ```
211
+
212
+ **Flow execution**: Entry step emits `data.prepared` → Both `process` and `validate` steps run in parallel (they both subscribe to `data.prepared`) → Each emits its own completion event for downstream steps.
213
+
214
+ ### Schedule a Flow
215
+
216
+ Schedule flows to run automatically with cron patterns or delays:
217
+
218
+ ```typescript
219
+ // Schedule a flow to run daily at 2 AM
220
+ await $fetch('/api/_flows/my-flow/schedule', {
221
+ method: 'POST',
222
+ body: {
223
+ cron: '0 2 * * *',
224
+ input: { retentionDays: 30 },
225
+ metadata: {
226
+ description: 'Daily cleanup job'
227
+ }
228
+ }
229
+ })
230
+
231
+ // Schedule a one-time delayed execution (5 minutes)
232
+ await $fetch('/api/_flows/reminder-flow/schedule', {
233
+ method: 'POST',
234
+ body: {
235
+ delay: 300000, // milliseconds
236
+ input: { userId: '123', message: 'Check your email' }
237
+ }
238
+ })
239
+
240
+ // List all schedules for a flow
241
+ const schedules = await $fetch('/api/_flows/my-flow/schedules')
242
+
243
+ // Delete a schedule
244
+ await $fetch('/api/_flows/my-flow/schedules/schedule-id', {
245
+ method: 'DELETE'
246
+ })
247
+ ```
248
+
249
+ **Common cron patterns:**
250
+ - `* * * * *` - Every minute
251
+ - `*/5 * * * *` - Every 5 minutes
252
+ - `0 * * * *` - Every hour
253
+ - `0 2 * * *` - Daily at 2 AM
254
+ - `0 9 * * 1` - Every Monday at 9 AM
255
+ - `0 0 1 * *` - First day of month at midnight
256
+
257
+ ## 🎨 Development UI
258
+
259
+ Access the built-in UI as `<QueueApp />` component:
260
+
261
+ - 📊 **Dashboard**: Overview of queues and flows
262
+ - 🔄 **Flow Diagrams**: Visual representation with Vue Flow
263
+ - ⏰ **Flow Scheduling**: Create and manage cron-based or delayed schedules
264
+ - 📝 **Event Timeline**: Real-time event stream with step details
265
+ - 📋 **Logs**: Filtered logging by flow/step
266
+ - 📈 **Metrics**: Queue statistics and performance
267
+ - 🔍 **Flow Runs**: Complete history with status tracking
268
+
269
+ ## 🏗️ Architecture
270
+
271
+ ### Event Sourcing
272
+
273
+ Every flow operation is stored as an event in Redis Streams:
274
+
275
+ ```
276
+ nq:flow:<runId>
277
+ ├─ flow.start
278
+ ├─ step.started
279
+ ├─ log
280
+ ├─ step.completed
281
+ ├─ step.started
282
+ ├─ log
283
+ ├─ step.completed
284
+ └─ flow.completed
285
+ ```
286
+
287
+ ### Real-time Distribution
288
+
289
+ Events are broadcast via Redis Pub/Sub for instant UI updates (<100ms latency).
290
+
291
+ ### Worker Context
292
+
293
+ Every worker receives a rich context:
294
+
295
+ ```typescript
296
+ {
297
+ jobId: string // BullMQ job ID
298
+ queue: string // Queue name
299
+ flowId: string // Flow run UUID
300
+ flowName: string // Flow definition name
301
+ stepName: string // Current step name
302
+ logger: {
303
+ log(level, msg, meta) // Structured logging
304
+ },
305
+ state: {
306
+ get(key) // Get flow-scoped state
307
+ set(key, value, opts) // Set with optional TTL
308
+ delete(key) // Delete state
309
+ },
310
+ flow: {
311
+ emit(eventName, data) // Emit flow event to trigger subscribed steps
312
+ startFlow(name, input) // Start nested flow
313
+ }
314
+ }
315
+ ```
316
+
317
+ ## 📚 Documentation
318
+
319
+ ### v0.4 Documentation
320
+ - **[Current Implementation](./specs/v0.4/current-implementation.md)** - Complete v0.4 architecture
321
+ - **[Event Schema](./specs/v0.4/event-schema.md)** - Event types and structure
322
+ - **[Flow Scheduling](./specs/v0.4/flow-scheduling.md)** - Scheduling specification
323
+ - **[Quick Reference](./specs/v0.4/quick-reference.md)** - One-page API reference
324
+
325
+ ### API & Advanced
326
+ - **[API Reference](./specs/v0.4/current-implementation.md#api-endpoints)** - REST endpoints for flows/queues
327
+ - **[Logging](./specs/v0.4/logging.md)** - Server logging and best practices
328
+
329
+ ### Roadmap & Future
330
+ - **[Roadmap](./specs/roadmap.md)** - Planned features across versions
331
+ - **[v0.5 Trigger System](./specs/v0.5/trigger-system.md)** - Next-gen event handling
332
+ - **[v0.6 Multi-language Workers](./specs/v0.6/multi-language-workers.md)** - Python support
333
+ - **[v0.6 Postgres Backend](./specs/v0.6/postgres-backend.md)** - PgBoss integration
334
+
335
+ ## 🔮 Roadmap
336
+
337
+ ### v0.4 (Current - November 2025)
338
+ ✅ Core queue and flow orchestration
339
+ ✅ Event sourcing with Redis Streams
340
+ ✅ Real-time monitoring UI
341
+ ✅ Flow scheduling (cron and delays)
342
+ ✅ Worker context with state and logging
343
+
344
+ ### v0.5
345
+ - 🎯 Comprehensive trigger system (schedule, webhook, event, manual)
346
+ - ⏱️ Await patterns (time, event, condition)
347
+ - 🐍 Python worker support with RPC bridge
348
+ - 🔗 Webhook triggers with auto-setup
349
+
350
+ ### v0.6
351
+ - 🐘 PgBoss queue provider option
352
+ - 🗄️ Postgres stream store adapter
353
+ - 🔄 Unified state and event storage
354
+ - 📊 Advanced state management
355
+
356
+ ### v0.7
357
+ - 📊 Enhanced logger with multiple adapters
358
+ - 🌐 HTTP mode for workers (REST/gRPC)
359
+ - 🔌 External service hooks
360
+ - 🎨 Pluggable worker execution modes
361
+
362
+ See [specs/roadmap.md](./specs/roadmap.md) for complete details.
363
+
364
+ ## 🤝 Contributing
365
+
366
+ Contributions welcome! Please read our architecture docs first:
367
+
368
+ 1. Review [specs/v0.4/current-implementation.md](./specs/v0.4/current-implementation.md)
369
+ 2. Check [specs/roadmap.md](./specs/roadmap.md) for planned features
370
+ 3. Open an issue to discuss changes
371
+ 4. Submit a PR with tests
372
+
373
+ ### Development Setup
374
+
375
+ ```bash
376
+ # Install dependencies
377
+ yarn install
378
+
379
+ # Start playground with dev UI
380
+ cd playground
381
+ yarn dev
382
+
383
+ # Run tests
384
+ yarn test
385
+ ```
386
+
387
+ ## 📄 License
388
+
389
+ [MIT License](./LICENSE) - Copyright (c) DevJoghurt
@@ -0,0 +1,193 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ /**
4
+ * Redis connection configuration
5
+ */
6
+ interface RedisConfig {
7
+ host?: string;
8
+ port?: number;
9
+ username?: string;
10
+ password?: string;
11
+ db?: number;
12
+ url?: string;
13
+ }
14
+ /**
15
+ * PostgreSQL connection configuration
16
+ */
17
+ interface PostgresConfig {
18
+ connectionString?: string;
19
+ host?: string;
20
+ port?: number;
21
+ database?: string;
22
+ user?: string;
23
+ password?: string;
24
+ }
25
+ /**
26
+ * Queue provider configuration
27
+ */
28
+ interface QueueConfig {
29
+ /**
30
+ * Queue backend adapter: 'redis' (BullMQ) or 'postgres' (PGBoss)
31
+ */
32
+ adapter?: 'redis' | 'postgres';
33
+ /**
34
+ * Redis connection config (when using BullMQ)
35
+ */
36
+ redis?: RedisConfig;
37
+ /**
38
+ * Postgres connection config (when using PGBoss)
39
+ */
40
+ postgres?: PostgresConfig;
41
+ /**
42
+ * Default configuration for queues and workers.
43
+ * Combines both queue and worker options for convenience.
44
+ */
45
+ defaultConfig?: {
46
+ prefix?: string;
47
+ defaultJobOptions?: {
48
+ attempts?: number;
49
+ backoff?: number | {
50
+ type: 'fixed' | 'exponential';
51
+ delay: number;
52
+ };
53
+ delay?: number;
54
+ priority?: number;
55
+ timeout?: number;
56
+ lifo?: boolean;
57
+ removeOnComplete?: boolean | number;
58
+ removeOnFail?: boolean | number;
59
+ };
60
+ limiter?: {
61
+ max?: number;
62
+ duration?: number;
63
+ groupKey?: string;
64
+ };
65
+ worker?: {
66
+ concurrency?: number;
67
+ lockDurationMs?: number;
68
+ maxStalledCount?: number;
69
+ drainDelayMs?: number;
70
+ autorun?: boolean;
71
+ pollingIntervalMs?: number;
72
+ };
73
+ };
74
+ }
75
+ /**
76
+ * State provider configuration
77
+ */
78
+ interface StateConfig {
79
+ adapter?: 'redis' | 'postgres';
80
+ namespace?: string;
81
+ autoScope?: 'always' | 'flow' | 'never';
82
+ cleanup?: {
83
+ strategy?: 'never' | 'immediate' | 'ttl' | 'on-complete';
84
+ ttlMs?: number;
85
+ };
86
+ redis?: RedisConfig;
87
+ postgres?: PostgresConfig;
88
+ }
89
+ /**
90
+ * Event store configuration
91
+ */
92
+ interface EventStoreConfig {
93
+ adapter?: 'redis' | 'postgres' | 'memory' | 'file';
94
+ streams?: any;
95
+ options?: {
96
+ file?: {
97
+ dir?: string;
98
+ ext?: string;
99
+ pollMs?: number;
100
+ };
101
+ };
102
+ redis?: RedisConfig;
103
+ postgres?: PostgresConfig;
104
+ /**
105
+ * Retention settings for event lifecycle tracking
106
+ */
107
+ retention?: {
108
+ /**
109
+ * How long to keep event stream data (in seconds)
110
+ * @default 604800 (7 days)
111
+ */
112
+ eventTTL?: number;
113
+ /**
114
+ * How long to keep flow metadata after completion/failure (in seconds)
115
+ * @default 2592000 (30 days)
116
+ */
117
+ metadataTTL?: number;
118
+ };
119
+ }
120
+ /**
121
+ * Store shortcut - sets all backends to the same storage
122
+ */
123
+ interface StoreShortcut {
124
+ /**
125
+ * Storage backend adapter to use for everything
126
+ */
127
+ adapter: 'redis' | 'postgres';
128
+ /**
129
+ * Redis config (used when adapter is 'redis')
130
+ */
131
+ redis?: RedisConfig;
132
+ /**
133
+ * Postgres config (used when adapter is 'postgres')
134
+ */
135
+ postgres?: PostgresConfig;
136
+ }
137
+ /**
138
+ * Module options for nuxt-queue
139
+ */
140
+ interface ModuleOptions {
141
+ /**
142
+ * Directory to scan for queue workers
143
+ */
144
+ dir?: string;
145
+ /**
146
+ * Enable dev UI
147
+ */
148
+ ui?: boolean;
149
+ /**
150
+ * Debug configuration
151
+ */
152
+ debug?: Record<string, any>;
153
+ /**
154
+ * Shortcut to configure all backends at once.
155
+ * Setting this will configure queue, state, and eventStore to use the same backend.
156
+ * Individual configs can still override this.
157
+ */
158
+ store?: StoreShortcut;
159
+ /**
160
+ * Queue provider configuration (BullMQ/PGBoss)
161
+ */
162
+ queue?: QueueConfig;
163
+ /**
164
+ * State provider configuration
165
+ */
166
+ state?: StateConfig;
167
+ /**
168
+ * Event store configuration
169
+ */
170
+ eventStore?: EventStoreConfig;
171
+ }
172
+ /**
173
+ * Runtime config shape for queue module
174
+ */
175
+ interface QueueModuleConfig {
176
+ debug?: Record<string, any>;
177
+ workers: any[];
178
+ registry?: any;
179
+ queue: Required<QueueConfig>;
180
+ state: Required<StateConfig>;
181
+ eventStore: Required<EventStoreConfig>;
182
+ rootDir?: string;
183
+ }
184
+
185
+ declare module '@nuxt/schema' {
186
+ interface RuntimeConfig {
187
+ queue: QueueModuleConfig;
188
+ }
189
+ }
190
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
191
+
192
+ export { _default as default };
193
+ export type { ModuleOptions };
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "queue",
3
+ "version": "0.1",
4
+ "configKey": "queue",
5
+ "builder": {
6
+ "@nuxt/module-builder": "1.0.2",
7
+ "unbuild": "3.6.1"
8
+ }
9
+ }