Files
Aislo/resources/tester/helper_347_2_drainage_live.cjs
T
eomsangdonandClaude Opus 5.5 44ffb99559 fix(B05 배수유역): 349 수동 [업데이트] 답 머묾 · 저장 뒤 낡음 — 답 받기 = 차례 + 입력 지문
- 묶음 drainage 단계 입력 지문(노선 초안 rev 뺌 · 관 id · 자리 cm) — 같은 노선 · 관으로 다시 돈 묶음은 흘려보냄(떠 있는 요청 안 끊음 · 다시 안 흐림)
- 차례 번호는 요청마다 하나 · 답은 차례 + 지문이 지금과 같을 때만 받음
- 서버 답이 「낡음」(노선 [저장] 뒤 등) = 수동은 흐림 + [업데이트] · 자동은 3 s 뒤 조용히(markStale)
- 시험 test_349_drainage_live_flow(가짜 DOM · 시계 · fetch 로 화면 파일 실행 — 수동 · 자동 · 제안 [적용]) · 347-2 헬퍼 새 받기 규칙
- PLAN.md 349-0b

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XWh5wNNycMkbwMpACz1rte
2026-10-16 14:14:32 +09:00

59 lines
2.4 KiB
JavaScript

/* 347-2 · 347-3 배수유역 자동/수동 · 제안 헬퍼 — logic 두 파일을 그 자리에서 트랜스파일해
* Node 로 돌리고 값을 JSON 으로 낸다(틀 = helper_281_1).
*/
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const ROOT = path.join(__dirname, "..", "..");
function loadTs(file) {
const js = ts.transpileModule(fs.readFileSync(file, "utf8"), {
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 live = loadTs(path.join(ROOT, "B05_Profile", "logic", "B05_Profile_Drainage_Live.ts"));
const sug = loadTs(path.join(ROOT, "B05_Profile", "logic", "B05_Profile_Drainage_Suggest.ts"));
const pipes = [
{ chainage_m: 100, source: "stream", options: { pipe_diameter_mm: 1000 } },
{ chainage_m: 300, source: "user", facility: "pipe" },
{ chainage_m: 500, source: "stream", facility: "box_culvert" },
];
const basins = [
{ chainage_m: 100, recommended_facility: "pipe", recommended_diameter_mm: 1200 },
{ chainage_m: 300, recommended_facility: "ford_bridge", recommended_diameter_mm: null },
{ chainage_m: 500, recommended_facility: "box_culvert", recommended_diameter_mm: null },
];
const candidates = [{ chainage_m: 200 }, { chainage_m: 500.2 }];
const before = JSON.stringify(pipes);
const at = (generation) => ({ generation, key: "k" }); // 349 — 차례 + 입력 지문
const suggestions = sug.collectSuggestions(pipes, basins, candidates);
const applied = sug.applySuggestions(pipes, suggestions);
process.stdout.write(
JSON.stringify({
quietMs: live.QUIET_MS,
modes: [
live.parseDrainageMode(null),
live.parseDrainageMode("auto"),
live.parseDrainageMode("x"),
],
stale: [live.draftMakesStale(null), live.draftMakesStale({ rev: 1 })],
accept: [
live.acceptLive({ status: "success", generation: 3 }, at(3), at(3)),
live.acceptLive({ status: "success", generation: 3 }, at(3), at(4)),
live.acceptLive({ status: "superseded" }, at(3), at(3)),
live.acceptLive({ status: "success", generation: 2 }, at(3), at(3)),
],
body: live.liveRequestBody(5, undefined, [{ chainage_m: 1 }]),
suggestions,
applied,
untouched: JSON.stringify(pipes) === before,
}),
);