import { prismaClient } from '../database/prismaClient.js';
export async function createTool(data) {
    return prismaClient.tool.create({
        data,
    });
}
export async function getTool(id) {
    return prismaClient.tool.findUnique({
        where: { id },
    });
}
export async function listTools() {
    return prismaClient.tool.findMany();
}
export async function listToolsFiltered(filters) {
    // Build `where` using Object.assign to keep it concise
    const where = {};
    Object.assign(where, {
        ...(filters?.functionName !== undefined && {
            function: {
                path: ['name'],
                equals: filters.functionName,
            },
        }),
        ...(filters?.verified !== undefined && { verified: filters.verified }),
        ...(filters?.agentId !== undefined && { agentId: filters.agentId }),
    });
    return prismaClient.tool.findMany({
        where,
        skip: filters?.offset,
        take: filters?.limit,
    });
}
export async function updateTool(id, data) {
    return prismaClient.tool.update({
        where: { id },
        data,
    });
}
export async function deleteTool(id) {
    return prismaClient.tool.delete({
        where: { id },
    });
}
