@tricoteuses/senat 2.8.6 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/model/dosleg.d.ts +0 -29
- package/lib/model/questions.d.ts +20 -0
- package/lib/model/questions.js +32 -1
- package/lib/model/sens.d.ts +670 -82
- package/lib/raw_types/dosleg.d.ts +77 -1994
- package/lib/raw_types/questions.d.ts +70 -0
- package/lib/raw_types/sens.d.ts +5424 -1570
- package/lib/raw_types_schemats/ameli.d.ts +12 -2
- package/lib/raw_types_schemats/debats.d.ts +2 -2
- package/lib/raw_types_schemats/dosleg.d.ts +2 -1054
- package/lib/raw_types_schemats/questions.d.ts +4 -2
- package/lib/raw_types_schemats/sens.d.ts +4235 -29
- package/package.json +9 -10
- package/lib/aggregates.d.ts +0 -52
- package/lib/aggregates.js +0 -949
- package/lib/aggregates.mjs +0 -726
- package/lib/aggregates.ts +0 -852
- package/lib/config.mjs +0 -16
- package/lib/config.ts +0 -26
- package/lib/databases.mjs +0 -55
- package/lib/databases.ts +0 -68
- package/lib/datasets.mjs +0 -78
- package/lib/datasets.ts +0 -118
- package/lib/fields.d.ts +0 -10
- package/lib/fields.js +0 -68
- package/lib/fields.mjs +0 -22
- package/lib/fields.ts +0 -29
- package/lib/index.mjs +0 -7
- package/lib/index.ts +0 -64
- package/lib/inserters.d.ts +0 -98
- package/lib/inserters.js +0 -500
- package/lib/inserters.mjs +0 -360
- package/lib/inserters.ts +0 -521
- package/lib/legislatures.json +0 -38
- package/lib/loaders.mjs +0 -97
- package/lib/loaders.ts +0 -173
- package/lib/model/ameli.mjs +0 -57
- package/lib/model/ameli.ts +0 -86
- package/lib/model/debats.mjs +0 -43
- package/lib/model/debats.ts +0 -68
- package/lib/model/dosleg.mjs +0 -163
- package/lib/model/dosleg.ts +0 -204
- package/lib/model/index.mjs +0 -4
- package/lib/model/index.ts +0 -13
- package/lib/model/questions.mjs +0 -76
- package/lib/model/questions.ts +0 -102
- package/lib/model/sens.mjs +0 -339
- package/lib/model/sens.ts +0 -432
- package/lib/model/texte.mjs +0 -156
- package/lib/model/texte.ts +0 -174
- package/lib/raw_types_kysely/ameli.d.ts +0 -915
- package/lib/raw_types_kysely/ameli.js +0 -7
- package/lib/raw_types_kysely/ameli.mjs +0 -5
- package/lib/raw_types_kysely/ameli.ts +0 -951
- package/lib/raw_types_kysely/debats.d.ts +0 -207
- package/lib/raw_types_kysely/debats.js +0 -7
- package/lib/raw_types_kysely/debats.mjs +0 -5
- package/lib/raw_types_kysely/debats.ts +0 -222
- package/lib/raw_types_kysely/dosleg.d.ts +0 -3532
- package/lib/raw_types_kysely/dosleg.js +0 -7
- package/lib/raw_types_kysely/dosleg.mjs +0 -5
- package/lib/raw_types_kysely/dosleg.ts +0 -3621
- package/lib/raw_types_kysely/questions.d.ts +0 -414
- package/lib/raw_types_kysely/questions.js +0 -7
- package/lib/raw_types_kysely/questions.mjs +0 -5
- package/lib/raw_types_kysely/questions.ts +0 -426
- package/lib/raw_types_kysely/sens.d.ts +0 -4394
- package/lib/raw_types_kysely/sens.js +0 -7
- package/lib/raw_types_kysely/sens.mjs +0 -5
- package/lib/raw_types_kysely/sens.ts +0 -4499
- 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 -2193
- package/lib/raw_types_schemats/questions.mjs +0 -2
- package/lib/raw_types_schemats/questions.ts +0 -249
- 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 -95
- package/lib/scripts/convert_data.ts +0 -119
- 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 -38
- package/lib/scripts/parse_textes.ts +0 -52
- package/lib/scripts/retrieve_documents.mjs +0 -243
- package/lib/scripts/retrieve_documents.ts +0 -279
- package/lib/scripts/retrieve_open_data.mjs +0 -214
- package/lib/scripts/retrieve_open_data.ts +0 -261
- 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 -165
- package/lib/scripts/retrieve_textes.ts +0 -79
- package/lib/scripts/shared/cli_helpers.ts +0 -36
- package/lib/scripts/shared/util.ts +0 -33
- 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 -66
- 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.d.ts +0 -0
- package/lib/validators/senat.js +0 -24
- package/lib/validators/senat.mjs +0 -24
- package/lib/validators/senat.ts +0 -26
package/lib/model/texte.ts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { JSDOM } from "jsdom"
|
|
2
|
-
|
|
3
|
-
import { AKN_WORKFLOW_IDENTIFICATION_STRUCTURE_REGEXP, AKN_IDENTIFICATION_STRUCTURE_REGEXP } from "../scripts/datautil"
|
|
4
|
-
import {
|
|
5
|
-
Alinea,
|
|
6
|
-
Article,
|
|
7
|
-
Division,
|
|
8
|
-
DivisionContent,
|
|
9
|
-
DivisionTag,
|
|
10
|
-
DivisionType,
|
|
11
|
-
FlatTexte, Step,
|
|
12
|
-
Version,
|
|
13
|
-
} from "../types/texte"
|
|
14
|
-
|
|
15
|
-
function buildWorklow (metaElement: HTMLMetaElement): Step[] {
|
|
16
|
-
const stepElements = metaElement.querySelectorAll("workflow step")
|
|
17
|
-
const steps: Step[] = []
|
|
18
|
-
for (const stepElement of stepElements) {
|
|
19
|
-
const identification = stepElement.getAttribute("href") ?? ""
|
|
20
|
-
const identificationParts = AKN_WORKFLOW_IDENTIFICATION_STRUCTURE_REGEXP.exec(identification)?.groups
|
|
21
|
-
steps.push({
|
|
22
|
-
eId: stepElement.getAttribute("eId")!,
|
|
23
|
-
date: stepElement.getAttribute("date") ? new Date(stepElement.getAttribute("date") ?? "") : null,
|
|
24
|
-
type: identificationParts?.type || null,
|
|
25
|
-
session: identificationParts?.session || null,
|
|
26
|
-
numero: identificationParts?.numTexte || null,
|
|
27
|
-
version: identificationParts?.version ? identificationParts.version as Version : null,
|
|
28
|
-
outcome: stepElement.getAttribute("outcome"),
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
return steps
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function buildDivision (node: Node, index: number): Division {
|
|
35
|
-
const eId = (node as Element).getAttribute("eId")!
|
|
36
|
-
const tag = node.nodeName as DivisionTag
|
|
37
|
-
const level = DivisionType[tag]
|
|
38
|
-
const titleNode = (node as Element).querySelector("num")
|
|
39
|
-
const subtitleNode = (node as Element).querySelector("heading")
|
|
40
|
-
const headings: DivisionContent[] = [
|
|
41
|
-
...(titleNode ? [{
|
|
42
|
-
text: titleNode.textContent?.trim() ?? null,
|
|
43
|
-
html: titleNode.innerHTML?.trim() ?? null,
|
|
44
|
-
}] : []),
|
|
45
|
-
...(subtitleNode ? [{
|
|
46
|
-
text: subtitleNode.textContent?.trim() ?? null,
|
|
47
|
-
html: subtitleNode.innerHTML?.trim() ?? null,
|
|
48
|
-
}] : []),
|
|
49
|
-
]
|
|
50
|
-
const division = {
|
|
51
|
-
index,
|
|
52
|
-
eId,
|
|
53
|
-
tag,
|
|
54
|
-
level,
|
|
55
|
-
headings,
|
|
56
|
-
}
|
|
57
|
-
if (tag === "article") {
|
|
58
|
-
(division as Article).alineas = []
|
|
59
|
-
}
|
|
60
|
-
return division
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function buildAlinea (contentNode: Node, alineaNode: Node): Alinea {
|
|
64
|
-
const eId = (alineaNode as Element).getAttribute("eId")!
|
|
65
|
-
const heading = {
|
|
66
|
-
text: (alineaNode as Element).querySelector("num")?.textContent ?? null,
|
|
67
|
-
}
|
|
68
|
-
const pastille = (alineaNode as Element).getAttribute("data:pastille") ?? null
|
|
69
|
-
return {
|
|
70
|
-
eId,
|
|
71
|
-
heading,
|
|
72
|
-
text: (contentNode as Element).textContent?.trim() ?? null,
|
|
73
|
-
html: (contentNode as Element).innerHTML?.trim() ?? null,
|
|
74
|
-
pastille,
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function buildEmptyArticle (index: number): Article {
|
|
79
|
-
return {
|
|
80
|
-
index: index,
|
|
81
|
-
eId: "",
|
|
82
|
-
tag: "article",
|
|
83
|
-
level: DivisionType["article"],
|
|
84
|
-
headings: [],
|
|
85
|
-
alineas: [],
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function flattenTexte (texteContentRoot: Node): Division[] {
|
|
90
|
-
const divisions: Division[] = []
|
|
91
|
-
let divisionIndex = 0
|
|
92
|
-
const iter = (node: Node) => {
|
|
93
|
-
if (node.nodeName === "content") {
|
|
94
|
-
return
|
|
95
|
-
}
|
|
96
|
-
switch (node.nodeName) {
|
|
97
|
-
case "tome":
|
|
98
|
-
case "part":
|
|
99
|
-
case "book":
|
|
100
|
-
case "title":
|
|
101
|
-
case "subtitle":
|
|
102
|
-
case "chapter":
|
|
103
|
-
case "section":
|
|
104
|
-
case "subsection":
|
|
105
|
-
case "paragraph":
|
|
106
|
-
case "article":
|
|
107
|
-
divisions.push(buildDivision(node, divisionIndex++))
|
|
108
|
-
break
|
|
109
|
-
}
|
|
110
|
-
if (node.nodeName === "alinea") {
|
|
111
|
-
Array.from(node.childNodes)
|
|
112
|
-
// Find direct content children programmatically
|
|
113
|
-
// because `:scope` selector does not work
|
|
114
|
-
// https://github.com/jsdom/jsdom/issues/2998
|
|
115
|
-
.filter((alineaChildNode: Node) => alineaChildNode.nodeName === "content")
|
|
116
|
-
.forEach((alineaContentNode: Node) => {
|
|
117
|
-
// Hypothesis: alineas should always be enclosed in articles
|
|
118
|
-
let lastArticle = divisions.findLast(division => division.tag === "article") as Article
|
|
119
|
-
if (!lastArticle) {
|
|
120
|
-
lastArticle = buildEmptyArticle(divisionIndex++)
|
|
121
|
-
divisions.push(lastArticle)
|
|
122
|
-
}
|
|
123
|
-
lastArticle.alineas.push(buildAlinea(alineaContentNode, node))
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
if (node.hasChildNodes()) {
|
|
127
|
-
node.childNodes.forEach((childNode: Node) => iter(childNode))
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
iter(texteContentRoot)
|
|
131
|
-
return divisions
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export function transformTexte (document: Document): FlatTexte | null {
|
|
135
|
-
let transformedTexte = null
|
|
136
|
-
const metaElement = document.querySelector("meta")
|
|
137
|
-
const identification = metaElement?.querySelector("FRBRExpression FRBRuri")?.getAttribute("value") ?? ""
|
|
138
|
-
const identificationParts = AKN_IDENTIFICATION_STRUCTURE_REGEXP.exec(identification)?.groups
|
|
139
|
-
const bodyElement = document.querySelector("body")
|
|
140
|
-
try {
|
|
141
|
-
transformedTexte = {
|
|
142
|
-
title: metaElement?.querySelector("FRBRalias[name='intitule-court']")
|
|
143
|
-
?.getAttribute("value") || null,
|
|
144
|
-
signetDossierLegislatifSenat:
|
|
145
|
-
metaElement?.querySelector("FRBRalias[name='signet-dossier-legislatif-senat']")
|
|
146
|
-
?.getAttribute("value") || null,
|
|
147
|
-
urlSenat: metaElement?.querySelector("FRBRalias[name='url-senat']")?.getAttribute("value") || null,
|
|
148
|
-
urlAssemblee: metaElement?.querySelector("FRBRalias[name='url-AN']")?.getAttribute("value") || null,
|
|
149
|
-
type: identificationParts?.type || null,
|
|
150
|
-
session: identificationParts?.session || null,
|
|
151
|
-
numero: identificationParts?.numTexte ? parseInt(identificationParts.numTexte) : null,
|
|
152
|
-
version: identificationParts?.version ? identificationParts.version as Version : null,
|
|
153
|
-
workflow: metaElement ? buildWorklow(metaElement) : [],
|
|
154
|
-
divisions: bodyElement ? flattenTexte(bodyElement) : [],
|
|
155
|
-
}
|
|
156
|
-
} catch (error: any) {
|
|
157
|
-
console.error(`Could not parse texte with error ${error}`)
|
|
158
|
-
}
|
|
159
|
-
return transformedTexte
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export function parseTexte (texteXml: string): FlatTexte | null {
|
|
163
|
-
const { document } = (new JSDOM(texteXml, {
|
|
164
|
-
contentType: "text/xml",
|
|
165
|
-
})).window
|
|
166
|
-
return transformTexte(document)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Prevent from memory leak
|
|
170
|
-
// https://github.com/jsdom/jsdom/issues/2583#issuecomment-559520814
|
|
171
|
-
export async function parseTexteFromFile (xmlFilePath: string): Promise<FlatTexte | null> {
|
|
172
|
-
const { document } = (await JSDOM.fromFile(xmlFilePath, { contentType: "text/xml" })).window
|
|
173
|
-
return transformTexte(document)
|
|
174
|
-
}
|