import { prismaClient } from '../database/prismaClient.js';
export async function createAgent(data) {
    return prismaClient.agent.create({
        data,
    });
}
export async function getAgent(id) {
    return prismaClient.agent.findUnique({
        where: { id },
    });
}
export async function listAgents() {
    return prismaClient.agent.findMany();
}
export async function listAgentsFiltered(filters) {
    const chainIdsInBigInt = filters?.chainIds?.length
        ? filters.chainIds.map((chainId) => BigInt(chainId))
        : null;
    // Build `where` using Object.assign to keep it concise
    const where = {};
    Object.assign(where, {
        ...(chainIdsInBigInt && { chainIds: { hasEvery: chainIdsInBigInt } }),
        ...(filters?.verified !== undefined && { verified: filters.verified }),
        ...(filters?.categories?.length && {
            categories: { hasEvery: filters.categories },
        }),
        ...(filters?.accountId !== undefined && { accountId: filters.accountId }),
    });
    return prismaClient.agent.findMany({
        where,
        skip: filters?.offset,
        take: filters?.limit,
    });
}
export async function updateAgent(id, data) {
    return prismaClient.agent.update({
        where: { id },
        data,
    });
}
export async function deleteAgent(id) {
    return prismaClient.agent.delete({
        where: { id },
    });
}
