Compare commits
No commits in common. "master" and "archive/maquette-initiale" have entirely different histories.
master
...
archive/ma
18
.gitattributes
vendored
@ -1,18 +0,0 @@
|
|||||||
# Fins de ligne : toujours LF dans le dépôt (évite les conflits Linux/Windows)
|
|
||||||
* text=auto eol=lf
|
|
||||||
|
|
||||||
# Fichiers binaires : pas de conversion
|
|
||||||
*.png binary
|
|
||||||
*.jpg binary
|
|
||||||
*.jpeg binary
|
|
||||||
*.gif binary
|
|
||||||
*.ico binary
|
|
||||||
*.webp binary
|
|
||||||
*.pdf binary
|
|
||||||
*.woff binary
|
|
||||||
*.woff2 binary
|
|
||||||
*.ttf binary
|
|
||||||
*.eot binary
|
|
||||||
|
|
||||||
# Scripts shell : toujours LF
|
|
||||||
*.sh text eol=lf
|
|
||||||
7
.gitignore
vendored
@ -12,7 +12,6 @@ dist/
|
|||||||
.env.*.local
|
.env.*.local
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
.cursor/
|
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
*.swp
|
*.swp
|
||||||
@ -33,16 +32,11 @@ yarn-error.log*
|
|||||||
*.sqlite3
|
*.sqlite3
|
||||||
|
|
||||||
# Flutter
|
# Flutter
|
||||||
**/android/local.properties
|
|
||||||
.flutter-plugins
|
.flutter-plugins
|
||||||
.flutter-plugins-dependencies
|
.flutter-plugins-dependencies
|
||||||
.pub-cache/
|
.pub-cache/
|
||||||
.pub/
|
.pub/
|
||||||
/build/
|
/build/
|
||||||
**/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
|
|
||||||
**/windows/flutter/generated_plugin_registrant.cc
|
|
||||||
**/windows/flutter/generated_plugin_registrant.h
|
|
||||||
**/windows/flutter/generated_plugins.cmake
|
|
||||||
|
|
||||||
# Coverage
|
# Coverage
|
||||||
coverage/
|
coverage/
|
||||||
@ -58,4 +52,3 @@ Xcf/**
|
|||||||
# Release notes
|
# Release notes
|
||||||
CHANGELOG.md
|
CHANGELOG.md
|
||||||
Ressources/
|
Ressources/
|
||||||
.gitea-token
|
|
||||||
|
|||||||
BIN
Archives/ChatGPT Image 25 avr. 2025, 16_45_30.png
Normal file
|
After Width: | Height: | Size: 2.3 MiB |
BIN
Archives/ChatGPT Image 30 avr. 2025, 11_48_00.png
Normal file
|
After Width: | Height: | Size: 1.6 MiB |
BIN
Archives/ChatGPT Image 30 avr. 2025, 11_48_14.png
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
BIN
Archives/Cinq Styles de _P'titsPas_.png
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
Archives/P'tisPas_logo.png
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
BIN
Archives/P'tisPas_logo_trans.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
Archives/P'titsPas et pierres colorées.png
Normal file
|
After Width: | Height: | Size: 2.3 MiB |
BIN
Archives/P'titsPas_icone.png
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
Archives/Pas à Pas en Couleurs tordu.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
Archives/Pas à Pas en Pastel encre.png
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
BIN
Archives/Taches_encres_01.png
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
Archives/Taches_encres_02.png
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
Archives/Taches_encres_03.png
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
Archives/champs_login.png
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
BIN
Archives/champs_login_2.png
Normal file
|
After Width: | Height: | Size: 2.3 MiB |
BIN
Archives/echantillons pierres.png
Normal file
|
After Width: | Height: | Size: 2.8 MiB |
BIN
Archives/icon.png
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
Archives/logo.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
Archives/logo02.png
Normal file
|
After Width: | Height: | Size: 662 KiB |
BIN
Archives/logo03.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
Archives/logo04.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
Archives/page_login.png
Normal file
|
After Width: | Height: | Size: 366 KiB |
BIN
Archives/page_login_2.png
Normal file
|
After Width: | Height: | Size: 501 KiB |
BIN
Archives/page_login_3.png
Normal file
|
After Width: | Height: | Size: 563 KiB |
BIN
Archives/page_login_4.1.png
Normal file
|
After Width: | Height: | Size: 498 KiB |
BIN
Archives/paper.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
Archives/paper2.png
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
Archives/pierres.png
Normal file
|
After Width: | Height: | Size: 164 KiB |
BIN
Archives/propositions.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
Xcf/P'tisPas_logo_trans.xcf
Normal file
BIN
Xcf/P'titsPas et pierres colorées.xcf
Normal file
BIN
Xcf/P'titsPas_icone.xcf
Normal file
BIN
Xcf/P'titsPas_logo.xcf
Normal file
@ -1,87 +0,0 @@
|
|||||||
# 📜 API Contracts - PtitsPas
|
|
||||||
|
|
||||||
Ce dossier contient les **contrats d'API** qui définissent les interfaces entre les différentes couches de l'application.
|
|
||||||
|
|
||||||
## 🎯 Objectif
|
|
||||||
|
|
||||||
Garantir que **Frontend**, **Backend** et **Database** respectent des contrats stricts, permettant de les rendre **interchangeables** sans casser l'application.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📁 Structure
|
|
||||||
|
|
||||||
```
|
|
||||||
api-contracts/
|
|
||||||
├── frontend-backend/ # Contrat Frontend ↔ Backend (HTTP REST)
|
|
||||||
│ ├── openapi.yaml # Spécification OpenAPI 3.0 (source de vérité)
|
|
||||||
│ └── generated/ # Code généré automatiquement
|
|
||||||
│ ├── dart/ # Client API pour Flutter
|
|
||||||
│ └── typescript/ # Types pour NestJS
|
|
||||||
│
|
|
||||||
└── backend-database/ # Contrat Backend ↔ Database (ORM/SQL)
|
|
||||||
├── schema.prisma # Schéma Prisma (ou TypeORM entities)
|
|
||||||
└── migrations/ # Migrations SQL versionnées
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🔄 Workflow de Génération
|
|
||||||
|
|
||||||
### 1. Frontend ↔ Backend
|
|
||||||
|
|
||||||
**Source de vérité :** `frontend-backend/openapi.yaml`
|
|
||||||
|
|
||||||
**Génération du client Dart (Flutter) :**
|
|
||||||
```bash
|
|
||||||
cd api-contracts/frontend-backend
|
|
||||||
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
|
|
||||||
-i /local/openapi.yaml \
|
|
||||||
-g dart-dio \
|
|
||||||
-o /local/generated/dart
|
|
||||||
```
|
|
||||||
|
|
||||||
**Génération des types TypeScript (NestJS) :**
|
|
||||||
```bash
|
|
||||||
cd api-contracts/frontend-backend
|
|
||||||
npx openapi-typescript openapi.yaml --output generated/typescript/api.types.ts
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### 2. Backend ↔ Database
|
|
||||||
|
|
||||||
**Source de vérité :** `backend-database/schema.prisma`
|
|
||||||
|
|
||||||
**Génération du client Prisma :**
|
|
||||||
```bash
|
|
||||||
cd api-contracts/backend-database
|
|
||||||
npx prisma generate
|
|
||||||
```
|
|
||||||
|
|
||||||
**Génération des migrations SQL :**
|
|
||||||
```bash
|
|
||||||
cd api-contracts/backend-database
|
|
||||||
npx prisma migrate dev --name <nom_migration>
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ✅ Avantages
|
|
||||||
|
|
||||||
- **Frontend interchangeable** : React, Vue, Angular → il suffit de régénérer le client API
|
|
||||||
- **Backend interchangeable** : Python, Go, Java → tant qu'il respecte `openapi.yaml`
|
|
||||||
- **Database read-only en prod** : User PostgreSQL `app_user` (pas de DDL)
|
|
||||||
- **Cohérence garantie** : Types générés = pas d'erreur de typage
|
|
||||||
- **Documentation auto** : OpenAPI = documentation interactive (Swagger UI)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📚 Documentation
|
|
||||||
|
|
||||||
- [OpenAPI 3.0 Spec](https://swagger.io/specification/)
|
|
||||||
- [Prisma Schema](https://www.prisma.io/docs/concepts/components/prisma-schema)
|
|
||||||
- [openapi-generator](https://openapi-generator.tech/)
|
|
||||||
- [openapi-typescript](https://github.com/drwpow/openapi-typescript)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
# 💾 Backend ↔ Database Contract
|
|
||||||
|
|
||||||
Ce dossier contient le **contrat de données** entre le Backend et la Base de Données.
|
|
||||||
|
|
||||||
## 📋 Contenu
|
|
||||||
|
|
||||||
- **`schema.prisma`** : Schéma de base de données (à créer)
|
|
||||||
- **`migrations/`** : Migrations SQL versionnées (actuellement dans `/database/migrations/`)
|
|
||||||
|
|
||||||
## 🔄 Migration Future
|
|
||||||
|
|
||||||
À terme, les migrations SQL de `/database/migrations/` seront gérées ici avec Prisma :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Générer une migration
|
|
||||||
npx prisma migrate dev --name add_user_phone
|
|
||||||
|
|
||||||
# Appliquer en production
|
|
||||||
npx prisma migrate deploy
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📚 Référence
|
|
||||||
|
|
||||||
- [Prisma Migrate](https://www.prisma.io/docs/concepts/components/prisma-migrate)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,179 +0,0 @@
|
|||||||
openapi: 3.0.0
|
|
||||||
info:
|
|
||||||
title: PtitsPas API
|
|
||||||
version: 1.0.0
|
|
||||||
description: |
|
|
||||||
API REST pour l'application PtitsPas.
|
|
||||||
Ce contrat définit l'interface entre le Frontend (Flutter) et le Backend (NestJS).
|
|
||||||
contact:
|
|
||||||
name: PtitsPas Team
|
|
||||||
email: admin@ptits-pas.fr
|
|
||||||
|
|
||||||
servers:
|
|
||||||
- url: https://app.ptits-pas.fr/api
|
|
||||||
description: Production
|
|
||||||
- url: http://localhost:3000/api
|
|
||||||
description: Développement local
|
|
||||||
|
|
||||||
paths:
|
|
||||||
/auth/login:
|
|
||||||
post:
|
|
||||||
summary: Authentification utilisateur
|
|
||||||
operationId: loginUser
|
|
||||||
tags:
|
|
||||||
- Authentication
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- email
|
|
||||||
- password
|
|
||||||
properties:
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
format: email
|
|
||||||
example: admin@ptits-pas.fr
|
|
||||||
password:
|
|
||||||
type: string
|
|
||||||
format: password
|
|
||||||
example: "4dm1n1strateur"
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Authentification réussie
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
access_token:
|
|
||||||
type: string
|
|
||||||
description: Token JWT d'accès
|
|
||||||
refresh_token:
|
|
||||||
type: string
|
|
||||||
description: Token JWT de rafraîchissement
|
|
||||||
user:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
'401':
|
|
||||||
description: Identifiants invalides
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Error'
|
|
||||||
|
|
||||||
/users:
|
|
||||||
get:
|
|
||||||
summary: Liste des utilisateurs
|
|
||||||
operationId: listUsers
|
|
||||||
tags:
|
|
||||||
- Users
|
|
||||||
security:
|
|
||||||
- bearerAuth: []
|
|
||||||
parameters:
|
|
||||||
- name: role
|
|
||||||
in: query
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/RoleType'
|
|
||||||
- name: statut
|
|
||||||
in: query
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/StatutUtilisateurType'
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Liste des utilisateurs
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
'401':
|
|
||||||
description: Non authentifié
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Error'
|
|
||||||
|
|
||||||
components:
|
|
||||||
schemas:
|
|
||||||
User:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
- email
|
|
||||||
- role
|
|
||||||
- statut
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
example: "550e8400-e29b-41d4-a716-446655440000"
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
format: email
|
|
||||||
example: "parent@ptits-pas.fr"
|
|
||||||
prenom:
|
|
||||||
type: string
|
|
||||||
example: "Jean"
|
|
||||||
nom:
|
|
||||||
type: string
|
|
||||||
example: "Dupont"
|
|
||||||
role:
|
|
||||||
$ref: '#/components/schemas/RoleType'
|
|
||||||
statut:
|
|
||||||
$ref: '#/components/schemas/StatutUtilisateurType'
|
|
||||||
telephone:
|
|
||||||
type: string
|
|
||||||
example: "0612345678"
|
|
||||||
adresse:
|
|
||||||
type: string
|
|
||||||
photo_url:
|
|
||||||
type: string
|
|
||||||
format: uri
|
|
||||||
cree_le:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
|
|
||||||
RoleType:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- parent
|
|
||||||
- assistante_maternelle
|
|
||||||
- gestionnaire
|
|
||||||
- administrateur
|
|
||||||
- super_admin
|
|
||||||
|
|
||||||
StatutUtilisateurType:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- en_attente
|
|
||||||
- actif
|
|
||||||
- suspendu
|
|
||||||
|
|
||||||
Error:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- message
|
|
||||||
- statusCode
|
|
||||||
properties:
|
|
||||||
message:
|
|
||||||
type: string
|
|
||||||
example: "Identifiants invalides"
|
|
||||||
statusCode:
|
|
||||||
type: integer
|
|
||||||
example: 401
|
|
||||||
error:
|
|
||||||
type: string
|
|
||||||
example: "Unauthorized"
|
|
||||||
|
|
||||||
securitySchemes:
|
|
||||||
bearerAuth:
|
|
||||||
type: http
|
|
||||||
scheme: bearer
|
|
||||||
bearerFormat: JWT
|
|
||||||
description: Token JWT obtenu via /auth/login
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
# Fichier: .env.example
|
|
||||||
# Copier ce fichier vers .env et adapter les valeurs selon votre environnement
|
|
||||||
|
|
||||||
# Configuration de la base de données PostgreSQL
|
|
||||||
POSTGRES_HOST=postgres
|
|
||||||
POSTGRES_PORT=5432
|
|
||||||
POSTGRES_USER=admin
|
|
||||||
POSTGRES_PASSWORD=admin123
|
|
||||||
POSTGRES_DB=ptitpas_db
|
|
||||||
|
|
||||||
# Configuration PgAdmin (accessible sur http://localhost:8080)
|
|
||||||
PGADMIN_DEFAULT_EMAIL=admin@localhost
|
|
||||||
PGADMIN_DEFAULT_PASSWORD=admin123
|
|
||||||
|
|
||||||
# Configuration de l'API
|
|
||||||
API_PORT=3000
|
|
||||||
|
|
||||||
# Secrets pour l'authentification JWT
|
|
||||||
JWT_SECRET=dev-jwt-secret-key-change-me
|
|
||||||
JWT_EXPIRATION_TIME=7d
|
|
||||||
|
|
||||||
# Environnement
|
|
||||||
NODE_ENV=development
|
|
||||||
|
|
||||||
# Photos inscription (fichiers écrits depuis base64). Préférer un chemin ABSOLU.
|
|
||||||
# Local : laisser vide → ./uploads/photos (relatif au cwd du processus).
|
|
||||||
# Docker (docker-compose) : UPLOAD_PHOTOS_DIR=/app/uploads/photos + volume nommé (voir docker-compose.yml).
|
|
||||||
# UPLOAD_PHOTOS_DIR=
|
|
||||||
#
|
|
||||||
# Reverse proxy : si Nginx devant l’API, augmenter la taille du corps (ex. client_max_body_size 16m;).
|
|
||||||
# Traefik en reverse proxy simple ne limite en général pas le corps ; si middleware buffering, prévoir ~16 Mo+.
|
|
||||||
|
|
||||||
# Log de chaque appel API (mode debug) — mettre à true pour tracer les requêtes front
|
|
||||||
# LOG_API_REQUESTS=true
|
|
||||||
64
backend/.gitignore
vendored
@ -1,64 +0,0 @@
|
|||||||
# compiled output
|
|
||||||
/dist
|
|
||||||
/node_modules
|
|
||||||
/build
|
|
||||||
|
|
||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
pnpm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
# OS
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# Tests
|
|
||||||
/coverage
|
|
||||||
/.nyc_output
|
|
||||||
|
|
||||||
# IDEs and editors
|
|
||||||
/.idea
|
|
||||||
.project
|
|
||||||
.classpath
|
|
||||||
.c9/
|
|
||||||
*.launch
|
|
||||||
.settings/
|
|
||||||
*.sublime-workspace
|
|
||||||
|
|
||||||
# IDE - VSCode
|
|
||||||
.vscode/*
|
|
||||||
!.vscode/settings.json
|
|
||||||
!.vscode/tasks.json
|
|
||||||
!.vscode/launch.json
|
|
||||||
!.vscode/extensions.json
|
|
||||||
|
|
||||||
# dotenv environment variable files
|
|
||||||
.env
|
|
||||||
.env.development.local
|
|
||||||
.env.test.local
|
|
||||||
.env.production.local
|
|
||||||
.env.local
|
|
||||||
|
|
||||||
# temp directory
|
|
||||||
.temp
|
|
||||||
.tmp
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.pid.lock
|
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
.env
|
|
||||||
|
|
||||||
|
|
||||||
# Tests bdd
|
|
||||||
.vscode/
|
|
||||||
BDD.sql
|
|
||||||
migrations/
|
|
||||||
src/seed/
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "all"
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
FROM node:22-alpine AS builder
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copier les fichiers de configuration
|
|
||||||
COPY package*.json ./
|
|
||||||
COPY tsconfig*.json ./
|
|
||||||
COPY nest-cli.json ./
|
|
||||||
|
|
||||||
# Installer TOUTES les dépendances (dev + prod pour le build)
|
|
||||||
RUN npm install && npm cache clean --force
|
|
||||||
|
|
||||||
# Copier le code source
|
|
||||||
COPY src ./src
|
|
||||||
|
|
||||||
# Builder l'application
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# Stage production
|
|
||||||
FROM node:22-alpine AS production
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Installer seulement les dépendances de production
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN npm install --only=production && npm cache clean --force
|
|
||||||
|
|
||||||
# Copier le build depuis le stage builder
|
|
||||||
COPY --from=builder /app/dist ./dist
|
|
||||||
|
|
||||||
# Créer un utilisateur non-root
|
|
||||||
RUN addgroup -g 1001 -S nodejs
|
|
||||||
RUN adduser -S nestjs -u 1001
|
|
||||||
|
|
||||||
# Dossiers écriture runtime (nestjs non-root) : photos + documents légaux (PDF)
|
|
||||||
RUN mkdir -p /app/uploads/photos /app/documents/legaux && \
|
|
||||||
chown -R nestjs:nodejs /app/uploads /app/documents
|
|
||||||
|
|
||||||
USER nestjs
|
|
||||||
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
CMD ["node", "dist/main"]
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
# 🚀 Guide de développement local
|
|
||||||
|
|
||||||
## Prérequis
|
|
||||||
- Docker et Docker Compose installés
|
|
||||||
- Git
|
|
||||||
|
|
||||||
## 🏃♂️ Démarrage rapide
|
|
||||||
|
|
||||||
### 1. Cloner le projet
|
|
||||||
```bash
|
|
||||||
git clone <url-du-depot-backend>
|
|
||||||
cd ptitspas-backend
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Configuration de l'environnement
|
|
||||||
```bash
|
|
||||||
# Copier le fichier d'exemple
|
|
||||||
cp .env.example .env
|
|
||||||
|
|
||||||
# Optionnel : adapter les valeurs dans .env selon vos besoins
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Lancer l'application
|
|
||||||
```bash
|
|
||||||
# Démarrer tous les services (PostgreSQL + PgAdmin + Backend)
|
|
||||||
docker compose -f docker-compose.dev.yml up -d
|
|
||||||
|
|
||||||
# Voir les logs
|
|
||||||
docker compose -f docker-compose.dev.yml logs -f
|
|
||||||
```
|
|
||||||
|
|
||||||
## 🌐 Accès aux services
|
|
||||||
|
|
||||||
- **Backend API** : http://localhost:3000
|
|
||||||
- **PgAdmin** : http://localhost:8080
|
|
||||||
- Email : admin@localhost
|
|
||||||
- Mot de passe : admin123
|
|
||||||
- **PostgreSQL** : localhost:5432
|
|
||||||
- Utilisateur : admin
|
|
||||||
- Mot de passe : admin123
|
|
||||||
- Base : ptitpas_db
|
|
||||||
|
|
||||||
## 🛠️ Commandes utiles
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Arrêter les services
|
|
||||||
docker compose -f docker-compose.dev.yml down
|
|
||||||
|
|
||||||
# Rebuild le backend après modification du Dockerfile
|
|
||||||
docker compose -f docker-compose.dev.yml up --build backend
|
|
||||||
|
|
||||||
# Voir l'état des services
|
|
||||||
docker compose -f docker-compose.dev.yml ps
|
|
||||||
|
|
||||||
# Accéder au container backend
|
|
||||||
docker exec -it ptitspas-backend-dev sh
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📝 Notes de développement
|
|
||||||
|
|
||||||
- Les modifications du code source sont automatiquement prises en compte (hot reload)
|
|
||||||
- Les données PostgreSQL sont persistantes via le volume `postgres_dev_data`
|
|
||||||
- Le fichier `.env` n'est pas versionné pour des raisons de sécurité
|
|
||||||
@ -1,158 +0,0 @@
|
|||||||
# P'titsPas API Backend ✨
|
|
||||||
|
|
||||||
Ce dépôt contient le code source de l'API backend pour la plateforme **P'titsPas**. L'API est construite avec NestJS et est responsable de toute la logique métier, de la gestion des données et de l'authentification des utilisateurs.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📚 Table des matières
|
|
||||||
|
|
||||||
- [Technologies utilisées](#-technologies-utilisées)
|
|
||||||
- [Prérequis](#-prérequis)
|
|
||||||
- [Installation](#-installation)
|
|
||||||
- [Lancement de l'application](#-lancement-de-lapplication)
|
|
||||||
- [Scripts principaux](#-scripts-principaux)
|
|
||||||
- [Tests](#-tests)
|
|
||||||
- [Gestion des migrations](#-gestion-des-migrations)
|
|
||||||
- [Documentation de l'API](#-documentation-de-lapi)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🛠️ Technologies utilisées
|
|
||||||
|
|
||||||
- **Framework**: [NestJS](https://nestjs.com/) (TypeScript)
|
|
||||||
- **Base de données**: [PostgreSQL](https://www.postgresql.org/)
|
|
||||||
- **ORM**: [TypeORM](https://typeorm.io/)
|
|
||||||
- **Authentification**: JWT avec [Passport.js](http://www.passportjs.org/)
|
|
||||||
- **Stockage Fichiers**: [MinIO](https://min.io/) (Compatible S3)
|
|
||||||
- **Tâches Asynchrones**: [Redis](https://redis.io/) avec [BullMQ](https://bullmq.io/)
|
|
||||||
- **Conteneurisation**: [Docker](https://www.docker.com/)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📋 Prérequis
|
|
||||||
|
|
||||||
Avant de commencer, assurez-vous d'avoir installé les outils suivants sur votre machine :
|
|
||||||
|
|
||||||
- [Node.js](https://nodejs.org/) (v18 ou supérieure)
|
|
||||||
- [npm](https://www.npmjs.com/) ou [pnpm](https://pnpm.io/)
|
|
||||||
- [Docker](https://www.docker.com/products/docker-desktop/) et Docker Compose
|
|
||||||
- [Git](https://git-scm.com/)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🚀 Installation
|
|
||||||
|
|
||||||
1. **Clonez le dépôt :**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/votre-username/ptitspas-backend.git
|
|
||||||
cd ptitspas-backend
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Créez le fichier d'environnement :**
|
|
||||||
Copiez le fichier d'exemple `.env.example` et renommez-le en `.env`. Ce fichier est ignoré par Git et contiendra vos secrets locaux.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cp .env.example .env
|
|
||||||
```
|
|
||||||
|
|
||||||
➡️ **Important :** Ouvrez le fichier `.env` et remplissez les variables (identifiants de la base de données, secrets JWT, etc.).
|
|
||||||
|
|
||||||
3. **Installez les dépendances du projet :**
|
|
||||||
```bash
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ▶️ Lancement de l'application
|
|
||||||
|
|
||||||
### Méthode recommandée : avec Docker
|
|
||||||
|
|
||||||
Cette méthode lance l'ensemble des services nécessaires (API, base de données, MinIO, Redis) dans des conteneurs isolés.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker-compose up --build
|
|
||||||
```
|
|
||||||
|
|
||||||
L'API sera accessible à l'adresse `http://localhost:3000` (ou le port que vous avez configuré dans votre `.env`).
|
|
||||||
|
|
||||||
### Méthode locale (pour le développement)
|
|
||||||
|
|
||||||
Cette méthode ne lance que le serveur NestJS. Assurez-vous que les autres services (PostgreSQL, Redis, etc.) sont déjà en cours d'exécution (par exemple, via Docker).
|
|
||||||
|
|
||||||
```
|
|
||||||
npm run start:dev
|
|
||||||
```
|
|
||||||
|
|
||||||
Le serveur redémarrera automatiquement à chaque modification de fichier.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ⚙️ Scripts principaux
|
|
||||||
|
|
||||||
| Commande | Description |
|
|
||||||
| :------------------ | :-------------------------------------------------------------------- |
|
|
||||||
| `npm run start:dev` | Lance le serveur en mode développement avec rechargement automatique. |
|
|
||||||
| `npm run build` | Compile le projet TypeScript en JavaScript. |
|
|
||||||
| `npm start` | Lance l'application depuis les fichiers compilés (mode production). |
|
|
||||||
| `npm run lint` | Analyse le code pour détecter les erreurs de style et de syntaxe. |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🧪 Tests
|
|
||||||
|
|
||||||
Pour lancer les tests, utilisez les commandes suivantes :
|
|
||||||
|
|
||||||
| Commande | Description |
|
|
||||||
| :----------------- | :--------------------------------------------------------------- |
|
|
||||||
| `npm test` | Lance les tests unitaires. |
|
|
||||||
| `npm run test:e2e` | Lance les tests de bout en bout (end-to-end). |
|
|
||||||
| `npm run test:cov` | Lance tous les tests et génère un rapport de couverture de code. |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🗄️ Gestion des migrations
|
|
||||||
|
|
||||||
La structure de la base de données est gérée par des fichiers de migration TypeORM.
|
|
||||||
|
|
||||||
1. **Générer une nouvelle migration :**
|
|
||||||
Après avoir modifié une entité TypeORM, générez automatiquement le fichier de migration correspondant.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run migration:generate -- src/database/migrations/NomDeLaMigration
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Appliquer les migrations :**
|
|
||||||
Pour mettre à jour le schéma de votre base de données avec les nouvelles migrations.
|
|
||||||
```bash
|
|
||||||
npm run migration:run
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📖 Documentation de l'API
|
|
||||||
|
|
||||||
Une fois l'application lancée, la documentation de l'API générée avec **Swagger (OpenAPI)** est disponible à l'adresse suivante :
|
|
||||||
|
|
||||||
➡️ **[http://localhost:3000/api-docs](http://localhost:3000/api-docs)**
|
|
||||||
|
|
||||||
Cette interface vous permet d'explorer et de tester toutes les routes de l'API directement depuis votre navigateur.
|
|
||||||
|
|
||||||
Excellente idée. C'est un élément crucial qui définit les droits et les devoirs liés à votre code.
|
|
||||||
|
|
||||||
En me basant sur la section `10.5 Propriété intellectuelle et licence de l’application` de votre cahier des charges, j'ai rédigé une section "Licence" qui reflète précisément le statut propriétaire de votre projet.
|
|
||||||
|
|
||||||
Voici le `README.md` complet et mis à jour.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📜 Licence
|
|
||||||
|
|
||||||
Ce projet est distribué sous une **licence propriétaire**.
|
|
||||||
|
|
||||||
Le code source, la marque "P'titsPas" et la documentation associée sont la propriété exclusive de l'éditeur, Julien MARTIN.
|
|
||||||
|
|
||||||
Toute reproduction, distribution, modification ou utilisation du code source est strictement interdite sans un accord écrit préalable de l'auteur. Les clients et partenaires autorisés disposent d'une licence d'utilisation non-exclusive et non-transférable, conformément aux termes de leur contrat.
|
|
||||||
|
|
||||||
Pour toute question relative à l'utilisation ou à l'acquisition d'une licence, veuillez contacter l'auteur.
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
# Docker Compose pour développement local
|
|
||||||
# Usage: docker compose -f docker-compose.dev.yml up -d
|
|
||||||
|
|
||||||
services:
|
|
||||||
# Base de données PostgreSQL
|
|
||||||
postgres:
|
|
||||||
image: postgres:17
|
|
||||||
container_name: ptitspas-postgres-dev
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-admin}
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-admin123}
|
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-ptitpas_db}
|
|
||||||
ports:
|
|
||||||
- "5433:5432"
|
|
||||||
volumes:
|
|
||||||
# Si le fichier d'init existe dans le dépôt database
|
|
||||||
- ./migrations/01_init.sql:/docker-entrypoint-initdb.d/01_init.sql
|
|
||||||
- postgres_dev_data:/var/lib/postgresql/data
|
|
||||||
|
|
||||||
networks:
|
|
||||||
- ptitspas_dev
|
|
||||||
|
|
||||||
# Interface d'administration DB
|
|
||||||
pgadmin:
|
|
||||||
image: dpage/pgadmin4
|
|
||||||
container_name: ptitspas-pgadmin-dev
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-admin@ptits-pas.fr}
|
|
||||||
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin123}
|
|
||||||
ports:
|
|
||||||
- "8080:80"
|
|
||||||
depends_on:
|
|
||||||
- postgres
|
|
||||||
networks:
|
|
||||||
- ptitspas_dev
|
|
||||||
|
|
||||||
# Backend NestJS
|
|
||||||
backend:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: ptitspas-backend-dev
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
POSTGRES_HOST: ${POSTGRES_HOST:-postgres}
|
|
||||||
POSTGRES_PORT: ${POSTGRES_PORT:-5432}
|
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-admin}
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-admin123}
|
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-ptitpas_db}
|
|
||||||
API_PORT: ${API_PORT:-3000}
|
|
||||||
JWT_SECRET: ${JWT_SECRET:-dev-jwt-secret-key}
|
|
||||||
JWT_EXPIRATION_TIME: ${JWT_EXPIRATION_TIME:-7d}
|
|
||||||
NODE_ENV: ${NODE_ENV:-development}
|
|
||||||
ports:
|
|
||||||
- "3000:3000"
|
|
||||||
depends_on:
|
|
||||||
- postgres
|
|
||||||
volumes:
|
|
||||||
# Pour le hot reload en développement
|
|
||||||
- ./src:/app/src
|
|
||||||
- /app/node_modules
|
|
||||||
networks:
|
|
||||||
- ptitspas_dev
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
postgres_dev_data:
|
|
||||||
|
|
||||||
networks:
|
|
||||||
ptitspas_dev:
|
|
||||||
driver: bridge
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
import eslint from '@eslint/js';
|
|
||||||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
||||||
import globals from 'globals';
|
|
||||||
import tseslint from 'typescript-eslint';
|
|
||||||
|
|
||||||
export default tseslint.config(
|
|
||||||
{
|
|
||||||
ignores: ['eslint.config.mjs'],
|
|
||||||
},
|
|
||||||
eslint.configs.recommended,
|
|
||||||
...tseslint.configs.recommendedTypeChecked,
|
|
||||||
eslintPluginPrettierRecommended,
|
|
||||||
{
|
|
||||||
languageOptions: {
|
|
||||||
globals: {
|
|
||||||
...globals.node,
|
|
||||||
...globals.jest,
|
|
||||||
},
|
|
||||||
sourceType: 'commonjs',
|
|
||||||
parserOptions: {
|
|
||||||
projectService: true,
|
|
||||||
tsconfigRootDir: import.meta.dirname,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
|
||||||
'@typescript-eslint/no-floating-promises': 'warn',
|
|
||||||
'@typescript-eslint/no-unsafe-argument': 'warn'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/nest-cli",
|
|
||||||
"collection": "@nestjs/schematics",
|
|
||||||
"sourceRoot": "src",
|
|
||||||
"compilerOptions": {
|
|
||||||
"deleteOutDir": true,
|
|
||||||
"assets": [
|
|
||||||
{
|
|
||||||
"include": "**/*.hbs",
|
|
||||||
"watchAssets": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
11662
backend/package-lock.json
generated
@ -1,98 +1,36 @@
|
|||||||
{
|
{
|
||||||
"name": "ptitspas-ynov-back",
|
"name": "petitspas-backend",
|
||||||
"version": "0.0.1",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "Backend pour l'application P'titsPas",
|
||||||
"author": "",
|
"main": "dist/index.js",
|
||||||
"private": true,
|
|
||||||
"license": "UNLICENSED",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"typeorm": "typeorm-ts-node-commonjs",
|
"start": "node dist/index.js",
|
||||||
"migration:run": "npm run typeorm migration:run",
|
"dev": "ts-node-dev --respawn --transpile-only src/index.ts",
|
||||||
"build": "nest build",
|
"build": "tsc",
|
||||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
||||||
"start": "nest start",
|
|
||||||
"start:dev": "nest start --watch",
|
|
||||||
"start:debug": "nest start --debug --watch",
|
|
||||||
"start:prod": "node dist/main",
|
|
||||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watch",
|
"init-admin": "ts-node src/scripts/initAdmin.ts"
|
||||||
"test:cov": "jest --coverage",
|
|
||||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
||||||
"test:e2e": "jest --config ./test/jest-e2e.json",
|
|
||||||
"test:api-dossiers": "node scripts/test-api-dossiers.js"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nestjs/common": "^11.1.6",
|
"@nestjs/common": "^11.1.0",
|
||||||
"@nestjs/config": "^4.0.2",
|
"@prisma/client": "^6.7.0",
|
||||||
"@nestjs/core": "^11.0.1",
|
"@types/jsonwebtoken": "^9.0.9",
|
||||||
"@nestjs/jwt": "^11.0.0",
|
"bcrypt": "^5.1.1",
|
||||||
"@nestjs/mapped-types": "^2.1.0",
|
"cors": "^2.8.5",
|
||||||
"@nestjs/platform-express": "^11.0.1",
|
"express": "^4.18.2",
|
||||||
"@nestjs/swagger": "^11.2.0",
|
"helmet": "^7.1.0",
|
||||||
"@nestjs/typeorm": "^11.0.0",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"@sentry/nestjs": "^10.10.0",
|
"morgan": "^1.10.0"
|
||||||
"bcrypt": "^6.0.0",
|
|
||||||
"bcryptjs": "^3.0.2",
|
|
||||||
"class-transformer": "^0.5.1",
|
|
||||||
"class-validator": "^0.14.2",
|
|
||||||
"handlebars": "^4.7.8",
|
|
||||||
"joi": "^18.0.0",
|
|
||||||
"mapped-types": "^0.0.1",
|
|
||||||
"multer": "^1.4.5-lts.1",
|
|
||||||
"nodemailer": "^6.9.16",
|
|
||||||
"passport-jwt": "^4.0.1",
|
|
||||||
"pg": "^8.16.3",
|
|
||||||
"reflect-metadata": "^0.2.2",
|
|
||||||
"rxjs": "^7.8.1",
|
|
||||||
"swagger-ui-express": "^5.0.1",
|
|
||||||
"typeorm": "^0.3.26"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "^3.2.0",
|
"@types/bcrypt": "^5.0.2",
|
||||||
"@eslint/js": "^9.18.0",
|
"@types/cors": "^2.8.17",
|
||||||
"@nestjs/cli": "^11.0.10",
|
"@types/express": "^4.17.21",
|
||||||
"@nestjs/schematics": "^11.0.0",
|
"@types/helmet": "^4.0.0",
|
||||||
"@nestjs/testing": "^11.0.1",
|
"@types/morgan": "^1.9.9",
|
||||||
"@types/bcrypt": "^6.0.0",
|
"@types/node": "^20.11.19",
|
||||||
"@types/express": "^5.0.0",
|
"prisma": "^6.7.0",
|
||||||
"@types/handlebars": "^4.1.0",
|
|
||||||
"@types/jest": "^30.0.0",
|
|
||||||
"@types/multer": "^1.4.12",
|
|
||||||
"@types/node": "^22.10.7",
|
|
||||||
"@types/nodemailer": "^6.4.16",
|
|
||||||
"@types/passport-jwt": "^4.0.1",
|
|
||||||
"@types/supertest": "^6.0.2",
|
|
||||||
"eslint": "^9.18.0",
|
|
||||||
"eslint-config-prettier": "^10.0.1",
|
|
||||||
"eslint-plugin-prettier": "^5.2.2",
|
|
||||||
"globals": "^16.0.0",
|
|
||||||
"jest": "^30.0.0",
|
|
||||||
"prettier": "^3.4.2",
|
|
||||||
"source-map-support": "^0.5.21",
|
|
||||||
"supertest": "^7.0.0",
|
|
||||||
"ts-jest": "^29.2.5",
|
|
||||||
"ts-loader": "^9.5.2",
|
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"tsconfig-paths": "^4.2.0",
|
"ts-node-dev": "^2.0.0",
|
||||||
"typescript": "^5.7.3",
|
"typescript": "^5.3.3"
|
||||||
"typescript-eslint": "^8.20.0"
|
|
||||||
},
|
|
||||||
"jest": {
|
|
||||||
"moduleFileExtensions": [
|
|
||||||
"js",
|
|
||||||
"json",
|
|
||||||
"ts"
|
|
||||||
],
|
|
||||||
"rootDir": "src",
|
|
||||||
"testRegex": ".*\\.spec\\.ts$",
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.(t|j)s$": "ts-jest"
|
|
||||||
},
|
|
||||||
"collectCoverageFrom": [
|
|
||||||
"**/*.(t|j)s"
|
|
||||||
],
|
|
||||||
"coverageDirectory": "../coverage",
|
|
||||||
"testEnvironment": "node"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,107 +0,0 @@
|
|||||||
/**
|
|
||||||
* Commentaire de clôture + fermeture issue Gitea #120.
|
|
||||||
* Usage: node backend/scripts/close-gitea-issue-120.js
|
|
||||||
* Token : .gitea-token (racine), GITEA_TOKEN, ou docs/27_BRIEFING-FRONTEND.md
|
|
||||||
*/
|
|
||||||
const https = require('https');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const repoRoot = path.join(__dirname, '../..');
|
|
||||||
const ISSUE = 120;
|
|
||||||
const REPO = 'jmartin/petitspas';
|
|
||||||
|
|
||||||
const body = `## Fermeture ticket #120 — livré sur \`develop\`
|
|
||||||
|
|
||||||
Branche **\`feature/120-inscription-am-photo\`** mergée dans **\`develop\`** (livraison : inscription AM alignée parents + panneau validation gestionnaire).
|
|
||||||
|
|
||||||
### Inscription AM (alignement parents)
|
|
||||||
- Photo, consentement, lieux de naissance : parcours et API alignés sur le modèle parents (DTO, entité user, migration SQL, écrans inscription AM, \`registration_photo_slot\`, scripts de test Node).
|
|
||||||
|
|
||||||
### Panneau gestionnaire — onglet « À valider »
|
|
||||||
- Bouton **Ouvrir** : visible au **survol** (même principe que les cartes admin), **icône centrée** sur la ligne et **taille doublée** (\`iconSize\` 34).
|
|
||||||
|
|
||||||
### Wizard validation dossier AM
|
|
||||||
- Titres : **Identité et coordonnées** · **Dossier professionnel** (au-dessus des champs à droite, pas de la photo) · **Présentation**.
|
|
||||||
- **Photo** à gauche (ratio identité 35×45) ; **grille droite** \`[2,2,2,2]\` : NIR | date de naissance, ville | pays de naissance, n° agrément | date d'agrément, capacité | places.
|
|
||||||
- **\`AppUser\`** : \`date_naissance\`, \`lieu_naissance_ville\`, \`lieu_naissance_pays\` ; affichage dates **\`dd/MM/yyyy\`** (\`formatIsoDateFr\`).
|
|
||||||
- **\`ValidationDetailSection\`** : titre **optionnel** (wizard AM).
|
|
||||||
|
|
||||||
### Wizard validation famille
|
|
||||||
- Étape 4 : titre **« Présentation »** (plus « Présentation / Motivation »).
|
|
||||||
|
|
||||||
### Nettoyage
|
|
||||||
- Suppression des **\`debugPrint\`** liés aux médias / images / chargement dossier (\`api_config\`, \`auth_network_image\`, \`dossier_unifie\`, \`user_service\`, carte enfant validation).
|
|
||||||
|
|
||||||
---
|
|
||||||
*Issue fermée après merge sur \`develop\` et recette.*`;
|
|
||||||
|
|
||||||
let token = process.env.GITEA_TOKEN;
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const tokenFile = path.join(repoRoot, '.gitea-token');
|
|
||||||
if (fs.existsSync(tokenFile)) token = fs.readFileSync(tokenFile, 'utf8').trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const briefing = fs.readFileSync(
|
|
||||||
path.join(repoRoot, 'docs/27_BRIEFING-FRONTEND.md'),
|
|
||||||
'utf8',
|
|
||||||
);
|
|
||||||
const m = briefing.match(/Token:\s*(giteabu_[a-f0-9]+)/);
|
|
||||||
if (m) token = m[1].trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
console.error('Token non trouvé : .gitea-token ou GITEA_TOKEN');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function request(method, apiPath, payloadObj) {
|
|
||||||
const payload = payloadObj ? JSON.stringify(payloadObj) : null;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const opts = {
|
|
||||||
hostname: 'git.ptits-pas.fr',
|
|
||||||
path: `/api/v1/repos/${REPO}${apiPath}`,
|
|
||||||
method,
|
|
||||||
headers: {
|
|
||||||
Authorization: 'token ' + token,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
...(payload ? { 'Content-Length': Buffer.byteLength(payload) } : {}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const req = https.request(opts, (res) => {
|
|
||||||
let d = '';
|
|
||||||
res.on('data', (c) => (d += c));
|
|
||||||
res.on('end', () => {
|
|
||||||
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
|
||||||
reject(new Error(`HTTP ${res.statusCode}: ${d}`));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
resolve(d ? JSON.parse(d) : {});
|
|
||||||
} catch (_) {
|
|
||||||
resolve({});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
req.on('error', reject);
|
|
||||||
if (payload) req.write(payload);
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
console.log(`POST commentaire issue #${ISSUE}...`);
|
|
||||||
await request('POST', `/issues/${ISSUE}/comments`, { body });
|
|
||||||
console.log('Commentaire publié.');
|
|
||||||
console.log(`PATCH fermeture issue #${ISSUE}...`);
|
|
||||||
await request('PATCH', `/issues/${ISSUE}`, { state: 'closed' });
|
|
||||||
console.log(`Issue #${ISSUE} fermée.`);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e.message || e);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
@ -1,123 +0,0 @@
|
|||||||
/**
|
|
||||||
* Commentaire de clôture + fermeture issue Gitea #131.
|
|
||||||
* Usage: node backend/scripts/close-gitea-issue-131.js
|
|
||||||
*/
|
|
||||||
const https = require('https');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const repoRoot = path.join(__dirname, '../..');
|
|
||||||
const ISSUE = 131;
|
|
||||||
const REPO = 'jmartin/petitspas';
|
|
||||||
|
|
||||||
const body = `## Fermeture ticket #131 — livré sur \`develop\` et \`master\`
|
|
||||||
|
|
||||||
Branche **\`feature/131\`** mergée dans **\`develop\`**, puis squash merge **\`develop\` → \`master\`** (déploiement production).
|
|
||||||
|
|
||||||
### Fiche parent (dashboard admin)
|
|
||||||
- Modale **\`AdminParentEditModal\`** éditable dès l'ouverture
|
|
||||||
- En-tête dynamique : **nom/prénom** + sous-titre **co-parent** (si connu)
|
|
||||||
- Gélule **statut** modifiable
|
|
||||||
- **\`PATCH /api/v1/parents/:id/fiche\`** — identité + statut
|
|
||||||
- **\`GET /api/v1/parents\`** — liste parents (fix décorateur \`@Get()\` manquant)
|
|
||||||
- Réponses API : \`co_parent\` peuplé, secrets user masqués (\`sanitizeUserForApi\`)
|
|
||||||
- Liste enfants en bas de fiche + rattachement/détachement
|
|
||||||
|
|
||||||
### Fiche AM (dashboard admin)
|
|
||||||
- Modale **\`AdminAmEditModal\`** — 3 onglets : Identité | Fiche pro | Enfants accueillis
|
|
||||||
- **\`PATCH /api/v1/assistantes-maternelles/:id/fiche\`** — identité + champs pro (NIR, date/lieu naissance, date agrément, places, disponibilité)
|
|
||||||
- **\`POST/DELETE …/enfants/:enfantId\`** — rattacher / détacher un enfant
|
|
||||||
- Grille capacité **\`AdminAmChildrenCapacityGrid\`** (2×2)
|
|
||||||
- Rattachement enfants **différé jusqu'à Sauvegarder** (pas d'appel API immédiat)
|
|
||||||
|
|
||||||
### Back — placement AM ↔ enfant
|
|
||||||
- Table **\`enfants_assistantes_maternelles\`** (placement temporel, 1 garde active/enfant)
|
|
||||||
- Enum enfant : \`a_naitre\`, \`garde\`, \`sans_garde\`, \`scolarise\` — **plus \`actif\`**
|
|
||||||
- Rattachement → statut enfant \`garde\` ; détachement → \`sans_garde\`
|
|
||||||
- Migration : \`database/migrations/2026_enfants_assistantes_maternelles.sql\`
|
|
||||||
- Schéma canonique : \`database/BDD.sql\`
|
|
||||||
|
|
||||||
### Front — statuts & polish
|
|
||||||
- **\`enfant_status_utils.dart\`** — libellés/couleurs \`garde\`/\`sans_garde\`
|
|
||||||
- Mise à jour cartes enfants, modale détail, filtres dashboard
|
|
||||||
|
|
||||||
### Correctifs recette
|
|
||||||
- \`GET /parents\` 404 → ajout \`@Get()\` sur \`getAll()\`
|
|
||||||
- Sauvegarde AM 400 → alignement DTO \`UpdateAmFicheAdminDto\` sur payload front
|
|
||||||
- Crash NIR → fix \`toISOString\` + pas d'effacement NIR (colonne NOT NULL)
|
|
||||||
|
|
||||||
### Hors périmètre #131 (tickets voisins)
|
|
||||||
- **#137** onglet Enfants global · **#138** fiche enfant complète · **#115/#116** affiliation avancée
|
|
||||||
|
|
||||||
---
|
|
||||||
*Issue fermée après merge sur \`develop\` + \`master\` et déploiement production.*`;
|
|
||||||
|
|
||||||
let token = process.env.GITEA_TOKEN;
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const tokenFile = path.join(repoRoot, '.gitea-token');
|
|
||||||
if (fs.existsSync(tokenFile)) token = fs.readFileSync(tokenFile, 'utf8').trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const briefing = fs.readFileSync(
|
|
||||||
path.join(repoRoot, 'docs/27_BRIEFING-FRONTEND.md'),
|
|
||||||
'utf8',
|
|
||||||
);
|
|
||||||
const m = briefing.match(/Token:\s*(giteabu_[a-f0-9]+)/);
|
|
||||||
if (m) token = m[1].trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
console.error('Token non trouvé : .gitea-token ou GITEA_TOKEN');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function request(method, apiPath, payloadObj) {
|
|
||||||
const payload = payloadObj ? JSON.stringify(payloadObj) : null;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const opts = {
|
|
||||||
hostname: 'git.ptits-pas.fr',
|
|
||||||
path: `/api/v1/repos/${REPO}${apiPath}`,
|
|
||||||
method,
|
|
||||||
headers: {
|
|
||||||
Authorization: 'token ' + token,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
...(payload ? { 'Content-Length': Buffer.byteLength(payload) } : {}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const req = https.request(opts, (res) => {
|
|
||||||
let d = '';
|
|
||||||
res.on('data', (c) => (d += c));
|
|
||||||
res.on('end', () => {
|
|
||||||
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
|
||||||
reject(new Error(`HTTP ${res.statusCode}: ${d}`));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
resolve(d ? JSON.parse(d) : {});
|
|
||||||
} catch (_) {
|
|
||||||
resolve({});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
req.on('error', reject);
|
|
||||||
if (payload) req.write(payload);
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
console.log(`POST commentaire issue #${ISSUE}...`);
|
|
||||||
await request('POST', `/issues/${ISSUE}/comments`, { body });
|
|
||||||
console.log('Commentaire publié.');
|
|
||||||
console.log(`PATCH fermeture issue #${ISSUE}...`);
|
|
||||||
await request('PATCH', `/issues/${ISSUE}`, { state: 'closed' });
|
|
||||||
console.log(`Issue #${ISSUE} fermée.`);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e.message || e);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
@ -1,111 +0,0 @@
|
|||||||
/**
|
|
||||||
* Crée l'issue Gitea — gestionnaire ne doit pas pouvoir se supprimer.
|
|
||||||
* Usage: node backend/scripts/create-gitea-issue-gestionnaire-self-delete.js
|
|
||||||
*/
|
|
||||||
const https = require('https');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const repoRoot = path.join(__dirname, '../..');
|
|
||||||
const MILESTONE_0_1_0 = 10;
|
|
||||||
|
|
||||||
let token = process.env.GITEA_TOKEN;
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const tokenFile = path.join(repoRoot, '.gitea-token');
|
|
||||||
if (fs.existsSync(tokenFile)) token = fs.readFileSync(tokenFile, 'utf8').trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const briefing = fs.readFileSync(
|
|
||||||
path.join(repoRoot, 'docs/27_BRIEFING-FRONTEND.md'),
|
|
||||||
'utf8',
|
|
||||||
);
|
|
||||||
const m = briefing.match(/Token:\s*(gitebu_[a-f0-9]+)/);
|
|
||||||
if (m) token = m[1].trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
console.error('Token non trouvé : .gitea-token ou GITEA_TOKEN');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const body = `## Contexte
|
|
||||||
|
|
||||||
Quand un **gestionnaire** connecté ouvre sa propre fiche dans l'onglet **Gestionnaires** (Gestion des utilisateurs), la modale **Modifier un "Gestionnaire"** affiche le bouton **Supprimer**.
|
|
||||||
|
|
||||||
Comportement actuel : le gestionnaire voit et peut tenter de supprimer son propre compte.
|
|
||||||
|
|
||||||
## Comportement attendu
|
|
||||||
|
|
||||||
Comme pour le **super administrateur** (bouton Supprimer masqué sur la fiche super admin) :
|
|
||||||
|
|
||||||
- **Pas de bouton Supprimer** quand l'utilisateur édite **sa propre fiche**
|
|
||||||
- **Modification** des informations (prénom, nom, email, téléphone, relais, mot de passe) **toujours autorisée**
|
|
||||||
|
|
||||||
## Périmètre
|
|
||||||
|
|
||||||
- Frontend : \`AdminUserFormDialog\` (\`gestionnaires_create.dart\`)
|
|
||||||
- Comparer \`initialUser.id\` avec l'utilisateur connecté (\`AuthService.getCurrentUser\`)
|
|
||||||
- Masquer Supprimer si édition de soi-même ; conserver garde existante super admin
|
|
||||||
|
|
||||||
## Critères d'acceptation
|
|
||||||
|
|
||||||
- [ ] Gestionnaire connecté → ouvre sa fiche → **pas** de bouton Supprimer
|
|
||||||
- [ ] Gestionnaire connecté → peut **Modifier** ses informations
|
|
||||||
- [ ] Super admin / admin → peut toujours supprimer **un autre** gestionnaire (si droits API)
|
|
||||||
- [ ] Pas de régression sur fiche super administrateur (Supprimer toujours masqué)
|
|
||||||
|
|
||||||
## Fichiers clés
|
|
||||||
|
|
||||||
- \`frontend/lib/screens/administrateurs/creation/gestionnaires_create.dart\`
|
|
||||||
- \`frontend/lib/widgets/admin/gestionnaire_management_widget.dart\`
|
|
||||||
|
|
||||||
## Milestone
|
|
||||||
|
|
||||||
**0.1.0** — correction UX / sécurité gestion utilisateurs.`;
|
|
||||||
|
|
||||||
const payloadClean = JSON.stringify({
|
|
||||||
title: '[Bug] Gestionnaire peut voir Supprimer sur sa propre fiche',
|
|
||||||
body,
|
|
||||||
milestone: MILESTONE_0_1_0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const opts = {
|
|
||||||
hostname: 'git.ptits-pas.fr',
|
|
||||||
path: '/api/v1/repos/jmartin/petitspas/issues',
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
Authorization: 'token ' + token,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Content-Length': Buffer.byteLength(payloadClean),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const req = https.request(opts, (res) => {
|
|
||||||
let d = '';
|
|
||||||
res.on('data', (c) => (d += c));
|
|
||||||
res.on('end', () => {
|
|
||||||
try {
|
|
||||||
const o = JSON.parse(d);
|
|
||||||
if (o.number) {
|
|
||||||
console.log('NUMBER:', o.number);
|
|
||||||
console.log('URL:', o.html_url);
|
|
||||||
console.log('MILESTONE:', o.milestone?.title ?? '(aucun)');
|
|
||||||
} else {
|
|
||||||
console.error('Réponse:', d);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(d);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
req.on('error', (e) => {
|
|
||||||
console.error(e);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
req.write(payloadClean);
|
|
||||||
req.end();
|
|
||||||
@ -1,95 +0,0 @@
|
|||||||
/**
|
|
||||||
* Crée l'issue Gitea "[Frontend] Inscription Parent – Branchement soumission formulaire à l'API"
|
|
||||||
* Usage: node backend/scripts/create-gitea-issue-parent-api.js
|
|
||||||
* Token : .gitea-token (racine du dépôt), sinon GITEA_TOKEN, sinon
|
|
||||||
* docs/27_BRIEFING-FRONTEND.md (voir docs/26_GITEA-API.md)
|
|
||||||
*/
|
|
||||||
const https = require('https');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const repoRoot = path.join(__dirname, '../..');
|
|
||||||
let token = process.env.GITEA_TOKEN;
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const tokenFile = path.join(repoRoot, '.gitea-token');
|
|
||||||
if (fs.existsSync(tokenFile)) {
|
|
||||||
token = fs.readFileSync(tokenFile, 'utf8').trim();
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const briefing = fs.readFileSync(
|
|
||||||
path.join(repoRoot, 'docs/27_BRIEFING-FRONTEND.md'),
|
|
||||||
'utf8',
|
|
||||||
);
|
|
||||||
const m = briefing.match(/Token:\s*(giteabu_[a-f0-9]+)/);
|
|
||||||
if (m) token = m[1].trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
console.error(
|
|
||||||
'Token non trouvé : créer .gitea-token à la racine ou export GITEA_TOKEN (voir docs/26_GITEA-API.md)',
|
|
||||||
);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const body = `## Description
|
|
||||||
|
|
||||||
Branchement du formulaire d'inscription parent (étape 5, récapitulatif) à l'endpoint d'inscription. Aujourd'hui la soumission n'appelle pas l'API : elle affiche uniquement une modale puis redirige vers le login.
|
|
||||||
|
|
||||||
**Estimation** : 4h | **Labels** : frontend, p3, auth, cdc
|
|
||||||
|
|
||||||
## Tâches
|
|
||||||
|
|
||||||
- [ ] Créer un service ou méthode (ex. AuthService.registerParent) appelant POST /api/v1/auth/register/parent
|
|
||||||
- [ ] Construire le body (DTO) à partir de UserRegistrationData (parent1, parent2, children, motivationText, CGU) en cohérence avec le backend (#18)
|
|
||||||
- [ ] Dans ParentRegisterStep5Screen, au clic « Soumettre » : appel API puis modale + redirection ou message d'erreur
|
|
||||||
- [ ] Gestion des photos enfants (base64 ou multipart selon API)
|
|
||||||
|
|
||||||
## Référence
|
|
||||||
|
|
||||||
20_WORKFLOW-CREATION-COMPTE.md § Étape 3 – Inscription d'un parent, backend #18`;
|
|
||||||
|
|
||||||
const payload = JSON.stringify({
|
|
||||||
title: "[Frontend] Inscription Parent – Branchement soumission formulaire à l'API",
|
|
||||||
body,
|
|
||||||
});
|
|
||||||
|
|
||||||
const opts = {
|
|
||||||
hostname: 'git.ptits-pas.fr',
|
|
||||||
path: '/api/v1/repos/jmartin/petitspas/issues',
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
Authorization: 'token ' + token,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Content-Length': Buffer.byteLength(payload),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const req = https.request(opts, (res) => {
|
|
||||||
let d = '';
|
|
||||||
res.on('data', (c) => (d += c));
|
|
||||||
res.on('end', () => {
|
|
||||||
try {
|
|
||||||
const o = JSON.parse(d);
|
|
||||||
if (o.number) {
|
|
||||||
console.log('NUMBER:', o.number);
|
|
||||||
console.log('URL:', o.html_url);
|
|
||||||
} else {
|
|
||||||
console.error('Erreur API:', o.message || d);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Réponse:', d);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
req.on('error', (e) => {
|
|
||||||
console.error(e);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
req.write(payload);
|
|
||||||
req.end();
|
|
||||||
@ -1,67 +0,0 @@
|
|||||||
/**
|
|
||||||
* Liste toutes les issues Gitea (ouvertes + fermées) pour jmartin/petitspas.
|
|
||||||
* Token : .gitea-token (racine), GITEA_TOKEN, ou docs/27_BRIEFING-FRONTEND.md
|
|
||||||
*/
|
|
||||||
const https = require('https');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const repoRoot = path.join(__dirname, '../..');
|
|
||||||
let token = process.env.GITEA_TOKEN;
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const tokenFile = path.join(repoRoot, '.gitea-token');
|
|
||||||
if (fs.existsSync(tokenFile)) token = fs.readFileSync(tokenFile, 'utf8').trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const briefing = fs.readFileSync(
|
|
||||||
path.join(repoRoot, 'docs/27_BRIEFING-FRONTEND.md'),
|
|
||||||
'utf8',
|
|
||||||
);
|
|
||||||
const m = briefing.match(/Token:\s*(giteabu_[a-f0-9]+)/);
|
|
||||||
if (m) token = m[1].trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
console.error('Token non trouvé');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function get(path) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const opts = { hostname: 'git.ptits-pas.fr', path, method: 'GET', headers: { Authorization: 'token ' + token } };
|
|
||||||
const req = https.request(opts, (res) => {
|
|
||||||
let d = '';
|
|
||||||
res.on('data', (c) => (d += c));
|
|
||||||
res.on('end', () => {
|
|
||||||
try { resolve(JSON.parse(d)); } catch (e) { reject(e); }
|
|
||||||
});
|
|
||||||
});
|
|
||||||
req.on('error', reject);
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
const seen = new Map();
|
|
||||||
for (const state of ['open', 'closed']) {
|
|
||||||
for (let page = 1; ; page++) {
|
|
||||||
const raw = await get('/api/v1/repos/jmartin/petitspas/issues?state=' + state + '&limit=50&page=' + page + '&type=issues');
|
|
||||||
if (raw && raw.message && !Array.isArray(raw)) {
|
|
||||||
console.error('API:', raw.message);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
const list = Array.isArray(raw) ? raw : [];
|
|
||||||
for (const i of list) {
|
|
||||||
if (!i.pull_request) seen.set(i.number, { number: i.number, title: i.title, state: i.state });
|
|
||||||
}
|
|
||||||
if (list.length < 50) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const all = [...seen.values()].sort((a, b) => a.number - b.number);
|
|
||||||
console.log(JSON.stringify(all, null, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
main().catch((e) => { console.error(e); process.exit(1); });
|
|
||||||
@ -1,122 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
/**
|
|
||||||
* Test API GET /dossiers/:numeroDossier (dossier unifié AM ou famille).
|
|
||||||
*
|
|
||||||
* Prérequis : backend démarré (npm run start:dev dans backend/).
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* node scripts/test-api-dossiers.js
|
|
||||||
* NUMERO_DOSSIER=2026-000001 node scripts/test-api-dossiers.js
|
|
||||||
* BASE_URL=https://app.ptits-pas.fr/api/v1 TEST_EMAIL=xxx TEST_PASSWORD=yyy NUMERO_DOSSIER=2026-000001 node scripts/test-api-dossiers.js
|
|
||||||
*
|
|
||||||
* Sans TEST_EMAIL/TEST_PASSWORD : 401 sur les routes protégées.
|
|
||||||
* NUMERO_DOSSIER : optionnel ; si absent, utilise le premier numero_dossier de pending-families (avec token).
|
|
||||||
*/
|
|
||||||
|
|
||||||
const BASE_URL = process.env.BASE_URL || 'http://localhost:3000/api/v1';
|
|
||||||
const TEST_EMAIL = process.env.TEST_EMAIL;
|
|
||||||
const TEST_PASSWORD = process.env.TEST_PASSWORD;
|
|
||||||
const NUMERO_DOSSIER = process.env.NUMERO_DOSSIER;
|
|
||||||
|
|
||||||
async function request(method, path, body = null, token = null) {
|
|
||||||
const url = path.startsWith('http') ? path : `${BASE_URL}${path}`;
|
|
||||||
const opts = {
|
|
||||||
method,
|
|
||||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
||||||
};
|
|
||||||
if (token) opts.headers.Authorization = `Bearer ${token}`;
|
|
||||||
if (body) opts.body = JSON.stringify(body);
|
|
||||||
const res = await fetch(url, opts);
|
|
||||||
const text = await res.text();
|
|
||||||
let data = null;
|
|
||||||
try {
|
|
||||||
data = text ? JSON.parse(text) : null;
|
|
||||||
} catch (_) {
|
|
||||||
data = text;
|
|
||||||
}
|
|
||||||
return { status: res.status, data };
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
console.log('Base URL:', BASE_URL);
|
|
||||||
console.log('Numéro dossier (env):', NUMERO_DOSSIER ?? '(sera déduit si token fourni)');
|
|
||||||
console.log('');
|
|
||||||
|
|
||||||
let token = null;
|
|
||||||
if (TEST_EMAIL && TEST_PASSWORD) {
|
|
||||||
console.log('1. Login...');
|
|
||||||
const loginRes = await request('POST', '/auth/login', {
|
|
||||||
email: TEST_EMAIL,
|
|
||||||
password: TEST_PASSWORD,
|
|
||||||
});
|
|
||||||
if (loginRes.status !== 200 && loginRes.status !== 201) {
|
|
||||||
console.log(' Échec login:', loginRes.status, loginRes.data);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
token = loginRes.data?.access_token ?? loginRes.data?.accessToken ?? null;
|
|
||||||
if (!token) {
|
|
||||||
console.log(' Réponse login sans token:', JSON.stringify(loginRes.data, null, 2));
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
console.log(' OK, token reçu.');
|
|
||||||
console.log('');
|
|
||||||
} else {
|
|
||||||
console.log('TEST_EMAIL / TEST_PASSWORD non définis : GET /dossiers/:numero nécessite un token (401 attendu).');
|
|
||||||
console.log('');
|
|
||||||
}
|
|
||||||
|
|
||||||
let numeroDossier = NUMERO_DOSSIER;
|
|
||||||
if (!numeroDossier && token) {
|
|
||||||
console.log('2. Récupération d\'un numéro de dossier (GET /parents/pending-families)...');
|
|
||||||
const pendingRes = await request('GET', '/parents/pending-families', null, token);
|
|
||||||
if (pendingRes.status === 200 && Array.isArray(pendingRes.data) && pendingRes.data.length > 0) {
|
|
||||||
numeroDossier = pendingRes.data[0].numero_dossier || null;
|
|
||||||
console.log(' Premier numero_dossier:', numeroDossier);
|
|
||||||
} else {
|
|
||||||
console.log(' Aucune famille en attente ou erreur. Utilisez NUMERO_DOSSIER=2026-000001');
|
|
||||||
}
|
|
||||||
console.log('');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!numeroDossier) {
|
|
||||||
numeroDossier = '2026-000001';
|
|
||||||
console.log('2. Pas de numéro fourni, test avec numéro par défaut:', numeroDossier);
|
|
||||||
} else {
|
|
||||||
console.log('2. GET /dossiers/' + encodeURIComponent(numeroDossier));
|
|
||||||
}
|
|
||||||
|
|
||||||
const dossierRes = await request(
|
|
||||||
'GET',
|
|
||||||
'/dossiers/' + encodeURIComponent(numeroDossier),
|
|
||||||
null,
|
|
||||||
token
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(' Status:', dossierRes.status);
|
|
||||||
if (dossierRes.status === 200 && dossierRes.data) {
|
|
||||||
const d = dossierRes.data;
|
|
||||||
console.log(' type:', d.type);
|
|
||||||
console.log(' dossier (clés):', d.dossier ? Object.keys(d.dossier) : '-');
|
|
||||||
if (d.dossier && Array.isArray(d.dossier.enfants)) {
|
|
||||||
console.log(' enfants:', d.dossier.enfants.length);
|
|
||||||
d.dossier.enfants.forEach((e, i) => {
|
|
||||||
console.log(
|
|
||||||
` [${i + 1}] id=${e.id} first_name=${e.first_name} last_name=${e.last_name} birth_date=${e.birth_date} gender=${e.gender} genre=${e.genre} status=${e.status}`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
console.log('');
|
|
||||||
console.log('Réponse brute (dossier):');
|
|
||||||
console.log(JSON.stringify(d.dossier, null, 2));
|
|
||||||
} else {
|
|
||||||
console.log(' Réponse:', JSON.stringify(dossierRes.data, null, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('');
|
|
||||||
console.log('Fin du test.');
|
|
||||||
}
|
|
||||||
|
|
||||||
main().catch((err) => {
|
|
||||||
console.error('Erreur:', err.message || err);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
@ -1,110 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
/**
|
|
||||||
* Test des endpoints "comptes en attente" (ticket #107).
|
|
||||||
*
|
|
||||||
* Prérequis : backend démarré (npm run start:dev dans backend/).
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* node scripts/test-pending-api.js
|
|
||||||
* TEST_EMAIL=xxx TEST_PASSWORD=yyy node scripts/test-pending-api.js
|
|
||||||
* BASE_URL=https://app.ptits-pas.fr/api/v1 TEST_EMAIL=xxx TEST_PASSWORD=yyy node scripts/test-pending-api.js
|
|
||||||
*
|
|
||||||
* Sans TEST_EMAIL/TEST_PASSWORD : les GET protégés renverront 401 (normal).
|
|
||||||
* Avec un compte gestionnaire ou admin : affiche les listes en attente.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const BASE_URL = process.env.BASE_URL || 'http://localhost:3000/api/v1';
|
|
||||||
const TEST_EMAIL = process.env.TEST_EMAIL;
|
|
||||||
const TEST_PASSWORD = process.env.TEST_PASSWORD;
|
|
||||||
|
|
||||||
async function request(method, path, body = null, token = null) {
|
|
||||||
const url = path.startsWith('http') ? path : `${BASE_URL}${path}`;
|
|
||||||
const opts = {
|
|
||||||
method,
|
|
||||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
||||||
};
|
|
||||||
if (token) opts.headers.Authorization = `Bearer ${token}`;
|
|
||||||
if (body) opts.body = JSON.stringify(body);
|
|
||||||
const res = await fetch(url, opts);
|
|
||||||
const text = await res.text();
|
|
||||||
let data = null;
|
|
||||||
try {
|
|
||||||
data = text ? JSON.parse(text) : null;
|
|
||||||
} catch (_) {
|
|
||||||
data = text;
|
|
||||||
}
|
|
||||||
return { status: res.status, data };
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
console.log('Base URL:', BASE_URL);
|
|
||||||
console.log('');
|
|
||||||
|
|
||||||
let token = null;
|
|
||||||
if (TEST_EMAIL && TEST_PASSWORD) {
|
|
||||||
console.log('1. Login...');
|
|
||||||
const loginRes = await request('POST', '/auth/login', {
|
|
||||||
email: TEST_EMAIL,
|
|
||||||
password: TEST_PASSWORD,
|
|
||||||
});
|
|
||||||
if (loginRes.status !== 200 && loginRes.status !== 201) {
|
|
||||||
console.log(' Échec login:', loginRes.status, loginRes.data);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
token = loginRes.data?.access_token ?? loginRes.data?.accessToken ?? null;
|
|
||||||
if (!token) {
|
|
||||||
console.log(' Réponse login sans token:', JSON.stringify(loginRes.data, null, 2));
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
console.log(' OK, token reçu.');
|
|
||||||
console.log('');
|
|
||||||
} else {
|
|
||||||
console.log('TEST_EMAIL / TEST_PASSWORD non définis : les appels protégés vont renvoyer 401.');
|
|
||||||
console.log('Exemple: TEST_EMAIL=admin@example.com TEST_PASSWORD=xxx node scripts/test-pending-api.js');
|
|
||||||
console.log('');
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('2. GET /users/pending?role=assistante_maternelle');
|
|
||||||
const pendingUsersRes = await request(
|
|
||||||
'GET',
|
|
||||||
'/users/pending?role=assistante_maternelle',
|
|
||||||
null,
|
|
||||||
token
|
|
||||||
);
|
|
||||||
console.log(' Status:', pendingUsersRes.status);
|
|
||||||
if (pendingUsersRes.status === 200) {
|
|
||||||
const list = Array.isArray(pendingUsersRes.data) ? pendingUsersRes.data : [];
|
|
||||||
console.log(' Nombre d\'utilisateurs en attente (AM):', list.length);
|
|
||||||
list.forEach((u, i) => {
|
|
||||||
console.log(
|
|
||||||
` [${i + 1}] id=${u.id} email=${u.email} role=${u.role} statut=${u.statut} numero_dossier=${u.numero_dossier ?? '-'}`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log(' Réponse:', JSON.stringify(pendingUsersRes.data, null, 2));
|
|
||||||
}
|
|
||||||
console.log('');
|
|
||||||
|
|
||||||
console.log('3. GET /parents/pending-families');
|
|
||||||
const pendingFamiliesRes = await request('GET', '/parents/pending-families', null, token);
|
|
||||||
console.log(' Status:', pendingFamiliesRes.status);
|
|
||||||
if (pendingFamiliesRes.status === 200) {
|
|
||||||
const list = Array.isArray(pendingFamiliesRes.data) ? pendingFamiliesRes.data : [];
|
|
||||||
console.log(' Nombre de familles en attente:', list.length);
|
|
||||||
list.forEach((f, i) => {
|
|
||||||
console.log(
|
|
||||||
` [${i + 1}] libelle=${f.libelle} parentIds=${JSON.stringify(f.parentIds)} numero_dossier=${f.numero_dossier ?? '-'}`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log(' Réponse:', JSON.stringify(pendingFamiliesRes.data, null, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('');
|
|
||||||
console.log('Fin du test.');
|
|
||||||
}
|
|
||||||
|
|
||||||
main().catch((err) => {
|
|
||||||
console.error('Erreur:', err.message || err);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Inscription AM complète : jeux officiels alignés sur database/seed/03_seed_test_data.sql
|
|
||||||
# node tests/scripts/register-am-dubois-test.mjs [BASE_URL]
|
|
||||||
# node tests/scripts/register-am-mansouri-test.mjs [BASE_URL]
|
|
||||||
#
|
|
||||||
# Smoke curl (email + NIR jetables, hors seed — ne pas mélanger avec Marie / Fatima) :
|
|
||||||
# Usage: ./scripts/test-register-am.sh [BASE_URL]
|
|
||||||
# Exemple: ./scripts/test-register-am.sh http://localhost:3000/api/v1
|
|
||||||
|
|
||||||
BASE_URL="${1:-http://localhost:3000/api/v1}"
|
|
||||||
echo "POST $BASE_URL/auth/register/am (profil smoke, pas les AM du seed)"
|
|
||||||
echo "---"
|
|
||||||
|
|
||||||
curl -s -w "\n\nHTTP %{http_code}\n" -X POST "$BASE_URL/auth/register/am" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{
|
|
||||||
"email": "smoke.am.curl@ptits-pas.fr",
|
|
||||||
"prenom": "Smoke",
|
|
||||||
"nom": "CURLTEST",
|
|
||||||
"telephone": "0612345678",
|
|
||||||
"adresse": "1 rue Smoke",
|
|
||||||
"code_postal": "95870",
|
|
||||||
"ville": "Bezons",
|
|
||||||
"consentement_photo": false,
|
|
||||||
"date_naissance": "1986-12-15",
|
|
||||||
"nir": "186127500100279",
|
|
||||||
"numero_agrement": "AGR-SMOKE-CURL-001",
|
|
||||||
"capacite_accueil": 3,
|
|
||||||
"places_disponibles": 2,
|
|
||||||
"acceptation_cgu": true,
|
|
||||||
"acceptation_privacy": true
|
|
||||||
}'
|
|
||||||
@ -1,100 +0,0 @@
|
|||||||
/**
|
|
||||||
* Met à jour l'issue Gitea #119 : endpoint unifié GET /dossiers/:numeroDossier (option A)
|
|
||||||
* Usage: node backend/scripts/update-gitea-issue-119-dossiers.js
|
|
||||||
* Token : .gitea-token (racine), GITEA_TOKEN, ou docs/27_BRIEFING-FRONTEND.md
|
|
||||||
*/
|
|
||||||
const https = require('https');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const repoRoot = path.join(__dirname, '../..');
|
|
||||||
let token = process.env.GITEA_TOKEN;
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const tokenFile = path.join(repoRoot, '.gitea-token');
|
|
||||||
if (fs.existsSync(tokenFile)) token = fs.readFileSync(tokenFile, 'utf8').trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const briefing = fs.readFileSync(
|
|
||||||
path.join(repoRoot, 'docs/27_BRIEFING-FRONTEND.md'),
|
|
||||||
'utf8',
|
|
||||||
);
|
|
||||||
const m = briefing.match(/Token:\s*(giteabu_[a-f0-9]+)/);
|
|
||||||
if (m) token = m[1].trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
console.error('Token non trouvé');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const body = `## Besoin
|
|
||||||
|
|
||||||
Un **seul** endpoint **GET par numéro de dossier** qui renvoie le dossier complet, **AM ou famille** selon le numéro. Clé unique = numéro de dossier (usage : modale de validation, consultation gestionnaire, reprise, etc.).
|
|
||||||
|
|
||||||
**Option A – Endpoint unifié**
|
|
||||||
|
|
||||||
- **Route** : \`GET /api/v1/dossiers/:numeroDossier\` (ou \`GET /dossiers/:numeroDossier\` selon préfixe API).
|
|
||||||
- Le backend détermine si le numéro appartient à une **AM** ou à une **famille** (ex. lookup \`users\` / \`parents\` / \`assistantes_maternelles\`).
|
|
||||||
- **Réponse** avec discriminent :
|
|
||||||
- \`{ type: 'family', dossier: { numero_dossier, parents, enfants, presentation } }\`
|
|
||||||
- \`{ type: 'am', dossier: { numero_dossier, user, ... } }\` (fiche AM complète, champs utiles sans secrets)
|
|
||||||
- **Rôles** : SUPER_ADMIN, ADMINISTRATEUR, GESTIONNAIRE.
|
|
||||||
- **Réponses** : 200 (dossier), 403, 404 (numéro inconnu).
|
|
||||||
|
|
||||||
Aucun filtre par statut : on renvoie le dossier s'il existe ; le front affiche Valider/Refuser selon le statut.
|
|
||||||
|
|
||||||
**Labels suggérés** : backend, api, dossiers, gestionnaire
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Implémentation
|
|
||||||
|
|
||||||
- **Nouveau module ou route** : \`GET /dossiers/:numeroDossier\`.
|
|
||||||
- **Service** : trouver qui possède ce \`numero_dossier\` (famille → \`parents\`, AM → \`users\` + \`assistantes_maternelles\`). Appeler la logique existante dossier-famille ou construire le payload AM, puis retourner \`{ type, dossier }\`.
|
|
||||||
- **Réutiliser** : la logique actuelle \`GET /parents/dossier-famille/:numeroDossier\` peut être appelée en interne pour \`type: 'family'\` ; ajouter une branche \`type: 'am'\` avec un DTO « dossier AM complet ».
|
|
||||||
- DTO(s) : garder \`DossierFamilleCompletDto\` pour la famille ; ajouter un DTO pour le dossier AM (user sans secrets + infos AM). Réponse unifiée : \`{ type: 'am' | 'family', dossier: ... }\`.`;
|
|
||||||
|
|
||||||
const payload = JSON.stringify({
|
|
||||||
title: 'Endpoint unifié GET /dossiers/:numeroDossier (AM ou famille)',
|
|
||||||
body,
|
|
||||||
});
|
|
||||||
|
|
||||||
const opts = {
|
|
||||||
hostname: 'git.ptits-pas.fr',
|
|
||||||
path: '/api/v1/repos/jmartin/petitspas/issues/119',
|
|
||||||
method: 'PATCH',
|
|
||||||
headers: {
|
|
||||||
Authorization: 'token ' + token,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Content-Length': Buffer.byteLength(payload),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const req = https.request(opts, (res) => {
|
|
||||||
let d = '';
|
|
||||||
res.on('data', (c) => (d += c));
|
|
||||||
res.on('end', () => {
|
|
||||||
try {
|
|
||||||
const o = JSON.parse(d);
|
|
||||||
if (o.number || o.id) {
|
|
||||||
console.log('Issue #119 mise à jour.');
|
|
||||||
console.log('URL:', o.html_url || 'https://git.ptits-pas.fr/jmartin/petitspas/issues/119');
|
|
||||||
} else {
|
|
||||||
console.error('Erreur API:', o.message || d);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Réponse:', d);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
req.on('error', (e) => {
|
|
||||||
console.error(e);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
req.write(payload);
|
|
||||||
req.end();
|
|
||||||
@ -1,153 +0,0 @@
|
|||||||
/**
|
|
||||||
* Met à jour l'issue Gitea #140 — epic dashboard admin ch.6 famille.
|
|
||||||
* Usage: node backend/scripts/update-gitea-issue-140-ch6-famille.js
|
|
||||||
* Token : .gitea-token (racine), GITEA_TOKEN, ou docs/27_BRIEFING-FRONTEND.md
|
|
||||||
*/
|
|
||||||
const https = require('https');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const repoRoot = path.join(__dirname, '../..');
|
|
||||||
let token = process.env.GITEA_TOKEN;
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const tokenFile = path.join(repoRoot, '.gitea-token');
|
|
||||||
if (fs.existsSync(tokenFile)) token = fs.readFileSync(tokenFile, 'utf8').trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
const briefing = fs.readFileSync(
|
|
||||||
path.join(repoRoot, 'docs/27_BRIEFING-FRONTEND.md'),
|
|
||||||
'utf8',
|
|
||||||
);
|
|
||||||
const m = briefing.match(/Token:\s*(giteabu_[a-f0-9]+)/);
|
|
||||||
if (m) token = m[1].trim();
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
if (!token) {
|
|
||||||
console.error('Token non trouvé : .gitea-token ou GITEA_TOKEN (voir docs/26_GITEA-API.md)');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const body = `## Rôle de ce ticket
|
|
||||||
|
|
||||||
**#140 est un ticket epic / livraison** : il regroupe la mise en œuvre du **chapitre 6** du doc [28_EVOLUTION-FAMILLE-ET-RESPONSABLES.md](../docs/28_EVOLUTION-FAMILLE-ET-RESPONSABLES.md) (§6.1 et §6.2) sur la branche \`feature/140-dashboard-admin-ch6-famille\`.
|
|
||||||
|
|
||||||
Il **ne remplace pas** les tickets détaillés ci-dessous : il sert de **fil de livraison** (PR, recette, fermeture coordonnée). Chaque sous-ticket garde son périmètre propre ; #140 est clos quand l'ensemble est **fonctionnel et homogène en UI**.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Tickets couverts (périmètres embarqués)
|
|
||||||
|
|
||||||
| Ticket | Sujet | Rôle dans #140 |
|
|
||||||
|--------|--------|----------------|
|
|
||||||
| **#115** | Rattachement parent — **backend** | API \`POST/DELETE …/enfants/:enfantId\` |
|
|
||||||
| **#116** | Rattachement parent — **frontend** | UI rattacher / détacher depuis la fiche parent |
|
|
||||||
| **#130** | \`UserService\` — APIs admin | Appels \`getParents\`, \`getParent\`, \`getEnfants\`, \`updateParentFiche\`, etc. |
|
|
||||||
| **#131** | Fiche parent éditable | Modale parent (dashboard) — *hors fiche AM* |
|
|
||||||
| **#137** | Onglet **Enfants** | Liste globale admin + accès fiche enfant |
|
|
||||||
| **#138** | Fiche enfant + liste dans fiche parent | \`AdminChildDetailModal\` + liste enfants en bas de fiche parent |
|
|
||||||
|
|
||||||
> **Note :** fermer #140 peut entraîner la fermeture **partielle ou totale** de ces tickets selon ce qui est réellement livré et recetté dans la PR.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Hors scope #140
|
|
||||||
|
|
||||||
- **§6.3** — Création dossier admin sans numéro → **#129**
|
|
||||||
- Fiche **AM** éditable (dashboard) → reste **#131** (partie AM)
|
|
||||||
- Parcours gestionnaire « famille complexe » → **#139**
|
|
||||||
- Qualification responsable légal (combobox sur lien) → ticket à créer
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Backend (attendu / livré)
|
|
||||||
|
|
||||||
- [x] \`PATCH /parents/:id/fiche\` — édition fiche parent (admin/gestionnaire)
|
|
||||||
- [x] \`POST /parents/:id/enfants/:enfantId\` — rattacher un enfant existant
|
|
||||||
- [x] \`DELETE /parents/:id/enfants/:enfantId\` — détacher (garde-fou : ≥1 responsable / enfant)
|
|
||||||
- [x] \`GET /enfants\` enrichi ; \`PATCH /enfants/:id\` pour gestionnaire
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Frontend — fait
|
|
||||||
|
|
||||||
- [x] Modale **fiche parent** éditable (shell aligné validation, statut gélule, téléphone formaté, \`IdentityBlock\`)
|
|
||||||
- [x] Onglet **Enfants** — liste globale (\`EnfantManagementWidget\`)
|
|
||||||
- [x] Liste enfants dans fiche parent — cartes (photo, nom, âge ans/mois, statut), cadre blanc, scroll 2,5 lignes
|
|
||||||
- [x] Rattacher / détacher un enfant **existant** (API branchée)
|
|
||||||
- [x] Parsing robuste \`parentChildren\` + URLs médias \`/uploads\` en Flutter web
|
|
||||||
- [x] \`UserService\` — APIs parents / enfants / affiliation
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Frontend — reste à faire (bloquant clôture)
|
|
||||||
|
|
||||||
### Fiche enfant — #138 (UI)
|
|
||||||
- [ ] Reprendre \`AdminChildDetailModal\` : même **look & feel** que fiche parent / modales validation (largeur ~930 px, grille champs, photo enfant)
|
|
||||||
- [ ] Aligner dates, genre, statut sur les wizards validation famille
|
|
||||||
|
|
||||||
### Modale **rattacher** un enfant — #116 (UI)
|
|
||||||
- [ ] Remplacer le \`SimpleDialog\` actuel par une modale cohérente : liste type \`AdminEnfantUserCard\` (photo, nom, âge), recherche éventuelle
|
|
||||||
|
|
||||||
### Création d'un **nouvel** enfant depuis la fiche parent — doc §6.2
|
|
||||||
- [ ] **Non implémenté** aujourd'hui (seul le rattachement d'un enfant déjà en base existe)
|
|
||||||
- [ ] À trancher : inclus dans #140 si le back expose un \`POST\` admin depuis le contexte parent, sinon ticket dédié / extension #129
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Recette avant merge
|
|
||||||
|
|
||||||
1. Parent avec 0 / 1 / 3+ enfants — liste, scroll, compteur
|
|
||||||
2. Rattacher puis détacher (message si dernier responsable)
|
|
||||||
3. Clic enfant → fiche enfant (après refonte UI)
|
|
||||||
4. Onglet Enfants — même rendu cartes
|
|
||||||
5. Avatars photos (URLs absolues web)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Branche
|
|
||||||
|
|
||||||
\`feature/140-dashboard-admin-ch6-famille\`
|
|
||||||
|
|
||||||
## Références
|
|
||||||
|
|
||||||
- Doc produit : \`docs/28_EVOLUTION-FAMILLE-ET-RESPONSABLES.md\` §6.1, §6.2`;
|
|
||||||
|
|
||||||
const payload = JSON.stringify({ body });
|
|
||||||
|
|
||||||
const req = https.request(
|
|
||||||
{
|
|
||||||
hostname: 'git.ptits-pas.fr',
|
|
||||||
path: '/api/v1/repos/jmartin/petitspas/issues/140',
|
|
||||||
method: 'PATCH',
|
|
||||||
headers: {
|
|
||||||
Authorization: `token ${token}`,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Content-Length': Buffer.byteLength(payload),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
(res) => {
|
|
||||||
let data = '';
|
|
||||||
res.on('data', (chunk) => {
|
|
||||||
data += chunk;
|
|
||||||
});
|
|
||||||
res.on('end', () => {
|
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
||||||
const json = JSON.parse(data);
|
|
||||||
console.log('Issue #140 mise à jour :', json.html_url);
|
|
||||||
console.log('updated_at:', json.updated_at);
|
|
||||||
} else {
|
|
||||||
console.error('Erreur', res.statusCode, data);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
req.on('error', (err) => {
|
|
||||||
console.error(err);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
req.write(payload);
|
|
||||||
req.end();
|
|
||||||
18
backend/src/admin/admin.controller.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Controller, Post, Body, UseGuards, Req } from '@nestjs/common';
|
||||||
|
import { AdminService } from './admin.service';
|
||||||
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||||
|
|
||||||
|
@Controller('admin')
|
||||||
|
export class AdminController {
|
||||||
|
constructor(private readonly adminService: AdminService) {}
|
||||||
|
|
||||||
|
@Post('change-password')
|
||||||
|
@UseGuards(JwtAuthGuard)
|
||||||
|
async changePassword(
|
||||||
|
@Req() req,
|
||||||
|
@Body('oldPassword') oldPassword: string,
|
||||||
|
@Body('newPassword') newPassword: string,
|
||||||
|
) {
|
||||||
|
return this.adminService.changePassword(req.user.id, oldPassword, newPassword);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
backend/src/admin/admin.module.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { AdminController } from './admin.controller';
|
||||||
|
import { AdminService } from './admin.service';
|
||||||
|
import { PrismaModule } from '../prisma/prisma.module';
|
||||||
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
PrismaModule,
|
||||||
|
JwtModule.register({
|
||||||
|
secret: process.env.JWT_SECRET,
|
||||||
|
signOptions: { expiresIn: '1d' },
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
controllers: [AdminController],
|
||||||
|
providers: [AdminService],
|
||||||
|
})
|
||||||
|
export class AdminModule {}
|
||||||
40
backend/src/admin/admin.service.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||||
|
import { JwtService } from '@nestjs/jwt';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import * as bcrypt from 'bcrypt';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AdminService {
|
||||||
|
constructor(
|
||||||
|
private prisma: PrismaService,
|
||||||
|
private jwtService: JwtService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async changePassword(adminId: string, oldPassword: string, newPassword: string) {
|
||||||
|
// Récupérer l'administrateur
|
||||||
|
const admin = await this.prisma.admin.findUnique({
|
||||||
|
where: { id: adminId },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!admin) {
|
||||||
|
throw new UnauthorizedException('Administrateur non trouvé');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vérifier l'ancien mot de passe
|
||||||
|
const isPasswordValid = await bcrypt.compare(oldPassword, admin.password);
|
||||||
|
if (!isPasswordValid) {
|
||||||
|
throw new UnauthorizedException('Ancien mot de passe incorrect');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hasher le nouveau mot de passe
|
||||||
|
const hashedPassword = await bcrypt.hash(newPassword, 10);
|
||||||
|
|
||||||
|
// Mettre à jour le mot de passe
|
||||||
|
await this.prisma.admin.update({
|
||||||
|
where: { id: adminId },
|
||||||
|
data: { password: hashedPassword },
|
||||||
|
});
|
||||||
|
|
||||||
|
return { message: 'Mot de passe modifié avec succès' };
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,22 +0,0 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { AppController } from './app.controller';
|
|
||||||
import { AppService } from './app.service';
|
|
||||||
|
|
||||||
describe('AppController', () => {
|
|
||||||
let appController: AppController;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const app: TestingModule = await Test.createTestingModule({
|
|
||||||
controllers: [AppController],
|
|
||||||
providers: [AppService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
appController = app.get<AppController>(AppController);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('root', () => {
|
|
||||||
it('should return "Hello World!"', () => {
|
|
||||||
expect(appController.getHello()).toBe('Hello World!');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
import { Controller, Get } from '@nestjs/common';
|
|
||||||
import { AppService } from './app.service';
|
|
||||||
|
|
||||||
@Controller()
|
|
||||||
export class AppController {
|
|
||||||
constructor(private readonly appService: AppService) {}
|
|
||||||
|
|
||||||
@Get()
|
|
||||||
getOverView() {
|
|
||||||
return this.appService.getOverView();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get('hello')
|
|
||||||
getHello(): string {
|
|
||||||
return this.appService.getHello();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,75 +1,17 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { AppController } from './app.controller';
|
import { PrismaModule } from './prisma/prisma.module';
|
||||||
import { AppService } from './app.service';
|
import { AuthModule } from './auth/auth.module';
|
||||||
import appConfig from './config/app.config';
|
import { AdminModule } from './admin/admin.module';
|
||||||
import databaseConfig from './config/database.config';
|
|
||||||
import jwtConfig from './config/jwt.config';
|
|
||||||
import { configValidationSchema } from './config/validation.schema';
|
|
||||||
import { UserModule } from './routes/user/user.module';
|
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
||||||
import { APP_FILTER } from '@nestjs/core';
|
|
||||||
import { ParentsModule } from './routes/parents/parents.module';
|
|
||||||
import { AuthModule } from './routes/auth/auth.module';
|
|
||||||
import { SentryGlobalFilter } from '@sentry/nestjs/setup';
|
|
||||||
import { AllExceptionsFilter } from './common/filters/all_exceptions.filters';
|
|
||||||
import { EnfantsModule } from './routes/enfants/enfants.module';
|
|
||||||
import { AppConfigModule } from './modules/config/config.module';
|
|
||||||
import { DocumentsLegauxModule } from './modules/documents-legaux';
|
|
||||||
import { RelaisModule } from './routes/relais/relais.module';
|
|
||||||
import { DossiersModule } from './routes/dossiers/dossiers.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
// Gestion dynamique des fichiers .env
|
|
||||||
envFilePath: [`.env.${process.env.NODE_ENV || 'development'}`, '.env'],
|
|
||||||
// envFilePath: '.env',
|
|
||||||
|
|
||||||
// Chargement de configurations typées
|
|
||||||
load: [appConfig, databaseConfig, jwtConfig],
|
|
||||||
|
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
validationSchema: configValidationSchema,
|
|
||||||
}),
|
}),
|
||||||
TypeOrmModule.forRootAsync({
|
PrismaModule,
|
||||||
imports: [ConfigModule,
|
|
||||||
],
|
|
||||||
inject: [ConfigService],
|
|
||||||
useFactory: (config: ConfigService) => ({
|
|
||||||
type: 'postgres',
|
|
||||||
host: config.get('database.host'),
|
|
||||||
port: config.get<number>('database.port'),
|
|
||||||
username: config.get('database.username'),
|
|
||||||
password: config.get('database.password'),
|
|
||||||
database: config.get('database.database'),
|
|
||||||
entities: [__dirname + '/**/*.entity{.ts,.js}'],
|
|
||||||
synchronize: false,
|
|
||||||
migrations: [__dirname + '/migrations/**/*{.ts,.js}'],
|
|
||||||
logging: true,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
UserModule,
|
|
||||||
ParentsModule,
|
|
||||||
EnfantsModule,
|
|
||||||
AuthModule,
|
AuthModule,
|
||||||
AppConfigModule,
|
AdminModule,
|
||||||
DocumentsLegauxModule,
|
|
||||||
RelaisModule,
|
|
||||||
DossiersModule,
|
|
||||||
],
|
|
||||||
controllers: [AppController],
|
|
||||||
providers: [
|
|
||||||
AppService,
|
|
||||||
{
|
|
||||||
provide: APP_FILTER,
|
|
||||||
useClass: SentryGlobalFilter
|
|
||||||
},
|
|
||||||
{
|
|
||||||
provide: APP_FILTER,
|
|
||||||
useClass: AllExceptionsFilter,
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
@ -1,62 +0,0 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class AppService {
|
|
||||||
getHello(): string {
|
|
||||||
return 'Hello Test!!!';
|
|
||||||
}
|
|
||||||
|
|
||||||
getOverView() {
|
|
||||||
return {
|
|
||||||
name: "P'titsPas API",
|
|
||||||
version: "1.0",
|
|
||||||
description: "Documentation rapide des endpoints disponibles",
|
|
||||||
authentication: "JWT Bearer Token requis",
|
|
||||||
endpoints: [
|
|
||||||
{
|
|
||||||
method: "GET",
|
|
||||||
path: "/parents",
|
|
||||||
description: "Liste tous les parents",
|
|
||||||
roles: ["SUPER_ADMIN", "GESTIONNAIRE"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: "GET",
|
|
||||||
path: "/parents/:id",
|
|
||||||
description: "Récupère un parent par ID utilisateur",
|
|
||||||
roles: ["SUPER_ADMIN", "GESTIONNAIRE"],
|
|
||||||
params: ["id (UUID)"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: "POST",
|
|
||||||
path: "/parents",
|
|
||||||
description: "Crée un parent",
|
|
||||||
roles: ["SUPER_ADMIN", "GESTIONNAIRE"],
|
|
||||||
body: {
|
|
||||||
user_id: "UUID",
|
|
||||||
co_parent_id: "UUID (optionnel)"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: "PATCH",
|
|
||||||
path: "/parents/:id",
|
|
||||||
description: "Met à jour un parent",
|
|
||||||
roles: ["SUPER_ADMIN", "GESTIONNAIRE"],
|
|
||||||
params: ["id (UUID)"],
|
|
||||||
body: {
|
|
||||||
user_id: "UUID (optionnel)",
|
|
||||||
co_parent_id: "UUID (optionnel)"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: "DELETE",
|
|
||||||
path: "/parents/:id",
|
|
||||||
description: "Supprime un parent",
|
|
||||||
roles: ["SUPER_ADMIN"],
|
|
||||||
params: ["id (UUID)"]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
docs: "/api/docs"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
import { SetMetadata } from "@nestjs/common";
|
|
||||||
|
|
||||||
export const IS_PUBLIC_KEY = 'isPublic';
|
|
||||||
export const Public = () => SetMetadata(IS_PUBLIC_KEY, true);
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
import { SetMetadata } from "@nestjs/common";
|
|
||||||
|
|
||||||
export const Roles = (...roles: string[]) => SetMetadata("roles", roles);
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
import { createParamDecorator, ExecutionContext } from "@nestjs/common";
|
|
||||||
|
|
||||||
export const User = createParamDecorator((data: string | undefined, ctx: ExecutionContext) => {
|
|
||||||
const request = ctx.switchToHttp().getRequest();
|
|
||||||
const user = request.user;
|
|
||||||
return data ? user?.[data] : user;
|
|
||||||
});
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
import { IsDateString, IsOptional } from "class-validator";
|
|
||||||
|
|
||||||
export class DateRangeQueryDto {
|
|
||||||
@IsOptional()
|
|
||||||
@IsDateString()
|
|
||||||
start?: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsDateString()
|
|
||||||
end?: string;
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
import { IsUUID } from "class-validator";
|
|
||||||
|
|
||||||
export class IdParamDto {
|
|
||||||
@IsUUID()
|
|
||||||
id: string;
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
import { IsOptional, IsPositive } from "class-validator";
|
|
||||||
|
|
||||||
export class PaginationQueryDto {
|
|
||||||
@IsOptional()
|
|
||||||
@IsPositive()
|
|
||||||
offset?: number;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsPositive()
|
|
||||||
limit?: number;
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
import { IsOptional, IsString, MinLength } from "class-validator";
|
|
||||||
|
|
||||||
export class SearchQueryDto {
|
|
||||||
@IsOptional()
|
|
||||||
@IsString()
|
|
||||||
@MinLength(2)
|
|
||||||
q?: string;
|
|
||||||
}
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
import { ArgumentsHost, Catch, ExceptionFilter, HttpException, HttpStatus } from "@nestjs/common";
|
|
||||||
|
|
||||||
@Catch()
|
|
||||||
export class AllExceptionsFilter implements ExceptionFilter {
|
|
||||||
catch(exception: unknown, host: ArgumentsHost) {
|
|
||||||
const ctx = host.switchToHttp();
|
|
||||||
const response = ctx.getResponse();
|
|
||||||
const request = ctx.getRequest();
|
|
||||||
const status =
|
|
||||||
exception instanceof HttpException
|
|
||||||
? exception.getStatus()
|
|
||||||
: HttpStatus.INTERNAL_SERVER_ERROR;
|
|
||||||
|
|
||||||
const message =
|
|
||||||
exception instanceof HttpException
|
|
||||||
? exception.getResponse()
|
|
||||||
: { message: 'Internal server error' };
|
|
||||||
|
|
||||||
response.status(status).json({
|
|
||||||
success: false,
|
|
||||||
statusCode: status,
|
|
||||||
timestamp: new Date().toISOString(),
|
|
||||||
path: request.url,
|
|
||||||
message,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
import { CanActivate, ExecutionContext, Injectable, UnauthorizedException } from "@nestjs/common";
|
|
||||||
import { Reflector } from "@nestjs/core";
|
|
||||||
import { JwtService } from "@nestjs/jwt";
|
|
||||||
import { Request } from 'express';
|
|
||||||
import { IS_PUBLIC_KEY } from "../decorators/public.decorator";
|
|
||||||
import { ConfigService } from "@nestjs/config";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class AuthGuard implements CanActivate {
|
|
||||||
constructor(
|
|
||||||
private readonly jwtService: JwtService,
|
|
||||||
private readonly reflector: Reflector,
|
|
||||||
private readonly configService: ConfigService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
||||||
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
|
||||||
context.getHandler(),
|
|
||||||
context.getClass(),
|
|
||||||
]);
|
|
||||||
if (isPublic) return true;
|
|
||||||
|
|
||||||
const request = context.switchToHttp().getRequest<Request>();
|
|
||||||
if (request.path.startsWith('/api-docs')) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const authHeader = request.headers['authorization'] as string | undefined;
|
|
||||||
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
|
||||||
throw new UnauthorizedException('Token manquant ou invalide');
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = authHeader.split(' ')[1];
|
|
||||||
try {
|
|
||||||
const payload = await this.jwtService.verifyAsync(token, {
|
|
||||||
secret: this.configService.get<string>('jwt.accessSecret'),
|
|
||||||
});
|
|
||||||
|
|
||||||
request.user = {
|
|
||||||
...payload,
|
|
||||||
id: payload.sub,
|
|
||||||
};
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
throw new UnauthorizedException('Token invalide ou expiré');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
import { CanActivate, ExecutionContext, Injectable } from "@nestjs/common";
|
|
||||||
import { Reflector } from "@nestjs/core";
|
|
||||||
import { Observable } from "rxjs";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class RolesGuard implements CanActivate {
|
|
||||||
constructor(private readonly reflector: Reflector) {}
|
|
||||||
|
|
||||||
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean> {
|
|
||||||
const requiredRoles = this.reflector.getAllAndOverride<string[]>('roles', [
|
|
||||||
context.getHandler(),
|
|
||||||
context.getClass(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!requiredRoles || requiredRoles.length === 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const request = context.switchToHttp().getRequest();
|
|
||||||
const user = request.user;
|
|
||||||
if (!user || !user.role) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return requiredRoles.includes(user.role);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,69 +0,0 @@
|
|||||||
import {
|
|
||||||
CallHandler,
|
|
||||||
ExecutionContext,
|
|
||||||
Injectable,
|
|
||||||
NestInterceptor,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { tap } from 'rxjs/operators';
|
|
||||||
import { Request } from 'express';
|
|
||||||
|
|
||||||
/** Clés à masquer dans les logs (corps de requête) */
|
|
||||||
const SENSITIVE_KEYS = [
|
|
||||||
'password',
|
|
||||||
'smtp_password',
|
|
||||||
'token',
|
|
||||||
'accessToken',
|
|
||||||
'refreshToken',
|
|
||||||
'secret',
|
|
||||||
];
|
|
||||||
|
|
||||||
function maskBody(body: unknown): unknown {
|
|
||||||
if (body === null || body === undefined) return body;
|
|
||||||
if (typeof body !== 'object') return body;
|
|
||||||
const out: Record<string, unknown> = {};
|
|
||||||
for (const [key, value] of Object.entries(body)) {
|
|
||||||
const lower = key.toLowerCase();
|
|
||||||
const isSensitive = SENSITIVE_KEYS.some((s) => lower.includes(s));
|
|
||||||
out[key] = isSensitive ? '***' : value;
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class LogRequestInterceptor implements NestInterceptor {
|
|
||||||
private readonly enabled: boolean;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.enabled =
|
|
||||||
process.env.LOG_API_REQUESTS === 'true' ||
|
|
||||||
process.env.LOG_API_REQUESTS === '1';
|
|
||||||
}
|
|
||||||
|
|
||||||
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {
|
|
||||||
if (!this.enabled) return next.handle();
|
|
||||||
|
|
||||||
const http = context.switchToHttp();
|
|
||||||
const req = http.getRequest<Request>();
|
|
||||||
const { method, url, body, query } = req;
|
|
||||||
const hasBody = body && Object.keys(body).length > 0;
|
|
||||||
|
|
||||||
const logLine = [
|
|
||||||
`[API] ${method} ${url}`,
|
|
||||||
Object.keys(query || {}).length ? `query=${JSON.stringify(query)}` : '',
|
|
||||||
hasBody ? `body=${JSON.stringify(maskBody(body))}` : '',
|
|
||||||
]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(' ');
|
|
||||||
|
|
||||||
console.log(logLine);
|
|
||||||
|
|
||||||
return next.handle().pipe(
|
|
||||||
tap({
|
|
||||||
next: () => {
|
|
||||||
// Optionnel: log du statut en fin de requête (si besoin plus tard)
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from "@nestjs/common";
|
|
||||||
import { map, Observable, timestamp } from "rxjs";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class TransformInterceptor implements NestInterceptor {
|
|
||||||
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
|
|
||||||
return next.handle().pipe(
|
|
||||||
map((data) => ({
|
|
||||||
success: true,
|
|
||||||
timestamp: new Date().toISOString(),
|
|
||||||
data
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,109 +0,0 @@
|
|||||||
/**
|
|
||||||
* Utilitaire de validation du NIR (numéro de sécurité sociale français).
|
|
||||||
* - Format 15 caractères (chiffres ou 2A/2B pour la Corse).
|
|
||||||
* - Clé de contrôle : 97 - (NIR13 mod 97). Pour 2A/2B, conversion temporaire (INSEE : 2A→19, 2B→20).
|
|
||||||
* - En cas d'incohérence avec les données (sexe, date, lieu) : warning uniquement, pas de rejet.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const NIR_CORSE_2A = '19';
|
|
||||||
const NIR_CORSE_2B = '20';
|
|
||||||
|
|
||||||
/** Regex 15 caractères : sexe (1-3) + 4 chiffres + (2A|2B|2 chiffres) + 6 chiffres + 2 chiffres clé */
|
|
||||||
const NIR_FORMAT = /^[1-3]\d{4}(?:2A|2B|\d{2})\d{6}\d{2}$/i;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convertit le NIR en chaîne de 13 chiffres pour le calcul de la clé (2A→19, 2B→20).
|
|
||||||
*/
|
|
||||||
export function nirTo13Digits(nir: string): string {
|
|
||||||
const n = nir.toUpperCase().replace(/\s/g, '');
|
|
||||||
if (n.length !== 15) return '';
|
|
||||||
const dept = n.slice(5, 7);
|
|
||||||
let deptNum: string;
|
|
||||||
if (dept === '2A') deptNum = NIR_CORSE_2A;
|
|
||||||
else if (dept === '2B') deptNum = NIR_CORSE_2B;
|
|
||||||
else deptNum = dept;
|
|
||||||
return n.slice(0, 5) + deptNum + n.slice(7, 13);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vérifie que le format NIR est valide (15 caractères, 2A/2B acceptés).
|
|
||||||
*/
|
|
||||||
export function isNirFormatValid(nir: string): boolean {
|
|
||||||
if (!nir || typeof nir !== 'string') return false;
|
|
||||||
const n = nir.replace(/\s/g, '').toUpperCase();
|
|
||||||
return NIR_FORMAT.test(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calcule la clé de contrôle attendue (97 - (NIR13 mod 97)).
|
|
||||||
* Retourne un nombre entre 1 et 97.
|
|
||||||
*/
|
|
||||||
export function computeNirKey(nir13: string): number {
|
|
||||||
const num = parseInt(nir13, 10);
|
|
||||||
if (Number.isNaN(num) || nir13.length !== 13) return -1;
|
|
||||||
return 97 - (num % 97);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vérifie la clé de contrôle du NIR (15 caractères).
|
|
||||||
* Retourne true si le NIR est valide (format + clé).
|
|
||||||
*/
|
|
||||||
export function isNirKeyValid(nir: string): boolean {
|
|
||||||
const n = nir.replace(/\s/g, '').toUpperCase();
|
|
||||||
if (n.length !== 15) return false;
|
|
||||||
const nir13 = nirTo13Digits(n);
|
|
||||||
if (nir13.length !== 13) return false;
|
|
||||||
const expectedKey = computeNirKey(nir13);
|
|
||||||
const actualKey = parseInt(n.slice(13, 15), 10);
|
|
||||||
return expectedKey === actualKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NirValidationResult {
|
|
||||||
valid: boolean;
|
|
||||||
error?: string;
|
|
||||||
warning?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Valide le NIR (format + clé). En cas d'incohérence avec date de naissance ou sexe, ajoute un warning sans invalider.
|
|
||||||
*/
|
|
||||||
export function validateNir(
|
|
||||||
nir: string,
|
|
||||||
options?: { dateNaissance?: string; genre?: 'H' | 'F' },
|
|
||||||
): NirValidationResult {
|
|
||||||
const n = (nir || '').replace(/\s/g, '').toUpperCase();
|
|
||||||
if (n.length === 0) return { valid: false, error: 'Le NIR est requis' };
|
|
||||||
if (!isNirFormatValid(n)) {
|
|
||||||
return { valid: false, error: 'Le NIR doit contenir 15 caractères (chiffres, ou 2A/2B pour la Corse)' };
|
|
||||||
}
|
|
||||||
if (!isNirKeyValid(n)) {
|
|
||||||
return { valid: false, error: 'Clé de contrôle du NIR invalide' };
|
|
||||||
}
|
|
||||||
let warning: string | undefined;
|
|
||||||
if (options?.genre) {
|
|
||||||
const sexNir = n[0];
|
|
||||||
const expectedSex = options.genre === 'F' ? '2' : '1';
|
|
||||||
if (sexNir !== expectedSex) {
|
|
||||||
warning = 'Le NIR ne correspond pas au genre indiqué (position 1 du NIR).';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (options?.dateNaissance) {
|
|
||||||
try {
|
|
||||||
const d = new Date(options.dateNaissance);
|
|
||||||
if (!Number.isNaN(d.getTime())) {
|
|
||||||
const year2 = d.getFullYear() % 100;
|
|
||||||
const month = d.getMonth() + 1;
|
|
||||||
const nirYear = parseInt(n.slice(1, 3), 10);
|
|
||||||
const nirMonth = parseInt(n.slice(3, 5), 10);
|
|
||||||
if (nirYear !== year2 || nirMonth !== month) {
|
|
||||||
warning = warning
|
|
||||||
? `${warning} Le NIR ne correspond pas à la date de naissance (positions 2-5).`
|
|
||||||
: 'Le NIR ne correspond pas à la date de naissance indiquée (positions 2-5).';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { valid: true, warning };
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
import { sanitizeUserForApi } from './sanitize-user-for-api';
|
|
||||||
import { RoleType, StatutUtilisateurType, Users } from '../../entities/users.entity';
|
|
||||||
|
|
||||||
describe('sanitizeUserForApi', () => {
|
|
||||||
const base: Users = {
|
|
||||||
id: 'u1',
|
|
||||||
email: 'a@b.fr',
|
|
||||||
prenom: 'Paul',
|
|
||||||
nom: 'Parent',
|
|
||||||
role: RoleType.PARENT,
|
|
||||||
statut: StatutUtilisateurType.ACTIF,
|
|
||||||
password: 'hash',
|
|
||||||
token_creation_mdp: 'tok',
|
|
||||||
token_creation_mdp_expire_le: new Date(),
|
|
||||||
password_reset_token: 'rst',
|
|
||||||
password_reset_expires: new Date(),
|
|
||||||
} as Users;
|
|
||||||
|
|
||||||
it('retire password et tokens', () => {
|
|
||||||
const out = sanitizeUserForApi(base)!;
|
|
||||||
expect(out.prenom).toBe('Paul');
|
|
||||||
expect(out.nom).toBe('Parent');
|
|
||||||
expect(out.password).toBeUndefined();
|
|
||||||
expect(out.token_creation_mdp).toBeUndefined();
|
|
||||||
expect(out.password_reset_token).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('retourne undefined si user absent', () => {
|
|
||||||
expect(sanitizeUserForApi(null)).toBeUndefined();
|
|
||||||
expect(sanitizeUserForApi(undefined)).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import { Users } from 'src/entities/users.entity';
|
|
||||||
|
|
||||||
/** Champs sensibles exclus des réponses API (ticket #131 — user / co_parent). */
|
|
||||||
const SENSITIVE_USER_KEYS: (keyof Users)[] = [
|
|
||||||
'password',
|
|
||||||
'token_creation_mdp',
|
|
||||||
'token_creation_mdp_expire_le',
|
|
||||||
'password_reset_token',
|
|
||||||
'password_reset_expires',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retourne une copie utilisateur sans secrets (hash MDP, tokens).
|
|
||||||
* Utilisé pour `user` et `co_parent` dans les réponses Parents.
|
|
||||||
*/
|
|
||||||
export function sanitizeUserForApi(user?: Users | null): Users | undefined {
|
|
||||||
if (!user) return undefined;
|
|
||||||
const safe = { ...user } as Users;
|
|
||||||
for (const key of SENSITIVE_USER_KEYS) {
|
|
||||||
delete safe[key];
|
|
||||||
}
|
|
||||||
return safe;
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
import { registerAs } from '@nestjs/config';
|
|
||||||
|
|
||||||
export default registerAs('', () => ({
|
|
||||||
port: process.env.PORT,
|
|
||||||
env: process.env.NODE_ENV,
|
|
||||||
}));
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
import { registerAs } from '@nestjs/config';
|
|
||||||
|
|
||||||
export default registerAs('database', () => ({
|
|
||||||
host: process.env.POSTGRES_HOST,
|
|
||||||
port: process.env.POSTGRES_PORT,
|
|
||||||
username: process.env.POSTGRES_USER,
|
|
||||||
password: process.env.POSTGRES_PASSWORD,
|
|
||||||
database: process.env.POSTGRES_DB,
|
|
||||||
}));
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
import { registerAs } from '@nestjs/config';
|
|
||||||
|
|
||||||
export default registerAs('jwt', () => ({
|
|
||||||
accessSecret: process.env.JWT_ACCESS_SECRET,
|
|
||||||
accessExpiresIn: process.env.JWT_ACCESS_EXPIRES,
|
|
||||||
refreshSecret: process.env.JWT_REFRESH_SECRET,
|
|
||||||
refreshExpiresIn: process.env.JWT_REFRESH_EXPIRES,
|
|
||||||
}));
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
import { DataSource } from 'typeorm';
|
|
||||||
import { config } from 'dotenv';
|
|
||||||
|
|
||||||
config();
|
|
||||||
|
|
||||||
export default new DataSource({
|
|
||||||
type: 'postgres',
|
|
||||||
host: process.env.DATABASE_HOST,
|
|
||||||
port: parseInt(process.env.DATABASE_PORT || '5432', 10),
|
|
||||||
username: process.env.DATABASE_USERNAME,
|
|
||||||
password: process.env.DATABASE_PASSWORD,
|
|
||||||
database: process.env.DATABASE_NAME,
|
|
||||||
entities: ['src/**/*.entity.ts'],
|
|
||||||
migrations: ['src/migrations/*.ts'],
|
|
||||||
});
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import * as Joi from 'joi';
|
|
||||||
|
|
||||||
export const configValidationSchema = Joi.object({
|
|
||||||
NODE_ENV: Joi.string()
|
|
||||||
.valid('development', 'production', 'test')
|
|
||||||
.default('development'),
|
|
||||||
PORT: Joi.number().optional(),
|
|
||||||
|
|
||||||
// Base de données
|
|
||||||
POSTGRES_HOST: Joi.string().required(),
|
|
||||||
POSTGRES_PORT: Joi.number().required(),
|
|
||||||
POSTGRES_USER: Joi.string().required(),
|
|
||||||
POSTGRES_PASSWORD: Joi.string().required(),
|
|
||||||
POSTGRES_DB: Joi.string().required(),
|
|
||||||
|
|
||||||
// JWT
|
|
||||||
JWT_ACCESS_SECRET: Joi.string().required(),
|
|
||||||
JWT_ACCESS_EXPIRES: Joi.string().required(),
|
|
||||||
JWT_REFRESH_SECRET: Joi.string().required(),
|
|
||||||
JWT_REFRESH_EXPIRES: Joi.string().required(),
|
|
||||||
});
|
|
||||||
72
backend/src/controllers/theme.controller.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import { Request, Response } from 'express';
|
||||||
|
import { ThemeService, ThemeData } from '../services/theme.service';
|
||||||
|
|
||||||
|
export class ThemeController {
|
||||||
|
// Créer un nouveau thème
|
||||||
|
static async createTheme(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const themeData: ThemeData = req.body;
|
||||||
|
const theme = await ThemeService.createTheme(themeData);
|
||||||
|
res.status(201).json(theme);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Erreur lors de la création du thème' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Récupérer tous les thèmes
|
||||||
|
static async getAllThemes(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const themes = await ThemeService.getAllThemes();
|
||||||
|
res.json(themes);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Erreur lors de la récupération des thèmes' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Récupérer le thème actif
|
||||||
|
static async getActiveTheme(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const theme = await ThemeService.getActiveTheme();
|
||||||
|
if (!theme) {
|
||||||
|
return res.status(404).json({ error: 'Aucun thème actif trouvé' });
|
||||||
|
}
|
||||||
|
res.json(theme);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Erreur lors de la récupération du thème actif' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activer un thème
|
||||||
|
static async activateTheme(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { themeId } = req.params;
|
||||||
|
const theme = await ThemeService.activateTheme(themeId);
|
||||||
|
res.json(theme);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Erreur lors de l\'activation du thème' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mettre à jour un thème
|
||||||
|
static async updateTheme(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { themeId } = req.params;
|
||||||
|
const themeData: Partial<ThemeData> = req.body;
|
||||||
|
const theme = await ThemeService.updateTheme(themeId, themeData);
|
||||||
|
res.json(theme);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Erreur lors de la mise à jour du thème' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprimer un thème
|
||||||
|
static async deleteTheme(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { themeId } = req.params;
|
||||||
|
await ThemeService.deleteTheme(themeId);
|
||||||
|
res.status(204).send();
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Erreur lors de la suppression du thème' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,40 +0,0 @@
|
|||||||
import {
|
|
||||||
Entity,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
Column,
|
|
||||||
ManyToOne,
|
|
||||||
JoinColumn,
|
|
||||||
CreateDateColumn,
|
|
||||||
} from 'typeorm';
|
|
||||||
import { Users } from './users.entity';
|
|
||||||
import { DocumentLegal } from './document-legal.entity';
|
|
||||||
|
|
||||||
@Entity('acceptations_documents')
|
|
||||||
export class AcceptationDocument {
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@ManyToOne(() => Users, { nullable: false, onDelete: 'CASCADE' })
|
|
||||||
@JoinColumn({ name: 'id_utilisateur' })
|
|
||||||
utilisateur: Users;
|
|
||||||
|
|
||||||
@ManyToOne(() => DocumentLegal, { nullable: true })
|
|
||||||
@JoinColumn({ name: 'id_document' })
|
|
||||||
document: DocumentLegal | null;
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 50, nullable: false })
|
|
||||||
type_document: 'cgu' | 'privacy';
|
|
||||||
|
|
||||||
@Column({ type: 'integer', nullable: false })
|
|
||||||
version_document: number;
|
|
||||||
|
|
||||||
@CreateDateColumn({ name: 'accepte_le', type: 'timestamptz' })
|
|
||||||
accepteLe: Date;
|
|
||||||
|
|
||||||
@Column({ type: 'inet', nullable: true })
|
|
||||||
ip_address: string | null;
|
|
||||||
|
|
||||||
@Column({ type: 'text', nullable: true })
|
|
||||||
user_agent: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
import {
|
|
||||||
Entity,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
Column,
|
|
||||||
ManyToOne,
|
|
||||||
JoinColumn,
|
|
||||||
CreateDateColumn,
|
|
||||||
} from 'typeorm';
|
|
||||||
import { AssistanteMaternelle } from './assistantes_maternelles.entity';
|
|
||||||
import { Children } from './children.entity';
|
|
||||||
import { Users } from './users.entity';
|
|
||||||
|
|
||||||
@Entity('enfants_assistantes_maternelles', { schema: 'public' })
|
|
||||||
export class AmChildren {
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@Column({ name: 'id_am', type: 'uuid' })
|
|
||||||
amId: string;
|
|
||||||
|
|
||||||
@Column({ name: 'id_enfant', type: 'uuid' })
|
|
||||||
enfantId: string;
|
|
||||||
|
|
||||||
@Column({ name: 'date_debut', type: 'date' })
|
|
||||||
date_debut: Date;
|
|
||||||
|
|
||||||
@Column({ name: 'date_fin', type: 'date', nullable: true })
|
|
||||||
date_fin?: Date;
|
|
||||||
|
|
||||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
|
||||||
cree_le: Date;
|
|
||||||
|
|
||||||
@Column({ name: 'cree_par', type: 'uuid', nullable: true })
|
|
||||||
cree_par?: string;
|
|
||||||
|
|
||||||
@ManyToOne(() => AssistanteMaternelle, (am) => am.amChildren, { onDelete: 'CASCADE' })
|
|
||||||
@JoinColumn({ name: 'id_am', referencedColumnName: 'user_id' })
|
|
||||||
am: AssistanteMaternelle;
|
|
||||||
|
|
||||||
@ManyToOne(() => Children, (c) => c.amLinks, { onDelete: 'CASCADE' })
|
|
||||||
@JoinColumn({ name: 'id_enfant', referencedColumnName: 'id' })
|
|
||||||
child: Children;
|
|
||||||
|
|
||||||
@ManyToOne(() => Users, { nullable: true, onDelete: 'SET NULL' })
|
|
||||||
@JoinColumn({ name: 'cree_par', referencedColumnName: 'id' })
|
|
||||||
createdBy?: Users;
|
|
||||||
}
|
|
||||||
@ -1,58 +0,0 @@
|
|||||||
import { Entity, PrimaryColumn, Column, OneToOne, OneToMany, JoinColumn } from 'typeorm';
|
|
||||||
import { Users } from './users.entity';
|
|
||||||
import { AmChildren } from './am_children.entity';
|
|
||||||
|
|
||||||
@Entity('assistantes_maternelles')
|
|
||||||
export class AssistanteMaternelle {
|
|
||||||
// PK = FK vers utilisateurs.id
|
|
||||||
@PrimaryColumn('uuid', { name: 'id_utilisateur' })
|
|
||||||
user_id: string;
|
|
||||||
|
|
||||||
@OneToOne(() => Users, (user) => user.assistanteMaternelle, {
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
|
||||||
@JoinColumn({ name: 'id_utilisateur', referencedColumnName: 'id' })
|
|
||||||
user: Users;
|
|
||||||
|
|
||||||
@Column({ name: 'numero_agrement', length: 50, nullable: true })
|
|
||||||
approval_number?: string;
|
|
||||||
|
|
||||||
@Column({ name: 'nir_chiffre', length: 15, nullable: true })
|
|
||||||
nir?: string;
|
|
||||||
|
|
||||||
@Column({ name: 'nb_max_enfants', type: 'int', nullable: true })
|
|
||||||
max_children?: number;
|
|
||||||
|
|
||||||
@Column({ name: 'biographie', type: 'text', nullable: true })
|
|
||||||
biography?: string;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
name: 'disponible',
|
|
||||||
type: 'boolean',
|
|
||||||
default: true,
|
|
||||||
nullable: true,
|
|
||||||
})
|
|
||||||
available?: boolean;
|
|
||||||
|
|
||||||
@Column({ name: 'ville_residence', length: 100, nullable: true })
|
|
||||||
residence_city?: string;
|
|
||||||
|
|
||||||
@Column( { name: 'date_agrement', type: 'date', nullable: true })
|
|
||||||
agreement_date?: Date;
|
|
||||||
|
|
||||||
@Column( { name: 'annee_experience', type: 'smallint', nullable: true })
|
|
||||||
years_experience?: number;
|
|
||||||
|
|
||||||
@Column( { name: 'specialite', length: 100, nullable: true })
|
|
||||||
specialty?: string;
|
|
||||||
|
|
||||||
@Column( { name: 'place_disponible', type: 'integer', nullable: true })
|
|
||||||
places_available?: number;
|
|
||||||
|
|
||||||
/** Numéro de dossier (format AAAA-NNNNNN), même valeur que sur utilisateurs (ticket #103) */
|
|
||||||
@Column({ name: 'numero_dossier', length: 20, nullable: true })
|
|
||||||
numero_dossier?: string;
|
|
||||||
|
|
||||||
@OneToMany(() => AmChildren, (ac) => ac.am)
|
|
||||||
amChildren: AmChildren[];
|
|
||||||
}
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
|
|
||||||
import { Contrat } from "./contrats.entity";
|
|
||||||
import { Users } from "./users.entity";
|
|
||||||
|
|
||||||
export enum StatutAvenantType {
|
|
||||||
PROPOSE = 'propose',
|
|
||||||
ACCEPTE = 'accepte',
|
|
||||||
REFUSE = 'refuse',
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity('avenants_contrats')
|
|
||||||
export class AvenantContrat {
|
|
||||||
// Define your columns and relationships here
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@ManyToOne(() => Contrat, { onDelete: 'CASCADE' })
|
|
||||||
@JoinColumn({ name: 'id_contrat' })
|
|
||||||
contrat: Contrat;
|
|
||||||
|
|
||||||
@Column({ type: 'jsonb', nullable: true, name: 'modifications' })
|
|
||||||
modifications?: any;
|
|
||||||
|
|
||||||
@ManyToOne(() => Users, { nullable: true })
|
|
||||||
@JoinColumn({ name: 'initie_par', referencedColumnName: 'id' })
|
|
||||||
initiator?: Users;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'enum',
|
|
||||||
enum: StatutAvenantType,
|
|
||||||
enumName: 'statut_avenant_type',
|
|
||||||
default: StatutAvenantType.PROPOSE,
|
|
||||||
name: 'statut'
|
|
||||||
})
|
|
||||||
statut: StatutAvenantType;
|
|
||||||
|
|
||||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
|
||||||
createdAt: Date;
|
|
||||||
|
|
||||||
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
|
||||||
updatedAt: Date;
|
|
||||||
}
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
import {
|
|
||||||
Entity, PrimaryGeneratedColumn, Column,
|
|
||||||
OneToMany, ManyToMany, CreateDateColumn, JoinTable
|
|
||||||
} from 'typeorm';
|
|
||||||
import { Parents } from './parents.entity';
|
|
||||||
import { ParentsChildren } from './parents_children.entity';
|
|
||||||
import { AmChildren } from './am_children.entity';
|
|
||||||
import { Dossier } from './dossiers.entity';
|
|
||||||
|
|
||||||
export enum StatutEnfantType {
|
|
||||||
A_NAITRE = 'a_naitre',
|
|
||||||
SCOLARISE = 'scolarise',
|
|
||||||
GARDE = 'garde',
|
|
||||||
SANS_GARDE = 'sans_garde',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum GenreType {
|
|
||||||
H = 'H',
|
|
||||||
F = 'F',
|
|
||||||
AUTRE = 'Autre',
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity('enfants')
|
|
||||||
export class Children {
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'enum',
|
|
||||||
enum: StatutEnfantType,
|
|
||||||
enumName: 'statut_enfant_type',
|
|
||||||
name: 'statut'
|
|
||||||
})
|
|
||||||
status: StatutEnfantType;
|
|
||||||
|
|
||||||
@Column({ name: 'prenom', length: 100, nullable: true })
|
|
||||||
first_name?: string;
|
|
||||||
|
|
||||||
@Column({ name: 'nom', length: 100, nullable: true })
|
|
||||||
last_name?: string;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'enum',
|
|
||||||
enum: GenreType,
|
|
||||||
enumName: 'genre_type',
|
|
||||||
nullable: true,
|
|
||||||
name: 'genre'
|
|
||||||
})
|
|
||||||
gender?: GenreType;
|
|
||||||
|
|
||||||
@Column({ type: 'date', nullable: true, name: 'date_naissance' })
|
|
||||||
birth_date?: Date;
|
|
||||||
|
|
||||||
@Column({ type: 'date', nullable: true, name: 'date_prevue_naissance' })
|
|
||||||
due_date?: Date;
|
|
||||||
|
|
||||||
@Column({ nullable: true, name: 'photo_url', type: 'text' })
|
|
||||||
photo_url?: string;
|
|
||||||
|
|
||||||
@Column({ default: false, name: 'consentement_photo', type: 'boolean' })
|
|
||||||
consent_photo: boolean;
|
|
||||||
|
|
||||||
@Column({ type: 'timestamptz', nullable: true, name: 'date_consentement_photo' })
|
|
||||||
consent_photo_at?: Date;
|
|
||||||
|
|
||||||
@Column({ default: false, name: 'est_multiple', type: 'boolean' })
|
|
||||||
is_multiple: boolean;
|
|
||||||
|
|
||||||
// Lien via table de jointure enfants_parents
|
|
||||||
@OneToMany(() => ParentsChildren, pc => pc.child)
|
|
||||||
parentLinks: ParentsChildren[];
|
|
||||||
|
|
||||||
@OneToMany(() => AmChildren, (ac) => ac.child)
|
|
||||||
amLinks: AmChildren[];
|
|
||||||
|
|
||||||
// Relation avec Dossier
|
|
||||||
@OneToMany(() => Dossier, d => d.child)
|
|
||||||
dossiers: Dossier[];
|
|
||||||
}
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
import {
|
|
||||||
Entity,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
Column,
|
|
||||||
ManyToOne,
|
|
||||||
JoinColumn,
|
|
||||||
CreateDateColumn,
|
|
||||||
UpdateDateColumn,
|
|
||||||
} from 'typeorm';
|
|
||||||
import { Users } from './users.entity';
|
|
||||||
|
|
||||||
@Entity('configuration')
|
|
||||||
export class Configuration {
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 100, unique: true, nullable: false })
|
|
||||||
cle: string;
|
|
||||||
|
|
||||||
@Column({ type: 'text', nullable: true })
|
|
||||||
valeur: string | null;
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 50, nullable: false })
|
|
||||||
type: 'string' | 'number' | 'boolean' | 'json' | 'encrypted';
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
|
||||||
categorie: 'email' | 'app' | 'security' | null;
|
|
||||||
|
|
||||||
@Column({ type: 'text', nullable: true })
|
|
||||||
description: string | null;
|
|
||||||
|
|
||||||
@UpdateDateColumn({ name: 'modifie_le' })
|
|
||||||
modifieLe: Date;
|
|
||||||
|
|
||||||
@ManyToOne(() => Users, { nullable: true })
|
|
||||||
@JoinColumn({ name: 'modifie_par' })
|
|
||||||
modifiePar: Users | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,57 +0,0 @@
|
|||||||
import { Column, CreateDateColumn, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
|
|
||||||
import { Dossier } from "./dossiers.entity";
|
|
||||||
|
|
||||||
export enum StatutContratType {
|
|
||||||
BROUILLON = 'brouillon',
|
|
||||||
EN_ATTENTE_SIGNATURE = 'en_attente_signature',
|
|
||||||
VALIDE = 'valide',
|
|
||||||
RESILIE = 'resilie',
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity('contrats')
|
|
||||||
export class Contrat {
|
|
||||||
// Define your columns and relationships here
|
|
||||||
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@OneToOne(() => Dossier, {onDelete: 'CASCADE'} )
|
|
||||||
@JoinColumn({ name: 'id_dossier'})
|
|
||||||
dossier: Dossier;
|
|
||||||
|
|
||||||
@Column({type: 'jsonb', nullable: true, name: 'planning'})
|
|
||||||
planning?: any;
|
|
||||||
|
|
||||||
@Column({type: 'numeric', precision: 6, scale: 2, nullable: true, name: 'tarif_horaire'})
|
|
||||||
hourly_rate?: string;
|
|
||||||
|
|
||||||
@Column({type: 'numeric', precision: 6, scale: 2, nullable: true, name: 'indemnites_repas'})
|
|
||||||
meal_indemnity?: string;
|
|
||||||
|
|
||||||
@Column( { name: 'date_debut', type: 'date', nullable: true })
|
|
||||||
start_date?: Date;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'enum',
|
|
||||||
enum: StatutContratType,
|
|
||||||
enumName: 'statut_contrat_type',
|
|
||||||
default: StatutContratType.BROUILLON,
|
|
||||||
name: 'statut'
|
|
||||||
})
|
|
||||||
statut: StatutContratType;
|
|
||||||
|
|
||||||
@Column({type: 'boolean', default: false, name: 'signe_parent'})
|
|
||||||
signed_by_parent: boolean;
|
|
||||||
|
|
||||||
@Column({type: 'boolean', default: false, name: 'signe_am'})
|
|
||||||
signed_by_am: boolean;
|
|
||||||
|
|
||||||
@Column({type: 'timestamptz', nullable: true, name: 'finalise_le'})
|
|
||||||
finalized_at?: Date;
|
|
||||||
|
|
||||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
|
||||||
created_at: Date;
|
|
||||||
|
|
||||||
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
|
||||||
updated_at: Date;
|
|
||||||
}
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
import {
|
|
||||||
Entity,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
Column,
|
|
||||||
ManyToOne,
|
|
||||||
JoinColumn,
|
|
||||||
CreateDateColumn,
|
|
||||||
} from 'typeorm';
|
|
||||||
import { Users } from './users.entity';
|
|
||||||
|
|
||||||
@Entity('documents_legaux')
|
|
||||||
export class DocumentLegal {
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 50, nullable: false })
|
|
||||||
type: 'cgu' | 'privacy';
|
|
||||||
|
|
||||||
@Column({ type: 'integer', nullable: false })
|
|
||||||
version: number;
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 255, nullable: false })
|
|
||||||
fichier_nom: string;
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 500, nullable: false })
|
|
||||||
fichier_path: string;
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 64, nullable: false })
|
|
||||||
fichier_hash: string;
|
|
||||||
|
|
||||||
@Column({ type: 'boolean', default: false })
|
|
||||||
actif: boolean;
|
|
||||||
|
|
||||||
@ManyToOne(() => Users, { nullable: true })
|
|
||||||
@JoinColumn({ name: 'televerse_par' })
|
|
||||||
televersePar: Users | null;
|
|
||||||
|
|
||||||
@CreateDateColumn({ name: 'televerse_le', type: 'timestamptz' })
|
|
||||||
televerseLe: Date;
|
|
||||||
|
|
||||||
@Column({ name: 'active_le', type: 'timestamptz', nullable: true })
|
|
||||||
activeLe: Date | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
import {
|
|
||||||
Entity,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
Column,
|
|
||||||
ManyToOne,
|
|
||||||
OneToMany,
|
|
||||||
CreateDateColumn,
|
|
||||||
UpdateDateColumn,
|
|
||||||
JoinColumn,
|
|
||||||
} from 'typeorm';
|
|
||||||
import { Parents } from './parents.entity';
|
|
||||||
import { Children } from './children.entity';
|
|
||||||
import { StatutDossierType } from './dossiers.entity';
|
|
||||||
|
|
||||||
/** Un dossier = une famille, N enfants (texte de motivation unique, liste d'enfants). */
|
|
||||||
@Entity('dossier_famille')
|
|
||||||
export class DossierFamille {
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@Column({ name: 'numero_dossier', length: 20 })
|
|
||||||
numero_dossier: string;
|
|
||||||
|
|
||||||
@ManyToOne(() => Parents, { onDelete: 'CASCADE', nullable: false })
|
|
||||||
@JoinColumn({ name: 'id_parent', referencedColumnName: 'user_id' })
|
|
||||||
parent: Parents;
|
|
||||||
|
|
||||||
@Column({ type: 'text', nullable: true })
|
|
||||||
presentation?: string;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'enum',
|
|
||||||
enum: StatutDossierType,
|
|
||||||
enumName: 'statut_dossier_type',
|
|
||||||
default: StatutDossierType.ENVOYE,
|
|
||||||
name: 'statut',
|
|
||||||
})
|
|
||||||
statut: StatutDossierType;
|
|
||||||
|
|
||||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
|
||||||
cree_le: Date;
|
|
||||||
|
|
||||||
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
|
||||||
modifie_le: Date;
|
|
||||||
|
|
||||||
@OneToMany(() => DossierFamilleEnfant, (dfe) => dfe.dossier_famille)
|
|
||||||
enfants: DossierFamilleEnfant[];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity('dossier_famille_enfants')
|
|
||||||
export class DossierFamilleEnfant {
|
|
||||||
@Column({ name: 'id_dossier_famille', primary: true })
|
|
||||||
id_dossier_famille: string;
|
|
||||||
|
|
||||||
@Column({ name: 'id_enfant', primary: true })
|
|
||||||
id_enfant: string;
|
|
||||||
|
|
||||||
@ManyToOne(() => DossierFamille, (df) => df.enfants, { onDelete: 'CASCADE' })
|
|
||||||
@JoinColumn({ name: 'id_dossier_famille' })
|
|
||||||
dossier_famille: DossierFamille;
|
|
||||||
|
|
||||||
@ManyToOne(() => Children, { onDelete: 'CASCADE' })
|
|
||||||
@JoinColumn({ name: 'id_enfant' })
|
|
||||||
enfant: Children;
|
|
||||||
}
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
import {
|
|
||||||
Entity, PrimaryGeneratedColumn, Column,
|
|
||||||
ManyToOne, OneToMany, CreateDateColumn, UpdateDateColumn, JoinColumn
|
|
||||||
} from 'typeorm';
|
|
||||||
import { Parents } from './parents.entity';
|
|
||||||
import { Children } from './children.entity';
|
|
||||||
import { Message } from './messages.entity';
|
|
||||||
|
|
||||||
export enum StatutDossierType {
|
|
||||||
ENVOYE = 'envoye',
|
|
||||||
ACCEPTE = 'accepte',
|
|
||||||
REFUSE = 'refuse',
|
|
||||||
CLOTURE = 'cloture',
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity('dossiers')
|
|
||||||
export class Dossier {
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@ManyToOne(() => Parents, p => p.dossiers, { onDelete: 'CASCADE', nullable: false })
|
|
||||||
@JoinColumn({ name: 'id_parent', referencedColumnName: 'user_id' })
|
|
||||||
parent: Parents;
|
|
||||||
|
|
||||||
@ManyToOne(() => Children, c => c.dossiers, { onDelete: 'CASCADE', nullable: false })
|
|
||||||
@JoinColumn({ name: 'id_enfant', referencedColumnName: 'id' })
|
|
||||||
child: Children;
|
|
||||||
|
|
||||||
@Column({ type: 'text', nullable: true, name: 'presentation' })
|
|
||||||
presentation?: string;
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 50, nullable: true, name: 'type_contrat' })
|
|
||||||
type_contrat?: string;
|
|
||||||
|
|
||||||
@Column({ type: 'boolean', default: false, name: 'repas' })
|
|
||||||
meals: boolean;
|
|
||||||
|
|
||||||
@Column({ type: 'numeric', precision: 10, scale: 2, nullable: true, name: 'budget' })
|
|
||||||
budget?: number;
|
|
||||||
|
|
||||||
@Column({ type: 'jsonb', nullable: true, name: 'planning_souhaite' })
|
|
||||||
desired_schedule?: any;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'enum',
|
|
||||||
enum: StatutDossierType,
|
|
||||||
enumName: 'statut_dossier_type',
|
|
||||||
default: StatutDossierType.ENVOYE,
|
|
||||||
name: 'statut'
|
|
||||||
})
|
|
||||||
status: StatutDossierType;
|
|
||||||
|
|
||||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
|
||||||
created_at: Date;
|
|
||||||
|
|
||||||
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
|
||||||
updated_at: Date;
|
|
||||||
|
|
||||||
@OneToMany(() => Message, m => m.dossier)
|
|
||||||
messages: Message[];
|
|
||||||
}
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
|
|
||||||
import { Children } from "./children.entity";
|
|
||||||
import { Users } from "./users.entity";
|
|
||||||
import { Parents } from "./parents.entity";
|
|
||||||
|
|
||||||
export enum TypeEvenementType {
|
|
||||||
ABSENCE_ENFANT = 'absence_enfant',
|
|
||||||
CONGE_AM = 'conge_am',
|
|
||||||
CONGE_PARENT = 'conge_parent',
|
|
||||||
ARRET_MALADIE_AM = 'arret_maladie_am',
|
|
||||||
EVENEMENT_RPE = 'evenement_rpe',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum StatutEvenementType {
|
|
||||||
PROPOSE = 'propose',
|
|
||||||
VALIDE = 'valide',
|
|
||||||
REFUSE = 'refuse',
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity('evenements')
|
|
||||||
export class Evenement {
|
|
||||||
// Define your columns and relationships here
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'enum',
|
|
||||||
enum: TypeEvenementType,
|
|
||||||
enumName: 'type_evenement_type',
|
|
||||||
name: 'type'
|
|
||||||
})
|
|
||||||
type: TypeEvenementType;
|
|
||||||
|
|
||||||
@ManyToOne(() => Children, { onDelete: 'CASCADE', nullable: true })
|
|
||||||
@JoinColumn({ name: 'id_enfant', referencedColumnName: 'id' })
|
|
||||||
child?: Children;
|
|
||||||
|
|
||||||
@ManyToOne(() => Users, { nullable: true })
|
|
||||||
@JoinColumn({ name: 'id_am', referencedColumnName: 'id' })
|
|
||||||
assistanteMaternelle?: Users;
|
|
||||||
|
|
||||||
@ManyToOne(() => Parents, { nullable: true })
|
|
||||||
@JoinColumn({ name: 'id_parent', referencedColumnName: 'user_id' })
|
|
||||||
parent?: Parents;
|
|
||||||
|
|
||||||
@ManyToOne(() => Users, { nullable: true })
|
|
||||||
@JoinColumn({ name: 'cree_par', referencedColumnName: 'id' })
|
|
||||||
created_by?: Users;
|
|
||||||
|
|
||||||
@Column({ type: 'timestamptz', nullable: true, name: 'date_debut' })
|
|
||||||
start_date?: Date;
|
|
||||||
|
|
||||||
@Column({ type: 'timestamptz', nullable: true, name: 'date_fin' })
|
|
||||||
end_date?: Date;
|
|
||||||
|
|
||||||
@Column({ type: 'text', nullable: true, name: 'commentaires' })
|
|
||||||
comments?: string;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'enum',
|
|
||||||
enum: StatutEvenementType,
|
|
||||||
enumName: 'statut_evenement_type',
|
|
||||||
name: 'statut',
|
|
||||||
default: StatutEvenementType.PROPOSE
|
|
||||||
})
|
|
||||||
status: StatutEvenementType;
|
|
||||||
|
|
||||||
@Column({type: 'timestamptz', nullable: true, name: 'delai_grace'})
|
|
||||||
grace_deadline?: Date;
|
|
||||||
|
|
||||||
@Column({type: 'boolean', default: false, name: 'urgent'})
|
|
||||||
urgent: boolean;
|
|
||||||
|
|
||||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
|
||||||
created_at: Date;
|
|
||||||
|
|
||||||
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
|
||||||
updated_at: Date;
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
import {
|
|
||||||
Entity, PrimaryGeneratedColumn, Column,
|
|
||||||
ManyToOne, JoinColumn, CreateDateColumn
|
|
||||||
} from 'typeorm';
|
|
||||||
import { Dossier } from './dossiers.entity';
|
|
||||||
import { Users } from './users.entity';
|
|
||||||
|
|
||||||
@Entity('messages')
|
|
||||||
export class Message {
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@ManyToOne(() => Dossier, d => d.messages, { onDelete: 'CASCADE', nullable: false })
|
|
||||||
@JoinColumn({ name: 'id_dossier' })
|
|
||||||
dossier: Dossier;
|
|
||||||
|
|
||||||
@ManyToOne(() => Users, u => u.messages, { onDelete: 'CASCADE', nullable: false })
|
|
||||||
@JoinColumn({ name: 'id_expediteur' })
|
|
||||||
sender: Users;
|
|
||||||
|
|
||||||
@Column({ type: 'text', name: 'contenu' })
|
|
||||||
content: string;
|
|
||||||
|
|
||||||
@Column({ type: 'boolean', name: 're_redige_par_ia', default: false })
|
|
||||||
reRedigeParIA: boolean;
|
|
||||||
|
|
||||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
|
||||||
created_at: Date;
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
|
||||||
import { Users } from "./users.entity";
|
|
||||||
|
|
||||||
@Entity('notifications')
|
|
||||||
export class Notification {
|
|
||||||
// Define your columns and relationships here
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@ManyToOne(() => Users, { onDelete: 'CASCADE' })
|
|
||||||
@JoinColumn({ name: 'id_utilisateur', referencedColumnName: 'id' })
|
|
||||||
user: Users;
|
|
||||||
|
|
||||||
@Column({ type: 'text', name: 'contenu' })
|
|
||||||
content: string;
|
|
||||||
|
|
||||||
@Column({type: 'boolean', name: 'lu', default: false})
|
|
||||||
read: boolean;
|
|
||||||
|
|
||||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
|
||||||
created_at: Date;
|
|
||||||
|
|
||||||
}
|
|
||||||