@tricoteuses/senat 1.3.4 → 1.4.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.
Files changed (46) hide show
  1. package/README.md +1 -3
  2. package/lib/config.js +4 -6
  3. package/lib/databases.js +34 -75
  4. package/lib/datasets.js +20 -28
  5. package/lib/index.d.ts +0 -3
  6. package/lib/index.js +1 -43
  7. package/lib/loaders.js +56 -74
  8. package/lib/model/ameli.d.ts +2 -2
  9. package/lib/model/ameli.js +22 -17
  10. package/lib/model/dosleg.js +47 -52
  11. package/lib/model/index.js +4 -13
  12. package/lib/model/questions.js +15 -18
  13. package/lib/model/sens.js +65 -71
  14. package/lib/model/texte.js +17 -25
  15. package/lib/model/util.js +13 -21
  16. package/lib/raw_types/ameli.js +1 -2
  17. package/lib/raw_types/debats.js +1 -2
  18. package/lib/raw_types/dosleg.js +1 -2
  19. package/lib/raw_types/questions.js +1 -2
  20. package/lib/raw_types/sens.js +1 -2
  21. package/lib/raw_types_schemats/ameli.js +1 -2
  22. package/lib/raw_types_schemats/debats.js +1 -2
  23. package/lib/raw_types_schemats/dosleg.js +1 -2
  24. package/lib/raw_types_schemats/questions.js +1 -2
  25. package/lib/raw_types_schemats/sens.js +1 -2
  26. package/lib/scripts/convert_data.js +78 -83
  27. package/lib/scripts/datautil.js +9 -13
  28. package/lib/scripts/parse_textes.js +23 -28
  29. package/lib/scripts/retrieve_documents.js +56 -61
  30. package/lib/scripts/retrieve_open_data.js +44 -49
  31. package/lib/scripts/retrieve_senateurs_photos.js +31 -36
  32. package/lib/scripts/shared/cli_helpers.js +9 -12
  33. package/lib/scripts/shared/util.js +7 -15
  34. package/lib/strings.js +4 -10
  35. package/lib/types/ameli.d.ts +0 -5
  36. package/lib/types/ameli.js +1 -16
  37. package/lib/types/debats.d.ts +0 -2
  38. package/lib/types/debats.js +1 -5
  39. package/lib/types/dosleg.d.ts +0 -28
  40. package/lib/types/dosleg.js +1 -154
  41. package/lib/types/questions.js +1 -2
  42. package/lib/types/sens.js +1 -2
  43. package/lib/types/sessions.js +2 -5
  44. package/lib/types/texte.js +2 -5
  45. package/lib/validators/config.js +4 -7
  46. package/package.json +2 -2
@@ -1,25 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const assert_1 = __importDefault(require("assert"));
7
- const child_process_1 = require("child_process");
8
- const command_line_args_1 = __importDefault(require("command-line-args"));
9
- const fs_extra_1 = __importDefault(require("fs-extra"));
1
+ import assert from "assert";
2
+ import { execSync } from "child_process";
3
+ import commandLineArgs from "command-line-args";
4
+ import fs from "fs-extra";
10
5
  // import fetch from "node-fetch"
11
- const path_1 = __importDefault(require("path"));
6
+ import path from "path";
12
7
  // import stream from "stream"
13
- const node_stream_zip_1 = __importDefault(require("node-stream-zip"));
14
- const readline_1 = __importDefault(require("readline"));
8
+ import StreamZip from "node-stream-zip";
9
+ import readline from "readline";
15
10
  // import util from "util"
16
- const windows_1252_1 = __importDefault(require("windows-1252"));
17
- const config_1 = __importDefault(require("../config"));
18
- const datasets_1 = require("../datasets");
19
- const cli_helpers_1 = require("./shared/cli_helpers");
11
+ import windows1252 from "windows-1252";
12
+ import config from "../config";
13
+ import { datasets, getChosenFromEnabledDatasets } from "../datasets";
14
+ import { commonOptions } from "./shared/cli_helpers";
20
15
  const badWindows1252CharacterRegex = /[\u0080-\u009f]/g;
