nvent 0.4.5 → 0.5.1
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 -180
- 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
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { TriggerEntry, TriggerSubscription } from '../../../registry/types.js';
|
|
2
|
+
import type { StoreAdapter } from '../../adapters/interfaces/store.js';
|
|
3
|
+
/**
|
|
4
|
+
* Centralized trigger runtime management
|
|
5
|
+
* Handles runtime state, payload storage/resolution, and state manipulation
|
|
6
|
+
*
|
|
7
|
+
* This class is the single source of truth for trigger runtime state,
|
|
8
|
+
* used by both useTrigger (public API) and triggerWiring (event orchestration)
|
|
9
|
+
*/
|
|
10
|
+
export declare class TriggerRuntime {
|
|
11
|
+
private state;
|
|
12
|
+
private store;
|
|
13
|
+
private logger;
|
|
14
|
+
constructor(store: StoreAdapter, logger: any);
|
|
15
|
+
get initialized(): boolean;
|
|
16
|
+
setInitialized(value: boolean): void;
|
|
17
|
+
hasTrigger(name: string): boolean;
|
|
18
|
+
getTrigger(name: string): TriggerEntry | undefined;
|
|
19
|
+
getAllTriggers(options?: {
|
|
20
|
+
sortBy?: 'registeredAt' | 'lastActivityAt' | 'name';
|
|
21
|
+
order?: 'asc' | 'desc';
|
|
22
|
+
limit?: number;
|
|
23
|
+
offset?: number;
|
|
24
|
+
}): TriggerEntry[];
|
|
25
|
+
getSubscribedFlows(trigger: string): string[];
|
|
26
|
+
getFlowTriggers(flow: string): string[];
|
|
27
|
+
getSubscription(trigger: string, flow: string): TriggerSubscription | undefined;
|
|
28
|
+
getAllSubscriptions(): TriggerSubscription[];
|
|
29
|
+
getRuntimeStats(): {
|
|
30
|
+
triggerCount: number;
|
|
31
|
+
subscriptionCount: number;
|
|
32
|
+
flowCount: number;
|
|
33
|
+
initialized: boolean;
|
|
34
|
+
};
|
|
35
|
+
addTrigger(name: string, entry: TriggerEntry): void;
|
|
36
|
+
removeTrigger(name: string): void;
|
|
37
|
+
addSubscription(triggerName: string, flowName: string, subscription: TriggerSubscription): void;
|
|
38
|
+
removeSubscription(triggerName: string, flowName: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Extract a minimal summary from payload for debugging
|
|
41
|
+
* Keeps only small, identifying fields
|
|
42
|
+
*/
|
|
43
|
+
private extractSummary;
|
|
44
|
+
/**
|
|
45
|
+
* Store large payload in KV store and return reference
|
|
46
|
+
* Returns either the original data (if small) or a reference object
|
|
47
|
+
*/
|
|
48
|
+
handleLargePayload(triggerName: string, data: any, threshold: number): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* Resolve payload reference if needed
|
|
51
|
+
* Returns the full payload from KV store, or falls back to summary if expired
|
|
52
|
+
*/
|
|
53
|
+
resolvePayload(data: any): Promise<any>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get or create the singleton TriggerRuntime instance
|
|
57
|
+
*/
|
|
58
|
+
export declare function getTriggerRuntime(store: StoreAdapter, logger: any): TriggerRuntime;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
export class TriggerRuntime {
|
|
2
|
+
state;
|
|
3
|
+
store;
|
|
4
|
+
logger;
|
|
5
|
+
constructor(store, logger) {
|
|
6
|
+
this.store = store;
|
|
7
|
+
this.logger = logger;
|
|
8
|
+
this.state = {
|
|
9
|
+
triggers: /* @__PURE__ */ new Map(),
|
|
10
|
+
triggerToFlows: /* @__PURE__ */ new Map(),
|
|
11
|
+
flowToTriggers: /* @__PURE__ */ new Map(),
|
|
12
|
+
initialized: false
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// State Access (Read-only)
|
|
17
|
+
// ============================================================================
|
|
18
|
+
get initialized() {
|
|
19
|
+
return this.state.initialized;
|
|
20
|
+
}
|
|
21
|
+
setInitialized(value) {
|
|
22
|
+
this.state.initialized = value;
|
|
23
|
+
}
|
|
24
|
+
hasTrigger(name) {
|
|
25
|
+
return this.state.triggers.has(name);
|
|
26
|
+
}
|
|
27
|
+
getTrigger(name) {
|
|
28
|
+
return this.state.triggers.get(name);
|
|
29
|
+
}
|
|
30
|
+
getAllTriggers(options) {
|
|
31
|
+
let triggers = Array.from(this.state.triggers.values());
|
|
32
|
+
if (options?.sortBy) {
|
|
33
|
+
triggers.sort((a, b) => {
|
|
34
|
+
const aValue = a[options.sortBy];
|
|
35
|
+
const bValue = b[options.sortBy];
|
|
36
|
+
if (aValue === void 0 && bValue === void 0) return 0;
|
|
37
|
+
if (aValue === void 0) return 1;
|
|
38
|
+
if (bValue === void 0) return -1;
|
|
39
|
+
if (typeof aValue === "string" && typeof bValue === "string") {
|
|
40
|
+
return options.order === "desc" ? bValue.localeCompare(aValue) : aValue.localeCompare(bValue);
|
|
41
|
+
}
|
|
42
|
+
if (typeof aValue === "number" && typeof bValue === "number") {
|
|
43
|
+
return options.order === "desc" ? bValue - aValue : aValue - bValue;
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (options?.offset !== void 0 || options?.limit !== void 0) {
|
|
49
|
+
const offset = options.offset || 0;
|
|
50
|
+
const limit = options.limit || triggers.length;
|
|
51
|
+
triggers = triggers.slice(offset, offset + limit);
|
|
52
|
+
}
|
|
53
|
+
return triggers;
|
|
54
|
+
}
|
|
55
|
+
getSubscribedFlows(trigger) {
|
|
56
|
+
const subs = this.state.triggerToFlows.get(trigger) || /* @__PURE__ */ new Set();
|
|
57
|
+
return Array.from(new Set(Array.from(subs).map((s) => s.flowName)));
|
|
58
|
+
}
|
|
59
|
+
getFlowTriggers(flow) {
|
|
60
|
+
return Array.from(this.state.flowToTriggers.get(flow) || /* @__PURE__ */ new Set());
|
|
61
|
+
}
|
|
62
|
+
getSubscription(trigger, flow) {
|
|
63
|
+
const subs = this.state.triggerToFlows.get(trigger);
|
|
64
|
+
if (!subs) return void 0;
|
|
65
|
+
return Array.from(subs).find((s) => s.flowName === flow);
|
|
66
|
+
}
|
|
67
|
+
getAllSubscriptions() {
|
|
68
|
+
const allSubs = [];
|
|
69
|
+
for (const subs of this.state.triggerToFlows.values()) {
|
|
70
|
+
allSubs.push(...Array.from(subs));
|
|
71
|
+
}
|
|
72
|
+
return allSubs;
|
|
73
|
+
}
|
|
74
|
+
getRuntimeStats() {
|
|
75
|
+
return {
|
|
76
|
+
triggerCount: this.state.triggers.size,
|
|
77
|
+
subscriptionCount: Array.from(this.state.triggerToFlows.values()).reduce((acc, subs) => acc + subs.size, 0),
|
|
78
|
+
flowCount: this.state.flowToTriggers.size,
|
|
79
|
+
initialized: this.state.initialized
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// State Manipulation (Internal)
|
|
84
|
+
// ============================================================================
|
|
85
|
+
addTrigger(name, entry) {
|
|
86
|
+
this.state.triggers.set(name, entry);
|
|
87
|
+
}
|
|
88
|
+
removeTrigger(name) {
|
|
89
|
+
this.state.triggers.delete(name);
|
|
90
|
+
this.state.triggerToFlows.delete(name);
|
|
91
|
+
for (const [flow, triggers] of this.state.flowToTriggers.entries()) {
|
|
92
|
+
triggers.delete(name);
|
|
93
|
+
if (triggers.size === 0) {
|
|
94
|
+
this.state.flowToTriggers.delete(flow);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
addSubscription(triggerName, flowName, subscription) {
|
|
99
|
+
if (!this.state.triggerToFlows.has(triggerName)) {
|
|
100
|
+
this.state.triggerToFlows.set(triggerName, /* @__PURE__ */ new Set());
|
|
101
|
+
}
|
|
102
|
+
const triggerSubs = this.state.triggerToFlows.get(triggerName);
|
|
103
|
+
const existingSub = Array.from(triggerSubs).find((s) => s.flowName === flowName);
|
|
104
|
+
if (existingSub) {
|
|
105
|
+
triggerSubs.delete(existingSub);
|
|
106
|
+
}
|
|
107
|
+
triggerSubs.add(subscription);
|
|
108
|
+
if (!this.state.flowToTriggers.has(flowName)) {
|
|
109
|
+
this.state.flowToTriggers.set(flowName, /* @__PURE__ */ new Set());
|
|
110
|
+
}
|
|
111
|
+
this.state.flowToTriggers.get(flowName).add(triggerName);
|
|
112
|
+
}
|
|
113
|
+
removeSubscription(triggerName, flowName) {
|
|
114
|
+
const triggerSubs = this.state.triggerToFlows.get(triggerName);
|
|
115
|
+
if (triggerSubs) {
|
|
116
|
+
const subToRemove = Array.from(triggerSubs).find((s) => s.flowName === flowName);
|
|
117
|
+
if (subToRemove) {
|
|
118
|
+
triggerSubs.delete(subToRemove);
|
|
119
|
+
if (triggerSubs.size === 0) {
|
|
120
|
+
this.state.triggerToFlows.delete(triggerName);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const flowTriggers = this.state.flowToTriggers.get(flowName);
|
|
125
|
+
if (flowTriggers) {
|
|
126
|
+
flowTriggers.delete(triggerName);
|
|
127
|
+
if (flowTriggers.size === 0) {
|
|
128
|
+
this.state.flowToTriggers.delete(flowName);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// Payload Management
|
|
134
|
+
// ============================================================================
|
|
135
|
+
/**
|
|
136
|
+
* Extract a minimal summary from payload for debugging
|
|
137
|
+
* Keeps only small, identifying fields
|
|
138
|
+
*/
|
|
139
|
+
extractSummary(data, maxDepth = 2) {
|
|
140
|
+
if (maxDepth === 0) return "[nested]";
|
|
141
|
+
if (Array.isArray(data)) {
|
|
142
|
+
return {
|
|
143
|
+
__type: "array",
|
|
144
|
+
length: data.length,
|
|
145
|
+
sample: data.length > 0 ? this.extractSummary(data[0], maxDepth - 1) : null
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (data && typeof data === "object") {
|
|
149
|
+
const summary = {};
|
|
150
|
+
for (const [key, val] of Object.entries(data)) {
|
|
151
|
+
if (typeof val === "string" && val.length > 100) {
|
|
152
|
+
summary[key] = `${val.slice(0, 100)}... (${val.length} chars)`;
|
|
153
|
+
} else if (typeof val === "object" && val !== null) {
|
|
154
|
+
summary[key] = this.extractSummary(val, maxDepth - 1);
|
|
155
|
+
} else {
|
|
156
|
+
summary[key] = val;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return summary;
|
|
160
|
+
}
|
|
161
|
+
return data;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Store large payload in KV store and return reference
|
|
165
|
+
* Returns either the original data (if small) or a reference object
|
|
166
|
+
*/
|
|
167
|
+
async handleLargePayload(triggerName, data, threshold) {
|
|
168
|
+
const serialized = JSON.stringify(data);
|
|
169
|
+
const sizeBytes = new TextEncoder().encode(serialized).length;
|
|
170
|
+
if (sizeBytes < threshold) {
|
|
171
|
+
return data;
|
|
172
|
+
}
|
|
173
|
+
const payloadId = `payload:${triggerName}:${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
174
|
+
const ttl = 7 * 24 * 60 * 60;
|
|
175
|
+
await this.store.kv.set(payloadId, data, ttl);
|
|
176
|
+
this.logger.debug("Stored large payload in KV", {
|
|
177
|
+
triggerName,
|
|
178
|
+
payloadId,
|
|
179
|
+
originalSize: sizeBytes,
|
|
180
|
+
threshold
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
__payloadRef: payloadId,
|
|
184
|
+
__size: sizeBytes,
|
|
185
|
+
__summary: this.extractSummary(data)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Resolve payload reference if needed
|
|
190
|
+
* Returns the full payload from KV store, or falls back to summary if expired
|
|
191
|
+
*/
|
|
192
|
+
async resolvePayload(data) {
|
|
193
|
+
if (data?.__payloadRef) {
|
|
194
|
+
const payload = await this.store.kv.get(data.__payloadRef);
|
|
195
|
+
if (!payload) {
|
|
196
|
+
this.logger.warn("Payload reference expired or not found, using summary", {
|
|
197
|
+
ref: data.__payloadRef
|
|
198
|
+
});
|
|
199
|
+
return data.__summary || {};
|
|
200
|
+
}
|
|
201
|
+
return payload;
|
|
202
|
+
}
|
|
203
|
+
return data;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
let instance = null;
|
|
207
|
+
export function getTriggerRuntime(store, logger) {
|
|
208
|
+
if (!instance) {
|
|
209
|
+
instance = new TriggerRuntime(store, logger);
|
|
210
|
+
}
|
|
211
|
+
return instance;
|
|
212
|
+
}
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
+
import { useStoreAdapter } from '#imports';
|
|
1
2
|
/**
|
|
2
3
|
* Check if all dependencies for a step are met
|
|
3
4
|
* Returns true if all subscriptions have been emitted or completed
|
|
4
5
|
*/
|
|
5
6
|
export declare function checkPendingStepTriggers(step: any, emittedEvents: Set<string>, completedSteps: Set<string>): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Check all steps in the flow and trigger any that now have all dependencies satisfied
|
|
9
|
+
* This is called after emit events and step completions
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkAndTriggerPendingSteps(flowName: string, runId: string, store: ReturnType<typeof useStoreAdapter>): Promise<void>;
|
|
6
12
|
/**
|
|
7
13
|
* Analyze flow completion status from events
|
|
8
14
|
* Returns status, step counts, and timestamps
|
|
9
15
|
*/
|
|
10
|
-
export declare function analyzeFlowCompletion(flowSteps: Record<string, any>, entryStep: string | undefined, events: any[]): {
|
|
11
|
-
status: 'running' | 'completed' | 'failed' | 'canceled';
|
|
16
|
+
export declare function analyzeFlowCompletion(flowSteps: Record<string, any>, entryStep: string | undefined, events: any[], entryStepDef?: any): {
|
|
17
|
+
status: 'running' | 'completed' | 'failed' | 'canceled' | 'awaiting';
|
|
12
18
|
totalSteps: number;
|
|
13
19
|
completedSteps: number;
|
|
14
20
|
startedAt: number;
|
|
15
21
|
completedAt: number;
|
|
16
22
|
};
|
|
17
23
|
/**
|
|
18
|
-
*
|
|
24
|
+
* Lean Flow Wiring
|
|
19
25
|
*
|
|
20
26
|
* 1. Persists flow events to streams using runId
|
|
21
27
|
* 2. Maintains a sorted set index using projection names for listing runs
|
|
@@ -23,6 +29,6 @@ export declare function analyzeFlowCompletion(flowSteps: Record<string, any>, en
|
|
|
23
29
|
* Events arrive as "ingress" (no id/ts) and are persisted to `nq:flow:{runId}` streams.
|
|
24
30
|
*/
|
|
25
31
|
export declare function createFlowWiring(): {
|
|
26
|
-
start: () => void
|
|
27
|
-
stop: () => void
|
|
32
|
+
start: () => Promise<void>;
|
|
33
|
+
stop: () => Promise<void>;
|
|
28
34
|
};
|