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,54 +0,0 @@
1
- import { useRuntimeConfig } from "#imports";
2
- import { consola } from "consola";
3
- const LOG_LEVELS = {
4
- debug: 0,
5
- info: 1,
6
- warn: 2,
7
- error: 3
8
- };
9
- const loggerCache = /* @__PURE__ */ new Map();
10
- export function useNventLogger(scope) {
11
- const rc = useRuntimeConfig();
12
- const debugConfig = rc?.nvent?.debug;
13
- const configLevel = debugConfig?.level || process.env.NQ_DEBUG_LEVEL || "info";
14
- const globalLevelNum = configLevel === "silent" ? Infinity : LOG_LEVELS[configLevel] ?? LOG_LEVELS.info;
15
- const scopeKey = scope.replace(/[^a-z0-9]/gi, "_").toLowerCase();
16
- const envKey = `NQ_DEBUG_${scopeKey.toUpperCase()}`;
17
- const isScopeDebugEnabled = debugConfig?.[scopeKey] === true || process.env[envKey] === "1";
18
- let scopedConsola = loggerCache.get(scope);
19
- if (!scopedConsola) {
20
- scopedConsola = consola.withTag(scope);
21
- loggerCache.set(scope, scopedConsola);
22
- }
23
- const logger = scopedConsola;
24
- function isEnabled(level) {
25
- const levelNum = LOG_LEVELS[level];
26
- if (isScopeDebugEnabled && level === "debug") {
27
- return true;
28
- }
29
- return levelNum >= globalLevelNum;
30
- }
31
- function log(level, message, context) {
32
- if (!isEnabled(level)) return;
33
- if (context && Object.keys(context).length > 0) {
34
- logger[level](message, context);
35
- } else {
36
- logger[level](message);
37
- }
38
- }
39
- return {
40
- debug: (message, context) => log("debug", message, context),
41
- info: (message, context) => log("info", message, context),
42
- warn: (message, context) => log("warn", message, context),
43
- error: (message, context) => log("error", message, context),
44
- log,
45
- isEnabled,
46
- consola: logger
47
- };
48
- }
49
- export function isDebugEnabled() {
50
- const rc = useRuntimeConfig();
51
- const debugConfig = rc?.nvent?.debug;
52
- const level = debugConfig?.level || process.env.NQ_DEBUG_LEVEL;
53
- return level === "debug" || Object.keys(debugConfig || {}).some((key) => key !== "level");
54
- }
@@ -1,6 +0,0 @@
1
- import type { RunContext } from '../worker/node/runner.js';
2
- /**
3
- * Create a minimal RunContext for use in lifecycle hooks and event handlers
4
- * This is a lightweight version without the full worker context
5
- */
6
- export declare function useRunContext(partial?: Partial<RunContext>): RunContext;
@@ -1,102 +0,0 @@
1
- import { useEventManager, useFlow, useRuntimeConfig, useStateAdapter } from "#imports";
2
- const defaultState = {
3
- async get() {
4
- return null;
5
- },
6
- async set() {
7
- },
8
- async delete() {
9
- }
10
- };
11
- function scopeKey(baseKey, flowId) {
12
- if (!flowId) return baseKey;
13
- return `flow:${flowId}:${baseKey}`;
14
- }
15
- export function useRunContext(partial) {
16
- const state = partial?.state || (() => {
17
- try {
18
- const stateAdapter = useStateAdapter();
19
- const rc = useRuntimeConfig();
20
- const cleanupCfg = rc?.nvent?.state?.cleanup || { strategy: "never" };
21
- return {
22
- async get(key) {
23
- return stateAdapter.get(scopeKey(key, partial?.flowId));
24
- },
25
- async set(key, value, opts) {
26
- const ttl = opts?.ttl ?? (cleanupCfg?.strategy === "ttl" ? cleanupCfg?.ttlMs : void 0);
27
- return stateAdapter.set(scopeKey(key, partial?.flowId), value, ttl ? { ttl } : void 0);
28
- },
29
- async delete(key) {
30
- return stateAdapter.delete(scopeKey(key, partial?.flowId));
31
- }
32
- };
33
- } catch {
34
- return defaultState;
35
- }
36
- })();
37
- const logger = partial?.logger || (() => {
38
- const eventManager = useEventManager();
39
- return {
40
- log: (level, msg, meta) => {
41
- const runId = partial?.flowId || "unknown";
42
- const flowName = meta?.flowName || partial?.flowName || "unknown";
43
- void eventManager.publishBus({
44
- type: "log",
45
- runId,
46
- flowName,
47
- stepName: meta?.stepName || partial?.stepName,
48
- stepId: meta?.stepId,
49
- attempt: meta?.attempt,
50
- data: { level, message: msg, ...meta }
51
- });
52
- }
53
- };
54
- })();
55
- const baseFlowEngine = useFlow();
56
- const flow = {
57
- ...baseFlowEngine,
58
- emit: async (trigger, payload = {}) => {
59
- const enrichedPayload = {
60
- ...payload,
61
- flowId: payload.flowId || partial?.flowId,
62
- flowName: payload.flowName || partial?.flowName,
63
- stepName: payload.stepName || partial?.stepName
64
- };
65
- return baseFlowEngine.emit(trigger, enrichedPayload);
66
- },
67
- cancel: async () => {
68
- if (!partial?.flowName || !partial?.flowId) {
69
- throw new Error("Cannot cancel flow: flowName or flowId not available in context");
70
- }
71
- return baseFlowEngine.cancelFlow(partial.flowName, partial.flowId);
72
- },
73
- isRunning: async (flowName, runId) => {
74
- const targetFlowName = flowName || partial?.flowName;
75
- if (!targetFlowName) {
76
- throw new Error("flowName is required to check if flow is running");
77
- }
78
- return baseFlowEngine.isRunning(targetFlowName, runId);
79
- },
80
- getRunningFlows: async (flowName) => {
81
- const targetFlowName = flowName || partial?.flowName;
82
- if (!targetFlowName) {
83
- throw new Error("flowName is required to get running flows");
84
- }
85
- return baseFlowEngine.getRunningFlows(targetFlowName);
86
- }
87
- };
88
- return {
89
- jobId: partial?.jobId,
90
- queue: partial?.queue,
91
- flowId: partial?.flowId,
92
- flowName: partial?.flowName,
93
- stepName: partial?.stepName,
94
- stepId: partial?.stepId,
95
- attempt: partial?.attempt,
96
- logger,
97
- state,
98
- flow,
99
- trigger: partial?.trigger,
100
- awaitConfig: partial?.awaitConfig
101
- };
102
- }
@@ -1,83 +0,0 @@
1
- export declare function useStreamTopics(): {
2
- StoreSubjects: {
3
- /**
4
- * Flow run event stream
5
- * Pattern: {prefix}:flow:run:{runId}
6
- * Type: Redis Stream (XADD/XRANGE)
7
- * Contains: All events for a specific flow run
8
- */
9
- readonly flowRun: (runId: string) => string;
10
- /**
11
- * Flow runs index (sorted set)
12
- * Pattern: {prefix}:flow:runs:{flowName}
13
- * Type: Sorted Set + Hash metadata
14
- * Contains: List of run IDs for a flow, sorted by timestamp
15
- */
16
- readonly flowRunIndex: (flowName: string) => string;
17
- /**
18
- * Flows index (sorted set)
19
- * Pattern: {prefix}:flows
20
- * Type: Sorted Set + Hash metadata
21
- * Contains: Flow metadata and statistics
22
- */
23
- readonly flowIndex: () => string;
24
- /**
25
- * Trigger event stream
26
- * Pattern: {prefix}:trigger:event:{triggerName}
27
- * Type: Redis Stream (XADD/XRANGE)
28
- * Contains: All events for a specific trigger
29
- */
30
- readonly triggerStream: (triggerName: string) => string;
31
- /**
32
- * Triggers index (sorted set)
33
- * Pattern: {prefix}:triggers
34
- * Type: Sorted Set + Hash metadata
35
- * Contains: Trigger metadata, subscriptions, and statistics
36
- */
37
- readonly triggerIndex: () => string;
38
- /**
39
- * Scheduler job index
40
- * Pattern: {prefix}:scheduler:jobs
41
- * Type: Sorted Set + Hash metadata
42
- * Contains: Scheduled job metadata
43
- */
44
- readonly schedulerJobs: () => string;
45
- /**
46
- * Scheduler lock index
47
- * Pattern: {prefix}:scheduler:locks
48
- * Type: Sorted Set + Hash metadata
49
- * Contains: Distributed scheduler lock metadata
50
- */
51
- readonly schedulerLocks: () => string;
52
- };
53
- StreamTopics: {
54
- /**
55
- * Flow events for a specific run
56
- * Pattern: {prefix}:stream:flow:events:{runId}
57
- * Published: When flow events occur (StreamWiring)
58
- * Subscribed: By WebSocket clients watching a specific flow run
59
- */
60
- readonly flowEvents: (runId: string) => string;
61
- /**
62
- * Flow statistics updates
63
- * Pattern: {prefix}:stream:flow:stats
64
- * Published: When flow stats change (StreamWiring)
65
- * Subscribed: By WebSocket clients watching flow overview
66
- */
67
- readonly flowStats: () => string;
68
- /**
69
- * Trigger events for a specific trigger
70
- * Pattern: {prefix}:stream:trigger:events:{triggerName}
71
- * Published: When trigger events occur (StreamWiring)
72
- * Subscribed: By WebSocket clients watching a specific trigger
73
- */
74
- readonly triggerEvents: (triggerName: string) => string;
75
- /**
76
- * Trigger statistics updates
77
- * Pattern: {prefix}:stream:trigger:stats
78
- * Published: When trigger stats change (StreamWiring)
79
- * Subscribed: By WebSocket clients watching trigger overview
80
- */
81
- readonly triggerStats: () => string;
82
- };
83
- };
@@ -1,94 +0,0 @@
1
- import { useRuntimeConfig } from "#imports";
2
- function getStoreSubjects(prefix) {
3
- return {
4
- /**
5
- * Flow run event stream
6
- * Pattern: {prefix}:flow:run:{runId}
7
- * Type: Redis Stream (XADD/XRANGE)
8
- * Contains: All events for a specific flow run
9
- */
10
- flowRun: (runId) => `${prefix}:flow:run:${runId}`,
11
- /**
12
- * Flow runs index (sorted set)
13
- * Pattern: {prefix}:flow:runs:{flowName}
14
- * Type: Sorted Set + Hash metadata
15
- * Contains: List of run IDs for a flow, sorted by timestamp
16
- */
17
- flowRunIndex: (flowName) => `${prefix}:flow:runs:${flowName}`,
18
- /**
19
- * Flows index (sorted set)
20
- * Pattern: {prefix}:flows
21
- * Type: Sorted Set + Hash metadata
22
- * Contains: Flow metadata and statistics
23
- */
24
- flowIndex: () => `${prefix}:flows`,
25
- /**
26
- * Trigger event stream
27
- * Pattern: {prefix}:trigger:event:{triggerName}
28
- * Type: Redis Stream (XADD/XRANGE)
29
- * Contains: All events for a specific trigger
30
- */
31
- triggerStream: (triggerName) => `${prefix}:trigger:event:${triggerName}`,
32
- /**
33
- * Triggers index (sorted set)
34
- * Pattern: {prefix}:triggers
35
- * Type: Sorted Set + Hash metadata
36
- * Contains: Trigger metadata, subscriptions, and statistics
37
- */
38
- triggerIndex: () => `${prefix}:triggers`,
39
- /**
40
- * Scheduler job index
41
- * Pattern: {prefix}:scheduler:jobs
42
- * Type: Sorted Set + Hash metadata
43
- * Contains: Scheduled job metadata
44
- */
45
- schedulerJobs: () => `${prefix}:scheduler:jobs`,
46
- /**
47
- * Scheduler lock index
48
- * Pattern: {prefix}:scheduler:locks
49
- * Type: Sorted Set + Hash metadata
50
- * Contains: Distributed scheduler lock metadata
51
- */
52
- schedulerLocks: () => `${prefix}:scheduler:locks`
53
- };
54
- }
55
- function getStreamTopics(prefix) {
56
- return {
57
- /**
58
- * Flow events for a specific run
59
- * Pattern: {prefix}:stream:flow:events:{runId}
60
- * Published: When flow events occur (StreamWiring)
61
- * Subscribed: By WebSocket clients watching a specific flow run
62
- */
63
- flowEvents: (runId) => `${prefix}:stream:flow:events:${runId}`,
64
- /**
65
- * Flow statistics updates
66
- * Pattern: {prefix}:stream:flow:stats
67
- * Published: When flow stats change (StreamWiring)
68
- * Subscribed: By WebSocket clients watching flow overview
69
- */
70
- flowStats: () => `${prefix}:stream:flow:stats`,
71
- /**
72
- * Trigger events for a specific trigger
73
- * Pattern: {prefix}:stream:trigger:events:{triggerName}
74
- * Published: When trigger events occur (StreamWiring)
75
- * Subscribed: By WebSocket clients watching a specific trigger
76
- */
77
- triggerEvents: (triggerName) => `${prefix}:stream:trigger:events:${triggerName}`,
78
- /**
79
- * Trigger statistics updates
80
- * Pattern: {prefix}:stream:trigger:stats
81
- * Published: When trigger stats change (StreamWiring)
82
- * Subscribed: By WebSocket clients watching trigger overview
83
- */
84
- triggerStats: () => `${prefix}:stream:trigger:stats`
85
- };
86
- }
87
- export function useStreamTopics() {
88
- const config = useRuntimeConfig();
89
- const prefix = config.nvent.store?.prefix || "nvent";
90
- return {
91
- StoreSubjects: getStoreSubjects(prefix),
92
- StreamTopics: getStreamTopics(prefix)
93
- };
94
- }
@@ -1,150 +0,0 @@
1
- import type { TriggerEntry, TriggerSubscription } from '../../../registry/types.js';
2
- /**
3
- * Public export for resolving payload references
4
- * Allows external code to resolve references if needed
5
- */
6
- export declare function resolvePayload(data: any): Promise<any>;
7
- export interface RegisterTriggerOptions {
8
- name: string;
9
- type: 'event' | 'webhook' | 'schedule' | 'manual';
10
- scope: 'flow' | 'run';
11
- status?: 'active' | 'inactive' | 'retired';
12
- displayName?: string;
13
- description?: string;
14
- source?: string;
15
- expectedSubscribers?: string[];
16
- webhook?: {
17
- path: string;
18
- method?: string;
19
- auth?: any;
20
- };
21
- schedule?: {
22
- cron: string;
23
- timezone?: string;
24
- enabled?: boolean;
25
- };
26
- schema?: any;
27
- transform?: (data: any) => any;
28
- config?: {
29
- persistData?: boolean;
30
- payloadThreshold?: number;
31
- retentionDays?: number;
32
- rateLimit?: {
33
- max: number;
34
- window: number;
35
- };
36
- };
37
- }
38
- export interface SubscribeTriggerOptions {
39
- trigger: string;
40
- flow: string;
41
- mode?: 'auto' | 'manual';
42
- filter?: (data: any) => boolean;
43
- transform?: (data: any) => any;
44
- }
45
- /**
46
- * Core trigger composable
47
- * Provides runtime API for trigger registration and emission
48
- */
49
- export declare function useTrigger(): {
50
- /**
51
- * Register a trigger (programmatic)
52
- * Publishes event to bus - triggerWiring handles persistence and orchestration
53
- */
54
- registerTrigger(opts: RegisterTriggerOptions): Promise<void>;
55
- /**
56
- * Subscribe flow to trigger (programmatic)
57
- * Publishes event to bus - triggerWiring handles persistence and orchestration
58
- */
59
- subscribeTrigger(opts: SubscribeTriggerOptions): Promise<void>;
60
- /**
61
- * Unsubscribe flow from trigger
62
- * Publishes event to bus - triggerWiring handles persistence and orchestration
63
- */
64
- unsubscribeTrigger(trigger: string, flow: string): Promise<void>;
65
- /**
66
- * Emit trigger (fire event)
67
- * Publishes event to bus - triggerWiring handles persistence, stats, and orchestration
68
- *
69
- * Large payloads are automatically stored in KV store and replaced with references
70
- * to keep stream events small and memory-efficient.
71
- */
72
- emitTrigger(name: string, data: any, opts?: {
73
- payloadThreshold?: number;
74
- }): Promise<void>;
75
- /**
76
- * Query methods
77
- */
78
- /**
79
- * Check if a trigger exists in the registry
80
- */
81
- hasTrigger(name: string): boolean;
82
- /**
83
- * Get trigger entry by name
84
- */
85
- getTrigger(name: string): TriggerEntry | undefined;
86
- /**
87
- * Get all registered triggers
88
- * @param options - Sorting and pagination options
89
- * @param options.sortBy - Field to sort by
90
- * @param options.order - Sort order (asc or desc)
91
- * @param options.limit - Maximum number of results
92
- * @param options.offset - Number of results to skip
93
- */
94
- getAllTriggers(options?: {
95
- sortBy?: "registeredAt" | "lastActivityAt" | "name";
96
- order?: "asc" | "desc";
97
- limit?: number;
98
- offset?: number;
99
- }): TriggerEntry[];
100
- /**
101
- * Get all flows subscribed to a specific trigger
102
- */
103
- getSubscribedFlows(trigger: string): string[];
104
- /**
105
- * Get all triggers that a flow is subscribed to
106
- */
107
- getFlowTriggers(flow: string): string[];
108
- /**
109
- * Get subscription details for a specific trigger-flow pair
110
- */
111
- getSubscription(trigger: string, flow: string): TriggerSubscription | undefined;
112
- getAllSubscriptions(): TriggerSubscription[];
113
- /**
114
- * Initialize runtime from store (called on startup)
115
- * Uses index + stream architecture (v0.5.1)
116
- */
117
- initialize(): Promise<void>;
118
- /**
119
- * Get runtime state (for debugging)
120
- */
121
- getRuntime(): {
122
- triggerCount: number;
123
- subscriptionCount: number;
124
- flowCount: number;
125
- initialized: boolean;
126
- };
127
- /**
128
- * Delete a trigger completely (removes all data)
129
- * Publishes event to bus - triggerWiring handles persistence and orchestration
130
- */
131
- deleteTrigger(name: string): Promise<void>;
132
- /**
133
- * Update trigger status (active/inactive/retired)
134
- * For future status management UI
135
- */
136
- updateTriggerStatus(name: string, status: "active" | "inactive" | "retired"): Promise<void>;
137
- /**
138
- * Get trigger statistics
139
- * v0.5.1: New analytics method
140
- */
141
- getTriggerStats(name: string): Promise<any>;
142
- /**
143
- * Get trigger history from stream
144
- * v0.5.1: New analytics method
145
- */
146
- getTriggerHistory(name: string, opts?: {
147
- limit?: number;
148
- types?: string[];
149
- }): Promise<any>;
150
- };