- 헬퍼 동작 그대로(풀이 함수 본문은 옮겨 담음) · 제품 코드 안 고침 - 확인: 이 묶음 헬퍼를 쓰는 시험 218 개 전 218 통과 → 후 218 통과 (시험별 junit 대조 · 어긋남 0) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
79 lines
2.9 KiB
JavaScript
79 lines
2.9 KiB
JavaScript
/* PLAN 298-1 헬퍼 — B06 [추가]가 적은 「높이 기다림」을 배수유역도 판이 같은 표(`fordWaitsOf`)로 보고
|
|
* 다시 나눈 유량으로 빈 월류 높이를 채움(126-1) · 프로젝트마다 따로 · 실패 = 토스트 한 줄(`analyzeFailed`).
|
|
* TS 로더는 `helper_126_ford_fill.cjs` 와 같다 · 결과 = 표준출력 JSON 한 벌.
|
|
*/
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const { makeLoader } = require("./helper_ts_stub_loader.cjs");
|
|
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
const toasts = [];
|
|
const STUBS = {
|
|
"@ui/ui_template_elements": { showToast: (message, kind) => toasts.push([message, kind]) },
|
|
};
|
|
|
|
const { loadTs } = makeLoader({
|
|
root: ROOT,
|
|
requireFor: (full) => (request) => {
|
|
if (STUBS[request]) return STUBS[request];
|
|
if (request === "@config/config_frontend")
|
|
return loadTs(path.join(ROOT, "config", "config_frontend.ts"));
|
|
if (request.startsWith(".")) return loadTs(path.join(path.dirname(full), `${request}.ts`));
|
|
if (request.startsWith("@")) return new Proxy({}, { get: () => () => {} });
|
|
return require(request);
|
|
},
|
|
});
|
|
|
|
const B05 = path.join(ROOT, "B05_Profile");
|
|
const fill = loadTs(path.join(B05, "B05_Profile_UI_Drainage_Ford_Fill.ts"));
|
|
const { fordHeightM } = loadTs(
|
|
path.join(ROOT, "A00_Common", "design", "design_structure_ford_calc.ts"),
|
|
);
|
|
|
|
const flow = 8.0;
|
|
const points = () => [
|
|
{ chainage_m: 185, facility: "ford_bridge", options: { ford_width_m: 10 } },
|
|
{ chainage_m: 300, facility: "ford_pavement", options: {} },
|
|
];
|
|
const basins = [
|
|
{ chainage_m: 185, design_flow_m3s: flow },
|
|
{ chainage_m: 300, design_flow_m3s: flow },
|
|
];
|
|
|
|
// ① B06 [추가] — 그 프로젝트 표에 측점을 적음(판과 같은 표)
|
|
const b06Wants = fill.waitsFordHeight("ford_bridge", { ford_width_m: 10 });
|
|
if (b06Wants) fill.fordWaitsOf("p1").add(185);
|
|
const same = fill.fordWaitsOf("p1") === fill.fordWaitsOf("p1");
|
|
// ② 판의 다시 나눔 응답 — 같은 표로 채움 · 기다리지 않던 300 은 빈칸 그대로
|
|
const p1 = points();
|
|
const filled = fill.fillFordHeights(p1, basins, fill.fordWaitsOf("p1"));
|
|
// ③ 다른 프로젝트 같은 측점은 안 채움
|
|
const p2 = points();
|
|
const otherFilled = fill.fillFordHeights(p2, basins, fill.fordWaitsOf("p2"));
|
|
|
|
let failed = null;
|
|
try {
|
|
const parts = loadTs(path.join(B05, "B05_Profile_UI_Drainage_Parts.ts"));
|
|
failed = {
|
|
status: parts.analyzeFailed(new Error("502 Bad Gateway"), "세부유역 산정에 실패했습니다."),
|
|
plain: parts.analyzeFailed("x", "세부유역 산정에 실패했습니다."),
|
|
toasts: [...toasts],
|
|
};
|
|
} catch (error) {
|
|
failed = { error: String(error) };
|
|
}
|
|
|
|
process.stdout.write(
|
|
JSON.stringify({
|
|
b06Wants,
|
|
same,
|
|
filled,
|
|
heights: p1.map((p) => p.options.ford_height_m ?? null),
|
|
left: [...fill.fordWaitsOf("p1")],
|
|
otherFilled,
|
|
otherHeights: p2.map((p) => p.options.ford_height_m ?? null),
|
|
need: fordHeightM(flow, 10),
|
|
failed,
|
|
}),
|
|
);
|