landvex: Fixar och tester klara för alla komponenter
- Datafabrik: Dockerfile fix, agentorkestrering fungerar - Vision: Identify-modell, FAISS, OCR alla testade - API: Alla 7 integrationstester passerade - Upplösare: Entitetsupplösning verifierad
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import { hydrate } from '../core';
|
||||
import { useQueryClient } from './QueryClientProvider';
|
||||
export function useHydrate(state, options) {
|
||||
var queryClient = useQueryClient();
|
||||
var optionsRef = React.useRef(options);
|
||||
optionsRef.current = options; // Running hydrate again with the same queries is safe,
|
||||
// it wont overwrite or initialize existing queries,
|
||||
// relying on useMemo here is only a performance optimization.
|
||||
// hydrate can and should be run *during* render here for SSR to work properly
|
||||
|
||||
React.useMemo(function () {
|
||||
if (state) {
|
||||
hydrate(queryClient, state, optionsRef.current);
|
||||
}
|
||||
}, [queryClient, state]);
|
||||
}
|
||||
export var Hydrate = function Hydrate(_ref) {
|
||||
var children = _ref.children,
|
||||
options = _ref.options,
|
||||
state = _ref.state;
|
||||
useHydrate(state, options);
|
||||
return children;
|
||||
};
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
import React from 'react';
|
||||
var defaultContext = /*#__PURE__*/React.createContext(undefined);
|
||||
var QueryClientSharingContext = /*#__PURE__*/React.createContext(false); // if contextSharing is on, we share the first and at least one
|
||||
// instance of the context across the window
|
||||
// to ensure that if React Query is used across
|
||||
// different bundles or microfrontends they will
|
||||
// all use the same **instance** of context, regardless
|
||||
// of module scoping.
|
||||
|
||||
function getQueryClientContext(contextSharing) {
|
||||
if (contextSharing && typeof window !== 'undefined') {
|
||||
if (!window.ReactQueryClientContext) {
|
||||
window.ReactQueryClientContext = defaultContext;
|
||||
}
|
||||
|
||||
return window.ReactQueryClientContext;
|
||||
}
|
||||
|
||||
return defaultContext;
|
||||
}
|
||||
|
||||
export var useQueryClient = function useQueryClient() {
|
||||
var queryClient = React.useContext(getQueryClientContext(React.useContext(QueryClientSharingContext)));
|
||||
|
||||
if (!queryClient) {
|
||||
throw new Error('No QueryClient set, use QueryClientProvider to set one');
|
||||
}
|
||||
|
||||
return queryClient;
|
||||
};
|
||||
export var QueryClientProvider = function QueryClientProvider(_ref) {
|
||||
var client = _ref.client,
|
||||
_ref$contextSharing = _ref.contextSharing,
|
||||
contextSharing = _ref$contextSharing === void 0 ? false : _ref$contextSharing,
|
||||
children = _ref.children;
|
||||
React.useEffect(function () {
|
||||
client.mount();
|
||||
return function () {
|
||||
client.unmount();
|
||||
};
|
||||
}, [client]);
|
||||
var Context = getQueryClientContext(contextSharing);
|
||||
return /*#__PURE__*/React.createElement(QueryClientSharingContext.Provider, {
|
||||
value: contextSharing
|
||||
}, /*#__PURE__*/React.createElement(Context.Provider, {
|
||||
value: client
|
||||
}, children));
|
||||
};
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import React from 'react'; // CONTEXT
|
||||
|
||||
function createValue() {
|
||||
var _isReset = false;
|
||||
return {
|
||||
clearReset: function clearReset() {
|
||||
_isReset = false;
|
||||
},
|
||||
reset: function reset() {
|
||||
_isReset = true;
|
||||
},
|
||||
isReset: function isReset() {
|
||||
return _isReset;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var QueryErrorResetBoundaryContext = /*#__PURE__*/React.createContext(createValue()); // HOOK
|
||||
|
||||
export var useQueryErrorResetBoundary = function useQueryErrorResetBoundary() {
|
||||
return React.useContext(QueryErrorResetBoundaryContext);
|
||||
}; // COMPONENT
|
||||
|
||||
export var QueryErrorResetBoundary = function QueryErrorResetBoundary(_ref) {
|
||||
var children = _ref.children;
|
||||
var value = React.useMemo(function () {
|
||||
return createValue();
|
||||
}, []);
|
||||
return /*#__PURE__*/React.createElement(QueryErrorResetBoundaryContext.Provider, {
|
||||
value: value
|
||||
}, typeof children === 'function' ? children(value) : children);
|
||||
};
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// Side effects
|
||||
import './setBatchUpdatesFn';
|
||||
import './setLogger';
|
||||
export { QueryClientProvider, useQueryClient } from './QueryClientProvider';
|
||||
export { QueryErrorResetBoundary, useQueryErrorResetBoundary } from './QueryErrorResetBoundary';
|
||||
export { useIsFetching } from './useIsFetching';
|
||||
export { useIsMutating } from './useIsMutating';
|
||||
export { useMutation } from './useMutation';
|
||||
export { useQuery } from './useQuery';
|
||||
export { useQueries } from './useQueries';
|
||||
export { useInfiniteQuery } from './useInfiniteQuery';
|
||||
export { useHydrate, Hydrate } from './Hydrate'; // Types
|
||||
|
||||
export * from './types';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export var logger = console;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export var logger = {
|
||||
log: console.log,
|
||||
warn: console.warn,
|
||||
error: console.warn
|
||||
};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import ReactDOM from 'react-dom';
|
||||
export var unstable_batchedUpdates = ReactDOM.unstable_batchedUpdates;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import { unstable_batchedUpdates } from 'react-native';
|
||||
export { unstable_batchedUpdates };
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { notifyManager } from '../core';
|
||||
import { unstable_batchedUpdates } from './reactBatchedUpdates';
|
||||
notifyManager.setBatchNotifyFunction(unstable_batchedUpdates);
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { setLogger } from '../core';
|
||||
import { logger } from './logger';
|
||||
setLogger(logger);
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
import React from 'react';
|
||||
import { notifyManager } from '../core/notifyManager';
|
||||
import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary';
|
||||
import { useQueryClient } from './QueryClientProvider';
|
||||
import { shouldThrowError } from './utils';
|
||||
export function useBaseQuery(options, Observer) {
|
||||
var mountedRef = React.useRef(false);
|
||||
|
||||
var _React$useState = React.useState(0),
|
||||
forceUpdate = _React$useState[1];
|
||||
|
||||
var queryClient = useQueryClient();
|
||||
var errorResetBoundary = useQueryErrorResetBoundary();
|
||||
var defaultedOptions = queryClient.defaultQueryObserverOptions(options); // Make sure results are optimistically set in fetching state before subscribing or updating options
|
||||
|
||||
defaultedOptions.optimisticResults = true; // Include callbacks in batch renders
|
||||
|
||||
if (defaultedOptions.onError) {
|
||||
defaultedOptions.onError = notifyManager.batchCalls(defaultedOptions.onError);
|
||||
}
|
||||
|
||||
if (defaultedOptions.onSuccess) {
|
||||
defaultedOptions.onSuccess = notifyManager.batchCalls(defaultedOptions.onSuccess);
|
||||
}
|
||||
|
||||
if (defaultedOptions.onSettled) {
|
||||
defaultedOptions.onSettled = notifyManager.batchCalls(defaultedOptions.onSettled);
|
||||
}
|
||||
|
||||
if (defaultedOptions.suspense) {
|
||||
// Always set stale time when using suspense to prevent
|
||||
// fetching again when directly mounting after suspending
|
||||
if (typeof defaultedOptions.staleTime !== 'number') {
|
||||
defaultedOptions.staleTime = 1000;
|
||||
} // Set cache time to 1 if the option has been set to 0
|
||||
// when using suspense to prevent infinite loop of fetches
|
||||
|
||||
|
||||
if (defaultedOptions.cacheTime === 0) {
|
||||
defaultedOptions.cacheTime = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultedOptions.suspense || defaultedOptions.useErrorBoundary) {
|
||||
// Prevent retrying failed query if the error boundary has not been reset yet
|
||||
if (!errorResetBoundary.isReset()) {
|
||||
defaultedOptions.retryOnMount = false;
|
||||
}
|
||||
}
|
||||
|
||||
var _React$useState2 = React.useState(function () {
|
||||
return new Observer(queryClient, defaultedOptions);
|
||||
}),
|
||||
observer = _React$useState2[0];
|
||||
|
||||
var result = observer.getOptimisticResult(defaultedOptions);
|
||||
React.useEffect(function () {
|
||||
mountedRef.current = true;
|
||||
errorResetBoundary.clearReset();
|
||||
var unsubscribe = observer.subscribe(notifyManager.batchCalls(function () {
|
||||
if (mountedRef.current) {
|
||||
forceUpdate(function (x) {
|
||||
return x + 1;
|
||||
});
|
||||
}
|
||||
})); // Update result to make sure we did not miss any query updates
|
||||
// between creating the observer and subscribing to it.
|
||||
|
||||
observer.updateResult();
|
||||
return function () {
|
||||
mountedRef.current = false;
|
||||
unsubscribe();
|
||||
};
|
||||
}, [errorResetBoundary, observer]);
|
||||
React.useEffect(function () {
|
||||
// Do not notify on updates because of changes in the options because
|
||||
// these changes should already be reflected in the optimistic result.
|
||||
observer.setOptions(defaultedOptions, {
|
||||
listeners: false
|
||||
});
|
||||
}, [defaultedOptions, observer]); // Handle suspense
|
||||
|
||||
if (defaultedOptions.suspense && result.isLoading) {
|
||||
throw observer.fetchOptimistic(defaultedOptions).then(function (_ref) {
|
||||
var data = _ref.data;
|
||||
defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
|
||||
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
|
||||
}).catch(function (error) {
|
||||
errorResetBoundary.clearReset();
|
||||
defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
|
||||
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error);
|
||||
});
|
||||
} // Handle error boundary
|
||||
|
||||
|
||||
if (result.isError && !errorResetBoundary.isReset() && !result.isFetching && shouldThrowError(defaultedOptions.suspense, defaultedOptions.useErrorBoundary, [result.error, observer.getCurrentQuery()])) {
|
||||
throw result.error;
|
||||
} // Handle result property usage tracking
|
||||
|
||||
|
||||
if (defaultedOptions.notifyOnChangeProps === 'tracked') {
|
||||
result = observer.trackResult(result, defaultedOptions);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { InfiniteQueryObserver } from '../core/infiniteQueryObserver';
|
||||
import { parseQueryArgs } from '../core/utils';
|
||||
import { useBaseQuery } from './useBaseQuery'; // HOOK
|
||||
|
||||
export function useInfiniteQuery(arg1, arg2, arg3) {
|
||||
var options = parseQueryArgs(arg1, arg2, arg3);
|
||||
return useBaseQuery(options, InfiniteQueryObserver);
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import { notifyManager } from '../core/notifyManager';
|
||||
import { parseFilterArgs } from '../core/utils';
|
||||
import { useQueryClient } from './QueryClientProvider';
|
||||
|
||||
var checkIsFetching = function checkIsFetching(queryClient, filters, isFetching, setIsFetching) {
|
||||
var newIsFetching = queryClient.isFetching(filters);
|
||||
|
||||
if (isFetching !== newIsFetching) {
|
||||
setIsFetching(newIsFetching);
|
||||
}
|
||||
};
|
||||
|
||||
export function useIsFetching(arg1, arg2) {
|
||||
var mountedRef = React.useRef(false);
|
||||
var queryClient = useQueryClient();
|
||||
|
||||
var _parseFilterArgs = parseFilterArgs(arg1, arg2),
|
||||
filters = _parseFilterArgs[0];
|
||||
|
||||
var _React$useState = React.useState(queryClient.isFetching(filters)),
|
||||
isFetching = _React$useState[0],
|
||||
setIsFetching = _React$useState[1];
|
||||
|
||||
var filtersRef = React.useRef(filters);
|
||||
filtersRef.current = filters;
|
||||
var isFetchingRef = React.useRef(isFetching);
|
||||
isFetchingRef.current = isFetching;
|
||||
React.useEffect(function () {
|
||||
mountedRef.current = true;
|
||||
checkIsFetching(queryClient, filtersRef.current, isFetchingRef.current, setIsFetching);
|
||||
var unsubscribe = queryClient.getQueryCache().subscribe(notifyManager.batchCalls(function () {
|
||||
if (mountedRef.current) {
|
||||
checkIsFetching(queryClient, filtersRef.current, isFetchingRef.current, setIsFetching);
|
||||
}
|
||||
}));
|
||||
return function () {
|
||||
mountedRef.current = false;
|
||||
unsubscribe();
|
||||
};
|
||||
}, [queryClient]);
|
||||
return isFetching;
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
import { notifyManager } from '../core/notifyManager';
|
||||
import { parseMutationFilterArgs } from '../core/utils';
|
||||
import { useQueryClient } from './QueryClientProvider';
|
||||
export function useIsMutating(arg1, arg2) {
|
||||
var mountedRef = React.useRef(false);
|
||||
var filters = parseMutationFilterArgs(arg1, arg2);
|
||||
var queryClient = useQueryClient();
|
||||
|
||||
var _React$useState = React.useState(queryClient.isMutating(filters)),
|
||||
isMutating = _React$useState[0],
|
||||
setIsMutating = _React$useState[1];
|
||||
|
||||
var filtersRef = React.useRef(filters);
|
||||
filtersRef.current = filters;
|
||||
var isMutatingRef = React.useRef(isMutating);
|
||||
isMutatingRef.current = isMutating;
|
||||
React.useEffect(function () {
|
||||
mountedRef.current = true;
|
||||
var unsubscribe = queryClient.getMutationCache().subscribe(notifyManager.batchCalls(function () {
|
||||
if (mountedRef.current) {
|
||||
var newIsMutating = queryClient.isMutating(filtersRef.current);
|
||||
|
||||
if (isMutatingRef.current !== newIsMutating) {
|
||||
setIsMutating(newIsMutating);
|
||||
}
|
||||
}
|
||||
}));
|
||||
return function () {
|
||||
mountedRef.current = false;
|
||||
unsubscribe();
|
||||
};
|
||||
}, [queryClient]);
|
||||
return isMutating;
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import React from 'react';
|
||||
import { notifyManager } from '../core/notifyManager';
|
||||
import { noop, parseMutationArgs } from '../core/utils';
|
||||
import { MutationObserver } from '../core/mutationObserver';
|
||||
import { useQueryClient } from './QueryClientProvider';
|
||||
import { shouldThrowError } from './utils'; // HOOK
|
||||
|
||||
export function useMutation(arg1, arg2, arg3) {
|
||||
var mountedRef = React.useRef(false);
|
||||
|
||||
var _React$useState = React.useState(0),
|
||||
forceUpdate = _React$useState[1];
|
||||
|
||||
var options = parseMutationArgs(arg1, arg2, arg3);
|
||||
var queryClient = useQueryClient();
|
||||
var obsRef = React.useRef();
|
||||
|
||||
if (!obsRef.current) {
|
||||
obsRef.current = new MutationObserver(queryClient, options);
|
||||
} else {
|
||||
obsRef.current.setOptions(options);
|
||||
}
|
||||
|
||||
var currentResult = obsRef.current.getCurrentResult();
|
||||
React.useEffect(function () {
|
||||
mountedRef.current = true;
|
||||
var unsubscribe = obsRef.current.subscribe(notifyManager.batchCalls(function () {
|
||||
if (mountedRef.current) {
|
||||
forceUpdate(function (x) {
|
||||
return x + 1;
|
||||
});
|
||||
}
|
||||
}));
|
||||
return function () {
|
||||
mountedRef.current = false;
|
||||
unsubscribe();
|
||||
};
|
||||
}, []);
|
||||
var mutate = React.useCallback(function (variables, mutateOptions) {
|
||||
obsRef.current.mutate(variables, mutateOptions).catch(noop);
|
||||
}, []);
|
||||
|
||||
if (currentResult.error && shouldThrowError(undefined, obsRef.current.options.useErrorBoundary, [currentResult.error])) {
|
||||
throw currentResult.error;
|
||||
}
|
||||
|
||||
return _extends({}, currentResult, {
|
||||
mutate: mutate,
|
||||
mutateAsync: currentResult.mutate
|
||||
});
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { notifyManager } from '../core/notifyManager';
|
||||
import { QueriesObserver } from '../core/queriesObserver';
|
||||
import { useQueryClient } from './QueryClientProvider';
|
||||
export function useQueries(queries) {
|
||||
var mountedRef = React.useRef(false);
|
||||
|
||||
var _React$useState = React.useState(0),
|
||||
forceUpdate = _React$useState[1];
|
||||
|
||||
var queryClient = useQueryClient();
|
||||
var defaultedQueries = useMemo(function () {
|
||||
return queries.map(function (options) {
|
||||
var defaultedOptions = queryClient.defaultQueryObserverOptions(options); // Make sure the results are already in fetching state before subscribing or updating options
|
||||
|
||||
defaultedOptions.optimisticResults = true;
|
||||
return defaultedOptions;
|
||||
});
|
||||
}, [queries, queryClient]);
|
||||
|
||||
var _React$useState2 = React.useState(function () {
|
||||
return new QueriesObserver(queryClient, defaultedQueries);
|
||||
}),
|
||||
observer = _React$useState2[0];
|
||||
|
||||
var result = observer.getOptimisticResult(defaultedQueries);
|
||||
React.useEffect(function () {
|
||||
mountedRef.current = true;
|
||||
var unsubscribe = observer.subscribe(notifyManager.batchCalls(function () {
|
||||
if (mountedRef.current) {
|
||||
forceUpdate(function (x) {
|
||||
return x + 1;
|
||||
});
|
||||
}
|
||||
}));
|
||||
return function () {
|
||||
mountedRef.current = false;
|
||||
unsubscribe();
|
||||
};
|
||||
}, [observer]);
|
||||
React.useEffect(function () {
|
||||
// Do not notify on updates because of changes in the options because
|
||||
// these changes should already be reflected in the optimistic result.
|
||||
observer.setQueries(defaultedQueries, {
|
||||
listeners: false
|
||||
});
|
||||
}, [defaultedQueries, observer]);
|
||||
return result;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { QueryObserver } from '../core';
|
||||
import { parseQueryArgs } from '../core/utils';
|
||||
import { useBaseQuery } from './useBaseQuery'; // HOOK
|
||||
|
||||
export function useQuery(arg1, arg2, arg3) {
|
||||
var parsedOptions = parseQueryArgs(arg1, arg2, arg3);
|
||||
return useBaseQuery(parsedOptions, QueryObserver);
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
export function shouldThrowError(suspense, _useErrorBoundary, params) {
|
||||
// Allow useErrorBoundary function to override throwing behavior on a per-error basis
|
||||
if (typeof _useErrorBoundary === 'function') {
|
||||
return _useErrorBoundary.apply(void 0, params);
|
||||
} // Allow useErrorBoundary to override suspense's throwing behavior
|
||||
|
||||
|
||||
if (typeof _useErrorBoundary === 'boolean') return _useErrorBoundary; // If suspense is enabled default to throwing errors
|
||||
|
||||
return !!suspense;
|
||||
}
|
||||
Reference in New Issue
Block a user