@tricoteuses/senat 1.1.2 → 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.
Files changed (155) hide show
  1. package/README.md +53 -15
  2. package/lib/config.d.ts +1 -0
  3. package/lib/config.js +14 -45
  4. package/lib/databases.d.ts +9 -0
  5. package/lib/databases.js +90 -117
  6. package/lib/datasets.js +78 -83
  7. package/lib/index.d.ts +8 -7
  8. package/lib/index.js +42 -523
  9. package/lib/legislatures.json +38 -0
  10. package/lib/loaders.d.ts +64 -0
  11. package/lib/loaders.js +177 -0
  12. package/lib/model/ameli.d.ts +105 -4
  13. package/lib/model/ameli.js +88 -166
  14. package/lib/model/debats.d.ts +0 -4
  15. package/lib/model/debats.js +0 -122
  16. package/lib/model/dosleg.d.ts +227 -29
  17. package/lib/model/dosleg.js +205 -839
  18. package/lib/model/index.d.ts +4 -5
  19. package/lib/model/index.js +12 -47
  20. package/lib/model/questions.d.ts +88 -2
  21. package/lib/model/questions.js +75 -51
  22. package/lib/model/sens.d.ts +524 -2
  23. package/lib/model/sens.js +449 -56
  24. package/lib/model/texte.d.ts +7 -0
  25. package/lib/model/texte.js +251 -0
  26. package/lib/model/util.d.ts +7 -1
  27. package/lib/model/util.js +26 -59
  28. package/lib/raw_types/ameli.d.ts +912 -538
  29. package/lib/raw_types/ameli.js +3 -42
  30. package/lib/raw_types/debats.d.ts +204 -124
  31. package/lib/raw_types/debats.js +3 -21
  32. package/lib/raw_types/dosleg.d.ts +3533 -2024
  33. package/lib/raw_types/dosleg.js +3 -95
  34. package/lib/raw_types/questions.d.ts +404 -220
  35. package/lib/raw_types/questions.js +3 -21
  36. package/lib/raw_types/sens.d.ts +4391 -2706
  37. package/lib/raw_types/sens.js +3 -111
  38. package/lib/raw_types_schemats/ameli.d.ts +541 -0
  39. package/lib/raw_types_schemats/ameli.js +3 -0
  40. package/lib/raw_types_schemats/debats.d.ts +127 -0
  41. package/lib/raw_types_schemats/debats.js +3 -0
  42. package/lib/raw_types_schemats/dosleg.d.ts +2029 -0
  43. package/lib/raw_types_schemats/dosleg.js +3 -0
  44. package/lib/raw_types_schemats/questions.d.ts +233 -0
  45. package/lib/raw_types_schemats/questions.js +3 -0
  46. package/lib/raw_types_schemats/sens.d.ts +2709 -0
  47. package/lib/raw_types_schemats/sens.js +3 -0
  48. package/lib/scripts/convert_data.js +184 -275
  49. package/lib/scripts/datautil.d.ts +5 -0
  50. package/lib/scripts/datautil.js +21 -0
  51. package/lib/scripts/parse_textes.js +49 -0
  52. package/lib/scripts/retrieve_documents.js +255 -0
  53. package/lib/scripts/retrieve_open_data.js +211 -360
  54. package/lib/scripts/retrieve_senateurs_photos.js +144 -257
  55. package/lib/scripts/shared/cli_helpers.d.ts +44 -0
  56. package/lib/scripts/shared/cli_helpers.js +35 -0
  57. package/lib/scripts/shared/util.d.ts +3 -0
  58. package/lib/scripts/shared/util.js +36 -0
  59. package/lib/strings.js +20 -45
  60. package/lib/types/ameli.d.ts +2 -2
  61. package/lib/types/ameli.js +14 -25
  62. package/lib/types/debats.d.ts +2 -2
  63. package/lib/types/debats.js +3 -21
  64. package/lib/types/dosleg.d.ts +3 -3
  65. package/lib/types/dosleg.js +152 -119
  66. package/lib/types/questions.d.ts +2 -2
  67. package/lib/types/questions.js +1 -13
  68. package/lib/types/sens.d.ts +2 -4
  69. package/lib/types/sens.js +1 -16
  70. package/lib/types/sessions.d.ts +42 -0
  71. package/lib/types/sessions.js +46 -0
  72. package/lib/types/texte.d.ts +65 -0
  73. package/lib/types/texte.js +19 -0
  74. package/lib/validators/config.js +47 -111
  75. package/lib/validators/senat.js +1 -5
  76. package/package.json +35 -32
  77. package/lib/aggregates.d.ts +0 -54
  78. package/lib/aggregates.js +0 -1122
  79. package/lib/aggregates.mjs +0 -802
  80. package/lib/aggregates.ts +0 -947
  81. package/lib/config.mjs +0 -16
  82. package/lib/config.ts +0 -26
  83. package/lib/databases.mjs +0 -26
  84. package/lib/databases.ts +0 -32
  85. package/lib/datasets.mjs +0 -78
  86. package/lib/datasets.ts +0 -118
  87. package/lib/fields.d.ts +0 -10
  88. package/lib/fields.js +0 -68
  89. package/lib/fields.mjs +0 -22
  90. package/lib/fields.ts +0 -29
  91. package/lib/index.mjs +0 -7
  92. package/lib/index.ts +0 -63
  93. package/lib/inserters.d.ts +0 -102
  94. package/lib/inserters.js +0 -518
  95. package/lib/inserters.mjs +0 -376
  96. package/lib/inserters.ts +0 -545
  97. package/lib/model/ameli.mjs +0 -57
  98. package/lib/model/ameli.ts +0 -86
  99. package/lib/model/debats.mjs +0 -43
  100. package/lib/model/debats.ts +0 -68
  101. package/lib/model/dosleg.mjs +0 -337
  102. package/lib/model/dosleg.ts +0 -558
  103. package/lib/model/index.mjs +0 -5
  104. package/lib/model/index.ts +0 -11
  105. package/lib/model/questions.mjs +0 -8
  106. package/lib/model/questions.ts +0 -14
  107. package/lib/model/sens.mjs +0 -9
  108. package/lib/model/sens.ts +0 -18
  109. package/lib/model/util.mjs +0 -10
  110. package/lib/model/util.ts +0 -16
  111. package/lib/raw_types/ameli.mjs +0 -2
  112. package/lib/raw_types/ameli.ts +0 -601
  113. package/lib/raw_types/debats.mjs +0 -2
  114. package/lib/raw_types/debats.ts +0 -145
  115. package/lib/raw_types/dosleg.mjs +0 -2
  116. package/lib/raw_types/dosleg.ts +0 -2193
  117. package/lib/raw_types/questions.mjs +0 -2
  118. package/lib/raw_types/questions.ts +0 -249
  119. package/lib/raw_types/sens.mjs +0 -2
  120. package/lib/raw_types/sens.ts +0 -2907
  121. package/lib/scripts/convert_data.mjs +0 -146
  122. package/lib/scripts/convert_data.ts +0 -182
  123. package/lib/scripts/fix_db.js +0 -144
  124. package/lib/scripts/fix_db.mjs +0 -64
  125. package/lib/scripts/fix_db.ts +0 -75
  126. package/lib/scripts/images/transparent_150x192.jpg +0 -0
  127. package/lib/scripts/images/transparent_155x225.jpg +0 -0
  128. package/lib/scripts/retrieve_open_data.mjs +0 -218
  129. package/lib/scripts/retrieve_open_data.ts +0 -258
  130. package/lib/scripts/retrieve_senateurs_photos.mjs +0 -164
  131. package/lib/scripts/retrieve_senateurs_photos.ts +0 -200
  132. package/lib/scripts/retrieve_textes.js +0 -179
  133. package/lib/scripts/retrieve_textes.mjs +0 -77
  134. package/lib/scripts/retrieve_textes.ts +0 -95
  135. package/lib/strings.mjs +0 -18
  136. package/lib/strings.ts +0 -26
  137. package/lib/types/ameli.mjs +0 -13
  138. package/lib/types/ameli.ts +0 -21
  139. package/lib/types/debats.mjs +0 -2
  140. package/lib/types/debats.ts +0 -6
  141. package/lib/types/dosleg.mjs +0 -151
  142. package/lib/types/dosleg.ts +0 -284
  143. package/lib/types/questions.mjs +0 -1
  144. package/lib/types/questions.ts +0 -3
  145. package/lib/types/sens.mjs +0 -23
  146. package/lib/types/sens.ts +0 -36
  147. package/lib/typings/windows-1252.d.js +0 -2
  148. package/lib/typings/windows-1252.d.mjs +0 -2
  149. package/lib/typings/windows-1252.d.ts +0 -11
  150. package/lib/validators/config.mjs +0 -54
  151. package/lib/validators/config.ts +0 -79
  152. package/lib/validators/senat.mjs +0 -24
  153. package/lib/validators/senat.ts +0 -26
  154. /package/lib/scripts/{fix_db.d.ts → parse_textes.d.ts} +0 -0
  155. /package/lib/scripts/{retrieve_textes.d.ts → retrieve_documents.d.ts} +0 -0
