/**
 * Base Entity Service
 *
 * Provides standard CRUD operations for entities with RLS support.
 * Entities extend this class and get type-safe operations out of the box.
 *
 * @example
 * ```typescript
 * export class ProductsService extends BaseEntityService<Product, CreateProduct, UpdateProduct> {
 *   constructor() {
 *     super({
 *       tableName: 'products',
 *       fields: ['title', 'description', 'status'],
 *       searchableFields: ['title'],
 *     })
 *   }
 *
 *   // Custom methods when needed
 *   async getByStatus(userId: string, status: string): Promise<Product[]> {
 *     return this.query(userId, {
 *       where: { status },
 *       orderBy: 'createdAt',
 *       orderDir: 'desc',
 *     })
 *   }
 * }
 * ```
 *
 * @module BaseEntityService
 */
export interface ListOptions {
    limit?: number;
    offset?: number;
    orderBy?: string;
    orderDir?: 'asc' | 'desc';
    where?: Record<string, unknown>;
    search?: string;
}
export interface ListResult<T> {
    data: T[];
    total: number;
    limit: number;
    offset: number;
}
export interface EntityServiceConfig {
    /** Database table name (snake_case, e.g., 'products' or 'blog_posts') */
    tableName: string;
    /** Entity fields that can be selected/inserted/updated (excluding system fields) */
    fields: string[];
    /** Fields that support text search (optional) */
    searchableFields?: string[];
    /** Default order by field */
    defaultOrderBy?: string;
    /** Default order direction */
    defaultOrderDir?: 'asc' | 'desc';
    /** Default page size */
    defaultLimit?: number;
}
export declare abstract class BaseEntityService<TEntity, TCreate = Partial<TEntity>, TUpdate = Partial<TEntity>> {
    protected config: Required<EntityServiceConfig>;
    constructor(config: EntityServiceConfig);
    /**
     * Get all selectable fields (entity fields + system fields)
     */
    protected get selectFields(): string[];
    /**
     * Build SELECT clause with proper quoting
     */
    protected buildSelectClause(): string;
    /**
     * Quote a field name if needed
     */
    protected quoteField(field: string): string;
    /**
     * Build WHERE clause from conditions
     */
    protected buildWhereClause(where: Record<string, unknown>, startIndex?: number): {
        clause: string;
        params: unknown[];
        nextIndex: number;
    };
    /**
     * Build search condition for text search
     */
    protected buildSearchCondition(search: string, paramIndex: number): {
        condition: string;
        param: string;
    } | null;
    /**
     * Map database row to entity (override for custom mapping)
     */
    protected mapRowToEntity(row: Record<string, unknown>): TEntity;
    /**
     * Get entity by ID
     *
     * @param id - Entity ID
     * @param userId - Current user ID for RLS
     * @returns Entity or null if not found
     */
    getById(id: string, userId: string): Promise<TEntity | null>;
    /**
     * List entities with pagination, filtering, and search
     *
     * @param userId - Current user ID for RLS
     * @param options - List options (limit, offset, where, search, orderBy)
     * @returns Paginated result with data and total count
     */
    list(userId: string, options?: ListOptions): Promise<ListResult<TEntity>>;
    /**
     * Query entities with custom conditions (simpler than list)
     *
     * @param userId - Current user ID for RLS
     * @param options - Query options
     * @returns Array of entities
     */
    query(userId: string, options?: Omit<ListOptions, 'offset'>): Promise<TEntity[]>;
    /**
     * Create a new entity
     *
     * @param userId - Current user ID for RLS and ownership
     * @param teamId - Team ID for team isolation
     * @param data - Entity data
     * @returns Created entity
     */
    create(userId: string, teamId: string, data: TCreate): Promise<TEntity>;
    /**
     * Update an existing entity
     *
     * @param id - Entity ID
     * @param userId - Current user ID for RLS
     * @param data - Fields to update
     * @returns Updated entity
     */
    update(id: string, userId: string, data: TUpdate): Promise<TEntity>;
    /**
     * Delete an entity
     *
     * @param id - Entity ID
     * @param userId - Current user ID for RLS
     * @returns true if deleted, false if not found
     */
    delete(id: string, userId: string): Promise<boolean>;
    /**
     * Check if an entity exists
     *
     * @param id - Entity ID
     * @param userId - Current user ID for RLS
     * @returns true if exists and accessible
     */
    exists(id: string, userId: string): Promise<boolean>;
    /**
     * Count entities with optional filtering
     *
     * @param userId - Current user ID for RLS
     * @param where - Filter conditions
     * @returns Count of matching entities
     */
    count(userId: string, where?: Record<string, unknown>): Promise<number>;
}
//# sourceMappingURL=base-entity.service.d.ts.map