nvent 0.4.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/dist/module.d.mts +4 -185
  2. package/dist/module.json +3 -3
  3. package/dist/module.mjs +451 -257
  4. package/dist/runtime/adapters/base/index.d.ts +6 -0
  5. package/dist/runtime/adapters/base/index.js +1 -0
  6. package/dist/runtime/adapters/base/store-validator.d.ts +48 -0
  7. package/dist/runtime/adapters/base/store-validator.js +147 -0
  8. package/dist/runtime/adapters/builtin/file-queue.d.ts +67 -0
  9. package/dist/runtime/adapters/builtin/file-queue.js +499 -0
  10. package/dist/runtime/adapters/builtin/file-store.d.ts +32 -0
  11. package/dist/runtime/adapters/builtin/file-store.js +206 -0
  12. package/dist/runtime/adapters/builtin/file-stream.d.ts +39 -0
  13. package/dist/runtime/adapters/builtin/file-stream.js +56 -0
  14. package/dist/runtime/adapters/builtin/index.d.ts +10 -0
  15. package/dist/runtime/adapters/builtin/index.js +5 -0
  16. package/dist/runtime/adapters/builtin/memory-queue.d.ts +52 -0
  17. package/dist/runtime/adapters/builtin/memory-queue.js +243 -0
  18. package/dist/runtime/adapters/builtin/memory-store.d.ts +68 -0
  19. package/dist/runtime/adapters/builtin/memory-store.js +333 -0
  20. package/dist/runtime/adapters/builtin/memory-stream.d.ts +21 -0
  21. package/dist/runtime/adapters/builtin/memory-stream.js +56 -0
  22. package/dist/runtime/adapters/factory.d.ts +31 -0
  23. package/dist/runtime/adapters/factory.js +134 -0
  24. package/dist/runtime/adapters/index.d.ts +8 -0
  25. package/dist/runtime/adapters/index.js +3 -0
  26. package/dist/runtime/adapters/interfaces/index.d.ts +11 -0
  27. package/dist/runtime/adapters/interfaces/index.js +3 -0
  28. package/dist/runtime/adapters/interfaces/queue.d.ts +150 -0
  29. package/dist/runtime/adapters/interfaces/store.d.ts +297 -0
  30. package/dist/runtime/adapters/interfaces/stream.d.ts +62 -0
  31. package/dist/runtime/adapters/registry.d.ts +85 -0
  32. package/dist/runtime/adapters/registry.js +161 -0
  33. package/dist/runtime/config/index.d.ts +29 -0
  34. package/dist/runtime/config/index.js +175 -0
  35. package/dist/runtime/config/types.d.ts +397 -0
  36. package/dist/runtime/config/types.js +0 -0
  37. package/dist/runtime/{server-utils/events → events}/eventBus.d.ts +1 -1
  38. package/dist/runtime/events/types.d.ts +145 -0
  39. package/dist/runtime/events/types.js +0 -0
  40. package/dist/runtime/events/utils/scheduleTrigger.d.ts +8 -0
  41. package/dist/runtime/events/utils/scheduleTrigger.js +69 -0
  42. package/dist/runtime/events/utils/stallDetector.d.ts +140 -0
  43. package/dist/runtime/events/utils/stallDetector.js +436 -0
  44. package/dist/runtime/events/utils/triggerRuntime.d.ts +58 -0
  45. package/dist/runtime/events/utils/triggerRuntime.js +212 -0
  46. package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.d.ts +12 -11
  47. package/dist/runtime/events/wiring/flowWiring.js +1020 -0
  48. package/dist/runtime/events/wiring/registry.d.ts +19 -0
  49. package/dist/runtime/events/wiring/registry.js +35 -0
  50. package/dist/runtime/events/wiring/stateWiring.d.ts +37 -0
  51. package/dist/runtime/events/wiring/stateWiring.js +92 -0
  52. package/dist/runtime/events/wiring/streamWiring.d.ts +36 -0
  53. package/dist/runtime/events/wiring/streamWiring.js +156 -0
  54. package/dist/runtime/events/wiring/triggerWiring.d.ts +21 -0
  55. package/dist/runtime/events/wiring/triggerWiring.js +412 -0
  56. package/dist/runtime/nitro/plugins/00.adapters.d.ts +14 -0
  57. package/dist/runtime/nitro/plugins/00.adapters.js +73 -0
  58. package/dist/runtime/nitro/plugins/02.workers.js +63 -0
  59. package/dist/runtime/nitro/plugins/03.triggers.d.ts +12 -0
  60. package/dist/runtime/nitro/plugins/03.triggers.js +55 -0
  61. package/dist/runtime/nitro/routes/webhook.await.d.ts +23 -0
  62. package/dist/runtime/nitro/routes/webhook.await.js +90 -0
  63. package/dist/runtime/nitro/routes/webhook.trigger.d.ts +69 -0
  64. package/dist/runtime/nitro/routes/webhook.trigger.js +64 -0
  65. package/dist/runtime/nitro/utils/adapters.d.ts +66 -0
  66. package/dist/runtime/nitro/utils/adapters.js +51 -0
  67. package/dist/runtime/nitro/utils/awaitPatterns/event.d.ts +15 -0
  68. package/dist/runtime/nitro/utils/awaitPatterns/event.js +120 -0
  69. package/dist/runtime/nitro/utils/awaitPatterns/index.d.ts +28 -0
  70. package/dist/runtime/nitro/utils/awaitPatterns/index.js +55 -0
  71. package/dist/runtime/nitro/utils/awaitPatterns/schedule.d.ts +16 -0
  72. package/dist/runtime/nitro/utils/awaitPatterns/schedule.js +78 -0
  73. package/dist/runtime/nitro/utils/awaitPatterns/time.d.ts +15 -0
  74. package/dist/runtime/nitro/utils/awaitPatterns/time.js +67 -0
  75. package/dist/runtime/nitro/utils/awaitPatterns/webhook.d.ts +15 -0
  76. package/dist/runtime/nitro/utils/awaitPatterns/webhook.js +120 -0
  77. package/dist/runtime/nitro/utils/defineFunction.d.ts +10 -0
  78. package/dist/runtime/nitro/utils/defineFunction.js +17 -0
  79. package/dist/runtime/nitro/utils/defineFunctionConfig.d.ts +310 -0
  80. package/dist/runtime/nitro/utils/defineFunctionConfig.js +3 -0
  81. package/dist/runtime/nitro/utils/defineHooks.d.ts +41 -0
  82. package/dist/runtime/nitro/utils/defineHooks.js +6 -0
  83. package/dist/runtime/nitro/utils/registerAdapter.d.ts +59 -0
  84. package/dist/runtime/nitro/utils/registerAdapter.js +13 -0
  85. package/dist/runtime/nitro/utils/useAwait.d.ts +71 -0
  86. package/dist/runtime/nitro/utils/useAwait.js +139 -0
  87. package/dist/runtime/{server-utils → nitro}/utils/useEventManager.d.ts +2 -2
  88. package/dist/runtime/{server-utils → nitro}/utils/useEventManager.js +1 -1
  89. package/dist/runtime/nitro/utils/useFlow.d.ts +68 -0
  90. package/dist/runtime/nitro/utils/useFlow.js +226 -0
  91. package/dist/runtime/nitro/utils/useHookRegistry.d.ts +34 -0
  92. package/dist/runtime/nitro/utils/useHookRegistry.js +25 -0
  93. package/dist/runtime/{server-utils → nitro}/utils/useNventLogger.js +2 -2
  94. package/dist/runtime/nitro/utils/useRunContext.d.ts +6 -0
  95. package/dist/runtime/nitro/utils/useRunContext.js +102 -0
  96. package/dist/runtime/nitro/utils/useStreamTopics.d.ts +83 -0
  97. package/dist/runtime/nitro/utils/useStreamTopics.js +94 -0
  98. package/dist/runtime/nitro/utils/useTrigger.d.ts +150 -0
  99. package/dist/runtime/nitro/utils/useTrigger.js +320 -0
  100. package/dist/runtime/scheduler/index.d.ts +33 -0
  101. package/dist/runtime/scheduler/index.js +38 -0
  102. package/dist/runtime/scheduler/scheduler.d.ts +113 -0
  103. package/dist/runtime/scheduler/scheduler.js +623 -0
  104. package/dist/runtime/scheduler/types.d.ts +116 -0
  105. package/dist/runtime/scheduler/types.js +0 -0
  106. package/dist/runtime/tsconfig.json +8 -0
  107. package/dist/runtime/worker/node/runner.d.ts +53 -0
  108. package/dist/runtime/worker/node/runner.js +327 -0
  109. package/dist/types.d.mts +2 -2
  110. package/package.json +16 -46
  111. package/LICENSE +0 -21
  112. package/README.md +0 -389
  113. package/dist/runtime/app/assets/vueflow.css +0 -1
  114. package/dist/runtime/app/components/ConfirmDialog.d.vue.ts +0 -33
  115. package/dist/runtime/app/components/ConfirmDialog.vue +0 -121
  116. package/dist/runtime/app/components/ConfirmDialog.vue.d.ts +0 -33
  117. package/dist/runtime/app/components/FlowDiagram.d.vue.ts +0 -64
  118. package/dist/runtime/app/components/FlowDiagram.vue +0 -338
  119. package/dist/runtime/app/components/FlowDiagram.vue.d.ts +0 -64
  120. package/dist/runtime/app/components/FlowNodeCard.d.vue.ts +0 -29
  121. package/dist/runtime/app/components/FlowNodeCard.vue +0 -156
  122. package/dist/runtime/app/components/FlowNodeCard.vue.d.ts +0 -29
  123. package/dist/runtime/app/components/FlowRunOverview.d.vue.ts +0 -9
  124. package/dist/runtime/app/components/FlowRunOverview.vue +0 -291
  125. package/dist/runtime/app/components/FlowRunOverview.vue.d.ts +0 -9
  126. package/dist/runtime/app/components/FlowRunStatusBadge.d.vue.ts +0 -14
  127. package/dist/runtime/app/components/FlowRunStatusBadge.vue +0 -60
  128. package/dist/runtime/app/components/FlowRunStatusBadge.vue.d.ts +0 -14
  129. package/dist/runtime/app/components/FlowRunTimeline.d.vue.ts +0 -12
  130. package/dist/runtime/app/components/FlowRunTimeline.vue +0 -127
  131. package/dist/runtime/app/components/FlowRunTimeline.vue.d.ts +0 -12
  132. package/dist/runtime/app/components/FlowScheduleDialog.d.vue.ts +0 -16
  133. package/dist/runtime/app/components/FlowScheduleDialog.vue +0 -226
  134. package/dist/runtime/app/components/FlowScheduleDialog.vue.d.ts +0 -16
  135. package/dist/runtime/app/components/FlowSchedulesList.d.vue.ts +0 -12
  136. package/dist/runtime/app/components/FlowSchedulesList.vue +0 -99
  137. package/dist/runtime/app/components/FlowSchedulesList.vue.d.ts +0 -12
  138. package/dist/runtime/app/components/JobScheduling.d.vue.ts +0 -6
  139. package/dist/runtime/app/components/JobScheduling.vue +0 -203
  140. package/dist/runtime/app/components/JobScheduling.vue.d.ts +0 -6
  141. package/dist/runtime/app/components/ListItem.d.vue.ts +0 -23
  142. package/dist/runtime/app/components/ListItem.vue +0 -70
  143. package/dist/runtime/app/components/ListItem.vue.d.ts +0 -23
  144. package/dist/runtime/app/components/QueueConfigDetails.d.vue.ts +0 -45
  145. package/dist/runtime/app/components/QueueConfigDetails.vue +0 -412
  146. package/dist/runtime/app/components/QueueConfigDetails.vue.d.ts +0 -45
  147. package/dist/runtime/app/components/StatCounter.d.vue.ts +0 -9
  148. package/dist/runtime/app/components/StatCounter.vue +0 -25
  149. package/dist/runtime/app/components/StatCounter.vue.d.ts +0 -9
  150. package/dist/runtime/app/components/TimelineList.d.vue.ts +0 -7
  151. package/dist/runtime/app/components/TimelineList.vue +0 -210
  152. package/dist/runtime/app/components/TimelineList.vue.d.ts +0 -7
  153. package/dist/runtime/app/components/nhealth/component-router.d.vue.ts +0 -46
  154. package/dist/runtime/app/components/nhealth/component-router.vue +0 -26
  155. package/dist/runtime/app/components/nhealth/component-router.vue.d.ts +0 -46
  156. package/dist/runtime/app/components/nhealth/component-shell.d.vue.ts +0 -24
  157. package/dist/runtime/app/components/nhealth/component-shell.vue +0 -89
  158. package/dist/runtime/app/components/nhealth/component-shell.vue.d.ts +0 -24
  159. package/dist/runtime/app/composables/useAnalyzedFlows.d.ts +0 -14
  160. package/dist/runtime/app/composables/useAnalyzedFlows.js +0 -8
  161. package/dist/runtime/app/composables/useComponentRouter.d.ts +0 -38
  162. package/dist/runtime/app/composables/useComponentRouter.js +0 -240
  163. package/dist/runtime/app/composables/useFlowRunTimeline.d.ts +0 -80
  164. package/dist/runtime/app/composables/useFlowRunTimeline.js +0 -68
  165. package/dist/runtime/app/composables/useFlowRuns.d.ts +0 -18
  166. package/dist/runtime/app/composables/useFlowRuns.js +0 -32
  167. package/dist/runtime/app/composables/useFlowRunsInfinite.d.ts +0 -24
  168. package/dist/runtime/app/composables/useFlowRunsInfinite.js +0 -123
  169. package/dist/runtime/app/composables/useFlowRunsPolling.d.ts +0 -9
  170. package/dist/runtime/app/composables/useFlowRunsPolling.js +0 -33
  171. package/dist/runtime/app/composables/useFlowState.d.ts +0 -125
  172. package/dist/runtime/app/composables/useFlowState.js +0 -211
  173. package/dist/runtime/app/composables/useFlowWebSocket.d.ts +0 -27
  174. package/dist/runtime/app/composables/useFlowWebSocket.js +0 -205
  175. package/dist/runtime/app/composables/useFlowsNavigation.d.ts +0 -10
  176. package/dist/runtime/app/composables/useFlowsNavigation.js +0 -58
  177. package/dist/runtime/app/composables/useQueueJobs.d.ts +0 -26
  178. package/dist/runtime/app/composables/useQueueJobs.js +0 -20
  179. package/dist/runtime/app/composables/useQueueUpdates.d.ts +0 -26
  180. package/dist/runtime/app/composables/useQueueUpdates.js +0 -122
  181. package/dist/runtime/app/composables/useQueues.d.ts +0 -45
  182. package/dist/runtime/app/composables/useQueues.js +0 -26
  183. package/dist/runtime/app/composables/useQueuesLive.d.ts +0 -19
  184. package/dist/runtime/app/composables/useQueuesLive.js +0 -143
  185. package/dist/runtime/app/pages/flows/index.d.vue.ts +0 -3
  186. package/dist/runtime/app/pages/flows/index.vue +0 -645
  187. package/dist/runtime/app/pages/flows/index.vue.d.ts +0 -3
  188. package/dist/runtime/app/pages/index.d.vue.ts +0 -3
  189. package/dist/runtime/app/pages/index.vue +0 -34
  190. package/dist/runtime/app/pages/index.vue.d.ts +0 -3
  191. package/dist/runtime/app/pages/queues/index.d.vue.ts +0 -3
  192. package/dist/runtime/app/pages/queues/index.vue +0 -229
  193. package/dist/runtime/app/pages/queues/index.vue.d.ts +0 -3
  194. package/dist/runtime/app/pages/queues/job.d.vue.ts +0 -3
  195. package/dist/runtime/app/pages/queues/job.vue +0 -262
  196. package/dist/runtime/app/pages/queues/job.vue.d.ts +0 -3
  197. package/dist/runtime/app/pages/queues/jobs.d.vue.ts +0 -3
  198. package/dist/runtime/app/pages/queues/jobs.vue +0 -291
  199. package/dist/runtime/app/pages/queues/jobs.vue.d.ts +0 -3
  200. package/dist/runtime/app/plugins/vueflow.client.d.ts +0 -2
  201. package/dist/runtime/app/plugins/vueflow.client.js +0 -11
  202. package/dist/runtime/constants.d.ts +0 -11
  203. package/dist/runtime/constants.js +0 -11
  204. package/dist/runtime/schema.d.ts +0 -37
  205. package/dist/runtime/schema.js +0 -20
  206. package/dist/runtime/server/api/_flows/[name]/clear-history.delete.d.ts +0 -10
  207. package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +0 -44
  208. package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +0 -7
  209. package/dist/runtime/server/api/_flows/[name]/runs.get.js +0 -53
  210. package/dist/runtime/server/api/_flows/[name]/schedule.post.js +0 -57
  211. package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.d.ts +0 -2
  212. package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +0 -42
  213. package/dist/runtime/server/api/_flows/[name]/schedules.get.d.ts +0 -2
  214. package/dist/runtime/server/api/_flows/[name]/schedules.get.js +0 -48
  215. package/dist/runtime/server/api/_flows/[name]/start.post.d.ts +0 -2
  216. package/dist/runtime/server/api/_flows/[name]/start.post.js +0 -9
  217. package/dist/runtime/server/api/_flows/index.get.d.ts +0 -6
  218. package/dist/runtime/server/api/_flows/index.get.js +0 -5
  219. package/dist/runtime/server/api/_flows/ws.d.ts +0 -60
  220. package/dist/runtime/server/api/_flows/ws.js +0 -188
  221. package/dist/runtime/server/api/_queues/[name]/job/[id].get.d.ts +0 -2
  222. package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +0 -9
  223. package/dist/runtime/server/api/_queues/[name]/job/index.get.d.ts +0 -2
  224. package/dist/runtime/server/api/_queues/[name]/job/index.get.js +0 -18
  225. package/dist/runtime/server/api/_queues/index.get.d.ts +0 -2
  226. package/dist/runtime/server/api/_queues/index.get.js +0 -63
  227. package/dist/runtime/server/api/_queues/ws.d.ts +0 -48
  228. package/dist/runtime/server/api/_queues/ws.js +0 -205
  229. package/dist/runtime/server/plugins/00.event-store.d.ts +0 -13
  230. package/dist/runtime/server/plugins/00.event-store.js +0 -16
  231. package/dist/runtime/server/plugins/flow-management.d.ts +0 -13
  232. package/dist/runtime/server/plugins/flow-management.js +0 -65
  233. package/dist/runtime/server/plugins/queue-management.d.ts +0 -2
  234. package/dist/runtime/server/plugins/queue-management.js +0 -27
  235. package/dist/runtime/server/plugins/state-cleanup.d.ts +0 -11
  236. package/dist/runtime/server/plugins/state-cleanup.js +0 -93
  237. package/dist/runtime/server/plugins/worker-management.d.ts +0 -2
  238. package/dist/runtime/server/plugins/worker-management.js +0 -33
  239. package/dist/runtime/server/tsconfig.json +0 -3
  240. package/dist/runtime/server-utils/events/adapters/fileAdapter.d.ts +0 -2
  241. package/dist/runtime/server-utils/events/adapters/fileAdapter.js +0 -382
  242. package/dist/runtime/server-utils/events/adapters/memoryAdapter.d.ts +0 -2
  243. package/dist/runtime/server-utils/events/adapters/memoryAdapter.js +0 -171
  244. package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.d.ts +0 -2
  245. package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.js +0 -348
  246. package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.d.ts +0 -30
  247. package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.js +0 -82
  248. package/dist/runtime/server-utils/events/eventStoreFactory.d.ts +0 -19
  249. package/dist/runtime/server-utils/events/eventStoreFactory.js +0 -44
  250. package/dist/runtime/server-utils/events/streamNames.d.ts +0 -17
  251. package/dist/runtime/server-utils/events/streamNames.js +0 -17
  252. package/dist/runtime/server-utils/events/types.d.ts +0 -63
  253. package/dist/runtime/server-utils/events/wiring/flowWiring.js +0 -409
  254. package/dist/runtime/server-utils/events/wiring/registry.d.ts +0 -10
  255. package/dist/runtime/server-utils/events/wiring/registry.js +0 -24
  256. package/dist/runtime/server-utils/queue/adapters/bullmq.d.ts +0 -18
  257. package/dist/runtime/server-utils/queue/adapters/bullmq.js +0 -164
  258. package/dist/runtime/server-utils/queue/queueFactory.d.ts +0 -3
  259. package/dist/runtime/server-utils/queue/queueFactory.js +0 -10
  260. package/dist/runtime/server-utils/queue/types.d.ts +0 -47
  261. package/dist/runtime/server-utils/state/adapters/redis.d.ts +0 -2
  262. package/dist/runtime/server-utils/state/adapters/redis.js +0 -42
  263. package/dist/runtime/server-utils/state/stateFactory.d.ts +0 -3
  264. package/dist/runtime/server-utils/state/stateFactory.js +0 -17
  265. package/dist/runtime/server-utils/state/types.d.ts +0 -23
  266. package/dist/runtime/server-utils/utils/defineQueueConfig.d.ts +0 -154
  267. package/dist/runtime/server-utils/utils/defineQueueConfig.js +0 -2
  268. package/dist/runtime/server-utils/utils/defineQueueWorker.d.ts +0 -10
  269. package/dist/runtime/server-utils/utils/defineQueueWorker.js +0 -17
  270. package/dist/runtime/server-utils/utils/useEventStore.d.ts +0 -20
  271. package/dist/runtime/server-utils/utils/useEventStore.js +0 -119
  272. package/dist/runtime/server-utils/utils/useFlowEngine.d.ts +0 -9
  273. package/dist/runtime/server-utils/utils/useFlowEngine.js +0 -44
  274. package/dist/runtime/server-utils/utils/useLogs.d.ts +0 -41
  275. package/dist/runtime/server-utils/utils/useLogs.js +0 -74
  276. package/dist/runtime/server-utils/utils/useQueue.d.ts +0 -31
  277. package/dist/runtime/server-utils/utils/useQueue.js +0 -24
  278. package/dist/runtime/server-utils/worker/adapter.d.ts +0 -4
  279. package/dist/runtime/server-utils/worker/adapter.js +0 -66
  280. package/dist/runtime/server-utils/worker/runner/node.d.ts +0 -27
  281. package/dist/runtime/server-utils/worker/runner/node.js +0 -196
  282. package/dist/runtime/types.d.ts +0 -132
  283. /package/dist/runtime/{server-utils/events/types.js → adapters/interfaces/queue.js} +0 -0
  284. /package/dist/runtime/{server-utils/queue/types.js → adapters/interfaces/store.js} +0 -0
  285. /package/dist/runtime/{server-utils/state/types.js → adapters/interfaces/stream.js} +0 -0
  286. /package/dist/runtime/{server-utils/events → events}/eventBus.js +0 -0
  287. /package/dist/runtime/{server/plugins/00.ws-lifecycle.d.ts → nitro/plugins/01.ws-lifecycle.d.ts} +0 -0
  288. /package/dist/runtime/{server/plugins/00.ws-lifecycle.js → nitro/plugins/01.ws-lifecycle.js} +0 -0
  289. /package/dist/runtime/{server/api/_flows/[name]/schedule.post.d.ts → nitro/plugins/02.workers.d.ts} +0 -0
  290. /package/dist/runtime/{server-utils → nitro}/utils/useNventLogger.d.ts +0 -0
  291. /package/dist/runtime/{server-utils → nitro}/utils/wsPeerManager.d.ts +0 -0
  292. /package/dist/runtime/{server-utils → nitro}/utils/wsPeerManager.js +0 -0
  293. /package/dist/runtime/{python → worker/python}/get_config.py +0 -0
