@tricoteuses/senat 2.22.13 → 2.22.15

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 (139) hide show
  1. package/lib/src/loaders.d.ts +2 -8
  2. package/lib/src/loaders.js +7 -25
  3. package/lib/src/scripts/retrieve_cr_commission.js +1 -1
  4. package/lib/src/scripts/retrieve_cr_seance.js +1 -1
  5. package/lib/src/scripts/retrieve_videos.js +2 -2
  6. package/lib/tests/test_iter_load.test.js +17 -0
  7. package/package.json +2 -2
  8. package/lib/config.d.ts +0 -21
  9. package/lib/config.js +0 -27
  10. package/lib/databases.d.ts +0 -2
  11. package/lib/databases.js +0 -26
  12. package/lib/datasets.d.ts +0 -34
  13. package/lib/datasets.js +0 -233
  14. package/lib/git.d.ts +0 -26
  15. package/lib/git.js +0 -167
  16. package/lib/index.d.ts +0 -13
  17. package/lib/index.js +0 -1
  18. package/lib/loaders.d.ts +0 -58
  19. package/lib/loaders.js +0 -286
  20. package/lib/model/agenda.d.ts +0 -6
  21. package/lib/model/agenda.js +0 -148
  22. package/lib/model/ameli.d.ts +0 -51
  23. package/lib/model/ameli.js +0 -147
  24. package/lib/model/commission.d.ts +0 -18
  25. package/lib/model/commission.js +0 -269
  26. package/lib/model/debats.d.ts +0 -67
  27. package/lib/model/debats.js +0 -95
  28. package/lib/model/documents.d.ts +0 -12
  29. package/lib/model/documents.js +0 -138
  30. package/lib/model/dosleg.d.ts +0 -7
  31. package/lib/model/dosleg.js +0 -326
  32. package/lib/model/index.d.ts +0 -7
  33. package/lib/model/index.js +0 -7
  34. package/lib/model/questions.d.ts +0 -45
  35. package/lib/model/questions.js +0 -89
  36. package/lib/model/scrutins.d.ts +0 -13
  37. package/lib/model/scrutins.js +0 -114
  38. package/lib/model/seance.d.ts +0 -3
  39. package/lib/model/seance.js +0 -267
  40. package/lib/model/sens.d.ts +0 -146
  41. package/lib/model/sens.js +0 -454
  42. package/lib/model/texte.d.ts +0 -7
  43. package/lib/model/texte.js +0 -228
  44. package/lib/model/util.d.ts +0 -9
  45. package/lib/model/util.js +0 -38
  46. package/lib/parsers/texte.d.ts +0 -7
  47. package/lib/parsers/texte.js +0 -228
  48. package/lib/raw_types/ameli.d.ts +0 -914
  49. package/lib/raw_types/ameli.js +0 -5
  50. package/lib/raw_types/debats.d.ts +0 -207
  51. package/lib/raw_types/debats.js +0 -5
  52. package/lib/raw_types/dosleg.d.ts +0 -1619
  53. package/lib/raw_types/dosleg.js +0 -5
  54. package/lib/raw_types/questions.d.ts +0 -423
  55. package/lib/raw_types/questions.js +0 -5
  56. package/lib/raw_types/senat.d.ts +0 -11372
  57. package/lib/raw_types/senat.js +0 -5
  58. package/lib/raw_types/sens.d.ts +0 -8248
  59. package/lib/raw_types/sens.js +0 -5
  60. package/lib/raw_types_schemats/ameli.d.ts +0 -539
  61. package/lib/raw_types_schemats/ameli.js +0 -2
  62. package/lib/raw_types_schemats/debats.d.ts +0 -127
  63. package/lib/raw_types_schemats/debats.js +0 -2
  64. package/lib/raw_types_schemats/dosleg.d.ts +0 -977
  65. package/lib/raw_types_schemats/dosleg.js +0 -2
  66. package/lib/raw_types_schemats/questions.d.ts +0 -237
  67. package/lib/raw_types_schemats/questions.js +0 -2
  68. package/lib/raw_types_schemats/sens.d.ts +0 -6915
  69. package/lib/raw_types_schemats/sens.js +0 -2
  70. package/lib/scripts/convert_data.js +0 -354
  71. package/lib/scripts/data-download.d.ts +0 -1
  72. package/lib/scripts/data-download.js +0 -12
  73. package/lib/scripts/datautil.d.ts +0 -8
  74. package/lib/scripts/datautil.js +0 -34
  75. package/lib/scripts/parse_textes.d.ts +0 -1
  76. package/lib/scripts/parse_textes.js +0 -44
  77. package/lib/scripts/retrieve_agenda.d.ts +0 -1
  78. package/lib/scripts/retrieve_agenda.js +0 -132
  79. package/lib/scripts/retrieve_cr_commission.d.ts +0 -1
  80. package/lib/scripts/retrieve_cr_commission.js +0 -364
  81. package/lib/scripts/retrieve_cr_seance.d.ts +0 -6
  82. package/lib/scripts/retrieve_cr_seance.js +0 -347
  83. package/lib/scripts/retrieve_documents.d.ts +0 -3
  84. package/lib/scripts/retrieve_documents.js +0 -219
  85. package/lib/scripts/retrieve_open_data.d.ts +0 -1
  86. package/lib/scripts/retrieve_open_data.js +0 -316
  87. package/lib/scripts/retrieve_senateurs_photos.d.ts +0 -1
  88. package/lib/scripts/retrieve_senateurs_photos.js +0 -147
  89. package/lib/scripts/retrieve_videos.d.ts +0 -1
  90. package/lib/scripts/retrieve_videos.js +0 -461
  91. package/lib/scripts/shared/cli_helpers.d.ts +0 -95
  92. package/lib/scripts/shared/cli_helpers.js +0 -91
  93. package/lib/scripts/shared/util.d.ts +0 -4
  94. package/lib/scripts/shared/util.js +0 -35
  95. package/lib/scripts/test_iter_load.d.ts +0 -1
  96. package/lib/scripts/test_iter_load.js +0 -12
  97. package/lib/src/utils/nvs-timecode.d.ts +0 -17
  98. package/lib/src/utils/nvs-timecode.js +0 -79
  99. package/lib/src/utils/weights_scoring_config.d.ts +0 -2
  100. package/lib/src/utils/weights_scoring_config.js +0 -15
  101. package/lib/strings.d.ts +0 -1
  102. package/lib/strings.js +0 -18
  103. package/lib/types/agenda.d.ts +0 -44
  104. package/lib/types/agenda.js +0 -1
  105. package/lib/types/ameli.d.ts +0 -5
  106. package/lib/types/ameli.js +0 -1
  107. package/lib/types/compte_rendu.d.ts +0 -83
  108. package/lib/types/compte_rendu.js +0 -1
  109. package/lib/types/debats.d.ts +0 -2
  110. package/lib/types/debats.js +0 -1
  111. package/lib/types/dosleg.d.ts +0 -70
  112. package/lib/types/dosleg.js +0 -1
  113. package/lib/types/questions.d.ts +0 -2
  114. package/lib/types/questions.js +0 -1
  115. package/lib/types/sens.d.ts +0 -10
  116. package/lib/types/sens.js +0 -1
  117. package/lib/types/sessions.d.ts +0 -5
  118. package/lib/types/sessions.js +0 -84
  119. package/lib/types/texte.d.ts +0 -74
  120. package/lib/types/texte.js +0 -16
  121. package/lib/utils/cr_spliting.d.ts +0 -28
  122. package/lib/utils/cr_spliting.js +0 -265
  123. package/lib/utils/date.d.ts +0 -10
  124. package/lib/utils/date.js +0 -100
  125. package/lib/utils/nvs-timecode.d.ts +0 -7
  126. package/lib/utils/nvs-timecode.js +0 -79
  127. package/lib/utils/reunion_grouping.d.ts +0 -11
  128. package/lib/utils/reunion_grouping.js +0 -337
  129. package/lib/utils/reunion_odj_building.d.ts +0 -5
  130. package/lib/utils/reunion_odj_building.js +0 -154
  131. package/lib/utils/reunion_parsing.d.ts +0 -23
  132. package/lib/utils/reunion_parsing.js +0 -209
  133. package/lib/utils/scoring.d.ts +0 -14
  134. package/lib/utils/scoring.js +0 -147
  135. package/lib/utils/string_cleaning.d.ts +0 -7
  136. package/lib/utils/string_cleaning.js +0 -57
  137. package/lib/validators/config.d.ts +0 -9
  138. package/lib/validators/config.js +0 -10
  139. /package/lib/{scripts/convert_data.d.ts → tests/test_iter_load.test.d.ts} +0 -0
