synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
168 lines (167 loc) • 5.01 kB
JavaScript
import { jsx as U, Fragment as M } from "react/jsx-runtime";
import T from "../../components/SourceAppImage.js";
import * as k from "../../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 "@sage-bionetworks/synapse-types";
import "../functions/EntityTypeUtils.js";
import { BUNDLE_MASK_QUERY_RESULTS as D } from "../SynapseConstants.js";
import "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import l from "../../theme/palette/Palettes.js";
import { useMemo as L } from "react";
import { useSuspenseQuery as G, useQueries as H } from "@tanstack/react-query";
import { useSynapseContext as W } from "../context/SynapseContext.js";
import "../PermissionLevelToAccessType.js";
import "use-deep-compare-effect";
import "@mui/material";
import "./useCookiePreferences.js";
import "universal-cookie";
import "../AppUtils/session/ApplicationSessionContext.js";
import "../context/FullContextProvider.js";
import "../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 "../types/IsType.js";
import { tableQueryUseQueryDefaults as j } from "../../synapse-queries/entity/useGetQueryResultBundle.js";
import { getRealmByIdQueryOptions as J } from "../../synapse-queries/realm/useRealmPrincipals.js";
const V = {
appId: "synapse.org",
appURL: "",
description: "",
friendlyName: "Synapse",
requestAffiliation: !1,
logo: /* @__PURE__ */ U(M, {}),
isPublicized: !0,
palette: { ...l.palette },
shortDescription: "",
defaultRealm: {
id: "0",
name: "Synapse"
}
}, Y = [V], he = (n, _) => {
const { synapseClient: h, keyFactory: R } = W(), S = {
entityId: n,
query: {
sql: `SELECT * FROM ${n}`,
limit: 75,
additionalFilters: _
},
partMask: D,
concreteType: "org.sagebionetworks.repo.model.table.QueryBundleRequest"
}, { data: d } = G({
...j,
queryKey: R.getEntityTableQueryResultWithAsyncStatusQueryKey(
S,
!1
),
queryFn: async () => {
try {
return await k.getQueryTableAsyncJobResults(
S,
void 0
// use an undefined access token to query a table in the default realm
);
} catch {
return null;
}
}
}), r = d?.responseBody?.queryResult?.queryResults, o = r?.headers, m = o?.findIndex(
(e) => e.name == "appId"
), p = o?.findIndex(
(e) => e.name == "appURL"
), q = o?.findIndex(
(e) => e.name == "friendlyName"
), u = o?.findIndex(
(e) => e.name == "description"
), g = o?.findIndex(
(e) => e.name == "logo"
), c = o?.findIndex(
(e) => e.name == "requestAffiliation"
), P = o?.findIndex(
(e) => e.name == "primaryColor"
), Q = o?.findIndex(
(e) => e.name == "secondaryColor"
), y = o?.findIndex(
(e) => e.name == "isPublicized"
), f = o?.findIndex(
(e) => e.name == "shortDescription"
), I = o?.findIndex(
(e) => e.name == "realmId"
), s = o?.findIndex((e) => e.name == "area") ?? -1, A = r?.rows, i = L(
() => A?.map((e) => {
const t = e.values, C = t[g], a = t[q] ?? "", b = /* @__PURE__ */ U(
T,
{
sourceAppConfigTableID: n,
fileHandleId: C,
friendlyName: a
}
), E = {
...l.palette,
primary: l.generatePalette(
t[P] ?? ""
),
secondary: l.generatePalette(
t[Q] ?? ""
)
}, F = t[m] == null ? "" : t[m], N = t[p] == null ? "" : t[p], v = t[u] == null ? "" : t[u], w = t[f] == null ? "" : t[f], B = t[c] == null ? !1 : t[c] == "true", O = t[y] == null ? !0 : t[y] == "true", z = t[I] == null ? "0" : t[I], K = s >= 0 && t[s] != null ? t[s] : void 0;
return {
appId: F,
appURL: N,
description: v,
friendlyName: a,
requestAffiliation: B,
logo: b,
isPublicized: O,
palette: E,
shortDescription: w,
realmId: z,
area: K
};
}),
[
A,
g,
q,
n,
P,
Q,
m,
p,
u,
f,
c,
y,
I,
s
]
), x = H({
queries: i?.map(
(e) => J(e.realmId, R, h)
) ?? []
});
return L(() => {
if (!d || !r)
return Y;
if (!(!i || !x.every((t) => t.isSuccess)))
return i.map((t, C) => {
const a = x[C].data;
return {
...t,
defaultRealm: a
};
});
}, [i, x, d, r]);
};
export {
V as STATIC_SOURCE_APP_CONFIG,
he as useSourceAppConfigs
};
//# sourceMappingURL=useSourceAppConfigs.js.map