@soulcraft/brainy 4.7.0 → 4.7.1
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/storage/baseStorage.js +32 -0
- package/package.json +1 -1
|
@@ -500,6 +500,38 @@ export class BaseStorage extends BaseStorageAdapter {
|
|
|
500
500
|
const cursor = pagination.cursor;
|
|
501
501
|
// Optimize for common filter cases to avoid loading all verbs
|
|
502
502
|
if (options?.filter) {
|
|
503
|
+
// CRITICAL VFS FIX: If filtering by sourceId + verbType (most common VFS pattern!)
|
|
504
|
+
// This is the query PathResolver.getChildren() uses: getRelations({ from: dirId, type: VerbType.Contains })
|
|
505
|
+
if (options.filter.sourceId &&
|
|
506
|
+
options.filter.verbType &&
|
|
507
|
+
!options.filter.targetId &&
|
|
508
|
+
!options.filter.service &&
|
|
509
|
+
!options.filter.metadata) {
|
|
510
|
+
const sourceId = Array.isArray(options.filter.sourceId)
|
|
511
|
+
? options.filter.sourceId[0]
|
|
512
|
+
: options.filter.sourceId;
|
|
513
|
+
const verbType = Array.isArray(options.filter.verbType)
|
|
514
|
+
? options.filter.verbType[0]
|
|
515
|
+
: options.filter.verbType;
|
|
516
|
+
// Get verbs by source, then filter by type (O(1) graph lookup + O(n) type filter)
|
|
517
|
+
const verbsBySource = await this.getVerbsBySource_internal(sourceId);
|
|
518
|
+
const filteredVerbs = verbsBySource.filter(v => v.verb === verbType);
|
|
519
|
+
// Apply pagination
|
|
520
|
+
const paginatedVerbs = filteredVerbs.slice(offset, offset + limit);
|
|
521
|
+
const hasMore = offset + limit < filteredVerbs.length;
|
|
522
|
+
// Set next cursor if there are more items
|
|
523
|
+
let nextCursor = undefined;
|
|
524
|
+
if (hasMore && paginatedVerbs.length > 0) {
|
|
525
|
+
const lastItem = paginatedVerbs[paginatedVerbs.length - 1];
|
|
526
|
+
nextCursor = lastItem.id;
|
|
527
|
+
}
|
|
528
|
+
return {
|
|
529
|
+
items: paginatedVerbs,
|
|
530
|
+
totalCount: filteredVerbs.length,
|
|
531
|
+
hasMore,
|
|
532
|
+
nextCursor
|
|
533
|
+
};
|
|
534
|
+
}
|
|
503
535
|
// If filtering by sourceId only, use the optimized method
|
|
504
536
|
if (options.filter.sourceId &&
|
|
505
537
|
!options.filter.verbType &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.1",
|
|
4
4
|
"description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|