mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-10 08:48:29 +00:00
* Feat: v2 * feat: add chat functionality * First cut: integrations * Feat: add conversation API * Enhance conversation handling and memory management * Feat: added conversation --------- Co-authored-by: Manoj K <saimanoj58@gmail.com>
38 lines
719 B
TypeScript
38 lines
719 B
TypeScript
import { type Workspace } from "@core/database";
|
|
import { prisma } from "~/db.server";
|
|
|
|
interface CreateWorkspaceDto {
|
|
name: string;
|
|
integrations: string[];
|
|
userId: string;
|
|
}
|
|
|
|
export async function createWorkspace(
|
|
input: CreateWorkspaceDto,
|
|
): Promise<Workspace> {
|
|
const workspace = await prisma.workspace.create({
|
|
data: {
|
|
slug: input.name,
|
|
name: input.name,
|
|
userId: input.userId,
|
|
},
|
|
});
|
|
|
|
await prisma.user.update({
|
|
where: { id: input.userId },
|
|
data: {
|
|
confirmedBasicDetails: true,
|
|
},
|
|
});
|
|
|
|
return workspace;
|
|
}
|
|
|
|
export async function getWorkspaceByUser(userId: string) {
|
|
return await prisma.workspace.findFirst({
|
|
where: {
|
|
userId,
|
|
},
|
|
});
|
|
}
|