@data-client/rest 0.1.0 → 0.2.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 (65) hide show
  1. package/dist/index.js +10 -14
  2. package/dist/index.umd.min.js +1 -1
  3. package/legacy/OptionsToFunction.js +1 -1
  4. package/legacy/RestEndpoint.js +5 -5
  5. package/legacy/createResource.js +8 -10
  6. package/legacy/index.js +2 -1
  7. package/legacy/next/index.js +4 -4
  8. package/legacy/resourceTypes.js +2 -0
  9. package/lib/OptionsToFunction.d.ts.map +1 -1
  10. package/lib/OptionsToFunction.js +1 -1
  11. package/lib/RestEndpoint.d.ts +29 -35
  12. package/lib/RestEndpoint.js +5 -5
  13. package/lib/createResource.d.ts +51 -31
  14. package/lib/createResource.d.ts.map +1 -1
  15. package/lib/createResource.js +7 -11
  16. package/lib/index.d.ts +3 -1
  17. package/lib/index.d.ts.map +1 -1
  18. package/lib/index.js +2 -1
  19. package/lib/next/index.d.ts +5 -5
  20. package/lib/next/index.d.ts.map +1 -1
  21. package/lib/next/index.js +4 -4
  22. package/lib/resourceTypes.d.ts.map +1 -0
  23. package/lib/resourceTypes.js +2 -0
  24. package/package.json +3 -3
  25. package/src/OptionsToFunction.ts +0 -1
  26. package/src/RestEndpoint.d.ts +29 -35
  27. package/src/RestEndpoint.js +4 -4
  28. package/src/__tests__/RestEndpoint.ts +38 -9
  29. package/src/__tests__/createResource.test.ts +3 -4
  30. package/src/__tests__/hookifyResource.ts +7 -3
  31. package/src/__tests__/types.test.ts +332 -212
  32. package/src/createResource.ts +81 -60
  33. package/src/index.ts +2 -2
  34. package/src/next/index.ts +5 -5
  35. package/ts4.0/RestEndpoint.d.ts +18 -32
  36. package/ts4.0/createResource.d.ts +59 -31
  37. package/ts4.0/index.d.ts +3 -1
  38. package/ts4.0/next/index.d.ts +5 -5
  39. package/legacy/next/OptionsToFunction.js +0 -2
  40. package/legacy/next/RestEndpoint.js +0 -225
  41. package/legacy/next/createResource.js +0 -86
  42. package/legacy/next/resourceTypes.js +0 -2
  43. package/lib/next/OptionsToFunction.d.ts +0 -7
  44. package/lib/next/OptionsToFunction.d.ts.map +0 -1
  45. package/lib/next/OptionsToFunction.js +0 -2
  46. package/lib/next/RestEndpoint.d.ts +0 -542
  47. package/lib/next/RestEndpoint.js +0 -229
  48. package/lib/next/createResource.d.ts +0 -86
  49. package/lib/next/createResource.d.ts.map +0 -1
  50. package/lib/next/createResource.js +0 -100
  51. package/lib/next/resourceTypes.d.ts.map +0 -1
  52. package/lib/next/resourceTypes.js +0 -2
  53. package/src/next/OptionsToFunction.ts +0 -41
  54. package/src/next/RestEndpoint.d.ts +0 -542
  55. package/src/next/RestEndpoint.js +0 -262
  56. package/src/next/__tests__/RestEndpoint.ts +0 -1333
  57. package/src/next/__tests__/__snapshots__/RestEndpoint.ts.snap +0 -18
  58. package/src/next/__tests__/types.test.ts +0 -429
  59. package/src/next/createResource.ts +0 -194
  60. package/ts4.0/next/OptionsToFunction.d.ts +0 -16
  61. package/ts4.0/next/RestEndpoint.d.ts +0 -226
  62. package/ts4.0/next/createResource.d.ts +0 -94
  63. /package/lib/{next/resourceTypes.d.ts → resourceTypes.d.ts} +0 -0
  64. /package/src/{next/resourceTypes.ts → resourceTypes.ts} +0 -0
  65. /package/ts4.0/{next/resourceTypes.d.ts → resourceTypes.d.ts} +0 -0
