/* ============================================================================= * B09_Draft_Print_Drawings_Node.ts * 인쇄 미리보기 도면(PLAN 302-2) — 미확정 횡단 장에 구조물을 얹는 Node 진입점(CLAUDE.md 5장 ②). * * B07 화면이 미확정 장을 열 때 얹는 것과 **같은 코드**(`placeStructureEntities`)를 서버에서 돌린다. * 입력 상세 = 정본(`get_section_detail`) — 화면 캐시의 저장 안 한 편집은 안 실림(인쇄 = 저장본). * * 실행: node <번들> <입력.json> <출력.json> * 입력 { detail: 종횡단 상세, drawings: { [도면 id]: CAD 도면 } } * 출력 { drawings: { [도면 id]: 구조물을 얹은 CAD 도면 } } * 끝 코드: 0 성공 / 2 인자 오류 * ========================================================================== */ import { readFileSync, writeFileSync } from "node:fs"; import type { SectionDetailResponse } from "../../B06_Section/B06_Section_Api_Fetch"; import "../../B07_DesignDetail/B07_DesignDetail_Node_Dom"; // 최소 DOM — 그리기 코드보다 먼저 import { placeStructureEntities } from "../../B07_DesignDetail/B07_DesignDetail_Cross_Overlay"; type Drawing = Parameters[1]; const [inputPath, outputPath] = process.argv.slice(2); if (!inputPath || !outputPath) { console.error("사용법: node <번들> <입력.json> <출력.json>"); process.exit(2); } const input = JSON.parse(readFileSync(inputPath, "utf8")) as { detail?: SectionDetailResponse; drawings?: Record; }; const sections = input.detail?.cross_sections ?? []; const drawings = input.drawings ?? {}; for (const drawing of Object.values(drawings)) placeStructureEntities(sections, drawing); writeFileSync(outputPath, JSON.stringify({ drawings }), "utf8");