@tricoteuses/senat 3.1.2 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/lib/src/rich_types/dosleg.js +13 -3
  2. package/lib/src/rich_types/sens.d.ts +2 -0
  3. package/lib/src/scripts/data-download.js +16 -9
  4. package/lib/src/scripts/retrieve_open_data.js +4 -2
  5. package/lib/src/scripts/shared/make_generate_zod_schemas.js +6 -2
  6. package/lib/src/server/databases_postgres.js +2 -1
  7. package/lib/src/server/documents.js +2 -2
  8. package/lib/src/server/dosleg.js +2 -2
  9. package/lib/src/server/sens.js +70 -0
  10. package/lib/src/utils/reunion_parsing.js +1 -1
  11. package/package.json +3 -1
  12. package/lib/src/config.d.ts +0 -43
  13. package/lib/src/config.js +0 -37
  14. package/lib/src/conversion_textes.d.ts +0 -11
  15. package/lib/src/conversion_textes.js +0 -320
  16. package/lib/src/databases_postgres.d.ts +0 -4
  17. package/lib/src/databases_postgres.js +0 -23
  18. package/lib/src/datasets.d.ts +0 -38
  19. package/lib/src/datasets.js +0 -247
  20. package/lib/src/git.d.ts +0 -27
  21. package/lib/src/git.js +0 -251
  22. package/lib/src/loaders.d.ts +0 -52
  23. package/lib/src/loaders.js +0 -260
  24. package/lib/src/model/agenda.d.ts +0 -6
  25. package/lib/src/model/agenda.js +0 -148
  26. package/lib/src/model/ameli.d.ts +0 -67
  27. package/lib/src/model/ameli.js +0 -150
  28. package/lib/src/model/commission.d.ts +0 -19
  29. package/lib/src/model/commission.js +0 -269
  30. package/lib/src/model/debats.d.ts +0 -39
  31. package/lib/src/model/debats.js +0 -112
  32. package/lib/src/model/documents.d.ts +0 -32
  33. package/lib/src/model/documents.js +0 -182
  34. package/lib/src/model/dosleg.d.ts +0 -144
  35. package/lib/src/model/dosleg.js +0 -468
  36. package/lib/src/model/index.d.ts +0 -7
  37. package/lib/src/model/index.js +0 -7
  38. package/lib/src/model/questions.d.ts +0 -54
  39. package/lib/src/model/questions.js +0 -91
  40. package/lib/src/model/scrutins.d.ts +0 -48
  41. package/lib/src/model/scrutins.js +0 -121
  42. package/lib/src/model/seance.d.ts +0 -3
  43. package/lib/src/model/seance.js +0 -267
  44. package/lib/src/model/sens.d.ts +0 -112
  45. package/lib/src/model/sens.js +0 -385
  46. package/lib/src/model/util.d.ts +0 -1
  47. package/lib/src/model/util.js +0 -15
  48. package/lib/src/raw_types/ameli.d.ts +0 -1762
  49. package/lib/src/raw_types/ameli.js +0 -1074
  50. package/lib/src/raw_types/debats.d.ts +0 -380
  51. package/lib/src/raw_types/debats.js +0 -266
  52. package/lib/src/raw_types/dosleg.d.ts +0 -2954
  53. package/lib/src/raw_types/dosleg.js +0 -2005
  54. package/lib/src/raw_types/questions.d.ts +0 -699
  55. package/lib/src/raw_types/questions.js +0 -493
  56. package/lib/src/raw_types/sens.d.ts +0 -7843
  57. package/lib/src/raw_types/sens.js +0 -4691
  58. package/lib/src/raw_types_schemats/ameli.d.ts +0 -541
  59. package/lib/src/raw_types_schemats/ameli.js +0 -2
  60. package/lib/src/raw_types_schemats/debats.d.ts +0 -127
  61. package/lib/src/raw_types_schemats/debats.js +0 -2
  62. package/lib/src/raw_types_schemats/dosleg.d.ts +0 -977
  63. package/lib/src/raw_types_schemats/dosleg.js +0 -2
  64. package/lib/src/raw_types_schemats/questions.d.ts +0 -237
  65. package/lib/src/raw_types_schemats/questions.js +0 -2
  66. package/lib/src/raw_types_schemats/sens.d.ts +0 -2709
  67. package/lib/src/raw_types_schemats/sens.js +0 -2
  68. package/lib/src/types/agenda.d.ts +0 -45
  69. package/lib/src/types/agenda.js +0 -1
  70. package/lib/src/types/ameli.d.ts +0 -5
  71. package/lib/src/types/ameli.js +0 -1
  72. package/lib/src/types/compte_rendu.d.ts +0 -83
  73. package/lib/src/types/compte_rendu.js +0 -1
  74. package/lib/src/types/debats.d.ts +0 -2
  75. package/lib/src/types/debats.js +0 -1
  76. package/lib/src/types/dosleg.d.ts +0 -70
  77. package/lib/src/types/dosleg.js +0 -1
  78. package/lib/src/types/questions.d.ts +0 -2
  79. package/lib/src/types/questions.js +0 -1
  80. package/lib/src/types/sens.d.ts +0 -8
  81. package/lib/src/types/sens.js +0 -1
  82. package/lib/src/types/sessions.d.ts +0 -6
  83. package/lib/src/types/sessions.js +0 -19
  84. package/lib/src/types/texte.d.ts +0 -72
  85. package/lib/src/types/texte.js +0 -15
  86. package/lib/src/validators/config.d.ts +0 -9
  87. package/lib/src/validators/config.js +0 -10
