From 396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b Mon Sep 17 00:00:00 2001 From: Fuwn <50817549+Fuwn@users.noreply.github.com> Date: Sat, 24 Jan 2026 13:09:50 +0000 Subject: Initial commit Created from https://vercel.com/new --- src/lib/types.ts | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 src/lib/types.ts (limited to 'src/lib/types.ts') diff --git a/src/lib/types.ts b/src/lib/types.ts new file mode 100644 index 0000000..9c06197 --- /dev/null +++ b/src/lib/types.ts @@ -0,0 +1,143 @@ +import type { UseQueryOptions } from '@tanstack/react-query'; +import type { DATA_TYPE, OPERATORS, ROLES } from './constants'; +import type { TIME_UNIT } from './date'; + +export type ObjectValues = T[keyof T]; + +export type ReactQueryOptions = Omit, 'queryKey' | 'queryFn'>; + +export type TimeUnit = ObjectValues; +export type Role = ObjectValues; +export type DynamicDataType = ObjectValues; +export type Operator = (typeof OPERATORS)[keyof typeof OPERATORS]; + +export interface Auth { + user?: { + id: string; + username: string; + role: string; + isAdmin: boolean; + }; + shareToken?: { + websiteId: string; + }; +} + +export interface Filter { + name: string; + operator: Operator; + value: string; + type?: string; + column?: string; + prefix?: string; +} + +export interface DateRange { + startDate: Date; + endDate: Date; + value?: string; + unit?: TimeUnit; + num?: number; + offset?: number; +} + +export interface DynamicData { + [key: string]: number | string | number[] | string[]; +} + +export interface QueryOptions { + joinSession?: boolean; + columns?: Record; + limit?: number; + prefix?: string; + isCohort?: boolean; +} + +export interface QueryFilters + extends DateParams, + FilterParams, + SortParams, + PageParams, + SegmentParams { + cohortFilters?: QueryFilters; +} + +export interface DateParams { + startDate?: Date; + endDate?: Date; + unit?: string; + timezone?: string; + compareDate?: Date; +} + +export interface FilterParams { + path?: string; + referrer?: string; + title?: string; + query?: string; + host?: string; + os?: string; + browser?: string; + device?: string; + country?: string; + region?: string; + city?: string; + language?: string; + event?: string; + search?: string; + tag?: string; + eventType?: number; + segment?: string; + cohort?: string; + compare?: string; +} + +export interface SortParams { + orderBy?: string; + sortDescending?: boolean; +} + +export interface PageParams { + page?: number; + pageSize?: number; +} + +export interface SegmentParams { + segment?: string; + cohort?: string; +} + +export interface PageResult { + data: T; + count: number; + page: number; + pageSize: number; + orderBy?: string; + sortDescending?: boolean; + search?: string; +} + +export interface RealtimeData { + countries: Record; + events: any[]; + pageviews: any[]; + referrers: Record; + timestamp: number; + series: { + views: any[]; + visitors: any[]; + }; + totals: { + views: number; + visitors: number; + events: number; + countries: number; + }; + urls: Record; + visitors: any[]; +} + +export interface ApiError extends Error { + code?: string; + message: string; +} -- cgit v1.2.3