|
| 1 | +/** Shared types used across all store modules. */ |
| 2 | + |
| 3 | +export type GraphName = 'code' | 'docs' | 'files' | 'knowledge' | 'tasks' | 'skills'; |
| 4 | + |
| 5 | +// --------------------------------------------------------------------------- |
| 6 | +// Search |
| 7 | +// --------------------------------------------------------------------------- |
| 8 | + |
| 9 | +export type SearchMode = 'hybrid' | 'vector' | 'keyword'; |
| 10 | + |
| 11 | +export interface SearchQuery { |
| 12 | + /** Text query for FTS5 keyword search */ |
| 13 | + text?: string; |
| 14 | + /** Embedding vector for sqlite-vec similarity search */ |
| 15 | + embedding?: number[]; |
| 16 | + /** Search strategy (default 'hybrid'). 'keyword' ignores embedding, 'vector' ignores text */ |
| 17 | + searchMode?: SearchMode; |
| 18 | + /** Max vector candidates before fusion/ranking (default 50) */ |
| 19 | + topK?: number; |
| 20 | + /** Max results to return (default 20) */ |
| 21 | + maxResults?: number; |
| 22 | + /** Minimum relevance score 0-1 (default 0) */ |
| 23 | + minScore?: number; |
| 24 | +} |
| 25 | + |
| 26 | +export interface SearchResult { |
| 27 | + id: string; |
| 28 | + score: number; |
| 29 | +} |
| 30 | + |
| 31 | +// --------------------------------------------------------------------------- |
| 32 | +// Meta (key-value, shared interface for all stores) |
| 33 | +// --------------------------------------------------------------------------- |
| 34 | + |
| 35 | +export interface MetaMixin { |
| 36 | + getMeta(key: string): string | null; |
| 37 | + setMeta(key: string, value: string): void; |
| 38 | + deleteMeta(key: string): void; |
| 39 | +} |
| 40 | + |
| 41 | +// --------------------------------------------------------------------------- |
| 42 | +// Pagination |
| 43 | +// --------------------------------------------------------------------------- |
| 44 | + |
| 45 | +export interface PaginationOptions { |
| 46 | + limit?: number; |
| 47 | + offset?: number; |
| 48 | +} |
| 49 | + |
| 50 | +// --------------------------------------------------------------------------- |
| 51 | +// Cross-graph links (replaces proxy nodes) |
| 52 | +// --------------------------------------------------------------------------- |
| 53 | + |
| 54 | +export interface CrossLink { |
| 55 | + sourceGraph: GraphName; |
| 56 | + sourceId: number; |
| 57 | + targetGraph: GraphName; |
| 58 | + targetId: number; |
| 59 | + kind: string; |
| 60 | +} |
| 61 | + |
| 62 | +export interface CrossLinkFilter { |
| 63 | + sourceGraph?: GraphName; |
| 64 | + sourceId?: number; |
| 65 | + targetGraph?: GraphName; |
| 66 | + targetId?: number; |
| 67 | + kind?: string; |
| 68 | +} |
| 69 | + |
| 70 | +// --------------------------------------------------------------------------- |
| 71 | +// Version conflict |
| 72 | +// --------------------------------------------------------------------------- |
| 73 | + |
| 74 | +export class VersionConflictError extends Error { |
| 75 | + constructor( |
| 76 | + public readonly current: number, |
| 77 | + public readonly expected: number, |
| 78 | + ) { |
| 79 | + super(`Version conflict: expected ${expected}, current is ${current}`); |
| 80 | + this.name = 'VersionConflictError'; |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +// --------------------------------------------------------------------------- |
| 85 | +// Relation (same-graph edge) |
| 86 | +// --------------------------------------------------------------------------- |
| 87 | + |
| 88 | +export interface Relation { |
| 89 | + fromId: number; |
| 90 | + toId: number; |
| 91 | + kind: string; |
| 92 | +} |
| 93 | + |
0 commit comments