37 lines
1,000 B
TypeScript
37 lines
1,000 B
TypeScript
import type { JsonValue } from '@std/json'
|
|
|
|
export type UUID = `${string}-${string}-${string}-${string}-${string}`
|
|
export type DateString =
|
|
`${number}-${number}-${number}T${number}:${number}:${number}.${number}Z"`
|
|
export type Login = `${string}.${string}`
|
|
export type MailAddress = `${string}@${string}.${string}`
|
|
|
|
export type ToJson<T> = T extends JsonValue ? T
|
|
: T extends { toJSON(): unknown } ? ReturnType<T['toJSON']>
|
|
: T extends { toJSON(): unknown }[]
|
|
? { [K: number]: ReturnType<T[typeof K]['toJSON']> }
|
|
: never
|
|
|
|
export type MethodOf<T, K extends keyof T> = {
|
|
[P in keyof Pick<T, T[K] extends CallableFunction ? K : never>]: never
|
|
}
|
|
|
|
export type Serializable<T extends object> = {
|
|
[key in Exclude<keyof T, 'toJSON' | 'toString' | 'toPrimitive' | 'valueOf'>]:
|
|
ToJson<T[key]>
|
|
}
|
|
|
|
export type Posix = {
|
|
id: number
|
|
home: string
|
|
shell: string
|
|
}
|
|
|
|
export type Base64String = `${string}`
|
|
export type UrlString = `${
|
|
| 'data:'
|
|
| 'file://'
|
|
| 'http://'
|
|
| 'https://'
|
|
| 'git:'}${string}`
|