import { prismaClient } from '../database/prismaClient.js';
export async function createTool(data) {
    console.log(`Creating Tool with ID: ${data.id}`);
    return prismaClient.tool.create({
        data,
    });
}
export async function getTool(id) {
    console.log(`Getting Tool with ID: ${id}`);
    return prismaClient.tool.findUnique({
        where: { id },
    });
}
export async function listTools() {
    console.log('Listing all Tools');
    return prismaClient.tool.findMany();
}
export async function listToolsFiltered(filters) {
    console.log(`Listing Tools with filters: ${JSON.stringify(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 }),
    });
    return prismaClient.tool.findMany({
        where,
        skip: filters?.offset,
        take: filters?.limit,
    });
}
export async function updateTool(id, data) {
    console.log(`Updating Tool with ID: ${id}`);
    return prismaClient.tool.update({
        where: { id },
        data,
    });
}
export async function deleteTool(id) {
    console.log(`Deleting Tool with ID: ${id}`);
    return prismaClient.tool.delete({
        where: { id },
    });
}
