feat: implement full CRUD and administrative management endpoints for WAP servers in the sysadmin API
This commit is contained in:
@@ -174,6 +174,130 @@ export const fetchWapServers = async (filters: any) => {
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export type WapServer = {
|
||||
id?: string;
|
||||
_id?: string;
|
||||
name?: string;
|
||||
description?: string;
|
||||
ipv4: string;
|
||||
ipv6?: string;
|
||||
countBots: number;
|
||||
maxBots: number;
|
||||
port: number;
|
||||
active: boolean;
|
||||
};
|
||||
|
||||
export type UpdateWapServerPayload = {
|
||||
serverId: string;
|
||||
name?: string;
|
||||
ipv4?: string;
|
||||
port?: number;
|
||||
maxBots?: number;
|
||||
active?: boolean;
|
||||
};
|
||||
|
||||
export const updateWapServer = async (data: UpdateWapServerPayload): Promise<WapServer> => {
|
||||
const res = await sysadminApi.post('/wap/update', data);
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export type WapAssignedOrganization = {
|
||||
id: string;
|
||||
name?: string;
|
||||
};
|
||||
|
||||
export type WapContainerDto = {
|
||||
id?: string;
|
||||
name?: string;
|
||||
organizationId?: string;
|
||||
image?: string;
|
||||
state?: string;
|
||||
status?: string;
|
||||
ports?: unknown[];
|
||||
created?: number;
|
||||
};
|
||||
|
||||
export type WapServerAuditResult = {
|
||||
serverId: string;
|
||||
assignedOrganizations: WapAssignedOrganization[];
|
||||
detectedBots: WapContainerDto[];
|
||||
validBots: WapContainerDto[];
|
||||
ghostBots: WapContainerDto[];
|
||||
missingBots: WapAssignedOrganization[];
|
||||
expectedCountBots: number;
|
||||
storedCountBots: number;
|
||||
runtimeCountBots: number;
|
||||
countMismatch: boolean;
|
||||
};
|
||||
|
||||
export type WapServerRecalculateCountResult = {
|
||||
serverId: string;
|
||||
before: number;
|
||||
after: number;
|
||||
};
|
||||
|
||||
export type WapServerDeleteResult = {
|
||||
serverId: string;
|
||||
deleted: true;
|
||||
};
|
||||
|
||||
export type WapServerOrganizationActionPayload = {
|
||||
serverId: string;
|
||||
organizationId: string;
|
||||
};
|
||||
|
||||
export type WapServerQrResult = WapServerOrganizationActionPayload & {
|
||||
qr: string;
|
||||
};
|
||||
|
||||
export type WapServerDetachResult = WapServerOrganizationActionPayload & {
|
||||
botDeleted: boolean;
|
||||
botAlreadyMissing: boolean;
|
||||
before: number;
|
||||
after: number;
|
||||
};
|
||||
|
||||
export const auditWapServer = async (serverId: string): Promise<WapServerAuditResult> => {
|
||||
const res = await sysadminApi.post('/wap/audit', { serverId });
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const recalculateWapServerCount = async (serverId: string): Promise<WapServerRecalculateCountResult> => {
|
||||
const res = await sysadminApi.post('/wap/recalculate-count', { serverId });
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const deleteWapServer = async (serverId: string): Promise<WapServerDeleteResult> => {
|
||||
const res = await sysadminApi.post('/wap/delete', { serverId });
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const startWapBot = async (data: WapServerOrganizationActionPayload): Promise<void> => {
|
||||
await sysadminApi.post('/wap/bot/start', data);
|
||||
};
|
||||
|
||||
export const stopWapBot = async (data: WapServerOrganizationActionPayload): Promise<void> => {
|
||||
await sysadminApi.post('/wap/bot/stop', data);
|
||||
};
|
||||
|
||||
export const restartWapBot = async (data: WapServerOrganizationActionPayload): Promise<void> => {
|
||||
await sysadminApi.post('/wap/bot/restart', data);
|
||||
};
|
||||
|
||||
export const getWapBotQr = async (data: WapServerOrganizationActionPayload): Promise<WapServerQrResult> => {
|
||||
const res = await sysadminApi.post('/wap/bot/qr', data);
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const deleteWapBot = async (data: WapServerOrganizationActionPayload): Promise<void> => {
|
||||
await sysadminApi.post('/wap/bot/delete', data);
|
||||
};
|
||||
|
||||
export const detachWapOrganizationServer = async (data: WapServerOrganizationActionPayload): Promise<WapServerDetachResult> => {
|
||||
const res = await sysadminApi.post('/wap/bot/detach', data);
|
||||
return res.data;
|
||||
};
|
||||
|
||||
// Companies API Calls
|
||||
export const fetchCompanies = async (filters: any) => {
|
||||
const res = await sysadminApi.post('/companies/paginate', filters);
|
||||
|
||||
Reference in New Issue
Block a user