=== UPDATES === - fieldedge: Added apps, tools, main server entry, full rebuild - lightspeed: Added complete src/ directory with tools + apps - squarespace: Full rebuild — new apps, clients, tools, types modules - toast: Full rebuild — api-client, apps, tools, types - touchbistro: Full rebuild — api-client, tools, types, gitignore - servicetitan: Added 4 React UI apps (call-tracking, lead-source-analytics, performance-metrics, schedule-calendar) All servers restructured from single-file to modular architecture.
143 lines
4.3 KiB
TypeScript
143 lines
4.3 KiB
TypeScript
import { z } from 'zod';
|
|
import type { ToastAPIClient } from '../api-client.js';
|
|
|
|
export function registerReportingTools(client: ToastAPIClient) {
|
|
return [
|
|
{
|
|
name: 'toast_sales_summary',
|
|
description: 'Get sales summary report for a date range',
|
|
inputSchema: z.object({
|
|
startDate: z.string().describe('Start date (ISO 8601 format)'),
|
|
endDate: z.string().describe('End date (ISO 8601 format)'),
|
|
}),
|
|
execute: async (args: any) => {
|
|
// This would aggregate data from orders and payments
|
|
const orders = await client.orders.list({
|
|
startDate: args.startDate,
|
|
endDate: args.endDate,
|
|
});
|
|
|
|
const payments = await client.payments.list(args.startDate, args.endDate);
|
|
|
|
// Calculate summary metrics
|
|
const summary = {
|
|
dateRange: { startDate: args.startDate, endDate: args.endDate },
|
|
orders: orders.data,
|
|
payments: payments.data,
|
|
summary: {
|
|
totalOrders: orders.totalCount,
|
|
totalPayments: payments.totalCount,
|
|
message: 'Sales summary data retrieved. Process orders and payments to calculate metrics.',
|
|
},
|
|
};
|
|
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(summary, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_labor_cost_report',
|
|
description: 'Get labor cost report for a business date',
|
|
inputSchema: z.object({
|
|
businessDate: z.string().describe('Business date (YYYYMMDD format)'),
|
|
}),
|
|
execute: async (args: any) => {
|
|
const result = await client.labor.getLaborCost(args.businessDate);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_menu_item_performance',
|
|
description: 'Get menu item sales performance for a date range',
|
|
inputSchema: z.object({
|
|
startDate: z.string().describe('Start date (ISO 8601 format)'),
|
|
endDate: z.string().describe('End date (ISO 8601 format)'),
|
|
}),
|
|
execute: async (args: any) => {
|
|
// Fetch orders and aggregate item sales
|
|
const orders = await client.orders.list({
|
|
startDate: args.startDate,
|
|
endDate: args.endDate,
|
|
});
|
|
|
|
const report = {
|
|
dateRange: { startDate: args.startDate, endDate: args.endDate },
|
|
orders: orders.data,
|
|
message: 'Menu item performance data retrieved. Process order selections to calculate metrics.',
|
|
};
|
|
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(report, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_revenue_by_hour',
|
|
description: 'Get revenue breakdown by hour for a date range',
|
|
inputSchema: z.object({
|
|
startDate: z.string().describe('Start date (ISO 8601 format)'),
|
|
endDate: z.string().describe('End date (ISO 8601 format)'),
|
|
}),
|
|
execute: async (args: any) => {
|
|
const orders = await client.orders.list({
|
|
startDate: args.startDate,
|
|
endDate: args.endDate,
|
|
});
|
|
|
|
const report = {
|
|
dateRange: { startDate: args.startDate, endDate: args.endDate },
|
|
orders: orders.data,
|
|
message: 'Hourly revenue data retrieved. Process order timestamps to calculate hourly breakdown.',
|
|
};
|
|
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(report, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_tip_summary',
|
|
description: 'Get tip summary report for a date range',
|
|
inputSchema: z.object({
|
|
startDate: z.string().describe('Start date (ISO 8601 format)'),
|
|
endDate: z.string().describe('End date (ISO 8601 format)'),
|
|
}),
|
|
execute: async (args: any) => {
|
|
const tips = await client.payments.listTips(args.startDate, args.endDate);
|
|
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(tips, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
];
|
|
}
|