// This file is auto-generated by @hey-api/openapi-ts

import { type Options, projectDeleteProjectSession, projectGetProject, projectPostProject, projectGetGlobalConfigStatus, projectInitProject, projectPostGlobalConfig, projectPostLockAcquire, projectGetLockStatus, projectPatchMasterdata, projectPatchModel, projectPatchAccess, userGetUser, userPatchApiKey, sessionCreateSession, sessionPatchAccessToken, smdaGetHealth, smdaPostField, smdaPostMasterdata, healthV1HealthCheck, healthHealthCheck } from '../sdk.gen';
import { type UseMutationOptions, queryOptions, type DefaultError } from '@tanstack/react-query';
import type { ProjectDeleteProjectSessionData, ProjectDeleteProjectSessionError, ProjectDeleteProjectSessionResponse, ProjectGetProjectData, ProjectPostProjectData, ProjectPostProjectError, ProjectPostProjectResponse, ProjectGetGlobalConfigStatusData, ProjectInitProjectData, ProjectInitProjectError, ProjectInitProjectResponse, ProjectPostGlobalConfigData, ProjectPostGlobalConfigResponse, ProjectPostLockAcquireData, ProjectPostLockAcquireError, ProjectPostLockAcquireResponse, ProjectGetLockStatusData, ProjectPatchMasterdataData, ProjectPatchMasterdataError, ProjectPatchMasterdataResponse, ProjectPatchModelData, ProjectPatchModelError, ProjectPatchModelResponse, ProjectPatchAccessData, ProjectPatchAccessError, ProjectPatchAccessResponse, UserGetUserData, UserPatchApiKeyData, UserPatchApiKeyError, UserPatchApiKeyResponse, SessionCreateSessionData, SessionCreateSessionError, SessionCreateSessionResponse, SessionPatchAccessTokenData, SessionPatchAccessTokenError, SessionPatchAccessTokenResponse, SmdaGetHealthData, SmdaPostFieldData, SmdaPostFieldError, SmdaPostFieldResponse, SmdaPostMasterdataData, SmdaPostMasterdataError, SmdaPostMasterdataResponse, HealthV1HealthCheckData, HealthHealthCheckData } from '../types.gen';
import type { AxiosError } from 'axios';
import { client as _heyApiClient } from '../client.gen';

