Files

13 lines
587 B
TypeScript

import { TaskTreeStore } from "./store.ts";
export function createTaskTreeActivities(store: TaskTreeStore) {
return {
async recordTaskExecution(input: { taskId: string }) {
const task = await store.getTask(input.taskId);
if (!task) throw Object.assign(new Error("task was not found"), { code: "task_not_found" });
const { report } = await store.writeReport({ taskId: task.id, title: "Temporal execution report", body: `Task ${task.title} completed by Temporal worker.`, status: "succeeded" });
return { taskId: task.id, reportId: report.id };
}
};
}