From f81f1eaa08550311ea163b88181e57e93638142a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20Kadir=20Ak=C4=B1n?= Date: Sat, 24 Jan 2026 17:11:58 +0300 Subject: [PATCH] chore(prisma): remove seed-flows.ts and its seeding functionality --- prisma/seed-flows.ts | 327 ------------------- src/app/[username]/page.tsx | 7 +- src/app/api/prompts/route.ts | 7 +- src/app/categories/[slug]/page.tsx | 7 +- src/app/collection/page.tsx | 7 +- src/app/feed/page.tsx | 7 +- src/app/prompts/page.tsx | 7 +- src/app/skills/page.tsx | 7 +- src/app/tags/[slug]/page.tsx | 7 +- src/app/workflows/page.tsx | 7 +- src/components/prompts/discovery-prompts.tsx | 7 +- 11 files changed, 60 insertions(+), 337 deletions(-) delete mode 100644 prisma/seed-flows.ts diff --git a/prisma/seed-flows.ts b/prisma/seed-flows.ts deleted file mode 100644 index 18959f81..00000000 --- a/prisma/seed-flows.ts +++ /dev/null @@ -1,327 +0,0 @@ -import { PrismaClient } from "@prisma/client"; -import bcrypt from "bcryptjs"; - -const prisma = new PrismaClient(); - -/** - * Generate a cuid-like ID - */ -function generateId(): string { - const timestamp = Date.now().toString(36); - const randomPart = Math.random().toString(36).substring(2, 15); - return `cm${timestamp}${randomPart}`.substring(0, 25); -} - -/** - * Seed script for testing prompt flows with branchy structure - * Run with: npx ts-node prisma/seed-flows.ts - */ -async function main() { - console.log("🌱 Seeding flow test data for user f1..."); - - const password = await bcrypt.hash("password123", 12); - - // Create or get user f1 - const user = await prisma.user.upsert({ - where: { username: "f" }, - update: {}, - create: { - email: "f@prompts.chat", - username: "f", - name: "Flow Tester", - password: password, - role: "USER", - locale: "en", - }, - }); - - console.log("āœ… User f1 ready"); - - // Create a category for flow prompts - const category = await prisma.category.upsert({ - where: { slug: "workflows" }, - update: {}, - create: { - name: "Workflows", - slug: "workflows", - icon: "šŸ”—", - order: 100, - }, - }); - - // Create prompts for a branchy flow structure - // - // Flow structure: - // - // [1. Start: Idea Generation] - // | - // (brainstorm complete) - // | - // [2. Outline Creation] - // | - // +---------------+---------------+ - // | | - // (technical path) (creative path) - // | | - // [3a. Technical Deep Dive] [3b. Creative Exploration] - // | | - // (analysis done) (ideas ready) - // | | - // [4a. Implementation Plan] [4b. Story Development] - // | | - // +---------------+---------------+ - // | - // (merge results) - // | - // [5. Final Review] - // | - // (review complete) - // | - // [6. Publication] - // - - // Pre-generate stable IDs for the flow prompts - const flowIds = { - "flow-1-start": generateId(), - "flow-2-outline": generateId(), - "flow-3a-technical": generateId(), - "flow-3b-creative": generateId(), - "flow-4a-implementation": generateId(), - "flow-4b-story": generateId(), - "flow-5-review": generateId(), - "flow-6-publish": generateId(), - }; - - const flowPrompts = [ - { - id: "flow-1-start", - title: "Idea Generation", - slug: "idea-generation", - description: "Start your workflow by brainstorming and generating initial ideas", - content: `You are a creative brainstorming assistant. Help the user generate innovative ideas for their project. - -1. Ask clarifying questions about the topic -2. Generate 5-10 diverse ideas -3. Rate each idea on feasibility and impact -4. Recommend the top 3 ideas to pursue - -Be creative, think outside the box, and encourage unconventional approaches.`, - }, - { - id: "flow-2-outline", - title: "Step 2: Outline Creation", - slug: "idea-generation-step-2-outline-creation", - description: "Create a structured outline from the generated ideas", - content: `Based on the ideas generated in the previous step, create a detailed outline. - -Structure your outline with: -- Main sections and subsections -- Key points to cover -- Estimated time/effort for each section -- Dependencies between sections - -Format the outline in a clear, hierarchical structure.`, - }, - { - id: "flow-3a-technical", - title: "Step 3a: Technical Deep Dive", - slug: "idea-generation-step-3a-technical-deep-dive", - description: "Technical path: Analyze technical requirements and feasibility", - content: `Perform a technical analysis of the outlined project. - -Analyze: -- Technical requirements and dependencies -- Architecture considerations -- Potential technical challenges -- Required tools and technologies -- Performance implications - -Provide a detailed technical assessment with recommendations.`, - }, - { - id: "flow-3b-creative", - title: "Step 3b: Creative Exploration", - slug: "idea-generation-step-3b-creative-exploration", - description: "Creative path: Explore creative directions and storytelling", - content: `Explore the creative dimensions of the outlined project. - -Focus on: -- Narrative and storytelling elements -- Visual and aesthetic considerations -- Emotional impact and user engagement -- Unique creative angles -- Inspiration from other works - -Generate creative concepts that bring the project to life.`, - }, - { - id: "flow-4a-implementation", - title: "Step 4a: Implementation Plan", - slug: "idea-generation-step-4a-implementation-plan", - description: "Create a detailed implementation plan based on technical analysis", - content: `Create a comprehensive implementation plan. - -Include: -- Phase breakdown with milestones -- Task list with priorities -- Resource allocation -- Risk mitigation strategies -- Timeline estimates -- Success metrics - -Format as an actionable project plan.`, - }, - { - id: "flow-4b-story", - title: "Step 4b: Story Development", - slug: "idea-generation-step-4b-story-development", - description: "Develop the narrative and content based on creative exploration", - content: `Develop the full story and content based on the creative exploration. - -Develop: -- Complete narrative arc -- Character or element descriptions -- Key scenes or moments -- Dialogue or copy -- Visual descriptions -- Emotional beats - -Create compelling, engaging content.`, - }, - { - id: "flow-5-review", - title: "Step 5: Final Review", - slug: "idea-generation-step-5-final-review", - description: "Review and merge all work streams for final quality check", - content: `Perform a comprehensive final review merging all work streams. - -Review checklist: -- Technical feasibility confirmed -- Creative vision aligned -- All requirements met -- Quality standards achieved -- Consistency across all elements -- Ready for publication - -Provide a final assessment with any last recommendations.`, - }, - { - id: "flow-6-publish", - title: "Step 6: Publication", - slug: "idea-generation-step-6-publication", - description: "Final step: Prepare and execute publication", - content: `Prepare the final deliverable for publication. - -Final steps: -- Format for target platform -- Create accompanying materials -- Set up distribution -- Prepare announcement -- Schedule publication -- Monitor initial reception - -Congratulations on completing the workflow!`, - }, - ]; - - // Create prompts - console.log("šŸ“ Creating flow prompts..."); - const createdPrompts: Record = {}; - - for (const p of flowPrompts) { - const existing = await prisma.prompt.findFirst({ where: { slug: p.slug } }); - - if (existing) { - createdPrompts[p.id] = existing.id; - console.log(` ā­ļø Prompt "${p.title}" already exists (id: ${existing.id})`); - } else { - const promptId = flowIds[p.id as keyof typeof flowIds]; - const prompt = await prisma.prompt.create({ - data: { - id: promptId, - title: p.title, - slug: p.slug, - description: p.description, - content: p.content, - type: "TEXT", - authorId: user.id, - categoryId: category.id, - isPrivate: false, - isUnlisted: false, - }, - }); - createdPrompts[p.id] = prompt.id; - console.log(` āœ… Created "${p.title}" (id: ${prompt.id})`); - } - } - - // Create connections (the flow structure) - console.log("\nšŸ”— Creating flow connections..."); - - const connections = [ - // Main flow: Start -> Outline - { source: "flow-1-start", target: "flow-2-outline", label: "brainstorm complete", order: 0 }, - - // Branch: Outline -> Technical AND Creative - { source: "flow-2-outline", target: "flow-3a-technical", label: "technical path", order: 0 }, - { source: "flow-2-outline", target: "flow-3b-creative", label: "creative path", order: 1 }, - - // Technical branch continues - { source: "flow-3a-technical", target: "flow-4a-implementation", label: "analysis done", order: 0 }, - - // Creative branch continues - { source: "flow-3b-creative", target: "flow-4b-story", label: "ideas ready", order: 0 }, - - // Both branches merge to review - { source: "flow-4a-implementation", target: "flow-5-review", label: "merge results", order: 0 }, - { source: "flow-4b-story", target: "flow-5-review", label: "merge results", order: 1 }, - - // Final step - { source: "flow-5-review", target: "flow-6-publish", label: "review complete", order: 0 }, - ]; - - for (const conn of connections) { - const sourceId = createdPrompts[conn.source]; - const targetId = createdPrompts[conn.target]; - - if (!sourceId || !targetId) { - console.log(` āš ļø Skipping connection: missing prompt IDs`); - continue; - } - - // Check if connection already exists - const existing = await prisma.promptConnection.findUnique({ - where: { sourceId_targetId: { sourceId, targetId } }, - }); - - if (existing) { - console.log(` ā­ļø Connection already exists: ${conn.source} -> ${conn.target}`); - } else { - const connectionId = generateId(); - await prisma.promptConnection.create({ - data: { - id: connectionId, - sourceId, - targetId, - label: conn.label, - order: conn.order, - }, - }); - console.log(` āœ… Created: ${conn.source} -> ${conn.target} (${conn.label}) (id: ${connectionId})`); - } - } - - console.log("\nšŸŽ‰ Flow seed complete!"); - console.log("\nšŸ“‹ Test user: f1@prompts.chat (password: password123)"); - console.log("\nšŸ”— Flow structure created:"); - console.log(" Start -> Outline -> [Technical, Creative] -> [Implementation, Story] -> Review -> Publish"); -} - -main() - .catch((e) => { - console.error("āŒ Flow seeding failed:", e); - process.exit(1); - }) - .finally(async () => { - await prisma.$disconnect(); - }); diff --git a/src/app/[username]/page.tsx b/src/app/[username]/page.tsx index 6ceb35b9..e0e523be 100644 --- a/src/app/[username]/page.tsx +++ b/src/app/[username]/page.tsx @@ -146,7 +146,12 @@ export default async function UserProfilePage({ params, searchParams }: UserProf }, }, _count: { - select: { votes: true, contributors: true, outgoingConnections: true, incomingConnections: true }, + select: { + votes: true, + contributors: true, + outgoingConnections: { where: { label: { not: "related" } } }, + incomingConnections: { where: { label: { not: "related" } } }, + }, }, }; diff --git a/src/app/api/prompts/route.ts b/src/app/api/prompts/route.ts index fa5095a3..aeb7d7e1 100644 --- a/src/app/api/prompts/route.ts +++ b/src/app/api/prompts/route.ts @@ -394,7 +394,12 @@ export async function GET(request: Request) { }, }, _count: { - select: { votes: true, contributors: true, outgoingConnections: true, incomingConnections: true }, + select: { + votes: true, + contributors: true, + outgoingConnections: { where: { label: { not: "related" } } }, + incomingConnections: { where: { label: { not: "related" } } }, + }, }, }, }), diff --git a/src/app/categories/[slug]/page.tsx b/src/app/categories/[slug]/page.tsx index 46727c4d..d344b14e 100644 --- a/src/app/categories/[slug]/page.tsx +++ b/src/app/categories/[slug]/page.tsx @@ -130,7 +130,12 @@ export default async function CategoryPage({ params, searchParams }: CategoryPag }, }, _count: { - select: { votes: true, contributors: true, outgoingConnections: true, incomingConnections: true }, + select: { + votes: true, + contributors: true, + outgoingConnections: { where: { label: { not: "related" } } }, + incomingConnections: { where: { label: { not: "related" } } }, + }, }, }, }); diff --git a/src/app/collection/page.tsx b/src/app/collection/page.tsx index 2d557003..ec06f7db 100644 --- a/src/app/collection/page.tsx +++ b/src/app/collection/page.tsx @@ -43,7 +43,12 @@ export default async function CollectionPage() { }, }, _count: { - select: { votes: true, contributors: true, outgoingConnections: true, incomingConnections: true }, + select: { + votes: true, + contributors: true, + outgoingConnections: { where: { label: { not: "related" } } }, + incomingConnections: { where: { label: { not: "related" } } }, + }, }, }, }, diff --git a/src/app/feed/page.tsx b/src/app/feed/page.tsx index 45569442..03d5e6b1 100644 --- a/src/app/feed/page.tsx +++ b/src/app/feed/page.tsx @@ -67,7 +67,12 @@ export default async function FeedPage() { }, }, _count: { - select: { votes: true, contributors: true, outgoingConnections: true, incomingConnections: true }, + select: { + votes: true, + contributors: true, + outgoingConnections: { where: { label: { not: "related" } } }, + incomingConnections: { where: { label: { not: "related" } } }, + }, }, }, }) diff --git a/src/app/prompts/page.tsx b/src/app/prompts/page.tsx index c5e7c061..b76d97a5 100644 --- a/src/app/prompts/page.tsx +++ b/src/app/prompts/page.tsx @@ -116,7 +116,12 @@ function getCachedPrompts( }, }, _count: { - select: { votes: true, contributors: true, outgoingConnections: true, incomingConnections: true }, + select: { + votes: true, + contributors: true, + outgoingConnections: { where: { label: { not: "related" } } }, + incomingConnections: { where: { label: { not: "related" } } }, + }, }, }, }), diff --git a/src/app/skills/page.tsx b/src/app/skills/page.tsx index 73322d54..952c4f6d 100644 --- a/src/app/skills/page.tsx +++ b/src/app/skills/page.tsx @@ -75,7 +75,12 @@ function getCachedSkills( }, }, _count: { - select: { votes: true, contributors: true, outgoingConnections: true, incomingConnections: true }, + select: { + votes: true, + contributors: true, + outgoingConnections: { where: { label: { not: "related" } } }, + incomingConnections: { where: { label: { not: "related" } } }, + }, }, }, }), diff --git a/src/app/tags/[slug]/page.tsx b/src/app/tags/[slug]/page.tsx index 62048844..bd5e6ef5 100644 --- a/src/app/tags/[slug]/page.tsx +++ b/src/app/tags/[slug]/page.tsx @@ -89,7 +89,12 @@ export default async function TagPage({ params, searchParams }: TagPageProps) { }, }, _count: { - select: { votes: true, contributors: true, outgoingConnections: true, incomingConnections: true }, + select: { + votes: true, + contributors: true, + outgoingConnections: { where: { label: { not: "related" } } }, + incomingConnections: { where: { label: { not: "related" } } }, + }, }, }, }), diff --git a/src/app/workflows/page.tsx b/src/app/workflows/page.tsx index 4b46f4ed..c3a32d73 100644 --- a/src/app/workflows/page.tsx +++ b/src/app/workflows/page.tsx @@ -83,7 +83,12 @@ function getCachedWorkflows( }, }, _count: { - select: { votes: true, contributors: true, outgoingConnections: true, incomingConnections: true }, + select: { + votes: true, + contributors: true, + outgoingConnections: { where: { label: { not: "related" } } }, + incomingConnections: { where: { label: { not: "related" } } }, + }, }, }, }), diff --git a/src/components/prompts/discovery-prompts.tsx b/src/components/prompts/discovery-prompts.tsx index 95721199..4a2fd80b 100644 --- a/src/components/prompts/discovery-prompts.tsx +++ b/src/components/prompts/discovery-prompts.tsx @@ -34,7 +34,12 @@ export async function DiscoveryPrompts({ isHomepage = false }: DiscoveryPromptsP select: { id: true, username: true, name: true, avatar: true }, }, _count: { - select: { votes: true, contributors: true, outgoingConnections: true, incomingConnections: true }, + select: { + votes: true, + contributors: true, + outgoingConnections: { where: { label: { not: "related" } } }, + incomingConnections: { where: { label: { not: "related" } } }, + }, }, };