@hyper-fetch/core 2.0.0 → 3.0.0

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.
Files changed (109) hide show
  1. package/README.md +14 -13
  2. package/dist/adapter/adapter.bindings.d.ts +25 -0
  3. package/dist/adapter/adapter.browser.d.ts +2 -0
  4. package/dist/{client/fetch.client.constants.d.ts → adapter/adapter.constants.d.ts} +0 -0
  5. package/dist/adapter/adapter.d.ts +2 -0
  6. package/dist/adapter/adapter.server.d.ts +2 -0
  7. package/dist/adapter/adapter.types.d.ts +57 -0
  8. package/dist/{client/fetch.client.utils.d.ts → adapter/adapter.utils.d.ts} +3 -3
  9. package/dist/adapter/index.d.ts +7 -0
  10. package/dist/cache/cache.d.ts +9 -9
  11. package/dist/cache/cache.types.d.ts +4 -4
  12. package/dist/cache/cache.utils.d.ts +3 -3
  13. package/dist/{builder/builder.constants.d.ts → client/client.constants.d.ts} +0 -0
  14. package/dist/client/client.d.ts +142 -0
  15. package/dist/client/client.types.d.ts +41 -0
  16. package/dist/client/client.utils.d.ts +10 -0
  17. package/dist/client/index.d.ts +4 -6
  18. package/dist/dispatcher/dispatcher.d.ts +23 -23
  19. package/dist/dispatcher/dispatcher.events.d.ts +8 -8
  20. package/dist/dispatcher/dispatcher.types.d.ts +10 -10
  21. package/dist/dispatcher/dispatcher.utils.d.ts +5 -5
  22. package/dist/effect/index.d.ts +2 -2
  23. package/dist/effect/request.effect.d.ts +14 -0
  24. package/dist/effect/request.effect.types.d.ts +32 -0
  25. package/dist/index.cjs.js +1 -1
  26. package/dist/index.cjs.js.map +4 -4
  27. package/dist/index.d.ts +3 -3
  28. package/dist/index.esm.js +1 -1
  29. package/dist/index.esm.js.map +4 -4
  30. package/dist/managers/index.d.ts +1 -1
  31. package/dist/managers/logger/logger.manager.d.ts +5 -5
  32. package/dist/managers/logger/logger.manager.types.d.ts +7 -7
  33. package/dist/managers/request/index.d.ts +4 -0
  34. package/dist/managers/request/request.manager.d.ts +43 -0
  35. package/dist/managers/request/request.manager.events.d.ts +36 -0
  36. package/dist/managers/{command/command.manager.types.d.ts → request/request.manager.types.d.ts} +6 -6
  37. package/dist/managers/{command/command.manager.utils.d.ts → request/request.manager.utils.d.ts} +0 -0
  38. package/dist/request/index.d.ts +3 -0
  39. package/dist/request/request.d.ts +98 -0
  40. package/dist/request/request.types.d.ts +202 -0
  41. package/dist/request/request.utils.d.ts +22 -0
  42. package/dist/types/fetch.types.d.ts +16 -16
  43. package/package.json +1 -1
  44. package/src/{client/fetch.client.bindings.ts → adapter/adapter.bindings.ts} +58 -58
  45. package/src/{client/fetch.client.browser.ts → adapter/adapter.browser.ts} +6 -6
  46. package/src/{client/fetch.client.constants.ts → adapter/adapter.constants.ts} +0 -0
  47. package/src/{client/fetch.client.server.ts → adapter/adapter.server.ts} +12 -12
  48. package/src/adapter/adapter.ts +8 -0
  49. package/src/adapter/adapter.types.ts +79 -0
  50. package/src/{client/fetch.client.utils.ts → adapter/adapter.utils.ts} +3 -3
  51. package/src/adapter/index.ts +7 -0
  52. package/src/cache/cache.ts +19 -19
  53. package/src/cache/cache.types.ts +4 -4
  54. package/src/cache/cache.utils.ts +6 -6
  55. package/src/{builder/builder.constants.ts → client/client.constants.ts} +0 -0
  56. package/src/client/client.ts +310 -0
  57. package/src/client/client.types.ts +52 -0
  58. package/src/{builder/builder.utils.ts → client/client.utils.ts} +34 -31
  59. package/src/client/index.ts +4 -6
  60. package/src/dispatcher/dispatcher.events.ts +11 -11
  61. package/src/dispatcher/dispatcher.ts +68 -68
  62. package/src/dispatcher/dispatcher.types.ts +10 -10
  63. package/src/dispatcher/dispatcher.utils.ts +7 -7
  64. package/src/effect/index.ts +2 -2
  65. package/src/effect/request.effect.ts +28 -0
  66. package/src/effect/request.effect.types.ts +35 -0
  67. package/src/index.ts +4 -4
  68. package/src/managers/index.ts +1 -1
  69. package/src/managers/logger/logger.manager.ts +8 -8
  70. package/src/managers/logger/logger.manager.types.ts +7 -7
  71. package/src/managers/request/index.ts +4 -0
  72. package/src/managers/{command/command.manager.events.ts → request/request.manager.events.ts} +47 -51
  73. package/src/managers/{command/command.manager.ts → request/request.manager.ts} +5 -5
  74. package/src/managers/request/request.manager.types.ts +25 -0
  75. package/src/managers/{command/command.manager.utils.ts → request/request.manager.utils.ts} +0 -0
  76. package/src/request/index.ts +3 -0
  77. package/src/{command/command.ts → request/request.ts} +188 -194
  78. package/src/request/request.types.ts +282 -0
  79. package/src/{command/command.utils.ts → request/request.utils.ts} +56 -53
  80. package/src/types/fetch.types.ts +18 -18
  81. package/dist/builder/builder.d.ts +0 -141
  82. package/dist/builder/builder.types.d.ts +0 -41
  83. package/dist/builder/builder.utils.d.ts +0 -10
  84. package/dist/builder/index.d.ts +0 -4
  85. package/dist/client/fetch.client.bindings.d.ts +0 -25
  86. package/dist/client/fetch.client.browser.d.ts +0 -2
  87. package/dist/client/fetch.client.d.ts +0 -2
  88. package/dist/client/fetch.client.server.d.ts +0 -2
  89. package/dist/client/fetch.client.types.d.ts +0 -57
  90. package/dist/command/command.d.ts +0 -98
  91. package/dist/command/command.types.d.ts +0 -202
  92. package/dist/command/command.utils.d.ts +0 -22
  93. package/dist/command/index.d.ts +0 -3
  94. package/dist/effect/fetch.effect.d.ts +0 -14
  95. package/dist/effect/fetch.effect.types.d.ts +0 -32
  96. package/dist/managers/command/command.manager.d.ts +0 -43
  97. package/dist/managers/command/command.manager.events.d.ts +0 -36
  98. package/dist/managers/command/index.d.ts +0 -4
  99. package/src/builder/builder.ts +0 -308
  100. package/src/builder/builder.types.ts +0 -53
  101. package/src/builder/index.ts +0 -4
  102. package/src/client/fetch.client.ts +0 -9
  103. package/src/client/fetch.client.types.ts +0 -83
  104. package/src/command/command.types.ts +0 -273
  105. package/src/command/index.ts +0 -3
  106. package/src/effect/fetch.effect.ts +0 -28
  107. package/src/effect/fetch.effect.types.ts +0 -35
  108. package/src/managers/command/command.manager.types.ts +0 -25
  109. package/src/managers/command/index.ts +0 -4
