// This file is auto-generated by @hey-api/openapi-ts import { type DefaultError, type MutationOptions, queryOptions, } from '@tanstack/angular-query-experimental'; 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, FindPetsByStatusResponse, FindPetsByTagsData, FindPetsByTagsResponse, GetInventoryData, GetInventoryResponse, GetOrderByIdData, GetOrderByIdResponse, GetPetByIdData, GetPetByIdResponse, GetUserByNameData, GetUserByNameResponse, LoginUserData, LoginUserResponse, 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>, ): MutationOptions> => { const mutationOptions: MutationOptions< AddPetResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await addPet({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Update an existing pet. * * Update an existing pet by Id. */ export const updatePetMutation = ( options?: Partial>, ): MutationOptions> => { const mutationOptions: MutationOptions< UpdatePetResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await updatePet({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export type QueryKey = [ Pick & { _id: string; _infinite?: boolean; tags?: ReadonlyArray; }, ]; const createQueryKey = ( id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray, ): [QueryKey[0]] => { const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl, } as QueryKey[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 findPetsByStatusQueryKey = ( options: Options, ) => createQueryKey('findPetsByStatus', options); /** * Finds Pets by status. * * Multiple status values can be provided with comma separated strings. */ export const findPetsByStatusOptions = ( options: Options, ) => queryOptions< FindPetsByStatusResponse, DefaultError, FindPetsByStatusResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await findPetsByStatus({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: findPetsByStatusQueryKey(options), }); export const findPetsByTagsQueryKey = (options: Options) => createQueryKey('findPetsByTags', options); /** * Finds Pets by tags. * * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. */ export const findPetsByTagsOptions = (options: Options) => queryOptions< FindPetsByTagsResponse, DefaultError, FindPetsByTagsResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await findPetsByTags({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: findPetsByTagsQueryKey(options), }); /** * Deletes a pet. * * Delete a pet. */ export const deletePetMutation = ( options?: Partial>, ): MutationOptions> => { const mutationOptions: MutationOptions< unknown, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await deletePet({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getPetByIdQueryKey = (options: Options) => createQueryKey('getPetById', options); /** * Find pet by ID. * * Returns a single pet. */ export const getPetByIdOptions = (options: Options) => queryOptions< GetPetByIdResponse, DefaultError, GetPetByIdResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getPetById({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getPetByIdQueryKey(options), }); /** * Updates a pet in the store with form data. * * Updates a pet resource based on the form data. */ export const updatePetWithFormMutation = ( options?: Partial>, ): MutationOptions< UpdatePetWithFormResponse, DefaultError, Options > => { const mutationOptions: MutationOptions< UpdatePetWithFormResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await updatePetWithForm({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Uploads an image. * * Upload image of the pet. */ export const uploadFileMutation = ( options?: Partial>, ): MutationOptions< UploadFileResponse, DefaultError, Options > => { const mutationOptions: MutationOptions< UploadFileResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await uploadFile({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getInventoryQueryKey = (options?: Options) => createQueryKey('getInventory', options); /** * Returns pet inventories by status. * * Returns a map of status codes to quantities. */ export const getInventoryOptions = (options?: Options) => queryOptions< GetInventoryResponse, DefaultError, GetInventoryResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getInventory({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getInventoryQueryKey(options), }); /** * Place an order for a pet. * * Place a new order in the store. */ export const placeOrderMutation = ( options?: Partial>, ): MutationOptions< PlaceOrderResponse, DefaultError, Options > => { const mutationOptions: MutationOptions< PlaceOrderResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await placeOrder({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * 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>, ): MutationOptions> => { const mutationOptions: MutationOptions< unknown, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await deleteOrder({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getOrderByIdQueryKey = (options: Options) => createQueryKey('getOrderById', options); /** * Find purchase order by ID. * * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. */ export const getOrderByIdOptions = (options: Options) => queryOptions< GetOrderByIdResponse, DefaultError, GetOrderByIdResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getOrderById({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getOrderByIdQueryKey(options), }); /** * Create user. * * This can only be done by the logged in user. */ export const createUserMutation = ( options?: Partial>, ): MutationOptions< CreateUserResponse, DefaultError, Options > => { const mutationOptions: MutationOptions< CreateUserResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await createUser({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Creates list of users with given input array. * * Creates list of users with given input array. */ export const createUsersWithListInputMutation = ( options?: Partial>, ): MutationOptions< CreateUsersWithListInputResponse, DefaultError, Options > => { const mutationOptions: MutationOptions< CreateUsersWithListInputResponse, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await createUsersWithListInput({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const loginUserQueryKey = (options?: Options) => createQueryKey('loginUser', options); /** * Logs user into the system. * * Log into the system. */ export const loginUserOptions = (options?: Options) => queryOptions< LoginUserResponse, DefaultError, LoginUserResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await loginUser({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: loginUserQueryKey(options), }); export const logoutUserQueryKey = (options?: Options) => createQueryKey('logoutUser', options); /** * Logs out current logged in user session. * * Log user out of the system. */ export const logoutUserOptions = (options?: Options) => queryOptions< unknown, DefaultError, unknown, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await logoutUser({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: logoutUserQueryKey(options), }); /** * Delete user resource. * * This can only be done by the logged in user. */ export const deleteUserMutation = ( options?: Partial>, ): MutationOptions> => { const mutationOptions: MutationOptions< unknown, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await deleteUser({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getUserByNameQueryKey = (options: Options) => createQueryKey('getUserByName', options); /** * Get user by user name. * * Get user detail based on username. */ export const getUserByNameOptions = (options: Options) => queryOptions< GetUserByNameResponse, DefaultError, GetUserByNameResponse, ReturnType >({ queryFn: async ({ queryKey, signal }) => { const { data } = await getUserByName({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getUserByNameQueryKey(options), }); /** * Update user resource. * * This can only be done by the logged in user. */ export const updateUserMutation = ( options?: Partial>, ): MutationOptions> => { const mutationOptions: MutationOptions< unknown, DefaultError, Options > = { mutationFn: async (fnOptions) => { const { data } = await updateUser({ ...options, ...fnOptions, throwOnError: true, }); return data; }, }; return mutationOptions; };