synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
183 lines (182 loc) • 5.94 kB
JavaScript
import "../../synapse-client/SynapseClient.js";
import "@sage-bionetworks/synapse-client/generated/models/ErrorResponseCode";
import "@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse";
import "@sage-bionetworks/synapse-client/util/SynapseClientError";
import { ColumnTypeEnum as m, RestrictableObjectType as C, FileHandleAssociateType as b } from "@sage-bionetworks/synapse-types";
import "../../utils/functions/EntityTypeUtils.js";
import "../../utils/SynapseConstants.js";
import { cloneDeep as D } from "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import { useQueryClient as L } from "@tanstack/react-query";
import "../../utils/PermissionLevelToAccessType.js";
import { useCallback as H, useMemo as N } from "react";
import { useSynapseContext as O } from "../../utils/context/SynapseContext.js";
import "use-deep-compare-effect";
import "react/jsx-runtime";
import "@mui/material";
import "../../utils/hooks/useCookiePreferences.js";
import "../../utils/hooks/useSourceAppConfigs.js";
import "universal-cookie";
import "../../utils/AppUtils/session/ApplicationSessionContext.js";
import "../../utils/context/FullContextProvider.js";
import "../../utils/context/DocumentMetadataContext.js";
import '../../style/components/_spinner.css';/* empty css */
import "@tanstack/query-core";
import "lodash-es/isEmpty";
import "lodash-es/isEqual";
import "lodash-es/xorWith";
import "react-router";
import "@sage-bionetworks/synapse-client";
import "../../utils/types/IsType.js";
import { useGetRestrictionInformationBatch as F } from "../../synapse-queries/dataaccess/useRestrictionInformation.js";
import { useGetEntity as T } from "../../synapse-queries/entity/useEntity.js";
import { useGetEntityHeaders as P } from "../../synapse-queries/entity/useGetEntityHeaders.js";
import { getTypeIndices as f, getFieldIndex as R } from "../../utils/functions/queryUtils.js";
import { useGetFileBatch as G } from "../../synapse-queries/file/useFiles.js";
import { useGetUserGroupHeaders as S } from "../../synapse-queries/user/useUserGroupHeader.js";
import { goToPage as U } from "../../utils/hooks/useImmutableTableQuery/TableQueryReducerActions.js";
import { useQueryContext as y } from "../QueryContext/QueryContext.js";
import { getTableQueryUseQueryOptions as q } from "../QueryWrapper/TableQueryUseQueryOptions.js";
import { useGetQueryMetadata as g } from "../QueryWrapper/useGetQueryMetadata.js";
import { isEntityViewOrDatasetOrCollection as E, isFileViewOrDataset as w } from "./SynapseTableUtils.js";
function Q(e) {
const { entityId: i, versionNumber: u } = y(), { data: n } = T(i, u), { data: s } = g(), o = f(
m.FILEHANDLEID,
s?.selectColumns
);
let r = [];
return n && e && s && s.selectColumns && (r = e.rows.reduce(
(c, t) => (o.forEach((l) => {
const a = t.values[l];
if (a) {
const d = s?.selectColumns[l];
w(n) && d.name === "dataFileHandleId" ? c.push({
fileHandleId: a,
associateObjectId: String(t.rowId),
associateObjectType: b.FileEntity
}) : c.push({
fileHandleId: a,
associateObjectId: n.id,
associateObjectType: b.TableEntity
});
}
}), c),
r
)), G(
{
requestedFiles: r,
includeFileHandles: !0,
includePreSignedURLs: !1,
includePreviewPreSignedURLs: !1
},
{
enabled: r.length > 0
}
);
}
function j(e) {
const { entityId: i, versionNumber: u } = y(), { data: n } = T(i, u), { data: s } = g();
let o = [];
n && E(n) && (o = e.rows.reduce((t, l) => {
const { rowId: a, versionNumber: d } = l;
return a && t.push({
targetId: `syn${a}`,
targetVersionNumber: d
}), t;
}, o));
let r = f(
m.ENTITYID,
s?.selectColumns
);
if (n && E(n)) {
const t = R("id", s);
r = r.filter(
(l) => l !== t
);
}
const c = f(
m.ENTITYID_LIST,
s?.selectColumns
);
return o = e.rows.reduce((t, l) => (r.forEach((a) => {
const d = l.values[a];
d && !t.find((p) => p.targetId === d && p.targetVersionNumber == null) && t.push({ targetId: d });
}), c.forEach((a) => {
const d = l.values[a];
d && JSON.parse(d).forEach((I) => {
I && !t.find((h) => h.targetId === I && h.targetVersionNumber == null) && t.push({ targetId: I });
});
}), t), o), o;
}
function v(e) {
return P(e, {
enabled: e.length > 0
});
}
function M(e) {
const { data: i } = g(), u = f(
m.USERID,
i?.selectColumns
), n = f(
m.USERID_LIST,
i?.selectColumns
), s = e.rows.reduce(
(o, r) => (u.forEach((c) => {
const t = r.values[c];
t && !o.includes(t) && o.push(t);
}), n.forEach((c) => {
const t = r.values[c];
t && JSON.parse(t).forEach((a) => {
o.includes(String(a)) || o.push(String(a));
});
}), o),
[]
);
return S(s, {
enabled: s.length > 0
});
}
function V(e) {
const i = N(() => {
const u = e.map((n) => n.targetId);
return Array.from(new Set(u));
}, [e]);
return F(
{
objectIds: i,
restrictableObjectType: C.ENTITY
},
{
enabled: e.length > 0
}
);
}
function Fe(e) {
const i = j(e), { isLoading: u } = v(i), { isLoading: n } = V(i), { isLoading: s } = Q(e), { isLoading: o } = M(e);
return {
dataHasBeenPrefetched: !u && !n && !s && !o
};
}
function Pe() {
const { keyFactory: e, accessToken: i } = O(), { currentQueryRequest: u } = y(), n = L(), s = void 0;
return H(
(o) => {
const r = U(
{ pageNumber: o },
D(u)
), { rowDataQueryOptions: c } = q(
r,
s,
e,
i
);
return n.prefetchQuery(c);
},
[i, u, e, s, n]
);
}
export {
Fe as usePrefetchResourcesInTable,
Pe as usePrefetchTableRows
};
//# sourceMappingURL=usePrefetchTableData.js.map