@danielsimonjr/memory-mcp 12.2.3 → 12.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -102
- package/dist/index.js +6 -0
- package/dist/server/toolDefinitions.d.ts.map +1 -1
- package/dist/server/toolDefinitions.js +745 -3
- package/dist/server/toolHandlers.d.ts +1 -9
- package/dist/server/toolHandlers.d.ts.map +1 -1
- package/dist/server/toolHandlers.js +859 -11
- package/package.json +9 -6
- package/dist/core/EntityManager.d.ts +0 -263
- package/dist/core/EntityManager.d.ts.map +0 -1
- package/dist/core/EntityManager.js +0 -478
- package/dist/core/GraphStorage.d.ts +0 -344
- package/dist/core/GraphStorage.d.ts.map +0 -1
- package/dist/core/GraphStorage.js +0 -708
- package/dist/core/GraphTraversal.d.ts +0 -136
- package/dist/core/GraphTraversal.d.ts.map +0 -1
- package/dist/core/GraphTraversal.js +0 -556
- package/dist/core/HierarchyManager.d.ts +0 -111
- package/dist/core/HierarchyManager.d.ts.map +0 -1
- package/dist/core/HierarchyManager.js +0 -224
- package/dist/core/ManagerContext.d.ts +0 -72
- package/dist/core/ManagerContext.d.ts.map +0 -1
- package/dist/core/ManagerContext.js +0 -118
- package/dist/core/ObservationManager.d.ts +0 -85
- package/dist/core/ObservationManager.d.ts.map +0 -1
- package/dist/core/ObservationManager.js +0 -123
- package/dist/core/RelationManager.d.ts +0 -131
- package/dist/core/RelationManager.d.ts.map +0 -1
- package/dist/core/RelationManager.js +0 -210
- package/dist/core/SQLiteStorage.d.ts +0 -354
- package/dist/core/SQLiteStorage.d.ts.map +0 -1
- package/dist/core/SQLiteStorage.js +0 -917
- package/dist/core/StorageFactory.d.ts +0 -45
- package/dist/core/StorageFactory.d.ts.map +0 -1
- package/dist/core/StorageFactory.js +0 -64
- package/dist/core/TransactionManager.d.ts +0 -259
- package/dist/core/TransactionManager.d.ts.map +0 -1
- package/dist/core/TransactionManager.js +0 -392
- package/dist/core/index.d.ts +0 -16
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -17
- package/dist/features/AnalyticsManager.d.ts +0 -44
- package/dist/features/AnalyticsManager.d.ts.map +0 -1
- package/dist/features/AnalyticsManager.js +0 -223
- package/dist/features/ArchiveManager.d.ts +0 -121
- package/dist/features/ArchiveManager.d.ts.map +0 -1
- package/dist/features/ArchiveManager.js +0 -240
- package/dist/features/CompressionManager.d.ts +0 -109
- package/dist/features/CompressionManager.d.ts.map +0 -1
- package/dist/features/CompressionManager.js +0 -404
- package/dist/features/IOManager.d.ts +0 -221
- package/dist/features/IOManager.d.ts.map +0 -1
- package/dist/features/IOManager.js +0 -997
- package/dist/features/StreamingExporter.d.ts +0 -105
- package/dist/features/StreamingExporter.d.ts.map +0 -1
- package/dist/features/StreamingExporter.js +0 -150
- package/dist/features/TagManager.d.ts +0 -147
- package/dist/features/TagManager.d.ts.map +0 -1
- package/dist/features/TagManager.js +0 -210
- package/dist/features/index.d.ts +0 -12
- package/dist/features/index.d.ts.map +0 -1
- package/dist/features/index.js +0 -11
- package/dist/search/BasicSearch.d.ts +0 -51
- package/dist/search/BasicSearch.d.ts.map +0 -1
- package/dist/search/BasicSearch.js +0 -137
- package/dist/search/BooleanSearch.d.ts +0 -98
- package/dist/search/BooleanSearch.d.ts.map +0 -1
- package/dist/search/BooleanSearch.js +0 -430
- package/dist/search/EmbeddingService.d.ts +0 -178
- package/dist/search/EmbeddingService.d.ts.map +0 -1
- package/dist/search/EmbeddingService.js +0 -358
- package/dist/search/FuzzySearch.d.ts +0 -118
- package/dist/search/FuzzySearch.d.ts.map +0 -1
- package/dist/search/FuzzySearch.js +0 -312
- package/dist/search/RankedSearch.d.ts +0 -71
- package/dist/search/RankedSearch.d.ts.map +0 -1
- package/dist/search/RankedSearch.js +0 -238
- package/dist/search/SavedSearchManager.d.ts +0 -79
- package/dist/search/SavedSearchManager.d.ts.map +0 -1
- package/dist/search/SavedSearchManager.js +0 -145
- package/dist/search/SearchFilterChain.d.ts +0 -120
- package/dist/search/SearchFilterChain.d.ts.map +0 -1
- package/dist/search/SearchFilterChain.js +0 -185
- package/dist/search/SearchManager.d.ts +0 -285
- package/dist/search/SearchManager.d.ts.map +0 -1
- package/dist/search/SearchManager.js +0 -338
- package/dist/search/SearchSuggestions.d.ts +0 -27
- package/dist/search/SearchSuggestions.d.ts.map +0 -1
- package/dist/search/SearchSuggestions.js +0 -57
- package/dist/search/SemanticSearch.d.ts +0 -146
- package/dist/search/SemanticSearch.d.ts.map +0 -1
- package/dist/search/SemanticSearch.js +0 -313
- package/dist/search/TFIDFIndexManager.d.ts +0 -63
- package/dist/search/TFIDFIndexManager.d.ts.map +0 -1
- package/dist/search/TFIDFIndexManager.js +0 -215
- package/dist/search/VectorStore.d.ts +0 -235
- package/dist/search/VectorStore.d.ts.map +0 -1
- package/dist/search/VectorStore.js +0 -311
- package/dist/search/index.d.ts +0 -18
- package/dist/search/index.d.ts.map +0 -1
- package/dist/search/index.js +0 -21
- package/dist/types/index.d.ts +0 -13
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -12
- package/dist/types/types.d.ts +0 -1234
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js +0 -9
- package/dist/utils/compressedCache.d.ts +0 -192
- package/dist/utils/compressedCache.d.ts.map +0 -1
- package/dist/utils/compressedCache.js +0 -309
- package/dist/utils/compressionUtil.d.ts +0 -214
- package/dist/utils/compressionUtil.d.ts.map +0 -1
- package/dist/utils/compressionUtil.js +0 -247
- package/dist/utils/constants.d.ts +0 -245
- package/dist/utils/constants.d.ts.map +0 -1
- package/dist/utils/constants.js +0 -252
- package/dist/utils/entityUtils.d.ts +0 -321
- package/dist/utils/entityUtils.d.ts.map +0 -1
- package/dist/utils/entityUtils.js +0 -538
- package/dist/utils/errors.d.ts +0 -77
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -121
- package/dist/utils/formatters.d.ts +0 -145
- package/dist/utils/formatters.d.ts.map +0 -1
- package/dist/utils/formatters.js +0 -132
- package/dist/utils/index.d.ts +0 -22
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -75
- package/dist/utils/indexes.d.ts +0 -270
- package/dist/utils/indexes.d.ts.map +0 -1
- package/dist/utils/indexes.js +0 -526
- package/dist/utils/logger.d.ts +0 -24
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -33
- package/dist/utils/parallelUtils.d.ts +0 -72
- package/dist/utils/parallelUtils.d.ts.map +0 -1
- package/dist/utils/parallelUtils.js +0 -169
- package/dist/utils/schemas.d.ts +0 -374
- package/dist/utils/schemas.d.ts.map +0 -1
- package/dist/utils/schemas.js +0 -484
- package/dist/utils/searchAlgorithms.d.ts +0 -99
- package/dist/utils/searchAlgorithms.d.ts.map +0 -1
- package/dist/utils/searchAlgorithms.js +0 -167
- package/dist/utils/searchCache.d.ts +0 -108
- package/dist/utils/searchCache.d.ts.map +0 -1
- package/dist/utils/searchCache.js +0 -209
- package/dist/utils/taskScheduler.d.ts +0 -290
- package/dist/utils/taskScheduler.d.ts.map +0 -1
- package/dist/utils/taskScheduler.js +0 -466
- package/dist/workers/WorkerPool.d.ts +0 -81
- package/dist/workers/WorkerPool.d.ts.map +0 -1
- package/dist/workers/WorkerPool.js +0 -121
- package/dist/workers/index.d.ts +0 -12
- package/dist/workers/index.d.ts.map +0 -1
- package/dist/workers/index.js +0 -9
- package/dist/workers/levenshteinWorker.d.ts +0 -60
- package/dist/workers/levenshteinWorker.d.ts.map +0 -1
- package/dist/workers/levenshteinWorker.js +0 -98
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage Factory
|
|
3
|
-
*
|
|
4
|
-
* Factory for creating IGraphStorage implementations.
|
|
5
|
-
* Supports different storage backends based on configuration.
|
|
6
|
-
*
|
|
7
|
-
* Supported storage types:
|
|
8
|
-
* - 'jsonl': JSONL file-based storage (default) - simple, human-readable
|
|
9
|
-
* - 'sqlite': SQLite database storage (better-sqlite3 native) - indexed, ACID transactions, FTS5
|
|
10
|
-
*
|
|
11
|
-
* @module core/StorageFactory
|
|
12
|
-
*/
|
|
13
|
-
import type { IGraphStorage, StorageConfig } from '../types/index.js';
|
|
14
|
-
/**
|
|
15
|
-
* Create a storage instance based on configuration.
|
|
16
|
-
*
|
|
17
|
-
* Uses environment variable MEMORY_STORAGE_TYPE to override default.
|
|
18
|
-
*
|
|
19
|
-
* @param config - Storage configuration
|
|
20
|
-
* @returns IGraphStorage implementation
|
|
21
|
-
* @throws Error if storage type is not supported
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* // Create default JSONL storage
|
|
26
|
-
* const storage = createStorage({ type: 'jsonl', path: './memory.jsonl' });
|
|
27
|
-
*
|
|
28
|
-
* // Create SQLite storage
|
|
29
|
-
* const storage = createStorage({ type: 'sqlite', path: './memory.db' });
|
|
30
|
-
*
|
|
31
|
-
* // Or use path-only shorthand (uses MEMORY_STORAGE_TYPE env var or defaults to jsonl)
|
|
32
|
-
* const storage = createStorageFromPath('./memory.jsonl');
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare function createStorage(config: StorageConfig): IGraphStorage;
|
|
36
|
-
/**
|
|
37
|
-
* Create a storage instance from a file path.
|
|
38
|
-
*
|
|
39
|
-
* Uses default storage type (jsonl) or MEMORY_STORAGE_TYPE env var.
|
|
40
|
-
*
|
|
41
|
-
* @param path - Path to storage file
|
|
42
|
-
* @returns IGraphStorage implementation
|
|
43
|
-
*/
|
|
44
|
-
export declare function createStorageFromPath(path: string): IGraphStorage;
|
|
45
|
-
//# sourceMappingURL=StorageFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StorageFactory.d.ts","sourceRoot":"","sources":["../../src/core/StorageFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAOtE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAiBlE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAGjE"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage Factory
|
|
3
|
-
*
|
|
4
|
-
* Factory for creating IGraphStorage implementations.
|
|
5
|
-
* Supports different storage backends based on configuration.
|
|
6
|
-
*
|
|
7
|
-
* Supported storage types:
|
|
8
|
-
* - 'jsonl': JSONL file-based storage (default) - simple, human-readable
|
|
9
|
-
* - 'sqlite': SQLite database storage (better-sqlite3 native) - indexed, ACID transactions, FTS5
|
|
10
|
-
*
|
|
11
|
-
* @module core/StorageFactory
|
|
12
|
-
*/
|
|
13
|
-
import { GraphStorage } from './GraphStorage.js';
|
|
14
|
-
import { SQLiteStorage } from './SQLiteStorage.js';
|
|
15
|
-
/**
|
|
16
|
-
* Default storage type when not specified.
|
|
17
|
-
*/
|
|
18
|
-
const DEFAULT_STORAGE_TYPE = 'jsonl';
|
|
19
|
-
/**
|
|
20
|
-
* Create a storage instance based on configuration.
|
|
21
|
-
*
|
|
22
|
-
* Uses environment variable MEMORY_STORAGE_TYPE to override default.
|
|
23
|
-
*
|
|
24
|
-
* @param config - Storage configuration
|
|
25
|
-
* @returns IGraphStorage implementation
|
|
26
|
-
* @throws Error if storage type is not supported
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* // Create default JSONL storage
|
|
31
|
-
* const storage = createStorage({ type: 'jsonl', path: './memory.jsonl' });
|
|
32
|
-
*
|
|
33
|
-
* // Create SQLite storage
|
|
34
|
-
* const storage = createStorage({ type: 'sqlite', path: './memory.db' });
|
|
35
|
-
*
|
|
36
|
-
* // Or use path-only shorthand (uses MEMORY_STORAGE_TYPE env var or defaults to jsonl)
|
|
37
|
-
* const storage = createStorageFromPath('./memory.jsonl');
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export function createStorage(config) {
|
|
41
|
-
// Allow environment override
|
|
42
|
-
const storageType = process.env.MEMORY_STORAGE_TYPE || config.type || DEFAULT_STORAGE_TYPE;
|
|
43
|
-
switch (storageType) {
|
|
44
|
-
case 'jsonl':
|
|
45
|
-
return new GraphStorage(config.path);
|
|
46
|
-
case 'sqlite':
|
|
47
|
-
return new SQLiteStorage(config.path);
|
|
48
|
-
default:
|
|
49
|
-
throw new Error(`Unknown storage type: ${storageType}. ` +
|
|
50
|
-
`Supported types: jsonl, sqlite`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Create a storage instance from a file path.
|
|
55
|
-
*
|
|
56
|
-
* Uses default storage type (jsonl) or MEMORY_STORAGE_TYPE env var.
|
|
57
|
-
*
|
|
58
|
-
* @param path - Path to storage file
|
|
59
|
-
* @returns IGraphStorage implementation
|
|
60
|
-
*/
|
|
61
|
-
export function createStorageFromPath(path) {
|
|
62
|
-
const storageType = process.env.MEMORY_STORAGE_TYPE || DEFAULT_STORAGE_TYPE;
|
|
63
|
-
return createStorage({ type: storageType, path });
|
|
64
|
-
}
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transaction Manager
|
|
3
|
-
*
|
|
4
|
-
* Provides atomic transaction support for knowledge graph operations.
|
|
5
|
-
* Ensures data consistency by allowing multiple operations to be
|
|
6
|
-
* grouped together and committed atomically, with automatic rollback on failure.
|
|
7
|
-
*
|
|
8
|
-
* @module core/TransactionManager
|
|
9
|
-
*/
|
|
10
|
-
import type { Entity, Relation } from '../types/index.js';
|
|
11
|
-
import type { GraphStorage } from './GraphStorage.js';
|
|
12
|
-
/**
|
|
13
|
-
* Types of operations that can be performed in a transaction.
|
|
14
|
-
*/
|
|
15
|
-
export declare enum OperationType {
|
|
16
|
-
CREATE_ENTITY = "CREATE_ENTITY",
|
|
17
|
-
UPDATE_ENTITY = "UPDATE_ENTITY",
|
|
18
|
-
DELETE_ENTITY = "DELETE_ENTITY",
|
|
19
|
-
CREATE_RELATION = "CREATE_RELATION",
|
|
20
|
-
DELETE_RELATION = "DELETE_RELATION"
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Represents a single operation in a transaction using discriminated union.
|
|
24
|
-
*/
|
|
25
|
-
export type TransactionOperation = {
|
|
26
|
-
type: OperationType.CREATE_ENTITY;
|
|
27
|
-
data: Omit<Entity, 'createdAt' | 'lastModified'>;
|
|
28
|
-
} | {
|
|
29
|
-
type: OperationType.UPDATE_ENTITY;
|
|
30
|
-
data: {
|
|
31
|
-
name: string;
|
|
32
|
-
updates: Partial<Entity>;
|
|
33
|
-
};
|
|
34
|
-
} | {
|
|
35
|
-
type: OperationType.DELETE_ENTITY;
|
|
36
|
-
data: {
|
|
37
|
-
name: string;
|
|
38
|
-
};
|
|
39
|
-
} | {
|
|
40
|
-
type: OperationType.CREATE_RELATION;
|
|
41
|
-
data: Omit<Relation, 'createdAt' | 'lastModified'>;
|
|
42
|
-
} | {
|
|
43
|
-
type: OperationType.DELETE_RELATION;
|
|
44
|
-
data: {
|
|
45
|
-
from: string;
|
|
46
|
-
to: string;
|
|
47
|
-
relationType: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Transaction execution result.
|
|
52
|
-
*/
|
|
53
|
-
export interface TransactionResult {
|
|
54
|
-
/** Whether the transaction was successful */
|
|
55
|
-
success: boolean;
|
|
56
|
-
/** Number of operations executed */
|
|
57
|
-
operationsExecuted: number;
|
|
58
|
-
/** Error message if transaction failed */
|
|
59
|
-
error?: string;
|
|
60
|
-
/** Path to rollback backup if created */
|
|
61
|
-
rollbackBackup?: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Manages atomic transactions for knowledge graph operations.
|
|
65
|
-
*
|
|
66
|
-
* Provides ACID-like guarantees:
|
|
67
|
-
* - Atomicity: All operations succeed or all fail
|
|
68
|
-
* - Consistency: Graph is always in a valid state
|
|
69
|
-
* - Isolation: Each transaction operates on a snapshot
|
|
70
|
-
* - Durability: Changes are persisted to disk
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* const storage = new GraphStorage('/data/memory.jsonl');
|
|
75
|
-
* const txManager = new TransactionManager(storage);
|
|
76
|
-
*
|
|
77
|
-
* // Begin transaction
|
|
78
|
-
* txManager.begin();
|
|
79
|
-
*
|
|
80
|
-
* // Stage operations
|
|
81
|
-
* txManager.createEntity({ name: 'Alice', entityType: 'person', observations: [] });
|
|
82
|
-
* txManager.createRelation({ from: 'Alice', to: 'Bob', relationType: 'knows' });
|
|
83
|
-
*
|
|
84
|
-
* // Commit atomically (or rollback on error)
|
|
85
|
-
* const result = await txManager.commit();
|
|
86
|
-
* if (result.success) {
|
|
87
|
-
* console.log(`Transaction completed: ${result.operationsExecuted} operations`);
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
export declare class TransactionManager {
|
|
92
|
-
private storage;
|
|
93
|
-
private operations;
|
|
94
|
-
private inTransaction;
|
|
95
|
-
private ioManager;
|
|
96
|
-
private transactionBackup?;
|
|
97
|
-
constructor(storage: GraphStorage);
|
|
98
|
-
/**
|
|
99
|
-
* Begin a new transaction.
|
|
100
|
-
*
|
|
101
|
-
* Creates a backup of the current state for rollback purposes.
|
|
102
|
-
* Only one transaction can be active at a time.
|
|
103
|
-
*
|
|
104
|
-
* @throws {KnowledgeGraphError} If a transaction is already in progress
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* ```typescript
|
|
108
|
-
* txManager.begin();
|
|
109
|
-
* // ... stage operations ...
|
|
110
|
-
* await txManager.commit();
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
begin(): void;
|
|
114
|
-
/**
|
|
115
|
-
* Stage a create entity operation.
|
|
116
|
-
*
|
|
117
|
-
* @param entity - Entity to create (without timestamps)
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* ```typescript
|
|
121
|
-
* txManager.begin();
|
|
122
|
-
* txManager.createEntity({
|
|
123
|
-
* name: 'Alice',
|
|
124
|
-
* entityType: 'person',
|
|
125
|
-
* observations: ['Software engineer'],
|
|
126
|
-
* importance: 8
|
|
127
|
-
* });
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
createEntity(entity: Omit<Entity, 'createdAt' | 'lastModified'>): void;
|
|
131
|
-
/**
|
|
132
|
-
* Stage an update entity operation.
|
|
133
|
-
*
|
|
134
|
-
* @param name - Name of entity to update
|
|
135
|
-
* @param updates - Partial entity updates
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```typescript
|
|
139
|
-
* txManager.begin();
|
|
140
|
-
* txManager.updateEntity('Alice', {
|
|
141
|
-
* importance: 9,
|
|
142
|
-
* observations: ['Lead software engineer']
|
|
143
|
-
* });
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
updateEntity(name: string, updates: Partial<Entity>): void;
|
|
147
|
-
/**
|
|
148
|
-
* Stage a delete entity operation.
|
|
149
|
-
*
|
|
150
|
-
* @param name - Name of entity to delete
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```typescript
|
|
154
|
-
* txManager.begin();
|
|
155
|
-
* txManager.deleteEntity('OldEntity');
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
deleteEntity(name: string): void;
|
|
159
|
-
/**
|
|
160
|
-
* Stage a create relation operation.
|
|
161
|
-
*
|
|
162
|
-
* @param relation - Relation to create (without timestamps)
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```typescript
|
|
166
|
-
* txManager.begin();
|
|
167
|
-
* txManager.createRelation({
|
|
168
|
-
* from: 'Alice',
|
|
169
|
-
* to: 'Bob',
|
|
170
|
-
* relationType: 'mentors'
|
|
171
|
-
* });
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
createRelation(relation: Omit<Relation, 'createdAt' | 'lastModified'>): void;
|
|
175
|
-
/**
|
|
176
|
-
* Stage a delete relation operation.
|
|
177
|
-
*
|
|
178
|
-
* @param from - Source entity name
|
|
179
|
-
* @param to - Target entity name
|
|
180
|
-
* @param relationType - Type of relation
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* ```typescript
|
|
184
|
-
* txManager.begin();
|
|
185
|
-
* txManager.deleteRelation('Alice', 'Bob', 'mentors');
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
deleteRelation(from: string, to: string, relationType: string): void;
|
|
189
|
-
/**
|
|
190
|
-
* Commit the transaction, applying all staged operations atomically.
|
|
191
|
-
*
|
|
192
|
-
* Creates a backup before applying changes. If any operation fails,
|
|
193
|
-
* automatically rolls back to the pre-transaction state.
|
|
194
|
-
*
|
|
195
|
-
* @returns Promise resolving to transaction result
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* ```typescript
|
|
199
|
-
* txManager.begin();
|
|
200
|
-
* txManager.createEntity({ name: 'Alice', entityType: 'person', observations: [] });
|
|
201
|
-
* txManager.createRelation({ from: 'Alice', to: 'Bob', relationType: 'knows' });
|
|
202
|
-
*
|
|
203
|
-
* const result = await txManager.commit();
|
|
204
|
-
* if (result.success) {
|
|
205
|
-
* console.log(`Committed ${result.operationsExecuted} operations`);
|
|
206
|
-
* } else {
|
|
207
|
-
* console.error(`Transaction failed: ${result.error}`);
|
|
208
|
-
* }
|
|
209
|
-
* ```
|
|
210
|
-
*/
|
|
211
|
-
commit(): Promise<TransactionResult>;
|
|
212
|
-
/**
|
|
213
|
-
* Rollback the current transaction.
|
|
214
|
-
*
|
|
215
|
-
* Restores the graph to the pre-transaction state using the backup.
|
|
216
|
-
* Automatically called by commit() on failure.
|
|
217
|
-
*
|
|
218
|
-
* @returns Promise resolving to rollback result
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* ```typescript
|
|
222
|
-
* txManager.begin();
|
|
223
|
-
* txManager.createEntity({ name: 'Test', entityType: 'temp', observations: [] });
|
|
224
|
-
*
|
|
225
|
-
* // Explicit rollback (e.g., user cancellation)
|
|
226
|
-
* const result = await txManager.rollback();
|
|
227
|
-
* console.log(`Rolled back, restored from: ${result.backupUsed}`);
|
|
228
|
-
* ```
|
|
229
|
-
*/
|
|
230
|
-
rollback(): Promise<{
|
|
231
|
-
success: boolean;
|
|
232
|
-
backupUsed?: string;
|
|
233
|
-
}>;
|
|
234
|
-
/**
|
|
235
|
-
* Check if a transaction is currently in progress.
|
|
236
|
-
*
|
|
237
|
-
* @returns True if transaction is active
|
|
238
|
-
*/
|
|
239
|
-
isInTransaction(): boolean;
|
|
240
|
-
/**
|
|
241
|
-
* Get the number of staged operations in the current transaction.
|
|
242
|
-
*
|
|
243
|
-
* @returns Number of operations staged
|
|
244
|
-
*/
|
|
245
|
-
getOperationCount(): number;
|
|
246
|
-
/**
|
|
247
|
-
* Ensure a transaction is in progress, or throw an error.
|
|
248
|
-
*
|
|
249
|
-
* @private
|
|
250
|
-
*/
|
|
251
|
-
private ensureInTransaction;
|
|
252
|
-
/**
|
|
253
|
-
* Apply a single operation to the graph.
|
|
254
|
-
*
|
|
255
|
-
* @private
|
|
256
|
-
*/
|
|
257
|
-
private applyOperation;
|
|
258
|
-
}
|
|
259
|
-
//# sourceMappingURL=TransactionManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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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