@cccsaurora/clue-ui 1.2.0-dev.197 → 1.2.0-dev.236

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/{ActionForm-TRst3ifX.js → ActionForm-U5a2mLUv.js} +2 -1
  2. package/{AnnotationDetails-CvaOf3Jl.js → AnnotationDetails-BEHFNNv3.js} +1 -1
  3. package/{AnnotationPreview-B-DhbGyc.js → AnnotationPreview-MO5UsP5l.js} +1 -1
  4. package/{ClueEnrichContext-BfhIZ_LV.js → ClueEnrichContext-DoOHQeVr.js} +1 -1
  5. package/components/AnnotationDetailPopover.js +1 -1
  6. package/components/AnnotationDetails.js +2 -2
  7. package/components/AnnotationEntry.js +2 -1
  8. package/components/AnnotationPreview.js +1 -1
  9. package/components/EnrichedCard.js +1 -1
  10. package/components/EnrichedChip.js +1 -1
  11. package/components/EnrichedTypography.js +1 -1
  12. package/components/actions/ActionForm.js +1 -1
  13. package/components/actions/ResultModal.js +1 -1
  14. package/components/enrichment/EnrichPopover.js +1 -1
  15. package/components/fetchers/Fetcher.js +41 -4
  16. package/components/group/GroupControl.js +1 -1
  17. package/hooks/ClueActionContext.js +2 -2
  18. package/hooks/ClueEnrichContext.js +2 -2
  19. package/hooks/ClueFetcherContext.d.ts +1 -0
  20. package/hooks/ClueFetcherContext.js +43 -24
  21. package/hooks/CluePopupContext.js +2 -2
  22. package/hooks/ClueProvider.js +3 -3
  23. package/hooks/selectors.js +2 -2
  24. package/hooks/useActionResult.js +1 -1
  25. package/hooks/useAnnotations.js +1 -1
  26. package/hooks/useClue.js +1 -1
  27. package/hooks/useClueActions.js +1 -1
  28. package/hooks/useClueTypeConfig.js +1 -1
  29. package/hooks/useFetcherResult.d.ts +14 -0
  30. package/hooks/useFetcherResult.js +40 -0
  31. package/icons/Action.js +2 -2
  32. package/icons/Assessment.js +1 -1
  33. package/icons/Context.js +1 -1
  34. package/icons/Opinion.js +1 -1
  35. package/main.js +4 -4
  36. package/package.json +1 -1
  37. package/types/fetcher.d.ts +19 -7
  38. package/{useClueTypeConfig-Cx-Is721.js → useClueTypeConfig-D2tf4-NM.js} +26 -10
@@ -6,7 +6,7 @@ import Iconified from "./components/display/icons/Iconified.js";
6
6
  import { J as JSONViewer } from "./index-Bmoj6JY8.js";
7
7
  import { ClueComponentContext } from "./hooks/ClueComponentContext.js";
8
8
  import { A as Ajv } from "./index-CC12Ux-9.js";
9
- import { a as api } from "./useClueTypeConfig-Cx-Is721.js";
9
+ import { a as api } from "./useClueTypeConfig-D2tf4-NM.js";
10
10
  import { d as toString } from "./_baseGet-Bx3A4Qfp.js";
11
11
  import { b as baseSlice } from "./_baseSlice-GAv_YFTT.js";
12
12
  import { i as isEqual } from "./utils-CW9CNV1h.js";