@@ -1,542 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-types */
2
- import type {
3
- EndpointExtraOptions,
4
- EndpointInstanceInterface,
5
- Schema,
6
- FetchFunction,
7
- ResolveType,
8
- } from '@data-client/endpoint';
9
-
10
- import { OptionsToFunction } from './OptionsToFunction.js';
11
- import type { ExtractCollection } from '../extractCollection.js';
12
- import { PathArgs } from '../pathTypes.js';
13
- import { EndpointUpdateFunction } from '../RestEndpointTypeHelp.js';
14
-
15
- export interface RestInstanceBase<
16
- F extends FetchFunction = FetchFunction,
17
- S extends Schema | undefined = any,
18
- M extends true | undefined = true | undefined,
19
- O extends {
20
- path: string;
21
- body?: any;
22
- searchParams?: any;
23
- } = { path: string },
24
- > extends EndpointInstanceInterface<F, S, M> {
25
- readonly body?: 'body' extends keyof O ? O['body'] : any;
26
- readonly searchParams?: 'searchParams' extends keyof O
27
- ? O['searchParams']
28
- : // unknown is identity with '&' type operator
29
- unknown;
30
-
31
- /** Pattern to construct url based on Url Parameters
32
- * @see https://resthooks.io/rest/api/RestEndpoint#path
33
- */
34
- readonly path: O['path'];
35
- /** Prepended to all urls
36
- * @see https://resthooks.io/rest/api/RestEndpoint#urlPrefix
37
- */
38
- readonly urlPrefix: string;
39
- readonly requestInit: RequestInit;
40
- readonly method: string;
41
- readonly signal: AbortSignal | undefined;
42
-
43
- /* fetch lifecycles */
44
- /* before-fetch */
45
- url(...args: Parameters<F>): string;
46
- /** @see https://resthooks.io/rest/api/RestEndpoint#getRequestInit */
47
- getRequestInit(
48
- this: any,
49
- body?: RequestInit['body'] | Record<string, unknown>,
50
- ): Promise<RequestInit> | RequestInit;
51
- /** @see https://resthooks.io/rest/api/RestEndpoint#getHeaders */
52
- getHeaders(headers: HeadersInit): Promise<HeadersInit> | HeadersInit;
53
- /* after-fetch */
54
- /** @see https://resthooks.io/rest/api/RestEndpoint#fetchResponse */
55
- fetchResponse(input: RequestInfo, init: RequestInit): Promise<Response>;
56
- /** @see https://resthooks.io/rest/api/RestEndpoint#parseResponse */
57
- parseResponse(response: Response): Promise<any>;
58
- /** @see https://resthooks.io/rest/api/RestEndpoint#process */
59
- process(value: any, ...args: Parameters<F>): ResolveType<F>;
60
-
61
- /* utilities */
62
- /** @see https://resthooks.io/rest/api/RestEndpoint#testKey */
63
- testKey(key: string): boolean;
64
-
65
- /* extenders */
66
- // TODO: figure out better way than wrapping whole options in Readonly<> + making O extend from {}
67
- // this is just a hack to handle when no members of PartialRestGenerics are present
68
- // Note: Using overloading (like paginated did) struggles because typescript does not have a clear way of distinguishing one
69
- // should be used from the other (due to same problem with every member being partial)
70
- extend<E extends RestInstanceBase, O extends PartialRestGenerics | {}>(
71
- this: E,
72
- options: Readonly<RestEndpointExtendOptions<O, E, F> & O>,
73
- ): RestExtendedEndpoint<O, E>;
74
- paginated<
75
- E extends RestInstanceBase<FetchFunction, any, undefined>,
76
- A extends any[],
77
- >(
78
- this: E,
79
- removeCursor: (...args: A) => readonly [...Parameters<E>],
80
- ): PaginationEndpoint<E, A>;
81
- paginated<
82
- E extends RestInstanceBase<FetchFunction, any, undefined>,
83
- C extends string,
84
- >(
85
- this: E,
86
- cursorField: C,
87
- ): PaginationFieldEndpoint<E, C>;
88
- }
89
-
90
- export interface RestInstance<
91
- F extends FetchFunction = FetchFunction,
92
- S extends Schema | undefined = any,
93
- M extends true | undefined = true | undefined,
94
- O extends {
95
- path: string;
96
- body?: any;
97
- searchParams?: any;
98
- } = { path: string },
99
- > extends RestInstanceBase<F, S, M, O> {
100
- push: AddEndpoint<F, S, O>;
101
- unshift: AddEndpoint<F, S, O>;
102
- assign: AddEndpoint<F, S, O>;
103
- }
104
-
105
- export type RestEndpointExtendOptions<
106
- O extends PartialRestGenerics,
107
- E extends RestInstanceBase,
108
- F extends FetchFunction,
109
- > = RestEndpointOptions<
110
- OptionsToFunction<O, E, F>,
111
- 'schema' extends keyof O
112
- ? Extract<O['schema'], Schema | undefined>
113
- : E['schema']
114
- > &
115
- Partial<Omit<E, KeyofRestEndpoint | keyof PartialRestGenerics>>;
116
-
117
- type OptionsToRestEndpoint<
118
- O extends PartialRestGenerics,
119
- E extends RestInstanceBase & { body?: any },
120
- F extends FetchFunction,
121
- > = 'path' extends keyof O
122
- ? RestType<
123
- 'searchParams' extends keyof O
124
- ? O['searchParams'] extends undefined
125
- ? PathArgs<Exclude<O['path'], undefined>>
126
- : O['searchParams'] & PathArgs<Exclude<O['path'], undefined>>
127
- : PathArgs<Exclude<O['path'], undefined>>,
128
- 'body' extends keyof O ? O['body'] : E['body'],
129
- 'schema' extends keyof O ? O['schema'] : E['schema'],
130
- 'method' extends keyof O ? MethodToSide<O['method']> : E['sideEffect'],
131
- O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>,
132
- {
133
- path: Exclude<O['path'], undefined>;
134
- body: 'body' extends keyof O ? O['body'] : E['body'];
135
- searchParams: 'searchParams' extends keyof O
136
- ? O['searchParams']
137
- : E['searchParams'];
138
- }
139
- >
140
- : 'body' extends keyof O
141
- ? RestType<
142
- 'searchParams' extends keyof O
143
- ? O['searchParams'] extends undefined
144
- ? PathArgs<Exclude<O['path'], undefined>>
145
- : O['searchParams'] & PathArgs<Exclude<E['path'], undefined>>
146
- : PathArgs<Exclude<E['path'], undefined>>,
147
- O['body'],
148
- 'schema' extends keyof O ? O['schema'] : E['schema'],
149
- 'method' extends keyof O ? MethodToSide<O['method']> : E['sideEffect'],
150
- O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>,
151
- {
152
- path: E['path'];
153
- body: O['body'];
154
- searchParams: 'searchParams' extends keyof O
155
- ? O['searchParams']
156
- : E['searchParams'];
157
- }
158
- >
159
- : 'searchParams' extends keyof O
160
- ? RestType<
161
- O['searchParams'] extends undefined
162
- ? PathArgs<Exclude<O['path'], undefined>>
163
- : O['searchParams'] & PathArgs<Exclude<E['path'], undefined>>,
164
- E['body'],
165
- 'schema' extends keyof O ? O['schema'] : E['schema'],
166
- 'method' extends keyof O ? MethodToSide<O['method']> : E['sideEffect'],
167
- O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>,
168
- {
169
- path: E['path'];
170
- body: E['body'];
171
- searchParams: O['searchParams'];
172
- }
173
- >
174
- : RestInstance<
175
- F,
176
- 'schema' extends keyof O ? O['schema'] : E['schema'],
177
- 'method' extends keyof O ? MethodToSide<O['method']> : E['sideEffect'],
178
- {
179
- path: 'path' extends keyof O
180
- ? Exclude<O['path'], undefined>
181
- : E['path'];
182
- body: 'body' extends keyof O ? O['body'] : E['body'];
183
- searchParams: 'searchParams' extends keyof O
184
- ? O['searchParams']
185
- : E['searchParams'];
186
- }
187
- >;
188
-
189
- export type RestExtendedEndpoint<
190
- O extends PartialRestGenerics,
191
- E extends RestInstanceBase,
192
- > = OptionsToRestEndpoint<
193
- O,
194
- E,
195
- RestInstance<
196
- (
197
- ...args: Parameters<E>
198
- ) => O['process'] extends {}
199
- ? Promise<ReturnType<O['process']>>
200
- : ReturnType<E>,
201
- 'schema' extends keyof O ? O['schema'] : E['schema'],
202
- 'method' extends keyof O ? MethodToSide<O['method']> : E['sideEffect']
203
- >
204
- > &
205
- Omit<O, KeyofRestEndpoint> &
206
- Omit<E, KeyofRestEndpoint | keyof O>;
207
-
208
- export interface PartialRestGenerics {
209
- readonly path?: string;
210
- readonly schema?: Schema | undefined;
211
- readonly method?: string;
212
- /** Only used for types */
213
- readonly body?: any;
214
- /** Only used for types */
215
- readonly searchParams?: any;
216
- /** @see https://resthooks.io/rest/api/RestEndpoint#process */
217
- process?(value: any, ...args: any): any;
218
- }
219
- export interface RestGenerics extends PartialRestGenerics {
220
- readonly path: string;
221
- }
222
-
223
- export type PaginationEndpoint<
224
- E extends RestInstanceBase,
225
- A extends any[],
226
- > = RestInstance<
227
- ParamFetchNoBody<A[0], ResolveType<E>>,
228
- E['schema'],
229
- E['sideEffect'],
230
- Pick<E, 'path' | 'searchParams' | 'body'> & {
231
- searchParams: Omit<A[0], keyof PathArgs<E['path']>>;
232
- }
233
- >;
234
- export type PaginationFieldEndpoint<
235
- E extends RestInstanceBase,
236
- C extends string,
237
- > = RestInstance<
238
- ParamFetchNoBody<
239
- { [K in C]: string | number | boolean } & E['searchParams'] &
240
- PathArgs<Exclude<E['path'], undefined>>,
241
- ResolveType<E>
242
- >,
243
- E['schema'],
244
- E['sideEffect'],
245
- Pick<E, 'path' | 'searchParams' | 'body'> & {
246
- searchParams: { [K in C]: string | number | boolean } & E['searchParams'];
247
- }
248
- >;
249
- export type AddEndpoint<
250
- F extends FetchFunction = FetchFunction,
251
- S extends Schema | undefined = any,
252
- O extends {
253
- path: string;
254
- body?: any;
255
- searchParams?: any;
256
- } = { path: string },
257
- > = RestInstanceBase<
258
- RestFetch<
259
- 'searchParams' extends keyof O
260
- ? O['searchParams'] extends undefined
261
- ? PathArgs<Exclude<O['path'], undefined>>
262
- : O['searchParams'] & PathArgs<Exclude<O['path'], undefined>>
263
- : PathArgs<Exclude<O['path'], undefined>>,
264
- any,
265
- ReturnType<F>
266
- >,
267
- ExtractCollection<S>,
268
- true,
269
- Omit<O, 'body'>
270
- > & { method: 'POST' };
271
-
272
- export type BodyDefault<O extends RestGenerics> = 'body' extends keyof O
273
- ? O['body']
274
- : O['method'] extends 'POST' | 'PUT' | 'PATCH'
275
- ? Record<string, unknown> | FormData
276
- : undefined;
277
-
278
- type OptionsBodyDefault<O extends RestGenerics> = 'body' extends keyof O
279
- ? O
280
- : O['method'] extends 'POST' | 'PUT' | 'PATCH'
281
- ? O & { body: any }
282
- : O & { body: undefined };
283
-
284
- export interface RestEndpointOptions<
285
- F extends FetchFunction = FetchFunction,
286
- S extends Schema | undefined = undefined,
287
- > extends EndpointExtraOptions<F> {
288
- urlPrefix?: string;
289
- requestInit?: RequestInit;
290
- getHeaders?(headers: HeadersInit): Promise<HeadersInit> | HeadersInit;
291
- getRequestInit?(body: any): Promise<RequestInit> | RequestInit;
292
- fetchResponse?(input: RequestInfo, init: RequestInit): Promise<any>;
293
- parseResponse?(response: Response): Promise<any>;
294
-
295
- sideEffect?: true | undefined;
296
- name?: string;
297
- signal?: AbortSignal;
298
- fetch?: F;
299
- key?(...args: Parameters<F>): string;
300
- url?(...args: Parameters<F>): string;
301
- update?: EndpointUpdateFunction<F, S>;
302
- }
303
-
304
- export type RestEndpointConstructorOptions<O extends RestGenerics = any> =
305
- RestEndpointOptions<
306
- RestFetch<
307
- 'searchParams' extends keyof O
308
- ? O['searchParams'] extends undefined
309
- ? PathArgs<O['path']>
310
- : O['searchParams'] & PathArgs<O['path']>
311
- : PathArgs<O['path']>,
312
- BodyDefault<O>,
313
- O['process'] extends {}
314
- ? ReturnType<O['process']>
315
- : any /*Denormalize<O['schema']>*/
316
- >,
317
- O['schema']
318
- >;
319
-
320
- export interface RestEndpointConstructor {
321
- new <O extends RestGenerics = any>({
322
- method,
323
- sideEffect,
324
- name,
325
- ...options
326
- }: RestEndpointConstructorOptions<O> & Readonly<O>): RestInstance<
327
- RestFetch<
328
- 'searchParams' extends keyof O
329
- ? O['searchParams'] extends undefined
330
- ? PathArgs<O['path']>
331
- : O['searchParams'] & PathArgs<O['path']>
332
- : PathArgs<O['path']>,
333
- BodyDefault<O>,
334
- O['process'] extends {}
335
- ? ReturnType<O['process']>
336
- : any /*Denormalize<O['schema']>*/
337
- >,
338
- 'schema' extends keyof O ? O['schema'] : undefined,
339
- MethodToSide<O['method']>,
340
- OptionsBodyDefault<O>
341
- >;
342
- readonly prototype: RestInstanceBase;
343
- }
344
-
345
- /** Simplifies endpoint definitions that follow REST patterns
346
- *
347
- * @see https://resthooks.io/rest/api/RestEndpoint
348
- */
349
- export declare let RestEndpoint: RestEndpointConstructor;
350
- export default RestEndpoint;
351
-
352
- export type MethodToSide<M> = M extends string
353
- ? M extends 'GET'
354
- ? undefined
355
- : true
356
- : undefined;
357
-
358
- /** RestEndpoint types simplified */
359
- export type RestType<
360
- UrlParams = any,
361
- Body = any,
362
- S extends Schema | undefined = Schema | undefined,
363
- M extends true | undefined = true | undefined,
364
- R = any,
365
- O extends {
366
- path: string;
367
- body?: any;
368
- searchParams?: any;
369
- } = { path: string },
370
- // eslint-disable-next-line @typescript-eslint/ban-types
371
- > = IfTypeScriptLooseNull<
372
- RestInstance<
373
- keyof UrlParams extends never
374
- ? (this: EndpointInstanceInterface, body?: Body) => Promise<R>
375
- : // even with loose null, this will only be true when all members are optional
376
- {} extends UrlParams
377
- ?
378
- | ((this: EndpointInstanceInterface, body?: Body) => Promise<R>)
379
- | ((
380
- this: EndpointInstanceInterface,
381
- params: UrlParams,
382
- body?: Body,
383
- ) => Promise<R>)
384
- : (
385
- this: EndpointInstanceInterface,
386
- params: UrlParams,
387
- body?: Body,
388
- ) => Promise<R>,
389
- S,
390
- M,
391
- O
392
- >,
393
- Body extends {}
394
- ? RestTypeWithBody<UrlParams, S, M, Body, R, O>
395
- : RestTypeNoBody<UrlParams, S, M, R, O>
396
- >;
397
-
398
- export type RestTypeWithBody<
399
- UrlParams = any,
400
- S extends Schema | undefined = Schema | undefined,
401
- M extends true | undefined = true | undefined,
402
- Body = any,
403
- R = any /*Denormalize<S>*/,
404
- O extends {
405
- path: string;
406
- body?: any;
407
- searchParams?: any;
408
- } = { path: string; body: any },
409
- > = RestInstance<ParamFetchWithBody<UrlParams, Body, R>, S, M, O>;
410
-
411
- export type RestTypeNoBody<
412
- UrlParams = any,
413
- S extends Schema | undefined = Schema | undefined,
414
- M extends true | undefined = true | undefined,
415
- R = any /*Denormalize<S>*/,
416
- O extends {
417
- path: string;
418
- body?: undefined;
419
- searchParams?: any;
420
- } = { path: string; body: undefined },
421
- > = RestInstance<ParamFetchNoBody<UrlParams, R>, S, M, O>;
422
-
423
- /** Simple parameters, and body fetch functions */
424
- export type RestFetch<
425
- UrlParams,
426
- // eslint-disable-next-line @typescript-eslint/ban-types
427
- Body = {},
428
- Resolve = any,
429
- > = IfTypeScriptLooseNull<
430
- | ParamFetchNoBody<UrlParams, Resolve>
431
- | ParamFetchWithBody<UrlParams, Body, Resolve>,
432
- Body extends {}
433
- ? ParamFetchWithBody<UrlParams, Body, Resolve>
434
- : ParamFetchNoBody<UrlParams, Resolve>
435
- >;
436
-
437
- export type ParamFetchWithBody<P, B = {}, R = any> =
438
- // we must always allow undefined in a union and give it a type without params
439
- P extends undefined
440
- ? (this: EndpointInstanceInterface, body: B) => Promise<R>
441
- : // even with loose null, this will only be true when all members are optional
442
- {} extends P
443
- ? // this safely handles PathArgs with no members that results in a simple `unknown` type
444
- keyof P extends never
445
- ? (this: EndpointInstanceInterface, body: B) => Promise<R>
446
- :
447
- | ((
448
- this: EndpointInstanceInterface,
449
- params: P,
450
- body: B,
451
- ) => Promise<R>)
452
- | ((this: EndpointInstanceInterface, body: B) => Promise<R>)
453
- : (this: EndpointInstanceInterface, params: P, body: B) => Promise<R>;
454
-
455
- export type ParamFetchNoBody<P, R = any> =
456
- // we must always allow undefined in a union and give it a type without params
457
- P extends undefined
458
- ? (this: EndpointInstanceInterface) => Promise<R>
459
- : // even with loose null, this will only be true when all members are optional
460
- {} extends P
461
- ? // this safely handles PathArgs with no members that results in a simple `unknown` type
462
- keyof P extends never
463
- ? (this: EndpointInstanceInterface) => Promise<R>
464
- :
465
- | ((this: EndpointInstanceInterface, params: P) => Promise<R>)
466
- | ((this: EndpointInstanceInterface) => Promise<R>)
467
- : (this: EndpointInstanceInterface, params: P) => Promise<R>;
468
-
469
- type IfTypeScriptLooseNull<Y, N> = 1 | undefined extends 1 ? Y : N;
470
-
471
- export type KeyofRestEndpoint = keyof RestInstance;
472
-
473
- export type FromFallBack<K extends keyof E, O, E> = K extends keyof O
474
- ? O[K]
475
- : E[K];
476
-
477
- export type FetchMutate<
478
- A extends readonly any[] = // eslint-disable-next-line @typescript-eslint/ban-types
479
- | [any, {}]
480
- // eslint-disable-next-line @typescript-eslint/ban-types
481
- | [{}],
482
- R = any,
483
- > = (this: RestInstance, ...args: A) => Promise<R>;
484
-
485
- export type FetchGet<A extends readonly any[] = [any], R = any> = (
486
- this: RestInstance,
487
- ...args: A
488
- ) => Promise<R>;
489
-
490
- export type Defaults<O, D> = {
491
- [K in keyof O | keyof D]: K extends keyof O
492
- ? Exclude<O[K], undefined>
493
- : D[Extract<K, keyof D>];
494
- };
495
-
496
- export type GetEndpoint<
497
- O extends {
498
- readonly path: string;
499
- readonly schema: Schema;
500
- /** Only used for types */
501
- readonly searchParams?: any;
502
- } = {
503
- path: string;
504
- schema: Schema;
505
- },
506
- > = RestTypeNoBody<
507
- 'searchParams' extends keyof O
508
- ? O['searchParams'] extends undefined
509
- ? PathArgs<O['path']>
510
- : O['searchParams'] & PathArgs<O['path']>
511
- : PathArgs<O['path']>,
512
- O['schema'],
513
- undefined,
514
- any,
515
- O & { body: undefined }
516
- >;
517
-
518
- export type MutateEndpoint<
519
- O extends {
520
- readonly path: string;
521
- readonly schema: Schema;
522
- /** Only used for types */
523
- readonly searchParams?: any;
524
- /** Only used for types */
525
- readonly body?: any;
526
- } = {
527
- path: string;
528
- body: any;
529
- schema: Schema;
530
- },
531
- > = RestTypeWithBody<
532
- 'searchParams' extends keyof O
533
- ? O['searchParams'] extends undefined
534
- ? PathArgs<O['path']>
535
- : O['searchParams'] & PathArgs<O['path']>
536
- : PathArgs<O['path']>,
537
- O['schema'],
538
- true,
539
- O['body'],
540
- any,
541
- O
542
- >;