@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,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
- }