@@ -1,56 +1,56 @@
1
1
  import {
2
- FetchType,
2
+ RequestSendOptionsType,
3
3
  ParamsType,
4
4
  getSimpleKey,
5
- getCommandKey,
6
- FetchMethodType,
7
- CommandData,
8
- CommandDump,
9
- CommandConfig,
5
+ getRequestKey,
6
+ RequestSendType,
7
+ PayloadType,
8
+ RequestDump,
9
+ RequestOptionsType,
10
10
  ExtractRouteParams,
11
- commandSendRequest,
12
- CommandCurrentType,
13
- CommandMapperType,
14
- } from "command";
15
- import { Builder } from "builder";
11
+ requestSendRequest,
12
+ RequestCurrentType,
13
+ PayloadMapperType,
14
+ } from "request";
15
+ import { Client } from "client";
16
16
  import { getUniqueRequestId } from "utils";
17
- import { ClientQueryParamsType } from "client";
17
+ import { QueryParamsType } from "adapter";
18
18
  import { HttpMethodsType, NegativeTypes } from "types";
19
19
  import { DateInterval } from "constants/time.constants";
20
20
  import { HttpMethodsEnum } from "constants/http.constants";
21
21
 
22
22
  /**
23
- * Fetch command it is designed to prepare the necessary setup to execute the request to the server.
23
+ * Fetch request it is designed to prepare the necessary setup to execute the request to the server.
24
24
  * We can setup basic options for example endpoint, method, headers and advanced settings like cache, invalidation patterns, concurrency, retries and much, much more.
25
25
  * :::info Usage
26
- * We should not use this class directly in the standard development flow. We can initialize it using the `createCommand` method on the **Builder** class.
26
+ * We should not use this class directly in the standard development flow. We can initialize it using the `createRequest` method on the **Client** class.
27
27
  * :::
28
28
  *
29
29
  * @attention
30
- * The most important thing about the command is that it keeps data in the format that can be dumped. This is necessary for the persistance and different dispatcher storage types.
30
+ * The most important thing about the request is that it keeps data in the format that can be dumped. This is necessary for the persistance and different dispatcher storage types.
31
31
  * This class doesn't have any callback methods by design and communicate with dispatcher and cache by events.
32
32
  */
