import { IBaseRepository, BaseService } from './base-service.js';
import '../subsystems/events/event-bus.protocol.js';
import '../types/drizzle.js';
import 'drizzle-orm/node-postgres';

/**
 * IntegratedEntityService<TRepo, TEntity>
 *
 * Family-specific base service for Integrated entities.
 * Delegates to a CRM repository that provides external ID lookups
 * and user-scoped queries.
 */

interface IIntegratedEntityRepository<TEntity> extends IBaseRepository<TEntity> {
    findByExternalId(externalId: string): Promise<TEntity | null>;
    findManyByExternalIds(externalIds: string[]): Promise<TEntity[]>;
    findAllByUserId(userId: string): Promise<TEntity[]>;
    findVisibleByUserId(userId: string): Promise<TEntity[]>;
    integrationUpsert(inputs: Array<Partial<TEntity>>): Promise<TEntity[]>;
}
declare abstract class IntegratedEntityService<TRepo extends IIntegratedEntityRepository<TEntity>, TEntity> extends BaseService<TRepo, TEntity> {
    /**
     * Find a single entity by its external CRM identifier.
     */
    findByExternalId(externalId: string): Promise<TEntity | null>;
    /**
     * Find multiple entities by external CRM identifiers.
     */
    findManyByExternalIds(externalIds: string[]): Promise<TEntity[]>;
    /**
     * Find all entities owned by a specific user.
     */
    findAllByUser(userId: string): Promise<TEntity[]>;
    /**
     * Find entities visible to a user (ownership + sharing rules).
     * Concrete services may override with domain-specific visibility logic.
     */
    findVisibleByUser(userId: string): Promise<TEntity[]>;
}

export { type IIntegratedEntityRepository, IntegratedEntityService };
