- 새 요소 파일(우리 md 에서만 · 판 2026-01-01): 엔지니어링노임 56 · 측량노임 20 · 건설사업관리노임 4 · SW노임 17 · 산림노임 2 — 빌더 build_인력_노임.py · 줄 수·값 md 기계 대조
- 준용대상 49 → 48: 측량중급기술자 옮김(로직 참조 8) · 원문 통합 목록 5 직종 통합 칸(목도 · 특수비계공 · 함석공 · 갱부 · 스레이트공) · 절단공 갈림 · 비슷한 이름 21 후보
- 건설노임 미공표 14 산정{값 · 근거 · 마지막공표} — 원문 회차 평균 그대로 이음 · 석조각공·드잡이공편수 다산소프트와 이음 계열 다름 비고 · 2026-09-01 적용분 확보됨 비고
- 엔진 차례 값 → 준용 → 통합 → 산정 · 호표 출처 · M01 준용 후보 7 노임 파일 · 통합·산정·후보 칸 읽기 전용
- ref/_비교_estx.md 10절: ESTX 378 줄 중 371 짝 · 짝 없는 직종 42 · 일괄 시험 계산 통과 1104 → 1115
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JgUhN55Z3BCYhUJTjwTNfj
167 lines
4.3 KiB
TypeScript
167 lines
4.3 KiB
TypeScript
/* =============================================================================
|
|
* M01_MasterData_UI_Logic_Api.ts
|
|
* 로직 화면이 부르는 서버 길 — 계약 `resources/master_data/_화면_계약.md` · `/api/m01`
|
|
* ========================================================================== */
|
|
|
|
import { API_BASE_URL } from "@config/config_frontend";
|
|
|
|
/** 로직 한 줄 — 파일 그대로(한글 칸) · 틀 `_틀.md` 6장 */
|
|
export interface LogicInput {
|
|
이름: string;
|
|
단위?: string;
|
|
고르기?: (string | number)[];
|
|
범위?: [number, number];
|
|
}
|
|
export interface HoLine {
|
|
종류: string;
|
|
요소: string;
|
|
이름?: string;
|
|
규격?: string;
|
|
단위?: string;
|
|
수량: string;
|
|
비목?: string;
|
|
}
|
|
export interface NamedFormula {
|
|
이름: string;
|
|
식: string;
|
|
비목?: string;
|
|
출처?: string;
|
|
}
|
|
export interface LogicRow {
|
|
열쇠: string;
|
|
이름: string;
|
|
결과단위: string;
|
|
출처: string;
|
|
소유?: string;
|
|
입력: LogicInput[];
|
|
중간: NamedFormula[];
|
|
호표?: HoLine[];
|
|
결과?: { 식: string };
|
|
덧줄?: NamedFormula[];
|
|
끝수?: string | null;
|
|
비고?: string;
|
|
[extra: string]: unknown;
|
|
}
|
|
|
|
export interface LogicSummary {
|
|
file: string;
|
|
book: string;
|
|
chapter: string;
|
|
열쇠: string;
|
|
이름: string;
|
|
결과단위: string;
|
|
출처: string;
|
|
blocked: boolean;
|
|
reasons: string[];
|
|
}
|
|
|
|
export interface ElementBrief {
|
|
ref: string;
|
|
file?: string;
|
|
이름?: string;
|
|
규격?: string;
|
|
단위?: unknown;
|
|
값?: unknown;
|
|
값칸?: Record<string, string> | null;
|
|
}
|
|
|
|
export interface LogicOne {
|
|
file: string;
|
|
version: string;
|
|
logic: LogicRow;
|
|
blocked: boolean;
|
|
reasons: string[];
|
|
prices: Record<string, ElementBrief | null>;
|
|
}
|
|
|
|
export interface CalcLine {
|
|
이름: string;
|
|
단위: string;
|
|
수량: number;
|
|
단가: number;
|
|
금액: number;
|
|
비목: Record<string, number>;
|
|
/** 값 없는 요소를 다른 값으로 셈 — 「준용: <직종>」 · 「통합: <직종>」 · 「산정: …」 */
|
|
출처?: string;
|
|
}
|
|
export type CalcAnswer =
|
|
| {
|
|
ok: true;
|
|
lines?: CalcLine[];
|
|
sums?: Record<string, number>;
|
|
result?: unknown;
|
|
middle: Record<string, unknown>;
|
|
}
|
|
| { ok: false; reason: string };
|
|
|
|
export interface LogicFile {
|
|
file: string;
|
|
book: string;
|
|
chapter: string;
|
|
version: string;
|
|
}
|
|
|
|
export interface SaveChange {
|
|
op: "edit" | "add" | "delete";
|
|
key?: string;
|
|
row?: LogicRow;
|
|
}
|
|
export interface SaveFile {
|
|
file: string;
|
|
version: string;
|
|
changes: SaveChange[];
|
|
}
|
|
|
|
/** 서버가 준 몸과 상태 번호 — 409·422 는 몸(`detail`)을 화면이 풀어 보임 */
|
|
export class ApiError extends Error {
|
|
constructor(
|
|
public status: number,
|
|
public detail: unknown,
|
|
) {
|
|
super(typeof detail === "string" ? detail : JSON.stringify(detail));
|
|
}
|
|
}
|
|
|
|
async function request<T>(path: string, body?: unknown): Promise<T> {
|
|
const response = await fetch(`${API_BASE_URL}/m01${path}`, {
|
|
method: body === undefined ? "GET" : "POST",
|
|
credentials: "include",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: body === undefined ? undefined : JSON.stringify(body),
|
|
});
|
|
const data = (await response.json().catch(() => ({}))) as { detail?: unknown } & T;
|
|
if (!response.ok) throw new ApiError(response.status, data.detail ?? response.statusText);
|
|
return data;
|
|
}
|
|
|
|
const query = (params: Record<string, string>): string => new URLSearchParams(params).toString();
|
|
|
|
export const fetchLogics = (): Promise<LogicSummary[]> =>
|
|
request<{ logics: LogicSummary[] }>("/logics").then((d) => d.logics);
|
|
|
|
export const fetchLogic = (book: string, key: string): Promise<LogicOne> =>
|
|
request(`/logic?${query({ book, key })}`);
|
|
|
|
export const fetchLogicFiles = (): Promise<LogicFile[]> =>
|
|
request<{ files: LogicFile[] }>(`/groups/${encodeURIComponent("로직")}/files`).then(
|
|
(d) => d.files,
|
|
);
|
|
|
|
export const searchElements = (
|
|
group: string,
|
|
q: string,
|
|
): Promise<{ total: number; items: ElementBrief[] }> =>
|
|
request(`/elements?${query({ group, q, limit: "100" })}`);
|
|
|
|
export const runCalc = (body: {
|
|
book: string;
|
|
key: string;
|
|
inputs: Record<string, unknown>;
|
|
row?: LogicRow;
|
|
file?: string;
|
|
}): Promise<CalcAnswer> => request("/calc", body);
|
|
|
|
export const saveFiles = (
|
|
files: SaveFile[],
|
|
): Promise<{ files: { file: string; version: string }[] }> => request("/save", { files });
|