@soulcraft/brainy 0.20.0 → 0.22.0
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 +1 -1
- package/dist/augmentations/conduitAugmentations.js +1158 -0
- package/dist/augmentations/conduitAugmentations.js.map +1 -0
- package/dist/augmentations/memoryAugmentations.js +255 -0
- package/dist/augmentations/memoryAugmentations.js.map +1 -0
- package/dist/augmentations/serverSearchAugmentations.js +531 -0
- package/dist/augmentations/serverSearchAugmentations.js.map +1 -0
- package/dist/coreTypes.d.ts +12 -0
- package/dist/examples/basicUsage.js +128 -0
- package/dist/examples/basicUsage.js.map +1 -0
- package/dist/hnsw/hnswIndex.js +550 -0
- package/dist/hnsw/hnswIndex.js.map +1 -0
- package/dist/hnsw/hnswIndexOptimized.js +441 -0
- package/dist/hnsw/hnswIndexOptimized.js.map +1 -0
- package/dist/mcp/brainyMCPAdapter.js +142 -0
- package/dist/mcp/brainyMCPAdapter.js.map +1 -0
- package/dist/mcp/brainyMCPService.js +248 -0
- package/dist/mcp/brainyMCPService.js.map +1 -0
- package/dist/mcp/index.js +17 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcpAugmentationToolset.js +180 -0
- package/dist/mcp/mcpAugmentationToolset.js.map +1 -0
- package/dist/storage/adapters/baseStorageAdapter.d.ts +14 -0
- package/dist/storage/adapters/baseStorageAdapter.d.ts.map +1 -1
- package/dist/storage/adapters/baseStorageAdapter.js +233 -0
- package/dist/storage/adapters/baseStorageAdapter.js.map +1 -0
- package/dist/storage/adapters/fileSystemStorage.d.ts +27 -27
- package/dist/storage/adapters/fileSystemStorage.d.ts.map +1 -1
- package/dist/storage/adapters/fileSystemStorage.js +568 -0
- package/dist/storage/adapters/fileSystemStorage.js.map +1 -0
- package/dist/storage/adapters/memoryStorage.d.ts +27 -27
- package/dist/storage/adapters/memoryStorage.d.ts.map +1 -1
- package/dist/storage/adapters/memoryStorage.js +300 -0
- package/dist/storage/adapters/memoryStorage.js.map +1 -0
- package/dist/storage/adapters/opfsStorage.d.ts +64 -6
- package/dist/storage/adapters/opfsStorage.d.ts.map +1 -1
- package/dist/storage/adapters/opfsStorage.js +778 -0
- package/dist/storage/adapters/opfsStorage.js.map +1 -0
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +86 -1
- package/dist/storage/adapters/s3CompatibleStorage.d.ts.map +1 -1
- package/dist/storage/adapters/s3CompatibleStorage.js +1021 -0
- package/dist/storage/adapters/s3CompatibleStorage.js.map +1 -0
- package/dist/storage/baseStorage.d.ts +24 -24
- package/dist/storage/baseStorage.d.ts.map +1 -1
- package/dist/storage/baseStorage.js +126 -0
- package/dist/storage/baseStorage.js.map +1 -0
- package/dist/storage/storageFactory.js +183 -0
- package/dist/storage/storageFactory.js.map +1 -0
- package/dist/types/augmentations.js +16 -0
- package/dist/types/augmentations.js.map +1 -0
- package/dist/types/brainyDataInterface.js +8 -0
- package/dist/types/brainyDataInterface.js.map +1 -0
- package/dist/types/fileSystemTypes.js +8 -0
- package/dist/types/fileSystemTypes.js.map +1 -0
- package/dist/types/graphTypes.d.ts +2 -1
- package/dist/types/graphTypes.d.ts.map +1 -1
- package/dist/types/graphTypes.js +36 -0
- package/dist/types/graphTypes.js.map +1 -0
- package/dist/types/mcpTypes.js +22 -0
- package/dist/types/mcpTypes.js.map +1 -0
- package/dist/types/pipelineTypes.js +7 -0
- package/dist/types/pipelineTypes.js.map +1 -0
- package/dist/types/tensorflowTypes.js +6 -0
- package/dist/types/tensorflowTypes.js.map +1 -0
- package/dist/unified.js +983 -336
- package/dist/unified.min.js +623 -623
- package/dist/utils/distance.js +239 -0
- package/dist/utils/distance.js.map +1 -0
- package/dist/utils/embedding.js +622 -0
- package/dist/utils/embedding.js.map +1 -0
- package/dist/utils/environment.js +75 -0
- package/dist/utils/environment.js.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/statistics.js +25 -0
- package/dist/utils/statistics.js.map +1 -0
- package/dist/utils/tensorflowUtils.js +25 -0
- package/dist/utils/tensorflowUtils.js.map +1 -0
- package/dist/utils/textEncoding.js +281 -0
- package/dist/utils/textEncoding.js.map +1 -0
- package/dist/utils/workerUtils.js +458 -0
- package/dist/utils/workerUtils.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Storage Adapter
|
|
3
|
+
* Provides common functionality for all storage adapters, including statistics tracking
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base class for storage adapters that implements statistics tracking
|
|
7
|
+
*/
|
|
8
|
+
export class BaseStorageAdapter {
|
|
9
|
+
constructor() {
|
|
10
|
+
// Statistics cache
|
|
11
|
+
this.statisticsCache = null;
|
|
12
|
+
// Batch update timer ID
|
|
13
|
+
this.statisticsBatchUpdateTimerId = null;
|
|
14
|
+
// Flag to indicate if statistics have been modified since last save
|
|
15
|
+
this.statisticsModified = false;
|
|
16
|
+
// Time of last statistics flush to storage
|
|
17
|
+
this.lastStatisticsFlushTime = 0;
|
|
18
|
+
// Minimum time between statistics flushes (5 seconds)
|
|
19
|
+
this.MIN_FLUSH_INTERVAL_MS = 5000;
|
|
20
|
+
// Maximum time to wait before flushing statistics (30 seconds)
|
|
21
|
+
this.MAX_FLUSH_DELAY_MS = 30000;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Save statistics data
|
|
25
|
+
* @param statistics The statistics data to save
|
|
26
|
+
*/
|
|
27
|
+
async saveStatistics(statistics) {
|
|
28
|
+
// Update the cache with a deep copy to avoid reference issues
|
|
29
|
+
this.statisticsCache = {
|
|
30
|
+
nounCount: { ...statistics.nounCount },
|
|
31
|
+
verbCount: { ...statistics.verbCount },
|
|
32
|
+
metadataCount: { ...statistics.metadataCount },
|
|
33
|
+
hnswIndexSize: statistics.hnswIndexSize,
|
|
34
|
+
lastUpdated: statistics.lastUpdated
|
|
35
|
+
};
|
|
36
|
+
// Schedule a batch update instead of saving immediately
|
|
37
|
+
this.scheduleBatchUpdate();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get statistics data
|
|
41
|
+
* @returns Promise that resolves to the statistics data
|
|
42
|
+
*/
|
|
43
|
+
async getStatistics() {
|
|
44
|
+
// If we have cached statistics, return a deep copy
|
|
45
|
+
if (this.statisticsCache) {
|
|
46
|
+
return {
|
|
47
|
+
nounCount: { ...this.statisticsCache.nounCount },
|
|
48
|
+
verbCount: { ...this.statisticsCache.verbCount },
|
|
49
|
+
metadataCount: { ...this.statisticsCache.metadataCount },
|
|
50
|
+
hnswIndexSize: this.statisticsCache.hnswIndexSize,
|
|
51
|
+
lastUpdated: this.statisticsCache.lastUpdated
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Otherwise, get from storage
|
|
55
|
+
const statistics = await this.getStatisticsData();
|
|
56
|
+
// If we found statistics, update the cache
|
|
57
|
+
if (statistics) {
|
|
58
|
+
// Update the cache with a deep copy
|
|
59
|
+
this.statisticsCache = {
|
|
60
|
+
nounCount: { ...statistics.nounCount },
|
|
61
|
+
verbCount: { ...statistics.verbCount },
|
|
62
|
+
metadataCount: { ...statistics.metadataCount },
|
|
63
|
+
hnswIndexSize: statistics.hnswIndexSize,
|
|
64
|
+
lastUpdated: statistics.lastUpdated
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return statistics;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Schedule a batch update of statistics
|
|
71
|
+
*/
|
|
72
|
+
scheduleBatchUpdate() {
|
|
73
|
+
// Mark statistics as modified
|
|
74
|
+
this.statisticsModified = true;
|
|
75
|
+
// If a timer is already set, don't set another one
|
|
76
|
+
if (this.statisticsBatchUpdateTimerId !== null) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// Calculate time since last flush
|
|
80
|
+
const now = Date.now();
|
|
81
|
+
const timeSinceLastFlush = now - this.lastStatisticsFlushTime;
|
|
82
|
+
// If we've recently flushed, wait longer before the next flush
|
|
83
|
+
const delayMs = timeSinceLastFlush < this.MIN_FLUSH_INTERVAL_MS
|
|
84
|
+
? this.MAX_FLUSH_DELAY_MS
|
|
85
|
+
: this.MIN_FLUSH_INTERVAL_MS;
|
|
86
|
+
// Schedule the batch update
|
|
87
|
+
this.statisticsBatchUpdateTimerId = setTimeout(() => {
|
|
88
|
+
this.flushStatistics();
|
|
89
|
+
}, delayMs);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Flush statistics to storage
|
|
93
|
+
*/
|
|
94
|
+
async flushStatistics() {
|
|
95
|
+
// Clear the timer
|
|
96
|
+
if (this.statisticsBatchUpdateTimerId !== null) {
|
|
97
|
+
clearTimeout(this.statisticsBatchUpdateTimerId);
|
|
98
|
+
this.statisticsBatchUpdateTimerId = null;
|
|
99
|
+
}
|
|
100
|
+
// If statistics haven't been modified, no need to flush
|
|
101
|
+
if (!this.statisticsModified || !this.statisticsCache) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
// Save the statistics to storage
|
|
106
|
+
await this.saveStatisticsData(this.statisticsCache);
|
|
107
|
+
// Update the last flush time
|
|
108
|
+
this.lastStatisticsFlushTime = Date.now();
|
|
109
|
+
// Reset the modified flag
|
|
110
|
+
this.statisticsModified = false;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error('Failed to flush statistics data:', error);
|
|
114
|
+
// Mark as still modified so we'll try again later
|
|
115
|
+
this.statisticsModified = true;
|
|
116
|
+
// Don't throw the error to avoid disrupting the application
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Increment a statistic counter
|
|
121
|
+
* @param type The type of statistic to increment ('noun', 'verb', 'metadata')
|
|
122
|
+
* @param service The service that inserted the data
|
|
123
|
+
* @param amount The amount to increment by (default: 1)
|
|
124
|
+
*/
|
|
125
|
+
async incrementStatistic(type, service, amount = 1) {
|
|
126
|
+
// Get current statistics from cache or storage
|
|
127
|
+
let statistics = this.statisticsCache;
|
|
128
|
+
if (!statistics) {
|
|
129
|
+
statistics = await this.getStatisticsData();
|
|
130
|
+
if (!statistics) {
|
|
131
|
+
statistics = this.createDefaultStatistics();
|
|
132
|
+
}
|
|
133
|
+
// Update the cache
|
|
134
|
+
this.statisticsCache = {
|
|
135
|
+
nounCount: { ...statistics.nounCount },
|
|
136
|
+
verbCount: { ...statistics.verbCount },
|
|
137
|
+
metadataCount: { ...statistics.metadataCount },
|
|
138
|
+
hnswIndexSize: statistics.hnswIndexSize,
|
|
139
|
+
lastUpdated: statistics.lastUpdated
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
// Increment the appropriate counter
|
|
143
|
+
const counterMap = {
|
|
144
|
+
noun: this.statisticsCache.nounCount,
|
|
145
|
+
verb: this.statisticsCache.verbCount,
|
|
146
|
+
metadata: this.statisticsCache.metadataCount
|
|
147
|
+
};
|
|
148
|
+
const counter = counterMap[type];
|
|
149
|
+
counter[service] = (counter[service] || 0) + amount;
|
|
150
|
+
// Update timestamp
|
|
151
|
+
this.statisticsCache.lastUpdated = new Date().toISOString();
|
|
152
|
+
// Schedule a batch update instead of saving immediately
|
|
153
|
+
this.scheduleBatchUpdate();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Decrement a statistic counter
|
|
157
|
+
* @param type The type of statistic to decrement ('noun', 'verb', 'metadata')
|
|
158
|
+
* @param service The service that inserted the data
|
|
159
|
+
* @param amount The amount to decrement by (default: 1)
|
|
160
|
+
*/
|
|
161
|
+
async decrementStatistic(type, service, amount = 1) {
|
|
162
|
+
// Get current statistics from cache or storage
|
|
163
|
+
let statistics = this.statisticsCache;
|
|
164
|
+
if (!statistics) {
|
|
165
|
+
statistics = await this.getStatisticsData();
|
|
166
|
+
if (!statistics) {
|
|
167
|
+
statistics = this.createDefaultStatistics();
|
|
168
|
+
}
|
|
169
|
+
// Update the cache
|
|
170
|
+
this.statisticsCache = {
|
|
171
|
+
nounCount: { ...statistics.nounCount },
|
|
172
|
+
verbCount: { ...statistics.verbCount },
|
|
173
|
+
metadataCount: { ...statistics.metadataCount },
|
|
174
|
+
hnswIndexSize: statistics.hnswIndexSize,
|
|
175
|
+
lastUpdated: statistics.lastUpdated
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
// Decrement the appropriate counter
|
|
179
|
+
const counterMap = {
|
|
180
|
+
noun: this.statisticsCache.nounCount,
|
|
181
|
+
verb: this.statisticsCache.verbCount,
|
|
182
|
+
metadata: this.statisticsCache.metadataCount
|
|
183
|
+
};
|
|
184
|
+
const counter = counterMap[type];
|
|
185
|
+
counter[service] = Math.max(0, (counter[service] || 0) - amount);
|
|
186
|
+
// Update timestamp
|
|
187
|
+
this.statisticsCache.lastUpdated = new Date().toISOString();
|
|
188
|
+
// Schedule a batch update instead of saving immediately
|
|
189
|
+
this.scheduleBatchUpdate();
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Update the HNSW index size statistic
|
|
193
|
+
* @param size The new size of the HNSW index
|
|
194
|
+
*/
|
|
195
|
+
async updateHnswIndexSize(size) {
|
|
196
|
+
// Get current statistics from cache or storage
|
|
197
|
+
let statistics = this.statisticsCache;
|
|
198
|
+
if (!statistics) {
|
|
199
|
+
statistics = await this.getStatisticsData();
|
|
200
|
+
if (!statistics) {
|
|
201
|
+
statistics = this.createDefaultStatistics();
|
|
202
|
+
}
|
|
203
|
+
// Update the cache
|
|
204
|
+
this.statisticsCache = {
|
|
205
|
+
nounCount: { ...statistics.nounCount },
|
|
206
|
+
verbCount: { ...statistics.verbCount },
|
|
207
|
+
metadataCount: { ...statistics.metadataCount },
|
|
208
|
+
hnswIndexSize: statistics.hnswIndexSize,
|
|
209
|
+
lastUpdated: statistics.lastUpdated
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
// Update HNSW index size
|
|
213
|
+
this.statisticsCache.hnswIndexSize = size;
|
|
214
|
+
// Update timestamp
|
|
215
|
+
this.statisticsCache.lastUpdated = new Date().toISOString();
|
|
216
|
+
// Schedule a batch update instead of saving immediately
|
|
217
|
+
this.scheduleBatchUpdate();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Create default statistics data
|
|
221
|
+
* @returns Default statistics data
|
|
222
|
+
*/
|
|
223
|
+
createDefaultStatistics() {
|
|
224
|
+
return {
|
|
225
|
+
nounCount: {},
|
|
226
|
+
verbCount: {},
|
|
227
|
+
metadataCount: {},
|
|
228
|
+
hnswIndexSize: 0,
|
|
229
|
+
lastUpdated: new Date().toISOString()
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=baseStorageAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseStorageAdapter.js","sourceRoot":"","sources":["../../../src/storage/adapters/baseStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,OAAgB,kBAAkB;IAAxC;QAyBE,mBAAmB;QACT,oBAAe,GAA0B,IAAI,CAAA;QAEvD,wBAAwB;QACd,iCAA4B,GAA0B,IAAI,CAAA;QAEpE,oEAAoE;QAC1D,uBAAkB,GAAG,KAAK,CAAA;QAEpC,2CAA2C;QACjC,4BAAuB,GAAG,CAAC,CAAA;QAErC,sDAAsD;QACnC,0BAAqB,GAAG,IAAI,CAAA;QAE/C,+DAA+D;QAC5C,uBAAkB,GAAG,KAAK,CAAA;IA8P/C,CAAC;IAxPC;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAC,UAA0B;QAC7C,8DAA8D;QAC9D,IAAI,CAAC,eAAe,GAAG;YACrB,SAAS,EAAE,EAAC,GAAG,UAAU,CAAC,SAAS,EAAC;YACpC,SAAS,EAAE,EAAC,GAAG,UAAU,CAAC,SAAS,EAAC;YACpC,aAAa,EAAE,EAAC,GAAG,UAAU,CAAC,aAAa,EAAC;YAC5C,aAAa,EAAE,UAAU,CAAC,aA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rC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,UAAU,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAA;YAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,UAAU,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAA;YAC7C,CAAC;YAED,mBAAmB;YACnB,IAAI,CAAC,eAAe,GAAG;gBACrB,SAAS,EAAE,EAAC,GAAG,UAAU,CAAC,SAAS,EAAC;gBACpC,SAAS,EAAE,EAAC,GAAG,UAAU,CAAC,SAAS,EAAC;gBACpC,aAAa,EAAE,EAAC,GAAG,UAAU,CAAC,aAAa,EAAC;gBAC5C,aAAa,EAAE,UAAU,CAAC,aAAa;gBACvC,WAAW,EAAE,UAAU,CAAC,WAAW;aACpC,CAAA;QACH,CAAC;QAED,yBAAyB;QACzB,IAAI,CAAC,eAAgB,CAAC,aAAa,GAAG,IAAI,CAAA;QAE1C,mBAAmB;QACnB,IAAI,CAAC,eAAgB,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;QAE5D,wDAAwD;QACxD,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED;;;OAGG;IACO,uBAAuB;QAC/B,OAAO;YACL,SAAS,EAAE,EAAE;YACb,SAAS,EAAE,EAAE;YACb,aAAa,EAAE,EAAE;YACjB,aAAa,EAAE,CAAC;YAChB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAA;IACH,CAAC;CACF"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { GraphVerb, HNSWNoun, StatisticsData } from '../../coreTypes.js';
|
|
6
6
|
import { BaseStorage } from '../baseStorage.js';
|
|
7
|
-
type
|
|
8
|
-
type
|
|
7
|
+
type HNSWNoun_internal = HNSWNoun;
|
|
8
|
+
type Verb = GraphVerb;
|
|
9
9
|
/**
|
|
10
10
|
* File system storage adapter for Node.js environments
|
|
11
11
|
* Uses the file system to store data in the specified directory structure
|
|
@@ -30,55 +30,55 @@ export declare class FileSystemStorage extends BaseStorage {
|
|
|
30
30
|
*/
|
|
31
31
|
private ensureDirectoryExists;
|
|
32
32
|
/**
|
|
33
|
-
* Save a
|
|
33
|
+
* Save a noun to storage
|
|
34
34
|
*/
|
|
35
|
-
protected
|
|
35
|
+
protected saveNoun_internal(noun: HNSWNoun_internal): Promise<void>;
|
|
36
36
|
/**
|
|
37
|
-
* Get a
|
|
37
|
+
* Get a noun from storage
|
|
38
38
|
*/
|
|
39
|
-
protected
|
|
39
|
+
protected getNoun_internal(id: string): Promise<HNSWNoun_internal | null>;
|
|
40
40
|
/**
|
|
41
|
-
* Get all
|
|
41
|
+
* Get all nouns from storage
|
|
42
42
|
*/
|
|
43
|
-
protected
|
|
43
|
+
protected getAllNouns_internal(): Promise<HNSWNoun_internal[]>;
|
|
44
44
|
/**
|
|
45
|
-
* Get
|
|
45
|
+
* Get nouns by noun type
|
|
46
46
|
* @param nounType The noun type to filter by
|
|
47
|
-
* @returns Promise that resolves to an array of
|
|
47
|
+
* @returns Promise that resolves to an array of nouns of the specified noun type
|
|
48
48
|
*/
|
|
49
|
-
protected
|
|
49
|
+
protected getNounsByNounType_internal(nounType: string): Promise<HNSWNoun_internal[]>;
|
|
50
50
|
/**
|
|
51
|
-
* Delete a
|
|
51
|
+
* Delete a noun from storage
|
|
52
52
|
*/
|
|
53
|
-
protected
|
|
53
|
+
protected deleteNoun_internal(id: string): Promise<void>;
|
|
54
54
|
/**
|
|
55
|
-
* Save
|
|
55
|
+
* Save a verb to storage
|
|
56
56
|
*/
|
|
57
|
-
protected
|
|
57
|
+
protected saveVerb_internal(verb: Verb): Promise<void>;
|
|
58
58
|
/**
|
|
59
|
-
* Get
|
|
59
|
+
* Get a verb from storage
|
|
60
60
|
*/
|
|
61
|
-
protected
|
|
61
|
+
protected getVerb_internal(id: string): Promise<Verb | null>;
|
|
62
62
|
/**
|
|
63
|
-
* Get all
|
|
63
|
+
* Get all verbs from storage
|
|
64
64
|
*/
|
|
65
|
-
protected
|
|
65
|
+
protected getAllVerbs_internal(): Promise<Verb[]>;
|
|
66
66
|
/**
|
|
67
|
-
* Get
|
|
67
|
+
* Get verbs by source
|
|
68
68
|
*/
|
|
69
|
-
protected
|
|
69
|
+
protected getVerbsBySource_internal(sourceId: string): Promise<Verb[]>;
|
|
70
70
|
/**
|
|
71
|
-
* Get
|
|
71
|
+
* Get verbs by target
|
|
72
72
|
*/
|
|
73
|
-
protected
|
|
73
|
+
protected getVerbsByTarget_internal(targetId: string): Promise<Verb[]>;
|
|
74
74
|
/**
|
|
75
|
-
* Get
|
|
75
|
+
* Get verbs by type
|
|
76
76
|
*/
|
|
77
|
-
protected
|
|
77
|
+
protected getVerbsByType_internal(type: string): Promise<Verb[]>;
|
|
78
78
|
/**
|
|
79
|
-
* Delete
|
|
79
|
+
* Delete a verb from storage
|
|
80
80
|
*/
|
|
81
|
-
protected
|
|
81
|
+
protected deleteVerb_internal(id: string): Promise<void>;
|
|
82
82
|
/**
|
|
83
83
|
* Save metadata to storage
|
|
84
84
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileSystemStorage.d.ts","sourceRoot":"","sources":["../../../src/storage/adapters/fileSystemStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,EAAE,WAAW,EAAiE,MAAM,mBAAmB,CAAA;AAG9G,KAAK,
|
|
1
|
+
{"version":3,"file":"fileSystemStorage.d.ts","sourceRoot":"","sources":["../../../src/storage/adapters/fileSystemStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,EAAE,WAAW,EAAiE,MAAM,mBAAmB,CAAA;AAG9G,KAAK,i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