227 lines
9.4 KiB
JavaScript
227 lines
9.4 KiB
JavaScript
import { z } from 'zod';
|
|
export function registerOrdersTools(client) {
|
|
return [
|
|
{
|
|
name: 'toast_list_orders',
|
|
description: 'List orders with optional date range filter',
|
|
inputSchema: z.object({
|
|
startDate: z.string().optional().describe('Start date (ISO 8601 format)'),
|
|
endDate: z.string().optional().describe('End date (ISO 8601 format)'),
|
|
page: z.number().optional().describe('Page number (default: 1)'),
|
|
pageSize: z.number().optional().describe('Items per page (default: 100)'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.orders.list({
|
|
startDate: args.startDate,
|
|
endDate: args.endDate,
|
|
pagination: {
|
|
page: args.page,
|
|
pageSize: args.pageSize,
|
|
},
|
|
});
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_get_order',
|
|
description: 'Get details of a specific order by ID',
|
|
inputSchema: z.object({
|
|
orderId: z.string().describe('Order GUID'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.orders.get(args.orderId);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_create_order',
|
|
description: 'Create a new order',
|
|
inputSchema: z.object({
|
|
diningOptionGuid: z.string().describe('Dining option GUID'),
|
|
revenueCenterGuid: z.string().optional().describe('Revenue center GUID'),
|
|
tableGuid: z.string().optional().describe('Table GUID'),
|
|
numberOfGuests: z.number().optional().describe('Number of guests'),
|
|
estimatedFulfillmentDate: z.string().optional().describe('Estimated fulfillment date (ISO 8601)'),
|
|
}),
|
|
execute: async (args) => {
|
|
const orderData = {
|
|
diningOption: { guid: args.diningOptionGuid },
|
|
...(args.revenueCenterGuid && { revenueCenterGuid: args.revenueCenterGuid }),
|
|
...(args.tableGuid && { table: { guid: args.tableGuid } }),
|
|
...(args.numberOfGuests && { numberOfGuests: args.numberOfGuests }),
|
|
...(args.estimatedFulfillmentDate && { estimatedFulfillmentDate: args.estimatedFulfillmentDate }),
|
|
};
|
|
const result = await client.orders.create(orderData);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_update_order',
|
|
description: 'Update an existing order',
|
|
inputSchema: z.object({
|
|
orderId: z.string().describe('Order GUID'),
|
|
numberOfGuests: z.number().optional().describe('Number of guests'),
|
|
tableGuid: z.string().optional().describe('Table GUID'),
|
|
estimatedFulfillmentDate: z.string().optional().describe('Estimated fulfillment date (ISO 8601)'),
|
|
}),
|
|
execute: async (args) => {
|
|
const updateData = {};
|
|
if (args.numberOfGuests !== undefined)
|
|
updateData.numberOfGuests = args.numberOfGuests;
|
|
if (args.tableGuid)
|
|
updateData.table = { guid: args.tableGuid };
|
|
if (args.estimatedFulfillmentDate)
|
|
updateData.estimatedFulfillmentDate = args.estimatedFulfillmentDate;
|
|
const result = await client.orders.update(args.orderId, updateData);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_add_order_item',
|
|
description: 'Add an item to an order check',
|
|
inputSchema: z.object({
|
|
orderId: z.string().describe('Order GUID'),
|
|
checkGuid: z.string().describe('Check GUID'),
|
|
itemGuid: z.string().describe('Menu item GUID'),
|
|
quantity: z.number().describe('Quantity'),
|
|
modifiers: z.array(z.object({
|
|
guid: z.string(),
|
|
quantity: z.number().optional(),
|
|
})).optional().describe('Item modifiers'),
|
|
specialRequest: z.string().optional().describe('Special instructions'),
|
|
}),
|
|
execute: async (args) => {
|
|
const itemData = {
|
|
item: { guid: args.itemGuid },
|
|
quantity: args.quantity,
|
|
...(args.modifiers && { modifiers: args.modifiers }),
|
|
...(args.specialRequest && { specialRequest: args.specialRequest }),
|
|
};
|
|
const result = await client.orders.addItem(args.orderId, args.checkGuid, itemData);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_remove_order_item',
|
|
description: 'Remove an item from an order check',
|
|
inputSchema: z.object({
|
|
orderId: z.string().describe('Order GUID'),
|
|
checkGuid: z.string().describe('Check GUID'),
|
|
selectionGuid: z.string().describe('Selection GUID to remove'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.orders.removeItem(args.orderId, args.checkGuid, args.selectionGuid);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: 'Item removed successfully',
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_apply_discount',
|
|
description: 'Apply a discount to an order check',
|
|
inputSchema: z.object({
|
|
orderId: z.string().describe('Order GUID'),
|
|
checkGuid: z.string().describe('Check GUID'),
|
|
discountGuid: z.string().optional().describe('Discount configuration GUID'),
|
|
discountAmount: z.number().optional().describe('Discount amount (for fixed amount)'),
|
|
discountPercent: z.number().optional().describe('Discount percentage (0-100)'),
|
|
}),
|
|
execute: async (args) => {
|
|
const discountData = {};
|
|
if (args.discountGuid)
|
|
discountData.guid = args.discountGuid;
|
|
if (args.discountAmount !== undefined)
|
|
discountData.amount = args.discountAmount;
|
|
if (args.discountPercent !== undefined)
|
|
discountData.discountPercent = args.discountPercent;
|
|
const result = await client.orders.applyDiscount(args.orderId, args.checkGuid, discountData);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_void_order',
|
|
description: 'Void an entire order',
|
|
inputSchema: z.object({
|
|
orderId: z.string().describe('Order GUID'),
|
|
voidReason: z.string().optional().describe('Reason for voiding'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.orders.void(args.orderId, args.voidReason);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_list_order_checks',
|
|
description: 'List all checks for an order',
|
|
inputSchema: z.object({
|
|
orderId: z.string().describe('Order GUID'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.orders.listChecks(args.orderId);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
];
|
|
}
|
|
//# sourceMappingURL=orders-tools.js.map
|