fix: Fixed tests
feat: Added RClone integration feat: Implemented plugin settings feat: Updated minimal store version test: Fixed tests feat: Moved store and igdb and es-de to their own plugins
This commit is contained in:
parent
444d8c4c27
commit
c09fbd3dc8
115 changed files with 4139 additions and 1502 deletions
|
|
@ -11,6 +11,15 @@ export const getAllPluginsQuery = queryOptions({
|
|||
}
|
||||
});
|
||||
|
||||
export const getPluginDetailsQuery = (source: string) => queryOptions({
|
||||
queryKey: ['plugins', source], queryFn: async () =>
|
||||
{
|
||||
const { data, error } = await pluginsApi.plugins({ id: source }).get();
|
||||
if (error) throw error;
|
||||
return data;
|
||||
}
|
||||
});
|
||||
|
||||
export const enablePluginMutation = mutationOptions({
|
||||
mutationKey: ['plugin', 'enable'],
|
||||
mutationFn: async (vars: { id: string, enabled: boolean; }) =>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { DefaultRommStaleTime, GameListFilterType, RommLoginDataSchema } from "@/shared/constants";
|
||||
import { rommApi, settingsApi } from "../clientApi";
|
||||
import { mutationOptions, QueryFilters, queryOptions, useMutation } from "@tanstack/react-query";
|
||||
import { InvalidateQueryFilters, mutationOptions, QueryFilters, queryOptions, useMutation } from "@tanstack/react-query";
|
||||
import z from "zod";
|
||||
import { statsApiStatsGetOptions } from "@/clients/romm/@tanstack/react-query.gen";
|
||||
|
||||
|
|
@ -72,8 +72,8 @@ export const rommLoggedInQuery = queryOptions({
|
|||
return data;
|
||||
}
|
||||
});
|
||||
export const rommHostnameQuery = queryOptions({ queryKey: ['romm', 'auth', 'hostname'], queryFn: () => settingsApi.api.settings({ id: 'rommAddress' }).get().then(d => d.data?.value as string) });
|
||||
export const rommUsernameQuery = queryOptions({ queryKey: ['romm', 'auth', 'username'], queryFn: () => settingsApi.api.settings({ id: 'rommUser' }).get().then(d => d.data?.value as string) });
|
||||
export const rommHostnameQuery = queryOptions({ queryKey: ['romm', 'auth', 'hostname'], queryFn: () => settingsApi.api.settings({ source: 'local' })({ id: 'rommAddress' }).get().then(d => d.data?.value as string) });
|
||||
export const rommUsernameQuery = queryOptions({ queryKey: ['romm', 'auth', 'username'], queryFn: () => settingsApi.api.settings({ source: 'local' })({ id: 'rommUser' }).get().then(d => d.data?.value as string) });
|
||||
export const deleteGameMutation = (id: FrontEndId) => mutationOptions({
|
||||
mutationKey: ['delete', id],
|
||||
mutationFn: () => rommApi.api.romm.game({ source: id.source })({ id: id.id }).delete()
|
||||
|
|
@ -107,9 +107,9 @@ export const platformQuery = (source: string, id: string) => queryOptions({
|
|||
});
|
||||
export const installMutation = (source: string, id: string) => mutationOptions({
|
||||
mutationKey: ['install', source, id],
|
||||
mutationFn: async () =>
|
||||
mutationFn: async (init: { downloadId?: string; }) =>
|
||||
{
|
||||
const { data, error } = await rommApi.api.romm.game({ source })({ id }).install.post();
|
||||
const { data, error } = await rommApi.api.romm.game({ source })({ id }).install.post({ query: { downloadId: init.downloadId } });
|
||||
if (error) throw error;
|
||||
return data;
|
||||
}
|
||||
|
|
@ -170,4 +170,45 @@ export const fixSourceMutation = mutationOptions({
|
|||
if (error) throw error;
|
||||
return data;
|
||||
}
|
||||
});
|
||||
export const updateSourceMutation = mutationOptions({
|
||||
mutationKey: ['game', "update_source"], mutationFn: async ({ source, id }: { source: string, id: string; }) =>
|
||||
{
|
||||
const { data, error } = await rommApi.api.romm.game({ source })({ id }).update.post();
|
||||
if (error) throw error;
|
||||
return data;
|
||||
}
|
||||
});
|
||||
export const updatePlatformMutation = (id: string) => mutationOptions({
|
||||
mutationKey: ['platform', 'local', 'update', id],
|
||||
mutationFn: async () =>
|
||||
{
|
||||
const { data, error } = await rommApi.api.romm.platform.local({ id }).update.post();
|
||||
if (error) throw error;
|
||||
return data;
|
||||
}
|
||||
});
|
||||
export const deletePlatformMutation = (id: string) => mutationOptions({
|
||||
mutationKey: ['platform', 'local', 'delete', id],
|
||||
mutationFn: async () =>
|
||||
{
|
||||
const { data, error } = await rommApi.api.romm.platform.local({ id }).delete();
|
||||
if (error) throw error;
|
||||
return data;
|
||||
}
|
||||
});
|
||||
export const localPlatformFilter = (id: string) => ({
|
||||
predicate (query)
|
||||
{
|
||||
return query.queryKey.includes('platform') && ((query.queryKey.includes('local') && query.queryKey.includes(id)) || query.queryKey.includes('all'));
|
||||
},
|
||||
} satisfies InvalidateQueryFilters as InvalidateQueryFilters);
|
||||
|
||||
export const gameFiltersQuery = (filters: { source?: string; }) => queryOptions({
|
||||
queryKey: ['game', 'filters', filters], queryFn: async () =>
|
||||
{
|
||||
const { data, error } = await rommApi.api.romm.games.filters.get({ query: { source: filters.source } });
|
||||
if (error) throw error;
|
||||
return data;
|
||||
}
|
||||
});
|
||||
|
|
@ -113,7 +113,7 @@ export const setSettingMutation = (id?: string) => mutationOptions({
|
|||
mutationKey: ["setting", id],
|
||||
mutationFn: async (value: any) =>
|
||||
{
|
||||
const response = await settingsApi.api.settings({ id: id! }).post({ value });
|
||||
const response = await settingsApi.api.settings.local({ id: id! }).post({ value });
|
||||
if (response.error) throw response.error;
|
||||
return response.data;
|
||||
}
|
||||
|
|
@ -123,9 +123,58 @@ export const getSettingQuery = (id: string | undefined) => queryOptions({
|
|||
queryKey: ["setting", id],
|
||||
queryFn: async () =>
|
||||
{
|
||||
const { data: value, error } = await settingsApi.api.settings({ id: id! }).get();
|
||||
const { data: value, error } = await settingsApi.api.settings.local({ id: id! }).get();
|
||||
if (error) throw error;
|
||||
|
||||
return value.value;
|
||||
},
|
||||
});
|
||||
export const getPluginSettingsDefinitionQuery = (source: string) => queryOptions({
|
||||
queryKey: ['settings', source, 'definitions'],
|
||||
queryFn: async () =>
|
||||
{
|
||||
const { data: value, error } = await settingsApi.api.settings.definitions({ source }).get();
|
||||
if (error) throw error;
|
||||
|
||||
return value;
|
||||
}
|
||||
});
|
||||
export const getPluginSettingQuery = (source: string, id: string) => queryOptions({
|
||||
queryKey: ["setting", source, id],
|
||||
queryFn: async () =>
|
||||
{
|
||||
const { data, error } = await settingsApi.api.settings({ source })({ id }).get();
|
||||
if (error) throw error;
|
||||
|
||||
return data;
|
||||
},
|
||||
});
|
||||
export const setPluginSettingMutation = (source: string, id: string) => mutationOptions({
|
||||
mutationKey: ["setting", source, id],
|
||||
mutationFn: async (value: any) =>
|
||||
{
|
||||
const { data, error } = await settingsApi.api.settings({ source })({ id }).put({ value });
|
||||
if (error) throw error;
|
||||
|
||||
return data;
|
||||
},
|
||||
});
|
||||
export const getPluginActionsQuery = (source: string) => queryOptions({
|
||||
queryKey: ['plugin', source, 'actions'], queryFn: async () =>
|
||||
{
|
||||
const { data, error } = await settingsApi.api.settings.actions({ source }).get();
|
||||
if (error) throw error;
|
||||
|
||||
return data;
|
||||
}
|
||||
});
|
||||
export const pluginActionMutation = (source: string, id: string) => mutationOptions({
|
||||
mutationKey: ["plugin", source, "action"],
|
||||
mutationFn: async () =>
|
||||
{
|
||||
const { data, error, response } = await settingsApi.api.settings.actions({ source })({ id }).post();
|
||||
if (error) throw error;
|
||||
|
||||
return { data: data as any, response };
|
||||
},
|
||||
});
|
||||
|
|
@ -43,6 +43,7 @@ export const storeEmulatorDeleteMutation = mutationOptions({
|
|||
if (error) throw error;
|
||||
}
|
||||
});
|
||||
|
||||
export const storeGamesInfiniteQuery = (filter: GameListFilterType) => infiniteQueryOptions<{ data: FrontEndGameType[], nextPage: number; }>({
|
||||
initialPageParam: 0,
|
||||
queryKey: ['store-games', filter],
|
||||
|
|
@ -55,6 +56,7 @@ export const storeGamesInfiniteQuery = (filter: GameListFilterType) => infiniteQ
|
|||
return { data: games.games, nextPage: pageParam + 1 };
|
||||
}
|
||||
});
|
||||
|
||||
export const storeGetStatsQuery = queryOptions({
|
||||
queryKey: ['store', 'stats'], queryFn: async () =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,4 +46,14 @@ export const closeMutation = mutationOptions({
|
|||
const { error } = await systemApi.api.system.exit.post();
|
||||
if (error) throw error;
|
||||
}
|
||||
});
|
||||
export const hasUpdateQuery = queryOptions({
|
||||
queryKey: ['update'],
|
||||
queryFn: async () =>
|
||||
{
|
||||
const { data, error } = await systemApi.api.system.update.get();
|
||||
if (error) throw error;
|
||||
return data;
|
||||
},
|
||||
staleTime: 1000 * 60 * 30
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue