import type { AppInfo, LibInfo } from "akanjs"; export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: { appName: string }) { return `import { dayjs } from "akanjs/base"; import type { DataInputOf } from "akanjs/document"; import { serve } from "akanjs/service"; import * as db from "../db"; // ===== task.service.ts ===== // Convention: .service.ts — business logic orchestration for a database module. // Extends serve(db., depsCallback) from akanjs/service — binds to the DB model, receives DI deps. // Auto-generated by akan sync (do not write manually): // getTask(id), createTask(data), updateTask(id, data), removeTask(id), // listByStatus(status), searchDocs(text), and all filter+query methods from document.ts. // Manual below: lifecycle hooks, custom business logic methods. // Registered by akan sync into srv.ts barrel. export class TaskService extends serve(db.task, () => ({})) { // Lifecycle hook: runs before every document creation. // Auto-injects the initial workHistory entry for the scalar embedding pattern. override _preCreate(data: DataInputOf): DataInputOf { return { ...data, workHistory: [{ action: "created", at: dayjs(), note: "" }], }; } async startTask(taskId: string) { const task = await this.getTask(taskId); return task.start().save(); } async completeTask(taskId: string) { const task = await this.getTask(taskId); return task.complete().save(); } } // ---- Expandable additional fields: ---- // export class TaskService extends serve(db.task, ({ service, use, signal, plug, env, memory }) => ({ // notiService: service(), // })) { `; }