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
@@ -7,7 +7,10 @@ import type {
CreatedIdResponse,
EntryTraceDto,
GenerateGridResultDto,
GridConfig,
GridGenerationMode,
GridImportResultDto,
GridPromptDto,
GridPlanDto,
GridProfileDto,
GridProfileKind,
@@ -121,6 +124,33 @@ export function generateGrid(
})
}
/** Выгрузка сетки одним файлом: перенос, бэкап перед экспериментом и образец для ИИ. */
export function exportGrid(channelId: string) {
return apiRequest<GridConfig>(`/admin/channels/${channelId}/template/export`)
}
/**
* Загрузка сетки из файла. `replace` — снести существующие слоты и построить заново; иначе слои
* и слоты добавляются к тому, что уже есть.
*/
export function importGrid(channelId: string, config: GridConfig, replace: boolean) {
return apiRequest<GridImportResultDto>(`/admin/channels/${channelId}/template/import`, {
method: 'POST',
body: { config, replace },
})
}
/**
* Собирает текст запроса к ИИ по референс-каналам и пожеланиям. Никуда не отправляется — админ
* копирует его в свою модель и приносит ответ назад кнопкой импорта.
*/
export function buildGridPrompt(channelId: string, references: string[], notes: string) {
return apiRequest<GridPromptDto>(`/admin/channels/${channelId}/template/ai-prompt`, {
method: 'POST',
body: { references, notes: notes || null },
})
}
/** Копия сетки на другой канал: слои, слоты, стыки и правила. Группы общие и не копируются. */
export function copyTemplateTo(channelId: string, targetChannelId: string) {
return apiRequest<CopyTemplateResultDto>(