@tricoteuses/tisseuse 0.14.13 → 0.14.14

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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as e, A as t, At as n, B as r, Bt as i, Ct as a, Dt as o, Et as s, F as c, Ft as l, G as u, Gt as d, H as f, Ht as p, I as m, It as ee, J as te, K as ne, L as re, Lt as ie, M as ae, Mt as oe, N as se, Nt as ce, Ot as le, P as ue, Pt as de, Q as fe, R as pe, Rt as me, S as he, St as ge, U as _e, Ut as ve, V as ye, Vt as be, W as xe, Wt as Se, Y as Ce, Z as we, _ as Te, _t as h, a as g, at as Ee, bt as De, c as Oe, ct as ke, d as Ae, dt as je, et as Me, f as Ne, ft as Pe, g as Fe, gt as Ie, h as Le, ht as Re, i as _, it as ze, j as Be, jt as Ve, kt as He, l as Ue, lt as We, m as Ge, mt as Ke, n as qe, o as Je, ot as Ye, pt as Xe, q as Ze, r as Qe, rt as $e, s as et, st as tt, t as nt, tt as rt, u as v, ut as it, v as at, vt as y, wt as ot, xt as st, yt as ct, z as lt, zt as ut } from "./html-D6-bRvBF.js";
1
+ import { $ as e, A as t, At as n, B as r, Bt as i, Ct as a, Dt as o, Et as s, F as c, Ft as l, G as u, Gt as d, H as f, Ht as p, I as m, It as ee, J as te, K as ne, L as re, Lt as ie, M as ae, Mt as oe, N as se, Nt as ce, Ot as le, P as ue, Pt as de, Q as fe, R as pe, Rt as me, S as he, St as ge, U as _e, Ut as ve, V as ye, Vt as be, W as xe, Wt as Se, Y as Ce, Z as we, _ as Te, _t as h, a as g, at as Ee, bt as De, c as Oe, ct as ke, d as Ae, dt as je, et as Me, f as Ne, ft as Pe, g as Fe, gt as Ie, h as Le, ht as Re, i as _, it as ze, j as Be, jt as Ve, kt as He, l as Ue, lt as We, m as Ge, mt as Ke, n as qe, o as Je, ot as Ye, pt as Xe, q as Ze, r as Qe, rt as $e, s as et, st as tt, t as nt, tt as rt, u as v, ut as it, v as at, vt as y, wt as ot, xt as st, yt as ct, z as lt, zt as ut } from "./html-CnfkCnJt.js";
2
2
  import { $ as dt, A as ft, C as pt, D as mt, Dt as b, E as ht, Et as x, F as gt, Ft as _t, H as vt, I as yt, It as bt, J as xt, K as St, L as S, Lt as C, M as Ct, Mt as wt, N as Tt, Nt as w, O as Et, Ot as T, P as Dt, Pt as Ot, Q as kt, R as E, S as At, St as jt, T as Mt, Tt as D, V as Nt, W as Pt, X as Ft, Y as It, Z as Lt, _ as Rt, b as O, bt as zt, c as Bt, ct as Vt, d as Ht, dt as Ut, et as k, f as Wt, ft as Gt, g as Kt, h as qt, j as Jt, jt as A, k as j, l as Yt, m as Xt, mt as Zt, n as Qt, ot as $t, p as en, pt as tn, q as nn, r as rn, rt as an, s as on, t as sn, tt as cn, u as ln, ut as un, v as dn, vt as M, w as fn, wt as pn, x as mn, xt as hn, y as N } from "./resolver-CuP8arVX.js";
3
3
  //#region ../../node_modules/@tricoteuses/legifrance/dist/legal/index.js
