@cccsaurora/clue-ui 1.0.1 → 1.0.2

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.
Files changed (54) hide show
  1. package/{ActionForm-WIj7BfD5.js → ActionForm-BtTv0s4P.js} +13 -13
  2. package/AnnotationDetails-D5tBIeEw.js +160 -0
  3. package/{AnnotationPreview-DWRDhxUB.js → AnnotationPreview-CZr_CcZC.js} +2 -2
  4. package/ClueEnrichContext-DH9lqjwH.js +401 -0
  5. package/api/lookup/enrich.d.ts +3 -3
  6. package/components/AnnotationDetailPopover.js +7 -7
  7. package/components/AnnotationDetails.js +21 -155
  8. package/components/AnnotationEntry.js +26 -31
  9. package/components/AnnotationPreview.js +2 -2
  10. package/components/EnrichedCard.js +8 -8
  11. package/components/EnrichedChip.js +1 -1
  12. package/components/EnrichedTypography.js +1 -1
  13. package/components/actions/ActionForm.js +3 -3
  14. package/components/actions/ResultModal.js +1 -1
  15. package/components/display/graph/elements/NodeCard.js +2 -2
  16. package/components/display/graph/index.js +1 -1
  17. package/components/display/json/index.js +2 -2
  18. package/components/enrichment/EnrichPopover.js +5 -5
  19. package/components/fetchers/Fetcher.js +1 -1
  20. package/components/group/Entry.js +7 -7
  21. package/components/group/GroupControl.js +9 -9
  22. package/database/index.js +1 -1
  23. package/hooks/ClueActionContext.d.ts +1 -1
  24. package/hooks/ClueActionContext.js +3 -3
  25. package/hooks/ClueDatabaseContext.js +1 -1
  26. package/hooks/ClueEnrichContext.js +4 -4
  27. package/hooks/ClueFetcherContext.js +1 -1
  28. package/hooks/CluePopupContext.js +2 -2
  29. package/hooks/ClueProvider.js +3 -3
  30. package/hooks/selectors.js +2 -2
  31. package/hooks/useAnnotations.js +23 -27
  32. package/hooks/useClue.js +1 -1
  33. package/hooks/useClueActions.js +1 -1
  34. package/hooks/useClueTypeConfig.d.ts +2 -1
  35. package/hooks/useClueTypeConfig.js +2 -2
  36. package/hooks/useMyLocalStorage.js +28 -28
  37. package/icons/Action.js +7 -7
  38. package/icons/Assessment.js +13 -13
  39. package/icons/Context.js +7 -7
  40. package/icons/Opinion.js +12 -12
  41. package/{index-HuYhutsd.js → index-BUcHmehh.js} +1 -1
  42. package/{index-WvFmjbxF.js → index-Bo-v5IAc.js} +4764 -4744
  43. package/{index-4YFAh_sa.js → index-CnaCBNrd.js} +1 -1
  44. package/main.d.ts +0 -1
  45. package/main.js +53 -63
  46. package/package.json +1 -1
  47. package/text/Frequency.js +19 -19
  48. package/{useClueTypeConfig-BQ33EiyB.js → useClueTypeConfig-CneP98N_.js} +10 -23
  49. package/utils/classificationParser.d.ts +8 -8
  50. package/utils/classificationParser.js +63 -76
  51. package/utils/utils.js +2 -2
  52. package/{utils-C_RX5uMP.js → utils-CD0rFIFU.js} +11 -11
  53. package/ClueEnrichContext-CbJVBm4w.js +0 -397
  54. package/isUndefined-DiNCDKoz.js +0 -10
@@ -3,24 +3,24 @@ import { materialRenderers as be, materialCells as Re } from "@jsonforms/materia
3
3
  import { JsonForms as Ee } from "@jsonforms/react";
4
4
  import { Stack as x, Typography as q, IconButton as Me, Modal as Se, Paper as je, Box as F, Button as G, Divider as oe, CircularProgress as Fe, Collapse as $e } from "@mui/material";
5
5
  import le from "./components/display/icons/Iconified.js";
6
- import { J as Je } from "./index-4YFAh_sa.js";
6
+ import { J as Je } from "./index-CnaCBNrd.js";
7
7
  import { ClueComponentContext as ie } from "./hooks/ClueComponentContext.js";
8
8
  import { c as Oe, u as ce, a as Pe } from "./index-E7g8cRyW.js";
