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,102 @@
|
|
|
1
|
+
import { useEventManager, useFlow, useRuntimeConfig, useStateAdapter } from "#imports";
|
|
2
|
+
const defaultState = {
|
|
3
|
+
async get() {
|
|
4
|
+
return null;
|
|
5
|
+
},
|
|
6
|
+
async set() {
|
|
7
|
+
},
|
|
8
|
+
async delete() {
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
function scopeKey(baseKey, flowId) {
|
|
12
|
+
if (!flowId) return baseKey;
|
|
13
|
+
return `flow:${flowId}:${baseKey}`;
|
|
14
|
+
}
|
|
15
|
+
export function useRunContext(partial) {
|
|
16
|
+
const state = partial?.state || (() => {
|
|
17
|
+
try {
|
|
18
|
+
const stateAdapter = useStateAdapter();
|
|
19
|
+
const rc = useRuntimeConfig();
|
|
20
|
+
const cleanupCfg = rc?.nvent?.state?.cleanup || { strategy: "never" };
|
|
21
|
+
return {
|
|
22
|
+
async get(key) {
|
|
23
|
+
return stateAdapter.get(scopeKey(key, partial?.flowId));
|
|
24
|
+
},
|
|
25
|
+
async set(key, value, opts) {
|
|
26
|
+
const ttl = opts?.ttl ?? (cleanupCfg?.strategy === "ttl" ? cleanupCfg?.ttlMs : void 0);
|
|
27
|
+
return stateAdapter.set(scopeKey(key, partial?.flowId), value, ttl ? { ttl } : void 0);
|
|
28
|
+
},
|
|
29
|
+
async delete(key) {
|
|
30
|
+
return stateAdapter.delete(scopeKey(key, partial?.flowId));
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
} catch {
|
|
34
|
+
return defaultState;
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
37
|
+
const logger = partial?.logger || (() => {
|
|
38
|
+
const eventManager = useEventManager();
|
|
39
|
+
return {
|
|
40
|
+
log: (level, msg, meta) => {
|
|
41
|
+
const runId = partial?.flowId || "unknown";
|
|
42
|
+
const flowName = meta?.flowName || partial?.flowName || "unknown";
|
|
43
|
+
void eventManager.publishBus({
|
|
44
|
+
type: "log",
|
|
45
|
+
runId,
|
|
46
|
+
flowName,
|
|
47
|
+
stepName: meta?.stepName || partial?.stepName,
|
|
48
|
+
stepId: meta?.stepId,
|
|
49
|
+
attempt: meta?.attempt,
|
|
50
|
+
data: { level, message: msg, ...meta }
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
55
|
+
const baseFlowEngine = useFlow();
|
|
56
|
+
const flow = {
|
|
57
|
+
...baseFlowEngine,
|
|
58
|
+
emit: async (trigger, payload = {}) => {
|
|
59
|
+
const enrichedPayload = {
|
|
60
|
+
...payload,
|
|
61
|
+
flowId: payload.flowId || partial?.flowId,
|
|
62
|
+
flowName: payload.flowName || partial?.flowName,
|
|
63
|
+
stepName: payload.stepName || partial?.stepName
|
|
64
|
+
};
|
|
65
|
+
return baseFlowEngine.emit(trigger, enrichedPayload);
|
|
66
|
+
},
|
|
67
|
+
cancel: async () => {
|
|
68
|
+
if (!partial?.flowName || !partial?.flowId) {
|
|
69
|
+
throw new Error("Cannot cancel flow: flowName or flowId not available in context");
|
|
70
|
+
}
|
|
71
|
+
return baseFlowEngine.cancelFlow(partial.flowName, partial.flowId);
|
|
72
|
+
},
|
|
73
|
+
isRunning: async (flowName, runId) => {
|
|
74
|
+
const targetFlowName = flowName || partial?.flowName;
|
|
75
|
+
if (!targetFlowName) {
|
|
76
|
+
throw new Error("flowName is required to check if flow is running");
|
|
77
|
+
}
|
|
78
|
+
return baseFlowEngine.isRunning(targetFlowName, runId);
|
|
79
|
+
},
|
|
80
|
+
getRunningFlows: async (flowName) => {
|
|
81
|
+
const targetFlowName = flowName || partial?.flowName;
|
|
82
|
+
if (!targetFlowName) {
|
|
83
|
+
throw new Error("flowName is required to get running flows");
|
|
84
|
+
}
|
|
85
|
+
return baseFlowEngine.getRunningFlows(targetFlowName);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
jobId: partial?.jobId,
|
|
90
|
+
queue: partial?.queue,
|
|
91
|
+
flowId: partial?.flowId,
|
|
92
|
+
flowName: partial?.flowName,
|
|
93
|
+
stepName: partial?.stepName,
|
|
94
|
+
stepId: partial?.stepId,
|
|
95
|
+
attempt: partial?.attempt,
|
|
96
|
+
logger,
|
|
97
|
+
state,
|
|
98
|
+
flow,
|
|
99
|
+
trigger: partial?.trigger,
|
|
100
|
+
awaitConfig: partial?.awaitConfig
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export declare function useStreamTopics(): {
|
|
2
|
+
StoreSubjects: {
|
|
3
|
+
/**
|
|
4
|
+
* Flow run event stream
|
|
5
|
+
* Pattern: {prefix}:flow:run:{runId}
|
|
6
|
+
* Type: Redis Stream (XADD/XRANGE)
|
|
7
|
+
* Contains: All events for a specific flow run
|
|
8
|
+
*/
|
|
9
|
+
readonly flowRun: (runId: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Flow runs index (sorted set)
|
|
12
|
+
* Pattern: {prefix}:flow:runs:{flowName}
|
|
13
|
+
* Type: Sorted Set + Hash metadata
|
|
14
|
+
* Contains: List of run IDs for a flow, sorted by timestamp
|
|
15
|
+
*/
|
|
16
|
+
readonly flowRunIndex: (flowName: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Flows index (sorted set)
|
|
19
|
+
* Pattern: {prefix}:flows
|
|
20
|
+
* Type: Sorted Set + Hash metadata
|
|
21
|
+
* Contains: Flow metadata and statistics
|
|
22
|
+
*/
|
|
23
|
+
readonly flowIndex: () => string;
|
|
24
|
+
/**
|
|
25
|
+
* Trigger event stream
|
|
26
|
+
* Pattern: {prefix}:trigger:event:{triggerName}
|
|
27
|
+
* Type: Redis Stream (XADD/XRANGE)
|
|
28
|
+
* Contains: All events for a specific trigger
|
|
29
|
+
*/
|
|
30
|
+
readonly triggerStream: (triggerName: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Triggers index (sorted set)
|
|
33
|
+
* Pattern: {prefix}:triggers
|
|
34
|
+
* Type: Sorted Set + Hash metadata
|
|
35
|
+
* Contains: Trigger metadata, subscriptions, and statistics
|
|
36
|
+
*/
|
|
37
|
+
readonly triggerIndex: () => string;
|
|
38
|
+
/**
|
|
39
|
+
* Scheduler job index
|
|
40
|
+
* Pattern: {prefix}:scheduler:jobs
|
|
41
|
+
* Type: Sorted Set + Hash metadata
|
|
42
|
+
* Contains: Scheduled job metadata
|
|
43
|
+
*/
|
|
44
|
+
readonly schedulerJobs: () => string;
|
|
45
|
+
/**
|
|
46
|
+
* Scheduler lock index
|
|
47
|
+
* Pattern: {prefix}:scheduler:locks
|
|
48
|
+
* Type: Sorted Set + Hash metadata
|
|
49
|
+
* Contains: Distributed scheduler lock metadata
|
|
50
|
+
*/
|
|
51
|
+
readonly schedulerLocks: () => string;
|
|
52
|
+
};
|
|
53
|
+
StreamTopics: {
|
|
54
|
+
/**
|
|
55
|
+
* Flow events for a specific run
|
|
56
|
+
* Pattern: {prefix}:stream:flow:events:{runId}
|
|
57
|
+
* Published: When flow events occur (StreamWiring)
|
|
58
|
+
* Subscribed: By WebSocket clients watching a specific flow run
|
|
59
|
+
*/
|
|
60
|
+
readonly flowEvents: (runId: string) => string;
|
|
61
|
+
/**
|
|
62
|
+
* Flow statistics updates
|
|
63
|
+
* Pattern: {prefix}:stream:flow:stats
|
|
64
|
+
* Published: When flow stats change (StreamWiring)
|
|
65
|
+
* Subscribed: By WebSocket clients watching flow overview
|
|
66
|
+
*/
|
|
67
|
+
readonly flowStats: () => string;
|
|
68
|
+
/**
|
|
69
|
+
* Trigger events for a specific trigger
|
|
70
|
+
* Pattern: {prefix}:stream:trigger:events:{triggerName}
|
|
71
|
+
* Published: When trigger events occur (StreamWiring)
|
|
72
|
+
* Subscribed: By WebSocket clients watching a specific trigger
|
|
73
|
+
*/
|
|
74
|
+
readonly triggerEvents: (triggerName: string) => string;
|
|
75
|
+
/**
|
|
76
|
+
* Trigger statistics updates
|
|
77
|
+
* Pattern: {prefix}:stream:trigger:stats
|
|
78
|
+
* Published: When trigger stats change (StreamWiring)
|
|
79
|
+
* Subscribed: By WebSocket clients watching trigger overview
|
|
80
|
+
*/
|
|
81
|
+
readonly triggerStats: () => string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
function getStoreSubjects(prefix) {
|
|
3
|
+
return {
|
|
4
|
+
/**
|
|
5
|
+
* Flow run event stream
|
|
6
|
+
* Pattern: {prefix}:flow:run:{runId}
|
|
7
|
+
* Type: Redis Stream (XADD/XRANGE)
|
|
8
|
+
* Contains: All events for a specific flow run
|
|
9
|
+
*/
|
|
10
|
+
flowRun: (runId) => `${prefix}:flow:run:${runId}`,
|
|
11
|
+
/**
|
|
12
|
+
* Flow runs index (sorted set)
|
|
13
|
+
* Pattern: {prefix}:flow:runs:{flowName}
|
|
14
|
+
* Type: Sorted Set + Hash metadata
|
|
15
|
+
* Contains: List of run IDs for a flow, sorted by timestamp
|
|
16
|
+
*/
|
|
17
|
+
flowRunIndex: (flowName) => `${prefix}:flow:runs:${flowName}`,
|
|
18
|
+
/**
|
|
19
|
+
* Flows index (sorted set)
|
|
20
|
+
* Pattern: {prefix}:flows
|
|
21
|
+
* Type: Sorted Set + Hash metadata
|
|
22
|
+
* Contains: Flow metadata and statistics
|
|
23
|
+
*/
|
|
24
|
+
flowIndex: () => `${prefix}:flows`,
|
|
25
|
+
/**
|
|
26
|
+
* Trigger event stream
|
|
27
|
+
* Pattern: {prefix}:trigger:event:{triggerName}
|
|
28
|
+
* Type: Redis Stream (XADD/XRANGE)
|
|
29
|
+
* Contains: All events for a specific trigger
|
|
30
|
+
*/
|
|
31
|
+
triggerStream: (triggerName) => `${prefix}:trigger:event:${triggerName}`,
|
|
32
|
+
/**
|
|
33
|
+
* Triggers index (sorted set)
|
|
34
|
+
* Pattern: {prefix}:triggers
|
|
35
|
+
* Type: Sorted Set + Hash metadata
|
|
36
|
+
* Contains: Trigger metadata, subscriptions, and statistics
|
|
37
|
+
*/
|
|
38
|
+
triggerIndex: () => `${prefix}:triggers`,
|
|
39
|
+
/**
|
|
40
|
+
* Scheduler job index
|
|
41
|
+
* Pattern: {prefix}:scheduler:jobs
|
|
42
|
+
* Type: Sorted Set + Hash metadata
|
|
43
|
+
* Contains: Scheduled job metadata
|
|
44
|
+
*/
|
|
45
|
+
schedulerJobs: () => `${prefix}:scheduler:jobs`,
|
|
46
|
+
/**
|
|
47
|
+
* Scheduler lock index
|
|
48
|
+
* Pattern: {prefix}:scheduler:locks
|
|
49
|
+
* Type: Sorted Set + Hash metadata
|
|
50
|
+
* Contains: Distributed scheduler lock metadata
|
|
51
|
+
*/
|
|
52
|
+
schedulerLocks: () => `${prefix}:scheduler:locks`
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function getStreamTopics(prefix) {
|
|
56
|
+
return {
|
|
57
|
+
/**
|
|
58
|
+
* Flow events for a specific run
|
|
59
|
+
* Pattern: {prefix}:stream:flow:events:{runId}
|
|
60
|
+
* Published: When flow events occur (StreamWiring)
|
|
61
|
+
* Subscribed: By WebSocket clients watching a specific flow run
|
|
62
|
+
*/
|
|
63
|
+
flowEvents: (runId) => `${prefix}:stream:flow:events:${runId}`,
|
|
64
|
+
/**
|
|
65
|
+
* Flow statistics updates
|
|
66
|
+
* Pattern: {prefix}:stream:flow:stats
|
|
67
|
+
* Published: When flow stats change (StreamWiring)
|
|
68
|
+
* Subscribed: By WebSocket clients watching flow overview
|
|
69
|
+
*/
|
|
70
|
+
flowStats: () => `${prefix}:stream:flow:stats`,
|
|
71
|
+
/**
|
|
72
|
+
* Trigger events for a specific trigger
|
|
73
|
+
* Pattern: {prefix}:stream:trigger:events:{triggerName}
|
|
74
|
+
* Published: When trigger events occur (StreamWiring)
|
|
75
|
+
* Subscribed: By WebSocket clients watching a specific trigger
|
|
76
|
+
*/
|
|
77
|
+
triggerEvents: (triggerName) => `${prefix}:stream:trigger:events:${triggerName}`,
|
|
78
|
+
/**
|
|
79
|
+
* Trigger statistics updates
|
|
80
|
+
* Pattern: {prefix}:stream:trigger:stats
|
|
81
|
+
* Published: When trigger stats change (StreamWiring)
|
|
82
|
+
* Subscribed: By WebSocket clients watching trigger overview
|
|
83
|
+
*/
|
|
84
|
+
triggerStats: () => `${prefix}:stream:trigger:stats`
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function useStreamTopics() {
|
|
88
|
+
const config = useRuntimeConfig();
|
|
89
|
+
const prefix = config.nvent.store?.prefix || "nvent";
|
|
90
|
+
return {
|
|
91
|
+
StoreSubjects: getStoreSubjects(prefix),
|
|
92
|
+
StreamTopics: getStreamTopics(prefix)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { TriggerEntry, TriggerSubscription } from '../../../registry/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Public export for resolving payload references
|
|
4
|
+
* Allows external code to resolve references if needed
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolvePayload(data: any): Promise<any>;
|
|
7
|
+
export interface RegisterTriggerOptions {
|
|
8
|
+
name: string;
|
|
9
|
+
type: 'event' | 'webhook' | 'schedule' | 'manual';
|
|
10
|
+
scope: 'flow' | 'run';
|
|
11
|
+
status?: 'active' | 'inactive' | 'retired';
|
|
12
|
+
displayName?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
source?: string;
|
|
15
|
+
expectedSubscribers?: string[];
|
|
16
|
+
webhook?: {
|
|
17
|
+
path: string;
|
|
18
|
+
method?: string;
|
|
19
|
+
auth?: any;
|
|
20
|
+
};
|
|
21
|
+
schedule?: {
|
|
22
|
+
cron: string;
|
|
23
|
+
timezone?: string;
|
|
24
|
+
enabled?: boolean;
|
|
25
|
+
};
|
|
26
|
+
schema?: any;
|
|
27
|
+
transform?: (data: any) => any;
|
|
28
|
+
config?: {
|
|
29
|
+
persistData?: boolean;
|
|
30
|
+
payloadThreshold?: number;
|
|
31
|
+
retentionDays?: number;
|
|
32
|
+
rateLimit?: {
|
|
33
|
+
max: number;
|
|
34
|
+
window: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface SubscribeTriggerOptions {
|
|
39
|
+
trigger: string;
|
|
40
|
+
flow: string;
|
|
41
|
+
mode?: 'auto' | 'manual';
|
|
42
|
+
filter?: (data: any) => boolean;
|
|
43
|
+
transform?: (data: any) => any;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Core trigger composable
|
|
47
|
+
* Provides runtime API for trigger registration and emission
|
|
48
|
+
*/
|
|
49
|
+
export declare function useTrigger(): {
|
|
50
|
+
/**
|
|
51
|
+
* Register a trigger (programmatic)
|
|
52
|
+
* Publishes event to bus - triggerWiring handles persistence and orchestration
|
|
53
|
+
*/
|
|
54
|
+
registerTrigger(opts: RegisterTriggerOptions): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Subscribe flow to trigger (programmatic)
|
|
57
|
+
* Publishes event to bus - triggerWiring handles persistence and orchestration
|
|
58
|
+
*/
|
|
59
|
+
subscribeTrigger(opts: SubscribeTriggerOptions): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Unsubscribe flow from trigger
|
|
62
|
+
* Publishes event to bus - triggerWiring handles persistence and orchestration
|
|
63
|
+
*/
|
|
64
|
+
unsubscribeTrigger(trigger: string, flow: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Emit trigger (fire event)
|
|
67
|
+
* Publishes event to bus - triggerWiring handles persistence, stats, and orchestration
|
|
68
|
+
*
|
|
69
|
+
* Large payloads are automatically stored in KV store and replaced with references
|
|
70
|
+
* to keep stream events small and memory-efficient.
|
|
71
|
+
*/
|
|
72
|
+
emitTrigger(name: string, data: any, opts?: {
|
|
73
|
+
payloadThreshold?: number;
|
|
74
|
+
}): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Query methods
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* Check if a trigger exists in the registry
|
|
80
|
+
*/
|
|
81
|
+
hasTrigger(name: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Get trigger entry by name
|
|
84
|
+
*/
|
|
85
|
+
getTrigger(name: string): TriggerEntry | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Get all registered triggers
|
|
88
|
+
* @param options - Sorting and pagination options
|
|
89
|
+
* @param options.sortBy - Field to sort by
|
|
90
|
+
* @param options.order - Sort order (asc or desc)
|
|
91
|
+
* @param options.limit - Maximum number of results
|
|
92
|
+
* @param options.offset - Number of results to skip
|
|
93
|
+
*/
|
|
94
|
+
getAllTriggers(options?: {
|
|
95
|
+
sortBy?: "registeredAt" | "lastActivityAt" | "name";
|
|
96
|
+
order?: "asc" | "desc";
|
|
97
|
+
limit?: number;
|
|
98
|
+
offset?: number;
|
|
99
|
+
}): TriggerEntry[];
|
|
100
|
+
/**
|
|
101
|
+
* Get all flows subscribed to a specific trigger
|
|
102
|
+
*/
|
|
103
|
+
getSubscribedFlows(trigger: string): string[];
|
|
104
|
+
/**
|
|
105
|
+
* Get all triggers that a flow is subscribed to
|
|
106
|
+
*/
|
|
107
|
+
getFlowTriggers(flow: string): string[];
|
|
108
|
+
/**
|
|
109
|
+
* Get subscription details for a specific trigger-flow pair
|
|
110
|
+
*/
|
|
111
|
+
getSubscription(trigger: string, flow: string): TriggerSubscription | undefined;
|
|
112
|
+
getAllSubscriptions(): TriggerSubscription[];
|
|
113
|
+
/**
|
|
114
|
+
* Initialize runtime from store (called on startup)
|
|
115
|
+
* Uses index + stream architecture (v0.5.1)
|
|
116
|
+
*/
|
|
117
|
+
initialize(): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Get runtime state (for debugging)
|
|
120
|
+
*/
|
|
121
|
+
getRuntime(): {
|
|
122
|
+
triggerCount: number;
|
|
123
|
+
subscriptionCount: number;
|
|
124
|
+
flowCount: number;
|
|
125
|
+
initialized: boolean;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Delete a trigger completely (removes all data)
|
|
129
|
+
* Publishes event to bus - triggerWiring handles persistence and orchestration
|
|
130
|
+
*/
|
|
131
|
+
deleteTrigger(name: string): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Update trigger status (active/inactive/retired)
|
|
134
|
+
* For future status management UI
|
|
135
|
+
*/
|
|
136
|
+
updateTriggerStatus(name: string, status: "active" | "inactive" | "retired"): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Get trigger statistics
|
|
139
|
+
* v0.5.1: New analytics method
|
|
140
|
+
*/
|
|
141
|
+
getTriggerStats(name: string): Promise<any>;
|
|
142
|
+
/**
|
|
143
|
+
* Get trigger history from stream
|
|
144
|
+
* v0.5.1: New analytics method
|
|
145
|
+
*/
|
|
146
|
+
getTriggerHistory(name: string, opts?: {
|
|
147
|
+
limit?: number;
|
|
148
|
+
types?: string[];
|
|
149
|
+
}): Promise<any>;
|
|
150
|
+
};
|