33
- export class Command<
34
- ResponseType,
35
- RequestDataType,
36
- QueryParamsType extends ClientQueryParamsType | string,
37
- GlobalErrorType, // Global Error Type
38
- LocalErrorType, // Additional Error for specific endpoint
39
- EndpointType extends string,
40
- ClientOptions,
33
+ export class Request<
34
+ Response,
35
+ Payload,
36
+ QueryParams extends QueryParamsType | string,
37
+ GlobalError, // Global Error Type
38
+ LocalError, // Additional Error for specific endpoint
39
+ Endpoint extends string,
40
+ AdapterOptions,
41
41
  HasData extends true | false = false,
42
42
  HasParams extends true | false = false,
43
43
  HasQuery extends true | false = false,
44
44
  MappedData = undefined,
45
45
  > {
46
- endpoint: EndpointType;
46
+ endpoint: Endpoint;
47
47
  headers?: HeadersInit;
48
48
  auth: boolean;
49
49
  method: HttpMethodsType;
50
- params: ExtractRouteParams<EndpointType> | NegativeTypes;
51
- data: CommandData<RequestDataType, MappedData>;
52
- queryParams: QueryParamsType | NegativeTypes;
53
- options?: ClientOptions | undefined;
50
+ params: ExtractRouteParams<Endpoint> | NegativeTypes;
51
+ data: PayloadType<Payload, MappedData>;
52
+ queryParams: QueryParams | NegativeTypes;
53
+ options?: AdapterOptions | undefined;
54
54
  cancelable: boolean;
55
55
  retry: number;
56
56
  retryTime: number;
@@ -73,20 +73,20 @@ export class Command<
73
73
  private updatedEffectKey: boolean;
74
74
 
75
75
  constructor(
76
- readonly builder: Builder<GlobalErrorType, ClientOptions>,
77
- readonly commandOptions: CommandConfig<EndpointType, ClientOptions>,
78
- readonly commandDump?:
79
- | CommandCurrentType<
80
- ResponseType,
81
- RequestDataType,
82
- QueryParamsType,
83
- GlobalErrorType | LocalErrorType,
84
- EndpointType,
85
- ClientOptions,
76
+ readonly client: Client<GlobalError, AdapterOptions>,
77
+ readonly requestOptions: RequestOptionsType<Endpoint, AdapterOptions>,
78
+ readonly requestDump?:
79
+ | RequestCurrentType<
80
+ Response,
81
+ Payload,
82
+ QueryParams,
83
+ GlobalError | LocalError,
84
+ Endpoint,
85
+ AdapterOptions,
86
86
  MappedData
87
87
  >
88
88
  | undefined,
89
- readonly dataMapper?: CommandMapperType<RequestDataType, MappedData>,
89
+ readonly dataMapper?: PayloadMapperType<Payload, MappedData>,
90
90
  ) {
91
91
  const {
92
92
  endpoint,
@@ -108,36 +108,36 @@ export class Command<
108
108
  effectKey,
109
109
  deduplicate = false,
110
110
  deduplicateTime = 10,
111
- } = { ...this.builder.commandConfig?.(commandOptions), ...commandOptions };
111
+ } = { ...this.client.requestDefaultOptions?.(requestOptions), ...requestOptions };
112
112
 
113
- this.endpoint = commandDump?.endpoint ?? endpoint;
114
- this.headers = commandDump?.headers ?? headers;
115
- this.auth = commandDump?.auth ?? auth;
113
+ this.endpoint = requestDump?.endpoint ?? endpoint;
114
+ this.headers = requestDump?.headers ?? headers;
115
+ this.auth = requestDump?.auth ?? auth;
116
116
  this.method = method;
117
- this.params = commandDump?.params;
118
- this.data = commandDump?.data;
119
- this.queryParams = commandDump?.queryParams;
120
- this.options = commandDump?.options ?? options;
121
- this.cancelable = commandDump?.cancelable ?? cancelable;
122
- this.retry = commandDump?.retry ?? retry;
123
- this.retryTime = commandDump?.retryTime ?? retryTime;
124
- this.garbageCollection = commandDump?.garbageCollection ?? garbageCollection;
125
- this.cache = commandDump?.cache ?? cache;
126
- this.cacheTime = commandDump?.cacheTime ?? cacheTime;
127
- this.queued = commandDump?.queued ?? queued;
128
- this.offline = commandDump?.offline ?? offline;
129
- this.abortKey = commandDump?.abortKey ?? abortKey ?? getSimpleKey(this);
130
- this.cacheKey = commandDump?.cacheKey ?? cacheKey ?? getCommandKey(this);
131
- this.queueKey = commandDump?.queueKey ?? queueKey ?? getSimpleKey(this);
132
- this.effectKey = commandDump?.effectKey ?? effectKey ?? getSimpleKey(this);
133
- this.used = commandDump?.used ?? false;
134
- this.deduplicate = commandDump?.deduplicate ?? deduplicate;
135
- this.deduplicateTime = commandDump?.deduplicateTime ?? deduplicateTime;
136
-
137
- this.updatedAbortKey = commandDump?.updatedAbortKey ?? false;
138
- this.updatedCacheKey = commandDump?.updatedCacheKey ?? false;
139
- this.updatedQueueKey = commandDump?.updatedQueueKey ?? false;
140
- this.updatedEffectKey = commandDump?.updatedEffectKey ?? false;
117
+ this.params = requestDump?.params;
118
+ this.data = requestDump?.data;
119
+ this.queryParams = requestDump?.queryParams;
120
+ this.options = requestDump?.options ?? options;
121
+ this.cancelable = requestDump?.cancelable ?? cancelable;
122
+ this.retry = requestDump?.retry ?? retry;
123
+ this.retryTime = requestDump?.retryTime ?? retryTime;
124
+ this.garbageCollection = requestDump?.garbageCollection ?? garbageCollection;
125
+ this.cache = requestDump?.cache ?? cache;
126
+ this.cacheTime = requestDump?.cacheTime ?? cacheTime;
127
+ this.queued = requestDump?.queued ?? queued;
128
+ this.offline = requestDump?.offline ?? offline;
129
+ this.abortKey = requestDump?.abortKey ?? abortKey ?? getSimpleKey(this);
130
+ this.cacheKey = requestDump?.cacheKey ?? cacheKey ?? getRequestKey(this);
131
+ this.queueKey = requestDump?.queueKey ?? queueKey ?? getSimpleKey(this);
132
+ this.effectKey = requestDump?.effectKey ?? effectKey ?? getSimpleKey(this);
133
+ this.used = requestDump?.used ?? false;
134
+ this.deduplicate = requestDump?.deduplicate ?? deduplicate;
135
+ this.deduplicateTime = requestDump?.deduplicateTime ?? deduplicateTime;
136
+
137
+ this.updatedAbortKey = requestDump?.updatedAbortKey ?? false;
138
+ this.updatedCacheKey = requestDump?.updatedCacheKey ?? false;
139
+ this.updatedQueueKey = requestDump?.updatedQueueKey ?? false;
140
+ this.updatedEffectKey = requestDump?.updatedEffectKey ?? false;
141
141
  }
