@cccsaurora/clue-ui 1.3.0-dev.279 → 1.3.0-dev.284

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 (58) hide show
  1. package/{ActionForm-C4mWgND1.js → ActionForm-Cdo8jBDU.js} +7 -7
  2. package/{AnnotationDetails-CFsyeAZD.js → AnnotationDetails-CUU61Vwl.js} +4 -3
  3. package/{AnnotationPreview-CEopHIPL.js → AnnotationPreview-WuxXgLCE.js} +1 -1
  4. package/{ClueEnrichContext-CJEJxrgs.js → ClueEnrichContext-CZkS1jpb.js} +24 -9
  5. package/components/AnnotationDetailPopover.js +1 -1
  6. package/components/AnnotationDetails.js +3 -3
  7. package/components/AnnotationPreview.js +1 -1
  8. package/components/EnrichedCard.js +2 -2
  9. package/components/EnrichedChip.js +2 -2
  10. package/components/EnrichedTypography.js +2 -2
  11. package/components/RetryFailedEnrichments.js +1 -1
  12. package/components/SourcePicker.js +1 -1
  13. package/components/actions/ActionForm.js +1 -1
  14. package/components/actions/ExecutePopover.js +1 -1
  15. package/components/actions/ResultModal.js +1 -1
  16. package/components/enrichment/EnrichPopover.js +1 -1
  17. package/components/fetchers/Fetcher.js +1 -1
  18. package/components/group/GroupControl.js +1 -1
  19. package/components/stats/QueryStatus.js +1 -1
  20. package/database/globals.d.ts +5 -0
  21. package/database/globals.js +4 -0
  22. package/database/index.js +4 -1
  23. package/database/replication.d.ts +4 -0
  24. package/database/replication.js +7 -0
  25. package/database/selector.schema.json.d.ts +94 -71
  26. package/database/sync.d.ts +12 -0
  27. package/database/types.d.ts +58 -1
  28. package/hooks/ClueActionContext.js +2 -2
  29. package/hooks/ClueDatabaseContext.d.ts +33 -0
  30. package/hooks/ClueDatabaseContext.js +22 -5
  31. package/hooks/ClueEnrichContext.js +6 -3
  32. package/hooks/ClueFetcherContext.js +1 -1
  33. package/hooks/ClueGroupContext.js +1 -1
  34. package/hooks/CluePopupContext.js +2 -2
  35. package/hooks/ClueProvider.js +3 -3
  36. package/hooks/selectors.js +2 -2
  37. package/hooks/useActionResult.js +1 -1
  38. package/hooks/useAnnotations.js +6 -4
  39. package/hooks/useClue.js +1 -1
  40. package/hooks/useClueActions.js +1 -1
  41. package/hooks/useClueTypeConfig.js +3 -2
  42. package/hooks/useErrors.js +1 -1
  43. package/hooks/useFetcherResult.js +1 -1
  44. package/icons/Action.js +2 -2
  45. package/icons/Assessment.js +1 -1
  46. package/icons/Context.js +1 -1
  47. package/icons/Opinion.js +1 -1
  48. package/{index-C12gPw2W.js → index-BXnMCI65.js} +775 -9162
  49. package/{useClueTypeConfig-Z1LFp01b.js → index-BfslcSud.js} +104 -129
  50. package/{index-B6C2a_Lg.js → index-NaBSmVOx.js} +1 -1
  51. package/main.js +5 -5
  52. package/package.json +17 -17
  53. package/replication-BCvfRqsy.js +11777 -0
  54. package/{debounce-bV0h5FC5.js → sessionStorage-Dbmo2Exe.js} +49 -1
  55. package/useClueTypeConfig-DnF4rLsl.js +59 -0
  56. package/utils/constants.d.ts +1 -0
  57. package/utils/constants.js +2 -0
  58. package/utils/sessionStorage.js +8 -49
