faturas.js•2.77 kB
export const faturaTools = [
{
name: "list_faturas",
description: "List faturas with optional filtering and pagination",
inputSchema: {
type: "object",
properties: {
filter: { type: "string", description: "Filter query (JSON string)" },
orderBy: { type: "string", description: "Order by field" },
limit: { type: "number", description: "Number of results (max 100)" },
depth: { type: "number", description: "Query depth for relations" },
startingAfter: { type: "string", description: "Cursor for pagination" },
endingBefore: { type: "string", description: "Cursor for pagination" }
}
}
},
{
name: "create_fatura",
description: "Create a new fatura in Twenty CRM",
inputSchema: {
type: "object",
properties: {
name: { type: "string", description: "Fatura name" },
status: { type: "string", description: "Fatura status" },
position: { type: "number", description: "Position" }
}
}
},
{
name: "get_fatura",
description: "Get details of a specific fatura by ID",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Fatura ID" },
depth: { type: "number", description: "Query depth for relations" }
},
required: ["id"]
}
},
{
name: "update_fatura",
description: "Update an existing fatura's information",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Fatura ID" },
name: { type: "string" },
status: { type: "string" },
position: { type: "number" }
},
required: ["id"]
}
},
{
name: "delete_fatura",
description: "Delete a fatura from Twenty CRM",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Fatura ID" }
},
required: ["id"]
}
}
];
export async function executeFaturaTool(toolName, params, apiClient) {
switch (toolName) {
case "list_faturas":
return await apiClient.makeRequest("/faturas", "GET", null, params);
case "create_fatura":
return await apiClient.makeRequest("/faturas", "POST", params);
case "get_fatura":
return await apiClient.makeRequest(`/faturas/${params.id}`, "GET", null, { depth: params.depth });
case "update_fatura":
const { id: faturaId, ...faturaData } = params;
return await apiClient.makeRequest(`/faturas/${faturaId}`, "PUT", faturaData);
case "delete_fatura":
return await apiClient.makeRequest(`/faturas/${params.id}`, "DELETE");
default:
throw new Error(`Unknown fatura tool: ${toolName}`);
}
}