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
@@ -1,122 +0,0 @@
1
- import { ref, computed, onUnmounted } from "#imports";
2
- export function useQueueUpdates(queueName) {
3
- const ws = ref(null);
4
- const isConnected = ref(false);
5
- const isReconnecting = ref(false);
6
- const state = ref({
7
- counts: null,
8
- lastEvent: null,
9
- countsUpdatedAt: null,
10
- shouldRefreshJobs: false
11
- });
12
- let reconnectTimeout = null;
13
- let reconnectAttempts = 0;
14
- const maxReconnectAttempts = 5;
15
- const connect = () => {
16
- if (!import.meta.client || !queueName.value) return;
17
- if (ws.value) {
18
- try {
19
- ws.value.close();
20
- } catch {
21
- }
22
- ws.value = null;
23
- }
24
- const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
25
- const wsUrl = `${protocol}//${window.location.host}/api/_queues/ws`;
26
- try {
27
- const socket = new WebSocket(wsUrl);
28
- ws.value = socket;
29
- socket.onopen = () => {
30
- console.log("[useQueueUpdates] connected");
31
- isConnected.value = true;
32
- isReconnecting.value = false;
33
- reconnectAttempts = 0;
34
- socket.send(JSON.stringify({
35
- type: "subscribe",
36
- queueName: queueName.value
37
- }));
38
- };
39
- socket.onmessage = (event) => {
40
- try {
41
- const message = JSON.parse(event.data);
42
- if (message.type === "event") {
43
- state.value.lastEvent = message.event;
44
- const eventType = message.event?.eventType;
45
- if (["waiting", "active", "completed", "failed"].includes(eventType)) {
46
- state.value.shouldRefreshJobs = true;
47
- }
48
- } else if (message.type === "counts") {
49
- state.value.counts = message.counts;
50
- state.value.countsUpdatedAt = Date.now();
51
- } else if (message.type === "error") {
52
- console.error("[useQueueUpdates] error:", message.message);
53
- }
54
- } catch (err) {
55
- console.error("[useQueueUpdates] parse error:", err);
56
- }
57
- };
58
- socket.onerror = (error) => {
59
- console.error("[useQueueUpdates] error:", error);
60
- };
61
- socket.onclose = () => {
62
- console.log("[useQueueUpdates] disconnected");
63
- isConnected.value = false;
64
- if (reconnectAttempts < maxReconnectAttempts && queueName.value) {
65
- isReconnecting.value = true;
66
- reconnectAttempts++;
67
- const delay = Math.min(1e3 * Math.pow(2, reconnectAttempts), 1e4);
68
- reconnectTimeout = setTimeout(() => {
69
- console.log(`[useQueueUpdates] reconnecting (attempt ${reconnectAttempts})...`);
70
- connect();
71
- }, delay);
72
- } else {
73
- isReconnecting.value = false;
74
- }
75
- };
76
- } catch (err) {
77
- console.error("[useQueueUpdates] connection error:", err);
78
- isConnected.value = false;
79
- }
80
- };
81
- const disconnect = () => {
82
- if (reconnectTimeout) {
83
- clearTimeout(reconnectTimeout);
84
- reconnectTimeout = null;
85
- }
86
- if (ws.value) {
87
- try {
88
- if (ws.value.readyState === WebSocket.OPEN) {
89
- ws.value.send(JSON.stringify({
90
- type: "unsubscribe",
91
- queueName: queueName.value
92
- }));
93
- }
94
- ws.value.close();
95
- } catch {
96
- }
97
- ws.value = null;
98
- }
99
- isConnected.value = false;
100
- isReconnecting.value = false;
101
- };
102
- if (import.meta.client && queueName.value) {
103
- connect();
104
- }
105
- onUnmounted(() => {
106
- disconnect();
107
- });
108
- const resetRefreshFlag = () => {
109
- state.value.shouldRefreshJobs = false;
110
- };
111
- return {
112
- isConnected: computed(() => isConnected.value),
113
- isReconnecting: computed(() => isReconnecting.value),
114
- counts: computed(() => state.value.counts),
115
- lastEvent: computed(() => state.value.lastEvent),
116
- countsUpdatedAt: computed(() => state.value.countsUpdatedAt),
117
- shouldRefreshJobs: computed(() => state.value.shouldRefreshJobs),
118
- resetRefreshFlag,
119
- connect,
120
- disconnect
121
- };
122
- }
@@ -1,44 +0,0 @@
1
- import type { FetchError } from 'ofetch';
2
- export interface QueueCounts {
3
- active: number;
4
- completed: number;
5
- failed: number;
6
- delayed: number;
7
- waiting: number;
8
- paused: number;
9
- }
10
- export interface QueueConfig {
11
- queue: {
12
- prefix?: string;
13
- defaultJobOptions?: Record<string, any>;
14
- limiter?: {
15
- max?: number;
16
- duration?: number;
17
- groupKey?: string;
18
- };
19
- };
20
- worker: {
21
- concurrency?: number;
22
- lockDurationMs?: number;
23
- maxStalledCount?: number;
24
- drainDelayMs?: number;
25
- autorun?: boolean;
26
- pollingIntervalMs?: number;
27
- };
28
- }
29
- export interface QueueInfo {
30
- name: string;
31
- counts: QueueCounts;
32
- isPaused: boolean;
33
- config?: QueueConfig;
34
- }
35
- /**
36
- * Composable for fetching queue list with job counts
37
- * Client-only to avoid hydration mismatches
38
- */
39
- export declare function useQueues(): {
40
- queues: globalThis.Ref<QueueInfo[] | null | undefined>;
41
- refresh: () => Promise<void>;
42
- status: globalThis.Ref<'idle' | 'pending' | 'success' | 'error'>;
43
- error: globalThis.Ref<FetchError | null | undefined>;
44
- };
@@ -1,26 +0,0 @@
1
- import { ref, useFetch } from "#imports";
2
- export function useQueues() {
3
- const refreshCounter = ref(0);
4
- const { data: queues, refresh: _refresh, status, error } = useFetch(
5
- () => `/api/_queues?_t=${refreshCounter.value}`,
6
- {
7
- immediate: false,
8
- watch: false,
9
- server: false
10
- // Client-only
11
- }
12
- );
13
- const refresh = async () => {
14
- refreshCounter.value++;
15
- await _refresh();
16
- };
17
- if (import.meta.client) {
18
- refresh();
19
- }
20
- return {
21
- queues,
22
- refresh,
23
- status,
24
- error
25
- };
26
- }
@@ -1,19 +0,0 @@
1
- import { type Ref } from '#imports';
2
- import type { QueueInfo, QueueCounts } from './useQueues.js';
3
- /**
4
- * Composable for live queue updates across all queues
5
- * Subscribes to WebSocket updates for multiple queues
6
- */
7
- export declare function useQueuesLive(queues: Ref<QueueInfo[] | null | undefined>): {
8
- queues: import("vue").ComputedRef<{
9
- counts: QueueCounts;
10
- name: string;
11
- isPaused: boolean;
12
- config?: import("#imports").QueueConfig;
13
- }[] | null>;
14
- isConnected: import("vue").ComputedRef<boolean>;
15
- isReconnecting: import("vue").ComputedRef<boolean>;
16
- liveCounts: import("vue").ComputedRef<Record<string, QueueCounts>>;
17
- connect: () => void;
18
- disconnect: () => void;
19
- };
@@ -1,143 +0,0 @@
1
- import { ref, computed, watch, onUnmounted } from "#imports";
2
- export function useQueuesLive(queues) {
3
- const ws = ref(null);
4
- const isConnected = ref(false);
5
- const isReconnecting = ref(false);
6
- const liveCounts = ref({});
7
- let reconnectTimeout = null;
8
- let reconnectAttempts = 0;
9
- const maxReconnectAttempts = 5;
10
- const safeSend = (data) => {
11
- if (!ws.value || ws.value.readyState !== WebSocket.OPEN) return false;
12
- try {
13
- ws.value.send(JSON.stringify(data));
14
- return true;
15
- } catch {
16
- return false;
17
- }
18
- };
19
- const subscribeToQueues = (queueNames) => {
20
- if (!ws.value || ws.value.readyState !== WebSocket.OPEN) return;
21
- for (const queueName of queueNames) {
22
- safeSend({
23
- type: "subscribe",
24
- queueName
25
- });
26
- }
27
- };
28
- const connect = () => {
29
- if (!import.meta.client) return;
30
- if (ws.value) {
31
- try {
32
- ws.value.close();
33
- } catch {
34
- }
35
- ws.value = null;
36
- }
37
- const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
38
- const wsUrl = `${protocol}//${window.location.host}/api/_queues/ws`;
39
- try {
40
- const socket = new WebSocket(wsUrl);
41
- ws.value = socket;
42
- socket.onopen = () => {
43
- console.log("[useQueuesLive] connected");
44
- isConnected.value = true;
45
- isReconnecting.value = false;
46
- reconnectAttempts = 0;
47
- if (queues.value) {
48
- const queueNames = queues.value.map((q) => q.name);
49
- subscribeToQueues(queueNames);
50
- }
51
- };
52
- socket.onmessage = (event) => {
53
- try {
54
- const message = JSON.parse(event.data);
55
- if (message.type === "counts" && message.queueName) {
56
- liveCounts.value[message.queueName] = message.counts;
57
- } else if (message.type === "error") {
58
- console.error("[useQueuesLive] error:", message.message);
59
- }
60
- } catch (err) {
61
- console.error("[useQueuesLive] parse error:", err);
62
- }
63
- };
64
- socket.onerror = (error) => {
65
- console.error("[useQueuesLive] error:", error);
66
- };
67
- socket.onclose = () => {
68
- console.log("[useQueuesLive] disconnected");
69
- isConnected.value = false;
70
- if (reconnectAttempts < maxReconnectAttempts) {
71
- isReconnecting.value = true;
72
- reconnectAttempts++;
73
- const delay = Math.min(1e3 * Math.pow(2, reconnectAttempts), 1e4);
74
- reconnectTimeout = setTimeout(() => {
75
- console.log(`[useQueuesLive] reconnecting (attempt ${reconnectAttempts})...`);
76
- connect();
77
- }, delay);
78
- } else {
79
- isReconnecting.value = false;
80
- }
81
- };
82
- } catch (err) {
83
- console.error("[useQueuesLive] connection error:", err);
84
- isConnected.value = false;
85
- }
86
- };
87
- const disconnect = () => {
88
- if (reconnectTimeout) {
89
- clearTimeout(reconnectTimeout);
90
- reconnectTimeout = null;
91
- }
92
- if (ws.value) {
93
- try {
94
- if (queues.value) {
95
- for (const queue of queues.value) {
96
- safeSend({
97
- type: "unsubscribe",
98
- queueName: queue.name
99
- });
100
- }
101
- }
102
- ws.value.close();
103
- } catch {
104
- }
105
- ws.value = null;
106
- }
107
- isConnected.value = false;
108
- isReconnecting.value = false;
109
- };
110
- if (import.meta.client) {
111
- connect();
112
- }
113
- watch(
114
- () => queues.value,
115
- (newQueues, oldQueues) => {
116
- if (!newQueues || !ws.value || ws.value.readyState !== WebSocket.OPEN) return;
117
- const oldNames = new Set(oldQueues?.map((q) => q.name) || []);
118
- const newNames = newQueues.map((q) => q.name);
119
- const toSubscribe = newNames.filter((name) => !oldNames.has(name));
120
- if (toSubscribe.length > 0) {
121
- subscribeToQueues(toSubscribe);
122
- }
123
- }
124
- );
125
- onUnmounted(() => {
126
- disconnect();
127
- });
128
- const queuesWithLiveCounts = computed(() => {
129
- if (!queues.value) return null;
130
- return queues.value.map((queue) => ({
131
- ...queue,
132
- counts: liveCounts.value[queue.name] || queue.counts
133
- }));
134
- });
135
- return {
136
- queues: queuesWithLiveCounts,
137
- isConnected: computed(() => isConnected.value),
138
- isReconnecting: computed(() => isReconnecting.value),
139
- liveCounts: computed(() => liveCounts.value),
140
- connect,
141
- disconnect
142
- };
143
- }
@@ -1,3 +0,0 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
- declare const _default: typeof __VLS_export;
3
- export default _default;