( orgId: string, data: Record<string, unknown>, )
| 45 | export type ServicePath = { href: string | null; label: string }; |
| 46 | |
| 47 | export async function resolveServicePath( |
| 48 | orgId: string, |
| 49 | data: Record<string, unknown>, |
| 50 | ): Promise<ServicePath> { |
| 51 | try { |
| 52 | const applicationId = data?.applicationId as string | undefined; |
| 53 | const composeId = data?.composeId as string | undefined; |
| 54 | if (applicationId) { |
| 55 | const app = await findApplicationById(applicationId); |
| 56 | if (app.environment.project.organizationId !== orgId) { |
| 57 | return { href: null, label: "Application" }; |
| 58 | } |
| 59 | return { |
| 60 | href: `/dashboard/project/${app.environment.project.projectId}/environment/${app.environment.environmentId}/services/application/${app.applicationId}`, |
| 61 | label: "Application", |
| 62 | }; |
| 63 | } |
| 64 | if (composeId) { |
| 65 | const comp = await findComposeById(composeId); |
| 66 | if (comp.environment.project.organizationId !== orgId) { |
| 67 | return { href: null, label: "Compose" }; |
| 68 | } |
| 69 | return { |
| 70 | href: `/dashboard/project/${comp.environment.project.projectId}/environment/${comp.environment.environmentId}/services/compose/${comp.composeId}`, |
| 71 | label: "Compose", |
| 72 | }; |
| 73 | } |
| 74 | } catch { |
| 75 | // not found or unauthorized |
| 76 | } |
| 77 | return { href: null, label: "—" }; |
| 78 | } |
| 79 | |
| 80 | export type Deployment = typeof deployments.$inferSelect; |
| 81 |
no test coverage detected