export const projectDeleteProjectSessionMutation = (options?: Partial<Options<ProjectDeleteProjectSessionData>>): UseMutationOptions<ProjectDeleteProjectSessionResponse, AxiosError<ProjectDeleteProjectSessionError>, Options<ProjectDeleteProjectSessionData>> => {
    const mutationOptions: UseMutationOptions<ProjectDeleteProjectSessionResponse, AxiosError<ProjectDeleteProjectSessionError>, Options<ProjectDeleteProjectSessionData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await projectDeleteProjectSession({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

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?.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 projectGetProjectQueryKey = (options?: Options<ProjectGetProjectData>) => createQueryKey('projectGetProject', options);

export const projectGetProjectOptions = (options?: Options<ProjectGetProjectData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await projectGetProject({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: projectGetProjectQueryKey(options)
    });
};

export const projectPostProjectQueryKey = (options: Options<ProjectPostProjectData>) => createQueryKey('projectPostProject', options);

export const projectPostProjectOptions = (options: Options<ProjectPostProjectData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await projectPostProject({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: projectPostProjectQueryKey(options)
    });
};

export const projectPostProjectMutation = (options?: Partial<Options<ProjectPostProjectData>>): UseMutationOptions<ProjectPostProjectResponse, AxiosError<ProjectPostProjectError>, Options<ProjectPostProjectData>> => {
    const mutationOptions: UseMutationOptions<ProjectPostProjectResponse, AxiosError<ProjectPostProjectError>, Options<ProjectPostProjectData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await projectPostProject({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const projectGetGlobalConfigStatusQueryKey = (options?: Options<ProjectGetGlobalConfigStatusData>) => createQueryKey('projectGetGlobalConfigStatus', options);

export const projectGetGlobalConfigStatusOptions = (options?: Options<ProjectGetGlobalConfigStatusData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await projectGetGlobalConfigStatus({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: projectGetGlobalConfigStatusQueryKey(options)
    });
};

export const projectInitProjectQueryKey = (options: Options<ProjectInitProjectData>) => createQueryKey('projectInitProject', options);

export const projectInitProjectOptions = (options: Options<ProjectInitProjectData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await projectInitProject({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: projectInitProjectQueryKey(options)
    });
};

export const projectInitProjectMutation = (options?: Partial<Options<ProjectInitProjectData>>): UseMutationOptions<ProjectInitProjectResponse, AxiosError<ProjectInitProjectError>, Options<ProjectInitProjectData>> => {
    const mutationOptions: UseMutationOptions<ProjectInitProjectResponse, AxiosError<ProjectInitProjectError>, Options<ProjectInitProjectData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await projectInitProject({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const projectPostGlobalConfigQueryKey = (options?: Options<ProjectPostGlobalConfigData>) => createQueryKey('projectPostGlobalConfig', options);

export const projectPostGlobalConfigOptions = (options?: Options<ProjectPostGlobalConfigData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await projectPostGlobalConfig({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: projectPostGlobalConfigQueryKey(options)
    });
};

export const projectPostGlobalConfigMutation = (options?: Partial<Options<ProjectPostGlobalConfigData>>): UseMutationOptions<ProjectPostGlobalConfigResponse, AxiosError<DefaultError>, Options<ProjectPostGlobalConfigData>> => {
    const mutationOptions: UseMutationOptions<ProjectPostGlobalConfigResponse, AxiosError<DefaultError>, Options<ProjectPostGlobalConfigData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await projectPostGlobalConfig({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const projectPostLockAcquireQueryKey = (options?: Options<ProjectPostLockAcquireData>) => createQueryKey('projectPostLockAcquire', options);

export const projectPostLockAcquireOptions = (options?: Options<ProjectPostLockAcquireData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await projectPostLockAcquire({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: projectPostLockAcquireQueryKey(options)
    });
};

export const projectPostLockAcquireMutation = (options?: Partial<Options<ProjectPostLockAcquireData>>): UseMutationOptions<ProjectPostLockAcquireResponse, AxiosError<ProjectPostLockAcquireError>, Options<ProjectPostLockAcquireData>> => {
    const mutationOptions: UseMutationOptions<ProjectPostLockAcquireResponse, AxiosError<ProjectPostLockAcquireError>, Options<ProjectPostLockAcquireData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await projectPostLockAcquire({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const projectGetLockStatusQueryKey = (options?: Options<ProjectGetLockStatusData>) => createQueryKey('projectGetLockStatus', options);

export const projectGetLockStatusOptions = (options?: Options<ProjectGetLockStatusData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await projectGetLockStatus({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: projectGetLockStatusQueryKey(options)
    });
};

export const projectPatchMasterdataMutation = (options?: Partial<Options<ProjectPatchMasterdataData>>): UseMutationOptions<ProjectPatchMasterdataResponse, AxiosError<ProjectPatchMasterdataError>, Options<ProjectPatchMasterdataData>> => {
    const mutationOptions: UseMutationOptions<ProjectPatchMasterdataResponse, AxiosError<ProjectPatchMasterdataError>, Options<ProjectPatchMasterdataData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await projectPatchMasterdata({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const projectPatchModelMutation = (options?: Partial<Options<ProjectPatchModelData>>): UseMutationOptions<ProjectPatchModelResponse, AxiosError<ProjectPatchModelError>, Options<ProjectPatchModelData>> => {
    const mutationOptions: UseMutationOptions<ProjectPatchModelResponse, AxiosError<ProjectPatchModelError>, Options<ProjectPatchModelData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await projectPatchModel({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const projectPatchAccessMutation = (options?: Partial<Options<ProjectPatchAccessData>>): UseMutationOptions<ProjectPatchAccessResponse, AxiosError<ProjectPatchAccessError>, Options<ProjectPatchAccessData>> => {
    const mutationOptions: UseMutationOptions<ProjectPatchAccessResponse, AxiosError<ProjectPatchAccessError>, Options<ProjectPatchAccessData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await projectPatchAccess({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const userGetUserQueryKey = (options?: Options<UserGetUserData>) => createQueryKey('userGetUser', options);

export const userGetUserOptions = (options?: Options<UserGetUserData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await userGetUser({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: userGetUserQueryKey(options)
    });
};

export const userPatchApiKeyMutation = (options?: Partial<Options<UserPatchApiKeyData>>): UseMutationOptions<UserPatchApiKeyResponse, AxiosError<UserPatchApiKeyError>, Options<UserPatchApiKeyData>> => {
    const mutationOptions: UseMutationOptions<UserPatchApiKeyResponse, AxiosError<UserPatchApiKeyError>, Options<UserPatchApiKeyData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await userPatchApiKey({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const sessionCreateSessionQueryKey = (options?: Options<SessionCreateSessionData>) => createQueryKey('sessionCreateSession', options);

export const sessionCreateSessionOptions = (options?: Options<SessionCreateSessionData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await sessionCreateSession({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: sessionCreateSessionQueryKey(options)
    });
};

export const sessionCreateSessionMutation = (options?: Partial<Options<SessionCreateSessionData>>): UseMutationOptions<SessionCreateSessionResponse, AxiosError<SessionCreateSessionError>, Options<SessionCreateSessionData>> => {
    const mutationOptions: UseMutationOptions<SessionCreateSessionResponse, AxiosError<SessionCreateSessionError>, Options<SessionCreateSessionData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await sessionCreateSession({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const sessionPatchAccessTokenMutation = (options?: Partial<Options<SessionPatchAccessTokenData>>): UseMutationOptions<SessionPatchAccessTokenResponse, AxiosError<SessionPatchAccessTokenError>, Options<SessionPatchAccessTokenData>> => {
    const mutationOptions: UseMutationOptions<SessionPatchAccessTokenResponse, AxiosError<SessionPatchAccessTokenError>, Options<SessionPatchAccessTokenData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await sessionPatchAccessToken({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const smdaGetHealthQueryKey = (options?: Options<SmdaGetHealthData>) => createQueryKey('smdaGetHealth', options);

export const smdaGetHealthOptions = (options?: Options<SmdaGetHealthData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await smdaGetHealth({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: smdaGetHealthQueryKey(options)
    });
};

export const smdaPostFieldQueryKey = (options: Options<SmdaPostFieldData>) => createQueryKey('smdaPostField', options);

export const smdaPostFieldOptions = (options: Options<SmdaPostFieldData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await smdaPostField({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: smdaPostFieldQueryKey(options)
    });
};

export const smdaPostFieldMutation = (options?: Partial<Options<SmdaPostFieldData>>): UseMutationOptions<SmdaPostFieldResponse, AxiosError<SmdaPostFieldError>, Options<SmdaPostFieldData>> => {
    const mutationOptions: UseMutationOptions<SmdaPostFieldResponse, AxiosError<SmdaPostFieldError>, Options<SmdaPostFieldData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await smdaPostField({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const smdaPostMasterdataQueryKey = (options: Options<SmdaPostMasterdataData>) => createQueryKey('smdaPostMasterdata', options);

export const smdaPostMasterdataOptions = (options: Options<SmdaPostMasterdataData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await smdaPostMasterdata({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: smdaPostMasterdataQueryKey(options)
    });
};

export const smdaPostMasterdataMutation = (options?: Partial<Options<SmdaPostMasterdataData>>): UseMutationOptions<SmdaPostMasterdataResponse, AxiosError<SmdaPostMasterdataError>, Options<SmdaPostMasterdataData>> => {
    const mutationOptions: UseMutationOptions<SmdaPostMasterdataResponse, AxiosError<SmdaPostMasterdataError>, Options<SmdaPostMasterdataData>> = {
        mutationFn: async (localOptions) => {
            const { data } = await smdaPostMasterdata({
                ...options,
                ...localOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const healthV1HealthCheckQueryKey = (options?: Options<HealthV1HealthCheckData>) => createQueryKey('healthV1HealthCheck', options);

export const healthV1HealthCheckOptions = (options?: Options<HealthV1HealthCheckData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await healthV1HealthCheck({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: healthV1HealthCheckQueryKey(options)
    });
};

export const healthHealthCheckQueryKey = (options?: Options<HealthHealthCheckData>) => createQueryKey('healthHealthCheck', options);

export const healthHealthCheckOptions = (options?: Options<HealthHealthCheckData>) => {
    return queryOptions({
        queryFn: async ({ queryKey, signal }) => {
            const { data } = await healthHealthCheck({
                ...options,
                ...queryKey[0],
                signal,
                throwOnError: true
            });
            return data;
        },
        queryKey: healthHealthCheckQueryKey(options)
    });
};