amazon-seller-mcp
Version:
Model Context Protocol (MCP) client for Amazon Selling Partner API
179 lines (178 loc) • 4.47 kB
TypeScript
/**
* Order notifications handler
*
* This file implements the order status change notification handler
*/
import { NotificationManager } from './notifications.js';
import { OrdersClient } from '../api/orders-client.js';
/**
* Order status change event data
*/
export interface OrderStatusChangeEvent {
/**
* Order ID
*/
orderId: string;
/**
* Previous status
*/
previousStatus: string;
/**
* New status
*/
newStatus: string;
/**
* Marketplace ID
*/
marketplaceId: string;
/**
* Timestamp of the change
*/
timestamp: string;
/**
* Additional order details
*/
orderDetails?: {
/**
* Purchase date
*/
purchaseDate: string;
/**
* Order total
*/
orderTotal?: {
currencyCode: string;
amount: number;
};
/**
* Fulfillment channel
*/
fulfillmentChannel?: string;
/**
* Number of items
*/
numberOfItems?: number;
};
}
/**
* Order monitoring configuration
*/
export interface OrderMonitoringConfig {
/**
* Whether to enable periodic order status monitoring
*/
enablePeriodicMonitoring?: boolean;
/**
* Monitoring interval in milliseconds (default: 5 minutes)
*/
monitoringInterval?: number;
/**
* Maximum number of orders to monitor per check (default: 100)
*/
maxOrdersPerCheck?: number;
/**
* How far back to look for orders to monitor (in hours, default: 24)
*/
monitoringWindowHours?: number;
}
/**
* Order status monitor class
*/
export declare class OrderStatusMonitor {
private ordersClient;
private notificationManager;
private config;
private monitoringInterval;
private orderStatusCache;
private isMonitoring;
constructor(ordersClient: OrdersClient, notificationManager: NotificationManager, config?: OrderMonitoringConfig);
/**
* Starts monitoring order status changes
*/
startMonitoring(): void;
/**
* Stops monitoring order status changes
*/
stopMonitoring(): void;
/**
* Checks for order status changes
*/
private checkOrderStatusChanges;
/**
* Checks a single order for status changes
*/
private checkSingleOrderStatusChange;
/**
* Manually checks a specific order for status changes
*/
checkOrderStatus(orderId: string): Promise<void>;
/**
* Gets the current monitoring status
*/
isMonitoringActive(): boolean;
/**
* Gets the monitoring configuration
*/
getConfig(): OrderMonitoringConfig;
/**
* Updates the monitoring configuration
*/
updateConfig(newConfig: Partial<OrderMonitoringConfig>): void;
/**
* Clears the order status cache
*/
clearCache(): void;
/**
* Gets the current cache size
*/
getCacheSize(): number;
}
/**
* Enhanced order status change notification handler
*/
export declare class OrderStatusChangeHandler {
private ordersClient;
private notificationManager;
private statusMonitor;
constructor(ordersClient: OrdersClient, notificationManager: NotificationManager, monitoringConfig?: OrderMonitoringConfig);
/**
* Sets up order status change notifications
*/
setup(): void;
/**
* Sets up notifications for updateOrderStatus method calls
*/
private setupUpdateOrderStatusNotifications;
/**
* Maps an action to the expected new status
*/
private mapActionToStatus;
/**
* Gets the status monitor
*/
getStatusMonitor(): OrderStatusMonitor;
/**
* Manually checks an order for status changes
*/
checkOrderStatus(orderId: string): Promise<void>;
/**
* Starts monitoring
*/
startMonitoring(): void;
/**
* Stops monitoring
*/
stopMonitoring(): void;
/**
* Cleanup method
*/
cleanup(): void;
}
/**
* Sets up order status change notifications (backward compatibility)
*
* @param ordersClient Orders client
* @param notificationManager Notification manager
* @param monitoringConfig Optional monitoring configuration
*/
export declare function setupOrderStatusChangeNotifications(ordersClient: OrdersClient, notificationManager: NotificationManager, monitoringConfig?: OrderMonitoringConfig): OrderStatusChangeHandler;