@tricoteuses/tisseuse 0.13.9 → 0.13.10
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 +11 -0
- package/dist/server.js +47 -35
- package/dist/src/lib/server/atomic_files.d.ts +8 -0
- package/dist/src/lib/server/atomic_files.test.d.ts +1 -0
- package/dist/src/lib/server/document_git_checkpoint.d.ts +6 -0
- package/dist/src/lib/server/document_git_checkpoint.test.d.ts +1 -0
- package/dist/src/lib/server/enriched_document_checkpoint.d.ts +3 -0
- package/dist/src/lib/server/enriched_document_checkpoint.test.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,6 +96,17 @@ npm run index:postgres:assemblee -- --all
|
|
|
96
96
|
|
|
97
97
|
La première commande consomme la file des documents à acquérir, simplifier et enrichir. La seconde indexe dans `tisseuse.assemblee_text_search` les articles et les exposés des motifs comme résultats distincts. Les déclencheurs sur `assemblee.documents`, le hash du contenu et les files PostgreSQL permettent les mises à jour ciblées ; les options `--all` demandent une réconciliation complète.
|
|
98
98
|
|
|
99
|
+
Pour acquérir et indexer immédiatement quelques documents indépendamment de leur position dans les files durables :
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
npm run sync:postgres:assemblee-content -- \
|
|
103
|
+
--document-uids PRJLANR5L17BTC2765,PRJLANR5L17BTC3067
|
|
104
|
+
npm run index:postgres:assemblee -- \
|
|
105
|
+
--document-uids PRJLANR5L17BTC2765,PRJLANR5L17BTC3067
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Le mode ciblé refuse les UID absents de `assemblee.documents` et ne peut pas être combiné avec `--all`.
|
|
109
|
+
|
|
99
110
|
Exploratrice et Moulineuse ne téléchargent jamais un document pendant une lecture. Lorsqu’un document source existe mais que son contenu n’est pas encore disponible, son état est conservé en base et l’interface doit l’indiquer au lieu de servir une copie locale périmée.
|
|
100
111
|
|
|
101
112
|
### Première itération de recherche plein texte Sénat
|
package/dist/server.js
CHANGED
|
@@ -269,7 +269,7 @@ function F(e) {
|
|
|
269
269
|
}
|
|
270
270
|
return null;
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function I(e, t, n) {
|
|
273
273
|
let r = [t.container], i = n?.container;
|
|
274
274
|
for (let e = F(t.container); e !== null && e !== i; e = F(e)) r.push(e);
|
|
275
275
|
if (r.length > 1) return r;
|
|
@@ -279,7 +279,7 @@ function _e(e, t, n) {
|
|
|
279
279
|
return n >= a && (o === -1 || n < o);
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
|
-
function
|
|
282
|
+
function _e(e, t) {
|
|
283
283
|
let n = [], r = /* @__PURE__ */ new Set();
|
|
284
284
|
for (let i of t) {
|
|
285
285
|
let t = "p,li,table", a = e(i).is(t) ? [i] : e(i).find(t).get();
|
|
@@ -287,9 +287,9 @@ function ve(e, t) {
|
|
|
287
287
|
}
|
|
288
288
|
return n;
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function L(e, t, n) {
|
|
291
291
|
let r = [], i = !1;
|
|
292
|
-
for (let a of
|
|
292
|
+
for (let a of _e(e, n)) {
|
|
293
293
|
let n = E(e(a).text());
|
|
294
294
|
if (!n) continue;
|
|
295
295
|
T.test(n) && (i = !0);
|
|
@@ -305,52 +305,64 @@ function I(e, t, n) {
|
|
|
305
305
|
}
|
|
306
306
|
return r;
|
|
307
307
|
}
|
|
308
|
-
function
|
|
308
|
+
function R(e, t) {
|
|
309
309
|
if (t.length === 0) return e;
|
|
310
310
|
let n = `<div style="display: none;">\n${t.map((e) => `<p class="assnatTOC6"><a href="#${`_TocArt${(e.num ?? e.label.replace(/^Article\s+/iu, "")).replace(/\s+/gu, "")}`}"><span class="assnatHyperlink" style="font-weight:bold; text-decoration:none; color:#000000">${e.label.toUpperCase()}</span></a></p>`).join("\n")}\n</div>`;
|
|
311
311
|
return e.includes("class=\"assnatSection3\"") ? e.replace(/(<div class="assnatSection3">)/u, `${n}$1`) : e.includes("id=\"formCorrection:panel:1:table\"") ? e.replace(/(<div id="formCorrection:panel:1:table">)/u, `${n}$1`) : `${n}\n${e}`;
|
|
312
312
|
}
|
|
313
|
-
function
|
|
313
|
+
function ve(t) {
|
|
314
314
|
let n = e(t);
|
|
315
315
|
for (let e of P(n)) {
|
|
316
316
|
let t = `_TocArt${(e.num ?? e.label.replace(/^Article\s+/iu, "")).replace(/\s+/gu, "")}`, r = n(e.element), i = r.attr("id");
|
|
317
|
-
i?.startsWith("_TocArt") || (i?.startsWith("_Toc") && !
|
|
317
|
+
i?.startsWith("_TocArt") || (i?.startsWith("_Toc") && !z(n, i, e.element) && r.before(n("<span></span>").attr("id", i)), r.attr("id", t));
|
|
318
|
+
}
|
|
319
|
+
let r = P(n);
|
|
320
|
+
for (let [e, t] of r.entries()) {
|
|
321
|
+
let i = I(n, t, r[e + 1]).flatMap((e) => n(e).is("span.alinea[data-alinea]") ? [e] : n(e).find("span.alinea[data-alinea]").get());
|
|
322
|
+
for (let e of i) {
|
|
323
|
+
let r = n(e).attr("data-alinea")?.trim();
|
|
324
|
+
if (!r) continue;
|
|
325
|
+
let i = `${t.id}-alinea-${r.replace(/\s+/gu, "")}`;
|
|
326
|
+
if (z(n, i, e)) continue;
|
|
327
|
+
let a = n(e).attr("id");
|
|
328
|
+
a && a !== i ? n(e).before(n("<span></span>").attr("id", i)) : n(e).attr("id", i);
|
|
329
|
+
}
|
|
318
330
|
}
|
|
319
331
|
return n.html();
|
|
320
332
|
}
|
|
321
|
-
function
|
|
333
|
+
function z(e, t, n) {
|
|
322
334
|
for (let r of e("[id]").get()) if (r !== n && e(r).attr("id") === t) return !0;
|
|
323
335
|
return !1;
|
|
324
336
|
}
|
|
325
|
-
function
|
|
337
|
+
function ye(e, t) {
|
|
326
338
|
let n = ue("sourceText" in t ? t.sourceText : "");
|
|
327
339
|
if (n) return e.filter((e) => e.kind === "directive_candidate").find((e) => {
|
|
328
340
|
let t = ue(e.text);
|
|
329
341
|
return t.length > 0 && (n.includes(t) || t.includes(n));
|
|
330
342
|
});
|
|
331
343
|
}
|
|
332
|
-
function
|
|
344
|
+
function be(e, t) {
|
|
333
345
|
if (t) return t.blockIds.map((t) => e.get(t)).find((e) => e?.kind === "directive_candidate");
|
|
334
346
|
}
|
|
335
|
-
function
|
|
347
|
+
function xe(e) {
|
|
336
348
|
return e?.links.filter((e) => !e.insideFrenchQuotes && (e.type === "article" || e.type === "division")).map((e) => e.id) ?? [];
|
|
337
349
|
}
|
|
338
|
-
var
|
|
350
|
+
var Se = [
|
|
339
351
|
/^([IVXLCDM]+)\s*[.).]?\s*[–—-]/iu,
|
|
340
352
|
/^(\d+°)\s+/u,
|
|
341
353
|
/^([a-z])\)\s+/iu,
|
|
342
354
|
/^([ivxlcdm]+)\)\s+/iu
|
|
343
355
|
];
|
|
344
|
-
function
|
|
356
|
+
function Ce(e) {
|
|
345
357
|
let t = E(e);
|
|
346
358
|
if (!t) return;
|
|
347
|
-
let n =
|
|
359
|
+
let n = Se.findIndex((e) => e.test(t));
|
|
348
360
|
return n === -1 ? t.endsWith(":") ? 0 : void 0 : n + 1;
|
|
349
361
|
}
|
|
350
|
-
function
|
|
362
|
+
function we(e) {
|
|
351
363
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
352
364
|
for (let r of e) {
|
|
353
|
-
let e =
|
|
365
|
+
let e = Ce(r.text);
|
|
354
366
|
if (e === void 0) {
|
|
355
367
|
t.set(r.id, [...n, r]);
|
|
356
368
|
continue;
|
|
@@ -359,14 +371,14 @@ function Te(e) {
|
|
|
359
371
|
}
|
|
360
372
|
return t;
|
|
361
373
|
}
|
|
362
|
-
function
|
|
374
|
+
function Te(e, t) {
|
|
363
375
|
let n = [], r = /* @__PURE__ */ new Set();
|
|
364
376
|
for (let i of [...e ?? [], ...t]) i !== void 0 && (r.has(i.id) || (r.add(i.id), n.push(i)));
|
|
365
377
|
return n;
|
|
366
378
|
}
|
|
367
|
-
function
|
|
379
|
+
function Ee(e, t, n) {
|
|
368
380
|
if (!t) return;
|
|
369
|
-
let r =
|
|
381
|
+
let r = Te(e, t.blockIds.map((e) => n.get(e)).filter((e) => e !== void 0));
|
|
370
382
|
if (r.length === 0) return;
|
|
371
383
|
let i = r.map((e) => e.id);
|
|
372
384
|
if (i.length === t.blockIds.length && i.every((e, n) => e === t.blockIds[n])) return;
|
|
@@ -381,7 +393,7 @@ function De(e, t, n) {
|
|
|
381
393
|
}
|
|
382
394
|
};
|
|
383
395
|
}
|
|
384
|
-
function
|
|
396
|
+
function De(e) {
|
|
385
397
|
let t = [], n = 0;
|
|
386
398
|
for (let r of e.blocks) {
|
|
387
399
|
let i = e.directiveText.indexOf(r.text, n);
|
|
@@ -395,7 +407,7 @@ function Oe(e) {
|
|
|
395
407
|
}
|
|
396
408
|
return t;
|
|
397
409
|
}
|
|
398
|
-
function
|
|
410
|
+
function Oe(e, t, n) {
|
|
399
411
|
let { start: r, stop: i } = n.sourcePosition, a = t.filter((e) => e.stop >= r && e.start <= i);
|
|
400
412
|
if (a.length === 0) return;
|
|
401
413
|
let o = a[0], s = a[a.length - 1], c = o.start, l = s.stop;
|
|
@@ -409,7 +421,7 @@ function ke(e, t, n) {
|
|
|
409
421
|
}
|
|
410
422
|
};
|
|
411
423
|
}
|
|
412
|
-
function
|
|
424
|
+
function ke(e, t, n) {
|
|
413
425
|
if (!t) return;
|
|
414
426
|
let r = e.directiveText.indexOf(t.text);
|
|
415
427
|
if (r === -1) return;
|
|
@@ -422,14 +434,14 @@ function Ae(e, t, n) {
|
|
|
422
434
|
stop: a
|
|
423
435
|
};
|
|
424
436
|
}
|
|
425
|
-
function
|
|
426
|
-
let t =
|
|
437
|
+
function Ae(e) {
|
|
438
|
+
let t = De(e), n = new Map(e.blocks.map((e) => [e.id, e])), r = we(e.blocks), a = /* @__PURE__ */ new Map(), o = [];
|
|
427
439
|
for (let t of e.blocks) {
|
|
428
|
-
let e =
|
|
440
|
+
let e = xe(t);
|
|
429
441
|
e.length > 0 && (o = e), a.set(t.id, o);
|
|
430
442
|
}
|
|
431
443
|
return i(e.directiveText).map((i) => {
|
|
432
|
-
let o =
|
|
444
|
+
let o = Oe(e, t, i), s = be(n, o) ?? ye(e.blocks, i), c = xe(s), l = c.length > 0 ? c : s?.id === void 0 ? [] : a.get(s.id) ?? [], u = ke(e, s, i), d = Ee(s?.id === void 0 ? void 0 : r.get(s.id), o, n);
|
|
433
445
|
return {
|
|
434
446
|
articleId: e.id,
|
|
435
447
|
blockId: s?.id,
|
|
@@ -449,7 +461,7 @@ function je(e) {
|
|
|
449
461
|
};
|
|
450
462
|
});
|
|
451
463
|
}
|
|
452
|
-
function
|
|
464
|
+
function je(e) {
|
|
453
465
|
let t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Set();
|
|
454
466
|
for (let i of e) {
|
|
455
467
|
let e = re(i.directive);
|
|
@@ -479,7 +491,7 @@ function Me(e) {
|
|
|
479
491
|
definitions: n
|
|
480
492
|
};
|
|
481
493
|
}
|
|
482
|
-
function
|
|
494
|
+
function Me(e, t, n) {
|
|
483
495
|
let r = new Map(t.map((e) => [O(e.num), e]));
|
|
484
496
|
return e.map((e) => {
|
|
485
497
|
let t = n.get(e), i = t?.[0], a = [...k(e.directive.reference)].map((e) => r.get(O(e))).filter((e) => e !== void 0 && e.definitionId !== i?.definitionId)[0], o = a === void 0 ? void 0 : {
|
|
@@ -498,7 +510,7 @@ function Ne(e, t, n) {
|
|
|
498
510
|
};
|
|
499
511
|
});
|
|
500
512
|
}
|
|
501
|
-
function
|
|
513
|
+
function Ne(e, t, n, i, a, o, s = !0) {
|
|
502
514
|
let c = a.map((e) => e.directiveText).filter(Boolean).join("\n"), l = {
|
|
503
515
|
sourceFormat: e,
|
|
504
516
|
documentDate: i,
|
|
@@ -511,7 +523,7 @@ function z(e, t, n, i, a, o, s = !0) {
|
|
|
511
523
|
...l,
|
|
512
524
|
directives: []
|
|
513
525
|
};
|
|
514
|
-
let u = le(a.map((e) => e.text).join("\n")), d = a.flatMap(
|
|
526
|
+
let u = le(a.map((e) => e.text).join("\n")), d = a.flatMap(Ae), { createdArticlesByDirective: f, definitions: p } = je(d), m = Me(d, p, f);
|
|
515
527
|
return {
|
|
516
528
|
...l,
|
|
517
529
|
...u ? { globalApplicabilityDate: u } : {},
|
|
@@ -532,8 +544,8 @@ function Pe(e) {
|
|
|
532
544
|
})) };
|
|
533
545
|
}
|
|
534
546
|
async function Fe(t, n) {
|
|
535
|
-
let r = new u("parseAssembleeBillRaw"), i = n.linkedHtml === void 0 ? await r.time("linkAssembleeBillRaw", () => Ie(t, n)) : void 0, a = r.timeSync("applyArticleAnchorIds", () =>
|
|
536
|
-
let n =
|
|
547
|
+
let r = new u("parseAssembleeBillRaw"), i = n.linkedHtml === void 0 ? await r.time("linkAssembleeBillRaw", () => Ie(t, n)) : void 0, a = r.timeSync("applyArticleAnchorIds", () => ve(n.linkedHtml ?? i.linkedHtml), { inputSize: t.length }), o = r.timeSync("cheerioLoadLinkedHtml", () => e(a)), s = r.timeSync("extractArticleHeadings", () => P(o)), c = r.timeSync("extractArticlesAndBlocks", () => s.map((e, t) => {
|
|
548
|
+
let n = I(o, e, s[t + 1]), r = L(o, e.id, n), i = r.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
|
|
537
549
|
return {
|
|
538
550
|
id: e.id,
|
|
539
551
|
label: e.label,
|
|
@@ -544,7 +556,7 @@ async function Fe(t, n) {
|
|
|
544
556
|
directiveText: i,
|
|
545
557
|
blocks: r
|
|
546
558
|
};
|
|
547
|
-
}), { count: s.length }), l = r.timeSync("injectHiddenArticleSummary", () =>
|
|
559
|
+
}), { count: s.length }), l = r.timeSync("injectHiddenArticleSummary", () => R(o.html(), c)), d = r.timeSync("buildAssembleeTableOfContents", () => Pe(c), { count: c.length }), f = r.timeSync("buildParsedDocument", () => Ne("assemblee-html", t, l, n.date, c, d, n.includeDirectiveAnalysis));
|
|
548
560
|
return r.log({
|
|
549
561
|
articleCount: f.articles.length,
|
|
550
562
|
blockCount: f.articles.reduce((e, t) => e + t.blocks.length, 0),
|
|
@@ -966,7 +978,7 @@ function gt(t) {
|
|
|
966
978
|
function _t(e) {
|
|
967
979
|
let t = [];
|
|
968
980
|
return e("article.akn-article").each((n, r) => {
|
|
969
|
-
let i = e(r).children("p.TCNumArticle").first().get(0), a = E(i ? e(i).text() : ""), o = M(a) ?? { label: a || `Article ${n + 1}` }, s = e(r).attr("id") ?? `akn-article-${String(n + 1).padStart(3, "0")}`, c = [r], l =
|
|
981
|
+
let i = e(r).children("p.TCNumArticle").first().get(0), a = E(i ? e(i).text() : ""), o = M(a) ?? { label: a || `Article ${n + 1}` }, s = e(r).attr("id") ?? `akn-article-${String(n + 1).padStart(3, "0")}`, c = [r], l = L(e, s, c), u = l.filter((e) => e.kind !== "noise").map((e) => e.text).join("\n");
|
|
970
982
|
t.push({
|
|
971
983
|
id: s,
|
|
972
984
|
label: o.label,
|
|
@@ -995,7 +1007,7 @@ async function yt(t, n) {
|
|
|
995
1007
|
} })), a = n.date ?? pt(i), o = r.timeSync("renderAknHtml", () => mt(i), { inputSize: t.length }), s = n.linkedHtml ?? await r.time("addLinksToRenderedAknHtml", () => N(o, {
|
|
996
1008
|
...n,
|
|
997
1009
|
date: a
|
|
998
|
-
}, a)), c = r.timeSync("extractRenderedAknArticles", () => gt(o)), l = r.timeSync("injectHiddenArticleSummary", () =>
|
|
1010
|
+
}, a)), c = r.timeSync("extractRenderedAknArticles", () => gt(o)), l = r.timeSync("injectHiddenArticleSummary", () => R(s, c)), { articles: d, htmlWithLinks: f } = r.timeSync("extractLinkedAknArticlesAndTaggedHtml", () => vt(l)), p = d.length > 0 ? d : c, m = r.timeSync("extractAknTableOfContents", () => ft(i)), h = r.timeSync("buildParsedDocument", () => Ne("akoma-ntoso", o, d.length > 0 ? f : l, a, p, m));
|
|
999
1011
|
return r.log({
|
|
1000
1012
|
articleCount: h.articles.length,
|
|
1001
1013
|
blockCount: h.articles.reduce((e, t) => e + t.blocks.length, 0),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function writeJsonAtomic(filePath: string, value: unknown, options?: {
|
|
2
|
+
encoding?: BufferEncoding;
|
|
3
|
+
spaces?: number;
|
|
4
|
+
stagingDirectory?: string;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
export declare function replaceDirectoryAtomically(targetDirectory: string, build: (stagingDirectory: string) => Promise<void>, { stagingRoot, }?: {
|
|
7
|
+
stagingRoot?: string;
|
|
8
|
+
}): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|