refactor(M02): Api_Fetch 옛 이름 별칭 지움 — copyBasis · 표번 · Kind basis
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EUypcnp5d1gU2aeKh9F2H7
This commit is contained in:
@@ -8,9 +8,8 @@ import { API_BASE_URL } from "@config/config_frontend";
|
||||
/** 층 이름 — 서버와 같은 글 */
|
||||
export type Layer = "system" | "company" | "personal" | "project";
|
||||
/** 서버 종류 — 화면의 「표 양식」 = table · 「도면 양식」 = drawing · 「구조물 도면」 = structure ·
|
||||
* 「면적산출」 = area · 「재료산출」 = material(둘 다 구조물집계표 열마다 한 통합문서) ·
|
||||
* @deprecated "basis" — 옛 이름(서버 길은 area 로 보냄) · sub2 가 새 이름으로 옮기면 지움 */
|
||||
export type Kind = "table" | "drawing" | "structure" | "area" | "material" | "basis";
|
||||
* 「면적산출」 = area · 「재료산출」 = material(둘 다 구조물집계표 열마다 한 통합문서) */
|
||||
export type Kind = "table" | "drawing" | "structure" | "area" | "material";
|
||||
|
||||
export interface TemplateInfo {
|
||||
종류: Kind;
|
||||
@@ -50,10 +49,8 @@ const enc = encodeURIComponent;
|
||||
const q = (projectId: string | null): string => (projectId ? `?project_id=${enc(projectId)}` : "");
|
||||
const head = (layer: Layer): string =>
|
||||
layer === "system" ? "/templates" : `/layers/${layer}/templates`;
|
||||
/** 서버 길의 종류 — 옛 "basis" 는 "area" 로 */
|
||||
const kindPath = (kind: Kind): string => (kind === "basis" ? "area" : kind);
|
||||
const item = (layer: Layer, kind: Kind, name: string, projectId: string | null): string =>
|
||||
`${head(layer)}/${kindPath(kind)}/${enc(name)}${layer === "system" ? "" : q(projectId)}`;
|
||||
`${head(layer)}/${kind}/${enc(name)}${layer === "system" ? "" : q(projectId)}`;
|
||||
|
||||
/** 시스템 길은 배열 · 층 길은 `{층, 양식: [...]}` — 둘 다 목록으로 */
|
||||
export const listTemplates = async (
|
||||
@@ -85,7 +82,7 @@ export const saveTemplate = (
|
||||
|
||||
/** 시스템 층만 지움 */
|
||||
export const deleteTemplate = (kind: Kind, name: string, 판: string): Promise<{ ok: boolean }> =>
|
||||
call(`/templates/${kindPath(kind)}/${enc(name)}?판=${enc(판)}`, { method: "DELETE" });
|
||||
call(`/templates/${kind}/${enc(name)}?판=${enc(판)}`, { method: "DELETE" });
|
||||
|
||||
/** 개인·회사 층에서 지움 — 판이 맞을 때만(다르면 409) */
|
||||
export const deleteLayerTemplate = (
|
||||
@@ -94,7 +91,7 @@ export const deleteLayerTemplate = (
|
||||
name: string,
|
||||
판: string,
|
||||
): Promise<{ ok: boolean }> =>
|
||||
call(`/layers/${layer}/templates/${kindPath(kind)}/${enc(name)}?판=${enc(판)}`, {
|
||||
call(`/layers/${layer}/templates/${kind}/${enc(name)}?판=${enc(판)}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
|
||||
@@ -125,16 +122,11 @@ export interface StructureNumbers {
|
||||
도번: string;
|
||||
면적번: string;
|
||||
재료번: string;
|
||||
/** @deprecated 옛 이름 — 면적번과 같은 값 · sub2 가 옮기면 지움 */
|
||||
표번?: string;
|
||||
}
|
||||
|
||||
/** `{열 id: {도번, 면적번, 재료번}}` — 구조물 열만(글 열 · 없는 열은 키 없음 = 「없음」) */
|
||||
export const fetchStructureNumbers = async (): Promise<Record<string, StructureNumbers>> => {
|
||||
const got = await call<Record<string, StructureNumbers>>("/structures/numbers");
|
||||
for (const row of Object.values(got)) row.표번 = row.면적번;
|
||||
return got;
|
||||
};
|
||||
export const fetchStructureNumbers = (): Promise<Record<string, StructureNumbers>> =>
|
||||
call("/structures/numbers");
|
||||
|
||||
/** 다른 열(`from`) 구조물 도면 내용을 받는 열(`column`)로 가져옴 — 도번 · 열은 받는 쪽 그대로 */
|
||||
export const copyStructure = async (column: string, from: string): Promise<void> => {
|
||||
@@ -151,9 +143,6 @@ export const copyMaterial = async (column: string, from: string): Promise<void>
|
||||
await call(`/material/${enc(column)}/copy?from=${enc(from)}`, { method: "POST" });
|
||||
};
|
||||
|
||||
/** @deprecated 옛 이름 — copyArea · sub2 가 옮기면 지움 */
|
||||
export const copyBasis = copyArea;
|
||||
|
||||
/* --- 프로젝트 층 단추 다섯 --- */
|
||||
const project = (id: string, tail: string): string => `/projects/${enc(id)}/templates/${tail}`;
|
||||
const post = (path: string, body: object = {}): Promise<unknown> =>
|
||||
|
||||
@@ -73,7 +73,7 @@ def test_sub2_가_부르는_이름과_모양():
|
||||
assert re.search(
|
||||
rf"export const {name} = async \(column: string, from: string\): Promise<void>", body
|
||||
), name
|
||||
assert "fetchStructureNumbers = async (): Promise<Record<string, StructureNumbers>>" in body
|
||||
assert "fetchStructureNumbers = (): Promise<Record<string, StructureNumbers>>" in body
|
||||
assert re.search(
|
||||
r"interface StructureNumbers \{\s*도번: string;\s*면적번: string;\s*재료번: string;", body
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user