807dfc539b
- Add thumbs-down feedback modal and preference API endpoint - Add AI UGC video platforms research doc - Add ReflectAd Remotion composition with public flow assets - Add gemini-ad-designer and poster-ad-designer pipeline skills - Add research_reflect_v1.1 pipeline script Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
import { auth } from "@/lib/auth";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { spawnVariations } from "@/lib/variations";
|
|
import type { AppConfig } from "@/lib/claude";
|
|
|
|
export async function GET(
|
|
_request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const session = await auth();
|
|
if (!session) return new Response("Unauthorized", { status: 401 });
|
|
|
|
const { id } = await params;
|
|
|
|
const variations = await prisma.asset.findMany({
|
|
where: { parentAssetId: id },
|
|
orderBy: { createdAt: "desc" },
|
|
});
|
|
|
|
return Response.json(variations);
|
|
}
|
|
|
|
export async function POST(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const session = await auth();
|
|
if (!session) return new Response("Unauthorized", { status: 401 });
|
|
|
|
const { id } = await params;
|
|
const body = await request.json();
|
|
const count = body.count || 5;
|
|
|
|
const asset = await prisma.asset.findUnique({
|
|
where: { id },
|
|
include: { campaign: { include: { app: true } } },
|
|
});
|
|
|
|
if (!asset) return Response.json({ error: "Not found" }, { status: 404 });
|
|
if (asset.type !== "image") {
|
|
return Response.json({ error: "Only image assets can spawn variations" }, { status: 400 });
|
|
}
|
|
|
|
// Build AppConfig if campaign has an app
|
|
let appConfig: AppConfig | undefined;
|
|
if (asset.campaign?.app) {
|
|
const app = asset.campaign.app;
|
|
appConfig = {
|
|
name: app.name,
|
|
slug: app.slug,
|
|
primaryColor: app.primaryColor,
|
|
accentColor: app.accentColor,
|
|
darkBg: app.darkBg,
|
|
assetsDir: `apps/${app.slug}`,
|
|
brandIdentity: app.brandIdentity,
|
|
productInfo: app.productInfo,
|
|
platformGuidelines: app.platformGuidelines,
|
|
stylePreferences: app.stylePreferences,
|
|
};
|
|
}
|
|
|
|
// Launch async — don't block the request
|
|
spawnVariations({ assetId: id, count, appConfig }).catch((err) =>
|
|
console.error(`Variation spawning failed for asset ${id}:`, err)
|
|
);
|
|
|
|
return Response.json({ status: "spawning", count });
|
|
}
|