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