@tricoteuses/senat 2.20.15 → 2.20.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export type { DossierLegislatifResult } from "./model/dosleg";
3
3
  export type { ScrutinResult } from "./model/scrutins";
4
4
  export type { QuestionResult } from "./model/questions";
5
5
  export type { CirconscriptionResult, OrganismeResult, SenateurResult } from "./model/sens";
6
- export type { AgendaEvent, GroupedReunion } from "./types/agenda";
6
+ export type { AgendaEvent, GroupedReunion, GroupedReunionOdjPoint } from "./types/agenda";
7
7
  export type { Ses, Sub, TxtAmeli } from "./types/ameli";
8
8
  export type { CompteRendu } from "./types/compte_rendu";
9
9
  export type { Debat, LecAssDeb } from "./types/debats";
@@ -3,40 +3,6 @@ const xmlParser = new XMLParser({
3
3
  ignoreAttributes: false,
4
4
  attributeNamePrefix: "@_",
5
5
  });
6
- function getFirstInterventionChapterId(dataNvs) {
7
- const xml = xmlParser.parse(dataNvs);
8
- const rootChapters = xml?.data?.chapters?.chapter;
9
- if (!rootChapters)
10
- return null;
11
- const chaptersArray = Array.isArray(rootChapters) ? rootChapters : [rootChapters];
12
- let foundId = null;
13
- function dfsChapter(chapter) {
14
- if (foundId)
15
- return;
16
- const metas = chapter.metadata ? (Array.isArray(chapter.metadata) ? chapter.metadata : [chapter.metadata]) : [];
17
- const isIntervention = metas.some((m) => m?.["@_name"] === "type" && (m?.["@_value"] === "IN" || m?.["@_label"] === "Intervention"));
18
- const hasSpeaker = !!chapter.speaker;
19
- if (isIntervention && hasSpeaker && chapter["@_id"]) {
20
- foundId = String(chapter["@_id"]);
21
- return;
22
- }
23
- const children = chapter.chapter;
24
- if (!children)
25
- return;
26
- const childArray = Array.isArray(children) ? children : [children];
27
- for (const child of childArray) {
28
- dfsChapter(child);
29
- if (foundId)
30
- return;
31
- }
32
- }
33
- for (const ch of chaptersArray) {
34
- dfsChapter(ch);
35
- if (foundId)
36
- break;
37
- }
38
- return foundId;
39
- }
40
6
  function getTimecodeForChapterId(finalPlayerNvs, chapterId) {
41
7
  const xml = xmlParser.parse(finalPlayerNvs);
42
8
  const synchros = xml?.player?.synchro;
@@ -55,8 +21,19 @@ function getTimecodeForChapterId(finalPlayerNvs, chapterId) {
55
21
  return Math.floor(ms / 1000);
56
22
  }
57
23
  export function getFirstInterventionStartTimecode(dataNvs, finalPlayerNvs) {
58
- const firstChapterId = getFirstInterventionChapterId(dataNvs);
24
+ const firstChapterId = getFirstChapterId(dataNvs);
59
25
  if (!firstChapterId)
60
26
  return null;
61
27
  return getTimecodeForChapterId(finalPlayerNvs, firstChapterId);
62
28
  }
29
+ function getFirstChapterId(dataNvs) {
30
+ const xml = xmlParser.parse(dataNvs);
31
+ const rootChapters = xml?.data?.chapters?.chapter;
32
+ if (!rootChapters)
33
+ return null;
34
+ const chaptersArray = Array.isArray(rootChapters) ? rootChapters : [rootChapters];
35
+ const firstChapter = chaptersArray[0];
36
+ if (!firstChapter || !firstChapter["@_id"])
37
+ return null;
38
+ return String(firstChapter["@_id"]);
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/senat",
3
- "version": "2.20.15",
3
+ "version": "2.20.17",
4
4
  "description": "Handle French Sénat's open data",
5
5
  "keywords": [
6
6
  "France",