@tricoteuses/tisseuse 0.22.1 → 0.22.3

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 (33) hide show
  1. package/README.md +11 -2
  2. package/dist/{html-BTaoaqX5.js → html-ClFZh0_V.js} +3991 -4556
  3. package/dist/index.js +53 -52
  4. package/dist/lib/extractors/links.d.ts +39 -5
  5. package/dist/lib/index.d.ts +3 -2
  6. package/dist/lib/legi/canutes_resolver.d.ts +24 -3
  7. package/dist/lib/legi/europe_attestation.d.ts +20 -0
  8. package/dist/lib/legi/europe_attestation.fixture.d.ts +8 -0
  9. package/dist/lib/legi/europe_attestation.test.d.ts +1 -0
  10. package/dist/lib/legi/europe_designation.d.ts +76 -0
  11. package/dist/lib/legi/europe_designation.test.d.ts +1 -0
  12. package/dist/lib/legi/europe_designation_cellar.test.d.ts +1 -0
  13. package/dist/lib/legi/europe_observation.d.ts +23 -0
  14. package/dist/lib/legi/europe_observation.test.d.ts +1 -0
  15. package/dist/lib/legi/resolver.d.ts +95 -0
  16. package/dist/lib/linkers/bascule_render_decisions.test.d.ts +1 -0
  17. package/dist/lib/linkers/html_european.test.d.ts +1 -0
  18. package/dist/lib/linkers/link_decision_metadata.d.ts +5 -0
  19. package/dist/lib/links.d.ts +29 -0
  20. package/dist/lib/text_parsers/ast.d.ts +6 -0
  21. package/dist/link-decision-metadata.js +8 -2
  22. package/dist/{resolver-GT7457lQ.js → resolver-C8c79uNU.js} +1341 -406
  23. package/dist/scripts/assemblee_install.integration.test.d.ts +1 -0
  24. package/dist/scripts/fixtures/assemblee-collation.d.ts +1 -0
  25. package/dist/scripts/fixtures/assemblee-empty-snapshot.d.ts +1 -0
  26. package/dist/scripts/installation-sandbox-locks.test.d.ts +1 -0
  27. package/dist/scripts/shared/assemblee_document_content.d.ts +46 -0
  28. package/dist/scripts/shared/assemblee_document_content.test.d.ts +1 -0
  29. package/dist/scripts/shared/assemblee_enqueue.d.ts +6 -0
  30. package/dist/scripts/sync_assemblee_queue.integration.test.d.ts +1 -0
  31. package/dist/server-f-legi.js +83 -83
  32. package/dist/server.js +445 -445
  33. package/package.json +18 -14
@@ -0,0 +1,23 @@
1
+ import { CheerioAPI } from 'cheerio';
2
+ /** Whether an article number can be verified at all, before reading anything. */
3
+ export declare function isVerifiableEuropeanArticle(article: string): boolean;
4
+ /** A loaded observation, so that many anchors are read in a single parse. */
5
+ export type EuropeanObservationDocument = CheerioAPI;
6
+ /**
7
+ * The canonical ELI fragment of an article inside one observation of a
8
+ * European act, or `undefined` when the observation does not prove it.
9
+ *
10
+ * A fragment is only admitted when the anchor exists **exactly once**, belongs
11
+ * to the enacting terms of the act, is the container Cellar gives an article,
12
+ * and is titled with the cited number. Everything else abstains: a fragment
13
+ * that cannot be verified in the observation is a misleading link.
14
+ *
15
+ * The check reads the stored observation, not the page Exploratrice renders
16
+ * from it. Both forms are measured by the tests, on the RGPD observation: the
17
+ * Cellar XHTML (`fixtures/rgpd-cellar.html`) and the captured public page
18
+ * (`fixtures/rgpd-exploratrice.html.gz`) carry the same anchors, under the
19
+ * same container and with the same heading.
20
+ */
21
+ export declare function observationArticleFragment($: EuropeanObservationDocument, article: string): string | undefined;
22
+ /** {@link observationArticleFragment} on the HTML of an observation. */
23
+ export declare function europeanObservationArticleFragment(html: string, article: string): string | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,67 @@
1
1
  import { PublicationComponentRow } from './publication_components.js';
