@tricoteuses/tisseuse 0.14.8 → 0.14.9

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.
@@ -25,6 +25,13 @@ export interface ArticleDefinition {
25
25
  export interface ArticleExternalLink {
26
26
  article: TextAstArticle;
27
27
  articleId?: string;
28
+ /**
29
+ * Defined only when no version of the cited article number is active at the
30
+ * reference date and the number has a single version chain in the cited
31
+ * text: latest version of that chain, allowing linkers to propose a history
32
+ * page (versions and their periods) instead of an arbitrary resolution.
33
+ */
34
+ historyArticleId?: string;
28
35
  /**
29
36
  * Only defined when a transformation was used to convert input text
30
37
  * to simpeurolified text.
@@ -19,7 +19,7 @@ export { addLinksToHtml, addLinksOrReferencesToHtmlPage, type OutputByType, type
19
19
  */
20
20
  export declare const addLinksToText: typeof addLinksToMarkdown;
21
21
  export { addLinksToMarkdown };
22
- export { linkTypes, urlFromLegalId, type LinkType } from './links.js';
22
+ export { linkTypes, urlFromArticleVersionsId, urlFromLegalId, type LinkType, } from './links.js';
23
23
  export { getOrLoadDocument, getOrLoadDocumentsByDossierParlementaireUid, getOrLoadDossierParlementaire, } from './loaders/assemblee.js';
24
24
  export { extendLoadedArticle, getOrLoadArticle, getOrLoadJo, getOrLoadSectionTa, getOrLoadSectionsTa, getOrLoadTextelr, getOrLoadTextekali, getOrLoadTexteslr, getOrLoadTextesVersions, getOrLoadTexteVersion, loadArticles, type ArticleExtension, type JorfArticleExtended, type KaliArticleExtended, type LegiArticleExtended, } from './loaders/legifrance.js';
25
25
  export { action } from './text_parsers/actions.js';
@@ -1,7 +1,27 @@
1
1
  import { Sql } from 'postgres';
2
- import { LegiResolver, LegiArticleInfo, LegiSectionInfo, PreloadTextTitlesInfosOptions } from './resolver.js';
2
+ import { LegiResolver, LegiArticleHistoryInfo, LegiArticleInfo, LegiSectionInfo, PreloadTextTitlesInfosOptions } from './resolver.js';
3
+ /**
4
+ * Minimal structural view of a Légifrance article row needed to compute an
5
+ * article history entry point; shared with the audit preload.
6
+ */
7
+ export interface ArticleHistorySourceRow {
8
+ dateDebut: string | null;
9
+ id: string;
10
+ versions: {
11
+ VERSION?: unknown;
12
+ } | null;
13
+ }
14
+ /**
15
+ * Group article rows by version chain (the set of ids listed in their
16
+ * VERSIONS section, always including the row's own id) and return the latest
17
+ * version of the chain, but only when exactly one chain exists for the
18
+ * requested number. Several chains mean the number was reused by distinct
19
+ * articles: the history would then be ambiguous.
20
+ */
21
+ export declare function articleHistoryInfoFromRows(rows: ArticleHistorySourceRow[]): LegiArticleHistoryInfo | undefined;
3
22
  export declare class CanutesResolver extends LegiResolver {
4
23
  private readonly canutesDb;
24
+ private readonly articleHistoryInfoByTextAndNum;
5
25
  private readonly articleRowsByNumByTextAndDate;
6
26
  private readonly directSectionChildrenByParentAndDate;
7
27
  private readonly globalArticleRowsByNumAndDate;
@@ -14,6 +34,10 @@ export declare class CanutesResolver extends LegiResolver {
14
34
  num: string | undefined;
15
35
  textId: string;
16
36
  }): Promise<LegiArticleInfo[]>;
37
+ getArticleHistoryInfo({ num, textId, }: {
38
+ num: string | undefined;
39
+ textId: string;
40
+ }): Promise<LegiArticleHistoryInfo | undefined>;
17
41
  getDirectSectionChildren({ date, parentPath, }: {
18
42
  date: string;
19
43
  parentPath: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -5,6 +5,13 @@ export interface LegiArticleInfo {
5
5
  num: string | null;
6
6
  textId: string | null;
7
7
  }
8
+ /**
9
+ * Entry point to the history of an article: the latest version of the unique
10
+ * version chain known for a cited article number within a cited text.
11
+ */
12
+ export interface LegiArticleHistoryInfo {
13
+ articleId: string;
14
+ }
8
15
  export interface LegiSectionInfo {
9
16
  dateDebut: string | null;
10
17
  dateFin: string | null;
@@ -32,6 +39,15 @@ export declare abstract class LegiResolver {
32
39
  num: string | undefined;
33
40
  textId: string;
34
41
  }): Promise<LegiArticleInfo[]>;
42
+ /**
43
+ * Latest version of the unique version chain of an article number within a
44
+ * text, or `undefined` when the number is unknown, ambiguous (several
45
+ * distinct version chains) or when the resolver cannot answer.
46
+ */
47
+ getArticleHistoryInfo(options: {
48
+ num: string | undefined;
49
+ textId: string;
50
+ }): Promise<LegiArticleHistoryInfo | undefined>;
35
51
  abstract getDirectSectionChildren(options: {
36
52
  date: string;
37
53
  parentPath: string;
@@ -1,3 +1,10 @@
1
1
  export type LinkType = (typeof linkTypes)[number];
2
2
  export declare const linkTypes: readonly ["Exploratrice", "Forgejo"];
3
+ /**
4
+ * URL of the page presenting every known version (with their validity
5
+ * periods) of a legal article. Used instead of a direct resolution when no
6
+ * version of the article is active at the reference date. Returns
7
+ * `undefined` when this link kind has no equivalent for the given type.
8
+ */
9
+ export declare function urlFromArticleVersionsId(linkType: LinkType, baseUrl: string, articleId: string): string | undefined;
3
10
  export declare function urlFromLegalId(linkType: LinkType, baseUrl: string, id: string): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tricoteuses/tisseuse",
3
3
  "description": "Find links in/to French legislative documents",
4
- "version": "0.14.8",
4
+ "version": "0.14.9",
5
5
  "keywords": [
6
6
  "Assemblée nationale",
7
7
  "France",