synapse-react-client 4.0.29 → 4.0.31
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/dist/SWC.index.d.ts +4 -0
- package/dist/SWC.index.d.ts.map +1 -1
- package/dist/SWC.index.js +2 -1
- package/dist/SWC.index.js.map +1 -1
- package/dist/assets/illustrations/curie_avatar.svg +52 -0
- package/dist/assets/illustrations/curie_avatar_head.js +91 -0
- package/dist/assets/illustrations/curie_avatar_head.js.map +1 -0
- package/dist/assets/illustrations/curie_avatar_head.svg +21 -0
- package/dist/assets/illustrations/discussions_illustration2.js +96 -0
- package/dist/assets/illustrations/discussions_illustration2.js.map +1 -0
- package/dist/assets/illustrations/discussions_illustration2.svg +17 -0
- package/dist/assets/illustrations/index.d.ts +3 -0
- package/dist/assets/illustrations/index.d.ts.map +1 -1
- package/dist/assets/illustrations/index.js +34 -32
- package/dist/assets/illustrations/index.js.map +1 -1
- package/dist/assets/mui_components/CurieAvatarHead.d.ts +5 -0
- package/dist/assets/mui_components/CurieAvatarHead.d.ts.map +1 -0
- package/dist/assets/mui_components/CurieAvatarHead.js +17 -0
- package/dist/assets/mui_components/CurieAvatarHead.js.map +1 -0
- package/dist/assets/themed_icons/Model.d.ts +3 -0
- package/dist/assets/themed_icons/Model.d.ts.map +1 -0
- package/dist/assets/themed_icons/Model.js +31 -0
- package/dist/assets/themed_icons/Model.js.map +1 -0
- package/dist/assets/themed_icons/index.d.ts +2 -1
- package/dist/assets/themed_icons/index.d.ts.map +1 -1
- package/dist/assets/themed_icons/index.js +19 -18
- package/dist/components/ChallengeDataDownload/ChallengeDataDownload.d.ts.map +1 -1
- package/dist/components/ChallengeDataDownload/ChallengeDataDownload.js +49 -39
- package/dist/components/ChallengeDataDownload/ChallengeDataDownload.js.map +1 -1
- package/dist/components/DataGrid/SynapseGrid.d.ts.map +1 -1
- package/dist/components/DataGrid/SynapseGrid.js +46 -45
- package/dist/components/DataGrid/SynapseGrid.js.map +1 -1
- package/dist/components/DataGrid/utils/DataGridUtils.js +1 -1
- package/dist/components/DataGrid/utils/DataGridUtils.js.map +1 -1
- package/dist/components/EntityFinder/EntityFinder.js +127 -127
- package/dist/components/EntityFinder/EntityFinder.js.map +1 -1
- package/dist/components/EntityFinder/details/view/DetailsView.js +53 -53
- package/dist/components/EntitySidebar/EntitySidebar.css +1 -1
- package/dist/components/EntitySidebar/EntitySidebar.module.js +11 -11
- package/dist/components/EntitySidebar/EntitySidebar.module.js.map +1 -1
- package/dist/components/EntitySidebar/EntitySidebar.module.scss +2 -2
- package/dist/components/EntityTreeTable/EntityTreeTable.d.ts +7 -0
- package/dist/components/EntityTreeTable/EntityTreeTable.d.ts.map +1 -1
- package/dist/components/EntityTreeTable/EntityTreeTable.js +24 -20
- package/dist/components/EntityTreeTable/EntityTreeTable.js.map +1 -1
- package/dist/components/EntityTreeTable/components/CheckboxCell.d.ts +4 -0
- package/dist/components/EntityTreeTable/components/CheckboxCell.d.ts.map +1 -0
- package/dist/components/EntityTreeTable/components/CheckboxCell.js +43 -0
- package/dist/components/EntityTreeTable/components/CheckboxCell.js.map +1 -0
- package/dist/components/EntityTreeTable/components/EntityNameCell.d.ts.map +1 -1
- package/dist/components/EntityTreeTable/components/EntityNameCell.js +10 -9
- package/dist/components/EntityTreeTable/components/EntityNameCell.js.map +1 -1
- package/dist/components/EntityTreeTable/components/EntityTreeTableContext.d.ts +6 -0
- package/dist/components/EntityTreeTable/components/EntityTreeTableContext.d.ts.map +1 -1
- package/dist/components/EntityTreeTable/components/EntityTreeTableContext.js.map +1 -1
- package/dist/components/EntityTreeTable/hooks/useTableColumns.d.ts +1 -1
- package/dist/components/EntityTreeTable/hooks/useTableColumns.d.ts.map +1 -1
- package/dist/components/EntityTreeTable/hooks/useTableColumns.js +49 -39
- package/dist/components/EntityTreeTable/hooks/useTableColumns.js.map +1 -1
- package/dist/components/EntityUpload/EntityUpload.js +6 -6
- package/dist/components/Forum/DiscussionEmpty.css +1 -0
- package/dist/components/Forum/DiscussionEmpty.d.ts +6 -0
- package/dist/components/Forum/DiscussionEmpty.d.ts.map +1 -0
- package/dist/components/Forum/DiscussionEmpty.js +30 -0
- package/dist/components/Forum/DiscussionEmpty.js.map +1 -0
- package/dist/components/Forum/DiscussionEmpty.module.js +10 -0
- package/dist/components/Forum/DiscussionEmpty.module.js.map +1 -0
- package/dist/components/Forum/DiscussionEmpty.module.scss +37 -0
- package/dist/components/Icon/Icon.d.ts.map +1 -1
- package/dist/components/Icon/Icon.js +82 -80
- package/dist/components/Icon/Icon.js.map +1 -1
- package/dist/components/ProvenanceGraph/ProvenanceGraph.d.ts.map +1 -1
- package/dist/components/ProvenanceGraph/ProvenanceGraph.js +39 -41
- package/dist/components/ProvenanceGraph/ProvenanceGraph.js.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.d.ts.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js +27 -20
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js.map +1 -1
- package/dist/components/SynapseChat/AccessLevelMenu.d.ts.map +1 -1
- package/dist/components/SynapseChat/AccessLevelMenu.js +1 -0
- package/dist/components/SynapseChat/AccessLevelMenu.js.map +1 -1
- package/dist/components/SynapseChat/GridAgentChat.d.ts.map +1 -1
- package/dist/components/SynapseChat/GridAgentChat.js +34 -25
- package/dist/components/SynapseChat/GridAgentChat.js.map +1 -1
- package/dist/components/SynapseChat/SynapseChat.d.ts +10 -12
- package/dist/components/SynapseChat/SynapseChat.d.ts.map +1 -1
- package/dist/components/SynapseChat/SynapseChat.js +106 -103
- package/dist/components/SynapseChat/SynapseChat.js.map +1 -1
- package/dist/components/SynapseChat/SynapseChatInteraction.css +1 -0
- package/dist/components/SynapseChat/SynapseChatInteraction.d.ts +22 -1
- package/dist/components/SynapseChat/SynapseChatInteraction.d.ts.map +1 -1
- package/dist/components/SynapseChat/SynapseChatInteraction.js +123 -94
- package/dist/components/SynapseChat/SynapseChatInteraction.js.map +1 -1
- package/dist/components/SynapseChat/SynapseChatInteraction.module.js +8 -0
- package/dist/components/SynapseChat/SynapseChatInteraction.module.js.map +1 -0
- package/dist/components/SynapseChat/SynapseChatInteraction.module.scss +25 -0
- package/dist/components/SynapseChat/SynapseChatMessage.d.ts +16 -1
- package/dist/components/SynapseChat/SynapseChatMessage.d.ts.map +1 -1
- package/dist/components/SynapseChat/SynapseChatMessage.js +25 -11
- package/dist/components/SynapseChat/SynapseChatMessage.js.map +1 -1
- package/dist/components/SynapseChat/components/AddFilesDialog/AddFilesDialog.d.ts +27 -0
- package/dist/components/SynapseChat/components/AddFilesDialog/AddFilesDialog.d.ts.map +1 -0
- package/dist/components/SynapseChat/components/AddFilesDialog/AddFilesDialog.js +79 -0
- package/dist/components/SynapseChat/components/AddFilesDialog/AddFilesDialog.js.map +1 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.css +1 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.d.ts +33 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.d.ts.map +1 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.js +77 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.js.map +1 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.module.js +8 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.module.js.map +1 -0
- package/dist/components/SynapseChat/components/AttachmentChip/AttachmentChip.module.scss +16 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.css +1 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.d.ts +23 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.d.ts.map +1 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.js +24 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.js.map +1 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.module.js +9 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.module.js.map +1 -0
- package/dist/components/SynapseChat/components/ChatAttachmentStrip/ChatAttachmentStrip.module.scss +19 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.css +1 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.d.ts +22 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.d.ts.map +1 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.js +80 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.js.map +1 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.module.js +9 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.module.js.map +1 -0
- package/dist/components/SynapseChat/components/ChatInputArea/ChatInputArea.module.scss +39 -0
- package/dist/components/SynapseChat/useChatState.d.ts +12 -4
- package/dist/components/SynapseChat/useChatState.d.ts.map +1 -1
- package/dist/components/SynapseChat/useChatState.js +38 -20
- package/dist/components/SynapseChat/useChatState.js.map +1 -1
- package/dist/components/SynapseChat/utils/constants.d.ts +8 -0
- package/dist/components/SynapseChat/utils/constants.d.ts.map +1 -0
- package/dist/components/SynapseChat/utils/constants.js +12 -0
- package/dist/components/SynapseChat/utils/constants.js.map +1 -0
- package/dist/components/SynapseChat/utils/types.d.ts +13 -0
- package/dist/components/SynapseChat/utils/types.d.ts.map +1 -0
- package/dist/components/SynapseChat/utils/types.js +0 -0
- package/dist/components/SynapseTable/datasets/DatasetItemsEditor.js +101 -101
- package/dist/components/SynapseTable/datasets/DatasetItemsEditor.js.map +1 -1
- package/dist/components/entity/page/action_menu/EntityActionMenu.d.ts +1 -0
- package/dist/components/entity/page/action_menu/EntityActionMenu.d.ts.map +1 -1
- package/dist/components/entity/page/action_menu/EntityActionMenu.js +8 -0
- package/dist/components/entity/page/action_menu/EntityActionMenu.js.map +1 -1
- package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.js +1 -1
- package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.js.map +1 -1
- package/dist/components/file/upload/BasicFileHandleUpload.d.ts +35 -4
- package/dist/components/file/upload/BasicFileHandleUpload.d.ts.map +1 -1
- package/dist/components/file/upload/BasicFileHandleUpload.js +22 -16
- package/dist/components/file/upload/BasicFileHandleUpload.js.map +1 -1
- package/dist/components/file/upload/MultiFileUploadProgress.js +6 -6
- package/dist/components/file/upload/UploadFilePanel.d.ts +32 -0
- package/dist/components/file/upload/UploadFilePanel.d.ts.map +1 -1
- package/dist/components/file/upload/UploadFilePanel.js +58 -42
- package/dist/components/file/upload/UploadFilePanel.js.map +1 -1
- package/dist/components/file/upload/validateFileSelection.d.ts +25 -0
- package/dist/components/file/upload/validateFileSelection.d.ts.map +1 -0
- package/dist/components/file/upload/validateFileSelection.js +18 -0
- package/dist/components/file/upload/validateFileSelection.js.map +1 -0
- package/dist/components/menu/DropdownMenu.d.ts +3 -0
- package/dist/components/menu/DropdownMenu.d.ts.map +1 -1
- package/dist/components/menu/DropdownMenu.js +108 -83
- package/dist/components/menu/DropdownMenu.js.map +1 -1
- package/dist/features/curator/dashboard/CuratorDashboard.d.ts.map +1 -1
- package/dist/features/curator/dashboard/CuratorDashboard.js +22 -23
- package/dist/features/curator/dashboard/CuratorDashboard.js.map +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCard.css +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCard.module.js +13 -13
- package/dist/features/curator/dashboard/components/CurationTaskCard.module.js.map +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCard.module.scss +2 -1
- package/dist/features/curator/dashboard/components/CurationTaskCardLayout.d.ts.map +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCardLayout.js +35 -27
- package/dist/features/curator/dashboard/components/CurationTaskCardLayout.js.map +1 -1
- package/dist/features/curator/dashboard/components/FilteredByTaskIdsBanner.d.ts +10 -0
- package/dist/features/curator/dashboard/components/FilteredByTaskIdsBanner.d.ts.map +1 -0
- package/dist/features/curator/dashboard/components/FilteredByTaskIdsBanner.js +19 -0
- package/dist/features/curator/dashboard/components/FilteredByTaskIdsBanner.js.map +1 -0
- package/dist/features/entity/metadata-task/components/MetadataTasksPage.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/components/MetadataTasksPage.js +50 -47
- package/dist/features/entity/metadata-task/components/MetadataTasksPage.js.map +1 -1
- package/dist/mocks/chat/mockChat.d.ts +13 -1
- package/dist/mocks/chat/mockChat.d.ts.map +1 -1
- package/dist/mocks/chat/mockChat.js +34 -9
- package/dist/mocks/chat/mockChat.js.map +1 -1
- package/dist/mocks/msw/handlers/chatHandlers.d.ts +1 -1
- package/dist/mocks/msw/handlers/chatHandlers.d.ts.map +1 -1
- package/dist/mocks/msw/handlers/chatHandlers.js +21 -7
- package/dist/mocks/msw/handlers/chatHandlers.js.map +1 -1
- package/dist/synapse-client/SynapseClient.d.ts +2 -2
- package/dist/synapse-client/SynapseClient.d.ts.map +1 -1
- package/dist/synapse-client/SynapseClient.js.map +1 -1
- package/dist/synapse-queries/KeyFactory.d.ts +10 -1
- package/dist/synapse-queries/KeyFactory.d.ts.map +1 -1
- package/dist/synapse-queries/KeyFactory.js +29 -2
- package/dist/synapse-queries/KeyFactory.js.map +1 -1
- package/dist/synapse-queries/asynchronous/usePollAsynchronousJob.d.ts +2 -2
- package/dist/synapse-queries/asynchronous/usePollAsynchronousJob.d.ts.map +1 -1
- package/dist/synapse-queries/asynchronous/usePollAsynchronousJob.js +2 -1
- package/dist/synapse-queries/asynchronous/usePollAsynchronousJob.js.map +1 -1
- package/dist/synapse-queries/chat/useChat.d.ts +3 -2
- package/dist/synapse-queries/chat/useChat.d.ts.map +1 -1
- package/dist/synapse-queries/chat/useChat.js +7 -6
- package/dist/synapse-queries/chat/useChat.js.map +1 -1
- package/dist/synapse-queries/dataaccess/index.d.ts +1 -0
- package/dist/synapse-queries/dataaccess/index.d.ts.map +1 -1
- package/dist/synapse-queries/dataaccess/index.js +4 -3
- package/dist/synapse-queries/dataaccess/useEDuc.d.ts +44 -0
- package/dist/synapse-queries/dataaccess/useEDuc.d.ts.map +1 -0
- package/dist/synapse-queries/dataaccess/useEDuc.js +75 -0
- package/dist/synapse-queries/dataaccess/useEDuc.js.map +1 -0
- package/dist/synapse-queries/featureflags/useGetFeatureFlag.d.ts.map +1 -1
- package/dist/synapse-queries/featureflags/useGetFeatureFlag.js +1 -1
- package/dist/synapse-queries/featureflags/useGetFeatureFlag.js.map +1 -1
- package/dist/synapse-queries/file/useDirectUploadToS3.js +6 -6
- package/dist/synapse-queries/index.js +181 -172
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/SynapseConstants.d.ts +3 -0
- package/dist/utils/SynapseConstants.d.ts.map +1 -1
- package/dist/utils/SynapseConstants.js +122 -119
- package/dist/utils/SynapseConstants.js.map +1 -1
- package/dist/utils/featureflag/FeatureFlags.d.ts +3 -1
- package/dist/utils/featureflag/FeatureFlags.d.ts.map +1 -1
- package/dist/utils/featureflag/FeatureFlags.js +1 -1
- package/dist/utils/featureflag/FeatureFlags.js.map +1 -1
- package/dist/utils/hooks/useCurationTaskListFilters.d.ts +36 -0
- package/dist/utils/hooks/useCurationTaskListFilters.d.ts.map +1 -0
- package/dist/utils/hooks/useCurationTaskListFilters.js +42 -0
- package/dist/utils/hooks/useCurationTaskListFilters.js.map +1 -0
- package/dist/utils/hooks/useUploadFileEntity/useUploadFileEntities.js +5 -5
- package/dist/utils/hooks/useUploadFileEntity/useUploadFiles.js +14 -14
- package/package.json +4 -4
|
@@ -8,22 +8,22 @@ import "../../synapse-queries/index.js";
|
|
|
8
8
|
import { NodeType as s, getLayoutedElements as ee, isArrayEqual as c } from "./ProvenanceUtils.js";
|
|
9
9
|
import { addActivityNode as te, addEntityNode as ne, addEntityPlaceholderNode as re, addExpandNode as l, addExternalNode as u, addUndefinedNode as ie, findEntityNode as ae, isRootEntity as d } from "./ProvenanceGraphUtils.js";
|
|
10
10
|
import { useCallback as f, useEffect as p, useState as m } from "react";
|
|
11
|
-
import { Button as
|
|
12
|
-
import { jsx as
|
|
13
|
-
import { USED_ENTITY_CONCRETE_TYPE_VALUE as
|
|
14
|
-
import { useErrorHandler as
|
|
15
|
-
import
|
|
11
|
+
import { Button as oe, CircularProgress as h, Stack as g, Typography as _ } from "@mui/material";
|
|
12
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
13
|
+
import { USED_ENTITY_CONCRETE_TYPE_VALUE as b } from "@sage-bionetworks/synapse-types";
|
|
14
|
+
import { useErrorHandler as x } from "react-error-boundary";
|
|
15
|
+
import S, { Controls as C, ReactFlowProvider as w, getConnectedEdges as se, useEdgesState as ce, useNodesState as le, useReactFlow as ue } from "reactflow";
|
|
16
16
|
import "reactflow/dist/style.css";
|
|
17
17
|
//#region src/components/ProvenanceGraph/ProvenanceGraph.tsx
|
|
18
|
-
var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e) => `We don’t have any provenance information for this ${e} yet.`, k = "#3B4046", fe = "#
|
|
19
|
-
let { entityRefs: w, containerHeight: D = "200px", initialNodes: A = [], initialEdges: j = [], onNodesChangedListener: M, onEdgesChangedListener: N, onEditProvenanceClicked: P } = i, { accessToken: F } = a(), [I, L] = m(A), [R, z] = m(j), [B, V] = le([]), [H, U] = ce([]), [W, G] = m(), [
|
|
18
|
+
var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e) => `We don’t have any provenance information for this ${e} yet.`, k = "#3B4046", fe = "#4D535A", pe = "#9EAAB7", me = "rgba(255, 255, 255, 0.60)", A = (i) => {
|
|
19
|
+
let { entityRefs: w, containerHeight: D = "200px", initialNodes: A = [], initialEdges: j = [], onNodesChangedListener: M, onEdgesChangedListener: N, onEditProvenanceClicked: P } = i, { accessToken: F } = a(), [I, L] = m(A), [R, z] = m(j), [B, V] = le([]), [H, U] = ce([]), [W, G] = m(), [he, ge] = m(!1), K = x(), { data: q, isSuccess: _e } = o(w, { throwOnError: !0 }), ve = [
|
|
20
20
|
s.ENTITY_PLACEHOLDER,
|
|
21
21
|
s.EXTERNAL,
|
|
22
22
|
s.ACTIVITY,
|
|
23
23
|
s.EXPAND
|
|
24
|
-
], ye = B.some((e) =>
|
|
25
|
-
|
|
26
|
-
let
|
|
24
|
+
], ye = B.some((e) => ve.includes(e.data.type)), be = he && !ye;
|
|
25
|
+
_e && q && q.totalNumberOfResults == 0 && K(`Unable to load provenance for the given Synapse IDs: ${w.map((e) => e.targetId).join(",")}`);
|
|
26
|
+
let J = q?.results, Y = J?.[0] ? n(r(J[0])).toLowerCase() : "entity", [X, xe] = m(!1), Z = ue(), Se = f((e, t) => {
|
|
27
27
|
G(t);
|
|
28
28
|
}, []), Q = f(async (e) => {
|
|
29
29
|
let { entityHeader: n, nodesCopy: r, edgesCopy: i, usedInActivity: a } = e;
|
|
@@ -37,7 +37,7 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
37
37
|
let e = await t.getActivityForEntity(n.id, n.versionNumber, F);
|
|
38
38
|
(!d({
|
|
39
39
|
entityHeader: n,
|
|
40
|
-
rootEntityHeaders:
|
|
40
|
+
rootEntityHeaders: J
|
|
41
41
|
}) || e.used && e.used.length >= T) && l({
|
|
42
42
|
entityHeader: n,
|
|
43
43
|
itemCount: e.used?.length,
|
|
@@ -47,18 +47,18 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
47
47
|
} catch (e) {
|
|
48
48
|
console.error(e), d({
|
|
49
49
|
entityHeader: n,
|
|
50
|
-
rootEntityHeaders:
|
|
50
|
+
rootEntityHeaders: J
|
|
51
51
|
}) && ie({
|
|
52
52
|
entityHeader: n,
|
|
53
53
|
nodesCopy: r,
|
|
54
54
|
edgesCopy: i
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
}, [F,
|
|
57
|
+
}, [F, J]);
|
|
58
58
|
p(() => {
|
|
59
59
|
!X && B.length > 0 && setTimeout(() => {
|
|
60
|
-
if (
|
|
61
|
-
let e = ae(
|
|
60
|
+
if (J) {
|
|
61
|
+
let e = ae(J[0], B);
|
|
62
62
|
if (e) {
|
|
63
63
|
let t = Z.getZoom(), n = t > E ? E : t;
|
|
64
64
|
Z?.setCenter(e.position.x + 150, e.position.y - 30, {
|
|
@@ -66,14 +66,14 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
66
66
|
duration: 0
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
xe(!0);
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
}, [
|
|
73
73
|
X,
|
|
74
74
|
B,
|
|
75
75
|
Z,
|
|
76
|
-
|
|
76
|
+
J
|
|
77
77
|
]);
|
|
78
78
|
let $ = f(async (e) => {
|
|
79
79
|
let { entityHeader: n, nodesCopy: r, edgesCopy: i } = e;
|
|
@@ -87,7 +87,7 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
87
87
|
}), e.used && e.used.length < T) {
|
|
88
88
|
let n = [];
|
|
89
89
|
e.used.forEach((t) => {
|
|
90
|
-
t.concreteType ==
|
|
90
|
+
t.concreteType == b ? n.push(t.reference) : u({
|
|
91
91
|
usedURL: t,
|
|
92
92
|
activity: e,
|
|
93
93
|
nodesCopy: r,
|
|
@@ -118,9 +118,9 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
118
118
|
}
|
|
119
119
|
}, [F, Q]);
|
|
120
120
|
p(() => {
|
|
121
|
-
if (
|
|
121
|
+
if (J && I.length == 0) {
|
|
122
122
|
let e = [...I], t = [...R], n = [];
|
|
123
|
-
|
|
123
|
+
J.forEach((r) => {
|
|
124
124
|
let i = Q({
|
|
125
125
|
entityHeader: r,
|
|
126
126
|
nodesCopy: e,
|
|
@@ -134,14 +134,14 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
134
134
|
});
|
|
135
135
|
n.push(a);
|
|
136
136
|
}), Promise.allSettled(n).finally(() => {
|
|
137
|
-
L(e), z(t),
|
|
137
|
+
L(e), z(t), ge(!0);
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
}, [
|
|
141
141
|
Q,
|
|
142
142
|
K,
|
|
143
143
|
$,
|
|
144
|
-
|
|
144
|
+
J,
|
|
145
145
|
w,
|
|
146
146
|
R,
|
|
147
147
|
I
|
|
@@ -153,7 +153,7 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
153
153
|
e("Web visualization does not support expanding this many items at this time.", "danger");
|
|
154
154
|
return;
|
|
155
155
|
} else {
|
|
156
|
-
t.label = /* @__PURE__ */
|
|
156
|
+
t.label = /* @__PURE__ */ v(h, { size: 30 });
|
|
157
157
|
let e = I.filter((e) => e.id != W.id), r = se([W], R)[0], i = R.filter((e) => e != r);
|
|
158
158
|
$({
|
|
159
159
|
entityHeader: n.entityHeader,
|
|
@@ -186,19 +186,17 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
186
186
|
M,
|
|
187
187
|
N
|
|
188
188
|
]);
|
|
189
|
-
let
|
|
189
|
+
let Ce = f((e) => {
|
|
190
190
|
e && e.deltaX !== void 0 && e.deltaY !== void 0 && window.scrollTo(window.scrollX + e.deltaX, window.scrollY + e.deltaY);
|
|
191
191
|
}, []);
|
|
192
|
-
return /* @__PURE__ */
|
|
192
|
+
return /* @__PURE__ */ v("div", {
|
|
193
193
|
className: "ProvenanceWidget",
|
|
194
194
|
role: "graphics-doc",
|
|
195
195
|
style: {
|
|
196
196
|
width: "100%",
|
|
197
|
-
height: D
|
|
198
|
-
backgroundColor: fe,
|
|
199
|
-
padding: "15px"
|
|
197
|
+
height: D
|
|
200
198
|
},
|
|
201
|
-
children: be ? /* @__PURE__ */
|
|
199
|
+
children: be ? /* @__PURE__ */ y(g, {
|
|
202
200
|
sx: {
|
|
203
201
|
display: "flex",
|
|
204
202
|
height: "100%",
|
|
@@ -207,7 +205,7 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
207
205
|
textAlign: "center"
|
|
208
206
|
},
|
|
209
207
|
children: [
|
|
210
|
-
/* @__PURE__ */
|
|
208
|
+
/* @__PURE__ */ v(_, {
|
|
211
209
|
sx: {
|
|
212
210
|
color: k,
|
|
213
211
|
fontSize: "16px",
|
|
@@ -217,23 +215,23 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
217
215
|
},
|
|
218
216
|
children: O
|
|
219
217
|
}),
|
|
220
|
-
/* @__PURE__ */
|
|
218
|
+
/* @__PURE__ */ v(_, {
|
|
221
219
|
sx: {
|
|
222
220
|
color: k,
|
|
223
221
|
fontSize: "14px",
|
|
224
222
|
lineHeight: "20px",
|
|
225
223
|
fontWeight: 440
|
|
226
224
|
},
|
|
227
|
-
children: de(
|
|
225
|
+
children: de(Y)
|
|
228
226
|
}),
|
|
229
|
-
P && /* @__PURE__ */
|
|
227
|
+
P && /* @__PURE__ */ v(oe, {
|
|
230
228
|
variant: "outlined",
|
|
231
229
|
sx: {
|
|
232
230
|
borderRadius: "6px",
|
|
233
231
|
border: "1px solid",
|
|
234
|
-
borderColor:
|
|
235
|
-
background:
|
|
236
|
-
color:
|
|
232
|
+
borderColor: pe,
|
|
233
|
+
background: me,
|
|
234
|
+
color: fe,
|
|
237
235
|
fontWeight: 540,
|
|
238
236
|
lineHeight: "12px",
|
|
239
237
|
letterSpacing: "-0.24px",
|
|
@@ -245,7 +243,7 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
245
243
|
children: "Edit Provenance"
|
|
246
244
|
})
|
|
247
245
|
]
|
|
248
|
-
}) : /* @__PURE__ */
|
|
246
|
+
}) : /* @__PURE__ */ v(S, {
|
|
249
247
|
defaultViewport: {
|
|
250
248
|
x: 0,
|
|
251
249
|
y: 0,
|
|
@@ -253,15 +251,15 @@ var T = 400, E = .85, D = "Edit Provenance", O = "No provenance data", de = (e)
|
|
|
253
251
|
},
|
|
254
252
|
nodes: B,
|
|
255
253
|
edges: H,
|
|
256
|
-
onNodeClick:
|
|
254
|
+
onNodeClick: Se,
|
|
257
255
|
attributionPosition: "bottom-right",
|
|
258
256
|
onConnect: void 0,
|
|
259
257
|
zoomOnScroll: !1,
|
|
260
|
-
onPaneScroll:
|
|
261
|
-
children: /* @__PURE__ */
|
|
258
|
+
onPaneScroll: Ce,
|
|
259
|
+
children: /* @__PURE__ */ v(C, {})
|
|
262
260
|
})
|
|
263
261
|
});
|
|
264
|
-
}, j = (e) => /* @__PURE__ */
|
|
262
|
+
}, j = (e) => /* @__PURE__ */ v(i, { children: /* @__PURE__ */ v(w, { children: /* @__PURE__ */ v(A, { ...e }) }) });
|
|
265
263
|
//#endregion
|
|
266
264
|
export { D as EDIT_PROVENANCE_TEXT, O as NO_PROVENANCE_TITLE, j as default };
|
|
267
265
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProvenanceGraph.js","names":[],"sources":["../../../src/components/ProvenanceGraph/ProvenanceGraph.tsx"],"sourcesContent":["import SynapseClient from '@/synapse-client'\nimport { useGetEntityHeaders } from '@/synapse-queries'\nimport {\n entityTypeToFriendlyName,\n getEntityTypeFromHeader,\n} from '@/utils/functions/EntityTypeUtils'\nimport { useSynapseContext } from '@/utils/context/SynapseContext'\nimport { CircularProgress, Typography, Button, Stack } from '@mui/material'\nimport {\n Activity,\n EntityHeader,\n ReferenceList,\n Used,\n USED_ENTITY_CONCRETE_TYPE_VALUE,\n UsedEntity,\n UsedURL,\n} from '@sage-bionetworks/synapse-types'\nimport { MouseEvent, useCallback, useEffect, useState, WheelEvent } from 'react'\nimport { useErrorHandler } from 'react-error-boundary'\nimport ReactFlow, {\n Controls,\n Edge,\n getConnectedEdges,\n Node,\n ReactFlowProvider,\n useEdgesState,\n useNodesState,\n useReactFlow,\n} from 'reactflow'\nimport { SynapseErrorBoundary } from '../error/ErrorBanner'\nimport { displayToast } from '../ToastMessage/ToastMessage'\nimport { ExpandGraphNodeDataProps } from './ExpandGraphNodeLabel'\nimport {\n addActivityNode,\n addEntityNode,\n addEntityPlaceholderNode,\n addExpandNode,\n addExternalNode,\n addUndefinedNode,\n findEntityNode,\n isRootEntity,\n} from './ProvenanceGraphUtils'\nimport {\n getLayoutedElements,\n isArrayEqual,\n NodeType,\n ProvenanceNodeData,\n} from './ProvenanceUtils'\nimport 'reactflow/dist/style.css'\n\nexport type ProvenanceProps = {\n // what entity nodes should we start with?\n entityRefs: ReferenceList\n containerHeight?: string\n initialNodes?: Node[]\n initialEdges?: Edge[]\n onNodesChangedListener?: (nodes: Node[]) => void\n onEdgesChangedListener?: (edges: Edge[]) => void\n onEditProvenanceClicked?: () => void\n}\n\nconst MAX_ACTIVITY_EXPAND_NODES = 400\nconst DEFAULT_ZOOM = 0.85\nexport const EDIT_PROVENANCE_TEXT = 'Edit Provenance'\nexport const NO_PROVENANCE_TITLE = 'No provenance data'\nconst NO_PROVENANCE_MESSAGE = (entityTypeName: string) =>\n `We don’t have any provenance information for this ${entityTypeName} yet.`\nconst NO_PROVENANCE_TEXT_COLOR = '#3B4046'\nconst PROVENANCE_BACKGROUND_COLOR = '#F9F9FA'\nconst EDIT_PROVENANCE_BUTTON_TEXT_COLOR = '#4D535A'\nconst EDIT_PROVENANCE_BUTTON_BORDER_COLOR = '#9EAAB7'\nconst EDIT_PROVENANCE_BUTTON_BACKGROUND_COLOR = 'rgba(255, 255, 255, 0.60)'\n\n/**\n * Renders a Provenance Graph for a set of entities.\n * New Nodes are added to tempNodes, and new Edges are added to tempEdges.\n * On change, these are fed into the dagre js graph library to figure out the node positions,\n * and the output stored in 'nodes' and 'edges'. The 'nodes' and 'edges' arrays are used by the\n * ReactFlow component.\n */\nconst ProvenanceReactFlow = (props: ProvenanceProps): React.ReactNode => {\n const {\n entityRefs: rootEntityRefs,\n containerHeight = '200px',\n initialNodes = [],\n initialEdges = [],\n onNodesChangedListener,\n onEdgesChangedListener,\n onEditProvenanceClicked,\n } = props\n const { accessToken } = useSynapseContext()\n const [tempNodes, setTempNodes] = useState<Node[]>(initialNodes)\n const [tempEdges, setTempEdges] = useState<Edge[]>(initialEdges)\n const [nodes, setNodes] = useNodesState([])\n const [edges, setEdges] = useEdgesState([])\n const [clickedNode, setClickedNode] = useState<Node>()\n const [initialBuildComplete, setInitialBuildComplete] =\n useState<boolean>(false)\n const handleError = useErrorHandler()\n\n const { data: rootEntityHeadersPage, isSuccess } = useGetEntityHeaders(\n rootEntityRefs,\n { throwOnError: true },\n )\n\n const PROVENANCE_NODE_TYPES = [\n NodeType.ENTITY_PLACEHOLDER,\n NodeType.EXTERNAL,\n NodeType.ACTIVITY,\n NodeType.EXPAND,\n ]\n const hasProvenanceNodes = nodes.some(node =>\n PROVENANCE_NODE_TYPES.includes((node.data as ProvenanceNodeData).type),\n )\n\n const showNoProvenance = initialBuildComplete && !hasProvenanceNodes\n\n if (\n isSuccess &&\n rootEntityHeadersPage &&\n rootEntityHeadersPage.totalNumberOfResults == 0\n ) {\n const synapseIds = rootEntityRefs.map(ref => ref.targetId).join(',')\n handleError(\n `Unable to load provenance for the given Synapse IDs: ${synapseIds}`,\n )\n }\n const rootEntityHeaders = rootEntityHeadersPage?.results\n const entityTypeName = rootEntityHeaders?.[0]\n ? entityTypeToFriendlyName(\n getEntityTypeFromHeader(rootEntityHeaders[0]),\n ).toLowerCase()\n : 'entity'\n const [initializedPosition, setInitializedPosition] = useState<boolean>(false)\n\n // Get the react flow instance so we attempt to properly center the view.\n const reactFlowInstance = useReactFlow()\n\n const onClickNode = useCallback((_event: MouseEvent, node: Node) => {\n setClickedNode(node)\n }, [])\n\n /**\n * Called when we have a new entity to add to the graph. This will result in adding\n * a new Entity Node to the nodesCopy, a link from the usedInActivity to the new Entity Node,\n * AND it will look for an Activity associated with the new entity. If an Activity is found,\n * it will add an Expand Node for the user to click (to expand to see this Activity!).\n * If this is a root node (starting entity node), then we automatically add the Activity Node\n * and process it.\n */\n const addEntity = useCallback(\n async (params: {\n entityHeader: EntityHeader\n usedInActivity?: Activity\n nodesCopy: Node[]\n edgesCopy: Edge[]\n }) => {\n const { entityHeader, nodesCopy, edgesCopy, usedInActivity } = params\n addEntityNode({\n entityHeader,\n activity: usedInActivity,\n nodesCopy,\n edgesCopy,\n })\n //look for Activity\n try {\n const activity = await SynapseClient.getActivityForEntity(\n entityHeader.id,\n entityHeader.versionNumber,\n accessToken,\n )\n // if this is not a root node (or there are too many items to show), add an expand node\n if (\n !isRootEntity({ entityHeader, rootEntityHeaders }) ||\n (activity.used && activity.used.length >= MAX_ACTIVITY_EXPAND_NODES)\n ) {\n addExpandNode({\n entityHeader,\n itemCount: activity.used?.length,\n nodesCopy,\n edgesCopy,\n })\n }\n } catch (e) {\n // Activity is not accessible\n console.error(e)\n if (\n isRootEntity({\n entityHeader,\n rootEntityHeaders,\n })\n ) {\n // add provenance undefined node\n addUndefinedNode({\n entityHeader,\n nodesCopy,\n edgesCopy,\n })\n }\n }\n },\n [accessToken, rootEntityHeaders],\n )\n\n /**\n * This effect attempts to center the graph on one of the root nodes.\n * Only initializes after after a root node has been added to the graph.\n */\n useEffect(() => {\n if (!initializedPosition && nodes.length > 0) {\n setTimeout(() => {\n if (rootEntityHeaders) {\n const rootEntityNode = findEntityNode(rootEntityHeaders[0], nodes)\n if (rootEntityNode) {\n const currentZoom = reactFlowInstance.getZoom()\n const zoom = currentZoom > DEFAULT_ZOOM ? DEFAULT_ZOOM : currentZoom\n reactFlowInstance?.setCenter(\n rootEntityNode.position.x + 150,\n rootEntityNode.position.y - 30,\n { zoom, duration: 0 },\n )\n }\n setInitializedPosition(true)\n }\n })\n }\n }, [initializedPosition, nodes, reactFlowInstance, rootEntityHeaders])\n\n /**\n * This is called when the user clicks on an Expand Node. It will add the associated Activity\n * and all \"used\" items (entities and urls) to the graph by adding items to the nodesCopy and edgesCopy arrays.\n */\n const onExpandEntity = useCallback(\n async (params: {\n entityHeader: EntityHeader\n nodesCopy: Node[]\n edgesCopy: Edge[]\n }) => {\n const { entityHeader, nodesCopy, edgesCopy } = params\n try {\n const activity = await SynapseClient.getActivityForEntity(\n entityHeader.id,\n entityHeader.versionNumber,\n accessToken,\n )\n addActivityNode({\n activity,\n entityHeader,\n nodesCopy,\n edgesCopy,\n })\n // go through Activity.used array to add these nodes/edges\n if (activity.used && activity.used.length < MAX_ACTIVITY_EXPAND_NODES) {\n const usedEntityReferences: ReferenceList = []\n activity.used.forEach((usedItem: Used) => {\n if (usedItem.concreteType == USED_ENTITY_CONCRETE_TYPE_VALUE) {\n usedEntityReferences.push((usedItem as UsedEntity).reference)\n } else {\n // UsedURL\n const usedURL = usedItem as UsedURL\n addExternalNode({ usedURL, activity, nodesCopy, edgesCopy })\n }\n })\n const usedEntityHeadersPage = await SynapseClient.getEntityHeaders(\n usedEntityReferences,\n accessToken,\n )\n const { results: usedEntityHeaderPageResults } = usedEntityHeadersPage\n // find refs that were not returned by the entity header call\n const refsMissingEntityHeaders = usedEntityReferences.filter(ref => {\n return (\n usedEntityHeaderPageResults.find(header => {\n return header.id == ref.targetId\n }) == undefined\n )\n })\n refsMissingEntityHeaders.forEach(ref => {\n addEntityPlaceholderNode({ ref, activity, nodesCopy, edgesCopy })\n })\n const addEntityPromises: Promise<void>[] = []\n usedEntityHeaderPageResults.forEach(header => {\n addEntityPromises.push(\n addEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n usedInActivity: activity,\n }),\n )\n })\n await Promise.allSettled(addEntityPromises)\n }\n } catch (e) {\n // Activity is not accessible\n console.error(e)\n }\n },\n [accessToken, addEntity],\n )\n\n /**\n * This effect code executes when no nodes have been added.\n * It will add the root nodes, and attempt to expand the root nodes.\n */\n useEffect(() => {\n if (rootEntityHeaders && tempNodes.length == 0) {\n const nodesCopy = [...tempNodes]\n const edgesCopy = [...tempEdges]\n const addAndExpandPromises: Promise<void>[] = []\n rootEntityHeaders.forEach(header => {\n const addEntityPromise = addEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n })\n addAndExpandPromises.push(addEntityPromise)\n\n const expandEntityPromise = onExpandEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n })\n addAndExpandPromises.push(expandEntityPromise)\n })\n Promise.allSettled(addAndExpandPromises).finally(() => {\n setTempNodes(nodesCopy)\n setTempEdges(edgesCopy)\n setInitialBuildComplete(true)\n })\n }\n }, [\n addEntity,\n handleError,\n onExpandEntity,\n rootEntityHeaders,\n rootEntityRefs,\n tempEdges,\n tempNodes,\n ])\n\n /**\n * This effect code executes when a node is clicked.\n * We check to see if it is an expand node. If it is, then we remove the expand node (and associated edge)\n * and ask for the Activity and associated \"used\" nodes (entities and URLs)\n */\n useEffect(() => {\n const nodeData: ProvenanceNodeData = clickedNode?.data as ProvenanceNodeData\n if (clickedNode && nodeData?.type == NodeType.EXPAND) {\n const expandNodeDataProps = nodeData.props as ExpandGraphNodeDataProps\n if (expandNodeDataProps.itemCount > MAX_ACTIVITY_EXPAND_NODES) {\n displayToast(\n 'Web visualization does not support expanding this many items at this time.',\n 'danger',\n )\n return\n } else {\n // graph will be used outside of synapse, so show a non-branded spinner\n nodeData.label = <CircularProgress size={30} />\n // remove clicked node\n const nodesWithoutExpandNode = tempNodes.filter(\n node => node.id != clickedNode.id,\n )\n const edgeToRemove = getConnectedEdges([clickedNode], tempEdges)[0]\n const edgesWithoutExpandEdge = tempEdges.filter(\n edge => edge != edgeToRemove,\n )\n onExpandEntity({\n entityHeader: expandNodeDataProps.entityHeader,\n nodesCopy: nodesWithoutExpandNode,\n edgesCopy: edgesWithoutExpandEdge,\n }).finally(() => {\n setTempNodes(nodesWithoutExpandNode)\n setTempEdges(edgesWithoutExpandEdge)\n })\n }\n setClickedNode(undefined)\n }\n }, [clickedNode, tempNodes, tempEdges, onExpandEntity])\n\n /**\n * This effect code is run when the graph nodes or edges change.\n * It feeds the nodes and edges into our layout library to figure out where they should be positioned.\n * The result is saved in the state variable \"nodes\" and \"edges\".\n */\n useEffect(() => {\n const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements(\n tempNodes,\n tempEdges,\n 'TB',\n )\n // hack: ProvenanceUtils.getProvenanceNode() returns a new object every time, so check to see if\n // there were any real changes\n if (!isArrayEqual(layoutedNodes, nodes)) {\n setNodes(layoutedNodes)\n if (onNodesChangedListener) {\n onNodesChangedListener(layoutedNodes)\n }\n }\n if (!isArrayEqual(layoutedEdges, edges)) {\n setEdges(layoutedEdges)\n if (onEdgesChangedListener) {\n onEdgesChangedListener(layoutedEdges)\n }\n }\n }, [\n tempNodes,\n tempEdges,\n nodes,\n edges,\n setNodes,\n setEdges,\n initializedPosition,\n reactFlowInstance,\n rootEntityRefs,\n onNodesChangedListener,\n onEdgesChangedListener,\n ])\n\n const onPaneScrollFunction: (event?: WheelEvent) => void = useCallback(\n event => {\n // Cannot simply check the truthy value of event.deltaX (or Y) because the value might be 0 (or -0), which is falsy\n if (\n event &&\n typeof event.deltaX !== 'undefined' &&\n typeof event.deltaY !== 'undefined'\n ) {\n window.scrollTo(\n window.scrollX + event.deltaX,\n window.scrollY + event.deltaY,\n )\n }\n },\n [],\n )\n return (\n <div\n className=\"ProvenanceWidget\"\n role=\"graphics-doc\" //https://www.w3.org/wiki/SVG_Accessibility/ARIA_roles_for_charts#Document_Roles\n style={{\n width: '100%',\n height: containerHeight,\n backgroundColor: PROVENANCE_BACKGROUND_COLOR,\n padding: '15px',\n }}\n >\n {showNoProvenance ? (\n <Stack\n sx={{\n display: 'flex',\n height: '100%',\n alignItems: 'center',\n justifyContent: 'center',\n textAlign: 'center',\n }}\n >\n <Typography\n sx={{\n color: NO_PROVENANCE_TEXT_COLOR,\n fontSize: '16px',\n lineHeight: '24px',\n fontWeight: 540,\n marginBottom: '12px',\n }}\n >\n {NO_PROVENANCE_TITLE}\n </Typography>\n <Typography\n sx={{\n color: NO_PROVENANCE_TEXT_COLOR,\n fontSize: '14px',\n lineHeight: '20px',\n fontWeight: 440,\n }}\n >\n {NO_PROVENANCE_MESSAGE(entityTypeName)}\n </Typography>\n {onEditProvenanceClicked && (\n <Button\n variant=\"outlined\"\n sx={{\n borderRadius: '6px',\n border: '1px solid',\n borderColor: EDIT_PROVENANCE_BUTTON_BORDER_COLOR,\n background: EDIT_PROVENANCE_BUTTON_BACKGROUND_COLOR,\n color: EDIT_PROVENANCE_BUTTON_TEXT_COLOR,\n fontWeight: 540,\n lineHeight: '12px' /* 100% */,\n letterSpacing: '-0.24px',\n marginTop: '20px',\n height: '28px',\n padding: '8px',\n }}\n onClick={onEditProvenanceClicked}\n >\n {EDIT_PROVENANCE_TEXT}\n </Button>\n )}\n </Stack>\n ) : (\n <ReactFlow\n defaultViewport={{ x: 0, y: 0, zoom: DEFAULT_ZOOM }}\n nodes={nodes}\n edges={edges}\n onNodeClick={onClickNode}\n // onNodesChange={onNodesChange} // SWC-6804: When the nodes/edges are updated (expanded) the graph is already re-rendered.\n // onEdgesChange={onEdgesChange} // Specifying these callbacks causes an infinite re-rendering loop.\n attributionPosition=\"bottom-right\"\n onConnect={undefined}\n zoomOnScroll={false}\n onPaneScroll={onPaneScrollFunction}\n >\n <Controls />\n </ReactFlow>\n )}\n </div>\n )\n}\n\nconst ProvenanceGraph = (props: ProvenanceProps): React.ReactNode => {\n return (\n <SynapseErrorBoundary>\n <ReactFlowProvider>\n <ProvenanceReactFlow {...props} />\n </ReactFlowProvider>\n </SynapseErrorBoundary>\n )\n}\n\nexport default ProvenanceGraph\n"],"mappings":";;;;;;;;;;;;;;;;;AA6DA,IAAM,IAA4B,KAC5B,IAAe,KACR,IAAuB,mBACvB,IAAsB,sBAC7B,MAAyB,MAC7B,qDAAqD,EAAe,QAChE,IAA2B,WAC3B,KAA8B,WAC9B,KAAoC,WACpC,KAAsC,WACtC,KAA0C,6BAS1C,KAAuB,MAA4C;CACvE,IAAM,EACJ,YAAY,G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Ae;MACf,WAAW;MACX,QAAQ;MACR,SAAS;KACX;KACA,SAAS;;IAGH,CAAA;GAEL;OAEP,kBAAC,GAAD;GACE,iBAAiB;IAAE,GAAG;IAAG,GAAG;IAAG,MAAM;GAAa;GAC3C;GACA;GACP,aAAa;GAGb,qBAAoB;GACpB,WAAW,KAAA;GACX,cAAc;GACd,cAAc;aAEd,kBAAC,IAAD,CAAW,CAAA;EACF,CAAA;CAEV,CAAA;AAET,GAEM,KAAmB,MAErB,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAqB,GAAI,EAAQ,CAAA,EAChB,CAAA,EACC,CAAA"}
|
|
1
|
+
{"version":3,"file":"ProvenanceGraph.js","names":[],"sources":["../../../src/components/ProvenanceGraph/ProvenanceGraph.tsx"],"sourcesContent":["import SynapseClient from '@/synapse-client'\nimport { useGetEntityHeaders } from '@/synapse-queries'\nimport {\n entityTypeToFriendlyName,\n getEntityTypeFromHeader,\n} from '@/utils/functions/EntityTypeUtils'\nimport { useSynapseContext } from '@/utils/context/SynapseContext'\nimport { CircularProgress, Typography, Button, Stack } from '@mui/material'\nimport {\n Activity,\n EntityHeader,\n ReferenceList,\n Used,\n USED_ENTITY_CONCRETE_TYPE_VALUE,\n UsedEntity,\n UsedURL,\n} from '@sage-bionetworks/synapse-types'\nimport { MouseEvent, useCallback, useEffect, useState, WheelEvent } from 'react'\nimport { useErrorHandler } from 'react-error-boundary'\nimport ReactFlow, {\n Controls,\n Edge,\n getConnectedEdges,\n Node,\n ReactFlowProvider,\n useEdgesState,\n useNodesState,\n useReactFlow,\n} from 'reactflow'\nimport { SynapseErrorBoundary } from '../error/ErrorBanner'\nimport { displayToast } from '../ToastMessage/ToastMessage'\nimport { ExpandGraphNodeDataProps } from './ExpandGraphNodeLabel'\nimport {\n addActivityNode,\n addEntityNode,\n addEntityPlaceholderNode,\n addExpandNode,\n addExternalNode,\n addUndefinedNode,\n findEntityNode,\n isRootEntity,\n} from './ProvenanceGraphUtils'\nimport {\n getLayoutedElements,\n isArrayEqual,\n NodeType,\n ProvenanceNodeData,\n} from './ProvenanceUtils'\nimport 'reactflow/dist/style.css'\n\nexport type ProvenanceProps = {\n // what entity nodes should we start with?\n entityRefs: ReferenceList\n containerHeight?: string\n initialNodes?: Node[]\n initialEdges?: Edge[]\n onNodesChangedListener?: (nodes: Node[]) => void\n onEdgesChangedListener?: (edges: Edge[]) => void\n onEditProvenanceClicked?: () => void\n}\n\nconst MAX_ACTIVITY_EXPAND_NODES = 400\nconst DEFAULT_ZOOM = 0.85\nexport const EDIT_PROVENANCE_TEXT = 'Edit Provenance'\nexport const NO_PROVENANCE_TITLE = 'No provenance data'\nconst NO_PROVENANCE_MESSAGE = (entityTypeName: string) =>\n `We don’t have any provenance information for this ${entityTypeName} yet.`\nconst NO_PROVENANCE_TEXT_COLOR = '#3B4046'\nconst EDIT_PROVENANCE_BUTTON_TEXT_COLOR = '#4D535A'\nconst EDIT_PROVENANCE_BUTTON_BORDER_COLOR = '#9EAAB7'\nconst EDIT_PROVENANCE_BUTTON_BACKGROUND_COLOR = 'rgba(255, 255, 255, 0.60)'\n\n/**\n * Renders a Provenance Graph for a set of entities.\n * New Nodes are added to tempNodes, and new Edges are added to tempEdges.\n * On change, these are fed into the dagre js graph library to figure out the node positions,\n * and the output stored in 'nodes' and 'edges'. The 'nodes' and 'edges' arrays are used by the\n * ReactFlow component.\n */\nconst ProvenanceReactFlow = (props: ProvenanceProps): React.ReactNode => {\n const {\n entityRefs: rootEntityRefs,\n containerHeight = '200px',\n initialNodes = [],\n initialEdges = [],\n onNodesChangedListener,\n onEdgesChangedListener,\n onEditProvenanceClicked,\n } = props\n const { accessToken } = useSynapseContext()\n const [tempNodes, setTempNodes] = useState<Node[]>(initialNodes)\n const [tempEdges, setTempEdges] = useState<Edge[]>(initialEdges)\n const [nodes, setNodes] = useNodesState([])\n const [edges, setEdges] = useEdgesState([])\n const [clickedNode, setClickedNode] = useState<Node>()\n const [initialBuildComplete, setInitialBuildComplete] =\n useState<boolean>(false)\n const handleError = useErrorHandler()\n\n const { data: rootEntityHeadersPage, isSuccess } = useGetEntityHeaders(\n rootEntityRefs,\n { throwOnError: true },\n )\n\n const PROVENANCE_NODE_TYPES = [\n NodeType.ENTITY_PLACEHOLDER,\n NodeType.EXTERNAL,\n NodeType.ACTIVITY,\n NodeType.EXPAND,\n ]\n const hasProvenanceNodes = nodes.some(node =>\n PROVENANCE_NODE_TYPES.includes((node.data as ProvenanceNodeData).type),\n )\n\n const showNoProvenance = initialBuildComplete && !hasProvenanceNodes\n\n if (\n isSuccess &&\n rootEntityHeadersPage &&\n rootEntityHeadersPage.totalNumberOfResults == 0\n ) {\n const synapseIds = rootEntityRefs.map(ref => ref.targetId).join(',')\n handleError(\n `Unable to load provenance for the given Synapse IDs: ${synapseIds}`,\n )\n }\n const rootEntityHeaders = rootEntityHeadersPage?.results\n const entityTypeName = rootEntityHeaders?.[0]\n ? entityTypeToFriendlyName(\n getEntityTypeFromHeader(rootEntityHeaders[0]),\n ).toLowerCase()\n : 'entity'\n const [initializedPosition, setInitializedPosition] = useState<boolean>(false)\n\n // Get the react flow instance so we attempt to properly center the view.\n const reactFlowInstance = useReactFlow()\n\n const onClickNode = useCallback((_event: MouseEvent, node: Node) => {\n setClickedNode(node)\n }, [])\n\n /**\n * Called when we have a new entity to add to the graph. This will result in adding\n * a new Entity Node to the nodesCopy, a link from the usedInActivity to the new Entity Node,\n * AND it will look for an Activity associated with the new entity. If an Activity is found,\n * it will add an Expand Node for the user to click (to expand to see this Activity!).\n * If this is a root node (starting entity node), then we automatically add the Activity Node\n * and process it.\n */\n const addEntity = useCallback(\n async (params: {\n entityHeader: EntityHeader\n usedInActivity?: Activity\n nodesCopy: Node[]\n edgesCopy: Edge[]\n }) => {\n const { entityHeader, nodesCopy, edgesCopy, usedInActivity } = params\n addEntityNode({\n entityHeader,\n activity: usedInActivity,\n nodesCopy,\n edgesCopy,\n })\n //look for Activity\n try {\n const activity = await SynapseClient.getActivityForEntity(\n entityHeader.id,\n entityHeader.versionNumber,\n accessToken,\n )\n // if this is not a root node (or there are too many items to show), add an expand node\n if (\n !isRootEntity({ entityHeader, rootEntityHeaders }) ||\n (activity.used && activity.used.length >= MAX_ACTIVITY_EXPAND_NODES)\n ) {\n addExpandNode({\n entityHeader,\n itemCount: activity.used?.length,\n nodesCopy,\n edgesCopy,\n })\n }\n } catch (e) {\n // Activity is not accessible\n console.error(e)\n if (\n isRootEntity({\n entityHeader,\n rootEntityHeaders,\n })\n ) {\n // add provenance undefined node\n addUndefinedNode({\n entityHeader,\n nodesCopy,\n edgesCopy,\n })\n }\n }\n },\n [accessToken, rootEntityHeaders],\n )\n\n /**\n * This effect attempts to center the graph on one of the root nodes.\n * Only initializes after after a root node has been added to the graph.\n */\n useEffect(() => {\n if (!initializedPosition && nodes.length > 0) {\n setTimeout(() => {\n if (rootEntityHeaders) {\n const rootEntityNode = findEntityNode(rootEntityHeaders[0], nodes)\n if (rootEntityNode) {\n const currentZoom = reactFlowInstance.getZoom()\n const zoom = currentZoom > DEFAULT_ZOOM ? DEFAULT_ZOOM : currentZoom\n reactFlowInstance?.setCenter(\n rootEntityNode.position.x + 150,\n rootEntityNode.position.y - 30,\n { zoom, duration: 0 },\n )\n }\n setInitializedPosition(true)\n }\n })\n }\n }, [initializedPosition, nodes, reactFlowInstance, rootEntityHeaders])\n\n /**\n * This is called when the user clicks on an Expand Node. It will add the associated Activity\n * and all \"used\" items (entities and urls) to the graph by adding items to the nodesCopy and edgesCopy arrays.\n */\n const onExpandEntity = useCallback(\n async (params: {\n entityHeader: EntityHeader\n nodesCopy: Node[]\n edgesCopy: Edge[]\n }) => {\n const { entityHeader, nodesCopy, edgesCopy } = params\n try {\n const activity = await SynapseClient.getActivityForEntity(\n entityHeader.id,\n entityHeader.versionNumber,\n accessToken,\n )\n addActivityNode({\n activity,\n entityHeader,\n nodesCopy,\n edgesCopy,\n })\n // go through Activity.used array to add these nodes/edges\n if (activity.used && activity.used.length < MAX_ACTIVITY_EXPAND_NODES) {\n const usedEntityReferences: ReferenceList = []\n activity.used.forEach((usedItem: Used) => {\n if (usedItem.concreteType == USED_ENTITY_CONCRETE_TYPE_VALUE) {\n usedEntityReferences.push((usedItem as UsedEntity).reference)\n } else {\n // UsedURL\n const usedURL = usedItem as UsedURL\n addExternalNode({ usedURL, activity, nodesCopy, edgesCopy })\n }\n })\n const usedEntityHeadersPage = await SynapseClient.getEntityHeaders(\n usedEntityReferences,\n accessToken,\n )\n const { results: usedEntityHeaderPageResults } = usedEntityHeadersPage\n // find refs that were not returned by the entity header call\n const refsMissingEntityHeaders = usedEntityReferences.filter(ref => {\n return (\n usedEntityHeaderPageResults.find(header => {\n return header.id == ref.targetId\n }) == undefined\n )\n })\n refsMissingEntityHeaders.forEach(ref => {\n addEntityPlaceholderNode({ ref, activity, nodesCopy, edgesCopy })\n })\n const addEntityPromises: Promise<void>[] = []\n usedEntityHeaderPageResults.forEach(header => {\n addEntityPromises.push(\n addEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n usedInActivity: activity,\n }),\n )\n })\n await Promise.allSettled(addEntityPromises)\n }\n } catch (e) {\n // Activity is not accessible\n console.error(e)\n }\n },\n [accessToken, addEntity],\n )\n\n /**\n * This effect code executes when no nodes have been added.\n * It will add the root nodes, and attempt to expand the root nodes.\n */\n useEffect(() => {\n if (rootEntityHeaders && tempNodes.length == 0) {\n const nodesCopy = [...tempNodes]\n const edgesCopy = [...tempEdges]\n const addAndExpandPromises: Promise<void>[] = []\n rootEntityHeaders.forEach(header => {\n const addEntityPromise = addEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n })\n addAndExpandPromises.push(addEntityPromise)\n\n const expandEntityPromise = onExpandEntity({\n entityHeader: header,\n nodesCopy,\n edgesCopy,\n })\n addAndExpandPromises.push(expandEntityPromise)\n })\n Promise.allSettled(addAndExpandPromises).finally(() => {\n setTempNodes(nodesCopy)\n setTempEdges(edgesCopy)\n setInitialBuildComplete(true)\n })\n }\n }, [\n addEntity,\n handleError,\n onExpandEntity,\n rootEntityHeaders,\n rootEntityRefs,\n tempEdges,\n tempNodes,\n ])\n\n /**\n * This effect code executes when a node is clicked.\n * We check to see if it is an expand node. If it is, then we remove the expand node (and associated edge)\n * and ask for the Activity and associated \"used\" nodes (entities and URLs)\n */\n useEffect(() => {\n const nodeData: ProvenanceNodeData = clickedNode?.data as ProvenanceNodeData\n if (clickedNode && nodeData?.type == NodeType.EXPAND) {\n const expandNodeDataProps = nodeData.props as ExpandGraphNodeDataProps\n if (expandNodeDataProps.itemCount > MAX_ACTIVITY_EXPAND_NODES) {\n displayToast(\n 'Web visualization does not support expanding this many items at this time.',\n 'danger',\n )\n return\n } else {\n // graph will be used outside of synapse, so show a non-branded spinner\n nodeData.label = <CircularProgress size={30} />\n // remove clicked node\n const nodesWithoutExpandNode = tempNodes.filter(\n node => node.id != clickedNode.id,\n )\n const edgeToRemove = getConnectedEdges([clickedNode], tempEdges)[0]\n const edgesWithoutExpandEdge = tempEdges.filter(\n edge => edge != edgeToRemove,\n )\n onExpandEntity({\n entityHeader: expandNodeDataProps.entityHeader,\n nodesCopy: nodesWithoutExpandNode,\n edgesCopy: edgesWithoutExpandEdge,\n }).finally(() => {\n setTempNodes(nodesWithoutExpandNode)\n setTempEdges(edgesWithoutExpandEdge)\n })\n }\n setClickedNode(undefined)\n }\n }, [clickedNode, tempNodes, tempEdges, onExpandEntity])\n\n /**\n * This effect code is run when the graph nodes or edges change.\n * It feeds the nodes and edges into our layout library to figure out where they should be positioned.\n * The result is saved in the state variable \"nodes\" and \"edges\".\n */\n useEffect(() => {\n const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements(\n tempNodes,\n tempEdges,\n 'TB',\n )\n // hack: ProvenanceUtils.getProvenanceNode() returns a new object every time, so check to see if\n // there were any real changes\n if (!isArrayEqual(layoutedNodes, nodes)) {\n setNodes(layoutedNodes)\n if (onNodesChangedListener) {\n onNodesChangedListener(layoutedNodes)\n }\n }\n if (!isArrayEqual(layoutedEdges, edges)) {\n setEdges(layoutedEdges)\n if (onEdgesChangedListener) {\n onEdgesChangedListener(layoutedEdges)\n }\n }\n }, [\n tempNodes,\n tempEdges,\n nodes,\n edges,\n setNodes,\n setEdges,\n initializedPosition,\n reactFlowInstance,\n rootEntityRefs,\n onNodesChangedListener,\n onEdgesChangedListener,\n ])\n\n const onPaneScrollFunction: (event?: WheelEvent) => void = useCallback(\n event => {\n // Cannot simply check the truthy value of event.deltaX (or Y) because the value might be 0 (or -0), which is falsy\n if (\n event &&\n typeof event.deltaX !== 'undefined' &&\n typeof event.deltaY !== 'undefined'\n ) {\n window.scrollTo(\n window.scrollX + event.deltaX,\n window.scrollY + event.deltaY,\n )\n }\n },\n [],\n )\n return (\n <div\n className=\"ProvenanceWidget\"\n role=\"graphics-doc\" //https://www.w3.org/wiki/SVG_Accessibility/ARIA_roles_for_charts#Document_Roles\n style={{\n width: '100%',\n height: containerHeight,\n }}\n >\n {showNoProvenance ? (\n <Stack\n sx={{\n display: 'flex',\n height: '100%',\n alignItems: 'center',\n justifyContent: 'center',\n textAlign: 'center',\n }}\n >\n <Typography\n sx={{\n color: NO_PROVENANCE_TEXT_COLOR,\n fontSize: '16px',\n lineHeight: '24px',\n fontWeight: 540,\n marginBottom: '12px',\n }}\n >\n {NO_PROVENANCE_TITLE}\n </Typography>\n <Typography\n sx={{\n color: NO_PROVENANCE_TEXT_COLOR,\n fontSize: '14px',\n lineHeight: '20px',\n fontWeight: 440,\n }}\n >\n {NO_PROVENANCE_MESSAGE(entityTypeName)}\n </Typography>\n {onEditProvenanceClicked && (\n <Button\n variant=\"outlined\"\n sx={{\n borderRadius: '6px',\n border: '1px solid',\n borderColor: EDIT_PROVENANCE_BUTTON_BORDER_COLOR,\n background: EDIT_PROVENANCE_BUTTON_BACKGROUND_COLOR,\n color: EDIT_PROVENANCE_BUTTON_TEXT_COLOR,\n fontWeight: 540,\n lineHeight: '12px' /* 100% */,\n letterSpacing: '-0.24px',\n marginTop: '20px',\n height: '28px',\n padding: '8px',\n }}\n onClick={onEditProvenanceClicked}\n >\n {EDIT_PROVENANCE_TEXT}\n </Button>\n )}\n </Stack>\n ) : (\n <ReactFlow\n defaultViewport={{ x: 0, y: 0, zoom: DEFAULT_ZOOM }}\n nodes={nodes}\n edges={edges}\n onNodeClick={onClickNode}\n // onNodesChange={onNodesChange} // SWC-6804: When the nodes/edges are updated (expanded) the graph is already re-rendered.\n // onEdgesChange={onEdgesChange} // Specifying these callbacks causes an infinite re-rendering loop.\n attributionPosition=\"bottom-right\"\n onConnect={undefined}\n zoomOnScroll={false}\n onPaneScroll={onPaneScrollFunction}\n >\n <Controls />\n </ReactFlow>\n )}\n </div>\n )\n}\n\nconst ProvenanceGraph = (props: ProvenanceProps): React.ReactNode => {\n return (\n <SynapseErrorBoundary>\n <ReactFlowProvider>\n <ProvenanceReactFlow {...props} />\n </ReactFlowProvider>\n </SynapseErrorBoundary>\n )\n}\n\nexport default ProvenanceGraph\n"],"mappings":";;;;;;;;;;;;;;;;;AA6DA,IAAM,IAA4B,KAC5B,IAAe,KACR,IAAuB,mBACvB,IAAsB,sBAC7B,MAAyB,MAC7B,qDAAqD,EAAe,QAChE,IAA2B,WAC3B,KAAoC,WACpC,KAAsC,WACtC,KAA0C,6BAS1C,KAAuB,MAA4C;CACvE,IAAM,EACJ,YAAY,GACZ,qBAAkB,SAClB,kBAAe,CAAC,GAChB,kBAAe,CAAC,GAChB,2BACA,2BACA,+BACE,GACE,EAAE,mBAAgB,EAAkB,GACpC,CAAC,GAAW,KAAgB,EAAiB,CAAY,GACzD,CAAC,GAAW,KAAgB,EAAiB,CAAY,GACzD,CAAC,GAAO,KAAY,GAAc,CAAC,CAAC,GACpC,CAAC,GAAO,KAAY,GAAc,CAAC,CAAC,GACpC,CAAC,GAAa,KAAkB,EAAe,GAC/C,CAAC,IAAsB,MAC3B,EAAkB,EAAK,GACnB,IAAc,EAAgB,GAE9B,EAAE,MAAM,GA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EACC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchQueryUseQueryOptions.d.ts","sourceRoot":"","sources":["../../../src/components/SearchQueryWrapper/SearchQueryUseQueryOptions.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,qBAAqB,EACrB,WAAW,EAEX,uBAAuB,EAIvB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,EAIP,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAGV,gBAAgB,EAChB,kBAAkB,EAElB,kBAAkB,EAEnB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,uBAAuB,CAAA;AAI9B,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAQzD,MAAM,MAAM,mBAAmB,GAC3B,aAAa,GACb,yBAAyB,GACzB,0BAA0B,GAC1B,qBAAqB,GACrB,eAAe,GACf,eAAe,CAAA;AAEnB,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;
|
|
1
|
+
{"version":3,"file":"SearchQueryUseQueryOptions.d.ts","sourceRoot":"","sources":["../../../src/components/SearchQueryWrapper/SearchQueryUseQueryOptions.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,qBAAqB,EACrB,WAAW,EAEX,uBAAuB,EAIvB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,EAIP,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAGV,gBAAgB,EAChB,kBAAkB,EAElB,kBAAkB,EAEnB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,YAA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;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,WAAW,EAAE,EAC5B,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,gBAAgB,CAqJlB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qCAAqC,CACnD,OAAO,EAAE,kBAAkB,GAAG,SAAS,EACvC,KAAK,EAAE,gBAAgB,EACvB,YAAY,CAAC,EAAE,WAAW,EAAE,EAC5B,cAAc,CAAC,EAAE,CAAC,wBAAwB,GAAG,uBAAuB,CAAC,EAAE,GACtE,iBAAiB,CAwKnB;AAED,wBAAgB,6BAA6B,CAC3C,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,aAAa,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,WAAW,EAAE,EAC5B,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,+BAA+B,CAgJjC;AAED;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAC7C,aAAa,EAAE,MAAM,EACrB,qBAAqB,EAAE,MAAM,GAAG,SAAS,GACxC,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAoC3C;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,+BAA+B,CA2BjC"}
|
|
@@ -11,8 +11,15 @@ import u from "dayjs";
|
|
|
11
11
|
function d(e) {
|
|
12
12
|
if (e) return Object.entries(e).map(([e, t]) => t === 1 ? e : `${e}^${t}`);
|
|
13
13
|
}
|
|
14
|
-
function f(e
|
|
14
|
+
function f(e) {
|
|
15
|
+
return /"[^"]+"/u.test(e);
|
|
16
|
+
}
|
|
17
|
+
function p(e, t = {}) {
|
|
15
18
|
let { queryStrategy: n = "MULTI_MATCH", fieldBoosts: r, fuzziness: i } = t, a = d(r);
|
|
19
|
+
if (f(e)) return { simple_query_string: {
|
|
20
|
+
query: e,
|
|
21
|
+
...a ? { fields: a } : {}
|
|
22
|
+
} };
|
|
16
23
|
switch (n) {
|
|
17
24
|
case "SIMPLE_QUERY_STRING": return { simple_query_string: {
|
|
18
25
|
query: e,
|
|
@@ -46,11 +53,11 @@ function f(e, t = {}) {
|
|
|
46
53
|
} };
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
|
-
function
|
|
56
|
+
function m(e, t) {
|
|
50
57
|
let n = e.responseBody?.queryResult?.queryResults.rows?.length ?? 0, r = e.requestBody?.searchQuery?.size, i = e.responseBody?.queryCount, a = t.reduce((e, t) => e + (t.responseBody?.queryResult?.queryResults.rows?.length ?? 0), 0);
|
|
51
58
|
if (n !== 0 && !(r != null && n < r) && !(i != null && a >= i)) return a;
|
|
52
59
|
}
|
|
53
|
-
function
|
|
60
|
+
function h(e, t, n, r) {
|
|
54
61
|
let i = [];
|
|
55
62
|
e.query.selectedFacets?.filter((e) => e.concreteType === c).forEach((e) => {
|
|
56
63
|
i.push({ terms: { [e.columnName]: e.facetValues ?? [] } });
|
|
@@ -59,9 +66,9 @@ function m(e, t, n, r) {
|
|
|
59
66
|
o !== void 0 && (a.gte = o), s !== void 0 && (a.lte = s), i.push({ range: { [e.columnName]: a } });
|
|
60
67
|
});
|
|
61
68
|
let a = e.query.additionalFilters?.filter((e) => e.concreteType === l).map((e) => e.searchExpression).filter((e) => e != null && e.length > 0), o = a && a.length > 0 ? a.join(" ") : void 0, d;
|
|
62
|
-
d = o ?
|
|
63
|
-
let
|
|
64
|
-
i.length === 1 ?
|
|
69
|
+
d = o ? p(o, r) : { match_all: {} };
|
|
70
|
+
let f;
|
|
71
|
+
i.length === 1 ? f = i[0] : i.length > 1 && (f = { bool: { must: i } });
|
|
65
72
|
let m = n?.filter((e) => e.facetType === "enumeration").map((e) => {
|
|
66
73
|
let t = {
|
|
67
74
|
field: e.name,
|
|
@@ -83,7 +90,7 @@ function m(e, t, n, r) {
|
|
|
83
90
|
searchIndexId: t,
|
|
84
91
|
searchQuery: {
|
|
85
92
|
query: d,
|
|
86
|
-
post_filter:
|
|
93
|
+
post_filter: f || void 0,
|
|
87
94
|
aggregations: h,
|
|
88
95
|
sort: g?.length ? g : void 0,
|
|
89
96
|
size: e.query.limit,
|
|
@@ -91,7 +98,7 @@ function m(e, t, n, r) {
|
|
|
91
98
|
}
|
|
92
99
|
};
|
|
93
100
|
}
|
|
94
|
-
function
|
|
101
|
+
function g(e, t, n, r) {
|
|
95
102
|
if (!e) return { concreteType: "org.sagebionetworks.repo.model.table.QueryResultBundle" };
|
|
96
103
|
let i = e.selectColumns?.map((e) => e.name).filter((e) => !!e) ?? [], a = i.map((e) => ({
|
|
97
104
|
name: e,
|
|
@@ -142,8 +149,8 @@ function h(e, t, n, r) {
|
|
|
142
149
|
...h !== void 0 && { maxScore: h }
|
|
143
150
|
};
|
|
144
151
|
}
|
|
145
|
-
function
|
|
146
|
-
let l =
|
|
152
|
+
function _(t, n, i, a, s, c) {
|
|
153
|
+
let l = h(t, a, s, c), u = {
|
|
147
154
|
...l,
|
|
148
155
|
searchQuery: {
|
|
149
156
|
...l.searchQuery,
|
|
@@ -164,28 +171,28 @@ function g(t, n, i, a, s, c) {
|
|
|
164
171
|
}, f = (e) => ({
|
|
165
172
|
...e,
|
|
166
173
|
responseParts: e.responseParts ? [...e.responseParts].sort() : void 0
|
|
167
|
-
}),
|
|
174
|
+
}), p = async (n) => {
|
|
168
175
|
let r = await e(n, i);
|
|
169
176
|
return {
|
|
170
177
|
...r,
|
|
171
|
-
responseBody:
|
|
178
|
+
responseBody: g(r.responseBody, n, s, t.query.selectedFacets)
|
|
172
179
|
};
|
|
173
180
|
};
|
|
174
181
|
return {
|
|
175
182
|
rowDataQueryOptions: {
|
|
176
183
|
...r,
|
|
177
184
|
queryKey: n.getSearchQueryResultWithAsyncStatusQueryKey(f(u), !1),
|
|
178
|
-
queryFn: () =>
|
|
185
|
+
queryFn: () => p(u),
|
|
179
186
|
select: (e) => e.responseBody?.queryResult?.queryResults
|
|
180
187
|
},
|
|
181
188
|
rowDataInfiniteQueryOptions: {
|
|
182
189
|
...r,
|
|
183
190
|
queryKey: n.getSearchQueryResultWithAsyncStatusQueryKey(f(u), !0),
|
|
184
191
|
initialPageParam: 0,
|
|
185
|
-
getNextPageParam: (e, t) =>
|
|
192
|
+
getNextPageParam: (e, t) => m(e, t),
|
|
186
193
|
queryFn: (e) => {
|
|
187
194
|
let t = typeof e.pageParam == "string" ? parseInt(e.pageParam) : e.pageParam ?? 0;
|
|
188
|
-
return
|
|
195
|
+
return p({
|
|
189
196
|
...u,
|
|
190
197
|
searchQuery: {
|
|
191
198
|
...u.searchQuery,
|
|
@@ -198,7 +205,7 @@ function g(t, n, i, a, s, c) {
|
|
|
198
205
|
queryMetadataQueryOptions: {
|
|
199
206
|
...r,
|
|
200
207
|
queryKey: n.getSearchQueryResultWithAsyncStatusQueryKey(f(d), !1),
|
|
201
|
-
queryFn: () =>
|
|
208
|
+
queryFn: () => p(d),
|
|
202
209
|
select: (e) => {
|
|
203
210
|
let t = o(e.responseBody ?? {}, "queryResult");
|
|
204
211
|
return s ? {
|
|
@@ -209,7 +216,7 @@ function g(t, n, i, a, s, c) {
|
|
|
209
216
|
}
|
|
210
217
|
};
|
|
211
218
|
}
|
|
212
|
-
function
|
|
219
|
+
function v(e, n) {
|
|
213
220
|
let { synapseClient: r } = t();
|
|
214
221
|
return i(async (t) => {
|
|
215
222
|
if (!n) return [];
|
|
@@ -230,9 +237,9 @@ function _(e, n) {
|
|
|
230
237
|
n
|
|
231
238
|
]);
|
|
232
239
|
}
|
|
233
|
-
function
|
|
240
|
+
function y(e, r, i, o) {
|
|
234
241
|
let { keyFactory: s, accessToken: c } = t(), { data: l } = n(i, void 0, { includeTableBundle: !0 }), u = l?.tableBundle?.columnModels;
|
|
235
|
-
return a(() =>
|
|
242
|
+
return a(() => _(e, s, c, r, u, o), [
|
|
236
243
|
s,
|
|
237
244
|
c,
|
|
238
245
|
e,
|
|
@@ -242,6 +249,6 @@ function v(e, r, i, o) {
|
|
|
242
249
|
]);
|
|
243
250
|
}
|
|
244
251
|
//#endregion
|
|
245
|
-
export {
|
|
252
|
+
export { m as getNextPageParamForSearchQueryResults, _ as getSearchQueryUseQueryOptions, g as searchQueryResultsToQueryResultBundle, h as toSearchIndexQuery, v as useGetSuggestionsForSearchIndex, y as useSearchQueryUseQueryOptions };
|
|
246
253
|
|
|
247
254
|
//# sourceMappingURL=SearchQueryUseQueryOptions.js.map
|