nvent 0.4.3 → 0.4.5

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 (234) hide show
  1. package/dist/module.d.mts +3 -184
  2. package/dist/module.json +3 -3
  3. package/dist/module.mjs +133 -197
  4. package/dist/runtime/adapters/builtin/file-queue.d.ts +53 -0
  5. package/dist/runtime/adapters/builtin/file-queue.js +435 -0
  6. package/dist/runtime/adapters/builtin/file-store.d.ts +46 -0
  7. package/dist/runtime/adapters/builtin/file-store.js +225 -0
  8. package/dist/runtime/adapters/builtin/file-stream.d.ts +39 -0
  9. package/dist/runtime/adapters/builtin/file-stream.js +56 -0
  10. package/dist/runtime/adapters/builtin/index.d.ts +10 -0
  11. package/dist/runtime/adapters/builtin/index.js +5 -0
  12. package/dist/runtime/adapters/builtin/memory-queue.d.ts +52 -0
  13. package/dist/runtime/adapters/builtin/memory-queue.js +239 -0
  14. package/dist/runtime/adapters/builtin/memory-store.d.ts +57 -0
  15. package/dist/runtime/adapters/builtin/memory-store.js +263 -0
  16. package/dist/runtime/adapters/builtin/memory-stream.d.ts +21 -0
  17. package/dist/runtime/adapters/builtin/memory-stream.js +56 -0
  18. package/dist/runtime/adapters/factory.d.ts +31 -0
  19. package/dist/runtime/adapters/factory.js +100 -0
  20. package/dist/runtime/adapters/index.d.ts +8 -0
  21. package/dist/runtime/adapters/index.js +3 -0
  22. package/dist/runtime/adapters/interfaces/index.d.ts +11 -0
  23. package/dist/runtime/adapters/interfaces/index.js +3 -0
  24. package/dist/runtime/adapters/interfaces/queue.d.ts +150 -0
  25. package/dist/runtime/adapters/interfaces/store.d.ts +233 -0
  26. package/dist/runtime/adapters/interfaces/stream.d.ts +62 -0
  27. package/dist/runtime/adapters/registry.d.ts +85 -0
  28. package/dist/runtime/adapters/registry.js +161 -0
  29. package/dist/runtime/config/index.d.ts +29 -0
  30. package/dist/runtime/config/index.js +167 -0
  31. package/dist/runtime/config/types.d.ts +367 -0
  32. package/dist/runtime/config/types.js +0 -0
  33. package/dist/runtime/events/types.d.ts +116 -0
  34. package/dist/runtime/events/types.js +0 -0
  35. package/dist/runtime/events/utils/stallDetector.d.ts +99 -0
  36. package/dist/runtime/events/utils/stallDetector.js +237 -0
  37. package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.d.ts +3 -8
  38. package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.js +119 -36
  39. package/dist/runtime/events/wiring/registry.d.ts +19 -0
  40. package/dist/runtime/events/wiring/registry.js +33 -0
  41. package/dist/runtime/events/wiring/stateWiring.d.ts +37 -0
  42. package/dist/runtime/events/wiring/stateWiring.js +92 -0
  43. package/dist/runtime/events/wiring/streamWiring.d.ts +32 -0
  44. package/dist/runtime/events/wiring/streamWiring.js +79 -0
  45. package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +16 -5
  46. package/dist/runtime/server/api/_flows/[name]/runs/[runId]/cancel.post.js +21 -0
  47. package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +12 -2
  48. package/dist/runtime/server/api/_flows/[name]/runs.get.js +15 -4
  49. package/dist/runtime/server/api/_flows/[name]/schedule.post.js +11 -2
  50. package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +21 -16
  51. package/dist/runtime/server/api/_flows/[name]/schedules.get.js +21 -19
  52. package/dist/runtime/server/api/_flows/ws.js +43 -22
  53. package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +8 -3
  54. package/dist/runtime/server/api/_queues/[name]/job/index.get.js +12 -3
  55. package/dist/runtime/server/api/_queues/index.get.js +66 -23
  56. package/dist/runtime/server/api/_queues/ws.js +14 -4
  57. package/dist/runtime/server/plugins/00.adapters.d.ts +14 -0
  58. package/dist/runtime/server/plugins/00.adapters.js +69 -0
  59. package/dist/runtime/server/plugins/02.workers.js +45 -0
  60. package/dist/runtime/tsconfig.json +8 -0
  61. package/dist/runtime/utils/adapters.d.ts +66 -0
  62. package/dist/runtime/utils/adapters.js +51 -0
  63. package/dist/runtime/utils/defineFunction.d.ts +10 -0
  64. package/dist/runtime/{server-utils/utils/defineQueueWorker.js → utils/defineFunction.js} +4 -4
  65. package/dist/runtime/{server-utils/utils/defineQueueConfig.d.ts → utils/defineFunctionConfig.d.ts} +3 -3
  66. package/dist/runtime/utils/defineFunctionConfig.js +2 -0
  67. package/dist/runtime/utils/registerAdapter.d.ts +59 -0
  68. package/dist/runtime/utils/registerAdapter.js +13 -0
  69. package/dist/runtime/utils/useFlowEngine.d.ts +19 -0
  70. package/dist/runtime/utils/useFlowEngine.js +108 -0
  71. package/dist/runtime/{server-utils/utils → utils}/useNventLogger.js +2 -2
  72. package/dist/runtime/utils/useStreamTopics.d.ts +72 -0
  73. package/dist/runtime/utils/useStreamTopics.js +47 -0
  74. package/dist/runtime/{server-utils/worker/runner/node.d.ts → worker/node/runner.d.ts} +18 -2
  75. package/dist/runtime/{server-utils/worker/runner/node.js → worker/node/runner.js} +44 -17
  76. package/dist/types.d.mts +2 -2
  77. package/package.json +14 -44
  78. package/LICENSE +0 -21
  79. package/README.md +0 -389
  80. package/dist/runtime/app/assets/vueflow.css +0 -1
  81. package/dist/runtime/app/components/ConfirmDialog.d.vue.ts +0 -33
  82. package/dist/runtime/app/components/ConfirmDialog.vue +0 -121
  83. package/dist/runtime/app/components/ConfirmDialog.vue.d.ts +0 -33
  84. package/dist/runtime/app/components/FlowDiagram.d.vue.ts +0 -64
  85. package/dist/runtime/app/components/FlowDiagram.vue +0 -338
  86. package/dist/runtime/app/components/FlowDiagram.vue.d.ts +0 -64
  87. package/dist/runtime/app/components/FlowNodeCard.d.vue.ts +0 -29
  88. package/dist/runtime/app/components/FlowNodeCard.vue +0 -156
  89. package/dist/runtime/app/components/FlowNodeCard.vue.d.ts +0 -29
  90. package/dist/runtime/app/components/FlowRunOverview.d.vue.ts +0 -9
  91. package/dist/runtime/app/components/FlowRunOverview.vue +0 -291
  92. package/dist/runtime/app/components/FlowRunOverview.vue.d.ts +0 -9
  93. package/dist/runtime/app/components/FlowRunStatusBadge.d.vue.ts +0 -14
  94. package/dist/runtime/app/components/FlowRunStatusBadge.vue +0 -60
  95. package/dist/runtime/app/components/FlowRunStatusBadge.vue.d.ts +0 -14
  96. package/dist/runtime/app/components/FlowRunTimeline.d.vue.ts +0 -12
  97. package/dist/runtime/app/components/FlowRunTimeline.vue +0 -127
  98. package/dist/runtime/app/components/FlowRunTimeline.vue.d.ts +0 -12
  99. package/dist/runtime/app/components/FlowScheduleDialog.d.vue.ts +0 -16
  100. package/dist/runtime/app/components/FlowScheduleDialog.vue +0 -226
  101. package/dist/runtime/app/components/FlowScheduleDialog.vue.d.ts +0 -16
  102. package/dist/runtime/app/components/FlowSchedulesList.d.vue.ts +0 -12
  103. package/dist/runtime/app/components/FlowSchedulesList.vue +0 -99
  104. package/dist/runtime/app/components/FlowSchedulesList.vue.d.ts +0 -12
  105. package/dist/runtime/app/components/JobScheduling.d.vue.ts +0 -6
  106. package/dist/runtime/app/components/JobScheduling.vue +0 -203
  107. package/dist/runtime/app/components/JobScheduling.vue.d.ts +0 -6
  108. package/dist/runtime/app/components/ListItem.d.vue.ts +0 -23
  109. package/dist/runtime/app/components/ListItem.vue +0 -70
  110. package/dist/runtime/app/components/ListItem.vue.d.ts +0 -23
  111. package/dist/runtime/app/components/QueueConfigDetails.d.vue.ts +0 -45
  112. package/dist/runtime/app/components/QueueConfigDetails.vue +0 -412
  113. package/dist/runtime/app/components/QueueConfigDetails.vue.d.ts +0 -45
  114. package/dist/runtime/app/components/StatCounter.d.vue.ts +0 -9
  115. package/dist/runtime/app/components/StatCounter.vue +0 -25
  116. package/dist/runtime/app/components/StatCounter.vue.d.ts +0 -9
  117. package/dist/runtime/app/components/TimelineList.d.vue.ts +0 -7
  118. package/dist/runtime/app/components/TimelineList.vue +0 -210
  119. package/dist/runtime/app/components/TimelineList.vue.d.ts +0 -7
  120. package/dist/runtime/app/components/nhealth/component-router.d.vue.ts +0 -46
  121. package/dist/runtime/app/components/nhealth/component-router.vue +0 -26
  122. package/dist/runtime/app/components/nhealth/component-router.vue.d.ts +0 -46
  123. package/dist/runtime/app/components/nhealth/component-shell.d.vue.ts +0 -24
  124. package/dist/runtime/app/components/nhealth/component-shell.vue +0 -89
  125. package/dist/runtime/app/components/nhealth/component-shell.vue.d.ts +0 -24
  126. package/dist/runtime/app/composables/useAnalyzedFlows.d.ts +0 -14
  127. package/dist/runtime/app/composables/useAnalyzedFlows.js +0 -8
  128. package/dist/runtime/app/composables/useComponentRouter.d.ts +0 -38
  129. package/dist/runtime/app/composables/useComponentRouter.js +0 -240
  130. package/dist/runtime/app/composables/useFlowRunTimeline.d.ts +0 -15
  131. package/dist/runtime/app/composables/useFlowRunTimeline.js +0 -66
  132. package/dist/runtime/app/composables/useFlowRuns.d.ts +0 -18
  133. package/dist/runtime/app/composables/useFlowRuns.js +0 -32
  134. package/dist/runtime/app/composables/useFlowRunsInfinite.d.ts +0 -24
  135. package/dist/runtime/app/composables/useFlowRunsInfinite.js +0 -123
  136. package/dist/runtime/app/composables/useFlowRunsPolling.d.ts +0 -9
  137. package/dist/runtime/app/composables/useFlowRunsPolling.js +0 -33
  138. package/dist/runtime/app/composables/useFlowState.d.ts +0 -125
  139. package/dist/runtime/app/composables/useFlowState.js +0 -211
  140. package/dist/runtime/app/composables/useFlowWebSocket.d.ts +0 -27
  141. package/dist/runtime/app/composables/useFlowWebSocket.js +0 -205
  142. package/dist/runtime/app/composables/useFlowsNavigation.d.ts +0 -10
  143. package/dist/runtime/app/composables/useFlowsNavigation.js +0 -58
  144. package/dist/runtime/app/composables/useQueueJobs.d.ts +0 -20
  145. package/dist/runtime/app/composables/useQueueJobs.js +0 -20
  146. package/dist/runtime/app/composables/useQueueUpdates.d.ts +0 -26
  147. package/dist/runtime/app/composables/useQueueUpdates.js +0 -122
  148. package/dist/runtime/app/composables/useQueues.d.ts +0 -44
  149. package/dist/runtime/app/composables/useQueues.js +0 -26
  150. package/dist/runtime/app/composables/useQueuesLive.d.ts +0 -19
  151. package/dist/runtime/app/composables/useQueuesLive.js +0 -143
  152. package/dist/runtime/app/pages/flows/index.d.vue.ts +0 -3
  153. package/dist/runtime/app/pages/flows/index.vue +0 -645
  154. package/dist/runtime/app/pages/flows/index.vue.d.ts +0 -3
  155. package/dist/runtime/app/pages/index.d.vue.ts +0 -3
  156. package/dist/runtime/app/pages/index.vue +0 -34
  157. package/dist/runtime/app/pages/index.vue.d.ts +0 -3
  158. package/dist/runtime/app/pages/queues/index.d.vue.ts +0 -3
  159. package/dist/runtime/app/pages/queues/index.vue +0 -229
  160. package/dist/runtime/app/pages/queues/index.vue.d.ts +0 -3
  161. package/dist/runtime/app/pages/queues/job.d.vue.ts +0 -3
  162. package/dist/runtime/app/pages/queues/job.vue +0 -262
  163. package/dist/runtime/app/pages/queues/job.vue.d.ts +0 -3
  164. package/dist/runtime/app/pages/queues/jobs.d.vue.ts +0 -3
  165. package/dist/runtime/app/pages/queues/jobs.vue +0 -291
  166. package/dist/runtime/app/pages/queues/jobs.vue.d.ts +0 -3
  167. package/dist/runtime/app/plugins/vueflow.client.d.ts +0 -2
  168. package/dist/runtime/app/plugins/vueflow.client.js +0 -11
  169. package/dist/runtime/constants.d.ts +0 -11
  170. package/dist/runtime/constants.js +0 -11
  171. package/dist/runtime/schema.d.ts +0 -37
  172. package/dist/runtime/schema.js +0 -20
  173. package/dist/runtime/server/plugins/00.event-store.d.ts +0 -13
  174. package/dist/runtime/server/plugins/00.event-store.js +0 -16
  175. package/dist/runtime/server/plugins/flow-management.d.ts +0 -13
  176. package/dist/runtime/server/plugins/flow-management.js +0 -65
  177. package/dist/runtime/server/plugins/queue-management.js +0 -27
  178. package/dist/runtime/server/plugins/state-cleanup.d.ts +0 -11
  179. package/dist/runtime/server/plugins/state-cleanup.js +0 -93
  180. package/dist/runtime/server/plugins/worker-management.js +0 -33
  181. package/dist/runtime/server/tsconfig.json +0 -3
  182. package/dist/runtime/server-utils/events/adapters/fileAdapter.d.ts +0 -2
  183. package/dist/runtime/server-utils/events/adapters/fileAdapter.js +0 -382
  184. package/dist/runtime/server-utils/events/adapters/memoryAdapter.d.ts +0 -2
  185. package/dist/runtime/server-utils/events/adapters/memoryAdapter.js +0 -171
  186. package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.d.ts +0 -2
  187. package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.js +0 -348
  188. package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.d.ts +0 -30
  189. package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.js +0 -82
  190. package/dist/runtime/server-utils/events/eventStoreFactory.d.ts +0 -19
  191. package/dist/runtime/server-utils/events/eventStoreFactory.js +0 -44
  192. package/dist/runtime/server-utils/events/streamNames.d.ts +0 -17
  193. package/dist/runtime/server-utils/events/streamNames.js +0 -17
  194. package/dist/runtime/server-utils/events/types.d.ts +0 -63
  195. package/dist/runtime/server-utils/events/wiring/registry.d.ts +0 -10
  196. package/dist/runtime/server-utils/events/wiring/registry.js +0 -24
  197. package/dist/runtime/server-utils/queue/adapters/bullmq.d.ts +0 -18
  198. package/dist/runtime/server-utils/queue/adapters/bullmq.js +0 -164
  199. package/dist/runtime/server-utils/queue/queueFactory.d.ts +0 -3
  200. package/dist/runtime/server-utils/queue/queueFactory.js +0 -10
  201. package/dist/runtime/server-utils/queue/types.d.ts +0 -47
  202. package/dist/runtime/server-utils/state/adapters/redis.d.ts +0 -2
  203. package/dist/runtime/server-utils/state/adapters/redis.js +0 -42
  204. package/dist/runtime/server-utils/state/stateFactory.d.ts +0 -3
  205. package/dist/runtime/server-utils/state/stateFactory.js +0 -17
  206. package/dist/runtime/server-utils/state/types.d.ts +0 -23
  207. package/dist/runtime/server-utils/utils/defineQueueConfig.js +0 -2
  208. package/dist/runtime/server-utils/utils/defineQueueWorker.d.ts +0 -10
  209. package/dist/runtime/server-utils/utils/useEventStore.d.ts +0 -20
  210. package/dist/runtime/server-utils/utils/useEventStore.js +0 -119
  211. package/dist/runtime/server-utils/utils/useFlowEngine.d.ts +0 -9
  212. package/dist/runtime/server-utils/utils/useFlowEngine.js +0 -44
  213. package/dist/runtime/server-utils/utils/useLogs.d.ts +0 -41
  214. package/dist/runtime/server-utils/utils/useLogs.js +0 -74
  215. package/dist/runtime/server-utils/utils/useQueue.d.ts +0 -31
  216. package/dist/runtime/server-utils/utils/useQueue.js +0 -24
  217. package/dist/runtime/server-utils/worker/adapter.d.ts +0 -4
  218. package/dist/runtime/server-utils/worker/adapter.js +0 -66
  219. package/dist/runtime/types.d.ts +0 -132
  220. /package/dist/runtime/{server-utils/events/types.js → adapters/interfaces/queue.js} +0 -0
  221. /package/dist/runtime/{server-utils/queue/types.js → adapters/interfaces/store.js} +0 -0
  222. /package/dist/runtime/{server-utils/state/types.js → adapters/interfaces/stream.js} +0 -0
  223. /package/dist/runtime/{server-utils/events → events}/eventBus.d.ts +0 -0
  224. /package/dist/runtime/{server-utils/events → events}/eventBus.js +0 -0
  225. /package/dist/runtime/server/{plugins/queue-management.d.ts → api/_flows/[name]/runs/[runId]/cancel.post.d.ts} +0 -0
  226. /package/dist/runtime/server/plugins/{00.ws-lifecycle.d.ts → 01.ws-lifecycle.d.ts} +0 -0
  227. /package/dist/runtime/server/plugins/{00.ws-lifecycle.js → 01.ws-lifecycle.js} +0 -0
  228. /package/dist/runtime/server/plugins/{worker-management.d.ts → 02.workers.d.ts} +0 -0
  229. /package/dist/runtime/{server-utils/utils → utils}/useEventManager.d.ts +0 -0
  230. /package/dist/runtime/{server-utils/utils → utils}/useEventManager.js +0 -0
  231. /package/dist/runtime/{server-utils/utils → utils}/useNventLogger.d.ts +0 -0
  232. /package/dist/runtime/{server-utils/utils → utils}/wsPeerManager.d.ts +0 -0
  233. /package/dist/runtime/{server-utils/utils → utils}/wsPeerManager.js +0 -0
  234. /package/dist/runtime/{python → worker/python}/get_config.py +0 -0
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Adapter Registration Utilities
3
+ *
4
+ * Used by external adapter modules to register their adapters with nvent
5
+ */
6
+ import type { QueueAdapter } from '../adapters/interfaces/queue.js';
7
+ import type { StreamAdapter } from '../adapters/interfaces/stream.js';
8
+ import type { StoreAdapter } from '../adapters/interfaces/store.js';
9
+ /**
10
+ * Register a queue adapter
11
+ *
12
+ * Called by external adapter modules (e.g., @nvent/adapter-queue-redis)
13
+ * to register their adapter implementation.
14
+ *
15
+ * @param name - Adapter name (e.g., 'redis', 'postgres', 'rabbitmq')
16
+ * @param adapter - QueueAdapter implementation
17
+ *
18
+ * @example
19
+ * import { registerQueueAdapter } from '#imports'
20
+ * import { RedisQueueAdapter } from './adapter'
21
+ *
22
+ * const adapter = new RedisQueueAdapter({ connection })
23
+ * registerQueueAdapter('redis', adapter)
24
+ */
25
+ export declare function registerQueueAdapter(name: string, adapter: QueueAdapter): void;
26
+ /**
27
+ * Register a stream adapter
28
+ *
29
+ * Called by external adapter modules (e.g., @nvent/adapter-stream-redis)
30
+ * to register their adapter implementation.
31
+ *
32
+ * @param name - Adapter name (e.g., 'redis', 'rabbitmq', 'kafka')
33
+ * @param adapter - StreamAdapter implementation
34
+ *
35
+ * @example
36
+ * import { registerStreamAdapter } from '#imports'
37
+ * import { RedisStreamAdapter } from './adapter'
38
+ *
39
+ * const adapter = new RedisStreamAdapter({ connection })
40
+ * registerStreamAdapter('redis', adapter)
41
+ */
42
+ export declare function registerStreamAdapter(name: string, adapter: StreamAdapter): void;
43
+ /**
44
+ * Register a store adapter
45
+ *
46
+ * Called by external adapter modules (e.g., @nvent/adapter-store-redis)
47
+ * to register their adapter implementation.
48
+ *
49
+ * @param name - Adapter name (e.g., 'redis', 'postgres')
50
+ * @param adapter - StoreAdapter implementation
51
+ *
52
+ * @example
53
+ * import { registerStoreAdapter } from '#imports'
54
+ * import { RedisStoreAdapter } from './adapter'
55
+ *
56
+ * const adapter = new RedisStoreAdapter({ connection })
57
+ * registerStoreAdapter('redis', adapter)
58
+ */
59
+ export declare function registerStoreAdapter(name: string, adapter: StoreAdapter): void;
@@ -0,0 +1,13 @@
1
+ import { useAdapterRegistry } from "../adapters/registry.js";
2
+ export function registerQueueAdapter(name, adapter) {
3
+ const registry = useAdapterRegistry();
4
+ registry.registerQueue(name, adapter);
5
+ }
6
+ export function registerStreamAdapter(name, adapter) {
7
+ const registry = useAdapterRegistry();
8
+ registry.registerStream(name, adapter);
9
+ }
10
+ export function registerStoreAdapter(name, adapter) {
11
+ const registry = useAdapterRegistry();
12
+ registry.registerStore(name, adapter);
13
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Flow Engine for starting and emitting flow events
3
+ */
4
+ export declare const useFlowEngine: () => {
5
+ startFlow: (flowName: string, payload?: any) => Promise<{
6
+ id: any;
7
+ queue: any;
8
+ step: any;
9
+ flowId: `${string}-${string}-${string}-${string}-${string}`;
10
+ }>;
11
+ emit: (trigger: string, payload?: any) => Promise<never[]>;
12
+ cancelFlow: (flowName: string, runId: string) => Promise<{
13
+ success: boolean;
14
+ runId: string;
15
+ flowName: string;
16
+ }>;
17
+ isRunning: (flowName: string, runId?: string) => Promise<any>;
18
+ getRunningFlows: (flowName: string) => Promise<any>;
19
+ };
@@ -0,0 +1,108 @@
1
+ import { $useQueueRegistry, useQueueAdapter, useEventManager, useNventLogger, useStoreAdapter, useStreamTopics } from "#imports";
2
+ import { randomUUID } from "node:crypto";
3
+ const logger = useNventLogger("flow-engine");
4
+ export const useFlowEngine = () => {
5
+ const registry = $useQueueRegistry();
6
+ const queueAdapter = useQueueAdapter();
7
+ const eventsManager = useEventManager();
8
+ const startFlow = async (flowName, payload = {}) => {
9
+ const flow = registry?.flows?.[flowName];
10
+ if (!flow || !flow.entry) throw new Error("Flow not found");
11
+ const queueName = typeof flow.entry.queue === "string" ? flow.entry.queue : flow.entry.queue?.name || flow.entry.queue;
12
+ const entryWorker = registry?.workers?.find(
13
+ (w) => w?.flow?.step === flow.entry.step && w?.queue?.name === queueName
14
+ );
15
+ const opts = entryWorker?.queue?.defaultJobOptions || {};
16
+ const flowId = randomUUID();
17
+ const id = await queueAdapter.enqueue(queueName, { name: flow.entry.step, data: { ...payload, flowId, flowName }, opts });
18
+ try {
19
+ await eventsManager.publishBus({ type: "flow.start", runId: flowId, flowName, data: { input: payload } });
20
+ } catch {
21
+ }
22
+ return { id, queue: queueName, step: flow.entry.step, flowId };
23
+ };
24
+ const emit = async (trigger, payload = {}) => {
25
+ const flowId = payload?.flowId;
26
+ const flowName = payload?.flowName || "unknown";
27
+ if (!flowId) {
28
+ logger.warn("emit called without flowId, trigger may not work", { trigger });
29
+ }
30
+ const { flowId: _, flowName: __, ...actualPayload } = payload;
31
+ try {
32
+ await eventsManager.publishBus({
33
+ type: "emit",
34
+ runId: flowId || "unknown",
35
+ flowName,
36
+ data: {
37
+ name: trigger,
38
+ payload: actualPayload
39
+ // Store actual payload separately
40
+ }
41
+ });
42
+ } catch (err) {
43
+ logger.error("Failed to emit trigger event", { trigger, error: err });
44
+ }
45
+ return [];
46
+ };
47
+ const cancelFlow = async (flowName, runId) => {
48
+ try {
49
+ await eventsManager.publishBus({
50
+ type: "flow.cancel",
51
+ runId,
52
+ flowName,
53
+ data: {
54
+ canceledAt: (/* @__PURE__ */ new Date()).toISOString()
55
+ }
56
+ });
57
+ logger.info("Flow canceled", { flowName, runId });
58
+ return { success: true, runId, flowName };
59
+ } catch (err) {
60
+ logger.error("Failed to cancel flow", { flowName, runId, error: err });
61
+ throw err;
62
+ }
63
+ };
64
+ const isRunning = async (flowName, runId) => {
65
+ try {
66
+ const store = useStoreAdapter();
67
+ const { SubjectPatterns } = useStreamTopics();
68
+ if (!store.indexRead) {
69
+ return false;
70
+ }
71
+ if (runId) {
72
+ const runIndexKey2 = SubjectPatterns.flowRunIndex(flowName);
73
+ const entries2 = await store.indexRead(runIndexKey2, { limit: 1e3 });
74
+ const run = entries2.find((e) => e.id === runId);
75
+ return run?.metadata?.status === "running";
76
+ }
77
+ const runIndexKey = SubjectPatterns.flowRunIndex(flowName);
78
+ const entries = await store.indexRead(runIndexKey, { limit: 1e3 });
79
+ return entries.some((e) => e.metadata?.status === "running");
80
+ } catch (err) {
81
+ logger.error("[isRunning] Error checking flow status:", err);
82
+ return false;
83
+ }
84
+ };
85
+ const getRunningFlows = async (flowName) => {
86
+ try {
87
+ const store = useStoreAdapter();
88
+ const { SubjectPatterns } = useStreamTopics();
89
+ if (!store.indexRead) {
90
+ return [];
91
+ }
92
+ const runIndexKey = SubjectPatterns.flowRunIndex(flowName);
93
+ const entries = await store.indexRead(runIndexKey, { limit: 1e3 });
94
+ return entries.filter((e) => e.metadata?.status === "running").map((e) => ({
95
+ id: e.id,
96
+ flowName,
97
+ status: e.metadata?.status,
98
+ startedAt: e.metadata?.startedAt,
99
+ stepCount: e.metadata?.stepCount || 0,
100
+ completedSteps: e.metadata?.completedSteps || 0
101
+ }));
102
+ } catch (err) {
103
+ logger.error("[getRunningFlows] Error getting running flows:", err);
104
+ return [];
105
+ }
106
+ };
107
+ return { startFlow, emit, cancelFlow, isRunning, getRunningFlows };
108
+ };
@@ -9,7 +9,7 @@ const LOG_LEVELS = {
9
9
  const loggerCache = /* @__PURE__ */ new Map();
10
10
  export function useNventLogger(scope) {
11
11
  const rc = useRuntimeConfig();
12
- const debugConfig = rc?.queue?.debug;
12
+ const debugConfig = rc?.nvent?.debug;
13
13
  const configLevel = debugConfig?.level || process.env.NQ_DEBUG_LEVEL || "info";
14
14
  const globalLevelNum = configLevel === "silent" ? Infinity : LOG_LEVELS[configLevel] ?? LOG_LEVELS.info;
15
15
  const scopeKey = scope.replace(/[^a-z0-9]/gi, "_").toLowerCase();
@@ -48,7 +48,7 @@ export function useNventLogger(scope) {
48
48
  }
49
49
  export function isDebugEnabled() {
50
50
  const rc = useRuntimeConfig();
51
- const debugConfig = rc?.queue?.debug;
51
+ const debugConfig = rc?.nvent?.debug;
52
52
  const level = debugConfig?.level || process.env.NQ_DEBUG_LEVEL;
53
53
  return level === "debug" || Object.keys(debugConfig || {}).some((key) => key !== "level");
54
54
  }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Stream topic naming utilities
3
+ *
4
+ * Standardized topic patterns for StreamAdapter pub/sub
5
+ * These match the topics published by StoreAdapter mutations and wiring coordinators
6
+ */
7
+ /**
8
+ * Get topic for store append events
9
+ * Pattern: store:append:{subject}
10
+ * Published when: StoreAdapter.append() adds an event to a subject
11
+ * Used by: StreamCoordinator (store-sync channel)
12
+ */
13
+ declare function getStoreAppendTopic(subject: string): string;
14
+ /**
15
+ * Get topic for store save events
16
+ * Pattern: store:save:{collection}
17
+ * Published when: StoreAdapter.save() creates/updates a document
18
+ */
19
+ declare function getStoreSaveTopic(collection: string): string;
20
+ /**
21
+ * Get topic for store delete events
22
+ * Pattern: store:delete:{collection}
23
+ * Published when: StoreAdapter.delete() removes a document
24
+ */
25
+ declare function getStoreDeleteTopic(collection: string): string;
26
+ /**
27
+ * Get topic for KV store events
28
+ * Pattern: store:kv:{key}
29
+ * Published when: StoreAdapter.kvSet() updates a key
30
+ */
31
+ declare function getStoreKvTopic(key: string): string;
32
+ /**
33
+ * Get topic for flow orchestration events
34
+ * Pattern: flow:event:{runId}
35
+ * Published when: StreamCoordinator flow-events channel publishes flow lifecycle events
36
+ * Used by: Future trigger system for cross-instance coordination
37
+ */
38
+ declare function getFlowEventTopic(runId: string): string;
39
+ /**
40
+ * Get topic for client messages (WebSocket/SSE)
41
+ * Pattern: client:flow:{runId}
42
+ * Published when: StreamCoordinator client-messages channel publishes UI updates
43
+ * Used by: WebSocket handler for real-time UI updates
44
+ */
45
+ declare function getClientFlowTopic(runId: string): string;
46
+ export declare function useStreamTopics(): {
47
+ getStoreAppendTopic: typeof getStoreAppendTopic;
48
+ getStoreSaveTopic: typeof getStoreSaveTopic;
49
+ getStoreDeleteTopic: typeof getStoreDeleteTopic;
50
+ getStoreKvTopic: typeof getStoreKvTopic;
51
+ getFlowEventTopic: typeof getFlowEventTopic;
52
+ getClientFlowTopic: typeof getClientFlowTopic;
53
+ SubjectPatterns: {
54
+ /**
55
+ * Flow run event stream subject
56
+ */
57
+ readonly flowRun: (runId: string) => string;
58
+ /**
59
+ * Flow run index (sorted set of runs by flow name)
60
+ */
61
+ readonly flowRunIndex: (flowName: string) => string;
62
+ /**
63
+ * Flow definition subject
64
+ */
65
+ readonly flowDefinition: (flowName: string) => string;
66
+ /**
67
+ * Worker heartbeat subject
68
+ */
69
+ readonly workerHeartbeat: (workerId: string) => string;
70
+ };
71
+ };
72
+ export {};
@@ -0,0 +1,47 @@
1
+ function getStoreAppendTopic(subject) {
2
+ return `store:append:${subject}`;
3
+ }
4
+ function getStoreSaveTopic(collection) {
5
+ return `store:save:${collection}`;
6
+ }
7
+ function getStoreDeleteTopic(collection) {
8
+ return `store:delete:${collection}`;
9
+ }
10
+ function getStoreKvTopic(key) {
11
+ return `store:kv:${key}`;
12
+ }
13
+ function getFlowEventTopic(runId) {
14
+ return `flow:event:${runId}`;
15
+ }
16
+ function getClientFlowTopic(runId) {
17
+ return `client:flow:${runId}`;
18
+ }
19
+ const SubjectPatterns = {
20
+ /**
21
+ * Flow run event stream subject
22
+ */
23
+ flowRun: (runId) => `nq:flow:${runId}`,
24
+ /**
25
+ * Flow run index (sorted set of runs by flow name)
26
+ */
27
+ flowRunIndex: (flowName) => `nq:flows:${flowName}`,
28
+ /**
29
+ * Flow definition subject
30
+ */
31
+ flowDefinition: (flowName) => `flow-def:${flowName}`,
32
+ /**
33
+ * Worker heartbeat subject
34
+ */
35
+ workerHeartbeat: (workerId) => `worker:${workerId}`
36
+ };
37
+ export function useStreamTopics() {
38
+ return {
39
+ getStoreAppendTopic,
40
+ getStoreSaveTopic,
41
+ getStoreDeleteTopic,
42
+ getStoreKvTopic,
43
+ getFlowEventTopic,
44
+ getClientFlowTopic,
45
+ SubjectPatterns
46
+ };
47
+ }
@@ -1,5 +1,17 @@
1
- import type { Job as BullJob } from 'bullmq';
2
1
  import { useFlowEngine } 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
+ }
3
15
  export interface RunLogger {
4
16
  log: (level: 'debug' | 'info' | 'warn' | 'error', msg: string, meta?: any) => void;
5
17
  }
@@ -24,4 +36,8 @@ export interface RunContext {
24
36
  }
25
37
  export declare function buildContext(partial?: Partial<RunContext>): RunContext;
26
38
  export type NodeHandler = (input: any, ctx: RunContext) => Promise<any>;
27
- export declare function createBullMQProcessor(handler: NodeHandler, queueName: string): (job: BullJob) => Promise<any>;
39
+ /**
40
+ * Wraps a NodeHandler with full RunContext building and event emission
41
+ * Works with any queue adapter by accepting a job-like object
42
+ */
43
+ export declare function createJobProcessor(handler: NodeHandler, queueName: string): (job: QueueJob) => Promise<any>;
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { getStateProvider } from "../../state/stateFactory.js";
3
- import { useRuntimeConfig, useLogs, useFlowEngine, useEventManager, useNventLogger } from "#imports";
2
+ import { useStateAdapter } from "../../utils/adapters.js";
3
+ import { useRuntimeConfig, useFlowEngine, useEventManager, useNventLogger } from "#imports";
4
+ const logger = useNventLogger("node-runner");
4
5
  const defaultState = {
5
6
  async get() {
6
7
  return null;
@@ -17,31 +18,40 @@ function scopeKey(baseKey, flowId) {
17
18
  export function buildContext(partial) {
18
19
  const state = partial?.state || (() => {
19
20
  try {
20
- const state2 = getStateProvider();
21
+ const stateAdapter = useStateAdapter();
21
22
  const rc = useRuntimeConfig();
22
- const cleanupCfg = rc?.queue?.state?.cleanup || { strategy: "never" };
23
+ const cleanupCfg = rc?.nvent?.state?.cleanup || { strategy: "never" };
23
24
  return {
24
25
  async get(key) {
25
- return state2.get(scopeKey(key, partial?.flowId));
26
+ return stateAdapter.get(scopeKey(key, partial?.flowId));
26
27
  },
27
28
  async set(key, value, opts) {
28
29
  const ttl = opts?.ttl ?? (cleanupCfg?.strategy === "ttl" ? cleanupCfg?.ttlMs : void 0);
29
- return state2.set(scopeKey(key, partial?.flowId), value, ttl ? { ttl } : void 0);
30
+ return stateAdapter.set(scopeKey(key, partial?.flowId), value, ttl ? { ttl } : void 0);
30
31
  },
31
32
  async delete(key) {
32
- return state2.delete(scopeKey(key, partial?.flowId));
33
+ return stateAdapter.delete(scopeKey(key, partial?.flowId));
33
34
  }
34
35
  };
35
36
  } catch {
36
37
  return defaultState;
37
38
  }
38
39
  })();
39
- const logger = partial?.logger || (() => {
40
- const logs = useLogs();
40
+ const logger2 = partial?.logger || (() => {
41
+ const eventManager = useEventManager();
41
42
  return {
42
43
  log: (level, msg, meta) => {
43
- const mergedMeta = { ...meta || {} };
44
- void logs.publishLog(level, msg, mergedMeta, { queue: partial?.queue, jobId: partial?.jobId, flowId: partial?.flowId });
44
+ const runId = partial?.flowId || "unknown";
45
+ const flowName = meta?.flowName || "unknown";
46
+ void eventManager.publishBus({
47
+ type: "log",
48
+ runId,
49
+ flowName,
50
+ stepName: meta?.stepName,
51
+ stepId: meta?.stepId || meta?.stepRunId,
52
+ attempt: meta?.attempt,
53
+ data: { level, message: msg, ...meta }
54
+ });
45
55
  }
46
56
  };
47
57
  })();
@@ -55,6 +65,26 @@ export function buildContext(partial) {
55
65
  flowName: payload.flowName || partial?.flowName
56
66
  };
57
67
  return baseFlowEngine.emit(trigger, enrichedPayload);
68
+ },
69
+ cancel: async () => {
70
+ if (!partial?.flowName || !partial?.flowId) {
71
+ throw new Error("Cannot cancel flow: flowName or flowId not available in context");
72
+ }
73
+ return baseFlowEngine.cancelFlow(partial.flowName, partial.flowId);
74
+ },
75
+ isRunning: async (flowName, runId) => {
76
+ const targetFlowName = flowName || partial?.flowName;
77
+ if (!targetFlowName) {
78
+ throw new Error("flowName is required to check if flow is running");
79
+ }
80
+ return baseFlowEngine.isRunning(targetFlowName, runId);
81
+ },
82
+ getRunningFlows: async (flowName) => {
83
+ const targetFlowName = flowName || partial?.flowName;
84
+ if (!targetFlowName) {
85
+ throw new Error("flowName is required to get running flows");
86
+ }
87
+ return baseFlowEngine.getRunningFlows(targetFlowName);
58
88
  }
59
89
  };
60
90
  return {
@@ -65,13 +95,12 @@ export function buildContext(partial) {
65
95
  stepName: partial?.stepName,
66
96
  stepId: partial?.stepId,
67
97
  attempt: partial?.attempt,
68
- logger,
98
+ logger: logger2,
69
99
  state,
70
100
  flow
71
101
  };
72
102
  }
73
- export function createBullMQProcessor(handler, queueName) {
74
- const logger = useNventLogger("node-runner");
103
+ export function createJobProcessor(handler, queueName) {
75
104
  return async function processor(job) {
76
105
  if (job.data?.__scheduledFlowStart) {
77
106
  const { __flowName, __flowInput } = job.data;
@@ -90,7 +119,7 @@ export function createBullMQProcessor(handler, queueName) {
90
119
  }
91
120
  const eventMgr = useEventManager();
92
121
  const rc = useRuntimeConfig();
93
- const autoScope = rc?.queue?.state?.autoScope || "always";
122
+ const autoScope = rc?.nvent?.store?.state?.autoScope || "always";
94
123
  const providedFlow = job.data?.flowId;
95
124
  const flowId = providedFlow || (autoScope === "always" ? randomUUID() : void 0);
96
125
  const attempt = (job.attemptsMade || 0) + 1;
@@ -166,8 +195,6 @@ export function createBullMQProcessor(handler, queueName) {
166
195
  data: {
167
196
  stepName: job.name,
168
197
  queue: queueName,
169
- error: String(err?.message || err),
170
- stack: err?.stack,
171
198
  attempt,
172
199
  maxAttempts,
173
200
  nextAttempt: attempt + 1
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.3",
4
- "description": "Nuxt queue service based on Bullmq",
5
- "repository": "DevJoghurt/nuxt-queue",
3
+ "version": "0.4.5",
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",
23
+ "test": "vitest"
29
24
  },
30
25
  "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
26
  "@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
27
  "chokidar": "^4.0.3",
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
36
  "zod": "^4.1.12"
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.10"
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.