Files
BarevClub/packages/i18n/scripts/dynamic-keys.ts
T
2026-10-25 22:55:29 +04:00

38 lines
2.2 KiB
TypeScript

/**
* Ключи, которые строятся динамически из домена (статусы сценариев, кнопки, чек-листы,
* параметры услуг, районы, роли). Используется в check.ts.
*/
import { CATALOG, FLOWS, flowStatuses, PROVIDER_ROLES, SERVICE_FLOWS, SETTING_KEYS, YEREVAN_DISTRICTS } from '@barev/core';
export function dynamicKeys(): string[] {
const keys: string[] = [];
for (const flow of SERVICE_FLOWS) {
for (const s of flowStatuses(flow)) keys.push(`status.${flow}.${s}`, `notify.status.${flow}.${s}`);
for (const t of FLOWS[flow].transitions) if (t.action) keys.push(`pro.action.${t.action}`, `admin.events.${t.action}`);
for (const e of FLOWS[flow].events) keys.push(`pro.action.${e.code}`, `admin.events.${e.code}`, `notify.event.${e.code}`);
keys.push(`client.detail.providerLabel.${flow}`);
}
for (const s of CATALOG) {
keys.push(`services.${s.code}.name`, `services.${s.code}.description`);
for (const c of s.checklist) keys.push(`checklist.${c.code}`);
if (s.pricing.kind === 'rooms') {
for (const [code, e] of Object.entries(s.pricing.extras)) {
keys.push(`extras.${code}.name`);
if (e.unit !== 'service') keys.push(`extras.${code}.per`);
}
}
for (const f of s.paramsSchema.fields) {
if (f.type === 'extras') continue;
keys.push(`params.${s.code}.${f.key}.label`);
if (f.type === 'select') for (const o of f.options) keys.push(`params.${s.code}.${f.key}.${o}`, `params.${s.code}.${f.key}.${o}_hint`);
}
}
for (const d of YEREVAN_DISTRICTS) keys.push(`districts.${d}`);
for (const r of PROVIDER_ROLES) keys.push(`roles.${r}`);
for (const k of SETTING_KEYS) keys.push(`admin.settings.${k.replace('.', '_')}`);
// приложение: статусы шагов переезда, категории партнёров (названия шагов и документов — в базе, RelocationItem)
for (const s of ['TODO', 'IN_PROGRESS', 'DONE', 'SKIPPED']) keys.push(`client.move.status.${s}`);
for (const c of ['cafe', 'restaurant', 'shop', 'beauty', 'other']) keys.push(`client.partners.cat.${c}`);
return keys;
}