import { Router } from 'express';
import { TurboGateway } from '../../core/gateway/TurboGateway';
import { requireTraceContext } from '../../core/guards/trace-context.guard';
import { requirePermission } from '../../core/guards/rbac.guard';
import { ProductController } from '../controllers/ProductController';

const router = Router();

// Standard CRUD
router.get('/', TurboGateway.cache(300), ProductController.getAll);

// Enhanced Crawlful AI functions
router.post('/autonomous-listing', requireTraceContext, ProductController.startAutonomousListing);
router.post('/collect-async', requireTraceContext, ProductController.collectAsync);
router.get('/collect-and-optimize', TurboGateway.throttle(10, 60000), ProductController.collectAndOptimize);
router.get('/:id/arbitrage-analyze', requireTraceContext, ProductController.analyzeArbitrage);
router.get('/visual-match', TurboGateway.cache(600), ProductController.findSimilar);
router.post('/:id/review', requireTraceContext, requirePermission('product:write'), ProductController.approve);
router.post('/:id/pulse', requireTraceContext, ProductController.checkPulse);
router.post('/:id/wash', requireTraceContext, requirePermission('product:write'), ProductController.washAndLocalize);
router.post('/:id/inquiry', requireTraceContext, requirePermission('product:write'), ProductController.generateInquiry);
router.get('/:id/price-advice', ProductController.getPriceAdvice);
router.get('/:id', TurboGateway.cache(300), ProductController.getById);
router.post('/', requireTraceContext, requirePermission('product:write'), ProductController.create);
router.put('/:id', requireTraceContext, requirePermission('product:write'), ProductController.update);
router.delete('/:id', requireTraceContext, requirePermission('product:delete'), ProductController.delete);

export default router;
