fix: 공개 개념 문서를 열 수 있게 한다

`/concepts/idp-brokering` 이 「페이지를 찾을 수 없습니다」였다. API 도
라우트도 200 인데 화면만 404 였고, 콘솔을 보니 개념 화면이
`/api/v1/public/questions/idp-brokering` 을 부르고 있었다.

세 가지가 겹쳤다. 계약 타입에는 getPublicConcept 이 있었지만 기여 목록에
등록되지 않아 부를 수 없었다. 게이트웨이는 종류를 삼항으로 이어 붙여
마지막 else 가 남은 것을 다 질문 조회로 보냈다. 응답을 기록으로 바꾸는
분기에도 개념이 없어, 설령 불렸어도 질문 매핑으로 떨어졌을 것이다.

개념 삭제에서 겪은 것과 같은 모양이다 — 손으로 나열한 분기의 마지막
else 가 새 종류를 조용히 삼킨다. 표로 두어 종류가 늘면 타입이 잡게 하고,
네 종류가 각각 자기 주소로 나가는지 확인하는 가드를 둔다.

개념 본문은 Case 와 같은 규칙을 쓴다(Markdown 한 덩어리 + `:::evidence`).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011nAjrqNHGPNngN4aUbcyvJ
This commit is contained in:
DongHyeonka
2026-09-01 14:37:39 +09:00
co-authored by Claude Opus 5
parent a3ed23e073
commit 8996430d23
3 changed files with 100 additions and 2 deletions
@@ -83,6 +83,13 @@ export const REFERENCE_RELATION_LABELS = Object.freeze({
relatedReferences: "함께 보는 기준",
});
export const CONCEPT_RELATION_LABELS = Object.freeze({
supportingCases: "이 개념을 확인한 기록",
relatedReferences: "함께 보는 기준",
relatedConcepts: "이어지는 개념",
relatedDecisions: "이 개념을 쓴 결정",
});
export const QUESTION_RELATION_LABELS = Object.freeze({
resultCase: "이 질문에서 나온 기록",
producedDecision: "이 질문이 이끈 결정",
@@ -162,8 +169,20 @@ export function createHttpPublicContentGateway(
kind: K,
slug: string,
): Promise<Extract<PublicRecord, { kind: K }> | undefined> {
const operationId =
kind === "CASE" ? "getPublicCase" : kind === "REFERENCE" ? "getPublicReference" : "getPublicQuestion";
/*
삼항으로 이어 붙이면 마지막 else 가 모르는 종류를 다 받아 간다 — 개념이 그렇게 질문
조회로 떨어졌고, `/concepts/{slug}` 화면이 `/api/v1/public/questions/{slug}` 를 불러
404 를 받아 「페이지를 찾을 수 없습니다」가 났다. 삭제 경로에서 겪은 것과 같은 모양이다.
표로 두면 종류가 늘 때 빠진 자리를 타입이 잡는다.
*/
const OPERATIONS: Record<RecordKind, string> = {
CASE: "getPublicCase",
REFERENCE: "getPublicReference",
QUESTION: "getPublicQuestion",
CONCEPT: "getPublicConcept",
};
const operationId = OPERATIONS[kind];
const detail = await read<Readonly<Record<string, unknown>>>(operationId, { slug });
if (detail === NOT_FOUND) return undefined;
@@ -256,6 +275,45 @@ export function createHttpPublicContentGateway(
}) as unknown as Extract<PublicRecord, { kind: K }>;
}
/*
개념은 Case 와 같은 본문 규칙을 쓴다 — Markdown 한 덩어리에 `:::evidence` 로 도식을
끌어온다. 이 분기가 없던 동안 개념은 마지막 return(질문 매핑)으로 떨어졌고, 그전에
이미 질문 조회 API 를 부르고 있어 화면이 통째로 404 였다.
*/
if (kind === "CONCEPT") {
const body = (detail.concept as Readonly<Record<string, unknown>>) ?? {};
return Object.freeze({
...baseOf("CONCEPT", slug, {
title: body.title as string,
summary: (body.summary as string) ?? "",
path: canonicalPath,
primaryTopic: body.primaryTopic as never,
primaryProject: body.primaryProject as never,
publishedAt: body.publishedAt as string,
relations: flattenRelations(groups, CONCEPT_RELATION_LABELS),
}),
kind: "CONCEPT",
basisVersion: (body.basisVersion as string) ?? "",
content: (body.content as string) ?? "",
bodyAssets: Object.freeze(
((body.bodyAssets as readonly Readonly<Record<string, unknown>>[]) ?? []).map((asset) =>
Object.freeze({
assetKey: asset.assetKey as string,
assetId: asset.assetId as string,
url: asset.url as string,
contentType: asset.contentType as string,
altText: (asset.altText as string) ?? "",
width: (asset.width as number) ?? null,
height: (asset.height as number) ?? null,
decorative: Boolean(asset.decorative),
}),
),
),
sections: markdownSections(body.content as string),
}) as unknown as Extract<PublicRecord, { kind: K }>;
}
const body = (detail.question as Readonly<Record<string, unknown>>) ?? {};
/*
`points` 는 그룹 이름을 키로 갖는 객체다 — 계약의 `QuestionPointGroup`. 여기서는
@@ -125,6 +125,7 @@ const HTTP_CONTRACTS = Object.freeze([
publicRead("getPublicCase", `${P}/cases/{slug}`, 524_288, bySlug),
publicRead("getPublicReference", `${P}/references/{slug}`, 524_288, bySlug),
publicRead("getPublicQuestion", `${P}/questions/{slug}`, 524_288, bySlug),
publicRead("getPublicConcept", `${P}/concepts/{slug}`, 524_288, bySlug),
publicRead("listPublicProjects", `${P}/projects`, 262_144),
publicRead("getPublicProject", `${P}/projects/{slug}`, 262_144, bySlug),
publicRead("listPublicProjectDecisions", `${P}/projects/{slug}/decisions`, 262_144, bySlug),