9
- import { A as ze } from "./index-WvFmjbxF.js";
10
- import { a as te } from "./useClueTypeConfig-BQ33EiyB.js";
11
- import { useState as v, useCallback as R, useEffect as We, useMemo as L, memo as qe } from "react";
12
- import U from "./components/ErrorBoundary.js";
13
- import { adaptSchema as Be } from "./components/actions/form/schemaAdapter.js";
9
+ import { A as ze } from "./index-Bo-v5IAc.js";
10
+ import { a as te } from "./useClueTypeConfig-CneP98N_.js";
14
11
  import { d as de } from "./_baseGet-Dgf6_xCm.js";
15
- import { b as Ve } from "./_baseSlice-M5RKzt1A.js";
16
- import { i as ke } from "./utils-C_RX5uMP.js";
12
+ import { b as We } from "./_baseSlice-M5RKzt1A.js";
13
+ import { i as qe } from "./utils-CD0rFIFU.js";
14
+ import { useState as v, useCallback as R, useEffect as Be, useMemo as L, memo as Ve } from "react";
15
+ import U from "./components/ErrorBoundary.js";
16
+ import { adaptSchema as ke } from "./components/actions/form/schemaAdapter.js";
17
17
  import He from "./components/actions/ResultModal.js";
18
18
  import { SNACKBAR_EVENT_ID as I } from "./data/event.js";
19
19
  import { safeDispatchEvent as K } from "./utils/window.js";
20
20
  import _e from "./hooks/useClue.js";
21
21
  function Ge(e, l, i) {
22
22
  var o = e.length;
23
- return i = i === void 0 ? o : i, !l && i >= o ? e : Ve(e, l, i);
23
+ return i = i === void 0 ? o : i, !l && i >= o ? e : We(e, l, i);
24
24
  }
25
25
  var Ie = "\\ud800-\\udfff", Ke = "\\u0300-\\u036f", Le = "\\ufe20-\\ufe2f", Ne = "\\u20d0-\\u20ff", Ze = Ke + Le + Ne, Ue = "\\ufe0e\\ufe0f", Qe = "\\u200d", Xe = RegExp("[" + Qe + Ie + Ze + Ue + "]");
26
26
  function fe(e) {
@@ -64,7 +64,7 @@ const as = new ze({ removeAdditional: !0, coerceTypes: !0, strict: !1 }), Ce = O
64
64
  const S = await te.actions.get(y);
65
65
  return S && O(S), S;
66
66
  }, [e, o, m, w]);