@@ -1,13 +1,70 @@
1
- import { Annotation, Selector, WithExtra } from "../types/lookup";
1
+ import { Annotation, Selector, WithExtra } from 'lib/types/lookup';
2
2
  import { RxCollection, RxDatabase, RxDocument } from 'rxdb';
3
3
 
4
4
 
5
+ /**
6
+ * Configuration options for the database.
7
+ */
5
8
  export interface DatabaseConfig {
9
+ /**
10
+ * The type of storage mechanism to use for persisting database data.
11
+ * - `'memory'`: Store data in memory (lost on page refresh)
12
+ * - `'sessionStorage'`: Store data in browser's sessionStorage (persists during session)
13
+ *
14
+ * @default 'memory'
15
+ */
6
16
  storageType?: 'memory' | 'sessionStorage';
17
+
18
+ /**
19
+ * Indicates whether the database is running in testing mode.
20
+ * When enabled, may apply test-specific configurations or disable certain features.
21
+ *
22
+ * @default false
23
+ */
7
24
  testing?: boolean;
25
+
26
+ /**
27
+ * Indicates whether the database is running in development mode.
28
+ * When enabled, provides additional logging and debugging capabilities.
29
+ *
30
+ * @default false
31
+ */
8
32
  devMode?: boolean;
33
+
34
+ /**
35
+ * Enables data replication to a remote server.
36
+ * When enabled, database changes are synchronized with the remote storage.
37
+ *
38
+ * @default false
39
+ */
40
+ replicate?: boolean;
41
+
42
+ /**
43
+ * The base URL of the clue API server used for replication and remote operations.
44
+ *
45
+ * @example 'https://api.clue.example.com'
46
+ */
47
+ baseURL?: string;
48
+
49
+ /**
50
+ * Add modify the Axios request configuration before the request is sent
51
+ *
52
+ * @param config The existing axios request config
53
+ */
54
+ onNetworkCall?: (config: AxiosRequestConfig) => AxiosRequestConfig;
55
+
56
+ /**
57
+ * Get an access token for the clue API. Used during replication.
58
+ *
59
+ * @returns An access token valid for use with the clue API.
60
+ */
61
+ getToken?: () => string;
9
62
  }
10
63
 
