( workspaceId: string, userId: string, content: string, labelId?: string, )
| 6 | * so we only store it for display/retrieval purposes. |
| 7 | */ |
| 8 | export const savePersonaDocument = async ( |
| 9 | workspaceId: string, |
| 10 | userId: string, |
| 11 | content: string, |
| 12 | labelId?: string, |
| 13 | ) => { |
| 14 | const sessionId = `persona-v2-${workspaceId}`; |
| 15 | |
| 16 | const document = await prisma.document.upsert({ |
| 17 | where: { |
| 18 | sessionId_workspaceId: { |
| 19 | sessionId, |
| 20 | workspaceId, |
| 21 | }, |
| 22 | }, |
| 23 | create: { |
| 24 | sessionId, |
| 25 | title: "Persona", |
| 26 | content, |
| 27 | labelIds: labelId ? [labelId] : [], |
| 28 | source: "persona-v2", |
| 29 | type: "skill", |
| 30 | metadata: { |
| 31 | generatedAt: new Date().toISOString(), |
| 32 | version: "v2", |
| 33 | }, |
| 34 | editedBy: userId, |
| 35 | workspaceId, |
| 36 | }, |
| 37 | update: { |
| 38 | content, |
| 39 | source: "persona-v2", |
| 40 | type: "skill", |
| 41 | updatedAt: new Date(), |
| 42 | metadata: { |
| 43 | generatedAt: new Date().toISOString(), |
| 44 | version: "v2", |
| 45 | }, |
| 46 | }, |
| 47 | }); |
| 48 | |
| 49 | return document; |
| 50 | }; |
no test coverage detected