nvent 0.4.3 → 0.4.5
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 +3 -184
- package/dist/module.json +3 -3
- package/dist/module.mjs +133 -197
- package/dist/runtime/adapters/builtin/file-queue.d.ts +53 -0
- package/dist/runtime/adapters/builtin/file-queue.js +435 -0
- package/dist/runtime/adapters/builtin/file-store.d.ts +46 -0
- package/dist/runtime/adapters/builtin/file-store.js +225 -0
- package/dist/runtime/adapters/builtin/file-stream.d.ts +39 -0
- package/dist/runtime/adapters/builtin/file-stream.js +56 -0
- package/dist/runtime/adapters/builtin/index.d.ts +10 -0
- package/dist/runtime/adapters/builtin/index.js +5 -0
- package/dist/runtime/adapters/builtin/memory-queue.d.ts +52 -0
- package/dist/runtime/adapters/builtin/memory-queue.js +239 -0
- package/dist/runtime/adapters/builtin/memory-store.d.ts +57 -0
- package/dist/runtime/adapters/builtin/memory-store.js +263 -0
- package/dist/runtime/adapters/builtin/memory-stream.d.ts +21 -0
- package/dist/runtime/adapters/builtin/memory-stream.js +56 -0
- package/dist/runtime/adapters/factory.d.ts +31 -0
- package/dist/runtime/adapters/factory.js +100 -0
- package/dist/runtime/adapters/index.d.ts +8 -0
- package/dist/runtime/adapters/index.js +3 -0
- package/dist/runtime/adapters/interfaces/index.d.ts +11 -0
- package/dist/runtime/adapters/interfaces/index.js +3 -0
- package/dist/runtime/adapters/interfaces/queue.d.ts +150 -0
- package/dist/runtime/adapters/interfaces/store.d.ts +233 -0
- package/dist/runtime/adapters/interfaces/stream.d.ts +62 -0
- package/dist/runtime/adapters/registry.d.ts +85 -0
- package/dist/runtime/adapters/registry.js +161 -0
- package/dist/runtime/config/index.d.ts +29 -0
- package/dist/runtime/config/index.js +167 -0
- package/dist/runtime/config/types.d.ts +367 -0
- package/dist/runtime/config/types.js +0 -0
- package/dist/runtime/events/types.d.ts +116 -0
- package/dist/runtime/events/types.js +0 -0
- package/dist/runtime/events/utils/stallDetector.d.ts +99 -0
- package/dist/runtime/events/utils/stallDetector.js +237 -0
- package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.d.ts +3 -8
- package/dist/runtime/{server-utils/events → events}/wiring/flowWiring.js +119 -36
- package/dist/runtime/events/wiring/registry.d.ts +19 -0
- package/dist/runtime/events/wiring/registry.js +33 -0
- package/dist/runtime/events/wiring/stateWiring.d.ts +37 -0
- package/dist/runtime/events/wiring/stateWiring.js +92 -0
- package/dist/runtime/events/wiring/streamWiring.d.ts +32 -0
- package/dist/runtime/events/wiring/streamWiring.js +79 -0
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +16 -5
- package/dist/runtime/server/api/_flows/[name]/runs/[runId]/cancel.post.js +21 -0
- package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +12 -2
- package/dist/runtime/server/api/_flows/[name]/runs.get.js +15 -4
- package/dist/runtime/server/api/_flows/[name]/schedule.post.js +11 -2
- package/dist/runtime/server/api/_flows/[name]/schedules/[id].delete.js +21 -16
- package/dist/runtime/server/api/_flows/[name]/schedules.get.js +21 -19
- package/dist/runtime/server/api/_flows/ws.js +43 -22
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +8 -3
- package/dist/runtime/server/api/_queues/[name]/job/index.get.js +12 -3
- package/dist/runtime/server/api/_queues/index.get.js +66 -23
- package/dist/runtime/server/api/_queues/ws.js +14 -4
- package/dist/runtime/server/plugins/00.adapters.d.ts +14 -0
- package/dist/runtime/server/plugins/00.adapters.js +69 -0
- package/dist/runtime/server/plugins/02.workers.js +45 -0
- package/dist/runtime/tsconfig.json +8 -0
- package/dist/runtime/utils/adapters.d.ts +66 -0
- package/dist/runtime/utils/adapters.js +51 -0
- package/dist/runtime/utils/defineFunction.d.ts +10 -0
- package/dist/runtime/{server-utils/utils/defineQueueWorker.js → utils/defineFunction.js} +4 -4
- package/dist/runtime/{server-utils/utils/defineQueueConfig.d.ts → utils/defineFunctionConfig.d.ts} +3 -3
- package/dist/runtime/utils/defineFunctionConfig.js +2 -0
- package/dist/runtime/utils/registerAdapter.d.ts +59 -0
- package/dist/runtime/utils/registerAdapter.js +13 -0
- package/dist/runtime/utils/useFlowEngine.d.ts +19 -0
- package/dist/runtime/utils/useFlowEngine.js +108 -0
- package/dist/runtime/{server-utils/utils → utils}/useNventLogger.js +2 -2
- package/dist/runtime/utils/useStreamTopics.d.ts +72 -0
- package/dist/runtime/utils/useStreamTopics.js +47 -0
- package/dist/runtime/{server-utils/worker/runner/node.d.ts → worker/node/runner.d.ts} +18 -2
- package/dist/runtime/{server-utils/worker/runner/node.js → worker/node/runner.js} +44 -17
- package/dist/types.d.mts +2 -2
- package/package.json +14 -44
- package/LICENSE +0 -21
- package/README.md +0 -389
- package/dist/runtime/app/assets/vueflow.css +0 -1
- package/dist/runtime/app/components/ConfirmDialog.d.vue.ts +0 -33
- package/dist/runtime/app/components/ConfirmDialog.vue +0 -121
- package/dist/runtime/app/components/ConfirmDialog.vue.d.ts +0 -33
- package/dist/runtime/app/components/FlowDiagram.d.vue.ts +0 -64
- package/dist/runtime/app/components/FlowDiagram.vue +0 -338
- package/dist/runtime/app/components/FlowDiagram.vue.d.ts +0 -64
- package/dist/runtime/app/components/FlowNodeCard.d.vue.ts +0 -29
- package/dist/runtime/app/components/FlowNodeCard.vue +0 -156
- package/dist/runtime/app/components/FlowNodeCard.vue.d.ts +0 -29
- package/dist/runtime/app/components/FlowRunOverview.d.vue.ts +0 -9
- package/dist/runtime/app/components/FlowRunOverview.vue +0 -291
- package/dist/runtime/app/components/FlowRunOverview.vue.d.ts +0 -9
- package/dist/runtime/app/components/FlowRunStatusBadge.d.vue.ts +0 -14
- package/dist/runtime/app/components/FlowRunStatusBadge.vue +0 -60
- package/dist/runtime/app/components/FlowRunStatusBadge.vue.d.ts +0 -14
- package/dist/runtime/app/components/FlowRunTimeline.d.vue.ts +0 -12
- package/dist/runtime/app/components/FlowRunTimeline.vue +0 -127
- package/dist/runtime/app/components/FlowRunTimeline.vue.d.ts +0 -12
- package/dist/runtime/app/components/FlowScheduleDialog.d.vue.ts +0 -16
- package/dist/runtime/app/components/FlowScheduleDialog.vue +0 -226
- package/dist/runtime/app/components/FlowScheduleDialog.vue.d.ts +0 -16
- package/dist/runtime/app/components/FlowSchedulesList.d.vue.ts +0 -12
- package/dist/runtime/app/components/FlowSchedulesList.vue +0 -99
- package/dist/runtime/app/components/FlowSchedulesList.vue.d.ts +0 -12
- package/dist/runtime/app/components/JobScheduling.d.vue.ts +0 -6
- package/dist/runtime/app/components/JobScheduling.vue +0 -203
- package/dist/runtime/app/components/JobScheduling.vue.d.ts +0 -6
- package/dist/runtime/app/components/ListItem.d.vue.ts +0 -23
- package/dist/runtime/app/components/ListItem.vue +0 -70
- package/dist/runtime/app/components/ListItem.vue.d.ts +0 -23
- package/dist/runtime/app/components/QueueConfigDetails.d.vue.ts +0 -45
- package/dist/runtime/app/components/QueueConfigDetails.vue +0 -412
- package/dist/runtime/app/components/QueueConfigDetails.vue.d.ts +0 -45
- package/dist/runtime/app/components/StatCounter.d.vue.ts +0 -9
- package/dist/runtime/app/components/StatCounter.vue +0 -25
- package/dist/runtime/app/components/StatCounter.vue.d.ts +0 -9
- package/dist/runtime/app/components/TimelineList.d.vue.ts +0 -7
- package/dist/runtime/app/components/TimelineList.vue +0 -210
- package/dist/runtime/app/components/TimelineList.vue.d.ts +0 -7
- package/dist/runtime/app/components/nhealth/component-router.d.vue.ts +0 -46
- package/dist/runtime/app/components/nhealth/component-router.vue +0 -26
- package/dist/runtime/app/components/nhealth/component-router.vue.d.ts +0 -46
- package/dist/runtime/app/components/nhealth/component-shell.d.vue.ts +0 -24
- package/dist/runtime/app/components/nhealth/component-shell.vue +0 -89
- package/dist/runtime/app/components/nhealth/component-shell.vue.d.ts +0 -24
- package/dist/runtime/app/composables/useAnalyzedFlows.d.ts +0 -14
- package/dist/runtime/app/composables/useAnalyzedFlows.js +0 -8
- package/dist/runtime/app/composables/useComponentRouter.d.ts +0 -38
- package/dist/runtime/app/composables/useComponentRouter.js +0 -240
- package/dist/runtime/app/composables/useFlowRunTimeline.d.ts +0 -15
- package/dist/runtime/app/composables/useFlowRunTimeline.js +0 -66
- package/dist/runtime/app/composables/useFlowRuns.d.ts +0 -18
- package/dist/runtime/app/composables/useFlowRuns.js +0 -32
- package/dist/runtime/app/composables/useFlowRunsInfinite.d.ts +0 -24
- package/dist/runtime/app/composables/useFlowRunsInfinite.js +0 -123
- package/dist/runtime/app/composables/useFlowRunsPolling.d.ts +0 -9
- package/dist/runtime/app/composables/useFlowRunsPolling.js +0 -33
- package/dist/runtime/app/composables/useFlowState.d.ts +0 -125
- package/dist/runtime/app/composables/useFlowState.js +0 -211
- package/dist/runtime/app/composables/useFlowWebSocket.d.ts +0 -27
- package/dist/runtime/app/composables/useFlowWebSocket.js +0 -205
- package/dist/runtime/app/composables/useFlowsNavigation.d.ts +0 -10
- package/dist/runtime/app/composables/useFlowsNavigation.js +0 -58
- package/dist/runtime/app/composables/useQueueJobs.d.ts +0 -20
- package/dist/runtime/app/composables/useQueueJobs.js +0 -20
- package/dist/runtime/app/composables/useQueueUpdates.d.ts +0 -26
- package/dist/runtime/app/composables/useQueueUpdates.js +0 -122
- package/dist/runtime/app/composables/useQueues.d.ts +0 -44
- package/dist/runtime/app/composables/useQueues.js +0 -26
- package/dist/runtime/app/composables/useQueuesLive.d.ts +0 -19
- package/dist/runtime/app/composables/useQueuesLive.js +0 -143
- package/dist/runtime/app/pages/flows/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/flows/index.vue +0 -645
- package/dist/runtime/app/pages/flows/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/index.vue +0 -34
- package/dist/runtime/app/pages/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/index.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/index.vue +0 -229
- package/dist/runtime/app/pages/queues/index.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/job.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/job.vue +0 -262
- package/dist/runtime/app/pages/queues/job.vue.d.ts +0 -3
- package/dist/runtime/app/pages/queues/jobs.d.vue.ts +0 -3
- package/dist/runtime/app/pages/queues/jobs.vue +0 -291
- package/dist/runtime/app/pages/queues/jobs.vue.d.ts +0 -3
- package/dist/runtime/app/plugins/vueflow.client.d.ts +0 -2
- package/dist/runtime/app/plugins/vueflow.client.js +0 -11
- package/dist/runtime/constants.d.ts +0 -11
- package/dist/runtime/constants.js +0 -11
- package/dist/runtime/schema.d.ts +0 -37
- package/dist/runtime/schema.js +0 -20
- package/dist/runtime/server/plugins/00.event-store.d.ts +0 -13
- package/dist/runtime/server/plugins/00.event-store.js +0 -16
- package/dist/runtime/server/plugins/flow-management.d.ts +0 -13
- package/dist/runtime/server/plugins/flow-management.js +0 -65
- package/dist/runtime/server/plugins/queue-management.js +0 -27
- package/dist/runtime/server/plugins/state-cleanup.d.ts +0 -11
- package/dist/runtime/server/plugins/state-cleanup.js +0 -93
- package/dist/runtime/server/plugins/worker-management.js +0 -33
- package/dist/runtime/server/tsconfig.json +0 -3
- package/dist/runtime/server-utils/events/adapters/fileAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/fileAdapter.js +0 -382
- package/dist/runtime/server-utils/events/adapters/memoryAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/memoryAdapter.js +0 -171
- package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.d.ts +0 -2
- package/dist/runtime/server-utils/events/adapters/redis/redisAdapter.js +0 -348
- package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.d.ts +0 -30
- package/dist/runtime/server-utils/events/adapters/redis/redisPubSubGateway.js +0 -82
- package/dist/runtime/server-utils/events/eventStoreFactory.d.ts +0 -19
- package/dist/runtime/server-utils/events/eventStoreFactory.js +0 -44
- package/dist/runtime/server-utils/events/streamNames.d.ts +0 -17
- package/dist/runtime/server-utils/events/streamNames.js +0 -17
- package/dist/runtime/server-utils/events/types.d.ts +0 -63
- package/dist/runtime/server-utils/events/wiring/registry.d.ts +0 -10
- package/dist/runtime/server-utils/events/wiring/registry.js +0 -24
- package/dist/runtime/server-utils/queue/adapters/bullmq.d.ts +0 -18
- package/dist/runtime/server-utils/queue/adapters/bullmq.js +0 -164
- package/dist/runtime/server-utils/queue/queueFactory.d.ts +0 -3
- package/dist/runtime/server-utils/queue/queueFactory.js +0 -10
- package/dist/runtime/server-utils/queue/types.d.ts +0 -47
- package/dist/runtime/server-utils/state/adapters/redis.d.ts +0 -2
- package/dist/runtime/server-utils/state/adapters/redis.js +0 -42
- package/dist/runtime/server-utils/state/stateFactory.d.ts +0 -3
- package/dist/runtime/server-utils/state/stateFactory.js +0 -17
- package/dist/runtime/server-utils/state/types.d.ts +0 -23
- package/dist/runtime/server-utils/utils/defineQueueConfig.js +0 -2
- package/dist/runtime/server-utils/utils/defineQueueWorker.d.ts +0 -10
- package/dist/runtime/server-utils/utils/useEventStore.d.ts +0 -20
- package/dist/runtime/server-utils/utils/useEventStore.js +0 -119
- package/dist/runtime/server-utils/utils/useFlowEngine.d.ts +0 -9
- package/dist/runtime/server-utils/utils/useFlowEngine.js +0 -44
- package/dist/runtime/server-utils/utils/useLogs.d.ts +0 -41
- package/dist/runtime/server-utils/utils/useLogs.js +0 -74
- package/dist/runtime/server-utils/utils/useQueue.d.ts +0 -31
- package/dist/runtime/server-utils/utils/useQueue.js +0 -24
- package/dist/runtime/server-utils/worker/adapter.d.ts +0 -4
- package/dist/runtime/server-utils/worker/adapter.js +0 -66
- package/dist/runtime/types.d.ts +0 -132
- /package/dist/runtime/{server-utils/events/types.js → adapters/interfaces/queue.js} +0 -0
- /package/dist/runtime/{server-utils/queue/types.js → adapters/interfaces/store.js} +0 -0
- /package/dist/runtime/{server-utils/state/types.js → adapters/interfaces/stream.js} +0 -0
- /package/dist/runtime/{server-utils/events → events}/eventBus.d.ts +0 -0
- /package/dist/runtime/{server-utils/events → events}/eventBus.js +0 -0
- /package/dist/runtime/server/{plugins/queue-management.d.ts → api/_flows/[name]/runs/[runId]/cancel.post.d.ts} +0 -0
- /package/dist/runtime/server/plugins/{00.ws-lifecycle.d.ts → 01.ws-lifecycle.d.ts} +0 -0
- /package/dist/runtime/server/plugins/{00.ws-lifecycle.js → 01.ws-lifecycle.js} +0 -0
- /package/dist/runtime/server/plugins/{worker-management.d.ts → 02.workers.d.ts} +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/useEventManager.d.ts +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/useEventManager.js +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/useNventLogger.d.ts +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/wsPeerManager.d.ts +0 -0
- /package/dist/runtime/{server-utils/utils → utils}/wsPeerManager.js +0 -0
- /package/dist/runtime/{python → worker/python}/get_config.py +0 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store Adapter Interface
|
|
3
|
+
*
|
|
4
|
+
* Three-tier storage system:
|
|
5
|
+
* 1. Event Stream - Append-only event log (replaces EventStore)
|
|
6
|
+
* 2. Document Store - Generic document storage (for flow wiring, triggers, metadata)
|
|
7
|
+
* 3. Key-Value Store - Fast lookups (for state, caching)
|
|
8
|
+
*/
|
|
9
|
+
export interface StoreAdapter {
|
|
10
|
+
/**
|
|
11
|
+
* Close/cleanup the adapter
|
|
12
|
+
*/
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Append an event to a subject's event stream
|
|
16
|
+
* @param subject - Event stream identifier (e.g., 'nq:flow:abc-123')
|
|
17
|
+
* @param event - Event to append (id and ts will be auto-generated)
|
|
18
|
+
* @returns The complete event record with generated id and timestamp
|
|
19
|
+
*/
|
|
20
|
+
append(subject: string, event: Omit<EventRecord, 'id' | 'ts'>): Promise<EventRecord>;
|
|
21
|
+
/**
|
|
22
|
+
* Read events from a subject's event stream
|
|
23
|
+
* @param subject - Event stream identifier
|
|
24
|
+
* @param opts - Query options (filtering, pagination, etc.)
|
|
25
|
+
* @returns Array of event records
|
|
26
|
+
*/
|
|
27
|
+
read(subject: string, opts?: EventReadOptions): Promise<EventRecord[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Subscribe to new events in a subject's event stream (optional, not all adapters support this)
|
|
30
|
+
* @param subject - Event stream identifier (supports wildcards if adapter allows)
|
|
31
|
+
* @param onEvent - Callback for new events
|
|
32
|
+
* @returns Subscription handle for unsubscribing
|
|
33
|
+
*/
|
|
34
|
+
subscribe?(subject: string, onEvent: (event: EventRecord) => void): Promise<EventSubscription>;
|
|
35
|
+
/**
|
|
36
|
+
* Save a document to a collection
|
|
37
|
+
* @param collection - Collection name (e.g., 'flow-wiring', 'triggers', 'flow-metadata')
|
|
38
|
+
* @param id - Document ID
|
|
39
|
+
* @param doc - Document data
|
|
40
|
+
*/
|
|
41
|
+
save(collection: string, id: string, doc: Record<string, any>): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Get a document from a collection
|
|
44
|
+
* @param collection - Collection name
|
|
45
|
+
* @param id - Document ID
|
|
46
|
+
* @returns Document or null if not found
|
|
47
|
+
*/
|
|
48
|
+
get(collection: string, id: string): Promise<Record<string, any> | null>;
|
|
49
|
+
/**
|
|
50
|
+
* List documents in a collection (optional, not all adapters may support complex queries)
|
|
51
|
+
* @param collection - Collection name
|
|
52
|
+
* @param opts - Query options (filtering, pagination, sorting)
|
|
53
|
+
* @returns Array of documents with their IDs
|
|
54
|
+
*/
|
|
55
|
+
list?(collection: string, opts?: ListOptions): Promise<Array<{
|
|
56
|
+
id: string;
|
|
57
|
+
doc: any;
|
|
58
|
+
}>>;
|
|
59
|
+
/**
|
|
60
|
+
* Delete a document from a collection
|
|
61
|
+
* @param collection - Collection name
|
|
62
|
+
* @param id - Document ID
|
|
63
|
+
*/
|
|
64
|
+
delete(collection: string, id: string): Promise<void>;
|
|
65
|
+
kv: {
|
|
66
|
+
/**
|
|
67
|
+
* Get a value by key
|
|
68
|
+
*/
|
|
69
|
+
get<T = any>(key: string): Promise<T | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Set a value with optional TTL
|
|
72
|
+
* @param key - Key
|
|
73
|
+
* @param value - Value to store
|
|
74
|
+
* @param ttl - Time to live in seconds (optional)
|
|
75
|
+
*/
|
|
76
|
+
set<T = any>(key: string, value: T, ttl?: number): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Delete a key
|
|
79
|
+
*/
|
|
80
|
+
delete(key: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Delete all keys matching a pattern (optional, not all adapters support patterns)
|
|
83
|
+
* @returns Number of keys deleted
|
|
84
|
+
*/
|
|
85
|
+
clear?(pattern: string): Promise<number>;
|
|
86
|
+
/**
|
|
87
|
+
* Atomic increment operation (optional, for counters)
|
|
88
|
+
* @returns New value after increment
|
|
89
|
+
*/
|
|
90
|
+
increment?(key: string, by?: number): Promise<number>;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Add entry to a sorted index (optional, for efficient time-ordered listings)
|
|
94
|
+
* @param key - Index key (e.g., 'nq:flows:flowName')
|
|
95
|
+
* @param id - Entry ID
|
|
96
|
+
* @param score - Sort score (typically timestamp)
|
|
97
|
+
* @param metadata - Optional metadata to store with entry
|
|
98
|
+
*/
|
|
99
|
+
indexAdd?(key: string, id: string, score: number, metadata?: Record<string, any>): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Get a single entry from a sorted index
|
|
102
|
+
* @param key - Index key
|
|
103
|
+
* @param id - Entry ID
|
|
104
|
+
* @returns Entry with score and metadata, or null if not found
|
|
105
|
+
*/
|
|
106
|
+
indexGet?(key: string, id: string): Promise<{
|
|
107
|
+
id: string;
|
|
108
|
+
score: number;
|
|
109
|
+
metadata?: any;
|
|
110
|
+
} | null>;
|
|
111
|
+
/**
|
|
112
|
+
* Read entries from a sorted index (ordered by score descending)
|
|
113
|
+
* @param key - Index key
|
|
114
|
+
* @param opts - Pagination options
|
|
115
|
+
* @param opts.offset - Number of entries to skip
|
|
116
|
+
* @param opts.limit - Maximum number of entries to return
|
|
117
|
+
* @returns Array of entries with scores and metadata
|
|
118
|
+
*/
|
|
119
|
+
indexRead?(key: string, opts?: {
|
|
120
|
+
offset?: number;
|
|
121
|
+
limit?: number;
|
|
122
|
+
}): Promise<Array<{
|
|
123
|
+
id: string;
|
|
124
|
+
score: number;
|
|
125
|
+
metadata?: any;
|
|
126
|
+
}>>;
|
|
127
|
+
/**
|
|
128
|
+
* Update metadata for an entry in a sorted index
|
|
129
|
+
* @param key - Index key
|
|
130
|
+
* @param id - Entry ID
|
|
131
|
+
* @param metadata - Metadata to update
|
|
132
|
+
* @returns True if update succeeded, false if version conflict
|
|
133
|
+
*/
|
|
134
|
+
indexUpdate?(key: string, id: string, metadata: Record<string, any>): Promise<boolean>;
|
|
135
|
+
/**
|
|
136
|
+
* Update with automatic retries on version conflicts
|
|
137
|
+
* @param key - Index key
|
|
138
|
+
* @param id - Entry ID
|
|
139
|
+
* @param metadata - Metadata to update
|
|
140
|
+
* @param maxRetries - Maximum retry attempts (default: 3)
|
|
141
|
+
*/
|
|
142
|
+
indexUpdateWithRetry?(key: string, id: string, metadata: Record<string, any>, maxRetries?: number): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Atomic increment of a metadata field in an index entry
|
|
145
|
+
* @param key - Index key
|
|
146
|
+
* @param id - Entry ID
|
|
147
|
+
* @param field - Field name to increment
|
|
148
|
+
* @param increment - Amount to increment by (default: 1)
|
|
149
|
+
* @returns New value after increment
|
|
150
|
+
*/
|
|
151
|
+
indexIncrement?(key: string, id: string, field: string, increment?: number): Promise<number>;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Event record in the event stream
|
|
155
|
+
* This is the storage representation - converts FlowEvent to/from storage format
|
|
156
|
+
*/
|
|
157
|
+
export interface EventRecord {
|
|
158
|
+
id: string;
|
|
159
|
+
ts: number;
|
|
160
|
+
type: string;
|
|
161
|
+
runId: string;
|
|
162
|
+
flowName: string;
|
|
163
|
+
stepName?: string;
|
|
164
|
+
stepId?: string;
|
|
165
|
+
attempt?: number;
|
|
166
|
+
data?: any;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Options for reading events from the event stream
|
|
170
|
+
*/
|
|
171
|
+
export interface EventReadOptions {
|
|
172
|
+
/**
|
|
173
|
+
* Filter by event types
|
|
174
|
+
*/
|
|
175
|
+
types?: string[];
|
|
176
|
+
/**
|
|
177
|
+
* Read events after this ID
|
|
178
|
+
*/
|
|
179
|
+
after?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Read events before this ID
|
|
182
|
+
*/
|
|
183
|
+
before?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Read events from this timestamp
|
|
186
|
+
*/
|
|
187
|
+
from?: number;
|
|
188
|
+
/**
|
|
189
|
+
* Read events until this timestamp
|
|
190
|
+
*/
|
|
191
|
+
to?: number;
|
|
192
|
+
/**
|
|
193
|
+
* Maximum number of events to return
|
|
194
|
+
*/
|
|
195
|
+
limit?: number;
|
|
196
|
+
/**
|
|
197
|
+
* Sort order ('asc' or 'desc')
|
|
198
|
+
*/
|
|
199
|
+
order?: 'asc' | 'desc';
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Subscription handle for event stream subscriptions
|
|
203
|
+
*/
|
|
204
|
+
export interface EventSubscription {
|
|
205
|
+
id: string;
|
|
206
|
+
subject: string;
|
|
207
|
+
unsubscribe: () => Promise<void>;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Options for listing documents
|
|
211
|
+
*/
|
|
212
|
+
export interface ListOptions {
|
|
213
|
+
/**
|
|
214
|
+
* Filter documents by field values
|
|
215
|
+
*/
|
|
216
|
+
filter?: Record<string, any>;
|
|
217
|
+
/**
|
|
218
|
+
* Maximum number of documents to return
|
|
219
|
+
*/
|
|
220
|
+
limit?: number;
|
|
221
|
+
/**
|
|
222
|
+
* Number of documents to skip
|
|
223
|
+
*/
|
|
224
|
+
offset?: number;
|
|
225
|
+
/**
|
|
226
|
+
* Sort by field
|
|
227
|
+
*/
|
|
228
|
+
sortBy?: string;
|
|
229
|
+
/**
|
|
230
|
+
* Sort order
|
|
231
|
+
*/
|
|
232
|
+
order?: 'asc' | 'desc';
|
|
233
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream Adapter Interface
|
|
3
|
+
*
|
|
4
|
+
* Handles pub/sub messaging for cross-instance communication
|
|
5
|
+
* Replaces the pub/sub functionality from EventStoreAdapter.subscribe()
|
|
6
|
+
*/
|
|
7
|
+
export interface StreamAdapter {
|
|
8
|
+
/**
|
|
9
|
+
* Initialize the stream adapter
|
|
10
|
+
*/
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Publish an event to a topic
|
|
14
|
+
*/
|
|
15
|
+
publish(topic: string, event: StreamEvent): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Subscribe to a topic
|
|
18
|
+
* @returns Subscription handle for unsubscribing
|
|
19
|
+
*/
|
|
20
|
+
subscribe(topic: string, handler: (event: StreamEvent) => void | Promise<void>, opts?: SubscribeOptions): Promise<SubscriptionHandle>;
|
|
21
|
+
/**
|
|
22
|
+
* Unsubscribe from a topic
|
|
23
|
+
*/
|
|
24
|
+
unsubscribe(handle: SubscriptionHandle): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* List all active topics
|
|
27
|
+
*/
|
|
28
|
+
listTopics(): Promise<string[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Get number of subscribers for a topic
|
|
31
|
+
*/
|
|
32
|
+
getSubscriptionCount(topic: string): Promise<number>;
|
|
33
|
+
/**
|
|
34
|
+
* Shutdown the adapter and cleanup resources
|
|
35
|
+
*/
|
|
36
|
+
shutdown(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export interface StreamEvent {
|
|
39
|
+
type: string;
|
|
40
|
+
data: any;
|
|
41
|
+
metadata?: Record<string, any>;
|
|
42
|
+
timestamp?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface SubscribeOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Consumer group for load balancing (if supported)
|
|
47
|
+
*/
|
|
48
|
+
group?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Filter events by type pattern
|
|
51
|
+
*/
|
|
52
|
+
filter?: string | RegExp;
|
|
53
|
+
/**
|
|
54
|
+
* Starting position (if supported by adapter)
|
|
55
|
+
*/
|
|
56
|
+
fromBeginning?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface SubscriptionHandle {
|
|
59
|
+
id: string;
|
|
60
|
+
topic: string;
|
|
61
|
+
unsubscribe: () => Promise<void>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all adapter types (queue, stream, store)
|
|
5
|
+
* Adapters are registered via the nvent:registerAdapter Nuxt hook
|
|
6
|
+
*/
|
|
7
|
+
import type { QueueAdapter, StreamAdapter, StoreAdapter } from './interfaces/index.js';
|
|
8
|
+
export declare class AdapterRegistry {
|
|
9
|
+
private queueAdapters;
|
|
10
|
+
private streamAdapters;
|
|
11
|
+
private storeAdapters;
|
|
12
|
+
/**
|
|
13
|
+
* Register a queue adapter
|
|
14
|
+
* @param name - Adapter name (e.g., 'redis', 'memory', 'postgres')
|
|
15
|
+
* @param adapter - QueueAdapter implementation
|
|
16
|
+
*/
|
|
17
|
+
registerQueue(name: string, adapter: QueueAdapter): void;
|
|
18
|
+
/**
|
|
19
|
+
* Register a stream adapter
|
|
20
|
+
* @param name - Adapter name (e.g., 'redis', 'memory', 'rabbitmq')
|
|
21
|
+
* @param adapter - StreamAdapter implementation
|
|
22
|
+
*/
|
|
23
|
+
registerStream(name: string, adapter: StreamAdapter): void;
|
|
24
|
+
/**
|
|
25
|
+
* Register a store adapter
|
|
26
|
+
* @param name - Adapter name (e.g., 'redis', 'memory', 'postgres')
|
|
27
|
+
* @param adapter - StoreAdapter implementation
|
|
28
|
+
*/
|
|
29
|
+
registerStore(name: string, adapter: StoreAdapter): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get a queue adapter by name
|
|
32
|
+
* @throws Error if adapter not found
|
|
33
|
+
*/
|
|
34
|
+
getQueue(name: string): QueueAdapter;
|
|
35
|
+
/**
|
|
36
|
+
* Get a stream adapter by name
|
|
37
|
+
* @throws Error if adapter not found
|
|
38
|
+
*/
|
|
39
|
+
getStream(name: string): StreamAdapter;
|
|
40
|
+
/**
|
|
41
|
+
* Get a store adapter by name
|
|
42
|
+
* @throws Error if adapter not found
|
|
43
|
+
*/
|
|
44
|
+
getStore(name: string): StoreAdapter;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a queue adapter is registered
|
|
47
|
+
*/
|
|
48
|
+
hasQueue(name: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Check if a stream adapter is registered
|
|
51
|
+
*/
|
|
52
|
+
hasStream(name: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Check if a store adapter is registered
|
|
55
|
+
*/
|
|
56
|
+
hasStore(name: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* List all registered queue adapters
|
|
59
|
+
*/
|
|
60
|
+
listQueueAdapters(): string[];
|
|
61
|
+
/**
|
|
62
|
+
* List all registered stream adapters
|
|
63
|
+
*/
|
|
64
|
+
listStreamAdapters(): string[];
|
|
65
|
+
/**
|
|
66
|
+
* List all registered store adapters
|
|
67
|
+
*/
|
|
68
|
+
listStoreAdapters(): string[];
|
|
69
|
+
/**
|
|
70
|
+
* Initialize all registered adapters
|
|
71
|
+
*/
|
|
72
|
+
initAll(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Close/cleanup all registered adapters
|
|
75
|
+
*/
|
|
76
|
+
closeAll(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the global adapter registry instance
|
|
80
|
+
*/
|
|
81
|
+
export declare function useAdapterRegistry(): AdapterRegistry;
|
|
82
|
+
/**
|
|
83
|
+
* Reset the registry (useful for testing)
|
|
84
|
+
*/
|
|
85
|
+
export declare function resetAdapterRegistry(): void;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
export class AdapterRegistry {
|
|
2
|
+
queueAdapters = /* @__PURE__ */ new Map();
|
|
3
|
+
streamAdapters = /* @__PURE__ */ new Map();
|
|
4
|
+
storeAdapters = /* @__PURE__ */ new Map();
|
|
5
|
+
// ============================================================
|
|
6
|
+
// Registration
|
|
7
|
+
// ============================================================
|
|
8
|
+
/**
|
|
9
|
+
* Register a queue adapter
|
|
10
|
+
* @param name - Adapter name (e.g., 'redis', 'memory', 'postgres')
|
|
11
|
+
* @param adapter - QueueAdapter implementation
|
|
12
|
+
*/
|
|
13
|
+
registerQueue(name, adapter) {
|
|
14
|
+
if (this.queueAdapters.has(name)) {
|
|
15
|
+
console.warn(`[nvent] Queue adapter "${name}" is already registered, overwriting`);
|
|
16
|
+
}
|
|
17
|
+
this.queueAdapters.set(name, adapter);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Register a stream adapter
|
|
21
|
+
* @param name - Adapter name (e.g., 'redis', 'memory', 'rabbitmq')
|
|
22
|
+
* @param adapter - StreamAdapter implementation
|
|
23
|
+
*/
|
|
24
|
+
registerStream(name, adapter) {
|
|
25
|
+
if (this.streamAdapters.has(name)) {
|
|
26
|
+
console.warn(`[nvent] Stream adapter "${name}" is already registered, overwriting`);
|
|
27
|
+
}
|
|
28
|
+
this.streamAdapters.set(name, adapter);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Register a store adapter
|
|
32
|
+
* @param name - Adapter name (e.g., 'redis', 'memory', 'postgres')
|
|
33
|
+
* @param adapter - StoreAdapter implementation
|
|
34
|
+
*/
|
|
35
|
+
registerStore(name, adapter) {
|
|
36
|
+
if (this.storeAdapters.has(name)) {
|
|
37
|
+
console.warn(`[nvent] Store adapter "${name}" is already registered, overwriting`);
|
|
38
|
+
}
|
|
39
|
+
this.storeAdapters.set(name, adapter);
|
|
40
|
+
}
|
|
41
|
+
// ============================================================
|
|
42
|
+
// Retrieval
|
|
43
|
+
// ============================================================
|
|
44
|
+
/**
|
|
45
|
+
* Get a queue adapter by name
|
|
46
|
+
* @throws Error if adapter not found
|
|
47
|
+
*/
|
|
48
|
+
getQueue(name) {
|
|
49
|
+
const adapter = this.queueAdapters.get(name);
|
|
50
|
+
if (!adapter) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`[nvent] Queue adapter "${name}" not found. Available: ${Array.from(this.queueAdapters.keys()).join(", ")}`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return adapter;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get a stream adapter by name
|
|
59
|
+
* @throws Error if adapter not found
|
|
60
|
+
*/
|
|
61
|
+
getStream(name) {
|
|
62
|
+
const adapter = this.streamAdapters.get(name);
|
|
63
|
+
if (!adapter) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`[nvent] Stream adapter "${name}" not found. Available: ${Array.from(this.streamAdapters.keys()).join(", ")}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return adapter;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get a store adapter by name
|
|
72
|
+
* @throws Error if adapter not found
|
|
73
|
+
*/
|
|
74
|
+
getStore(name) {
|
|
75
|
+
const adapter = this.storeAdapters.get(name);
|
|
76
|
+
if (!adapter) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`[nvent] Store adapter "${name}" not found. Available: ${Array.from(this.storeAdapters.keys()).join(", ")}`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return adapter;
|
|
82
|
+
}
|
|
83
|
+
// ============================================================
|
|
84
|
+
// Utilities
|
|
85
|
+
// ============================================================
|
|
86
|
+
/**
|
|
87
|
+
* Check if a queue adapter is registered
|
|
88
|
+
*/
|
|
89
|
+
hasQueue(name) {
|
|
90
|
+
return this.queueAdapters.has(name);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Check if a stream adapter is registered
|
|
94
|
+
*/
|
|
95
|
+
hasStream(name) {
|
|
96
|
+
return this.streamAdapters.has(name);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if a store adapter is registered
|
|
100
|
+
*/
|
|
101
|
+
hasStore(name) {
|
|
102
|
+
return this.storeAdapters.has(name);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* List all registered queue adapters
|
|
106
|
+
*/
|
|
107
|
+
listQueueAdapters() {
|
|
108
|
+
return Array.from(this.queueAdapters.keys());
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* List all registered stream adapters
|
|
112
|
+
*/
|
|
113
|
+
listStreamAdapters() {
|
|
114
|
+
return Array.from(this.streamAdapters.keys());
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* List all registered store adapters
|
|
118
|
+
*/
|
|
119
|
+
listStoreAdapters() {
|
|
120
|
+
return Array.from(this.storeAdapters.keys());
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Initialize all registered adapters
|
|
124
|
+
*/
|
|
125
|
+
async initAll() {
|
|
126
|
+
const promises = [];
|
|
127
|
+
Array.from(this.queueAdapters.values()).forEach((adapter) => {
|
|
128
|
+
promises.push(adapter.init());
|
|
129
|
+
});
|
|
130
|
+
Array.from(this.streamAdapters.values()).forEach((adapter) => {
|
|
131
|
+
promises.push(adapter.init());
|
|
132
|
+
});
|
|
133
|
+
await Promise.all(promises);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Close/cleanup all registered adapters
|
|
137
|
+
*/
|
|
138
|
+
async closeAll() {
|
|
139
|
+
const promises = [];
|
|
140
|
+
Array.from(this.queueAdapters.values()).forEach((adapter) => {
|
|
141
|
+
promises.push(adapter.close());
|
|
142
|
+
});
|
|
143
|
+
Array.from(this.streamAdapters.values()).forEach((adapter) => {
|
|
144
|
+
promises.push(adapter.shutdown());
|
|
145
|
+
});
|
|
146
|
+
Array.from(this.storeAdapters.values()).forEach((adapter) => {
|
|
147
|
+
promises.push(adapter.close());
|
|
148
|
+
});
|
|
149
|
+
await Promise.all(promises);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
let registry = null;
|
|
153
|
+
export function useAdapterRegistry() {
|
|
154
|
+
if (!registry) {
|
|
155
|
+
registry = new AdapterRegistry();
|
|
156
|
+
}
|
|
157
|
+
return registry;
|
|
158
|
+
}
|
|
159
|
+
export function resetAdapterRegistry() {
|
|
160
|
+
registry = null;
|
|
161
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ModuleOptions, ModuleConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Merge and normalize module options with defaults (v0.4.1).
|
|
4
|
+
* Applies connection fallback: adapter-specific connections override connections.redis/postgres.
|
|
5
|
+
* Only includes connection defaults for adapters that are actually used.
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeModuleOptions(options: ModuleOptions): Required<ModuleOptions>;
|
|
8
|
+
/**
|
|
9
|
+
* Convert normalized module options to runtime config format (v0.4.1).
|
|
10
|
+
*/
|
|
11
|
+
export declare function toRuntimeConfig(normalizedOptions: Required<ModuleOptions>): ModuleConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Get Redis connection config for nitro storage.
|
|
14
|
+
* Uses shared connections.redis as primary source.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getRedisStorageConfig(normalizedOptions: Required<ModuleOptions>): {
|
|
17
|
+
host: string;
|
|
18
|
+
port: number;
|
|
19
|
+
username?: undefined;
|
|
20
|
+
password?: undefined;
|
|
21
|
+
db?: undefined;
|
|
22
|
+
} | {
|
|
23
|
+
host: string | undefined;
|
|
24
|
+
port: number | undefined;
|
|
25
|
+
username: string | undefined;
|
|
26
|
+
password: string | undefined;
|
|
27
|
+
db: number | undefined;
|
|
28
|
+
};
|
|
29
|
+
export type { ModuleOptions, ModuleConfig } from './types.js';
|