| 26 | * and the CodeTaskRepository for persistence. |
| 27 | */ |
| 28 | export class CodeTaskServiceImpl implements CodeTaskService { |
| 29 | private codeTaskCreation: CodeTaskCreation; |
| 30 | private codeTaskFileSelection: CodeTaskFileSelection; |
| 31 | private codeTaskDesignGeneration: CodeTaskDesignGeneration; |
| 32 | |
| 33 | constructor(private codeTaskRepo: CodeTaskRepository) { |
| 34 | this.codeTaskCreation = new CodeTaskCreation(codeTaskRepo); |
| 35 | this.codeTaskFileSelection = new CodeTaskFileSelection(codeTaskRepo); |
| 36 | } |
| 37 | |
| 38 | // --- CodeTask CRUD (Delegated to Repository) --- |
| 39 | |
| 40 | async getCodeTask(userId: string, codeTaskId: string): Promise<CodeTask | null> { |
| 41 | logger.debug({ userId, codeTaskId }, '[CodeTaskServiceImpl] Getting codeTask...'); |
| 42 | // Authorization might be checked here or rely on repository/user context |
| 43 | return this.codeTaskRepo.getCodeTask(userId, codeTaskId); |
| 44 | } |
| 45 | |
| 46 | async listCodeTasks(userId: string): Promise<CodeTask[]> { |
| 47 | logger.debug({ userId }, '[CodeTaskServiceImpl] Listing codeTasks...'); |
| 48 | return this.codeTaskRepo.listCodeTasks(userId); |
| 49 | } |
| 50 | |
| 51 | async updateCodeTask(userId: string, codeTaskId: string, updates: UpdateCodeTaskData): Promise<void> { |
| 52 | logger.debug({ userId, codeTaskId, updates }, '[CodeTaskServiceImpl] Updating codeTask...'); |
| 53 | // Add validation or business logic before updating if needed |
| 54 | await this.codeTaskRepo.updateCodeTask(userId, codeTaskId, updates); |
| 55 | } |
| 56 | |
| 57 | async deleteCodeTask(userId: string, codeTaskId: string): Promise<void> { |
| 58 | logger.info({ userId, codeTaskId }, '[CodeTaskServiceImpl] Deleting codeTask...'); |
| 59 | // TODO: Implement workspace cleanup logic (e.g., delete cloned repo directory) |
| 60 | logger.info({ codeTaskId }, '[CodeTaskServiceImpl] Cleaning up workspace (placeholder)...'); |
| 61 | await this.codeTaskRepo.deleteCodeTask(userId, codeTaskId); |
| 62 | logger.info({ codeTaskId }, '[CodeTaskServiceImpl] CodeTask deleted from repository.'); |
| 63 | } |
| 64 | |
| 65 | // --- Preset CRUD (Delegated to Repository) --- |
| 66 | |
| 67 | async saveCodeTaskPreset(userId: string, name: string, config: Omit<CreateCodeTaskData, 'title' | 'instructions'>): Promise<CodeTaskPreset> { |
| 68 | logger.info({ userId, name }, '[CodeTaskServiceImpl] Saving preset...'); |
| 69 | const presetId = randomUUID(); |
| 70 | const now = Date.now(); |
| 71 | const newPreset: CodeTaskPreset = { |
| 72 | id: presetId, |
| 73 | userId: userId, |
| 74 | name: name, |
| 75 | config: config, |
| 76 | createdAt: now, |
| 77 | updatedAt: now, |
| 78 | }; |
| 79 | await this.codeTaskRepo.saveCodeTaskPreset(newPreset); |
| 80 | return { ...newPreset }; |
| 81 | } |
| 82 | |
| 83 | async listCodeTaskPresets(userId: string): Promise<CodeTaskPreset[]> { |
| 84 | logger.debug({ userId }, '[CodeTaskServiceImpl] Listing presets...'); |
| 85 | return this.codeTaskRepo.listCodeTaskPresets(userId); |
nothing calls this directly
no outgoing calls
no test coverage detected