feat(frontend): add config types and API client for file-config endpoints
- types/config.ts: TypeScript interfaces for ActionConfig, FilterConfig, JailFileConfig, ConfFileContent, and related request/response shapes - api/config.ts: typed API functions for reading and writing conf files - api/endpoints.ts: add /config/file/* endpoint constants
This commit is contained in:
@@ -5,11 +5,15 @@
|
||||
import { del, get, post, put } from "./client";
|
||||
import { ENDPOINTS } from "./endpoints";
|
||||
import type {
|
||||
ActionConfig,
|
||||
ActionConfigUpdate,
|
||||
AddLogPathRequest,
|
||||
ConfFileContent,
|
||||
ConfFileCreateRequest,
|
||||
ConfFilesResponse,
|
||||
ConfFileUpdateRequest,
|
||||
FilterConfig,
|
||||
FilterConfigUpdate,
|
||||
GlobalConfig,
|
||||
GlobalConfigUpdate,
|
||||
JailConfigFileContent,
|
||||
@@ -26,6 +30,8 @@ import type {
|
||||
RegexTestResponse,
|
||||
ServerSettingsResponse,
|
||||
ServerSettingsUpdate,
|
||||
JailFileConfig,
|
||||
JailFileConfigUpdate,
|
||||
} from "../types/config";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -164,6 +170,12 @@ export async function fetchJailConfigFiles(): Promise<JailConfigFilesResponse> {
|
||||
return get<JailConfigFilesResponse>(ENDPOINTS.configJailFiles);
|
||||
}
|
||||
|
||||
export async function createJailConfigFile(
|
||||
req: ConfFileCreateRequest
|
||||
): Promise<ConfFileContent> {
|
||||
return post<ConfFileContent>(ENDPOINTS.configJailFiles, req);
|
||||
}
|
||||
|
||||
export async function fetchJailConfigFileContent(
|
||||
filename: string
|
||||
): Promise<JailConfigFileContent> {
|
||||
@@ -226,3 +238,48 @@ export async function createActionFile(
|
||||
): Promise<ConfFileContent> {
|
||||
return post<ConfFileContent>(ENDPOINTS.configActions, req);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Parsed filter config (Task 2.2)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export async function fetchParsedFilter(name: string): Promise<FilterConfig> {
|
||||
return get<FilterConfig>(ENDPOINTS.configFilterParsed(name));
|
||||
}
|
||||
|
||||
export async function updateParsedFilter(
|
||||
name: string,
|
||||
update: FilterConfigUpdate
|
||||
): Promise<void> {
|
||||
await put<undefined>(ENDPOINTS.configFilterParsed(name), update);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Parsed action config (Task 3.2)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export async function fetchParsedAction(name: string): Promise<ActionConfig> {
|
||||
return get<ActionConfig>(ENDPOINTS.configActionParsed(name));
|
||||
}
|
||||
|
||||
export async function updateParsedAction(
|
||||
name: string,
|
||||
update: ActionConfigUpdate
|
||||
): Promise<void> {
|
||||
await put<undefined>(ENDPOINTS.configActionParsed(name), update);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Parsed jail file config (Task 6.1 / 6.2)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export async function fetchParsedJailFile(filename: string): Promise<JailFileConfig> {
|
||||
return get<JailFileConfig>(ENDPOINTS.configJailFileParsed(filename));
|
||||
}
|
||||
|
||||
export async function updateParsedJailFile(
|
||||
filename: string,
|
||||
update: JailFileConfigUpdate
|
||||
): Promise<void> {
|
||||
await put<undefined>(ENDPOINTS.configJailFileParsed(filename), update);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user