();
+ const http = createTechLogHttpBinding(context.http);
+
const createStudioAssetGateway = () =>
context.studioSource === "MOCK"
? createMockStudioAssetGateway(mockAssets)
: createHttpStudioAssetGateway({
- operations: context.contractOperations,
+ http,
csrf: context.csrf,
upload: createAssetUploadTransport({
baseUrl: context.apiBaseUrl,
@@ -67,7 +69,7 @@ export function createTechLogFeatureInstalledInput(
const createStudioGateway = () =>
context.studioSource === "MOCK"
? createMockStudioGateway({ assets: mockAssets })
- : createHttpStudioGateway({ operations: context.contractOperations });
+ : createHttpStudioGateway({ http });
// The public read source switches independently of Studio: the two are
// different services, and the combination that matters today is an authoring
@@ -75,16 +77,21 @@ export function createTechLogFeatureInstalledInput(
const publicContent =
context.publicSource === "MOCK"
? publicContentQueries
- : createHttpPublicContentGateway({ operations: context.contractOperations });
+ : createHttpPublicContentGateway({ http });
const createManagementGateway = () =>
- createHttpManagementGateway({ operations: context.contractOperations });
+ createHttpManagementGateway({ http });
+
+ const createStudioApplication = () =>
+ createTechLogStudioApplication({
+ studio: createStudioGateway(),
+ assets: createStudioAssetGateway(),
+ management: createManagementGateway(),
+ });
const input: TechLogFeatureInput = Object.freeze({
publicContent,
- createManagementGateway,
- createStudioGateway,
- createStudioAssetGateway,
+ createStudioApplication,
});
return Object.freeze({
diff --git a/src/features/tech-log/adapters/http/http-management-gateway.ts b/src/features/tech-log/adapters/http/http-management-gateway.ts
index b23ce45..1693b45 100644
--- a/src/features/tech-log/adapters/http/http-management-gateway.ts
+++ b/src/features/tech-log/adapters/http/http-management-gateway.ts
@@ -22,18 +22,18 @@ import type {
ManagementGateway,
} from "../../application/ports/management-gateway.ts";
import { ManagementGatewayError } from "../../application/ports/management-gateway-error.ts";
-import type { StudioOperationExecutor } from "./http-studio-gateway.ts";
+import type {
+ IdempotentOptions,
+ RequestOptions,
+} from "../../application/ports/studio-gateway.ts";
+import { mutationIntent } from "./http-studio-gateway.ts";
+import type {
+ TechLogHttpBinding,
+ TechLogHttpOperationId,
+} from "./tech-log-http-binding.ts";
export type { ManagementGateway };
-const ROUTE_ID = "TECH_LOG_STUDIO";
-
-/**
- * 주제·프로젝트 관리 게이트웨이.
- *
- * Studio 게이트웨이와 같은 실패 규약을 쓴다 — 실패는 던지고, 화면은 `usePublicContent` 가 아니라
- * Studio 쪽 상태 처리를 그대로 쓴다. 여기서 Result 로 감싸면 이 표면만 다른 규약이 된다.
- */
export {
ManagementGatewayError,
@@ -41,131 +41,227 @@ export {
} from "../../application/ports/management-gateway-error.ts";
export function createHttpManagementGateway(
- deps: Readonly<{ operations: StudioOperationExecutor }>,
+ deps: Readonly<{ http: TechLogHttpBinding }>,
): ManagementGateway {
- async function run(operationId: string, input: unknown): Promise {
- const outcome = await deps.operations.execute(operationId, input, { routeId: ROUTE_ID });
- if (outcome.kind === "SUCCESS") return outcome.value as T;
- if (outcome.kind === "PROBLEM") {
- // The management surface answers with the ADR-006 envelope, which nests
- // the code under `error` — reading `problem.code` found nothing and every
- // failure surfaced as the literal "PROBLEM", matching no i18n key.
- const body = outcome.problem as
- | Readonly<{
- code?: unknown;
- detail?: unknown;
- error?: Readonly<{ code?: unknown; message?: unknown }>;
- }>
- | null;
- const code =
- typeof body?.code === "string"
- ? body.code
- : typeof body?.error?.code === "string"
- ? body.error.code
- : "PROBLEM";
- const detail =
- typeof body?.error?.message === "string"
- ? body.error.message
- : typeof body?.detail === "string"
- ? body.detail
- : "";
- throw new ManagementGatewayError(operationId, code, detail);
- }
- throw new ManagementGatewayError(operationId, outcome.kind, "");
+ async function read(
+ operationId: TechLogHttpOperationId,
+ input: unknown,
+ options?: RequestOptions,
+ ): Promise {
+ const result = await deps.http.execute(operationId, input, {
+ ...(options?.signal ? { signal: options.signal } : {}),
+ });
+ if (result.ok) return result.value as T;
+ throw new ManagementGatewayError(
+ operationId,
+ result.error.code,
+ result.error.detail ?? "",
+ );
+ }
+
+ async function command(
+ operationId: TechLogHttpOperationId,
+ input: unknown,
+ options: IdempotentOptions,
+ ): Promise {
+ const result = await deps.http.execute(operationId, input, {
+ intent: mutationIntent(operationId, options.idempotencyKey, input),
+ ...(options.signal ? { signal: options.signal } : {}),
+ });
+ if (result.ok) return result.value as T;
+ throw new ManagementGatewayError(
+ operationId,
+ result.error.code,
+ result.error.detail ?? "",
+ );
}
return Object.freeze({
- listTopics: () => run("listStudioTopics", {}),
- createTopic: (input: TopicEdit) => run("createTopic", input),
- updateTopic: (id: string, body: TopicEdit) => run("updateTopic", { id, body }),
- listTopicVariants: (topicId: string) =>
- run("listTopicVariants", { id: topicId }),
- createTopicVariant: (topicId: string, body: TopicVariantEdit) =>
- run("createTopicVariant", { id: topicId, body }),
- updateTopicVariant: (topicId: string, variantId: string, body: TopicVariantEdit) =>
- run("updateTopicVariant", { id: topicId, variantId, body }),
- deleteTopicVariant: async (topicId: string, variantId: string, expectedVersion: number) => {
- await run("deleteTopicVariant", { id: topicId, variantId, expectedVersion });
+ listTopics: (options) => read("listStudioTopics", {}, options),
+ createTopic: (input, options) =>
+ command("createTopic", input, options),
+ updateTopic: (id, body, options) =>
+ command("updateTopic", { id, body }, options),
+ deleteTopic: async (id, expectedVersion, options) => {
+ await command("deleteTopic", { id, expectedVersion }, options);
},
- deleteTopic: async (id: string, expectedVersion: number) => {
- await run("deleteTopic", { id, expectedVersion });
+
+ listTopicVariants: (topicId, options) =>
+ read("listTopicVariants", { id: topicId }, options),
+ createTopicVariant: (topicId, body, options) =>
+ command(
+ "createTopicVariant",
+ { id: topicId, body },
+ options,
+ ),
+ updateTopicVariant: (topicId, variantId, body, options) =>
+ command(
+ "updateTopicVariant",
+ { id: topicId, variantId, body },
+ options,
+ ),
+ deleteTopicVariant: async (
+ topicId,
+ variantId,
+ expectedVersion,
+ options,
+ ) => {
+ await command(
+ "deleteTopicVariant",
+ { id: topicId, variantId, expectedVersion },
+ options,
+ );
},
- listProjects: (page?: number, size?: number) =>
- run("listStudioProjects", { ...(page !== undefined ? { page } : {}), ...(size !== undefined ? { size } : {}) }),
- listQuestions: (page?: number, size?: number) =>
- run("listStudioQuestions", {
- ...(page !== undefined ? { page } : {}),
- ...(size !== undefined ? { size } : {}),
- }),
- listProjectDecisions: (projectId: string) =>
- run("listStudioProjectDecisions", { id: projectId }),
- getProject: (id: string) => run("getProjectForEdit", { id }),
- createProject: (title: string) => run("createProject", { title }),
- updateProject: (id: string, body: ProjectUpdateRequest) =>
- run("updateProject", { id, body }),
- listReleases: (page?: number, size?: number) =>
- run("listStudioReleases", { ...(page !== undefined ? { page } : {}), ...(size !== undefined ? { size } : {}) }),
- getRelease: (id: string) => run("getReleaseForEdit", { id }),
- createRelease: (title: string) => run("createRelease", { title }),
- updateRelease: (id: string, body: ReleaseUpdateRequest) =>
- run("updateRelease", { id, body }),
- deleteRelease: async (id: string, expectedVersion: number) => {
- await run("deleteRelease", { id, expectedVersion });
- },
- listProjectActivities: (id: string) =>
- run("listStudioProjectActivities", { id }),
- createProjectActivity: (id: string, body: ProjectActivityRequest) =>
- run("createProjectActivity", { id, body }),
- updateProjectActivity: (
- id: string,
- activityId: string,
- body: UpdateProjectActivityRequest,
- ) => run("updateProjectActivity", { id, activityId, body }),
- deleteProjectActivity: async (id: string, activityId: string, expectedVersion: number) => {
- await run("deleteProjectActivity", { id, activityId, expectedVersion });
+
+ listProjects: (page, size, options) =>
+ read(
+ "listStudioProjects",
+ {
+ ...(page !== undefined ? { page } : {}),
+ ...(size !== undefined ? { size } : {}),
+ },
+ options,
+ ),
+ listQuestions: (page, size, options) =>
+ read(
+ "listStudioQuestions",
+ {
+ ...(page !== undefined ? { page } : {}),
+ ...(size !== undefined ? { size } : {}),
+ },
+ options,
+ ),
+ listProjectDecisions: (projectId, options) =>
+ read(
+ "listStudioProjectDecisions",
+ { id: projectId },
+ options,
+ ),
+
+ getProject: (id, options) =>
+ read("getProjectForEdit", { id }, options),
+ createProject: (title, options) =>
+ command("createProject", { title }, options),
+ updateProject: (id, body, options) =>
+ command("updateProject", { id, body }, options),
+ deleteProject: async (id, expectedVersion, options) => {
+ await command("deleteProject", { id, expectedVersion }, options);
},
publishProject: (
- id: string,
- expectedVersion: number,
- visibility: "PUBLIC" | "UNLISTED" = "PUBLIC",
- ) => run("publishProject", { id, expectedVersion, visibility }),
- unpublishProject: (id: string, expectedVersion: number) =>
- run("unpublishProject", { id, expectedVersion }),
- getHomeFocus: () => run("getHomeFocus", {}),
- updateHomeFocus: (body: HomeFocusRequest) =>
- run("updateHomeFocus", body),
- publishRelease: (id: string, expectedVersion: number) =>
- run("publishRelease", { id, expectedVersion }),
- archiveRelease: (id: string, expectedVersion: number) =>
- run("archiveRelease", { id, expectedVersion }),
+ id,
+ expectedVersion,
+ visibility = "PUBLIC",
+ options,
+ ) =>
+ command(
+ "publishProject",
+ { id, expectedVersion, visibility },
+ options,
+ ),
+ unpublishProject: (id, expectedVersion, options) =>
+ command(
+ "unpublishProject",
+ { id, expectedVersion },
+ options,
+ ),
+
+ listProjectActivities: (id, options) =>
+ read(
+ "listStudioProjectActivities",
+ { id },
+ options,
+ ),
+ createProjectActivity: (id, body, options) =>
+ command(
+ "createProjectActivity",
+ { id, body },
+ options,
+ ),
+ updateProjectActivity: (id, activityId, body, options) =>
+ command(
+ "updateProjectActivity",
+ { id, activityId, body },
+ options,
+ ),
+ deleteProjectActivity: async (
+ id,
+ activityId,
+ expectedVersion,
+ options,
+ ) => {
+ await command(
+ "deleteProjectActivity",
+ { id, activityId, expectedVersion },
+ options,
+ );
+ },
+
+ getHomeFocus: (options) =>
+ read("getHomeFocus", {}, options),
+ updateHomeFocus: (body, options) =>
+ command("updateHomeFocus", body, options),
+
+ listReleases: (page, size, options) =>
+ read(
+ "listStudioReleases",
+ {
+ ...(page !== undefined ? { page } : {}),
+ ...(size !== undefined ? { size } : {}),
+ },
+ options,
+ ),
+ getRelease: (id, options) =>
+ read("getReleaseForEdit", { id }, options),
+ createRelease: (title, options) =>
+ command("createRelease", { title }, options),
+ updateRelease: (id, body, options) =>
+ command("updateRelease", { id, body }, options),
+ deleteRelease: async (id, expectedVersion, options) => {
+ await command("deleteRelease", { id, expectedVersion }, options);
+ },
+ publishRelease: (id, expectedVersion, options) =>
+ command(
+ "publishRelease",
+ { id, expectedVersion },
+ options,
+ ),
+ archiveRelease: (id, expectedVersion, options) =>
+ command(
+ "archiveRelease",
+ { id, expectedVersion },
+ options,
+ ),
+
deleteDocument: async (
kind: DeletableDocumentKind,
id: string,
expectedVersion: number,
+ options: IdempotentOptions,
) => {
- /*
- 삼항으로 이어 붙이면 마지막 else 가 모르는 종류를 다 받아 간다 — 개념이 그렇게 질문
- 삭제로 떨어졌고, 「질문을 찾을 수 없습니다」가 났다. 표로 두면 종류가 늘 때 빠진
- 자리를 타입이 잡는다.
-
- 메서드 매개변수는 TypeScript 에서 bivariant 라, 이 자리에 좁은 종류를 적어도 넓은
- 포트 시그니처를 만족한 것으로 통과한다 — 그래서 타입 검사가 이 결함을 잡지 못했다.
- 아래 표가 `Record` 인 것이 실제로 종류를 강제하는 지점이다.
- */
- const OPERATIONS: Record = {
+ const OPERATIONS: Record = {
CASE: "deleteCaseDraft",
REFERENCE: "deleteReferenceDraft",
QUESTION: "deleteQuestion",
CONCEPT: "deleteConceptDraft",
SETUP: "deleteSetupDraft",
};
- await run(OPERATIONS[kind], { id, expectedVersion });
+ await command(
+ OPERATIONS[kind],
+ { id, expectedVersion },
+ options,
+ );
},
- deleteDecision: async (projectId: string, decisionId: string, expectedVersion: number) => {
- await run("deleteProjectDecision", { id: projectId, decisionId, expectedVersion });
- },
- deleteProject: async (id: string, expectedVersion: number) => {
- await run("deleteProject", { id, expectedVersion });
+ deleteDecision: async (
+ projectId,
+ decisionId,
+ expectedVersion,
+ options,
+ ) => {
+ await command(
+ "deleteProjectDecision",
+ { id: projectId, decisionId, expectedVersion },
+ options,
+ );
},
});
}
diff --git a/src/features/tech-log/adapters/http/http-public-content-gateway.ts b/src/features/tech-log/adapters/http/http-public-content-gateway.ts
index 24e315a..1616ad0 100644
--- a/src/features/tech-log/adapters/http/http-public-content-gateway.ts
+++ b/src/features/tech-log/adapters/http/http-public-content-gateway.ts
@@ -1,6 +1,9 @@
import type {
HomeFocusItem,
LatestRecordEntry,
+ PublicHomeView,
+ PublicProjectSummary,
+ PublicReleaseSummary,
ProjectActivity,
ProjectDecision,
Project,
@@ -30,10 +33,12 @@ import {
} from "./public-content-mapping.ts";
import { cardSummary } from "../../domain/content-format/card-summary.ts";
import type { components } from "../../contracts/public/generated.ts";
-import type { StudioOperationExecutor } from "./http-studio-gateway.ts";
+import type {
+ TechLogHttpBinding,
+ TechLogHttpOperationId,
+} from "./tech-log-http-binding.ts";
import { projectStageLabel } from "../../domain/public/project-phase-labels.ts";
-const ROUTE_ID = "TECH_LOG_PUBLIC";
/**
* A missing slug is an answer, not a failure.
@@ -53,19 +58,6 @@ function gatewayError(operationId: string, detail: string): PublicContentGateway
return error;
}
-/**
- * Reads the backend's error code out of either response shape — RFC7807 puts it
- * at the top level, the ADR-006 envelope nests it under `error`. Without this
- * every failure was reported as the literal "PROBLEM", which told a reader
- * nothing and matched no i18n key.
- */
-function problemCode(problem: unknown): string {
- if (!problem || typeof problem !== "object") return "PROBLEM";
- const body = problem as Readonly<{ code?: unknown; error?: Readonly<{ code?: unknown }> }>;
- if (typeof body.code === "string") return body.code;
- if (typeof body.error?.code === "string") return body.error.code;
- return "PROBLEM";
-}
/*
관계 묶음의 이름을 사람이 읽는 말로 바꾼다. 라벨이 없으면 계약의 키가 그대로 화면에 나온다 —
@@ -105,26 +97,22 @@ export const QUESTION_RELATION_LABELS = Object.freeze({
});
export function createHttpPublicContentGateway(
- deps: Readonly<{ operations: StudioOperationExecutor }>,
+ deps: Readonly<{ http: TechLogHttpBinding }>,
): PublicContentQueries {
- async function read(operationId: string, input: unknown): Promise {
- const outcome = await deps.operations.execute(operationId, input, { routeId: ROUTE_ID });
- if (outcome.kind === "SUCCESS") return outcome.value as T;
- if (outcome.kind === "PROBLEM") {
- // The HTTP status is the authoritative signal, and the only one that
- // holds across both shapes this surface answers with. RFC7807 carries
- // `status` in the body; the ADR-006 envelope does not — it puts the
- // reason in `error.category` and a backend-specific string in
- // `error.code` (PUBLIC_RESOURCE_NOT_FOUND, not NOT_FOUND). The old
- // body-only check matched neither, so every 404 raised the terminal
- // error surface on a page whose real state was "this does not exist".
- if (outcome.metadata.status === 404) return NOT_FOUND;
- throw gatewayError(operationId, problemCode(outcome.problem));
- }
- throw gatewayError(operationId, outcome.kind);
+ async function read(
+ operationId: TechLogHttpOperationId,
+ input: unknown,
+ ): Promise {
+ const result = await deps.http.execute(operationId, input);
+ if (result.ok) return result.value as T;
+ if (result.error.httpStatus === 404) return NOT_FOUND;
+ throw gatewayError(operationId, result.error.code);
}
- async function readOrThrow(operationId: string, input: unknown): Promise {
+ async function readOrThrow(
+ operationId: TechLogHttpOperationId,
+ input: unknown,
+ ): Promise {
const value = await read(operationId, input);
if (value === NOT_FOUND) throw gatewayError(operationId, "NOT_FOUND");
return value;
@@ -185,7 +173,7 @@ export function createHttpPublicContentGateway(
표로 두면 종류가 늘 때 빠진 자리를 타입이 잡는다.
*/
- const OPERATIONS: Record = {
+ const OPERATIONS: Record = {
CASE: "getPublicCase",
REFERENCE: "getPublicReference",
QUESTION: "getPublicQuestion",
@@ -533,23 +521,29 @@ export function createHttpPublicContentGateway(
});
}
- /**
- * 공개 투영이 고른 최근 기록. `entryType` 은 계약이 네 값만 허용하므로 그대로 믿고 쓴다 —
- * 서버가 이미 걸러 보낸다.
- */
- async function getLatestEntries(): Promise {
- const home = await read>[] }>>(
- "getPublicHome",
- {},
- );
- if (home === NOT_FOUND) return [];
+ type PublicHomeProjection = Readonly<{
+ latestEntries?: readonly Readonly>[];
+ focus?: Readonly>;
+ }>;
+
+ function latestEntriesFromHome(
+ home: PublicHomeProjection,
+ ): LatestRecordEntry[] {
return (home.latestEntries ?? []).map((entry) => {
- const topic = entry.primaryTopic as Readonly> | null | undefined;
- const project = entry.primaryProject as Readonly> | null | undefined;
+ const topic = entry.primaryTopic as
+ | Readonly>
+ | null
+ | undefined;
+ const project = entry.primaryProject as
+ | Readonly>
+ | null
+ | undefined;
const path = String(entry.path ?? "");
return Object.freeze({
id: `${String(entry.entryType ?? "")}:${path}`,
- entryType: String(entry.entryType ?? "CASE") as LatestRecordEntry["entryType"],
+ entryType: String(
+ entry.entryType ?? "CASE",
+ ) as LatestRecordEntry["entryType"],
title: String(entry.title ?? ""),
summary: String(entry.summary ?? ""),
path,
@@ -560,13 +554,10 @@ export function createHttpPublicContentGateway(
});
}
- async function getHomeFocusItems(): Promise {
- const home = await read> }>>(
- "getPublicHome",
- {},
- );
- if (home === NOT_FOUND) return [];
- const focus = (home.focus ?? {}) as Readonly>>>;
+ function focusItemsFromHome(home: PublicHomeProjection): HomeFocusItem[] {
+ const focus = (home.focus ?? {}) as Readonly<
+ Record>>
+ >;
const items: HomeFocusItem[] = [];
const work = focus.currentWork;
if (work) {
@@ -577,19 +568,21 @@ export function createHttpPublicContentGateway(
title: String(work.projectName ?? ""),
summary: String(work.purpose ?? ""),
details: Object.freeze([
- /*
- 단계는 저장하는 값(`DESIGN`)이지 방문자에게 할 말이 아니다. 홈의 「지금 집중하는
- 것」이 그 상수를 그대로 찍고 있었다 — 프로젝트 화면은 같은 값을 「설계」로 부르고
- 있어서, 한 사이트가 같은 것을 두 이름으로 말했다.
- */
- { label: "단계", value: projectStageLabel(String(work.phase ?? "")) },
- { label: "현재 목표", value: String(work.currentObjective ?? "") },
+ {
+ label: "단계",
+ value: projectStageLabel(String(work.phase ?? "")),
+ },
+ {
+ label: "현재 목표",
+ value: String(work.currentObjective ?? ""),
+ },
{ label: "다음 작업", value: String(work.nextStep ?? "") },
]),
targetPath: String(work.projectPath ?? "/projects"),
}),
);
}
+
const question = focus.openQuestion;
if (question) {
items.push(
@@ -599,14 +592,28 @@ export function createHttpPublicContentGateway(
title: String(question.question ?? ""),
summary: String(question.summary ?? ""),
details: Object.freeze([
- { label: "확인한 사실", value: ((question.knownFacts as readonly string[]) ?? []).join(" · ") },
- { label: "미해결", value: ((question.unresolvedPoints as readonly string[]) ?? []).join(" · ") },
- { label: "다음 검증", value: String(question.nextVerification ?? "") },
+ {
+ label: "확인한 사실",
+ value: (
+ (question.knownFacts as readonly string[]) ?? []
+ ).join(" · "),
+ },
+ {
+ label: "미해결",
+ value: (
+ (question.unresolvedPoints as readonly string[]) ?? []
+ ).join(" · "),
+ },
+ {
+ label: "다음 검증",
+ value: String(question.nextVerification ?? ""),
+ },
]),
targetPath: String(question.questionPath ?? "/explore/questions"),
}),
);
}
+
const decision = focus.recentDecision;
if (decision) {
items.push(
@@ -616,8 +623,16 @@ export function createHttpPublicContentGateway(
title: String(decision.statement ?? ""),
summary: String(decision.rationale ?? ""),
details: Object.freeze([
- { label: "결정일", value: dateLabel(decision.decidedAt as string) },
- { label: "영향", value: ((decision.consequences as readonly string[]) ?? []).join(" · ") },
+ {
+ label: "결정일",
+ value: dateLabel(decision.decidedAt as string),
+ },
+ {
+ label: "영향",
+ value: (
+ (decision.consequences as readonly string[]) ?? []
+ ).join(" · "),
+ },
]),
targetPath: String(decision.decisionPath ?? "/projects"),
}),
@@ -626,27 +641,56 @@ export function createHttpPublicContentGateway(
return items;
}
- /**
- * 빈 검색어는 검색이 아니라 "카탈로그 전부"라는 뜻이다.
- *
- * 픽스처가 그렇게 동작했고 화면들이 그 의미에 기대어 쓰고 있다 — 홈 타임라인,
- * 프로젝트 목록, 릴리즈 목록, 탐색 필터가 전부 `searchPublicContent("")` 로 카탈로그를
- * 받아 간다. 계약에는 그런 의미가 없고 `q` 는 필수라, 그대로 보내면 400
- * (`PUBLIC_REQUEST_INVALID`) 이 오고 홈을 포함한 네 화면이 통째로 오류 화면이 된다.
- *
- * 그래서 빈 검색어는 검색 엔드포인트로 보내지 않고, 계약이 이미 가진 목록
- * 엔드포인트에서 조립한다. 검색어가 있으면 그때는 서버 검색을 쓴다 — 클라이언트에서
- * 거르면 페이지 밖의 결과를 영영 못 찾는다.
- */
- async function searchPublicContent(query: string): Promise {
- const trimmed = query.trim();
- if (trimmed.length > 0) {
- const page = await read("searchPublicResources", { q: trimmed });
- if (page === NOT_FOUND) return [];
- return (page.items ?? []).map(searchItemToEntity);
+ async function getHome(): Promise {
+ const home = await read("getPublicHome", {});
+ if (home === NOT_FOUND) {
+ return Object.freeze({
+ focusItems: Object.freeze([]),
+ latestEntries: Object.freeze([]),
+ });
}
+ return Object.freeze({
+ focusItems: Object.freeze(focusItemsFromHome(home)),
+ latestEntries: Object.freeze(latestEntriesFromHome(home)),
+ });
+ }
- const [knowledge, questions, projects, releases] = await Promise.all([
+ async function listProjects(): Promise {
+ const page = await read("listPublicProjects", {});
+ if (page === NOT_FOUND) return [];
+ return (page.items ?? []).map((item) =>
+ Object.freeze({
+ slug: String(item.slug ?? ""),
+ title: String(item.name ?? ""),
+ summary: String(item.oneLinePurpose ?? ""),
+ path: String(item.path ?? `/projects/${String(item.slug ?? "")}`),
+ }),
+ );
+ }
+
+ async function getLatestEntries(): Promise {
+ return [...(await getHome()).latestEntries];
+ }
+
+ async function getHomeFocusItems(): Promise {
+ return [...(await getHome()).focusItems];
+ }
+
+ async function listReleases(): Promise {
+ const page = await read("listPublicReleases", {});
+ if (page === NOT_FOUND) return [];
+ return (page.items ?? []).map((item) =>
+ Object.freeze({
+ version: String(item.version ?? ""),
+ title: String(item.title ?? ""),
+ summary: String(item.summary ?? ""),
+ path: String(item.path ?? `/releases/${String(item.version ?? "")}`),
+ }),
+ );
+ }
+
+ async function listCatalog(): Promise {
+ const [knowledge, questions, projectPage, releasePage] = await Promise.all([
read("exploreKnowledge", {}),
read("exploreQuestions", {}),
read("listPublicProjects", {}),
@@ -663,7 +707,7 @@ export function createHttpPublicContentGateway(
for (const item of items(questions)) {
entities.push(recordToEntity(questionListItemToRecord(item)));
}
- for (const item of items(projects)) {
+ for (const item of items(projectPage)) {
entities.push(
Object.freeze({
contentType: "PROJECT",
@@ -673,7 +717,7 @@ export function createHttpPublicContentGateway(
}),
);
}
- for (const item of items(releases)) {
+ for (const item of items(releasePage)) {
entities.push(
Object.freeze({
contentType: "RELEASE",
@@ -686,6 +730,17 @@ export function createHttpPublicContentGateway(
return entities;
}
+ async function searchPublicContent(
+ query: string,
+ ): Promise {
+ const trimmed = query.trim();
+ if (trimmed.length === 0) return listCatalog();
+
+ const page = await read("searchPublicResources", { q: trimmed });
+ if (page === NOT_FOUND) return [];
+ return (page.items ?? []).map(searchItemToEntity);
+ }
+
function recordToEntity(record: PublicRecord): SearchablePublicEntity {
return Object.freeze({
contentType: record.kind,
@@ -709,6 +764,10 @@ export function createHttpPublicContentGateway(
getProjectRecords,
getProjectDecisions,
getProjectActivity,
+ getHome,
+ listProjects,
+ listReleases,
+ listCatalog,
getHomeFocusItems,
getLatestEntries,
searchPublicContent,
diff --git a/src/features/tech-log/adapters/http/http-studio-asset-gateway.ts b/src/features/tech-log/adapters/http/http-studio-asset-gateway.ts
index 143904c..0c5ed91 100644
--- a/src/features/tech-log/adapters/http/http-studio-asset-gateway.ts
+++ b/src/features/tech-log/adapters/http/http-studio-asset-gateway.ts
@@ -11,8 +11,12 @@ import type {
} from "../../application/ports/studio-asset-gateway.ts";
import type { IdempotentOptions, RequestOptions } from "../../application/ports/studio-gateway.ts";
import { isStudioGatewayError } from "../../application/ports/studio-gateway-error.ts";
-import { toStudioGatewayError } from "./studio-error-mapping.ts";
-import { mutationIntent, type StudioOperationExecutor } from "./http-studio-gateway.ts";
+import { toStudioGatewayErrorFromFailure } from "./studio-error-mapping.ts";
+import { mutationIntent } from "./http-studio-gateway.ts";
+import type {
+ TechLogHttpBinding,
+ TechLogHttpOperationId,
+} from "./tech-log-http-binding.ts";
import type { CsrfTokenProvider } from "./studio-session-csrf.ts";
export type StudioAssetUploadTransport = Readonly<{
@@ -24,35 +28,38 @@ export type StudioAssetUploadTransport = Readonly<{
}>;
export type HttpStudioAssetGatewayDependencies = Readonly<{
- operations: StudioOperationExecutor;
+ http: TechLogHttpBinding;
csrf: CsrfTokenProvider;
upload: StudioAssetUploadTransport;
}>;
-const ROUTE_ID = "TECH_LOG_STUDIO_ASSETS";
export function createHttpStudioAssetGateway(
deps: HttpStudioAssetGatewayDependencies,
): StudioAssetGateway {
- async function read(operationId: string, input: unknown, options?: RequestOptions) {
- const outcome = await deps.operations.execute(operationId, input, {
- routeId: ROUTE_ID,
+ async function read(
+ operationId: TechLogHttpOperationId,
+ input: unknown,
+ options?: RequestOptions,
+ ) {
+ const result = await deps.http.execute(operationId, input, {
...(options?.signal ? { signal: options.signal } : {}),
});
- if (outcome.kind !== "SUCCESS") throw toStudioGatewayError(outcome, operationId);
- return outcome.value as T;
+ if (!result.ok) throw toStudioGatewayErrorFromFailure(result.error);
+ return result.value as T;
}
- async function command(operationId: string, input: unknown, options: IdempotentOptions) {
- // Task 4와 동일한 규칙: 헤더는 gateway가 만들지 않는다. `Idempotency-Key`는
- // intent에서, `x-csrf-token`은 credential collaborator에서 온다.
- const outcome = await deps.operations.execute(operationId, input, {
- routeId: ROUTE_ID,
+ async function command(
+ operationId: TechLogHttpOperationId,
+ input: unknown,
+ options: IdempotentOptions,
+ ) {
+ const result = await deps.http.execute(operationId, input, {
intent: mutationIntent(operationId, options.idempotencyKey, input),
...(options.signal ? { signal: options.signal } : {}),
});
- if (outcome.kind === "SUCCESS") return outcome.value as T;
- throw toStudioGatewayError(outcome, operationId);
+ if (result.ok) return result.value as T;
+ throw toStudioGatewayErrorFromFailure(result.error);
}
const gateway: StudioAssetGateway = {
diff --git a/src/features/tech-log/adapters/http/http-studio-gateway.ts b/src/features/tech-log/adapters/http/http-studio-gateway.ts
index 225b9ca..d4ec4dc 100644
--- a/src/features/tech-log/adapters/http/http-studio-gateway.ts
+++ b/src/features/tech-log/adapters/http/http-studio-gateway.ts
@@ -4,33 +4,22 @@ import {
MUTATION_INTENT_BOUNDS,
type MutationIntent,
} from "../../../../contracts/mutation-intent.ts";
-import type { HttpExecutionOutcome } from "../../../../adapters/http/index.ts";
import { stableStringify } from "../stable-stringify.ts";
import type {
IdempotentOptions,
RequestOptions,
StudioGateway,
} from "../../application/ports/studio-gateway.ts";
-import { toStudioGatewayError } from "./studio-error-mapping.ts";
-
-export type StudioOperationExecutor = Readonly<{
- execute(
- operationId: string,
- input: unknown,
- context: Readonly<{
- routeId: string;
- signal?: AbortSignal;
- intent?: MutationIntent;
- }>,
- ): Promise>;
-}>;
+import { toStudioGatewayErrorFromFailure } from "./studio-error-mapping.ts";
+import type {
+ TechLogHttpBinding,
+ TechLogHttpOperationId,
+} from "./tech-log-http-binding.ts";
export type HttpStudioGatewayDependencies = Readonly<{
- operations: StudioOperationExecutor;
+ http: TechLogHttpBinding;
}>;
-const ROUTE_ID = "TECH_LOG_STUDIO";
-
const IDENTITY_ENCODER = new TextEncoder();
const IDENTITY_DECODER = new TextDecoder();
@@ -42,7 +31,7 @@ const IDENTITY_DECODER = new TextDecoder();
* "A caller-supplied value is never trimmed, regenerated or silently dropped").
*/
export function mutationIntent(
- operationId: string,
+ operationId: TechLogHttpOperationId,
idempotencyKey: string,
input: unknown,
): MutationIntent {
@@ -85,30 +74,28 @@ export function createHttpStudioGateway(
deps: HttpStudioGatewayDependencies,
): StudioGateway {
async function read(
- operationId: string,
+ operationId: TechLogHttpOperationId,
input: unknown,
options?: RequestOptions,
): Promise {
- const outcome = await deps.operations.execute(operationId, input, {
- routeId: ROUTE_ID,
+ const result = await deps.http.execute(operationId, input, {
...(options?.signal ? { signal: options.signal } : {}),
});
- if (outcome.kind !== "SUCCESS") throw toStudioGatewayError(outcome, operationId);
- return outcome.value as T;
+ if (!result.ok) throw toStudioGatewayErrorFromFailure(result.error);
+ return result.value as T;
}
async function command(
- operationId: string,
+ operationId: TechLogHttpOperationId,
input: unknown,
options: IdempotentOptions,
): Promise {
- const outcome = await deps.operations.execute(operationId, input, {
- routeId: ROUTE_ID,
+ const result = await deps.http.execute(operationId, input, {
intent: mutationIntent(operationId, options.idempotencyKey, input),
...(options.signal ? { signal: options.signal } : {}),
});
- if (outcome.kind === "SUCCESS") return outcome.value as T;
- throw toStudioGatewayError(outcome, operationId);
+ if (result.ok) return result.value as T;
+ throw toStudioGatewayErrorFromFailure(result.error);
}
const gateway: StudioGateway = {
diff --git a/src/features/tech-log/adapters/http/studio-error-mapping.ts b/src/features/tech-log/adapters/http/studio-error-mapping.ts
index 7967580..cde8256 100644
--- a/src/features/tech-log/adapters/http/studio-error-mapping.ts
+++ b/src/features/tech-log/adapters/http/studio-error-mapping.ts
@@ -1,4 +1,5 @@
import type { HttpExecutionOutcome } from "../../../../adapters/http/index.ts";
+import type { AppFailure } from "../../../../contracts/errors.ts";
import { StudioGatewayError } from "../../application/ports/studio-gateway-error.ts";
import type { ProblemDetails } from "../../contracts/studio/contract.ts";
@@ -92,3 +93,45 @@ export function toStudioGatewayError(
throw new Error(`${operationId}: success outcome is not an error`);
}
}
+
+
+function fallbackStatus(failure: AppFailure): number {
+ if (failure.httpStatus !== undefined) return failure.httpStatus;
+ switch (failure.kind) {
+ case "AUTH_REQUIRED":
+ return 401;
+ case "FORBIDDEN":
+ return 403;
+ case "RATE_LIMITED":
+ return 429;
+ case "REQUEST_ABORTED":
+ return 499;
+ case "REQUEST_TIMEOUT":
+ return 504;
+ case "NETWORK_UNREACHABLE":
+ case "SERVER_FAILURE":
+ return 503;
+ default:
+ return 502;
+ }
+}
+
+export function toStudioGatewayErrorFromFailure(
+ failure: AppFailure,
+): StudioGatewayError {
+ const status = fallbackStatus(failure);
+ const code: ProblemDetails["code"] =
+ CODES.has(failure.code)
+ ? failure.code as ProblemDetails["code"]
+ : failure.kind === "AUTH_REQUIRED"
+ ? "AUTHENTICATION_REQUIRED"
+ : failure.kind === "FORBIDDEN"
+ ? "STUDIO_ACCESS_DENIED"
+ : "STUDIO_UNAVAILABLE";
+ return synthetic(
+ code,
+ status,
+ failure.detail ?? (failure.operationId + ": " + failure.code),
+ failure.retryable,
+ );
+}
diff --git a/src/features/tech-log/adapters/http/tech-log-http-binding.ts b/src/features/tech-log/adapters/http/tech-log-http-binding.ts
new file mode 100644
index 0000000..d285455
--- /dev/null
+++ b/src/features/tech-log/adapters/http/tech-log-http-binding.ts
@@ -0,0 +1,130 @@
+import {
+ createFeatureHttpBinding,
+ defineFeatureHttpOperation,
+ type FeatureHttpBinding,
+ type FeatureHttpOperation,
+ type InstalledHttpOperationExecutor,
+ type SafeResponseMetadata,
+} from "../../../../adapters/http/index.ts";
+import { mappingSuccess } from "../../../../contracts/boundary-mapper.ts";
+import { kindForStatus } from "../../../../contracts/errors.ts";
+import type { ProblemDetails } from "../../contracts/studio/contract.ts";
+import { TECH_LOG_MANAGEMENT_HTTP_CONTRACTS } from "../../contracts/tech-log-management-contract-contribution.ts";
+import { TECH_LOG_PUBLIC_HTTP_CONTRACTS } from "../../contracts/tech-log-public-contract-contribution.ts";
+import { TECH_LOG_STUDIO_HTTP_CONTRACTS } from "../../contracts/tech-log-studio-contract-contribution.ts";
+
+const TECH_LOG_HTTP_CONTRACTS = Object.freeze([
+ ...TECH_LOG_STUDIO_HTTP_CONTRACTS,
+ ...TECH_LOG_PUBLIC_HTTP_CONTRACTS,
+ ...TECH_LOG_MANAGEMENT_HTTP_CONTRACTS,
+] as const);
+
+type TechLogHttpContract = (typeof TECH_LOG_HTTP_CONTRACTS)[number];
+
+export type TechLogHttpOperationId =
+ TechLogHttpContract["contract"]["operationId"];
+
+type ContractFor =
+ Extract<
+ TechLogHttpContract,
+ Readonly<{
+ contract: Readonly<{ operationId: OperationId }>;
+ }>
+ >;
+
+type TechLogRouteId =
+ | "TECH_LOG_STUDIO"
+ | "TECH_LOG_STUDIO_ASSETS"
+ | "TECH_LOG_PUBLIC";
+
+type TechLogHttpOperations = Readonly<{
+ [OperationId in TechLogHttpOperationId]: FeatureHttpOperation<
+ ContractFor,
+ unknown,
+ TechLogRouteId
+ >;
+}>;
+
+const ASSET_OPERATION_IDS = new Set([
+ "listStudioAssets",
+ "getStudioAsset",
+ "updateStudioAsset",
+ "deleteStudioAsset",
+]);
+
+const PUBLIC_OPERATION_IDS = new Set(
+ TECH_LOG_PUBLIC_HTTP_CONTRACTS.map(
+ (contract) => contract.contract.operationId as TechLogHttpOperationId,
+ ),
+);
+
+function routeIdFor(operationId: TechLogHttpOperationId): TechLogRouteId {
+ if (PUBLIC_OPERATION_IDS.has(operationId)) return "TECH_LOG_PUBLIC";
+ if (ASSET_OPERATION_IDS.has(operationId)) return "TECH_LOG_STUDIO_ASSETS";
+ return "TECH_LOG_STUDIO";
+}
+
+function problemCode(problem: unknown): string {
+ if (!problem || typeof problem !== "object") return "CONTRACT_PROBLEM";
+ const candidate = problem as Readonly<{
+ code?: unknown;
+ error?: Readonly<{ code?: unknown }>;
+ }>;
+ if (typeof candidate.code === "string") return candidate.code;
+ if (typeof candidate.error?.code === "string") return candidate.error.code;
+ return "CONTRACT_PROBLEM";
+}
+
+function problemDetail(problem: unknown): string | undefined {
+ if (!problem || typeof problem !== "object") return undefined;
+ const candidate = problem as Partial &
+ Readonly<{ error?: Readonly<{ message?: unknown }> }>;
+ if (typeof candidate.detail === "string" && candidate.detail.length > 0) {
+ return candidate.detail;
+ }
+ return typeof candidate.error?.message === "string" &&
+ candidate.error.message.length > 0
+ ? candidate.error.message
+ : undefined;
+}
+
+function mapProblem(problem: unknown, metadata: SafeResponseMetadata) {
+ const detail = problemDetail(problem);
+ return Object.freeze({
+ kind: kindForStatus(metadata.status),
+ code: problemCode(problem),
+ ...(detail === undefined ? {} : { detail }),
+ });
+}
+
+function buildOperations(): TechLogHttpOperations {
+ const registry: Record> =
+ Object.create(null);
+
+ for (const contract of TECH_LOG_HTTP_CONTRACTS) {
+ const operationId = contract.contract.operationId as TechLogHttpOperationId;
+ if (Object.hasOwn(registry, operationId)) {
+ throw new TypeError("Duplicate TechLog HTTP operation: " + operationId);
+ }
+ registry[operationId] = defineFeatureHttpOperation({
+ contract,
+ routeId: routeIdFor(operationId),
+ mapSuccess: mappingSuccess,
+ mapProblem,
+ }) as FeatureHttpOperation;
+ }
+
+ return Object.freeze(registry) as unknown as TechLogHttpOperations;
+}
+
+export const TECH_LOG_HTTP_OPERATIONS = buildOperations();
+
+export type TechLogHttpBinding = FeatureHttpBinding<
+ typeof TECH_LOG_HTTP_OPERATIONS
+>;
+
+export function createTechLogHttpBinding(
+ executor: InstalledHttpOperationExecutor,
+): TechLogHttpBinding {
+ return createFeatureHttpBinding(executor, TECH_LOG_HTTP_OPERATIONS);
+}
diff --git a/src/features/tech-log/adapters/static/content.ts b/src/features/tech-log/adapters/static/content.ts
index 43e3363..dde0369 100644
--- a/src/features/tech-log/adapters/static/content.ts
+++ b/src/features/tech-log/adapters/static/content.ts
@@ -1,5 +1,5 @@
import { projects, publicRecords, releases } from "./public-content.ts";
-import { getHomeFocusItems, searchPublicContent } from "./public-query.ts";
+import { getHomeFocusItems, listCatalog } from "./public-query.ts";
export { publicSiteConfig as siteConfig } from "../../contracts/public-site-config.ts";
@@ -82,7 +82,7 @@ export const exploreEntries = [
},
] as const;
-export const searchEntries = searchPublicContent("");
+export const searchEntries = listCatalog();
const fetchJoinCase = publicRecords.find(
(record) =>
diff --git a/src/features/tech-log/adapters/static/public-query.ts b/src/features/tech-log/adapters/static/public-query.ts
index 43c2c2e..72ef0d3 100644
--- a/src/features/tech-log/adapters/static/public-query.ts
+++ b/src/features/tech-log/adapters/static/public-query.ts
@@ -326,13 +326,17 @@ function releaseSearchEntity(release: Release): SearchablePublicEntity {
};
}
-export function searchPublicContent(query: string): SearchablePublicEntity[] {
- const normalizedQuery = query.trim().toLocaleLowerCase("ko-KR");
- const entities = [
+export function listCatalog(): SearchablePublicEntity[] {
+ return [
...publicRecords.map(recordSearchEntity),
...projects.map(projectSearchEntity),
...releases.map(releaseSearchEntity),
];
+}
+
+export function searchPublicContent(query: string): SearchablePublicEntity[] {
+ const normalizedQuery = query.trim().toLocaleLowerCase("ko-KR");
+ const entities = listCatalog();
if (!normalizedQuery) return entities;
@@ -393,6 +397,35 @@ export const publicContentQueries = Object.freeze({
async getTopicDetail(slug: string) {
return getTopicDetail(slug);
},
+ async getHome() {
+ return Object.freeze({
+ focusItems: Object.freeze(getHomeFocusItems()),
+ latestEntries: Object.freeze(getLatestEntries()),
+ });
+ },
+ async listProjects() {
+ return projects.map((project) =>
+ Object.freeze({
+ slug: project.slug,
+ title: project.title,
+ summary: project.summary,
+ path: `/projects/${project.slug}`,
+ }),
+ );
+ },
+ async listReleases() {
+ return releases.map((release) =>
+ Object.freeze({
+ version: release.version,
+ title: release.title,
+ summary: release.summary,
+ path: release.path,
+ }),
+ );
+ },
+ async listCatalog() {
+ return listCatalog();
+ },
async getLatestEntries() {
return getLatestEntries();
},
diff --git a/src/features/tech-log/application/ports/management-gateway.ts b/src/features/tech-log/application/ports/management-gateway.ts
index 3987580..334c588 100644
--- a/src/features/tech-log/application/ports/management-gateway.ts
+++ b/src/features/tech-log/application/ports/management-gateway.ts
@@ -17,92 +17,182 @@ import type {
TopicEdit,
TopicVariantEdit,
} from "../../contracts/management/contract.ts";
+import type {
+ IdempotentOptions,
+ RequestOptions,
+} from "./studio-gateway.ts";
/**
* 주제·프로젝트·릴리즈·작업본 삭제 관리 표면.
*
- * Studio 게이트웨이와 같은 실패 규약이다 — 실패는 던지고, 화면이 잡는다. MOCK 대응물을 두지
- * 않는 것도 의도다: 이 표면은 백엔드가 없으면 존재할 이유가 없고, 픽스처를 만들면 실제로는 만들
- * 수 없는 주제를 화면이 보여주게 된다.
+ * 읽기와 명령 모두 Studio server-state runtime의 cancellation/idempotency
+ * 계약을 끝까지 전달할 수 있어야 한다. presentation이 공통 mutation
+ * coordinator를 사용해도 이 포트에서 옵션을 버리면 실제 HTTP 실행은 그
+ * 보호를 받지 못한다.
*/
-/** 이 게이트웨이로 지울 수 있는 문서 종류. 결정은 프로젝트 경로를 요구하므로 별도 메서드다. */
-export type DeletableDocumentKind = "CASE" | "REFERENCE" | "QUESTION" | "CONCEPT" | "SETUP";
+export type DeletableDocumentKind =
+ | "CASE"
+ | "REFERENCE"
+ | "QUESTION"
+ | "CONCEPT"
+ | "SETUP";
export type ManagementGateway = Readonly<{
- listTopics(): Promise;
- createTopic(input: TopicEdit): Promise;
- updateTopic(id: string, body: TopicEdit): Promise;
- deleteTopic(id: string, expectedVersion: number): Promise;
- /*
- 주제 안의 축. 「구조」「조회 전략」처럼 주제마다 이름이 다른 축 하나가 접근 하나고, 기록은
- 거기에 걸린다. 아무 축에도 걸리지 않은 기록은 그 주제의 공통 기록이다.
- */
- listTopicVariants(topicId: string): Promise;
- createTopicVariant(topicId: string, body: TopicVariantEdit): Promise;
+ listTopics(options?: RequestOptions): Promise;
+ createTopic(
+ input: TopicEdit,
+ options: IdempotentOptions,
+ ): Promise;
+ updateTopic(
+ id: string,
+ body: TopicEdit,
+ options: IdempotentOptions,
+ ): Promise;
+ deleteTopic(
+ id: string,
+ expectedVersion: number,
+ options: IdempotentOptions,
+ ): Promise;
+
+ listTopicVariants(
+ topicId: string,
+ options?: RequestOptions,
+ ): Promise;
+ createTopicVariant(
+ topicId: string,
+ body: TopicVariantEdit,
+ options: IdempotentOptions,
+ ): Promise;
updateTopicVariant(
topicId: string,
variantId: string,
body: TopicVariantEdit,
+ options: IdempotentOptions,
): Promise;
- deleteTopicVariant(topicId: string, variantId: string, expectedVersion: number): Promise;
- listProjects(page?: number, size?: number): Promise;
- /*
- 홈 「지금 집중하는 것」 편집기가 쓰는 둘. 질문 항목은 `primaryProject` 를 들고 오므로 그것으로
- 거르고, 결정은 경로 자체가 프로젝트를 요구하므로 고른 프로젝트의 것만 온다.
- */
- listQuestions(page?: number, size?: number): Promise;
- listProjectDecisions(projectId: string): Promise;
- getProject(id: string): Promise;
- createProject(title: string): Promise;
- updateProject(id: string, body: ProjectUpdateRequest): Promise;
- deleteProject(id: string, expectedVersion: number): Promise;
- /**
- * 프로젝트 게시. 프로젝트는 Studio 문서가 아니라 게시 파이프라인 밖에 있고, 그래서 문서를
- * 게시해도 그 문서가 속한 프로젝트는 비공개로 남는다 — 공개 화면(프로젝트 목록·프로필의
- * "현재 프로젝트"·홈의 focus)은 모두 게시된 프로젝트만 읽으므로, 이 호출 없이는 어디에도
- * 나타나지 않는다.
- */
+ deleteTopicVariant(
+ topicId: string,
+ variantId: string,
+ expectedVersion: number,
+ options: IdempotentOptions,
+ ): Promise;
+
+ listProjects(
+ page?: number,
+ size?: number,
+ options?: RequestOptions,
+ ): Promise;
+ listQuestions(
+ page?: number,
+ size?: number,
+ options?: RequestOptions,
+ ): Promise;
+ listProjectDecisions(
+ projectId: string,
+ options?: RequestOptions,
+ ): Promise;
+
+ getProject(
+ id: string,
+ options?: RequestOptions,
+ ): Promise;
+ createProject(
+ title: string,
+ options: IdempotentOptions,
+ ): Promise;
+ updateProject(
+ id: string,
+ body: ProjectUpdateRequest,
+ options: IdempotentOptions,
+ ): Promise;
+ deleteProject(
+ id: string,
+ expectedVersion: number,
+ options: IdempotentOptions,
+ ): Promise;
publishProject(
id: string,
expectedVersion: number,
- visibility?: "PUBLIC" | "UNLISTED",
+ visibility: "PUBLIC" | "UNLISTED" | undefined,
+ options: IdempotentOptions,
): Promise;
- unpublishProject(id: string, expectedVersion: number): Promise;
- /**
- * 프로젝트 활동. 공개 프로젝트 화면의 "활동" 은 이 목록을 투영 없이 직접 읽으므로, 여기서
- * 만든 줄이 곧 그 화면이다.
- */
- listProjectActivities(id: string): Promise;
- createProjectActivity(id: string, body: ProjectActivityRequest): Promise;
+ unpublishProject(
+ id: string,
+ expectedVersion: number,
+ options: IdempotentOptions,
+ ): Promise;
+
+ listProjectActivities(
+ id: string,
+ options?: RequestOptions,
+ ): Promise;
+ createProjectActivity(
+ id: string,
+ body: ProjectActivityRequest,
+ options: IdempotentOptions,
+ ): Promise;
updateProjectActivity(
id: string,
activityId: string,
body: UpdateProjectActivityRequest,
+ options: IdempotentOptions,
): Promise;
- deleteProjectActivity(id: string, activityId: string, expectedVersion: number): Promise;
- /** 공개 홈이 무엇을 앞에 둘지. 세 슬롯이 모두 비면 홈은 그 영역을 아예 그리지 않는다. */
- getHomeFocus(): Promise;
- updateHomeFocus(body: HomeFocusRequest): Promise;
- listReleases(page?: number, size?: number): Promise;
- getRelease(id: string): Promise;
- createRelease(title: string): Promise;
- updateRelease(id: string, body: ReleaseUpdateRequest): Promise;
- deleteRelease(id: string, expectedVersion: number): Promise;
- publishRelease(id: string, expectedVersion: number): Promise;
- archiveRelease(id: string, expectedVersion: number): Promise;
- /**
- * 작업본 삭제. 종류마다 다른 endpoint 인 것은 계약의 모양이자 저장 구조다 — Case 와 Reference
- * 는 한 테이블을 나눠 쓰고 Question 은 다른 테이블이다. Decision 은 계약에 삭제가 없다:
- * 그쪽 수명주기는 수락·기각·대체이고, 그건 지우는 것이 아니라 무슨 일이 있었는지 남기는 것이다.
- */
- /**
- * 작업본 삭제. 종류를 손으로 나열하지 않는다 — 개념을 더했을 때 이 목록이 셋에 머물러
- * 있었고, 부르는 쪽이 `as` 로 캐스팅해 넘기는 바람에 개념이 질문 삭제로 떨어졌다.
- */
- deleteDocument(kind: DeletableDocumentKind, id: string, expectedVersion: number): Promise;
- /**
- * Decision 은 프로젝트에 속하므로 경로가 둘을 요구한다. 다른 종류처럼 한 번에 묶지 않는 이유는
- * 계약이 그렇게 선언했고, 실제로도 프로젝트 밖의 Decision 은 존재하지 않기 때문이다.
- */
- deleteDecision(projectId: string, decisionId: string, expectedVersion: number): Promise;
+ deleteProjectActivity(
+ id: string,
+ activityId: string,
+ expectedVersion: number,
+ options: IdempotentOptions,
+ ): Promise;
+
+ getHomeFocus(options?: RequestOptions): Promise;
+ updateHomeFocus(
+ body: HomeFocusRequest,
+ options: IdempotentOptions,
+ ): Promise;
+
+ listReleases(
+ page?: number,
+ size?: number,
+ options?: RequestOptions,
+ ): Promise;
+ getRelease(
+ id: string,
+ options?: RequestOptions,
+ ): Promise;
+ createRelease(
+ title: string,
+ options: IdempotentOptions,
+ ): Promise;
+ updateRelease(
+ id: string,
+ body: ReleaseUpdateRequest,
+ options: IdempotentOptions,
+ ): Promise;
+ deleteRelease(
+ id: string,
+ expectedVersion: number,
+ options: IdempotentOptions,
+ ): Promise;
+ publishRelease(
+ id: string,
+ expectedVersion: number,
+ options: IdempotentOptions,
+ ): Promise;
+ archiveRelease(
+ id: string,
+ expectedVersion: number,
+ options: IdempotentOptions,
+ ): Promise;
+
+ deleteDocument(
+ kind: DeletableDocumentKind,
+ id: string,
+ expectedVersion: number,
+ options: IdempotentOptions,
+ ): Promise;
+ deleteDecision(
+ projectId: string,
+ decisionId: string,
+ expectedVersion: number,
+ options: IdempotentOptions,
+ ): Promise;
}>;
diff --git a/src/features/tech-log/application/ports/public-content-queries.ts b/src/features/tech-log/application/ports/public-content-queries.ts
index 9d1a4b6..c7ed1f0 100644
--- a/src/features/tech-log/application/ports/public-content-queries.ts
+++ b/src/features/tech-log/application/ports/public-content-queries.ts
@@ -325,6 +325,25 @@ export type HomeFocusItem = {
targetPath: string;
};
+export type PublicHomeView = Readonly<{
+ focusItems: readonly HomeFocusItem[];
+ latestEntries: readonly LatestRecordEntry[];
+}>;
+
+export type PublicProjectSummary = Readonly<{
+ slug: string;
+ title: string;
+ summary: string;
+ path: string;
+}>;
+
+export type PublicReleaseSummary = Readonly<{
+ version: string;
+ title: string;
+ summary: string;
+ path: string;
+}>;
+
export type RecordFilters = {
kind?: RecordKind;
topic?: string;
@@ -388,6 +407,14 @@ export type PublicContentQueries = Readonly<{
listContacts(): Promise;
/** 주제 한 편. 주제가 없으면 `undefined`. */
getTopicDetail(slug: string): Promise;
+ /** 홈 투영은 한 번 읽어 focus/latest를 같은 snapshot에서 돌려준다. */
+ getHome(): Promise;
+ /** 검색과 분리된 명시적 프로젝트 목록 use case. */
+ listProjects(): Promise;
+ /** 검색과 분리된 명시적 릴리즈 목록 use case. */
+ listReleases(): Promise;
+ /** type-ahead/filter가 로컬에서 거를 공개 카탈로그 snapshot. */
+ listCatalog(): Promise;
getLatestEntries(): Promise;
getHomeFocusItems(): Promise;
searchPublicContent(query: string): Promise;
diff --git a/src/features/tech-log/application/studio-application.ts b/src/features/tech-log/application/studio-application.ts
new file mode 100644
index 0000000..5f3cee3
--- /dev/null
+++ b/src/features/tech-log/application/studio-application.ts
@@ -0,0 +1,243 @@
+import type {
+ ManagementGateway,
+ DeletableDocumentKind,
+} from "./ports/management-gateway.ts";
+import { ManagementGatewayError } from "./ports/management-gateway-error.ts";
+import type {
+ StudioAssetGateway,
+ ListAssetsQuery,
+ UploadAssetForm,
+} from "./ports/studio-asset-gateway.ts";
+import type {
+ StudioGateway,
+ CatalogQuery,
+ ListDocumentsQuery,
+ ListPublicationsQuery,
+} from "./ports/studio-gateway.ts";
+import { isStudioGatewayError } from "./ports/studio-gateway-error.ts";
+import type {
+ Asset,
+ AssetDetail,
+ AssetPage,
+ CatalogPage,
+ CreateDocumentInput,
+ CreatePreviewCommand,
+ DocumentPage,
+ PreviewDetail,
+ PublicationPage,
+ PublicationSnapshot,
+ PublicPreview,
+ PublishDocumentCommand,
+ PublishResult,
+ SaveDocumentCommand,
+ StudioDashboard,
+ UnpublishCommand,
+ UpdateAssetCommand,
+ ValidationReport,
+ ValidateDocumentCommand,
+ WorkingCopy,
+ WorkingCopyDetail,
+} from "../contracts/studio/contract.ts";
+import type {
+ CreateDraftResponse,
+ DecisionResponse,
+ HomeFocusRequest,
+ HomeFocusResponse,
+ ProjectActivityRequest,
+ ProjectActivityResponse,
+ ProjectEditResponse,
+ ProjectIndexPage,
+ ProjectUpdateRequest,
+ PublishResponse,
+ QuestionIndexPage,
+ ReleaseEditResponse,
+ ReleaseIndexPage,
+ ReleaseUpdateRequest,
+ TopicEdit,
+ TopicVariantEdit,
+ UpdateProjectActivityRequest,
+} from "../contracts/management/contract.ts";
+
+export type StudioQueryContext = Readonly<{ signal?: AbortSignal }>;
+export type StudioCommandContext = Readonly<{
+ signal?: AbortSignal;
+ idempotencyKey: string;
+}>;
+
+export type StudioWorkspaceQueries = Readonly<{
+ getDashboard(context?: StudioQueryContext): Promise;
+ listDocuments(query: ListDocumentsQuery, context?: StudioQueryContext): Promise;
+ listPublications(query: ListPublicationsQuery, context?: StudioQueryContext): Promise;
+ getPublicationSnapshot(publicationEventId: string, context?: StudioQueryContext): Promise;
+ getCatalog(query: CatalogQuery, context?: StudioQueryContext): Promise;
+}>;
+
+export type StudioWorkspaceCommands = Readonly<{
+ createDocument(input: CreateDocumentInput, context: StudioCommandContext): Promise;
+ unpublishPublication(publicationId: string, command: UnpublishCommand, context: StudioCommandContext): Promise;
+}>;
+
+export type StudioDocumentQueries = Readonly<{
+ getDocument(documentId: string, context?: StudioQueryContext): Promise;
+ getCurrentPreview(documentId: string, context?: StudioQueryContext): Promise;
+}>;
+
+export type StudioDocumentCommands = Readonly<{
+ saveDocument(documentId: string, command: SaveDocumentCommand, context: StudioCommandContext): Promise;
+ validateDocument(documentId: string, command: ValidateDocumentCommand, context: StudioCommandContext): Promise;
+ createPreview(documentId: string, command: CreatePreviewCommand, context: StudioCommandContext): Promise;
+ publishDocument(documentId: string, command: PublishDocumentCommand, context: StudioCommandContext): Promise;
+}>;
+
+export type StudioAssetQueries = Readonly<{
+ listAssets(query: ListAssetsQuery, context?: StudioQueryContext): Promise;
+ getAsset(assetId: string, context?: StudioQueryContext): Promise;
+}>;
+
+export type StudioAssetCommands = Readonly<{
+ uploadAsset(form: UploadAssetForm, context: StudioCommandContext): Promise;
+ updateAssetMetadata(assetId: string, command: UpdateAssetCommand, context: StudioCommandContext): Promise;
+ deleteAsset(assetId: string, context: StudioCommandContext): Promise;
+}>;
+
+export type StudioManagementQueries = Readonly<{
+ listTopics(context?: StudioQueryContext): Promise;
+ listTopicVariants(topicId: string, context?: StudioQueryContext): Promise;
+ listProjects(page?: number, size?: number, context?: StudioQueryContext): Promise;
+ listQuestions(page?: number, size?: number, context?: StudioQueryContext): Promise;
+ listProjectDecisions(projectId: string, context?: StudioQueryContext): Promise;
+ getProject(id: string, context?: StudioQueryContext): Promise;
+ listProjectActivities(id: string, context?: StudioQueryContext): Promise;
+ getHomeFocus(context?: StudioQueryContext): Promise;
+ listReleases(page?: number, size?: number, context?: StudioQueryContext): Promise;
+ getRelease(id: string, context?: StudioQueryContext): Promise;
+}>;
+
+export type StudioManagementCommands = Readonly<{
+ createTopic(input: TopicEdit, context: StudioCommandContext): Promise;
+ updateTopic(id: string, body: TopicEdit, context: StudioCommandContext): Promise;
+ deleteTopic(id: string, expectedVersion: number, context: StudioCommandContext): Promise;
+ createTopicVariant(topicId: string, body: TopicVariantEdit, context: StudioCommandContext): Promise;
+ updateTopicVariant(topicId: string, variantId: string, body: TopicVariantEdit, context: StudioCommandContext): Promise;
+ deleteTopicVariant(topicId: string, variantId: string, expectedVersion: number, context: StudioCommandContext): Promise;
+ createProject(title: string, context: StudioCommandContext): Promise;
+ updateProject(id: string, body: ProjectUpdateRequest, context: StudioCommandContext): Promise;
+ deleteProject(id: string, expectedVersion: number, context: StudioCommandContext): Promise;
+ publishProject(id: string, expectedVersion: number, visibility: "PUBLIC" | "UNLISTED" | undefined, context: StudioCommandContext): Promise;
+ unpublishProject(id: string, expectedVersion: number, context: StudioCommandContext): Promise;
+ createProjectActivity(id: string, body: ProjectActivityRequest, context: StudioCommandContext): Promise;
+ updateProjectActivity(id: string, activityId: string, body: UpdateProjectActivityRequest, context: StudioCommandContext): Promise;
+ deleteProjectActivity(id: string, activityId: string, expectedVersion: number, context: StudioCommandContext): Promise;
+ updateHomeFocus(body: HomeFocusRequest, context: StudioCommandContext): Promise;
+ createRelease(title: string, context: StudioCommandContext): Promise;
+ updateRelease(id: string, body: ReleaseUpdateRequest, context: StudioCommandContext): Promise;
+ deleteRelease(id: string, expectedVersion: number, context: StudioCommandContext): Promise;
+ publishRelease(id: string, expectedVersion: number, context: StudioCommandContext): Promise;
+ archiveRelease(id: string, expectedVersion: number, context: StudioCommandContext): Promise