@tricoteuses/tisseuse 0.12.10 → 0.13.0
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/README.md +46 -0
- package/dist/index.js +143 -1397
- package/dist/server.js +2739 -158
- package/dist/src/lib/extractors/action_directives.d.ts +84 -22
- package/dist/src/lib/extractors/article_portions.d.ts +15 -1
- package/dist/src/lib/extractors/references.d.ts +3 -1
- package/dist/src/lib/extractors/table_of_contents.d.ts +2 -0
- package/dist/src/lib/f_legi/extractors/links.d.ts +134 -0
- package/dist/src/lib/f_legi/linkers/html.d.ts +51 -0
- package/dist/src/lib/f_legi/resolver.d.ts +54 -0
- package/dist/src/lib/index.d.ts +4 -3
- package/dist/src/lib/legi/canutes_resolver.d.ts +33 -0
- package/dist/src/lib/legi/resolver.d.ts +48 -0
- package/dist/src/lib/server/databases/index.d.ts +1 -1
- package/dist/src/lib/server/f_legi/databases/index.d.ts +2 -0
- package/dist/src/lib/server/f_legi/linkers/html.d.ts +20 -0
- package/dist/src/lib/server/index.d.ts +3 -0
- package/dist/src/lib/server/legi/resolvers.d.ts +10 -0
- package/dist/src/lib/server/parsed_bills.d.ts +105 -0
- package/dist/src/lib/server/parsed_bills.test.d.ts +1 -0
- package/dist/src/lib/test/text_titles_infos.d.ts +1 -0
- package/dist/src/lib/text_parsers/action_directives.d.ts +3 -0
- package/dist/src/lib/text_parsers/action_directives.test.d.ts +1 -0
- package/dist/src/lib/text_parsers/ast.d.ts +53 -1
- package/dist/src/lib/text_parsers/parsers.d.ts +2 -0
- package/dist/src/lib/text_parsers/texts.d.ts +1 -0
- package/dist/src/lib/timings.d.ts +19 -0
- package/dist/src/scripts/f_legi/add_links_to_html_document.d.ts +0 -0
- package/dist/src/scripts/parse_akoma_ntoso_bill_raw.d.ts +1 -0
- package/dist/src/scripts/parse_assemblee_bill_raw.d.ts +1 -0
- package/dist/{html-DAKCS7I8.js → textes-8dVwaLo9.js} +5161 -3078
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PortionSelector } from './article_portions.js';
|
|
2
|
-
import { ActionTarget, TextAstReference } from '../text_parsers/ast.js';
|
|
2
|
+
import { ActionTarget, TextAstActionDirective, TextAstReference } from '../text_parsers/ast.js';
|
|
3
3
|
import { FragmentPosition } from '../text_parsers/fragments.js';
|
|
4
4
|
export type ActionReplacement = {
|
|
5
5
|
type: "text";
|
|
@@ -17,29 +17,76 @@ export type ActionTableTarget = {
|
|
|
17
17
|
rowIndex?: number;
|
|
18
18
|
columnIndex?: number;
|
|
19
19
|
};
|
|
20
|
-
export type
|
|
20
|
+
export type ActionInsertLayout = "block" | "inline";
|
|
21
|
+
export type ActionReplacementLayout = ActionInsertLayout;
|
|
22
|
+
export type ActionTargetScope = {
|
|
23
|
+
type: "tail_after_target";
|
|
24
|
+
unit?: "phrase" | "alinéa" | "article";
|
|
25
|
+
};
|
|
26
|
+
type ActionOperationTarget = {
|
|
27
|
+
targetType?: ActionTarget;
|
|
28
|
+
reference?: TextAstReference;
|
|
29
|
+
portionSelectors?: PortionSelector[];
|
|
30
|
+
};
|
|
31
|
+
type ActionDirectiveCommon = {
|
|
32
|
+
applicabilityDate?: string;
|
|
33
|
+
sourcePosition: FragmentPosition;
|
|
34
|
+
sourceText: string;
|
|
35
|
+
};
|
|
36
|
+
export type ActionOperation = (ActionOperationTarget & {
|
|
37
|
+
kind: "insert_after" | "insert_before";
|
|
38
|
+
targetText: string;
|
|
39
|
+
insertText: string;
|
|
40
|
+
insertLayout?: ActionInsertLayout;
|
|
41
|
+
citation?: ActionCitation;
|
|
42
|
+
tableTarget?: ActionTableTarget;
|
|
43
|
+
}) | (ActionOperationTarget & {
|
|
44
|
+
kind: "replace_portion";
|
|
45
|
+
replacementText: string;
|
|
46
|
+
replacement: ActionReplacement;
|
|
47
|
+
replacementLayout?: ActionReplacementLayout;
|
|
48
|
+
citation?: ActionCitation;
|
|
49
|
+
tableTarget?: ActionTableTarget;
|
|
50
|
+
}) | (ActionOperationTarget & {
|
|
51
|
+
kind: "replace";
|
|
52
|
+
targetText: string;
|
|
53
|
+
replacementText: string;
|
|
54
|
+
replacement: ActionReplacement;
|
|
55
|
+
targetScope?: ActionTargetScope;
|
|
56
|
+
tableTarget?: ActionTableTarget;
|
|
57
|
+
}) | (ActionOperationTarget & {
|
|
58
|
+
kind: "delete";
|
|
59
|
+
targetText: string;
|
|
60
|
+
targetScope?: ActionTargetScope;
|
|
61
|
+
occurrenceIndex?: number;
|
|
62
|
+
tableTarget?: ActionTableTarget;
|
|
63
|
+
}) | (ActionOperationTarget & {
|
|
64
|
+
kind: "delete_portion";
|
|
65
|
+
tableTarget?: ActionTableTarget;
|
|
66
|
+
}) | (ActionOperationTarget & {
|
|
67
|
+
kind: "delete_article";
|
|
68
|
+
});
|
|
69
|
+
export type ResolvedActionDirective = (ActionDirectiveCommon & {
|
|
21
70
|
kind: "insert_after" | "insert_before";
|
|
22
71
|
targetType: ActionTarget;
|
|
23
72
|
reference: TextAstReference;
|
|
24
73
|
portionSelectors: PortionSelector[];
|
|
25
74
|
targetText: string;
|
|
26
75
|
insertText: string;
|
|
76
|
+
insertLayout?: ActionInsertLayout;
|
|
27
77
|
citation?: ActionCitation;
|
|
28
78
|
tableTarget?: ActionTableTarget;
|
|
29
|
-
|
|
30
|
-
sourceText: string;
|
|
31
|
-
} | {
|
|
79
|
+
}) | (ActionDirectiveCommon & {
|
|
32
80
|
kind: "replace_portion";
|
|
33
81
|
targetType: ActionTarget;
|
|
34
82
|
reference: TextAstReference;
|
|
35
83
|
portionSelectors: PortionSelector[];
|
|
36
84
|
replacementText: string;
|
|
37
85
|
replacement: ActionReplacement;
|
|
86
|
+
replacementLayout?: ActionReplacementLayout;
|
|
38
87
|
citation?: ActionCitation;
|
|
39
88
|
tableTarget?: ActionTableTarget;
|
|
40
|
-
|
|
41
|
-
sourceText: string;
|
|
42
|
-
} | {
|
|
89
|
+
}) | (ActionDirectiveCommon & {
|
|
43
90
|
kind: "replace";
|
|
44
91
|
targetType: ActionTarget;
|
|
45
92
|
reference: TextAstReference;
|
|
@@ -47,34 +94,49 @@ export type ActionDirective = {
|
|
|
47
94
|
targetText: string;
|
|
48
95
|
replacementText: string;
|
|
49
96
|
replacement: ActionReplacement;
|
|
97
|
+
targetScope?: ActionTargetScope;
|
|
50
98
|
tableTarget?: ActionTableTarget;
|
|
51
|
-
|
|
52
|
-
sourceText: string;
|
|
53
|
-
} | {
|
|
99
|
+
}) | (ActionDirectiveCommon & {
|
|
54
100
|
kind: "delete";
|
|
55
101
|
targetType: ActionTarget;
|
|
56
102
|
reference: TextAstReference;
|
|
57
103
|
portionSelectors: PortionSelector[];
|
|
58
104
|
targetText: string;
|
|
105
|
+
targetScope?: ActionTargetScope;
|
|
59
106
|
occurrenceIndex?: number;
|
|
60
107
|
tableTarget?: ActionTableTarget;
|
|
61
|
-
|
|
62
|
-
sourceText: string;
|
|
63
|
-
} | {
|
|
108
|
+
}) | (ActionDirectiveCommon & {
|
|
64
109
|
kind: "delete_portion";
|
|
65
110
|
targetType: ActionTarget;
|
|
66
111
|
reference: TextAstReference;
|
|
67
112
|
portionSelectors: PortionSelector[];
|
|
68
113
|
tableTarget?: ActionTableTarget;
|
|
69
|
-
|
|
70
|
-
sourceText: string;
|
|
71
|
-
} | {
|
|
114
|
+
}) | (ActionDirectiveCommon & {
|
|
72
115
|
kind: "delete_article";
|
|
73
116
|
targetType: "article";
|
|
74
117
|
reference: TextAstReference;
|
|
75
118
|
portionSelectors: PortionSelector[];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
119
|
+
}) | (ActionDirectiveCommon & {
|
|
120
|
+
kind: "compound";
|
|
121
|
+
targetType: ActionTarget;
|
|
122
|
+
reference: TextAstReference;
|
|
123
|
+
portionSelectors: PortionSelector[];
|
|
124
|
+
operations: ActionOperation[];
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* @deprecated Use ResolvedActionDirective for resolved, projection-ready
|
|
128
|
+
* directives. TextAstActionDirective is the generic parser AST.
|
|
129
|
+
*/
|
|
130
|
+
export type ActionDirective = ResolvedActionDirective;
|
|
131
|
+
export declare function extractActionDirectiveAstsFromText(text: string): TextAstActionDirective[];
|
|
132
|
+
export declare function resolveActionDirectivesFromText(text: string): ActionDirective[];
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated Use resolveActionDirectivesFromText.
|
|
135
|
+
*/
|
|
136
|
+
export declare const extractActionDirectivesFromText: typeof resolveActionDirectivesFromText;
|
|
137
|
+
export declare function resolveActionDirectivesFromHtml(html: string): ActionDirective[];
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated Use resolveActionDirectivesFromHtml.
|
|
140
|
+
*/
|
|
141
|
+
export declare const extractActionDirectivesFromHtml: typeof resolveActionDirectivesFromHtml;
|
|
142
|
+
export {};
|
|
@@ -15,7 +15,7 @@ export type PortionSelector = {
|
|
|
15
15
|
last: PortionSelectorStep[];
|
|
16
16
|
count?: number;
|
|
17
17
|
};
|
|
18
|
-
export type ArticlePortionNode = ArticlePortionArticle | ArticlePortionDivision | ArticlePortionItem | ArticlePortionAlinea;
|
|
18
|
+
export type ArticlePortionNode = ArticlePortionArticle | ArticlePortionDivision | ArticlePortionItem | ArticlePortionAlinea | ArticlePortionPhrase;
|
|
19
19
|
export interface ArticlePortionArticle {
|
|
20
20
|
type: "article";
|
|
21
21
|
children: ArticlePortionNode[];
|
|
@@ -40,6 +40,19 @@ export interface ArticlePortionAlinea {
|
|
|
40
40
|
text: string;
|
|
41
41
|
html: string;
|
|
42
42
|
paragraphIndex: number;
|
|
43
|
+
htmlStart?: number;
|
|
44
|
+
htmlStop?: number;
|
|
45
|
+
lineIndex?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface ArticlePortionPhrase {
|
|
48
|
+
type: "phrase";
|
|
49
|
+
index: number;
|
|
50
|
+
text: string;
|
|
51
|
+
html: string;
|
|
52
|
+
paragraphIndex: number;
|
|
53
|
+
htmlStart?: number;
|
|
54
|
+
htmlStop?: number;
|
|
55
|
+
alinea: ArticlePortionAlinea;
|
|
43
56
|
}
|
|
44
57
|
export type ArticlePortionMatch = {
|
|
45
58
|
selector: PortionSelector;
|
|
@@ -55,6 +68,7 @@ export type ArticlePortionMatch = {
|
|
|
55
68
|
export declare const ITEM_PREFIX_RE: RegExp;
|
|
56
69
|
export declare const BARE_ITEM_PREFIX_RE: RegExp;
|
|
57
70
|
export declare function isRomanNumeral(token: string): boolean;
|
|
71
|
+
export declare function isArticlePortionStructuralStart(text: string): boolean;
|
|
58
72
|
export declare function buildArticlePortionTreeFromHtml(html: string): ArticlePortionArticle;
|
|
59
73
|
export declare function extractPortionSelectors(reference: TextAstReference): PortionSelector[];
|
|
60
74
|
export declare function resolvePortionSelector(article: ArticlePortionArticle, selector: PortionSelector): ArticlePortionMatch | null;
|
|
@@ -2,7 +2,9 @@ import { TextAstCitation, TextAstReference } from '../text_parsers/ast.js';
|
|
|
2
2
|
import { TextParserContext } from '../text_parsers/parsers.js';
|
|
3
3
|
import { Transformation } from '../text_parsers/transformers.js';
|
|
4
4
|
export declare function extractCitationReferences(context: TextParserContext, citation: TextAstCitation): Generator<TextAstReference, void>;
|
|
5
|
-
export declare function extractReferences(context: TextParserContext
|
|
5
|
+
export declare function extractReferences(context: TextParserContext, options?: {
|
|
6
|
+
overlapWindowForCandidate?: (anchor: string) => number;
|
|
7
|
+
}): Generator<TextAstReference, void>;
|
|
6
8
|
export declare function extractReferencesWithOriginalTransformations(context: TextParserContext, transformation: Transformation): Generator<TextAstReference, void>;
|
|
7
9
|
export declare const getExtractedReferences: (context: TextParserContext) => TextAstReference[];
|
|
8
10
|
export declare const getExtractedReferencesWithOriginalTransformations: (context: TextParserContext, transformation: Transformation) => TextAstReference[];
|
|
@@ -7,6 +7,7 @@ export interface TableOfContents {
|
|
|
7
7
|
divisions?: TableOfContentsDivision[];
|
|
8
8
|
}
|
|
9
9
|
export interface TableOfContentsArticle {
|
|
10
|
+
id?: string;
|
|
10
11
|
line: string;
|
|
11
12
|
type: "article";
|
|
12
13
|
}
|
|
@@ -17,6 +18,7 @@ export type TableOfContentsArticlePositioned = TableOfContentsArticle & {
|
|
|
17
18
|
export interface TableOfContentsDivision {
|
|
18
19
|
articles?: TableOfContentsArticle[];
|
|
19
20
|
divisions?: TableOfContentsDivision[];
|
|
21
|
+
id?: string;
|
|
20
22
|
line: string;
|
|
21
23
|
type: DivisionType;
|
|
22
24
|
}
|
|
@@ -0,0 +1,134 @@
|
|
|
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>;
|
|
@@ -0,0 +1,51 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Sql } from 'postgres';
|
|
2
|
+
import { LegiArticleInfo, LegiResolver, LegiSectionInfo, PreloadTextTitlesInfosOptions } from '../legi/resolver.js';
|
|
3
|
+
export type FlegiArticleInfo = LegiArticleInfo;
|
|
4
|
+
export type FlegiSectionInfo = LegiSectionInfo;
|
|
5
|
+
export declare class FlegiResolver implements LegiResolver {
|
|
6
|
+
private readonly flegiDb;
|
|
7
|
+
private readonly articleRowsByNumByTextAndDate;
|
|
8
|
+
private readonly articleNumsLoadedByTextAndDate;
|
|
9
|
+
private readonly articleRowsByContextTextId;
|
|
10
|
+
private readonly directSectionChildrenByParentAndDate;
|
|
11
|
+
private readonly globalArticleRowsByNumAndDate;
|
|
12
|
+
private readonly rootTextIdsByTextId;
|
|
13
|
+
private readonly contextTextIdsByTextId;
|
|
14
|
+
private readonly textIdBySegmentId;
|
|
15
|
+
private textTitlesInfosLoaded;
|
|
16
|
+
constructor(flegiDb: Sql);
|
|
17
|
+
getActiveArticlesByTextAndNum({ date, num, textId, }: {
|
|
18
|
+
date: string;
|
|
19
|
+
num: string | undefined;
|
|
20
|
+
textId: string;
|
|
21
|
+
}): Promise<FlegiArticleInfo[]>;
|
|
22
|
+
getDirectSectionChildren({ date, parentPath, }: {
|
|
23
|
+
date: string;
|
|
24
|
+
parentPath: string;
|
|
25
|
+
}): Promise<FlegiSectionInfo[]>;
|
|
26
|
+
getTextIdFromSegmentId(segmentId: string): Promise<string | undefined>;
|
|
27
|
+
preloadTextTitlesInfos(options?: PreloadTextTitlesInfosOptions): Promise<void>;
|
|
28
|
+
getUniqueActiveArticlesByNum({ date, num, }: {
|
|
29
|
+
date: string;
|
|
30
|
+
num: string | undefined;
|
|
31
|
+
}): Promise<FlegiArticleInfo[]>;
|
|
32
|
+
preloadUniqueActiveArticlesByNums({ date, nums, }: {
|
|
33
|
+
date: string;
|
|
34
|
+
nums: Iterable<string | undefined>;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
preloadActiveArticlesByTextIds({ date, nums, textIds, }: {
|
|
37
|
+
date: string;
|
|
38
|
+
nums?: Iterable<string | undefined>;
|
|
39
|
+
textIds: Iterable<string | undefined>;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
private queryUniqueActiveArticlesByNumsUsingContextHeuristic;
|
|
42
|
+
private queryGloballyUniqueArticleRowsByNums;
|
|
43
|
+
private getActiveArticleRowsByNum;
|
|
44
|
+
private getActiveArticleRowsForContextTextIds;
|
|
45
|
+
private getActiveArticleRowsForContextTextIdsWithRoots;
|
|
46
|
+
private queryActiveArticleRowsForContextTextIds;
|
|
47
|
+
private getDirectSectionChildrenByExactParentPath;
|
|
48
|
+
private getTextIdFromSegmentIdUsingContextHeuristic;
|
|
49
|
+
private getTextIdFromSegmentIdUsingSctaHeuristic;
|
|
50
|
+
private getContextTextIdsFromTextId;
|
|
51
|
+
private getContextTextIdsByTextIds;
|
|
52
|
+
private getRootTextIdsFromTextId;
|
|
53
|
+
private getRootTextIdsByTextIds;
|
|
54
|
+
}
|
package/dist/src/lib/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ export { assertNever } from './asserts.js';
|
|
|
4
4
|
export { newAssembleeObjectCache, newLegifranceObjectCache, newObjectCache, type AssembleeObjectCache, type AssembleeObjectType, type LegifranceObjectCache, type ObjectCache, } from './cache.js';
|
|
5
5
|
export { formatLongDate } from './dates.js';
|
|
6
6
|
export { extractBillDefinitions } from './extractors/definitions.js';
|
|
7
|
-
export { extractActionDirectivesFromHtml, extractActionDirectivesFromText, type ActionCitation, type ActionDirective, type ActionReplacement, type ActionTableTarget, } from './extractors/action_directives.js';
|
|
7
|
+
export { extractActionDirectivesFromHtml, extractActionDirectiveAstsFromText, extractActionDirectivesFromText, resolveActionDirectivesFromHtml, resolveActionDirectivesFromText, type ActionCitation, type ActionDirective, type ActionOperation, type ActionReplacement, type ActionTableTarget, type ResolvedActionDirective, } from './extractors/action_directives.js';
|
|
8
8
|
export { extractTextLinks, iterReferenceLinks, type ArticleDefinition, type ArticleExternalLink, type ArticleInternalLink, type ArticleLink, type DefinitionOrLink, type DivisionExternalLink, type DivisionLink, type ExtractedLinkDb, type TextEuropeanLink, type TextExternalLink, type TextLink, type TextLinksParserState, } from './extractors/links.js';
|
|
9
9
|
export { extractCitationReferences, extractReferences, extractReferencesWithOriginalTransformations, getExtractedReferences, getExtractedReferencesWithOriginalTransformations, } from './extractors/references.js';
|
|
10
|
-
export { buildArticlePortionTreeFromHtml, extractPortionSelectors, resolvePortionSelector, type ArticlePortionArticle, type ArticlePortionDivision, type ArticlePortionItem, type ArticlePortionAlinea, type ArticlePortionMatch, type ArticlePortionNode, type PortionSelector, type PortionSelectorStep, } from './extractors/article_portions.js';
|
|
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
13
|
export { addLinksToHtml, addLinksOrReferencesToHtmlPage, type OutputByType, type OutputType, } from './linkers/html.js';
|
|
@@ -21,8 +21,9 @@ export { linkTypes, urlFromLegalId, type LinkType } from './links.js';
|
|
|
21
21
|
export { getOrLoadDocument, getOrLoadDocumentsByDossierParlementaireUid, getOrLoadDossierParlementaire, } from './loaders/assemblee.js';
|
|
22
22
|
export { extendLoadedArticle, getOrLoadArticle, getOrLoadJo, getOrLoadSectionTa, getOrLoadSectionsTa, getOrLoadTextelr, getOrLoadTexteslr, getOrLoadTextesVersions, getOrLoadTexteVersion, loadArticles, type ArticleExtension, type JorfArticleExtended, type LegiArticleExtended, } from './loaders/legifrance.js';
|
|
23
23
|
export { action } from './text_parsers/actions.js';
|
|
24
|
+
export { actionDirective } from './text_parsers/action_directives.js';
|
|
24
25
|
export { article, articles, definitionArticleDansCitation, definitionArticleDansProjetOuPropositionLoi, designationArticle, listeArticles, nomArticle, nomSpecialArticle, } from './text_parsers/articles.js';
|
|
25
|
-
export { actionTargets, compoundReferencesSeparators, divisionTypes, europeanLawNatures, frenchLawNatures, internationalLawNatures, isTextAstAtomicReference, isTextAstDivision, isTextAstPortion, lawNatures, localizationAdverbs, portionTypes, type ActionTarget, type CompoundReferencesSeparator, type DivisionType, type EuropeanLawNature, type FrenchLawNature, type InternationalLawNature, type LawNature, type LocalizationAdverb, type PortionType, type TextAst, type TextAstAction, type TextAstArticle, type TextAstAtomicReference, type TextAstBoundedInterval, type TextAstCitation, type TextAstCompoundReference, type TextAstConseilConstitutionnelDecision, type TextAstCountedInterval, type TextAstDivision, type TextAstEnumeration, type TextAstExclusion, type TextAstIncompleteHeader, type TextAstLocalization, type TextAstNumber, type TextAstParentChild, type TextAstPortion, type TextAstPosition, type TextAstReference, type TextAstReferenceAndAction, type TextAstText, type TextAstTextIdentification, type TextAstTextInfos, type TextInfosByWordsTree, type TextInfosByWordsTreeNode, } from './text_parsers/ast.js';
|
|
26
|
+
export { actionTargets, compoundReferencesSeparators, divisionTypes, europeanLawNatures, frenchLawNatures, internationalLawNatures, isTextAstAtomicReference, isTextAstDivision, isTextAstPortion, lawNatures, localizationAdverbs, portionTypes, type ActionTarget, type CompoundReferencesSeparator, type DivisionType, type EuropeanLawNature, type FrenchLawNature, type InternationalLawNature, type LawNature, type LocalizationAdverb, type PortionType, type TextAst, type TextAstAction, type TextAstActionDirective, type TextAstActionDirectiveOperation, type TextAstActionTargetScope, type TextAstApplicabilityClause, type TextAstArticle, type TextAstAtomicReference, type TextAstBoundedInterval, type TextAstCitation, type TextAstCompoundReference, type TextAstConseilConstitutionnelDecision, type TextAstCountedInterval, type TextAstDivision, type TextAstEnumeration, type TextAstExclusion, type TextAstIncompleteHeader, type TextAstLocalization, type TextAstModificationBlock, type TextAstModificationItem, type TextAstNumber, type TextAstParentChild, type TextAstPortion, type TextAstPosition, type TextAstReference, type TextAstReferenceAndAction, type TextAstText, type TextAstTextIdentification, type TextAstTextInfos, type TextInfosByWordsTree, type TextInfosByWordsTreeNode, } from './text_parsers/ast.js';
|
|
26
27
|
export { citation, citationLigne, citationSimple, } from './text_parsers/citations.js';
|
|
27
28
|
export { date, duDate } from './text_parsers/dates.js';
|
|
28
29
|
export { definitionDivision, designationDivision, division, divisions, natureDivisionSingulier, numeroDivision, } from './text_parsers/divisions.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Sql } from 'postgres';
|
|
2
|
+
import { LegiArticleInfo, LegiResolver, LegiSectionInfo, PreloadTextTitlesInfosOptions } from './resolver.js';
|
|
3
|
+
export declare class CanutesResolver implements LegiResolver {
|
|
4
|
+
private readonly canutesDb;
|
|
5
|
+
private readonly options;
|
|
6
|
+
private readonly articleRowsByNumByTextAndDate;
|
|
7
|
+
private readonly directSectionChildrenByParentAndDate;
|
|
8
|
+
private readonly globalArticleRowsByNumAndDate;
|
|
9
|
+
private readonly textIdBySegmentId;
|
|
10
|
+
private textTitlesInfosLoaded;
|
|
11
|
+
constructor(canutesDb: Sql, options?: {
|
|
12
|
+
textTitlesInfosPath?: string;
|
|
13
|
+
});
|
|
14
|
+
getActiveArticlesByTextAndNum({ date, num, textId, }: {
|
|
15
|
+
date: string;
|
|
16
|
+
num: string | undefined;
|
|
17
|
+
textId: string;
|
|
18
|
+
}): Promise<LegiArticleInfo[]>;
|
|
19
|
+
getDirectSectionChildren({ date, parentPath, }: {
|
|
20
|
+
date: string;
|
|
21
|
+
parentPath: string;
|
|
22
|
+
}): Promise<LegiSectionInfo[]>;
|
|
23
|
+
getTextIdFromSegmentId(segmentId: string): Promise<string | undefined>;
|
|
24
|
+
getUniqueActiveArticlesByNum({ date, num, }: {
|
|
25
|
+
date: string;
|
|
26
|
+
num: string | undefined;
|
|
27
|
+
}): Promise<LegiArticleInfo[]>;
|
|
28
|
+
preloadTextTitlesInfos(options?: PreloadTextTitlesInfosOptions): Promise<void>;
|
|
29
|
+
preloadUniqueActiveArticlesByNums({ date, nums, }: {
|
|
30
|
+
date: string;
|
|
31
|
+
nums: Iterable<string | undefined>;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface LegiArticleInfo {
|
|
2
|
+
dateDebut: string;
|
|
3
|
+
dateFin: string;
|
|
4
|
+
id: string;
|
|
5
|
+
num: string | null;
|
|
6
|
+
textId: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface LegiSectionInfo {
|
|
9
|
+
dateDebut: string | null;
|
|
10
|
+
dateFin: string | null;
|
|
11
|
+
id: string;
|
|
12
|
+
path: string;
|
|
13
|
+
title: string | null;
|
|
14
|
+
}
|
|
15
|
+
export type PreloadTextTitlesInfosProgress = {
|
|
16
|
+
count?: number;
|
|
17
|
+
detail?: string;
|
|
18
|
+
phase: string;
|
|
19
|
+
resolver: LegiResolverKind;
|
|
20
|
+
};
|
|
21
|
+
export type PreloadTextTitlesInfosOptions = {
|
|
22
|
+
onProgress?: (progress: PreloadTextTitlesInfosProgress) => void;
|
|
23
|
+
};
|
|
24
|
+
export interface LegiResolver {
|
|
25
|
+
getActiveArticlesByTextAndNum(options: {
|
|
26
|
+
date: string;
|
|
27
|
+
num: string | undefined;
|
|
28
|
+
textId: string;
|
|
29
|
+
}): Promise<LegiArticleInfo[]>;
|
|
30
|
+
getDirectSectionChildren(options: {
|
|
31
|
+
date: string;
|
|
32
|
+
parentPath: string;
|
|
33
|
+
}): Promise<LegiSectionInfo[]>;
|
|
34
|
+
getTextIdFromSegmentId(segmentId: string): Promise<string | undefined>;
|
|
35
|
+
getUniqueActiveArticlesByNum(options: {
|
|
36
|
+
date: string;
|
|
37
|
+
num: string | undefined;
|
|
38
|
+
}): Promise<LegiArticleInfo[]>;
|
|
39
|
+
preloadTextTitlesInfos(options?: PreloadTextTitlesInfosOptions): Promise<void>;
|
|
40
|
+
preloadUniqueActiveArticlesByNums(options: {
|
|
41
|
+
date: string;
|
|
42
|
+
nums: Iterable<string | undefined>;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
}
|
|
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;
|
|
@@ -5,7 +5,7 @@ export interface Version {
|
|
|
5
5
|
export declare const canutesDb: postgres.Sql<{}>;
|
|
6
6
|
export declare const assembleeVersionNumber = 7;
|
|
7
7
|
export declare const legiAnomaliesVersionNumber = 1;
|
|
8
|
-
export declare const legiVersionNumber =
|
|
8
|
+
export declare const legiVersionNumber = 21;
|
|
9
9
|
export declare const tisseuseVersionNumber = 3;
|
|
10
10
|
export declare function checkAssembleeDb(): Promise<void>;
|
|
11
11
|
export declare function checkLegiAnomaliesDb(): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
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>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { simplifyWordHtml, simplifyWordHtmlToDocument, type SimplifyHtmlOptions, } from './html_simplifier.js';
|
|
2
2
|
export { addLinksOrReferencesToHtmlFile } from './linkers/html.js';
|
|
3
|
+
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';
|
|
4
|
+
export { defaultLegiResolverKind, legiResolverKinds, parseLegiResolverKind, type LegiArticleInfo, type LegiResolver, type LegiResolverKind, type LegiSectionInfo, } from '../legi/resolver.js';
|
|
3
5
|
export { addPositionsToTableOfContentsFile, simplifiedHtmlBillFileToTableOfContentsFile, } from './tables_of_contents.js';
|
|
6
|
+
export { createLegiResolver } from './legi/resolvers.js';
|
|
4
7
|
export { readTransformation, writeTransformation, } from './text_parsers/transformers.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
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, }: {
|
|
6
|
+
canutesDb: Sql;
|
|
7
|
+
resolver?: string;
|
|
8
|
+
textTitlesInfosPath?: string;
|
|
9
|
+
}): LegiResolver;
|
|
10
|
+
export declare function endLegiResolverDatabases(): Promise<void>;
|