feat(api-detail): isCurrent + setCurrent + màj doc et seeder

- Shared types : ajout isCurrent sur ApiEntry et ApiEntryListItem
- Backend entity : colonne is_current (boolean, default true)
- Backend service : isCurrent calculé à la création, setCurrent()
  marque une version comme courante (siblings → false)
- Backend controller : POST /api/apis/:id/set-current
- Frontend ApiService : méthode setCurrent()
- Browse/upload : affichage badge "Courante" via isCurrent
- Seeder : données de démo mises à jour
- Documentation : api-reference, architecture, local-setup, CLAUDE.md

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
z3n
2026-06-19 14:23:31 +00:00
parent c8b3e393ea
commit 0976c33059
15 changed files with 610 additions and 235 deletions

View File

@@ -605,10 +605,41 @@ export class SeederService implements OnApplicationBootstrap {
await this.reset();
}
const count = await this.apiRepo.count();
if (count > 0) return; /* Idempotent — ne ré-exécute pas si des données existent */
if (count > 0) {
await this.fixIsCurrentFlags();
return;
}
await this.seed();
}
/**
* Corrige les flags is_current après une migration :
* si toutes les versions d'un même groupe (name+convention) sont marquées courantes,
* on ne garde que la plus haute version.
*/
private async fixIsCurrentFlags(): Promise<void> {
await this.dataSource.query(`
UPDATE api_entries SET is_current = false
WHERE id IN (
SELECT a.id
FROM api_entries a
WHERE a.is_current = true
AND EXISTS (
SELECT 1 FROM api_entries b
WHERE b.name = a.name AND b.convention = a.convention
AND b.is_current = true
AND b.id != a.id
AND (
b.version_major > a.version_major
OR (b.version_major = a.version_major AND b.version_minor > a.version_minor)
OR (b.version_major = a.version_major AND b.version_minor = a.version_minor
AND b.version_patch > a.version_patch)
)
)
)
`);
}
private async reset(): Promise<void> {
/* Supprimer toutes les entrées puis les catégories */
await this.apiRepo.delete({});
@@ -697,6 +728,7 @@ export class SeederService implements OnApplicationBootstrap {
versionMajor: 3,
versionMinor: 0,
versionPatch: 4,
isCurrent: true,
description:
'A sample API that uses a petstore as an example to demonstrate features in the OpenAPI specification.',
type: 'OPENAPI',
@@ -775,6 +807,7 @@ export class SeederService implements OnApplicationBootstrap {
versionMajor: 3,
versionMinor: 0,
versionPatch: 3,
isCurrent: false,
description:
'A sample API that uses a petstore as an example to demonstrate features in the OpenAPI specification.',
type: 'OPENAPI',
@@ -795,6 +828,7 @@ export class SeederService implements OnApplicationBootstrap {
versionMajor: 3,
versionMinor: 0,
versionPatch: 2,
isCurrent: false,
description:
'A sample API that uses a petstore as an example to demonstrate features in the OpenAPI specification.',
type: 'OPENAPI',