refactor(859-5 ③④): 구조물 정의 자료 master_template → master_data/구조물정의

- 구조물정의.json → resources/master_data/구조물정의/구조물정의.json(git mv · 내용 그대로)
- 구조물정의_이력/판_1 ~ 22 → resources/master_data/구조물정의/이력/(git mv · 내용 그대로)
- 읽는 자리 = B05 Structures_Schema DEFINITION_PATH · HISTORY_DIRNAME · M01_SO_Definition HISTORY
- M01 요소 로더 · check_master 는 첫 층 *.json 만 읽음 — 새 폴더는 요소로 안 읽힘(수식문서/ 와 같은 대접)
- 시험 · 도우미 · ui_checks 경로 글 고침(파일 이름 그대로)
- resources/master_template 에 구조물 정의 자료 남지 않음

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 22:09:35 +09:00
co-authored by Claude Opus 5.5
parent 88527876fc
commit 40126051dc
55 changed files with 81 additions and 41 deletions
+5 -4
View File
@@ -1,6 +1,6 @@
"""B05 구조물 타입 레지스트리·인스턴스 검증 모델.
구조물 타입 정의는 코드가 아니라 데이터(M02 마스터 `resources/master_template/구조물정의.json`
구조물 타입 정의는 코드가 아니라 데이터(M01 마스터 `resources/master_data/구조물정의/구조물정의.json`
`types` · PLAN 48-1)다. 리스트가 바뀌어도 코드를 고치지 않도록 분리했고, 프론트는
`GET /structure-types`로 같은 정본을 받는다. 정의 틀 = `docs/raw/M02_구조물옵션정의/정의_틀.md`.
@@ -27,7 +27,8 @@ STRUCTURE_SIDES = ("left", "right", "center", "cross")
DEFINITION_PATH = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
"resources",
"master_template",
"master_data",
"구조물정의",
"구조물정의.json",
)
@@ -159,8 +160,8 @@ def is_station_planting_type(item: StructureType) -> bool:
return row is not None and row["station"] != "none"
#: 지난 판 정의(`판_N.json`) 폴더 — 정본 옆(M02 `M01_SO_Definition.HISTORY` 와 같은 이름)
HISTORY_DIRNAME = "구조물정의_이력"
#: 지난 판 정의(`판_N.json`) 폴더 — 정본 옆(M01 `M01_SO_Definition.HISTORY` 와 같은 이름)
HISTORY_DIRNAME = "이력"
def registry_schema_version() -> int:
@@ -2,7 +2,7 @@
* B05_Profile_UI_Structures_Define.ts
* 구조물 정의 → 「구조물 배치」 칸 모양 (PLAN 48-3 · 48-4) — 화면 요소 없는 순수 규칙.
*
* 정의(`resources/master_template/구조물정의.json` · GET /structure-types 가 실어 줌)를 읽어
* 정의(`resources/master_data/구조물정의/구조물정의.json` · GET /structure-types 가 실어 줌)를 읽어
* 칸 차례 · 격자 · 안 씀 · 규칙(상위 값 → 하위 선택지 · 보이기 · 기본값)을 낸다. 틀 =
* `docs/raw/M02_구조물옵션정의/정의_틀.md`. 선택지를 줄이면(숨김) 옛 값은 그 값만 남겨 보임.
* 그리기는 `_Structures_Panel_Options`(레지스트리 칸) · `_Structures_Define_Form`(시설 폼 칸).
+1 -1
View File
@@ -25,7 +25,7 @@ export const fetchStructureDef = (): Promise<StructDef> => call("/structure-defi
export const saveStructureDef = (판: number, 정의: StructDef): Promise<StructDef> =>
call("/structure-definition", { method: "PUT", body: JSON.stringify({ 판, 정의 }) });
/** 지난 판 목록(`구조물정의_이력/판_N.json`) */
/** 지난 판 목록(`구조물정의/이력/판_N.json`) */
export const fetchStructureDefHistory = (): Promise<DefVersion[]> =>
call("/structure-definition/history");
@@ -1,7 +1,7 @@
"""M02 구조물 정의 한 벌(PLAN 48-1) — 정본 `resources/master_template/구조물정의.json`.
"""M01 구조물 정의 한 벌(PLAN 48-1) — 정본 `resources/master_data/구조물정의/구조물정의.json`.
틀 = `docs/raw/M02_구조물옵션정의/정의_틀.md`. 읽기 = 로그인 누구나 · 쓰기 = 시스템 관리자만.
판 = 정수 · 저장마다 +1 · 앞 판은 `구조물정의_이력/판_N.json` 으로 남김(지난 정의 값 읽기용).
판 = 정수 · 저장마다 +1 · 앞 판은 `구조물정의/이력/판_N.json` 으로 남김(지난 정의 값 읽기용).
검사 = 칸 꼴 · 키 겹침 · 표시 · 그룹 · 배치 · 규칙 대상 있음 — 틀리면 422 · 낡은 판 409.
"""
@@ -21,7 +21,7 @@ from M01_MasterData.StructOptions.M01_SO_Check import catalog_errors
from M02_MasterTemplete import M02_MasterTemplete_Store as store
FILE = "구조물정의.json"
HISTORY = "구조물정의_이력"
HISTORY = "이력"
# 반영 · 부품 = 구조물 표 칸(322-2 · 없으면 처음값 · 검사 = `M01_SO_Check`)
TOP = {"판", "schema_version", "comment", "구조물군", "동작", "types", "반영", "부품"}
SECTIONS = {"종류": dict, "표시": dict, "그룹": dict, "배치": dict, "규칙": list}
@@ -41,7 +41,10 @@ const { loadForm } = loadTs(path.join(B05, "B05_Profile_UI_Structures_Panel_Comm
const entry = (required, value) => ({ required, isEmpty: () => value === "" });
// 동작 = 정의 종류 덧칸(앱의 `withDefinition` 과 같음 · 323-7 종류 키 대신 동작 이름)
const DEFINED = JSON.parse(
fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(
path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
"utf8",
),
);
const behaviors = (typeId) => DEFINED.종류?.[typeId]?.동작 ?? [];
const type = (type_id, managed_by = null) => ({
+4 -1
View File
@@ -35,7 +35,10 @@ const { fordHeightM } = loadTs(
// 동작 = 정의 종류 덧칸(앱의 `withDefinition` 과 같음 · 323-7 종류 키 대신 동작 이름)
const DEFINED = JSON.parse(
fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(
path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
"utf8",
),
);
const type = (type_id) => ({
type_id,
@@ -63,7 +63,10 @@ const ids = loadTs(path.join(design, "design_pipe_ids.ts"));
const { useDesignStore } = loadTs(path.join(design, "design_store.ts"));
const { readState } = loadTs(path.join(ROOT, "A00_Common", "b_page_state.ts"));
const TYPES = JSON.parse(
fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(
path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
"utf8",
),
).types;
/** 가짜 종단도 — 받은 것 · 편집 옮김 기록. */
@@ -60,7 +60,7 @@ function load(full) {
const P = (...a) => path.join(ROOT, ...a);
const D = load(P("B06_Section", "B06_Section_Section_Drafts.ts"));
const def = JSON.parse(
fs.readFileSync(P("resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(P("resources", "master_data", "구조물정의", "구조물정의.json"), "utf8"),
);
S.types = def.types.map((t) => ({
type_id: t.type_id,
+4 -1
View File
@@ -12,7 +12,10 @@ const ROOT = path.join(__dirname, "..", "..");
const B05 = (name) => path.join(ROOT, "B05_Profile", `${name}.ts`);
const B06 = (name) => path.join(ROOT, "B06_Section", `${name}.ts`);
const TYPES = JSON.parse(
fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(
path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
"utf8",
),
).types;
class FakeStorage {
+4 -1
View File
@@ -8,7 +8,10 @@ const path = require("path");
const ROOT = path.join(__dirname, "..", "..");
const ts = require(path.join(ROOT, "config", "node_modules", "typescript"));
const DEF = JSON.parse(
fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(
path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
"utf8",
),
);
const TYPES = DEF.types.map((t) => ({ managed_by: null, enabled: true, ...t }));
@@ -16,7 +16,7 @@ const box = { exports: {} };
new Function("exports", "module", "require", js)(box.exports, box, () =>
read("common_util", "common_util_structure_parts.json"),
);
box.exports.useCatalogDefinition(read("resources", "master_template", "구조물정의.json"));
box.exports.useCatalogDefinition(read("resources", "master_data", "구조물정의", "구조물정의.json"));
/** 로더 요청이 구조물 표 모듈인가. */
box.exports.isCatalogRequest = (request) => /common_util_structure_catalog(\.js)?$/.test(request);
+4 -1
View File
@@ -37,7 +37,10 @@ function load(file) {
const C = (name) => path.join(ROOT, "common_util", `${name}.ts`);
const M = (name) => path.join(ROOT, "M01_MasterData", "StructOptions", `${name}.ts`);
const master = JSON.parse(
fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(
path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
"utf8",
),
);
const def = JSON.parse(JSON.stringify(master));
const add = load(M("M01_SO_Def_Add"));
+1 -1
View File
@@ -66,7 +66,7 @@ const detail = {
};
// 구조물 표 = 실제 정의(마스터 읽기만) · 측점을 심는 구조물 — 켜진 점형 하나 · 꺼진 것 하나(보기와 같이 둘 다 심음)
const definition = JSON.parse(
readFileSync(new URL("../master_template/구조물정의.json", import.meta.url), "utf8"),
readFileSync(new URL("../master_data/구조물정의/구조물정의.json", import.meta.url), "utf8"),
);
m.useCatalogDefinition(definition);
const planting = (item) => {
+1 -1
View File
@@ -52,7 +52,7 @@ const PD = load(P("B05_Profile", "logic", "B05_Profile_Pipeline_Detail.ts"));
const CR = load(P("A00_Common", "design", "design_pipeline_cross.ts"));
const def = JSON.parse(
fs.readFileSync(P("resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(P("resources", "master_data", "구조물정의", "구조물정의.json"), "utf8"),
);
const types = def.types
.filter((t) => t.enabled !== false)
+1 -1
View File
@@ -42,7 +42,7 @@ const SS = load(P("B05_Profile", "logic", "B05_Profile_Sections_Stations.ts"));
const SW = load(P("B06_Section", "logic", "B06_Section_Station_Swap.ts"));
const AT = load(P("common_util", "common_util_structure_attach.ts"));
const def = JSON.parse(
fs.readFileSync(P("resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(P("resources", "master_data", "구조물정의", "구조물정의.json"), "utf8"),
);
const types = def.types
.filter((t) => t.enabled !== false)
+4 -1
View File
@@ -62,7 +62,10 @@ const { createFacilityLane } = loadTs(path.join(design, "design_facility_lane.ts
const ids = loadTs(path.join(design, "design_pipe_ids.ts"));
const { listedBase } = loadTs(path.join(design, "design_profile_base.ts"));
const TYPES = JSON.parse(
fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(
path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
"utf8",
),
).types;
/** 가짜 종단도 — 측점을 받은 차례 기록. */
@@ -1,6 +1,6 @@
/* 구조물 정의 → 칸 모양 단위검증 헬퍼(PLAN 48-3 · 48-4) — `B05_Profile_UI_Structures_Define.ts` 를
* 그 자리에서 트랜스파일해 Node 로 돌림(import 없는 파일). 결과는 표준출력에 JSON 한 벌.
* 판 1 정의(`resources/master_template/구조물정의.json`)도 읽어 지금 화면과 같은지(차례 · 2열) 봄.
* 판 1 정의(`resources/master_data/구조물정의/구조물정의.json`)도 읽어 지금 화면과 같은지(차례 · 2열) 봄.
*/
const fs = require("fs");
const path = require("path");
@@ -48,7 +48,10 @@ const type = {
const plain = (states) => Object.fromEntries([...states].map(([k, v]) => [k, v]));
const def = JSON.parse(
fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(
path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
"utf8",
),
);
const merged = d.withDefinition(
def.types.map((t) => ({ ...t, groups: (def.그룹[t.type_id] ?? []).map((g) => ({ id: g.id })) })),
@@ -39,7 +39,10 @@ const { loadTs } = makeLoader({
});
const DEF = JSON.parse(
fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(
path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
"utf8",
),
);
const TYPES = DEF.types.map((t) => ({ managed_by: null, enabled: true, ...t }));
const attach = loadTs(path.join(ROOT, "common_util", "common_util_structure_attach.ts"));
+4 -1
View File
@@ -29,7 +29,10 @@ const m = load("M01_MasterData", "StructOptions", "M01_SO_Def_Spec_Model.ts");
const { PIPE_SPEC } = load("A00_Common", "design", "logic", "design_structure_pipe.ts");
const real = () =>
JSON.parse(
fs.readFileSync(path.join(ROOT, "resources", "master_template", "구조물정의.json"), "utf8"),
fs.readFileSync(
path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
"utf8",
),
);
const out = {};
@@ -68,7 +68,7 @@ def test_로케일에_기슭막이는_독립_한_곳뿐():
def test_정의_label은_흙막이_choices_값은_그대로():
definition = json.loads(_read("resources", "master_template", "구조물정의.json"))
definition = json.loads(_read("resources", "master_data", "구조물정의", "구조물정의.json"))
labels, choices = [], []
def walk(node):
+1 -1
View File
@@ -32,7 +32,7 @@ from config.config_system import STANDARD_CROSS_SECTION
ROOT = Path(__file__).resolve().parents[2]
TSC = ROOT / "config" / "node_modules" / "typescript" / "bin" / "tsc"
HELPER = Path(__file__).parent / "helper_194_1_berm_pick.cjs"
DEF = ROOT / "resources" / "master_template" / "구조물정의.json"
DEF = ROOT / "resources" / "master_data" / "구조물정의" / "구조물정의.json"
node_only = pytest.mark.skipif(not TSC.is_file(), reason="프론트엔드 의존성 미설치")
+1 -1
View File
@@ -75,7 +75,7 @@ def test_check_screen_equals_server(ts: dict, copied: dict) -> None:
master = json.loads(Path(definition.schema.DEFINITION_PATH).read_text(encoding="utf-8"))
assert ts["problems"] == []
real = json.loads(
(ROOT / "resources" / "master_template" / "구조물정의.json").read_text("utf-8")
(ROOT / "resources" / "master_data" / "구조물정의" / "구조물정의.json").read_text("utf-8")
)
assert definition.check(copied, real) == []
assert ts["badBase"] is True and ts["chain"] is True
@@ -13,7 +13,7 @@ import pytest
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(os.path.dirname(HERE))
DEFINITION = os.path.join(ROOT, "resources", "master_template", "구조물정의.json")
DEFINITION = os.path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json")
@pytest.fixture(scope="module")
@@ -131,7 +131,7 @@ def test_집계표_짝_명세와_같음():
def test_정의_그룹_경사각도():
with open(
os.path.join(ROOT, "resources/master_template/구조물정의.json"), encoding="utf-8"
os.path.join(ROOT, "resources/master_data/구조물정의/구조물정의.json"), encoding="utf-8"
) as f:
groups = json.load(f)["그룹"]["ford_pavement"]
assert [(g["id"], g["이름"]) for g in groups] == [("gfordpaveslope", "경사각도")]
@@ -110,7 +110,8 @@ def test_월류_높이는_폭과_연동_필요_수심_올림(out):
def test_정의_파일에_세월교_이름_표가_올라_있음():
names = _node("names")
with open(
os.path.join(ROOT, "resources", "master_template", "구조물정의.json"), encoding="utf-8"
os.path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
encoding="utf-8",
) as f:
doc = json.load(f)
# 그림 전용 길이 칸(294-4)은 마스터 정의 이름 표에 안 올림(마스터 손대지 않음) — 대조 밖
@@ -99,7 +99,8 @@ def test_사용자_입력_빈_칸은_다시_열어도_사용자_입력(out):
def test_정의_파일에_이름_표_그룹_선택지가_올라_있음():
names = _node("names")
with open(
os.path.join(ROOT, "resources", "master_template", "구조물정의.json"), encoding="utf-8"
os.path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
encoding="utf-8",
) as f:
doc = json.load(f)
# 그림 전용 길이 칸(294-4)은 마스터 정의 이름 표에 안 올림(마스터 손대지 않음) — 대조 밖
@@ -103,7 +103,8 @@ def test_잇기_키와_이름_바꿈(out):
def test_정의_파일에_이름_표가_올라_있음():
names = _node("names")
with open(
os.path.join(ROOT, "resources", "master_template", "구조물정의.json"), encoding="utf-8"
os.path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
encoding="utf-8",
) as f:
doc = json.load(f)
on_file = doc["종류"]["pipe"]["이름"]
@@ -18,7 +18,9 @@ ROOT = Path(__file__).resolve().parents[2]
def _box_options() -> dict[str, dict]:
registry = json.loads(
(ROOT / "resources" / "master_template" / "구조물정의.json").read_text(encoding="utf-8")
(ROOT / "resources" / "master_data" / "구조물정의" / "구조물정의.json").read_text(
encoding="utf-8"
)
)
types = registry if isinstance(registry, list) else registry.get("types") or []
box = next(t for t in types if t["type_id"] == "box_culvert")
+3 -1
View File
@@ -32,7 +32,9 @@ QUANTITY_ONLY = {
def _pipe_option_keys() -> list[str]:
payload = json.loads(
(ROOT / "resources" / "master_template" / "구조물정의.json").read_text(encoding="utf-8")
(ROOT / "resources" / "master_data" / "구조물정의" / "구조물정의.json").read_text(
encoding="utf-8"
)
)
types = payload if isinstance(payload, list) else payload["types"]
pipe = next(item for item in types if item["type_id"] == "pipe")
+3 -1
View File
@@ -15,7 +15,9 @@ M02 = ROOT / "M02_MasterTemplete"
def test_분류는_구조물군_종류_공통():
defn = json.loads((ROOT / "resources/master_template/구조물정의.json").read_text("utf-8"))
defn = json.loads(
(ROOT / "resources/master_data/구조물정의/구조물정의.json").read_text("utf-8")
)
proc = subprocess.run(
["node", os.path.join(HERE, "helper_m02_precombo_scope.cjs")],
input=json.dumps({"rows": [], "def": defn}, ensure_ascii=False),
@@ -3,7 +3,7 @@
못박는 것
- 판 1 = 옛 레지스트리 그대로 옮김(37종 · 옵션 235 · 키 그대로) · 검사 통과.
- 읽기 = 로그인 누구나 · 쓰기 = 시스템 관리자만(403).
- 저장마다 판 +1(지금 판에서) · 앞 판은 `구조물정의_이력/판_N.json` · 낡은 판 409 · 틀린 정의 422(안 씀).
- 저장마다 판 +1(지금 판에서) · 앞 판은 `구조물정의/이력/판_N.json` · 낡은 판 409 · 틀린 정의 422(안 씀).
- 검사 = 키 겹침 · 꼴 · 규칙 대상 있음 · 그룹 형상.
- 저장한 정의를 `/structure-types` 가 바로 읽음 · 프로젝트 저장에 정의 판 · 없는 키 값 보존.
"""
@@ -81,13 +81,13 @@ def test_저장마다_판_더하기_1_앞_판은_이력_structure_types_가_바
res = admin.put(URL, json={"판": v, "정의": doc})
assert res.status_code == 200, res.text
assert res.json()["판"] == v + 1
old = json.loads((copy.parent / "구조물정의_이력" / f"판_{v}.json").read_text("utf-8"))
old = json.loads((copy.parent / "이력" / f"판_{v}.json").read_text("utf-8"))
assert old["판"] == v and old["types"][0]["name"] != "이름 바꿈"
seen = {t["type_id"]: t for t in admin.get(TYPES).json()["types"]}
assert seen[tid]["name"] == "이름 바꿈" and len(seen) == len(doc["types"])
assert admin.put(URL, json={"판": v, "정의": doc}).status_code == 409 # 낡은 판
assert admin.put(URL, json={"판": v + 1, "정의": res.json()}).json()["판"] == v + 2
assert (copy.parent / "구조물정의_이력" / f"판_{v + 1}.json").is_file()
assert (copy.parent / "이력" / f"판_{v + 1}.json").is_file()
def _rule(doc: dict) -> tuple[str, dict, dict]:
@@ -143,7 +143,7 @@ def test_검사_키_겹침_꼴_규칙_대상_형상(copy) -> None:
res = admin.put(URL, json={"판": v, "정의": doc})
assert res.status_code == 422, (i, res.text)
assert json.loads(copy.read_text("utf-8"))["판"] == v # 거절되면 안 씀
assert not (copy.parent / "구조물정의_이력").exists()
assert not (copy.parent / "이력").exists()
shaped = bad(종류={tid: {"기준측점": False}})
shaped["그룹"]["pipe"][0]["형상"] = {"길이": {"받기": True, "뜻": "관 길이"}}
assert admin.put(URL, json={"판": v, "정의": shaped}).status_code == 200
@@ -1,4 +1,4 @@
/* 48-1 — 구조물 정의 한 벌(resources/master_template/구조물정의.json)로 옮긴 뒤 화면 변화 0
/* 48-1 — 구조물 정의 한 벌(resources/master_data/구조물정의/구조물정의.json)로 옮긴 뒤 화면 변화 0
* 시작 화면: M02 마스터 템플릿 · 마스터 층(#/m02-master-template?root=master) · 시스템 관리자 · 저장 안 함
* 부르는 법: orca eval --expression "$(cat 이 파일)" (async 식 · JSON 글을 돌려줌)
* 기대 수치: