- 박스암거 명세(design_structure_box) — 본체 규격 2.0×2.0 · 3.0×3.0 · 사용자 입력(가로 × 세로 숫자 칸) · 유입 · 유출 구조 없음 · 날개벽 · 흙막이 · 컨테이너마다 구조물 조합 잇기(gboxbody · gboxin · gboxout) - 저장 키 = 옛 키 그대로(body_width_m · body_height_m · wing_in · wing_out) · 규격 칸은 저장 안 함(폭 · 높이로 되찾음) · 옛 「있음」 = 날개벽 · 옛 날개벽 치수는 화면에서 빼고 지난 정의 값 - 명세 등록(STRUCTURE_SPECS) · 배관 시험 헬퍼가 같은 폴더 명세를 옮겨 읽음 - B06 날개벽 설치 판정 한 곳(wingInstalled) — 흙막이 = 날개벽 안 세움 · 저장 글을 있음/없음으로 안 덮음 · 날개벽 조정 행은 명세 유입 · 유출 칸으로 - 정의 판 7 — box_culvert 이름 표 · 그룹 셋 · wing_in/out 선택지 · 판 6 이력 보관 - 시험 test_52_structure_spec_box · 레지스트리 · 새 구조물 기본값 기대값 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4uKaV4ZBhsJN4GHG7yRj4
62 lines
2.6 KiB
JavaScript
62 lines
2.6 KiB
JavaScript
/* 박스암거 명세 단위검증 헬퍼(PLAN 52-2) — `design_structure_spec.ts` · `design_structure_box.ts` 를
|
||
* 그 자리에서 트랜스파일해 Node 로 돌림(꼴만 import). 결과 = JSON 한 벌.
|
||
* 인자 `names` 면 박스암거 이름 표(정의 `종류.box_culvert.이름`)만 냄.
|
||
*/
|
||
const fs = require("fs");
|
||
const path = require("path");
|
||
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
||
|
||
const ROOT = path.join(__dirname, "..", "..");
|
||
const load = (file) => {
|
||
const src = fs.readFileSync(path.join(ROOT, "A00_Common", "design", file), "utf8");
|
||
const js = ts.transpileModule(src, {
|
||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
||
}).outputText;
|
||
const box = { exports: {} };
|
||
new Function("exports", "module", "require", js)(box.exports, box, require);
|
||
return box.exports;
|
||
};
|
||
const s = load("design_structure_spec.ts");
|
||
const b = load("design_structure_box.ts");
|
||
const SPEC = b.BOX_SPEC;
|
||
|
||
if (process.argv[2] === "names") {
|
||
process.stdout.write(JSON.stringify(s.nameTable(SPEC)));
|
||
process.exit(0);
|
||
}
|
||
|
||
/** 화면이 하는 차례 그대로 — 옛 값 정리 → 명세 읽기 → 본체 칸 되찾기 → 저장 옵션. */
|
||
const roundTrip = (options, edit) => {
|
||
const state = s.readState(SPEC, b.boxOptionsIn(options));
|
||
Object.assign(state.body[0], b.bodyOf(options));
|
||
edit?.(state);
|
||
return { state, out: { ...s.writeOptions(SPEC, state), ...b.bodyOptions(state.body[0]) } };
|
||
};
|
||
const body = SPEC.containers.find((c) => c.id === "body");
|
||
const width = body.items.find((i) => i.id === "width");
|
||
|
||
const old = { body_width_m: 3, body_height_m: 2.5, wing_in: "있음", wing_in_length_m: 2 };
|
||
const out = {
|
||
containers: SPEC.containers.map((c) => [c.id, c.title, c.required]),
|
||
links: SPEC.containers.map((c) => s.linkOf(c, 1)),
|
||
sizes: body.items[0].choices.map((c) => c.value),
|
||
structures: SPEC.containers[1].items[0].choices.map((c) => c.value),
|
||
customHidden: s.branchOf(width, { size: "2.0×2.0" }),
|
||
customShown: s.branchOf(width, { size: "사용자 입력" }),
|
||
old: roundTrip(old),
|
||
preset: roundTrip({ body_width_m: 2, body_height_m: 2, wing_out: "없음" }),
|
||
toPreset: roundTrip(old, (st) => {
|
||
st.body[0].size = "3.0×3.0";
|
||
st.outlet[0].structure = "흙막이";
|
||
}),
|
||
toCustom: roundTrip({ body_width_m: 2, body_height_m: 2 }, (st) => {
|
||
st.body[0].size = "사용자 입력";
|
||
st.body[0].width = "2.4";
|
||
st.body[0].height = "1.8";
|
||
}),
|
||
blank: roundTrip({}),
|
||
keys: s.specKeys(SPEC),
|
||
retired: SPEC.retired,
|
||
};
|
||
process.stdout.write(JSON.stringify(out));
|