🎯 Objective
Develop a comprehensive TypeScript service layer for the Product Follow Contract that manages product following, notifications, alerts, and user preferences within the StarShop marketplace.
🏗 Service Structure
src/shared/services/product_follow/
follow.service.ts // Main service class
types/
follow.types.ts // TypeScript interfaces
notification.types.ts // Notification types
alert.types.ts // Alert types
utils/
follow.utils.ts // Helper functions
constants/
follow.constants.ts // Contract addresses, error codes
🗂 Requirements
1. Follow Management
followProduct(productId, user) - Follow product
unfollowProduct(productId, user) - Unfollow product
getFollowers(productId) - Get product followers
getFollowing(user) - Get user's followed products
isFollowing(productId, user) - Check if user follows product
2. Notification Management
setNotificationPreferences(user, preferences) - Set preferences
getNotificationPreferences(user) - Get preferences
sendNotification(productId, type, data) - Send notification
getNotificationHistory(user) - Get notification history
3. Alert Management
createAlert(productId, conditions) - Create price/stock alert
updateAlert(alertId, conditions) - Update alert
deleteAlert(alertId) - Delete alert
getAlerts(user) - Get user's alerts
triggerAlert(alertId) - Trigger alert
4. Rate Limiting & Validation
checkRateLimit(user, action) - Check rate limits
validateNotificationFormat(data) - Validate notification
validateUserPreferences(preferences) - Validate preferences
🎯 Objective
Develop a comprehensive TypeScript service layer for the Product Follow Contract that manages product following, notifications, alerts, and user preferences within the StarShop marketplace.
🏗 Service Structure
🗂 Requirements
1. Follow Management
followProduct(productId, user)- Follow productunfollowProduct(productId, user)- Unfollow productgetFollowers(productId)- Get product followersgetFollowing(user)- Get user's followed productsisFollowing(productId, user)- Check if user follows product2. Notification Management
setNotificationPreferences(user, preferences)- Set preferencesgetNotificationPreferences(user)- Get preferencessendNotification(productId, type, data)- Send notificationgetNotificationHistory(user)- Get notification history3. Alert Management
createAlert(productId, conditions)- Create price/stock alertupdateAlert(alertId, conditions)- Update alertdeleteAlert(alertId)- Delete alertgetAlerts(user)- Get user's alertstriggerAlert(alertId)- Trigger alert4. Rate Limiting & Validation
checkRateLimit(user, action)- Check rate limitsvalidateNotificationFormat(data)- Validate notificationvalidateUserPreferences(preferences)- Validate preferences