@@ -17,7 +17,7 @@ import type {
1717 CallApiRequestOptionsForHooks ,
1818} from "./types/common" ;
1919import type { DefaultCallApiContext } from "./types/default-types" ;
20- import type { AnyFunction , Awaitable , Prettify , UnmaskType } from "./types/type-helpers" ;
20+ import type { AnyFunction , Awaitable , Prettify } from "./types/type-helpers" ;
2121
2222export interface Hooks < TCallApiContext extends CallApiContext = DefaultCallApiContext > {
2323 /**
@@ -176,7 +176,7 @@ export interface HookConfigOptions {
176176}
177177
178178export type RequestContext <
179- TCallApiContext extends Pick < CallApiContext , "InferredPluginOptions " | "Meta" > = DefaultCallApiContext ,
179+ TCallApiContext extends Pick < CallApiContext , "InferredExtraOptions " | "Meta" > = DefaultCallApiContext ,
180180> = {
181181 /**
182182 * Base configuration object passed to createFetchClient.
@@ -214,98 +214,92 @@ export type RequestContext<
214214} ;
215215
216216export type ValidationErrorContext <
217- TCallApiContext extends Pick < CallApiContext , "InferredPluginOptions" | "Meta" > = DefaultCallApiContext ,
218- > = UnmaskType <
219- RequestContext < TCallApiContext > & {
220- error : PossibleValidationError ;
221- response : Response | null ;
222- }
223- > ;
217+ TCallApiContext extends Pick < CallApiContext , "InferredExtraOptions" | "Meta" > = DefaultCallApiContext ,
218+ > = RequestContext < TCallApiContext > & {
219+ error : PossibleValidationError ;
220+ response : Response | null ;
221+ } ;
224222
225223export type SuccessContext <
226- TCallApiContext extends Pick < CallApiContext , "Data" | "InferredPluginOptions" | "Meta" > =
227- DefaultCallApiContext ,
228- > = UnmaskType <
229- RequestContext < TCallApiContext > & {
230- data : NoInfer < TCallApiContext [ "Data" ] > ;
231- response : Response ;
232- }
233- > ;
224+ TCallApiContext extends Pick <
225+ CallApiContext ,
226+ "Data" | "InferredExtraOptions" | "Meta"
227+ > = DefaultCallApiContext ,
228+ > = RequestContext < TCallApiContext > & {
229+ data : NoInfer < TCallApiContext [ "Data" ] > ;
230+ response : Response ;
231+ } ;
234232
235233export type ResponseContext <
236- TCallApiContext extends Pick < CallApiContext , "Data" | "ErrorData" | "InferredPluginOptions" | "Meta" > =
237- DefaultCallApiContext ,
238- > = UnmaskType <
239- RequestContext < TCallApiContext >
240- & (
241- | Prettify < CallApiResultSuccessVariant < TCallApiContext [ "Data" ] > >
242- | Prettify <
243- Extract <
244- CallApiResultErrorVariant < TCallApiContext [ "ErrorData" ] > ,
245- { error : PossibleHTTPError < TCallApiContext [ "ErrorData" ] > }
246- >
247- >
248- )
249- > ;
234+ TCallApiContext extends Pick <
235+ CallApiContext ,
236+ "Data" | "ErrorData" | "InferredExtraOptions" | "Meta"
237+ > = DefaultCallApiContext ,
238+ > = RequestContext < TCallApiContext >
239+ & (
240+ | Prettify < CallApiResultSuccessVariant < TCallApiContext [ "Data" ] > >
241+ | Prettify <
242+ Extract <
243+ CallApiResultErrorVariant < TCallApiContext [ "ErrorData" ] > ,
244+ { error : PossibleHTTPError < TCallApiContext [ "ErrorData" ] > }
245+ >
246+ >
247+ ) ;
250248
251249export type RequestErrorContext <
252- TCallApiContext extends Pick < CallApiContext , "InferredPluginOptions " | "Meta" > = DefaultCallApiContext ,
250+ TCallApiContext extends Pick < CallApiContext , "InferredExtraOptions " | "Meta" > = DefaultCallApiContext ,
253251> = RequestContext < TCallApiContext > & {
254252 error : PossibleJavaScriptError ;
255253 response : null ;
256254} ;
257255
258256export type ErrorContext <
259- TCallApiContext extends Pick < CallApiContext , "ErrorData" | "InferredPluginOptions" | "Meta" > =
260- DefaultCallApiContext ,
261- > = UnmaskType <
262- RequestContext < TCallApiContext >
263- & (
264- | {
265- error : PossibleHTTPError < TCallApiContext [ "ErrorData" ] > ;
266- response : Response ;
267- }
268- | {
269- error : PossibleJavaScriptOrValidationError ;
270- response : Response | null ;
271- }
272- )
273- > ;
257+ TCallApiContext extends Pick <
258+ CallApiContext ,
259+ "ErrorData" | "InferredExtraOptions" | "Meta"
260+ > = DefaultCallApiContext ,
261+ > = RequestContext < TCallApiContext >
262+ & (
263+ | {
264+ error : PossibleHTTPError < TCallApiContext [ "ErrorData" ] > ;
265+ response : Response ;
266+ }
267+ | {
268+ error : PossibleJavaScriptOrValidationError ;
269+ response : Response | null ;
270+ }
271+ ) ;
274272
275273export type ResponseErrorContext <
276- TCallApiContext extends Pick < CallApiContext , "ErrorData" | "InferredPluginOptions" | "Meta" > =
277- DefaultCallApiContext ,
278- > = UnmaskType <
279- Extract < ErrorContext < TCallApiContext > , { error : PossibleHTTPError < TCallApiContext [ "ErrorData" ] > } >
280- & RequestContext < TCallApiContext >
281- > ;
274+ TCallApiContext extends Pick <
275+ CallApiContext ,
276+ "ErrorData" | "InferredExtraOptions" | "Meta"
277+ > = DefaultCallApiContext ,
278+ > = Extract < ErrorContext < TCallApiContext > , { error : PossibleHTTPError < TCallApiContext [ "ErrorData" ] > } >
279+ & RequestContext < TCallApiContext > ;
282280
283281export type RetryContext <
284- TCallApiContext extends Pick < CallApiContext , "ErrorData" | "InferredPluginOptions" | "Meta" > =
285- DefaultCallApiContext ,
286- > = UnmaskType <
287- ErrorContext < TCallApiContext > & {
288- retryAttemptCount : number ;
289- }
290- > ;
282+ TCallApiContext extends Pick <
283+ CallApiContext ,
284+ "ErrorData" | "InferredExtraOptions" | "Meta"
285+ > = DefaultCallApiContext ,
286+ > = ErrorContext < TCallApiContext > & {
287+ retryAttemptCount : number ;
288+ } ;
291289
292290export type RequestStreamContext <
293- TCallApiContext extends Pick < CallApiContext , "InferredPluginOptions" | "Meta" > = DefaultCallApiContext ,
294- > = UnmaskType <
295- RequestContext < TCallApiContext > & {
296- event : StreamProgressEvent ;
297- requestInstance : Request ;
298- }
299- > ;
291+ TCallApiContext extends Pick < CallApiContext , "InferredExtraOptions" | "Meta" > = DefaultCallApiContext ,
292+ > = RequestContext < TCallApiContext > & {
293+ event : StreamProgressEvent ;
294+ requestInstance : Request ;
295+ } ;
300296
301297export type ResponseStreamContext <
302- TCallApiContext extends Pick < CallApiContext , "InferredPluginOptions" | "Meta" > = DefaultCallApiContext ,
303- > = UnmaskType <
304- RequestContext < TCallApiContext > & {
305- event : StreamProgressEvent ;
306- response : Response ;
307- }
308- > ;
298+ TCallApiContext extends Pick < CallApiContext , "InferredExtraOptions" | "Meta" > = DefaultCallApiContext ,
299+ > = RequestContext < TCallApiContext > & {
300+ event : StreamProgressEvent ;
301+ response : Response ;
302+ } ;
309303
310304type HookRegistries = Required < {
311305 [ Key in keyof Hooks ] : Set < Hooks [ Key ] > ;
0 commit comments