nvent 0.4.4 → 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 -80
  131. package/dist/runtime/app/composables/useFlowRunTimeline.js +0 -68
  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 -26
  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 -45
  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
@@ -1,125 +0,0 @@
1
- import { type Ref } from '#imports';
2
- /**
3
- * Client-Side Flow State Reducer
4
- *
5
- * Reduces an array of events from the flow timeline into current state.
6
- */
7
- export interface FlowState {
8
- status: 'running' | 'completed' | 'failed';
9
- startedAt?: string;
10
- completedAt?: string;
11
- steps: Record<string, StepState>;
12
- logs: LogEntry[];
13
- meta?: Record<string, any>;
14
- }
15
- export interface StepState {
16
- status: 'pending' | 'running' | 'completed' | 'failed' | 'retrying' | 'waiting' | 'timeout';
17
- attempt: number;
18
- startedAt?: string;
19
- completedAt?: string;
20
- error?: string;
21
- awaitType?: 'time' | 'event' | 'trigger';
22
- awaitData?: any;
23
- result?: any;
24
- }
25
- export interface LogEntry {
26
- ts: string;
27
- step?: string;
28
- level: string;
29
- msg: string;
30
- data?: any;
31
- }
32
- export interface EventRecord {
33
- id: string;
34
- ts: string;
35
- type: string;
36
- runId: string;
37
- flowName?: string;
38
- stepName?: string;
39
- stepId?: string;
40
- attempt?: number;
41
- data?: any;
42
- }
43
- /**
44
- * Reduce an array of events into current flow state
45
- */
46
- export declare function reduceFlowState(events: EventRecord[]): FlowState;
47
- /**
48
- * Composable for managing flow state from event stream
49
- *
50
- * Usage:
51
- * ```typescript
52
- * const { state, events, addEvent, addEvents, reset } = useFlowState()
53
- *
54
- * // Add events as they arrive
55
- * addEvent(newEvent)
56
- *
57
- * // Access computed state
58
- * console.log(state.value.status) // 'running' | 'completed' | 'failed'
59
- * ```
60
- */
61
- export declare function useFlowState(initialEvents?: EventRecord[]): {
62
- events: Ref<EventRecord[], EventRecord[]>;
63
- state: import("vue").ComputedRef<FlowState>;
64
- addEvent: (event: EventRecord) => void;
65
- addEvents: (newEvents: EventRecord[]) => void;
66
- reset: (newEvents?: EventRecord[]) => void;
67
- isRunning: import("vue").ComputedRef<boolean>;
68
- isCompleted: import("vue").ComputedRef<boolean>;
69
- isFailed: import("vue").ComputedRef<boolean>;
70
- stepList: import("vue").ComputedRef<{
71
- status: "pending" | "running" | "completed" | "failed" | "retrying" | "waiting" | "timeout";
72
- attempt: number;
73
- startedAt?: string;
74
- completedAt?: string;
75
- error?: string;
76
- awaitType?: "time" | "event" | "trigger";
77
- awaitData?: any;
78
- result?: any;
79
- key: string;
80
- }[]>;
81
- runningSteps: import("vue").ComputedRef<{
82
- status: "pending" | "running" | "completed" | "failed" | "retrying" | "waiting" | "timeout";
83
- attempt: number;
84
- startedAt?: string;
85
- completedAt?: string;
86
- error?: string;
87
- awaitType?: "time" | "event" | "trigger";
88
- awaitData?: any;
89
- result?: any;
90
- key: string;
91
- }[]>;
92
- waitingSteps: import("vue").ComputedRef<{
93
- status: "pending" | "running" | "completed" | "failed" | "retrying" | "waiting" | "timeout";
94
- attempt: number;
95
- startedAt?: string;
96
- completedAt?: string;
97
- error?: string;
98
- awaitType?: "time" | "event" | "trigger";
99
- awaitData?: any;
100
- result?: any;
101
- key: string;
102
- }[]>;
103
- failedSteps: import("vue").ComputedRef<{
104
- status: "pending" | "running" | "completed" | "failed" | "retrying" | "waiting" | "timeout";
105
- attempt: number;
106
- startedAt?: string;
107
- completedAt?: string;
108
- error?: string;
109
- awaitType?: "time" | "event" | "trigger";
110
- awaitData?: any;
111
- result?: any;
112
- key: string;
113
- }[]>;
114
- completedSteps: import("vue").ComputedRef<{
115
- status: "pending" | "running" | "completed" | "failed" | "retrying" | "waiting" | "timeout";
116
- attempt: number;
117
- startedAt?: string;
118
- completedAt?: string;
119
- error?: string;
120
- awaitType?: "time" | "event" | "trigger";
121
- awaitData?: any;
122
- result?: any;
123
- key: string;
124
- }[]>;
125
- };
@@ -1,211 +0,0 @@
1
- import { ref, computed } from "#imports";
2
- export function reduceFlowState(events) {
3
- const state = {
4
- status: "running",
5
- steps: {},
6
- logs: []
7
- };
8
- for (const e of events) {
9
- const eventType = e.type;
10
- const stepKey = e.stepName;
11
- switch (eventType) {
12
- case "flow.start":
13
- case "flow.started":
14
- state.status = "running";
15
- state.startedAt = e.ts;
16
- if (e.flowName) state.meta = { ...state.meta, flowName: e.flowName };
17
- if (e.data?.flowName) state.meta = { ...state.meta, flowName: e.data.flowName };
18
- if (e.data?.input) state.meta = { ...state.meta, input: e.data.input };
19
- break;
20
- case "flow.complete":
21
- case "flow.completed":
22
- state.status = "completed";
23
- state.completedAt = e.ts;
24
- if (e.data?.result) state.meta = { ...state.meta, result: e.data.result };
25
- break;
26
- case "flow.failed":
27
- state.status = "failed";
28
- state.completedAt = e.ts;
29
- if (e.data?.error) state.meta = { ...state.meta, error: e.data.error };
30
- break;
31
- case "step.started": {
32
- if (!stepKey) break;
33
- if (!state.steps[stepKey]) {
34
- state.steps[stepKey] = {
35
- status: "running",
36
- attempt: 1
37
- };
38
- }
39
- const currentStatus = state.steps[stepKey].status;
40
- if (currentStatus !== "completed" && currentStatus !== "failed" && currentStatus !== "timeout") {
41
- state.steps[stepKey].status = "running";
42
- }
43
- state.steps[stepKey].startedAt = e.ts;
44
- state.steps[stepKey].attempt = e.attempt || state.steps[stepKey].attempt || 1;
45
- break;
46
- }
47
- case "step.completed": {
48
- if (!stepKey) break;
49
- if (!state.steps[stepKey]) {
50
- state.steps[stepKey] = { status: "completed", attempt: 1 };
51
- }
52
- state.steps[stepKey].status = "completed";
53
- state.steps[stepKey].completedAt = e.ts;
54
- if (e.data?.result !== void 0) state.steps[stepKey].result = e.data.result;
55
- break;
56
- }
57
- case "step.failed": {
58
- if (!stepKey) break;
59
- if (!state.steps[stepKey]) {
60
- state.steps[stepKey] = { status: "failed", attempt: 1 };
61
- }
62
- const willRetry = e.data?.willRetry || e.data?.retry;
63
- state.steps[stepKey].status = willRetry ? "retrying" : "failed";
64
- state.steps[stepKey].error = e.data?.error || e.data?.message;
65
- if (!willRetry) {
66
- state.steps[stepKey].completedAt = e.ts;
67
- }
68
- break;
69
- }
70
- case "step.retry": {
71
- if (!stepKey) break;
72
- if (!state.steps[stepKey]) {
73
- state.steps[stepKey] = { status: "retrying", attempt: 1 };
74
- }
75
- state.steps[stepKey].status = "retrying";
76
- state.steps[stepKey].attempt = e.data?.nextAttempt || e.attempt || 1;
77
- state.steps[stepKey].error = e.data?.error;
78
- break;
79
- }
80
- case "step.await.time":
81
- case "step.await.event":
82
- case "step.await.trigger": {
83
- if (!stepKey) break;
84
- if (!state.steps[stepKey]) {
85
- state.steps[stepKey] = { status: "waiting", attempt: 1 };
86
- }
87
- state.steps[stepKey].status = "waiting";
88
- state.steps[stepKey].awaitType = eventType.split(".")[2];
89
- state.steps[stepKey].awaitData = e.data;
90
- break;
91
- }
92
- case "step.resumed": {
93
- if (!stepKey) break;
94
- if (!state.steps[stepKey]) {
95
- state.steps[stepKey] = { status: "running", attempt: 1 };
96
- }
97
- state.steps[stepKey].status = "running";
98
- delete state.steps[stepKey].awaitType;
99
- delete state.steps[stepKey].awaitData;
100
- break;
101
- }
102
- case "step.await.timeout": {
103
- if (!stepKey) break;
104
- if (!state.steps[stepKey]) {
105
- state.steps[stepKey] = { status: "timeout", attempt: 1 };
106
- }
107
- state.steps[stepKey].status = "timeout";
108
- state.steps[stepKey].error = `Await timeout after ${e.data?.duration}ms`;
109
- state.steps[stepKey].completedAt = e.ts;
110
- break;
111
- }
112
- case "runner.log":
113
- case "log": {
114
- state.logs.push({
115
- ts: e.ts,
116
- step: stepKey,
117
- level: e.data?.level || "info",
118
- msg: e.data?.message || e.data?.msg || (typeof e.data === "string" ? e.data : String(e.data)),
119
- data: e.data
120
- });
121
- break;
122
- }
123
- // Handle any unrecognized events - log for debugging
124
- default: {
125
- if (typeof console !== "undefined" && eventType && !eventType.startsWith("_")) {
126
- console.debug("[useFlowState] Unhandled event type:", eventType, {
127
- stepName: e.stepName,
128
- stepKey,
129
- data: e.data
130
- });
131
- }
132
- }
133
- }
134
- }
135
- if (!state.startedAt && events.length > 0 && events[0]) {
136
- state.startedAt = events[0].ts;
137
- }
138
- if (state.status === "running" && state.startedAt && Object.keys(state.steps).length > 0) {
139
- const hasRunningSteps = Object.values(state.steps).some(
140
- (s) => s.status === "running" || s.status === "retrying" || s.status === "waiting"
141
- );
142
- const hasFailedSteps = Object.values(state.steps).some((s) => s.status === "failed");
143
- const allStepsTerminal = Object.values(state.steps).every(
144
- (s) => s.status === "completed" || s.status === "failed" || s.status === "timeout"
145
- );
146
- if (!hasRunningSteps && allStepsTerminal) {
147
- if (hasFailedSteps) {
148
- state.status = "failed";
149
- } else {
150
- state.status = "completed";
151
- }
152
- const latestCompletion = Object.values(state.steps).map((s) => s.completedAt).filter(Boolean).sort().pop();
153
- if (latestCompletion) {
154
- state.completedAt = latestCompletion;
155
- }
156
- }
157
- }
158
- return state;
159
- }
160
- export function useFlowState(initialEvents = []) {
161
- const events = ref(initialEvents);
162
- const state = computed(() => reduceFlowState(events.value));
163
- const addEvent = (event) => {
164
- events.value.push(event);
165
- };
166
- const addEvents = (newEvents) => {
167
- events.value.push(...newEvents);
168
- };
169
- const reset = (newEvents = []) => {
170
- events.value = newEvents;
171
- };
172
- const isRunning = computed(() => state.value.status === "running");
173
- const isCompleted = computed(() => state.value.status === "completed");
174
- const isFailed = computed(() => state.value.status === "failed");
175
- const stepList = computed(() => {
176
- return Object.entries(state.value.steps).map(([key, step]) => ({
177
- key,
178
- ...step
179
- }));
180
- });
181
- const runningSteps = computed(() => {
182
- return stepList.value.filter((s) => s.status === "running");
183
- });
184
- const waitingSteps = computed(() => {
185
- return stepList.value.filter((s) => s.status === "waiting");
186
- });
187
- const failedSteps = computed(() => {
188
- return stepList.value.filter((s) => s.status === "failed");
189
- });
190
- const completedSteps = computed(() => {
191
- return stepList.value.filter((s) => s.status === "completed");
192
- });
193
- return {
194
- // Raw data
195
- events,
196
- state,
197
- // Methods
198
- addEvent,
199
- addEvents,
200
- reset,
201
- // Computed helpers
202
- isRunning,
203
- isCompleted,
204
- isFailed,
205
- stepList,
206
- runningSteps,
207
- waitingSteps,
208
- failedSteps,
209
- completedSteps
210
- };
211
- }
@@ -1,27 +0,0 @@
1
- export interface UseFlowWebSocketOptions {
2
- autoReconnect?: boolean;
3
- maxRetries?: number;
4
- baseDelayMs?: number;
5
- maxDelayMs?: number;
6
- onOpen?: () => void;
7
- onError?: (err?: any) => void;
8
- onClose?: (event?: CloseEvent) => void;
9
- }
10
- export interface FlowSubscription {
11
- flowName: string;
12
- runId: string;
13
- onEvent: (event: any) => void;
14
- onHistory?: (events: any[]) => void;
15
- }
16
- /**
17
- * WebSocket composable for flow run events
18
- * Replaces the SSE-based useEventSSE with a more reliable WebSocket implementation
19
- */
20
- export declare function useFlowWebSocket(): {
21
- subscribe: (subscription: FlowSubscription, opts?: UseFlowWebSocketOptions) => void;
22
- unsubscribe: () => void;
23
- stop: () => void;
24
- connected: import("vue").Ref<boolean, boolean>;
25
- reconnecting: import("vue").Ref<boolean, boolean>;
26
- };
27
- export default useFlowWebSocket;
@@ -1,205 +0,0 @@
1
- import { ref, onBeforeUnmount } from "#imports";
2
- export function useFlowWebSocket() {
3
- const ws = ref(null);
4
- const connected = ref(false);
5
- const reconnecting = ref(false);
6
- let retry = 0;
7
- let reconnectTimer = null;
8
- let currentOptions;
9
- let currentSubscription = null;
10
- let pingInterval = null;
11
- let isServerRestarting = false;
12
- const computeDelay = (opts) => {
13
- const base = Math.max(100, opts?.baseDelayMs ?? 1e3);
14
- const max = Math.max(base, opts?.maxDelayMs ?? 1e4);
15
- const exp = Math.min(max, base * Math.pow(2, retry));
16
- const jitter = Math.floor(Math.random() * Math.min(1e3, exp / 4));
17
- return exp + jitter;
18
- };
19
- const clearTimers = () => {
20
- if (reconnectTimer) {
21
- try {
22
- clearTimeout(reconnectTimer);
23
- } catch {
24
- }
25
- reconnectTimer = null;
26
- }
27
- if (pingInterval) {
28
- try {
29
- clearInterval(pingInterval);
30
- } catch {
31
- }
32
- pingInterval = null;
33
- }
34
- };
35
- const send = (data) => {
36
- if (ws.value && ws.value.readyState === WebSocket.OPEN) {
37
- ws.value.send(JSON.stringify(data));
38
- }
39
- };
40
- const startPingInterval = () => {
41
- clearTimers();
42
- pingInterval = setInterval(() => {
43
- if (ws.value && ws.value.readyState === WebSocket.OPEN) {
44
- send({ type: "ping" });
45
- }
46
- }, 3e4);
47
- };
48
- const stop = () => {
49
- clearTimers();
50
- isServerRestarting = false;
51
- try {
52
- if (ws.value) {
53
- ws.value.close(1e3, "Client closing");
54
- }
55
- } catch (err) {
56
- console.warn("[useFlowWebSocket] Error closing WebSocket:", err);
57
- }
58
- ws.value = null;
59
- connected.value = false;
60
- reconnecting.value = false;
61
- retry = 0;
62
- currentSubscription = null;
63
- };
64
- const attemptReconnect = () => {
65
- if (!currentOptions?.autoReconnect) {
66
- stop();
67
- return;
68
- }
69
- const max = Math.max(0, currentOptions?.maxRetries ?? 10);
70
- if (retry >= max) {
71
- console.error("[useFlowWebSocket] Max retries reached");
72
- stop();
73
- return;
74
- }
75
- retry++;
76
- reconnecting.value = true;
77
- const baseDelay = isServerRestarting ? 2e3 : computeDelay(currentOptions);
78
- const delay = baseDelay;
79
- console.log(`[useFlowWebSocket] Will attempt reconnection in ${delay}ms (attempt ${retry}/${max})${isServerRestarting ? " [server restart]" : ""}`);
80
- clearTimers();
81
- reconnectTimer = setTimeout(() => {
82
- if (currentSubscription) {
83
- innerSubscribe(currentSubscription, currentOptions);
84
- }
85
- }, delay);
86
- };
87
- const setupWebSocket = (socket, subscription, opts) => {
88
- socket.onopen = () => {
89
- console.log("[useFlowWebSocket] Connected");
90
- connected.value = true;
91
- reconnecting.value = false;
92
- retry = 0;
93
- startPingInterval();
94
- send({
95
- type: "subscribe",
96
- flowName: subscription.flowName,
97
- runId: subscription.runId
98
- });
99
- opts?.onOpen?.();
100
- };
101
- socket.onmessage = (event) => {
102
- try {
103
- const data = JSON.parse(event.data);
104
- switch (data.type) {
105
- case "connected":
106
- console.log("[useFlowWebSocket] Server acknowledged connection");
107
- break;
108
- case "subscribed":
109
- console.log("[useFlowWebSocket] Subscribed to flow:", data.flowName, data.runId);
110
- break;
111
- case "unsubscribed":
112
- console.log("[useFlowWebSocket] Unsubscribed from flow:", data.flowName, data.runId);
113
- break;
114
- case "history":
115
- if (subscription.onHistory) {
116
- subscription.onHistory(data.events);
117
- } else {
118
- for (const eventData of data.events) {
119
- subscription.onEvent(eventData);
120
- }
121
- }
122
- break;
123
- case "event":
124
- subscription.onEvent(data.event);
125
- break;
126
- case "pong":
127
- break;
128
- case "server-restart":
129
- console.log("[useFlowWebSocket] Server is restarting (HMR)");
130
- isServerRestarting = true;
131
- break;
132
- case "error":
133
- console.error("[useFlowWebSocket] Server error:", data.message);
134
- opts?.onError?.(new Error(data.message));
135
- break;
136
- default:
137
- console.warn("[useFlowWebSocket] Unknown message type:", data.type);
138
- }
139
- } catch (err) {
140
- console.error("[useFlowWebSocket] Error parsing message:", err);
141
- }
142
- };
143
- socket.onerror = (err) => {
144
- console.error("[useFlowWebSocket] WebSocket error:", err);
145
- opts?.onError?.(err);
146
- };
147
- socket.onclose = (event) => {
148
- console.log("[useFlowWebSocket] Connection closed:", event.code, event.reason);
149
- connected.value = false;
150
- clearTimers();
151
- opts?.onClose?.(event);
152
- const shouldReconnect = event.code !== 1e3 && opts?.autoReconnect;
153
- if (shouldReconnect) {
154
- console.log("[useFlowWebSocket] Will attempt reconnection (code:", event.code, ")");
155
- attemptReconnect();
156
- } else {
157
- isServerRestarting = false;
158
- }
159
- };
160
- };
161
- const innerSubscribe = (subscription, opts) => {
162
- if (import.meta.server || typeof WebSocket === "undefined") {
163
- console.warn("[useFlowWebSocket] WebSocket not available (SSR context)");
164
- return;
165
- }
166
- if (ws.value) {
167
- stop();
168
- }
169
- currentOptions = opts;
170
- currentSubscription = subscription;
171
- try {
172
- const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
173
- const wsUrl = `${protocol}//${window.location.host}/api/_flows/ws`;
174
- const socket = new WebSocket(wsUrl);
175
- ws.value = socket;
176
- setupWebSocket(socket, subscription, opts);
177
- } catch (err) {
178
- console.error("[useFlowWebSocket] Error creating WebSocket:", err);
179
- opts?.onError?.(err);
180
- attemptReconnect();
181
- }
182
- };
183
- const subscribe = (subscription, opts) => {
184
- innerSubscribe(subscription, opts);
185
- };
186
- const unsubscribe = () => {
187
- if (currentSubscription && ws.value && ws.value.readyState === WebSocket.OPEN) {
188
- send({
189
- type: "unsubscribe",
190
- flowName: currentSubscription.flowName,
191
- runId: currentSubscription.runId
192
- });
193
- }
194
- currentSubscription = null;
195
- };
196
- onBeforeUnmount(() => stop());
197
- return {
198
- subscribe,
199
- unsubscribe,
200
- stop,
201
- connected,
202
- reconnecting
203
- };
204
- }
205
- export default useFlowWebSocket;
@@ -1,10 +0,0 @@
1
- /**
2
- * Composable for managing flows page navigation state
3
- * Uses URL query params for persistence across HMR
4
- */
5
- export declare function useFlowsNavigation(): {
6
- selectedFlow: import("vue").WritableComputedRef<string, string>;
7
- selectedRunId: import("vue").WritableComputedRef<string, string>;
8
- timelineOpen: import("vue").Ref<boolean, boolean>;
9
- selectedTab: import("vue").WritableComputedRef<string, string>;
10
- };
@@ -1,58 +0,0 @@
1
- import { computed, ref, watch, useRoute, useRouter } from "#imports";
2
- export function useFlowsNavigation() {
3
- const route = useRoute();
4
- const router = useRouter();
5
- const selectedFlow = computed({
6
- get: () => route.query.flow || "",
7
- set: (value) => {
8
- router.push({
9
- query: {
10
- ...route.query,
11
- flow: value || void 0,
12
- run: void 0
13
- // Clear run when flow changes
14
- }
15
- });
16
- }
17
- });
18
- const selectedRunId = computed({
19
- get: () => route.query.run || "",
20
- set: (value) => {
21
- router.push({
22
- query: {
23
- ...route.query,
24
- run: value || void 0
25
- }
26
- });
27
- }
28
- });
29
- const timelineOpen = ref(route.query.timeline === "true");
30
- watch(timelineOpen, (value) => {
31
- router.push({
32
- query: {
33
- ...route.query,
34
- timeline: value ? "true" : void 0
35
- }
36
- });
37
- });
38
- watch(() => route.query.timeline, (value) => {
39
- timelineOpen.value = value === "true";
40
- });
41
- const selectedTab = computed({
42
- get: () => route.query.tab || "overview",
43
- set: (value) => {
44
- router.push({
45
- query: {
46
- ...route.query,
47
- tab: value !== "overview" ? value : void 0
48
- }
49
- });
50
- }
51
- });
52
- return {
53
- selectedFlow,
54
- selectedRunId,
55
- timelineOpen,
56
- selectedTab
57
- };
58
- }
@@ -1,26 +0,0 @@
1
- import { type Ref } from '#imports';
2
- import type { FetchError } from 'ofetch';
3
- export interface Job {
4
- id: string;
5
- name: string;
6
- data: any;
7
- state?: 'waiting' | 'active' | 'completed' | 'failed' | 'delayed' | 'paused';
8
- returnvalue?: any;
9
- failedReason?: string;
10
- timestamp?: number;
11
- processedOn?: number;
12
- finishedOn?: number;
13
- }
14
- export interface JobsResponse {
15
- jobs: Job[];
16
- }
17
- /**
18
- * Composable for fetching jobs for a queue
19
- * Client-only to avoid hydration mismatches
20
- */
21
- export declare function useQueueJobs(queueName: Ref<string>, state?: Ref<string | null>): {
22
- data: Ref<JobsResponse | null | undefined>;
23
- refresh: () => Promise<void>;
24
- status: Ref<'idle' | 'pending' | 'success' | 'error'>;
25
- error: Ref<FetchError | null | undefined>;
26
- };
@@ -1,20 +0,0 @@
1
- import { ref, useFetch } from "#imports";
2
- export function useQueueJobs(queueName, state = ref(null)) {
3
- return useFetch(
4
- () => {
5
- const params = new URLSearchParams();
6
- if (state.value) {
7
- params.append("state", state.value);
8
- }
9
- const queryString = params.toString();
10
- return `/api/_queues/${encodeURIComponent(queueName.value)}/job${queryString ? `?${queryString}` : ""}`;
11
- },
12
- {
13
- key: () => `queue-jobs-${queueName.value}-${state.value || "all"}`,
14
- watch: [queueName, state],
15
- immediate: true,
16
- server: false
17
- // Client-only
18
- }
19
- );
20
- }