Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Backend domain architecture #3502

Merged
merged 10 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ storybook-static
**/package.json

# gcloud credentials
backend/src/common/services/keyfile.json
keyfile.json
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? {},
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Financeur, 'id' | 'ficheId' | 'financeurTagId'>;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EffetAttendu } from '@/backend/shared';
import { EffetAttendu } from '@/domain/shared';
import { SelectFilter, SelectMultipleProps } from '@/ui';
import { useEffetsAttendus } from './useEffetsAttendus';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TempsDeMiseEnOeuvre } from '@/backend/shared';
import { TempsDeMiseEnOeuvre } from '@/domain/shared';
import { Select, SelectProps } from '@/ui';
import { useMiseEnOeuvre } from './useMiseEnOeuvre';

Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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<SelectMultipleProps, 'values' | 'onChange' | 'options'> & {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<SelectProps, 'values' | 'onChange' | 'options'> & {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<SelectMultipleProps, 'values' | 'onChange' | 'options'> & {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<SelectProps, 'values' | 'onChange' | 'options'> & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ParticipationCitoyenne,
Priorite,
Statut,
} from '@/backend/plans/fiches';
} from '@/domain/plans/fiches';

type Options<T extends string> = {
value: T;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Loading
Loading