diff --git a/backend/src/routes/referentiel.js b/backend/src/routes/referentiel.js index cf777e2..b63dcf2 100644 --- a/backend/src/routes/referentiel.js +++ b/backend/src/routes/referentiel.js @@ -388,7 +388,7 @@ router.get('/:id/export', (req, res, next) => { const entries = []; const manifest = { - version: '1.0', + version: '1.1', app: 'crowdlending', exported_at: new Date().toISOString(), count: 1, @@ -396,6 +396,20 @@ router.get('/:id/export', (req, res, next) => { }; entries.push({ name: 'manifest.json', data: JSON.stringify(manifest, null, 2) }); + // Notation pour cette entrée + const notRows = db.prepare( + 'SELECT * FROM referentiel_notation WHERE referentiel_id = ? ORDER BY ordre, id' + ).all(ref.id); + const notation = notRows.map(n => ({ + nom: n.nom, + type: n.type, + valeurs: n.valeurs ? JSON.parse(n.valeurs) : null, + min_val: n.min_val, + max_val: n.max_val, + description: n.description, + ordre: n.ordre, + })); + const dataRow = { nom: enriched.nom, url: enriched.url, @@ -431,10 +445,17 @@ router.get('/:id/export', (req, res, next) => { icone_filename: enriched.icone_filename, categories_inv: (enriched.categories_inv || []).map(c => c.nom), secteurs_inv: (enriched.secteurs_inv || []).map(s => s.nom), + notation, }; entries.push({ name: 'data.json', data: JSON.stringify([dataRow], null, 2) }); + // Types de garanties du user courant + const garanties = db.prepare( + 'SELECT libelle, description, ordre FROM garantie_types WHERE user_id = ? ORDER BY ordre, id' + ).all(req.user.id); + entries.push({ name: 'garanties.json', data: JSON.stringify(garanties, null, 2) }); + for (const fname of [enriched.logo_filename, enriched.icone_filename]) { if (!fname) continue; const fpath = path.join(logosDir, fname);