refactor(openflare): migrate console APIs to v1 and centralize routing

Move OpenFlare management endpoints to /api/v1/custom/openflare with
Wavelet response envelopes and Abort* error handling. Keep agent, relay,
and flared protocol routes on /api/* with the legacy compat format.

- Add apiutil helpers and Swagger annotations for console handlers
- Register all OpenFlare routes in internal/router/openflare (not apps)
- Switch frontend services to OpenFlareBaseService and v1 paths
- Remove dead auth/compat code and legacy-base.service.ts
- Update integration tests and changelog
This commit is contained in:
ryan
2026-06-18 20:34:54 +08:00
parent aa348a1b48
commit 399c1bc88d
104 changed files with 28541 additions and 3879 deletions
@@ -1,4 +1,4 @@
import {LegacyOpenFlareBaseService} from './legacy-base.service';
import {OpenFlareBaseService} from './base.service';
import type {
WAFIPGroup,
WAFIPGroupAutoTestPayload,
@@ -10,76 +10,76 @@ import type {
WAFSiteRuleGroups,
} from './types';
export class WafService extends LegacyOpenFlareBaseService {
protected static readonly basePath = '/api/waf';
export class WafService extends OpenFlareBaseService {
protected static override readonly basePath: string = '/api/v1/custom/openflare/waf';
static async listRuleGroups(): Promise<WAFRuleGroup[]> {
return this.legacyGet<WAFRuleGroup[]>('/rule-groups');
return this.get<WAFRuleGroup[]>('/rule-groups');
}
static async getRuleGroup(id: number): Promise<WAFRuleGroup> {
return this.legacyGet<WAFRuleGroup>(`/rule-groups/${id}`);
return this.get<WAFRuleGroup>(`/rule-groups/${id}`);
}
static async createRuleGroup(payload: WAFRuleGroupPayload): Promise<WAFRuleGroup> {
return this.legacyPost<WAFRuleGroup>('/rule-groups', payload);
return this.post<WAFRuleGroup>('/rule-groups', payload);
}
static async updateRuleGroup(
id: number,
payload: WAFRuleGroupPayload,
): Promise<WAFRuleGroup> {
return this.legacyPost<WAFRuleGroup>(`/rule-groups/${id}/update`, payload);
return this.post<WAFRuleGroup>(`/rule-groups/${id}/update`, payload);
}
static async deleteRuleGroup(id: number): Promise<void> {
return this.legacyPost<void>(`/rule-groups/${id}/delete`);
return this.post<void>(`/rule-groups/${id}/delete`);
}
static async updateRuleGroupSites(id: number, ids: number[]): Promise<WAFRuleGroup> {
return this.legacyPost<WAFRuleGroup>(`/rule-groups/${id}/sites`, { ids });
return this.post<WAFRuleGroup>(`/rule-groups/${id}/sites`, { ids });
}
static async listSiteRuleGroups(routeId: number): Promise<WAFSiteRuleGroups> {
return this.legacyGet<WAFSiteRuleGroups>(`/sites/${routeId}/rule-groups`);
return this.get<WAFSiteRuleGroups>(`/sites/${routeId}/rule-groups`);
}
static async updateSiteRuleGroups(
routeId: number,
ids: number[],
): Promise<WAFSiteRuleGroups> {
return this.legacyPost<WAFSiteRuleGroups>(`/sites/${routeId}/rule-groups`, {
return this.post<WAFSiteRuleGroups>(`/sites/${routeId}/rule-groups`, {
ids,
});
}
static async listIPGroups(): Promise<WAFIPGroup[]> {
return this.legacyGet<WAFIPGroup[]>('/ip-groups');
return this.get<WAFIPGroup[]>('/ip-groups');
}
static async getIPGroup(id: number): Promise<WAFIPGroup> {
return this.legacyGet<WAFIPGroup>(`/ip-groups/${id}`);
return this.get<WAFIPGroup>(`/ip-groups/${id}`);
}
static async createIPGroup(payload: WAFIPGroupPayload): Promise<WAFIPGroup> {
return this.legacyPost<WAFIPGroup>('/ip-groups', payload);
return this.post<WAFIPGroup>('/ip-groups', payload);
}
static async updateIPGroup(id: number, payload: WAFIPGroupPayload): Promise<WAFIPGroup> {
return this.legacyPost<WAFIPGroup>(`/ip-groups/${id}/update`, payload);
return this.post<WAFIPGroup>(`/ip-groups/${id}/update`, payload);
}
static async deleteIPGroup(id: number): Promise<void> {
return this.legacyPost<void>(`/ip-groups/${id}/delete`);
return this.post<void>(`/ip-groups/${id}/delete`);
}
static async testIPGroup(
payload: WAFIPGroupAutoTestPayload,
): Promise<WAFIPGroupAutoTestResult> {
return this.legacyPost<WAFIPGroupAutoTestResult>('/ip-groups/test', payload);
return this.post<WAFIPGroupAutoTestResult>('/ip-groups/test', payload);
}
static async syncIPGroup(id: number): Promise<WAFIPGroupSyncResult> {
return this.legacyPost<WAFIPGroupSyncResult>(`/ip-groups/${id}/sync`);
return this.post<WAFIPGroupSyncResult>(`/ip-groups/${id}/sync`);
}
}
}