@tricoteuses/senat 0.3.2 → 1.1.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 (131) hide show
  1. package/README.md +55 -0
  2. package/lib/aggregates.d.ts +54 -0
  3. package/lib/aggregates.js +1122 -0
  4. package/lib/aggregates.mjs +802 -0
  5. package/lib/aggregates.ts +947 -0
  6. package/lib/config.d.ts +2 -0
  7. package/lib/config.js +49 -0
  8. package/lib/config.mjs +16 -0
  9. package/lib/config.ts +26 -0
  10. package/lib/databases.d.ts +11 -0
  11. package/lib/databases.js +125 -0
  12. package/lib/databases.mjs +26 -0
  13. package/lib/databases.ts +32 -0
  14. package/lib/datasets.d.ts +28 -0
  15. package/lib/datasets.js +93 -0
  16. package/lib/datasets.mjs +78 -0
  17. package/lib/datasets.ts +118 -0
  18. package/lib/fields.d.ts +10 -0
  19. package/lib/fields.js +68 -0
  20. package/lib/fields.mjs +22 -0
  21. package/lib/fields.ts +29 -0
  22. package/lib/index.d.ts +6 -5
  23. package/lib/index.js +236 -7
  24. package/lib/index.mjs +6 -1
  25. package/lib/index.ts +59 -0
  26. package/lib/inserters.d.ts +6 -2
  27. package/lib/inserters.js +86 -191
  28. package/lib/inserters.mjs +19 -3
  29. package/lib/inserters.ts +545 -0
  30. package/lib/model/ameli.d.ts +4 -0
  31. package/lib/model/ameli.js +167 -0
  32. package/lib/model/ameli.mjs +57 -0
  33. package/lib/model/ameli.ts +86 -0
  34. package/lib/model/debats.d.ts +4 -0
  35. package/lib/model/debats.js +123 -0
  36. package/lib/model/debats.mjs +43 -0
  37. package/lib/model/debats.ts +68 -0
  38. package/lib/model/dosleg.d.ts +29 -0
  39. package/lib/model/dosleg.js +840 -0
  40. package/lib/model/dosleg.mjs +337 -0
  41. package/lib/model/dosleg.ts +558 -0
  42. package/lib/model/index.d.ts +5 -0
  43. package/lib/model/index.js +48 -0
  44. package/lib/model/index.mjs +5 -0
  45. package/lib/model/index.ts +11 -0
  46. package/lib/model/questions.d.ts +2 -0
  47. package/lib/model/questions.js +52 -0
  48. package/lib/model/questions.mjs +8 -0
  49. package/lib/model/questions.ts +14 -0
  50. package/lib/model/sens.d.ts +2 -0
  51. package/lib/model/sens.js +57 -0
  52. package/lib/model/sens.mjs +9 -0
  53. package/lib/model/sens.ts +18 -0
  54. package/lib/model/util.d.ts +1 -0
  55. package/lib/model/util.js +60 -0
  56. package/lib/model/util.mjs +10 -0
  57. package/lib/model/util.ts +16 -0
  58. package/lib/raw_types/ameli.d.ts +416 -410
  59. package/lib/raw_types/ameli.js +26 -144
  60. package/lib/raw_types/ameli.ts +601 -0
  61. package/lib/raw_types/debats.d.ts +82 -80
  62. package/lib/raw_types/debats.js +8 -42
  63. package/lib/raw_types/debats.ts +145 -0
  64. package/lib/raw_types/dosleg.d.ts +936 -920
  65. package/lib/raw_types/dosleg.js +5 -345
  66. package/lib/raw_types/dosleg.ts +2193 -0
  67. package/lib/raw_types/questions.d.ts +226 -2
  68. package/lib/raw_types/questions.js +18 -5
  69. package/lib/raw_types/questions.mjs +1 -8
  70. package/lib/raw_types/questions.ts +249 -0
  71. package/lib/raw_types/sens.d.ts +1180 -1176
  72. package/lib/raw_types/sens.js +3 -397
  73. package/lib/raw_types/sens.ts +2907 -0
  74. package/lib/scripts/convert_data.d.ts +1 -0
  75. package/lib/scripts/convert_data.js +284 -0
  76. package/lib/scripts/convert_data.mjs +146 -0
  77. package/lib/scripts/convert_data.ts +182 -0
  78. package/lib/scripts/fix_db.d.ts +1 -0
  79. package/lib/scripts/fix_db.js +144 -0
  80. package/lib/scripts/fix_db.mjs +64 -0
  81. package/lib/scripts/fix_db.ts +75 -0
  82. package/lib/scripts/images/transparent_150x192.jpg +0 -0
  83. package/lib/scripts/images/transparent_155x225.jpg +0 -0
  84. package/lib/scripts/retrieve_open_data.d.ts +1 -0
  85. package/lib/scripts/retrieve_open_data.js +371 -0
  86. package/lib/scripts/retrieve_open_data.mjs +218 -0
  87. package/lib/scripts/retrieve_open_data.ts +258 -0
  88. package/lib/scripts/retrieve_senateurs_photos.d.ts +1 -0
  89. package/lib/scripts/retrieve_senateurs_photos.js +268 -0
  90. package/lib/scripts/retrieve_senateurs_photos.mjs +164 -0
  91. package/lib/scripts/retrieve_senateurs_photos.ts +200 -0
  92. package/lib/scripts/retrieve_textes.d.ts +1 -0
  93. package/lib/scripts/retrieve_textes.js +179 -0
  94. package/lib/scripts/retrieve_textes.mjs +77 -0
  95. package/lib/scripts/retrieve_textes.ts +95 -0
  96. package/lib/strings.d.ts +1 -0
  97. package/lib/strings.js +49 -0
  98. package/lib/strings.mjs +18 -0
  99. package/lib/strings.ts +26 -0
  100. package/lib/types/ameli.d.ts +5 -0
  101. package/lib/types/ameli.js +7 -4
  102. package/lib/types/ameli.mjs +13 -1
  103. package/lib/types/ameli.ts +21 -0
  104. package/lib/types/debats.d.ts +2 -0
  105. package/lib/types/debats.js +4 -3
  106. package/lib/types/debats.mjs +2 -1
  107. package/lib/types/debats.ts +6 -0
  108. package/lib/types/dosleg.d.ts +28 -0
  109. package/lib/types/dosleg.js +30 -3
  110. package/lib/types/dosleg.mjs +151 -1
  111. package/lib/types/dosleg.ts +284 -0
  112. package/lib/types/questions.d.ts +2 -0
  113. package/lib/types/questions.js +13 -1
  114. package/lib/types/questions.mjs +1 -1
  115. package/lib/types/questions.ts +3 -0
  116. package/lib/types/sens.d.ts +2 -0
  117. package/lib/types/sens.js +4 -3
  118. package/lib/types/sens.mjs +23 -1
  119. package/lib/types/sens.ts +36 -0
  120. package/lib/typings/windows-1252.d.js +2 -0
  121. package/lib/typings/windows-1252.d.mjs +2 -0
  122. package/lib/typings/windows-1252.d.ts +11 -0
  123. package/lib/validators/config.d.ts +1 -0
  124. package/lib/validators/config.js +121 -0
  125. package/lib/validators/config.mjs +54 -0
  126. package/lib/validators/config.ts +79 -0
  127. package/lib/validators/senat.d.ts +0 -0
  128. package/lib/validators/senat.js +28 -0
  129. package/lib/validators/senat.mjs +24 -0
  130. package/lib/validators/senat.ts +26 -0
  131. package/package.json +35 -4
