/* ============================================================================= * B06_Section_Api_Context.ts * 종횡단 설정값(`GET …/sections/context`)의 **세션 캐시 창구** — 화면 쪽. * * `B06_Section_Api_Fetch.ts` 에서 갈라냄(472-2) — 서버 Node 묶음이 Api_Fetch 를 끌어도 * 세션(`b_page_state`)을 함께 끌지 않게. * ========================================================================== */ import { clearState, readState, writeState } from "../A00_Common/b_page_state"; import { requestSectionContext } from "./B06_Section_Api_Fetch"; import type { SectionContextResponse } from "./B06_Section_Api_Types"; /** 최신 확정 경로와 B04 확정값, config 기반 생성 기본값을 조회한다. */ /** 종횡단 설정값 — ④ 계산 결과라 세션에 담아 두고 화면을 오갈 때마다 다시 묻지 않는다 * (2026-09-06 호출 정리). 노선이 바뀌면 `clearSectionContextCache` 로 버린다. * 저장된 표준 횡단면(`stored_standard_cross_section`)은 이 칸에서 바로 읽음(`readStoredStandard`) — * 초안 칸(`std-cross`)에 베끼지 않음(272 · 값이 저장분과 같으면 초안 칸 없음). */ export async function fetchSectionContext(projectId: string): Promise { const cached = readState("section-context", projectId); if (cached) return cached; const fresh = await requestSectionContext(projectId); writeState("section-context", fresh, projectId); return fresh; } /** 서버가 지금 보는 노선 id — 세션 캐시를 건너뛰고 묻는다. [저장] · [확정] 앞에서 화면이 쥔 * 노선과 대조한다(PLAN 76-1). 받은 설정값으로 캐시도 새로 둔다. */ export async function fetchCurrentRouteId(projectId: string): Promise { const fresh = await requestSectionContext(projectId); writeState("section-context", fresh, projectId); return fresh.route_id; } export function clearSectionContextCache(projectId: string): void { clearState("section-context", projectId); }