@cccsaurora/clue-ui 1.1.0-dev.10 → 1.1.0-dev.100
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-D4ryHO0M.js → ActionForm-ByeOzpc4.js} +162 -43
- package/{AnnotationDetails-YAPoqw3R.js → AnnotationDetails-DknbKDyl.js} +1 -1
- package/{AnnotationPreview-DiQDjt9s.js → AnnotationPreview-CQwKs8se.js} +2 -2
- package/{ClueEnrichContext-DIn6g8tw.js → ClueEnrichContext-6NJfXpUB.js} +27 -13
- package/_commonjsHelpers-DWwsNxpa.js +8 -0
- package/api/lookup/index.d.ts +1 -1
- package/api/lookup/types.d.ts +2 -2
- package/api/lookup/types_detection.d.ts +2 -2
- package/components/AnnotationBody.js +1 -1
- package/components/AnnotationDetailPopover.js +1 -1
- package/components/AnnotationDetails.js +2 -2
- package/components/AnnotationEntry.js +1 -1
- package/components/AnnotationPreview.js +2 -2
- package/components/ClassificationChip.d.ts +2 -1
- package/components/EnrichedCard.js +11 -5
- package/components/EnrichedChip.js +4 -10
- package/components/EnrichedTypography.d.ts +1 -1
- package/components/EnrichedTypography.js +7 -12
- package/components/actions/ActionForm.js +3 -3
- package/components/actions/ResultModal.js +12 -44
- package/components/actions/form/schemaAdapter.js +4 -3
- package/components/display/graph/elements/NodeCard.js +26 -4
- package/components/display/graph/index.js +15 -16
- package/components/display/json/index.js +2 -2
- package/components/display/markdown/index.js +190 -19
- package/components/enrichment/EnrichPopover.js +1 -1
- package/components/fetchers/Fetcher.js +1 -1
- package/components/fetchers/StatusChip.js +0 -1
- package/components/group/Entry.js +1 -1
- package/components/group/GroupControl.js +3 -2
- package/components/stats/QueryStatus.js +8 -4
- package/database/index.js +1 -1
- package/en/translation.json +39 -59
- package/fr/translation.json +37 -56
- package/hooks/ClueActionContext.d.ts +26 -0
- package/hooks/ClueActionContext.js +5 -4
- package/hooks/ClueDatabaseContext.js +1 -1
- package/hooks/ClueEnrichContext.js +2 -2
- package/hooks/ClueEnrichContextType.d.ts +7 -0
- package/hooks/ClueEnrichProps.d.ts +3 -1
- package/hooks/ClueFetcherContext.js +1 -1
- package/hooks/CluePopupContext.js +2 -2
- package/hooks/ClueProvider.js +3 -3
- package/hooks/selectors.d.ts +4 -5
- package/hooks/selectors.js +3 -4
- package/hooks/useActionResult.d.ts +14 -0
- package/hooks/useActionResult.js +5 -0
- package/hooks/useAnnotations.js +1 -1
- package/hooks/useClue.js +1 -1
- package/hooks/useClueActions.d.ts +1 -1
- package/hooks/useClueActions.js +1 -1
- package/hooks/useClueConfig.d.ts +2 -1
- package/hooks/useClueConfig.js +2 -2
- package/hooks/useClueTypeConfig.js +1 -1
- package/hooks/useMyLocalStorage.d.ts +4 -3
- package/hooks/useMyLocalStorage.js +6 -6
- package/icons/Action.js +2 -2
- package/icons/Assessment.js +1 -1
- package/icons/Context.js +6 -3
- package/icons/Opinion.js +1 -1
- package/{index-BMxyILVD.js → index-Bi21Wb23.js} +1 -1
- package/{index-BHPT3qoB.js → index-C3lkTD69.js} +1 -1
- package/{index-Dz1kF2MU.js → index-CC12Ux-9.js} +2 -2
- package/main.d.ts +3 -2
- package/main.js +17 -13
- package/package.json +3 -3
- package/types/RunningActionData.d.ts +4 -3
- package/types/action.d.ts +10 -1
- package/types/config.d.ts +4 -1
- package/{useClueTypeConfig-CH-nGq6a.js → useClueTypeConfig-XvGvIw2S.js} +54 -37
- package/utils/graph.js +4 -4
- package/utils/loggerUtil.d.ts +1 -1
- package/utils/loggerUtil.js +2 -2
- package/utils/sessionStorage.js +1 -1
- package/utils/time.d.ts +3 -0
- package/utils/time.js +536 -0
- package/utils/utils.js +2 -1
- package/utils-7OtvGnmf.js +200 -0
- package/_commonjsHelpers-CUmg6egw.js +0 -6
- package/components/display/markdown/DynamicTabs.d.ts +0 -8
- package/components/display/markdown/DynamicTabs.js +0 -26
- package/components/display/markdown/markdownPlugins/tabs.d.ts +0 -3
- package/components/display/markdown/markdownPlugins/tabs.js +0 -4
- package/tabs-xGuUGsJd.js +0 -254
- package/utils-Dr4wbKBZ.js +0 -4182
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { materialRenderers, materialCells } from "@jsonforms/material-renderers";
|
|
3
3
|
import { JsonForms } from "@jsonforms/react";
|
|
4
|
-
import {
|
|
4
|
+
import { Modal, Paper, Stack, Typography, Divider, LinearProgress, Button, IconButton, Box, CircularProgress, Collapse } from "@mui/material";
|
|
5
5
|
import Iconified from "./components/display/icons/Iconified.js";
|
|
6
|
-
import { J as JSONViewer } from "./index-
|
|
6
|
+
import { J as JSONViewer } from "./index-Bi21Wb23.js";
|
|
7
7
|
import { ClueComponentContext } from "./hooks/ClueComponentContext.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { a as api } from "./useClueTypeConfig-CH-nGq6a.js";
|
|
8
|
+
import { A as Ajv } from "./index-CC12Ux-9.js";
|
|
9
|
+
import { a as api } from "./useClueTypeConfig-XvGvIw2S.js";
|
|
11
10
|
import { d as toString } from "./_baseGet-BSK_nnoz.js";
|
|
12
11
|
import { b as baseSlice } from "./_baseSlice-GAv_YFTT.js";
|
|
13
|
-
import { i as isEqual } from "./utils-
|
|
14
|
-
import { useState,
|
|
12
|
+
import { i as isEqual } from "./utils-7OtvGnmf.js";
|
|
13
|
+
import { useState, useRef, useMemo, useEffect, memo, useCallback } from "react";
|
|
14
|
+
import { u as useContextSelector, c as createContext, a as useContext } from "./index-BDVjGvMI.js";
|
|
15
15
|
import ErrorBoundary from "./components/ErrorBoundary.js";
|
|
16
16
|
import { adaptSchema } from "./components/actions/form/schemaAdapter.js";
|
|
17
|
-
import
|
|
17
|
+
import { I as Icon } from "./iconify-CXMreGTg.js";
|
|
18
|
+
import Markdown from "./components/display/markdown/index.js";
|
|
19
|
+
import ClassificationChip from "./components/ClassificationChip.js";
|
|
18
20
|
import { SNACKBAR_EVENT_ID } from "./data/event.js";
|
|
21
|
+
import { dayjs } from "./utils/time.js";
|
|
19
22
|
import { safeDispatchEvent } from "./utils/window.js";
|
|
20
23
|
import useClue from "./hooks/useClue.js";
|
|
24
|
+
import { i as isNil } from "./isNil-CIubwp4T.js";
|
|
21
25
|
function castSlice(array, start, end) {
|
|
22
26
|
var length = array.length;
|
|
23
27
|
end = end === void 0 ? length : end;
|
|
@@ -55,16 +59,92 @@ var upperFirst = createCaseFirst("toUpperCase");
|
|
|
55
59
|
function capitalize(string) {
|
|
56
60
|
return upperFirst(toString(string).toLowerCase());
|
|
57
61
|
}
|
|
62
|
+
const useActionResult = (resultWithData, interval = 2e3) => {
|
|
63
|
+
const [result, setResult] = useState(resultWithData);
|
|
64
|
+
const timeoutRef = useRef(null);
|
|
65
|
+
const { getActionStatus } = useClueActions();
|
|
66
|
+
const taskId = useMemo(() => resultWithData == null ? void 0 : resultWithData.task_id, [resultWithData == null ? void 0 : resultWithData.task_id]);
|
|
67
|
+
const actionId = useMemo(() => resultWithData == null ? void 0 : resultWithData.actionId, [resultWithData == null ? void 0 : resultWithData.actionId]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if ((resultWithData == null ? void 0 : resultWithData.outcome) !== "pending" || !taskId) return;
|
|
70
|
+
let cancelled = false;
|
|
71
|
+
const poll = async () => {
|
|
72
|
+
const res = await getActionStatus(actionId, taskId);
|
|
73
|
+
if (!res) {
|
|
74
|
+
setResult({ outcome: "failure", done: true });
|
|
75
|
+
} else if (res.outcome === "success" || res.outcome === "failure") {
|
|
76
|
+
setResult({ ...res, done: true });
|
|
77
|
+
} else {
|
|
78
|
+
if (cancelled) return;
|
|
79
|
+
setResult({ ...res });
|
|
80
|
+
timeoutRef.current = setTimeout(poll, interval);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
poll();
|
|
84
|
+
return () => {
|
|
85
|
+
cancelled = true;
|
|
86
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
87
|
+
};
|
|
88
|
+
}, [actionId, getActionStatus, interval, resultWithData == null ? void 0 : resultWithData.outcome, taskId]);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
setResult(resultWithData);
|
|
91
|
+
}, [resultWithData]);
|
|
92
|
+
return useMemo(
|
|
93
|
+
() => resultWithData || result ? { ...resultWithData, ...result } : void 0,
|
|
94
|
+
[resultWithData, result]
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
const ResultModal = ({ result: _result, onClose, show = false }) => {
|
|
98
|
+
var _a, _b;
|
|
99
|
+
const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
|
|
100
|
+
const result = useActionResult(_result);
|
|
101
|
+
if (!result) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return /* @__PURE__ */ jsx(Modal, { open: show, sx: { display: "flex", alignItems: "center", justifyContent: "center" }, onClose, children: /* @__PURE__ */ jsx(Paper, { sx: { maxHeight: "80%", maxWidth: "80%", height: "100%", p: 2, minWidth: "750px" }, children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs(Stack, { spacing: 1, height: "100%", children: [
|
|
105
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
|
|
106
|
+
result.action.action_icon && /* @__PURE__ */ jsx(Icon, { height: "1.5rem", icon: result.action.action_icon }),
|
|
107
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h5", children: result.action.name }),
|
|
108
|
+
result.action.supported_types && /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: result.action.supported_types.map((type) => type.toUpperCase()).join(", ") }),
|
|
109
|
+
/* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
|
|
110
|
+
/* @__PURE__ */ jsx(ClassificationChip, { size: "small", classification: result.action.classification })
|
|
111
|
+
] }),
|
|
112
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body1", children: result.action.summary }),
|
|
113
|
+
/* @__PURE__ */ jsx(Divider, { flexItem: true }),
|
|
114
|
+
result.done ? /* @__PURE__ */ jsx(ErrorBoundary, { children: result.format === "markdown" ? /* @__PURE__ */ jsx(Markdown, { md: result.output }) : result.format === "json" ? /* @__PURE__ */ jsx(JSONViewer, { data: result.output, collapse: true, forceCompact: true }) : /* @__PURE__ */ jsxs(Stack, { sx: { overflowY: "auto" }, children: [
|
|
115
|
+
/* @__PURE__ */ jsx(Markdown, { md: "`" + result.format + "` is not recognized as a format in this application." }),
|
|
116
|
+
/* @__PURE__ */ jsx(JSONViewer, { data: result, collapse: true, forceCompact: true })
|
|
117
|
+
] }) }) : /* @__PURE__ */ jsxs(Stack, { flex: 1, sx: { pt: 2, alignItems: "center" }, spacing: 1, children: [
|
|
118
|
+
result.summary && /* @__PURE__ */ jsx(Typography, { variant: "caption", children: result.summary }),
|
|
119
|
+
/* @__PURE__ */ jsx(
|
|
120
|
+
LinearProgress,
|
|
121
|
+
{
|
|
122
|
+
variant: ((_a = result.output) == null ? void 0 : _a.progress) ? "determinate" : "indeterminate",
|
|
123
|
+
value: ((_b = result.output) == null ? void 0 : _b.progress) * 100,
|
|
124
|
+
sx: { maxWidth: 500, width: "100%", borderRadius: (theme) => theme.shape.borderRadius }
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
] }),
|
|
128
|
+
/* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
|
|
129
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
|
|
130
|
+
/* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
|
|
131
|
+
result.link && /* @__PURE__ */ jsx(Button, { variant: "outlined", component: "a", target: "_blank", href: result.link, children: t("details.open") }),
|
|
132
|
+
/* @__PURE__ */ jsx(Button, { variant: "outlined", color: "error", onClick: onClose, children: t("close") })
|
|
133
|
+
] })
|
|
134
|
+
] }) }) }) });
|
|
135
|
+
};
|
|
136
|
+
const ResultModal$1 = memo(ResultModal);
|
|
58
137
|
const AJV = new Ajv({ removeAdditional: true, coerceTypes: true, strict: false });
|
|
59
138
|
const ClueActionContext = createContext(null);
|
|
60
139
|
const ClueActionProvider = ({
|
|
61
140
|
baseURL,
|
|
62
141
|
children,
|
|
63
142
|
classification: defaultClassification,
|
|
143
|
+
includeContext: defaultIncludeContext,
|
|
64
144
|
getToken,
|
|
65
145
|
onNetworkCall
|
|
66
146
|
}) => {
|
|
67
|
-
const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
|
|
147
|
+
const { t, i18n } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
|
|
68
148
|
const { ready } = useClue();
|
|
69
149
|
const [runningActionData, setRunningActionData] = useState(null);
|
|
70
150
|
const [actionResults, setActionResults] = useState({});
|
|
@@ -72,25 +152,25 @@ const ClueActionProvider = ({
|
|
|
72
152
|
const [lastResult, setLastResult] = useState(null);
|
|
73
153
|
const [loading, setLoading] = useState(false);
|
|
74
154
|
const [availableActions, setAvailableActions] = useState({});
|
|
75
|
-
const
|
|
76
|
-
if (!ready) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
155
|
+
const requestConfig = useMemo(() => {
|
|
79
156
|
const headers = {};
|
|
80
157
|
const token = getToken == null ? void 0 : getToken();
|
|
81
158
|
if (token) {
|
|
82
159
|
headers.Authorization = `Bearer ${token}`;
|
|
83
160
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
161
|
+
const baseConfig = { baseURL, headers };
|
|
162
|
+
return onNetworkCall ? onNetworkCall(baseConfig) : { baseURL, headers };
|
|
163
|
+
}, [baseURL, getToken, onNetworkCall]);
|
|
164
|
+
const refreshActions = useCallback(async () => {
|
|
165
|
+
if (!ready) {
|
|
166
|
+
return;
|
|
87
167
|
}
|
|
88
168
|
const _actions = await api.actions.get(requestConfig);
|
|
89
169
|
if (_actions) {
|
|
90
170
|
setAvailableActions(_actions);
|
|
91
171
|
}
|
|
92
172
|
return _actions;
|
|
93
|
-
}, [
|
|
173
|
+
}, [ready, requestConfig]);
|
|
94
174
|
useEffect(() => {
|
|
95
175
|
refreshActions();
|
|
96
176
|
}, [baseURL, ready]);
|
|
@@ -100,18 +180,15 @@ const ClueActionProvider = ({
|
|
|
100
180
|
);
|
|
101
181
|
const executeAction = useCallback(
|
|
102
182
|
async (actionId, selectors, params, options) => {
|
|
103
|
-
const { forceMenu, onComplete, skipMenu, timeout } = {
|
|
183
|
+
const { forceMenu, onComplete, skipMenu, skipResultModal, timeout, includeContext, extraContext } = {
|
|
104
184
|
forceMenu: false,
|
|
105
185
|
skipMenu: false,
|
|
106
186
|
onComplete: null,
|
|
107
187
|
timeout: null,
|
|
188
|
+
includeContext: defaultIncludeContext ?? false,
|
|
189
|
+
extraContext: null,
|
|
108
190
|
...options
|
|
109
191
|
};
|
|
110
|
-
const headers = {};
|
|
111
|
-
const token = getToken == null ? void 0 : getToken();
|
|
112
|
-
if (token) {
|
|
113
|
-
headers.Authorization = `Bearer ${token}`;
|
|
114
|
-
}
|
|
115
192
|
if (!Object.keys(availableActions).includes(actionId)) {
|
|
116
193
|
throw new Error("Invalid action id");
|
|
117
194
|
}
|
|
@@ -121,6 +198,20 @@ const ClueActionProvider = ({
|
|
|
121
198
|
const actionToRun = availableActions[actionId];
|
|
122
199
|
const validator = AJV.compile(actionToRun.params);
|
|
123
200
|
const validatedParams = { selectors: stringifiedSelectors, ...params };
|
|
201
|
+
let context2 = null;
|
|
202
|
+
if (includeContext) {
|
|
203
|
+
context2 = {
|
|
204
|
+
timestamp: dayjs().toISOString(),
|
|
205
|
+
url: window.location,
|
|
206
|
+
language: (i18n == null ? void 0 : i18n.language) ?? "en"
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (!isNil(extraContext)) {
|
|
210
|
+
context2 = {
|
|
211
|
+
...context2 ?? {},
|
|
212
|
+
...extraContext
|
|
213
|
+
};
|
|
214
|
+
}
|
|
124
215
|
setLoading(true);
|
|
125
216
|
if (!validator(validatedParams) || forceMenu) {
|
|
126
217
|
if (skipMenu && !forceMenu) {
|
|
@@ -143,20 +234,18 @@ const ClueActionProvider = ({
|
|
|
143
234
|
action: actionToRun,
|
|
144
235
|
selectors,
|
|
145
236
|
params: validatedParams ?? {},
|
|
237
|
+
context: context2,
|
|
146
238
|
onComplete,
|
|
147
239
|
timeout
|
|
148
240
|
});
|
|
149
241
|
return;
|
|
150
242
|
}
|
|
151
243
|
try {
|
|
152
|
-
let requestConfig = { baseURL, headers };
|
|
153
|
-
if (onNetworkCall) {
|
|
154
|
-
requestConfig = onNetworkCall(requestConfig);
|
|
155
|
-
}
|
|
156
244
|
const actionResult = await api.actions.post(
|
|
157
245
|
actionId,
|
|
158
246
|
stringifiedSelectors,
|
|
159
247
|
validatedParams ?? {},
|
|
248
|
+
context2,
|
|
160
249
|
{ timeout },
|
|
161
250
|
requestConfig
|
|
162
251
|
);
|
|
@@ -183,7 +272,7 @@ const ClueActionProvider = ({
|
|
|
183
272
|
actionResult.link && /* @__PURE__ */ jsx(IconButton, { component: "a", href: actionResult.link, size: "small", target: "_blank", children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-open-in-new", fontSize: "small" }) })
|
|
184
273
|
] }),
|
|
185
274
|
timeout: actionResult.link ? null : 5e3,
|
|
186
|
-
level: actionResult.outcome === "success" ? "success" : "error",
|
|
275
|
+
level: actionResult.outcome === "success" ? "success" : actionResult.outcome === "pending" ? "info" : "error",
|
|
187
276
|
options: {
|
|
188
277
|
style: {
|
|
189
278
|
minWidth: 0
|
|
@@ -200,9 +289,15 @@ const ClueActionProvider = ({
|
|
|
200
289
|
if (actionResult.outcome === "success") {
|
|
201
290
|
setRunningActionData(null);
|
|
202
291
|
}
|
|
292
|
+
if (actionResult.outcome === "pending") {
|
|
293
|
+
setLastResult({ ...actionResult, actionId, action: actionToRun });
|
|
294
|
+
if (!skipResultModal) {
|
|
295
|
+
setShowResultModal(true);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
203
298
|
if (actionResult.format) {
|
|
204
299
|
setLastResult({ ...actionResult, actionId, action: actionToRun });
|
|
205
|
-
if (actionResult.format !== "pivot") {
|
|
300
|
+
if (actionResult.format !== "pivot" && !skipResultModal) {
|
|
206
301
|
setShowResultModal(true);
|
|
207
302
|
} else {
|
|
208
303
|
window.open(actionResult.output, "_blank", "noreferrer");
|
|
@@ -221,7 +316,25 @@ const ClueActionProvider = ({
|
|
|
221
316
|
setLoading(false);
|
|
222
317
|
}
|
|
223
318
|
},
|
|
224
|
-
[availableActions,
|
|
319
|
+
[availableActions, defaultIncludeContext, getHashKey, i18n == null ? void 0 : i18n.language, requestConfig, runningActionData == null ? void 0 : runningActionData.id, t]
|
|
320
|
+
);
|
|
321
|
+
const getActionStatus = useCallback(
|
|
322
|
+
async (actionId, taskId) => {
|
|
323
|
+
try {
|
|
324
|
+
const res = await api.actions.status.get(actionId, taskId, {}, requestConfig);
|
|
325
|
+
return res;
|
|
326
|
+
} catch (e) {
|
|
327
|
+
safeDispatchEvent(
|
|
328
|
+
new CustomEvent(SNACKBAR_EVENT_ID, {
|
|
329
|
+
detail: {
|
|
330
|
+
message: e.toString(),
|
|
331
|
+
level: "error"
|
|
332
|
+
}
|
|
333
|
+
})
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
[requestConfig]
|
|
225
338
|
);
|
|
226
339
|
const cancelAction = useCallback(() => {
|
|
227
340
|
setRunningActionData(null);
|
|
@@ -236,18 +349,19 @@ const ClueActionProvider = ({
|
|
|
236
349
|
availableActions,
|
|
237
350
|
executeAction,
|
|
238
351
|
cancelAction,
|
|
352
|
+
getActionStatus,
|
|
239
353
|
getActionResults,
|
|
240
354
|
loading,
|
|
241
355
|
refreshActions
|
|
242
356
|
}),
|
|
243
|
-
[availableActions, cancelAction, executeAction, getActionResults, loading, refreshActions]
|
|
357
|
+
[availableActions, cancelAction, executeAction, getActionResults, getActionStatus, loading, refreshActions]
|
|
244
358
|
);
|
|
245
359
|
return /* @__PURE__ */ jsxs(ClueActionContext.Provider, { value: context, children: [
|
|
246
360
|
children,
|
|
247
361
|
/* @__PURE__ */ jsxs(ErrorBoundary, { children: [
|
|
248
362
|
runningActionData && /* @__PURE__ */ jsx(ActionForm$1, { runningActionData }),
|
|
249
363
|
/* @__PURE__ */ jsx(
|
|
250
|
-
ResultModal,
|
|
364
|
+
ResultModal$1,
|
|
251
365
|
{
|
|
252
366
|
show: showResultModal && !!lastResult,
|
|
253
367
|
result: lastResult,
|
|
@@ -284,16 +398,19 @@ const ActionForm = ({ runningActionData }) => {
|
|
|
284
398
|
} else {
|
|
285
399
|
return +(formSchema == null ? void 0 : formSchema.required.includes(a_key)) - +(formSchema == null ? void 0 : formSchema.required.includes(b_key));
|
|
286
400
|
}
|
|
287
|
-
}).map(([key, value]) =>
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
401
|
+
}).map(([key, value]) => {
|
|
402
|
+
var _a;
|
|
403
|
+
return {
|
|
404
|
+
type: "Control",
|
|
405
|
+
scope: `#/properties/${key}`,
|
|
406
|
+
options: {
|
|
407
|
+
autocomplete: !!value.enum || ((_a = value.options) == null ? void 0 : _a.autocomplete),
|
|
408
|
+
showUnfocusedDescription: true,
|
|
409
|
+
...value.options
|
|
410
|
+
},
|
|
411
|
+
rule: value.rule
|
|
412
|
+
};
|
|
413
|
+
})
|
|
297
414
|
}),
|
|
298
415
|
[formSchema == null ? void 0 : formSchema.properties, formSchema == null ? void 0 : formSchema.required]
|
|
299
416
|
);
|
|
@@ -430,7 +547,9 @@ const ActionForm$1 = memo(ActionForm);
|
|
|
430
547
|
export {
|
|
431
548
|
ActionForm$1 as A,
|
|
432
549
|
ClueActionProvider as C,
|
|
550
|
+
ResultModal$1 as R,
|
|
433
551
|
ClueActionContext as a,
|
|
552
|
+
useActionResult as b,
|
|
434
553
|
capitalize as c,
|
|
435
554
|
useClueActions as u
|
|
436
555
|
};
|
|
@@ -10,7 +10,7 @@ import useErrors from "./hooks/useErrors.js";
|
|
|
10
10
|
import { ICON_MAP } from "./icons/iconMap.js";
|
|
11
11
|
import { safeDispatchEvent } from "./utils/window.js";
|
|
12
12
|
import { g as groupBy } from "./groupBy-DC2oOuBN.js";
|
|
13
|
-
import { u as uniq } from "./ClueEnrichContext-
|
|
13
|
+
import { u as uniq } from "./ClueEnrichContext-6NJfXpUB.js";
|
|
14
14
|
import { memo, useState, useMemo, useCallback, useEffect } from "react";
|
|
15
15
|
import { u as useContextSelector } from "./index-BDVjGvMI.js";
|
|
16
16
|
import ExecutePopover from "./components/actions/ExecutePopover.js";
|
|
@@ -3,12 +3,12 @@ import { I as Icon } from "./iconify-CXMreGTg.js";
|
|
|
3
3
|
import { useTheme, Popper, Fade, Paper, Stack, Typography, Divider } from "@mui/material";
|
|
4
4
|
import AnnotationDetailPopover from "./components/AnnotationDetailPopover.js";
|
|
5
5
|
import useAnnotations from "./hooks/useAnnotations.js";
|
|
6
|
-
import { t as twitterShort } from "./utils-
|
|
6
|
+
import { t as twitterShort } from "./utils-7OtvGnmf.js";
|
|
7
7
|
import { useState, useRef, useCallback, useEffect, useMemo } from "react";
|
|
8
8
|
import { c as createContext, u as useContextSelector } from "./index-BDVjGvMI.js";
|
|
9
9
|
import { SHOW_EVENT_ID, HIDE_EVENT_ID } from "./data/event.js";
|
|
10
10
|
import { safeDispatchEvent, safeAddEventListener } from "./utils/window.js";
|
|
11
|
-
import { i as isNull } from "./AnnotationDetails-
|
|
11
|
+
import { i as isNull } from "./AnnotationDetails-DknbKDyl.js";
|
|
12
12
|
const CluePopupContext = createContext(null);
|
|
13
13
|
const CluePopupProvider = ({ children }) => {
|
|
14
14
|
const [popupType, setPopupType] = useState(null);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { a as addAPIProvider } from "./iconify-CXMreGTg.js";
|
|
3
|
-
import { u as useClueTypeConfig, a as api, p as post } from "./useClueTypeConfig-
|
|
3
|
+
import { u as useClueTypeConfig, a as api, p as post } from "./useClueTypeConfig-XvGvIw2S.js";
|
|
4
4
|
import { clueDebugLogger } from "./utils/loggerUtil.js";
|
|
5
5
|
import { b as baseSlice } from "./_baseSlice-GAv_YFTT.js";
|
|
6
6
|
import { t as toFinite } from "./toFinite-Bc55msYj.js";
|
|
@@ -8,7 +8,7 @@ import { d as debounce } from "./debounce-bV0h5FC5.js";
|
|
|
8
8
|
import { g as groupBy } from "./groupBy-DC2oOuBN.js";
|
|
9
9
|
import { b as baseUniq } from "./_baseUniq-CpupKWcL.js";
|
|
10
10
|
import { b as baseIteratee } from "./_baseIteratee-p6Nj07-n.js";
|
|
11
|
-
import { useContext, useMemo,
|
|
11
|
+
import { useContext, useState, useMemo, useCallback, useRef, useEffect } from "react";
|
|
12
12
|
import { c as createContext } from "./index-BDVjGvMI.js";
|
|
13
13
|
import { ClueDatabaseContext } from "./hooks/ClueDatabaseContext.js";
|
|
14
14
|
import useClueConfig from "./hooks/useClueConfig.js";
|
|
@@ -89,13 +89,24 @@ const ClueEnrichProvider = ({
|
|
|
89
89
|
customIconify: _customIconify,
|
|
90
90
|
debugLogging = true
|
|
91
91
|
}) => {
|
|
92
|
-
var _a;
|
|
92
|
+
var _a, _b, _c, _d;
|
|
93
93
|
const clueConfig = useClueConfig();
|
|
94
94
|
const database = useContext(ClueDatabaseContext);
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
const [configuredDefaultClassification, setConfiguredDefaultClassification] = useState(null);
|
|
96
|
+
const defaultClassification = useMemo(
|
|
97
|
+
() => {
|
|
98
|
+
var _a2, _b2;
|
|
99
|
+
return configuredDefaultClassification ?? _defaultClassification ?? ((_b2 = (_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef) == null ? void 0 : _b2.RESTRICTED);
|
|
100
|
+
},
|
|
101
|
+
[_defaultClassification, (_b = (_a = clueConfig.config) == null ? void 0 : _a.c12nDef) == null ? void 0 : _b.RESTRICTED, configuredDefaultClassification]
|
|
102
|
+
);
|
|
103
|
+
const setDefaultClassification = useCallback(
|
|
104
|
+
(func) => {
|
|
105
|
+
var _a2;
|
|
106
|
+
return setConfiguredDefaultClassification(func((_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef));
|
|
107
|
+
},
|
|
108
|
+
[(_c = clueConfig.config) == null ? void 0 : _c.c12nDef]
|
|
109
|
+
);
|
|
99
110
|
const [isReady, setIsReady] = useState(ready);
|
|
100
111
|
const runningRequestCount = useRef(0);
|
|
101
112
|
const [sources, setSources] = useState([]);
|
|
@@ -191,7 +202,7 @@ const ClueEnrichProvider = ({
|
|
|
191
202
|
);
|
|
192
203
|
const enrich = useCallback(
|
|
193
204
|
async (type, value2, _options = {}) => {
|
|
194
|
-
var _a2,
|
|
205
|
+
var _a2, _b2;
|
|
195
206
|
if (!type || !value2) {
|
|
196
207
|
console.error(`Type (${type}) or value (${value2}) is empty, returning empty response`);
|
|
197
208
|
return {};
|
|
@@ -222,7 +233,7 @@ const ClueEnrichProvider = ({
|
|
|
222
233
|
};
|
|
223
234
|
let statusRecord = await ((_a2 = database.status) == null ? void 0 : _a2.findOne({ selector: { ...selector } }).exec());
|
|
224
235
|
if (!statusRecord) {
|
|
225
|
-
statusRecord = await ((
|
|
236
|
+
statusRecord = await ((_b2 = database.status) == null ? void 0 : _b2.insert({
|
|
226
237
|
id: v4(),
|
|
227
238
|
type: selector.type,
|
|
228
239
|
value: selector.value,
|
|
@@ -235,12 +246,13 @@ const ClueEnrichProvider = ({
|
|
|
235
246
|
try {
|
|
236
247
|
const enrichmentResult = await post([selector], options.sources, options, requestConfig);
|
|
237
248
|
const enrichData = Object.values(Object.values(enrichmentResult)[0])[0];
|
|
238
|
-
await (statusRecord == null ? void 0 : statusRecord.incrementalPatch({ status: "complete" }));
|
|
239
249
|
await _addEntries(Object.values(enrichData));
|
|
240
250
|
return enrichData;
|
|
241
251
|
} catch (e) {
|
|
242
252
|
console.error(e);
|
|
243
253
|
return {};
|
|
254
|
+
} finally {
|
|
255
|
+
await (statusRecord == null ? void 0 : statusRecord.incrementalPatch({ status: "complete" }));
|
|
244
256
|
}
|
|
245
257
|
},
|
|
246
258
|
[
|
|
@@ -460,7 +472,7 @@ const ClueEnrichProvider = ({
|
|
|
460
472
|
);
|
|
461
473
|
const guessType = useCallback(
|
|
462
474
|
(value2) => {
|
|
463
|
-
var _a2,
|
|
475
|
+
var _a2, _b2;
|
|
464
476
|
if (!value2) {
|
|
465
477
|
return null;
|
|
466
478
|
}
|
|
@@ -470,7 +482,7 @@ const ClueEnrichProvider = ({
|
|
|
470
482
|
return regularCheck;
|
|
471
483
|
}
|
|
472
484
|
const lowercased = value2.toLowerCase();
|
|
473
|
-
const lowercaseCheck = (
|
|
485
|
+
const lowercaseCheck = (_b2 = types.find(([_type, _regexp]) => _regexp.exec(lowercased))) == null ? void 0 : _b2[0];
|
|
474
486
|
if (lowercaseCheck) {
|
|
475
487
|
return lowercaseCheck;
|
|
476
488
|
}
|
|
@@ -492,6 +504,7 @@ const ClueEnrichProvider = ({
|
|
|
492
504
|
guessType,
|
|
493
505
|
queueEnrich,
|
|
494
506
|
setCustomIconify,
|
|
507
|
+
setDefaultClassification,
|
|
495
508
|
setReady: setIsReady,
|
|
496
509
|
defaultClassification,
|
|
497
510
|
ready: isReady && !!database && !!((_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef)
|
|
@@ -506,10 +519,11 @@ const ClueEnrichProvider = ({
|
|
|
506
519
|
availableSources,
|
|
507
520
|
guessType,
|
|
508
521
|
queueEnrich,
|
|
522
|
+
setDefaultClassification,
|
|
509
523
|
defaultClassification,
|
|
510
524
|
isReady,
|
|
511
525
|
database,
|
|
512
|
-
(
|
|
526
|
+
(_d = clueConfig.config) == null ? void 0 : _d.c12nDef
|
|
513
527
|
]
|
|
514
528
|
);
|
|
515
529
|
return /* @__PURE__ */ jsx(ClueEnrichContext.Provider, { value, children });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
2
|
+
function getDefaultExportFromCjs(x) {
|
|
3
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
4
|
+
}
|
|
5
|
+
export {
|
|
6
|
+
commonjsGlobal as c,
|
|
7
|
+
getDefaultExportFromCjs as g
|
|
8
|
+
};
|
package/api/lookup/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as enrich from "../../api/lookup/enrich";
|
|
2
2
|
import * as types from "../../api/lookup/types";
|
|
3
3
|
import * as types_detection from "../../api/lookup/types_detection";
|
|
4
|
-
export declare
|
|
4
|
+
export declare const uri: () => string;
|
|
5
5
|
export { enrich, types, types_detection };
|
package/api/lookup/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { TypesResponse } from "../../types/lookup";
|
|
3
3
|
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
4
|
+
export declare const uri: () => string;
|
|
5
|
+
export declare const get: (config?: AxiosRequestConfig) => Promise<TypesResponse>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { TypesDetectionResponse } from "../../types/lookup";
|
|
3
3
|
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
4
|
+
export declare const uri: () => string;
|
|
5
|
+
export declare const get: (config?: AxiosRequestConfig) => Promise<TypesDetectionResponse>;
|
|
@@ -47,7 +47,7 @@ const AnnotationBody = ({ annotation }) => {
|
|
|
47
47
|
annotation.type,
|
|
48
48
|
":"
|
|
49
49
|
] }),
|
|
50
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", children: annotation.value })
|
|
50
|
+
typeof annotation.value !== "string" ? /* @__PURE__ */ jsx(Typography, { variant: "body2", children: annotation.value }) : /* @__PURE__ */ jsx(Stack, { spacing: 0.5, children: annotation.value.split("\n").map((line) => /* @__PURE__ */ jsx(Typography, { variant: "body2", children: line }, line)) })
|
|
51
51
|
] });
|
|
52
52
|
};
|
|
53
53
|
const AnnotationBody$1 = memo(AnnotationBody);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Popover } from "@mui/material";
|
|
3
3
|
import React__default, { useRef, useState, useEffect } from "react";
|
|
4
|
-
import { A as AnnotationDetails } from "../AnnotationDetails-
|
|
4
|
+
import { A as AnnotationDetails } from "../AnnotationDetails-DknbKDyl.js";
|
|
5
5
|
const AnnotationDetailPopover = React__default.memo(({ anchorEl, enrichRequest, open, onClose, ...otherProps }) => {
|
|
6
6
|
var _a, _b, _c;
|
|
7
7
|
const actionRef = useRef();
|
|
@@ -10,8 +10,8 @@ import "../hooks/useErrors.js";
|
|
|
10
10
|
import "../icons/iconMap.js";
|
|
11
11
|
import "../utils/window.js";
|
|
12
12
|
import "../groupBy-DC2oOuBN.js";
|
|
13
|
-
import { A } from "../AnnotationDetails-
|
|
14
|
-
import "../ClueEnrichContext-
|
|
13
|
+
import { A } from "../AnnotationDetails-DknbKDyl.js";
|
|
14
|
+
import "../ClueEnrichContext-6NJfXpUB.js";
|
|
15
15
|
import "react";
|
|
16
16
|
import "../index-BDVjGvMI.js";
|
|
17
17
|
import "./actions/ExecutePopover.js";
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { I as Icon } from "../iconify-CXMreGTg.js";
|
|
3
3
|
import { Stack, Typography, Chip, IconButton } from "@mui/material";
|
|
4
4
|
import Iconified from "./display/icons/Iconified.js";
|
|
5
|
-
import { t as twitterShort } from "../utils-
|
|
5
|
+
import { t as twitterShort } from "../utils-7OtvGnmf.js";
|
|
6
6
|
import { memo } from "react";
|
|
7
7
|
import AnnotationBody from "./AnnotationBody.js";
|
|
8
8
|
import ClassificationChip from "./ClassificationChip.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "../iconify-CXMreGTg.js";
|
|
3
3
|
import "@mui/material";
|
|
4
|
-
import { A } from "../AnnotationPreview-
|
|
4
|
+
import { A } from "../AnnotationPreview-CQwKs8se.js";
|
|
5
5
|
import "../hooks/useAnnotations.js";
|
|
6
|
-
import "../utils-
|
|
6
|
+
import "../utils-7OtvGnmf.js";
|
|
7
7
|
import "react";
|
|
8
8
|
import "../index-BDVjGvMI.js";
|
|
9
9
|
export {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { ChipOwnProps } from '@mui/material';
|
|
1
2
|
import { default as React } from 'react';
|
|
2
3
|
|
|
3
4
|
interface EnrichedChipProps {
|
|
4
5
|
classification: string;
|
|
5
6
|
}
|
|
6
|
-
declare const _default: React.NamedExoticComponent<EnrichedChipProps &
|
|
7
|
+
declare const _default: React.NamedExoticComponent<EnrichedChipProps & ChipOwnProps & import('@mui/material/OverridableComponent').CommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
7
8
|
ref?: React.Ref<HTMLDivElement>;
|
|
8
9
|
}, "disabled" | "icon" | "color" | "style" | "size" | "children" | "variant" | "classes" | "className" | "sx" | "label" | "tabIndex" | "onDelete" | "avatar" | "clickable" | "deleteIcon" | "skipFocusWhenDisabled"> & {
|
|
9
10
|
component?: React.ElementType;
|
|
@@ -10,10 +10,12 @@ import ContextIcon from "../icons/Context.js";
|
|
|
10
10
|
import OpinionIcon from "../icons/Opinion.js";
|
|
11
11
|
import { ICON_MAP } from "../icons/iconMap.js";
|
|
12
12
|
import FrequencyText from "../text/Frequency.js";
|
|
13
|
-
import { u as uniq } from "../ClueEnrichContext-
|
|
13
|
+
import { u as uniq } from "../ClueEnrichContext-6NJfXpUB.js";
|
|
14
14
|
import { memo, useState, useMemo, useCallback } from "react";
|
|
15
15
|
import { u as useContextSelector } from "../index-BDVjGvMI.js";
|
|
16
16
|
import AnnotationEntry from "./AnnotationEntry.js";
|
|
17
|
+
import ExecutePopover from "./actions/ExecutePopover.js";
|
|
18
|
+
import EnrichPopover from "./enrichment/EnrichPopover.js";
|
|
17
19
|
const EnrichedCard = ({
|
|
18
20
|
type,
|
|
19
21
|
value,
|
|
@@ -34,6 +36,7 @@ const EnrichedCard = ({
|
|
|
34
36
|
);
|
|
35
37
|
const [annotations, loading] = useAnnotations(type, value, classification);
|
|
36
38
|
const errors = useErrors(value);
|
|
39
|
+
const enrichRequest = { type, value, classification };
|
|
37
40
|
const options = useMemo(() => ["all", ...uniq(annotations.map((annotation) => annotation.type))], [annotations]);
|
|
38
41
|
const forceEnrich = useCallback(() => {
|
|
39
42
|
return enrich(type, value, {
|
|
@@ -61,7 +64,7 @@ const EnrichedCard = ({
|
|
|
61
64
|
/* @__PURE__ */ jsx(
|
|
62
65
|
AssessmentIcon,
|
|
63
66
|
{
|
|
64
|
-
value:
|
|
67
|
+
value: enrichRequest,
|
|
65
68
|
annotations,
|
|
66
69
|
counters,
|
|
67
70
|
fontSize: "1em",
|
|
@@ -71,7 +74,7 @@ const EnrichedCard = ({
|
|
|
71
74
|
/* @__PURE__ */ jsx(
|
|
72
75
|
OpinionIcon,
|
|
73
76
|
{
|
|
74
|
-
value:
|
|
77
|
+
value: enrichRequest,
|
|
75
78
|
annotations,
|
|
76
79
|
counters,
|
|
77
80
|
fontSize: "1em",
|
|
@@ -81,7 +84,7 @@ const EnrichedCard = ({
|
|
|
81
84
|
/* @__PURE__ */ jsx(
|
|
82
85
|
ContextIcon,
|
|
83
86
|
{
|
|
84
|
-
value:
|
|
87
|
+
value: enrichRequest,
|
|
85
88
|
annotations,
|
|
86
89
|
counters,
|
|
87
90
|
showExtraIcon: contextIcon,
|
|
@@ -89,7 +92,10 @@ const EnrichedCard = ({
|
|
|
89
92
|
disableTooltip: true
|
|
90
93
|
}
|
|
91
94
|
),
|
|
92
|
-
loading && !hideLoading && /* @__PURE__ */ jsx(CircularProgress, { color: "primary", size: 18 })
|
|
95
|
+
loading && !hideLoading && /* @__PURE__ */ jsx(CircularProgress, { color: "primary", size: 18 }),
|
|
96
|
+
/* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
|
|
97
|
+
/* @__PURE__ */ jsx(EnrichPopover, { selector: enrichRequest }),
|
|
98
|
+
/* @__PURE__ */ jsx(ExecutePopover, { selectors: [enrichRequest] })
|
|
93
99
|
] })
|
|
94
100
|
}
|
|
95
101
|
),
|