mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
update segmentParamSchema, add typing to getEntity
This commit is contained in:
parent
d4ff7c8e3f
commit
f4eaa9fd0d
3 changed files with 5 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ import { z } from 'zod';
|
|||
import { uuid } from '@/lib/crypto';
|
||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||
import { json, unauthorized } from '@/lib/response';
|
||||
import { searchParams, segmentParametersSchema, segmentTypeParam } from '@/lib/schema';
|
||||
import { searchParams, segmentParamSchema, segmentTypeParam } from '@/lib/schema';
|
||||
import { canUpdateWebsite, canViewWebsite } from '@/permissions';
|
||||
import { createSegment, getWebsiteSegments } from '@/queries/prisma';
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ export async function POST(
|
|||
const schema = z.object({
|
||||
type: segmentTypeParam,
|
||||
name: z.string().max(200),
|
||||
parameters: segmentParametersSchema,
|
||||
parameters: segmentParamSchema,
|
||||
});
|
||||
|
||||
const { auth, body, error } = await parseRequest(request, schema);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import type { Link, Pixel, Website } from '@/generated/prisma/client';
|
||||
import { getLink, getPixel, getWebsite } from '@/queries/prisma';
|
||||
|
||||
export async function getEntity(entityId: string) {
|
||||
export async function getEntity(entityId: string): Promise<Website | Link | Pixel | null> {
|
||||
const website = await getWebsite(entityId);
|
||||
const link = await getLink(entityId);
|
||||
const pixel = await getPixel(entityId);
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ export const reportResultSchema = z.intersection(
|
|||
|
||||
export const segmentTypeParam = z.enum(['segment', 'cohort']);
|
||||
|
||||
export const segmentParametersSchema = z.object({
|
||||
export const segmentParamSchema = z.object({
|
||||
filters: z
|
||||
.array(
|
||||
z.object({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue