@tricoteuses/senat 2.22.16 → 3.0.0

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 (345) hide show
  1. package/README.md +168 -0
  2. package/lib/aggregates.d.ts +52 -0
  3. package/lib/aggregates.js +930 -0
  4. package/lib/aggregates.mjs +713 -0
  5. package/lib/aggregates.ts +833 -0
  6. package/lib/config.d.ts +10 -0
  7. package/lib/config.js +16 -0
  8. package/lib/config.mjs +16 -0
  9. package/lib/config.ts +26 -0
  10. package/lib/databases.d.ts +2 -0
  11. package/lib/databases.js +26 -0
  12. package/lib/databases.mjs +57 -0
  13. package/lib/databases.ts +71 -0
  14. package/lib/datasets.d.ts +34 -0
  15. package/lib/datasets.js +233 -0
  16. package/lib/datasets.mjs +78 -0
  17. package/lib/datasets.ts +118 -0
  18. package/lib/fields.d.ts +10 -0
  19. package/lib/fields.js +68 -0
  20. package/lib/fields.mjs +22 -0
  21. package/lib/fields.ts +29 -0
  22. package/lib/git.d.ts +26 -0
  23. package/lib/git.js +167 -0
  24. package/lib/index.d.ts +13 -0
  25. package/lib/index.js +1 -0
  26. package/lib/index.mjs +7 -0
  27. package/lib/index.ts +64 -0
  28. package/lib/inserters.d.ts +98 -0
  29. package/lib/inserters.js +500 -0
  30. package/lib/inserters.mjs +360 -0
  31. package/lib/inserters.ts +521 -0
  32. package/lib/legislatures.json +38 -0
  33. package/lib/loaders.d.ts +58 -0
  34. package/lib/loaders.js +286 -0
  35. package/lib/loaders.mjs +158 -0
  36. package/lib/loaders.ts +271 -0
  37. package/lib/model/agenda.d.ts +6 -0
  38. package/lib/model/agenda.js +148 -0
  39. package/lib/model/ameli.d.ts +51 -0
  40. package/lib/model/ameli.js +149 -0
  41. package/lib/model/ameli.mjs +84 -0
  42. package/lib/model/ameli.ts +100 -0
  43. package/lib/model/commission.d.ts +18 -0
  44. package/lib/model/commission.js +269 -0
  45. package/lib/model/debats.d.ts +67 -0
  46. package/lib/model/debats.js +95 -0
  47. package/lib/model/debats.mjs +43 -0
  48. package/lib/model/debats.ts +68 -0
  49. package/lib/model/documents.d.ts +12 -0
  50. package/lib/model/documents.js +151 -0
  51. package/lib/model/dosleg.d.ts +7 -0
  52. package/lib/model/dosleg.js +326 -0
  53. package/lib/model/dosleg.mjs +196 -0
  54. package/lib/model/dosleg.ts +240 -0
  55. package/lib/model/index.d.ts +7 -0
  56. package/lib/model/index.js +7 -0
  57. package/lib/model/index.mjs +5 -0
  58. package/lib/model/index.ts +15 -0
  59. package/lib/model/questions.d.ts +45 -0
  60. package/lib/model/questions.js +89 -0
  61. package/lib/model/questions.mjs +71 -0
  62. package/lib/model/questions.ts +93 -0
  63. package/lib/model/scrutins.d.ts +13 -0
  64. package/lib/model/scrutins.js +114 -0
  65. package/lib/model/seance.d.ts +3 -0
  66. package/lib/model/seance.js +267 -0
  67. package/lib/model/sens.d.ts +146 -0
  68. package/lib/model/sens.js +454 -0
  69. package/lib/model/sens.mjs +415 -0
  70. package/lib/model/sens.ts +516 -0
  71. package/lib/model/texte.d.ts +7 -0
  72. package/lib/model/texte.js +256 -0
  73. package/lib/model/texte.mjs +208 -0
  74. package/lib/model/texte.ts +229 -0
  75. package/lib/model/util.d.ts +9 -0
  76. package/lib/model/util.js +38 -0
  77. package/lib/model/util.mjs +19 -0
  78. package/lib/model/util.ts +32 -0
  79. package/lib/parsers/texte.d.ts +7 -0
  80. package/lib/parsers/texte.js +228 -0
  81. package/lib/raw_types/ameli.d.ts +914 -0
  82. package/lib/raw_types/ameli.js +5 -0
  83. package/lib/raw_types/ameli.mjs +163 -0
  84. package/lib/raw_types/debats.d.ts +207 -0
  85. package/lib/raw_types/debats.js +5 -0
  86. package/lib/raw_types/debats.mjs +58 -0
  87. package/lib/raw_types/dosleg.d.ts +1619 -0
  88. package/lib/raw_types/dosleg.js +5 -0
  89. package/lib/raw_types/dosleg.mjs +438 -0
  90. package/lib/raw_types/questions.d.ts +419 -0
  91. package/lib/raw_types/questions.js +5 -0
  92. package/lib/raw_types/questions.mjs +11 -0
  93. package/lib/raw_types/senat.d.ts +11368 -0
  94. package/lib/raw_types/senat.js +5 -0
  95. package/lib/raw_types/sens.d.ts +8248 -0
  96. package/lib/raw_types/sens.js +5 -0
  97. package/lib/raw_types/sens.mjs +508 -0
  98. package/lib/raw_types_kysely/ameli.d.ts +915 -0
  99. package/lib/raw_types_kysely/ameli.js +7 -0
  100. package/lib/raw_types_kysely/ameli.mjs +5 -0
  101. package/lib/raw_types_kysely/ameli.ts +951 -0
  102. package/lib/raw_types_kysely/debats.d.ts +207 -0
  103. package/lib/raw_types_kysely/debats.js +7 -0
  104. package/lib/raw_types_kysely/debats.mjs +5 -0
  105. package/lib/raw_types_kysely/debats.ts +222 -0
  106. package/lib/raw_types_kysely/dosleg.d.ts +3532 -0
  107. package/lib/raw_types_kysely/dosleg.js +7 -0
  108. package/lib/raw_types_kysely/dosleg.mjs +5 -0
  109. package/lib/raw_types_kysely/dosleg.ts +3621 -0
  110. package/lib/raw_types_kysely/questions.d.ts +414 -0
  111. package/lib/raw_types_kysely/questions.js +7 -0
  112. package/lib/raw_types_kysely/questions.mjs +5 -0
  113. package/lib/raw_types_kysely/questions.ts +426 -0
  114. package/lib/raw_types_kysely/sens.d.ts +4394 -0
  115. package/lib/raw_types_kysely/sens.js +7 -0
  116. package/lib/raw_types_kysely/sens.mjs +5 -0
  117. package/lib/raw_types_kysely/sens.ts +4499 -0
  118. package/lib/raw_types_schemats/ameli.d.ts +539 -0
  119. package/lib/raw_types_schemats/ameli.js +2 -0
  120. package/lib/raw_types_schemats/ameli.mjs +2 -0
  121. package/lib/raw_types_schemats/ameli.ts +601 -0
  122. package/lib/raw_types_schemats/debats.d.ts +127 -0
  123. package/lib/raw_types_schemats/debats.js +2 -0
  124. package/lib/raw_types_schemats/debats.mjs +2 -0
  125. package/lib/raw_types_schemats/debats.ts +145 -0
  126. package/lib/raw_types_schemats/dosleg.d.ts +977 -0
  127. package/lib/raw_types_schemats/dosleg.js +2 -0
  128. package/lib/raw_types_schemats/dosleg.mjs +2 -0
  129. package/lib/raw_types_schemats/dosleg.ts +2193 -0
  130. package/lib/raw_types_schemats/questions.d.ts +235 -0
  131. package/lib/raw_types_schemats/questions.js +2 -0
  132. package/lib/raw_types_schemats/questions.mjs +2 -0
  133. package/lib/raw_types_schemats/questions.ts +249 -0
  134. package/lib/raw_types_schemats/sens.d.ts +6915 -0
  135. package/lib/raw_types_schemats/sens.js +2 -0
  136. package/lib/raw_types_schemats/sens.mjs +2 -0
  137. package/lib/raw_types_schemats/sens.ts +2907 -0
  138. package/lib/scripts/convert_data.d.ts +1 -0
  139. package/lib/scripts/convert_data.js +354 -0
  140. package/lib/scripts/convert_data.mjs +181 -0
  141. package/lib/scripts/convert_data.ts +243 -0
  142. package/lib/scripts/data-download.d.ts +1 -0
  143. package/lib/scripts/data-download.js +12 -0
  144. package/lib/scripts/datautil.d.ts +8 -0
  145. package/lib/scripts/datautil.js +34 -0
  146. package/lib/scripts/datautil.mjs +16 -0
  147. package/lib/scripts/datautil.ts +19 -0
  148. package/lib/scripts/images/transparent_150x192.jpg +0 -0
  149. package/lib/scripts/images/transparent_155x225.jpg +0 -0
  150. package/lib/scripts/parse_textes.d.ts +1 -0
  151. package/lib/scripts/parse_textes.js +44 -0
  152. package/lib/scripts/parse_textes.mjs +46 -0
  153. package/lib/scripts/parse_textes.ts +65 -0
  154. package/lib/scripts/retrieve_agenda.d.ts +1 -0
  155. package/lib/scripts/retrieve_agenda.js +132 -0
  156. package/lib/scripts/retrieve_cr_commission.d.ts +1 -0
  157. package/lib/scripts/retrieve_cr_commission.js +364 -0
  158. package/lib/scripts/retrieve_cr_seance.d.ts +6 -0
  159. package/lib/scripts/retrieve_cr_seance.js +347 -0
  160. package/lib/scripts/retrieve_documents.d.ts +3 -0
  161. package/lib/scripts/retrieve_documents.js +219 -0
  162. package/lib/scripts/retrieve_documents.mjs +249 -0
  163. package/lib/scripts/retrieve_documents.ts +298 -0
  164. package/lib/scripts/retrieve_open_data.d.ts +1 -0
  165. package/lib/scripts/retrieve_open_data.js +315 -0
  166. package/lib/scripts/retrieve_open_data.mjs +217 -0
  167. package/lib/scripts/retrieve_open_data.ts +268 -0
  168. package/lib/scripts/retrieve_senateurs_photos.d.ts +1 -0
  169. package/lib/scripts/retrieve_senateurs_photos.js +147 -0
  170. package/lib/scripts/retrieve_senateurs_photos.mjs +147 -0
  171. package/lib/scripts/retrieve_senateurs_photos.ts +177 -0
  172. package/lib/scripts/retrieve_videos.d.ts +1 -0
  173. package/lib/scripts/retrieve_videos.js +461 -0
  174. package/lib/scripts/shared/cli_helpers.d.ts +95 -0
  175. package/lib/scripts/shared/cli_helpers.js +91 -0
  176. package/lib/scripts/shared/cli_helpers.ts +36 -0
  177. package/lib/scripts/shared/util.d.ts +4 -0
  178. package/lib/scripts/shared/util.js +35 -0
  179. package/lib/scripts/shared/util.ts +33 -0
  180. package/lib/scripts/test_iter_load.d.ts +1 -0
  181. package/lib/scripts/test_iter_load.js +12 -0
  182. package/lib/src/config.d.ts +22 -0
  183. package/lib/src/config.js +17 -7
  184. package/lib/src/conversion_textes.js +5 -1
  185. package/lib/src/databases.d.ts +2 -1
  186. package/lib/src/databases_postgres.d.ts +4 -0
  187. package/lib/src/databases_postgres.js +23 -0
  188. package/lib/src/datasets.d.ts +4 -0
  189. package/lib/src/datasets.js +16 -2
  190. package/lib/src/git.d.ts +1 -0
  191. package/lib/src/git.js +45 -11
  192. package/lib/src/index.d.ts +19 -8
  193. package/lib/src/index.js +6 -1
  194. package/lib/src/loaders.js +10 -4
  195. package/lib/src/model/agenda.js +2 -2
  196. package/lib/src/model/ameli.d.ts +64 -52
  197. package/lib/src/model/ameli.js +147 -145
  198. package/lib/src/model/ameli_postgres.d.ts +67 -0
  199. package/lib/src/model/ameli_postgres.js +150 -0
  200. package/lib/src/model/commission.d.ts +3 -2
  201. package/lib/src/model/commission.js +2 -2
  202. package/lib/src/model/debats.d.ts +38 -66
  203. package/lib/src/model/debats.js +110 -93
  204. package/lib/src/model/documents.d.ts +32 -12
  205. package/lib/src/model/documents.js +171 -130
  206. package/lib/src/model/dosleg.d.ts +142 -5
  207. package/lib/src/model/dosleg.js +298 -156
  208. package/lib/src/model/questions.d.ts +54 -45
  209. package/lib/src/model/questions.js +89 -87
  210. package/lib/src/model/scrutins.d.ts +48 -13
  211. package/lib/src/model/scrutins.js +118 -111
  212. package/lib/src/model/seance.js +3 -3
  213. package/lib/src/model/sens.d.ts +109 -179
  214. package/lib/src/model/sens.js +384 -484
  215. package/lib/src/model/util.d.ts +0 -8
  216. package/lib/src/model/util.js +0 -23
  217. package/lib/src/parsers/texte.js +7 -7
  218. package/lib/src/raw_types/ameli.d.ts +1651 -803
  219. package/lib/src/raw_types/ameli.js +1816 -5
  220. package/lib/src/raw_types/debats.d.ts +353 -180
  221. package/lib/src/raw_types/debats.js +517 -5
  222. package/lib/src/raw_types/dosleg.d.ts +2862 -1527
  223. package/lib/src/raw_types/dosleg.js +4354 -5
  224. package/lib/src/raw_types/questions.d.ts +671 -395
  225. package/lib/src/raw_types/questions.js +1303 -5
  226. package/lib/src/raw_types/sens.d.ts +7743 -8148
  227. package/lib/src/raw_types/sens.js +10429 -5
  228. package/lib/src/raw_types_schemats/ameli.d.ts +4 -2
  229. package/lib/src/raw_types_schemats/debats.d.ts +2 -2
  230. package/lib/src/raw_types_schemats/dosleg.d.ts +2 -2
  231. package/lib/src/raw_types_schemats/questions.d.ts +2 -2
  232. package/lib/src/raw_types_schemats/sens.d.ts +10 -4216
  233. package/lib/src/scripts/convert_data.js +7 -6
  234. package/lib/src/scripts/convert_xml_to_html.js +2 -2
  235. package/lib/src/scripts/data-download.js +3 -2
  236. package/lib/src/scripts/retrieve_agenda.js +21 -9
  237. package/lib/src/scripts/retrieve_cr_commission.js +17 -17
  238. package/lib/src/scripts/retrieve_cr_seance.d.ts +14 -1
  239. package/lib/src/scripts/retrieve_cr_seance.js +10 -11
  240. package/lib/src/scripts/retrieve_documents.d.ts +11 -2
  241. package/lib/src/scripts/retrieve_documents.js +25 -14
  242. package/lib/src/scripts/retrieve_open_data.js +514 -153
  243. package/lib/src/scripts/retrieve_senateurs_photos.js +25 -11
  244. package/lib/src/scripts/retrieve_videos.js +12 -11
  245. package/lib/src/scripts/shared/cli_helpers.d.ts +1 -6
  246. package/lib/src/scripts/shared/cli_helpers.js +9 -8
  247. package/lib/src/scripts/shared/incremental_import_sql.d.ts +2 -0
  248. package/lib/src/scripts/shared/incremental_import_sql.js +894 -0
  249. package/lib/src/scripts/shared/prefixed_tables.d.ts +10 -0
  250. package/lib/src/scripts/shared/prefixed_tables.js +36 -0
  251. package/lib/src/scripts/shared/schema_version.d.ts +3 -0
  252. package/lib/src/scripts/shared/schema_version.js +97 -0
  253. package/lib/src/scripts/shared/staging_import.d.ts +3 -0
  254. package/lib/src/scripts/shared/staging_import.js +80 -0
  255. package/lib/src/scripts/shared/staging_metadata_sql.d.ts +1 -0
  256. package/lib/src/scripts/shared/staging_metadata_sql.js +221 -0
  257. package/lib/src/scripts/validate_prefixed_tables.d.ts +1 -0
  258. package/lib/src/scripts/validate_prefixed_tables.js +101 -0
  259. package/lib/src/types/ameli.d.ts +4 -4
  260. package/lib/src/types/debats.d.ts +2 -2
  261. package/lib/src/types/dosleg.d.ts +39 -39
  262. package/lib/src/types/questions.d.ts +2 -2
  263. package/lib/src/types/sens.d.ts +0 -2
  264. package/lib/src/types/texte.d.ts +1 -1
  265. package/lib/src/utils/cr_spliting.d.ts +9 -6
  266. package/lib/src/utils/cr_spliting.js +6 -101
  267. package/lib/src/utils/reunion_odj_building.d.ts +7 -3
  268. package/lib/src/utils/reunion_parsing.d.ts +2 -1
  269. package/lib/src/utils/reunion_parsing.js +2 -2
  270. package/lib/src/videos/match.js +8 -5
  271. package/lib/src/videos/pipeline.d.ts +6 -2
  272. package/lib/src/videos/pipeline.js +21 -8
  273. package/lib/src/videos/search.js +6 -2
  274. package/lib/strings.d.ts +1 -0
  275. package/lib/strings.js +18 -0
  276. package/lib/strings.mjs +18 -0
  277. package/lib/strings.ts +26 -0
  278. package/lib/tests/incrementalImportSql.test.d.ts +1 -0
  279. package/lib/tests/incrementalImportSql.test.js +155 -0
  280. package/lib/tests/prefixedTables.test.d.ts +1 -0
  281. package/lib/tests/prefixedTables.test.js +22 -0
  282. package/lib/tests/schemaVersion.test.d.ts +1 -0
  283. package/lib/tests/schemaVersion.test.js +23 -0
  284. package/lib/tests/validatePrefixedTables.test.d.ts +1 -0
  285. package/lib/tests/validatePrefixedTables.test.js +14 -0
  286. package/lib/types/agenda.d.ts +44 -0
  287. package/lib/types/agenda.js +1 -0
  288. package/lib/types/ameli.d.ts +5 -0
  289. package/lib/types/ameli.js +1 -0
  290. package/lib/types/ameli.mjs +13 -0
  291. package/lib/types/ameli.ts +21 -0
  292. package/lib/types/compte_rendu.d.ts +83 -0
  293. package/lib/types/compte_rendu.js +1 -0
  294. package/lib/types/debats.d.ts +2 -0
  295. package/lib/types/debats.js +1 -0
  296. package/lib/types/debats.mjs +2 -0
  297. package/lib/types/debats.ts +6 -0
  298. package/lib/types/dosleg.d.ts +70 -0
  299. package/lib/types/dosleg.js +1 -0
  300. package/lib/types/dosleg.mjs +151 -0
  301. package/lib/types/dosleg.ts +284 -0
  302. package/lib/types/questions.d.ts +2 -0
  303. package/lib/types/questions.js +1 -0
  304. package/lib/types/questions.mjs +1 -0
  305. package/lib/types/questions.ts +3 -0
  306. package/lib/types/sens.d.ts +10 -0
  307. package/lib/types/sens.js +1 -0
  308. package/lib/types/sens.mjs +1 -0
  309. package/lib/types/sens.ts +12 -0
  310. package/lib/types/sessions.d.ts +5 -0
  311. package/lib/types/sessions.js +84 -0
  312. package/lib/types/sessions.mjs +43 -0
  313. package/lib/types/sessions.ts +42 -0
  314. package/lib/types/texte.d.ts +74 -0
  315. package/lib/types/texte.js +16 -0
  316. package/lib/types/texte.mjs +16 -0
  317. package/lib/types/texte.ts +76 -0
  318. package/lib/typings/windows-1252.d.js +2 -0
  319. package/lib/typings/windows-1252.d.mjs +2 -0
  320. package/lib/typings/windows-1252.d.ts +11 -0
  321. package/lib/utils/cr_spliting.d.ts +28 -0
  322. package/lib/utils/cr_spliting.js +265 -0
  323. package/lib/utils/date.d.ts +10 -0
  324. package/lib/utils/date.js +100 -0
  325. package/lib/utils/nvs-timecode.d.ts +7 -0
  326. package/lib/utils/nvs-timecode.js +79 -0
  327. package/lib/utils/reunion_grouping.d.ts +9 -0
  328. package/lib/utils/reunion_grouping.js +361 -0
  329. package/lib/utils/reunion_odj_building.d.ts +5 -0
  330. package/lib/utils/reunion_odj_building.js +154 -0
  331. package/lib/utils/reunion_parsing.d.ts +23 -0
  332. package/lib/utils/reunion_parsing.js +209 -0
  333. package/lib/utils/scoring.d.ts +14 -0
  334. package/lib/utils/scoring.js +147 -0
  335. package/lib/utils/string_cleaning.d.ts +7 -0
  336. package/lib/utils/string_cleaning.js +57 -0
  337. package/lib/validators/config.d.ts +9 -0
  338. package/lib/validators/config.js +10 -0
  339. package/lib/validators/config.mjs +54 -0
  340. package/lib/validators/config.ts +79 -0
  341. package/lib/validators/senat.d.ts +0 -0
  342. package/lib/validators/senat.js +28 -0
  343. package/lib/validators/senat.mjs +24 -0
  344. package/lib/validators/senat.ts +26 -0
  345. package/package.json +11 -11
