@tricoteuses/senat 2.20.34 → 2.20.35

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/lib/config.d.ts CHANGED
@@ -1,3 +1,21 @@
1
1
  import "dotenv/config";
2
- declare const validConfig: any;
3
- export default validConfig;
2
+ import { z } from "zod";
3
+ export declare const configSchema: z.ZodObject<{
4
+ db: z.ZodObject<{
5
+ host: z.ZodString;
6
+ name: z.ZodString;
7
+ password: z.ZodString;
8
+ port: z.ZodCoercedNumber<unknown>;
9
+ user: z.ZodString;
10
+ }, z.core.$strip>;
11
+ }, z.core.$strip>;
12
+ declare const _default: {
13
+ db: {
14
+ host: string;
15
+ name: string;
16
+ password: string;
17
+ port: number;
18
+ user: string;
19
+ };
20
+ };
21
+ export default _default;
package/lib/config.js CHANGED
@@ -1,16 +1,27 @@
1
1
  import "dotenv/config";
2
- import { validateConfig } from "./validators/config";
2
+ import { z } from "zod";
3
+ const dbSchema = z.object({
4
+ host: z.string().trim().min(1, "Must not be empty"),
5
+ name: z.string().trim().min(1, "Must not be empty"),
6
+ password: z.string().trim().min(1, "Must not be empty"),
7
+ port: z.coerce.number().int().min(0).max(65535),
8
+ user: z.string().trim().min(1, "Must not be empty"),
9
+ });
10
+ export const configSchema = z.object({
11
+ db: dbSchema,
12
+ });
3
13
  const config = {
4
14
  db: {
5
15
  host: process.env["TRICOTEUSES_SENAT_DB_HOST"] || "localhost",
16
+ name: process.env["TRICOTEUSES_SENAT_DB_NAME"] || "postgres",
6
17
  password: process.env["TRICOTEUSES_SENAT_DB_PASSWORD"] || "opendata",
7
18
  port: process.env["TRICOTEUSES_SENAT_DB_PORT"] || 5432,
8
19
  user: process.env["TRICOTEUSES_SENAT_DB_USER"] || "opendata",
9
20
  },
10
21
  };
