import type { UseMutationOptions, UseQueryOptions } from '@tanstack/preact-query'; type MandatoryQueryArgs = 'queryKey' | 'queryFn'; type MandatoryMutationArgs = 'mutationFn'; /** * useQuery params we do NOT want in our options. * is the type of the Response received, * is the type returned by the select function (defaults to ResponseType) * provide the generic to QueryOptions and nowhere else, it will be infered */ export type QueryOptions = Omit, MandatoryQueryArgs>; /** * useMutation params we do NOT want in our options. */ export type MutationOptions = Omit, MandatoryMutationArgs>; type StripSlashV1Slash = T extends `/v1/${infer Endpoint}` ? Endpoint : T; type StripGetParams = T extends `${infer Endpoint}?${string}` ? Endpoint : T; type OptionalGetParams = `?${string}` | ''; type VariablesFromCurlyBraces = T extends `${infer Head}{${string}}${infer Tail}` ? `${Head}${string}${EndpointFromPaths}${OptionalGetParams}` : T; /** * Creates a string union of all possible endpoints, by taking as generic the * paths interface which we have in openApi contract.d.ts files, with variables included * * Used to type endpoint strings accross the codebase (api calls, mocks, etc.) * It's recommended to narrow it down to one specific endpoint from the union, with Extract * Strips `/v1/` from the beginning and anything after `?` (query params) at the end * */ export type EndpointFromPaths = StripSlashV1Slash>>; export {};