@soulcraft/brainy 3.43.2 → 3.43.3
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.
|
@@ -40,6 +40,15 @@ export interface StorageOptions {
|
|
|
40
40
|
* Root directory for file system storage (Node.js only)
|
|
41
41
|
*/
|
|
42
42
|
rootDirectory?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Nested options object for backward compatibility with BrainyConfig.storage.options
|
|
45
|
+
* Supports flexible API patterns
|
|
46
|
+
*/
|
|
47
|
+
options?: {
|
|
48
|
+
rootDirectory?: string;
|
|
49
|
+
path?: string;
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
};
|
|
43
52
|
/**
|
|
44
53
|
* Configuration for Amazon S3 storage
|
|
45
54
|
*/
|
|
@@ -8,6 +8,19 @@ import { S3CompatibleStorage, R2Storage } from './adapters/s3CompatibleStorage.j
|
|
|
8
8
|
import { GcsStorage } from './adapters/gcsStorage.js';
|
|
9
9
|
// FileSystemStorage is dynamically imported to avoid issues in browser environments
|
|
10
10
|
import { isBrowser } from '../utils/environment.js';
|
|
11
|
+
/**
|
|
12
|
+
* Extract filesystem root directory from options
|
|
13
|
+
* Single source of truth for path resolution - supports all API variants
|
|
14
|
+
* Zero-config philosophy: flexible input, predictable output
|
|
15
|
+
*/
|
|
16
|
+
function getFileSystemPath(options) {
|
|
17
|
+
return (options.rootDirectory || // Official storageFactory API
|
|
18
|
+
options.path || // User-friendly API
|
|
19
|
+
options.options?.rootDirectory || // Nested options API
|
|
20
|
+
options.options?.path || // Nested path API
|
|
21
|
+
'./brainy-data' // Zero-config fallback
|
|
22
|
+
);
|
|
23
|
+
}
|
|
11
24
|
/**
|
|
12
25
|
* Create a storage adapter based on the environment and configuration
|
|
13
26
|
* @param options Options for creating the storage adapter
|
|
@@ -28,7 +41,7 @@ export async function createStorage(options = {}) {
|
|
|
28
41
|
console.log('Using file system storage (forced)');
|
|
29
42
|
try {
|
|
30
43
|
const { FileSystemStorage } = await import('./adapters/fileSystemStorage.js');
|
|
31
|
-
return new FileSystemStorage(options
|
|
44
|
+
return new FileSystemStorage(getFileSystemPath(options));
|
|
32
45
|
}
|
|
33
46
|
catch (error) {
|
|
34
47
|
console.warn('Failed to load FileSystemStorage, falling back to memory storage:', error);
|
|
@@ -67,7 +80,7 @@ export async function createStorage(options = {}) {
|
|
|
67
80
|
console.log('Using file system storage');
|
|
68
81
|
try {
|
|
69
82
|
const { FileSystemStorage } = await import('./adapters/fileSystemStorage.js');
|
|
70
|
-
return new FileSystemStorage(options
|
|
83
|
+
return new FileSystemStorage(getFileSystemPath(options));
|
|
71
84
|
}
|
|
72
85
|
catch (error) {
|
|
73
86
|
console.warn('Failed to load FileSystemStorage, falling back to memory storage:', error);
|
|
@@ -220,7 +233,7 @@ export async function createStorage(options = {}) {
|
|
|
220
233
|
console.log('Using file system storage (auto-detected)');
|
|
221
234
|
try {
|
|
222
235
|
const { FileSystemStorage } = await import('./adapters/fileSystemStorage.js');
|
|
223
|
-
return new FileSystemStorage(options
|
|
236
|
+
return new FileSystemStorage(getFileSystemPath(options));
|
|
224
237
|
}
|
|
225
238
|
catch (fsError) {
|
|
226
239
|
console.warn('Failed to load FileSystemStorage, falling back to memory storage:', fsError);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "3.43.
|
|
3
|
+
"version": "3.43.3",
|
|
4
4
|
"description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|