@soulcraft/brainy 5.3.5 → 5.4.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/CHANGELOG.md +72 -0
- package/dist/brainy.d.ts +61 -0
- package/dist/brainy.js +188 -24
- package/dist/storage/adapters/azureBlobStorage.d.ts +13 -64
- package/dist/storage/adapters/azureBlobStorage.js +78 -388
- package/dist/storage/adapters/fileSystemStorage.d.ts +12 -78
- package/dist/storage/adapters/fileSystemStorage.js +49 -395
- package/dist/storage/adapters/gcsStorage.d.ts +13 -134
- package/dist/storage/adapters/gcsStorage.js +79 -557
- package/dist/storage/adapters/historicalStorageAdapter.d.ts +181 -0
- package/dist/storage/adapters/historicalStorageAdapter.js +332 -0
- package/dist/storage/adapters/memoryStorage.d.ts +4 -113
- package/dist/storage/adapters/memoryStorage.js +34 -471
- package/dist/storage/adapters/opfsStorage.d.ts +14 -127
- package/dist/storage/adapters/opfsStorage.js +44 -693
- package/dist/storage/adapters/r2Storage.d.ts +8 -41
- package/dist/storage/adapters/r2Storage.js +49 -237
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +13 -111
- package/dist/storage/adapters/s3CompatibleStorage.js +77 -596
- package/dist/storage/baseStorage.d.ts +78 -38
- package/dist/storage/baseStorage.js +699 -23
- package/dist/storage/cow/BlobStorage.d.ts +2 -2
- package/dist/storage/cow/BlobStorage.js +4 -4
- package/dist/storage/storageFactory.d.ts +2 -3
- package/dist/storage/storageFactory.js +114 -66
- package/dist/vfs/types.d.ts +6 -2
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { GraphAdjacencyIndex } from '../graph/graphAdjacencyIndex.js';
|
|
6
6
|
import { GraphVerb, HNSWNoun, HNSWVerb, NounMetadata, VerbMetadata, HNSWNounWithMetadata, HNSWVerbWithMetadata, StatisticsData } from '../coreTypes.js';
|
|
7
7
|
import { BaseStorageAdapter } from './adapters/baseStorageAdapter.js';
|
|
8
|
+
import { NounType, VerbType } from '../types/graphTypes.js';
|
|
8
9
|
import { RefManager } from './cow/RefManager.js';
|
|
9
10
|
import { BlobStorage } from './cow/BlobStorage.js';
|
|
10
11
|
import { CommitLog } from './cow/CommitLog.js';
|
|
@@ -56,6 +57,10 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
|
|
|
56
57
|
commitLog?: CommitLog;
|
|
57
58
|
currentBranch: string;
|
|
58
59
|
protected cowEnabled: boolean;
|
|
60
|
+
protected nounCountsByType: Uint32Array<ArrayBuffer>;
|
|
61
|
+
protected verbCountsByType: Uint32Array<ArrayBuffer>;
|
|
62
|
+
protected nounTypeCache: Map<string, NounType>;
|
|
63
|
+
protected verbTypeCache: Map<string, VerbType>;
|
|
59
64
|
/**
|
|
60
65
|
* Analyze a storage key to determine its routing and path
|
|
61
66
|
* @param id - The key to analyze (UUID or system key)
|
|
@@ -65,10 +70,12 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
|
|
|
65
70
|
*/
|
|
66
71
|
private analyzeKey;
|
|
67
72
|
/**
|
|
68
|
-
* Initialize the storage adapter
|
|
69
|
-
*
|
|
73
|
+
* Initialize the storage adapter (v5.4.0)
|
|
74
|
+
* Loads type statistics for built-in type-aware indexing
|
|
75
|
+
*
|
|
76
|
+
* IMPORTANT: If your adapter overrides init(), call await super.init() first!
|
|
70
77
|
*/
|
|
71
|
-
|
|
78
|
+
init(): Promise<void>;
|
|
72
79
|
/**
|
|
73
80
|
* Ensure the storage adapter is initialized
|
|
74
81
|
*/
|
|
@@ -213,6 +220,27 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
|
|
|
213
220
|
hasMore: boolean;
|
|
214
221
|
nextCursor?: string;
|
|
215
222
|
}>;
|
|
223
|
+
/**
|
|
224
|
+
* Get nouns with pagination (v5.4.0: Type-first implementation)
|
|
225
|
+
*
|
|
226
|
+
* CRITICAL: This method is required for brain.find() to work!
|
|
227
|
+
* Iterates through all noun types to find entities.
|
|
228
|
+
*/
|
|
229
|
+
getNounsWithPagination(options: {
|
|
230
|
+
limit: number;
|
|
231
|
+
offset: number;
|
|
232
|
+
cursor?: string;
|
|
233
|
+
filter?: {
|
|
234
|
+
nounType?: string | string[];
|
|
235
|
+
service?: string | string[];
|
|
236
|
+
metadata?: Record<string, any>;
|
|
237
|
+
};
|
|
238
|
+
}): Promise<{
|
|
239
|
+
items: HNSWNounWithMetadata[];
|
|
240
|
+
totalCount: number;
|
|
241
|
+
hasMore: boolean;
|
|
242
|
+
nextCursor?: string;
|
|
243
|
+
}>;
|
|
216
244
|
/**
|
|
217
245
|
* Get verbs with pagination and filtering
|
|
218
246
|
* @param options Pagination and filtering options
|
|
@@ -319,12 +347,12 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
|
|
|
319
347
|
protected saveNounMetadata_internal(id: string, metadata: NounMetadata): Promise<void>;
|
|
320
348
|
/**
|
|
321
349
|
* Get noun metadata from storage (v4.0.0: now typed)
|
|
322
|
-
* Uses
|
|
350
|
+
* v5.4.0: Uses type-first paths (must match saveNounMetadata_internal)
|
|
323
351
|
*/
|
|
324
352
|
getNounMetadata(id: string): Promise<NounMetadata | null>;
|
|
325
353
|
/**
|
|
326
354
|
* Delete noun metadata from storage
|
|
327
|
-
* Uses
|
|
355
|
+
* v5.4.0: Uses type-first paths (must match saveNounMetadata_internal)
|
|
328
356
|
*/
|
|
329
357
|
deleteNounMetadata(id: string): Promise<void>;
|
|
330
358
|
/**
|
|
@@ -334,7 +362,7 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
|
|
|
334
362
|
saveVerbMetadata(id: string, metadata: VerbMetadata): Promise<void>;
|
|
335
363
|
/**
|
|
336
364
|
* Internal method for saving verb metadata (v4.0.0: now typed)
|
|
337
|
-
* Uses
|
|
365
|
+
* v5.4.0: Uses type-first paths (must match getVerbMetadata)
|
|
338
366
|
*
|
|
339
367
|
* CRITICAL (v4.1.2): Count synchronization happens here
|
|
340
368
|
* This ensures verb counts are updated AFTER metadata exists, fixing the race condition
|
|
@@ -347,64 +375,76 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
|
|
|
347
375
|
protected saveVerbMetadata_internal(id: string, metadata: VerbMetadata): Promise<void>;
|
|
348
376
|
/**
|
|
349
377
|
* Get verb metadata from storage (v4.0.0: now typed)
|
|
350
|
-
* Uses
|
|
378
|
+
* v5.4.0: Uses type-first paths (must match saveVerbMetadata_internal)
|
|
351
379
|
*/
|
|
352
380
|
getVerbMetadata(id: string): Promise<VerbMetadata | null>;
|
|
353
381
|
/**
|
|
354
382
|
* Delete verb metadata from storage
|
|
355
|
-
* Uses
|
|
383
|
+
* v5.4.0: Uses type-first paths (must match saveVerbMetadata_internal)
|
|
356
384
|
*/
|
|
357
385
|
deleteVerbMetadata(id: string): Promise<void>;
|
|
358
386
|
/**
|
|
359
|
-
*
|
|
360
|
-
*
|
|
387
|
+
* Load type statistics from storage
|
|
388
|
+
* Rebuilds type counts if needed (called during init)
|
|
361
389
|
*/
|
|
362
|
-
protected
|
|
390
|
+
protected loadTypeStatistics(): Promise<void>;
|
|
363
391
|
/**
|
|
364
|
-
*
|
|
365
|
-
*
|
|
392
|
+
* Save type statistics to storage
|
|
393
|
+
* Periodically called when counts are updated
|
|
366
394
|
*/
|
|
367
|
-
protected
|
|
395
|
+
protected saveTypeStatistics(): Promise<void>;
|
|
368
396
|
/**
|
|
369
|
-
* Get
|
|
370
|
-
*
|
|
397
|
+
* Get noun type from cache or metadata
|
|
398
|
+
* Relies on nounTypeCache populated during metadata saves
|
|
371
399
|
*/
|
|
372
|
-
protected
|
|
400
|
+
protected getNounType(noun: HNSWNoun): NounType;
|
|
373
401
|
/**
|
|
374
|
-
*
|
|
375
|
-
*
|
|
402
|
+
* Get verb type from verb object
|
|
403
|
+
* Verb type is a required field in HNSWVerb
|
|
376
404
|
*/
|
|
377
|
-
protected
|
|
405
|
+
protected getVerbType(verb: HNSWVerb | GraphVerb): VerbType;
|
|
378
406
|
/**
|
|
379
|
-
* Save a
|
|
380
|
-
* This method should be implemented by each specific adapter
|
|
407
|
+
* Save a noun to storage (type-first path)
|
|
381
408
|
*/
|
|
382
|
-
protected
|
|
409
|
+
protected saveNoun_internal(noun: HNSWNoun): Promise<void>;
|
|
383
410
|
/**
|
|
384
|
-
* Get a
|
|
385
|
-
* This method should be implemented by each specific adapter
|
|
411
|
+
* Get a noun from storage (type-first path)
|
|
386
412
|
*/
|
|
387
|
-
protected
|
|
413
|
+
protected getNoun_internal(id: string): Promise<HNSWNoun | null>;
|
|
388
414
|
/**
|
|
389
|
-
* Get
|
|
390
|
-
* This method should be implemented by each specific adapter
|
|
415
|
+
* Get nouns by noun type (O(1) with type-first paths!)
|
|
391
416
|
*/
|
|
392
|
-
protected
|
|
417
|
+
protected getNounsByNounType_internal(nounType: string): Promise<HNSWNoun[]>;
|
|
393
418
|
/**
|
|
394
|
-
*
|
|
395
|
-
* This method should be implemented by each specific adapter
|
|
419
|
+
* Delete a noun from storage (type-first path)
|
|
396
420
|
*/
|
|
397
|
-
protected
|
|
421
|
+
protected deleteNoun_internal(id: string): Promise<void>;
|
|
398
422
|
/**
|
|
399
|
-
*
|
|
400
|
-
* This method should be implemented by each specific adapter
|
|
423
|
+
* Save a verb to storage (type-first path)
|
|
401
424
|
*/
|
|
402
|
-
protected
|
|
425
|
+
protected saveVerb_internal(verb: HNSWVerb): Promise<void>;
|
|
403
426
|
/**
|
|
404
|
-
*
|
|
405
|
-
|
|
427
|
+
* Get a verb from storage (type-first path)
|
|
428
|
+
*/
|
|
429
|
+
protected getVerb_internal(id: string): Promise<HNSWVerb | null>;
|
|
430
|
+
/**
|
|
431
|
+
* Get verbs by source (COW-aware implementation)
|
|
432
|
+
* v5.4.0: Fixed to directly list verb files instead of directories
|
|
433
|
+
*/
|
|
434
|
+
protected getVerbsBySource_internal(sourceId: string): Promise<HNSWVerbWithMetadata[]>;
|
|
435
|
+
/**
|
|
436
|
+
* Get verbs by target (COW-aware implementation)
|
|
437
|
+
* v5.4.0: Fixed to directly list verb files instead of directories
|
|
438
|
+
*/
|
|
439
|
+
protected getVerbsByTarget_internal(targetId: string): Promise<HNSWVerbWithMetadata[]>;
|
|
440
|
+
/**
|
|
441
|
+
* Get verbs by type (O(1) with type-first paths!)
|
|
442
|
+
*/
|
|
443
|
+
protected getVerbsByType_internal(verbType: string): Promise<HNSWVerbWithMetadata[]>;
|
|
444
|
+
/**
|
|
445
|
+
* Delete a verb from storage (type-first path)
|
|
406
446
|
*/
|
|
407
|
-
protected
|
|
447
|
+
protected deleteVerb_internal(id: string): Promise<void>;
|
|
408
448
|
/**
|
|
409
449
|
* Helper method to convert a Map to a plain object for serialization
|
|
410
450
|
*/
|