moflo 4.8.19 → 4.8.20
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/.claude/guidance/shipped/moflo.md +45 -0
- package/.claude/helpers/statusline.cjs +1 -1
- package/.claude/workflow-state.json +9 -0
- package/package.json +2 -2
- package/src/@claude-flow/cli/dist/src/init/statusline-generator.js +1 -1
- package/src/@claude-flow/cli/dist/src/services/agentic-flow-bridge.js +5 -3
- package/src/@claude-flow/cli/package.json +1 -1
- package/src/@claude-flow/memory/dist/agent-memory-scope.d.ts +131 -0
- package/src/@claude-flow/memory/dist/agent-memory-scope.js +223 -0
- package/src/@claude-flow/memory/dist/agent-memory-scope.test.d.ts +8 -0
- package/src/@claude-flow/memory/dist/agent-memory-scope.test.js +466 -0
- package/src/@claude-flow/memory/dist/agentdb-adapter.d.ts +165 -0
- package/src/@claude-flow/memory/dist/agentdb-adapter.js +806 -0
- package/src/@claude-flow/memory/dist/agentdb-backend.d.ts +212 -0
- package/src/@claude-flow/memory/dist/agentdb-backend.js +842 -0
- package/src/@claude-flow/memory/dist/agentdb-backend.test.d.ts +7 -0
- package/src/@claude-flow/memory/dist/agentdb-backend.test.js +258 -0
- package/src/@claude-flow/memory/dist/application/commands/delete-memory.command.d.ts +65 -0
- package/src/@claude-flow/memory/dist/application/commands/delete-memory.command.js +129 -0
- package/src/@claude-flow/memory/dist/application/commands/store-memory.command.d.ts +48 -0
- package/src/@claude-flow/memory/dist/application/commands/store-memory.command.js +72 -0
- package/src/@claude-flow/memory/dist/application/index.d.ts +12 -0
- package/src/@claude-flow/memory/dist/application/index.js +15 -0
- package/src/@claude-flow/memory/dist/application/queries/search-memory.query.d.ts +72 -0
- package/src/@claude-flow/memory/dist/application/queries/search-memory.query.js +143 -0
- package/src/@claude-flow/memory/dist/application/services/memory-application-service.d.ts +121 -0
- package/src/@claude-flow/memory/dist/application/services/memory-application-service.js +190 -0
- package/src/@claude-flow/memory/dist/auto-memory-bridge.d.ts +226 -0
- package/src/@claude-flow/memory/dist/auto-memory-bridge.js +709 -0
- package/src/@claude-flow/memory/dist/auto-memory-bridge.test.d.ts +8 -0
- package/src/@claude-flow/memory/dist/auto-memory-bridge.test.js +757 -0
- package/src/@claude-flow/memory/dist/benchmark.test.d.ts +2 -0
- package/src/@claude-flow/memory/dist/benchmark.test.js +277 -0
- package/src/@claude-flow/memory/dist/cache-manager.d.ts +134 -0
- package/src/@claude-flow/memory/dist/cache-manager.js +407 -0
- package/src/@claude-flow/memory/dist/controller-registry.d.ts +216 -0
- package/src/@claude-flow/memory/dist/controller-registry.js +893 -0
- package/src/@claude-flow/memory/dist/controller-registry.test.d.ts +14 -0
- package/src/@claude-flow/memory/dist/controller-registry.test.js +593 -0
- package/src/@claude-flow/memory/dist/database-provider.d.ts +87 -0
- package/src/@claude-flow/memory/dist/database-provider.js +372 -0
- package/src/@claude-flow/memory/dist/database-provider.test.d.ts +7 -0
- package/src/@claude-flow/memory/dist/database-provider.test.js +287 -0
- package/src/@claude-flow/memory/dist/domain/entities/memory-entry.d.ts +143 -0
- package/src/@claude-flow/memory/dist/domain/entities/memory-entry.js +226 -0
- package/src/@claude-flow/memory/dist/domain/index.d.ts +11 -0
- package/src/@claude-flow/memory/dist/domain/index.js +12 -0
- package/src/@claude-flow/memory/dist/domain/repositories/memory-repository.interface.d.ts +102 -0
- package/src/@claude-flow/memory/dist/domain/repositories/memory-repository.interface.js +11 -0
- package/src/@claude-flow/memory/dist/domain/services/memory-domain-service.d.ts +105 -0
- package/src/@claude-flow/memory/dist/domain/services/memory-domain-service.js +297 -0
- package/src/@claude-flow/memory/dist/hnsw-index.d.ts +111 -0
- package/src/@claude-flow/memory/dist/hnsw-index.js +781 -0
- package/src/@claude-flow/memory/dist/hnsw-lite.d.ts +23 -0
- package/src/@claude-flow/memory/dist/hnsw-lite.js +168 -0
- package/src/@claude-flow/memory/dist/index.d.ts +204 -0
- package/src/@claude-flow/memory/dist/index.js +358 -0
- package/src/@claude-flow/memory/dist/infrastructure/index.d.ts +17 -0
- package/src/@claude-flow/memory/dist/infrastructure/index.js +16 -0
- package/src/@claude-flow/memory/dist/infrastructure/repositories/hybrid-memory-repository.d.ts +66 -0
- package/src/@claude-flow/memory/dist/infrastructure/repositories/hybrid-memory-repository.js +409 -0
- package/src/@claude-flow/memory/dist/learning-bridge.d.ts +137 -0
- package/src/@claude-flow/memory/dist/learning-bridge.js +335 -0
- package/src/@claude-flow/memory/dist/learning-bridge.test.d.ts +8 -0
- package/src/@claude-flow/memory/dist/learning-bridge.test.js +578 -0
- package/src/@claude-flow/memory/dist/memory-graph.d.ts +100 -0
- package/src/@claude-flow/memory/dist/memory-graph.js +333 -0
- package/src/@claude-flow/memory/dist/memory-graph.test.d.ts +8 -0
- package/src/@claude-flow/memory/dist/memory-graph.test.js +609 -0
- package/src/@claude-flow/memory/dist/migration.d.ts +68 -0
- package/src/@claude-flow/memory/dist/migration.js +513 -0
- package/src/@claude-flow/memory/dist/persistent-sona.d.ts +144 -0
- package/src/@claude-flow/memory/dist/persistent-sona.js +332 -0
- package/src/@claude-flow/memory/dist/query-builder.d.ts +211 -0
- package/src/@claude-flow/memory/dist/query-builder.js +438 -0
- package/src/@claude-flow/memory/dist/rvf-backend.d.ts +51 -0
- package/src/@claude-flow/memory/dist/rvf-backend.js +481 -0
- package/src/@claude-flow/memory/dist/rvf-learning-store.d.ts +139 -0
- package/src/@claude-flow/memory/dist/rvf-learning-store.js +295 -0
- package/src/@claude-flow/memory/dist/rvf-migration.d.ts +45 -0
- package/src/@claude-flow/memory/dist/rvf-migration.js +234 -0
- package/src/@claude-flow/memory/dist/sqljs-backend.d.ts +127 -0
- package/src/@claude-flow/memory/dist/sqljs-backend.js +600 -0
- package/src/@claude-flow/memory/dist/types.d.ts +484 -0
- package/src/@claude-flow/memory/dist/types.js +58 -0
- package/src/@claude-flow/shared/dist/core/config/defaults.d.ts +41 -0
- package/src/@claude-flow/shared/dist/core/config/defaults.js +186 -0
- package/src/@claude-flow/shared/dist/core/config/index.d.ts +8 -0
- package/src/@claude-flow/shared/dist/core/config/index.js +12 -0
- package/src/@claude-flow/shared/dist/core/config/loader.d.ts +45 -0
- package/src/@claude-flow/shared/dist/core/config/loader.js +222 -0
- package/src/@claude-flow/shared/dist/core/config/schema.d.ts +1134 -0
- package/src/@claude-flow/shared/dist/core/config/schema.js +158 -0
- package/src/@claude-flow/shared/dist/core/config/validator.d.ts +92 -0
- package/src/@claude-flow/shared/dist/core/config/validator.js +147 -0
- package/src/@claude-flow/shared/dist/core/event-bus.d.ts +31 -0
- package/src/@claude-flow/shared/dist/core/event-bus.js +197 -0
- package/src/@claude-flow/shared/dist/core/index.d.ts +15 -0
- package/src/@claude-flow/shared/dist/core/index.js +19 -0
- package/src/@claude-flow/shared/dist/core/interfaces/agent.interface.d.ts +200 -0
- package/src/@claude-flow/shared/dist/core/interfaces/agent.interface.js +6 -0
- package/src/@claude-flow/shared/dist/core/interfaces/coordinator.interface.d.ts +310 -0
- package/src/@claude-flow/shared/dist/core/interfaces/coordinator.interface.js +7 -0
- package/src/@claude-flow/shared/dist/core/interfaces/event.interface.d.ts +224 -0
- package/src/@claude-flow/shared/dist/core/interfaces/event.interface.js +46 -0
- package/src/@claude-flow/shared/dist/core/interfaces/index.d.ts +10 -0
- package/src/@claude-flow/shared/dist/core/interfaces/index.js +15 -0
- package/src/@claude-flow/shared/dist/core/interfaces/memory.interface.d.ts +298 -0
- package/src/@claude-flow/shared/dist/core/interfaces/memory.interface.js +7 -0
- package/src/@claude-flow/shared/dist/core/interfaces/task.interface.d.ts +185 -0
- package/src/@claude-flow/shared/dist/core/interfaces/task.interface.js +6 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/event-coordinator.d.ts +35 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/event-coordinator.js +101 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/health-monitor.d.ts +60 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/health-monitor.js +166 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/index.d.ts +46 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/index.js +64 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/lifecycle-manager.d.ts +56 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/lifecycle-manager.js +195 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/session-manager.d.ts +83 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/session-manager.js +193 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/task-manager.d.ts +49 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/task-manager.js +253 -0
- package/src/@claude-flow/shared/dist/events/domain-events.d.ts +282 -0
- package/src/@claude-flow/shared/dist/events/domain-events.js +165 -0
- package/src/@claude-flow/shared/dist/events/event-store.d.ts +126 -0
- package/src/@claude-flow/shared/dist/events/event-store.js +432 -0
- package/src/@claude-flow/shared/dist/events/event-store.test.d.ts +8 -0
- package/src/@claude-flow/shared/dist/events/event-store.test.js +297 -0
- package/src/@claude-flow/shared/dist/events/example-usage.d.ts +10 -0
- package/src/@claude-flow/shared/dist/events/example-usage.js +193 -0
- package/src/@claude-flow/shared/dist/events/index.d.ts +21 -0
- package/src/@claude-flow/shared/dist/events/index.js +22 -0
- package/src/@claude-flow/shared/dist/events/projections.d.ts +177 -0
- package/src/@claude-flow/shared/dist/events/projections.js +421 -0
- package/src/@claude-flow/shared/dist/events/rvf-event-log.d.ts +82 -0
- package/src/@claude-flow/shared/dist/events/rvf-event-log.js +340 -0
- package/src/@claude-flow/shared/dist/events/state-reconstructor.d.ts +101 -0
- package/src/@claude-flow/shared/dist/events/state-reconstructor.js +263 -0
- package/src/@claude-flow/shared/dist/events.d.ts +80 -0
- package/src/@claude-flow/shared/dist/events.js +249 -0
- package/src/@claude-flow/shared/dist/hooks/example-usage.d.ts +42 -0
- package/src/@claude-flow/shared/dist/hooks/example-usage.js +351 -0
- package/src/@claude-flow/shared/dist/hooks/executor.d.ts +100 -0
- package/src/@claude-flow/shared/dist/hooks/executor.js +267 -0
- package/src/@claude-flow/shared/dist/hooks/hooks.test.d.ts +9 -0
- package/src/@claude-flow/shared/dist/hooks/hooks.test.js +322 -0
- package/src/@claude-flow/shared/dist/hooks/index.d.ts +52 -0
- package/src/@claude-flow/shared/dist/hooks/index.js +51 -0
- package/src/@claude-flow/shared/dist/hooks/registry.d.ts +133 -0
- package/src/@claude-flow/shared/dist/hooks/registry.js +277 -0
- package/src/@claude-flow/shared/dist/hooks/safety/bash-safety.d.ts +105 -0
- package/src/@claude-flow/shared/dist/hooks/safety/bash-safety.js +481 -0
- package/src/@claude-flow/shared/dist/hooks/safety/file-organization.d.ts +144 -0
- package/src/@claude-flow/shared/dist/hooks/safety/file-organization.js +328 -0
- package/src/@claude-flow/shared/dist/hooks/safety/git-commit.d.ts +158 -0
- package/src/@claude-flow/shared/dist/hooks/safety/git-commit.js +450 -0
- package/src/@claude-flow/shared/dist/hooks/safety/index.d.ts +17 -0
- package/src/@claude-flow/shared/dist/hooks/safety/index.js +17 -0
- package/src/@claude-flow/shared/dist/hooks/session-hooks.d.ts +234 -0
- package/src/@claude-flow/shared/dist/hooks/session-hooks.js +334 -0
- package/src/@claude-flow/shared/dist/hooks/task-hooks.d.ts +163 -0
- package/src/@claude-flow/shared/dist/hooks/task-hooks.js +326 -0
- package/src/@claude-flow/shared/dist/hooks/types.d.ts +267 -0
- package/src/@claude-flow/shared/dist/hooks/types.js +62 -0
- package/src/@claude-flow/shared/dist/hooks/verify-exports.test.d.ts +9 -0
- package/src/@claude-flow/shared/dist/hooks/verify-exports.test.js +93 -0
- package/src/@claude-flow/shared/dist/index.d.ts +20 -0
- package/src/@claude-flow/shared/dist/index.js +50 -0
- package/src/@claude-flow/shared/dist/mcp/connection-pool.d.ts +98 -0
- package/src/@claude-flow/shared/dist/mcp/connection-pool.js +364 -0
- package/src/@claude-flow/shared/dist/mcp/index.d.ts +69 -0
- package/src/@claude-flow/shared/dist/mcp/index.js +84 -0
- package/src/@claude-flow/shared/dist/mcp/server.d.ts +166 -0
- package/src/@claude-flow/shared/dist/mcp/server.js +593 -0
- package/src/@claude-flow/shared/dist/mcp/session-manager.d.ts +136 -0
- package/src/@claude-flow/shared/dist/mcp/session-manager.js +335 -0
- package/src/@claude-flow/shared/dist/mcp/tool-registry.d.ts +178 -0
- package/src/@claude-flow/shared/dist/mcp/tool-registry.js +439 -0
- package/src/@claude-flow/shared/dist/mcp/transport/http.d.ts +104 -0
- package/src/@claude-flow/shared/dist/mcp/transport/http.js +476 -0
- package/src/@claude-flow/shared/dist/mcp/transport/index.d.ts +102 -0
- package/src/@claude-flow/shared/dist/mcp/transport/index.js +238 -0
- package/src/@claude-flow/shared/dist/mcp/transport/stdio.d.ts +104 -0
- package/src/@claude-flow/shared/dist/mcp/transport/stdio.js +263 -0
- package/src/@claude-flow/shared/dist/mcp/transport/websocket.d.ts +133 -0
- package/src/@claude-flow/shared/dist/mcp/transport/websocket.js +396 -0
- package/src/@claude-flow/shared/dist/mcp/types.d.ts +438 -0
- package/src/@claude-flow/shared/dist/mcp/types.js +54 -0
- package/src/@claude-flow/shared/dist/plugin-interface.d.ts +544 -0
- package/src/@claude-flow/shared/dist/plugin-interface.js +23 -0
- package/src/@claude-flow/shared/dist/plugin-loader.d.ts +139 -0
- package/src/@claude-flow/shared/dist/plugin-loader.js +434 -0
- package/src/@claude-flow/shared/dist/plugin-registry.d.ts +183 -0
- package/src/@claude-flow/shared/dist/plugin-registry.js +457 -0
- package/src/@claude-flow/shared/dist/plugins/index.d.ts +10 -0
- package/src/@claude-flow/shared/dist/plugins/index.js +10 -0
- package/src/@claude-flow/shared/dist/plugins/official/hive-mind-plugin.d.ts +106 -0
- package/src/@claude-flow/shared/dist/plugins/official/hive-mind-plugin.js +241 -0
- package/src/@claude-flow/shared/dist/plugins/official/index.d.ts +10 -0
- package/src/@claude-flow/shared/dist/plugins/official/index.js +10 -0
- package/src/@claude-flow/shared/dist/plugins/official/maestro-plugin.d.ts +121 -0
- package/src/@claude-flow/shared/dist/plugins/official/maestro-plugin.js +355 -0
- package/src/@claude-flow/shared/dist/plugins/types.d.ts +93 -0
- package/src/@claude-flow/shared/dist/plugins/types.js +9 -0
- package/src/@claude-flow/shared/dist/resilience/bulkhead.d.ts +105 -0
- package/src/@claude-flow/shared/dist/resilience/bulkhead.js +206 -0
- package/src/@claude-flow/shared/dist/resilience/circuit-breaker.d.ts +132 -0
- package/src/@claude-flow/shared/dist/resilience/circuit-breaker.js +233 -0
- package/src/@claude-flow/shared/dist/resilience/index.d.ts +19 -0
- package/src/@claude-flow/shared/dist/resilience/index.js +19 -0
- package/src/@claude-flow/shared/dist/resilience/rate-limiter.d.ts +168 -0
- package/src/@claude-flow/shared/dist/resilience/rate-limiter.js +314 -0
- package/src/@claude-flow/shared/dist/resilience/retry.d.ts +91 -0
- package/src/@claude-flow/shared/dist/resilience/retry.js +159 -0
- package/src/@claude-flow/shared/dist/security/index.d.ts +10 -0
- package/src/@claude-flow/shared/dist/security/index.js +12 -0
- package/src/@claude-flow/shared/dist/security/input-validation.d.ts +73 -0
- package/src/@claude-flow/shared/dist/security/input-validation.js +201 -0
- package/src/@claude-flow/shared/dist/security/secure-random.d.ts +92 -0
- package/src/@claude-flow/shared/dist/security/secure-random.js +142 -0
- package/src/@claude-flow/shared/dist/services/index.d.ts +7 -0
- package/src/@claude-flow/shared/dist/services/index.js +7 -0
- package/src/@claude-flow/shared/dist/services/v3-progress.service.d.ts +124 -0
- package/src/@claude-flow/shared/dist/services/v3-progress.service.js +402 -0
- package/src/@claude-flow/shared/dist/types/agent.types.d.ts +137 -0
- package/src/@claude-flow/shared/dist/types/agent.types.js +6 -0
- package/src/@claude-flow/shared/dist/types/index.d.ts +11 -0
- package/src/@claude-flow/shared/dist/types/index.js +17 -0
- package/src/@claude-flow/shared/dist/types/mcp.types.d.ts +266 -0
- package/src/@claude-flow/shared/dist/types/mcp.types.js +7 -0
- package/src/@claude-flow/shared/dist/types/memory.types.d.ts +236 -0
- package/src/@claude-flow/shared/dist/types/memory.types.js +7 -0
- package/src/@claude-flow/shared/dist/types/swarm.types.d.ts +186 -0
- package/src/@claude-flow/shared/dist/types/swarm.types.js +65 -0
- package/src/@claude-flow/shared/dist/types/task.types.d.ts +178 -0
- package/src/@claude-flow/shared/dist/types/task.types.js +32 -0
- package/src/@claude-flow/shared/dist/types.d.ts +197 -0
- package/src/@claude-flow/shared/dist/types.js +21 -0
- package/src/@claude-flow/shared/dist/utils/secure-logger.d.ts +69 -0
- package/src/@claude-flow/shared/dist/utils/secure-logger.js +208 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Store Persistence (ADR-007)
|
|
3
|
+
*
|
|
4
|
+
* Provides persistent storage for domain events using SQLite.
|
|
5
|
+
* Supports event replay, snapshots, and projections.
|
|
6
|
+
*
|
|
7
|
+
* Key Features:
|
|
8
|
+
* - Append-only event log
|
|
9
|
+
* - Event versioning per aggregate
|
|
10
|
+
* - Event filtering and queries
|
|
11
|
+
* - Snapshot support for performance
|
|
12
|
+
* - Event replay for projections
|
|
13
|
+
* - Cross-platform SQLite (sql.js fallback)
|
|
14
|
+
*
|
|
15
|
+
* @module v3/shared/events/event-store
|
|
16
|
+
*/
|
|
17
|
+
import { EventEmitter } from 'node:events';
|
|
18
|
+
import { DomainEvent } from './domain-events.js';
|
|
19
|
+
export interface EventStoreConfig {
|
|
20
|
+
/** Path to SQLite database file (:memory: for in-memory) */
|
|
21
|
+
databasePath: string;
|
|
22
|
+
/** Enable verbose logging */
|
|
23
|
+
verbose: boolean;
|
|
24
|
+
/** Auto-persist interval in milliseconds (0 = manual only) */
|
|
25
|
+
autoPersistInterval: number;
|
|
26
|
+
/** Maximum events before snapshot recommendation */
|
|
27
|
+
snapshotThreshold: number;
|
|
28
|
+
/** Path to sql.js WASM file (optional) */
|
|
29
|
+
wasmPath?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface EventFilter {
|
|
32
|
+
/** Filter by aggregate IDs */
|
|
33
|
+
aggregateIds?: string[];
|
|
34
|
+
/** Filter by aggregate types */
|
|
35
|
+
aggregateTypes?: Array<'agent' | 'task' | 'memory' | 'swarm'>;
|
|
36
|
+
/** Filter by event types */
|
|
37
|
+
eventTypes?: string[];
|
|
38
|
+
/** Filter events after timestamp */
|
|
39
|
+
afterTimestamp?: number;
|
|
40
|
+
/** Filter events before timestamp */
|
|
41
|
+
beforeTimestamp?: number;
|
|
42
|
+
/** Filter by minimum version */
|
|
43
|
+
fromVersion?: number;
|
|
44
|
+
/** Limit number of results */
|
|
45
|
+
limit?: number;
|
|
46
|
+
/** Offset for pagination */
|
|
47
|
+
offset?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface EventSnapshot {
|
|
50
|
+
/** Aggregate ID */
|
|
51
|
+
aggregateId: string;
|
|
52
|
+
/** Aggregate type */
|
|
53
|
+
aggregateType: 'agent' | 'task' | 'memory' | 'swarm';
|
|
54
|
+
/** Version at snapshot */
|
|
55
|
+
version: number;
|
|
56
|
+
/** Snapshot state */
|
|
57
|
+
state: Record<string, unknown>;
|
|
58
|
+
/** Timestamp when snapshot was created */
|
|
59
|
+
timestamp: number;
|
|
60
|
+
}
|
|
61
|
+
export interface EventStoreStats {
|
|
62
|
+
totalEvents: number;
|
|
63
|
+
eventsByType: Record<string, number>;
|
|
64
|
+
eventsByAggregate: Record<string, number>;
|
|
65
|
+
oldestEvent: number | null;
|
|
66
|
+
newestEvent: number | null;
|
|
67
|
+
snapshotCount: number;
|
|
68
|
+
}
|
|
69
|
+
export declare class EventStore extends EventEmitter {
|
|
70
|
+
private config;
|
|
71
|
+
private db;
|
|
72
|
+
private initialized;
|
|
73
|
+
private persistTimer;
|
|
74
|
+
private SQL;
|
|
75
|
+
private aggregateVersions;
|
|
76
|
+
constructor(config?: Partial<EventStoreConfig>);
|
|
77
|
+
/**
|
|
78
|
+
* Initialize the event store
|
|
79
|
+
*/
|
|
80
|
+
initialize(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Shutdown the event store
|
|
83
|
+
*/
|
|
84
|
+
shutdown(): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Append a new event to the store
|
|
87
|
+
*/
|
|
88
|
+
append(event: DomainEvent): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Get events for a specific aggregate
|
|
91
|
+
*/
|
|
92
|
+
getEvents(aggregateId: string, fromVersion?: number): Promise<DomainEvent[]>;
|
|
93
|
+
/**
|
|
94
|
+
* Get events by type
|
|
95
|
+
*/
|
|
96
|
+
getEventsByType(type: string): Promise<DomainEvent[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Query events with filters
|
|
99
|
+
*/
|
|
100
|
+
query(filter: EventFilter): Promise<DomainEvent[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Replay events from a specific version
|
|
103
|
+
*/
|
|
104
|
+
replay(fromVersion?: number): AsyncIterable<DomainEvent>;
|
|
105
|
+
/**
|
|
106
|
+
* Save a snapshot for an aggregate
|
|
107
|
+
*/
|
|
108
|
+
saveSnapshot(snapshot: EventSnapshot): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Get snapshot for an aggregate
|
|
111
|
+
*/
|
|
112
|
+
getSnapshot(aggregateId: string): Promise<EventSnapshot | null>;
|
|
113
|
+
/**
|
|
114
|
+
* Get event store statistics
|
|
115
|
+
*/
|
|
116
|
+
getStats(): Promise<EventStoreStats>;
|
|
117
|
+
/**
|
|
118
|
+
* Persist to disk
|
|
119
|
+
*/
|
|
120
|
+
persist(): Promise<void>;
|
|
121
|
+
private createSchema;
|
|
122
|
+
private loadAggregateVersions;
|
|
123
|
+
private rowToEvent;
|
|
124
|
+
private ensureInitialized;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=event-store.d.ts.map
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Store Persistence (ADR-007)
|
|
3
|
+
*
|
|
4
|
+
* Provides persistent storage for domain events using SQLite.
|
|
5
|
+
* Supports event replay, snapshots, and projections.
|
|
6
|
+
*
|
|
7
|
+
* Key Features:
|
|
8
|
+
* - Append-only event log
|
|
9
|
+
* - Event versioning per aggregate
|
|
10
|
+
* - Event filtering and queries
|
|
11
|
+
* - Snapshot support for performance
|
|
12
|
+
* - Event replay for projections
|
|
13
|
+
* - Cross-platform SQLite (sql.js fallback)
|
|
14
|
+
*
|
|
15
|
+
* @module v3/shared/events/event-store
|
|
16
|
+
*/
|
|
17
|
+
import { EventEmitter } from 'node:events';
|
|
18
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
19
|
+
import initSqlJs from 'sql.js';
|
|
20
|
+
const DEFAULT_CONFIG = {
|
|
21
|
+
databasePath: ':memory:',
|
|
22
|
+
verbose: false,
|
|
23
|
+
autoPersistInterval: 5000, // 5 seconds
|
|
24
|
+
snapshotThreshold: 100,
|
|
25
|
+
};
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// Event Store Implementation
|
|
28
|
+
// =============================================================================
|
|
29
|
+
export class EventStore extends EventEmitter {
|
|
30
|
+
config;
|
|
31
|
+
db = null;
|
|
32
|
+
initialized = false;
|
|
33
|
+
persistTimer = null;
|
|
34
|
+
SQL = null;
|
|
35
|
+
// Version tracking per aggregate
|
|
36
|
+
aggregateVersions = new Map();
|
|
37
|
+
constructor(config = {}) {
|
|
38
|
+
super();
|
|
39
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Initialize the event store
|
|
43
|
+
*/
|
|
44
|
+
async initialize() {
|
|
45
|
+
if (this.initialized)
|
|
46
|
+
return;
|
|
47
|
+
// Load sql.js WASM — prefer local node_modules copy over remote URL
|
|
48
|
+
this.SQL = await initSqlJs({
|
|
49
|
+
locateFile: this.config.wasmPath
|
|
50
|
+
? () => this.config.wasmPath
|
|
51
|
+
: (file) => {
|
|
52
|
+
// Try to resolve from node_modules first (works in Node.js)
|
|
53
|
+
try {
|
|
54
|
+
const sqlJsDir = require.resolve('sql.js');
|
|
55
|
+
const { dirname, join } = require('node:path');
|
|
56
|
+
const localPath = join(dirname(sqlJsDir), file);
|
|
57
|
+
if (require('node:fs').existsSync(localPath))
|
|
58
|
+
return localPath;
|
|
59
|
+
}
|
|
60
|
+
catch { /* fallback below */ }
|
|
61
|
+
return `https://sql.js.org/dist/${file}`;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
// Load existing database if exists
|
|
65
|
+
if (this.config.databasePath !== ':memory:' && existsSync(this.config.databasePath)) {
|
|
66
|
+
const buffer = readFileSync(this.config.databasePath);
|
|
67
|
+
this.db = new this.SQL.Database(new Uint8Array(buffer));
|
|
68
|
+
if (this.config.verbose) {
|
|
69
|
+
console.log(`[EventStore] Loaded database from ${this.config.databasePath}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.db = new this.SQL.Database();
|
|
74
|
+
if (this.config.verbose) {
|
|
75
|
+
console.log('[EventStore] Created new event store database');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Create schema
|
|
79
|
+
this.createSchema();
|
|
80
|
+
// Load aggregate versions
|
|
81
|
+
this.loadAggregateVersions();
|
|
82
|
+
// Set up auto-persist
|
|
83
|
+
if (this.config.autoPersistInterval > 0 && this.config.databasePath !== ':memory:') {
|
|
84
|
+
this.persistTimer = setInterval(() => {
|
|
85
|
+
this.persist().catch((err) => {
|
|
86
|
+
this.emit('error', { operation: 'auto-persist', error: err });
|
|
87
|
+
});
|
|
88
|
+
}, this.config.autoPersistInterval);
|
|
89
|
+
}
|
|
90
|
+
this.initialized = true;
|
|
91
|
+
this.emit('initialized');
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Shutdown the event store
|
|
95
|
+
*/
|
|
96
|
+
async shutdown() {
|
|
97
|
+
if (!this.initialized || !this.db)
|
|
98
|
+
return;
|
|
99
|
+
// Stop auto-persist
|
|
100
|
+
if (this.persistTimer) {
|
|
101
|
+
clearInterval(this.persistTimer);
|
|
102
|
+
this.persistTimer = null;
|
|
103
|
+
}
|
|
104
|
+
// Final persist
|
|
105
|
+
if (this.config.databasePath !== ':memory:') {
|
|
106
|
+
await this.persist();
|
|
107
|
+
}
|
|
108
|
+
this.db.close();
|
|
109
|
+
this.db = null;
|
|
110
|
+
this.initialized = false;
|
|
111
|
+
this.emit('shutdown');
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Append a new event to the store
|
|
115
|
+
*/
|
|
116
|
+
async append(event) {
|
|
117
|
+
this.ensureInitialized();
|
|
118
|
+
// Get next version for aggregate
|
|
119
|
+
const currentVersion = this.aggregateVersions.get(event.aggregateId) || 0;
|
|
120
|
+
const nextVersion = currentVersion + 1;
|
|
121
|
+
// Set version on event
|
|
122
|
+
event.version = nextVersion;
|
|
123
|
+
// Insert event
|
|
124
|
+
const stmt = `
|
|
125
|
+
INSERT INTO events (
|
|
126
|
+
id, type, aggregate_id, aggregate_type, version, timestamp,
|
|
127
|
+
source, payload, metadata, causation_id, correlation_id
|
|
128
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
129
|
+
`;
|
|
130
|
+
this.db.run(stmt, [
|
|
131
|
+
event.id,
|
|
132
|
+
event.type,
|
|
133
|
+
event.aggregateId,
|
|
134
|
+
event.aggregateType,
|
|
135
|
+
event.version,
|
|
136
|
+
event.timestamp,
|
|
137
|
+
event.source,
|
|
138
|
+
JSON.stringify(event.payload),
|
|
139
|
+
JSON.stringify(event.metadata || {}),
|
|
140
|
+
event.causationId || null,
|
|
141
|
+
event.correlationId || null,
|
|
142
|
+
]);
|
|
143
|
+
// Update version tracker
|
|
144
|
+
this.aggregateVersions.set(event.aggregateId, nextVersion);
|
|
145
|
+
// Emit event appended notification
|
|
146
|
+
this.emit('event:appended', event);
|
|
147
|
+
// Check if snapshot needed
|
|
148
|
+
if (nextVersion % this.config.snapshotThreshold === 0) {
|
|
149
|
+
this.emit('snapshot:recommended', { aggregateId: event.aggregateId, version: nextVersion });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get events for a specific aggregate
|
|
154
|
+
*/
|
|
155
|
+
async getEvents(aggregateId, fromVersion) {
|
|
156
|
+
this.ensureInitialized();
|
|
157
|
+
let sql = 'SELECT * FROM events WHERE aggregate_id = ?';
|
|
158
|
+
const params = [aggregateId];
|
|
159
|
+
if (fromVersion !== undefined) {
|
|
160
|
+
sql += ' AND version >= ?';
|
|
161
|
+
params.push(fromVersion);
|
|
162
|
+
}
|
|
163
|
+
sql += ' ORDER BY version ASC';
|
|
164
|
+
const stmt = this.db.prepare(sql);
|
|
165
|
+
const events = [];
|
|
166
|
+
stmt.bind(params);
|
|
167
|
+
while (stmt.step()) {
|
|
168
|
+
const row = stmt.getAsObject();
|
|
169
|
+
events.push(this.rowToEvent(row));
|
|
170
|
+
}
|
|
171
|
+
stmt.free();
|
|
172
|
+
return events;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get events by type
|
|
176
|
+
*/
|
|
177
|
+
async getEventsByType(type) {
|
|
178
|
+
this.ensureInitialized();
|
|
179
|
+
const stmt = this.db.prepare('SELECT * FROM events WHERE type = ? ORDER BY timestamp ASC');
|
|
180
|
+
const events = [];
|
|
181
|
+
stmt.bind([type]);
|
|
182
|
+
while (stmt.step()) {
|
|
183
|
+
const row = stmt.getAsObject();
|
|
184
|
+
events.push(this.rowToEvent(row));
|
|
185
|
+
}
|
|
186
|
+
stmt.free();
|
|
187
|
+
return events;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Query events with filters
|
|
191
|
+
*/
|
|
192
|
+
async query(filter) {
|
|
193
|
+
this.ensureInitialized();
|
|
194
|
+
let sql = 'SELECT * FROM events WHERE 1=1';
|
|
195
|
+
const params = [];
|
|
196
|
+
// Aggregate ID filter
|
|
197
|
+
if (filter.aggregateIds && filter.aggregateIds.length > 0) {
|
|
198
|
+
sql += ` AND aggregate_id IN (${filter.aggregateIds.map(() => '?').join(',')})`;
|
|
199
|
+
params.push(...filter.aggregateIds);
|
|
200
|
+
}
|
|
201
|
+
// Aggregate type filter
|
|
202
|
+
if (filter.aggregateTypes && filter.aggregateTypes.length > 0) {
|
|
203
|
+
sql += ` AND aggregate_type IN (${filter.aggregateTypes.map(() => '?').join(',')})`;
|
|
204
|
+
params.push(...filter.aggregateTypes);
|
|
205
|
+
}
|
|
206
|
+
// Event type filter
|
|
207
|
+
if (filter.eventTypes && filter.eventTypes.length > 0) {
|
|
208
|
+
sql += ` AND type IN (${filter.eventTypes.map(() => '?').join(',')})`;
|
|
209
|
+
params.push(...filter.eventTypes);
|
|
210
|
+
}
|
|
211
|
+
// Timestamp filters
|
|
212
|
+
if (filter.afterTimestamp) {
|
|
213
|
+
sql += ' AND timestamp > ?';
|
|
214
|
+
params.push(filter.afterTimestamp);
|
|
215
|
+
}
|
|
216
|
+
if (filter.beforeTimestamp) {
|
|
217
|
+
sql += ' AND timestamp < ?';
|
|
218
|
+
params.push(filter.beforeTimestamp);
|
|
219
|
+
}
|
|
220
|
+
// Version filter
|
|
221
|
+
if (filter.fromVersion) {
|
|
222
|
+
sql += ' AND version >= ?';
|
|
223
|
+
params.push(filter.fromVersion);
|
|
224
|
+
}
|
|
225
|
+
// Order by timestamp
|
|
226
|
+
sql += ' ORDER BY timestamp ASC';
|
|
227
|
+
// Pagination
|
|
228
|
+
if (filter.limit) {
|
|
229
|
+
sql += ' LIMIT ?';
|
|
230
|
+
params.push(filter.limit);
|
|
231
|
+
}
|
|
232
|
+
if (filter.offset) {
|
|
233
|
+
sql += ' OFFSET ?';
|
|
234
|
+
params.push(filter.offset);
|
|
235
|
+
}
|
|
236
|
+
const stmt = this.db.prepare(sql);
|
|
237
|
+
const events = [];
|
|
238
|
+
stmt.bind(params);
|
|
239
|
+
while (stmt.step()) {
|
|
240
|
+
const row = stmt.getAsObject();
|
|
241
|
+
events.push(this.rowToEvent(row));
|
|
242
|
+
}
|
|
243
|
+
stmt.free();
|
|
244
|
+
return events;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Replay events from a specific version
|
|
248
|
+
*/
|
|
249
|
+
async *replay(fromVersion = 0) {
|
|
250
|
+
this.ensureInitialized();
|
|
251
|
+
const stmt = this.db.prepare('SELECT * FROM events WHERE version >= ? ORDER BY version ASC');
|
|
252
|
+
stmt.bind([fromVersion]);
|
|
253
|
+
while (stmt.step()) {
|
|
254
|
+
const row = stmt.getAsObject();
|
|
255
|
+
yield this.rowToEvent(row);
|
|
256
|
+
}
|
|
257
|
+
stmt.free();
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Save a snapshot for an aggregate
|
|
261
|
+
*/
|
|
262
|
+
async saveSnapshot(snapshot) {
|
|
263
|
+
this.ensureInitialized();
|
|
264
|
+
const stmt = `
|
|
265
|
+
INSERT OR REPLACE INTO snapshots (
|
|
266
|
+
aggregate_id, aggregate_type, version, state, timestamp
|
|
267
|
+
) VALUES (?, ?, ?, ?, ?)
|
|
268
|
+
`;
|
|
269
|
+
this.db.run(stmt, [
|
|
270
|
+
snapshot.aggregateId,
|
|
271
|
+
snapshot.aggregateType,
|
|
272
|
+
snapshot.version,
|
|
273
|
+
JSON.stringify(snapshot.state),
|
|
274
|
+
snapshot.timestamp,
|
|
275
|
+
]);
|
|
276
|
+
this.emit('snapshot:saved', snapshot);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Get snapshot for an aggregate
|
|
280
|
+
*/
|
|
281
|
+
async getSnapshot(aggregateId) {
|
|
282
|
+
this.ensureInitialized();
|
|
283
|
+
const stmt = this.db.prepare('SELECT * FROM snapshots WHERE aggregate_id = ? ORDER BY version DESC LIMIT 1');
|
|
284
|
+
stmt.bind([aggregateId]);
|
|
285
|
+
const hasRow = stmt.step();
|
|
286
|
+
const row = hasRow ? stmt.getAsObject() : null;
|
|
287
|
+
stmt.free();
|
|
288
|
+
if (!row || Object.keys(row).length === 0) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
aggregateId: row.aggregate_id,
|
|
293
|
+
aggregateType: row.aggregate_type,
|
|
294
|
+
version: row.version,
|
|
295
|
+
state: JSON.parse(row.state),
|
|
296
|
+
timestamp: row.timestamp,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Get event store statistics
|
|
301
|
+
*/
|
|
302
|
+
async getStats() {
|
|
303
|
+
this.ensureInitialized();
|
|
304
|
+
// Total events
|
|
305
|
+
const totalStmt = this.db.prepare('SELECT COUNT(*) as count FROM events');
|
|
306
|
+
totalStmt.step();
|
|
307
|
+
const totalRow = totalStmt.getAsObject();
|
|
308
|
+
totalStmt.free();
|
|
309
|
+
const totalEvents = totalRow.count || 0;
|
|
310
|
+
// Events by type
|
|
311
|
+
const typeStmt = this.db.prepare('SELECT type, COUNT(*) as count FROM events GROUP BY type');
|
|
312
|
+
const eventsByType = {};
|
|
313
|
+
while (typeStmt.step()) {
|
|
314
|
+
const row = typeStmt.getAsObject();
|
|
315
|
+
eventsByType[row.type] = row.count || 0;
|
|
316
|
+
}
|
|
317
|
+
typeStmt.free();
|
|
318
|
+
// Events by aggregate
|
|
319
|
+
const aggStmt = this.db.prepare('SELECT aggregate_id, COUNT(*) as count FROM events GROUP BY aggregate_id');
|
|
320
|
+
const eventsByAggregate = {};
|
|
321
|
+
while (aggStmt.step()) {
|
|
322
|
+
const row = aggStmt.getAsObject();
|
|
323
|
+
eventsByAggregate[row.aggregate_id] = row.count || 0;
|
|
324
|
+
}
|
|
325
|
+
aggStmt.free();
|
|
326
|
+
// Timestamp range
|
|
327
|
+
const rangeStmt = this.db.prepare('SELECT MIN(timestamp) as oldest, MAX(timestamp) as newest FROM events');
|
|
328
|
+
rangeStmt.step();
|
|
329
|
+
const rangeRow = rangeStmt.getAsObject();
|
|
330
|
+
rangeStmt.free();
|
|
331
|
+
// Snapshot count
|
|
332
|
+
const snapshotStmt = this.db.prepare('SELECT COUNT(*) as count FROM snapshots');
|
|
333
|
+
snapshotStmt.step();
|
|
334
|
+
const snapshotRow = snapshotStmt.getAsObject();
|
|
335
|
+
snapshotStmt.free();
|
|
336
|
+
return {
|
|
337
|
+
totalEvents,
|
|
338
|
+
eventsByType,
|
|
339
|
+
eventsByAggregate,
|
|
340
|
+
oldestEvent: rangeRow.oldest || null,
|
|
341
|
+
newestEvent: rangeRow.newest || null,
|
|
342
|
+
snapshotCount: snapshotRow.count || 0,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Persist to disk
|
|
347
|
+
*/
|
|
348
|
+
async persist() {
|
|
349
|
+
if (!this.db || this.config.databasePath === ':memory:') {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const data = this.db.export();
|
|
353
|
+
const buffer = Buffer.from(data);
|
|
354
|
+
writeFileSync(this.config.databasePath, buffer);
|
|
355
|
+
if (this.config.verbose) {
|
|
356
|
+
console.log(`[EventStore] Persisted ${buffer.length} bytes to ${this.config.databasePath}`);
|
|
357
|
+
}
|
|
358
|
+
this.emit('persisted', { size: buffer.length, path: this.config.databasePath });
|
|
359
|
+
}
|
|
360
|
+
// ===== Private Methods =====
|
|
361
|
+
createSchema() {
|
|
362
|
+
if (!this.db)
|
|
363
|
+
return;
|
|
364
|
+
// Events table
|
|
365
|
+
this.db.run(`
|
|
366
|
+
CREATE TABLE IF NOT EXISTS events (
|
|
367
|
+
id TEXT PRIMARY KEY,
|
|
368
|
+
type TEXT NOT NULL,
|
|
369
|
+
aggregate_id TEXT NOT NULL,
|
|
370
|
+
aggregate_type TEXT NOT NULL,
|
|
371
|
+
version INTEGER NOT NULL,
|
|
372
|
+
timestamp INTEGER NOT NULL,
|
|
373
|
+
source TEXT NOT NULL,
|
|
374
|
+
payload TEXT NOT NULL,
|
|
375
|
+
metadata TEXT,
|
|
376
|
+
causation_id TEXT,
|
|
377
|
+
correlation_id TEXT
|
|
378
|
+
)
|
|
379
|
+
`);
|
|
380
|
+
// Indexes for performance
|
|
381
|
+
this.db.run('CREATE INDEX IF NOT EXISTS idx_aggregate_id ON events(aggregate_id)');
|
|
382
|
+
this.db.run('CREATE INDEX IF NOT EXISTS idx_aggregate_type ON events(aggregate_type)');
|
|
383
|
+
this.db.run('CREATE INDEX IF NOT EXISTS idx_event_type ON events(type)');
|
|
384
|
+
this.db.run('CREATE INDEX IF NOT EXISTS idx_timestamp ON events(timestamp)');
|
|
385
|
+
this.db.run('CREATE INDEX IF NOT EXISTS idx_version ON events(version)');
|
|
386
|
+
this.db.run('CREATE UNIQUE INDEX IF NOT EXISTS idx_aggregate_version ON events(aggregate_id, version)');
|
|
387
|
+
// Snapshots table
|
|
388
|
+
this.db.run(`
|
|
389
|
+
CREATE TABLE IF NOT EXISTS snapshots (
|
|
390
|
+
aggregate_id TEXT PRIMARY KEY,
|
|
391
|
+
aggregate_type TEXT NOT NULL,
|
|
392
|
+
version INTEGER NOT NULL,
|
|
393
|
+
state TEXT NOT NULL,
|
|
394
|
+
timestamp INTEGER NOT NULL
|
|
395
|
+
)
|
|
396
|
+
`);
|
|
397
|
+
if (this.config.verbose) {
|
|
398
|
+
console.log('[EventStore] Schema created successfully');
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
loadAggregateVersions() {
|
|
402
|
+
if (!this.db)
|
|
403
|
+
return;
|
|
404
|
+
const stmt = this.db.prepare('SELECT aggregate_id, MAX(version) as max_version FROM events GROUP BY aggregate_id');
|
|
405
|
+
while (stmt.step()) {
|
|
406
|
+
const row = stmt.getAsObject();
|
|
407
|
+
this.aggregateVersions.set(row.aggregate_id, row.max_version || 0);
|
|
408
|
+
}
|
|
409
|
+
stmt.free();
|
|
410
|
+
}
|
|
411
|
+
rowToEvent(row) {
|
|
412
|
+
return {
|
|
413
|
+
id: row.id,
|
|
414
|
+
type: row.type,
|
|
415
|
+
aggregateId: row.aggregate_id,
|
|
416
|
+
aggregateType: row.aggregate_type,
|
|
417
|
+
version: row.version,
|
|
418
|
+
timestamp: row.timestamp,
|
|
419
|
+
source: row.source,
|
|
420
|
+
payload: JSON.parse(row.payload),
|
|
421
|
+
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
|
|
422
|
+
causationId: row.causation_id,
|
|
423
|
+
correlationId: row.correlation_id,
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
ensureInitialized() {
|
|
427
|
+
if (!this.initialized || !this.db) {
|
|
428
|
+
throw new Error('EventStore not initialized. Call initialize() first.');
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
//# sourceMappingURL=event-store.js.map
|