@danielsimonjr/memory-mcp 11.0.1 → 11.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -22
- package/dist/core/EntityManager.d.ts +10 -15
- package/dist/core/EntityManager.d.ts.map +1 -1
- package/dist/core/EntityManager.js +21 -54
- package/dist/core/GraphStorage.d.ts +0 -51
- package/dist/core/GraphStorage.d.ts.map +1 -1
- package/dist/core/GraphStorage.js +2 -79
- package/dist/core/GraphTraversal.d.ts +2 -7
- package/dist/core/GraphTraversal.d.ts.map +1 -1
- package/dist/core/GraphTraversal.js +2 -19
- package/dist/core/ManagerContext.d.ts +0 -4
- package/dist/core/ManagerContext.d.ts.map +1 -1
- package/dist/core/ManagerContext.js +2 -12
- package/dist/core/RelationManager.d.ts.map +1 -1
- package/dist/core/RelationManager.js +4 -5
- package/dist/core/SQLiteStorage.d.ts.map +1 -1
- package/dist/core/SQLiteStorage.js +2 -3
- package/dist/core/TransactionManager.d.ts +2 -207
- package/dist/core/TransactionManager.d.ts.map +1 -1
- package/dist/core/TransactionManager.js +6 -482
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -3
- package/dist/features/ArchiveManager.d.ts +2 -14
- package/dist/features/ArchiveManager.d.ts.map +1 -1
- package/dist/features/ArchiveManager.js +3 -44
- package/dist/features/CompressionManager.d.ts +4 -14
- package/dist/features/CompressionManager.d.ts.map +1 -1
- package/dist/features/CompressionManager.js +9 -74
- package/dist/features/IOManager.d.ts +2 -6
- package/dist/features/IOManager.d.ts.map +1 -1
- package/dist/features/IOManager.js +10 -105
- package/dist/features/StreamingExporter.d.ts +4 -27
- package/dist/features/StreamingExporter.d.ts.map +1 -1
- package/dist/features/StreamingExporter.js +4 -65
- package/dist/features/index.d.ts +0 -2
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/index.js +0 -3
- package/dist/search/EmbeddingService.d.ts +9 -108
- package/dist/search/EmbeddingService.d.ts.map +1 -1
- package/dist/search/EmbeddingService.js +15 -187
- package/dist/search/FuzzySearch.js +1 -1
- package/dist/search/SavedSearchManager.d.ts.map +1 -1
- package/dist/search/SavedSearchManager.js +2 -3
- package/dist/search/SearchManager.d.ts +1 -42
- package/dist/search/SearchManager.d.ts.map +1 -1
- package/dist/search/SearchManager.js +0 -115
- package/dist/search/SemanticSearch.d.ts +1 -4
- package/dist/search/SemanticSearch.d.ts.map +1 -1
- package/dist/search/SemanticSearch.js +2 -12
- package/dist/search/TFIDFIndexManager.d.ts +0 -88
- package/dist/search/TFIDFIndexManager.d.ts.map +1 -1
- package/dist/search/TFIDFIndexManager.js +0 -217
- package/dist/search/index.d.ts +1 -18
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +1 -32
- package/dist/server/MCPServer.d.ts.map +1 -1
- package/dist/server/MCPServer.js +4 -1
- package/dist/server/responseCompressor.js +5 -5
- package/dist/server/toolDefinitions.d.ts.map +1 -1
- package/dist/server/toolDefinitions.js +5 -1
- package/dist/server/toolHandlers.d.ts +9 -5
- package/dist/server/toolHandlers.d.ts.map +1 -1
- package/dist/server/toolHandlers.js +23 -8
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -579
- package/dist/types/types.d.ts.map +1 -1
- package/dist/utils/compressedCache.d.ts +0 -29
- package/dist/utils/compressedCache.d.ts.map +1 -1
- package/dist/utils/compressedCache.js +0 -39
- package/dist/utils/entityUtils.d.ts +1 -59
- package/dist/utils/entityUtils.d.ts.map +1 -1
- package/dist/utils/entityUtils.js +3 -113
- package/dist/utils/errors.d.ts +0 -18
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +0 -24
- package/dist/utils/index.d.ts +2 -6
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -14
- package/dist/utils/logger.d.ts +0 -7
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +2 -9
- package/dist/utils/parallelUtils.d.ts +1 -5
- package/dist/utils/parallelUtils.d.ts.map +1 -1
- package/dist/utils/parallelUtils.js +1 -23
- package/dist/utils/schemas.d.ts +16 -16
- package/dist/utils/schemas.d.ts.map +1 -1
- package/dist/utils/schemas.js +12 -12
- package/dist/utils/taskScheduler.d.ts +0 -4
- package/dist/utils/taskScheduler.d.ts.map +1 -1
- package/dist/utils/taskScheduler.js +1 -21
- package/dist/workers/WorkerPool.d.ts +81 -0
- package/dist/workers/WorkerPool.d.ts.map +1 -0
- package/dist/workers/WorkerPool.js +121 -0
- package/dist/workers/index.d.ts +1 -1
- package/dist/workers/index.d.ts.map +1 -1
- package/dist/workers/levenshteinWorker.js +1 -1
- package/package.json +1 -4
- package/dist/__tests__/file-path.test.js +0 -119
- package/dist/__tests__/knowledge-graph.test.js +0 -318
- package/dist/core/GraphEventEmitter.d.ts +0 -202
- package/dist/core/GraphEventEmitter.d.ts.map +0 -1
- package/dist/core/GraphEventEmitter.js +0 -346
- package/dist/features/KeywordExtractor.d.ts +0 -61
- package/dist/features/KeywordExtractor.d.ts.map +0 -1
- package/dist/features/KeywordExtractor.js +0 -126
- package/dist/features/ObservationNormalizer.d.ts +0 -90
- package/dist/features/ObservationNormalizer.d.ts.map +0 -1
- package/dist/features/ObservationNormalizer.js +0 -193
- package/dist/memory.jsonl +0 -1
- package/dist/search/BM25Search.d.ts +0 -148
- package/dist/search/BM25Search.d.ts.map +0 -1
- package/dist/search/BM25Search.js +0 -339
- package/dist/search/EarlyTerminationManager.d.ts +0 -140
- package/dist/search/EarlyTerminationManager.d.ts.map +0 -1
- package/dist/search/EarlyTerminationManager.js +0 -279
- package/dist/search/EmbeddingCache.d.ts +0 -175
- package/dist/search/EmbeddingCache.d.ts.map +0 -1
- package/dist/search/EmbeddingCache.js +0 -246
- package/dist/search/HybridScorer.d.ts +0 -181
- package/dist/search/HybridScorer.d.ts.map +0 -1
- package/dist/search/HybridScorer.js +0 -257
- package/dist/search/HybridSearchManager.d.ts +0 -80
- package/dist/search/HybridSearchManager.d.ts.map +0 -1
- package/dist/search/HybridSearchManager.js +0 -187
- package/dist/search/IncrementalIndexer.d.ts +0 -201
- package/dist/search/IncrementalIndexer.d.ts.map +0 -1
- package/dist/search/IncrementalIndexer.js +0 -342
- package/dist/search/OptimizedInvertedIndex.d.ts +0 -163
- package/dist/search/OptimizedInvertedIndex.d.ts.map +0 -1
- package/dist/search/OptimizedInvertedIndex.js +0 -358
- package/dist/search/ParallelSearchExecutor.d.ts +0 -172
- package/dist/search/ParallelSearchExecutor.d.ts.map +0 -1
- package/dist/search/ParallelSearchExecutor.js +0 -309
- package/dist/search/QuantizedVectorStore.d.ts +0 -171
- package/dist/search/QuantizedVectorStore.d.ts.map +0 -1
- package/dist/search/QuantizedVectorStore.js +0 -307
- package/dist/search/QueryAnalyzer.d.ts +0 -76
- package/dist/search/QueryAnalyzer.d.ts.map +0 -1
- package/dist/search/QueryAnalyzer.js +0 -227
- package/dist/search/QueryCostEstimator.d.ts +0 -244
- package/dist/search/QueryCostEstimator.d.ts.map +0 -1
- package/dist/search/QueryCostEstimator.js +0 -652
- package/dist/search/QueryPlanCache.d.ts +0 -220
- package/dist/search/QueryPlanCache.d.ts.map +0 -1
- package/dist/search/QueryPlanCache.js +0 -379
- package/dist/search/QueryPlanner.d.ts +0 -58
- package/dist/search/QueryPlanner.d.ts.map +0 -1
- package/dist/search/QueryPlanner.js +0 -137
- package/dist/search/ReflectionManager.d.ts +0 -120
- package/dist/search/ReflectionManager.d.ts.map +0 -1
- package/dist/search/ReflectionManager.js +0 -231
- package/dist/search/SymbolicSearch.d.ts +0 -61
- package/dist/search/SymbolicSearch.d.ts.map +0 -1
- package/dist/search/SymbolicSearch.js +0 -163
- package/dist/search/TFIDFEventSync.d.ts +0 -85
- package/dist/search/TFIDFEventSync.d.ts.map +0 -1
- package/dist/search/TFIDFEventSync.js +0 -133
- package/dist/utils/BatchProcessor.d.ts +0 -271
- package/dist/utils/BatchProcessor.d.ts.map +0 -1
- package/dist/utils/BatchProcessor.js +0 -376
- package/dist/utils/MemoryMonitor.d.ts +0 -176
- package/dist/utils/MemoryMonitor.d.ts.map +0 -1
- package/dist/utils/MemoryMonitor.js +0 -305
- package/dist/utils/WorkerPoolManager.d.ts +0 -233
- package/dist/utils/WorkerPoolManager.d.ts.map +0 -1
- package/dist/utils/WorkerPoolManager.js +0 -420
- package/dist/utils/operationUtils.d.ts +0 -124
- package/dist/utils/operationUtils.d.ts.map +0 -1
- package/dist/utils/operationUtils.js +0 -175
- package/dist/vitest.config.js +0 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManagerContext.d.ts","sourceRoot":"","sources":["../../src/core/ManagerContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ManagerContext.d.ts","sourceRoot":"","sources":["../../src/core/ManagerContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAA6C,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,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E3B;IAED,yDAAyD;IACzD,IAAI,gBAAgB,IAAI,gBAAgB,CAEvC;IAED,kEAAkE;IAClE,IAAI,kBAAkB,IAAI,kBAAkB,CAE3C;IAED,kDAAkD;IAClD,IAAI,cAAc,IAAI,cAAc,CAEnC;CACF"}
|
|
@@ -8,14 +8,13 @@
|
|
|
8
8
|
* @module core/ManagerContext
|
|
9
9
|
*/
|
|
10
10
|
import path from 'path';
|
|
11
|
-
import {
|
|
11
|
+
import { GraphStorage } from './GraphStorage.js';
|
|
12
12
|
import { EntityManager } from './EntityManager.js';
|
|
13
13
|
import { RelationManager } from './RelationManager.js';
|
|
14
14
|
import { ObservationManager } from './ObservationManager.js';
|
|
15
15
|
import { HierarchyManager } from './HierarchyManager.js';
|
|
16
16
|
import { GraphTraversal } from './GraphTraversal.js';
|
|
17
17
|
import { SearchManager } from '../search/SearchManager.js';
|
|
18
|
-
import { RankedSearch } from '../search/RankedSearch.js';
|
|
19
18
|
import { SemanticSearch, createEmbeddingService, createVectorStore } from '../search/index.js';
|
|
20
19
|
import { IOManager } from '../features/IOManager.js';
|
|
21
20
|
import { TagManager } from '../features/TagManager.js';
|
|
@@ -28,8 +27,6 @@ import { getEmbeddingConfig } from '../utils/constants.js';
|
|
|
28
27
|
* Provides direct manager access for toolHandlers.
|
|
29
28
|
*/
|
|
30
29
|
export class ManagerContext {
|
|
31
|
-
// Type as GraphStorage for manager compatibility; actual instance may be SQLiteStorage
|
|
32
|
-
// which implements the same interface via duck typing
|
|
33
30
|
storage;
|
|
34
31
|
savedSearchesFilePath;
|
|
35
32
|
tagAliasesFilePath;
|
|
@@ -41,7 +38,6 @@ export class ManagerContext {
|
|
|
41
38
|
_graphTraversal;
|
|
42
39
|
_searchManager;
|
|
43
40
|
_semanticSearch;
|
|
44
|
-
_rankedSearch;
|
|
45
41
|
_ioManager;
|
|
46
42
|
_tagManager;
|
|
47
43
|
_analyticsManager;
|
|
@@ -53,9 +49,7 @@ export class ManagerContext {
|
|
|
53
49
|
const basename = path.basename(memoryFilePath, path.extname(memoryFilePath));
|
|
54
50
|
this.savedSearchesFilePath = path.join(dir, `${basename}-saved-searches.jsonl`);
|
|
55
51
|
this.tagAliasesFilePath = path.join(dir, `${basename}-tag-aliases.jsonl`);
|
|
56
|
-
|
|
57
|
-
// Type assertion: SQLiteStorage implements same interface as GraphStorage
|
|
58
|
-
this.storage = createStorageFromPath(memoryFilePath);
|
|
52
|
+
this.storage = new GraphStorage(memoryFilePath);
|
|
59
53
|
}
|
|
60
54
|
// ==================== MANAGER ACCESSORS ====================
|
|
61
55
|
// Use these for direct manager access in toolHandlers
|
|
@@ -101,10 +95,6 @@ export class ManagerContext {
|
|
|
101
95
|
}
|
|
102
96
|
return this._semanticSearch;
|
|
103
97
|
}
|
|
104
|
-
/** RankedSearch - Phase 11: TF-IDF/BM25 ranked search for hybrid search */
|
|
105
|
-
get rankedSearch() {
|
|
106
|
-
return (this._rankedSearch ??= new RankedSearch(this.storage));
|
|
107
|
-
}
|
|
108
98
|
/** IOManager - Import, export, and backup operations */
|
|
109
99
|
get ioManager() {
|
|
110
100
|
return (this._ioManager ??= new IOManager(this.storage));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationManager.d.ts","sourceRoot":"","sources":["../../src/core/RelationManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKtD;;GAEG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACG,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAiEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACG,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"RelationManager.d.ts","sourceRoot":"","sources":["../../src/core/RelationManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKtD;;GAEG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACG,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAiEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACG,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;CAK5D"}
|
|
@@ -158,11 +158,10 @@ export class RelationManager {
|
|
|
158
158
|
affectedEntityNames.add(rel.from);
|
|
159
159
|
affectedEntityNames.add(rel.to);
|
|
160
160
|
});
|
|
161
|
-
//
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
graph.relations = graph.relations.filter(r => !relationsToDeleteSet.has(`${r.from}|${r.to}|${r.relationType}`));
|
|
161
|
+
// Remove relations
|
|
162
|
+
graph.relations = graph.relations.filter(r => !relations.some(delRelation => r.from === delRelation.from &&
|
|
163
|
+
r.to === delRelation.to &&
|
|
164
|
+
r.relationType === delRelation.relationType));
|
|
166
165
|
// Update lastModified for affected entities
|
|
167
166
|
graph.entities.forEach(entity => {
|
|
168
167
|
if (affectedEntityNames.has(entity.name)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLiteStorage.d.ts","sourceRoot":"","sources":["../../src/core/SQLiteStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"SQLiteStorage.d.ts","sourceRoot":"","sources":["../../src/core/SQLiteStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIhI;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAc,YAAW,aAAa;IAyDrC,OAAO,CAAC,UAAU;IAxD9B;;;;;OAKG;IACH,OAAO,CAAC,KAAK,CAAe;IAE5B;;OAEG;IACH,OAAO,CAAC,EAAE,CAA6B;IAEvC;;OAEG;IACH,OAAO,CAAC,WAAW,CAAkB;IAErC;;;OAGG;IACH,OAAO,CAAC,KAAK,CAA+B;IAE5C;;OAEG;IACH,OAAO,CAAC,SAAS,CAA8B;IAE/C;;OAEG;IACH,OAAO,CAAC,SAAS,CAA8B;IAE/C;;OAEG;IACH,OAAO,CAAC,cAAc,CAAyC;IAE/D;;;OAGG;IACH,OAAO,CAAC,cAAc,CAAa;IAEnC;;;OAGG;IACH,OAAO,CAAC,0BAA0B,CAAsC;IAExE;;;;OAIG;gBACiB,UAAU,EAAE,MAAM;IAEtC;;OAEG;IACH,OAAO,CAAC,UAAU;IAmBlB;;OAEG;IACH,OAAO,CAAC,YAAY;IAkFpB;;OAEG;IACH,OAAO,CAAC,SAAS;IA2BjB;;OAEG;IACH,OAAO,CAAC,WAAW;IAanB;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E,CAAA;KAAE;CAmBzD"}
|
|
@@ -23,7 +23,6 @@ import Database from 'better-sqlite3';
|
|
|
23
23
|
import { Mutex } from 'async-mutex';
|
|
24
24
|
import { clearAllSearchCaches } from '../utils/searchCache.js';
|
|
25
25
|
import { NameIndex, TypeIndex } from '../utils/indexes.js';
|
|
26
|
-
import { sanitizeObject } from '../utils/index.js';
|
|
27
26
|
/**
|
|
28
27
|
* SQLiteStorage manages persistence of the knowledge graph using native SQLite.
|
|
29
28
|
*
|
|
@@ -443,8 +442,8 @@ export class SQLiteStorage {
|
|
|
443
442
|
}
|
|
444
443
|
// Track old type for index update
|
|
445
444
|
const oldType = entity.entityType;
|
|
446
|
-
// Apply updates to cached entity
|
|
447
|
-
Object.assign(entity,
|
|
445
|
+
// Apply updates to cached entity
|
|
446
|
+
Object.assign(entity, updates);
|
|
448
447
|
entity.lastModified = new Date().toISOString();
|
|
449
448
|
// Update in database
|
|
450
449
|
const stmt = this.db.prepare(`
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module core/TransactionManager
|
|
9
9
|
*/
|
|
10
|
-
import type { Entity, Relation
|
|
10
|
+
import type { Entity, Relation } from '../types/index.js';
|
|
11
11
|
import type { GraphStorage } from './GraphStorage.js';
|
|
12
12
|
/**
|
|
13
13
|
* Types of operations that can be performed in a transaction.
|
|
@@ -192,11 +192,7 @@ export declare class TransactionManager {
|
|
|
192
192
|
* Creates a backup before applying changes. If any operation fails,
|
|
193
193
|
* automatically rolls back to the pre-transaction state.
|
|
194
194
|
*
|
|
195
|
-
* Phase 9B: Supports progress tracking and cancellation via LongRunningOperationOptions.
|
|
196
|
-
*
|
|
197
|
-
* @param options - Optional progress/cancellation options (Phase 9B)
|
|
198
195
|
* @returns Promise resolving to transaction result
|
|
199
|
-
* @throws {OperationCancelledError} If operation is cancelled via signal (Phase 9B)
|
|
200
196
|
*
|
|
201
197
|
* @example
|
|
202
198
|
* ```typescript
|
|
@@ -210,14 +206,9 @@ export declare class TransactionManager {
|
|
|
210
206
|
* } else {
|
|
211
207
|
* console.error(`Transaction failed: ${result.error}`);
|
|
212
208
|
* }
|
|
213
|
-
*
|
|
214
|
-
* // With progress tracking (Phase 9B)
|
|
215
|
-
* const result = await txManager.commit({
|
|
216
|
-
* onProgress: (p) => console.log(`${p.percentage}% complete`),
|
|
217
|
-
* });
|
|
218
209
|
* ```
|
|
219
210
|
*/
|
|
220
|
-
commit(
|
|
211
|
+
commit(): Promise<TransactionResult>;
|
|
221
212
|
/**
|
|
222
213
|
* Rollback the current transaction.
|
|
223
214
|
*
|
|
@@ -265,200 +256,4 @@ export declare class TransactionManager {
|
|
|
265
256
|
*/
|
|
266
257
|
private applyOperation;
|
|
267
258
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Phase 10 Sprint 1: Fluent API for building and executing batch transactions.
|
|
270
|
-
*
|
|
271
|
-
* BatchTransaction provides a builder pattern for accumulating multiple
|
|
272
|
-
* graph operations and executing them atomically in a single transaction.
|
|
273
|
-
* This reduces I/O overhead and ensures consistency across related changes.
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* ```typescript
|
|
277
|
-
* const storage = new GraphStorage('/data/memory.jsonl');
|
|
278
|
-
* const batch = new BatchTransaction(storage);
|
|
279
|
-
*
|
|
280
|
-
* // Build the batch with fluent API
|
|
281
|
-
* const result = await batch
|
|
282
|
-
* .createEntity({ name: 'Alice', entityType: 'person', observations: ['Developer'] })
|
|
283
|
-
* .createEntity({ name: 'Bob', entityType: 'person', observations: ['Designer'] })
|
|
284
|
-
* .createRelation({ from: 'Alice', to: 'Bob', relationType: 'knows' })
|
|
285
|
-
* .updateEntity('Alice', { importance: 8 })
|
|
286
|
-
* .execute();
|
|
287
|
-
*
|
|
288
|
-
* if (result.success) {
|
|
289
|
-
* console.log(`Batch completed: ${result.operationsExecuted} operations in ${result.executionTimeMs}ms`);
|
|
290
|
-
* }
|
|
291
|
-
* ```
|
|
292
|
-
*/
|
|
293
|
-
export declare class BatchTransaction {
|
|
294
|
-
private operations;
|
|
295
|
-
private storage;
|
|
296
|
-
/**
|
|
297
|
-
* Create a new BatchTransaction instance.
|
|
298
|
-
*
|
|
299
|
-
* @param storage - GraphStorage instance to execute operations against
|
|
300
|
-
*/
|
|
301
|
-
constructor(storage: GraphStorage);
|
|
302
|
-
/**
|
|
303
|
-
* Add a create entity operation to the batch.
|
|
304
|
-
*
|
|
305
|
-
* @param entity - Entity to create (without timestamps)
|
|
306
|
-
* @returns This BatchTransaction for chaining
|
|
307
|
-
*
|
|
308
|
-
* @example
|
|
309
|
-
* ```typescript
|
|
310
|
-
* batch.createEntity({
|
|
311
|
-
* name: 'Alice',
|
|
312
|
-
* entityType: 'person',
|
|
313
|
-
* observations: ['Software engineer'],
|
|
314
|
-
* importance: 8
|
|
315
|
-
* });
|
|
316
|
-
* ```
|
|
317
|
-
*/
|
|
318
|
-
createEntity(entity: Omit<Entity, 'createdAt' | 'lastModified'>): this;
|
|
319
|
-
/**
|
|
320
|
-
* Add an update entity operation to the batch.
|
|
321
|
-
*
|
|
322
|
-
* @param name - Name of entity to update
|
|
323
|
-
* @param updates - Partial entity updates
|
|
324
|
-
* @returns This BatchTransaction for chaining
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* ```typescript
|
|
328
|
-
* batch.updateEntity('Alice', { importance: 9 });
|
|
329
|
-
* ```
|
|
330
|
-
*/
|
|
331
|
-
updateEntity(name: string, updates: Partial<Entity>): this;
|
|
332
|
-
/**
|
|
333
|
-
* Add a delete entity operation to the batch.
|
|
334
|
-
*
|
|
335
|
-
* @param name - Name of entity to delete
|
|
336
|
-
* @returns This BatchTransaction for chaining
|
|
337
|
-
*
|
|
338
|
-
* @example
|
|
339
|
-
* ```typescript
|
|
340
|
-
* batch.deleteEntity('OldEntity');
|
|
341
|
-
* ```
|
|
342
|
-
*/
|
|
343
|
-
deleteEntity(name: string): this;
|
|
344
|
-
/**
|
|
345
|
-
* Add a create relation operation to the batch.
|
|
346
|
-
*
|
|
347
|
-
* @param relation - Relation to create (without timestamps)
|
|
348
|
-
* @returns This BatchTransaction for chaining
|
|
349
|
-
*
|
|
350
|
-
* @example
|
|
351
|
-
* ```typescript
|
|
352
|
-
* batch.createRelation({
|
|
353
|
-
* from: 'Alice',
|
|
354
|
-
* to: 'Bob',
|
|
355
|
-
* relationType: 'mentors'
|
|
356
|
-
* });
|
|
357
|
-
* ```
|
|
358
|
-
*/
|
|
359
|
-
createRelation(relation: Omit<Relation, 'createdAt' | 'lastModified'>): this;
|
|
360
|
-
/**
|
|
361
|
-
* Add a delete relation operation to the batch.
|
|
362
|
-
*
|
|
363
|
-
* @param from - Source entity name
|
|
364
|
-
* @param to - Target entity name
|
|
365
|
-
* @param relationType - Type of relation
|
|
366
|
-
* @returns This BatchTransaction for chaining
|
|
367
|
-
*
|
|
368
|
-
* @example
|
|
369
|
-
* ```typescript
|
|
370
|
-
* batch.deleteRelation('Alice', 'Bob', 'mentors');
|
|
371
|
-
* ```
|
|
372
|
-
*/
|
|
373
|
-
deleteRelation(from: string, to: string, relationType: string): this;
|
|
374
|
-
/**
|
|
375
|
-
* Add observations to an existing entity.
|
|
376
|
-
*
|
|
377
|
-
* @param name - Name of entity to add observations to
|
|
378
|
-
* @param observations - Observations to add
|
|
379
|
-
* @returns This BatchTransaction for chaining
|
|
380
|
-
*
|
|
381
|
-
* @example
|
|
382
|
-
* ```typescript
|
|
383
|
-
* batch.addObservations('Alice', ['Knows TypeScript', 'Leads team']);
|
|
384
|
-
* ```
|
|
385
|
-
*/
|
|
386
|
-
addObservations(name: string, observations: string[]): this;
|
|
387
|
-
/**
|
|
388
|
-
* Delete observations from an existing entity.
|
|
389
|
-
*
|
|
390
|
-
* @param name - Name of entity to delete observations from
|
|
391
|
-
* @param observations - Observations to delete
|
|
392
|
-
* @returns This BatchTransaction for chaining
|
|
393
|
-
*
|
|
394
|
-
* @example
|
|
395
|
-
* ```typescript
|
|
396
|
-
* batch.deleteObservations('Alice', ['Old fact']);
|
|
397
|
-
* ```
|
|
398
|
-
*/
|
|
399
|
-
deleteObservations(name: string, observations: string[]): this;
|
|
400
|
-
/**
|
|
401
|
-
* Add multiple operations from an array.
|
|
402
|
-
*
|
|
403
|
-
* @param operations - Array of batch operations
|
|
404
|
-
* @returns This BatchTransaction for chaining
|
|
405
|
-
*
|
|
406
|
-
* @example
|
|
407
|
-
* ```typescript
|
|
408
|
-
* batch.addOperations([
|
|
409
|
-
* { type: 'createEntity', data: { name: 'A', entityType: 'x', observations: [] } },
|
|
410
|
-
* { type: 'createEntity', data: { name: 'B', entityType: 'x', observations: [] } }
|
|
411
|
-
* ]);
|
|
412
|
-
* ```
|
|
413
|
-
*/
|
|
414
|
-
addOperations(operations: BatchOperation[]): this;
|
|
415
|
-
/**
|
|
416
|
-
* Get the number of operations in this batch.
|
|
417
|
-
*
|
|
418
|
-
* @returns Number of operations queued
|
|
419
|
-
*/
|
|
420
|
-
size(): number;
|
|
421
|
-
/**
|
|
422
|
-
* Clear all operations from the batch.
|
|
423
|
-
*
|
|
424
|
-
* @returns This BatchTransaction for chaining
|
|
425
|
-
*/
|
|
426
|
-
clear(): this;
|
|
427
|
-
/**
|
|
428
|
-
* Get a copy of the operations in this batch.
|
|
429
|
-
*
|
|
430
|
-
* @returns Array of batch operations
|
|
431
|
-
*/
|
|
432
|
-
getOperations(): BatchOperation[];
|
|
433
|
-
/**
|
|
434
|
-
* Execute all operations in the batch atomically.
|
|
435
|
-
*
|
|
436
|
-
* All operations are applied within a single transaction. If any
|
|
437
|
-
* operation fails, all changes are rolled back (when stopOnError is true).
|
|
438
|
-
*
|
|
439
|
-
* @param options - Batch execution options
|
|
440
|
-
* @returns Promise resolving to batch result
|
|
441
|
-
*
|
|
442
|
-
* @example
|
|
443
|
-
* ```typescript
|
|
444
|
-
* const result = await batch.execute();
|
|
445
|
-
* if (result.success) {
|
|
446
|
-
* console.log(`Created ${result.entitiesCreated} entities`);
|
|
447
|
-
* } else {
|
|
448
|
-
* console.error(`Failed at operation ${result.failedOperationIndex}: ${result.error}`);
|
|
449
|
-
* }
|
|
450
|
-
* ```
|
|
451
|
-
*/
|
|
452
|
-
execute(options?: BatchOptions): Promise<BatchResult>;
|
|
453
|
-
/**
|
|
454
|
-
* Validate all operations before executing.
|
|
455
|
-
* @private
|
|
456
|
-
*/
|
|
457
|
-
private validateOperations;
|
|
458
|
-
/**
|
|
459
|
-
* Apply a single batch operation to the graph.
|
|
460
|
-
* @private
|
|
461
|
-
*/
|
|
462
|
-
private applyBatchOperation;
|
|
463
|
-
}
|
|
464
259
|
//# sourceMappingURL=TransactionManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionManager.d.ts","sourceRoot":"","sources":["../../src/core/TransactionManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"TransactionManager.d.ts","sourceRoot":"","sources":["../../src/core/TransactionManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD;;GAEG;AACH,oBAAY,aAAa;IACvB,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IACE,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,cAAc,CAAC,CAAC;CAClD,GACD;IACE,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC;IAClC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,CAA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