@@ -1,138 +0,0 @@
1
- import { sql } from "kysely";
2
- import { dbSenat } from "../databases";
3
- import { concat, rtrim, toDateString } from "./util";
4
- import { jsonArrayFrom } from "kysely/helpers/postgres";
5
- function orderOrdreOrigineTexte(expr) {
6
- return sql `array_position(array['0','2','1'], ${expr})`;
7
- }
8
- function auteursRapport(rapportId) {
9
- return jsonArrayFrom(dbSenat
10
- .withSchema("dosleg")
11
- .selectFrom("dosleg.auteur")
12
- .leftJoin("dosleg.ecr", "dosleg.ecr.autcod", "dosleg.auteur.autcod")
13
- .leftJoin("dosleg.rolsig", "dosleg.rolsig.signataire", "dosleg.ecr.signataire")
14
- .where("dosleg.ecr.rapcod", "=", rapportId)
15
- .select([
16
- "dosleg.auteur.prenom as prenom",
17
- "dosleg.auteur.nomuse as nom_usuel",
18
- "dosleg.auteur.autmat as matricule",
19
- "dosleg.ecr.ecrnumtri as ordre",
20
- "dosleg.rolsig.rolsiglib as role",
21
- "dosleg.ecr.ecrqua as qualite",
22
- ])
23
- .orderBy("dosleg.ecr.ecrnumtri", "asc"));
24
- }
25
- function documentsAttaches(rapportId) {
26
- return jsonArrayFrom(dbSenat
27
- .withSchema("dosleg")
28
- .selectFrom("docatt")
29
- .leftJoin("typatt", "docatt.typattcod", "typatt.typattcod")
30
- .where("docatt.rapcod", "=", rapportId)
31
- .select(["docatt.docatturl as url", "typatt.typattlib as type_document"]));
32
- }
33
- function selectRapportAttributes({ eb, ref, val }) {
34
- return [
35
- "rap.rapnum as numero",
36
- "raporg.orgcod as code_organisme",
37
- eb
38
- .case()
39
- .when("rap.rapurl", "is not", null)
40
- .then(sql `regexp_replace(trim(${ref("rap.rapurl")}), '^(.*/)?(.*?)(\\.html)?$', '\\2')`)
41
- .else(null)
42
- .end()
43
- .as("id"),
44
- eb
45
- .case()
46
- .when("rap.typurl", "=", "I")
47
- .then(concat(val("https://www.senat.fr/rap/"), rtrim(ref("rap.rapurl"))))
48
- .else(rtrim(ref("rap.rapurl")))
49
- .end()
50
- .as("url"),
51
- rtrim(ref("denrap.libdenrap")).as("type"),
52
- rtrim(rtrim(ref("rap.raptil"))).as("titre"),
53
- rtrim(rtrim(ref("rap.rapsoustit"))).as("sous_titre"),
54
- toDateString(ref("rap.date_depot")).as("date"),
55
- "rap.sesann as session",
56
- auteursRapport(ref("rap.rapcod")).as("auteurs"),
57
- documentsAttaches(ref("rap.rapcod")).as("documents_annexes"),
58
- ];
59
- }
60
- const baseQueryRapports = dbSenat
61
- .withSchema("dosleg")
62
- .selectFrom("rap")
63
- .leftJoin("raporg", "raporg.rapcod", "rap.rapcod")
64
- .leftJoin("denrap", "denrap.coddenrap", "rap.coddenrap")
65
- .leftJoin("lecassrap", "lecassrap.rapcod", "rap.rapcod");
66
- const queryRapports = baseQueryRapports
67
- .leftJoin("lecass", "lecass.lecassidt", "lecassrap.lecassidt")
68
- .leftJoin("lecture", "lecture.lecidt", "lecass.lecidt")
69
- .leftJoin("loi", "loi.loicod", "lecture.loicod")
70
- .select((args) => ["loi.signet as signet_dossier", ...selectRapportAttributes(args)]);
71
- export function rapports(lectureAssembleeId) {
72
- return jsonArrayFrom(baseQueryRapports.select(selectRapportAttributes).where("lecassrap.lecassidt", "=", lectureAssembleeId));
73
- }
74
- function auteursTexte(texteId) {
75
- return jsonArrayFrom(dbSenat
76
- .withSchema("dosleg")
77
- .selectFrom("auteur")
78
- .leftJoin("ecr", "ecr.autcod", "auteur.autcod")
79
- .leftJoin("rolsig", "rolsig.signataire", "ecr.signataire")
80
- .where("ecr.texcod", "=", texteId)
81
- .select([
82
- "auteur.prenom as prenom",
83
- "auteur.nomuse as nom_usuel",
84
- "auteur.autmat as matricule",
85
- "ecr.ecrnumtri as ordre",
86
- "rolsig.rolsiglib as role",
87
- "ecr.ecrqua as qualite",
88
- ])
89
- .orderBy("ecr.ecrnumtri", "asc"));
90
- }
91
- function selectTexteAttributes({ eb, ref, val }) {
92
- return [
93
- "texte.texnum as numero",
94
- "texte.orgcod as code_organisme",
95
- eb
96
- .case()
97
- .when("texte.texurl", "is not", null)
98
- .then(sql `regexp_replace(trim(${ref("texte.texurl")}), '^(.*/)?(.*?)(\\.html)?$', '\\2')`)
99
- .else(null)
100
- .end()
101
- .as("id"),
102
- eb
103
- .case()
104
- .when("texte.typurl", "=", "I")
105
- .then(concat(val("https://www.senat.fr/leg/"), rtrim(ref("texte.texurl"))))
106
- .else(rtrim(ref("texte.texurl")))
107
- .end()
108
- .as("url"),
109
- rtrim(ref("oritxt.oritxtlib")).as("origine"),
110
- "oritxt.oriordre as ordre_origine",
111
- "oritxt.oritxtado as code_adoption",
112
- "oritxt.oritxtmod as modification",
113
- rtrim(ref("typtxt.typtxtlib")).as("type"),
114
- toDateString(ref("texte.txtoritxtdat")).as("date"),
115
- "texte.sesann as session",
116
- auteursTexte(ref("texte.texcod")).as("auteurs"),
117
- ];
118
- }
119
- const baseQueryTextes = dbSenat
120
- .withSchema("dosleg")
121
- .selectFrom("texte")
122
- .leftJoin("oritxt", "oritxt.oritxtcod", "texte.oritxtcod")
123
- .leftJoin("typtxt", "typtxt.typtxtcod", "texte.typtxtcod")
124
- .orderBy(({ ref }) => orderOrdreOrigineTexte(ref("oritxt.oriordre")));
125
- const queryTextes = baseQueryTextes
126
- .leftJoin("lecass", "lecass.lecassidt", "texte.lecassidt")
127
- .leftJoin("lecture", "lecture.lecidt", "lecass.lecidt")
128
- .leftJoin("loi", "loi.loicod", "lecture.loicod")
129
- .select((args) => ["loi.signet as signet_dossier", ...selectTexteAttributes(args)]);
130
- export function textes(lectureAssembleeId) {
131
- return jsonArrayFrom(baseQueryTextes.select(selectTexteAttributes).where("texte.lecassidt", "=", lectureAssembleeId));
132
- }
133
- export function findAllTextes() {
134
- return queryTextes.stream();
135
- }
136
- export function findAllRapports() {
137
- return queryRapports.stream();
138
- }
@@ -1,7 +0,0 @@
1
- import { InferResult, SelectQueryBuilder } from "kysely";
2
- declare const findAllDossiersQuery: SelectQueryBuilder<any, any, any>;
3
- export declare function findAllDossiers(): AsyncIterableIterator<DossierLegislatifResult>;
4
- export declare function getCodeActeLecture(codeNatureDossier: string, typeLecture: string, assemblee: string): string | null;
5
- export type DossierLegislatifResult = InferResult<typeof findAllDossiersQuery>[0];
6
- export declare function buildActesLegislatifs(dossier: any): any[];
7
- export {};
@@ -1,326 +0,0 @@
1
- import { sql } from "kysely";
2
- import { jsonArrayFrom } from "kysely/helpers/postgres";
3
- import { dbSenat } from "../databases";
4
- import { concat, rtrim, toDateString } from "./util";
5
- import { textes, rapports } from "./documents";
6
- function datesSeances(lectureAssembleeId) {
7
- return jsonArrayFrom(dbSenat
8
- .withSchema("dosleg")
9
- .selectFrom("dosleg.date_seance")
10
- .where("dosleg.date_seance.lecidt", "=", lectureAssembleeId)
11
- .select(({ ref }) => [toDateString(ref("dosleg.date_seance.date_s")).as("date")]));
12
- }
13
- function lecturesAssemblee(lectureId) {
14
- return jsonArrayFrom(dbSenat
15
- .withSchema("dosleg")
16
- .selectFrom("lecass")
17
- .where("lecass.lecidt", "=", lectureId)
18
- .leftJoin("ass", "ass.codass", "lecass.codass")
19
- .leftJoin("org", "org.orgcod", "lecass.orgcod")
20
- .leftJoin("orippr", "orippr.oripprcod", "lecass.orippr")
21
- .select(({ ref }) => [
22
- rtrim(ref("ass.libass")).as("assemblee"),
23
- "org.orgnom as libelle_organisme",
24
- "org.senorgcod as code_organisme",
25
- "lecass.ordreass as ordre_lecture_assemblee",
26
- "lecass.sesann as session",
27
- "orippr.oripprlib as origine_proposition",
28
- "lecass.ptlnum as numero_petite_loi",
29
- "lecass.ptlurl as url_petite_loi",
30
- "lecass.loiintmod as loi_intitule_modifie",
31
- "lecass.debatsurl as url_cr_debats",
32
- toDateString(ref("lecass.lecassamecomdat")).as("date_publication_amendements_commission"),
33
- toDateString(ref("lecass.lecassamedat")).as("date_publication_amendements_seance"),
34
- textes(ref("lecass.lecassidt")).as("textes"),
35
- rapports(ref("lecass.lecassidt")).as("rapports"),
36
- datesSeances(ref("lecass.lecassidt")).as("dates_seances"),
37
- ])
38
- .orderBy("lecass.ordreass", "asc"));
39
- }
40
- function lectures(loiId) {
41
- return jsonArrayFrom(dbSenat
42
- .withSchema("dosleg")
43
- .selectFrom("lecture")
44
- .leftJoin("typlec", "typlec.typleccod", "lecture.typleccod")
45
- .where("lecture.loicod", "=", loiId)
46
- .select(({ ref }) => [
47
- rtrim(ref("typlec.typleclib")).as("type_lecture"),
48
- rtrim(ref("lecture.leccom")).as("libelle"),
49
- "typlec.typlecord as ordre_lecture",
50
- lecturesAssemblee(ref("lecture.lecidt")).as("lectures_assemblee"),
51
- ])
52
- .orderBy("typlec.typlecord", "asc"));
53
- }
54
- function themes(loiId) {
55
- return jsonArrayFrom(dbSenat
56
- .withSchema("dosleg")
57
- .selectFrom("the")
58
- .leftJoin("loithe", "loithe.thecle", "the.thecle")
59
- .where("loithe.loicod", "=", loiId)
60
- .select(["the.thelib as libelle"]));
61
- }
62
- const findAllDossiersQuery = dbSenat
63
- .withSchema("dosleg")
64
- .selectFrom("loi")
65
- .leftJoin("typloi", "typloi.typloicod", "loi.typloicod")
66
- .leftJoin("etaloi", "etaloi.etaloicod", "loi.etaloicod")
67
- .leftJoin("deccoc", "deccoc.deccoccod", "loi.deccoccod")
68
- .select(({ eb, ref, val }) => [
69
- rtrim(ref("loi.loicod")).as("code"),
70
- "loi.numero as numero",
71
- "loi.signet as signet",
72
- sql `NULLIF(regexp_replace(loi.url_an, '^.*\\/(DL[^\\/]+)\\.asp$', '\\1'), '')`.as("code_dossier_an"),
73
- "loi.signetalt as signet_alternatif",
74
- rtrim(ref("loi.motclef")).as("mot_cle"),
75
- rtrim(ref("loi.loient")).as("titre_court"),
76
- concat(rtrim(ref("typloi.typloiden")), val(" "), rtrim(ref("loi.loitit"))).as("titre"),
77
- concat(rtrim(ref("typloi.typloiden")), val(" "), rtrim(ref("loi.loiint"))).as("titre_long"),
78
- concat(rtrim(ref("typloi.typloiden")), val(" "), rtrim(ref("loi.loiintori"))).as("titre_long_original"),
79
- concat(val("https://www.senat.fr/dossier-legislatif/"), ref("loi.signet"), val(".html")).as("url"),
80
- "loi.urgence as urgence",
81
- rtrim(ref("typloi.groupe")).as("code_nature_dossier"),
82
- rtrim(ref("typloi.typloilib")).as("libelle_type_dossier"),
83
- rtrim(ref("etaloi.etaloilib")).as("etat_dossier"),
84
- "loi.url_an as url_dossier_assemblee_nationale",
85
- "loi.url_presart as url_presentation_articles",
86
- "loi.url_ordonnance as url_ordonnance",
87
- "loi.orgcod as code_organisme_resolution",
88
- "deccoc.deccoclib as libelle_decision_CoC",
89
- toDateString(ref("loi.date_decision")).as("date_decision_CoC"),
90
- "loi.num_decision as num_decision_CoC",
91
- "loi.deccocurl as url_decision_CoC",
92
- "loi.doscocurl as url_dossier_CoC",
93
- toDateString(ref("loi.saisine_date")).as("date_saisine_CoC"),
94
- "loi.saisine_par as condition_saisine_CoC",
95
- toDateString(ref("loi.proaccdat")).as("date_procedure_acceleree"),
96
- toDateString(ref("loi.proaccoppdat")).as("date_opposition_procedure_acceleree"),
97
- toDateString(ref("loi.retproaccdat")).as("date_retrait_procedure_acceleree"),
98
- toDateString(ref("loi.date_loi")).as("date_promulgation"),
99
- eb
100
- .case()
101
- .when("loi.loititjo", "is not", null)
102
- .then(concat(rtrim(ref("typloi.typloiden")), val(" "), rtrim(ref("loi.loititjo"))))
103
- .else("")
104
- .end()
105
- .as("titre_JO"),
106
- toDateString(ref("loi.loidatjo")).as("date_publication_JO"),
107
- "loi.loinumjo as numero_JO",
108
- "loi.url_jo as url_JO",
109
- toDateString(ref("loi.loidatjo2")).as("date_publication_JO_correctif_1"),
110
- "loi.loinumjo2 as numero_JO_correctif_1",
111
- "loi.url_jo2 as url_JO_correctif_1",
112
- toDateString(ref("loi.loidatjo3")).as("date_publication_JO_correctif_2"),
113
- "loi.loinumjo3 as numero_JO_correctif_2",
114
- "loi.url_jo3 as url_JO_correctif_2",
115
- lectures(ref("loi.loicod")).as("lectures"),
116
- themes(ref("loi.loicod")).as("themes"),
117
- ])
118
- .$narrowType();
119
- export function findAllDossiers() {
120
- return findAllDossiersQuery.stream();
121
- }
122
- export function getCodeActeLecture(codeNatureDossier, typeLecture, assemblee) {
123
- const codeAssemblee = assemblee === "Sénat" ? "SN" : assemblee === "Assemblée nationale" ? "AN" : null;
124
- if (typeLecture === "Commission mixte paritaire") {
125
- return "CMP";
126
- }
127
- if (!codeAssemblee) {
128
- return null;
129
- }
130
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Première lecture") {
131
- return `${codeAssemblee}1`;
132
- }
133
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Deuxième lecture") {
134
- return `${codeAssemblee}2`;
135
- }
136
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Troisième lecture") {
137
- return `${codeAssemblee}3`;
138
- }
139
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Quatrième lecture") {
140
- return `${codeAssemblee}4`;
141
- }
142
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Nouvelle lecture") {
143
- return `${codeAssemblee}NLEC`;
144
- }
145
- if (["ppl", "pjl", "cvn"].includes(codeNatureDossier) && typeLecture === "Lecture définitive") {
146
- return `${codeAssemblee}LDEF`;
147
- }
148
- if (["ppr"].includes(codeNatureDossier) && typeLecture === "Première lecture") {
149
- return `${codeAssemblee}LUNI`;
150
- }
151
- return null;
152
- }
153
- // Helper pour déterminer le code de phase (SN1, SN2, CMP...)
154
- function getPhasePrefix(lecture, assemblee) {
155
- if (assemblee !== "Sénat")
156
- return null;
157
- const typeLibelle = (lecture.type_lecture || "").toLowerCase();
158
- if (typeLibelle.includes("cmp") || typeLibelle.includes("mixte"))
159
- return "CMP";
160
- if (typeLibelle.includes("nouvelle lecture"))
161
- return "SNNLEC";
162
- if (typeLibelle.includes("d\u00e9finitive"))
163
- return "SNLDEF";
164
- if (typeLibelle.includes("unique"))
165
- return "SNLUNI";
166
- if (lecture.ordre_lecture) {
167
- return `SN${lecture.ordre_lecture}`;
168
- }
169
- if (typeLibelle.includes("premi\u00e8re"))
170
- return "SN1";
171
- if (typeLibelle.includes("deuxi\u00e8me") || typeLibelle.includes("seconde"))
172
- return "SN2";
173
- return "SN1";
174
- }
175
- export function buildActesLegislatifs(dossier) {
176
- const actes = [];
177
- const loiSignet = dossier.signet;
178
- const lectures = dossier.lectures || [];
179
- for (const lecture of lectures) {
180
- const lecturesAssemblee = lecture.lectures_assemblee || [];
181
- for (const lecAss of lecturesAssemblee) {
182
- // On ne traite que la partie SÉNAT
183
- if (lecAss.assemblee !== "Sénat")
184
- continue;
185
- const phasePrefix = getPhasePrefix(lecture, lecAss.assemblee);
186
- if (!phasePrefix)
187
- continue;
188
- // Préparation des textes (tri chronologique)
189
- const textes = lecAss.textes || [];
190
- const textesTries = [...textes].sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
191
- // =================================================================
192
- // A. DÉPÔT
193
- // =================================================================
194
- const depotTexte = textesTries.find((t) => (t.origine || "").toLowerCase().includes("déposé") ||
195
- (t.origine || "").toLowerCase().includes("transmis") ||
196
- t.ordre_origine === "0");
197
- if (depotTexte && depotTexte.date) {
198
- actes.push({
199
- code_acte: `${phasePrefix}-DEPOT`,
200
- date: depotTexte.date,
201
- libelle: `Dépôt du texte n°${depotTexte.numero}`,
202
- id: depotTexte.id,
203
- numero: depotTexte.numero,
204
- uid: `${loiSignet}-${phasePrefix}-DEPOT`,
205
- session: lecAss.session,
206
- chambre: "SN",
207
- signet_dossier: loiSignet,
208
- texte_url: depotTexte.url,
209
- code_organisme: null,
210
- });
211
- }
212
- // =================================================================
213
- // B. COMMISSION (Rapports)
214
- // =================================================================
215
- const rapports = lecAss.rapports || [];
216
- for (const rap of rapports) {
217
- if (rap.date) {
218
- actes.push({
219
- code_acte: `${phasePrefix}-COM-FOND`,
220
- date: rap.date,
221
- libelle: `Rapport n°${rap.numero} de la commission`,
222
- id: rap.id,
223
- numero: rap.numero,
224
- code_organisme: rap.code_organisme,
225
- adoption: rap.adoption,
226
- uid: `${loiSignet}-${phasePrefix}-COM`,
227
- session: lecAss.session,
228
- chambre: "SN",
229
- signet_dossier: loiSignet,
230
- texte_url: rap.url,
231
- });
232
- }
233
- }
234
- // =================================================================
235
- // C. SÉANCE PUBLIQUE
236
- // =================================================================
237
- const datesSeances = lecAss.dates_seances || [];
238
- if (datesSeances.length > 0) {
239
- // Tri des objets dates
240
- datesSeances.sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
241
- const premiereSeance = datesSeances[0];
242
- if (premiereSeance && premiereSeance.date) {
243
- actes.push({
244
- // Champs pour buildParlementActeLegislatif
245
- code_acte: `${phasePrefix}-DEBATS-SEANCE`,
246
- date: premiereSeance.date,
247
- libelle: `Discussion en séance publique`,
248
- uid: `${loiSignet}-${phasePrefix}-DEBATS-SEANCE`,
249
- session: lecAss.session,
250
- chambre: "SN",
251
- signet_dossier: loiSignet,
252
- code_organisme: null,
253
- });
254
- }
255
- }
256
- // =================================================================
257
- // D. DÉCISION / VOTE
258
- // =================================================================
259
- const texteFinal = [...textesTries].reverse().find((t) => {
260
- const origine = (t.origine || "").toLowerCase();
261
- return (origine.includes("adopté") ||
262
- origine.includes("rejeté") ||
263
- origine.includes("devenu résolution") ||
264
- t.code_adoption === "O");
265
- });
266
- if (texteFinal && texteFinal.date) {
267
- const origine = (texteFinal.origine || "").toLowerCase();
268
- let libelleStatut = "Adopté";
269
- if (origine.includes("rejeté")) {
270
- libelleStatut = "Rejeté";
271
- }
272
- else if (origine.includes("devenue résolution")) {
273
- libelleStatut = "Adopté";
274
- }
275
- actes.push({
276
- code_acte: `${phasePrefix}-DEBATS-DEC`,
277
- date: texteFinal.date,
278
- libelle: `${libelleStatut === "Adopté" ? "Adoption" : "Rejet"} (Texte n°${texteFinal.numero})`,
279
- id: texteFinal.id,
280
- numero: texteFinal.numero,
281
- adoption: libelleStatut,
282
- uid: `${loiSignet}-DEC-${texteFinal.numero}`,
283
- session: lecAss.session,
284
- chambre: "SN",
285
- signet_dossier: loiSignet,
286
- texte_url: texteFinal.url,
287
- code_organisme: null,
288
- });
289
- }
290
- }
291
- }
292
- // =================================================================
293
- // E. HORS LECTURE (CC & PROMULGATION)
294
- // =================================================================
295
- if (dossier.date_decision_CoC) {
296
- actes.push({
297
- code_acte: "CC",
298
- date: dossier.date_decision_CoC,
299
- libelle: `Décision du Conseil constitutionnel`,
300
- id: dossier.url_decision_CoC,
301
- uid: `${loiSignet}-CC`,
302
- chambre: "AN",
303
- signet_dossier: loiSignet,
304
- texte_url: dossier.url_decision_CoC || dossier.url_dossier_CoC,
305
- });
306
- }
307
- if (dossier.date_promulgation) {
308
- actes.push({
309
- code_acte: "PROM",
310
- date: dossier.date_promulgation,
311
- libelle: `Promulgation de la loi`,
312
- date_publication_JO: dossier.date_publication_JO,
313
- numero_JO: dossier.numero_JO,
314
- url_legifrance: dossier.url_JO,
315
- id: dossier.url_JO,
316
- uid: `${loiSignet}-PROM`,
317
- chambre: "AN",
318
- signet_dossier: loiSignet,
319
- });
320
- }
321
- return actes.sort((a, b) => {
322
- const dateA = new Date(a.date).getTime();
323
- const dateB = new Date(b.date).getTime();
324
- return dateA - dateB;
325
- });
326
- }
@@ -1,7 +0,0 @@
1
- export { findAllAmendements } from "./ameli";
2
- export { findAll as findAllDebats } from "./debats";
3
- export { findAllDossiers } from "./dosleg";
4
- export { findAllTextes, findAllRapports } from "./documents";
5
- export { findAllScrutins } from "./scrutins";
6
- export { findAll as findAllQuestions } from "./questions";
7
- export { findAll as findAllSens, findAllCirconscriptions, findAllOrganismes } from "./sens";
@@ -1,7 +0,0 @@
1
- export { findAllAmendements } from "./ameli";
2
- export { findAll as findAllDebats } from "./debats";
3
- export { findAllDossiers } from "./dosleg";
4
- export { findAllTextes, findAllRapports } from "./documents";
5
- export { findAllScrutins } from "./scrutins";
6
- export { findAll as findAllQuestions } from "./questions";
7
- export { findAll as findAllSens, findAllCirconscriptions, findAllOrganismes } from "./sens";
@@ -1,45 +0,0 @@
1
- import { InferResult } from "kysely";
2
- export type QuestionResult = InferResult<typeof findAllQuery>[0];
3
- declare const findAllQuery: import("kysely").SelectQueryBuilder<{
4
- [x: string]: any;
5
- [x: number]: any;
6
- [x: symbol]: any;
7
- }, "tam_questions" | "sortquestion" | "etatquestion" | "tam_ministeres" | "naturequestion", {
8
- [x: string]: any;
9
- date_publication_JO: string;
10
- ministere_depot: string;
11
- ministere_depot_date_debut: string;
12
- date_transmission: string;
13
- date_reponse_JO: string;
14
- date_erratum_JO: string;
15
- date_cloture: string;
16
- date_signalement: string;
17
- themes: {
18
- libelle: any;
19
- }[];
20
- reponses: {
21
- [x: string]: any;
22
- date_reponse_JO: string;
23
- date_erratum_JO: string;
24
- }[];
25
- }>;
26
- export declare function findAll(): AsyncIterableIterator<{
27
- [x: string]: any;
28
- date_publication_JO: string;
29
- ministere_depot: string;
30
- ministere_depot_date_debut: string;
31
- date_transmission: string;
32
- date_reponse_JO: string;
33
- date_erratum_JO: string;
34
- date_cloture: string;
35
- date_signalement: string;
36
- themes: {
37
- libelle: any;
38
- }[];
39
- reponses: {
40
- [x: string]: any;
41
- date_reponse_JO: string;
42
- date_erratum_JO: string;
43
- }[];
44
- }>;
45
- export {};
@@ -1,89 +0,0 @@
1
- import { jsonArrayFrom } from "kysely/helpers/postgres";
2
- import { dbSenat } from "../databases";
3
- import { expandToRows, rtrim, toDateString } from "./util";
4
- function reponses(questionId) {
5
- return jsonArrayFrom(dbSenat
6
- .withSchema("questions")
7
- .selectFrom("tam_reponses")
8
- .where("tam_reponses.idque", "=", questionId)
9
- .select(({ ref }) => [
10
- toDateString(ref("tam_reponses.datejorep")).as("date_reponse_JO"),
11
- "tam_reponses.pagejorep as page_JO",
12
- toDateString(ref("tam_reponses.errdate")).as("date_erratum_JO"),
13
- "tam_reponses.minreplib as ministere_reponse",
14
- "tam_reponses.minrepid as ministere_reponse_id",
15
- "tam_reponses.urlrep as url",
16
- "tam_reponses.txtrep as texte",
17
- "tam_reponses.txterrrep as texte_erratum",
18
- ])
19
- .orderBy("tam_reponses.datejorep", "asc"));
20
- }
21
- function themes(questionId) {
22
- return jsonArrayFrom(dbSenat
23
- .withSchema("questions")
24
- .with("question_theme", (db) => db
25
- .selectFrom("tam_questions")
26
- .select(({ eb, ref, val }) => [
27
- "id as question_id",
28
- eb.cast(expandToRows(ref("tam_questions.themes"), val("#(\\d+)")), "smallint").as("theme_id"),
29
- ]))
30
- .selectFrom("the")
31
- .leftJoin("question_theme", "the.thenouidt", "question_theme.theme_id")
32
- .where("question_theme.question_id", "=", questionId)
33
- .select("the.thelib as libelle")
34
- .orderBy("the.thenouidt", "asc"));
35
- }
36
- const findAllQuery = dbSenat
37
- .withSchema("questions")
38
- .selectFrom("tam_questions")
39
- .leftJoin("tam_ministeres", "tam_questions.mindepotid", "tam_ministeres.minid")
40
- .leftJoin("sortquestion", (join) => join.onRef("tam_questions.sorquecod", "=", (eb) => eb.cast("sortquestion.sorquecod", "bigint")))
41
- .leftJoin("naturequestion", "tam_questions.natquecod", "naturequestion.natquecod")
42
- .leftJoin("etatquestion", (join) => join.onRef("tam_questions.etaquecod", "=", (eb) => eb.cast("etatquestion.etaquecod", "bigint")))
43
- .select(({ ref }) => [
44
- "tam_questions.repub as republique",
45
- "tam_questions.legislature as legislature",
46
- "tam_questions.natquecod as nature",
47
- "naturequestion.natquelib as nature_libelle",
48
- "tam_questions.numero as numero",
49
- "tam_questions.reference as reference",
50
- "tam_questions.titre as titre",
51
- "tam_questions.nom as nom",
52
- "tam_questions.prenom as prenom",
53
- "tam_questions.nomtechnique as nom_technique",
54
- "tam_questions.codequalite as civilite",
55
- "tam_questions.matricule as matricule",
56
- "tam_questions.cirnum as circonscription_numero",
57
- "tam_questions.circonscription as circonscription",
58
- "tam_questions.groupe as groupe",
59
- "tam_questions.ratgrp as type_appartenance",
60
- toDateString(ref("tam_questions.datejodepot")).as("date_publication_JO"),
61
- "tam_questions.pagejodepot as page_JO",
62
- rtrim(ref("tam_questions.mindepotlib")).as("ministere_depot"),
63
- "tam_questions.mindepotid as ministere_depot_id",
64
- toDateString(ref("tam_ministeres.datedebut")).as("ministere_depot_date_debut"),
65
- toDateString(ref("tam_questions.datejotran")).as("date_transmission"),
66
- "tam_questions.mintranlib as ministere_transmission",
67
- toDateString(ref("tam_questions.datejorep1")).as("date_reponse_JO"),
68
- toDateString(ref("tam_questions.dateerr")).as("date_erratum_JO"),
69
- "tam_questions.pageerr as page_erratum_JO",
70
- "tam_questions.minreplib1 as ministere_reponse",
71
- toDateString(ref("tam_questions.datecloture")).as("date_cloture"),
72
- toDateString(ref("tam_questions.datesignal")).as("date_signalement"),
73
- "tam_questions.refquerappelee as reference_question_rappelee",
74
- //"tam_questions.url as url", // TODO ?
75
- "tam_questions.txtque as texte",
76
- "tam_questions.txterrque as texte_erratum",
77
- "tam_questions.rubrique as rubrique",
78
- "sortquestion.sorquelib as sort",
79
- "sortquestion.sorquecod as sort_code",
80
- "sortquestion.sorquenumtri as sort_tri",
81
- "etatquestion.etaquelib as etat_libelle",
82
- "etatquestion.etaquecod as etat_code",
83
- "etatquestion.etaquenumtri as etat_tri",
84
- themes(ref("tam_questions.id")).as("themes"),
85
- reponses(ref("tam_questions.id")).as("reponses"),
86
- ]);
87
- export function findAll() {
88
- return findAllQuery.stream();
89
- }
@@ -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 {};