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.
- package/dist/module.d.mts +4 -185
- package/dist/module.json +3 -3
- package/dist/module.mjs +451 -257
- package/dist/runtime/adapters/base/index.d.ts +6 -0
- package/dist/runtime/adapters/base/index.js +1 -0
- package/dist/runtime/adapters/base/store-validator.d.ts +48 -0
- package/dist/runtime/adapters/base/store-validator.js +147 -0
- package/dist/runtime/adapters/builtin/file-queue.d.ts +67 -0
- package/dist/runtime/adapters/builtin/file-queue.js +499 -0
- package/dist/runtime/adapters/builtin/file-store.d.ts +32 -0
- package/dist/runtime/adapters/builtin/file-store.js +206 -0
- package/dist/runtime/adapters/builtin/file-stream.d.ts +39 -0
- package/dist/runtime/adapters/builtin/file-stream.js +56 -0
- package/dist/runtime/adapters/builtin/index.d.ts +10 -0
- package/dist/runtime/adapters/builtin/index.js +5 -0
- package/dist/runtime/adapters/builtin/memory-queue.d.ts +52 -0
- package/dist/runtime/adapters/builtin/memory-queue.js +243 -0
- package/dist/runtime/adapters/builtin/memory-store.d.ts +68 -0
- package/dist/runtime/adapters/builtin/memory-store.js +333 -0
- package/dist/runtime/adapters/builtin/memory-stream.d.ts +21 -0
- package/dist/runtime/adapters/builtin/memory-stream.js +56 -0
- package/dist/runtime/adapters/factory.d.ts +31 -0
- package/dist/runtime/adapters/factory.js +134 -0
- package/dist/runtime/adapters/index.d.ts +8 -0
- package/dist/runtime/adapters/index.js +3 -0
- package/dist/runtime/adapters/interfaces/index.d.ts +11 -0
- package/dist/runtime/adapters/interfaces/index.js +3 -0
- package/dist/runtime/adapters/interfaces/queue.d.ts +150 -0
- package/dist/runtime/adapters/interfaces/store.d.ts +297 -0
- package/dist/runtime/adapters/interfaces/stream.d.ts +62 -0
- package/dist/runtime/adapters/registry.d.ts +85 -0
- package/dist/runtime/adapters/registry.js +161 -0
- package/dist/runtime/config/index.d.ts +29 -0
- package/dist/runtime/config/index.js +175 -0
- package/dist/runtime/config/types.d.ts +397 -0
- package/dist/runtime/config/types.js +0 -0
- package/dist/runtime/{server-utils/events → events}/eventBus.d.ts +1 -1
- package/dist/runtime/events/types.d.ts +145 -0
- package/dist/runtime/events/types.js +0 -0
- package/dist/runtime/events/utils/scheduleTrigger.d.ts +8 -0
- package/dist/runtime/events/utils/scheduleTrigger.js +69 -0
- package/dist/runtime/events/utils/stallDetector.d.ts +140 -0
- package/dist/runtime/events/utils/stallDetector.js +436 -0
- package/dist/runtime/events/utils/triggerRuntime.d.ts +58 -0
- package/dist/runtime/events/utils/triggerRuntime.js +212 -0
- package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.d.ts +12 -11
- package/dist/runtime/events/wiring/flowWiring.js +1020 -0
- package/dist/runtime/events/wiring/registry.d.ts +19 -0
- package/dist/runtime/events/wiring/registry.js +35 -0
- package/dist/runtime/events/wiring/stateWiring.d.ts +37 -0
- package/dist/runtime/events/wiring/stateWiring.js +92 -0
- package/dist/runtime/events/wiring/streamWiring.d.ts +36 -0
- package/dist/runtime/events/wiring/streamWiring.js +156 -0
- package/dist/runtime/events/wiring/triggerWiring.d.ts +21 -0
- package/dist/runtime/events/wiring/triggerWiring.js +412 -0
- package/dist/runtime/nitro/plugins/00.adapters.d.ts +14 -0
- package/dist/runtime/nitro/plugins/00.adapters.js +73 -0
- package/dist/runtime/nitro/plugins/02.workers.js +63 -0
- package/dist/runtime/nitro/plugins/03.triggers.d.ts +12 -0
- package/dist/runtime/nitro/plugins/03.triggers.js +55 -0
- package/dist/runtime/nitro/routes/webhook.await.d.ts +23 -0
- package/dist/runtime/nitro/routes/webhook.await.js +90 -0
- package/dist/runtime/nitro/routes/webhook.trigger.d.ts +69 -0
- package/dist/runtime/nitro/routes/webhook.trigger.js +64 -0
- package/dist/runtime/nitro/utils/adapters.d.ts +66 -0
- package/dist/runtime/nitro/utils/adapters.js +51 -0
- package/dist/runtime/nitro/utils/awaitPatterns/event.d.ts +15 -0
- package/dist/runtime/nitro/utils/awaitPatterns/event.js +120 -0
- package/dist/runtime/nitro/utils/awaitPatterns/index.d.ts +28 -0
- package/dist/runtime/nitro/utils/awaitPatterns/index.js +55 -0
- package/dist/runtime/nitro/utils/awaitPatterns/schedule.d.ts +16 -0
- package/dist/runtime/nitro/utils/awaitPatterns/schedule.js +78 -0
- package/dist/runtime/nitro/utils/awaitPatterns/time.d.ts +15 -0
- package/dist/runtime/nitro/utils/awaitPatterns/time.js +67 -0
- package/dist/runtime/nitro/utils/awaitPatterns/webhook.d.ts +15 -0
- package/dist/runtime/nitro/utils/awaitPatterns/webhook.js +120 -0
- package/dist/runtime/nitro/utils/defineFunction.d.ts +10 -0
- package/dist/runtime/nitro/utils/defineFunction.js +17 -0
- package/dist/runtime/nitro/utils/defineFunctionConfig.d.ts +310 -0
- package/dist/runtime/nitro/utils/defineFunctionConfig.js +3 -0
- package/dist/runtime/nitro/utils/defineHooks.d.ts +41 -0
- package/dist/runtime/nitro/utils/defineHooks.js +6 -0
- package/dist/runtime/nitro/utils/registerAdapter.d.ts +59 -0
- package/dist/runtime/nitro/utils/registerAdapter.js +13 -0
- package/dist/runtime/nitro/utils/useAwait.d.ts +71 -0
- package/dist/runtime/nitro/utils/useAwait.js +139 -0
- package/dist/runtime/{server-utils → nitro}/utils/useEventManager.d.ts +2 -2
- package/dist/runtime/{server-utils → nitro}/utils/useEventManager.js +1 -1
- package/dist/runtime/nitro/utils/useFlow.d.ts +68 -0
- package/dist/runtime/nitro/utils/useFlow.js +226 -0
- package/dist/runtime/nitro/utils/useHookRegistry.d.ts +34 -0
- package/dist/runtime/nitro/utils/useHookRegistry.js +25 -0
- package/dist/runtime/{server-utils → nitro}/utils/useNventLogger.js +2 -2
- package/dist/runtime/nitro/utils/useRunContext.d.ts +6 -0
- package/dist/runtime/nitro/utils/useRunContext.js +102 -0
- package/dist/runtime/nitro/utils/useStreamTopics.d.ts +83 -0
- package/dist/runtime/nitro/utils/useStreamTopics.js +94 -0
- package/dist/runtime/nitro/utils/useTrigger.d.ts +150 -0
- package/dist/runtime/nitro/utils/useTrigger.js +320 -0
- package/dist/runtime/scheduler/index.d.ts +33 -0
- package/dist/runtime/scheduler/index.js +38 -0
- package/dist/runtime/scheduler/scheduler.d.ts +113 -0
- package/dist/runtime/scheduler/scheduler.js +623 -0
- package/dist/runtime/scheduler/types.d.ts +116 -0
- package/dist/runtime/scheduler/types.js +0 -0
- package/dist/runtime/tsconfig.json +8 -0
- package/dist/runtime/worker/node/runner.d.ts +53 -0
- package/dist/runtime/worker/node/runner.js +327 -0
- package/dist/types.d.mts +2 -2
- package/package.json +16 -46
- package/LICENSE +0 -21
- package/README.md +0 -389
- package/dist/runtime/app/assets/vueflow.css +0 -1
- package/dist/runtime/app/components/ConfirmDialog.d.vue.ts +0 -33
- package/dist/runtime/app/components/ConfirmDialog.vue +0 -121
- package/dist/runtime/app/components/ConfirmDialog.vue.d.ts +0 -33
- package/dist/runtime/app/components/FlowDiagram.d.vue.ts +0 -64
- package/dist/runtime/app/components/FlowDiagram.vue +0 -338
- package/dist/runtime/app/components/FlowDiagram.vue.d.ts +0 -64
- package/dist/runtime/app/components/FlowNodeCard.d.vue.ts +0 -29
- package/dist/runtime/app/components/FlowNodeCard.vue +0 -156
- package/dist/runtime/app/components/FlowNodeCard.vue.d.ts +0 -29
- package/dist/runtime/app/components/FlowRunOverview.d.vue.ts +0 -9
- package/dist/runtime/app/components/FlowRunOverview.vue +0 -291
- package/dist/runtime/app/components/FlowRunOverview.vue.d.ts +0 -9
- package/dist/runtime/app/components/FlowRunStatusBadge.d.vue.ts +0 -14
- package/dist/runtime/app/components/FlowRunStatusBadge.vue +0 -60
- package/dist/runtime/app/components/FlowRunStatusBadge.vue.d.ts +0 -14
- package/dist/runtime/app/components/FlowRunTimeline.d.vue.ts +0 -12
- package/dist/runtime/app/components/FlowRunTimeline.vue +0 -127
- package/dist/runtime/app/components/FlowRunTimeline.vue.d.ts +0 -12
- package/dist/runtime/app/components/FlowScheduleDialog.d.vue.ts +0 -16
- package/dist/runtime/app/components/FlowScheduleDialog.vue +0 -226
- package/dist/runtime/app/components/FlowScheduleDialog.vue.d.ts +0 -16
- package/dist/runtime/app/components/FlowSchedulesList.d.vue.ts +0 -12
- package/dist/runtime/app/components/FlowSchedulesList.vue +0 -99
- package/dist/runtime/app/components/FlowSchedulesList.vue.d.ts +0 -12
- package/dist/runtime/app/components/JobScheduling.d.vue.ts +0 -6
- package/dist/runtime/app/components/JobScheduling.vue +0 -203
- package/dist/runtime/app/components/JobScheduling.vue.d.ts +0 -6
- package/dist/runtime/app/components/ListItem.d.vue.ts +0 -23
- package/dist/runtime/app/components/ListItem.vue +0 -70
- package/dist/runtime/app/components/ListItem.vue.d.ts +0 -23
- package/dist/runtime/app/components/QueueConfigDetails.d.vue.ts +0 -45
- package/dist/runtime/app/components/QueueConfigDetails.vue +0 -412
- package/dist/runtime/app/components/QueueConfigDetails.vue.d.ts +0 -45
- package/dist/runtime/app/components/StatCounter.d.vue.ts +0 -9
- package/dist/runtime/app/components/StatCounter.vue +0 -25
- package/dist/runtime/app/components/StatCounter.vue.d.ts +0 -9
- package/dist/runtime/app/components/TimelineList.d.vue.ts +0 -7
- package/dist/runtime/app/components/TimelineList.vue +0 -210
- package/dist/runtime/app/components/TimelineList.vue.d.ts +0 -7
- package/dist/runtime/app/components/nhealth/component-router.d.vue.ts +0 -46
- package/dist/runtime/app/components/nhealth/component-router.vue +0 -26
- package/dist/runtime/app/components/nhealth/component-router.vue.d.ts +0 -46
- package/dist/runtime/app/components/nhealth/component-shell.d.vue.ts +0 -24
- package/dist/runtime/app/components/nhealth/component-shell.vue +0 -89
- package/dist/runtime/app/components/nhealth/component-shell.vue.d.ts +0 -24
- package/dist/runtime/app/composables/useAnalyzedFlows.d.ts +0 -14
- package/dist/runtime/app/composables/useAnalyzedFlows.js +0 -8
- package/dist/runtime/app/composables/useComponentRouter.d.ts +0 -38
- package/dist/runtime/app/composables/useComponentRouter.js +0 -240
- package/dist/runtime/app/composables/useFlowRunTimeline.d.ts +0 -80
- package/dist/runtime/app/composables/useFlowRunTimeline.js +0 -68
- package/dist/runtime/app/composables/useFlowRuns.d.ts +0 -18
- package/dist/runtime/app/composables/useFlowRuns.js +0 -32
- package/dist/runtime/app/composables/useFlowRunsInfinite.d.ts +0 -24
- package/dist/runtime/app/composables/useFlowRunsInfinite.js +0 -123
- package/dist/runtime/app/composables/useFlowRunsPolling.d.ts +0 -9
- package/dist/runtime/app/composables/useFlowRunsPolling.js +0 -33
- package/dist/runtime/app/composables/useFlowState.d.ts +0 -125
- package/dist/runtime/app/composables/useFlowState.js +0 -211
- package/dist/runtime/app/composables/useFlowWebSocket.d.ts +0 -27
- package/dist/runtime/app/composables/useFlowWebSocket.js +0 -205
- package/dist/runtime/app/composables/useFlowsNavigation.d.ts +0 -10
- package/dist/runtime/app/composables/useFlowsNavigation.js +0 -58
- package/dist/runtime/app/composables/useQueueJobs.d.ts +0 -26
- package/dist/runtime/app/composables/useQueueJobs.js +0 -20
- package/dist/runtime/app/composables/useQueueUpdates.d.ts +0 -26
- package/dist/runtime/app/composables/useQueueUpdates.js +0 -122
- package/dist/runtime/app/composables/useQueues.d.ts +0 -45
- package/dist/runtime/app/composables/useQueues.js +0 -26
- package/dist/runtime/app/composables/useQueuesLive.d.ts +0 -19
- package/dist/runtime/app/composables/useQueuesLive.js +0 -143
- package/dist/runtime/app/pages/flows/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/flows/index.vue +0 -645
- package/dist/runtime/app/pages/flows/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/index.vue +0 -34
- package/dist/runtime/app/pages/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/index.vue +0 -229
- package/dist/runtime/app/pages/queues/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/job.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/job.vue +0 -262
- package/dist/runtime/app/pages/queues/job.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/jobs.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/jobs.vue +0 -291
- package/dist/runtime/app/pages/queues/jobs.vue.d.ts +0 -3
- package/dist/runtime/app/plugins/vueflow.client.d.ts +0 -2
- package/dist/runtime/app/plugins/vueflow.client.js +0 -11
- package/dist/runtime/constants.d.ts +0 -11
- package/dist/runtime/constants.js +0 -11
- package/dist/runtime/schema.d.ts +0 -37
- package/dist/runtime/schema.js +0 -20
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.d.ts +0 -10
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +0 -44
- package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +0 -7
- package/dist/runtime/server/api/_flows/[name]/runs.get.js +0 -53
- package/dist/runtime/server/api/_flows/[name]/schedule.post.js +0 -57
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +0 -42
- package/dist/runtime/server/api/_flows/[name]/schedules.get.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/schedules.get.js +0 -48
- package/dist/runtime/server/api/_flows/[name]/start.post.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/start.post.js +0 -9
- package/dist/runtime/server/api/_flows/index.get.d.ts +0 -6
- package/dist/runtime/server/api/_flows/index.get.js +0 -5
- package/dist/runtime/server/api/_flows/ws.d.ts +0 -60
- package/dist/runtime/server/api/_flows/ws.js +0 -188
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.d.ts +0 -2
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +0 -9
- package/dist/runtime/server/api/_queues/[name]/job/index.get.d.ts +0 -2
- package/dist/runtime/server/api/_queues/[name]/job/index.get.js +0 -18
- package/dist/runtime/server/api/_queues/index.get.d.ts +0 -2
- package/dist/runtime/server/api/_queues/index.get.js +0 -63
- package/dist/runtime/server/api/_queues/ws.d.ts +0 -48
- package/dist/runtime/server/api/_queues/ws.js +0 -205
- package/dist/runtime/server/plugins/00.event-store.d.ts +0 -13
- package/dist/runtime/server/plugins/00.event-store.js +0 -16
- package/dist/runtime/server/plugins/flow-management.d.ts +0 -13
- package/dist/runtime/server/plugins/flow-management.js +0 -65
- package/dist/runtime/server/plugins/queue-management.d.ts +0 -2
- package/dist/runtime/server/plugins/queue-management.js +0 -27
- package/dist/runtime/server/plugins/state-cleanup.d.ts +0 -11
- package/dist/runtime/server/plugins/state-cleanup.js +0 -93
- package/dist/runtime/server/plugins/worker-management.d.ts +0 -2
- package/dist/runtime/server/plugins/worker-management.js +0 -33
- package/dist/runtime/server/tsconfig.json +0 -3
- package/dist/runtime/server-utils/events/adapters/fileAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/fileAdapter.js +0 -382
- package/dist/runtime/server-utils/events/adapters/memoryAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/memoryAdapter.js +0 -171
- package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.js +0 -348
- package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.d.ts +0 -30
- package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.js +0 -82
- package/dist/runtime/server-utils/events/eventStoreFactory.d.ts +0 -19
- package/dist/runtime/server-utils/events/eventStoreFactory.js +0 -44
- package/dist/runtime/server-utils/events/streamNames.d.ts +0 -17
- package/dist/runtime/server-utils/events/streamNames.js +0 -17
- package/dist/runtime/server-utils/events/types.d.ts +0 -63
- package/dist/runtime/server-utils/events/wiring/flowWiring.js +0 -409
- package/dist/runtime/server-utils/events/wiring/registry.d.ts +0 -10
- package/dist/runtime/server-utils/events/wiring/registry.js +0 -24
- package/dist/runtime/server-utils/queue/adapters/bullmq.d.ts +0 -18
- package/dist/runtime/server-utils/queue/adapters/bullmq.js +0 -164
- package/dist/runtime/server-utils/queue/queueFactory.d.ts +0 -3
- package/dist/runtime/server-utils/queue/queueFactory.js +0 -10
- package/dist/runtime/server-utils/queue/types.d.ts +0 -47
- package/dist/runtime/server-utils/state/adapters/redis.d.ts +0 -2
- package/dist/runtime/server-utils/state/adapters/redis.js +0 -42
- package/dist/runtime/server-utils/state/stateFactory.d.ts +0 -3
- package/dist/runtime/server-utils/state/stateFactory.js +0 -17
- package/dist/runtime/server-utils/state/types.d.ts +0 -23
- package/dist/runtime/server-utils/utils/defineQueueConfig.d.ts +0 -154
- package/dist/runtime/server-utils/utils/defineQueueConfig.js +0 -2
- package/dist/runtime/server-utils/utils/defineQueueWorker.d.ts +0 -10
- package/dist/runtime/server-utils/utils/defineQueueWorker.js +0 -17
- package/dist/runtime/server-utils/utils/useEventStore.d.ts +0 -20
- package/dist/runtime/server-utils/utils/useEventStore.js +0 -119
- package/dist/runtime/server-utils/utils/useFlowEngine.d.ts +0 -9
- package/dist/runtime/server-utils/utils/useFlowEngine.js +0 -44
- package/dist/runtime/server-utils/utils/useLogs.d.ts +0 -41
- package/dist/runtime/server-utils/utils/useLogs.js +0 -74
- package/dist/runtime/server-utils/utils/useQueue.d.ts +0 -31
- package/dist/runtime/server-utils/utils/useQueue.js +0 -24
- package/dist/runtime/server-utils/worker/adapter.d.ts +0 -4
- package/dist/runtime/server-utils/worker/adapter.js +0 -66
- package/dist/runtime/server-utils/worker/runner/node.d.ts +0 -27
- package/dist/runtime/server-utils/worker/runner/node.js +0 -196
- package/dist/runtime/types.d.ts +0 -132
- /package/dist/runtime/{server-utils/events/types.js → adapters/interfaces/queue.js} +0 -0
- /package/dist/runtime/{server-utils/queue/types.js → adapters/interfaces/store.js} +0 -0
- /package/dist/runtime/{server-utils/state/types.js → adapters/interfaces/stream.js} +0 -0
- /package/dist/runtime/{server-utils/events → events}/eventBus.js +0 -0
- /package/dist/runtime/{server/plugins/00.ws-lifecycle.d.ts → nitro/plugins/01.ws-lifecycle.d.ts} +0 -0
- /package/dist/runtime/{server/plugins/00.ws-lifecycle.js → nitro/plugins/01.ws-lifecycle.js} +0 -0
- /package/dist/runtime/{server/api/_flows/[name]/schedule.post.d.ts → nitro/plugins/02.workers.d.ts} +0 -0
- /package/dist/runtime/{server-utils → nitro}/utils/useNventLogger.d.ts +0 -0
- /package/dist/runtime/{server-utils → nitro}/utils/wsPeerManager.d.ts +0 -0
- /package/dist/runtime/{server-utils → nitro}/utils/wsPeerManager.js +0 -0
- /package/dist/runtime/{python → worker/python}/get_config.py +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
export class AdapterRegistry {
|
|
2
|
+
queueAdapters = /* @__PURE__ */ new Map();
|
|
3
|
+
streamAdapters = /* @__PURE__ */ new Map();
|
|
4
|
+
storeAdapters = /* @__PURE__ */ new Map();
|
|
5
|
+
// ============================================================
|
|
6
|
+
// Registration
|
|
7
|
+
// ============================================================
|
|
8
|
+
/**
|
|
9
|
+
* Register a queue adapter
|
|
10
|
+
* @param name - Adapter name (e.g., 'redis', 'memory', 'postgres')
|
|
11
|
+
* @param adapter - QueueAdapter implementation
|
|
12
|
+
*/
|
|
13
|
+
registerQueue(name, adapter) {
|
|
14
|
+
if (this.queueAdapters.has(name)) {
|
|
15
|
+
console.warn(`[nvent] Queue adapter "${name}" is already registered, overwriting`);
|
|
16
|
+
}
|
|
17
|
+
this.queueAdapters.set(name, adapter);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Register a stream adapter
|
|
21
|
+
* @param name - Adapter name (e.g., 'redis', 'memory', 'rabbitmq')
|
|
22
|
+
* @param adapter - StreamAdapter implementation
|
|
23
|
+
*/
|
|
24
|
+
registerStream(name, adapter) {
|
|
25
|
+
if (this.streamAdapters.has(name)) {
|
|
26
|
+
console.warn(`[nvent] Stream adapter "${name}" is already registered, overwriting`);
|
|
27
|
+
}
|
|
28
|
+
this.streamAdapters.set(name, adapter);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Register a store adapter
|
|
32
|
+
* @param name - Adapter name (e.g., 'redis', 'memory', 'postgres')
|
|
33
|
+
* @param adapter - StoreAdapter implementation
|
|
34
|
+
*/
|
|
35
|
+
registerStore(name, adapter) {
|
|
36
|
+
if (this.storeAdapters.has(name)) {
|
|
37
|
+
console.warn(`[nvent] Store adapter "${name}" is already registered, overwriting`);
|
|
38
|
+
}
|
|
39
|
+
this.storeAdapters.set(name, adapter);
|
|
40
|
+
}
|
|
41
|
+
// ============================================================
|
|
42
|
+
// Retrieval
|
|
43
|
+
// ============================================================
|
|
44
|
+
/**
|
|
45
|
+
* Get a queue adapter by name
|
|
46
|
+
* @throws Error if adapter not found
|
|
47
|
+
*/
|
|
48
|
+
getQueue(name) {
|
|
49
|
+
const adapter = this.queueAdapters.get(name);
|
|
50
|
+
if (!adapter) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`[nvent] Queue adapter "${name}" not found. Available: ${Array.from(this.queueAdapters.keys()).join(", ")}`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return adapter;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get a stream adapter by name
|
|
59
|
+
* @throws Error if adapter not found
|
|
60
|
+
*/
|
|
61
|
+
getStream(name) {
|
|
62
|
+
const adapter = this.streamAdapters.get(name);
|
|
63
|
+
if (!adapter) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`[nvent] Stream adapter "${name}" not found. Available: ${Array.from(this.streamAdapters.keys()).join(", ")}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return adapter;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get a store adapter by name
|
|
72
|
+
* @throws Error if adapter not found
|
|
73
|
+
*/
|
|
74
|
+
getStore(name) {
|
|
75
|
+
const adapter = this.storeAdapters.get(name);
|
|
76
|
+
if (!adapter) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`[nvent] Store adapter "${name}" not found. Available: ${Array.from(this.storeAdapters.keys()).join(", ")}`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return adapter;
|
|
82
|
+
}
|
|
83
|
+
// ============================================================
|
|
84
|
+
// Utilities
|
|
85
|
+
// ============================================================
|
|
86
|
+
/**
|
|
87
|
+
* Check if a queue adapter is registered
|
|
88
|
+
*/
|
|
89
|
+
hasQueue(name) {
|
|
90
|
+
return this.queueAdapters.has(name);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Check if a stream adapter is registered
|
|
94
|
+
*/
|
|
95
|
+
hasStream(name) {
|
|
96
|
+
return this.streamAdapters.has(name);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if a store adapter is registered
|
|
100
|
+
*/
|
|
101
|
+
hasStore(name) {
|
|
102
|
+
return this.storeAdapters.has(name);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* List all registered queue adapters
|
|
106
|
+
*/
|
|
107
|
+
listQueueAdapters() {
|
|
108
|
+
return Array.from(this.queueAdapters.keys());
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* List all registered stream adapters
|
|
112
|
+
*/
|
|
113
|
+
listStreamAdapters() {
|
|
114
|
+
return Array.from(this.streamAdapters.keys());
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* List all registered store adapters
|
|
118
|
+
*/
|
|
119
|
+
listStoreAdapters() {
|
|
120
|
+
return Array.from(this.storeAdapters.keys());
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Initialize all registered adapters
|
|
124
|
+
*/
|
|
125
|
+
async initAll() {
|
|
126
|
+
const promises = [];
|
|
127
|
+
Array.from(this.queueAdapters.values()).forEach((adapter) => {
|
|
128
|
+
promises.push(adapter.init());
|
|
129
|
+
});
|
|
130
|
+
Array.from(this.streamAdapters.values()).forEach((adapter) => {
|
|
131
|
+
promises.push(adapter.init());
|
|
132
|
+
});
|
|
133
|
+
await Promise.all(promises);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Close/cleanup all registered adapters
|
|
137
|
+
*/
|
|
138
|
+
async closeAll() {
|
|
139
|
+
const promises = [];
|
|
140
|
+
Array.from(this.queueAdapters.values()).forEach((adapter) => {
|
|
141
|
+
promises.push(adapter.close());
|
|
142
|
+
});
|
|
143
|
+
Array.from(this.streamAdapters.values()).forEach((adapter) => {
|
|
144
|
+
promises.push(adapter.shutdown());
|
|
145
|
+
});
|
|
146
|
+
Array.from(this.storeAdapters.values()).forEach((adapter) => {
|
|
147
|
+
promises.push(adapter.close());
|
|
148
|
+
});
|
|
149
|
+
await Promise.all(promises);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
let registry = null;
|
|
153
|
+
export function useAdapterRegistry() {
|
|
154
|
+
if (!registry) {
|
|
155
|
+
registry = new AdapterRegistry();
|
|
156
|
+
}
|
|
157
|
+
return registry;
|
|
158
|
+
}
|
|
159
|
+
export function resetAdapterRegistry() {
|
|
160
|
+
registry = null;
|
|
161
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ModuleOptions, ModuleConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Merge and normalize module options with defaults.
|
|
4
|
+
* Applies connection fallback: adapter-specific connections override connections.redis/postgres.
|
|
5
|
+
* Only includes connection defaults for adapters that are actually used.
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeModuleOptions(options: ModuleOptions): Required<ModuleOptions>;
|
|
8
|
+
/**
|
|
9
|
+
* Convert normalized module options to runtime config format.
|
|
10
|
+
*/
|
|
11
|
+
export declare function toRuntimeConfig(normalizedOptions: Required<ModuleOptions>): ModuleConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Get Redis connection config for nitro storage.
|
|
14
|
+
* Uses shared connections.redis as primary source.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getRedisStorageConfig(normalizedOptions: Required<ModuleOptions>): {
|
|
17
|
+
host: string;
|
|
18
|
+
port: number;
|
|
19
|
+
username?: undefined;
|
|
20
|
+
password?: undefined;
|
|
21
|
+
db?: undefined;
|
|
22
|
+
} | {
|
|
23
|
+
host: string | undefined;
|
|
24
|
+
port: number | undefined;
|
|
25
|
+
username: string | undefined;
|
|
26
|
+
password: string | undefined;
|
|
27
|
+
db: number | undefined;
|
|
28
|
+
};
|
|
29
|
+
export type { ModuleOptions, ModuleConfig } from './types.js';
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import defu from "defu";
|
|
2
|
+
export function normalizeModuleOptions(options) {
|
|
3
|
+
const defaults = {
|
|
4
|
+
dir: "functions",
|
|
5
|
+
ui: true,
|
|
6
|
+
debug: {},
|
|
7
|
+
connections: {},
|
|
8
|
+
queue: {
|
|
9
|
+
adapter: "file",
|
|
10
|
+
prefix: "nvent",
|
|
11
|
+
schema: "nvent_queue",
|
|
12
|
+
defaultJobOptions: {},
|
|
13
|
+
worker: {
|
|
14
|
+
concurrency: 2,
|
|
15
|
+
autorun: true,
|
|
16
|
+
pollingIntervalMs: 1e3
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
stream: {
|
|
20
|
+
adapter: "memory",
|
|
21
|
+
prefix: "nvent"
|
|
22
|
+
},
|
|
23
|
+
store: {
|
|
24
|
+
adapter: "file",
|
|
25
|
+
prefix: "nvent",
|
|
26
|
+
schema: "nvent_store",
|
|
27
|
+
state: {
|
|
28
|
+
autoScope: "always",
|
|
29
|
+
cleanup: {
|
|
30
|
+
strategy: "never",
|
|
31
|
+
ttlMs: 36e5
|
|
32
|
+
// 1 hour
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
eventTTL: 604800,
|
|
36
|
+
// 7 days
|
|
37
|
+
metadataTTL: 2592e3
|
|
38
|
+
// 30 days
|
|
39
|
+
},
|
|
40
|
+
flow: {
|
|
41
|
+
stallDetection: {
|
|
42
|
+
enabled: true,
|
|
43
|
+
stallTimeout: 30 * 60 * 1e3,
|
|
44
|
+
// 30 minutes
|
|
45
|
+
checkInterval: 15 * 60 * 1e3,
|
|
46
|
+
// 15 minutes
|
|
47
|
+
enablePeriodicCheck: true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
webhooks: {
|
|
51
|
+
// baseUrl will be determined at runtime from Nitro context
|
|
52
|
+
// Users can override via NUXT_PUBLIC_SITE_URL or explicit config
|
|
53
|
+
baseUrl: process.env.NUXT_PUBLIC_SITE_URL || void 0
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const normalized = defu(options, defaults);
|
|
57
|
+
const neededConnections = /* @__PURE__ */ new Set();
|
|
58
|
+
const queueAdapter = normalized.queue.adapter;
|
|
59
|
+
if (queueAdapter === "redis") {
|
|
60
|
+
neededConnections.add("redis");
|
|
61
|
+
} else if (queueAdapter === "postgres") {
|
|
62
|
+
neededConnections.add("postgres");
|
|
63
|
+
} else if (queueAdapter === "file") {
|
|
64
|
+
neededConnections.add("file");
|
|
65
|
+
}
|
|
66
|
+
const streamAdapter = normalized.stream.adapter;
|
|
67
|
+
if (streamAdapter === "redis") {
|
|
68
|
+
neededConnections.add("redis");
|
|
69
|
+
} else if (streamAdapter === "rabbitmq") {
|
|
70
|
+
neededConnections.add("rabbitmq");
|
|
71
|
+
} else if (streamAdapter === "kafka") {
|
|
72
|
+
neededConnections.add("kafka");
|
|
73
|
+
}
|
|
74
|
+
const storeAdapter = normalized.store.adapter;
|
|
75
|
+
if (storeAdapter === "redis") {
|
|
76
|
+
neededConnections.add("redis");
|
|
77
|
+
} else if (storeAdapter === "postgres") {
|
|
78
|
+
neededConnections.add("postgres");
|
|
79
|
+
} else if (storeAdapter === "file") {
|
|
80
|
+
neededConnections.add("file");
|
|
81
|
+
}
|
|
82
|
+
if (!normalized.connections) {
|
|
83
|
+
normalized.connections = {};
|
|
84
|
+
}
|
|
85
|
+
if (neededConnections.has("redis") && !normalized.connections.redis) {
|
|
86
|
+
normalized.connections.redis = {
|
|
87
|
+
host: "127.0.0.1",
|
|
88
|
+
port: 6379
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (neededConnections.has("postgres") && !normalized.connections.postgres) {
|
|
92
|
+
normalized.connections.postgres = {
|
|
93
|
+
connectionString: process.env.DATABASE_URL || "postgresql://localhost:5432/nvent"
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (neededConnections.has("rabbitmq") && !normalized.connections.rabbitmq) {
|
|
97
|
+
normalized.connections.rabbitmq = {
|
|
98
|
+
host: "localhost",
|
|
99
|
+
port: 5672
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (neededConnections.has("kafka") && !normalized.connections.kafka) {
|
|
103
|
+
normalized.connections.kafka = {
|
|
104
|
+
brokers: ["localhost:9092"]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (neededConnections.has("file") && !normalized.connections.file) {
|
|
108
|
+
normalized.connections.file = {
|
|
109
|
+
dataDir: ".data"
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
applyConnectionFallback(normalized);
|
|
113
|
+
return normalized;
|
|
114
|
+
}
|
|
115
|
+
function applyConnectionFallback(config) {
|
|
116
|
+
if (!config.queue.redis && config.connections.redis) {
|
|
117
|
+
config.queue.redis = config.connections.redis;
|
|
118
|
+
}
|
|
119
|
+
if (!config.queue.postgres && config.connections.postgres) {
|
|
120
|
+
config.queue.postgres = config.connections.postgres;
|
|
121
|
+
}
|
|
122
|
+
if (!config.queue.file && config.connections.file) {
|
|
123
|
+
config.queue.file = {
|
|
124
|
+
dataDir: `${config.connections.file.dataDir}/queue`
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (!config.stream.redis && config.connections.redis) {
|
|
128
|
+
config.stream.redis = config.connections.redis;
|
|
129
|
+
}
|
|
130
|
+
if (!config.stream.rabbitmq && config.connections.rabbitmq) {
|
|
131
|
+
config.stream.rabbitmq = config.connections.rabbitmq;
|
|
132
|
+
}
|
|
133
|
+
if (!config.stream.kafka && config.connections.kafka) {
|
|
134
|
+
config.stream.kafka = config.connections.kafka;
|
|
135
|
+
}
|
|
136
|
+
if (!config.store.redis && config.connections.redis) {
|
|
137
|
+
config.store.redis = config.connections.redis;
|
|
138
|
+
}
|
|
139
|
+
if (!config.store.postgres && config.connections.postgres) {
|
|
140
|
+
config.store.postgres = config.connections.postgres;
|
|
141
|
+
}
|
|
142
|
+
if (!config.store.file && config.connections.file) {
|
|
143
|
+
config.store.file = {
|
|
144
|
+
dataDir: `${config.connections.file.dataDir}/store`
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export function toRuntimeConfig(normalizedOptions) {
|
|
149
|
+
return {
|
|
150
|
+
debug: normalizedOptions.debug,
|
|
151
|
+
rootDir: void 0,
|
|
152
|
+
queue: normalizedOptions.queue,
|
|
153
|
+
stream: normalizedOptions.stream,
|
|
154
|
+
store: normalizedOptions.store,
|
|
155
|
+
connections: normalizedOptions.connections,
|
|
156
|
+
flow: normalizedOptions.flow,
|
|
157
|
+
webhooks: normalizedOptions.webhooks
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
export function getRedisStorageConfig(normalizedOptions) {
|
|
161
|
+
const redisConfig = normalizedOptions.connections.redis;
|
|
162
|
+
if (!redisConfig) {
|
|
163
|
+
return {
|
|
164
|
+
host: "127.0.0.1",
|
|
165
|
+
port: 6379
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
host: redisConfig.host,
|
|
170
|
+
port: redisConfig.port,
|
|
171
|
+
username: redisConfig.username,
|
|
172
|
+
password: redisConfig.password,
|
|
173
|
+
db: redisConfig.db
|
|
174
|
+
};
|
|
175
|
+
}
|