@danielsimonjr/memoryjs 1.0.0 → 1.2.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 +24156 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +16967 -0
- package/dist/index.d.ts +16963 -11
- package/dist/index.js +23887 -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 +75 -69
- 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,186 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Search Filter Chain
|
|
3
|
-
*
|
|
4
|
-
* Centralizes filter logic for all search implementations to eliminate
|
|
5
|
-
* duplicate filtering code across BasicSearch, BooleanSearch, FuzzySearch,
|
|
6
|
-
* and RankedSearch.
|
|
7
|
-
*
|
|
8
|
-
* @module search/SearchFilterChain
|
|
9
|
-
*/
|
|
10
|
-
import { normalizeTags, hasMatchingTag, isWithinImportanceRange, validatePagination, applyPagination, } from '../utils/index.js';
|
|
11
|
-
/**
|
|
12
|
-
* Centralized filter chain for all search implementations.
|
|
13
|
-
* Ensures consistent filtering behavior across search types.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const filters: SearchFilters = { tags: ['important'], minImportance: 5 };
|
|
18
|
-
* const filtered = SearchFilterChain.applyFilters(entities, filters);
|
|
19
|
-
* const pagination = SearchFilterChain.validatePagination(0, 50);
|
|
20
|
-
* const result = SearchFilterChain.paginate(filtered, pagination);
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export class SearchFilterChain {
|
|
24
|
-
/**
|
|
25
|
-
* Applies all filters to an array of entities.
|
|
26
|
-
* Entities must pass ALL specified filters to be included.
|
|
27
|
-
*
|
|
28
|
-
* @param entities - Entities to filter
|
|
29
|
-
* @param filters - Filter criteria to apply
|
|
30
|
-
* @returns Filtered entities array
|
|
31
|
-
*/
|
|
32
|
-
static applyFilters(entities, filters) {
|
|
33
|
-
// Early return if no filters are active
|
|
34
|
-
if (!this.hasActiveFilters(filters)) {
|
|
35
|
-
return [...entities];
|
|
36
|
-
}
|
|
37
|
-
// Pre-normalize tags once for efficiency
|
|
38
|
-
const normalizedSearchTags = filters.tags?.length
|
|
39
|
-
? normalizeTags(filters.tags)
|
|
40
|
-
: undefined;
|
|
41
|
-
return entities.filter(entity => this.entityPassesFilters(entity, filters, normalizedSearchTags));
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Checks if an entity passes all active filters.
|
|
45
|
-
* Short-circuits on first failing filter for performance.
|
|
46
|
-
*
|
|
47
|
-
* @param entity - Entity to check
|
|
48
|
-
* @param filters - Filter criteria
|
|
49
|
-
* @param normalizedSearchTags - Pre-normalized search tags (for efficiency)
|
|
50
|
-
* @returns true if entity passes all filters
|
|
51
|
-
*/
|
|
52
|
-
static entityPassesFilters(entity, filters, normalizedSearchTags) {
|
|
53
|
-
// Tag filter - check if entity has any matching tag
|
|
54
|
-
if (normalizedSearchTags && normalizedSearchTags.length > 0) {
|
|
55
|
-
if (!entity.tags || entity.tags.length === 0) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
const entityTags = normalizeTags(entity.tags);
|
|
59
|
-
const hasMatch = normalizedSearchTags.some(tag => entityTags.includes(tag));
|
|
60
|
-
if (!hasMatch) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// Importance filter
|
|
65
|
-
if (!isWithinImportanceRange(entity.importance, filters.minImportance, filters.maxImportance)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
// Entity type filter
|
|
69
|
-
if (filters.entityType && entity.entityType !== filters.entityType) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
// Created date filter
|
|
73
|
-
if (filters.createdAfter || filters.createdBefore) {
|
|
74
|
-
if (!entity.createdAt) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
const createdAt = new Date(entity.createdAt);
|
|
78
|
-
if (filters.createdAfter && createdAt < new Date(filters.createdAfter)) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
if (filters.createdBefore && createdAt > new Date(filters.createdBefore)) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
// Modified date filter
|
|
86
|
-
if (filters.modifiedAfter || filters.modifiedBefore) {
|
|
87
|
-
if (!entity.lastModified) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
const modifiedAt = new Date(entity.lastModified);
|
|
91
|
-
if (filters.modifiedAfter && modifiedAt < new Date(filters.modifiedAfter)) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
if (filters.modifiedBefore && modifiedAt > new Date(filters.modifiedBefore)) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Checks if any filters are actually specified.
|
|
102
|
-
* Used for early return optimization.
|
|
103
|
-
*
|
|
104
|
-
* @param filters - Filter criteria to check
|
|
105
|
-
* @returns true if at least one filter is active
|
|
106
|
-
*/
|
|
107
|
-
static hasActiveFilters(filters) {
|
|
108
|
-
return !!((filters.tags && filters.tags.length > 0) ||
|
|
109
|
-
filters.minImportance !== undefined ||
|
|
110
|
-
filters.maxImportance !== undefined ||
|
|
111
|
-
filters.entityType ||
|
|
112
|
-
filters.createdAfter ||
|
|
113
|
-
filters.createdBefore ||
|
|
114
|
-
filters.modifiedAfter ||
|
|
115
|
-
filters.modifiedBefore);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Validates and returns pagination parameters.
|
|
119
|
-
* Delegates to paginationUtils.validatePagination.
|
|
120
|
-
*
|
|
121
|
-
* @param offset - Starting position
|
|
122
|
-
* @param limit - Maximum results
|
|
123
|
-
* @returns Validated pagination object
|
|
124
|
-
*/
|
|
125
|
-
static validatePagination(offset = 0, limit) {
|
|
126
|
-
return validatePagination(offset, limit);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Applies pagination to a filtered result set.
|
|
130
|
-
*
|
|
131
|
-
* @param entities - Entities to paginate
|
|
132
|
-
* @param pagination - Validated pagination parameters
|
|
133
|
-
* @returns Paginated slice of entities
|
|
134
|
-
*/
|
|
135
|
-
static paginate(entities, pagination) {
|
|
136
|
-
return applyPagination(entities, pagination);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Convenience method to apply both filters and pagination in one call.
|
|
140
|
-
*
|
|
141
|
-
* @param entities - Entities to process
|
|
142
|
-
* @param filters - Filter criteria
|
|
143
|
-
* @param offset - Pagination offset
|
|
144
|
-
* @param limit - Pagination limit
|
|
145
|
-
* @returns Filtered and paginated entities
|
|
146
|
-
*/
|
|
147
|
-
static filterAndPaginate(entities, filters, offset = 0, limit) {
|
|
148
|
-
const filtered = this.applyFilters(entities, filters);
|
|
149
|
-
const pagination = this.validatePagination(offset, limit);
|
|
150
|
-
return this.paginate(filtered, pagination);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Applies tag filter only. Useful when other filters are handled separately.
|
|
154
|
-
*
|
|
155
|
-
* @param entities - Entities to filter
|
|
156
|
-
* @param tags - Tags to filter by
|
|
157
|
-
* @returns Filtered entities
|
|
158
|
-
*/
|
|
159
|
-
static filterByTags(entities, tags) {
|
|
160
|
-
if (!tags || tags.length === 0) {
|
|
161
|
-
return entities;
|
|
162
|
-
}
|
|
163
|
-
const normalizedTags = normalizeTags(tags);
|
|
164
|
-
return entities.filter(entity => {
|
|
165
|
-
if (!entity.tags || entity.tags.length === 0) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
return hasMatchingTag(entity.tags, normalizedTags);
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Applies importance filter only. Useful when other filters are handled separately.
|
|
173
|
-
*
|
|
174
|
-
* @param entities - Entities to filter
|
|
175
|
-
* @param minImportance - Minimum importance
|
|
176
|
-
* @param maxImportance - Maximum importance
|
|
177
|
-
* @returns Filtered entities
|
|
178
|
-
*/
|
|
179
|
-
static filterByImportance(entities, minImportance, maxImportance) {
|
|
180
|
-
if (minImportance === undefined && maxImportance === undefined) {
|
|
181
|
-
return entities;
|
|
182
|
-
}
|
|
183
|
-
return entities.filter(entity => isWithinImportanceRange(entity.importance, minImportance, maxImportance));
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
//# sourceMappingURL=SearchFilterChain.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SearchFilterChain.js","sourceRoot":"","sources":["../../src/search/SearchFilterChain.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GAEhB,MAAM,mBAAmB,CAAC;AAyB3B;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,QAA2B,EAAE,OAAsB;QACrE,wCAAwC;QACxC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;QACvB,CAAC;QAED,yCAAyC;QACzC,MAAM,oBAAoB,GAAG,OAAO,CAAC,IAAI,EAAE,MAAM;YAC/C,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC;YAC7B,CAAC,CAAC,SAAS,CAAC;QAEd,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAC9B,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,oBAAoB,CA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QAClB,CAAC;QAED,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAC9B,uBAAuB,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,EAAE,aAAa,CAAC,CACzE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Search Manager
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates all search types (basic, ranked, boolean, fuzzy).
|
|
5
|
-
* Focused on search operations only (Phase 4: Consolidate God Objects).
|
|
6
|
-
*
|
|
7
|
-
* @module search/SearchManager
|
|
8
|
-
*/
|
|
9
|
-
import type { KnowledgeGraph, SearchResult, SavedSearch, AutoSearchResult } from '../types/index.js';
|
|
10
|
-
import type { GraphStorage } from '../core/GraphStorage.js';
|
|
11
|
-
import { QueryCostEstimator } from './QueryCostEstimator.js';
|
|
12
|
-
/**
|
|
13
|
-
* Unified search manager providing access to all search types.
|
|
14
|
-
*
|
|
15
|
-
* Phase 4 Sprint 5: Manages search caches across all search types.
|
|
16
|
-
*/
|
|
17
|
-
export declare class SearchManager {
|
|
18
|
-
private basicSearch;
|
|
19
|
-
private rankedSearch;
|
|
20
|
-
private booleanSearcher;
|
|
21
|
-
private fuzzySearcher;
|
|
22
|
-
private searchSuggestions;
|
|
23
|
-
private savedSearchManager;
|
|
24
|
-
private storage;
|
|
25
|
-
private queryEstimator;
|
|
26
|
-
constructor(storage: GraphStorage, savedSearchesFilePath: string);
|
|
27
|
-
/**
|
|
28
|
-
* Phase 4 Sprint 5: Clear all search caches.
|
|
29
|
-
*
|
|
30
|
-
* Clears caches in all search types: fuzzy, boolean, and ranked token cache.
|
|
31
|
-
* Call this when the graph has been modified to ensure fresh results.
|
|
32
|
-
*/
|
|
33
|
-
clearAllCaches(): void;
|
|
34
|
-
/**
|
|
35
|
-
* Phase 4 Sprint 5: Clear fuzzy search cache.
|
|
36
|
-
*/
|
|
37
|
-
clearFuzzyCache(): void;
|
|
38
|
-
/**
|
|
39
|
-
* Phase 4 Sprint 5: Clear boolean search cache.
|
|
40
|
-
*/
|
|
41
|
-
clearBooleanCache(): void;
|
|
42
|
-
/**
|
|
43
|
-
* Phase 4 Sprint 5: Clear ranked search token cache.
|
|
44
|
-
*/
|
|
45
|
-
clearRankedCache(): void;
|
|
46
|
-
/**
|
|
47
|
-
* Perform a simple text-based search across entity names and observations.
|
|
48
|
-
*
|
|
49
|
-
* This is the primary search method that searches through entity names,
|
|
50
|
-
* observations, and types using case-insensitive substring matching.
|
|
51
|
-
* Optionally filter by tags and importance range.
|
|
52
|
-
*
|
|
53
|
-
* @param query - Text to search for (case-insensitive, searches names/observations/types)
|
|
54
|
-
* @param tags - Optional array of tags to filter results (lowercase)
|
|
55
|
-
* @param minImportance - Optional minimum importance value (0-10)
|
|
56
|
-
* @param maxImportance - Optional maximum importance value (0-10)
|
|
57
|
-
* @returns KnowledgeGraph containing matching entities and their relations
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* const manager = new SearchManager(storage, savedSearchesPath);
|
|
62
|
-
*
|
|
63
|
-
* // Simple text search
|
|
64
|
-
* const results = await manager.searchNodes('Alice');
|
|
65
|
-
*
|
|
66
|
-
* // Search with tag filter
|
|
67
|
-
* const engineeringResults = await manager.searchNodes('project', ['engineering']);
|
|
68
|
-
*
|
|
69
|
-
* // Search with importance range
|
|
70
|
-
* const importantResults = await manager.searchNodes('critical', undefined, 8, 10);
|
|
71
|
-
*
|
|
72
|
-
* // Combined filters
|
|
73
|
-
* const filtered = await manager.searchNodes('bug', ['backend'], 5, 10);
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
searchNodes(query: string, tags?: string[], minImportance?: number, maxImportance?: number): Promise<KnowledgeGraph>;
|
|
77
|
-
/**
|
|
78
|
-
* Open specific nodes by name.
|
|
79
|
-
*
|
|
80
|
-
* @param names - Array of entity names
|
|
81
|
-
* @returns Knowledge graph with specified entities
|
|
82
|
-
*/
|
|
83
|
-
openNodes(names: string[]): Promise<KnowledgeGraph>;
|
|
84
|
-
/**
|
|
85
|
-
* Search by date range.
|
|
86
|
-
*
|
|
87
|
-
* @param startDate - Optional start date (ISO 8601)
|
|
88
|
-
* @param endDate - Optional end date (ISO 8601)
|
|
89
|
-
* @param entityType - Optional entity type filter
|
|
90
|
-
* @param tags - Optional tags filter
|
|
91
|
-
* @returns Filtered knowledge graph
|
|
92
|
-
*/
|
|
93
|
-
searchByDateRange(startDate?: string, endDate?: string, entityType?: string, tags?: string[]): Promise<KnowledgeGraph>;
|
|
94
|
-
/**
|
|
95
|
-
* Perform TF-IDF ranked search with relevance scoring.
|
|
96
|
-
*
|
|
97
|
-
* Uses Term Frequency-Inverse Document Frequency algorithm to rank results
|
|
98
|
-
* by relevance to the query. Results are sorted by score (highest first).
|
|
99
|
-
* This is ideal for finding the most relevant entities for a search query.
|
|
100
|
-
*
|
|
101
|
-
* @param query - Search query (analyzed for term frequency)
|
|
102
|
-
* @param tags - Optional array of tags to filter results (lowercase)
|
|
103
|
-
* @param minImportance - Optional minimum importance value (0-10)
|
|
104
|
-
* @param maxImportance - Optional maximum importance value (0-10)
|
|
105
|
-
* @param limit - Maximum number of results to return (default: 50, max: 200)
|
|
106
|
-
* @returns Array of SearchResult objects sorted by relevance score (descending)
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```typescript
|
|
110
|
-
* const manager = new SearchManager(storage, savedSearchesPath);
|
|
111
|
-
*
|
|
112
|
-
* // Basic ranked search
|
|
113
|
-
* const results = await manager.searchNodesRanked('machine learning algorithms');
|
|
114
|
-
* results.forEach(r => {
|
|
115
|
-
* console.log(`${r.entity.name} (score: ${r.score})`);
|
|
116
|
-
* });
|
|
117
|
-
*
|
|
118
|
-
* // Limit to top 10 most relevant results
|
|
119
|
-
* const top10 = await manager.searchNodesRanked('database optimization', undefined, undefined, undefined, 10);
|
|
120
|
-
*
|
|
121
|
-
* // Ranked search with filters
|
|
122
|
-
* const relevantImportant = await manager.searchNodesRanked(
|
|
123
|
-
* 'security vulnerability',
|
|
124
|
-
* ['security', 'critical'],
|
|
125
|
-
* 8,
|
|
126
|
-
* 10,
|
|
127
|
-
* 20
|
|
128
|
-
* );
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
searchNodesRanked(query: string, tags?: string[], minImportance?: number, maxImportance?: number, limit?: number): Promise<SearchResult[]>;
|
|
132
|
-
/**
|
|
133
|
-
* Perform boolean search with AND, OR, NOT operators.
|
|
134
|
-
*
|
|
135
|
-
* Supports complex boolean logic for precise search queries.
|
|
136
|
-
* Use AND/OR/NOT operators (case-insensitive) to combine search terms.
|
|
137
|
-
* Parentheses are supported for grouping.
|
|
138
|
-
*
|
|
139
|
-
* @param query - Boolean query string (e.g., "alice AND bob", "frontend OR backend NOT legacy")
|
|
140
|
-
* @param tags - Optional array of tags to filter results (lowercase)
|
|
141
|
-
* @param minImportance - Optional minimum importance value (0-10)
|
|
142
|
-
* @param maxImportance - Optional maximum importance value (0-10)
|
|
143
|
-
* @returns KnowledgeGraph containing entities matching the boolean expression
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```typescript
|
|
147
|
-
* const manager = new SearchManager(storage, savedSearchesPath);
|
|
148
|
-
*
|
|
149
|
-
* // AND operator - entities matching all terms
|
|
150
|
-
* const both = await manager.booleanSearch('database AND performance');
|
|
151
|
-
*
|
|
152
|
-
* // OR operator - entities matching any term
|
|
153
|
-
* const either = await manager.booleanSearch('frontend OR backend');
|
|
154
|
-
*
|
|
155
|
-
* // NOT operator - exclude terms
|
|
156
|
-
* const excluding = await manager.booleanSearch('API NOT deprecated');
|
|
157
|
-
*
|
|
158
|
-
* // Complex queries with grouping
|
|
159
|
-
* const complex = await manager.booleanSearch('(react OR vue) AND (component OR hook) NOT legacy');
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
booleanSearch(query: string, tags?: string[], minImportance?: number, maxImportance?: number): Promise<KnowledgeGraph>;
|
|
163
|
-
/**
|
|
164
|
-
* Perform fuzzy search with typo tolerance.
|
|
165
|
-
*
|
|
166
|
-
* Uses Levenshtein distance to find entities that approximately match the query,
|
|
167
|
-
* making it ideal for handling typos and variations in spelling.
|
|
168
|
-
* Higher threshold values require closer matches.
|
|
169
|
-
*
|
|
170
|
-
* @param query - Search query (will match approximate spellings)
|
|
171
|
-
* @param threshold - Similarity threshold from 0.0 (very lenient) to 1.0 (exact match). Default: 0.7
|
|
172
|
-
* @param tags - Optional array of tags to filter results (lowercase)
|
|
173
|
-
* @param minImportance - Optional minimum importance value (0-10)
|
|
174
|
-
* @param maxImportance - Optional maximum importance value (0-10)
|
|
175
|
-
* @returns KnowledgeGraph containing entities with similar names/observations
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
* ```typescript
|
|
179
|
-
* const manager = new SearchManager(storage, savedSearchesPath);
|
|
180
|
-
*
|
|
181
|
-
* // Find entities even with typos
|
|
182
|
-
* const results = await manager.fuzzySearch('databse'); // Will match "database"
|
|
183
|
-
*
|
|
184
|
-
* // Adjust threshold for strictness
|
|
185
|
-
* const strict = await manager.fuzzySearch('optmization', 0.9); // Requires very close match
|
|
186
|
-
* const lenient = await manager.fuzzySearch('optmization', 0.6); // More tolerant of differences
|
|
187
|
-
*
|
|
188
|
-
* // Fuzzy search with filters
|
|
189
|
-
* const filtered = await manager.fuzzySearch('secrity', 0.7, ['important'], 7, 10);
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
fuzzySearch(query: string, threshold?: number, tags?: string[], minImportance?: number, maxImportance?: number): Promise<KnowledgeGraph>;
|
|
193
|
-
/**
|
|
194
|
-
* Get search suggestions for a query.
|
|
195
|
-
*
|
|
196
|
-
* @param query - Search query
|
|
197
|
-
* @param maxSuggestions - Maximum suggestions to return
|
|
198
|
-
* @returns Array of suggested terms
|
|
199
|
-
*/
|
|
200
|
-
getSearchSuggestions(query: string, maxSuggestions?: number): Promise<string[]>;
|
|
201
|
-
/**
|
|
202
|
-
* Save a search query for later reuse.
|
|
203
|
-
*
|
|
204
|
-
* Saved searches store query parameters and can be re-executed later.
|
|
205
|
-
* The system tracks usage count and last used timestamp automatically.
|
|
206
|
-
*
|
|
207
|
-
* @param search - Search parameters (name, query, and optional filters)
|
|
208
|
-
* @returns Newly created SavedSearch object with metadata
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* ```typescript
|
|
212
|
-
* const manager = new SearchManager(storage, savedSearchesPath);
|
|
213
|
-
*
|
|
214
|
-
* // Save a simple search
|
|
215
|
-
* const saved = await manager.saveSearch({
|
|
216
|
-
* name: 'High Priority Bugs',
|
|
217
|
-
* query: 'bug',
|
|
218
|
-
* tags: ['critical'],
|
|
219
|
-
* minImportance: 8
|
|
220
|
-
* });
|
|
221
|
-
*
|
|
222
|
-
* // Save a complex search
|
|
223
|
-
* await manager.saveSearch({
|
|
224
|
-
* name: 'Recent Frontend Work',
|
|
225
|
-
* query: 'component OR hook',
|
|
226
|
-
* tags: ['frontend', 'react'],
|
|
227
|
-
* searchType: 'boolean'
|
|
228
|
-
* });
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
saveSearch(search: Omit<SavedSearch, 'createdAt' | 'useCount' | 'lastUsed'>): Promise<SavedSearch>;
|
|
232
|
-
/**
|
|
233
|
-
* List all saved searches.
|
|
234
|
-
*
|
|
235
|
-
* @returns Array of saved searches
|
|
236
|
-
*/
|
|
237
|
-
listSavedSearches(): Promise<SavedSearch[]>;
|
|
238
|
-
/**
|
|
239
|
-
* Get a saved search by name.
|
|
240
|
-
*
|
|
241
|
-
* @param name - Search name
|
|
242
|
-
* @returns Saved search or null
|
|
243
|
-
*/
|
|
244
|
-
getSavedSearch(name: string): Promise<SavedSearch | null>;
|
|
245
|
-
/**
|
|
246
|
-
* Execute a saved search by name.
|
|
247
|
-
*
|
|
248
|
-
* Runs a previously saved search with its stored parameters.
|
|
249
|
-
* Automatically updates the search's useCount and lastUsed timestamp.
|
|
250
|
-
*
|
|
251
|
-
* @param name - The unique name of the saved search to execute
|
|
252
|
-
* @returns KnowledgeGraph containing the search results
|
|
253
|
-
* @throws Error if saved search not found
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* ```typescript
|
|
257
|
-
* const manager = new SearchManager(storage, savedSearchesPath);
|
|
258
|
-
*
|
|
259
|
-
* // Execute a saved search
|
|
260
|
-
* const results = await manager.executeSavedSearch('High Priority Bugs');
|
|
261
|
-
* console.log(`Found ${results.entities.length} high priority bugs`);
|
|
262
|
-
*
|
|
263
|
-
* // Handle missing saved search
|
|
264
|
-
* try {
|
|
265
|
-
* await manager.executeSavedSearch('NonExistent');
|
|
266
|
-
* } catch (error) {
|
|
267
|
-
* console.error('Search not found');
|
|
268
|
-
* }
|
|
269
|
-
* ```
|
|
270
|
-
*/
|
|
271
|
-
executeSavedSearch(name: string): Promise<KnowledgeGraph>;
|
|
272
|
-
/**
|
|
273
|
-
* Delete a saved search.
|
|
274
|
-
*
|
|
275
|
-
* @param name - Search name
|
|
276
|
-
* @returns True if deleted
|
|
277
|
-
*/
|
|
278
|
-
deleteSavedSearch(name: string): Promise<boolean>;
|
|
279
|
-
/**
|
|
280
|
-
* Update a saved search.
|
|
281
|
-
*
|
|
282
|
-
* @param name - Search name
|
|
283
|
-
* @param updates - Fields to update
|
|
284
|
-
* @returns Updated saved search
|
|
285
|
-
*/
|
|
286
|
-
updateSavedSearch(name: string, updates: Partial<Omit<SavedSearch, 'name' | 'createdAt' | 'useCount' | 'lastUsed'>>): Promise<SavedSearch>;
|
|
287
|
-
/**
|
|
288
|
-
* Phase 10 Sprint 4: Automatically select and execute the best search method.
|
|
289
|
-
*
|
|
290
|
-
* Analyzes the query and graph size to determine the optimal search method,
|
|
291
|
-
* then executes it and returns both the results and the selection reasoning.
|
|
292
|
-
*
|
|
293
|
-
* @param query - The search query
|
|
294
|
-
* @param limit - Maximum number of results (default: 10)
|
|
295
|
-
* @returns AutoSearchResult with selected method, results, and estimates
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* ```typescript
|
|
299
|
-
* const manager = new SearchManager(storage, savedSearchesPath);
|
|
300
|
-
*
|
|
301
|
-
* // Let the system choose the best search method
|
|
302
|
-
* const result = await manager.autoSearch('software engineer skills');
|
|
303
|
-
*
|
|
304
|
-
* console.log(`Used ${result.selectedMethod} because: ${result.selectionReason}`);
|
|
305
|
-
* console.log(`Found ${result.results.length} results in ${result.executionTimeMs}ms`);
|
|
306
|
-
* ```
|
|
307
|
-
*/
|
|
308
|
-
autoSearch(query: string, limit?: number): Promise<AutoSearchResult>;
|
|
309
|
-
/**
|
|
310
|
-
* Phase 10 Sprint 4: Get cost estimates for all search methods.
|
|
311
|
-
*
|
|
312
|
-
* Useful for clients that want to display cost information or
|
|
313
|
-
* make their own method selection decisions.
|
|
314
|
-
*
|
|
315
|
-
* @param query - The search query
|
|
316
|
-
* @returns Array of cost estimates for all methods
|
|
317
|
-
*/
|
|
318
|
-
getSearchCostEstimates(query: string): Promise<import('../types/index.js').QueryCostEstimate[]>;
|
|
319
|
-
/**
|
|
320
|
-
* Phase 10 Sprint 4: Get the query cost estimator instance.
|
|
321
|
-
*
|
|
322
|
-
* @returns The QueryCostEstimator instance
|
|
323
|
-
*/
|
|
324
|
-
getQueryEstimator(): QueryCostEstimator;
|
|
325
|
-
}
|
|
326
|
-
//# sourceMappingURL=SearchManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SearchManager.d.ts","sourceRoot":"","sources":["../../src/search/SearchManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAU,MAAM,mBAAmB,CAAC;AAC7G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAO5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;G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