nvent 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.mts +3 -184
- package/dist/module.json +3 -3
- package/dist/module.mjs +133 -197
- package/dist/runtime/adapters/builtin/file-queue.d.ts +53 -0
- package/dist/runtime/adapters/builtin/file-queue.js +435 -0
- package/dist/runtime/adapters/builtin/file-store.d.ts +46 -0
- package/dist/runtime/adapters/builtin/file-store.js +225 -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 +239 -0
- package/dist/runtime/adapters/builtin/memory-store.d.ts +57 -0
- package/dist/runtime/adapters/builtin/memory-store.js +263 -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 +100 -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 +233 -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 +167 -0
- package/dist/runtime/config/types.d.ts +367 -0
- package/dist/runtime/config/types.js +0 -0
- package/dist/runtime/events/types.d.ts +116 -0
- package/dist/runtime/events/types.js +0 -0
- package/dist/runtime/events/utils/stallDetector.d.ts +99 -0
- package/dist/runtime/events/utils/stallDetector.js +237 -0
- package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.d.ts +3 -8
- package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.js +119 -36
- package/dist/runtime/events/wiring/registry.d.ts +19 -0
- package/dist/runtime/events/wiring/registry.js +33 -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 +32 -0
- package/dist/runtime/events/wiring/streamWiring.js +79 -0
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +16 -5
- package/dist/runtime/server/api/_flows/[name]/runs/[runId]/cancel.post.js +21 -0
- package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +12 -2
- package/dist/runtime/server/api/_flows/[name]/runs.get.js +15 -4
- package/dist/runtime/server/api/_flows/[name]/schedule.post.js +11 -2
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +21 -16
- package/dist/runtime/server/api/_flows/[name]/schedules.get.js +21 -19
- package/dist/runtime/server/api/_flows/ws.js +43 -22
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +8 -3
- package/dist/runtime/server/api/_queues/[name]/job/index.get.js +12 -3
- package/dist/runtime/server/api/_queues/index.get.js +66 -23
- package/dist/runtime/server/api/_queues/ws.js +14 -4
- package/dist/runtime/server/plugins/00.adapters.d.ts +14 -0
- package/dist/runtime/server/plugins/00.adapters.js +69 -0
- package/dist/runtime/server/plugins/02.workers.js +45 -0
- package/dist/runtime/tsconfig.json +8 -0
- package/dist/runtime/utils/adapters.d.ts +66 -0
- package/dist/runtime/utils/adapters.js +51 -0
- package/dist/runtime/utils/defineFunction.d.ts +10 -0
- package/dist/runtime/{server-utils/utils/defineQueueWorker.js → utils/defineFunction.js} +4 -4
- package/dist/runtime/{server-utils/utils/defineQueueConfig.d.ts → utils/defineFunctionConfig.d.ts} +3 -3
- package/dist/runtime/utils/defineFunctionConfig.js +2 -0
- package/dist/runtime/utils/registerAdapter.d.ts +59 -0
- package/dist/runtime/utils/registerAdapter.js +13 -0
- package/dist/runtime/utils/useFlowEngine.d.ts +19 -0
- package/dist/runtime/utils/useFlowEngine.js +108 -0
- package/dist/runtime/{server-utils/utils → utils}/useNventLogger.js +2 -2
- package/dist/runtime/utils/useStreamTopics.d.ts +72 -0
- package/dist/runtime/utils/useStreamTopics.js +47 -0
- package/dist/runtime/{server-utils/worker/runner/node.d.ts → worker/node/runner.d.ts} +18 -2
- package/dist/runtime/{server-utils/worker/runner/node.js → worker/node/runner.js} +44 -17
- package/dist/types.d.mts +2 -2
- package/package.json +14 -44
- 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/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.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.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/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.js +0 -2
- package/dist/runtime/server-utils/utils/defineQueueWorker.d.ts +0 -10
- 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/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.d.ts +0 -0
- /package/dist/runtime/{server-utils/events → events}/eventBus.js +0 -0
- /package/dist/runtime/server/{plugins/queue-management.d.ts → api/_flows/[name]/runs/[runId]/cancel.post.d.ts} +0 -0
- /package/dist/runtime/server/plugins/{00.ws-lifecycle.d.ts → 01.ws-lifecycle.d.ts} +0 -0
- /package/dist/runtime/server/plugins/{00.ws-lifecycle.js → 01.ws-lifecycle.js} +0 -0
- /package/dist/runtime/server/plugins/{worker-management.d.ts → 02.workers.d.ts} +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/useEventManager.d.ts +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/useEventManager.js +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/useNventLogger.d.ts +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/wsPeerManager.d.ts +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/wsPeerManager.js +0 -0
- /package/dist/runtime/{python → worker/python}/get_config.py +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { QueueEvent, JobsQuery, ScheduleOptions, JobInput, JobCounts } from '../queue/types.js';
|
|
2
|
-
export declare const useQueue: () => {
|
|
3
|
-
enqueue: (queue: string, job: JobInput) => Promise<string>;
|
|
4
|
-
schedule: (queue: string, job: JobInput, opts?: ScheduleOptions) => Promise<string>;
|
|
5
|
-
getJob: (queue: string, id: string) => Promise<import("../queue/types.js").Job | null>;
|
|
6
|
-
getJobs: (queue: string, q?: JobsQuery) => Promise<import("../queue/types.js").Job[]>;
|
|
7
|
-
on: (queue: string, event: QueueEvent, cb: (p: any) => void) => () => void;
|
|
8
|
-
pause: (queue: string) => Promise<void>;
|
|
9
|
-
resume: (queue: string) => Promise<void>;
|
|
10
|
-
getJobCounts: (queue: string) => Promise<Record<string, number>> | {
|
|
11
|
-
new (executor: (resolve: (value: JobCounts | PromiseLike<JobCounts>) => void, reject: (reason?: any) => void) => void): Promise<JobCounts>;
|
|
12
|
-
all<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
|
|
13
|
-
all<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>;
|
|
14
|
-
race<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
|
|
15
|
-
race<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
|
|
16
|
-
readonly prototype: Promise<any>;
|
|
17
|
-
reject<T = never>(reason?: any): Promise<T>;
|
|
18
|
-
resolve(): Promise<void>;
|
|
19
|
-
resolve<T>(value: T): Promise<Awaited<T>>;
|
|
20
|
-
resolve<T>(value: T | PromiseLike<T>): Promise<Awaited<T>>;
|
|
21
|
-
allSettled<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>; }>;
|
|
22
|
-
allSettled<T>(values: Iterable<T | PromiseLike<T>>): Promise<PromiseSettledResult<Awaited<T>>[]>;
|
|
23
|
-
any<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
|
|
24
|
-
any<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
|
|
25
|
-
withResolvers<T>(): PromiseWithResolvers<T>;
|
|
26
|
-
try<T, U extends unknown[]>(callbackFn: (...args: U) => T | PromiseLike<T>, ...args: U): Promise<Awaited<T>>;
|
|
27
|
-
readonly [Symbol.species]: PromiseConstructor;
|
|
28
|
-
};
|
|
29
|
-
isPaused: (queue: string) => Promise<any>;
|
|
30
|
-
close: () => Promise<void>;
|
|
31
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { getQueueProvider } from "../queue/queueFactory.js";
|
|
2
|
-
export const useQueue = () => {
|
|
3
|
-
const provider = getQueueProvider();
|
|
4
|
-
return {
|
|
5
|
-
// Enqueue immediately
|
|
6
|
-
enqueue: (queue, job) => provider.enqueue(queue, job),
|
|
7
|
-
// Schedule with optional delay or cron
|
|
8
|
-
schedule: (queue, job, opts) => provider.schedule(queue, job, opts),
|
|
9
|
-
// Fetch single job
|
|
10
|
-
getJob: (queue, id) => provider.getJob(queue, id),
|
|
11
|
-
// List jobs (provider decides states/pagination)
|
|
12
|
-
getJobs: (queue, q) => provider.getJobs(queue, q),
|
|
13
|
-
// Subscribe to provider-agnostic events
|
|
14
|
-
on: (queue, event, cb) => provider.on(queue, event, cb),
|
|
15
|
-
// Operational controls
|
|
16
|
-
pause: (queue) => provider.pause(queue),
|
|
17
|
-
resume: (queue) => provider.resume(queue),
|
|
18
|
-
// Optional helpers if provider exposes them
|
|
19
|
-
getJobCounts: (queue) => provider.getJobCounts ? provider.getJobCounts(queue) : Promise,
|
|
20
|
-
isPaused: (queue) => provider.isPaused ? provider.isPaused(queue) : Promise.resolve(void 0),
|
|
21
|
-
// Provider lifecycle (normally handled by plugin/provider)
|
|
22
|
-
close: () => provider.close()
|
|
23
|
-
};
|
|
24
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Worker } from 'bullmq';
|
|
2
|
-
import { type NodeHandler } from './runner/node.js';
|
|
3
|
-
export declare function closeAllWorkers(): Promise<void>;
|
|
4
|
-
export declare function registerTsWorker(queueName: string, jobName: string, handler: NodeHandler, opts?: any): Promise<Worker<any, any, string>>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Worker } from "bullmq";
|
|
2
|
-
import { createBullMQProcessor } from "./runner/node.js";
|
|
3
|
-
import { useRuntimeConfig, useNventLogger } from "#imports";
|
|
4
|
-
const registeredWorkers = /* @__PURE__ */ new Map();
|
|
5
|
-
export async function closeAllWorkers() {
|
|
6
|
-
const logger = useNventLogger("worker-adapter");
|
|
7
|
-
const closePromises = [];
|
|
8
|
-
for (const [queueName, info] of registeredWorkers.entries()) {
|
|
9
|
-
closePromises.push(
|
|
10
|
-
info.worker.close().catch((err) => {
|
|
11
|
-
if (err.code !== "EPIPE" && !err.message?.includes("Connection is closed")) {
|
|
12
|
-
logger.warn("Error closing worker for queue", { queueName, error: err });
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
await Promise.allSettled(closePromises);
|
|
18
|
-
registeredWorkers.clear();
|
|
19
|
-
logger.info("[closeAllWorkers] All workers closed");
|
|
20
|
-
}
|
|
21
|
-
export async function registerTsWorker(queueName, jobName, handler, opts) {
|
|
22
|
-
let info = registeredWorkers.get(queueName);
|
|
23
|
-
const logger = useNventLogger("worker-adapter");
|
|
24
|
-
if (info) {
|
|
25
|
-
logger.info(`[registerTsWorker] Adding handler for job "${jobName}" to existing worker for queue "${queueName}"`);
|
|
26
|
-
info.handlers.set(jobName, handler);
|
|
27
|
-
return info.worker;
|
|
28
|
-
}
|
|
29
|
-
logger.info(`[registerTsWorker] Creating new worker for queue: ${queueName}`);
|
|
30
|
-
const handlers = /* @__PURE__ */ new Map();
|
|
31
|
-
handlers.set(jobName, handler);
|
|
32
|
-
const dispatcher = async (job) => {
|
|
33
|
-
const handler2 = handlers.get(job.name);
|
|
34
|
-
if (!handler2) {
|
|
35
|
-
const error = `[Worker] No handler registered for job "${job.name}" on queue "${queueName}". Available handlers: ${Array.from(handlers.keys()).join(", ")}`;
|
|
36
|
-
logger.error(error);
|
|
37
|
-
throw new Error(error);
|
|
38
|
-
}
|
|
39
|
-
const processor = createBullMQProcessor(handler2, queueName);
|
|
40
|
-
return processor(job);
|
|
41
|
-
};
|
|
42
|
-
const rc = useRuntimeConfig();
|
|
43
|
-
const connection = rc?.queue?.queue?.redis;
|
|
44
|
-
const shouldPause = opts?.autorun === false;
|
|
45
|
-
const worker = new Worker(queueName, dispatcher, { connection, ...opts || {} });
|
|
46
|
-
if (shouldPause) {
|
|
47
|
-
await worker.pause();
|
|
48
|
-
logger.info(`[registerTsWorker] Worker for queue "${queueName}" created but paused (autorun: false)`);
|
|
49
|
-
} else {
|
|
50
|
-
logger.info(`[registerTsWorker] Worker for queue "${queueName}" created and running`);
|
|
51
|
-
}
|
|
52
|
-
worker.on("error", (err) => {
|
|
53
|
-
logger.error(`[Worker] Error in worker for queue "${queueName}":`, err);
|
|
54
|
-
});
|
|
55
|
-
worker.on("failed", (job, err) => {
|
|
56
|
-
logger.error(`[Worker] Job failed in worker for queue "${queueName}":`, {
|
|
57
|
-
jobId: job?.id,
|
|
58
|
-
jobName: job?.name,
|
|
59
|
-
error: err.message,
|
|
60
|
-
stack: err.stack
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
info = { worker, handlers };
|
|
64
|
-
registeredWorkers.set(queueName, info);
|
|
65
|
-
return worker;
|
|
66
|
-
}
|
package/dist/runtime/types.d.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import type { WorkerOptions as BullmqWorkerOptions } from 'bullmq'
|
|
2
|
-
import type z from 'zod'
|
|
3
|
-
import type colors from 'tailwindcss/colors'
|
|
4
|
-
import type { JobSchemaArray, JobSchema } from './schema'
|
|
5
|
-
|
|
6
|
-
type NeutralColor = 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone'
|
|
7
|
-
export type Color = Exclude<keyof typeof colors, 'inherit' | 'current' | 'transparent' | 'black' | 'white' | NeutralColor> | NeutralColor
|
|
8
|
-
|
|
9
|
-
export type Jobs = z.infer<typeof JobSchemaArray>
|
|
10
|
-
export type Job = z.infer<typeof JobSchema>
|
|
11
|
-
|
|
12
|
-
export type WorkerOptions = Omit<BullmqWorkerOptions, 'connection' | 'useWorkerThreads'>
|
|
13
|
-
|
|
14
|
-
export type WorkerConfig = Record<string, WorkerOptions>
|
|
15
|
-
|
|
16
|
-
export type QueueData = {
|
|
17
|
-
name: string
|
|
18
|
-
origin: 'remote' | 'local'
|
|
19
|
-
active: boolean
|
|
20
|
-
jobs: JobCounts
|
|
21
|
-
worker: number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Declarations for worker authoring helpers available via auto-imports at runtime
|
|
25
|
-
// These declarations make TS happy in worker files and tests.
|
|
26
|
-
export declare function defineQueueWorker(processor: (...args: any[]) => any): any
|
|
27
|
-
export declare function defineQueueConfig(cfg: any): any
|
|
28
|
-
|
|
29
|
-
// v0.4 Event Schema
|
|
30
|
-
export type EventType = 'flow.start' | 'flow.completed' | 'flow.failed' | 'step.started' | 'step.completed' | 'step.failed' | 'step.retry' | 'log' | 'emit' | 'state'
|
|
31
|
-
|
|
32
|
-
export interface BaseEvent {
|
|
33
|
-
id?: string // Redis stream ID (auto-generated, not present for ingress events)
|
|
34
|
-
ts?: string // ISO timestamp (auto-generated, not present for ingress events)
|
|
35
|
-
type: EventType
|
|
36
|
-
runId: string // Flow run UUID
|
|
37
|
-
flowName: string // Flow definition name
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface StepEvent extends BaseEvent {
|
|
41
|
-
stepName: string
|
|
42
|
-
stepId: string
|
|
43
|
-
attempt: number
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface FlowStartEvent extends BaseEvent {
|
|
47
|
-
type: 'flow.start'
|
|
48
|
-
data?: {
|
|
49
|
-
input?: any
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface FlowCompletedEvent extends BaseEvent {
|
|
54
|
-
type: 'flow.completed'
|
|
55
|
-
data?: {
|
|
56
|
-
result?: any
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface FlowFailedEvent extends BaseEvent {
|
|
61
|
-
type: 'flow.failed'
|
|
62
|
-
data?: {
|
|
63
|
-
error?: string
|
|
64
|
-
stack?: string
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface StepStartedEvent extends StepEvent {
|
|
69
|
-
type: 'step.started'
|
|
70
|
-
data?: {
|
|
71
|
-
input?: any
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface StepCompletedEvent extends StepEvent {
|
|
76
|
-
type: 'step.completed'
|
|
77
|
-
data?: {
|
|
78
|
-
result?: any
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface StepFailedEvent extends StepEvent {
|
|
83
|
-
type: 'step.failed'
|
|
84
|
-
data?: {
|
|
85
|
-
error?: string
|
|
86
|
-
stack?: string
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface StepRetryEvent extends StepEvent {
|
|
91
|
-
type: 'step.retry'
|
|
92
|
-
data?: {
|
|
93
|
-
stepName: string
|
|
94
|
-
queue: string
|
|
95
|
-
error?: string
|
|
96
|
-
stack?: string
|
|
97
|
-
attempt: number
|
|
98
|
-
maxAttempts: number
|
|
99
|
-
nextAttempt: number
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface LogEvent extends StepEvent {
|
|
104
|
-
type: 'log'
|
|
105
|
-
data: {
|
|
106
|
-
level: 'debug' | 'info' | 'warn' | 'error'
|
|
107
|
-
message: string
|
|
108
|
-
[key: string]: any
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface EmitEvent extends StepEvent {
|
|
113
|
-
type: 'emit'
|
|
114
|
-
data: {
|
|
115
|
-
topic: string
|
|
116
|
-
payload: any
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface StateEvent extends StepEvent {
|
|
121
|
-
type: 'state'
|
|
122
|
-
data: {
|
|
123
|
-
operation: 'get' | 'set' | 'delete'
|
|
124
|
-
scope?: string
|
|
125
|
-
key: string
|
|
126
|
-
value?: any
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export type FlowEvent = FlowStartEvent | FlowCompletedEvent | FlowFailedEvent | StepStartedEvent | StepCompletedEvent | StepFailedEvent | StepRetryEvent | LogEvent | EmitEvent | StateEvent
|
|
131
|
-
|
|
132
|
-
export type EventRecord = FlowEvent
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|