/** * Warehouse Service * * Unified data warehouse interface for querying and writing data across * databases, graphs, and vector stores using a single JSON interface. * * Features: * - Cross-database joins (hash, nested loop, sort-merge) * - Semantic joins (vector similarity) * - Graph traversal joins * - Unified where clauses * - Distributed transactions (Saga pattern) * - Query parsing and validation */ import { DatabaseService } from '../database/databases.service'; import { GraphService } from '../graph/graphs.service'; import { VectorDatabaseService } from '../vector/vector-database.service'; import { IWarehouseQuery, IWarehouseResult, IDataSource, ISagaTransaction, ISagaResult, DataSourceType } from './types'; import { IRegistryConfig } from './registry'; /** * Warehouse service configuration */ export interface IWarehouseConfig { /** Registry configuration */ registry?: IRegistryConfig; /** Default query timeout (ms) */ defaultTimeout?: number; /** Enable query caching */ enableCache?: boolean; /** Cache TTL (seconds) */ cacheTtl?: number; /** Maximum join memory (bytes) */ maxJoinMemory?: number; /** Enable parallel execution */ parallel?: boolean; /** Embedding function for semantic joins */ embedFn?: (text: string) => Promise; } /** * Context for warehouse operations */ export interface IWarehouseContext { /** Default environment */ env: string; /** Default product */ product: string; } /** * Warehouse Service * * Main entry point for the unified data warehouse interface. * Orchestrates queries across databases, graphs, and vector stores. */ export declare class WarehouseService { private readonly databaseService; private readonly graphService; private readonly vectorService; private readonly context; private readonly config; private readonly registry; private readonly parser; private readonly singleSourceExecutor; private readonly joinExecutor; private readonly semanticJoinExecutor; private readonly sagaOrchestrator; constructor(databaseService: DatabaseService, graphService: GraphService, vectorService: VectorDatabaseService, context: IWarehouseContext, config?: IWarehouseConfig); /** * Register a database data source */ registerDatabase(tag: string, env?: string, product?: string): Promise; /** * Register a graph data source */ registerGraph(tag: string, env?: string, product?: string): Promise; /** * Register a vector data source */ registerVector(tag: string, env?: string, product?: string): Promise; /** * Get registered data sources */ getDataSources(type?: DataSourceType): import("./registry").IRegisteredDataSource[]; /** * Execute a warehouse query * * @example * // Simple database query * const result = await warehouse.query({ * operation: 'select', * from: { type: 'database', tag: 'users-pg', entity: 'users', alias: 'u' }, * fields: ['u.id', 'u.name', 'u.email'], * where: { 'u.status': { $eq: 'active' } }, * limit: 100 * }); * * @example * // Cross-database join * const result = await warehouse.query({ * operation: 'select', * from: { type: 'database', tag: 'users-pg', entity: 'users', alias: 'u' }, * fields: ['u.name', 'o.total'], * join: [{ * type: 'left', * source: { type: 'database', tag: 'orders-mongo', entity: 'orders', alias: 'o' }, * on: { left: 'u.id', right: 'o.userId' } * }], * where: { 'u.status': { $eq: 'active' } } * }); * * @example * // Semantic join (vector similarity) * const result = await warehouse.query({ * operation: 'select', * from: { type: 'database', tag: 'products-pg', entity: 'products', alias: 'p' }, * join: [{ * type: 'semantic', * source: { type: 'vector', tag: 'embeddings-pinecone', entity: 'products', alias: 's' }, * semantic: { embedField: 'p.description', similarityThreshold: 0.8, topK: 5 } * }] * }); */ query>(query: IWarehouseQuery): Promise>; /** * Execute a single query (for saga orchestrator) */ private executeSingleQuery; /** * Select from a single source */ select>(source: IDataSource, options?: { fields?: string[]; where?: Record; orderBy?: { field: string; order: 'ASC' | 'DESC'; }[]; limit?: number; offset?: number; }): Promise; /** * Insert into a source */ insert>(source: IDataSource, data: Record | Record[], options?: { returning?: boolean; }): Promise>; /** * Update in a source */ update>(source: IDataSource, data: Record, where: Record, options?: { returning?: boolean; }): Promise>; /** * Delete from a source */ delete>(source: IDataSource, where: Record, options?: { returning?: boolean; }): Promise>; /** * Upsert into a source */ upsert>(source: IDataSource, data: Record, options?: { returning?: boolean; }): Promise>; /** * Execute multiple operations in a saga transaction */ transaction(operations: Omit[], options?: Partial): Promise; /** * Execute a single-source query */ private executeSingleSource; /** * Execute a query with cross-database joins */ private executeWithJoins; /** * Execute a single join operation */ private executeJoin; /** * Execute a graph traversal join */ private executeGraphJoin; /** * Execute query with transaction */ private executeWithTransaction; /** * Merge two rows */ private mergeRows; /** * Project result to requested fields */ private projectFields; /** * Clean up resources */ destroy(): void; }