mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: local volume explore file system
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
unmountVolume,
|
||||
healthCheckVolume,
|
||||
listFiles,
|
||||
browseFilesystem,
|
||||
listRepositories,
|
||||
createRepository,
|
||||
deleteRepository,
|
||||
@@ -67,6 +68,7 @@ import type {
|
||||
HealthCheckVolumeData,
|
||||
HealthCheckVolumeResponse,
|
||||
ListFilesData,
|
||||
BrowseFilesystemData,
|
||||
ListRepositoriesData,
|
||||
CreateRepositoryData,
|
||||
CreateRepositoryResponse,
|
||||
@@ -647,6 +649,27 @@ export const listFilesOptions = (options: Options<ListFilesData>) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const browseFilesystemQueryKey = (options?: Options<BrowseFilesystemData>) =>
|
||||
createQueryKey("browseFilesystem", options);
|
||||
|
||||
/**
|
||||
* Browse directories on the host filesystem
|
||||
*/
|
||||
export const browseFilesystemOptions = (options?: Options<BrowseFilesystemData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await browseFilesystem({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: browseFilesystemQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const listRepositoriesQueryKey = (options?: Options<ListRepositoriesData>) =>
|
||||
createQueryKey("listRepositories", options);
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ import type {
|
||||
HealthCheckVolumeErrors,
|
||||
ListFilesData,
|
||||
ListFilesResponses,
|
||||
BrowseFilesystemData,
|
||||
BrowseFilesystemResponses,
|
||||
ListRepositoriesData,
|
||||
ListRepositoriesResponses,
|
||||
CreateRepositoryData,
|
||||
@@ -308,6 +310,18 @@ export const listFiles = <ThrowOnError extends boolean = false>(options: Options
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Browse directories on the host filesystem
|
||||
*/
|
||||
export const browseFilesystem = <ThrowOnError extends boolean = false>(
|
||||
options?: Options<BrowseFilesystemData, ThrowOnError>,
|
||||
) => {
|
||||
return (options?.client ?? _heyApiClient).get<BrowseFilesystemResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/volumes/filesystem/browse",
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* List all repositories
|
||||
*/
|
||||
|
||||
@@ -663,6 +663,36 @@ export type ListFilesResponses = {
|
||||
|
||||
export type ListFilesResponse = ListFilesResponses[keyof ListFilesResponses];
|
||||
|
||||
export type BrowseFilesystemData = {
|
||||
body?: never;
|
||||
path?: never;
|
||||
query?: {
|
||||
/**
|
||||
* Directory path to browse (absolute path, defaults to /)
|
||||
*/
|
||||
path?: string;
|
||||
};
|
||||
url: "/api/v1/volumes/filesystem/browse";
|
||||
};
|
||||
|
||||
export type BrowseFilesystemResponses = {
|
||||
/**
|
||||
* List of directories in the specified path
|
||||
*/
|
||||
200: {
|
||||
directories: Array<{
|
||||
name: string;
|
||||
path: string;
|
||||
type: "directory" | "file";
|
||||
modifiedAt?: number;
|
||||
size?: number;
|
||||
}>;
|
||||
path: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type BrowseFilesystemResponse = BrowseFilesystemResponses[keyof BrowseFilesystemResponses];
|
||||
|
||||
export type ListRepositoriesData = {
|
||||
body?: never;
|
||||
path?: never;
|
||||
|
||||
Reference in New Issue
Block a user