finish segments, update migration from filters to parameters

This commit is contained in:
Francis Cao 2025-06-20 10:27:57 -07:00
parent 8408bbd25c
commit 5ffafc71fc
10 changed files with 25 additions and 16 deletions

View file

@ -20,8 +20,6 @@ export async function GET(request: Request, { params }: { params: Promise<{ repo
return unauthorized();
}
report.parameters = JSON.parse(report.parameters);
return json(report);
}

View file

@ -103,7 +103,7 @@ export async function POST(request: Request) {
type,
name,
description,
parameters: JSON.stringify(parameters),
parameters: parameters,
} as any);
return json(result);

View file

@ -33,7 +33,7 @@ export async function POST(
const schema = z.object({
type: segmentTypeParam,
name: z.string().max(200),
filters: z.object({}).passthrough(),
parameters: z.object({}).passthrough(),
});
const { auth, body, error } = await parseRequest(request, schema);
@ -43,7 +43,7 @@ export async function POST(
}
const { websiteId, segmentId } = await params;
const { type, name, filters } = body;
const { type, name, parameters } = body;
const segment = await getSegment(segmentId);
@ -58,7 +58,7 @@ export async function POST(
const result = await updateSegment(segmentId, {
type,
name,
filters,
parameters,
} as any);
return json(result);

View file

@ -39,7 +39,7 @@ export async function POST(
const schema = z.object({
type: segmentTypeParam,
name: z.string().max(200),
filters: z.object({}).passthrough(),
parameters: z.object({}).passthrough(),
});
const { auth, body, error } = await parseRequest(request, schema);
@ -49,7 +49,7 @@ export async function POST(
}
const { websiteId } = await params;
const { type, name, filters } = body;
const { type, name, parameters } = body;
if (!(await canUpdateWebsite(auth, websiteId))) {
return unauthorized();
@ -60,7 +60,7 @@ export async function POST(
websiteId,
type,
name,
filters,
parameters,
} as any);
return json(result);