@tricoteuses/senat 1.1.1 → 1.3.1
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.
- package/README.md +53 -15
- package/lib/aggregates.d.ts +4 -6
- package/lib/aggregates.mjs +908 -780
- package/lib/aggregates.ts +8 -122
- package/lib/data/legislatures.json +38 -0
- package/lib/databases.d.ts +9 -0
- package/lib/databases.js +41 -11
- package/lib/databases.mjs +32 -1
- package/lib/databases.ts +40 -1
- package/lib/fields.mjs +64 -18
- package/lib/index.d.ts +5 -6
- package/lib/index.js +8 -99
- package/lib/index.mjs +4 -6
- package/lib/index.ts +9 -26
- package/lib/inserters.d.ts +0 -4
- package/lib/inserters.mjs +461 -337
- package/lib/inserters.ts +0 -24
- package/lib/legislatures.json +38 -0
- package/lib/loaders.d.ts +64 -0
- package/lib/loaders.js +682 -0
- package/lib/loaders.mjs +158 -0
- package/lib/loaders.ts +271 -0
- package/lib/model/ameli.d.ts +105 -4
- package/lib/model/ameli.js +20 -160
- package/lib/model/ameli.mjs +84 -57
- package/lib/model/ameli.ts +94 -80
- package/lib/model/debats.d.ts +0 -4
- package/lib/model/debats.js +1 -122
- package/lib/model/debats.mjs +1 -43
- package/lib/model/debats.ts +0 -68
- package/lib/model/dosleg.d.ts +227 -29
- package/lib/model/dosleg.js +92 -832
- package/lib/model/dosleg.mjs +196 -337
- package/lib/model/dosleg.ts +213 -531
- package/lib/model/index.d.ts +4 -5
- package/lib/model/index.js +14 -15
- package/lib/model/index.mjs +4 -5
- package/lib/model/index.ts +8 -5
- package/lib/model/questions.d.ts +88 -2
- package/lib/model/questions.js +40 -45
- package/lib/model/questions.mjs +71 -8
- package/lib/model/questions.ts +90 -11
- package/lib/model/sens.d.ts +524 -2
- package/lib/model/sens.js +172 -49
- package/lib/model/sens.mjs +415 -9
- package/lib/model/sens.ts +514 -16
- package/lib/model/texte.d.ts +7 -0
- package/lib/model/texte.js +321 -0
- package/lib/model/texte.mjs +208 -0
- package/lib/model/texte.ts +229 -0
- package/lib/model/util.d.ts +7 -1
- package/lib/model/util.js +37 -53
- package/lib/model/util.mjs +19 -10
- package/lib/model/util.ts +30 -14
- package/lib/raw_types/ameli.d.ts +912 -538
- package/lib/raw_types/ameli.js +1 -39
- package/lib/raw_types/ameli.mjs +4 -1
- package/lib/raw_types/ameli.ts +947 -597
- package/lib/raw_types/debats.d.ts +204 -124
- package/lib/raw_types/debats.js +1 -18
- package/lib/raw_types/debats.mjs +4 -1
- package/lib/raw_types/debats.ts +218 -141
- package/lib/raw_types/dosleg.d.ts +3533 -2024
- package/lib/raw_types/dosleg.js +1 -92
- package/lib/raw_types/dosleg.mjs +4 -1
- package/lib/raw_types/dosleg.ts +3621 -2189
- package/lib/raw_types/questions.d.ts +404 -220
- package/lib/raw_types/questions.js +1 -18
- package/lib/raw_types/questions.mjs +4 -1
- package/lib/raw_types/questions.ts +404 -226
- package/lib/raw_types/sens.d.ts +4391 -2706
- package/lib/raw_types/sens.js +1 -108
- package/lib/raw_types/sens.mjs +4 -1
- package/lib/raw_types/sens.ts +4495 -2903
- package/lib/raw_types_kysely/ameli.d.ts +6 -0
- package/lib/raw_types_kysely/ameli.mjs +7 -0
- package/lib/raw_types_kysely/ameli.ts +6 -0
- package/lib/raw_types_kysely/debats.d.ts +6 -0
- package/lib/raw_types_kysely/debats.mjs +7 -0
- package/lib/raw_types_kysely/debats.ts +6 -0
- package/lib/raw_types_kysely/dosleg.d.ts +6 -0
- package/lib/raw_types_kysely/dosleg.mjs +7 -0
- package/lib/raw_types_kysely/dosleg.ts +6 -0
- package/lib/raw_types_kysely/questions.d.ts +6 -0
- package/lib/raw_types_kysely/questions.mjs +7 -0
- package/lib/raw_types_kysely/questions.ts +6 -0
- package/lib/raw_types_kysely/sens.d.ts +6 -0
- package/lib/raw_types_kysely/sens.mjs +7 -0
- package/lib/raw_types_kysely/sens.ts +6 -0
- package/lib/raw_types_kysely/texte.d.ts +45 -0
- package/lib/raw_types_kysely/texte.mjs +7 -0
- package/lib/raw_types_kysely/texte.ts +53 -0
- package/lib/raw_types_schemats/ameli.d.ts +541 -0
- package/lib/raw_types_schemats/ameli.js +45 -0
- package/lib/raw_types_schemats/ameli.mjs +2 -0
- package/lib/raw_types_schemats/ameli.ts +601 -0
- package/lib/raw_types_schemats/debats.d.ts +127 -0
- package/lib/raw_types_schemats/debats.js +24 -0
- package/lib/raw_types_schemats/debats.mjs +2 -0
- package/lib/raw_types_schemats/debats.ts +145 -0
- package/lib/raw_types_schemats/dosleg.d.ts +2029 -0
- package/lib/raw_types_schemats/dosleg.js +98 -0
- package/lib/raw_types_schemats/dosleg.mjs +2 -0
- package/lib/raw_types_schemats/dosleg.ts +2195 -0
- package/lib/raw_types_schemats/questions.d.ts +233 -0
- package/lib/raw_types_schemats/questions.js +24 -0
- package/lib/raw_types_schemats/questions.mjs +2 -0
- package/lib/raw_types_schemats/questions.ts +251 -0
- package/lib/raw_types_schemats/sens.d.ts +2709 -0
- package/lib/raw_types_schemats/sens.js +114 -0
- package/lib/raw_types_schemats/sens.mjs +2 -0
- package/lib/raw_types_schemats/sens.ts +2907 -0
- package/lib/scripts/convert_data.js +574 -215
- package/lib/scripts/convert_data.mjs +134 -99
- package/lib/scripts/convert_data.ts +173 -112
- package/lib/scripts/datautil.d.ts +5 -0
- package/lib/scripts/datautil.js +64 -0
- package/lib/scripts/datautil.mjs +16 -0
- package/lib/scripts/datautil.ts +19 -0
- package/lib/scripts/parse_textes.js +132 -0
- package/lib/scripts/parse_textes.mjs +46 -0
- package/lib/scripts/parse_textes.ts +65 -0
- package/lib/scripts/retrieve_documents.d.ts +1 -0
- package/lib/scripts/retrieve_documents.js +521 -0
- package/lib/scripts/retrieve_documents.mjs +249 -0
- package/lib/scripts/retrieve_documents.ts +298 -0
- package/lib/scripts/retrieve_open_data.js +77 -69
- package/lib/scripts/retrieve_open_data.mjs +48 -49
- package/lib/scripts/retrieve_open_data.ts +74 -58
- package/lib/scripts/retrieve_senateurs_photos.js +45 -63
- package/lib/scripts/retrieve_senateurs_photos.mjs +4 -21
- package/lib/scripts/retrieve_senateurs_photos.ts +6 -29
- package/lib/scripts/retrieve_textes.mjs +325 -74
- package/lib/scripts/retrieve_textes.ts +111 -63
- package/lib/scripts/shared/cli_helpers.d.ts +44 -0
- package/lib/scripts/shared/cli_helpers.js +35 -0
- package/lib/scripts/shared/cli_helpers.ts +36 -0
- package/lib/scripts/shared/util.d.ts +3 -0
- package/lib/scripts/shared/util.js +102 -0
- package/lib/scripts/shared/util.ts +33 -0
- package/lib/src/aggregates.d.ts +52 -0
- package/lib/src/aggregates.mjs +726 -0
- package/lib/src/config.d.ts +2 -0
- package/lib/src/config.mjs +16 -0
- package/lib/src/databases.d.ts +18 -0
- package/lib/src/databases.mjs +55 -0
- package/lib/src/datasets.d.ts +28 -0
- package/lib/src/datasets.mjs +78 -0
- package/lib/src/fields.d.ts +10 -0
- package/lib/src/fields.mjs +22 -0
- package/lib/src/index.d.ts +8 -0
- package/lib/src/index.mjs +7 -0
- package/lib/src/inserters.d.ts +98 -0
- package/lib/src/inserters.mjs +360 -0
- package/lib/src/loaders.d.ts +36 -0
- package/lib/src/loaders.mjs +107 -0
- package/lib/src/model/ameli.d.ts +4 -0
- package/lib/src/model/ameli.js +57 -0
- package/lib/src/model/debats.d.ts +4 -0
- package/lib/src/model/debats.js +43 -0
- package/lib/src/model/dosleg.d.ts +197 -0
- package/lib/src/model/dosleg.js +169 -0
- package/lib/src/model/index.d.ts +4 -0
- package/lib/src/model/index.js +4 -0
- package/lib/src/model/questions.d.ts +89 -0
- package/lib/src/model/questions.js +76 -0
- package/lib/src/model/sens.d.ts +390 -0
- package/lib/src/model/sens.js +339 -0
- package/lib/src/model/texte.d.ts +7 -0
- package/lib/src/model/texte.js +183 -0
- package/lib/src/raw_types_kysely/ameli.d.ts +915 -0
- package/lib/src/raw_types_kysely/ameli.js +5 -0
- package/lib/src/raw_types_kysely/debats.d.ts +207 -0
- package/lib/src/raw_types_kysely/debats.js +5 -0
- package/lib/src/raw_types_kysely/dosleg.d.ts +3532 -0
- package/lib/src/raw_types_kysely/dosleg.js +5 -0
- package/lib/src/raw_types_kysely/questions.d.ts +414 -0
- package/lib/src/raw_types_kysely/questions.js +5 -0
- package/lib/src/raw_types_kysely/sens.d.ts +4394 -0
- package/lib/src/raw_types_kysely/sens.js +5 -0
- package/lib/src/raw_types_schemats/ameli.d.ts +541 -0
- package/lib/src/raw_types_schemats/ameli.js +2 -0
- package/lib/src/raw_types_schemats/debats.d.ts +127 -0
- package/lib/src/raw_types_schemats/debats.js +2 -0
- package/lib/src/raw_types_schemats/dosleg.d.ts +2027 -0
- package/lib/src/raw_types_schemats/dosleg.js +2 -0
- package/lib/src/raw_types_schemats/questions.d.ts +231 -0
- package/lib/src/raw_types_schemats/questions.js +2 -0
- package/lib/src/raw_types_schemats/sens.d.ts +2709 -0
- package/lib/src/raw_types_schemats/sens.js +2 -0
- package/lib/src/scripts/convert_data.d.ts +1 -0
- package/lib/src/scripts/convert_data.js +95 -0
- package/lib/src/scripts/datautil.d.ts +5 -0
- package/lib/src/scripts/datautil.js +16 -0
- package/lib/src/scripts/parse_textes.d.ts +1 -0
- package/lib/src/scripts/parse_textes.js +47 -0
- package/lib/src/scripts/retrieve_documents.d.ts +1 -0
- package/lib/src/scripts/retrieve_documents.js +258 -0
- package/lib/src/scripts/retrieve_open_data.d.ts +1 -0
- package/lib/src/scripts/retrieve_open_data.js +214 -0
- package/lib/src/scripts/retrieve_senateurs_photos.d.ts +1 -0
- package/lib/src/scripts/retrieve_senateurs_photos.js +147 -0
- package/lib/src/scripts/shared/cli_helpers.d.ts +44 -0
- package/lib/src/scripts/shared/cli_helpers.js +32 -0
- package/lib/src/scripts/shared/util.d.ts +3 -0
- package/lib/src/scripts/shared/util.js +28 -0
- package/lib/src/strings.d.ts +1 -0
- package/lib/src/strings.mjs +18 -0
- package/lib/src/types/ameli.d.ts +10 -0
- package/lib/src/types/ameli.js +13 -0
- package/lib/src/types/debats.d.ts +4 -0
- package/lib/src/types/debats.js +2 -0
- package/lib/src/types/dosleg.d.ts +98 -0
- package/lib/src/types/dosleg.js +151 -0
- package/lib/src/types/questions.d.ts +2 -0
- package/lib/src/types/questions.js +1 -0
- package/lib/src/types/sens.d.ts +10 -0
- package/lib/src/types/sens.js +1 -0
- package/lib/src/types/sessions.d.ts +42 -0
- package/lib/src/types/sessions.js +43 -0
- package/lib/src/types/texte.d.ts +61 -0
- package/lib/src/types/texte.js +16 -0
- package/lib/src/validators/config.d.ts +1 -0
- package/lib/src/validators/config.js +54 -0
- package/lib/src/validators/senat.d.ts +0 -0
- package/lib/src/validators/senat.js +24 -0
- package/lib/types/ameli.d.ts +1 -1
- package/lib/types/ameli.js +2 -2
- package/lib/types/ameli.ts +1 -1
- package/lib/types/debats.d.ts +1 -1
- package/lib/types/debats.js +2 -2
- package/lib/types/debats.ts +1 -1
- package/lib/types/dosleg.d.ts +2 -2
- package/lib/types/dosleg.js +2 -2
- package/lib/types/dosleg.ts +2 -2
- package/lib/types/questions.d.ts +1 -1
- package/lib/types/questions.js +2 -2
- package/lib/types/questions.ts +1 -1
- package/lib/types/sens.d.ts +1 -3
- package/lib/types/sens.js +2 -5
- package/lib/types/sens.mjs +1 -23
- package/lib/types/sens.ts +1 -25
- package/lib/types/sessions.d.ts +42 -0
- package/lib/types/sessions.js +51 -0
- package/lib/types/sessions.mjs +43 -0
- package/lib/types/sessions.ts +42 -0
- package/lib/types/texte.d.ts +65 -0
- package/lib/types/texte.js +24 -0
- package/lib/types/texte.mjs +16 -0
- package/lib/types/texte.ts +76 -0
- package/package.json +35 -10
- package/lib/aggregates.js +0 -1122
- package/lib/fields.js +0 -68
- package/lib/inserters.js +0 -518
- package/lib/scripts/fix_db.js +0 -144
- package/lib/scripts/fix_db.mjs +0 -64
- package/lib/scripts/fix_db.ts +0 -75
- package/lib/scripts/retrieve_textes.js +0 -179
- /package/lib/scripts/{fix_db.d.ts → parse_textes.d.ts} +0 -0
package/lib/model/dosleg.mjs
CHANGED
|
@@ -1,337 +1,196 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
export
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
WHERE orgcod IN (
|
|
198
|
-
SELECT orgcod
|
|
199
|
-
FROM raporg
|
|
200
|
-
WHERE rapcod IN ($<ids:list>)
|
|
201
|
-
)
|
|
202
|
-
`, {
|
|
203
|
-
ids,
|
|
204
|
-
})).map((org) => trimFieldsRight(orgFieldsToTrim, org));
|
|
205
|
-
};
|
|
206
|
-
export const getRaporgsFromOrgcods = async (ids) => {
|
|
207
|
-
if (ids.length === 0) {
|
|
208
|
-
return [];
|
|
209
|
-
}
|
|
210
|
-
return (await dbByName.dosleg.any(`
|
|
211
|
-
SELECT *
|
|
212
|
-
FROM raporg
|
|
213
|
-
WHERE orgcod IN ($<ids:list>)
|
|
214
|
-
`, {
|
|
215
|
-
ids,
|
|
216
|
-
})).map((raporg) => trimFieldsRight(raporgFieldsToTrim, raporg));
|
|
217
|
-
};
|
|
218
|
-
export const getOritxts = async (ids) => {
|
|
219
|
-
if (ids.length === 0) {
|
|
220
|
-
return [];
|
|
221
|
-
}
|
|
222
|
-
return (await dbByName.dosleg.any(`
|
|
223
|
-
SELECT *
|
|
224
|
-
FROM oritxt
|
|
225
|
-
WHERE oritxtcod IN ($<ids:list>)
|
|
226
|
-
`, {
|
|
227
|
-
ids,
|
|
228
|
-
})).map((oritxt) => trimFieldsRight(oritxtFieldsToTrim, oritxt));
|
|
229
|
-
};
|
|
230
|
-
export const getQuas = async (ids) => {
|
|
231
|
-
if (ids.length === 0) {
|
|
232
|
-
return [];
|
|
233
|
-
}
|
|
234
|
-
return (await dbByName.dosleg.any(`
|
|
235
|
-
SELECT *
|
|
236
|
-
FROM qua
|
|
237
|
-
WHERE quacod IN ($<ids:list>)
|
|
238
|
-
`, {
|
|
239
|
-
ids,
|
|
240
|
-
})).map((qua) => trimFieldsRight(quaFieldsToTrim, qua));
|
|
241
|
-
};
|
|
242
|
-
export const getRaps = async (ids) => {
|
|
243
|
-
if (ids.length === 0) {
|
|
244
|
-
return [];
|
|
245
|
-
}
|
|
246
|
-
return (await dbByName.dosleg.any(`
|
|
247
|
-
SELECT *
|
|
248
|
-
FROM rap
|
|
249
|
-
WHERE rapcod IN ($<ids:list>)
|
|
250
|
-
`, {
|
|
251
|
-
ids,
|
|
252
|
-
})).map((rap) => parseIntFields(rapFieldsToParseInt, trimFieldsRight(rapFieldsToTrim, rap)));
|
|
253
|
-
};
|
|
254
|
-
export const getScrsFromCodes = async (ids) => {
|
|
255
|
-
if (ids.length === 0) {
|
|
256
|
-
return [];
|
|
257
|
-
}
|
|
258
|
-
return (await dbByName.dosleg.any(`
|
|
259
|
-
SELECT *
|
|
260
|
-
FROM scr
|
|
261
|
-
WHERE code IN ($<ids:list>)
|
|
262
|
-
`, {
|
|
263
|
-
ids,
|
|
264
|
-
})).map((scr) => trimFieldsRight(scrFieldsToTrim, scr));
|
|
265
|
-
};
|
|
266
|
-
export const getTextesFromLecassidts = async (ids) => {
|
|
267
|
-
if (ids.length === 0) {
|
|
268
|
-
return [];
|
|
269
|
-
}
|
|
270
|
-
return (await dbByName.dosleg.any(`
|
|
271
|
-
SELECT *
|
|
272
|
-
FROM texte
|
|
273
|
-
WHERE lecassidt IN ($<ids:list>)
|
|
274
|
-
`, {
|
|
275
|
-
ids,
|
|
276
|
-
})).map((texte) => parseIntFields(texteFieldsToParseInt, trimFieldsRight(texteFieldsToTrim, texte)));
|
|
277
|
-
};
|
|
278
|
-
export const getTypatts = async (ids) => {
|
|
279
|
-
if (ids.length === 0) {
|
|
280
|
-
return [];
|
|
281
|
-
}
|
|
282
|
-
return (await dbByName.dosleg.any(`
|
|
283
|
-
SELECT *
|
|
284
|
-
FROM typatt
|
|
285
|
-
WHERE typattcod IN ($<ids:list>)
|
|
286
|
-
`, {
|
|
287
|
-
ids,
|
|
288
|
-
})).map((typatt) => trimFieldsRight(typattFieldsToTrim, typatt));
|
|
289
|
-
};
|
|
290
|
-
export const getTyplecs = async (ids) => {
|
|
291
|
-
if (ids.length === 0) {
|
|
292
|
-
return [];
|
|
293
|
-
}
|
|
294
|
-
return (await dbByName.dosleg.any(`
|
|
295
|
-
SELECT *
|
|
296
|
-
FROM typlec
|
|
297
|
-
WHERE typleccod IN ($<ids:list>)
|
|
298
|
-
`, {
|
|
299
|
-
ids,
|
|
300
|
-
})).map((typlec) => trimFieldsRight(typlecFieldsToTrim, typlec));
|
|
301
|
-
};
|
|
302
|
-
export const getTyplois = async (ids) => {
|
|
303
|
-
if (ids.length === 0) {
|
|
304
|
-
return [];
|
|
305
|
-
}
|
|
306
|
-
return (await dbByName.dosleg.any(`
|
|
307
|
-
SELECT *
|
|
308
|
-
FROM typloi
|
|
309
|
-
WHERE typloicod IN ($<ids:list>)
|
|
310
|
-
`, {
|
|
311
|
-
ids,
|
|
312
|
-
})).map((typloi) => trimFieldsRight(typloiFieldsToTrim, typloi));
|
|
313
|
-
};
|
|
314
|
-
export const getTyptxts = async (ids) => {
|
|
315
|
-
if (ids.length === 0) {
|
|
316
|
-
return [];
|
|
317
|
-
}
|
|
318
|
-
return (await dbByName.dosleg.any(`
|
|
319
|
-
SELECT *
|
|
320
|
-
FROM typtxt
|
|
321
|
-
WHERE typtxtcod IN ($<ids:list>)
|
|
322
|
-
`, {
|
|
323
|
-
ids,
|
|
324
|
-
})).map((typtxt) => trimFieldsRight(typtxtFieldsToTrim, typtxt));
|
|
325
|
-
};
|
|
326
|
-
export const getTypurls = async (ids) => {
|
|
327
|
-
if (ids.length === 0) {
|
|
328
|
-
return [];
|
|
329
|
-
}
|
|
330
|
-
return (await dbByName.dosleg.any(`
|
|
331
|
-
SELECT *
|
|
332
|
-
FROM typurl
|
|
333
|
-
WHERE typurl IN ($<ids:list>)
|
|
334
|
-
`, {
|
|
335
|
-
ids,
|
|
336
|
-
})).map((typurl) => trimFieldsRight(typurlFieldsToTrim, typurl));
|
|
337
|
-
};
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
import { jsonArrayFrom } from "kysely/helpers/postgres";
|
|
3
|
+
import { dbDosleg } from "../databases";
|
|
4
|
+
import { concat, removeSubstring, rtrim, toDateString } from "./util";
|
|
5
|
+
function orderOrdreOrigineTexte(expr) {
|
|
6
|
+
return sql `array_position(array['0','2','1'], ${expr})`;
|
|
7
|
+
}
|
|
8
|
+
function datesSeances(lectureAssembleeId) {
|
|
9
|
+
return jsonArrayFrom(dbDosleg.selectFrom("date_seance")
|
|
10
|
+
.where("date_seance.lecidt", "=", lectureAssembleeId)
|
|
11
|
+
.select(({ ref }) => [
|
|
12
|
+
toDateString(ref("date_seance.date_s")).as("date"),
|
|
13
|
+
]));
|
|
14
|
+
}
|
|
15
|
+
function organismesRapport(rapportId) {
|
|
16
|
+
return jsonArrayFrom(dbDosleg.selectFrom("org")
|
|
17
|
+
.leftJoin("raporg", "raporg.orgcod", "org.orgcod")
|
|
18
|
+
.where("raporg.rapcod", "=", rapportId)
|
|
19
|
+
.select([
|
|
20
|
+
"org.orgnom as libelle",
|
|
21
|
+
]));
|
|
22
|
+
}
|
|
23
|
+
function auteursRapport(rapportId) {
|
|
24
|
+
return jsonArrayFrom(dbDosleg.selectFrom("auteur")
|
|
25
|
+
.leftJoin("ecr", "ecr.autcod", "auteur.autcod")
|
|
26
|
+
.where("ecr.rapcod", "=", rapportId)
|
|
27
|
+
.select([
|
|
28
|
+
"auteur.prenom as prenom",
|
|
29
|
+
"auteur.nomuse as nom_usuel",
|
|
30
|
+
"auteur.autmat as matricule",
|
|
31
|
+
])
|
|
32
|
+
.orderBy("ecr.ecrnumtri", "asc"));
|
|
33
|
+
}
|
|
34
|
+
function rapports(lectureAssembleeId) {
|
|
35
|
+
return jsonArrayFrom(dbDosleg.selectFrom("rap")
|
|
36
|
+
.leftJoin("lecassrap", "lecassrap.rapcod", "rap.rapcod")
|
|
37
|
+
.leftJoin("denrap", "denrap.coddenrap", "rap.coddenrap")
|
|
38
|
+
.where("lecassrap.lecassidt", "=", lectureAssembleeId)
|
|
39
|
+
.select(({ eb, ref, val }) => [
|
|
40
|
+
"rap.rapnum as numero",
|
|
41
|
+
rtrim(ref("denrap.libdenrap")).as("type_rapport"),
|
|
42
|
+
eb.case()
|
|
43
|
+
.when("rap.typurl", "=", "I")
|
|
44
|
+
.then(concat(val("https://www.senat.fr/rap/"), rtrim(ref("rap.rapurl"))))
|
|
45
|
+
.else(rtrim(ref("rap.rapurl")))
|
|
46
|
+
.end()
|
|
47
|
+
.as("url"),
|
|
48
|
+
toDateString(ref("rap.date_depot")).as("date_depot"),
|
|
49
|
+
auteursRapport(ref("rap.rapcod")).as("auteurs"),
|
|
50
|
+
organismesRapport(ref("rap.rapcod")).as("organismes"),
|
|
51
|
+
]));
|
|
52
|
+
}
|
|
53
|
+
function auteursTexte(texteId) {
|
|
54
|
+
return jsonArrayFrom(dbDosleg.selectFrom("auteur")
|
|
55
|
+
.leftJoin("ecr", "ecr.autcod", "auteur.autcod")
|
|
56
|
+
.where("ecr.texcod", "=", texteId)
|
|
57
|
+
.select([
|
|
58
|
+
"auteur.prenom as prenom",
|
|
59
|
+
"auteur.nomuse as nom_usuel",
|
|
60
|
+
"auteur.autmat as matricule",
|
|
61
|
+
])
|
|
62
|
+
.orderBy("ecr.ecrnumtri", "asc"));
|
|
63
|
+
}
|
|
64
|
+
function textes(lectureAssembleeId) {
|
|
65
|
+
return jsonArrayFrom(dbDosleg.selectFrom("texte")
|
|
66
|
+
.leftJoin("oritxt", "oritxt.oritxtcod", "texte.oritxtcod")
|
|
67
|
+
.leftJoin("typtxt", "typtxt.typtxtcod", "texte.typtxtcod")
|
|
68
|
+
.where("texte.lecassidt", "=", lectureAssembleeId)
|
|
69
|
+
.select(({ eb, ref, val }) => [
|
|
70
|
+
"texte.texnum as numero",
|
|
71
|
+
eb.case()
|
|
72
|
+
.when("texte.typurl", "=", "I")
|
|
73
|
+
.then(removeSubstring(ref("texte.texurl"), val(".html")))
|
|
74
|
+
.else(null)
|
|
75
|
+
.end()
|
|
76
|
+
.as("id"),
|
|
77
|
+
eb.case()
|
|
78
|
+
.when("texte.typurl", "=", "I")
|
|
79
|
+
.then(concat(val("https://www.senat.fr/leg/"), rtrim(ref("texte.texurl"))))
|
|
80
|
+
.else(rtrim(ref("texte.texurl")))
|
|
81
|
+
.end()
|
|
82
|
+
.as("url"),
|
|
83
|
+
rtrim(ref("oritxt.oritxtlib")).as("origine_texte"),
|
|
84
|
+
rtrim(ref("typtxt.typtxtlib")).as("type_texte"),
|
|
85
|
+
toDateString(ref("texte.txtoritxtdat")).as("date"),
|
|
86
|
+
"sesann as session",
|
|
87
|
+
auteursTexte(ref("texte.texcod")).as("auteurs"),
|
|
88
|
+
])
|
|
89
|
+
.orderBy(({ ref }) => orderOrdreOrigineTexte(ref("oritxt.oriordre"))));
|
|
90
|
+
}
|
|
91
|
+
function lecturesAssemblee(lectureId) {
|
|
92
|
+
return jsonArrayFrom(dbDosleg.selectFrom("lecass")
|
|
93
|
+
.where("lecass.lecidt", "=", lectureId)
|
|
94
|
+
.leftJoin("ass", "ass.codass", "lecass.codass")
|
|
95
|
+
.leftJoin("org", "org.orgcod", "lecass.orgcod")
|
|
96
|
+
.select(({ ref }) => [
|
|
97
|
+
rtrim(ref("ass.libass")).as("assemblee"),
|
|
98
|
+
"org.orgnom as libelle_organisme",
|
|
99
|
+
"org.orgcod as code_organisme",
|
|
100
|
+
"lecass.ordreass as ordre_lecture_assemblee",
|
|
101
|
+
textes(ref("lecass.lecassidt")).as("textes"),
|
|
102
|
+
rapports(ref("lecass.lecassidt")).as("rapports"),
|
|
103
|
+
datesSeances(ref("lecass.lecassidt")).as("dates_seances"),
|
|
104
|
+
])
|
|
105
|
+
.orderBy("lecass.ordreass", "asc"));
|
|
106
|
+
}
|
|
107
|
+
function lectures(loiId) {
|
|
108
|
+
return jsonArrayFrom(dbDosleg.selectFrom("lecture")
|
|
109
|
+
.leftJoin("typlec", "typlec.typleccod", "lecture.typleccod")
|
|
110
|
+
.where("lecture.loicod", "=", loiId)
|
|
111
|
+
.select(({ ref }) => [
|
|
112
|
+
rtrim(ref("typlec.typleclib")).as("type_lecture"),
|
|
113
|
+
rtrim(ref("lecture.leccom")).as("libelle"),
|
|
114
|
+
"typlec.typlecord as ordre_lecture",
|
|
115
|
+
lecturesAssemblee(ref("lecture.lecidt")).as("lectures_assemblee"),
|
|
116
|
+
])
|
|
117
|
+
.orderBy("typlec.typlecord", "asc"));
|
|
118
|
+
}
|
|
119
|
+
function themes(loiId) {
|
|
120
|
+
return jsonArrayFrom(dbDosleg.selectFrom("the")
|
|
121
|
+
.leftJoin("loithe", "loithe.thecle", "the.thecle")
|
|
122
|
+
.where("loithe.loicod", "=", loiId)
|
|
123
|
+
.select([
|
|
124
|
+
"the.thelib as libelle",
|
|
125
|
+
]));
|
|
126
|
+
}
|
|
127
|
+
const findAllQuery = dbDosleg
|
|
128
|
+
.selectFrom("loi")
|
|
129
|
+
.leftJoin("typloi", "typloi.typloicod", "loi.typloicod")
|
|
130
|
+
.leftJoin("etaloi", "etaloi.etaloicod", "loi.etaloicod")
|
|
131
|
+
.select(({ eb, ref, val }) => [
|
|
132
|
+
"loi.signet as signet",
|
|
133
|
+
concat(val("https://www.senat.fr/dossier-legislatif/"), ref("loi.signet"), val(".html")).as("url"),
|
|
134
|
+
concat(rtrim(ref("typloi.typloiden")), val(" "), rtrim(ref("loi.loitit"))).as("titre"),
|
|
135
|
+
rtrim(ref("loi.loient")).as("titre_court"),
|
|
136
|
+
rtrim(ref("typloi.groupe")).as("code_nature_dossier"),
|
|
137
|
+
rtrim(ref("typloi.typloilib")).as("libelle_type_dossier"),
|
|
138
|
+
rtrim(ref("etaloi.etaloilib")).as("etat_dossier"),
|
|
139
|
+
"loi.url_an as url_dossier_assemblee_nationale",
|
|
140
|
+
toDateString(ref("loi.date_decision")).as("date_decision_CoC"),
|
|
141
|
+
"loi.num_decision as num_decision_CoC",
|
|
142
|
+
"loi.deccocurl as url_decision_CoC",
|
|
143
|
+
toDateString(ref("loi.saisine_date")).as("date_saisine_CoC"),
|
|
144
|
+
"loi.saisine_par as condition_saisine_CoC",
|
|
145
|
+
toDateString(ref("loi.date_loi")).as("date_promulgation"),
|
|
146
|
+
"loi.numero as numero_loi",
|
|
147
|
+
eb.case()
|
|
148
|
+
.when("loi.loititjo", "is not", null)
|
|
149
|
+
.then(concat(rtrim(ref("typloi.typloiden")), val(" "), rtrim(ref("loi.loititjo"))))
|
|
150
|
+
.else("")
|
|
151
|
+
.end()
|
|
152
|
+
.as("titre_JO"),
|
|
153
|
+
toDateString(ref("loi.loidatjo")).as("date_publication_JO"),
|
|
154
|
+
"loi.loinumjo as numero_JO",
|
|
155
|
+
"loi.url_jo as url_JO",
|
|
156
|
+
lectures(ref("loi.loicod")).as("lectures"),
|
|
157
|
+
themes(ref("loi.loicod")).as("themes"),
|
|
158
|
+
])
|
|
159
|
+
.$narrowType();
|
|
160
|
+
export function findAll() {
|
|
161
|
+
return findAllQuery.stream();
|
|
162
|
+
}
|
|
163
|
+
export function findSenatTexteUrls(sessions = []) {
|
|
164
|
+
return dbDosleg
|
|
165
|
+
.selectFrom("texte")
|
|
166
|
+
.where("texurl", "is not", null)
|
|
167
|
+
.where("typurl", "=", "I")
|
|
168
|
+
.$if(sessions.length > 0, (qb) => qb
|
|
169
|
+
.where("sesann", "in", sessions))
|
|
170
|
+
.select(({ eb, ref }) => [
|
|
171
|
+
"sesann as session",
|
|
172
|
+
rtrim(ref("texurl")).as("url"),
|
|
173
|
+
eb.case()
|
|
174
|
+
.when("oritxtcod", "=", "1")
|
|
175
|
+
.then(true)
|
|
176
|
+
.else(false)
|
|
177
|
+
.end()
|
|
178
|
+
.as("hasExposeDesMotifs"),
|
|
179
|
+
])
|
|
180
|
+
.$narrowType()
|
|
181
|
+
.stream();
|
|
182
|
+
}
|
|
183
|
+
export function findSenatRapportUrls(sessions = []) {
|
|
184
|
+
return dbDosleg
|
|
185
|
+
.selectFrom("rap")
|
|
186
|
+
.where("rapurl", "is not", null)
|
|
187
|
+
.where("typurl", "=", "I")
|
|
188
|
+
.$if(sessions.length > 0, (qb) => qb
|
|
189
|
+
.where("sesann", "in", sessions))
|
|
190
|
+
.select(({ ref }) => [
|
|
191
|
+
rtrim(ref("rapurl")).as("url"),
|
|
192
|
+
"sesann as session",
|
|
193
|
+
])
|
|
194
|
+
.$narrowType()
|
|
195
|
+
.stream();
|
|
196
|
+
}
|