@tricoteuses/tisseuse 0.13.7 → 0.13.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.
Files changed (31) hide show
  1. package/README.md +39 -35
  2. package/dist/{textes-BIJjrNwg.js → html-DhGw-Yqr.js} +3875 -5243
  3. package/dist/index.js +280 -147
  4. package/dist/resolver-DZS-DNp6.js +1848 -0
  5. package/dist/server-f-legi.js +532 -0
  6. package/dist/server.js +530 -2161
  7. package/dist/src/lib/extractors/links.d.ts +6 -4
  8. package/dist/src/lib/f_legi/resolver.d.ts +5 -7
  9. package/dist/src/lib/index.d.ts +2 -0
  10. package/dist/src/lib/legi/canutes_resolver.d.ts +5 -6
  11. package/dist/src/lib/legi/resolver.d.ts +15 -12
  12. package/dist/src/lib/legi/resolver.test.d.ts +1 -0
  13. package/dist/src/lib/legi/text_titles_infos.d.ts +26 -0
  14. package/dist/src/lib/linkers/html.d.ts +15 -4
  15. package/dist/src/lib/linkers/markdown.d.ts +4 -2
  16. package/dist/src/lib/server/databases/index.d.ts +1 -1
  17. package/dist/src/lib/server/f_legi/index.d.ts +1 -0
  18. package/dist/src/lib/server/index.d.ts +2 -1
  19. package/dist/src/lib/server/judilibre_search.d.ts +31 -0
  20. package/dist/src/lib/server/judilibre_search.test.d.ts +1 -0
  21. package/dist/src/lib/server/legi/resolvers.d.ts +2 -7
  22. package/dist/src/lib/server/linkers/html.d.ts +4 -2
  23. package/dist/src/scripts/enrich_senat_documents.d.ts +1 -0
  24. package/dist/src/scripts/index_postgres_judilibre.d.ts +1 -0
  25. package/package.json +8 -1
  26. package/dist/src/lib/f_legi/extractors/links.d.ts +0 -134
  27. package/dist/src/lib/f_legi/linkers/html.d.ts +0 -51
  28. package/dist/src/lib/server/f_legi/databases/index.d.ts +0 -2
  29. package/dist/src/lib/server/f_legi/linkers/html.d.ts +0 -20
  30. package/dist/src/scripts/f_legi/add_links_to_html_document.d.ts +0 -0
  31. /package/dist/src/{scripts/extract_texts_titles_infos.d.ts → lib/f_legi/resolver.test.d.ts} +0 -0
@@ -1,4 +1,5 @@
1
1
  import { Sql } from 'postgres';
2
+ import { LegiResolver } from '../legi/resolver.js';
2
3
  import { TextAstArticle, TextAstDivision, TextAstPosition, TextAstReference, TextAstText } from '../text_parsers/ast.js';
3
4
  import { FragmentPosition, FragmentReverseTransformation } from '../text_parsers/fragments.js';
4
5
  import { TextParserContext } from '../text_parsers/parsers.js';
@@ -101,10 +102,11 @@ export interface TextLinksParserState {
101
102
  sectionTaId?: string;
102
103
  textId?: string;
103
104
  }
