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