2025-08-26 12:32:21 -07:00
|
|
|
/**
|
2025-09-17 11:54:20 -07:00
|
|
|
* BrainyInterface - Modern API Only
|
|
|
|
|
*
|
|
|
|
|
* This interface defines the MODERN methods from Brainy 3.0.
|
|
|
|
|
* Used to break circular dependencies while enforcing modern API usage.
|
|
|
|
|
*
|
|
|
|
|
* NO DEPRECATED METHODS - Only clean, modern API patterns.
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { Vector } from '../coreTypes.js'
|
2025-09-17 11:54:20 -07:00
|
|
|
import { AddParams, RelateParams, Result, Entity, FindParams, SimilarParams } from './brainy.types.js'
|
2025-08-26 12:32:21 -07:00
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
export interface BrainyInterface<T = unknown> {
|
2025-08-26 12:32:21 -07:00
|
|
|
/**
|
|
|
|
|
* Initialize the database
|
|
|
|
|
*/
|
|
|
|
|
init(): Promise<void>
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-17 11:54:20 -07:00
|
|
|
* Modern add method - unified entity creation
|
|
|
|
|
* @param params Parameters for adding entities
|
|
|
|
|
* @returns The ID of the created entity
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
2025-09-17 11:54:20 -07:00
|
|
|
add(params: AddParams<T>): Promise<string>
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
/**
|
2025-09-17 11:54:20 -07:00
|
|
|
* Modern relate method - unified relationship creation
|
|
|
|
|
* @param params Parameters for creating relationships
|
|
|
|
|
* @returns The ID of the created relationship
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
2025-09-17 11:54:20 -07:00
|
|
|
relate(params: RelateParams<T>): Promise<string>
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
/**
|
2025-09-17 11:54:20 -07:00
|
|
|
* Modern find method - unified search and discovery
|
|
|
|
|
* @param query Search query or parameters object
|
|
|
|
|
* @returns Array of search results
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
2025-09-17 11:54:20 -07:00
|
|
|
find(query: string | FindParams<T>): Promise<Result<T>[]>
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
/**
|
2025-09-17 11:54:20 -07:00
|
|
|
* Modern get method - retrieve entities by ID
|
|
|
|
|
* @param id The entity ID to retrieve
|
|
|
|
|
* @returns Entity or null if not found
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
2025-09-17 11:54:20 -07:00
|
|
|
get(id: string): Promise<Entity<T> | null>
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
/**
|
2025-09-17 11:54:20 -07:00
|
|
|
* Modern similar method - find similar entities
|
|
|
|
|
* @param params Parameters for similarity search
|
|
|
|
|
* @returns Array of similar entities with scores
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
2025-09-17 11:54:20 -07:00
|
|
|
similar(params: SimilarParams<T>): Promise<Result<T>[]>
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate embedding vector from text
|
|
|
|
|
* @param text The text to embed
|
|
|
|
|
* @returns Vector representation of the text
|
|
|
|
|
*/
|
|
|
|
|
embed(text: string): Promise<Vector>
|
2025-09-17 11:54:20 -07:00
|
|
|
}
|