104
- export declare function extractTextLinks({ context, date, canutesDb, logIgnoredReferencesTypes, logPartialReferences, logReferences, state: inputState, transformation, }: {
105
+ export declare function extractTextLinks({ canutesDb, context, date, legiResolver: providedLegiResolver, logIgnoredReferencesTypes, logPartialReferences, logReferences, state: inputState, transformation, }: {
106
+ canutesDb?: Sql;
105
107
  context: TextParserContext;
106
108
  date: string;
107
- canutesDb: Sql;
109
+ legiResolver?: LegiResolver;
108
110
  logIgnoredReferencesTypes?: boolean;
109
111
  logPartialReferences?: boolean;
110
112
  logReferences?: boolean;
@@ -116,9 +118,9 @@ export declare function extractTextLinks({ context, date, canutesDb, logIgnoredR
116
118
  state?: TextLinksParserState;
117
119
  transformation?: Transformation;
118
120
  }): AsyncGenerator<DefinitionOrLink, void>;
119
- export declare function iterReferenceLinks({ articleDefinitionByNumByTextId: articleDefinitionByNumByTextIdInput, canutesDb, context, date, logIgnoredReferencesTypes, logPartialReferences, originalPositionsFromTransformedIterator, reference, state: inputState, }: {
121
+ export declare function iterReferenceLinks({ articleDefinitionByNumByTextId: articleDefinitionByNumByTextIdInput, legiResolver, context, date, logIgnoredReferencesTypes, logPartialReferences, originalPositionsFromTransformedIterator, reference, state: inputState, }: {
120
122
  articleDefinitionByNumByTextId?: Record<string, Record<string, ArticleDefinition>>;
121
- canutesDb: Sql;
123
+ legiResolver: LegiResolver;
122
124
  context: TextParserContext;
123
125
  date: string;
124
126
  logIgnoredReferencesTypes?: boolean;
@@ -1,8 +1,9 @@
1
1
  import { Sql } from 'postgres';
2
- import { LegiArticleInfo, LegiResolver, LegiSectionInfo, PreloadTextTitlesInfosOptions } from '../legi/resolver.js';
2
+ import { LegiResolver, LegiArticleInfo, LegiSectionInfo, PreloadActiveArticlesByTextIdsOptions, PreloadTextTitlesInfosOptions } from '../legi/resolver.js';
3
3
  export type FlegiArticleInfo = LegiArticleInfo;
4
4
  export type FlegiSectionInfo = LegiSectionInfo;
5
- export declare class FlegiResolver implements LegiResolver {
5
+ export declare function checkFlegiResolverDatabase(flegiDb: Sql): Promise<void>;
6
+ export declare class FlegiResolver extends LegiResolver {
6
7
  private readonly flegiDb;
7
8
  private readonly articleRowsByNumByTextAndDate;
8
9
  private readonly articleNumsLoadedByTextAndDate;
@@ -12,6 +13,7 @@ export declare class FlegiResolver implements LegiResolver {
12
13
  private readonly rootTextIdsByTextId;
13
14
  private readonly contextTextIdsByTextId;
14
15
  private readonly textIdBySegmentId;
16
+ private schemaValidationPromise;
15
17
  private textTitlesInfosLoaded;
16
18
  constructor(flegiDb: Sql);
17
19
  getActiveArticlesByTextAndNum({ date, num, textId, }: {
@@ -33,11 +35,7 @@ export declare class FlegiResolver implements LegiResolver {
33
35
  date: string;
34
36
  nums: Iterable<string | undefined>;
35
37
  }): Promise<void>;
36
- preloadActiveArticlesByTextIds({ date, nums, textIds, }: {
37
- date: string;
38
- nums?: Iterable<string | undefined>;
39
- textIds: Iterable<string | undefined>;
40
- }): Promise<void>;
38
+ preloadActiveArticlesByTextIds({ date, nums, textIds, }: PreloadActiveArticlesByTextIdsOptions): Promise<void>;
41
39
  private queryUniqueActiveArticlesByNumsUsingContextHeuristic;
42
40
  private queryGloballyUniqueArticleRowsByNums;
43
41
  private getActiveArticleRowsByNum;
@@ -10,6 +10,8 @@ export { extractCitationReferences, extractReferences, extractReferencesWithOrig
10
10
  export { buildArticlePortionTreeFromHtml, extractPortionSelectors, isArticlePortionStructuralStart, resolvePortionSelector, type ArticlePortionArticle, type ArticlePortionDivision, type ArticlePortionItem, type ArticlePortionAlinea, type ArticlePortionPhrase, type ArticlePortionMatch, type ArticlePortionNode, type PortionSelector, type PortionSelectorStep, } from './extractors/article_portions.js';
11
11
  export { addPositionsToTableOfContentsItems, getExtractedTableOfContentsFromTextBill, walkTableOfContents, type TableOfContents, type TableOfContentsArticle, type TableOfContentsArticlePositioned, type TableOfContentsDivision, type TableOfContentsDivisionPositioned, type TableOfContentsPositioned, } from './extractors/table_of_contents.js';
12
12
  export { jsonReplacer } from './json.js';
13
+ export { LegiResolver, type LegiArticleInfo, type LegiSectionInfo, type PreloadActiveArticlesByTextIdsOptions, type PreloadTextTitlesInfosOptions, type PreloadTextTitlesInfosProgress, } from './legi/resolver.js';
14
+ export { buildAndInstallTextTitlesInfos, buildTextTitlesInfos, type BuildTextTitlesInfosProgress, type TextTitlesInfoRow, type TextTitlesInfos, } from './legi/text_titles_infos.js';
13
15
  export { addLinksToHtml, addLinksOrReferencesToHtmlPage, type OutputByType, type OutputType, } from './linkers/html.js';
14
16
  /**
15
17
  * @deprecated Utiliser `addLinksToMarkdown` à la place.
@@ -1,16 +1,14 @@
1
1
  import { Sql } from 'postgres';
2
- import { LegiArticleInfo, LegiResolver, LegiSectionInfo, PreloadTextTitlesInfosOptions } from './resolver.js';
3
- export declare class CanutesResolver implements LegiResolver {
2
+ import { LegiResolver, LegiArticleInfo, LegiSectionInfo, PreloadTextTitlesInfosOptions } from './resolver.js';
3
+ export declare class CanutesResolver extends LegiResolver {
4
4
  private readonly canutesDb;
5
- private readonly options;
6
5
  private readonly articleRowsByNumByTextAndDate;
7
6
  private readonly directSectionChildrenByParentAndDate;
8
7
  private readonly globalArticleRowsByNumAndDate;
8
+ private readonly europeanTextUrlByTitleId;
9
9
  private readonly textIdBySegmentId;
10
10
  private textTitlesInfosLoaded;
11
- constructor(canutesDb: Sql, options?: {
12
- textTitlesInfosPath?: string;
13
- });
11
+ constructor(canutesDb: Sql);
14
12
  getActiveArticlesByTextAndNum({ date, num, textId, }: {
15
13
  date: string;
16
14
  num: string | undefined;
@@ -20,6 +18,7 @@ export declare class CanutesResolver implements LegiResolver {
20
18
  date: string;
21
19
  parentPath: string;
22
20
  }): Promise<LegiSectionInfo[]>;
21
+ getEuropeanTextUrl(titleId: string): Promise<string | undefined>;
23
22
  getTextIdFromSegmentId(segmentId: string): Promise<string | undefined>;
24
23
  getUniqueActiveArticlesByNum({ date, num, }: {
25
24
  date: string;
@@ -16,33 +16,36 @@ export type PreloadTextTitlesInfosProgress = {
16
16
  count?: number;
17
17
  detail?: string;
18
18
  phase: string;
19
- resolver: LegiResolverKind;
19
+ resolver: string;
20
20
  };
21
21
  export type PreloadTextTitlesInfosOptions = {
22
22
  onProgress?: (progress: PreloadTextTitlesInfosProgress) => void;
23
23
  };
24
- export interface LegiResolver {
25
- getActiveArticlesByTextAndNum(options: {
24
+ export type PreloadActiveArticlesByTextIdsOptions = {
25
+ date: string;
26
+ nums?: Iterable<string | undefined>;
27
+ textIds: Iterable<string | undefined>;
28
+ };
29
+ export declare abstract class LegiResolver {
30
+ abstract getActiveArticlesByTextAndNum(options: {
26
31
  date: string;
27
32
  num: string | undefined;
28
33
  textId: string;
29
34
  }): Promise<LegiArticleInfo[]>;
30
- getDirectSectionChildren(options: {
35
+ abstract getDirectSectionChildren(options: {
31
36
  date: string;
32
37
  parentPath: string;
33
38
  }): Promise<LegiSectionInfo[]>;
34
- getTextIdFromSegmentId(segmentId: string): Promise<string | undefined>;
35
- getUniqueActiveArticlesByNum(options: {
39
+ abstract getTextIdFromSegmentId(segmentId: string): Promise<string | undefined>;
40
+ getEuropeanTextUrl(titleId: string): Promise<string | undefined>;
41
+ abstract getUniqueActiveArticlesByNum(options: {
36
42
  date: string;
37
43
  num: string | undefined;
38
44
  }): Promise<LegiArticleInfo[]>;
39
- preloadTextTitlesInfos(options?: PreloadTextTitlesInfosOptions): Promise<void>;
40
- preloadUniqueActiveArticlesByNums(options: {
45
+ abstract preloadTextTitlesInfos(options?: PreloadTextTitlesInfosOptions): Promise<void>;
46
+ preloadActiveArticlesByTextIds(options: PreloadActiveArticlesByTextIdsOptions): Promise<void>;
47
+ abstract preloadUniqueActiveArticlesByNums(options: {
41
48
  date: string;
42
49
  nums: Iterable<string | undefined>;
43
50
  }): Promise<void>;
44
51
  }
45
- export declare const legiResolverKinds: readonly ["canutes", "f_legi"];
46
- export type LegiResolverKind = (typeof legiResolverKinds)[number];
47
- export declare const defaultLegiResolverKind: LegiResolverKind;
48
- export declare function parseLegiResolverKind(value: string | undefined): LegiResolverKind;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import { TextInfosByWordsTree } from '../text_parsers/ast.js';
2
+ export type TextTitlesInfoRow = {
3
+ cid: string;
4
+ dateTexte: string | null;
5
+ id: string;
6
+ nature: string;
7
+ num: string | null;
8
+ title: string;
9
+ };
10
+ export type TextTitlesInfos = {
11
+ textCidByOtherTitleWordsTree: TextInfosByWordsTree;
12
+ textCidByTitleRestWordsTree: TextInfosByWordsTree;
13
+ textInfosByCid: Record<string, [nature: string, title: string]>;
14
+ textsCidsByNatureAndDate: Record<string, Record<string, string | string[]>>;
15
+ textsCidsByNatureAndNum: Record<string, Record<string, string | string[]>>;
16
+ };
17
+ export type BuildTextTitlesInfosProgress = {
18
+ count?: number;
19
+ phase: string;
20
+ };
21
+ export declare function buildAndInstallTextTitlesInfos(rows: TextTitlesInfoRow[], options?: {
22
+ onProgress?: (progress: BuildTextTitlesInfosProgress) => void;
23
+ }): Promise<void>;
24
+ export declare function buildTextTitlesInfos(rows: TextTitlesInfoRow[], { onProgress, }?: {
25
+ onProgress?: (progress: BuildTextTitlesInfosProgress) => void;
26
+ }): Promise<TextTitlesInfos>;
@@ -1,10 +1,12 @@
1
1
  import { Sql } from 'postgres';
2
2
  import { DefinitionOrLink, TextLinksParserState } from '../extractors/links.js';
3
+ import { LegiResolver } from '../legi/resolver.js';
3
4
  import { LinkType } from '../links.js';
4
5
  import { TextParserContext } from '../text_parsers/parsers.js';
5
6
  import { Transformation } from '../text_parsers/transformers.js';
6
- export declare function addLinksToHtml({ canutesDb, date, html, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, onLink, previousContext, state, }: {
7
- canutesDb: Sql;
7
+ export declare function addLinksToHtml({ canutesDb, legiResolver: providedLegiResolver, date, html, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, onLink, previousContext, state, }: {
8
+ canutesDb?: Sql;
9
+ legiResolver?: LegiResolver;
8
10
  date: string;
9
11
  html: string;
10
12
  linkBaseUrl: string;
@@ -22,10 +24,18 @@ export declare function addLinksToHtml({ canutesDb, date, html, linkBaseUrl, lin
22
24
  export type OutputByType = Partial<Record<OutputType, {
23
25
  html: string;
24
26
  offset: number;
27
+ replacements: HtmlReplacement[];
25
28
  }>>;
26
29
  export type OutputType = "links" | "links_or_references" | "references";
27
- export declare function addLinksOrReferencesToHtmlPage({ canutesDb, date, defaultTextId, htmlTransformation, inputHtml, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, outputTypes: requestedOutputTypes, referredLegifranceTextsInfos, }: {
28
- canutesDb: Sql;
30
+ interface HtmlReplacement {
31
+ order: number;
32
+ replacement: string;
33
+ start: number;
34
+ stop: number;
35
+ }
36
+ export declare function addLinksOrReferencesToHtmlPage({ canutesDb, legiResolver: providedLegiResolver, date, defaultTextId, htmlTransformation, inputHtml, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, outputTypes: requestedOutputTypes, referredLegifranceTextsInfos, }: {
37
+ canutesDb?: Sql;
38
+ legiResolver?: LegiResolver;
29
39
  date: string;
30
40
  defaultTextId?: string;
31
41
  htmlTransformation: Transformation;
@@ -41,3 +51,4 @@ export declare function addLinksOrReferencesToHtmlPage({ canutesDb, date, defaul
41
51
  outputByType: OutputByType;
42
52
  referredLegifranceTextCountByCid: Record<string, number>;
43
53
  }>;
54
+ export {};
@@ -1,8 +1,10 @@
1
1
  import { Sql } from 'postgres';
2
+ import { LegiResolver } from '../legi/resolver.js';
2
3
  import { LinkType } from '../links.js';
3
4
  import { TextParserContext } from '../text_parsers/parsers.js';
4
- export declare function addLinksToMarkdown({ canutesDb, date, linkBaseUrl, linkType, previousContext, text, }: {
5
- canutesDb: Sql;
5
+ export declare function addLinksToMarkdown({ canutesDb, legiResolver: providedLegiResolver, date, linkBaseUrl, linkType, previousContext, text, }: {
6
+ canutesDb?: Sql;
7
+ legiResolver?: LegiResolver;
6
8
  date: string;
7
9
  linkBaseUrl: string;
8
10
  linkType: LinkType;
@@ -6,7 +6,7 @@ export declare const canutesDb: postgres.Sql<{}>;
6
6
  export declare const assembleeVersionNumber = 7;
7
7
  export declare const legiAnomaliesVersionNumber = 1;
8
8
  export declare const legiVersionNumber = 23;
9
- export declare const tisseuseVersionNumber = 11;
9
+ export declare const tisseuseVersionNumber = 12;
10
10
  export declare function checkAssembleeDb(): Promise<void>;
11
11
  export declare function checkLegiAnomaliesDb(): Promise<void>;
12
12
  export declare function checkLegiDb(): Promise<void>;
@@ -0,0 +1 @@
1
+ export { checkFlegiResolverDatabase, FlegiResolver, type FlegiArticleInfo, type FlegiSectionInfo, } from '../../f_legi/resolver.js';
@@ -6,7 +6,8 @@ export { isAkomaNtosoXml, resolveSenatAkomaNtosoSource, type SenatAkomaNtosoSour
6
6
  export { simplifyWordHtml, simplifyWordHtmlToDocument, type SimplifyHtmlOptions, } from './html_simplifier.js';
7
7
  export { addLinksOrReferencesToHtmlFile } from './linkers/html.js';
8
8
  export { linkAkomaNtosoBillRaw, linkAssembleeBillRaw, parseAkomaNtosoBillRaw, parseAssembleeBillRaw, renderAkomaNtosoBillRaw, type LinkedBillDocument, type ParsedBillArticle, type ParsedBillBlock, type ParsedBillBlockKind, type ParsedBillDirective, type ParsedBillDocument, type ParsedBillLink, type ParsedBillSourceFormat, type ParsedBillToc, type ParseBillRawOptions, } from './parsed_bills.js';
9
- export { defaultLegiResolverKind, legiResolverKinds, parseLegiResolverKind, type LegiArticleInfo, type LegiResolver, type LegiResolverKind, type LegiSectionInfo, } from '../legi/resolver.js';
9
+ export { type LegiArticleInfo, LegiResolver, type LegiSectionInfo, type PreloadActiveArticlesByTextIdsOptions, type PreloadTextTitlesInfosOptions, type PreloadTextTitlesInfosProgress, } from '../legi/resolver.js';
10
+ export { buildAndInstallTextTitlesInfos, buildTextTitlesInfos, type BuildTextTitlesInfosProgress, type TextTitlesInfoRow, type TextTitlesInfos, } from '../legi/text_titles_infos.js';
10
11
  export { addPositionsToTableOfContentsFile, simplifiedHtmlBillFileToTableOfContentsFile, } from './tables_of_contents.js';
11
12
  export { createLegiResolver } from './legi/resolvers.js';
12
13
  export { readTransformation, writeTransformation, } from './text_parsers/transformers.js';
@@ -0,0 +1,31 @@
1
+ export interface JudilibreSearchDocument {
2
+ chamber: string | null;
3
+ content: string;
4
+ decisionDate: string;
5
+ ecli: string | null;
6
+ formation: string | null;
7
+ id: string;
8
+ jurisdiction: string;
9
+ location: string | null;
10
+ number: string | null;
11
+ publication: string;
12
+ solution: string | null;
13
+ source: string;
14
+ sourceHash: string;
15
+ summary: string;
16
+ themes: string;
17
+ title: string;
18
+ type: string | null;
19
+ updateDate: string | null;
20
+ }
21
+ export declare function createJudilibreSearchDocument({ chamber, data, decisionDate, ecli, id, jurisdiction, number, source, updateDate, }: {
22
+ chamber: string | null;
23
+ data: string;
24
+ decisionDate: string;
25
+ ecli: string | null;
26
+ id: string;
27
+ jurisdiction: string;
28
+ number: string | null;
29
+ source: string;
30
+ updateDate: string | null;
31
+ }): JudilibreSearchDocument;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,5 @@
1
1
  import { Sql } from 'postgres';
2
- import { LegiResolver, LegiResolverKind } from '../../legi/resolver.js';
3
- export declare function getTextTitlesInfosPath(input?: string): string | undefined;
4
- export declare function getLegiResolverKind(input?: string): LegiResolverKind;
5
- export declare function createLegiResolver({ canutesDb, resolver, textTitlesInfosPath, }: {
2
+ import { LegiResolver } from '../../legi/resolver.js';
3
+ export declare function createLegiResolver({ canutesDb, }: {
6
4
  canutesDb: Sql;
7
- resolver?: string;
8
- textTitlesInfosPath?: string;
9
5
  }): LegiResolver;
10
- export declare function endLegiResolverDatabases(): Promise<void>;
@@ -1,7 +1,9 @@
1
+ import { LegiResolver } from '../../legi/resolver.js';
1
2
  import { LinkType } from '../../links.js';
2
3
  import { Sql } from 'postgres';
3
- export declare function addLinksOrReferencesToHtmlFile({ canutesDb, date, defaultTextId, htmlFilePath, htmlTransformationsInputDir, htmlTransformationsOutputDir, htmlWithLinksFilePath, htmlWithLinksOrReferencesFilePath, htmlWithLinksTransformationsOutputDir, htmlWithReferencesFilePath, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, referredLegifranceTextsInfosFilePath, }: {
4
- canutesDb: Sql;
4
+ export declare function addLinksOrReferencesToHtmlFile({ canutesDb, legiResolver: providedLegiResolver, date, defaultTextId, htmlFilePath, htmlTransformationsInputDir, htmlTransformationsOutputDir, htmlWithLinksFilePath, htmlWithLinksOrReferencesFilePath, htmlWithLinksTransformationsOutputDir, htmlWithReferencesFilePath, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, referredLegifranceTextsInfosFilePath, }: {
5
+ canutesDb?: Sql;
6
+ legiResolver?: LegiResolver;
5
7
  date: string;
6
8
  defaultTextId?: string;
7
9
  htmlFilePath: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
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.13.7",
4
+ "version": "0.13.9",
5
5
  "keywords": [
6
6
  "Assemblée nationale",
7
7
  "France",
@@ -45,6 +45,11 @@
45
45
  "import": "./dist/server.js",
46
46
  "types": "./dist/src/lib/server/index.d.ts"
47
47
  },
48
+ "./server/f-legi": {
49
+ "typedoc": "./src/lib/server/f_legi/index.ts",
50
+ "import": "./dist/server-f-legi.js",
51
+ "types": "./dist/src/lib/server/f_legi/index.d.ts"
52
+ },
48
53
  "./package.json": "./package.json"
49
54
  },
50
55
  "publishConfig": {
@@ -63,6 +68,7 @@
63
68
  "index:postgres:assemblee-amendments": "tsx src/scripts/index_postgres_assemblee_amendments.ts",
64
69
  "index:postgres:legifrance": "tsx src/scripts/index_postgres_legifrance_articles.ts",
65
70
  "index:postgres:legifrance-jurisprudence": "tsx src/scripts/index_postgres_legifrance_jurisprudence.ts",
71
+ "index:postgres:judilibre": "tsx src/scripts/index_postgres_judilibre.ts",
66
72
  "index:postgres:senat": "tsx src/scripts/index_postgres_senat_texts.ts",
67
73
  "index:postgres:senat-amendments": "tsx src/scripts/index_postgres_senat_amendments.ts",
68
74
  "profile:assemblee-document": "tsx src/scripts/profile_assemblee_document_parsing.ts",
@@ -92,6 +98,7 @@
92
98
  "fs-extra": "^11.3.5",
93
99
  "globals": "^17.6.0",
94
100
  "papaparse": "^5.5.3",
101
+ "pg": "^8.23.0",
95
102
  "postgres": "^3.4.9",
96
103
  "prettier": "^3.8.3",
97
104
  "sade": "^1.8.1",
@@ -1,134 +0,0 @@
1
- import { LegiResolver } from '../../legi/resolver.js';
2
- import { TextAstArticle, TextAstDivision, TextAstPosition, TextAstReference, TextAstText } from '../../text_parsers/ast.js';
3
- import { FragmentPosition, FragmentReverseTransformation } from '../../text_parsers/fragments.js';
4
- import { TextParserContext } from '../../text_parsers/parsers.js';
5
- import { Transformation } from '../../text_parsers/transformers.js';
6
- export type DefinitionOrLink = ArticleDefinition | ArticleLink | DivisionLink | TextLink;
7
- export interface ArticleDefinition {
8
- article: TextAstArticle;
9
- /**
10
- * Same value as article.originalTransformation, added for homogeneity
11
- *
12
- * Only defined when a transformation was used to convert input text
13
- * to simplified text.
14
- */
15
- originalTransformation?: FragmentReverseTransformation;
16
- /**
17
- * Same value as article.position, added for homogeneity
18
- */
19
- position: FragmentPosition;
20
- reference: TextAstReference;
21
- textId: string;
22
- type: "article_definition";
23
- }
24
- export interface ArticleExternalLink {
25
- article: TextAstArticle;
26
- articleId?: string;
27
- /**
28
- * Only defined when a transformation was used to convert input text
29
- * to simpeurolified text.
30
- */
31
- originalTransformation?: FragmentReverseTransformation;
32
- position: FragmentPosition;
33
- reference: TextAstReference;
34
- type: "external_article";
35
- }
36
- export interface ArticleInternalLink {
37
- article: TextAstArticle;
38
- definition: ArticleDefinition;
39
- /**
40
- * Only defined when a transformation was used to convert input text
41
- * to simplified text.
42
- */
43
- originalTransformation?: FragmentReverseTransformation;
44
- position: FragmentPosition;
45
- reference: TextAstReference;
46
- type: "internal_article";
47
- }
48
- export type ArticleLink = ArticleExternalLink | ArticleInternalLink;
49
- export interface DivisionExternalLink {
50
- division: TextAstDivision;
51
- /**
52
- * Only defined when a transformation was used to convert input text
53
- * to simplified text.
54
- */
55
- originalTransformation?: FragmentReverseTransformation;
56
- position: FragmentPosition;
57
- reference: TextAstReference;
58
- sectionTaId?: string;
59
- type: "external_division";
60
- }
61
- export type DivisionLink = DivisionExternalLink;
62
- export interface ExtractedLinkDb {
63
- field_name: string;
64
- index: number;
65
- link: ArticleExternalLink | DivisionExternalLink | TextEuropeanLink | TextExternalLink;
66
- source_id: string;
67
- target_id: string | null;
68
- }
69
- export interface TextEuropeanLink {
70
- /**
71
- * Only defined when a transformation was used to convert input text
72
- * to simplified text.
73
- */
74
- originalTransformation?: FragmentReverseTransformation;
75
- position: FragmentPosition;
76
- reference: TextAstReference;
77
- text: TextAstText & TextAstPosition;
78
- titleId: string;
79
- type: "european_text";
80
- url?: string;
81
- }
82
- export interface TextExternalLink {
83
- /**
84
- * Only defined when a transformation was used to convert input text
85
- * to simplified text.
86
- */
87
- originalTransformation?: FragmentReverseTransformation;
88
- position: FragmentPosition;
89
- reference: TextAstReference;
90
- text: TextAstText & TextAstPosition;
91
- type: "external_text";
92
- }
93
- export type TextLink = TextEuropeanLink | TextExternalLink;
94
- export interface TextLinksParserState {
95
- articleId?: string;
96
- codeId?: string;
97
- constitutionId?: string;
98
- decreeId?: string;
99
- defaultTextId?: string;
100
- lawId?: string;
101
- sectionTaId?: string;
102
- textId?: string;
103
- }
104
- export declare function extractTextLinks({ context, date, flegiResolver, logIgnoredReferencesTypes, logPartialReferences, logReferences, state: inputState, transformation, }: {
105
- context: TextParserContext;
106
- date: string;
107
- flegiResolver: LegiResolver;
108
- logIgnoredReferencesTypes?: boolean;
109
- logPartialReferences?: boolean;
110
- logReferences?: boolean;
111
- /**
112
- * When given, state is modified by this generator, so that the callers
113
- * always has the latest state version (and can reuse it for the next article,
114
- * for example).
115
- */
116
- state?: TextLinksParserState;
117
- transformation?: Transformation;
118
- }): AsyncGenerator<DefinitionOrLink, void>;
119
- export declare function iterReferenceLinks({ articleDefinitionByNumByTextId: articleDefinitionByNumByTextIdInput, flegiResolver, context, date, logIgnoredReferencesTypes, logPartialReferences, originalPositionsFromTransformedIterator, reference, state: inputState, }: {
120
- articleDefinitionByNumByTextId?: Record<string, Record<string, ArticleDefinition>>;
121
- flegiResolver: LegiResolver;
122
- context: TextParserContext;
123
- date: string;
124
- logIgnoredReferencesTypes?: boolean;
125
- logPartialReferences?: boolean;
126
- originalPositionsFromTransformedIterator?: Generator<FragmentReverseTransformation, void, FragmentPosition | undefined>;
127
- reference: TextAstReference;
128
- /**
129
- * When given, state is modified by this generator, so that the callers
130
- * always has the latest state version (and can reuse it for the next article,
131
- * for example).
132
- */
133
- state?: TextLinksParserState;
134
- }): AsyncGenerator<DefinitionOrLink>;
@@ -1,51 +0,0 @@
1
- import { DefinitionOrLink, TextLinksParserState } from '../extractors/links.js';
2
- import { LegiResolver } from '../../legi/resolver.js';
3
- import { LinkType } from '../../links.js';
4
- import { TextParserContext } from '../../text_parsers/parsers.js';
5
- import { Transformation } from '../../text_parsers/transformers.js';
6
- export declare function addLinksToHtml({ legiResolver, date, html, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, onLink, previousContext, state, }: {
7
- legiResolver: LegiResolver;
8
- date: string;
9
- html: string;
10
- linkBaseUrl: string;
11
- linkType: LinkType;
12
- logIgnoredReferencesTypes?: boolean;
13
- logPartialReferences?: boolean;
14
- logReferences?: boolean;
15
- onLink?: (link: DefinitionOrLink, index: number) => Promise<boolean | void>;
16
- previousContext?: TextParserContext;
17
- state?: TextLinksParserState;
18
- }): Promise<{
19
- context: TextParserContext;
20
- output: string | null;
21
- }>;
22
- export type OutputByType = Partial<Record<OutputType, {
23
- html: string;
24
- offset: number;
25
- replacements: HtmlReplacement[];
26
- }>>;
27
- export type OutputType = "links" | "links_or_references" | "references";
28
- interface HtmlReplacement {
29
- order: number;
30
- replacement: string;
31
- start: number;
32
- stop: number;
33
- }
34
- export declare function addLinksOrReferencesToHtmlPage({ legiResolver, date, defaultTextId, htmlTransformation, inputHtml, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, outputTypes: requestedOutputTypes, referredLegifranceTextsInfos, }: {
35
- legiResolver: LegiResolver;
36
- date: string;
37
- defaultTextId?: string;
38
- htmlTransformation: Transformation;
39
- inputHtml: string;
40
- linkBaseUrl: string;
41
- linkType: LinkType;
42
- logIgnoredReferencesTypes?: boolean;
43
- logPartialReferences?: boolean;
44
- logReferences?: boolean;
45
- outputTypes: OutputType[];
46
- referredLegifranceTextsInfos?: boolean;
47
- }): Promise<{
48
- outputByType: OutputByType;
49
- referredLegifranceTextCountByCid: Record<string, number>;
50
- }>;
51
- export {};
@@ -1,2 +0,0 @@
1
- import { default as postgres } from 'postgres';
2
- export declare const flegiDb: postgres.Sql<{}>;
@@ -1,20 +0,0 @@
1
- import { LinkType } from '../../../links.js';
2
- import { LegiResolver } from '../../../legi/resolver.js';
3
- export declare function addLinksOrReferencesToHtmlFile({ legiResolver, date, defaultTextId, htmlFilePath, htmlTransformationsInputDir, htmlTransformationsOutputDir, htmlWithLinksFilePath, htmlWithLinksOrReferencesFilePath, htmlWithLinksTransformationsOutputDir, htmlWithReferencesFilePath, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, referredLegifranceTextsInfosFilePath, }: {
4
- legiResolver: LegiResolver;
5
- date: string;
6
- defaultTextId?: string;
7
- htmlFilePath: string;
8
- htmlTransformationsInputDir?: string;
9
- htmlTransformationsOutputDir?: string;
10
- htmlWithLinksFilePath?: string;
11
- htmlWithLinksOrReferencesFilePath?: string;
12
- htmlWithLinksTransformationsOutputDir?: string;
13
- htmlWithReferencesFilePath?: string;
14
- linkBaseUrl: string;
15
- linkType: LinkType;
16
- logIgnoredReferencesTypes?: boolean;
17
- logPartialReferences?: boolean;
18
- logReferences?: boolean;
19
- referredLegifranceTextsInfosFilePath?: string;
20
- }): Promise<void>;