@danielsimonjr/memoryjs 1.0.0 → 1.1.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 +385 -113
- package/README.md.backup-1768084780988 +266 -0
- package/dist/index.cjs +17364 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12371 -0
- package/dist/index.d.ts +12367 -11
- package/dist/index.js +17102 -19
- package/dist/index.js.map +1 -1
- package/dist/workers/levenshteinWorker.cjs +102 -0
- package/dist/workers/levenshteinWorker.cjs.map +1 -0
- package/dist/workers/levenshteinWorker.js +57 -91
- package/dist/workers/levenshteinWorker.js.map +1 -1
- package/package.json +12 -6
- package/dist/core/EntityManager.d.ts +0 -268
- package/dist/core/EntityManager.d.ts.map +0 -1
- package/dist/core/EntityManager.js +0 -512
- package/dist/core/EntityManager.js.map +0 -1
- package/dist/core/GraphEventEmitter.d.ts +0 -202
- package/dist/core/GraphEventEmitter.d.ts.map +0 -1
- package/dist/core/GraphEventEmitter.js +0 -347
- package/dist/core/GraphEventEmitter.js.map +0 -1
- package/dist/core/GraphStorage.d.ts +0 -395
- package/dist/core/GraphStorage.d.ts.map +0 -1
- package/dist/core/GraphStorage.js +0 -786
- package/dist/core/GraphStorage.js.map +0 -1
- package/dist/core/GraphTraversal.d.ts +0 -141
- package/dist/core/GraphTraversal.d.ts.map +0 -1
- package/dist/core/GraphTraversal.js +0 -574
- package/dist/core/GraphTraversal.js.map +0 -1
- package/dist/core/HierarchyManager.d.ts +0 -111
- package/dist/core/HierarchyManager.d.ts.map +0 -1
- package/dist/core/HierarchyManager.js +0 -225
- package/dist/core/HierarchyManager.js.map +0 -1
- package/dist/core/ManagerContext.d.ts +0 -76
- package/dist/core/ManagerContext.d.ts.map +0 -1
- package/dist/core/ManagerContext.js +0 -129
- package/dist/core/ManagerContext.js.map +0 -1
- package/dist/core/ObservationManager.d.ts +0 -85
- package/dist/core/ObservationManager.d.ts.map +0 -1
- package/dist/core/ObservationManager.js +0 -124
- package/dist/core/ObservationManager.js.map +0 -1
- package/dist/core/RelationManager.d.ts +0 -131
- package/dist/core/RelationManager.d.ts.map +0 -1
- package/dist/core/RelationManager.js +0 -212
- package/dist/core/RelationManager.js.map +0 -1
- package/dist/core/SQLiteStorage.d.ts +0 -354
- package/dist/core/SQLiteStorage.d.ts.map +0 -1
- package/dist/core/SQLiteStorage.js +0 -919
- package/dist/core/SQLiteStorage.js.map +0 -1
- package/dist/core/StorageFactory.d.ts +0 -45
- package/dist/core/StorageFactory.d.ts.map +0 -1
- package/dist/core/StorageFactory.js +0 -65
- package/dist/core/StorageFactory.js.map +0 -1
- package/dist/core/TransactionManager.d.ts +0 -464
- package/dist/core/TransactionManager.d.ts.map +0 -1
- package/dist/core/TransactionManager.js +0 -869
- package/dist/core/TransactionManager.js.map +0 -1
- package/dist/core/index.d.ts +0 -17
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -20
- package/dist/core/index.js.map +0 -1
- package/dist/features/AnalyticsManager.d.ts +0 -44
- package/dist/features/AnalyticsManager.d.ts.map +0 -1
- package/dist/features/AnalyticsManager.js +0 -224
- package/dist/features/AnalyticsManager.js.map +0 -1
- package/dist/features/ArchiveManager.d.ts +0 -133
- package/dist/features/ArchiveManager.d.ts.map +0 -1
- package/dist/features/ArchiveManager.js +0 -282
- package/dist/features/ArchiveManager.js.map +0 -1
- package/dist/features/CompressionManager.d.ts +0 -119
- package/dist/features/CompressionManager.d.ts.map +0 -1
- package/dist/features/CompressionManager.js +0 -470
- package/dist/features/CompressionManager.js.map +0 -1
- package/dist/features/IOManager.d.ts +0 -225
- package/dist/features/IOManager.d.ts.map +0 -1
- package/dist/features/IOManager.js +0 -1093
- package/dist/features/IOManager.js.map +0 -1
- package/dist/features/KeywordExtractor.d.ts +0 -61
- package/dist/features/KeywordExtractor.d.ts.map +0 -1
- package/dist/features/KeywordExtractor.js +0 -127
- package/dist/features/KeywordExtractor.js.map +0 -1
- package/dist/features/ObservationNormalizer.d.ts +0 -90
- package/dist/features/ObservationNormalizer.d.ts.map +0 -1
- package/dist/features/ObservationNormalizer.js +0 -194
- package/dist/features/ObservationNormalizer.js.map +0 -1
- package/dist/features/StreamingExporter.d.ts +0 -128
- package/dist/features/StreamingExporter.d.ts.map +0 -1
- package/dist/features/StreamingExporter.js +0 -212
- package/dist/features/StreamingExporter.js.map +0 -1
- package/dist/features/TagManager.d.ts +0 -147
- package/dist/features/TagManager.d.ts.map +0 -1
- package/dist/features/TagManager.js +0 -211
- package/dist/features/TagManager.js.map +0 -1
- package/dist/features/index.d.ts +0 -14
- package/dist/features/index.d.ts.map +0 -1
- package/dist/features/index.js +0 -15
- package/dist/features/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/search/BM25Search.d.ts +0 -148
- package/dist/search/BM25Search.d.ts.map +0 -1
- package/dist/search/BM25Search.js +0 -340
- package/dist/search/BM25Search.js.map +0 -1
- package/dist/search/BasicSearch.d.ts +0 -51
- package/dist/search/BasicSearch.d.ts.map +0 -1
- package/dist/search/BasicSearch.js +0 -138
- package/dist/search/BasicSearch.js.map +0 -1
- package/dist/search/BooleanSearch.d.ts +0 -98
- package/dist/search/BooleanSearch.d.ts.map +0 -1
- package/dist/search/BooleanSearch.js +0 -431
- package/dist/search/BooleanSearch.js.map +0 -1
- package/dist/search/EarlyTerminationManager.d.ts +0 -140
- package/dist/search/EarlyTerminationManager.d.ts.map +0 -1
- package/dist/search/EarlyTerminationManager.js +0 -280
- package/dist/search/EarlyTerminationManager.js.map +0 -1
- package/dist/search/EmbeddingCache.d.ts +0 -175
- package/dist/search/EmbeddingCache.d.ts.map +0 -1
- package/dist/search/EmbeddingCache.js +0 -247
- package/dist/search/EmbeddingCache.js.map +0 -1
- package/dist/search/EmbeddingService.d.ts +0 -277
- package/dist/search/EmbeddingService.d.ts.map +0 -1
- package/dist/search/EmbeddingService.js +0 -531
- package/dist/search/EmbeddingService.js.map +0 -1
- package/dist/search/FuzzySearch.d.ts +0 -118
- package/dist/search/FuzzySearch.d.ts.map +0 -1
- package/dist/search/FuzzySearch.js +0 -313
- package/dist/search/FuzzySearch.js.map +0 -1
- package/dist/search/HybridScorer.d.ts +0 -181
- package/dist/search/HybridScorer.d.ts.map +0 -1
- package/dist/search/HybridScorer.js +0 -258
- package/dist/search/HybridScorer.js.map +0 -1
- package/dist/search/HybridSearchManager.d.ts +0 -80
- package/dist/search/HybridSearchManager.d.ts.map +0 -1
- package/dist/search/HybridSearchManager.js +0 -188
- package/dist/search/HybridSearchManager.js.map +0 -1
- package/dist/search/IncrementalIndexer.d.ts +0 -201
- package/dist/search/IncrementalIndexer.d.ts.map +0 -1
- package/dist/search/IncrementalIndexer.js +0 -343
- package/dist/search/IncrementalIndexer.js.map +0 -1
- package/dist/search/OptimizedInvertedIndex.d.ts +0 -163
- package/dist/search/OptimizedInvertedIndex.d.ts.map +0 -1
- package/dist/search/OptimizedInvertedIndex.js +0 -359
- package/dist/search/OptimizedInvertedIndex.js.map +0 -1
- package/dist/search/ParallelSearchExecutor.d.ts +0 -172
- package/dist/search/ParallelSearchExecutor.d.ts.map +0 -1
- package/dist/search/ParallelSearchExecutor.js +0 -310
- package/dist/search/ParallelSearchExecutor.js.map +0 -1
- package/dist/search/QuantizedVectorStore.d.ts +0 -171
- package/dist/search/QuantizedVectorStore.d.ts.map +0 -1
- package/dist/search/QuantizedVectorStore.js +0 -308
- package/dist/search/QuantizedVectorStore.js.map +0 -1
- package/dist/search/QueryAnalyzer.d.ts +0 -76
- package/dist/search/QueryAnalyzer.d.ts.map +0 -1
- package/dist/search/QueryAnalyzer.js +0 -228
- package/dist/search/QueryAnalyzer.js.map +0 -1
- package/dist/search/QueryCostEstimator.d.ts +0 -244
- package/dist/search/QueryCostEstimator.d.ts.map +0 -1
- package/dist/search/QueryCostEstimator.js +0 -653
- package/dist/search/QueryCostEstimator.js.map +0 -1
- package/dist/search/QueryPlanCache.d.ts +0 -220
- package/dist/search/QueryPlanCache.d.ts.map +0 -1
- package/dist/search/QueryPlanCache.js +0 -380
- package/dist/search/QueryPlanCache.js.map +0 -1
- package/dist/search/QueryPlanner.d.ts +0 -58
- package/dist/search/QueryPlanner.d.ts.map +0 -1
- package/dist/search/QueryPlanner.js +0 -138
- package/dist/search/QueryPlanner.js.map +0 -1
- package/dist/search/RankedSearch.d.ts +0 -71
- package/dist/search/RankedSearch.d.ts.map +0 -1
- package/dist/search/RankedSearch.js +0 -239
- package/dist/search/RankedSearch.js.map +0 -1
- package/dist/search/ReflectionManager.d.ts +0 -120
- package/dist/search/ReflectionManager.d.ts.map +0 -1
- package/dist/search/ReflectionManager.js +0 -232
- package/dist/search/ReflectionManager.js.map +0 -1
- package/dist/search/SavedSearchManager.d.ts +0 -79
- package/dist/search/SavedSearchManager.d.ts.map +0 -1
- package/dist/search/SavedSearchManager.js +0 -147
- package/dist/search/SavedSearchManager.js.map +0 -1
- package/dist/search/SearchFilterChain.d.ts +0 -120
- package/dist/search/SearchFilterChain.d.ts.map +0 -1
- package/dist/search/SearchFilterChain.js +0 -186
- package/dist/search/SearchFilterChain.js.map +0 -1
- package/dist/search/SearchManager.d.ts +0 -326
- package/dist/search/SearchManager.d.ts.map +0 -1
- package/dist/search/SearchManager.js +0 -454
- package/dist/search/SearchManager.js.map +0 -1
- package/dist/search/SearchSuggestions.d.ts +0 -27
- package/dist/search/SearchSuggestions.d.ts.map +0 -1
- package/dist/search/SearchSuggestions.js +0 -58
- package/dist/search/SearchSuggestions.js.map +0 -1
- package/dist/search/SemanticSearch.d.ts +0 -149
- package/dist/search/SemanticSearch.d.ts.map +0 -1
- package/dist/search/SemanticSearch.js +0 -324
- package/dist/search/SemanticSearch.js.map +0 -1
- package/dist/search/SymbolicSearch.d.ts +0 -61
- package/dist/search/SymbolicSearch.d.ts.map +0 -1
- package/dist/search/SymbolicSearch.js +0 -164
- package/dist/search/SymbolicSearch.js.map +0 -1
- package/dist/search/TFIDFEventSync.d.ts +0 -85
- package/dist/search/TFIDFEventSync.d.ts.map +0 -1
- package/dist/search/TFIDFEventSync.js +0 -134
- package/dist/search/TFIDFEventSync.js.map +0 -1
- package/dist/search/TFIDFIndexManager.d.ts +0 -151
- package/dist/search/TFIDFIndexManager.d.ts.map +0 -1
- package/dist/search/TFIDFIndexManager.js +0 -433
- package/dist/search/TFIDFIndexManager.js.map +0 -1
- package/dist/search/VectorStore.d.ts +0 -235
- package/dist/search/VectorStore.d.ts.map +0 -1
- package/dist/search/VectorStore.js +0 -312
- package/dist/search/VectorStore.js.map +0 -1
- package/dist/search/index.d.ts +0 -35
- package/dist/search/index.d.ts.map +0 -1
- package/dist/search/index.js +0 -53
- package/dist/search/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -13
- package/dist/types/index.js.map +0 -1
- package/dist/types/types.d.ts +0 -1811
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js +0 -10
- package/dist/types/types.js.map +0 -1
- package/dist/utils/BatchProcessor.d.ts +0 -271
- package/dist/utils/BatchProcessor.d.ts.map +0 -1
- package/dist/utils/BatchProcessor.js +0 -377
- package/dist/utils/BatchProcessor.js.map +0 -1
- package/dist/utils/MemoryMonitor.d.ts +0 -176
- package/dist/utils/MemoryMonitor.d.ts.map +0 -1
- package/dist/utils/MemoryMonitor.js +0 -306
- package/dist/utils/MemoryMonitor.js.map +0 -1
- package/dist/utils/WorkerPoolManager.d.ts +0 -233
- package/dist/utils/WorkerPoolManager.d.ts.map +0 -1
- package/dist/utils/WorkerPoolManager.js +0 -421
- package/dist/utils/WorkerPoolManager.js.map +0 -1
- package/dist/utils/compressedCache.d.ts +0 -221
- package/dist/utils/compressedCache.d.ts.map +0 -1
- package/dist/utils/compressedCache.js +0 -349
- package/dist/utils/compressedCache.js.map +0 -1
- package/dist/utils/compressionUtil.d.ts +0 -214
- package/dist/utils/compressionUtil.d.ts.map +0 -1
- package/dist/utils/compressionUtil.js +0 -248
- package/dist/utils/compressionUtil.js.map +0 -1
- package/dist/utils/constants.d.ts +0 -245
- package/dist/utils/constants.d.ts.map +0 -1
- package/dist/utils/constants.js +0 -253
- package/dist/utils/constants.js.map +0 -1
- package/dist/utils/entityUtils.d.ts +0 -379
- package/dist/utils/entityUtils.d.ts.map +0 -1
- package/dist/utils/entityUtils.js +0 -649
- package/dist/utils/entityUtils.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -95
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -146
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/formatters.d.ts +0 -145
- package/dist/utils/formatters.d.ts.map +0 -1
- package/dist/utils/formatters.js +0 -133
- package/dist/utils/formatters.js.map +0 -1
- package/dist/utils/index.d.ts +0 -26
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -88
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/indexes.d.ts +0 -270
- package/dist/utils/indexes.d.ts.map +0 -1
- package/dist/utils/indexes.js +0 -527
- package/dist/utils/indexes.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -31
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -41
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/operationUtils.d.ts +0 -124
- package/dist/utils/operationUtils.d.ts.map +0 -1
- package/dist/utils/operationUtils.js +0 -176
- package/dist/utils/operationUtils.js.map +0 -1
- package/dist/utils/parallelUtils.d.ts +0 -76
- package/dist/utils/parallelUtils.d.ts.map +0 -1
- package/dist/utils/parallelUtils.js +0 -192
- package/dist/utils/parallelUtils.js.map +0 -1
- package/dist/utils/schemas.d.ts +0 -556
- package/dist/utils/schemas.d.ts.map +0 -1
- package/dist/utils/schemas.js +0 -485
- package/dist/utils/schemas.js.map +0 -1
- package/dist/utils/searchAlgorithms.d.ts +0 -99
- package/dist/utils/searchAlgorithms.d.ts.map +0 -1
- package/dist/utils/searchAlgorithms.js +0 -168
- package/dist/utils/searchAlgorithms.js.map +0 -1
- package/dist/utils/searchCache.d.ts +0 -108
- package/dist/utils/searchCache.d.ts.map +0 -1
- package/dist/utils/searchCache.js +0 -210
- package/dist/utils/searchCache.js.map +0 -1
- package/dist/utils/taskScheduler.d.ts +0 -294
- package/dist/utils/taskScheduler.d.ts.map +0 -1
- package/dist/utils/taskScheduler.js +0 -487
- package/dist/utils/taskScheduler.js.map +0 -1
- package/dist/workers/index.d.ts +0 -12
- package/dist/workers/index.d.ts.map +0 -1
- package/dist/workers/index.js +0 -10
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/levenshteinWorker.d.ts +0 -60
- package/dist/workers/levenshteinWorker.d.ts.map +0 -1
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compression Utility Module
|
|
3
|
-
*
|
|
4
|
-
* Provides brotli compression and decompression utilities using Node.js
|
|
5
|
-
* built-in zlib module. No external dependencies required.
|
|
6
|
-
*
|
|
7
|
-
* Brotli offers 15-20% better compression than gzip, with 60-75%
|
|
8
|
-
* compression typical for JSON data.
|
|
9
|
-
*
|
|
10
|
-
* @module utils/compressionUtil
|
|
11
|
-
*/
|
|
12
|
-
import { brotliCompress, brotliDecompress, constants } from 'zlib';
|
|
13
|
-
import { promisify } from 'util';
|
|
14
|
-
import { promises as fs } from 'fs';
|
|
15
|
-
import { COMPRESSION_CONFIG } from './constants.js';
|
|
16
|
-
// Promisify Node.js zlib functions for async/await usage
|
|
17
|
-
const compressAsync = promisify(brotliCompress);
|
|
18
|
-
const decompressAsync = promisify(brotliDecompress);
|
|
19
|
-
/**
|
|
20
|
-
* Check if a file path indicates brotli compression based on extension.
|
|
21
|
-
*
|
|
22
|
-
* Note: Brotli doesn't have reliable magic bytes for detection.
|
|
23
|
-
* Using file extension (.br) is the recommended detection method.
|
|
24
|
-
*
|
|
25
|
-
* @param filePath - The file path to check
|
|
26
|
-
* @returns True if the path ends with .br extension
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* hasBrotliExtension('backup.jsonl.br') // true
|
|
31
|
-
* hasBrotliExtension('backup.jsonl') // false
|
|
32
|
-
* hasBrotliExtension('data.json') // false
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export function hasBrotliExtension(filePath) {
|
|
36
|
-
return filePath.endsWith(COMPRESSION_CONFIG.BROTLI_EXTENSION);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Compress data using brotli algorithm.
|
|
40
|
-
*
|
|
41
|
-
* @param data - The data to compress (string or Buffer)
|
|
42
|
-
* @param options - Compression options
|
|
43
|
-
* @returns Compression result with compressed data and statistics
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* const jsonData = JSON.stringify({ entities: [...] });
|
|
48
|
-
* const result = await compress(jsonData, { quality: 11 });
|
|
49
|
-
* console.log(`Compressed from ${result.originalSize} to ${result.compressedSize} bytes`);
|
|
50
|
-
* console.log(`Compression ratio: ${(result.ratio * 100).toFixed(1)}%`);
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
export async function compress(data, options = {}) {
|
|
54
|
-
const input = Buffer.isBuffer(data) ? data : Buffer.from(data, 'utf-8');
|
|
55
|
-
const quality = options.quality ?? COMPRESSION_CONFIG.BROTLI_QUALITY_BATCH;
|
|
56
|
-
// Validate quality range
|
|
57
|
-
if (quality < 0 || quality > 11) {
|
|
58
|
-
throw new Error(`Invalid brotli quality level: ${quality}. Must be 0-11.`);
|
|
59
|
-
}
|
|
60
|
-
const zlibOptions = {
|
|
61
|
-
params: {
|
|
62
|
-
[constants.BROTLI_PARAM_QUALITY]: quality,
|
|
63
|
-
[constants.BROTLI_PARAM_MODE]: options.mode === 'text'
|
|
64
|
-
? constants.BROTLI_MODE_TEXT
|
|
65
|
-
: constants.BROTLI_MODE_GENERIC,
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
if (options.lgwin !== undefined) {
|
|
69
|
-
if (options.lgwin < 10 || options.lgwin > 24) {
|
|
70
|
-
throw new Error(`Invalid brotli window size: ${options.lgwin}. Must be 10-24.`);
|
|
71
|
-
}
|
|
72
|
-
zlibOptions.params[constants.BROTLI_PARAM_LGWIN] = options.lgwin;
|
|
73
|
-
}
|
|
74
|
-
const compressed = await compressAsync(input, zlibOptions);
|
|
75
|
-
return {
|
|
76
|
-
compressed,
|
|
77
|
-
originalSize: input.length,
|
|
78
|
-
compressedSize: compressed.length,
|
|
79
|
-
ratio: input.length > 0 ? compressed.length / input.length : 1,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Decompress brotli-compressed data.
|
|
84
|
-
*
|
|
85
|
-
* @param data - The compressed data as a Buffer
|
|
86
|
-
* @returns The decompressed data as a Buffer
|
|
87
|
-
* @throws Error if decompression fails (corrupt or invalid data)
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* const compressed = await fs.readFile('backup.jsonl.br');
|
|
92
|
-
* const decompressed = await decompress(compressed);
|
|
93
|
-
* const jsonData = decompressed.toString('utf-8');
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
export async function decompress(data) {
|
|
97
|
-
if (!Buffer.isBuffer(data)) {
|
|
98
|
-
throw new Error('Input must be a Buffer');
|
|
99
|
-
}
|
|
100
|
-
if (data.length === 0) {
|
|
101
|
-
return Buffer.alloc(0);
|
|
102
|
-
}
|
|
103
|
-
try {
|
|
104
|
-
return await decompressAsync(data);
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
108
|
-
throw new Error(`Brotli decompression failed: ${message}`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Calculate compression ratio.
|
|
113
|
-
*
|
|
114
|
-
* @param originalSize - Original size in bytes
|
|
115
|
-
* @param compressedSize - Compressed size in bytes
|
|
116
|
-
* @returns Ratio as a decimal (e.g., 0.25 = 75% compression)
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* ```typescript
|
|
120
|
-
* const ratio = getCompressionRatio(1000, 250);
|
|
121
|
-
* console.log(`Compression ratio: ${(1 - ratio) * 100}%`); // "Compression ratio: 75%"
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
export function getCompressionRatio(originalSize, compressedSize) {
|
|
125
|
-
if (originalSize <= 0)
|
|
126
|
-
return 1;
|
|
127
|
-
return compressedSize / originalSize;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Compress a file and write the result to disk.
|
|
131
|
-
*
|
|
132
|
-
* @param inputPath - Path to the input file
|
|
133
|
-
* @param outputPath - Path for the compressed output file
|
|
134
|
-
* @param options - Compression options
|
|
135
|
-
* @returns Compression result with statistics
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```typescript
|
|
139
|
-
* const result = await compressFile(
|
|
140
|
-
* 'memory.jsonl',
|
|
141
|
-
* 'memory.jsonl.br',
|
|
142
|
-
* { quality: 11 }
|
|
143
|
-
* );
|
|
144
|
-
* console.log(`Saved ${result.originalSize - result.compressedSize} bytes`);
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
export async function compressFile(inputPath, outputPath, options) {
|
|
148
|
-
const input = await fs.readFile(inputPath);
|
|
149
|
-
const result = await compress(input, options);
|
|
150
|
-
await fs.writeFile(outputPath, result.compressed);
|
|
151
|
-
return result;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Decompress a file and write the result to disk.
|
|
155
|
-
*
|
|
156
|
-
* @param inputPath - Path to the compressed input file
|
|
157
|
-
* @param outputPath - Path for the decompressed output file
|
|
158
|
-
* @throws Error if file not found or decompression fails
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```typescript
|
|
162
|
-
* await decompressFile('backup.jsonl.br', 'restored.jsonl');
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
export async function decompressFile(inputPath, outputPath) {
|
|
166
|
-
const input = await fs.readFile(inputPath);
|
|
167
|
-
const decompressed = await decompress(input);
|
|
168
|
-
await fs.writeFile(outputPath, decompressed);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Create metadata object for a compression result.
|
|
172
|
-
* This metadata should be stored alongside compressed files for
|
|
173
|
-
* integrity verification and restoration.
|
|
174
|
-
*
|
|
175
|
-
* @param result - The compression result
|
|
176
|
-
* @param checksum - Optional checksum of the original data
|
|
177
|
-
* @returns Compression metadata object
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```typescript
|
|
181
|
-
* const result = await compress(data);
|
|
182
|
-
* const metadata = createMetadata(result);
|
|
183
|
-
* await fs.writeFile('backup.meta.json', JSON.stringify(metadata, null, 2));
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
|
-
export function createMetadata(result, checksum) {
|
|
187
|
-
return {
|
|
188
|
-
compressed: true,
|
|
189
|
-
compressionFormat: 'brotli',
|
|
190
|
-
originalSize: result.originalSize,
|
|
191
|
-
compressedSize: result.compressedSize,
|
|
192
|
-
originalChecksum: checksum,
|
|
193
|
-
createdAt: new Date().toISOString(),
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Create metadata for uncompressed data.
|
|
198
|
-
* Useful for consistent metadata format when compression is disabled.
|
|
199
|
-
*
|
|
200
|
-
* @param size - Size of the data in bytes
|
|
201
|
-
* @returns Compression metadata indicating no compression
|
|
202
|
-
*/
|
|
203
|
-
export function createUncompressedMetadata(size) {
|
|
204
|
-
return {
|
|
205
|
-
compressed: false,
|
|
206
|
-
compressionFormat: 'none',
|
|
207
|
-
originalSize: size,
|
|
208
|
-
compressedSize: size,
|
|
209
|
-
createdAt: new Date().toISOString(),
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Compress a string and return base64-encoded result.
|
|
214
|
-
* Useful for embedding compressed data in JSON responses.
|
|
215
|
-
*
|
|
216
|
-
* @param data - String data to compress
|
|
217
|
-
* @param options - Compression options
|
|
218
|
-
* @returns Base64-encoded compressed data
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* ```typescript
|
|
222
|
-
* const encoded = await compressToBase64(jsonString);
|
|
223
|
-
* // Send in response: { compressed: true, data: encoded }
|
|
224
|
-
* ```
|
|
225
|
-
*/
|
|
226
|
-
export async function compressToBase64(data, options) {
|
|
227
|
-
const result = await compress(data, options);
|
|
228
|
-
return result.compressed.toString('base64');
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Decompress base64-encoded compressed data.
|
|
232
|
-
* Counterpart to compressToBase64.
|
|
233
|
-
*
|
|
234
|
-
* @param base64Data - Base64-encoded compressed data
|
|
235
|
-
* @returns Decompressed string
|
|
236
|
-
*
|
|
237
|
-
* @example
|
|
238
|
-
* ```typescript
|
|
239
|
-
* const original = await decompressFromBase64(response.data);
|
|
240
|
-
* const parsed = JSON.parse(original);
|
|
241
|
-
* ```
|
|
242
|
-
*/
|
|
243
|
-
export async function decompressFromBase64(base64Data) {
|
|
244
|
-
const buffer = Buffer.from(base64Data, 'base64');
|
|
245
|
-
const decompressed = await decompress(buffer);
|
|
246
|
-
return decompressed.toString('utf-8');
|
|
247
|
-
}
|
|
248
|
-
//# sourceMappingURL=compressionUtil.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compressionUtil.js","sourceRoot":"","sources":["../../src/utils/compressionUtil.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB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E,CAAC,WAAW,EAAE;KACpC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAY,EACZ,OAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,UAAkB;IAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjD,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9C,OAAO,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Application Constants
|
|
3
|
-
*
|
|
4
|
-
* Centralized configuration constants for file paths, extensions, and default values.
|
|
5
|
-
*
|
|
6
|
-
* @module utils/constants
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* File extensions used by the memory system.
|
|
10
|
-
*/
|
|
11
|
-
export declare const FILE_EXTENSIONS: {
|
|
12
|
-
/** JSONL format for line-delimited JSON storage */
|
|
13
|
-
readonly JSONL: ".jsonl";
|
|
14
|
-
/** Legacy JSON format (backward compatibility) */
|
|
15
|
-
readonly JSON: ".json";
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* File name suffixes for auxiliary data files.
|
|
19
|
-
* These suffixes are appended to the base memory file name.
|
|
20
|
-
*/
|
|
21
|
-
export declare const FILE_SUFFIXES: {
|
|
22
|
-
/** Suffix for saved searches file */
|
|
23
|
-
readonly SAVED_SEARCHES: "-saved-searches";
|
|
24
|
-
/** Suffix for tag aliases file */
|
|
25
|
-
readonly TAG_ALIASES: "-tag-aliases";
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Default file names used by the memory system.
|
|
29
|
-
*/
|
|
30
|
-
export declare const DEFAULT_FILE_NAMES: {
|
|
31
|
-
/** Default memory file name */
|
|
32
|
-
readonly MEMORY: "memory";
|
|
33
|
-
/** Legacy memory file name (for backward compatibility) */
|
|
34
|
-
readonly MEMORY_LEGACY: "memory";
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Environment variable names used for configuration.
|
|
38
|
-
*/
|
|
39
|
-
export declare const ENV_VARS: {
|
|
40
|
-
/** Environment variable for custom memory file path */
|
|
41
|
-
readonly MEMORY_FILE_PATH: "MEMORY_FILE_PATH";
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Default base directory relative to the compiled code.
|
|
45
|
-
*/
|
|
46
|
-
export declare const DEFAULT_BASE_DIR = "../";
|
|
47
|
-
/**
|
|
48
|
-
* Log message prefixes for consistent logging.
|
|
49
|
-
*/
|
|
50
|
-
export declare const LOG_PREFIXES: {
|
|
51
|
-
/** Informational message prefix */
|
|
52
|
-
readonly INFO: "[INFO]";
|
|
53
|
-
/** Error message prefix */
|
|
54
|
-
readonly ERROR: "[ERROR]";
|
|
55
|
-
/** Warning message prefix */
|
|
56
|
-
readonly WARN: "[WARN]";
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Similarity scoring weights for duplicate detection.
|
|
60
|
-
* These weights determine the relative importance of each factor
|
|
61
|
-
* when calculating entity similarity for duplicate detection.
|
|
62
|
-
* Total weights must sum to 1.0 (100%).
|
|
63
|
-
*/
|
|
64
|
-
export declare const SIMILARITY_WEIGHTS: {
|
|
65
|
-
/** Name similarity weight (40%) - Uses Levenshtein distance */
|
|
66
|
-
readonly NAME: 0.4;
|
|
67
|
-
/** Entity type match weight (20%) - Exact match required */
|
|
68
|
-
readonly TYPE: 0.2;
|
|
69
|
-
/** Observation overlap weight (30%) - Uses Jaccard similarity */
|
|
70
|
-
readonly OBSERVATIONS: 0.3;
|
|
71
|
-
/** Tag overlap weight (10%) - Uses Jaccard similarity */
|
|
72
|
-
readonly TAGS: 0.1;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Default threshold for duplicate detection (80% similarity required).
|
|
76
|
-
*/
|
|
77
|
-
export declare const DEFAULT_DUPLICATE_THRESHOLD = 0.8;
|
|
78
|
-
/**
|
|
79
|
-
* Search result limits to prevent resource exhaustion.
|
|
80
|
-
*/
|
|
81
|
-
export declare const SEARCH_LIMITS: {
|
|
82
|
-
/** Default number of results to return */
|
|
83
|
-
readonly DEFAULT: 50;
|
|
84
|
-
/** Maximum number of results allowed */
|
|
85
|
-
readonly MAX: 200;
|
|
86
|
-
/** Minimum number of results (must be at least 1) */
|
|
87
|
-
readonly MIN: 1;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Entity importance range validation constants.
|
|
91
|
-
* Importance is used to prioritize entities (0 = lowest, 10 = highest).
|
|
92
|
-
*/
|
|
93
|
-
export declare const IMPORTANCE_RANGE: {
|
|
94
|
-
/** Minimum importance value */
|
|
95
|
-
readonly MIN: 0;
|
|
96
|
-
/** Maximum importance value */
|
|
97
|
-
readonly MAX: 10;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Graph size limits to prevent resource exhaustion and ensure performance.
|
|
101
|
-
* These limits help maintain system stability and responsiveness.
|
|
102
|
-
*/
|
|
103
|
-
export declare const GRAPH_LIMITS: {
|
|
104
|
-
/** Maximum number of entities in the graph */
|
|
105
|
-
readonly MAX_ENTITIES: 100000;
|
|
106
|
-
/** Maximum number of relations in the graph */
|
|
107
|
-
readonly MAX_RELATIONS: 1000000;
|
|
108
|
-
/** Maximum graph file size in megabytes */
|
|
109
|
-
readonly MAX_FILE_SIZE_MB: 500;
|
|
110
|
-
/** Maximum observations per entity */
|
|
111
|
-
readonly MAX_OBSERVATIONS_PER_ENTITY: 1000;
|
|
112
|
-
/** Maximum tags per entity */
|
|
113
|
-
readonly MAX_TAGS_PER_ENTITY: 100;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Query complexity limits to prevent expensive query operations.
|
|
117
|
-
* These limits protect against denial-of-service through complex queries.
|
|
118
|
-
*/
|
|
119
|
-
export declare const QUERY_LIMITS: {
|
|
120
|
-
/** Maximum nesting depth for boolean queries */
|
|
121
|
-
readonly MAX_DEPTH: 10;
|
|
122
|
-
/** Maximum number of terms in a single query */
|
|
123
|
-
readonly MAX_TERMS: 50;
|
|
124
|
-
/** Maximum number of boolean operators (AND/OR/NOT) */
|
|
125
|
-
readonly MAX_OPERATORS: 20;
|
|
126
|
-
/** Maximum query string length */
|
|
127
|
-
readonly MAX_QUERY_LENGTH: 5000;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Brotli compression configuration constants.
|
|
131
|
-
* Brotli is built into Node.js >=11.7.0 via the zlib module.
|
|
132
|
-
* No external dependencies required.
|
|
133
|
-
*
|
|
134
|
-
* Quality levels determine compression ratio vs speed tradeoff:
|
|
135
|
-
* - Lower values (0-4): Faster compression, lower ratio
|
|
136
|
-
* - Higher values (9-11): Slower compression, higher ratio
|
|
137
|
-
*/
|
|
138
|
-
export declare const COMPRESSION_CONFIG: {
|
|
139
|
-
/** Fast compression for real-time entity writes (quality 4) */
|
|
140
|
-
readonly BROTLI_QUALITY_REALTIME: 4;
|
|
141
|
-
/** Balanced compression for exports and imports (quality 6) */
|
|
142
|
-
readonly BROTLI_QUALITY_BATCH: 6;
|
|
143
|
-
/** Maximum compression for backups and archives (quality 11) */
|
|
144
|
-
readonly BROTLI_QUALITY_ARCHIVE: 11;
|
|
145
|
-
/** Fast decompress for cache compression (quality 5) */
|
|
146
|
-
readonly BROTLI_QUALITY_CACHE: 5;
|
|
147
|
-
/** Auto-compress exports larger than 100KB */
|
|
148
|
-
readonly AUTO_COMPRESS_EXPORT_SIZE: number;
|
|
149
|
-
/** Auto-compress MCP responses larger than 256KB */
|
|
150
|
-
readonly AUTO_COMPRESS_RESPONSE_SIZE: number;
|
|
151
|
-
/** Always compress backups by default */
|
|
152
|
-
readonly AUTO_COMPRESS_BACKUP: true;
|
|
153
|
-
/** Brotli compressed file extension */
|
|
154
|
-
readonly BROTLI_EXTENSION: ".br";
|
|
155
|
-
/** Chunk size for streaming compression (64KB) */
|
|
156
|
-
readonly COMPRESSION_CHUNK_SIZE: 65536;
|
|
157
|
-
/** Default window size for brotli (lgwin parameter) */
|
|
158
|
-
readonly COMPRESSION_WINDOW_SIZE: 22;
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* Type representing valid brotli quality levels used in the application.
|
|
162
|
-
*/
|
|
163
|
-
export type CompressionQuality = typeof COMPRESSION_CONFIG.BROTLI_QUALITY_REALTIME | typeof COMPRESSION_CONFIG.BROTLI_QUALITY_BATCH | typeof COMPRESSION_CONFIG.BROTLI_QUALITY_ARCHIVE | typeof COMPRESSION_CONFIG.BROTLI_QUALITY_CACHE;
|
|
164
|
-
/**
|
|
165
|
-
* Environment variable names for embedding configuration.
|
|
166
|
-
*/
|
|
167
|
-
export declare const EMBEDDING_ENV_VARS: {
|
|
168
|
-
/** Embedding provider: 'openai', 'local', or 'none' (default: 'none') */
|
|
169
|
-
readonly PROVIDER: "MEMORY_EMBEDDING_PROVIDER";
|
|
170
|
-
/** OpenAI API key (required when provider is 'openai') */
|
|
171
|
-
readonly OPENAI_API_KEY: "MEMORY_OPENAI_API_KEY";
|
|
172
|
-
/** Optional model override for the embedding service */
|
|
173
|
-
readonly MODEL: "MEMORY_EMBEDDING_MODEL";
|
|
174
|
-
/** Auto-index entities on creation: 'true' or 'false' (default: 'false') */
|
|
175
|
-
readonly AUTO_INDEX: "MEMORY_AUTO_INDEX_EMBEDDINGS";
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Default embedding configuration values.
|
|
179
|
-
*/
|
|
180
|
-
export declare const EMBEDDING_DEFAULTS: {
|
|
181
|
-
/** Default provider (disabled by default) */
|
|
182
|
-
readonly PROVIDER: "none";
|
|
183
|
-
/** Default OpenAI model for embeddings (1536 dimensions) */
|
|
184
|
-
readonly OPENAI_MODEL: "text-embedding-3-small";
|
|
185
|
-
/** Default local model for embeddings (384 dimensions) */
|
|
186
|
-
readonly LOCAL_MODEL: "Xenova/all-MiniLM-L6-v2";
|
|
187
|
-
/** OpenAI embedding dimensions for text-embedding-3-small */
|
|
188
|
-
readonly OPENAI_DIMENSIONS: 1536;
|
|
189
|
-
/** Local embedding dimensions for all-MiniLM-L6-v2 */
|
|
190
|
-
readonly LOCAL_DIMENSIONS: 384;
|
|
191
|
-
/** Maximum texts per batch for OpenAI */
|
|
192
|
-
readonly OPENAI_MAX_BATCH_SIZE: 2048;
|
|
193
|
-
/** Default batch size for embedding operations */
|
|
194
|
-
readonly DEFAULT_BATCH_SIZE: 100;
|
|
195
|
-
/** Whether to auto-index entities by default */
|
|
196
|
-
readonly AUTO_INDEX: false;
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Semantic search configuration limits.
|
|
200
|
-
*/
|
|
201
|
-
export declare const SEMANTIC_SEARCH_LIMITS: {
|
|
202
|
-
/** Default number of results for semantic search */
|
|
203
|
-
readonly DEFAULT_LIMIT: 10;
|
|
204
|
-
/** Maximum number of results for semantic search */
|
|
205
|
-
readonly MAX_LIMIT: 100;
|
|
206
|
-
/** Minimum similarity score for results (0.0-1.0) */
|
|
207
|
-
readonly MIN_SIMILARITY: 0;
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* OpenAI API configuration.
|
|
211
|
-
*/
|
|
212
|
-
export declare const OPENAI_API_CONFIG: {
|
|
213
|
-
BASE_URL: string;
|
|
214
|
-
EMBEDDINGS_ENDPOINT: string;
|
|
215
|
-
MAX_RETRIES: number;
|
|
216
|
-
INITIAL_BACKOFF_MS: number;
|
|
217
|
-
MAX_BACKOFF_MS: number;
|
|
218
|
-
};
|
|
219
|
-
/**
|
|
220
|
-
* Get embedding configuration from environment variables.
|
|
221
|
-
*
|
|
222
|
-
* @returns EmbeddingConfig object with values from environment or defaults
|
|
223
|
-
*/
|
|
224
|
-
export declare function getEmbeddingConfig(): {
|
|
225
|
-
provider: 'openai' | 'local' | 'none';
|
|
226
|
-
apiKey?: string;
|
|
227
|
-
model?: string;
|
|
228
|
-
autoIndex: boolean;
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* Streaming export configuration.
|
|
232
|
-
*
|
|
233
|
-
* Controls when to use streaming mode and buffer sizes for optimal memory usage.
|
|
234
|
-
*/
|
|
235
|
-
export declare const STREAMING_CONFIG: {
|
|
236
|
-
/** Minimum entity count to trigger streaming mode */
|
|
237
|
-
readonly STREAMING_THRESHOLD: 5000;
|
|
238
|
-
/** Chunk size for batched streaming operations */
|
|
239
|
-
readonly CHUNK_SIZE: 500;
|
|
240
|
-
/** High water mark for stream buffers (bytes) */
|
|
241
|
-
readonly HIGH_WATER_MARK: number;
|
|
242
|
-
/** Flush interval for long-running streams (ms) */
|
|
243
|
-
readonly FLUSH_INTERVAL_MS: 100;
|
|
244
|
-
};
|
|
245
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B,mDAAmD;;IAEnD,kDAAkD;;CAE1C,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,aAAa;IACxB,qCAAqC;;IAErC,kCAAkC;;CAE1B,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,+BAA+B;;IAE/B,2DAA2D;;CAEnD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,QAAQ;IACnB,uDAAuD;;CAE/C,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAEtC;;GAEG;AACH,eA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