64
+ export type WithLastUpdated<T> = T & {
65
+ updated_at: number;
66
+ };
67
+
11
68
  export interface SelectorDocType {
12
69
  id: string;
13
70
  source: string;
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "@mui/material";
3
- import { g, C } from "../ActionForm-C4mWgND1.js";
4
- import "../useClueTypeConfig-Z1LFp01b.js";
3
+ import { g, C } from "../ActionForm-Cdo8jBDU.js";
4
+ import "../index-BfslcSud.js";
5
5
  import "../components/display/icons/Iconified.js";
6
6
  import "../components/ErrorBoundary.js";
7
7
  import "../data/event.js";
@@ -1,9 +1,42 @@
1
1
  import { ClueDatabase, DatabaseConfig } from "../database/types";
2
2
  import { FC, PropsWithChildren } from 'react';
3
3
 
4
+ /**
5
+ * Context properties for the Clue Database.
6
+ *
7
+ * Provides access to the Clue database instance, configuration, and authentication utilities
8
+ * for interacting with the Clue API.
9
+ *
10
+ * @property {ClueDatabase} [database] - The Clue database instance. Optional, may be undefined
11
+ * if the database is not yet initialized.
12
+ *
13
+ * @property {DatabaseConfig} [databaseConfig] - Configuration settings for the database connection.
14
+ * Optional, may be undefined if configuration has not been loaded.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const contextProps: ClueDatabaseContextProps = {
19
+ * database: myDatabaseInstance,
20
+ * databaseConfig: myConfig
21
+ * };
22
+ * ```
23
+ */
4
24
  export interface ClueDatabaseContextProps {
25
+ /**
26
+ * The Clue Database instance used for data operations and queries. Optional.
27
+ */
5
28
  database?: ClueDatabase;
29
+ /**
30
+ * Configuration settings for the database connection and behavior.
31
+ * Optional - may be undefined if using default database configuration.
32
+ */
6
33
  databaseConfig?: DatabaseConfig;
34
+ /**
35
+ * Get an access token for the clue API. Used during replication. Must be a stable reference.
36
+ *
37
+ * @returns An access token valid for use with the clue API.
38
+ */
39
+ getToken?: () => string;
7
40
  }
8
41
  export type ClueDatabaseContextType = ClueDatabase;
9
42
  export declare const ClueDatabaseContext: import('react').Context<ClueDatabase>;
@@ -1,18 +1,35 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { b as buildDatabase } from "../index-C12gPw2W.js";
3
- import { createContext, useState, useEffect } from "react";
2
+ import { b as buildDatabase } from "../index-BXnMCI65.js";
3
+ import { createContext, useState, useRef, useEffect } from "react";
4
4
  const ClueDatabaseContext = createContext(null);
5
5
  const ClueDatabaseProvider = ({
6
6
  children,
7
7
  database: _database,
8
- databaseConfig
8
+ databaseConfig,
9
+ getToken
9
10
  }) => {
10
11
  const [database, setDatabase] = useState();
12
+ const getTokenRef = useRef(getToken);
13
+ useEffect(() => {
14
+ getTokenRef.current = getToken;
15
+ }, [getToken]);
11
16
  useEffect(() => {
12
17
  if (_database) {
13
18
  setDatabase(_database);
14
- } else {
15
- buildDatabase(databaseConfig).then(setDatabase);
19
+ }
20
+ }, [_database]);
21
+ useEffect(() => {
22
+ let cancelled = false;
23
+ if (!_database) {
24
+ console.warn("It is heavily suggested to initialize the database outside of the React component tree.");
25
+ buildDatabase({ getToken: getTokenRef.current, ...databaseConfig }).then((_db) => {
26
+ if (!cancelled) {
27
+ setDatabase(_db);
28
+ }
29
+ });
30
+ return () => {
31
+ cancelled = true;
32
+ };
16
33
  }
17
34
  }, [_database, databaseConfig]);
18
35
  return /* @__PURE__ */ jsx(ClueDatabaseContext.Provider, { value: database, children });
@@ -1,14 +1,17 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../iconify-CXMreGTg.js";
3
- import "../useClueTypeConfig-Z1LFp01b.js";
3
+ import "../index-BfslcSud.js";
4
+ import "../database/globals.js";
4
5
  import "../utils/loggerUtil.js";
5
- import { C, a } from "../ClueEnrichContext-CJEJxrgs.js";
6
- import "../debounce-bV0h5FC5.js";
6
+ import { C, a } from "../ClueEnrichContext-CZkS1jpb.js";
7
+ import "../sessionStorage-Dbmo2Exe.js";
7
8
  import "../groupBy-xqz-n0Vd.js";
9
+ import "../useClueTypeConfig-DnF4rLsl.js";
8
10
  import "react";
9
11
  import "../index-AMfoEg_6.js";
10
12
  import "./ClueDatabaseContext.js";
11
13
  import "./useClueConfig.js";
14
+ import "../_baseUniq-BI9GIHMF.js";
12
15
  export {
13
16
  C as ClueEnrichContext,
14
17
  a as ClueEnrichProvider
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { a as api } from "../useClueTypeConfig-Z1LFp01b.js";
2
+ import { a as api } from "../index-BfslcSud.js";
3
3
  import { SNACKBAR_EVENT_ID } from "../data/event.js";
4
4
  import { safeDispatchEvent } from "../utils/window.js";
5
5
  import { useState, useRef, useMemo, useCallback, useEffect } from "react";
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useState, useMemo } from "react";
3
3
  import { c as createContext } from "../index-AMfoEg_6.js";
4
- import { b as useClueEnrichSelector } from "../ActionForm-C4mWgND1.js";
4
+ import { b as useClueEnrichSelector } from "../ActionForm-Cdo8jBDU.js";
5
5
  const ClueGroupContext = createContext(null);
6
6
  const ClueGroupProvider = ({ children, type, classification }) => {
7
7
  const defaultClassification = useClueEnrichSelector((ctx) => ctx.defaultClassification);
@@ -1,9 +1,9 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../components/AnnotationDetailPopover.js";
3
- import { C, a } from "../AnnotationPreview-CEopHIPL.js";
3
+ import { C, a } from "../AnnotationPreview-WuxXgLCE.js";
4
4
  import "../data/event.js";
5
5
  import "../utils/window.js";
6
- import "../AnnotationDetails-CFsyeAZD.js";
6
+ import "../AnnotationDetails-CUU61Vwl.js";
7
7
  import "react";
8
8
  import "../index-AMfoEg_6.js";
9
9
  export {
@@ -1,11 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { C as ClueActionProvider } from "../ActionForm-C4mWgND1.js";
2
+ import { C as ClueActionProvider } from "../ActionForm-Cdo8jBDU.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-CJEJxrgs.js";
6
+ import { a as ClueEnrichProvider } from "../ClueEnrichContext-CZkS1jpb.js";
7
7
  import { ClueFetcherProvider } from "./ClueFetcherContext.js";
8
- import { a as CluePopupProvider } from "../AnnotationPreview-CEopHIPL.js";
8
+ import { a as CluePopupProvider } from "../AnnotationPreview-WuxXgLCE.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, d, b, c } from "../ActionForm-C4mWgND1.js";
1
+ import { a, d, b, c } from "../ActionForm-Cdo8jBDU.js";
2
2
  import "./ClueComponentContext.js";
3
- import "../ClueEnrichContext-CJEJxrgs.js";
3
+ import "../ClueEnrichContext-CZkS1jpb.js";
4
4
  import "./ClueFetcherContext.js";
5
5
  import "../index-AMfoEg_6.js";
6
6
  export {
@@ -1,5 +1,5 @@
1
1
  import "react";
2
- import { f } from "../ActionForm-C4mWgND1.js";
2
+ import { f } from "../ActionForm-Cdo8jBDU.js";
3
3
  export {
4
4
  f as useActionResult
5
5
  };
@@ -1,8 +1,9 @@
1
- import { u as uniqBy } from "../ClueEnrichContext-CJEJxrgs.js";
1
+ import { u as uniqBy } from "../ClueEnrichContext-CZkS1jpb.js";
2
2
  import { useContext, useMemo, useState, useEffect } from "react";
3
3
  import { ClueDatabaseContext } from "./ClueDatabaseContext.js";
4
- import { b as useClueEnrichSelector } from "../ActionForm-C4mWgND1.js";
4
+ import { b as useClueEnrichSelector } from "../ActionForm-Cdo8jBDU.js";
5
5
  const useAnnotations = (type, value, _classification, { skipEnrichment } = { skipEnrichment: false }) => {
6
+ var _a;
6
7
  const database = useContext(ClueDatabaseContext);
7
8
  const defaultClassification = useClueEnrichSelector((ctx) => ctx.defaultClassification);
8
9
  const enrichReady = useClueEnrichSelector((ctx) => ctx.ready);
@@ -15,8 +16,9 @@ const useAnnotations = (type, value, _classification, { skipEnrichment } = { ski
15
16
  const [loading, setLoading] = useState(false);
16
17
  const [annotations, setAnnotations] = useState([]);
17
18
  const ready = useMemo(
18
- () => enrichReady && !!type && !!value && !!classification,
19
- [classification, enrichReady, type, value]
19
+ () => enrichReady && !!type && !!value && !!classification && !!(database == null ? void 0 : database.selectors) && !database.selectors.closed,
20
+ // eslint-disable-next-line react-hooks/exhaustive-deps
21
+ [classification, database == null ? void 0 : database.selectors, (_a = database == null ? void 0 : database.selectors) == null ? void 0 : _a.closed, enrichReady, type, value]
20
22
  );
21
23
  useEffect(() => {
22
24
  if (!ready || !(database == null ? void 0 : database.status)) {
package/hooks/useClue.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as useContext } from "../index-AMfoEg_6.js";
2
- import { C as ClueEnrichContext } from "../ClueEnrichContext-CJEJxrgs.js";
2
+ import { C as ClueEnrichContext } from "../ClueEnrichContext-CZkS1jpb.js";
3
3
  const useClue = () => {
4
4
  return useContext(ClueEnrichContext);
5
5
  };
@@ -1,4 +1,4 @@
1
- import { u } from "../ActionForm-C4mWgND1.js";
1
+ import { u } from "../ActionForm-Cdo8jBDU.js";
2
2
  import "../index-AMfoEg_6.js";
3
3
  export {
4
4
  u as default
@@ -1,7 +1,8 @@
1
- import { b } from "../useClueTypeConfig-Z1LFp01b.js";
1
+ import "../index-BfslcSud.js";
2
2
  import "../utils/loggerUtil.js";
3
3
  import "../_baseUniq-BI9GIHMF.js";
4
4
  import "react";
5
+ import { a } from "../useClueTypeConfig-DnF4rLsl.js";
5
6
  export {
6
- b as default
7
+ a as default
7
8
  };
@@ -1,6 +1,6 @@
1
1
  import { useContext, useState, useEffect } from "react";
2
2
  import { ClueDatabaseContext } from "./ClueDatabaseContext.js";
3
- import { b as useClueEnrichSelector } from "../ActionForm-C4mWgND1.js";
3
+ import { b as useClueEnrichSelector } from "../ActionForm-Cdo8jBDU.js";
4
4
  const useErrors = (value) => {
5
5
  const database = useContext(ClueDatabaseContext);
6
6
  const ready = useClueEnrichSelector((ctx) => ctx.ready);
@@ -1,5 +1,5 @@
1
1
  import { useState, useRef, useMemo, useEffect } from "react";
2
- import { u as useClueActions } from "../ActionForm-C4mWgND1.js";
2
+ import { u as useClueActions } from "../ActionForm-Cdo8jBDU.js";
3
3
  const useActionResult = (resultWithData, interval = 2e3) => {
4
4
  const [result, setResult] = useState(resultWithData);
5
5
  const timeoutRef = useRef(null);
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-CEopHIPL.js";
6
- import { u as useClueActions } from "../ActionForm-C4mWgND1.js";
5
+ import { C as CluePopupContext } from "../AnnotationPreview-WuxXgLCE.js";
6
+ import { u as useClueActions } from "../ActionForm-Cdo8jBDU.js";
7
7
  import { g as groupBy } from "../groupBy-xqz-n0Vd.js";
8
8
  import { memo, useRef, useMemo, useEffect } from "react";
9
9
  import { u as useContextSelector } from "../index-AMfoEg_6.js";
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } 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-CEopHIPL.js";
5
+ import { C as CluePopupContext } from "../AnnotationPreview-WuxXgLCE.js";
6
6
  import { g as groupBy } from "../groupBy-xqz-n0Vd.js";
7
7
  import { l as last } from "../last-CUCl67Im.js";
8
8
  import { m as maxBy } from "../maxBy-IKHzFrCS.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-CEopHIPL.js";
7
+ import { C as CluePopupContext } from "../AnnotationPreview-WuxXgLCE.js";
8
8
  import { g as groupBy } from "../groupBy-xqz-n0Vd.js";
9
9
  import { memo, useRef, useMemo, useEffect } from "react";
10
10
  import { u as useContextSelector } from "../index-AMfoEg_6.js";
package/icons/Opinion.js CHANGED
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } 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-CEopHIPL.js";
5
+ import { C as CluePopupContext } from "../AnnotationPreview-WuxXgLCE.js";
6
6
  import { g as groupBy } from "../groupBy-xqz-n0Vd.js";
7
7
  import { s as sortBy } from "../sortBy-DfSj8IoJ.js";
8
8
  import { s as sumBy } from "../sumBy-D-hb_NY-.js";