@tricoteuses/tisseuse 0.13.8 → 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.
package/README.md CHANGED
@@ -133,46 +133,34 @@ Les documents sans URL, externes au Sénat, sans Akoma Ntoso ou en échec de par
133
133
 
134
134
  ## Legal reference resolver
135
135
 
136
- Tisseuse resolves legal references through a `LegiResolver`. The default
137
- resolver is `canutes`, which uses the configured Canutes database and a generated
138
- `text_titles_infos.json` file.
136
+ Tisseuse resolves legal references through the Canutes-backed `LegiResolver`.
137
+ `LegiResolver` is exported as an abstract class from both
138
+ `@tricoteuses/tisseuse` and `@tricoteuses/tisseuse/server`, so applications can
139
+ provide another storage-backed implementation. At process startup, the Canutes
140
+ resolver reads the title metadata it needs directly from
141
+ `legifrance.texte_version` and builds the parser indexes in memory. Concurrent
142
+ callers share the same preload operation, and the resulting indexes remain fixed
143
+ for the lifetime of the process.
139
144
 
140
- There are two supported resolver paths for tests and scripts:
145
+ No generated title index belongs in the source tree. Tests that resolve the full
146
+ Légifrance title corpus need access to the configured Canutes database and call
147
+ the same preload operation as production code.
141
148
 
142
- - `f_legi`: uses the flat f_legi database and does not need a generated
143
- `text_titles_infos.json` file.
144
- - `canutes`: uses the Canutes database and requires generating
145
- `src/lib/text_parsers/text_titles_infos.json` before running tests that parse
146
- or resolve French text titles.
149
+ ### `f_legi` server adapter
147
150
 
148
- Use `f_legi` explicitly when you want to run against the flat f_legi database:
151
+ Applications backed by a `f_legi` database can import the optional server-only
152
+ adapter from the same package:
149
153
 
150
- ```sh
151
- TISSEUSE_LEGI_RESOLVER=f_legi npm test
152
- npx tsx src/scripts/parse_assemblee_bill_raw.ts bill.html.raw --resolver f_legi
153
- ```
154
+ ```ts
155
+ import { FlegiResolver } from "@tricoteuses/tisseuse/server/f-legi"
154
156
 
155
- For the default Canutes resolver, generate the text title index first, then run
156
- the tests:
157
-
158
- ```sh
159
- npx tsx src/scripts/extract_texts_titles_infos.ts
160
- npm test
157
+ const resolver = new FlegiResolver(sql)
161
158
  ```
162
159
 
163
- This creates `src/lib/text_parsers/text_titles_infos.json`. It is generated from
164
- the Canutes database, is listed in `.gitignore`, and must never be committed.
165
-
166
- If you need to keep the generated file outside the working tree, pass it through
167
- `TISSEUSE_TEXT_TITLES_INFOS_PATH` or script options instead:
168
-
169
- ```sh
170
- TISSEUSE_TEXT_TITLES_INFOS_PATH=/path/to/text_titles_infos.json npm test
171
- npx tsx src/scripts/parse_akoma_ntoso_bill_raw.ts bill.akn.xml.raw --text-titles-infos /path/to/text_titles_infos.json
172
- ```
160
+ The caller owns the PostgreSQL client and its lifecycle. Importing the adapter
161
+ does not open a connection, read environment variables, or preload title data.
162
+ The generic Tisseuse entry points do not load this adapter.
173
163
 
174
- If no path is supplied, the Canutes resolver first tries
175
- `src/lib/text_parsers/text_titles_infos.json` from the current working tree, then
176
- the same generated file in the local tisseuse package source tree. That file is
177
- generated data and is not loaded through Vitest global setup; tests that need it
178
- preload it explicitly through the selected resolver.
164
+ External adapters can extend the public `LegiResolver` class. The public package
165
+ also exports the resolver option types and `buildAndInstallTextTitlesInfos`, so
166
+ an adapter does not need deep imports into Tisseuse.