@tricoteuses/senat 1.1.2 → 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 -7
- package/lib/index.js +8 -112
- package/lib/index.mjs +4 -7
- package/lib/index.ts +9 -30
- 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/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# Tricoteuses-Senat
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## _Retrieve, clean up & handle French Sénat's open data_
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node >= 22
|
|
4
8
|
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
@@ -15,7 +19,7 @@ Create a `.env` file to set PostgreSQL database informations and other configura
|
|
|
15
19
|
npm install
|
|
16
20
|
```
|
|
17
21
|
|
|
18
|
-
### Database creation
|
|
22
|
+
### Database creation (not needed if downloading with Docker image)
|
|
19
23
|
|
|
20
24
|
#### Using Docker
|
|
21
25
|
|
|
@@ -26,33 +30,67 @@ docker run --name local-postgres -d -p 5432:5432 -e POSTGRES_PASSWORD=$YOUR_CUST
|
|
|
26
30
|
docker exec -it local-postgres psql -U postgres -c "CREATE ROLE opendata;"
|
|
27
31
|
```
|
|
28
32
|
|
|
29
|
-
##
|
|
33
|
+
## Download data
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
Create a folder where the data will be downloaded and run the following command to download the data and convert it into JSON files.
|
|
32
36
|
|
|
33
37
|
```bash
|
|
34
38
|
mkdir ../senat-data/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
|
|
40
|
+
# Available options for optional `categories` parameter : All, Ameli, Debats, DosLeg, Questions, Sens
|
|
41
|
+
npm run data:download ../senat-data -- [--categories All]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Data from other sources is also available :
|
|
45
|
+
```bash
|
|
46
|
+
# Retrieval of sénateurs' pictures from Sénat's website
|
|
47
|
+
npm run data:retrieve_senateurs_photos ../senat-data
|
|
48
|
+
|
|
49
|
+
# Retrieval of textes and rapports from Sénat's website
|
|
50
|
+
# Available options for optional `formats` parameter : xml, html, pdf
|
|
51
|
+
# Available options for optional `types` parameter : textes, rapports
|
|
52
|
+
npm run data:retrieve_documents ../senat-data -- --sessions 2024 2025 [--formats xml pdf] [--types textes]
|
|
53
|
+
|
|
54
|
+
# Retrieval & parsing (textes in xml format only for now)
|
|
55
|
+
npm run data:retrieve_documents ../senat-data -- --sessions 2024 2025 --parseDocuments
|
|
56
|
+
|
|
57
|
+
# Parsing only
|
|
58
|
+
npm run data:parse_textes_lois ../senat-data
|
|
39
59
|
```
|
|
40
60
|
|
|
41
|
-
##
|
|
61
|
+
## Data download using Docker
|
|
62
|
+
|
|
63
|
+
A Docker image that downloads and cleans the data all at once is available. Create and run it locally from the container registry:
|
|
42
64
|
|
|
43
65
|
```bash
|
|
44
|
-
|
|
66
|
+
docker volume create senat-data # Create a volume to download the data
|
|
67
|
+
docker run --name tricoteuses-senat -v senat-data:/app/senat-data -d registry.en-root.org/tricoteuses/tricoteuses-senat:latest
|
|
45
68
|
```
|
|
46
69
|
|
|
47
|
-
|
|
70
|
+
Use the environment variable `CATEGORIES` and `SESSIONS` if needed.
|
|
71
|
+
|
|
72
|
+
## Using the data
|
|
73
|
+
|
|
74
|
+
Once the data is downloaded, you can use loaders to retrieve it.
|
|
75
|
+
To use loaders in your project, you can install the _@tricoteuses/senat_ package, and import the iterator functions that you need.
|
|
76
|
+
|
|
77
|
+
_Only iterator for Questions, Sénateurs and Circonscriptions available for now_
|
|
48
78
|
|
|
49
79
|
```bash
|
|
50
|
-
|
|
80
|
+
npm install @tricoteuses/senat
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
import { iterLoadSenatQuestions } from "@tricoteuses/senat/lib/loaders"
|
|
85
|
+
|
|
86
|
+
// Pass data directory and legislature as arguments
|
|
87
|
+
for (const { item: question } of iterLoadSenatQuestions("../senat-data", 17)) {
|
|
88
|
+
console.log(question.id)
|
|
89
|
+
}
|
|
51
90
|
```
|
|
52
91
|
|
|
53
|
-
|
|
92
|
+
## Generation of raw types from SQL schema (for contributors only)
|
|
54
93
|
|
|
55
|
-
To be run after database has been fixed (`src/scripts/fix_db.ts --updateSchema`).
|
|
56
94
|
```bash
|
|
57
|
-
|
|
95
|
+
npm run data:generate_schemas ../senat-data
|
|
58
96
|
```
|
package/lib/aggregates.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Ses, Sub, TxtAmeli } from
|
|
2
|
-
import { Debat } from
|
|
3
|
-
import { Ass, Aud, Auteur, DateSeance, DecCoc, DenRap, DocAtt, Ecr, EtaLoi, LecAss, LecAssRap, Lecture, Loi, Org, OriTxt, Qua, Rap, Scr, Texte, TypAtt, TypLec, TypLoi, TypTxt, TypUrl } from
|
|
4
|
-
import { Question } from
|
|
5
|
-
import { Sen } from './types/sens';
|
|
1
|
+
import { Ses, Sub, TxtAmeli } from "./types/ameli";
|
|
2
|
+
import { Debat } from "./types/debats";
|
|
3
|
+
import { Ass, Aud, Auteur, DateSeance, DecCoc, DenRap, DocAtt, Ecr, EtaLoi, LecAss, LecAssRap, Lecture, Loi, Org, OriTxt, Qua, Rap, Scr, Texte, TypAtt, TypLec, TypLoi, TypTxt, TypUrl } from "./types/dosleg";
|
|
4
|
+
import { Question } from "./types/questions";
|
|
6
5
|
export declare const allFollows: string[];
|
|
7
6
|
export declare class Aggregator {
|
|
8
7
|
follow: Set<string>;
|
|
@@ -38,7 +37,6 @@ export declare class Aggregator {
|
|
|
38
37
|
addQuestion(question: Question): void;
|
|
39
38
|
addRap(rap: Rap): void;
|
|
40
39
|
addScr(scr: Scr): void;
|
|
41
|
-
addSen(sen: Sen): void;
|
|
42
40
|
addSes(ses: Ses): void;
|
|
43
41
|
addSub(sub: Sub): void;
|
|
44
42
|
addTexte(texte: Texte): void;
|