mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Updated types.
This commit is contained in:
parent
1e0c177fe6
commit
6b9c83381c
12 changed files with 40 additions and 43 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "umami",
|
"name": "umami",
|
||||||
"version": "2.9.0",
|
"version": "2.10.0",
|
||||||
"description": "A simple, fast, privacy-focused alternative to Google Analytics.",
|
"description": "A simple, fast, privacy-focused alternative to Google Analytics.",
|
||||||
"author": "Mike Cao <mike@mikecao.com>",
|
"author": "Mike Cao <mike@mikecao.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prisma": "5.7.0",
|
"prisma": "5.7.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-basics": "^0.117.0",
|
"react-basics": "^0.118.0",
|
||||||
"react-beautiful-dnd": "^13.1.0",
|
"react-beautiful-dnd": "^13.1.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-error-boundary": "^4.0.4",
|
"react-error-boundary": "^4.0.4",
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@ import { Button, Flexbox } from 'react-basics';
|
||||||
import useDateRange from 'components/hooks/useDateRange';
|
import useDateRange from 'components/hooks/useDateRange';
|
||||||
import { DEFAULT_DATE_RANGE } from 'lib/constants';
|
import { DEFAULT_DATE_RANGE } from 'lib/constants';
|
||||||
import useMessages from 'components/hooks/useMessages';
|
import useMessages from 'components/hooks/useMessages';
|
||||||
|
import { DateRange } from 'lib/types';
|
||||||
|
|
||||||
export function DateRangeSetting() {
|
export function DateRangeSetting() {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const [dateRange, setDateRange] = useDateRange();
|
const [dateRange, setDateRange] = useDateRange();
|
||||||
const { value } = dateRange;
|
const { value } = dateRange;
|
||||||
|
|
||||||
const handleChange = value => setDateRange(value);
|
const handleChange = (value: string | DateRange) => setDateRange(value);
|
||||||
const handleReset = () => setDateRange(DEFAULT_DATE_RANGE);
|
const handleReset = () => setDateRange(DEFAULT_DATE_RANGE);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,6 @@
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
min-height: 70px;
|
min-height: 70px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-width: min-content;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.body > div > div > div {
|
.body > div > div > div {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ export function useDateRange(websiteId?: string) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return [dateRange, saveDateRange] as [
|
return [dateRange, saveDateRange] as [
|
||||||
{ startDate: Date; endDate: Date; modified?: number },
|
{ startDate: Date; endDate: Date; modified?: number; value?: string },
|
||||||
(value: string | DateRange) => void,
|
(value: string | DateRange) => void,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,22 +46,22 @@ function getClient() {
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDateStringQuery(data, unit) {
|
function getDateStringQuery(data: any, unit: string | number) {
|
||||||
return `formatDateTime(${data}, '${CLICKHOUSE_DATE_FORMATS[unit]}')`;
|
return `formatDateTime(${data}, '${CLICKHOUSE_DATE_FORMATS[unit]}')`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDateQuery(field, unit, timezone?) {
|
function getDateQuery(field: string, unit: string, timezone?: string) {
|
||||||
if (timezone) {
|
if (timezone) {
|
||||||
return `date_trunc('${unit}', ${field}, '${timezone}')`;
|
return `date_trunc('${unit}', ${field}, '${timezone}')`;
|
||||||
}
|
}
|
||||||
return `date_trunc('${unit}', ${field})`;
|
return `date_trunc('${unit}', ${field})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDateFormat(date) {
|
function getDateFormat(date: Date) {
|
||||||
return `'${dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss')}'`;
|
return `'${dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss')}'`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapFilter(column, operator, name, type = 'String') {
|
function mapFilter(column: string, operator: string, name: string, type = 'String') {
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case OPERATORS.equals:
|
case OPERATORS.equals:
|
||||||
return `${column} = {${name}:${type}}`;
|
return `${column} = {${name}:${type}}`;
|
||||||
|
|
@ -130,12 +130,10 @@ async function rawQuery(query: string, params: Record<string, unknown> = {}): Pr
|
||||||
format: 'JSONEachRow',
|
format: 'JSONEachRow',
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await resultSet.json();
|
return resultSet.json();
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findUnique(data) {
|
async function findUnique(data: any[]) {
|
||||||
if (data.length > 1) {
|
if (data.length > 1) {
|
||||||
throw `${data.length} records found when expecting 1.`;
|
throw `${data.length} records found when expecting 1.`;
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +141,7 @@ async function findUnique(data) {
|
||||||
return findFirst(data);
|
return findFirst(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findFirst(data) {
|
async function findFirst(data: any[]) {
|
||||||
return data[0] ?? null;
|
return data[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,16 +206,14 @@ function getPageFilters(filters: SearchFilter): [
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSearchMode(): { mode?: Prisma.QueryMode } {
|
function getQueryMode(): Prisma.QueryMode {
|
||||||
const db = getDatabaseType();
|
const db = getDatabaseType();
|
||||||
|
|
||||||
if (db === POSTGRESQL) {
|
if (db === POSTGRESQL) {
|
||||||
return {
|
return 'insensitive';
|
||||||
mode: 'insensitive',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -228,6 +226,6 @@ export default {
|
||||||
getFilterQuery,
|
getFilterQuery,
|
||||||
parseFilters,
|
parseFilters,
|
||||||
getPageFilters,
|
getPageFilters,
|
||||||
getSearchMode,
|
getQueryMode,
|
||||||
rawQuery,
|
rawQuery,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,11 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
||||||
return badRequest(res, 'Data required.');
|
return badRequest(res, 'Data required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
await saveSessionData({ ...session, sessionData: eventData, sessionId: session.id });
|
await saveSessionData({
|
||||||
|
websiteId: session.websiteId,
|
||||||
|
sessionId: session.id,
|
||||||
|
sessionData: eventData,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = createToken(session, secret());
|
const token = createToken(session, secret());
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ export async function getReports(
|
||||||
): Promise<FilterResult<Report[]>> {
|
): Promise<FilterResult<Report[]>> {
|
||||||
const { query, userId, websiteId, includeTeams } = params;
|
const { query, userId, websiteId, includeTeams } = params;
|
||||||
|
|
||||||
const mode = prisma.getSearchMode();
|
const mode = prisma.getQueryMode();
|
||||||
|
|
||||||
const where: Prisma.ReportWhereInput = {
|
const where: Prisma.ReportWhereInput = {
|
||||||
userId,
|
userId,
|
||||||
|
|
@ -66,26 +66,26 @@ export async function getReports(
|
||||||
{
|
{
|
||||||
name: {
|
name: {
|
||||||
contains: query,
|
contains: query,
|
||||||
...mode,
|
mode,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: {
|
description: {
|
||||||
contains: query,
|
contains: query,
|
||||||
...mode,
|
mode,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: {
|
type: {
|
||||||
contains: query,
|
contains: query,
|
||||||
...mode,
|
mode,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
user: {
|
user: {
|
||||||
username: {
|
username: {
|
||||||
contains: query,
|
contains: query,
|
||||||
...mode,
|
mode,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -93,7 +93,7 @@ export async function getReports(
|
||||||
website: {
|
website: {
|
||||||
name: {
|
name: {
|
||||||
contains: query,
|
contains: query,
|
||||||
...mode,
|
mode,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -101,7 +101,7 @@ export async function getReports(
|
||||||
website: {
|
website: {
|
||||||
domain: {
|
domain: {
|
||||||
contains: query,
|
contains: query,
|
||||||
...mode,
|
mode,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ export async function getTeams(
|
||||||
options?: { include?: Prisma.TeamInclude },
|
options?: { include?: Prisma.TeamInclude },
|
||||||
): Promise<FilterResult<Team[]>> {
|
): Promise<FilterResult<Team[]>> {
|
||||||
const { userId, query } = filters;
|
const { userId, query } = filters;
|
||||||
const mode = prisma.getSearchMode();
|
const mode = prisma.getQueryMode();
|
||||||
|
|
||||||
const where: Prisma.TeamWhereInput = {
|
const where: Prisma.TeamWhereInput = {
|
||||||
...(userId && {
|
...(userId && {
|
||||||
|
|
@ -98,7 +98,7 @@ export async function getTeams(
|
||||||
AND: {
|
AND: {
|
||||||
OR: [
|
OR: [
|
||||||
{
|
{
|
||||||
name: { startsWith: query, ...mode },
|
name: { startsWith: query, mode },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
teamUser: {
|
teamUser: {
|
||||||
|
|
@ -107,7 +107,7 @@ export async function getTeams(
|
||||||
user: {
|
user: {
|
||||||
username: {
|
username: {
|
||||||
startsWith: query,
|
startsWith: query,
|
||||||
...mode,
|
mode,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export async function getUsers(
|
||||||
options?: { include?: Prisma.UserInclude },
|
options?: { include?: Prisma.UserInclude },
|
||||||
): Promise<FilterResult<User[]>> {
|
): Promise<FilterResult<User[]>> {
|
||||||
const { teamId, query } = params;
|
const { teamId, query } = params;
|
||||||
const mode = prisma.getSearchMode();
|
const mode = prisma.getQueryMode();
|
||||||
|
|
||||||
const where: Prisma.UserWhereInput = {
|
const where: Prisma.UserWhereInput = {
|
||||||
...(teamId && {
|
...(teamId && {
|
||||||
|
|
@ -61,7 +61,7 @@ export async function getUsers(
|
||||||
{
|
{
|
||||||
username: {
|
username: {
|
||||||
contains: query,
|
contains: query,
|
||||||
...mode,
|
mode,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ export async function getWebsites(
|
||||||
options?: { include?: Prisma.WebsiteInclude },
|
options?: { include?: Prisma.WebsiteInclude },
|
||||||
): Promise<FilterResult<Website[]>> {
|
): Promise<FilterResult<Website[]>> {
|
||||||
const { userId, teamId, includeTeams, onlyTeams, query } = filters;
|
const { userId, teamId, includeTeams, onlyTeams, query } = filters;
|
||||||
const mode = prisma.getSearchMode();
|
const mode = prisma.getQueryMode();
|
||||||
|
|
||||||
const where: Prisma.WebsiteWhereInput = {
|
const where: Prisma.WebsiteWhereInput = {
|
||||||
...(teamId && {
|
...(teamId && {
|
||||||
|
|
@ -72,10 +72,10 @@ export async function getWebsites(
|
||||||
OR: query
|
OR: query
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
name: { contains: query, ...mode },
|
name: { contains: query, mode },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
domain: { contains: query, ...mode },
|
domain: { contains: query, mode },
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: [],
|
: [],
|
||||||
|
|
|
||||||
|
|
@ -7570,10 +7570,10 @@ rc@^1.2.7:
|
||||||
minimist "^1.2.0"
|
minimist "^1.2.0"
|
||||||
strip-json-comments "~2.0.1"
|
strip-json-comments "~2.0.1"
|
||||||
|
|
||||||
react-basics@^0.117.0:
|
react-basics@^0.118.0:
|
||||||
version "0.117.0"
|
version "0.118.0"
|
||||||
resolved "https://registry.yarnpkg.com/react-basics/-/react-basics-0.117.0.tgz#f75c78acac678f6c4c8e1fdcc7e2a9f415148f1d"
|
resolved "https://registry.yarnpkg.com/react-basics/-/react-basics-0.118.0.tgz#4c00cc96f8ed0c6f95347b714e0965a7772e9c55"
|
||||||
integrity sha512-coGwL84LhNrw9kAN2REvR9i6bVs55ZnnQxlDsnH6hnj75Sp36rigGNClSwVN1XTlUWp6k+Gc4rn78cc1E/qn2g==
|
integrity sha512-DLxlWCygMX1nY1mA83qI6mFoN5oVHJFjDdhX119C+CgUIrGY5ynJmPnM5yVoholDHlOLS32npd6Pe02071X3uA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@react-spring/web" "^9.7.3"
|
"@react-spring/web" "^9.7.3"
|
||||||
classnames "^2.3.1"
|
classnames "^2.3.1"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue