(req: HTTPRequestLike, res: HTTPResponseLike)
| 63 | |
| 64 | @Post("/api/nlp/parse") |
| 65 | async handleNLPParse(req: HTTPRequestLike, res: HTTPResponseLike): Promise<void> { |
| 66 | try { |
| 67 | const body = await this.parseRequestBody(req); |
| 68 | |
| 69 | if (!body.text || typeof body.text !== "string") { |
| 70 | this.sendResponse( |
| 71 | res, |
| 72 | 400, |
| 73 | this.errorResponse("Text field is required and must be a string") |
| 74 | ); |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | // Parse the natural language input |
| 79 | const parsedData = this.nlParser.parseInput(body.text); |
| 80 | |
| 81 | const taskData = buildTaskCreationDataFromParsed(this.plugin, parsedData); |
| 82 | |
| 83 | this.sendResponse( |
| 84 | res, |
| 85 | 200, |
| 86 | this.successResponse({ |
| 87 | parsed: parsedData, |
| 88 | taskData: taskData, |
| 89 | }) |
| 90 | ); |
| 91 | } catch (error: unknown) { |
| 92 | this.sendResponse(res, 500, this.errorResponse(this.getErrorMessage(error))); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | @Post("/api/nlp/create") |
| 97 | async handleNLPCreate(req: HTTPRequestLike, res: HTTPResponseLike): Promise<void> { |
no test coverage detected