diff --git a/.eslintrc.json b/.eslintrc.json index 49ee147585..ca73ac10bd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,9 +17,9 @@ // https://github.com/tailwindlabs/tailwindcss/issues/11097 "../ui/src/tailwind-preset", - // Backend is an application but is also used as a library, - // we want our front apps to be allowed to reference it - "@/backend" + // `@/domain` imports are used as a library but exists inside the `backend` application. + // We explicitely allow our front apps to be allowed to reference it. + "@/domain" ], "depConstraints": [ { diff --git a/.gitignore b/.gitignore index 74e53c1044..cece4bc63a 100644 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,4 @@ storybook-static **/package.json # gcloud credentials -backend/src/common/services/keyfile.json +keyfile.json diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/Indicateur/detail/useIndicateurServices.ts b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/Indicateur/detail/useIndicateurServices.ts index 59e3dd6d29..b400f62f33 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/Indicateur/detail/useIndicateurServices.ts +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/Indicateur/detail/useIndicateurServices.ts @@ -1,7 +1,7 @@ import { Indicateurs } from '@/api'; import { supabaseClient } from '@/app/core-logic/api/supabase'; import { useCollectiviteId } from '@/app/core-logic/hooks/params'; -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { useMutation, useQuery, useQueryClient } from 'react-query'; /** Met à jour les services pilotes d'un indicateur */ diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/IndicateurPersoNouveau.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/IndicateurPersoNouveau.tsx index 53cbc9d761..b5f6dcd4eb 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/IndicateurPersoNouveau.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/IndicateurPersoNouveau.tsx @@ -7,7 +7,7 @@ import { makeCollectiviteIndicateursUrl } from '@/app/app/paths'; import { useCollectiviteId } from '@/app/core-logic/hooks/params'; import ThematiquesDropdown from '@/app/ui/dropdownLists/ThematiquesDropdown/ThematiquesDropdown'; import FormikInput from '@/app/ui/shared/form/formik/FormikInput'; -import { Thematique } from '@/backend/shared'; +import { Thematique } from '@/domain/shared'; import { Alert, Button, Checkbox, Field, FormSectionGrid } from '@/ui'; import { Form, Formik } from 'formik'; import { useRouter } from 'next/navigation'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/IndicateurCard/IndicateurCardEdit/IndicateurCardEditModal.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/IndicateurCard/IndicateurCardEdit/IndicateurCardEditModal.tsx index d177c3b7e0..d56245a498 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/IndicateurCard/IndicateurCardEdit/IndicateurCardEditModal.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/IndicateurCard/IndicateurCardEdit/IndicateurCardEditModal.tsx @@ -3,8 +3,8 @@ import { useUpdateIndicateurCard } from '@/app/app/pages/collectivite/Indicateur import PersonnesDropdown from '@/app/ui/dropdownLists/PersonnesDropdown/PersonnesDropdown'; import ServicesPilotesDropdown from '@/app/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown'; import ThematiquesDropdown from '@/app/ui/dropdownLists/ThematiquesDropdown/ThematiquesDropdown'; -import { Tag } from '@/backend/collectivites'; -import { Thematique } from '@/backend/shared'; +import { Tag } from '@/domain/collectivites'; +import { Thematique } from '@/domain/shared'; import { Field, Modal, ModalFooterOKCancel } from '@/ui'; import { OpenState } from '@/ui/utils/types'; import { useEffect, useState } from 'react'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/IndicateurCard/IndicateurCardEdit/useUpdateIndicateurCard.ts b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/IndicateurCard/IndicateurCardEdit/useUpdateIndicateurCard.ts index e566071a0f..7ff880d756 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/IndicateurCard/IndicateurCardEdit/useUpdateIndicateurCard.ts +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/IndicateurCard/IndicateurCardEdit/useUpdateIndicateurCard.ts @@ -2,8 +2,8 @@ import { Indicateurs } from '@/api'; import { Personne } from '@/api/collectivites'; import { supabaseClient } from '@/app/core-logic/api/supabase'; import { useCollectiviteId } from '@/app/core-logic/hooks/params'; -import { Tag } from '@/backend/collectivites'; -import { Thematique } from '@/backend/shared'; +import { Tag } from '@/domain/collectivites'; +import { Thematique } from '@/domain/shared'; import { useMutation } from 'react-query'; /** Met à jour les pilotes, les services pilotes, les thématique d'un indicateur */ diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/useFilteredIndicateurDefinitions.ts b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/useFilteredIndicateurDefinitions.ts index 8a8a90ba9a..0c3f7b72da 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/useFilteredIndicateurDefinitions.ts +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/lists/useFilteredIndicateurDefinitions.ts @@ -27,7 +27,7 @@ export const useFilteredIndicateurDefinitions = ( delete options.filtre?.text; // Delete it, search is done locally for now due to backend reasons } - const { data, error, isLoading } = trpc.indicateurs.filtre.list.useQuery( + const { data, error, isLoading } = trpc.indicateurs.list.useQuery( { collectiviteId: collectiviteId!, filtre: options.filtre ?? {}, diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ActionsGroupees/EditionPriorite.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ActionsGroupees/EditionPriorite.tsx index aaa0304aa0..9dec48e2bd 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ActionsGroupees/EditionPriorite.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ActionsGroupees/EditionPriorite.tsx @@ -1,6 +1,6 @@ import { useCollectiviteId } from '@/app/core-logic/hooks/params'; import PrioritesSelectDropdown from '@/app/ui/dropdownLists/ficheAction/priorites/PrioritesSelectDropdown'; -import { Priorite } from '@/backend/plans/fiches'; +import { Priorite } from '@/domain/plans/fiches'; import { Button, Field, useEventTracker } from '@/ui'; import { OpenState } from '@/ui/utils/types'; import { useState } from 'react'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ActionsGroupees/EditionTagsLibres.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ActionsGroupees/EditionTagsLibres.tsx index 0eeb8384dc..d3a6e8bdcc 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ActionsGroupees/EditionTagsLibres.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/ActionsGroupees/EditionTagsLibres.tsx @@ -1,6 +1,6 @@ import { useCollectiviteId } from '@/app/core-logic/hooks/params'; import TagsSuiviPersoDropdown from '@/app/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown'; -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { Button, Field, useEventTracker } from '@/ui'; import { OpenState } from '@/ui/utils/types'; import { useState } from 'react'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Budget/FinanceursInput.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Budget/FinanceursInput.tsx index 6db4202032..ce58bdcc98 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Budget/FinanceursInput.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Budget/FinanceursInput.tsx @@ -1,5 +1,5 @@ import FinanceursDropdown from '@/app/ui/dropdownLists/FinanceursDropdown/FinanceursDropdown'; -import { Financeur, FinanceurUpdate } from '@/backend/plans/fiches'; +import { Financeur, FinanceurUpdate } from '@/domain/plans/fiches'; import { Button, Field, Input } from '@/ui'; type FinanceurPartial = Omit; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Budget/FinanceursListe.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Budget/FinanceursListe.tsx index e0e52dc470..0fe915fc0a 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Budget/FinanceursListe.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Budget/FinanceursListe.tsx @@ -1,5 +1,5 @@ import { getFormattedNumber } from '@/app/utils/formatUtils'; -import { FinanceurUpdate } from '@/backend/plans/fiches'; +import { FinanceurUpdate } from '@/domain/plans/fiches'; import { Badge } from '@/ui'; type FinanceursListeProps = { diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx index 2c908d0127..564b6f781c 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionDescription/ModaleDescription.tsx @@ -4,7 +4,7 @@ import SousThematiquesDropdown from '@/app/ui/dropdownLists/SousThematiquesDropd import TagsSuiviPersoDropdown from '@/app/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown'; import ThematiquesDropdown from '@/app/ui/dropdownLists/ThematiquesDropdown/ThematiquesDropdown'; import { getMaxLengthMessage } from '@/app/utils/formatUtils'; -import { Thematique } from '@/backend/shared'; +import { Thematique } from '@/domain/shared'; import { Button, Field, diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Header/CheminsFiche.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Header/CheminsFiche.tsx index c48d6b6f1f..66122bf7db 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Header/CheminsFiche.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/Header/CheminsFiche.tsx @@ -1,5 +1,5 @@ import { makeCollectiviteFichesNonClasseesUrl } from '@/app/app/paths'; -import { Axe } from '@/backend/plans/fiches'; +import { Axe } from '@/domain/plans/fiches'; import { Breadcrumbs, Button } from '@/ui'; import { useRouter } from 'next/navigation'; import { useState } from 'react'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts index 0ca1363d1c..e17e276831 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/FicheAction/utils.ts @@ -1,4 +1,4 @@ -import { Statut } from '@/backend/plans/fiches'; +import { Statut } from '@/domain/plans/fiches'; import { preset } from '@/ui'; /** Correspondance entre les statuts et couleurs associées */ diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/PlanActionFiltres/FiltrePriorites.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/PlanActionFiltres/FiltrePriorites.tsx index bbb1a73105..a6bb9c9e97 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/PlanActionFiltres/FiltrePriorites.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/PlanActionFiltres/FiltrePriorites.tsx @@ -1,5 +1,5 @@ import { TOption } from '@/app/ui/shared/select/commons'; -import { Priorite } from '@/backend/plans/fiches'; +import { Priorite } from '@/domain/plans/fiches'; import { Field, OptionValue, SelectFilter } from '@/ui'; import { ficheActionNiveauPrioriteOptions } from '../../../../../../ui/dropdownLists/listesStatiques'; import BadgePriorite from '../../components/BadgePriorite'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/PlanActionFiltres/FiltreStatuts.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/PlanActionFiltres/FiltreStatuts.tsx index 5e691ec087..19f36785bb 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/PlanActionFiltres/FiltreStatuts.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/PlanActionFiltres/FiltreStatuts.tsx @@ -1,6 +1,6 @@ import { TFicheActionStatuts } from '@/app/types/alias'; import { TOption } from '@/app/ui/shared/select/commons'; -import { Statut } from '@/backend/plans/fiches'; +import { Statut } from '@/domain/plans/fiches'; import { Field, OptionValue, SelectFilter } from '@/ui'; import { ficheActionStatutOptions } from '../../../../../../ui/dropdownLists/listesStatiques'; import BadgeStatut from '../../components/BadgeStatut'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/card/PlanActionCard.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/card/PlanActionCard.tsx index 48219cf027..c7a688665d 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/card/PlanActionCard.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/card/PlanActionCard.tsx @@ -2,7 +2,7 @@ import { generateTitle } from '@/app/app/pages/collectivite/PlansActions/FicheAc import Statuts from '@/app/app/pages/collectivite/PlansActions/PlanAction/list/card/Statuts'; import { useFichesActionStatuts } from '@/app/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/useFichesActionStatuts'; import { ModuleDisplay } from '@/app/app/pages/collectivite/TableauDeBord/components/Module'; -import { Axe } from '@/backend/plans/fiches'; +import { Axe } from '@/domain/plans/fiches'; import { Card } from '@/ui'; import classNames from 'classnames'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/card/Statuts.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/card/Statuts.tsx index 3c42932ab7..a5c6ba14c5 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/card/Statuts.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/list/card/Statuts.tsx @@ -2,7 +2,7 @@ import BadgeStatut from '@/app/app/pages/collectivite/PlansActions/components/Ba import { statutToColor } from '@/app/app/pages/collectivite/PlansActions/FicheAction/utils'; import { ModuleDisplay } from '@/app/app/pages/collectivite/TableauDeBord/components/Module'; import Chart from '@/app/ui/charts/Chart'; -import { Statut } from '@/backend/plans/fiches'; +import { Statut } from '@/domain/plans/fiches'; import { Tooltip } from '@/ui'; type Props = { diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/Synthese/utils.ts b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/Synthese/utils.ts index aea8f22319..bbbee167f0 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/Synthese/utils.ts +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/Synthese/utils.ts @@ -1,6 +1,6 @@ import { statutToColor } from '@/app/app/pages/collectivite/PlansActions/FicheAction/utils'; import { DonutData } from '@/app/ui/charts/Donut/DonutChart'; -import { Statut } from '@/backend/plans/fiches'; +import { Statut } from '@/domain/plans/fiches'; import { FiltersKeys } from '../FicheAction/data/filters'; import { TPlanActionTableauDeBord } from './data/usePlanActionTableauDeBord'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/components/BadgeStatut.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/components/BadgeStatut.tsx index c47dc1d107..c573dd1f5a 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/components/BadgeStatut.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/PlansActions/components/BadgeStatut.tsx @@ -1,4 +1,4 @@ -import { Statut } from '@/backend/plans/fiches'; +import { Statut } from '@/domain/plans/fiches'; import { Badge, BadgeState } from '@/ui'; import classNames from 'classnames'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/ModalAvancementFichesAction.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/ModalAvancementFichesAction.tsx index 4e7c35e37c..a8cfd14bbe 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/ModalAvancementFichesAction.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/ModalAvancementFichesAction.tsx @@ -23,7 +23,7 @@ import { } from '@/app/ui/dropdownLists/PersonnesDropdown/utils'; import PlansActionDropdown from '@/app/ui/dropdownLists/PlansActionDropdown'; import ServicesPilotesDropdown from '@/app/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown'; -import { Cible } from '@/backend/plans/fiches'; +import { Cible } from '@/domain/plans/fiches'; type Props = ModalProps & { module: ModuleFicheActionCountByStatusSelect; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/ModuleAvancementFichesAction.tsx b/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/ModuleAvancementFichesAction.tsx index 887569f444..caf4bdb667 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/ModuleAvancementFichesAction.tsx +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/ModuleAvancementFichesAction.tsx @@ -12,7 +12,7 @@ import { TDBViewParam } from '@/app/app/paths'; import { useCurrentCollectivite } from '@/app/core-logic/hooks/useCurrentCollectivite'; import Chart from '@/app/ui/charts/Chart'; import PictoDocument from '@/app/ui/pictogrammes/PictoDocument'; -import { Statut } from '@/backend/plans/fiches'; +import { Statut } from '@/domain/plans/fiches'; import { useEventTracker } from '@/ui'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; diff --git a/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/utils.ts b/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/utils.ts index ee793833cf..3d5d314d84 100644 --- a/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/utils.ts +++ b/app.territoiresentransitions.react/src/app/pages/collectivite/TableauDeBord/Collectivite/ModuleAvancementFichesAction/utils.ts @@ -1,7 +1,7 @@ import { Filtre } from '@/api/plan-actions/dashboards/collectivite-dashboard/domain/fiches-synthese.schema'; import { FicheActionParam } from '@/app/app/pages/collectivite/PlansActions/ToutesLesFichesAction/ToutesLesFichesAction'; import { makeCollectiviteToutesLesFichesUrl } from '@/app/app/paths'; -import { Statut } from '@/backend/plans/fiches'; +import { Statut } from '@/domain/plans/fiches'; /** Permet de transformer les filtres de modules fiches action en paramètres d'URL */ export const makeFichesActionUrlWithParams = ( diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/FichesActionsDropdown/FichesActionsDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/FichesActionsDropdown/FichesActionsDropdown.tsx index b8aa5f2946..fb6c74b882 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/FichesActionsDropdown/FichesActionsDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/FichesActionsDropdown/FichesActionsDropdown.tsx @@ -2,7 +2,7 @@ import { FicheResume } from '@/api/plan-actions'; import { useFicheResumesFetch } from '@/app/app/pages/collectivite/PlansActions/FicheAction/data/useFicheResumesFetch'; import { generateTitle } from '@/app/app/pages/collectivite/PlansActions/FicheAction/data/utils'; import { naturalSort } from '@/app/utils/naturalSort'; -import { CreateAxeType } from '@/backend/plans/fiches'; +import { CreateAxeType } from '@/domain/plans/fiches'; import { Option, OptionValue, diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/FinanceursDropdown/FinanceursDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/FinanceursDropdown/FinanceursDropdown.tsx index 2894c6dc96..3973598590 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/FinanceursDropdown/FinanceursDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/FinanceursDropdown/FinanceursDropdown.tsx @@ -1,4 +1,4 @@ -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { SelectMultipleProps } from '@/ui'; import SelectTags from '../tags/SelectTags'; import { useFinanceursListe } from './useFinanceursListe'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/FinanceursDropdown/useFinanceursListe.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/FinanceursDropdown/useFinanceursListe.ts index dc397c4dcd..f44b016863 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/FinanceursDropdown/useFinanceursListe.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/FinanceursDropdown/useFinanceursListe.ts @@ -1,6 +1,6 @@ import { supabaseClient } from '@/app/core-logic/api/supabase'; import { useCollectiviteId } from '@/app/core-logic/hooks/params'; -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { useQuery } from 'react-query'; import { objectToCamel } from 'ts-case-convert'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx index c7c14fc913..bd9d5affb4 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/PartenairesDropdown.tsx @@ -1,4 +1,4 @@ -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { SelectMultipleProps } from '@/ui'; import SelectTags from '../tags/SelectTags'; import { usePartenairesListe } from './usePartenairesListe'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/usePartenairesListe.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/usePartenairesListe.ts index 1722c5dc74..3dc46bf18a 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/usePartenairesListe.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/PartenairesDropdown/usePartenairesListe.ts @@ -1,6 +1,6 @@ import { supabaseClient } from '@/app/core-logic/api/supabase'; import { useCollectiviteId } from '@/app/core-logic/hooks/params'; -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { useQuery } from 'react-query'; import { objectToCamel } from 'ts-case-convert'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx index 75567c3140..1b191dcb10 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown.tsx @@ -1,4 +1,4 @@ -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { SelectMultipleProps } from '@/ui'; import SelectTags from '../tags/SelectTags'; import { useServicesPilotesListe } from './useServicesPilotesListe'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/useServicesPilotesListe.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/useServicesPilotesListe.ts index 7d98653aa6..6fa252c30b 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/useServicesPilotesListe.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ServicesPilotesDropdown/useServicesPilotesListe.ts @@ -1,6 +1,6 @@ import { supabaseClient } from '@/app/core-logic/api/supabase'; import { useCollectiviteId } from '@/app/core-logic/hooks/params'; -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { useQuery } from 'react-query'; import { objectToCamel } from 'ts-case-convert'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/SousThematiquesDropdown/SousThematiquesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/SousThematiquesDropdown/SousThematiquesDropdown.tsx index 64192c0a61..1319d79357 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/SousThematiquesDropdown/SousThematiquesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/SousThematiquesDropdown/SousThematiquesDropdown.tsx @@ -1,4 +1,4 @@ -import { SousThematique } from '@/backend/shared'; +import { SousThematique } from '@/domain/shared'; import { Option, OptionValue, SelectFilter, SelectMultipleProps } from '@/ui'; import { useEffect } from 'react'; import { useSousThematiqueListe } from './useSousThematiqueListe'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/SousThematiquesDropdown/useSousThematiqueListe.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/SousThematiquesDropdown/useSousThematiqueListe.ts index 4ccc531dac..cd1bdc4fe9 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/SousThematiquesDropdown/useSousThematiqueListe.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/SousThematiquesDropdown/useSousThematiqueListe.ts @@ -1,5 +1,5 @@ import { supabaseClient } from '@/app/core-logic/api/supabase'; -import { SousThematique } from '@/backend/shared'; +import { SousThematique } from '@/domain/shared'; import { useQuery } from 'react-query'; import { objectToCamel } from 'ts-case-convert'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx index b162391307..91e42c3fe6 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/StructuresDropdown.tsx @@ -1,4 +1,4 @@ -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { SelectMultipleProps } from '@/ui'; import SelectTags from '../tags/SelectTags'; import { useStructuresListe } from './useStructuresListe'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/useStructuresListe.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/useStructuresListe.ts index 1167fdfac3..29bfa7df95 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/useStructuresListe.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/StructuresDropdown/useStructuresListe.ts @@ -1,6 +1,6 @@ import { supabaseClient } from '@/app/core-logic/api/supabase'; import { useCollectiviteId } from '@/app/core-logic/hooks/params'; -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { useQuery } from 'react-query'; import { objectToCamel } from 'ts-case-convert'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx index 01f7a9c395..b2e8752a43 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/TagsSuiviPersoDropdown.tsx @@ -1,4 +1,4 @@ -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { SelectMultipleProps } from '@/ui'; import SelectTags from '../tags/SelectTags'; import { useTagsSuiviPersoListe } from './useTagsSuiviPersoListe'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/useTagsSuiviPersoListe.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/useTagsSuiviPersoListe.ts index e18faba78c..3519772bd7 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/useTagsSuiviPersoListe.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/TagsSuiviPersoDropdown/useTagsSuiviPersoListe.ts @@ -1,6 +1,6 @@ import { supabaseClient } from '@/app/core-logic/api/supabase'; import { useCollectiviteId } from '@/app/core-logic/hooks/params'; -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { useQuery } from 'react-query'; import { objectToCamel } from 'ts-case-convert'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/CiblesDropdown/CiblesDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/CiblesDropdown/CiblesDropdown.tsx index 266e328606..3d665232b8 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/CiblesDropdown/CiblesDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/CiblesDropdown/CiblesDropdown.tsx @@ -1,4 +1,4 @@ -import { Cible } from '@/backend/plans/fiches'; +import { Cible } from '@/domain/plans/fiches'; import { SelectFilter, SelectMultipleProps } from '@/ui'; import { ficheActionCiblesOptions } from '../../listesStatiques'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/EffetsAttendusDropdown/EffetsAttendusDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/EffetsAttendusDropdown/EffetsAttendusDropdown.tsx index 18918bdc4c..4b13c01ad6 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/EffetsAttendusDropdown/EffetsAttendusDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/EffetsAttendusDropdown/EffetsAttendusDropdown.tsx @@ -1,4 +1,4 @@ -import { EffetAttendu } from '@/backend/shared'; +import { EffetAttendu } from '@/domain/shared'; import { SelectFilter, SelectMultipleProps } from '@/ui'; import { useEffetsAttendus } from './useEffetsAttendus'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/MiseEnOeuvreDropdown/MiseEnOeuvreDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/MiseEnOeuvreDropdown/MiseEnOeuvreDropdown.tsx index 25b5c9b9ea..3fe8a4c467 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/MiseEnOeuvreDropdown/MiseEnOeuvreDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/MiseEnOeuvreDropdown/MiseEnOeuvreDropdown.tsx @@ -1,4 +1,4 @@ -import { TempsDeMiseEnOeuvre } from '@/backend/shared'; +import { TempsDeMiseEnOeuvre } from '@/domain/shared'; import { Select, SelectProps } from '@/ui'; import { useMiseEnOeuvre } from './useMiseEnOeuvre'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/ParticipationCitoyenneDropdown/ParticipationCitoyenneDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/ParticipationCitoyenneDropdown/ParticipationCitoyenneDropdown.tsx index b661738c7f..9ddc72b70a 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/ParticipationCitoyenneDropdown/ParticipationCitoyenneDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/ParticipationCitoyenneDropdown/ParticipationCitoyenneDropdown.tsx @@ -1,4 +1,4 @@ -import { ParticipationCitoyenne } from '@/backend/plans/fiches'; +import { ParticipationCitoyenne } from '@/domain/plans/fiches'; import { Select, SelectMultipleProps } from '@/ui'; import { ficheActionParticipationOptions } from '../../listesStatiques'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/priorites/PrioritesFilterDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/priorites/PrioritesFilterDropdown.tsx index 111851acad..5a2a58f778 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/priorites/PrioritesFilterDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/priorites/PrioritesFilterDropdown.tsx @@ -1,6 +1,6 @@ import BadgePriorite from '@/app/app/pages/collectivite/PlansActions/components/BadgePriorite'; import { ficheActionNiveauPrioriteOptions } from '@/app/ui/dropdownLists/listesStatiques'; -import { Priorite } from '@/backend/plans/fiches'; +import { Priorite } from '@/domain/plans/fiches'; import { SelectFilter, SelectMultipleProps } from '@/ui'; type Props = Omit & { diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/priorites/PrioritesSelectDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/priorites/PrioritesSelectDropdown.tsx index 5dd06b23d0..c46933c28e 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/priorites/PrioritesSelectDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/priorites/PrioritesSelectDropdown.tsx @@ -1,6 +1,6 @@ import BadgePriorite from '@/app/app/pages/collectivite/PlansActions/components/BadgePriorite'; import { ficheActionNiveauPrioriteOptions } from '@/app/ui/dropdownLists/listesStatiques'; -import { Priorite } from '@/backend/plans/fiches'; +import { Priorite } from '@/domain/plans/fiches'; import { Select, SelectProps } from '@/ui'; type Props = Omit & { diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/statuts/StatutsFilterDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/statuts/StatutsFilterDropdown.tsx index f85afee49e..031ec9f23d 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/statuts/StatutsFilterDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/statuts/StatutsFilterDropdown.tsx @@ -1,6 +1,6 @@ import BadgeStatut from '@/app/app/pages/collectivite/PlansActions/components/BadgeStatut'; import { ficheActionStatutOptions } from '@/app/ui/dropdownLists/listesStatiques'; -import { Statut } from '@/backend/plans/fiches'; +import { Statut } from '@/domain/plans/fiches'; import { SelectFilter, SelectMultipleProps } from '@/ui'; type Props = Omit & { diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/statuts/StatutsSelectDropdown.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/statuts/StatutsSelectDropdown.tsx index 28f59fcd2e..cb5205c7da 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/statuts/StatutsSelectDropdown.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/ficheAction/statuts/StatutsSelectDropdown.tsx @@ -1,6 +1,6 @@ import BadgeStatut from '@/app/app/pages/collectivite/PlansActions/components/BadgeStatut'; import { ficheActionStatutOptions } from '@/app/ui/dropdownLists/listesStatiques'; -import { Statut } from '@/backend/plans/fiches'; +import { Statut } from '@/domain/plans/fiches'; import { Select, SelectProps } from '@/ui'; type Props = Omit & { diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/indicateur/use-categorie-tags.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/indicateur/use-categorie-tags.tsx index e96b0444d9..d34bb84eda 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/indicateur/use-categorie-tags.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/indicateur/use-categorie-tags.tsx @@ -3,8 +3,11 @@ import { useCollectiviteId } from '../../../core-logic/hooks/params'; export const useCategorieTags = () => { const collectiviteId = useCollectiviteId(); - if (!collectiviteId) return { data: null }; - return trpc.tags.categories.list.useQuery({ + if (!collectiviteId) { + return { data: null }; + } + + return trpc.collectivites.categories.list.useQuery({ collectiviteId, withPredefinedTags: true, }); diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/listesStatiques.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/listesStatiques.ts index e8b49d8e1c..ae2082fff2 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/listesStatiques.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/listesStatiques.ts @@ -5,7 +5,7 @@ import { ParticipationCitoyenne, Priorite, Statut, -} from '@/backend/plans/fiches'; +} from '@/domain/plans/fiches'; type Options = { value: T; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx index 8be3d875f6..c3048a64ba 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/SelectTags.tsx @@ -1,6 +1,6 @@ import { TableTag } from '@/api'; import { useCollectiviteId } from '@/app/core-logic/hooks/params'; -import { Tag } from '@/backend/collectivites'; +import { Tag } from '@/domain/collectivites'; import { Option, OptionValue, SelectFilter, SelectMultipleProps } from '@/ui'; import { useEffect } from 'react'; import { QueryKey } from 'react-query'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagCreate.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagCreate.ts index f0978b73d5..b98c370ba0 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagCreate.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagCreate.ts @@ -1,6 +1,6 @@ import { CollectiviteTag, TableTag } from '@/api'; import { supabaseClient } from '@/app/core-logic/api/supabase'; -import { TagInsert } from '@/backend/collectivites'; +import { TagInsert } from '@/domain/collectivites'; import { QueryKey, useMutation, useQueryClient } from 'react-query'; import { objectToSnake } from 'ts-case-convert'; diff --git a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts index 3d021f8cef..3f4b40a70f 100644 --- a/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts +++ b/app.territoiresentransitions.react/src/ui/dropdownLists/tags/useTagUpdate.ts @@ -1,6 +1,6 @@ import { TableTag } from '@/api'; import { supabaseClient } from '@/app/core-logic/api/supabase'; -import { TagUpdate } from '@/backend/collectivites'; +import { TagUpdate } from '@/domain/collectivites'; import { QueryKey, useMutation, useQueryClient } from 'react-query'; import { objectToSnake } from 'ts-case-convert'; diff --git a/app.territoiresentransitions.react/src/ui/export-pdf/components/Badge/BadgeStatut.tsx b/app.territoiresentransitions.react/src/ui/export-pdf/components/Badge/BadgeStatut.tsx index 27b01f2372..a4c288703e 100644 --- a/app.territoiresentransitions.react/src/ui/export-pdf/components/Badge/BadgeStatut.tsx +++ b/app.territoiresentransitions.react/src/ui/export-pdf/components/Badge/BadgeStatut.tsx @@ -1,5 +1,5 @@ import { statusToState } from '@/app/app/pages/collectivite/PlansActions/components/BadgeStatut'; -import { Statut } from '@/backend/plans/fiches'; +import { Statut } from '@/domain/plans/fiches'; import classNames from 'classnames'; import { Badge } from './Badge'; diff --git a/backend/README.md b/backend/README.md index 58be49e156..3fd452f999 100644 --- a/backend/README.md +++ b/backend/README.md @@ -46,20 +46,31 @@ $ nx test backend ### Tests -Pour lancer tous les tests : +Les tests sont colocalisés au plus près du fichier testé. + +Exemple : ``` -nx test backend +└ update-action-statut.router.ts +└ update-action-statut.router.e2e-spec.ts ``` -Pour lancer uniquement les tests unitaires (dossier `src`) : +--- -``` -nx test backend src +Lancer tous les tests : + +```sh +nx test backend ``` -Pour lancer uniquement les tests end-to-end (dossier `test`) : +Lancer uniquement un fichier de test donné : +```sh +nx test backend 'update-action-statut.router.e2e-spec.ts' ``` -nx test backend test + +Lancer uniquement les tests dont le chemin contient `referentiels` : + +```sh +nx test backend 'referentiels' ``` diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index 69d7cee971..f45b3df0fc 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -3,17 +3,17 @@ import { ConfigModule } from '@nestjs/config'; import { SentryModule } from '@sentry/nestjs/setup'; import { AuthModule } from './auth/auth.module'; import { CollectivitesModule } from './collectivites/collectivites.module'; -import { CommonModule } from './common/common.module'; -import configuration from './config/configuration'; -import { ConfigurationModule } from './config/configuration.module'; import { IndicateursModule } from './indicateurs/indicateurs.module'; import { PersonnalisationsModule } from './personnalisations/personnalisations.module'; import { FichesActionModule } from './plans/fiches/fiches.module'; import { ReferentielsModule } from './referentiels/referentiels.module'; -import { TaxonomieModule } from './taxonomie/taxonomie.module'; +import configuration from './utils/config/configuration'; +import { ConfigurationModule } from './utils/config/configuration.module'; +import { DatabaseModule } from './utils/database/database.module'; import { SheetModule } from './utils/google-sheets/sheet.module'; import { TrpcModule } from './utils/trpc/trpc.module'; import { TrpcRouter } from './utils/trpc/trpc.router'; +import { UtilsModule } from './utils/utils.module'; @Module({ imports: [ @@ -24,7 +24,9 @@ import { TrpcRouter } from './utils/trpc/trpc.router'; load: [configuration], }), ConfigurationModule, - CommonModule, + // Test without + UtilsModule, + DatabaseModule, TrpcModule, SheetModule, CollectivitesModule, @@ -33,7 +35,6 @@ import { TrpcRouter } from './utils/trpc/trpc.router'; FichesActionModule, PersonnalisationsModule, ReferentielsModule, - TaxonomieModule, ], providers: [TrpcRouter], }) diff --git a/backend/src/auth/auth.module.ts b/backend/src/auth/auth.module.ts index 110b14009a..bfe825c7de 100644 --- a/backend/src/auth/auth.module.ts +++ b/backend/src/auth/auth.module.ts @@ -1,12 +1,10 @@ +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; +import { RoleService } from '@/backend/auth/authorizations/roles/role.service'; import { Global, Module } from '@nestjs/common'; import { APP_GUARD } from '@nestjs/core'; import { JwtModule } from '@nestjs/jwt'; import { CollectivitesModule } from '../collectivites/collectivites.module'; -import { CommonModule } from '../common/common.module'; -import { ConfigurationModule } from '../config/configuration.module'; import { AuthGuard } from './guards/auth.guard'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; -import { RoleService } from '@/backend/auth/authorizations/roles/role.service'; @Global() @Module({ @@ -15,8 +13,6 @@ import { RoleService } from '@/backend/auth/authorizations/roles/role.service'; global: true, secret: process.env.SUPABASE_JWT_SECRET, }), - ConfigurationModule, - CommonModule, CollectivitesModule, ], providers: [ @@ -25,7 +21,7 @@ import { RoleService } from '@/backend/auth/authorizations/roles/role.service'; useClass: AuthGuard, }, PermissionService, - RoleService + RoleService, ], exports: [PermissionService], }) diff --git a/backend/src/auth/authorizations/permission.service.e2e-spec.ts b/backend/src/auth/authorizations/permission.service.e2e-spec.ts index e9276db8d8..b470c89093 100644 --- a/backend/src/auth/authorizations/permission.service.e2e-spec.ts +++ b/backend/src/auth/authorizations/permission.service.e2e-spec.ts @@ -1,15 +1,20 @@ -import { getAuthUser, getTestApp, getTestDatabase, YOULOU_DOUDOU } from '@/backend/test'; -import { INestApplication } from '@nestjs/common'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; -import { AuthenticatedUser } from '@/backend/auth/models/auth.models'; +import { dcpTable } from '@/backend/auth'; import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; -import DatabaseService from '../../common/services/database.service'; -import { eq } from 'drizzle-orm'; import { utilisateurSupportTable } from '@/backend/auth/authorizations/roles/utilisateur-support.table'; import { utilisateurVerifieTable } from '@/backend/auth/authorizations/roles/utilisateur-verifie.table'; -import { dcpTable } from '@/backend/auth'; -import { collectiviteTable } from '@/backend/collectivites/models/collectivite.table'; +import { AuthenticatedUser } from '@/backend/auth/models/auth.models'; +import { collectiviteTable } from '@/backend/collectivites'; +import { + getAuthUser, + getTestApp, + getTestDatabase, + YOULOU_DOUDOU, +} from '@/backend/test'; +import { DatabaseService } from '@/backend/utils'; +import { INestApplication } from '@nestjs/common'; +import { eq } from 'drizzle-orm'; describe('Gestion des droits', () => { let app: INestApplication; @@ -22,7 +27,7 @@ describe('Gestion des droits', () => { app = await getTestApp(); permissionService = app.get(PermissionService); yoloDodoUser = await getAuthUser(); - youlouDoudouUser = await getAuthUser(YOULOU_DOUDOU) + youlouDoudouUser = await getAuthUser(YOULOU_DOUDOU); databaseService = await getTestDatabase(app); }); diff --git a/backend/src/auth/authorizations/roles/private-utilisateur-droit.table.ts b/backend/src/auth/authorizations/roles/private-utilisateur-droit.table.ts index 179756d4c6..e06ce601f5 100644 --- a/backend/src/auth/authorizations/roles/private-utilisateur-droit.table.ts +++ b/backend/src/auth/authorizations/roles/private-utilisateur-droit.table.ts @@ -1,7 +1,7 @@ -import { createdAt, modifiedAt } from '@/backend/utils'; +import { createdAt, modifiedAt } from '@/domain/utils'; import { InferSelectModel } from 'drizzle-orm'; import { boolean, integer, pgTable, serial, uuid } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../../collectivites/shared/models/collectivite.table'; import { invitationTable } from '../../models/invitation.table'; import { NiveauAcces, niveauAccessEnum } from './niveau-acces.enum'; diff --git a/backend/src/auth/authorizations/roles/role.service.ts b/backend/src/auth/authorizations/roles/role.service.ts index 9d68fbb712..a445a362a0 100644 --- a/backend/src/auth/authorizations/roles/role.service.ts +++ b/backend/src/auth/authorizations/roles/role.service.ts @@ -1,18 +1,17 @@ -import { Injectable, Logger } from '@nestjs/common'; -import { and, eq, sql } from 'drizzle-orm'; -import DatabaseService from '../../../common/services/database.service'; -import { AuthRole, AuthUser } from '../../models/auth.models'; import { + dcpTable, utilisateurDroitTable, UtilisateurDroitType, } from '@/backend/auth'; +import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; +import { Role } from '@/backend/auth/authorizations/roles/role.enum'; +import { DatabaseService } from '@/backend/utils'; +import { Injectable, Logger } from '@nestjs/common'; +import { and, eq, sql } from 'drizzle-orm'; +import { AuthRole, AuthUser } from '../../models/auth.models'; import { NiveauAcces } from './niveau-acces.enum'; import { utilisateurSupportTable } from './utilisateur-support.table'; import { utilisateurVerifieTable } from './utilisateur-verifie.table'; -import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; -import { Role } from '@/backend/auth/authorizations/roles/role.enum'; -import { dcpTable } from '@/backend/auth'; - @Injectable() export class RoleService { diff --git a/backend/src/auth/authorizations/roles/utilisateur-support.table.ts b/backend/src/auth/authorizations/roles/utilisateur-support.table.ts index 9a4cca0e2a..72986bcbe6 100644 --- a/backend/src/auth/authorizations/roles/utilisateur-support.table.ts +++ b/backend/src/auth/authorizations/roles/utilisateur-support.table.ts @@ -1,5 +1,5 @@ +import { dcpTable } from '@/domain/auth'; import { boolean, pgTable, uuid } from 'drizzle-orm/pg-core'; -import { dcpTable } from '@/backend/auth'; export const utilisateurSupportTable = pgTable('utilisateur_support', { userId: uuid('user_id') diff --git a/backend/src/auth/authorizations/roles/utilisateur-verifie.table.ts b/backend/src/auth/authorizations/roles/utilisateur-verifie.table.ts index f9f13170dc..f3d32453ae 100644 --- a/backend/src/auth/authorizations/roles/utilisateur-verifie.table.ts +++ b/backend/src/auth/authorizations/roles/utilisateur-verifie.table.ts @@ -1,5 +1,5 @@ +import { dcpTable } from '@/domain/auth'; import { boolean, pgTable, uuid } from 'drizzle-orm/pg-core'; -import { dcpTable } from '@/backend/auth'; export const utilisateurVerifieTable = pgTable('utilisateur_verifie', { userId: uuid('user_id') diff --git a/backend/src/auth/guards/auth.guard.ts b/backend/src/auth/guards/auth.guard.ts index 3ae9e9d25f..8141eea06b 100644 --- a/backend/src/auth/guards/auth.guard.ts +++ b/backend/src/auth/guards/auth.guard.ts @@ -8,8 +8,8 @@ import { import { Reflector } from '@nestjs/core'; import { JwtService } from '@nestjs/jwt'; import { Request } from 'express'; -import { getErrorMessage } from '../../common/services/errors.helper'; -import BackendConfigurationService from '../../config/configuration.service'; +import BackendConfigurationService from '../../utils/config/configuration.service'; +import { getErrorMessage } from '../../utils/nest/errors.utils'; import { AllowAnonymousAccess } from '../decorators/allow-anonymous-access.decorator'; import { AllowPublicAccess } from '../decorators/allow-public-access.decorator'; import { diff --git a/backend/src/auth/index-domain.ts b/backend/src/auth/index-domain.ts new file mode 100644 index 0000000000..9629ef3391 --- /dev/null +++ b/backend/src/auth/index-domain.ts @@ -0,0 +1,11 @@ +// `index-domain.ts` file must only contain exports that are shareable with client-side apps. +// Exports from this file can be imported with `@/domain/*` alias path. + +export * from './authorizations/permission-operation.enum'; +export * from './authorizations/permission.models'; +export * from './authorizations/resource-type.enum'; +export * from './authorizations/roles/private-utilisateur-droit.table'; +export * from './models/auth-users.table'; +export * from './models/auth.models'; +export * from './models/dcp.table'; +export * from './models/invitation.table'; diff --git a/backend/src/auth/index.ts b/backend/src/auth/index.ts index b864998055..81ce45f809 100644 --- a/backend/src/auth/index.ts +++ b/backend/src/auth/index.ts @@ -1,8 +1 @@ -export * from './authorizations/permission-operation.enum'; -export * from './authorizations/permission.models'; -export * from './authorizations/resource-type.enum'; -export * from './authorizations/roles/private-utilisateur-droit.table'; -export * from './models/auth-users.table'; -export * from './models/auth.models'; -export * from './models/dcp.table'; -export * from './models/invitation.table'; +export * from './index-domain'; diff --git a/backend/src/auth/models/invitation.table.ts b/backend/src/auth/models/invitation.table.ts index e16938bb5c..9a597c7cef 100644 --- a/backend/src/auth/models/invitation.table.ts +++ b/backend/src/auth/models/invitation.table.ts @@ -7,7 +7,7 @@ import { timestamp, uuid, } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { createdAt, createdBy, diff --git a/backend/src/collectivites/controllers/collectivite.controller.ts b/backend/src/collectivites/collectivite.controller.ts similarity index 85% rename from backend/src/collectivites/controllers/collectivite.controller.ts rename to backend/src/collectivites/collectivite.controller.ts index 4b16cd5e30..08728510ba 100644 --- a/backend/src/collectivites/controllers/collectivite.controller.ts +++ b/backend/src/collectivites/collectivite.controller.ts @@ -1,7 +1,7 @@ import { Controller, Get, Param, Query } from '@nestjs/common'; import { ApiOkResponse } from '@nestjs/swagger'; -import { AllowPublicAccess } from '../../auth/decorators/allow-public-access.decorator'; -import CollectivitesService from '../services/collectivites.service'; +import { AllowPublicAccess } from '../auth/decorators/allow-public-access.decorator'; +import CollectivitesService from './services/collectivites.service'; /** * Création des classes de réponse à partir du schema pour générer automatiquement la documentation OpenAPI diff --git a/backend/src/collectivites/models/collectivite.request.ts b/backend/src/collectivites/collectivite.request.ts similarity index 100% rename from backend/src/collectivites/models/collectivite.request.ts rename to backend/src/collectivites/collectivite.request.ts diff --git a/backend/src/collectivites/collectivites.module.ts b/backend/src/collectivites/collectivites.module.ts index b541bc7b9f..10223c180b 100644 --- a/backend/src/collectivites/collectivites.module.ts +++ b/backend/src/collectivites/collectivites.module.ts @@ -1,15 +1,16 @@ import { Module } from '@nestjs/common'; -import { CommonModule } from '../common/common.module'; -import { CollectiviteController } from './controllers/collectivite.controller'; +import { CollectiviteController } from './collectivite.controller'; +import { ListCategoriesRouter } from './handle-categories/list-categories.router'; +import ListCategoriesService from './handle-categories/list-categories.service'; +import { CollectiviteMembresRouter } from './membres/membres.router'; +import { CollectiviteMembresService } from './membres/membres.service'; import { PersonnesRouter } from './personnes.router'; import CollectivitesService from './services/collectivites.service'; import GroupementsService from './services/groupements.service'; import { PersonnesService } from './services/personnes.service'; -import { CollectiviteMembresService } from './membres/membres.service'; -import { CollectiviteMembresRouter } from './membres/membres.router'; @Module({ - imports: [CommonModule], + imports: [], providers: [ CollectivitesService, CollectiviteMembresService, @@ -17,6 +18,8 @@ import { CollectiviteMembresRouter } from './membres/membres.router'; GroupementsService, PersonnesService, PersonnesRouter, + ListCategoriesService, + ListCategoriesRouter, ], exports: [ CollectivitesService, @@ -24,6 +27,8 @@ import { CollectiviteMembresRouter } from './membres/membres.router'; CollectiviteMembresRouter, GroupementsService, PersonnesRouter, + ListCategoriesService, + ListCategoriesRouter, ], controllers: [CollectiviteController], }) diff --git a/backend/src/taxonomie/routers/get-categories-by-collectivite.router.e2e-spec.ts b/backend/src/collectivites/handle-categories/list-categories.router.e2e-spec.ts similarity index 79% rename from backend/src/taxonomie/routers/get-categories-by-collectivite.router.e2e-spec.ts rename to backend/src/collectivites/handle-categories/list-categories.router.e2e-spec.ts index 2b9a481ae0..bcb1e293e0 100644 --- a/backend/src/taxonomie/routers/get-categories-by-collectivite.router.e2e-spec.ts +++ b/backend/src/collectivites/handle-categories/list-categories.router.e2e-spec.ts @@ -1,10 +1,12 @@ import { inferProcedureInput } from '@trpc/server'; import { getTestRouter } from '../../../test/app-utils'; import { getAuthUser } from '../../../test/auth-utils'; +import { AuthenticatedUser } from '../../auth/models/auth.models'; import { AppRouter, TrpcRouter } from '../../utils/trpc/trpc.router'; -import { AuthenticatedUser } from './../../auth/models/auth.models'; -type Input = inferProcedureInput; +type Input = inferProcedureInput< + AppRouter['collectivites']['categories']['list'] +>; describe('Route de lecture des tags catégories', () => { let router: TrpcRouter; @@ -22,7 +24,7 @@ describe('Route de lecture des tags catégories', () => { collectiviteId: 1, withPredefinedTags: false, }; - const result = await caller.tags.categories.list(input); + const result = await caller.collectivites.categories.list(input); // Il n'y a pas de catégories propres à une collectivité dans le jeu de test expect(result.length).toBe(0); }); @@ -34,7 +36,7 @@ describe('Route de lecture des tags catégories', () => { collectiviteId: 1, withPredefinedTags: true, }; - const result = await caller.tags.categories.list(input); + const result = await caller.collectivites.categories.list(input); expect(result.length).not.toBe(0); }); }); diff --git a/backend/src/taxonomie/routers/get-categories-by-collectivite.router.ts b/backend/src/collectivites/handle-categories/list-categories.router.ts similarity index 75% rename from backend/src/taxonomie/routers/get-categories-by-collectivite.router.ts rename to backend/src/collectivites/handle-categories/list-categories.router.ts index 78f2a126f2..bbd85d5c36 100644 --- a/backend/src/taxonomie/routers/get-categories-by-collectivite.router.ts +++ b/backend/src/collectivites/handle-categories/list-categories.router.ts @@ -1,7 +1,7 @@ import { TrpcService } from '@/backend/utils/trpc/trpc.service'; import { Injectable } from '@nestjs/common'; import { z } from 'zod'; -import TagService from '../services/tag.service'; +import ListCategoriesService from './list-categories.service'; const inputSchema = z.object({ collectiviteId: z.number(), @@ -9,10 +9,10 @@ const inputSchema = z.object({ }); @Injectable() -export class GetCategoriesByCollectiviteRouter { +export class ListCategoriesRouter { constructor( private readonly trpc: TrpcService, - private readonly service: TagService + private readonly service: ListCategoriesService ) {} router = this.trpc.router({ @@ -20,7 +20,7 @@ export class GetCategoriesByCollectiviteRouter { .input(inputSchema) .query(({ ctx, input }) => { const { collectiviteId, withPredefinedTags } = input; - return this.service.getCategoriesByCollectivite( + return this.service.listCategories( collectiviteId, withPredefinedTags, ctx.user diff --git a/backend/src/taxonomie/services/tag.service.ts b/backend/src/collectivites/handle-categories/list-categories.service.ts similarity index 65% rename from backend/src/taxonomie/services/tag.service.ts rename to backend/src/collectivites/handle-categories/list-categories.service.ts index a9bd674ad6..29a2c29387 100644 --- a/backend/src/taxonomie/services/tag.service.ts +++ b/backend/src/collectivites/handle-categories/list-categories.service.ts @@ -1,19 +1,18 @@ import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; import { PermissionService } from '@/backend/auth/authorizations/permission.service'; import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; -import { partenaireTagTable } from '@/backend/collectivites'; import CollectivitesService from '@/backend/collectivites/services/collectivites.service'; import { Injectable, Logger } from '@nestjs/common'; import { and, eq, inArray, isNull, or } from 'drizzle-orm'; import { AuthenticatedUser } from '../../auth/models/auth.models'; -import { groupementCollectiviteTable } from '../../collectivites/models/groupement-collectivite.table'; -import { Tag } from '../../collectivites/shared/models/tag.table-base'; -import DatabaseService from '../../common/services/database.service'; -import { categorieTagTable } from '../models/categorie-tag.table'; +import { DatabaseService } from '../../utils/database/database.service'; +import { categorieTagTable } from '../shared/models/categorie-tag.table'; +import { groupementCollectiviteTable } from '../shared/models/groupement-collectivite.table'; +import { Tag } from '../shared/models/tag.table-base'; @Injectable() -export default class TagService { - private readonly logger = new Logger(TagService.name); +export default class ListCategoriesService { + private readonly logger = new Logger(ListCategoriesService.name); constructor( private readonly databaseService: DatabaseService, @@ -21,47 +20,13 @@ export default class TagService { private readonly collectiviteService: CollectivitesService ) {} - /** - * TODO à factoriser avec les autres tags - * Récupère l'id du tag partenaire pour une collectivité et le crée s'il n'existe pas - * @param nom du partenaire - * @param collectiviteId identifiant de la collectivité - * @return identifiant du tag partenaire - */ - async getPartenaireId(nom: string, collectiviteId: number): Promise { - let tag = null; - if (collectiviteId) { - const tags = await this.databaseService.db - .select() - .from(partenaireTagTable) - .where( - and( - eq(partenaireTagTable.nom, nom.trim()), - eq(partenaireTagTable.collectiviteId, collectiviteId) - ) - ); - tag = tags.length > 0 ? tags[0] : null; - } - if (!tag) { - const toReturn = await this.databaseService.db - .insert(partenaireTagTable) - .values({ - collectiviteId: collectiviteId, - nom: nom, - }) - .returning(); - return toReturn[0]?.id; - } - return tag.id; - } - /** * Récupère les catégories possibles pour une collectivité * @param collectiviteId * @param withPredefinedTags vrai pour inclure les tags prédéfinis par TeT * @param tokenInfo */ - async getCategoriesByCollectivite( + async listCategories( collectiviteId: number, withPredefinedTags: boolean, tokenInfo: AuthenticatedUser diff --git a/backend/src/collectivites/models/identite-collectivite.dto.ts b/backend/src/collectivites/identite-collectivite.dto.ts similarity index 90% rename from backend/src/collectivites/models/identite-collectivite.dto.ts rename to backend/src/collectivites/identite-collectivite.dto.ts index 3803e423d3..6d82b0ec58 100644 --- a/backend/src/collectivites/models/identite-collectivite.dto.ts +++ b/backend/src/collectivites/identite-collectivite.dto.ts @@ -1,8 +1,8 @@ import { pgEnum } from 'drizzle-orm/pg-core'; import { z } from 'zod'; -import { collectiviteSchema } from './collectivite.table'; -import { communeSchema } from './commune.table'; -import { epciSchema } from './epci.table'; +import { collectiviteSchema } from './shared/models/collectivite.table'; +import { communeSchema } from './shared/models/commune.table'; +import { epciSchema } from './shared/models/epci.table'; export enum CollectiviteTypeEnum { EPCI = 'EPCI', diff --git a/backend/src/collectivites/index-domain.ts b/backend/src/collectivites/index-domain.ts new file mode 100644 index 0000000000..e89c558080 --- /dev/null +++ b/backend/src/collectivites/index-domain.ts @@ -0,0 +1,12 @@ +// `index-domain.ts` file must only contain exports that are shareable with client-side apps. +// Exports from this file can be imported with `@/domain/*` alias path. + +export * from './shared/models/categorie-tag.table'; +export * from './shared/models/collectivite.table'; +export * from './shared/models/financeur-tag.table'; +export * from './shared/models/libre-tag.table'; +export * from './shared/models/partenaire-tag.table'; +export * from './shared/models/personne-tag.table'; +export * from './shared/models/service-tag.table'; +export * from './shared/models/structure-tag.table'; +export * from './shared/models/tag.table-base'; diff --git a/backend/src/collectivites/index.ts b/backend/src/collectivites/index.ts index 9a14e5b08e..81ce45f809 100644 --- a/backend/src/collectivites/index.ts +++ b/backend/src/collectivites/index.ts @@ -1,7 +1 @@ -export * from './shared/models/financeur-tag.table'; -export * from './shared/models/libre-tag.table'; -export * from './shared/models/partenaire-tag.table'; -export * from './shared/models/personne-tag.table'; -export * from './shared/models/service-tag.table'; -export * from './shared/models/structure-tag.table'; -export * from './shared/models/tag.table-base'; +export * from './index-domain'; diff --git a/backend/src/collectivites/membres/membres.router.e2e-spec.ts b/backend/src/collectivites/membres/membres.router.e2e-spec.ts index c60b7be763..093f2a0048 100644 --- a/backend/src/collectivites/membres/membres.router.e2e-spec.ts +++ b/backend/src/collectivites/membres/membres.router.e2e-spec.ts @@ -1,3 +1,4 @@ +import { NiveauAcces } from '@/backend/auth/authorizations/roles/niveau-acces.enum'; import { INestApplication } from '@nestjs/common'; import { inferProcedureInput } from '@trpc/server'; import { sql } from 'drizzle-orm'; @@ -6,10 +7,9 @@ import { getAuthUser } from '../../../test/auth-utils'; import { YOLO_DODO } from '../../../test/test-users.samples'; import { AuthenticatedUser } from '../../auth/models/auth.models'; import { invitationTable } from '../../auth/models/invitation.table'; -import { NiveauAcces } from '@/backend/auth/authorizations/roles/niveau-acces.enum'; -import DatabaseService from '../../common/services/database.service'; +import { DatabaseService } from '../../utils/database/database.service'; import { AppRouter, TrpcRouter } from '../../utils/trpc/trpc.router'; -import { MembreFonctionEnum } from '../models/membre-fonction.enum'; +import { MembreFonctionEnum } from '../shared/models/membre-fonction.enum'; type Input = inferProcedureInput; diff --git a/backend/src/collectivites/membres/membres.service.ts b/backend/src/collectivites/membres/membres.service.ts index 599227fd39..b761cef753 100644 --- a/backend/src/collectivites/membres/membres.service.ts +++ b/backend/src/collectivites/membres/membres.service.ts @@ -1,13 +1,13 @@ import { dcpTable } from '@/backend/auth'; +import { utilisateurDroitTable } from '@/backend/auth/authorizations/roles/private-utilisateur-droit.table'; import { Injectable, Logger } from '@nestjs/common'; import { and, eq, sql } from 'drizzle-orm'; import { unionAll } from 'drizzle-orm/pg-core'; import z from 'zod'; import { invitationTable } from '../../auth/models/invitation.table'; -import { utilisateurDroitTable } from '@/backend/auth/authorizations/roles/private-utilisateur-droit.table'; -import DatabaseService from '../../common/services/database.service'; -import { MembreFonction } from '../models/membre-fonction.enum'; -import { insertMembreSchema, membreTable } from '../models/membre.table'; +import { DatabaseService } from '../../utils/database/database.service'; +import { MembreFonction } from '../shared/models/membre-fonction.enum'; +import { insertMembreSchema, membreTable } from '../shared/models/membre.table'; @Injectable() export class CollectiviteMembresService { diff --git a/backend/src/collectivites/personnes.router.e2e-spec.ts b/backend/src/collectivites/personnes.router.e2e-spec.ts index b6e6b77b60..a3354d6a37 100644 --- a/backend/src/collectivites/personnes.router.e2e-spec.ts +++ b/backend/src/collectivites/personnes.router.e2e-spec.ts @@ -1,3 +1,4 @@ +import { utilisateurDroitTable } from '@/backend/auth/authorizations/roles/private-utilisateur-droit.table'; import { inferProcedureInput } from '@trpc/server'; import { eq } from 'drizzle-orm'; import { @@ -8,8 +9,7 @@ import { import { getAuthUser } from '../../test/auth-utils'; import { YOLO_DODO, YULU_DUDU } from '../../test/test-users.samples'; import { AuthenticatedUser } from '../auth/models/auth.models'; -import { utilisateurDroitTable } from '@/backend/auth/authorizations/roles/private-utilisateur-droit.table'; -import DatabaseService from '../common/services/database.service'; +import { DatabaseService } from '../utils/database/database.service'; import { AppRouter, TrpcRouter } from '../utils/trpc/trpc.router'; type ListRequest = inferProcedureInput< diff --git a/backend/src/collectivites/services/collectivites.service.ts b/backend/src/collectivites/services/collectivites.service.ts index 01f5f13bca..35220cefd8 100644 --- a/backend/src/collectivites/services/collectivites.service.ts +++ b/backend/src/collectivites/services/collectivites.service.ts @@ -1,20 +1,20 @@ import { Injectable, Logger, NotFoundException } from '@nestjs/common'; import { aliasedTable, eq, or } from 'drizzle-orm'; import { isNil } from 'es-toolkit'; -import DatabaseService from '../../common/services/database.service'; -import { collectiviteTestTable } from '../models/collectivite-test.table'; -import { collectiviteTable } from '../models/collectivite.table'; -import { communeTable, CommuneType } from '../models/commune.table'; -import { epciTable, EpciType } from '../models/epci.table'; +import { DatabaseService } from '../../utils/database/database.service'; import { CollectiviteAvecType, CollectivitePopulationTypeEnum, CollectiviteSousTypeEnum, CollectiviteTypeEnum, -} from '../models/identite-collectivite.dto'; -import { banaticTable } from '../models/imports-banatic.table'; -import { importCommuneTable } from '../models/imports-commune.table'; -import { regionTable } from '../models/imports-region.table'; +} from '../identite-collectivite.dto'; +import { collectiviteTestTable } from '../shared/models/collectivite-test.table'; +import { collectiviteTable } from '../shared/models/collectivite.table'; +import { communeTable, CommuneType } from '../shared/models/commune.table'; +import { epciTable, EpciType } from '../shared/models/epci.table'; +import { banaticTable } from '../shared/models/imports-banatic.table'; +import { importCommuneTable } from '../shared/models/imports-commune.table'; +import { regionTable } from '../shared/models/imports-region.table'; @Injectable() export default class CollectivitesService { @@ -199,10 +199,8 @@ export default class CollectivitesService { return epciBySirenResult[0]; } - async isPrivate(collectiviteId : number) : Promise{ - const collectivite = await this.getCollectivite( - collectiviteId - ); + async isPrivate(collectiviteId: number): Promise { + const collectivite = await this.getCollectivite(collectiviteId); return collectivite.collectivite.accessRestreint || false; } } diff --git a/backend/src/collectivites/services/groupements.service.ts b/backend/src/collectivites/services/groupements.service.ts index 2a51797fd1..73297b124a 100644 --- a/backend/src/collectivites/services/groupements.service.ts +++ b/backend/src/collectivites/services/groupements.service.ts @@ -6,12 +6,12 @@ import { NotFoundException, } from '@nestjs/common'; import { eq } from 'drizzle-orm'; -import DatabaseService from '../../common/services/database.service'; -import { groupementTable } from '../models/groupement.table'; +import { DatabaseService } from '../../utils/database/database.service'; import { CreateGroupementCollectiviteType, groupementCollectiviteTable, -} from '../models/groupement-collectivite.table'; +} from '../shared/models/groupement-collectivite.table'; +import { groupementTable } from '../shared/models/groupement.table'; @Injectable() export default class GroupementsService { diff --git a/backend/src/collectivites/services/personnes.service.ts b/backend/src/collectivites/services/personnes.service.ts index f82cead51f..b2ccdbebf1 100644 --- a/backend/src/collectivites/services/personnes.service.ts +++ b/backend/src/collectivites/services/personnes.service.ts @@ -1,6 +1,6 @@ import { dcpTable, utilisateurDroitTable } from '@/backend/auth'; import { personneTagTable } from '@/backend/collectivites/shared/models/personne-tag.table'; -import { DatabaseService } from '@/backend/common'; +import { DatabaseService } from '@/backend/utils'; import { Injectable } from '@nestjs/common'; import { and, eq, sql } from 'drizzle-orm'; import { union } from 'drizzle-orm/pg-core'; diff --git a/backend/src/taxonomie/models/categorie-tag.table.ts b/backend/src/collectivites/shared/models/categorie-tag.table.ts similarity index 67% rename from backend/src/taxonomie/models/categorie-tag.table.ts rename to backend/src/collectivites/shared/models/categorie-tag.table.ts index 3d40a47b5a..7e041cbceb 100644 --- a/backend/src/taxonomie/models/categorie-tag.table.ts +++ b/backend/src/collectivites/shared/models/categorie-tag.table.ts @@ -1,6 +1,6 @@ import { boolean, integer, pgTable } from 'drizzle-orm/pg-core'; -import { tagTableBase } from '../../collectivites/shared/models/tag.table-base'; -import { createdAt, createdBy } from '../../utils/column.utils'; +import { createdAt, createdBy } from '../../../utils/column.utils'; +import { tagTableBase } from './tag.table-base'; export const categorieTagTable = pgTable('categorie_tag', { ...tagTableBase, diff --git a/backend/src/collectivites/models/collectivite-banatic-competence.table.ts b/backend/src/collectivites/shared/models/collectivite-banatic-competence.table.ts similarity index 79% rename from backend/src/collectivites/models/collectivite-banatic-competence.table.ts rename to backend/src/collectivites/shared/models/collectivite-banatic-competence.table.ts index 9557f6e101..921b9af375 100644 --- a/backend/src/collectivites/models/collectivite-banatic-competence.table.ts +++ b/backend/src/collectivites/shared/models/collectivite-banatic-competence.table.ts @@ -1,7 +1,6 @@ -import { integer, pgTable } from 'drizzle-orm/pg-core'; +import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; +import { banaticCompetenceTable } from '../../../shared/models/banatic-competence.table'; import { collectiviteTable } from './collectivite.table'; -import { primaryKey } from 'drizzle-orm/pg-core'; -import { banaticCompetenceTable } from '../../taxonomie/models/banatic-competence.table'; export const collectiviteBanaticCompetenceTable = pgTable( 'collectivite_banatic_competence', diff --git a/backend/src/collectivites/models/collectivite-test.table.ts b/backend/src/collectivites/shared/models/collectivite-test.table.ts similarity index 100% rename from backend/src/collectivites/models/collectivite-test.table.ts rename to backend/src/collectivites/shared/models/collectivite-test.table.ts diff --git a/backend/src/collectivites/models/collectivite.table.ts b/backend/src/collectivites/shared/models/collectivite.table.ts similarity index 92% rename from backend/src/collectivites/models/collectivite.table.ts rename to backend/src/collectivites/shared/models/collectivite.table.ts index d65d978aec..35b21c5780 100644 --- a/backend/src/collectivites/models/collectivite.table.ts +++ b/backend/src/collectivites/shared/models/collectivite.table.ts @@ -1,7 +1,7 @@ import { InferInsertModel, InferSelectModel } from 'drizzle-orm'; import { boolean, pgTable, serial } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; -import { createdAt, modifiedAt } from '../../utils/column.utils'; +import { createdAt, modifiedAt } from '../../../utils/column.utils'; // TODO: create domain siren as varchar(9) check ( value ~ '^\d{9}$' ); // TODO: create domain codegeo as varchar(5); diff --git a/backend/src/collectivites/models/commune.table.ts b/backend/src/collectivites/shared/models/commune.table.ts similarity index 100% rename from backend/src/collectivites/models/commune.table.ts rename to backend/src/collectivites/shared/models/commune.table.ts diff --git a/backend/src/collectivites/models/epci.table.ts b/backend/src/collectivites/shared/models/epci.table.ts similarity index 100% rename from backend/src/collectivites/models/epci.table.ts rename to backend/src/collectivites/shared/models/epci.table.ts diff --git a/backend/src/collectivites/models/groupement-collectivite.table.ts b/backend/src/collectivites/shared/models/groupement-collectivite.table.ts similarity index 100% rename from backend/src/collectivites/models/groupement-collectivite.table.ts rename to backend/src/collectivites/shared/models/groupement-collectivite.table.ts diff --git a/backend/src/collectivites/models/groupement.table.ts b/backend/src/collectivites/shared/models/groupement.table.ts similarity index 100% rename from backend/src/collectivites/models/groupement.table.ts rename to backend/src/collectivites/shared/models/groupement.table.ts diff --git a/backend/src/collectivites/models/imports-banatic.table.ts b/backend/src/collectivites/shared/models/imports-banatic.table.ts similarity index 100% rename from backend/src/collectivites/models/imports-banatic.table.ts rename to backend/src/collectivites/shared/models/imports-banatic.table.ts diff --git a/backend/src/collectivites/models/imports-commune.table.ts b/backend/src/collectivites/shared/models/imports-commune.table.ts similarity index 100% rename from backend/src/collectivites/models/imports-commune.table.ts rename to backend/src/collectivites/shared/models/imports-commune.table.ts diff --git a/backend/src/collectivites/models/imports-region.table.ts b/backend/src/collectivites/shared/models/imports-region.table.ts similarity index 100% rename from backend/src/collectivites/models/imports-region.table.ts rename to backend/src/collectivites/shared/models/imports-region.table.ts diff --git a/backend/src/collectivites/models/membre-fonction.enum.ts b/backend/src/collectivites/shared/models/membre-fonction.enum.ts similarity index 100% rename from backend/src/collectivites/models/membre-fonction.enum.ts rename to backend/src/collectivites/shared/models/membre-fonction.enum.ts diff --git a/backend/src/collectivites/models/membre.table.ts b/backend/src/collectivites/shared/models/membre.table.ts similarity index 81% rename from backend/src/collectivites/models/membre.table.ts rename to backend/src/collectivites/shared/models/membre.table.ts index 4772fe7bda..fc251072ec 100644 --- a/backend/src/collectivites/models/membre.table.ts +++ b/backend/src/collectivites/shared/models/membre.table.ts @@ -7,9 +7,9 @@ import { uuid, } from 'drizzle-orm/pg-core'; import { createInsertSchema } from 'drizzle-zod'; -import { authUsersTable } from '../../auth/models/auth-users.table'; -import { referentielEnum } from '../../referentiels/models/referentiel.enum'; -import { createdAt, modifiedAt } from '../../utils/column.utils'; +import { authUsersTable } from '../../../auth/models/auth-users.table'; +import { referentielEnum } from '../../../referentiels/models/referentiel.enum'; +import { createdAt, modifiedAt } from '../../../utils/column.utils'; import { collectiviteTable } from './collectivite.table'; import { membreFonctionEnum } from './membre-fonction.enum'; diff --git a/backend/src/collectivites/shared/models/tag.table-base.ts b/backend/src/collectivites/shared/models/tag.table-base.ts index 8217a66a3f..0140060a09 100644 --- a/backend/src/collectivites/shared/models/tag.table-base.ts +++ b/backend/src/collectivites/shared/models/tag.table-base.ts @@ -1,6 +1,6 @@ import { integer, serial, text } from 'drizzle-orm/pg-core'; import z from 'zod'; -import { collectiviteTable } from '../../models/collectivite.table'; +import { collectiviteTable } from './collectivite.table'; export type TagType = | 'personne' diff --git a/backend/src/common/common.module.ts b/backend/src/common/common.module.ts deleted file mode 100644 index 4a852c82da..0000000000 --- a/backend/src/common/common.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Module } from '@nestjs/common'; -import { ConfigurationModule } from '../config/configuration.module'; -import { VersionController } from '../utils/version/version.controller'; -import DatabaseService from './services/database.service'; -import MattermostNotificationService from './services/mattermost-notification.service'; -import SupabaseService from './services/supabase.service'; - -@Module({ - imports: [ConfigurationModule], - providers: [DatabaseService, MattermostNotificationService, SupabaseService], - exports: [DatabaseService, MattermostNotificationService, SupabaseService], - controllers: [VersionController], -}) -export class CommonModule {} diff --git a/backend/src/common/index.ts b/backend/src/common/index.ts deleted file mode 100644 index 35e7573d73..0000000000 --- a/backend/src/common/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as DatabaseService } from './services/database.service'; diff --git a/backend/src/common/services/optionalBooleanMapper.ts b/backend/src/common/services/optionalBooleanMapper.ts deleted file mode 100644 index c70023fb91..0000000000 --- a/backend/src/common/services/optionalBooleanMapper.ts +++ /dev/null @@ -1,7 +0,0 @@ -const optionalBooleanMapper = new Map([ - ['undefined', undefined], - ['true', true], - ['false', false], -]); - -export default optionalBooleanMapper; diff --git a/backend/src/documents/models/document.basetable.ts b/backend/src/documents/models/document.basetable.ts index 96ea0f073f..b32effdcbc 100644 --- a/backend/src/documents/models/document.basetable.ts +++ b/backend/src/documents/models/document.basetable.ts @@ -1,13 +1,6 @@ -import { TIMESTAMP_OPTIONS } from '@/backend/utils'; -import { - integer, - jsonb, - serial, - text, - timestamp, - uuid, -} from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { modifiedAt, modifiedBy } from '@/backend/utils'; +import { integer, jsonb, serial, text } from 'drizzle-orm/pg-core'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; export const DocumentBase = { id: serial('id').primaryKey(), @@ -18,9 +11,7 @@ export const DocumentBase = { url: text('url'), titre: text('titre'), commentaire: text('commentaire'), - modifiedAt: timestamp('modified_at', TIMESTAMP_OPTIONS) - .notNull() - .defaultNow(), - modifiedBy: uuid('modified_by'), // TODO references auth.uid, + modifiedAt, + modifiedBy, lien: jsonb('lien'), }; diff --git a/backend/src/documents/models/preuve-rapport.table.ts b/backend/src/documents/models/preuve-rapport.table.ts index 749dc99736..56de6ef904 100644 --- a/backend/src/documents/models/preuve-rapport.table.ts +++ b/backend/src/documents/models/preuve-rapport.table.ts @@ -1,4 +1,4 @@ -import { TIMESTAMP_OPTIONS } from '@/backend/utils'; +import { TIMESTAMP_OPTIONS } from '@/domain/utils'; import { pgTable, timestamp } from 'drizzle-orm/pg-core'; import { DocumentBase } from './document.basetable'; diff --git a/backend/src/documents/services/document.service.ts b/backend/src/documents/services/document.service.ts index 9eab9bfbf8..39da0d0c15 100644 --- a/backend/src/documents/services/document.service.ts +++ b/backend/src/documents/services/document.service.ts @@ -1,5 +1,5 @@ import { Injectable, Logger } from '@nestjs/common'; -import DatabaseService from '../../common/services/database.service'; +import { DatabaseService } from '../../utils/database/database.service'; import { annexeTable } from '../models/annexe.table'; import { lienType } from '../models/document-lien.dto'; diff --git a/backend/src/indicateurs/controllers/trajectoires.controller.ts b/backend/src/indicateurs/controllers/trajectoires.controller.ts index ecc84cbd3b..a312ade9c8 100644 --- a/backend/src/indicateurs/controllers/trajectoires.controller.ts +++ b/backend/src/indicateurs/controllers/trajectoires.controller.ts @@ -12,16 +12,16 @@ import { ApiOkResponse, ApiResponse, ApiTags } from '@nestjs/swagger'; import { NextFunction, Response } from 'express'; import { AllowPublicAccess } from '../../auth/decorators/allow-public-access.decorator'; import { TokenInfo } from '../../auth/decorators/token-info.decorators'; -import { CollectiviteRequestClass } from '../../collectivites/models/collectivite.request'; +import type { AuthenticatedUser } from '../../auth/models/auth.models'; +import { CollectiviteRequestClass } from '../../collectivites/collectivite.request'; import { calculTrajectoireRequestSchema } from '../models/calcul-trajectoire.request'; +import { calculTrajectoireResponseSchema } from '../models/calcul-trajectoire.response'; +import { modeleTrajectoireTelechargementRequestSchema } from '../models/modele-trajectoire-telechargement.request'; +import { verificationTrajectoireRequestSchema } from '../models/verification-trajectoire.request'; +import { verificationTrajectoireResponseSchema } from '../models/verification-trajectoire.response'; import TrajectoiresDataService from '../services/trajectoires-data.service'; import TrajectoiresSpreadsheetService from '../services/trajectoires-spreadsheet.service'; import TrajectoiresXlsxService from '../services/trajectoires-xlsx.service'; -import type { AuthenticatedUser } from '../../auth/models/auth.models'; -import { verificationTrajectoireResponseSchema } from '../models/verification-trajectoire.response'; -import { modeleTrajectoireTelechargementRequestSchema } from '../models/modele-trajectoire-telechargement.request'; -import { verificationTrajectoireRequestSchema } from '../models/verification-trajectoire.request'; -import { calculTrajectoireResponseSchema } from '../models/calcul-trajectoire.response'; /** * Création des classes de requête/réponse à partir du schema pour générer automatiquement la documentation OpenAPI et la validation des entrées diff --git a/backend/src/indicateurs/index-domain.ts b/backend/src/indicateurs/index-domain.ts new file mode 100644 index 0000000000..a10e793525 --- /dev/null +++ b/backend/src/indicateurs/index-domain.ts @@ -0,0 +1,4 @@ +// `index-domain.ts` file must only contain exports that are shareable with client-side apps. +// Exports from this file can be imported with `@/domain/*` alias path. + +export * from './models/indicateur-definition.table'; diff --git a/backend/src/indicateurs/index.ts b/backend/src/indicateurs/index.ts index a45ee415da..81ce45f809 100644 --- a/backend/src/indicateurs/index.ts +++ b/backend/src/indicateurs/index.ts @@ -1 +1 @@ -export * from './models/indicateur-definition.table'; +export * from './index-domain'; diff --git a/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.router.e2e-spec.ts b/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.router.e2e-spec.ts index c016aaa805..d03f198b89 100644 --- a/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.router.e2e-spec.ts +++ b/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.router.e2e-spec.ts @@ -9,7 +9,7 @@ import { } from './get-filtered-indicateurs.request'; import { getFilteredIndicateurResponseSchema } from './get-filtered-indicateurs.response'; -type Input = inferProcedureInput; +type Input = inferProcedureInput; describe('Route de lecture des indicateurs filtrés', () => { let router: TrpcRouter; @@ -39,7 +39,7 @@ describe('Route de lecture des indicateurs filtrés', () => { filtre: filtre, queryOptions: queryOptions, }; - const result = await caller.indicateurs.filtre.list(input); + const result = await caller.indicateurs.list(input); expect(result.length).not.toBe(0); const toCheck = getFilteredIndicateurResponseSchema.safeParse(result); expect(toCheck.success).toBeTruthy; @@ -73,7 +73,7 @@ describe('Route de lecture des indicateurs filtrés', () => { queryOptions: queryOptions, }; - const result = await caller.indicateurs.filtre.list(input); + const result = await caller.indicateurs.list(input); expect(result.length).toBe(0); }); }); diff --git a/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.service.spec.ts b/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.service.spec.ts index 2545b68566..4d8d6e6898 100644 --- a/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.service.spec.ts +++ b/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.service.spec.ts @@ -1,12 +1,12 @@ +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; import { Test } from '@nestjs/testing'; -import DatabaseService from '../../common/services/database.service'; -import IndicateurFiltreService from './indicateur-filtre.service'; +import CollectivitesService from '../../collectivites/services/collectivites.service'; +import { DatabaseService } from '../../utils/database/database.service'; import { GetFilteredIndicateurRequestQueryOptionType, GetFilteredIndicateursRequestOptionType, } from './get-filtered-indicateurs.request'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; -import CollectivitesService from '../../collectivites/services/collectivites.service'; +import IndicateurFiltreService from './indicateur-filtre.service'; describe('IndicateurFiltreService', () => { let indicateurFiltreService: IndicateurFiltreService; diff --git a/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.service.ts b/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.service.ts index 2c182e971e..a024c25324 100644 --- a/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.service.ts +++ b/backend/src/indicateurs/indicateur-filtre/indicateur-filtre.service.ts @@ -8,11 +8,11 @@ import { Injectable } from '@nestjs/common'; import { getTableName, sql } from 'drizzle-orm'; import { intersection, isNil } from 'es-toolkit'; import { AuthenticatedUser } from '../../auth/models/auth.models'; -import { groupementCollectiviteTable } from '../../collectivites/models/groupement-collectivite.table'; import CollectivitesService from '../../collectivites/services/collectivites.service'; -import DatabaseService from '../../common/services/database.service'; +import { categorieTagTable } from '../../collectivites/shared/models/categorie-tag.table'; +import { groupementCollectiviteTable } from '../../collectivites/shared/models/groupement-collectivite.table'; import { ficheActionTable } from '../../plans/fiches/shared/models/fiche-action.table'; -import { categorieTagTable } from '../../taxonomie/models/categorie-tag.table'; +import { DatabaseService } from '../../utils/database/database.service'; import { indicateurActionTable } from '../models/indicateur-action.table'; import { indicateurCategorieTagTable } from '../models/indicateur-categorie-tag.table'; import { indicateurCollectiviteTable } from '../models/indicateur-collectivite.table'; diff --git a/backend/src/indicateurs/indicateurs.module.ts b/backend/src/indicateurs/indicateurs.module.ts index ffe839fe6a..ee5d077ad8 100644 --- a/backend/src/indicateurs/indicateurs.module.ts +++ b/backend/src/indicateurs/indicateurs.module.ts @@ -1,8 +1,6 @@ import { Module } from '@nestjs/common'; import { AuthModule } from '../auth/auth.module'; import { CollectivitesModule } from '../collectivites/collectivites.module'; -import { CommonModule } from '../common/common.module'; -import { ConfigurationModule } from '../config/configuration.module'; import { SheetModule } from '../utils/google-sheets/sheet.module'; import { IndicateursController } from './controllers/indicateurs.controller'; import { TrajectoiresController } from './controllers/trajectoires.controller'; @@ -17,13 +15,7 @@ import TrajectoiresSpreadsheetService from './services/trajectoires-spreadsheet. import TrajectoiresXlsxService from './services/trajectoires-xlsx.service'; @Module({ - imports: [ - ConfigurationModule, - CommonModule, - AuthModule, - CollectivitesModule, - SheetModule, - ], + imports: [AuthModule, CollectivitesModule, SheetModule], providers: [ ExportIndicateursService, IndicateurSourcesService, diff --git a/backend/src/indicateurs/models/calcul-trajectoire.request.ts b/backend/src/indicateurs/models/calcul-trajectoire.request.ts index 2b13e4ccdb..db10e771d2 100644 --- a/backend/src/indicateurs/models/calcul-trajectoire.request.ts +++ b/backend/src/indicateurs/models/calcul-trajectoire.request.ts @@ -1,6 +1,6 @@ import { extendApi } from '@anatine/zod-openapi'; import { z } from 'zod'; -import { collectiviteRequestSchema } from '../../collectivites/models/collectivite.request'; +import { collectiviteRequestSchema } from '../../collectivites/collectivite.request'; export enum CalculTrajectoireReset { MAJ_SPREADSHEET_EXISTANT = 'maj_spreadsheet_existant', diff --git a/backend/src/indicateurs/models/indicateur-categorie-tag.table.ts b/backend/src/indicateurs/models/indicateur-categorie-tag.table.ts index 08f217821c..9bdb2df45f 100644 --- a/backend/src/indicateurs/models/indicateur-categorie-tag.table.ts +++ b/backend/src/indicateurs/models/indicateur-categorie-tag.table.ts @@ -1,7 +1,6 @@ -import { integer, pgTable } from 'drizzle-orm/pg-core'; +import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; +import { categorieTagTable } from '../../collectivites/shared/models/categorie-tag.table'; import { indicateurDefinitionTable } from './indicateur-definition.table'; -import { primaryKey } from 'drizzle-orm/pg-core'; -import { categorieTagTable } from '../../taxonomie/models/categorie-tag.table'; export const indicateurCategorieTagTable = pgTable( 'indicateur_categorie_tag', diff --git a/backend/src/indicateurs/models/indicateur-collectivite.table.ts b/backend/src/indicateurs/models/indicateur-collectivite.table.ts index 8c5b0a2fe9..78e3a2177b 100644 --- a/backend/src/indicateurs/models/indicateur-collectivite.table.ts +++ b/backend/src/indicateurs/models/indicateur-collectivite.table.ts @@ -1,7 +1,12 @@ -import { boolean, integer, pgTable, text } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { + boolean, + integer, + pgTable, + primaryKey, + text, +} from 'drizzle-orm/pg-core'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { indicateurDefinitionTable } from './indicateur-definition.table'; -import { primaryKey } from 'drizzle-orm/pg-core'; export const indicateurCollectiviteTable = pgTable( 'indicateur_collectivite', diff --git a/backend/src/indicateurs/models/indicateur-definition.table.ts b/backend/src/indicateurs/models/indicateur-definition.table.ts index 7118cfdcd2..415755e4ea 100644 --- a/backend/src/indicateurs/models/indicateur-definition.table.ts +++ b/backend/src/indicateurs/models/indicateur-definition.table.ts @@ -9,7 +9,7 @@ import { } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; import { z } from 'zod'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { createdAt, createdBy, diff --git a/backend/src/indicateurs/models/indicateur-pilote.table.ts b/backend/src/indicateurs/models/indicateur-pilote.table.ts index 35f2dfc0d7..5f206437cd 100644 --- a/backend/src/indicateurs/models/indicateur-pilote.table.ts +++ b/backend/src/indicateurs/models/indicateur-pilote.table.ts @@ -1,5 +1,5 @@ import { integer, pgTable, serial, uuid } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { personneTagTable } from '../../collectivites/shared/models/personne-tag.table'; import { indicateurDefinitionTable } from './indicateur-definition.table'; diff --git a/backend/src/indicateurs/models/indicateur-service-tag.table.ts b/backend/src/indicateurs/models/indicateur-service-tag.table.ts index 165b762098..dab77b160c 100644 --- a/backend/src/indicateurs/models/indicateur-service-tag.table.ts +++ b/backend/src/indicateurs/models/indicateur-service-tag.table.ts @@ -1,6 +1,6 @@ -import { serviceTagTable } from '@/backend/collectivites'; +import { serviceTagTable } from '@/domain/collectivites'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { indicateurDefinitionTable } from './indicateur-definition.table'; export const indicateurServiceTagTable = pgTable( diff --git a/backend/src/indicateurs/models/indicateur-valeur.table.ts b/backend/src/indicateurs/models/indicateur-valeur.table.ts index 1a00009fd2..38b68d4b2b 100644 --- a/backend/src/indicateurs/models/indicateur-valeur.table.ts +++ b/backend/src/indicateurs/models/indicateur-valeur.table.ts @@ -11,7 +11,7 @@ import { } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; import { z } from 'zod'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { createdAt, createdBy, diff --git a/backend/src/indicateurs/models/verification-trajectoire.request.ts b/backend/src/indicateurs/models/verification-trajectoire.request.ts index c4cd36391c..f151aa801b 100644 --- a/backend/src/indicateurs/models/verification-trajectoire.request.ts +++ b/backend/src/indicateurs/models/verification-trajectoire.request.ts @@ -1,6 +1,6 @@ import { extendApi } from '@anatine/zod-openapi'; import { z } from 'zod'; -import { collectiviteRequestSchema } from '../../collectivites/models/collectivite.request'; +import { collectiviteRequestSchema } from '../../collectivites/collectivite.request'; export const verificationTrajectoireRequestSchema = extendApi( collectiviteRequestSchema.extend({ diff --git a/backend/src/indicateurs/models/verification-trajectoire.response.ts b/backend/src/indicateurs/models/verification-trajectoire.response.ts index 69bc300b98..515150c151 100644 --- a/backend/src/indicateurs/models/verification-trajectoire.response.ts +++ b/backend/src/indicateurs/models/verification-trajectoire.response.ts @@ -1,6 +1,6 @@ import { extendApi } from '@anatine/zod-openapi'; import { z } from 'zod'; -import { epciSchema } from '../../collectivites/models/epci.table'; +import { epciSchema } from '../../collectivites/shared/models/epci.table'; import { donneesCalculTrajectoireARemplirSchema } from './donnees-calcul-trajectoire-a-remplir.dto'; import { IndicateurValeurType } from './indicateur-valeur.table'; diff --git a/backend/src/indicateurs/services/export-indicateurs.service.ts b/backend/src/indicateurs/services/export-indicateurs.service.ts index 439ca17472..d72896c5d6 100644 --- a/backend/src/indicateurs/services/export-indicateurs.service.ts +++ b/backend/src/indicateurs/services/export-indicateurs.service.ts @@ -15,7 +15,7 @@ import { adjustColumnWidth, BOLD, normalizeWorksheetName, -} from '../../common/services/xlsx.helper'; +} from '../../utils/excel/excel.utils'; import CollectivitesService from '../../collectivites/services/collectivites.service'; import { PermissionService } from '@/backend/auth/authorizations/permission.service'; import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; diff --git a/backend/src/indicateurs/services/indicateur-sources.service.ts b/backend/src/indicateurs/services/indicateur-sources.service.ts index cc13ebac21..1569205084 100644 --- a/backend/src/indicateurs/services/indicateur-sources.service.ts +++ b/backend/src/indicateurs/services/indicateur-sources.service.ts @@ -1,6 +1,6 @@ import { Injectable, Logger } from '@nestjs/common'; import { and, eq } from 'drizzle-orm'; -import DatabaseService from '../../common/services/database.service'; +import { DatabaseService } from '../../utils/database/database.service'; import { CreateIndicateurSourceMetadonneeType, indicateurSourceMetadonneeTable, diff --git a/backend/src/indicateurs/services/indicateurs.service.spec.ts b/backend/src/indicateurs/services/indicateurs.service.spec.ts index 72f5d87182..3b5ddf408d 100644 --- a/backend/src/indicateurs/services/indicateurs.service.spec.ts +++ b/backend/src/indicateurs/services/indicateurs.service.spec.ts @@ -1,7 +1,7 @@ +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; import { Test } from '@nestjs/testing'; import * as _ from 'lodash'; -import { DateTime } from 'luxon'; -import DatabaseService from '../../common/services/database.service'; +import { DatabaseService } from '../../utils/database/database.service'; import { IndicateurDefinitionType } from '../models/indicateur-definition.table'; import { IndicateurSourceMetadonneeType } from '../models/indicateur-source-metadonnee.table'; import { @@ -10,7 +10,6 @@ import { IndicateurValeurAvecMetadonnesDefinition, IndicateurValeurType, } from '../models/indicateur-valeur.table'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; import IndicateursService from './indicateurs.service'; describe('IndicateursService', () => { diff --git a/backend/src/indicateurs/services/indicateurs.service.ts b/backend/src/indicateurs/services/indicateurs.service.ts index 54060a14c1..69f79ce059 100644 --- a/backend/src/indicateurs/services/indicateurs.service.ts +++ b/backend/src/indicateurs/services/indicateurs.service.ts @@ -1,3 +1,6 @@ +import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; +import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; import { Injectable, Logger } from '@nestjs/common'; import { aliasedTable, @@ -14,11 +17,13 @@ import { SQL, SQLWrapper, } from 'drizzle-orm'; -import { objectToCamel } from 'ts-case-convert'; import { groupBy, partition } from 'es-toolkit'; import * as _ from 'lodash'; +import { objectToCamel } from 'ts-case-convert'; import { AuthenticatedUser, AuthRole } from '../../auth/models/auth.models'; -import DatabaseService from '../../common/services/database.service'; +import { groupementCollectiviteTable } from '../../collectivites/shared/models/groupement-collectivite.table'; +import { groupementTable } from '../../collectivites/shared/models/groupement.table'; +import { DatabaseService } from '../../utils/database/database.service'; import { DeleteIndicateursValeursRequestType } from '../models/delete-indicateurs.request'; import { GetIndicateursValeursRequestType } from '../models/get-indicateurs.request'; import { GetIndicateursValeursResponseType } from '../models/get-indicateurs.response'; @@ -28,6 +33,7 @@ import { IndicateurDefinitionType, MinimalIndicateurDefinitionType, } from '../models/indicateur-definition.table'; +import { indicateurGroupeTable } from '../models/indicateur-groupe.table'; import { indicateurSourceMetadonneeTable, IndicateurSourceMetadonneeType, @@ -42,12 +48,6 @@ import { indicateurValeurTable, IndicateurValeurType, } from '../models/indicateur-valeur.table'; -import { indicateurGroupeTable } from '../models/indicateur-groupe.table'; -import { groupementTable } from '../../collectivites/models/groupement.table'; -import { groupementCollectiviteTable } from '../../collectivites/models/groupement-collectivite.table'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; -import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; -import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; @Injectable() export default class IndicateursService { diff --git a/backend/src/indicateurs/services/trajectoires-data.service.ts b/backend/src/indicateurs/services/trajectoires-data.service.ts index fc0bbb253f..3ceebef346 100644 --- a/backend/src/indicateurs/services/trajectoires-data.service.ts +++ b/backend/src/indicateurs/services/trajectoires-data.service.ts @@ -1,3 +1,6 @@ +import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; +import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; import { Injectable, InternalServerErrorException, @@ -7,8 +10,11 @@ import { isNil } from 'es-toolkit'; import * as _ from 'lodash'; import { DateTime } from 'luxon'; import { AuthenticatedUser } from '../../auth/models/auth.models'; -import { EpciType } from '../../collectivites/models/epci.table'; import CollectivitesService from '../../collectivites/services/collectivites.service'; +import { EpciType } from '../../collectivites/shared/models/epci.table'; +import { DonneesARemplirResultType } from '../models/donnees-a-remplir-result.dto'; +import { DonneesARemplirValeurType } from '../models/donnees-a-remplir-valeur.dto'; +import { DonneesCalculTrajectoireARemplirType } from '../models/donnees-calcul-trajectoire-a-remplir.dto'; import { CreateIndicateurSourceMetadonneeType, IndicateurSourceMetadonneeType, @@ -18,17 +24,11 @@ import { IndicateurValeurAvecMetadonnesDefinition, IndicateurValeurType, } from '../models/indicateur-valeur.table'; +import { VerificationTrajectoireRequestType } from '../models/verification-trajectoire.request'; import { VerificationTrajectoireResultType, VerificationTrajectoireStatus, } from '../models/verification-trajectoire.response'; -import { VerificationTrajectoireRequestType } from '../models/verification-trajectoire.request'; -import { DonneesCalculTrajectoireARemplirType } from '../models/donnees-calcul-trajectoire-a-remplir.dto'; -import { DonneesARemplirValeurType } from '../models/donnees-a-remplir-valeur.dto'; -import { DonneesARemplirResultType } from '../models/donnees-a-remplir-result.dto'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; -import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; -import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; import IndicateurSourcesService from './indicateur-sources.service'; import IndicateursService from './indicateurs.service'; @@ -684,7 +684,7 @@ export default class TrajectoiresDataService { return response; } } - if(!forceRecuperationDonneesUniquementPourLecture) { + if (!forceRecuperationDonneesUniquementPourLecture) { // Vérification des droits pour calculer les données await this.permissionService.isAllowed( tokenInfo, diff --git a/backend/src/indicateurs/services/trajectoires-spreadsheet.service.ts b/backend/src/indicateurs/services/trajectoires-spreadsheet.service.ts index a3c3eea4ff..fae81d1e33 100644 --- a/backend/src/indicateurs/services/trajectoires-spreadsheet.service.ts +++ b/backend/src/indicateurs/services/trajectoires-spreadsheet.service.ts @@ -8,9 +8,9 @@ import { isNil, partition } from 'es-toolkit'; import * as _ from 'lodash'; import slugify from 'slugify'; import { AuthenticatedUser } from '../../auth/models/auth.models'; -import { EpciType } from '../../collectivites/models/epci.table'; import GroupementsService from '../../collectivites/services/groupements.service'; -import ConfigurationService from '../../config/configuration.service'; +import { EpciType } from '../../collectivites/shared/models/epci.table'; +import ConfigurationService from '../../utils/config/configuration.service'; import SheetService from '../../utils/google-sheets/sheet.service'; import { CalculTrajectoireRequestType, @@ -261,7 +261,7 @@ export default class TrajectoiresSpreadsheetService { // Ecriture des informations d'émission GES const emissionGesSpreadsheetData = resultatVerification.donneesEntree!.emissionsGes.valeurs.map((valeur) => [ - (valeur.valeur || 0), + valeur.valeur || 0, ]); await this.sheetService.overwriteRawDataToSheet( trajectoireCalculSheetId, @@ -273,7 +273,7 @@ export default class TrajectoiresSpreadsheetService { // Les valeurs de séquestration sont positives en base quand il y a une séquestration mais doivent être écrites avec le signe opposé const sequestrationSpreadsheetData = resultatVerification.donneesEntree!.sequestrations.valeurs.map( - (valeur) => [((valeur.valeur || 0) * -1)] + (valeur) => [(valeur.valeur || 0) * -1] ); await this.sheetService.overwriteRawDataToSheet( trajectoireCalculSheetId, diff --git a/backend/src/indicateurs/services/trajectoires-xlsx.service.ts b/backend/src/indicateurs/services/trajectoires-xlsx.service.ts index e9c37f1b2d..703fd41903 100644 --- a/backend/src/indicateurs/services/trajectoires-xlsx.service.ts +++ b/backend/src/indicateurs/services/trajectoires-xlsx.service.ts @@ -7,9 +7,9 @@ import { import { NextFunction, Response } from 'express'; import { default as XlsxTemplate } from 'xlsx-template'; import { AuthenticatedUser } from '../../auth/models/auth.models'; -import { CollectiviteRequestType } from '../../collectivites/models/collectivite.request'; -import { EpciType } from '../../collectivites/models/epci.table'; -import BackendConfigurationService from '../../config/configuration.service'; +import { CollectiviteRequestType } from '../../collectivites/collectivite.request'; +import { EpciType } from '../../collectivites/shared/models/epci.table'; +import BackendConfigurationService from '../../utils/config/configuration.service'; import SheetService from '../../utils/google-sheets/sheet.service'; import { DonneesCalculTrajectoireARemplirType } from '../models/donnees-calcul-trajectoire-a-remplir.dto'; import { ModeleTrajectoireTelechargementRequestType } from '../models/modele-trajectoire-telechargement.request'; @@ -162,14 +162,14 @@ export default class TrajectoiresXlsxService { valeur.identifiantsReferentiel ); emissionGesSequestrationConsommationsSubstitionValeurs[cleSubstitution] = - (valeur.valeur || 0); + valeur.valeur || 0; }); valeurIndicateurs?.sequestrations.valeurs.forEach((valeur) => { const cleSubstitution = this.getXlsxCleSubstitution( valeur.identifiantsReferentiel ); emissionGesSequestrationConsommationsSubstitionValeurs[cleSubstitution] = - ((valeur.valeur || 0) * -1); + (valeur.valeur || 0) * -1; }); valeurIndicateurs?.consommationsFinales.valeurs.forEach((valeur) => { const cleSubstitution = this.getXlsxCleSubstitution( diff --git a/backend/src/main.ts b/backend/src/main.ts index 19f8a20428..c9b049d939 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -1,13 +1,13 @@ // WARNING: Do this import first -import './common/services/sentry.service'; +import './utils/sentry-init'; // Other imports import { patchNestjsSwagger, ZodValidationPipe } from '@anatine/zod-nestjs'; import { Logger } from '@nestjs/common'; import { HttpAdapterHost, NestFactory } from '@nestjs/core'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { AppModule } from './app.module'; -import { AllExceptionsFilter } from './common/filters/all-exceptions.filter'; -import { initApplicationCredentials } from './common/services/gcloud.helper'; +import { initGoogleCloudCredentials } from './utils/google-sheets/gcloud.helper'; +import { AllExceptionsFilter } from './utils/nest/all-exceptions.filter'; import { TrpcRouter } from './utils/trpc/trpc.router'; const logger = new Logger('main'); @@ -15,7 +15,7 @@ const port = process.env.PORT || 8080; logger.log(`Launching NestJS app on port ${port}`); async function bootstrap() { - initApplicationCredentials(); + initGoogleCloudCredentials(); const app = await NestFactory.create(AppModule, { logger: ['fatal', 'error', 'warn', 'log'], // No debug by default diff --git a/backend/src/personnalisations/models/historique-reponse-binaire.table.ts b/backend/src/personnalisations/models/historique-reponse-binaire.table.ts index 844bba1b12..267126ba52 100644 --- a/backend/src/personnalisations/models/historique-reponse-binaire.table.ts +++ b/backend/src/personnalisations/models/historique-reponse-binaire.table.ts @@ -1,6 +1,6 @@ import { sql } from 'drizzle-orm'; import { boolean, integer, timestamp, varchar } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { historiqueSchema } from './historique-reponse-choix.table'; export const historiqueReponseBinaireTable = historiqueSchema.table( diff --git a/backend/src/personnalisations/models/historique-reponse-choix.table.ts b/backend/src/personnalisations/models/historique-reponse-choix.table.ts index 67ed56d4ee..f249b42745 100644 --- a/backend/src/personnalisations/models/historique-reponse-choix.table.ts +++ b/backend/src/personnalisations/models/historique-reponse-choix.table.ts @@ -1,6 +1,6 @@ import { sql } from 'drizzle-orm'; import { integer, pgSchema, timestamp, varchar } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; export const historiqueSchema = pgSchema('historique'); export const historiqueReponseChoixTable = historiqueSchema.table( diff --git a/backend/src/personnalisations/models/historique-reponse-proportion.table.ts b/backend/src/personnalisations/models/historique-reponse-proportion.table.ts index fbe93bb74d..b93b4a300d 100644 --- a/backend/src/personnalisations/models/historique-reponse-proportion.table.ts +++ b/backend/src/personnalisations/models/historique-reponse-proportion.table.ts @@ -5,7 +5,7 @@ import { timestamp, varchar, } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { historiqueSchema } from './historique-reponse-choix.table'; export const historiqueReponseProportionTable = historiqueSchema.table( diff --git a/backend/src/personnalisations/models/personnalisation-regle.table.ts b/backend/src/personnalisations/models/personnalisation-regle.table.ts index 151c1ca3f5..fa1557ba37 100644 --- a/backend/src/personnalisations/models/personnalisation-regle.table.ts +++ b/backend/src/personnalisations/models/personnalisation-regle.table.ts @@ -1,4 +1,4 @@ -import { modifiedAt } from '@/backend/utils'; +import { modifiedAt } from '@/domain/utils'; import { InferInsertModel, InferSelectModel } from 'drizzle-orm'; import { pgEnum, pgTable, primaryKey, text } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; diff --git a/backend/src/personnalisations/models/reponse-binaire.table.ts b/backend/src/personnalisations/models/reponse-binaire.table.ts index ca2177877f..77704f35a7 100644 --- a/backend/src/personnalisations/models/reponse-binaire.table.ts +++ b/backend/src/personnalisations/models/reponse-binaire.table.ts @@ -1,6 +1,6 @@ -import { modifiedAt } from '@/backend/utils'; +import { modifiedAt } from '@/domain/utils'; import { boolean, integer, pgTable, varchar } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; export const reponseBinaireTable = pgTable('reponse_binaire', { modifiedAt, diff --git a/backend/src/personnalisations/models/reponse-choix.table.ts b/backend/src/personnalisations/models/reponse-choix.table.ts index 7adb0253a5..b561bcd56c 100644 --- a/backend/src/personnalisations/models/reponse-choix.table.ts +++ b/backend/src/personnalisations/models/reponse-choix.table.ts @@ -1,6 +1,6 @@ -import { modifiedAt } from '@/backend/utils'; +import { modifiedAt } from '@/domain/utils'; import { integer, pgTable, varchar } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; export const reponseChoixTable = pgTable('reponse_choix', { modifiedAt, diff --git a/backend/src/personnalisations/models/reponse-proportion.table.ts b/backend/src/personnalisations/models/reponse-proportion.table.ts index 4e0ebae1ba..7f908efb8f 100644 --- a/backend/src/personnalisations/models/reponse-proportion.table.ts +++ b/backend/src/personnalisations/models/reponse-proportion.table.ts @@ -1,11 +1,11 @@ -import { modifiedAt } from '@/backend/utils'; +import { modifiedAt } from '@/domain/utils'; import { doublePrecision, integer, pgTable, varchar, } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; export const reponseProportionTable = pgTable('reponse_proportion', { modifiedAt, diff --git a/backend/src/personnalisations/personnalisations.module.ts b/backend/src/personnalisations/personnalisations.module.ts index 0cbbd90cd5..9f8a90ddf0 100644 --- a/backend/src/personnalisations/personnalisations.module.ts +++ b/backend/src/personnalisations/personnalisations.module.ts @@ -1,13 +1,12 @@ import { Module } from '@nestjs/common'; import { AuthModule } from '../auth/auth.module'; import { CollectivitesModule } from '../collectivites/collectivites.module'; -import { CommonModule } from '../common/common.module'; import { PersonnalisationsController } from './controllers/personnalisations.controller'; import ExpressionParserService from './services/expression-parser.service'; import PersonnalisationsService from './services/personnalisations-service'; @Module({ - imports: [CommonModule, CollectivitesModule, AuthModule], + imports: [CollectivitesModule, AuthModule], providers: [ExpressionParserService, PersonnalisationsService], exports: [ExpressionParserService, PersonnalisationsService], controllers: [PersonnalisationsController], diff --git a/backend/src/personnalisations/services/expression-parser.service.spec.ts b/backend/src/personnalisations/services/expression-parser.service.spec.ts index c890520417..cd48cd5f55 100644 --- a/backend/src/personnalisations/services/expression-parser.service.spec.ts +++ b/backend/src/personnalisations/services/expression-parser.service.spec.ts @@ -2,7 +2,7 @@ import { Test } from '@nestjs/testing'; import { CollectivitePopulationTypeEnum, CollectiviteTypeEnum, -} from '../../collectivites/models/identite-collectivite.dto'; +} from '../../collectivites/identite-collectivite.dto'; import ExpressionParserService from './expression-parser.service'; describe('ExpressionParserService', () => { @@ -256,8 +256,8 @@ describe('ExpressionParserService', () => { le score de la 1.2.3 est réduit à 2 points. */ - const expression = `si reponse(dechets_1, OUI) et reponse(dechets_2, OUI) et reponse(dechets_3, OUI) alors 1.0 -sinon si reponse(dechets_1, NON) et reponse(dechets_2, NON) et reponse(dechets_3, NON) alors 2/12 + const expression = `si reponse(dechets_1, OUI) et reponse(dechets_2, OUI) et reponse(dechets_3, OUI) alors 1.0 +sinon si reponse(dechets_1, NON) et reponse(dechets_2, NON) et reponse(dechets_3, NON) alors 2/12 sinon 0.75`; expect(() => expressionParserService.parseAndEvaluateExpression(expression) @@ -331,12 +331,12 @@ sinon 0.75`; Ces réductions sont cumulables dans la limite de 2 points restants pour prendre en compte la part d’influence dans les instances compétentes et les actions partenariales. */ - const expression = `si reponse(AOD_elec, OUI) et reponse(AOD_gaz, OUI) et reponse(AOD_chaleur, OUI) alors 1.0 -sinon si reponse(AOD_elec, NON) et reponse(AOD_gaz, NON) et reponse(AOD_chaleur, NON) alors 2/10 -sinon si reponse(AOD_elec, NON) et reponse(AOD_gaz, NON) alors 4/10 -sinon si reponse(AOD_elec, NON) et reponse(AOD_chaleur, NON) alors 3/10 -sinon si reponse(AOD_gaz, NON) et reponse(AOD_chaleur, NON) alors 3/10 -sinon si reponse(AOD_elec, NON) ou reponse(AOD_gaz, NON) alors 7/10 + const expression = `si reponse(AOD_elec, OUI) et reponse(AOD_gaz, OUI) et reponse(AOD_chaleur, OUI) alors 1.0 +sinon si reponse(AOD_elec, NON) et reponse(AOD_gaz, NON) et reponse(AOD_chaleur, NON) alors 2/10 +sinon si reponse(AOD_elec, NON) et reponse(AOD_gaz, NON) alors 4/10 +sinon si reponse(AOD_elec, NON) et reponse(AOD_chaleur, NON) alors 3/10 +sinon si reponse(AOD_gaz, NON) et reponse(AOD_chaleur, NON) alors 3/10 +sinon si reponse(AOD_elec, NON) ou reponse(AOD_gaz, NON) alors 7/10 sinon si reponse(AOD_chaleur, NON) alors 6/10`; expect( diff --git a/backend/src/personnalisations/services/expression-parser.service.ts b/backend/src/personnalisations/services/expression-parser.service.ts index 9882405ddb..4ff7403c0a 100644 --- a/backend/src/personnalisations/services/expression-parser.service.ts +++ b/backend/src/personnalisations/services/expression-parser.service.ts @@ -7,7 +7,7 @@ import { tokenMatcher, } from 'chevrotain'; import * as _ from 'lodash'; -import { IdentiteCollectivite } from '../../collectivites/models/identite-collectivite.dto'; +import { IdentiteCollectivite } from '../../collectivites/identite-collectivite.dto'; // Define all the tokens used in the grammar const VRAI = createToken({ name: 'VRAI', pattern: /VRAI/ }); diff --git a/backend/src/personnalisations/services/personnalisations-service.ts b/backend/src/personnalisations/services/personnalisations-service.ts index 84c9a5028d..bc8ac5cdcb 100644 --- a/backend/src/personnalisations/services/personnalisations-service.ts +++ b/backend/src/personnalisations/services/personnalisations-service.ts @@ -1,12 +1,15 @@ +import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; +import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; import { Injectable, Logger } from '@nestjs/common'; import { and, asc, desc, eq, like, lte, SQL, SQLWrapper } from 'drizzle-orm'; import { AuthenticatedUser } from '../../auth/models/auth.models'; import { CollectiviteAvecType, IdentiteCollectivite, -} from '../../collectivites/models/identite-collectivite.dto'; +} from '../../collectivites/identite-collectivite.dto'; import CollectivitesService from '../../collectivites/services/collectivites.service'; -import DatabaseService from '../../common/services/database.service'; +import { DatabaseService } from '../../utils/database/database.service'; import { GetPersonnalisationConsequencesRequestType } from '../models/get-personnalisation-consequences.request'; import { GetPersonnalitionConsequencesResponseType } from '../models/get-personnalisation-consequences.response'; import { GetPersonnalisationReglesResponseType } from '../models/get-personnalisation-regles.response'; @@ -22,9 +25,6 @@ import { reponseBinaireTable } from '../models/reponse-binaire.table'; import { reponseChoixTable } from '../models/reponse-choix.table'; import { reponseProportionTable } from '../models/reponse-proportion.table'; import ExpressionParserService from './expression-parser.service'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; -import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; -import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; export type ReponseTables = | typeof reponseBinaireTable diff --git a/backend/src/plans/fiches/axe.service.ts b/backend/src/plans/fiches/axe.service.ts index db5d2fe629..b92731e39a 100644 --- a/backend/src/plans/fiches/axe.service.ts +++ b/backend/src/plans/fiches/axe.service.ts @@ -1,5 +1,5 @@ import { Injectable, Logger } from '@nestjs/common'; -import DatabaseService from '../../common/services/database.service'; +import { DatabaseService } from '../../utils/database/database.service'; import { axeTable, CreateAxeType } from './shared/models/axe.table'; import { ficheActionAxeTable } from './shared/models/fiche-action-axe.table'; diff --git a/backend/src/plans/fiches/bulk-edit/bulk-edit.router.e2e-spec.ts b/backend/src/plans/fiches/bulk-edit/bulk-edit.router.e2e-spec.ts index 129b221f81..88607faa83 100644 --- a/backend/src/plans/fiches/bulk-edit/bulk-edit.router.e2e-spec.ts +++ b/backend/src/plans/fiches/bulk-edit/bulk-edit.router.e2e-spec.ts @@ -1,6 +1,5 @@ import { AuthenticatedUser } from '@/backend/auth/models/auth.models'; import { libreTagTable } from '@/backend/collectivites'; -import { DatabaseService } from '@/backend/common'; import { getAuthUser, getTestApp, @@ -9,6 +8,7 @@ import { YOLO_DODO, YULU_DUDU, } from '@/backend/test'; +import { DatabaseService } from '@/backend/utils'; import { AppRouter, TrpcRouter } from '@/backend/utils/trpc/trpc.router'; import { inferProcedureInput } from '@trpc/server'; import { eq, inArray, sql } from 'drizzle-orm'; diff --git a/backend/src/plans/fiches/bulk-edit/bulk-edit.service.ts b/backend/src/plans/fiches/bulk-edit/bulk-edit.service.ts index 1514522943..961d8ddae3 100644 --- a/backend/src/plans/fiches/bulk-edit/bulk-edit.service.ts +++ b/backend/src/plans/fiches/bulk-edit/bulk-edit.service.ts @@ -2,13 +2,13 @@ import { PermissionOperation } from '@/backend/auth/authorizations/permission-op import { PermissionService } from '@/backend/auth/authorizations/permission.service'; import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; import { AuthUser } from '@/backend/auth/models/auth.models'; -import { DatabaseService } from '@/backend/common'; import { ficheActionLibreTagTable, ficheActionTable, ficheSchema, } from '@/backend/plans/fiches'; import { editFicheRequestSchema } from '@/backend/plans/fiches/shared/edit-fiche.request'; +import { DatabaseService } from '@/backend/utils'; import { Injectable } from '@nestjs/common'; import { and, inArray, or } from 'drizzle-orm'; import z from 'zod'; diff --git a/backend/src/plans/fiches/count-by-statut/count-by-statut.service.ts b/backend/src/plans/fiches/count-by-statut/count-by-statut.service.ts index ad71e827dd..f170db3249 100644 --- a/backend/src/plans/fiches/count-by-statut/count-by-statut.service.ts +++ b/backend/src/plans/fiches/count-by-statut/count-by-statut.service.ts @@ -1,5 +1,3 @@ -import { DatabaseService } from '@/backend/common'; -import { getModifiedSinceDate } from '@/backend/common/models/modified-since.enum'; import { axeTable, ficheActionPartenaireTagTable, @@ -9,7 +7,9 @@ import { statutsEnumValues, } from '@/backend/plans/fiches'; import { GetFichesActionFilterRequestType } from '@/backend/plans/fiches/shared/fetch-fiches-filter.request'; +import { DatabaseService } from '@/backend/utils'; import { CountByRecordType } from '@/backend/utils/count-by.dto'; +import { getModifiedSinceDate } from '@/backend/utils/modified-since.enum'; import { Injectable, Logger } from '@nestjs/common'; import { and, diff --git a/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.router.e2e-spec.ts b/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.router.e2e-spec.ts index d3c76b00cd..58f4fd0030 100644 --- a/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.router.e2e-spec.ts +++ b/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.router.e2e-spec.ts @@ -1,12 +1,11 @@ import { AuthenticatedUser } from '@/backend/auth/models/auth.models'; -import { DatabaseService } from '@/backend/common'; import { getAuthUser, getTestApp, getTestDatabase, getTestRouter, } from '@/backend/test'; -import { AppRouter } from '@/backend/utils'; +import { AppRouter, DatabaseService } from '@/backend/utils'; import { TrpcRouter } from '@/backend/utils/trpc/trpc.router'; import { inferProcedureInput } from '@trpc/server'; import { eq } from 'drizzle-orm'; diff --git a/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.service.ts b/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.service.ts index f5c9322757..be9451760b 100644 --- a/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.service.ts +++ b/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.service.ts @@ -1,5 +1,5 @@ import { AuthenticatedUser } from '@/backend/auth/models/auth.models'; -import { DatabaseService } from '@/backend/common'; +import { DatabaseService } from '@/backend/utils'; import { Injectable } from '@nestjs/common'; import { and, eq, gt, gte, lt, lte, sql } from 'drizzle-orm'; import FicheService from '../fiche.service'; diff --git a/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.table.ts b/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.table.ts index 28133861a1..1b1a1f1ab0 100644 --- a/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.table.ts +++ b/backend/src/plans/fiches/fiche-action-etape/fiche-action-etape.table.ts @@ -1,4 +1,4 @@ -import { createdAt, createdBy, modifiedAt, modifiedBy } from '@/backend/utils'; +import { createdAt, createdBy, modifiedAt, modifiedBy } from '@/domain/utils'; import { InferSelectModel } from 'drizzle-orm'; import { boolean, integer, pgTable, serial, text } from 'drizzle-orm/pg-core'; import { createInsertSchema } from 'drizzle-zod'; diff --git a/backend/src/plans/fiches/fiche-action-update.e2e-spec.ts b/backend/src/plans/fiches/fiche-action-update.e2e-spec.ts index 9b3b8c37a7..3175d29021 100644 --- a/backend/src/plans/fiches/fiche-action-update.e2e-spec.ts +++ b/backend/src/plans/fiches/fiche-action-update.e2e-spec.ts @@ -5,7 +5,7 @@ import { default as request } from 'supertest'; import { describe, expect, it } from 'vitest'; import { getTestApp } from '../../../test/app-utils'; import { getAuthToken } from '../../../test/auth-utils'; -import DatabaseService from '../../common/services/database.service'; +import { DatabaseService } from '../../utils/database/database.service'; import { UpdateFicheActionRequestClass } from './fiches-action.controller'; import { UpdateFicheActionRequestType } from './shared/edit-fiche.request'; import { diff --git a/backend/src/plans/fiches/fiche.service.ts b/backend/src/plans/fiches/fiche.service.ts index 83fb4b0bf6..4f095a8f0b 100644 --- a/backend/src/plans/fiches/fiche.service.ts +++ b/backend/src/plans/fiches/fiche.service.ts @@ -5,8 +5,7 @@ import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; import { Injectable, Logger } from '@nestjs/common'; import { aliasedTable, desc, eq } from 'drizzle-orm'; import { AuthenticatedUser } from '../../auth/models/auth.models'; -import DatabaseService from '../../common/services/database.service'; -import TagService from '../../taxonomie/services/tag.service'; +import { DatabaseService } from '../../utils/database/database.service'; import { ficheActionActionImpactTable } from './shared/models/fiche-action-action-impact.table'; import { ficheActionActionTable } from './shared/models/fiche-action-action.table'; import { ficheActionEffetAttenduTable } from './shared/models/fiche-action-effet-attendu.table'; @@ -26,8 +25,7 @@ export default class FicheService { constructor( private readonly permissionService: PermissionService, - private readonly databaseService: DatabaseService, - private readonly tagService: TagService + private readonly databaseService: DatabaseService ) {} /** Renvoi une fiche à partir de son id */ @@ -155,21 +153,6 @@ export default class FicheService { }); } - /** - * Ajoute un partenaire à une fiche à partir du nom du partenaire et la collectivité - * @param ficheId identifiant de la fiche - * @param nomTag nom du partenaire - * @param collectiviteId identifiant de la collectivité - */ - async addPartenaireByNom( - ficheId: number, - nomTag: string, - collectiviteId: number - ): Promise { - const tagId = await this.tagService.getPartenaireId(nomTag, collectiviteId); - await this.addPartenaireById(ficheId, tagId); - } - // On ajoute le financement /** diff --git a/backend/src/plans/fiches/fiches-action-update.service.ts b/backend/src/plans/fiches/fiches-action-update.service.ts index 5aed237bea..ec2e5fa39a 100644 --- a/backend/src/plans/fiches/fiches-action-update.service.ts +++ b/backend/src/plans/fiches/fiches-action-update.service.ts @@ -1,3 +1,4 @@ +import { DatabaseService } from '@/backend/utils'; import { Injectable, Logger, NotFoundException } from '@nestjs/common'; import { and, @@ -13,8 +14,7 @@ import { PgTable, PgTransaction } from 'drizzle-orm/pg-core'; import { PostgresJsQueryResultHKT } from 'drizzle-orm/postgres-js'; import { toCamel } from 'postgres'; import { AuthenticatedUser } from '../../auth/models/auth.models'; -import DatabaseService from '../../common/services/database.service'; -import { buildConflictUpdateColumns } from '../../utils/drizzle/conflict.utils'; +import { buildConflictUpdateColumns } from '../../utils/database/conflict.utils'; import FicheService from './fiche.service'; import { UpdateFicheActionRequestType } from './shared/edit-fiche.request'; import { ficheActionActionTable } from './shared/models/fiche-action-action.table'; diff --git a/backend/src/plans/fiches/fiches.module.ts b/backend/src/plans/fiches/fiches.module.ts index 8325450ba3..038b77f118 100644 --- a/backend/src/plans/fiches/fiches.module.ts +++ b/backend/src/plans/fiches/fiches.module.ts @@ -1,8 +1,6 @@ import { Module } from '@nestjs/common'; import { AuthModule } from '../../auth/auth.module'; import { CollectivitesModule } from '../../collectivites/collectivites.module'; -import { CommonModule } from '../../common/common.module'; -import TagService from '../../taxonomie/services/tag.service'; import { BulkEditRouter } from './bulk-edit/bulk-edit.router'; import { BulkEditService } from './bulk-edit/bulk-edit.service'; import { CountByStatutRouter } from './count-by-statut/count-by-statut.router'; @@ -14,7 +12,7 @@ import FichesActionUpdateService from './fiches-action-update.service'; import { FichesActionController } from './fiches-action.controller'; @Module({ - imports: [CommonModule, AuthModule, CollectivitesModule], + imports: [AuthModule, CollectivitesModule], providers: [ FicheService, CountByStatutService, @@ -22,7 +20,6 @@ import { FichesActionController } from './fiches-action.controller'; BulkEditService, BulkEditRouter, FichesActionUpdateService, - TagService, FicheActionEtapeService, FicheActionEtapeRouter, ], diff --git a/backend/src/plans/fiches/index-domain.ts b/backend/src/plans/fiches/index-domain.ts new file mode 100644 index 0000000000..5d35bca520 --- /dev/null +++ b/backend/src/plans/fiches/index-domain.ts @@ -0,0 +1,18 @@ +// `index-domain.ts` file must only contain exports that are shareable with client-side apps. +// Exports from this file can be imported with `@/domain/*` alias path. + +export * from './shared/models/axe.table'; +export * from './shared/models/fiche-action-effet-attendu.table'; +export * from './shared/models/fiche-action-financeur-tag.table'; +export * from './shared/models/fiche-action-indicateur.table'; +export * from './shared/models/fiche-action-libre-tag.table'; +export * from './shared/models/fiche-action-lien.table'; +export * from './shared/models/fiche-action-note.table'; +export * from './shared/models/fiche-action-partenaire-tag.table'; +export * from './shared/models/fiche-action-service-tag.table'; +export * from './shared/models/fiche-action-sous-thematique.table'; +export * from './shared/models/fiche-action-structure-tag.table'; +export * from './shared/models/fiche-action-thematique.table'; +export * from './shared/models/fiche-action.table'; +export * from './shared/models/plan-action-type-categorie.table'; +export * from './shared/models/plan-action-type.table'; diff --git a/backend/src/plans/fiches/index.ts b/backend/src/plans/fiches/index.ts index 3c07fa18a5..81ce45f809 100644 --- a/backend/src/plans/fiches/index.ts +++ b/backend/src/plans/fiches/index.ts @@ -1,15 +1 @@ -export * from './shared/models/axe.table'; -export * from './shared/models/fiche-action-effet-attendu.table'; -export * from './shared/models/fiche-action-financeur-tag.table'; -export * from './shared/models/fiche-action-indicateur.table'; -export * from './shared/models/fiche-action-libre-tag.table'; -export * from './shared/models/fiche-action-lien.table'; -export * from './shared/models/fiche-action-note.table'; -export * from './shared/models/fiche-action-partenaire-tag.table'; -export * from './shared/models/fiche-action-service-tag.table'; -export * from './shared/models/fiche-action-sous-thematique.table'; -export * from './shared/models/fiche-action-structure-tag.table'; -export * from './shared/models/fiche-action-thematique.table'; -export * from './shared/models/fiche-action.table'; -export * from './shared/models/plan-action-type-categorie.table'; -export * from './shared/models/plan-action-type.table'; +export * from './index-domain'; diff --git a/backend/src/plans/fiches/shared/fetch-fiches-filter.request.ts b/backend/src/plans/fiches/shared/fetch-fiches-filter.request.ts index b471396d10..004b72354c 100644 --- a/backend/src/plans/fiches/shared/fetch-fiches-filter.request.ts +++ b/backend/src/plans/fiches/shared/fetch-fiches-filter.request.ts @@ -1,4 +1,4 @@ -import { modifiedSinceSchema } from '@/backend/common/models/modified-since.enum'; +import { modifiedSinceSchema } from '@/backend/utils/modified-since.enum'; import { z } from 'zod'; import { ciblesEnumSchema } from './models/fiche-action.table'; diff --git a/backend/src/plans/fiches/shared/models/axe.table.ts b/backend/src/plans/fiches/shared/models/axe.table.ts index fe60ea9bb1..eababe421b 100644 --- a/backend/src/plans/fiches/shared/models/axe.table.ts +++ b/backend/src/plans/fiches/shared/models/axe.table.ts @@ -1,4 +1,4 @@ -import { createdAt, modifiedAt, modifiedBy } from '@/backend/utils'; +import { createdAt, modifiedAt, modifiedBy } from '@/domain/utils'; import { InferInsertModel } from 'drizzle-orm'; import { AnyPgColumn, @@ -9,8 +9,8 @@ import { } from 'drizzle-orm/pg-core'; import { createSelectSchema } from 'drizzle-zod'; import z from 'zod'; -import { collectiviteTable } from '../../../../collectivites/models/collectivite.table'; -import { panierTable } from '../../../../panier/models/panier.table'; +import { collectiviteTable } from '../../../../collectivites/shared/models/collectivite.table'; +import { panierTable } from '../../../paniers/models/panier.table'; import { planActionTypeSchema, planActionTypeTable, diff --git a/backend/src/plans/fiches/shared/models/fiche-action-action-impact.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-action-impact.table.ts index 7175041e34..e641bd8481 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-action-impact.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-action-impact.table.ts @@ -1,5 +1,5 @@ +import { actionImpactTable } from '@/domain/plans/paniers'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; -import { actionImpactTable } from '../../../../panier/models/action-impact.table'; import { ficheActionTable } from './fiche-action.table'; export const ficheActionActionImpactTable = pgTable( diff --git a/backend/src/plans/fiches/shared/models/fiche-action-action.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-action.table.ts index 27b64d507c..7b4494fd0d 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-action.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-action.table.ts @@ -1,4 +1,4 @@ -import { actionRelationTable } from '@/backend/referentiels'; +import { actionRelationTable } from '@/domain/referentiels'; import { integer, pgTable, primaryKey, varchar } from 'drizzle-orm/pg-core'; import { ficheActionTable } from './fiche-action.table'; diff --git a/backend/src/plans/fiches/shared/models/fiche-action-effet-attendu.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-effet-attendu.table.ts index 319c3b18d4..065a080499 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-effet-attendu.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-effet-attendu.table.ts @@ -1,8 +1,8 @@ +import { effetAttenduTable } from '@/domain/shared'; import { sql } from 'drizzle-orm'; import { integer, pgPolicy, pgTable, primaryKey } from 'drizzle-orm/pg-core'; import { authenticatedRole } from 'drizzle-orm/supabase'; import { ficheActionTable } from './fiche-action.table'; -import { effetAttenduTable } from '@/backend/shared'; export const ficheActionEffetAttenduTable = pgTable( 'fiche_action_effet_attendu', diff --git a/backend/src/plans/fiches/shared/models/fiche-action-indicateur.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-indicateur.table.ts index 3712df1742..cec0085d97 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-indicateur.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-indicateur.table.ts @@ -1,4 +1,4 @@ -import { indicateurDefinitionTable } from '@/backend/indicateurs'; +import { indicateurDefinitionTable } from '@/domain/indicateurs'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; import { ficheActionTable } from './fiche-action.table'; diff --git a/backend/src/plans/fiches/shared/models/fiche-action-libre-tag.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-libre-tag.table.ts index 6f2c4d3d3b..e081215f87 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-libre-tag.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-libre-tag.table.ts @@ -1,5 +1,5 @@ -import { libreTagTable } from '@/backend/collectivites'; -import { createdAt, createdBy } from '@/backend/utils'; +import { libreTagTable } from '@/domain/collectivites'; +import { createdAt, createdBy } from '@/domain/utils'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; import { ficheActionTable } from './fiche-action.table'; diff --git a/backend/src/plans/fiches/shared/models/fiche-action-note.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-note.table.ts index ffb278bd7e..331bfbc2d3 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-note.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-note.table.ts @@ -1,4 +1,4 @@ -import { createdAt, createdBy, modifiedAt, modifiedBy } from '@/backend/utils'; +import { createdAt, createdBy, modifiedAt, modifiedBy } from '@/domain/utils'; import { InferSelectModel } from 'drizzle-orm'; import { date, integer, pgTable, serial, text } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; diff --git a/backend/src/plans/fiches/shared/models/fiche-action-partenaire-tag.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-partenaire-tag.table.ts index 3900c9a802..5063515b23 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-partenaire-tag.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-partenaire-tag.table.ts @@ -1,4 +1,4 @@ -import { partenaireTagTable } from '@/backend/collectivites'; +import { partenaireTagTable } from '@/domain/collectivites'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; import { ficheActionTable } from './fiche-action.table'; diff --git a/backend/src/plans/fiches/shared/models/fiche-action-referent.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-referent.table.ts index efd1e7e5a7..449606ef43 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-referent.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-referent.table.ts @@ -1,4 +1,4 @@ -import { personneTagTable } from '@/backend/collectivites'; +import { personneTagTable } from '@/domain/collectivites'; import { integer, pgTable, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; import { ficheActionTable } from './fiche-action.table'; diff --git a/backend/src/plans/fiches/shared/models/fiche-action-service-tag.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-service-tag.table.ts index 01940fe9ac..4f4926ec1c 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-service-tag.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-service-tag.table.ts @@ -1,4 +1,4 @@ -import { serviceTagTable } from '@/backend/collectivites'; +import { serviceTagTable } from '@/domain/collectivites'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; import { ficheActionTable } from './fiche-action.table'; diff --git a/backend/src/plans/fiches/shared/models/fiche-action-sous-thematique.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-sous-thematique.table.ts index 11d7d442b3..843ea92d62 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-sous-thematique.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-sous-thematique.table.ts @@ -1,4 +1,4 @@ -import { sousThematiqueTable } from '@/backend/shared'; +import { sousThematiqueTable } from '@/domain/shared'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; import { ficheActionTable } from './fiche-action.table'; diff --git a/backend/src/plans/fiches/shared/models/fiche-action-structure-tag.table.ts b/backend/src/plans/fiches/shared/models/fiche-action-structure-tag.table.ts index 3f0c824532..dd374909fe 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action-structure-tag.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action-structure-tag.table.ts @@ -1,4 +1,4 @@ -import { structureTagTable } from '@/backend/collectivites'; +import { structureTagTable } from '@/domain/collectivites'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; import { ficheActionTable } from './fiche-action.table'; diff --git a/backend/src/plans/fiches/shared/models/fiche-action.table.ts b/backend/src/plans/fiches/shared/models/fiche-action.table.ts index a6faf34d81..300a3c4a42 100644 --- a/backend/src/plans/fiches/shared/models/fiche-action.table.ts +++ b/backend/src/plans/fiches/shared/models/fiche-action.table.ts @@ -12,7 +12,7 @@ import { } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; import { z } from 'zod'; -import { collectiviteTable } from '../../../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../../../collectivites/shared/models/collectivite.table'; import { tempsDeMiseEnOeuvreTable } from '../../../../shared/models/temps-de-mise-en-oeuvre.table'; import { createdAt, diff --git a/backend/src/plans/paniers/index-domain.ts b/backend/src/plans/paniers/index-domain.ts new file mode 100644 index 0000000000..745028455c --- /dev/null +++ b/backend/src/plans/paniers/index-domain.ts @@ -0,0 +1,4 @@ +// `index-domain.ts` file must only contain exports that are shareable with client-side apps. +// Exports from this file can be imported with `@/domain/*` alias path. + +export * from './models/action-impact.table'; diff --git a/backend/src/plans/paniers/index.ts b/backend/src/plans/paniers/index.ts new file mode 100644 index 0000000000..81ce45f809 --- /dev/null +++ b/backend/src/plans/paniers/index.ts @@ -0,0 +1 @@ +export * from './index-domain'; diff --git a/backend/src/panier/models/action-impact-action.table.ts b/backend/src/plans/paniers/models/action-impact-action.table.ts similarity index 75% rename from backend/src/panier/models/action-impact-action.table.ts rename to backend/src/plans/paniers/models/action-impact-action.table.ts index 6cb1162297..250c4c526e 100644 --- a/backend/src/panier/models/action-impact-action.table.ts +++ b/backend/src/plans/paniers/models/action-impact-action.table.ts @@ -1,8 +1,7 @@ -import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; -import { actionRelationTable } from '../../referentiels/models/action-relation.table'; -import { actionImpactTable } from './action-impact.table'; -import { text } from 'drizzle-orm/pg-core'; +import { actionRelationTable } from '@/domain/referentiels'; import { InferSelectModel } from 'drizzle-orm'; +import { integer, pgTable, primaryKey, text } from 'drizzle-orm/pg-core'; +import { actionImpactTable } from './action-impact.table'; export const actionImpactActionTable = pgTable( 'action_impact_action', diff --git a/backend/src/panier/models/action-impact-banatic-competence.table.ts b/backend/src/plans/paniers/models/action-impact-banatic-competence.table.ts similarity index 76% rename from backend/src/panier/models/action-impact-banatic-competence.table.ts rename to backend/src/plans/paniers/models/action-impact-banatic-competence.table.ts index 4576428c79..cd49d67c50 100644 --- a/backend/src/panier/models/action-impact-banatic-competence.table.ts +++ b/backend/src/plans/paniers/models/action-impact-banatic-competence.table.ts @@ -1,7 +1,6 @@ -import { integer, pgTable } from 'drizzle-orm/pg-core'; -import { primaryKey } from 'drizzle-orm/pg-core'; +import { banaticCompetenceTable } from '@/domain/shared'; +import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; import { actionImpactTable } from './action-impact.table'; -import { banaticCompetenceTable } from '../../taxonomie/models/banatic-competence.table'; export const actionImpactBanaticCompetenceTable = pgTable( 'action_impact_banatic_competence', diff --git a/backend/src/panier/models/action-impact-categorie.table.ts b/backend/src/plans/paniers/models/action-impact-categorie.table.ts similarity index 100% rename from backend/src/panier/models/action-impact-categorie.table.ts rename to backend/src/plans/paniers/models/action-impact-categorie.table.ts diff --git a/backend/src/panier/models/action-impact-cateorie-fnv.table.ts b/backend/src/plans/paniers/models/action-impact-cateorie-fnv.table.ts similarity index 87% rename from backend/src/panier/models/action-impact-cateorie-fnv.table.ts rename to backend/src/plans/paniers/models/action-impact-cateorie-fnv.table.ts index a1b6498c9e..cda3bc21cd 100644 --- a/backend/src/panier/models/action-impact-cateorie-fnv.table.ts +++ b/backend/src/plans/paniers/models/action-impact-cateorie-fnv.table.ts @@ -1,6 +1,6 @@ +import { categorieFNVTable } from '@/domain/shared'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; import { actionImpactTable } from './action-impact.table'; -import { categorieFNVTable } from '../../taxonomie/models/categorie-fnv.table'; export const actionImpactCategorieFNVTable = pgTable( 'action_impact_categorie_fnv', diff --git a/backend/src/panier/models/action-impact-effet-attendu.table.ts b/backend/src/plans/paniers/models/action-impact-effet-attendu.table.ts similarity index 90% rename from backend/src/panier/models/action-impact-effet-attendu.table.ts rename to backend/src/plans/paniers/models/action-impact-effet-attendu.table.ts index 6fa9b9d30f..cb5e8fde2e 100644 --- a/backend/src/panier/models/action-impact-effet-attendu.table.ts +++ b/backend/src/plans/paniers/models/action-impact-effet-attendu.table.ts @@ -1,6 +1,6 @@ +import { effetAttenduTable } from '@/domain/shared'; import { InferSelectModel } from 'drizzle-orm'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; -import { effetAttenduTable } from '../../shared/models/effet-attendu.table'; import { actionImpactTable } from './action-impact.table'; export const actionImpactEffetAttenduTable = pgTable( diff --git a/backend/src/panier/models/action-impact-fourchette-budgetaire.table.ts b/backend/src/plans/paniers/models/action-impact-fourchette-budgetaire.table.ts similarity index 100% rename from backend/src/panier/models/action-impact-fourchette-budgetaire.table.ts rename to backend/src/plans/paniers/models/action-impact-fourchette-budgetaire.table.ts diff --git a/backend/src/panier/models/action-impact-indicateur.table.ts b/backend/src/plans/paniers/models/action-impact-indicateur.table.ts similarity index 88% rename from backend/src/panier/models/action-impact-indicateur.table.ts rename to backend/src/plans/paniers/models/action-impact-indicateur.table.ts index fc44a9a54d..2b12b683e8 100644 --- a/backend/src/panier/models/action-impact-indicateur.table.ts +++ b/backend/src/plans/paniers/models/action-impact-indicateur.table.ts @@ -1,7 +1,7 @@ +import { indicateurDefinitionTable } from '@/domain/indicateurs'; +import { InferSelectModel } from 'drizzle-orm'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; import { actionImpactTable } from './action-impact.table'; -import { indicateurDefinitionTable } from '../../indicateurs/models/indicateur-definition.table'; -import { InferSelectModel } from 'drizzle-orm'; export const actionImpactIndicateurTable = pgTable( 'action_impact_indicateur', diff --git a/backend/src/panier/models/action-impact-panier.table.ts b/backend/src/plans/paniers/models/action-impact-panier.table.ts similarity index 100% rename from backend/src/panier/models/action-impact-panier.table.ts rename to backend/src/plans/paniers/models/action-impact-panier.table.ts diff --git a/backend/src/panier/models/action-impact-partenaire.table.ts b/backend/src/plans/paniers/models/action-impact-partenaire.table.ts similarity index 86% rename from backend/src/panier/models/action-impact-partenaire.table.ts rename to backend/src/plans/paniers/models/action-impact-partenaire.table.ts index 87add19f28..781de1198c 100644 --- a/backend/src/panier/models/action-impact-partenaire.table.ts +++ b/backend/src/plans/paniers/models/action-impact-partenaire.table.ts @@ -1,6 +1,6 @@ import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; -import { panierPartenaireTable } from '../../taxonomie/models/panier-partenaire.table'; import { actionImpactTable } from './action-impact.table'; +import { panierPartenaireTable } from './panier-partenaire.table'; export const actionImpactPartenaireTable = pgTable( 'action_impact_partenaire', diff --git a/backend/src/panier/models/action-impact-sous-thematique.table.ts b/backend/src/plans/paniers/models/action-impact-sous-thematique.table.ts similarity index 90% rename from backend/src/panier/models/action-impact-sous-thematique.table.ts rename to backend/src/plans/paniers/models/action-impact-sous-thematique.table.ts index 71d3ceddbc..f8a07d7bc6 100644 --- a/backend/src/panier/models/action-impact-sous-thematique.table.ts +++ b/backend/src/plans/paniers/models/action-impact-sous-thematique.table.ts @@ -1,6 +1,6 @@ +import { sousThematiqueTable } from '@/domain/shared'; import { InferSelectModel } from 'drizzle-orm'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; -import { sousThematiqueTable } from '../../shared/models/sous-thematique.table'; import { actionImpactTable } from './action-impact.table'; export const actionImpactSousThematiqueTable = pgTable( diff --git a/backend/src/panier/models/action-impact-statut.table.ts b/backend/src/plans/paniers/models/action-impact-statut.table.ts similarity index 100% rename from backend/src/panier/models/action-impact-statut.table.ts rename to backend/src/plans/paniers/models/action-impact-statut.table.ts diff --git a/backend/src/panier/models/action-impact-thematique.table.ts b/backend/src/plans/paniers/models/action-impact-thematique.table.ts similarity index 90% rename from backend/src/panier/models/action-impact-thematique.table.ts rename to backend/src/plans/paniers/models/action-impact-thematique.table.ts index d2a0c061e8..b3771648b4 100644 --- a/backend/src/panier/models/action-impact-thematique.table.ts +++ b/backend/src/plans/paniers/models/action-impact-thematique.table.ts @@ -1,6 +1,6 @@ +import { thematiqueTable } from '@/domain/shared'; import { InferSelectModel } from 'drizzle-orm'; import { integer, pgTable, primaryKey } from 'drizzle-orm/pg-core'; -import { thematiqueTable } from '../../shared/models/thematique.table'; import { actionImpactTable } from './action-impact.table'; export const actionImpactThematiqueTable = pgTable( diff --git a/backend/src/panier/models/action-impact-tier.table.ts b/backend/src/plans/paniers/models/action-impact-tier.table.ts similarity index 100% rename from backend/src/panier/models/action-impact-tier.table.ts rename to backend/src/plans/paniers/models/action-impact-tier.table.ts diff --git a/backend/src/panier/models/action-impact.table.ts b/backend/src/plans/paniers/models/action-impact.table.ts similarity index 92% rename from backend/src/panier/models/action-impact.table.ts rename to backend/src/plans/paniers/models/action-impact.table.ts index 9a4372c55c..778c93d5b7 100644 --- a/backend/src/panier/models/action-impact.table.ts +++ b/backend/src/plans/paniers/models/action-impact.table.ts @@ -1,3 +1,10 @@ +import { + categorieFNVSchema, + CategorieFNVType, + tempsDeMiseEnOeuvreTable, + thematiqueSchema, + ThematiqueType, +} from '@/domain/shared'; import { createZodDto } from '@anatine/zod-nestjs'; import { InferSelectModel } from 'drizzle-orm'; import { @@ -10,16 +17,10 @@ import { } from 'drizzle-orm/pg-core'; import { createSelectSchema } from 'drizzle-zod'; import { z } from 'zod'; -import { lienSchema, lienType } from '../../documents/models/document-lien.dto'; -import { tempsDeMiseEnOeuvreTable } from '../../shared/models/temps-de-mise-en-oeuvre.table'; import { - thematiqueSchema, - ThematiqueType, -} from '../../shared/models/thematique.table'; -import { - categorieFNVSchema, - CategorieFNVType, -} from '../../taxonomie/models/categorie-fnv.table'; + lienSchema, + lienType, +} from '../../../documents/models/document-lien.dto'; import { actionImpactFourchetteBudgetaireTable } from './action-impact-fourchette-budgetaire.table'; import { actionImpactTierTable } from './action-impact-tier.table'; diff --git a/backend/src/taxonomie/models/panier-partenaire.table.ts b/backend/src/plans/paniers/models/panier-partenaire.table.ts similarity index 100% rename from backend/src/taxonomie/models/panier-partenaire.table.ts rename to backend/src/plans/paniers/models/panier-partenaire.table.ts diff --git a/backend/src/panier/models/panier.table.ts b/backend/src/plans/paniers/models/panier.table.ts similarity index 92% rename from backend/src/panier/models/panier.table.ts rename to backend/src/plans/paniers/models/panier.table.ts index a5168c1541..274d34aa8d 100644 --- a/backend/src/panier/models/panier.table.ts +++ b/backend/src/plans/paniers/models/panier.table.ts @@ -1,3 +1,4 @@ +import { collectiviteTable } from '@/domain/collectivites'; import { InferSelectModel, SQL, sql } from 'drizzle-orm'; import { boolean, @@ -7,7 +8,6 @@ import { uuid, } from 'drizzle-orm/pg-core'; import { createSelectSchema } from 'drizzle-zod'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; export const panierTable = pgTable('panier', { id: uuid('id').primaryKey().defaultRandom(), diff --git a/backend/src/referentiels/controllers/referentiels-scoring.e2e-spec.ts b/backend/src/referentiels/controllers/referentiels-scoring.e2e-spec.ts index 023504f9b9..431f7fe40a 100644 --- a/backend/src/referentiels/controllers/referentiels-scoring.e2e-spec.ts +++ b/backend/src/referentiels/controllers/referentiels-scoring.e2e-spec.ts @@ -3,7 +3,7 @@ import { default as request } from 'supertest'; import { getTestApp } from '../../../test/app-utils'; import { getAuthToken } from '../../../test/auth-utils'; import { getCollectiviteIdBySiren } from '../../../test/collectivites-utils'; -import { HttpErrorResponse } from '../../common/models/http-error.response'; +import { HttpErrorResponse } from '../../utils/nest/http-error.response'; import { ActionScoreType } from '../models/action-score.dto'; import { ActionStatutType } from '../models/action-statut.table'; import { ActionType } from '../models/action-type.enum'; diff --git a/backend/src/referentiels/index-domain.ts b/backend/src/referentiels/index-domain.ts new file mode 100644 index 0000000000..b429561207 --- /dev/null +++ b/backend/src/referentiels/index-domain.ts @@ -0,0 +1,4 @@ +// `index-domain.ts` file must only contain exports that are shareable with client-side apps. +// Exports from this file can be imported with `@/domain/*` alias path. + +export * from './models/action-relation.table'; diff --git a/backend/src/referentiels/index.ts b/backend/src/referentiels/index.ts index 9fcfb558d3..81ce45f809 100644 --- a/backend/src/referentiels/index.ts +++ b/backend/src/referentiels/index.ts @@ -1 +1 @@ -export * from './models/action-relation.table'; +export * from './index-domain'; diff --git a/backend/src/referentiels/models/action-commentaire.table.ts b/backend/src/referentiels/models/action-commentaire.table.ts index 82e6ca22b1..5c98b5d376 100644 --- a/backend/src/referentiels/models/action-commentaire.table.ts +++ b/backend/src/referentiels/models/action-commentaire.table.ts @@ -1,4 +1,4 @@ -import { modifiedAt, modifiedBy } from '@/backend/utils'; +import { modifiedAt, modifiedBy } from '@/domain/utils'; import { InferInsertModel, InferSelectModel } from 'drizzle-orm'; import { foreignKey, @@ -9,7 +9,7 @@ import { } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; import { authUsersTable } from '../../auth/models/auth-users.table'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { actionIdVarchar } from './action-definition.table'; import { actionRelationTable } from './action-relation.table'; diff --git a/backend/src/referentiels/models/action-computed-points.table.ts b/backend/src/referentiels/models/action-computed-points.table.ts index e9c40c4612..b60a319ef4 100644 --- a/backend/src/referentiels/models/action-computed-points.table.ts +++ b/backend/src/referentiels/models/action-computed-points.table.ts @@ -1,4 +1,4 @@ -import { modifiedAt } from '@/backend/utils'; +import { modifiedAt } from '@/domain/utils'; import { InferInsertModel, InferSelectModel } from 'drizzle-orm'; import { doublePrecision, pgTable } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; diff --git a/backend/src/referentiels/models/action-definition.table.ts b/backend/src/referentiels/models/action-definition.table.ts index 38d46bc07b..1199cb1677 100644 --- a/backend/src/referentiels/models/action-definition.table.ts +++ b/backend/src/referentiels/models/action-definition.table.ts @@ -1,4 +1,4 @@ -import { modifiedAt } from '@/backend/utils'; +import { modifiedAt } from '@/domain/utils'; import { InferInsertModel, InferSelectModel } from 'drizzle-orm'; import { doublePrecision, diff --git a/backend/src/referentiels/models/action-statut.table.ts b/backend/src/referentiels/models/action-statut.table.ts index 742da7a863..3409611752 100644 --- a/backend/src/referentiels/models/action-statut.table.ts +++ b/backend/src/referentiels/models/action-statut.table.ts @@ -1,4 +1,4 @@ -import { modifiedAt, modifiedBy } from '@/backend/utils'; +import { modifiedAt, modifiedBy } from '@/domain/utils'; import { InferInsertModel, InferSelectModel } from 'drizzle-orm'; import { boolean, @@ -8,7 +8,7 @@ import { pgTable, } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { actionIdReference } from './action-definition.table'; export const avancementEnum = pgEnum('avancement', [ diff --git a/backend/src/referentiels/models/client-scores.table.ts b/backend/src/referentiels/models/client-scores.table.ts index a8fc7aa69a..31dbf20a28 100644 --- a/backend/src/referentiels/models/client-scores.table.ts +++ b/backend/src/referentiels/models/client-scores.table.ts @@ -8,7 +8,7 @@ import { timestamp, } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { referentielEnum } from './referentiel.enum'; export const clientScoresTable = pgTable( diff --git a/backend/src/referentiels/models/get-referentiel-scores.response.ts b/backend/src/referentiels/models/get-referentiel-scores.response.ts index 0e0856274f..e71e5d8a48 100644 --- a/backend/src/referentiels/models/get-referentiel-scores.response.ts +++ b/backend/src/referentiels/models/get-referentiel-scores.response.ts @@ -1,6 +1,6 @@ import { extendApi } from '@anatine/zod-openapi'; import { z } from 'zod'; -import { collectiviteAvecTypeSchema } from '../../collectivites/models/identite-collectivite.dto'; +import { collectiviteAvecTypeSchema } from '../../collectivites/identite-collectivite.dto'; import { ComputeScoreMode } from './compute-scores-mode.enum'; import { referentielActionAvecScoreDtoSchema } from './referentiel-action-avec-score.dto'; import { ReferentielType } from './referentiel.enum'; diff --git a/backend/src/referentiels/models/historique-action-statut.table.ts b/backend/src/referentiels/models/historique-action-statut.table.ts index c91e15e2ec..6daa45fe6a 100644 --- a/backend/src/referentiels/models/historique-action-statut.table.ts +++ b/backend/src/referentiels/models/historique-action-statut.table.ts @@ -7,7 +7,7 @@ import { uuid, } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { historiqueSchema } from '../../personnalisations/models/historique-reponse-choix.table'; import { actionIdReference } from './action-definition.table'; import { avancementEnum } from './action-statut.table'; diff --git a/backend/src/referentiels/models/labellisation-action-audit-state.table.ts b/backend/src/referentiels/models/labellisation-action-audit-state.table.ts index 5b1dba7709..2524ec4ec3 100644 --- a/backend/src/referentiels/models/labellisation-action-audit-state.table.ts +++ b/backend/src/referentiels/models/labellisation-action-audit-state.table.ts @@ -1,4 +1,4 @@ -import { modifiedAt } from '@/backend/utils'; +import { modifiedAt } from '@/domain/utils'; import { sql } from 'drizzle-orm'; import { boolean, @@ -11,7 +11,7 @@ import { uuid, } from 'drizzle-orm/pg-core'; import { authUsersTable } from '../../auth/models/auth-users.table'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { actionIdReference } from './action-definition.table'; import { labellisationAuditTable } from './labellisation-audit.table'; import { labellisationSchema } from './labellisation.schema'; diff --git a/backend/src/referentiels/models/labellisation-audit.table.ts b/backend/src/referentiels/models/labellisation-audit.table.ts index efbb04db9a..039a59a572 100644 --- a/backend/src/referentiels/models/labellisation-audit.table.ts +++ b/backend/src/referentiels/models/labellisation-audit.table.ts @@ -1,4 +1,4 @@ -import { TIMESTAMP_OPTIONS } from '@/backend/utils'; +import { TIMESTAMP_OPTIONS } from '@/domain/utils'; import { InferInsertModel, InferSelectModel, sql } from 'drizzle-orm'; import { boolean, @@ -9,7 +9,7 @@ import { uniqueIndex, } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { labellisationDemandeTable } from './labellisation-demande.table'; import { labellisationSchema } from './labellisation.schema'; import { referentielEnum } from './referentiel.enum'; diff --git a/backend/src/referentiels/models/labellisation-bibliotheque-fichier.table.ts b/backend/src/referentiels/models/labellisation-bibliotheque-fichier.table.ts index c23960665a..93e9f7e3d9 100644 --- a/backend/src/referentiels/models/labellisation-bibliotheque-fichier.table.ts +++ b/backend/src/referentiels/models/labellisation-bibliotheque-fichier.table.ts @@ -7,7 +7,7 @@ import { unique, varchar, } from 'drizzle-orm/pg-core'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { labellisationSchema } from './labellisation.schema'; export const labellisationBibliothequeFichierTable = labellisationSchema.table( diff --git a/backend/src/referentiels/models/labellisation-demande.table.ts b/backend/src/referentiels/models/labellisation-demande.table.ts index e9980da56a..bfa1098ade 100644 --- a/backend/src/referentiels/models/labellisation-demande.table.ts +++ b/backend/src/referentiels/models/labellisation-demande.table.ts @@ -1,4 +1,4 @@ -import { TIMESTAMP_OPTIONS } from '@/backend/utils'; +import { TIMESTAMP_OPTIONS } from '@/domain/utils'; import { boolean, foreignKey, @@ -8,7 +8,7 @@ import { uuid, } from 'drizzle-orm/pg-core'; import { authUsersTable } from '../../auth/models/auth-users.table'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { labellisationEtoileEnum } from './labellisation-etoile.table'; import { labellisationSchema } from './labellisation.schema'; import { referentielEnum } from './referentiel.enum'; diff --git a/backend/src/referentiels/models/labellisation-preuve-base.table.ts b/backend/src/referentiels/models/labellisation-preuve-base.table.ts index 97b1fd808e..3e3244c680 100644 --- a/backend/src/referentiels/models/labellisation-preuve-base.table.ts +++ b/backend/src/referentiels/models/labellisation-preuve-base.table.ts @@ -1,8 +1,8 @@ -import { modifiedAt, modifiedBy } from '@/backend/utils'; +import { modifiedAt, modifiedBy } from '@/domain/utils'; import { sql } from 'drizzle-orm'; import { foreignKey, integer, jsonb, text } from 'drizzle-orm/pg-core'; import { authUsersTable } from '../../auth/models/auth-users.table'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { labellisationBibliothequeFichierTable } from './labellisation-bibliotheque-fichier.table'; import { labellisationSchema } from './labellisation.schema'; diff --git a/backend/src/referentiels/models/referentiel-definition.table.ts b/backend/src/referentiels/models/referentiel-definition.table.ts index b50531c827..7eff77303c 100644 --- a/backend/src/referentiels/models/referentiel-definition.table.ts +++ b/backend/src/referentiels/models/referentiel-definition.table.ts @@ -1,4 +1,4 @@ -import { createdAt, modifiedAt } from '@/backend/utils'; +import { createdAt, modifiedAt } from '@/domain/utils'; import { InferSelectModel } from 'drizzle-orm'; import { pgTable, varchar } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; diff --git a/backend/src/referentiels/models/score-snapshot.table.ts b/backend/src/referentiels/models/score-snapshot.table.ts index c81e7cb31a..74e831211d 100644 --- a/backend/src/referentiels/models/score-snapshot.table.ts +++ b/backend/src/referentiels/models/score-snapshot.table.ts @@ -12,7 +12,7 @@ import { } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; import z from 'zod'; -import { collectiviteTable } from '../../collectivites/models/collectivite.table'; +import { collectiviteTable } from '../../collectivites/shared/models/collectivite.table'; import { getPersonnalitionReponsesResponseSchema } from '../../personnalisations/models/get-personnalisation-reponses.response'; import { createdAt, diff --git a/backend/src/referentiels/referentiels.module.ts b/backend/src/referentiels/referentiels.module.ts index 02e7b7d675..7e0f13c2f6 100644 --- a/backend/src/referentiels/referentiels.module.ts +++ b/backend/src/referentiels/referentiels.module.ts @@ -1,8 +1,6 @@ import { Module } from '@nestjs/common'; import { AuthModule } from '../auth/auth.module'; import { CollectivitesModule } from '../collectivites/collectivites.module'; -import { CommonModule } from '../common/common.module'; -import { ConfigurationModule } from '../config/configuration.module'; import { PersonnalisationsModule } from '../personnalisations/personnalisations.module'; import { SheetModule } from '../utils/google-sheets/sheet.module'; import { ComputeScoreRouter } from './compute-score/compute-score.router'; @@ -20,8 +18,6 @@ import { UpdateActionStatutService } from './update-action-statut/update-action- imports: [ AuthModule, CollectivitesModule, - CommonModule, - ConfigurationModule, SheetModule, PersonnalisationsModule, ], diff --git a/backend/src/referentiels/services/labellisation.service.ts b/backend/src/referentiels/services/labellisation.service.ts index 89fbfca4fe..c2c7ac7385 100644 --- a/backend/src/referentiels/services/labellisation.service.ts +++ b/backend/src/referentiels/services/labellisation.service.ts @@ -1,6 +1,6 @@ +import { DatabaseService } from '@/backend/utils'; import { Injectable, Logger } from '@nestjs/common'; import { and, desc, eq, isNotNull, SQL, SQLWrapper } from 'drizzle-orm'; -import DatabaseService from '../../common/services/database.service'; import { labellisationAuditTable, LabellisationAuditType, diff --git a/backend/src/referentiels/services/referentiels-scoring-snapshots.service.ts b/backend/src/referentiels/services/referentiels-scoring-snapshots.service.ts index 17bd58b4c5..296f0c3f2d 100644 --- a/backend/src/referentiels/services/referentiels-scoring-snapshots.service.ts +++ b/backend/src/referentiels/services/referentiels-scoring-snapshots.service.ts @@ -1,3 +1,6 @@ +import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; +import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; import { BadRequestException, Injectable, @@ -10,10 +13,10 @@ import { and, asc, eq, inArray, sql } from 'drizzle-orm'; import { DateTime } from 'luxon'; import slugify from 'slugify'; import { AuthRole, AuthUser } from '../../auth/models/auth.models'; -import { PgIntegrityConstraintViolation } from '../../common/models/postgresql-error-codes.enum'; -import DatabaseService from '../../common/services/database.service'; -import { getErrorWithCode } from '../../common/services/errors.helper'; import { GetPersonnalisationReponsesResponseType } from '../../personnalisations/models/get-personnalisation-reponses.response'; +import { DatabaseService } from '../../utils/database/database.service'; +import { getErrorWithCode } from '../../utils/nest/errors.utils'; +import { PgIntegrityConstraintViolation } from '../../utils/postgresql-error-codes.enum'; import { GetReferentielScoresResponseType } from '../models/get-referentiel-scores.response'; import { GetScoreSnapshotsRequestType } from '../models/get-score-snapshots.request'; import { @@ -28,9 +31,6 @@ import { scoreSnapshotTable, ScoreSnapshotType, } from '../models/score-snapshot.table'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; -import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; -import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; @Injectable() export default class ReferentielsScoringSnapshotsService { diff --git a/backend/src/referentiels/services/referentiels-scoring.service.spec.ts b/backend/src/referentiels/services/referentiels-scoring.service.spec.ts index 9e26adc9c9..55fe1a87c4 100644 --- a/backend/src/referentiels/services/referentiels-scoring.service.spec.ts +++ b/backend/src/referentiels/services/referentiels-scoring.service.spec.ts @@ -1,19 +1,20 @@ +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; import { Test } from '@nestjs/testing'; import { CollectiviteTypeEnum, IdentiteCollectivite, -} from '../../collectivites/models/identite-collectivite.dto'; +} from '../../collectivites/identite-collectivite.dto'; import CollectivitesService from '../../collectivites/services/collectivites.service'; -import DatabaseService from '../../common/services/database.service'; -import MattermostNotificationService from '../../common/services/mattermost-notification.service'; -import { roundTo } from '../../common/services/number.helper'; -import ConfigurationService from '../../config/configuration.service'; import { GetPersonnalitionConsequencesResponseType } from '../../personnalisations/models/get-personnalisation-consequences.response'; import { GetPersonnalisationReponsesResponseType } from '../../personnalisations/models/get-personnalisation-reponses.response'; import { caePersonnalisationRegles } from '../../personnalisations/models/samples/cae-personnalisation-regles.sample'; import ExpressionParserService from '../../personnalisations/services/expression-parser.service'; import PersonnalisationsService from '../../personnalisations/services/personnalisations-service'; +import ConfigurationService from '../../utils/config/configuration.service'; +import { DatabaseService } from '../../utils/database/database.service'; import SheetService from '../../utils/google-sheets/sheet.service'; +import MattermostNotificationService from '../../utils/mattermost-notification.service'; +import { roundTo } from '../../utils/number.helper'; import { ActionPointScoreType } from '../models/action-point-score.dto'; import { ActionType } from '../models/action-type.enum'; import { GetActionStatutsResponseType } from '../models/get-action-statuts.response'; @@ -26,7 +27,6 @@ import LabellisationService from './labellisation.service'; import ReferentielsScoringSnapshotsService from './referentiels-scoring-snapshots.service'; import ReferentielsScoringService from './referentiels-scoring.service'; import ReferentielsService from './referentiels.service'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; describe('ReferentielsScoringService', () => { let referentielsScoringService: ReferentielsScoringService; diff --git a/backend/src/referentiels/services/referentiels-scoring.service.ts b/backend/src/referentiels/services/referentiels-scoring.service.ts index 1165903de1..b133e2ae5b 100644 --- a/backend/src/referentiels/services/referentiels-scoring.service.ts +++ b/backend/src/referentiels/services/referentiels-scoring.service.ts @@ -1,3 +1,7 @@ +import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; +import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; +import { NiveauAcces } from '@/backend/auth/authorizations/roles/niveau-acces.enum'; import { HttpException, Injectable, @@ -20,18 +24,17 @@ import { chunk, isNil } from 'es-toolkit'; import * as _ from 'lodash'; import { DateTime } from 'luxon'; import { AuthenticatedUser } from '../../auth/models/auth.models'; -import { NiveauAcces } from '@/backend/auth/authorizations/roles/niveau-acces.enum'; -import { CollectiviteAvecType } from '../../collectivites/models/identite-collectivite.dto'; +import { CollectiviteAvecType } from '../../collectivites/identite-collectivite.dto'; import CollectivitesService from '../../collectivites/services/collectivites.service'; -import DatabaseService from '../../common/services/database.service'; -import { getErrorMessage } from '../../common/services/errors.helper'; -import MattermostNotificationService from '../../common/services/mattermost-notification.service'; -import { roundTo } from '../../common/services/number.helper'; -import { sleep } from '../../common/services/sleep.helper'; -import ConfigurationService from '../../config/configuration.service'; import { GetPersonnalitionConsequencesResponseType } from '../../personnalisations/models/get-personnalisation-consequences.response'; import ExpressionParserService from '../../personnalisations/services/expression-parser.service'; import PersonnalisationsService from '../../personnalisations/services/personnalisations-service'; +import ConfigurationService from '../../utils/config/configuration.service'; +import { DatabaseService } from '../../utils/database/database.service'; +import MattermostNotificationService from '../../utils/mattermost-notification.service'; +import { getErrorMessage } from '../../utils/nest/errors.utils'; +import { roundTo } from '../../utils/number.helper'; +import { sleep } from '../../utils/sleep.utils'; import { actionCommentaireTable } from '../models/action-commentaire.table'; import { ActionPointScoreType, @@ -76,9 +79,6 @@ import { ScoreJalon } from '../models/score-jalon.enum'; import LabellisationService from './labellisation.service'; import ReferentielsScoringSnapshotsService from './referentiels-scoring-snapshots.service'; import ReferentielsService from './referentiels.service'; -import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; -import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; @Injectable() export default class ReferentielsScoringService { diff --git a/backend/src/referentiels/services/referentiels.service.spec.ts b/backend/src/referentiels/services/referentiels.service.spec.ts index 67b5ffa745..9b13db9e58 100644 --- a/backend/src/referentiels/services/referentiels.service.spec.ts +++ b/backend/src/referentiels/services/referentiels.service.spec.ts @@ -1,7 +1,7 @@ +import { DatabaseService } from '@/backend/utils'; import { Test } from '@nestjs/testing'; -import DatabaseService from '../../common/services/database.service'; -import ConfigurationService from '../../config/configuration.service'; import ExpressionParserService from '../../personnalisations/services/expression-parser.service'; +import ConfigurationService from '../../utils/config/configuration.service'; import SheetService from '../../utils/google-sheets/sheet.service'; import { ActionDefinitionAvecParentType } from '../models/action-definition.table'; import { CreateActionOrigineType } from '../models/action-origine.table'; diff --git a/backend/src/referentiels/services/referentiels.service.ts b/backend/src/referentiels/services/referentiels.service.ts index 4fe42b5c58..70dec62743 100644 --- a/backend/src/referentiels/services/referentiels.service.ts +++ b/backend/src/referentiels/services/referentiels.service.ts @@ -1,3 +1,4 @@ +import { DatabaseService } from '@/backend/utils'; import { HttpException, HttpStatus, @@ -10,9 +11,6 @@ import { and, asc, eq, getTableColumns, inArray, sql } from 'drizzle-orm'; import { isNil } from 'es-toolkit'; import * as _ from 'lodash'; import * as semver from 'semver'; -import DatabaseService from '../../common/services/database.service'; -import { getErrorMessage } from '../../common/services/errors.helper'; -import ConfigurationService from '../../config/configuration.service'; import { CreatePersonnalisationRegleType, personnalisationRegleTable, @@ -22,7 +20,9 @@ import { PersonnalisationType, } from '../../personnalisations/models/personnalisation.table'; import ExpressionParserService from '../../personnalisations/services/expression-parser.service'; +import ConfigurationService from '../../utils/config/configuration.service'; import SheetService from '../../utils/google-sheets/sheet.service'; +import { getErrorMessage } from '../../utils/nest/errors.utils'; import { actionDefinitionTagTable, CreateActionDefinitionTagType, diff --git a/backend/src/referentiels/update-action-statut/update-action-statut.router.e2e-spec.ts b/backend/src/referentiels/update-action-statut/update-action-statut.router.e2e-spec.ts index 2b4b73dc2a..e783e091d5 100644 --- a/backend/src/referentiels/update-action-statut/update-action-statut.router.e2e-spec.ts +++ b/backend/src/referentiels/update-action-statut/update-action-statut.router.e2e-spec.ts @@ -26,7 +26,6 @@ describe('UpdateActionStatutRouter', () => { const caller = router.createCaller({ user: null }); const input: Input = { - referentielId: ReferentielType.CAE, actionStatut: { collectiviteId: 1, actionId: 'cae_1.1.1.2', @@ -47,7 +46,6 @@ describe('UpdateActionStatutRouter', () => { const caller = router.createCaller({ user: yoloDodoUser }); const input: Input = { - referentielId: ReferentielType.CAE, actionStatut: { collectiviteId: rhoneAggloCollectiviteId, actionId: 'cae_1.1.1.2', @@ -68,7 +66,6 @@ describe('UpdateActionStatutRouter', () => { const caller = router.createCaller({ user: yoloDodoUser }); const input: Input = { - referentielId: ReferentielType.CAE, actionStatut: { collectiviteId: 1, actionId: 'cae_1.1.1.11', @@ -91,7 +88,6 @@ describe('UpdateActionStatutRouter', () => { const caller = router.createCaller({ user: yoloDodoUser }); const input: Input = { - referentielId: ReferentielType.CAE, actionStatut: { collectiviteId: 1, actionId: 'cae_1.1.1.1.2', @@ -140,7 +136,6 @@ describe('UpdateActionStatutRouter', () => { // Restore the previous state const actionNonFaite: Input = { - referentielId: ReferentielType.CAE, actionStatut: { collectiviteId: 1, actionId: 'cae_1.1.1.1.2', diff --git a/backend/src/referentiels/update-action-statut/update-action-statut.service.ts b/backend/src/referentiels/update-action-statut/update-action-statut.service.ts index 3034ae3c37..28a92cd0e0 100644 --- a/backend/src/referentiels/update-action-statut/update-action-statut.service.ts +++ b/backend/src/referentiels/update-action-statut/update-action-statut.service.ts @@ -1,11 +1,14 @@ +import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; +import { PermissionService } from '@/backend/auth/authorizations/permission.service'; +import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; +import { DatabaseService } from '@/backend/utils'; import { Injectable, Logger, NotFoundException } from '@nestjs/common'; import { sql } from 'drizzle-orm'; import { PostgresError } from 'postgres'; import z from 'zod'; import { AuthenticatedUser } from '../../auth/models/auth.models'; -import { PgIntegrityConstraintViolation } from '../../common/models/postgresql-error-codes.enum'; -import DatabaseService from '../../common/services/database.service'; -import { getErrorWithCode } from '../../common/services/errors.helper'; +import { getErrorWithCode } from '../../utils/nest/errors.utils'; +import { PgIntegrityConstraintViolation } from '../../utils/postgresql-error-codes.enum'; import { actionStatutTable, createActionStatutSchema, @@ -14,9 +17,6 @@ import { ComputeScoreMode } from '../models/compute-scores-mode.enum'; import { GetReferentielScoresRequestType } from '../models/get-referentiel-scores.request'; import ReferentielsScoringService from '../services/referentiels-scoring.service'; import ReferentielsService from '../services/referentiels.service'; -import { PermissionService } from '@/backend/auth/authorizations/permission.service'; -import { PermissionOperation } from '@/backend/auth/authorizations/permission-operation.enum'; -import { ResourceType } from '@/backend/auth/authorizations/resource-type.enum'; export const upsertActionStatutRequestSchema = z.object({ actionStatut: createActionStatutSchema, diff --git a/backend/src/shared/index-domain.ts b/backend/src/shared/index-domain.ts new file mode 100644 index 0000000000..50fb079a2c --- /dev/null +++ b/backend/src/shared/index-domain.ts @@ -0,0 +1,9 @@ +// `index-domain.ts` file must only contain exports that are shareable with client-side apps. +// Exports from this file can be imported with `@/domain/*` alias path. + +export * from './models/banatic-competence.table'; +export * from './models/categorie-fnv.table'; +export * from './models/effet-attendu.table'; +export * from './models/sous-thematique.table'; +export * from './models/temps-de-mise-en-oeuvre.table'; +export * from './models/thematique.table'; diff --git a/backend/src/shared/index.ts b/backend/src/shared/index.ts index 3363d19e75..81ce45f809 100644 --- a/backend/src/shared/index.ts +++ b/backend/src/shared/index.ts @@ -1,4 +1 @@ -export * from './models/effet-attendu.table'; -export * from './models/sous-thematique.table'; -export * from './models/temps-de-mise-en-oeuvre.table'; -export * from './models/thematique.table'; +export * from './index-domain'; diff --git a/backend/src/taxonomie/models/banatic-competence.table.ts b/backend/src/shared/models/banatic-competence.table.ts similarity index 100% rename from backend/src/taxonomie/models/banatic-competence.table.ts rename to backend/src/shared/models/banatic-competence.table.ts diff --git a/backend/src/taxonomie/models/categorie-fnv.table.ts b/backend/src/shared/models/categorie-fnv.table.ts similarity index 100% rename from backend/src/taxonomie/models/categorie-fnv.table.ts rename to backend/src/shared/models/categorie-fnv.table.ts diff --git a/backend/src/taxonomie/taxonomie.module.ts b/backend/src/taxonomie/taxonomie.module.ts deleted file mode 100644 index 0d70fd5f62..0000000000 --- a/backend/src/taxonomie/taxonomie.module.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Module } from '@nestjs/common'; -import { AuthModule } from '../auth/auth.module'; -import { CollectivitesModule } from '../collectivites/collectivites.module'; -import { CommonModule } from '../common/common.module'; -import { ConfigurationModule } from '../config/configuration.module'; -import TagService from '../taxonomie/services/tag.service'; -import { - GetCategoriesByCollectiviteRouter -} from '../taxonomie/routers/get-categories-by-collectivite.router'; - -@Module({ - imports: [ - ConfigurationModule, - CommonModule, - AuthModule, - CollectivitesModule, - ], - providers: [ - TagService, - GetCategoriesByCollectiviteRouter - ], - exports: [TagService, GetCategoriesByCollectiviteRouter], - controllers: [], -}) -export class TaxonomieModule {} - diff --git a/backend/src/config/configuration.model.ts b/backend/src/utils/config/configuration.model.ts similarity index 100% rename from backend/src/config/configuration.model.ts rename to backend/src/utils/config/configuration.model.ts diff --git a/backend/src/config/configuration.module.ts b/backend/src/utils/config/configuration.module.ts similarity index 81% rename from backend/src/config/configuration.module.ts rename to backend/src/utils/config/configuration.module.ts index f6a34547f9..440337dc0e 100644 --- a/backend/src/config/configuration.module.ts +++ b/backend/src/utils/config/configuration.module.ts @@ -1,7 +1,8 @@ -import { Module } from '@nestjs/common'; +import { Global, Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import ConfigurationService from './configuration.service'; +@Global() @Module({ imports: [ConfigModule.forRoot()], providers: [ConfigurationService], diff --git a/backend/src/config/configuration.service.ts b/backend/src/utils/config/configuration.service.ts similarity index 100% rename from backend/src/config/configuration.service.ts rename to backend/src/utils/config/configuration.service.ts diff --git a/backend/src/config/configuration.ts b/backend/src/utils/config/configuration.ts similarity index 100% rename from backend/src/config/configuration.ts rename to backend/src/utils/config/configuration.ts diff --git a/backend/src/utils/drizzle/conflict.utils.ts b/backend/src/utils/database/conflict.utils.ts similarity index 100% rename from backend/src/utils/drizzle/conflict.utils.ts rename to backend/src/utils/database/conflict.utils.ts diff --git a/backend/src/utils/database/database.module.ts b/backend/src/utils/database/database.module.ts new file mode 100644 index 0000000000..cb10e22ac7 --- /dev/null +++ b/backend/src/utils/database/database.module.ts @@ -0,0 +1,10 @@ +import { Global, Module } from '@nestjs/common'; +import { DatabaseService } from './database.service'; +import SupabaseService from './supabase.service'; + +@Global() +@Module({ + providers: [DatabaseService, SupabaseService], + exports: [DatabaseService, SupabaseService], +}) +export class DatabaseModule {} diff --git a/backend/src/common/services/database.service.ts b/backend/src/utils/database/database.service.ts similarity index 93% rename from backend/src/common/services/database.service.ts rename to backend/src/utils/database/database.service.ts index 591ba41e59..94a125585b 100644 --- a/backend/src/common/services/database.service.ts +++ b/backend/src/utils/database/database.service.ts @@ -3,10 +3,10 @@ import { Injectable, Logger, OnApplicationShutdown } from '@nestjs/common'; import { sql } from 'drizzle-orm'; import { drizzle } from 'drizzle-orm/postgres-js'; import { default as postgres } from 'postgres'; -import ConfigurationService from '../../config/configuration.service'; +import ConfigurationService from '../config/configuration.service'; @Injectable() -export default class DatabaseService implements OnApplicationShutdown { +export class DatabaseService implements OnApplicationShutdown { private readonly logger = new Logger(DatabaseService.name); private readonly client = postgres( diff --git a/backend/src/common/services/supabase.service.ts b/backend/src/utils/database/supabase.service.ts similarity index 89% rename from backend/src/common/services/supabase.service.ts rename to backend/src/utils/database/supabase.service.ts index 36fb13a7e9..1646953aa7 100644 --- a/backend/src/common/services/supabase.service.ts +++ b/backend/src/utils/database/supabase.service.ts @@ -1,6 +1,6 @@ import { Injectable, Logger } from '@nestjs/common'; import { createClient } from '@supabase/supabase-js'; -import ConfigurationService from '../../config/configuration.service'; +import ConfigurationService from '../config/configuration.service'; @Injectable() export default class SupabaseService { diff --git a/backend/src/common/services/xlsx.helper.ts b/backend/src/utils/excel/excel.utils.ts similarity index 100% rename from backend/src/common/services/xlsx.helper.ts rename to backend/src/utils/excel/excel.utils.ts diff --git a/backend/src/common/services/gcloud.helper.ts b/backend/src/utils/google-sheets/gcloud.helper.ts similarity index 81% rename from backend/src/common/services/gcloud.helper.ts rename to backend/src/utils/google-sheets/gcloud.helper.ts index a4d39c8ae4..bfae96e5dc 100644 --- a/backend/src/common/services/gcloud.helper.ts +++ b/backend/src/utils/google-sheets/gcloud.helper.ts @@ -3,7 +3,7 @@ import * as fs from 'fs'; const logger = new Logger('gcloud.helper'); -export const initApplicationCredentials = () => { +export const initGoogleCloudCredentials = () => { if ( process.env.GCLOUD_SERVICE_ACCOUNT_KEY && !process.env.GOOGLE_APPLICATION_CREDENTIALS @@ -15,13 +15,12 @@ export const initApplicationCredentials = () => { let credentialsJson = process.env.GCLOUD_SERVICE_ACCOUNT_KEY; if (!credentialsJson.includes('{')) { // Assume it's a base64 encoded string - credentialsJson = Buffer.from(credentialsJson, 'base64').toString('utf-8'); + credentialsJson = Buffer.from(credentialsJson, 'base64').toString( + 'utf-8' + ); } - - fs.writeFileSync( - serviceAccountFile, - credentialsJson - ); + + fs.writeFileSync(serviceAccountFile, credentialsJson); process.env.GOOGLE_APPLICATION_CREDENTIALS = serviceAccountFile; } }; diff --git a/backend/src/utils/google-sheets/sheet.service.ts b/backend/src/utils/google-sheets/sheet.service.ts index 24275920c8..7ff70fc816 100644 --- a/backend/src/utils/google-sheets/sheet.service.ts +++ b/backend/src/utils/google-sheets/sheet.service.ts @@ -6,8 +6,8 @@ import * as auth from 'google-auth-library'; import { drive_v3, google, sheets_v4 } from 'googleapis'; import * as _ from 'lodash'; import { z } from 'zod'; -import { initApplicationCredentials } from '../../common/services/gcloud.helper'; -import { getPropertyPaths } from '../../common/services/zod.helper'; +import { getPropertyPaths } from '../zod.utils'; +import { initGoogleCloudCredentials } from './gcloud.helper'; import { SheetValueInputOption, SheetValueRenderOption, @@ -43,7 +43,7 @@ export default class SheetService { | auth.Impersonated > { if (!this.authClient) { - initApplicationCredentials(); + initGoogleCloudCredentials(); this.authClient = await google.auth.getClient({ scopes: [ 'https://www.googleapis.com/auth/spreadsheets', diff --git a/backend/src/utils/index-domain.ts b/backend/src/utils/index-domain.ts new file mode 100644 index 0000000000..b8a8135053 --- /dev/null +++ b/backend/src/utils/index-domain.ts @@ -0,0 +1,8 @@ +// `index-domain.ts` file must only contain exports that are shareable with client-side apps. +// Exports from this file can be imported with `@/domain/*` alias path. + +export * from './column.utils'; +export * from './enum.utils'; +export * from './pagination.schema'; + +export type { AppRouter } from './trpc/trpc.router'; diff --git a/backend/src/utils/index.ts b/backend/src/utils/index.ts index 60ddf66f13..ac2e13e9a5 100644 --- a/backend/src/utils/index.ts +++ b/backend/src/utils/index.ts @@ -1,5 +1,2 @@ -export * from './column.utils'; -export * from './enum.utils'; -export * from './pagination.schema'; - -export type { AppRouter } from './trpc/trpc.router'; +export * from './database/database.service'; +export * from './index-domain'; diff --git a/backend/src/common/services/mattermost-notification.service.ts b/backend/src/utils/mattermost-notification.service.ts similarity index 91% rename from backend/src/common/services/mattermost-notification.service.ts rename to backend/src/utils/mattermost-notification.service.ts index 8456a4b338..90f7b125a3 100644 --- a/backend/src/common/services/mattermost-notification.service.ts +++ b/backend/src/utils/mattermost-notification.service.ts @@ -1,6 +1,6 @@ import { Injectable, Logger } from '@nestjs/common'; -import ConfigurationService from '../../config/configuration.service'; -import { getErrorMessage } from './errors.helper'; +import ConfigurationService from './config/configuration.service'; +import { getErrorMessage } from './nest/errors.utils'; @Injectable() export default class MattermostNotificationService { diff --git a/backend/src/common/models/modified-since.enum.ts b/backend/src/utils/modified-since.enum.ts similarity index 100% rename from backend/src/common/models/modified-since.enum.ts rename to backend/src/utils/modified-since.enum.ts diff --git a/backend/src/common/filters/all-exceptions.filter.ts b/backend/src/utils/nest/all-exceptions.filter.ts similarity index 92% rename from backend/src/common/filters/all-exceptions.filter.ts rename to backend/src/utils/nest/all-exceptions.filter.ts index 58c97fd2dc..3dadb4e499 100644 --- a/backend/src/common/filters/all-exceptions.filter.ts +++ b/backend/src/utils/nest/all-exceptions.filter.ts @@ -3,8 +3,8 @@ import { ArgumentsHost, Catch, HttpException, Logger } from '@nestjs/common'; import { BaseExceptionFilter } from '@nestjs/core'; import { SentryExceptionCaptured } from '@sentry/nestjs'; import { Request, Response } from 'express'; -import { HttpErrorResponse } from '../models/http-error.response'; -import { getErrorWithCode } from '../services/errors.helper'; +import { getErrorWithCode } from './errors.utils'; +import { HttpErrorResponse } from './http-error.response'; export const getHttpErrorResponse = (exception: unknown): HttpErrorResponse => { const errorWithCode = getErrorWithCode(exception); diff --git a/backend/src/common/services/errors.helper.ts b/backend/src/utils/nest/errors.utils.ts similarity index 100% rename from backend/src/common/services/errors.helper.ts rename to backend/src/utils/nest/errors.utils.ts diff --git a/backend/src/common/models/http-error.response.ts b/backend/src/utils/nest/http-error.response.ts similarity index 100% rename from backend/src/common/models/http-error.response.ts rename to backend/src/utils/nest/http-error.response.ts diff --git a/backend/src/common/services/number.helper.spec.ts b/backend/src/utils/number.helper.spec.ts similarity index 100% rename from backend/src/common/services/number.helper.spec.ts rename to backend/src/utils/number.helper.spec.ts diff --git a/backend/src/common/services/number.helper.ts b/backend/src/utils/number.helper.ts similarity index 100% rename from backend/src/common/services/number.helper.ts rename to backend/src/utils/number.helper.ts diff --git a/backend/src/common/models/postgresql-error-codes.enum.ts b/backend/src/utils/postgresql-error-codes.enum.ts similarity index 100% rename from backend/src/common/models/postgresql-error-codes.enum.ts rename to backend/src/utils/postgresql-error-codes.enum.ts diff --git a/backend/src/common/services/sentry.service.ts b/backend/src/utils/sentry-init.ts similarity index 100% rename from backend/src/common/services/sentry.service.ts rename to backend/src/utils/sentry-init.ts diff --git a/backend/src/common/services/sleep.helper.ts b/backend/src/utils/sleep.utils.ts similarity index 100% rename from backend/src/common/services/sleep.helper.ts rename to backend/src/utils/sleep.utils.ts diff --git a/backend/src/utils/trpc/trpc.router.ts b/backend/src/utils/trpc/trpc.router.ts index 95e935720a..09ee01c91c 100644 --- a/backend/src/utils/trpc/trpc.router.ts +++ b/backend/src/utils/trpc/trpc.router.ts @@ -3,15 +3,15 @@ import { CountByStatutRouter } from '@/backend/plans/fiches/count-by-statut/coun import { FicheActionEtapeRouter } from '@/backend/plans/fiches/fiche-action-etape/fiche-action-etape.router'; import { INestApplication, Injectable, Logger } from '@nestjs/common'; import { createExpressMiddleware } from '@trpc/server/adapters/express'; +import { ListCategoriesRouter } from '../../collectivites/handle-categories/list-categories.router'; import { CollectiviteMembresRouter } from '../../collectivites/membres/membres.router'; import { PersonnesRouter } from '../../collectivites/personnes.router'; -import SupabaseService from '../../common/services/supabase.service'; import { IndicateurFiltreRouter } from '../../indicateurs/indicateur-filtre/indicateur-filtre.router'; import { TrajectoiresRouter } from '../../indicateurs/routers/trajectoires.router'; import { ComputeScoreRouter } from '../../referentiels/compute-score/compute-score.router'; import { ScoreSnapshotsRouter } from '../../referentiels/snapshots/score-snaphots.router'; import { UpdateActionStatutRouter } from '../../referentiels/update-action-statut/update-action-statut.router'; -import { GetCategoriesByCollectiviteRouter } from '../../taxonomie/routers/get-categories-by-collectivite.router'; +import SupabaseService from '../database/supabase.service'; import { createContext, TrpcService } from './trpc.service'; @Injectable() @@ -23,7 +23,7 @@ export class TrpcRouter { private readonly supabase: SupabaseService, private readonly trajectoiresRouter: TrajectoiresRouter, private readonly countByStatutRouter: CountByStatutRouter, - private readonly getCategoriesByCollectiviteRouter: GetCategoriesByCollectiviteRouter, + private readonly getCategoriesByCollectiviteRouter: ListCategoriesRouter, private readonly personnes: PersonnesRouter, private readonly ficheActionEtapeRouter: FicheActionEtapeRouter, private readonly indicateurFiltreRouter: IndicateurFiltreRouter, @@ -37,7 +37,7 @@ export class TrpcRouter { appRouter = this.trpc.router({ indicateurs: { trajectoires: this.trajectoiresRouter.router, - filtre: this.indicateurFiltreRouter.router, + list: this.indicateurFiltreRouter.router.list, }, plans: { fiches: this.trpc.mergeRouters( @@ -49,8 +49,6 @@ export class TrpcRouter { collectivites: { personnes: this.personnes.router, membres: this.membresRouter.router, - }, - tags: { categories: this.getCategoriesByCollectiviteRouter.router, }, referentiels: { diff --git a/backend/src/utils/utils.module.ts b/backend/src/utils/utils.module.ts new file mode 100644 index 0000000000..f8e13ea85c --- /dev/null +++ b/backend/src/utils/utils.module.ts @@ -0,0 +1,11 @@ +import { Global, Module } from '@nestjs/common'; +import MattermostNotificationService from './mattermost-notification.service'; +import { VersionController } from './version/version.controller'; + +@Global() +@Module({ + providers: [MattermostNotificationService], + exports: [MattermostNotificationService], + controllers: [VersionController], +}) +export class UtilsModule {} diff --git a/backend/src/common/services/zod.helper.ts b/backend/src/utils/zod.utils.ts similarity index 100% rename from backend/src/common/services/zod.helper.ts rename to backend/src/utils/zod.utils.ts diff --git a/backend/test/app-utils.ts b/backend/test/app-utils.ts index 4b7fae3fd9..9f42d5c913 100644 --- a/backend/test/app-utils.ts +++ b/backend/test/app-utils.ts @@ -2,7 +2,7 @@ import { ZodValidationPipe } from '@anatine/zod-nestjs/src/lib/zod-validation-pi import { INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; import { AppModule } from '../src/app.module'; -import DatabaseService from '../src/common/services/database.service'; +import { DatabaseService } from '../src/utils/database/database.service'; import { TrpcRouter } from '../src/utils/trpc/trpc.router'; export const getTestApp = async (): Promise => { diff --git a/packages/api/src/indicateurs/actions/indicateur.fetch.ts b/packages/api/src/indicateurs/actions/indicateur.fetch.ts index d8af51bee9..9b955622e8 100644 --- a/packages/api/src/indicateurs/actions/indicateur.fetch.ts +++ b/packages/api/src/indicateurs/actions/indicateur.fetch.ts @@ -19,7 +19,7 @@ import { ValeurComparaison, ValeurComparaisonLigne, } from '../domain/valeur.schema'; -import { Thematique } from '@/backend/shared'; +import { Thematique } from '@/domain/shared'; // cas spécial pour cet indicateur TODO: utiliser un champ distinct dans les markdowns plutôt que cet ID "en dur" const ID_COMPACITE_FORMES_URBAINES = 'cae_9'; diff --git a/packages/api/src/indicateurs/actions/indicateur.save.test.ts b/packages/api/src/indicateurs/actions/indicateur.save.test.ts index e40a28db5d..39c8188328 100644 --- a/packages/api/src/indicateurs/actions/indicateur.save.test.ts +++ b/packages/api/src/indicateurs/actions/indicateur.save.test.ts @@ -1,5 +1,5 @@ -import { TagInsert } from '@/backend/collectivites'; -import { Thematique } from '@/backend/shared'; +import { TagInsert } from '@/domain/collectivites'; +import { Thematique } from '@/domain/shared'; import { beforeAll, describe, expect, test } from 'vitest'; import { Personne } from '../../collectivites/shared/domain/personne.schema'; import { FicheResume } from '../../plan-actions/domain/fiche-action.schema'; diff --git a/packages/api/src/indicateurs/actions/indicateur.save.ts b/packages/api/src/indicateurs/actions/indicateur.save.ts index 178b5e891f..28f3b506c8 100644 --- a/packages/api/src/indicateurs/actions/indicateur.save.ts +++ b/packages/api/src/indicateurs/actions/indicateur.save.ts @@ -1,5 +1,5 @@ -import { Tag, TagInsert } from '@/backend/collectivites'; -import { Thematique } from '@/backend/shared'; +import { Tag, TagInsert } from '@/domain/collectivites'; +import { Thematique } from '@/domain/shared'; import { isNil } from 'es-toolkit/predicate'; import { objectToSnake } from 'ts-case-convert'; import { Personne } from '../../collectivites/shared/domain/personne.schema'; diff --git a/packages/api/src/indicateurs/domain/definition.schema.ts b/packages/api/src/indicateurs/domain/definition.schema.ts index f2cdd4c153..c0832cc909 100644 --- a/packages/api/src/indicateurs/domain/definition.schema.ts +++ b/packages/api/src/indicateurs/domain/definition.schema.ts @@ -1,4 +1,4 @@ -import { thematiqueSchema } from '@/backend/shared'; +import { thematiqueSchema } from '@/domain/shared'; import { z } from 'zod'; import { actionSchema } from '../../referentiel/domain/action.schema'; import { categorieSchema } from './categorie.schema'; diff --git a/packages/api/src/indicateurs/domain/fetch-options.schema.ts b/packages/api/src/indicateurs/domain/fetch-options.schema.ts index 7240ff6151..6106407c09 100644 --- a/packages/api/src/indicateurs/domain/fetch-options.schema.ts +++ b/packages/api/src/indicateurs/domain/fetch-options.schema.ts @@ -1,4 +1,4 @@ -import { getPaginationSchema } from '@/backend/utils'; +import { getPaginationSchema } from '@/domain/utils'; import { z } from 'zod'; import { filtreRessourceLieesSchema } from '../../collectivites/shared/domain/filtre-ressource-liees.schema'; diff --git a/packages/api/src/plan-actions/domain/fiche-action.schema.ts b/packages/api/src/plan-actions/domain/fiche-action.schema.ts index 8aa181715b..0144343604 100644 --- a/packages/api/src/plan-actions/domain/fiche-action.schema.ts +++ b/packages/api/src/plan-actions/domain/fiche-action.schema.ts @@ -1,8 +1,8 @@ import { personneSchema } from '@/api/collectivites'; import { indicateurListItemSchema } from '@/api/indicateurs/domain'; import { actionSchema } from '@/api/referentiel'; -import { authorSchema } from '@/backend/auth'; -import { tagSchema } from '@/backend/collectivites'; +import { authorSchema } from '@/domain/auth'; +import { tagSchema } from '@/domain/collectivites'; import { axeSchema, ciblesEnumSchema, @@ -10,13 +10,13 @@ import { participationCitoyenneEnumSchema, prioriteEnumSchema, statutsEnumSchema, -} from '@/backend/plans/fiches'; +} from '@/domain/plans/fiches'; import { effetAttenduSchema, sousThematiqueSchema, tempsDeMiseEnOeuvreSchema, thematiqueSchema, -} from '@/backend/shared'; +} from '@/domain/shared'; import { z } from 'zod'; export const ficheActionSchema = z.object({ diff --git a/packages/api/src/plan-actions/fiche-resumes.list/domain/fetch-options.schema.ts b/packages/api/src/plan-actions/fiche-resumes.list/domain/fetch-options.schema.ts index 42892fee0a..a26e11fb3c 100644 --- a/packages/api/src/plan-actions/fiche-resumes.list/domain/fetch-options.schema.ts +++ b/packages/api/src/plan-actions/fiche-resumes.list/domain/fetch-options.schema.ts @@ -2,8 +2,8 @@ import { ciblesEnumSchema, prioriteEnumSchema, statutsEnumSchema, -} from '@/backend/plans/fiches'; -import { getPaginationSchema } from '@/backend/utils'; +} from '@/domain/plans/fiches'; +import { getPaginationSchema } from '@/domain/utils'; import { z } from 'zod'; import { filtreRessourceLieesSchema } from '../../../collectivites/shared/domain/filtre-ressource-liees.schema'; diff --git a/packages/api/src/plan-actions/plan-actions.list/data-access/plan-actions.fetch.ts b/packages/api/src/plan-actions/plan-actions.list/data-access/plan-actions.fetch.ts index 5eb39ea6ed..872d38fbc0 100644 --- a/packages/api/src/plan-actions/plan-actions.list/data-access/plan-actions.fetch.ts +++ b/packages/api/src/plan-actions/plan-actions.list/data-access/plan-actions.fetch.ts @@ -1,5 +1,5 @@ import { DBClient } from '@/api/typeUtils'; -import { Axe, PlanActionType } from '@/backend/plans/fiches'; +import { Axe, PlanActionType } from '@/domain/plans/fiches'; import { objectToCamel } from 'ts-case-convert'; import { FetchOptions, diff --git a/packages/api/src/plan-actions/plan-actions.list/domain/fetch-options.schema.ts b/packages/api/src/plan-actions/plan-actions.list/domain/fetch-options.schema.ts index 00d6108d12..1442d87d95 100644 --- a/packages/api/src/plan-actions/plan-actions.list/domain/fetch-options.schema.ts +++ b/packages/api/src/plan-actions/plan-actions.list/domain/fetch-options.schema.ts @@ -1,4 +1,4 @@ -import { getPaginationSchema } from '@/backend/utils'; +import { getPaginationSchema } from '@/domain/utils'; import { z } from 'zod'; import { filtreRessourceLieesSchema } from '../../../collectivites/shared/domain/filtre-ressource-liees.schema'; diff --git a/packages/api/src/shared/actions/tag.fetch.ts b/packages/api/src/shared/actions/tag.fetch.ts index d6af0f2abe..f984bc740d 100644 --- a/packages/api/src/shared/actions/tag.fetch.ts +++ b/packages/api/src/shared/actions/tag.fetch.ts @@ -1,4 +1,4 @@ -import { Tag, TagType } from '@/backend/collectivites'; +import { Tag, TagType } from '@/domain/collectivites'; import { objectToCamel } from 'ts-case-convert'; import { DBClient } from '../../typeUtils'; diff --git a/packages/api/src/shared/actions/tag.save.test.ts b/packages/api/src/shared/actions/tag.save.test.ts index f9c2df5894..792302263f 100644 --- a/packages/api/src/shared/actions/tag.save.test.ts +++ b/packages/api/src/shared/actions/tag.save.test.ts @@ -1,4 +1,4 @@ -import { TagInsert } from '@/backend/collectivites'; +import { TagInsert } from '@/domain/collectivites'; import { beforeAll, expect, test } from 'vitest'; import { signIn, signOut } from '../../tests/auth'; import { supabase } from '../../tests/supabase'; diff --git a/packages/api/src/shared/actions/tag.save.ts b/packages/api/src/shared/actions/tag.save.ts index 8b4e60acb6..f1b283af1e 100644 --- a/packages/api/src/shared/actions/tag.save.ts +++ b/packages/api/src/shared/actions/tag.save.ts @@ -1,4 +1,4 @@ -import { Tag, TagInsert, TagType } from '@/backend/collectivites'; +import { Tag, TagInsert, TagType } from '@/domain/collectivites'; import { objectToCamel, objectToSnake } from 'ts-case-convert'; import { DBClient } from '../../typeUtils'; diff --git a/packages/api/src/shared/actions/thematique.fetch.ts b/packages/api/src/shared/actions/thematique.fetch.ts index d1802304dc..ebd19c06b9 100644 --- a/packages/api/src/shared/actions/thematique.fetch.ts +++ b/packages/api/src/shared/actions/thematique.fetch.ts @@ -1,4 +1,4 @@ -import { Thematique } from '@/backend/shared'; +import { Thematique } from '@/domain/shared'; import { DBClient } from '../../typeUtils'; /** diff --git a/packages/api/src/utils/trpc/client.tsx b/packages/api/src/utils/trpc/client.tsx index 28998038e8..12457d49bd 100644 --- a/packages/api/src/utils/trpc/client.tsx +++ b/packages/api/src/utils/trpc/client.tsx @@ -14,7 +14,7 @@ import { makeQueryClient } from './query-client'; // By using `import type` you ensure that the reference will be stripped at compile-time, meaning you don't inadvertently import server-side code into your client. // For more information, see the Typescript docs: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export // eslint-disable-next-line @nx/enforce-module-boundaries -import type { AppRouter } from '@/backend/utils/trpc/trpc.router'; +import type { AppRouter } from '@/domain/utils'; import { getAuthHeaders } from '../authTokens'; export type RouterInput = inferRouterInputs; diff --git a/tsconfig.base.json b/tsconfig.base.json index 87e8ddda9c..49c70ccaca 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -24,6 +24,7 @@ "@/api/*": ["./packages/api/src/*"], "@/app/*": ["./app.territoiresentransitions.react/src/*"], "@/auth/*": ["./packages/auth/*"], + "@/domain/*": ["./backend/src/*/index-domain.ts"], "@/backend/*": ["./backend/src/*"], "@/backend/test": ["./backend/test/index.ts"], "@/panier/*": ["./packages/panier/*"],