@tricoteuses/tisseuse 0.2.0 → 0.4.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.
@@ -0,0 +1,13 @@
1
+ import { JorfArticle, LegiArticle } from '@tricoteuses/legifrance';
2
+ import { Sql } from 'postgres';
3
+ import { LegalObjectCacheByIdByCategorieTag } from './loaders.js';
4
+ /**
5
+ * TODO: Migrate to @tricoteuses/legifrance
6
+ */
7
+ export declare function getArticleDateSignature(article: JorfArticle | LegiArticle): string;
8
+ /**
9
+ * TODO:
10
+ * - Handle date to filter articles outside date
11
+ * - Migrate everything @tricoteuses/legifrance.
12
+ */
13
+ export declare function getOrLoadArticleSiblingId(legiDb: Sql, legalObjectCacheByIdByCategorieTag: LegalObjectCacheByIdByCategorieTag, id: string, offset: -1 | 1): Promise<string | undefined>;
@@ -1,7 +1,8 @@
1
+ export { getArticleDateSignature, getOrLoadArticleSiblingId, } from './articles.js';
1
2
  export { assertNever } from './asserts.js';
2
3
  export { formatLongDate } from './dates.js';
3
4
  export { jsonReplacer } from './json.js';
4
- export { iterCardinalNumeralFormsFromNumber, iterLatinMultiplicativeAdverbsFromNumber, iterOrdinalNumeralFormsFromNumber, numberFromRomanNumeral, ordinalNumeralFromNumber, romanNumeralFromNumber, } from './numbers.js';
5
+ export { extendLoadedArticle, newLegalObjectCacheByIdByCategorieTag, getOrLoadArticle, getOrLoadJo, getOrLoadSectionTa, getOrLoadSectionsTa, getOrLoadTextelr, getOrLoadTexteVersion, type ArticleExtension, type JorfArticleExtended, type LegalObjectCacheByIdByCategorieTag, type LegiArticleExtended, } from './loaders.js';
5
6
  export { action } from './text_parsers/actions.js';
6
7
  export { article, articles, definitionArticle, designationArticle, listeArticles, nomArticle, nomSpecialArticle, } from './text_parsers/articles.js';
