Export template source from 15b93e42825a3f8055f6305999a12c5b1cc73330:quixos-instance/packages/project-runtime
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import type { Contexts } from "./gen/qx.js";
|
||||
|
||||
export const createProject = ({ objectId }: Contexts["createProject"]) => objectId;
|
||||
export const addTask = async ({ input, ports }: Contexts["addTask"]) => {
|
||||
const task = await ports.task.construct(input.trim() || "Untitled task");
|
||||
await ports.tasks.connect(task);
|
||||
return task;
|
||||
};
|
||||
export const taskCount = { kind: "derived" as const, get: async ({ ports }: Contexts["taskCountGet"]) =>
|
||||
(await ports.tasks.resolve()).length,
|
||||
};
|
||||
export const searchDocument = { kind: "derived" as const, get: async ({ ports }: Contexts["searchDocumentGet"]) => {
|
||||
const [name, tasks] = await Promise.all([ports.named["name.get"](), ports.tasks["tasks.resolve"]()]);
|
||||
const count = tasks.length;
|
||||
return {
|
||||
title: name || "Untitled project",
|
||||
subtitle: `Project · ${count} ${count === 1 ? "task" : "tasks"}`,
|
||||
keywords: ["project", "workspace", count === 0 ? "empty" : "tasks"],
|
||||
};
|
||||
}};
|
||||
export const stopWatch = () => null;
|
||||
Reference in New Issue
Block a user