(req: HTTPRequestLike, res: HTTPResponseLike)
| 95 | |
| 96 | @Post("/api/nlp/create") |
| 97 | async handleNLPCreate(req: HTTPRequestLike, res: HTTPResponseLike): Promise<void> { |
| 98 | try { |
| 99 | const body = await this.parseRequestBody(req); |
| 100 | |
| 101 | if (!body.text || typeof body.text !== "string") { |
| 102 | this.sendResponse( |
| 103 | res, |
| 104 | 400, |
| 105 | this.errorResponse("Text field is required and must be a string") |
| 106 | ); |
| 107 | return; |
| 108 | } |
| 109 | |
| 110 | // Parse the natural language input |
| 111 | const parsedData = this.nlParser.parseInput(body.text); |
| 112 | |
| 113 | const taskData = buildTaskCreationDataFromParsed(this.plugin, parsedData, { |
| 114 | creationContext: "api", |
| 115 | }); |
| 116 | |
| 117 | // Create the task - TaskService.createTask() applies defaults automatically |
| 118 | const result = await this.taskService.createTask(taskData); |
| 119 | |
| 120 | this.sendResponse( |
| 121 | res, |
| 122 | 201, |
| 123 | this.successResponse({ |
| 124 | task: result.taskInfo, |
| 125 | parsed: parsedData, |
| 126 | }) |
| 127 | ); |
| 128 | } catch (error: unknown) { |
| 129 | this.sendResponse(res, 400, this.errorResponse(this.getErrorMessage(error))); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | @Get("/api/docs") |
| 134 | async handleOpenAPISpec(req: HTTPRequestLike, res: HTTPResponseLike): Promise<void> { |
no test coverage detected