feat: align investment client with hourly sync
This commit is contained in:
@@ -15,8 +15,10 @@ import { ApiErrorCode, apiErrorCode, isApiErrorCode } from "./problem-details";
|
||||
type InvestmentResourceMeta = components["schemas"]["InvestmentResourceMetaDto"];
|
||||
|
||||
type Resource = {
|
||||
[key: string]: unknown;
|
||||
data: unknown;
|
||||
meta: InvestmentResourceMeta;
|
||||
sync?: unknown;
|
||||
};
|
||||
|
||||
type ResourcePath = {
|
||||
@@ -66,8 +68,12 @@ function invalidateResourceAccess(
|
||||
|
||||
// Keep endpoint and parameters intact. The generated queryFn accepts the
|
||||
// optional sync mode even for a cache key originally created without init.
|
||||
function observationKey<K extends ResourceQueryKey>(key: K): K {
|
||||
const [method, path, init] = key;
|
||||
function observationKey<K extends readonly unknown[]>(key: K): K {
|
||||
const [method, path, init] = key as unknown as [
|
||||
string,
|
||||
string,
|
||||
{ params?: { path?: object; query?: object } }?,
|
||||
];
|
||||
|
||||
return [method, path, {
|
||||
...init,
|
||||
@@ -76,7 +82,11 @@ function observationKey<K extends ResourceQueryKey>(key: K): K {
|
||||
}
|
||||
|
||||
// Observation changes transport mode, never the generated cache identity.
|
||||
function useResourceQuery<T extends Resource, E, K extends ResourceQueryKey>(
|
||||
function useResourceQuery<
|
||||
T extends Resource,
|
||||
E = unknown,
|
||||
K extends readonly unknown[] = ResourceQueryKey,
|
||||
>(
|
||||
options: UseQueryOptions<T, E, T, K>,
|
||||
) {
|
||||
const client = useQueryClient();
|
||||
@@ -135,11 +145,11 @@ function useResourceQuery<T extends Resource, E, K extends ResourceQueryKey>(
|
||||
queryKey: options.queryKey,
|
||||
refetch: query.refetch,
|
||||
status: query.status,
|
||||
sync: query.data?.sync,
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
invalidateResourceAccess,
|
||||
type InvestmentResourceMeta,
|
||||
useResourceQuery,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user