142
142
 
143
143
  public setHeaders = (headers: HeadersInit) => {
@@ -148,22 +148,22 @@ export class Command<
148
148
  return this.clone({ auth });
149
149
  };
150
150
 
151
- public setParams = <P extends ExtractRouteParams<EndpointType>>(params: P) => {
151
+ public setParams = <P extends ExtractRouteParams<Endpoint>>(params: P) => {
152
152
  return this.clone<HasData, P extends null ? false : true, HasQuery>({ params });
153
153
  };
154
154
 
155
- public setData = <D extends RequestDataType>(data: D) => {
155
+ public setData = <D extends Payload>(data: D) => {
156
156
  const modifiedData = this.dataMapper?.(data) || data;
157
157
  return this.clone<D extends null ? false : true, HasParams, HasQuery, MappedData>({
158
- data: modifiedData as CommandData<RequestDataType, MappedData>,
158
+ data: modifiedData as PayloadType<Payload, MappedData>,
159
159
  });
160
160
  };
161
161
 
162
- public setQueryParams = (queryParams: QueryParamsType) => {
162
+ public setQueryParams = (queryParams: QueryParams) => {
163
163
  return this.clone<HasData, HasParams, true>({ queryParams });
164
164
  };
165
165
 
166
- public setOptions = (options: ClientOptions) => {
166
+ public setOptions = (options: AdapterOptions) => {
167
167
  return this.clone<HasData, HasParams, true>({ options });
168
168
  };
169
169
 
@@ -171,25 +171,25 @@ export class Command<
171
171
  return this.clone({ cancelable });
172
172
  };
173
173
 
174
- public setRetry = (retry: CommandConfig<EndpointType, ClientOptions>["retry"]) => {
174
+ public setRetry = (retry: RequestOptionsType<Endpoint, AdapterOptions>["retry"]) => {
175
175
  return this.clone({ retry });
176
176
  };
177
177
 
178
- public setRetryTime = (retryTime: CommandConfig<EndpointType, ClientOptions>["retryTime"]) => {
178
+ public setRetryTime = (retryTime: RequestOptionsType<Endpoint, AdapterOptions>["retryTime"]) => {
179
179
  return this.clone({ retryTime });
180
180
  };
181
181
 
182
182
  public setGarbageCollection = (
183
- garbageCollection: CommandConfig<EndpointType, ClientOptions>["garbageCollection"],
183
+ garbageCollection: RequestOptionsType<Endpoint, AdapterOptions>["garbageCollection"],
184
184
  ) => {
185
185
  return this.clone({ garbageCollection });
186
186
  };
187
187
 
188
- public setCache = (cache: CommandConfig<EndpointType, ClientOptions>["cache"]) => {
188
+ public setCache = (cache: RequestOptionsType<Endpoint, AdapterOptions>["cache"]) => {
189
189
  return this.clone({ cache });
190
190
  };
191
191
 
192
- public setCacheTime = (cacheTime: CommandConfig<EndpointType, ClientOptions>["cacheTime"]) => {
192
+ public setCacheTime = (cacheTime: RequestOptionsType<Endpoint, AdapterOptions>["cacheTime"]) => {
193
193
  return this.clone({ cacheTime });
194
194
  };
195
195
 
@@ -233,45 +233,42 @@ export class Command<
233
233
  return this.clone({ offline });
234
234
  };
235
235
 
236
- public setDataMapper = <DataMapper extends (data: RequestDataType) => any>(mapper: DataMapper) => {
236
+ public setDataMapper = <DataMapper extends (data: Payload) => any>(mapper: DataMapper) => {
237
237
  return this.clone<HasData, HasParams, HasQuery>(undefined, mapper);
238
238
  };
239
239
 
240
- private paramsMapper = (
241
- params: ParamsType | null | undefined,
242
- queryParams: QueryParamsType | NegativeTypes,
243
- ): string => {
244
- let endpoint = this.commandOptions.endpoint as string;
240
+ private paramsMapper = (params: ParamsType | null | undefined, queryParams: QueryParams | NegativeTypes): string => {
241
+ let endpoint = this.requestOptions.endpoint as string;
245
242
  if (params) {
246
243
  Object.entries(params).forEach(([key, value]) => {
247
244
  endpoint = endpoint.replace(new RegExp(`:${key}`, "g"), String(value));
248
245
  });
249
246
  }
250
247
  if (queryParams) {
251
- endpoint += this.builder.stringifyQueryParams(queryParams);
248
+ endpoint += this.client.stringifyQueryParams(queryParams);
252
249
  }
253
250
  return endpoint;
254
251
  };
255
252
 
256
- public dump(): CommandDump<
257
- Command<
258
- ResponseType,
259
- RequestDataType,
260
- QueryParamsType,
261
- GlobalErrorType,
262
- LocalErrorType,
263
- EndpointType,
264
- ClientOptions,
253
+ public dump(): RequestDump<
254
+ Request<
255
+ Response,
256
+ Payload,
257
+ QueryParams,
258
+ GlobalError,
259
+ LocalError,
260
+ Endpoint,
261
+ AdapterOptions,
265
262
  HasData,
266
263
  HasParams,
267
264
  HasQuery,
268
265
  MappedData
269
266
  >,
270
- ClientOptions,
271
- QueryParamsType
267
+ AdapterOptions,
268
+ QueryParams
272
269
  > {
273
270
  return {
274
- commandOptions: this.commandOptions,
271
+ requestOptions: this.requestOptions,
275
272
  endpoint: this.endpoint,
276
273
  headers: this.headers,
277
274
  auth: this.auth,
@@ -293,8 +290,8 @@ export class Command<
293
290
  queueKey: this.queueKey,
294
291
  effectKey: this.effectKey,
295
292
  used: this.used,
296
- disableResponseInterceptors: this.commandOptions.disableResponseInterceptors,
297
- disableRequestInterceptors: this.commandOptions.disableRequestInterceptors,
293
+ disableResponseInterceptors: this.requestOptions.disableResponseInterceptors,
294
+ disableRequestInterceptors: this.requestOptions.disableRequestInterceptors,
298
295
  updatedAbortKey: this.updatedAbortKey,
299
296
  updatedCacheKey: this.updatedCacheKey,
300
297
  updatedQueueKey: this.updatedQueueKey,
@@ -310,37 +307,37 @@ export class Command<
310
307
  Q extends true | false = HasQuery,
311
308
  NewMappedData = MappedData,
312
309
  >(
313
- options?: CommandCurrentType<
314
- ResponseType,
315
- RequestDataType,
316
- QueryParamsType,
317
- GlobalErrorType | LocalErrorType,
318
- EndpointType,
319
- ClientOptions,
310
+ options?: RequestCurrentType<
311
+ Response,
312
+ Payload,
313
+ QueryParams,
314
+ GlobalError | LocalError,
315
+ Endpoint,
316
+ AdapterOptions,
320
317
  NewMappedData
321
318
  >,
322
- mapper?: CommandMapperType<RequestDataType, NewMappedData>,
323
- ): Command<
324
- ResponseType,
325
- RequestDataType,
326
- QueryParamsType,
327
- GlobalErrorType,
328
- LocalErrorType,
329
- EndpointType,
330
- ClientOptions,
319
+ mapper?: PayloadMapperType<Payload, NewMappedData>,
320
+ ): Request<
321
+ Response,
322
+ Payload,
323
+ QueryParams,
324
+ GlobalError,
325
+ LocalError,
326
+ Endpoint,
327
+ AdapterOptions,
331
328
  D,
332
329
  P,
333
330
  Q,
334
331
  NewMappedData
335
332
  > {
336
333
  const dump = this.dump();
337
- const commandDump: CommandCurrentType<
338
- ResponseType,
339
- RequestDataType,
340
- QueryParamsType,
341
- GlobalErrorType | LocalErrorType,
342
- EndpointType,
343
- ClientOptions,
334
+ const requestDump: RequestCurrentType<
335
+ Response,
336
+ Payload,
337
+ QueryParams,
338
+ GlobalError | LocalError,
339
+ Endpoint,
340
+ AdapterOptions,
344
341
  NewMappedData
345
342
  > = {
346
343
  ...dump,
@@ -348,10 +345,7 @@ export class Command<
348
345
  abortKey: this.updatedAbortKey ? options?.abortKey || this.abortKey : undefined,
349
346
  cacheKey: this.updatedCacheKey ? options?.cacheKey || this.cacheKey : undefined,
350
347
  queueKey: this.updatedQueueKey ? options?.queueKey || this.queueKey : undefined,
351
- endpoint: this.paramsMapper(
352
- options?.params || this.params,
353
- options?.queryParams || this.queryParams,
354
- ) as EndpointType,
348
+ endpoint: this.paramsMapper(options?.params || this.params, options?.queryParams || this.queryParams) as Endpoint,
355
349
  queryParams: options?.queryParams || this.queryParams,
356
350
  // Typescript circular types issue - we have to leave any here
357
351
  data: (options?.data || this.data) as any,
@@ -359,32 +353,32 @@ export class Command<
359
353
 
360
354
  const mapperFn = (mapper || this.dataMapper) as typeof mapper;
361
355
 
362
- const cloned = new Command<
363
- ResponseType,
364
- RequestDataType,
365
- QueryParamsType,
366
- GlobalErrorType,
367
- LocalErrorType,
368
- EndpointType,
369
- ClientOptions,
356
+ const cloned = new Request<
357
+ Response,
358
+ Payload,
359
+ QueryParams,
360
+ GlobalError,
361
+ LocalError,
362
+ Endpoint,
363
+ AdapterOptions,
370
364
  D,
371
365
  P,
372
366
  Q,
373
367
  NewMappedData
374
- >(this.builder, this.commandOptions, commandDump, mapperFn);
368
+ >(this.client, this.requestOptions, requestDump, mapperFn);
375
369
 
376
370
  return cloned;
377
371
  }
378
372
 
379
373
  public abort = () => {
380
- const { commandManager } = this.builder;
381
- commandManager.abortByKey(this.abortKey);
374
+ const { requestManager } = this.client;
375
+ requestManager.abortByKey(this.abortKey);
382
376
 
383
377
  return this.clone();
384
378
  };
385
379
 
386
380
  /**
387
- * Method to use the command WITHOUT adding it to cache and queues. This mean it will make simple request without queue side effects.
381
+ * Method to use the request WITHOUT adding it to cache and queues. This mean it will make simple request without queue side effects.
388
382
  * @param options
389
383
  * @disableReturns
390
384
  * @returns
@@ -392,30 +386,30 @@ export class Command<
392
386
  * Promise<[Data | null, Error | null, HttpStatus]>
393
387
  * ```
394
388
  */
395
- public exec: FetchMethodType<
396
- Command<
397
- ResponseType,
398
- RequestDataType,
399
- QueryParamsType,
400
- GlobalErrorType,
401
- LocalErrorType,
402
- EndpointType,
403
- ClientOptions,
389
+ public exec: RequestSendType<
390
+ Request<
391
+ Response,
392
+ Payload,
393
+ QueryParams,
394
+ GlobalError,
395
+ LocalError,
396
+ Endpoint,
397
+ AdapterOptions,
404
398
  HasData,
405
399
  HasParams,
406
400
  HasQuery,
407
401
  MappedData
408
402
  >
409
403
  > = async (
410
- options?: FetchType<
411
- Command<
412
- ResponseType,
413
- RequestDataType,
414
- QueryParamsType,
415
- GlobalErrorType,
416
- LocalErrorType,
417
- EndpointType,
418
- ClientOptions,
404
+ options?: RequestSendOptionsType<
405
+ Request<
406
+ Response,
407
+ Payload,
408
+ QueryParams,
409
+ GlobalError,
410
+ LocalError,
411
+ Endpoint,
412
+ AdapterOptions,
419
413
  HasData,
420
414
  HasParams,
421
415
  HasQuery,
@@ -423,12 +417,12 @@ export class Command<
423
417
  >
424
418
  >,
425
419
  ) => {
426
- const { client } = this.builder;
427
- const command = this.clone(options as any);
420
+ const { adapter } = this.client;
421
+ const request = this.clone(options as any);
428
422
 
429
423
  const requestId = getUniqueRequestId(this.queueKey);
430
424
 
431
- return client(command, requestId);
425
+ return adapter(request, requestId);
432
426
  };
433
427
 
434
428
  /**
@@ -441,30 +435,30 @@ export class Command<
441
435
  * Promise<[Data | null, Error | null, HttpStatus]>
442
436
  * ```
443
437
  */
444
- public send: FetchMethodType<
445
- Command<
446
- ResponseType,
447
- RequestDataType,
448
- QueryParamsType,
449
- GlobalErrorType,
450
- LocalErrorType,
451
- EndpointType,
452
- ClientOptions,
438
+ public send: RequestSendType<
439
+ Request<
440
+ Response,
441
+ Payload,
442
+ QueryParams,
443
+ GlobalError,
444
+ LocalError,
445
+ Endpoint,
446
+ AdapterOptions,
453
447
  HasData,
454
448
  HasParams,
455
449
  HasQuery,
456
450
  MappedData
457
451
  >
458
452
  > = async (
459
- options?: FetchType<
460
- Command<
461
- ResponseType,
462
- RequestDataType,
463
- QueryParamsType,
464
- GlobalErrorType,
465
- LocalErrorType,
466
- EndpointType,
467
- ClientOptions,
453
+ options?: RequestSendOptionsType<
454
+ Request<
455
+ Response,
456
+ Payload,
457
+ QueryParams,
458
+ GlobalError,
459
+ LocalError,
460
+ Endpoint,
461
+ AdapterOptions,
468
462
  HasData,
469
463
  HasParams,
470
464
  HasQuery,
@@ -474,22 +468,22 @@ export class Command<
474
468
  ) => {
475
469
  const { dispatcherType, ...rest } = options || {};
476
470
 
477
- const command = this.clone(rest as any);
478
- return commandSendRequest<
479
- Command<
480
- ResponseType,
481
- RequestDataType,
482
- QueryParamsType,
483
- GlobalErrorType,
484
- LocalErrorType,
485
- EndpointType,
486
- ClientOptions,
471
+ const request = this.clone(rest as any);
472
+ return requestSendRequest<
473
+ Request<
474
+ Response,
475
+ Payload,
476
+ QueryParams,
477
+ GlobalError,
478
+ LocalError,
479
+ Endpoint,
480
+ AdapterOptions,
487
481
  HasData,
488
482
  HasParams,
489
483
  HasQuery,
490
484
  MappedData
491
485
  >
492
- >(command, options);
486
+ >(request, options);
493
487
  };
494
488
  }
495
489
 
@@ -497,32 +491,32 @@ export class Command<
497
491
  // * Typescript test cases
498
492
  // */
499
493
 
500
- // const builder = new Builder({
494
+ // const client = new Client({
501
495
  // url: "http://localhost:3000",
502
496
  // });
503
497
 
504
- // const getUsers = builder.createCommand<{ id: string }[]>()({
498
+ // const getUsers = client.createRequest<{ id: string }[]>()({
505
499
  // method: "GET",
506
500
  // endpoint: "/users",
507
501
  // });
508
502
 
509
- // const getUser = builder.createCommand<{ id: string }>()({
503
+ // const getUser = client.createRequest<{ id: string }>()({
510
504
  // method: "GET",
511
505
  // endpoint: "/users/:id",
512
506
  // });
513
507
 
514
- // const postUser = builder.createCommand<{ id: string }, { name: string }>()({
508
+ // const postUser = client.createRequest<{ id: string }, { name: string }>()({
515
509
  // method: "POST",
516
510
  // endpoint: "/users",
517
511
  // });
518
512
 
519
- // const patchUser = builder.createCommand<{ id: string }, { name: string }>()({
513
+ // const patchUser = client.createRequest<{ id: string }, { name: string }>()({
520
514
  // method: "PATCH",
521
515
  // endpoint: "/users/:id",
522
516
  // });
523
517
 
524
- // const mappedReq = builder
525
- // .createCommand<{ id: string }, { name: string }>()({
518
+ // const mappedReq = client
519
+ // .createRequest<{ id: string }, { name: string }>()({
526
520
  // method: "POST",
527
521
  // endpoint: "/users",
528
522
  // })