Initial curated projectbrain source from 8a7b1e0651dbdab97d744cbd2e653ab3970ac6c5

This commit is contained in:
Public Source Publisher committed 2026-10-01 01:43:26 +02:00
commit 5aa3e8d685
700 files changed
+132801

No files matched your search

@@ -0,0 +1,43 @@
import { prisma } from "../db/prisma.js";
import type { FeatureGroupDto, FocusAreaPurpose } from "../types/api.js";
const toPublicId = (value: { slug: string | null; readableId: string | null; id: string }) =>
value.slug ?? value.readableId ?? value.id;
const findProjectRecordBySlugOrId = (projectIdOrSlug: string) =>
prisma.project.findFirst({
where: {
deletedAt: null,
OR: [{ id: projectIdOrSlug }, { slug: projectIdOrSlug }],
},
});
export const listFeatureGroupsForProject = async (
projectIdOrSlug: string,
): Promise<FeatureGroupDto[] | undefined> => {
const project = await findProjectRecordBySlugOrId(projectIdOrSlug);
if (!project) return undefined;
const groups = await prisma.featureGroup.findMany({
where: {
projectId: project.id,
deletedAt: null,
},
orderBy: [{ name: "asc" }],
include: {
features: {
where: { deletedAt: null },
orderBy: { name: "asc" },
},
},
});
return groups.map((group) => ({
id: toPublicId(group),
projectId: project.slug,
name: group.name,
description: group.description ?? undefined,
focusArea: group.focusArea as FocusAreaPurpose | undefined,
featureIds: group.features.map(toPublicId),
}));
};