Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: regenerate sample apps #1772

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const listPets = async (
...options,
method: 'GET',
});

const data = await res.json();

return { status: res.status, data, headers: res.headers };
Expand Down Expand Up @@ -70,6 +71,7 @@ export const createPets = async (
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(createPetsBodyItem),
});

const data = await res.json();

return { status: res.status, data, headers: res.headers };
Expand Down Expand Up @@ -98,6 +100,7 @@ export const updatePets = async (
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(pet),
});

const data = await res.json();

return { status: res.status, data, headers: res.headers };
Expand All @@ -124,6 +127,7 @@ export const showPetById = async (
...options,
method: 'GET',
});

const data = await res.json();

return { status: res.status, data, headers: res.headers };
Expand Down
99 changes: 33 additions & 66 deletions samples/react-query/form-data-mutator/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,7 @@ export const getListPetsQueryOptions = <
TError = Error,
>(
params?: ListPetsParams,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof listPets>>,
TError,
TData
>;
},
options?: { query?: UseQueryOptions<TData, TError, TData> },
) => {
const { query: queryOptions } = options ?? {};

Expand All @@ -67,7 +61,7 @@ export const getListPetsQueryOptions = <
}) => listPets(params, signal);

return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
Awaited<ReturnType<typeof listPets>>,
TData,
TError,
TData
> & { queryKey: QueryKey };
Expand All @@ -87,13 +81,7 @@ export function useListPets<
TError = Error,
>(
params?: ListPetsParams,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof listPets>>,
TError,
TData
>;
},
options?: { query?: UseQueryOptions<TData, TError, TData> },
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getListPetsQueryOptions(params, options);

Expand Down Expand Up @@ -123,22 +111,25 @@ export const createPets = (
};

export const getCreatePetsMutationOptions = <
TData = Awaited<ReturnType<typeof createPets>>,
TError = Error,
TContext = unknown,
>(options?: {
mutation?: UseMutationOptions<
Awaited<ReturnType<typeof createPets>>,
TData,
TError,
{ data: CreatePetsBody },
TContext
>;
}): UseMutationOptions<
Awaited<ReturnType<typeof createPets>>,
TError,
{ data: CreatePetsBody },
TContext
> => {
const { mutation: mutationOptions } = options ?? {};
}) => {
const mutationKey = ['createPets'];
const { mutation: mutationOptions } = options
? options.mutation &&
'mutationKey' in options.mutation &&
options.mutation.mutationKey
? options
: { ...options, mutation: { ...options.mutation, mutationKey } }
: { mutation: { mutationKey } };

const mutationFn: MutationFunction<
Awaited<ReturnType<typeof createPets>>,
Expand All @@ -149,7 +140,12 @@ export const getCreatePetsMutationOptions = <
return createPets(data);
};

return { mutationFn, ...mutationOptions };
return { mutationFn, ...mutationOptions } as UseMutationOptions<
TData,
TError,
{ data: CreatePetsBody },
TContext
>;
};

export type CreatePetsMutationResult = NonNullable<
Expand All @@ -161,19 +157,18 @@ export type CreatePetsMutationError = Error;
/**
* @summary Create a pet
*/
export const useCreatePets = <TError = Error, TContext = unknown>(options?: {
export const useCreatePets = <
TData = Awaited<ReturnType<typeof createPets>>,
TError = Error,
TContext = unknown,
>(options?: {
mutation?: UseMutationOptions<
Awaited<ReturnType<typeof createPets>>,
TData,
TError,
{ data: CreatePetsBody },
TContext
>;
}): UseMutationResult<
Awaited<ReturnType<typeof createPets>>,
TError,
{ data: CreatePetsBody },
TContext
> => {
}): UseMutationResult<TData, TError, { data: CreatePetsBody }, TContext> => {
const mutationOptions = getCreatePetsMutationOptions(options);

return useMutation(mutationOptions);
Expand Down Expand Up @@ -205,13 +200,7 @@ export const getListPetsNestedArrayQueryOptions = <
TError = Error,
>(
params?: ListPetsNestedArrayParams,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof listPetsNestedArray>>,
TError,
TData
>;
},
options?: { query?: UseQueryOptions<TData, TError, TData> },
) => {
const { query: queryOptions } = options ?? {};

Expand All @@ -223,7 +212,7 @@ export const getListPetsNestedArrayQueryOptions = <
> = ({ signal }) => listPetsNestedArray(params, signal);

return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
Awaited<ReturnType<typeof listPetsNestedArray>>,
TData,
TError,
TData
> & { queryKey: QueryKey };
Expand All @@ -243,13 +232,7 @@ export function useListPetsNestedArray<
TError = Error,
>(
params?: ListPetsNestedArrayParams,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof listPetsNestedArray>>,
TError,
TData
>;
},
options?: { query?: UseQueryOptions<TData, TError, TData> },
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getListPetsNestedArrayQueryOptions(params, options);

Expand Down Expand Up @@ -278,13 +261,7 @@ export const getShowPetByIdQueryOptions = <
TError = Error,
>(
petId: string,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof showPetById>>,
TError,
TData
>;
},
options?: { query?: UseQueryOptions<TData, TError, TData> },
) => {
const { query: queryOptions } = options ?? {};

Expand All @@ -299,11 +276,7 @@ export const getShowPetByIdQueryOptions = <
queryFn,
enabled: !!petId,
...queryOptions,
} as UseQueryOptions<
Awaited<ReturnType<typeof showPetById>>,
TError,
TData
> & { queryKey: QueryKey };
} as UseQueryOptions<TData, TError, TData> & { queryKey: QueryKey };
};

export type ShowPetByIdQueryResult = NonNullable<
Expand All @@ -320,13 +293,7 @@ export function useShowPetById<
TError = Error,
>(
petId: string,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof showPetById>>,
TError,
TData
>;
},
options?: { query?: UseQueryOptions<TData, TError, TData> },
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getShowPetByIdQueryOptions(petId, options);

Expand Down
20 changes: 10 additions & 10 deletions samples/react-query/form-data-mutator/models/pet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ import type { PetCallingCode } from './petCallingCode';
import type { PetCountry } from './petCountry';

export interface Pet {
/**
* @minimum 0
* @maximum 30
* @exclusiveMinimum
* @exclusiveMaximum
*/
age?: number;
callingCode?: PetCallingCode;
country?: PetCountry;
email?: string;
id: number;
/**
* Name of pet
* @minLength 40
* @maxLength 0
*/
name: string;
/**
* @minimum 0
* @maximum 30
* @exclusiveMinimum
* @exclusiveMaximum
*/
age?: number;
/**
* @nullable
* @pattern ^\\d{3}-\\d{2}-\\d{4}$
*/
tag?: string | null;
email?: string;
callingCode?: PetCallingCode;
country?: PetCountry;
}
Loading
Loading