update segmentParamSchema, add typing to getEntity
This commit is contained in:
@@ -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);
|
||||
|
||||
+2
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user