@tricoteuses/senat 3.1.22 → 3.1.23

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 (388) hide show
  1. package/LICENSE.md +32 -32
  2. package/README.md +326 -326
  3. package/lib/src/other_types/collaborateurs.d.ts +5 -0
  4. package/lib/src/parsers/collaborateurs.d.ts +44 -0
  5. package/lib/src/parsers/collaborateurs.js +157 -0
  6. package/lib/src/scripts/retrieve_collaborateurs.js +166 -0
  7. package/lib/src/scripts/retrieve_cr_seance.js +34 -25
  8. package/lib/src/scripts/retrieve_videos.js +13 -8
  9. package/lib/src/scripts/shared/incremental_import_sql.js +866 -859
  10. package/lib/src/scripts/shared/schema_version.js +84 -84
  11. package/lib/src/scripts/shared/staging_metadata_sql.js +214 -214
  12. package/lib/src/scripts/validate_prefixed_tables.js +12 -12
  13. package/lib/src/server/ameli.js +14 -13
  14. package/lib/src/server/conversion_textes.js +106 -106
  15. package/lib/src/server/debats.js +10 -10
  16. package/lib/src/server/documents.js +22 -22
  17. package/lib/src/server/dosleg.js +33 -33
  18. package/lib/src/server/questions.js +10 -10
  19. package/lib/src/server/scrutins.js +3 -3
  20. package/lib/src/server/sens.js +19 -19
  21. package/lib/src/utils/reunion_odj_building.js +0 -4
  22. package/lib/src/videos/match.js +7 -5
  23. package/lib/src/videos/pipeline.js +26 -19
  24. package/lib/tests/collaborateurs.test.js +115 -0
  25. package/lib/tests/incrementalImportSql.test.js +4 -1
  26. package/package.json +119 -119
  27. package/lib/add-js-extensions-v2.js +0 -23
  28. package/lib/add-js-extensions.js +0 -17
  29. package/lib/aggregates.d.ts +0 -52
  30. package/lib/aggregates.js +0 -930
  31. package/lib/aggregates.mjs +0 -713
  32. package/lib/aggregates.ts +0 -833
  33. package/lib/config.d.ts +0 -10
  34. package/lib/config.js +0 -16
  35. package/lib/config.mjs +0 -16
  36. package/lib/config.ts +0 -26
  37. package/lib/databases.d.ts +0 -2
  38. package/lib/databases.js +0 -26
  39. package/lib/databases.mjs +0 -57
  40. package/lib/databases.ts +0 -71
  41. package/lib/datasets.d.ts +0 -34
  42. package/lib/datasets.js +0 -233
  43. package/lib/datasets.mjs +0 -78
  44. package/lib/datasets.ts +0 -118
  45. package/lib/fields.d.ts +0 -10
  46. package/lib/fields.js +0 -68
  47. package/lib/fields.mjs +0 -22
  48. package/lib/fields.ts +0 -29
  49. package/lib/git.d.ts +0 -26
  50. package/lib/git.js +0 -167
  51. package/lib/index.d.ts +0 -13
  52. package/lib/index.js +0 -1
  53. package/lib/index.mjs +0 -7
  54. package/lib/index.ts +0 -64
  55. package/lib/inserters.d.ts +0 -98
  56. package/lib/inserters.js +0 -500
  57. package/lib/inserters.mjs +0 -360
  58. package/lib/inserters.ts +0 -521
  59. package/lib/legislatures.json +0 -38
  60. package/lib/loaders.d.ts +0 -58
  61. package/lib/loaders.js +0 -286
  62. package/lib/loaders.mjs +0 -158
  63. package/lib/loaders.ts +0 -271
  64. package/lib/model/agenda.d.ts +0 -6
  65. package/lib/model/agenda.js +0 -148
  66. package/lib/model/ameli.d.ts +0 -51
  67. package/lib/model/ameli.js +0 -149
  68. package/lib/model/ameli.mjs +0 -84
  69. package/lib/model/ameli.ts +0 -100
  70. package/lib/model/commission.d.ts +0 -18
  71. package/lib/model/commission.js +0 -269
  72. package/lib/model/debats.d.ts +0 -67
  73. package/lib/model/debats.js +0 -95
  74. package/lib/model/debats.mjs +0 -43
  75. package/lib/model/debats.ts +0 -68
  76. package/lib/model/documents.d.ts +0 -12
  77. package/lib/model/documents.js +0 -151
  78. package/lib/model/dosleg.d.ts +0 -7
  79. package/lib/model/dosleg.js +0 -326
  80. package/lib/model/dosleg.mjs +0 -196
  81. package/lib/model/dosleg.ts +0 -240
  82. package/lib/model/index.d.ts +0 -7
  83. package/lib/model/index.js +0 -7
  84. package/lib/model/index.mjs +0 -5
  85. package/lib/model/index.ts +0 -15
  86. package/lib/model/questions.d.ts +0 -45
  87. package/lib/model/questions.js +0 -89
  88. package/lib/model/questions.mjs +0 -71
  89. package/lib/model/questions.ts +0 -93
  90. package/lib/model/scrutins.d.ts +0 -13
  91. package/lib/model/scrutins.js +0 -114
  92. package/lib/model/seance.d.ts +0 -3
  93. package/lib/model/seance.js +0 -267
  94. package/lib/model/sens.d.ts +0 -146
  95. package/lib/model/sens.js +0 -454
  96. package/lib/model/sens.mjs +0 -415
  97. package/lib/model/sens.ts +0 -516
  98. package/lib/model/texte.d.ts +0 -7
  99. package/lib/model/texte.js +0 -256
  100. package/lib/model/texte.mjs +0 -208
  101. package/lib/model/texte.ts +0 -229
  102. package/lib/model/util.d.ts +0 -9
  103. package/lib/model/util.js +0 -38
  104. package/lib/model/util.mjs +0 -19
  105. package/lib/model/util.ts +0 -32
  106. package/lib/parsers/texte.d.ts +0 -7
  107. package/lib/parsers/texte.js +0 -228
  108. package/lib/raw_types/ameli.d.ts +0 -914
  109. package/lib/raw_types/ameli.js +0 -5
  110. package/lib/raw_types/ameli.mjs +0 -163
  111. package/lib/raw_types/debats.d.ts +0 -207
  112. package/lib/raw_types/debats.js +0 -5
  113. package/lib/raw_types/debats.mjs +0 -58
  114. package/lib/raw_types/dosleg.d.ts +0 -1619
  115. package/lib/raw_types/dosleg.js +0 -5
  116. package/lib/raw_types/dosleg.mjs +0 -438
  117. package/lib/raw_types/questions.d.ts +0 -419
  118. package/lib/raw_types/questions.js +0 -5
  119. package/lib/raw_types/questions.mjs +0 -11
  120. package/lib/raw_types/senat.d.ts +0 -11368
  121. package/lib/raw_types/senat.js +0 -5
  122. package/lib/raw_types/sens.d.ts +0 -8248
  123. package/lib/raw_types/sens.js +0 -5
  124. package/lib/raw_types/sens.mjs +0 -508
  125. package/lib/raw_types_kysely/ameli.d.ts +0 -915
  126. package/lib/raw_types_kysely/ameli.js +0 -7
  127. package/lib/raw_types_kysely/ameli.mjs +0 -5
  128. package/lib/raw_types_kysely/ameli.ts +0 -951
  129. package/lib/raw_types_kysely/debats.d.ts +0 -207
  130. package/lib/raw_types_kysely/debats.js +0 -7
  131. package/lib/raw_types_kysely/debats.mjs +0 -5
  132. package/lib/raw_types_kysely/debats.ts +0 -222
  133. package/lib/raw_types_kysely/dosleg.d.ts +0 -3532
  134. package/lib/raw_types_kysely/dosleg.js +0 -7
  135. package/lib/raw_types_kysely/dosleg.mjs +0 -5
  136. package/lib/raw_types_kysely/dosleg.ts +0 -3621
  137. package/lib/raw_types_kysely/questions.d.ts +0 -414
  138. package/lib/raw_types_kysely/questions.js +0 -7
  139. package/lib/raw_types_kysely/questions.mjs +0 -5
  140. package/lib/raw_types_kysely/questions.ts +0 -426
  141. package/lib/raw_types_kysely/sens.d.ts +0 -4394
  142. package/lib/raw_types_kysely/sens.js +0 -7
  143. package/lib/raw_types_kysely/sens.mjs +0 -5
  144. package/lib/raw_types_kysely/sens.ts +0 -4499
  145. package/lib/raw_types_schemats/ameli.d.ts +0 -539
  146. package/lib/raw_types_schemats/ameli.js +0 -2
  147. package/lib/raw_types_schemats/ameli.mjs +0 -2
  148. package/lib/raw_types_schemats/ameli.ts +0 -601
  149. package/lib/raw_types_schemats/debats.d.ts +0 -127
  150. package/lib/raw_types_schemats/debats.js +0 -2
  151. package/lib/raw_types_schemats/debats.mjs +0 -2
  152. package/lib/raw_types_schemats/debats.ts +0 -145
  153. package/lib/raw_types_schemats/dosleg.d.ts +0 -977
  154. package/lib/raw_types_schemats/dosleg.js +0 -2
  155. package/lib/raw_types_schemats/dosleg.mjs +0 -2
  156. package/lib/raw_types_schemats/dosleg.ts +0 -2193
  157. package/lib/raw_types_schemats/questions.d.ts +0 -235
  158. package/lib/raw_types_schemats/questions.js +0 -2
  159. package/lib/raw_types_schemats/questions.mjs +0 -2
  160. package/lib/raw_types_schemats/questions.ts +0 -249
  161. package/lib/raw_types_schemats/sens.d.ts +0 -6915
  162. package/lib/raw_types_schemats/sens.js +0 -2
  163. package/lib/raw_types_schemats/sens.mjs +0 -2
  164. package/lib/raw_types_schemats/sens.ts +0 -2907
  165. package/lib/scripts/convert_data.js +0 -354
  166. package/lib/scripts/convert_data.mjs +0 -181
  167. package/lib/scripts/convert_data.ts +0 -243
  168. package/lib/scripts/data-download.d.ts +0 -1
  169. package/lib/scripts/data-download.js +0 -12
  170. package/lib/scripts/datautil.d.ts +0 -8
  171. package/lib/scripts/datautil.js +0 -34
  172. package/lib/scripts/datautil.mjs +0 -16
  173. package/lib/scripts/datautil.ts +0 -19
  174. package/lib/scripts/images/transparent_150x192.jpg +0 -0
  175. package/lib/scripts/images/transparent_155x225.jpg +0 -0
  176. package/lib/scripts/parse_textes.d.ts +0 -1
  177. package/lib/scripts/parse_textes.js +0 -44
  178. package/lib/scripts/parse_textes.mjs +0 -46
  179. package/lib/scripts/parse_textes.ts +0 -65
  180. package/lib/scripts/retrieve_agenda.d.ts +0 -1
  181. package/lib/scripts/retrieve_agenda.js +0 -132
  182. package/lib/scripts/retrieve_cr_commission.d.ts +0 -1
  183. package/lib/scripts/retrieve_cr_commission.js +0 -364
  184. package/lib/scripts/retrieve_cr_seance.d.ts +0 -6
  185. package/lib/scripts/retrieve_cr_seance.js +0 -347
  186. package/lib/scripts/retrieve_documents.d.ts +0 -3
  187. package/lib/scripts/retrieve_documents.js +0 -219
  188. package/lib/scripts/retrieve_documents.mjs +0 -249
  189. package/lib/scripts/retrieve_documents.ts +0 -298
  190. package/lib/scripts/retrieve_open_data.d.ts +0 -1
  191. package/lib/scripts/retrieve_open_data.js +0 -315
  192. package/lib/scripts/retrieve_open_data.mjs +0 -217
  193. package/lib/scripts/retrieve_open_data.ts +0 -268
  194. package/lib/scripts/retrieve_senateurs_photos.d.ts +0 -1
  195. package/lib/scripts/retrieve_senateurs_photos.js +0 -147
  196. package/lib/scripts/retrieve_senateurs_photos.mjs +0 -147
  197. package/lib/scripts/retrieve_senateurs_photos.ts +0 -177
  198. package/lib/scripts/retrieve_videos.d.ts +0 -1
  199. package/lib/scripts/retrieve_videos.js +0 -461
  200. package/lib/scripts/shared/cli_helpers.d.ts +0 -95
  201. package/lib/scripts/shared/cli_helpers.js +0 -91
  202. package/lib/scripts/shared/cli_helpers.ts +0 -36
  203. package/lib/scripts/shared/util.d.ts +0 -4
  204. package/lib/scripts/shared/util.js +0 -35
  205. package/lib/scripts/shared/util.ts +0 -33
  206. package/lib/scripts/test_iter_load.d.ts +0 -1
  207. package/lib/scripts/test_iter_load.js +0 -12
  208. package/lib/src/ameli.d.ts +0 -66
  209. package/lib/src/ameli.js +0 -1
  210. package/lib/src/config.d.ts +0 -43
  211. package/lib/src/config.js +0 -37
  212. package/lib/src/conversion_textes.d.ts +0 -11
  213. package/lib/src/conversion_textes.js +0 -320
  214. package/lib/src/databases.d.ts +0 -3
  215. package/lib/src/databases.js +0 -26
  216. package/lib/src/databases_postgres.d.ts +0 -4
  217. package/lib/src/databases_postgres.js +0 -23
  218. package/lib/src/datasets.d.ts +0 -38
  219. package/lib/src/datasets.js +0 -247
  220. package/lib/src/db_types/ameli.d.ts +0 -1762
  221. package/lib/src/db_types/ameli.js +0 -1074
  222. package/lib/src/db_types/debats.d.ts +0 -380
  223. package/lib/src/db_types/debats.js +0 -266
  224. package/lib/src/db_types/dosleg.d.ts +0 -2954
  225. package/lib/src/db_types/dosleg.js +0 -2005
  226. package/lib/src/db_types/questions.d.ts +0 -699
  227. package/lib/src/db_types/questions.js +0 -493
  228. package/lib/src/db_types/sens.d.ts +0 -7843
  229. package/lib/src/db_types/sens.js +0 -4691
  230. package/lib/src/debats.d.ts +0 -38
  231. package/lib/src/debats.js +0 -1
  232. package/lib/src/dosleg.d.ts +0 -142
  233. package/lib/src/dosleg.js +0 -193
  234. package/lib/src/git.d.ts +0 -27
  235. package/lib/src/git.js +0 -251
  236. package/lib/src/loaders.d.ts +0 -52
  237. package/lib/src/loaders.js +0 -260
  238. package/lib/src/model/agenda.d.ts +0 -6
  239. package/lib/src/model/agenda.js +0 -148
  240. package/lib/src/model/ameli.d.ts +0 -67
  241. package/lib/src/model/ameli.js +0 -150
  242. package/lib/src/model/ameli_postgres.d.ts +0 -67
  243. package/lib/src/model/ameli_postgres.js +0 -150
  244. package/lib/src/model/commission.d.ts +0 -19
  245. package/lib/src/model/commission.js +0 -269
  246. package/lib/src/model/debats.d.ts +0 -39
  247. package/lib/src/model/debats.js +0 -112
  248. package/lib/src/model/documents.d.ts +0 -32
  249. package/lib/src/model/documents.js +0 -182
  250. package/lib/src/model/dosleg.d.ts +0 -144
  251. package/lib/src/model/dosleg.js +0 -468
  252. package/lib/src/model/index.d.ts +0 -7
  253. package/lib/src/model/index.js +0 -7
  254. package/lib/src/model/questions.d.ts +0 -54
  255. package/lib/src/model/questions.js +0 -91
  256. package/lib/src/model/scrutins.d.ts +0 -48
  257. package/lib/src/model/scrutins.js +0 -121
  258. package/lib/src/model/seance.d.ts +0 -3
  259. package/lib/src/model/seance.js +0 -267
  260. package/lib/src/model/sens.d.ts +0 -112
  261. package/lib/src/model/sens.js +0 -385
  262. package/lib/src/model/util.d.ts +0 -1
  263. package/lib/src/model/util.js +0 -15
  264. package/lib/src/other_types/questions.d.ts +0 -2
  265. package/lib/src/other_types/questions.js +0 -1
  266. package/lib/src/questions.d.ts +0 -53
  267. package/lib/src/questions.js +0 -1
  268. package/lib/src/raw_types/ameli.d.ts +0 -1762
  269. package/lib/src/raw_types/ameli.js +0 -1074
  270. package/lib/src/raw_types/debats.d.ts +0 -380
  271. package/lib/src/raw_types/debats.js +0 -266
  272. package/lib/src/raw_types/dosleg.d.ts +0 -2954
  273. package/lib/src/raw_types/dosleg.js +0 -2005
  274. package/lib/src/raw_types/questions.d.ts +0 -699
  275. package/lib/src/raw_types/questions.js +0 -493
  276. package/lib/src/raw_types/senat.d.ts +0 -11372
  277. package/lib/src/raw_types/senat.js +0 -5
  278. package/lib/src/raw_types/sens.d.ts +0 -7843
  279. package/lib/src/raw_types/sens.js +0 -4691
  280. package/lib/src/raw_types_schemats/ameli.d.ts +0 -541
  281. package/lib/src/raw_types_schemats/ameli.js +0 -2
  282. package/lib/src/raw_types_schemats/debats.d.ts +0 -127
  283. package/lib/src/raw_types_schemats/debats.js +0 -2
  284. package/lib/src/raw_types_schemats/dosleg.d.ts +0 -977
  285. package/lib/src/raw_types_schemats/dosleg.js +0 -2
  286. package/lib/src/raw_types_schemats/questions.d.ts +0 -237
  287. package/lib/src/raw_types_schemats/questions.js +0 -2
  288. package/lib/src/raw_types_schemats/sens.d.ts +0 -2709
  289. package/lib/src/raw_types_schemats/sens.js +0 -2
  290. package/lib/src/rich_types/agenda.d.ts +0 -45
  291. package/lib/src/rich_types/agenda.js +0 -1
  292. package/lib/src/rich_types/compte_rendu.d.ts +0 -83
  293. package/lib/src/rich_types/compte_rendu.js +0 -1
  294. package/lib/src/rich_types/sessions.d.ts +0 -6
  295. package/lib/src/rich_types/sessions.js +0 -19
  296. package/lib/src/rich_types/texte.d.ts +0 -72
  297. package/lib/src/rich_types/texte.js +0 -15
  298. package/lib/src/scripts/test_iter_load.d.ts +0 -1
  299. package/lib/src/scripts/test_iter_load.js +0 -12
  300. package/lib/src/sens.d.ts +0 -104
  301. package/lib/src/sens.js +0 -1
  302. package/lib/src/types/agenda.d.ts +0 -45
  303. package/lib/src/types/agenda.js +0 -1
  304. package/lib/src/types/ameli.d.ts +0 -1762
  305. package/lib/src/types/ameli.js +0 -1074
  306. package/lib/src/types/compte_rendu.d.ts +0 -83
  307. package/lib/src/types/compte_rendu.js +0 -1
  308. package/lib/src/types/debats.d.ts +0 -380
  309. package/lib/src/types/debats.js +0 -266
  310. package/lib/src/types/dosleg.d.ts +0 -2954
  311. package/lib/src/types/dosleg.js +0 -2005
  312. package/lib/src/types/questions.d.ts +0 -699
  313. package/lib/src/types/questions.js +0 -493
  314. package/lib/src/types/sens.d.ts +0 -7843
  315. package/lib/src/types/sens.js +0 -4691
  316. package/lib/src/types/sessions.d.ts +0 -6
  317. package/lib/src/types/sessions.js +0 -19
  318. package/lib/src/types/texte.d.ts +0 -72
  319. package/lib/src/types/texte.js +0 -15
  320. package/lib/src/validators/config.d.ts +0 -9
  321. package/lib/src/validators/config.js +0 -10
  322. package/lib/strings.d.ts +0 -1
  323. package/lib/strings.js +0 -18
  324. package/lib/strings.mjs +0 -18
  325. package/lib/strings.ts +0 -26
  326. package/lib/tsconfig.tsbuildinfo +0 -1
  327. package/lib/types/agenda.d.ts +0 -44
  328. package/lib/types/agenda.js +0 -1
  329. package/lib/types/ameli.d.ts +0 -5
  330. package/lib/types/ameli.js +0 -1
  331. package/lib/types/ameli.mjs +0 -13
  332. package/lib/types/ameli.ts +0 -21
  333. package/lib/types/compte_rendu.d.ts +0 -83
  334. package/lib/types/compte_rendu.js +0 -1
  335. package/lib/types/debats.d.ts +0 -2
  336. package/lib/types/debats.js +0 -1
  337. package/lib/types/debats.mjs +0 -2
  338. package/lib/types/debats.ts +0 -6
  339. package/lib/types/dosleg.d.ts +0 -70
  340. package/lib/types/dosleg.js +0 -1
  341. package/lib/types/dosleg.mjs +0 -151
  342. package/lib/types/dosleg.ts +0 -284
  343. package/lib/types/questions.d.ts +0 -2
  344. package/lib/types/questions.js +0 -1
  345. package/lib/types/questions.mjs +0 -1
  346. package/lib/types/questions.ts +0 -3
  347. package/lib/types/sens.d.ts +0 -10
  348. package/lib/types/sens.js +0 -1
  349. package/lib/types/sens.mjs +0 -1
  350. package/lib/types/sens.ts +0 -12
  351. package/lib/types/sessions.d.ts +0 -5
  352. package/lib/types/sessions.js +0 -84
  353. package/lib/types/sessions.mjs +0 -43
  354. package/lib/types/sessions.ts +0 -42
  355. package/lib/types/texte.d.ts +0 -74
  356. package/lib/types/texte.js +0 -16
  357. package/lib/types/texte.mjs +0 -16
  358. package/lib/types/texte.ts +0 -76
  359. package/lib/typings/windows-1252.d.js +0 -2
  360. package/lib/typings/windows-1252.d.mjs +0 -2
  361. package/lib/typings/windows-1252.d.ts +0 -11
  362. package/lib/utils/cr_spliting.d.ts +0 -28
  363. package/lib/utils/cr_spliting.js +0 -265
  364. package/lib/utils/date.d.ts +0 -10
  365. package/lib/utils/date.js +0 -100
  366. package/lib/utils/nvs-timecode.d.ts +0 -7
  367. package/lib/utils/nvs-timecode.js +0 -79
  368. package/lib/utils/reunion_grouping.d.ts +0 -9
  369. package/lib/utils/reunion_grouping.js +0 -361
  370. package/lib/utils/reunion_odj_building.d.ts +0 -5
  371. package/lib/utils/reunion_odj_building.js +0 -154
  372. package/lib/utils/reunion_parsing.d.ts +0 -23
  373. package/lib/utils/reunion_parsing.js +0 -209
  374. package/lib/utils/scoring.d.ts +0 -14
  375. package/lib/utils/scoring.js +0 -147
  376. package/lib/utils/string_cleaning.d.ts +0 -7
  377. package/lib/utils/string_cleaning.js +0 -57
  378. package/lib/validators/config.d.ts +0 -9
  379. package/lib/validators/config.js +0 -10
  380. package/lib/validators/config.mjs +0 -54
  381. package/lib/validators/config.ts +0 -79
  382. package/lib/validators/senat.d.ts +0 -0
  383. package/lib/validators/senat.js +0 -28
  384. package/lib/validators/senat.mjs +0 -24
  385. package/lib/validators/senat.ts +0 -26
  386. /package/lib/{add-js-extensions-v2.d.ts → src/other_types/collaborateurs.js} +0 -0
  387. /package/lib/{add-js-extensions.d.ts → src/scripts/retrieve_collaborateurs.d.ts} +0 -0
  388. /package/lib/{scripts/convert_data.d.ts → tests/collaborateurs.test.d.ts} +0 -0