@@ -0,0 +1,67 @@
1
+ export interface AmendementAuteurRow {
2
+ group_politique_code: string | null;
3
+ groupe_politique_id: number | null;
4
+ groupe_politique_libelle: string | null;
5
+ groupe_politique_libelle_court: string | null;
6
+ homonyme: string | null;
7
+ matricule: string | null;
8
+ nom: string | null;
9
+ prenom: string | null;
10
+ qualite: string | null;
11
+ rang: string | null;
12
+ }
13
+ export interface AmendementPostgresResult {
14
+ accepte_gouvernement: string | null;
15
+ alinea: number | null;
16
+ auteur_est_gouvernement: boolean;
17
+ au_nom_de_commission: string | null;
18
+ au_nom_de_groupe_politique: string | null;
19
+ auteurs: AmendementAuteurRow[];
20
+ avis_commission: string | null;
21
+ avis_gouvernement: string | null;
22
+ code_commission: string | null;
23
+ date_depot: string | null;
24
+ discussion_commune_id: number | null;
25
+ dispositif: string | null;
26
+ etat: string;
27
+ etat_texte: string | null;
28
+ etat_texte_libelle: string | null;
29
+ id: number;
30
+ identique_id: number | null;
31
+ intitule_texte: string | null;
32
+ lecture: string | null;
33
+ motion_libelle: string | null;
34
+ nature: string;
35
+ nature_texte: string | null;
36
+ nature_texte_libelle: string | null;
37
+ numero: string;
38
+ numero_absolu: string | null;
39
+ numero_adoption_texte: string | null;
40
+ numero_texte: string | null;
41
+ objet: string | null;
42
+ observations: string | null;
43
+ observations_additionnelles: string | null;
44
+ ordre: number | null;
45
+ parent_id: number | null;
46
+ revision: string | null;
47
+ session: string;
48
+ session_libelle: string;
49
+ signet_dossier_legislatif: string | null;
50
+ sort: string | null;
51
+ scrutin_num: string | null;
52
+ subdivision_commission_id: number | null;
53
+ subdivision_dupliquee: string | null;
54
+ subdivision_libelle: string | null;
55
+ subdivision_libelle_court: string | null;
56
+ subdivision_mere_id: number | null;
57
+ subdivision_position_discussion: number | null;
58
+ subdivision_position_texte: number | null;
59
+ subdivision_signet: string | null;
60
+ subdivision_type: string | null;
61
+ texte_id: number | null;
62
+ type_rectification: string | null;
63
+ type_session: string | null;
64
+ type_texte: string | null;
65
+ url: string;
66
+ }
67
+ export declare function findAllAmendementsPostgres(fromSession?: number): AsyncGenerator<AmendementPostgresResult, void, unknown>;
@@ -0,0 +1,150 @@
1
+ import { streamUnsafeQuery } from "../databases_postgres";
2
+ function buildFindAllAmendementsQuery(fromSession) {
3
+ const params = [];
4
+ const whereSession = fromSession === undefined ? "" : "where ameli.ses.ann >= $1";
5
+ if (fromSession !== undefined) {
6
+ params.push(String(fromSession));
7
+ }
8
+ return {
9
+ params,
10
+ query: `
11
+ select
12
+ ameli.ses.ann::text as session,
13
+ ameli.ses.lil as session_libelle,
14
+ ameli.typses.lib as type_session,
15
+ ameli.txt_ameli.doslegsignet as signet_dossier_legislatif,
16
+ ameli.nat.libcourt as nature_texte,
17
+ ameli.nat.lib as nature_texte_libelle,
18
+ ameli.txt_ameli.numabs as numero_texte,
19
+ ameli.txt_ameli.numado as numero_adoption_texte,
20
+ ameli.txt_ameli.int as intitule_texte,
21
+ ameli.etatxt.lic as etat_texte,
22
+ ameli.etatxt.lib as etat_texte_libelle,
23
+ ameli.etatxt.txttyp as type_texte,
24
+ ameli.lec_ameli.lib as lecture,
25
+ case ameli.amd.typ
26
+ when 'A' then 'Amendement'
27
+ when 'M' then 'Motion'
28
+ when 'S' then 'Sous-amendement'
29
+ else ''
30
+ end as nature,
31
+ ameli.amd.id,
32
+ ameli.amd.amdperid as parent_id,
33
+ ameli.amd.ideid as identique_id,
34
+ ameli.amd.discomid as discussion_commune_id,
35
+ ameli.amd.num as numero,
36
+ ameli.amd.numabs as numero_absolu,
37
+ ameli.amd.ord as ordre,
38
+ ameli.amd.accgou as accepte_gouvernement,
39
+ ameli.amd.txtid as texte_id,
40
+ ameli.sub.lib as subdivision_libelle,
41
+ ameli.sub.lic as subdivision_libelle_court,
42
+ ameli.sub.pos as subdivision_position_texte,
43
+ ameli.sub.posder as subdivision_position_discussion,
44
+ ameli.sub.merid as subdivision_mere_id,
45
+ ameli.sub.sig as subdivision_signet,
46
+ ameli.sub.comdelid as subdivision_commission_id,
47
+ ameli.sub.dupl as subdivision_dupliquee,
48
+ ameli.typsub.lib as subdivision_type,
49
+ ameli.amd.alinea,
50
+ ameli.amd.obs as observations,
51
+ ameli.amd.mot as observations_additionnelles,
52
+ to_char(ameli.amd.datdep, 'YYYY-MM-DD') as date_depot,
53
+ ameli.amd.dis as dispositif,
54
+ ameli.amd.obj as objet,
55
+ ameli.typrect.lib as type_rectification,
56
+ ameli.mot.lib as motion_libelle,
57
+ case ameli.amd.etaid
58
+ when 7 then 'Diffusé'
59
+ when 8 then 'Retiré avant réunion ou séance'
60
+ when 9 then 'Examiné en commission ou séance'
61
+ when 10 then 'Irrecevable'
62
+ when 11 then 'Irrecevable'
63
+ else ''
64
+ end as etat,
65
+ ameli.avicom.lib as avis_commission,
66
+ ameli.avigvt.lib as avis_gouvernement,
67
+ coalesce(ameli.sor.lib, ameli.irr.libirr) as sort,
68
+ ameli.amd.rev as revision,
69
+ (
70
+ case
71
+ when ameli.amd.num like '%COM%' then 'https://www.senat.fr/amendements/commissions/'
72
+ else 'https://www.senat.fr/amendements/'
73
+ end ||
74
+ ameli.ses.ann::text || '-' ||
75
+ (ameli.ses.ann + 1)::text || '/' ||
76
+ ameli.txt_ameli.numabs || '/Amdt_' ||
77
+ ameli.amd.num || '.html'
78
+ ) as url,
79
+ ameli.grppol_ameli.lilcou as au_nom_de_groupe_politique,
80
+ rtrim(ameli.com_ameli.lil) as au_nom_de_commission,
81
+ rtrim(ameli.com_ameli.cod) as code_commission,
82
+ (ameli.cab.entid is not null) as auteur_est_gouvernement,
83
+ (
84
+ select dosleg.amescr.scrnum::text
85
+ from dosleg.amescr
86
+ left join dosleg.scr
87
+ on dosleg.amescr.scrnum = dosleg.scr.scrnum
88
+ and dosleg.amescr.sesann = dosleg.scr.sesann
89
+ left join dosleg.date_seance on dosleg.scr.code = dosleg.date_seance.code
90
+ where dosleg.amescr.amescrnum = ameli.amd.num
91
+ and dosleg.amescr.sesann = ameli.ses.ann
92
+ and dosleg.date_seance.lecidt = dosleg.texte.lecassidt
93
+ limit 1
94
+ ) as scrutin_num,
95
+ (
96
+ select coalesce(json_agg(author_rows order by author_rows.rang nulls last), '[]'::json)
97
+ from (
98
+ select
99
+ ameli.amdsen.prenomuse as prenom,
100
+ ameli.amdsen.hom as homonyme,
101
+ ameli.amdsen.nomuse as nom,
102
+ ameli.amdsen.qua as qualite,
103
+ ameli.amdsen.rng::text as rang,
104
+ ameli.sen_ameli.mat as matricule,
105
+ ameli.amdsen.grpid as groupe_politique_id,
106
+ ameli.grppol_ameli.cod as group_politique_code,
107
+ ameli.grppol_ameli.libcou as groupe_politique_libelle_court,
108
+ ameli.grppol_ameli.lilcou as groupe_politique_libelle
109
+ from ameli.amdsen
110
+ left join ameli.sen_ameli on ameli.amdsen.senid = ameli.sen_ameli.entid
111
+ left join ameli.grppol_ameli on ameli.amdsen.grpid = ameli.grppol_ameli.entid
112
+ where ameli.amdsen.amdid = ameli.amd.id
113
+ order by ameli.amdsen.rng asc
114
+ ) as author_rows
115
+ ) as auteurs
116
+ from ameli.amd
117
+ left join ameli.sub on ameli.amd.subid = ameli.sub.id
118
+ left join ameli.typsub on ameli.sub.typid = ameli.typsub.id
119
+ left join ameli.typrect on ameli.amd.typrectid = ameli.typrect.id
120
+ left join ameli.txt_ameli on ameli.amd.txtid = ameli.txt_ameli.id
121
+ left join ameli.etatxt on ameli.txt_ameli.txtetaid = ameli.etatxt.id
122
+ left join ameli.ses on ameli.txt_ameli.sesdepid = ameli.ses.id
123
+ left join ameli.typses on ameli.typses.id = ameli.ses.typid
124
+ left join ameli.nat on ameli.txt_ameli.natid = ameli.nat.id
125
+ left join ameli.lec_ameli on ameli.txt_ameli.lecid = ameli.lec_ameli.id
126
+ left join dosleg.texte
127
+ on ameli.ses.ann::text = dosleg.texte.sesann
128
+ and ameli.txt_ameli.numabs = dosleg.texte.texnum
129
+ left join dosleg.lecass on dosleg.texte.lecassidt = dosleg.lecass.lecassidt
130
+ left join ameli.mot on ameli.amd.motid = ameli.mot.id
131
+ left join ameli.avicom on ameli.amd.avcid = ameli.avicom.id
132
+ left join ameli.avigvt on ameli.amd.avgid = ameli.avigvt.id
133
+ left join ameli.sor on ameli.amd.sorid = ameli.sor.id
134
+ left join ameli.irr on ameli.amd.irrid = ameli.irr.id
135
+ left join ameli.grppol_ameli on ameli.amd.nomentid = ameli.grppol_ameli.entid
136
+ left join ameli.com_ameli on ameli.amd.nomentid = ameli.com_ameli.entid
137
+ left join ameli.cab on ameli.amd.nomentid = ameli.cab.entid
138
+ ${whereSession}
139
+ `,
140
+ };
141
+ }
142
+ export async function* findAllAmendementsPostgres(fromSession) {
143
+ const { query, params } = buildFindAllAmendementsQuery(fromSession);
144
+ for await (const row of streamUnsafeQuery(query, params)) {
145
+ yield {
146
+ ...row,
147
+ auteurs: row.auteurs ?? [],
148
+ };
149
+ }
150
+ }
@@ -1,10 +1,11 @@
1
1
  import * as cheerio from "cheerio";
