@soulcraft/brainy 0.39.0 → 0.41.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/dist/brainyData.d.ts +5 -0
- package/dist/coreTypes.d.ts +48 -0
- package/dist/hnsw/hnswIndex.d.ts +9 -0
- package/dist/hnsw/hnswIndex.d.ts.map +1 -1
- package/dist/hnsw/hnswIndexOptimized.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/storage/adapters/fileSystemStorage.d.ts.map +1 -1
- package/dist/storage/adapters/memoryStorage.d.ts.map +1 -1
- package/dist/storage/adapters/opfsStorage.d.ts.map +1 -1
- package/dist/storage/adapters/optimizedS3Search.d.ts +79 -0
- package/dist/storage/adapters/optimizedS3Search.d.ts.map +1 -0
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +21 -0
- package/dist/storage/adapters/s3CompatibleStorage.d.ts.map +1 -1
- package/dist/storage/baseStorage.d.ts +1 -0
- package/dist/storage/baseStorage.d.ts.map +1 -1
- package/dist/storage/cacheManager.d.ts +2 -2
- package/dist/storage/cacheManager.d.ts.map +1 -1
- package/dist/unified.js +721 -131
- package/dist/unified.min.js +991 -991
- package/dist/utils/logger.d.ts +45 -92
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/statisticsCollector.d.ts +55 -0
- package/dist/utils/statisticsCollector.d.ts.map +1 -0
- package/package.json +4 -1
package/dist/utils/logger.d.ts
CHANGED
|
@@ -1,99 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized logging utility for Brainy
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
* Provides configurable log levels and consistent logging across the codebase
|
|
4
|
+
*/
|
|
5
|
+
export declare enum LogLevel {
|
|
6
|
+
ERROR = 0,
|
|
7
|
+
WARN = 1,
|
|
8
|
+
INFO = 2,
|
|
9
|
+
DEBUG = 3,
|
|
10
|
+
TRACE = 4
|
|
11
|
+
}
|
|
11
12
|
export interface LoggerConfig {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* @default true
|
|
20
|
-
*/
|
|
21
|
-
showPrefix?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Custom prefix for log messages
|
|
24
|
-
* @default 'Brainy'
|
|
25
|
-
*/
|
|
26
|
-
prefix?: string;
|
|
13
|
+
level: LogLevel;
|
|
14
|
+
modules?: {
|
|
15
|
+
[moduleName: string]: LogLevel;
|
|
16
|
+
};
|
|
17
|
+
timestamps?: boolean;
|
|
18
|
+
includeModule?: boolean;
|
|
19
|
+
handler?: (level: LogLevel, module: string, message: string, ...args: any[]) => void;
|
|
27
20
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Log warning messages (always shown, but can be controlled)
|
|
54
|
-
*/
|
|
55
|
-
warn: (message: string, ...args: any[]) => void;
|
|
56
|
-
/**
|
|
57
|
-
* Log error messages (always shown)
|
|
58
|
-
*/
|
|
21
|
+
declare class Logger {
|
|
22
|
+
private static instance;
|
|
23
|
+
private config;
|
|
24
|
+
private constructor();
|
|
25
|
+
static getInstance(): Logger;
|
|
26
|
+
configure(config: Partial<LoggerConfig>): void;
|
|
27
|
+
private shouldLog;
|
|
28
|
+
private formatMessage;
|
|
29
|
+
private log;
|
|
30
|
+
error(module: string, message: string, ...args: any[]): void;
|
|
31
|
+
warn(module: string, message: string, ...args: any[]): void;
|
|
32
|
+
info(module: string, message: string, ...args: any[]): void;
|
|
33
|
+
debug(module: string, message: string, ...args: any[]): void;
|
|
34
|
+
trace(module: string, message: string, ...args: any[]): void;
|
|
35
|
+
createModuleLogger(module: string): {
|
|
36
|
+
error: (message: string, ...args: any[]) => void;
|
|
37
|
+
warn: (message: string, ...args: any[]) => void;
|
|
38
|
+
info: (message: string, ...args: any[]) => void;
|
|
39
|
+
debug: (message: string, ...args: any[]) => void;
|
|
40
|
+
trace: (message: string, ...args: any[]) => void;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export declare const logger: Logger;
|
|
44
|
+
export declare function createModuleLogger(module: string): {
|
|
59
45
|
error: (message: string, ...args: any[]) => void;
|
|
60
|
-
/**
|
|
61
|
-
* Log with custom prefix (only shown when debug mode is enabled)
|
|
62
|
-
*/
|
|
63
|
-
debugWithPrefix: (prefix: string, message: string, ...args: any[]) => void;
|
|
64
|
-
/**
|
|
65
|
-
* Log info with custom prefix (only shown when debug mode is enabled)
|
|
66
|
-
*/
|
|
67
|
-
infoWithPrefix: (prefix: string, message: string, ...args: any[]) => void;
|
|
68
|
-
/**
|
|
69
|
-
* Log warning with custom prefix (controlled by debug mode)
|
|
70
|
-
*/
|
|
71
|
-
warnWithPrefix: (prefix: string, message: string, ...args: any[]) => void;
|
|
72
|
-
/**
|
|
73
|
-
* Log error with custom prefix (always shown)
|
|
74
|
-
*/
|
|
75
|
-
errorWithPrefix: (prefix: string, message: string, ...args: any[]) => void;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Legacy console methods for backward compatibility
|
|
79
|
-
* These will respect the debug mode setting
|
|
80
|
-
*/
|
|
81
|
-
export declare const debugConsole: {
|
|
82
|
-
log: (message: string, ...args: any[]) => void;
|
|
83
|
-
debug: (message: string, ...args: any[]) => void;
|
|
84
|
-
info: (message: string, ...args: any[]) => void;
|
|
85
46
|
warn: (message: string, ...args: any[]) => void;
|
|
86
|
-
|
|
47
|
+
info: (message: string, ...args: any[]) => void;
|
|
48
|
+
debug: (message: string, ...args: any[]) => void;
|
|
49
|
+
trace: (message: string, ...args: any[]) => void;
|
|
87
50
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*/
|
|
91
|
-
export declare function enableDebugMode(): void;
|
|
92
|
-
/**
|
|
93
|
-
* Disable debug mode programmatically
|
|
94
|
-
*/
|
|
95
|
-
export declare function disableDebugMode(): void;
|
|
96
|
-
/**
|
|
97
|
-
* Create a scoped logger with a specific prefix
|
|
98
|
-
*/
|
|
99
|
-
export declare function createScopedLogger(prefix: string): typeof logger;
|
|
51
|
+
export declare function configureLogger(config: Partial<LoggerConfig>): void;
|
|
52
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;IACT,KAAK,IAAI;CACV;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,QAAQ,CAAA;IAEf,OAAO,CAAC,EAAE;QACR,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAA;KAC/B,CAAA;IAED,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB,aAAa,CAAC,EAAE,OAAO,CAAA;IAEvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CACrF;AAED,cAAM,MAAM;IACV,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAQ;IAC/B,OAAO,CAAC,MAAM,CAIb;I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OAAO,CAAC,YAAY,CAAC,QAE5D"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight statistics collector for Brainy
|
|
3
|
+
* Designed to have minimal performance impact even with millions of entries
|
|
4
|
+
*/
|
|
5
|
+
import { StatisticsData } from '../coreTypes.js';
|
|
6
|
+
export declare class StatisticsCollector {
|
|
7
|
+
private contentTypes;
|
|
8
|
+
private oldestTimestamp;
|
|
9
|
+
private newestTimestamp;
|
|
10
|
+
private updateTimestamps;
|
|
11
|
+
private searchMetrics;
|
|
12
|
+
private verbTypes;
|
|
13
|
+
private storageSizeCache;
|
|
14
|
+
private readonly MAX_TIMESTAMPS;
|
|
15
|
+
private readonly MAX_SEARCH_TERMS;
|
|
16
|
+
private readonly SIZE_UPDATE_INTERVAL;
|
|
17
|
+
/**
|
|
18
|
+
* Track content type (very lightweight)
|
|
19
|
+
*/
|
|
20
|
+
trackContentType(type: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Track data update timestamp (lightweight)
|
|
23
|
+
*/
|
|
24
|
+
trackUpdate(timestamp?: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Track search performance (lightweight)
|
|
27
|
+
*/
|
|
28
|
+
trackSearch(searchTerm: string, durationMs: number): void;
|
|
29
|
+
/**
|
|
30
|
+
* Track verb type (lightweight)
|
|
31
|
+
*/
|
|
32
|
+
trackVerbType(type: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Update storage size estimates (called periodically, not on every operation)
|
|
35
|
+
*/
|
|
36
|
+
updateStorageSizes(sizes: {
|
|
37
|
+
nouns: number;
|
|
38
|
+
verbs: number;
|
|
39
|
+
metadata: number;
|
|
40
|
+
index: number;
|
|
41
|
+
}): void;
|
|
42
|
+
/**
|
|
43
|
+
* Get comprehensive statistics
|
|
44
|
+
*/
|
|
45
|
+
getStatistics(): Partial<StatisticsData>;
|
|
46
|
+
/**
|
|
47
|
+
* Merge statistics from storage (for distributed systems)
|
|
48
|
+
*/
|
|
49
|
+
mergeFromStorage(stored: Partial<StatisticsData>): void;
|
|
50
|
+
/**
|
|
51
|
+
* Reset statistics (for testing)
|
|
52
|
+
*/
|
|
53
|
+
reset(): void;
|
|
54
|
+
private pruneSearchTerms;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statisticsCollector.d.ts","sourceRoot":"","sources":["../../src/utils/statisticsCollector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAOhD,qBAAa,mBAAmB;IAE9B,OAAO,CAAC,YAAY,CAAiC;IAGrD,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,gBAAgB,CAAuB;IAG/C,OAAO,CAAC,aAAa,CAKpB;IAGD,OAAO,CAAC,SAAS,CAAiC;IAGlD,OAAO,CAAC,gBAAgB,CAQvB;IAED,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAO;IACtC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAM;IACvC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAQ;IAE7C;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIpC;;OAEG;IACH,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAgBrC;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAyBzD;;OAEG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIjC;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE;QACxB,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,MAAM,CAAA;QACb,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;KACd,GAAG,IAAI;IAOR;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,cAAc,CAAC;IAmFxC;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;IA4BvD;;OAEG;IACH,KAAK,IAAI,IAAI;IAcb,OAAO,CAAC,gBAAgB;CAWzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "A vector graph database using HNSW indexing with Origin Private File System storage",
|
|
5
5
|
"main": "dist/unified.js",
|
|
6
6
|
"module": "dist/unified.js",
|
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=24.4.0"
|
|
50
50
|
},
|
|
51
|
+
"overrides": {
|
|
52
|
+
"form-data": "^4.0.4"
|
|
53
|
+
},
|
|
51
54
|
"scripts": {
|
|
52
55
|
"prebuild": "echo 'Prebuild step - no version generation needed'",
|
|
53
56
|
"build": "BUILD_TYPE=unified rollup -c rollup.config.js",
|