@@ -0,0 +1,947 @@
1
+ import {
2
+ Ses,
3
+ Sub,
4
+ TxtAmeli,
5
+ } from './types/ameli'
6
+ import { Debat } from './types/debats'
7
+ import {
8
+ Ass,
9
+ Aud,
10
+ Auteur,
11
+ DateSeance,
12
+ DecCoc,
13
+ DenRap,
14
+ DocAtt,
15
+ Ecr,
16
+ EtaLoi,
17
+ LecAss,
18
+ LecAssRap,
19
+ Lecture,
20
+ Loi,
21
+ Org,
22
+ OriTxt,
23
+ Qua,
24
+ Rap,
25
+ Scr,
26
+ Texte,
27
+ TypAtt,
28
+ TypLec,
29
+ TypLoi,
30
+ TypTxt,
31
+ TypUrl,
32
+ } from './types/dosleg'
33
+ import { Question } from './types/questions'
34
+ import { Sen } from './types/sens'
35
+ import {
36
+ getSessFromAnns,
37
+ getSubsFromTxtids,
38
+ getTxtsAmeliBySesannNumJoins,
39
+ } from './model/ameli'
40
+ import {
41
+ getDebats,
42
+ getDebatsFromLecassidts,
43
+ getLecAssDebsFromDatseas,
44
+ } from './model/debats'
45
+ import {
46
+ getAsss,
47
+ getAudsFromLecassidts,
48
+ getAuteurs,
49
+ getDatesSeancesFromLecassidts,
50
+ getDeccocs,
51
+ getDenraps,
52
+ getDocattsFromRapcods,
53
+ getEcrsFromRapcods,
54
+ getEcrsFromTexcods,
55
+ getEtalois,
56
+ getLecassrapsFromLecassidts,
57
+ getLecasssFromLecidts,
58
+ getLecturesFromLoicods,
59
+ getLois,
60
+ getOrgs,
61
+ getOrgsFromRapcods,
62
+ getOritxts,
63
+ getQuas,
64
+ getRaporgsFromOrgcods,
65
+ getRaps,
66
+ getScrsFromCodes,
67
+ getTextesFromLecassidts,
68
+ getTypatts,
69
+ getTyplecs,
70
+ getTyplois,
71
+ getTyptxts,
72
+ getTypurls,
73
+ } from './model/dosleg'
74
+
75
+ export const allFollows = [
76
+ "aud.org",
77
+ "auteur.qua",
78
+ "dateSeance.debat",
79
+ "dateSeance.scrs",
80
+ "docatt.rec",
81
+ "docatt.typatt",
82
+ "ecr.aut",
83
+ "lecass.ass",
84
+ "lecass.auds",
85
+ "lecass.datesSeances",
86
+ "lecass.debats",
87
+ "lecass.lecassraps",
88
+ "lecass.org",
89
+ "lecass.textes",
90
+ "lecassrap.rap",
91
+ "lecture.lecasss",
92
+ "lecture.typlec",
93
+ "loi.deccoc",
94
+ "loi.etaloi",
95
+ "loi.lectures",
96
+ "loi.typloi",
97
+ "rap.denrap",
98
+ "rap.docatts",
99
+ "rap.ecrs",
100
+ "rap.orgs",
101
+ "texte.ecrs",
102
+ "texte.org",
103
+ "texte.oritxt",
104
+ "texte.txtAmeli",
105
+ "texte.typtxt",
106
+ "texte.typurl",
107
+ "txtAmeli.subs",
108
+ ]
109
+
110
+ export class Aggregator {
111
+ objectByIdByTableName: { [name: string]: { [id: string]: object } } = {}
112
+ requestedIdsByTableName: { [name: string]: Set<string> } = {}
113
+ visitedIdsByTableName: { [name: string]: Set<string> } = {}
114
+
115
+ constructor(public follow: Set<string>) {}
116
+
117
+ addAss(ass: Ass): void {
118
+ let objectById = this.objectByIdByTableName.ass
119
+ if (objectById === undefined) {
120
+ objectById = this.objectByIdByTableName.ass = {}
121
+ }
122
+ objectById[ass.codass] = ass
123
+ }
124
+
125
+ addAud(aud: Aud): void {
126
+ let objectById = this.objectByIdByTableName.aud
127
+ if (objectById === undefined) {
128
+ objectById = this.objectByIdByTableName.aud = {}
129
+ }
130
+ objectById[aud.audcle] = aud
131
+
132
+ if (aud.orgcod !== null && this.follow.has("aud.org")) {
133
+ this.request("org", aud.orgcod)
134
+ }
135
+ }
136
+
137
+ addAuteur(auteur: Auteur): void {
138
+ let objectById = this.objectByIdByTableName.auteur
139
+ if (objectById === undefined) {
140
+ objectById = this.objectByIdByTableName.auteur = {}
141
+ }
142
+ objectById[auteur.autcod] = auteur
143
+
144
+ if (this.follow.has("auteur.qua")) {
145
+ this.request("qua", auteur.quacod)
146
+ }
147
+
148
+ // TODO
149
+ }
150
+
151
+ addDateSeance(dateSeance: DateSeance): void {
152
+ let objectById = this.objectByIdByTableName.date_seance
153
+ if (objectById === undefined) {
154
+ objectById = this.objectByIdByTableName.date_seance = {}
155
+ }
156
+ objectById[dateSeance.code] = dateSeance
157
+
158
+ if (dateSeance.date_s !== null && this.follow.has("dateSeance.debat")) {
159
+ this.request("debats", dateSeance.date_s.toISOString())
160
+ }
161
+
162
+ if (this.follow.has("dateSeance.scrs")) {
163
+ this.request("scr_by_code", dateSeance.code.toString())
164
+ }
165
+ }
166
+
167
+ addDebat(debat: Debat): void {
168
+ let objectById = this.objectByIdByTableName.debats
169
+ if (objectById === undefined) {
170
+ objectById = this.objectByIdByTableName.debats = {}
171
+ }
172
+ objectById[debat.datsea.toISOString()] = debat
173
+ }
174
+
175
+ addDeccoc(deccoc: DecCoc): void {
176
+ let objectById = this.objectByIdByTableName.deccoc
177
+ if (objectById === undefined) {
178
+ objectById = this.objectByIdByTableName.deccoc = {}
179
+ }
180
+ objectById[deccoc.deccoccod] = deccoc
181
+ }
182
+
183
+ addDenrap(denrap: DenRap): void {
184
+ let objectById = this.objectByIdByTableName.denrap
185
+ if (objectById === undefined) {
186
+ objectById = this.objectByIdByTableName.denrap = {}
187
+ }
188
+ objectById[denrap.coddenrap] = denrap
189
+ }
190
+
191
+ addDocatt(docatt: DocAtt): void {
192
+ let objectById = this.objectByIdByTableName.docatt
193
+ if (objectById === undefined) {
194
+ objectById = this.objectByIdByTableName.docatt = {}
195
+ }
196
+ objectById[docatt.docattcle] = docatt
197
+
198
+ if (this.follow.has("docatt.rap")) {
199
+ this.request("rap", docatt.rapcod.toString())
200
+ }
201
+
202
+ if (this.follow.has("docatt.typatt")) {
203
+ this.request("typatt", docatt.rapcod.toString())
204
+ }
205
+ }
206
+
207
+ addEcr(ecr: Ecr): void {
208
+ let objectById = this.objectByIdByTableName.ecr
209
+ if (objectById === undefined) {
210
+ objectById = this.objectByIdByTableName.ecr = {}
211
+ }
212
+ objectById[ecr.ecrnum] = ecr
213
+
214
+ if (ecr.autcod !== null && this.follow.has("ecr.aut")) {
215
+ this.request("auteur", ecr.autcod)
216
+ }
217
+ }
218
+
219
+ addEtaloi(etaloi: EtaLoi): void {
220
+ let objectById = this.objectByIdByTableName.etaloi
221
+ if (objectById === undefined) {
222
+ objectById = this.objectByIdByTableName.etaloi = {}
223
+ }
224
+ objectById[etaloi.etaloicod] = etaloi
225
+ }
226
+
227
+ addLecass(lecass: LecAss): void {
228
+ let objectById = this.objectByIdByTableName.lecass
229
+ if (objectById === undefined) {
230
+ objectById = this.objectByIdByTableName.lecass = {}
231
+ }
232
+ objectById[lecass.lecassidt] = lecass
233
+
234
+ if (this.follow.has("lecass.ass")) {
235
+ this.request("ass", lecass.codass)
236
+ }
237
+
238
+ if (lecass.orgcod !== null && this.follow.has("lecass.org")) {
239
+ this.request("org", lecass.orgcod)
240
+ }
241
+
242
+ if (this.follow.has("lecass.auds")) {
243
+ this.request("aud_by_lecassidt", lecass.lecassidt)
244
+ }
245
+
246
+ if (this.follow.has("lecass.datesSeances")) {
247
+ this.request("date_seance_by_lecassidt", lecass.lecassidt)
248
+ }
249
+
250
+ if (this.follow.has("lecass.debats")) {
251
+ this.request("debat_by_lecassidt", lecass.lecassidt)
252
+ }
253
+
254
+ if (this.follow.has("lecass.lecassraps")) {
255
+ this.request("lecassrap_by_lecassidt", lecass.lecassidt)
256
+ }
257
+
258
+ if (this.follow.has("lecass.textes")) {
259
+ this.request("texte_by_lecassidt", lecass.lecassidt)
260
+ }
261
+ }
262
+
263
+ addLecassrap(lecassrap: LecAssRap): void {
264
+ let objectById = this.objectByIdByTableName.lecassrap
265
+ if (objectById === undefined) {
266
+ objectById = this.objectByIdByTableName.lecassrap = {}
267
+ }
268
+ objectById[`${lecassrap.lecassidt} ${lecassrap.rapcod}`] = lecassrap
269
+
270
+ if (this.follow.has("lecassrap.rap")) {
271
+ this.request("rap", lecassrap.rapcod.toString())
272
+ }
273
+ }
274
+
275
+ addLecture(lecture: Lecture): void {
276
+ let objectById = this.objectByIdByTableName.lecture
277
+ if (objectById === undefined) {
278
+ objectById = this.objectByIdByTableName.lecture = {}
279
+ }
280
+ objectById[lecture.lecidt] = lecture
281
+
282
+ if (this.follow.has("lecture.typlec")) {
283
+ this.request("typlec", lecture.typleccod)
284
+ }
285
+
286
+ if (this.follow.has("lecture.lecasss")) {
287
+ this.request("lecasss_by_lecidt", lecture.lecidt)
288
+ }
289
+ }
290
+
291
+ addLoi(loi: Loi): void {
292
+ let objectById = this.objectByIdByTableName.loi
293
+ if (objectById === undefined) {
294
+ objectById = this.objectByIdByTableName.loi = {}
295
+ }
296
+ objectById[loi.loicod] = loi
297
+
298
+ if (this.follow.has("loi.typloi")) {
299
+ this.request("typloi", loi.typloicod)
300
+ }
301
+
302
+ if (this.follow.has("loi.etaloi") && loi.etaloicod !== null) {
303
+ this.request("etaloi", loi.etaloicod)
304
+ }
305
+
306
+ if (this.follow.has("loi.deccoc") && loi.deccoccod !== null) {
307
+ this.request("deccoc", loi.deccoccod)
308
+ }
309
+
310
+ if (this.follow.has("loi.lectures")) {
311
+ this.request("lectures_by_loicod", loi.loicod)
312
+ }
313
+ }
314
+
315
+ addOrg(org: Org): void {
316
+ let objectById = this.objectByIdByTableName.org
317
+ if (objectById === undefined) {
318
+ objectById = this.objectByIdByTableName.org = {}
319
+ }
320
+ objectById[org.orgcod] = org
321
+
322
+ // TODO
323
+ }
324
+
325
+ addOritxt(oritxt: OriTxt): void {
326
+ let objectById = this.objectByIdByTableName.oritxt
327
+ if (objectById === undefined) {
328
+ objectById = this.objectByIdByTableName.oritxt = {}
329
+ }
330
+ objectById[oritxt.oritxtcod] = oritxt
331
+
332
+ // TODO
333
+ }
334
+
335
+ addQua(qua: Qua): void {
336
+ let objectById = this.objectByIdByTableName.qua
337
+ if (objectById === undefined) {
338
+ objectById = this.objectByIdByTableName.qua = {}
339
+ }
340
+ objectById[qua.quacod] = qua
341
+ }
342
+
343
+ addQuestion(question: Question): void {
344
+ let objectById = this.objectByIdByTableName.tam_questions
345
+ if (objectById === undefined) {
346
+ objectById = this.objectByIdByTableName.tam_questions = {}
347
+ }
348
+ objectById[question.id] = question
349
+ }
350
+
351
+ addRap(rap: Rap): void {
352
+ let objectById = this.objectByIdByTableName.rap
353
+ if (objectById === undefined) {
354
+ objectById = this.objectByIdByTableName.rap = {}
355
+ }
356
+ objectById[rap.rapcod.toString()] = rap
357
+
358
+ if (this.follow.has("rap.denrap")) {
359
+ this.request("denrap", rap.coddenrap)
360
+ }
361
+
362
+ if (this.follow.has("rap.docatts")) {
363
+ this.request("docatt_by_rapcod", rap.rapcod.toString())
364
+ }
365
+
366
+ if (this.follow.has("rap.ecrs")) {
367
+ this.request("ecr_by_rapcod", rap.rapcod.toString())
368
+ }
369
+
370
+ if (this.follow.has("rap.orgs")) {
371
+ this.request("org_by_rapcod", rap.rapcod.toString())
372
+ }
373
+
374
+ // TODO
375
+ }
376
+
377
+ addScr(scr: Scr): void {
378
+ let objectById = this.objectByIdByTableName.scr
379
+ if (objectById === undefined) {
380
+ objectById = this.objectByIdByTableName.scr = {}
381
+ }
382
+ objectById[`${scr.sesann} ${scr.scrnum}`] = scr
383
+
384
+ // TODO
385
+ }
386
+
387
+ addSen(sen: Sen): void {
388
+ let objectById = this.objectByIdByTableName.sen
389
+ if (objectById === undefined) {
390
+ objectById = this.objectByIdByTableName.sen = {}
391
+ }
392
+ objectById[sen.senmat] = sen
393
+ }
394
+
395
+ addSes(ses: Ses): void {
396
+ let objectById = this.objectByIdByTableName.ses
397
+ if (objectById === undefined) {
398
+ objectById = this.objectByIdByTableName.ses = {}
399
+ }
400
+ objectById[ses.id] = ses
401
+ }
402
+
403
+ addSub(sub: Sub): void {
404
+ let objectById = this.objectByIdByTableName.sub
405
+ if (objectById === undefined) {
406
+ objectById = this.objectByIdByTableName.sub = {}
407
+ }
408
+ objectById[sub.id] = sub
409
+
410
+ // TODO
411
+ }
412
+
413
+ addTexte(texte: Texte): void {
414
+ let objectById = this.objectByIdByTableName.texte
415
+ if (objectById === undefined) {
416
+ objectById = this.objectByIdByTableName.texte = {}
417
+ }
418
+ objectById[texte.texcod] = texte
419
+
420
+ if (this.follow.has("texte.ecrs")) {
421
+ this.request("ecr_by_texcod", texte.texcod.toString())
422
+ }
423
+
424
+ if (texte.orgcod !== null && this.follow.has("texte.org")) {
425
+ this.request("org", texte.orgcod)
426
+ }
427
+
428
+ if (texte.oritxtcod !== null && this.follow.has("texte.oritxt")) {
429
+ this.request("oritxt", texte.oritxtcod)
430
+ }
431
+
432
+ if (
433
+ texte.sesann !== null &&
434
+ texte.texnum !== null &&
435
+ this.follow.has("texte.txtAmeli")
436
+ ) {
437
+ this.request("ses_by_ann", texte.sesann.toString())
438
+ this.request("txt_ameli_by_sesann_num", `${texte.sesann} ${texte.texnum}`)
439
+ }
440
+
441
+ if (texte.typtxtcod !== null && this.follow.has("texte.typtxt")) {
442
+ this.request("typtxt", texte.typtxtcod)
443
+ }
444
+
445
+ if (texte.typurl !== null && this.follow.has("texte.typurl")) {
446
+ this.request("typurl", texte.typurl)
447
+ }
448
+ }
449
+
450
+ addTxtAmeli(txtAmeli: TxtAmeli): void {
451
+ let objectById = this.objectByIdByTableName.txt_ameli
452
+ if (objectById === undefined) {
453
+ objectById = this.objectByIdByTableName.txt_ameli = {}
454
+ }
455
+ objectById[txtAmeli.id] = txtAmeli
456
+
457
+ if (this.follow.has("txtAmeli.subs")) {
458
+ this.request("sub_by_txtid", txtAmeli.id.toString())
459
+ }
460
+
461
+ // TODO
462
+ }
463
+
464
+ addTypatt(typatt: TypAtt): void {
465
+ let objectById = this.objectByIdByTableName.typatt
466
+ if (objectById === undefined) {
467
+ objectById = this.objectByIdByTableName.typatt = {}
468
+ }
469
+ objectById[typatt.typattcod] = typatt
470
+ }
471
+
472
+ addTyplec(typlec: TypLec): void {
473
+ let objectById = this.objectByIdByTableName.typlec
474
+ if (objectById === undefined) {
475
+ objectById = this.objectByIdByTableName.typlec = {}
476
+ }
477
+ objectById[typlec.typleccod] = typlec
478
+ }
479
+
480
+ addTyploi(typloi: TypLoi): void {
481
+ let objectById = this.objectByIdByTableName.typloi
482
+ if (objectById === undefined) {
483
+ objectById = this.objectByIdByTableName.typloi = {}
484
+ }
485
+ objectById[typloi.typloicod] = typloi
486
+
487
+ // TODO
488
+ }
489
+
490
+ addTyptxt(typtxt: TypTxt): void {
491
+ let objectById = this.objectByIdByTableName.typtxt
492
+ if (objectById === undefined) {
493
+ objectById = this.objectByIdByTableName.typtxt = {}
494
+ }
495
+ objectById[typtxt.typtxtcod] = typtxt
496
+ }
497
+
498
+ addTypurl(typurl: TypUrl): void {
499
+ let objectById = this.objectByIdByTableName.typurl
500
+ if (objectById === undefined) {
501
+ objectById = this.objectByIdByTableName.typurl = {}
502
+ }
503
+ objectById[typurl.typurl] = typurl
504
+ }
505
+
506
+ async getAll(): Promise<void> {
507
+ while (Object.keys(this.requestedIdsByTableName).length > 0) {
508
+ for (const [tableName, requestedIdsSet] of Object.entries(
509
+ this.requestedIdsByTableName,
510
+ )) {
511
+ const requestedIds = [...requestedIdsSet]
512
+ delete this.requestedIdsByTableName[tableName]
513
+ switch (tableName) {
514
+ case "ass": {
515
+ ;(await getAsss(requestedIds)).map(this.addAss.bind(this))
516
+ break
517
+ }
518
+ case "aud_by_lecassidt": {
519
+ ;(await getAudsFromLecassidts(requestedIds)).map(
520
+ this.addAud.bind(this),
521
+ )
522
+ break
523
+ }
524
+ case "auteur": {
525
+ ;(await getAuteurs(requestedIds)).map(this.addAuteur.bind(this))
526
+ break
527
+ }
528
+ case "date_seance_by_lecassidt": {
529
+ ;(await getDatesSeancesFromLecassidts(requestedIds)).map(
530
+ this.addDateSeance.bind(this),
531
+ )
532
+ break
533
+ }
534
+ case "debat_by_lecassidt": {
535
+ ;(await getDebatsFromLecassidts(requestedIds)).map(
536
+ this.addDebat.bind(this),
537
+ )
538
+ break
539
+ }
540
+ case "debats": {
541
+ ;(await getDebats(requestedIds)).map(this.addDebat.bind(this))
542
+ break
543
+ }
544
+ case "deccoc": {
545
+ ;(await getDeccocs(requestedIds)).map(this.addDeccoc.bind(this))
546
+ break
547
+ }
548
+ case "denrap": {
549
+ ;(await getDenraps(requestedIds)).map(this.addDenrap.bind(this))
550
+ break
551
+ }
552
+ case "docatt_by_rapcod": {
553
+ ;(await getDocattsFromRapcods(requestedIds)).map(
554
+ this.addDocatt.bind(this),
555
+ )
556
+ break
557
+ }
558
+ case "ecr_by_rapcod": {
559
+ ;(await getEcrsFromRapcods(requestedIds)).map(
560
+ this.addEcr.bind(this),
561
+ )
562
+ break
563
+ }
564
+ case "ecr_by_texcod": {
565
+ ;(await getEcrsFromTexcods(requestedIds)).map(
566
+ this.addEcr.bind(this),
567
+ )
568
+ break
569
+ }
570
+ case "etaloi": {
571
+ ;(await getEtalois(requestedIds)).map(this.addEtaloi.bind(this))
572
+ break
573
+ }
574
+ case "lecasss_by_lecidt": {
575
+ ;(await getLecasssFromLecidts(requestedIds)).map(
576
+ this.addLecass.bind(this),
577
+ )
578
+ break
579
+ }
580
+ case "lecassrap_by_lecassidt": {
581
+ ;(await getLecassrapsFromLecassidts(requestedIds)).map(
582
+ this.addLecassrap.bind(this),
583
+ )
584
+ break
585
+ }
586
+ case "lectures_by_loicod": {
587
+ ;(await getLecturesFromLoicods(requestedIds)).map(
588
+ this.addLecture.bind(this),
589
+ )
590
+ break
591
+ }
592
+ case "loi": {
593
+ ;(await getLois(requestedIds)).map(this.addLoi.bind(this))
594
+ break
595
+ }
596
+ case "org": {
597
+ ;(await getOrgs(requestedIds)).map(this.addOrg.bind(this))
598
+ break
599
+ }
600
+ case "org_by_rapcod": {
601
+ ;(await getOrgsFromRapcods(requestedIds)).map(
602
+ this.addOrg.bind(this),
603
+ )
604
+ break
605
+ }
606
+ case "oritxt": {
607
+ ;(await getOritxts(requestedIds)).map(this.addOritxt.bind(this))
608
+ break
609
+ }
610
+ case "qua": {
611
+ ;(await getQuas(requestedIds)).map(this.addQua.bind(this))
612
+ break
613
+ }
614
+ case "rap": {
615
+ ;(await getRaps(requestedIds)).map(this.addRap.bind(this))
616
+ break
617
+ }
618
+ case "scr_by_code": {
619
+ ;(await getScrsFromCodes(requestedIds)).map(this.addScr.bind(this))
620
+ break
621
+ }
622
+ case "ses_by_ann": {
623
+ ;(await getSessFromAnns(requestedIds)).map(this.addSes.bind(this))
624
+ break
625
+ }
626
+ case "sub_by_txtid": {
627
+ ;(await getSubsFromTxtids(requestedIds)).map(this.addSub.bind(this))
628
+ break
629
+ }
630
+ case "texte_by_lecassidt": {
631
+ ;(await getTextesFromLecassidts(requestedIds)).map(
632
+ this.addTexte.bind(this),
633
+ )
634
+ break
635
+ }
636
+ case "txt_ameli_by_sesann_num": {
637
+ ;(await getTxtsAmeliBySesannNumJoins(requestedIds)).map(
638
+ this.addTxtAmeli.bind(this),
639
+ )
640
+ break
641
+ }
642
+ case "typatt": {
643
+ ;(await getTypatts(requestedIds)).map(this.addTypatt.bind(this))
644
+ break
645
+ }
646
+ case "typlec": {
647
+ ;(await getTyplecs(requestedIds)).map(this.addTyplec.bind(this))
648
+ break
649
+ }
650
+ case "typloi": {
651
+ ;(await getTyplois(requestedIds)).map(this.addTyploi.bind(this))
652
+ break
653
+ }
654
+ case "typtxt": {
655
+ ;(await getTyptxts(requestedIds)).map(this.addTyptxt.bind(this))
656
+ break
657
+ }
658
+ case "typurl": {
659
+ ;(await getTypurls(requestedIds)).map(this.addTypurl.bind(this))
660
+ break
661
+ }
662
+ default:
663
+ throw new Error(`Unhandled table: ${tableName}`)
664
+ }
665
+ let visitedIds = this.visitedIdsByTableName[tableName]
666
+ this.visitedIdsByTableName[tableName] =
667
+ visitedIds === undefined
668
+ ? new Set(requestedIds)
669
+ : new Set([...visitedIds, ...requestedIds])
670
+ }
671
+ }
672
+
673
+ // Add "1 to many" and other computed references.
674
+ if (this.follow.has("dateSeance.scrs")) {
675
+ const scrById = this.objectByIdByTableName.scr
676
+ const dateSeanceByCode = this.objectByIdByTableName.date_seance
677
+ if (scrById !== undefined && dateSeanceByCode !== undefined) {
678
+ for (const scr of Object.values(scrById) as Scr[]) {
679
+ const scrCode = scr.code
680
+ if (scrCode === null) {
681
+ continue
682
+ }
683
+ const dateSeance = dateSeanceByCode[scrCode] as DateSeance
684
+ if (dateSeance !== undefined) {
685
+ let scrids = dateSeance.scrids
686
+ if (scrids === undefined) {
687
+ scrids = dateSeance.scrids = []
688
+ }
689
+ scrids.push(`${scr.sesann} ${scr.scrnum}`)
690
+ }
691
+ }
692
+ }
693
+ }
694
+ if (this.follow.has("lecass.auds")) {
695
+ const audByAudcle = this.objectByIdByTableName.aud
696
+ const lecassByLecassidt = this.objectByIdByTableName.lecass
697
+ if (audByAudcle !== undefined && lecassByLecassidt !== undefined) {
698
+ for (const aud of Object.values(audByAudcle) as Aud[]) {
699
+ const lecass = lecassByLecassidt[aud.lecassidt] as LecAss
700
+ if (lecass !== undefined) {
701
+ let audcles = lecass.audcles
702
+ if (audcles === undefined) {
703
+ audcles = lecass.audcles = []
704
+ }
705
+ audcles.push(aud.audcle)
706
+ }
707
+ }
708
+ }
709
+ }
710
+ if (this.follow.has("lecass.datesSeances")) {
711
+ const dateSeanceByCode = this.objectByIdByTableName.date_seance
712
+ const lecassByLecassidt = this.objectByIdByTableName.lecass
713
+ if (dateSeanceByCode !== undefined && lecassByLecassidt !== undefined) {
714
+ for (const dateSeance of Object.values(
715
+ dateSeanceByCode,
716
+ ) as DateSeance[]) {
717
+ const lecassidt = dateSeance.lecidt
718
+ if (lecassidt === null) {
719
+ continue
720
+ }
721
+ const lecass = lecassByLecassidt[lecassidt] as LecAss
722
+ if (lecass !== undefined) {
723
+ let datesSeancesCodes = lecass.datesSeancesCodes
724
+ if (datesSeancesCodes === undefined) {
725
+ datesSeancesCodes = lecass.datesSeancesCodes = []
726
+ }
727
+ datesSeancesCodes.push(dateSeance.code)
728
+ }
729
+ }
730
+ }
731
+ }
732
+ if (this.follow.has("lecass.debats")) {
733
+ const debatById = this.objectByIdByTableName.debats
734
+ const lecassByLecassidt = this.objectByIdByTableName.lecass
735
+ if (debatById !== undefined && lecassByLecassidt !== undefined) {
736
+ const lecassdebs = await getLecAssDebsFromDatseas(Object.keys(debatById))
737
+ for (const lecassdeb of lecassdebs) {
738
+ const lecass = lecassByLecassidt[lecassdeb.lecassidt] as LecAss
739
+ if (lecass !== undefined) {
740
+ let debatdatseas = lecass.debatdatseas
741
+ if (debatdatseas === undefined) {
742
+ debatdatseas = lecass.debatdatseas = []
743
+ }
744
+ debatdatseas.push(lecassdeb.datsea)
745
+ }
746
+ }
747
+ }
748
+ }
749
+ if (this.follow.has("lecass.lecassraps")) {
750
+ const lecassrapById = this.objectByIdByTableName.lecassrap
751
+ const lecassByLecassidt = this.objectByIdByTableName.lecass
752
+ if (lecassrapById !== undefined && lecassByLecassidt !== undefined) {
753
+ for (const lecassrap of Object.values(lecassrapById) as LecAssRap[]) {
754
+ const lecass = lecassByLecassidt[lecassrap.lecassidt] as LecAss
755
+ if (lecass !== undefined) {
756
+ let lecassrapids = lecass.lecassrapids
757
+ if (lecassrapids === undefined) {
758
+ lecassrapids = lecass.lecassrapids = []
759
+ }
760
+ lecassrapids.push(`${lecassrap.lecassidt} ${lecassrap.rapcod}`)
761
+ }
762
+ }
763
+ }
764
+ }
765
+ if (this.follow.has("lecass.textes")) {
766
+ const texteByTexcod = this.objectByIdByTableName.texte
767
+ const lecassByLecassidt = this.objectByIdByTableName.lecass
768
+ if (texteByTexcod !== undefined && lecassByLecassidt !== undefined) {
769
+ for (const texte of Object.values(texteByTexcod) as Texte[]) {
770
+ const lecass = lecassByLecassidt[texte.lecassidt] as LecAss
771
+ if (lecass !== undefined) {
772
+ let texcods = lecass.texcods
773
+ if (texcods === undefined) {
774
+ texcods = lecass.texcods = []
775
+ }
776
+ texcods.push(texte.texcod)
777
+ }
778
+ }
779
+ }
780
+ }
781
+ if (this.follow.has("lecture.lecasss")) {
782
+ const lecassByLecassidt = this.objectByIdByTableName.lecass
783
+ const lectureByLecidt = this.objectByIdByTableName.lecture
784
+ if (lecassByLecassidt !== undefined && lectureByLecidt !== undefined) {
785
+ for (const lecass of Object.values(lecassByLecassidt) as LecAss[]) {
786
+ const lecture = lectureByLecidt[lecass.lecidt] as Lecture
787
+ if (lecture !== undefined) {
788
+ let lecassidts = lecture.lecassidts
789
+ if (lecassidts === undefined) {
790
+ lecassidts = lecture.lecassidts = []
791
+ }
792
+ lecassidts.push(lecass.lecassidt)
793
+ }
794
+ }
795
+ }
796
+ }
797
+ if (this.follow.has("loi.lectures")) {
798
+ const lectureByLecidt = this.objectByIdByTableName.lecture
799
+ const loiByLoicod = this.objectByIdByTableName.loi
800
+ if (lectureByLecidt !== undefined && loiByLoicod !== undefined) {
801
+ for (const lecture of Object.values(lectureByLecidt) as Lecture[]) {
802
+ const loi = loiByLoicod[lecture.loicod] as Loi
803
+ if (loi !== undefined) {
804
+ let lecidts = loi.lecidts
805
+ if (lecidts === undefined) {
806
+ lecidts = loi.lecidts = []
807
+ }
808
+ lecidts.push(lecture.lecidt)
809
+ }
810
+ }
811
+ }
812
+ }
813
+ if (this.follow.has("rap.docatts")) {
814
+ const docattByDocattcle = this.objectByIdByTableName.docatt
815
+ const rapById = this.objectByIdByTableName.rap
816
+ if (docattByDocattcle !== undefined && rapById !== undefined) {
817
+ for (const docatt of Object.values(docattByDocattcle) as DocAtt[]) {
818
+ const rapcod = docatt.rapcod
819
+ if (rapcod === null) {
820
+ continue
821
+ }
822
+ const rap = rapById[rapcod] as Rap
823
+ if (rap !== undefined) {
824
+ let docattcles = rap.docattcles
825
+ if (docattcles === undefined) {
826
+ docattcles = rap.docattcles = []
827
+ }
828
+ docattcles.push(docatt.docattcle)
829
+ }
830
+ }
831
+ }
832
+ }
833
+ if (this.follow.has("rap.ecrs")) {
834
+ const ecrByEcrnum = this.objectByIdByTableName.ecr
835
+ const rapById = this.objectByIdByTableName.rap
836
+ if (ecrByEcrnum !== undefined && rapById !== undefined) {
837
+ for (const ecr of Object.values(ecrByEcrnum) as Ecr[]) {
838
+ const rapcod = ecr.rapcod
839
+ if (rapcod === null) {
840
+ continue
841
+ }
842
+ const rap = rapById[rapcod] as Rap
843
+ if (rap !== undefined) {
844
+ let ecrnums = rap.ecrnums
845
+ if (ecrnums === undefined) {
846
+ ecrnums = rap.ecrnums = []
847
+ }
848
+ ecrnums.push(ecr.ecrnum)
849
+ }
850
+ }
851
+ }
852
+ }
853
+ if (this.follow.has("rap.orgs")) {
854
+ const orgByOrgcod = this.objectByIdByTableName.org
855
+ const rapById = this.objectByIdByTableName.rap
856
+ if (orgByOrgcod !== undefined && rapById !== undefined) {
857
+ const raporgs = await getRaporgsFromOrgcods(Object.keys(orgByOrgcod))
858
+ for (const raporg of raporgs) {
859
+ const rap = rapById[raporg.rapcod.toString()] as Rap
860
+ if (rap !== undefined) {
861
+ let orgcods = rap.orgcods
862
+ if (orgcods === undefined) {
863
+ orgcods = rap.orgcods = []
864
+ }
865
+ orgcods.push(raporg.orgcod)
866
+ }
867
+ }
868
+ }
869
+ }
870
+ if (this.follow.has("texte.ecrs")) {
871
+ const ecrByEcrnum = this.objectByIdByTableName.ecr
872
+ const texteById = this.objectByIdByTableName.texte
873
+ if (ecrByEcrnum !== undefined && texteById !== undefined) {
874
+ for (const ecr of Object.values(ecrByEcrnum) as Ecr[]) {
875
+ const texcod = ecr.texcod
876
+ if (texcod === null) {
877
+ continue
878
+ }
879
+ const texte = texteById[texcod] as Texte
880
+ if (texte !== undefined) {
881
+ let ecrnums = texte.ecrnums
882
+ if (ecrnums === undefined) {
883
+ ecrnums = texte.ecrnums = []
884
+ }
885
+ ecrnums.push(ecr.ecrnum)
886
+ }
887
+ }
888
+ }
889
+ }
890
+ if (this.follow.has("texte.txtAmeli")) {
891
+ const sesById = this.objectByIdByTableName.ses
892
+ const texteById = this.objectByIdByTableName.texte
893
+ const txtAmeliById = this.objectByIdByTableName.txt_ameli
894
+ if (
895
+ sesById !== undefined &&
896
+ texteById !== undefined &&
897
+ txtAmeliById !== undefined
898
+ ) {
899
+ for (const txtAmeli of Object.values(txtAmeliById) as TxtAmeli[]) {
900
+ const sesinsid = txtAmeli.sesinsid
901
+ const num = parseInt(txtAmeli.num)
902
+ if (sesinsid !== null) {
903
+ const sesins = sesById[sesinsid] as Ses
904
+ if (sesins !== undefined) {
905
+ for (const texte of Object.values(texteById) as Texte[]) {
906
+ if (texte.sesann === sesins.ann && texte.texnum === num) {
907
+ texte.txtAmeliId = txtAmeli.id
908
+ }
909
+ }
910
+ }
911
+ }
912
+ }
913
+ }
914
+ }
915
+ if (this.follow.has("txtAmeli.subs")) {
916
+ const subById = this.objectByIdByTableName.sub
917
+ const txtAmeliById = this.objectByIdByTableName.txt_ameli
918
+ if (subById !== undefined && txtAmeliById !== undefined) {
919
+ for (const sub of Object.values(subById) as Sub[]) {
920
+ const txtAmeli = txtAmeliById[sub.txtid] as TxtAmeli
921
+ if (txtAmeli !== undefined) {
922
+ let subids = txtAmeli.subids
923
+ if (subids === undefined) {
924
+ subids = txtAmeli.subids = []
925
+ }
926
+ subids.push(sub.id)
927
+ }
928
+ }
929
+ }
930
+ }
931
+ }
932
+
933
+ request(tableName: string, id: string): void {
934
+ const visitedIds = this.visitedIdsByTableName[tableName]
935
+ if (visitedIds === undefined || !visitedIds.has(id)) {
936
+ let requestedIds = this.requestedIdsByTableName[tableName]
937
+ if (requestedIds === undefined) {
938
+ requestedIds = this.requestedIdsByTableName[tableName] = new Set()
939
+ }
940
+ requestedIds.add(id)
941
+ }
942
+ }
943
+
944
+ toJson(): any {
945
+ return this.objectByIdByTableName
946
+ }
947
+ }