"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.SettingController = void 0;
const openapi = require("@nestjs/swagger");
const common_1 = require("@nestjs/common");
const platform_express_1 = require("@nestjs/platform-express");
const swagger_1 = require("@nestjs/swagger");
const public_decorator_1 = require("../decorators/public.decorator");
const solid_request_context_decorator_1 = require("../decorators/solid-request-context.decorator");
const solid_request_context_dto_1 = require("../dtos/solid-request-context.dto");
const setting_service_1 = require("../services/setting.service");
let SettingController = class SettingController {
    constructor(service) {
        this.service = service;
    }
    async updateSettings(body, files) {
        let settings = [];
        try {
            settings = typeof body.settings === 'string' ? JSON.parse(body.settings) : body.settings;
        }
        catch (e) {
            throw new common_1.BadRequestException('Invalid settings payload');
        }
        return this.service.updateSettings(settings, files);
    }
    async wrapSettings() {
        return this.service.getNonEncryptedSystemAdminReadonlyAndAboveSettings();
    }
    async getAllSettings() {
        return this.service.getNonEncryptedSystemAdminReadonlyAndAboveSettings();
    }
    getMcpUrl(query, solidRequestContext) {
        return this.service.getMcpUrl(query, solidRequestContext);
    }
};
exports.SettingController = SettingController;
__decorate([
    (0, swagger_1.ApiBearerAuth)("jwt"),
    (0, common_1.Put)('/bulk'),
    (0, common_1.UseInterceptors)((0, platform_express_1.AnyFilesInterceptor)()),
    openapi.ApiResponse({ status: 200, type: [require("../entities/setting.entity").Setting] }),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.UploadedFiles)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Array]),
    __metadata("design:returntype", Promise)
], SettingController.prototype, "updateSettings", null);
__decorate([
    (0, common_1.Get)('/wrapped'),
    (0, public_decorator_1.Public)(),
    openapi.ApiResponse({ status: 200 }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], SettingController.prototype, "wrapSettings", null);
__decorate([
    (0, swagger_1.ApiBearerAuth)("jwt"),
    (0, common_1.Get)(),
    openapi.ApiResponse({ status: 200 }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], SettingController.prototype, "getAllSettings", null);
__decorate([
    (0, swagger_1.ApiBearerAuth)("jwt"),
    (0, swagger_1.ApiQuery)({ name: 'showHeader', required: false, type: String }),
    (0, swagger_1.ApiQuery)({ name: 'inListView', required: false, type: String }),
    (0, common_1.Get)('/get-mcp-url'),
    openapi.ApiResponse({ status: 200, type: Object }),
    __param(0, (0, common_1.Query)()),
    __param(1, (0, solid_request_context_decorator_1.SolidRequestContextDecorator)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, solid_request_context_dto_1.SolidRequestContextDto]),
    __metadata("design:returntype", void 0)
], SettingController.prototype, "getMcpUrl", null);
exports.SettingController = SettingController = __decorate([
    (0, swagger_1.ApiTags)('Solid Core'),
    (0, common_1.Controller)('setting'),
    __metadata("design:paramtypes", [setting_service_1.SettingService])
], SettingController);
//# sourceMappingURL=setting.controller.js.map