@@ -1,320 +0,0 @@
1
- import { JSDOM } from "jsdom";
2
- import fs from "fs-extra";
3
- import path from "path";
4
- import { DateTime } from "luxon";
5
- export function extractMetadata(xmlDoc) {
6
- const metadata = {
7
- number: null,
8
- session: null,
9
- date: null,
10
- type: null,
11
- authors: null,
12
- title: xmlDoc.querySelector("docTitle")?.textContent?.trim() || null,
13
- commission: null,
14
- };
15
- // Extract Number
16
- const docIdAlias = xmlDoc.querySelector('FRBRalias[name="signet-dossier-legislatif-senat"]');
17
- if (docIdAlias) {
18
- const value = docIdAlias.getAttribute("value");
19
- if (value) {
20
- const match = value.match(/\d+$/);
21
- if (match)
22
- metadata.number = match[0];
23
- }
24
- }
25
- // Extract Session
26
- const sessionUri = xmlDoc.querySelector("FRBRExpression > FRBRuri")?.getAttribute("value");
27
- if (sessionUri) {
28
- const match = sessionUri.match(/\d{4}-\d{4}/);
29
- if (match)
30
- metadata.session = match[0];
31
- }
32
- // Extract Date
33
- const depotDate = xmlDoc.querySelector('FRBRdate[name="#depot"]')?.getAttribute("date");
34
- if (depotDate) {
35
- metadata.date = DateTime.fromISO(depotDate).setLocale("fr").toFormat("d MMMM yyyy");
36
- }
37
- else {
38
- const presentationDate = xmlDoc.querySelector('FRBRdate[name="#presentation"]')?.getAttribute("date");
39
- if (presentationDate) {
40
- metadata.date = DateTime.fromISO(presentationDate).setLocale("fr").toFormat("d MMMM yyyy");
41
- }
42
- }
43
- // Extract Type
44
- const bill = xmlDoc.querySelector("bill");
45
- const typeCode = bill?.getAttribute("name");
46
- if (typeCode === "ppl") {
47
- metadata.type = "PROPOSITION DE LOI";
48
- }
49
- else if (typeCode === "pjl") {
50
- metadata.type = "PROJET DE LOI";
51
- }
52
- // Extract Authors
53
- const authorRef = xmlDoc.querySelector('FRBRWork > FRBRauthor[as="#auteur"]')?.getAttribute("href");
54
- if (authorRef) {
55
- const authorId = authorRef.replace(/^#/, "");
56
- const authorPerson = xmlDoc.querySelector(`TLCPerson[eId="${authorId}"]`);
57
- if (authorPerson) {
58
- const showAs = authorPerson.getAttribute("showAs");
59
- if (showAs) {
60
- metadata.authors = showAs.replace(/, Sénateurs$/, ", Sénateurs et Sénatrices");
61
- }
62
- }
63
- }
64
- // Extract Commission
65
- const commissionNode = xmlDoc.querySelector('TLCOrganization[eId="commission-senat"]') ||
66
- xmlDoc.querySelector('TLCOrganization[eId^="commission-"]:not([eId*="assemblee"])');
67
- if (commissionNode) {
68
- metadata.commission = commissionNode.getAttribute("showAs");
69
- }
70
- return metadata;
71
- }
72
- export async function convertSenatXmlToHtml(texteXml, outputFilePath) {
73
- let xmlDoc;
74
- try {
75
- xmlDoc = new JSDOM(texteXml, { contentType: "text/xml" }).window.document;
76
- }
77
- catch (err) {
78
- if (await fs.pathExists(outputFilePath)) {
79
- await fs.remove(outputFilePath);
80
- }
81
- throw err;
82
- }
83
- const metadata = extractMetadata(xmlDoc);
84
- const xmlBody = xmlDoc.querySelector("body");
85
- const style = `
86
- body {
87
- font-family: "URW Bookman", "Bookman Old Style", serif;
88
- max-width: 800px;
89
- margin: 40px auto;
90
- line-height: 1.5;
91
- color: #333;
92
- }
93
- .header {
94
- text-align: center;
95
- margin-bottom: 40px;
96
- border-bottom: 2px solid #333;
97
- padding-bottom: 20px;
98
- }
99
- .header-top {
100
- font-weight: bold;
101
- font-size: 1.2em;
102
- margin-bottom: 10px;
103
- }
104
- .header-session {
105
- text-transform: uppercase;
106
- font-size: 0.9em;
107
- margin-bottom: 5px;
108
- }
109
- .header-date {
110
- font-size: 0.9em;
111
- margin-bottom: 5px;
112
- }
113
- .header-number {
114
- font-weight: bold;
115
- font-size: 1.1em;
116
- margin-bottom: 20px;
117
- }
118
- .header-type {
119
- font-weight: bold;
120
- font-size: 1.5em;
121
- margin-top: 20px;
122
- }
123
- .header-authors {
124
- margin-top: 20px;
125
- font-style: italic;
126
- }
127
- .header-commission {
128
- margin-top: 15px;
129
- font-size: 0.9em;
130
- }
131
- h1 {
132
- text-align: center;
133
- font-size: 1.8em;
134
- margin-top: 10px;
135
- }
136
- p {
137
- margin: 0.6em 0;
138
- }
139
- p.has-alinea {
140
- position: relative;
141
- padding-left: 2.5em;
142
- }
143
- .alinea {
144
- position: absolute;
145
- left: 0;
146
- top: 0.15em;
147
- display: inline-flex;
148
- align-items: center;
149
- justify-content: center;
150
- min-width: 1.5em;
151
- height: 1.5em;
152
- padding: 0 0.3em;
153
- margin-right: 0.3em;
154
- font-size: 0.75em;
155
- font-weight: bold;
156
- color: #555;
157
- background-color: #f0f0f0;
158
- border: 1px solid #ccc;
159
- border-radius: 1em;
160
- }
161
- .num {
162
- font-weight: bold;
163
- margin-right: 0.2em;
164
- }
165
- .article {
166
- margin-top: 2em;
167
- }
168
- .article h3 {
169
- border-bottom: 1px solid #eee;
170
- padding-bottom: 5px;
171
- }
172
- `;
173
- const htmlDocTemplate = `<!DOCTYPE html>
174
- <html lang="fr">
175
- <head>
176
- <meta charset="utf-8">
177
- <title>${metadata.title || "Document Sénat"}</title>
178
- <style>${style}</style>
179
- </head>
180
- <body>
181
- <div class="header">
182
- <div class="header-top">SÉNAT</div>
183
- <div class="header-session">SESSION ORDINAIRE DE ${metadata.session || "...."}</div>
184
- ${metadata.date ? `<div class="header-date">Enregistré à la Présidence du Sénat le ${metadata.date}</div>` : ""}
185
- <div class="header-number">N° ${metadata.number || "...."}</div>
186
- <div class="header-type">${metadata.type || ""}</div>
187
- <div class="header-authors">${metadata.authors || ""}</div>
188
- ${metadata.commission
189
- ? [
190
- `<div class="header-commission">Envoyée à la ${metadata.commission.toLowerCase()},`,
191
- "sous réserve de la constitution éventuelle d'une commission spéciale dans les conditions prévues",
192
- "par le Règlement.</div>",
193
- ].join(" ")
194
- : ""}
195
- </div>
196
- <h1>${metadata.title || ""}</h1>
197
- </body>
198
- </html>`;
199
- const { document: htmlDoc } = new JSDOM(htmlDocTemplate).window;
200
- const body = htmlDoc.body;
201
- if (xmlBody) {
202
- const processNode = (xmlNode, htmlParent, alineaData = null) => {
203
- const children = Array.from(xmlNode.childNodes);
204
- const alineaChildren = [];
205
- const otherChildren = [];
206
- for (const child of children) {
207
- if (child.nodeType === 1 && child.tagName.toLowerCase() === "alinea") {
208
- alineaChildren.push(child);
209
- }
210
- else {
211
- otherChildren.push(child);
212
- }
213
- }
214
- for (const child of otherChildren) {
215
- if (child.nodeType === 3) {
216
- htmlParent.appendChild(htmlDoc.createTextNode(child.textContent || ""));
217
- }
218
- else if (child.nodeType === 1) {
219
- const element = child;
220
- const tagName = element.tagName.toLowerCase();
221
- let htmlElement = null;
222
- switch (tagName) {
223
- case "article": {
224
- htmlElement = htmlDoc.createElement("div");
225
- htmlElement.className = "article";
226
- const artId = element.getAttribute("eId");
227
- if (artId)
228
- htmlElement.id = artId;
229
- const artGuid = element.getAttribute("GUID");
230
- if (artGuid)
231
- htmlElement.setAttribute("data-guid", artGuid);
232
- break;
233
- }
234
- case "num": {
235
- const parentTagName = element.parentElement?.tagName.toLowerCase();
236
- if (parentTagName === "alinea" && alineaData) {
237
- alineaData.numText = element.textContent?.trim();
238
- continue;
239
- }
240
- htmlElement = htmlDoc.createElement("span");
241
- htmlElement.className = "num";
242
- break;
243
- }
244
- case "heading":
245
- htmlElement = htmlDoc.createElement("h4");
246
- break;
247
- case "p":
248
- htmlElement = htmlDoc.createElement("p");
249
- if (alineaData) {
250
- htmlElement.classList.add("has-alinea");
251
- if (alineaData.id)
252
- htmlElement.id = alineaData.id;
253
- if (alineaData.guid)
254
- htmlElement.setAttribute("data-guid", alineaData.guid);
255
- const pastille = alineaData.pastille;
256
- if (pastille) {
257
- htmlElement.setAttribute("data-pastille", pastille);
258
- if (!alineaData.pastilleApplied) {
259
- const span = htmlDoc.createElement("span");
260
- span.className = "alinea";
261
- span.setAttribute("data-alinea", pastille);
262
- span.textContent = pastille;
263
- htmlElement.appendChild(span);
264
- alineaData.pastilleApplied = true;
265
- }
266
- }
267
- if (alineaData.numText) {
268
- const xmlPText = element.textContent || "";
269
- const normalize = (s) => s.replace(/[\\s\\u00A0]+/g, " ").trim();
270
- const normalizedNum = normalize(alineaData.numText);
271
- const normalizedP = normalize(xmlPText);
272
- if (normalizedNum && !normalizedP.startsWith(normalizedNum)) {
273
- const numSpan = htmlDoc.createElement("span");
274
- numSpan.className = "num";
275
- numSpan.textContent = alineaData.numText + " ";
276
- htmlElement.appendChild(numSpan);
277
- }
278
- alineaData.numText = null;
279
- }
280
- }
281
- break;
282
- case "content":
283
- processNode(element, htmlParent, alineaData);
284
- continue;
285
- case "doctitle":
286
- continue;
287
- case "i":
288
- case "b":
289
- case "u":
290
- case "sup":
291
- case "sub":
292
- htmlElement = htmlDoc.createElement(tagName);
293
- break;
294
- default:
295
- htmlElement = htmlDoc.createElement("span");
296
- htmlElement.setAttribute("data-xml-tag", tagName);
297
- break;
298
- }
299
- if (htmlElement) {
300
- htmlParent.appendChild(htmlElement);
301
- processNode(element, htmlElement, alineaData);
302
- }
303
- }
304
- }
305
- for (const element of alineaChildren) {
306
- const nextAlineaData = {
307
- id: element.getAttribute("eId"),
308
- guid: element.getAttribute("GUID"),
309
- pastille: element.getAttribute("data:pastille"),
310
- pastilleApplied: false,
311
- };
312
- processNode(element, htmlParent, nextAlineaData);
313
- }
314
- };
315
- processNode(xmlBody, body);
316
- }
317
- const htmlContent = "<!DOCTYPE html>\n" + htmlDoc.documentElement.outerHTML;
318
- await fs.ensureDir(path.dirname(outputFilePath));
319
- await fs.outputFile(outputFilePath, htmlContent);
320
- }
@@ -1,4 +0,0 @@
1
- import postgres from "postgres";
2
- export type SqlValue = postgres.ParameterOrJSON<never>;
3
- export declare const sql: postgres.Sql<{}>;
4
- export declare function streamUnsafeQuery<T>(query: string, params?: readonly unknown[], batchSize?: number): AsyncGenerator<T, void, unknown>;
@@ -1,23 +0,0 @@
1
- import postgres from "postgres";
2
- import config from "./config.js";
3
- export const sql = postgres({
4
- database: config.db.name,
5
- host: config.db.host,
6
- password: config.db.password,
7
- port: config.db.port,
8
- transform: {
9
- undefined: null,
10
- },
11
- user: config.db.user,
12
- });
13
- function toSqlValue(value) {
14
- return value;
15
- }
16
- export async function* streamUnsafeQuery(query, params = [], batchSize = 100) {
17
- const values = params.map(toSqlValue);
18
- for await (const rows of sql.unsafe(query, values).cursor(batchSize)) {
19
- for (const row of rows) {
20
- yield row;
21
- }
22
- }
23
- }
@@ -1,38 +0,0 @@
1
- export interface Dataset {
2
- database: string;
3
- repairEncoding: boolean;
4
- repairZip?: (dataset: Dataset, dataDir: string) => void;
5
- title: string;
6
- url: string;
7
- indexes?: {
8
- [table: string]: Array<{
9
- name: string;
10
- columns: string[];
11
- }>;
12
- };
13
- mergeKeys?: {
14
- [table: string]: string[];
15
- };
16
- rowMultisetMergeTables?: string[];
17
- }
18
- export interface Datasets {
19
- ameli: Dataset;
20
- debats: Dataset;
21
- dosleg: Dataset;
22
- questions: Dataset;
23
- sens: Dataset;
24
- }
25
- export declare enum EnabledDatasets {
26
- None = 0,
27
- Ameli = 1,
28
- Debats = 2,
29
- DosLeg = 4,
30
- Questions = 8,
31
- Sens = 16,
32
- PhotosSenateurs = 32,
33
- Agenda = 64,
34
- All = 127
35
- }
36
- export declare const datasets: Datasets;
37
- export declare function getEnabledDatasets(categories: string[]): EnabledDatasets;
38
- export declare function getChosenDatasets(enabledDatasets: EnabledDatasets): Dataset[];
@@ -1,247 +0,0 @@
1
- import fs from "fs-extra";
2
- import path from "path";
3
- import assert from "assert";
4
- export var EnabledDatasets;
5
- (function (EnabledDatasets) {
6
- EnabledDatasets[EnabledDatasets["None"] = 0] = "None";
7
- EnabledDatasets[EnabledDatasets["Ameli"] = 1] = "Ameli";
8
- EnabledDatasets[EnabledDatasets["Debats"] = 2] = "Debats";
9
- EnabledDatasets[EnabledDatasets["DosLeg"] = 4] = "DosLeg";
10
- EnabledDatasets[EnabledDatasets["Questions"] = 8] = "Questions";
11
- EnabledDatasets[EnabledDatasets["Sens"] = 16] = "Sens";
12
- EnabledDatasets[EnabledDatasets["PhotosSenateurs"] = 32] = "PhotosSenateurs";
13
- EnabledDatasets[EnabledDatasets["Agenda"] = 64] = "Agenda";
14
- EnabledDatasets[EnabledDatasets["All"] = 127] = "All";
15
- })(EnabledDatasets || (EnabledDatasets = {}));
16
- export const datasets = {
17
- ameli: {
18
- database: "ameli",
19
- repairEncoding: true,
20
- repairZip: (dataset, dataDir) => {
21
- const sqlFilename = `${dataset.database}.sql`;
22
- const sqlFilePath = path.join(dataDir, sqlFilename);
23
- fs.removeSync(sqlFilePath);
24
- fs.moveSync(path.join(dataDir, "var", "opt", "opendata", sqlFilename), sqlFilePath);
25
- },
26
- title: "Amendements",
27
- url: "https://data.senat.fr/data/ameli/ameli.zip",
28
- indexes: {
29
- amdsen: [
30
- { name: "idx_amdid", columns: ["amdid"] },
31
- { name: "idx_senid", columns: ["senid"] },
32
- { name: "idx_grpid", columns: ["grpid"] },
33
- ],
34
- sen_ameli: [{ name: "idx_entid", columns: ["entid"] }],
35
- grppol_ameli: [{ name: "idx_entid", columns: ["entid"] }],
36
- sub: [
37
- { name: "idx_id", columns: ["id"] },
38
- { name: "idx_typid", columns: ["typid"] },
39
- { name: "idx_merid", columns: ["merid"] },
40
- { name: "idx_comdelid", columns: ["comdelid"] },
41
- ],
42
- typsub: [{ name: "idx_id", columns: ["id"] }],
43
- typrect: [{ name: "idx_id", columns: ["id"] }],
44
- txt_ameli: [
45
- { name: "idx_id", columns: ["id"] },
46
- { name: "idx_txtetaid", columns: ["txtetaid"] },
47
- { name: "idx_sesdepid", columns: ["sesdepid"] },
48
- { name: "idx_natid", columns: ["natid"] },
49
- { name: "idx_lecid", columns: ["lecid"] },
50
- ],
51
- etatxt: [{ name: "idx_id", columns: ["id"] }],
52
- ses: [
53
- { name: "idx_id", columns: ["id"] },
54
- { name: "idx_typid", columns: ["typid"] },
55
- { name: "idx_ann", columns: ["ann"] },
56
- ],
57
- typses: [{ name: "idx_id", columns: ["id"] }],
58
- nat: [{ name: "idx_id", columns: ["id"] }],
59
- lec_ameli: [{ name: "idx_id", columns: ["id"] }],
60
- mot: [{ name: "idx_id", columns: ["id"] }],
61
- avicom: [{ name: "idx_id", columns: ["id"] }],
62
- avigvt: [{ name: "idx_id", columns: ["id"] }],
63
- sor: [{ name: "idx_id", columns: ["id"] }],
64
- irr: [{ name: "idx_id", columns: ["id"] }],
65
- com_ameli: [{ name: "idx_entid", columns: ["entid"] }],
66
- cab: [{ name: "idx_entid", columns: ["entid"] }],
67
- amd: [
68
- { name: "idx_subid", columns: ["subid"] },
69
- { name: "idx_typrectid", columns: ["typrectid"] },
70
- { name: "idx_txtid", columns: ["txtid"] },
71
- { name: "idx_motid", columns: ["motid"] },
72
- { name: "idx_avcid", columns: ["avcid"] },
73
- { name: "idx_avgid", columns: ["avgid"] },
74
- { name: "idx_sorid", columns: ["sorid"] },
75
- { name: "idx_irrid", columns: ["irrid"] },
76
- { name: "idx_nomentid", columns: ["nomentid"] },
77
- ],
78
- },
79
- },
80
- debats: {
81
- database: "debats",
82
- repairEncoding: false,
83
- title: "Informations relatives aux comptes rendus intégraux de la séance publique",
84
- url: "https://data.senat.fr/data/debats/debats.zip",
85
- indexes: {
86
- secdis: [
87
- { name: "idx_datsea", columns: ["datsea"] },
88
- { name: "idx_typseccod", columns: ["typseccod"] },
89
- ],
90
- intpjl: [{ name: "idx_secdiscle", columns: ["secdiscle"] }],
91
- secdivers: [
92
- { name: "idx_datsea", columns: ["datsea"] },
93
- { name: "idx_typseccod", columns: ["typseccod"] },
94
- ],
95
- intdivers: [{ name: "idx_intdiverscle", columns: ["intdiverscle"] }],
96
- lecassdeb: [{ name: "idx_datsea", columns: ["datsea"] }],
97
- },
98
- },
99
- dosleg: {
100
- database: "dosleg",
101
- repairEncoding: false,
102
- title: "Dossiers législatifs",
103
- url: "https://data.senat.fr/data/dosleg/dosleg.zip",
104
- indexes: {
105
- amescr: [{ name: "idx_scrnum", columns: ["scrnum"] }],
106
- auteur: [{ name: "idx_autcod", columns: ["autcod"] }],
107
- corscr: [{ name: "idx_scrnum", columns: ["scrnum"] }],
108
- date_seance: [
109
- { name: "idx_code", columns: ["code"] },
110
- { name: "idx_lecidt", columns: ["lecidt"] },
111
- ],
112
- deccoc: [{ name: "idx_deccoccod", columns: ["deccoccod"] }],
113
- etaloi: [{ name: "idx_etaloicod", columns: ["etaloicod"] }],
114
- lecass: [
115
- { name: "idx_lecidt", columns: ["lecidt"] },
116
- { name: "idx_codass", columns: ["codass"] },
117
- { name: "idx_orgcod", columns: ["orgcod"] },
118
- { name: "idx_orippr", columns: ["orippr"] },
119
- ],
120
- lecassrap: [
121
- { name: "idx_rapcod", columns: ["rapcod"] },
122
- { name: "idx_lecassidt", columns: ["lecassidt"] },
123
- ],
124
- lecture: [
125
- { name: "idx_loicod", columns: ["loicod"] },
126
- { name: "idx_typleccod", columns: ["typleccod"] },
127
- { name: "idx_lecidt", columns: ["lecidt"] },
128
- ],
129
- loi: [
130
- { name: "idx_typloicod", columns: ["typloicod"] },
131
- { name: "idx_etaloicod", columns: ["etaloicod"] },
132
- { name: "idx_deccoccod", columns: ["deccoccod"] },
133
- { name: "idx_loicod", columns: ["loicod"] },
134
- ],
135
- loithe: [
136
- { name: "idx_thecle", columns: ["thecle"] },
137
- { name: "idx_loicod", columns: ["loicod"] },
138
- ],
139
- posvot: [{ name: "idx_posvotcod", columns: ["posvotcod"] }],
140
- rap: [
141
- { name: "idx_rapcod", columns: ["rapcod"] },
142
- { name: "idx_coddenrap", columns: ["coddenrap"] },
143
- ],
144
- rolsig: [{ name: "idx_signataire", columns: ["signataire"] }],
145
- scr: [
146
- { name: "idx_code", columns: ["code"] },
147
- { name: "idx_scrnum", columns: ["scrnum"] },
148
- { name: "idx_sesann", columns: ["sesann"] },
149
- ],
150
- stavot: [{ name: "idx_stavotidt", columns: ["stavotidt"] }],
151
- texte: [
152
- { name: "idx_lecassidt", columns: ["lecassidt"] },
153
- { name: "idx_oritxtcod", columns: ["oritxtcod"] },
154
- { name: "idx_typtxtcod", columns: ["typtxtcod"] },
155
- { name: "idx_texcod", columns: ["texcod"] },
156
- ],
157
- the: [{ name: "idx_thecle", columns: ["thecle"] }],
158
- titsen: [{ name: "idx_titsencod", columns: ["titsencod"] }],
159
- typloi: [{ name: "idx_typloicod", columns: ["typloicod"] }],
160
- typtxt: [{ name: "idx_typtxtcod", columns: ["typtxtcod"] }],
161
- votsen: [
162
- { name: "idx_scrnum", columns: ["scrnum"] },
163
- { name: "idx_sesann", columns: ["sesann"] },
164
- { name: "idx_titsencod", columns: ["titsencod"] },
165
- { name: "idx_stavotidt", columns: ["stavotidt"] },
166
- { name: "idx_posvotcod", columns: ["posvotcod"] },
167
- { name: "idx_senmat", columns: ["senmat"] },
168
- ],
169
- },
170
- mergeKeys: {
171
- corscr: ["sesann", "scrnum", "corscrord"],
172
- docsea: ["evtseacle", "docseaord"],
173
- gen: ["gencod"],
174
- },
175
- rowMultisetMergeTables: ["amescr"],
176
- },
177
- questions: {
178
- database: "questions",
179
- repairEncoding: false,
180
- title: "Questions écrites et orales posées par les sénateurs au Gouvernement",
181
- url: "https://data.senat.fr/data/questions/questions.zip",
182
- indexes: {
183
- tam_reponses: [{ name: "idx_idque", columns: ["idque"] }],
184
- tam_questions: [
185
- { name: "idx_sorquecod", columns: ["sorquecod"] },
186
- { name: "idx_etaquecod", columns: ["etaquecod"] },
187
- ],
188
- the: [{ name: "idx_thenouidt", columns: ["thenouidt"] }],
189
- sortquestion: [{ name: "idx_sorquecod", columns: ["sorquecod"] }],
190
- etatquestion: [{ name: "idx_etaquecod", columns: ["etaquecod"] }],
191
- },
192
- rowMultisetMergeTables: ["tam_reponses"],
193
- },
194
- sens: {
195
- database: "sens",
196
- repairEncoding: false,
197
- repairZip: (dataset, dataDir) => {
198
- const sqlFilename = `${dataset.database}.sql`;
199
- const sqlFilePath = path.join(dataDir, sqlFilename);
200
- fs.removeSync(sqlFilePath);
201
- fs.moveSync(path.join(dataDir, "export_sens.sql"), sqlFilePath);
202
- },
203
- title: "Sénateurs (y compris organes et présence)",
204
- url: "https://data.senat.fr/data/senateurs/export_sens.zip",
205
- indexes: {
206
- dpt: [
207
- { name: "idx_dptnum", columns: ["dptnum"] },
208
- { name: "idx_regcod", columns: ["regcod"] },
209
- ],
210
- activite_loi: [{ name: "idx_actid", columns: ["actid"] }],
211
- activite_delegation: [{ name: "idx_actid", columns: ["actid"] }],
212
- activite_participant: [{ name: "idx_senmat", columns: ["senmat"] }],
213
- activite_senateur: [{ name: "idx_senmat", columns: ["senmat"] }],
214
- senbur: [
215
- { name: "idx_senmat", columns: ["senmat"] },
216
- { name: "idx_burcod", columns: ["burcod"] },
217
- ],
218
- elucan: [
219
- { name: "idx_senmat", columns: ["senmat"] },
220
- { name: "idx_typmancod", columns: ["typmancod"] },
221
- ],
222
- },
223
- mergeKeys: {
224
- activite: ["actid"],
225
- },
226
- },
227
- };
228
- function getEnabledDatasetByName(datasetName) {
229
- const enabledDataset = EnabledDatasets[datasetName];
230
- return typeof enabledDataset === "number" ? enabledDataset : undefined;
231
- }
232
- export function getEnabledDatasets(categories) {
233
- categories.map((datasetName) => assert.notStrictEqual(getEnabledDatasetByName(datasetName), undefined, `Unknown name of dataset: ${datasetName}`));
234
- return categories.reduce((enabledDatasets, datasetName) => {
235
- const enabledDataset = getEnabledDatasetByName(datasetName);
236
- return enabledDatasets | (enabledDataset || EnabledDatasets.None);
237
- }, EnabledDatasets.None);
238
- }
239
- export function getChosenDatasets(enabledDatasets) {
240
- return [
241
- enabledDatasets & EnabledDatasets.Ameli ? datasets.ameli : null,
242
- enabledDatasets & EnabledDatasets.Debats ? datasets.debats : null,
243
- enabledDatasets & EnabledDatasets.DosLeg ? datasets.dosleg : null,
244
- enabledDatasets & EnabledDatasets.Questions ? datasets.questions : null,
245
- enabledDatasets & EnabledDatasets.Sens ? datasets.sens : null,
246
- ].filter((dataset) => dataset !== null);
247
- }
package/lib/src/git.d.ts DELETED
@@ -1,27 +0,0 @@
1
- export declare function initRepo(repositoryDir: string): void;
2
- export declare function commit(repositoryDir: string, message: string): boolean;
3
- export declare function commitAndPush(repositoryDir: string, message: string, remotes?: string[]): number;
4
- export declare function pull(repositoryDir: string, remote?: string, branch?: string): boolean;
5
- export declare function resetAndPull(gitDir: string): boolean;
6
- export declare function clone(gitGroupUrl: string | undefined, gitName: string, workingDir: string): void;
7
- export declare function run(repositoryDir: string, args: string, verbose?: boolean): string;
8
- export declare function test(repositoryDir: string, args: string, verbose?: boolean): boolean;
9
- /**
10
- * Information about a changed file in git
11
- */
12
- export interface GitChangedFile {
13
- path: string;
14
- status: "A" | "M" | "D" | "R" | "C" | "T" | "U";
15
- }
16
- /**
17
- * Get the list of files that have changed since a specific commit in a git repository.
18
- * @param repositoryDir The directory of the git repository
19
- * @param sinceCommit The commit hash to compare against (e.g., "HEAD~1", "abc123", etc.)
20
- * @param options Options for filtering
21
- * @param options.diffFilter Git diff-filter string (default: "AMR").
22
- * A=Added, M=Modified, D=Deleted, R=Renamed, C=Copied, T=Type changed, U=Unmerged
23
- * @returns A Map of file paths to their git status
24
- */
25
- export declare function getChangedFilesSinceCommit(repositoryDir: string, sinceCommit: string, options?: {
26
- diffFilter?: string;
27
- }): Map<string, GitChangedFile["status"]>;