"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bulkGeocodeRouter = void 0;
const express_1 = require("express");
const geocode_queue_service_1 = require("../../../services/geocode-queue.service");
const bulk_geocode_schemas_1 = require("./bulk-geocode.schemas");
const validate_1 = require("../../../middleware/validate");
const auth_middleware_1 = require("../../../middleware/auth.middleware");
const rbac_middleware_1 = require("../../../middleware/rbac.middleware");
const roles_1 = require("../../../utils/roles");
const router = (0, express_1.Router)();
exports.bulkGeocodeRouter = router;
router.use(auth_middleware_1.authenticate);
router.use((0, rbac_middleware_1.requireRole)(...roles_1.MAP_ROLES));
// POST /api/map/locations/bulk-geocode — start bulk geocoding job
router.post('/', (0, validate_1.validate)(bulk_geocode_schemas_1.bulkGeocodeSchema), async (req, res, next) => {
    try {
        const jobId = await geocode_queue_service_1.geocodeQueueService.startBulkGeocode(req.user.id, req.body);
        res.json({ jobId, message: 'Bulk geocoding job started' });
    }
    catch (err) {
        next(err);
    }
});
// GET /api/map/locations/bulk-geocode/:jobId — get job status
router.get('/:jobId', async (req, res, next) => {
    try {
        const status = await geocode_queue_service_1.geocodeQueueService.getJobStatus(req.params.jobId);
        res.json(status);
    }
    catch (err) {
        next(err);
    }
});
// GET /api/map/locations/bulk-geocode/stats — queue statistics
router.get('/stats', async (_req, res, next) => {
    try {
        const stats = await geocode_queue_service_1.geocodeQueueService.getStats();
        res.json(stats);
    }
    catch (err) {
        next(err);
    }
});
//# sourceMappingURL=bulk-geocode.routes.js.map