@@ -14,7 +14,8 @@ import {
1414 ExtractResponse ,
1515} from "types" ;
1616import { Command } from "command" ;
17- import { ClientResponseType , ClientQueryParamsType } from "client" ;
17+ import { ClientResponseType , ClientQueryParamsType , FetchProgressType } from "client" ;
18+ import { CommandEventDetails , CommandResponseDetails } from "managers" ;
1819
1920// Progress
2021export type ClientProgressEvent = { total : number ; loaded : number } ;
@@ -233,36 +234,35 @@ export type CommandQueueOptions = {
233234 dispatcherType ?: "auto" | "fetch" | "submit" ;
234235} ;
235236
236- export type FetchType < Command extends CommandInstance , AdditionalOptions = unknown > = FetchQueryParamsType <
237+ export type FetchType < Command extends CommandInstance > = FetchQueryParamsType <
237238 ExtractQueryParams < Command > ,
238239 ExtractHasQueryParams < Command >
239240> &
240241 FetchParamsType < ExtractEndpoint < Command > , ExtractHasParams < Command > > &
241242 FetchRequestDataType < ExtractRequestData < Command > , ExtractHasData < Command > > &
242- FetchOptionsType < ExtractClientOptions < Command > > &
243- AdditionalOptions ;
243+ Omit < FetchOptionsType < ExtractClientOptions < Command > > , "params" | "data" > &
244+ FetchSendActionsType < Command > &
245+ CommandQueueOptions ;
244246
245- export type FetchMethodType < Command extends CommandInstance , AdditionalOptions = unknown > = FetchType <
246- Command ,
247- AdditionalOptions
248- > [ "data" ] extends any
249- ? (
250- options ?: FetchType < Command , AdditionalOptions > ,
251- onInit ?: ( requestId : string , command : Command ) => void ,
252- ) => Promise < ClientResponseType < ExtractResponse < Command > , ExtractError < Command > > >
253- : FetchType < Command , AdditionalOptions > [ "data" ] extends NegativeTypes
254- ? FetchType < Command , AdditionalOptions > [ "params" ] extends NegativeTypes
255- ? (
256- options ?: FetchType < Command , AdditionalOptions > ,
257- onInit ?: ( requestId : string , command : Command ) => void ,
258- ) => Promise < ClientResponseType < ExtractResponse < Command > , ExtractError < Command > > >
259- : (
260- options : FetchType < Command , AdditionalOptions > ,
261- onInit ?: ( requestId : string , command : Command ) => void ,
262- ) => Promise < ClientResponseType < ExtractResponse < Command > , ExtractError < Command > > >
263- : (
264- options : FetchType < Command , ExtractHasQueryParams < Command > > ,
265- onInit ?: ( requestId : string , command : Command ) => void ,
266- ) => Promise < ClientResponseType < ExtractResponse < Command > , ExtractError < Command > > > ;
247+ export type FetchSendActionsType < Command extends CommandInstance > = {
248+ onSettle ?: ( requestId : string , command : Command ) => void ;
249+ onRequestStart ?: ( details : CommandEventDetails < Command > ) => void ;
250+ onResponseStart ?: ( details : CommandEventDetails < Command > ) => void ;
251+ onUploadProgress ?: ( values : FetchProgressType , details : CommandEventDetails < Command > ) => void ;
252+ onDownloadProgress ?: ( values : FetchProgressType , details : CommandEventDetails < Command > ) => void ;
253+ onResponse ?: (
254+ response : ClientResponseType < ExtractResponse < Command > , ExtractError < Command > > ,
255+ details : CommandResponseDetails ,
256+ ) => void ;
257+ onRemove ?: ( details : CommandEventDetails < Command > ) => void ;
258+ } ;
259+
260+ export type FetchMethodType < Command extends CommandInstance > = FetchType < Command > [ "data" ] extends any
261+ ? ( options ?: FetchType < Command > ) => Promise < ClientResponseType < ExtractResponse < Command > , ExtractError < Command > > >
262+ : FetchType < Command > [ "data" ] extends NegativeTypes
263+ ? FetchType < Command > [ "params" ] extends NegativeTypes
264+ ? ( options ?: FetchType < Command > ) => Promise < ClientResponseType < ExtractResponse < Command > , ExtractError < Command > > >
265+ : ( options : FetchType < Command > ) => Promise < ClientResponseType < ExtractResponse < Command > , ExtractError < Command > > >
266+ : ( options : FetchType < Command > ) => Promise < ClientResponseType < ExtractResponse < Command > , ExtractError < Command > > > ;
267267
268268export type CommandInstance = Command < any , any , any , any , any , any , any , any , any , any , any > ;
0 commit comments