@@ -184,6 +184,7 @@ const ClueActionProvider = ({
184
184
  const { forceMenu, onComplete, skipMenu, skipResultModal, timeout, includeContext, extraContext } = {
185
185
  forceMenu: false,
186
186
  skipMenu: false,
187
+ skipResultModal: false,
187
188
  onComplete: null,
188
189
  timeout: null,
189
190
  includeContext: defaultIncludeContext ?? false,
@@ -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-mXHt-nYT.js";
13
- import { u as uniq } from "./useClueTypeConfig-Cx-Is721.js";
13
+ import { u as uniq } from "./useClueTypeConfig-D2tf4-NM.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";
@@ -8,7 +8,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-CvaOf3Jl.js";
11
+ import { i as isNull } from "./AnnotationDetails-BEHFNNv3.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 { b as useClueTypeConfig, a as api, p as post, u as uniq } from "./useClueTypeConfig-Cx-Is721.js";
3
+ import { b as useClueTypeConfig, a as api, p as post, u as uniq } from "./useClueTypeConfig-D2tf4-NM.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";
@@ -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-CvaOf3Jl.js";
4
+ import { A as AnnotationDetails } from "../AnnotationDetails-BEHFNNv3.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-mXHt-nYT.js";
13
- import { A } from "../AnnotationDetails-CvaOf3Jl.js";
14
- import "../useClueTypeConfig-Cx-Is721.js";
13
+ import { A } from "../AnnotationDetails-BEHFNNv3.js";
14
+ import "../useClueTypeConfig-D2tf4-NM.js";
15
15
  import "react";
16
16
  import "../index-BDVjGvMI.js";
17
17
  import "./actions/ExecutePopover.js";
@@ -7,6 +7,7 @@ import { memo } from "react";
7
7
  import AnnotationBody from "./AnnotationBody.js";
8
8
  import ClassificationChip from "./ClassificationChip.js";
9
9
  const AnnotatonEntry = ({ annotation }) => {
10
+ var _a;
10
11
  return /* @__PURE__ */ jsxs(Stack, { direction: "column", spacing: 1, children: [
11
12
  /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
12
13
  annotation.analytic_icon && /* @__PURE__ */ jsx(
@@ -37,7 +38,7 @@ const AnnotatonEntry = ({ annotation }) => {
37
38
  annotation.classification && /* @__PURE__ */ jsx(ClassificationChip, { size: "small", classification: annotation.classification })
38
39
  ] }),
39
40
  /* @__PURE__ */ jsx(AnnotationBody, { annotation }),
40
- /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: annotation.summary }),
41
+ (_a = annotation.summary) == null ? void 0 : _a.split("\n").map((line) => /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: line }, line)),
41
42
  /* @__PURE__ */ jsxs(Stack, { direction: "row", children: [
42
43
  /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", fontSize: "10px", children: twitterShort(annotation.timestamp) }),
43
44
  /* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../iconify-CXMreGTg.js";
3
3
  import "@mui/material";
4
- import { A } from "../AnnotationPreview-B-DhbGyc.js";
4
+ import { A } from "../AnnotationPreview-MO5UsP5l.js";
5
5
  import "../hooks/useAnnotations.js";
6
6
  import "../utils-CW9CNV1h.js";
7
7
  import "react";
@@ -10,7 +10,7 @@ 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 "../useClueTypeConfig-Cx-Is721.js";
13
+ import { u as uniq } from "../useClueTypeConfig-D2tf4-NM.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";
@@ -3,7 +3,7 @@ import { Chip, Tooltip, Box, Stack, CircularProgress } from "@mui/material";
3
3
  import Iconified from "./display/icons/Iconified.js";
4
4
  import { ClueComponentContext } from "../hooks/ClueComponentContext.js";
5
5
  import { ClueGroupContext } from "../hooks/ClueGroupContext.js";
6
- import { C as CluePopupContext } from "../AnnotationPreview-B-DhbGyc.js";
6
+ import { C as CluePopupContext } from "../AnnotationPreview-MO5UsP5l.js";
7
7
  import { useClueEnrichSelector } from "../hooks/selectors.js";
8
8
  import useAnnotations from "../hooks/useAnnotations.js";
9
9
  import ActionIcon from "../icons/Action.js";
@@ -3,7 +3,7 @@ import { useTheme, Stack, CircularProgress, Tooltip, IconButton } from "@mui/mat
3
3
  import Iconified from "./display/icons/Iconified.js";
4
4
  import { ClueComponentContext } from "../hooks/ClueComponentContext.js";
5
5
  import { ClueGroupContext } from "../hooks/ClueGroupContext.js";
6
- import { C as CluePopupContext } from "../AnnotationPreview-B-DhbGyc.js";
6
+ import { C as CluePopupContext } from "../AnnotationPreview-MO5UsP5l.js";
7
7
  import { useClueEnrichSelector } from "../hooks/selectors.js";
8
8
  import useAnnotations from "../hooks/useAnnotations.js";
9
9
  import ActionIcon from "../icons/Action.js";
@@ -5,7 +5,7 @@ import "@mui/material";
5
5
  import "../display/icons/Iconified.js";
6
6
  import "../../index-Bmoj6JY8.js";
7
7
  import "../../hooks/ClueComponentContext.js";
8
- import { A } from "../../ActionForm-TRst3ifX.js";
8
+ import { A } from "../../ActionForm-U5a2mLUv.js";
9
9
  import "../../utils-CW9CNV1h.js";
10
10
  import "react";
11
11
  import "../../index-BDVjGvMI.js";
@@ -2,7 +2,7 @@ import "react/jsx-runtime";
2
2
  import "../../iconify-CXMreGTg.js";
3
3
  import "@mui/material";
4
4
  import "../../hooks/ClueComponentContext.js";
5
- import { R } from "../../ActionForm-TRst3ifX.js";
5
+ import { R } from "../../ActionForm-U5a2mLUv.js";
6
6
  import "react";
7
7
  import "../../index-BDVjGvMI.js";
8
8
  import "../ClassificationChip.js";
@@ -1,7 +1,7 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useTheme, Tooltip, IconButton, CircularProgress, Button, Popover, Paper, Stack, Box, Typography, Divider } from "@mui/material";
3
3
  import { useClueComponentSelector, useClueEnrichSelector } from "../../hooks/selectors.js";
4
- import { c as capitalize } from "../../ActionForm-TRst3ifX.js";
4
+ import { c as capitalize } from "../../ActionForm-U5a2mLUv.js";
5
5
  import { useState, useRef, useCallback, useEffect } from "react";
6
6
  import Iconified from "../display/icons/Iconified.js";
7
7
  const EnrichPopover = ({ show = false, size = "small", selector }) => {
@@ -1,12 +1,12 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { I as Icon } from "../../iconify-CXMreGTg.js";
3
- import { useTheme, Skeleton, Chip, Tooltip, Paper, Stack, Box, IconButton } from "@mui/material";
3
+ import { useTheme, Skeleton, Chip, Tooltip, Stack, Typography, LinearProgress, Paper, Box, IconButton } from "@mui/material";
4
4
  import { F as FlexOne } from "../../FlexOne-BSYAhhtG.js";
5
5
  import Iconified from "../display/icons/Iconified.js";
6
6
  import { J as JSONViewer } from "../../index-Bmoj6JY8.js";
7
7
  import { ClueComponentContext } from "../../hooks/ClueComponentContext.js";
8
8
  import { useClueFetcherSelector } from "../../hooks/selectors.js";
9
- import React__default, { useState, useEffect, memo } from "react";
9
+ import React__default, { useState, useRef, useMemo, useEffect, memo } from "react";
10
10
  import { u as useContextSelector } from "../../index-BDVjGvMI.js";
11
11
  import Graph from "../display/graph/index.js";
12
12
  import Markdown from "../display/markdown/index.js";
@@ -27,21 +27,45 @@ const Fetcher = React__default.memo(
27
27
  skeleton: skeletonProps = {}
28
28
  } = {}
29
29
  }) => {
30
- var _a;
30
+ var _a, _b, _c, _d;
31
31
  const theme = useTheme();
32
32
  const fetchers = useClueFetcherSelector((ctx) => ctx.fetchers);
33
33
  const fetchSelector = useClueFetcherSelector((ctx) => ctx.fetchSelector);
34
+ const getFetcherStatus = useClueFetcherSelector((ctx) => ctx.getFetcherStatus);
34
35
  const fetchCompleted = useClueFetcherSelector((ctx) => ctx.fetchCompleted);
35
36
  const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx == null ? void 0 : ctx.i18next);
36
37
  const [result, setResult] = useState(null);
37
38
  const [loading, setLoading] = useState(true);
38
39
  const [showPreview, setShowPreview] = useState(false);
40
+ const timeoutRef = useRef(null);
41
+ const taskId = useMemo(() => result == null ? void 0 : result.task_id, [result == null ? void 0 : result.task_id]);
42
+ useEffect(() => {
43
+ if ((result == null ? void 0 : result.outcome) !== "pending" || !taskId) return;
44
+ let cancelled = false;
45
+ const poll = async () => {
46
+ const res = await getFetcherStatus(fetcherId, taskId);
47
+ if (!res) {
48
+ setResult({ outcome: "failure", done: true, error: "Missing result", link: "" });
49
+ } else if (res.outcome === "success" || res.outcome === "failure") {
50
+ setResult({ ...res, done: true });
51
+ } else {
52
+ if (cancelled) return;
53
+ setResult({ ...res });
54
+ timeoutRef.current = setTimeout(poll, 2e3);
55
+ }
56
+ };
57
+ poll();
58
+ return () => {
59
+ cancelled = true;
60
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
61
+ };
62
+ }, [fetcherId, getFetcherStatus, result == null ? void 0 : result.outcome, taskId]);
39
63
  useEffect(() => {
40
64
  (async () => {
41
65
  try {
42
66
  setLoading(true);
43
67
  setResult(await fetchSelector(fetcherId, { type, value, classification }));
44
- } finally {
68
+ } catch {
45
69
  setLoading(false);
46
70
  }
47
71
  })();
@@ -92,6 +116,19 @@ const Fetcher = React__default.memo(
92
116
  }
93
117
  );
94
118
  }
119
+ if (result.outcome === "pending") {
120
+ return /* @__PURE__ */ jsxs(Stack, { flex: 1, sx: { pt: 2, alignItems: "center" }, spacing: 1, children: [
121
+ ((_b = result.data) == null ? void 0 : _b.summary) && /* @__PURE__ */ jsx(Typography, { variant: "caption", children: result.data.summary }),
122
+ /* @__PURE__ */ jsx(
123
+ LinearProgress,
124
+ {
125
+ variant: ((_c = result.data) == null ? void 0 : _c.progress) ? "determinate" : "indeterminate",
126
+ value: ((_d = result.data) == null ? void 0 : _d.progress) * 100,
127
+ sx: { maxWidth: 500, width: "100%", borderRadius: theme.shape.borderRadius }
128
+ }
129
+ )
130
+ ] });
131
+ }
95
132
  if ((result == null ? void 0 : result.format) === "status") {
96
133
  return /* @__PURE__ */ jsx(StatusChip, { data: result.data, ...chipProps });
97
134
  }
@@ -6,7 +6,7 @@ import { SNACKBAR_EVENT_ID } from "../../data/event.js";
6
6
  import { ClueGroupContext } from "../../hooks/ClueGroupContext.js";
7
7
  import { useClueComponentSelector, useClueEnrichSelector } from "../../hooks/selectors.js";
8
8
  import { safeDispatchEvent } from "../../utils/window.js";
9
- import { c as capitalize } from "../../ActionForm-TRst3ifX.js";
9
+ import { c as capitalize } from "../../ActionForm-U5a2mLUv.js";
10
10
  import { useState, useMemo, useCallback } from "react";
11
11
  import { u as useContextSelector } from "../../index-BDVjGvMI.js";
12
12
  import ExecutePopover from "../actions/ExecutePopover.js";
@@ -1,8 +1,8 @@
1
1
  import "react/jsx-runtime";
2
2
  import "@mui/material";
3
3
  import "../index-CC12Ux-9.js";
4
- import "../useClueTypeConfig-Cx-Is721.js";
5
- import { a, C } from "../ActionForm-TRst3ifX.js";
4
+ import "../useClueTypeConfig-D2tf4-NM.js";
5
+ import { a, C } from "../ActionForm-U5a2mLUv.js";
6
6
  import "../components/display/icons/Iconified.js";
7
7
  import "../components/ErrorBoundary.js";
8
8
  import "../data/event.js";
@@ -1,8 +1,8 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../iconify-CXMreGTg.js";
3
- import "../useClueTypeConfig-Cx-Is721.js";
3
+ import "../useClueTypeConfig-D2tf4-NM.js";
4
4
  import "../utils/loggerUtil.js";
5
- import { C, a } from "../ClueEnrichContext-BfhIZ_LV.js";
5
+ import { C, a } from "../ClueEnrichContext-DoOHQeVr.js";
6
6
  import "../debounce-bV0h5FC5.js";
7
7
  import "../groupBy-mXHt-nYT.js";
8
8
  import "react";
@@ -26,6 +26,7 @@ export interface ClueFetcherContextProps {
26
26
  }
27
27
  export type ClueFetcherContextType = {
28
28
  fetchSelector: (fetcherId: string, selector: Selector) => Promise<FetcherResult>;
29
+ getFetcherStatus: (fetcherId: string, taskId: string) => Promise<FetcherResult>;
29
30
  fetchers: {
30
31
  [index: string]: FetcherDefinition;
31
32
  };
@@ -1,6 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { a as api } from "../useClueTypeConfig-Cx-Is721.js";
3
- import { useState, useRef, useCallback, useEffect, useMemo } from "react";
2
+ import { a as api } from "../useClueTypeConfig-D2tf4-NM.js";
3
+ import { SNACKBAR_EVENT_ID } from "../data/event.js";
4
+ import { safeDispatchEvent } from "../utils/window.js";
5
+ import { useState, useRef, useMemo, useCallback, useEffect } from "react";
4
6
  import { c as createContext } from "../index-BDVjGvMI.js";
5
7
  import useClue from "./useClue.js";
6
8
  import useClueConfig from "./useClueConfig.js";
@@ -19,6 +21,15 @@ const ClueFetcherProvider = ({
19
21
  const [fetchCompleted, setFetchCompleted] = useState(false);
20
22
  const [fetchers, setFetchers] = useState({});
21
23
  const fetchRequests = useRef({});
24
+ const requestConfig = useMemo(() => {
25
+ const headers = {};
26
+ const token = getToken == null ? void 0 : getToken();
27
+ if (token) {
28
+ headers.Authorization = `Bearer ${token}`;
29
+ }
30
+ const baseConfig = { baseURL, headers };
31
+ return onNetworkCall ? onNetworkCall(baseConfig) : { baseURL, headers };
32
+ }, [baseURL, getToken, onNetworkCall]);
22
33
  const getHashKey = useCallback(
23
34
  ({ type, value, classification }) => JSON.stringify({ type, value, classification: classification ?? defaultClassification }),
24
35
  [defaultClassification]
@@ -30,26 +41,42 @@ const ClueFetcherProvider = ({
30
41
  return fetchRequests.current[fetcherId][getHashKey(selector)];
31
42
  }
32
43
  try {
33
- const headers = {};
34
- const token = getToken == null ? void 0 : getToken();
35
- if (token) {
36
- headers.Authorization = `Bearer ${token}`;
37
- }
38
- let requestConfig = { baseURL, headers };
39
- if (onNetworkCall) {
40
- requestConfig = onNetworkCall(requestConfig);
41
- }
42
44
  const result = api.fetchers.post(fetcherId, selector, requestConfig);
43
45
  if (!fetchRequests.current[fetcherId]) {
44
46
  fetchRequests.current[fetcherId] = {};
45
47
  }
46
48
  fetchRequests.current[fetcherId][getHashKey(selector)] = result;
47
49
  return await result;
48
- } catch {
49
- return null;
50
+ } catch (e) {
51
+ safeDispatchEvent(
52
+ new CustomEvent(SNACKBAR_EVENT_ID, {
53
+ detail: {
54
+ message: e.toString(),
55
+ level: "error"
56
+ }
57
+ })
58
+ );
50
59
  }
51
60
  },
52
- [baseURL, getHashKey, getToken, onNetworkCall]
61
+ [getHashKey, requestConfig]
62
+ );
63
+ const getFetcherStatus = useCallback(
64
+ async (fetcherId, taskId) => {
65
+ try {
66
+ const res = await api.fetchers.status.get(fetcherId, taskId, {}, requestConfig);
67
+ return res;
68
+ } catch (e) {
69
+ safeDispatchEvent(
70
+ new CustomEvent(SNACKBAR_EVENT_ID, {
71
+ detail: {
72
+ message: e.toString(),
73
+ level: "error"
74
+ }
75
+ })
76
+ );
77
+ }
78
+ },
79
+ [requestConfig]
53
80
  );
54
81
  useEffect(() => {
55
82
  var _a2, _b2, _c, _d;
@@ -61,24 +88,16 @@ const ClueFetcherProvider = ({
61
88
  if (!ready) {
62
89
  return;
63
90
  }
64
- const headers = {};
65
- const token = getToken == null ? void 0 : getToken();
66
- if (token) {
67
- headers.Authorization = `Bearer ${token}`;
68
- }
69
- let requestConfig = { baseURL, headers };
70
- if (onNetworkCall) {
71
- requestConfig = onNetworkCall(requestConfig);
72
- }
73
91
  api.fetchers.get(requestConfig).then(setFetchers).finally(() => setFetchCompleted(true));
74
92
  }, [baseURL, ready]);
75
93
  const context = useMemo(
76
94
  () => ({
77
95
  fetchSelector,
96
+ getFetcherStatus,
78
97
  fetchers,
79
98
  fetchCompleted
80
99
  }),
81
- [fetchCompleted, fetchSelector, fetchers]
100
+ [fetchCompleted, fetchSelector, fetchers, getFetcherStatus]
82
101
  );
83
102
  return /* @__PURE__ */ jsx(ClueFetcherContext.Provider, { value: context, children });
84
103
  };
@@ -1,9 +1,9 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../components/AnnotationDetailPopover.js";
3
- import { C, a } from "../AnnotationPreview-B-DhbGyc.js";
3
+ import { C, a } from "../AnnotationPreview-MO5UsP5l.js";
4
4
  import "../data/event.js";
5
5
  import "../utils/window.js";
6
- import "../AnnotationDetails-CvaOf3Jl.js";
6
+ import "../AnnotationDetails-BEHFNNv3.js";
7
7
  import "react";
8
8
  import "../index-BDVjGvMI.js";
9
9
  export {
@@ -1,11 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { C as ClueActionProvider } from "../ActionForm-TRst3ifX.js";
2
+ import { C as ClueActionProvider } from "../ActionForm-U5a2mLUv.js";
3
3
  import { ClueComponentProvider } from "./ClueComponentContext.js";
4
4
  import { ClueConfigProvider } from "./ClueConfigProvider.js";
5
5
  import { ClueDatabaseProvider } from "./ClueDatabaseContext.js";
6
- import { a as ClueEnrichProvider } from "../ClueEnrichContext-BfhIZ_LV.js";
6
+ import { a as ClueEnrichProvider } from "../ClueEnrichContext-DoOHQeVr.js";
7
7
  import { ClueFetcherProvider } from "./ClueFetcherContext.js";
8
- import { a as CluePopupProvider } from "../AnnotationPreview-B-DhbGyc.js";
8
+ import { a as CluePopupProvider } from "../AnnotationPreview-MO5UsP5l.js";
9
9
  const ClueProvider = ({ children, ...props }) => {
10
10
  return /* @__PURE__ */ jsx(ClueComponentProvider, { ...props, children: /* @__PURE__ */ jsx(ClueConfigProvider, { config: props.config, children: /* @__PURE__ */ jsx(ClueDatabaseProvider, { ...props, children: /* @__PURE__ */ jsx(ClueEnrichProvider, { ...props, children: /* @__PURE__ */ jsx(ClueFetcherProvider, { ...props, children: /* @__PURE__ */ jsx(ClueActionProvider, { ...props, children: /* @__PURE__ */ jsx(CluePopupProvider, { children }) }) }) }) }) }) });
11
11
  };
@@ -1,6 +1,6 @@
1
- import { a as ClueActionContext } from "../ActionForm-TRst3ifX.js";
1
+ import { a as ClueActionContext } from "../ActionForm-U5a2mLUv.js";
2
2
  import { ClueComponentContext } from "./ClueComponentContext.js";
3
- import { C as ClueEnrichContext } from "../ClueEnrichContext-BfhIZ_LV.js";
3
+ import { C as ClueEnrichContext } from "../ClueEnrichContext-DoOHQeVr.js";
4
4
  import { ClueFetcherContext } from "./ClueFetcherContext.js";
5
5
  import { u as useContextSelector } from "../index-BDVjGvMI.js";
6
6
  const useClueFetcherSelector = (selector) => {
@@ -1,5 +1,5 @@
1
1
  import "react";
2
- import { b } from "../ActionForm-TRst3ifX.js";
2
+ import { b } from "../ActionForm-U5a2mLUv.js";
3
3
  export {
4
4
  b as useActionResult
5
5
  };
@@ -1,4 +1,4 @@
1
- import { u as uniqBy } from "../ClueEnrichContext-BfhIZ_LV.js";
1
+ import { u as uniqBy } from "../ClueEnrichContext-DoOHQeVr.js";
2
2
  import { useContext, useMemo, useState, useEffect } from "react";
3
3
  import { ClueDatabaseContext } from "./ClueDatabaseContext.js";
4
4
  import { useClueEnrichSelector } from "./selectors.js";
package/hooks/useClue.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as useContext } from "../index-BDVjGvMI.js";
2
- import { C as ClueEnrichContext } from "../ClueEnrichContext-BfhIZ_LV.js";
2
+ import { C as ClueEnrichContext } from "../ClueEnrichContext-DoOHQeVr.js";
3
3
  const useClue = () => {
4
4
  return useContext(ClueEnrichContext);
5
5
  };
@@ -1,4 +1,4 @@
1
- import { u } from "../ActionForm-TRst3ifX.js";
1
+ import { u } from "../ActionForm-U5a2mLUv.js";
2
2
  import "../index-BDVjGvMI.js";
3
3
  export {
4
4
  u as default
@@ -1,4 +1,4 @@
1
- import { b } from "../useClueTypeConfig-Cx-Is721.js";
1
+ import { b } from "../useClueTypeConfig-D2tf4-NM.js";
2
2
  import "../utils/loggerUtil.js";
3
3
  import "../_baseUniq-B8fK6hI-.js";
4
4
  import "react";
@@ -0,0 +1,14 @@
1
+ import { ActionResult } from "../types/action";
2
+ import { WithActionData } from "../types/WithActionData";
3
+
4
+ export declare const useActionResult: (resultWithData: WithActionData<ActionResult>, interval?: number) => {
5
+ outcome: "success" | "failure" | "pending";
6
+ summary?: string;
7
+ output?: any;
8
+ format?: string;
9
+ link?: string;
10
+ done?: boolean;
11
+ task_id?: string;
12
+ actionId: string;
13
+ action: import("../types/action").ActionDefinition;
14
+ };
@@ -0,0 +1,40 @@
1
+ import { useState, useRef, useMemo, useEffect } from "react";
2
+ import { u as useClueActions } from "../ActionForm-U5a2mLUv.js";
3
+ const useActionResult = (resultWithData, interval = 2e3) => {
4
+ const [result, setResult] = useState(resultWithData);
5
+ const timeoutRef = useRef(null);
6
+ const { getActionStatus } = useClueActions();
7
+ const taskId = useMemo(() => resultWithData == null ? void 0 : resultWithData.task_id, [resultWithData == null ? void 0 : resultWithData.task_id]);
8
+ const actionId = useMemo(() => resultWithData == null ? void 0 : resultWithData.actionId, [resultWithData == null ? void 0 : resultWithData.actionId]);
9
+ useEffect(() => {
10
+ if ((resultWithData == null ? void 0 : resultWithData.outcome) !== "pending" || !taskId) return;
11
+ let cancelled = false;
12
+ const poll = async () => {
13
+ const res = await getActionStatus(actionId, taskId);
14
+ if (!res) {
15
+ setResult({ outcome: "failure", done: true });
16
+ } else if (res.outcome === "success" || res.outcome === "failure") {
17
+ setResult({ ...res, done: true });
18
+ } else {
19
+ if (cancelled) return;
20
+ setResult({ ...res });
21
+ timeoutRef.current = setTimeout(poll, interval);
22
+ }
23
+ };
24
+ poll();
25
+ return () => {
26
+ cancelled = true;
27
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
28
+ };
29
+ }, [actionId, getActionStatus, interval, resultWithData == null ? void 0 : resultWithData.outcome, taskId]);
30
+ useEffect(() => {
31
+ setResult(resultWithData);
32
+ }, [resultWithData]);
33
+ return useMemo(
34
+ () => resultWithData || result ? { ...resultWithData, ...result } : void 0,
35
+ [resultWithData, result]
36
+ );
37
+ };
38
+ export {
39
+ useActionResult
40
+ };
package/icons/Action.js CHANGED
@@ -2,8 +2,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { I as Icon } from "../iconify-CXMreGTg.js";
3
3
  import { useTheme, Stack, Divider, Typography } from "@mui/material";
4
4
  import CountBadge from "../components/CountBadge.js";
5
- import { C as CluePopupContext } from "../AnnotationPreview-B-DhbGyc.js";
6
- import { u as useClueActions } from "../ActionForm-TRst3ifX.js";
5
+ import { C as CluePopupContext } from "../AnnotationPreview-MO5UsP5l.js";
6
+ import { u as useClueActions } from "../ActionForm-U5a2mLUv.js";
7
7
  import { g as groupBy } from "../groupBy-mXHt-nYT.js";
8
8
  import { memo, useRef, useMemo, useEffect } from "react";
9
9
  import { u as useContextSelector } from "../index-BDVjGvMI.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 { useTheme, Stack, Chip, Divider, Grid, Tooltip } from "@mui/material";
4
4
  import CountBadge from "../components/CountBadge.js";
5
- import { C as CluePopupContext } from "../AnnotationPreview-B-DhbGyc.js";
5
+ import { C as CluePopupContext } from "../AnnotationPreview-MO5UsP5l.js";
6
6
  import { g as groupBy } from "../groupBy-mXHt-nYT.js";
7
7
  import { l as last } from "../last-CUCl67Im.js";
8
8
  import { m as maxBy, s as sortBy } from "../sortBy-B0zptFuY.js";
package/icons/Context.js CHANGED
@@ -4,7 +4,7 @@ import { Stack, Divider } from "@mui/material";
4
4
  import AnnotationEntry from "../components/AnnotationEntry.js";
5
5
  import CountBadge from "../components/CountBadge.js";
6
6
  import Iconified from "../components/display/icons/Iconified.js";
7
- import { C as CluePopupContext } from "../AnnotationPreview-B-DhbGyc.js";
7
+ import { C as CluePopupContext } from "../AnnotationPreview-MO5UsP5l.js";
8
8
  import { g as groupBy } from "../groupBy-mXHt-nYT.js";
9
9
  import { memo, useRef, useMemo, useEffect } from "react";
10
10
  import { u as useContextSelector } from "../index-BDVjGvMI.js";
package/icons/Opinion.js CHANGED
@@ -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 { useTheme, Stack, Chip, Divider, Grid } from "@mui/material";
4
4
  import CountBadge from "../components/CountBadge.js";
5
- import { C as CluePopupContext } from "../AnnotationPreview-B-DhbGyc.js";
5
+ import { C as CluePopupContext } from "../AnnotationPreview-MO5UsP5l.js";
6
6
  import chain from "../utils/chain.js";
7
7
  import { g as groupBy } from "../groupBy-mXHt-nYT.js";
8
8
  import { s as sortBy } from "../sortBy-B0zptFuY.js";
package/main.js CHANGED
@@ -1,8 +1,8 @@
1
- import { A, u } from "./ActionForm-TRst3ifX.js";
1
+ import { A, u } from "./ActionForm-U5a2mLUv.js";
2
2
  import { default as default2 } from "./components/AnnotationDetailPopover.js";
3
- import { A as A2 } from "./AnnotationDetails-CvaOf3Jl.js";
3
+ import { A as A2 } from "./AnnotationDetails-BEHFNNv3.js";
4
4
  import { default as default3 } from "./components/AnnotationEntry.js";
5
- import { A as A3, C } from "./AnnotationPreview-B-DhbGyc.js";
5
+ import { A as A3, C } from "./AnnotationPreview-MO5UsP5l.js";
6
6
  import { default as default4 } from "./components/CountBadge.js";
7
7
  import { default as default5 } from "./components/EnrichedCard.js";
8
8
  import { default as default6 } from "./components/EnrichedChip.js";
@@ -18,7 +18,7 @@ import { b } from "./index-CC12Ux-9.js";
18
18
  import { ClueComponentContext } from "./hooks/ClueComponentContext.js";
19
19
  import { ClueConfigContext } from "./hooks/ClueConfigProvider.js";
20
20
  import { ClueDatabaseContext } from "./hooks/ClueDatabaseContext.js";
21
- import { C as C2 } from "./ClueEnrichContext-BfhIZ_LV.js";
21
+ import { C as C2 } from "./ClueEnrichContext-DoOHQeVr.js";
22
22
  import { ClueProvider } from "./hooks/ClueProvider.js";
23
23
  import { useClueActionsSelector, useClueEnrichSelector, useClueFetcherSelector } from "./hooks/selectors.js";
24
24
  import { default as default14 } from "./hooks/useClue.js";
package/package.json CHANGED
@@ -66,7 +66,7 @@
66
66
  },
67
67
  "type": "module",
68
68
  "types": "main.d.ts",
69
- "version": "1.2.0-dev.197",
69
+ "version": "1.2.0-dev.236",
70
70
  "exports": {
71
71
  ".": "./main.js",
72
72
  "./index.css": "./index.css",
@@ -10,10 +10,12 @@ export interface FetcherDefinition {
10
10
  }
11
11
 
12
12
  interface BaseFetcherResult {
13
- outcome: 'success' | 'failure';
14
- error: string;
15
- link: string;
16
- format: string;
13
+ outcome: 'success' | 'failure' | 'pending';
14
+ error?: string;
15
+ link?: string;
16
+ format?: string;
17
+ done?: boolean;
18
+ task_id?: string;
17
19
  }
18
20
 
19
21
  export interface FetcherImageResult extends BaseFetcherResult {
@@ -40,14 +42,23 @@ export interface FetcherGraphResult extends BaseFetcherResult {
40
42
  }
41
43
 
42
44
  export interface FetcherStatusResult extends BaseFetcherResult {
43
- data: {
45
+ data?: {
44
46
  empty: boolean;
45
47
  labels: { language: string; label: string }[];
46
48
  link?: string;
47
49
  icon?: string;
48
50
  color?: string;
49
51
  };
50
- format: 'status';
52
+ format?: 'status';
53
+ }
54
+
55
+ export interface GetFetcherStatusResult extends BaseFetcherResult {
56
+ task_id: string;
57
+ outcome: 'pending';
58
+ data?: {
59
+ summary?: string;
60
+ progress?: number;
61
+ };
51
62
  }
52
63
 
53
64
  export type FetcherResult =
@@ -55,6 +66,7 @@ export type FetcherResult =
55
66
  | FetcherJsonResult
56
67
  | FetcherGraphResult
57
68
  | FetcherMarkdownResult
58
- | FetcherStatusResult;
69
+ | FetcherStatusResult
70
+ | GetFetcherStatusResult;
59
71
 
60
72
  export type FetcherDefinitionsResponse = { [type: string]: FetcherDefinition };
@@ -11,7 +11,7 @@ import { useState, useEffect } from "react";
11
11
  function uniq(array) {
12
12
  return array && array.length ? baseUniq(array) : [];
13
13
  }
14
- const get$8 = (actionId, taskId, options = { timeout: null }, config) => {
14
+ const get$9 = (actionId, taskId, options = { timeout: null }, config) => {
15
15
  const searchParams = [];
16
16
  if (!isNil(options.timeout)) {
17
17
  searchParams.push(`max_timeout=${options.timeout}`);
@@ -22,14 +22,14 @@ const get$8 = (actionId, taskId, options = { timeout: null }, config) => {
22
22
  config
23
23
  );
24
24
  };
25
- const status = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
25
+ const status$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26
26
  __proto__: null,
27
- get: get$8
27
+ get: get$9
28
28
  }, Symbol.toStringTag, { value: "Module" }));
29
29
  const uri$c = () => {
30
30
  return joinUri(uri(), "actions");
31
31
  };
32
- const get$7 = (config) => {
32
+ const get$8 = (config) => {
33
33
  return hget(uri$c(), null, config);
34
34
  };
35
35
  const post$3 = (actionId, selectors, params, context, options = { timeout: null }, config) => {
@@ -60,9 +60,9 @@ const post$3 = (actionId, selectors, params, context, options = { timeout: null
60
60
  };
61
61
  const actions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
62
62
  __proto__: null,
63
- get: get$7,
63
+ get: get$8,
64
64
  post: post$3,
65
- status,
65
+ status: status$1,
66
66
  uri: uri$c
67
67
  }, Symbol.toStringTag, { value: "Module" }));
68
68
  const uri$b = (searchParams) => {
@@ -71,7 +71,7 @@ const uri$b = (searchParams) => {
71
71
  const post$2 = (body) => {
72
72
  return hpost(uri$b(), body);
73
73
  };
74
- const get$6 = (search) => {
74
+ const get$7 = (search) => {
75
75
  const nonce = localStorage.getItem(`${MY_LOCAL_STORAGE_PREFIX}.${StorageKey.LOGIN_NONCE}`);
76
76
  if (nonce) {
77
77
  search.set("nonce", JSON.parse(nonce));
@@ -81,7 +81,7 @@ const get$6 = (search) => {
81
81
  };
82
82
  const login = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
83
83
  __proto__: null,
84
- get: get$6,
84
+ get: get$7,
85
85
  post: post$2,
86
86
  uri: uri$b
87
87
  }, Symbol.toStringTag, { value: "Module" }));
@@ -96,14 +96,29 @@ const auth = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty
96
96
  const uri$9 = () => {
97
97
  return joinUri(uri(), "configs");
98
98
  };
99
- const get$5 = (config) => {
99
+ const get$6 = (config) => {
100
100
  return hget(uri$9(), null, config);
101
101
  };
102
102
  const configs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
103
103
  __proto__: null,
104
- get: get$5,
104
+ get: get$6,
105
105
  uri: uri$9
106
106
  }, Symbol.toStringTag, { value: "Module" }));
107
+ const get$5 = (fetcherId, taskId, options = { timeout: null }, config) => {
108
+ const searchParams = [];
109
+ if (!isNil(options.timeout)) {
110
+ searchParams.push(`max_timeout=${options.timeout}`);
111
+ }
112
+ return hget(
113
+ joinUri(uri$c(), `${fetcherId.replace(".", "/")}/status/${taskId}`),
114
+ searchParams.length > 0 ? new URLSearchParams(searchParams.join("&")) : null,
115
+ config
116
+ );
117
+ };
118
+ const status = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
119
+ __proto__: null,
120
+ get: get$5
121
+ }, Symbol.toStringTag, { value: "Module" }));
107
122
  const uri$8 = () => {
108
123
  return joinUri(uri(), "fetchers");
109
124
  };
@@ -117,6 +132,7 @@ const fetchers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
117
132
  __proto__: null,
118
133
  get: get$4,
119
134
  post: post$1,
135
+ status,
120
136
  uri: uri$8
121
137
  }, Symbol.toStringTag, { value: "Module" }));
122
138
  const uri$7 = () => {