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,67 @@
|
|
|
1
|
+
import { useNventLogger, useScheduler } from "#imports";
|
|
2
|
+
import { getEventBus } from "../../../events/eventBus.js";
|
|
3
|
+
export async function registerTimeAwait(runId, stepName, flowName, config, position = "after") {
|
|
4
|
+
const logger = useNventLogger("await-time");
|
|
5
|
+
const eventBus = getEventBus();
|
|
6
|
+
const scheduler = useScheduler();
|
|
7
|
+
if (!config.delay) {
|
|
8
|
+
throw new Error("Time await requires delay configuration (in milliseconds)");
|
|
9
|
+
}
|
|
10
|
+
logger.info(`Registering time await: ${config.delay}ms`, { runId, stepName });
|
|
11
|
+
const resolveAt = Date.now() + config.delay;
|
|
12
|
+
const jobId = `await-time-${runId}-${stepName}-${position}`;
|
|
13
|
+
await scheduler.schedule({
|
|
14
|
+
id: jobId,
|
|
15
|
+
name: `Time Await: ${flowName} - ${stepName}`,
|
|
16
|
+
type: "one-time",
|
|
17
|
+
executeAt: resolveAt,
|
|
18
|
+
handler: async () => {
|
|
19
|
+
await resolveTimeAwait(runId, stepName, flowName, position, { delayCompleted: true });
|
|
20
|
+
},
|
|
21
|
+
metadata: {
|
|
22
|
+
component: "await-pattern",
|
|
23
|
+
awaitType: "time",
|
|
24
|
+
runId,
|
|
25
|
+
stepName,
|
|
26
|
+
flowName,
|
|
27
|
+
position,
|
|
28
|
+
delay: config.delay
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
eventBus.publish({
|
|
32
|
+
type: "await.registered",
|
|
33
|
+
flowName,
|
|
34
|
+
runId,
|
|
35
|
+
stepName,
|
|
36
|
+
awaitType: "time",
|
|
37
|
+
position,
|
|
38
|
+
config,
|
|
39
|
+
data: {
|
|
40
|
+
delay: config.delay,
|
|
41
|
+
resolveAt,
|
|
42
|
+
registeredAt: Date.now()
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
logger.debug(`Time await registered: ${config.delay}ms`, { runId, stepName });
|
|
46
|
+
return {
|
|
47
|
+
delay: config.delay,
|
|
48
|
+
resolveAt
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export async function resolveTimeAwait(runId, stepName, flowName, position, timeData) {
|
|
52
|
+
const logger = useNventLogger("await-time");
|
|
53
|
+
const eventBus = getEventBus();
|
|
54
|
+
logger.info(`Resolving time await`, { runId, stepName });
|
|
55
|
+
eventBus.publish({
|
|
56
|
+
type: "await.resolved",
|
|
57
|
+
flowName,
|
|
58
|
+
runId,
|
|
59
|
+
stepName,
|
|
60
|
+
position,
|
|
61
|
+
triggerData: timeData,
|
|
62
|
+
data: {
|
|
63
|
+
resolvedAt: Date.now()
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
logger.debug(`Time await resolved`, { runId, stepName });
|
|
67
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AwaitConfig } from '../../../../registry/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Await Pattern: Webhook
|
|
4
|
+
*
|
|
5
|
+
* Creates a dynamic webhook endpoint that resolves when called
|
|
6
|
+
* Useful for human approval flows, external integrations
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerWebhookAwait(runId: string, stepName: string, flowName: string, config: AwaitConfig, position?: 'before' | 'after'): Promise<{
|
|
9
|
+
webhookUrl: string;
|
|
10
|
+
timeout: number | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve webhook await when webhook is called
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveWebhookAwait(runId: string, stepName: string, flowName: string, position: 'before' | 'after', webhookData: any): Promise<void>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useNventLogger, useRuntimeConfig, useScheduler } from "#imports";
|
|
2
|
+
import { getEventBus } from "../../../events/eventBus.js";
|
|
3
|
+
export async function registerWebhookAwait(runId, stepName, flowName, config, position = "after") {
|
|
4
|
+
const logger = useNventLogger("await-webhook");
|
|
5
|
+
const eventBus = getEventBus();
|
|
6
|
+
const runtimeConfig = useRuntimeConfig();
|
|
7
|
+
const path = `/${flowName}/${runId}/${stepName}`;
|
|
8
|
+
let baseUrl = runtimeConfig.nvent?.webhooks?.baseUrl;
|
|
9
|
+
if (!baseUrl) {
|
|
10
|
+
const nitroApp = runtimeConfig.nitro?.app;
|
|
11
|
+
if (nitroApp?.baseURL) {
|
|
12
|
+
baseUrl = `${nitroApp.baseURL}`;
|
|
13
|
+
}
|
|
14
|
+
if (!baseUrl) {
|
|
15
|
+
baseUrl = process.env.NITRO_URL || process.env.URL || (process.env.NODE_ENV === "development" ? "http://localhost:3000" : void 0);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (!baseUrl) {
|
|
19
|
+
logger.warn("No baseUrl configured for webhooks. Set NUXT_PUBLIC_SITE_URL or nvent.webhooks.baseUrl");
|
|
20
|
+
baseUrl = "http://localhost:3000";
|
|
21
|
+
}
|
|
22
|
+
const webhookPath = `/api/_webhook/await${path}`;
|
|
23
|
+
const fullWebhookUrl = `${baseUrl.replace(/\/$/, "")}${webhookPath}`;
|
|
24
|
+
logger.info(`Registering webhook await: ${fullWebhookUrl}`, { runId, stepName });
|
|
25
|
+
eventBus.publish({
|
|
26
|
+
type: "await.registered",
|
|
27
|
+
flowName,
|
|
28
|
+
runId,
|
|
29
|
+
stepName,
|
|
30
|
+
awaitType: "webhook",
|
|
31
|
+
position,
|
|
32
|
+
config,
|
|
33
|
+
data: {
|
|
34
|
+
path,
|
|
35
|
+
method: config.method || "POST",
|
|
36
|
+
timeout: config.timeout,
|
|
37
|
+
registeredAt: Date.now(),
|
|
38
|
+
webhookUrl: fullWebhookUrl
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (config.timeout && config.timeout > 0) {
|
|
42
|
+
const scheduler = useScheduler();
|
|
43
|
+
const timeoutAt = Date.now() + config.timeout;
|
|
44
|
+
const jobId = `await-webhook-timeout-${runId}-${stepName}-${position}`;
|
|
45
|
+
await scheduler.schedule({
|
|
46
|
+
id: jobId,
|
|
47
|
+
name: `Webhook Timeout: ${flowName} - ${stepName}`,
|
|
48
|
+
type: "one-time",
|
|
49
|
+
executeAt: timeoutAt,
|
|
50
|
+
handler: async () => {
|
|
51
|
+
logger.warn("Webhook await timeout", {
|
|
52
|
+
runId,
|
|
53
|
+
stepName,
|
|
54
|
+
flowName,
|
|
55
|
+
timeout: config.timeout,
|
|
56
|
+
timeoutAction: config.timeoutAction || "fail"
|
|
57
|
+
});
|
|
58
|
+
eventBus.publish({
|
|
59
|
+
type: "await.timeout",
|
|
60
|
+
flowName,
|
|
61
|
+
runId,
|
|
62
|
+
stepName,
|
|
63
|
+
position,
|
|
64
|
+
awaitType: "webhook",
|
|
65
|
+
timeoutAction: config.timeoutAction || "fail",
|
|
66
|
+
data: {
|
|
67
|
+
timeout: config.timeout,
|
|
68
|
+
registeredAt: Date.now() - (config.timeout || 0),
|
|
69
|
+
timedOutAt: Date.now()
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
metadata: {
|
|
74
|
+
component: "await-pattern",
|
|
75
|
+
awaitType: "webhook",
|
|
76
|
+
runId,
|
|
77
|
+
stepName,
|
|
78
|
+
flowName,
|
|
79
|
+
position,
|
|
80
|
+
timeout: config.timeout
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
logger.debug(`Webhook timeout scheduled`, {
|
|
84
|
+
runId,
|
|
85
|
+
stepName,
|
|
86
|
+
timeout: config.timeout,
|
|
87
|
+
timeoutAction: config.timeoutAction
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
logger.debug(`Webhook await registered: ${fullWebhookUrl}`, { runId, stepName });
|
|
91
|
+
return {
|
|
92
|
+
webhookUrl: fullWebhookUrl,
|
|
93
|
+
timeout: config.timeout
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export async function resolveWebhookAwait(runId, stepName, flowName, position, webhookData) {
|
|
97
|
+
const logger = useNventLogger("await-webhook");
|
|
98
|
+
const eventBus = getEventBus();
|
|
99
|
+
const scheduler = useScheduler();
|
|
100
|
+
logger.info(`Resolving webhook await`, { runId, stepName });
|
|
101
|
+
const jobId = `await-webhook-timeout-${runId}-${stepName}-${position}`;
|
|
102
|
+
try {
|
|
103
|
+
await scheduler.unschedule(jobId);
|
|
104
|
+
logger.debug("Unscheduled webhook timeout job", { runId, stepName, jobId });
|
|
105
|
+
} catch {
|
|
106
|
+
logger.debug("Could not unschedule timeout job (may not exist)", { runId, stepName, jobId });
|
|
107
|
+
}
|
|
108
|
+
eventBus.publish({
|
|
109
|
+
type: "await.resolved",
|
|
110
|
+
flowName,
|
|
111
|
+
runId,
|
|
112
|
+
stepName,
|
|
113
|
+
position,
|
|
114
|
+
triggerData: webhookData,
|
|
115
|
+
data: {
|
|
116
|
+
resolvedAt: Date.now()
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
logger.debug(`Webhook await resolved`, { runId, stepName });
|
|
120
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useFlow, useQueueAdapter } from '#imports';
|
|
2
|
+
import type { RunContext, NodeHandler } from '../worker/node/runner.js';
|
|
3
|
+
export type ExtendedRunContext = RunContext & {
|
|
4
|
+
provider: ReturnType<typeof useQueueAdapter>;
|
|
5
|
+
flow: ReturnType<typeof useFlow>;
|
|
6
|
+
registry: any;
|
|
7
|
+
};
|
|
8
|
+
export type DefineFunction = (handler: (input: any, ctx: ExtendedRunContext) => Promise<any>) => NodeHandler;
|
|
9
|
+
export declare const defineFunction: DefineFunction;
|
|
10
|
+
export default defineFunction;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { $useFunctionRegistry, useFlow, useQueueAdapter } from "#imports";
|
|
2
|
+
export const defineFunction = (handler) => {
|
|
3
|
+
const wrapped = async (input, ctx) => {
|
|
4
|
+
const provider = useQueueAdapter();
|
|
5
|
+
const flow = ctx.flow || useFlow();
|
|
6
|
+
const registry = $useFunctionRegistry();
|
|
7
|
+
const extended = {
|
|
8
|
+
...ctx,
|
|
9
|
+
provider,
|
|
10
|
+
flow,
|
|
11
|
+
registry
|
|
12
|
+
};
|
|
13
|
+
return handler(input, extended);
|
|
14
|
+
};
|
|
15
|
+
return wrapped;
|
|
16
|
+
};
|
|
17
|
+
export default defineFunction;
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
export type FlowRole = 'entry' | 'step';
|
|
2
|
+
/**
|
|
3
|
+
* Trigger definition for inline trigger registration
|
|
4
|
+
* Can be defined in function config alongside subscription
|
|
5
|
+
*/
|
|
6
|
+
export interface TriggerDefinition {
|
|
7
|
+
/**
|
|
8
|
+
* Unique trigger name (e.g., 'manual.approve-order')
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Trigger type
|
|
13
|
+
*/
|
|
14
|
+
type: 'event' | 'webhook' | 'schedule' | 'manual';
|
|
15
|
+
/**
|
|
16
|
+
* Trigger scope: 'flow' for entry triggers, 'await' for await patterns
|
|
17
|
+
*/
|
|
18
|
+
scope?: 'flow' | 'await';
|
|
19
|
+
/**
|
|
20
|
+
* Human-readable display name
|
|
21
|
+
*/
|
|
22
|
+
displayName?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Description of what this trigger does
|
|
25
|
+
*/
|
|
26
|
+
description?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Expected flows that should subscribe to this trigger (for validation)
|
|
29
|
+
*/
|
|
30
|
+
expectedSubscribers?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Webhook-specific configuration
|
|
33
|
+
*/
|
|
34
|
+
webhook?: {
|
|
35
|
+
/**
|
|
36
|
+
* URL path for webhook (e.g., '/api/webhooks/stripe')
|
|
37
|
+
*/
|
|
38
|
+
path: string;
|
|
39
|
+
/**
|
|
40
|
+
* HTTP method
|
|
41
|
+
*/
|
|
42
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
43
|
+
/**
|
|
44
|
+
* Authentication configuration
|
|
45
|
+
*/
|
|
46
|
+
auth?: any;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Schedule-specific configuration
|
|
50
|
+
*/
|
|
51
|
+
schedule?: {
|
|
52
|
+
/**
|
|
53
|
+
* Cron expression (e.g., '0 9 * * *' for 9 AM daily)
|
|
54
|
+
*/
|
|
55
|
+
cron: string;
|
|
56
|
+
/**
|
|
57
|
+
* Timezone for cron expression
|
|
58
|
+
*/
|
|
59
|
+
timezone?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Whether schedule is enabled
|
|
62
|
+
*/
|
|
63
|
+
enabled?: boolean;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Additional configuration options
|
|
67
|
+
*/
|
|
68
|
+
config?: Record<string, any>;
|
|
69
|
+
}
|
|
70
|
+
export interface FlowConfig {
|
|
71
|
+
/**
|
|
72
|
+
* One or more flow names this step belongs to.
|
|
73
|
+
* A single worker step can participate in multiple flows.
|
|
74
|
+
*/
|
|
75
|
+
name: string | string[];
|
|
76
|
+
/**
|
|
77
|
+
* Role of this step in the flow.
|
|
78
|
+
*/
|
|
79
|
+
role: FlowRole;
|
|
80
|
+
/**
|
|
81
|
+
* Logical step name (used as job name and event kind on start).
|
|
82
|
+
*/
|
|
83
|
+
step: string;
|
|
84
|
+
/**
|
|
85
|
+
* Event kinds this step emits (e.g., `${step}.completed`).
|
|
86
|
+
*/
|
|
87
|
+
emits?: string[];
|
|
88
|
+
/**
|
|
89
|
+
* Event kinds this step subscribes to; can be a single string or an array.
|
|
90
|
+
* The compiler normalizes this to `string[]` under `subscribes`.
|
|
91
|
+
*/
|
|
92
|
+
subscribes?: string | string[];
|
|
93
|
+
/**
|
|
94
|
+
* Entry trigger configuration (v0.5)
|
|
95
|
+
* Define and/or subscribe to triggers to start flow runs
|
|
96
|
+
*/
|
|
97
|
+
triggers?: {
|
|
98
|
+
/**
|
|
99
|
+
* Define a new trigger inline (optional)
|
|
100
|
+
* If provided, this trigger will be registered at build time
|
|
101
|
+
*/
|
|
102
|
+
define?: TriggerDefinition;
|
|
103
|
+
/**
|
|
104
|
+
* Array of trigger names to subscribe to
|
|
105
|
+
* Can include the defined trigger or external triggers
|
|
106
|
+
*/
|
|
107
|
+
subscribe: string[];
|
|
108
|
+
/**
|
|
109
|
+
* Trigger mode: 'auto' (immediate) or 'manual' (requires approval)
|
|
110
|
+
*/
|
|
111
|
+
mode?: 'auto' | 'manual';
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Await pattern: Wait BEFORE step execution (v0.5)
|
|
115
|
+
* Step won't execute until trigger fires
|
|
116
|
+
*/
|
|
117
|
+
awaitBefore?: AwaitConfig;
|
|
118
|
+
/**
|
|
119
|
+
* Await pattern: Wait AFTER step execution (v0.5)
|
|
120
|
+
* Next steps won't trigger until trigger fires
|
|
121
|
+
*/
|
|
122
|
+
awaitAfter?: AwaitConfig;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Await configuration (run-scoped triggers)
|
|
126
|
+
* Declared in config, no functions allowed (AST-parsed)
|
|
127
|
+
*/
|
|
128
|
+
export interface AwaitConfig {
|
|
129
|
+
/**
|
|
130
|
+
* Trigger type
|
|
131
|
+
*/
|
|
132
|
+
type: 'webhook' | 'event' | 'schedule' | 'time';
|
|
133
|
+
/**
|
|
134
|
+
* URL path for webhook (supports template variables: {runId}, {stepId})
|
|
135
|
+
*/
|
|
136
|
+
path?: string;
|
|
137
|
+
/**
|
|
138
|
+
* HTTP method for webhook
|
|
139
|
+
*/
|
|
140
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
141
|
+
/**
|
|
142
|
+
* Event name to wait for
|
|
143
|
+
*/
|
|
144
|
+
event?: string;
|
|
145
|
+
/**
|
|
146
|
+
* Key to match between event and step data
|
|
147
|
+
* e.g., 'orderId' matches event.orderId === step.orderId
|
|
148
|
+
* Supports nested paths: 'order.id' matches event.order.id === step.order.id
|
|
149
|
+
*/
|
|
150
|
+
filterKey?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Cron expression (e.g., '0 9 * * *' for 9 AM daily)
|
|
153
|
+
*/
|
|
154
|
+
cron?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Hours to add after step completion before calculating next cron occurrence
|
|
157
|
+
*/
|
|
158
|
+
nextAfterHours?: number;
|
|
159
|
+
/**
|
|
160
|
+
* Timezone for cron expression
|
|
161
|
+
*/
|
|
162
|
+
timezone?: string;
|
|
163
|
+
/**
|
|
164
|
+
* Delay in milliseconds
|
|
165
|
+
*/
|
|
166
|
+
delay?: number;
|
|
167
|
+
/**
|
|
168
|
+
* Maximum wait time in milliseconds
|
|
169
|
+
*/
|
|
170
|
+
timeout?: number;
|
|
171
|
+
/**
|
|
172
|
+
* Action to take on timeout
|
|
173
|
+
*/
|
|
174
|
+
timeoutAction?: 'fail' | 'continue' | 'retry';
|
|
175
|
+
}
|
|
176
|
+
export interface QueueJobDefaults {
|
|
177
|
+
/**
|
|
178
|
+
* Number of retry attempts for failed jobs.
|
|
179
|
+
* BullMQ: attempts, PGBoss: retryLimit
|
|
180
|
+
*/
|
|
181
|
+
attempts?: number;
|
|
182
|
+
/**
|
|
183
|
+
* Backoff strategy for retries.
|
|
184
|
+
* BullMQ: backoff, PGBoss: retryBackoff + exponentialBackoff
|
|
185
|
+
*/
|
|
186
|
+
backoff?: number | {
|
|
187
|
+
type: 'fixed' | 'exponential';
|
|
188
|
+
delay: number;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Delay in milliseconds before the job is processed.
|
|
192
|
+
* BullMQ: delay, PGBoss: startAfter
|
|
193
|
+
*/
|
|
194
|
+
delay?: number;
|
|
195
|
+
/**
|
|
196
|
+
* Job priority (higher number = higher priority).
|
|
197
|
+
* BullMQ: priority, PGBoss: priority
|
|
198
|
+
*/
|
|
199
|
+
priority?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Job timeout in milliseconds.
|
|
202
|
+
* BullMQ: timeout, PGBoss: expireInSeconds (converted)
|
|
203
|
+
*/
|
|
204
|
+
timeout?: number;
|
|
205
|
+
/**
|
|
206
|
+
* Process jobs in LIFO (Last In First Out) order.
|
|
207
|
+
* BullMQ: lifo, PGBoss: not supported
|
|
208
|
+
*/
|
|
209
|
+
lifo?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Remove job from queue when completed.
|
|
212
|
+
* BullMQ: removeOnComplete, PGBoss: deleteAfterSeconds
|
|
213
|
+
*/
|
|
214
|
+
removeOnComplete?: boolean | number;
|
|
215
|
+
/**
|
|
216
|
+
* Remove job from queue when failed.
|
|
217
|
+
* BullMQ: removeOnFail, PGBoss: deleteAfterSeconds
|
|
218
|
+
*/
|
|
219
|
+
removeOnFail?: boolean | number;
|
|
220
|
+
/**
|
|
221
|
+
* Repeatable job configuration.
|
|
222
|
+
* BullMQ: repeat, PGBoss: schedule pattern
|
|
223
|
+
*/
|
|
224
|
+
repeat?: {
|
|
225
|
+
cron?: string;
|
|
226
|
+
every?: number;
|
|
227
|
+
limit?: number;
|
|
228
|
+
tz?: string;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export interface QueueConfig {
|
|
232
|
+
/**
|
|
233
|
+
* Queue name. If not provided, the filename will be used.
|
|
234
|
+
*/
|
|
235
|
+
name?: string;
|
|
236
|
+
/**
|
|
237
|
+
* Default options for jobs enqueued to this queue.
|
|
238
|
+
*/
|
|
239
|
+
defaultJobOptions?: QueueJobDefaults;
|
|
240
|
+
/**
|
|
241
|
+
* Prefix for queue keys in Redis/storage.
|
|
242
|
+
* BullMQ: prefix, PGBoss: schema
|
|
243
|
+
*/
|
|
244
|
+
prefix?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Rate limiting configuration.
|
|
247
|
+
* BullMQ: limiter, PGBoss: teamSize + teamConcurrency (partial)
|
|
248
|
+
*/
|
|
249
|
+
limiter?: {
|
|
250
|
+
/**
|
|
251
|
+
* Maximum number of jobs to process in the duration window.
|
|
252
|
+
*/
|
|
253
|
+
max?: number;
|
|
254
|
+
/**
|
|
255
|
+
* Duration of the rate limit window in milliseconds.
|
|
256
|
+
*/
|
|
257
|
+
duration?: number;
|
|
258
|
+
/**
|
|
259
|
+
* Group key for rate limiting (optional).
|
|
260
|
+
* BullMQ only: allows per-group rate limiting
|
|
261
|
+
*/
|
|
262
|
+
groupKey?: string;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
export interface WorkerConfig {
|
|
266
|
+
/**
|
|
267
|
+
* Number of jobs to process concurrently.
|
|
268
|
+
* BullMQ: concurrency, PGBoss: teamSize
|
|
269
|
+
*/
|
|
270
|
+
concurrency?: number;
|
|
271
|
+
/**
|
|
272
|
+
* Lock duration in milliseconds.
|
|
273
|
+
* BullMQ: lockDuration, PGBoss: newJobCheckInterval (similar concept)
|
|
274
|
+
*/
|
|
275
|
+
lockDurationMs?: number;
|
|
276
|
+
/**
|
|
277
|
+
* Maximum number of times a job can be stalled before being failed.
|
|
278
|
+
* BullMQ: maxStalledCount, PGBoss: not directly supported
|
|
279
|
+
*/
|
|
280
|
+
maxStalledCount?: number;
|
|
281
|
+
/**
|
|
282
|
+
* Delay in milliseconds before processing jobs after queue is drained.
|
|
283
|
+
* BullMQ: drainDelay, PGBoss: not directly supported
|
|
284
|
+
*/
|
|
285
|
+
drainDelayMs?: number;
|
|
286
|
+
/**
|
|
287
|
+
* Automatically run worker on startup.
|
|
288
|
+
* BullMQ: autorun, PGBoss: workers start automatically
|
|
289
|
+
*/
|
|
290
|
+
autorun?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Polling interval in milliseconds for checking new jobs.
|
|
293
|
+
* PGBoss: newJobCheckInterval, BullMQ: uses blocking wait
|
|
294
|
+
*/
|
|
295
|
+
pollingIntervalMs?: number;
|
|
296
|
+
}
|
|
297
|
+
export interface QueueWorkerConfig {
|
|
298
|
+
queue?: QueueConfig;
|
|
299
|
+
flow?: FlowConfig;
|
|
300
|
+
worker?: WorkerConfig;
|
|
301
|
+
}
|
|
302
|
+
export type DefineFunctionConfig = <T extends QueueWorkerConfig>(cfg: T) => T;
|
|
303
|
+
export declare const defineFunctionConfig: DefineFunctionConfig;
|
|
304
|
+
/**
|
|
305
|
+
* Helper for defining trigger configurations inline
|
|
306
|
+
* This is just a type helper, actual value is the same as defineFunctionConfig
|
|
307
|
+
*/
|
|
308
|
+
export type DefineTriggerConfig = <T extends TriggerDefinition>(cfg: T) => T;
|
|
309
|
+
export declare const defineTriggerConfig: DefineTriggerConfig;
|
|
310
|
+
export default defineFunctionConfig;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe hook definitions for await patterns
|
|
3
|
+
* v0.5 - Await Integration
|
|
4
|
+
*/
|
|
5
|
+
import type { RunContext } from '../worker/node/runner.js';
|
|
6
|
+
export interface AwaitRegisterContext extends Pick<RunContext, 'flowId' | 'flowName' | 'stepName' | 'logger' | 'state'> {
|
|
7
|
+
awaitType: 'webhook' | 'event' | 'schedule' | 'time';
|
|
8
|
+
awaitConfig: any;
|
|
9
|
+
}
|
|
10
|
+
export interface AwaitResolveContext extends Pick<RunContext, 'flowId' | 'flowName' | 'stepName' | 'logger' | 'state'> {
|
|
11
|
+
awaitType: 'webhook' | 'event' | 'schedule' | 'time';
|
|
12
|
+
resolvedData: any;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Define onAwaitRegister hook with proper types
|
|
16
|
+
* Called when an await pattern is registered (before handler execution or after completion)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* export const onAwaitRegister = defineAwaitRegisterHook(async (webhookUrl, stepData, ctx) => {
|
|
20
|
+
* // Send notification email with webhook URL
|
|
21
|
+
* await sendEmail({
|
|
22
|
+
* to: stepData.reviewerEmail,
|
|
23
|
+
* subject: 'Approval Required',
|
|
24
|
+
* approveUrl: webhookUrl
|
|
25
|
+
* })
|
|
26
|
+
* })
|
|
27
|
+
*/
|
|
28
|
+
export declare function defineAwaitRegisterHook(hook: (webhookUrl: string, stepData: any, ctx: AwaitRegisterContext) => Promise<void>): (webhookUrl: string, stepData: any, ctx: AwaitRegisterContext) => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Define onAwaitResolve hook with proper types
|
|
31
|
+
* Called when an await pattern is resolved (external trigger fired)
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* export const onAwaitResolve = defineAwaitResolveHook(async (resolvedData, stepData, ctx) => {
|
|
35
|
+
* ctx.logger.log('info', 'Approval received', { approved: resolvedData.approved })
|
|
36
|
+
*
|
|
37
|
+
* // Update external system
|
|
38
|
+
* await updateTicketStatus(stepData.ticketId, resolvedData.approved ? 'approved' : 'rejected')
|
|
39
|
+
* })
|
|
40
|
+
*/
|
|
41
|
+
export declare function defineAwaitResolveHook(hook: (resolvedData: any, stepData: any, ctx: AwaitResolveContext) => Promise<void>): (resolvedData: any, stepData: any, ctx: AwaitResolveContext) => Promise<void>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter Registration Utilities
|
|
3
|
+
*
|
|
4
|
+
* Used by external adapter modules to register their adapters with nvent
|
|
5
|
+
*/
|
|
6
|
+
import type { QueueAdapter } from '../../adapters/interfaces/queue.js';
|
|
7
|
+
import type { StreamAdapter } from '../../adapters/interfaces/stream.js';
|
|
8
|
+
import type { StoreAdapter } from '../../adapters/interfaces/store.js';
|
|
9
|
+
/**
|
|
10
|
+
* Register a queue adapter
|
|
11
|
+
*
|
|
12
|
+
* Called by external adapter modules (e.g., @nvent/adapter-queue-redis)
|
|
13
|
+
* to register their adapter implementation.
|
|
14
|
+
*
|
|
15
|
+
* @param name - Adapter name (e.g., 'redis', 'postgres', 'rabbitmq')
|
|
16
|
+
* @param adapter - QueueAdapter implementation
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* import { registerQueueAdapter } from '#imports'
|
|
20
|
+
* import { RedisQueueAdapter } from './adapter'
|
|
21
|
+
*
|
|
22
|
+
* const adapter = new RedisQueueAdapter({ connection })
|
|
23
|
+
* registerQueueAdapter('redis', adapter)
|
|
24
|
+
*/
|
|
25
|
+
export declare function registerQueueAdapter(name: string, adapter: QueueAdapter): void;
|
|
26
|
+
/**
|
|
27
|
+
* Register a stream adapter
|
|
28
|
+
*
|
|
29
|
+
* Called by external adapter modules (e.g., @nvent/adapter-stream-redis)
|
|
30
|
+
* to register their adapter implementation.
|
|
31
|
+
*
|
|
32
|
+
* @param name - Adapter name (e.g., 'redis', 'rabbitmq', 'kafka')
|
|
33
|
+
* @param adapter - StreamAdapter implementation
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* import { registerStreamAdapter } from '#imports'
|
|
37
|
+
* import { RedisStreamAdapter } from './adapter'
|
|
38
|
+
*
|
|
39
|
+
* const adapter = new RedisStreamAdapter({ connection })
|
|
40
|
+
* registerStreamAdapter('redis', adapter)
|
|
41
|
+
*/
|
|
42
|
+
export declare function registerStreamAdapter(name: string, adapter: StreamAdapter): void;
|
|
43
|
+
/**
|
|
44
|
+
* Register a store adapter
|
|
45
|
+
*
|
|
46
|
+
* Called by external adapter modules (e.g., @nvent/adapter-store-redis)
|
|
47
|
+
* to register their adapter implementation.
|
|
48
|
+
*
|
|
49
|
+
* @param name - Adapter name (e.g., 'redis', 'postgres')
|
|
50
|
+
* @param adapter - StoreAdapter implementation
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* import { registerStoreAdapter } from '#imports'
|
|
54
|
+
* import { RedisStoreAdapter } from './adapter'
|
|
55
|
+
*
|
|
56
|
+
* const adapter = new RedisStoreAdapter({ connection })
|
|
57
|
+
* registerStoreAdapter('redis', adapter)
|
|
58
|
+
*/
|
|
59
|
+
export declare function registerStoreAdapter(name: string, adapter: StoreAdapter): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useAdapterRegistry } from "../../adapters/registry.js";
|
|
2
|
+
export function registerQueueAdapter(name, adapter) {
|
|
3
|
+
const registry = useAdapterRegistry();
|
|
4
|
+
registry.registerQueue(name, adapter);
|
|
5
|
+
}
|
|
6
|
+
export function registerStreamAdapter(name, adapter) {
|
|
7
|
+
const registry = useAdapterRegistry();
|
|
8
|
+
registry.registerStream(name, adapter);
|
|
9
|
+
}
|
|
10
|
+
export function registerStoreAdapter(name, adapter) {
|
|
11
|
+
const registry = useAdapterRegistry();
|
|
12
|
+
registry.registerStore(name, adapter);
|
|
13
|
+
}
|