import { FilterValues, LogicalCondition, OrderByTuple } from "@rebasepro/types"; import type { VectorSearchParams } from "@rebasepro/types"; import { FetchService } from "./FetchService"; import { PersistService } from "./PersistService"; import { RelationService } from "./RelationService"; import { DataRepository, DrizzleClient } from "../interfaces"; import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry"; export { sanitizeAndConvertDates, serializeDataToServer, parseDataFromServer } from "../data-transformer"; export { FetchService } from "./FetchService"; export { PersistService } from "./PersistService"; export { RelationService } from "./RelationService"; export * from "../interfaces"; /** * DataService - Facade for row operations. * * This class provides a unified API for row CRUD operations by delegating * to specialized services: * - FetchService: Read operations (fetch, search, count) * - PersistService: Write operations (save, delete) * - RelationService: Relation operations (fetch related, update relations) * * Implements the DataRepository interface for database abstraction. */ export declare class DataService implements DataRepository { private db; private registry; private fetchService; private persistService; constructor(db: DrizzleClient, registry: PostgresCollectionRegistry); /** * Fetch a single row by ID */ fetchOne>(collectionPath: string, id: string | number, databaseId?: string): Promise | undefined>; /** * Fetch a collection of rows with optional filtering, ordering, and pagination */ fetchCollection>(collectionPath: string, options?: { filter?: FilterValues>; /** An `or(...)`/`and(...)` group, applied alongside `filter`. */ logical?: LogicalCondition; orderBy?: string | OrderByTuple[]; order?: "desc" | "asc"; limit?: number; offset?: number; startAfter?: Record; searchString?: string; databaseId?: string; vectorSearch?: VectorSearchParams; }): Promise[]>; /** * Search rows by text */ searchRows>(collectionPath: string, searchString: string, options?: { filter?: FilterValues>; /** An `or(...)`/`and(...)` group, applied alongside `filter`. */ logical?: LogicalCondition; orderBy?: string | OrderByTuple[]; order?: "desc" | "asc"; limit?: number; databaseId?: string; searchExplain?: boolean; }): Promise[]>; /** * Count rows in a collection */ count>(collectionPath: string, options?: { filter?: FilterValues>; /** An `or(...)`/`and(...)` group, applied alongside `filter`. */ logical?: LogicalCondition; searchString?: string; databaseId?: string; /** Only the `threshold` narrows the count — see `FetchService.count`. */ vectorSearch?: VectorSearchParams; }): Promise; /** * Check if a field value is unique in a collection */ checkUniqueField(collectionPath: string, fieldName: string, value: unknown, excludeEntityId?: string, databaseId?: string): Promise; /** * Fetch rows related to a parent row */ fetchRelatedEntities>(parentCollectionPath: string, parentId: string | number, relationKey: string, options?: { filter?: FilterValues>; orderBy?: string | OrderByTuple[]; order?: "desc" | "asc"; limit?: number; startAfter?: Record; searchString?: string; databaseId?: string; }): Promise[]>; /** * Save an row (create or update) */ save>(collectionPath: string, values: Partial, id?: string | number, databaseId?: string, options?: { upsert?: boolean; }): Promise>; /** * Delete an row by ID */ delete(collectionPath: string, id: string | number, databaseId?: string): Promise; /** * Delete all rows from a collection */ deleteAll(collectionPath: string, databaseId?: string): Promise; /** * Execute raw SQL */ executeSql(sqlText: string, params?: unknown[]): Promise[]>; /** * Get the underlying FetchService for advanced use */ getFetchService(): FetchService; /** * Get the underlying PersistService for advanced use */ getPersistService(): PersistService; /** * Get the underlying RelationService for advanced use */ getRelationService(): RelationService; }