@tricoteuses/senat 3.1.0 → 3.1.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.
Files changed (306) hide show
  1. package/lib/src/loaders.d.ts +3 -3
  2. package/lib/src/loaders.js +1 -1
  3. package/lib/src/model/agenda.d.ts +1 -1
  4. package/lib/src/model/commission.d.ts +2 -2
  5. package/lib/src/model/seance.d.ts +1 -1
  6. package/lib/src/types/ameli.d.ts +4 -1761
  7. package/lib/src/types/ameli.js +1 -1074
  8. package/lib/src/types/debats.d.ts +2 -380
  9. package/lib/src/types/debats.js +1 -266
  10. package/lib/src/types/dosleg.d.ts +69 -2953
  11. package/lib/src/types/dosleg.js +1 -2005
  12. package/lib/src/types/questions.d.ts +2 -699
  13. package/lib/src/types/questions.js +1 -493
  14. package/lib/src/types/sens.d.ts +7 -7842
  15. package/lib/src/types/sens.js +1 -4691
  16. package/lib/src/utils/nvs-parsing.d.ts +1 -1
  17. package/lib/src/utils/nvs-parsing.js +9 -1
  18. package/lib/src/videos/pipeline.d.ts +3 -3
  19. package/lib/src/videos/pipeline.js +2 -2
  20. package/package.json +1 -1
  21. package/lib/add-js-extensions-v2.d.ts +0 -1
  22. package/lib/add-js-extensions-v2.js +0 -23
  23. package/lib/add-js-extensions.d.ts +0 -1
  24. package/lib/add-js-extensions.js +0 -17
  25. package/lib/aggregates.d.ts +0 -52
  26. package/lib/aggregates.js +0 -930
  27. package/lib/aggregates.mjs +0 -713
  28. package/lib/aggregates.ts +0 -833
  29. package/lib/config.d.ts +0 -10
  30. package/lib/config.js +0 -16
  31. package/lib/config.mjs +0 -16
  32. package/lib/config.ts +0 -26
  33. package/lib/databases.d.ts +0 -2
  34. package/lib/databases.js +0 -26
  35. package/lib/databases.mjs +0 -57
  36. package/lib/databases.ts +0 -71
  37. package/lib/datasets.d.ts +0 -34
  38. package/lib/datasets.js +0 -233
  39. package/lib/datasets.mjs +0 -78
  40. package/lib/datasets.ts +0 -118
  41. package/lib/fields.d.ts +0 -10
  42. package/lib/fields.js +0 -68
  43. package/lib/fields.mjs +0 -22
  44. package/lib/fields.ts +0 -29
  45. package/lib/git.d.ts +0 -26
  46. package/lib/git.js +0 -167
  47. package/lib/index.d.ts +0 -13
  48. package/lib/index.js +0 -1
  49. package/lib/index.mjs +0 -7
  50. package/lib/index.ts +0 -64
  51. package/lib/inserters.d.ts +0 -98
  52. package/lib/inserters.js +0 -500
  53. package/lib/inserters.mjs +0 -360
  54. package/lib/inserters.ts +0 -521
  55. package/lib/legislatures.json +0 -38
  56. package/lib/loaders.d.ts +0 -58
  57. package/lib/loaders.js +0 -286
  58. package/lib/loaders.mjs +0 -158
  59. package/lib/loaders.ts +0 -271
  60. package/lib/model/agenda.d.ts +0 -6
  61. package/lib/model/agenda.js +0 -148
  62. package/lib/model/ameli.d.ts +0 -51
  63. package/lib/model/ameli.js +0 -149
  64. package/lib/model/ameli.mjs +0 -84
  65. package/lib/model/ameli.ts +0 -100
  66. package/lib/model/commission.d.ts +0 -18
  67. package/lib/model/commission.js +0 -269
  68. package/lib/model/debats.d.ts +0 -67
  69. package/lib/model/debats.js +0 -95
  70. package/lib/model/debats.mjs +0 -43
  71. package/lib/model/debats.ts +0 -68
  72. package/lib/model/documents.d.ts +0 -12
  73. package/lib/model/documents.js +0 -151
  74. package/lib/model/dosleg.d.ts +0 -7
  75. package/lib/model/dosleg.js +0 -326
  76. package/lib/model/dosleg.mjs +0 -196
  77. package/lib/model/dosleg.ts +0 -240
  78. package/lib/model/index.d.ts +0 -7
  79. package/lib/model/index.js +0 -7
  80. package/lib/model/index.mjs +0 -5
  81. package/lib/model/index.ts +0 -15
  82. package/lib/model/questions.d.ts +0 -45
  83. package/lib/model/questions.js +0 -89
  84. package/lib/model/questions.mjs +0 -71
  85. package/lib/model/questions.ts +0 -93
  86. package/lib/model/scrutins.d.ts +0 -13
  87. package/lib/model/scrutins.js +0 -114
  88. package/lib/model/seance.d.ts +0 -3
  89. package/lib/model/seance.js +0 -267
  90. package/lib/model/sens.d.ts +0 -146
  91. package/lib/model/sens.js +0 -454
  92. package/lib/model/sens.mjs +0 -415
  93. package/lib/model/sens.ts +0 -516
  94. package/lib/model/texte.d.ts +0 -7
  95. package/lib/model/texte.js +0 -256
  96. package/lib/model/texte.mjs +0 -208
  97. package/lib/model/texte.ts +0 -229
  98. package/lib/model/util.d.ts +0 -9
  99. package/lib/model/util.js +0 -38
  100. package/lib/model/util.mjs +0 -19
  101. package/lib/model/util.ts +0 -32
  102. package/lib/parsers/texte.d.ts +0 -7
  103. package/lib/parsers/texte.js +0 -228
  104. package/lib/raw_types/ameli.d.ts +0 -914
  105. package/lib/raw_types/ameli.js +0 -5
  106. package/lib/raw_types/ameli.mjs +0 -163
  107. package/lib/raw_types/debats.d.ts +0 -207
  108. package/lib/raw_types/debats.js +0 -5
  109. package/lib/raw_types/debats.mjs +0 -58
  110. package/lib/raw_types/dosleg.d.ts +0 -1619
  111. package/lib/raw_types/dosleg.js +0 -5
  112. package/lib/raw_types/dosleg.mjs +0 -438
  113. package/lib/raw_types/questions.d.ts +0 -419
  114. package/lib/raw_types/questions.js +0 -5
  115. package/lib/raw_types/questions.mjs +0 -11
  116. package/lib/raw_types/senat.d.ts +0 -11368
  117. package/lib/raw_types/senat.js +0 -5
  118. package/lib/raw_types/sens.d.ts +0 -8248
  119. package/lib/raw_types/sens.js +0 -5
  120. package/lib/raw_types/sens.mjs +0 -508
  121. package/lib/raw_types_kysely/ameli.d.ts +0 -915
  122. package/lib/raw_types_kysely/ameli.js +0 -7
  123. package/lib/raw_types_kysely/ameli.mjs +0 -5
  124. package/lib/raw_types_kysely/ameli.ts +0 -951
  125. package/lib/raw_types_kysely/debats.d.ts +0 -207
  126. package/lib/raw_types_kysely/debats.js +0 -7
  127. package/lib/raw_types_kysely/debats.mjs +0 -5
  128. package/lib/raw_types_kysely/debats.ts +0 -222
  129. package/lib/raw_types_kysely/dosleg.d.ts +0 -3532
  130. package/lib/raw_types_kysely/dosleg.js +0 -7
  131. package/lib/raw_types_kysely/dosleg.mjs +0 -5
  132. package/lib/raw_types_kysely/dosleg.ts +0 -3621
  133. package/lib/raw_types_kysely/questions.d.ts +0 -414
  134. package/lib/raw_types_kysely/questions.js +0 -7
  135. package/lib/raw_types_kysely/questions.mjs +0 -5
  136. package/lib/raw_types_kysely/questions.ts +0 -426
  137. package/lib/raw_types_kysely/sens.d.ts +0 -4394
  138. package/lib/raw_types_kysely/sens.js +0 -7
  139. package/lib/raw_types_kysely/sens.mjs +0 -5
  140. package/lib/raw_types_kysely/sens.ts +0 -4499
  141. package/lib/raw_types_schemats/ameli.d.ts +0 -539
  142. package/lib/raw_types_schemats/ameli.js +0 -2
  143. package/lib/raw_types_schemats/ameli.mjs +0 -2
  144. package/lib/raw_types_schemats/ameli.ts +0 -601
  145. package/lib/raw_types_schemats/debats.d.ts +0 -127
  146. package/lib/raw_types_schemats/debats.js +0 -2
  147. package/lib/raw_types_schemats/debats.mjs +0 -2
  148. package/lib/raw_types_schemats/debats.ts +0 -145
  149. package/lib/raw_types_schemats/dosleg.d.ts +0 -977
  150. package/lib/raw_types_schemats/dosleg.js +0 -2
  151. package/lib/raw_types_schemats/dosleg.mjs +0 -2
  152. package/lib/raw_types_schemats/dosleg.ts +0 -2193
  153. package/lib/raw_types_schemats/questions.d.ts +0 -235
  154. package/lib/raw_types_schemats/questions.js +0 -2
  155. package/lib/raw_types_schemats/questions.mjs +0 -2
  156. package/lib/raw_types_schemats/questions.ts +0 -249
  157. package/lib/raw_types_schemats/sens.d.ts +0 -6915
  158. package/lib/raw_types_schemats/sens.js +0 -2
  159. package/lib/raw_types_schemats/sens.mjs +0 -2
  160. package/lib/raw_types_schemats/sens.ts +0 -2907
  161. package/lib/scripts/convert_data.d.ts +0 -1
  162. package/lib/scripts/convert_data.js +0 -354
  163. package/lib/scripts/convert_data.mjs +0 -181
  164. package/lib/scripts/convert_data.ts +0 -243
  165. package/lib/scripts/data-download.d.ts +0 -1
  166. package/lib/scripts/data-download.js +0 -12
  167. package/lib/scripts/datautil.d.ts +0 -8
  168. package/lib/scripts/datautil.js +0 -34
  169. package/lib/scripts/datautil.mjs +0 -16
  170. package/lib/scripts/datautil.ts +0 -19
  171. package/lib/scripts/images/transparent_150x192.jpg +0 -0
  172. package/lib/scripts/images/transparent_155x225.jpg +0 -0
  173. package/lib/scripts/parse_textes.d.ts +0 -1
  174. package/lib/scripts/parse_textes.js +0 -44
  175. package/lib/scripts/parse_textes.mjs +0 -46
  176. package/lib/scripts/parse_textes.ts +0 -65
  177. package/lib/scripts/retrieve_agenda.d.ts +0 -1
  178. package/lib/scripts/retrieve_agenda.js +0 -132
  179. package/lib/scripts/retrieve_cr_commission.d.ts +0 -1
  180. package/lib/scripts/retrieve_cr_commission.js +0 -364
  181. package/lib/scripts/retrieve_cr_seance.d.ts +0 -6
  182. package/lib/scripts/retrieve_cr_seance.js +0 -347
  183. package/lib/scripts/retrieve_documents.d.ts +0 -3
  184. package/lib/scripts/retrieve_documents.js +0 -219
  185. package/lib/scripts/retrieve_documents.mjs +0 -249
  186. package/lib/scripts/retrieve_documents.ts +0 -298
  187. package/lib/scripts/retrieve_open_data.d.ts +0 -1
  188. package/lib/scripts/retrieve_open_data.js +0 -315
  189. package/lib/scripts/retrieve_open_data.mjs +0 -217
  190. package/lib/scripts/retrieve_open_data.ts +0 -268
  191. package/lib/scripts/retrieve_senateurs_photos.d.ts +0 -1
  192. package/lib/scripts/retrieve_senateurs_photos.js +0 -147
  193. package/lib/scripts/retrieve_senateurs_photos.mjs +0 -147
  194. package/lib/scripts/retrieve_senateurs_photos.ts +0 -177
  195. package/lib/scripts/retrieve_videos.d.ts +0 -1
  196. package/lib/scripts/retrieve_videos.js +0 -461
  197. package/lib/scripts/shared/cli_helpers.d.ts +0 -95
  198. package/lib/scripts/shared/cli_helpers.js +0 -91
  199. package/lib/scripts/shared/cli_helpers.ts +0 -36
  200. package/lib/scripts/shared/util.d.ts +0 -4
  201. package/lib/scripts/shared/util.js +0 -35
  202. package/lib/scripts/shared/util.ts +0 -33
  203. package/lib/scripts/test_iter_load.d.ts +0 -1
  204. package/lib/scripts/test_iter_load.js +0 -12
  205. package/lib/src/ameli.d.ts +0 -66
  206. package/lib/src/ameli.js +0 -1
  207. package/lib/src/databases.d.ts +0 -3
  208. package/lib/src/databases.js +0 -26
  209. package/lib/src/db_types/ameli.d.ts +0 -1762
  210. package/lib/src/db_types/ameli.js +0 -1074
  211. package/lib/src/db_types/debats.d.ts +0 -380
  212. package/lib/src/db_types/debats.js +0 -266
  213. package/lib/src/db_types/dosleg.d.ts +0 -2954
  214. package/lib/src/db_types/dosleg.js +0 -2005
  215. package/lib/src/db_types/questions.d.ts +0 -699
  216. package/lib/src/db_types/questions.js +0 -493
  217. package/lib/src/db_types/sens.d.ts +0 -7843
  218. package/lib/src/db_types/sens.js +0 -4691
  219. package/lib/src/debats.d.ts +0 -38
  220. package/lib/src/debats.js +0 -1
  221. package/lib/src/dosleg.d.ts +0 -142
  222. package/lib/src/dosleg.js +0 -193
  223. package/lib/src/model/ameli_postgres.d.ts +0 -67
  224. package/lib/src/model/ameli_postgres.js +0 -150
  225. package/lib/src/other_types/questions.d.ts +0 -2
  226. package/lib/src/other_types/questions.js +0 -1
  227. package/lib/src/questions.d.ts +0 -53
  228. package/lib/src/questions.js +0 -1
  229. package/lib/src/raw_types/senat.d.ts +0 -11372
  230. package/lib/src/raw_types/senat.js +0 -5
  231. package/lib/src/rich_types/agenda.d.ts +0 -45
  232. package/lib/src/rich_types/agenda.js +0 -1
  233. package/lib/src/rich_types/compte_rendu.d.ts +0 -83
  234. package/lib/src/rich_types/compte_rendu.js +0 -1
  235. package/lib/src/rich_types/sessions.d.ts +0 -6
  236. package/lib/src/rich_types/sessions.js +0 -19
  237. package/lib/src/rich_types/texte.d.ts +0 -72
  238. package/lib/src/rich_types/texte.js +0 -15
  239. package/lib/src/scripts/test_iter_load.d.ts +0 -1
  240. package/lib/src/scripts/test_iter_load.js +0 -12
  241. package/lib/src/sens.d.ts +0 -104
  242. package/lib/src/sens.js +0 -1
  243. package/lib/strings.d.ts +0 -1
  244. package/lib/strings.js +0 -18
  245. package/lib/strings.mjs +0 -18
  246. package/lib/strings.ts +0 -26
  247. package/lib/tsconfig.tsbuildinfo +0 -1
  248. package/lib/types/agenda.d.ts +0 -44
  249. package/lib/types/agenda.js +0 -1
  250. package/lib/types/ameli.d.ts +0 -5
  251. package/lib/types/ameli.js +0 -1
  252. package/lib/types/ameli.mjs +0 -13
  253. package/lib/types/ameli.ts +0 -21
  254. package/lib/types/compte_rendu.d.ts +0 -83
  255. package/lib/types/compte_rendu.js +0 -1
  256. package/lib/types/debats.d.ts +0 -2
  257. package/lib/types/debats.js +0 -1
  258. package/lib/types/debats.mjs +0 -2
  259. package/lib/types/debats.ts +0 -6
  260. package/lib/types/dosleg.d.ts +0 -70
  261. package/lib/types/dosleg.js +0 -1
  262. package/lib/types/dosleg.mjs +0 -151
  263. package/lib/types/dosleg.ts +0 -284
  264. package/lib/types/questions.d.ts +0 -2
  265. package/lib/types/questions.js +0 -1
  266. package/lib/types/questions.mjs +0 -1
  267. package/lib/types/questions.ts +0 -3
  268. package/lib/types/sens.d.ts +0 -10
  269. package/lib/types/sens.js +0 -1
  270. package/lib/types/sens.mjs +0 -1
  271. package/lib/types/sens.ts +0 -12
  272. package/lib/types/sessions.d.ts +0 -5
  273. package/lib/types/sessions.js +0 -84
  274. package/lib/types/sessions.mjs +0 -43
  275. package/lib/types/sessions.ts +0 -42
  276. package/lib/types/texte.d.ts +0 -74
  277. package/lib/types/texte.js +0 -16
  278. package/lib/types/texte.mjs +0 -16
  279. package/lib/types/texte.ts +0 -76
  280. package/lib/typings/windows-1252.d.js +0 -2
  281. package/lib/typings/windows-1252.d.mjs +0 -2
  282. package/lib/typings/windows-1252.d.ts +0 -11
  283. package/lib/utils/cr_spliting.d.ts +0 -28
  284. package/lib/utils/cr_spliting.js +0 -265
  285. package/lib/utils/date.d.ts +0 -10
  286. package/lib/utils/date.js +0 -100
  287. package/lib/utils/nvs-timecode.d.ts +0 -7
  288. package/lib/utils/nvs-timecode.js +0 -79
  289. package/lib/utils/reunion_grouping.d.ts +0 -9
  290. package/lib/utils/reunion_grouping.js +0 -361
  291. package/lib/utils/reunion_odj_building.d.ts +0 -5
  292. package/lib/utils/reunion_odj_building.js +0 -154
  293. package/lib/utils/reunion_parsing.d.ts +0 -23
  294. package/lib/utils/reunion_parsing.js +0 -209
  295. package/lib/utils/scoring.d.ts +0 -14
  296. package/lib/utils/scoring.js +0 -147
  297. package/lib/utils/string_cleaning.d.ts +0 -7
  298. package/lib/utils/string_cleaning.js +0 -57
  299. package/lib/validators/config.d.ts +0 -9
  300. package/lib/validators/config.js +0 -10
  301. package/lib/validators/config.mjs +0 -54
  302. package/lib/validators/config.ts +0 -79
  303. package/lib/validators/senat.d.ts +0 -0
  304. package/lib/validators/senat.js +0 -28
  305. package/lib/validators/senat.mjs +0 -24
  306. package/lib/validators/senat.ts +0 -26
