import type { AppInfo, LibInfo } from "akanjs"; export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: { appName: string }) { return `import { endpoint, internal, Public, slice } from "akanjs/signal"; import * as cnst from "../cnst"; import * as srv from "../srv"; // ===== task.signal.ts ===== // Convention: .signal.ts — the API surface for a database module. // Extends endpoint(srv., ...) from akanjs/signal — binds to the service to define query/mutation/pubsub. // endpoint() receives: { query, mutation, pubsub, message } — each typed with the model's return type. // .param() = URL path parameter, .body() = request body, .search() = query string. // // Auto-generated by akan sync (do not write manually): // viewTask(id) — fetch single task for detail view // editTask(id) — fetch task for edit view // mergeTask(id, data) — create/update task // Manual endpoints below: only define endpoints that need custom business logic. // Registered by akan sync into sig.ts barrel. export class TaskInternal extends internal(srv.task, ({ interval }) => ({})) {} export class TaskSlice extends slice(srv.task, { guards: { root: Public, get: Public, cru: Public } }, (init) => ({ inPublic: init().exec(function () { return this.taskService.queryAny(); }), })) {} export class TaskEndpoint extends endpoint(srv.task, ({ mutation }) => ({ startTask: mutation(cnst.Task) .param("taskId", String) .exec(async function (taskId) { return await this.taskService.startTask(taskId); }), completeTask: mutation(cnst.Task) .param("taskId", String) .exec(async function (taskId) { return await this.taskService.completeTask(taskId); }), })) {} // ---- Expandable additional fields: ---- // // message: server→client real-time message (WebSocket) // taskCreated: message(cnst.Task).room("taskId", String).exec(...), // // pubsub: publish-subscribe pattern // taskEvent: pubsub(cnst.Task).exec(...), // // search: search parameters (optional, URL query string) // searchTask: query(cnst.LightTask).search("keyword", String).exec(...), // // guards: authentication/authorization guards // // export class TaskEndpoint extends endpoint(srv.task, { guards: { root: SignedIn } }, ({ query, mutation }) => ({})) {} `; }