@@ -0,0 +1,333 @@
1
+ import { defu } from "defu";
2
+ import { createStoreValidator } from "../base/store-validator.js";
3
+ export class MemoryStoreAdapter {
4
+ // Event Stream storage: subject -> events
5
+ eventStreams = /* @__PURE__ */ new Map();
6
+ eventSubscriptions = /* @__PURE__ */ new Map();
7
+ subscriptionCounter = 0;
8
+ // Key-Value Store storage: key -> value
9
+ kvStore = /* @__PURE__ */ new Map();
10
+ // Sorted index storage: key -> sorted array of {id, score, metadata}
11
+ sortedIndices = /* @__PURE__ */ new Map();
12
+ // Validator for update operations
13
+ validator = createStoreValidator("MemoryStoreAdapter");
14
+ // Lock mechanism for atomic index operations
15
+ indexLocks = /* @__PURE__ */ new Map();
16
+ async close() {
17
+ this.eventStreams.clear();
18
+ this.eventSubscriptions.clear();
19
+ this.kvStore.clear();
20
+ this.sortedIndices.clear();
21
+ }
22
+ // ============================================================
23
+ // Event Stream
24
+ // ============================================================
25
+ stream = {
26
+ append: async (subject, event) => {
27
+ const eventRecord = {
28
+ id: this.generateId(),
29
+ ts: Date.now(),
30
+ ...event
31
+ };
32
+ if (!this.eventStreams.has(subject)) {
33
+ this.eventStreams.set(subject, []);
34
+ }
35
+ const stream = this.eventStreams.get(subject);
36
+ stream.push(eventRecord);
37
+ this.notifySubscribers(subject, eventRecord);
38
+ return eventRecord;
39
+ },
40
+ read: async (subject, opts) => {
41
+ const stream = this.eventStreams.get(subject) || [];
42
+ let events = [...stream];
43
+ if (opts?.types && opts.types.length > 0) {
44
+ events = events.filter((e) => opts.types.includes(e.type));
45
+ }
46
+ if (opts?.after) {
47
+ const afterIndex = events.findIndex((e) => e.id === opts.after);
48
+ if (afterIndex >= 0) {
49
+ events = events.slice(afterIndex + 1);
50
+ }
51
+ }
52
+ if (opts?.before) {
53
+ const beforeIndex = events.findIndex((e) => e.id === opts.before);
54
+ if (beforeIndex >= 0) {
55
+ events = events.slice(0, beforeIndex);
56
+ }
57
+ }
58
+ if (opts?.from) {
59
+ events = events.filter((e) => e.ts >= opts.from);
60
+ }
61
+ if (opts?.to) {
62
+ events = events.filter((e) => e.ts <= opts.to);
63
+ }
64
+ if (opts?.order === "desc") {
65
+ events.reverse();
66
+ }
67
+ if (opts?.limit) {
68
+ events = events.slice(0, opts.limit);
69
+ }
70
+ return events;
71
+ },
72
+ subscribe: async (subject, onEvent) => {
73
+ const subscriptionId = `sub-${++this.subscriptionCounter}`;
74
+ if (!this.eventSubscriptions.has(subject)) {
75
+ this.eventSubscriptions.set(subject, /* @__PURE__ */ new Map());
76
+ }
77
+ const subjectSubs = this.eventSubscriptions.get(subject);
78
+ subjectSubs.set(subscriptionId, onEvent);
79
+ return {
80
+ id: subscriptionId,
81
+ subject,
82
+ unsubscribe: async () => {
83
+ const subs = this.eventSubscriptions.get(subject);
84
+ if (subs) {
85
+ subs.delete(subscriptionId);
86
+ if (subs.size === 0) {
87
+ this.eventSubscriptions.delete(subject);
88
+ }
89
+ }
90
+ }
91
+ };
92
+ },
93
+ delete: async (subject) => {
94
+ const existed = this.eventStreams.has(subject);
95
+ if (existed) {
96
+ this.eventStreams.delete(subject);
97
+ this.eventSubscriptions.delete(subject);
98
+ }
99
+ return existed;
100
+ }
101
+ };
102
+ notifySubscribers(subject, event) {
103
+ const subs = this.eventSubscriptions.get(subject);
104
+ if (subs) {
105
+ Array.from(subs.values()).forEach((callback) => {
106
+ try {
107
+ callback(event);
108
+ } catch (error) {
109
+ console.error(`[MemoryStoreAdapter] Error in event subscription for ${subject}:`, error);
110
+ }
111
+ });
112
+ }
113
+ }
114
+ // ============================================================
115
+ // Key-Value Store
116
+ // ============================================================
117
+ kv = {
118
+ get: async (key) => {
119
+ return this.kvStore.get(key) || null;
120
+ },
121
+ set: async (key, value, _ttl) => {
122
+ this.kvStore.set(key, value);
123
+ },
124
+ delete: async (key) => {
125
+ this.kvStore.delete(key);
126
+ },
127
+ clear: async (pattern) => {
128
+ const regex = new RegExp(`^${pattern.replace(/\*/g, ".*")}$`);
129
+ const keys = Array.from(this.kvStore.keys());
130
+ let count = 0;
131
+ for (const key of keys) {
132
+ if (regex.test(key)) {
133
+ this.kvStore.delete(key);
134
+ count++;
135
+ }
136
+ }
137
+ return count;
138
+ },
139
+ increment: async (key, by = 1) => {
140
+ const current = this.kvStore.get(key) || 0;
141
+ const newValue = (typeof current === "number" ? current : 0) + by;
142
+ this.kvStore.set(key, newValue);
143
+ return newValue;
144
+ }
145
+ };
146
+ // ============================================================
147
+ // Sorted Index (for time-ordered listings)
148
+ // ============================================================
149
+ index = {
150
+ add: async (key, id, score, metadata) => {
151
+ if (!this.sortedIndices.has(key)) {
152
+ this.sortedIndices.set(key, []);
153
+ }
154
+ const index = this.sortedIndices.get(key);
155
+ const existingIndex = index.findIndex((entry2) => entry2.id === id);
156
+ const expandedMetadata = metadata ? this.expandDotNotation(metadata) : void 0;
157
+ const entry = {
158
+ id,
159
+ score,
160
+ metadata: expandedMetadata ? { version: 0, ...expandedMetadata } : void 0
161
+ };
162
+ if (existingIndex >= 0) {
163
+ index[existingIndex] = entry;
164
+ } else {
165
+ index.push(entry);
166
+ }
167
+ index.sort((a, b) => b.score - a.score);
168
+ },
169
+ get: async (key, id) => {
170
+ const index = this.sortedIndices.get(key);
171
+ if (!index) return null;
172
+ const entry = index.find((e) => e.id === id);
173
+ return entry ? { ...entry } : null;
174
+ },
175
+ read: async (key, opts) => {
176
+ const index = this.sortedIndices.get(key) || [];
177
+ const offset = opts?.offset || 0;
178
+ const limit = opts?.limit || 50;
179
+ return index.slice(offset, offset + limit).map((e) => ({ ...e }));
180
+ },
181
+ update: async (key, id, metadata) => {
182
+ this.validator.validateUpdatePayload(metadata, "index.update");
183
+ const lockKey = `${key}:${id}`;
184
+ const release = await this.acquireIndexLock(lockKey);
185
+ try {
186
+ const index = this.sortedIndices.get(key);
187
+ if (!index) return false;
188
+ const entry = index.find((e) => e.id === id);
189
+ if (!entry || !entry.metadata) return false;
190
+ const currentVersion = entry.metadata.version || 0;
191
+ const updates = this.expandDotNotation(metadata);
192
+ const deleteMarkers = updates.__deleteMarkers;
193
+ delete updates.__deleteMarkers;
194
+ entry.metadata = defu(updates, entry.metadata);
195
+ if (deleteMarkers) {
196
+ for (const { path } of deleteMarkers) {
197
+ let current = entry.metadata;
198
+ for (let i = 0; i < path.length - 1; i++) {
199
+ if (!current[path[i]]) break;
200
+ current = current[path[i]];
201
+ }
202
+ if (current) {
203
+ const lastKey = path[path.length - 1];
204
+ Reflect.deleteProperty(current, lastKey);
205
+ }
206
+ }
207
+ }
208
+ entry.metadata.version = currentVersion + 1;
209
+ return true;
210
+ } finally {
211
+ release();
212
+ }
213
+ },
214
+ updateWithRetry: async (key, id, metadata, maxRetries = 3) => {
215
+ this.validator.validateUpdatePayload(metadata, "index.updateWithRetry");
216
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
217
+ const success = await this.index.update(key, id, metadata);
218
+ if (success) return;
219
+ await new Promise((resolve) => setTimeout(resolve, 10 * Math.pow(2, attempt)));
220
+ }
221
+ throw new Error(`Failed to update index after ${maxRetries} retries`);
222
+ },
223
+ increment: async (key, id, field, increment = 1) => {
224
+ const lockKey = `${key}:${id}`;
225
+ const release = await this.acquireIndexLock(lockKey);
226
+ try {
227
+ const index = this.sortedIndices.get(key);
228
+ if (!index) throw new Error(`Index not found: ${key}`);
229
+ const entry = index.find((e) => e.id === id);
230
+ if (!entry) throw new Error(`Entry not found: ${id} in index ${key}`);
231
+ if (!entry.metadata) {
232
+ entry.metadata = { version: 0 };
233
+ }
234
+ let currentValue;
235
+ let newValue;
236
+ if (field.includes(".")) {
237
+ const keys = field.split(".");
238
+ let current = entry.metadata;
239
+ for (let i = 0; i < keys.length - 1; i++) {
240
+ const k = keys[i];
241
+ if (!current[k] || typeof current[k] !== "object") {
242
+ current[k] = {};
243
+ }
244
+ current = current[k];
245
+ }
246
+ const lastKey = keys[keys.length - 1];
247
+ currentValue = current[lastKey] || 0;
248
+ newValue = (typeof currentValue === "number" ? currentValue : 0) + increment;
249
+ current[lastKey] = newValue;
250
+ } else {
251
+ currentValue = entry.metadata[field] || 0;
252
+ newValue = (typeof currentValue === "number" ? currentValue : 0) + increment;
253
+ entry.metadata[field] = newValue;
254
+ }
255
+ entry.metadata.version = (entry.metadata.version || 0) + 1;
256
+ return newValue;
257
+ } finally {
258
+ release();
259
+ }
260
+ },
261
+ delete: async (key, id) => {
262
+ const index = this.sortedIndices.get(key);
263
+ if (!index) return false;
264
+ const initialLength = index.length;
265
+ const filtered = index.filter((e) => e.id !== id);
266
+ if (filtered.length === initialLength) {
267
+ return false;
268
+ }
269
+ this.sortedIndices.set(key, filtered);
270
+ return true;
271
+ }
272
+ };
273
+ /**
274
+ * Acquire a lock for atomic index operations
275
+ * Protected to allow access from FileStoreAdapter
276
+ */
277
+ async acquireIndexLock(key) {
278
+ while (this.indexLocks.has(key)) {
279
+ await this.indexLocks.get(key);
280
+ }
281
+ let releaseLock;
282
+ const lockPromise = new Promise((resolve) => {
283
+ releaseLock = resolve;
284
+ });
285
+ this.indexLocks.set(key, lockPromise);
286
+ return () => {
287
+ this.indexLocks.delete(key);
288
+ releaseLock();
289
+ };
290
+ }
291
+ /**
292
+ * Convert dot notation keys to nested objects
293
+ * e.g., { 'stats.totalFires': 5 } -> { stats: { totalFires: 5 } }
294
+ * null values are preserved for deletion
295
+ */
296
+ expandDotNotation(obj) {
297
+ const result = {};
298
+ const deleteMarkers = [];
299
+ for (const [key, value] of Object.entries(obj)) {
300
+ if (key === "version") {
301
+ continue;
302
+ }
303
+ if (key.includes(".")) {
304
+ const keys = key.split(".");
305
+ if (value === null || value === void 0) {
306
+ deleteMarkers.push({ path: keys, delete: true });
307
+ continue;
308
+ }
309
+ let current = result;
310
+ for (let i = 0; i < keys.length - 1; i++) {
311
+ const k = keys[i];
312
+ if (!current[k]) {
313
+ current[k] = {};
314
+ }
315
+ current = current[k];
316
+ }
317
+ current[keys[keys.length - 1]] = value;
318
+ } else {
319
+ result[key] = value;
320
+ }
321
+ }
322
+ if (deleteMarkers.length > 0) {
323
+ result.__deleteMarkers = deleteMarkers;
324
+ }
325
+ return result;
326
+ }
327
+ // ============================================================
328
+ // Helpers
329
+ // ============================================================
330
+ generateId() {
331
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
332
+ }
333
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Memory Stream Adapter
3
+ *
4
+ * In-memory pub/sub implementation for development
5
+ * - Uses EventEmitter pattern
6
+ * - No external dependencies
7
+ * - Single instance only
8
+ * - Data lost on restart
9
+ */
10
+ import type { StreamAdapter, StreamEvent, SubscribeOptions, SubscriptionHandle } from '../interfaces/stream.js';
11
+ export declare class MemoryStreamAdapter implements StreamAdapter {
12
+ private subscriptions;
13
+ private subscriptionCounter;
14
+ init(): Promise<void>;
15
+ publish(topic: string, event: StreamEvent): Promise<void>;
16
+ subscribe(topic: string, handler: (event: StreamEvent) => void | Promise<void>, _opts?: SubscribeOptions): Promise<SubscriptionHandle>;
17
+ unsubscribe(handle: SubscriptionHandle): Promise<void>;
18
+ listTopics(): Promise<string[]>;
19
+ getSubscriptionCount(topic: string): Promise<number>;
20
+ shutdown(): Promise<void>;
21
+ }
@@ -0,0 +1,56 @@
1
+ export class MemoryStreamAdapter {
2
+ subscriptions = /* @__PURE__ */ new Map();
3
+ subscriptionCounter = 0;
4
+ async init() {
5
+ }
6
+ async publish(topic, event) {
7
+ const topicSubscriptions = this.subscriptions.get(topic);
8
+ if (!topicSubscriptions || topicSubscriptions.size === 0) {
9
+ return;
10
+ }
11
+ const eventWithTs = {
12
+ ...event,
13
+ timestamp: event.timestamp || Date.now()
14
+ };
15
+ const promises = [];
16
+ Array.from(topicSubscriptions.values()).forEach((handler) => {
17
+ promises.push(handler(eventWithTs));
18
+ });
19
+ await Promise.all(promises);
20
+ }
21
+ async subscribe(topic, handler, _opts) {
22
+ const subscriptionId = `sub-${++this.subscriptionCounter}`;
23
+ if (!this.subscriptions.has(topic)) {
24
+ this.subscriptions.set(topic, /* @__PURE__ */ new Map());
25
+ }
26
+ const topicSubscriptions = this.subscriptions.get(topic);
27
+ topicSubscriptions.set(subscriptionId, handler);
28
+ return {
29
+ id: subscriptionId,
30
+ topic,
31
+ unsubscribe: async () => {
32
+ await this.unsubscribe({ id: subscriptionId, topic, unsubscribe: async () => {
33
+ } });
34
+ }
35
+ };
36
+ }
37
+ async unsubscribe(handle) {
38
+ const topicSubscriptions = this.subscriptions.get(handle.topic);
39
+ if (topicSubscriptions) {
40
+ topicSubscriptions.delete(handle.id);
41
+ if (topicSubscriptions.size === 0) {
42
+ this.subscriptions.delete(handle.topic);
43
+ }
44
+ }
45
+ }
46
+ async listTopics() {
47
+ return Array.from(this.subscriptions.keys());
48
+ }
49
+ async getSubscriptionCount(topic) {
50
+ const topicSubscriptions = this.subscriptions.get(topic);
51
+ return topicSubscriptions ? topicSubscriptions.size : 0;
52
+ }
53
+ async shutdown() {
54
+ this.subscriptions.clear();
55
+ }
56
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Adapter Factory
3
+ *
4
+ * Creates adapters independently without dependencies
5
+ * StoreAdapter is pure storage - streaming handled by wiring layer
6
+ *
7
+ * Now supports external adapters via the adapter registry.
8
+ * External adapters registered via the nvent:registerAdapter hook take precedence.
9
+ */
10
+ import type { QueueAdapter } from './interfaces/queue.js';
11
+ import type { StreamAdapter } from './interfaces/stream.js';
12
+ import type { StoreAdapter } from './interfaces/store.js';
13
+ import type { QueueConfig, StreamConfig, StoreConfig } from '../config/types.js';
14
+ export interface AdapterSet {
15
+ queue: QueueAdapter;
16
+ stream: StreamAdapter;
17
+ store: StoreAdapter;
18
+ }
19
+ /**
20
+ * Create a complete set of adapters
21
+ * All adapters are independent - wiring layer handles coordination
22
+ */
23
+ export declare function createAdapters(config: {
24
+ queue: QueueConfig;
25
+ stream: StreamConfig;
26
+ store: StoreConfig;
27
+ }): Promise<AdapterSet>;
28
+ /**
29
+ * Shutdown all adapters gracefully
30
+ */
31
+ export declare function shutdownAdapters(adapters: AdapterSet): Promise<void>;
@@ -0,0 +1,134 @@
1
+ import { useAdapterRegistry } from "./registry.js";
2
+ import { useStreamTopics, $useAnalyzedFlows } from "#imports";
3
+ import {
4
+ MemoryQueueAdapter,
5
+ MemoryStreamAdapter,
6
+ MemoryStoreAdapter,
7
+ FileQueueAdapter,
8
+ FileStoreAdapter
9
+ } from "./builtin/index.js";
10
+ export async function createAdapters(config) {
11
+ const stream = await createStreamAdapter(config.stream);
12
+ const store = await createStoreAdapter(config.store);
13
+ const queue = await createQueueAdapter(config.queue);
14
+ return { queue, stream, store };
15
+ }
16
+ async function createStreamAdapter(config) {
17
+ const type = config.adapter || "memory";
18
+ const registry = useAdapterRegistry();
19
+ if (registry.hasStream(type)) {
20
+ const adapter = registry.getStream(type);
21
+ await adapter.init();
22
+ return adapter;
23
+ }
24
+ switch (type) {
25
+ case "memory": {
26
+ const adapter = new MemoryStreamAdapter();
27
+ await adapter.init();
28
+ return adapter;
29
+ }
30
+ case "redis":
31
+ throw new Error("Redis stream adapter not registered. Install @nvent/adapter-stream-redis and add it to your nuxt.config modules.");
32
+ case "rabbitmq":
33
+ throw new Error("RabbitMQ stream adapter not yet implemented");
34
+ case "kafka":
35
+ throw new Error("Kafka stream adapter not yet implemented");
36
+ default:
37
+ throw new Error(`Unknown stream adapter type: ${type}`);
38
+ }
39
+ }
40
+ async function createStoreAdapter(config) {
41
+ const type = config.adapter || "file";
42
+ const registry = useAdapterRegistry();
43
+ let adapter;
44
+ if (registry.hasStore(type)) {
45
+ adapter = registry.getStore(type);
46
+ } else {
47
+ switch (type) {
48
+ case "memory": {
49
+ adapter = new MemoryStoreAdapter();
50
+ break;
51
+ }
52
+ case "file": {
53
+ const dataDir = config.file?.dataDir || ".data/store";
54
+ const fileAdapter = new FileStoreAdapter({
55
+ dataDir
56
+ });
57
+ await fileAdapter.init();
58
+ adapter = fileAdapter;
59
+ break;
60
+ }
61
+ case "redis":
62
+ throw new Error("Redis store adapter not registered. Install @nvent/adapter-store-redis and add it to your nuxt.config modules.");
63
+ case "postgres":
64
+ throw new Error("Postgres store adapter not yet implemented");
65
+ default:
66
+ throw new Error(`Unknown store adapter type: ${type}`);
67
+ }
68
+ }
69
+ try {
70
+ const { StoreSubjects } = useStreamTopics();
71
+ const flowIndexKey = StoreSubjects.flowIndex();
72
+ const existingFlows = await adapter.index.read(flowIndexKey, { limit: 1 });
73
+ if (existingFlows.length === 0) {
74
+ const analyzedFlows = $useAnalyzedFlows();
75
+ if (analyzedFlows && analyzedFlows.length > 0) {
76
+ const now = (/* @__PURE__ */ new Date()).toISOString();
77
+ for (const flow of analyzedFlows) {
78
+ await adapter.index.add(flowIndexKey, flow.id, Date.now(), {
79
+ name: flow.id,
80
+ displayName: flow.id,
81
+ registeredAt: now,
82
+ stats: {
83
+ total: 0,
84
+ success: 0,
85
+ failure: 0,
86
+ cancel: 0,
87
+ running: 0,
88
+ awaiting: 0
89
+ },
90
+ version: 1
91
+ });
92
+ }
93
+ }
94
+ }
95
+ } catch (err) {
96
+ console.warn("[factory] Failed to initialize flow index:", err?.message);
97
+ }
98
+ return adapter;
99
+ }
100
+ async function createQueueAdapter(config) {
101
+ const type = config.adapter || "file";
102
+ const registry = useAdapterRegistry();
103
+ if (registry.hasQueue(type)) {
104
+ const adapter = registry.getQueue(type);
105
+ await adapter.init();
106
+ return adapter;
107
+ }
108
+ switch (type) {
109
+ case "memory": {
110
+ const adapter = new MemoryQueueAdapter();
111
+ await adapter.init();
112
+ return adapter;
113
+ }
114
+ case "file": {
115
+ const dataDir = config.file?.dataDir || ".data/queue";
116
+ const adapter = new FileQueueAdapter({ dataDir });
117
+ await adapter.init();
118
+ return adapter;
119
+ }
120
+ case "redis":
121
+ throw new Error("Redis queue adapter not registered. Install @nvent/adapter-queue-redis and add it to your nuxt.config modules.");
122
+ case "postgres":
123
+ throw new Error("Postgres queue adapter not registered. Install @nvent/adapter-queue-postgres and add it to your nuxt.config modules.");
124
+ default:
125
+ throw new Error(`Unknown queue adapter type: ${type}`);
126
+ }
127
+ }
128
+ export async function shutdownAdapters(adapters) {
129
+ await Promise.all([
130
+ adapters.queue.close(),
131
+ adapters.stream.shutdown(),
132
+ adapters.store.close()
133
+ ]);
134
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Adapter System Exports
3
+ *
4
+ * Re-exports all adapter interfaces, factory, and utilities
5
+ */
6
+ export * from './interfaces/index.js';
7
+ export * from './factory.js';
8
+ export * from './builtin/index.js';
@@ -0,0 +1,3 @@
1
+ export * from "./interfaces/index.js";
2
+ export * from "./factory.js";
3
+ export * from "./builtin/index.js";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Adapter Interfaces
3
+ *
4
+ * Three types of adapters for nvent:
5
+ * - QueueAdapter: Job execution infrastructure
6
+ * - StreamAdapter: Cross-instance pub/sub messaging
7
+ * - StoreAdapter: Three-tier storage (events, documents, key-value)
8
+ */
9
+ export * from './queue.js';
10
+ export * from './stream.js';
11
+ export * from './store.js';
@@ -0,0 +1,3 @@
1
+ export * from "./queue.js";
2
+ export * from "./stream.js";
3
+ export * from "./store.js";