"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSetting = getSetting; exports.getSettingBool = getSettingBool; exports.setSetting = setSetting; exports.getAllSettings = getAllSettings; exports.getPublicSettings = getPublicSettings; const client_1 = require("@prisma/client"); const prisma = new client_1.PrismaClient(); // Default settings const DEFAULT_SETTINGS = { customerSupportTicketsEnabled: 'false', // Vertrags-Cockpit: Fristenschwellen (in Tagen) deadlineCriticalDays: '14', // Rot: Kritisch deadlineWarningDays: '42', // Gelb: Warnung (6 Wochen) deadlineOkDays: '90', // GrĂ¼n: OK (3 Monate) }; async function getSetting(key) { const setting = await prisma.appSetting.findUnique({ where: { key }, }); if (setting) { return setting.value; } // Return default if exists return DEFAULT_SETTINGS[key] ?? null; } async function getSettingBool(key) { const value = await getSetting(key); return value === 'true'; } async function setSetting(key, value) { await prisma.appSetting.upsert({ where: { key }, update: { value }, create: { key, value }, }); } async function getAllSettings() { const settings = await prisma.appSetting.findMany(); // Start with defaults, then override with stored values const result = { ...DEFAULT_SETTINGS }; for (const setting of settings) { result[setting.key] = setting.value; } return result; } async function getPublicSettings() { // Settings that should be available to all authenticated users (including customers) const publicKeys = ['customerSupportTicketsEnabled']; const allSettings = await getAllSettings(); const result = {}; for (const key of publicKeys) { if (key in allSettings) { result[key] = allSettings[key]; } } return result; } //# sourceMappingURL=appSetting.service.js.map