@cccsaurora/clue-ui 1.2.3-dev.266 → 1.2.3
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-DlOXqMUx.js +4460 -0
- package/AnnotationDetails-Bk-p0F6h.js +160 -0
- package/AnnotationPreview-jzZvkCxJ.js +140 -0
- package/ClueEnrichContext-KqRuuWNS.js +418 -0
- package/FlexOne-BXWFOd1T.js +6 -0
- package/_MapCache-BiTi0iqu.js +180 -0
- package/_Uint8Array-BQNOM9Rr.js +101 -0
- package/_baseAssignValue-CNMLQZco.js +20 -0
- package/_baseClone-BnT-6pyM.js +207 -0
- package/_baseExtremum-Ca2EHgy2.js +16 -0
- package/_baseFlatten-Bfr_Molw.js +72 -0
- package/_baseGet-DSZygzyq.js +79 -0
- package/_baseIsEqual-VgvaAFZG.js +147 -0
- package/_baseIteratee-Dbfsw5z8.js +95 -0
- package/_baseSlice-M5RKzt1A.js +10 -0
- package/_baseSum-wEbgNeUs.js +10 -0
- package/_baseUniq-BJcj69PL.js +79 -0
- package/_commonjsHelpers-DaMA6jEr.js +8 -0
- package/_createAggregator-k3TuAnxT.js +53 -0
- package/_getPrototype-Cr1Mk7BC.js +5 -0
- package/_getTag-CK2Sffaq.js +90 -0
- package/_isIterateeCall-DkJP7Rbx.js +13 -0
- package/_setToArray-C7yMOeww.js +29 -0
- package/cloneDeep-CF8TtLHr.js +8 -0
- package/components/AnnotationBody.js +35 -49
- package/components/AnnotationDetailPopover.js +30 -36
- package/components/AnnotationDetails.js +7 -7
- package/components/AnnotationEntry.js +35 -35
- package/components/AnnotationPreview.js +5 -5
- package/components/ClassificationChip.js +23 -44
- package/components/CountBadge.js +26 -31
- package/components/EnrichedCard.js +97 -110
- package/components/EnrichedChip.js +105 -130
- package/components/EnrichedTypography.js +107 -133
- package/components/ErrorBoundary.js +24 -28
- package/components/RetryFailedEnrichments.js +9 -10
- package/components/SourcePicker.js +49 -57
- package/components/actions/ActionForm.js +4 -4
- package/components/actions/ExecutePopover.js +59 -75
- package/components/actions/ResultModal.js +4 -4
- package/components/actions/form/schemaAdapter.js +23 -39
- package/components/actions/formats/FileResult.js +59 -86
- package/components/actions/formats/index.js +10 -21
- package/components/display/graph/ExpandMoreButton.js +10 -10
- package/components/display/graph/elements/NodeCard.js +91 -111
- package/components/display/graph/elements/NodeTag.js +13 -15
- package/components/display/graph/index.js +202 -261
- package/components/display/graph/visualizations/Leaf.js +69 -88
- package/components/display/graph/visualizations/cloud/index.js +81 -98
- package/components/display/graph/visualizations/icons/BaseIcon.js +21 -26
- package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
- package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
- package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
- package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
- package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
- package/components/display/graph/visualizations/icons/index.js +13 -14
- package/components/display/graph/visualizations/panels/NodePanel.js +8 -10
- package/components/display/graph/visualizations/tree/BundleLine.js +81 -108
- package/components/display/graph/visualizations/tree/Triangle.js +13 -13
- package/components/display/graph/visualizations/tree/index.js +306 -408
- package/components/display/icons/Iconified.js +12 -27
- package/components/display/json/index.js +4 -4
- package/components/display/markdown/index.js +5770 -8678
- package/components/enrichment/EnrichPopover.js +46 -54
- package/components/fetchers/Fetcher.js +119 -158
- package/components/fetchers/PreviewModal.js +17 -20
- package/components/fetchers/StatusChip.js +17 -21
- package/components/group/Entry.js +11 -13
- package/components/group/Group.js +10 -13
- package/components/group/GroupControl.js +65 -76
- package/components/stats/QueryStatus.js +33 -43
- package/countBy-CdYegFSu.js +8 -0
- package/data/event.js +4 -6
- package/database/index.js +2 -2
- package/debounce-DryYcbJ4.js +56 -0
- package/get-CH7kz5Ix.js +8 -0
- package/groupBy-br8xmD2R.js +8 -0
- package/hooks/ClueActionContext.js +6 -6
- package/hooks/ClueComponentContext.js +23 -29
- package/hooks/ClueConfigProvider.js +12 -14
- package/hooks/ClueDatabaseContext.js +13 -19
- package/hooks/ClueEnrichContext.js +8 -8
- package/hooks/ClueFetcherContext.js +56 -83
- package/hooks/ClueGroupContext.js +14 -17
- package/hooks/CluePopupContext.js +5 -5
- package/hooks/ClueProvider.js +10 -12
- package/hooks/selectors.js +7 -7
- package/hooks/useActionResult.js +2 -2
- package/hooks/useAnnotations.js +31 -47
- package/hooks/useClue.js +4 -6
- package/hooks/useClueActions.js +3 -3
- package/hooks/useClueConfig.js +4 -6
- package/hooks/useClueTypeConfig.js +3 -3
- package/hooks/useComparator.js +435 -722
- package/hooks/useErrors.js +18 -22
- package/hooks/useFetcherResult.js +24 -33
- package/hooks/useMyHighlights.js +36 -66
- package/hooks/useMyLocalStorage.js +37 -66
- package/iconify-BBckr5AQ.js +1263 -0
- package/icons/Action.js +49 -66
- package/icons/Assessment.js +69 -85
- package/icons/Context.js +63 -77
- package/icons/Opinion.js +60 -76
- package/icons/iconMap.js +2 -2
- package/identity-ByMq8VxU.js +6 -0
- package/index-BHAe_V9n.js +12768 -0
- package/index-BK-zfYhR.js +358 -0
- package/index-CA5CUNZO.js +975 -0
- package/index-Dj5C04IX.js +568 -0
- package/index-p5_wX7q1.js +11729 -0
- package/isNil-CjWwlQS3.js +6 -0
- package/isObject-B53jY8Qg.js +7 -0
- package/isObjectLike-BatpeCIi.js +29 -0
- package/isSymbol-C3_SC0Qp.js +8 -0
- package/last-7CdUxN0r.js +7 -0
- package/main.js +60 -60
- package/maxBy-Bc0dYHcO.js +8 -0
- package/package.json +1 -1
- package/sortBy-DY2JBf9n.js +75 -0
- package/sumBy-DuMASLPd.js +8 -0
- package/text/Frequency.js +23 -42
- package/toFinite-BMy6GObD.js +14 -0
- package/toNumber-YVhnnJv4.js +31 -0
- package/useClueTypeConfig-Ct9Ygter.js +2292 -0
- package/utils/chain.js +65 -92
- package/utils/classificationParser.js +256 -519
- package/utils/constants.js +10 -35
- package/utils/graph.js +45 -72
- package/utils/hashUtil.js +7 -7
- package/utils/line.js +81 -131
- package/utils/loggerUtil.js +3 -5
- package/utils/sessionStorage.js +27 -41
- package/utils/time.js +423 -423
- package/utils/utils.js +9 -9
- package/utils/window.js +10 -21
- package/utils-DmwSUrum.js +129 -0
- package/ActionForm-uDp92tN2.js +0 -5941
- package/AnnotationDetails-DGYfOiWm.js +0 -175
- package/AnnotationPreview-bHObsb3P.js +0 -188
- package/ClueEnrichContext-CJEJxrgs.js +0 -541
- package/FlexOne-BSYAhhtG.js +0 -9
- package/_MapCache-WmuDdwuH.js +0 -222
- package/_Uint8Array-B7JqpgFX.js +0 -128
- package/_baseAssignValue-CGTuELqU.js +0 -25
- package/_baseClone-CkNrTyhm.js +0 -283
- package/_baseExtremum-kob8QXyt.js +0 -18
- package/_baseFlatten-jIR_sN_-.js +0 -92
- package/_baseGet-Bx3A4Qfp.js +0 -108
- package/_baseIsEqual-C5OTWzTk.js +0 -208
- package/_baseIteratee-avi7MX2o.js +0 -126
- package/_baseSlice-GAv_YFTT.js +0 -20
- package/_baseSum-D0WC1dN0.js +0 -13
- package/_baseUniq-BI9GIHMF.js +0 -115
- package/_commonjsHelpers-DWwsNxpa.js +0 -8
- package/_createAggregator-QD8MzKwe.js +0 -63
- package/_getPrototype-CU0j_POw.js +0 -5
- package/_getTag-Ckxxfr88.js +0 -126
- package/_isIterateeCall-Ds3sw2SF.js +0 -17
- package/_setToArray-CaPKQhcz.js +0 -33
- package/cloneDeep-DJrLSw8W.js +0 -8
- package/countBy-c6S3dvSW.js +0 -14
- package/debounce-bV0h5FC5.js +0 -92
- package/get-DSsNkRQs.js +0 -8
- package/groupBy-xqz-n0Vd.js +0 -14
- package/iconify-CXMreGTg.js +0 -1782
- package/identity-CPGTqrE4.js +0 -6
- package/index-AMfoEg_6.js +0 -696
- package/index-B6C2a_Lg.js +0 -1172
- package/index-C12gPw2W.js +0 -17698
- package/index-DCKkHTvx.js +0 -15750
- package/index-JcKyZeoY.js +0 -465
- package/isNil-CIubwp4T.js +0 -6
- package/isObject-FTY-5JQX.js +0 -7
- package/isObjectLike-OAgjjZye.js +0 -48
- package/isSymbol-Xd2FsJyp.js +0 -8
- package/last-CUCl67Im.js +0 -7
- package/maxBy-IKHzFrCS.js +0 -8
- package/sortBy-DfSj8IoJ.js +0 -96
- package/sumBy-D-hb_NY-.js +0 -8
- package/toFinite-Bc55msYj.js +0 -16
- package/toNumber-DPxy1FBy.js +0 -39
- package/useClueTypeConfig-Z1LFp01b.js +0 -3289
- package/utils-HmNPuoDB.js +0 -199
|
@@ -1,541 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { a as addAPIProvider } from "./iconify-CXMreGTg.js";
|
|
3
|
-
import { b as useClueTypeConfig, a as api, p as post, u as uniq } from "./useClueTypeConfig-Z1LFp01b.js";
|
|
4
|
-
import { clueDebugLogger } from "./utils/loggerUtil.js";
|
|
5
|
-
import { b as baseSlice } from "./_baseSlice-GAv_YFTT.js";
|
|
6
|
-
import { t as toFinite } from "./toFinite-Bc55msYj.js";
|
|
7
|
-
import { d as debounce } from "./debounce-bV0h5FC5.js";
|
|
8
|
-
import { g as groupBy } from "./groupBy-xqz-n0Vd.js";
|
|
9
|
-
import { b as baseIteratee } from "./_baseIteratee-avi7MX2o.js";
|
|
10
|
-
import { b as baseUniq } from "./_baseUniq-BI9GIHMF.js";
|
|
11
|
-
import { useContext, useState, useMemo, useCallback, useRef, useEffect } from "react";
|
|
12
|
-
import { c as createContext } from "./index-AMfoEg_6.js";
|
|
13
|
-
import { ClueDatabaseContext } from "./hooks/ClueDatabaseContext.js";
|
|
14
|
-
import useClueConfig from "./hooks/useClueConfig.js";
|
|
15
|
-
function toInteger(value) {
|
|
16
|
-
var result = toFinite(value), remainder = result % 1;
|
|
17
|
-
return result === result ? remainder ? result - remainder : result : 0;
|
|
18
|
-
}
|
|
19
|
-
var nativeCeil = Math.ceil, nativeMax = Math.max;
|
|
20
|
-
function chunk(array, size, guard) {
|
|
21
|
-
if (size === void 0) {
|
|
22
|
-
size = 1;
|
|
23
|
-
} else {
|
|
24
|
-
size = nativeMax(toInteger(size), 0);
|
|
25
|
-
}
|
|
26
|
-
var length = array == null ? 0 : array.length;
|
|
27
|
-
if (!length || size < 1) {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
var index = 0, resIndex = 0, result = Array(nativeCeil(length / size));
|
|
31
|
-
while (index < length) {
|
|
32
|
-
result[resIndex++] = baseSlice(array, index, index += size);
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
function uniqBy(array, iteratee) {
|
|
37
|
-
return array && array.length ? baseUniq(array, baseIteratee(iteratee)) : [];
|
|
38
|
-
}
|
|
39
|
-
let getRandomValues;
|
|
40
|
-
const rnds8 = new Uint8Array(16);
|
|
41
|
-
function rng() {
|
|
42
|
-
if (!getRandomValues) {
|
|
43
|
-
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
44
|
-
if (!getRandomValues) {
|
|
45
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return getRandomValues(rnds8);
|
|
49
|
-
}
|
|
50
|
-
const byteToHex = [];
|
|
51
|
-
for (let i = 0; i < 256; ++i) {
|
|
52
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
53
|
-
}
|
|
54
|
-
function unsafeStringify(arr, offset = 0) {
|
|
55
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
56
|
-
}
|
|
57
|
-
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
58
|
-
const native = {
|
|
59
|
-
randomUUID
|
|
60
|
-
};
|
|
61
|
-
function v4(options, buf, offset) {
|
|
62
|
-
if (native.randomUUID && true && !options) {
|
|
63
|
-
return native.randomUUID();
|
|
64
|
-
}
|
|
65
|
-
options = options || {};
|
|
66
|
-
const rnds = options.random || (options.rng || rng)();
|
|
67
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
68
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
69
|
-
return unsafeStringify(rnds);
|
|
70
|
-
}
|
|
71
|
-
const ClueEnrichContext = createContext(null);
|
|
72
|
-
const ClueEnrichProvider = ({
|
|
73
|
-
children,
|
|
74
|
-
classification: _defaultClassification,
|
|
75
|
-
baseURL,
|
|
76
|
-
getToken,
|
|
77
|
-
onNetworkCall,
|
|
78
|
-
pickSources,
|
|
79
|
-
chunkSize = 15,
|
|
80
|
-
maxRequestCount = 4,
|
|
81
|
-
defaultTimeout = 5,
|
|
82
|
-
enabled = true,
|
|
83
|
-
ready = false,
|
|
84
|
-
publicIconify = true,
|
|
85
|
-
skipConfigCall = false,
|
|
86
|
-
customIconify: _customIconify,
|
|
87
|
-
debugLogging = true
|
|
88
|
-
}) => {
|
|
89
|
-
var _a, _b, _c, _d, _e;
|
|
90
|
-
const clueConfig = useClueConfig();
|
|
91
|
-
const database = useContext(ClueDatabaseContext);
|
|
92
|
-
const [configuredDefaultClassification, setConfiguredDefaultClassification] = useState(null);
|
|
93
|
-
const defaultClassification = useMemo(
|
|
94
|
-
() => {
|
|
95
|
-
var _a2, _b2;
|
|
96
|
-
return configuredDefaultClassification ?? _defaultClassification ?? ((_b2 = (_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef) == null ? void 0 : _b2.RESTRICTED);
|
|
97
|
-
},
|
|
98
|
-
[_defaultClassification, (_b = (_a = clueConfig.config) == null ? void 0 : _a.c12nDef) == null ? void 0 : _b.RESTRICTED, configuredDefaultClassification]
|
|
99
|
-
);
|
|
100
|
-
const setDefaultClassification = useCallback(
|
|
101
|
-
(func) => {
|
|
102
|
-
var _a2;
|
|
103
|
-
return setConfiguredDefaultClassification(func((_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef));
|
|
104
|
-
},
|
|
105
|
-
[(_c = clueConfig.config) == null ? void 0 : _c.c12nDef]
|
|
106
|
-
);
|
|
107
|
-
const [isReady, setIsReady] = useState(ready);
|
|
108
|
-
const runningRequestCount = useRef(0);
|
|
109
|
-
const [sources, setSources] = useState([]);
|
|
110
|
-
const { availableSources, typesDetection, supportedTypes } = useClueTypeConfig(
|
|
111
|
-
enabled && isReady,
|
|
112
|
-
baseURL,
|
|
113
|
-
debugLogging,
|
|
114
|
-
getToken,
|
|
115
|
-
onNetworkCall
|
|
116
|
-
);
|
|
117
|
-
useEffect(() => {
|
|
118
|
-
if (skipConfigCall || !enabled || !isReady) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const headers = {};
|
|
122
|
-
const token = getToken == null ? void 0 : getToken();
|
|
123
|
-
if (token) {
|
|
124
|
-
headers.Authorization = `Bearer ${token}`;
|
|
125
|
-
}
|
|
126
|
-
let requestConfig = { baseURL, headers };
|
|
127
|
-
if (onNetworkCall) {
|
|
128
|
-
requestConfig = onNetworkCall(requestConfig);
|
|
129
|
-
}
|
|
130
|
-
api.configs.get(requestConfig).then(clueConfig.setConfig);
|
|
131
|
-
}, [baseURL, onNetworkCall, skipConfigCall, isReady]);
|
|
132
|
-
const [customIconify, setCustomIconify] = useState(_customIconify);
|
|
133
|
-
useEffect(() => {
|
|
134
|
-
if (_customIconify) {
|
|
135
|
-
setCustomIconify(_customIconify);
|
|
136
|
-
}
|
|
137
|
-
}, [_customIconify]);
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
if (publicIconify) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
let iconURL = customIconify ?? void 0 ?? (baseURL == null ? void 0 : baseURL.replace(/^[^.]+/, "icons"));
|
|
143
|
-
if (!iconURL && typeof window !== "undefined" && !!window && !window.location.origin.includes("localhost")) {
|
|
144
|
-
iconURL = window.location.protocol + "//" + window.location.origin.replace(/^[^.]+/, "icons");
|
|
145
|
-
}
|
|
146
|
-
if (iconURL) {
|
|
147
|
-
clueDebugLogger(`Using ${iconURL} for iconify`, debugLogging);
|
|
148
|
-
addAPIProvider("", {
|
|
149
|
-
resources: [iconURL]
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}, [baseURL, customIconify, debugLogging, publicIconify]);
|
|
153
|
-
const _addEntries = useCallback(
|
|
154
|
-
async (entries) => {
|
|
155
|
-
const newRecords = [];
|
|
156
|
-
for (const entry of entries) {
|
|
157
|
-
const { latency, source, type, value: value2, items, error } = entry;
|
|
158
|
-
if (error) {
|
|
159
|
-
newRecords.push({
|
|
160
|
-
id: v4(),
|
|
161
|
-
source,
|
|
162
|
-
type,
|
|
163
|
-
value: value2,
|
|
164
|
-
annotations: [],
|
|
165
|
-
classification: defaultClassification,
|
|
166
|
-
latency,
|
|
167
|
-
count: 0,
|
|
168
|
-
error
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
for (const item of items) {
|
|
172
|
-
const { classification, count, link, annotations } = item;
|
|
173
|
-
await database.selectors.find({ selector: { type, value: value2, source, classification } }).incrementalRemove();
|
|
174
|
-
const record = {
|
|
175
|
-
id: v4(),
|
|
176
|
-
source,
|
|
177
|
-
type,
|
|
178
|
-
value: value2,
|
|
179
|
-
annotations,
|
|
180
|
-
classification,
|
|
181
|
-
latency,
|
|
182
|
-
count,
|
|
183
|
-
link,
|
|
184
|
-
error
|
|
185
|
-
};
|
|
186
|
-
if (newRecords.some((_entry) => _entry.id === record.id)) {
|
|
187
|
-
record.id = v4();
|
|
188
|
-
}
|
|
189
|
-
newRecords.push(record);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
const result = await database.selectors.bulkInsert(newRecords);
|
|
193
|
-
if (result.error.length > 0) {
|
|
194
|
-
console.warn("Errors on upsert:");
|
|
195
|
-
result.error.forEach((err) => console.warn(err.documentId, err.validationErrors ?? err.status));
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
[database, defaultClassification]
|
|
199
|
-
);
|
|
200
|
-
const enrich = useCallback(
|
|
201
|
-
async (type, value2, _options = {}) => {
|
|
202
|
-
var _a2, _b2;
|
|
203
|
-
if (!type || !value2) {
|
|
204
|
-
console.error(`Type (${type}) or value (${value2}) is empty, returning empty response`);
|
|
205
|
-
return {};
|
|
206
|
-
}
|
|
207
|
-
const _sources = (pickSources == null ? void 0 : pickSources(sources, availableSources, [{ type, value: value2, classification: _options.classification }])) ?? sources;
|
|
208
|
-
const options = {
|
|
209
|
-
timeout: defaultTimeout,
|
|
210
|
-
force: false,
|
|
211
|
-
includeRaw: false,
|
|
212
|
-
noCache: false,
|
|
213
|
-
classification: defaultClassification,
|
|
214
|
-
sources: _sources,
|
|
215
|
-
..._options
|
|
216
|
-
};
|
|
217
|
-
const headers = {};
|
|
218
|
-
const token = getToken == null ? void 0 : getToken();
|
|
219
|
-
if (token) {
|
|
220
|
-
headers.Authorization = `Bearer ${token}`;
|
|
221
|
-
}
|
|
222
|
-
let requestConfig = { baseURL, headers };
|
|
223
|
-
if (onNetworkCall) {
|
|
224
|
-
requestConfig = onNetworkCall(requestConfig);
|
|
225
|
-
}
|
|
226
|
-
const selector = {
|
|
227
|
-
type,
|
|
228
|
-
value: value2,
|
|
229
|
-
classification: options.classification
|
|
230
|
-
};
|
|
231
|
-
let statusRecord = await ((_a2 = database.status) == null ? void 0 : _a2.findOne({ selector: { ...selector } }).exec());
|
|
232
|
-
if (!statusRecord) {
|
|
233
|
-
statusRecord = await ((_b2 = database.status) == null ? void 0 : _b2.insert({
|
|
234
|
-
id: v4(),
|
|
235
|
-
type: selector.type,
|
|
236
|
-
value: selector.value,
|
|
237
|
-
classification: selector.classification ?? defaultClassification,
|
|
238
|
-
status: "in-progress"
|
|
239
|
-
}));
|
|
240
|
-
} else {
|
|
241
|
-
await statusRecord.incrementalPatch({ status: "in-progress" });
|
|
242
|
-
}
|
|
243
|
-
try {
|
|
244
|
-
const enrichmentResult = await post([selector], options.sources, options, requestConfig);
|
|
245
|
-
const enrichData = Object.values(Object.values(enrichmentResult)[0])[0];
|
|
246
|
-
await _addEntries(Object.values(enrichData));
|
|
247
|
-
return enrichData;
|
|
248
|
-
} catch (e) {
|
|
249
|
-
console.error(e);
|
|
250
|
-
return {};
|
|
251
|
-
} finally {
|
|
252
|
-
await (statusRecord == null ? void 0 : statusRecord.incrementalPatch({ status: "complete" }));
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
[
|
|
256
|
-
_addEntries,
|
|
257
|
-
availableSources,
|
|
258
|
-
baseURL,
|
|
259
|
-
database,
|
|
260
|
-
defaultClassification,
|
|
261
|
-
defaultTimeout,
|
|
262
|
-
getToken,
|
|
263
|
-
onNetworkCall,
|
|
264
|
-
pickSources,
|
|
265
|
-
sources
|
|
266
|
-
]
|
|
267
|
-
);
|
|
268
|
-
const bulkEnrich = useCallback(
|
|
269
|
-
async (bulkRequest, _options) => {
|
|
270
|
-
const _sources = (pickSources == null ? void 0 : pickSources(sources, availableSources, bulkRequest)) ?? sources;
|
|
271
|
-
const options = {
|
|
272
|
-
timeout: defaultTimeout,
|
|
273
|
-
includeRaw: false,
|
|
274
|
-
noCache: false,
|
|
275
|
-
classification: defaultClassification,
|
|
276
|
-
sources: _sources,
|
|
277
|
-
..._options
|
|
278
|
-
};
|
|
279
|
-
const headers = {};
|
|
280
|
-
const token = getToken == null ? void 0 : getToken();
|
|
281
|
-
if (token) {
|
|
282
|
-
headers.Authorization = `Bearer ${token}`;
|
|
283
|
-
}
|
|
284
|
-
let requestConfig = { baseURL, headers };
|
|
285
|
-
if (onNetworkCall) {
|
|
286
|
-
requestConfig = onNetworkCall(requestConfig);
|
|
287
|
-
}
|
|
288
|
-
const statuses = [];
|
|
289
|
-
for (const selector of bulkRequest) {
|
|
290
|
-
const query = { type: selector.type, value: selector.value, classification: options.classification };
|
|
291
|
-
let statusRecord = await database.status.findOne({
|
|
292
|
-
selector: query
|
|
293
|
-
}).incrementalPatch({
|
|
294
|
-
status: "in-progress"
|
|
295
|
-
});
|
|
296
|
-
if (!statusRecord) {
|
|
297
|
-
statusRecord = await database.status.insert({
|
|
298
|
-
id: v4(),
|
|
299
|
-
...query,
|
|
300
|
-
status: "in-progress",
|
|
301
|
-
sources: options.sources
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
statuses.push(statusRecord.toMutableJSON());
|
|
305
|
-
}
|
|
306
|
-
try {
|
|
307
|
-
const result = await post(bulkRequest, options.sources, options, requestConfig);
|
|
308
|
-
const entries = Object.values(result).flatMap(Object.values).flatMap(Object.values);
|
|
309
|
-
await _addEntries(entries);
|
|
310
|
-
return result;
|
|
311
|
-
} catch (e) {
|
|
312
|
-
console.error(e);
|
|
313
|
-
return {};
|
|
314
|
-
} finally {
|
|
315
|
-
database.status.bulkUpsert(
|
|
316
|
-
uniqBy(statuses, (_record) => _record.id).map((record) => {
|
|
317
|
-
record.status = "complete";
|
|
318
|
-
return record;
|
|
319
|
-
})
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
[
|
|
324
|
-
pickSources,
|
|
325
|
-
sources,
|
|
326
|
-
availableSources,
|
|
327
|
-
defaultTimeout,
|
|
328
|
-
defaultClassification,
|
|
329
|
-
getToken,
|
|
330
|
-
baseURL,
|
|
331
|
-
onNetworkCall,
|
|
332
|
-
database,
|
|
333
|
-
_addEntries
|
|
334
|
-
]
|
|
335
|
-
);
|
|
336
|
-
const enrichFailedEnrichments = useCallback(async () => {
|
|
337
|
-
if (!(database == null ? void 0 : database.selectors) || database.selectors.closed) {
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
const failedEnrichments = await database.selectors.find({ selector: { error: { $exists: true } } }).exec();
|
|
341
|
-
const byClassification = groupBy(failedEnrichments, "classification");
|
|
342
|
-
const newRequests = [];
|
|
343
|
-
for (const [classification, selectors] of Object.entries(byClassification)) {
|
|
344
|
-
const bySelector = groupBy(selectors, (_selector) => `${_selector.type}:${_selector.value}`);
|
|
345
|
-
Object.values(bySelector).forEach((records) => {
|
|
346
|
-
newRequests.push({
|
|
347
|
-
id: v4(),
|
|
348
|
-
type: records[0].type,
|
|
349
|
-
value: records[0].value,
|
|
350
|
-
classification,
|
|
351
|
-
sources: uniq(records.map((_record) => _record.source)).sort(),
|
|
352
|
-
status: "pending"
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
await database.status.bulkInsert(newRequests);
|
|
357
|
-
await database.selectors.bulkRemove(failedEnrichments);
|
|
358
|
-
}, [database]);
|
|
359
|
-
const enrichQueued = useMemo(
|
|
360
|
-
() => debounce(
|
|
361
|
-
async () => {
|
|
362
|
-
if (!(database == null ? void 0 : database.status)) {
|
|
363
|
-
return;
|
|
364
|
-
} else if (database.status.closed) {
|
|
365
|
-
console.warn("Status database is closed, will not enrich");
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
const selectors = await database.status.find({ selector: { status: "pending" } }).update({ $set: { status: "in-progress" } });
|
|
369
|
-
if (selectors.length < 1) {
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
const chunks = chunk(selectors, chunkSize);
|
|
373
|
-
clueDebugLogger(
|
|
374
|
-
`Enriching ${selectors.length} selectors in ${chunks.length} chunks of ${chunkSize}.`,
|
|
375
|
-
debugLogging
|
|
376
|
-
);
|
|
377
|
-
await Promise.all(
|
|
378
|
-
// For performance reasons, we chunk the requests. This will allow us to take advantage of parellelization in the
|
|
379
|
-
// backend, both on the pod level and kubernetes level
|
|
380
|
-
chunks.map(async (reqsChunk) => {
|
|
381
|
-
let _interval = null;
|
|
382
|
-
if (runningRequestCount.current <= maxRequestCount) {
|
|
383
|
-
runningRequestCount.current += 1;
|
|
384
|
-
} else {
|
|
385
|
-
let startOfWait = Date.now();
|
|
386
|
-
await new Promise((res) => {
|
|
387
|
-
_interval = setInterval(() => {
|
|
388
|
-
clueDebugLogger(
|
|
389
|
-
`Waiting on ${runningRequestCount.current} existing requests to complete (total delay: ${Date.now() - startOfWait}ms)`,
|
|
390
|
-
debugLogging
|
|
391
|
-
);
|
|
392
|
-
if (runningRequestCount.current < maxRequestCount) {
|
|
393
|
-
res();
|
|
394
|
-
}
|
|
395
|
-
}, 400);
|
|
396
|
-
}).finally(() => {
|
|
397
|
-
runningRequestCount.current += 1;
|
|
398
|
-
clearInterval(_interval);
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
try {
|
|
402
|
-
const options = {};
|
|
403
|
-
const _sources = uniq(reqsChunk.flatMap((record) => record.sources ?? []));
|
|
404
|
-
if (_sources.length > 0) {
|
|
405
|
-
options.sources = _sources;
|
|
406
|
-
}
|
|
407
|
-
await bulkEnrich(
|
|
408
|
-
reqsChunk.map((record) => record.toSelector()),
|
|
409
|
-
options
|
|
410
|
-
);
|
|
411
|
-
await database.status.findByIds(reqsChunk.map((selector) => selector.id)).update({ $set: { status: "complete" } });
|
|
412
|
-
} catch (e) {
|
|
413
|
-
console.error(e);
|
|
414
|
-
} finally {
|
|
415
|
-
runningRequestCount.current -= 1;
|
|
416
|
-
if (_interval) {
|
|
417
|
-
clearInterval(_interval);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
})
|
|
421
|
-
);
|
|
422
|
-
},
|
|
423
|
-
200,
|
|
424
|
-
{ maxWait: 500, leading: false }
|
|
425
|
-
),
|
|
426
|
-
[bulkEnrich, chunkSize, database, debugLogging, maxRequestCount]
|
|
427
|
-
);
|
|
428
|
-
useEffect(() => {
|
|
429
|
-
{
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
}, [database, debugLogging]);
|
|
433
|
-
useEffect(() => {
|
|
434
|
-
if (!enabled || !isReady || !(database == null ? void 0 : database.status)) {
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
if (database == null ? void 0 : database.status.closed) {
|
|
438
|
-
console.warn("Status collection is closed");
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
const observer = database.status.find({
|
|
442
|
-
selector: {
|
|
443
|
-
status: "pending"
|
|
444
|
-
}
|
|
445
|
-
}).$.subscribe(() => enrichQueued());
|
|
446
|
-
return () => {
|
|
447
|
-
try {
|
|
448
|
-
observer == null ? void 0 : observer.unsubscribe();
|
|
449
|
-
} catch (e) {
|
|
450
|
-
console.warn(e);
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
}, [enabled, isReady, database, debugLogging, enrichQueued, (_d = database == null ? void 0 : database.status) == null ? void 0 : _d.closed]);
|
|
454
|
-
const queueEnrich = useCallback(
|
|
455
|
-
async (type, value2, classification) => {
|
|
456
|
-
if (!type) {
|
|
457
|
-
throw new Error("Type cannot be null");
|
|
458
|
-
}
|
|
459
|
-
if (!value2) {
|
|
460
|
-
throw new Error("Value cannot be null");
|
|
461
|
-
}
|
|
462
|
-
const query = { type, value: value2, classification: classification ?? defaultClassification };
|
|
463
|
-
let statusRecord = await database.status.findOne({
|
|
464
|
-
selector: query
|
|
465
|
-
}).exec();
|
|
466
|
-
if (!statusRecord) {
|
|
467
|
-
statusRecord = await database.status.queueInsert({
|
|
468
|
-
id: v4(),
|
|
469
|
-
...query,
|
|
470
|
-
status: "pending"
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
return statusRecord;
|
|
474
|
-
},
|
|
475
|
-
[defaultClassification, database]
|
|
476
|
-
);
|
|
477
|
-
const guessType = useCallback(
|
|
478
|
-
(value2) => {
|
|
479
|
-
var _a2, _b2;
|
|
480
|
-
if (!value2) {
|
|
481
|
-
return null;
|
|
482
|
-
}
|
|
483
|
-
const types = Object.entries(typesDetection);
|
|
484
|
-
const regularCheck = (_a2 = types.find(([_type, _regexp]) => _regexp.exec(value2))) == null ? void 0 : _a2[0];
|
|
485
|
-
if (regularCheck) {
|
|
486
|
-
return regularCheck;
|
|
487
|
-
}
|
|
488
|
-
const lowercased = value2.toLowerCase();
|
|
489
|
-
const lowercaseCheck = (_b2 = types.find(([_type, _regexp]) => _regexp.exec(lowercased))) == null ? void 0 : _b2[0];
|
|
490
|
-
if (lowercaseCheck) {
|
|
491
|
-
return lowercaseCheck;
|
|
492
|
-
}
|
|
493
|
-
return null;
|
|
494
|
-
},
|
|
495
|
-
[typesDetection]
|
|
496
|
-
);
|
|
497
|
-
const value = useMemo(
|
|
498
|
-
() => {
|
|
499
|
-
var _a2;
|
|
500
|
-
return {
|
|
501
|
-
bulkEnrich,
|
|
502
|
-
enrich,
|
|
503
|
-
enrichFailedEnrichments,
|
|
504
|
-
sources,
|
|
505
|
-
setSources,
|
|
506
|
-
typesDetection,
|
|
507
|
-
supportedTypes,
|
|
508
|
-
availableSources,
|
|
509
|
-
guessType,
|
|
510
|
-
queueEnrich,
|
|
511
|
-
setCustomIconify,
|
|
512
|
-
setDefaultClassification,
|
|
513
|
-
setReady: setIsReady,
|
|
514
|
-
defaultClassification,
|
|
515
|
-
ready: isReady && !!database && !!((_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef)
|
|
516
|
-
};
|
|
517
|
-
},
|
|
518
|
-
[
|
|
519
|
-
bulkEnrich,
|
|
520
|
-
enrich,
|
|
521
|
-
enrichFailedEnrichments,
|
|
522
|
-
sources,
|
|
523
|
-
typesDetection,
|
|
524
|
-
supportedTypes,
|
|
525
|
-
availableSources,
|
|
526
|
-
guessType,
|
|
527
|
-
queueEnrich,
|
|
528
|
-
setDefaultClassification,
|
|
529
|
-
defaultClassification,
|
|
530
|
-
isReady,
|
|
531
|
-
database,
|
|
532
|
-
(_e = clueConfig.config) == null ? void 0 : _e.c12nDef
|
|
533
|
-
]
|
|
534
|
-
);
|
|
535
|
-
return /* @__PURE__ */ jsx(ClueEnrichContext.Provider, { value, children });
|
|
536
|
-
};
|
|
537
|
-
export {
|
|
538
|
-
ClueEnrichContext as C,
|
|
539
|
-
ClueEnrichProvider as a,
|
|
540
|
-
uniqBy as u
|
|
541
|
-
};
|
package/FlexOne-BSYAhhtG.js
DELETED