7
8
  export { compoundReferencesSeparators, divisionTypes, europeanLawNatures, frenchLawNatures, internationalLawNatures, isTextAstAtomicReference, isTextAstDivision, isTextAstPortion, lawNatures, localizationAdverbs, portionTypes, 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';
@@ -18,6 +19,7 @@ export { ditPluriel, ditSingulier, introPluriel, introSingulier, liaisonPluriel,
18
19
  export { reference, uniteBasePreciseeSingulier, uniteBaseSingulier, } from './text_parsers/references.js';
19
20
  export { adverbeRelatif, espaceAdverbeRelatif, relatifPlurielPrepose, relatifSingulierPrepose, } from './text_parsers/relative_locations.js';
20
21
  export { convertHtmlElementsToText, decodeNamedHtmlEntities, decodeNumericHtmlEntities, replacePattern, replacePatterns, simplifyHtml, simplifyText, simplifyUnicodeCharacters, } from './text_parsers/simplifiers.js';
22
+ export { parseTextLinks, type ArticleDefinition, type ArticleExternalLink, type ArticleInternalLink, type ArticleLink, type DefinitionOrLink, type DivisionExternalLink, type DivisionLink, type ExtractedLinkDb, type TextExternalLink, type TextLink, type TextLinksParserState, } from './text_parsers/text_links.js';
21
23
  export { definitionTexteFrancais, identificationTexteEuropeen, natureTexteFrancais, numeroEtOuDateTexteFrancais, numeroTexteEuropeen, numeroTexteFrancais, optionalEspaceDuTerritoire, texte, texteEuropeen, texteFrancais, texteInternational, } from './text_parsers/texts.js';
22
24
  export { chainTransformers, iterOriginalMergedPositionsFromTransformed, originalMergedPositionsFromTransformed, originalSplitPositionsFromTransformed, reverseTransformedInnerFragment, reverseTransformedReplacement, type SourceMapSegment, type Transformation, type TransformationLeaf, type TransformationNode, type Transformer, type TransformerLeaf, type TransformerNode, } from './text_parsers/transformers.js';
23
25
  export { espace, lettreAsciiMinuscule, nonLettre, numero, virguleOuEspace, } from './text_parsers/typography.js';
@@ -0,0 +1,19 @@
1
+ import { Jo, JorfArticle, JorfCategorieTag, JorfSectionTa, JorfTextelr, JorfTexteVersion, LegiArticle, LegiCategorieTag, LegiSectionTa, LegiTextelr, LegiTexteVersion } from '@tricoteuses/legifrance';
2
+ import { JSONValue, Sql } from 'postgres';
3
+ export interface ArticleExtension {
4
+ num?: string;
5
+ }
6
+ export type JorfArticleExtended = JorfArticle & ArticleExtension;
7
+ export type LegalObjectCacheByIdByCategorieTag = Map<JorfCategorieTag | LegiCategorieTag, Map<string, JSONValue>>;
8
+ export type LegiArticleExtended = LegiArticle & ArticleExtension;
9
+ export declare function extendLoadedArticle<ArticleType extends JorfArticle | LegiArticle>({ data: article, num, }: {
10
+ data: ArticleType;
11
+ num: string | null;
12
+ }): ArticleType & ArticleExtension;
13
+ export declare function getOrLoadArticle<ArticleType extends JorfArticle | LegiArticle>(legiDb: Sql, legalObjectCacheByIdByCategorieTag: LegalObjectCacheByIdByCategorieTag, id: string): Promise<(ArticleType & ArticleExtension) | undefined>;
14
+ export declare function getOrLoadJo<JoType extends Jo>(legiDb: Sql, legalObjectCacheByIdByCategorieTag: LegalObjectCacheByIdByCategorieTag, id: string): Promise<JoType | undefined>;
15
+ export declare function getOrLoadSectionTa<SectionTaType extends JorfSectionTa | LegiSectionTa>(legiDb: Sql, legalObjectCacheByIdByCategorieTag: LegalObjectCacheByIdByCategorieTag, id: string): Promise<SectionTaType | undefined>;
16
+ export declare function getOrLoadSectionsTa<SectionTaType extends JorfSectionTa | LegiSectionTa>(legiDb: Sql, legalObjectCacheByIdByCategorieTag: LegalObjectCacheByIdByCategorieTag, ids: string[]): Promise<SectionTaType[]>;
17
+ export declare function getOrLoadTextelr<TextelrType extends JorfTextelr | LegiTextelr>(legiDb: Sql, legalObjectCacheByIdByCategorieTag: LegalObjectCacheByIdByCategorieTag, id: string): Promise<TextelrType | undefined>;
18
+ export declare function getOrLoadTexteVersion<TexteVersionType extends JorfTexteVersion | LegiTexteVersion>(legiDb: Sql, legalObjectCacheByIdByCategorieTag: LegalObjectCacheByIdByCategorieTag, id: string): Promise<TexteVersionType | undefined>;
19
+ export declare const newLegalObjectCacheByIdByCategorieTag: () => LegalObjectCacheByIdByCategorieTag;
@@ -7,7 +7,7 @@ export declare const assembleeVersionNumber = 7;
7
7
  export declare const legiAnomaliesDb: postgres.Sql<{}>;
8
8
  export declare const legiAnomaliesVersionNumber = 1;
9
9
  export declare const legiDb: postgres.Sql<{}>;
10
- export declare const legiVersionNumber = 16;
10
+ export declare const legiVersionNumber = 19;
11
11
  export declare const tisseuseDb: postgres.Sql<{}>;
12
12
  export declare const tisseuseVersionNumber = 1;
13
13
  /**
@@ -11,6 +11,7 @@ export declare const nombreRomainOu0iAsTextAstNumber: import('./parsers.js').Tex
11
11
  export declare const adjectifNumeralCardinalDix: import('./parsers.js').TextParser;
12
12
  export declare const adjectifNumeralCardinalDizaine: import('./parsers.js').TextParser;
13
13
  export declare const adjectifNumeralCardinalUnite: import('./parsers.js').TextParser;
14
+ export declare const adjectifNumeralCardinalLong: import('./parsers.js').TextParser;
14
15
  export declare const adjectifNumeralCardinal: import('./parsers.js').TextParser;
15
16
  export declare const adjectifNumeralOrdinalLong: import('./parsers.js').TextParser;
16
17
  export declare const adjectifNumeralOrdinal: import('./parsers.js').TextParser;
@@ -9,8 +9,10 @@ export declare const naturePortionPluriel: import('./parsers.js').TextParser;
9
9
  */
10
10
  export declare const numeroPortion: import('./parsers.js').TextParser;
11
11
  /**
12
- * Portion désignée soit par un adjectif relatif soit par un ordinal écrit en lettres,
13
- * par exemple « même alinéa » ou « troisième phrase »
12
+ * Portion désignée !
13
+ * - soit par un adjectif relatif (par exemple « même alinéa)
14
+ * - soit par un nombre ordinal écrit en lettres (par exemple « troisième phrase »)
15
+ * - soit par un npmbre cardinal (par exemple « alinéa 3 »)
14
16
  */
15
17
  export declare const unePortion: import('./parsers.js').TextParser;
16
18
  export declare const numeroPortionOuUnePortion: import('./parsers.js').TextParser;
@@ -43,7 +45,7 @@ export declare const listeQuelquesPortions: import('./parsers.js').TextParser;
43
45
  * TODO: Les fusionner ?
44
46
  */
45
47
  export declare const listePortions: import('./parsers.js').TextParser;
46
- export declare const portionsEntreParentheses: import('./parsers.js').TextParser;
48
+ export declare const portionsEntreParenthesesOuVirgules: import('./parsers.js').TextParser;
47
49
  export declare const localisationPortion: import('./parsers.js').TextParser;
48
50
  export declare const portion: import('./parsers.js').TextParser;
49
51
  export declare const portions: import('./parsers.js').TextParser;
@@ -1,5 +1,8 @@
1
+ import { Sql } from 'postgres';
1
2
  import { TextAstArticle, TextAstDivision, TextAstPosition, TextAstReference, TextAstText } from './ast.js';
2
3
  import { FragmentPosition, FragmentReverseTransformation } from './fragments.js';
4
+ import { TextParserContext } from './parsers.js';
5
+ import { Transformation } from './transformers.js';
3
6
  export type DefinitionOrLink = ArticleDefinition | ArticleLink | DivisionLink | TextLink;
4
7
  export interface ArticleDefinition {
5
8
  article: TextAstArticle;
@@ -75,3 +78,28 @@ export interface TextExternalLink {
75
78
  type: "external_text";
76
79
  }
77
80
  export type TextLink = TextExternalLink;
81
+ export interface TextLinksParserState {
82
+ articleId?: string;
83
+ codeId?: string;
84
+ constitutionId?: string;
85
+ decreeId?: string;
86
+ defaultTextId?: string;
87
+ lawId?: string;
88
+ sectionTaId?: string;
89
+ textId?: string;
90
+ }
91
+ export declare function parseTextLinks({ context, date, legiDb, logIgnoredReferencesTypes, logPartialReferences, logReferences, state: inputState, transformation, }: {
92
+ context: TextParserContext;
93
+ date: string;
94
+ legiDb: Sql;
95
+ logIgnoredReferencesTypes?: boolean;
96
+ logPartialReferences?: boolean;
97
+ logReferences?: boolean;
98
+ /**
99
+ * When given, state is modified by this generator, so that the callers
100
+ * always has the latest state version (and can reuse it for the next article,
101
+ * for example).
102
+ */
103
+ state?: TextLinksParserState;
104
+ transformation?: Transformation;
105
+ }): AsyncGenerator<DefinitionOrLink, void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,6 @@
1
+ import { JorfTexteVersion, LegiTexteVersion } from '@tricoteuses/legifrance';
1
2
  export declare const cleanTexteTitle: <StringOrUndefined extends string | undefined>(title: StringOrUndefined) => StringOrUndefined;
3
+ /**
4
+ * TODO: Migrate to @tricoteuses/legifrance
5
+ */
6
+ export declare function getTexteVersionDateSignature(texteVersion: JorfTexteVersion | LegiTexteVersion): string;
@@ -0,0 +1,2 @@
1
+ import { JorfArticle, LegiArticle } from '@tricoteuses/legifrance';
2
+ export declare function getArticleNum(article: JorfArticle | LegiArticle): Promise<string | undefined>;
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.2.0",
4
+ "version": "0.4.0",
5
5
  "keywords": [
6
6
  "Assemblée nationale",
7
7
  "France",
@@ -26,7 +26,9 @@
26
26
  "node": ">=22.14.0"
27
27
  },
28
28
  "files": [
29
- "dist"
29
+ "dist",
30
+ "!dist/server",
31
+ "!**/*.test.js"
30
32
  ],
31
33
  "exports": {
32
34
  ".": {
@@ -44,28 +46,28 @@
44
46
  "configure": "tsx src/scripts/configure.ts",
45
47
  "format": "prettier --write \"src/**/*.ts\"",
46
48
  "lint": "eslint .",
47
- "prepare": "npm run build",
49
+ "prepack": "npm run build",
48
50
  "test": "npm run test:unit -- --run",
49
51
  "test:unit": "vitest"
50
52
  },
51
53
  "devDependencies": {
52
54
  "@auditors/core": "^0.7.4",
53
55
  "@tricoteuses/assemblee": "^2.3.1",
54
- "@tricoteuses/legifrance": "^0.15.2",
56
+ "@tricoteuses/legifrance": "^0.16.0",
55
57
  "@types/fs-extra": "^11.0.4",
56
- "@types/node": "^24.3.1",
57
- "@typescript-eslint/eslint-plugin": "^8.43.0",
58
- "@typescript-eslint/parser": "^8.43.0",
58
+ "@types/node": "^24.8.1",
59
+ "@typescript-eslint/eslint-plugin": "^8.46.1",
60
+ "@typescript-eslint/parser": "^8.46.1",
59
61
  "dedent-js": "^1.0.1",
60
62
  "dotenv": "^17.2.2",
61
- "eslint": "^9.35.0",
63
+ "eslint": "^9.38.0",
62
64
  "fs-extra": "^11.3.1",
63
65
  "postgres": "^3.4.7",
64
66
  "prettier": "^3.0.0",
65
67
  "sade": "^1.8.1",
66
68
  "tsx": "^4.20.5",
67
69
  "typescript": "^5.0.0",
68
- "vite": "^7.1.5",
70
+ "vite": "^7.1.10",
69
71
  "vite-plugin-dts": "^4.5.4",
70
72
  "vitest": "^3.2.4"
71
73
  }
@@ -1,6 +0,0 @@
1
- export declare function iterCardinalNumeralFormsFromNumber(num: number): Generator<string, void>;
2
- export declare function iterLatinMultiplicativeAdverbsFromNumber(num: number): Generator<string, void>;
3
- export declare function iterOrdinalNumeralFormsFromNumber(num: number): Generator<string, void>;
4
- export declare function numberFromRomanNumeral(romanNumeral: string): number;
5
- export declare function ordinalNumeralFromNumber(num: number): string | undefined;
6
- export declare function romanNumeralFromNumber(num: number): string | undefined;
@@ -1,11 +0,0 @@
1
- import { TextParserContext } from '../text_parsers/parsers.js';
2
- import { DefinitionOrLink } from '../text_parsers/text_links.js';
3
- import { Transformation } from '../text_parsers/transformers.js';
4
- export declare function iterTextLinks(context: TextParserContext, { date, defaultTextId, logIgnoredReferencesTypes, logPartialReferences, logReferences, transformation, }: {
5
- date: string;
6
- defaultTextId?: string;
7
- logIgnoredReferencesTypes?: boolean;
8
- logPartialReferences?: boolean;
9
- logReferences?: boolean;
10
- transformation?: Transformation;
11
- }): AsyncGenerator<DefinitionOrLink, void>;