mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
refactor: simplify snapshot file explorer
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
deleteRepository,
|
||||
getRepository,
|
||||
listSnapshots,
|
||||
getSnapshotDetails,
|
||||
listSnapshotFiles,
|
||||
restoreSnapshot,
|
||||
listBackupSchedules,
|
||||
@@ -69,6 +70,7 @@ import type {
|
||||
DeleteRepositoryResponse,
|
||||
GetRepositoryData,
|
||||
ListSnapshotsData,
|
||||
GetSnapshotDetailsData,
|
||||
ListSnapshotFilesData,
|
||||
RestoreSnapshotData,
|
||||
RestoreSnapshotResponse,
|
||||
@@ -720,6 +722,27 @@ export const listSnapshotsOptions = (options: Options<ListSnapshotsData>) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getSnapshotDetailsQueryKey = (options: Options<GetSnapshotDetailsData>) =>
|
||||
createQueryKey("getSnapshotDetails", options);
|
||||
|
||||
/**
|
||||
* Get details of a specific snapshot
|
||||
*/
|
||||
export const getSnapshotDetailsOptions = (options: Options<GetSnapshotDetailsData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getSnapshotDetails({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getSnapshotDetailsQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const listSnapshotFilesQueryKey = (options: Options<ListSnapshotFilesData>) =>
|
||||
createQueryKey("listSnapshotFiles", options);
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ import type {
|
||||
GetRepositoryResponses,
|
||||
ListSnapshotsData,
|
||||
ListSnapshotsResponses,
|
||||
GetSnapshotDetailsData,
|
||||
GetSnapshotDetailsResponses,
|
||||
ListSnapshotFilesData,
|
||||
ListSnapshotFilesResponses,
|
||||
RestoreSnapshotData,
|
||||
@@ -352,6 +354,18 @@ export const listSnapshots = <ThrowOnError extends boolean = false>(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get details of a specific snapshot
|
||||
*/
|
||||
export const getSnapshotDetails = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetSnapshotDetailsData, ThrowOnError>,
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).get<GetSnapshotDetailsResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{name}/snapshots/{snapshotId}",
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* List files and directories in a snapshot
|
||||
*/
|
||||
|
||||
@@ -802,6 +802,31 @@ export type ListSnapshotsResponses = {
|
||||
|
||||
export type ListSnapshotsResponse = ListSnapshotsResponses[keyof ListSnapshotsResponses];
|
||||
|
||||
export type GetSnapshotDetailsData = {
|
||||
body?: never;
|
||||
path: {
|
||||
name: string;
|
||||
snapshotId: string;
|
||||
};
|
||||
query?: never;
|
||||
url: "/api/v1/repositories/{name}/snapshots/{snapshotId}";
|
||||
};
|
||||
|
||||
export type GetSnapshotDetailsResponses = {
|
||||
/**
|
||||
* Snapshot details
|
||||
*/
|
||||
200: {
|
||||
duration: number;
|
||||
paths: Array<string>;
|
||||
short_id: string;
|
||||
size: number;
|
||||
time: number;
|
||||
};
|
||||
};
|
||||
|
||||
export type GetSnapshotDetailsResponse = GetSnapshotDetailsResponses[keyof GetSnapshotDetailsResponses];
|
||||
|
||||
export type ListSnapshotFilesData = {
|
||||
body?: never;
|
||||
path: {
|
||||
|
||||
Reference in New Issue
Block a user