import { v4 as uuidv4 } from 'uuid'; import { logger } from '../config/logging.js'; import { getPromisifiedDb } from './db.js'; import fs from 'fs/promises'; import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); export interface Template { id: string; name: string; description?: string; content: string; tags?: string[]; version: number; createdAt: Date; updatedAt: Date; } // Database row interface to handle type conversions interface TemplateRow { id: string; name: string; description: string | null; content: string; tags: string | null; version: number; created_at: string; updated_at: string; } /** * Get a template by name or ID */ export async function getTemplate(nameOrId: string): Promise