2
+ import type { AnyNode } from "domhandler";
2
3
  import { CompteRendu } from "../types/compte_rendu";
3
4
  import { Reunion } from "../types/agenda";
4
- export declare function getRemainingTextAfterSpeakerHeader($: cheerio.CheerioAPI, $p: cheerio.Cheerio<any>): string;
5
+ export declare function getRemainingTextAfterSpeakerHeader($: cheerio.CheerioAPI, $p: cheerio.Cheerio<AnyNode>): string;
5
6
  export type DaySection = {
6
7
  title: string;
7
- $start: cheerio.Cheerio<any>;
8
+ $start: cheerio.Cheerio<AnyNode>;
8
9
  time?: string;
9
10
  };
10
11
  export declare function cleanTitle(t: string): string;
@@ -39,7 +39,7 @@ function collectLeadingHeaderStrongEls($, $clone) {
39
39
  }
40
40
  if ($n.is("a") && $n.children("strong, b").length) {
41
41
  $n.children("strong, b").each((_, el) => {
42
- els.push($(el));
42
+ els.push(el);
43
43
  });
44
44
  continue;
45
45
  }
@@ -68,7 +68,7 @@ function buildPointsFromParagraphs($, paras) {
68
68
  const normSpeaker = (s) => s
69
69
  .normalize("NFKC")
70
70
  .replace(/\s+/g, " ")
71
- .replace(/[:\.]\s*$/, "")
71
+ .replace(/[.:]\s*$/, "")
72
72
  .trim();
73
73
  const normQual = (s) => s
74
74
  .normalize("NFKC")
@@ -1,67 +1,39 @@
1
- import { InferResult } from "kysely";
2
- export type DebatResult = InferResult<typeof findAllQuery>[0];
3
- declare const findAllQuery: import("kysely").SelectQueryBuilder<any, "debats.debats", {
4
- [x: string]: any;
1
+ export interface DebatAuteurRow {
2
+ code: string | null;
3
+ matricule: string | null;
4
+ nom: string | null;
5
+ prenom: string | null;
6
+ }
7
+ export interface DebatInterventionRow {
8
+ analyse: string | null;
9
+ auteur: DebatAuteurRow | null;
10
+ auteur_code: string;
11
+ fonction_intervenant: string | null;
12
+ id: string | null;
13
+ url: string | null;
14
+ }
15
+ export interface DebatSectionRow {
16
+ categorie: string | null;
17
+ id?: string | null;
18
+ interventions: DebatInterventionRow[];
19
+ lecture_id?: string | null;
20
+ libelle?: string | null;
21
+ numero?: string | null;
22
+ objet: string | null;
23
+ type: string | null;
24
+ url?: string | null;
25
+ }
26
+ export interface DebatLectureRow {
5
27
  id: string;
6
- date_seance: string;
7
- sections: {
8
- [x: string]: any;
9
- interventions: {
10
- [x: string]: any;
11
- auteur: {
12
- code: any;
13
- nom: any;
14
- prenom: any;
15
- matricule: any;
16
- };
17
- }[];
18
- }[];
19
- sections_divers: {
20
- [x: string]: any;
21
- interventions: {
22
- [x: string]: any;
23
- auteur: {
24
- code: any;
25
- nom: any;
26
- prenom: any;
27
- matricule: any;
28
- };
29
- }[];
30
- }[];
31
- lectures: {
32
- id: any;
33
- }[];
34
- }>;
35
- export declare function findAll(fromSession?: number): AsyncIterableIterator<{
36
- [x: string]: any;
37
- id: string;
38
- date_seance: string;
39
- sections: {
40
- [x: string]: any;
41
- interventions: {
42
- [x: string]: any;
43
- auteur: {
44
- code: any;
45
- nom: any;
46
- prenom: any;
47
- matricule: any;
48
- };
49
- }[];
50
- }[];
51
- sections_divers: {
52
- [x: string]: any;
53
- interventions: {
54
- [x: string]: any;
55
- auteur: {
56
- code: any;
57
- nom: any;
58
- prenom: any;
59
- matricule: any;
60
- };
61
- }[];
62
- }[];
63
- lectures: {
64
- id: any;
65
- }[];
66
- }>;
67
- export {};
28
+ }
29
+ export interface DebatResult {
30
+ date_seance: string | null;
31
+ etat_synchronisation: string | null;
32
+ id: string | null;
33
+ lectures: DebatLectureRow[];
34
+ numero: string | null;
35
+ sections: DebatSectionRow[];
36
+ sections_divers: DebatSectionRow[];
37
+ url: string | null;
38
+ }
39
+ export declare function findAll(): AsyncGenerator<DebatResult, void, unknown>;
@@ -1,95 +1,112 @@
1
- import { jsonArrayFrom, jsonBuildObject } from "kysely/helpers/postgres";
2
- import { dbSenat } from "../databases";
3
- import { ID_DATE_FORMAT } from "../scripts/datautil";
4
- import { toDateString } from "./util";
5
- function sectionsLegislatives(dateSeance) {
6
- return jsonArrayFrom(dbSenat
7
- .selectFrom("debats.secdis")
8
- .leftJoin("debats.typsec", "debats.secdis.typseccod", "debats.typsec.typseccod")
9
- .where("debats.secdis.datsea", "=", dateSeance)
10
- .select(({ ref }) => [
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",
19
- ])
20
- .orderBy("debats.secdis.secdisordid", "asc"));
1
+ import { streamUnsafeQuery } from "../databases_postgres";
2
+ function buildFindAllDebatsQuery() {
3
+ return {
4
+ params: [],
5
+ query: `
6
+ select
7
+ to_char(debats.datsea, 'YYYYMMDD') as id,
8
+ to_char(debats.datsea, 'YYYY-MM-DD') as date_seance,
9
+ debats.numero::text as numero,
10
+ debats.deburl as url,
11
+ debats.debsyn as etat_synchronisation,
12
+ (
13
+ select coalesce(json_agg(section_rows order by section_rows.section_order nulls last), '[]'::json)
14
+ from (
15
+ select
16
+ secdis.secdisordid::text as id,
17
+ secdis.secdisnum as numero,
18
+ secdis.secdisobj as objet,
19
+ secdis.secdisurl as url,
20
+ typsec.typseclib as type,
21
+ typsec.typseccat as categorie,
22
+ secdis.lecassidt as lecture_id,
23
+ secdis.secdisordid as section_order,
24
+ (
25
+ select coalesce(
26
+ json_agg(intervention_rows order by intervention_rows.intervention_order nulls last),
27
+ '[]'::json
28
+ )
29
+ from (
30
+ select
31
+ intpjl.intordid::text as id,
32
+ intpjl.autcod as auteur_code,
33
+ intpjl.intfon as fonction_intervenant,
34
+ intpjl.inturl as url,
35
+ intpjl.intana as analyse,
36
+ json_build_object(
37
+ 'code', auteur.autcod,
38
+ 'nom', auteur.nomuse,
39
+ 'prenom', auteur.prenom,
40
+ 'matricule', auteur.autmat
41
+ ) as auteur,
42
+ intpjl.intordid as intervention_order
43
+ from senat.debats_intpjl as intpjl
44
+ left join senat.dosleg_auteur as auteur on intpjl.autcod = auteur.autcod
45
+ where intpjl.secdiscle = secdis.secdiscle
46
+ ) as intervention_rows
47
+ ) as interventions
48
+ from senat.debats_secdis as secdis
49
+ left join senat.debats_typsec as typsec on secdis.typseccod = typsec.typseccod
50
+ where secdis.datsea = debats.datsea
51
+ ) as section_rows
52
+ ) as sections,
53
+ (
54
+ select coalesce(json_agg(section_rows), '[]'::json)
55
+ from (
56
+ select
57
+ secdivers.secdiverslibelle as libelle,
58
+ secdivers.secdiversobj as objet,
59
+ typsec.typseclib as type,
60
+ typsec.typseccat as categorie,
61
+ (
62
+ select coalesce(
63
+ json_agg(intervention_rows order by intervention_rows.intervention_order nulls last),
64
+ '[]'::json
65
+ )
66
+ from (
67
+ select
68
+ intdivers.intdiversordid::text as id,
69
+ intdivers.autcod as auteur_code,
70
+ intdivers.intfon as fonction_intervenant,
71
+ intdivers.inturl as url,
72
+ intdivers.intana as analyse,
73
+ json_build_object(
74
+ 'code', auteur.autcod,
75
+ 'nom', auteur.nomuse,
76
+ 'prenom', auteur.prenom,
77
+ 'matricule', auteur.autmat
78
+ ) as auteur,
79
+ intdivers.intdiversordid as intervention_order
80
+ from senat.debats_intdivers as intdivers
81
+ left join senat.dosleg_auteur as auteur on intdivers.autcod = auteur.autcod
82
+ where intdivers.secdiverscle = secdivers.secdiverscle
83
+ ) as intervention_rows
84
+ ) as interventions
85
+ from senat.debats_secdivers as secdivers
86
+ left join senat.debats_typsec as typsec on secdivers.typseccod = typsec.typseccod
87
+ where secdivers.datsea = debats.datsea
88
+ ) as section_rows
89
+ ) as sections_divers,
90
+ (
91
+ select coalesce(json_agg(lecture_rows), '[]'::json)
92
+ from (
93
+ select lecassdeb.lecassidt as id
94
+ from senat.debats_lecassdeb as lecassdeb
95
+ where lecassdeb.datsea = debats.datsea
96
+ ) as lecture_rows
97
+ ) as lectures
98
+ from senat.debats_debats as debats
99
+ `,
100
+ };
21
101
  }
22
- function interventionsLegislatives(sectionId) {
23
- return jsonArrayFrom(dbSenat
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"),
39
- ])
40
- .orderBy("debats.intpjl.intordid", "asc"));
41
- }
42
- function sectionsNonLegislatives(dateSeance) {
43
- return jsonArrayFrom(dbSenat
44
- .selectFrom("debats.secdivers")
45
- .leftJoin("debats.typsec", "debats.secdivers.typseccod", "debats.typsec.typseccod")
46
- .where("debats.secdivers.datsea", "=", dateSeance)
47
- .select(({ ref }) => [
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"),
53
- ]));
54
- }
55
- function interventionsNonLegislatives(sectionId) {
56
- return jsonArrayFrom(dbSenat
57
- .selectFrom("debats.intdivers")
58
- .leftJoin("dosleg.auteur", "debats.intdivers.autcod", "dosleg.auteur.autcod")
59
- .where("debats.intdivers.intdiverscle", "=", sectionId)
60
- .select(({ ref, val }) => [
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"),
72
- ])
73
- .orderBy("debats.intdivers.intdiversordid", "asc"));
74
- }
75
- function lecturesAssemblee(dateSeance) {
76
- return jsonArrayFrom(dbSenat
77
- .selectFrom("debats.lecassdeb")
78
- .where("debats.lecassdeb.datsea", "=", dateSeance)
79
- .select("debats.lecassdeb.lecassidt as id"));
80
- }
81
- const findAllQuery = dbSenat
82
- .selectFrom("debats.debats")
83
- .select(({ ref, val }) => [
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"),
92
- ]);
93
- export function findAll(fromSession) {
94
- return findAllQuery.stream();
102
+ export async function* findAll() {
103
+ const { query, params } = buildFindAllDebatsQuery();
104
+ for await (const row of streamUnsafeQuery(query, params)) {
105
+ yield {
106
+ ...row,
107
+ lectures: row.lectures ?? [],
108
+ sections: row.sections ?? [],
109
+ sections_divers: row.sections_divers ?? [],
110
+ };
111
+ }
95
112
  }
@@ -1,12 +1,32 @@
1
- import { Expression, InferResult, SelectQueryBuilder } from "kysely";
2
- export declare function rapports(lectureAssembleeId: Expression<string>): import("kysely").RawBuilder<{
3
- [x: string]: any;
4
- }[]>;
5
- declare const queryTextes: SelectQueryBuilder<any, any, any>;
6
- export declare function textes(lectureAssembleeId: Expression<string>): import("kysely").RawBuilder<{
7
- [x: string]: any;
8
- }[]>;
9
- export declare function findAllTextes(): AsyncIterableIterator<DocumentResult>;
10
- export declare function findAllRapports(): AsyncIterableIterator<DocumentResult>;
11
- export type DocumentResult = InferResult<typeof queryTextes>[0];
12
- export {};
1
+ export interface AuteurDocumentRow {
2
+ matricule: string | null;
3
+ nom_usuel: string;
4
+ ordre: string | null;
5
+ prenom: string | null;
6
+ qualite: string | null;
7
+ role: string | null;
8
+ }
9
+ export interface DocumentAnnexeRow {
10
+ type_document: string;
11
+ url: string | null;
12
+ }
13
+ export interface DocumentResult {
14
+ auteurs: AuteurDocumentRow[];
15
+ code_adoption?: string | null;
16
+ code_organisme: string | null;
17
+ date: string;
18
+ documents_annexes?: DocumentAnnexeRow[];
19
+ id: string | null;
20
+ modification?: string | null;
21
+ numero: number | string | null;
22
+ ordre_origine?: string | null;
23
+ origine?: string | null;
24
+ session: number | null;
25
+ signet_dossier?: string | null;
26
+ sous_titre?: string | null;
27
+ titre: string | null;
28
+ type: string | null;
29
+ url: string | null;
30
+ }
31
+ export declare function findAllTextes(): AsyncGenerator<DocumentResult, void, unknown>;
32
+ export declare function findAllRapports(): AsyncGenerator<DocumentResult, void, unknown>;