2
+ /**
3
+ * Identity criteria of a cited European act, as written in the source. Only
4
+ * the criteria actually cited are provided: a missing date never becomes the
5
+ * resolution date of the document.
6
+ */
7
+ export interface EuropeanActReference {
8
+ /** Number as cited, for example « 2016/679 » or « 95/46/CE ». */
9
+ numero: string;
10
+ /** Cited nature: « règlement », « directive » or « décision ». */
11
+ nature?: string;
12
+ /** Date of the act, explicitly cited in the source (AAAA-MM-JJ). */
13
+ date?: string;
14
+ /**
15
+ * Treaty regime written in parentheses, as written (« UE », « CE »,
16
+ * « UE, Euratom »). A resolver must confront it with the act it designates,
17
+ * or abstain: it is part of the designation the source claims.
18
+ */
19
+ regime?: string;
20
+ /**
21
+ * Institution the source names right after the act (« du Parlement européen
22
+ * et du Conseil »). Confronted with the act's own designation when the
23
+ * resolver can read it, otherwise abstained on.
24
+ */
25
+ institution?: string;
26
+ }
27
+ /**
28
+ * Verdict of the identity confrontation between a citation's written criteria
29
+ * and the designation the resolved act carries (`europe.document.title`).
30
+ */
31
+ export type EuropeanActIdentity = {
32
+ /**
33
+ * CELEX of the single consultable act the citation designates, or `[]` when
34
+ * the citation is refused. Ambiguity is expressed the same way: nothing is
35
+ * established.
36
+ */
37
+ celexIds: string[];
38
+ /**
39
+ * Regimes written by the citation that the act's designation carries under
40
+ * another nomenclature of the same treaty (`CE`/`CEE`/`UE`): a link kept by
41
+ * equivalence, not by equality, and therefore announced rather than silent.
42
+ * Empty when every written criterion is matched literally, or none is
43
+ * written.
44
+ */
45
+ regimesDecales: string[];
46
+ };
47
+ /**
48
+ * A verified position inside one observation of a European act. The fragment is
49
+ * the canonical ELI subdivision (for example `art_5`) and carries no version:
50
+ * the observation identifies the version the fragment was checked in, and the
51
+ * empreinte attests the bytes it was checked in.
52
+ */
53
+ export interface EuropeanObservationFragment {
54
+ /** Observation of the act the fragment was verified in. */
55
+ observation: string;
56
+ /** Canonical ELI fragment, without `#`. */
57
+ fragment: string;
58
+ /**
59
+ * SHA-256 of the HTML read for that observation. The page rendering the
60
+ * observation recomputes it and drops the fragment on a difference: a
61
+ * fragment is never honoured on an observation that is not the attested one.
62
+ */
63
+ empreinte: string;
64
+ }
2
65
  export interface LegiPublicationComponentsProof {
3
66
  candidates: PublicationComponentRow[];
4
67
  bodyCid: string;
@@ -93,7 +156,39 @@ export declare abstract class LegiResolver {
93
156
  parentPath: string;
94
157
  }): Promise<LegiSectionInfo[]>;
95
158
  abstract getTextIdFromSegmentId(segmentId: string): Promise<string | undefined>;
159
+ /**
160
+ * Outcome of the identity confrontation for a cited European act: which act
161
+ * the citation designates, and which of its written criteria the act's own
162
+ * designation carries under another nomenclature of the same treaty.
163
+ *
164
+ * The verdict is `undefined` when the citation writes a criterion this
165
+ * grammar cannot read: the resolver abstains rather than ignore it.
166
+ */
167
+ getEuropeanActIdentity(reference: EuropeanActReference): Promise<EuropeanActIdentity | undefined>;
168
+ /**
169
+ * Compatibility projection over `getEuropeanActIdentity`: the consultable
170
+ * CELEX candidates of a cited act, `[]` when the citation is refused and
171
+ * `undefined` when the resolver abstains.
172
+ */
173
+ getEuropeanActCandidates(reference: EuropeanActReference): Promise<string[] | undefined>;
174
+ /**
175
+ * Compatibility wrapper over `getEuropeanActCandidates`: the consultation
176
+ * URL of the single consultable act cited by its number alone, or
177
+ * `undefined` when that number is unknown, ambiguous or has no document.
178
+ */
96
179
  getEuropeanTextUrl(titleId: string): Promise<string | undefined>;
