feat: add forced WAP server deletion support to clean up associated organizations and runtime bots

This commit is contained in:
2026-07-30 17:58:10 -03:00
parent cb830fcf01
commit 446c65ff37
8 changed files with 191 additions and 19 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import axios from "axios";
import { Request, Response } from "express";
import { WapService } from "../services/wap.service";
import { CreateWapServerParams, PaginateWapServerParams, UpdateWapServerParams, WapServerByIdParams, WapServerOrganizationActionParams } from "src/models/WapServers.Model";
import { CreateWapServerParams, PaginateWapServerParams, UpdateWapServerParams, WapServerByIdParams, WapServerDeleteParams, WapServerOrganizationActionParams } from "src/models/WapServers.Model";
const wapService = new WapService();
@@ -83,7 +83,7 @@ export class WapController {
public deleteServer = async (req: Request, res: Response): Promise<void> => {
try {
const data: WapServerByIdParams = req.body as WapServerByIdParams;
const data: WapServerDeleteParams = req.body as WapServerDeleteParams;
const result = await wapService.deleteWapServer(data);
res.json(result);
} catch (error) {
+10
View File
@@ -62,9 +62,19 @@ export type WapServerByIdParams = {
serverId: string;
};
export type WapServerDeleteParams = WapServerByIdParams & {
force?: boolean;
};
export type WapServerDeleteResult = {
serverId: string;
deleted: true;
force?: boolean;
detachedOrganizations?: number;
deletedRuntimeBots?: number;
skippedRuntimeBots?: number;
auditFailed?: boolean;
auditMessage?: string;
};
export type WapServerOrganizationActionParams = WapServerByIdParams & {
+2 -1
View File
@@ -8,6 +8,7 @@ import {
PaginateWapServerResults,
WapServerAuditResult,
WapServerByIdParams,
WapServerDeleteParams,
WapServerDeleteResult,
WapServerDetachResult,
WapServerOrganizationActionParams,
@@ -82,7 +83,7 @@ export class WapService {
return response.data as WapServerRecalculateCountResult;
}
public async deleteWapServer(data: WapServerByIdParams): Promise<WapServerDeleteResult> {
public async deleteWapServer(data: WapServerDeleteParams): Promise<WapServerDeleteResult> {
const nonce = await getSysAdminNonce();
const postData = { ...data, ...{ payload: getPayload(nonce) } };