fix: close competition cutover integrity gaps

This commit is contained in:
dahyeon committed 2026-07-12 21:22:22 +00:00
1 parent 7ea2002975
commit 683d602d63
57 files changed
+4805 -1582

No files matched your search

@@ -0,0 +1,94 @@
interface RevisionedSnapshot {
revision: number;
}
export type TeamProgressErrorContent = {
kind:
| "unauthorized"
| "forbidden"
| "not-found"
| "not-ready"
| "server"
| "network"
| "unknown";
title: string;
description: string;
};
export function isConsistentTeamProgressSnapshot(
competition: RevisionedSnapshot | null | undefined,
teamView: RevisionedSnapshot | null | undefined,
): boolean {
return Boolean(
competition &&
teamView &&
competition.revision === teamView.revision,
);
}
export function getTeamProgressErrorContent(
errors: readonly unknown[],
): TeamProgressErrorContent {
const statuses = errors.flatMap((error) => {
if (typeof error !== "object" || error === null || !("status" in error)) {
return [];
}
return typeof error.status === "number" ? [error.status] : [];
});
if (statuses.includes(401)) {
return {
kind: "unauthorized",
title: "로그인이 필요합니다",
description: "팀 진행 정보를 보려면 로그인한 뒤 다시 시도해 주세요.",
};
}
if (statuses.includes(403)) {
return {
kind: "forbidden",
title: "팀 진행 정보를 볼 권한이 없습니다",
description:
"이 내전에 참여한 팀원 계정으로 로그인했는지 확인해 주세요.",
};
}
if (statuses.includes(404)) {
return {
kind: "not-found",
title: "팀 진행 정보를 찾을 수 없습니다",
description: "내전이 삭제되었거나 Competition이 아직 준비되지 않았습니다.",
};
}
if (statuses.includes(409)) {
return {
kind: "not-ready",
title: "Competition이 아직 준비되지 않았습니다",
description: "팀 구성이 완료된 뒤 다시 시도해 주세요.",
};
}
if (statuses.some((status) => status >= 500 && status <= 599)) {
return {
kind: "server",
title: "서버에서 팀 진행 정보를 불러오지 못했습니다",
description: "잠시 후 다시 시도해 주세요.",
};
}
if (errors.some(isNetworkError)) {
return {
kind: "network",
title: "네트워크에 연결할 수 없습니다",
description: "인터넷 연결을 확인한 뒤 다시 시도해 주세요.",
};
}
return {
kind: "unknown",
title: "팀 진행 정보를 불러오지 못했습니다",
description: "일시적인 오류일 수 있습니다. 다시 시도해 주세요.",
};
}
function isNetworkError(error: unknown): boolean {
return (
error instanceof TypeError ||
(error instanceof Error && error.name === "TypeError")
);
}