lint and format

This commit is contained in:
Kartik Datrika
2026-03-23 15:46:32 +05:30
parent 30a4cda178
commit a1157ab4c1
48 changed files with 10980 additions and 2810 deletions

View File

@@ -1,61 +1,72 @@
import { Controller, Get, Patch, Headers, Param, Body, HttpException, Logger } from '@nestjs/common';
import {
Controller,
Get,
Patch,
Headers,
Param,
Body,
HttpException,
Logger,
} from '@nestjs/common';
import { PlatformGraphqlService } from '../platform/platform-graphql.service';
import { WorklistService } from './worklist.service';
import { MissedQueueService } from './missed-queue.service';
@Controller('api/worklist')
export class WorklistController {
private readonly logger = new Logger(WorklistController.name);
private readonly logger = new Logger(WorklistController.name);
constructor(
private readonly worklist: WorklistService,
private readonly missedQueue: MissedQueueService,
private readonly platform: PlatformGraphqlService,
) {}
constructor(
private readonly worklist: WorklistService,
private readonly missedQueue: MissedQueueService,
private readonly platform: PlatformGraphqlService,
) {}
@Get()
async getWorklist(@Headers('authorization') authHeader: string) {
if (!authHeader) {
throw new HttpException('Authorization required', 401);
}
const agentName = await this.resolveAgentName(authHeader);
this.logger.log(`Fetching worklist for agent: ${agentName}`);
return this.worklist.getWorklist(agentName, authHeader);
@Get()
async getWorklist(@Headers('authorization') authHeader: string) {
if (!authHeader) {
throw new HttpException('Authorization required', 401);
}
@Get('missed-queue')
async getMissedQueue(@Headers('authorization') authHeader: string) {
if (!authHeader) throw new HttpException('Authorization header required', 401);
const agentName = await this.resolveAgentName(authHeader);
return this.missedQueue.getMissedQueue(agentName, authHeader);
}
const agentName = await this.resolveAgentName(authHeader);
this.logger.log(`Fetching worklist for agent: ${agentName}`);
@Patch('missed-queue/:id/status')
async updateMissedCallStatus(
@Param('id') id: string,
@Headers('authorization') authHeader: string,
@Body() body: { status: string },
) {
if (!authHeader) throw new HttpException('Authorization header required', 401);
if (!body.status) throw new HttpException('status is required', 400);
return this.missedQueue.updateStatus(id, body.status, authHeader);
}
return this.worklist.getWorklist(agentName, authHeader);
}
private async resolveAgentName(authHeader: string): Promise<string> {
try {
const data = await this.platform.queryWithAuth<any>(
`{ currentUser { workspaceMember { name { firstName lastName } } } }`,
undefined,
authHeader,
);
const name = data.currentUser?.workspaceMember?.name;
const full = `${name?.firstName ?? ''} ${name?.lastName ?? ''}`.trim();
if (full) return full;
} catch (err) {
this.logger.warn(`Failed to resolve agent name: ${err}`);
}
throw new HttpException('Could not determine agent identity', 400);
@Get('missed-queue')
async getMissedQueue(@Headers('authorization') authHeader: string) {
if (!authHeader)
throw new HttpException('Authorization header required', 401);
const agentName = await this.resolveAgentName(authHeader);
return this.missedQueue.getMissedQueue(agentName, authHeader);
}
@Patch('missed-queue/:id/status')
async updateMissedCallStatus(
@Param('id') id: string,
@Headers('authorization') authHeader: string,
@Body() body: { status: string },
) {
if (!authHeader)
throw new HttpException('Authorization header required', 401);
if (!body.status) throw new HttpException('status is required', 400);
return this.missedQueue.updateStatus(id, body.status, authHeader);
}
private async resolveAgentName(authHeader: string): Promise<string> {
try {
const data = await this.platform.queryWithAuth<any>(
`{ currentUser { workspaceMember { name { firstName lastName } } } }`,
undefined,
authHeader,
);
const name = data.currentUser?.workspaceMember?.name;
const full = `${name?.firstName ?? ''} ${name?.lastName ?? ''}`.trim();
if (full) return full;
} catch (err) {
this.logger.warn(`Failed to resolve agent name: ${err}`);
}
throw new HttpException('Could not determine agent identity', 400);
}
}