@soulcraft/brainy 3.0.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 +53 -3
- package/README.md +353 -110
- package/bin/brainy.js +340 -62
- 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 +290 -9
- 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 +142 -8
- package/dist/augmentations/brainyAugmentation.js +179 -2
- package/dist/augmentations/cacheAugmentation.d.ts +8 -5
- package/dist/augmentations/cacheAugmentation.js +116 -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 +14 -10
- package/dist/augmentations/defaultAugmentations.js +16 -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/cache.d.ts +130 -0
- package/dist/augmentations/display/cache.js +319 -0
- package/dist/augmentations/display/fieldPatterns.d.ts +52 -0
- package/dist/augmentations/display/fieldPatterns.js +393 -0
- package/dist/augmentations/display/iconMappings.d.ts +57 -0
- package/dist/augmentations/display/iconMappings.js +68 -0
- package/dist/augmentations/display/intelligentComputation.d.ts +109 -0
- package/dist/augmentations/display/intelligentComputation.js +462 -0
- package/dist/augmentations/display/types.d.ts +203 -0
- package/dist/augmentations/display/types.js +7 -0
- package/dist/augmentations/entityRegistryAugmentation.d.ts +3 -1
- package/dist/augmentations/entityRegistryAugmentation.js +5 -1
- package/dist/augmentations/indexAugmentation.d.ts +5 -3
- package/dist/augmentations/indexAugmentation.js +5 -2
- package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +24 -7
- package/dist/augmentations/intelligentVerbScoringAugmentation.js +111 -27
- 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/neuralImport.js +4 -4
- 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/brainyTypes.d.ts +83 -0
- package/dist/augmentations/typeMatching/brainyTypes.js +425 -0
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.d.ts +39 -59
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +103 -389
- package/dist/augmentations/universalDisplayAugmentation.d.ts +191 -0
- package/dist/augmentations/universalDisplayAugmentation.js +371 -0
- 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 +56 -111
- package/dist/brainyData.js +912 -756
- 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/distributedPresets-new.d.ts +118 -0
- package/dist/config/distributedPresets-new.js +318 -0
- package/dist/config/distributedPresets.d.ts +118 -0
- package/dist/config/distributedPresets.js +318 -0
- package/dist/config/extensibleConfig.d.ts +99 -0
- package/dist/config/extensibleConfig.js +268 -0
- package/dist/config/index.d.ts +17 -0
- package/dist/config/index.js +35 -0
- package/dist/config/modelAutoConfig.d.ts +32 -0
- package/dist/config/modelAutoConfig.js +139 -0
- package/dist/config/modelPrecisionManager.d.ts +42 -0
- package/dist/config/modelPrecisionManager.js +98 -0
- package/dist/config/sharedConfigManager.d.ts +67 -0
- package/dist/config/sharedConfigManager.js +215 -0
- package/dist/config/storageAutoConfig.d.ts +41 -0
- package/dist/config/storageAutoConfig.js +328 -0
- package/dist/config/zeroConfig.d.ts +68 -0
- package/dist/config/zeroConfig.js +301 -0
- 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/CachedEmbeddings.d.ts +40 -0
- package/dist/embeddings/CachedEmbeddings.js +146 -0
- package/dist/embeddings/EmbeddingManager.d.ts +102 -0
- package/dist/embeddings/EmbeddingManager.js +291 -0
- package/dist/embeddings/SingletonModelManager.d.ts +95 -0
- package/dist/embeddings/SingletonModelManager.js +220 -0
- package/dist/embeddings/index.d.ts +12 -0
- package/dist/embeddings/index.js +16 -0
- package/dist/embeddings/lightweight-embedder.d.ts +0 -1
- package/dist/embeddings/lightweight-embedder.js +4 -12
- package/dist/embeddings/model-manager.d.ts +11 -0
- package/dist/embeddings/model-manager.js +43 -7
- package/dist/embeddings/universal-memory-manager.d.ts +1 -1
- package/dist/embeddings/universal-memory-manager.js +27 -67
- package/dist/embeddings/worker-embedding.js +4 -8
- package/dist/errors/brainyError.d.ts +5 -1
- package/dist/errors/brainyError.js +12 -0
- package/dist/examples/basicUsage.js +7 -4
- 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 +8 -5
- package/dist/index.d.ts +17 -22
- package/dist/index.js +37 -23
- 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.d.ts +357 -0
- package/dist/neural/improvedNeuralAPI.js +2628 -0
- 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/neural/types.d.ts +287 -0
- package/dist/neural/types.js +24 -0
- package/dist/shared/default-augmentations.d.ts +3 -3
- package/dist/shared/default-augmentations.js +5 -5
- package/dist/storage/adapters/baseStorageAdapter.d.ts +42 -0
- package/dist/storage/adapters/fileSystemStorage.d.ts +26 -2
- package/dist/storage/adapters/fileSystemStorage.js +218 -15
- package/dist/storage/adapters/memoryStorage.d.ts +4 -4
- package/dist/storage/adapters/memoryStorage.js +17 -12
- package/dist/storage/adapters/opfsStorage.d.ts +2 -2
- package/dist/storage/adapters/opfsStorage.js +2 -2
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +2 -2
- package/dist/storage/adapters/s3CompatibleStorage.js +2 -2
- package/dist/storage/backwardCompatibility.d.ts +10 -78
- package/dist/storage/backwardCompatibility.js +17 -132
- package/dist/storage/baseStorage.d.ts +18 -2
- package/dist/storage/baseStorage.js +74 -3
- 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 +5 -8
- package/dist/types/brainyDataInterface.js +2 -2
- package/dist/types/graphTypes.js +2 -2
- package/dist/utils/brainyTypes.d.ts +217 -0
- package/dist/utils/brainyTypes.js +261 -0
- package/dist/utils/cacheAutoConfig.d.ts +3 -3
- package/dist/utils/embedding.d.ts +9 -4
- package/dist/utils/embedding.js +89 -26
- package/dist/utils/enhancedLogger.d.ts +104 -0
- package/dist/utils/enhancedLogger.js +232 -0
- package/dist/utils/hybridModelManager.d.ts +19 -28
- package/dist/utils/hybridModelManager.js +36 -200
- 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/nodeVersionCheck.d.ts +24 -0
- package/dist/utils/nodeVersionCheck.js +65 -0
- 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 +59 -0
- package/dist/utils/typeValidation.js +374 -0
- package/dist/utils/version.js +19 -3
- package/package.json +15 -4
- package/scripts/download-models.cjs +94 -20
- package/dist/augmentations/walAugmentation.d.ts +0 -109
- package/dist/augmentations/walAugmentation.js +0 -516
- 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,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Resolver for Augmentations
|
|
3
|
+
*
|
|
4
|
+
* Handles loading and resolving configuration from multiple sources:
|
|
5
|
+
* - Environment variables
|
|
6
|
+
* - Configuration files
|
|
7
|
+
* - Runtime updates
|
|
8
|
+
* - Default values from schema
|
|
9
|
+
*/
|
|
10
|
+
import { JSONSchema } from './manifest.js';
|
|
11
|
+
/**
|
|
12
|
+
* Configuration source priority (highest to lowest)
|
|
13
|
+
*/
|
|
14
|
+
export declare enum ConfigPriority {
|
|
15
|
+
RUNTIME = 4,// Runtime updates (highest priority)
|
|
16
|
+
CONSTRUCTOR = 3,// Constructor parameters
|
|
17
|
+
ENVIRONMENT = 2,// Environment variables
|
|
18
|
+
FILE = 1,// Configuration files
|
|
19
|
+
DEFAULT = 0
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Configuration source information
|
|
23
|
+
*/
|
|
24
|
+
export interface ConfigSource {
|
|
25
|
+
priority: ConfigPriority;
|
|
26
|
+
source: string;
|
|
27
|
+
config: any;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Configuration resolution options
|
|
31
|
+
*/
|
|
32
|
+
export interface ConfigResolverOptions {
|
|
33
|
+
augmentationId: string;
|
|
34
|
+
schema?: JSONSchema;
|
|
35
|
+
defaults?: Record<string, any>;
|
|
36
|
+
configPaths?: string[];
|
|
37
|
+
envPrefix?: string;
|
|
38
|
+
allowUndefined?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Augmentation Configuration Resolver
|
|
42
|
+
*/
|
|
43
|
+
export declare class AugmentationConfigResolver {
|
|
44
|
+
private options;
|
|
45
|
+
private sources;
|
|
46
|
+
private resolved;
|
|
47
|
+
constructor(options: ConfigResolverOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Resolve configuration from all sources
|
|
50
|
+
* @param constructorConfig Optional constructor configuration
|
|
51
|
+
* @returns Resolved configuration
|
|
52
|
+
*/
|
|
53
|
+
resolve(constructorConfig?: any): any;
|
|
54
|
+
/**
|
|
55
|
+
* Load default values from schema and defaults
|
|
56
|
+
*/
|
|
57
|
+
private loadDefaults;
|
|
58
|
+
/**
|
|
59
|
+
* Load configuration from files
|
|
60
|
+
*/
|
|
61
|
+
private loadFromFiles;
|
|
62
|
+
/**
|
|
63
|
+
* Parse configuration file based on extension
|
|
64
|
+
*/
|
|
65
|
+
private parseConfigFile;
|
|
66
|
+
/**
|
|
67
|
+
* Extract augmentation-specific configuration from a config object
|
|
68
|
+
*/
|
|
69
|
+
private extractAugmentationConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Load configuration from environment variables
|
|
72
|
+
*/
|
|
73
|
+
private loadFromEnvironment;
|
|
74
|
+
/**
|
|
75
|
+
* Convert environment variable key to config key
|
|
76
|
+
* ENABLED -> enabled
|
|
77
|
+
* MAX_SIZE -> maxSize
|
|
78
|
+
*/
|
|
79
|
+
private envKeyToConfigKey;
|
|
80
|
+
/**
|
|
81
|
+
* Parse environment variable value
|
|
82
|
+
*/
|
|
83
|
+
private parseEnvValue;
|
|
84
|
+
/**
|
|
85
|
+
* Merge configurations by priority
|
|
86
|
+
*/
|
|
87
|
+
private mergeConfigurations;
|
|
88
|
+
/**
|
|
89
|
+
* Deep merge two objects
|
|
90
|
+
*/
|
|
91
|
+
private deepMerge;
|
|
92
|
+
/**
|
|
93
|
+
* Validate configuration against schema
|
|
94
|
+
*/
|
|
95
|
+
private validateConfiguration;
|
|
96
|
+
/**
|
|
97
|
+
* Validate a single property against its schema
|
|
98
|
+
*/
|
|
99
|
+
private validateProperty;
|
|
100
|
+
/**
|
|
101
|
+
* Get configuration sources for debugging
|
|
102
|
+
*/
|
|
103
|
+
getSources(): ConfigSource[];
|
|
104
|
+
/**
|
|
105
|
+
* Get resolved configuration
|
|
106
|
+
*/
|
|
107
|
+
getResolved(): any;
|
|
108
|
+
/**
|
|
109
|
+
* Update configuration at runtime
|
|
110
|
+
*/
|
|
111
|
+
updateRuntime(config: any): any;
|
|
112
|
+
/**
|
|
113
|
+
* Save configuration to file
|
|
114
|
+
* @param filepath Path to save configuration
|
|
115
|
+
* @param format Format to save as (json, etc.)
|
|
116
|
+
*/
|
|
117
|
+
saveToFile(filepath?: string, format?: 'json'): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Get environment variable names for this augmentation
|
|
120
|
+
*/
|
|
121
|
+
getEnvironmentVariables(): Record<string, any>;
|
|
122
|
+
}
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Resolver for Augmentations
|
|
3
|
+
*
|
|
4
|
+
* Handles loading and resolving configuration from multiple sources:
|
|
5
|
+
* - Environment variables
|
|
6
|
+
* - Configuration files
|
|
7
|
+
* - Runtime updates
|
|
8
|
+
* - Default values from schema
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, readFileSync } from 'fs';
|
|
11
|
+
import { join } from 'path';
|
|
12
|
+
import { homedir } from 'os';
|
|
13
|
+
/**
|
|
14
|
+
* Configuration source priority (highest to lowest)
|
|
15
|
+
*/
|
|
16
|
+
export var ConfigPriority;
|
|
17
|
+
(function (ConfigPriority) {
|
|
18
|
+
ConfigPriority[ConfigPriority["RUNTIME"] = 4] = "RUNTIME";
|
|
19
|
+
ConfigPriority[ConfigPriority["CONSTRUCTOR"] = 3] = "CONSTRUCTOR";
|
|
20
|
+
ConfigPriority[ConfigPriority["ENVIRONMENT"] = 2] = "ENVIRONMENT";
|
|
21
|
+
ConfigPriority[ConfigPriority["FILE"] = 1] = "FILE";
|
|
22
|
+
ConfigPriority[ConfigPriority["DEFAULT"] = 0] = "DEFAULT"; // Schema defaults (lowest priority)
|
|
23
|
+
})(ConfigPriority || (ConfigPriority = {}));
|
|
24
|
+
/**
|
|
25
|
+
* Augmentation Configuration Resolver
|
|
26
|
+
*/
|
|
27
|
+
export class AugmentationConfigResolver {
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.options = options;
|
|
30
|
+
this.sources = [];
|
|
31
|
+
this.resolved = {};
|
|
32
|
+
this.options = {
|
|
33
|
+
configPaths: [
|
|
34
|
+
'.brainyrc',
|
|
35
|
+
'.brainyrc.json',
|
|
36
|
+
'brainy.config.json',
|
|
37
|
+
join(homedir(), '.brainy', 'config.json'),
|
|
38
|
+
join(homedir(), '.brainyrc')
|
|
39
|
+
],
|
|
40
|
+
envPrefix: `BRAINY_AUG_${options.augmentationId.toUpperCase()}_`,
|
|
41
|
+
allowUndefined: true,
|
|
42
|
+
...options
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resolve configuration from all sources
|
|
47
|
+
* @param constructorConfig Optional constructor configuration
|
|
48
|
+
* @returns Resolved configuration
|
|
49
|
+
*/
|
|
50
|
+
resolve(constructorConfig) {
|
|
51
|
+
this.sources = [];
|
|
52
|
+
// Load from all sources in priority order
|
|
53
|
+
this.loadDefaults();
|
|
54
|
+
this.loadFromFiles();
|
|
55
|
+
this.loadFromEnvironment();
|
|
56
|
+
if (constructorConfig) {
|
|
57
|
+
this.sources.push({
|
|
58
|
+
priority: ConfigPriority.CONSTRUCTOR,
|
|
59
|
+
source: 'constructor',
|
|
60
|
+
config: constructorConfig
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// Merge configurations by priority
|
|
64
|
+
this.resolved = this.mergeConfigurations();
|
|
65
|
+
// Validate against schema if provided
|
|
66
|
+
if (this.options.schema) {
|
|
67
|
+
this.validateConfiguration(this.resolved);
|
|
68
|
+
}
|
|
69
|
+
return this.resolved;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Load default values from schema and defaults
|
|
73
|
+
*/
|
|
74
|
+
loadDefaults() {
|
|
75
|
+
let defaults = {};
|
|
76
|
+
// Load from provided defaults
|
|
77
|
+
if (this.options.defaults) {
|
|
78
|
+
defaults = { ...defaults, ...this.options.defaults };
|
|
79
|
+
}
|
|
80
|
+
// Load from schema defaults
|
|
81
|
+
if (this.options.schema?.properties) {
|
|
82
|
+
for (const [key, prop] of Object.entries(this.options.schema.properties)) {
|
|
83
|
+
if (prop.default !== undefined && defaults[key] === undefined) {
|
|
84
|
+
defaults[key] = prop.default;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (Object.keys(defaults).length > 0) {
|
|
89
|
+
this.sources.push({
|
|
90
|
+
priority: ConfigPriority.DEFAULT,
|
|
91
|
+
source: 'defaults',
|
|
92
|
+
config: defaults
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Load configuration from files
|
|
98
|
+
*/
|
|
99
|
+
loadFromFiles() {
|
|
100
|
+
// Skip in browser environment
|
|
101
|
+
if (typeof process === 'undefined' || typeof window !== 'undefined') {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
for (const configPath of this.options.configPaths || []) {
|
|
105
|
+
try {
|
|
106
|
+
if (existsSync(configPath)) {
|
|
107
|
+
const content = readFileSync(configPath, 'utf8');
|
|
108
|
+
const config = this.parseConfigFile(content, configPath);
|
|
109
|
+
// Extract augmentation-specific configuration
|
|
110
|
+
const augConfig = this.extractAugmentationConfig(config);
|
|
111
|
+
if (augConfig && Object.keys(augConfig).length > 0) {
|
|
112
|
+
this.sources.push({
|
|
113
|
+
priority: ConfigPriority.FILE,
|
|
114
|
+
source: `file:${configPath}`,
|
|
115
|
+
config: augConfig
|
|
116
|
+
});
|
|
117
|
+
break; // Use first found config file
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
// Silently ignore file errors
|
|
123
|
+
console.debug(`Failed to load config from ${configPath}:`, error);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Parse configuration file based on extension
|
|
129
|
+
*/
|
|
130
|
+
parseConfigFile(content, filepath) {
|
|
131
|
+
try {
|
|
132
|
+
// Try JSON first
|
|
133
|
+
return JSON.parse(content);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// Try other formats in the future (YAML, TOML, etc.)
|
|
137
|
+
throw new Error(`Unable to parse config file: ${filepath}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Extract augmentation-specific configuration from a config object
|
|
142
|
+
*/
|
|
143
|
+
extractAugmentationConfig(config) {
|
|
144
|
+
const augId = this.options.augmentationId;
|
|
145
|
+
// Check for augmentations section
|
|
146
|
+
if (config.augmentations && config.augmentations[augId]) {
|
|
147
|
+
return config.augmentations[augId];
|
|
148
|
+
}
|
|
149
|
+
// Check for direct augmentation config (prefixed keys)
|
|
150
|
+
const prefix = `${augId}.`;
|
|
151
|
+
const augConfig = {};
|
|
152
|
+
for (const [key, value] of Object.entries(config)) {
|
|
153
|
+
if (key.startsWith(prefix)) {
|
|
154
|
+
const configKey = key.slice(prefix.length);
|
|
155
|
+
augConfig[configKey] = value;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return Object.keys(augConfig).length > 0 ? augConfig : null;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Load configuration from environment variables
|
|
162
|
+
*/
|
|
163
|
+
loadFromEnvironment() {
|
|
164
|
+
// Skip in browser environment
|
|
165
|
+
if (typeof process === 'undefined' || !process.env) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const prefix = this.options.envPrefix;
|
|
169
|
+
const envConfig = {};
|
|
170
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
171
|
+
if (key.startsWith(prefix)) {
|
|
172
|
+
const configKey = this.envKeyToConfigKey(key.slice(prefix.length));
|
|
173
|
+
envConfig[configKey] = this.parseEnvValue(value);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (Object.keys(envConfig).length > 0) {
|
|
177
|
+
this.sources.push({
|
|
178
|
+
priority: ConfigPriority.ENVIRONMENT,
|
|
179
|
+
source: 'environment',
|
|
180
|
+
config: envConfig
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Convert environment variable key to config key
|
|
186
|
+
* ENABLED -> enabled
|
|
187
|
+
* MAX_SIZE -> maxSize
|
|
188
|
+
*/
|
|
189
|
+
envKeyToConfigKey(envKey) {
|
|
190
|
+
return envKey
|
|
191
|
+
.toLowerCase()
|
|
192
|
+
.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Parse environment variable value
|
|
196
|
+
*/
|
|
197
|
+
parseEnvValue(value) {
|
|
198
|
+
// Handle empty strings
|
|
199
|
+
if (value === '')
|
|
200
|
+
return value;
|
|
201
|
+
// Try to parse as JSON
|
|
202
|
+
try {
|
|
203
|
+
return JSON.parse(value);
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
// Check for boolean strings
|
|
207
|
+
if (value.toLowerCase() === 'true')
|
|
208
|
+
return true;
|
|
209
|
+
if (value.toLowerCase() === 'false')
|
|
210
|
+
return false;
|
|
211
|
+
// Check for number strings
|
|
212
|
+
const num = Number(value);
|
|
213
|
+
if (!isNaN(num) && value.trim() !== '')
|
|
214
|
+
return num;
|
|
215
|
+
// Return as string
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Merge configurations by priority
|
|
221
|
+
*/
|
|
222
|
+
mergeConfigurations() {
|
|
223
|
+
// Sort by priority (lowest to highest)
|
|
224
|
+
const sorted = [...this.sources].sort((a, b) => a.priority - b.priority);
|
|
225
|
+
// Merge configurations
|
|
226
|
+
let merged = {};
|
|
227
|
+
for (const source of sorted) {
|
|
228
|
+
merged = this.deepMerge(merged, source.config);
|
|
229
|
+
}
|
|
230
|
+
return merged;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Deep merge two objects
|
|
234
|
+
*/
|
|
235
|
+
deepMerge(target, source) {
|
|
236
|
+
const output = { ...target };
|
|
237
|
+
for (const key in source) {
|
|
238
|
+
if (source.hasOwnProperty(key)) {
|
|
239
|
+
if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
|
240
|
+
if (target[key] && typeof target[key] === 'object' && !Array.isArray(target[key])) {
|
|
241
|
+
output[key] = this.deepMerge(target[key], source[key]);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
output[key] = source[key];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
output[key] = source[key];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return output;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Validate configuration against schema
|
|
256
|
+
*/
|
|
257
|
+
validateConfiguration(config) {
|
|
258
|
+
if (!this.options.schema)
|
|
259
|
+
return;
|
|
260
|
+
const schema = this.options.schema;
|
|
261
|
+
const errors = [];
|
|
262
|
+
// Check required fields
|
|
263
|
+
if (schema.required) {
|
|
264
|
+
for (const field of schema.required) {
|
|
265
|
+
if (config[field] === undefined) {
|
|
266
|
+
errors.push(`Missing required field: ${field}`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Validate properties
|
|
271
|
+
if (schema.properties) {
|
|
272
|
+
for (const [key, propSchema] of Object.entries(schema.properties)) {
|
|
273
|
+
const value = config[key];
|
|
274
|
+
if (value !== undefined) {
|
|
275
|
+
this.validateProperty(key, value, propSchema, errors);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// Check for additional properties
|
|
280
|
+
if (schema.additionalProperties === false) {
|
|
281
|
+
const allowedKeys = Object.keys(schema.properties || {});
|
|
282
|
+
for (const key of Object.keys(config)) {
|
|
283
|
+
if (!allowedKeys.includes(key)) {
|
|
284
|
+
errors.push(`Unknown configuration property: ${key}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (errors.length > 0) {
|
|
289
|
+
throw new Error(`Configuration validation failed for ${this.options.augmentationId}:\n${errors.join('\n')}`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Validate a single property against its schema
|
|
294
|
+
*/
|
|
295
|
+
validateProperty(key, value, schema, errors) {
|
|
296
|
+
// Type validation
|
|
297
|
+
if (schema.type) {
|
|
298
|
+
const actualType = Array.isArray(value) ? 'array' : typeof value;
|
|
299
|
+
if (actualType !== schema.type) {
|
|
300
|
+
errors.push(`${key}: expected ${schema.type}, got ${actualType}`);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// Number validations
|
|
305
|
+
if (schema.type === 'number') {
|
|
306
|
+
if (schema.minimum !== undefined && value < schema.minimum) {
|
|
307
|
+
errors.push(`${key}: value ${value} is less than minimum ${schema.minimum}`);
|
|
308
|
+
}
|
|
309
|
+
if (schema.maximum !== undefined && value > schema.maximum) {
|
|
310
|
+
errors.push(`${key}: value ${value} is greater than maximum ${schema.maximum}`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
// String validations
|
|
314
|
+
if (schema.type === 'string') {
|
|
315
|
+
if (schema.minLength !== undefined && value.length < schema.minLength) {
|
|
316
|
+
errors.push(`${key}: length ${value.length} is less than minimum ${schema.minLength}`);
|
|
317
|
+
}
|
|
318
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength) {
|
|
319
|
+
errors.push(`${key}: length ${value.length} is greater than maximum ${schema.maxLength}`);
|
|
320
|
+
}
|
|
321
|
+
if (schema.pattern) {
|
|
322
|
+
const regex = new RegExp(schema.pattern);
|
|
323
|
+
if (!regex.test(value)) {
|
|
324
|
+
errors.push(`${key}: value does not match pattern ${schema.pattern}`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
// Enum validation
|
|
329
|
+
if (schema.enum && !schema.enum.includes(value)) {
|
|
330
|
+
errors.push(`${key}: value ${value} is not one of allowed values: ${schema.enum.join(', ')}`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Get configuration sources for debugging
|
|
335
|
+
*/
|
|
336
|
+
getSources() {
|
|
337
|
+
return [...this.sources];
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Get resolved configuration
|
|
341
|
+
*/
|
|
342
|
+
getResolved() {
|
|
343
|
+
return { ...this.resolved };
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Update configuration at runtime
|
|
347
|
+
*/
|
|
348
|
+
updateRuntime(config) {
|
|
349
|
+
// Add or update runtime source
|
|
350
|
+
const runtimeIndex = this.sources.findIndex(s => s.priority === ConfigPriority.RUNTIME);
|
|
351
|
+
if (runtimeIndex >= 0) {
|
|
352
|
+
this.sources[runtimeIndex].config = {
|
|
353
|
+
...this.sources[runtimeIndex].config,
|
|
354
|
+
...config
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
this.sources.push({
|
|
359
|
+
priority: ConfigPriority.RUNTIME,
|
|
360
|
+
source: 'runtime',
|
|
361
|
+
config
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
// Re-merge configurations
|
|
365
|
+
this.resolved = this.mergeConfigurations();
|
|
366
|
+
// Validate
|
|
367
|
+
if (this.options.schema) {
|
|
368
|
+
this.validateConfiguration(this.resolved);
|
|
369
|
+
}
|
|
370
|
+
return this.resolved;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Save configuration to file
|
|
374
|
+
* @param filepath Path to save configuration
|
|
375
|
+
* @param format Format to save as (json, etc.)
|
|
376
|
+
*/
|
|
377
|
+
async saveToFile(filepath, format = 'json') {
|
|
378
|
+
// Skip in browser environment
|
|
379
|
+
if (typeof process === 'undefined' || typeof window !== 'undefined') {
|
|
380
|
+
throw new Error('Cannot save configuration files in browser environment');
|
|
381
|
+
}
|
|
382
|
+
const fs = await import('fs');
|
|
383
|
+
const path = await import('path');
|
|
384
|
+
const configPath = filepath || this.options.configPaths?.[0] || '.brainyrc';
|
|
385
|
+
const augId = this.options.augmentationId;
|
|
386
|
+
// Load existing config if it exists
|
|
387
|
+
let fullConfig = {};
|
|
388
|
+
try {
|
|
389
|
+
if (fs.existsSync(configPath)) {
|
|
390
|
+
const content = fs.readFileSync(configPath, 'utf8');
|
|
391
|
+
fullConfig = JSON.parse(content);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
catch {
|
|
395
|
+
// Start with empty config
|
|
396
|
+
}
|
|
397
|
+
// Ensure augmentations section exists
|
|
398
|
+
if (!fullConfig.augmentations) {
|
|
399
|
+
fullConfig.augmentations = {};
|
|
400
|
+
}
|
|
401
|
+
// Update augmentation config
|
|
402
|
+
fullConfig.augmentations[augId] = this.resolved;
|
|
403
|
+
// Save based on format
|
|
404
|
+
let content;
|
|
405
|
+
if (format === 'json') {
|
|
406
|
+
content = JSON.stringify(fullConfig, null, 2);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
410
|
+
}
|
|
411
|
+
// Ensure directory exists
|
|
412
|
+
const dir = path.dirname(configPath);
|
|
413
|
+
if (!fs.existsSync(dir)) {
|
|
414
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
415
|
+
}
|
|
416
|
+
// Write file
|
|
417
|
+
fs.writeFileSync(configPath, content, 'utf8');
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Get environment variable names for this augmentation
|
|
421
|
+
*/
|
|
422
|
+
getEnvironmentVariables() {
|
|
423
|
+
const schema = this.options.schema;
|
|
424
|
+
const prefix = this.options.envPrefix;
|
|
425
|
+
const vars = {};
|
|
426
|
+
if (schema?.properties) {
|
|
427
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
428
|
+
const envKey = prefix + key.replace(/([A-Z])/g, '_$1').toUpperCase();
|
|
429
|
+
vars[envKey] = {
|
|
430
|
+
description: prop.description,
|
|
431
|
+
type: prop.type,
|
|
432
|
+
default: prop.default,
|
|
433
|
+
currentValue: process.env?.[envKey]
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return vars;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
//# sourceMappingURL=configResolver.js.map
|
|
@@ -22,7 +22,7 @@ export declare class ConnectionPoolAugmentation extends BaseAugmentation {
|
|
|
22
22
|
metadata: "none";
|
|
23
23
|
operations: ("storage")[];
|
|
24
24
|
priority: number;
|
|
25
|
-
|
|
25
|
+
protected config: Required<ConnectionPoolConfig>;
|
|
26
26
|
private connections;
|
|
27
27
|
private requestQueue;
|
|
28
28
|
private healthCheckInterval?;
|
|
@@ -43,6 +43,8 @@ export declare class ConnectionPoolAugmentation extends BaseAugmentation {
|
|
|
43
43
|
private processQueue;
|
|
44
44
|
private initializeConnectionPool;
|
|
45
45
|
private createConnection;
|
|
46
|
+
private createStorageConnection;
|
|
47
|
+
private getOrCreateConnection;
|
|
46
48
|
private startHealthChecks;
|
|
47
49
|
private performHealthChecks;
|
|
48
50
|
private startMetricsCollection;
|
|
@@ -130,11 +130,11 @@ export class ConnectionPoolAugmentation extends BaseAugmentation {
|
|
|
130
130
|
throw new Error('Connection pool queue full - system overloaded');
|
|
131
131
|
}
|
|
132
132
|
// Try to get available connection immediately
|
|
133
|
-
const connection = this.
|
|
134
|
-
if (connection) {
|
|
133
|
+
const connection = await this.getOrCreateConnection();
|
|
134
|
+
if (connection && connection.isIdle) {
|
|
135
135
|
return this.executeWithConnection(connection, operation, executor);
|
|
136
136
|
}
|
|
137
|
-
// Queue the request
|
|
137
|
+
// Queue the request with the actual executor
|
|
138
138
|
return this.queueRequest(operation, params, executor, priority);
|
|
139
139
|
}
|
|
140
140
|
getAvailableConnection() {
|
|
@@ -181,6 +181,7 @@ export class ConnectionPoolAugmentation extends BaseAugmentation {
|
|
|
181
181
|
id: `req_${Date.now()}_${Math.random()}`,
|
|
182
182
|
operation,
|
|
183
183
|
params,
|
|
184
|
+
executor, // Store the actual executor function
|
|
184
185
|
resolver: resolve,
|
|
185
186
|
rejector: reject,
|
|
186
187
|
timestamp: Date.now(),
|
|
@@ -214,13 +215,10 @@ export class ConnectionPoolAugmentation extends BaseAugmentation {
|
|
|
214
215
|
return;
|
|
215
216
|
const request = this.requestQueue.shift();
|
|
216
217
|
this.stats.queuedRequests--;
|
|
217
|
-
// Execute queued request
|
|
218
|
-
this.executeWithConnection(connection, request.operation,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
// For now, we'll resolve with a placeholder
|
|
222
|
-
return {};
|
|
223
|
-
}).then(request.resolver).catch(request.rejector);
|
|
218
|
+
// Execute queued request with the REAL executor
|
|
219
|
+
this.executeWithConnection(connection, request.operation, request.executor)
|
|
220
|
+
.then(request.resolver)
|
|
221
|
+
.catch(request.rejector);
|
|
224
222
|
}
|
|
225
223
|
async initializeConnectionPool() {
|
|
226
224
|
// Create minimum connections
|
|
@@ -230,18 +228,45 @@ export class ConnectionPoolAugmentation extends BaseAugmentation {
|
|
|
230
228
|
}
|
|
231
229
|
async createConnection() {
|
|
232
230
|
const connectionId = `conn_${Date.now()}_${Math.random()}`;
|
|
231
|
+
// Create actual connection based on storage type
|
|
232
|
+
const actualConnection = await this.createStorageConnection();
|
|
233
233
|
const connection = {
|
|
234
234
|
id: connectionId,
|
|
235
|
-
connection:
|
|
235
|
+
connection: actualConnection,
|
|
236
236
|
isIdle: true,
|
|
237
237
|
lastUsed: Date.now(),
|
|
238
238
|
healthScore: 100,
|
|
239
|
-
activeRequests: 0
|
|
239
|
+
activeRequests: 0,
|
|
240
|
+
requestCount: 0
|
|
240
241
|
};
|
|
241
242
|
this.connections.set(connectionId, connection);
|
|
242
243
|
this.stats.totalConnections++;
|
|
243
244
|
return connection;
|
|
244
245
|
}
|
|
246
|
+
async createStorageConnection() {
|
|
247
|
+
// For cloud storage, reuse the existing storage instance
|
|
248
|
+
// Connection pooling in this context means managing concurrent requests
|
|
249
|
+
// not creating multiple storage instances (which would be wasteful)
|
|
250
|
+
const storage = this.context?.storage;
|
|
251
|
+
if (!storage) {
|
|
252
|
+
throw new Error('Storage not available for connection pooling');
|
|
253
|
+
}
|
|
254
|
+
// Return a connection wrapper that tracks usage
|
|
255
|
+
return {
|
|
256
|
+
storage,
|
|
257
|
+
created: Date.now(),
|
|
258
|
+
requestCount: 0
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
async getOrCreateConnection() {
|
|
262
|
+
// Try to get an available connection
|
|
263
|
+
let connection = this.getAvailableConnection();
|
|
264
|
+
// If no connection available and under max, create new one
|
|
265
|
+
if (!connection && this.connections.size < this.config.maxConnections) {
|
|
266
|
+
connection = await this.createConnection();
|
|
267
|
+
}
|
|
268
|
+
return connection;
|
|
269
|
+
}
|
|
245
270
|
startHealthChecks() {
|
|
246
271
|
this.healthCheckInterval = setInterval(() => {
|
|
247
272
|
this.performHealthChecks();
|