(auditLog: AuditLog)
| 170 | } |
| 171 | |
| 172 | function getViewLink(auditLog: AuditLog): string | null { |
| 173 | let parsedRequest: Record<string, unknown>; |
| 174 | let parsedResponse: Record<string, unknown>; |
| 175 | try { |
| 176 | parsedRequest = JSON.parse(auditLog.request || "{}") as Record< |
| 177 | string, |
| 178 | unknown |
| 179 | >; |
| 180 | parsedResponse = JSON.parse(auditLog.response || "{}") as Record< |
| 181 | string, |
| 182 | unknown |
| 183 | >; |
| 184 | } catch { |
| 185 | return null; |
| 186 | } |
| 187 | if (Boolean(parsedRequest["validateOnly"])) return null; |
| 188 | const sections = auditLog.method.split("/").filter((i) => i); |
| 189 | switch (sections[0]) { |
| 190 | case RolloutService.typeName: |
| 191 | case PlanService.typeName: |
| 192 | case IssueService.typeName: |
| 193 | return (parsedResponse["name"] as string) || null; |
| 194 | case SQLService.typeName: { |
| 195 | if (sections[1] !== "Export") return null; |
| 196 | const name = parsedRequest["name"] as string | undefined; |
| 197 | if (!name) return null; |
| 198 | const [projectId, planId] = |
| 199 | getProjectIdPlanUidStageUidFromRolloutName(name); |
| 200 | if (!projectId || !planId) return null; |
| 201 | return `${projectNamePrefix}${projectId}/${planNamePrefix}${planId}/rollout`; |
| 202 | } |
| 203 | } |
| 204 | return null; |
| 205 | } |
| 206 | |
| 207 | // ============================================================ |
| 208 | // JSONStringView |
no test coverage detected