@@ -1,71 +0,0 @@
1
- import { jsonArrayFrom } from "kysely/helpers/postgres";
2
- import { dbQuestions } from "../databases";
3
- import { expandToRows, rtrim, toDateString } from "./util";
4
- function reponses(questionId) {
5
- return jsonArrayFrom(dbQuestions.selectFrom("tam_reponses")
6
- .where("tam_reponses.idque", "=", questionId)
7
- .select(({ ref }) => [
8
- toDateString(ref("tam_reponses.datejorep")).as("date_reponse_JO"),
9
- "tam_reponses.minreplib as ministere_reponse",
10
- "tam_reponses.txtrep as texte",
11
- "tam_reponses.txterrrep as texte_erratum",
12
- ])
13
- .orderBy("tam_reponses.datejorep asc"));
14
- }
15
- function themes(questionId) {
16
- return jsonArrayFrom(dbQuestions.with("question_theme", (db) => db
17
- .selectFrom("tam_questions")
18
- .select(({ eb, ref, val }) => [
19
- "id as question_id",
20
- eb.cast(expandToRows(ref("tam_questions.themes"), val("#(\\d+)")), "smallint").as("theme_id"),
21
- ]))
22
- .selectFrom("the")
23
- .leftJoin("question_theme", "the.thenouidt", "question_theme.theme_id")
24
- .where("question_theme.question_id", "=", questionId)
25
- .select("the.thelib as libelle")
26
- .orderBy("the.thenouidt asc"));
27
- }
28
- const findAllQuery = dbQuestions
29
- .selectFrom("tam_questions")
30
- .leftJoin("tam_ministeres", "tam_questions.mindepotid", "tam_ministeres.minid")
31
- .leftJoin("sortquestion", (join) => join
32
- .onRef("tam_questions.sorquecod", "=", eb => eb.cast("sortquestion.sorquecod", "bigint")))
33
- .leftJoin("naturequestion", "tam_questions.natquecod", "naturequestion.natquecod")
34
- .leftJoin("etatquestion", (join) => join
35
- .onRef("tam_questions.etaquecod", "=", eb => eb.cast("etatquestion.etaquecod", "bigint")))
36
- .select(({ ref }) => [
37
- "tam_questions.repub as republique",
38
- "tam_questions.legislature as legislature",
39
- "sortquestion.sorquelib as sort",
40
- "tam_questions.natquecod as nature",
41
- "tam_questions.numero as numero",
42
- "tam_questions.reference as reference",
43
- "tam_questions.titre as titre",
44
- "tam_questions.nom as nom",
45
- "tam_questions.prenom as prenom",
46
- "tam_questions.codequalite as civilite",
47
- "tam_questions.matricule as matricule",
48
- "tam_questions.circonscription as circonscription",
49
- "tam_questions.groupe as groupe",
50
- "tam_questions.ratgrp as type_appartenance",
51
- toDateString(ref("tam_questions.datejodepot")).as("date_publication_JO"),
52
- rtrim(ref("tam_questions.mindepotlib")).as("ministere_depot"),
53
- toDateString(ref("tam_ministeres.datedebut")).as("ministere_depot_date_debut"),
54
- toDateString(ref("tam_questions.datejotran")).as("date_transmission"),
55
- "tam_questions.mintranlib as ministere_transmission",
56
- toDateString(ref("tam_questions.datejorep1")).as("date_reponse_JO"),
57
- "tam_questions.minreplib1 as ministere_reponse",
58
- toDateString(ref("tam_questions.datecloture")).as("date_cloture"),
59
- "tam_questions.refquerappelee as reference_question_rappelee",
60
- //"tam_questions.url as url", // TODO ?
61
- "tam_questions.txtque as texte",
62
- "tam_questions.txtque as texte_erratum",
63
- "tam_questions.rubrique as rubrique",
64
- ])
65
- .select(({ ref }) => [
66
- themes(ref("tam_questions.id")).as("themes"),
67
- reponses(ref("tam_questions.id")).as("reponses"),
68
- ]);
69
- export function findAll() {
70
- return findAllQuery.stream();
71
- }
@@ -1,93 +0,0 @@
1
- import { Expression, InferResult } from "kysely"
2
- import { jsonArrayFrom } from "kysely/helpers/postgres"
3
- import { dbQuestions } from "../databases"
4
- import { expandToRows, rtrim, toDateString } from "./util"
5
-
6
- function reponses (questionId: Expression<string>) {
7
- return jsonArrayFrom(
8
- dbQuestions.selectFrom("tam_reponses")
9
- .where("tam_reponses.idque", "=", questionId)
10
- .select(({ ref }) => [
11
- toDateString(ref("tam_reponses.datejorep")).as("date_reponse_JO"),
12
- "tam_reponses.minreplib as ministere_reponse",
13
- "tam_reponses.txtrep as texte",
14
- "tam_reponses.txterrrep as texte_erratum",
15
- ])
16
- .orderBy("tam_reponses.datejorep asc"),
17
- )
18
- }
19
-
20
- function themes (questionId: Expression<string>) {
21
- return jsonArrayFrom(
22
- dbQuestions.with("question_theme", (db) => db
23
- .selectFrom("tam_questions")
24
- .select(({ eb, ref, val }) => [
25
- "id as question_id",
26
- eb.cast<number>(expandToRows(ref("tam_questions.themes"), val("#(\\d+)")), "smallint").as("theme_id"),
27
- ]),
28
- )
29
- .selectFrom("the")
30
- .leftJoin("question_theme", "the.thenouidt", "question_theme.theme_id")
31
- .where("question_theme.question_id", "=", questionId)
32
- .select("the.thelib as libelle")
33
- .orderBy("the.thenouidt asc"),
34
- )
35
- }
36
-
37
- const findAllQuery = dbQuestions
38
- .selectFrom("tam_questions")
39
- .leftJoin("tam_ministeres", "tam_questions.mindepotid", "tam_ministeres.minid")
40
- .leftJoin("sortquestion", (join) => join
41
- .onRef(
42
- "tam_questions.sorquecod",
43
- "=",
44
- eb => eb.cast<number>("sortquestion.sorquecod", "bigint"),
45
- ),
46
- )
47
- .leftJoin("naturequestion", "tam_questions.natquecod", "naturequestion.natquecod")
48
- .leftJoin("etatquestion", (join) => join
49
- .onRef(
50
- "tam_questions.etaquecod",
51
- "=",
52
- eb => eb.cast<number>("etatquestion.etaquecod", "bigint"),
53
- ),
54
- )
55
- .select(({ ref }) => [
56
- "tam_questions.repub as republique",
57
- "tam_questions.legislature as legislature",
58
- "sortquestion.sorquelib as sort",
59
- "tam_questions.natquecod as nature",
60
- "tam_questions.numero as numero",
61
- "tam_questions.reference as reference",
62
- "tam_questions.titre as titre",
63
- "tam_questions.nom as nom",
64
- "tam_questions.prenom as prenom",
65
- "tam_questions.codequalite as civilite",
66
- "tam_questions.matricule as matricule",
67
- "tam_questions.circonscription as circonscription",
68
- "tam_questions.groupe as groupe",
69
- "tam_questions.ratgrp as type_appartenance",
70
- toDateString(ref("tam_questions.datejodepot")).as("date_publication_JO"),
71
- rtrim(ref("tam_questions.mindepotlib")).as("ministere_depot"),
72
- toDateString(ref("tam_ministeres.datedebut")).as("ministere_depot_date_debut"),
73
- toDateString(ref("tam_questions.datejotran")).as("date_transmission"),
74
- "tam_questions.mintranlib as ministere_transmission",
75
- toDateString(ref("tam_questions.datejorep1")).as("date_reponse_JO"),
76
- "tam_questions.minreplib1 as ministere_reponse",
77
- toDateString(ref("tam_questions.datecloture")).as("date_cloture"),
78
- "tam_questions.refquerappelee as reference_question_rappelee",
79
- //"tam_questions.url as url", // TODO ?
80
- "tam_questions.txtque as texte",
81
- "tam_questions.txtque as texte_erratum",
82
- "tam_questions.rubrique as rubrique",
83
- ])
84
- .select(({ ref }) => [
85
- themes(ref("tam_questions.id")).as("themes"),
86
- reponses(ref("tam_questions.id")).as("reponses"),
87
- ])
88
-
89
- export type QuestionResult = InferResult<typeof findAllQuery>[0]
90
-
91
- export function findAll () {
92
- return findAllQuery.stream()
93
- }
@@ -1,13 +0,0 @@
1
- import { InferResult } from "kysely";
2
- export type ScrutinResult = InferResult<typeof findAllScrutinsQuery>[0];
3
- declare const findAllScrutinsQuery: import("kysely").SelectQueryBuilder<{
4
- [x: string]: any;
5
- [x: number]: any;
6
- [x: symbol]: any;
7
- }, "date_seance" | "lecass" | "lecture" | "loi" | "scr" | "typlec", {
8
- [x: string]: any;
9
- }>;
10
- export declare function findAllScrutins(fromSession?: number): AsyncIterableIterator<{
11
- [x: string]: any;
12
- }>;
13
- export {};
@@ -1,114 +0,0 @@
1
- import { sql } from "kysely";
2
- import { jsonArrayFrom } from "kysely/helpers/postgres";
3
- import { dbSenat } from "../databases";
4
- import { rtrim, toDateString } from "./util";
5
- function votes(scrutinNum, scrutinSession, scrutinDate) {
6
- return jsonArrayFrom(dbSenat
7
- .selectFrom("dosleg.votsen")
8
- .leftJoin("dosleg.titsen", "dosleg.titsen.titsencod", "dosleg.votsen.titsencod")
9
- .leftJoin("dosleg.stavot", "dosleg.stavot.stavotidt", "dosleg.votsen.stavotidt")
10
- .leftJoin("dosleg.posvot", "dosleg.posvot.posvotcod", "dosleg.votsen.posvotcod")
11
- .leftJoin("sens.memgrppol", (join) => join
12
- .onRef("sens.memgrppol.senmat", "=", "dosleg.votsen.senmat")
13
- .onRef("sens.memgrppol.memgrppoldatdeb", "<=", scrutinDate)
14
- .on((eb) => eb.or([
15
- eb("sens.memgrppol.memgrppoldatfin", ">=", scrutinDate),
16
- eb("sens.memgrppol.memgrppoldatfin", "is", null),
17
- ])))
18
- .where("dosleg.votsen.scrnum", "=", scrutinNum)
19
- .where("dosleg.votsen.sesann", "=", scrutinSession)
20
- .orderBy("sens.memgrppol.memgrppoldatdeb", "desc")
21
- .select([
22
- "dosleg.votsen.senmat as matricule_votant",
23
- "dosleg.votsen.senmatdel as matricule_delegant",
24
- "dosleg.posvot.posvotlib as position",
25
- "dosleg.stavot.stavotlib as statut_votant",
26
- "dosleg.titsen.titsenlib as titre_votant",
27
- "sens.memgrppol.memgrppolid as groupe_politique_id",
28
- "sens.memgrppol.grppolcod as groupe_politique_code",
29
- ]));
30
- }
31
- function groupesVotants(scrutinNum, scrutinSession, scrutinDate) {
32
- return jsonArrayFrom(dbSenat
33
- .selectFrom((eb) => eb
34
- .selectFrom("dosleg.votsen")
35
- .leftJoin("dosleg.posvot", "dosleg.posvot.posvotcod", "dosleg.votsen.posvotcod")
36
- .leftJoin("dosleg.stavot", "dosleg.stavot.stavotidt", "dosleg.votsen.stavotidt")
37
- .leftJoin("sens.memgrppol", (join) => join
38
- .onRef("sens.memgrppol.senmat", "=", "dosleg.votsen.senmat")
39
- .onRef("sens.memgrppol.memgrppoldatdeb", "<=", scrutinDate)
40
- .on((eb) => eb.or([
41
- eb("sens.memgrppol.memgrppoldatfin", ">=", scrutinDate),
42
- eb("sens.memgrppol.memgrppoldatfin", "is", null),
43
- ])))
44
- .where("dosleg.votsen.scrnum", "=", scrutinNum)
45
- .where("dosleg.votsen.sesann", "=", scrutinSession)
46
- .orderBy("sens.memgrppol.memgrppoldatdeb", "desc")
47
- .select([
48
- "dosleg.votsen.senmat",
49
- "dosleg.posvot.posvotlib",
50
- "dosleg.stavot.stavotlib",
51
- "sens.memgrppol.grppolcod",
52
- ])
53
- .as("unique_votes"))
54
- .groupBy(["unique_votes.grppolcod"])
55
- .select(({ fn, eb }) => [
56
- "unique_votes.grppolcod as groupe_politique_code",
57
- fn.sum(eb.case().when("unique_votes.posvotlib", "=", "pour").then(1).else(0).end()).as("nombre_pour"),
58
- fn.sum(eb.case().when("unique_votes.posvotlib", "=", "contre").then(1).else(0).end()).as("nombre_contre"),
59
- fn
60
- .sum(eb.case().when("unique_votes.posvotlib", "=", "abstention").then(1).else(0).end())
61
- .as("nombre_abstentions"),
62
- fn
63
- .sum(eb.case().when("unique_votes.posvotlib", "=", "non-votant").then(1).else(0).end())
64
- .as("nombre_non_votants"),
65
- fn.count("unique_votes.senmat").as("nombre_votants"),
66
- ]));
67
- }
68
- function misesAuPoint(scrutinNum) {
69
- return jsonArrayFrom(dbSenat
70
- .withSchema("dosleg")
71
- .selectFrom("corscr")
72
- .where("corscr.scrnum", "=", scrutinNum)
73
- .select(["corscr.corscrtxt as texte", "corscr.corscrord as ordre", "corscr.corscrurl as url"]));
74
- }
75
- const findAllScrutinsQuery = dbSenat
76
- .withSchema("dosleg")
77
- .selectFrom("scr")
78
- .leftJoin("date_seance", "scr.code", "date_seance.code")
79
- .leftJoin("lecass", "date_seance.lecidt", "lecass.lecassidt")
80
- .leftJoin("lecture", "lecture.lecidt", "lecass.lecidt")
81
- .leftJoin("loi", "loi.loicod", "lecture.loicod")
82
- .leftJoin("typlec", "typlec.typleccod", "lecture.typleccod")
83
- .select(({ eb, ref, val }) => [
84
- "scr.sesann as session",
85
- "scr.scrnum as numero",
86
- rtrim(ref("date_seance.lecidt")).as("lecture_id"),
87
- rtrim(ref("lecture.leccom")).as("lecture_libelle"),
88
- "loi.signet as signet_dossier",
89
- rtrim(ref("typlec.typleclib")).as("type_lecture"),
90
- toDateString(ref("scr.scrdat")).as("date_scrutin"),
91
- toDateString(ref("scr.scrdateff")).as("date_scrutin_effective"),
92
- sql `REPLACE(scr.scrint, E'\\u0092', '''')`.as("intitule"),
93
- "scr.scrbaspag as note",
94
- "scr.scrmaj as nombre_majorite",
95
- "scr.scrmajsea as nombre_majorite_seance",
96
- "scr.scrvot as nombre_votants",
97
- "scr.scrvotsea as nombre_votants_seance",
98
- "scr.scrsuf as nombre_suffrages",
99
- "scr.scrsufsea as nombre_suffrages_seance",
100
- "scr.scrcon as nombre_contre",
101
- "scr.scrconsea as nombre_contre_seance",
102
- "scr.scrpou as nombre_pour",
103
- "scr.scrpousea as nombre_pour_seance",
104
- votes(ref("scr.scrnum"), ref("scr.sesann"), ref("scr.scrdat")).as("votes"),
105
- groupesVotants(ref("scr.scrnum"), ref("scr.sesann"), ref("scr.scrdat")).as("groupes_votants"),
106
- misesAuPoint(ref("scr.scrnum")).as("mises_au_point"),
107
- ])
108
- .$narrowType();
109
- export function findAllScrutins(fromSession) {
110
- if (fromSession !== undefined) {
111
- return findAllScrutinsQuery.where("scr.sesann", ">=", fromSession).stream();
112
- }
113
- return findAllScrutinsQuery.stream();
114
- }
@@ -1,3 +0,0 @@
1
- import { CompteRendu } from "../types/compte_rendu";
2
- export declare function parseCompteRenduIntervalFromFile(xmlFilePath: string, startIndex: number, endIndex: number, agendaEventId: string): Promise<CompteRendu | null>;
3
- export declare function sessionStartYearFromDate(d: Date): number;
@@ -1,267 +0,0 @@
1
- import fs from "fs";
2
- import * as cheerio from "cheerio";
3
- import { toCRDate } from "./util";
4
- import { makeReunionUid } from "../utils/reunion_parsing";
5
- import { yyyymmddFromPath } from "../utils/date";
6
- import { decodeHtmlEntities, dedupeSpeaker, fixApostrophes, norm } from "../utils/string_cleaning";
7
- export async function parseCompteRenduIntervalFromFile(xmlFilePath, startIndex, endIndex, agendaEventId) {
8
- try {
9
- const raw = fs.readFileSync(xmlFilePath, "utf8");
10
- const $ = cheerio.load(raw, { xml: false });
11
- const metadonnees = extractMetadonnees($, xmlFilePath);
12
- const order = $("body *").toArray();
13
- const idx = new Map(order.map((el, i) => [el, i]));
14
- const totalNodes = order.length;
15
- const clampedStart = Math.max(0, Math.min(startIndex, totalNodes - 1));
16
- const clampedEnd = Math.max(0, Math.min(endIndex, totalNodes - 1));
17
- const intervals = [
18
- {
19
- start: clampedStart,
20
- end: clampedEnd,
21
- },
22
- ];
23
- metadonnees.sommaire = extractSommaireForIntervals($, idx, intervals);
24
- const points = [];
25
- let ordre = 0;
26
- const addPoint = (p) => points.push({ ...p, ordre_absolu_seance: String(++ordre) });
27
- // Interventions
28
- $("div.intervenant").each((_, block) => {
29
- if (!elementInAnyInterval(block, idx, intervals))
30
- return;
31
- const $block = $(block);
32
- $block
33
- .find([
34
- "p[class^='titre_S']",
35
- "p.mention_titre",
36
- "p.intitule_titre",
37
- "p.mention_chapitre",
38
- "p.intitule_chapitre",
39
- "p.mention_article",
40
- "p.intitule_article",
41
- "p.mention_section",
42
- "p.intitule_section",
43
- ].join(","))
44
- .remove();
45
- const firstP = $block.find("p").first();
46
- if (!firstP || firstP.length === 0)
47
- return;
48
- const speakerLabelRaw = firstP.find(".orateur_nom").text() || firstP.find("a.lien_senfic").text() || "";
49
- const speakerLabel = dedupeSpeaker(speakerLabelRaw);
50
- const { mat, nom: nomCRI, qua: quaCRI } = readIntervenantMeta($block);
51
- const qualFromSpans = extractAndRemoveLeadingQualite($, $block);
52
- const qualite = norm(decodeHtmlEntities(quaCRI || "")) || qualFromSpans;
53
- const canonicalName = dedupeSpeaker(nomCRI || speakerLabel);
54
- const role = roleForSpeaker(speakerLabel) || roleForSpeaker(qualite) || roleForSpeaker(quaCRI || "");
55
- const speechHtml = sanitizeInterventionHtml($, $block);
56
- const speechText = norm(cheerio.load(speechHtml).text() || "");
57
- if (!speechText)
58
- return;
59
- addPoint({
60
- code_grammaire: "PAROLE_GENERIQUE",
61
- roledebat: role,
62
- orateurs: { orateur: { nom: canonicalName, id: mat || "", qualite } },
63
- texte: { _: speechHtml },
64
- });
65
- });
66
- const contenu = {
67
- quantiemes: {
68
- journee: metadonnees.dateSeance,
69
- session: metadonnees.session,
70
- },
71
- point: points,
72
- };
73
- const yyyymmdd = yyyymmddFromPath(xmlFilePath);
74
- const dateISO = `${yyyymmdd.slice(0, 4)}-${yyyymmdd.slice(4, 6)}-${yyyymmdd.slice(6, 8)}`;
75
- const seanceRef = makeReunionUid(dateISO, "SP", agendaEventId, null);
76
- return {
77
- uid: `CRSSN${yyyymmdd}E${agendaEventId}`,
78
- seanceRef,
79
- sessionRef: metadonnees.session,
80
- metadonnees,
81
- contenu,
82
- };
83
- }
84
- catch (e) {
85
- console.error(`[CRI] parseInterval error file=${xmlFilePath} interval=[${startIndex}..${endIndex}] event=${agendaEventId}:`, e);
86
- return null;
87
- }
88
- }
89
- export function sessionStartYearFromDate(d) {
90
- // Session (1th oct N → 30 sept N+1)
91
- const m = d.getMonth();
92
- const y = d.getFullYear();
93
- return m >= 9 ? y : y - 1;
94
- }
95
- function roleForSpeaker(labelOrQualite) {
96
- const s = (labelOrQualite || "").toLowerCase();
97
- 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))
98
- return "président";
99
- return "";
100
- }
101
- function readIntervenantMeta($block) {
102
- const int = $block.find("cri\\:intervenant").first();
103
- if (int.length)
104
- return { mat: int.attr("mat") || undefined, nom: int.attr("nom") || undefined, qua: int.attr("qua") || undefined };
105
- const html = $block.html() || "";
106
- const m = html.match(/<!--\s*cri:intervenant\b([^>]+)-->/i);
107
- if (!m)
108
- return {};
109
- const out = {};
110
- const re = /(\w+)="([^"]*)"/g;
111
- let a;
112
- while ((a = re.exec(m[1])))
113
- out[a[1]] = decodeHtmlEntities(a[2]);
114
- return { mat: out["mat"], nom: out["nom"], qua: out["qua"] };
115
- }
116
- function extractAndRemoveLeadingQualite($, $block) {
117
- const firstP = $block.find("p").first();
118
- if (firstP.length === 0)
119
- return "";
120
- const parts = [];
121
- let stop = false;
122
- firstP.contents().each((_, node) => {
123
- if (stop)
124
- return;
125
- if (node.type === "tag") {
126
- const $node = $(node);
127
- if ($node.hasClass("orateur_nom")) {
128
- $node.remove();
129
- return;
130
- }
131
- if ($node.hasClass("orateur_qualite")) {
132
- parts.push($node.text() || "");
133
- $node.remove();
134
- return;
135
- }
136
- const t = norm($node.text() || "");
137
- if (t)
138
- stop = true;
139
- else
140
- $node.remove();
141
- }
142
- else if (node.type === "text") {
143
- const t = norm(node.data || "");
144
- if (!t || /^[:.,;–—-]+$/.test(t)) {
145
- ;
146
- node.data = "";
147
- return;
148
- }
149
- stop = true;
150
- }
151
- });
152
- return fixApostrophes(norm(parts.join(" ")));
153
- }
154
- function sanitizeInterventionHtml($, $block) {
155
- const ps = $block.find("p").toArray();
156
- const cleaned = ps
157
- .map((p) => {
158
- const $p = $(p).clone();
159
- $p.find(".orateur_nom, .orateur_qualite").remove();
160
- $p.find("a").each((_, a) => {
161
- const $a = $(a);
162
- $a.replaceWith($a.text());
163
- });
164
- $p.find(".info_entre_parentheses").each((_, el) => {
165
- const txt = $(el).text();
166
- $(el).replaceWith($("<em/>").text(txt));
167
- });
168
- $p.find("span").each((_, span) => {
169
- const $s = $(span);
170
- if (!$s.text().trim())
171
- $s.remove();
172
- });
173
- const inner = ($p.html() || "").trim();
174
- if (!inner)
175
- return null;
176
- return `<p>${inner}</p>`;
177
- })
178
- .filter(Boolean);
179
- return cleaned.join("<br/>");
180
- }
181
- function extractSommaireForIntervals($, idx, intervals) {
182
- const inIv = (el) => elementInAnyInterval(el, idx, intervals);
183
- const root = $("body");
184
- const sommaire = { presidentSeance: { _: "" }, sommaire1: [] };
185
- // (1) Présidence (tm2) — première ligne dans l’intervalle
186
- const pres = root
187
- .find("p.tm2")
188
- .filter((_, el) => inIv(el))
189
- .first();
190
- if (pres.length)
191
- sommaire.presidentSeance = { _: norm(pres.text()) };
192
- // (2) Paras tm5 présents dans l’intervalle
193
- const paras = [];
194
- root.find("p.tm5").each((_, el) => {
195
- if (!inIv(el))
196
- return;
197
- const t = norm($(el).text());
198
- if (t)
199
- paras.push({ _: t });
200
- });
201
- if (paras.length)
202
- sommaire.para = paras.length === 1 ? paras[0] : paras;
203
- // (3) Items de 1er niveau (tm3) présents dans l’intervalle
204
- const items = [];
205
- root.find("p.tm3").each((_, el) => {
206
- if (!inIv(el))
207
- return;
208
- const $p = $(el);
209
- const full = norm($p.text() || "");
210
- if (!full)
211
- return;
212
- const numMatch = full.match(/^(\d+)\s*[.\-–—]\s*/);
213
- const valeur = numMatch ? numMatch[1] : undefined;
214
- // prefere intitule in ancre <a> if present
215
- const a = $p.find("a").first();
216
- const intituleRaw = a.length ? a.text() : full.replace(/^(\d+)\s*[.\-–—]\s*/, "");
217
- const intitule = norm(intituleRaw);
218
- // id_syceron from href="#Niv1_SOMx"
219
- const href = (a.attr("href") || "").trim();
220
- const idSyceron = href.startsWith("#") ? href.slice(1) : href;
221
- const titreStruct = { id_syceron: idSyceron || "", intitule };
222
- items.push({ valeur_pts_odj: valeur, titreStruct });
223
- });
224
- if (items.length)
225
- sommaire.sommaire1 = items;
226
- return sommaire;
227
- }
228
- function extractMetadonnees($, filePath) {
229
- let dateText = norm($("h1, h2, .page-title").first().text() || "");
230
- if (!dateText)
231
- dateText = norm($("p").first().text() || "");
232
- const dateMatch = dateText.match(/\b(\d{1,2}\s+\w+\s+\d{4})\b/i);
233
- const allText = norm($("body").text() || "");
234
- const sessionMatch = allText.match(/\bsession\s+(\d{4}-\d{4})\b/i);
235
- let dateSeance = dateMatch?.[1] || "";
236
- if (!dateSeance) {
237
- const m = filePath.match(/d(\d{4})(\d{2})(\d{2})\.xml$/i);
238
- if (m)
239
- dateSeance = `${m[1]}-${m[2]}-${m[3]}`;
240
- }
241
- dateSeance = toCRDate(dateSeance, null);
242
- return {
243
- dateSeance,
244
- dateSeanceJour: dateSeance,
245
- numSeanceJour: "",
246
- numSeance: "",
247
- typeAssemblee: "SN",
248
- legislature: "",
249
- session: sessionMatch?.[1] || "",
250
- nomFichierJo: "",
251
- validite: "",
252
- etat: "",
253
- diffusion: "",
254
- version: "1.0",
255
- environnement: "",
256
- heureGeneration: new Date(),
257
- };
258
- }
259
- function elementInAnyInterval(el, idx, intervals) {
260
- const p = idx.get(el);
261
- if (p == null)
262
- return false;
263
- for (const iv of intervals)
264
- if (p >= iv.start && p < iv.end)
265
- return true;
266
- return false;
267
- }