feat: hey-api and projects fetch

This commit is contained in:
2025-08-03 11:07:56 +04:00
parent 459487a896
commit 3e1d544b33
26 changed files with 1825 additions and 684 deletions

View File

@ -0,0 +1,63 @@
// This file is auto-generated by @hey-api/openapi-ts
import { queryOptions } from "@tanstack/react-query";
import { client as _heyApiClient } from "../client.gen";
import { getProjects, type Options } from "../sdk.gen";
import type { GetProjectsData } from "../types.gen";
export type QueryKey<TOptions extends Options> = [
Pick<TOptions, "baseURL" | "body" | "headers" | "path" | "query"> & {
_id: string;
_infinite?: boolean;
},
];
const createQueryKey = <TOptions extends Options>(
id: string,
options?: TOptions,
infinite?: boolean
): [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 (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 getProjectsQueryKey = (options?: Options<GetProjectsData>) =>
createQueryKey("getProjects", options);
/**
* Get Projects
*/
export const getProjectsOptions = (options?: Options<GetProjectsData>) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getProjects({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getProjectsQueryKey(options),
});
};