mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
refactor: switch from go to bun
This commit is contained in:
71
apps/client/app/api-client/@tanstack/react-query.gen.ts
Normal file
71
apps/client/app/api-client/@tanstack/react-query.gen.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
// 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),
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user