| 1 | import type { SafeAny } from "@/types/common.d" |
| 2 | |
| 3 | export interface Log { |
| 4 | event_type: LogEventType |
| 5 | user_id: number | null |
| 6 | route: string |
| 7 | method: LogMethod |
| 8 | status_code: number |
| 9 | message: string |
| 10 | additional_info: string | null |
| 11 | timestamp: string |
| 12 | } |
| 13 | |
| 14 | export enum LogEventType { |
| 15 | ERROR = "Error", |
| 16 | INFO = "Info" |
| 17 | } |
| 18 | |
| 19 | export enum LogMethod { |
| 20 | Get = "GET", |
| 21 | Options = "OPTIONS", |
| 22 | Post = "POST" |
| 23 | } |
| 24 | |
| 25 | export type LogsQueryTimeRange = `${number}${"h" | "d" | "w"}` |
| 26 | export type LogsQueryEventType = `${LogEventType}` |
| 27 | export type LogsQuery = { userId: string } | { timeRange: LogsQueryTimeRange } | { eventType: LogsQueryEventType } |
| 28 | |
| 29 | // Extraction of keys from the union type LogsQuery |
| 30 | type KeysOfLogsQuery<T> = T extends { [K in keyof T]: SafeAny } ? keyof T : never |
| 31 | |
| 32 | // Union of values extracted from keys |
| 33 | export type LogsQueryTypes = KeysOfLogsQuery<LogsQuery> |
| 34 | export type LogsQueryValues = string | LogsQueryTimeRange | LogsQueryEventType |