@cccsaurora/clue-ui 1.0.2 → 1.0.4
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/{ActionForm-BtTv0s4P.js → ActionForm-Sw7D-KOE.js} +1 -1
- package/{AnnotationDetails-D5tBIeEw.js → AnnotationDetails-BoX61_IF.js} +1 -1
- package/{AnnotationPreview-CZr_CcZC.js → AnnotationPreview-dYinoSA9.js} +1 -1
- package/ClueEnrichContext-CvCIPOMC.js +412 -0
- package/components/AnnotationDetailPopover.js +1 -1
- package/components/AnnotationDetails.js +2 -2
- package/components/AnnotationPreview.js +1 -1
- package/components/EnrichedCard.js +1 -1
- package/components/EnrichedChip.js +1 -1
- package/components/EnrichedTypography.js +1 -1
- package/components/actions/ActionForm.js +1 -1
- package/components/enrichment/EnrichPopover.js +1 -1
- package/components/group/GroupControl.js +1 -1
- package/database/index.js +1 -1
- package/hooks/ClueActionContext.js +2 -2
- package/hooks/ClueDatabaseContext.js +1 -1
- package/hooks/ClueEnrichContext.js +1 -1
- package/hooks/ClueEnrichContextType.d.ts +7 -0
- package/hooks/CluePopupContext.js +2 -2
- package/hooks/ClueProvider.js +3 -3
- package/hooks/selectors.js +2 -2
- package/hooks/useAnnotations.js +1 -1
- package/hooks/useClue.js +1 -1
- package/hooks/useClueActions.js +1 -1
- package/icons/Action.js +2 -2
- package/icons/Assessment.js +1 -1
- package/icons/Context.js +1 -1
- package/icons/Opinion.js +1 -1
- package/{index-BUcHmehh.js → index-V7wwd05F.js} +1 -1
- package/{index-Bo-v5IAc.js → index-pQg5VUAZ.js} +4743 -4763
- package/main.d.ts +3 -2
- package/main.js +35 -31
- package/package.json +1 -1
- package/types/config.d.ts +4 -1
- package/ClueEnrichContext-DH9lqjwH.js +0 -401
package/main.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { default as SourcePicker } from './components/SourcePicker';
|
|
|
23
23
|
import { SNACKBAR_EVENT_ID, SnackbarEvents } from './data/event';
|
|
24
24
|
import { default as buildDatabase } from './database';
|
|
25
25
|
import { ClueComponentContext } from './hooks/ClueComponentContext';
|
|
26
|
-
import { ClueConfigContextProps } from './hooks/ClueConfigProvider';
|
|
26
|
+
import { ClueConfigContextProps, ClueConfigContext } from './hooks/ClueConfigProvider';
|
|
27
27
|
import { ClueDatabaseContext, ClueDatabaseContextProps } from './hooks/ClueDatabaseContext';
|
|
28
28
|
import { ClueEnrichContext } from './hooks/ClueEnrichContext';
|
|
29
29
|
import { CluePopupContext } from './hooks/CluePopupContext';
|
|
@@ -31,11 +31,12 @@ import { ClueProvider } from './hooks/ClueProvider';
|
|
|
31
31
|
import { useClueActionsSelector, useClueEnrichSelector, useClueFetcherSelector } from './hooks/selectors';
|
|
32
32
|
import { default as useClue } from './hooks/useClue';
|
|
33
33
|
import { default as useClueActions } from './hooks/useClueActions';
|
|
34
|
+
import { default as useClueConfig } from './hooks/useClueConfig';
|
|
34
35
|
import { default as AssessmentIcon } from './icons/Assessment';
|
|
35
36
|
import { default as ContextIcon } from './icons/Context';
|
|
36
37
|
import { default as OpinionIcon } from './icons/Opinion';
|
|
37
38
|
import { default as FrequencyText } from './text/Frequency';
|
|
38
39
|
|
|
39
|
-
export { ActionForm, AnnotationDetailPopover, AnnotationDetails, AnnotationEntry, AnnotationPreview, AssessmentIcon, buildDatabase, ClueComponentContext, ClueDatabaseContext, ClueEnrichContext, CluePopupContext, ClueProvider, ContextIcon, CountBadge, EnrichedCard, EnrichedChip, EnrichedTypography, Entry, Fetcher, FrequencyText, Group, GroupControl, OpinionIcon, SNACKBAR_EVENT_ID, SourcePicker, StatusChip, useClue, useClueActions, useClueActionsSelector, useClueEnrichSelector, useClueFetcherSelector };
|
|
40
|
+
export { ActionForm, AnnotationDetailPopover, AnnotationDetails, AnnotationEntry, AnnotationPreview, AssessmentIcon, buildDatabase, ClueComponentContext, ClueConfigContext, ClueDatabaseContext, ClueEnrichContext, CluePopupContext, ClueProvider, ContextIcon, CountBadge, EnrichedCard, EnrichedChip, EnrichedTypography, Entry, Fetcher, FrequencyText, Group, GroupControl, OpinionIcon, SNACKBAR_EVENT_ID, SourcePicker, StatusChip, useClue, useClueActions, useClueActionsSelector, useClueConfig, useClueEnrichSelector, useClueFetcherSelector };
|
|
40
41
|
export type { ActionDefinition, ActionDefinitionsResponse, ActionResult, Annotation, BulkEnrichRequest, BulkEnrichResponses, ClueConfigContextProps, ClueDatabase, ClueDatabaseCollections, ClueDatabaseContextProps, ClueResponse, EnrichedCardProps, EnrichedTypographyProps, Enrichment, EnrichmentProps, EnrichResponse, EnrichResponses, FailedRequest, FetcherDefinition, FetcherDefinitionsResponse, FetcherResult, RunningActionData, Selector, SelectorCollection, SelectorCollectionMethods, SelectorDocMethods, SelectorDocType, SelectorDocument, SnackbarEvents, StatusCollection, StatusCollectionMethods, StatusDocMethods, StatusDocType, StatusDocument, TypesDetectionResponse, TypesResponse, WithExtra };
|
|
41
42
|
export type { ClueConfigContextProps as BorealisConfigContextProps, ClueDatabase as BorealisDatabase, ClueDatabaseCollections as BorealisDatabaseCollections, ClueDatabaseContextProps as BorealisDatabaseContextProps, ClueResponse as BorealisResponse };
|
package/main.js
CHANGED
|
@@ -1,60 +1,64 @@
|
|
|
1
|
-
import { A as t, u as r } from "./ActionForm-
|
|
1
|
+
import { A as t, u as r } from "./ActionForm-Sw7D-KOE.js";
|
|
2
2
|
import { default as f } from "./components/AnnotationDetailPopover.js";
|
|
3
|
-
import { A as
|
|
3
|
+
import { A as n } from "./AnnotationDetails-BoX61_IF.js";
|
|
4
4
|
import { default as p } from "./components/AnnotationEntry.js";
|
|
5
|
-
import { A as x, C as m } from "./AnnotationPreview-
|
|
6
|
-
import { default as
|
|
5
|
+
import { A as x, C as m } from "./AnnotationPreview-dYinoSA9.js";
|
|
6
|
+
import { default as d } from "./components/CountBadge.js";
|
|
7
7
|
import { default as c } from "./components/EnrichedCard.js";
|
|
8
8
|
import { default as h } from "./components/EnrichedChip.js";
|
|
9
9
|
import { default as S } from "./components/EnrichedTypography.js";
|
|
10
10
|
import { default as D } from "./components/fetchers/Fetcher.js";
|
|
11
11
|
import { default as b } from "./components/fetchers/StatusChip.js";
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
12
|
+
import { default as F } from "./components/group/Entry.js";
|
|
13
|
+
import { default as v } from "./components/group/Group.js";
|
|
14
14
|
import { default as B } from "./components/group/GroupControl.js";
|
|
15
15
|
import { default as N } from "./components/SourcePicker.js";
|
|
16
16
|
import { SNACKBAR_EVENT_ID as k } from "./data/event.js";
|
|
17
|
-
import { b as w } from "./index-
|
|
17
|
+
import { b as w } from "./index-pQg5VUAZ.js";
|
|
18
18
|
import { ClueComponentContext as O } from "./hooks/ClueComponentContext.js";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { default as Z } from "./
|
|
25
|
-
import { default as ee } from "./
|
|
26
|
-
import { default as te } from "./icons/
|
|
27
|
-
import { default as ae } from "./
|
|
19
|
+
import { ClueConfigContext as V } from "./hooks/ClueConfigProvider.js";
|
|
20
|
+
import { ClueDatabaseContext as z } from "./hooks/ClueDatabaseContext.js";
|
|
21
|
+
import { C as J } from "./ClueEnrichContext-CvCIPOMC.js";
|
|
22
|
+
import { ClueProvider as M } from "./hooks/ClueProvider.js";
|
|
23
|
+
import { useClueActionsSelector as U, useClueEnrichSelector as W, useClueFetcherSelector as X } from "./hooks/selectors.js";
|
|
24
|
+
import { default as Z } from "./hooks/useClue.js";
|
|
25
|
+
import { default as ee } from "./hooks/useClueConfig.js";
|
|
26
|
+
import { default as te } from "./icons/Assessment.js";
|
|
27
|
+
import { default as ae } from "./icons/Context.js";
|
|
28
|
+
import { default as ue } from "./icons/Opinion.js";
|
|
29
|
+
import { default as se } from "./text/Frequency.js";
|
|
28
30
|
export {
|
|
29
31
|
t as ActionForm,
|
|
30
32
|
f as AnnotationDetailPopover,
|
|
31
|
-
|
|
33
|
+
n as AnnotationDetails,
|
|
32
34
|
p as AnnotationEntry,
|
|
33
35
|
x as AnnotationPreview,
|
|
34
|
-
|
|
36
|
+
te as AssessmentIcon,
|
|
35
37
|
O as ClueComponentContext,
|
|
36
|
-
V as
|
|
37
|
-
z as
|
|
38
|
+
V as ClueConfigContext,
|
|
39
|
+
z as ClueDatabaseContext,
|
|
40
|
+
J as ClueEnrichContext,
|
|
38
41
|
m as CluePopupContext,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
M as ClueProvider,
|
|
43
|
+
ae as ContextIcon,
|
|
44
|
+
d as CountBadge,
|
|
42
45
|
c as EnrichedCard,
|
|
43
46
|
h as EnrichedChip,
|
|
44
47
|
S as EnrichedTypography,
|
|
45
|
-
|
|
48
|
+
F as Entry,
|
|
46
49
|
D as Fetcher,
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
se as FrequencyText,
|
|
51
|
+
v as Group,
|
|
49
52
|
B as GroupControl,
|
|
50
|
-
|
|
53
|
+
ue as OpinionIcon,
|
|
51
54
|
k as SNACKBAR_EVENT_ID,
|
|
52
55
|
N as SourcePicker,
|
|
53
56
|
b as StatusChip,
|
|
54
57
|
w as buildDatabase,
|
|
55
|
-
|
|
58
|
+
Z as useClue,
|
|
56
59
|
r as useClueActions,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
U as useClueActionsSelector,
|
|
61
|
+
ee as useClueConfig,
|
|
62
|
+
W as useClueEnrichSelector,
|
|
63
|
+
X as useClueFetcherSelector
|
|
60
64
|
};
|
package/package.json
CHANGED
package/types/config.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ClassificationDefinition } from "../utils/classificationParser";
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
export interface ApiType {
|
|
2
5
|
configuration: {
|
|
3
6
|
auth: {
|
|
@@ -12,5 +15,5 @@ export interface ApiType {
|
|
|
12
15
|
apps: any[];
|
|
13
16
|
};
|
|
14
17
|
};
|
|
15
|
-
c12nDef:
|
|
18
|
+
c12nDef: ClassificationDefinition;
|
|
16
19
|
}
|
|
@@ -1,401 +0,0 @@
|
|
|
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
|
-
};
|