mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
Converted UTM report to a view.
This commit is contained in:
parent
06f76dda13
commit
d0d11225f4
24 changed files with 1815 additions and 1568 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { z, ZodSchema } from 'zod';
|
||||
import { z } from 'zod/v4';
|
||||
import { FILTER_COLUMNS } from '@/lib/constants';
|
||||
import { badRequest, unauthorized } from '@/lib/response';
|
||||
import { getAllowedUnits, getMinimumUnit } from '@/lib/date';
|
||||
|
|
@ -7,7 +7,7 @@ import { getWebsiteDateRange } from '@/queries';
|
|||
|
||||
export async function parseRequest(
|
||||
request: Request,
|
||||
schema?: ZodSchema,
|
||||
schema?: any,
|
||||
options?: { skipAuth: boolean },
|
||||
): Promise<any> {
|
||||
const url = new URL(request.url);
|
||||
|
|
@ -21,7 +21,7 @@ export async function parseRequest(
|
|||
const result = schema.safeParse(isGet ? query : body);
|
||||
|
||||
if (!result.success) {
|
||||
error = () => badRequest(getErrorMessages(result.error));
|
||||
error = () => badRequest(z.treeifyError(result.error));
|
||||
} else if (isGet) {
|
||||
query = result.data;
|
||||
} else {
|
||||
|
|
@ -87,13 +87,3 @@ export function getRequestFilters(query: Record<string, any>) {
|
|||
return obj;
|
||||
}, {});
|
||||
}
|
||||
|
||||
export function getErrorMessages(error: z.ZodError) {
|
||||
return Object.entries(error.format())
|
||||
.flatMap(([key, value]) => {
|
||||
if (key === '_errors') {
|
||||
return value;
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue