Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(types): align client models and add reliable web typecheck command

Andreje9ea4731984b
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index a5784f9d3..82bfb09aa 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -82,7 +82,7 @@ api.get("/health", (c) => {
return c.json({ status: "ok" });
});
-api.get("/public-project/:id", async (c) => {
+const publicProjectApi = api.get("/public-project/:id", async (c) => {
const { id } = c.req.param();
const project = await getPublicProject(id);
@@ -242,6 +242,7 @@ export type AppType =
| typeof externalLinkApi
| typeof workflowRuleApi
| typeof invitationApi
+ | typeof publicProjectApi
| typeof invitationPublicApi;
export default app;
diff --git a/apps/web/package.json b/apps/web/package.json
index d7c0f2ccf..ab0f6547c 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -7,7 +7,8 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
- "lint": "biome check --write ."
+ "lint": "biome check --write .",
+ "typecheck": "tsc --noEmit -p tsconfig.app.json"
},
"dependencies": {
"@base-ui/react": "^1.2.0",
diff --git a/apps/web/src/components/project/workflow-editor.tsx b/apps/web/src/components/project/workflow-editor.tsx
index bcc306c40..2c24cef17 100644
--- a/apps/web/src/components/project/workflow-editor.tsx
+++ b/apps/web/src/components/project/workflow-editor.tsx
@@ -28,7 +28,9 @@ export default function WorkflowEditor({ projectId }: WorkflowEditorProps) {
useGetWorkflowRules(projectId);
const { mutateAsync: upsertRule } = useUpsertWorkflowRule();
- const handleChange = async (eventType: string, columnId: string) => {
+ const handleChange = async (eventType: string, columnId: string | null) => {
+ if (!columnId) return;
+
try {
await upsertRule({
projectId,
diff --git a/apps/web/src/fetchers/activity/create-activity.ts b/apps/web/src/fetchers/activity/create-activity.ts
index a8d3f39cc..045371bd0 100644
--- a/apps/web/src/fetchers/activity/create-activity.ts
+++ b/apps/web/src/fetchers/activity/create-activity.ts
@@ -5,16 +5,11 @@ export type CreateActivityRequest = InferRequestType<
(typeof client)["activity"]["comment"]["$post"]
>["json"];
-async function createActivity({
- taskId,
- content,
- userId,
-}: CreateActivityRequest) {
+async function createActivity({ taskId, comment }: CreateActivityRequest) {
const response = await client.activity.comment.$post({
json: {
taskId,
- content,
- userId,
+ comment,
},
});
diff --git a/apps/web/src/fetchers/task/update-task-assignee.ts b/apps/web/src/fetchers/task/update-task-assignee.ts
index 2e39bb747..41e76b633 100644
--- a/apps/web/src/fetchers/task/update-task-assignee.ts
+++ b/apps/web/src/fetchers/task/update-task-assignee.ts
@@ -1,7 +1,12 @@
import { client } from "@kaneo/libs";
import type Task from "@/types/task";
-async function updateTaskAssignee(taskId: string, task: Task) {
+type UpdateTaskAssigneePayload = Pick<Task, "userId">;
+
+async function updateTaskAssignee(
+ taskId: string,
+ task: UpdateTaskAssigneePayload,
+) {
const response = await client.task.assignee[":id"].$put({
param: { id: taskId },
json: {
diff --git a/apps/web/src/fetchers/task/update-task-status.ts b/apps/web/src/fetchers/task/update-task-status.ts
index bbbd13f3a..13e60e42a 100644
--- a/apps/web/src/fetchers/task/update-task-status.ts
+++ b/apps/web/src/fetchers/task/update-task-status.ts
@@ -1,7 +1,9 @@
import { client } from "@kaneo/libs";
import type Task from "@/types/task";
-async function updateTaskStatus(taskId: string, task: Task) {
+type UpdateTaskStatusPayload = Pick<Task, "status">;
+
+async function updateTaskStatus(taskId: string, task: UpdateTaskStatusPayload) {
const response = await client.task.status[":id"].$put({
param: { id: taskId },
json: {
diff --git a/apps/web/src/lib/toast.ts b/apps/web/src/lib/toast.ts
index 5cc83652f..ac39d1ba6 100644
--- a/apps/web/src/lib/toast.ts
+++ b/apps/web/src/lib/toast.ts
@@ -41,6 +41,7 @@ function addToast(
}
type ToastFn = (title: string, options?: ToastOptions) => string;
+type ToastId = string;
const success: ToastFn = (title, options) =>
addToast(title, "success", options);
@@ -50,6 +51,16 @@ const warning: ToastFn = (title, options) =>
addToast(title, "warning", options);
const message: ToastFn = (title, options) =>
addToast(title, undefined, options);
+const loading: ToastFn = (title, options) =>
+ toastManager.add({
+ title,
+ description: options?.description,
+ type: "loading",
+ });
+const dismiss = (id?: ToastId) => {
+ if (!id) return;
+ toastManager.close(id);
+};
const toast = Object.assign(message, {
success,
@@ -57,6 +68,8 @@ const toast = Object.assign(message, {
info,
warning,
message,
+ loading,
+ dismiss,
});
export { toast };
diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx
index f8cca4f3b..30c2bae8f 100644
--- a/apps/web/src/main.tsx
+++ b/apps/web/src/main.tsx
@@ -42,12 +42,6 @@ const router = createRouter({
},
});
-declare module "@tanstack/react-router" {
- type Register = {
- router: typeof router;
- };
-}
-
function App() {
const { user } = useAuth();
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/account/preferences.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/account/preferences.tsx
index b3c94a772..886192966 100644
--- a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/account/preferences.tsx
+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/account/preferences.tsx
@@ -67,7 +67,10 @@ function RouteComponent() {
Choose your preferred color scheme
</p>
</div>
- <Select value={theme} onValueChange={setTheme}>
+ <Select
+ value={theme}
+ onValueChange={(value) => value && setTheme(value)}
+ >
<SelectTrigger className="!py-4">
<SelectValue placeholder="Select a theme" />
</SelectTrigger>
@@ -107,7 +110,10 @@ function RouteComponent() {
Choose your preferred task view mode
</p>
</div>
- <Select value={viewMode} onValueChange={setViewMode}>
+ <Select
+ value={viewMode}
+ onValueChange={(value) => value && setViewMode(value)}
+ >
<SelectTrigger className="!py-4">
<SelectValue placeholder="Select a view mode" />
</SelectTrigger>
diff --git a/apps/web/src/routes/invitation/accept.$inviteId.tsx b/apps/web/src/routes/invitation/accept.$inviteId.tsx
index 438dc6628..62ce1c302 100644
--- a/apps/web/src/routes/invitation/accept.$inviteId.tsx
+++ b/apps/web/src/routes/invitation/accept.$inviteId.tsx
@@ -110,7 +110,7 @@ function AcceptInvitation() {
<div className="flex items-center justify-center w-12 h-12 mx-auto bg-destructive/10 rounded-full">
<XCircle className="w-6 h-6 text-destructive" />
</div>
- <Alert variant="destructive">
+ <Alert variant="error">
<AlertCircle className="h-4 w-4" />
<AlertDescription>
Failed to load invitation details. The invitation may be invalid
diff --git a/apps/web/src/types/external-link/index.ts b/apps/web/src/types/external-link/index.ts
index 9f3ed949e..d18e581e9 100644
--- a/apps/web/src/types/external-link/index.ts
+++ b/apps/web/src/types/external-link/index.ts
@@ -18,13 +18,13 @@ export type ExternalLink = {
id: string;
taskId: string;
integrationId: string;
- resourceType: "issue" | "pull_request" | "branch";
+ resourceType: string;
externalId: string;
url: string;
title: string | null;
metadata: ExternalLinkMetadata | null;
- createdAt: string;
- updatedAt: string;
+ createdAt?: string;
+ updatedAt?: string;
integration?: {
id: string;
type: string;
diff --git a/apps/web/src/types/project/index.ts b/apps/web/src/types/project/index.ts
index b6e0a25f1..1086bee09 100644
--- a/apps/web/src/types/project/index.ts
+++ b/apps/web/src/types/project/index.ts
@@ -1,15 +1,29 @@
import type { client } from "@kaneo/libs";
import type { InferResponseType } from "hono/client";
+import type Task from "@/types/task";
export type Project = Extract<
InferResponseType<(typeof client)["project"][":id"]["$get"], 200>,
{ id: string }
>;
-export type ProjectWithTasks = Extract<
+type ProjectWithTasksRaw = Extract<
InferResponseType<
(typeof client)["task"]["tasks"][":projectId"]["$get"],
200
>,
{ id: string }
>;
+
+export type ProjectWithTasks = Omit<
+ ProjectWithTasksRaw,
+ "archivedTasks" | "columns" | "plannedTasks"
+> & {
+ archivedTasks: Task[];
+ columns: Array<
+ Omit<ProjectWithTasksRaw["columns"][number], "tasks"> & {
+ tasks: Task[];
+ }
+ >;
+ plannedTasks: Task[];
+};
diff --git a/apps/web/src/types/task/index.ts b/apps/web/src/types/task/index.ts
index c861de2b2..58f1c692b 100644
--- a/apps/web/src/types/task/index.ts
+++ b/apps/web/src/types/task/index.ts
@@ -1,11 +1,39 @@
-import type { client } from "@kaneo/libs";
-import type { InferResponseType } from "hono/client";
+type TaskLabel = {
+ id: string;
+ name: string;
+ color: string;
+};
-type Task = Extract<
- InferResponseType<
- (typeof client)["task"]["tasks"][":projectId"]["$get"]
- >["columns"][number]["tasks"][number],
- { id: string }
->;
+type TaskExternalLink = {
+ id: string;
+ taskId: string;
+ integrationId: string;
+ resourceType: string;
+ externalId: string;
+ url: string;
+ title: string | null;
+ metadata: Record<string, unknown> | null;
+};
+
+type Task = {
+ id: string;
+ title: string;
+ number: number | null;
+ description: string | null;
+ status: string;
+ priority: string | null;
+ dueDate: string | null;
+ position: number | null;
+ createdAt: string;
+ updatedAt?: string;
+ userId: string | null;
+ assigneeId: string | null;
+ assigneeName: string | null;
+ assigneeImage?: string | null;
+ projectId: string;
+ columnId?: string | null;
+ labels?: TaskLabel[];
+ externalLinks?: TaskExternalLink[];
+};
export default Task;