nvent 0.4.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/LICENSE +21 -0
- package/README.md +389 -0
- package/dist/module.d.mts +193 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +974 -0
- package/dist/runtime/app/components/ConfirmDialog.d.vue.ts +33 -0
- package/dist/runtime/app/components/ConfirmDialog.vue +121 -0
- package/dist/runtime/app/components/ConfirmDialog.vue.d.ts +33 -0
- package/dist/runtime/app/components/FlowDiagram.d.vue.ts +64 -0
- package/dist/runtime/app/components/FlowDiagram.vue +338 -0
- package/dist/runtime/app/components/FlowDiagram.vue.d.ts +64 -0
- package/dist/runtime/app/components/FlowNodeCard.d.vue.ts +29 -0
- package/dist/runtime/app/components/FlowNodeCard.vue +156 -0
- package/dist/runtime/app/components/FlowNodeCard.vue.d.ts +29 -0
- package/dist/runtime/app/components/FlowRunOverview.d.vue.ts +9 -0
- package/dist/runtime/app/components/FlowRunOverview.vue +291 -0
- package/dist/runtime/app/components/FlowRunOverview.vue.d.ts +9 -0
- package/dist/runtime/app/components/FlowRunStatusBadge.d.vue.ts +14 -0
- package/dist/runtime/app/components/FlowRunStatusBadge.vue +60 -0
- package/dist/runtime/app/components/FlowRunStatusBadge.vue.d.ts +14 -0
- package/dist/runtime/app/components/FlowRunTimeline.d.vue.ts +12 -0
- package/dist/runtime/app/components/FlowRunTimeline.vue +127 -0
- package/dist/runtime/app/components/FlowRunTimeline.vue.d.ts +12 -0
- package/dist/runtime/app/components/FlowScheduleDialog.d.vue.ts +16 -0
- package/dist/runtime/app/components/FlowScheduleDialog.vue +226 -0
- package/dist/runtime/app/components/FlowScheduleDialog.vue.d.ts +16 -0
- package/dist/runtime/app/components/FlowSchedulesList.d.vue.ts +12 -0
- package/dist/runtime/app/components/FlowSchedulesList.vue +99 -0
- package/dist/runtime/app/components/FlowSchedulesList.vue.d.ts +12 -0
- package/dist/runtime/app/components/JobScheduling.d.vue.ts +6 -0
- package/dist/runtime/app/components/JobScheduling.vue +203 -0
- package/dist/runtime/app/components/JobScheduling.vue.d.ts +6 -0
- package/dist/runtime/app/components/ListItem.d.vue.ts +23 -0
- package/dist/runtime/app/components/ListItem.vue +70 -0
- package/dist/runtime/app/components/ListItem.vue.d.ts +23 -0
- package/dist/runtime/app/components/QueueConfigDetails.d.vue.ts +45 -0
- package/dist/runtime/app/components/QueueConfigDetails.vue +412 -0
- package/dist/runtime/app/components/QueueConfigDetails.vue.d.ts +45 -0
- package/dist/runtime/app/components/StatCounter.d.vue.ts +9 -0
- package/dist/runtime/app/components/StatCounter.vue +25 -0
- package/dist/runtime/app/components/StatCounter.vue.d.ts +9 -0
- package/dist/runtime/app/components/TimelineList.d.vue.ts +7 -0
- package/dist/runtime/app/components/TimelineList.vue +210 -0
- package/dist/runtime/app/components/TimelineList.vue.d.ts +7 -0
- package/dist/runtime/app/components/nhealth/component-router.d.vue.ts +46 -0
- package/dist/runtime/app/components/nhealth/component-router.vue +26 -0
- package/dist/runtime/app/components/nhealth/component-router.vue.d.ts +46 -0
- package/dist/runtime/app/components/nhealth/component-shell.d.vue.ts +24 -0
- package/dist/runtime/app/components/nhealth/component-shell.vue +89 -0
- package/dist/runtime/app/components/nhealth/component-shell.vue.d.ts +24 -0
- package/dist/runtime/app/composables/useAnalyzedFlows.d.ts +14 -0
- package/dist/runtime/app/composables/useAnalyzedFlows.js +7 -0
- package/dist/runtime/app/composables/useComponentRouter.d.ts +38 -0
- package/dist/runtime/app/composables/useComponentRouter.js +240 -0
- package/dist/runtime/app/composables/useFlowRunTimeline.d.ts +15 -0
- package/dist/runtime/app/composables/useFlowRunTimeline.js +66 -0
- package/dist/runtime/app/composables/useFlowRuns.d.ts +11 -0
- package/dist/runtime/app/composables/useFlowRuns.js +31 -0
- package/dist/runtime/app/composables/useFlowRunsInfinite.d.ts +24 -0
- package/dist/runtime/app/composables/useFlowRunsInfinite.js +123 -0
- package/dist/runtime/app/composables/useFlowRunsPolling.d.ts +8 -0
- package/dist/runtime/app/composables/useFlowRunsPolling.js +26 -0
- package/dist/runtime/app/composables/useFlowState.d.ts +125 -0
- package/dist/runtime/app/composables/useFlowState.js +211 -0
- package/dist/runtime/app/composables/useFlowWebSocket.d.ts +27 -0
- package/dist/runtime/app/composables/useFlowWebSocket.js +205 -0
- package/dist/runtime/app/composables/useFlowsNavigation.d.ts +10 -0
- package/dist/runtime/app/composables/useFlowsNavigation.js +57 -0
- package/dist/runtime/app/composables/useQueueJobs.d.ts +20 -0
- package/dist/runtime/app/composables/useQueueJobs.js +20 -0
- package/dist/runtime/app/composables/useQueueUpdates.d.ts +26 -0
- package/dist/runtime/app/composables/useQueueUpdates.js +122 -0
- package/dist/runtime/app/composables/useQueues.d.ts +43 -0
- package/dist/runtime/app/composables/useQueues.js +26 -0
- package/dist/runtime/app/composables/useQueuesLive.d.ts +19 -0
- package/dist/runtime/app/composables/useQueuesLive.js +143 -0
- package/dist/runtime/app/pages/flows/index.d.vue.ts +3 -0
- package/dist/runtime/app/pages/flows/index.vue +645 -0
- package/dist/runtime/app/pages/flows/index.vue.d.ts +3 -0
- package/dist/runtime/app/pages/index.d.vue.ts +3 -0
- package/dist/runtime/app/pages/index.vue +34 -0
- package/dist/runtime/app/pages/index.vue.d.ts +3 -0
- package/dist/runtime/app/pages/queues/index.d.vue.ts +3 -0
- package/dist/runtime/app/pages/queues/index.vue +229 -0
- package/dist/runtime/app/pages/queues/index.vue.d.ts +3 -0
- package/dist/runtime/app/pages/queues/job.d.vue.ts +3 -0
- package/dist/runtime/app/pages/queues/job.vue +262 -0
- package/dist/runtime/app/pages/queues/job.vue.d.ts +3 -0
- package/dist/runtime/app/pages/queues/jobs.d.vue.ts +3 -0
- package/dist/runtime/app/pages/queues/jobs.vue +291 -0
- package/dist/runtime/app/pages/queues/jobs.vue.d.ts +3 -0
- package/dist/runtime/app/plugins/vueflow.client.d.ts +6 -0
- package/dist/runtime/app/plugins/vueflow.client.js +15 -0
- package/dist/runtime/constants.d.ts +11 -0
- package/dist/runtime/constants.js +11 -0
- package/dist/runtime/python/get_config.py +64 -0
- package/dist/runtime/schema.d.ts +37 -0
- package/dist/runtime/schema.js +20 -0
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.d.ts +10 -0
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +44 -0
- package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +7 -0
- package/dist/runtime/server/api/_flows/[name]/runs.get.js +53 -0
- package/dist/runtime/server/api/_flows/[name]/schedule.post.d.ts +2 -0
- package/dist/runtime/server/api/_flows/[name]/schedule.post.js +57 -0
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.d.ts +2 -0
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +42 -0
- package/dist/runtime/server/api/_flows/[name]/schedules.get.d.ts +2 -0
- package/dist/runtime/server/api/_flows/[name]/schedules.get.js +48 -0
- package/dist/runtime/server/api/_flows/[name]/start.post.d.ts +2 -0
- package/dist/runtime/server/api/_flows/[name]/start.post.js +9 -0
- package/dist/runtime/server/api/_flows/index.get.d.ts +6 -0
- package/dist/runtime/server/api/_flows/index.get.js +5 -0
- package/dist/runtime/server/api/_flows/ws.d.ts +60 -0
- package/dist/runtime/server/api/_flows/ws.js +183 -0
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.d.ts +2 -0
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +9 -0
- package/dist/runtime/server/api/_queues/[name]/job/index.get.d.ts +2 -0
- package/dist/runtime/server/api/_queues/[name]/job/index.get.js +18 -0
- package/dist/runtime/server/api/_queues/index.get.d.ts +2 -0
- package/dist/runtime/server/api/_queues/index.get.js +63 -0
- package/dist/runtime/server/api/_queues/ws.d.ts +48 -0
- package/dist/runtime/server/api/_queues/ws.js +200 -0
- package/dist/runtime/server/events/adapters/fileAdapter.d.ts +2 -0
- package/dist/runtime/server/events/adapters/fileAdapter.js +382 -0
- package/dist/runtime/server/events/adapters/memoryAdapter.d.ts +2 -0
- package/dist/runtime/server/events/adapters/memoryAdapter.js +171 -0
- package/dist/runtime/server/events/adapters/redis/redisAdapter.d.ts +2 -0
- package/dist/runtime/server/events/adapters/redis/redisAdapter.js +348 -0
- package/dist/runtime/server/events/adapters/redis/redisPubSubGateway.d.ts +29 -0
- package/dist/runtime/server/events/adapters/redis/redisPubSubGateway.js +82 -0
- package/dist/runtime/server/events/eventBus.d.ts +20 -0
- package/dist/runtime/server/events/eventBus.js +35 -0
- package/dist/runtime/server/events/eventStoreFactory.d.ts +19 -0
- package/dist/runtime/server/events/eventStoreFactory.js +44 -0
- package/dist/runtime/server/events/streamNames.d.ts +17 -0
- package/dist/runtime/server/events/streamNames.js +17 -0
- package/dist/runtime/server/events/types.d.ts +63 -0
- package/dist/runtime/server/events/types.js +0 -0
- package/dist/runtime/server/events/wiring/flowWiring.d.ts +33 -0
- package/dist/runtime/server/events/wiring/flowWiring.js +406 -0
- package/dist/runtime/server/events/wiring/registry.d.ts +10 -0
- package/dist/runtime/server/events/wiring/registry.js +24 -0
- package/dist/runtime/server/plugins/00.event-store.d.ts +13 -0
- package/dist/runtime/server/plugins/00.event-store.js +16 -0
- package/dist/runtime/server/plugins/00.ws-lifecycle.d.ts +5 -0
- package/dist/runtime/server/plugins/00.ws-lifecycle.js +66 -0
- package/dist/runtime/server/plugins/flow-management.d.ts +13 -0
- package/dist/runtime/server/plugins/flow-management.js +65 -0
- package/dist/runtime/server/plugins/queue-management.d.ts +2 -0
- package/dist/runtime/server/plugins/queue-management.js +27 -0
- package/dist/runtime/server/plugins/state-cleanup.d.ts +11 -0
- package/dist/runtime/server/plugins/state-cleanup.js +93 -0
- package/dist/runtime/server/plugins/worker-management.d.ts +2 -0
- package/dist/runtime/server/plugins/worker-management.js +33 -0
- package/dist/runtime/server/queue/adapters/bullmq.d.ts +17 -0
- package/dist/runtime/server/queue/adapters/bullmq.js +164 -0
- package/dist/runtime/server/queue/queueFactory.d.ts +3 -0
- package/dist/runtime/server/queue/queueFactory.js +10 -0
- package/dist/runtime/server/queue/types.d.ts +47 -0
- package/dist/runtime/server/queue/types.js +0 -0
- package/dist/runtime/server/state/adapters/redis.d.ts +2 -0
- package/dist/runtime/server/state/adapters/redis.js +42 -0
- package/dist/runtime/server/state/stateFactory.d.ts +3 -0
- package/dist/runtime/server/state/stateFactory.js +17 -0
- package/dist/runtime/server/state/types.d.ts +23 -0
- package/dist/runtime/server/state/types.js +0 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils/defineQueueConfig.d.ts +154 -0
- package/dist/runtime/server/utils/defineQueueConfig.js +2 -0
- package/dist/runtime/server/utils/defineQueueWorker.d.ts +10 -0
- package/dist/runtime/server/utils/defineQueueWorker.js +17 -0
- package/dist/runtime/server/utils/useEventManager.d.ts +15 -0
- package/dist/runtime/server/utils/useEventManager.js +26 -0
- package/dist/runtime/server/utils/useEventStore.d.ts +20 -0
- package/dist/runtime/server/utils/useEventStore.js +119 -0
- package/dist/runtime/server/utils/useFlowEngine.d.ts +9 -0
- package/dist/runtime/server/utils/useFlowEngine.js +44 -0
- package/dist/runtime/server/utils/useLogs.d.ts +41 -0
- package/dist/runtime/server/utils/useLogs.js +74 -0
- package/dist/runtime/server/utils/useQueue.d.ts +31 -0
- package/dist/runtime/server/utils/useQueue.js +24 -0
- package/dist/runtime/server/utils/useServerLogger.d.ts +42 -0
- package/dist/runtime/server/utils/useServerLogger.js +54 -0
- package/dist/runtime/server/utils/wsPeerManager.d.ts +34 -0
- package/dist/runtime/server/utils/wsPeerManager.js +23 -0
- package/dist/runtime/server/worker/adapter.d.ts +4 -0
- package/dist/runtime/server/worker/adapter.js +65 -0
- package/dist/runtime/server/worker/runner/node.d.ts +27 -0
- package/dist/runtime/server/worker/runner/node.js +196 -0
- package/dist/runtime/types.d.ts +132 -0
- package/dist/types.d.mts +3 -0
- package/package.json +75 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
export type FlowRole = 'entry' | 'step';
|
|
2
|
+
export interface FlowConfig {
|
|
3
|
+
/**
|
|
4
|
+
* One or more flow names this step belongs to.
|
|
5
|
+
* A single worker step can participate in multiple flows.
|
|
6
|
+
*/
|
|
7
|
+
name: string | string[];
|
|
8
|
+
/**
|
|
9
|
+
* Role of this step in the flow.
|
|
10
|
+
*/
|
|
11
|
+
role: FlowRole;
|
|
12
|
+
/**
|
|
13
|
+
* Logical step name (used as job name and event kind on start).
|
|
14
|
+
*/
|
|
15
|
+
step: string;
|
|
16
|
+
/**
|
|
17
|
+
* Event kinds this step emits (e.g., `${step}.completed`).
|
|
18
|
+
*/
|
|
19
|
+
emits?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Event kinds this step subscribes to; can be a single string or an array.
|
|
22
|
+
* The compiler normalizes this to `string[]` under `subscribes`.
|
|
23
|
+
*/
|
|
24
|
+
subscribes?: string | string[];
|
|
25
|
+
}
|
|
26
|
+
export interface QueueJobDefaults {
|
|
27
|
+
/**
|
|
28
|
+
* Number of retry attempts for failed jobs.
|
|
29
|
+
* BullMQ: attempts, PGBoss: retryLimit
|
|
30
|
+
*/
|
|
31
|
+
attempts?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Backoff strategy for retries.
|
|
34
|
+
* BullMQ: backoff, PGBoss: retryBackoff + exponentialBackoff
|
|
35
|
+
*/
|
|
36
|
+
backoff?: number | {
|
|
37
|
+
type: 'fixed' | 'exponential';
|
|
38
|
+
delay: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Delay in milliseconds before the job is processed.
|
|
42
|
+
* BullMQ: delay, PGBoss: startAfter
|
|
43
|
+
*/
|
|
44
|
+
delay?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Job priority (higher number = higher priority).
|
|
47
|
+
* BullMQ: priority, PGBoss: priority
|
|
48
|
+
*/
|
|
49
|
+
priority?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Job timeout in milliseconds.
|
|
52
|
+
* BullMQ: timeout, PGBoss: expireInSeconds (converted)
|
|
53
|
+
*/
|
|
54
|
+
timeout?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Process jobs in LIFO (Last In First Out) order.
|
|
57
|
+
* BullMQ: lifo, PGBoss: not supported
|
|
58
|
+
*/
|
|
59
|
+
lifo?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Remove job from queue when completed.
|
|
62
|
+
* BullMQ: removeOnComplete, PGBoss: deleteAfterSeconds
|
|
63
|
+
*/
|
|
64
|
+
removeOnComplete?: boolean | number;
|
|
65
|
+
/**
|
|
66
|
+
* Remove job from queue when failed.
|
|
67
|
+
* BullMQ: removeOnFail, PGBoss: deleteAfterSeconds
|
|
68
|
+
*/
|
|
69
|
+
removeOnFail?: boolean | number;
|
|
70
|
+
/**
|
|
71
|
+
* Repeatable job configuration.
|
|
72
|
+
* BullMQ: repeat, PGBoss: schedule pattern
|
|
73
|
+
*/
|
|
74
|
+
repeat?: {
|
|
75
|
+
cron?: string;
|
|
76
|
+
every?: number;
|
|
77
|
+
limit?: number;
|
|
78
|
+
tz?: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export interface QueueConfig {
|
|
82
|
+
/**
|
|
83
|
+
* Queue name. If not provided, the filename will be used.
|
|
84
|
+
*/
|
|
85
|
+
name?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Default options for jobs enqueued to this queue.
|
|
88
|
+
*/
|
|
89
|
+
defaultJobOptions?: QueueJobDefaults;
|
|
90
|
+
/**
|
|
91
|
+
* Prefix for queue keys in Redis/storage.
|
|
92
|
+
* BullMQ: prefix, PGBoss: schema
|
|
93
|
+
*/
|
|
94
|
+
prefix?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Rate limiting configuration.
|
|
97
|
+
* BullMQ: limiter, PGBoss: teamSize + teamConcurrency (partial)
|
|
98
|
+
*/
|
|
99
|
+
limiter?: {
|
|
100
|
+
/**
|
|
101
|
+
* Maximum number of jobs to process in the duration window.
|
|
102
|
+
*/
|
|
103
|
+
max?: number;
|
|
104
|
+
/**
|
|
105
|
+
* Duration of the rate limit window in milliseconds.
|
|
106
|
+
*/
|
|
107
|
+
duration?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Group key for rate limiting (optional).
|
|
110
|
+
* BullMQ only: allows per-group rate limiting
|
|
111
|
+
*/
|
|
112
|
+
groupKey?: string;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export interface WorkerConfig {
|
|
116
|
+
/**
|
|
117
|
+
* Number of jobs to process concurrently.
|
|
118
|
+
* BullMQ: concurrency, PGBoss: teamSize
|
|
119
|
+
*/
|
|
120
|
+
concurrency?: number;
|
|
121
|
+
/**
|
|
122
|
+
* Lock duration in milliseconds.
|
|
123
|
+
* BullMQ: lockDuration, PGBoss: newJobCheckInterval (similar concept)
|
|
124
|
+
*/
|
|
125
|
+
lockDurationMs?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Maximum number of times a job can be stalled before being failed.
|
|
128
|
+
* BullMQ: maxStalledCount, PGBoss: not directly supported
|
|
129
|
+
*/
|
|
130
|
+
maxStalledCount?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Delay in milliseconds before processing jobs after queue is drained.
|
|
133
|
+
* BullMQ: drainDelay, PGBoss: not directly supported
|
|
134
|
+
*/
|
|
135
|
+
drainDelayMs?: number;
|
|
136
|
+
/**
|
|
137
|
+
* Automatically run worker on startup.
|
|
138
|
+
* BullMQ: autorun, PGBoss: workers start automatically
|
|
139
|
+
*/
|
|
140
|
+
autorun?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Polling interval in milliseconds for checking new jobs.
|
|
143
|
+
* PGBoss: newJobCheckInterval, BullMQ: uses blocking wait
|
|
144
|
+
*/
|
|
145
|
+
pollingIntervalMs?: number;
|
|
146
|
+
}
|
|
147
|
+
export interface QueueWorkerConfig {
|
|
148
|
+
queue?: QueueConfig;
|
|
149
|
+
flow?: FlowConfig;
|
|
150
|
+
worker?: WorkerConfig;
|
|
151
|
+
}
|
|
152
|
+
export type DefineQueueConfig = <T extends QueueWorkerConfig>(cfg: T) => T;
|
|
153
|
+
export declare const defineQueueConfig: DefineQueueConfig;
|
|
154
|
+
export default defineQueueConfig;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useFlowEngine, useQueue } from '#imports';
|
|
2
|
+
import type { RunContext, NodeHandler } from '../worker/runner/node.js';
|
|
3
|
+
export type ExtendedRunContext = RunContext & {
|
|
4
|
+
provider: ReturnType<typeof useQueue>;
|
|
5
|
+
flow: ReturnType<typeof useFlowEngine>;
|
|
6
|
+
registry: any;
|
|
7
|
+
};
|
|
8
|
+
export type DefineQueueWorker = (handler: (input: any, ctx: ExtendedRunContext) => Promise<any>) => NodeHandler;
|
|
9
|
+
export declare const defineQueueWorker: DefineQueueWorker;
|
|
10
|
+
export default defineQueueWorker;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { $useQueueRegistry, useFlowEngine, useQueue } from "#imports";
|
|
2
|
+
export const defineQueueWorker = (handler) => {
|
|
3
|
+
const wrapped = async (input, ctx) => {
|
|
4
|
+
const provider = useQueue();
|
|
5
|
+
const flow = ctx.flow || useFlowEngine();
|
|
6
|
+
const registry = $useQueueRegistry();
|
|
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 defineQueueWorker;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getEventBus } from '../events/eventBus.js';
|
|
2
|
+
import type { EventRecord } from '../../types.js';
|
|
3
|
+
export interface EventManager {
|
|
4
|
+
/**
|
|
5
|
+
* Publish an event directly to the in-proc bus.
|
|
6
|
+
*/
|
|
7
|
+
publishBus(evt: Partial<EventRecord>): Promise<void>;
|
|
8
|
+
onType: (type: string, handler: (e: EventRecord) => void) => () => void;
|
|
9
|
+
subscribeRunId: ReturnType<typeof getEventBus>['subscribeRunId'];
|
|
10
|
+
}
|
|
11
|
+
declare global {
|
|
12
|
+
var __nq_event_manager: EventManager | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare function useEventManager(): EventManager;
|
|
15
|
+
export declare function setEventManager(mgr: EventManager): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getEventBus } from "../events/eventBus.js";
|
|
2
|
+
import { useServerLogger } from "#imports";
|
|
3
|
+
const logger = useServerLogger("event-manager");
|
|
4
|
+
export function useEventManager() {
|
|
5
|
+
if (globalThis.__nq_event_manager) return globalThis.__nq_event_manager;
|
|
6
|
+
const bus = getEventBus();
|
|
7
|
+
const publishBus = async (evt) => {
|
|
8
|
+
const rec = {
|
|
9
|
+
...evt,
|
|
10
|
+
runId: evt.runId || ""
|
|
11
|
+
};
|
|
12
|
+
bus.publish(rec);
|
|
13
|
+
logger.debug("Published event to bus", { type: rec.type, runId: rec.runId });
|
|
14
|
+
};
|
|
15
|
+
const subscribeRunId = (runId, handler) => {
|
|
16
|
+
return bus.subscribeRunId(runId, handler);
|
|
17
|
+
};
|
|
18
|
+
const onType = (type, handler) => {
|
|
19
|
+
return bus.onType(type, handler);
|
|
20
|
+
};
|
|
21
|
+
globalThis.__nq_event_manager = { publishBus, onType, subscribeRunId };
|
|
22
|
+
return globalThis.__nq_event_manager;
|
|
23
|
+
}
|
|
24
|
+
export function setEventManager(mgr) {
|
|
25
|
+
globalThis.__nq_event_manager = mgr;
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EventReadOptions } from '../events/types.js';
|
|
2
|
+
import type { EventRecord } from '../../types.js';
|
|
3
|
+
export declare function useEventStore(): {
|
|
4
|
+
names: () => import("../events/streamNames.js").StreamNames;
|
|
5
|
+
read: (stream: string, opts?: EventReadOptions) => Promise<EventRecord[]>;
|
|
6
|
+
indexAdd: (key: string, id: string, score: number, metadata?: Record<string, any>) => Promise<void>;
|
|
7
|
+
indexGet: (key: string, id: string) => Promise<import("../events/types.js").IndexEntry | null>;
|
|
8
|
+
indexUpdate: (key: string, id: string, metadata: Record<string, any>) => Promise<boolean>;
|
|
9
|
+
indexUpdateWithRetry: (key: string, id: string, metadata: Record<string, any>, maxRetries?: number) => Promise<void>;
|
|
10
|
+
indexIncrement: (key: string, id: string, field: string, increment?: number) => Promise<number>;
|
|
11
|
+
indexRead: (key: string, opts?: {
|
|
12
|
+
offset?: number;
|
|
13
|
+
limit?: number;
|
|
14
|
+
}) => Promise<import("../events/types.js").IndexEntry[]>;
|
|
15
|
+
deleteStream: (subject: string) => Promise<void>;
|
|
16
|
+
deleteByPattern: (pattern: string) => Promise<number>;
|
|
17
|
+
deleteIndex: (key: string) => Promise<void>;
|
|
18
|
+
subscribe: (stream: string, handler: (e: EventRecord) => void) => () => void;
|
|
19
|
+
adapter: import("../events/types.js").EventStoreAdapter;
|
|
20
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { getEventStoreFactory } from "../events/eventStoreFactory.js";
|
|
2
|
+
import { useServerLogger } from "#imports";
|
|
3
|
+
const logger = useServerLogger("event-store");
|
|
4
|
+
export function useEventStore() {
|
|
5
|
+
const factory = getEventStoreFactory();
|
|
6
|
+
async function read(stream, opts) {
|
|
7
|
+
return await factory.adapter.read(stream, opts);
|
|
8
|
+
}
|
|
9
|
+
async function indexAdd(key, id, score, metadata) {
|
|
10
|
+
if (!factory.adapter.indexAdd) {
|
|
11
|
+
throw new Error("Current adapter does not support indexAdd");
|
|
12
|
+
}
|
|
13
|
+
return await factory.adapter.indexAdd(key, id, score, metadata);
|
|
14
|
+
}
|
|
15
|
+
async function indexGet(key, id) {
|
|
16
|
+
if (!factory.adapter.indexGet) {
|
|
17
|
+
throw new Error("Current adapter does not support indexGet");
|
|
18
|
+
}
|
|
19
|
+
return await factory.adapter.indexGet(key, id);
|
|
20
|
+
}
|
|
21
|
+
async function indexUpdate(key, id, metadata) {
|
|
22
|
+
if (!factory.adapter.indexUpdate) {
|
|
23
|
+
throw new Error("Current adapter does not support indexUpdate");
|
|
24
|
+
}
|
|
25
|
+
return await factory.adapter.indexUpdate(key, id, metadata);
|
|
26
|
+
}
|
|
27
|
+
async function indexUpdateWithRetry(key, id, metadata, maxRetries) {
|
|
28
|
+
if (!factory.adapter.indexUpdateWithRetry) {
|
|
29
|
+
throw new Error("Current adapter does not support indexUpdateWithRetry");
|
|
30
|
+
}
|
|
31
|
+
return await factory.adapter.indexUpdateWithRetry(key, id, metadata, maxRetries);
|
|
32
|
+
}
|
|
33
|
+
async function indexIncrement(key, id, field, increment) {
|
|
34
|
+
if (!factory.adapter.indexIncrement) {
|
|
35
|
+
throw new Error("Current adapter does not support indexIncrement");
|
|
36
|
+
}
|
|
37
|
+
return await factory.adapter.indexIncrement(key, id, field, increment);
|
|
38
|
+
}
|
|
39
|
+
async function indexRead(key, opts) {
|
|
40
|
+
if (!factory.adapter.indexRead) {
|
|
41
|
+
throw new Error("Current adapter does not support indexRead");
|
|
42
|
+
}
|
|
43
|
+
return await factory.adapter.indexRead(key, opts);
|
|
44
|
+
}
|
|
45
|
+
async function deleteStream(subject) {
|
|
46
|
+
if (!factory.adapter.deleteStream) {
|
|
47
|
+
throw new Error("Current adapter does not support deleteStream");
|
|
48
|
+
}
|
|
49
|
+
return await factory.adapter.deleteStream(subject);
|
|
50
|
+
}
|
|
51
|
+
async function deleteByPattern(pattern) {
|
|
52
|
+
if (!factory.adapter.deleteByPattern) {
|
|
53
|
+
throw new Error("Current adapter does not support deleteByPattern");
|
|
54
|
+
}
|
|
55
|
+
return await factory.adapter.deleteByPattern(pattern);
|
|
56
|
+
}
|
|
57
|
+
async function deleteIndex(key) {
|
|
58
|
+
if (!factory.adapter.deleteIndex) {
|
|
59
|
+
throw new Error("Current adapter does not support deleteIndex");
|
|
60
|
+
}
|
|
61
|
+
return await factory.adapter.deleteIndex(key);
|
|
62
|
+
}
|
|
63
|
+
function names() {
|
|
64
|
+
return factory.names;
|
|
65
|
+
}
|
|
66
|
+
function subscribe(stream, handler) {
|
|
67
|
+
logger.debug("Subscribing to stream", { stream });
|
|
68
|
+
let sub = null;
|
|
69
|
+
let active = true;
|
|
70
|
+
(async () => {
|
|
71
|
+
try {
|
|
72
|
+
sub = await factory.adapter.subscribe(stream, (e) => {
|
|
73
|
+
logger.debug("Event received", { stream, id: e?.id, type: e?.type });
|
|
74
|
+
handler(e);
|
|
75
|
+
});
|
|
76
|
+
logger.debug("Subscription active", { stream });
|
|
77
|
+
} catch (err) {
|
|
78
|
+
logger.error("Subscription error", { stream, error: err });
|
|
79
|
+
}
|
|
80
|
+
if (!active && sub) {
|
|
81
|
+
try {
|
|
82
|
+
sub.unsubscribe();
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})();
|
|
87
|
+
return () => {
|
|
88
|
+
active = false;
|
|
89
|
+
if (sub) {
|
|
90
|
+
try {
|
|
91
|
+
sub.unsubscribe();
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
sub = null;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
// names
|
|
100
|
+
names,
|
|
101
|
+
// read from canonical streams
|
|
102
|
+
read,
|
|
103
|
+
// sorted set index operations
|
|
104
|
+
indexAdd,
|
|
105
|
+
indexGet,
|
|
106
|
+
indexUpdate,
|
|
107
|
+
indexUpdateWithRetry,
|
|
108
|
+
indexIncrement,
|
|
109
|
+
indexRead,
|
|
110
|
+
// deletion operations
|
|
111
|
+
deleteStream,
|
|
112
|
+
deleteByPattern,
|
|
113
|
+
deleteIndex,
|
|
114
|
+
// subscribe to canonical stream events via the adapter (Store Bus)
|
|
115
|
+
subscribe,
|
|
116
|
+
// expose adapter if advanced usage is needed
|
|
117
|
+
adapter: factory.adapter
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const useFlowEngine: () => {
|
|
2
|
+
startFlow: (flowName: string, payload?: any) => Promise<{
|
|
3
|
+
id: any;
|
|
4
|
+
queue: any;
|
|
5
|
+
step: any;
|
|
6
|
+
flowId: `${string}-${string}-${string}-${string}-${string}`;
|
|
7
|
+
}>;
|
|
8
|
+
emit: (trigger: string, payload?: any) => Promise<never[]>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { $useQueueRegistry, useQueue, useEventManager, useServerLogger } from "#imports";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
const logger = useServerLogger("flow-engine");
|
|
4
|
+
export const useFlowEngine = () => {
|
|
5
|
+
const registry = $useQueueRegistry();
|
|
6
|
+
const queueAdapter = useQueue();
|
|
7
|
+
const eventsManager = useEventManager();
|
|
8
|
+
const startFlow = async (flowName, payload = {}) => {
|
|
9
|
+
const flow = registry?.flows?.[flowName];
|
|
10
|
+
if (!flow || !flow.entry) throw new Error("Flow not found");
|
|
11
|
+
const queueName = typeof flow.entry.queue === "string" ? flow.entry.queue : flow.entry.queue?.name || flow.entry.queue;
|
|
12
|
+
const flowId = randomUUID();
|
|
13
|
+
const id = await queueAdapter.enqueue(queueName, { name: flow.entry.step, data: { ...payload, flowId, flowName } });
|
|
14
|
+
try {
|
|
15
|
+
await eventsManager.publishBus({ type: "flow.start", runId: flowId, flowName, data: { input: payload } });
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
return { id, queue: queueName, step: flow.entry.step, flowId };
|
|
19
|
+
};
|
|
20
|
+
const emit = async (trigger, payload = {}) => {
|
|
21
|
+
const flowId = payload?.flowId;
|
|
22
|
+
const flowName = payload?.flowName || "unknown";
|
|
23
|
+
if (!flowId) {
|
|
24
|
+
logger.warn("emit called without flowId, trigger may not work", { trigger });
|
|
25
|
+
}
|
|
26
|
+
const { flowId: _, flowName: __, ...actualPayload } = payload;
|
|
27
|
+
try {
|
|
28
|
+
await eventsManager.publishBus({
|
|
29
|
+
type: "emit",
|
|
30
|
+
runId: flowId || "unknown",
|
|
31
|
+
flowName,
|
|
32
|
+
data: {
|
|
33
|
+
name: trigger,
|
|
34
|
+
payload: actualPayload
|
|
35
|
+
// Store actual payload separately
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
} catch (err) {
|
|
39
|
+
logger.error("Failed to emit trigger event", { trigger, error: err });
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
};
|
|
43
|
+
return { startFlow, emit };
|
|
44
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface LogReadOptions {
|
|
2
|
+
fromId?: string;
|
|
3
|
+
limit?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function useLogs(): {
|
|
6
|
+
getJobLogs: (_jobId: string, _opts?: {
|
|
7
|
+
limit?: number;
|
|
8
|
+
fromId?: string;
|
|
9
|
+
direction?: "forward" | "backward";
|
|
10
|
+
paged?: boolean;
|
|
11
|
+
}) => Promise<any>;
|
|
12
|
+
getFlowRunLogs: (flowId: string, opts?: {
|
|
13
|
+
limit?: number;
|
|
14
|
+
fromId?: string;
|
|
15
|
+
direction?: "forward" | "backward";
|
|
16
|
+
paged?: boolean;
|
|
17
|
+
}) => Promise<any>;
|
|
18
|
+
publishLog: (level: "debug" | "info" | "warn" | "error", msg: string, meta?: any, ctx?: {
|
|
19
|
+
queue?: string;
|
|
20
|
+
jobId?: string;
|
|
21
|
+
flowId?: string;
|
|
22
|
+
}) => Promise<void>;
|
|
23
|
+
onLog: (handler: (e: {
|
|
24
|
+
level: "debug" | "info" | "warn" | "error";
|
|
25
|
+
msg: string;
|
|
26
|
+
meta?: any;
|
|
27
|
+
raw: any;
|
|
28
|
+
}) => void) => any;
|
|
29
|
+
onJobLog: (_jobId: string, _handler: (e: {
|
|
30
|
+
level: "debug" | "info" | "warn" | "error";
|
|
31
|
+
msg: string;
|
|
32
|
+
meta?: any;
|
|
33
|
+
raw: any;
|
|
34
|
+
}) => void) => () => void;
|
|
35
|
+
onFlowLog: (flowId: string, handler: (e: {
|
|
36
|
+
level: "debug" | "info" | "warn" | "error";
|
|
37
|
+
msg: string;
|
|
38
|
+
meta?: any;
|
|
39
|
+
raw: any;
|
|
40
|
+
}) => void) => any;
|
|
41
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useEventManager, useEventStore } from "#imports";
|
|
2
|
+
export function useLogs() {
|
|
3
|
+
const eventManager = useEventManager();
|
|
4
|
+
const store = useEventStore();
|
|
5
|
+
const names = store.names();
|
|
6
|
+
async function getJobLogs(_jobId, _opts) {
|
|
7
|
+
return { items: [], nextFromId: void 0 };
|
|
8
|
+
}
|
|
9
|
+
async function getFlowRunLogs(flowId, opts) {
|
|
10
|
+
const s = names.flow(flowId);
|
|
11
|
+
const limit = opts?.limit ?? 200;
|
|
12
|
+
const direction = opts?.direction || "backward";
|
|
13
|
+
if (opts?.paged) {
|
|
14
|
+
const page2 = await store.read(s, { limit: limit * 5, fromId: opts?.fromId, direction });
|
|
15
|
+
const filtered = page2.filter((r) => r?.kind === "runner.log");
|
|
16
|
+
const items = filtered.slice(0, limit);
|
|
17
|
+
const nextFromId = page2.length >= limit * 5 ? page2[page2.length - 1]?.id : void 0;
|
|
18
|
+
return { items, nextFromId };
|
|
19
|
+
}
|
|
20
|
+
const page = await store.read(s, { limit, fromId: opts?.fromId, direction });
|
|
21
|
+
return page.filter((r) => r?.kind === "runner.log").slice(0, limit);
|
|
22
|
+
}
|
|
23
|
+
async function publishLog(level, msg, meta, ctx) {
|
|
24
|
+
const reserved = /* @__PURE__ */ new Set(["flowId", "flowName", "stepName", "stepRunId", "stepId", "attempt", "jobId", "queue", "tags"]);
|
|
25
|
+
const envMeta = {};
|
|
26
|
+
const dataMeta = {};
|
|
27
|
+
const src = meta || {};
|
|
28
|
+
for (const k of Object.keys(src)) {
|
|
29
|
+
if (reserved.has(k)) envMeta[k] = src[k];
|
|
30
|
+
else dataMeta[k] = src[k];
|
|
31
|
+
}
|
|
32
|
+
if (ctx?.flowId && envMeta.flowId == null) envMeta.flowId = ctx.flowId;
|
|
33
|
+
const runId = ctx?.flowId || "unknown";
|
|
34
|
+
const flowName = envMeta.flowName || "unknown";
|
|
35
|
+
const stepName = envMeta.stepName;
|
|
36
|
+
const stepId = envMeta.stepId || envMeta.stepRunId;
|
|
37
|
+
const attempt = envMeta.attempt;
|
|
38
|
+
await eventManager.publishBus({
|
|
39
|
+
type: "log",
|
|
40
|
+
runId,
|
|
41
|
+
flowName,
|
|
42
|
+
stepName,
|
|
43
|
+
stepId,
|
|
44
|
+
attempt,
|
|
45
|
+
data: { level, message: msg, ...dataMeta }
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function onLog(handler) {
|
|
49
|
+
return eventManager.onType("log", (evt) => {
|
|
50
|
+
const d = evt?.data || {};
|
|
51
|
+
handler({ level: d.level, msg: d.message || d.msg, meta: d.meta, raw: evt });
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function onJobLog(_jobId, _handler) {
|
|
55
|
+
return () => {
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function onFlowLog(flowId, handler) {
|
|
59
|
+
const s = names.flow(flowId);
|
|
60
|
+
return store.subscribe(s, (evt) => {
|
|
61
|
+
if (evt?.kind !== "runner.log") return;
|
|
62
|
+
const d = evt?.data || {};
|
|
63
|
+
handler({ level: d.level, msg: d.msg, meta: d.meta, raw: evt });
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
getJobLogs,
|
|
68
|
+
getFlowRunLogs,
|
|
69
|
+
publishLog,
|
|
70
|
+
onLog,
|
|
71
|
+
onJobLog,
|
|
72
|
+
onFlowLog
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ConsolaInstance } from 'consola';
|
|
2
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
3
|
+
export interface ServerLogger {
|
|
4
|
+
debug: (message: string, context?: any) => void;
|
|
5
|
+
info: (message: string, context?: any) => void;
|
|
6
|
+
warn: (message: string, context?: any) => void;
|
|
7
|
+
error: (message: string, context?: any) => void;
|
|
8
|
+
log: (level: LogLevel, message: string, context?: any) => void;
|
|
9
|
+
isEnabled: (level: LogLevel) => boolean;
|
|
10
|
+
consola: ConsolaInstance;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a contextual server logger with configurable log levels
|
|
14
|
+
* Uses consola for beautiful, styled console output with colors and icons
|
|
15
|
+
*
|
|
16
|
+
* Configuration via runtime config or environment variables:
|
|
17
|
+
* - queue.debug.level: 'debug' | 'info' | 'warn' | 'error' | 'silent'
|
|
18
|
+
* - queue.debug.<scope>: boolean (enables debug logging for specific scope)
|
|
19
|
+
* - NQ_DEBUG_LEVEL: environment variable override
|
|
20
|
+
* - NQ_DEBUG_<SCOPE>: environment variable for scope (e.g., NQ_DEBUG_FLOW_WIRING=1)
|
|
21
|
+
*
|
|
22
|
+
* @param scope - Logger scope/namespace (e.g., 'flow-wiring', 'event-manager')
|
|
23
|
+
* @returns ServerLogger instance with scoped logging methods
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const logger = useServerLogger('flow-wiring')
|
|
28
|
+
* logger.debug('Step triggered', { stepName: 'process', runId: '123' })
|
|
29
|
+
* logger.info('Flow completed', { flowName: 'example' })
|
|
30
|
+
* logger.warn('Retry attempt', { attempt: 3 })
|
|
31
|
+
* logger.error('Processing failed', { error: err.message })
|
|
32
|
+
*
|
|
33
|
+
* // Access consola instance for advanced features
|
|
34
|
+
* logger.consola.success('All steps completed!')
|
|
35
|
+
* logger.consola.box('🚀 Flow Started')
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function useServerLogger(scope: string): ServerLogger;
|
|
39
|
+
/**
|
|
40
|
+
* Type guard to check if debug logging is enabled for any scope
|
|
41
|
+
*/
|
|
42
|
+
export declare function isDebugEnabled(): boolean;
|