@soulcraft/brainy 2.15.0 → 3.0.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/CHANGELOG.md +18 -0
- package/README.md +249 -152
- package/dist/api/ConfigAPI.d.ts +67 -0
- package/dist/api/ConfigAPI.js +166 -0
- package/dist/api/DataAPI.d.ts +123 -0
- package/dist/api/DataAPI.js +391 -0
- package/dist/api/SecurityAPI.d.ts +50 -0
- package/dist/api/SecurityAPI.js +139 -0
- package/dist/api/UniversalImportAPI.d.ts +134 -0
- package/dist/api/UniversalImportAPI.js +615 -0
- package/dist/augmentationManager.js +12 -7
- package/dist/augmentationPipeline.d.ts +0 -61
- package/dist/augmentationPipeline.js +0 -87
- package/dist/augmentationRegistry.d.ts +1 -1
- package/dist/augmentationRegistry.js +1 -1
- package/dist/augmentations/apiServerAugmentation.d.ts +27 -1
- package/dist/augmentations/apiServerAugmentation.js +288 -7
- package/dist/augmentations/auditLogAugmentation.d.ts +109 -0
- package/dist/augmentations/auditLogAugmentation.js +358 -0
- package/dist/augmentations/batchProcessingAugmentation.d.ts +3 -2
- package/dist/augmentations/batchProcessingAugmentation.js +123 -22
- package/dist/augmentations/brainyAugmentation.d.ts +87 -8
- package/dist/augmentations/brainyAugmentation.js +159 -2
- package/dist/augmentations/cacheAugmentation.d.ts +6 -5
- package/dist/augmentations/cacheAugmentation.js +113 -17
- package/dist/augmentations/conduitAugmentations.d.ts +2 -2
- package/dist/augmentations/conduitAugmentations.js +2 -2
- package/dist/augmentations/configResolver.d.ts +122 -0
- package/dist/augmentations/configResolver.js +440 -0
- package/dist/augmentations/connectionPoolAugmentation.d.ts +3 -1
- package/dist/augmentations/connectionPoolAugmentation.js +37 -12
- package/dist/augmentations/defaultAugmentations.d.ts +9 -11
- package/dist/augmentations/defaultAugmentations.js +4 -11
- package/dist/augmentations/discovery/catalogDiscovery.d.ts +142 -0
- package/dist/augmentations/discovery/catalogDiscovery.js +249 -0
- package/dist/augmentations/discovery/localDiscovery.d.ts +84 -0
- package/dist/augmentations/discovery/localDiscovery.js +246 -0
- package/dist/augmentations/discovery/runtimeLoader.d.ts +97 -0
- package/dist/augmentations/discovery/runtimeLoader.js +337 -0
- package/dist/augmentations/discovery.d.ts +152 -0
- package/dist/augmentations/discovery.js +441 -0
- package/dist/augmentations/display/intelligentComputation.d.ts +1 -1
- package/dist/augmentations/display/intelligentComputation.js +4 -4
- package/dist/augmentations/entityRegistryAugmentation.d.ts +3 -1
- package/dist/augmentations/entityRegistryAugmentation.js +5 -1
- package/dist/augmentations/indexAugmentation.d.ts +3 -3
- package/dist/augmentations/indexAugmentation.js +2 -2
- package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +22 -6
- package/dist/augmentations/intelligentVerbScoringAugmentation.js +106 -23
- package/dist/augmentations/manifest.d.ts +176 -0
- package/dist/augmentations/manifest.js +8 -0
- package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +168 -0
- package/dist/augmentations/marketplace/AugmentationMarketplace.js +329 -0
- package/dist/augmentations/marketplace/cli.d.ts +47 -0
- package/dist/augmentations/marketplace/cli.js +265 -0
- package/dist/augmentations/metricsAugmentation.d.ts +3 -3
- package/dist/augmentations/metricsAugmentation.js +2 -2
- package/dist/augmentations/monitoringAugmentation.d.ts +3 -3
- package/dist/augmentations/monitoringAugmentation.js +2 -2
- package/dist/augmentations/neuralImport.d.ts +1 -1
- package/dist/augmentations/rateLimitAugmentation.d.ts +82 -0
- package/dist/augmentations/rateLimitAugmentation.js +321 -0
- package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +2 -2
- package/dist/augmentations/requestDeduplicatorAugmentation.js +1 -1
- package/dist/augmentations/storageAugmentation.d.ts +1 -1
- package/dist/augmentations/storageAugmentation.js +2 -2
- package/dist/augmentations/storageAugmentations.d.ts +37 -8
- package/dist/augmentations/storageAugmentations.js +204 -15
- package/dist/augmentations/synapseAugmentation.d.ts +1 -1
- package/dist/augmentations/synapseAugmentation.js +35 -16
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.d.ts +39 -59
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +103 -389
- package/dist/augmentations/universalDisplayAugmentation.d.ts +2 -2
- package/dist/augmentations/universalDisplayAugmentation.js +2 -2
- package/dist/brainy-unified.d.ts +106 -0
- package/dist/brainy-unified.js +327 -0
- package/dist/brainy.d.ts +273 -0
- package/dist/brainy.js +1181 -0
- package/dist/brainyData.d.ts +29 -72
- package/dist/brainyData.js +350 -304
- package/dist/brainyDataV3.d.ts +186 -0
- package/dist/brainyDataV3.js +337 -0
- package/dist/browserFramework.d.ts +6 -6
- package/dist/browserFramework.js +11 -8
- package/dist/browserFramework.minimal.d.ts +5 -5
- package/dist/browserFramework.minimal.js +11 -8
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +3 -3
- package/dist/config/modelAutoConfig.d.ts +6 -7
- package/dist/config/modelAutoConfig.js +17 -76
- package/dist/cortex/backupRestore.d.ts +2 -2
- package/dist/cortex/backupRestore.js +85 -27
- package/dist/cortex/healthCheck.d.ts +2 -2
- package/dist/cortex/neuralImport.d.ts +2 -2
- package/dist/cortex/neuralImport.js +18 -13
- package/dist/cortex/performanceMonitor.d.ts +2 -2
- package/dist/critical/model-guardian.d.ts +4 -0
- package/dist/critical/model-guardian.js +31 -11
- package/dist/demo.d.ts +4 -4
- package/dist/demo.js +7 -7
- package/dist/distributed/cacheSync.d.ts +112 -0
- package/dist/distributed/cacheSync.js +265 -0
- package/dist/distributed/coordinator.d.ts +193 -0
- package/dist/distributed/coordinator.js +548 -0
- package/dist/distributed/httpTransport.d.ts +120 -0
- package/dist/distributed/httpTransport.js +446 -0
- package/dist/distributed/index.d.ts +8 -0
- package/dist/distributed/index.js +5 -0
- package/dist/distributed/networkTransport.d.ts +132 -0
- package/dist/distributed/networkTransport.js +633 -0
- package/dist/distributed/queryPlanner.d.ts +104 -0
- package/dist/distributed/queryPlanner.js +327 -0
- package/dist/distributed/readWriteSeparation.d.ts +134 -0
- package/dist/distributed/readWriteSeparation.js +350 -0
- package/dist/distributed/shardManager.d.ts +114 -0
- package/dist/distributed/shardManager.js +357 -0
- package/dist/distributed/shardMigration.d.ts +110 -0
- package/dist/distributed/shardMigration.js +289 -0
- package/dist/distributed/storageDiscovery.d.ts +160 -0
- package/dist/distributed/storageDiscovery.js +551 -0
- package/dist/embeddings/EmbeddingManager.d.ts +0 -4
- package/dist/embeddings/EmbeddingManager.js +21 -26
- package/dist/errors/brainyError.d.ts +5 -1
- package/dist/errors/brainyError.js +12 -0
- package/dist/examples/basicUsage.js +3 -3
- package/dist/graph/graphAdjacencyIndex.d.ts +96 -0
- package/dist/graph/graphAdjacencyIndex.js +288 -0
- package/dist/graph/pathfinding.js +4 -2
- package/dist/hnsw/scaledHNSWSystem.js +11 -2
- package/dist/importManager.js +6 -3
- package/dist/index.d.ts +12 -21
- package/dist/index.js +14 -22
- package/dist/mcp/brainyMCPAdapter.d.ts +4 -4
- package/dist/mcp/brainyMCPAdapter.js +5 -5
- package/dist/mcp/brainyMCPService.d.ts +3 -3
- package/dist/mcp/brainyMCPService.js +3 -11
- package/dist/mcp/mcpAugmentationToolset.js +20 -30
- package/dist/neural/embeddedPatterns.d.ts +1 -1
- package/dist/neural/embeddedPatterns.js +2 -2
- package/dist/neural/entityExtractor.d.ts +65 -0
- package/dist/neural/entityExtractor.js +316 -0
- package/dist/neural/improvedNeuralAPI.js +90 -79
- package/dist/neural/naturalLanguageProcessor.d.ts +155 -10
- package/dist/neural/naturalLanguageProcessor.js +941 -66
- package/dist/neural/naturalLanguageProcessorStatic.d.ts +2 -2
- package/dist/neural/naturalLanguageProcessorStatic.js +3 -3
- package/dist/neural/neuralAPI.js +8 -2
- package/dist/neural/patternLibrary.d.ts +57 -3
- package/dist/neural/patternLibrary.js +348 -13
- package/dist/neural/staticPatternMatcher.d.ts +2 -2
- package/dist/neural/staticPatternMatcher.js +2 -2
- package/dist/shared/default-augmentations.d.ts +3 -3
- package/dist/shared/default-augmentations.js +5 -5
- package/dist/storage/adapters/fileSystemStorage.d.ts +4 -0
- package/dist/storage/adapters/fileSystemStorage.js +54 -1
- package/dist/storage/adapters/memoryStorage.js +13 -8
- package/dist/storage/backwardCompatibility.d.ts +10 -78
- package/dist/storage/backwardCompatibility.js +17 -132
- package/dist/storage/baseStorage.d.ts +6 -0
- package/dist/storage/baseStorage.js +17 -0
- package/dist/storage/cacheManager.js +2 -2
- package/dist/storage/readOnlyOptimizations.js +8 -3
- package/dist/streaming/pipeline.d.ts +154 -0
- package/dist/streaming/pipeline.js +551 -0
- package/dist/triple/TripleIntelligence.d.ts +25 -110
- package/dist/triple/TripleIntelligence.js +4 -574
- package/dist/triple/TripleIntelligenceSystem.d.ts +159 -0
- package/dist/triple/TripleIntelligenceSystem.js +519 -0
- package/dist/types/apiTypes.d.ts +278 -0
- package/dist/types/apiTypes.js +33 -0
- package/dist/types/brainy.types.d.ts +308 -0
- package/dist/types/brainy.types.js +8 -0
- package/dist/types/brainyDataInterface.d.ts +3 -3
- package/dist/types/brainyDataInterface.js +2 -2
- package/dist/types/graphTypes.js +2 -2
- package/dist/utils/cacheAutoConfig.d.ts +3 -3
- package/dist/utils/embedding.js +8 -14
- package/dist/utils/enhancedLogger.d.ts +104 -0
- package/dist/utils/enhancedLogger.js +232 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/intelligentTypeMapper.d.ts +60 -0
- package/dist/utils/intelligentTypeMapper.js +349 -0
- package/dist/utils/metadataIndex.d.ts +118 -1
- package/dist/utils/metadataIndex.js +539 -16
- package/dist/utils/paramValidation.d.ts +39 -0
- package/dist/utils/paramValidation.js +192 -0
- package/dist/utils/rateLimiter.d.ts +160 -0
- package/dist/utils/rateLimiter.js +271 -0
- package/dist/utils/statistics.d.ts +4 -4
- package/dist/utils/statistics.js +3 -3
- package/dist/utils/structuredLogger.d.ts +146 -0
- package/dist/utils/structuredLogger.js +394 -0
- package/dist/utils/textEncoding.js +2 -1
- package/dist/utils/typeValidation.d.ts +34 -0
- package/dist/utils/typeValidation.js +247 -0
- package/package.json +14 -6
- package/scripts/download-models.cjs +6 -15
- package/dist/augmentations/walAugmentation.d.ts +0 -111
- package/dist/augmentations/walAugmentation.js +0 -519
- package/dist/chat/BrainyChat.d.ts +0 -121
- package/dist/chat/BrainyChat.js +0 -396
- package/dist/chat/ChatCLI.d.ts +0 -61
- package/dist/chat/ChatCLI.js +0 -351
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration API for Brainy 3.0
|
|
3
|
+
* Provides configuration storage with optional encryption
|
|
4
|
+
*/
|
|
5
|
+
import { StorageAdapter } from '../coreTypes.js';
|
|
6
|
+
export interface ConfigOptions {
|
|
7
|
+
encrypt?: boolean;
|
|
8
|
+
decrypt?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ConfigEntry {
|
|
11
|
+
key: string;
|
|
12
|
+
value: any;
|
|
13
|
+
encrypted: boolean;
|
|
14
|
+
createdAt: number;
|
|
15
|
+
updatedAt: number;
|
|
16
|
+
}
|
|
17
|
+
export declare class ConfigAPI {
|
|
18
|
+
private storage;
|
|
19
|
+
private security;
|
|
20
|
+
private configCache;
|
|
21
|
+
private CONFIG_NOUN_PREFIX;
|
|
22
|
+
constructor(storage: StorageAdapter);
|
|
23
|
+
/**
|
|
24
|
+
* Set a configuration value with optional encryption
|
|
25
|
+
*/
|
|
26
|
+
set(params: {
|
|
27
|
+
key: string;
|
|
28
|
+
value: any;
|
|
29
|
+
encrypt?: boolean;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Get a configuration value with optional decryption
|
|
33
|
+
*/
|
|
34
|
+
get(params: {
|
|
35
|
+
key: string;
|
|
36
|
+
decrypt?: boolean;
|
|
37
|
+
defaultValue?: any;
|
|
38
|
+
}): Promise<any>;
|
|
39
|
+
/**
|
|
40
|
+
* Delete a configuration value
|
|
41
|
+
*/
|
|
42
|
+
delete(key: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* List all configuration keys
|
|
45
|
+
*/
|
|
46
|
+
list(): Promise<string[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Check if a configuration key exists
|
|
49
|
+
*/
|
|
50
|
+
has(key: string): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Clear all configuration
|
|
53
|
+
*/
|
|
54
|
+
clear(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Export all configuration
|
|
57
|
+
*/
|
|
58
|
+
export(): Promise<Record<string, ConfigEntry>>;
|
|
59
|
+
/**
|
|
60
|
+
* Import configuration
|
|
61
|
+
*/
|
|
62
|
+
import(config: Record<string, ConfigEntry>): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Get raw config entry (without decryption)
|
|
65
|
+
*/
|
|
66
|
+
private getEntry;
|
|
67
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration API for Brainy 3.0
|
|
3
|
+
* Provides configuration storage with optional encryption
|
|
4
|
+
*/
|
|
5
|
+
import { SecurityAPI } from './SecurityAPI.js';
|
|
6
|
+
export class ConfigAPI {
|
|
7
|
+
constructor(storage) {
|
|
8
|
+
this.storage = storage;
|
|
9
|
+
this.configCache = new Map();
|
|
10
|
+
this.CONFIG_NOUN_PREFIX = '_config_';
|
|
11
|
+
this.security = new SecurityAPI();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Set a configuration value with optional encryption
|
|
15
|
+
*/
|
|
16
|
+
async set(params) {
|
|
17
|
+
const { key, value, encrypt = false } = params;
|
|
18
|
+
// Serialize and optionally encrypt the value
|
|
19
|
+
let storedValue = value;
|
|
20
|
+
if (typeof value !== 'string') {
|
|
21
|
+
storedValue = JSON.stringify(value);
|
|
22
|
+
}
|
|
23
|
+
if (encrypt) {
|
|
24
|
+
storedValue = await this.security.encrypt(storedValue);
|
|
25
|
+
}
|
|
26
|
+
// Create config entry
|
|
27
|
+
const entry = {
|
|
28
|
+
key,
|
|
29
|
+
value: storedValue,
|
|
30
|
+
encrypted: encrypt,
|
|
31
|
+
createdAt: this.configCache.get(key)?.createdAt || Date.now(),
|
|
32
|
+
updatedAt: Date.now()
|
|
33
|
+
};
|
|
34
|
+
// Store in cache
|
|
35
|
+
this.configCache.set(key, entry);
|
|
36
|
+
// Persist to storage
|
|
37
|
+
const configId = this.CONFIG_NOUN_PREFIX + key;
|
|
38
|
+
await this.storage.saveMetadata(configId, entry);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get a configuration value with optional decryption
|
|
42
|
+
*/
|
|
43
|
+
async get(params) {
|
|
44
|
+
const { key, decrypt, defaultValue } = params;
|
|
45
|
+
// Check cache first
|
|
46
|
+
let entry = this.configCache.get(key);
|
|
47
|
+
// If not in cache, load from storage
|
|
48
|
+
if (!entry) {
|
|
49
|
+
const configId = this.CONFIG_NOUN_PREFIX + key;
|
|
50
|
+
const metadata = await this.storage.getMetadata(configId);
|
|
51
|
+
if (!metadata) {
|
|
52
|
+
return defaultValue;
|
|
53
|
+
}
|
|
54
|
+
entry = metadata;
|
|
55
|
+
this.configCache.set(key, entry);
|
|
56
|
+
}
|
|
57
|
+
let value = entry.value;
|
|
58
|
+
// Decrypt if needed
|
|
59
|
+
const shouldDecrypt = decrypt !== undefined ? decrypt : entry.encrypted;
|
|
60
|
+
if (shouldDecrypt && entry.encrypted && typeof value === 'string') {
|
|
61
|
+
value = await this.security.decrypt(value);
|
|
62
|
+
}
|
|
63
|
+
// Try to parse JSON if it looks like JSON
|
|
64
|
+
if (typeof value === 'string' && (value.startsWith('{') || value.startsWith('['))) {
|
|
65
|
+
try {
|
|
66
|
+
value = JSON.parse(value);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Not JSON, return as string
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Delete a configuration value
|
|
76
|
+
*/
|
|
77
|
+
async delete(key) {
|
|
78
|
+
// Remove from cache
|
|
79
|
+
this.configCache.delete(key);
|
|
80
|
+
// Remove from storage
|
|
81
|
+
const configId = this.CONFIG_NOUN_PREFIX + key;
|
|
82
|
+
await this.storage.saveMetadata(configId, null);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* List all configuration keys
|
|
86
|
+
*/
|
|
87
|
+
async list() {
|
|
88
|
+
// Get all metadata keys from storage
|
|
89
|
+
const allMetadata = await this.storage.getMetadata('');
|
|
90
|
+
if (!allMetadata || typeof allMetadata !== 'object') {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
// Filter for config keys
|
|
94
|
+
const configKeys = [];
|
|
95
|
+
for (const key of Object.keys(allMetadata)) {
|
|
96
|
+
if (key.startsWith(this.CONFIG_NOUN_PREFIX)) {
|
|
97
|
+
configKeys.push(key.substring(this.CONFIG_NOUN_PREFIX.length));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return configKeys;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Check if a configuration key exists
|
|
104
|
+
*/
|
|
105
|
+
async has(key) {
|
|
106
|
+
if (this.configCache.has(key)) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
const configId = this.CONFIG_NOUN_PREFIX + key;
|
|
110
|
+
const metadata = await this.storage.getMetadata(configId);
|
|
111
|
+
return metadata !== null && metadata !== undefined;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Clear all configuration
|
|
115
|
+
*/
|
|
116
|
+
async clear() {
|
|
117
|
+
// Clear cache
|
|
118
|
+
this.configCache.clear();
|
|
119
|
+
// Clear from storage
|
|
120
|
+
const keys = await this.list();
|
|
121
|
+
for (const key of keys) {
|
|
122
|
+
await this.delete(key);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Export all configuration
|
|
127
|
+
*/
|
|
128
|
+
async export() {
|
|
129
|
+
const keys = await this.list();
|
|
130
|
+
const config = {};
|
|
131
|
+
for (const key of keys) {
|
|
132
|
+
const entry = await this.getEntry(key);
|
|
133
|
+
if (entry) {
|
|
134
|
+
config[key] = entry;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return config;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Import configuration
|
|
141
|
+
*/
|
|
142
|
+
async import(config) {
|
|
143
|
+
for (const [key, entry] of Object.entries(config)) {
|
|
144
|
+
this.configCache.set(key, entry);
|
|
145
|
+
const configId = this.CONFIG_NOUN_PREFIX + key;
|
|
146
|
+
await this.storage.saveMetadata(configId, entry);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get raw config entry (without decryption)
|
|
151
|
+
*/
|
|
152
|
+
async getEntry(key) {
|
|
153
|
+
if (this.configCache.has(key)) {
|
|
154
|
+
return this.configCache.get(key);
|
|
155
|
+
}
|
|
156
|
+
const configId = this.CONFIG_NOUN_PREFIX + key;
|
|
157
|
+
const metadata = await this.storage.getMetadata(configId);
|
|
158
|
+
if (!metadata) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
const entry = metadata;
|
|
162
|
+
this.configCache.set(key, entry);
|
|
163
|
+
return entry;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=ConfigAPI.js.map
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Management API for Brainy 3.0
|
|
3
|
+
* Provides backup, restore, import, export, and data management
|
|
4
|
+
*/
|
|
5
|
+
import { StorageAdapter } from '../coreTypes.js';
|
|
6
|
+
import { Entity, Relation } from '../types/brainy.types.js';
|
|
7
|
+
import { NounType } from '../types/graphTypes.js';
|
|
8
|
+
export interface BackupOptions {
|
|
9
|
+
includeVectors?: boolean;
|
|
10
|
+
compress?: boolean;
|
|
11
|
+
format?: 'json' | 'binary';
|
|
12
|
+
}
|
|
13
|
+
export interface RestoreOptions {
|
|
14
|
+
merge?: boolean;
|
|
15
|
+
overwrite?: boolean;
|
|
16
|
+
validate?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ImportOptions {
|
|
19
|
+
format: 'json' | 'csv';
|
|
20
|
+
mapping?: Record<string, string>;
|
|
21
|
+
batchSize?: number;
|
|
22
|
+
validate?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ExportOptions {
|
|
25
|
+
format?: 'json' | 'csv';
|
|
26
|
+
filter?: {
|
|
27
|
+
type?: NounType | NounType[];
|
|
28
|
+
where?: Record<string, any>;
|
|
29
|
+
service?: string;
|
|
30
|
+
};
|
|
31
|
+
includeVectors?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface BackupData {
|
|
34
|
+
version: string;
|
|
35
|
+
timestamp: number;
|
|
36
|
+
entities: Array<{
|
|
37
|
+
id: string;
|
|
38
|
+
vector?: number[];
|
|
39
|
+
type: string;
|
|
40
|
+
metadata: any;
|
|
41
|
+
service?: string;
|
|
42
|
+
}>;
|
|
43
|
+
relations: Array<{
|
|
44
|
+
id: string;
|
|
45
|
+
from: string;
|
|
46
|
+
to: string;
|
|
47
|
+
type: string;
|
|
48
|
+
weight: number;
|
|
49
|
+
metadata?: any;
|
|
50
|
+
}>;
|
|
51
|
+
config?: Record<string, any>;
|
|
52
|
+
stats: {
|
|
53
|
+
entityCount: number;
|
|
54
|
+
relationCount: number;
|
|
55
|
+
vectorDimensions?: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface ImportResult {
|
|
59
|
+
successful: number;
|
|
60
|
+
failed: number;
|
|
61
|
+
errors: Array<{
|
|
62
|
+
item: any;
|
|
63
|
+
error: string;
|
|
64
|
+
}>;
|
|
65
|
+
duration: number;
|
|
66
|
+
}
|
|
67
|
+
export declare class DataAPI {
|
|
68
|
+
private storage;
|
|
69
|
+
private getEntity;
|
|
70
|
+
private getRelation?;
|
|
71
|
+
private brain;
|
|
72
|
+
constructor(storage: StorageAdapter, getEntity: (id: string) => Promise<Entity | null>, getRelation?: ((id: string) => Promise<Relation | null>) | undefined, brain?: any);
|
|
73
|
+
/**
|
|
74
|
+
* Create a backup of all data
|
|
75
|
+
*/
|
|
76
|
+
backup(options?: BackupOptions): Promise<BackupData | {
|
|
77
|
+
compressed: boolean;
|
|
78
|
+
data: string;
|
|
79
|
+
originalSize: number;
|
|
80
|
+
compressedSize: number;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Restore data from a backup
|
|
84
|
+
*/
|
|
85
|
+
restore(params: {
|
|
86
|
+
backup: BackupData;
|
|
87
|
+
merge?: boolean;
|
|
88
|
+
overwrite?: boolean;
|
|
89
|
+
validate?: boolean;
|
|
90
|
+
}): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Clear data
|
|
93
|
+
*/
|
|
94
|
+
clear(params?: {
|
|
95
|
+
entities?: boolean;
|
|
96
|
+
relations?: boolean;
|
|
97
|
+
config?: boolean;
|
|
98
|
+
}): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Import data from various formats
|
|
101
|
+
*/
|
|
102
|
+
import(params: ImportOptions & {
|
|
103
|
+
data: any;
|
|
104
|
+
}): Promise<ImportResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Export data to various formats
|
|
107
|
+
*/
|
|
108
|
+
export(params?: ExportOptions): Promise<any>;
|
|
109
|
+
/**
|
|
110
|
+
* Get storage statistics
|
|
111
|
+
*/
|
|
112
|
+
getStats(): Promise<{
|
|
113
|
+
entities: number;
|
|
114
|
+
relations: number;
|
|
115
|
+
storageSize?: number;
|
|
116
|
+
vectorDimensions?: number;
|
|
117
|
+
}>;
|
|
118
|
+
private applyMapping;
|
|
119
|
+
private validateImportItem;
|
|
120
|
+
private matchesFilter;
|
|
121
|
+
private convertToCSV;
|
|
122
|
+
private generateId;
|
|
123
|
+
}
|