package/lib/inserters.ts DELETED
@@ -1,545 +0,0 @@
1
- import { TxtAmeli } from "./types/ameli"
2
- import { Debat } from "./types/debats"
3
- import {
4
- Ass,
5
- Aud,
6
- Auteur,
7
- DateSeance,
8
- DecCoc,
9
- DenRap,
10
- DocAtt,
11
- Ecr,
12
- EtaLoi,
13
- LecAss,
14
- LecAssRap,
15
- Lecture,
16
- Loi,
17
- Org,
18
- OriTxt,
19
- Qua,
20
- Rap,
21
- Scr,
22
- Texte,
23
- TypAtt,
24
- TypLec,
25
- TypLoi,
26
- TypTxt,
27
- TypUrl,
28
- } from "./types/dosleg"
29
- import { Question } from "./types/questions"
30
- import { Sen } from "./types/sens"
31
-
32
- export interface OutputData {
33
- readonly ass?: { [id: string]: Ass }
34
- readonly aud?: { [id: string]: Aud }
35
- readonly auteur?: { [id: string]: Auteur }
36
- readonly date_seance?: { [id: string]: DateSeance }
37
- readonly debats?: { [id: string]: Debat }
38
- readonly deccoc?: { [id: string]: DecCoc }
39
- readonly denrap?: { [id: string]: DenRap }
40
- readonly docatt?: { [id: string]: DocAtt }
41
- readonly ecr?: { [id: string]: Ecr }
42
- readonly etaloi?: { [id: string]: EtaLoi }
43
- readonly lecass?: { [id: string]: LecAss }
44
- readonly lecassrap?: { [id: string]: LecAssRap }
45
- readonly lecture?: { [id: string]: Lecture }
46
- readonly loi?: { [id: string]: Loi }
47
- readonly org?: { [id: string]: Org }
48
- readonly oritxt?: { [id: string]: OriTxt }
49
- readonly qua?: { [id: string]: Qua }
50
- readonly rap?: { [id: string]: Rap }
51
- readonly scr?: { [id: string]: Scr }
52
- readonly texte?: { [id: string]: Texte }
53
- readonly typatt?: { [id: string]: TypAtt }
54
- readonly typlec?: { [id: string]: TypLec }
55
- readonly typloi?: { [id: string]: TypLoi }
56
- readonly typtxt?: { [id: string]: TypTxt }
57
- readonly typurl?: { [id: string]: TypUrl }
58
- readonly txt_ameli?: { [id: string]: TxtAmeli }
59
- }
60
-
61
- type VisitedIdsByTableName = { [tableName: string]: Set<number | string> }
62
-
63
- export function insertAudReferences(
64
- aud: Aud,
65
- data: OutputData,
66
- visitedIdsByTableName: VisitedIdsByTableName,
67
- ) {
68
- let visitedIds = visitedIdsByTableName.aud
69
- if (visitedIds === undefined) {
70
- visitedIds = visitedIdsByTableName.aud = new Set()
71
- }
72
- if (!visitedIds.has(aud.audcle)) {
73
- visitedIds.add(aud.audcle)
74
-
75
- if (aud.orgcod !== null && data.org !== undefined) {
76
- const org = data.org[aud.orgcod]
77
- if (org !== undefined) {
78
- aud.org = org
79
- // insertOrgReferences(org, data, visitedIdsByTableName)
80
- }
81
- }
82
-
83
- // TODO
84
- }
85
-
86
- return aud
87
- }
88
-
89
- export function insertAuteurReferences(
90
- auteur: Auteur,
91
- data: OutputData,
92
- visitedIdsByTableName: VisitedIdsByTableName,
93
- ) {
94
- let visitedIds = visitedIdsByTableName.auteur
95
- if (visitedIds === undefined) {
96
- visitedIds = visitedIdsByTableName.auteur = new Set()
97
- }
98
- if (!visitedIds.has(auteur.autcod)) {
99
- visitedIds.add(auteur.autcod)
100
-
101
- if (data.qua !== undefined) {
102
- const qua = data.qua[auteur.quacod]
103
- if (qua !== undefined) {
104
- auteur.qua = qua
105
- // insertQuaReferences(qua, data, visitedIdsByTableName)
106
- }
107
- }
108
-
109
- // TODO
110
- }
111
-
112
- return auteur
113
- }
114
-
115
- export function insertDateSeanceReferences(
116
- dateSeance: DateSeance,
117
- data: OutputData,
118
- visitedIdsByTableName: VisitedIdsByTableName,
119
- ) {
120
- let visitedIds = visitedIdsByTableName.date_seance
121
- if (visitedIds === undefined) {
122
- visitedIds = visitedIdsByTableName.date_seance = new Set()
123
- }
124
- if (!visitedIds.has(dateSeance.code)) {
125
- visitedIds.add(dateSeance.code)
126
-
127
- if (dateSeance.date_s !== null && data.debats !== undefined) {
128
- const dateString =
129
- dateSeance.date_s instanceof Date
130
- ? dateSeance.date_s.toISOString()
131
- : dateSeance.date_s
132
- const debat = data.debats[dateString]
133
- if (debat !== undefined) {
134
- dateSeance.debat = debat
135
- // insertDebatReferences(debat, data, visitedIdsByTableName)
136
- }
137
- }
138
-
139
- dateSeance.scrs = []
140
- if (dateSeance.scrids !== undefined && data.scr !== undefined) {
141
- for (const scrid of dateSeance.scrids) {
142
- const scr = data.scr[scrid]
143
- if (scr !== undefined) {
144
- dateSeance.scrs.push(scr)
145
- // insertScrReferences(scr, data, visitedIdsByTableName)
146
- }
147
- }
148
- }
149
- }
150
-
151
- return dateSeance
152
- }
153
-
154
- export function insertDocAttReferences(
155
- docatt: DocAtt,
156
- data: OutputData,
157
- visitedIdsByTableName: VisitedIdsByTableName,
158
- performInsertRapReferences=true
159
- ) {
160
- let visitedIds = visitedIdsByTableName.docatt
161
- if (visitedIds === undefined) {
162
- visitedIds = visitedIdsByTableName.docatt = new Set()
163
- }
164
- if (!visitedIds.has(docatt.docattcle)) {
165
- visitedIds.add(docatt.docattcle)
166
-
167
- if (performInsertRapReferences && docatt.rapcod !== null && data.rap !== undefined) {
168
- const rap = data.rap[docatt.rapcod]
169
- if (rap !== undefined) {
170
- docatt.rap = rap
171
- insertRapReferences(rap, data, visitedIdsByTableName)
172
- }
173
- }
174
-
175
- if (docatt.typattcod !== null && data.typatt !== undefined) {
176
- const typatt = data.typatt[docatt.typattcod]
177
- if (typatt !== undefined) {
178
- docatt.typatt = typatt
179
- // insertTypAttReferences(typatt, data, visitedIdsByTableName)
180
- }
181
- }
182
- }
183
-
184
- return docatt
185
- }
186
-
187
- export function insertEcrReferences(
188
- ecr: Ecr,
189
- data: OutputData,
190
- visitedIdsByTableName: VisitedIdsByTableName,
191
- ) {
192
- let visitedIds = visitedIdsByTableName.ecr
193
- if (visitedIds === undefined) {
194
- visitedIds = visitedIdsByTableName.ecr = new Set()
195
- }
196
- if (!visitedIds.has(ecr.ecrnum)) {
197
- visitedIds.add(ecr.ecrnum)
198
-
199
- if (ecr.autcod !== null && data.auteur !== undefined) {
200
- const aut = data.auteur[ecr.autcod]
201
- if (aut !== undefined) {
202
- ecr.aut = aut
203
- insertAuteurReferences(aut, data, visitedIdsByTableName)
204
- }
205
- }
206
-
207
- // TODO
208
- }
209
-
210
- return ecr
211
- }
212
-
213
- export function insertLecassrapReferences(
214
- lecassrap: LecAssRap,
215
- data: OutputData,
216
- visitedIdsByTableName: VisitedIdsByTableName,
217
- ) {
218
- let visitedIds = visitedIdsByTableName.lecassrap
219
- if (visitedIds === undefined) {
220
- visitedIds = visitedIdsByTableName.lecassrap = new Set()
221
- }
222
- const lecasrapid = `${lecassrap.lecassidt} ${lecassrap.rapcod}`
223
- if (!visitedIds.has(lecasrapid)) {
224
- visitedIds.add(lecasrapid)
225
-
226
- if (lecassrap.rapcod !== null && data.rap !== undefined) {
227
- const rap = data.rap[lecassrap.rapcod]
228
- if (rap !== undefined) {
229
- lecassrap.rap = rap
230
- insertRapReferences(rap, data, visitedIdsByTableName)
231
- }
232
- }
233
- }
234
-
235
- return lecassrap
236
- }
237
-
238
- export function insertLecassReferences(
239
- lecass: LecAss,
240
- data: OutputData,
241
- visitedIdsByTableName: VisitedIdsByTableName,
242
- ) {
243
- let visitedIds = visitedIdsByTableName.lecass
244
- if (visitedIds === undefined) {
245
- visitedIds = visitedIdsByTableName.lecass = new Set()
246
- }
247
- if (!visitedIds.has(lecass.lecassidt)) {
248
- visitedIds.add(lecass.lecassidt)
249
-
250
- if (lecass.codass !== null && data.ass !== undefined) {
251
- const ass = data.ass[lecass.codass]
252
- if (ass !== undefined) {
253
- lecass.ass = ass
254
- // insertAssReferences(ass, data, visitedIdsByTableName)
255
- }
256
- }
257
-
258
- if (lecass.orgcod !== null && data.org !== undefined) {
259
- const org = data.org[lecass.orgcod]
260
- if (org !== undefined) {
261
- lecass.org = org
262
- // insertOrgReferences(org, data, visitedIdsByTableName)
263
- }
264
- }
265
-
266
- lecass.auds = []
267
- if (lecass.audcles !== undefined && data.aud !== undefined) {
268
- for (const audcle of lecass.audcles) {
269
- const aud = data.aud[audcle]
270
- if (aud !== undefined) {
271
- lecass.auds.push(aud)
272
- insertAudReferences(aud, data, visitedIdsByTableName)
273
- }
274
- }
275
- }
276
-
277
- lecass.datesSeances = []
278
- if (lecass.datesSeancesCodes !== undefined && data.date_seance !== undefined) {
279
- for (const dateSeanceCode of lecass.datesSeancesCodes) {
280
- const dateSeance = data.date_seance[dateSeanceCode]
281
- if (dateSeance !== undefined) {
282
- lecass.datesSeances.push(dateSeance)
283
- insertDateSeanceReferences(dateSeance, data, visitedIdsByTableName)
284
- }
285
- }
286
- }
287
-
288
- lecass.lecassraps = []
289
- if (lecass.lecassrapids !== undefined && data.lecassrap !== undefined) {
290
- for (const lecassrapid of lecass.lecassrapids) {
291
- const lecassrap = data.lecassrap[lecassrapid]
292
- if (lecassrap !== undefined) {
293
- lecass.lecassraps.push(lecassrap)
294
- insertLecassrapReferences(lecassrap, data, visitedIdsByTableName)
295
- }
296
- }
297
- }
298
-
299
- lecass.textes = []
300
- if (lecass.texcods !== undefined && data.texte !== undefined) {
301
- for (const texcod of lecass.texcods) {
302
- const texte = data.texte[texcod]
303
- if (texte !== undefined) {
304
- lecass.textes.push(texte)
305
- insertTexteReferences(texte, data, visitedIdsByTableName)
306
- }
307
- }
308
- }
309
- }
310
-
311
- return lecass
312
- }
313
-
314
- export function insertLectureReferences(
315
- lecture: Lecture,
316
- data: OutputData,
317
- visitedIdsByTableName: VisitedIdsByTableName,
318
- ) {
319
- let visitedIds = visitedIdsByTableName.lecture
320
- if (visitedIds === undefined) {
321
- visitedIds = visitedIdsByTableName.lecture = new Set()
322
- }
323
- if (!visitedIds.has(lecture.lecidt)) {
324
- visitedIds.add(lecture.lecidt)
325
-
326
- if (lecture.typleccod !== null && data.typlec !== undefined) {
327
- const typlec = data.typlec[lecture.typleccod]
328
- if (typlec !== undefined) {
329
- lecture.typlec = typlec
330
- // insertTyplecReferences(typlec, data, visitedIdsByTableName)
331
- }
332
- }
333
-
334
- lecture.lecasss = []
335
- if (lecture.lecassidts !== undefined && data.lecass !== undefined) {
336
- for (const lecassidt of lecture.lecassidts) {
337
- const lecass = data.lecass[lecassidt]
338
- if (lecass !== undefined) {
339
- lecture.lecasss.push(lecass)
340
- insertLecassReferences(lecass, data, visitedIdsByTableName)
341
- }
342
- }
343
- }
344
- }
345
-
346
- return lecture
347
- }
348
-
349
- export function insertLoiReferences(
350
- loi: Loi,
351
- data: OutputData,
352
- visitedIdsByTableName: VisitedIdsByTableName,
353
- ) {
354
- let visitedIds = visitedIdsByTableName.loi
355
- if (visitedIds === undefined) {
356
- visitedIds = visitedIdsByTableName.loi = new Set()
357
- }
358
- if (!visitedIds.has(loi.loicod)) {
359
- visitedIds.add(loi.loicod)
360
-
361
- if (loi.typloicod !== null && data.typloi !== undefined) {
362
- const typloi = data.typloi[loi.typloicod]
363
- if (typloi !== undefined) {
364
- loi.typloi = typloi
365
- // insertTyploiReferences(typloi, data, visitedIdsByTableName)
366
- }
367
- }
368
-
369
- if (loi.etaloicod !== null && data.etaloi !== undefined) {
370
- const etaloi = data.etaloi[loi.etaloicod]
371
- if (etaloi !== undefined) {
372
- loi.etaloi = etaloi
373
- // insertEtaloiReferences(etaloi, data, visitedIdsByTableName)
374
- }
375
- }
376
-
377
- if (loi.deccoccod !== null && data.deccoc !== undefined) {
378
- const deccoc = data.deccoc[loi.deccoccod]
379
- if (deccoc !== undefined) {
380
- loi.deccoc = deccoc
381
- // insertDeccocReferences(deccoc, data, visitedIdsByTableName)
382
- }
383
- }
384
-
385
- loi.lectures = []
386
- if (loi.lecidts !== undefined && data.lecture !== undefined) {
387
- for (const lecidt of loi.lecidts) {
388
- const lecture = data.lecture[lecidt]
389
- if (lecture !== undefined) {
390
- loi.lectures.push(lecture)
391
- insertLectureReferences(lecture, data, visitedIdsByTableName)
392
- }
393
- }
394
- }
395
- }
396
-
397
- return loi
398
- }
399
-
400
- export function insertQuestionReferences(
401
- question: Question,
402
- // @ts-ignore TO BE REMOVED WHEN DONE
403
- data: OutputData,
404
- // @ts-ignore TO BE REMOVED WHEN DONE
405
- visitedIdsByTableName: VisitedIdsByTableName,
406
- ) {
407
- // TODO
408
- return question
409
- }
410
-
411
- export function insertRapReferences(
412
- rap: Rap,
413
- data: OutputData,
414
- visitedIdsByTableName: VisitedIdsByTableName,
415
- ) {
416
- let visitedIds = visitedIdsByTableName.rap
417
- if (visitedIds === undefined) {
418
- visitedIds = visitedIdsByTableName.rap = new Set()
419
- }
420
- if (!visitedIds.has(rap.rapcod)) {
421
- visitedIds.add(rap.rapcod)
422
-
423
- if (rap.coddenrap !== null && data.denrap !== undefined) {
424
- const denrap = data.denrap[rap.coddenrap]
425
- if (denrap !== undefined) {
426
- rap.denrap = denrap
427
- // insertDenrapReferences(denrap, data, visitedIdsByTableName)
428
- }
429
- }
430
-
431
- rap.docatts = []
432
- if (rap.docattcles !== undefined && data.docatt !== undefined) {
433
- for (const docattcle of rap.docattcles) {
434
- const docatt = data.docatt[docattcle]
435
- if (docatt !== undefined) {
436
- rap.docatts.push(docatt)
437
- insertDocAttReferences(docatt, data, visitedIdsByTableName, false)
438
- }
439
- }
440
- }
441
-
442
- rap.ecrs = []
443
- if (rap.ecrnums !== undefined && data.ecr !== undefined) {
444
- for (const ecrnum of rap.ecrnums) {
445
- const ecr = data.ecr[ecrnum]
446
- if (ecr !== undefined) {
447
- rap.ecrs.push(ecr)
448
- insertEcrReferences(ecr, data, visitedIdsByTableName)
449
- }
450
- }
451
- }
452
-
453
- rap.orgs = []
454
- if (rap.orgcods !== undefined && data.org !== undefined) {
455
- for (const orgcod of rap.orgcods) {
456
- const org = data.org[orgcod]
457
- if (org !== undefined) {
458
- rap.orgs.push(org)
459
- // insertOrgReferences(org, data, visitedIdsByTableName)
460
- }
461
- }
462
- }
463
- }
464
-
465
- return rap
466
- }
467
-
468
- export function insertSenReferences(
469
- sen: Sen,
470
- // @ts-ignore TO BE REMOVED WHEN DONE
471
- data: OutputData,
472
- // @ts-ignore TO BE REMOVED WHEN DONE
473
- visitedIdsByTableName: VisitedIdsByTableName,
474
- ) {
475
- // TODO
476
- return sen
477
- }
478
-
479
- export function insertTexteReferences(
480
- texte: Texte,
481
- data: OutputData,
482
- visitedIdsByTableName: VisitedIdsByTableName,
483
- ) {
484
- let visitedIds = visitedIdsByTableName.texte
485
- if (visitedIds === undefined) {
486
- visitedIds = visitedIdsByTableName.texte = new Set()
487
- }
488
- if (!visitedIds.has(texte.texcod)) {
489
- visitedIds.add(texte.texcod)
490
-
491
- texte.ecrs = []
492
- if (texte.ecrnums !== undefined && data.ecr !== undefined) {
493
- for (const ecrnum of texte.ecrnums) {
494
- const ecr = data.ecr[ecrnum]
495
- if (ecr !== undefined) {
496
- texte.ecrs.push(ecr)
497
- insertEcrReferences(ecr, data, visitedIdsByTableName)
498
- }
499
- }
500
- }
501
-
502
- if (texte.orgcod !== null && data.org !== undefined) {
503
- const org = data.org[texte.orgcod]
504
- if (org !== undefined) {
505
- texte.org = org
506
- // insertOrgReferences(org, data, visitedIdsByTableName)
507
- }
508
- }
509
-
510
- if (texte.oritxtcod !== null && data.oritxt !== undefined) {
511
- const oritxt = data.oritxt[texte.oritxtcod]
512
- if (oritxt !== undefined) {
513
- texte.oritxt = oritxt
514
- // insertOritxtReferences(oritxt, data, visitedIdsByTableName)
515
- }
516
- }
517
-
518
- if (texte.txtAmeliId !== undefined && data.txt_ameli !== undefined) {
519
- const txtAmeli = data.txt_ameli[texte.txtAmeliId]
520
- if (txtAmeli !== undefined) {
521
- texte.txtAmeli = txtAmeli
522
- }
523
- }
524
-
525
- if (texte.typtxtcod !== null && data.typtxt !== undefined) {
526
- const typtxt = data.typtxt[texte.typtxtcod]
527
- if (typtxt !== undefined) {
528
- texte.typtxt = typtxt
529
- // insertTyptxtReferences(typtxt, data, visitedIdsByTableName)
530
- }
531
- }
532
-
533
- if (texte.typurl !== null && data.typurl !== undefined) {
534
- const typurl = data.typurl[texte.typurl]
535
- if (typurl !== undefined) {
536
- texte.libtypurl = typurl.libtypurl
537
- // insertTypurlReferences(typurl, data, visitedIdsByTableName)
538
- }
539
- }
540
-
541
- // TODO
542
- }
543
-
544
- return texte
545
- }
@@ -1,57 +0,0 @@
1
- import { sesFieldsToParseInt, sesFieldsToTrim, subFieldsToParseInt, subFieldsToTrim, txtAmeliFieldsToTrim } from '../types/ameli';
2
- import { dbByName } from "../databases";
3
- import { parseIntFields, trimFieldsRight } from '../fields';
4
- export const getSessFromAnns = async (ids) => {
5
- if (ids.length === 0) {
6
- return [];
7
- }
8
- return (await dbByName.ameli.any(`
9
- SELECT *
10
- FROM ses
11
- WHERE ann IN ($<ids:list>)
12
- `, {
13
- ids,
14
- })).map((ses) => parseIntFields(sesFieldsToParseInt, trimFieldsRight(sesFieldsToTrim, ses)));
15
- };
16
- export const getSubsFromTxtids = async (ids) => {
17
- if (ids.length === 0) {
18
- return [];
19
- }
20
- return (await dbByName.ameli.any(`
21
- SELECT *
22
- FROM sub
23
- WHERE txtid IN($<ids:list>)
24
- `, {
25
- ids,
26
- })).map((sub) => parseIntFields(subFieldsToParseInt, trimFieldsRight(subFieldsToTrim, sub)));
27
- };
28
- export const getTxtsAmeliBySesannNumJoins = async (ids) => {
29
- if (ids.length === 0) {
30
- return [];
31
- }
32
- const txtsAmelis = [];
33
- for (const id of ids) {
34
- const idSplit = id.split(" ");
35
- const sesann = parseInt(idSplit[0]);
36
- const num = idSplit[1];
37
- const txtAmeli = trimFieldsRight(txtAmeliFieldsToTrim, await dbByName.ameli.oneOrNone(`
38
- SELECT *
39
- FROM txt_ameli
40
- WHERE
41
- sesinsid in (
42
- SELECT id
43
- FROM ses
44
- WHERE ann = $<sesann>
45
- ) AND
46
- num = $<num>
47
- LIMIT 1
48
- `, {
49
- num,
50
- sesann,
51
- }));
52
- if (txtAmeli !== null) {
53
- txtsAmelis.push(txtAmeli);
54
- }
55
- }
56
- return txtsAmelis;
57
- };
@@ -1,86 +0,0 @@
1
- import {
2
- Ses, sesFieldsToParseInt, sesFieldsToTrim,
3
- Sub, subFieldsToParseInt, subFieldsToTrim,
4
- TxtAmeli, txtAmeliFieldsToTrim
5
- } from '../types/ameli'
6
- import { dbByName } from "../databases"
7
- import { parseIntFields, trimFieldsRight } from '../fields'
8
-
9
- export const getSessFromAnns = async (ids: string[]): Promise<Ses[]> => {
10
- if (ids.length === 0) {
11
- return []
12
- }
13
- return (
14
- await dbByName.ameli.any(
15
- `
16
- SELECT *
17
- FROM ses
18
- WHERE ann IN ($<ids:list>)
19
- `,
20
- {
21
- ids,
22
- },
23
- )
24
- ).map((ses: Ses) =>
25
- parseIntFields(sesFieldsToParseInt, trimFieldsRight(sesFieldsToTrim, ses)),
26
- )
27
- }
28
-
29
- export const getSubsFromTxtids = async (ids: string[]): Promise<Sub[]> => {
30
- if (ids.length === 0) {
31
- return []
32
- }
33
- return (
34
- await dbByName.ameli.any(
35
- `
36
- SELECT *
37
- FROM sub
38
- WHERE txtid IN($<ids:list>)
39
- `,
40
- {
41
- ids,
42
- },
43
- )
44
- ).map((sub: Sub) =>
45
- parseIntFields(subFieldsToParseInt, trimFieldsRight(subFieldsToTrim, sub)),
46
- )
47
- }
48
-
49
- export const getTxtsAmeliBySesannNumJoins = async (
50
- ids: string[],
51
- ): Promise<TxtAmeli[]> => {
52
- if (ids.length === 0) {
53
- return []
54
- }
55
- const txtsAmelis = []
56
- for (const id of ids) {
57
- const idSplit = id.split(" ")
58
- const sesann = parseInt(idSplit[0])
59
- const num = idSplit[1]
60
- const txtAmeli = trimFieldsRight(
61
- txtAmeliFieldsToTrim,
62
- await dbByName.ameli.oneOrNone(
63
- `
64
- SELECT *
65
- FROM txt_ameli
66
- WHERE
67
- sesinsid in (
68
- SELECT id
69
- FROM ses
70
- WHERE ann = $<sesann>
71
- ) AND
72
- num = $<num>
73
- LIMIT 1
74
- `,
75
- {
76
- num,
77
- sesann,
78
- },
79
- ),
80
- ) as TxtAmeli
81
- if (txtAmeli !== null) {
82
- txtsAmelis.push(txtAmeli)
83
- }
84
- }
85
- return txtsAmelis
86
- }