/* ============================================================================= * M02_DF_Api.ts * 기계 이름 · 끈 기계 읽기 — 서버 `GET /api/m02/df/machine-names` · `machine-off`(`M02_DF_Router.py`) * 부르는 곳 = 옵션 기계 이름(`formula_doc_options`) · 단위 표준 표 읽기는 단위 고르기(`ui_template_unit_pick`)로 옮김(856-4) * ========================================================================== */ import { API_BASE_URL } from "@config/config_frontend"; let machineNames: Promise> | null = null; /** 기계 원문번호 → 「이름 규격」 — 한 번 받아 둠(못 받으면 빈 표 · 다음에 다시) */ export function cfMachineNames(): Promise> { machineNames ??= fetch(`${API_BASE_URL}/m02/df/machine-names`, { credentials: "include" }) .then((r) => (r.ok ? (r.json() as Promise>) : Promise.reject())) .catch(() => ((machineNames = null), {})); return machineNames; } /** 끈 기계 원문번호(842-2) — 이름과 함께 한 번 받아 둠(못 받으면 빈 목록) */ export const cfMachineOff = (): Promise => fetch(`${API_BASE_URL}/m02/df/machine-off`, { credentials: "include" }) .then((r) => (r.ok ? (r.json() as Promise) : [])) .catch(() => []);