Fixed report validations.
This commit is contained in:
@@ -10,16 +10,23 @@ export async function POST(request: Request) {
|
|||||||
...reportParms,
|
...reportParms,
|
||||||
goals: z
|
goals: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z
|
||||||
type: z.string().regex(/url|event|event-data/),
|
.object({
|
||||||
value: z.string(),
|
type: z.string().regex(/url|event|event-data/),
|
||||||
goal: z.number(),
|
value: z.string(),
|
||||||
operator: z
|
goal: z.coerce.number(),
|
||||||
.string()
|
operator: z
|
||||||
.regex(/count|sum|average/)
|
.string()
|
||||||
.refine(data => data['type'] === 'event-data'),
|
.regex(/count|sum|average/)
|
||||||
property: z.string().refine(data => data['type'] === 'event-data'),
|
.optional(),
|
||||||
}),
|
property: z.string().optional(),
|
||||||
|
})
|
||||||
|
.refine(data => {
|
||||||
|
if (data['type'] === 'event-data') {
|
||||||
|
return data['operator'] && data['property'];
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
.min(1),
|
.min(1),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { getReports, createReport } from 'queries';
|
|||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
|
websiteId: z.string().uuid().optional(),
|
||||||
|
teamId: z.string().uuid().optional(),
|
||||||
...pagingParams,
|
...pagingParams,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user