mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
feat: add scoped manual usage cleanup
This commit is contained in:
@@ -310,15 +310,35 @@ export interface ManualUsageCleanupSummary {
|
||||
records_deleted: number
|
||||
}
|
||||
|
||||
export interface ManualUsageCleanupResponse {
|
||||
export type ManualUsageCleanupMode = 'policy' | 'older_than_days' | 'before_now'
|
||||
export type ManualUsageCleanupTarget = 'detail_body' | 'compressed_body' | 'headers' | 'records'
|
||||
|
||||
export interface ManualUsageCleanupTargets {
|
||||
detail_body: boolean
|
||||
compressed_body: boolean
|
||||
headers: boolean
|
||||
records: boolean
|
||||
expired_keys: boolean
|
||||
}
|
||||
|
||||
export interface ManualUsageCleanupRequest {
|
||||
mode?: ManualUsageCleanupMode
|
||||
older_than_days?: number
|
||||
targets?: ManualUsageCleanupTarget[]
|
||||
}
|
||||
|
||||
export interface ManualUsageCleanupTaskResponse {
|
||||
message: string
|
||||
mode: ManualUsageCleanupMode
|
||||
requested_older_than_days: number | null
|
||||
summary: ManualUsageCleanupSummary
|
||||
total_affected: number
|
||||
targets: ManualUsageCleanupTargets
|
||||
task: CleanupRunRecord
|
||||
}
|
||||
|
||||
export interface ManualUsageCleanupPreview {
|
||||
mode: ManualUsageCleanupMode
|
||||
requested_older_than_days: number | null
|
||||
targets: ManualUsageCleanupTargets
|
||||
effective_cutoffs: {
|
||||
detail: string
|
||||
compressed: string
|
||||
@@ -1218,14 +1238,20 @@ export const adminApi = {
|
||||
},
|
||||
|
||||
async runManualUsageCleanup(
|
||||
params: { older_than_days?: number } = {}
|
||||
): Promise<ManualUsageCleanupResponse | ManualUsageCleanupConflict> {
|
||||
const body: Record<string, number> = {}
|
||||
params: ManualUsageCleanupRequest = {}
|
||||
): Promise<ManualUsageCleanupTaskResponse | ManualUsageCleanupConflict> {
|
||||
const body: ManualUsageCleanupRequest = {}
|
||||
if (params.mode) {
|
||||
body.mode = params.mode
|
||||
}
|
||||
if (typeof params.older_than_days === 'number') {
|
||||
body.older_than_days = params.older_than_days
|
||||
}
|
||||
if (params.targets?.length) {
|
||||
body.targets = params.targets
|
||||
}
|
||||
try {
|
||||
const response = await apiClient.post<ManualUsageCleanupResponse>(
|
||||
const response = await apiClient.post<ManualUsageCleanupTaskResponse>(
|
||||
'/api/admin/system/cleanup/usage/manual',
|
||||
body
|
||||
)
|
||||
@@ -1240,12 +1266,18 @@ export const adminApi = {
|
||||
},
|
||||
|
||||
async previewManualUsageCleanup(
|
||||
params: { older_than_days?: number } = {}
|
||||
params: ManualUsageCleanupRequest = {}
|
||||
): Promise<ManualUsageCleanupPreview> {
|
||||
const query: Record<string, number> = {}
|
||||
const query: Record<string, string | number> = {}
|
||||
if (params.mode) {
|
||||
query.mode = params.mode
|
||||
}
|
||||
if (typeof params.older_than_days === 'number') {
|
||||
query.older_than_days = params.older_than_days
|
||||
}
|
||||
if (params.targets?.length) {
|
||||
query.targets = params.targets.join(',')
|
||||
}
|
||||
const response = await apiClient.get<ManualUsageCleanupPreview>(
|
||||
'/api/admin/system/cleanup/usage/preview',
|
||||
{ params: query }
|
||||
|
||||
Reference in New Issue
Block a user