180
+ /**
181
+ * Fragment of a cited article inside one observation of the act, or
182
+ * `undefined` when no observation proves it. A resolver must verify the
183
+ * anchor in the observation it names, or abstain: an unproven fragment is a
184
+ * misleading link.
185
+ */
186
+ getEuropeanArticleFragment(reference: {
187
+ /** CELEX of the established act. */
188
+ celexId: string;
189
+ /** Article number as cited, a plain integer. */
190
+ article: string;
191
+ }): Promise<EuropeanObservationFragment | undefined>;
97
192
  abstract getUniqueActiveArticlesByNum(options: {
98
193
  date: string;
99
194
  num: string | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -9,6 +9,11 @@ export declare const linkDecisionReferenceClasses: {
9
9
  readonly linked: "lien_texte_externe";
10
10
  readonly undecidable: "reference_texte_indecidable";
11
11
  };
12
+ /** European act: the act is linked, never one of its articles. */
13
+ readonly european_text: {
14
+ readonly linked: "lien_texte_europeen";
15
+ readonly undecidable: "reference_texte_europeen_indecidable";
16
+ };
12
17
  };
13
18
  export type LinkDecisionReferenceKind = keyof typeof linkDecisionReferenceClasses;
14
19
  export declare function isLinkDecisionWarning(code: string): boolean;
@@ -14,4 +14,33 @@ export declare function citedArticleNumFromTextCitation(textCitation: string): s
14
14
  * `undefined` when this link kind has no equivalent for the given type.
15
15
  */
16
16
  export declare function urlFromArticleVersionsId(linkType: LinkType, baseUrl: string, articleId: string): string | undefined;
17
+ /**
18
+ * Canonical ELI subdivision fragment: `art_5`, `cpt_III`, `anx_1`. The URL is
19
+ * composed from data, so the fragment is checked before being appended: a
20
+ * fragment that is not in this shape would designate nothing (or, once escaped
21
+ * by the client, something else).
22
+ */
23
+ export declare const europeanFragmentRegExp: RegExp;
24
+ /**
25
+ * Page of a European act in Exploratrice, keyed by its CELEX identifier. The
26
+ * route is the same for every link kind: no Git rendering of the act exists.
27
+ *
28
+ * A verified fragment carries three inseparable parts:
29
+ *
30
+ * - `?version=` pins the observation it was verified in;
31
+ * - `empreinte=` gives the SHA-256 of the observation's HTML, so the page can
32
+ * recompute it and drop the fragment on any difference;
33
+ * - `ancre=` names the subdivision, so the page can neutralise the browser jump
34
+ * when the fragment is not attested (the `#` itself never reaches the server).
35
+ *
36
+ * Without a verified empreinte the fragment is dropped, not escaped: the link
37
+ * degrades to the act, never to another position. A fragment on an observation
38
+ * whose bytes are not attested would be exactly the misleading link this chain
39
+ * exists to prevent.
40
+ */
41
+ export declare function europeanDocumentUrl(celex: string, fragment?: {
42
+ empreinte: string;
43
+ observation: string;
44
+ fragment: string;
45
+ }): string;
17
46
  export declare function urlFromLegalId(linkType: LinkType, baseUrl: string, id: string): string;
@@ -182,6 +182,12 @@ export type TextAstText = {
182
182
  nature: LawNature;
183
183
  legislation?: "international" | "UE";
184
184
  ofTheSaid?: boolean;
185
+ /**
186
+ * Treaty regime written in parentheses after the nature, as written
187
+ * (« UE », « CE », « UE, Euratom »). Kept unjudged: whether it proves which
188
+ * act is cited is decided where the act is resolved.
189
+ */
190
+ regimeEuropeen?: string;
185
191
  /**
186
192
  * For the texts found in the Légifrance datasets, the title
187
193
  * is the Légifrance one ⇒ it may differ from the title given in
@@ -7,6 +7,10 @@ var e = ["data-tisseuse-warning", "data-tisseuse-candidates"], t = {
7
7
  text: {
8
8
  linked: "lien_texte_externe",
9
9
  undecidable: "reference_texte_indecidable"
10
+ },
11
+ european_text: {
12
+ linked: "lien_texte_europeen",
13
+ undecidable: "reference_texte_europeen_indecidable"
10
14
  }
11
15
  }, n = new Set([
12
16
  "article_futur_a_date_reference",
@@ -17,10 +21,12 @@ var e = ["data-tisseuse-warning", "data-tisseuse-candidates"], t = {
17
21
  "reference_historique_explicite",
18
22
  "plusieurs_candidats_indepartageables",
19
23
  "cid_non_etabli",
20
- "donnees_insuffisantes"
24
+ "donnees_insuffisantes",
25
+ "nomenclature_decalee"
21
26
  ]), r = {
22
27
  article: /^(?:LEGIARTI|JORFARTI)\d{12}$/,
23
- text: /^(?:LEGITEXT|JORFTEXT)\d{12}$/
28
+ text: /^(?:LEGITEXT|JORFTEXT)\d{12}$/,
29
+ european_text: /^[23]\d{4}[RLD]\d{4}$/
24
30
  };
25
31
  function i(e) {
26
32
  return n.has(e);