@thehammer/template-verification 0.2.11 → 0.2.12
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/components/VerifiedField.vue.d.ts +40 -10
- package/dist/lib/discrepancy.d.ts +10 -1
- package/dist/style.css +1 -1
- package/dist/template-verification.js +165 -156
- package/dist/types.d.ts +35 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ref as P, watch as K, defineComponent as U, computed as l, openBlock as
|
|
2
|
-
import { DanxSkeleton as
|
|
3
|
-
const
|
|
1
|
+
import { ref as P, watch as K, defineComponent as U, computed as l, openBlock as u, createElementBlock as g, normalizeClass as y, createElementVNode as p, toDisplayString as w, createCommentVNode as _, createBlock as j, unref as f, Fragment as M, renderSlot as ne, createTextVNode as re, withModifiers as G, createVNode as N, withDirectives as ae, isRef as le, vModelCheckbox as oe } from "vue";
|
|
2
|
+
import { DanxSkeleton as ie, useToast as se, DanxIcon as ue, gearIcon as ce, DanxBadge as de, DanxProgressBar as fe, DanxToastContainer as ve } from "@thehammer/danx-ui";
|
|
3
|
+
const $ = "tv-chrome", q = "template-verification:enabled";
|
|
4
4
|
let O = null;
|
|
5
|
-
function
|
|
5
|
+
function pe(e) {
|
|
6
6
|
var t;
|
|
7
7
|
try {
|
|
8
8
|
return ((t = globalThis.localStorage) == null ? void 0 : t.getItem(e)) ?? null;
|
|
@@ -10,22 +10,22 @@ function ve(e) {
|
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function ge(e, t) {
|
|
14
14
|
var n;
|
|
15
15
|
try {
|
|
16
16
|
(n = globalThis.localStorage) == null || n.setItem(e, t);
|
|
17
17
|
} catch {
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const t =
|
|
20
|
+
function be(e) {
|
|
21
|
+
const t = pe(q);
|
|
22
22
|
return t === null ? e : t === "true";
|
|
23
23
|
}
|
|
24
24
|
function J(e) {
|
|
25
|
-
const t = P(
|
|
25
|
+
const t = P(be((e == null ? void 0 : e.defaultEnabled) ?? !1));
|
|
26
26
|
return K(
|
|
27
27
|
t,
|
|
28
|
-
(n) =>
|
|
28
|
+
(n) => ge(q, n ? "true" : "false")
|
|
29
29
|
), {
|
|
30
30
|
enabled: t,
|
|
31
31
|
data: (e == null ? void 0 : e.data) ?? {},
|
|
@@ -33,14 +33,14 @@ function J(e) {
|
|
|
33
33
|
loading: (e == null ? void 0 : e.loading) ?? !1
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function he() {
|
|
37
37
|
return O || (O = J()), O;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function qe(e) {
|
|
40
40
|
O = J(e);
|
|
41
41
|
}
|
|
42
42
|
function Q() {
|
|
43
|
-
const e =
|
|
43
|
+
const e = he();
|
|
44
44
|
return {
|
|
45
45
|
enabled: e.enabled,
|
|
46
46
|
data: e.data,
|
|
@@ -51,7 +51,7 @@ function Q() {
|
|
|
51
51
|
function W(e) {
|
|
52
52
|
return typeof e != "number" || Number.isNaN(e) ? "unverifiable" : e <= 2 ? "low" : e === 3 ? "medium" : "high";
|
|
53
53
|
}
|
|
54
|
-
const
|
|
54
|
+
const me = {
|
|
55
55
|
high: "bg-green-50 text-green-700 ring-1 ring-inset ring-green-600/20",
|
|
56
56
|
medium: "bg-yellow-50 text-yellow-700 ring-1 ring-inset ring-yellow-600/20",
|
|
57
57
|
low: "bg-red-50 text-red-700 ring-1 ring-inset ring-red-600/20",
|
|
@@ -66,10 +66,10 @@ const be = {
|
|
|
66
66
|
unverifiable: "Unverifiable",
|
|
67
67
|
failed: "Failed"
|
|
68
68
|
}, X = ["override", "extracted", "claim"];
|
|
69
|
-
function he(e) {
|
|
70
|
-
return e ? e.resolved && e.resolved.source && e.resolved.source !== "none" ? e.resolved : we(e.candidates) : { value: null, source: "none" };
|
|
71
|
-
}
|
|
72
69
|
function we(e) {
|
|
70
|
+
return e ? e.resolved && e.resolved.source && e.resolved.source !== "none" ? e.resolved : ye(e.candidates) : { value: null, source: "none" };
|
|
71
|
+
}
|
|
72
|
+
function ye(e) {
|
|
73
73
|
if (e)
|
|
74
74
|
for (const t of X) {
|
|
75
75
|
const n = e[t];
|
|
@@ -78,44 +78,47 @@ function we(e) {
|
|
|
78
78
|
}
|
|
79
79
|
return { value: null, source: "none" };
|
|
80
80
|
}
|
|
81
|
-
function ye(e) {
|
|
82
|
-
return e ? typeof e.discrepancy == "boolean" ? e.discrepancy : xe(e.candidates) : !1;
|
|
83
|
-
}
|
|
84
81
|
function xe(e) {
|
|
82
|
+
return e ? typeof e.discrepancy == "boolean" ? e.discrepancy : _e(e.candidates) : !1;
|
|
83
|
+
}
|
|
84
|
+
function _e(e) {
|
|
85
85
|
if (!e) return !1;
|
|
86
|
-
const t = X.map((n) => e[n]).filter((n) => n != null).map((n) =>
|
|
86
|
+
const t = X.map((n) => e[n]).filter((n) => n != null).map((n) => ke(n.value));
|
|
87
87
|
return t.length < 2 ? !1 : new Set(t).size > 1;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function ke(e) {
|
|
90
90
|
return JSON.stringify(e ?? null);
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function Se(e) {
|
|
93
93
|
return !!(e != null && e.source_discrepancy);
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
function Ie(e) {
|
|
96
|
+
return !!(e != null && e.correction);
|
|
97
|
+
}
|
|
98
|
+
const Ce = "danxbot-template", Te = 1, $e = "data-point-activated";
|
|
99
|
+
function Ae() {
|
|
97
100
|
if (typeof window > "u") return null;
|
|
98
101
|
const e = window.location.ancestorOrigins, t = e && e.length > 0 ? e[0] : null;
|
|
99
102
|
if (t && t !== "null") return t;
|
|
100
103
|
const n = typeof document > "u" ? "" : document.referrer;
|
|
101
104
|
if (!n) return null;
|
|
102
105
|
try {
|
|
103
|
-
const
|
|
104
|
-
return
|
|
106
|
+
const c = new URL(n).origin;
|
|
107
|
+
return c === "null" ? null : c;
|
|
105
108
|
} catch {
|
|
106
109
|
return null;
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
|
-
function
|
|
112
|
+
function Ee(e) {
|
|
110
113
|
if (typeof window > "u") return !1;
|
|
111
114
|
const t = window.parent;
|
|
112
115
|
if (!t || t === window) return !1;
|
|
113
|
-
const n =
|
|
116
|
+
const n = Ae();
|
|
114
117
|
if (!n) return !1;
|
|
115
|
-
const
|
|
116
|
-
source:
|
|
117
|
-
version:
|
|
118
|
-
type:
|
|
118
|
+
const c = {
|
|
119
|
+
source: Ce,
|
|
120
|
+
version: Te,
|
|
121
|
+
type: $e,
|
|
119
122
|
anchor: {
|
|
120
123
|
object_ids: [...e.anchor.object_ids],
|
|
121
124
|
field: e.anchor.field,
|
|
@@ -125,9 +128,9 @@ function Ae(e) {
|
|
|
125
128
|
label: e.label ?? null,
|
|
126
129
|
value: e.value ?? null
|
|
127
130
|
};
|
|
128
|
-
return t.postMessage(
|
|
131
|
+
return t.postMessage(c, n), !0;
|
|
129
132
|
}
|
|
130
|
-
const
|
|
133
|
+
const Re = /* @__PURE__ */ new Set(["name", "type"]);
|
|
131
134
|
function Z(e, t = "") {
|
|
132
135
|
const n = [];
|
|
133
136
|
return B(e, t, n), n;
|
|
@@ -138,17 +141,17 @@ function B(e, t, n) {
|
|
|
138
141
|
return;
|
|
139
142
|
}
|
|
140
143
|
if (!H(e)) return;
|
|
141
|
-
const
|
|
144
|
+
const b = e.__meta ?? {};
|
|
142
145
|
for (const [r, i] of Object.entries(e)) {
|
|
143
146
|
if (r === "__meta") continue;
|
|
144
|
-
const
|
|
147
|
+
const m = t ? `${t}.${r}` : r;
|
|
145
148
|
if (Array.isArray(i) || H(i)) {
|
|
146
|
-
B(i,
|
|
149
|
+
B(i, m, n);
|
|
147
150
|
continue;
|
|
148
151
|
}
|
|
149
|
-
const v =
|
|
150
|
-
!v &&
|
|
151
|
-
path:
|
|
152
|
+
const v = b[r];
|
|
153
|
+
!v && Re.has(r) || n.push({
|
|
154
|
+
path: m,
|
|
152
155
|
label: r,
|
|
153
156
|
meta: v ?? null,
|
|
154
157
|
value: i,
|
|
@@ -165,32 +168,32 @@ function ee(e) {
|
|
|
165
168
|
const t = (n = e.candidates.extracted) == null ? void 0 : n.confidence;
|
|
166
169
|
return e.discrepancy || t == null || t <= 2;
|
|
167
170
|
}
|
|
168
|
-
function
|
|
171
|
+
function Oe(e) {
|
|
169
172
|
const t = Z(e).filter(
|
|
170
173
|
(r) => r.meta !== null
|
|
171
174
|
), n = t.length;
|
|
172
|
-
let
|
|
175
|
+
let c = 0, b = 0;
|
|
173
176
|
for (const r of t) {
|
|
174
177
|
if (r.meta.candidates.override) {
|
|
175
|
-
|
|
178
|
+
c++;
|
|
176
179
|
continue;
|
|
177
180
|
}
|
|
178
|
-
ee(r.meta) &&
|
|
181
|
+
ee(r.meta) && b++;
|
|
179
182
|
}
|
|
180
183
|
return {
|
|
181
184
|
total: n,
|
|
182
|
-
verified:
|
|
183
|
-
needsReview:
|
|
184
|
-
percent: n === 0 ? 100 : Math.round(
|
|
185
|
+
verified: c,
|
|
186
|
+
needsReview: b,
|
|
187
|
+
percent: n === 0 ? 100 : Math.round(c / n * 100)
|
|
185
188
|
};
|
|
186
189
|
}
|
|
187
|
-
const
|
|
190
|
+
const Ve = ["data-status", "title"], De = {
|
|
188
191
|
class: "tv-confidence-glyph",
|
|
189
192
|
"aria-hidden": "true"
|
|
190
|
-
},
|
|
193
|
+
}, Le = {
|
|
191
194
|
key: 0,
|
|
192
195
|
class: "tv-confidence-label"
|
|
193
|
-
},
|
|
196
|
+
}, Ne = /* @__PURE__ */ U({
|
|
194
197
|
__name: "ConfidenceIcon",
|
|
195
198
|
props: {
|
|
196
199
|
confidence: {},
|
|
@@ -200,7 +203,7 @@ const Re = ["data-status", "title"], Oe = {
|
|
|
200
203
|
setup(e) {
|
|
201
204
|
const t = e, n = l(
|
|
202
205
|
() => t.status ?? W(t.confidence)
|
|
203
|
-
),
|
|
206
|
+
), c = {
|
|
204
207
|
high: "✔",
|
|
205
208
|
// check
|
|
206
209
|
medium: "⚠",
|
|
@@ -210,21 +213,25 @@ const Re = ["data-status", "title"], Oe = {
|
|
|
210
213
|
unverifiable: "?",
|
|
211
214
|
failed: "⊗"
|
|
212
215
|
// circled x — distinct from low's plain x
|
|
213
|
-
},
|
|
214
|
-
return (
|
|
215
|
-
class:
|
|
216
|
+
}, b = l(() => c[n.value]), r = l(() => me[n.value]), i = l(() => V[n.value]);
|
|
217
|
+
return (m, v) => (u(), g("span", {
|
|
218
|
+
class: y(["tv-confidence-icon inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-semibold leading-none", r.value]),
|
|
216
219
|
"data-status": n.value,
|
|
217
220
|
title: i.value
|
|
218
221
|
}, [
|
|
219
|
-
|
|
220
|
-
e.showLabel ? (
|
|
221
|
-
], 10,
|
|
222
|
+
p("span", De, w(b.value), 1),
|
|
223
|
+
e.showLabel ? (u(), g("span", Le, w(i.value), 1)) : _("", !0)
|
|
224
|
+
], 10, Ve));
|
|
222
225
|
}
|
|
223
|
-
}),
|
|
226
|
+
}), Pe = { class: "tv-mark-slot" }, je = ["aria-label", "title"], Me = {
|
|
224
227
|
key: 1,
|
|
225
228
|
class: "tv-verified-chip inline-flex items-center gap-1 rounded-full bg-green-600 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",
|
|
226
229
|
"data-status": "verified"
|
|
227
|
-
},
|
|
230
|
+
}, Be = {
|
|
231
|
+
key: 3,
|
|
232
|
+
class: "tv-correction-indicator ml-0.5 text-blue-500",
|
|
233
|
+
"aria-hidden": !0
|
|
234
|
+
}, Je = /* @__PURE__ */ U({
|
|
228
235
|
__name: "VerifiedField",
|
|
229
236
|
props: {
|
|
230
237
|
source: {},
|
|
@@ -233,123 +240,125 @@ const Re = ["data-status", "title"], Oe = {
|
|
|
233
240
|
format: { type: Function }
|
|
234
241
|
},
|
|
235
242
|
setup(e) {
|
|
236
|
-
const t = e, n = Q(),
|
|
243
|
+
const t = e, n = Q(), c = l(() => n.enabled.value), b = l(() => n.loading), r = l(() => {
|
|
237
244
|
var a;
|
|
238
245
|
return t.source && t.field ? ((a = t.source.__meta) == null ? void 0 : a[t.field]) ?? null : null;
|
|
239
|
-
}), i = l(() =>
|
|
246
|
+
}), i = l(() => we(r.value)), m = l(() => {
|
|
240
247
|
if (t.original !== void 0 && t.original !== null)
|
|
241
248
|
return t.original;
|
|
242
249
|
if (r.value && i.value.value !== null && i.value.value !== void 0)
|
|
243
250
|
return i.value.value;
|
|
244
251
|
if (t.source && t.field) return t.source[t.field];
|
|
245
252
|
}), v = l(() => {
|
|
246
|
-
const a =
|
|
253
|
+
const a = m.value;
|
|
247
254
|
return a == null ? "" : typeof t.format == "function" ? t.format(a) : String(a);
|
|
248
255
|
}), A = l(() => {
|
|
249
256
|
var s, d;
|
|
250
257
|
const a = (d = (s = r.value) == null ? void 0 : s.candidates) == null ? void 0 : d.extracted;
|
|
251
258
|
return (a == null ? void 0 : a.state) === "failed" ? "failed" : W(a == null ? void 0 : a.confidence);
|
|
252
|
-
}),
|
|
259
|
+
}), h = l(() => xe(r.value)), o = l(() => Se(r.value)), x = l(() => !h.value && Ie(r.value)), k = l(() => {
|
|
253
260
|
var a, s;
|
|
254
261
|
return !!((s = (a = r.value) == null ? void 0 : a.candidates) != null && s.override);
|
|
255
262
|
}), E = l(() => {
|
|
256
263
|
var s;
|
|
257
264
|
const a = (s = r.value) == null ? void 0 : s.candidates;
|
|
258
265
|
return !!(a != null && a.override || a != null && a.extracted || a != null && a.claim);
|
|
259
|
-
}),
|
|
266
|
+
}), I = l(() => c.value), R = l(() => {
|
|
260
267
|
const a = r.value;
|
|
261
|
-
return
|
|
262
|
-
}),
|
|
268
|
+
return I.value && !!a && ee(a);
|
|
269
|
+
}), C = l(() => {
|
|
263
270
|
var a;
|
|
264
271
|
return !!((a = r.value) != null && a.anchor);
|
|
265
272
|
}), T = l(() => {
|
|
266
273
|
var z, F, Y;
|
|
267
|
-
const a = t.field ?? "This value", s =
|
|
268
|
-
if (
|
|
269
|
-
const d = (F = (z = r.value) == null ? void 0 : z.candidates) == null ? void 0 : F.extracted, D = A.value,
|
|
270
|
-
D === "failed" ?
|
|
274
|
+
const a = t.field ?? "This value", s = C.value ? " — open in the review panel" : "";
|
|
275
|
+
if (k.value) return `${a}: verified by a person${s}`;
|
|
276
|
+
const d = (F = (z = r.value) == null ? void 0 : z.candidates) == null ? void 0 : F.extracted, D = A.value, S = [];
|
|
277
|
+
D === "failed" ? S.push(V.failed) : (d == null ? void 0 : d.confidence) != null ? S.push(`${V[D]} (${d.confidence}/5)`) : S.push(V[D]);
|
|
271
278
|
const L = (d == null ? void 0 : d.sources_count) ?? ((Y = d == null ? void 0 : d.sources) == null ? void 0 : Y.length) ?? 0;
|
|
272
|
-
return L > 0 &&
|
|
279
|
+
return L > 0 && S.push(`${L} cited ${L === 1 ? "page" : "pages"}`), h.value ? S.push(o.value ? "source document conflict" : "sources disagree") : x.value && S.push("value corrected"), `${a}: ${S.join(", ")}${s}`;
|
|
273
280
|
});
|
|
274
|
-
function
|
|
281
|
+
function te() {
|
|
275
282
|
var s;
|
|
276
283
|
const a = (s = r.value) == null ? void 0 : s.anchor;
|
|
277
|
-
a &&
|
|
284
|
+
a && Ee({
|
|
278
285
|
anchor: a,
|
|
279
286
|
workflowInputId: n.workflowInputId,
|
|
280
287
|
label: t.field ?? null,
|
|
281
288
|
value: v.value
|
|
282
289
|
});
|
|
283
290
|
}
|
|
284
|
-
return (a, s) => (
|
|
285
|
-
class:
|
|
291
|
+
return (a, s) => (u(), g("span", {
|
|
292
|
+
class: y(["tv-field", R.value ? "tv-needs-review" : ""])
|
|
286
293
|
}, [
|
|
287
|
-
|
|
294
|
+
b.value ? (u(), j(f(ie), {
|
|
288
295
|
key: 0,
|
|
289
296
|
shape: "rounded",
|
|
290
297
|
class: "tv-field-skeleton inline-block h-[1em] w-16 align-middle"
|
|
291
|
-
})) : (
|
|
292
|
-
|
|
293
|
-
class:
|
|
298
|
+
})) : (u(), g(M, { key: 1 }, [
|
|
299
|
+
p("span", {
|
|
300
|
+
class: y([
|
|
294
301
|
"tv-field-value",
|
|
295
|
-
|
|
302
|
+
I.value && !E.value ? "tv-field-unverified border-b border-dotted border-gray-300" : ""
|
|
296
303
|
])
|
|
297
304
|
}, [
|
|
298
|
-
|
|
299
|
-
value:
|
|
305
|
+
ne(a.$slots, "default", {
|
|
306
|
+
value: m.value,
|
|
300
307
|
formatted: v.value
|
|
301
308
|
}, () => [
|
|
302
|
-
|
|
309
|
+
re(w(v.value), 1)
|
|
303
310
|
])
|
|
304
311
|
], 2),
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
type: "button",
|
|
308
|
-
class: x(["tv-overlay", [f(C), S.value ? "cursor-pointer" : "cursor-default"]]),
|
|
309
|
-
"aria-label": T.value,
|
|
310
|
-
title: T.value,
|
|
311
|
-
onClick: s[0] || (s[0] = (d) => S.value ? R() : void 0)
|
|
312
|
-
}, [
|
|
313
|
-
w.value ? (c(), m("span", Ne, "✔")) : (c(), j(De, {
|
|
312
|
+
p("span", Pe, [
|
|
313
|
+
I.value ? (u(), g("button", {
|
|
314
314
|
key: 0,
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
315
|
+
type: "button",
|
|
316
|
+
class: y(["tv-overlay", [f($), C.value ? "cursor-pointer" : "cursor-default"]]),
|
|
317
|
+
"aria-label": T.value,
|
|
318
|
+
title: T.value,
|
|
319
|
+
onClick: s[0] || (s[0] = (d) => C.value ? te() : void 0)
|
|
320
|
+
}, [
|
|
321
|
+
k.value ? (u(), g("span", Me, "✔")) : (u(), j(Ne, {
|
|
322
|
+
key: 0,
|
|
323
|
+
status: A.value
|
|
324
|
+
}, null, 8, ["status"])),
|
|
325
|
+
h.value && !k.value ? (u(), g("span", {
|
|
326
|
+
key: 2,
|
|
327
|
+
class: y(["tv-discrepancy-indicator ml-0.5 text-amber-500", o.value ? "tv-source-discrepancy-indicator" : ""]),
|
|
328
|
+
"aria-hidden": !0
|
|
329
|
+
}, "⚠", 2)) : x.value && !k.value ? (u(), g("span", Be, "✎")) : _("", !0)
|
|
330
|
+
], 10, je)) : _("", !0)
|
|
331
|
+
])
|
|
323
332
|
], 64))
|
|
324
333
|
], 2));
|
|
325
334
|
}
|
|
326
|
-
}),
|
|
335
|
+
}), Ue = { class: "tv-enable-toggle flex items-center justify-between text-sm font-medium text-gray-700" }, ze = { class: "tv-progress-block" }, Fe = { class: "mb-1 flex items-baseline justify-between" }, Ye = { class: "tv-progress-count text-xs font-semibold text-gray-600" }, Ge = {
|
|
327
336
|
key: 0,
|
|
328
337
|
class: "tv-attempts-recorded mt-1 text-[11px] text-gray-400"
|
|
329
|
-
},
|
|
338
|
+
}, Qe = /* @__PURE__ */ U({
|
|
330
339
|
__name: "VerificationChrome",
|
|
331
340
|
setup(e) {
|
|
332
|
-
const t = Q(), { enabled: n } = t,
|
|
341
|
+
const t = Q(), { enabled: n } = t, c = se(), b = P(!1), r = l(() => Oe(t.data)), i = l(
|
|
333
342
|
() => Z(t.data).reduce(
|
|
334
|
-
(
|
|
335
|
-
var
|
|
336
|
-
return
|
|
343
|
+
(h, o) => {
|
|
344
|
+
var x, k, E, I, R, C, T;
|
|
345
|
+
return h + (((E = (k = (x = o.meta) == null ? void 0 : x.candidates) == null ? void 0 : k.extracted) == null ? void 0 : E.history_count) ?? ((T = (C = (R = (I = o.meta) == null ? void 0 : I.candidates) == null ? void 0 : R.extracted) == null ? void 0 : C.history) == null ? void 0 : T.length) ?? 0);
|
|
337
346
|
},
|
|
338
347
|
0
|
|
339
348
|
)
|
|
340
|
-
),
|
|
349
|
+
), m = P(!1);
|
|
341
350
|
K(
|
|
342
351
|
() => r.value.percent,
|
|
343
|
-
(
|
|
344
|
-
|
|
352
|
+
(h) => {
|
|
353
|
+
h === 100 && r.value.total > 0 && !m.value && (m.value = !0, c.success("All data points verified 🎯"));
|
|
345
354
|
}
|
|
346
355
|
);
|
|
347
356
|
let v = 0;
|
|
348
357
|
function A() {
|
|
349
|
-
const
|
|
350
|
-
if (!
|
|
351
|
-
v = v %
|
|
352
|
-
const o =
|
|
358
|
+
const h = document.querySelectorAll(".tv-needs-review");
|
|
359
|
+
if (!h.length) return;
|
|
360
|
+
v = v % h.length;
|
|
361
|
+
const o = h[v];
|
|
353
362
|
v++, o.scrollIntoView({ behavior: "smooth", block: "center" }), o.animate(
|
|
354
363
|
[
|
|
355
364
|
{ boxShadow: "0 0 0 0 rgba(245, 158, 11, 0.8)" },
|
|
@@ -358,45 +367,45 @@ const Re = ["data-status", "title"], Oe = {
|
|
|
358
367
|
{ duration: 900, iterations: 2 }
|
|
359
368
|
);
|
|
360
369
|
}
|
|
361
|
-
return (
|
|
362
|
-
|
|
370
|
+
return (h, o) => (u(), g(M, null, [
|
|
371
|
+
p("button", {
|
|
363
372
|
type: "button",
|
|
364
|
-
class:
|
|
373
|
+
class: y(["tv-settings-button fixed bottom-4 right-4 z-50 flex h-11 w-11 items-center justify-center rounded-full bg-gray-900 text-white shadow-lg transition-transform hover:scale-105", f($)]),
|
|
365
374
|
title: "Verification",
|
|
366
|
-
onClick: o[0] || (o[0] = G((
|
|
375
|
+
onClick: o[0] || (o[0] = G((x) => b.value = !b.value, ["stop"]))
|
|
367
376
|
}, [
|
|
368
|
-
N(f(
|
|
369
|
-
icon: f(
|
|
377
|
+
N(f(ue), {
|
|
378
|
+
icon: f(ce),
|
|
370
379
|
class: "h-5 w-5"
|
|
371
380
|
}, null, 8, ["icon"]),
|
|
372
|
-
f(n) && r.value.needsReview > 0 ? (
|
|
381
|
+
f(n) && r.value.needsReview > 0 ? (u(), j(f(de), {
|
|
373
382
|
key: 0,
|
|
374
383
|
value: r.value.needsReview,
|
|
375
384
|
variant: "warning",
|
|
376
385
|
class: "tv-needs-review-badge absolute -right-1 -top-1"
|
|
377
386
|
}, null, 8, ["value"])) : _("", !0)
|
|
378
387
|
], 2),
|
|
379
|
-
|
|
388
|
+
b.value ? (u(), g("div", {
|
|
380
389
|
key: 0,
|
|
381
|
-
class:
|
|
390
|
+
class: y(["tv-settings-panel fixed bottom-20 right-4 z-50 flex w-72 flex-col gap-4 rounded-xl bg-white p-4 shadow-2xl ring-1 ring-gray-200", f($)])
|
|
382
391
|
}, [
|
|
383
|
-
|
|
384
|
-
o[2] || (o[2] =
|
|
385
|
-
|
|
386
|
-
"onUpdate:modelValue": o[1] || (o[1] = (
|
|
392
|
+
p("label", Ue, [
|
|
393
|
+
o[2] || (o[2] = p("span", null, "Verification overlay", -1)),
|
|
394
|
+
ae(p("input", {
|
|
395
|
+
"onUpdate:modelValue": o[1] || (o[1] = (x) => le(n) ? n.value = x : null),
|
|
387
396
|
type: "checkbox",
|
|
388
397
|
class: "tv-enable-checkbox h-4 w-4 accent-gray-900"
|
|
389
398
|
}, null, 512), [
|
|
390
|
-
[
|
|
399
|
+
[oe, f(n)]
|
|
391
400
|
])
|
|
392
401
|
]),
|
|
393
|
-
f(n) && r.value.total > 0 ? (
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
o[3] || (o[3] =
|
|
397
|
-
|
|
402
|
+
f(n) && r.value.total > 0 ? (u(), g(M, { key: 0 }, [
|
|
403
|
+
p("div", ze, [
|
|
404
|
+
p("div", Fe, [
|
|
405
|
+
o[3] || (o[3] = p("span", { class: "text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, "Review progress", -1)),
|
|
406
|
+
p("span", Ye, w(r.value.verified) + " / " + w(r.value.total), 1)
|
|
398
407
|
]),
|
|
399
|
-
N(f(
|
|
408
|
+
N(f(fe), {
|
|
400
409
|
value: r.value.verified,
|
|
401
410
|
max: r.value.total,
|
|
402
411
|
size: "md",
|
|
@@ -406,46 +415,46 @@ const Re = ["data-status", "title"], Oe = {
|
|
|
406
415
|
glow: r.value.percent === 100,
|
|
407
416
|
gradient: ""
|
|
408
417
|
}, null, 8, ["value", "max", "variant", "striped", "animate-stripes", "glow"]),
|
|
409
|
-
i.value > 0 ? (
|
|
418
|
+
i.value > 0 ? (u(), g("div", Ge, w(i.value) + " extraction attempt" + w(i.value === 1 ? "" : "s") + " recorded ", 1)) : _("", !0)
|
|
410
419
|
]),
|
|
411
|
-
r.value.needsReview > 0 ? (
|
|
420
|
+
r.value.needsReview > 0 ? (u(), g("button", {
|
|
412
421
|
key: 0,
|
|
413
422
|
type: "button",
|
|
414
|
-
class:
|
|
423
|
+
class: y(["tv-next-flagged flex items-center justify-between rounded-lg bg-amber-50 px-3 py-2 text-left text-xs font-medium text-amber-700 ring-1 ring-inset ring-amber-600/20 transition hover:bg-amber-100", f($)]),
|
|
415
424
|
onClick: G(A, ["stop"])
|
|
416
425
|
}, [
|
|
417
|
-
|
|
418
|
-
o[4] || (o[4] =
|
|
426
|
+
p("span", null, w(r.value.needsReview) + " need" + w(r.value.needsReview === 1 ? "s" : "") + " review", 1),
|
|
427
|
+
o[4] || (o[4] = p("span", { "aria-hidden": "true" }, "→", -1))
|
|
419
428
|
], 2)) : _("", !0)
|
|
420
429
|
], 64)) : _("", !0)
|
|
421
430
|
], 2)) : _("", !0),
|
|
422
|
-
N(f(
|
|
423
|
-
class:
|
|
431
|
+
N(f(ve), {
|
|
432
|
+
class: y(f($))
|
|
424
433
|
}, null, 8, ["class"])
|
|
425
434
|
], 64));
|
|
426
435
|
}
|
|
427
436
|
});
|
|
428
437
|
export {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
438
|
+
$ as CHROME_CLASS,
|
|
439
|
+
Ne as ConfidenceIcon,
|
|
440
|
+
$e as DATA_POINT_ACTIVATED,
|
|
432
441
|
q as ENABLED_STORAGE_KEY,
|
|
433
442
|
X as RESOLUTION_PRIORITY,
|
|
434
|
-
|
|
443
|
+
me as STATUS_COLORS,
|
|
435
444
|
V as STATUS_LABELS,
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
445
|
+
Ce as TEMPLATE_MESSAGE_SOURCE,
|
|
446
|
+
Te as TEMPLATE_PROTOCOL_VERSION,
|
|
447
|
+
Qe as VerificationChrome,
|
|
448
|
+
Je as VerifiedField,
|
|
440
449
|
W as bucketConfidence,
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
450
|
+
_e as candidatesDisagree,
|
|
451
|
+
Oe as computeProgress,
|
|
452
|
+
Ae as embedderOrigin,
|
|
453
|
+
xe as hasDiscrepancy,
|
|
454
|
+
qe as initVerification,
|
|
455
|
+
Ee as notifyDataPointActivated,
|
|
456
|
+
ye as resolveCandidates,
|
|
457
|
+
we as resolveDataPoint,
|
|
449
458
|
Q as useVerification,
|
|
450
459
|
Z as walkDataPoints
|
|
451
460
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -91,6 +91,28 @@ export interface SourceDiscrepancy {
|
|
|
91
91
|
/** The reconciling explanation (which values disagreed, why, and what corroborated the winner). */
|
|
92
92
|
reason: string;
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* A recorded CORRECTION — "we normalised/typo-fixed/OCR-corrected this value" — the host's
|
|
96
|
+
* DataExtraction identity-dedupe pass applies for every field it returns a canonical spelling
|
|
97
|
+
* for (SG-396), an ordinary case/spacing/punctuation normalisation included (SG-406). Same
|
|
98
|
+
* shape as {@link SourceDiscrepancy} but a DIFFERENT fact: this is provenance ("we corrected
|
|
99
|
+
* this value"), never a claim that the source documents disagreed. The two used to share one
|
|
100
|
+
* field (`source_discrepancy`), which fired the reviewer's genuine-conflict warning on routine
|
|
101
|
+
* housekeeping — SG-406 gave the correction its own home. Present on any field the block
|
|
102
|
+
* dedupe touched; null/undefined on every field it never corrected.
|
|
103
|
+
*/
|
|
104
|
+
export interface Correction {
|
|
105
|
+
/** Which field was corrected — a constant naming the data point (e.g. "name"). */
|
|
106
|
+
field: string;
|
|
107
|
+
/** The literal pre-correction spelling(s) recorded before normalisation. */
|
|
108
|
+
conflicting_values: string[];
|
|
109
|
+
/** The evidence pages/sources the correction was decided from. */
|
|
110
|
+
evidence: SourceDiscrepancyEvidence[];
|
|
111
|
+
/** The canonical value that won. */
|
|
112
|
+
winning_value: string;
|
|
113
|
+
/** The correcting explanation. */
|
|
114
|
+
reason: string;
|
|
115
|
+
}
|
|
94
116
|
/**
|
|
95
117
|
* The extracted (pipeline) candidate — carries provenance: confidence, reasoning, citation.
|
|
96
118
|
*
|
|
@@ -140,6 +162,12 @@ export interface ExtractedCandidate {
|
|
|
140
162
|
* none of the SG-392 payload-size risk and `hasDiscrepancy()` needs it in light mode too.
|
|
141
163
|
*/
|
|
142
164
|
source_discrepancy?: SourceDiscrepancy | null;
|
|
165
|
+
/**
|
|
166
|
+
* Non-null when this candidate's value was NORMALISED/typo-fixed by the block dedupe
|
|
167
|
+
* (SG-406) — a DIFFERENT fact from `source_discrepancy` above, never folded into
|
|
168
|
+
* `discrepancy`. Shipped in BOTH light and full mode, same argument as `source_discrepancy`.
|
|
169
|
+
*/
|
|
170
|
+
correction?: Correction | null;
|
|
143
171
|
}
|
|
144
172
|
/**
|
|
145
173
|
* One recorded attempt in a field's extraction history (SG-190). Mirrors the extracted
|
|
@@ -201,6 +229,13 @@ export interface DataPointMeta {
|
|
|
201
229
|
* purposes — see {@link isSourceDiscrepancy} in `lib/discrepancy.ts`.
|
|
202
230
|
*/
|
|
203
231
|
source_discrepancy?: SourceDiscrepancy | null;
|
|
232
|
+
/**
|
|
233
|
+
* Present (non-null) when the extracted candidate carries a `correction` (SG-406) — "we
|
|
234
|
+
* normalised/typo-fixed this value" provenance, distinct from `source_discrepancy` and
|
|
235
|
+
* deliberately NEVER folded into `discrepancy`. See {@link hasCorrection}/{@link correctionOf}
|
|
236
|
+
* in `lib/discrepancy.ts`.
|
|
237
|
+
*/
|
|
238
|
+
correction?: Correction | null;
|
|
204
239
|
}
|
|
205
240
|
/** An object node in the rendered `data` tree carrying a keyed `__meta` map. */
|
|
206
241
|
export type MetaCarrier = Record<string, unknown> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thehammer/template-verification",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Read-write verification overlay for rendered template apps — per-data-point confidence, discrepancy, 3-source resolution (override > extracted > claim), inline edit, and a recursive comparison page. Consumes the host's __meta sidecar; fetches nothing.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|