( projectId: string, provider: string, serviceData: Record<string, unknown> )
| 43 | } |
| 44 | |
| 45 | export async function upsertProjectServiceConnection( |
| 46 | projectId: string, |
| 47 | provider: string, |
| 48 | serviceData: Record<string, unknown> |
| 49 | ) { |
| 50 | const existing = await prisma.projectServiceConnection.findFirst({ |
| 51 | where: { projectId, provider }, |
| 52 | }); |
| 53 | |
| 54 | if (existing) { |
| 55 | const updated = await prisma.projectServiceConnection.update({ |
| 56 | where: { id: existing.id }, |
| 57 | data: { |
| 58 | serviceData: serializeServiceData(serviceData), |
| 59 | status: 'connected', |
| 60 | }, |
| 61 | }); |
| 62 | return deserializeServiceData(updated); |
| 63 | } |
| 64 | |
| 65 | const created = await prisma.projectServiceConnection.create({ |
| 66 | data: { |
| 67 | projectId, |
| 68 | provider, |
| 69 | status: 'connected', |
| 70 | serviceData: serializeServiceData(serviceData), |
| 71 | }, |
| 72 | }); |
| 73 | |
| 74 | return deserializeServiceData(created); |
| 75 | } |
| 76 | |
| 77 | export async function deleteProjectService(serviceId: string): Promise<boolean> { |
| 78 | try { |
no test coverage detected