// API 응답 타입 interface ApiResponse { success: boolean; message: string; data: T; errorCode?: string; } // 타입 정의 export interface BypassParamDto { id?: number; paramName: string; paramType: string; // STRING, INTEGER, LONG, BOOLEAN paramIn: string; // PATH, QUERY, BODY required: boolean; description: string; example: string; // Swagger @Parameter example 값 sortOrder: number; } export interface BypassConfigRequest { domainName: string; displayName: string; webclientBean: string; externalPath: string; httpMethod: string; description: string; params: BypassParamDto[]; } export interface BypassConfigResponse { id: number; domainName: string; endpointName: string; displayName: string; webclientBean: string; externalPath: string; httpMethod: string; description: string; generated: boolean; generatedAt: string | null; responseSchemaClass: string | null; createdAt: string; updatedAt: string; params: BypassParamDto[]; } export interface CodeGenerationResult { controllerPath: string; servicePaths: string[]; message: string; } export interface WebClientBeanInfo { name: string; description: string; } // BASE URL const BASE = '/snp-global/api/bypass-config'; // 헬퍼 함수 (batchApi.ts 패턴과 동일) async function fetchJson(url: string): Promise { const res = await fetch(url); if (!res.ok) throw new Error(`API Error: ${res.status} ${res.statusText}`); return res.json(); } async function postJson(url: string, body?: unknown): Promise { const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: body != null ? JSON.stringify(body) : undefined, }); if (!res.ok) throw new Error(`API Error: ${res.status} ${res.statusText}`); return res.json(); } async function putJson(url: string, body?: unknown): Promise { const res = await fetch(url, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: body != null ? JSON.stringify(body) : undefined, }); if (!res.ok) throw new Error(`API Error: ${res.status} ${res.statusText}`); return res.json(); } async function deleteJson(url: string): Promise { const res = await fetch(url, { method: 'DELETE' }); if (!res.ok) throw new Error(`API Error: ${res.status} ${res.statusText}`); return res.json(); } export const bypassApi = { getConfigs: () => fetchJson>(BASE), getConfig: (id: number) => fetchJson>(`${BASE}/${id}`), createConfig: (data: BypassConfigRequest) => postJson>(BASE, data), updateConfig: (id: number, data: BypassConfigRequest) => putJson>(`${BASE}/${id}`, data), deleteConfig: (id: number) => deleteJson>(`${BASE}/${id}`), generateCode: (id: number, force = false) => postJson>(`${BASE}/${id}/generate?force=${force}`), getWebclientBeans: () => fetchJson>(`${BASE}/webclient-beans`), };