@soulcraft/brainy 0.54.2 → 0.54.4
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.js +26 -15
- package/dist/brainyData.js.map +1 -1
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +15 -0
- package/dist/storage/adapters/s3CompatibleStorage.js +151 -126
- package/dist/storage/adapters/s3CompatibleStorage.js.map +1 -1
- package/dist/utils/metadataIndex.d.ts +7 -1
- package/dist/utils/metadataIndex.js +82 -20
- package/dist/utils/metadataIndex.js.map +1 -1
- package/package.json +1 -1
package/dist/brainyData.js
CHANGED
|
@@ -788,8 +788,9 @@ export class BrainyData {
|
|
|
788
788
|
catch (e) {
|
|
789
789
|
// Ignore errors loading existing statistics
|
|
790
790
|
}
|
|
791
|
-
// Initialize metadata index
|
|
792
|
-
|
|
791
|
+
// Initialize metadata index unless in read-only mode
|
|
792
|
+
// Write-only mode NEEDS metadata indexing for search capability!
|
|
793
|
+
if (!this.readOnly) {
|
|
793
794
|
this.metadataIndex = new MetadataIndexManager(this.storage, this.config.metadataIndex);
|
|
794
795
|
// Check if we need to rebuild the index (for existing data)
|
|
795
796
|
// Skip rebuild for memory storage (starts empty) or when in read-only mode
|
|
@@ -802,20 +803,30 @@ export class BrainyData {
|
|
|
802
803
|
try {
|
|
803
804
|
const testResult = await this.storage.getNouns({ pagination: { offset: 0, limit: 1 } });
|
|
804
805
|
if (testResult.items.length > 0) {
|
|
805
|
-
if
|
|
806
|
-
|
|
806
|
+
// Only rebuild metadata index if explicitly requested or if we have very few items
|
|
807
|
+
const shouldRebuild = process.env.BRAINY_REBUILD_INDEX === 'true';
|
|
808
|
+
if (shouldRebuild) {
|
|
809
|
+
if (this.loggingConfig?.verbose) {
|
|
810
|
+
console.log('🔄 Rebuilding metadata index for existing data...');
|
|
811
|
+
}
|
|
812
|
+
await this.metadataIndex.rebuild();
|
|
813
|
+
if (this.loggingConfig?.verbose) {
|
|
814
|
+
const newStats = await this.metadataIndex.getStats();
|
|
815
|
+
console.log(`✅ Metadata index rebuilt: ${newStats.totalEntries} entries, ${newStats.fieldsIndexed.length} fields`);
|
|
816
|
+
}
|
|
807
817
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
818
|
+
else {
|
|
819
|
+
if (this.loggingConfig?.verbose) {
|
|
820
|
+
console.log('⏭️ Skipping metadata index rebuild (set BRAINY_REBUILD_INDEX=true to force)');
|
|
821
|
+
}
|
|
822
|
+
// Build index incrementally as items are accessed instead
|
|
812
823
|
}
|
|
813
824
|
}
|
|
814
825
|
}
|
|
815
826
|
catch (error) {
|
|
816
827
|
// If getNouns fails, skip rebuild
|
|
817
828
|
if (this.loggingConfig?.verbose) {
|
|
818
|
-
console.log('Skipping metadata index rebuild:', error);
|
|
829
|
+
console.log('⚠️ Skipping metadata index rebuild due to error:', error);
|
|
819
830
|
}
|
|
820
831
|
}
|
|
821
832
|
}
|
|
@@ -1186,8 +1197,8 @@ export class BrainyData {
|
|
|
1186
1197
|
}
|
|
1187
1198
|
}
|
|
1188
1199
|
await this.storage.saveMetadata(id, metadataToSave);
|
|
1189
|
-
// Update metadata index
|
|
1190
|
-
if (this.metadataIndex && !this.
|
|
1200
|
+
// Update metadata index (write-only mode should build indices!)
|
|
1201
|
+
if (this.metadataIndex && !this.frozen) {
|
|
1191
1202
|
await this.metadataIndex.addToIndex(id, metadataToSave);
|
|
1192
1203
|
}
|
|
1193
1204
|
// Track metadata statistics
|
|
@@ -2288,8 +2299,8 @@ export class BrainyData {
|
|
|
2288
2299
|
try {
|
|
2289
2300
|
// Get metadata before removing for index cleanup
|
|
2290
2301
|
const existingMetadata = await this.storage.getMetadata(actualId);
|
|
2291
|
-
// Remove from metadata index
|
|
2292
|
-
if (this.metadataIndex && existingMetadata && !this.
|
|
2302
|
+
// Remove from metadata index (write-only mode should update indices!)
|
|
2303
|
+
if (this.metadataIndex && existingMetadata && !this.frozen) {
|
|
2293
2304
|
await this.metadataIndex.removeFromIndex(actualId, existingMetadata);
|
|
2294
2305
|
}
|
|
2295
2306
|
await this.storage.saveMetadata(actualId, null);
|
|
@@ -2377,8 +2388,8 @@ export class BrainyData {
|
|
|
2377
2388
|
}
|
|
2378
2389
|
// Update metadata
|
|
2379
2390
|
await this.storage.saveMetadata(id, metadata);
|
|
2380
|
-
// Update metadata index
|
|
2381
|
-
if (this.metadataIndex && !this.
|
|
2391
|
+
// Update metadata index (write-only mode should build indices!)
|
|
2392
|
+
if (this.metadataIndex && !this.frozen) {
|
|
2382
2393
|
// Remove old metadata from index if it exists
|
|
2383
2394
|
const oldMetadata = await this.storage.getMetadata(id);
|
|
2384
2395
|
if (oldMetadata) {
|