Implement template export/import endpoints and enhance grid generation logic
ci / build-backend (push) Successful in 1m31s
ci / build-frontend (push) Successful in 1m5s
ci / tests (push) Successful in 3m54s
ci / sonar (push) Successful in 4m40s

Added new endpoints for exporting and importing grid configurations in TemplateEndpoints, allowing for better management of template data. Enhanced the GenerateGridCommandHandler to support seasonal layers in grid generation, improving scheduling accuracy during holiday periods. Updated related classes and records to accommodate these changes, ensuring a cohesive integration of new features. Improved documentation for clarity and maintainability.
This commit is contained in:
Leonid Pershin
2026-07-28 02:15:04 +03:00
parent 7bee84c548
commit f7e7b5f7c3
45 changed files with 2929 additions and 242 deletions
+64 -1
View File
@@ -589,6 +589,8 @@ export type JunctionConditions = {
dayparts?: Daypart[] | null
timeWindow?: JunctionTimeWindow | null
chance: number
/** Ставить только в пределах ±N минут от круглого часа; 0 — без привязки. */
nearHourMinutes: number
}
export type JunctionElementDto = {
@@ -762,7 +764,7 @@ export type GridProfileDto = {
/** Строка предпросмотра: будущий слот до того, как он создан. */
export type GridPlanSlotDto = {
layer: 'Main' | 'Weekend'
layer: 'Main' | 'Weekend' | 'Season'
weekday: number | null
start: string
durationMinutes: number
@@ -791,6 +793,67 @@ export type GridPlanDto = {
export type GenerateGridResultDto = { created: number; removed: number }
/**
* Файл обмена конфигурацией сетки. Ссылки на группы и стыки — по именам: файл переносится между
* каналами и установками, а сетку для импорта пишет в том числе ИИ, который GUID может только
* выдумать. Схема повторяет серверную GridConfig.
*/
export type GridConfigSlot = {
title: string
start: string
durationMinutes: number
daypart?: Daypart
kind?: SlotKind
weekday?: number | null
group?: string | null
strategy?: SlotStrategy | null
repeat?: RepeatSource | null
blockMode?: SlotBlockMode
blockValue?: number
overflow?: OverflowPolicy
isAnchor?: boolean
maxDriftMinutes?: number
snapToMinutes?: number | null
junctionBetween?: string | null
junctionAfter?: string | null
}
export type GridConfigLayer = {
name: string
priority: number
slots: GridConfigSlot[]
isEnabled?: boolean
isBackground?: boolean
applicability?: LayerApplicability | null
}
export type GridConfig = {
format: string
version: number
channel?: { name: string; dayStart: string; utcOffsetMinutes: number } | null
rules?: PlanningRules | null
fallbackGroup?: string | null
defaultJunction?: string | null
layers: GridConfigLayer[]
}
/** Итог импорта: пропущенные слоты — не ошибка, а список того, чего не нашлось в библиотеке. */
export type GridImportResultDto = {
layers: number
slots: number
skipped: number
removed: number
warnings: string[]
}
/** Готовый запрос к ИИ и то, из чего он собран. */
export type GridPromptDto = {
prompt: string
groups: number
shows: number
characters: number
}
/** Итог отката сетки: сколько слотов осталось и сколько ссылок восстановить не удалось. */
export type RestoreTemplateResultDto = { slots: number; droppedRefs: number }
+41
View File
@@ -429,6 +429,38 @@ export const en = {
addSlotHere: 'Add slot',
newSlot: 'New slot',
/** Grid auto-build by profile: plan preview and creation. */
transfer: {
action: 'Import / export',
title: 'Grid configuration exchange',
hint: 'The file references groups and junctions by name, so it moves between channels and installations. The AI request is not sent anywhere — you copy it into your own model and bring the answer back to the import tab.',
tabs: { export: 'Export', import: 'Import', ai: 'AI request' },
exportHint:
'Exports layers, slots, rules and references to groups and junctions. Works both as a backup before an experiment and as a sample for a model.',
exportAction: 'Download file',
exported: 'File exported',
importHint:
'Load a file or paste JSON — a model answer, for example. Unknown references do not break the import: such slots are skipped and listed below.',
pickFile: 'Pick a file',
replace: 'Remove existing slots',
pastePlaceholder: 'Paste the grid configuration JSON',
importAction: 'Import',
imported: 'Slots created: {{slots}}, skipped: {{skipped}}',
badJson: 'That does not look like JSON — check that the whole answer was copied.',
warnings: 'What could not be resolved',
aiHint:
'We build the request: channel settings, your groups and library, your references and notes, plus the answer schema. The model returns JSON that loads on the import tab.',
references: 'Reference channels',
referencesPlaceholder: 'Cartoon Network, Paramount Comedy',
referencesHint:
'Comma-separated. The model matches their rhythm — block length, prime, night.',
notes: 'Notes',
notesPlaceholder:
'For example: kids in the morning, films in the evening, adult block at night',
buildPrompt: 'Build the request',
copyPrompt: 'Copy',
copied: 'Request copied',
aiNext: 'Send this to your model and paste the JSON you get back on the "Import" tab.',
},
generate: {
action: 'Build grid',
title: 'Grid auto-build',
@@ -712,6 +744,11 @@ export const en = {
timeWindow: 'Channel time window',
clearWindow: 'Clear',
timeWindowHint: 'Empty — any time. The window may cross midnight.',
nearHour: 'Near the round hour',
nearHourUnit: 'min before and after :00',
nearHourHint:
'0 — no anchoring. Time signals and jingles work this way: the break only plays around :00, not somewhere within the hour.',
badgeNearHour: '±{{minutes}} min off the hour',
badgeOnChange: 'on change',
badgeInterval: 'once per {{minutes}} min',
},
@@ -792,6 +829,10 @@ export const en = {
'next.year': 'Next show year',
'next.genre': 'Next show genre',
'next.time': 'Next start time',
'tonight.title': 'Tonights programme',
'tonight.time': 'Tonights start time',
'tomorrow.title': 'Tomorrows programme',
'tomorrow.time': 'Tomorrows start time',
time: 'Bumper airing time',
date: 'Date',
weekday: 'Weekday',
+40
View File
@@ -430,6 +430,37 @@ export const ru = {
addSlotHere: 'Добавить слот',
newSlot: 'Новый слот',
/** Автосборка сетки по профилю: предпросмотр плана и его создание. */
transfer: {
action: 'Импорт / экспорт',
title: 'Обмен конфигурацией сетки',
hint: 'Файл ссылается на группы и стыки по именам, поэтому переносится между каналами и установками. Запрос к ИИ никуда не отправляется — вы копируете его в свою модель и приносите ответ назад вкладкой импорта.',
tabs: { export: 'Экспорт', import: 'Импорт', ai: 'Запрос к ИИ' },
exportHint:
'Выгружает слои, слоты, правила и ссылки на группы и стыки. Годится и как бэкап перед экспериментом, и как образец для модели.',
exportAction: 'Скачать файл',
exported: 'Файл выгружен',
importHint:
'Загрузите файл или вставьте JSON — например ответ модели. Незнакомые ссылки не валят импорт: такие слоты пропускаются, и вы увидите их списком.',
pickFile: 'Выбрать файл',
replace: 'Снести существующие слоты',
pastePlaceholder: 'Вставьте JSON конфигурации сетки',
importAction: 'Загрузить',
imported: 'Создано слотов: {{slots}}, пропущено: {{skipped}}',
badJson: 'Это не похоже на JSON — проверьте, что скопирован весь ответ целиком.',
warnings: 'Что не удалось разобрать',
aiHint:
'Соберём запрос: параметры канала, ваши группы и библиотека, ваши референсы и пожелания, плюс схема ответа. Модель вернёт JSON, который загружается вкладкой импорта.',
references: 'Референс-каналы',
referencesPlaceholder: '2×2, Paramount Comedy',
referencesHint:
'Через запятую. На их ритм модель будет равняться — длина блоков, прайм, ночь.',
notes: 'Пожелания',
notesPlaceholder: 'Например: утром детское, вечером кино, ночью — взрослый блок',
buildPrompt: 'Собрать запрос',
copyPrompt: 'Скопировать',
copied: 'Запрос скопирован',
aiNext: 'Отправьте это в свою модель, а полученный JSON вставьте во вкладке «Импорт».',
},
generate: {
action: 'Собрать сетку',
title: 'Автосборка сетки',
@@ -712,6 +743,11 @@ export const ru = {
timeWindow: 'Окно суток канала',
clearWindow: 'Сбросить',
timeWindowHint: 'Пусто — в любое время. Окно может переходить через полночь.',
nearHour: 'Рядом с круглым часом',
nearHourUnit: 'мин до и после :00',
nearHourHint:
'0 — без привязки. Сигнал точного времени и джингл ставятся так: врезка играет только в окрестности :00, а не когда-нибудь в этом часе.',
badgeNearHour: '±{{minutes}} мин от часа',
badgeOnChange: 'на смене',
badgeInterval: 'раз в {{minutes}} мин',
},
@@ -792,6 +828,10 @@ export const ru = {
'next.year': 'Год следующего',
'next.genre': 'Жанр следующего',
'next.time': 'Время старта следующего',
'tonight.title': 'Вечерняя программа',
'tonight.time': 'Время вечерней программы',
'tomorrow.title': 'Программа завтра вечером',
'tomorrow.time': 'Время программы завтра',
time: 'Время показа заставки',
date: 'Дата',
weekday: 'День недели',