Files
Aislo/A00_Common/design/design_pipeline_cross_server.ts
T

45 lines
2.1 KiB
TypeScript

/* =============================================================================
* A00_Common/design/design_pipeline_cross_server.ts
* 계산 자리 cross = server 의 묶음 cross 단계(PLAN 511-B B-4) — 엔진 길(노선 초안 · 저장 상세 없음)을 서버 Node
* 단계(`stage.cross` · `design_calc_node_stages.ts`)가 같은 단계 함수 · 같은 붙임으로 셈. 저장 노선 다시 셈은
* `B06_Section_Cross_Refresh` 의 `cross.refresh`. 판 both · DTM 격자 없음(DTM 아닌 지표면 · 받기 전) = null
* (브라우저). 격자 경로 · 구조물 정의 = 서버 창구가 채움(`B06_Section_Router_Calc.py`).
* ========================================================================== */
import { readState } from "../b_page_state";
import { designTerrainGridNow } from "../../B05_Profile/B05_Profile_Api_TerrainGrid";
import { calcOnServerOnly } from "./design_calc_server";
import { calcOnServerNow } from "./design_calc_sites";
import type { StagesInputs } from "./logic/design_calc_node_stages";
import type { CrossOutput, StageContext } from "./logic/design_pipeline_types";
/** 단계 입력 중 페이지 저장 맥락(묶음 입력 · 격자 · 관 세션 장부 뺌). */
export type CrossStageContext = Omit<
NonNullable<StagesInputs["stages"]>,
"input" | "grid" | "pipe_ids"
>;
/** 서버 단계 답 · 끊김 · 실패 = undefined(부르는 쪽이 브라우저) · server 아님 = null. */
export function crossOnServer(
projectId: string,
ctx: StageContext<"cross">,
context: () => CrossStageContext | null,
): Promise<CrossOutput | undefined> | null {
if (!calcOnServerNow("cross") || !designTerrainGridNow(projectId)) return null;
const saved = context();
if (!saved) return null;
// ponytail: 저장 상세(1.4 MB)를 부름마다 올림 — 시험용 길 · 느리면 서버가 정본 맥락을 붙임
return calcOnServerOnly<CrossOutput>(
"cross",
"C.stage",
{
run: ["stage.cross"],
inputs: {
stages: { ...saved, pipe_ids: readState("pipe-ids", projectId), input: { ...ctx.inputs } },
},
pick: (results) => results["stage.cross"],
},
ctx.signal,
);
}