4
4
  function gn(e, t) {
@@ -27,6 +27,8 @@ var l = class extends i {
27
27
  articleNumsLoadedByTextAndDate = /* @__PURE__ */ new Map();
28
28
  articleRowsByContextTextId = /* @__PURE__ */ new Map();
29
29
  directSectionChildrenByParentAndDate = /* @__PURE__ */ new Map();
30
+ directSectionChildrenLoadedRootsAndDate = /* @__PURE__ */ new Set();
31
+ directSectionChildrenRootPromises = /* @__PURE__ */ new Map();
30
32
  globalArticleRowsByNumAndDate = /* @__PURE__ */ new Map();
31
33
  rootTextIdsByTextId = /* @__PURE__ */ new Map();
32
34
  contextTextIdsByTextId = /* @__PURE__ */ new Map();
@@ -43,10 +45,7 @@ var l = class extends i {
43
45
  let r = `${t}\0${e}`, i = this.directSectionChildrenByParentAndDate.get(r);
44
46
  if (i === void 0) {
45
47
  let a = new n("f_legi.getDirectSectionChildren"), o, s = !1;
46
- if (i = await a.time("getDirectSectionChildrenByExactParentPath", () => this.getDirectSectionChildrenByExactParentPath({
47
- date: e,
48
- parentPath: t
49
- })), i.length === 0 && !t.includes(".")) {
48
+ if (await a.time("preloadDirectSectionChildrenByRootPath", () => this.preloadDirectSectionChildrenByRootPath(t, e)), i = this.directSectionChildrenByParentAndDate.get(r) ?? [], i.length === 0 && !t.includes(".")) {
50
49
  o = await a.time("getRootTextIdsFromTextId", () => this.getRootTextIdsFromTextId(t));
51
50
  let n = o;
52
51
  n.length > 1 && (s = !0, i = await a.time("queryRootDirectSectionChildren", () => this.flegiDb`
@@ -522,39 +521,40 @@ var l = class extends i {
522
521
  article_rows.order_id
523
522
  `).toSorted((e, t) => e.id.localeCompare(t.id));
524
523
  }
525
- async getDirectSectionChildrenByExactParentPath({ date: e, parentPath: t }) {
526
- if (!t.includes(".")) return await this.flegiDb`
527
- SELECT
528
- dernier_segment AS id,
529
- chemin::text AS path,
530
- titre AS title,
531
- date_debut::text AS "dateDebut",
532
- date_fin::text AS "dateFin"
533
- FROM scta
534
- WHERE
535
- subltree(chemin, 0, 1) = ${t}::ltree
536
- AND nlevel(chemin) = 2
537
- AND type_objet = 'scta'
538
- AND date_debut <= ${e}::date
539
- AND date_fin >= ${e}::date
540
- ORDER BY tri_hierarchique
541
- `;
542
- let n = `${t}.*{1}`;
543
- return await this.flegiDb`
544
- SELECT
545
- dernier_segment AS id,
546
- chemin::text AS path,
547
- titre AS title,
548
- date_debut::text AS "dateDebut",
549
- date_fin::text AS "dateFin"
550
- FROM scta
551
- WHERE
552
- chemin ~ ${n}::lquery
553
- AND type_objet = 'scta'
554
- AND date_debut <= ${e}::date
555
- AND date_fin >= ${e}::date
556
- ORDER BY tri_hierarchique
557
- `;
524
+ async preloadDirectSectionChildrenByRootPath(e, t) {
525
+ let n = e.split(".", 1)[0], r = `${n}\0${t}`;
526
+ if (this.directSectionChildrenLoadedRootsAndDate.has(r)) {
527
+ this.directSectionChildrenByParentAndDate.set(`${e}\0${t}`, this.directSectionChildrenByParentAndDate.get(`${e}\0${t}`) ?? []);
528
+ return;
529
+ }
530
+ let i = this.directSectionChildrenRootPromises.get(r);
531
+ i === void 0 && (i = (async () => {
532
+ let i = /* @__PURE__ */ new Map(), a = await this.flegiDb`
533
+ SELECT
534
+ subltree(chemin, 0, nlevel(chemin) - 1)::text AS "parentPath",
535
+ dernier_segment AS id,
536
+ chemin::text AS path,
537
+ titre AS title,
538
+ date_debut::text AS "dateDebut",
539
+ date_fin::text AS "dateFin"
540
+ FROM scta
541
+ WHERE
542
+ subltree(chemin, 0, 1) = ${n}::ltree
543
+ AND nlevel(chemin) > 1
544
+ AND type_objet = 'scta'
545
+ AND date_debut <= ${t}::date
546
+ AND date_fin >= ${t}::date
547
+ ORDER BY tri_hierarchique
548
+ `;
549
+ for (let { parentPath: e, ...t } of a) {
550
+ let n = i.get(e);
551
+ n === void 0 ? i.set(e, [t]) : n.push(t);
552
+ }
553
+ for (let [e, n] of i) this.directSectionChildrenByParentAndDate.set(`${e}\0${t}`, n);
554
+ this.directSectionChildrenByParentAndDate.set(`${e}\0${t}`, i.get(e) ?? []), this.directSectionChildrenLoadedRootsAndDate.add(r);
555
+ })().finally(() => {
556
+ this.directSectionChildrenRootPromises.delete(r);
557
+ }), this.directSectionChildrenRootPromises.set(r, i)), await i;
558
558
  }
559
559
  async getTextIdFromSegmentIdUsingContextHeuristic(e) {
560
560
  if (e.startsWith("LEGIARTI")) return (await this.flegiDb`
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as e, D as t, E as n, I as r, K as i, Mt as a, Nt as o, O as s, St as c, T as l, Tt as u, X as d, Y as f, b as p, bt as m, et as h, f as g, g as _, ht as v, k as y, l as b, n as x, nt as S, o as ee, p as C, s as te, t as ne, w as re, x as ie, xt as w, y as ae, yt as oe } from "./html-D6-bRvBF.js";
1
+ import { C as e, D as t, E as n, I as r, K as i, Mt as a, Nt as o, O as s, St as c, T as l, Tt as u, X as d, Y as f, b as p, bt as m, et as h, f as g, g as _, ht as v, k as y, l as b, n as x, nt as S, o as ee, p as C, s as te, t as ne, w as re, x as ie, xt as w, y as ae, yt as oe } from "./html-CnfkCnJt.js";
2
2
  import { Dt as T, Et as E, F as se, N as ce, Nt as D, O as le, Tt as ue, ct as de, et as fe, ht as pe, jt as O, k as me, n as he, o as ge, r as _e, t as ve, vt as k } from "./resolver-CuP8arVX.js";
3
3
  import * as ye from "node:crypto";
4
4
  import { createHash as be } from "node:crypto";
@@ -9,6 +9,8 @@ export declare class FlegiResolver extends LegiResolver {
9
9
  private readonly articleNumsLoadedByTextAndDate;
10
10
  private readonly articleRowsByContextTextId;
11
11
  private readonly directSectionChildrenByParentAndDate;
12
+ private readonly directSectionChildrenLoadedRootsAndDate;
13
+ private readonly directSectionChildrenRootPromises;
12
14
  private readonly globalArticleRowsByNumAndDate;
13
15
  private readonly rootTextIdsByTextId;
14
16
  private readonly contextTextIdsByTextId;
@@ -46,7 +48,7 @@ export declare class FlegiResolver extends LegiResolver {
46
48
  private getActiveArticleRowsForContextTextIds;
47
49
  private getActiveArticleRowsForContextTextIdsWithRoots;
48
50
  private queryActiveArticleRowsForContextTextIds;
49
- private getDirectSectionChildrenByExactParentPath;
51
+ private preloadDirectSectionChildrenByRootPath;
50
52
  private getTextIdFromSegmentIdUsingContextHeuristic;
51
53
  private getTextIdFromSegmentIdUsingSctaHeuristic;
52
54
  private getContextTextIdsFromTextId;
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.14.13",
4
+ "version": "0.14.14",
5
5
  "keywords": [
6
6
  "Assemblée nationale",
7
7
  "France",