mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 21:57:16 +01:00
Refactor filter handling for queries.
This commit is contained in:
parent
5b300f1ff5
commit
ee6c68d27c
107 changed files with 731 additions and 835 deletions
119
src/lib/types.ts
119
src/lib/types.ts
|
|
@ -1,45 +1,16 @@
|
|||
import { Dispatch, SetStateAction } from 'react';
|
||||
import { UseQueryOptions } from '@tanstack/react-query';
|
||||
import { DATA_TYPE, PERMISSIONS, ROLES } from './constants';
|
||||
import { TIME_UNIT } from './date';
|
||||
|
||||
export type ObjectValues<T> = T[keyof T];
|
||||
|
||||
export type ReactQueryOptions<T> = Omit<UseQueryOptions<T, Error, T>, 'queryKey' | 'queryFn'>;
|
||||
export type ReactQueryOptions<T = any> = Omit<UseQueryOptions<T, Error, T>, 'queryKey' | 'queryFn'>;
|
||||
|
||||
export type TimeUnit = ObjectValues<typeof TIME_UNIT>;
|
||||
export type Permission = ObjectValues<typeof PERMISSIONS>;
|
||||
export type Role = ObjectValues<typeof ROLES>;
|
||||
export type DynamicDataType = ObjectValues<typeof DATA_TYPE>;
|
||||
|
||||
export interface PageParams {
|
||||
search?: string;
|
||||
page?: string | number;
|
||||
pageSize?: string;
|
||||
orderBy?: string;
|
||||
sortDescending?: boolean;
|
||||
}
|
||||
|
||||
export interface PageResult<T> {
|
||||
data: T;
|
||||
count: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
orderBy?: string;
|
||||
sortDescending?: boolean;
|
||||
}
|
||||
|
||||
export interface PagedQueryResult<T = any> {
|
||||
result: PageResult<T>;
|
||||
query: any;
|
||||
params: PageParams;
|
||||
setParams: Dispatch<SetStateAction<T | PageParams>>;
|
||||
}
|
||||
|
||||
export interface DynamicData {
|
||||
[key: string]: number | string | number[] | string[];
|
||||
}
|
||||
|
||||
export interface Auth {
|
||||
user?: {
|
||||
id: string;
|
||||
|
|
@ -54,20 +25,35 @@ export interface Auth {
|
|||
}
|
||||
|
||||
export interface DateRange {
|
||||
value: string;
|
||||
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<string, string>;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export interface QueryFilters {
|
||||
websiteId?: string;
|
||||
// Date range
|
||||
startDate?: Date;
|
||||
endDate?: Date;
|
||||
timezone?: string;
|
||||
compareStartDate?: Date;
|
||||
compareEndDate?: Date;
|
||||
compare?: string;
|
||||
unit?: string;
|
||||
eventType?: number;
|
||||
timezone?: string;
|
||||
// Filters
|
||||
path?: string;
|
||||
referrer?: string;
|
||||
title?: string;
|
||||
|
|
@ -83,54 +69,29 @@ export interface QueryFilters {
|
|||
event?: string;
|
||||
search?: string;
|
||||
tag?: string;
|
||||
eventType?: number;
|
||||
// Paging
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
// Sorting
|
||||
orderBy?: string;
|
||||
sortDescending?: boolean;
|
||||
}
|
||||
|
||||
export interface QueryOptions {
|
||||
joinSession?: boolean;
|
||||
columns?: { [key: string]: string };
|
||||
limit?: number;
|
||||
export interface PageParams {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
orderBy?: string;
|
||||
sortDescending?: boolean;
|
||||
search?: string;
|
||||
}
|
||||
|
||||
export interface RealtimeData {
|
||||
countries: { [key: string]: number };
|
||||
events: any[];
|
||||
pageviews: any[];
|
||||
referrers: { [key: string]: number };
|
||||
timestamp: number;
|
||||
series: {
|
||||
views: any[];
|
||||
visitors: any[];
|
||||
};
|
||||
totals: {
|
||||
views: number;
|
||||
visitors: number;
|
||||
events: number;
|
||||
countries: number;
|
||||
};
|
||||
urls: { [key: string]: number };
|
||||
visitors: any[];
|
||||
}
|
||||
|
||||
export interface SessionData {
|
||||
id: string;
|
||||
websiteId: string;
|
||||
visitId: string;
|
||||
hostname: string;
|
||||
browser: string;
|
||||
os: string;
|
||||
device: string;
|
||||
screen: string;
|
||||
language: string;
|
||||
country: string;
|
||||
region: string;
|
||||
city: string;
|
||||
ip?: string;
|
||||
userAgent?: string;
|
||||
}
|
||||
|
||||
export interface InputItem {
|
||||
id: string;
|
||||
label: string;
|
||||
icon: any;
|
||||
seperator?: boolean;
|
||||
export interface PageResult<T> {
|
||||
data: T;
|
||||
count: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
orderBy?: string;
|
||||
sortDescending?: boolean;
|
||||
search?: string;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue