@tricoteuses/senat 1.3.1 → 1.3.2
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 +1 -0
- package/lib/config.js +14 -45
- package/lib/databases.js +86 -143
- package/lib/datasets.js +78 -83
- package/lib/index.d.ts +7 -4
- package/lib/index.js +42 -419
- package/lib/loaders.js +149 -654
- package/lib/model/ameli.js +83 -21
- package/lib/model/debats.js +0 -1
- package/lib/model/dosleg.d.ts +1 -1
- package/lib/model/dosleg.js +179 -73
- package/lib/model/index.d.ts +3 -3
- package/lib/model/index.js +12 -46
- package/lib/model/questions.js +68 -39
- package/lib/model/sens.js +383 -113
- package/lib/model/texte.js +220 -290
- package/lib/model/util.js +9 -26
- package/lib/raw_types/ameli.js +5 -6
- package/lib/raw_types/debats.js +5 -6
- package/lib/raw_types/dosleg.js +5 -6
- package/lib/raw_types/questions.js +5 -6
- package/lib/raw_types/sens.js +5 -6
- package/lib/raw_types_schemats/ameli.js +1 -43
- package/lib/raw_types_schemats/debats.js +1 -22
- package/lib/raw_types_schemats/dosleg.js +1 -96
- package/lib/raw_types_schemats/questions.js +1 -22
- package/lib/raw_types_schemats/sens.js +1 -112
- package/lib/scripts/convert_data.js +181 -631
- package/lib/scripts/datautil.js +17 -60
- package/lib/scripts/parse_textes.js +46 -129
- package/lib/scripts/retrieve_documents.js +247 -513
- package/lib/scripts/retrieve_open_data.js +211 -368
- package/lib/scripts/retrieve_senateurs_photos.js +144 -239
- package/lib/scripts/shared/cli_helpers.js +30 -30
- package/lib/scripts/shared/util.js +28 -94
- package/lib/strings.js +20 -45
- package/lib/types/ameli.d.ts +1 -1
- package/lib/types/ameli.js +14 -25
- package/lib/types/debats.d.ts +1 -1
- package/lib/types/debats.js +3 -21
- package/lib/types/dosleg.d.ts +1 -1
- package/lib/types/dosleg.js +152 -119
- package/lib/types/questions.d.ts +1 -1
- package/lib/types/questions.js +1 -13
- package/lib/types/sens.d.ts +1 -1
- package/lib/types/sens.js +1 -13
- package/lib/types/sessions.js +44 -49
- package/lib/types/texte.js +17 -22
- package/lib/validators/config.js +47 -111
- package/lib/validators/senat.js +1 -5
- package/package.json +16 -38
- package/lib/aggregates.d.ts +0 -52
- package/lib/aggregates.mjs +0 -930
- package/lib/aggregates.ts +0 -833
- package/lib/config.mjs +0 -16
- package/lib/config.ts +0 -26
- package/lib/data/legislatures.json +0 -38
- package/lib/databases.mjs +0 -57
- package/lib/databases.ts +0 -71
- package/lib/datasets.mjs +0 -78
- package/lib/datasets.ts +0 -118
- package/lib/fields.d.ts +0 -10
- package/lib/fields.mjs +0 -68
- package/lib/fields.ts +0 -29
- package/lib/index.mjs +0 -4
- package/lib/index.ts +0 -42
- package/lib/inserters.d.ts +0 -98
- package/lib/inserters.mjs +0 -500
- package/lib/inserters.ts +0 -521
- package/lib/loaders.mjs +0 -158
- package/lib/loaders.ts +0 -271
- package/lib/model/ameli.mjs +0 -84
- package/lib/model/ameli.ts +0 -100
- package/lib/model/debats.mjs +0 -1
- package/lib/model/debats.ts +0 -0
- package/lib/model/dosleg.mjs +0 -196
- package/lib/model/dosleg.ts +0 -240
- package/lib/model/index.mjs +0 -4
- package/lib/model/index.ts +0 -14
- package/lib/model/questions.mjs +0 -71
- package/lib/model/questions.ts +0 -93
- package/lib/model/sens.mjs +0 -415
- package/lib/model/sens.ts +0 -516
- package/lib/model/texte.mjs +0 -208
- package/lib/model/texte.ts +0 -229
- package/lib/model/util.mjs +0 -19
- package/lib/model/util.ts +0 -32
- package/lib/raw_types/ameli.mjs +0 -5
- package/lib/raw_types/ameli.ts +0 -951
- package/lib/raw_types/debats.mjs +0 -5
- package/lib/raw_types/debats.ts +0 -222
- package/lib/raw_types/dosleg.mjs +0 -5
- package/lib/raw_types/dosleg.ts +0 -3625
- package/lib/raw_types/questions.mjs +0 -5
- package/lib/raw_types/questions.ts +0 -427
- package/lib/raw_types/sens.mjs +0 -5
- package/lib/raw_types/sens.ts +0 -4499
- package/lib/raw_types_kysely/ameli.d.ts +0 -6
- package/lib/raw_types_kysely/ameli.mjs +0 -7
- package/lib/raw_types_kysely/ameli.ts +0 -6
- package/lib/raw_types_kysely/debats.d.ts +0 -6
- package/lib/raw_types_kysely/debats.mjs +0 -7
- package/lib/raw_types_kysely/debats.ts +0 -6
- package/lib/raw_types_kysely/dosleg.d.ts +0 -6
- package/lib/raw_types_kysely/dosleg.mjs +0 -7
- package/lib/raw_types_kysely/dosleg.ts +0 -6
- package/lib/raw_types_kysely/questions.d.ts +0 -6
- package/lib/raw_types_kysely/questions.mjs +0 -7
- package/lib/raw_types_kysely/questions.ts +0 -6
- package/lib/raw_types_kysely/sens.d.ts +0 -6
- package/lib/raw_types_kysely/sens.mjs +0 -7
- package/lib/raw_types_kysely/sens.ts +0 -6
- package/lib/raw_types_kysely/texte.d.ts +0 -45
- package/lib/raw_types_kysely/texte.mjs +0 -7
- package/lib/raw_types_kysely/texte.ts +0 -53
- package/lib/raw_types_schemats/ameli.mjs +0 -2
- package/lib/raw_types_schemats/ameli.ts +0 -601
- package/lib/raw_types_schemats/debats.mjs +0 -2
- package/lib/raw_types_schemats/debats.ts +0 -145
- package/lib/raw_types_schemats/dosleg.mjs +0 -2
- package/lib/raw_types_schemats/dosleg.ts +0 -2195
- package/lib/raw_types_schemats/questions.mjs +0 -2
- package/lib/raw_types_schemats/questions.ts +0 -251
- package/lib/raw_types_schemats/sens.mjs +0 -2
- package/lib/raw_types_schemats/sens.ts +0 -2907
- package/lib/scripts/convert_data.mjs +0 -181
- package/lib/scripts/convert_data.ts +0 -243
- package/lib/scripts/datautil.mjs +0 -16
- package/lib/scripts/datautil.ts +0 -19
- package/lib/scripts/images/transparent_150x192.jpg +0 -0
- package/lib/scripts/images/transparent_155x225.jpg +0 -0
- package/lib/scripts/parse_textes.mjs +0 -46
- package/lib/scripts/parse_textes.ts +0 -65
- package/lib/scripts/retrieve_documents.mjs +0 -249
- package/lib/scripts/retrieve_documents.ts +0 -298
- package/lib/scripts/retrieve_open_data.mjs +0 -217
- package/lib/scripts/retrieve_open_data.ts +0 -274
- package/lib/scripts/retrieve_senateurs_photos.mjs +0 -147
- package/lib/scripts/retrieve_senateurs_photos.ts +0 -177
- package/lib/scripts/retrieve_textes.d.ts +0 -1
- package/lib/scripts/retrieve_textes.mjs +0 -328
- package/lib/scripts/retrieve_textes.ts +0 -143
- package/lib/scripts/shared/cli_helpers.ts +0 -36
- package/lib/scripts/shared/util.ts +0 -33
- package/lib/src/aggregates.d.ts +0 -52
- package/lib/src/aggregates.mjs +0 -726
- package/lib/src/config.d.ts +0 -2
- package/lib/src/config.mjs +0 -16
- package/lib/src/databases.d.ts +0 -18
- package/lib/src/databases.mjs +0 -55
- package/lib/src/datasets.d.ts +0 -28
- package/lib/src/datasets.mjs +0 -78
- package/lib/src/fields.d.ts +0 -10
- package/lib/src/fields.mjs +0 -22
- package/lib/src/index.d.ts +0 -8
- package/lib/src/index.mjs +0 -7
- package/lib/src/inserters.d.ts +0 -98
- package/lib/src/inserters.mjs +0 -360
- package/lib/src/loaders.d.ts +0 -36
- package/lib/src/loaders.mjs +0 -107
- package/lib/src/model/ameli.d.ts +0 -4
- package/lib/src/model/ameli.js +0 -57
- package/lib/src/model/debats.d.ts +0 -4
- package/lib/src/model/debats.js +0 -43
- package/lib/src/model/dosleg.d.ts +0 -197
- package/lib/src/model/dosleg.js +0 -169
- package/lib/src/model/index.d.ts +0 -4
- package/lib/src/model/index.js +0 -4
- package/lib/src/model/questions.d.ts +0 -89
- package/lib/src/model/questions.js +0 -76
- package/lib/src/model/sens.d.ts +0 -390
- package/lib/src/model/sens.js +0 -339
- package/lib/src/model/texte.d.ts +0 -7
- package/lib/src/model/texte.js +0 -183
- package/lib/src/raw_types_kysely/ameli.d.ts +0 -915
- package/lib/src/raw_types_kysely/ameli.js +0 -5
- package/lib/src/raw_types_kysely/debats.d.ts +0 -207
- package/lib/src/raw_types_kysely/debats.js +0 -5
- package/lib/src/raw_types_kysely/dosleg.d.ts +0 -3532
- package/lib/src/raw_types_kysely/dosleg.js +0 -5
- package/lib/src/raw_types_kysely/questions.d.ts +0 -414
- package/lib/src/raw_types_kysely/questions.js +0 -5
- package/lib/src/raw_types_kysely/sens.d.ts +0 -4394
- package/lib/src/raw_types_kysely/sens.js +0 -5
- package/lib/src/raw_types_schemats/ameli.d.ts +0 -541
- package/lib/src/raw_types_schemats/ameli.js +0 -2
- package/lib/src/raw_types_schemats/debats.d.ts +0 -127
- package/lib/src/raw_types_schemats/debats.js +0 -2
- package/lib/src/raw_types_schemats/dosleg.d.ts +0 -2027
- package/lib/src/raw_types_schemats/dosleg.js +0 -2
- package/lib/src/raw_types_schemats/questions.d.ts +0 -231
- package/lib/src/raw_types_schemats/questions.js +0 -2
- package/lib/src/raw_types_schemats/sens.d.ts +0 -2709
- package/lib/src/raw_types_schemats/sens.js +0 -2
- package/lib/src/scripts/convert_data.d.ts +0 -1
- package/lib/src/scripts/convert_data.js +0 -95
- package/lib/src/scripts/datautil.d.ts +0 -5
- package/lib/src/scripts/datautil.js +0 -16
- package/lib/src/scripts/parse_textes.d.ts +0 -1
- package/lib/src/scripts/parse_textes.js +0 -47
- package/lib/src/scripts/retrieve_documents.d.ts +0 -1
- package/lib/src/scripts/retrieve_documents.js +0 -258
- package/lib/src/scripts/retrieve_open_data.d.ts +0 -1
- package/lib/src/scripts/retrieve_open_data.js +0 -214
- package/lib/src/scripts/retrieve_senateurs_photos.d.ts +0 -1
- package/lib/src/scripts/retrieve_senateurs_photos.js +0 -147
- package/lib/src/scripts/shared/cli_helpers.d.ts +0 -44
- package/lib/src/scripts/shared/cli_helpers.js +0 -32
- package/lib/src/scripts/shared/util.d.ts +0 -3
- package/lib/src/scripts/shared/util.js +0 -28
- package/lib/src/strings.d.ts +0 -1
- package/lib/src/strings.mjs +0 -18
- package/lib/src/types/ameli.d.ts +0 -10
- package/lib/src/types/ameli.js +0 -13
- package/lib/src/types/debats.d.ts +0 -4
- package/lib/src/types/debats.js +0 -2
- package/lib/src/types/dosleg.d.ts +0 -98
- package/lib/src/types/dosleg.js +0 -151
- package/lib/src/types/questions.d.ts +0 -2
- package/lib/src/types/questions.js +0 -1
- package/lib/src/types/sens.d.ts +0 -10
- package/lib/src/types/sens.js +0 -1
- package/lib/src/types/sessions.d.ts +0 -42
- package/lib/src/types/sessions.js +0 -43
- package/lib/src/types/texte.d.ts +0 -61
- package/lib/src/types/texte.js +0 -16
- package/lib/src/validators/config.d.ts +0 -1
- package/lib/src/validators/config.js +0 -54
- package/lib/src/validators/senat.d.ts +0 -0
- package/lib/src/validators/senat.js +0 -24
- package/lib/strings.mjs +0 -18
- package/lib/strings.ts +0 -26
- package/lib/types/ameli.mjs +0 -13
- package/lib/types/ameli.ts +0 -21
- package/lib/types/debats.mjs +0 -2
- package/lib/types/debats.ts +0 -6
- package/lib/types/dosleg.mjs +0 -151
- package/lib/types/dosleg.ts +0 -284
- package/lib/types/questions.mjs +0 -1
- package/lib/types/questions.ts +0 -3
- package/lib/types/sens.mjs +0 -1
- package/lib/types/sens.ts +0 -12
- package/lib/types/sessions.mjs +0 -43
- package/lib/types/sessions.ts +0 -42
- package/lib/types/texte.mjs +0 -16
- package/lib/types/texte.ts +0 -76
- package/lib/typings/windows-1252.d.js +0 -2
- package/lib/typings/windows-1252.d.mjs +0 -2
- package/lib/typings/windows-1252.d.ts +0 -11
- package/lib/validators/config.mjs +0 -54
- package/lib/validators/config.ts +0 -79
- package/lib/validators/senat.mjs +0 -24
- package/lib/validators/senat.ts +0 -26
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import assert from "assert"
|
|
2
|
-
import commandLineArgs from "command-line-args"
|
|
3
|
-
import fs from "fs-extra"
|
|
4
|
-
import path from "path"
|
|
5
|
-
|
|
6
|
-
import { findSenatRapportUrls, findSenatTexteUrls } from "../model/dosleg"
|
|
7
|
-
import { UNDEFINED_SESSION } from "./datautil"
|
|
8
|
-
import { commonOptions } from "./shared/cli_helpers"
|
|
9
|
-
import { ensureAndClearDir, fetchWithRetry } from "./shared/util"
|
|
10
|
-
|
|
11
|
-
const optionsDefinitions = [
|
|
12
|
-
...commonOptions,
|
|
13
|
-
{
|
|
14
|
-
help: "sessions of texts to retrieve; leave empty for all",
|
|
15
|
-
multiple: true,
|
|
16
|
-
name: "sessions",
|
|
17
|
-
type: String,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
help: "parse and convert documents into JSON (textes only for now)",
|
|
21
|
-
name: "parseDocuments",
|
|
22
|
-
type: Boolean,
|
|
23
|
-
},
|
|
24
|
-
]
|
|
25
|
-
const options = commandLineArgs(optionsDefinitions)
|
|
26
|
-
|
|
27
|
-
const SENAT_TEXTE_BASE_URL = "https://www.senat.fr/akomantoso/"
|
|
28
|
-
const SENAT_RAPPORT_BASE_URL = "https://www.senat.fr/rap/"
|
|
29
|
-
|
|
30
|
-
async function retrieveDocument (documentUrl: string) {
|
|
31
|
-
if (!options.silent) {
|
|
32
|
-
console.log(`Retrieving document ${documentUrl}…`)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
const response = await fetchWithRetry(documentUrl)
|
|
37
|
-
if (!response.ok) {
|
|
38
|
-
if (response.status === 404) {
|
|
39
|
-
console.warn(`Texte ${documentUrl} not found`)
|
|
40
|
-
} else {
|
|
41
|
-
console.error(`An error occurred while retrieving texte ${documentUrl}: ${response.status}`)
|
|
42
|
-
}
|
|
43
|
-
return null
|
|
44
|
-
}
|
|
45
|
-
return await response.text()
|
|
46
|
-
} catch (error: any) {
|
|
47
|
-
console.error(error.message)
|
|
48
|
-
return null
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function retrieveTextes (dataDir: string) {
|
|
53
|
-
const textesDir = path.join(dataDir, "leg")
|
|
54
|
-
fs.ensureDirSync(textesDir)
|
|
55
|
-
|
|
56
|
-
let retrievedTextesCount = 0
|
|
57
|
-
const texteUrlsNotFoundOrError = []
|
|
58
|
-
|
|
59
|
-
for await (const texte of findSenatTexteUrls(options.sessions)) {
|
|
60
|
-
const texteName = path.parse(texte.url).name
|
|
61
|
-
const texteXmlUrl = `${texteName}.akn.xml`
|
|
62
|
-
const texteXmlAbsoluteUrl = new URL(texteXmlUrl, SENAT_TEXTE_BASE_URL).toString()
|
|
63
|
-
|
|
64
|
-
const texteXml = await retrieveDocument(texteXmlAbsoluteUrl)
|
|
65
|
-
|
|
66
|
-
if (texteXml) {
|
|
67
|
-
if (options.parseDocuments) {
|
|
68
|
-
//const parsedTexte = await parseTexte(texteXml)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const texteDir = path.join(textesDir, `${texte.session ?? UNDEFINED_SESSION}`, texteName)
|
|
72
|
-
ensureAndClearDir(texteDir)
|
|
73
|
-
fs.writeFileSync(path.join(texteDir, texteXmlUrl), texteXml)
|
|
74
|
-
retrievedTextesCount++
|
|
75
|
-
} else {
|
|
76
|
-
texteUrlsNotFoundOrError.push(texteXmlAbsoluteUrl)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (options.verbose) {
|
|
81
|
-
console.log(`${retrievedTextesCount} textes retrieved`)
|
|
82
|
-
console.log(
|
|
83
|
-
`${texteUrlsNotFoundOrError.length} textes failed with URLs ${texteUrlsNotFoundOrError.join(", ")}`
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
// TODO retrieve other formats (html/pdf) ?
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async function retrieveRapports (dataDir: string) {
|
|
90
|
-
const rapportsDir = path.join(dataDir, "rap")
|
|
91
|
-
fs.ensureDirSync(rapportsDir)
|
|
92
|
-
|
|
93
|
-
let retrievedRapportsCount = 0
|
|
94
|
-
const rapportUrlsNotFoundOrError = []
|
|
95
|
-
|
|
96
|
-
for await (const rapport of findSenatRapportUrls(options.sessions)) {
|
|
97
|
-
let rapportUrl = rapport.url
|
|
98
|
-
const parsedRapportUrl = path.parse(rapport.url)
|
|
99
|
-
let rapportUrlBase = parsedRapportUrl.base
|
|
100
|
-
const rapportName = parsedRapportUrl.name
|
|
101
|
-
if (parsedRapportUrl.ext === ".html") {
|
|
102
|
-
rapportUrlBase = `${rapportName}_mono.html`
|
|
103
|
-
rapportUrl = path.format({
|
|
104
|
-
dir: parsedRapportUrl.dir,
|
|
105
|
-
base: rapportUrlBase,
|
|
106
|
-
})
|
|
107
|
-
}
|
|
108
|
-
const rapportAbsoluteUrl = new URL(rapportUrl, SENAT_RAPPORT_BASE_URL).toString()
|
|
109
|
-
|
|
110
|
-
const rapportContent = await retrieveDocument(rapportAbsoluteUrl)
|
|
111
|
-
|
|
112
|
-
if (rapportContent) {
|
|
113
|
-
const rapportDir = path.join(rapportsDir, `${rapport.session ?? UNDEFINED_SESSION}`, rapportName)
|
|
114
|
-
ensureAndClearDir(rapportDir)
|
|
115
|
-
fs.writeFileSync(path.join(rapportDir, rapportUrlBase), rapportContent)
|
|
116
|
-
retrievedRapportsCount++
|
|
117
|
-
} else {
|
|
118
|
-
rapportUrlsNotFoundOrError.push(rapportAbsoluteUrl)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (options.verbose) {
|
|
123
|
-
console.log(`${retrievedRapportsCount} rapports retrieved`)
|
|
124
|
-
console.log(
|
|
125
|
-
`${rapportUrlsNotFoundOrError.length} rapports failed with URLs ${rapportUrlsNotFoundOrError.join(", ")}`
|
|
126
|
-
)
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async function main() {
|
|
131
|
-
const dataDir = options.dataDir
|
|
132
|
-
assert(dataDir, "Missing argument: data directory")
|
|
133
|
-
|
|
134
|
-
await retrieveTextes(dataDir)
|
|
135
|
-
await retrieveRapports(dataDir)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
main()
|
|
139
|
-
.then(() => process.exit(0))
|
|
140
|
-
.catch((error) => {
|
|
141
|
-
console.log(error)
|
|
142
|
-
process.exit(1)
|
|
143
|
-
})
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export const categoriesOption = {
|
|
2
|
-
alias: "k",
|
|
3
|
-
defaultValue: ["All"],
|
|
4
|
-
help: "categories of datasets to reorganize",
|
|
5
|
-
multiple: true,
|
|
6
|
-
name: "categories",
|
|
7
|
-
type: String,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const dataDirDefaultOption = {
|
|
11
|
-
defaultOption: true,
|
|
12
|
-
help: "directory containing Sénat open data files",
|
|
13
|
-
name: "dataDir",
|
|
14
|
-
type: String,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const silentOption = {
|
|
18
|
-
alias: "s",
|
|
19
|
-
help: "don't log anything",
|
|
20
|
-
name: "silent",
|
|
21
|
-
type: Boolean,
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const verboseOption = {
|
|
25
|
-
alias: "v",
|
|
26
|
-
help: "verbose logs",
|
|
27
|
-
name: "verbose",
|
|
28
|
-
type: Boolean,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const commonOptions = [
|
|
32
|
-
categoriesOption,
|
|
33
|
-
dataDirDefaultOption,
|
|
34
|
-
silentOption,
|
|
35
|
-
verboseOption,
|
|
36
|
-
]
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra"
|
|
2
|
-
|
|
3
|
-
export function isOptionEmptyOrHasValue (option: string, value: string) {
|
|
4
|
-
return !option || option.length === 0 || option.includes(value)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function ensureAndClearDir (path: string) {
|
|
8
|
-
if (!fs.existsSync(path)) {
|
|
9
|
-
fs.mkdirSync(path, { recursive: true })
|
|
10
|
-
} else {
|
|
11
|
-
fs.emptyDirSync(path)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function fetchWithRetry (
|
|
16
|
-
url: string,
|
|
17
|
-
retries: number = 3,
|
|
18
|
-
backoff: number = 300,
|
|
19
|
-
): Promise<Response> {
|
|
20
|
-
for (let attempt = 0; attempt < retries; attempt++) {
|
|
21
|
-
try {
|
|
22
|
-
return await fetch(url)
|
|
23
|
-
} catch (error) {
|
|
24
|
-
if (attempt === retries - 1) {
|
|
25
|
-
throw error
|
|
26
|
-
}
|
|
27
|
-
console.warn(`Fetch attempt ${attempt + 1} for ${url} failed. Retrying in ${backoff}ms…`)
|
|
28
|
-
await new Promise((resolve) => setTimeout(resolve, backoff))
|
|
29
|
-
backoff *= 2
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
throw new Error(`Failed to fetch ${url} after ${retries} attempts`)
|
|
33
|
-
}
|
package/lib/src/aggregates.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Ses, Sub, TxtAmeli } from "./types/ameli";
|
|
2
|
-
import { Debat } from "./types/debats";
|
|
3
|
-
import { Ass, Aud, Auteur, DateSeance, DecCoc, DenRap, DocAtt, Ecr, EtaLoi, LecAss, LecAssRap, Lecture, Loi, Org, OriTxt, Qua, Rap, Scr, Texte, TypAtt, TypLec, TypLoi, TypTxt, TypUrl } from "./types/dosleg";
|
|
4
|
-
import { Question } from "./types/questions";
|
|
5
|
-
export declare const allFollows: string[];
|
|
6
|
-
export declare class Aggregator {
|
|
7
|
-
follow: Set<string>;
|
|
8
|
-
objectByIdByTableName: {
|
|
9
|
-
[name: string]: {
|
|
10
|
-
[id: string]: object;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
requestedIdsByTableName: {
|
|
14
|
-
[name: string]: Set<string>;
|
|
15
|
-
};
|
|
16
|
-
visitedIdsByTableName: {
|
|
17
|
-
[name: string]: Set<string>;
|
|
18
|
-
};
|
|
19
|
-
constructor(follow: Set<string>);
|
|
20
|
-
addAss(ass: Ass): void;
|
|
21
|
-
addAud(aud: Aud): void;
|
|
22
|
-
addAuteur(auteur: Auteur): void;
|
|
23
|
-
addDateSeance(dateSeance: DateSeance): void;
|
|
24
|
-
addDebat(debat: Debat): void;
|
|
25
|
-
addDeccoc(deccoc: DecCoc): void;
|
|
26
|
-
addDenrap(denrap: DenRap): void;
|
|
27
|
-
addDocatt(docatt: DocAtt): void;
|
|
28
|
-
addEcr(ecr: Ecr): void;
|
|
29
|
-
addEtaloi(etaloi: EtaLoi): void;
|
|
30
|
-
addLecass(lecass: LecAss): void;
|
|
31
|
-
addLecassrap(lecassrap: LecAssRap): void;
|
|
32
|
-
addLecture(lecture: Lecture): void;
|
|
33
|
-
addLoi(loi: Loi): void;
|
|
34
|
-
addOrg(org: Org): void;
|
|
35
|
-
addOritxt(oritxt: OriTxt): void;
|
|
36
|
-
addQua(qua: Qua): void;
|
|
37
|
-
addQuestion(question: Question): void;
|
|
38
|
-
addRap(rap: Rap): void;
|
|
39
|
-
addScr(scr: Scr): void;
|
|
40
|
-
addSes(ses: Ses): void;
|
|
41
|
-
addSub(sub: Sub): void;
|
|
42
|
-
addTexte(texte: Texte): void;
|
|
43
|
-
addTxtAmeli(txtAmeli: TxtAmeli): void;
|
|
44
|
-
addTypatt(typatt: TypAtt): void;
|
|
45
|
-
addTyplec(typlec: TypLec): void;
|
|
46
|
-
addTyploi(typloi: TypLoi): void;
|
|
47
|
-
addTyptxt(typtxt: TypTxt): void;
|
|
48
|
-
addTypurl(typurl: TypUrl): void;
|
|
49
|
-
getAll(): Promise<void>;
|
|
50
|
-
request(tableName: string, id: string): void;
|
|
51
|
-
toJson(): any;
|
|
52
|
-
}
|