Files
Aislo/resources/tester/helper_65_ford_box.cjs
T
eomsangdonandClaude Opus 5.5 281c71b55b refactor(logic): 348-1 순수 계산 TS 49 파일 <페이지>/logic/ 로 옮김 — 이름 앞머리 그대로 · 동작 고침 없음
- 옮김: B04 2 · B05 23 · B06 11 · A00_Common/design 13 (9,299 줄) · 이미 logic/ 에 있던 16 파일 그대로
- 안 옮김: 묶음 입구(package.json build:*) · 파이썬 · 순수지만 계산 아닌 8 (보기 결선 · 콜백 · API 타입 · 갈아끼움 알림판)
- import 266 줄(142 파일) · 시험 · 주석 · 짝 표시 문자열 경로 고침 · B05 · B06 CLAUDE.md 짝 줄 logic/
- 시험 도우미 새 경로: 가짜 require 열쇠 · B05()/B06() 부름 · 형제 import 자리 · tsc 묶어 돌리는 시험 · 정규식 · rglob
- design_view_cross 줄 한도 시험 685 → 688 (긴 import 경로 줄바꿈 3줄)
- 확인: typecheck 0 · 서버 묶음 넷(corridor · server-calc · b07-extent · b07-note) 다시 지어 코드 같음(//#region 경로 주석만 다름) · 관련 시험 270 파일 — 남은 실패 19 는 옮기기 전과 같음

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
2026-10-16 13:44:50 +09:00

95 lines
3.6 KiB
JavaScript

/* 65장 세월교 · 박스암거 · 물넘이 포장 명세 단위검증 헬퍼 — `design_structure_*.ts` 를 그 자리에서 트랜스파일해
* Node 로 돌림(같은 폴더 명세 import 는 따라 옮김). 결과 = JSON 한 벌. 짝 = `test_65_ford_defaults.py`.
*/
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const ROOT = path.join(__dirname, "..", "..");
const cache = new Map();
const load = (file) => {
if (cache.has(file)) return cache.get(file);
const js = ts.transpileModule(fs.readFileSync(file, "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
cache.set(file, box.exports);
const near = (m) => {
const base = m.startsWith("@config/")
? path.join(ROOT, "config", m.slice(8))
: path.join(path.dirname(file), m);
return load(`${base}.ts`);
};
new Function("exports", "module", "require", js)(box.exports, box, near);
return box.exports;
};
const D = (f) => path.join(ROOT, "A00_Common", "design", f);
const s = load(D("logic/design_structure_spec.ts"));
const { FORD_SPEC, withLegacyGuards } = load(D("logic/design_structure_ford.ts"));
const { BOX_SPEC } = load(D("logic/design_structure_box.ts"));
const { FORD_PAVEMENT_SPEC } = load(D("logic/design_structure_ford_pavement.ts"));
const calc = load(D("design_structure_ford_calc.ts"));
/** 상자마다 칸 id · 갈래(구조 값 → 저장 키) — 칸 목록 대조용. */
const items = (spec) =>
Object.fromEntries(
spec.containers.map((c) => [
c.id,
c.items.map((i) => [i.id, i.by ? Object.keys(i.by.map) : null, i.default ?? null]),
]),
);
const none = (spec) =>
Object.fromEntries(
spec.containers.map((c) => [
c.id,
[s.isNone(c, { structure: "없음" }), s.isNone(c, { structure: "흙막이" })],
]),
);
// 세월교 유입 흙막이 · 유출 없음 · 추가 흙막이 1 · 도수로 1 → 저장 → 다시 읽기
const fordState = s.readState(FORD_SPEC, withLegacyGuards({ pipe_diameter_mm: 1000 }));
fordState.inlet[0] = {
structure: "흙막이",
form: "돌망태",
length: "8",
height: "1.2",
before: "3",
after: "5",
};
fordState.outlet[0] = { structure: "없음" };
fordState.soil_add.push({ form: "바자", length: "6", height: "1", before: "3", after: "3" });
fordState.chute_add.push({ structure: "돌붙임" });
const fordOut = s.writeOptions(FORD_SPEC, fordState);
const fordBack = s.readState(FORD_SPEC, withLegacyGuards(fordOut));
// 박스 유출 흙막이 → 저장 키
const boxState = s.readState(BOX_SPEC, {});
boxState.outlet[0] = { structure: "흙막이", form: "콘크리트", length: "4", height: "2" };
const boxOut = s.writeOptions(BOX_SPEC, boxState);
// 물넘이 포장 경사각 · 월류 폭 · 높이
const paveState = s.readState(FORD_PAVEMENT_SPEC, { ford_slope_deg: 3, ford_width_m: 5 });
paveState.slope[0].height = String(calc.fordHeightM(2.54, 5));
const paveOut = s.writeOptions(FORD_PAVEMENT_SPEC, paveState);
process.stdout.write(
JSON.stringify({
ford: items(FORD_SPEC),
box: items(BOX_SPEC),
pave: items(FORD_PAVEMENT_SPEC),
fordNone: none(FORD_SPEC),
boxNone: none(BOX_SPEC),
fordOut,
fordBack,
boxOut,
paveOut,
paveRetired: FORD_PAVEMENT_SPEC.retired,
fordKeys: s.specKeys(FORD_SPEC),
boxKeys: s.specKeys(BOX_SPEC),
paveKeys: s.specKeys(FORD_PAVEMENT_SPEC),
table: [0.5, 2.54, 8, 30].flatMap((q) =>
[3, 5, 10, 20].map((b) => [q, b, calc.fordHeightM(q, b)]),
),
}),
);