@darajs/core 1.8.6 → 1.9.1
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/api/websocket.js +2 -2
- package/dist/api/websocket.js.map +1 -1
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/auth/auth.js +7 -1
- package/dist/auth/auth.js.map +1 -1
- package/dist/auth/basic/basic-auth-login.d.ts.map +1 -1
- package/dist/auth/basic/basic-auth-login.js +3 -5
- package/dist/auth/basic/basic-auth-login.js.map +1 -1
- package/dist/auth/default/default-auth-login.d.ts.map +1 -1
- package/dist/auth/default/default-auth-login.js +3 -5
- package/dist/auth/default/default-auth-login.js.map +1 -1
- package/dist/{dara_core-1.8.6-py3-none-any.whl → dara_core-1.9.1-py3-none-any.whl} +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/private-route/private-route.d.ts.map +1 -1
- package/dist/shared/private-route/private-route.js +8 -3
- package/dist/shared/private-route/private-route.js.map +1 -1
- package/dist/shared/utils/index.d.ts +1 -1
- package/dist/shared/utils/index.d.ts.map +1 -1
- package/dist/shared/utils/index.js +1 -1
- package/dist/shared/utils/index.js.map +1 -1
- package/dist/shared/utils/use-action.d.ts +10 -1
- package/dist/shared/utils/use-action.d.ts.map +1 -1
- package/dist/shared/utils/use-action.js +33 -6
- package/dist/shared/utils/use-action.js.map +1 -1
- package/dist/types/core.d.ts +4 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/umd/dara.core.umd.js +283 -261
- package/package.json +2 -2
|
@@ -33,7 +33,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
33
33
|
(function(global2, factory) {
|
|
34
34
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("@tanstack/react-query"), require("react-dom"), require("styled-components")) : typeof define === "function" && define.amd ? define(["exports", "react", "@tanstack/react-query", "react-dom", "styled-components"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory((global2.dara = global2.dara || {}, global2.dara.core = {}), global2.React, global2.ReactQuery, global2.ReactDOM, global2.styled));
|
|
35
35
|
})(this, function(exports, React, reactQuery, ReactDOM, styled) {
|
|
36
|
-
var _pingInterval, _socketUrl, _reconnectCount, _instance, _observers
|
|
36
|
+
var _pingInterval, _socketUrl, _reconnectCount, _events$, _parentBus, _instance, _observers;
|
|
37
37
|
"use strict";
|
|
38
38
|
const _interopDefaultLegacy = (e3) => e3 && typeof e3 === "object" && "default" in e3 ? e3 : { default: e3 };
|
|
39
39
|
function _interopNamespace(e3) {
|
|
@@ -55995,10 +55995,13 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
55995
55995
|
}
|
|
55996
55996
|
}
|
|
55997
55997
|
async function handleAuthErrors(res, toLogin = false, ignoreErrors = null) {
|
|
55998
|
+
var _a;
|
|
55998
55999
|
const content = await res.clone().json();
|
|
55999
56000
|
if (isAuthenticationError(content == null ? void 0 : content.detail) && !shouldIgnoreError(content == null ? void 0 : content.detail, ignoreErrors)) {
|
|
56000
56001
|
localStorage.removeItem(getTokenKey());
|
|
56001
|
-
const
|
|
56002
|
+
const queryParams = new URLSearchParams(window.location.search);
|
|
56003
|
+
const referrer = (_a = queryParams.get("referrer")) != null ? _a : encodeURIComponent(window.location.pathname + window.location.search);
|
|
56004
|
+
const path = toLogin || shouldRedirectToLogin(content.detail) ? `/login?referrer=${referrer}` : `/error?code=${res.status}`;
|
|
56002
56005
|
window.location.href = `${window.dara.base_url}${path}`;
|
|
56003
56006
|
return true;
|
|
56004
56007
|
}
|
|
@@ -56303,7 +56306,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
56303
56306
|
const handler = () => {
|
|
56304
56307
|
if (document.visibilityState === "visible") {
|
|
56305
56308
|
__privateSet(this, _reconnectCount, 0);
|
|
56306
|
-
this.initialize();
|
|
56309
|
+
this.socket = this.initialize();
|
|
56307
56310
|
document.removeEventListener("visibilitychange", handler);
|
|
56308
56311
|
}
|
|
56309
56312
|
};
|
|
@@ -56312,7 +56315,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
56312
56315
|
}
|
|
56313
56316
|
setTimeout(() => {
|
|
56314
56317
|
__privateWrapper(this, _reconnectCount)._++;
|
|
56315
|
-
this.initialize(true);
|
|
56318
|
+
this.socket = this.initialize(true);
|
|
56316
56319
|
}, interAttemptTimeout);
|
|
56317
56320
|
}
|
|
56318
56321
|
close() {
|
|
@@ -56437,6 +56440,38 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
56437
56440
|
url.searchParams.set("token", sessionToken);
|
|
56438
56441
|
return new WebSocketClient(socketUrl, sessionToken, liveReload);
|
|
56439
56442
|
}
|
|
56443
|
+
class EventBus {
|
|
56444
|
+
constructor(parentBus) {
|
|
56445
|
+
__privateAdd(this, _events$, new Subject());
|
|
56446
|
+
__privateAdd(this, _parentBus, null);
|
|
56447
|
+
__privateSet(this, _parentBus, parentBus != null ? parentBus : null);
|
|
56448
|
+
}
|
|
56449
|
+
publish(type, data) {
|
|
56450
|
+
__privateGet(this, _events$).next({ type, data });
|
|
56451
|
+
if (__privateGet(this, _parentBus)) {
|
|
56452
|
+
__privateGet(this, _parentBus).publish(type, data);
|
|
56453
|
+
}
|
|
56454
|
+
}
|
|
56455
|
+
subscribe(callback) {
|
|
56456
|
+
const sub = __privateGet(this, _events$).pipe().subscribe(callback);
|
|
56457
|
+
return () => sub.unsubscribe();
|
|
56458
|
+
}
|
|
56459
|
+
}
|
|
56460
|
+
_events$ = new WeakMap();
|
|
56461
|
+
_parentBus = new WeakMap();
|
|
56462
|
+
const DEFAULT_BUS = new EventBus();
|
|
56463
|
+
const EventBusContext = React__namespace.createContext(DEFAULT_BUS);
|
|
56464
|
+
function useEventBus() {
|
|
56465
|
+
return React__namespace.useContext(EventBusContext);
|
|
56466
|
+
}
|
|
56467
|
+
function EventCapturer({ children, onEvent }) {
|
|
56468
|
+
const parentBus = useEventBus();
|
|
56469
|
+
const bus = React__namespace.useMemo(() => new EventBus(parentBus), [parentBus]);
|
|
56470
|
+
React__namespace.useEffect(() => {
|
|
56471
|
+
return bus.subscribe(onEvent);
|
|
56472
|
+
}, [bus, onEvent]);
|
|
56473
|
+
return /* @__PURE__ */ React__namespace.createElement(EventBusContext.Provider, { value: bus }, children);
|
|
56474
|
+
}
|
|
56440
56475
|
function err(message) {
|
|
56441
56476
|
const error = new Error(message);
|
|
56442
56477
|
if (error.stack === void 0) {
|
|
@@ -57411,38 +57446,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
57411
57446
|
function useUrlVariable(variable) {
|
|
57412
57447
|
return Recoil_index_22(getOrRegisterUrlVariable(variable));
|
|
57413
57448
|
}
|
|
57414
|
-
class EventBus {
|
|
57415
|
-
constructor(parentBus) {
|
|
57416
|
-
__privateAdd(this, _events$, new Subject());
|
|
57417
|
-
__privateAdd(this, _parentBus, null);
|
|
57418
|
-
__privateSet(this, _parentBus, parentBus != null ? parentBus : null);
|
|
57419
|
-
}
|
|
57420
|
-
publish(type, data) {
|
|
57421
|
-
__privateGet(this, _events$).next({ type, data });
|
|
57422
|
-
if (__privateGet(this, _parentBus)) {
|
|
57423
|
-
__privateGet(this, _parentBus).publish(type, data);
|
|
57424
|
-
}
|
|
57425
|
-
}
|
|
57426
|
-
subscribe(callback) {
|
|
57427
|
-
const sub = __privateGet(this, _events$).pipe().subscribe(callback);
|
|
57428
|
-
return () => sub.unsubscribe();
|
|
57429
|
-
}
|
|
57430
|
-
}
|
|
57431
|
-
_events$ = new WeakMap();
|
|
57432
|
-
_parentBus = new WeakMap();
|
|
57433
|
-
const DEFAULT_BUS = new EventBus();
|
|
57434
|
-
const EventBusContext = React__namespace.createContext(DEFAULT_BUS);
|
|
57435
|
-
function useEventBus() {
|
|
57436
|
-
return React__namespace.useContext(EventBusContext);
|
|
57437
|
-
}
|
|
57438
|
-
function EventCapturer({ children, onEvent }) {
|
|
57439
|
-
const parentBus = useEventBus();
|
|
57440
|
-
const bus = React__namespace.useMemo(() => new EventBus(parentBus), [parentBus]);
|
|
57441
|
-
React__namespace.useEffect(() => {
|
|
57442
|
-
return bus.subscribe(onEvent);
|
|
57443
|
-
}, [bus, onEvent]);
|
|
57444
|
-
return /* @__PURE__ */ React__namespace.createElement(EventBusContext.Provider, { value: bus }, children);
|
|
57445
|
-
}
|
|
57446
57449
|
function combineFilters(combinator, queries) {
|
|
57447
57450
|
const validQueries = queries.filter(Boolean);
|
|
57448
57451
|
if (validQueries.length === 0) {
|
|
@@ -58021,6 +58024,216 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
58021
58024
|
}
|
|
58022
58025
|
return resolver(getOrRegisterPlainVariable(variable, client, taskContext, extras));
|
|
58023
58026
|
}
|
|
58027
|
+
function warnUpdateOnDerivedState() {
|
|
58028
|
+
console.warn("You tried to call update on variable with derived state, this is a noop and will be ignored.");
|
|
58029
|
+
}
|
|
58030
|
+
function useVariable(variable) {
|
|
58031
|
+
const extras = useRequestExtras();
|
|
58032
|
+
const { client: WsClient } = React.useContext(websocketCtx);
|
|
58033
|
+
const taskContext = useTaskContext();
|
|
58034
|
+
const variablesContext = React.useContext(variablesCtx);
|
|
58035
|
+
const bus = useEventBus();
|
|
58036
|
+
if (!isVariable(variable)) {
|
|
58037
|
+
return React.useState(variable);
|
|
58038
|
+
}
|
|
58039
|
+
variablesContext.variables.current.add(variable.uid);
|
|
58040
|
+
React.useEffect(() => {
|
|
58041
|
+
return () => {
|
|
58042
|
+
variablesContext.variables.current.delete(variable.uid);
|
|
58043
|
+
};
|
|
58044
|
+
}, []);
|
|
58045
|
+
if (isDataVariable(variable) || isDerivedDataVariable(variable)) {
|
|
58046
|
+
throw new Error(`Non-data variable expected, got ${variable.__typename}`);
|
|
58047
|
+
}
|
|
58048
|
+
if (isDerivedVariable(variable)) {
|
|
58049
|
+
const selector2 = useDerivedVariable(variable, WsClient, taskContext, extras);
|
|
58050
|
+
const selectorLoadable = Recoil_index_28(selector2);
|
|
58051
|
+
React.useEffect(() => {
|
|
58052
|
+
if (selectorLoadable.state !== "loading") {
|
|
58053
|
+
bus.publish("DERIVED_VARIABLE_LOADED", { variable, value: selectorLoadable.contents });
|
|
58054
|
+
}
|
|
58055
|
+
}, [selectorLoadable]);
|
|
58056
|
+
const deferred2 = useDeferLoadable(selectorLoadable);
|
|
58057
|
+
return [deferred2.value, warnUpdateOnDerivedState];
|
|
58058
|
+
}
|
|
58059
|
+
if (isUrlVariable(variable)) {
|
|
58060
|
+
return useUrlVariable(variable);
|
|
58061
|
+
}
|
|
58062
|
+
const recoilState = getOrRegisterPlainVariable(variable, WsClient, taskContext, extras);
|
|
58063
|
+
const [loadable, setLoadable] = Recoil_index_23(recoilState);
|
|
58064
|
+
const deferred = useDeferLoadable(loadable);
|
|
58065
|
+
React.useEffect(() => {
|
|
58066
|
+
if (loadable.state !== "loading") {
|
|
58067
|
+
bus.publish("PLAIN_VARIABLE_LOADED", { variable, value: loadable.contents });
|
|
58068
|
+
}
|
|
58069
|
+
}, [loadable]);
|
|
58070
|
+
return [deferred, setLoadable];
|
|
58071
|
+
}
|
|
58072
|
+
function useDataVariable(variable) {
|
|
58073
|
+
const extras = useRequestExtras();
|
|
58074
|
+
const { client: wsClient } = React.useContext(websocketCtx);
|
|
58075
|
+
if (isDataVariable(variable)) {
|
|
58076
|
+
registerDataVariable(variable);
|
|
58077
|
+
const serverTriggers$ = React.useMemo(() => wsClient.serverTriggers$(variable.uid), []);
|
|
58078
|
+
const [serverTriggerCounter, setServerTriggerCounter] = React.useState(0);
|
|
58079
|
+
React.useEffect(() => {
|
|
58080
|
+
const sub = serverTriggers$.subscribe(() => setServerTriggerCounter((c2) => c2 + 1));
|
|
58081
|
+
return () => sub.unsubscribe();
|
|
58082
|
+
}, [serverTriggers$]);
|
|
58083
|
+
const fetchDataVariable2 = useFetchDataVariable(variable, serverTriggerCounter);
|
|
58084
|
+
return fetchDataVariable2;
|
|
58085
|
+
}
|
|
58086
|
+
const variablesContext = React.useContext(variablesCtx);
|
|
58087
|
+
variablesContext.variables.current.add(variable.uid);
|
|
58088
|
+
React.useEffect(() => {
|
|
58089
|
+
return () => {
|
|
58090
|
+
variablesContext.variables.current.delete(variable.uid);
|
|
58091
|
+
};
|
|
58092
|
+
}, []);
|
|
58093
|
+
const taskContext = useTaskContext();
|
|
58094
|
+
const dvSelector = useDerivedVariable(variable, wsClient, taskContext, extras);
|
|
58095
|
+
const dvLoadable = Recoil_index_21(dvSelector);
|
|
58096
|
+
const [dvValue, setDvValue] = React.useState(dvLoadable.toPromise());
|
|
58097
|
+
React.useEffect(() => {
|
|
58098
|
+
if (dvLoadable.state === "loading") {
|
|
58099
|
+
setDvValue(dvLoadable.toPromise());
|
|
58100
|
+
}
|
|
58101
|
+
}, [dvLoadable]);
|
|
58102
|
+
const fetchDerivedDataVariable2 = useFetchDerivedDataVariable(variable, taskContext, wsClient, dvValue);
|
|
58103
|
+
return fetchDerivedDataVariable2;
|
|
58104
|
+
}
|
|
58105
|
+
function useAnyVariable(variable) {
|
|
58106
|
+
if (isDataVariable(variable) || isDerivedDataVariable(variable)) {
|
|
58107
|
+
const getData2 = useDataVariable(variable);
|
|
58108
|
+
const { data, refetch } = reactQuery.useQuery({
|
|
58109
|
+
cacheTime: 1,
|
|
58110
|
+
queryFn: async () => {
|
|
58111
|
+
const dataResponse = await getData2();
|
|
58112
|
+
return dataResponse.data;
|
|
58113
|
+
},
|
|
58114
|
+
queryKey: ["any-variable-data", variable.uid],
|
|
58115
|
+
refetchOnWindowFocus: false,
|
|
58116
|
+
suspense: true
|
|
58117
|
+
});
|
|
58118
|
+
React.useEffect(() => {
|
|
58119
|
+
refetch();
|
|
58120
|
+
}, [getData2]);
|
|
58121
|
+
return data;
|
|
58122
|
+
}
|
|
58123
|
+
return useVariable(variable)[0];
|
|
58124
|
+
}
|
|
58125
|
+
function getVariableValue(variable, shouldFetchVariable = false, ctx) {
|
|
58126
|
+
const resolved = resolveVariable(
|
|
58127
|
+
variable,
|
|
58128
|
+
ctx.client,
|
|
58129
|
+
ctx.taskContext,
|
|
58130
|
+
ctx.extras,
|
|
58131
|
+
(v2) => ctx.snapshot.getLoadable(v2).getValue()
|
|
58132
|
+
);
|
|
58133
|
+
if (!shouldFetchVariable || !isDerivedVariable(variable) && !isDataVariable(variable) && !isDerivedDataVariable(variable)) {
|
|
58134
|
+
return resolved;
|
|
58135
|
+
}
|
|
58136
|
+
if (!isResolvedDerivedVariable(resolved) && !isResolvedDataVariable(resolved) && !isResolvedDerivedDataVariable(resolved)) {
|
|
58137
|
+
return resolved;
|
|
58138
|
+
}
|
|
58139
|
+
if (isResolvedDataVariable(resolved)) {
|
|
58140
|
+
return fetchDataVariable(resolved.uid, ctx.extras, resolved.filters);
|
|
58141
|
+
}
|
|
58142
|
+
return fetchDerivedVariable({
|
|
58143
|
+
cache: variable.cache,
|
|
58144
|
+
extras: ctx.extras,
|
|
58145
|
+
force: false,
|
|
58146
|
+
selectorKey: resolved.uid,
|
|
58147
|
+
values: normalizeRequest(
|
|
58148
|
+
formatDerivedVariableRequest(resolved.values),
|
|
58149
|
+
variable.variables
|
|
58150
|
+
),
|
|
58151
|
+
variableUid: resolved.uid,
|
|
58152
|
+
wsClient: ctx.client
|
|
58153
|
+
}).then((resp) => {
|
|
58154
|
+
if (isTaskResponse$1(resp)) {
|
|
58155
|
+
throw new Error("Task DerivedVariables are not supported in this context");
|
|
58156
|
+
}
|
|
58157
|
+
if (isDerivedDataVariable(variable)) {
|
|
58158
|
+
return ctx.client.getChannel().then(
|
|
58159
|
+
(chan) => fetchDerivedDataVariable(variable.uid, ctx.extras, resp.cache_key, chan, variable.filters)
|
|
58160
|
+
);
|
|
58161
|
+
}
|
|
58162
|
+
return resp.value;
|
|
58163
|
+
});
|
|
58164
|
+
}
|
|
58165
|
+
function useVariableValue(variable, shouldFetchVariable = false) {
|
|
58166
|
+
const taskContext = useTaskContext();
|
|
58167
|
+
const { client } = React.useContext(websocketCtx);
|
|
58168
|
+
const { search } = useLocation();
|
|
58169
|
+
const extras = useRequestExtras();
|
|
58170
|
+
if (!isVariable(variable)) {
|
|
58171
|
+
return () => variable;
|
|
58172
|
+
}
|
|
58173
|
+
return Recoil_index_31(
|
|
58174
|
+
({ snapshot }) => {
|
|
58175
|
+
return () => {
|
|
58176
|
+
return getVariableValue(variable, shouldFetchVariable, {
|
|
58177
|
+
client,
|
|
58178
|
+
extras,
|
|
58179
|
+
search,
|
|
58180
|
+
snapshot,
|
|
58181
|
+
taskContext
|
|
58182
|
+
});
|
|
58183
|
+
};
|
|
58184
|
+
},
|
|
58185
|
+
[variable.uid, useDeepCompare(taskContext), client, search, extras]
|
|
58186
|
+
);
|
|
58187
|
+
}
|
|
58188
|
+
function resolveValue(value, force) {
|
|
58189
|
+
if (isResolvedDerivedVariable(value) || isResolvedDerivedDataVariable(value)) {
|
|
58190
|
+
const { deps, ...rest } = value;
|
|
58191
|
+
const resolvedValues = value.values.map((v2) => resolveValue(v2, force));
|
|
58192
|
+
return {
|
|
58193
|
+
...rest,
|
|
58194
|
+
force,
|
|
58195
|
+
values: resolvedValues
|
|
58196
|
+
};
|
|
58197
|
+
}
|
|
58198
|
+
if (typeof value === "function") {
|
|
58199
|
+
return resolveValue(value(), force);
|
|
58200
|
+
}
|
|
58201
|
+
return value;
|
|
58202
|
+
}
|
|
58203
|
+
function useRefreshSelector() {
|
|
58204
|
+
return Recoil_index_31(({ refresh }) => {
|
|
58205
|
+
return (key, extras) => {
|
|
58206
|
+
var _a;
|
|
58207
|
+
const family = selectorFamilyRegistry.get(key);
|
|
58208
|
+
if (family) {
|
|
58209
|
+
const selector2 = (_a = selectorFamilyMembersRegistry.get(family)) == null ? void 0 : _a.get(extras);
|
|
58210
|
+
if (selector2) {
|
|
58211
|
+
refresh(selector2);
|
|
58212
|
+
}
|
|
58213
|
+
}
|
|
58214
|
+
};
|
|
58215
|
+
});
|
|
58216
|
+
}
|
|
58217
|
+
function useVariableState() {
|
|
58218
|
+
const extras = useRequestExtras();
|
|
58219
|
+
const { client } = React.useContext(websocketCtx);
|
|
58220
|
+
const taskCtx = useTaskContext();
|
|
58221
|
+
return Recoil_index_31(({ snapshot }) => {
|
|
58222
|
+
return (variable) => {
|
|
58223
|
+
if (!isRegistered(variable)) {
|
|
58224
|
+
return "__NOT_REGISTERED__";
|
|
58225
|
+
}
|
|
58226
|
+
const resolvedVariable = resolveVariable(
|
|
58227
|
+
variable,
|
|
58228
|
+
client,
|
|
58229
|
+
taskCtx,
|
|
58230
|
+
extras,
|
|
58231
|
+
(v2) => snapshot.getLoadable(v2).getValue()
|
|
58232
|
+
);
|
|
58233
|
+
return resolvedVariable;
|
|
58234
|
+
};
|
|
58235
|
+
}, []);
|
|
58236
|
+
}
|
|
58024
58237
|
function useActionRegistry() {
|
|
58025
58238
|
const { actionRegistry: actions } = React.useContext(registriesCtx);
|
|
58026
58239
|
const get2 = React.useCallback(
|
|
@@ -58169,6 +58382,12 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
58169
58382
|
});
|
|
58170
58383
|
}
|
|
58171
58384
|
const noop = () => Promise.resolve();
|
|
58385
|
+
function useActionIsLoading(action) {
|
|
58386
|
+
if (!action || isActionImpl(action) || Array.isArray(action)) {
|
|
58387
|
+
return false;
|
|
58388
|
+
}
|
|
58389
|
+
return useVariable(action.loading)[0];
|
|
58390
|
+
}
|
|
58172
58391
|
function useAction(action, options) {
|
|
58173
58392
|
const { client: wsClient } = React.useContext(websocketCtx);
|
|
58174
58393
|
const importers = React.useContext(importersCtx);
|
|
@@ -58178,7 +58397,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
58178
58397
|
const history2 = useHistory();
|
|
58179
58398
|
const taskCtx = useTaskContext();
|
|
58180
58399
|
const location2 = useLocation();
|
|
58181
|
-
const [isLoading, setIsLoading] = React.useState(false);
|
|
58182
58400
|
const actionCtx = React.useRef();
|
|
58183
58401
|
actionCtx.current = {
|
|
58184
58402
|
extras,
|
|
@@ -58193,9 +58411,12 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
58193
58411
|
const callback = Recoil_index_31(
|
|
58194
58412
|
(cbInterface) => async (input) => {
|
|
58195
58413
|
var _a;
|
|
58196
|
-
setIsLoading(true);
|
|
58197
58414
|
const actionsToExecute = Array.isArray(action) ? action : [action];
|
|
58198
58415
|
for (const actionToExecute of actionsToExecute) {
|
|
58416
|
+
const loadingVariable = !isActionImpl(actionToExecute) ? getOrRegisterPlainVariable(actionToExecute.loading, wsClient, taskCtx, extras) : null;
|
|
58417
|
+
if (loadingVariable) {
|
|
58418
|
+
cbInterface.set(loadingVariable, true);
|
|
58419
|
+
}
|
|
58199
58420
|
const fullActionContext = {
|
|
58200
58421
|
...actionCtx.current,
|
|
58201
58422
|
input,
|
|
@@ -58222,15 +58443,17 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
58222
58443
|
title: "Error executing action"
|
|
58223
58444
|
});
|
|
58224
58445
|
}
|
|
58446
|
+
if (loadingVariable) {
|
|
58447
|
+
cbInterface.set(loadingVariable, false);
|
|
58448
|
+
}
|
|
58225
58449
|
}
|
|
58226
|
-
setIsLoading(false);
|
|
58227
58450
|
},
|
|
58228
58451
|
[action, getAction, importers]
|
|
58229
58452
|
);
|
|
58230
58453
|
if (!action) {
|
|
58231
|
-
return
|
|
58454
|
+
return noop;
|
|
58232
58455
|
}
|
|
58233
|
-
return
|
|
58456
|
+
return callback;
|
|
58234
58457
|
}
|
|
58235
58458
|
function useDeferLoadable(loadable) {
|
|
58236
58459
|
const { suspend } = React.useContext(fallbackCtx);
|
|
@@ -58615,13 +58838,23 @@ Inferred class string: "${iconClasses}."`
|
|
|
58615
58838
|
}
|
|
58616
58839
|
function PrivateRoute({ children, on_load, name }) {
|
|
58617
58840
|
const token = useSessionToken();
|
|
58618
|
-
const
|
|
58841
|
+
const onLoad = useAction(on_load);
|
|
58842
|
+
const isLoading = useActionIsLoading(on_load);
|
|
58619
58843
|
useWindowTitle(name);
|
|
58620
58844
|
React.useEffect(() => {
|
|
58621
58845
|
onLoad();
|
|
58622
58846
|
}, []);
|
|
58623
58847
|
if (!token) {
|
|
58624
|
-
|
|
58848
|
+
const referrer = encodeURIComponent(window.location.pathname + window.location.search);
|
|
58849
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
58850
|
+
Redirect,
|
|
58851
|
+
{
|
|
58852
|
+
to: {
|
|
58853
|
+
pathname: "/login",
|
|
58854
|
+
search: `?referrer=${referrer}`
|
|
58855
|
+
}
|
|
58856
|
+
}
|
|
58857
|
+
);
|
|
58625
58858
|
}
|
|
58626
58859
|
return isLoading ? /* @__PURE__ */ React__default.default.createElement(DefaultFallback, null) : children;
|
|
58627
58860
|
}
|
|
@@ -58995,216 +59228,6 @@ Inferred class string: "${iconClasses}."`
|
|
|
58995
59228
|
const [styles2, css2] = parseRawCss((_a = props.config) == null ? void 0 : _a.raw_css);
|
|
58996
59229
|
return /* @__PURE__ */ React__default.default.createElement(ErrorDisplayWrapper, { $rawCss: css2, style: styles2 }, /* @__PURE__ */ React__default.default.createElement(ContentWrapper, null, /* @__PURE__ */ React__default.default.createElement(ErrorContent, null, /* @__PURE__ */ React__default.default.createElement(ErrorTitle$1, null, /* @__PURE__ */ React__default.default.createElement(IconWrapper, null, /* @__PURE__ */ React__default.default.createElement(ErrorIcon, { "aria-hidden": true, className: "fa-solid fa-circle-xmark fa-lg" })), (_c = (_b = props == null ? void 0 : props.config) == null ? void 0 : _b.title) != null ? _c : "Error"), /* @__PURE__ */ React__default.default.createElement(ErrorText$1, null, (_e2 = (_d = props == null ? void 0 : props.config) == null ? void 0 : _d.description) != null ? _e2 : "Try again or contact the application owner."))), props.resetErrorBoundary && /* @__PURE__ */ React__default.default.createElement(RetryButton, { onClick: () => props.resetErrorBoundary(props.error), type: "button" }, /* @__PURE__ */ React__default.default.createElement("i", { "aria-hidden": true, className: "fa-solid fa-rotate fa-xl" })));
|
|
58997
59230
|
}
|
|
58998
|
-
function warnUpdateOnDerivedState() {
|
|
58999
|
-
console.warn("You tried to call update on variable with derived state, this is a noop and will be ignored.");
|
|
59000
|
-
}
|
|
59001
|
-
function useVariable(variable) {
|
|
59002
|
-
const extras = useRequestExtras();
|
|
59003
|
-
const { client: WsClient } = React.useContext(websocketCtx);
|
|
59004
|
-
const taskContext = useTaskContext();
|
|
59005
|
-
const variablesContext = React.useContext(variablesCtx);
|
|
59006
|
-
const bus = useEventBus();
|
|
59007
|
-
if (!isVariable(variable)) {
|
|
59008
|
-
return React.useState(variable);
|
|
59009
|
-
}
|
|
59010
|
-
variablesContext.variables.current.add(variable.uid);
|
|
59011
|
-
React.useEffect(() => {
|
|
59012
|
-
return () => {
|
|
59013
|
-
variablesContext.variables.current.delete(variable.uid);
|
|
59014
|
-
};
|
|
59015
|
-
}, []);
|
|
59016
|
-
if (isDataVariable(variable) || isDerivedDataVariable(variable)) {
|
|
59017
|
-
throw new Error(`Non-data variable expected, got ${variable.__typename}`);
|
|
59018
|
-
}
|
|
59019
|
-
if (isDerivedVariable(variable)) {
|
|
59020
|
-
const selector2 = useDerivedVariable(variable, WsClient, taskContext, extras);
|
|
59021
|
-
const selectorLoadable = Recoil_index_28(selector2);
|
|
59022
|
-
React.useEffect(() => {
|
|
59023
|
-
if (selectorLoadable.state !== "loading") {
|
|
59024
|
-
bus.publish("DERIVED_VARIABLE_LOADED", { variable, value: selectorLoadable.contents });
|
|
59025
|
-
}
|
|
59026
|
-
}, [selectorLoadable]);
|
|
59027
|
-
const deferred2 = useDeferLoadable(selectorLoadable);
|
|
59028
|
-
return [deferred2.value, warnUpdateOnDerivedState];
|
|
59029
|
-
}
|
|
59030
|
-
if (isUrlVariable(variable)) {
|
|
59031
|
-
return useUrlVariable(variable);
|
|
59032
|
-
}
|
|
59033
|
-
const recoilState = getOrRegisterPlainVariable(variable, WsClient, taskContext, extras);
|
|
59034
|
-
const [loadable, setLoadable] = Recoil_index_23(recoilState);
|
|
59035
|
-
const deferred = useDeferLoadable(loadable);
|
|
59036
|
-
React.useEffect(() => {
|
|
59037
|
-
if (loadable.state !== "loading") {
|
|
59038
|
-
bus.publish("PLAIN_VARIABLE_LOADED", { variable, value: loadable.contents });
|
|
59039
|
-
}
|
|
59040
|
-
}, [loadable]);
|
|
59041
|
-
return [deferred, setLoadable];
|
|
59042
|
-
}
|
|
59043
|
-
function useDataVariable(variable) {
|
|
59044
|
-
const extras = useRequestExtras();
|
|
59045
|
-
const { client: wsClient } = React.useContext(websocketCtx);
|
|
59046
|
-
if (isDataVariable(variable)) {
|
|
59047
|
-
registerDataVariable(variable);
|
|
59048
|
-
const serverTriggers$ = React.useMemo(() => wsClient.serverTriggers$(variable.uid), []);
|
|
59049
|
-
const [serverTriggerCounter, setServerTriggerCounter] = React.useState(0);
|
|
59050
|
-
React.useEffect(() => {
|
|
59051
|
-
const sub = serverTriggers$.subscribe(() => setServerTriggerCounter((c2) => c2 + 1));
|
|
59052
|
-
return () => sub.unsubscribe();
|
|
59053
|
-
}, [serverTriggers$]);
|
|
59054
|
-
const fetchDataVariable2 = useFetchDataVariable(variable, serverTriggerCounter);
|
|
59055
|
-
return fetchDataVariable2;
|
|
59056
|
-
}
|
|
59057
|
-
const variablesContext = React.useContext(variablesCtx);
|
|
59058
|
-
variablesContext.variables.current.add(variable.uid);
|
|
59059
|
-
React.useEffect(() => {
|
|
59060
|
-
return () => {
|
|
59061
|
-
variablesContext.variables.current.delete(variable.uid);
|
|
59062
|
-
};
|
|
59063
|
-
}, []);
|
|
59064
|
-
const taskContext = useTaskContext();
|
|
59065
|
-
const dvSelector = useDerivedVariable(variable, wsClient, taskContext, extras);
|
|
59066
|
-
const dvLoadable = Recoil_index_21(dvSelector);
|
|
59067
|
-
const [dvValue, setDvValue] = React.useState(dvLoadable.toPromise());
|
|
59068
|
-
React.useEffect(() => {
|
|
59069
|
-
if (dvLoadable.state === "loading") {
|
|
59070
|
-
setDvValue(dvLoadable.toPromise());
|
|
59071
|
-
}
|
|
59072
|
-
}, [dvLoadable]);
|
|
59073
|
-
const fetchDerivedDataVariable2 = useFetchDerivedDataVariable(variable, taskContext, wsClient, dvValue);
|
|
59074
|
-
return fetchDerivedDataVariable2;
|
|
59075
|
-
}
|
|
59076
|
-
function useAnyVariable(variable) {
|
|
59077
|
-
if (isDataVariable(variable) || isDerivedDataVariable(variable)) {
|
|
59078
|
-
const getData2 = useDataVariable(variable);
|
|
59079
|
-
const { data, refetch } = reactQuery.useQuery({
|
|
59080
|
-
cacheTime: 1,
|
|
59081
|
-
queryFn: async () => {
|
|
59082
|
-
const dataResponse = await getData2();
|
|
59083
|
-
return dataResponse.data;
|
|
59084
|
-
},
|
|
59085
|
-
queryKey: ["any-variable-data", variable.uid],
|
|
59086
|
-
refetchOnWindowFocus: false,
|
|
59087
|
-
suspense: true
|
|
59088
|
-
});
|
|
59089
|
-
React.useEffect(() => {
|
|
59090
|
-
refetch();
|
|
59091
|
-
}, [getData2]);
|
|
59092
|
-
return data;
|
|
59093
|
-
}
|
|
59094
|
-
return useVariable(variable)[0];
|
|
59095
|
-
}
|
|
59096
|
-
function getVariableValue(variable, shouldFetchVariable = false, ctx) {
|
|
59097
|
-
const resolved = resolveVariable(
|
|
59098
|
-
variable,
|
|
59099
|
-
ctx.client,
|
|
59100
|
-
ctx.taskContext,
|
|
59101
|
-
ctx.extras,
|
|
59102
|
-
(v2) => ctx.snapshot.getLoadable(v2).getValue()
|
|
59103
|
-
);
|
|
59104
|
-
if (!shouldFetchVariable || !isDerivedVariable(variable) && !isDataVariable(variable) && !isDerivedDataVariable(variable)) {
|
|
59105
|
-
return resolved;
|
|
59106
|
-
}
|
|
59107
|
-
if (!isResolvedDerivedVariable(resolved) && !isResolvedDataVariable(resolved) && !isResolvedDerivedDataVariable(resolved)) {
|
|
59108
|
-
return resolved;
|
|
59109
|
-
}
|
|
59110
|
-
if (isResolvedDataVariable(resolved)) {
|
|
59111
|
-
return fetchDataVariable(resolved.uid, ctx.extras, resolved.filters);
|
|
59112
|
-
}
|
|
59113
|
-
return fetchDerivedVariable({
|
|
59114
|
-
cache: variable.cache,
|
|
59115
|
-
extras: ctx.extras,
|
|
59116
|
-
force: false,
|
|
59117
|
-
selectorKey: resolved.uid,
|
|
59118
|
-
values: normalizeRequest(
|
|
59119
|
-
formatDerivedVariableRequest(resolved.values),
|
|
59120
|
-
variable.variables
|
|
59121
|
-
),
|
|
59122
|
-
variableUid: resolved.uid,
|
|
59123
|
-
wsClient: ctx.client
|
|
59124
|
-
}).then((resp) => {
|
|
59125
|
-
if (isTaskResponse$1(resp)) {
|
|
59126
|
-
throw new Error("Task DerivedVariables are not supported in this context");
|
|
59127
|
-
}
|
|
59128
|
-
if (isDerivedDataVariable(variable)) {
|
|
59129
|
-
return ctx.client.getChannel().then(
|
|
59130
|
-
(chan) => fetchDerivedDataVariable(variable.uid, ctx.extras, resp.cache_key, chan, variable.filters)
|
|
59131
|
-
);
|
|
59132
|
-
}
|
|
59133
|
-
return resp.value;
|
|
59134
|
-
});
|
|
59135
|
-
}
|
|
59136
|
-
function useVariableValue(variable, shouldFetchVariable = false) {
|
|
59137
|
-
const taskContext = useTaskContext();
|
|
59138
|
-
const { client } = React.useContext(websocketCtx);
|
|
59139
|
-
const { search } = useLocation();
|
|
59140
|
-
const extras = useRequestExtras();
|
|
59141
|
-
if (!isVariable(variable)) {
|
|
59142
|
-
return () => variable;
|
|
59143
|
-
}
|
|
59144
|
-
return Recoil_index_31(
|
|
59145
|
-
({ snapshot }) => {
|
|
59146
|
-
return () => {
|
|
59147
|
-
return getVariableValue(variable, shouldFetchVariable, {
|
|
59148
|
-
client,
|
|
59149
|
-
extras,
|
|
59150
|
-
search,
|
|
59151
|
-
snapshot,
|
|
59152
|
-
taskContext
|
|
59153
|
-
});
|
|
59154
|
-
};
|
|
59155
|
-
},
|
|
59156
|
-
[variable.uid, useDeepCompare(taskContext), client, search, extras]
|
|
59157
|
-
);
|
|
59158
|
-
}
|
|
59159
|
-
function resolveValue(value, force) {
|
|
59160
|
-
if (isResolvedDerivedVariable(value) || isResolvedDerivedDataVariable(value)) {
|
|
59161
|
-
const { deps, ...rest } = value;
|
|
59162
|
-
const resolvedValues = value.values.map((v2) => resolveValue(v2, force));
|
|
59163
|
-
return {
|
|
59164
|
-
...rest,
|
|
59165
|
-
force,
|
|
59166
|
-
values: resolvedValues
|
|
59167
|
-
};
|
|
59168
|
-
}
|
|
59169
|
-
if (typeof value === "function") {
|
|
59170
|
-
return resolveValue(value(), force);
|
|
59171
|
-
}
|
|
59172
|
-
return value;
|
|
59173
|
-
}
|
|
59174
|
-
function useRefreshSelector() {
|
|
59175
|
-
return Recoil_index_31(({ refresh }) => {
|
|
59176
|
-
return (key, extras) => {
|
|
59177
|
-
var _a;
|
|
59178
|
-
const family = selectorFamilyRegistry.get(key);
|
|
59179
|
-
if (family) {
|
|
59180
|
-
const selector2 = (_a = selectorFamilyMembersRegistry.get(family)) == null ? void 0 : _a.get(extras);
|
|
59181
|
-
if (selector2) {
|
|
59182
|
-
refresh(selector2);
|
|
59183
|
-
}
|
|
59184
|
-
}
|
|
59185
|
-
};
|
|
59186
|
-
});
|
|
59187
|
-
}
|
|
59188
|
-
function useVariableState() {
|
|
59189
|
-
const extras = useRequestExtras();
|
|
59190
|
-
const { client } = React.useContext(websocketCtx);
|
|
59191
|
-
const taskCtx = useTaskContext();
|
|
59192
|
-
return Recoil_index_31(({ snapshot }) => {
|
|
59193
|
-
return (variable) => {
|
|
59194
|
-
if (!isRegistered(variable)) {
|
|
59195
|
-
return "__NOT_REGISTERED__";
|
|
59196
|
-
}
|
|
59197
|
-
const resolvedVariable = resolveVariable(
|
|
59198
|
-
variable,
|
|
59199
|
-
client,
|
|
59200
|
-
taskCtx,
|
|
59201
|
-
extras,
|
|
59202
|
-
(v2) => snapshot.getLoadable(v2).getValue()
|
|
59203
|
-
);
|
|
59204
|
-
return resolvedVariable;
|
|
59205
|
-
};
|
|
59206
|
-
}, []);
|
|
59207
|
-
}
|
|
59208
59231
|
function isTaskResponse(response) {
|
|
59209
59232
|
return response && typeof response === "object" && "task_id" in response;
|
|
59210
59233
|
}
|
|
@@ -85717,8 +85740,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
85717
85740
|
const history2 = useHistory();
|
|
85718
85741
|
const location2 = useLocation();
|
|
85719
85742
|
const queryParams = new URLSearchParams(location2.search);
|
|
85720
|
-
const previousLocation =
|
|
85721
|
-
const { from: from2 } = previousLocation;
|
|
85743
|
+
const previousLocation = (_a = queryParams.get("referrer")) != null ? _a : "/";
|
|
85722
85744
|
const login = async () => {
|
|
85723
85745
|
setIsLoggingIn(true);
|
|
85724
85746
|
setIsError(false);
|
|
@@ -85726,7 +85748,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
85726
85748
|
const sessionToken = await getSessionToken({ password, username });
|
|
85727
85749
|
if (sessionToken) {
|
|
85728
85750
|
setToken(sessionToken);
|
|
85729
|
-
history2.replace(
|
|
85751
|
+
history2.replace(decodeURIComponent(previousLocation));
|
|
85730
85752
|
}
|
|
85731
85753
|
} catch {
|
|
85732
85754
|
setIsError(true);
|
|
@@ -85738,7 +85760,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
85738
85760
|
if (token) {
|
|
85739
85761
|
verifySessionToken(localStorage.getItem(key)).then((verified) => {
|
|
85740
85762
|
if (verified) {
|
|
85741
|
-
history2.replace(
|
|
85763
|
+
history2.replace(decodeURIComponent(previousLocation));
|
|
85742
85764
|
} else {
|
|
85743
85765
|
setIsVerifyingToken(false);
|
|
85744
85766
|
}
|
|
@@ -85809,13 +85831,12 @@ Inferred class string: "${iconClasses}."`
|
|
|
85809
85831
|
const history2 = useHistory();
|
|
85810
85832
|
const location2 = useLocation();
|
|
85811
85833
|
const queryParams = new URLSearchParams(location2.search);
|
|
85812
|
-
const previousLocation =
|
|
85813
|
-
const { from: from2 } = previousLocation;
|
|
85834
|
+
const previousLocation = (_a = queryParams.get("referrer")) != null ? _a : "/";
|
|
85814
85835
|
async function getNewToken() {
|
|
85815
85836
|
const sessionToken = await getSessionToken({});
|
|
85816
85837
|
if (sessionToken) {
|
|
85817
85838
|
setToken(sessionToken);
|
|
85818
|
-
history2.replace(
|
|
85839
|
+
history2.replace(decodeURIComponent(previousLocation));
|
|
85819
85840
|
}
|
|
85820
85841
|
}
|
|
85821
85842
|
React.useEffect(() => {
|
|
@@ -85827,7 +85848,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
85827
85848
|
}
|
|
85828
85849
|
verifySessionToken(localStorage.getItem(key)).then((verified) => {
|
|
85829
85850
|
if (verified) {
|
|
85830
|
-
history2.replace(
|
|
85851
|
+
history2.replace(decodeURIComponent(previousLocation));
|
|
85831
85852
|
} else {
|
|
85832
85853
|
getNewToken();
|
|
85833
85854
|
}
|
|
@@ -86170,6 +86191,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
86170
86191
|
exports.resolveValue = resolveValue;
|
|
86171
86192
|
exports.revokeSession = revokeSession;
|
|
86172
86193
|
exports.useAction = useAction;
|
|
86194
|
+
exports.useActionIsLoading = useActionIsLoading;
|
|
86173
86195
|
exports.useAnyVariable = useAnyVariable;
|
|
86174
86196
|
exports.useAuthCtx = useAuthCtx;
|
|
86175
86197
|
exports.useComponentStyles = useComponentStyles;
|