Export template source from 4c88728f144add3457b4273d4b9a04ee53c53be3:quixos-instance/packages/project-runtime
This commit is contained in:
+905
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
||||
// This adapter keeps the implementation file hand-authored.
|
||||
export { addTask as handler } from "../project.impl.js";
|
||||
@@ -0,0 +1,2 @@
|
||||
// This adapter keeps the implementation file hand-authored.
|
||||
export { createProject as handler } from "../project.impl.js";
|
||||
@@ -0,0 +1,2 @@
|
||||
// This adapter keeps the implementation file hand-authored.
|
||||
export { searchDocument as handler } from "../project.impl.js";
|
||||
@@ -0,0 +1,2 @@
|
||||
// This adapter keeps the implementation file hand-authored.
|
||||
export { searchDocument as handler } from "../project.impl.js";
|
||||
@@ -0,0 +1,2 @@
|
||||
// This adapter keeps the implementation file hand-authored.
|
||||
export { stopWatch as handler } from "../project.impl.js";
|
||||
@@ -0,0 +1,2 @@
|
||||
// This adapter keeps the implementation file hand-authored.
|
||||
export { taskCount as handler } from "../project.impl.js";
|
||||
@@ -0,0 +1,2 @@
|
||||
// This adapter keeps the implementation file hand-authored.
|
||||
export { taskCount as handler } from "../project.impl.js";
|
||||
@@ -0,0 +1,2 @@
|
||||
// This adapter keeps the implementation file hand-authored.
|
||||
export { stopWatch as handler } from "../project.impl.js";
|
||||
@@ -0,0 +1,15 @@
|
||||
import { encodeQxValue, decodeQxValue, type MessageBinding, type QxValueType } from "@quixos/camino-package-runtime";
|
||||
|
||||
type SearchDocument = { title: string; subtitle: string; keywords: string[] };
|
||||
const schema: QxValueType = {
|
||||
kind: "record",
|
||||
fields: {
|
||||
title: { kind: "scalar", name: "string" },
|
||||
subtitle: { kind: "scalar", name: "string" },
|
||||
keywords: { kind: "list", value: { kind: "scalar", name: "string" } },
|
||||
},
|
||||
};
|
||||
export const searchDocumentBinding: MessageBinding<SearchDocument> = {
|
||||
encode: (value) => encodeQxValue(schema, value, {}),
|
||||
decode: (value) => decodeQxValue(schema, value, {}),
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
// Generated by qx-scaffold-v1
|
||||
import { serveMigration } from "@quixos/camino-package-runtime";
|
||||
await serveMigration({});
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { Contexts } from "./gen/qx.js";
|
||||
|
||||
export const createProject = ({ objectId }: Contexts["createProject"]) => objectId;
|
||||
export const createTag = async ({ ports, input, objectId }: Contexts["createTag"]) => {
|
||||
await ports.data["name.set"](input.trim() || "New tag");
|
||||
return objectId;
|
||||
};
|
||||
export const addTag = async ({ ports, input }: Contexts["addTag"]) => {
|
||||
if (!input.trim()) throw new Error("Enter a tag name");
|
||||
const tag = await ports.tag.construct(input.trim());
|
||||
await ports.catalog["tags.connect"](tag);
|
||||
return tag;
|
||||
};
|
||||
export const addTask = async ({ input, ports }: Contexts["addTask"]) => {
|
||||
const task = await ports.task.construct(input.trim() || "Untitled task");
|
||||
await ports.tasks["tasks.connect"](task);
|
||||
return task;
|
||||
};
|
||||
export const taskCount = {
|
||||
kind: "derived" as const,
|
||||
get: async ({ ports }: Contexts["taskCountGet"]) => (await ports.tasks["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;
|
||||
@@ -0,0 +1,27 @@
|
||||
// Generated by qx-scaffold-v1
|
||||
import { servePackageRuntime } from "@quixos/camino-package-runtime";
|
||||
import { createRuntime } from "./gen/qx.js";
|
||||
import { addTag, createTag } from "./project.impl.js";
|
||||
import { handler as impl0 } from "./impl/createProject.js";
|
||||
import { handler as impl1 } from "./impl/addTask.js";
|
||||
import { handler as impl2 } from "./impl/taskCountGet.js";
|
||||
import { handler as impl3 } from "./impl/taskCountWatch.js";
|
||||
import { handler as impl4 } from "./impl/taskCountWatchStop.js";
|
||||
import { handler as impl5 } from "./impl/searchDocumentGet.js";
|
||||
import { handler as impl6 } from "./impl/searchDocumentWatch.js";
|
||||
import { handler as impl7 } from "./impl/searchDocumentWatchStop.js";
|
||||
servePackageRuntime(
|
||||
createRuntime({
|
||||
addTag,
|
||||
createTag,
|
||||
newProject: ({ ports }) => ports.project.construct(),
|
||||
createProject: impl0,
|
||||
addTask: impl1,
|
||||
taskCountGet: impl2,
|
||||
taskCountWatch: impl3,
|
||||
taskCountWatchStop: impl4,
|
||||
searchDocumentGet: impl5,
|
||||
searchDocumentWatch: impl6,
|
||||
searchDocumentWatchStop: impl7,
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user