-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadditional.ts
More file actions
31 lines (28 loc) · 1.01 KB
/
additional.ts
File metadata and controls
31 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { DevupApiServers } from './api-struct'
import type { Middleware } from './middleware'
export type Additional<
T extends string,
Target extends object,
> = T extends keyof Target ? Target[T] & object : object
export type RequiredOptions<T extends object> = keyof T extends undefined
? never
: 'params' extends keyof T
? T
: 'query' extends keyof T
? T
: 'body' extends keyof T
? T
: never
export type IsCold = keyof DevupApiServers extends never ? true : false
export type DevupApiRequestInit = Omit<RequestInit, 'body'> & {
body?: object | RequestInit['body']
params?: Record<string, string | number | boolean | null | undefined>
query?:
| ConstructorParameters<typeof URLSearchParams>[0]
| Record<string, string | number | (number | string)[]>
middleware?: Middleware[]
}
// biome-ignore lint/suspicious/noExplicitAny: any is used to allow for flexibility in the type
export type ExtractValue<T, V extends string, F = any> = V extends keyof T
? T[V]
: F