mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
tighten zod validation for segment parameters
Some checks are pending
Node.js CI / build (push) Waiting to run
Some checks are pending
Node.js CI / build (push) Waiting to run
This commit is contained in:
parent
6fd428683d
commit
d4ff7c8e3f
2 changed files with 38 additions and 2 deletions
|
|
@ -104,6 +104,23 @@ export const reportTypeParam = z.enum([
|
|||
'utm',
|
||||
]);
|
||||
|
||||
export const operatorParam = z.enum([
|
||||
'eq',
|
||||
'neq',
|
||||
's',
|
||||
'ns',
|
||||
'c',
|
||||
'dnc',
|
||||
't',
|
||||
'f',
|
||||
'gt',
|
||||
'lt',
|
||||
'gte',
|
||||
'lte',
|
||||
'bf',
|
||||
'af',
|
||||
]);
|
||||
|
||||
export const goalReportSchema = z.object({
|
||||
type: z.literal('goal'),
|
||||
parameters: z
|
||||
|
|
@ -231,3 +248,22 @@ export const reportResultSchema = z.intersection(
|
|||
);
|
||||
|
||||
export const segmentTypeParam = z.enum(['segment', 'cohort']);
|
||||
|
||||
export const segmentParametersSchema = z.object({
|
||||
filters: z
|
||||
.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
operator: operatorParam,
|
||||
value: z.string(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
dateRange: z.string().optional(),
|
||||
action: z
|
||||
.object({
|
||||
type: z.string(),
|
||||
value: z.string(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue