@tricoteuses/senat 2.5.9 → 2.6.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 +6 -5
- package/lib/databases.d.ts +2 -11
- package/lib/databases.js +5 -29
- package/lib/index.d.ts +1 -0
- package/lib/loaders.d.ts +4 -1
- package/lib/loaders.js +7 -11
- package/lib/model/agenda.js +2 -1
- package/lib/model/ameli.d.ts +4 -6
- package/lib/model/ameli.js +2 -2
- package/lib/model/compte_rendu.d.ts +3 -0
- package/lib/model/compte_rendu.js +32 -0
- package/lib/model/debats.d.ts +81 -0
- package/lib/model/debats.js +81 -1
- package/lib/model/dosleg.d.ts +27 -14
- package/lib/model/dosleg.js +20 -2
- package/lib/model/index.d.ts +2 -1
- package/lib/model/index.js +2 -1
- package/lib/model/questions.d.ts +6 -8
- package/lib/model/questions.js +0 -2
- package/lib/model/sens.d.ts +11 -13
- package/lib/model/sens.js +7 -10
- package/lib/model/util.d.ts +1 -1
- package/lib/model/util.js +3 -2
- package/lib/scripts/convert_data.js +50 -20
- package/lib/scripts/datautil.d.ts +6 -2
- package/lib/scripts/datautil.js +22 -5
- package/lib/scripts/retrieve_agenda.js +46 -29
- package/lib/scripts/retrieve_comptes_rendus.d.ts +1 -0
- package/lib/scripts/retrieve_comptes_rendus.js +106 -0
- package/lib/scripts/retrieve_documents.js +74 -67
- package/lib/types/compte_rendu.d.ts +11 -0
- package/lib/types/compte_rendu.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# This repository has been migrated to https://git.tricoteuses.fr/logiciels/tricoteuses-senat.
|
|
2
|
-
|
|
3
1
|
# Tricoteuses-Senat
|
|
4
2
|
|
|
5
3
|
## _Retrieve, clean up & handle French Sénat's open data_
|
|
@@ -59,17 +57,20 @@ npm run data:parse_textes_lois ../senat-data
|
|
|
59
57
|
# Retrieval (& parsing) of agenda from Sénat's website
|
|
60
58
|
npm run data:retrieve_agenda ../senat-data -- --fromSession 2022 [--parseAgenda]
|
|
61
59
|
|
|
60
|
+
# Retrieval (& parsing) of comptes-rendus des débats from Sénat's website
|
|
61
|
+
npm run data:retrieve_comptes_rendus ../senat-data -- [--parseDebats]
|
|
62
|
+
|
|
62
63
|
# Retrieval of sénateurs' pictures from Sénat's website
|
|
63
64
|
npm run data:retrieve_senateurs_photos ../senat-data
|
|
64
65
|
```
|
|
65
66
|
|
|
66
67
|
## Data download using Docker
|
|
67
68
|
|
|
68
|
-
A Docker image that downloads and
|
|
69
|
+
A Docker image that downloads and converts the data all at once is available. Build it locally or run it from the container registry.
|
|
70
|
+
Use the environment variables `FROM_SESSION` and `CATEGORIES` if needed.
|
|
69
71
|
|
|
70
72
|
```bash
|
|
71
|
-
docker
|
|
72
|
-
docker run --name tricoteuses-senat -v senat-data:/app/senat-data -d git.tricoteuses.fr/logiciels/tricoteuses-senat:latest
|
|
73
|
+
docker run --pull always --name tricoteuses-senat -v ../senat-data:/app/senat-data -d git.tricoteuses.fr/logiciels/tricoteuses-senat:latest
|
|
73
74
|
```
|
|
74
75
|
|
|
75
76
|
Use the environment variable `CATEGORIES` and `FROM_SESSION` if needed.
|
package/lib/databases.d.ts
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { Kysely } from "kysely";
|
|
2
|
-
import PgPromise from "pg-promise";
|
|
3
2
|
import { DB as AmeliDatabase } from "./raw_types/ameli";
|
|
3
|
+
import { DB as DebatsDatabase } from "./raw_types/debats";
|
|
4
4
|
import { DB as DoslegDatabase } from "./raw_types/dosleg";
|
|
5
5
|
import { DB as QuestionsDatabase } from "./raw_types/questions";
|
|
6
6
|
import { DB as SensDatabase } from "./raw_types/sens";
|
|
7
|
-
export declare const pgPromise: PgPromise.IMain<{}, import("pg-promise/typescript/pg-subset").IClient>;
|
|
8
|
-
export declare const dbNames: string[];
|
|
9
|
-
export declare const dbByName: {
|
|
10
|
-
[name: string]: any;
|
|
11
|
-
};
|
|
12
7
|
export declare const dbAmeli: Kysely<AmeliDatabase>;
|
|
8
|
+
export declare const dbDebats: Kysely<DebatsDatabase>;
|
|
13
9
|
export declare const dbDosleg: Kysely<DoslegDatabase>;
|
|
14
10
|
export declare const dbQuestions: Kysely<QuestionsDatabase>;
|
|
15
11
|
export declare const dbSens: Kysely<SensDatabase>;
|
|
16
|
-
export declare let dbSharedConnectionObjectByName: {
|
|
17
|
-
[name: string]: PgPromise.IConnected<unknown, any>;
|
|
18
|
-
};
|
|
19
|
-
export declare function checkDatabase(name: string): Promise<any>;
|
|
20
|
-
export declare function checkDatabases(): Promise<void>;
|
package/lib/databases.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Kysely, PostgresDialect } from "kysely";
|
|
|
2
2
|
import * as pg from "pg";
|
|
3
3
|
import { types } from "pg";
|
|
4
4
|
import Cursor from "pg-cursor";
|
|
5
|
-
import PgPromise from "pg-promise";
|
|
6
5
|
import config from "./config";
|
|
7
6
|
import { datasets } from "./datasets";
|
|
8
7
|
// Map int8 to number instead of string
|
|
@@ -10,18 +9,11 @@ import { datasets } from "./datasets";
|
|
|
10
9
|
pg.types.setTypeParser(types.builtins.INT8, (val) => {
|
|
11
10
|
return parseInt(val, 10);
|
|
12
11
|
});
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
15
|
-
export const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
database: name,
|
|
19
|
-
host: config.db.host,
|
|
20
|
-
password: config.db.password,
|
|
21
|
-
port: config.db.port,
|
|
22
|
-
user: config.db.user,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
12
|
+
export const dbAmeli = createDb(datasets.ameli.database, datasets.ameli.schema);
|
|
13
|
+
export const dbDebats = createDb(datasets.debats.database, datasets.debats.schema);
|
|
14
|
+
export const dbDosleg = createDb(datasets.dosleg.database, datasets.dosleg.schema);
|
|
15
|
+
export const dbQuestions = createDb(datasets.questions.database, datasets.questions.schema);
|
|
16
|
+
export const dbSens = createDb(datasets.sens.database, datasets.sens.schema);
|
|
25
17
|
function createDb(database, schema) {
|
|
26
18
|
const dialect = new PostgresDialect({
|
|
27
19
|
pool: new pg.Pool({
|
|
@@ -39,19 +31,3 @@ function createDb(database, schema) {
|
|
|
39
31
|
dialect: dialect,
|
|
40
32
|
}).withSchema(schema);
|
|
41
33
|
}
|
|
42
|
-
export const dbAmeli = createDb(datasets.ameli.database, datasets.ameli.schema);
|
|
43
|
-
export const dbDosleg = createDb(datasets.dosleg.database, datasets.dosleg.schema);
|
|
44
|
-
export const dbQuestions = createDb(datasets.questions.database, datasets.questions.schema);
|
|
45
|
-
export const dbSens = createDb(datasets.sens.database, datasets.sens.schema);
|
|
46
|
-
export let dbSharedConnectionObjectByName = {};
|
|
47
|
-
export async function checkDatabase(name) {
|
|
48
|
-
// Check that database exists.
|
|
49
|
-
const db = dbByName[name];
|
|
50
|
-
dbSharedConnectionObjectByName[name] = await db.connect();
|
|
51
|
-
return db;
|
|
52
|
-
}
|
|
53
|
-
export async function checkDatabases() {
|
|
54
|
-
for (const name of dbNames) {
|
|
55
|
-
await checkDatabase(name);
|
|
56
|
-
}
|
|
57
|
-
}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { QuestionResult, } from "./model/questions";
|
|
|
4
4
|
export type { CirconscriptionResult, OrganismeResult, SenateurResult, } from "./model/sens";
|
|
5
5
|
export type { AgendaEvent } from "./types/agenda";
|
|
6
6
|
export type { Ses, Sub, TxtAmeli } from "./types/ameli";
|
|
7
|
+
export type { CompteRendu } from "./types/compte_rendu";
|
|
7
8
|
export type { Debat, LecAssDeb } from "./types/debats";
|
|
8
9
|
export type { Ass, Aud, Auteur, DateSeance, DecCoc, DenRap, DocAtt, Ecr, EtaLoi, LecAss, LecAssRap, Lecture, Loi, Org, OriTxt, Qua, Rap, RapOrg, Scr, Texte, TypAtt, TypLec, TypLoi, TypTxt, TypUrl, } from "./types/dosleg";
|
|
9
10
|
export type { Photo, Sen } from "./types/sens";
|
package/lib/loaders.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AmendementResult } from "./model/ameli";
|
|
2
|
+
import { DebatResult } from "./model/debats";
|
|
2
3
|
import { DossierLegislatifResult } from "./model/dosleg";
|
|
3
4
|
import { QuestionResult } from "./model/questions";
|
|
4
5
|
import { CirconscriptionResult, OrganismeResult, SenateurResult } from "./model/sens";
|
|
@@ -6,6 +7,7 @@ import { AgendaEvent } from "./types/agenda";
|
|
|
6
7
|
import { FlatTexte } from "./types/texte";
|
|
7
8
|
export { EnabledDatasets } from "./datasets";
|
|
8
9
|
export declare const AGENDA_FOLDER = "agenda";
|
|
10
|
+
export declare const COMPTES_RENDUS_FOLDER = "seances";
|
|
9
11
|
export declare const DOSLEG_DOSSIERS_FOLDER = "dossiers";
|
|
10
12
|
export declare const RAPPORT_FOLDER = "rap";
|
|
11
13
|
export declare const SENS_CIRCONSCRIPTIONS_FOLDER = "circonscriptions";
|
|
@@ -59,6 +61,7 @@ export interface DossierLegislatifDocumentResult {
|
|
|
59
61
|
}
|
|
60
62
|
export declare function iterFilePaths(dirPath: string): Generator<string>;
|
|
61
63
|
export declare function iterLoadSenatAmendements(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<AmendementResult>>;
|
|
64
|
+
export declare function iterLoadSenatDebats(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<DebatResult>>;
|
|
62
65
|
export declare function iterLoadSenatDossiersLegislatifs(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<DossierLegislatifResult>>;
|
|
63
66
|
export declare function iterLoadSenatDossiersLegislatifsRapportUrls(dataDir: string, session: number | undefined): Generator<IterItem<RapportMetadata>>;
|
|
64
67
|
export declare function iterLoadSenatDossiersLegislatifsTexteUrls(dataDir: string, session: number | undefined): Generator<IterItem<TexteMetadata>>;
|
|
@@ -69,5 +72,5 @@ export declare function loadSenatTexteContent(dataDir: string, textePathFromData
|
|
|
69
72
|
export declare function iterLoadSenatEvenements(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<AgendaEvent>>;
|
|
70
73
|
export declare function iterLoadSenatCirconscriptions(dataDir: string, options?: {}): Generator<IterItem<CirconscriptionResult>>;
|
|
71
74
|
export declare function iterLoadSenatOrganismes(dataDir: string, options?: {}): Generator<IterItem<OrganismeResult>>;
|
|
72
|
-
export declare function iterLoadSenatSenateurs(dataDir: string,
|
|
75
|
+
export declare function iterLoadSenatSenateurs(dataDir: string, options?: {}): Generator<IterItem<SenateurResult>>;
|
|
73
76
|
export declare function iterLoadSenatQuestions(dataDir: string, legislature: number, options?: {}): Generator<IterItem<QuestionResult>>;
|
package/lib/loaders.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import legislatures from "./legislatures.json";
|
|
4
3
|
import { datasets } from "./datasets";
|
|
5
4
|
import { UNDEFINED_SESSION } from "./types/sessions";
|
|
6
5
|
export { EnabledDatasets } from "./datasets";
|
|
7
6
|
export const AGENDA_FOLDER = "agenda";
|
|
7
|
+
export const COMPTES_RENDUS_FOLDER = "seances";
|
|
8
8
|
export const DOSLEG_DOSSIERS_FOLDER = "dossiers";
|
|
9
9
|
export const RAPPORT_FOLDER = "rap";
|
|
10
10
|
export const SENS_CIRCONSCRIPTIONS_FOLDER = "circonscriptions";
|
|
@@ -54,6 +54,11 @@ export function* iterLoadSenatAmendements(dataDir, session, options = {}) {
|
|
|
54
54
|
yield amendementItem;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
export function* iterLoadSenatDebats(dataDir, session, options = {}) {
|
|
58
|
+
for (const debatItem of iterLoadSenatItems(dataDir, datasets.debats.database, session, undefined, options)) {
|
|
59
|
+
yield debatItem;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
57
62
|
export function* iterLoadSenatDossiersLegislatifs(dataDir, session, options = {}) {
|
|
58
63
|
for (const dossierLegislatifItem of iterLoadSenatItems(dataDir, datasets.dosleg.database, session, DOSLEG_DOSSIERS_FOLDER, options)) {
|
|
59
64
|
yield dossierLegislatifItem;
|
|
@@ -156,17 +161,8 @@ export function* iterLoadSenatOrganismes(dataDir, options = {}) {
|
|
|
156
161
|
yield organismeItem;
|
|
157
162
|
}
|
|
158
163
|
}
|
|
159
|
-
export function* iterLoadSenatSenateurs(dataDir,
|
|
160
|
-
const dateDebutLegislatureStr = legislatures.find((legislatureInfo) => legislatureInfo.numero === legislature)?.date_debut;
|
|
161
|
-
const dateDebutLegislature = new Date(dateDebutLegislatureStr);
|
|
164
|
+
export function* iterLoadSenatSenateurs(dataDir, options = {}) {
|
|
162
165
|
for (const senateurItem of iterLoadSenatItems(dataDir, datasets.sens.database, undefined, SENS_SENATEURS_FOLDER, options)) {
|
|
163
|
-
const dateFinMandatSenateur = senateurItem.item.mandats_senateur[0]
|
|
164
|
-
?.date_fin
|
|
165
|
-
? new Date(senateurItem.item.mandats_senateur[0]?.date_fin)
|
|
166
|
-
: null;
|
|
167
|
-
if (dateFinMandatSenateur && dateFinMandatSenateur < dateDebutLegislature) {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
166
|
yield senateurItem;
|
|
171
167
|
}
|
|
172
168
|
}
|
package/lib/model/agenda.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JSDOM } from "jsdom";
|
|
2
2
|
import { DateTime } from "luxon";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import { ID_DATE_FORMAT, STANDARD_DATE_FORMAT } from "../scripts/datautil";
|
|
4
5
|
const FR_TZ = "Europe/Paris";
|
|
5
6
|
function getEventType(eventClasses) {
|
|
6
7
|
const typeClass = [...eventClasses]
|
|
@@ -67,7 +68,7 @@ function transformAgenda(document, fileName) {
|
|
|
67
68
|
continue;
|
|
68
69
|
}
|
|
69
70
|
const type = getEventType(eventElement.classList);
|
|
70
|
-
const date = DateTime.fromFormat(fileName,
|
|
71
|
+
const date = DateTime.fromFormat(fileName, ID_DATE_FORMAT).toFormat(STANDARD_DATE_FORMAT);
|
|
71
72
|
const timeOriginal = eventElement.querySelector(".time")?.textContent || null;
|
|
72
73
|
const { startTime, endTime } = getStartAndEndTimes(timeOriginal);
|
|
73
74
|
const titre = eventElement.querySelector(".titre")?.textContent?.trim() || null;
|
package/lib/model/ameli.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InferResult } from "kysely";
|
|
2
|
+
export type AmendementResult = InferResult<typeof findAllQuery>[0];
|
|
2
3
|
declare const findAllQuery: import("kysely").SelectQueryBuilder<{
|
|
3
|
-
sub: import("kysely").Nullable<import("../raw_types/ameli").Sub>;
|
|
4
|
-
amdsen: import("../raw_types/ameli").Amdsen;
|
|
5
4
|
amd: import("../raw_types/ameli").Amd;
|
|
5
|
+
amdsen: import("../raw_types/ameli").Amdsen;
|
|
6
6
|
avicom: import("kysely").Nullable<import("../raw_types/ameli").Avicom>;
|
|
7
7
|
avigvt: import("kysely").Nullable<import("../raw_types/ameli").Avigvt>;
|
|
8
8
|
cab: import("kysely").Nullable<import("../raw_types/ameli").Cab>;
|
|
@@ -24,12 +24,13 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<{
|
|
|
24
24
|
sen_ameli: import("../raw_types/ameli").SenAmeli;
|
|
25
25
|
ses: import("kysely").Nullable<import("../raw_types/ameli").Ses>;
|
|
26
26
|
sor: import("kysely").Nullable<import("../raw_types/ameli").Sor>;
|
|
27
|
+
sub: import("kysely").Nullable<import("../raw_types/ameli").Sub>;
|
|
27
28
|
txt_ameli: import("kysely").Nullable<import("../raw_types/ameli").TxtAmeli>;
|
|
28
29
|
typrect: import("../raw_types/ameli").Typrect;
|
|
29
30
|
typses: import("../raw_types/ameli").Typses;
|
|
30
31
|
typsub: import("kysely").Nullable<import("../raw_types/ameli").Typsub>;
|
|
31
32
|
w_nivrec: import("../raw_types/ameli").WNivrec;
|
|
32
|
-
}, "
|
|
33
|
+
}, "amd" | "avicom" | "avigvt" | "cab" | "com_ameli" | "grppol_ameli" | "irr" | "lec_ameli" | "nat" | "ses" | "sor" | "sub" | "txt_ameli" | "typsub", {
|
|
33
34
|
session: string | null;
|
|
34
35
|
signet_dossier_legislatif: string | null;
|
|
35
36
|
nature_texte: string | null;
|
|
@@ -58,14 +59,12 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<{
|
|
|
58
59
|
au_nom_de_groupe_politique: string | null;
|
|
59
60
|
au_nom_de_commission: string | null;
|
|
60
61
|
auteur_est_gouvernement: boolean;
|
|
61
|
-
} & {
|
|
62
62
|
auteurs: {
|
|
63
63
|
prenom: string | null;
|
|
64
64
|
nom: string | null;
|
|
65
65
|
matricule: string | null;
|
|
66
66
|
}[];
|
|
67
67
|
}>;
|
|
68
|
-
export type AmendementResult = InferResult<typeof findAllQuery>[0];
|
|
69
68
|
export declare function findAll(): AsyncIterableIterator<{
|
|
70
69
|
session: string | null;
|
|
71
70
|
signet_dossier_legislatif: string | null;
|
|
@@ -95,7 +94,6 @@ export declare function findAll(): AsyncIterableIterator<{
|
|
|
95
94
|
au_nom_de_groupe_politique: string | null;
|
|
96
95
|
au_nom_de_commission: string | null;
|
|
97
96
|
auteur_est_gouvernement: boolean;
|
|
98
|
-
} & {
|
|
99
97
|
auteurs: {
|
|
100
98
|
prenom: string | null;
|
|
101
99
|
nom: string | null;
|
package/lib/model/ameli.js
CHANGED
|
@@ -87,8 +87,8 @@ const findAllQuery = dbAmeli
|
|
|
87
87
|
.else(false)
|
|
88
88
|
.end()
|
|
89
89
|
.as("auteur_est_gouvernement"),
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
auteurs(ref("amd.id")).as("auteurs"),
|
|
91
|
+
]);
|
|
92
92
|
export function findAll() {
|
|
93
93
|
return findAllQuery.stream();
|
|
94
94
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { JSDOM } from "jsdom";
|
|
2
|
+
function transformCompteRendu(document, debat) {
|
|
3
|
+
const compteRendu = {
|
|
4
|
+
sections: [],
|
|
5
|
+
};
|
|
6
|
+
for (const section of debat.sections) {
|
|
7
|
+
const compteRenduSection = {
|
|
8
|
+
id: section.id,
|
|
9
|
+
interventions: [],
|
|
10
|
+
};
|
|
11
|
+
compteRendu.sections.push(compteRenduSection);
|
|
12
|
+
for (const sectionIntervention of section.interventions) {
|
|
13
|
+
const interventionAnchor = document.querySelector(`a[name="int${sectionIntervention.id}"]`);
|
|
14
|
+
const interventionParent = interventionAnchor?.parentElement;
|
|
15
|
+
compteRenduSection.interventions.push({
|
|
16
|
+
id: sectionIntervention.id,
|
|
17
|
+
texteHtml: interventionParent?.outerHTML || null,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return compteRendu;
|
|
22
|
+
}
|
|
23
|
+
export async function parseCompteRenduFromFile(htmlFilePath, debat) {
|
|
24
|
+
try {
|
|
25
|
+
const { document } = (await JSDOM.fromFile(htmlFilePath, { contentType: "text/html" })).window;
|
|
26
|
+
return transformCompteRendu(document, debat);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error(`Could not parse compte-rendu with error ${error}`);
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
package/lib/model/debats.d.ts
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { InferResult } from "kysely";
|
|
2
|
+
export type DebatResult = InferResult<typeof findAllQuery>[0];
|
|
3
|
+
declare const findAllQuery: import("kysely").SelectQueryBuilder<import("../raw_types/debats").DB, "debats", {
|
|
4
|
+
id: string;
|
|
5
|
+
date_seance: string;
|
|
6
|
+
numero: string | null;
|
|
7
|
+
url: string | null;
|
|
8
|
+
etat_synchronisation: string | null;
|
|
9
|
+
sections: {
|
|
10
|
+
id: string | null;
|
|
11
|
+
numero: string | null;
|
|
12
|
+
objet: string | null;
|
|
13
|
+
url: string | null;
|
|
14
|
+
type: string | null;
|
|
15
|
+
categorie: string | null;
|
|
16
|
+
interventions: {
|
|
17
|
+
id: string | null;
|
|
18
|
+
auteur_code: string;
|
|
19
|
+
fonction_intervenant: string | null;
|
|
20
|
+
url: string | null;
|
|
21
|
+
analyse: string | null;
|
|
22
|
+
}[];
|
|
23
|
+
lecture_id: string;
|
|
24
|
+
}[];
|
|
25
|
+
sections_divers: {
|
|
26
|
+
type: string | null;
|
|
27
|
+
categorie: string | null;
|
|
28
|
+
libelle: string | null;
|
|
29
|
+
objet: string | null;
|
|
30
|
+
interventions: {
|
|
31
|
+
id: string | null;
|
|
32
|
+
auteur_code: string;
|
|
33
|
+
fonction_intervenant: string | null;
|
|
34
|
+
url: string | null;
|
|
35
|
+
analyse: string | null;
|
|
36
|
+
}[];
|
|
37
|
+
}[];
|
|
38
|
+
lectures: {
|
|
39
|
+
id: string;
|
|
40
|
+
}[];
|
|
41
|
+
}>;
|
|
42
|
+
export declare function findAll(): AsyncIterableIterator<{
|
|
43
|
+
id: string;
|
|
44
|
+
date_seance: string;
|
|
45
|
+
numero: string | null;
|
|
46
|
+
url: string | null;
|
|
47
|
+
etat_synchronisation: string | null;
|
|
48
|
+
sections: {
|
|
49
|
+
id: string | null;
|
|
50
|
+
numero: string | null;
|
|
51
|
+
objet: string | null;
|
|
52
|
+
url: string | null;
|
|
53
|
+
type: string | null;
|
|
54
|
+
categorie: string | null;
|
|
55
|
+
interventions: {
|
|
56
|
+
id: string | null;
|
|
57
|
+
auteur_code: string;
|
|
58
|
+
fonction_intervenant: string | null;
|
|
59
|
+
url: string | null;
|
|
60
|
+
analyse: string | null;
|
|
61
|
+
}[];
|
|
62
|
+
lecture_id: string;
|
|
63
|
+
}[];
|
|
64
|
+
sections_divers: {
|
|
65
|
+
type: string | null;
|
|
66
|
+
categorie: string | null;
|
|
67
|
+
libelle: string | null;
|
|
68
|
+
objet: string | null;
|
|
69
|
+
interventions: {
|
|
70
|
+
id: string | null;
|
|
71
|
+
auteur_code: string;
|
|
72
|
+
fonction_intervenant: string | null;
|
|
73
|
+
url: string | null;
|
|
74
|
+
analyse: string | null;
|
|
75
|
+
}[];
|
|
76
|
+
}[];
|
|
77
|
+
lectures: {
|
|
78
|
+
id: string;
|
|
79
|
+
}[];
|
|
80
|
+
}>;
|
|
81
|
+
export {};
|
package/lib/model/debats.js
CHANGED
|
@@ -1 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsonArrayFrom } from "kysely/helpers/postgres";
|
|
2
|
+
import { dbDebats } from "../databases";
|
|
3
|
+
import { ID_DATE_FORMAT } from "../scripts/datautil";
|
|
4
|
+
import { toDateString } from "./util";
|
|
5
|
+
function sectionsLegislatives(dateSeance) {
|
|
6
|
+
return jsonArrayFrom(dbDebats
|
|
7
|
+
.selectFrom("secdis")
|
|
8
|
+
.leftJoin("typsec", "secdis.typseccod", "typsec.typseccod")
|
|
9
|
+
.where("secdis.datsea", "=", dateSeance)
|
|
10
|
+
.select(({ ref }) => [
|
|
11
|
+
"secdis.secdisordid as id",
|
|
12
|
+
"secdis.secdisnum as numero",
|
|
13
|
+
"secdis.secdisobj as objet",
|
|
14
|
+
"secdis.secdisurl as url",
|
|
15
|
+
"typsec.typseclib as type",
|
|
16
|
+
"typsec.typseccat as categorie",
|
|
17
|
+
interventionsLegislatives(ref("secdis.secdiscle")).as("interventions"),
|
|
18
|
+
"secdis.lecassidt as lecture_id"
|
|
19
|
+
])
|
|
20
|
+
.orderBy("secdis.secdisordid asc"));
|
|
21
|
+
}
|
|
22
|
+
function interventionsLegislatives(sectionId) {
|
|
23
|
+
return jsonArrayFrom(dbDebats
|
|
24
|
+
.selectFrom("intpjl")
|
|
25
|
+
.where("intpjl.secdiscle", "=", sectionId)
|
|
26
|
+
.select(({ ref, val }) => [
|
|
27
|
+
"intpjl.intordid as id",
|
|
28
|
+
"intpjl.autcod as auteur_code",
|
|
29
|
+
"intpjl.intfon as fonction_intervenant",
|
|
30
|
+
"intpjl.inturl as url",
|
|
31
|
+
"intpjl.intana as analyse",
|
|
32
|
+
])
|
|
33
|
+
.orderBy("intpjl.intordid asc"));
|
|
34
|
+
}
|
|
35
|
+
function sectionsNonLegislatives(dateSeance) {
|
|
36
|
+
return jsonArrayFrom(dbDebats
|
|
37
|
+
.selectFrom("secdivers")
|
|
38
|
+
.leftJoin("typsec", "secdivers.typseccod", "typsec.typseccod")
|
|
39
|
+
.where("secdivers.datsea", "=", dateSeance)
|
|
40
|
+
.select(({ ref }) => [
|
|
41
|
+
"secdivers.secdiverslibelle as libelle",
|
|
42
|
+
"secdivers.secdiversobj as objet",
|
|
43
|
+
"typsec.typseclib as type",
|
|
44
|
+
"typsec.typseccat as categorie",
|
|
45
|
+
interventionsNonLegislatives(ref("secdivers.secdiverscle")).as("interventions"),
|
|
46
|
+
]));
|
|
47
|
+
}
|
|
48
|
+
function interventionsNonLegislatives(sectionId) {
|
|
49
|
+
return jsonArrayFrom(dbDebats
|
|
50
|
+
.selectFrom("intdivers")
|
|
51
|
+
.where("intdivers.intdiverscle", "=", sectionId)
|
|
52
|
+
.select(({ ref, val }) => [
|
|
53
|
+
"intdivers.intdiversordid as id",
|
|
54
|
+
"intdivers.autcod as auteur_code",
|
|
55
|
+
"intdivers.intfon as fonction_intervenant",
|
|
56
|
+
"intdivers.inturl as url",
|
|
57
|
+
"intdivers.intana as analyse",
|
|
58
|
+
])
|
|
59
|
+
.orderBy("intdivers.intdiversordid asc"));
|
|
60
|
+
}
|
|
61
|
+
function lecturesAssemblee(dateSeance) {
|
|
62
|
+
return jsonArrayFrom(dbDebats
|
|
63
|
+
.selectFrom("lecassdeb")
|
|
64
|
+
.where("lecassdeb.datsea", "=", dateSeance)
|
|
65
|
+
.select("lecassdeb.lecassidt as id"));
|
|
66
|
+
}
|
|
67
|
+
const findAllQuery = dbDebats
|
|
68
|
+
.selectFrom("debats")
|
|
69
|
+
.select(({ ref, val }) => [
|
|
70
|
+
toDateString(ref("debats.datsea"), val(ID_DATE_FORMAT)).as("id"),
|
|
71
|
+
toDateString(ref("debats.datsea")).as("date_seance"),
|
|
72
|
+
"debats.numero as numero",
|
|
73
|
+
"debats.deburl as url",
|
|
74
|
+
"debats.debsyn as etat_synchronisation",
|
|
75
|
+
sectionsLegislatives(ref("debats.datsea")).as("sections"),
|
|
76
|
+
sectionsNonLegislatives(ref("debats.datsea")).as("sections_divers"),
|
|
77
|
+
lecturesAssemblee(ref("debats.datsea")).as("lectures"),
|
|
78
|
+
]);
|
|
79
|
+
export function findAll() {
|
|
80
|
+
return findAllQuery.stream();
|
|
81
|
+
}
|
package/lib/model/dosleg.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { InferResult } from "kysely";
|
|
2
|
+
export type DossierLegislatifResult = InferResult<typeof findAllQuery>[0];
|
|
3
|
+
export type AuteurResult = InferResult<typeof findAuteursQuery>[0];
|
|
2
4
|
declare const findAllQuery: import("kysely").SelectQueryBuilder<{
|
|
3
5
|
ses: import("../raw_types/dosleg").Ses;
|
|
4
6
|
qua: import("../raw_types/dosleg").Qua;
|
|
5
7
|
lecture: import("../raw_types/dosleg").Lecture;
|
|
6
|
-
|
|
8
|
+
loi: import("../raw_types/dosleg").Loi;
|
|
7
9
|
amescr: import("../raw_types/dosleg").Amescr;
|
|
8
10
|
ass: import("../raw_types/dosleg").Ass;
|
|
9
11
|
aud: import("../raw_types/dosleg").Aud;
|
|
@@ -13,6 +15,7 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<{
|
|
|
13
15
|
catrap: import("../raw_types/dosleg").Catrap;
|
|
14
16
|
com: import("../raw_types/dosleg").Com;
|
|
15
17
|
corscr: import("../raw_types/dosleg").Corscr;
|
|
18
|
+
date_seance: import("../raw_types/dosleg").DateSeance;
|
|
16
19
|
deccoc: import("../raw_types/dosleg").Deccoc;
|
|
17
20
|
delega: import("../raw_types/dosleg").Delega;
|
|
18
21
|
denrap: import("../raw_types/dosleg").Denrap;
|
|
@@ -44,7 +47,6 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<{
|
|
|
44
47
|
libdelega: import("../raw_types/dosleg").Libdelega;
|
|
45
48
|
libgrppol: import("../raw_types/dosleg").Libgrppol;
|
|
46
49
|
lnkrap: import("../raw_types/dosleg").Lnkrap;
|
|
47
|
-
loi: import("../raw_types/dosleg").Loi;
|
|
48
50
|
loithe: import("../raw_types/dosleg").Loithe;
|
|
49
51
|
memcom: import("../raw_types/dosleg").Memcom;
|
|
50
52
|
memdelega: import("../raw_types/dosleg").Memdelega;
|
|
@@ -82,7 +84,7 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<{
|
|
|
82
84
|
typtxt: import("../raw_types/dosleg").Typtxt;
|
|
83
85
|
typurl: import("../raw_types/dosleg").Typurl;
|
|
84
86
|
votsen: import("../raw_types/dosleg").Votsen;
|
|
85
|
-
}, "
|
|
87
|
+
}, "loi" | "etaloi" | "typloi", {
|
|
86
88
|
url: string;
|
|
87
89
|
signet: string;
|
|
88
90
|
titre: string;
|
|
@@ -107,30 +109,30 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<{
|
|
|
107
109
|
session: string | null;
|
|
108
110
|
textes: {
|
|
109
111
|
url: string;
|
|
110
|
-
|
|
112
|
+
numero: string | null;
|
|
111
113
|
id: string | null;
|
|
114
|
+
origine: string;
|
|
112
115
|
type: string;
|
|
116
|
+
date: string;
|
|
113
117
|
session: string | null;
|
|
114
118
|
auteurs: {
|
|
115
119
|
prenom: string | null;
|
|
116
120
|
nom_usuel: string;
|
|
117
121
|
matricule: string | null;
|
|
118
122
|
}[];
|
|
119
|
-
numero: string | null;
|
|
120
|
-
origine: string;
|
|
121
123
|
}[];
|
|
122
124
|
rapports: {
|
|
123
125
|
url: string;
|
|
124
|
-
date: string;
|
|
125
|
-
numero: string | null;
|
|
126
126
|
id: string | null;
|
|
127
127
|
type: string;
|
|
128
|
+
date: string;
|
|
128
129
|
session: string;
|
|
129
130
|
auteurs: {
|
|
130
131
|
prenom: string | null;
|
|
131
132
|
nom_usuel: string;
|
|
132
133
|
matricule: string | null;
|
|
133
134
|
}[];
|
|
135
|
+
numero: string | null;
|
|
134
136
|
}[];
|
|
135
137
|
dates_seances: {
|
|
136
138
|
date: string;
|
|
@@ -173,30 +175,30 @@ export declare function findAll(): AsyncIterableIterator<{
|
|
|
173
175
|
session: string | null;
|
|
174
176
|
textes: {
|
|
175
177
|
url: string;
|
|
176
|
-
|
|
178
|
+
numero: string | null;
|
|
177
179
|
id: string | null;
|
|
180
|
+
origine: string;
|
|
178
181
|
type: string;
|
|
182
|
+
date: string;
|
|
179
183
|
session: string | null;
|
|
180
184
|
auteurs: {
|
|
181
185
|
prenom: string | null;
|
|
182
186
|
nom_usuel: string;
|
|
183
187
|
matricule: string | null;
|
|
184
188
|
}[];
|
|
185
|
-
numero: string | null;
|
|
186
|
-
origine: string;
|
|
187
189
|
}[];
|
|
188
190
|
rapports: {
|
|
189
191
|
url: string;
|
|
190
|
-
date: string;
|
|
191
|
-
numero: string | null;
|
|
192
192
|
id: string | null;
|
|
193
193
|
type: string;
|
|
194
|
+
date: string;
|
|
194
195
|
session: string;
|
|
195
196
|
auteurs: {
|
|
196
197
|
prenom: string | null;
|
|
197
198
|
nom_usuel: string;
|
|
198
199
|
matricule: string | null;
|
|
199
200
|
}[];
|
|
201
|
+
numero: string | null;
|
|
200
202
|
}[];
|
|
201
203
|
dates_seances: {
|
|
202
204
|
date: string;
|
|
@@ -223,5 +225,16 @@ export declare function findSenatRapportUrls(sessions?: number[]): AsyncIterable
|
|
|
223
225
|
url: string;
|
|
224
226
|
session: string | null | undefined;
|
|
225
227
|
}>;
|
|
226
|
-
|
|
228
|
+
declare const findAuteursQuery: import("kysely").SelectQueryBuilder<import("../raw_types/dosleg").DB, "auteur", {
|
|
229
|
+
code: string;
|
|
230
|
+
nom: string;
|
|
231
|
+
prenom: string | null;
|
|
232
|
+
matricule: string | null;
|
|
233
|
+
}>;
|
|
234
|
+
export declare function findAuteur(auteurCode: string): Promise<{
|
|
235
|
+
code: string;
|
|
236
|
+
nom: string;
|
|
237
|
+
prenom: string | null;
|
|
238
|
+
matricule: string | null;
|
|
239
|
+
} | undefined>;
|
|
227
240
|
export {};
|
package/lib/model/dosleg.js
CHANGED
|
@@ -131,7 +131,9 @@ function themes(loiId) {
|
|
|
131
131
|
.selectFrom("the")
|
|
132
132
|
.leftJoin("loithe", "loithe.thecle", "the.thecle")
|
|
133
133
|
.where("loithe.loicod", "=", loiId)
|
|
134
|
-
.select([
|
|
134
|
+
.select([
|
|
135
|
+
"the.thelib as libelle",
|
|
136
|
+
]));
|
|
135
137
|
}
|
|
136
138
|
const findAllQuery = dbDosleg
|
|
137
139
|
.selectFrom("loi")
|
|
@@ -198,7 +200,23 @@ export function findSenatRapportUrls(sessions = []) {
|
|
|
198
200
|
.where("rapurl", "is not", null)
|
|
199
201
|
.where("typurl", "=", "I")
|
|
200
202
|
.$if(sessions.length > 0, (qb) => qb.where("sesann", "in", sessionsStr))
|
|
201
|
-
.select(({ ref }) => [
|
|
203
|
+
.select(({ ref }) => [
|
|
204
|
+
"sesann as session",
|
|
205
|
+
rtrim(ref("rapurl")).as("url"),
|
|
206
|
+
])
|
|
202
207
|
.$narrowType()
|
|
203
208
|
.stream();
|
|
204
209
|
}
|
|
210
|
+
const findAuteursQuery = dbDosleg
|
|
211
|
+
.selectFrom("auteur")
|
|
212
|
+
.select([
|
|
213
|
+
"autcod as code",
|
|
214
|
+
"nomuse as nom",
|
|
215
|
+
"prenom as prenom",
|
|
216
|
+
"autmat as matricule",
|
|
217
|
+
]);
|
|
218
|
+
export async function findAuteur(auteurCode) {
|
|
219
|
+
return findAuteursQuery
|
|
220
|
+
.where("autcod", "=", auteurCode)
|
|
221
|
+
.executeTakeFirst();
|
|
222
|
+
}
|
package/lib/model/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { findAll as findAllAmendements } from "./ameli";
|
|
2
|
-
export { findAll as
|
|
2
|
+
export { findAll as findAllDebats } from "./debats";
|
|
3
|
+
export { findAll as findAllLois, findAuteur, findSenatRapportUrls, findSenatTexteUrls, } from "./dosleg";
|
|
3
4
|
export { findAll as findAllQuestions } from "./questions";
|
|
4
5
|
export { findAll as findAllSens, findAllCirconscriptions, findAllOrganismes, } from "./sens";
|
package/lib/model/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { findAll as findAllAmendements } from "./ameli";
|
|
2
|
-
export { findAll as
|
|
2
|
+
export { findAll as findAllDebats } from "./debats";
|
|
3
|
+
export { findAll as findAllLois, findAuteur, findSenatRapportUrls, findSenatTexteUrls, } from "./dosleg";
|
|
3
4
|
export { findAll as findAllQuestions } from "./questions";
|
|
4
5
|
export { findAll as findAllSens, findAllCirconscriptions, findAllOrganismes, } from "./sens";
|