115 lines
4.3 KiB
JavaScript
115 lines
4.3 KiB
JavaScript
import { z } from 'zod';
|
|
export function registerInventoryTools(client) {
|
|
return [
|
|
{
|
|
name: 'toast_list_inventory_items',
|
|
description: 'List all inventory items',
|
|
inputSchema: z.object({
|
|
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.inventory.listItems({
|
|
page: args.page,
|
|
pageSize: args.pageSize,
|
|
});
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_get_inventory_item',
|
|
description: 'Get details of a specific inventory item',
|
|
inputSchema: z.object({
|
|
itemGuid: z.string().describe('Inventory item GUID'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.inventory.getItem(args.itemGuid);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_update_inventory_count',
|
|
description: 'Update the current quantity of an inventory item',
|
|
inputSchema: z.object({
|
|
itemGuid: z.string().describe('Inventory item GUID'),
|
|
quantity: z.number().describe('New quantity'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.inventory.updateCount(args.itemGuid, args.quantity);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_list_vendors',
|
|
description: 'List all vendors',
|
|
inputSchema: z.object({}),
|
|
execute: async (args) => {
|
|
const result = await client.inventory.listVendors();
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_create_purchase_order',
|
|
description: 'Create a new purchase order',
|
|
inputSchema: z.object({
|
|
vendorGuid: z.string().describe('Vendor GUID'),
|
|
expectedDeliveryDate: z.string().optional().describe('Expected delivery date (ISO 8601)'),
|
|
items: z.array(z.object({
|
|
itemGuid: z.string(),
|
|
quantity: z.number(),
|
|
unitCost: z.number(),
|
|
})).describe('Purchase order items'),
|
|
}),
|
|
execute: async (args) => {
|
|
const poData = {
|
|
vendor: { guid: args.vendorGuid },
|
|
...(args.expectedDeliveryDate && { expectedDeliveryDate: args.expectedDeliveryDate }),
|
|
items: args.items.map((item) => ({
|
|
inventoryItem: { guid: item.itemGuid },
|
|
quantity: item.quantity,
|
|
unitCost: item.unitCost,
|
|
totalCost: item.quantity * item.unitCost,
|
|
})),
|
|
};
|
|
const result = await client.inventory.createPurchaseOrder(poData);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
];
|
|
}
|
|
//# sourceMappingURL=inventory-tools.js.map
|