@hyper-fetch/core 2.1.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/adapter/adapter.bindings.d.ts +25 -0
- package/dist/adapter/adapter.browser.d.ts +2 -0
- package/dist/{client/fetch.client.constants.d.ts → adapter/adapter.constants.d.ts} +0 -0
- package/dist/adapter/adapter.d.ts +2 -0
- package/dist/adapter/adapter.server.d.ts +2 -0
- package/dist/adapter/adapter.types.d.ts +57 -0
- package/dist/{client/fetch.client.utils.d.ts → adapter/adapter.utils.d.ts} +3 -3
- package/dist/adapter/index.d.ts +7 -0
- package/dist/cache/cache.d.ts +9 -9
- package/dist/cache/cache.types.d.ts +4 -4
- package/dist/cache/cache.utils.d.ts +3 -3
- package/dist/{builder/builder.constants.d.ts → client/client.constants.d.ts} +0 -0
- package/dist/client/client.d.ts +142 -0
- package/dist/client/client.types.d.ts +41 -0
- package/dist/client/client.utils.d.ts +10 -0
- package/dist/client/index.d.ts +4 -6
- package/dist/dispatcher/dispatcher.d.ts +23 -23
- package/dist/dispatcher/dispatcher.events.d.ts +8 -8
- package/dist/dispatcher/dispatcher.types.d.ts +10 -10
- package/dist/dispatcher/dispatcher.utils.d.ts +5 -5
- package/dist/effect/index.d.ts +2 -2
- package/dist/effect/request.effect.d.ts +14 -0
- package/dist/effect/request.effect.types.d.ts +32 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +4 -4
- package/dist/managers/index.d.ts +1 -1
- package/dist/managers/logger/logger.manager.d.ts +5 -5
- package/dist/managers/logger/logger.manager.types.d.ts +7 -7
- package/dist/managers/request/index.d.ts +4 -0
- package/dist/managers/request/request.manager.d.ts +43 -0
- package/dist/managers/request/request.manager.events.d.ts +36 -0
- package/dist/managers/{command/command.manager.types.d.ts → request/request.manager.types.d.ts} +6 -6
- package/dist/managers/{command/command.manager.utils.d.ts → request/request.manager.utils.d.ts} +0 -0
- package/dist/request/index.d.ts +3 -0
- package/dist/request/request.d.ts +98 -0
- package/dist/request/request.types.d.ts +202 -0
- package/dist/request/request.utils.d.ts +22 -0
- package/dist/types/fetch.types.d.ts +16 -16
- package/package.json +1 -1
- package/src/{client/fetch.client.bindings.ts → adapter/adapter.bindings.ts} +58 -58
- package/src/{client/fetch.client.browser.ts → adapter/adapter.browser.ts} +6 -6
- package/src/{client/fetch.client.constants.ts → adapter/adapter.constants.ts} +0 -0
- package/src/{client/fetch.client.server.ts → adapter/adapter.server.ts} +22 -18
- package/src/adapter/adapter.ts +8 -0
- package/src/adapter/adapter.types.ts +79 -0
- package/src/{client/fetch.client.utils.ts → adapter/adapter.utils.ts} +3 -3
- package/src/adapter/index.ts +7 -0
- package/src/cache/cache.ts +19 -19
- package/src/cache/cache.types.ts +4 -4
- package/src/cache/cache.utils.ts +6 -6
- package/src/{builder/builder.constants.ts → client/client.constants.ts} +0 -0
- package/src/client/client.ts +310 -0
- package/src/client/client.types.ts +52 -0
- package/src/{builder/builder.utils.ts → client/client.utils.ts} +34 -31
- package/src/client/index.ts +4 -6
- package/src/dispatcher/dispatcher.events.ts +11 -11
- package/src/dispatcher/dispatcher.ts +68 -68
- package/src/dispatcher/dispatcher.types.ts +10 -10
- package/src/dispatcher/dispatcher.utils.ts +7 -7
- package/src/effect/index.ts +2 -2
- package/src/effect/request.effect.ts +28 -0
- package/src/effect/request.effect.types.ts +35 -0
- package/src/index.ts +4 -4
- package/src/managers/index.ts +1 -1
- package/src/managers/logger/logger.manager.ts +8 -8
- package/src/managers/logger/logger.manager.types.ts +7 -7
- package/src/managers/request/index.ts +4 -0
- package/src/managers/{command/command.manager.events.ts → request/request.manager.events.ts} +47 -51
- package/src/managers/{command/command.manager.ts → request/request.manager.ts} +5 -5
- package/src/managers/request/request.manager.types.ts +25 -0
- package/src/managers/{command/command.manager.utils.ts → request/request.manager.utils.ts} +0 -0
- package/src/request/index.ts +3 -0
- package/src/{command/command.ts → request/request.ts} +188 -194
- package/src/request/request.types.ts +282 -0
- package/src/{command/command.utils.ts → request/request.utils.ts} +56 -53
- package/src/types/fetch.types.ts +18 -18
- package/dist/builder/builder.d.ts +0 -141
- package/dist/builder/builder.types.d.ts +0 -41
- package/dist/builder/builder.utils.d.ts +0 -10
- package/dist/builder/index.d.ts +0 -4
- package/dist/client/fetch.client.bindings.d.ts +0 -25
- package/dist/client/fetch.client.browser.d.ts +0 -2
- package/dist/client/fetch.client.d.ts +0 -2
- package/dist/client/fetch.client.server.d.ts +0 -2
- package/dist/client/fetch.client.types.d.ts +0 -57
- package/dist/command/command.d.ts +0 -98
- package/dist/command/command.types.d.ts +0 -202
- package/dist/command/command.utils.d.ts +0 -22
- package/dist/command/index.d.ts +0 -3
- package/dist/effect/fetch.effect.d.ts +0 -14
- package/dist/effect/fetch.effect.types.d.ts +0 -32
- package/dist/managers/command/command.manager.d.ts +0 -43
- package/dist/managers/command/command.manager.events.d.ts +0 -36
- package/dist/managers/command/index.d.ts +0 -4
- package/src/builder/builder.ts +0 -308
- package/src/builder/builder.types.ts +0 -53
- package/src/builder/index.ts +0 -4
- package/src/client/fetch.client.ts +0 -9
- package/src/client/fetch.client.types.ts +0 -83
- package/src/command/command.types.ts +0 -273
- package/src/command/index.ts +0 -3
- package/src/effect/fetch.effect.ts +0 -28
- package/src/effect/fetch.effect.types.ts +0 -35
- package/src/managers/command/command.manager.types.ts +0 -25
- package/src/managers/command/index.ts +0 -4
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NullableKeys,
|
|
3
|
-
NegativeTypes,
|
|
4
|
-
ExtractParams,
|
|
5
|
-
ExtractRequestData,
|
|
6
|
-
HttpMethodsType,
|
|
7
|
-
ExtractQueryParams,
|
|
8
|
-
ExtractClientOptions,
|
|
9
|
-
ExtractEndpoint,
|
|
10
|
-
ExtractHasData,
|
|
11
|
-
ExtractHasParams,
|
|
12
|
-
ExtractHasQueryParams,
|
|
13
|
-
ExtractError,
|
|
14
|
-
ExtractResponse,
|
|
15
|
-
} from "types";
|
|
16
|
-
import { Command } from "command";
|
|
17
|
-
import { ClientResponseType, ClientQueryParamsType, FetchProgressType } from "client";
|
|
18
|
-
import { CommandEventDetails, CommandResponseDetails } from "managers";
|
|
19
|
-
|
|
20
|
-
// Progress
|
|
21
|
-
export type ClientProgressEvent = { total: number; loaded: number };
|
|
22
|
-
export type ClientProgressResponse = {
|
|
23
|
-
progress: number;
|
|
24
|
-
timeLeft: number;
|
|
25
|
-
sizeLeft: number;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Dump
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Dump of the command used to later recreate it
|
|
32
|
-
*/
|
|
33
|
-
export type CommandDump<
|
|
34
|
-
Command extends CommandInstance,
|
|
35
|
-
// Bellow generics provided only to overcome the typescript bugs
|
|
36
|
-
ClientOptions = unknown,
|
|
37
|
-
QueryParamsType = ClientQueryParamsType,
|
|
38
|
-
Params = ExtractParams<Command>,
|
|
39
|
-
> = {
|
|
40
|
-
commandOptions: CommandConfig<string, ClientOptions | ExtractClientOptions<Command>>;
|
|
41
|
-
endpoint: string;
|
|
42
|
-
method: HttpMethodsType;
|
|
43
|
-
headers?: HeadersInit;
|
|
44
|
-
auth: boolean;
|
|
45
|
-
cancelable: boolean;
|
|
46
|
-
retry: number;
|
|
47
|
-
retryTime: number;
|
|
48
|
-
garbageCollection: number;
|
|
49
|
-
cache: boolean;
|
|
50
|
-
cacheTime: number;
|
|
51
|
-
queued: boolean;
|
|
52
|
-
offline: boolean;
|
|
53
|
-
disableResponseInterceptors: boolean | undefined;
|
|
54
|
-
disableRequestInterceptors: boolean | undefined;
|
|
55
|
-
options?: ClientOptions | ExtractClientOptions<Command>;
|
|
56
|
-
data: CommandData<ExtractRequestData<Command>, unknown>;
|
|
57
|
-
params: Params | NegativeTypes;
|
|
58
|
-
queryParams: QueryParamsType | NegativeTypes;
|
|
59
|
-
abortKey: string;
|
|
60
|
-
cacheKey: string;
|
|
61
|
-
queueKey: string;
|
|
62
|
-
effectKey: string;
|
|
63
|
-
used: boolean;
|
|
64
|
-
updatedAbortKey: boolean;
|
|
65
|
-
updatedCacheKey: boolean;
|
|
66
|
-
updatedQueueKey: boolean;
|
|
67
|
-
updatedEffectKey: boolean;
|
|
68
|
-
deduplicate: boolean;
|
|
69
|
-
deduplicateTime: number;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// Command
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Configuration options for command creation
|
|
76
|
-
*/
|
|
77
|
-
export type CommandConfig<GenericEndpoint extends string, ClientOptions> = {
|
|
78
|
-
/**
|
|
79
|
-
* Determine the endpoint for command request
|
|
80
|
-
*/
|
|
81
|
-
endpoint: GenericEndpoint;
|
|
82
|
-
/**
|
|
83
|
-
* Custom headers for command
|
|
84
|
-
*/
|
|
85
|
-
headers?: HeadersInit;
|
|
86
|
-
/**
|
|
87
|
-
* Should the onAuth method get called on this command
|
|
88
|
-
*/
|
|
89
|
-
auth?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Request method GET | POST | PATCH | PUT | DELETE
|
|
92
|
-
*/
|
|
93
|
-
method?: HttpMethodsType;
|
|
94
|
-
/**
|
|
95
|
-
* Should enable cancelable mode in the Dispatcher
|
|
96
|
-
*/
|
|
97
|
-
cancelable?: boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Retry count when request is failed
|
|
100
|
-
*/
|
|
101
|
-
retry?: number;
|
|
102
|
-
/**
|
|
103
|
-
* Retry time delay between retries
|
|
104
|
-
*/
|
|
105
|
-
retryTime?: number;
|
|
106
|
-
/**
|
|
107
|
-
* Should we trigger garbage collection or leave data in memory
|
|
108
|
-
*/
|
|
109
|
-
garbageCollection?: number;
|
|
110
|
-
/**
|
|
111
|
-
* Should we save the response to cache
|
|
112
|
-
*/
|
|
113
|
-
cache?: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Time for which the cache is considered up-to-date
|
|
116
|
-
*/
|
|
117
|
-
cacheTime?: number;
|
|
118
|
-
/**
|
|
119
|
-
* Should the requests from this command be send one-by-one
|
|
120
|
-
*/
|
|
121
|
-
queued?: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* Do we want to store request made in offline mode for latter use when we go back online
|
|
124
|
-
*/
|
|
125
|
-
offline?: boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Disable post-request interceptors
|
|
128
|
-
*/
|
|
129
|
-
disableResponseInterceptors?: boolean;
|
|
130
|
-
/**
|
|
131
|
-
* Disable pre-request interceptors
|
|
132
|
-
*/
|
|
133
|
-
disableRequestInterceptors?: boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Additional options for your client, by default XHR options
|
|
136
|
-
*/
|
|
137
|
-
options?: ClientOptions;
|
|
138
|
-
/**
|
|
139
|
-
* Key which will be used to cancel requests. Autogenerated by default.
|
|
140
|
-
*/
|
|
141
|
-
abortKey?: string;
|
|
142
|
-
/**
|
|
143
|
-
* Key which will be used to cache requests. Autogenerated by default.
|
|
144
|
-
*/
|
|
145
|
-
cacheKey?: string;
|
|
146
|
-
/**
|
|
147
|
-
* Key which will be used to queue requests. Autogenerated by default.
|
|
148
|
-
*/
|
|
149
|
-
queueKey?: string;
|
|
150
|
-
/**
|
|
151
|
-
* Key which will be used to use effects. Autogenerated by default.
|
|
152
|
-
*/
|
|
153
|
-
effectKey?: string;
|
|
154
|
-
/**
|
|
155
|
-
* Should we deduplicate two requests made at the same time into one
|
|
156
|
-
*/
|
|
157
|
-
deduplicate?: boolean;
|
|
158
|
-
/**
|
|
159
|
-
* Time of pooling for the deduplication to be active (default 10ms)
|
|
160
|
-
*/
|
|
161
|
-
deduplicateTime?: number;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export type CommandMapperType<RequestDataType, MappedData> = (data: RequestDataType) => MappedData;
|
|
165
|
-
|
|
166
|
-
export type CommandData<RequestDataType, MappedData> =
|
|
167
|
-
| (MappedData extends never ? RequestDataType : MappedData)
|
|
168
|
-
| NegativeTypes;
|
|
169
|
-
|
|
170
|
-
export type CommandCurrentType<
|
|
171
|
-
ResponseType,
|
|
172
|
-
RequestDataType,
|
|
173
|
-
QueryParamsType,
|
|
174
|
-
ErrorType,
|
|
175
|
-
GenericEndpoint extends string,
|
|
176
|
-
ClientOptions,
|
|
177
|
-
MappedData,
|
|
178
|
-
> = {
|
|
179
|
-
used?: boolean;
|
|
180
|
-
params?: ExtractRouteParams<GenericEndpoint> | NegativeTypes;
|
|
181
|
-
queryParams?: QueryParamsType | NegativeTypes;
|
|
182
|
-
data?: CommandData<RequestDataType, MappedData>;
|
|
183
|
-
mockCallback?: ((data: RequestDataType) => ClientResponseType<ResponseType, ErrorType>) | undefined;
|
|
184
|
-
headers?: HeadersInit;
|
|
185
|
-
updatedAbortKey?: boolean;
|
|
186
|
-
updatedCacheKey?: boolean;
|
|
187
|
-
updatedQueueKey?: boolean;
|
|
188
|
-
updatedEffectKey?: boolean;
|
|
189
|
-
} & Partial<NullableKeys<CommandConfig<GenericEndpoint, ClientOptions>>>;
|
|
190
|
-
|
|
191
|
-
export type ParamType = string | number;
|
|
192
|
-
export type ParamsType = Record<string, ParamType>;
|
|
193
|
-
|
|
194
|
-
export type ExtractRouteParams<T extends string> = string extends T
|
|
195
|
-
? NegativeTypes
|
|
196
|
-
: T extends `${string}:${infer Param}/${infer Rest}`
|
|
197
|
-
? { [k in Param | keyof ExtractRouteParams<Rest>]: ParamType }
|
|
198
|
-
: T extends `${string}:${infer Param}`
|
|
199
|
-
? { [k in Param]: ParamType }
|
|
200
|
-
: NegativeTypes;
|
|
201
|
-
|
|
202
|
-
export type FetchOptionsType<ClientOptions> = Omit<
|
|
203
|
-
Partial<CommandConfig<string, ClientOptions>>,
|
|
204
|
-
"endpoint" | "method"
|
|
205
|
-
>;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* It will check if the query params are already set
|
|
209
|
-
*/
|
|
210
|
-
export type FetchQueryParamsType<
|
|
211
|
-
QueryParamsType extends ClientQueryParamsType | string,
|
|
212
|
-
HasQuery extends true | false = false,
|
|
213
|
-
> = HasQuery extends true
|
|
214
|
-
? { queryParams?: NegativeTypes }
|
|
215
|
-
: {
|
|
216
|
-
queryParams?: QueryParamsType | string;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* If the command endpoint parameters are not filled it will throw an error
|
|
221
|
-
*/
|
|
222
|
-
export type FetchParamsType<
|
|
223
|
-
EndpointType extends string,
|
|
224
|
-
HasParams extends true | false,
|
|
225
|
-
> = ExtractRouteParams<EndpointType> extends NegativeTypes
|
|
226
|
-
? { params?: NegativeTypes }
|
|
227
|
-
: true extends HasParams
|
|
228
|
-
? { params?: NegativeTypes }
|
|
229
|
-
: { params: NonNullable<ExtractRouteParams<EndpointType>> };
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* If the command data is not filled it will throw an error
|
|
233
|
-
*/
|
|
234
|
-
export type FetchRequestDataType<RequestDataType, HasData extends true | false> = RequestDataType extends NegativeTypes
|
|
235
|
-
? { data?: NegativeTypes }
|
|
236
|
-
: HasData extends true
|
|
237
|
-
? { data?: NegativeTypes }
|
|
238
|
-
: { data: NonNullable<RequestDataType> };
|
|
239
|
-
|
|
240
|
-
export type CommandQueueOptions = {
|
|
241
|
-
dispatcherType?: "auto" | "fetch" | "submit";
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
export type FetchType<Command extends CommandInstance> = FetchQueryParamsType<
|
|
245
|
-
ExtractQueryParams<Command>,
|
|
246
|
-
ExtractHasQueryParams<Command>
|
|
247
|
-
> &
|
|
248
|
-
FetchParamsType<ExtractEndpoint<Command>, ExtractHasParams<Command>> &
|
|
249
|
-
FetchRequestDataType<ExtractRequestData<Command>, ExtractHasData<Command>> &
|
|
250
|
-
Omit<FetchOptionsType<ExtractClientOptions<Command>>, "params" | "data"> &
|
|
251
|
-
FetchSendActionsType<Command> &
|
|
252
|
-
CommandQueueOptions;
|
|
253
|
-
|
|
254
|
-
export type FetchSendActionsType<Command extends CommandInstance> = {
|
|
255
|
-
onSettle?: (requestId: string, command: Command) => void;
|
|
256
|
-
onRequestStart?: (details: CommandEventDetails<Command>) => void;
|
|
257
|
-
onResponseStart?: (details: CommandEventDetails<Command>) => void;
|
|
258
|
-
onUploadProgress?: (values: FetchProgressType, details: CommandEventDetails<Command>) => void;
|
|
259
|
-
onDownloadProgress?: (values: FetchProgressType, details: CommandEventDetails<Command>) => void;
|
|
260
|
-
onResponse?: (
|
|
261
|
-
response: ClientResponseType<ExtractResponse<Command>, ExtractError<Command>>,
|
|
262
|
-
details: CommandResponseDetails,
|
|
263
|
-
) => void;
|
|
264
|
-
onRemove?: (details: CommandEventDetails<Command>) => void;
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
export type FetchMethodType<Command extends CommandInstance> = FetchType<Command>["data"] extends NegativeTypes
|
|
268
|
-
? FetchType<Command>["params"] extends NegativeTypes
|
|
269
|
-
? (options?: FetchType<Command>) => Promise<ClientResponseType<ExtractResponse<Command>, ExtractError<Command>>>
|
|
270
|
-
: (options: FetchType<Command>) => Promise<ClientResponseType<ExtractResponse<Command>, ExtractError<Command>>>
|
|
271
|
-
: (options: FetchType<Command>) => Promise<ClientResponseType<ExtractResponse<Command>, ExtractError<Command>>>;
|
|
272
|
-
|
|
273
|
-
export type CommandInstance = Command<any, any, any, any, any, any, any, any, any, any, any>;
|
package/src/command/index.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ExtractError } from "types";
|
|
2
|
-
import { FetchEffectConfig } from "effect";
|
|
3
|
-
import { CommandInstance } from "command";
|
|
4
|
-
import { ClientResponseErrorType, ClientResponseType, ClientResponseSuccessType } from "client";
|
|
5
|
-
|
|
6
|
-
export class FetchEffect<T extends CommandInstance> {
|
|
7
|
-
constructor(public config: FetchEffectConfig<T>) {}
|
|
8
|
-
|
|
9
|
-
getEffectKey = () => {
|
|
10
|
-
return this.config.effectKey;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
onTrigger = (command: T) => {
|
|
14
|
-
this.config.onTrigger?.(command);
|
|
15
|
-
};
|
|
16
|
-
onStart = (command: T) => {
|
|
17
|
-
this.config.onStart?.(command);
|
|
18
|
-
};
|
|
19
|
-
onSuccess = (response: ClientResponseSuccessType<ResponseType>, command: T) => {
|
|
20
|
-
this.config.onSuccess?.(response, command);
|
|
21
|
-
};
|
|
22
|
-
onError = (response: ClientResponseErrorType<ExtractError<T>>, command: T) => {
|
|
23
|
-
this.config.onError?.(response, command);
|
|
24
|
-
};
|
|
25
|
-
onFinished = (response: ClientResponseType<ResponseType, ExtractError<T>>, command: T) => {
|
|
26
|
-
this.config.onFinished?.(response, command);
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { CommandInstance } from "command";
|
|
2
|
-
import { ClientResponseErrorType, ClientResponseType, ClientResponseSuccessType } from "client";
|
|
3
|
-
import { FetchEffect } from "effect";
|
|
4
|
-
import { ExtractError } from "types";
|
|
5
|
-
|
|
6
|
-
export type FetchEffectLifecycle = "trigger" | "start" | "success" | "error" | "finished";
|
|
7
|
-
|
|
8
|
-
export type FetchEffectInstance = FetchEffect<CommandInstance>;
|
|
9
|
-
|
|
10
|
-
export type FetchEffectConfig<T extends CommandInstance> = {
|
|
11
|
-
/**
|
|
12
|
-
* It should match effectKey on the command for which given effect should be triggered.
|
|
13
|
-
*/
|
|
14
|
-
effectKey: string;
|
|
15
|
-
/**
|
|
16
|
-
* Callback that will be executed when request gets triggered
|
|
17
|
-
*/
|
|
18
|
-
onTrigger?: (command: CommandInstance) => void;
|
|
19
|
-
/**
|
|
20
|
-
* Callback that will be executed when request starts
|
|
21
|
-
*/
|
|
22
|
-
onStart?: (command: CommandInstance) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Callback that will be executed when response is successful
|
|
25
|
-
*/
|
|
26
|
-
onSuccess?: (response: ClientResponseSuccessType<ResponseType>, command: CommandInstance) => void;
|
|
27
|
-
/**
|
|
28
|
-
* Callback that will be executed when response is failed
|
|
29
|
-
*/
|
|
30
|
-
onError?: (response: ClientResponseErrorType<ExtractError<T>>, command: CommandInstance) => void;
|
|
31
|
-
/**
|
|
32
|
-
* Callback that will be executed when response is finished
|
|
33
|
-
*/
|
|
34
|
-
onFinished?: (response: ClientResponseType<ResponseType, ExtractError<T>>, command: CommandInstance) => void;
|
|
35
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { CommandInstance } from "command";
|
|
2
|
-
|
|
3
|
-
// Events
|
|
4
|
-
export type CommandLoadingEventType = {
|
|
5
|
-
queueKey: string;
|
|
6
|
-
requestId: string;
|
|
7
|
-
loading: boolean;
|
|
8
|
-
isRetry: boolean;
|
|
9
|
-
isOffline: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type CommandEventDetails<T extends CommandInstance> = {
|
|
13
|
-
requestId: string;
|
|
14
|
-
command: T;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type CommandResponseDetails = {
|
|
18
|
-
retries: number;
|
|
19
|
-
timestamp: number;
|
|
20
|
-
isFailed: boolean;
|
|
21
|
-
isCanceled: boolean;
|
|
22
|
-
isOffline: boolean;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type CommandRemoveDetails = { queueKey: string; requestId: string };
|