21
16
  const optionsDefinitions = [
22
- ...cli_helpers_1.commonOptions,
17
+ ...commonOptions,
23
18
  {
24
19
  alias: "a",
25
20
  help: "all options: fetch, unzip, repair-encoding, import",
@@ -63,11 +58,11 @@ const optionsDefinitions = [
63
58
  type: Boolean,
64
59
  },
65
60
  ];
66
- const options = (0, command_line_args_1.default)(optionsDefinitions);
61
+ const options = commandLineArgs(optionsDefinitions);
67
62
  // const pipeline = util.promisify(stream.pipeline)
68
63
  async function retrieveDataset(dataDir, dataset) {
69
64
  const zipFilename = dataset.url.substring(dataset.url.lastIndexOf("/") + 1);
70
- const zipFilePath = path_1.default.join(dataDir, zipFilename);
65
+ const zipFilePath = path.join(dataDir, zipFilename);
71
66
  if (options["all"] || options["fetch"]) {
72
67
  // Fetch & save ZIP file.
73
68
  if (!options["silent"]) {
@@ -82,8 +77,8 @@ async function retrieveDataset(dataDir, dataset) {
82
77
  // throw new Error(`Fetch failed: ${dataset.url}`)
83
78
  // }
84
79
  // await pipeline(response.body!, fs.createWriteStream(zipFilePath))
85
- fs_extra_1.default.removeSync(zipFilePath);
86
- (0, child_process_1.execSync)(`wget --quiet ${dataset.url}`, {
80
+ fs.removeSync(zipFilePath);
81
+ execSync(`wget --quiet ${dataset.url}`, {
87
82
  cwd: dataDir,
88
83
  env: process.env,
89
84
  encoding: "utf-8",
@@ -91,13 +86,13 @@ async function retrieveDataset(dataDir, dataset) {
91
86
  });
92
87
  }
93
88
  const sqlFilename = `${dataset.database}.sql`;
94
- const sqlFilePath = path_1.default.join(dataDir, sqlFilename);
89
+ const sqlFilePath = path.join(dataDir, sqlFilename);
95
90
  if (options["all"] || options["unzip"]) {
96
91
  if (!options["silent"]) {
97
92
  console.log(`Unzipping ${dataset.title}: ${zipFilename}…`);
98
93
  }
99
- fs_extra_1.default.removeSync(sqlFilePath);
100
- const zip = new node_stream_zip_1.default({
94
+ fs.removeSync(sqlFilePath);
95
+ const zip = new StreamZip({
101
96
  file: zipFilePath,
102
97
  storeEntries: true,
103
98
  });
@@ -126,24 +121,24 @@ async function retrieveDataset(dataDir, dataset) {
126
121
  console.log(`Repairing Windows CP1252 encoding of ${dataset.title}: ${sqlFilename}…`);
127
122
  }
128
123
  const repairedSqlFilePath = sqlFilePath + ".repaired";
129
- const repairedSqlWriter = fs_extra_1.default.createWriteStream(repairedSqlFilePath, {
124
+ const repairedSqlWriter = fs.createWriteStream(repairedSqlFilePath, {
130
125
  encoding: "utf8",
131
126
  });
132
- const lineReader = readline_1.default.createInterface({
133
- input: fs_extra_1.default.createReadStream(sqlFilePath, { encoding: "utf8" }),
127
+ const lineReader = readline.createInterface({
128
+ input: fs.createReadStream(sqlFilePath, { encoding: "utf8" }),
134
129
  crlfDelay: Infinity,
135
130
  });
136
131
  for await (const line of lineReader) {
137
- repairedSqlWriter.write(line.replace(badWindows1252CharacterRegex, (match) => windows_1252_1.default.decode(match, { mode: "fatal" })) + "\n");
132
+ repairedSqlWriter.write(line.replace(badWindows1252CharacterRegex, (match) => windows1252.decode(match, { mode: "fatal" })) + "\n");
138
133
  }
139
134
  repairedSqlWriter.end();
140
- await fs_extra_1.default.move(repairedSqlFilePath, sqlFilePath, { overwrite: true });
135
+ await fs.move(repairedSqlFilePath, sqlFilePath, { overwrite: true });
141
136
  }
142
137
  if (options["all"] || options["import"] || options["schema"]) {
143
138
  if (!options["silent"]) {
144
139
  console.log(`Importing ${dataset.title}: ${sqlFilename}…`);
145
140
  }
146
- (0, child_process_1.execSync)(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -d ${dataset.database} -f ${sqlFilename}`, {
141
+ execSync(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -d ${dataset.database} -f ${sqlFilename}`, {
147
142
  cwd: dataDir,
148
143
  env: process.env,
149
144
  encoding: "utf-8",
@@ -151,27 +146,27 @@ async function retrieveDataset(dataDir, dataset) {
151
146
  });
152
147
  }
153
148
  if (options["schema"]) {
154
- let definitionsDir = path_1.default.resolve("src", "raw_types_schemats");
155
- (0, assert_1.default)(fs_extra_1.default.statSync(definitionsDir).isDirectory());
149
+ let definitionsDir = path.resolve("src", "raw_types_schemats");
150
+ assert(fs.statSync(definitionsDir).isDirectory());
156
151
  if (!options["silent"]) {
157
152
  console.log(`Creating TypeScript definitions from schema of database ${dataset.database}…`);
158
153
  }
159
154
  const dbConnectionString = `postgres://${process.env["PGUSER"]}:${process.env["PGPASSWORD"]}@${process.env["PGHOST"]}:${process.env["PGPORT"]}/${dataset.database}`;
160
- let definitionFilePath = path_1.default.join(definitionsDir, `${dataset.database}.ts`);
161
- (0, child_process_1.execSync)(`npx schemats generate -c ${dbConnectionString} -s ${dataset.schema} -o ${definitionFilePath}`, {
155
+ let definitionFilePath = path.join(definitionsDir, `${dataset.database}.ts`);
156
+ execSync(`npx schemats generate -c ${dbConnectionString} -s ${dataset.schema} -o ${definitionFilePath}`, {
162
157
  // cwd: dataDir,
163
158
  env: process.env,
164
159
  encoding: "utf-8",
165
160
  // stdio: ["ignore", "ignore", "pipe"],
166
161
  });
167
- const definition = fs_extra_1.default.readFileSync(definitionFilePath, { encoding: "utf8" });
162
+ const definition = fs.readFileSync(definitionFilePath, { encoding: "utf8" });
168
163
  const definitionRepaired = definition
169
164
  .replace(/\r\n/g, "\n")
170
165
  .replace(/AUTO-GENERATED FILE @ \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/, "AUTO-GENERATED FILE");
171
- fs_extra_1.default.writeFileSync(definitionFilePath, definitionRepaired);
172
- definitionsDir = path_1.default.resolve("src", "raw_types");
173
- definitionFilePath = path_1.default.join(definitionsDir, `${dataset.database}.ts`);
174
- (0, child_process_1.execSync)(`kysely-codegen --url ${dbConnectionString} --default-schema=${dataset.schema} --out-file=${definitionFilePath}`, {
166
+ fs.writeFileSync(definitionFilePath, definitionRepaired);
167
+ definitionsDir = path.resolve("src", "raw_types");
168
+ definitionFilePath = path.join(definitionsDir, `${dataset.database}.ts`);
169
+ execSync(`kysely-codegen --url ${dbConnectionString} --default-schema=${dataset.schema} --out-file=${definitionFilePath}`, {
175
170
  // cwd: dataDir,
176
171
  env: process.env,
177
172
  encoding: "utf-8",
@@ -181,32 +176,32 @@ async function retrieveDataset(dataDir, dataset) {
181
176
  }
182
177
  async function retrieveOpenData() {
183
178
  const dataDir = options["dataDir"];
184
- (0, assert_1.default)(dataDir, "Missing argument: data directory");
179
+ assert(dataDir, "Missing argument: data directory");
185
180
  process.env = {
186
181
  ...process.env,
187
- PGHOST: process.env["PGHOST"] || config_1.default.db.host,
188
- PGPORT: process.env["PGPORT"] || config_1.default.db.port,
189
- PGUSER: process.env["PGUSER"] || config_1.default.db.user,
190
- PGPASSWORD: process.env["PGPASSWORD"] || config_1.default.db.password,
182
+ PGHOST: process.env["PGHOST"] || config.db.host,
183
+ PGPORT: process.env["PGPORT"] || config.db.port,
184
+ PGUSER: process.env["PGUSER"] || config.db.user,
185
+ PGPASSWORD: process.env["PGPASSWORD"] || config.db.password,
191
186
  };
192
- (0, assert_1.default)(process.env["PGHOST"] &&
187
+ assert(process.env["PGHOST"] &&
193
188
  process.env["PGPORT"] &&
194
189
  process.env["PGUSER"] &&
195
190
  process.env["PGPASSWORD"], "Missing database configuration: environment variables PGHOST, PGPORT, PGUSER and PGPASSWORD or TRICOTEUSES_SENAT_DB_* in .env file");
196
191
  console.time("data extraction time");
197
- for (const [, dataset] of Object.entries(datasets_1.datasets)) {
198
- (0, child_process_1.execSync)(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -c "DROP DATABASE IF EXISTS ${dataset.database}"`, {
192
+ for (const [, dataset] of Object.entries(datasets)) {
193
+ execSync(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -c "DROP DATABASE IF EXISTS ${dataset.database}"`, {
199
194
  cwd: dataDir,
200
195
  env: process.env,
201
196
  encoding: "utf-8",
202
197
  });
203
- (0, child_process_1.execSync)(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -c "CREATE DATABASE ${dataset.database} WITH OWNER opendata"`, {
198
+ execSync(`${options["sudo"] ? `sudo -u ${options["sudo"]} ` : ""}psql --quiet -c "CREATE DATABASE ${dataset.database} WITH OWNER opendata"`, {
204
199
  cwd: dataDir,
205
200
  env: process.env,
206
201
  encoding: "utf-8",
207
202
  });
208
203
  }
209
- const choosenDatasets = (0, datasets_1.getChosenFromEnabledDatasets)(options["categories"]);
204
+ const choosenDatasets = getChosenFromEnabledDatasets(options["categories"]);
210
205
  for (const dataset of choosenDatasets) {
211
206
  await retrieveDataset(dataDir, dataset);
212
207
  }
@@ -1,21 +1,16 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const assert_1 = __importDefault(require("assert"));
7
- const child_process_1 = require("child_process");
8
- const command_line_args_1 = __importDefault(require("command-line-args"));
9
- const fs_extra_1 = __importDefault(require("fs-extra"));
1
+ import assert from "assert";
2
+ import { execSync } from "child_process";
3
+ import commandLineArgs from "command-line-args";
4
+ import fs from "fs-extra";
10
5
  // import fetch from "node-fetch"
11
- const path_1 = __importDefault(require("path"));
6
+ import path from "path";
12
7
  // import stream from "stream"
13
8
  // import util from "util"
14
- const sens_1 = require("../model/sens");
15
- const strings_1 = require("../strings");
16
- const cli_helpers_1 = require("./shared/cli_helpers");
9
+ import { findActif as findActifSenateurs } from "../model/sens";
10
+ import { slugify } from "../strings";
11
+ import { commonOptions } from "./shared/cli_helpers";
17
12
  const optionsDefinitions = [
18
- ...cli_helpers_1.commonOptions,
13
+ ...commonOptions,
19
14
  {
20
15
  alias: "f",
21
16
  help: "fetch sénateurs' pictures instead of retrieving them from files",
@@ -23,23 +18,23 @@ const optionsDefinitions = [
23
18
  type: Boolean,
24
19
  },
25
20
  ];
26
- const options = (0, command_line_args_1.default)(optionsDefinitions);
21
+ const options = commandLineArgs(optionsDefinitions);
27
22
  // const pipeline = util.promisify(stream.pipeline)
28
23
  async function retrievePhotosSenateurs() {
29
24
  const dataDir = options["dataDir"];
30
- (0, assert_1.default)(dataDir, "Missing argument: data directory");
31
- const photosDir = path_1.default.join(dataDir, "photos_senateurs");
32
- const missingPhotoFilePath = path_1.default.resolve(__dirname, "images", "transparent_155x225.jpg");
33
- const sens = await Array.fromAsync((0, sens_1.findActif)());
25
+ assert(dataDir, "Missing argument: data directory");
26
+ const photosDir = path.join(dataDir, "photos_senateurs");
27
+ const missingPhotoFilePath = path.resolve(__dirname, "images", "transparent_155x225.jpg");
28
+ const sens = await Array.fromAsync(findActifSenateurs());
34
29
  // Download photos.
35
- fs_extra_1.default.ensureDirSync(photosDir);
30
+ fs.ensureDirSync(photosDir);
36
31
  if (options["fetch"]) {
37
32
  for (const sen of sens) {
38
- const photoStem = `${(0, strings_1.slugify)(sen.sennomuse, "_")}_${(0, strings_1.slugify)(sen.senprenomuse, "_")}${(0, strings_1.slugify)(sen.senmat, "_")}`;
33
+ const photoStem = `${slugify(sen.sennomuse, "_")}_${slugify(sen.senprenomuse, "_")}${slugify(sen.senmat, "_")}`;
39
34
  const photoFilename = photoStem + ".jpg";
40
- const photoFilePath = path_1.default.join(photosDir, photoFilename);
35
+ const photoFilePath = path.join(photosDir, photoFilename);
41
36
  const photoTempFilename = photoStem + "_temp.jpg";
42
- const photoTempFilePath = path_1.default.join(photosDir, photoTempFilename);
37
+ const photoTempFilePath = path.join(photosDir, photoTempFilename);
43
38
  const urlPhoto = `https://www.senat.fr/senimg/${photoFilename}`;
44
39
  if (!options["silent"]) {
45
40
  console.log(`Loading photo ${urlPhoto} for ${sen.senprenomuse} ${sen.sennomuse}…`);
@@ -67,13 +62,13 @@ async function retrievePhotosSenateurs() {
67
62
  // }
68
63
  // }
69
64
  try {
70
- (0, child_process_1.execSync)(`wget --quiet -O ${photoTempFilename} ${urlPhoto}`, {
65
+ execSync(`wget --quiet -O ${photoTempFilename} ${urlPhoto}`, {
71
66
  cwd: photosDir,
72
67
  env: process.env,
73
68
  encoding: "utf-8",
74
69
  // stdio: ["ignore", "ignore", "pipe"],
75
70
  });
76
- fs_extra_1.default.renameSync(photoTempFilePath, photoFilePath);
71
+ fs.renameSync(photoTempFilePath, photoFilePath);
77
72
  }
78
73
  catch (error) {
79
74
  if (typeof error === "object" &&
@@ -89,14 +84,14 @@ async function retrievePhotosSenateurs() {
89
84
  }
90
85
  // Resize photos to 155x225, because some haven't exactly this size.
91
86
  for (const sen of sens) {
92
- const photoStem = `${(0, strings_1.slugify)(sen.sennomuse, "_")}_${(0, strings_1.slugify)(sen.senprenomuse, "_")}${(0, strings_1.slugify)(sen.senmat, "_")}`;
87
+ const photoStem = `${slugify(sen.sennomuse, "_")}_${slugify(sen.senprenomuse, "_")}${slugify(sen.senmat, "_")}`;
93
88
  const photoFilename = photoStem + ".jpg";
94
- const photoFilePath = path_1.default.join(photosDir, photoFilename);
95
- if (fs_extra_1.default.existsSync(photoFilePath)) {
89
+ const photoFilePath = path.join(photosDir, photoFilename);
90
+ if (fs.existsSync(photoFilePath)) {
96
91
  if (!options["silent"]) {
97
92
  console.log(`Resizing photo ${photoStem} for ${sen.senprenomuse} ${sen.sennomuse}…`);
98
93
  }
99
- (0, child_process_1.execSync)(`gm convert -resize 155x225! ${photoStem}.jpg ${photoStem}_155x225.jpg`, {
94
+ execSync(`gm convert -resize 155x225! ${photoStem}.jpg ${photoStem}_155x225.jpg`, {
100
95
  cwd: photosDir,
101
96
  });
102
97
  }
@@ -104,7 +99,7 @@ async function retrievePhotosSenateurs() {
104
99
  if (!options["silent"]) {
105
100
  console.warn(`Missing photo for ${sen.senprenomuse} ${sen.sennomuse}: using blank image`);
106
101
  }
107
- fs_extra_1.default.copyFileSync(missingPhotoFilePath, path_1.default.join(photosDir, `${photoStem}_155x225.jpg`));
102
+ fs.copyFileSync(missingPhotoFilePath, path.join(photosDir, `${photoStem}_155x225.jpg`));
108
103
  }
109
104
  }
110
105
  // Create a mosaic of photos.
@@ -117,7 +112,7 @@ async function retrievePhotosSenateurs() {
117
112
  const row = sens.slice(senIndex, senIndex + 25);
118
113
  const photosFilenames = [];
119
114
  for (const [columnIndex, sen] of row.entries()) {
120
- const photoStem = `${(0, strings_1.slugify)(sen.sennomuse, "_")}_${(0, strings_1.slugify)(sen.senprenomuse, "_")}${(0, strings_1.slugify)(sen.senmat, "_")}`;
115
+ const photoStem = `${slugify(sen.sennomuse, "_")}_${slugify(sen.senprenomuse, "_")}${slugify(sen.senmat, "_")}`;
121
116
  const photoFilename = `${photoStem}_155x225.jpg`;
122
117
  photosFilenames.push(photoFilename);
123
118
  photoBySenmat[sen.senmat] = {
@@ -130,22 +125,22 @@ async function retrievePhotosSenateurs() {
130
125
  };
131
126
  }
132
127
  const rowFilename = `row-${rowIndex}.jpg`;
133
- (0, child_process_1.execSync)(`gm convert ${photosFilenames.join(" ")} +append ${rowFilename}`, {
128
+ execSync(`gm convert ${photosFilenames.join(" ")} +append ${rowFilename}`, {
134
129
  cwd: photosDir,
135
130
  });
136
131
  rowsFilenames.push(rowFilename);
137
132
  }
138
- (0, child_process_1.execSync)(`gm convert ${rowsFilenames.join(" ")} -append senateurs.jpg`, {
133
+ execSync(`gm convert ${rowsFilenames.join(" ")} -append senateurs.jpg`, {
139
134
  cwd: photosDir,
140
135
  });
141
136
  for (const rowFilename of rowsFilenames) {
142
- fs_extra_1.default.unlinkSync(path_1.default.join(photosDir, rowFilename));
137
+ fs.unlinkSync(path.join(photosDir, rowFilename));
143
138
  }
144
139
  if (!options["silent"]) {
145
140
  console.log("Creating JSON file containing informations on all pictures…");
146
141
  }
147
- const jsonFilePath = path_1.default.join(photosDir, "senateurs.json");
148
- fs_extra_1.default.writeFileSync(jsonFilePath, JSON.stringify(photoBySenmat, null, 2));
142
+ const jsonFilePath = path.join(photosDir, "senateurs.json");
143
+ fs.writeFileSync(jsonFilePath, JSON.stringify(photoBySenmat, null, 2));
149
144
  }
150
145
  retrievePhotosSenateurs()
151
146
  .then(() => process.exit(0))
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.commonOptions = exports.verboseOption = exports.silentOption = exports.dataDirDefaultOption = exports.categoriesOption = void 0;
4
- exports.categoriesOption = {
1
+ export const categoriesOption = {
5
2
  alias: "k",
6
3
  defaultValue: ["All"],
7
4
  help: "categories of datasets to reorganize",
@@ -9,27 +6,27 @@ exports.categoriesOption = {
9
6
  name: "categories",
10
7
  type: String,
11
8
  };
12
- exports.dataDirDefaultOption = {
9
+ export const dataDirDefaultOption = {
13
10
  defaultOption: true,
14
11
  help: "directory containing Sénat open data files",
15
12
  name: "dataDir",
16
13
  type: String,
17
14
  };
18
- exports.silentOption = {
15
+ export const silentOption = {
19
16
  alias: "s",
20
17
  help: "don't log anything",
21
18
  name: "silent",
22
19
  type: Boolean,
23
20
  };
24
- exports.verboseOption = {
21
+ export const verboseOption = {
25
22
  alias: "v",
26
23
  help: "verbose logs",
27
24
  name: "verbose",
28
25
  type: Boolean,
29
26
  };
30
- exports.commonOptions = [
31
- exports.categoriesOption,
32
- exports.dataDirDefaultOption,
33
- exports.silentOption,
34
- exports.verboseOption,
27
+ export const commonOptions = [
28
+ categoriesOption,
29
+ dataDirDefaultOption,
30
+ silentOption,
31
+ verboseOption,
35
32
  ];
@@ -1,24 +1,16 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isOptionEmptyOrHasValue = isOptionEmptyOrHasValue;
7
- exports.ensureAndClearDir = ensureAndClearDir;
8
- exports.fetchWithRetry = fetchWithRetry;
9
- const fs_extra_1 = __importDefault(require("fs-extra"));
10
- function isOptionEmptyOrHasValue(option, value) {
1
+ import fs from "fs-extra";
2
+ export function isOptionEmptyOrHasValue(option, value) {
11
3
  return !option || option.length === 0 || option.includes(value);
12
4
  }
13
- function ensureAndClearDir(path) {
14
- if (!fs_extra_1.default.existsSync(path)) {
15
- fs_extra_1.default.mkdirSync(path, { recursive: true });
5
+ export function ensureAndClearDir(path) {
6
+ if (!fs.existsSync(path)) {
7
+ fs.mkdirSync(path, { recursive: true });
16
8
  }
17
9
  else {
18
- fs_extra_1.default.emptyDirSync(path);
10
+ fs.emptyDirSync(path);
19
11
  }
20
12
  }
21
- async function fetchWithRetry(url, retries = 3, backoff = 300) {
13
+ export async function fetchWithRetry(url, retries = 3, backoff = 300) {
22
14
  for (let attempt = 0; attempt < retries; attempt++) {
23
15
  try {
24
16
  return await fetch(url);
package/lib/strings.js CHANGED
@@ -1,18 +1,12 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.slugify = slugify;
7
- const slug_1 = __importDefault(require("slug"));
1
+ import originalSlugify from "slug";
8
2
  const slugifyCharmap = {
9
- ...slug_1.default.defaults.charmap,
3
+ ...originalSlugify.defaults.charmap,
10
4
  "'": " ",
11
5
  "@": " ",
12
6
  ".": " ",
13
7
  "-": "_",
14
8
  };
15
- function slugify(string, replacement) {
9
+ export function slugify(string, replacement) {
16
10
  const options = {
17
11
  charmap: slugifyCharmap,
18
12
  mode: "rfc3986",
@@ -20,5 +14,5 @@ function slugify(string, replacement) {
20
14
  if (replacement) {
21
15
  options.replacement = replacement;
22
16
  }
23
- return (0, slug_1.default)(string, options);
17
+ return originalSlugify(string, options);
24
18
  }
@@ -3,8 +3,3 @@ export type { Ses, Sub };
3
3
  export interface TxtAmeli extends txt_ameli {
4
4
  subids?: subFields.id[];
5
5
  }
6
- export declare const sesFieldsToParseInt: string[];
7
- export declare const sesFieldsToTrim: string[];
8
- export declare const subFieldsToParseInt: string[];
9
- export declare const subFieldsToTrim: string[];
10
- export declare const txtAmeliFieldsToTrim: string[];
@@ -1,16 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.txtAmeliFieldsToTrim = exports.subFieldsToTrim = exports.subFieldsToParseInt = exports.sesFieldsToTrim = exports.sesFieldsToParseInt = void 0;
4
- exports.sesFieldsToParseInt = ["ann"];
5
- exports.sesFieldsToTrim = ["lil"];
6
- exports.subFieldsToParseInt = ["pos", "posder", "prires"];
7
- exports.subFieldsToTrim = ["lic", "lib", "sig", "style"];
8
- exports.txtAmeliFieldsToTrim = [
9
- "num",
10
- "int",
11
- "inl",
12
- "libdelim",
13
- "libcplnat",
14
- "doslegsignet",
15
- "ordsnddelib",
16
- ];
1
+ export {};
@@ -1,4 +1,2 @@
1
1
  import { debats as Debat, lecassdeb as LecAssDeb } from "../raw_types_schemats/debats";
2
2
  export type { Debat, LecAssDeb };
3
- export declare const debatsFieldsToTrim: string[];
4
- export declare const lecassdebFieldsToTrim: string[];
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lecassdebFieldsToTrim = exports.debatsFieldsToTrim = void 0;
4
- exports.debatsFieldsToTrim = ["deburl", "libspec"];
5
- exports.lecassdebFieldsToTrim = ["lecassidt"];
1
+ export {};
@@ -68,31 +68,3 @@ export interface Texte extends texte {
68
68
  txtAmeli?: TxtAmeli;
69
69
  txtAmeliId: txt_ameliFields.id;
70
70
  }
71
- export declare const assFieldsToTrim: string[];
72
- export declare const audFieldsToTrim: string[];
73
- export declare const auteurFieldsToTrim: string[];
74
- export declare const dateSeanceFieldsToTrim: string[];
75
- export declare const deccocFieldsToTrim: string[];
76
- export declare const denrapFieldsToTrim: string[];
77
- export declare const docattFieldsToParseInt: string[];
78
- export declare const docattFieldsToTrim: string[];
79
- export declare const ecrFieldsToTrim: string[];
80
- export declare const etaloiFieldsToTrim: string[];
81
- export declare const lecassFieldsToTrim: string[];
82
- export declare const lecassrapFieldsToTrim: string[];
83
- export declare const lectureFieldsToTrim: string[];
84
- export declare const loiFieldsToTrim: string[];
85
- export declare const orgFieldsToTrim: string[];
86
- export declare const oritxtFieldsToTrim: string[];
87
- export declare const quaFieldsToTrim: string[];
88
- export declare const rapFieldsToParseInt: string[];
89
- export declare const rapFieldsToTrim: string[];
90
- export declare const raporgFieldsToTrim: string[];
91
- export declare const scrFieldsToTrim: string[];
92
- export declare const texteFieldsToParseInt: string[];
93
- export declare const texteFieldsToTrim: string[];
94
- export declare const typattFieldsToTrim: string[];
95
- export declare const typlecFieldsToTrim: string[];
96
- export declare const typloiFieldsToTrim: string[];
97
- export declare const typtxtFieldsToTrim: string[];
98
- export declare const typurlFieldsToTrim: string[];