"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomVariablesController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const custom_variables_service_1 = require("./custom-variables.service");
const custom_variable_dto_1 = require("./dto/custom-variable.dto");
const core_entities_1 = require("../core-entities");
let CustomVariablesController = class CustomVariablesController {
    constructor(customVariablesService) {
        this.customVariablesService = customVariablesService;
    }
    async create(createCustomVariableDto) {
        return this.customVariablesService.create(createCustomVariableDto);
    }
    async findAll() {
        return this.customVariablesService.findAll();
    }
    async findOne(id) {
        return this.customVariablesService.findOne(id);
    }
    async update(id, updateCustomVariableDto) {
        return this.customVariablesService.update(id, updateCustomVariableDto);
    }
    async remove(id) {
        return this.customVariablesService.remove(id);
    }
    async reorder(orderedIds) {
        return this.customVariablesService.reorder(orderedIds);
    }
};
exports.CustomVariablesController = CustomVariablesController;
__decorate([
    (0, common_1.Post)(),
    (0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
    (0, swagger_1.ApiOperation)({ summary: 'Create a custom variable' }),
    (0, swagger_1.ApiResponse)({
        status: 201,
        description: 'Variable created',
        type: core_entities_1.CustomVariable,
    }),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [custom_variable_dto_1.CreateCustomVariableDto]),
    __metadata("design:returntype", Promise)
], CustomVariablesController.prototype, "create", null);
__decorate([
    (0, common_1.Get)(),
    (0, swagger_1.ApiOperation)({ summary: 'List all custom variables' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'List of variables',
        type: [core_entities_1.CustomVariable],
    }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], CustomVariablesController.prototype, "findAll", null);
__decorate([
    (0, common_1.Get)(':id'),
    (0, swagger_1.ApiOperation)({ summary: 'Get a custom variable by ID' }),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Variable UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Variable found',
        type: core_entities_1.CustomVariable,
    }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Variable not found' }),
    __param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], CustomVariablesController.prototype, "findOne", null);
__decorate([
    (0, common_1.Put)(':id'),
    (0, swagger_1.ApiOperation)({ summary: 'Update a custom variable' }),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Variable UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Variable updated',
        type: core_entities_1.CustomVariable,
    }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Variable not found' }),
    __param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
    __param(1, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, custom_variable_dto_1.UpdateCustomVariableDto]),
    __metadata("design:returntype", Promise)
], CustomVariablesController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)(':id'),
    (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
    (0, swagger_1.ApiOperation)({ summary: 'Delete a custom variable' }),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Variable UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({ status: 204, description: 'Variable deleted' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Variable not found' }),
    __param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], CustomVariablesController.prototype, "remove", null);
__decorate([
    (0, common_1.Post)('reorder'),
    (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
    (0, swagger_1.ApiOperation)({
        summary: 'Reorder variables',
        description: 'Update the display order of variables. Pass an array of variable IDs in the desired order.',
    }),
    (0, swagger_1.ApiBody)({
        description: 'Array of variable IDs in desired order',
        type: [String],
        examples: { default: { value: ['uuid-1', 'uuid-2', 'uuid-3'] } },
    }),
    (0, swagger_1.ApiResponse)({ status: 204, description: 'Variables reordered' }),
    __param(0, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Array]),
    __metadata("design:returntype", Promise)
], CustomVariablesController.prototype, "reorder", null);
exports.CustomVariablesController = CustomVariablesController = __decorate([
    (0, swagger_1.ApiTags)('custom-variables'),
    (0, common_1.Controller)('custom-variables'),
    __metadata("design:paramtypes", [custom_variables_service_1.CustomVariablesService])
], CustomVariablesController);
//# sourceMappingURL=custom-variables.controller.js.map