Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: première passe de test sur le validateur des intentions #527

Merged
merged 11 commits into from
Feb 24, 2025
13 changes: 7 additions & 6 deletions server/src/db/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ColumnType } from "kysely";
import type { DemandeType } from "shared/enum/demandeTypeEnum";

export type Generated<T> =
T extends ColumnType<infer S, infer I, infer U> ? ColumnType<S, I | undefined, U> : ColumnType<T, T | undefined, T>;
Expand Down Expand Up @@ -192,7 +193,7 @@ export interface Demande {
codeDispositif: string | null;
uai: string;
rentreeScolaire: number | null;
typeDemande: string | null;
typeDemande: DemandeType | null;
motif: string[] | null;
autreMotif: string | null;
coloration: boolean | null;
Expand Down Expand Up @@ -255,7 +256,7 @@ export interface DemandeIntentionNonMaterializedView {
codeDispositif: string | null;
uai: string | null;
rentreeScolaire: number | null;
typeDemande: string | null;
typeDemande: DemandeType | null;
motif: string[] | null;
autreMotif: string | null;
coloration: boolean | null;
Expand Down Expand Up @@ -495,7 +496,7 @@ export interface Intention {
codeDispositif: string | null;
uai: string | null;
rentreeScolaire: number | null;
typeDemande: string | null;
typeDemande: DemandeType | null;
motif: string[] | null;
autreMotif: string | null;
coloration: boolean | null;
Expand Down Expand Up @@ -585,7 +586,7 @@ export interface LatestDemandeIntentionNonMaterializedView {
codeDispositif: string | null;
uai: string | null;
rentreeScolaire: number | null;
typeDemande: string | null;
typeDemande: DemandeType | null;
motif: string[] | null;
autreMotif: string | null;
coloration: boolean | null;
Expand Down Expand Up @@ -661,7 +662,7 @@ export interface LatestDemandeNonMaterializedView {
codeDispositif: string | null;
uai: string | null;
rentreeScolaire: number | null;
typeDemande: string | null;
typeDemande: DemandeType | null;
motif: string[] | null;
autreMotif: string | null;
coloration: boolean | null;
Expand Down Expand Up @@ -723,7 +724,7 @@ export interface LatestIntentionNonMaterializedView {
codeDispositif: string | null;
uai: string | null;
rentreeScolaire: number | null;
typeDemande: string | null;
typeDemande: DemandeType | null;
motif: string[] | null;
autreMotif: string | null;
coloration: boolean | null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DemandeStatutEnum } from "shared/enum/demandeStatutEnum";
import {DemandeTypeEnum } from "shared/enum/demandeTypeEnum";
import { describe, expect, it, vi } from "vitest";

import { submitDemandeFactory } from "./submitDemande.usecase";
Expand Down Expand Up @@ -29,7 +30,7 @@ const demande = {
createdBy: "user-id",
codeDispositif: "codeDispositif",
rentreeScolaire: 2025,
typeDemande: "augmentation",
typeDemande: DemandeTypeEnum["augmentation_nette"],
motif: ["autre"],
autreMotif: "autre motif",
poursuitePedagogique: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DemandeStatutEnum } from "shared/enum/demandeStatutEnum";
import {DemandeTypeEnum } from "shared/enum/demandeTypeEnum";
import { describe, expect, it, vi } from "vitest";

import { submitIntentionFactory } from "@/modules/intentions/usecases/submitIntention/submitIntention.usecase";
Expand Down Expand Up @@ -30,7 +31,7 @@ const intention = {
createdBy: "user-id",
codeDispositif: "codeDispositif",
rentreeScolaire: 2025,
typeDemande: "augmentation",
typeDemande: DemandeTypeEnum["augmentation_nette"],
motif: ["autre"],
autreMotif: "autre motif",
poursuitePedagogique: false,
Expand Down
8 changes: 6 additions & 2 deletions shared/routes/schemas/get.corrections.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";
import { TypeFormationSpecifiqueZodType } from "../../enum/formationSpecifiqueEnum";
import { FormationSpecifiqueFlagsSchema } from "../../schema/formationSpecifiqueFlagsSchema";
import { OptionSchema } from "../../schema/optionSchema";
Expand Down Expand Up @@ -65,7 +66,7 @@ export const FiltersSchema = z.object({
codeDepartement: z.array(z.string()).optional(),
uai: z.array(z.string()).optional(),
rentreeScolaire: z.string().optional(),
typeDemande: z.array(z.string()).optional(),
typeDemande: z.array(DemandeTypeZodType).optional(),
statut: z.array(DemandeStatutZodType.exclude(["supprimée"])).optional(),
codeNiveauDiplome: z.array(z.string()).optional(),
cfd: z.array(z.string()).optional(),
Expand Down Expand Up @@ -98,7 +99,10 @@ export const getCorrectionsSchema = {
academies: z.array(OptionSchema),
departements: z.array(OptionSchema),
etablissements: z.array(OptionSchema),
typesDemande: z.array(OptionSchema),
typesDemande: z.array(z.object({
label: DemandeTypeZodType,
value: DemandeTypeZodType,
})),
diplomes: z.array(OptionSchema),
formations: z.array(OptionSchema),
libellesNsf: z.array(OptionSchema),
Expand Down
3 changes: 2 additions & 1 deletion shared/routes/schemas/get.demande.numero.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";
import { FormationSpecifiqueFlagsSchema } from "../../schema/formationSpecifiqueFlagsSchema";
const UserSchema = z.object({
fullname: z.string().optional(),
Expand Down Expand Up @@ -63,7 +64,7 @@ const DemandeSchema = z.object({
libelleFCIL: z.string().optional(),
// Type de demande
rentreeScolaire: z.coerce.number(),
typeDemande: z.string(),
typeDemande: DemandeTypeZodType,
coloration: z.boolean(),
libelleColoration: z.string().optional(),
// Capacité
Expand Down
3 changes: 2 additions & 1 deletion shared/routes/schemas/get.demandes.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";
import { OptionSchema } from "../../schema/optionSchema";

const UserSchema = z.object({
Expand All @@ -26,7 +27,7 @@ const DemandeItem = z.object({
libelleFCIL: z.string().optional(),
// Type de demande
rentreeScolaire: z.coerce.number().optional(),
typeDemande: z.string().optional(),
typeDemande: DemandeTypeZodType.optional(),
coloration: z.boolean().optional(),
libelleColoration: z.string().optional(),
// Capacités
Expand Down
3 changes: 2 additions & 1 deletion shared/routes/schemas/get.intention.numero.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { z } from "zod";
import { AvisStatutZodType } from "../../enum/avisStatutEnum";
import { AvisTypeZodType } from "../../enum/avisTypeEnum";
import { DemandeStatutEnum, DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";
import { FormationSpecifiqueFlagsSchema } from "../../schema/formationSpecifiqueFlagsSchema";
const UserSchema = z.object({
fullname: z.string().optional(),
Expand Down Expand Up @@ -44,7 +45,7 @@ const IntentionSchema = z.object({
libelleFCIL: z.string().optional(),
// Type de demande
rentreeScolaire: z.coerce.number(),
typeDemande: z.string(),
typeDemande: DemandeTypeZodType,
coloration: z.boolean(),
libelleColoration: z.string().optional(),
// Capacité
Expand Down
3 changes: 2 additions & 1 deletion shared/routes/schemas/get.intentions.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";
import { OptionSchema } from "../../schema/optionSchema";

const UserSchema = z.object({
Expand Down Expand Up @@ -34,7 +35,7 @@ const IntentionsItem = z.object({
libelleFCIL: z.string().optional(),
// Type de demande
rentreeScolaire: z.coerce.number().optional(),
typeDemande: z.string(),
typeDemande: DemandeTypeZodType,
coloration: z.boolean(),
libelleColoration: z.string().optional(),
// Capacité
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";
import { TypeFormationSpecifiqueZodType } from "../../enum/formationSpecifiqueEnum";
import { FormationSpecifiqueFlagsSchema } from "../../schema/formationSpecifiqueFlagsSchema";
import { OptionSchema } from "../../schema/optionSchema";
Expand All @@ -26,7 +27,7 @@ const DemandeSchema = z.object({
codeDispositif: z.string(),
cfd: z.string(),
// Demande
typeDemande: z.string(),
typeDemande: DemandeTypeZodType,
motif: z.array(z.string()),
autreMotif: z.string().optional(),
rentreeScolaire: z.coerce.number().optional(),
Expand Down Expand Up @@ -109,7 +110,7 @@ export const FiltersSchema = z.object({
codeDepartement: z.array(z.string()).optional(),
uai: z.array(z.string()).optional(),
rentreeScolaire: z.string().optional(),
typeDemande: z.array(z.string()).optional(),
typeDemande: z.array(DemandeTypeZodType).optional(),
statut: z.array(DemandeStatutZodType.exclude(["supprimée"])).optional(),
codeNiveauDiplome: z.array(z.string()).optional(),
cfd: z.array(z.string()).optional(),
Expand Down Expand Up @@ -139,7 +140,10 @@ export const getDemandesRestitutionIntentionsSchema = {
academies: z.array(OptionSchema),
departements: z.array(OptionSchema),
etablissements: z.array(OptionSchema),
typesDemande: z.array(OptionSchema),
typesDemande: z.array(z.object({
label: DemandeTypeZodType,
value: DemandeTypeZodType
})),
diplomes: z.array(OptionSchema),
formations: z.array(OptionSchema),
libellesNsf: z.array(OptionSchema),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";
import { TypeFormationSpecifiqueZodType } from "../../enum/formationSpecifiqueEnum";

const CountCapaciteStatsDemandesSchema = z.object({
Expand All @@ -18,7 +19,7 @@ export const FiltersSchema = z.object({
codeDepartement: z.array(z.string()).optional(),
uai: z.array(z.string()).optional(),
rentreeScolaire: z.string().optional(),
typeDemande: z.array(z.string()).optional(),
typeDemande: z.array(DemandeTypeZodType).optional(),
statut: z.array(DemandeStatutZodType.exclude(["supprimée"])).optional(),
codeNiveauDiplome: z.array(z.string()).optional(),
cfd: z.array(z.string()).optional(),
Expand Down
3 changes: 2 additions & 1 deletion shared/routes/schemas/post.demande.import.numero.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";

const EtablissementMetadataSchema = z
.object({
Expand Down Expand Up @@ -40,7 +41,7 @@ const DemandeSchema = z.object({
codeDispositif: z.string(),
libelleFCIL: z.string().optional(),
rentreeScolaire: z.coerce.number(),
typeDemande: z.string(),
typeDemande: DemandeTypeZodType,
compensationUai: z.string().optional(),
compensationCfd: z.string().optional(),
compensationCodeDispositif: z.string().optional(),
Expand Down
3 changes: 2 additions & 1 deletion shared/routes/schemas/post.demande.submit.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";
import { unEscapeString } from "../../utils/escapeString";

export const submitDemandeSchema = {
Expand All @@ -12,7 +13,7 @@ export const submitDemandeSchema = {
libelleFCIL: z.string().optional(),
// Type de demande
rentreeScolaire: z.coerce.number(),
typeDemande: z.string(),
typeDemande: DemandeTypeZodType,
coloration: z.boolean(),
libelleColoration: z.string().optional(),
// Capacité
Expand Down
3 changes: 2 additions & 1 deletion shared/routes/schemas/post.intention.import.numero.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";

const EtablissementMetadataSchema = z
.object({
Expand Down Expand Up @@ -38,7 +39,7 @@ const IntentionSchema = z.object({
codeDispositif: z.string(),
libelleFCIL: z.string().optional(),
rentreeScolaire: z.coerce.number(),
typeDemande: z.string(),
typeDemande: DemandeTypeZodType,
compensationUai: z.string().optional(),
compensationCfd: z.string().optional(),
compensationCodeDispositif: z.string().optional(),
Expand Down
3 changes: 2 additions & 1 deletion shared/routes/schemas/post.intention.submit.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from "zod";

import { DemandeStatutZodType } from "../../enum/demandeStatutEnum";
import { DemandeTypeZodType } from "../../enum/demandeTypeEnum";
import { unEscapeString } from "../../utils/escapeString";

export const submitIntentionSchema = {
Expand All @@ -12,7 +13,7 @@ export const submitIntentionSchema = {
libelleFCIL: z.string().optional(),
// Type de demande
rentreeScolaire: z.coerce.number(),
typeDemande: z.string(),
typeDemande: DemandeTypeZodType,
coloration: z.boolean(),
libelleColoration: z.string().optional(),
// Capacité
Expand Down
Loading
Loading