@tricoteuses/tisseuse 0.10.0 → 0.12.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.
@@ -14,7 +14,7 @@ export declare const getArticleDateSignature: (article: JorfArticle | LegiArticl
14
14
  * - Handle date to filter articles outside date
15
15
  * - Migrate everything @tricoteuses/legifrance.
16
16
  */
17
- export declare function getOrLoadArticleSiblingId(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string, offset: -1 | 1): Promise<string | undefined>;
17
+ export declare function getOrLoadArticleSiblingId(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string, offset: -1 | 1): Promise<string | undefined>;
18
18
  /**
19
19
  * TODO: Migrate to @tricoteuses/legifrance
20
20
  */
@@ -33,6 +33,7 @@ export type ActionDirective = {
33
33
  reference: TextAstReference;
34
34
  portionSelectors: PortionSelector[];
35
35
  targetText: string;
36
+ occurrenceIndex?: number;
36
37
  sourcePosition: FragmentPosition;
37
38
  sourceText: string;
38
39
  } | {
@@ -101,11 +101,10 @@ export interface TextLinksParserState {
101
101
  sectionTaId?: string;
102
102
  textId?: string;
103
103
  }
104
- export declare function extractTextLinks({ context, date, europeDb, legiDb, logIgnoredReferencesTypes, logPartialReferences, logReferences, state: inputState, transformation, }: {
104
+ export declare function extractTextLinks({ context, date, canutesDb, logIgnoredReferencesTypes, logPartialReferences, logReferences, state: inputState, transformation, }: {
105
105
  context: TextParserContext;
106
106
  date: string;
107
- europeDb: Sql;
108
- legiDb: Sql;
107
+ canutesDb: Sql;
109
108
  logIgnoredReferencesTypes?: boolean;
110
109
  logPartialReferences?: boolean;
111
110
  logReferences?: boolean;
@@ -117,12 +116,11 @@ export declare function extractTextLinks({ context, date, europeDb, legiDb, logI
117
116
  state?: TextLinksParserState;
118
117
  transformation?: Transformation;
119
118
  }): AsyncGenerator<DefinitionOrLink, void>;
120
- export declare function iterReferenceLinks({ articleDefinitionByNumByTextId: articleDefinitionByNumByTextIdInput, context, date, europeDb, legiDb, logIgnoredReferencesTypes, logPartialReferences, originalPositionsFromTransformedIterator, reference, state: inputState, }: {
119
+ export declare function iterReferenceLinks({ articleDefinitionByNumByTextId: articleDefinitionByNumByTextIdInput, canutesDb, context, date, logIgnoredReferencesTypes, logPartialReferences, originalPositionsFromTransformedIterator, reference, state: inputState, }: {
121
120
  articleDefinitionByNumByTextId?: Record<string, Record<string, ArticleDefinition>>;
121
+ canutesDb: Sql;
122
122
  context: TextParserContext;
123
123
  date: string;
124
- europeDb: Sql;
125
- legiDb: Sql;
126
124
  logIgnoredReferencesTypes?: boolean;
127
125
  logPartialReferences?: boolean;
128
126
  originalPositionsFromTransformedIterator?: Generator<FragmentReverseTransformation, void, FragmentPosition | undefined>;
@@ -3,11 +3,10 @@ import { DefinitionOrLink, TextLinksParserState } from '../extractors/links.js';
3
3
  import { LinkType } from '../links.js';
4
4
  import { TextParserContext } from '../text_parsers/parsers.js';
5
5
  import { Transformation } from '../text_parsers/transformers.js';
6
- export declare function addLinksToHtml({ date, europeDb, html, legiDb, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, onLink, previousContext, state, }: {
6
+ export declare function addLinksToHtml({ canutesDb, date, html, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, onLink, previousContext, state, }: {
7
+ canutesDb: Sql;
7
8
  date: string;
8
- europeDb: Sql;
9
9
  html: string;
10
- legiDb: Sql;
11
10
  linkBaseUrl: string;
12
11
  linkType: LinkType;
13
12
  logIgnoredReferencesTypes?: boolean;
@@ -25,13 +24,12 @@ export type OutputByType = Partial<Record<OutputType, {
25
24
  offset: number;
26
25
  }>>;
27
26
  export type OutputType = "links" | "links_or_references" | "references";
28
- export declare function addLinksOrReferencesToHtmlPage({ date, defaultTextId, europeDb, htmlTransformation, inputHtml, legiDb, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, outputTypes: requestedOutputTypes, referredLegifranceTextsInfos, }: {
27
+ export declare function addLinksOrReferencesToHtmlPage({ canutesDb, date, defaultTextId, htmlTransformation, inputHtml, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, outputTypes: requestedOutputTypes, referredLegifranceTextsInfos, }: {
28
+ canutesDb: Sql;
29
29
  date: string;
30
30
  defaultTextId?: string;
31
- europeDb: Sql;
32
31
  htmlTransformation: Transformation;
33
32
  inputHtml: string;
34
- legiDb: Sql;
35
33
  linkBaseUrl: string;
36
34
  linkType: LinkType;
37
35
  logIgnoredReferencesTypes?: boolean;
@@ -1,10 +1,9 @@
1
1
  import { Sql } from 'postgres';
2
2
  import { LinkType } from '../links.js';
3
3
  import { TextParserContext } from '../text_parsers/parsers.js';
4
- export declare function addLinksToMarkdown({ date, europeDb, legiDb, linkBaseUrl, linkType, previousContext, text, }: {
4
+ export declare function addLinksToMarkdown({ canutesDb, date, linkBaseUrl, linkType, previousContext, text, }: {
5
+ canutesDb: Sql;
5
6
  date: string;
6
- europeDb: Sql;
7
- legiDb: Sql;
8
7
  linkBaseUrl: string;
9
8
  linkType: LinkType;
10
9
  previousContext?: TextParserContext;
@@ -1,6 +1,6 @@
1
1
  import { Document, DossierParlementaire } from '@tricoteuses/assemblee';
2
2
  import { Sql } from 'postgres';
3
3
  import { AssembleeObjectCache } from '../cache.js';
4
- export declare function getOrLoadDocument(assembleeDb: Sql, assembleeObjectCache: AssembleeObjectCache, uid: string): Promise<Document | undefined>;
5
- export declare function getOrLoadDocumentsByDossierParlementaireUid(assembleeDb: Sql, assembleeObjectCache: AssembleeObjectCache, dossierUid: string): Promise<Document[]>;
6
- export declare function getOrLoadDossierParlementaire(assembleeDb: Sql, assembleeObjectCache: AssembleeObjectCache, uid: string): Promise<DossierParlementaire | undefined>;
4
+ export declare function getOrLoadDocument(canutesDb: Sql, assembleeObjectCache: AssembleeObjectCache, uid: string): Promise<Document | undefined>;
5
+ export declare function getOrLoadDocumentsByDossierParlementaireUid(canutesDb: Sql, assembleeObjectCache: AssembleeObjectCache, dossierUid: string): Promise<Document[]>;
6
+ export declare function getOrLoadDossierParlementaire(canutesDb: Sql, assembleeObjectCache: AssembleeObjectCache, uid: string): Promise<DossierParlementaire | undefined>;
@@ -10,13 +10,13 @@ export declare function extendLoadedArticle<ArticleType extends JorfArticle | Le
10
10
  data: ArticleType;
11
11
  num: string | null;
12
12
  }): ArticleType & ArticleExtension;
13
- export declare function getOrLoadArticle<ArticleType extends JorfArticle | LegiArticle>(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string): Promise<(ArticleType & ArticleExtension) | undefined>;
14
- export declare function getOrLoadArticles<ArticleType extends JorfArticle | LegiArticle>(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, ids: string[]): Promise<Array<ArticleType & ArticleExtension>>;
15
- export declare function getOrLoadJo<JoType extends Jo>(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string): Promise<JoType | undefined>;
16
- export declare function getOrLoadSectionTa<SectionTaType extends JorfSectionTa | LegiSectionTa>(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string): Promise<SectionTaType | undefined>;
17
- export declare function getOrLoadSectionsTa<SectionTaType extends JorfSectionTa | LegiSectionTa>(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, ids: string[]): Promise<SectionTaType[]>;
18
- export declare function getOrLoadTextelr<TextelrType extends JorfTextelr | LegiTextelr>(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string): Promise<TextelrType | undefined>;
19
- export declare function getOrLoadTexteslr<TextelrType extends JorfTextelr | LegiTextelr>(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, ids: string[]): Promise<Array<TextelrType>>;
20
- export declare function getOrLoadTextesVersions<TexteVersionType extends JorfTexteVersion | LegiTexteVersion>(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, ids: string[]): Promise<Array<TexteVersionType>>;
21
- export declare function getOrLoadTexteVersion<TexteVersionType extends JorfTexteVersion | LegiTexteVersion>(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string): Promise<TexteVersionType | undefined>;
22
- export declare function loadArticles<ArticleType extends JorfArticle | LegiArticle>(legiDb: Sql, legifranceObjectCache: LegifranceObjectCache, whereClause: PendingQuery<Row[]> | Array<PendingQuery<Row[]>>): Promise<Array<ArticleType & ArticleExtension>>;
13
+ export declare function getOrLoadArticle<ArticleType extends JorfArticle | LegiArticle>(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string): Promise<(ArticleType & ArticleExtension) | undefined>;
14
+ export declare function getOrLoadArticles<ArticleType extends JorfArticle | LegiArticle>(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, ids: string[]): Promise<Array<ArticleType & ArticleExtension>>;
15
+ export declare function getOrLoadJo<JoType extends Jo>(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string): Promise<JoType | undefined>;
16
+ export declare function getOrLoadSectionTa<SectionTaType extends JorfSectionTa | LegiSectionTa>(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string): Promise<SectionTaType | undefined>;
17
+ export declare function getOrLoadSectionsTa<SectionTaType extends JorfSectionTa | LegiSectionTa>(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, ids: string[]): Promise<SectionTaType[]>;
18
+ export declare function getOrLoadTextelr<TextelrType extends JorfTextelr | LegiTextelr>(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string): Promise<TextelrType | undefined>;
19
+ export declare function getOrLoadTexteslr<TextelrType extends JorfTextelr | LegiTextelr>(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, ids: string[]): Promise<Array<TextelrType>>;
20
+ export declare function getOrLoadTextesVersions<TexteVersionType extends JorfTexteVersion | LegiTexteVersion>(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, ids: string[]): Promise<Array<TexteVersionType>>;
21
+ export declare function getOrLoadTexteVersion<TexteVersionType extends JorfTexteVersion | LegiTexteVersion>(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, id: string): Promise<TexteVersionType | undefined>;
22
+ export declare function loadArticles<ArticleType extends JorfArticle | LegiArticle>(canutesDb: Sql, legifranceObjectCache: LegifranceObjectCache, whereClause: PendingQuery<Row[]> | Array<PendingQuery<Row[]>>): Promise<Array<ArticleType & ArticleExtension>>;
@@ -1,9 +1,6 @@
1
1
  import { LinkType } from '../links';
2
2
  export interface Config {
3
- assembleeDb: DatabaseConfig;
4
- europeDb: DatabaseConfig;
5
- legiAnomaliesDb: DatabaseConfig;
6
- legiDb: DatabaseConfig;
3
+ canutesDb: DatabaseConfig;
7
4
  linkBaseUrl: string;
8
5
  linkType: LinkType;
9
6
  }
@@ -2,23 +2,13 @@ import { default as postgres } from 'postgres';
2
2
  export interface Version {
3
3
  number: number;
4
4
  }
5
- export declare const assembleeDb: postgres.Sql<{}>;
5
+ export declare const canutesDb: postgres.Sql<{}>;
6
6
  export declare const assembleeVersionNumber = 7;
7
- export declare const europeDb: postgres.Sql<{}>;
8
- export declare const legiAnomaliesDb: postgres.Sql<{}>;
9
7
  export declare const legiAnomaliesVersionNumber = 1;
10
- export declare const legiDb: postgres.Sql<{}>;
11
8
  export declare const legiVersionNumber = 19;
12
9
  export declare const tisseuseVersionNumber = 3;
13
- /**
14
- * Check that assemblee database exists and is up to date.
15
- */
16
10
  export declare function checkAssembleeDb(): Promise<void>;
17
- /**
18
- * Check that legi_anomalies database exists and is up to date.
19
- */
20
11
  export declare function checkLegiAnomaliesDb(): Promise<void>;
21
- /**
22
- * Check that legi database exists and is up to date.
23
- */
24
12
  export declare function checkLegiDb(): Promise<void>;
13
+ export declare function checkTisseuseDb(): Promise<void>;
14
+ export declare function configureTisseuseDatabase(): Promise<void>;
@@ -1,9 +1,9 @@
1
1
  import { LinkType } from '../../links.js';
2
2
  import { Sql } from 'postgres';
3
- export declare function addLinksOrReferencesToHtmlFile({ date, defaultTextId, europeDb, htmlFilePath, htmlTransformationsInputDir, htmlTransformationsOutputDir, htmlWithLinksFilePath, htmlWithLinksOrReferencesFilePath, htmlWithLinksTransformationsOutputDir, htmlWithReferencesFilePath, legiDb, linkBaseUrl, linkType, logIgnoredReferencesTypes, logPartialReferences, logReferences, referredLegifranceTextsInfosFilePath, }: {
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
5
  date: string;
5
6
  defaultTextId?: string;
6
- europeDb: Sql;
7
7
  htmlFilePath: string;
8
8
  htmlTransformationsInputDir?: string;
9
9
  htmlTransformationsOutputDir?: string;
@@ -11,7 +11,6 @@ export declare function addLinksOrReferencesToHtmlFile({ date, defaultTextId, eu
11
11
  htmlWithLinksOrReferencesFilePath?: string;
12
12
  htmlWithLinksTransformationsOutputDir?: string;
13
13
  htmlWithReferencesFilePath?: string;
14
- legiDb: Sql;
15
14
  linkBaseUrl: string;
16
15
  linkType: LinkType;
17
16
  logIgnoredReferencesTypes?: boolean;
@@ -16,4 +16,9 @@ export declare const adjectifNumeralCardinalLong: import('./parsers.js').TextPar
16
16
  export declare const adjectifNumeralCardinal: import('./parsers.js').TextParser<TextAst>;
17
17
  export declare const adjectifNumeralOrdinalLong: import('./parsers.js').TextParser<TextAst>;
18
18
  export declare const adjectifNumeralOrdinal: import('./parsers.js').TextParser<TextAst>;
19
+ export declare const multiplicativeLatinSuffixes: Array<{
20
+ pattern: string;
21
+ value: number;
22
+ }>;
23
+ export declare const multiplicativeLatinSuffixPattern: string;
19
24
  export declare const adverbeMultiplicatifLatin: import('./parsers.js').TextParser<TextAst>;
@@ -0,0 +1,4 @@
1
+ declare const _default: {}
2
+ ;
3
+
4
+ export default _default;
@@ -0,0 +1 @@
1
+ export declare function configure(): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as e, a as t, g as n, mn as r, o as i, t as a } from "./html-B_uf_8Zi.js";
1
+ import { $ as e, a as t, g as n, gn as r, o as i, t as a } from "./html-kKhAILq4.js";
2
2
  import * as o from "node:crypto";
3
3
  import s from "fs-extra";
4
4
  import c from "node:path";
@@ -19445,32 +19445,31 @@ function N(e, t, n = "1") {
19445
19445
  }
19446
19446
  //#endregion
19447
19447
  //#region src/lib/server/linkers/html.ts
19448
- async function P({ date: e, defaultTextId: t, europeDb: r, htmlFilePath: i, htmlTransformationsInputDir: o, htmlTransformationsOutputDir: c, htmlWithLinksFilePath: l, htmlWithLinksOrReferencesFilePath: u, htmlWithLinksTransformationsOutputDir: d, htmlWithReferencesFilePath: f, legiDb: p, linkBaseUrl: m, linkType: h, logIgnoredReferencesTypes: g, logPartialReferences: _, logReferences: v, referredLegifranceTextsInfosFilePath: y }) {
19449
- let b = await s.readFile(i, { encoding: "utf-8" }), x;
19450
- o === void 0 ? (x = n({ removeAWithHref: !0 })(b), c !== void 0 && N(x, c)) : x = j(b, o);
19451
- let S = [];
19452
- l !== void 0 && S.push("links"), u !== void 0 && S.push("links_or_references"), f !== void 0 && S.push("references");
19453
- let { outputByType: C, referredLegifranceTextCountByCid: w } = await a({
19454
- date: e,
19455
- defaultTextId: t,
19456
- europeDb: r,
19457
- htmlTransformation: x,
19458
- inputHtml: b,
19459
- legiDb: p,
19460
- linkBaseUrl: m,
19461
- linkType: h,
19462
- logIgnoredReferencesTypes: g,
19463
- logPartialReferences: _,
19464
- logReferences: v,
19465
- outputTypes: S,
19466
- referredLegifranceTextsInfos: y !== void 0
19467
- }), T = {};
19468
- l !== void 0 && (T.links = l), u !== void 0 && (T.links_or_references = u), f !== void 0 && (T.references = f);
19469
- for (let [e, t] of Object.entries(C)) {
19470
- let n = T[e];
19448
+ async function P({ canutesDb: e, date: t, defaultTextId: r, htmlFilePath: i, htmlTransformationsInputDir: o, htmlTransformationsOutputDir: c, htmlWithLinksFilePath: l, htmlWithLinksOrReferencesFilePath: u, htmlWithLinksTransformationsOutputDir: d, htmlWithReferencesFilePath: f, linkBaseUrl: p, linkType: m, logIgnoredReferencesTypes: h, logPartialReferences: g, logReferences: _, referredLegifranceTextsInfosFilePath: v }) {
19449
+ let y = await s.readFile(i, { encoding: "utf-8" }), b;
19450
+ o === void 0 ? (b = n({ removeAWithHref: !0 })(y), c !== void 0 && N(b, c)) : b = j(y, o);
19451
+ let x = [];
19452
+ l !== void 0 && x.push("links"), u !== void 0 && x.push("links_or_references"), f !== void 0 && x.push("references");
19453
+ let { outputByType: S, referredLegifranceTextCountByCid: C } = await a({
19454
+ canutesDb: e,
19455
+ date: t,
19456
+ defaultTextId: r,
19457
+ htmlTransformation: b,
19458
+ inputHtml: y,
19459
+ linkBaseUrl: p,
19460
+ linkType: m,
19461
+ logIgnoredReferencesTypes: h,
19462
+ logPartialReferences: g,
19463
+ logReferences: _,
19464
+ outputTypes: x,
19465
+ referredLegifranceTextsInfos: v !== void 0
19466
+ }), w = {};
19467
+ l !== void 0 && (w.links = l), u !== void 0 && (w.links_or_references = u), f !== void 0 && (w.references = f);
19468
+ for (let [e, t] of Object.entries(S)) {
19469
+ let n = w[e];
19471
19470
  n !== void 0 && await s.writeFile(n, t.html, { encoding: "utf-8" });
19472
19471
  }
19473
- C.links !== void 0 && d !== void 0 && N(n()(C.links.html), d), y !== void 0 && await s.writeJson(y, w, {
19472
+ S.links !== void 0 && d !== void 0 && N(n()(S.links.html), d), v !== void 0 && await s.writeJson(v, C, {
19474
19473
  encoding: "utf-8",
19475
19474
  spaces: 2
19476
19475
  });
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.10.0",
4
+ "version": "0.12.0",
5
5
  "keywords": [
6
6
  "Assemblée nationale",
7
7
  "France",
@@ -50,6 +50,8 @@
50
50
  "access": "public"
51
51
  },
52
52
  "scripts": {
53
+ "associate:jorf:commissions": "tsx src/scripts/associate_jorf_textes_with_assemblee_commissions.ts",
54
+ "associate:jorf:dossiers": "tsx src/scripts/associate_jorf_textes_with_dossiers_legislatifs_assemblee.ts",
53
55
  "build": "vite build",
54
56
  "configure": "tsx src/scripts/configure.ts",
55
57
  "format": "prettier --write \"src/**/*.ts\" \"*.md\"",
@@ -62,26 +64,28 @@
62
64
  },
63
65
  "devDependencies": {
64
66
  "@auditors/core": "^0.7.4",
65
- "@tricoteuses/assemblee": "^3.0.18",
66
- "@tricoteuses/legifrance": "^0.17.0",
67
- "@tricoteuses/senat": "^2.22.16",
67
+ "@tricoteuses/assemblee": "^3.2.0",
68
+ "@tricoteuses/legifrance": "^0.18.0",
69
+ "@tricoteuses/senat": "^3.0.1",
68
70
  "@types/fs-extra": "^11.0.4",
69
71
  "@types/node": "^25.5.0",
70
- "@typescript-eslint/eslint-plugin": "^8.57.1",
71
- "@typescript-eslint/parser": "^8.57.1",
72
+ "@types/papaparse": "^5.5.2",
73
+ "@typescript-eslint/eslint-plugin": "^8.57.2",
74
+ "@typescript-eslint/parser": "^8.57.2",
72
75
  "cheerio": "^1.2.0",
73
76
  "dedent-js": "^1.0.1",
74
77
  "dotenv": "^17.3.1",
75
- "eslint": "^10.0.3",
78
+ "eslint": "^10.1.0",
76
79
  "fs-extra": "^11.3.4",
80
+ "papaparse": "^5.5.3",
77
81
  "postgres": "^3.4.8",
78
82
  "prettier": "^3.8.1",
79
83
  "sade": "^1.8.1",
80
84
  "tsx": "^4.21.0",
81
85
  "typescript": "^5.9.3",
82
- "typesense": "^3.0.3",
83
- "vite": "^8.0.0",
86
+ "typesense": "^3.0.4",
87
+ "vite": "^8.0.3",
84
88
  "vite-plugin-dts": "^4.5.4",
85
- "vitest": "^4.1.0"
89
+ "vitest": "^4.1.2"
86
90
  }
87
91
  }