@tricoteuses/tisseuse 0.12.9 → 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.
Files changed (32) hide show
  1. package/README.md +46 -0
  2. package/dist/index.js +143 -1397
  3. package/dist/server.js +2739 -158
  4. package/dist/src/lib/extractors/action_directives.d.ts +84 -22
  5. package/dist/src/lib/extractors/article_portions.d.ts +15 -1
  6. package/dist/src/lib/extractors/references.d.ts +3 -1
  7. package/dist/src/lib/extractors/table_of_contents.d.ts +2 -0
  8. package/dist/src/lib/f_legi/extractors/links.d.ts +134 -0
  9. package/dist/src/lib/f_legi/linkers/html.d.ts +51 -0
  10. package/dist/src/lib/f_legi/resolver.d.ts +54 -0
  11. package/dist/src/lib/index.d.ts +4 -3
  12. package/dist/src/lib/legi/canutes_resolver.d.ts +33 -0
  13. package/dist/src/lib/legi/resolver.d.ts +48 -0
  14. package/dist/src/lib/server/databases/index.d.ts +1 -1
  15. package/dist/src/lib/server/f_legi/databases/index.d.ts +2 -0
  16. package/dist/src/lib/server/f_legi/linkers/html.d.ts +20 -0
  17. package/dist/src/lib/server/index.d.ts +3 -0
  18. package/dist/src/lib/server/legi/resolvers.d.ts +10 -0
  19. package/dist/src/lib/server/parsed_bills.d.ts +105 -0
  20. package/dist/src/lib/server/parsed_bills.test.d.ts +1 -0
  21. package/dist/src/lib/test/text_titles_infos.d.ts +1 -0
  22. package/dist/src/lib/text_parsers/action_directives.d.ts +3 -0
  23. package/dist/src/lib/text_parsers/action_directives.test.d.ts +1 -0
  24. package/dist/src/lib/text_parsers/ast.d.ts +53 -1
  25. package/dist/src/lib/text_parsers/parsers.d.ts +2 -0
  26. package/dist/src/lib/text_parsers/texts.d.ts +1 -0
  27. package/dist/src/lib/timings.d.ts +19 -0
  28. package/dist/src/scripts/f_legi/add_links_to_html_document.d.ts +0 -0
  29. package/dist/src/scripts/parse_akoma_ntoso_bill_raw.d.ts +1 -0
  30. package/dist/src/scripts/parse_assemblee_bill_raw.d.ts +1 -0
  31. package/dist/{html-D3MxsPeu.js → textes-8dVwaLo9.js} +5162 -3076
  32. package/package.json +5 -5
