skailan-ai
Version:
Servicio de IA y procesamiento de lenguaje natural para Skailan
24 lines • 950 B
JavaScript
export class UpdatePrompt {
promptRepository;
constructor(promptRepository) {
this.promptRepository = promptRepository;
}
async execute(request) {
const { id, organizationId, ...updates } = request;
const existingPrompt = await this.promptRepository.findById(id, organizationId);
if (!existingPrompt) {
throw new Error('Prompt not found.');
}
if (updates.name !== undefined)
existingPrompt.name = updates.name;
if (updates.description !== undefined)
existingPrompt.description = updates.description;
if (updates.template !== undefined)
existingPrompt.template = updates.template;
if (updates.type !== undefined)
existingPrompt.type = updates.type;
existingPrompt.updatedAt = new Date();
return this.promptRepository.save(existingPrompt);
}
}
//# sourceMappingURL=UpdatePrompt.js.map