"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDeviceRoutes = void 0;
const express_1 = require("express");
const validation_middleware_1 = require("../middleware/validation.middleware");
const dto_1 = require("../../application/dto");
const pagination_dto_1 = require("../../application/dto/pagination.dto");
/**
 * Device routes mounted under `/api/v1`.
 *
 * Routes:
 *  - POST   /devices            Create or retrieve a device by fingerprint.
 *                               Body: { location, type, info?, ipAddress, userAgent?, acceptLanguage?, fingerprint, status? }
 *                               status: 'active' | 'background' | 'closed' (default: 'closed')
 *  - GET    /devices            List devices with pagination.
 *                               Query: { limit?: number, offset?: number }
 *  - GET    /devices/:id        Get a device by its UUID.
 *                               Param: { id: string (UUID) }
 *  - PATCH  /devices/:id/status Update a device status.
 *                               Param: { id: string (UUID) }
 *                               Body: { status: 'active' | 'background' | 'closed' }
 *  - PATCH  /devices/:id/push-token Update a device's OneSignal push token.
 *                               Param: { id: string (UUID) }
 *                               Body: { pushToken: string | null }
 */
const createDeviceRoutes = (controller) => {
    const router = (0, express_1.Router)();
    router.post('/devices', (0, validation_middleware_1.validateRequest)({ body: dto_1.createDeviceSchema }), controller.create);
    router.get('/devices', (0, validation_middleware_1.validateRequest)({ query: pagination_dto_1.paginationQuerySchema }), controller.getAll);
    router.get('/devices/:id', (0, validation_middleware_1.validateRequest)({ params: dto_1.deviceIdParamSchema }), controller.getById);
    router.patch('/devices/:id/status', (0, validation_middleware_1.validateRequest)({
        params: dto_1.deviceIdParamSchema,
        body: dto_1.updateDeviceStatusSchema,
    }), controller.updateStatus);
    router.patch('/devices/:id/push-token', (0, validation_middleware_1.validateRequest)({
        params: dto_1.deviceIdParamSchema,
        body: dto_1.updateDevicePushTokenSchema,
    }), controller.updatePushToken);
    return router;
};
exports.createDeviceRoutes = createDeviceRoutes;
//# sourceMappingURL=device.routes.js.map