nvent 0.5.15 → 1.0.0-alpha.2

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.
Files changed (149) hide show
  1. package/dist/module.d.mts +181 -8
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +1257 -1196
  4. package/dist/runtime/app/composables/useFunctionCall.d.ts +17 -0
  5. package/dist/runtime/app/composables/useFunctionCall.js +25 -0
  6. package/dist/runtime/app/composables/useNventStream.d.ts +23 -0
  7. package/dist/runtime/app/composables/useNventStream.js +58 -0
  8. package/dist/runtime/nitro/plugins/00.iii-lifecycle.d.ts +19 -0
  9. package/dist/runtime/nitro/plugins/00.iii-lifecycle.js +62 -0
  10. package/dist/runtime/nitro/plugins/01.iii-worker.d.ts +15 -0
  11. package/dist/runtime/nitro/plugins/01.iii-worker.js +91 -0
  12. package/dist/runtime/nitro/routes/stream-proxy.d.ts +17 -0
  13. package/dist/runtime/nitro/routes/stream-proxy.js +45 -0
  14. package/dist/runtime/nitro/utils/console.d.ts +32 -0
  15. package/dist/runtime/nitro/utils/console.js +95 -0
  16. package/dist/runtime/nitro/utils/defineFunction.d.ts +378 -3
  17. package/dist/runtime/nitro/utils/defineFunction.js +224 -4
  18. package/dist/runtime/nitro/utils/engine.d.ts +25 -0
  19. package/dist/runtime/nitro/utils/engine.js +130 -0
  20. package/dist/runtime/nitro/utils/nventDir.d.ts +1 -0
  21. package/dist/runtime/nitro/utils/nventDir.js +20 -0
  22. package/dist/runtime/nitro/utils/useIii.d.ts +23 -0
  23. package/dist/runtime/nitro/utils/useIii.js +14 -0
  24. package/dist/runtime/nitro/utils/workers/node.d.ts +24 -0
  25. package/dist/runtime/nitro/utils/workers/node.js +57 -0
  26. package/dist/runtime/nitro/utils/workers/python.d.ts +67 -0
  27. package/dist/runtime/nitro/utils/workers/python.js +220 -0
  28. package/dist/runtime/python/nvent.py +208 -0
  29. package/dist/runtime/python/worker_runtime.py +659 -0
  30. package/dist/runtime/virtual.d.ts +17 -0
  31. package/dist/types.d.mts +5 -1
  32. package/package.json +11 -14
  33. package/dist/runtime/adapters/base/index.d.ts +0 -6
  34. package/dist/runtime/adapters/base/index.js +0 -1
  35. package/dist/runtime/adapters/base/store-validator.d.ts +0 -48
  36. package/dist/runtime/adapters/base/store-validator.js +0 -147
  37. package/dist/runtime/adapters/builtin/file-queue.d.ts +0 -67
  38. package/dist/runtime/adapters/builtin/file-queue.js +0 -499
  39. package/dist/runtime/adapters/builtin/file-store.d.ts +0 -32
  40. package/dist/runtime/adapters/builtin/file-store.js +0 -206
  41. package/dist/runtime/adapters/builtin/file-stream.d.ts +0 -39
  42. package/dist/runtime/adapters/builtin/file-stream.js +0 -56
  43. package/dist/runtime/adapters/builtin/index.d.ts +0 -10
  44. package/dist/runtime/adapters/builtin/index.js +0 -5
  45. package/dist/runtime/adapters/builtin/memory-queue.d.ts +0 -52
  46. package/dist/runtime/adapters/builtin/memory-queue.js +0 -243
  47. package/dist/runtime/adapters/builtin/memory-store.d.ts +0 -69
  48. package/dist/runtime/adapters/builtin/memory-store.js +0 -357
  49. package/dist/runtime/adapters/builtin/memory-stream.d.ts +0 -21
  50. package/dist/runtime/adapters/builtin/memory-stream.js +0 -56
  51. package/dist/runtime/adapters/factory.d.ts +0 -31
  52. package/dist/runtime/adapters/factory.js +0 -135
  53. package/dist/runtime/adapters/index.d.ts +0 -8
  54. package/dist/runtime/adapters/index.js +0 -3
  55. package/dist/runtime/adapters/interfaces/index.d.ts +0 -11
  56. package/dist/runtime/adapters/interfaces/index.js +0 -3
  57. package/dist/runtime/adapters/interfaces/queue.d.ts +0 -155
  58. package/dist/runtime/adapters/interfaces/queue.js +0 -0
  59. package/dist/runtime/adapters/interfaces/store.d.ts +0 -299
  60. package/dist/runtime/adapters/interfaces/store.js +0 -0
  61. package/dist/runtime/adapters/interfaces/stream.d.ts +0 -62
  62. package/dist/runtime/adapters/interfaces/stream.js +0 -0
  63. package/dist/runtime/adapters/registry.d.ts +0 -85
  64. package/dist/runtime/adapters/registry.js +0 -161
  65. package/dist/runtime/config/index.d.ts +0 -23
  66. package/dist/runtime/config/index.js +0 -200
  67. package/dist/runtime/config/types.d.ts +0 -439
  68. package/dist/runtime/config/types.js +0 -0
  69. package/dist/runtime/events/eventBus.d.ts +0 -20
  70. package/dist/runtime/events/eventBus.js +0 -35
  71. package/dist/runtime/events/types.d.ts +0 -144
  72. package/dist/runtime/events/types.js +0 -0
  73. package/dist/runtime/events/utils/scheduleTrigger.d.ts +0 -8
  74. package/dist/runtime/events/utils/scheduleTrigger.js +0 -71
  75. package/dist/runtime/events/utils/stallDetector.d.ts +0 -83
  76. package/dist/runtime/events/utils/stallDetector.js +0 -318
  77. package/dist/runtime/events/utils/triggerRuntime.d.ts +0 -58
  78. package/dist/runtime/events/utils/triggerRuntime.js +0 -212
  79. package/dist/runtime/events/wiring/flowWiring.d.ts +0 -34
  80. package/dist/runtime/events/wiring/flowWiring.js +0 -1258
  81. package/dist/runtime/events/wiring/registry.d.ts +0 -19
  82. package/dist/runtime/events/wiring/registry.js +0 -43
  83. package/dist/runtime/events/wiring/stateWiring.d.ts +0 -37
  84. package/dist/runtime/events/wiring/stateWiring.js +0 -92
  85. package/dist/runtime/events/wiring/streamWiring.d.ts +0 -36
  86. package/dist/runtime/events/wiring/streamWiring.js +0 -156
  87. package/dist/runtime/events/wiring/triggerWiring.d.ts +0 -21
  88. package/dist/runtime/events/wiring/triggerWiring.js +0 -422
  89. package/dist/runtime/nitro/plugins/00.adapters.d.ts +0 -14
  90. package/dist/runtime/nitro/plugins/00.adapters.js +0 -73
  91. package/dist/runtime/nitro/plugins/01.ws-lifecycle.d.ts +0 -5
  92. package/dist/runtime/nitro/plugins/01.ws-lifecycle.js +0 -69
  93. package/dist/runtime/nitro/plugins/02.workers.d.ts +0 -2
  94. package/dist/runtime/nitro/plugins/02.workers.js +0 -92
  95. package/dist/runtime/nitro/plugins/03.triggers.d.ts +0 -12
  96. package/dist/runtime/nitro/plugins/03.triggers.js +0 -55
  97. package/dist/runtime/nitro/routes/webhook.await.d.ts +0 -23
  98. package/dist/runtime/nitro/routes/webhook.await.js +0 -112
  99. package/dist/runtime/nitro/routes/webhook.trigger.d.ts +0 -86
  100. package/dist/runtime/nitro/routes/webhook.trigger.js +0 -73
  101. package/dist/runtime/nitro/utils/adapters.d.ts +0 -66
  102. package/dist/runtime/nitro/utils/adapters.js +0 -51
  103. package/dist/runtime/nitro/utils/awaitPatterns/event.d.ts +0 -15
  104. package/dist/runtime/nitro/utils/awaitPatterns/event.js +0 -128
  105. package/dist/runtime/nitro/utils/awaitPatterns/index.d.ts +0 -28
  106. package/dist/runtime/nitro/utils/awaitPatterns/index.js +0 -55
  107. package/dist/runtime/nitro/utils/awaitPatterns/schedule.d.ts +0 -16
  108. package/dist/runtime/nitro/utils/awaitPatterns/schedule.js +0 -83
  109. package/dist/runtime/nitro/utils/awaitPatterns/time.d.ts +0 -15
  110. package/dist/runtime/nitro/utils/awaitPatterns/time.js +0 -71
  111. package/dist/runtime/nitro/utils/awaitPatterns/webhook.d.ts +0 -15
  112. package/dist/runtime/nitro/utils/awaitPatterns/webhook.js +0 -128
  113. package/dist/runtime/nitro/utils/defineFunctionConfig.d.ts +0 -378
  114. package/dist/runtime/nitro/utils/defineFunctionConfig.js +0 -3
  115. package/dist/runtime/nitro/utils/defineHooks.d.ts +0 -95
  116. package/dist/runtime/nitro/utils/defineHooks.js +0 -9
  117. package/dist/runtime/nitro/utils/registerAdapter.d.ts +0 -59
  118. package/dist/runtime/nitro/utils/registerAdapter.js +0 -13
  119. package/dist/runtime/nitro/utils/useAwait.d.ts +0 -83
  120. package/dist/runtime/nitro/utils/useAwait.js +0 -169
  121. package/dist/runtime/nitro/utils/useEventManager.d.ts +0 -15
  122. package/dist/runtime/nitro/utils/useEventManager.js +0 -26
  123. package/dist/runtime/nitro/utils/useFlow.d.ts +0 -66
  124. package/dist/runtime/nitro/utils/useFlow.js +0 -310
  125. package/dist/runtime/nitro/utils/useHookRegistry.d.ts +0 -40
  126. package/dist/runtime/nitro/utils/useHookRegistry.js +0 -25
  127. package/dist/runtime/nitro/utils/useNventLogger.d.ts +0 -42
  128. package/dist/runtime/nitro/utils/useNventLogger.js +0 -54
  129. package/dist/runtime/nitro/utils/useRunContext.d.ts +0 -6
  130. package/dist/runtime/nitro/utils/useRunContext.js +0 -102
  131. package/dist/runtime/nitro/utils/useStreamTopics.d.ts +0 -83
  132. package/dist/runtime/nitro/utils/useStreamTopics.js +0 -94
  133. package/dist/runtime/nitro/utils/useTrigger.d.ts +0 -150
  134. package/dist/runtime/nitro/utils/useTrigger.js +0 -311
  135. package/dist/runtime/nitro/utils/wsPeerManager.d.ts +0 -44
  136. package/dist/runtime/nitro/utils/wsPeerManager.js +0 -32
  137. package/dist/runtime/scheduler/index.d.ts +0 -33
  138. package/dist/runtime/scheduler/index.js +0 -42
  139. package/dist/runtime/scheduler/scheduler.d.ts +0 -132
  140. package/dist/runtime/scheduler/scheduler.js +0 -799
  141. package/dist/runtime/scheduler/types.d.ts +0 -122
  142. package/dist/runtime/scheduler/types.js +0 -0
  143. package/dist/runtime/worker/node/runner.d.ts +0 -95
  144. package/dist/runtime/worker/node/runner.js +0 -272
  145. package/dist/runtime/worker/python/get_config.py +0 -64
  146. package/dist/runtime/worker/system/awaitHandlers.d.ts +0 -27
  147. package/dist/runtime/worker/system/awaitHandlers.js +0 -230
  148. package/dist/runtime/worker/system/index.d.ts +0 -24
  149. package/dist/runtime/worker/system/index.js +0 -39
