Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions backend/prisma/docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
- [DataCatalog](#datacatalog)
- [Hosting](#hosting)
- [Labels](#labels)
- [License](#license)
- [Metadata](#metadata)
- [Notifications](#notifications)
- [Organizations](#organizations)
- [Users](#users)
- [Signalements](#signalements)
- [Statistics](#statistics)
- [Technology](#technology)
- [default](#default)

## Applications
Expand Down Expand Up @@ -598,6 +600,32 @@ Properties as follows:
- `id`: Identifiant unique
- `source`: Nom unique du système source

## License

```mermaid
erDiagram
"License" {
String id PK
String applicationId FK
String name
String(50) version "nullable"
}
```

### `License`

Licence logicielle utilisée par une application.
Une application peut référencer 0 à N licences, une par identifiant de licence.
Le nom suit de préférence un identifiant SPDX (ex. « MIT », « Apache-2.0 »),
mais la saisie libre reste possible (normalisation assurée côté frontend).

Properties as follows:

- `id`: Identifiant unique
- `applicationId`: Identifiant de l'application
- `name`: Nom / identifiant SPDX de la licence (ex. « MIT », « Apache-2.0 »)
- `version`: Version de la licence si pertinent (ex. « 2.0 »)

## Metadata

```mermaid
Expand All @@ -617,6 +645,8 @@ erDiagram
String hostingId FK "nullable"
String technicalDebtInfoId FK "nullable"
String rgaaComplianceId FK "nullable"
String technologyStackId FK "nullable"
String licenseId FK "nullable"
String dataApplicationId FK "nullable"
String dataDescriptionId FK "nullable"
}
Expand All @@ -643,6 +673,8 @@ Properties as follows:
- `hostingId`:
- `technicalDebtInfoId`:
- `rgaaComplianceId`:
- `technologyStackId`:
- `licenseId`:
- `dataApplicationId`:
- `dataDescriptionId`:

Expand Down Expand Up @@ -1002,6 +1034,36 @@ Properties as follows:
- `type`: Type de statistique
- `date`: Date à laquelle cette statistique s'applique

## Technology

```mermaid
erDiagram
"TechnologyStack" {
String id PK
String applicationId FK
String technology
String(50) version "nullable"
DateTime eolDate "nullable"
DateTime eolCheckedAt "nullable"
}
```

### `TechnologyStack`

Élément de la stack technique d'une application (technologie + version).
Une application peut référencer 0 à N technologies, une par technologie.
Les champs de fin de vie (eolDate / eolCheckedAt) sont prévus pour une
intégration ultérieure de https://endoflife.date (cf. #1099).

Properties as follows:

- `id`: Identifiant unique
- `applicationId`: Identifiant de l'application
- `technology`: Nom de la technologie (ex. « Node.js », « PostgreSQL »)
- `version`: Version utilisée (ex. « 20.11 »)
- `eolDate`: Date de fin de support/vie de la version (renseignée via endoflife.date)
- `eolCheckedAt`: Date de dernière vérification du statut de fin de vie

## default

```mermaid
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-- AlterTable
ALTER TABLE "Metadata" ADD COLUMN "licenseId" TEXT,
ADD COLUMN "technologyStackId" TEXT;

-- CreateTable
CREATE TABLE "License" (
"id" TEXT NOT NULL,
"applicationId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"version" VARCHAR(50),

CONSTRAINT "License_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "TechnologyStack" (
"id" TEXT NOT NULL,
"applicationId" TEXT NOT NULL,
"technology" TEXT NOT NULL,
"version" VARCHAR(50),
"eolDate" TIMESTAMP(3),
"eolCheckedAt" TIMESTAMP(3),

CONSTRAINT "TechnologyStack_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "License_applicationId_idx" ON "License"("applicationId");

-- CreateIndex
CREATE UNIQUE INDEX "License_applicationId_name_key" ON "License"("applicationId", "name");

-- CreateIndex
CREATE INDEX "TechnologyStack_applicationId_idx" ON "TechnologyStack"("applicationId");

-- CreateIndex
CREATE UNIQUE INDEX "TechnologyStack_applicationId_technology_key" ON "TechnologyStack"("applicationId", "technology");

-- AddForeignKey
ALTER TABLE "License" ADD CONSTRAINT "License_applicationId_fkey" FOREIGN KEY ("applicationId") REFERENCES "Application"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Metadata" ADD CONSTRAINT "Metadata_technologyStackId_fkey" FOREIGN KEY ("technologyStackId") REFERENCES "TechnologyStack"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Metadata" ADD CONSTRAINT "Metadata_licenseId_fkey" FOREIGN KEY ("licenseId") REFERENCES "License"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "TechnologyStack" ADD CONSTRAINT "TechnologyStack_applicationId_fkey" FOREIGN KEY ("applicationId") REFERENCES "Application"("id") ON DELETE CASCADE ON UPDATE CASCADE;

4 changes: 4 additions & 0 deletions backend/prisma/schema/applications.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ model Application {
compliance Compliance?
/// Conformités RGAA (0 à N, une par site web)
rgaaCompliances RgaaCompliance[]
/// Stack technique (0 à N technologies + versions)
technologies TechnologyStack[]
/// Licences logicielles utilisées (0 à N)
licenses License[]
/// Signalements pour cette application
reports Report[]
/// Ressources externes liées à cette application
Expand Down
24 changes: 24 additions & 0 deletions backend/prisma/schema/license.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// Licence logicielle utilisée par une application.
/// Une application peut référencer 0 à N licences, une par identifiant de licence.
/// Le nom suit de préférence un identifiant SPDX (ex. « MIT », « Apache-2.0 »),
/// mais la saisie libre reste possible (normalisation assurée côté frontend).
///
/// @namespace License
model License {
/// Identifiant unique
id String @id @default(uuid())
/// Identifiant de l'application
applicationId String
/// Application à laquelle cette licence appartient
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)

/// Nom / identifiant SPDX de la licence (ex. « MIT », « Apache-2.0 »)
name String
/// Version de la licence si pertinent (ex. « 2.0 »)
version String? @db.VarChar(50)

metadatas Metadata[] @relation()

@@unique([applicationId, name])
@@index([applicationId])
}
8 changes: 8 additions & 0 deletions backend/prisma/schema/metadata.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ model Metadata {
rgaaComplianceId String?
/// Conformité RGAA associée
rgaaCompliance RgaaCompliance? @relation(fields: [rgaaComplianceId], references: [id])

technologyStackId String?
/// Élément de stack technique associé
technologyStack TechnologyStack? @relation(fields: [technologyStackId], references: [id])

licenseId String?
/// Licence associée
license License? @relation(fields: [licenseId], references: [id])
dataApplicationId String?
dataApplication DataApplication? @relation("DataApplicationMetadata", fields: [dataApplicationId], references: [id])

Expand Down
29 changes: 29 additions & 0 deletions backend/prisma/schema/technology.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// Élément de la stack technique d'une application (technologie + version).
/// Une application peut référencer 0 à N technologies, une par technologie.
/// Les champs de fin de vie (eolDate / eolCheckedAt) sont prévus pour une
/// intégration ultérieure de https://endoflife.date (cf. #1099).
///
/// @namespace Technology
model TechnologyStack {
/// Identifiant unique
id String @id @default(uuid())
/// Identifiant de l'application
applicationId String
/// Application à laquelle cette technologie appartient
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)

/// Nom de la technologie (ex. « Node.js », « PostgreSQL »)
technology String
/// Version utilisée (ex. « 20.11 »)
version String? @db.VarChar(50)

/// Date de fin de support/vie de la version (renseignée via endoflife.date)
eolDate DateTime?
/// Date de dernière vérification du statut de fin de vie
eolCheckedAt DateTime?

metadatas Metadata[] @relation()

@@unique([applicationId, technology])
@@index([applicationId])
}
4 changes: 4 additions & 0 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { UserModule } from "./user/user.module";
import { LabelSourceModule } from "./label-source/label-source.module";
import { MditCampaignModule } from "./mdit-campaign/mdit-campaign.module";
import { RgaaModule } from "./rgaa/rgaa.module";
import { TechnologyModule } from "./technology/technology.module";
import { LicenseModule } from "./license/license.module";
import { DataCatalogModule } from "./data-catalog/data-catalogue.module";
import { OrganizationMaiaReferencesModule } from "./organization-maia-references/organization-maia-references.module";
import { ImportModule } from "./import/import.module";
Expand Down Expand Up @@ -68,6 +70,8 @@ import { ImportModule } from "./import/import.module";
TagsModule,
TechnicalDebtInfoModule,
RgaaModule,
TechnologyModule,
LicenseModule,
PrismaModule,
ConfigModule,
StatusesModule,
Expand Down
47 changes: 47 additions & 0 deletions backend/src/license/dto/license.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsOptional, IsString, MaxLength } from "class-validator";

export class CreateLicenseDto {
@ApiProperty({
example: "MIT",
description: "Nom / identifiant SPDX de la licence",
})
@IsString()
name: string;

@ApiProperty({
example: "2.0",
description: "Version de la licence si pertinent",
required: false,
nullable: true,
})
@IsOptional()
@IsString()
@MaxLength(50)
version?: string | null;
}

export class LicenseDto extends CreateLicenseDto {
@ApiProperty({
example: "12345678-1234-1234-1234-123456789012",
description: "Identifiant unique de la licence",
})
@IsString()
id: string;

@ApiProperty({
example: "12345678-1234-1234-1234-123456789012",
description: "Identifiant de l'application",
})
@IsString()
applicationId: string;
}

export class LicenseErrorResponseDto {
@ApiProperty({
example: "Cette licence est déjà renseignée pour cette application",
description: "Message d'erreur en cas de conflit",
})
@IsString()
message: string;
}
6 changes: 6 additions & 0 deletions backend/src/license/entities/license.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class License {
id: string;
applicationId: string;
name: string;
version?: string;
}
Loading
Loading