@tricoteuses/tisseuse 0.14.12 → 0.14.13
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 +34 -5
- package/dist/{html-Bos7PYtS.js → html-D6-bRvBF.js} +5384 -5056
- package/dist/index.js +116 -116
- package/dist/{resolver-D5TCkLkD.js → resolver-CuP8arVX.js} +189 -131
- package/dist/server-f-legi.js +225 -105
- package/dist/server.js +883 -734
- package/dist/src/lib/extractors/action_directives.d.ts +33 -1
- package/dist/src/lib/extractors/links.d.ts +41 -1
- package/dist/src/lib/extractors/references.d.ts +12 -3
- package/dist/src/lib/f_legi/resolver.d.ts +4 -0
- package/dist/src/lib/legi/text_titles_infos.d.ts +3 -0
- package/dist/src/lib/text_parsers/parsers.d.ts +20 -1
- package/package.json +1 -1
package/dist/server-f-legi.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as e, i as t, o as n, r, t as i } from "./resolver-CuP8arVX.js";
|
|
2
2
|
//#region src/lib/f_legi/resolver.ts
|
|
3
|
-
var
|
|
3
|
+
var a = [
|
|
4
4
|
"article_location_diffs",
|
|
5
5
|
"article_num_candidate_stats",
|
|
6
6
|
"article_num_candidates",
|
|
@@ -9,18 +9,19 @@ var r = [
|
|
|
9
9
|
"legiarti",
|
|
10
10
|
"legitext",
|
|
11
11
|
"scta",
|
|
12
|
-
"text_titles_infos"
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
"text_titles_infos",
|
|
13
|
+
"text_titles_infos_parser_cache"
|
|
14
|
+
], o, s;
|
|
15
|
+
async function c(e) {
|
|
15
16
|
let t = await e`
|
|
16
17
|
SELECT required.name
|
|
17
|
-
FROM unnest(${e.array([...
|
|
18
|
+
FROM unnest(${e.array([...a])}::text[]) AS required(name)
|
|
18
19
|
WHERE to_regclass(required.name) IS NULL
|
|
19
20
|
ORDER BY required.name
|
|
20
21
|
`;
|
|
21
22
|
if (t.length > 0) throw Error(`The f_legi database is missing required relations: ${t.map(({ name: e }) => e).join(", ")}`);
|
|
22
23
|
}
|
|
23
|
-
var
|
|
24
|
+
var l = class extends i {
|
|
24
25
|
flegiDb;
|
|
25
26
|
articleRowsByNumByTextAndDate = /* @__PURE__ */ new Map();
|
|
26
27
|
articleNumsLoadedByTextAndDate = /* @__PURE__ */ new Map();
|
|
@@ -39,123 +40,222 @@ var o = class extends n {
|
|
|
39
40
|
return t === void 0 ? [] : (await this.getActiveArticleRowsByNum(n, e, t)).get(t) ?? [];
|
|
40
41
|
}
|
|
41
42
|
async getDirectSectionChildren({ date: e, parentPath: t }) {
|
|
42
|
-
let
|
|
43
|
-
if (
|
|
44
|
-
|
|
43
|
+
let r = `${t}\0${e}`, i = this.directSectionChildrenByParentAndDate.get(r);
|
|
44
|
+
if (i === void 0) {
|
|
45
|
+
let a = new n("f_legi.getDirectSectionChildren"), o, s = !1;
|
|
46
|
+
if (i = await a.time("getDirectSectionChildrenByExactParentPath", () => this.getDirectSectionChildrenByExactParentPath({
|
|
45
47
|
date: e,
|
|
46
48
|
parentPath: t
|
|
47
|
-
}),
|
|
48
|
-
|
|
49
|
-
n
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
})), i.length === 0 && !t.includes(".")) {
|
|
50
|
+
o = await a.time("getRootTextIdsFromTextId", () => this.getRootTextIdsFromTextId(t));
|
|
51
|
+
let n = o;
|
|
52
|
+
n.length > 1 && (s = !0, i = await a.time("queryRootDirectSectionChildren", () => this.flegiDb`
|
|
53
|
+
SELECT
|
|
54
|
+
dernier_segment AS id,
|
|
55
|
+
chemin::text AS path,
|
|
56
|
+
titre AS title,
|
|
57
|
+
date_debut::text AS "dateDebut",
|
|
58
|
+
date_fin::text AS "dateFin"
|
|
59
|
+
FROM scta
|
|
60
|
+
WHERE
|
|
61
|
+
subltree(chemin, 0, 1) = ANY(${this.flegiDb.array(n)}::ltree[])
|
|
62
|
+
AND nlevel(chemin) = 2
|
|
63
|
+
AND type_objet = 'scta'
|
|
64
|
+
AND date_debut <= ${e}::date
|
|
65
|
+
AND date_fin >= ${e}::date
|
|
66
|
+
ORDER BY tri_hierarchique
|
|
67
|
+
`, { count: o.length }));
|
|
65
68
|
}
|
|
66
|
-
|
|
69
|
+
a.log({
|
|
70
|
+
exactResultCount: o === void 0 ? i.length : 0,
|
|
71
|
+
fallbackResultCount: s ? i.length : void 0,
|
|
72
|
+
fallbackRootTextIdCount: o?.length,
|
|
73
|
+
parentPath: t,
|
|
74
|
+
resultCount: i.length,
|
|
75
|
+
usedFallbackQuery: s
|
|
76
|
+
}), this.directSectionChildrenByParentAndDate.set(r, i);
|
|
67
77
|
}
|
|
68
|
-
return
|
|
78
|
+
return i;
|
|
69
79
|
}
|
|
70
80
|
async getTextIdFromSegmentId(e) {
|
|
71
81
|
let t = this.textIdBySegmentId.get(e);
|
|
72
82
|
return t === void 0 && (t = await this.getTextIdFromSegmentIdUsingContextHeuristic(e) ?? await this.getTextIdFromSegmentIdUsingSctaHeuristic(e) ?? null, this.textIdBySegmentId.set(e, t)), t ?? void 0;
|
|
73
83
|
}
|
|
74
|
-
async preloadTextTitlesInfos(
|
|
75
|
-
let
|
|
76
|
-
|
|
77
|
-
...
|
|
78
|
-
phase:
|
|
84
|
+
async preloadTextTitlesInfos(e = {}) {
|
|
85
|
+
let t = (t, n = {}) => {
|
|
86
|
+
e.onProgress?.({
|
|
87
|
+
...n,
|
|
88
|
+
phase: t,
|
|
79
89
|
resolver: "f_legi"
|
|
80
90
|
});
|
|
81
|
-
};
|
|
82
|
-
if (this.
|
|
83
|
-
|
|
91
|
+
}, r = new n("f_legi.preloadTextTitlesInfos");
|
|
92
|
+
if (this.schemaValidationPromise ??= c(this.flegiDb).catch((e) => {
|
|
93
|
+
throw this.schemaValidationPromise = void 0, e;
|
|
94
|
+
}), await this.schemaValidationPromise, this.textTitlesInfosLoaded) {
|
|
95
|
+
let e = await this.getTextTitlesInfosParserCacheMeta(r);
|
|
96
|
+
if (e !== void 0 && e.formatVersion === 1 && e.generatedAt === o) {
|
|
97
|
+
t("already-loaded");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this.textTitlesInfosLoaded = !1;
|
|
101
|
+
}
|
|
102
|
+
s === void 0 ? s = (async () => await this.loadOrBuildTextTitlesInfosParserCache({
|
|
103
|
+
progress: t,
|
|
104
|
+
timings: r
|
|
105
|
+
}))().catch((e) => {
|
|
106
|
+
throw s = void 0, e;
|
|
107
|
+
}) : t("waiting-for-shared-preload"), o = await s, s = void 0, t("setTextTitlesInfos:done"), r.log(), this.textTitlesInfosLoaded = !0;
|
|
108
|
+
}
|
|
109
|
+
async buildAndCacheTextTitlesInfos({ progress: n, sql: i, timings: a }) {
|
|
110
|
+
await a.time("lockTextTitlesInfos", () => i`SELECT lock_text_titles_infos_for_parser_cache()`), n("queryTextTitlesInfos:start");
|
|
111
|
+
let o = await a.time("queryTextTitlesInfos", () => i`
|
|
112
|
+
SELECT
|
|
113
|
+
cid,
|
|
114
|
+
date_texte::text AS "dateTexte",
|
|
115
|
+
legi_id::text AS id,
|
|
116
|
+
nature,
|
|
117
|
+
num,
|
|
118
|
+
title
|
|
119
|
+
FROM text_titles_infos
|
|
120
|
+
ORDER BY legi_id
|
|
121
|
+
`);
|
|
122
|
+
n("queryTextTitlesInfos:done", { count: o.length }), n("buildTextTitlesInfos:start", { count: o.length });
|
|
123
|
+
let s = performance.now(), c = await r(o, { onProgress: ({ count: e, phase: t }) => n(`buildTextTitlesInfos:${t}`, { count: e }) });
|
|
124
|
+
a.add({
|
|
125
|
+
count: o.length,
|
|
126
|
+
durationMs: Math.round((performance.now() - s) * 10) / 10,
|
|
127
|
+
phase: "buildTextTitlesInfos"
|
|
128
|
+
}), n("buildTextTitlesInfos:done"), n("writeTextTitlesInfosParserCache:start", { count: o.length });
|
|
129
|
+
let [l] = await a.time("writeTextTitlesInfosParserCache", () => i`
|
|
130
|
+
INSERT INTO text_titles_infos_parser_cache (
|
|
131
|
+
key,
|
|
132
|
+
format_version,
|
|
133
|
+
source_row_count,
|
|
134
|
+
generated_at,
|
|
135
|
+
data
|
|
136
|
+
) VALUES (
|
|
137
|
+
${e},
|
|
138
|
+
${1},
|
|
139
|
+
${o.length},
|
|
140
|
+
now(),
|
|
141
|
+
${this.flegiDb.json(c)}
|
|
142
|
+
)
|
|
143
|
+
ON CONFLICT (key)
|
|
144
|
+
DO UPDATE SET
|
|
145
|
+
format_version = EXCLUDED.format_version,
|
|
146
|
+
source_row_count = EXCLUDED.source_row_count,
|
|
147
|
+
generated_at = EXCLUDED.generated_at,
|
|
148
|
+
data = EXCLUDED.data
|
|
149
|
+
RETURNING generated_at::text AS "generatedAt"
|
|
150
|
+
`);
|
|
151
|
+
return n("writeTextTitlesInfosParserCache:done", { count: o.length }), t(c), l.generatedAt;
|
|
152
|
+
}
|
|
153
|
+
async getTextTitlesInfosParserCacheMeta(t) {
|
|
154
|
+
let [n] = await t.time("queryTextTitlesInfosParserCacheMeta", () => this.flegiDb`
|
|
155
|
+
SELECT
|
|
156
|
+
format_version AS "formatVersion",
|
|
157
|
+
generated_at::text AS "generatedAt",
|
|
158
|
+
source_row_count AS "sourceRowCount"
|
|
159
|
+
FROM text_titles_infos_parser_cache
|
|
160
|
+
WHERE key = ${e}
|
|
161
|
+
`);
|
|
162
|
+
return n;
|
|
163
|
+
}
|
|
164
|
+
async loadTextTitlesInfosParserCache({ progress: n, sql: r, timings: i }) {
|
|
165
|
+
let a = r ?? this.flegiDb;
|
|
166
|
+
n("queryTextTitlesInfosParserCache:start");
|
|
167
|
+
let [o] = await i.time("queryTextTitlesInfosParserCache", () => a`
|
|
168
|
+
SELECT
|
|
169
|
+
data,
|
|
170
|
+
format_version AS "formatVersion",
|
|
171
|
+
generated_at::text AS "generatedAt",
|
|
172
|
+
source_row_count AS "sourceRowCount"
|
|
173
|
+
FROM text_titles_infos_parser_cache
|
|
174
|
+
WHERE key = ${e}
|
|
175
|
+
`);
|
|
176
|
+
if (o === void 0) {
|
|
177
|
+
n("queryTextTitlesInfosParserCache:miss");
|
|
84
178
|
return;
|
|
85
179
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
180
|
+
if (o.formatVersion !== 1) {
|
|
181
|
+
n("queryTextTitlesInfosParserCache:format-mismatch");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
n("queryTextTitlesInfosParserCache:done", { count: o.sourceRowCount });
|
|
185
|
+
let s = performance.now();
|
|
186
|
+
return t(o.data), i.add({
|
|
187
|
+
count: o.sourceRowCount,
|
|
188
|
+
durationMs: Math.round((performance.now() - s) * 10) / 10,
|
|
189
|
+
phase: "installTextTitlesInfosParserCache"
|
|
190
|
+
}), o.generatedAt;
|
|
191
|
+
}
|
|
192
|
+
async loadOrBuildTextTitlesInfosParserCache({ progress: e, timings: t }) {
|
|
193
|
+
let n = await this.loadTextTitlesInfosParserCache({
|
|
194
|
+
progress: e,
|
|
195
|
+
timings: t
|
|
196
|
+
});
|
|
197
|
+
return n === void 0 ? await this.flegiDb.begin(async (n) => {
|
|
198
|
+
await t.time("waitTextTitlesInfosParserCacheLock", () => n`SELECT pg_advisory_xact_lock(hashtext('text_titles_infos_parser_cache'))`);
|
|
199
|
+
let r = await this.loadTextTitlesInfosParserCache({
|
|
200
|
+
progress: e,
|
|
201
|
+
sql: n,
|
|
202
|
+
timings: t
|
|
203
|
+
});
|
|
204
|
+
return r === void 0 ? await this.buildAndCacheTextTitlesInfos({
|
|
205
|
+
progress: e,
|
|
206
|
+
sql: n,
|
|
207
|
+
timings: t
|
|
208
|
+
}) : r;
|
|
209
|
+
}) : n;
|
|
111
210
|
}
|
|
112
211
|
async getUniqueActiveArticlesByNum({ date: e, num: t }) {
|
|
113
212
|
if (t === void 0) return [];
|
|
114
213
|
let n = `${t}\0${e}`, r = this.globalArticleRowsByNumAndDate.get(n);
|
|
115
214
|
return r === void 0 && (r = await this.queryUniqueActiveArticlesByNumsUsingContextHeuristic([t]), this.globalArticleRowsByNumAndDate.set(n, r)), r;
|
|
116
215
|
}
|
|
117
|
-
async preloadUniqueActiveArticlesByNums({ date:
|
|
118
|
-
let r = [];
|
|
119
|
-
for (let
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
|
|
216
|
+
async preloadUniqueActiveArticlesByNums({ date: e, nums: t }) {
|
|
217
|
+
let r = [], i = /* @__PURE__ */ new Set();
|
|
218
|
+
for (let n of t) {
|
|
219
|
+
if (n === void 0 || i.has(n)) continue;
|
|
220
|
+
i.add(n);
|
|
221
|
+
let t = `${n}\0${e}`;
|
|
222
|
+
this.globalArticleRowsByNumAndDate.has(t) || r.push(n);
|
|
123
223
|
}
|
|
124
224
|
if (r.length === 0) return;
|
|
125
|
-
let
|
|
126
|
-
for (let e of r)
|
|
127
|
-
let
|
|
128
|
-
for (let e of
|
|
225
|
+
let a = new n("f_legi.preloadUniqueActiveArticlesByNums"), o = await a.time("queryGloballyUniqueArticleRowsByNums", () => this.queryGloballyUniqueArticleRowsByNums(r), { count: r.length }), s = new Set(o.map(({ num: e }) => e).filter((e) => e !== null)), c = r.filter((e) => !s.has(e)), l = await a.time("queryUniqueActiveArticlesByNumsUsingContextHeuristic", () => this.queryUniqueActiveArticlesByNumsUsingContextHeuristic(c), { count: c.length }), u = [...o, ...l].toSorted((e, t) => e.id < t.id ? -1 : +(e.id > t.id)), d = /* @__PURE__ */ new Map();
|
|
226
|
+
for (let e of r) d.set(e, []);
|
|
227
|
+
let f = /* @__PURE__ */ new Map();
|
|
228
|
+
for (let e of u) {
|
|
129
229
|
if (e.num === null) continue;
|
|
130
|
-
let t =
|
|
131
|
-
|
|
230
|
+
let t = f.get(e.num) ?? 0;
|
|
231
|
+
f.set(e.num, t + 1), !(t >= 100) && d.get(e.num)?.push(e);
|
|
132
232
|
}
|
|
133
|
-
for (let [
|
|
134
|
-
|
|
135
|
-
articleRowCount:
|
|
136
|
-
globallyUniqueArticleRowCount:
|
|
137
|
-
heuristicArticleRowCount:
|
|
138
|
-
heuristicNumCount:
|
|
233
|
+
for (let [t, n] of d) this.globalArticleRowsByNumAndDate.set(`${t}\0${e}`, n);
|
|
234
|
+
a.log({
|
|
235
|
+
articleRowCount: u.length,
|
|
236
|
+
globallyUniqueArticleRowCount: o.length,
|
|
237
|
+
heuristicArticleRowCount: l.length,
|
|
238
|
+
heuristicNumCount: c.length,
|
|
139
239
|
numCount: r.length
|
|
140
240
|
});
|
|
141
241
|
}
|
|
142
|
-
async preloadActiveArticlesByTextIds({ date:
|
|
143
|
-
let i =
|
|
144
|
-
if (
|
|
145
|
-
let n = `${
|
|
242
|
+
async preloadActiveArticlesByTextIds({ date: e, nums: t, textIds: r }) {
|
|
243
|
+
let i = t === void 0 ? void 0 : [...new Set(t)].filter(Boolean), a = [...new Set(r)].filter((t) => {
|
|
244
|
+
if (t === void 0) return !1;
|
|
245
|
+
let n = `${t}\0${e}`;
|
|
146
246
|
if (this.articleRowsByNumByTextAndDate.get(n) === void 0) return !0;
|
|
147
247
|
let r = this.articleNumsLoadedByTextAndDate.get(n);
|
|
148
248
|
return r === "all" ? !1 : i === void 0 ? !0 : i.some((e) => !r?.has(e));
|
|
149
249
|
});
|
|
150
250
|
if (a.length === 0) return;
|
|
151
|
-
let o = new
|
|
251
|
+
let o = new n("f_legi.preloadActiveArticlesByTextIds"), s = await o.time("getContextTextIdsByTextIds", () => this.getContextTextIdsByTextIds(a)), c = [...new Set([...s.values()].flat())], l = await o.time("getActiveArticleRowsForContextTextIds", () => i === void 0 ? this.getActiveArticleRowsForContextTextIdsWithRoots(c) : this.queryActiveArticleRowsForContextTextIds(c, i), { count: c.length }), u = /* @__PURE__ */ new Map(), d = (e, t) => {
|
|
152
252
|
if (e === null) return;
|
|
153
253
|
let n = u.get(e);
|
|
154
254
|
n === void 0 ? u.set(e, [t]) : n.push(t);
|
|
155
255
|
};
|
|
156
256
|
for (let e of l) d(e.rootTextId, e), d(e.textId, e);
|
|
157
|
-
for (let
|
|
158
|
-
let n = `${
|
|
257
|
+
for (let t of a) {
|
|
258
|
+
let n = `${t}\0${e}`, r = s.get(t) ?? [t], a = /* @__PURE__ */ new Map();
|
|
159
259
|
for (let e of r) for (let t of u.get(e) ?? []) a.set(`${t.id}\0${t.textId}`, {
|
|
160
260
|
id: t.id,
|
|
161
261
|
textId: t.textId,
|
|
@@ -163,11 +263,14 @@ var o = class extends n {
|
|
|
163
263
|
dateDebut: t.dateDebut,
|
|
164
264
|
dateFin: t.dateFin
|
|
165
265
|
});
|
|
166
|
-
let o = this.articleRowsByNumByTextAndDate.get(n) ?? /* @__PURE__ */ new Map();
|
|
266
|
+
let o = this.articleRowsByNumByTextAndDate.get(n) ?? /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
|
267
|
+
for (let [e, t] of o) c.set(e, new Set(t.map((e) => `${e.id}\0${e.textId}`)));
|
|
167
268
|
for (let e of a.values()) {
|
|
168
269
|
if (e.num === null) continue;
|
|
169
|
-
let t =
|
|
170
|
-
|
|
270
|
+
let t = `${e.id}\0${e.textId}`, n = c.get(e.num);
|
|
271
|
+
n === void 0 && (n = /* @__PURE__ */ new Set(), c.set(e.num, n));
|
|
272
|
+
let r = o.get(e.num);
|
|
273
|
+
r === void 0 ? (o.set(e.num, [e]), n.add(t)) : n.has(t) || (r.push(e), n.add(t));
|
|
171
274
|
}
|
|
172
275
|
if (this.articleRowsByNumByTextAndDate.set(n, o), i === void 0) this.articleNumsLoadedByTextAndDate.set(n, "all");
|
|
173
276
|
else {
|
|
@@ -420,6 +523,23 @@ var o = class extends n {
|
|
|
420
523
|
`).toSorted((e, t) => e.id.localeCompare(t.id));
|
|
421
524
|
}
|
|
422
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}`;
|
|
423
543
|
return await this.flegiDb`
|
|
424
544
|
SELECT
|
|
425
545
|
dernier_segment AS id,
|
|
@@ -429,8 +549,7 @@ var o = class extends n {
|
|
|
429
549
|
date_fin::text AS "dateFin"
|
|
430
550
|
FROM scta
|
|
431
551
|
WHERE
|
|
432
|
-
chemin
|
|
433
|
-
AND nlevel(chemin) = nlevel(${t}::ltree) + 1
|
|
552
|
+
chemin ~ ${n}::lquery
|
|
434
553
|
AND type_objet = 'scta'
|
|
435
554
|
AND date_debut <= ${e}::date
|
|
436
555
|
AND date_fin >= ${e}::date
|
|
@@ -476,14 +595,14 @@ var o = class extends n {
|
|
|
476
595
|
return t === void 0 && (t = (await this.getContextTextIdsByTextIds([e])).get(e) ?? [e], this.contextTextIdsByTextId.set(e, t)), t;
|
|
477
596
|
}
|
|
478
597
|
async getContextTextIdsByTextIds(e) {
|
|
479
|
-
let t = /* @__PURE__ */ new Map(), n = e.filter((e) => !this.contextTextIdsByTextId.has(e));
|
|
598
|
+
let t = /* @__PURE__ */ new Map(), n = e.filter((e) => !this.contextTextIdsByTextId.has(e)), r = new Set(n);
|
|
480
599
|
for (let n of e) {
|
|
481
600
|
let e = this.contextTextIdsByTextId.get(n);
|
|
482
601
|
e !== void 0 && t.set(n, e);
|
|
483
602
|
}
|
|
484
603
|
if (n.length === 0) return t;
|
|
485
604
|
for (let e of n) t.set(e, [e]);
|
|
486
|
-
let
|
|
605
|
+
let i = await this.flegiDb`
|
|
487
606
|
SELECT legi_id AS "textId", cid AS "contextTextId"
|
|
488
607
|
FROM legitext
|
|
489
608
|
WHERE legi_id IN ${this.flegiDb(n)} OR cid IN ${this.flegiDb(n)}
|
|
@@ -496,10 +615,10 @@ var o = class extends n {
|
|
|
496
615
|
|
|
497
616
|
ORDER BY "textId", "contextTextId"
|
|
498
617
|
`;
|
|
499
|
-
for (let { contextTextId: e, textId:
|
|
500
|
-
if (!
|
|
501
|
-
let
|
|
502
|
-
|
|
618
|
+
for (let { contextTextId: e, textId: n } of i) for (let i of [n, e]) {
|
|
619
|
+
if (!r.has(i)) continue;
|
|
620
|
+
let n = t.get(i) ?? [i];
|
|
621
|
+
n.includes(e) || n.push(e), t.set(i, n);
|
|
503
622
|
}
|
|
504
623
|
for (let e of n) this.contextTextIdsByTextId.set(e, t.get(e) ?? [e]);
|
|
505
624
|
return t;
|
|
@@ -509,14 +628,14 @@ var o = class extends n {
|
|
|
509
628
|
return t === void 0 && (t = (await this.getRootTextIdsByTextIds([e])).get(e) ?? [e], this.rootTextIdsByTextId.set(e, t)), t;
|
|
510
629
|
}
|
|
511
630
|
async getRootTextIdsByTextIds(e) {
|
|
512
|
-
let t = /* @__PURE__ */ new Map(), n = e.filter((e) => !this.rootTextIdsByTextId.has(e));
|
|
631
|
+
let t = /* @__PURE__ */ new Map(), n = e.filter((e) => !this.rootTextIdsByTextId.has(e)), r = new Set(n);
|
|
513
632
|
for (let n of e) {
|
|
514
633
|
let e = this.rootTextIdsByTextId.get(n);
|
|
515
634
|
e !== void 0 && t.set(n, e);
|
|
516
635
|
}
|
|
517
636
|
if (n.length === 0) return t;
|
|
518
637
|
for (let e of n) t.set(e, [e]);
|
|
519
|
-
let
|
|
638
|
+
let i = await this.flegiDb`
|
|
520
639
|
SELECT cid AS "textId", legi_id AS "rootTextId"
|
|
521
640
|
FROM legitext
|
|
522
641
|
WHERE cid IN ${this.flegiDb(n)}
|
|
@@ -529,13 +648,14 @@ var o = class extends n {
|
|
|
529
648
|
|
|
530
649
|
ORDER BY "textId", "rootTextId"
|
|
531
650
|
`;
|
|
532
|
-
for (let { textId: e, rootTextId: n } of
|
|
533
|
-
|
|
534
|
-
|
|
651
|
+
for (let { textId: e, rootTextId: n } of i) {
|
|
652
|
+
if (!r.has(e)) continue;
|
|
653
|
+
let i = t.get(e) ?? [e];
|
|
654
|
+
i.includes(n) || i.push(n), t.set(e, i);
|
|
535
655
|
}
|
|
536
656
|
for (let e of n) this.rootTextIdsByTextId.set(e, t.get(e) ?? [e]);
|
|
537
657
|
return t;
|
|
538
658
|
}
|
|
539
659
|
};
|
|
540
660
|
//#endregion
|
|
541
|
-
export {
|
|
661
|
+
export { l as FlegiResolver, c as checkFlegiResolverDatabase };
|