@@ -0,0 +1,105 @@
1
+ import { Sql } from 'postgres';
2
+ import { ResolvedActionDirective } from '../extractors/action_directives.js';
3
+ import { TableOfContents } from '../extractors/table_of_contents.js';
4
+ import { LegiResolver } from '../legi/resolver.js';
5
+ import { LinkType } from '../links.js';
6
+ export type ParsedBillSourceFormat = "assemblee-html" | "akoma-ntoso";
7
+ export type ParsedBillBlockKind = "directive_candidate" | "context" | "noise";
8
+ export type ParsedBillToc = TableOfContents;
9
+ export type ParsedBillBlock = {
10
+ id: string;
11
+ articleId: string;
12
+ kind: ParsedBillBlockKind;
13
+ links: ParsedBillLink[];
14
+ text: string;
15
+ html: string;
16
+ };
17
+ export type ParsedBillLink = {
18
+ id: string;
19
+ insideFrenchQuotes?: boolean;
20
+ text?: string;
21
+ type: "article" | "division" | "text";
22
+ };
23
+ export type ParsedBillArticle = {
24
+ id: string;
25
+ label: string;
26
+ num?: string;
27
+ title?: string;
28
+ text: string;
29
+ html: string;
30
+ directiveText: string;
31
+ blocks: ParsedBillBlock[];
32
+ };
33
+ export type ParsedBillDirective = {
34
+ articleId: string;
35
+ blockId?: string;
36
+ sourceBlockIds?: string[];
37
+ sourceBlockText?: string;
38
+ sourceBlockHtml?: string;
39
+ sourceBlockPosition?: {
40
+ start: number;
41
+ stop: number;
42
+ };
43
+ sourceContextBlockIds?: string[];
44
+ sourceContextText?: string;
45
+ sourceContextHtml?: string;
46
+ sourceContextPosition?: {
47
+ start: number;
48
+ stop: number;
49
+ };
50
+ directive: ResolvedActionDirective;
51
+ createdArticle?: ParsedBillInternalArticleTarget;
52
+ createdArticles?: ParsedBillInternalArticleTarget[];
53
+ internalTarget?: ParsedBillInternalArticleTarget & {
54
+ resolution: "explicit" | "fallback";
55
+ };
56
+ internalTargetAmbiguity?: ParsedBillInternalArticleTarget;
57
+ targetIds?: string[];
58
+ };
59
+ export type ParsedBillInternalArticleTarget = {
60
+ definitionId: string;
61
+ num: string;
62
+ };
63
+ export type ParsedBillInternalArticleDefinition = ParsedBillInternalArticleTarget & {
64
+ articleId: string;
65
+ blockId?: string;
66
+ html: string;
67
+ parentTargetIds?: string[];
68
+ sourceDirectiveId?: string;
69
+ sourceBlockHtml?: string;
70
+ sourceBlockText?: string;
71
+ text: string;
72
+ };
73
+ export type ParseBillRawOptions = {
74
+ canutesDb?: Sql;
75
+ date?: string;
76
+ legiResolver?: LegiResolver;
77
+ linkBaseUrl: string;
78
+ linkType: LinkType;
79
+ linkedHtml?: string;
80
+ logIgnoredReferencesTypes?: boolean;
81
+ logPartialReferences?: boolean;
82
+ logReferences?: boolean;
83
+ };
84
+ export type LinkedBillDocument = {
85
+ sourceFormat: ParsedBillSourceFormat;
86
+ documentDate?: string;
87
+ html: string;
88
+ linkedHtml: string;
89
+ };
90
+ export type ParsedBillDocument = {
91
+ sourceFormat: ParsedBillSourceFormat;
92
+ documentDate?: string;
93
+ html: string;
94
+ htmlWithLinks: string;
95
+ tableOfContents: ParsedBillToc;
96
+ articles: ParsedBillArticle[];
97
+ globalApplicabilityDate?: string;
98
+ internalArticleDefinitions?: ParsedBillInternalArticleDefinition[];
99
+ directives: ParsedBillDirective[];
100
+ };
101
+ export declare function parseAssembleeBillRaw(input: string, options: ParseBillRawOptions): Promise<ParsedBillDocument>;
102
+ export declare function linkAssembleeBillRaw(input: string, options: ParseBillRawOptions): Promise<LinkedBillDocument>;
103
+ export declare function renderAkomaNtosoBillRaw(input: string): LinkedBillDocument;
104
+ export declare function parseAkomaNtosoBillRaw(input: string, options: ParseBillRawOptions): Promise<ParsedBillDocument>;
105
+ export declare function linkAkomaNtosoBillRaw(input: string, options: ParseBillRawOptions): Promise<LinkedBillDocument>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function preloadTextTitlesInfosForTests(): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { TextAstActionDirective } from './ast.js';
2
+ import { TextParser } from './parsers.js';
3
+ export declare const actionDirective: TextParser<TextAstActionDirective>;
@@ -9,13 +9,65 @@ export type InternationalLawNature = (typeof internationalLawNatures)[number];
9
9
  export type LawNature = (typeof lawNatures)[number];
10
10
  export type LocalizationAdverb = (typeof localizationAdverbs)[number];
11
11
  export type PortionType = (typeof portionTypes)[number];
12
- export type TextAst = boolean | null | number | string | TextAstAction | TextAstArticle | TextAstBoundedInterval | TextAstCitation | TextAstLocalization | TextAstNumber | TextAstPosition | TextAstReference | TextAstText | TextAstTextIdentification | TextAstTextInfos | Array<TextAst>;
12
+ export type TextAst = boolean | null | number | string | TextAstAction | TextAstActionDirective | TextAstApplicabilityClause | TextAstArticle | TextAstBoundedInterval | TextAstCitation | TextAstLocalization | TextAstModificationBlock | TextAstModificationItem | TextAstNumber | TextAstPosition | TextAstReference | TextAstText | TextAstTextIdentification | TextAstTextInfos | Array<TextAst>;
13
13
  export interface TextAstAction {
14
14
  action: "abroger" | "ajouter" | "application" | "compléter" | "dérogation" | "devenir" | "insérer" | "mention" | "modifier" | "précision" | "prévision" | "remplacer" | "renuméroter" | "rédiger" | "référence_définition" | "rétablir" | "supprimer";
15
15
  actionInContent?: boolean;
16
16
  originalCitations?: TextAstCitation[];
17
17
  target?: ActionTarget;
18
18
  }
