@tricoteuses/senat 3.1.16 → 3.1.18

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.
@@ -118,7 +118,7 @@ export function buildActesLegislatifs(dossier) {
118
118
  const commissionRaps = rapports.filter((r) => r.code_organisme === commission.code_organisme);
119
119
  const firstRapDate = commissionRaps.find((r) => r.date)?.date;
120
120
  const firstReunionDate = commission.reunions?.find((r) => r.date)?.date;
121
- const acteDate = firstRapDate ?? firstReunionDate;
121
+ const acteDate = firstRapDate ?? firstReunionDate ?? lecAss.date_publication_amendements_commission;
122
122
  if (acteDate) {
123
123
  const rap = commissionRaps.find((r) => r.date);
124
124
  actes.push({
@@ -407,6 +407,26 @@ function mergeCommissionsSaisies(lectures) {
407
407
  }
408
408
  }
409
409
  }
410
+ // Rapports avec une commission qui n'est pas encore dans commissions_saisies.
411
+ // Les avis de commission (ex: DEVE) peuvent être absents des saisines ameli
412
+ // (table ameli.sai) alors qu'un rapport a déjà été déposé. On les ajoute
413
+ // comme saisines "avis" pour que buildActesLegislatifs puisse créer l'acte.
414
+ if (lecAss.rapports) {
415
+ for (const rap of lecAss.rapports) {
416
+ if (!rap.code_organisme || knownOrgs.has(rap.code_organisme))
417
+ continue;
418
+ const rapType = (rap.type || "").toLowerCase();
419
+ if (rapType.includes("avis") || rapType.includes("information")) {
420
+ commissionsSaisies.push({
421
+ code_organisme: rap.code_organisme,
422
+ libelle_organisme: null,
423
+ type_saisine: "avis",
424
+ deleguee_au_fond: null,
425
+ });
426
+ knownOrgs.add(rap.code_organisme);
427
+ }
428
+ }
429
+ }
410
430
  for (const commission of commissionsSaisies) {
411
431
  commission.reunions = reunions_commission
412
432
  ?.filter((r) => r.code_organisme === commission.code_organisme)
@@ -44,7 +44,7 @@ export declare function loadSenatTexteContent(dataDir: string, session: number |
44
44
  export declare function loadSenatCompteRenduContent(dataDir: string, session: number, debatId: string | number): {
45
45
  item: CompteRendu | null;
46
46
  };
47
- export declare function iterLoadSenatAgendas(dataDir: string, session: number | undefined): Generator<IterItem<Reunion>>;
47
+ export declare function iterLoadSenatAgendas(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<Reunion>>;
48
48
  export declare function iterLoadSenatCirconscriptions(dataDir: string, options?: {}): Generator<IterItem<CirconscriptionResult>>;
49
49
  export declare function iterLoadSenatOrganismes(dataDir: string, options?: {}): Generator<IterItem<OrganismeResult>>;
50
50
  export declare function iterLoadSenatSenateurs(dataDir: string, options?: {}): Generator<IterItem<SenateurResult>>;
@@ -1,4 +1,3 @@
1
- import fsex from "fs-extra";
2
1
  import fs from "fs";
3
2
  import path from "path";
4
3
  import * as git from "./git.js";
@@ -207,30 +206,16 @@ export function loadSenatCompteRenduContent(dataDir, session, debatId) {
207
206
  const json = fs.readFileSync(fullPath, { encoding: "utf8" });
208
207
  return { item: JSON.parse(json) };
209
208
  }
210
- export function* iterLoadSenatAgendas(dataDir, session) {
211
- const baseDir = path.join(dataDir, AGENDA_FOLDER, DATA_TRANSFORMED_FOLDER, String(session ?? ""));
212
- if (!fs.existsSync(baseDir))
213
- return;
214
- const files = (fs.readdirSync(baseDir) || []).filter((f) => f.startsWith("RUSN") && f.endsWith(".json")).sort();
215
- for (const fileName of files) {
216
- const filePath = path.join(baseDir, fileName);
217
- let raw;
218
- try {
219
- raw = fsex.readJSONSync(filePath);
220
- }
221
- catch {
222
- continue; // JSON invalide
223
- }
224
- if (!raw || typeof raw !== "object")
225
- continue;
226
- const gr = raw;
209
+ export function* iterLoadSenatAgendas(dataDir, session, options = {}) {
210
+ for (const reunionItem of iterLoadSenatItems(dataDir, AGENDA_FOLDER, session, DATA_TRANSFORMED_FOLDER, options)) {
211
+ const gr = reunionItem.item;
227
212
  if (!gr.uid || !gr.date || !gr.titre)
228
213
  continue;
229
- const reunion = {
214
+ reunionItem.item = {
230
215
  ...gr,
231
216
  events: Array.isArray(gr.events) ? gr.events : [],
232
217
  };
233
- yield { item: reunion };
218
+ yield reunionItem;
234
219
  }
235
220
  }
236
221
  export function* iterLoadSenatCirconscriptions(dataDir, options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/senat",
3
- "version": "3.1.16",
3
+ "version": "3.1.18",
4
4
  "description": "Handle French Sénat's open data",
5
5
  "keywords": [
6
6
  "France",