11
- const [validConfig, error] = validateConfig(config);
12
- if (error !== null) {
13
- console.error(`Error in configuration:\n${JSON.stringify(validConfig, null, 2)}\nError:\n${JSON.stringify(error, null, 2)}`);
22
+ const result = configSchema.safeParse(config);
23
+ if (!result.success) {
24
+ console.error(`Error in configuration:\n${JSON.stringify(config, null, 2)}\nError:\n${JSON.stringify(result.error.issues, null, 2)}`);
14
25
  process.exit(-1);
15
26
  }
16
- export default validConfig;
27
+ export default result.data;
package/lib/loaders.d.ts CHANGED
@@ -5,9 +5,11 @@ import { QuestionResult } from "./model/questions";
5
5
  import { ScrutinResult } from "./model/scrutins";
6
6
  import { CirconscriptionResult, OrganismeResult, SenateurResult } from "./model/sens";
7
7
  import { Reunion } from "./types/agenda";
8
- import { FlatTexte } from "./types/texte";
8
+ import { FlatTexte, DocumentMetadata } from "./types/texte";
9
9
  import { CompteRendu } from "./types/compte_rendu";
10
+ import { DocumentResult } from "./model/documents";
10
11
  export { EnabledDatasets } from "./datasets";
12
+ export type { DocumentResult } from "./model/documents";
11
13
  export declare const AGENDA_FOLDER = "agenda";
12
14
  export declare const COMPTES_RENDUS_FOLDER = "seances";
13
15
  export declare const COMMISSION_FOLDER = "commissions";
@@ -27,46 +29,6 @@ export type IterItem<T> = {
27
29
  legislature?: number;
28
30
  gitStatus?: "A" | "M" | "D" | "R" | "C" | "T" | "U";
29
31
  };
30
- export interface TexteMetadata {
31
- name: string;
32
- session: number | null | undefined;
33
- date?: string | null;
34
- url_expose_des_motifs?: URL;
35
- url_xml: URL;
36
- url_html: URL;
37
- url_pdf: URL;
38
- }
39
- export interface RapportMetadata {
40
- name: string;
41
- session: number | null | undefined;
42
- date?: string | null;
43
- url_html: URL;
44
- url_pdf: URL;
45
- }
46
- export interface DossierLegislatifDocumentResult {
47
- signet_dossier: string;
48
- url_dossier_senat: string;
49
- url_dossier_assemblee_nationale: string | null;
50
- type_lecture: string;
51
- libelle_lecture: string;
52
- libelle_organisme: string | null;
53
- code_organisme: string | null;
54
- numero: number | null;
55
- id: string | null;
56
- url: string;
57
- origine?: string | null | undefined;
58
- type: string;
59
- date: string;
60
- session: number | null;
61
- auteurs: {
62
- prenom: string | null;
63
- nom_usuel: string;
64
- matricule: string | null;
65
- }[];
66
- organismes?: {
67
- libelle: string;
68
- }[] | undefined;
69
- }
70
32
  export declare function iterFilePaths(dirPath: string): Generator<string>;
71
33
  export declare function iterLoadSenatAmendements(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<AmendementResult>>;
72
34
  export declare function iterLoadSenatDebats(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<DebatResult>>;
@@ -79,11 +41,11 @@ export declare function iterLoadSenatComptesRendusCommissions(dataDir: string, s
79
41
  session: number;
80
42
  }>;
81
43
  export declare function iterLoadSenatDossiersLegislatifs(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<DossierLegislatifResult>>;
82
- export declare function iterLoadSenatDossiersLegislatifsRapportUrls(dataDir: string, session: number | undefined): Generator<IterItem<RapportMetadata>>;
83
- export declare function iterLoadSenatDossiersLegislatifsTexteUrls(dataDir: string, session: number | undefined): Generator<IterItem<TexteMetadata>>;
84
- export declare function iterLoadSenatDossiersLegislatifsDocuments(dataDir: string, session: number | undefined, documentType: "textes" | "rapports", options?: {}): Generator<IterItem<DossierLegislatifDocumentResult>>;
85
- export declare function iterLoadSenatDossiersLegislatifsRapports(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<DossierLegislatifDocumentResult>>;
86
- export declare function iterLoadSenatDossiersLegislatifsTextes(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<DossierLegislatifDocumentResult>>;
44
+ export declare function iterLoadSenatRapportUrls(dataDir: string, session: number | undefined): Generator<IterItem<DocumentMetadata>>;
45
+ export declare function iterLoadSenatTexteUrls(dataDir: string, session: number | undefined): Generator<IterItem<DocumentMetadata>>;
46
+ export declare function iterLoadSenatDocuments(dataDir: string, session: number | undefined, documentType: "textes" | "rapports", options?: {}): Generator<IterItem<DocumentResult>>;
47
+ export declare function iterLoadSenatRapports(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<DocumentResult>>;
48
+ export declare function iterLoadSenatTextes(dataDir: string, session: number | undefined, options?: {}): Generator<IterItem<DocumentResult>>;
87
49
  export declare function loadSenatTexteContent(dataDir: string, textePathFromDataset: string): IterItem<FlatTexte | null>;
88
50
  export declare function loadSenatCompteRenduContent(dataDir: string, session: number, debatId: string | number): {
89
51
  item: CompteRendu | null;
package/lib/loaders.js CHANGED
@@ -50,6 +50,9 @@ function* iterLoadSenatItems(dataDir, dataName, legislatureOrSession, subDir, {
50
50
  console.log(`Found ${changedFiles?.size || 0} changed files (AMR)`);
51
51
  }
52
52
  for (const filePath of iterFilePaths(itemsDir)) {
53
+ if (!filePath.endsWith(".json")) {
54
+ continue;
55
+ }
53
56
  const relativePath = path.relative(path.join(dataDir, dataName), filePath);
54
57
  const gitStatus = changedFiles?.get(relativePath);
55
58
  // Filter by changed files if sinceCommit is specified
@@ -147,7 +150,7 @@ export function* iterLoadSenatDossiersLegislatifs(dataDir, session, options = {}
147
150
  yield dossierLegislatifItem;
148
151
  }
149
152
  }
150
- export function* iterLoadSenatDossiersLegislatifsRapportUrls(dataDir, session) {
153
+ export function* iterLoadSenatRapportUrls(dataDir, session) {
151
154
  let itemsDir = path.join(dataDir, RAPPORT_FOLDER, DATA_ORIGINAL_FOLDER);
152
155
  if (session) {
153
156
  itemsDir = path.join(itemsDir, session.toString());
@@ -163,7 +166,7 @@ export function* iterLoadSenatDossiersLegislatifsRapportUrls(dataDir, session) {
163
166
  }
164
167
  }
165
168
  }
166
- export function* iterLoadSenatDossiersLegislatifsTexteUrls(dataDir, session) {
169
+ export function* iterLoadSenatTexteUrls(dataDir, session) {
167
170
  let itemsDir = path.join(dataDir, TEXTE_FOLDER, DATA_ORIGINAL_FOLDER);
168
171
  if (session) {
169
172
  itemsDir = path.join(itemsDir, session.toString());
@@ -179,7 +182,7 @@ export function* iterLoadSenatDossiersLegislatifsTexteUrls(dataDir, session) {
179
182
  }
180
183
  }
181
184
  }
182
- export function* iterLoadSenatDossiersLegislatifsDocuments(dataDir, session, documentType, options = {}) {
185
+ export function* iterLoadSenatDocuments(dataDir, session, documentType, options = {}) {
183
186
  for (const { item: dossierLegislatif } of iterLoadSenatDossiersLegislatifs(dataDir, session, options)) {
184
187
  for (const lecture of dossierLegislatif["lectures"]) {
185
188
  const lecturesSenat = lecture.lectures_assemblee.filter((lectureAssemblee) => lectureAssemblee.assemblee === "Sénat");
@@ -187,11 +190,6 @@ export function* iterLoadSenatDossiersLegislatifsDocuments(dataDir, session, doc
187
190
  for (const document of lectureSenat[documentType]) {
188
191
  const enrichedDocument = {
189
192
  signet_dossier: dossierLegislatif["signet"],
190
- url_dossier_senat: dossierLegislatif["url"],
191
- url_dossier_assemblee_nationale: dossierLegislatif["url_dossier_assemblee_nationale"],
192
- type_lecture: lecture.type_lecture,
193
- libelle_lecture: lecture.libelle,
194
- libelle_organisme: lectureSenat.libelle_organisme,
195
193
  ...document,
196
194
  };
197
195
  const documentItem = {
@@ -207,13 +205,15 @@ export function* iterLoadSenatDossiersLegislatifsDocuments(dataDir, session, doc
207
205
  }
208
206
  }
209
207
  }
210
- export function* iterLoadSenatDossiersLegislatifsRapports(dataDir, session, options = {}) {
211
- for (const iterItem of iterLoadSenatDossiersLegislatifsDocuments(dataDir, session, "rapports", options)) {
212
- yield iterItem;
208
+ export function* iterLoadSenatRapports(dataDir, session, options = {}) {
209
+ for (const iterItem of iterLoadSenatItems(dataDir, RAPPORT_FOLDER, session, "original", options)) {
210
+ if (iterItem.item?.["id"]) {
211
+ yield iterItem;
212
+ }
213
213
  }
214
214
  }
215
- export function* iterLoadSenatDossiersLegislatifsTextes(dataDir, session, options = {}) {
216
- for (const iterItem of iterLoadSenatDossiersLegislatifsDocuments(dataDir, session, "textes", options)) {
215
+ export function* iterLoadSenatTextes(dataDir, session, options = {}) {
216
+ for (const iterItem of iterLoadSenatDocuments(dataDir, session, "textes", options)) {
217
217
  yield iterItem;
218
218
  }
219
219
  }
@@ -47,9 +47,7 @@ const findAllAmendementsQuery = dbSenat
47
47
  .leftJoin("ameli.typses", "ameli.typses.id", "ameli.ses.typid")
48
48
  .leftJoin("ameli.nat", "ameli.txt_ameli.natid", "ameli.nat.id")
49
49
  .leftJoin("ameli.lec_ameli", "ameli.txt_ameli.lecid", "ameli.lec_ameli.id")
50
- .leftJoin("dosleg.texte", (join) => join
51
- .onRef("ameli.ses.ann", "=", "dosleg.texte.sesann")
52
- .onRef("ameli.txt_ameli.numabs", "=", "dosleg.texte.texnum"))
50
+ .leftJoin("dosleg.texte", (join) => join.onRef("ameli.ses.ann", "=", "dosleg.texte.sesann").onRef("ameli.txt_ameli.numabs", "=", "dosleg.texte.texnum"))
53
51
  .leftJoin("dosleg.lecass", "dosleg.texte.lecassidt", "dosleg.lecass.lecassidt")
54
52
  .leftJoin("ameli.mot", "ameli.amd.motid", "ameli.mot.id")
55
53
  .leftJoin("ameli.avicom", "ameli.amd.avcid", "ameli.avicom.id")
@@ -1,2 +1,12 @@
1
- export declare function findSenatTexteUrls(sessions?: number[]): any;
2
- export declare function findSenatRapportUrls(sessions?: number[]): any;
1
+ import { Expression, InferResult, SelectQueryBuilder } from "kysely";
2
+ export declare function rapports(lectureAssembleeId: Expression<string>): import("kysely").RawBuilder<{
3
+ [x: string]: any;
4
+ }[]>;
5
+ declare const queryTextes: SelectQueryBuilder<any, any, any>;
6
+ export declare function textes(lectureAssembleeId: Expression<string>): import("kysely").RawBuilder<{
7
+ [x: string]: any;
8
+ }[]>;
9
+ export declare function findAllTextes(): AsyncIterableIterator<DocumentResult>;
10
+ export declare function findAllRapports(): AsyncIterableIterator<DocumentResult>;
11
+ export type DocumentResult = InferResult<typeof queryTextes>[0];
12
+ export {};
@@ -1,33 +1,138 @@
1
+ import { sql } from "kysely";
1
2
  import { dbSenat } from "../databases";
2
- import { rtrim, toDateString } from "./util";
3
- export function findSenatTexteUrls(sessions = []) {
4
- return dbSenat
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
5
10
  .withSchema("dosleg")
6
- .selectFrom("texte")
7
- .where("texurl", "is not", null)
8
- .where("typurl", "=", "I")
9
- .$if(sessions.length > 0, (qb) => qb.where("sesann", "in", sessions))
10
- .select(({ eb, ref }) => [
11
- "sesann as session",
12
- rtrim(ref("texurl")).as("url"),
13
- toDateString(ref("txtoritxtdat")).as("date"),
14
- eb.case().when("oritxtcod", "=", "1").then(true).else(false).end().as("hasExposeDesMotifs"),
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",
15
22
  ])
16
- .$narrowType()
17
- .stream();
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));
18
73
  }
19
- export function findSenatRapportUrls(sessions = []) {
20
- return dbSenat
74
+ function auteursTexte(texteId) {
75
+ return jsonArrayFrom(dbSenat
21
76
  .withSchema("dosleg")
22
- .selectFrom("rap")
23
- .where("rapurl", "is not", null)
24
- .where("typurl", "=", "I")
25
- .$if(sessions.length > 0, (qb) => qb.where("sesann", "in", sessions))
26
- .select(({ ref }) => [
27
- "sesann as session",
28
- rtrim(ref("rapurl")).as("url"),
29
- toDateString(ref("date_depot")).as("date"),
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",
30
88
  ])
31
- .$narrowType()
32
- .stream();
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();
33
138
  }
@@ -1,10 +1,8 @@
1
1
  import { sql } from "kysely";
2
2
  import { jsonArrayFrom } from "kysely/helpers/postgres";
3
3
  import { dbSenat } 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
- }
4
+ import { concat, rtrim, toDateString } from "./util";
5
+ import { textes, rapports } from "./documents";
8
6
  function datesSeances(lectureAssembleeId) {
9
7
  return jsonArrayFrom(dbSenat
10
8
  .withSchema("dosleg")
@@ -12,120 +10,6 @@ function datesSeances(lectureAssembleeId) {
12
10
  .where("dosleg.date_seance.lecidt", "=", lectureAssembleeId)
13
11
  .select(({ ref }) => [toDateString(ref("dosleg.date_seance.date_s")).as("date")]));
14
12
  }
15
- function auteursRapport(rapportId) {
16
- return jsonArrayFrom(dbSenat
17
- .withSchema("dosleg")
18
- .selectFrom("dosleg.auteur")
19
- .leftJoin("dosleg.ecr", "dosleg.ecr.autcod", "dosleg.auteur.autcod")
20
- .leftJoin("dosleg.rolsig", "dosleg.rolsig.signataire", "dosleg.ecr.signataire")
21
- .where("dosleg.ecr.rapcod", "=", rapportId)
22
- .select([
23
- "dosleg.auteur.prenom as prenom",
24
- "dosleg.auteur.nomuse as nom_usuel",
25
- "dosleg.auteur.autmat as matricule",
26
- "dosleg.ecr.ecrnumtri as ordre",
27
- "dosleg.rolsig.rolsiglib as role",
28
- "dosleg.ecr.ecrqua as qualite",
29
- ])
30
- .orderBy("dosleg.ecr.ecrnumtri", "asc"));
31
- }
32
- function documentsAttaches(rapportId) {
33
- return jsonArrayFrom(dbSenat
34
- .withSchema("dosleg")
35
- .selectFrom("docatt")
36
- .leftJoin("typatt", "docatt.typattcod", "typatt.typattcod")
37
- .where("docatt.rapcod", "=", rapportId)
38
- .select([
39
- "docatt.docatturl as url",
40
- "typatt.typattlib as type_document"
41
- ]));
42
- }
43
- function rapports(lectureAssembleeId) {
44
- return jsonArrayFrom(dbSenat
45
- .withSchema("dosleg")
46
- .selectFrom("rap")
47
- .leftJoin("lecassrap", "lecassrap.rapcod", "rap.rapcod")
48
- .leftJoin("raporg", "raporg.rapcod", "rap.rapcod")
49
- .leftJoin("denrap", "denrap.coddenrap", "rap.coddenrap")
50
- .where("lecassrap.lecassidt", "=", lectureAssembleeId)
51
- .select(({ eb, ref, val }) => [
52
- "rap.rapnum as numero",
53
- "raporg.orgcod as code_organisme",
54
- eb
55
- .case()
56
- .when("rap.typurl", "=", "I")
57
- .then(removeSubstring(ref("rap.rapurl"), val(".html")))
58
- .else(null)
59
- .end()
60
- .as("id"),
61
- eb
62
- .case()
63
- .when("rap.typurl", "=", "I")
64
- .then(concat(val("https://www.senat.fr/rap/"), rtrim(ref("rap.rapurl"))))
65
- .else(rtrim(ref("rap.rapurl")))
66
- .end()
67
- .as("url"),
68
- rtrim(ref("denrap.libdenrap")).as("type"),
69
- rtrim(ref("rap.raptil")).as("titre"),
70
- rtrim(ref("rap.rapsoustit")).as("sous_titre"),
71
- toDateString(ref("rap.date_depot")).as("date"),
72
- "sesann as session",
73
- auteursRapport(ref("rap.rapcod")).as("auteurs"),
74
- documentsAttaches(ref("rap.rapcod")).as("documents_annexes"),
75
- ]));
76
- }
77
- function auteursTexte(texteId) {
78
- return jsonArrayFrom(dbSenat
79
- .withSchema("dosleg")
80
- .selectFrom("auteur")
81
- .leftJoin("ecr", "ecr.autcod", "auteur.autcod")
82
- .leftJoin("rolsig", "rolsig.signataire", "ecr.signataire")
83
- .where("ecr.texcod", "=", texteId)
84
- .select([
85
- "auteur.prenom as prenom",
86
- "auteur.nomuse as nom_usuel",
87
- "auteur.autmat as matricule",
88
- "ecr.ecrnumtri as ordre",
89
- "rolsig.rolsiglib as role",
90
- "ecr.ecrqua as qualite",
91
- ])
92
- .orderBy("ecr.ecrnumtri", "asc"));
93
- }
94
- function textes(lectureAssembleeId) {
95
- return jsonArrayFrom(dbSenat
96
- .withSchema("dosleg")
97
- .selectFrom("texte")
98
- .leftJoin("oritxt", "oritxt.oritxtcod", "texte.oritxtcod")
99
- .leftJoin("typtxt", "typtxt.typtxtcod", "texte.typtxtcod")
100
- .where("texte.lecassidt", "=", lectureAssembleeId)
101
- .select(({ eb, ref, val }) => [
102
- "texte.texnum as numero",
103
- "texte.orgcod as code_organisme",
104
- eb
105
- .case()
106
- .when("texte.typurl", "=", "I")
107
- .then(removeSubstring(ref("texte.texurl"), val(".html")))
108
- .else(null)
109
- .end()
110
- .as("id"),
111
- eb
112
- .case()
113
- .when("texte.typurl", "=", "I")
114
- .then(concat(val("https://www.senat.fr/leg/"), rtrim(ref("texte.texurl"))))
115
- .else(rtrim(ref("texte.texurl")))
116
- .end()
117
- .as("url"),
118
- rtrim(ref("oritxt.oritxtlib")).as("origine"),
119
- "oritxt.oriordre as ordre_origine",
120
- "oritxt.oritxtado as code_adoption",
121
- "oritxt.oritxtmod as modification",
122
- rtrim(ref("typtxt.typtxtlib")).as("type"),
123
- toDateString(ref("texte.txtoritxtdat")).as("date"),
124
- "sesann as session",
125
- auteursTexte(ref("texte.texcod")).as("auteurs"),
126
- ])
127
- .orderBy(({ ref }) => orderOrdreOrigineTexte(ref("oritxt.oriordre"))));
128
- }
129
13
  function lecturesAssemblee(lectureId) {
130
14
  return jsonArrayFrom(dbSenat
131
15
  .withSchema("dosleg")
@@ -319,10 +203,10 @@ export function buildActesLegislatifs(dossier) {
319
203
  numero: depotTexte.numero,
320
204
  uid: `${loiSignet}-${phasePrefix}-DEPOT`,
321
205
  session: lecAss.session,
322
- chambre: 'SN',
206
+ chambre: "SN",
323
207
  signet_dossier: loiSignet,
324
208
  texte_url: depotTexte.url,
325
- code_organisme: null
209
+ code_organisme: null,
326
210
  });
327
211
  }
328
212
  // =================================================================
@@ -341,7 +225,7 @@ export function buildActesLegislatifs(dossier) {
341
225
  adoption: rap.adoption,
342
226
  uid: `${loiSignet}-${phasePrefix}-COM`,
343
227
  session: lecAss.session,
344
- chambre: 'SN',
228
+ chambre: "SN",
345
229
  signet_dossier: loiSignet,
346
230
  texte_url: rap.url,
347
231
  });
@@ -363,9 +247,9 @@ export function buildActesLegislatifs(dossier) {
363
247
  libelle: `Discussion en séance publique`,
364
248
  uid: `${loiSignet}-${phasePrefix}-DEBATS-SEANCE`,
365
249
  session: lecAss.session,
366
- chambre: 'SN',
250
+ chambre: "SN",
367
251
  signet_dossier: loiSignet,
368
- code_organisme: null
252
+ code_organisme: null,
369
253
  });
370
254
  }
371
255
  }
@@ -397,10 +281,10 @@ export function buildActesLegislatifs(dossier) {
397
281
  adoption: libelleStatut,
398
282
  uid: `${loiSignet}-DEC-${texteFinal.numero}`,
399
283
  session: lecAss.session,
400
- chambre: 'SN',
284
+ chambre: "SN",
401
285
  signet_dossier: loiSignet,
402
286
  texte_url: texteFinal.url,
403
- code_organisme: null
287
+ code_organisme: null,
404
288
  });
405
289
  }
406
290
  }
@@ -410,19 +294,19 @@ export function buildActesLegislatifs(dossier) {
410
294
  // =================================================================
411
295
  if (dossier.date_decision_CoC) {
412
296
  actes.push({
413
- code_acte: 'CC',
297
+ code_acte: "CC",
414
298
  date: dossier.date_decision_CoC,
415
299
  libelle: `Décision du Conseil constitutionnel`,
416
300
  id: dossier.url_decision_CoC,
417
301
  uid: `${loiSignet}-CC`,
418
- chambre: 'AN',
302
+ chambre: "AN",
419
303
  signet_dossier: loiSignet,
420
304
  texte_url: dossier.url_decision_CoC || dossier.url_dossier_CoC,
421
305
  });
422
306
  }
423
307
  if (dossier.date_promulgation) {
424
308
  actes.push({
425
- code_acte: 'PROM',
309
+ code_acte: "PROM",
426
310
  date: dossier.date_promulgation,
427
311
  libelle: `Promulgation de la loi`,
428
312
  date_publication_JO: dossier.date_publication_JO,
@@ -430,7 +314,7 @@ export function buildActesLegislatifs(dossier) {
430
314
  url_legifrance: dossier.url_JO,
431
315
  id: dossier.url_JO,
432
316
  uid: `${loiSignet}-PROM`,
433
- chambre: 'AN',
317
+ chambre: "AN",
434
318
  signet_dossier: loiSignet,
435
319
  });
436
320
  }
@@ -1,7 +1,7 @@
1
1
  export { findAllAmendements } from "./ameli";
2
2
  export { findAll as findAllDebats } from "./debats";
3
3
  export { findAllDossiers } from "./dosleg";
4
- export { findSenatTexteUrls, findSenatRapportUrls } from "./documents";
4
+ export { findAllTextes, findAllRapports } from "./documents";
5
5
  export { findAllScrutins } from "./scrutins";
6
6
  export { findAll as findAllQuestions } from "./questions";
7
7
  export { findAll as findAllSens, findAllCirconscriptions, findAllOrganismes } from "./sens";
@@ -1,7 +1,7 @@
1
1
  export { findAllAmendements } from "./ameli";
2
2
  export { findAll as findAllDebats } from "./debats";
3
3
  export { findAllDossiers } from "./dosleg";
4
- export { findSenatTexteUrls, findSenatRapportUrls } from "./documents";
4
+ export { findAllTextes, findAllRapports } from "./documents";
5
5
  export { findAllScrutins } from "./scrutins";
6
6
  export { findAll as findAllQuestions } from "./questions";
7
7
  export { findAll as findAllSens, findAllCirconscriptions, findAllOrganismes } from "./sens";
@@ -113,6 +113,10 @@ export interface TamMinisteres {
113
113
  titreministre: string | null;
114
114
  }
115
115
  export interface TamQuestions {
116
+ /**
117
+ * Question caduque redéposée
118
+ */
119
+ caduque_redeposee: string | null;
116
120
  /**
117
121
  * Libellé de la circonscription
118
122
  */
@@ -2735,6 +2735,10 @@ export interface QuestionsTamMinisteres {
2735
2735
  titreministre: string | null;
2736
2736
  }
2737
2737
  export interface QuestionsTamQuestions {
2738
+ /**
2739
+ * Question caduque redéposée
2740
+ */
2741
+ caduque_redeposee: string | null;
2738
2742
  /**
2739
2743
  * Libellé de la circonscription
2740
2744
  */