fix: 개념 삭제가 질문 삭제로 떨어지던 것을 고친다
개념을 지우려 하면 「질문을 찾을 수 없습니다」가 났다. 세 가지가 겹쳤다. 게이트웨이가 종류를 삼항으로 이어 붙여, 마지막 else 가 모르는 종류를 다 받아 갔다 — 개념이 deleteQuestion 으로 떨어졌다. 화면은 종류를 `as "CASE" | "REFERENCE" | "QUESTION"` 으로 좁혀 넘겼으므로 타입도 잡지 못했다. 포트의 종류 목록도 손으로 나열해 셋에 머물러 있었다. 삼항을 Record<DeletableDocumentKind, string> 표로 바꾼다 — 종류가 늘면 빠진 자리를 타입이 잡는다. 캐스팅을 걷어내고, 계약 기여 목록에 deleteConceptDraft 를 등록한다. 이 목록에 빠뜨리면 요청이 조용히 다른 주소로 나가므로(어제 페이지 인자가 그랬다) 네 종류가 각각 자기 주소로 나가는지 확인하는 가드를 함께 둔다 — 등록을 지우면 깨지는 것을 확인했다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011nAjrqNHGPNngN4aUbcyvJ
This commit is contained in:
co-authored by
Claude Opus 5
parent
8c5dbe1a0d
commit
dec86bd1f2
@@ -38,28 +38,28 @@
|
||||
},
|
||||
"contractSet": {
|
||||
"setAlgorithm": "CA_CONTRACT_SET_V1",
|
||||
"setDigest": "sha256:b9e1e6a07e087dc56fe81805303a6f20022956174449b65575b350a71ab40675",
|
||||
"setDigest": "sha256:c841cbe2de536a2e3879e8dd42a9471f674d8164b1c0698bc6acd90a59721f43",
|
||||
"packages": [
|
||||
{
|
||||
"packageId": "@tech-log/management-contract",
|
||||
"version": "1.0.0",
|
||||
"digest": "sha256:f97b97101791d87fcf27d78a4c016370cabd2f02bb3b30eec0b8e453803d2d5f",
|
||||
"digest": "sha256:a422ff091cdba5f17a27edfa12fec06e077bcc52c9615136ddecfa8df58a5f6e",
|
||||
"runtimeProtocolVersion": 1,
|
||||
"sourceRevision": "5942a2e"
|
||||
"sourceRevision": "f56a03b"
|
||||
},
|
||||
{
|
||||
"packageId": "@tech-log/public-contract",
|
||||
"version": "2.1.0",
|
||||
"digest": "sha256:afe415880eb5d6289ae10abf493333c97270c323c16a7245a466d4db4466e630",
|
||||
"runtimeProtocolVersion": 1,
|
||||
"sourceRevision": "5942a2e"
|
||||
"sourceRevision": "f56a03b"
|
||||
},
|
||||
{
|
||||
"packageId": "@tech-log/studio-contract",
|
||||
"version": "3.1.0",
|
||||
"digest": "sha256:7e1ee18f7e6a6cb1750dd0baec28d975fb3b535116d8dfb57c17ae16ee8d2be8",
|
||||
"runtimeProtocolVersion": 1,
|
||||
"sourceRevision": "5942a2e"
|
||||
"sourceRevision": "f56a03b"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ import type {
|
||||
ReleaseUpdateRequest,
|
||||
TopicEdit,
|
||||
} from "../../contracts/management/contract.ts";
|
||||
import type { ManagementGateway } from "../../application/ports/management-gateway.ts";
|
||||
import type {
|
||||
DeletableDocumentKind,
|
||||
ManagementGateway,
|
||||
} from "../../application/ports/management-gateway.ts";
|
||||
import { ManagementGatewayError } from "../../application/ports/management-gateway-error.ts";
|
||||
import type { StudioOperationExecutor } from "./http-studio-gateway.ts";
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ import type {
|
||||
* 않는 것도 의도다: 이 표면은 백엔드가 없으면 존재할 이유가 없고, 픽스처를 만들면 실제로는 만들
|
||||
* 수 없는 주제를 화면이 보여주게 된다.
|
||||
*/
|
||||
/** 이 게이트웨이로 지울 수 있는 문서 종류. 결정은 프로젝트 경로를 요구하므로 별도 메서드다. */
|
||||
export type DeletableDocumentKind = "CASE" | "REFERENCE" | "QUESTION" | "CONCEPT";
|
||||
|
||||
export type ManagementGateway = Readonly<{
|
||||
listTopics(): Promise<TopicEdit[]>;
|
||||
createTopic(input: TopicEdit): Promise<TopicEdit>;
|
||||
@@ -71,7 +74,11 @@ export type ManagementGateway = Readonly<{
|
||||
* 는 한 테이블을 나눠 쓰고 Question 은 다른 테이블이다. Decision 은 계약에 삭제가 없다:
|
||||
* 그쪽 수명주기는 수락·기각·대체이고, 그건 지우는 것이 아니라 무슨 일이 있었는지 남기는 것이다.
|
||||
*/
|
||||
deleteDocument(kind: "CASE" | "REFERENCE" | "QUESTION", id: string, expectedVersion: number): Promise<void>;
|
||||
/**
|
||||
* 작업본 삭제. 종류를 손으로 나열하지 않는다 — 개념을 더했을 때 이 목록이 셋에 머물러
|
||||
* 있었고, 부르는 쪽이 `as` 로 캐스팅해 넘기는 바람에 개념이 질문 삭제로 떨어졌다.
|
||||
*/
|
||||
deleteDocument(kind: DeletableDocumentKind, id: string, expectedVersion: number): Promise<void>;
|
||||
/**
|
||||
* Decision 은 프로젝트에 속하므로 경로가 둘을 요구한다. 다른 종류처럼 한 번에 묶지 않는 이유는
|
||||
* 계약이 그렇게 선언했고, 실제로도 프로젝트 밖의 Decision 은 존재하지 않기 때문이다.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"packageId": "@tech-log/management-contract",
|
||||
"version": "1.0.0",
|
||||
"digest": "sha256:f97b97101791d87fcf27d78a4c016370cabd2f02bb3b30eec0b8e453803d2d5f",
|
||||
"sourceRevision": "5942a2e",
|
||||
"digest": "sha256:a422ff091cdba5f17a27edfa12fec06e077bcc52c9615136ddecfa8df58a5f6e",
|
||||
"sourceRevision": "f56a03b",
|
||||
"operationIds": [
|
||||
"createCaseDraft",
|
||||
"getCaseForEdit",
|
||||
@@ -12,6 +12,7 @@
|
||||
"getReferenceForEdit",
|
||||
"updateReferenceDraft",
|
||||
"deleteReferenceDraft",
|
||||
"deleteConceptDraft",
|
||||
"validateCase",
|
||||
"submitReviewCase",
|
||||
"returnToDraftCase",
|
||||
|
||||
@@ -68,6 +68,26 @@ export interface paths {
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/v1/studio/concepts/{id}": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
post?: never;
|
||||
/** @description 개념 작업본을 지운다. Case·Reference 와 같은 `document` 테이블을 쓰므로 같은
|
||||
* 유스케이스가 처리하며 `document_type` 으로만 갈린다. 공개된 개념은 지우지 않는다 —
|
||||
* 공개 취소가 그 경로다.
|
||||
* */
|
||||
delete: operations["deleteConceptDraft"];
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/v1/studio/cases/{id}/validate": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
@@ -2345,6 +2365,59 @@ export interface operations {
|
||||
};
|
||||
};
|
||||
};
|
||||
deleteConceptDraft: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header: {
|
||||
"X-CSRF-TOKEN": components["parameters"]["CsrfToken"];
|
||||
};
|
||||
path: {
|
||||
id: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["ExpectedVersionRequest"];
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description No Content */
|
||||
204: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content?: never;
|
||||
};
|
||||
/** @description Bad Request */
|
||||
400: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/problem+json": components["schemas"]["ProblemDetails"];
|
||||
};
|
||||
};
|
||||
/** @description Not Found */
|
||||
404: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/problem+json": components["schemas"]["ProblemDetails"];
|
||||
};
|
||||
};
|
||||
/** @description Conflict */
|
||||
409: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/problem+json": components["schemas"]["ProblemDetails"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
validateCase: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
|
||||
@@ -557,6 +557,52 @@ paths:
|
||||
$ref: '#/components/schemas/ExpectedVersionRequest'
|
||||
security:
|
||||
- sessionCookie: []
|
||||
/api/v1/studio/concepts/{id}:
|
||||
delete:
|
||||
operationId: deleteConceptDraft
|
||||
tags:
|
||||
- Concepts
|
||||
description: |
|
||||
개념 작업본을 지운다. Case·Reference 와 같은 `document` 테이블을 쓰므로 같은
|
||||
유스케이스가 처리하며 `document_type` 으로만 갈린다. 공개된 개념은 지우지 않는다 —
|
||||
공개 취소가 그 경로다.
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
- $ref: '#/components/parameters/CsrfToken'
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ExpectedVersionRequest'
|
||||
responses:
|
||||
'204':
|
||||
description: No Content
|
||||
'400':
|
||||
description: Bad Request
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ProblemDetails'
|
||||
'404':
|
||||
description: Not Found
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ProblemDetails'
|
||||
'409':
|
||||
description: Conflict
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ProblemDetails'
|
||||
security:
|
||||
- sessionCookie: []
|
||||
/api/v1/studio/cases/{id}/validate:
|
||||
post:
|
||||
operationId: validateCase
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"packageId": "@tech-log/public-contract",
|
||||
"version": "2.1.0",
|
||||
"digest": "sha256:afe415880eb5d6289ae10abf493333c97270c323c16a7245a466d4db4466e630",
|
||||
"sourceRevision": "5942a2e",
|
||||
"sourceRevision": "f56a03b",
|
||||
"operationIds": [
|
||||
"getPublicSite",
|
||||
"getPublicHome",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"packageId": "@tech-log/studio-contract",
|
||||
"version": "3.1.0",
|
||||
"digest": "sha256:7e1ee18f7e6a6cb1750dd0baec28d975fb3b535116d8dfb57c17ae16ee8d2be8",
|
||||
"sourceRevision": "5942a2e",
|
||||
"sourceRevision": "f56a03b",
|
||||
"operationIds": [
|
||||
"getStudioSession",
|
||||
"getStudioDashboard",
|
||||
|
||||
@@ -435,6 +435,25 @@ const HTTP_CONTRACTS = Object.freeze([
|
||||
});
|
||||
},
|
||||
),
|
||||
writeOperation(
|
||||
"deleteConceptDraft",
|
||||
"DELETE",
|
||||
`${D}/concepts/{id}`,
|
||||
{
|
||||
acceptedStatuses: [204],
|
||||
emptyBodyStatuses: [204],
|
||||
requestByteLimit: 1_024,
|
||||
responseByteLimit: 1_024,
|
||||
},
|
||||
(input: never) => {
|
||||
const value = input as unknown as Readonly<{ id: string; expectedVersion: number }>;
|
||||
return Object.freeze({
|
||||
pathValues: Object.freeze({ id: value.id }),
|
||||
queryEntries: NO_QUERY,
|
||||
body: { expectedVersion: value.expectedVersion },
|
||||
});
|
||||
},
|
||||
),
|
||||
writeOperation(
|
||||
"deleteCaseDraft",
|
||||
"DELETE",
|
||||
|
||||
@@ -80,8 +80,14 @@ export function DocumentList() {
|
||||
detail.document.version,
|
||||
);
|
||||
} else {
|
||||
/*
|
||||
예전에는 여기서 `as "CASE" | "REFERENCE" | "QUESTION"` 으로 종류를 좁혔다. 개념이
|
||||
더해졌을 때 그 캐스팅이 개념을 가렸고, 게이트웨이의 마지막 else 가 질문 삭제를
|
||||
부르는 바람에 「질문을 찾을 수 없습니다」가 났다. 캐스팅을 걷어내면 새 종류가
|
||||
생길 때 타입이 여기서 막는다.
|
||||
*/
|
||||
await managementGateway.deleteDocument(
|
||||
item.kind as "CASE" | "REFERENCE" | "QUESTION",
|
||||
item.kind,
|
||||
item.id,
|
||||
detail.document.version,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "vitest";
|
||||
|
||||
import { TECH_LOG_MANAGEMENT_CONTRIBUTION } from "../../../src/features/tech-log/contracts/tech-log-management-contract-contribution.ts";
|
||||
import type { DeletableDocumentKind } from "../../../src/features/tech-log/application/ports/management-gateway.ts";
|
||||
|
||||
/**
|
||||
* 종류마다 지우는 주소가 다르다. 이 대응이 어긋나면 지우려던 것과 다른 종류의 API 를 부른다.
|
||||
*
|
||||
* <p>실제로 그렇게 났다: 개념을 더할 때 관리 계약에 삭제 경로를 만들지 않았고, 게이트웨이가
|
||||
* 종류를 삼항으로 이어 붙여 마지막 else 가 남은 것을 다 받아 갔다. 부르는 화면은 종류를
|
||||
* `as "CASE" | "REFERENCE" | "QUESTION"` 으로 좁혀 넘겼으므로 타입도 잡지 못했다. 개념을
|
||||
* 지우려 하면 질문 삭제가 불렸고 「질문을 찾을 수 없습니다」가 났다.
|
||||
*/
|
||||
const EXPECTED: Record<DeletableDocumentKind, { operationId: string; path: string }> = {
|
||||
CASE: { operationId: "deleteCaseDraft", path: "/api/v1/studio/cases/{id}" },
|
||||
REFERENCE: { operationId: "deleteReferenceDraft", path: "/api/v1/studio/references/{id}" },
|
||||
QUESTION: { operationId: "deleteQuestion", path: "/api/v1/studio/questions/{id}" },
|
||||
CONCEPT: { operationId: "deleteConceptDraft", path: "/api/v1/studio/concepts/{id}" },
|
||||
};
|
||||
|
||||
test("지울 수 있는 종류마다 자기 주소가 있고 서로 겹치지 않는다", () => {
|
||||
const byId = new Map(
|
||||
TECH_LOG_MANAGEMENT_CONTRIBUTION.http.map((entry) => [entry.contract.operationId, entry]),
|
||||
);
|
||||
|
||||
const paths = new Set<string>();
|
||||
for (const [kind, expected] of Object.entries(EXPECTED)) {
|
||||
const installed = byId.get(expected.operationId);
|
||||
assert.ok(installed, `${kind} 를 지우는 ${expected.operationId} 가 계약에 있어야 한다`);
|
||||
assert.equal(installed.contract.method, "DELETE");
|
||||
assert.equal(
|
||||
installed.contract.pathTemplate,
|
||||
expected.path,
|
||||
`${kind} 는 자기 주소로 나가야 한다`,
|
||||
);
|
||||
assert.ok(!paths.has(expected.path), `${kind} 가 다른 종류와 같은 주소를 쓴다`);
|
||||
paths.add(expected.path);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user