@tricoteuses/senat 2.8.1 → 2.8.4

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