67
- We(() => {
67
+ Be(() => {
68
68
  k();
69
69
  }, [e, w]);
70
70
  const P = R(
@@ -197,7 +197,7 @@ const as = new ze({ removeAdditional: !0, coerceTypes: !0, strict: !1 }), Ce = O
197
197
  renderer: ({ ...l }) => /* @__PURE__ */ s(U, { children: /* @__PURE__ */ s(e.renderer, { ...l }) })
198
198
  })), vs = ({ runningActionData: e }) => {
199
199
  const { executeAction: l, cancelAction: i } = us(), { t: o } = ce(ie, (r) => r.i18next), [m, E] = v(!1), [w, a] = v(null), [C, $] = v(e == null ? void 0 : e.params), [M, B] = v(!1), t = L(
200
- () => e != null && e.action ? { ...Be(e.action.params), ...e.action.extra_schema ?? {} } : null,
200
+ () => e != null && e.action ? { ...ke(e.action.params), ...e.action.extra_schema ?? {} } : null,
201
201
  [e == null ? void 0 : e.action]
202
202
  ), J = L(
203
203
  () => ({
@@ -293,7 +293,7 @@ const as = new ze({ removeAdditional: !0, coerceTypes: !0, strict: !1 }), Ce = O
293
293
  cells: Re,
294
294
  data: C,
295
295
  onChange: ({ data: r, errors: d }) => {
296
- ke(r, C) || $(r), a(d);
296
+ qe(r, C) || $(r), a(d);
297
297
  },
298
298
  config: {}
299
299
  }
@@ -330,7 +330,7 @@ const as = new ze({ removeAdditional: !0, coerceTypes: !0, strict: !1 }), Ce = O
330
330
  } catch (r) {
331
331
  return console.warn(r), null;
332
332
  }
333
- }, Cs = qe(vs);
333
+ }, Cs = Ve(vs);
334
334
  export {
335
335
  Cs as A,
336
336
  Hs as C,
@@ -0,0 +1,160 @@
1
+ import { jsxs as a, jsx as o } from "react/jsx-runtime";
2
+ import { I as u } from "./iconify-BBckr5AQ.js";
3
+ import { useTheme as M, Stack as l, Typography as s, Tooltip as x, Box as A, IconButton as E, CircularProgress as N, Chip as z, Accordion as $, AccordionSummary as j, AccordionDetails as _, Divider as S } from "@mui/material";
4
+ import g from "./components/display/icons/Iconified.js";
5
+ import { SNACKBAR_EVENT_ID as O } from "./data/event.js";
6
+ import { ClueComponentContext as F } from "./hooks/ClueComponentContext.js";
7
+ import { useClueEnrichSelector as H } from "./hooks/selectors.js";
8
+ import K from "./hooks/useAnnotations.js";
9
+ import L from "./hooks/useErrors.js";
10
+ import { ICON_MAP as T } from "./icons/iconMap.js";
11
+ import { safeDispatchEvent as U } from "./utils/window.js";
12
+ import { g as V } from "./groupBy-BheQYl6f.js";
13
+ import { u as W } from "./ClueEnrichContext-DH9lqjwH.js";
14
+ import { memo as G, useState as J, useMemo as k, useCallback as P, useEffect as Q } from "react";
15
+ import { u as X } from "./index-E7g8cRyW.js";
16
+ import Y from "./components/actions/ExecutePopover.js";
17
+ import Z from "./components/AnnotationEntry.js";
18
+ import q from "./components/ClassificationChip.js";
19
+ import R from "./components/enrichment/EnrichPopover.js";
20
+ function w(i) {
21
+ return i === null;
22
+ }
23
+ const ii = ({ enrichRequest: i, setReady: d, updatePosition: p }) => {
24
+ const v = M(), { t: c } = X(F, (n) => n.i18next), [r, I] = J("all"), y = H((n) => n.enrich), [t, C] = K(
25
+ i == null ? void 0 : i.type,
26
+ i == null ? void 0 : i.value,
27
+ i == null ? void 0 : i.classification,
28
+ { skipEnrichment: !0 }
29
+ ), m = L(i == null ? void 0 : i.value), B = k(
30
+ () => ["all", ...W((t ?? []).map((n) => n.type))],
31
+ [t]
32
+ ), b = k(() => V(t ?? [], "type"), [t]), h = P(async () => {
33
+ await y(i.type, i.value, {
34
+ classification: i.classification,
35
+ timeout: 15,
36
+ force: !0
37
+ });
38
+ }, [i, y]);
39
+ return Q(() => {
40
+ d && (d(i && !w(t)), p == null || p());
41
+ }, [t, i, d, p]), i && !w(t) && /* @__PURE__ */ a(l, { direction: "column", sx: { p: 1, width: "100%" }, spacing: 1, children: [
42
+ /* @__PURE__ */ a(l, { spacing: 1, children: [
43
+ /* @__PURE__ */ a(l, { direction: "row", spacing: 1, children: [
44
+ /* @__PURE__ */ a(l, { children: [
45
+ /* @__PURE__ */ a(l, { direction: "row", spacing: 1, children: [
46
+ /* @__PURE__ */ o(s, { variant: "body1", fontWeight: "bold", children: "Clue" }),
47
+ i.classification && /* @__PURE__ */ o(q, { size: "small", classification: i.classification })
48
+ ] }),
49
+ /* @__PURE__ */ a(s, { variant: "caption", color: "text.secondary", children: [
50
+ i.type.toLocaleUpperCase(),
51
+ " ",
52
+ c("enrichment")
53
+ ] })
54
+ ] }),
55
+ /* @__PURE__ */ o("div", { style: { flex: 1 } }),
56
+ /* @__PURE__ */ o(x, { title: c("refresh"), children: /* @__PURE__ */ o(A, { sx: { alignSelf: "center", m: -1 }, children: /* @__PURE__ */ o(E, { onClick: () => h(), disabled: C, children: C ? /* @__PURE__ */ o(N, { variant: "indeterminate", size: 20 }) : /* @__PURE__ */ o(g, { icon: "ic:baseline-replay", fontSize: "small" }) }) }) }),
57
+ /* @__PURE__ */ o(x, { title: c("clipboard"), children: /* @__PURE__ */ o(
58
+ E,
59
+ {
60
+ sx: { alignSelf: "center", m: -1 },
61
+ onClick: () => {
62
+ navigator.clipboard.writeText(i.value), U(
63
+ new CustomEvent(O, {
64
+ detail: {
65
+ message: `${i.value} ${c("clipboard.success")}`,
66
+ level: "success"
67
+ }
68
+ })
69
+ );
70
+ },
71
+ children: /* @__PURE__ */ o(g, { icon: "ic:outline-assignment", fontSize: "small" })
72
+ }
73
+ ) }),
74
+ /* @__PURE__ */ o(R, { selector: i }),
75
+ /* @__PURE__ */ o(Y, { selectors: [i] })
76
+ ] }),
77
+ /* @__PURE__ */ a(l, { direction: "row", spacing: 0.5, children: [
78
+ B.map((n, e) => /* @__PURE__ */ o(
79
+ z,
80
+ {
81
+ size: "small",
82
+ variant: n === r ? "filled" : "outlined",
83
+ icon: T[n] && /* @__PURE__ */ o(u, { icon: T[n] }),
84
+ label: /* @__PURE__ */ a(s, { variant: "caption", textTransform: "capitalize", children: [
85
+ n,
86
+ ":",
87
+ " ",
88
+ n === "all" ? t.length : t.filter((f) => f.type === n).length
89
+ ] }),
90
+ onClick: () => I(n)
91
+ },
92
+ e
93
+ )),
94
+ (m == null ? void 0 : m.length) > 0 && /* @__PURE__ */ o(
95
+ x,
96
+ {
97
+ title: /* @__PURE__ */ o("div", { onClick: (n) => n.stopPropagation(), children: m.map((n, e) => /* @__PURE__ */ a("div", { children: [
98
+ /* @__PURE__ */ o("span", { style: { textTransform: "capitalize" }, children: n.source.replace(/-/g, " ") }),
99
+ ":",
100
+ " ",
101
+ n.message
102
+ ] }, e)) }),
103
+ children: /* @__PURE__ */ o(
104
+ z,
105
+ {
106
+ size: "small",
107
+ variant: "outlined",
108
+ icon: /* @__PURE__ */ o(u, { icon: "material-symbols:timer-outline", color: v.palette.error.main }),
109
+ label: /* @__PURE__ */ a(s, { variant: "caption", textTransform: "capitalize", children: [
110
+ c("annotation.failed"),
111
+ ": ",
112
+ m.length
113
+ ] }),
114
+ onClick: h
115
+ }
116
+ )
117
+ }
118
+ )
119
+ ] })
120
+ ] }),
121
+ /* @__PURE__ */ o(A, {}),
122
+ Object.keys(b).filter((n) => !r || r === "all" || n === r).map((n, e) => /* @__PURE__ */ a(
123
+ $,
124
+ {
125
+ defaultExpanded: !0,
126
+ sx: {
127
+ marginTop: `${v.spacing(1)} !important`,
128
+ marginBottom: "0 !important",
129
+ "&:before": { height: 0 }
130
+ },
131
+ children: [
132
+ r === "all" && /* @__PURE__ */ o(
133
+ j,
134
+ {
135
+ expandIcon: /* @__PURE__ */ o(g, { icon: "ic:baseline-arrow-drop-down" }),
136
+ sx: {
137
+ minHeight: "initial !important",
138
+ mt: 0.5,
139
+ mb: 0,
140
+ px: 1,
141
+ "& .MuiAccordionSummary-content": { my: 0.5, mx: 0 },
142
+ "& .MuiAccordionSummary-content.Mui-expanded": { my: 0.5, mx: 0 }
143
+ },
144
+ children: /* @__PURE__ */ o(s, { variant: "body1", textTransform: "capitalize", children: n }, n)
145
+ }
146
+ ),
147
+ /* @__PURE__ */ a(_, { sx: { px: 1 }, children: [
148
+ r === "all" && /* @__PURE__ */ o(S, { orientation: "horizontal", sx: { mb: 1 } }),
149
+ /* @__PURE__ */ o(l, { spacing: 1, divider: /* @__PURE__ */ o(S, { orientation: "horizontal", flexItem: !0 }), children: b[n].map((f, D) => /* @__PURE__ */ o(Z, { annotation: f }, D)) })
150
+ ] })
151
+ ]
152
+ },
153
+ e
154
+ ))
155
+ ] });
156
+ }, hi = G(ii);
157
+ export {
158
+ hi as A,
159
+ w as i
160
+ };
@@ -3,12 +3,12 @@ import { I as H } from "./iconify-BBckr5AQ.js";
3
3
  import { useTheme as k, Popper as V, Fade as j, Paper as O, Stack as w, Typography as y, Divider as W } from "@mui/material";
4
4
  import F from "./components/AnnotationDetailPopover.js";
5
5
  import L from "./hooks/useAnnotations.js";
6
- import { t as M } from "./utils-C_RX5uMP.js";
6
+ import { t as M } from "./utils-CD0rFIFU.js";
7
7
  import { useState as v, useRef as Y, useCallback as x, useEffect as Z, useMemo as _ } from "react";
8
8
  import { c as B, u as G } from "./index-E7g8cRyW.js";
9
9
  import { SHOW_EVENT_ID as g, HIDE_EVENT_ID as D } from "./data/event.js";
10
10
  import { safeDispatchEvent as A, safeAddEventListener as S } from "./utils/window.js";
11
- import { i as J } from "./isUndefined-DiNCDKoz.js";
11
+ import { i as J } from "./AnnotationDetails-D5tBIeEw.js";
12
12
  const b = B(null), rt = ({ children: c }) => {
13
13
  const [l, e] = v(null), [p, i] = v(null), [r, d] = v(null), [u, m] = v(null), [f, t] = v({}), a = Y(null), P = x((s, o, z, N) => {
14
14
  A(
@@ -0,0 +1,401 @@
1
+ import { jsx as dt } from "react/jsx-runtime";
2
+ import { a as pt } from "./iconify-BBckr5AQ.js";
3
+ import { u as mt, a as ht, p as et } from "./useClueTypeConfig-CneP98N_.js";
4
+ import { clueDebugLogger as Q } from "./utils/loggerUtil.js";
5
+ import { b as yt } from "./_baseSlice-M5RKzt1A.js";
6
+ import { t as wt } from "./toFinite-BMy6GObD.js";
7
+ import { d as vt } from "./debounce-DryYcbJ4.js";
8
+ import { g as st } from "./groupBy-BheQYl6f.js";
9
+ import { b as rt } from "./_baseUniq-tMFmk80M.js";
10
+ import { b as xt } from "./_baseIteratee-CP1bocOX.js";
11
+ import { useContext as Et, useMemo as G, useState as K, useRef as It, useEffect as q, useCallback as b } from "react";
12
+ import { c as $t } from "./index-E7g8cRyW.js";
13
+ import { ClueDatabaseContext as Ct } from "./hooks/ClueDatabaseContext.js";
14
+ import Dt from "./hooks/useClueConfig.js";
15
+ function Ot(e) {
16
+ var s = wt(e), p = s % 1;
17
+ return s === s ? p ? s - p : s : 0;
18
+ }
19
+ var gt = Math.ceil, bt = Math.max;
20
+ function jt(e, s, p) {
21
+ s === void 0 ? s = 1 : s = bt(Ot(s), 0);
22
+ var l = e == null ? 0 : e.length;
23
+ if (!l || s < 1)
24
+ return [];
25
+ for (var h = 0, v = 0, D = Array(gt(l / s)); h < l; )
26
+ D[v++] = yt(e, h, h += s);
27
+ return D;
28
+ }
29
+ function nt(e) {
30
+ return e && e.length ? rt(e) : [];
31
+ }
32
+ function Pt(e, s) {
33
+ return e && e.length ? rt(e, xt(s)) : [];
34
+ }
35
+ let F;
36
+ const Mt = new Uint8Array(16);
37
+ function qt() {
38
+ if (!F && (F = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !F))
39
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
40
+ return F(Mt);
41
+ }
42
+ const d = [];
43
+ for (let e = 0; e < 256; ++e)
44
+ d.push((e + 256).toString(16).slice(1));
45
+ function At(e, s = 0) {
46
+ return d[e[s + 0]] + d[e[s + 1]] + d[e[s + 2]] + d[e[s + 3]] + "-" + d[e[s + 4]] + d[e[s + 5]] + "-" + d[e[s + 6]] + d[e[s + 7]] + "-" + d[e[s + 8]] + d[e[s + 9]] + "-" + d[e[s + 10]] + d[e[s + 11]] + d[e[s + 12]] + d[e[s + 13]] + d[e[s + 14]] + d[e[s + 15]];
47
+ }
48
+ const Bt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), it = {
49
+ randomUUID: Bt
50
+ };
51
+ function C(e, s, p) {
52
+ if (it.randomUUID && !e)
53
+ return it.randomUUID();
54
+ e = e || {};
55
+ const l = e.random || (e.rng || qt)();
56
+ return l[6] = l[6] & 15 | 64, l[8] = l[8] & 63 | 128, At(l);
57
+ }
58
+ const Vt = $t(null), zt = ({
59
+ children: e,
60
+ classification: s,
61
+ baseURL: p,
62
+ getToken: l,
63
+ onNetworkCall: h,
64
+ pickSources: v,
65
+ chunkSize: D = 15,
66
+ maxRequestCount: H = 4,
67
+ defaultTimeout: A = 5,
68
+ enabled: B = !0,
69
+ ready: ot = !1,
70
+ publicIconify: X = !0,
71
+ skipConfigCall: Y = !1,
72
+ customIconify: V,
73
+ debugLogging: x = !0
74
+ }) => {
75
+ var tt;
76
+ const j = Dt(), n = Et(Ct), w = G(() => {
77
+ var t, i;
78
+ return (i = (t = j.config) == null ? void 0 : t.c12nDef) == null ? void 0 : i.UNRESTRICTED;
79
+ }, [j.config]), [$, ct] = K(ot), O = It(0), [E, at] = K([]), { availableSources: g, typesDetection: R } = mt(
80
+ B && $,
81
+ p,
82
+ x,
83
+ l,
84
+ h
85
+ );
86
+ q(() => {
87
+ if (Y || !B || !$)
88
+ return;
89
+ const t = {}, i = l == null ? void 0 : l();
90
+ i && (t.Authorization = `Bearer ${i}`);
91
+ let u = { baseURL: p, headers: t };
92
+ h && (u = h(u)), ht.configs.get(u).then(j.setConfig);
93
+ }, [p, h, Y, $]);
94
+ const [Z, S] = K(V);
95
+ q(() => {
96
+ V && S(V);
97
+ }, [V]), q(() => {
98
+ if (X)
99
+ return;
100
+ let t = Z ?? void 0 ?? (p == null ? void 0 : p.replace(/^[^.]+/, "icons"));
101
+ !t && typeof window < "u" && window && !window.location.origin.includes("localhost") && (t = window.location.protocol + "//" + window.location.origin.replace(/^[^.]+/, "icons")), t && (Q(`Using ${t} for iconify`, x), pt("", {
102
+ resources: [t]
103
+ }));
104
+ }, [p, Z, x, X]);
105
+ const U = b(
106
+ async (t) => {
107
+ const i = [];
108
+ for (const c of t) {
109
+ const { latency: o, source: f, type: r, value: y, items: a, error: m } = c;
110
+ m && i.push({
111
+ id: C(),
112
+ source: f,
113
+ type: r,
114
+ value: y,
115
+ annotations: [],
116
+ classification: w,
117
+ latency: o,
118
+ count: 0,
119
+ error: m
120
+ });
121
+ for (const I of a) {
122
+ const { classification: P, count: M, link: _, annotations: lt } = I;
123
+ await n.selectors.find({ selector: { type: r, value: y, source: f, classification: P } }).incrementalRemove();
124
+ const J = {
125
+ id: C(),
126
+ source: f,
127
+ type: r,
128
+ value: y,
129
+ annotations: lt,
130
+ classification: P,
131
+ latency: o,
132
+ count: M,
133
+ link: _,
134
+ error: m
135
+ };
136
+ i.some((ft) => ft.id === J.id) && (J.id = C()), i.push(J);
137
+ }
138
+ }
139
+ const u = await n.selectors.bulkInsert(i);
140
+ u.error.length > 0 && (console.warn("Errors on upsert:"), u.error.forEach((c) => console.warn(c.documentId, c.validationErrors ?? c.status)));
141
+ },
142
+ [n, w]
143
+ ), z = b(
144
+ async (t, i, u = {}) => {
145
+ var I, P;
146
+ if (!t || !i)
147
+ return console.error(`Type (${t}) or value (${i}) is empty, returning empty response`), {};
148
+ const c = (v == null ? void 0 : v(E, g, [{ type: t, value: i, classification: u.classification }])) ?? E, o = {
149
+ timeout: A,
150
+ force: !1,
151
+ includeRaw: !1,
152
+ noCache: !1,
153
+ classification: w,
154
+ sources: c,
155
+ ...u
156
+ }, f = {}, r = l == null ? void 0 : l();
157
+ r && (f.Authorization = `Bearer ${r}`);
158
+ let y = { baseURL: p, headers: f };
159
+ h && (y = h(y));
160
+ const a = {
161
+ type: t,
162
+ value: i,
163
+ classification: o.classification
164
+ };
165
+ let m = await ((I = n.status) == null ? void 0 : I.findOne({ selector: { ...a } }).exec());
166
+ m ? await m.incrementalPatch({ status: "in-progress" }) : m = await ((P = n.status) == null ? void 0 : P.insert({
167
+ id: C(),
168
+ type: a.type,
169
+ value: a.value,
170
+ classification: a.classification ?? w,
171
+ status: "in-progress"
172
+ }));
173
+ try {
174
+ const M = await et([a], o.sources, o, y), _ = Object.values(Object.values(M)[0])[0];
175
+ return await (m == null ? void 0 : m.incrementalPatch({ status: "complete" })), await U(Object.values(_)), _;
176
+ } catch (M) {
177
+ return console.error(M), {};
178
+ }
179
+ },
180
+ [
181
+ U,
182
+ g,
183
+ p,
184
+ n,
185
+ w,
186
+ A,
187
+ l,
188
+ h,
189
+ v,
190
+ E
191
+ ]
192
+ ), W = b(
193
+ async (t, i) => {
194
+ const u = (v == null ? void 0 : v(E, g, t)) ?? E, c = {
195
+ timeout: A,
196
+ includeRaw: !1,
197
+ noCache: !1,
198
+ classification: w,
199
+ sources: u,
200
+ ...i
201
+ }, o = {}, f = l == null ? void 0 : l();
202
+ f && (o.Authorization = `Bearer ${f}`);
203
+ let r = { baseURL: p, headers: o };
204
+ h && (r = h(r));
205
+ const y = [];
206
+ for (const a of t) {
207
+ const m = { type: a.type, value: a.value, classification: c.classification };
208
+ let I = await n.status.findOne({
209
+ selector: m
210
+ }).incrementalPatch({
211
+ status: "in-progress"
212
+ });
213
+ I || (I = await n.status.insert({
214
+ id: C(),
215
+ ...m,
216
+ status: "in-progress",
217
+ sources: c.sources
218
+ })), y.push(I.toMutableJSON());
219
+ }
220
+ try {
221
+ const a = await et(t, c.sources, c, r), m = Object.values(a).flatMap(Object.values).flatMap(Object.values);
222
+ return await U(m), a;
223
+ } catch (a) {
224
+ return console.error(a), {};
225
+ } finally {
226
+ n.status.bulkUpsert(
227
+ Pt(y, (a) => a.id).map((a) => (a.status = "complete", a))
228
+ );
229
+ }
230
+ },
231
+ [
232
+ v,
233
+ E,
234
+ g,
235
+ A,
236
+ w,
237
+ l,
238
+ p,
239
+ h,
240
+ n,
241
+ U
242
+ ]
243
+ ), N = b(async () => {
244
+ const t = await n.selectors.find({ selector: { error: { $exists: !0 } } }).exec(), i = st(t, "classification"), u = [];
245
+ for (const [c, o] of Object.entries(i)) {
246
+ const f = st(o, (r) => `${r.type}:${r.value}`);
247
+ Object.values(f).forEach((r) => {
248
+ u.push({
249
+ id: C(),
250
+ type: r[0].type,
251
+ value: r[0].value,
252
+ classification: c,
253
+ sources: nt(r.map((y) => y.source)).sort(),
254
+ status: "pending"
255
+ });
256
+ });
257
+ }
258
+ await n.status.bulkInsert(u), await n.selectors.bulkRemove(t);
259
+ }, [n]), T = G(
260
+ () => vt(
261
+ async () => {
262
+ if (n != null && n.status) {
263
+ if (n.status.closed) {
264
+ console.warn("Status database is closed, will not enrich");
265
+ return;
266
+ }
267
+ } else return;
268
+ const t = await n.status.find({ selector: { status: "pending" } }).update({ $set: { status: "in-progress" } });
269
+ if (t.length < 1)
270
+ return;
271
+ const i = jt(t, D);
272
+ Q(
273
+ `Enriching ${t.length} selectors in ${i.length} chunks of ${D}.`,
274
+ x
275
+ ), await Promise.all(
276
+ // For performance reasons, we chunk the requests. This will allow us to take advantage of parellelization in the
277
+ // backend, both on the pod level and kubernetes level
278
+ i.map(async (u) => {
279
+ let c = null;
280
+ if (O.current <= H)
281
+ O.current += 1;
282
+ else {
283
+ let o = Date.now();
284
+ await new Promise((f) => {
285
+ c = setInterval(() => {
286
+ Q(
287
+ `Waiting on ${O.current} existing requests to complete (total delay: ${Date.now() - o}ms)`,
288
+ x
289
+ ), O.current < H && f();
290
+ }, 400);
291
+ }).finally(() => {
292
+ O.current += 1, clearInterval(c);
293
+ });
294
+ }
295
+ try {
296
+ const o = {}, f = nt(u.flatMap((r) => r.sources ?? []));
297
+ f.length > 0 && (o.sources = f), await W(
298
+ u.map((r) => r.toSelector()),
299
+ o
300
+ ), await n.status.findByIds(u.map((r) => r.id)).update({ $set: { status: "complete" } });
301
+ } catch (o) {
302
+ console.error(o);
303
+ } finally {
304
+ O.current -= 1, c && clearInterval(c);
305
+ }
306
+ })
307
+ );
308
+ },
309
+ 200,
310
+ { maxWait: 500, leading: !1 }
311
+ ),
312
+ [W, D, n, x, H]
313
+ );
314
+ q(() => {
315
+ }, [n, x]), q(() => {
316
+ if (!B || !$ || !(n != null && n.status))
317
+ return;
318
+ const t = n.status.find({
319
+ selector: {
320
+ status: "pending"
321
+ }
322
+ }).$.subscribe(() => T());
323
+ return () => {
324
+ try {
325
+ t == null || t.unsubscribe();
326
+ } catch (i) {
327
+ console.warn(i);
328
+ }
329
+ };
330
+ }, [B, $, n, x, T]);
331
+ const L = b(
332
+ async (t, i, u) => {
333
+ if (!t)
334
+ throw new Error("Type cannot be null");
335
+ if (!i)
336
+ throw new Error("Value cannot be null");
337
+ const c = { type: t, value: i, classification: u ?? w };
338
+ let o = await n.status.findOne({
339
+ selector: c
340
+ }).exec();
341
+ return o || (o = await n.status.queueInsert({
342
+ id: C(),
343
+ ...c,
344
+ status: "pending"
345
+ })), o;
346
+ },
347
+ [w, n]
348
+ ), k = b(
349
+ (t) => {
350
+ var f, r;
351
+ if (!t)
352
+ return null;
353
+ const i = Object.entries(R), u = (f = i.find(([y, a]) => a.exec(t))) == null ? void 0 : f[0];
354
+ if (u)
355
+ return u;
356
+ const c = t.toLowerCase(), o = (r = i.find(([y, a]) => a.exec(c))) == null ? void 0 : r[0];
357
+ return o || null;
358
+ },
359
+ [R]
360
+ ), ut = G(
361
+ () => {
362
+ var t;
363
+ return {
364
+ bulkEnrich: W,
365
+ enrich: z,
366
+ enrichFailedEnrichments: N,
367
+ sources: E,
368
+ setSources: at,
369
+ typesDetection: R,
370
+ availableSources: g,
371
+ guessType: k,
372
+ queueEnrich: L,
373
+ setCustomIconify: S,
374
+ setReady: ct,
375
+ defaultClassification: w,
376
+ ready: $ && !!n && !!((t = j.config) != null && t.c12nDef)
377
+ };
378
+ },
379
+ [
380
+ W,
381
+ z,
382
+ N,
383
+ E,
384
+ R,
385
+ g,
386
+ k,
387
+ L,
388
+ w,
389
+ $,
390
+ n,
391
+ (tt = j.config) == null ? void 0 : tt.c12nDef
392
+ ]
393
+ );
394
+ return /* @__PURE__ */ dt(Vt.Provider, { value: ut, children: e });
395
+ };
396
+ export {
397
+ Vt as C,
398
+ zt as a,
399
+ Pt as b,
400
+ nt as u
401
+ };
@@ -1,10 +1,10 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import { BulkEnrichResponses, Selector } from "../../types/lookup";
3
3
 
4
- export declare function uri(): string;
5
- export declare function post(bulkData: Selector[], sources?: string[], options?: {
4
+ export declare const uri: () => string;
5
+ export declare const post: (bulkData: Selector[], sources?: string[], options?: {
6
6
  classification?: string;
7
7
  timeout?: number;
8
8
  includeRaw?: boolean;
9
9
  noCache?: boolean;
10
- }, config?: AxiosRequestConfig): Promise<BulkEnrichResponses>;
10
+ }, config?: AxiosRequestConfig) => Promise<BulkEnrichResponses>;