// This file is auto-generated by @hey-api/openapi-ts import { type _JSONValue, defineQueryOptions, type UseMutationOptions } from '@pinia/colada' import { serializeQueryKeyValue } from '../client' import { client } from '../client.gen' import { addPet, createUser, createUsersWithListInput, deleteOrder, deletePet, deleteUser, findPetsByStatus, findPetsByTags, getInventory, getOrderById, getPetById, getUserByName, loginUser, logoutUser, type Options, placeOrder, updatePet, updatePetWithForm, updateUser, uploadFile } from '../sdk.gen' import type { AddPetData, AddPetResponse, CreateUserData, CreateUserResponse, CreateUsersWithListInputData, CreateUsersWithListInputResponse, DeleteOrderData, DeletePetData, DeleteUserData, FindPetsByStatusData, FindPetsByTagsData, GetInventoryData, GetOrderByIdData, GetPetByIdData, GetUserByNameData, LoginUserData, LogoutUserData, PlaceOrderData, PlaceOrderResponse, UpdatePetData, UpdatePetResponse, UpdatePetWithFormData, UpdatePetWithFormResponse, UpdateUserData, UploadFileData, UploadFileResponse } from '../types.gen' /** * Add a new pet to the store. * * Add a new pet to the store. */ export const addPetMutation = ( options?: Partial> ): UseMutationOptions, Error> => ({ mutation: async (vars) => { const { data } = await addPet({ ...options, ...vars, throwOnError: true }) return data } }) /** * Update an existing pet. * * Update an existing pet by Id. */ export const updatePetMutation = ( options?: Partial> ): UseMutationOptions, Error> => ({ mutation: async (vars) => { const { data } = await updatePet({ ...options, ...vars, throwOnError: true }) return data } }) export type QueryKey = [ Pick & { _id: string baseUrl?: _JSONValue body?: _JSONValue query?: _JSONValue tags?: _JSONValue } ] const createQueryKey = ( id: string, options?: TOptions, tags?: ReadonlyArray ): [QueryKey[0]] => { const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0] if (tags) { params.tags = tags as unknown as _JSONValue } if (options?.body !== undefined) { const normalizedBody = serializeQueryKeyValue(options.body) if (normalizedBody !== undefined) { params.body = normalizedBody } } if (options?.path) { params.path = options.path } if (options?.query !== undefined) { const normalizedQuery = serializeQueryKeyValue(options.query) if (normalizedQuery !== undefined) { params.query = normalizedQuery } } return [params] } /** * Finds Pets by status. * * Multiple status values can be provided with comma separated strings. */ export const findPetsByStatusQuery = defineQueryOptions( (options: Options) => ({ key: createQueryKey('findPetsByStatus', options), query: async (context) => { const { data } = await findPetsByStatus({ ...options, ...context, throwOnError: true }) return data } }) ) /** * Finds Pets by tags. * * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. */ export const findPetsByTagsQuery = defineQueryOptions((options: Options) => ({ key: createQueryKey('findPetsByTags', options), query: async (context) => { const { data } = await findPetsByTags({ ...options, ...context, throwOnError: true }) return data } })) /** * Deletes a pet. * * Delete a pet. */ export const deletePetMutation = ( options?: Partial> ): UseMutationOptions, Error> => ({ mutation: async (vars) => { const { data } = await deletePet({ ...options, ...vars, throwOnError: true }) return data } }) /** * Find pet by ID. * * Returns a single pet. */ export const getPetByIdQuery = defineQueryOptions((options: Options) => ({ key: createQueryKey('getPetById', options), query: async (context) => { const { data } = await getPetById({ ...options, ...context, throwOnError: true }) return data } })) /** * Updates a pet in the store with form data. * * Updates a pet resource based on the form data. */ export const updatePetWithFormMutation = ( options?: Partial> ): UseMutationOptions, Error> => ({ mutation: async (vars) => { const { data } = await updatePetWithForm({ ...options, ...vars, throwOnError: true }) return data } }) /** * Uploads an image. * * Upload image of the pet. */ export const uploadFileMutation = ( options?: Partial> ): UseMutationOptions, Error> => ({ mutation: async (vars) => { const { data } = await uploadFile({ ...options, ...vars, throwOnError: true }) return data } }) /** * Returns pet inventories by status. * * Returns a map of status codes to quantities. */ export const getInventoryQuery = defineQueryOptions((options?: Options) => ({ key: createQueryKey('getInventory', options), query: async (context) => { const { data } = await getInventory({ ...options, ...context, throwOnError: true }) return data } })) /** * Place an order for a pet. * * Place a new order in the store. */ export const placeOrderMutation = ( options?: Partial> ): UseMutationOptions, Error> => ({ mutation: async (vars) => { const { data } = await placeOrder({ ...options, ...vars, throwOnError: true }) return data } }) /** * Delete purchase order by identifier. * * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors. */ export const deleteOrderMutation = ( options?: Partial> ): UseMutationOptions, Error> => ({ mutation: async (vars) => { const { data } = await deleteOrder({ ...options, ...vars, throwOnError: true }) return data } }) /** * Find purchase order by ID. * * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. */ export const getOrderByIdQuery = defineQueryOptions((options: Options) => ({ key: createQueryKey('getOrderById', options), query: async (context) => { const { data } = await getOrderById({ ...options, ...context, throwOnError: true }) return data } })) /** * Create user. * * This can only be done by the logged in user. */ export const createUserMutation = ( options?: Partial> ): UseMutationOptions, Error> => ({ mutation: async (vars) => { const { data } = await createUser({ ...options, ...vars, throwOnError: true }) return data } }) /** * Creates list of users with given input array. * * Creates list of users with given input array. */ export const createUsersWithListInputMutation = ( options?: Partial> ): UseMutationOptions< CreateUsersWithListInputResponse, Options, Error > => ({ mutation: async (vars) => { const { data } = await createUsersWithListInput({ ...options, ...vars, throwOnError: true }) return data } }) /** * Logs user into the system. * * Log into the system. */ export const loginUserQuery = defineQueryOptions((options?: Options) => ({ key: createQueryKey('loginUser', options), query: async (context) => { const { data } = await loginUser({ ...options, ...context, throwOnError: true }) return data } })) /** * Logs out current logged in user session. * * Log user out of the system. */ export const logoutUserQuery = defineQueryOptions((options?: Options) => ({ key: createQueryKey('logoutUser', options), query: async (context) => { const { data } = await logoutUser({ ...options, ...context, throwOnError: true }) return data } })) /** * Delete user resource. * * This can only be done by the logged in user. */ export const deleteUserMutation = ( options?: Partial> ): UseMutationOptions, Error> => ({ mutation: async (vars) => { const { data } = await deleteUser({ ...options, ...vars, throwOnError: true }) return data } }) /** * Get user by user name. * * Get user detail based on username. */ export const getUserByNameQuery = defineQueryOptions((options: Options) => ({ key: createQueryKey('getUserByName', options), query: async (context) => { const { data } = await getUserByName({ ...options, ...context, throwOnError: true }) return data } })) /** * Update user resource. * * This can only be done by the logged in user. */ export const updateUserMutation = ( options?: Partial> ): UseMutationOptions, Error> => ({ mutation: async (vars) => { const { data } = await updateUser({ ...options, ...vars, throwOnError: true }) return data } })