nvent 0.4.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.mts +1 -1
- package/dist/module.mjs +433 -175
- package/dist/runtime/adapters/base/index.d.ts +6 -0
- package/dist/runtime/adapters/base/index.js +1 -0
- package/dist/runtime/adapters/base/store-validator.d.ts +48 -0
- package/dist/runtime/adapters/base/store-validator.js +147 -0
- package/dist/runtime/adapters/builtin/file-queue.d.ts +15 -1
- package/dist/runtime/adapters/builtin/file-queue.js +70 -6
- package/dist/runtime/adapters/builtin/file-store.d.ts +4 -18
- package/dist/runtime/adapters/builtin/file-store.js +90 -109
- package/dist/runtime/adapters/builtin/memory-queue.js +4 -0
- package/dist/runtime/adapters/builtin/memory-store.d.ts +42 -31
- package/dist/runtime/adapters/builtin/memory-store.js +253 -183
- package/dist/runtime/adapters/factory.d.ts +2 -2
- package/dist/runtime/adapters/factory.js +54 -20
- package/dist/runtime/adapters/interfaces/store.d.ts +177 -113
- package/dist/runtime/config/index.d.ts +2 -2
- package/dist/runtime/config/index.js +14 -6
- package/dist/runtime/config/types.d.ts +32 -2
- package/dist/runtime/events/eventBus.d.ts +1 -1
- package/dist/runtime/events/types.d.ts +31 -2
- package/dist/runtime/events/utils/scheduleTrigger.d.ts +8 -0
- package/dist/runtime/events/utils/scheduleTrigger.js +69 -0
- package/dist/runtime/events/utils/stallDetector.d.ts +44 -3
- package/dist/runtime/events/utils/stallDetector.js +288 -89
- package/dist/runtime/events/utils/triggerRuntime.d.ts +58 -0
- package/dist/runtime/events/utils/triggerRuntime.js +212 -0
- package/dist/runtime/events/wiring/flowWiring.d.ts +11 -5
- package/dist/runtime/events/wiring/flowWiring.js +620 -92
- package/dist/runtime/events/wiring/registry.d.ts +2 -2
- package/dist/runtime/events/wiring/registry.js +8 -6
- package/dist/runtime/events/wiring/streamWiring.d.ts +15 -11
- package/dist/runtime/events/wiring/streamWiring.js +88 -11
- package/dist/runtime/events/wiring/triggerWiring.d.ts +21 -0
- package/dist/runtime/events/wiring/triggerWiring.js +412 -0
- package/dist/runtime/{server → nitro}/plugins/00.adapters.js +8 -4
- package/dist/runtime/{server → nitro}/plugins/02.workers.js +21 -3
- package/dist/runtime/nitro/plugins/03.triggers.d.ts +12 -0
- package/dist/runtime/nitro/plugins/03.triggers.js +55 -0
- package/dist/runtime/nitro/routes/webhook.await.d.ts +23 -0
- package/dist/runtime/nitro/routes/webhook.await.js +90 -0
- package/dist/runtime/nitro/routes/webhook.trigger.d.ts +69 -0
- package/dist/runtime/nitro/routes/webhook.trigger.js +64 -0
- package/dist/runtime/{utils → nitro/utils}/adapters.d.ts +6 -6
- package/dist/runtime/nitro/utils/awaitPatterns/event.d.ts +15 -0
- package/dist/runtime/nitro/utils/awaitPatterns/event.js +120 -0
- package/dist/runtime/nitro/utils/awaitPatterns/index.d.ts +28 -0
- package/dist/runtime/nitro/utils/awaitPatterns/index.js +55 -0
- package/dist/runtime/nitro/utils/awaitPatterns/schedule.d.ts +16 -0
- package/dist/runtime/nitro/utils/awaitPatterns/schedule.js +78 -0
- package/dist/runtime/nitro/utils/awaitPatterns/time.d.ts +15 -0
- package/dist/runtime/nitro/utils/awaitPatterns/time.js +67 -0
- package/dist/runtime/nitro/utils/awaitPatterns/webhook.d.ts +15 -0
- package/dist/runtime/nitro/utils/awaitPatterns/webhook.js +120 -0
- package/dist/runtime/{utils → nitro/utils}/defineFunction.d.ts +2 -2
- package/dist/runtime/{utils → nitro/utils}/defineFunction.js +3 -3
- package/dist/runtime/{utils → nitro/utils}/defineFunctionConfig.d.ts +156 -0
- package/dist/runtime/{utils → nitro/utils}/defineFunctionConfig.js +1 -0
- package/dist/runtime/nitro/utils/defineHooks.d.ts +41 -0
- package/dist/runtime/nitro/utils/defineHooks.js +6 -0
- package/dist/runtime/{utils → nitro/utils}/registerAdapter.d.ts +3 -3
- package/dist/runtime/{utils → nitro/utils}/registerAdapter.js +1 -1
- package/dist/runtime/nitro/utils/useAwait.d.ts +71 -0
- package/dist/runtime/nitro/utils/useAwait.js +139 -0
- package/dist/runtime/{utils → nitro/utils}/useEventManager.d.ts +2 -2
- package/dist/runtime/{utils → nitro/utils}/useEventManager.js +1 -1
- package/dist/runtime/nitro/utils/useFlow.d.ts +68 -0
- package/dist/runtime/nitro/utils/useFlow.js +226 -0
- package/dist/runtime/nitro/utils/useHookRegistry.d.ts +34 -0
- package/dist/runtime/nitro/utils/useHookRegistry.js +25 -0
- package/dist/runtime/nitro/utils/useRunContext.d.ts +6 -0
- package/dist/runtime/nitro/utils/useRunContext.js +102 -0
- package/dist/runtime/nitro/utils/useStreamTopics.d.ts +83 -0
- package/dist/runtime/nitro/utils/useStreamTopics.js +94 -0
- package/dist/runtime/nitro/utils/useTrigger.d.ts +150 -0
- package/dist/runtime/nitro/utils/useTrigger.js +320 -0
- package/dist/runtime/scheduler/index.d.ts +33 -0
- package/dist/runtime/scheduler/index.js +38 -0
- package/dist/runtime/scheduler/scheduler.d.ts +113 -0
- package/dist/runtime/scheduler/scheduler.js +623 -0
- package/dist/runtime/scheduler/types.d.ts +116 -0
- package/dist/runtime/scheduler/types.js +0 -0
- package/dist/runtime/worker/node/runner.d.ts +12 -2
- package/dist/runtime/worker/node/runner.js +141 -37
- package/package.json +6 -6
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.d.ts +0 -10
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +0 -55
- package/dist/runtime/server/api/_flows/[name]/runs/[runId]/cancel.post.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/runs/[runId]/cancel.post.js +0 -21
- package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +0 -17
- package/dist/runtime/server/api/_flows/[name]/runs.get.js +0 -64
- package/dist/runtime/server/api/_flows/[name]/schedule.post.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/schedule.post.js +0 -66
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +0 -47
- package/dist/runtime/server/api/_flows/[name]/schedules.get.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/schedules.get.js +0 -50
- package/dist/runtime/server/api/_flows/[name]/start.post.d.ts +0 -2
- package/dist/runtime/server/api/_flows/[name]/start.post.js +0 -9
- package/dist/runtime/server/api/_flows/index.get.d.ts +0 -6
- package/dist/runtime/server/api/_flows/index.get.js +0 -5
- package/dist/runtime/server/api/_flows/ws.d.ts +0 -60
- package/dist/runtime/server/api/_flows/ws.js +0 -209
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.d.ts +0 -2
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +0 -14
- package/dist/runtime/server/api/_queues/[name]/job/index.get.d.ts +0 -2
- package/dist/runtime/server/api/_queues/[name]/job/index.get.js +0 -27
- package/dist/runtime/server/api/_queues/index.get.d.ts +0 -2
- package/dist/runtime/server/api/_queues/index.get.js +0 -106
- package/dist/runtime/server/api/_queues/ws.d.ts +0 -48
- package/dist/runtime/server/api/_queues/ws.js +0 -215
- package/dist/runtime/utils/useFlowEngine.d.ts +0 -19
- package/dist/runtime/utils/useFlowEngine.js +0 -108
- package/dist/runtime/utils/useStreamTopics.d.ts +0 -72
- package/dist/runtime/utils/useStreamTopics.js +0 -47
- /package/dist/runtime/{server → nitro}/plugins/00.adapters.d.ts +0 -0
- /package/dist/runtime/{server → nitro}/plugins/01.ws-lifecycle.d.ts +0 -0
- /package/dist/runtime/{server → nitro}/plugins/01.ws-lifecycle.js +0 -0
- /package/dist/runtime/{server → nitro}/plugins/02.workers.d.ts +0 -0
- /package/dist/runtime/{utils → nitro/utils}/adapters.js +0 -0
- /package/dist/runtime/{utils → nitro/utils}/useNventLogger.d.ts +0 -0
- /package/dist/runtime/{utils → nitro/utils}/useNventLogger.js +0 -0
- /package/dist/runtime/{utils → nitro/utils}/wsPeerManager.d.ts +0 -0
- /package/dist/runtime/{utils → nitro/utils}/wsPeerManager.js +0 -0
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname, join, extname, relative } from 'node:path';
|
|
2
|
-
import { useLogger, defineNuxtModule, createResolver,
|
|
2
|
+
import { useLogger, defineNuxtModule, createResolver, addTemplate, addTypeTemplate, addServerPlugin, addServerHandler, addServerImports, updateTemplates } from '@nuxt/kit';
|
|
3
3
|
import defu from 'defu';
|
|
4
4
|
import { existsSync, realpathSync } from 'node:fs';
|
|
5
5
|
import { globby } from 'globby';
|
|
@@ -30,7 +30,10 @@ async function loadJsConfig(absPath) {
|
|
|
30
30
|
role: flowCfg.role,
|
|
31
31
|
step: flowCfg.step,
|
|
32
32
|
emits: flowCfg.emits,
|
|
33
|
-
subscribes
|
|
33
|
+
subscribes,
|
|
34
|
+
triggers: flowCfg.triggers,
|
|
35
|
+
awaitBefore: flowCfg.awaitBefore,
|
|
36
|
+
awaitAfter: flowCfg.awaitAfter
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
}
|
|
@@ -42,7 +45,8 @@ async function loadJsConfig(absPath) {
|
|
|
42
45
|
} : void 0;
|
|
43
46
|
const workerCfg = cfg?.worker && typeof cfg.worker === "object" ? { ...cfg.worker } : void 0;
|
|
44
47
|
const hasDefaultExport = !!(mod && mod.default);
|
|
45
|
-
|
|
48
|
+
const hasHooks = !!(mod && typeof mod.onAwaitRegister === "function" || mod && typeof mod.onAwaitResolve === "function");
|
|
49
|
+
return { queueName, flow, runtype, queue: queueCfg, worker: workerCfg, hasDefaultExport, hasHooks };
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
async function loadTsConfig(absPath) {
|
|
@@ -69,7 +73,10 @@ async function loadTsConfig(absPath) {
|
|
|
69
73
|
role: flowCfg.role,
|
|
70
74
|
step: flowCfg.step,
|
|
71
75
|
emits: flowCfg.emits,
|
|
72
|
-
subscribes
|
|
76
|
+
subscribes,
|
|
77
|
+
triggers: flowCfg.triggers,
|
|
78
|
+
awaitBefore: flowCfg.awaitBefore,
|
|
79
|
+
awaitAfter: flowCfg.awaitAfter
|
|
73
80
|
};
|
|
74
81
|
}
|
|
75
82
|
}
|
|
@@ -80,7 +87,8 @@ async function loadTsConfig(absPath) {
|
|
|
80
87
|
limiter: cfg.queue.limiter
|
|
81
88
|
} : void 0;
|
|
82
89
|
const workerCfg = cfg?.worker && typeof cfg.worker === "object" ? { ...cfg.worker } : void 0;
|
|
83
|
-
|
|
90
|
+
const hasHooks = !!(mod.exports.onAwaitRegister || mod.exports.onAwaitResolve);
|
|
91
|
+
return { queueName, flow, runtype, queue: queueCfg, worker: workerCfg, hasDefaultExport, hasHooks };
|
|
84
92
|
} catch (error) {
|
|
85
93
|
throw new Error(`Failed to parse config from ${absPath}: ${error}`);
|
|
86
94
|
}
|
|
@@ -175,7 +183,10 @@ async function loadPyConfig(absPath, logger) {
|
|
|
175
183
|
role: flowCfg.role,
|
|
176
184
|
step: flowCfg.step,
|
|
177
185
|
emits: flowCfg.emits,
|
|
178
|
-
subscribes
|
|
186
|
+
subscribes,
|
|
187
|
+
triggers: flowCfg.triggers,
|
|
188
|
+
awaitBefore: flowCfg.awaitBefore,
|
|
189
|
+
awaitAfter: flowCfg.awaitAfter
|
|
179
190
|
};
|
|
180
191
|
}
|
|
181
192
|
}
|
|
@@ -183,13 +194,13 @@ async function loadPyConfig(absPath, logger) {
|
|
|
183
194
|
return { queueName, flow, hasDefaultExport: true };
|
|
184
195
|
}
|
|
185
196
|
|
|
186
|
-
async function scanWorkers(layers,
|
|
197
|
+
async function scanWorkers(layers, functionsDir = "functions") {
|
|
187
198
|
const logger = useLogger();
|
|
188
199
|
const workerByVirtualPath = /* @__PURE__ */ new Map();
|
|
189
200
|
const seenFiles = /* @__PURE__ */ new Set();
|
|
190
201
|
const flowSources = [];
|
|
191
202
|
for (const layer of layers) {
|
|
192
|
-
const base = join(layer.serverDir,
|
|
203
|
+
const base = join(layer.serverDir, functionsDir);
|
|
193
204
|
if (!existsSync(base)) continue;
|
|
194
205
|
const files = await globby("**/*.{ts,js,mjs,cjs,mts,cts,py}", { cwd: base, dot: false });
|
|
195
206
|
for (const rel of files) {
|
|
@@ -217,6 +228,7 @@ async function scanWorkers(layers, queuesDir = "queues") {
|
|
|
217
228
|
queueName = String(meta.queue?.name || meta.queueName || (id.split("/").pop() || id));
|
|
218
229
|
workerByVirtualPath.set(virtualPath, {
|
|
219
230
|
id,
|
|
231
|
+
name: queueName,
|
|
220
232
|
kind,
|
|
221
233
|
filePath: virtualPath,
|
|
222
234
|
absPath: abs,
|
|
@@ -240,6 +252,7 @@ async function scanWorkers(layers, queuesDir = "queues") {
|
|
|
240
252
|
queueName = String(meta.queue?.name || meta.queueName || (id.split("/").pop() || id));
|
|
241
253
|
workerByVirtualPath.set(virtualPath, {
|
|
242
254
|
id,
|
|
255
|
+
name: queueName,
|
|
243
256
|
kind,
|
|
244
257
|
filePath: virtualPath,
|
|
245
258
|
absPath: abs,
|
|
@@ -263,6 +276,7 @@ async function scanWorkers(layers, queuesDir = "queues") {
|
|
|
263
276
|
queueName = String(meta.queue?.name || meta.queueName || (id.split("/").pop() || id));
|
|
264
277
|
workerByVirtualPath.set(virtualPath, {
|
|
265
278
|
id,
|
|
279
|
+
name: queueName,
|
|
266
280
|
kind,
|
|
267
281
|
filePath: virtualPath,
|
|
268
282
|
absPath: abs,
|
|
@@ -315,20 +329,41 @@ function buildFlows(flowSources) {
|
|
|
315
329
|
const key = `${flowId}:${f.role}:${mainStep}`;
|
|
316
330
|
if (!seenFlowKeys.has(key)) {
|
|
317
331
|
seenFlowKeys.add(key);
|
|
318
|
-
bucket.entry = {
|
|
332
|
+
bucket.entry = {
|
|
333
|
+
step: mainStep,
|
|
334
|
+
queue,
|
|
335
|
+
workerId: id,
|
|
336
|
+
emits: f.emits,
|
|
337
|
+
awaitBefore: f.awaitBefore,
|
|
338
|
+
awaitAfter: f.awaitAfter
|
|
339
|
+
};
|
|
319
340
|
}
|
|
320
341
|
for (const s of steps.slice(1)) {
|
|
321
342
|
const skey = `${flowId}:step:${s}`;
|
|
322
343
|
if (seenFlowKeys.has(skey)) continue;
|
|
323
344
|
seenFlowKeys.add(skey);
|
|
324
|
-
bucket.steps[s] = {
|
|
345
|
+
bucket.steps[s] = {
|
|
346
|
+
queue,
|
|
347
|
+
workerId: id,
|
|
348
|
+
subscribes: f.subscribes,
|
|
349
|
+
emits: f.emits,
|
|
350
|
+
awaitBefore: f.awaitBefore,
|
|
351
|
+
awaitAfter: f.awaitAfter
|
|
352
|
+
};
|
|
325
353
|
}
|
|
326
354
|
} else {
|
|
327
355
|
for (const s of steps) {
|
|
328
356
|
const skey = `${flowId}:${f.role}:${s}`;
|
|
329
357
|
if (seenFlowKeys.has(skey)) continue;
|
|
330
358
|
seenFlowKeys.add(skey);
|
|
331
|
-
bucket.steps[s] = {
|
|
359
|
+
bucket.steps[s] = {
|
|
360
|
+
queue,
|
|
361
|
+
workerId: id,
|
|
362
|
+
subscribes: f.subscribes,
|
|
363
|
+
emits: f.emits,
|
|
364
|
+
awaitBefore: f.awaitBefore,
|
|
365
|
+
awaitAfter: f.awaitAfter
|
|
366
|
+
};
|
|
332
367
|
}
|
|
333
368
|
}
|
|
334
369
|
if (f.subscribes) {
|
|
@@ -485,6 +520,46 @@ function findTriggeredSteps(stepName, step, allSteps) {
|
|
|
485
520
|
}
|
|
486
521
|
return Array.from(triggered);
|
|
487
522
|
}
|
|
523
|
+
function getStepAwaitTimeout(step) {
|
|
524
|
+
let timeout = 0;
|
|
525
|
+
if (step.awaitBefore?.timeout) timeout += step.awaitBefore.timeout;
|
|
526
|
+
if (step.awaitAfter?.timeout) timeout += step.awaitAfter.timeout;
|
|
527
|
+
return timeout;
|
|
528
|
+
}
|
|
529
|
+
function calculateFlowStallTimeout(steps, levels) {
|
|
530
|
+
const DEFAULT_STALL_TIMEOUT = 30 * 60 * 1e3;
|
|
531
|
+
const MIN_BUFFER = 5 * 60 * 1e3;
|
|
532
|
+
const BUFFER_PERCENTAGE = 0.1;
|
|
533
|
+
const levelTimeouts = [];
|
|
534
|
+
let awaitCount = 0;
|
|
535
|
+
for (const levelSteps of levels) {
|
|
536
|
+
let maxLevelTimeout = 0;
|
|
537
|
+
for (const stepName of levelSteps) {
|
|
538
|
+
const step = steps[stepName];
|
|
539
|
+
if (!step) continue;
|
|
540
|
+
const stepTimeout = getStepAwaitTimeout(step);
|
|
541
|
+
if (stepTimeout > 0) {
|
|
542
|
+
awaitCount++;
|
|
543
|
+
maxLevelTimeout = Math.max(maxLevelTimeout, stepTimeout);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
if (maxLevelTimeout > 0) {
|
|
547
|
+
levelTimeouts.push(maxLevelTimeout);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (levelTimeouts.length === 0) {
|
|
551
|
+
return DEFAULT_STALL_TIMEOUT;
|
|
552
|
+
}
|
|
553
|
+
const totalAwaitTimeout = levelTimeouts.reduce((sum, timeout) => sum + timeout, 0);
|
|
554
|
+
const buffer = Math.max(totalAwaitTimeout * BUFFER_PERCENTAGE, MIN_BUFFER);
|
|
555
|
+
const calculatedTimeout = totalAwaitTimeout + buffer;
|
|
556
|
+
if (calculatedTimeout > DEFAULT_STALL_TIMEOUT * 2) {
|
|
557
|
+
console.log(
|
|
558
|
+
`[flow-analyzer] Flow has ${awaitCount} await patterns across ${levelTimeouts.length} levels, calculated stall timeout: ${calculatedTimeout / 1e3}s (total await time: ${totalAwaitTimeout / 1e3}s, level timeouts: [${levelTimeouts.map((t) => `${t / 1e3}s`).join(", ")}])`
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
return calculatedTimeout;
|
|
562
|
+
}
|
|
488
563
|
function analyzeFlow(flow) {
|
|
489
564
|
const entryStepName = flow.entry?.step;
|
|
490
565
|
const steps = flow.steps || {};
|
|
@@ -492,12 +567,14 @@ function analyzeFlow(flow) {
|
|
|
492
567
|
const levels = calculateLevels(entryStepName, dependencies);
|
|
493
568
|
const analyzedSteps = {};
|
|
494
569
|
for (const [stepName, step] of Object.entries(steps)) {
|
|
570
|
+
const hasAwaitPattern = !!(step.awaitBefore || step.awaitAfter);
|
|
495
571
|
analyzedSteps[stepName] = {
|
|
496
572
|
...step,
|
|
497
573
|
name: stepName,
|
|
498
574
|
dependsOn: dependencies[stepName] || [],
|
|
499
575
|
triggers: findTriggeredSteps(stepName, step, steps),
|
|
500
|
-
level: levels[stepName] ?? 1
|
|
576
|
+
level: levels[stepName] ?? 1,
|
|
577
|
+
hasAwaitPattern
|
|
501
578
|
};
|
|
502
579
|
}
|
|
503
580
|
const maxLevel = Math.max(0, ...Object.values(levels));
|
|
@@ -508,12 +585,28 @@ function analyzeFlow(flow) {
|
|
|
508
585
|
levelArray.push(stepName);
|
|
509
586
|
}
|
|
510
587
|
}
|
|
588
|
+
const stallTimeout = calculateFlowStallTimeout(analyzedSteps, levelGroups);
|
|
589
|
+
const awaitSteps = Object.values(analyzedSteps).filter((s) => s.hasAwaitPattern);
|
|
590
|
+
const totalTimeout = awaitSteps.reduce((sum, s) => {
|
|
591
|
+
let stepTimeout = 0;
|
|
592
|
+
if (s.awaitBefore?.timeout) stepTimeout += s.awaitBefore.timeout;
|
|
593
|
+
if (s.awaitAfter?.timeout) stepTimeout += s.awaitAfter.timeout;
|
|
594
|
+
return sum + stepTimeout;
|
|
595
|
+
}, 0);
|
|
596
|
+
const awaitPatterns = awaitSteps.length > 0 ? {
|
|
597
|
+
steps: awaitSteps.map((s) => s.name),
|
|
598
|
+
beforeCount: awaitSteps.filter((s) => s.awaitBefore).length,
|
|
599
|
+
afterCount: awaitSteps.filter((s) => s.awaitAfter).length,
|
|
600
|
+
totalTimeout
|
|
601
|
+
} : void 0;
|
|
511
602
|
return {
|
|
512
603
|
id: flow.id,
|
|
513
604
|
entry: flow.entry,
|
|
514
605
|
steps: analyzedSteps,
|
|
515
606
|
levels: levelGroups,
|
|
516
|
-
maxLevel
|
|
607
|
+
maxLevel,
|
|
608
|
+
stallTimeout,
|
|
609
|
+
awaitPatterns
|
|
517
610
|
};
|
|
518
611
|
}
|
|
519
612
|
|
|
@@ -529,7 +622,7 @@ async function compileRegistryFromServerWorkers(layers, queuesDir = "queues", de
|
|
|
529
622
|
return compiled;
|
|
530
623
|
}
|
|
531
624
|
|
|
532
|
-
const logger = useLogger("
|
|
625
|
+
const logger = useLogger("nvent");
|
|
533
626
|
function watchQueueFiles(options) {
|
|
534
627
|
const { nuxt, layerInfos, queuesDir, onRefresh } = options;
|
|
535
628
|
const dirsToWatch = layerInfos.map((layer) => {
|
|
@@ -591,13 +684,73 @@ function watchQueueFiles(options) {
|
|
|
591
684
|
return watcher;
|
|
592
685
|
}
|
|
593
686
|
|
|
687
|
+
function analyzeTriggerDefinitions(workers) {
|
|
688
|
+
const triggers = [];
|
|
689
|
+
const seenTriggers = /* @__PURE__ */ new Set();
|
|
690
|
+
for (const worker of workers) {
|
|
691
|
+
const triggerDef = worker.flow?.triggers?.define;
|
|
692
|
+
if (!triggerDef) continue;
|
|
693
|
+
if (seenTriggers.has(triggerDef.name)) continue;
|
|
694
|
+
seenTriggers.add(triggerDef.name);
|
|
695
|
+
triggers.push({
|
|
696
|
+
name: triggerDef.name,
|
|
697
|
+
type: triggerDef.type,
|
|
698
|
+
scope: triggerDef.scope || "flow",
|
|
699
|
+
displayName: triggerDef.displayName,
|
|
700
|
+
description: triggerDef.description,
|
|
701
|
+
source: `function:${worker.name}`,
|
|
702
|
+
expectedSubscribers: triggerDef.expectedSubscribers,
|
|
703
|
+
webhook: triggerDef.webhook,
|
|
704
|
+
schedule: triggerDef.schedule,
|
|
705
|
+
config: triggerDef.config,
|
|
706
|
+
registeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
707
|
+
registeredBy: "code"
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
return triggers;
|
|
711
|
+
}
|
|
712
|
+
function analyzeTriggerSubscriptions(workers) {
|
|
713
|
+
const subscriptions = [];
|
|
714
|
+
for (const worker of workers) {
|
|
715
|
+
if (!worker.flow?.triggers?.subscribe) continue;
|
|
716
|
+
const flowNames = Array.isArray(worker.flow.names) ? worker.flow.names : [worker.flow.names];
|
|
717
|
+
for (const flowName of flowNames) {
|
|
718
|
+
for (const triggerName of worker.flow.triggers.subscribe) {
|
|
719
|
+
subscriptions.push({
|
|
720
|
+
triggerName,
|
|
721
|
+
flowName,
|
|
722
|
+
mode: worker.flow.triggers.mode || "auto",
|
|
723
|
+
source: "config",
|
|
724
|
+
registeredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return subscriptions;
|
|
730
|
+
}
|
|
731
|
+
function buildTriggerIndex(subscriptions) {
|
|
732
|
+
const triggerToFlows = /* @__PURE__ */ new Map();
|
|
733
|
+
const flowToTriggers = /* @__PURE__ */ new Map();
|
|
734
|
+
for (const sub of subscriptions) {
|
|
735
|
+
if (!triggerToFlows.has(sub.triggerName)) {
|
|
736
|
+
triggerToFlows.set(sub.triggerName, /* @__PURE__ */ new Set());
|
|
737
|
+
}
|
|
738
|
+
triggerToFlows.get(sub.triggerName).add(sub.flowName);
|
|
739
|
+
if (!flowToTriggers.has(sub.flowName)) {
|
|
740
|
+
flowToTriggers.set(sub.flowName, /* @__PURE__ */ new Set());
|
|
741
|
+
}
|
|
742
|
+
flowToTriggers.get(sub.flowName).add(sub.triggerName);
|
|
743
|
+
}
|
|
744
|
+
return { triggerToFlows, flowToTriggers };
|
|
745
|
+
}
|
|
746
|
+
|
|
594
747
|
function generateRegistryTemplate(registry) {
|
|
595
|
-
return `// auto-generated by
|
|
748
|
+
return `// auto-generated by nvent
|
|
596
749
|
export const registry = ${JSON.stringify(registry, null, 2)};
|
|
597
750
|
|
|
598
|
-
export const
|
|
751
|
+
export const useFunctionRegistry = () => registry;
|
|
599
752
|
|
|
600
|
-
export default
|
|
753
|
+
export default useFunctionRegistry;
|
|
601
754
|
`;
|
|
602
755
|
}
|
|
603
756
|
function generateHandlersTemplate(registry) {
|
|
@@ -606,16 +759,18 @@ function generateHandlersTemplate(registry) {
|
|
|
606
759
|
const entries = [];
|
|
607
760
|
regWorkers.filter((w) => w?.kind === "ts" && (w?.runtype ? w.runtype !== "task" : registry?.runner?.ts?.isolate !== "task")).forEach((w, i) => {
|
|
608
761
|
const varName = `h${i}`;
|
|
762
|
+
const moduleVar = `m${i}`;
|
|
609
763
|
const src = w && (w.absPath || w.abs || w.cwd && w.file && join(w.cwd, w.file) || w.entry || w.path) || "";
|
|
610
764
|
if (!src) return;
|
|
611
765
|
const importPath = String(src);
|
|
612
766
|
lines.push(`import ${varName} from '${importPath}'`);
|
|
767
|
+
lines.push(`import * as ${moduleVar} from '${importPath}'`);
|
|
613
768
|
const queue = String(w?.queue?.name || `w${i}`);
|
|
614
769
|
const id = String(w?.id || `w${i}`);
|
|
615
770
|
const absPath = importPath;
|
|
616
|
-
entries.push(`{ queue: '${queue}', id: '${id}', absPath: '${absPath}', handler: ${varName} }`);
|
|
771
|
+
entries.push(`{ queue: '${queue}', id: '${id}', absPath: '${absPath}', handler: ${varName}, module: ${moduleVar} }`);
|
|
617
772
|
});
|
|
618
|
-
return `// auto-generated by
|
|
773
|
+
return `// auto-generated by nvent
|
|
619
774
|
${lines.join("\n")}
|
|
620
775
|
|
|
621
776
|
export const handlers = [
|
|
@@ -673,11 +828,13 @@ function generateAnalyzedFlowsTemplate(registry) {
|
|
|
673
828
|
analyzed: {
|
|
674
829
|
levels: analyzed.levels,
|
|
675
830
|
maxLevel: analyzed.maxLevel,
|
|
831
|
+
stallTimeout: analyzed.stallTimeout,
|
|
832
|
+
awaitPatterns: analyzed.awaitPatterns,
|
|
676
833
|
steps: analyzed.steps
|
|
677
834
|
}
|
|
678
835
|
};
|
|
679
836
|
});
|
|
680
|
-
return `// auto-generated by
|
|
837
|
+
return `// auto-generated by nvent
|
|
681
838
|
export const analyzedFlows = ${JSON.stringify(analyzedFlows, null, 2)};
|
|
682
839
|
|
|
683
840
|
export const useAnalyzedFlows = () => analyzedFlows;
|
|
@@ -685,13 +842,240 @@ export const useAnalyzedFlows = () => analyzedFlows;
|
|
|
685
842
|
export default useAnalyzedFlows;
|
|
686
843
|
`;
|
|
687
844
|
}
|
|
845
|
+
function generateTriggerRegistryTemplate(registry) {
|
|
846
|
+
const workers = registry?.workers || [];
|
|
847
|
+
const triggers = analyzeTriggerDefinitions(workers);
|
|
848
|
+
const subscriptions = analyzeTriggerSubscriptions(workers);
|
|
849
|
+
const index = buildTriggerIndex(subscriptions);
|
|
850
|
+
const triggerToFlows = {};
|
|
851
|
+
for (const [trigger, subs] of index.triggerToFlows.entries()) {
|
|
852
|
+
triggerToFlows[trigger] = Array.from(subs);
|
|
853
|
+
}
|
|
854
|
+
const flowToTriggers = {};
|
|
855
|
+
for (const [flow, triggers2] of index.flowToTriggers.entries()) {
|
|
856
|
+
flowToTriggers[flow] = Array.from(triggers2);
|
|
857
|
+
}
|
|
858
|
+
const triggerRegistry = {
|
|
859
|
+
triggers,
|
|
860
|
+
subscriptions,
|
|
861
|
+
index: {
|
|
862
|
+
triggerToFlows,
|
|
863
|
+
flowToTriggers
|
|
864
|
+
},
|
|
865
|
+
compiledAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
866
|
+
};
|
|
867
|
+
return `// auto-generated by nvent
|
|
868
|
+
export const triggerRegistry = ${JSON.stringify(triggerRegistry, null, 2)};
|
|
869
|
+
|
|
870
|
+
export const useTriggerRegistry = () => triggerRegistry;
|
|
871
|
+
|
|
872
|
+
export default useTriggerRegistry;
|
|
873
|
+
`;
|
|
874
|
+
}
|
|
875
|
+
function generateAdapterTypesTemplate(resolverFn) {
|
|
876
|
+
return `// Auto-generated adapter type definitions
|
|
877
|
+
// External adapter packages can import these types
|
|
878
|
+
|
|
879
|
+
// Queue Adapter
|
|
880
|
+
export type {
|
|
881
|
+
QueueAdapter,
|
|
882
|
+
JobInput,
|
|
883
|
+
Job,
|
|
884
|
+
JobsQuery,
|
|
885
|
+
JobOptions,
|
|
886
|
+
JobState,
|
|
887
|
+
ScheduleOptions,
|
|
888
|
+
JobCounts,
|
|
889
|
+
QueueEvent,
|
|
890
|
+
WorkerHandler,
|
|
891
|
+
WorkerContext,
|
|
892
|
+
WorkerOptions,
|
|
893
|
+
} from ${JSON.stringify(resolverFn("./runtime/adapters/interfaces/queue"))}
|
|
894
|
+
|
|
895
|
+
// Stream Adapter
|
|
896
|
+
export type {
|
|
897
|
+
StreamAdapter,
|
|
898
|
+
StreamEvent,
|
|
899
|
+
SubscribeOptions,
|
|
900
|
+
SubscriptionHandle,
|
|
901
|
+
} from ${JSON.stringify(resolverFn("./runtime/adapters/interfaces/stream"))}
|
|
902
|
+
|
|
903
|
+
// Store Adapter
|
|
904
|
+
export type {
|
|
905
|
+
StoreAdapter,
|
|
906
|
+
EventRecord,
|
|
907
|
+
EventReadOptions,
|
|
908
|
+
EventSubscription,
|
|
909
|
+
ListOptions,
|
|
910
|
+
} from ${JSON.stringify(resolverFn("./runtime/adapters/interfaces/store"))}
|
|
911
|
+
|
|
912
|
+
// Event Types
|
|
913
|
+
export type {
|
|
914
|
+
EventType,
|
|
915
|
+
BaseEvent,
|
|
916
|
+
StepEvent,
|
|
917
|
+
FlowStartEvent,
|
|
918
|
+
FlowCompletedEvent,
|
|
919
|
+
FlowFailedEvent,
|
|
920
|
+
FlowCancelEvent,
|
|
921
|
+
FlowStalledEvent,
|
|
922
|
+
StepStartedEvent,
|
|
923
|
+
StepCompletedEvent,
|
|
924
|
+
StepFailedEvent,
|
|
925
|
+
StepRetryEvent,
|
|
926
|
+
LogEvent,
|
|
927
|
+
EmitEvent,
|
|
928
|
+
StateEvent,
|
|
929
|
+
FlowEvent,
|
|
930
|
+
} from ${JSON.stringify(resolverFn("./runtime/events/types"))}
|
|
931
|
+
|
|
932
|
+
// Adapter Registry
|
|
933
|
+
export type { AdapterRegistry } from ${JSON.stringify(resolverFn("./runtime/adapters/registry"))}`;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
function getServerImports(resolverFn, buildDir) {
|
|
937
|
+
return [
|
|
938
|
+
// Generated templates
|
|
939
|
+
{
|
|
940
|
+
name: "useFunctionRegistry",
|
|
941
|
+
as: "$useFunctionRegistry",
|
|
942
|
+
from: resolverFn(buildDir + "/function-registry")
|
|
943
|
+
},
|
|
944
|
+
{
|
|
945
|
+
name: "useWorkerHandlers",
|
|
946
|
+
as: "$useWorkerHandlers",
|
|
947
|
+
from: resolverFn(buildDir + "/worker-handlers")
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
name: "useAnalyzedFlows",
|
|
951
|
+
as: "$useAnalyzedFlows",
|
|
952
|
+
from: resolverFn(buildDir + "/analyzed-flows")
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
name: "useTriggerRegistry",
|
|
956
|
+
as: "$useTriggerRegistry",
|
|
957
|
+
from: resolverFn(buildDir + "/trigger-registry")
|
|
958
|
+
},
|
|
959
|
+
// Core utilities for user code
|
|
960
|
+
{
|
|
961
|
+
name: "defineFunctionConfig",
|
|
962
|
+
from: resolverFn("./runtime/nitro/utils/defineFunctionConfig")
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
name: "defineFunction",
|
|
966
|
+
from: resolverFn("./runtime/nitro/utils/defineFunction")
|
|
967
|
+
},
|
|
968
|
+
// Composables users may need in server code
|
|
969
|
+
{
|
|
970
|
+
name: "useEventManager",
|
|
971
|
+
from: resolverFn("./runtime/nitro/utils/useEventManager")
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
name: "usePeerManager",
|
|
975
|
+
from: resolverFn("./runtime/nitro/utils/wsPeerManager")
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
name: "useNventLogger",
|
|
979
|
+
from: resolverFn("./runtime/nitro/utils/useNventLogger")
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
name: "useHookRegistry",
|
|
983
|
+
from: resolverFn("./runtime/nitro/utils/useHookRegistry")
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
name: "useAwait",
|
|
987
|
+
from: resolverFn("./runtime/nitro/utils/useAwait")
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
name: "useRunContext",
|
|
991
|
+
from: resolverFn("./runtime/nitro/utils/useRunContext")
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
name: "defineAwaitRegisterHook",
|
|
995
|
+
from: resolverFn("./runtime/nitro/utils/defineHooks")
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
name: "defineAwaitResolveHook",
|
|
999
|
+
from: resolverFn("./runtime/nitro/utils/defineHooks")
|
|
1000
|
+
},
|
|
1001
|
+
// Adapter composables
|
|
1002
|
+
{
|
|
1003
|
+
name: "useQueueAdapter",
|
|
1004
|
+
from: resolverFn("./runtime/nitro/utils/adapters")
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
name: "useStoreAdapter",
|
|
1008
|
+
from: resolverFn("./runtime/nitro/utils/adapters")
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
name: "useStreamAdapter",
|
|
1012
|
+
from: resolverFn("./runtime/nitro/utils/adapters")
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
name: "useStateAdapter",
|
|
1016
|
+
from: resolverFn("./runtime/nitro/utils/adapters")
|
|
1017
|
+
},
|
|
1018
|
+
{
|
|
1019
|
+
name: "getAdapters",
|
|
1020
|
+
from: resolverFn("./runtime/nitro/utils/adapters")
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
name: "setAdapters",
|
|
1024
|
+
from: resolverFn("./runtime/nitro/utils/adapters")
|
|
1025
|
+
},
|
|
1026
|
+
// Runtime utilities
|
|
1027
|
+
{
|
|
1028
|
+
name: "useStreamTopics",
|
|
1029
|
+
from: resolverFn("./runtime/nitro/utils/useStreamTopics")
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
name: "useTrigger",
|
|
1033
|
+
from: resolverFn("./runtime/nitro/utils/useTrigger")
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
name: "useFlow",
|
|
1037
|
+
from: resolverFn("./runtime/nitro/utils/useFlow")
|
|
1038
|
+
},
|
|
1039
|
+
// Scheduler
|
|
1040
|
+
{
|
|
1041
|
+
name: "useScheduler",
|
|
1042
|
+
from: resolverFn("./runtime/scheduler")
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
name: "initializeScheduler",
|
|
1046
|
+
from: resolverFn("./runtime/scheduler")
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
name: "shutdownScheduler",
|
|
1050
|
+
from: resolverFn("./runtime/scheduler")
|
|
1051
|
+
},
|
|
1052
|
+
// Adapter registration utilities for external modules
|
|
1053
|
+
{
|
|
1054
|
+
name: "registerQueueAdapter",
|
|
1055
|
+
from: resolverFn("./runtime/nitro/utils/registerAdapter")
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
name: "registerStreamAdapter",
|
|
1059
|
+
from: resolverFn("./runtime/nitro/utils/registerAdapter")
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
name: "registerStoreAdapter",
|
|
1063
|
+
from: resolverFn("./runtime/nitro/utils/registerAdapter")
|
|
1064
|
+
},
|
|
1065
|
+
// Adapter base utilities for external adapter packages
|
|
1066
|
+
{
|
|
1067
|
+
name: "createStoreValidator",
|
|
1068
|
+
from: resolverFn("./runtime/adapters/base/store-validator")
|
|
1069
|
+
}
|
|
1070
|
+
];
|
|
1071
|
+
}
|
|
688
1072
|
|
|
689
1073
|
const meta = {
|
|
690
1074
|
name: "nvent",
|
|
691
1075
|
version: "0.4.1",
|
|
692
1076
|
configKey: "nvent"
|
|
693
1077
|
};
|
|
694
|
-
const module$1 = defineNuxtModule({
|
|
1078
|
+
const module$1 = defineNuxtModule().with({
|
|
695
1079
|
meta,
|
|
696
1080
|
defaults: {},
|
|
697
1081
|
moduleDependencies: {
|
|
@@ -704,7 +1088,6 @@ const module$1 = defineNuxtModule({
|
|
|
704
1088
|
const userConfig = nuxt.options[meta.configKey] || {};
|
|
705
1089
|
const mergedOptions = { ...userConfig, ...options };
|
|
706
1090
|
const config = normalizeModuleOptions(mergedOptions);
|
|
707
|
-
addServerScanDir(resolve("./runtime/server"));
|
|
708
1091
|
nuxt.hook("nitro:config", (nitro) => {
|
|
709
1092
|
const redisConfig = getRedisStorageConfig(config);
|
|
710
1093
|
nitro.storage = defu(nitro.storage || {}, {
|
|
@@ -743,10 +1126,11 @@ const module$1 = defineNuxtModule({
|
|
|
743
1126
|
});
|
|
744
1127
|
const compiledSnapshot = JSON.parse(JSON.stringify(compiledWithMeta));
|
|
745
1128
|
let lastCompiledRegistry = compiledSnapshot;
|
|
746
|
-
const REGISTRY_TEMPLATE = "
|
|
1129
|
+
const REGISTRY_TEMPLATE = "function-registry.mjs";
|
|
747
1130
|
const HANDLERS_TEMPLATE = "worker-handlers.mjs";
|
|
748
1131
|
const ANALYZED_FLOWS_TEMPLATE = "analyzed-flows.mjs";
|
|
749
|
-
|
|
1132
|
+
const TRIGGER_REGISTRY_TEMPLATE = "trigger-registry.mjs";
|
|
1133
|
+
for (const templateName of [REGISTRY_TEMPLATE, HANDLERS_TEMPLATE, ANALYZED_FLOWS_TEMPLATE, TRIGGER_REGISTRY_TEMPLATE]) {
|
|
750
1134
|
const templatePath = resolve(nuxt.options.buildDir, templateName);
|
|
751
1135
|
nuxt.options.build.transpile.push(templatePath);
|
|
752
1136
|
}
|
|
@@ -765,155 +1149,29 @@ const module$1 = defineNuxtModule({
|
|
|
765
1149
|
write: true,
|
|
766
1150
|
getContents: () => generateAnalyzedFlowsTemplate(lastCompiledRegistry)
|
|
767
1151
|
});
|
|
1152
|
+
addTemplate({
|
|
1153
|
+
filename: TRIGGER_REGISTRY_TEMPLATE,
|
|
1154
|
+
write: true,
|
|
1155
|
+
getContents: () => generateTriggerRegistryTemplate(lastCompiledRegistry)
|
|
1156
|
+
});
|
|
768
1157
|
addTypeTemplate({
|
|
769
1158
|
filename: "types/nvent-adapters.d.ts",
|
|
770
|
-
getContents: () =>
|
|
771
|
-
// Auto-generated adapter type definitions
|
|
772
|
-
// External adapter packages can import these types
|
|
773
|
-
|
|
774
|
-
// Queue Adapter
|
|
775
|
-
export type {
|
|
776
|
-
QueueAdapter,
|
|
777
|
-
JobInput,
|
|
778
|
-
Job,
|
|
779
|
-
JobsQuery,
|
|
780
|
-
JobOptions,
|
|
781
|
-
JobState,
|
|
782
|
-
ScheduleOptions,
|
|
783
|
-
JobCounts,
|
|
784
|
-
QueueEvent,
|
|
785
|
-
WorkerHandler,
|
|
786
|
-
WorkerContext,
|
|
787
|
-
WorkerOptions,
|
|
788
|
-
} from ${JSON.stringify(resolve("./runtime/adapters/interfaces/queue"))}
|
|
789
|
-
|
|
790
|
-
// Stream Adapter
|
|
791
|
-
export type {
|
|
792
|
-
StreamAdapter,
|
|
793
|
-
StreamEvent,
|
|
794
|
-
SubscribeOptions,
|
|
795
|
-
SubscriptionHandle,
|
|
796
|
-
} from ${JSON.stringify(resolve("./runtime/adapters/interfaces/stream"))}
|
|
797
|
-
|
|
798
|
-
// Store Adapter
|
|
799
|
-
export type {
|
|
800
|
-
StoreAdapter,
|
|
801
|
-
EventRecord,
|
|
802
|
-
EventReadOptions,
|
|
803
|
-
EventSubscription,
|
|
804
|
-
ListOptions,
|
|
805
|
-
} from ${JSON.stringify(resolve("./runtime/adapters/interfaces/store"))}
|
|
806
|
-
|
|
807
|
-
// Event Types
|
|
808
|
-
export type {
|
|
809
|
-
EventType,
|
|
810
|
-
BaseEvent,
|
|
811
|
-
StepEvent,
|
|
812
|
-
FlowStartEvent,
|
|
813
|
-
FlowCompletedEvent,
|
|
814
|
-
FlowFailedEvent,
|
|
815
|
-
FlowCancelEvent,
|
|
816
|
-
FlowStalledEvent,
|
|
817
|
-
StepStartedEvent,
|
|
818
|
-
StepCompletedEvent,
|
|
819
|
-
StepFailedEvent,
|
|
820
|
-
StepRetryEvent,
|
|
821
|
-
LogEvent,
|
|
822
|
-
EmitEvent,
|
|
823
|
-
StateEvent,
|
|
824
|
-
FlowEvent,
|
|
825
|
-
} from ${JSON.stringify(resolve("./runtime/events/types"))}
|
|
826
|
-
|
|
827
|
-
// Adapter Registry
|
|
828
|
-
export type { AdapterRegistry } from ${JSON.stringify(resolve("./runtime/adapters/registry"))}
|
|
829
|
-
`.trim()
|
|
1159
|
+
getContents: () => generateAdapterTypesTemplate(resolve)
|
|
830
1160
|
});
|
|
831
1161
|
nuxt.options.alias["#nvent/adapters"] = resolve(nuxt.options.buildDir, "types/nvent-adapters");
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
name: "useAnalyzedFlows",
|
|
846
|
-
as: "$useAnalyzedFlows",
|
|
847
|
-
from: resolve(nuxt.options.buildDir, "analyzed-flows")
|
|
848
|
-
},
|
|
849
|
-
// Core utilities for user code
|
|
850
|
-
{
|
|
851
|
-
name: "defineFunctionConfig",
|
|
852
|
-
from: resolve("./runtime/utils/defineFunctionConfig")
|
|
853
|
-
},
|
|
854
|
-
{
|
|
855
|
-
name: "defineFunction",
|
|
856
|
-
from: resolve("./runtime/utils/defineFunction")
|
|
857
|
-
},
|
|
858
|
-
// Composables users may need in server code
|
|
859
|
-
{
|
|
860
|
-
name: "useFlowEngine",
|
|
861
|
-
from: resolve("./runtime/utils/useFlowEngine")
|
|
862
|
-
},
|
|
863
|
-
{
|
|
864
|
-
name: "useEventManager",
|
|
865
|
-
from: resolve("./runtime/utils/useEventManager")
|
|
866
|
-
},
|
|
867
|
-
{
|
|
868
|
-
name: "usePeerManager",
|
|
869
|
-
from: resolve("./runtime/utils/wsPeerManager")
|
|
870
|
-
},
|
|
871
|
-
{
|
|
872
|
-
name: "useNventLogger",
|
|
873
|
-
from: resolve("./runtime/utils/useNventLogger")
|
|
874
|
-
},
|
|
875
|
-
{
|
|
876
|
-
name: "useQueueAdapter",
|
|
877
|
-
from: resolve("./runtime/utils/adapters")
|
|
878
|
-
},
|
|
879
|
-
{
|
|
880
|
-
name: "useStoreAdapter",
|
|
881
|
-
from: resolve("./runtime/utils/adapters")
|
|
882
|
-
},
|
|
883
|
-
{
|
|
884
|
-
name: "useStreamAdapter",
|
|
885
|
-
from: resolve("./runtime/utils/adapters")
|
|
886
|
-
},
|
|
887
|
-
{
|
|
888
|
-
name: "useStateAdapter",
|
|
889
|
-
from: resolve("./runtime/utils/adapters")
|
|
890
|
-
},
|
|
891
|
-
{
|
|
892
|
-
name: "getAdapters",
|
|
893
|
-
from: resolve("./runtime/utils/adapters")
|
|
894
|
-
},
|
|
895
|
-
{
|
|
896
|
-
name: "setAdapters",
|
|
897
|
-
from: resolve("./runtime/utils/adapters")
|
|
898
|
-
},
|
|
899
|
-
{
|
|
900
|
-
name: "useStreamTopics",
|
|
901
|
-
from: resolve("./runtime/utils/useStreamTopics")
|
|
902
|
-
},
|
|
903
|
-
// Adapter registration utilities for external modules
|
|
904
|
-
{
|
|
905
|
-
name: "registerQueueAdapter",
|
|
906
|
-
from: resolve("./runtime/utils/registerAdapter")
|
|
907
|
-
},
|
|
908
|
-
{
|
|
909
|
-
name: "registerStreamAdapter",
|
|
910
|
-
from: resolve("./runtime/utils/registerAdapter")
|
|
911
|
-
},
|
|
912
|
-
{
|
|
913
|
-
name: "registerStoreAdapter",
|
|
914
|
-
from: resolve("./runtime/utils/registerAdapter")
|
|
915
|
-
}
|
|
916
|
-
]);
|
|
1162
|
+
addServerPlugin(resolve("./runtime/nitro/plugins/00.adapters"));
|
|
1163
|
+
addServerPlugin(resolve("./runtime/nitro/plugins/01.ws-lifecycle"));
|
|
1164
|
+
addServerPlugin(resolve("./runtime/nitro/plugins/02.workers"));
|
|
1165
|
+
addServerPlugin(resolve("./runtime/nitro/plugins/03.triggers"));
|
|
1166
|
+
addServerHandler({
|
|
1167
|
+
route: "/api/_webhook/await/:flowName/:runId/:stepName",
|
|
1168
|
+
handler: resolve("./runtime/nitro/routes/webhook.await")
|
|
1169
|
+
});
|
|
1170
|
+
addServerHandler({
|
|
1171
|
+
route: "/api/_webhook/trigger/:triggerName",
|
|
1172
|
+
handler: resolve("./runtime/nitro/routes/webhook.trigger")
|
|
1173
|
+
});
|
|
1174
|
+
addServerImports(getServerImports(resolve, nuxt.options.buildDir));
|
|
917
1175
|
const refreshRegistry = async (reason, changedPath) => {
|
|
918
1176
|
const functionsDir = config.dir || "functions";
|
|
919
1177
|
const updatedRegistry = await compileRegistryFromServerWorkers(layerInfos, functionsDir, defaultConfigs);
|
|
@@ -926,19 +1184,19 @@ export type { AdapterRegistry } from ${JSON.stringify(resolve("./runtime/adapter
|
|
|
926
1184
|
flows: {},
|
|
927
1185
|
eventIndex: {}
|
|
928
1186
|
})));
|
|
929
|
-
console.log(`[
|
|
930
|
-
console.log(`[
|
|
931
|
-
console.log(`[
|
|
1187
|
+
console.log(`[nvent] registry refreshed (${reason})`, changedPath || "");
|
|
1188
|
+
console.log(`[nvent] new registry has ${lastCompiledRegistry.workers?.length || 0} workers`);
|
|
1189
|
+
console.log(`[nvent] new registry compiled at: ${lastCompiledRegistry.compiledAt}`);
|
|
932
1190
|
await updateTemplates({
|
|
933
1191
|
filter: (template) => {
|
|
934
|
-
const match = template.filename === REGISTRY_TEMPLATE || template.filename === HANDLERS_TEMPLATE || template.filename === ANALYZED_FLOWS_TEMPLATE;
|
|
1192
|
+
const match = template.filename === REGISTRY_TEMPLATE || template.filename === HANDLERS_TEMPLATE || template.filename === ANALYZED_FLOWS_TEMPLATE || template.filename === TRIGGER_REGISTRY_TEMPLATE;
|
|
935
1193
|
if (match) {
|
|
936
|
-
console.log(`[
|
|
1194
|
+
console.log(`[nvent] updating template: ${template.filename}`);
|
|
937
1195
|
}
|
|
938
1196
|
return match;
|
|
939
1197
|
}
|
|
940
1198
|
});
|
|
941
|
-
console.log(`[
|
|
1199
|
+
console.log(`[nvent] templates updated`);
|
|
942
1200
|
};
|
|
943
1201
|
if (nuxt.options.dev) {
|
|
944
1202
|
const functionsDir = config.dir || "functions";
|