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