delete-journal-entry.tool.ts•1.52 kB
import { deleteQuickbooksJournalEntry } from "../handlers/delete-quickbooks-journal-entry.handler.js";
import { ToolDefinition } from "../types/tool-definition.js";
import { z } from "zod";
// Define the tool metadata
const toolName = "delete_journal_entry";
const toolTitle = "Delete Journal Entry";
const toolDescription = "Delete (make inactive) a journal entry in QuickBooks Online.";
// Define the expected input schema for deleting a journal entry
const inputSchema = {
idOrEntity: z.any(),
};
const outputSchema = {
success: z.boolean().describe("Whether the operation was successful"),
data: z.any().optional().describe("The result data"),
error: z.string().optional().describe("Error message if operation failed"),
};
// Define the tool handler
const toolHandler = async (params: z.infer<z.ZodObject<typeof inputSchema>>) => {
const response = await deleteQuickbooksJournalEntry(params.idOrEntity);
if (response.isError) {
return {
content: [
{ type: "text" as const, text: `Error deleting journal entry: ${response.error}` },
],
};
}
return {
content: [
{ type: "text" as const, text: `Journal entry deleted:` },
{ type: "text" as const, text: JSON.stringify(response.result) },
],
};
};
export const DeleteJournalEntryTool: ToolDefinition<typeof inputSchema, typeof outputSchema> = {
name: toolName,
title: toolTitle,
description: toolDescription,
inputSchema: inputSchema,
outputSchema: outputSchema,
handler: toolHandler,
};