@tricoteuses/senat 2.13.2 → 2.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/loaders.d.ts CHANGED
@@ -83,7 +83,7 @@ export declare function loadSenatTexteContent(dataDir: string, textePathFromData
83
83
  export declare function loadSenatCompteRenduContent(dataDir: string, session: number, debatId: string | number): {
84
84
  item: CompteRendu | null;
85
85
  };
86
- export declare function iterLoadSenatAgendasGrouped(dataDir: string, session: number | undefined): Generator<IterItem<GroupedReunion>>;
86
+ export declare function iterLoadSenatAgendas(dataDir: string, session: number | undefined): Generator<IterItem<GroupedReunion>>;
87
87
  export declare function iterLoadSenatCirconscriptions(dataDir: string, options?: {}): Generator<IterItem<CirconscriptionResult>>;
88
88
  export declare function iterLoadSenatOrganismes(dataDir: string, options?: {}): Generator<IterItem<OrganismeResult>>;
89
89
  export declare function iterLoadSenatSenateurs(dataDir: string, options?: {}): Generator<IterItem<SenateurResult>>;
package/lib/loaders.js CHANGED
@@ -183,7 +183,7 @@ export function loadSenatCompteRenduContent(dataDir, session, debatId) {
183
183
  const json = fs.readFileSync(fullPath, { encoding: "utf8" });
184
184
  return { item: JSON.parse(json) };
185
185
  }
186
- export function* iterLoadSenatAgendasGrouped(dataDir, session) {
186
+ export function* iterLoadSenatAgendas(dataDir, session) {
187
187
  const baseDir = path.join(dataDir, AGENDA_FOLDER, DATA_TRANSFORMED_FOLDER, String(session ?? ""));
188
188
  if (!fs.existsSync(baseDir))
189
189
  return;
@@ -13,6 +13,7 @@ export declare function findAuteurs(): Promise<{
13
13
  prenom: any;
14
14
  matricule: any;
15
15
  }[]>;
16
+ export declare function createActesLegislatifs(dossier: DossierLegislatifResult): any;
16
17
  export declare function getCodeActeLecture(codeNatureDossier: string, typeLecture: string, assemblee: string): string | null;
17
18
  export declare function getCodeActeTexte(codeParent: string | null, texteOrigine: string): string | null;
18
19
  export type DossierLegislatifResult = InferResult<typeof findAllDossiersQuery>[0];
@@ -235,6 +235,75 @@ export async function findAuteurs() {
235
235
  return findAuteursQuery
236
236
  .execute();
237
237
  }
238
+ export function createActesLegislatifs(dossier) {
239
+ const actesLegislatifs = (dossier["lectures"] || []).map((lecture) => {
240
+ const lecturesAssemblee = (lecture["lectures_assemblee"] || []).map((lectureAss) => {
241
+ const codeParent = getCodeActeLecture(dossier["code_nature_dossier"], lecture["type_lecture"], lectureAss["assemblee"]);
242
+ const textesWithCodeActe = (lectureAss["textes"] || []).map((texte) => ({
243
+ code_acte: getCodeActeTexte(codeParent, texte["origine"]),
244
+ ...texte
245
+ }));
246
+ // Ajout étape -COM-FOND après chaque -DEPOT
247
+ let textesWithComFond = [];
248
+ for (let i = 0; i < textesWithCodeActe.length; i++) {
249
+ const t = textesWithCodeActe[i];
250
+ textesWithComFond.push(t);
251
+ if (t.code_acte && t.code_acte.endsWith('-DEPOT')) {
252
+ textesWithComFond.push({
253
+ ...t,
254
+ code_acte: t.code_acte.replace('-DEPOT', '-COM-FOND')
255
+ });
256
+ }
257
+ }
258
+ const { textes, rapports, ...lectureAssWithoutTextes } = lectureAss;
259
+ return {
260
+ type_lecture: lecture["type_lecture"],
261
+ ordre_lecture: lecture["ordre_lecture"],
262
+ libelle_lecture: lecture["libelle"],
263
+ code_acte: codeParent,
264
+ actes_legislatifs: textesWithComFond,
265
+ ...lectureAssWithoutTextes,
266
+ };
267
+ });
268
+ return lecturesAssemblee;
269
+ });
270
+ if (dossier["date_decision_CoC"]) {
271
+ actesLegislatifs.push({
272
+ type_lecture: "Conseil constitutionnel",
273
+ ordre_lecture: null,
274
+ libelle_lecture: "Conseil constitutionnel",
275
+ code_acte: "CC",
276
+ actes_legislatifs: [{
277
+ code_acte: "CC-SAISIE",
278
+ date: dossier["date_saisine_CoC"],
279
+ libelle_decision_CoC: dossier["libelle_decision_CoC"],
280
+ date_decision_CoC: dossier["date_decision_CoC"],
281
+ num_decision_CoC: dossier["num_decision_CoC"],
282
+ url_decision_CoC: dossier["url_decision_CoC"],
283
+ url_dossier_CoC: dossier["url_dossier_CoC"],
284
+ date_saisine_CoC: dossier["date_saisine_CoC"],
285
+ condition_saisine_CoC: dossier["condition_saisine_CoC"],
286
+ }]
287
+ });
288
+ }
289
+ if (dossier["date_publication_JO"]) {
290
+ actesLegislatifs.push({
291
+ type_lecture: "Promulgation",
292
+ ordre_lecture: null,
293
+ libelle_lecture: "Promulgation",
294
+ code_acte: "PROM",
295
+ actes_legislatifs: [{
296
+ code_acte: "PROM-PUB",
297
+ date: dossier["date_publication_JO"],
298
+ titre_JO: dossier["titre_JO"],
299
+ date_publication_JO: dossier["date_publication_JO"],
300
+ numero_JO: dossier["numero_JO"],
301
+ url_JO: dossier["url_JO"]
302
+ }]
303
+ });
304
+ }
305
+ return actesLegislatifs;
306
+ }
238
307
  export function getCodeActeLecture(codeNatureDossier, typeLecture, assemblee) {
239
308
  const codeAssemblee = assemblee === "Sénat" ? "SN" : assemblee === "Assemblée nationale" ? "AN" : null;
240
309
  if (typeLecture === "Commission mixte paritaire") {
@@ -268,30 +337,26 @@ export function getCodeActeLecture(codeNatureDossier, typeLecture, assemblee) {
268
337
  }
269
338
  export function getCodeActeTexte(codeParent, texteOrigine) {
270
339
  if (codeParent === "CMP") {
271
- if (texteOrigine === "adopté par l'Assemblée Nationale") {
272
- return "CMP-DEBATS-SN";
340
+ if (texteOrigine === "de la commission") {
341
+ return "CMP-DEBATS-AN";
273
342
  }
274
- else if (texteOrigine === "adopté définitivement par le Sénat") {
275
- return "PROM";
343
+ else if (texteOrigine === "adopté par l'Assemblée Nationale" || texteOrigine === "adopté par l'Assemblée nationale") {
344
+ return "CMP-DEBATS-SN";
276
345
  }
277
346
  }
278
- if (texteOrigine === "transmis au Sénat" || texteOrigine === "déposé au Sénat") {
347
+ if (texteOrigine === "transmis au Sénat" || texteOrigine === "déposé au Sénat" ||
348
+ texteOrigine === "transmis à l'Assemblée nationale" || texteOrigine === "déposé à l'Assemblée nationale" ||
349
+ texteOrigine === "transmis à l'Assemblée Nationale" || texteOrigine === "déposé à l'Assemblée Nationale") {
279
350
  return `${codeParent}-DEPOT`;
280
351
  }
281
- // Rajouter une étape similaire -COM-FOND
282
352
  if (texteOrigine === "de la commission" || texteOrigine === "de la commission (AN)" || texteOrigine === "résultat des travaux de la commission") {
283
353
  return `${codeParent}-DEBATS-SEANCE`;
284
354
  }
285
- if (texteOrigine === "déposé à l'Assemblée Nationale") {
286
- return `${codeParent}-DEPOT`;
287
- }
288
355
  if (texteOrigine === "retiré par l'auteur") {
289
356
  return `${codeParent}-RTRINI`;
290
357
  }
291
- if (texteOrigine === "adopté par le Sénat" || texteOrigine === "adopté par l'Assemblée Nationale" || texteOrigine === "rejeté par le Sénat") {
292
- return `${codeParent}-DEC`;
358
+ if (texteOrigine.includes("adopté") || texteOrigine.includes("rejeté") || texteOrigine.includes("modifié")) {
359
+ return `${codeParent}-DEBATS-DEC`;
293
360
  }
294
- // Rajouter une étape CC-SAISIE
295
- // Rajouter une étape PROM-
296
361
  return null;
297
362
  }
@@ -5,7 +5,7 @@ import path from "path";
5
5
  import { datasets, EnabledDatasets, getEnabledDatasets } from "../datasets";
6
6
  import { DATA_ORIGINAL_FOLDER, DOCUMENT_METADATA_FILE, DOSLEG_DOSSIERS_FOLDER, SCRUTINS_FOLDER, RAPPORT_FOLDER, SENS_CIRCONSCRIPTIONS_FOLDER, SENS_ORGANISMES_FOLDER, SENS_SENATEURS_FOLDER, TEXTE_FOLDER, } from "../loaders";
7
7
  import { findAllAmendements, findAllCirconscriptions, findAllDebats, findAllDossiers, findAllScrutins, findAllOrganismes, findAllQuestions, findAllSens, findAuteurs, findSenatRapportUrls, findSenatTexteUrls, } from "../model";
8
- import { getCodeActeLecture, getCodeActeTexte } from "../model/dosleg";
8
+ import { createActesLegislatifs } from "../model/dosleg";
9
9
  import { UNDEFINED_SESSION } from "../types/sessions";
10
10
  import { getSessionFromDate, getSessionFromSignet } from "./datautil";
11
11
  import { commonOptions } from "./shared/cli_helpers";
@@ -121,28 +121,11 @@ async function convertDatasetDosLeg(dataDir, options) {
121
121
  }
122
122
  loiReorganizedDir = path.join(dossiersReorganizedDir, String(session));
123
123
  fs.ensureDirSync(loiReorganizedDir);
124
- // Ajout de code_acte à chaque lecture du dossier
125
- const lecturesWithCodeActe = (loi["lectures"] || []).map((lecture) => {
126
- const lecturesAssemblee = (lecture["lectures_assemblee"] || []).map((lectureAss) => {
127
- const codeParent = getCodeActeLecture(loi["code_nature_dossier"], lecture["type_lecture"], lectureAss["assemblee"]);
128
- const textesWithCodeActe = (lectureAss["textes"] || []).map((texte) => ({
129
- ...texte,
130
- code_acte: getCodeActeTexte(codeParent, texte["origine"])
131
- }));
132
- return {
133
- ...lectureAss,
134
- code_acte: codeParent,
135
- textes: textesWithCodeActe
136
- };
137
- });
138
- return {
139
- ...lecture,
140
- lectures_assemblee: lecturesAssemblee
141
- };
142
- });
143
- const loiWithCodeActe = { ...loi, lectures: lecturesWithCodeActe };
124
+ // Ajout des actes législatifs au dossier
125
+ const actesLegislatifs = createActesLegislatifs(loi);
126
+ const loiWithActes = { ...loi, actes_legislatifs: actesLegislatifs };
144
127
  const scrutinFileName = `${loi["signet"]}.json`;
145
- fs.writeJSONSync(path.join(loiReorganizedDir, scrutinFileName), loiWithCodeActe, {
128
+ fs.writeJSONSync(path.join(loiReorganizedDir, scrutinFileName), loiWithActes, {
146
129
  spaces: 2,
147
130
  });
148
131
  }
@@ -4,7 +4,7 @@ import commandLineArgs from "command-line-args";
4
4
  import fs from "fs-extra";
5
5
  import fsp from "fs/promises";
6
6
  import path from "path";
7
- import { AGENDA_FOLDER, DATA_TRANSFORMED_FOLDER, iterLoadSenatAgendasGrouped } from "../loaders";
7
+ import { AGENDA_FOLDER, DATA_TRANSFORMED_FOLDER, iterLoadSenatAgendas } from "../loaders";
8
8
  import { getSessionsFromStart } from "../types/sessions";
9
9
  import { commonOptions } from "./shared/cli_helpers";
10
10
  // ===================== Constants =====================
@@ -398,7 +398,7 @@ async function processGroupedReunion(agenda, session, dataDir) {
398
398
  async function processAll(dataDir, sessions) {
399
399
  console.log("Process all Agendas and fetch video's url");
400
400
  for (const session of sessions) {
401
- for (const { item: agenda } of iterLoadSenatAgendasGrouped(dataDir, session)) {
401
+ for (const { item: agenda } of iterLoadSenatAgendas(dataDir, session)) {
402
402
  try {
403
403
  await processGroupedReunion(agenda, session, dataDir);
404
404
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/senat",
3
- "version": "2.13.2",
3
+ "version": "2.14.2",
4
4
  "description": "Handle French Sénat's open data",
5
5
  "keywords": [
6
6
  "France",