mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
72 lines
1.6 KiB
TypeScript
72 lines
1.6 KiB
TypeScript
// This file is auto-generated by @hey-api/openapi-ts
|
|
|
|
import { type Options, getApiV1Volumes } from "../sdk.gen";
|
|
import { queryOptions } from "@tanstack/react-query";
|
|
import type { GetApiV1VolumesData } from "../types.gen";
|
|
import { client as _heyApiClient } from "../client.gen";
|
|
|
|
export type QueryKey<TOptions extends Options> = [
|
|
Pick<TOptions, "baseUrl" | "body" | "headers" | "path" | "query"> & {
|
|
_id: string;
|
|
_infinite?: boolean;
|
|
tags?: ReadonlyArray<string>;
|
|
},
|
|
];
|
|
|
|
const createQueryKey = <TOptions extends Options>(
|
|
id: string,
|
|
options?: TOptions,
|
|
infinite?: boolean,
|
|
tags?: ReadonlyArray<string>,
|
|
): [QueryKey<TOptions>[0]] => {
|
|
const params: QueryKey<TOptions>[0] = {
|
|
_id: id,
|
|
baseUrl:
|
|
options?.baseUrl ||
|
|
(options?.client ?? _heyApiClient).getConfig().baseUrl,
|
|
} as QueryKey<TOptions>[0];
|
|
if (infinite) {
|
|
params._infinite = infinite;
|
|
}
|
|
if (tags) {
|
|
params.tags = tags;
|
|
}
|
|
if (options?.body) {
|
|
params.body = options.body;
|
|
}
|
|
if (options?.headers) {
|
|
params.headers = options.headers;
|
|
}
|
|
if (options?.path) {
|
|
params.path = options.path;
|
|
}
|
|
if (options?.query) {
|
|
params.query = options.query;
|
|
}
|
|
return [params];
|
|
};
|
|
|
|
export const getApiV1VolumesQueryKey = (
|
|
options?: Options<GetApiV1VolumesData>,
|
|
) => createQueryKey("getApiV1Volumes", options);
|
|
|
|
/**
|
|
* List all volumes
|
|
*/
|
|
export const getApiV1VolumesOptions = (
|
|
options?: Options<GetApiV1VolumesData>,
|
|
) => {
|
|
return queryOptions({
|
|
queryFn: async ({ queryKey, signal }) => {
|
|
const { data } = await getApiV1Volumes({
|
|
...options,
|
|
...queryKey[0],
|
|
signal,
|
|
throwOnError: true,
|
|
});
|
|
return data;
|
|
},
|
|
queryKey: getApiV1VolumesQueryKey(options),
|
|
});
|
|
};
|