@tricoteuses/senat 2.16.3 → 2.16.5
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/model/compte_rendu.d.ts +9 -0
- package/lib/model/compte_rendu.js +325 -0
- package/lib/model/debats.d.ts +26 -2
- package/lib/model/debats.js +65 -57
- package/lib/model/dosleg.d.ts +0 -13
- package/lib/model/dosleg.js +0 -13
- package/lib/model/index.d.ts +1 -1
- package/lib/model/index.js +1 -1
- package/lib/raw_types/db.d.ts +11389 -0
- package/lib/raw_types/db.js +5 -0
- package/lib/scripts/convert_data.js +50 -56
- package/lib/scripts/retrieve_comptes_rendus.d.ts +6 -0
- package/lib/scripts/retrieve_comptes_rendus.js +274 -0
- package/lib/scripts/retrieve_open_data.js +75 -76
- package/package.json +2 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CompteRendu, Sommaire } from "../types/compte_rendu";
|
|
2
|
+
import { TimeSlot } from "../types/agenda";
|
|
3
|
+
export declare function parseCompteRenduSlotFromFile(xmlFilePath: string, wantedSlot: TimeSlot, firstSlotOfDay?: TimeSlot): Promise<CompteRendu | null>;
|
|
4
|
+
export declare function sessionStartYearFromDate(d: Date): number;
|
|
5
|
+
export declare function parseYYYYMMDD(yyyymmdd: string): Date | null;
|
|
6
|
+
export declare function deriveTitreObjetFromSommaire(sommaire: Sommaire | undefined, slot: TimeSlot): {
|
|
7
|
+
titre: string;
|
|
8
|
+
objet: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import * as cheerio from "cheerio";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { computeIntervalsBySlot } from "../utils/cr_spliting";
|
|
5
|
+
import { norm } from "./util";
|
|
6
|
+
const asArray = (x) => x == null ? [] : Array.isArray(x) ? x : [x];
|
|
7
|
+
const toInt = (s) => Number.isFinite(Number(s)) ? Number(s) : Number.POSITIVE_INFINITY;
|
|
8
|
+
export async function parseCompteRenduSlotFromFile(xmlFilePath, wantedSlot, firstSlotOfDay) {
|
|
9
|
+
try {
|
|
10
|
+
const raw = fs.readFileSync(xmlFilePath, "utf8");
|
|
11
|
+
const $ = cheerio.load(raw, { xml: false });
|
|
12
|
+
const metadonnees = extractMetadonnees($, xmlFilePath);
|
|
13
|
+
const order = $("body *").toArray();
|
|
14
|
+
const idx = new Map(order.map((el, i) => [el, i]));
|
|
15
|
+
const intervalsAll = computeIntervalsBySlot($, idx, firstSlotOfDay);
|
|
16
|
+
const intervals = intervalsAll.filter(iv => iv.slot === wantedSlot);
|
|
17
|
+
if (intervals.length === 0) {
|
|
18
|
+
console.warn(`[CRI] no intervals for ${path.basename(xmlFilePath)} [${wantedSlot}]`);
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
metadonnees.sommaire = extractSommaireForIntervals($, idx, intervals);
|
|
22
|
+
const points = [];
|
|
23
|
+
let ordre = 0;
|
|
24
|
+
const addPoint = (p) => points.push({ ...p, ordre_absolu_seance: String(++ordre) });
|
|
25
|
+
// Titles
|
|
26
|
+
$("cri\\:titreS1 p.titre_S1").each((_, el) => {
|
|
27
|
+
if (!elementInAnyInterval(el, idx, intervals))
|
|
28
|
+
return;
|
|
29
|
+
const t = normalizeTitle(norm($(el).text() || ""));
|
|
30
|
+
if (t)
|
|
31
|
+
addPoint({ code_grammaire: "TITRE_TEXTE_DISCUSSION", texte: { _: t }, code_style: "Titre" });
|
|
32
|
+
});
|
|
33
|
+
// Interventions
|
|
34
|
+
$("div.intervenant").each((_, block) => {
|
|
35
|
+
if (!elementInAnyInterval(block, idx, intervals))
|
|
36
|
+
return;
|
|
37
|
+
const $block = $(block);
|
|
38
|
+
$block.find([
|
|
39
|
+
"p[class^='titre_S']",
|
|
40
|
+
"p.mention_titre",
|
|
41
|
+
"p.intitule_titre",
|
|
42
|
+
"p.mention_chapitre",
|
|
43
|
+
"p.intitule_chapitre",
|
|
44
|
+
"p.mention_article",
|
|
45
|
+
"p.intitule_article",
|
|
46
|
+
"p.mention_section",
|
|
47
|
+
"p.intitule_section",
|
|
48
|
+
].join(",")).remove();
|
|
49
|
+
const firstP = $block.find("p").first();
|
|
50
|
+
const speakerLabelRaw = firstP.find(".orateur_nom").text() || firstP.find("a.lien_senfic").text() || "";
|
|
51
|
+
const speakerLabel = dedupeSpeaker(speakerLabelRaw);
|
|
52
|
+
const { mat, nom: nomCRI, qua: quaCRI } = readIntervenantMeta($block);
|
|
53
|
+
const qualFromSpans = extractAndRemoveLeadingQualite($, $block);
|
|
54
|
+
const qualite = norm(decodeHtmlEntities(quaCRI || "")) || qualFromSpans;
|
|
55
|
+
const canonicalName = dedupeSpeaker(nomCRI || speakerLabel);
|
|
56
|
+
const role = roleForSpeaker(speakerLabel) || roleForSpeaker(qualite) || roleForSpeaker(quaCRI || "");
|
|
57
|
+
const speechHtml = sanitizeInterventionHtml($, $block);
|
|
58
|
+
if (!norm(cheerio.load(speechHtml).text() || ""))
|
|
59
|
+
return;
|
|
60
|
+
addPoint({
|
|
61
|
+
code_grammaire: "PAROLE_GENERIQUE",
|
|
62
|
+
roledebat: role,
|
|
63
|
+
orateurs: { orateur: { nom: canonicalName, id: mat || "", qualite } },
|
|
64
|
+
texte: { _: speechHtml },
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
const contenu = {
|
|
68
|
+
quantiemes: { journee: metadonnees.dateSeance, session: metadonnees.session },
|
|
69
|
+
point: points,
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
uid: "CRSSN" + xmlFilePath.replace(/^.*?(\d{8}).*$/i, "$1") + `-${wantedSlot}`,
|
|
73
|
+
seanceRef: "RUSN" + xmlFilePath.replace(/^.*?(\d{8}).*$/i, "$1") + "IDS-" + wantedSlot,
|
|
74
|
+
sessionRef: metadonnees.session,
|
|
75
|
+
metadonnees,
|
|
76
|
+
contenu,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
console.error(`[CRI] parseSlot error file=${xmlFilePath} slot=${wantedSlot}:`, e);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function sessionStartYearFromDate(d) {
|
|
85
|
+
// Session (1th oct N → 30 sept N+1)
|
|
86
|
+
const m = d.getMonth();
|
|
87
|
+
const y = d.getFullYear();
|
|
88
|
+
return m >= 9 ? y : y - 1;
|
|
89
|
+
}
|
|
90
|
+
export function parseYYYYMMDD(yyyymmdd) {
|
|
91
|
+
if (!/^\d{8}$/.test(yyyymmdd))
|
|
92
|
+
return null;
|
|
93
|
+
const y = Number(yyyymmdd.slice(0, 4));
|
|
94
|
+
const m = Number(yyyymmdd.slice(4, 6)) - 1;
|
|
95
|
+
const d = Number(yyyymmdd.slice(6, 8));
|
|
96
|
+
const dt = new Date(y, m, d);
|
|
97
|
+
return Number.isFinite(dt.getTime()) ? dt : null;
|
|
98
|
+
}
|
|
99
|
+
export function deriveTitreObjetFromSommaire(sommaire, slot) {
|
|
100
|
+
const items = extractLevel1Items(sommaire);
|
|
101
|
+
const meaningful = items.filter(it => !isBoilerplate(it.label));
|
|
102
|
+
if (meaningful.length === 0) {
|
|
103
|
+
return {
|
|
104
|
+
titre: `Séance publique ${slotLabel(slot)}`,
|
|
105
|
+
objet: "",
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const titre = meaningful[0].label;
|
|
109
|
+
const objet = meaningful.slice(0, 3).map(it => it.label).join(" ; ");
|
|
110
|
+
return { titre, objet };
|
|
111
|
+
}
|
|
112
|
+
function slotLabel(slot) {
|
|
113
|
+
switch (slot) {
|
|
114
|
+
case "MATIN": return "du matin";
|
|
115
|
+
case "APRES-MIDI": return "de l’après-midi";
|
|
116
|
+
case "SOIR": return "du soir";
|
|
117
|
+
default: return "";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const BOILERPLATE_PATTERNS = [
|
|
121
|
+
/proc(?:è|e)s-?verbal/i,
|
|
122
|
+
/hommages?/i,
|
|
123
|
+
/désignation des vice-?président/i,
|
|
124
|
+
/candidatures? aux?/i,
|
|
125
|
+
/ordre du jour/i,
|
|
126
|
+
/rappels? au règlement/i,
|
|
127
|
+
/communications?/i,
|
|
128
|
+
/dépôts?/i,
|
|
129
|
+
/proclamation/i,
|
|
130
|
+
/présidence de/i,
|
|
131
|
+
/questions? diverses?/i,
|
|
132
|
+
/ouverture de la séance/i,
|
|
133
|
+
/clo(?:t|̂)ure de la séance/i,
|
|
134
|
+
];
|
|
135
|
+
const isBoilerplate = (label) => !label?.trim() || BOILERPLATE_PATTERNS.some(rx => rx.test(label));
|
|
136
|
+
function extractLevel1Items(sommaire) {
|
|
137
|
+
const level1 = asArray(sommaire?.sommaire1);
|
|
138
|
+
return level1
|
|
139
|
+
.map(el => ({
|
|
140
|
+
numero: toInt(el?.valeur_pts_odj),
|
|
141
|
+
label: String(el?.titreStruct?.intitule ?? "").trim(),
|
|
142
|
+
}))
|
|
143
|
+
.filter(it => !!it.label)
|
|
144
|
+
.sort((a, b) => a.numero - b.numero);
|
|
145
|
+
}
|
|
146
|
+
function stripTrailingPunct(s) { return s.replace(/\s*([:,.;])\s*$/u, "").trim(); }
|
|
147
|
+
function dedupeSpeaker(raw) {
|
|
148
|
+
let s = norm(raw);
|
|
149
|
+
s = stripTrailingPunct(s);
|
|
150
|
+
const dupPatterns = [/^(.+?)\s*[.]\s*\1$/u, /^(.+?)\s*,\s*\1,?$/u, /^(.+?)\s+\1$/u];
|
|
151
|
+
for (const re of dupPatterns) {
|
|
152
|
+
const m = s.match(re);
|
|
153
|
+
if (m) {
|
|
154
|
+
s = m[1];
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return s.replace(/\.\s*$/, "");
|
|
159
|
+
}
|
|
160
|
+
function decodeHtmlEntities(s) {
|
|
161
|
+
return s.replace(/&#(\d+);/g, (_, d) => String.fromCharCode(parseInt(d, 10)))
|
|
162
|
+
.replace(/&#x([0-9a-fA-F]+);/g, (_, h) => String.fromCharCode(parseInt(h, 16)));
|
|
163
|
+
}
|
|
164
|
+
function fixApostrophes(s) {
|
|
165
|
+
let out = s;
|
|
166
|
+
out = out.replace(/\s*’\s*/g, "’");
|
|
167
|
+
out = out.replace(/\b([dljctmsn])\s*’/gi, (_, m) => m + "’");
|
|
168
|
+
out = out.replace(/’\s+([A-Za-zÀ-ÖØ-öø-ÿ])/g, "’$1");
|
|
169
|
+
out = out.replace(/\s+([,;:.!?])/g, "$1");
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
function normalizeTitle(text) { return text.replace(/^PR[ÉE]SIDENCE DE\b/i, "Présidence de "); }
|
|
173
|
+
function roleForSpeaker(labelOrQualite) {
|
|
174
|
+
const s = (labelOrQualite || "").toLowerCase();
|
|
175
|
+
if (/^(m\.|mme)?\s*(le|la)\s+pr[ée]sident(e)?\b/.test(s) || /\bpr[ée]sident[e]?\s+de\s+séance\b/.test(s))
|
|
176
|
+
return "président";
|
|
177
|
+
return "";
|
|
178
|
+
}
|
|
179
|
+
function readIntervenantMeta($block) {
|
|
180
|
+
const int = $block.find('cri\\:intervenant').first();
|
|
181
|
+
if (int.length)
|
|
182
|
+
return { mat: int.attr("mat") || undefined, nom: int.attr("nom") || undefined, qua: int.attr("qua") || undefined };
|
|
183
|
+
const html = $block.html() || "";
|
|
184
|
+
const m = html.match(/<!--\s*cri:intervenant\b([^>]+)-->/i);
|
|
185
|
+
if (!m)
|
|
186
|
+
return {};
|
|
187
|
+
const out = {};
|
|
188
|
+
const re = /(\w+)="([^"]*)"/g;
|
|
189
|
+
let a;
|
|
190
|
+
while ((a = re.exec(m[1])))
|
|
191
|
+
out[a[1]] = decodeHtmlEntities(a[2]);
|
|
192
|
+
return { mat: out["mat"], nom: out["nom"], qua: out["qua"] };
|
|
193
|
+
}
|
|
194
|
+
function extractAndRemoveLeadingQualite($, $block) {
|
|
195
|
+
const firstP = $block.find("p").first();
|
|
196
|
+
if (firstP.length === 0)
|
|
197
|
+
return "";
|
|
198
|
+
const parts = [];
|
|
199
|
+
let stop = false;
|
|
200
|
+
firstP.contents().each((_, node) => {
|
|
201
|
+
if (stop)
|
|
202
|
+
return;
|
|
203
|
+
if (node.type === "tag") {
|
|
204
|
+
const $node = $(node);
|
|
205
|
+
if ($node.hasClass("orateur_nom")) {
|
|
206
|
+
$node.remove();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if ($node.hasClass("orateur_qualite")) {
|
|
210
|
+
parts.push($node.text() || "");
|
|
211
|
+
$node.remove();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const t = norm($node.text() || "");
|
|
215
|
+
if (t)
|
|
216
|
+
stop = true;
|
|
217
|
+
else
|
|
218
|
+
$node.remove();
|
|
219
|
+
}
|
|
220
|
+
else if (node.type === "text") {
|
|
221
|
+
const t = norm(node.data || "");
|
|
222
|
+
if (!t || /^[:.,;–—-]+$/.test(t)) {
|
|
223
|
+
node.data = "";
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
stop = true;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
return fixApostrophes(norm(parts.join(" ")));
|
|
230
|
+
}
|
|
231
|
+
function sanitizeInterventionHtml($, $block) {
|
|
232
|
+
const $clone = $block.clone();
|
|
233
|
+
$clone.find('a[name]').remove();
|
|
234
|
+
$clone.find('div[align="right"]').remove();
|
|
235
|
+
$clone.find('a.link').remove();
|
|
236
|
+
$clone.find('img').remove();
|
|
237
|
+
$clone.find('a#ameli_amendement_cri_phrase, a#ameli_amendement_cra_contenu, a#ameli_amendement_cra_objet').remove();
|
|
238
|
+
$clone.find(".orateur_nom, .orateur_qualite").remove();
|
|
239
|
+
let html = $clone.html() || "";
|
|
240
|
+
html = html.replace(/<!--[\s\S]*?-->/g, "");
|
|
241
|
+
return html.trim();
|
|
242
|
+
}
|
|
243
|
+
function extractSommaireForIntervals($, idx, intervals) {
|
|
244
|
+
const inIv = (el) => elementInAnyInterval(el, idx, intervals);
|
|
245
|
+
const root = $("body");
|
|
246
|
+
const sommaire = { presidentSeance: { _: "" }, sommaire1: [] };
|
|
247
|
+
// (1) Présidence (tm2) — première ligne dans l’intervalle
|
|
248
|
+
const pres = root.find("p.tm2").filter((_, el) => inIv(el)).first();
|
|
249
|
+
if (pres.length)
|
|
250
|
+
sommaire.presidentSeance = { _: norm(pres.text()) };
|
|
251
|
+
// (2) Paras tm5 présents dans l’intervalle
|
|
252
|
+
const paras = [];
|
|
253
|
+
root.find("p.tm5").each((_, el) => {
|
|
254
|
+
if (!inIv(el))
|
|
255
|
+
return;
|
|
256
|
+
const t = norm($(el).text());
|
|
257
|
+
if (t)
|
|
258
|
+
paras.push({ _: t });
|
|
259
|
+
});
|
|
260
|
+
if (paras.length)
|
|
261
|
+
sommaire.para = paras.length === 1 ? paras[0] : paras;
|
|
262
|
+
// (3) Items de 1er niveau (tm3) présents dans l’intervalle
|
|
263
|
+
const items = [];
|
|
264
|
+
root.find("p.tm3").each((_, el) => {
|
|
265
|
+
if (!inIv(el))
|
|
266
|
+
return;
|
|
267
|
+
const $p = $(el);
|
|
268
|
+
const full = norm($p.text() || "");
|
|
269
|
+
if (!full)
|
|
270
|
+
return;
|
|
271
|
+
const numMatch = full.match(/^(\d+)\s*[.\-–—]\s*/);
|
|
272
|
+
const valeur = numMatch ? numMatch[1] : undefined;
|
|
273
|
+
// prefere intitule in ancre <a> if present
|
|
274
|
+
const a = $p.find("a").first();
|
|
275
|
+
const intituleRaw = a.length ? a.text() : full.replace(/^(\d+)\s*[.\-–—]\s*/, "");
|
|
276
|
+
const intitule = norm(intituleRaw);
|
|
277
|
+
// id_syceron from href="#Niv1_SOMx"
|
|
278
|
+
const href = (a.attr("href") || "").trim();
|
|
279
|
+
const idSyceron = href.startsWith("#") ? href.slice(1) : href;
|
|
280
|
+
const titreStruct = { id_syceron: idSyceron || "", intitule };
|
|
281
|
+
items.push({ valeur_pts_odj: valeur, titreStruct });
|
|
282
|
+
});
|
|
283
|
+
if (items.length)
|
|
284
|
+
sommaire.sommaire1 = items;
|
|
285
|
+
return sommaire;
|
|
286
|
+
}
|
|
287
|
+
function extractMetadonnees($, filePath) {
|
|
288
|
+
let dateText = norm($("h1, h2, .page-title").first().text() || "");
|
|
289
|
+
if (!dateText)
|
|
290
|
+
dateText = norm($("p").first().text() || "");
|
|
291
|
+
const dateMatch = dateText.match(/\b(\d{1,2}\s+\w+\s+\d{4})\b/i);
|
|
292
|
+
const allText = norm($("body").text() || "");
|
|
293
|
+
const sessionMatch = allText.match(/\bsession\s+(\d{4}-\d{4})\b/i);
|
|
294
|
+
let dateSeance = dateMatch?.[1] || "";
|
|
295
|
+
if (!dateSeance) {
|
|
296
|
+
const m = filePath.match(/d(\d{4})(\d{2})(\d{2})\.xml$/i);
|
|
297
|
+
if (m)
|
|
298
|
+
dateSeance = `${m[1]}-${m[2]}-${m[3]}`;
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
dateSeance,
|
|
302
|
+
dateSeanceJour: dateSeance,
|
|
303
|
+
numSeanceJour: "",
|
|
304
|
+
numSeance: "",
|
|
305
|
+
typeAssemblee: "SN",
|
|
306
|
+
legislature: "",
|
|
307
|
+
session: sessionMatch?.[1] || "",
|
|
308
|
+
nomFichierJo: "",
|
|
309
|
+
validite: "",
|
|
310
|
+
etat: "",
|
|
311
|
+
diffusion: "",
|
|
312
|
+
version: "1.0",
|
|
313
|
+
environnement: "",
|
|
314
|
+
heureGeneration: new Date()
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function elementInAnyInterval(el, idx, intervals) {
|
|
318
|
+
const p = idx.get(el);
|
|
319
|
+
if (p == null)
|
|
320
|
+
return false;
|
|
321
|
+
for (const iv of intervals)
|
|
322
|
+
if (p >= iv.start && p < iv.end)
|
|
323
|
+
return true;
|
|
324
|
+
return false;
|
|
325
|
+
}
|
package/lib/model/debats.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InferResult } from "kysely";
|
|
2
2
|
export type DebatResult = InferResult<typeof findAllQuery>[0];
|
|
3
|
-
declare const findAllQuery: import("kysely").SelectQueryBuilder<any, "debats", {
|
|
3
|
+
declare const findAllQuery: import("kysely").SelectQueryBuilder<any, "debats.debats", {
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
id: string;
|
|
6
6
|
date_seance: string;
|
|
@@ -8,19 +8,31 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<any, "debats", {
|
|
|
8
8
|
[x: string]: any;
|
|
9
9
|
interventions: {
|
|
10
10
|
[x: string]: any;
|
|
11
|
+
auteur: {
|
|
12
|
+
code: any;
|
|
13
|
+
nom: any;
|
|
14
|
+
prenom: any;
|
|
15
|
+
matricule: any;
|
|
16
|
+
};
|
|
11
17
|
}[];
|
|
12
18
|
}[];
|
|
13
19
|
sections_divers: {
|
|
14
20
|
[x: string]: any;
|
|
15
21
|
interventions: {
|
|
16
22
|
[x: string]: any;
|
|
23
|
+
auteur: {
|
|
24
|
+
code: any;
|
|
25
|
+
nom: any;
|
|
26
|
+
prenom: any;
|
|
27
|
+
matricule: any;
|
|
28
|
+
};
|
|
17
29
|
}[];
|
|
18
30
|
}[];
|
|
19
31
|
lectures: {
|
|
20
32
|
id: any;
|
|
21
33
|
}[];
|
|
22
34
|
}>;
|
|
23
|
-
export declare function findAll(): AsyncIterableIterator<{
|
|
35
|
+
export declare function findAll(fromSession?: number): AsyncIterableIterator<{
|
|
24
36
|
[x: string]: any;
|
|
25
37
|
id: string;
|
|
26
38
|
date_seance: string;
|
|
@@ -28,12 +40,24 @@ export declare function findAll(): AsyncIterableIterator<{
|
|
|
28
40
|
[x: string]: any;
|
|
29
41
|
interventions: {
|
|
30
42
|
[x: string]: any;
|
|
43
|
+
auteur: {
|
|
44
|
+
code: any;
|
|
45
|
+
nom: any;
|
|
46
|
+
prenom: any;
|
|
47
|
+
matricule: any;
|
|
48
|
+
};
|
|
31
49
|
}[];
|
|
32
50
|
}[];
|
|
33
51
|
sections_divers: {
|
|
34
52
|
[x: string]: any;
|
|
35
53
|
interventions: {
|
|
36
54
|
[x: string]: any;
|
|
55
|
+
auteur: {
|
|
56
|
+
code: any;
|
|
57
|
+
nom: any;
|
|
58
|
+
prenom: any;
|
|
59
|
+
matricule: any;
|
|
60
|
+
};
|
|
37
61
|
}[];
|
|
38
62
|
}[];
|
|
39
63
|
lectures: {
|
package/lib/model/debats.js
CHANGED
|
@@ -1,87 +1,95 @@
|
|
|
1
|
-
import { jsonArrayFrom } from "kysely/helpers/postgres";
|
|
1
|
+
import { jsonArrayFrom, jsonBuildObject } from "kysely/helpers/postgres";
|
|
2
2
|
import { dbSenat } from "../databases";
|
|
3
3
|
import { ID_DATE_FORMAT } from "../scripts/datautil";
|
|
4
4
|
import { toDateString } from "./util";
|
|
5
5
|
function sectionsLegislatives(dateSeance) {
|
|
6
6
|
return jsonArrayFrom(dbSenat
|
|
7
|
-
.
|
|
8
|
-
.
|
|
9
|
-
.
|
|
10
|
-
.where("secdis.datsea", "=", dateSeance)
|
|
7
|
+
.selectFrom("debats.secdis")
|
|
8
|
+
.leftJoin("debats.typsec", "debats.secdis.typseccod", "debats.typsec.typseccod")
|
|
9
|
+
.where("debats.secdis.datsea", "=", dateSeance)
|
|
11
10
|
.select(({ ref }) => [
|
|
12
|
-
"secdis.secdisordid as id",
|
|
13
|
-
"secdis.secdisnum as numero",
|
|
14
|
-
"secdis.secdisobj as objet",
|
|
15
|
-
"secdis.secdisurl as url",
|
|
16
|
-
"typsec.typseclib as type",
|
|
17
|
-
"typsec.typseccat as categorie",
|
|
18
|
-
interventionsLegislatives(ref("secdis.secdiscle")).as("interventions"),
|
|
19
|
-
"secdis.lecassidt as lecture_id"
|
|
11
|
+
"debats.secdis.secdisordid as id",
|
|
12
|
+
"debats.secdis.secdisnum as numero",
|
|
13
|
+
"debats.secdis.secdisobj as objet",
|
|
14
|
+
"debats.secdis.secdisurl as url",
|
|
15
|
+
"debats.typsec.typseclib as type",
|
|
16
|
+
"debats.typsec.typseccat as categorie",
|
|
17
|
+
interventionsLegislatives(ref("debats.secdis.secdiscle")).as("interventions"),
|
|
18
|
+
"debats.secdis.lecassidt as lecture_id"
|
|
20
19
|
])
|
|
21
|
-
.orderBy("secdis.secdisordid asc"));
|
|
20
|
+
.orderBy("debats.secdis.secdisordid asc"));
|
|
22
21
|
}
|
|
23
22
|
function interventionsLegislatives(sectionId) {
|
|
24
23
|
return jsonArrayFrom(dbSenat
|
|
25
|
-
.
|
|
26
|
-
.
|
|
27
|
-
.where("intpjl.secdiscle", "=", sectionId)
|
|
28
|
-
.select(({ ref, val }) => [
|
|
29
|
-
"intpjl.intordid as id",
|
|
30
|
-
"intpjl.autcod as auteur_code",
|
|
31
|
-
"intpjl.intfon as fonction_intervenant",
|
|
32
|
-
"intpjl.inturl as url",
|
|
33
|
-
"intpjl.intana as analyse",
|
|
24
|
+
.selectFrom("debats.intpjl")
|
|
25
|
+
.leftJoin("dosleg.auteur", "debats.intpjl.autcod", "dosleg.auteur.autcod")
|
|
26
|
+
.where("debats.intpjl.secdiscle", "=", sectionId)
|
|
27
|
+
.select(({ ref, val, fn }) => [
|
|
28
|
+
"debats.intpjl.intordid as id",
|
|
29
|
+
"debats.intpjl.autcod as auteur_code",
|
|
30
|
+
"debats.intpjl.intfon as fonction_intervenant",
|
|
31
|
+
"debats.intpjl.inturl as url",
|
|
32
|
+
"debats.intpjl.intana as analyse",
|
|
33
|
+
jsonBuildObject({
|
|
34
|
+
code: ref("dosleg.auteur.autcod"),
|
|
35
|
+
nom: ref("dosleg.auteur.nomuse"),
|
|
36
|
+
prenom: ref("dosleg.auteur.prenom"),
|
|
37
|
+
matricule: ref("dosleg.auteur.autmat")
|
|
38
|
+
}).as("auteur")
|
|
34
39
|
])
|
|
35
|
-
.orderBy("intpjl.intordid asc"));
|
|
40
|
+
.orderBy("debats.intpjl.intordid asc"));
|
|
36
41
|
}
|
|
37
42
|
function sectionsNonLegislatives(dateSeance) {
|
|
38
43
|
return jsonArrayFrom(dbSenat
|
|
39
|
-
.
|
|
40
|
-
.
|
|
41
|
-
.
|
|
42
|
-
.where("secdivers.datsea", "=", dateSeance)
|
|
44
|
+
.selectFrom("debats.secdivers")
|
|
45
|
+
.leftJoin("debats.typsec", "debats.secdivers.typseccod", "debats.typsec.typseccod")
|
|
46
|
+
.where("debats.secdivers.datsea", "=", dateSeance)
|
|
43
47
|
.select(({ ref }) => [
|
|
44
|
-
"secdivers.secdiverslibelle as libelle",
|
|
45
|
-
"secdivers.secdiversobj as objet",
|
|
46
|
-
"typsec.typseclib as type",
|
|
47
|
-
"typsec.typseccat as categorie",
|
|
48
|
-
interventionsNonLegislatives(ref("secdivers.secdiverscle")).as("interventions"),
|
|
48
|
+
"debats.secdivers.secdiverslibelle as libelle",
|
|
49
|
+
"debats.secdivers.secdiversobj as objet",
|
|
50
|
+
"debats.typsec.typseclib as type",
|
|
51
|
+
"debats.typsec.typseccat as categorie",
|
|
52
|
+
interventionsNonLegislatives(ref("debats.secdivers.secdiverscle")).as("interventions"),
|
|
49
53
|
]));
|
|
50
54
|
}
|
|
51
55
|
function interventionsNonLegislatives(sectionId) {
|
|
52
56
|
return jsonArrayFrom(dbSenat
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.where("intdivers.intdiverscle", "=", sectionId)
|
|
57
|
+
.selectFrom("debats.intdivers")
|
|
58
|
+
.leftJoin("dosleg.auteur", "debats.intdivers.autcod", "dosleg.auteur.autcod")
|
|
59
|
+
.where("debats.intdivers.intdiverscle", "=", sectionId)
|
|
56
60
|
.select(({ ref, val }) => [
|
|
57
|
-
"intdivers.intdiversordid as id",
|
|
58
|
-
"intdivers.autcod as auteur_code",
|
|
59
|
-
"intdivers.intfon as fonction_intervenant",
|
|
60
|
-
"intdivers.inturl as url",
|
|
61
|
-
"intdivers.intana as analyse",
|
|
61
|
+
"debats.intdivers.intdiversordid as id",
|
|
62
|
+
"debats.intdivers.autcod as auteur_code",
|
|
63
|
+
"debats.intdivers.intfon as fonction_intervenant",
|
|
64
|
+
"debats.intdivers.inturl as url",
|
|
65
|
+
"debats.intdivers.intana as analyse",
|
|
66
|
+
jsonBuildObject({
|
|
67
|
+
code: ref("dosleg.auteur.autcod"),
|
|
68
|
+
nom: ref("dosleg.auteur.nomuse"),
|
|
69
|
+
prenom: ref("dosleg.auteur.prenom"),
|
|
70
|
+
matricule: ref("dosleg.auteur.autmat")
|
|
71
|
+
}).as("auteur")
|
|
62
72
|
])
|
|
63
|
-
.orderBy("intdivers.intdiversordid asc"));
|
|
73
|
+
.orderBy("debats.intdivers.intdiversordid asc"));
|
|
64
74
|
}
|
|
65
75
|
function lecturesAssemblee(dateSeance) {
|
|
66
76
|
return jsonArrayFrom(dbSenat
|
|
67
|
-
.
|
|
68
|
-
.
|
|
69
|
-
.
|
|
70
|
-
.select("lecassdeb.lecassidt as id"));
|
|
77
|
+
.selectFrom("debats.lecassdeb")
|
|
78
|
+
.where("debats.lecassdeb.datsea", "=", dateSeance)
|
|
79
|
+
.select("debats.lecassdeb.lecassidt as id"));
|
|
71
80
|
}
|
|
72
81
|
const findAllQuery = dbSenat
|
|
73
|
-
.
|
|
74
|
-
.selectFrom("debats")
|
|
82
|
+
.selectFrom("debats.debats")
|
|
75
83
|
.select(({ ref, val }) => [
|
|
76
|
-
toDateString(ref("debats.datsea"), val(ID_DATE_FORMAT)).as("id"),
|
|
77
|
-
toDateString(ref("debats.datsea")).as("date_seance"),
|
|
78
|
-
"debats.numero as numero",
|
|
79
|
-
"debats.deburl as url",
|
|
80
|
-
"debats.debsyn as etat_synchronisation",
|
|
81
|
-
sectionsLegislatives(ref("debats.datsea")).as("sections"),
|
|
82
|
-
sectionsNonLegislatives(ref("debats.datsea")).as("sections_divers"),
|
|
83
|
-
lecturesAssemblee(ref("debats.datsea")).as("lectures"),
|
|
84
|
+
toDateString(ref("debats.debats.datsea"), val(ID_DATE_FORMAT)).as("id"),
|
|
85
|
+
toDateString(ref("debats.debats.datsea")).as("date_seance"),
|
|
86
|
+
"debats.debats.numero as numero",
|
|
87
|
+
"debats.debats.deburl as url",
|
|
88
|
+
"debats.debats.debsyn as etat_synchronisation",
|
|
89
|
+
sectionsLegislatives(ref("debats.debats.datsea")).as("sections"),
|
|
90
|
+
sectionsNonLegislatives(ref("debats.debats.datsea")).as("sections_divers"),
|
|
91
|
+
lecturesAssemblee(ref("debats.debats.datsea")).as("lectures"),
|
|
84
92
|
]);
|
|
85
|
-
export function findAll() {
|
|
93
|
+
export function findAll(fromSession) {
|
|
86
94
|
return findAllQuery.stream();
|
|
87
95
|
}
|
package/lib/model/dosleg.d.ts
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import { InferResult, SelectQueryBuilder } from "kysely";
|
|
2
2
|
declare const findAllDossiersQuery: SelectQueryBuilder<any, any, any>;
|
|
3
3
|
export declare function findAllDossiers(): AsyncIterableIterator<DossierLegislatifResult>;
|
|
4
|
-
declare const findAuteursQuery: SelectQueryBuilder<any, "dosleg.auteur", {
|
|
5
|
-
code: any;
|
|
6
|
-
nom: any;
|
|
7
|
-
prenom: any;
|
|
8
|
-
matricule: any;
|
|
9
|
-
}>;
|
|
10
|
-
export declare function findAuteurs(): Promise<{
|
|
11
|
-
code: any;
|
|
12
|
-
nom: any;
|
|
13
|
-
prenom: any;
|
|
14
|
-
matricule: any;
|
|
15
|
-
}[]>;
|
|
16
4
|
export declare function createActesLegislatifs(dossier: DossierLegislatifResult): any;
|
|
17
5
|
export declare function getCodeActeLecture(codeNatureDossier: string, typeLecture: string, assemblee: string): string | null;
|
|
18
6
|
export declare function getCodeActeTexte(codeParent: string | null, texteOrigine: string): string | null;
|
|
19
7
|
export type DossierLegislatifResult = InferResult<typeof findAllDossiersQuery>[0];
|
|
20
|
-
export type AuteurResult = InferResult<typeof findAuteursQuery>[0];
|
|
21
8
|
export {};
|
package/lib/model/dosleg.js
CHANGED
|
@@ -222,19 +222,6 @@ const findAllDossiersQuery = dbSenat
|
|
|
222
222
|
export function findAllDossiers() {
|
|
223
223
|
return findAllDossiersQuery.stream();
|
|
224
224
|
}
|
|
225
|
-
const findAuteursQuery = dbSenat
|
|
226
|
-
.withSchema("dosleg")
|
|
227
|
-
.selectFrom("dosleg.auteur")
|
|
228
|
-
.select([
|
|
229
|
-
"autcod as code",
|
|
230
|
-
"nomuse as nom",
|
|
231
|
-
"prenom as prenom",
|
|
232
|
-
"autmat as matricule",
|
|
233
|
-
]);
|
|
234
|
-
export async function findAuteurs() {
|
|
235
|
-
return findAuteursQuery
|
|
236
|
-
.execute();
|
|
237
|
-
}
|
|
238
225
|
export function createActesLegislatifs(dossier) {
|
|
239
226
|
const actesLegislatifs = (dossier["lectures"] || []).map((lecture) => {
|
|
240
227
|
const lecturesAssemblee = (lecture["lectures_assemblee"] || []).map((lectureAss) => {
|
package/lib/model/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { findAllAmendements } from "./ameli";
|
|
2
2
|
export { findAll as findAllDebats } from "./debats";
|
|
3
|
-
export { findAllDossiers,
|
|
3
|
+
export { findAllDossiers, } from "./dosleg";
|
|
4
4
|
export { findSenatTexteUrls, findSenatRapportUrls } from "./documents";
|
|
5
5
|
export { findAllScrutins } from "./scrutins";
|
|
6
6
|
export { findAll as findAllQuestions } from "./questions";
|
package/lib/model/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { findAllAmendements } from "./ameli";
|
|
2
2
|
export { findAll as findAllDebats } from "./debats";
|
|
3
|
-
export { findAllDossiers,
|
|
3
|
+
export { findAllDossiers, } from "./dosleg";
|
|
4
4
|
export { findSenatTexteUrls, findSenatRapportUrls } from "./documents";
|
|
5
5
|
export { findAllScrutins } from "./scrutins";
|
|
6
6
|
export { findAll as findAllQuestions } from "./questions";
|