= {
cdtn_id: "cdtn_id",
@@ -135,6 +142,8 @@ describe("mapContributionToDocument", () => {
document: {
content:
"Quand une femme tombe enceinte et décide de partir en congé maternité, cette dernière a droit à des indemnités journalières de sécurité sociale venant indemniser la période durant laquelle elle ne peut plus travailler. Certaines conventions collectives prévoient également un maintien de salaire versé par l’employeur. Si le maintien est à 100%, dans ce cas, les deux mécanismes ne sont pas cumulables. Si le maintien est inférieur à 100%, le pourcentage de rémunération restant est indemnisé par les indemnités de Sécurité sociale.
Maintien de salaire Les salariées ayant au moins une année de présence continue dans l'entreprise à la date de l'accouchement ont droit à un maintien de salaire, après déduction des indemnités de Sécurité sociale, qui leur assure leur salaire habituel, et ce pendant une durée de 36 jours (en principe 18 jours avant l’accouchement, 18 jours après).
Pour les salariées cadres âgées de moins de 25 ans et les autres salariées âgées de moins de 22 ans à la date de l'accouchement, la période de 36 jours est augmentée de 2 jours par enfant à charge. L'indemnité complémentaire ne pourra pas être versée plus de 46 jours. Est considéré comme enfant à charge tout enfant à charge de la salariée au sens de la législation des prestations familiales et âgé de moins de 15 ans à la date de l'accouchement.
A noter : Les périodes de suspension du contrat de travail (maladie, etc.) sont prises en compte pour l'ancienneté.
Si la salariée ne respecte pas la condition d’ancienneté, elle n’a pas droit au maintien de salaire versé par l’employeur mais aura potentiellement droit aux indemnités journalières de Sécurité sociale si elle respecte ses conditions d’octroi.
Indemnités de Sécurité sociale Conditions d’ouverture des droits aux indemnités journalières de Sécurité sociale
Pour être indemnisée, la salariée doit remplir les conditions suivantes :
avoir :
soit travaillé au moins 150 heures au cours des 3 mois civils ou des 90 jours précédant l'arrêt,
soit travaillé au moins 600 heures au cours des 12 mois précédant l’arrêt de travail,
soit cotisé, au cours des 6 mois civils précédant l'arrêt, sur la base d'une rémunération au moins égale à 1 015 fois le montant du Smic horaire fixé au début de cette période,
soit cotisé au cours des 12 mois civils précédant l’arrêt, sur la base d'une rémunération au moins égale à 2030 fois le montant du Smic horaire fixé en début de période.
Exemple : le congé a débuté le 1er juillet 2023 pour une date présumée d'accouchement au 1er septembre 2023.
Le droit aux indemnités journalières est ouvert si :
La salariée était déjà affiliée à la Sécurité sociale avant novembre 2022 ;
et a travaillé soit au moins 150 heures entre le 1er avril 2023 et le 30 juin 2023, soit au moins 600 heures entre le 1er juillet 2022 et le 30 juin 2023, soit a cotisé entre le 1er janvier 2023 et le 30 juin 2023 sur la base d'une rémunération au moins égale à 11 439,05 €, soit a cotisé entre le 1er juillet 2022 et le 30 juin 2023 sur la base d’une rémunération au moins égale à 22 878,1 €.
Montant
La CPAM verse des indemnités journalières, dont le montant est fixé selon les étapes de calcul suivantes :
Calcul du salaire journalier de base : somme des 3 derniers salaires bruts perçus avant la date d'interruption du travail, divisé par 91,25.
Montant maximal du salaire journalier de base : le salaire pris en compte ne peut pas dépasser le plafond mensuel de la sécurité sociale en vigueur lors du dernier jour du mois qui précède l'arrêt (soit 3 666 € par mois en 2023, ou 3 428 € en 2022).
Taux forfaitaire appliqué par la CPAM : la CPAM retire à ce salaire journalier de base un taux forfaitaire de 21 %.
Montant minimal et montant maximal des indemnités journalières : le montant ne peut pas être inférieur à 10,24 € ni supérieur à 95,22 € par jour.
Versement
Les indemnités journalières sont versées tous les 14 jours.
",
+ contentWithGlossary:
+ "Quand une femme tombe enceinte et décide de partir en congé maternité, cette dernière a droit à des indemnités journalières de sécurité sociale venant indemniser la période durant laquelle elle ne peut plus travailler. Certaines conventions collectives prévoient également un maintien de salaire versé par l’employeur. Si le maintien est à 100%, dans ce cas, les deux mécanismes ne sont pas cumulables. Si le maintien est inférieur à 100%, le pourcentage de rémunération restant est indemnisé par les indemnités de Sécurité sociale.
Maintien de salaire Les salariées ayant au moins une année de présence continue dans l'entreprise à la date de l'accouchement ont droit à un maintien de salaire, après déduction des indemnités de Sécurité sociale, qui leur assure leur salaire habituel, et ce pendant une durée de 36 jours (en principe 18 jours avant l’accouchement, 18 jours après).
Pour les salariées cadres âgées de moins de 25 ans et les autres salariées âgées de moins de 22 ans à la date de l'accouchement, la période de 36 jours est augmentée de 2 jours par enfant à charge. L'indemnité complémentaire ne pourra pas être versée plus de 46 jours. Est considéré comme enfant à charge tout enfant à charge de la salariée au sens de la législation des prestations familiales et âgé de moins de 15 ans à la date de l'accouchement.
A noter : Les périodes de suspension du contrat de travail (maladie, etc.) sont prises en compte pour l'ancienneté.
Si la salariée ne respecte pas la condition d’ancienneté, elle n’a pas droit au maintien de salaire versé par l’employeur mais aura potentiellement droit aux indemnités journalières de Sécurité sociale si elle respecte ses conditions d’octroi.
Indemnités de Sécurité sociale Conditions d’ouverture des droits aux indemnités journalières de Sécurité sociale
Pour être indemnisée, la salariée doit remplir les conditions suivantes :
avoir :
soit travaillé au moins 150 heures au cours des 3 mois civils ou des 90 jours précédant l'arrêt,
soit travaillé au moins 600 heures au cours des 12 mois précédant l’arrêt de travail,
soit cotisé, au cours des 6 mois civils précédant l'arrêt, sur la base d'une rémunération au moins égale à 1 015 fois le montant du Smic horaire fixé au début de cette période,
soit cotisé au cours des 12 mois civils précédant l’arrêt, sur la base d'une rémunération au moins égale à 2030 fois le montant du Smic horaire fixé en début de période.
Exemple : le congé a débuté le 1er juillet 2023 pour une date présumée d'accouchement au 1er septembre 2023.
Le droit aux indemnités journalières est ouvert si :
La salariée était déjà affiliée à la Sécurité sociale avant novembre 2022 ;
et a travaillé soit au moins 150 heures entre le 1er avril 2023 et le 30 juin 2023, soit au moins 600 heures entre le 1er juillet 2022 et le 30 juin 2023, soit a cotisé entre le 1er janvier 2023 et le 30 juin 2023 sur la base d'une rémunération au moins égale à 11 439,05 €, soit a cotisé entre le 1er juillet 2022 et le 30 juin 2023 sur la base d’une rémunération au moins égale à 22 878,1 €.
Montant
La CPAM verse des indemnités journalières, dont le montant est fixé selon les étapes de calcul suivantes :
Calcul du salaire journalier de base : somme des 3 derniers salaires bruts perçus avant la date d'interruption du travail, divisé par 91,25.
Montant maximal du salaire journalier de base : le salaire pris en compte ne peut pas dépasser le plafond mensuel de la sécurité sociale en vigueur lors du dernier jour du mois qui précède l'arrêt (soit 3 666 € par mois en 2023, ou 3 428 € en 2022).
Taux forfaitaire appliqué par la CPAM : la CPAM retire à ce salaire journalier de base un taux forfaitaire de 21 %.
Montant minimal et montant maximal des indemnités journalières : le montant ne peut pas être inférieur à 10,24 € ni supérieur à 95,22 € par jour.
Versement
Les indemnités journalières sont versées tous les 14 jours.
",
description:
"Quand une femme tombe enceinte et décide de partir en congé maternité, cette dernière a droit à des indemnités journalières de sécurité sociale venant indemniser la période durant laquelle elle ne peut plus travailler.",
contentType: "ANSWER",
From cda1c3d53477c1ccc01ac880be8b8e47d1eb3200 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Tue, 4 Jun 2024 09:34:47 +0200
Subject: [PATCH 09/40] fix: ui
---
shared/types/src/elastic/editorial-content.ts | 9 ++++++---
targets/frontend/src/pages/glossary/index.tsx | 3 +++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/shared/types/src/elastic/editorial-content.ts b/shared/types/src/elastic/editorial-content.ts
index 2f25ef428..3191ce1b4 100644
--- a/shared/types/src/elastic/editorial-content.ts
+++ b/shared/types/src/elastic/editorial-content.ts
@@ -2,7 +2,10 @@ import { EditorialContentDoc } from "../hasura";
import { KeysToCamelCase } from "../utility";
import { DocumentElasticWithSource } from "./common";
-export type EditorialContentElasticDocument = DocumentElasticWithSource<
- KeysToCamelCase,
- "information"
+export type EditorialContentElasticDocument = Omit<
+ DocumentElasticWithSource<
+ KeysToCamelCase,
+ "information"
+ >,
+ "introWithGlossary"
>;
diff --git a/targets/frontend/src/pages/glossary/index.tsx b/targets/frontend/src/pages/glossary/index.tsx
index 6e7e24727..a4295a3bd 100644
--- a/targets/frontend/src/pages/glossary/index.tsx
+++ b/targets/frontend/src/pages/glossary/index.tsx
@@ -172,6 +172,7 @@ const AddATermButton = () => (
);
const SynchronizeButton = () => {
+ const [isDisabled, setIsDisabled] = useState(false);
const onClick = async () => {
const result = await fetch(`/api/glossary`, {
method: "POST",
@@ -184,6 +185,7 @@ const SynchronizeButton = () => {
return;
}
alert("Le lexique est en cours de synchronisation");
+ setIsDisabled(true);
};
return (
{
color="primary"
style={{ marginLeft: "1rem" }}
onClick={onClick}
+ disabled={isDisabled}
>
Synchroniser le lexique
From abd5023d1b09db306f2099f3785b7cc125f4f75d Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Tue, 4 Jun 2024 11:18:11 +0200
Subject: [PATCH 10/40] fix: variable
---
.kontinuous/env/dev/templates/export.configmap.yaml | 1 -
.kontinuous/templates/alert.cronjob.yaml | 5 ++---
README.md | 3 +--
targets/export-elasticsearch/src/ingester/ingest.ts | 10 +++-------
.../src/workers/ingester-preprod.ts | 3 +--
.../export-elasticsearch/src/workers/ingester-prod.ts | 3 +--
6 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/.kontinuous/env/dev/templates/export.configmap.yaml b/.kontinuous/env/dev/templates/export.configmap.yaml
index 5c9fccd99..f754b09f4 100644
--- a/.kontinuous/env/dev/templates/export.configmap.yaml
+++ b/.kontinuous/env/dev/templates/export.configmap.yaml
@@ -7,7 +7,6 @@ data:
NLP_URL: "https://serving-ml-preprod.ovh.fabrique.social.gouv.fr"
NODE_ENV: "production"
LOG_LEVEL: "info"
- GLOSSARY_PREPROD_DISABLE: "true"
NLP_PREPROD_DISABLE: "true"
BUCKET_DEFAULT_FOLDER: "default"
BUCKET_DRAFT_FOLDER: "draft"
diff --git a/.kontinuous/templates/alert.cronjob.yaml b/.kontinuous/templates/alert.cronjob.yaml
index 4a35e158a..147fe293f 100644
--- a/.kontinuous/templates/alert.cronjob.yaml
+++ b/.kontinuous/templates/alert.cronjob.yaml
@@ -6,6 +6,5 @@ spec:
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 3
- schedule: 30 1 * * *
- jobTemplate:
- {{- include "job.alert" . | nindent 4 }}
+ schedule: 30 2 * * *
+ jobTemplate: { { - include "job.alert" . | nindent 4 } }
diff --git a/README.md b/README.md
index 02fc9df08..cba2cd7f3 100644
--- a/README.md
+++ b/README.md
@@ -148,7 +148,7 @@ docker-compose up -d hasura minio elasticsearch createbuckets
#### 5. Run ingester in development mode
```sh
-GLOSSARY_PREPROD_DISABLE=true DISABLE_LIMIT_EXPORT=true DISABLE_AGREEMENTS=true DISABLE_SITEMAP=true NLP_URL=https://serving-ml-preprod.ovh.fabrique.social.gouv.fr HASURA_GRAPHQL_ENDPOINT="http://localhost:8080/v1/graphql" HASURA_GRAPHQL_ADMIN_SECRET="admin1" ELASTICSEARCH_URL_PREPROD="http://localhost:9200" ELASTICSEARCH_URL_PROD="http://localhost:9200" SITEMAP_DESTINATION_FOLDER="sitemap" SITEMAP_NAME="sitemap.xml" SITEMAP_ENDPOINT="http://localhost:3001/api/sitemap" AGREEMENTS_DESTINATION_FOLDER="agreements" AGREEMENTS_DESTINATION_NAME="index.json" BUCKET_DEFAULT_FOLDER="default" BUCKET_DRAFT_FOLDER="draft" BUCKET_PUBLISHED_FOLDER= BUCKET_PREVIEW_FOLDER="preview" BUCKET_ACCESS_KEY="MINIO_ACCESS_KEY" BUCKET_ENDPOINT=http://localhost:9000 BUCKET_NAME="cdtn" BUCKET_SECRET_KEY="MINIO_SECRET_KEY" BUCKET_REGION="us-east-1" CDTN_ADMIN_ENDPOINT="http://localhost:8080/v1/graphql" ELASTICSEARCH_INDEX_PREPROD="cdtn-v2" ELASTICSEARCH_INDEX_PROD="cdtn-v2" FETCH_PAGE_SIZE=1000 FETCH_JOB_CONCURRENCY=5 yarn workspace export-elasticsearch dev
+DISABLE_LIMIT_EXPORT=true DISABLE_AGREEMENTS=true DISABLE_SITEMAP=true NLP_URL=https://serving-ml-preprod.ovh.fabrique.social.gouv.fr HASURA_GRAPHQL_ENDPOINT="http://localhost:8080/v1/graphql" HASURA_GRAPHQL_ADMIN_SECRET="admin1" ELASTICSEARCH_URL_PREPROD="http://localhost:9200" ELASTICSEARCH_URL_PROD="http://localhost:9200" SITEMAP_DESTINATION_FOLDER="sitemap" SITEMAP_NAME="sitemap.xml" SITEMAP_ENDPOINT="http://localhost:3001/api/sitemap" AGREEMENTS_DESTINATION_FOLDER="agreements" AGREEMENTS_DESTINATION_NAME="index.json" BUCKET_DEFAULT_FOLDER="default" BUCKET_DRAFT_FOLDER="draft" BUCKET_PUBLISHED_FOLDER= BUCKET_PREVIEW_FOLDER="preview" BUCKET_ACCESS_KEY="MINIO_ACCESS_KEY" BUCKET_ENDPOINT=http://localhost:9000 BUCKET_NAME="cdtn" BUCKET_SECRET_KEY="MINIO_SECRET_KEY" BUCKET_REGION="us-east-1" CDTN_ADMIN_ENDPOINT="http://localhost:8080/v1/graphql" ELASTICSEARCH_INDEX_PREPROD="cdtn-v2" ELASTICSEARCH_INDEX_PROD="cdtn-v2" FETCH_PAGE_SIZE=1000 FETCH_JOB_CONCURRENCY=5 yarn workspace export-elasticsearch dev
```
- `DISABLE_LIMIT_EXPORT` is used to disable the limit to run two export in less than one hour
@@ -156,7 +156,6 @@ GLOSSARY_PREPROD_DISABLE=true DISABLE_LIMIT_EXPORT=true DISABLE_AGREEMENTS=true
- `DISABLE_COPY` is used to disable copy between two containers
- `DISABLE_SITEMAP` is used to disable copy of the sitemap
- `DISABLE_AGREEMENTS` is used to disable copy of the agreements
-- `GLOSSARY_PREPROD_DISABLE` is used to disable glossary to gain time.
> **Note**: You can remove `NLP_URL` from your environment variables if you don't want to use the NLP service and gain time during the process of ingester elasticsearch.
diff --git a/targets/export-elasticsearch/src/ingester/ingest.ts b/targets/export-elasticsearch/src/ingester/ingest.ts
index 401c7e00b..dd6e12831 100644
--- a/targets/export-elasticsearch/src/ingester/ingest.ts
+++ b/targets/export-elasticsearch/src/ingester/ingest.ts
@@ -63,8 +63,7 @@ export async function ingest(
nlpUrl: string | undefined,
suggestIndexName: string | undefined,
bufferSize: number | undefined,
- suggestFile: string | undefined,
- disableGlossary: boolean | undefined
+ suggestFile: string | undefined
) {
context.provide();
process.env.NLP_URL = nlpUrl; //pour setter la variable d'environment du package elasticsearch...
@@ -79,8 +78,7 @@ export async function ingest(
nlpUrl,
suggestIndexName,
bufferSize,
- suggestFile,
- disableGlossary
+ suggestFile
);
}
@@ -95,8 +93,7 @@ async function runIngester(
nlpUrl: string | undefined,
suggestIndexName: string | undefined,
bufferSize: number | undefined,
- suggestFile: string | undefined,
- disableGlossary: boolean | undefined
+ suggestFile: string | undefined
) {
const ES_INDEX_PREFIX = esIndexPrefix || "cdtn";
@@ -119,7 +116,6 @@ async function runIngester(
context.set("suggestIndexName", suggestIndexName);
context.set("bufferSize", bufferSize);
context.set("suggestFile", suggestFile);
- context.set("disableGlossary", disableGlossary);
context.set("nlpUrl", nlpUrl);
const ts = Date.now();
logger.info(`Using cdtn elasticsearch ${ELASTICSEARCH_URL}`);
diff --git a/targets/export-elasticsearch/src/workers/ingester-preprod.ts b/targets/export-elasticsearch/src/workers/ingester-preprod.ts
index dd8d487db..5b59872eb 100644
--- a/targets/export-elasticsearch/src/workers/ingester-preprod.ts
+++ b/targets/export-elasticsearch/src/workers/ingester-preprod.ts
@@ -17,8 +17,7 @@ const ingester = async (): Promise => {
process.env.NLP_PREPROD_DISABLE ? undefined : process.env.NLP_URL,
undefined,
undefined,
- undefined,
- process.env.GLOSSARY_PREPROD_DISABLE === "true"
+ undefined
);
resolve("Export elasticsearch completed successfully");
} catch (error: unknown) {
diff --git a/targets/export-elasticsearch/src/workers/ingester-prod.ts b/targets/export-elasticsearch/src/workers/ingester-prod.ts
index 76159d274..c533eb5d3 100644
--- a/targets/export-elasticsearch/src/workers/ingester-prod.ts
+++ b/targets/export-elasticsearch/src/workers/ingester-prod.ts
@@ -17,8 +17,7 @@ const ingester = async (): Promise => {
process.env.NLP_URL,
undefined,
undefined,
- undefined,
- false
+ undefined
);
resolve("Export elasticsearch completed successfully");
} catch (error: unknown) {
From ffa2bd3780048b52e458d3dff3bad481e8670f86 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Tue, 4 Jun 2024 11:33:21 +0200
Subject: [PATCH 11/40] fix: variable
---
targets/export-elasticsearch/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/targets/export-elasticsearch/package.json b/targets/export-elasticsearch/package.json
index f62084b5c..55de1b0e0 100644
--- a/targets/export-elasticsearch/package.json
+++ b/targets/export-elasticsearch/package.json
@@ -19,7 +19,7 @@
"build:watch": "tsc -w -p tsconfig.json",
"build:swc": "swc ./src -d build",
"build:swc:watch": "swc ./src -d build -w",
- "run:ingester": "curl -X POST -H \"Content-Type: application/json\" -d '{\"environment\": \"preproduction\", \"userId\": \"3d6dddc4-e117-4772-9288-cd8a608693e4\"}' http://localhost:8787/export",
+ "run:ingester": "curl -X POST -H \"Content-Type: application/json\" -d '{\"environment\": \"preproduction\", \"userId\": \"d8b11bd2-dd16-4632-b5de-0e7021faadeb\"}' http://localhost:8787/export",
"lint": "npx eslint ./src --ext .ts",
"type-check": "tsc --noEmit"
},
From 54336da729b2badd46f34950e7b11b70dc3ba6af Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Tue, 4 Jun 2024 11:47:42 +0200
Subject: [PATCH 12/40] fix: variable
---
.kontinuous/env/dev/values.yaml | 15 ---------------
.kontinuous/env/prod/values.yaml | 8 ++++----
.kontinuous/values.yaml | 6 +++---
3 files changed, 7 insertions(+), 22 deletions(-)
diff --git a/.kontinuous/env/dev/values.yaml b/.kontinuous/env/dev/values.yaml
index c84451be2..01842dae1 100644
--- a/.kontinuous/env/dev/values.yaml
+++ b/.kontinuous/env/dev/values.yaml
@@ -26,27 +26,12 @@ hasura:
- secretRef:
name: hasura
replicas: 2
- # Retirer le commentaire des lignes ci-dessous pour utiliser l'export dans une branche dev /!\ Penser à remettre le commentaire avant de merger la branche dans master
- # resources:
- # limits:
- # cpu: "2000m"
- # memory: "4Gi"
- # requests:
- # cpu: "1000m"
- # memory: "1Gi"
export:
env:
- name: "BRANCH_NAME_SLUG"
value: "{{.Values.global.branchSlug32}}"
resources:
- # Pour exporter les données avec le glossaire et les vecteurs, il faut modifier les valeurs des ressources comme ceci:
- # limits:
- # cpu: "2000m"
- # memory: "4Gi"
- # requests:
- # cpu: "1000m"
- # memory: "1Gi"
limits:
cpu: "1000m"
memory: "1024Mi"
diff --git a/.kontinuous/env/prod/values.yaml b/.kontinuous/env/prod/values.yaml
index 22f389be2..490364b2e 100644
--- a/.kontinuous/env/prod/values.yaml
+++ b/.kontinuous/env/prod/values.yaml
@@ -15,11 +15,11 @@ www:
value: https://cdtn-admin.fabrique.social.gouv.fr
resources:
limits:
- cpu: "200m"
- memory: "512Mi"
+ cpu: "500m"
+ memory: "1Gi"
requests:
- cpu: "100m"
- memory: "256Mi"
+ cpu: "250m"
+ memory: "512Mi"
export:
replicas: 1
diff --git a/.kontinuous/values.yaml b/.kontinuous/values.yaml
index c8e6dd053..e21c24977 100644
--- a/.kontinuous/values.yaml
+++ b/.kontinuous/values.yaml
@@ -59,11 +59,11 @@ www:
value: https://www-{{.Values.global.host}}
resources:
limits:
+ cpu: "200m"
+ memory: "512Mi"
+ requests:
cpu: "100m"
memory: "256Mi"
- requests:
- cpu: "50m"
- memory: "128Mi"
replicas: 1
securityContext:
fsGroup: 1000
From 4d6707125f9b777f10378b5e7cfcdaefcceabd3b Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Tue, 4 Jun 2024 11:50:07 +0200
Subject: [PATCH 13/40] fix: variable
---
.kontinuous/env/dev/values.yaml | 8 --------
.kontinuous/env/prod/values.yaml | 6 +++---
.kontinuous/values.yaml | 4 ++--
3 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/.kontinuous/env/dev/values.yaml b/.kontinuous/env/dev/values.yaml
index 01842dae1..edba2986c 100644
--- a/.kontinuous/env/dev/values.yaml
+++ b/.kontinuous/env/dev/values.yaml
@@ -25,19 +25,11 @@ hasura:
name: hasura
- secretRef:
name: hasura
- replicas: 2
export:
env:
- name: "BRANCH_NAME_SLUG"
value: "{{.Values.global.branchSlug32}}"
- resources:
- limits:
- cpu: "1000m"
- memory: "1024Mi"
- requests:
- cpu: "1000m"
- memory: "896Mi"
pg:
~chart: pg
diff --git a/.kontinuous/env/prod/values.yaml b/.kontinuous/env/prod/values.yaml
index 490364b2e..d1df38fd2 100644
--- a/.kontinuous/env/prod/values.yaml
+++ b/.kontinuous/env/prod/values.yaml
@@ -15,8 +15,8 @@ www:
value: https://cdtn-admin.fabrique.social.gouv.fr
resources:
limits:
- cpu: "500m"
- memory: "1Gi"
+ cpu: "1000m"
+ memory: "2Gi"
requests:
cpu: "250m"
memory: "512Mi"
@@ -29,7 +29,7 @@ export:
memory: "4096Mi"
requests:
cpu: "1000m"
- memory: "896Mi"
+ memory: "512Mi"
hasura:
replicas: 2
diff --git a/.kontinuous/values.yaml b/.kontinuous/values.yaml
index e21c24977..0d110b687 100644
--- a/.kontinuous/values.yaml
+++ b/.kontinuous/values.yaml
@@ -59,8 +59,8 @@ www:
value: https://www-{{.Values.global.host}}
resources:
limits:
- cpu: "200m"
- memory: "512Mi"
+ cpu: "500m"
+ memory: "1Gi"
requests:
cpu: "100m"
memory: "256Mi"
From ba90d329783c4763e1426bbaf76ce32f32adc7da Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Wed, 5 Jun 2024 11:44:51 +0200
Subject: [PATCH 14/40] fix: replace uuid
---
.kontinuous/sql/post-restore.sql | 2 +-
targets/export-elasticsearch/package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.kontinuous/sql/post-restore.sql b/.kontinuous/sql/post-restore.sql
index 751fe8a44..a5655e6f8 100644
--- a/.kontinuous/sql/post-restore.sql
+++ b/.kontinuous/sql/post-restore.sql
@@ -19,7 +19,7 @@ VALUES (
'Administrateur',
'super',
TRUE,
- 'd8b11bd2-dd16-4632-b5de-0e7021faadeb'
+ '8babda41-6001-4665-96f5-c430fddb0c53'
);
-- Remove all data from audit tables
diff --git a/targets/export-elasticsearch/package.json b/targets/export-elasticsearch/package.json
index 51f32ca72..be03869bd 100644
--- a/targets/export-elasticsearch/package.json
+++ b/targets/export-elasticsearch/package.json
@@ -19,7 +19,7 @@
"build:watch": "tsc -w -p tsconfig.json",
"build:swc": "swc ./src -d build",
"build:swc:watch": "swc ./src -d build -w",
- "run:ingester": "curl -X POST -H \"Content-Type: application/json\" -d '{\"environment\": \"preproduction\", \"userId\": \"d8b11bd2-dd16-4632-b5de-0e7021faadeb\"}' http://localhost:8787/export",
+ "run:ingester": "curl -X POST -H \"Content-Type: application/json\" -d '{\"environment\": \"preproduction\", \"userId\": \"8babda41-6001-4665-96f5-c430fddb0c53\"}' http://localhost:8787/export",
"lint": "npx eslint ./src --ext .ts",
"type-check": "tsc --noEmit"
},
From 942637bfc9ee860154102e16884290ebfc361c98 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Wed, 5 Jun 2024 12:10:40 +0200
Subject: [PATCH 15/40] fix: formattage
---
.kontinuous/templates/alert.cronjob.yaml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.kontinuous/templates/alert.cronjob.yaml b/.kontinuous/templates/alert.cronjob.yaml
index 147fe293f..b18225abe 100644
--- a/.kontinuous/templates/alert.cronjob.yaml
+++ b/.kontinuous/templates/alert.cronjob.yaml
@@ -7,4 +7,5 @@ spec:
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 3
schedule: 30 2 * * *
- jobTemplate: { { - include "job.alert" . | nindent 4 } }
+ jobTemplate:
+ {{- include "job.alert" . | nindent 4 }}
From c7ce7777a3fc3d216e191786442f6b17e43f84ff Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Wed, 5 Jun 2024 16:08:21 +0200
Subject: [PATCH 16/40] fix: alert-cli
---
.kontinuous/env/prod/values.yaml | 7 -------
.kontinuous/values.yaml | 27 +++------------------------
2 files changed, 3 insertions(+), 31 deletions(-)
diff --git a/.kontinuous/env/prod/values.yaml b/.kontinuous/env/prod/values.yaml
index fda6a63c1..2d3c522f7 100644
--- a/.kontinuous/env/prod/values.yaml
+++ b/.kontinuous/env/prod/values.yaml
@@ -36,13 +36,6 @@ export:
hasura:
autoscale:
enabled: true
- resources:
- limits:
- cpu: "2000m"
- memory: "4Gi"
- requests:
- cpu: "1000m"
- memory: "1Gi"
envFrom:
- secretRef:
name: pg-app
diff --git a/.kontinuous/values.yaml b/.kontinuous/values.yaml
index 0d110b687..f452de127 100644
--- a/.kontinuous/values.yaml
+++ b/.kontinuous/values.yaml
@@ -57,18 +57,13 @@ www:
env:
- name: NEXTAUTH_URL
value: https://www-{{.Values.global.host}}
- resources:
- limits:
- cpu: "500m"
- memory: "1Gi"
- requests:
- cpu: "100m"
- memory: "256Mi"
- replicas: 1
securityContext:
fsGroup: 1000
runAsUser: 1000
runAsGroup: 1000
+ annotations:
+ vpa.socialgouv.io/min-cpu: "500m"
+ vpa.socialgouv.io/min-memory: "1Gi"
export:
~chart: app
@@ -85,14 +80,6 @@ export:
name: export-elasticsearch
- secretRef:
name: s3
- resources:
- limits:
- cpu: "100m"
- memory: 256Mi
- requests:
- cpu: "50m"
- memory: 128Mi
- replicas: 1
securityContext:
fsGroup: 1000
runAsUser: 1000
@@ -111,14 +98,6 @@ hasura:
name: hasura
- secretRef:
name: hasura
- replicas: 2
- resources:
- limits:
- cpu: "2000m"
- memory: "4Gi"
- requests:
- cpu: "50m"
- memory: 650Mi
securityContext:
fsGroup: 1001
runAsUser: 1001
From c88a9298f9261f15b8af29f47e507182caf4f43e Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Wed, 5 Jun 2024 16:30:13 +0200
Subject: [PATCH 17/40] empty
From b45b1388fcd7eaef0ab337bc675a05b587b37c06 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Wed, 5 Jun 2024 17:04:36 +0200
Subject: [PATCH 18/40] fix: glossary
---
.../utils/src/glossary/addGlossaryContent.ts | 11 +-
.../documents/api/documents.service.ts | 118 ++++++++++--------
...updateEditorialContentDocumentsGlossary.ts | 46 ++++---
3 files changed, 94 insertions(+), 81 deletions(-)
diff --git a/shared/utils/src/glossary/addGlossaryContent.ts b/shared/utils/src/glossary/addGlossaryContent.ts
index ea6bc86cc..2a424f035 100644
--- a/shared/utils/src/glossary/addGlossaryContent.ts
+++ b/shared/utils/src/glossary/addGlossaryContent.ts
@@ -24,12 +24,11 @@ export const addGlossaryContent = (
return insertWebComponentGlossary(content, glossaryTerms);
};
-export function addGlossaryContentToMarkdown(
+export async function addGlossaryContentToMarkdown(
glossary: Glossary,
markdown: string
-): string {
- return addGlossaryContent(
- glossary,
- markdownProcessor.processSync(markdown).contents as string
- );
+): Promise {
+ const content = (await markdownProcessor.process(markdown))
+ .contents as string;
+ return addGlossaryContent(glossary, content);
}
diff --git a/targets/frontend/src/modules/documents/api/documents.service.ts b/targets/frontend/src/modules/documents/api/documents.service.ts
index 8e4609c17..30a863241 100644
--- a/targets/frontend/src/modules/documents/api/documents.service.ts
+++ b/targets/frontend/src/modules/documents/api/documents.service.ts
@@ -47,6 +47,10 @@ export class DocumentsService {
document?: HasuraDocument
): Promise> {
const glossary = await fetchGlossary();
+ const introWithGlossary = await addGlossaryContentToMarkdown(
+ glossary,
+ data.intro ?? ""
+ );
return {
cdtn_id: document?.cdtn_id ?? generateCdtnId(data.title),
initial_id: data.id ?? generateInitialId(),
@@ -63,10 +67,7 @@ export class DocumentsService {
? format(new Date(data.updatedAt), "dd/MM/yyyy")
: undefined,
intro: data.intro,
- introWithGlossary: addGlossaryContentToMarkdown(
- glossary,
- data.intro ?? ""
- ),
+ introWithGlossary,
description: data.description,
sectionDisplayMode: data.sectionDisplayMode,
dismissalProcess: data.dismissalProcess,
@@ -78,59 +79,66 @@ export class DocumentsService {
},
]
: undefined,
- contents: data.contents.map(
- ({ name, title, blocks, references, referenceLabel }) => {
- return {
- name,
- title,
- blocks: blocks.map((block) => {
- return {
- type: block.type,
- ...(block.type === "content"
- ? {
- title: block.content,
- }
- : {
- markdown: block.content,
- htmlWithGlossary: addGlossaryContentToMarkdown(
+ contents: await Promise.all(
+ data.contents.map(
+ async ({ name, title, blocks, references, referenceLabel }) => {
+ return {
+ name,
+ title,
+ blocks: await Promise.all(
+ blocks.map(async (block) => {
+ const htmlWithGlossary = block.content
+ ? await addGlossaryContentToMarkdown(
glossary,
block.content
- ),
- }),
- ...(block.type === "graphic"
- ? {
- size: block.file?.size,
- imgUrl: block.img?.url,
- altText: block.img?.altText,
- fileUrl: block.file?.url,
- }
- : {}),
- ...(block.type === "content"
- ? {
- blockDisplayMode: block.contentDisplayMode,
- contents: block.contents?.length
- ? block.contents.map(({ document }) => {
- return {
- title: document.title,
- cdtnId: document.cdtnId,
- source: document.source,
- };
- })
- : undefined,
- }
- : {}),
- };
- }),
- references: references?.length
- ? [
- {
- label: referenceLabel,
- links: references,
- },
- ]
- : undefined,
- };
- }
+ )
+ : "";
+ return {
+ type: block.type,
+ ...(block.type === "content"
+ ? {
+ title: block.content,
+ }
+ : {
+ markdown: block.content,
+ htmlWithGlossary,
+ }),
+ ...(block.type === "graphic"
+ ? {
+ size: block.file?.size,
+ imgUrl: block.img?.url,
+ altText: block.img?.altText,
+ fileUrl: block.file?.url,
+ }
+ : {}),
+ ...(block.type === "content"
+ ? {
+ blockDisplayMode: block.contentDisplayMode,
+ contents: block.contents?.length
+ ? block.contents.map(({ document }) => {
+ return {
+ title: document.title,
+ cdtnId: document.cdtnId,
+ source: document.source,
+ };
+ })
+ : undefined,
+ }
+ : {}),
+ };
+ })
+ ),
+ references: references?.length
+ ? [
+ {
+ label: referenceLabel,
+ links: references,
+ },
+ ]
+ : undefined,
+ };
+ }
+ )
),
},
};
diff --git a/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts b/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts
index 413c3d36b..1406394e5 100644
--- a/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts
+++ b/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts
@@ -15,29 +15,35 @@ export const updateEditorialContentDocumentsGlossary = async () => {
logger.info(`Found ${editorialContents.length} editorial contents`);
for (let i = 0; i < editorialContents.length; i++) {
const document = editorialContents[i].document;
+ const introWithGlossary = await addGlossaryContentToMarkdown(
+ glossary,
+ document.intro ?? ""
+ );
await updateDocument(editorialContents[i].cdtn_id, {
...document,
- introWithGlossary: addGlossaryContentToMarkdown(
- glossary,
- document.intro ?? ""
+ introWithGlossary,
+ contents: await Promise.all(
+ document.contents.map(async (content: any) => {
+ return {
+ ...content,
+ blocks: await Promise.all(
+ content.blocks.map(async (block: any) => {
+ if ("markdown" in block) {
+ const htmlWithGlossary = await addGlossaryContentToMarkdown(
+ glossary,
+ block.markdown
+ );
+ return {
+ ...block,
+ htmlWithGlossary,
+ };
+ }
+ return block;
+ })
+ ),
+ };
+ })
),
- contents: document.contents.map((content: any) => {
- return {
- ...content,
- blocks: content.blocks.map((block: any) => {
- if ("markdown" in block) {
- return {
- ...block,
- htmlWithGlossary: addGlossaryContentToMarkdown(
- glossary,
- block.markdown
- ),
- };
- }
- return block;
- }),
- };
- }),
});
logger.info(
`Updated editorial content ${i + 1}/${
From 61c32f6d641f18142c49bd132208575e27aa0e1b Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Wed, 5 Jun 2024 17:22:24 +0200
Subject: [PATCH 19/40] fix: glossary
---
.kontinuous/values.yaml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/.kontinuous/values.yaml b/.kontinuous/values.yaml
index f452de127..386bbdf66 100644
--- a/.kontinuous/values.yaml
+++ b/.kontinuous/values.yaml
@@ -61,9 +61,6 @@ www:
fsGroup: 1000
runAsUser: 1000
runAsGroup: 1000
- annotations:
- vpa.socialgouv.io/min-cpu: "500m"
- vpa.socialgouv.io/min-memory: "1Gi"
export:
~chart: app
From 49cd64eeb099049b1d0342b0e39a584106f3a877 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Thu, 6 Jun 2024 12:43:35 +0200
Subject: [PATCH 20/40] fix: glossary
---
.../utils/src/glossary/addGlossaryContent.ts | 9 ++-
shared/utils/src/glossary/index.ts | 2 +-
.../src/glossary/workers/launchWorker.ts | 32 ++++++++
.../glossary/workers/runGlossaryProcess.ts | 19 +++++
.../contribution/mapContributionToDocument.ts | 8 +-
.../documents/api/documents.service.ts | 20 ++---
.../updateContributionsDocumentsGlossary.ts | 9 ++-
...updateEditorialContentDocumentsGlossary.ts | 20 +++--
.../src/transform/fiche-travail-emploi.ts | 80 +++++++++++--------
9 files changed, 134 insertions(+), 65 deletions(-)
create mode 100644 shared/utils/src/glossary/workers/launchWorker.ts
create mode 100644 shared/utils/src/glossary/workers/runGlossaryProcess.ts
diff --git a/shared/utils/src/glossary/addGlossaryContent.ts b/shared/utils/src/glossary/addGlossaryContent.ts
index 2a424f035..634f378ec 100644
--- a/shared/utils/src/glossary/addGlossaryContent.ts
+++ b/shared/utils/src/glossary/addGlossaryContent.ts
@@ -5,8 +5,10 @@ import { Glossary } from "@socialgouv/cdtn-types";
export const addGlossaryContent = (
glossary: Glossary,
- content: string
+ content?: string | null
): string => {
+ if (!content) return "";
+
glossary.sort((previous, next) => {
return next.term.length - previous.term.length;
});
@@ -20,14 +22,15 @@ export const addGlossaryContent = (
};
});
- if (!content) return "";
return insertWebComponentGlossary(content, glossaryTerms);
};
export async function addGlossaryContentToMarkdown(
glossary: Glossary,
- markdown: string
+ markdown?: string | null
): Promise {
+ if (!markdown) return "";
+
const content = (await markdownProcessor.process(markdown))
.contents as string;
return addGlossaryContent(glossary, content);
diff --git a/shared/utils/src/glossary/index.ts b/shared/utils/src/glossary/index.ts
index 3673b2588..73de90b7e 100644
--- a/shared/utils/src/glossary/index.ts
+++ b/shared/utils/src/glossary/index.ts
@@ -1,2 +1,2 @@
-export * from "./addGlossaryContent";
+export * from "./workers/launchWorker";
export * from "./fetchGlossary";
diff --git a/shared/utils/src/glossary/workers/launchWorker.ts b/shared/utils/src/glossary/workers/launchWorker.ts
new file mode 100644
index 000000000..0f12a2d13
--- /dev/null
+++ b/shared/utils/src/glossary/workers/launchWorker.ts
@@ -0,0 +1,32 @@
+import { Glossary } from "@socialgouv/cdtn-types";
+import { Worker } from "worker_threads";
+import path from "path";
+
+export type GlossaryWorkerData = {
+ glossary: Glossary;
+ type: "markdown" | "html";
+ content?: string | null;
+};
+
+export const addGlossaryContentWorker = async (
+ workerData: GlossaryWorkerData
+): Promise => {
+ return new Promise((resolve, reject) => {
+ const worker = new Worker(
+ path.resolve(
+ process.cwd(),
+ "../../shared/utils/build/src/glossary/workers/runGlossaryProcess.js"
+ ),
+ {
+ workerData,
+ }
+ );
+ worker.on("message", resolve);
+ worker.on("error", reject);
+ worker.on("exit", (code) => {
+ if (code !== 0) {
+ reject(new Error(`Worker stopped with exit code ${code}`));
+ }
+ });
+ });
+};
diff --git a/shared/utils/src/glossary/workers/runGlossaryProcess.ts b/shared/utils/src/glossary/workers/runGlossaryProcess.ts
new file mode 100644
index 000000000..6ede26299
--- /dev/null
+++ b/shared/utils/src/glossary/workers/runGlossaryProcess.ts
@@ -0,0 +1,19 @@
+import {
+ addGlossaryContent,
+ addGlossaryContentToMarkdown,
+} from "../addGlossaryContent";
+import { parentPort, workerData } from "worker_threads";
+import { GlossaryWorkerData } from "./launchWorker";
+
+export const runGlossaryProcess = async () => {
+ const { glossary, type, content } = workerData as GlossaryWorkerData;
+ let result = "";
+ if (type === "markdown") {
+ result = await addGlossaryContentToMarkdown(glossary, content);
+ } else if (type === "html") {
+ result = addGlossaryContent(glossary, content);
+ }
+ parentPort?.postMessage(result);
+};
+
+runGlossaryProcess();
diff --git a/targets/frontend/src/modules/contribution/mapContributionToDocument.ts b/targets/frontend/src/modules/contribution/mapContributionToDocument.ts
index 185e245c6..e7717c209 100644
--- a/targets/frontend/src/modules/contribution/mapContributionToDocument.ts
+++ b/targets/frontend/src/modules/contribution/mapContributionToDocument.ts
@@ -7,7 +7,7 @@ import { SOURCES } from "@socialgouv/cdtn-sources";
import { getReferences } from "./getReferences";
import {
generateCdtnId,
- addGlossaryContent,
+ addGlossaryContentWorker,
fetchGlossary,
} from "@shared/utils";
import { generateContributionSlug } from "./generateSlug";
@@ -24,7 +24,11 @@ async function getBaseDocument(
return {
type: "content",
content: data.content,
- contentWithGlossary: addGlossaryContent(glossary, data.content ?? ""),
+ contentWithGlossary: addGlossaryContentWorker({
+ glossary,
+ type: "html",
+ content: data.content,
+ }),
};
case "GENERIC_NO_CDT":
return {
diff --git a/targets/frontend/src/modules/documents/api/documents.service.ts b/targets/frontend/src/modules/documents/api/documents.service.ts
index 30a863241..7ab4066d2 100644
--- a/targets/frontend/src/modules/documents/api/documents.service.ts
+++ b/targets/frontend/src/modules/documents/api/documents.service.ts
@@ -3,7 +3,7 @@ import { ConflictError, NotFoundError } from "src/lib/api/ApiErrors";
import { Information, InformationsRepository } from "src/modules/informations";
import { format, parseISO } from "date-fns";
import {
- addGlossaryContentToMarkdown,
+ addGlossaryContentWorker,
fetchGlossary,
generateCdtnId,
generateInitialId,
@@ -47,10 +47,11 @@ export class DocumentsService {
document?: HasuraDocument
): Promise> {
const glossary = await fetchGlossary();
- const introWithGlossary = await addGlossaryContentToMarkdown(
+ const introWithGlossary = await addGlossaryContentWorker({
glossary,
- data.intro ?? ""
- );
+ type: "markdown",
+ content: data.intro,
+ });
return {
cdtn_id: document?.cdtn_id ?? generateCdtnId(data.title),
initial_id: data.id ?? generateInitialId(),
@@ -87,12 +88,11 @@ export class DocumentsService {
title,
blocks: await Promise.all(
blocks.map(async (block) => {
- const htmlWithGlossary = block.content
- ? await addGlossaryContentToMarkdown(
- glossary,
- block.content
- )
- : "";
+ const htmlWithGlossary = await addGlossaryContentWorker({
+ glossary,
+ type: "markdown",
+ content: block.content,
+ });
return {
type: block.type,
...(block.type === "content"
diff --git a/targets/frontend/src/modules/glossary/updateContributionsDocumentsGlossary.ts b/targets/frontend/src/modules/glossary/updateContributionsDocumentsGlossary.ts
index f0b914f53..affb1ef8e 100644
--- a/targets/frontend/src/modules/glossary/updateContributionsDocumentsGlossary.ts
+++ b/targets/frontend/src/modules/glossary/updateContributionsDocumentsGlossary.ts
@@ -1,6 +1,6 @@
import { SOURCES } from "@socialgouv/cdtn-sources";
import { fetchDocumentBySource } from "./fetchDocumentBySource";
-import { addGlossaryContent, fetchGlossary } from "@shared/utils";
+import { addGlossaryContentWorker, fetchGlossary } from "@shared/utils";
import { updateDocument } from "./updateDocument";
import { logger } from "@shared/utils";
@@ -11,10 +11,11 @@ export const updateContributionsDocumentsGlossary = async () => {
for (let i = 0; i < contributions.length; i++) {
const document = contributions[i].document;
if (document.contentType === "ANSWER") {
- const contentWithGlossary = addGlossaryContent(
+ const contentWithGlossary = await addGlossaryContentWorker({
glossary,
- document.content ?? ""
- );
+ type: "html",
+ content: document.content,
+ });
await updateDocument(contributions[i].cdtn_id, {
...document,
contentWithGlossary,
diff --git a/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts b/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts
index 1406394e5..243459164 100644
--- a/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts
+++ b/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts
@@ -1,10 +1,6 @@
import { SOURCES } from "@socialgouv/cdtn-sources";
import { fetchDocumentBySource } from "./fetchDocumentBySource";
-import {
- addGlossaryContentToMarkdown,
- fetchGlossary,
- logger,
-} from "@shared/utils";
+import { addGlossaryContentWorker, fetchGlossary, logger } from "@shared/utils";
import { updateDocument } from "./updateDocument";
export const updateEditorialContentDocumentsGlossary = async () => {
@@ -15,10 +11,11 @@ export const updateEditorialContentDocumentsGlossary = async () => {
logger.info(`Found ${editorialContents.length} editorial contents`);
for (let i = 0; i < editorialContents.length; i++) {
const document = editorialContents[i].document;
- const introWithGlossary = await addGlossaryContentToMarkdown(
+ const introWithGlossary = await addGlossaryContentWorker({
glossary,
- document.intro ?? ""
- );
+ type: "markdown",
+ content: document.intro,
+ });
await updateDocument(editorialContents[i].cdtn_id, {
...document,
introWithGlossary,
@@ -29,10 +26,11 @@ export const updateEditorialContentDocumentsGlossary = async () => {
blocks: await Promise.all(
content.blocks.map(async (block: any) => {
if ("markdown" in block) {
- const htmlWithGlossary = await addGlossaryContentToMarkdown(
+ const htmlWithGlossary = await addGlossaryContentWorker({
glossary,
- block.markdown
- );
+ type: "markdown",
+ content: block.markdown,
+ });
return {
...block,
htmlWithGlossary,
diff --git a/targets/ingester/src/transform/fiche-travail-emploi.ts b/targets/ingester/src/transform/fiche-travail-emploi.ts
index ef873e011..356d3bef4 100644
--- a/targets/ingester/src/transform/fiche-travail-emploi.ts
+++ b/targets/ingester/src/transform/fiche-travail-emploi.ts
@@ -7,7 +7,7 @@ import {
articleToReference,
createReferenceResolver,
} from "../lib/referenceResolver";
-import { addGlossaryContent, fetchGlossary } from "@shared/utils";
+import { addGlossaryContentWorker, fetchGlossary } from "@shared/utils";
export default async function getFicheTravailEmploi(pkgName: string) {
const [fichesMT, cdt] = await Promise.all([
@@ -18,37 +18,49 @@ export default async function getFicheTravailEmploi(pkgName: string) {
]);
const glossary = await fetchGlossary();
const resolveCdtReference = createReferenceResolver(cdt);
- return fichesMT.map(({ pubId, sections, ...content }) => {
- return {
- id: pubId,
- ...content,
- is_searchable: true,
- sections: sections.map(({ references, ...section }) => ({
- ...section,
- htmlWithGlossary: addGlossaryContent(glossary, section.html),
- references: Object.keys(references).flatMap((key) => {
- if (key !== "LEGITEXT000006072050") {
- return [];
- }
- const { articles } = references[key];
- return articles.flatMap(({ id }) => {
- const maybeArticle = resolveCdtReference(
- id
- ) as LegiData.CodeArticle[];
- if (maybeArticle.length !== 1) {
- return [];
- }
- return articleToReference(maybeArticle[0]);
- });
- }),
- })),
- slug: slugify(content.title),
- source: SOURCES.SHEET_MT_PAGE,
- /**
- * text is empty here because text used for search (in elasticsearch)
- * is in each sections and sections will be transform as searchable document
- */
- text: "",
- };
- });
+ const result = await Promise.all(
+ fichesMT.map(async ({ pubId, sections, ...content }) => {
+ return {
+ id: pubId,
+ ...content,
+ is_searchable: true,
+ sections: await Promise.all(
+ sections.map(async ({ references, ...section }) => {
+ const htmlWithGlossary = await addGlossaryContentWorker({
+ glossary,
+ type: "html",
+ content: section.html,
+ });
+ return {
+ ...section,
+ htmlWithGlossary,
+ references: Object.keys(references).flatMap((key) => {
+ if (key !== "LEGITEXT000006072050") {
+ return [];
+ }
+ const { articles } = references[key];
+ return articles.flatMap(({ id }) => {
+ const maybeArticle = resolveCdtReference(
+ id
+ ) as LegiData.CodeArticle[];
+ if (maybeArticle.length !== 1) {
+ return [];
+ }
+ return articleToReference(maybeArticle[0]);
+ });
+ }),
+ };
+ })
+ ),
+ slug: slugify(content.title),
+ source: SOURCES.SHEET_MT_PAGE,
+ /**
+ * text is empty here because text used for search (in elasticsearch)
+ * is in each sections and sections will be transform as searchable document
+ */
+ text: "",
+ };
+ })
+ );
+ return result;
}
From 53c37710c13ad883edd0fad904e2ade2276b6491 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Thu, 6 Jun 2024 14:12:14 +0200
Subject: [PATCH 21/40] fix: glossary
---
shared/utils/src/glossary/workers/launchWorker.ts | 6 ++----
shared/utils/tsconfig.json | 4 ++--
targets/frontend/next.config.js | 1 +
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/shared/utils/src/glossary/workers/launchWorker.ts b/shared/utils/src/glossary/workers/launchWorker.ts
index 0f12a2d13..fcaa4acc8 100644
--- a/shared/utils/src/glossary/workers/launchWorker.ts
+++ b/shared/utils/src/glossary/workers/launchWorker.ts
@@ -12,11 +12,9 @@ export const addGlossaryContentWorker = async (
workerData: GlossaryWorkerData
): Promise => {
return new Promise((resolve, reject) => {
+ const packagePath = path.dirname(require.resolve("@shared/utils"));
const worker = new Worker(
- path.resolve(
- process.cwd(),
- "../../shared/utils/build/src/glossary/workers/runGlossaryProcess.js"
- ),
+ path.join("../", packagePath, "/glossary/workers/runGlossaryProcess.js"),
{
workerData,
}
diff --git a/shared/utils/tsconfig.json b/shared/utils/tsconfig.json
index 1d00dbd3c..10a0aefaf 100644
--- a/shared/utils/tsconfig.json
+++ b/shared/utils/tsconfig.json
@@ -6,9 +6,9 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
- "lib": ["es2022"],
+ "lib": ["ESNext"],
"module": "CommonJS",
- "target": "es2022",
+ "target": "ESNext",
"declaration": true,
"outDir": "build",
"moduleDetection": "force",
diff --git a/targets/frontend/next.config.js b/targets/frontend/next.config.js
index 955855b72..dc77bb614 100644
--- a/targets/frontend/next.config.js
+++ b/targets/frontend/next.config.js
@@ -29,6 +29,7 @@ module.exports = {
...config.resolve,
fallback: {
fs: false,
+ worker_threads: false,
},
};
return config;
From 60d50b2cb1f3563a964dd41bd8dff1e4c5b6b67c Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Thu, 6 Jun 2024 14:55:47 +0200
Subject: [PATCH 22/40] fix: glossary
---
shared/utils/src/glossary/workers/launchWorker.ts | 8 ++++++--
shared/utils/src/glossary/workers/utils.ts | 14 ++++++++++++++
.../contribution/mapContributionToDocument.ts | 2 +-
3 files changed, 21 insertions(+), 3 deletions(-)
create mode 100644 shared/utils/src/glossary/workers/utils.ts
diff --git a/shared/utils/src/glossary/workers/launchWorker.ts b/shared/utils/src/glossary/workers/launchWorker.ts
index fcaa4acc8..28332098d 100644
--- a/shared/utils/src/glossary/workers/launchWorker.ts
+++ b/shared/utils/src/glossary/workers/launchWorker.ts
@@ -1,6 +1,7 @@
import { Glossary } from "@socialgouv/cdtn-types";
import { Worker } from "worker_threads";
import path from "path";
+import { getMonorepoRoot } from "./utils";
export type GlossaryWorkerData = {
glossary: Glossary;
@@ -12,9 +13,12 @@ export const addGlossaryContentWorker = async (
workerData: GlossaryWorkerData
): Promise => {
return new Promise((resolve, reject) => {
- const packagePath = path.dirname(require.resolve("@shared/utils"));
+ const rootPath = getMonorepoRoot(__dirname, "cdtn-admin");
const worker = new Worker(
- path.join("../", packagePath, "/glossary/workers/runGlossaryProcess.js"),
+ path.join(
+ rootPath,
+ "/shared/utils/build/src/glossary/workers/runGlossaryProcess.js"
+ ),
{
workerData,
}
diff --git a/shared/utils/src/glossary/workers/utils.ts b/shared/utils/src/glossary/workers/utils.ts
new file mode 100644
index 000000000..3f567995a
--- /dev/null
+++ b/shared/utils/src/glossary/workers/utils.ts
@@ -0,0 +1,14 @@
+import path from "path";
+
+export function getMonorepoRoot(currentPath: string, rootDirName: string) {
+ let dir = currentPath;
+
+ while (dir !== path.parse(dir).root) {
+ if (path.basename(dir) === rootDirName) {
+ return dir;
+ }
+ dir = path.dirname(dir);
+ }
+
+ return "";
+}
diff --git a/targets/frontend/src/modules/contribution/mapContributionToDocument.ts b/targets/frontend/src/modules/contribution/mapContributionToDocument.ts
index e7717c209..42106c868 100644
--- a/targets/frontend/src/modules/contribution/mapContributionToDocument.ts
+++ b/targets/frontend/src/modules/contribution/mapContributionToDocument.ts
@@ -24,7 +24,7 @@ async function getBaseDocument(
return {
type: "content",
content: data.content,
- contentWithGlossary: addGlossaryContentWorker({
+ contentWithGlossary: await addGlossaryContentWorker({
glossary,
type: "html",
content: data.content,
From d917a8b6ca1ed5fd09fcc1b420054bc28ba22f5e Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:23:09 +0200
Subject: [PATCH 23/40] empty
From 089058d3197491cf4b3f3af07a6209c7793df739 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Thu, 6 Jun 2024 16:35:11 +0200
Subject: [PATCH 24/40] fix: glossary
---
shared/utils/src/glossary/index.ts | 2 +-
shared/utils/src/glossary/launchWorker.ts | 42 +++++++++++++++++++
.../src/glossary/workers/launchWorker.ts | 34 ---------------
.../glossary/workers/runGlossaryProcess.ts | 19 ---------
shared/utils/src/glossary/workers/utils.ts | 14 -------
5 files changed, 43 insertions(+), 68 deletions(-)
create mode 100644 shared/utils/src/glossary/launchWorker.ts
delete mode 100644 shared/utils/src/glossary/workers/launchWorker.ts
delete mode 100644 shared/utils/src/glossary/workers/runGlossaryProcess.ts
delete mode 100644 shared/utils/src/glossary/workers/utils.ts
diff --git a/shared/utils/src/glossary/index.ts b/shared/utils/src/glossary/index.ts
index 73de90b7e..b8cf6b8b0 100644
--- a/shared/utils/src/glossary/index.ts
+++ b/shared/utils/src/glossary/index.ts
@@ -1,2 +1,2 @@
-export * from "./workers/launchWorker";
+export * from "./launchWorker";
export * from "./fetchGlossary";
diff --git a/shared/utils/src/glossary/launchWorker.ts b/shared/utils/src/glossary/launchWorker.ts
new file mode 100644
index 000000000..f93e95209
--- /dev/null
+++ b/shared/utils/src/glossary/launchWorker.ts
@@ -0,0 +1,42 @@
+import { Glossary } from "@socialgouv/cdtn-types";
+import { Worker, isMainThread, parentPort, workerData } from "worker_threads";
+import {
+ addGlossaryContent,
+ addGlossaryContentToMarkdown,
+} from "./addGlossaryContent";
+
+export type GlossaryWorkerData = {
+ glossary: Glossary;
+ type: "markdown" | "html";
+ content?: string | null;
+};
+
+export const addGlossaryContentWorker = async (
+ workerData: GlossaryWorkerData
+): Promise => {
+ return new Promise((resolve, reject) => {
+ const worker = new Worker(__filename, {
+ workerData,
+ });
+ worker.on("message", resolve);
+ worker.on("error", reject);
+ worker.on("exit", (code) => {
+ if (code !== 0) {
+ reject(new Error(`Worker stopped with exit code ${code}`));
+ }
+ });
+ });
+};
+
+if (!isMainThread) {
+ const { glossary, type, content } = workerData as GlossaryWorkerData;
+ let result = "";
+ if (type === "markdown") {
+ addGlossaryContentToMarkdown(glossary, content).then((res) => {
+ parentPort?.postMessage(res);
+ });
+ } else if (type === "html") {
+ result = addGlossaryContent(glossary, content);
+ parentPort?.postMessage(result);
+ }
+}
diff --git a/shared/utils/src/glossary/workers/launchWorker.ts b/shared/utils/src/glossary/workers/launchWorker.ts
deleted file mode 100644
index 28332098d..000000000
--- a/shared/utils/src/glossary/workers/launchWorker.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Glossary } from "@socialgouv/cdtn-types";
-import { Worker } from "worker_threads";
-import path from "path";
-import { getMonorepoRoot } from "./utils";
-
-export type GlossaryWorkerData = {
- glossary: Glossary;
- type: "markdown" | "html";
- content?: string | null;
-};
-
-export const addGlossaryContentWorker = async (
- workerData: GlossaryWorkerData
-): Promise => {
- return new Promise((resolve, reject) => {
- const rootPath = getMonorepoRoot(__dirname, "cdtn-admin");
- const worker = new Worker(
- path.join(
- rootPath,
- "/shared/utils/build/src/glossary/workers/runGlossaryProcess.js"
- ),
- {
- workerData,
- }
- );
- worker.on("message", resolve);
- worker.on("error", reject);
- worker.on("exit", (code) => {
- if (code !== 0) {
- reject(new Error(`Worker stopped with exit code ${code}`));
- }
- });
- });
-};
diff --git a/shared/utils/src/glossary/workers/runGlossaryProcess.ts b/shared/utils/src/glossary/workers/runGlossaryProcess.ts
deleted file mode 100644
index 6ede26299..000000000
--- a/shared/utils/src/glossary/workers/runGlossaryProcess.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import {
- addGlossaryContent,
- addGlossaryContentToMarkdown,
-} from "../addGlossaryContent";
-import { parentPort, workerData } from "worker_threads";
-import { GlossaryWorkerData } from "./launchWorker";
-
-export const runGlossaryProcess = async () => {
- const { glossary, type, content } = workerData as GlossaryWorkerData;
- let result = "";
- if (type === "markdown") {
- result = await addGlossaryContentToMarkdown(glossary, content);
- } else if (type === "html") {
- result = addGlossaryContent(glossary, content);
- }
- parentPort?.postMessage(result);
-};
-
-runGlossaryProcess();
diff --git a/shared/utils/src/glossary/workers/utils.ts b/shared/utils/src/glossary/workers/utils.ts
deleted file mode 100644
index 3f567995a..000000000
--- a/shared/utils/src/glossary/workers/utils.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import path from "path";
-
-export function getMonorepoRoot(currentPath: string, rootDirName: string) {
- let dir = currentPath;
-
- while (dir !== path.parse(dir).root) {
- if (path.basename(dir) === rootDirName) {
- return dir;
- }
- dir = path.dirname(dir);
- }
-
- return "";
-}
From b4a4c3c0b7ba07a39fbfd80e4a9adc6a20076376 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Thu, 6 Jun 2024 16:59:39 +0200
Subject: [PATCH 25/40] fix: glossary
---
.kontinuous/values.yaml | 3 +++
shared/utils/src/glossary/launchWorker.ts | 4 +---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/.kontinuous/values.yaml b/.kontinuous/values.yaml
index 386bbdf66..f452de127 100644
--- a/.kontinuous/values.yaml
+++ b/.kontinuous/values.yaml
@@ -61,6 +61,9 @@ www:
fsGroup: 1000
runAsUser: 1000
runAsGroup: 1000
+ annotations:
+ vpa.socialgouv.io/min-cpu: "500m"
+ vpa.socialgouv.io/min-memory: "1Gi"
export:
~chart: app
diff --git a/shared/utils/src/glossary/launchWorker.ts b/shared/utils/src/glossary/launchWorker.ts
index f93e95209..2bca2b01b 100644
--- a/shared/utils/src/glossary/launchWorker.ts
+++ b/shared/utils/src/glossary/launchWorker.ts
@@ -30,13 +30,11 @@ export const addGlossaryContentWorker = async (
if (!isMainThread) {
const { glossary, type, content } = workerData as GlossaryWorkerData;
- let result = "";
if (type === "markdown") {
addGlossaryContentToMarkdown(glossary, content).then((res) => {
parentPort?.postMessage(res);
});
} else if (type === "html") {
- result = addGlossaryContent(glossary, content);
- parentPort?.postMessage(result);
+ parentPort?.postMessage(addGlossaryContent(glossary, content));
}
}
From 2d8e475da2d868384cb86a46dd473ba5062ee504 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Thu, 6 Jun 2024 17:49:35 +0200
Subject: [PATCH 26/40] fix: glossary
---
.kontinuous/values.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.kontinuous/values.yaml b/.kontinuous/values.yaml
index f452de127..86cbeb54e 100644
--- a/.kontinuous/values.yaml
+++ b/.kontinuous/values.yaml
@@ -62,8 +62,8 @@ www:
runAsUser: 1000
runAsGroup: 1000
annotations:
- vpa.socialgouv.io/min-cpu: "500m"
- vpa.socialgouv.io/min-memory: "1Gi"
+ vpa.socialgouv.io/min-cpu: "2000m"
+ vpa.socialgouv.io/min-memory: "3Gi"
export:
~chart: app
From d6621563aae8f30c4f8374293398ad1e9344c497 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Fri, 7 Jun 2024 09:45:30 +0200
Subject: [PATCH 27/40] fix: log
---
shared/utils/src/glossary/launchWorker.ts | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/shared/utils/src/glossary/launchWorker.ts b/shared/utils/src/glossary/launchWorker.ts
index 2bca2b01b..020d61fd0 100644
--- a/shared/utils/src/glossary/launchWorker.ts
+++ b/shared/utils/src/glossary/launchWorker.ts
@@ -19,16 +19,25 @@ export const addGlossaryContentWorker = async (
workerData,
});
worker.on("message", resolve);
- worker.on("error", reject);
+ worker.on("error", (error) => {
+ console.error("[addGlossaryContentWorker] - error", error);
+ reject(error);
+ });
worker.on("exit", (code) => {
if (code !== 0) {
- reject(new Error(`Worker stopped with exit code ${code}`));
+ console.error(
+ `[addGlossaryContentWorker] - Worker stopped with exit code ${code}`
+ );
+ reject(`Worker stopped with exit code ${code}`);
}
});
});
};
+console.log("GFR - isMainThread", isMainThread);
+
if (!isMainThread) {
+ console.log("GFR - worker qui se lance", workerData);
const { glossary, type, content } = workerData as GlossaryWorkerData;
if (type === "markdown") {
addGlossaryContentToMarkdown(glossary, content).then((res) => {
From 7c87a338f266ea2b1585083fd10137fe186db90a Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Fri, 7 Jun 2024 12:41:00 +0200
Subject: [PATCH 28/40] fix: log
---
.env | 18 ++---------
.../env/dev/templates/hasura.configmap.yaml | 1 -
.../dev/templates/hasura.sealed-secret.yaml | 2 --
.../preprod/templates/hasura.configmap.yaml | 1 -
.../templates/hasura.sealed-secret.yaml | 2 --
.../env/prod/templates/hasura.configmap.yaml | 1 -
.../prod/templates/hasura.sealed-secret.yaml | 2 --
docker-compose.yml | 31 +++++++++----------
shared/utils/src/glossary/launchWorker.ts | 13 +++-----
targets/frontend/next.config.js | 19 +++++++-----
targets/frontend/package.json | 1 +
11 files changed, 34 insertions(+), 57 deletions(-)
diff --git a/.env b/.env
index 408e6faa5..423855fc9 100644
--- a/.env
+++ b/.env
@@ -1,26 +1,12 @@
-##
-## Hasura
-##
-PUBLICATION_WEBHOOK_URL=http://host.docker.internal:3001/api/webhooks/publication
API_URL=http://host.docker.internal:3001/api
HASURA_GRAPHQL_DATABASE_URL=postgres://postgres:postgrespassword@postgres:5432/postgres
HASURA_GRAPHQL_ENABLED_LOG_TYPES=startup, http-log, webhook-log, websocket-log, query-log
HASURA_GRAPHQL_NO_OF_RETRIES=5
HASURA_GRAPHQL_MIGRATIONS_SERVER_TIMEOUT=10
HASURA_GRAPHQL_UNAUTHORIZED_ROLE=public
+HASURA_GRAPHQL_ADMIN_SECRET=admin1
+HASURA_GRAPHQL_JWT_SECRET={"type": "HS256", "key": "a_pretty_long_secret_key_that_should_be_at_least_32_char"}
SMTP_URL=smtp.url
SMTP_EMAIL_USER=email
SMTP_EMAIL_PASSWORD=pass
-
-##
-## Shared secret between hasura and frontend
-##
-
-# Hasura
-HASURA_GRAPHQL_ADMIN_SECRET=admin1
-HASURA_GRAPHQL_JWT_SECRET={"type": "HS256", "key": "a_pretty_long_secret_key_that_should_be_at_least_32_char"}
-
-# webhook & action
-ACTIONS_SECRET=a random string that will be verify when calling the webhook
-PUBLICATION_SECRET=a random string that will be verify when calling the webhook
diff --git a/.kontinuous/env/dev/templates/hasura.configmap.yaml b/.kontinuous/env/dev/templates/hasura.configmap.yaml
index 59d08e5e1..a5c66a7c6 100644
--- a/.kontinuous/env/dev/templates/hasura.configmap.yaml
+++ b/.kontinuous/env/dev/templates/hasura.configmap.yaml
@@ -4,7 +4,6 @@ metadata:
name: hasura
data:
API_URL: "http://www/api"
- PUBLICATION_WEBHOOK_URL: "http://www/api/webhooks/publication"
HASURA_GRAPHQL_ENABLE_CONSOLE: "false"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: "startup, http-log, webhook-log, websocket-log, query-log"
HASURA_GRAPHQL_NO_OF_RETRIES: "5"
diff --git a/.kontinuous/env/dev/templates/hasura.sealed-secret.yaml b/.kontinuous/env/dev/templates/hasura.sealed-secret.yaml
index 0ac8e0ad2..c0127dcee 100644
--- a/.kontinuous/env/dev/templates/hasura.sealed-secret.yaml
+++ b/.kontinuous/env/dev/templates/hasura.sealed-secret.yaml
@@ -10,8 +10,6 @@ spec:
encryptedData:
HASURA_GRAPHQL_ADMIN_SECRET: AgC4DoTx/Burraa4LQnxWJ8pa4gK7mSHWd4fFFUHWeVrTmcoxLRyVVqH8ajgXFBZ1uksTujs8LM0eDtxeO/d6e88y7lF8epCutVm/9Lr39E8eMA4zwMU6QNrCX4j34YRonf4vbOnlUfm88XKek7DTOsUsbTp5BbO/IrESzabBJ9ntLBAdCVK+j6eGZyCC44VcfszHoiQINwi0Iax66KuA4oUvpQuTdTbB20wr9vzZarMatDDQRYtjugtYFzQQAv45+BZscb1Q+cMz+MXGOeJTDpFrhhV0OeDp5llEDhmx3nhyeRGyeWZdvONrDl4lDvftO6b8CTV1jBaoCX1r8pKcdp69WbkX2V+62lqamr5bmgJiuBWeOTHT1qQrv9uuInhrBBrkcHrXXMKlTY+p9auY/IQLw9CyBn41sK+RDteQfoZFRHSo2UOipbfgB5j9mCVnyJLDYLfyH4TEdGM6lkCATnKHr7Jz16IeR+GwmLfHrHkv3TW6zPijBBZRVcC5Z6LQNVv/6BzrKlzOkgZCKsX5pgaQWQBDSJSe8QGkx3Ccik6XpC/jgdHPEuP8zqDhE4VzWM6FrsxLAvso5WWNgdmS3i01RFa+pnFK7wLp7oLtDjKo7GyG2mXGt2B2+uvUffAmrE4jTCIbjUQtgrHHDBpq0hhxrG0njbh3SL29fNz1FeaXOFdubRfs0Zg2aNXtwDFHDrM8jCt/Yj4mY21uKup82mQZG6FCENCx+Hl7GGtuhs=
HASURA_GRAPHQL_JWT_SECRET: AgDSW4ceV9HFoxBNqg/hGa6uunl76cjtKBRSYf5LEPKzNHtXixd73LoFGa2y6/cQ/yGevNU6k7w62pkbWnz5rNAznsBE8QtBt1eRKQqjyJJ21m4sWI/MK6UI3gUS/Ad+LeCMxSoKG3XEzFSAwSndSXsgmwAP4KPpBF83DvdpVVpZtAjvPbNYNE6Ocjhtmt/TLqWjsV4Z+hkS8CKGk+PsYDEuR74Mj5TJys0MALJA9TB2dTIqMHOVZofD8T9hKH42yJWCDruH+gNNPKcleG/R0Pt7LJSamZtsqtXdxeE02tB+I9/VaEMrBL2WCJKhGHTjlDxexl4V/fswFYgXc/T4+hmPVB76xWVi6yFfggD/tLcAvgw3Ivdmbk/1c4CayKjU0+B+57EVrRqCGbJieBfbv6L3EWjU0uQj/uJEaZxIF4st3/r+iSGnrtPveBqnUgkJeqOmhf4sWJwE3xsPJM2kNYDPelWpYdxpoPaq3PNcLs7WpxMtRvwvvz2LMsWhEuUyHpe5yLOvi5swhcGqX1ALxGxfxzV+O229WfuTmV/kGUmcHhdf/VXdJRa+PYS83YK39wC1ZsoXJvPjAvEMgoTaRE8NHPWVD2ookNwdiRQIoLrSrGMP6F+Team2KtCic9ONYnM2wwUj2JCQRkFX2LZXwm9g9uR/Leuyd/IL5+tczwfF+PHfs6TQv+uKVz2qoZQZk4myQ/0JwHluOSXHTwEWkvuwGYO8QMTDOTTdp4Dor3kN7hQZyvWf41V/EHmOoLeFsdpQkWexo1FWHRZYtgG7ZVrgs07bY65gY6c1tZOKFaWhacTuneiLosz79vxn5omsFpjOOiWdSQOPZU8GkGxqJVq16H3VJg==
- PUBLICATION_SECRET: AgAtDPOTr9khd47wV5WPXJaLSj+6Kmh5N/Wt9SJUTmRgn9jp8trclhS5DvZxmfVv/rYRRiDTuPATDR4yMbfvtrO9ABAhmRZFvmU5VbxdtCDrc9qtv5ZJ4dsYIVxyXIad7+CumHkunXYSwgmCqr2bvv5oeWRmTx2x4uwaNzhEKQ4hUzYCyWp9laJHt5mYT/c/IWZu0PaDXJQVWQuep3fJvjtxQw9EZVy+ehGAqyClL7bkqT1KVrVBDfvpPeO97O2e2de49RcdZSCtBTmGDHKg7fwUziBJSSI8ObtUMzWm56223XZXKqrxdChAlWJE05tHsvowa18NadFDjJwVt3RtPp+HguVj+I7PiTJMTjyZpsmHlr767teLYrXAoAVc9MRrGeznvYw4i0DhNFZXfyYghSKnKPW4yfYzNKwX50huCyQethn1TqU6MAYGrWiyx9XsaHy3bNgAO4ru9o8WV7bfyeRRsABMoiubyq9RCxfOXRU3cbWYaiS8aiPxALZRKjhSeQhJ5ufdL700rJWV2nuoxXG8jjR3yw3bpCL6imIrLRIAP1+Wki5I8Qo98dfBBF/nahEWeXdCqCjpImfSLUioKMes2IrH8ragfja+85x06S8717b67qyBqtGeGAfX2JYLDWILoA0k9RdzyIwuakAZkChGoWTUy8aRjC7GJIKCQ5IKZ5FQr0IuVVjj1xoGBh6O/sFsOLF7/sA3hRcvirzcCFvCIwsmHs/q4K1iU7nDR0WE1AUV/uccbP3yzAzv6gqElztn1f/LOpA01b2Wn9YAzi6S65wUXUWx7UAx6YaiiofmnySnseSNfE+8
- ACTIONS_SECRET: AgCrnvsRqo0y0d2B5jJOSfdsu7zPJ+DmjbS7GVXRYEHOMIi2tLwuuNvZdRk7iBc/DtbCrIA4Wg55gKTUD1XYtzIYcdysovYTDEBl1IcR1/9mSzbYB7XXWrBfsyP36UbNIEah/caigryy0THA4Rulde6yZ71lSIX3nmpXObEdoO3AHfGQtQE948CCwQdA/9SI90bvvCp9aYJ+oGbB4xqipguchUQIFH8UpRxsWywFQo7I6ao/lB6KfxIxdLxfEFOwisFEHWdranEE/ai2QJrzE0Eeo5y0jcp8FMJ2WvWmIVNrg+4mfDK4dzmSozbP06X03FDWLtRmkU3F5M42/aqBRSCw1kU2yuTNjP3DzyIdwOEYRIShzU5A2RaGWzLclkeqjQQFXSXs0Ju3mcaD6C8WWde+A7tFm9pSrx8yp8PkG+7E5DfNsC8jMQnIFDLIqgcFMPF6vnOyb6HS1fW/Aa0O7xD2Oq6Gpx6wyw0GzZ6ZB8IkUp1PMc+bNNR0bY6Rh0PjdjPXuyPFVuZ1zHc9Kpd9pYhNr06ldiOe6ZrtI/GEAUJe2DEtkZYDjVu6A5IdEFIn1mTW/+H5EduxQv6NuVzYudNg2n6/wC2S8637EkyPrgklHS+lCxMr7N9uHPRHJm+tAB5bwds/jZjivHrePv52rVtZxSaPc1AchoORsGqbJks2L3u0Bu7o2sdDtNAj2vyxp39FHpgeMqNbBF21nyohjhXvR7gPWvzBGl1+0au6CJfqEkOzgovbI4hPmUWzXbf0jW6pMcAERiQ04h07ZjqyHYRAXw4J9Gm1GDooxNDdVi7yOu1dI4iKoLwD
template:
metadata:
annotations: *a1
diff --git a/.kontinuous/env/preprod/templates/hasura.configmap.yaml b/.kontinuous/env/preprod/templates/hasura.configmap.yaml
index 59d08e5e1..a5c66a7c6 100644
--- a/.kontinuous/env/preprod/templates/hasura.configmap.yaml
+++ b/.kontinuous/env/preprod/templates/hasura.configmap.yaml
@@ -4,7 +4,6 @@ metadata:
name: hasura
data:
API_URL: "http://www/api"
- PUBLICATION_WEBHOOK_URL: "http://www/api/webhooks/publication"
HASURA_GRAPHQL_ENABLE_CONSOLE: "false"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: "startup, http-log, webhook-log, websocket-log, query-log"
HASURA_GRAPHQL_NO_OF_RETRIES: "5"
diff --git a/.kontinuous/env/preprod/templates/hasura.sealed-secret.yaml b/.kontinuous/env/preprod/templates/hasura.sealed-secret.yaml
index 0ac8e0ad2..c0127dcee 100644
--- a/.kontinuous/env/preprod/templates/hasura.sealed-secret.yaml
+++ b/.kontinuous/env/preprod/templates/hasura.sealed-secret.yaml
@@ -10,8 +10,6 @@ spec:
encryptedData:
HASURA_GRAPHQL_ADMIN_SECRET: AgC4DoTx/Burraa4LQnxWJ8pa4gK7mSHWd4fFFUHWeVrTmcoxLRyVVqH8ajgXFBZ1uksTujs8LM0eDtxeO/d6e88y7lF8epCutVm/9Lr39E8eMA4zwMU6QNrCX4j34YRonf4vbOnlUfm88XKek7DTOsUsbTp5BbO/IrESzabBJ9ntLBAdCVK+j6eGZyCC44VcfszHoiQINwi0Iax66KuA4oUvpQuTdTbB20wr9vzZarMatDDQRYtjugtYFzQQAv45+BZscb1Q+cMz+MXGOeJTDpFrhhV0OeDp5llEDhmx3nhyeRGyeWZdvONrDl4lDvftO6b8CTV1jBaoCX1r8pKcdp69WbkX2V+62lqamr5bmgJiuBWeOTHT1qQrv9uuInhrBBrkcHrXXMKlTY+p9auY/IQLw9CyBn41sK+RDteQfoZFRHSo2UOipbfgB5j9mCVnyJLDYLfyH4TEdGM6lkCATnKHr7Jz16IeR+GwmLfHrHkv3TW6zPijBBZRVcC5Z6LQNVv/6BzrKlzOkgZCKsX5pgaQWQBDSJSe8QGkx3Ccik6XpC/jgdHPEuP8zqDhE4VzWM6FrsxLAvso5WWNgdmS3i01RFa+pnFK7wLp7oLtDjKo7GyG2mXGt2B2+uvUffAmrE4jTCIbjUQtgrHHDBpq0hhxrG0njbh3SL29fNz1FeaXOFdubRfs0Zg2aNXtwDFHDrM8jCt/Yj4mY21uKup82mQZG6FCENCx+Hl7GGtuhs=
HASURA_GRAPHQL_JWT_SECRET: AgDSW4ceV9HFoxBNqg/hGa6uunl76cjtKBRSYf5LEPKzNHtXixd73LoFGa2y6/cQ/yGevNU6k7w62pkbWnz5rNAznsBE8QtBt1eRKQqjyJJ21m4sWI/MK6UI3gUS/Ad+LeCMxSoKG3XEzFSAwSndSXsgmwAP4KPpBF83DvdpVVpZtAjvPbNYNE6Ocjhtmt/TLqWjsV4Z+hkS8CKGk+PsYDEuR74Mj5TJys0MALJA9TB2dTIqMHOVZofD8T9hKH42yJWCDruH+gNNPKcleG/R0Pt7LJSamZtsqtXdxeE02tB+I9/VaEMrBL2WCJKhGHTjlDxexl4V/fswFYgXc/T4+hmPVB76xWVi6yFfggD/tLcAvgw3Ivdmbk/1c4CayKjU0+B+57EVrRqCGbJieBfbv6L3EWjU0uQj/uJEaZxIF4st3/r+iSGnrtPveBqnUgkJeqOmhf4sWJwE3xsPJM2kNYDPelWpYdxpoPaq3PNcLs7WpxMtRvwvvz2LMsWhEuUyHpe5yLOvi5swhcGqX1ALxGxfxzV+O229WfuTmV/kGUmcHhdf/VXdJRa+PYS83YK39wC1ZsoXJvPjAvEMgoTaRE8NHPWVD2ookNwdiRQIoLrSrGMP6F+Team2KtCic9ONYnM2wwUj2JCQRkFX2LZXwm9g9uR/Leuyd/IL5+tczwfF+PHfs6TQv+uKVz2qoZQZk4myQ/0JwHluOSXHTwEWkvuwGYO8QMTDOTTdp4Dor3kN7hQZyvWf41V/EHmOoLeFsdpQkWexo1FWHRZYtgG7ZVrgs07bY65gY6c1tZOKFaWhacTuneiLosz79vxn5omsFpjOOiWdSQOPZU8GkGxqJVq16H3VJg==
- PUBLICATION_SECRET: AgAtDPOTr9khd47wV5WPXJaLSj+6Kmh5N/Wt9SJUTmRgn9jp8trclhS5DvZxmfVv/rYRRiDTuPATDR4yMbfvtrO9ABAhmRZFvmU5VbxdtCDrc9qtv5ZJ4dsYIVxyXIad7+CumHkunXYSwgmCqr2bvv5oeWRmTx2x4uwaNzhEKQ4hUzYCyWp9laJHt5mYT/c/IWZu0PaDXJQVWQuep3fJvjtxQw9EZVy+ehGAqyClL7bkqT1KVrVBDfvpPeO97O2e2de49RcdZSCtBTmGDHKg7fwUziBJSSI8ObtUMzWm56223XZXKqrxdChAlWJE05tHsvowa18NadFDjJwVt3RtPp+HguVj+I7PiTJMTjyZpsmHlr767teLYrXAoAVc9MRrGeznvYw4i0DhNFZXfyYghSKnKPW4yfYzNKwX50huCyQethn1TqU6MAYGrWiyx9XsaHy3bNgAO4ru9o8WV7bfyeRRsABMoiubyq9RCxfOXRU3cbWYaiS8aiPxALZRKjhSeQhJ5ufdL700rJWV2nuoxXG8jjR3yw3bpCL6imIrLRIAP1+Wki5I8Qo98dfBBF/nahEWeXdCqCjpImfSLUioKMes2IrH8ragfja+85x06S8717b67qyBqtGeGAfX2JYLDWILoA0k9RdzyIwuakAZkChGoWTUy8aRjC7GJIKCQ5IKZ5FQr0IuVVjj1xoGBh6O/sFsOLF7/sA3hRcvirzcCFvCIwsmHs/q4K1iU7nDR0WE1AUV/uccbP3yzAzv6gqElztn1f/LOpA01b2Wn9YAzi6S65wUXUWx7UAx6YaiiofmnySnseSNfE+8
- ACTIONS_SECRET: AgCrnvsRqo0y0d2B5jJOSfdsu7zPJ+DmjbS7GVXRYEHOMIi2tLwuuNvZdRk7iBc/DtbCrIA4Wg55gKTUD1XYtzIYcdysovYTDEBl1IcR1/9mSzbYB7XXWrBfsyP36UbNIEah/caigryy0THA4Rulde6yZ71lSIX3nmpXObEdoO3AHfGQtQE948CCwQdA/9SI90bvvCp9aYJ+oGbB4xqipguchUQIFH8UpRxsWywFQo7I6ao/lB6KfxIxdLxfEFOwisFEHWdranEE/ai2QJrzE0Eeo5y0jcp8FMJ2WvWmIVNrg+4mfDK4dzmSozbP06X03FDWLtRmkU3F5M42/aqBRSCw1kU2yuTNjP3DzyIdwOEYRIShzU5A2RaGWzLclkeqjQQFXSXs0Ju3mcaD6C8WWde+A7tFm9pSrx8yp8PkG+7E5DfNsC8jMQnIFDLIqgcFMPF6vnOyb6HS1fW/Aa0O7xD2Oq6Gpx6wyw0GzZ6ZB8IkUp1PMc+bNNR0bY6Rh0PjdjPXuyPFVuZ1zHc9Kpd9pYhNr06ldiOe6ZrtI/GEAUJe2DEtkZYDjVu6A5IdEFIn1mTW/+H5EduxQv6NuVzYudNg2n6/wC2S8637EkyPrgklHS+lCxMr7N9uHPRHJm+tAB5bwds/jZjivHrePv52rVtZxSaPc1AchoORsGqbJks2L3u0Bu7o2sdDtNAj2vyxp39FHpgeMqNbBF21nyohjhXvR7gPWvzBGl1+0au6CJfqEkOzgovbI4hPmUWzXbf0jW6pMcAERiQ04h07ZjqyHYRAXw4J9Gm1GDooxNDdVi7yOu1dI4iKoLwD
template:
metadata:
annotations: *a1
diff --git a/.kontinuous/env/prod/templates/hasura.configmap.yaml b/.kontinuous/env/prod/templates/hasura.configmap.yaml
index 2da203422..a5c66a7c6 100644
--- a/.kontinuous/env/prod/templates/hasura.configmap.yaml
+++ b/.kontinuous/env/prod/templates/hasura.configmap.yaml
@@ -9,4 +9,3 @@ data:
HASURA_GRAPHQL_NO_OF_RETRIES: "5"
HASURA_GRAPHQL_SERVER_PORT: "8080"
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "public"
- PUBLICATION_WEBHOOK_URL: "http://www/api/webhooks/publication"
diff --git a/.kontinuous/env/prod/templates/hasura.sealed-secret.yaml b/.kontinuous/env/prod/templates/hasura.sealed-secret.yaml
index 4e0e44661..7827a2c04 100644
--- a/.kontinuous/env/prod/templates/hasura.sealed-secret.yaml
+++ b/.kontinuous/env/prod/templates/hasura.sealed-secret.yaml
@@ -7,8 +7,6 @@ spec:
encryptedData:
HASURA_GRAPHQL_ADMIN_SECRET: AgBq/VnExWhATvCrlpqyhvUwUCEZUpQEZ0N7A4glKiU8BhuuyTIj+1HIfLMANcjoXMfOUWT46DNRy5fRHzUFm/j22QZd+4lfvQIytrMlcdpuFb5yMCWW62+/i44EXW3GcXkUnacVp5NN4WOWPzQNuhf/0oIDlIN1ULKzUleFzJfS1MCPxD5T721qTkvcSfoJosSjRCCQbOeUcxYLbCGbCQSflaEJ11SE2EXTGf4jv9px9eAUlKbhOgyThQnSlnfaRYcepa27zZNM1X3ggjCLHHG+C2cElpkBzepw/hrEnAiq64DbzgGcoPWDCjAwKTrCdytnyrqj3cJkbAuWQVbhv39vPSy/HW/pKGsakNGvZV7ofCAfFWQC5wGFkd7Kph4/cV3XRuPfCq/8kNrQpfmfVwJpsJH63o/Do9svynLvyWmtmJiE50tUOhI1yOzeRFNGtcGPCRJGBmXAAz9LkF1bpT6WWxrTya0jbXolvkuqwYHDaUcL29DGmNwfcfW94z9NrfmGp/ppeN9A1j7cqU53U/c444mn8Ns+kpbV7Q1VmZIzeNrq4zX88VAXbmou5tJyiWuCpKQRvtqfvoCGlWVKmdoya+yFHHR2NeDoj9246Hi66K9K7BluWsK9CKY74lXKBzDW2B3ThOxdpmWDof6WJaPKOltszm0xQLAK8l2VRVrSv6mmUkiYsAu2iBjfB/C9jQRBYYWy75LHS6V3lEKj0hkGMtwh6apya/RpwPL76do=
HASURA_GRAPHQL_JWT_SECRET: AgBsyXBoL2VRo5DZ3mwg7XtRm+HvPMVs8xxcL8OHaHsiAeTkIbLnBShtgOIwOYTWmoGjLQTBnPdrbKOzqzZNZVdZojPqZeFuxo/Y0E72rnEQQWTFCmQ7wwJxtWnMaBBukqQqMjhqBD1octAR+B5693dLRRd4bgjVSOY57CwNh15S2bXLNNqXPbmQMhlM/8xWEPFTAWs/9CT7ARnUgOEPThQ3RrFKXyJvCByVVz75Ly1EEeVHucfN5PngsN13Y5P3qDSOSBhbfn6+zZqSrvfboMVF4lACwKYoTulUkQFTboxuHv1dsepqA0y7fntcOAnoVDwe8CryMUX4+vJb/ikKfFhkl1h+NyTRPzjbsghxEWvz5jsnaLeJGZl9yvkZoVpIpxfQFIE1ATORgfWiB4qs31bbl24EH8m3sTMsBzC4Ssjy8/5zd7hDP+mmT8IUIaoCNf8CCGONPpw9RzgbX2xdEhEKyR8DMjFEPH05F8lamHcj4u8z1w7pjRL1hzfu4IZSnawwJ7AYqClLH4Gfcvw9WdPTUazB4/A6/xAM0gKMCuueNYfegHmWReD/Xs2pMly14x7tzfT/h/b9N0+7diJ6KkieO6VFxc7kDhTUZZWZtcsmfigO4wFDXINZNJX/dSKGj8YO2pp8HvsMcTEL+EVE74ZRLCH2bq7GwATTxInRJpkAUBTYmeI8XtbHF6cEg+bignl90CFfmwdSrD+adSD1v7nHpWvysOkfFDu7rotthvlE8HpFKReaomoyiAybPUPABC2ftMOzLpD/iSgmVA4YrU9VJKxkOrMrjF8VnvG+bkTEBrqnRg1T8fL4zvzj1XB1g5ZVVry8UGeA+s9uJTze/iF6BmccHw==
- PUBLICATION_SECRET: AgBcsYTPFZtlCxaB6GhB+y2Bv2D+amWD188Hk5HgYVTz18yWpLlqQiylERizCGmqrH1lQM7UeVyhH45e90BVcZ2M2B33S1HKCtElIIf8ZpTI3XM2HhlZo0z9ij+lKi3te4e7ccjvgjni8FuxUv/C0LW9rXFJ93PsxdSQA8b0VyFohEKGmzFJIv+vuNopyFxpew2EtgSES/n3Km8sySdqFGiwwmPx2L/fUDfdvsW1pACsitvAZe3sDfi/Bq+d6psLQ45copWDhJDhP8GuPgVeogw9mHbTTeNnqHffEvBGQyQMmuf21CpFd4OCjuw6W7kyNxqno5eGs0pvQut7Bx+al7AHGKc4fNF3Paz9z+YZU2qCffdtUGtQ7ZpUvK07o03FCgb1KMBABrLBVxRurde+4AutBYhgSgRQhY2d3O9fwIUqB6oFF4YhBXo4YZUa0BdxZ0v0gz9VyaTj3/jjg2aC/VHi3hnI+zyO6cSWDzSiG7eh3XZfUo8gHwMY4hqqsNKJA++9GjMufsRRReHB+7GbDxiWidpiHD0eMUfR4AXj/4fUPk8mIR2HMHES3XlBvdOjHwvzXpjIyI0WJNMisv1K4IzOPLQ7MLmsVwa+LJntUYZxS7p74tn/DXDZ5bQ5pVERMKN8KcSqigAoLssYkUsUGMvnBRIhn8d8BwZhJvz5PXHuneyiNrQY85v/rp6j0Ls1/pCBQF6LifHFlmd3uVArVUskqvkxcfa17X84u6oIqL9hWFLdJyPnifsO+SUvyEF386V+npsXpbsuHPf3UjzzXAUQfiXMQrjQH+VjfjilQnTLUB1h1/iX146w
- ACTIONS_SECRET: AgCkkuGEYepd3F5aYpHWr1UKcFYkA2a0xzr4CFYZgQ2JAA0bW3iPuNEWEZUNQvH8fiwQXn1rv6tP47s8uxeefJzEyMmjxF6Zia9nmdrfwzEZ9/4rjSKT0yXqqsnpq/PaJhQKcMZV8MXTA//dheFGKZzWgoEUJM1VsoVDsoL5xwA+qq3Y72CtPsFOMoVtPBmUauvIySYVf2Nsn23s+nkP0crdwigpQ5030QQ+gyJEm8UPD68ibNkcGR5/NhFsNu29EFwbWLq0aXG0q7q3bS31Yo/7ZebRNBb7vcDqOcwu7xQBbg0OOweNbTp4xBaHZCEhme2WEc+FZIwFEWNyv7cpwLSjpJYtKZBbFEFzEEKINFlIKrLFEEWodS0/kKrlLRD1oFWilfa8xhk2ZegKA1G5wIrJ0BEgoIA9JnjPMEAny8/wEGSVJAUvsbKMp7NManU7kCRalD6GmSZ+Oy5ZEi8rCorNT1rAQSEERBpCMsglnW5XGewf4TlLrIM4ynki4DUlu8CdG3zJyqjMdYHAcL/2JI5pMjg4aM00aAS7ZlmYOTuREbp19NXXJf2ScCpXHjWSHHjxzAZpa4pxHZfnmkYWgo9g/eAq/W7WK9oBVO4Cla3p+cuH/sHsSIY/2dga/slAyhHzhzJ/xZeQT77a5FxMGNHrk5nv/XvzLWZO12Tnq2GINQsxJr0Xs08Xiqzpp9oypCgJkFKyAQlxlSgcqpo/cFgb2m+5M1YOX6agvZiXnC2izT7PmCvtUiRrCv9Fby0DYY3WayF5kI6lpoLcl1oIeY9jyzlRC760X7A20xk3+g70vWdBGwPV7xFx
template:
metadata:
name: hasura
diff --git a/docker-compose.yml b/docker-compose.yml
index a9a8394d2..792084f0f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -32,22 +32,6 @@ services:
HASURA_GRAPHQL_MIGRATIONS_DIR: /hasura-migrations
HASURA_GRAPHQL_METADATA_DIR: /hasura-metadata
- www:
- build:
- context: .
- dockerfile: targets/frontend/Dockerfile
- shm_size: 512m
- secrets:
- - npmTiptapToken
- depends_on:
- - hasura
- ports:
- - "3001:3001"
- env_file:
- - .env
- environment:
- HASURA_GRAPHQL_ENDPOINT: "http://hasura:8080/v1/graphql"
-
ingester:
build:
context: .
@@ -117,6 +101,21 @@ services:
depends_on:
- elasticsearch
+ www:
+ build:
+ context: .
+ dockerfile: targets/frontend/Dockerfile
+ secrets:
+ - npmTiptapToken
+ depends_on:
+ - hasura
+ ports:
+ - "3001:3000"
+ environment:
+ HASURA_GRAPHQL_ENDPOINT: "http://hasura:8080/v1/graphql"
+ NEXTAUTH_SECRET: "6ZYMHbt0mxOj9y6mTyG2nJVt2zWDEdckLJz248uflwI="
+ NEXTAUTH_URL: "http://localhost:3001"
+
export:
platform: linux/amd64
build:
diff --git a/shared/utils/src/glossary/launchWorker.ts b/shared/utils/src/glossary/launchWorker.ts
index 020d61fd0..1eb33ec4a 100644
--- a/shared/utils/src/glossary/launchWorker.ts
+++ b/shared/utils/src/glossary/launchWorker.ts
@@ -1,5 +1,5 @@
import { Glossary } from "@socialgouv/cdtn-types";
-import { Worker, isMainThread, parentPort, workerData } from "worker_threads";
+import { Worker, parentPort, workerData, isMainThread } from "worker_threads";
import {
addGlossaryContent,
addGlossaryContentToMarkdown,
@@ -11,9 +11,9 @@ export type GlossaryWorkerData = {
content?: string | null;
};
-export const addGlossaryContentWorker = async (
+export function addGlossaryContentWorker(
workerData: GlossaryWorkerData
-): Promise => {
+): Promise {
return new Promise((resolve, reject) => {
const worker = new Worker(__filename, {
workerData,
@@ -32,13 +32,10 @@ export const addGlossaryContentWorker = async (
}
});
});
-};
-
-console.log("GFR - isMainThread", isMainThread);
+}
if (!isMainThread) {
- console.log("GFR - worker qui se lance", workerData);
- const { glossary, type, content } = workerData as GlossaryWorkerData;
+ const { glossary, type, content }: GlossaryWorkerData = workerData;
if (type === "markdown") {
addGlossaryContentToMarkdown(glossary, content).then((res) => {
parentPort?.postMessage(res);
diff --git a/targets/frontend/next.config.js b/targets/frontend/next.config.js
index dc77bb614..0248c1065 100644
--- a/targets/frontend/next.config.js
+++ b/targets/frontend/next.config.js
@@ -15,7 +15,7 @@ module.exports = {
];
},
poweredByHeader: false,
- webpack: (config, { isServer, dev }) => {
+ webpack: (config, { isServer }) => {
config.module.rules.push({
exclude: /node_modules/,
loader: "graphql-tag/loader",
@@ -25,13 +25,16 @@ module.exports = {
test: /\.woff2$/,
type: "asset/resource",
});
- config.resolve = {
- ...config.resolve,
- fallback: {
- fs: false,
- worker_threads: false,
- },
- };
+ if (!isServer) {
+ config.resolve = {
+ ...config.resolve,
+ fallback: {
+ ...config.resolve.fallback,
+ fs: false,
+ worker_threads: false,
+ },
+ };
+ }
return config;
},
transpilePackages: [
diff --git a/targets/frontend/package.json b/targets/frontend/package.json
index beb280689..4ceda04e9 100644
--- a/targets/frontend/package.json
+++ b/targets/frontend/package.json
@@ -94,6 +94,7 @@
"scripts": {
"build": "yarn prebuild && next build",
"dev": "yarn predev && NEXTAUTH_URL=http://localhost:3001 NEXTAUTH_SECRET=6ZYMHbt0mxOj9y6mTyG2nJVt2zWDEdckLJz248uflwI= next dev -p 3001",
+ "simulate:start": "yarn build && NEXTAUTH_URL=http://localhost:3001 NEXTAUTH_SECRET=6ZYMHbt0mxOj9y6mTyG2nJVt2zWDEdckLJz248uflwI= yarn workspace frontend start -p 3001",
"lint": "next lint",
"precommit": "lint-staged",
"start": "next start",
From decc5346ca056bcadeb9365b398a41bca4020e76 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Fri, 7 Jun 2024 19:32:39 +0200
Subject: [PATCH 29/40] fix: donnnnnne
---
.../env/dev/templates/ingester.configmap.yaml | 1 +
.../preprod/templates/ingester.configmap.yaml | 1 +
.../prod/templates/ingester.configmap.yaml | 1 +
.kontinuous/values.yaml | 3 -
shared/utils/package.json | 5 -
shared/utils/src/glossary/fetchGlossary.ts | 30 -----
shared/utils/src/glossary/index.ts | 2 -
shared/utils/src/index.ts | 1 -
targets/export-elasticsearch/package.json | 5 +
targets/export-elasticsearch/request.http | 12 ++
.../src/controllers/glossary.ts | 40 ++++++
.../src/controllers/index.ts | 1 +
.../src/controllers/middlewares/glossary.ts | 28 +++++
.../src/controllers/middlewares/index.ts | 1 +
.../src/repositories/glossary.ts | 62 ++++++++++
.../src/repositories/graphql/mutation.ts | 8 ++
.../src/repositories/graphql/queries.ts | 22 ++++
targets/export-elasticsearch/src/server.ts | 20 ++-
.../src/services/glossary.ts | 115 ++++++++++++++++++
.../glossary/__mocks__/glossaryData.ts | 0
.../__tests__/addGlossaryContent.test.ts | 0
.../workers}/glossary/addGlossaryContent.ts | 2 +-
.../workers}/glossary/explodeGlossaryTerms.ts | 0
.../src/workers/glossary/index.ts | 1 +
.../glossary/insertWebComponentGlossary.ts | 0
.../src/workers}/glossary/launchWorker.ts | 6 +-
.../workers/glossary}/markdownProcessor.ts | 0
targets/frontend/next.config.js | 1 -
.../src/modules/common/getGlossaryContent.ts | 28 +++++
.../mapContributionToDocument.test.ts | 8 +-
.../contribution/mapContributionToDocument.ts | 17 +--
.../documents/api/documents.service.ts | 27 ++--
.../modules/glossary/fetchDocumentBySource.ts | 37 ------
.../frontend/src/modules/glossary/index.ts | 12 --
.../updateContributionsDocumentsGlossary.ts | 28 -----
.../src/modules/glossary/updateDocument.ts | 26 ----
...updateEditorialContentDocumentsGlossary.ts | 52 --------
targets/frontend/src/pages/api/export.ts | 2 +-
targets/frontend/src/pages/api/glossary.ts | 12 +-
.../src/transform/fiche-travail-emploi.ts | 32 +++--
yarn.lock | 10 +-
41 files changed, 404 insertions(+), 255 deletions(-)
delete mode 100644 shared/utils/src/glossary/fetchGlossary.ts
delete mode 100644 shared/utils/src/glossary/index.ts
create mode 100644 targets/export-elasticsearch/src/controllers/glossary.ts
create mode 100644 targets/export-elasticsearch/src/controllers/middlewares/glossary.ts
create mode 100644 targets/export-elasticsearch/src/repositories/glossary.ts
create mode 100644 targets/export-elasticsearch/src/services/glossary.ts
rename {shared/utils/src => targets/export-elasticsearch/src/workers}/glossary/__mocks__/glossaryData.ts (100%)
rename {shared/utils/src => targets/export-elasticsearch/src/workers}/glossary/__tests__/addGlossaryContent.test.ts (100%)
rename {shared/utils/src => targets/export-elasticsearch/src/workers}/glossary/addGlossaryContent.ts (94%)
rename {shared/utils/src => targets/export-elasticsearch/src/workers}/glossary/explodeGlossaryTerms.ts (100%)
create mode 100644 targets/export-elasticsearch/src/workers/glossary/index.ts
rename {shared/utils/src => targets/export-elasticsearch/src/workers}/glossary/insertWebComponentGlossary.ts (100%)
rename {shared/utils/src => targets/export-elasticsearch/src/workers}/glossary/launchWorker.ts (95%)
rename {shared/utils/src => targets/export-elasticsearch/src/workers/glossary}/markdownProcessor.ts (100%)
create mode 100644 targets/frontend/src/modules/common/getGlossaryContent.ts
delete mode 100644 targets/frontend/src/modules/glossary/fetchDocumentBySource.ts
delete mode 100644 targets/frontend/src/modules/glossary/index.ts
delete mode 100644 targets/frontend/src/modules/glossary/updateContributionsDocumentsGlossary.ts
delete mode 100644 targets/frontend/src/modules/glossary/updateDocument.ts
delete mode 100644 targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts
diff --git a/.kontinuous/env/dev/templates/ingester.configmap.yaml b/.kontinuous/env/dev/templates/ingester.configmap.yaml
index 04a64ecec..392140ece 100644
--- a/.kontinuous/env/dev/templates/ingester.configmap.yaml
+++ b/.kontinuous/env/dev/templates/ingester.configmap.yaml
@@ -5,3 +5,4 @@ metadata:
data:
NODE_ENV: "production"
HASURA_GRAPHQL_ENDPOINT: "http://hasura/v1/graphql"
+ URL_EXPORT: "http://export"
diff --git a/.kontinuous/env/preprod/templates/ingester.configmap.yaml b/.kontinuous/env/preprod/templates/ingester.configmap.yaml
index 04a64ecec..954a2886c 100644
--- a/.kontinuous/env/preprod/templates/ingester.configmap.yaml
+++ b/.kontinuous/env/preprod/templates/ingester.configmap.yaml
@@ -5,3 +5,4 @@ metadata:
data:
NODE_ENV: "production"
HASURA_GRAPHQL_ENDPOINT: "http://hasura/v1/graphql"
+ URL_EXPORT: "http://export"
\ No newline at end of file
diff --git a/.kontinuous/env/prod/templates/ingester.configmap.yaml b/.kontinuous/env/prod/templates/ingester.configmap.yaml
index 04a64ecec..392140ece 100644
--- a/.kontinuous/env/prod/templates/ingester.configmap.yaml
+++ b/.kontinuous/env/prod/templates/ingester.configmap.yaml
@@ -5,3 +5,4 @@ metadata:
data:
NODE_ENV: "production"
HASURA_GRAPHQL_ENDPOINT: "http://hasura/v1/graphql"
+ URL_EXPORT: "http://export"
diff --git a/.kontinuous/values.yaml b/.kontinuous/values.yaml
index 86cbeb54e..386bbdf66 100644
--- a/.kontinuous/values.yaml
+++ b/.kontinuous/values.yaml
@@ -61,9 +61,6 @@ www:
fsGroup: 1000
runAsUser: 1000
runAsGroup: 1000
- annotations:
- vpa.socialgouv.io/min-cpu: "2000m"
- vpa.socialgouv.io/min-memory: "3Gi"
export:
~chart: app
diff --git a/shared/utils/package.json b/shared/utils/package.json
index ee8b1d6b2..fa759b81d 100644
--- a/shared/utils/package.json
+++ b/shared/utils/package.json
@@ -8,11 +8,6 @@
"@urql/core": "^4.3.0",
"graphql": "^16.8.1",
"isomorphic-unfetch": "^4.0.2",
- "rehype-raw": "^5.1.0",
- "rehype-stringify": "^8.0.0",
- "remark-parse": "^9.0.0",
- "remark-rehype": "^8.1.0",
- "unified": "^9.2.2",
"uuid": "^9.0.1",
"winston": "3.3.3",
"xxhashjs": "^0.2.2"
diff --git a/shared/utils/src/glossary/fetchGlossary.ts b/shared/utils/src/glossary/fetchGlossary.ts
deleted file mode 100644
index 4b6b54640..000000000
--- a/shared/utils/src/glossary/fetchGlossary.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { Glossary } from "@socialgouv/cdtn-types";
-import { gqlClient, gqlDefaultProps } from "../gqlClient";
-
-const gqlGlossary = `
- query Glossary {
- glossary {
- term
- abbreviations
- definition
- variants
- references
- slug
- }
- }
-`;
-
-export async function fetchGlossary(
- props = gqlDefaultProps
-): Promise {
- const result = await gqlClient(props)
- .query<{ glossary: Glossary }>(gqlGlossary, {})
- .toPromise();
- if (result.error || !result.data) {
- console.error(result.error);
- throw new Error(
- `Error fetching glossary => ${JSON.stringify(result.error)}`
- );
- }
- return result.data.glossary;
-}
diff --git a/shared/utils/src/glossary/index.ts b/shared/utils/src/glossary/index.ts
deleted file mode 100644
index b8cf6b8b0..000000000
--- a/shared/utils/src/glossary/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./launchWorker";
-export * from "./fetchGlossary";
diff --git a/shared/utils/src/index.ts b/shared/utils/src/index.ts
index 27dd66642..6aa05eafa 100644
--- a/shared/utils/src/index.ts
+++ b/shared/utils/src/index.ts
@@ -4,4 +4,3 @@ export * from "./gqlClient";
export * from "./config";
export * from "./logger";
export * from "./dilaResolver";
-export * from "./glossary";
diff --git a/targets/export-elasticsearch/package.json b/targets/export-elasticsearch/package.json
index be03869bd..6b57b5b6b 100644
--- a/targets/export-elasticsearch/package.json
+++ b/targets/export-elasticsearch/package.json
@@ -43,6 +43,11 @@
"p-map": "^4.0.0",
"p-queue": "^6.6.2",
"reflect-metadata": "^0.1.13",
+ "rehype-raw": "^5.1.0",
+ "rehype-stringify": "^8.0.0",
+ "remark-parse": "^9.0.0",
+ "remark-rehype": "^8.1.0",
+ "unified": "^9.2.2",
"zod": "^3.14.2"
},
"devDependencies": {
diff --git a/targets/export-elasticsearch/request.http b/targets/export-elasticsearch/request.http
index a9f81213e..d26a7ab86 100644
--- a/targets/export-elasticsearch/request.http
+++ b/targets/export-elasticsearch/request.http
@@ -26,3 +26,15 @@ POST http://localhost:8787/sitemap
###
POST http://localhost:8787/copy
+
+###
+POST http://localhost:8787/glossary/all
+
+###
+POST http://localhost:8787/glossary
+content-type: application/json
+
+{
+ "type": "html",
+ "content": "Ceci est une abrogation
"
+}
diff --git a/targets/export-elasticsearch/src/controllers/glossary.ts b/targets/export-elasticsearch/src/controllers/glossary.ts
new file mode 100644
index 000000000..33e4d2960
--- /dev/null
+++ b/targets/export-elasticsearch/src/controllers/glossary.ts
@@ -0,0 +1,40 @@
+import { Request, Response } from "express";
+import { inject } from "inversify";
+import type { interfaces } from "inversify-express-utils";
+import {
+ controller,
+ httpPost,
+ request,
+ response,
+} from "inversify-express-utils";
+
+import { GlossaryService } from "../services/glossary";
+import { getName } from "../utils";
+import type { ValidatorCreateGlossaryType } from "./middlewares";
+import { GlossaryMiddleware } from "./middlewares";
+
+@controller("/glossary")
+export class GlossaryController implements interfaces.Controller {
+ constructor(
+ @inject(getName(GlossaryService))
+ private readonly service: GlossaryService
+ ) {}
+
+ @httpPost("/", getName(GlossaryMiddleware))
+ async getForOneContent(@request() req: Request) {
+ const body: ValidatorCreateGlossaryType = req.body;
+ const result = await this.service.getContentWithGlossary(
+ body.type,
+ body.content
+ );
+ return {
+ result,
+ };
+ }
+
+ @httpPost("/all")
+ async runGlossary(@response() res: Response) {
+ res.status(202);
+ return this.service.runGlossaryForAllContent();
+ }
+}
diff --git a/targets/export-elasticsearch/src/controllers/index.ts b/targets/export-elasticsearch/src/controllers/index.ts
index 7a3979305..242777881 100644
--- a/targets/export-elasticsearch/src/controllers/index.ts
+++ b/targets/export-elasticsearch/src/controllers/index.ts
@@ -1,2 +1,3 @@
export * from "./export";
export * from "./monitoring";
+export * from "./glossary";
diff --git a/targets/export-elasticsearch/src/controllers/middlewares/glossary.ts b/targets/export-elasticsearch/src/controllers/middlewares/glossary.ts
new file mode 100644
index 000000000..cd284e28e
--- /dev/null
+++ b/targets/export-elasticsearch/src/controllers/middlewares/glossary.ts
@@ -0,0 +1,28 @@
+import type { NextFunction, Request, Response } from "express";
+import { injectable } from "inversify";
+import { BaseMiddleware } from "inversify-express-utils";
+import { z } from "zod";
+
+import { name } from "../../utils";
+
+const ValidatorCreateGlossary = z.object({
+ type: z.enum(["markdown", "html"]),
+ content: z.string(),
+});
+
+export type ValidatorCreateGlossaryType = z.infer<
+ typeof ValidatorCreateGlossary
+>;
+
+@injectable()
+@name("GlossaryMiddleware")
+export class GlossaryMiddleware extends BaseMiddleware {
+ public handler(req: Request, res: Response, next: NextFunction): void {
+ const parse = ValidatorCreateGlossary.safeParse(req.body);
+ if (parse.success) {
+ next();
+ } else {
+ res.status(400).json({ errors: parse.error.issues });
+ }
+ }
+}
diff --git a/targets/export-elasticsearch/src/controllers/middlewares/index.ts b/targets/export-elasticsearch/src/controllers/middlewares/index.ts
index ffea9c3cf..4e13e8223 100644
--- a/targets/export-elasticsearch/src/controllers/middlewares/index.ts
+++ b/targets/export-elasticsearch/src/controllers/middlewares/index.ts
@@ -1 +1,2 @@
export * from "./export";
+export * from "./glossary";
diff --git a/targets/export-elasticsearch/src/repositories/glossary.ts b/targets/export-elasticsearch/src/repositories/glossary.ts
new file mode 100644
index 000000000..f520caad9
--- /dev/null
+++ b/targets/export-elasticsearch/src/repositories/glossary.ts
@@ -0,0 +1,62 @@
+import { gqlClient, logger } from "@shared/utils";
+import { injectable } from "inversify";
+
+import { name } from "../utils";
+import {
+ fetchDocumentQuery,
+ getGlossaryQuery,
+ updateDocumentWithCdtnIdMutation,
+} from "./graphql";
+import { Glossary, HasuraDocument } from "@socialgouv/cdtn-types";
+import { SourceRoute } from "@socialgouv/cdtn-sources";
+
+interface HasuraReturnFetchDocumentBySource {
+ documents: Pick, "cdtn_id" | "document">[];
+}
+
+@injectable()
+@name("GlossaryRepository")
+export class GlossaryRepository {
+ public async getGlossary(): Promise {
+ const result = await gqlClient()
+ .query<{ glossary: Glossary }>(getGlossaryQuery, {})
+ .toPromise();
+ if (result.error || !result.data) {
+ console.error(result.error);
+ throw new Error(
+ `Error fetching glossary => ${JSON.stringify(result.error)}`
+ );
+ }
+ return result.data.glossary;
+ }
+
+ public async fetchDocumentBySource(
+ source: SourceRoute
+ ): Promise {
+ const res = await gqlClient()
+ .query(fetchDocumentQuery, { source })
+ .toPromise();
+ if (res.error) {
+ throw res.error;
+ }
+ if (!res.data?.documents.length) {
+ logger.error("No contributions found");
+ return [];
+ }
+ return res.data.documents;
+ }
+
+ public async updateDocument(cdtnId: string, document: any): Promise {
+ const res = await gqlClient()
+ .mutation(updateDocumentWithCdtnIdMutation, {
+ cdtnId,
+ document,
+ })
+ .toPromise();
+ if (res.error) {
+ console.error(res.error);
+ throw res.error;
+ }
+ return;
+ }
+}
diff --git a/targets/export-elasticsearch/src/repositories/graphql/mutation.ts b/targets/export-elasticsearch/src/repositories/graphql/mutation.ts
index bac0b3311..71226ffab 100644
--- a/targets/export-elasticsearch/src/repositories/graphql/mutation.ts
+++ b/targets/export-elasticsearch/src/repositories/graphql/mutation.ts
@@ -33,3 +33,11 @@ mutation updateOneExportEsStatus($id: uuid!, $status: String!, $updated_at: time
documentsCount
}
}`;
+
+export const updateDocumentWithCdtnIdMutation = `
+mutation editDocument($cdtnId: String!, $document: jsonb) {
+ update_documents(where: {cdtn_id: {_eq: $cdtnId}}, _set: {document: $document}) {
+ affected_rows
+ }
+}
+`;
diff --git a/targets/export-elasticsearch/src/repositories/graphql/queries.ts b/targets/export-elasticsearch/src/repositories/graphql/queries.ts
index e2bebbf57..aa6a71655 100644
--- a/targets/export-elasticsearch/src/repositories/graphql/queries.ts
+++ b/targets/export-elasticsearch/src/repositories/graphql/queries.ts
@@ -110,3 +110,25 @@ query ListSupportedAgreements {
}
}
`;
+
+export const getGlossaryQuery = `
+ query Glossary {
+ glossary {
+ term
+ abbreviations
+ definition
+ variants
+ references
+ slug
+ }
+ }
+`;
+
+export const fetchDocumentQuery = `
+query fetchDocument($source: String) {
+ documents(where: {source: {_eq: $source}}) {
+ cdtn_id
+ document
+ }
+}
+`;
diff --git a/targets/export-elasticsearch/src/server.ts b/targets/export-elasticsearch/src/server.ts
index 0c82a35fd..d038adb31 100644
--- a/targets/export-elasticsearch/src/server.ts
+++ b/targets/export-elasticsearch/src/server.ts
@@ -7,7 +7,10 @@ import type { NextFunction, Request, Response } from "express";
import { Container } from "inversify";
import { InversifyExpressServer } from "inversify-express-utils";
-import { ExportEsRunMiddleware } from "./controllers/middlewares";
+import {
+ ExportEsRunMiddleware,
+ GlossaryMiddleware,
+} from "./controllers/middlewares";
import { S3Parameters, S3Repository, ExportRepository } from "./repositories";
import {
CopyContainerService,
@@ -17,11 +20,11 @@ import {
import { getName } from "./utils";
import { AgreementsService } from "./services/agreements";
import { AgreementsRepository } from "./repositories/agreements";
+import { GlossaryService } from "./services/glossary";
+import { GlossaryRepository } from "./repositories/glossary";
// set up container
export const rootContainer = new Container();
-/* REPOSITORIES */
-rootContainer.bind(getName(S3Repository)).to(S3Repository);
/* PARAMETERS OF CONTAINER */
rootContainer
.bind(S3Parameters.BUCKET_ACCESS_KEY)
@@ -50,16 +53,24 @@ rootContainer
rootContainer
.bind(S3Parameters.BUCKET_DEFAULT_FOLDER)
.toConstantValue(process.env.BUCKET_DEFAULT_FOLDER ?? `default`);
+/* REPOSITORIES */
+rootContainer.bind(getName(S3Repository)).to(S3Repository);
rootContainer
.bind(getName(ExportRepository))
.to(ExportRepository);
rootContainer
.bind(getName(AgreementsRepository))
.to(AgreementsRepository);
+rootContainer
+ .bind(getName(GlossaryRepository))
+ .to(GlossaryRepository);
/* MIDDLEWARE */
rootContainer
.bind(getName(ExportEsRunMiddleware))
.to(ExportEsRunMiddleware);
+rootContainer
+ .bind(getName(GlossaryMiddleware))
+ .to(GlossaryMiddleware);
/* SERVICES */
rootContainer.bind(getName(ExportService)).to(ExportService);
rootContainer.bind(getName(SitemapService)).to(SitemapService);
@@ -69,6 +80,9 @@ rootContainer
rootContainer
.bind(getName(CopyContainerService))
.to(CopyContainerService);
+rootContainer
+ .bind(getName(GlossaryService))
+ .to(GlossaryService);
// create server
const server = new InversifyExpressServer(rootContainer);
diff --git a/targets/export-elasticsearch/src/services/glossary.ts b/targets/export-elasticsearch/src/services/glossary.ts
new file mode 100644
index 000000000..21ad9e28c
--- /dev/null
+++ b/targets/export-elasticsearch/src/services/glossary.ts
@@ -0,0 +1,115 @@
+import { inject, injectable } from "inversify";
+import { getName, name } from "../utils";
+import { addGlossaryContentWorker } from "../workers/glossary";
+import { ValidatorCreateGlossaryType } from "../controllers/middlewares";
+import { GlossaryRepository } from "../repositories/glossary";
+import { logger } from "@shared/utils";
+import { Glossary } from "@socialgouv/cdtn-types";
+import { SOURCES } from "@socialgouv/cdtn-sources";
+
+@injectable()
+@name("GlossaryService")
+export class GlossaryService {
+ constructor(
+ @inject(getName(GlossaryRepository))
+ private readonly glossaryRepository: GlossaryRepository
+ ) {}
+
+ async getContentWithGlossary(
+ type: ValidatorCreateGlossaryType["type"],
+ content: ValidatorCreateGlossaryType["content"]
+ ): Promise {
+ const glossary = await this.glossaryRepository.getGlossary();
+ const result = await addGlossaryContentWorker({
+ glossary,
+ type,
+ content,
+ });
+ return result;
+ }
+
+ async runGlossaryForAllContent() {
+ const glossary = await this.glossaryRepository.getGlossary();
+ logger.info("=== Starting glossary update ===");
+ logger.info("Updating contributions documents glossary...");
+ await this.updateGlossaryForEditorialContents(glossary);
+ logger.info("Updating editorial content documents glossary...");
+ await this.updateGlossaryForContributions(glossary);
+ logger.info("=== Ending glossary update ===");
+ }
+
+ private async updateGlossaryForContributions(glossary: Glossary) {
+ const contributions = await this.glossaryRepository.fetchDocumentBySource(
+ SOURCES.CONTRIBUTIONS
+ );
+ logger.info(`Found ${contributions.length} contributions`);
+ for (let i = 0; i < contributions.length; i++) {
+ const document = contributions[i].document;
+ if (document.contentType === "ANSWER") {
+ const contentWithGlossary = await addGlossaryContentWorker({
+ glossary,
+ type: "html",
+ content: document.content,
+ });
+ await this.glossaryRepository.updateDocument(contributions[i].cdtn_id, {
+ ...document,
+ contentWithGlossary,
+ });
+ logger.info(
+ `Updated contribution ${i + 1}/${contributions.length} with glossary`
+ );
+ }
+ }
+ }
+
+ private async updateGlossaryForEditorialContents(glossary: Glossary) {
+ const editorialContents =
+ await this.glossaryRepository.fetchDocumentBySource(
+ SOURCES.EDITORIAL_CONTENT
+ );
+ logger.info(`Found ${editorialContents.length} editorial contents`);
+ for (let i = 0; i < editorialContents.length; i++) {
+ const document = editorialContents[i].document;
+ const introWithGlossary = await addGlossaryContentWorker({
+ glossary,
+ type: "markdown",
+ content: document.intro,
+ });
+ await this.glossaryRepository.updateDocument(
+ editorialContents[i].cdtn_id,
+ {
+ ...document,
+ introWithGlossary,
+ contents: await Promise.all(
+ document.contents.map(async (content: any) => {
+ return {
+ ...content,
+ blocks: await Promise.all(
+ content.blocks.map(async (block: any) => {
+ if ("markdown" in block) {
+ const htmlWithGlossary = await addGlossaryContentWorker({
+ glossary,
+ type: "markdown",
+ content: block.markdown,
+ });
+ return {
+ ...block,
+ htmlWithGlossary,
+ };
+ }
+ return block;
+ })
+ ),
+ };
+ })
+ ),
+ }
+ );
+ logger.info(
+ `Updated editorial content ${i + 1}/${
+ editorialContents.length
+ } with glossary`
+ );
+ }
+ }
+}
diff --git a/shared/utils/src/glossary/__mocks__/glossaryData.ts b/targets/export-elasticsearch/src/workers/glossary/__mocks__/glossaryData.ts
similarity index 100%
rename from shared/utils/src/glossary/__mocks__/glossaryData.ts
rename to targets/export-elasticsearch/src/workers/glossary/__mocks__/glossaryData.ts
diff --git a/shared/utils/src/glossary/__tests__/addGlossaryContent.test.ts b/targets/export-elasticsearch/src/workers/glossary/__tests__/addGlossaryContent.test.ts
similarity index 100%
rename from shared/utils/src/glossary/__tests__/addGlossaryContent.test.ts
rename to targets/export-elasticsearch/src/workers/glossary/__tests__/addGlossaryContent.test.ts
diff --git a/shared/utils/src/glossary/addGlossaryContent.ts b/targets/export-elasticsearch/src/workers/glossary/addGlossaryContent.ts
similarity index 94%
rename from shared/utils/src/glossary/addGlossaryContent.ts
rename to targets/export-elasticsearch/src/workers/glossary/addGlossaryContent.ts
index 634f378ec..e31bcb8de 100644
--- a/shared/utils/src/glossary/addGlossaryContent.ts
+++ b/targets/export-elasticsearch/src/workers/glossary/addGlossaryContent.ts
@@ -1,7 +1,7 @@
-import { markdownProcessor } from "../markdownProcessor";
import { explodeGlossaryTerms } from "./explodeGlossaryTerms";
import { insertWebComponentGlossary } from "./insertWebComponentGlossary";
import { Glossary } from "@socialgouv/cdtn-types";
+import { markdownProcessor } from "./markdownProcessor";
export const addGlossaryContent = (
glossary: Glossary,
diff --git a/shared/utils/src/glossary/explodeGlossaryTerms.ts b/targets/export-elasticsearch/src/workers/glossary/explodeGlossaryTerms.ts
similarity index 100%
rename from shared/utils/src/glossary/explodeGlossaryTerms.ts
rename to targets/export-elasticsearch/src/workers/glossary/explodeGlossaryTerms.ts
diff --git a/targets/export-elasticsearch/src/workers/glossary/index.ts b/targets/export-elasticsearch/src/workers/glossary/index.ts
new file mode 100644
index 000000000..d530ac06a
--- /dev/null
+++ b/targets/export-elasticsearch/src/workers/glossary/index.ts
@@ -0,0 +1 @@
+export * from "./launchWorker";
diff --git a/shared/utils/src/glossary/insertWebComponentGlossary.ts b/targets/export-elasticsearch/src/workers/glossary/insertWebComponentGlossary.ts
similarity index 100%
rename from shared/utils/src/glossary/insertWebComponentGlossary.ts
rename to targets/export-elasticsearch/src/workers/glossary/insertWebComponentGlossary.ts
diff --git a/shared/utils/src/glossary/launchWorker.ts b/targets/export-elasticsearch/src/workers/glossary/launchWorker.ts
similarity index 95%
rename from shared/utils/src/glossary/launchWorker.ts
rename to targets/export-elasticsearch/src/workers/glossary/launchWorker.ts
index 1eb33ec4a..8feec0d7c 100644
--- a/shared/utils/src/glossary/launchWorker.ts
+++ b/targets/export-elasticsearch/src/workers/glossary/launchWorker.ts
@@ -5,11 +5,11 @@ import {
addGlossaryContentToMarkdown,
} from "./addGlossaryContent";
-export type GlossaryWorkerData = {
+export interface GlossaryWorkerData {
glossary: Glossary;
type: "markdown" | "html";
- content?: string | null;
-};
+ content: string;
+}
export function addGlossaryContentWorker(
workerData: GlossaryWorkerData
diff --git a/shared/utils/src/markdownProcessor.ts b/targets/export-elasticsearch/src/workers/glossary/markdownProcessor.ts
similarity index 100%
rename from shared/utils/src/markdownProcessor.ts
rename to targets/export-elasticsearch/src/workers/glossary/markdownProcessor.ts
diff --git a/targets/frontend/next.config.js b/targets/frontend/next.config.js
index 0248c1065..de85dc1d3 100644
--- a/targets/frontend/next.config.js
+++ b/targets/frontend/next.config.js
@@ -31,7 +31,6 @@ module.exports = {
fallback: {
...config.resolve.fallback,
fs: false,
- worker_threads: false,
},
};
}
diff --git a/targets/frontend/src/modules/common/getGlossaryContent.ts b/targets/frontend/src/modules/common/getGlossaryContent.ts
new file mode 100644
index 000000000..3c8fed62b
--- /dev/null
+++ b/targets/frontend/src/modules/common/getGlossaryContent.ts
@@ -0,0 +1,28 @@
+import { URL_EXPORT } from "src/pages/api/export";
+
+export const getGlossaryContent = async (
+ type: "html" | "markdown",
+ content: string
+): Promise => {
+ const resultProcess = await fetch(URL_EXPORT + "/glossary", {
+ body: JSON.stringify({
+ type,
+ content,
+ }),
+ headers: {
+ "Content-Type": "application/json",
+ },
+ method: "POST",
+ })
+ .then((response) => {
+ if (!response.ok) {
+ throw new Error(`HTTP error on glossary! status: ${response.status}`);
+ }
+ return response.json();
+ })
+ .catch((error) => {
+ console.error(error);
+ throw new Error(`Error on glossary! ${error}`);
+ });
+ return resultProcess.result;
+};
diff --git a/targets/frontend/src/modules/contribution/__tests__/mapContributionToDocument.test.ts b/targets/frontend/src/modules/contribution/__tests__/mapContributionToDocument.test.ts
index 3e5f91cce..cc5747e49 100644
--- a/targets/frontend/src/modules/contribution/__tests__/mapContributionToDocument.test.ts
+++ b/targets/frontend/src/modules/contribution/__tests__/mapContributionToDocument.test.ts
@@ -5,10 +5,9 @@ import {
} from "@socialgouv/cdtn-types";
import { mapContributionToDocument } from "../mapContributionToDocument";
-jest.mock("@shared/utils", () => {
+jest.mock("../../common/getGlossaryContent.ts", () => {
return {
- ...jest.requireActual("@shared/utils"),
- fetchGlossary: jest.fn().mockResolvedValue([]),
+ getGlossaryContent: jest.fn(() => "mocked-glossary-content"),
};
});
@@ -142,8 +141,7 @@ describe("mapContributionToDocument", () => {
document: {
content:
"Quand une femme tombe enceinte et décide de partir en congé maternité, cette dernière a droit à des indemnités journalières de sécurité sociale venant indemniser la période durant laquelle elle ne peut plus travailler. Certaines conventions collectives prévoient également un maintien de salaire versé par l’employeur. Si le maintien est à 100%, dans ce cas, les deux mécanismes ne sont pas cumulables. Si le maintien est inférieur à 100%, le pourcentage de rémunération restant est indemnisé par les indemnités de Sécurité sociale.
Maintien de salaire Les salariées ayant au moins une année de présence continue dans l'entreprise à la date de l'accouchement ont droit à un maintien de salaire, après déduction des indemnités de Sécurité sociale, qui leur assure leur salaire habituel, et ce pendant une durée de 36 jours (en principe 18 jours avant l’accouchement, 18 jours après).
Pour les salariées cadres âgées de moins de 25 ans et les autres salariées âgées de moins de 22 ans à la date de l'accouchement, la période de 36 jours est augmentée de 2 jours par enfant à charge. L'indemnité complémentaire ne pourra pas être versée plus de 46 jours. Est considéré comme enfant à charge tout enfant à charge de la salariée au sens de la législation des prestations familiales et âgé de moins de 15 ans à la date de l'accouchement.
A noter : Les périodes de suspension du contrat de travail (maladie, etc.) sont prises en compte pour l'ancienneté.
Si la salariée ne respecte pas la condition d’ancienneté, elle n’a pas droit au maintien de salaire versé par l’employeur mais aura potentiellement droit aux indemnités journalières de Sécurité sociale si elle respecte ses conditions d’octroi.
Indemnités de Sécurité sociale Conditions d’ouverture des droits aux indemnités journalières de Sécurité sociale
Pour être indemnisée, la salariée doit remplir les conditions suivantes :
avoir :
soit travaillé au moins 150 heures au cours des 3 mois civils ou des 90 jours précédant l'arrêt,
soit travaillé au moins 600 heures au cours des 12 mois précédant l’arrêt de travail,
soit cotisé, au cours des 6 mois civils précédant l'arrêt, sur la base d'une rémunération au moins égale à 1 015 fois le montant du Smic horaire fixé au début de cette période,
soit cotisé au cours des 12 mois civils précédant l’arrêt, sur la base d'une rémunération au moins égale à 2030 fois le montant du Smic horaire fixé en début de période.
Exemple : le congé a débuté le 1er juillet 2023 pour une date présumée d'accouchement au 1er septembre 2023.
Le droit aux indemnités journalières est ouvert si :
La salariée était déjà affiliée à la Sécurité sociale avant novembre 2022 ;
et a travaillé soit au moins 150 heures entre le 1er avril 2023 et le 30 juin 2023, soit au moins 600 heures entre le 1er juillet 2022 et le 30 juin 2023, soit a cotisé entre le 1er janvier 2023 et le 30 juin 2023 sur la base d'une rémunération au moins égale à 11 439,05 €, soit a cotisé entre le 1er juillet 2022 et le 30 juin 2023 sur la base d’une rémunération au moins égale à 22 878,1 €.
Montant
La CPAM verse des indemnités journalières, dont le montant est fixé selon les étapes de calcul suivantes :
Calcul du salaire journalier de base : somme des 3 derniers salaires bruts perçus avant la date d'interruption du travail, divisé par 91,25.
Montant maximal du salaire journalier de base : le salaire pris en compte ne peut pas dépasser le plafond mensuel de la sécurité sociale en vigueur lors du dernier jour du mois qui précède l'arrêt (soit 3 666 € par mois en 2023, ou 3 428 € en 2022).
Taux forfaitaire appliqué par la CPAM : la CPAM retire à ce salaire journalier de base un taux forfaitaire de 21 %.
Montant minimal et montant maximal des indemnités journalières : le montant ne peut pas être inférieur à 10,24 € ni supérieur à 95,22 € par jour.
Versement
Les indemnités journalières sont versées tous les 14 jours.
",
- contentWithGlossary:
- "Quand une femme tombe enceinte et décide de partir en congé maternité, cette dernière a droit à des indemnités journalières de sécurité sociale venant indemniser la période durant laquelle elle ne peut plus travailler. Certaines conventions collectives prévoient également un maintien de salaire versé par l’employeur. Si le maintien est à 100%, dans ce cas, les deux mécanismes ne sont pas cumulables. Si le maintien est inférieur à 100%, le pourcentage de rémunération restant est indemnisé par les indemnités de Sécurité sociale.
Maintien de salaire Les salariées ayant au moins une année de présence continue dans l'entreprise à la date de l'accouchement ont droit à un maintien de salaire, après déduction des indemnités de Sécurité sociale, qui leur assure leur salaire habituel, et ce pendant une durée de 36 jours (en principe 18 jours avant l’accouchement, 18 jours après).
Pour les salariées cadres âgées de moins de 25 ans et les autres salariées âgées de moins de 22 ans à la date de l'accouchement, la période de 36 jours est augmentée de 2 jours par enfant à charge. L'indemnité complémentaire ne pourra pas être versée plus de 46 jours. Est considéré comme enfant à charge tout enfant à charge de la salariée au sens de la législation des prestations familiales et âgé de moins de 15 ans à la date de l'accouchement.
A noter : Les périodes de suspension du contrat de travail (maladie, etc.) sont prises en compte pour l'ancienneté.
Si la salariée ne respecte pas la condition d’ancienneté, elle n’a pas droit au maintien de salaire versé par l’employeur mais aura potentiellement droit aux indemnités journalières de Sécurité sociale si elle respecte ses conditions d’octroi.
Indemnités de Sécurité sociale Conditions d’ouverture des droits aux indemnités journalières de Sécurité sociale
Pour être indemnisée, la salariée doit remplir les conditions suivantes :
avoir :
soit travaillé au moins 150 heures au cours des 3 mois civils ou des 90 jours précédant l'arrêt,
soit travaillé au moins 600 heures au cours des 12 mois précédant l’arrêt de travail,
soit cotisé, au cours des 6 mois civils précédant l'arrêt, sur la base d'une rémunération au moins égale à 1 015 fois le montant du Smic horaire fixé au début de cette période,
soit cotisé au cours des 12 mois civils précédant l’arrêt, sur la base d'une rémunération au moins égale à 2030 fois le montant du Smic horaire fixé en début de période.
Exemple : le congé a débuté le 1er juillet 2023 pour une date présumée d'accouchement au 1er septembre 2023.
Le droit aux indemnités journalières est ouvert si :
La salariée était déjà affiliée à la Sécurité sociale avant novembre 2022 ;
et a travaillé soit au moins 150 heures entre le 1er avril 2023 et le 30 juin 2023, soit au moins 600 heures entre le 1er juillet 2022 et le 30 juin 2023, soit a cotisé entre le 1er janvier 2023 et le 30 juin 2023 sur la base d'une rémunération au moins égale à 11 439,05 €, soit a cotisé entre le 1er juillet 2022 et le 30 juin 2023 sur la base d’une rémunération au moins égale à 22 878,1 €.
Montant
La CPAM verse des indemnités journalières, dont le montant est fixé selon les étapes de calcul suivantes :
Calcul du salaire journalier de base : somme des 3 derniers salaires bruts perçus avant la date d'interruption du travail, divisé par 91,25.
Montant maximal du salaire journalier de base : le salaire pris en compte ne peut pas dépasser le plafond mensuel de la sécurité sociale en vigueur lors du dernier jour du mois qui précède l'arrêt (soit 3 666 € par mois en 2023, ou 3 428 € en 2022).
Taux forfaitaire appliqué par la CPAM : la CPAM retire à ce salaire journalier de base un taux forfaitaire de 21 %.
Montant minimal et montant maximal des indemnités journalières : le montant ne peut pas être inférieur à 10,24 € ni supérieur à 95,22 € par jour.
Versement
Les indemnités journalières sont versées tous les 14 jours.
",
+ contentWithGlossary: "mocked-glossary-content",
description:
"Quand une femme tombe enceinte et décide de partir en congé maternité, cette dernière a droit à des indemnités journalières de sécurité sociale venant indemniser la période durant laquelle elle ne peut plus travailler.",
contentType: "ANSWER",
diff --git a/targets/frontend/src/modules/contribution/mapContributionToDocument.ts b/targets/frontend/src/modules/contribution/mapContributionToDocument.ts
index 42106c868..a8aff6af5 100644
--- a/targets/frontend/src/modules/contribution/mapContributionToDocument.ts
+++ b/targets/frontend/src/modules/contribution/mapContributionToDocument.ts
@@ -5,12 +5,9 @@ import {
} from "@socialgouv/cdtn-types";
import { SOURCES } from "@socialgouv/cdtn-sources";
import { getReferences } from "./getReferences";
-import {
- generateCdtnId,
- addGlossaryContentWorker,
- fetchGlossary,
-} from "@shared/utils";
+import { generateCdtnId } from "@shared/utils";
import { generateContributionSlug } from "./generateSlug";
+import { getGlossaryContent } from "../common/getGlossaryContent";
async function getBaseDocument(
data: ContributionsAnswers,
@@ -18,17 +15,15 @@ async function getBaseDocument(
questionId: string
) => Promise>
) {
- const glossary = await fetchGlossary();
switch (data.content_type) {
case "ANSWER":
return {
type: "content",
content: data.content,
- contentWithGlossary: await addGlossaryContentWorker({
- glossary,
- type: "html",
- content: data.content,
- }),
+ contentWithGlossary: await getGlossaryContent(
+ "html",
+ data.content ?? ""
+ ),
};
case "GENERIC_NO_CDT":
return {
diff --git a/targets/frontend/src/modules/documents/api/documents.service.ts b/targets/frontend/src/modules/documents/api/documents.service.ts
index 7ab4066d2..8de51e639 100644
--- a/targets/frontend/src/modules/documents/api/documents.service.ts
+++ b/targets/frontend/src/modules/documents/api/documents.service.ts
@@ -2,12 +2,7 @@ import { DocumentsRepository } from "./documents.repository";
import { ConflictError, NotFoundError } from "src/lib/api/ApiErrors";
import { Information, InformationsRepository } from "src/modules/informations";
import { format, parseISO } from "date-fns";
-import {
- addGlossaryContentWorker,
- fetchGlossary,
- generateCdtnId,
- generateInitialId,
-} from "@shared/utils";
+import { generateCdtnId, generateInitialId } from "@shared/utils";
import slugify from "@socialgouv/cdtn-slugify";
import {
ContributionRepository,
@@ -20,6 +15,7 @@ import { generateContributionSlug } from "src/modules/contribution/generateSlug"
import { AgreementRepository } from "../../agreements/api";
import { Agreement } from "../../agreements";
import { SourceRoute } from "@socialgouv/cdtn-sources";
+import { getGlossaryContent } from "src/modules/common/getGlossaryContent";
export class DocumentsService {
private readonly informationsRepository: InformationsRepository;
@@ -46,12 +42,10 @@ export class DocumentsService {
data: Information,
document?: HasuraDocument
): Promise> {
- const glossary = await fetchGlossary();
- const introWithGlossary = await addGlossaryContentWorker({
- glossary,
- type: "markdown",
- content: data.intro,
- });
+ const introWithGlossary = await getGlossaryContent(
+ "markdown",
+ data.intro ?? ""
+ );
return {
cdtn_id: document?.cdtn_id ?? generateCdtnId(data.title),
initial_id: data.id ?? generateInitialId(),
@@ -88,11 +82,10 @@ export class DocumentsService {
title,
blocks: await Promise.all(
blocks.map(async (block) => {
- const htmlWithGlossary = await addGlossaryContentWorker({
- glossary,
- type: "markdown",
- content: block.content,
- });
+ const htmlWithGlossary = await getGlossaryContent(
+ "markdown",
+ block.content ?? ""
+ );
return {
type: block.type,
...(block.type === "content"
diff --git a/targets/frontend/src/modules/glossary/fetchDocumentBySource.ts b/targets/frontend/src/modules/glossary/fetchDocumentBySource.ts
deleted file mode 100644
index ce77ce26e..000000000
--- a/targets/frontend/src/modules/glossary/fetchDocumentBySource.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { gqlClient, logger } from "@shared/utils";
-import { SourceRoute } from "@socialgouv/cdtn-sources";
-import { HasuraDocument } from "@socialgouv/cdtn-types";
-
-const fetchDocumentQuery = `
-query fetchDocument($source: String) {
- documents(where: {source: {_eq: $source}}) {
- cdtn_id
- document
- }
-}
-`;
-
-interface HasuraReturn {
- documents: Pick, "cdtn_id" | "document">[];
-}
-
-export interface Document {
- cdtnId: string;
- document: any;
-}
-
-export async function fetchDocumentBySource(
- source: SourceRoute
-): Promise {
- const res = await gqlClient()
- .query(fetchDocumentQuery, { source })
- .toPromise();
- if (res.error) {
- throw res.error;
- }
- if (!res.data?.documents.length) {
- logger.error("No contributions found");
- return [];
- }
- return res.data.documents;
-}
diff --git a/targets/frontend/src/modules/glossary/index.ts b/targets/frontend/src/modules/glossary/index.ts
deleted file mode 100644
index 5a7a6d1c3..000000000
--- a/targets/frontend/src/modules/glossary/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { logger } from "@shared/utils";
-import { updateContributionsDocumentsGlossary } from "./updateContributionsDocumentsGlossary";
-import { updateEditorialContentDocumentsGlossary } from "./updateEditorialContentDocumentsGlossary";
-
-export const updateGlossary = async () => {
- logger.info("=== Starting glossary update ===");
- logger.info("Updating editorial content documents glossary...");
- await updateEditorialContentDocumentsGlossary();
- logger.info("Updating contributions documents glossary...");
- await updateContributionsDocumentsGlossary();
- logger.info("=== Ending glossary update ===");
-};
diff --git a/targets/frontend/src/modules/glossary/updateContributionsDocumentsGlossary.ts b/targets/frontend/src/modules/glossary/updateContributionsDocumentsGlossary.ts
deleted file mode 100644
index affb1ef8e..000000000
--- a/targets/frontend/src/modules/glossary/updateContributionsDocumentsGlossary.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { SOURCES } from "@socialgouv/cdtn-sources";
-import { fetchDocumentBySource } from "./fetchDocumentBySource";
-import { addGlossaryContentWorker, fetchGlossary } from "@shared/utils";
-import { updateDocument } from "./updateDocument";
-import { logger } from "@shared/utils";
-
-export const updateContributionsDocumentsGlossary = async () => {
- const glossary = await fetchGlossary();
- const contributions = await fetchDocumentBySource(SOURCES.CONTRIBUTIONS);
- logger.info(`Found ${contributions.length} contributions`);
- for (let i = 0; i < contributions.length; i++) {
- const document = contributions[i].document;
- if (document.contentType === "ANSWER") {
- const contentWithGlossary = await addGlossaryContentWorker({
- glossary,
- type: "html",
- content: document.content,
- });
- await updateDocument(contributions[i].cdtn_id, {
- ...document,
- contentWithGlossary,
- });
- logger.info(
- `Updated contribution ${i + 1}/${contributions.length} with glossary`
- );
- }
- }
-};
diff --git a/targets/frontend/src/modules/glossary/updateDocument.ts b/targets/frontend/src/modules/glossary/updateDocument.ts
deleted file mode 100644
index c6ae3209e..000000000
--- a/targets/frontend/src/modules/glossary/updateDocument.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { gqlClient } from "@shared/utils";
-
-const updateDocumentWithCdtnId = `
-mutation editDocument($cdtnId: String!, $document: jsonb) {
- update_documents(where: {cdtn_id: {_eq: $cdtnId}}, _set: {document: $document}) {
- affected_rows
- }
-}
-`;
-
-export async function updateDocument(
- cdtnId: string,
- document: any
-): Promise {
- const res = await gqlClient()
- .mutation(updateDocumentWithCdtnId, {
- cdtnId,
- document,
- })
- .toPromise();
- if (res.error) {
- console.error(res.error);
- throw res.error;
- }
- return;
-}
diff --git a/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts b/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts
deleted file mode 100644
index 243459164..000000000
--- a/targets/frontend/src/modules/glossary/updateEditorialContentDocumentsGlossary.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { SOURCES } from "@socialgouv/cdtn-sources";
-import { fetchDocumentBySource } from "./fetchDocumentBySource";
-import { addGlossaryContentWorker, fetchGlossary, logger } from "@shared/utils";
-import { updateDocument } from "./updateDocument";
-
-export const updateEditorialContentDocumentsGlossary = async () => {
- const glossary = await fetchGlossary();
- const editorialContents = await fetchDocumentBySource(
- SOURCES.EDITORIAL_CONTENT
- );
- logger.info(`Found ${editorialContents.length} editorial contents`);
- for (let i = 0; i < editorialContents.length; i++) {
- const document = editorialContents[i].document;
- const introWithGlossary = await addGlossaryContentWorker({
- glossary,
- type: "markdown",
- content: document.intro,
- });
- await updateDocument(editorialContents[i].cdtn_id, {
- ...document,
- introWithGlossary,
- contents: await Promise.all(
- document.contents.map(async (content: any) => {
- return {
- ...content,
- blocks: await Promise.all(
- content.blocks.map(async (block: any) => {
- if ("markdown" in block) {
- const htmlWithGlossary = await addGlossaryContentWorker({
- glossary,
- type: "markdown",
- content: block.markdown,
- });
- return {
- ...block,
- htmlWithGlossary,
- };
- }
- return block;
- })
- ),
- };
- })
- ),
- });
- logger.info(
- `Updated editorial content ${i + 1}/${
- editorialContents.length
- } with glossary`
- );
- }
-};
diff --git a/targets/frontend/src/pages/api/export.ts b/targets/frontend/src/pages/api/export.ts
index 8ae22bfca..e470604e8 100644
--- a/targets/frontend/src/pages/api/export.ts
+++ b/targets/frontend/src/pages/api/export.ts
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from "next";
-const URL_EXPORT = process.env.URL_EXPORT ?? "http://localhost:8787";
+export const URL_EXPORT = process.env.URL_EXPORT ?? "http://localhost:8787";
const main = (req: NextApiRequest, res: NextApiResponse) => {
// GET
diff --git a/targets/frontend/src/pages/api/glossary.ts b/targets/frontend/src/pages/api/glossary.ts
index ddec2408c..1f02dd466 100644
--- a/targets/frontend/src/pages/api/glossary.ts
+++ b/targets/frontend/src/pages/api/glossary.ts
@@ -1,7 +1,7 @@
import { getServerSession } from "next-auth/next";
import { authOptions } from "./auth/[...nextauth]";
import { NextApiRequest, NextApiResponse } from "next";
-import { updateGlossary } from "src/modules/glossary";
+import { URL_EXPORT } from "./export";
export default async function handler(
req: NextApiRequest,
@@ -19,9 +19,11 @@ export default async function handler(
return;
}
- updateGlossary();
-
- return res.json({
- message: "Success",
+ fetch(URL_EXPORT + "/glossary/all", {
+ headers: {
+ "Content-Type": "application/json",
+ },
+ method: "POST",
});
+ res.status(201).json({ message: "Glossary content is being updated." });
}
diff --git a/targets/ingester/src/transform/fiche-travail-emploi.ts b/targets/ingester/src/transform/fiche-travail-emploi.ts
index 356d3bef4..2aefa7e6f 100644
--- a/targets/ingester/src/transform/fiche-travail-emploi.ts
+++ b/targets/ingester/src/transform/fiche-travail-emploi.ts
@@ -7,7 +7,8 @@ import {
articleToReference,
createReferenceResolver,
} from "../lib/referenceResolver";
-import { addGlossaryContentWorker, fetchGlossary } from "@shared/utils";
+
+const URL_EXPORT = process.env.URL_EXPORT || "http://localhost:8787";
export default async function getFicheTravailEmploi(pkgName: string) {
const [fichesMT, cdt] = await Promise.all([
@@ -16,7 +17,6 @@ export default async function getFicheTravailEmploi(pkgName: string) {
`@socialgouv/legi-data/data/LEGITEXT000006072050.json`
),
]);
- const glossary = await fetchGlossary();
const resolveCdtReference = createReferenceResolver(cdt);
const result = await Promise.all(
fichesMT.map(async ({ pubId, sections, ...content }) => {
@@ -26,11 +26,29 @@ export default async function getFicheTravailEmploi(pkgName: string) {
is_searchable: true,
sections: await Promise.all(
sections.map(async ({ references, ...section }) => {
- const htmlWithGlossary = await addGlossaryContentWorker({
- glossary,
- type: "html",
- content: section.html,
- });
+ const resultProcess = await fetch(URL_EXPORT + "/glossary", {
+ body: JSON.stringify({
+ type: "html",
+ content: section.html,
+ }),
+ headers: {
+ "Content-Type": "application/json",
+ },
+ method: "POST",
+ })
+ .then((response) => {
+ if (!response.ok) {
+ throw new Error(
+ `HTTP error on glossary! status: ${response.status}`
+ );
+ }
+ return response.json();
+ })
+ .catch((error) => {
+ throw new Error(`Error on glossary! ${error}`);
+ });
+ const htmlWithGlossary = resultProcess.result;
+
return {
...section,
htmlWithGlossary,
diff --git a/yarn.lock b/yarn.lock
index 610218e49..c98c8fa76 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4821,12 +4821,7 @@ __metadata:
graphql: ^16.8.1
isomorphic-unfetch: ^4.0.2
jest: ^29.7.0
- rehype-raw: ^5.1.0
- rehype-stringify: ^8.0.0
- remark-parse: ^9.0.0
- remark-rehype: ^8.1.0
typescript: ^5.4.3
- unified: ^9.2.2
uuid: ^9.0.1
winston: 3.3.3
xxhashjs: ^0.2.2
@@ -11520,10 +11515,15 @@ __metadata:
p-map: ^4.0.0
p-queue: ^6.6.2
reflect-metadata: ^0.1.13
+ rehype-raw: ^5.1.0
+ rehype-stringify: ^8.0.0
+ remark-parse: ^9.0.0
+ remark-rehype: ^8.1.0
rimraf: 3.0.2
supertest: ^6.2.2
timekeeper: ^2.2.0
typescript: ^5.4.3
+ unified: ^9.2.2
zod: ^3.14.2
languageName: unknown
linkType: soft
From e2ab2c62bef25f27088f107f4af9d77ba40e5ec3 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Fri, 7 Jun 2024 19:49:33 +0200
Subject: [PATCH 30/40] fix: done
---
.../src/ingester/common/fetchGlossary.ts | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/targets/export-elasticsearch/src/ingester/common/fetchGlossary.ts b/targets/export-elasticsearch/src/ingester/common/fetchGlossary.ts
index 0dcfe2e32..f63228808 100644
--- a/targets/export-elasticsearch/src/ingester/common/fetchGlossary.ts
+++ b/targets/export-elasticsearch/src/ingester/common/fetchGlossary.ts
@@ -1,11 +1,24 @@
-import { fetchGlossary } from "@shared/utils";
+import { gqlClient } from "@shared/utils";
import { context } from "../context";
import { Glossary } from "@socialgouv/cdtn-types";
+import { getGlossaryQuery } from "../../repositories/graphql";
export const getGlossary = async (): Promise => {
const graphqlEndpoint: string =
context.get("cdtnAdminEndpoint") || "http://localhost:8080/v1/graphql";
const adminSecret: string =
context.get("cdtnAdminEndpointSecret") || "admin1";
- return await fetchGlossary({ adminSecret, graphqlEndpoint });
+ const result = await gqlClient({
+ graphqlEndpoint,
+ adminSecret,
+ })
+ .query<{ glossary: Glossary }>(getGlossaryQuery, {})
+ .toPromise();
+ if (result.error || !result.data) {
+ console.error(result.error);
+ throw new Error(
+ `Error fetching glossary => ${JSON.stringify(result.error)}`
+ );
+ }
+ return result.data.glossary;
};
From 4e082a7ab5ed5dfbcc2b8ce6e24f154a17ea8381 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Fri, 7 Jun 2024 19:55:47 +0200
Subject: [PATCH 31/40] fix: done
---
.kontinuous/env/prod/values.yaml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/.kontinuous/env/prod/values.yaml b/.kontinuous/env/prod/values.yaml
index 2d3c522f7..43a66dfdb 100644
--- a/.kontinuous/env/prod/values.yaml
+++ b/.kontinuous/env/prod/values.yaml
@@ -17,11 +17,11 @@ www:
value: https://cdtn-admin.fabrique.social.gouv.fr
resources:
limits:
- cpu: "1000m"
- memory: "2Gi"
- requests:
- cpu: "250m"
+ cpu: "200m"
memory: "512Mi"
+ requests:
+ cpu: "100m"
+ memory: "256Mi"
export:
replicas: 1
@@ -31,7 +31,7 @@ export:
memory: "4096Mi"
requests:
cpu: "1000m"
- memory: "512Mi"
+ memory: "896Mi"
hasura:
autoscale:
From 1e780d99510f59a229bb18e2af9f1018664b5401 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Mon, 10 Jun 2024 09:42:26 +0200
Subject: [PATCH 32/40] empty
From 7afed52cdf1b68eec1e7f5c29588689aa06aa937 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Mon, 10 Jun 2024 10:02:59 +0200
Subject: [PATCH 33/40] fix: done
---
targets/ingester/package.json | 1 +
targets/ingester/src/transform/fiche-travail-emploi.ts | 3 ++-
yarn.lock | 8 ++++++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/targets/ingester/package.json b/targets/ingester/package.json
index 0fc4eefeb..e00435a68 100644
--- a/targets/ingester/package.json
+++ b/targets/ingester/package.json
@@ -14,6 +14,7 @@
"query-string": "7.0.1",
"semver": "7.3.5",
"tar-fs": "2.1.1",
+ "undici": "^6.18.2",
"unist-util-filter": "^2.0.3",
"unist-util-find": "1.0.2",
"unist-util-flat-filter": "1.0.0",
diff --git a/targets/ingester/src/transform/fiche-travail-emploi.ts b/targets/ingester/src/transform/fiche-travail-emploi.ts
index 2aefa7e6f..4e7ab7456 100644
--- a/targets/ingester/src/transform/fiche-travail-emploi.ts
+++ b/targets/ingester/src/transform/fiche-travail-emploi.ts
@@ -1,6 +1,7 @@
import slugify from "@socialgouv/cdtn-slugify";
import { SOURCES } from "@socialgouv/cdtn-sources";
import type { FicheTravailEmploi } from "@socialgouv/fiches-travail-data-types";
+import { fetch } from "undici";
import { getJson } from "../lib/getJson";
import {
@@ -26,7 +27,7 @@ export default async function getFicheTravailEmploi(pkgName: string) {
is_searchable: true,
sections: await Promise.all(
sections.map(async ({ references, ...section }) => {
- const resultProcess = await fetch(URL_EXPORT + "/glossary", {
+ const resultProcess: any = await fetch(URL_EXPORT + "/glossary", {
body: JSON.stringify({
type: "html",
content: section.html,
diff --git a/yarn.lock b/yarn.lock
index c98c8fa76..af52cdcf0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -13368,6 +13368,7 @@ __metadata:
ts-jest: ^27.0.5
ts-node: 10.8.0
typescript: ^5.4.3
+ undici: ^6.18.2
unist-util-filter: ^2.0.3
unist-util-find: 1.0.2
unist-util-flat-filter: 1.0.0
@@ -22370,6 +22371,13 @@ __metadata:
languageName: node
linkType: hard
+"undici@npm:^6.18.2":
+ version: 6.18.2
+ resolution: "undici@npm:6.18.2"
+ checksum: c20e47bd4f959c00d24516756b178190f0a9ae000007e875f1f68c8e7f3f9a68b0a7faa03f3d030ddd71a9e3feb558fbce661b5229a0aa8380cfbe1cea4281e4
+ languageName: node
+ linkType: hard
+
"unfetch@npm:^5.0.0":
version: 5.0.0
resolution: "unfetch@npm:5.0.0"
From 94745d3a93dd58f8b3fb4ffabd35a94f2cb233b6 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Mon, 10 Jun 2024 10:38:24 +0200
Subject: [PATCH 34/40] fix: performance
---
.kontinuous/env/prod/values.yaml | 6 +++---
.kontinuous/values.yaml | 3 +++
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/.kontinuous/env/prod/values.yaml b/.kontinuous/env/prod/values.yaml
index 43a66dfdb..0dedcc4a8 100644
--- a/.kontinuous/env/prod/values.yaml
+++ b/.kontinuous/env/prod/values.yaml
@@ -27,11 +27,11 @@ export:
replicas: 1
resources:
limits:
- cpu: "1500m"
+ cpu: "2000m"
memory: "4096Mi"
requests:
- cpu: "1000m"
- memory: "896Mi"
+ cpu: "1500m"
+ memory: "2Gi"
hasura:
autoscale:
diff --git a/.kontinuous/values.yaml b/.kontinuous/values.yaml
index 386bbdf66..197793ecb 100644
--- a/.kontinuous/values.yaml
+++ b/.kontinuous/values.yaml
@@ -81,6 +81,9 @@ export:
fsGroup: 1000
runAsUser: 1000
runAsGroup: 1000
+ annotations:
+ vpa.socialgouv.io/min-cpu: "1500m"
+ vpa.socialgouv.io/min-memory: "2Gi"
hasura:
~chart: hasura
From 18ed206da15565f1821a369b8076b735a5f9bcb9 Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Mon, 10 Jun 2024 11:41:02 +0200
Subject: [PATCH 35/40] fix: performance
---
targets/export-elasticsearch/src/services/glossary.ts | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/targets/export-elasticsearch/src/services/glossary.ts b/targets/export-elasticsearch/src/services/glossary.ts
index 21ad9e28c..b6f3291c4 100644
--- a/targets/export-elasticsearch/src/services/glossary.ts
+++ b/targets/export-elasticsearch/src/services/glossary.ts
@@ -1,5 +1,5 @@
import { inject, injectable } from "inversify";
-import { getName, name } from "../utils";
+import { getName, name, sendMattermostMessage } from "../utils";
import { addGlossaryContentWorker } from "../workers/glossary";
import { ValidatorCreateGlossaryType } from "../controllers/middlewares";
import { GlossaryRepository } from "../repositories/glossary";
@@ -30,12 +30,20 @@ export class GlossaryService {
async runGlossaryForAllContent() {
const glossary = await this.glossaryRepository.getGlossary();
+ await sendMattermostMessage(
+ `**Glossaire:** Lancement du processus ⏳`,
+ process.env.MATTERMOST_CHANNEL_EXPORT
+ );
logger.info("=== Starting glossary update ===");
logger.info("Updating contributions documents glossary...");
await this.updateGlossaryForEditorialContents(glossary);
logger.info("Updating editorial content documents glossary...");
await this.updateGlossaryForContributions(glossary);
logger.info("=== Ending glossary update ===");
+ await sendMattermostMessage(
+ `**Glossaire:** Fin du processus ⌛️`,
+ process.env.MATTERMOST_CHANNEL_EXPORT
+ );
}
private async updateGlossaryForContributions(glossary: Glossary) {
From 687d80ca793e30913a6ead2a02c31821f039638c Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Mon, 17 Jun 2024 16:56:04 +0200
Subject: [PATCH 36/40] fix: returning
---
targets/frontend/src/pages/glossary/index.tsx | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/targets/frontend/src/pages/glossary/index.tsx b/targets/frontend/src/pages/glossary/index.tsx
index a4295a3bd..d3999f115 100644
--- a/targets/frontend/src/pages/glossary/index.tsx
+++ b/targets/frontend/src/pages/glossary/index.tsx
@@ -184,7 +184,9 @@ const SynchronizeButton = () => {
alert(`Un problème est survenu, l'erreur est : ${resultJson.message}`);
return;
}
- alert("Le lexique est en cours de synchronisation");
+ alert(
+ "Le glossaire est en cours de synchronisation. Cette opération prends du temps (environ 30 minutes). veuillez ne pas faire de modification entre temps."
+ );
setIsDisabled(true);
};
return (
@@ -197,7 +199,7 @@ const SynchronizeButton = () => {
disabled={isDisabled}
>
- Synchroniser le lexique
+ Mettre à jour le glossaire sur toutes les pages
);
};
From 248674fd0f4b2824f1fba2bb9d2c6b31e085943f Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Tue, 18 Jun 2024 12:03:19 +0200
Subject: [PATCH 37/40] fix: performance
---
.kontinuous/env/prod/values.yaml | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/.kontinuous/env/prod/values.yaml b/.kontinuous/env/prod/values.yaml
index 0dedcc4a8..1a9a0350d 100644
--- a/.kontinuous/env/prod/values.yaml
+++ b/.kontinuous/env/prod/values.yaml
@@ -36,6 +36,13 @@ export:
hasura:
autoscale:
enabled: true
+ resources:
+ limits:
+ cpu: "2000m"
+ memory: "4Gi"
+ requests:
+ cpu: "1000m"
+ memory: "1Gi"
envFrom:
- secretRef:
name: pg-app
From b859eb4977392264d153675cdcef7eb0828eac0a Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Tue, 18 Jun 2024 12:17:55 +0200
Subject: [PATCH 38/40] fix: fetch
---
.../utils/src/__tests__/url-generator.test.ts | 6 ++++--
targets/alert-cli/Dockerfile | 1 -
targets/alert-cli/tsconfig.json | 15 +++++++++----
.../src/services/glossary.ts | 4 ++--
targets/ingester/Dockerfile | 1 -
targets/ingester/package.json | 1 -
.../src/transform/fiche-travail-emploi.ts | 1 -
targets/ingester/tsconfig.json | 15 +++++++++----
tsconfig.build.json | 21 -------------------
tsconfig.json | 9 --------
yarn.lock | 8 -------
11 files changed, 28 insertions(+), 54 deletions(-)
delete mode 100644 tsconfig.build.json
delete mode 100644 tsconfig.json
diff --git a/shared/utils/src/__tests__/url-generator.test.ts b/shared/utils/src/__tests__/url-generator.test.ts
index 9125b1989..82c0537e2 100644
--- a/shared/utils/src/__tests__/url-generator.test.ts
+++ b/shared/utils/src/__tests__/url-generator.test.ts
@@ -1,7 +1,9 @@
-import { generateFichesSpRef } from "../url-generator";
+import { generateFichesSpRef } from "../urlGenerator";
describe("url-generator", () => {
test("generateFichesSpRef with audience camel case", () => {
- expect(generateFichesSpRef("associations", "article")).toEqual("https://www.service-public.fr/associations/vosdroits/article");
+ expect(generateFichesSpRef("associations", "article")).toEqual(
+ "https://www.service-public.fr/associations/vosdroits/article"
+ );
});
});
diff --git a/targets/alert-cli/Dockerfile b/targets/alert-cli/Dockerfile
index 177eadd8c..5446a1eba 100644
--- a/targets/alert-cli/Dockerfile
+++ b/targets/alert-cli/Dockerfile
@@ -25,7 +25,6 @@ COPY --from=build-utils /app/shared/utils /app/shared/utils
COPY --from=build-types /app/shared/types /app/shared/types
COPY targets/alert-cli ./targets/alert-cli
-COPY tsconfig.build.json ./
RUN yarn workspace alert-cli build
diff --git a/targets/alert-cli/tsconfig.json b/targets/alert-cli/tsconfig.json
index 898102d09..9a6538ba3 100644
--- a/targets/alert-cli/tsconfig.json
+++ b/targets/alert-cli/tsconfig.json
@@ -1,11 +1,18 @@
{
- "extends": "../../tsconfig.build.json",
"compilerOptions": {
- "target": "es2015",
+ "target": "ESNext",
"module": "es2015",
"moduleResolution": "node",
"allowJs": true,
- "lib": ["DOM"]
+ "lib": ["es2020", "DOM"],
+ "outDir": "./lib",
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "noEmit": true,
+ "skipLibCheck": true,
+ "strict": true,
+ "resolveJsonModule": true
},
- "include": ["src", "@types"]
+ "include": ["src", "@types"],
+ "exclude": ["node_modules", "dist"]
}
diff --git a/targets/export-elasticsearch/src/services/glossary.ts b/targets/export-elasticsearch/src/services/glossary.ts
index b6f3291c4..395ac64a4 100644
--- a/targets/export-elasticsearch/src/services/glossary.ts
+++ b/targets/export-elasticsearch/src/services/glossary.ts
@@ -31,7 +31,7 @@ export class GlossaryService {
async runGlossaryForAllContent() {
const glossary = await this.glossaryRepository.getGlossary();
await sendMattermostMessage(
- `**Glossaire:** Lancement du processus ⏳`,
+ `**Glossaire:** Début de la synchronisation du glossaire ⏳`,
process.env.MATTERMOST_CHANNEL_EXPORT
);
logger.info("=== Starting glossary update ===");
@@ -41,7 +41,7 @@ export class GlossaryService {
await this.updateGlossaryForContributions(glossary);
logger.info("=== Ending glossary update ===");
await sendMattermostMessage(
- `**Glossaire:** Fin du processus ⌛️`,
+ `**Glossaire:** Fin de la synchronisation du glossaire ⌛️`,
process.env.MATTERMOST_CHANNEL_EXPORT
);
}
diff --git a/targets/ingester/Dockerfile b/targets/ingester/Dockerfile
index 4fbba7314..e2e6796cb 100644
--- a/targets/ingester/Dockerfile
+++ b/targets/ingester/Dockerfile
@@ -25,7 +25,6 @@ FROM deps as dist
COPY --from=build-types /app/shared/types /app/shared/types
COPY --from=build-utils /app/shared/utils /app/shared/utils
COPY targets/ingester targets/ingester
-COPY tsconfig.build.json .
RUN yarn workspace ingester build
diff --git a/targets/ingester/package.json b/targets/ingester/package.json
index e00435a68..0fc4eefeb 100644
--- a/targets/ingester/package.json
+++ b/targets/ingester/package.json
@@ -14,7 +14,6 @@
"query-string": "7.0.1",
"semver": "7.3.5",
"tar-fs": "2.1.1",
- "undici": "^6.18.2",
"unist-util-filter": "^2.0.3",
"unist-util-find": "1.0.2",
"unist-util-flat-filter": "1.0.0",
diff --git a/targets/ingester/src/transform/fiche-travail-emploi.ts b/targets/ingester/src/transform/fiche-travail-emploi.ts
index 4e7ab7456..0440a01ca 100644
--- a/targets/ingester/src/transform/fiche-travail-emploi.ts
+++ b/targets/ingester/src/transform/fiche-travail-emploi.ts
@@ -1,7 +1,6 @@
import slugify from "@socialgouv/cdtn-slugify";
import { SOURCES } from "@socialgouv/cdtn-sources";
import type { FicheTravailEmploi } from "@socialgouv/fiches-travail-data-types";
-import { fetch } from "undici";
import { getJson } from "../lib/getJson";
import {
diff --git a/targets/ingester/tsconfig.json b/targets/ingester/tsconfig.json
index 0291b810f..27a28c9b8 100644
--- a/targets/ingester/tsconfig.json
+++ b/targets/ingester/tsconfig.json
@@ -1,11 +1,18 @@
{
- "extends": "../../tsconfig.build.json",
"compilerOptions": {
- "target": "es2015",
+ "target": "ESNext",
"moduleResolution": "node",
"esModuleInterop": true,
- "allowJs": true
+ "allowJs": true,
+ "outDir": "./lib",
+ "forceConsistentCasingInFileNames": true,
+ "noEmit": true,
+ "skipLibCheck": true,
+ "strict": true,
+ "lib": ["es2020"],
+ "module": "commonjs",
+ "resolveJsonModule": true
},
"include": ["src", "@types"],
- "exclude": ["__tests__", "node_modules", "data"]
+ "exclude": ["__tests__", "node_modules", "dist", "data"]
}
diff --git a/tsconfig.build.json b/tsconfig.build.json
deleted file mode 100644
index 6927696f6..000000000
--- a/tsconfig.build.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "compilerOptions": {
- "outDir": "./lib",
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
- "noEmit": true,
- "skipLibCheck": true,
- "strict": true,
- "lib": [
- "es2020"
- ],
- "module": "commonjs",
- "resolveJsonModule": true
- },
- "exclude": [
- "__tests__",
- "node_modules",
- "dist",
- "lib",
- ]
-}
diff --git a/tsconfig.json b/tsconfig.json
deleted file mode 100644
index f492a2a1f..000000000
--- a/tsconfig.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "extends": "./tsconfig.build.json",
- "compilerOptions": {
- "baseUrl": ".",
- "paths": {
- "@shared/*": ["shared/*/src"]
- }
- }
-}
diff --git a/yarn.lock b/yarn.lock
index af52cdcf0..c98c8fa76 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -13368,7 +13368,6 @@ __metadata:
ts-jest: ^27.0.5
ts-node: 10.8.0
typescript: ^5.4.3
- undici: ^6.18.2
unist-util-filter: ^2.0.3
unist-util-find: 1.0.2
unist-util-flat-filter: 1.0.0
@@ -22371,13 +22370,6 @@ __metadata:
languageName: node
linkType: hard
-"undici@npm:^6.18.2":
- version: 6.18.2
- resolution: "undici@npm:6.18.2"
- checksum: c20e47bd4f959c00d24516756b178190f0a9ae000007e875f1f68c8e7f3f9a68b0a7faa03f3d030ddd71a9e3feb558fbce661b5229a0aa8380cfbe1cea4281e4
- languageName: node
- linkType: hard
-
"unfetch@npm:^5.0.0":
version: 5.0.0
resolution: "unfetch@npm:5.0.0"
From a603b4454adfb8eadc3e9fac278ad971005db64d Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Tue, 18 Jun 2024 12:21:57 +0200
Subject: [PATCH 39/40] fix: build encore
---
targets/alert-cli/tsconfig.json | 4 ++--
targets/ingester/tsconfig.json | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/targets/alert-cli/tsconfig.json b/targets/alert-cli/tsconfig.json
index 9a6538ba3..1525212f8 100644
--- a/targets/alert-cli/tsconfig.json
+++ b/targets/alert-cli/tsconfig.json
@@ -1,10 +1,10 @@
{
"compilerOptions": {
"target": "ESNext",
- "module": "es2015",
+ "module": "ESNext",
"moduleResolution": "node",
"allowJs": true,
- "lib": ["es2020", "DOM"],
+ "lib": ["ESNext"],
"outDir": "./lib",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
diff --git a/targets/ingester/tsconfig.json b/targets/ingester/tsconfig.json
index 27a28c9b8..1e0e7629b 100644
--- a/targets/ingester/tsconfig.json
+++ b/targets/ingester/tsconfig.json
@@ -9,7 +9,7 @@
"noEmit": true,
"skipLibCheck": true,
"strict": true,
- "lib": ["es2020"],
+ "lib": ["ESNext"],
"module": "commonjs",
"resolveJsonModule": true
},
From 03b007bd862c309ce0f8ae213ccf726d325b30fa Mon Sep 17 00:00:00 2001
From: maxgfr <25312957+maxgfr@users.noreply.github.com>
Date: Tue, 18 Jun 2024 12:29:41 +0200
Subject: [PATCH 40/40] fix: build encore
---
targets/alert-cli/tsconfig.json | 4 ++--
targets/ingester/tsconfig.json | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/targets/alert-cli/tsconfig.json b/targets/alert-cli/tsconfig.json
index 1525212f8..ccd8ac4f5 100644
--- a/targets/alert-cli/tsconfig.json
+++ b/targets/alert-cli/tsconfig.json
@@ -1,10 +1,10 @@
{
"compilerOptions": {
- "target": "ESNext",
+ "target": "ES2015",
"module": "ESNext",
"moduleResolution": "node",
"allowJs": true,
- "lib": ["ESNext"],
+ "lib": ["dom", "dom.iterable", "esnext"],
"outDir": "./lib",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
diff --git a/targets/ingester/tsconfig.json b/targets/ingester/tsconfig.json
index 1e0e7629b..da36f45b0 100644
--- a/targets/ingester/tsconfig.json
+++ b/targets/ingester/tsconfig.json
@@ -1,6 +1,6 @@
{
"compilerOptions": {
- "target": "ESNext",
+ "target": "ES2015",
"moduleResolution": "node",
"esModuleInterop": true,
"allowJs": true,
@@ -9,7 +9,7 @@
"noEmit": true,
"skipLibCheck": true,
"strict": true,
- "lib": ["ESNext"],
+ "lib": ["dom", "dom.iterable", "esnext"],
"module": "commonjs",
"resolveJsonModule": true
},