- 지움: DataFlow/M02_DF_Round.ts(가져가는 곳 0) · _standard/금액단위표준.json · /df/standards 답의 money 칸(단위 고르기는 unit 만 씀) - M02_DF_Values: 흐름도 입력 값 길(values · one_value · materials · slot_price · group_find · standards_check 와 딸린 함수 · 550 → 62 줄) — 남김 = Item_Prices 가 쓰는 _pick · _group_rows · GROUP_RULE · MACHINE_SEP · HOURLY + standards - 시험: 옛 값 찾기만 보던 test_m02_df_values_old 지움 · 794-1b 표준 표 기대를 unit 만으로 - 검증: 빌더 --check 같음 · 핵심 시험 99 통과 · 관련 시험 182 + 3 통과 · typecheck 0 · 서버 로그 오류 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.7 KiB
TypeScript
36 lines
1.7 KiB
TypeScript
/* =============================================================================
|
|
* M02_DF_Api.ts
|
|
* 단위 표준 표 읽기 — 서버 `GET /api/m02/df/standards`(`M02_DF_Router.py`)
|
|
* 부르는 곳 = 단위 고르기(`M02_DF_UnitPick`) · 옵션 기계 이름(`formula_doc_options`)
|
|
* ========================================================================== */
|
|
|
|
import { API_BASE_URL } from "@config/config_frontend";
|
|
|
|
/** 단위 표준 표 */
|
|
export interface CfStandards {
|
|
unit: { 이름: string; 줄: Record<string, unknown>[]; [k: string]: unknown };
|
|
saved: boolean;
|
|
}
|
|
|
|
export async function cfStandards(): Promise<CfStandards> {
|
|
const response = await fetch(`${API_BASE_URL}/m02/df/standards`, { credentials: "include" });
|
|
if (!response.ok) throw new Error(`표준 표 읽기 실패 (${response.status})`);
|
|
return (await response.json()) as CfStandards;
|
|
}
|
|
|
|
let machineNames: Promise<Record<string, string>> | null = null;
|
|
|
|
/** 기계 원문번호 → 「이름 규격」 — 한 번 받아 둠(못 받으면 빈 표 · 다음에 다시) */
|
|
export function cfMachineNames(): Promise<Record<string, string>> {
|
|
machineNames ??= fetch(`${API_BASE_URL}/m02/df/machine-names`, { credentials: "include" })
|
|
.then((r) => (r.ok ? (r.json() as Promise<Record<string, string>>) : Promise.reject()))
|
|
.catch(() => ((machineNames = null), {}));
|
|
return machineNames;
|
|
}
|
|
|
|
/** 끈 기계 원문번호(842-2) — 이름과 함께 한 번 받아 둠(못 받으면 빈 목록) */
|
|
export const cfMachineOff = (): Promise<string[]> =>
|
|
fetch(`${API_BASE_URL}/m02/df/machine-off`, { credentials: "include" })
|
|
.then((r) => (r.ok ? (r.json() as Promise<string[]>) : []))
|
|
.catch(() => []);
|