19
+ export type TextAstActionDirectiveOperation = {
20
+ kind: "delete";
21
+ occurrenceIndex?: number;
22
+ targetCitation: TextAstCitation;
23
+ targetScope?: TextAstActionTargetScope;
24
+ } | {
25
+ insertCitation: TextAstCitation;
26
+ kind: "insert_after" | "insert_before";
27
+ targetCitation?: TextAstCitation;
28
+ } | {
29
+ kind: "replace";
30
+ replacementCitation: TextAstCitation;
31
+ targetCitation: TextAstCitation;
32
+ targetScope?: TextAstActionTargetScope;
33
+ } | {
34
+ kind: "replace_portion";
35
+ replacementCitation?: TextAstCitation;
36
+ replacementKind: "following_table" | "text";
37
+ } | {
38
+ kind: "delete_portion";
39
+ } | {
40
+ kind: "delete_article";
41
+ };
42
+ export type TextAstActionTargetScope = {
43
+ type: "tail_after_target";
44
+ unit?: "phrase" | "alinéa" | "article";
45
+ };
46
+ export type TextAstActionDirective = {
47
+ action: TextAstAction;
48
+ operations: TextAstActionDirectiveOperation[];
49
+ reference: TextAstReference;
50
+ type: "action_directive";
51
+ } & TextAstPosition;
52
+ export type TextAstApplicabilityClause = {
53
+ date: string;
54
+ itemPaths: string[][];
55
+ type: "applicability_clause";
56
+ } & TextAstPosition;
57
+ export type TextAstModificationItem = {
58
+ actionDirectives: TextAstActionDirective[];
59
+ applicabilityClauses: TextAstApplicabilityClause[];
60
+ children: TextAstModificationItem[];
61
+ marker: string;
62
+ path: string[];
63
+ type: "modification_item";
64
+ } & TextAstPosition;
65
+ export type TextAstModificationBlock = {
66
+ actionDirectives: TextAstActionDirective[];
67
+ applicabilityClauses: TextAstApplicabilityClause[];
68
+ items: TextAstModificationItem[];
69
+ type: "modification_block";
70
+ } & TextAstPosition;
19
71
  export type TextAstArticle = {
20
72
  definition?: boolean;
21
73
  definitionSuffix?: string;
@@ -7,7 +7,9 @@ export type TextParser<T extends TextAst = TextAst> = {
7
7
  (context: TextParserContext): T | undefined;
8
8
  extract?: (context: TextParserContext, options?: {
9
9
  jumpExact?: boolean;
10
+ globalRegExpFlags?: string;
10
11
  overlapWindow?: number;
12
+ overlapWindowForCandidate?: (anchor: string) => number;
11
13
  }) => Generator<T, void, undefined>;
12
14
  };
13
15
  export declare class TextParserContext {
@@ -1,3 +1,4 @@
1
+ export declare function setTextTitlesInfos(textTitlesInfos: unknown): void;
1
2
  /**
2
3
  * Nature d’un texte français, par exemple « code » ou « loi organique »
3
4
  *
@@ -0,0 +1,19 @@
1
+ export type TimingMetric = {
2
+ count?: number;
3
+ durationMs: number;
4
+ inputSize?: number;
5
+ outputSize?: number;
6
+ phase: string;
7
+ };
8
+ export declare class TimingCollector {
9
+ readonly label: string;
10
+ readonly enabled: boolean;
11
+ readonly metrics: TimingMetric[];
12
+ readonly startedAt: number;
13
+ constructor(label: string, enabled?: boolean);
14
+ add(metric: TimingMetric): void;
15
+ time<T>(phase: string, task: () => Promise<T>, details?: Omit<TimingMetric, "durationMs" | "phase">): Promise<T>;
16
+ timeSync<T>(phase: string, task: () => T, details?: Omit<TimingMetric, "durationMs" | "phase">): T;
17
+ log(extra?: Record<string, unknown>): void;
18
+ }
19
+ export declare function isTimingEnabled(): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};