import { normalizeGenerationPoemBatchPayload, normalizeGenerationPoemPreview, normalizeGenerationPoemRows } from './generation-poem-contract.js' import { normalizeGenealogyPathId } from './genealogy-contract.js' import { requestStrict } from './request-client.js' export const generationPoemApi = { async getGenerationPoems(genealogyId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const generationPoems = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/generation-poems`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeGenerationPoemRows(generationPoems, normalizedGenealogyId) }, async getGenerationPoemManagement(genealogyId, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const generationPoems = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/generation-poems/management`, method: 'GET' }, { requestController: requestOptions.requestController ?? null }) return normalizeGenerationPoemRows(generationPoems, normalizedGenealogyId) }, async previewGenerationPoemBatch(genealogyId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) const preview = await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/generation-poems/batch/preview`, method: 'POST', data: normalizeGenerationPoemBatchPayload(payload) }, { requestController: requestOptions.requestController ?? null }) return normalizeGenerationPoemPreview(preview, normalizedGenealogyId) }, async saveGenerationPoemBatch(genealogyId, payload, requestOptions = {}) { const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId) await requestStrict({ url: `/genealogy/app/genealogies/${normalizedGenealogyId}/generation-poems/batch/save`, method: 'POST', data: normalizeGenerationPoemBatchPayload(payload) }, { requireData: false, requestController: requestOptions.requestController ?? null }) return null } }