@cccsaurora/clue-ui 1.3.0-dev.404 → 1.3.0
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-CHOSKfvu.js +4403 -0
- package/AnnotationDetails-Bqq6Ymmg.js +160 -0
- package/AnnotationPreview-CqXmC-j8.js +140 -0
- package/ClueEnrichContext-DL6aGe1k.js +432 -0
- package/FlexOne-BXWFOd1T.js +6 -0
- package/_MapCache-DRK-s2eK.js +179 -0
- package/_Set-DrS_bbSV.js +6 -0
- package/_Uint8Array-D9R2N9Lp.js +98 -0
- package/_arrayIncludes-Dcl_29E6.js +25 -0
- package/_arrayPush-DBJIuK2V.js +8 -0
- package/_baseAssignValue-Bx1cxHj5.js +12 -0
- package/_baseClone-DRhywkxm.js +211 -0
- package/_baseExtremum-DodEaEyF.js +16 -0
- package/_baseFlatten-CD9NgrYE.js +72 -0
- package/_baseGet-bVwDaGrA.js +80 -0
- package/_baseGetTag-CxDaTem-.js +25 -0
- package/_baseIsEqual-C-FKsm1J.js +150 -0
- package/_baseIteratee-D0FhC5bC.js +95 -0
- package/_baseRest-D_eW2E0d.js +8 -0
- package/_baseSlice-M5RKzt1A.js +10 -0
- package/_baseSum-wEbgNeUs.js +10 -0
- package/_baseUniq-D3N8igOm.js +41 -0
- package/_cacheHas-Wgl-hw34.js +22 -0
- package/_commonjsHelpers-C6fGbg64.js +6 -0
- package/_createAggregator-BVj8IAuF.js +53 -0
- package/_defineProperty-BZU4WKA3.js +11 -0
- package/_getPrototype-BGBCg-aX.js +5 -0
- package/_getTag-B7R9qBo7.js +73 -0
- package/_isIterateeCall-Dm0VTAYy.js +13 -0
- package/_setToArray-Ck4YZu0Z.js +9 -0
- package/cloneDeep-fV59zwUf.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 +25 -29
- 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 +70 -89
- 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 +123 -166
- package/components/fetchers/FetcherResultView.js +27 -31
- package/components/fetchers/PreviewModal.js +16 -17
- 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 +32 -45
- package/countBy-B3rNuG4T.js +8 -0
- package/data/event.js +4 -6
- package/database/globals.js +2 -2
- package/database/index.js +3 -3
- package/database/replication.js +4 -4
- package/get-Bil3mzRD.js +8 -0
- package/groupBy-CrJC7sGa.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 +23 -35
- package/hooks/ClueEnrichContext.js +11 -11
- package/hooks/ClueFetcherContext.js +56 -83
- package/hooks/ClueGroupContext.js +14 -17
- package/hooks/CluePopupContext.js +5 -5
- package/hooks/ClueProvider.js +11 -13
- package/hooks/ClueUIPluginContext.js +35 -49
- package/hooks/selectors.js +7 -7
- package/hooks/useActionResult.js +3 -3
- package/hooks/useAnnotations.js +32 -48
- package/hooks/useClue.js +4 -6
- package/hooks/useClueActions.js +3 -3
- package/hooks/useClueConfig.js +4 -6
- package/hooks/useClueTypeConfig.js +24 -49
- package/hooks/useClueUIPlugins.js +7 -8
- 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-Ptb5dTKy.js +1270 -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-BH-gBhtO.js +2282 -0
- package/index-BM9Sve5T.js +571 -0
- package/index-Cj4d5cGz.js +357 -0
- package/index-Dh2PP9h8.js +11747 -0
- package/index-DoFpWPHo.js +975 -0
- package/index-DzVIklWY.js +6464 -0
- package/isArguments-BWcXOE6a.js +24 -0
- package/isArray-WzO_os3q.js +4 -0
- package/isEmpty-DKxrY-_M.js +22 -0
- package/isNil-CjWwlQS3.js +6 -0
- package/isObject-B53jY8Qg.js +7 -0
- package/isObjectLike-CYbdrIBr.js +6 -0
- package/isSymbol-DE1Kcy2M.js +9 -0
- package/last-7CdUxN0r.js +7 -0
- package/main.js +62 -62
- package/maxBy-BOWDkL_D.js +8 -0
- package/package.json +1 -1
- package/plugins/ClueUIPlugin.js +96 -163
- package/plugins/file/index.js +15 -15
- package/plugins/graph/index.js +26 -29
- package/plugins/image/index.js +24 -28
- package/plugins/json/index.js +21 -21
- package/plugins/markdown/index.js +18 -18
- package/plugins/registry.js +6 -6
- package/plugins/store.js +4 -4
- package/plugins/test/index.js +17 -17
- package/plugins/utils.js +12 -13
- package/replication-WkKbPdwG.js +8453 -0
- package/sessionStorage-DFMae61b.js +90 -0
- package/sortBy-BHe812lF.js +74 -0
- package/store-DClHBq7r.js +1169 -0
- package/sumBy-B7f_bP_k.js +8 -0
- package/text/Frequency.js +23 -42
- package/toFinite-CBrE65MP.js +14 -0
- package/toNumber-CxmWey0f.js +31 -0
- package/uniq-B4UZ671_.js +7 -0
- package/utils/chain.js +65 -92
- package/utils/classificationParser.js +256 -519
- package/utils/constants.js +11 -37
- 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 +7 -7
- package/utils/time.js +427 -447
- package/utils/utils.js +10 -10
- package/utils/window.js +10 -21
- package/utils-SpTOhPYl.js +147 -0
- package/ActionForm-CqKcnDWC.js +0 -6099
- package/AnnotationDetails-BlPd3T8k.js +0 -176
- package/AnnotationPreview-Bl447SKT.js +0 -188
- package/ClueEnrichContext-B3YrTCaJ.js +0 -567
- package/FlexOne-BSYAhhtG.js +0 -9
- package/_MapCache-kuEY_iOH.js +0 -220
- package/_Set-BrSMTlHn.js +0 -6
- package/_Uint8Array-OPpgYQj7.js +0 -123
- package/_arrayIncludes-BNqL-9ZP.js +0 -31
- package/_arrayPush-CBkQqaE_.js +0 -10
- package/_baseAssignValue-CNUVPOBW.js +0 -16
- package/_baseClone-9FaRd1R2.js +0 -287
- package/_baseExtremum-wOGT4Dgw.js +0 -18
- package/_baseFlatten-Co6QHDlG.js +0 -92
- package/_baseGet-Cmp6FztG.js +0 -109
- package/_baseGetTag-Hj-0NTYF.js +0 -44
- package/_baseIsEqual-1CpU47TZ.js +0 -211
- package/_baseIteratee-BN7Vbe5g.js +0 -126
- package/_baseRest-BZ_hQ9PC.js +0 -8
- package/_baseSlice-GAv_YFTT.js +0 -20
- package/_baseSum-D0WC1dN0.js +0 -13
- package/_baseUniq-BnvS3JHL.js +0 -63
- package/_cacheHas-_aF2y2Xv.js +0 -25
- package/_commonjsHelpers-CUmg6egw.js +0 -6
- package/_createAggregator-BUZrP_is.js +0 -63
- package/_defineProperty-DolZLKmv.js +0 -12
- package/_getPrototype-Bb4gm-5m.js +0 -5
- package/_getTag-CML_cXiN.js +0 -105
- package/_isIterateeCall-B1IFEqVv.js +0 -17
- package/_setToArray-CqyqC8ib.js +0 -10
- package/cloneDeep-l3UkXG5M.js +0 -8
- package/countBy-Bqcp3VCs.js +0 -14
- package/get-CdMThM8x.js +0 -8
- package/groupBy-BVV07EGQ.js +0 -14
- package/iconify-DJxl6dC-.js +0 -1789
- package/identity-CPGTqrE4.js +0 -6
- package/index-CAvu7vwt.js +0 -1172
- package/index-CVUD9o3t.js +0 -15768
- package/index-DUEubgWN.js +0 -464
- package/index-Dj1N4IQP.js +0 -9314
- package/index-DpJxD74E.js +0 -3272
- package/index-_gpzM2Px.js +0 -702
- package/isArguments-CuYlEuhP.js +0 -27
- package/isArray-RJPfgWqI.js +0 -4
- package/isEmpty-BE656RUK.js +0 -30
- package/isNil-CIubwp4T.js +0 -6
- package/isObject-FTY-5JQX.js +0 -7
- package/isObjectLike-CeENW9FN.js +0 -6
- package/isSymbol-D_H4HPZQ.js +0 -9
- package/last-CUCl67Im.js +0 -7
- package/maxBy-BjjQmX5t.js +0 -8
- package/replication--gLEZw8a.js +0 -11777
- package/sessionStorage-B68y-wnE.js +0 -140
- package/sortBy-B8JVsLQY.js +0 -95
- package/store-B9sjQbcS.js +0 -2163
- package/sumBy-D-HCzM2i.js +0 -8
- package/toFinite-meZTg4Su.js +0 -16
- package/toNumber-B5JaA1vX.js +0 -39
- package/uniq-CahZPAwp.js +0 -7
- package/utils-CEySTPtg.js +0 -224
|
@@ -1,567 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { a as addAPIProvider } from "./iconify-DJxl6dC-.js";
|
|
3
|
-
import { a as api, p as post } from "./index-DpJxD74E.js";
|
|
4
|
-
import { REPLICATORS } from "./database/globals.js";
|
|
5
|
-
import { clueDebugLogger } from "./utils/loggerUtil.js";
|
|
6
|
-
import { c as computeStatusId } from "./utils-CEySTPtg.js";
|
|
7
|
-
import { b as baseSlice } from "./_baseSlice-GAv_YFTT.js";
|
|
8
|
-
import { t as toFinite } from "./toFinite-meZTg4Su.js";
|
|
9
|
-
import { d as debounce } from "./sessionStorage-B68y-wnE.js";
|
|
10
|
-
import { g as groupBy } from "./groupBy-BVV07EGQ.js";
|
|
11
|
-
import { u as uniq } from "./uniq-CahZPAwp.js";
|
|
12
|
-
import { b as baseIteratee } from "./_baseIteratee-BN7Vbe5g.js";
|
|
13
|
-
import { b as baseUniq } from "./_baseUniq-BnvS3JHL.js";
|
|
14
|
-
import { useContext, useState, useMemo, useCallback, useRef, useEffect } from "react";
|
|
15
|
-
import { c as createContext } from "./index-_gpzM2Px.js";
|
|
16
|
-
import { ClueDatabaseContext } from "./hooks/ClueDatabaseContext.js";
|
|
17
|
-
import useClueConfig from "./hooks/useClueConfig.js";
|
|
18
|
-
import useClueTypeConfig from "./hooks/useClueTypeConfig.js";
|
|
19
|
-
import { i as isEmpty } from "./isEmpty-BE656RUK.js";
|
|
20
|
-
function toInteger(value) {
|
|
21
|
-
var result = toFinite(value), remainder = result % 1;
|
|
22
|
-
return result === result ? remainder ? result - remainder : result : 0;
|
|
23
|
-
}
|
|
24
|
-
var nativeCeil = Math.ceil, nativeMax = Math.max;
|
|
25
|
-
function chunk(array, size, guard) {
|
|
26
|
-
if (size === void 0) {
|
|
27
|
-
size = 1;
|
|
28
|
-
} else {
|
|
29
|
-
size = nativeMax(toInteger(size), 0);
|
|
30
|
-
}
|
|
31
|
-
var length = array == null ? 0 : array.length;
|
|
32
|
-
if (!length || size < 1) {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
var index = 0, resIndex = 0, result = Array(nativeCeil(length / size));
|
|
36
|
-
while (index < length) {
|
|
37
|
-
result[resIndex++] = baseSlice(array, index, index += size);
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
function uniqBy(array, iteratee) {
|
|
42
|
-
return array && array.length ? baseUniq(array, baseIteratee(iteratee)) : [];
|
|
43
|
-
}
|
|
44
|
-
let getRandomValues;
|
|
45
|
-
const rnds8 = new Uint8Array(16);
|
|
46
|
-
function rng() {
|
|
47
|
-
if (!getRandomValues) {
|
|
48
|
-
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
49
|
-
if (!getRandomValues) {
|
|
50
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return getRandomValues(rnds8);
|
|
54
|
-
}
|
|
55
|
-
const byteToHex = [];
|
|
56
|
-
for (let i = 0; i < 256; ++i) {
|
|
57
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
58
|
-
}
|
|
59
|
-
function unsafeStringify(arr, offset = 0) {
|
|
60
|
-
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]];
|
|
61
|
-
}
|
|
62
|
-
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
63
|
-
const native = {
|
|
64
|
-
randomUUID
|
|
65
|
-
};
|
|
66
|
-
function v4(options, buf, offset) {
|
|
67
|
-
if (native.randomUUID && true && !options) {
|
|
68
|
-
return native.randomUUID();
|
|
69
|
-
}
|
|
70
|
-
options = options || {};
|
|
71
|
-
const rnds = options.random || (options.rng || rng)();
|
|
72
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
73
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
74
|
-
return unsafeStringify(rnds);
|
|
75
|
-
}
|
|
76
|
-
const ClueEnrichContext = createContext(null);
|
|
77
|
-
const ClueEnrichProvider = ({
|
|
78
|
-
children,
|
|
79
|
-
classification: _defaultClassification,
|
|
80
|
-
baseURL,
|
|
81
|
-
getToken,
|
|
82
|
-
onNetworkCall,
|
|
83
|
-
pickSources,
|
|
84
|
-
chunkSize = 15,
|
|
85
|
-
maxRequestCount = 4,
|
|
86
|
-
defaultTimeout = 5,
|
|
87
|
-
enabled = true,
|
|
88
|
-
ready = false,
|
|
89
|
-
publicIconify = true,
|
|
90
|
-
skipConfigCall = false,
|
|
91
|
-
customIconify: _customIconify,
|
|
92
|
-
debugLogging = true
|
|
93
|
-
}) => {
|
|
94
|
-
var _a, _b, _c, _d, _e;
|
|
95
|
-
const clueConfig = useClueConfig();
|
|
96
|
-
const database = useContext(ClueDatabaseContext);
|
|
97
|
-
const [configuredDefaultClassification, setConfiguredDefaultClassification] = useState(null);
|
|
98
|
-
const defaultClassification = useMemo(
|
|
99
|
-
() => {
|
|
100
|
-
var _a2, _b2;
|
|
101
|
-
return configuredDefaultClassification ?? _defaultClassification ?? ((_b2 = (_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef) == null ? void 0 : _b2.RESTRICTED);
|
|
102
|
-
},
|
|
103
|
-
[_defaultClassification, (_b = (_a = clueConfig.config) == null ? void 0 : _a.c12nDef) == null ? void 0 : _b.RESTRICTED, configuredDefaultClassification]
|
|
104
|
-
);
|
|
105
|
-
const setDefaultClassification = useCallback(
|
|
106
|
-
(func) => {
|
|
107
|
-
var _a2;
|
|
108
|
-
return setConfiguredDefaultClassification(func((_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef));
|
|
109
|
-
},
|
|
110
|
-
[(_c = clueConfig.config) == null ? void 0 : _c.c12nDef]
|
|
111
|
-
);
|
|
112
|
-
const [isReady, setIsReady] = useState(ready);
|
|
113
|
-
const runningRequestCount = useRef(0);
|
|
114
|
-
const [sources, setSources] = useState([]);
|
|
115
|
-
const { availableSources, typesDetection, supportedTypes } = useClueTypeConfig(
|
|
116
|
-
enabled && isReady,
|
|
117
|
-
baseURL,
|
|
118
|
-
debugLogging,
|
|
119
|
-
getToken,
|
|
120
|
-
onNetworkCall
|
|
121
|
-
);
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
if (skipConfigCall || !enabled || !isReady) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const headers = {};
|
|
127
|
-
const token = getToken == null ? void 0 : getToken();
|
|
128
|
-
if (token) {
|
|
129
|
-
headers.Authorization = `Bearer ${token}`;
|
|
130
|
-
}
|
|
131
|
-
let requestConfig = { baseURL, headers };
|
|
132
|
-
if (onNetworkCall) {
|
|
133
|
-
requestConfig = onNetworkCall(requestConfig);
|
|
134
|
-
}
|
|
135
|
-
api.configs.get(requestConfig).then(clueConfig.setConfig);
|
|
136
|
-
}, [baseURL, onNetworkCall, skipConfigCall, isReady]);
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
if (isReady) {
|
|
139
|
-
Object.values(REPLICATORS).forEach((replicator) => {
|
|
140
|
-
replicator.reSync();
|
|
141
|
-
replicator.start();
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return () => {
|
|
145
|
-
Object.values(REPLICATORS).forEach((replicator) => {
|
|
146
|
-
replicator.pause();
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
}, [isReady]);
|
|
150
|
-
const [customIconify, setCustomIconify] = useState(_customIconify);
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
if (_customIconify) {
|
|
153
|
-
setCustomIconify(_customIconify);
|
|
154
|
-
}
|
|
155
|
-
}, [_customIconify]);
|
|
156
|
-
useEffect(() => {
|
|
157
|
-
if (publicIconify) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
let iconURL = customIconify ?? void 0 ?? (baseURL == null ? void 0 : baseURL.replace(/^[^.]+/, "icons"));
|
|
161
|
-
if (!iconURL && typeof window !== "undefined" && !!window && !window.location.origin.includes("localhost")) {
|
|
162
|
-
iconURL = window.location.protocol + "//" + window.location.origin.replace(/^[^.]+/, "icons");
|
|
163
|
-
}
|
|
164
|
-
if (iconURL) {
|
|
165
|
-
clueDebugLogger(`Using ${iconURL} for iconify`, debugLogging);
|
|
166
|
-
addAPIProvider("", {
|
|
167
|
-
resources: [iconURL]
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}, [baseURL, customIconify, debugLogging, publicIconify]);
|
|
171
|
-
const _addEntries = useCallback(
|
|
172
|
-
async (entries) => {
|
|
173
|
-
const newRecords = [];
|
|
174
|
-
for (const entry of entries) {
|
|
175
|
-
const { latency, source, type, value: value2, items, error } = entry;
|
|
176
|
-
await database.selectors.find({ selector: { type, value: value2, source } }).incrementalRemove();
|
|
177
|
-
if (error) {
|
|
178
|
-
newRecords.push({
|
|
179
|
-
id: v4(),
|
|
180
|
-
source,
|
|
181
|
-
type,
|
|
182
|
-
value: value2,
|
|
183
|
-
annotations: [],
|
|
184
|
-
classification: defaultClassification,
|
|
185
|
-
latency,
|
|
186
|
-
count: 0,
|
|
187
|
-
error
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
for (const item of items) {
|
|
191
|
-
const { classification, count, link, annotations } = item;
|
|
192
|
-
const record = {
|
|
193
|
-
id: v4(),
|
|
194
|
-
source,
|
|
195
|
-
type,
|
|
196
|
-
value: value2,
|
|
197
|
-
annotations,
|
|
198
|
-
classification,
|
|
199
|
-
latency,
|
|
200
|
-
count,
|
|
201
|
-
link,
|
|
202
|
-
error
|
|
203
|
-
};
|
|
204
|
-
if (newRecords.some((_entry) => _entry.id === record.id)) {
|
|
205
|
-
record.id = v4();
|
|
206
|
-
}
|
|
207
|
-
newRecords.push(record);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
const result = await database.selectors.bulkInsert(newRecords);
|
|
211
|
-
if (result.error.length > 0) {
|
|
212
|
-
console.warn("Errors on upsert:");
|
|
213
|
-
result.error.forEach((err) => console.warn(err.documentId, err.validationErrors ?? err.status));
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
[database, defaultClassification]
|
|
217
|
-
);
|
|
218
|
-
const enrich = useCallback(
|
|
219
|
-
async (type, value2, _options = {}) => {
|
|
220
|
-
var _a2;
|
|
221
|
-
if (!type || !value2) {
|
|
222
|
-
console.error(`Type (${type}) or value (${value2}) is empty, returning empty response`);
|
|
223
|
-
return {};
|
|
224
|
-
}
|
|
225
|
-
const _sources = (pickSources == null ? void 0 : pickSources(sources, availableSources, [{ type, value: value2, classification: _options.classification }])) ?? sources;
|
|
226
|
-
const options = {
|
|
227
|
-
timeout: defaultTimeout,
|
|
228
|
-
force: false,
|
|
229
|
-
includeRaw: false,
|
|
230
|
-
noCache: false,
|
|
231
|
-
classification: defaultClassification,
|
|
232
|
-
sources: _sources,
|
|
233
|
-
..._options
|
|
234
|
-
};
|
|
235
|
-
const headers = {};
|
|
236
|
-
const token = getToken == null ? void 0 : getToken();
|
|
237
|
-
if (token) {
|
|
238
|
-
headers.Authorization = `Bearer ${token}`;
|
|
239
|
-
}
|
|
240
|
-
let requestConfig = { baseURL, headers };
|
|
241
|
-
if (onNetworkCall) {
|
|
242
|
-
requestConfig = onNetworkCall(requestConfig);
|
|
243
|
-
}
|
|
244
|
-
const selector = {
|
|
245
|
-
type,
|
|
246
|
-
value: value2,
|
|
247
|
-
classification: options.classification
|
|
248
|
-
};
|
|
249
|
-
let statusRecord = await database.status.findOne({ selector: { ...selector } }).exec();
|
|
250
|
-
if (!statusRecord) {
|
|
251
|
-
statusRecord = await ((_a2 = database.status) == null ? void 0 : _a2.insert({
|
|
252
|
-
id: await computeStatusId(selector.type, selector.value, selector.classification ?? defaultClassification),
|
|
253
|
-
type: selector.type,
|
|
254
|
-
value: selector.value,
|
|
255
|
-
classification: selector.classification ?? defaultClassification,
|
|
256
|
-
status: "in-progress"
|
|
257
|
-
}));
|
|
258
|
-
} else {
|
|
259
|
-
await statusRecord.incrementalPatch({ status: "in-progress" });
|
|
260
|
-
}
|
|
261
|
-
try {
|
|
262
|
-
const enrichmentResult = await post([selector], options.sources, options, requestConfig);
|
|
263
|
-
const enrichData = Object.values(Object.values(enrichmentResult)[0])[0];
|
|
264
|
-
await _addEntries(Object.values(enrichData));
|
|
265
|
-
return enrichData;
|
|
266
|
-
} catch (e) {
|
|
267
|
-
console.error(e);
|
|
268
|
-
return {};
|
|
269
|
-
} finally {
|
|
270
|
-
await (statusRecord == null ? void 0 : statusRecord.incrementalPatch({ status: "complete" }));
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
[
|
|
274
|
-
_addEntries,
|
|
275
|
-
availableSources,
|
|
276
|
-
baseURL,
|
|
277
|
-
database,
|
|
278
|
-
defaultClassification,
|
|
279
|
-
defaultTimeout,
|
|
280
|
-
getToken,
|
|
281
|
-
onNetworkCall,
|
|
282
|
-
pickSources,
|
|
283
|
-
sources
|
|
284
|
-
]
|
|
285
|
-
);
|
|
286
|
-
const bulkEnrich = useCallback(
|
|
287
|
-
async (bulkRequest, _options) => {
|
|
288
|
-
var _a2, _b2;
|
|
289
|
-
const _sources = (pickSources == null ? void 0 : pickSources(sources, availableSources, bulkRequest)) ?? sources;
|
|
290
|
-
const options = {
|
|
291
|
-
timeout: defaultTimeout,
|
|
292
|
-
includeRaw: false,
|
|
293
|
-
noCache: false,
|
|
294
|
-
classification: defaultClassification,
|
|
295
|
-
sources: _sources,
|
|
296
|
-
..._options
|
|
297
|
-
};
|
|
298
|
-
const headers = {};
|
|
299
|
-
const token = getToken == null ? void 0 : getToken();
|
|
300
|
-
if (token) {
|
|
301
|
-
headers.Authorization = `Bearer ${token}`;
|
|
302
|
-
}
|
|
303
|
-
let requestConfig = { baseURL, headers };
|
|
304
|
-
if (onNetworkCall) {
|
|
305
|
-
requestConfig = onNetworkCall(requestConfig);
|
|
306
|
-
}
|
|
307
|
-
const statuses = [];
|
|
308
|
-
for (const selector of bulkRequest) {
|
|
309
|
-
const query = { type: selector.type, value: selector.value, classification: options.classification };
|
|
310
|
-
let statusRecord = await ((_a2 = database.status) == null ? void 0 : _a2.findOne({
|
|
311
|
-
selector: query
|
|
312
|
-
}).incrementalPatch({
|
|
313
|
-
status: "in-progress"
|
|
314
|
-
}));
|
|
315
|
-
if (!statusRecord) {
|
|
316
|
-
statusRecord = await ((_b2 = database.status) == null ? void 0 : _b2.insert({
|
|
317
|
-
id: await computeStatusId(query.type, query.value, query.classification),
|
|
318
|
-
...query,
|
|
319
|
-
status: "in-progress",
|
|
320
|
-
sources: options.sources
|
|
321
|
-
}));
|
|
322
|
-
}
|
|
323
|
-
if (statusRecord) {
|
|
324
|
-
statuses.push(statusRecord.toMutableJSON());
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
try {
|
|
328
|
-
const result = await post(bulkRequest, options.sources, options, requestConfig);
|
|
329
|
-
const entries = Object.values(result).flatMap(Object.values).flatMap(Object.values);
|
|
330
|
-
await _addEntries(entries);
|
|
331
|
-
return result;
|
|
332
|
-
} catch (e) {
|
|
333
|
-
console.error(e);
|
|
334
|
-
return {};
|
|
335
|
-
} finally {
|
|
336
|
-
database.status.bulkUpsert(
|
|
337
|
-
uniqBy(statuses, (_record) => _record.id).map((record) => {
|
|
338
|
-
record.status = "complete";
|
|
339
|
-
return record;
|
|
340
|
-
})
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
},
|
|
344
|
-
[
|
|
345
|
-
pickSources,
|
|
346
|
-
sources,
|
|
347
|
-
availableSources,
|
|
348
|
-
defaultTimeout,
|
|
349
|
-
defaultClassification,
|
|
350
|
-
getToken,
|
|
351
|
-
baseURL,
|
|
352
|
-
onNetworkCall,
|
|
353
|
-
database,
|
|
354
|
-
_addEntries
|
|
355
|
-
]
|
|
356
|
-
);
|
|
357
|
-
const enrichFailedEnrichments = useCallback(async () => {
|
|
358
|
-
if (!(database == null ? void 0 : database.selectors) || database.selectors.closed) {
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
const failedEnrichments = await database.selectors.find({ selector: { error: { $exists: true } } }).exec();
|
|
362
|
-
const byClassification = groupBy(failedEnrichments, "classification");
|
|
363
|
-
const newRequests = [];
|
|
364
|
-
for (const [classification, selectors] of Object.entries(byClassification)) {
|
|
365
|
-
const bySelector = groupBy(selectors, (_selector) => `${_selector.type}:${_selector.value}`);
|
|
366
|
-
for (const records of Object.values(bySelector)) {
|
|
367
|
-
newRequests.push({
|
|
368
|
-
id: await computeStatusId(records[0].type, records[0].value, classification),
|
|
369
|
-
type: records[0].type,
|
|
370
|
-
value: records[0].value,
|
|
371
|
-
classification,
|
|
372
|
-
sources: uniq(records.map((_record) => _record.source)).sort(),
|
|
373
|
-
status: "pending"
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
await database.status.bulkInsert(newRequests);
|
|
378
|
-
await database.selectors.bulkRemove(failedEnrichments);
|
|
379
|
-
}, [database]);
|
|
380
|
-
const enrichQueued = useMemo(
|
|
381
|
-
() => debounce(
|
|
382
|
-
async () => {
|
|
383
|
-
if (!(database == null ? void 0 : database.status)) {
|
|
384
|
-
return;
|
|
385
|
-
} else if (database.status.closed) {
|
|
386
|
-
console.warn("Status database is closed, will not enrich");
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
const selectors = await database.status.find({ selector: { status: "pending" } }).update({ $set: { status: "in-progress" } });
|
|
390
|
-
if (selectors.length < 1) {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
const chunks = chunk(selectors, chunkSize);
|
|
394
|
-
clueDebugLogger(
|
|
395
|
-
`Enriching ${selectors.length} selectors in ${chunks.length} chunks of ${chunkSize}.`,
|
|
396
|
-
debugLogging
|
|
397
|
-
);
|
|
398
|
-
await Promise.all(
|
|
399
|
-
// For performance reasons, we chunk the requests. This will allow us to take advantage of parellelization in the
|
|
400
|
-
// backend, both on the pod level and kubernetes level
|
|
401
|
-
chunks.map(async (reqsChunk) => {
|
|
402
|
-
let _interval = null;
|
|
403
|
-
if (runningRequestCount.current <= maxRequestCount) {
|
|
404
|
-
runningRequestCount.current += 1;
|
|
405
|
-
} else {
|
|
406
|
-
let startOfWait = Date.now();
|
|
407
|
-
await new Promise((res) => {
|
|
408
|
-
_interval = setInterval(() => {
|
|
409
|
-
clueDebugLogger(
|
|
410
|
-
`Waiting on ${runningRequestCount.current} existing requests to complete (total delay: ${Date.now() - startOfWait}ms)`,
|
|
411
|
-
debugLogging
|
|
412
|
-
);
|
|
413
|
-
if (runningRequestCount.current < maxRequestCount) {
|
|
414
|
-
res();
|
|
415
|
-
}
|
|
416
|
-
}, 400);
|
|
417
|
-
}).finally(() => {
|
|
418
|
-
runningRequestCount.current += 1;
|
|
419
|
-
clearInterval(_interval);
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
try {
|
|
423
|
-
const options = {};
|
|
424
|
-
const _sources = uniq(reqsChunk.flatMap((record) => record.sources ?? []));
|
|
425
|
-
if (_sources.length > 0) {
|
|
426
|
-
options.sources = _sources;
|
|
427
|
-
}
|
|
428
|
-
await bulkEnrich(
|
|
429
|
-
reqsChunk.map((record) => record.toSelector()),
|
|
430
|
-
options
|
|
431
|
-
);
|
|
432
|
-
await database.status.findByIds(reqsChunk.map((selector) => selector.id)).update({ $set: { status: "complete" } });
|
|
433
|
-
} catch (e) {
|
|
434
|
-
console.error(e);
|
|
435
|
-
} finally {
|
|
436
|
-
runningRequestCount.current -= 1;
|
|
437
|
-
if (_interval) {
|
|
438
|
-
clearInterval(_interval);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
})
|
|
442
|
-
);
|
|
443
|
-
},
|
|
444
|
-
200,
|
|
445
|
-
{ maxWait: 500, leading: false }
|
|
446
|
-
),
|
|
447
|
-
[bulkEnrich, chunkSize, database, debugLogging, maxRequestCount]
|
|
448
|
-
);
|
|
449
|
-
useEffect(() => {
|
|
450
|
-
{
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
}, [database, debugLogging]);
|
|
454
|
-
useEffect(() => {
|
|
455
|
-
if (!enabled || !isReady || !(database == null ? void 0 : database.status)) {
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
if (database == null ? void 0 : database.status.closed) {
|
|
459
|
-
console.warn("Status collection is closed");
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
const observer = database.status.find({
|
|
463
|
-
selector: {
|
|
464
|
-
status: "pending"
|
|
465
|
-
}
|
|
466
|
-
}).$.subscribe(() => enrichQueued());
|
|
467
|
-
return () => {
|
|
468
|
-
try {
|
|
469
|
-
observer == null ? void 0 : observer.unsubscribe();
|
|
470
|
-
} catch (e) {
|
|
471
|
-
console.warn(e);
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
}, [enabled, isReady, database, debugLogging, enrichQueued, (_d = database == null ? void 0 : database.status) == null ? void 0 : _d.closed]);
|
|
475
|
-
const queueEnrich = useCallback(
|
|
476
|
-
async (type, value2, classification) => {
|
|
477
|
-
var _a2, _b2;
|
|
478
|
-
if (!type) {
|
|
479
|
-
throw new Error("Type cannot be null");
|
|
480
|
-
}
|
|
481
|
-
if (!value2) {
|
|
482
|
-
throw new Error("Value cannot be null");
|
|
483
|
-
}
|
|
484
|
-
if (!database.status || database.status.closed) {
|
|
485
|
-
console.warn("status collection is closed");
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
const query = { type, value: value2, classification: classification ?? defaultClassification };
|
|
489
|
-
let statusRecord = await ((_a2 = database.status) == null ? void 0 : _a2.findOne({
|
|
490
|
-
selector: query
|
|
491
|
-
}).exec());
|
|
492
|
-
if (!statusRecord) {
|
|
493
|
-
statusRecord = await ((_b2 = database.status) == null ? void 0 : _b2.queueInsert({
|
|
494
|
-
id: await computeStatusId(query.type, query.value, query.classification),
|
|
495
|
-
...query,
|
|
496
|
-
status: "pending"
|
|
497
|
-
}));
|
|
498
|
-
}
|
|
499
|
-
return statusRecord;
|
|
500
|
-
},
|
|
501
|
-
[defaultClassification, database]
|
|
502
|
-
);
|
|
503
|
-
const guessType = useCallback(
|
|
504
|
-
(value2) => {
|
|
505
|
-
var _a2, _b2;
|
|
506
|
-
if (!value2) {
|
|
507
|
-
return null;
|
|
508
|
-
}
|
|
509
|
-
const types = Object.entries(typesDetection);
|
|
510
|
-
const regularCheck = (_a2 = types.find(([_type, _regexp]) => _regexp.exec(value2))) == null ? void 0 : _a2[0];
|
|
511
|
-
if (regularCheck) {
|
|
512
|
-
return regularCheck;
|
|
513
|
-
}
|
|
514
|
-
const lowercased = value2.toLowerCase();
|
|
515
|
-
const lowercaseCheck = (_b2 = types.find(([_type, _regexp]) => _regexp.exec(lowercased))) == null ? void 0 : _b2[0];
|
|
516
|
-
if (lowercaseCheck) {
|
|
517
|
-
return lowercaseCheck;
|
|
518
|
-
}
|
|
519
|
-
return null;
|
|
520
|
-
},
|
|
521
|
-
[typesDetection]
|
|
522
|
-
);
|
|
523
|
-
const value = useMemo(
|
|
524
|
-
() => {
|
|
525
|
-
var _a2, _b2;
|
|
526
|
-
return {
|
|
527
|
-
bulkEnrich,
|
|
528
|
-
enrich,
|
|
529
|
-
enrichFailedEnrichments,
|
|
530
|
-
sources,
|
|
531
|
-
setSources,
|
|
532
|
-
typesDetection,
|
|
533
|
-
supportedTypes,
|
|
534
|
-
availableSources,
|
|
535
|
-
guessType,
|
|
536
|
-
queueEnrich,
|
|
537
|
-
setCustomIconify,
|
|
538
|
-
setDefaultClassification,
|
|
539
|
-
setReady: setIsReady,
|
|
540
|
-
defaultClassification,
|
|
541
|
-
ready: isReady && !!database && !!((_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef) && (isEmpty(REPLICATORS) || ((_b2 = database.selectors) == null ? void 0 : _b2.synced))
|
|
542
|
-
};
|
|
543
|
-
},
|
|
544
|
-
[
|
|
545
|
-
bulkEnrich,
|
|
546
|
-
enrich,
|
|
547
|
-
enrichFailedEnrichments,
|
|
548
|
-
sources,
|
|
549
|
-
typesDetection,
|
|
550
|
-
supportedTypes,
|
|
551
|
-
availableSources,
|
|
552
|
-
guessType,
|
|
553
|
-
queueEnrich,
|
|
554
|
-
setDefaultClassification,
|
|
555
|
-
defaultClassification,
|
|
556
|
-
isReady,
|
|
557
|
-
database,
|
|
558
|
-
(_e = clueConfig.config) == null ? void 0 : _e.c12nDef
|
|
559
|
-
]
|
|
560
|
-
);
|
|
561
|
-
return /* @__PURE__ */ jsx(ClueEnrichContext.Provider, { value, children });
|
|
562
|
-
};
|
|
563
|
-
export {
|
|
564
|
-
ClueEnrichContext as C,
|
|
565
|
-
ClueEnrichProvider as a,
|
|
566
|
-
uniqBy as u
|
|
567
|
-
};
|
package/FlexOne-BSYAhhtG.js
DELETED