@@ -1,121 +0,0 @@
1
- import { streamUnsafeQuery } from "../databases_postgres.js";
2
- function buildFindAllScrutinsQuery(fromSession) {
3
- const params = [];
4
- const whereSession = fromSession === undefined ? "" : "where scr.sesann >= $1";
5
- if (fromSession !== undefined) {
6
- params.push(String(fromSession));
7
- }
8
- return {
9
- params,
10
- query: `
11
- select
12
- scr.sesann::text as session,
13
- scr.scrnum::text as numero,
14
- rtrim(date_seance.lecidt) as lecture_id,
15
- rtrim(lecture.leccom) as lecture_libelle,
16
- loi.signet as signet_dossier,
17
- rtrim(typlec.typleclib) as type_lecture,
18
- to_char(scr.scrdat, 'YYYY-MM-DD') as date_scrutin,
19
- to_char(scr.scrdateff, 'YYYY-MM-DD') as date_scrutin_effective,
20
- replace(scr.scrint, E'\\u0092', '''') as intitule,
21
- scr.scrbaspag as note,
22
- scr.scrmaj::text as nombre_majorite,
23
- scr.scrmajsea::text as nombre_majorite_seance,
24
- scr.scrvot::text as nombre_votants,
25
- scr.scrvotsea::text as nombre_votants_seance,
26
- scr.scrsuf::text as nombre_suffrages,
27
- scr.scrsufsea::text as nombre_suffrages_seance,
28
- scr.scrcon::text as nombre_contre,
29
- scr.scrconsea::text as nombre_contre_seance,
30
- scr.scrpou::text as nombre_pour,
31
- scr.scrpousea::text as nombre_pour_seance,
32
- (
33
- select coalesce(json_agg(vote_rows order by vote_rows.membership_start desc nulls last), '[]'::json)
34
- from (
35
- select
36
- votsen.senmat as matricule_votant,
37
- votsen.senmatdel as matricule_delegant,
38
- posvot.posvotlib as position,
39
- stavot.stavotlib as statut_votant,
40
- titsen.titsenlib as titre_votant,
41
- memgrppol.memgrppolid::text as groupe_politique_id,
42
- memgrppol.grppolcod as groupe_politique_code,
43
- memgrppol.memgrppoldatdeb as membership_start
44
- from senat.dosleg_votsen as votsen
45
- left join senat.dosleg_titsen as titsen on titsen.titsencod = votsen.titsencod
46
- left join senat.dosleg_stavot as stavot on stavot.stavotidt = votsen.stavotidt
47
- left join senat.dosleg_posvot as posvot on posvot.posvotcod = votsen.posvotcod
48
- left join senat.sens_memgrppol as memgrppol
49
- on memgrppol.senmat = votsen.senmat
50
- and memgrppol.memgrppoldatdeb <= scr.scrdat
51
- and (memgrppol.memgrppoldatfin >= scr.scrdat or memgrppol.memgrppoldatfin is null)
52
- where votsen.scrnum = scr.scrnum
53
- and votsen.sesann = scr.sesann
54
- ) as vote_rows
55
- ) as votes,
56
- (
57
- select coalesce(json_agg(group_rows order by group_rows.groupe_politique_code nulls last), '[]'::json)
58
- from (
59
- select
60
- unique_votes.grppolcod as groupe_politique_code,
61
- sum(case when unique_votes.posvotlib = 'pour' then 1 else 0 end)::text as nombre_pour,
62
- sum(case when unique_votes.posvotlib = 'contre' then 1 else 0 end)::text as nombre_contre,
63
- sum(case when unique_votes.posvotlib = 'abstention' then 1 else 0 end)::text as nombre_abstentions,
64
- sum(case when unique_votes.posvotlib = 'non-votant' then 1 else 0 end)::text as nombre_non_votants,
65
- count(unique_votes.senmat)::text as nombre_votants
66
- from (
67
- select
68
- votsen.senmat,
69
- posvot.posvotlib,
70
- stavot.stavotlib,
71
- memgrppol.grppolcod,
72
- row_number() over (
73
- partition by votsen.senmat, votsen.scrnum, votsen.sesann
74
- order by memgrppol.memgrppoldatdeb desc nulls last
75
- ) as vote_rank
76
- from senat.dosleg_votsen as votsen
77
- left join senat.dosleg_posvot as posvot on posvot.posvotcod = votsen.posvotcod
78
- left join senat.dosleg_stavot as stavot on stavot.stavotidt = votsen.stavotidt
79
- left join senat.sens_memgrppol as memgrppol
80
- on memgrppol.senmat = votsen.senmat
81
- and memgrppol.memgrppoldatdeb <= scr.scrdat
82
- and (memgrppol.memgrppoldatfin >= scr.scrdat or memgrppol.memgrppoldatfin is null)
83
- where votsen.scrnum = scr.scrnum
84
- and votsen.sesann = scr.sesann
85
- ) as unique_votes
86
- where unique_votes.vote_rank = 1
87
- group by unique_votes.grppolcod
88
- ) as group_rows
89
- ) as groupes_votants,
90
- (
91
- select coalesce(json_agg(correction_rows order by correction_rows.ordre nulls last), '[]'::json)
92
- from (
93
- select
94
- corscr.corscrtxt as texte,
95
- corscr.corscrord::text as ordre,
96
- corscr.corscrurl as url
97
- from senat.dosleg_corscr as corscr
98
- where corscr.scrnum = scr.scrnum
99
- ) as correction_rows
100
- ) as mises_au_point
101
- from senat.dosleg_scr as scr
102
- left join senat.dosleg_date_seance as date_seance on scr.code = date_seance.code
103
- left join senat.dosleg_lecass as lecass on date_seance.lecidt = lecass.lecassidt
104
- left join senat.dosleg_lecture as lecture on lecture.lecidt = lecass.lecidt
105
- left join senat.dosleg_loi as loi on loi.loicod = lecture.loicod
106
- left join senat.dosleg_typlec as typlec on typlec.typleccod = lecture.typleccod
107
- ${whereSession}
108
- `,
109
- };
110
- }
111
- export async function* findAllScrutins(fromSession) {
112
- const { query, params } = buildFindAllScrutinsQuery(fromSession);
113
- for await (const row of streamUnsafeQuery(query, params)) {
114
- yield {
115
- ...row,
116
- groupes_votants: row.groupes_votants ?? [],
117
- mises_au_point: row.mises_au_point ?? [],
118
- votes: row.votes ?? [],
119
- };
120
- }
121
- }
@@ -1,3 +0,0 @@
1
- import { CompteRendu } from "../rich_types/compte_rendu.js";
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.js";
4
- import { makeReunionUid } from "../utils/reunion_parsing.js";
5
- import { yyyymmddFromPath } from "../utils/date.js";
6
- import { decodeHtmlEntities, dedupeSpeaker, fixApostrophes, norm } from "../utils/string_cleaning.js";
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 textNode = node;
144
- const t = norm(textNode.data || "");
145
- if (!t || /^[:.,;–—-]+$/.test(t)) {
146
- textNode.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
- }
@@ -1,112 +0,0 @@
1
- export interface FonctionRow {
2
- date_debut: string | null;
3
- date_fin: string | null;
4
- libelle: string | null;
5
- }
6
- export interface MandatSenateurRow {
7
- code_circonscription: string | null;
8
- date_debut: string | null;
9
- date_fin: string | null;
10
- etat: string | null;
11
- etat_debut: string | null;
12
- etat_fin: string | null;
13
- }
14
- export interface MandatOrganismeRow {
15
- code_organisme: string;
16
- date_debut: string | null;
17
- date_fin: string | null;
18
- etat: string | null;
19
- fonctions: FonctionRow[];
20
- libelle: string | null;
21
- type_code_organisme: string | null;
22
- type_organisme: string | null;
23
- }
24
- export interface AdressePointContactRow {
25
- bureau_distributeur: string | null;
26
- code_cedex: string | null;
27
- code_postal: string | null;
28
- commune: string | null;
29
- complement: string | null;
30
- complement2: string | null;
31
- libelle_cedex: string | null;
32
- nom_voie: string | null;
33
- numero_voie: string | null;
34
- }
35
- export interface TelephonePointContactRow {
36
- numero: string | null;
37
- type: string;
38
- }
39
- export interface PointContactRow {
40
- adresses: AdressePointContactRow[];
41
- id: string;
42
- libelle: string | null;
43
- telephones: TelephonePointContactRow[];
44
- type: string;
45
- }
46
- export interface UrlRow {
47
- code_url: string;
48
- url: string;
49
- }
50
- export interface SenateurResult {
51
- PCS_INSEE: string | null;
52
- PCS_INSEE_24: string | null;
53
- PCS_INSEE_42: string | null;
54
- PCS_INSEE_8: string | null;
55
- circonscription: string | null;
56
- code_circonscription: string | null;
57
- code_commission_permanente: string | null;
58
- code_groupe_politique: string | null;
59
- commission_permanente: string | null;
60
- commissions: MandatOrganismeRow[];
61
- courrier_electronique: string | null;
62
- date_deces: string | null;
63
- date_naissance: string | null;
64
- delegations: MandatOrganismeRow[];
65
- description_profession: string | null;
66
- etat: string;
67
- fonction_bureau_senat: string | null;
68
- fonctions_bureau: FonctionRow[];
69
- groupe_politique: string | null;
70
- groupes: MandatOrganismeRow[];
71
- mandats_senateur: MandatSenateurRow[];
72
- matricule: string;
73
- nom_usuel: string | null;
74
- points_contact: PointContactRow[];
75
- prenom_usuel: string;
76
- qualite: string;
77
- siege: string | null;
78
- url_hatvp: string | null;
79
- urls: UrlRow[];
80
- }
81
- export interface CirconscriptionResult {
82
- article: string | null;
83
- code: string;
84
- date_debut: string | null;
85
- date_fin: string | null;
86
- etat: string | null;
87
- identifiant: string;
88
- libelle_departement: string;
89
- libelle_region: string;
90
- nombre_senateurs: string | null;
91
- url: string | null;
92
- }
93
- export interface OrganismeResult {
94
- code: string;
95
- date_debut: string | null;
96
- date_fin: string | null;
97
- etat: string | null;
98
- libelle: string | null;
99
- libelle_court: string | null;
100
- libelle_long: string | null;
101
- type_code: string;
102
- type_libelle: string | null;
103
- url: string | null;
104
- }
105
- export declare function findAll(): AsyncGenerator<SenateurResult, void, unknown>;
106
- export declare function findAllCirconscriptions(): AsyncGenerator<CirconscriptionResult, void, unknown>;
107
- export declare function findAllOrganismes(): AsyncGenerator<OrganismeResult, void, unknown>;
108
- export declare function findActif(): AsyncGenerator<{
109
- senmat: string;
110
- sennomuse: string | null;
111
- senprenomuse: string;
112
- }, void, unknown>;