Files
ridebus-status/server/incident-updates.mjs
2026-10-13 02:24:39 +03:00

18 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export const incidentStages = ['detected', 'reported', 'investigating', 'identified', 'monitoring', 'resolved', 'postmortem'];
export const teamStages = ['investigating', 'identified', 'monitoring', 'postmortem'];
export const stageNames = {
detected: { ru: 'Сбой обнаружен', en: 'Outage detected' },
reported: { ru: 'Сообщение команды', en: 'Team report' },
investigating: { ru: 'Проверяем причину', en: 'Investigating' },
identified: { ru: 'Причина найдена', en: 'Cause identified' },
monitoring: { ru: 'Наблюдаем за работой', en: 'Monitoring' },
resolved: { ru: 'Восстановлено', en: 'Resolved' },
postmortem: { ru: 'Причина и итоги', en: 'Cause and outcome' },
};
export function validateUpdate({ stage, messageRu, messageEn }) {
if (!teamStages.includes(stage)) throw new Error('Stage must be investigating, identified, monitoring or postmortem');
for (const text of [messageRu, messageEn]) if (typeof text !== 'string' || !text.trim() || text.trim().length > 2000) throw new Error('Provide message-ru and message-en, 1–2000 characters each');
return { stage, messageRu: messageRu.trim(), messageEn: messageEn.trim() };
}