@@ -1,439 +0,0 @@
1
- /**
2
- * Redis connection configuration
3
- */
4
- export interface RedisConfig {
5
- host?: string;
6
- port?: number;
7
- username?: string;
8
- password?: string;
9
- db?: number;
10
- url?: string;
11
- }
12
- /**
13
- * PostgreSQL connection configuration
14
- */
15
- export interface PostgresConfig {
16
- connectionString?: string;
17
- host?: string;
18
- port?: number;
19
- database?: string;
20
- user?: string;
21
- password?: string;
22
- ssl?: boolean | object;
23
- }
24
- /**
25
- * RabbitMQ connection configuration
26
- */
27
- export interface RabbitMQConfig {
28
- url?: string;
29
- host?: string;
30
- port?: number;
31
- username?: string;
32
- password?: string;
33
- vhost?: string;
34
- }
35
- /**
36
- * Kafka connection configuration
37
- */
38
- export interface KafkaConfig {
39
- brokers?: string[];
40
- clientId?: string;
41
- groupId?: string;
42
- }
43
- /**
44
- * File storage configuration
45
- */
46
- export interface FileConfig {
47
- /**
48
- * Base directory for file storage
49
- * @default '.data'
50
- */
51
- dataDir?: string;
52
- }
53
- /**
54
- * Shared connection configurations (v0.4.1)
55
- * Provides fallback connections for all adapters
56
- */
57
- export interface ConnectionsConfig {
58
- /**
59
- * Shared Redis connection - used by adapters that specify 'redis' but don't provide connection details
60
- */
61
- redis?: RedisConfig;
62
- /**
63
- * Shared Postgres connection - used by adapters that specify 'postgres' but don't provide connection details
64
- */
65
- postgres?: PostgresConfig;
66
- /**
67
- * Shared RabbitMQ connection - used by stream adapter when 'rabbitmq' is specified
68
- */
69
- rabbitmq?: RabbitMQConfig;
70
- /**
71
- * Shared Kafka connection - used by stream adapter when 'kafka' is specified
72
- */
73
- kafka?: KafkaConfig;
74
- /**
75
- * Shared file storage configuration - used by file adapters
76
- */
77
- file?: FileConfig;
78
- }
79
- /**
80
- * Worker configuration
81
- */
82
- export interface WorkerConfig {
83
- /**
84
- * Number of concurrent jobs to process
85
- * @default 2
86
- */
87
- concurrency?: number;
88
- /**
89
- * Lock duration for jobs in milliseconds
90
- */
91
- lockDurationMs?: number;
92
- /**
93
- * Maximum number of times a job can be stalled before failing
94
- */
95
- maxStalledCount?: number;
96
- /**
97
- * Delay before draining the queue on shutdown
98
- */
99
- drainDelayMs?: number;
100
- /**
101
- * Automatically start workers
102
- * @default true
103
- */
104
- autorun?: boolean;
105
- /**
106
- * Polling interval for file adapter (milliseconds)
107
- * @default 1000
108
- */
109
- pollingIntervalMs?: number;
110
- }
111
- /**
112
- * Queue adapter configuration (v0.4.1)
113
- */
114
- export interface QueueConfig {
115
- /**
116
- * Queue backend adapter
117
- * @default 'file'
118
- */
119
- adapter?: 'memory' | 'file' | 'redis' | 'postgres';
120
- /**
121
- * Redis connection (overrides connections.redis if specified)
122
- */
123
- redis?: RedisConfig;
124
- /**
125
- * Postgres connection (overrides connections.postgres if specified)
126
- */
127
- postgres?: PostgresConfig;
128
- /**
129
- * File storage configuration (overrides connections.file if specified)
130
- */
131
- file?: FileConfig;
132
- /**
133
- * Queue-specific options (BullMQ/PGBoss configuration)
134
- */
135
- prefix?: string;
136
- /**
137
- * PostgreSQL schema name for pg-boss tables
138
- * Only applies when adapter is 'postgres'
139
- * @default 'pgboss'
140
- */
141
- schema?: string;
142
- defaultJobOptions?: {
143
- attempts?: number;
144
- backoff?: number | {
145
- type: 'fixed' | 'exponential';
146
- delay: number;
147
- };
148
- delay?: number;
149
- priority?: number;
150
- timeout?: number;
151
- lifo?: boolean;
152
- removeOnComplete?: boolean | number;
153
- removeOnFail?: boolean | number;
154
- };
155
- limiter?: {
156
- max?: number;
157
- duration?: number;
158
- groupKey?: string;
159
- };
160
- /**
161
- * Worker configuration
162
- */
163
- worker?: WorkerConfig;
164
- }
165
- /**
166
- * Stream adapter configuration (v0.4.1)
167
- * Cross-instance pub/sub messaging
168
- */
169
- export interface StreamConfig {
170
- /**
171
- * Stream adapter
172
- * @default 'memory'
173
- */
174
- adapter?: 'memory' | 'redis' | 'rabbitmq' | 'kafka';
175
- /**
176
- * Redis connection (overrides connections.redis if specified)
177
- */
178
- redis?: RedisConfig;
179
- /**
180
- * Postgres connection (overrides connections.postgres if specified)
181
- */
182
- postgres?: PostgresConfig;
183
- /**
184
- * RabbitMQ connection (overrides connections.rabbitmq if specified)
185
- */
186
- rabbitmq?: RabbitMQConfig;
187
- /**
188
- * Kafka connection (overrides connections.kafka if specified)
189
- */
190
- kafka?: KafkaConfig;
191
- /**
192
- * Stream-specific options
193
- */
194
- prefix?: string;
195
- retryAttempts?: number;
196
- retryDelay?: number;
197
- }
198
- /**
199
- * Webhooks configuration
200
- */
201
- export interface WebhooksConfig {
202
- /**
203
- * Base URL for webhook endpoints
204
- * Auto-detected from Nitro context in development
205
- * Set explicitly for production or to override auto-detection
206
- * @default Auto-detected from NUXT_PUBLIC_SITE_URL, NITRO_URL, or dev server (http://localhost:3000 fallback)
207
- */
208
- baseUrl?: string;
209
- }
210
- /**
211
- * Flow configuration
212
- */
213
- export interface FlowConfig {
214
- /**
215
- * Stall detection configuration
216
- * Detects and marks flows that have been running without activity for too long
217
- */
218
- stallDetection?: {
219
- /**
220
- * Enable stall detection
221
- * @default true
222
- */
223
- enabled?: boolean;
224
- /**
225
- * Time in milliseconds after which a running flow without activity is considered stalled
226
- * @default 1800000 (30 minutes)
227
- */
228
- stallTimeout?: number;
229
- /**
230
- * Interval in milliseconds for periodic stall checks
231
- * @default 900000 (15 minutes)
232
- */
233
- checkInterval?: number;
234
- /**
235
- * Enable periodic background checks
236
- * Set to false to use only lazy detection (when flows are queried)
237
- * @default true
238
- */
239
- enablePeriodicCheck?: boolean;
240
- };
241
- /**
242
- * Default timeout values for await patterns
243
- * These are used when developers don't specify explicit timeouts
244
- * @since v0.5.0
245
- */
246
- awaitDefaults?: {
247
- /**
248
- * Default timeout for webhook await patterns in milliseconds
249
- * @default 86400000 (24 hours)
250
- */
251
- webhookTimeout?: number;
252
- /**
253
- * Default timeout for event await patterns in milliseconds
254
- * @default 86400000 (24 hours)
255
- */
256
- eventTimeout?: number;
257
- /**
258
- * Default timeout for time await patterns in milliseconds
259
- * Time awaits typically don't need a timeout since they resolve based on delay
260
- * @default undefined (no timeout)
261
- */
262
- timeTimeout?: number;
263
- /**
264
- * Default timeout for schedule await patterns in milliseconds
265
- * Schedule awaits typically don't need a timeout since they resolve based on cron
266
- * @default undefined (no timeout)
267
- */
268
- scheduleTimeout?: number;
269
- /**
270
- * Default timeout action when await times out
271
- * @default 'fail'
272
- */
273
- timeoutAction?: 'fail' | 'continue' | 'retry';
274
- };
275
- /**
276
- * Default step execution timeout in milliseconds
277
- * This is the maximum time a step function can run before timing out
278
- * Priority: defineFunctionConfig > flow.stepTimeout > queue.defaultJobOptions.timeout
279
- * @default 300000 (5 minutes)
280
- * @since v0.5.0
281
- */
282
- stepTimeout?: number;
283
- }
284
- /**
285
- * State management configuration
286
- */
287
- export interface StateManagementConfig {
288
- /**
289
- * Automatic scope/flow ID assignment for state operations
290
- * - 'always': Always create a new flow ID (recommended for most cases)
291
- * - 'flow': Only use flow ID if provided in context
292
- * - 'never': Never scope state to flow IDs
293
- * @default 'always'
294
- */
295
- autoScope?: 'always' | 'flow' | 'never';
296
- /**
297
- * State cleanup strategy
298
- */
299
- cleanup?: {
300
- /**
301
- * Cleanup strategy
302
- * - 'never': State persists indefinitely
303
- * - 'immediate': Cleanup after each step (not recommended)
304
- * - 'on-complete': Cleanup when flow completes (recommended)
305
- * - 'ttl': Automatic expiration via TTL
306
- * @default 'never'
307
- */
308
- strategy?: 'never' | 'immediate' | 'on-complete' | 'ttl';
309
- /**
310
- * TTL in milliseconds for 'ttl' strategy
311
- * @default 3600000 (1 hour)
312
- */
313
- ttlMs?: number;
314
- };
315
- }
316
- /**
317
- * Store adapter configuration (v0.4.1)
318
- * Three-tier storage: events (NDJSON), documents (JSON), KV (JSON), indices (JSON)
319
- * Replaces both state and eventStore configs from v0.4.0
320
- */
321
- export interface StoreConfig {
322
- /**
323
- * Store adapter
324
- * @default 'file'
325
- */
326
- adapter?: 'memory' | 'file' | 'redis' | 'postgres';
327
- /**
328
- * Redis connection (overrides connections.redis if specified)
329
- */
330
- redis?: RedisConfig;
331
- /**
332
- * Postgres connection (overrides connections.postgres if specified)
333
- */
334
- postgres?: PostgresConfig;
335
- /**
336
- * File storage configuration (overrides connections.file if specified)
337
- */
338
- file?: FileConfig;
339
- /**
340
- * Key prefix/namespace for all store operations
341
- * @default 'nq'
342
- */
343
- prefix?: string;
344
- /**
345
- * PostgreSQL schema name for store tables
346
- * Only applies when adapter is 'postgres'
347
- * @default 'public'
348
- */
349
- schema?: string;
350
- /**
351
- * State management configuration (KV store behavior)
352
- */
353
- state?: StateManagementConfig;
354
- /**
355
- * Event stream TTL in seconds
356
- * @default 604800 (7 days)
357
- */
358
- eventTTL?: number;
359
- /**
360
- * Metadata document TTL in seconds
361
- * @default 2592000 (30 days)
362
- */
363
- metadataTTL?: number;
364
- /**
365
- * KV store TTL in seconds
366
- */
367
- kvTTL?: number;
368
- /**
369
- * Index TTL in seconds
370
- */
371
- indexTTL?: number;
372
- /**
373
- * Enable compression for stored data
374
- */
375
- compression?: boolean;
376
- }
377
- /**
378
- * Module options for nvent (v0.4.1+)
379
- */
380
- export interface ModuleOptions {
381
- /**
382
- * Directory to scan for function definitions
383
- * @default 'server/functions'
384
- */
385
- dir?: string;
386
- /**
387
- * Enable dev UI
388
- * @default true in development
389
- */
390
- ui?: boolean;
391
- /**
392
- * Debug configuration
393
- */
394
- debug?: Record<string, any>;
395
- /**
396
- * Queue adapter configuration (job execution)
397
- */
398
- queue?: QueueConfig;
399
- /**
400
- * Stream adapter configuration (pub/sub messaging)
401
- * @since v0.4.1
402
- */
403
- stream?: StreamConfig;
404
- /**
405
- * Store adapter configuration (persistence)
406
- * Three-tier storage: events, documents, KV, indices
407
- * @since v0.4.1
408
- */
409
- store?: StoreConfig;
410
- /**
411
- * Flow-specific configuration
412
- * @since v0.4.1
413
- */
414
- flow?: FlowConfig;
415
- /**
416
- * Webhooks configuration
417
- * @since v0.5.0
418
- */
419
- webhooks?: WebhooksConfig;
420
- /**
421
- * Shared connection configurations
422
- * Used as fallback if adapters don't specify their own connections
423
- * @since v0.4.1
424
- */
425
- connections?: ConnectionsConfig;
426
- }
427
- /**
428
- * Runtime config shape for nvent module (v0.4.1+)
429
- */
430
- export interface ModuleConfig {
431
- debug?: Record<string, any>;
432
- queue: Required<QueueConfig>;
433
- stream: Required<StreamConfig>;
434
- store: Required<StoreConfig>;
435
- flow: Required<FlowConfig>;
436
- webhooks: Required<WebhooksConfig>;
437
- connections: Required<ConnectionsConfig>;
438
- rootDir?: string;
439
- }
File without changes
@@ -1,20 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import type { EventRecord } from './types.js';
3
- type Handler = (e: EventRecord) => void;
4
- declare global {
5
- var __nq_bus_emitter: EventEmitter | undefined;
6
- }
7
- declare function publish(event: EventRecord): void;
8
- declare function subscribeRunId(runId: string, handler: Handler): () => void;
9
- declare function onType(type: string, handler: Handler): () => void;
10
- export declare const eventBus: {
11
- publish: typeof publish;
12
- subscribeRunId: typeof subscribeRunId;
13
- onType: typeof onType;
14
- };
15
- export declare function getEventBus(): {
16
- publish: typeof publish;
17
- subscribeRunId: typeof subscribeRunId;
18
- onType: typeof onType;
19
- };
20
- export {};
@@ -1,35 +0,0 @@
1
- import { EventEmitter } from "node:events";
2
- const emitter = globalThis.__nq_bus_emitter ??= new EventEmitter();
3
- try {
4
- const max = Number(process.env.NQ_BUS_MAX_LISTENERS || 100);
5
- if (!Number.isNaN(max) && max > 0) emitter.setMaxListeners(max);
6
- } catch {
7
- }
8
- function eventNameForRunId(runId) {
9
- return `runId:${runId}`;
10
- }
11
- function eventNameForType(type) {
12
- return `type:${type}`;
13
- }
14
- function publish(event) {
15
- emitter.emit(eventNameForRunId(event.runId), event);
16
- emitter.emit(eventNameForType(event.type), event);
17
- }
18
- function subscribeRunId(runId, handler) {
19
- const name = eventNameForRunId(runId);
20
- emitter.on(name, handler);
21
- return () => {
22
- emitter.off(name, handler);
23
- };
24
- }
25
- function onType(type, handler) {
26
- const name = eventNameForType(type);
27
- emitter.on(name, handler);
28
- return () => {
29
- emitter.off(name, handler);
30
- };
31
- }
32
- export const eventBus = { publish, subscribeRunId, onType };
33
- export function getEventBus() {
34
- return eventBus;
35
- }
@@ -1,144 +0,0 @@
1
- export interface PublishContext {
2
- queue?: string;
3
- jobId?: string;
4
- /** Flow run ID for flow events */
5
- flowId?: string;
6
- /** Trigger ID for trigger events */
7
- triggerId?: string;
8
- }
9
- export interface PublishPayload<T = any> {
10
- type: string;
11
- runId: string;
12
- flowName: string;
13
- stepName?: string;
14
- stepId?: string;
15
- attempt?: number;
16
- data?: T;
17
- }
18
- export type EventType = 'flow.start' | 'flow.completed' | 'flow.failed' | 'flow.cancel' | 'step.started' | 'step.completed' | 'step.failed' | 'step.retry' | 'log' | 'emit' | 'state' | 'flow.stalled' | 'trigger.fired' | 'trigger.registered' | 'await.registered' | 'await.resolved' | 'await.timeout';
19
- export interface BaseEvent {
20
- id?: string;
21
- ts?: string;
22
- type: EventType;
23
- runId: string;
24
- flowName: string;
25
- }
26
- export interface StepEvent extends BaseEvent {
27
- stepName: string;
28
- stepId: string;
29
- attempt: number;
30
- }
31
- export interface FlowStartEvent extends BaseEvent {
32
- type: 'flow.start';
33
- data?: {
34
- input?: any;
35
- };
36
- }
37
- export interface FlowCompletedEvent extends BaseEvent {
38
- type: 'flow.completed';
39
- data?: {
40
- result?: any;
41
- };
42
- }
43
- export interface FlowFailedEvent extends BaseEvent {
44
- type: 'flow.failed';
45
- data?: {
46
- error?: string;
47
- stack?: string;
48
- };
49
- }
50
- export interface FlowCancelEvent extends BaseEvent {
51
- type: 'flow.cancel';
52
- data?: {
53
- canceledAt?: string;
54
- };
55
- }
56
- export interface FlowStalledEvent extends BaseEvent {
57
- type: 'flow.stalled';
58
- data?: {
59
- lastActivityAt?: number;
60
- };
61
- }
62
- export interface StepStartedEvent extends StepEvent {
63
- type: 'step.started';
64
- data?: {
65
- input?: any;
66
- };
67
- }
68
- export interface StepCompletedEvent extends StepEvent {
69
- type: 'step.completed';
70
- data?: {
71
- result?: any;
72
- };
73
- }
74
- export interface StepFailedEvent extends StepEvent {
75
- type: 'step.failed';
76
- data?: {
77
- error?: string;
78
- stack?: string;
79
- };
80
- }
81
- export interface StepRetryEvent extends StepEvent {
82
- type: 'step.retry';
83
- data?: {
84
- stepName: string;
85
- queue: string;
86
- attempt: number;
87
- maxAttempts: number;
88
- nextAttempt: number;
89
- };
90
- }
91
- export interface LogEvent extends StepEvent {
92
- type: 'log';
93
- data: {
94
- level: 'debug' | 'info' | 'warn' | 'error';
95
- message: string;
96
- [key: string]: any;
97
- };
98
- }
99
- export interface EmitEvent extends StepEvent {
100
- type: 'emit';
101
- data: {
102
- topic: string;
103
- payload: any;
104
- };
105
- }
106
- export interface StateEvent extends StepEvent {
107
- type: 'state';
108
- data: {
109
- operation: 'get' | 'set' | 'delete';
110
- scope?: string;
111
- key: string;
112
- value?: any;
113
- };
114
- }
115
- export interface TriggerFiredEvent extends BaseEvent {
116
- type: 'trigger.fired';
117
- triggerName: string;
118
- data: any;
119
- }
120
- export interface TriggerRegisteredEvent {
121
- type: 'trigger.registered';
122
- triggerName: string;
123
- triggerType: 'event' | 'webhook' | 'schedule' | 'manual';
124
- scope: 'flow' | 'run';
125
- }
126
- export interface AwaitRegisteredEvent extends BaseEvent {
127
- type: 'await.registered';
128
- stepName: string;
129
- awaitType: 'webhook' | 'event' | 'schedule' | 'time';
130
- position: 'before' | 'after';
131
- config: any;
132
- }
133
- export interface AwaitResolvedEvent extends BaseEvent {
134
- type: 'await.resolved';
135
- stepName: string;
136
- triggerData: any;
137
- position: 'before' | 'after';
138
- }
139
- export interface AwaitTimeoutEvent extends BaseEvent {
140
- type: 'await.timeout';
141
- stepName: string;
142
- action: 'fail' | 'continue' | 'retry';
143
- }
144
- export type FlowEvent = FlowStartEvent | FlowCompletedEvent | FlowFailedEvent | FlowCancelEvent | FlowStalledEvent | StepStartedEvent | StepCompletedEvent | StepFailedEvent | StepRetryEvent | LogEvent | EmitEvent | StateEvent | TriggerFiredEvent | TriggerRegisteredEvent | AwaitRegisteredEvent | AwaitResolvedEvent | AwaitTimeoutEvent;
File without changes
@@ -1,8 +0,0 @@
1
- /**
2
- * Schedule or update a schedule trigger in the scheduler
3
- */
4
- export declare function scheduleTrigger(triggerName: string, scheduleConfig: any, triggerStatus?: string): Promise<void>;
5
- /**
6
- * Unschedule a schedule trigger from the scheduler
7
- */
8
- export declare function unscheduleTrigger(triggerName: string): Promise<void>;