⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(api): restore the entitlement check on project creation
Andrej Acevskia581bdd2a2ca
diff --git a/apps/api/src/activity/response.ts b/apps/api/src/activity/response.tsindex 3b4c35cb0..174aef8cd 100644--- a/apps/api/src/activity/response.ts+++ b/apps/api/src/activity/response.ts@@ -3,8 +3,6 @@ import { responseTimestamp, z } from "../openapi";const activityTypeDescription ="One of: comment, task, create, status_changed, priority_changed, assignee_changed, unassigned, due_date_changed, title_changed, description_changed.";-// The raw activity row. Comments are activities with type `comment` and a-// non-null content, which is why comment mutations return this same shape.export const activitySchema = z.object({id: z.string(),diff --git a/apps/api/src/auth-openapi.ts b/apps/api/src/auth-openapi.tsindex 823775ada..500d75ea9 100644--- a/apps/api/src/auth-openapi.ts+++ b/apps/api/src/auth-openapi.ts@@ -2,14 +2,8 @@ import type { OpenAPIHono } from "@hono/zod-openapi";import { z } from "./openapi";// Better Auth serves /api/auth/* from its own handler, so these operations have-// no route of ours to hang documentation off. They are registered directly on-// the OpenAPI registry instead.-//-// This file is generated from Better Auth's own generateOpenAPISchema() output-// and then reviewed. Declaring it here replaced a runtime call to that-// generator plus ~200 lines of spec rewriting (operationId/summary/tag-// normalization, ref pruning, and a 3.1-to-3.0 downgrade). Regenerate and diff-// this file when upgrading Better Auth.+// no route of ours to document. Generated from its generateOpenAPISchema()+// output; regenerate and diff this file when upgrading Better Auth.export function organizationRoutes(registry: OpenAPIHono["openAPIRegistry"]) {registry.registerPath({method: "post",diff --git a/apps/api/src/billing/index.ts b/apps/api/src/billing/index.tsindex 56ae1031b..b466c5f91 100644--- a/apps/api/src/billing/index.ts+++ b/apps/api/src/billing/index.ts@@ -51,9 +51,7 @@ async function requireBillingManager(userId: string, workspaceId: string) {// Excluded from the app-wide auth middleware: authenticity comes from the// provider's webhook signature instead of a session.-// Billing is a Kaneo Cloud concern: on a self-hosted instance isBillingEnabled()-// is false and these routes report an always-active entitlement. They stay-// served, but `hide` keeps them out of the published OpenAPI document so the+// Kaneo Cloud only: still served, but kept out of the published document so the// self-hosted API reference does not advertise a paid tier that does not exist.const cloudOnly = { hide: true } as const;diff --git a/apps/api/src/column/schema.ts b/apps/api/src/column/schema.tsindex 30f32466c..f90125a2b 100644--- a/apps/api/src/column/schema.ts+++ b/apps/api/src/column/schema.ts@@ -11,8 +11,6 @@ export const createColumnBody = z.object({isFinal: z.boolean().optional(),});-// Every field is optional: omitting one leaves it unchanged, and icon and color-// accept null to clear them.export const updateColumnBody = z.object({name: z.string().optional(),icon: z.string().nullable().optional(),diff --git a/apps/api/src/comment/response.ts b/apps/api/src/comment/response.tsindex 01c2cb547..b1ca2c699 100644--- a/apps/api/src/comment/response.ts+++ b/apps/api/src/comment/response.ts@@ -1,7 +1,5 @@import { responseTimestamp, z } from "../openapi";-// The list route joins the author; the mutation routes return the raw activity-// row, which carries no author object. See activity/response.ts.export const commentSchema = z.object({id: z.string(),diff --git a/apps/api/src/config/response.ts b/apps/api/src/config/response.tsindex bd7b8bf2c..fde2ffb82 100644--- a/apps/api/src/config/response.ts+++ b/apps/api/src/config/response.ts@@ -1,7 +1,5 @@import { z } from "../openapi";-// getSettings() derives every flag from process.env with a boolean fallback, so-// none of these are nullable despite the previous schema saying so.export const configSchema = z.object({disableRegistration: z.boolean(),diff --git a/apps/api/src/discord-integration/index.ts b/apps/api/src/discord-integration/index.tsindex bd3e51e93..de8cad367 100644--- a/apps/api/src/discord-integration/index.ts+++ b/apps/api/src/discord-integration/index.ts@@ -2,18 +2,13 @@ import { and, eq } from "drizzle-orm";import { HTTPException } from "hono/http-exception";import db from "../database";import { integrationTable } from "../database/schema";-import {- deletedSchema,- integrationEventToggles,- projectIdParam,-} from "../integrations/schema";+import { deletedSchema, projectIdParam } from "../integrations/schema";import {apiRouter,type BaseVariables,createRoute,errorResponse,jsonResponse,- z,} from "../openapi";import {type DiscordConfig,@@ -24,6 +19,7 @@ import {import { requireWorkspacePermission } from "../utils/require-workspace-permission";import { workspaceAccess } from "../utils/workspace-access-middleware";import { discordIntegrationSchema } from "./response";+import { createDiscordBody, updateDiscordBody } from "./schema";function maskWebhookUrl(value: string): string {try {@@ -83,19 +79,6 @@ async function getDiscordIntegration(projectId: string) {return toResponse(integration);}-const createBody = z.object({- webhookUrl: z.string().min(1),- channelName: z.string().optional(),- events: integrationEventToggles.optional(),-});--const updateBody = z.object({- webhookUrl: z.string().optional(),- channelName: z.string().nullable().optional(),- isActive: z.boolean().optional(),- events: integrationEventToggles.optional(),-});-const manageAccess = [workspaceAccess.fromProject("projectId"),requireWorkspacePermission({ workspace: ["manage_settings"] }),@@ -136,7 +119,7 @@ const createDiscordIntegrationRoute = createRoute({params: projectIdParam,body: {required: true,- content: { "application/json": { schema: createBody } },+ content: { "application/json": { schema: createDiscordBody } },},},responses: {@@ -164,7 +147,7 @@ const updateDiscordIntegrationRoute = createRoute({params: projectIdParam,body: {required: true,- content: { "application/json": { schema: updateBody } },+ content: { "application/json": { schema: updateDiscordBody } },},},responses: {diff --git a/apps/api/src/discord-integration/schema.ts b/apps/api/src/discord-integration/schema.tsnew file mode 100644index 000000000..67d995861--- /dev/null+++ b/apps/api/src/discord-integration/schema.ts@@ -0,0 +1,15 @@+import { integrationEventToggles } from "../integrations/schema";+import { z } from "../openapi";++export const createDiscordBody = z.object({+ webhookUrl: z.string().min(1),+ channelName: z.string().optional(),+ events: integrationEventToggles.optional(),+});++export const updateDiscordBody = z.object({+ webhookUrl: z.string().optional(),+ channelName: z.string().nullable().optional(),+ isActive: z.boolean().optional(),+ events: integrationEventToggles.optional(),+});diff --git a/apps/api/src/generic-webhook-integration/index.ts b/apps/api/src/generic-webhook-integration/index.tsindex ac2866e92..47a77f9af 100644--- a/apps/api/src/generic-webhook-integration/index.ts+++ b/apps/api/src/generic-webhook-integration/index.ts@@ -2,18 +2,13 @@ import { and, eq } from "drizzle-orm";import { HTTPException } from "hono/http-exception";import db from "../database";import { integrationTable } from "../database/schema";-import {- deletedSchema,- genericWebhookEventToggles,- projectIdParam,-} from "../integrations/schema";+import { deletedSchema, projectIdParam } from "../integrations/schema";import {apiRouter,type BaseVariables,createRoute,errorResponse,jsonResponse,- z,} from "../openapi";import {defaultGenericWebhookEvents,@@ -24,6 +19,7 @@ import {import { requireWorkspacePermission } from "../utils/require-workspace-permission";import { workspaceAccess } from "../utils/workspace-access-middleware";import { genericWebhookIntegrationSchema } from "./response";+import { createWebhookBody, updateWebhookBody } from "./schema";function maskValue(value: string | undefined): string | null {if (!value) return null;@@ -76,32 +72,6 @@ async function getGenericWebhookIntegration(projectId: string) {return toResponse(integration);}-const leadTimeMinutes = z- .number()- .int()- .min(5)- .max(43_200)- .openapi({ description: "Between 5 minutes and 30 days." });--const createBody = z.object({- webhookUrl: z.string().min(1),- secret: z.string().optional().openapi({- description: "Optional HMAC secret used to sign outgoing deliveries.",- }),- events: genericWebhookEventToggles.optional(),- dueDateReminderLeadTimeMinutes: leadTimeMinutes.optional(),-});--const updateBody = z.object({- webhookUrl: z.string().optional(),- secret: z.string().nullable().optional().openapi({- description: "Send null to remove the signing secret.",- }),- isActive: z.boolean().optional(),- events: genericWebhookEventToggles.optional(),- dueDateReminderLeadTimeMinutes: leadTimeMinutes.optional(),-});-const manageAccess = [workspaceAccess.fromProject("projectId"),requireWorkspacePermission({ workspace: ["manage_settings"] }),@@ -142,7 +112,7 @@ const createGenericWebhookIntegrationRoute = createRoute({params: projectIdParam,body: {required: true,- content: { "application/json": { schema: createBody } },+ content: { "application/json": { schema: createWebhookBody } },},},responses: {@@ -170,7 +140,7 @@ const updateGenericWebhookIntegrationRoute = createRoute({params: projectIdParam,body: {required: true,- content: { "application/json": { schema: updateBody } },+ content: { "application/json": { schema: updateWebhookBody } },},},responses: {diff --git a/apps/api/src/generic-webhook-integration/response.ts b/apps/api/src/generic-webhook-integration/response.tsindex 8617eeb45..0d1ae2e9a 100644--- a/apps/api/src/generic-webhook-integration/response.ts+++ b/apps/api/src/generic-webhook-integration/response.ts@@ -1,8 +1,7 @@import { genericWebhookEventsSchema } from "../integrations/response";import { responseTimestamp, z } from "../openapi";-// Both the URL and the signing secret are credentials, so only masked forms-// are returned alongside a boolean saying whether each is set.+// Credentials are only ever returned masked, with a boolean saying if each is set.export const genericWebhookIntegrationSchema = z.object({id: z.string(),diff --git a/apps/api/src/generic-webhook-integration/schema.ts b/apps/api/src/generic-webhook-integration/schema.tsnew file mode 100644index 000000000..ebd5b5672--- /dev/null+++ b/apps/api/src/generic-webhook-integration/schema.ts@@ -0,0 +1,28 @@+import { genericWebhookEventToggles } from "../integrations/schema";+import { z } from "../openapi";++const leadTimeMinutes = z+ .number()+ .int()+ .min(5)+ .max(43_200)+ .openapi({ description: "Between 5 minutes and 30 days." });++export const createWebhookBody = z.object({+ webhookUrl: z.string().min(1),+ secret: z.string().optional().openapi({+ description: "Optional HMAC secret used to sign outgoing deliveries.",+ }),+ events: genericWebhookEventToggles.optional(),+ dueDateReminderLeadTimeMinutes: leadTimeMinutes.optional(),+});++export const updateWebhookBody = z.object({+ webhookUrl: z.string().optional(),+ secret: z.string().nullable().optional().openapi({+ description: "Send null to remove the signing secret.",+ }),+ isActive: z.boolean().optional(),+ events: genericWebhookEventToggles.optional(),+ dueDateReminderLeadTimeMinutes: leadTimeMinutes.optional(),+});diff --git a/apps/api/src/gitea-integration/index.ts b/apps/api/src/gitea-integration/index.tsindex 8d00b12f9..b68cffe3e 100644--- a/apps/api/src/gitea-integration/index.ts+++ b/apps/api/src/gitea-integration/index.ts@@ -11,7 +11,6 @@ import {createRoute,errorResponse,jsonResponse,- z,} from "../openapi";import { type GiteaConfig, validateGiteaConfig } from "../plugins/gitea/config";import { handleGiteaWebhookRequest } from "../plugins/gitea/webhook-handler";@@ -32,41 +31,20 @@ import {giteaIntegrationSchema,giteaRepositoryListSchema,giteaVerificationResultSchema,+ integrationNotFoundSchema,} from "./response";+import {+ createGiteaBody,+ listGiteaRepositoriesBody,+ updateGiteaBody,+ verifyGiteaBody,+} from "./schema";const manageAccess = [workspaceAccess.fromProject("projectId"),requireWorkspacePermission({ workspace: ["manage_settings"] }),];-const giteaCredentials = {- projectId: z.string().min(1),- baseUrl: z.url(),- accessToken: z.string().min(1),-};--const listRepositoriesBody = z.object(giteaCredentials);--const verifyBody = z.object({- ...giteaCredentials,- repositoryOwner: z.string().min(1),- repositoryName: z.string().min(1),-});--const createBody = z.object({- baseUrl: z.string().min(1),- accessToken: z.string().optional().openapi({- description: "Omit to keep the token already stored for this project.",- }),- repositoryOwner: z.string().min(1),- repositoryName: z.string().min(1),-});--const updateBody = z.object({- isActive: z.boolean().optional(),- commentTaskLinkOnGiteaIssue: z.boolean().optional(),-});-const listRepositoriesRoute = createRoute({method: "post",operationId: "listGiteaRepositories",@@ -79,7 +57,7 @@ const listRepositoriesRoute = createRoute({request: {body: {required: true,- content: { "application/json": { schema: listRepositoriesBody } },+ content: { "application/json": { schema: listGiteaRepositoriesBody } },},},responses: {@@ -103,7 +81,7 @@ const verifyRoute = createRoute({request: {body: {required: true,- content: { "application/json": { schema: verifyBody } },+ content: { "application/json": { schema: verifyGiteaBody } },},},responses: {@@ -150,7 +128,7 @@ const createIntegrationRoute = createRoute({params: projectIdParam,body: {required: true,- content: { "application/json": { schema: createBody } },+ content: { "application/json": { schema: createGiteaBody } },},},responses: {@@ -175,7 +153,7 @@ const updateIntegrationRoute = createRoute({params: projectIdParam,body: {required: true,- content: { "application/json": { schema: updateBody } },+ content: { "application/json": { schema: updateGiteaBody } },},},responses: {@@ -184,7 +162,7 @@ const updateIntegrationRoute = createRoute({403: errorResponse("No workspace access, or missing workspace:manage_settings",),- 404: jsonResponse("Integration not found", z.object({ error: z.string() })),+ 404: jsonResponse("Integration not found", integrationNotFoundSchema),},});diff --git a/apps/api/src/gitea-integration/response.ts b/apps/api/src/gitea-integration/response.tsindex 1cba1afdb..f88c8f9e8 100644--- a/apps/api/src/gitea-integration/response.ts+++ b/apps/api/src/gitea-integration/response.ts@@ -1,7 +1,7 @@import { responseTimestamp, z } from "../openapi";-// The access token is a credential, so only a masked form is returned. The-// webhook secret is included only for callers holding workspace:manage_settings.+// Credentials are only ever returned masked; the webhook secret goes only to+// callers holding workspace:manage_settings.export const giteaIntegrationSchema = z.object({id: z.string(),@@ -79,3 +79,7 @@ export const giteaImportResultSchema = zexport const giteaDeleteResultSchema = z.object({ success: z.boolean(), message: z.string() }).openapi("GiteaDeleteResult");++export const integrationNotFoundSchema = z+ .object({ error: z.string() })+ .openapi("GiteaIntegrationNotFound");diff --git a/apps/api/src/gitea-integration/schema.ts b/apps/api/src/gitea-integration/schema.tsnew file mode 100644index 000000000..fcbfa0cbc--- /dev/null+++ b/apps/api/src/gitea-integration/schema.ts@@ -0,0 +1,29 @@+import { z } from "../openapi";++const giteaCredentials = {+ projectId: z.string().min(1),+ baseUrl: z.url(),+ accessToken: z.string().min(1),+};++export const listGiteaRepositoriesBody = z.object(giteaCredentials);++export const verifyGiteaBody = z.object({+ ...giteaCredentials,+ repositoryOwner: z.string().min(1),+ repositoryName: z.string().min(1),+});++export const createGiteaBody = z.object({+ baseUrl: z.string().min(1),+ accessToken: z.string().optional().openapi({+ description: "Omit to keep the token already stored for this project.",+ }),+ repositoryOwner: z.string().min(1),+ repositoryName: z.string().min(1),+});++export const updateGiteaBody = z.object({+ isActive: z.boolean().optional(),+ commentTaskLinkOnGiteaIssue: z.boolean().optional(),+});diff --git a/apps/api/src/github-integration/index.ts b/apps/api/src/github-integration/index.tsindex f7c90d99a..4bd3dd9fa 100644--- a/apps/api/src/github-integration/index.ts+++ b/apps/api/src/github-integration/index.ts@@ -11,7 +11,6 @@ import {createRoute,errorResponse,jsonResponse,- z,} from "../openapi";import {type GitHubConfig,@@ -33,31 +32,16 @@ import {githubIntegrationSchema,githubRepositoryListSchema,importResultSchema,+ integrationNotFoundSchema,verificationResultSchema,} from "./response";+import { createGitHubBody, updateGitHubBody, verifyGitHubBody } from "./schema";const manageAccess = [workspaceAccess.fromProject("projectId"),requireWorkspacePermission({ workspace: ["manage_settings"] }),];-const repositoryRef = {- repositoryOwner: z.string().min(1),- repositoryName: z.string().min(1),-};--const verifyBody = z.object({- projectId: z.string().min(1),- ...repositoryRef,-});--const createBody = z.object(repositoryRef);--const updateBody = z.object({- isActive: z.boolean().optional(),- commentTaskLinkOnGitHubIssue: z.boolean().optional(),-});-const getAppInfoRoute = createRoute({method: "get",operationId: "getGitHubAppInfo",@@ -107,7 +91,7 @@ const verifyRoute = createRoute({request: {body: {required: true,- content: { "application/json": { schema: verifyBody } },+ content: { "application/json": { schema: verifyGitHubBody } },},},responses: {@@ -153,7 +137,7 @@ const createIntegrationRoute = createRoute({params: projectIdParam,body: {required: true,- content: { "application/json": { schema: createBody } },+ content: { "application/json": { schema: createGitHubBody } },},},responses: {@@ -178,7 +162,7 @@ const updateIntegrationRoute = createRoute({params: projectIdParam,body: {required: true,- content: { "application/json": { schema: updateBody } },+ content: { "application/json": { schema: updateGitHubBody } },},},responses: {@@ -190,7 +174,7 @@ const updateIntegrationRoute = createRoute({403: errorResponse("No workspace access, or missing workspace:manage_settings",),- 404: jsonResponse("Integration not found", z.object({ error: z.string() })),+ 404: jsonResponse("Integration not found", integrationNotFoundSchema),},});diff --git a/apps/api/src/github-integration/response.ts b/apps/api/src/github-integration/response.tsindex 8694ad5db..c3b022f66 100644--- a/apps/api/src/github-integration/response.ts+++ b/apps/api/src/github-integration/response.ts@@ -76,8 +76,6 @@ export const githubInstallationSchema = z}).openapi("GitHubInstallation");-// The previous spec described this route as returning a bare repository array;-// it has always returned this envelope.export const githubRepositoryListSchema = z.object({repositories: z.array(githubRepositorySchema).openapi({@@ -125,9 +123,6 @@ export const importResultSchema = z}).openapi("IssueImportResult");-// createGithubIntegration assembles its result from the inserted row, whose-// fields TypeScript cannot prove are present, so the create route reports the-// looser shape rather than claiming a guarantee the code does not make.export const createdGithubIntegrationSchema = githubIntegrationSchema.partial({id: true,@@ -138,8 +133,10 @@ export const createdGithubIntegrationSchema = githubIntegrationSchema}).openapi("CreatedGitHubIntegration");-// The delete route returns a plain acknowledgement, not the removed row ---// the previous spec described it as returning the integration.export const deleteResultSchema = z.object({ success: z.boolean(), message: z.string() }).openapi("GitHubDeleteResult");++export const integrationNotFoundSchema = z+ .object({ error: z.string() })+ .openapi("GitHubIntegrationNotFound");diff --git a/apps/api/src/github-integration/schema.ts b/apps/api/src/github-integration/schema.tsnew file mode 100644index 000000000..c38ae7fc1--- /dev/null+++ b/apps/api/src/github-integration/schema.ts@@ -0,0 +1,18 @@+import { z } from "../openapi";++const repositoryRef = {+ repositoryOwner: z.string().min(1),+ repositoryName: z.string().min(1),+};++export const verifyGitHubBody = z.object({+ projectId: z.string().min(1),+ ...repositoryRef,+});++export const createGitHubBody = z.object(repositoryRef);++export const updateGitHubBody = z.object({+ isActive: z.boolean().optional(),+ commentTaskLinkOnGitHubIssue: z.boolean().optional(),+});diff --git a/apps/api/src/integrations/middleware.ts b/apps/api/src/integrations/middleware.tsindex fe356773f..389fa368f 100644--- a/apps/api/src/integrations/middleware.ts+++ b/apps/api/src/integrations/middleware.ts@@ -5,9 +5,7 @@ import db from "../database";import { projectTable } from "../database/schema";import { validateWorkspaceAccess } from "../utils/validate-workspace-access";-// Scopes the request to the workspace owning the projectId in the JSON body.-// Route middleware runs before the request validators, so this reads the raw-// body rather than c.req.valid("json"), which is not populated yet.+// Route middleware runs before the validators, so c.req.valid() is unavailable.export async function scopeToProjectFromBody(c: Context, next: Next) {const userId = c.get("userId");if (!userId) {diff --git a/apps/api/src/integrations/response.ts b/apps/api/src/integrations/response.tsindex bbe9a2dde..93edced3d 100644--- a/apps/api/src/integrations/response.ts+++ b/apps/api/src/integrations/response.ts@@ -1,8 +1,5 @@import { z } from "../openapi";-// Which task events a chat/webhook integration forwards. Every integration-// stores the full set with defaults applied, so none of these are optional on-// the way out.export const integrationEventsSchema = z.object({taskCreated: z.boolean(),diff --git a/apps/api/src/integrations/schema.ts b/apps/api/src/integrations/schema.tsindex 9fead5ed5..5d436ea58 100644--- a/apps/api/src/integrations/schema.ts+++ b/apps/api/src/integrations/schema.ts@@ -2,7 +2,6 @@ import { z } from "../openapi";export const projectIdParam = z.object({ projectId: z.string() });-// On the way in every toggle is optional: omitted ones keep their current value.export const integrationEventToggles = z.object({taskCreated: z.boolean().optional(),taskStatusChanged: z.boolean().optional(),diff --git a/apps/api/src/notification-preferences/index.ts b/apps/api/src/notification-preferences/index.tsindex 249e7d9e6..0cef14c1e 100644--- a/apps/api/src/notification-preferences/index.ts+++ b/apps/api/src/notification-preferences/index.ts@@ -17,8 +17,6 @@ import {upsertWorkspaceRule,} from "./service";-// Every route returns the full preference document, so a client never has to-// re-fetch after a write.const preferencesResponse = (description: string) =>jsonResponse(description, notificationPreferenceSchema);diff --git a/apps/api/src/notification-preferences/response.ts b/apps/api/src/notification-preferences/response.tsindex 8ce70d48f..8b7771625 100644--- a/apps/api/src/notification-preferences/response.ts+++ b/apps/api/src/notification-preferences/response.ts@@ -1,8 +1,6 @@import { nullableResponseTimestamp, responseTimestamp, z } from "../openapi";-// Secrets are never returned. Each one is reported as a *Configured boolean-// plus a masked preview, so a client can show that a value is set without-// being able to read it.+// Secrets are never returned: each is a *Configured boolean plus a masked preview.export const workspaceRuleSchema = z.object({id: z.string(),diff --git a/apps/api/src/notification-preferences/schema.ts b/apps/api/src/notification-preferences/schema.tsindex 27338146f..7c10f2d5c 100644--- a/apps/api/src/notification-preferences/schema.ts+++ b/apps/api/src/notification-preferences/schema.ts@@ -2,8 +2,7 @@ import { z } from "../openapi";export const workspaceIdParam = z.object({ workspaceId: z.string() });-// Write-only secret fields: send a value to set it, null to clear it, omit to-// leave it untouched. They are never echoed back.+// Secrets are write-only: a value sets it, null clears it, omitting leaves it.export const updatePreferencesBody = z.object({emailEnabled: z.boolean().optional(),ntfyEnabled: z.boolean().optional(),diff --git a/apps/api/src/openapi.ts b/apps/api/src/openapi.tsindex b1832374e..47051ae1f 100644--- a/apps/api/src/openapi.ts+++ b/apps/api/src/openapi.ts@@ -20,13 +20,8 @@ export type BaseVariables = {apiKey?: ApiKey;};-// NOTE: routes declare auth/access middleware via createRoute({ middleware }),-// which @hono/zod-openapi registers BEFORE the request validators (index.mjs:147-// -- `this.on(method, path, ...middleware, ...validators, handler)`). The-// hono-openapi routes this replaces listed validator() first, so a malformed-// body used to be rejected before any authorization ran. Order is now-// authorize-then-validate: an unauthorized caller gets 403 instead of 400 and-// no longer learns whether their body was well-formed.+// createRoute({ middleware }) registers middleware BEFORE the request+// validators, so middleware must read the raw request, not c.req.valid().export function apiRouter<V extends BaseVariables = BaseVariables>() {return new OpenAPIHono<{ Variables: V }>({defaultHook: (result) => {@@ -51,14 +46,8 @@ export const nullableResponseTimestamp = responseTimestamp.nullable().openapi({ type: ["string", "null"], format: "date-time" });-// HTTPException bodies are the plain message string (Hono's default-// getResponse()), which every web fetcher reads with response.text().-//-// Declaring any non-2xx response puts it in the route's typed-response union,-// so an untagged InferResponseType<typeof client.x.$get> on the frontend widens-// from `Label` to `Label | string`. Tag the status instead ---// InferResponseType<typeof client.x.$get, 200> -- as src/types/project already-// does. Fetchers that narrow on `response.ok` before .json() are unaffected.+// Declaring a non-2xx response widens an untagged InferResponseType on the+// frontend, so those call sites must tag the status: InferResponseType<T, 200>.export function errorResponse(description: string) {return {description,diff --git a/apps/api/src/project/index.ts b/apps/api/src/project/index.tsindex d2e058834..b0228f14e 100644--- a/apps/api/src/project/index.ts+++ b/apps/api/src/project/index.ts@@ -1,3 +1,4 @@+import { requireEntitlement } from "../billing/require-entitlement-middleware";import {apiRouter,type BaseVariables,@@ -54,6 +55,7 @@ const createProjectRoute = createRoute({middleware: [workspaceAccess.fromBody(),requireWorkspacePermission({ project: ["create"] }),+ requireEntitlement,] as const,request: {body: {diff --git a/apps/api/src/project/response.ts b/apps/api/src/project/response.tsindex 6d2920ae8..b1dea62a1 100644--- a/apps/api/src/project/response.ts+++ b/apps/api/src/project/response.ts@@ -38,13 +38,10 @@ export const projectStatisticsSchema = z}).openapi("ProjectStatistics");-// The list route enriches each project with rollup statistics. The three empty-// arrays are retained for clients that still read them; they are never filled.export const projectListItemSchema = projectSchema.extend({statistics: projectStatisticsSchema,- // Legacy fields kept for clients that still read them. The list route- // always returns them empty; fetch the board via GET /task/tasks/{id}.+ // Legacy, always empty. Fetch the board via GET /task/tasks/{id}.archivedTasks: z.array(boardTaskSchema).openapi({ description: "Always empty." }),diff --git a/apps/api/src/search/schema.ts b/apps/api/src/search/schema.tsindex bf044c2fd..34da835b0 100644--- a/apps/api/src/search/schema.ts+++ b/apps/api/src/search/schema.ts@@ -8,7 +8,6 @@ export const searchQuery = z.object({.default("all"),workspaceId: z.string().min(1),projectId: z.string().optional(),- // Query strings arrive as text; keep the wire type honest and coerce after.limit: z.string().optional()diff --git a/apps/api/src/slack-integration/index.ts b/apps/api/src/slack-integration/index.tsindex 1e24e3ae8..2b4f16057 100644--- a/apps/api/src/slack-integration/index.ts+++ b/apps/api/src/slack-integration/index.ts@@ -2,18 +2,13 @@ import { and, eq } from "drizzle-orm";import { HTTPException } from "hono/http-exception";import db from "../database";import { integrationTable } from "../database/schema";-import {- deletedSchema,- integrationEventToggles,- projectIdParam,-} from "../integrations/schema";+import { deletedSchema, projectIdParam } from "../integrations/schema";import {apiRouter,type BaseVariables,createRoute,errorResponse,jsonResponse,- z,} from "../openapi";import {defaultSlackEvents,@@ -24,6 +19,7 @@ import {import { requireWorkspacePermission } from "../utils/require-workspace-permission";import { workspaceAccess } from "../utils/workspace-access-middleware";import { slackIntegrationSchema } from "./response";+import { createSlackBody, updateSlackBody } from "./schema";function maskWebhookUrl(value: string): string {try {@@ -81,19 +77,6 @@ async function getSlackIntegration(projectId: string) {return toResponse(integration);}-const createBody = z.object({- webhookUrl: z.string().min(1),- channelName: z.string().optional(),- events: integrationEventToggles.optional(),-});--const updateBody = z.object({- webhookUrl: z.string().optional(),- channelName: z.string().nullable().optional(),- isActive: z.boolean().optional(),- events: integrationEventToggles.optional(),-});-const manageAccess = [workspaceAccess.fromProject("projectId"),requireWorkspacePermission({ workspace: ["manage_settings"] }),@@ -134,7 +117,7 @@ const createSlackIntegrationRoute = createRoute({params: projectIdParam,body: {required: true,- content: { "application/json": { schema: createBody } },+ content: { "application/json": { schema: createSlackBody } },},},responses: {@@ -162,7 +145,7 @@ const updateSlackIntegrationRoute = createRoute({params: projectIdParam,body: {required: true,- content: { "application/json": { schema: updateBody } },+ content: { "application/json": { schema: updateSlackBody } },},},responses: {diff --git a/apps/api/src/slack-integration/schema.ts b/apps/api/src/slack-integration/schema.tsnew file mode 100644index 000000000..877b836ef--- /dev/null+++ b/apps/api/src/slack-integration/schema.ts@@ -0,0 +1,15 @@+import { integrationEventToggles } from "../integrations/schema";+import { z } from "../openapi";++export const createSlackBody = z.object({+ webhookUrl: z.string().min(1),+ channelName: z.string().optional(),+ events: integrationEventToggles.optional(),+});++export const updateSlackBody = z.object({+ webhookUrl: z.string().optional(),+ channelName: z.string().nullable().optional(),+ isActive: z.boolean().optional(),+ events: integrationEventToggles.optional(),+});diff --git a/apps/api/src/task-relation/response.ts b/apps/api/src/task-relation/response.tsindex 053937fc3..51205b47a 100644--- a/apps/api/src/task-relation/response.ts+++ b/apps/api/src/task-relation/response.ts@@ -3,7 +3,6 @@ import { responseTimestamp, z } from "../openapi";const relationTypeDescription ="How the two tasks relate: `subtask`, `blocks`, or `related`.";-// The joined task summary, restricted to the caller's workspace.const relatedTaskSchema = z.object({id: z.string(),@@ -27,9 +26,8 @@ export const taskRelationSchema = z}).openapi("TaskRelation");-// getTaskRelations drops any relation whose endpoints are not both visible in-// the workspace, so in practice these are always present; they stay nullable-// because the lookup itself is a map read.+// Always present in practice: relations whose endpoints are not both visible in+// the workspace are dropped. Nullable only because the lookup is a map read.export const taskRelationWithTasksSchema = taskRelationSchema.extend({sourceTask: relatedTaskSchema.nullable(),diff --git a/apps/api/src/task/controllers/require-task-permission.ts b/apps/api/src/task/controllers/require-task-permission.tsindex a3607a41b..df99af8cb 100644--- a/apps/api/src/task/controllers/require-task-permission.ts+++ b/apps/api/src/task/controllers/require-task-permission.ts@@ -25,9 +25,7 @@ const BULK_OPERATIONS: readonly BulkTaskOperation[] = ["updateDueDate",];-// These run as route middleware, which @hono/zod-openapi registers before the-// request validators, so c.req.valid() is not populated yet. Read the raw body-// instead. The validator still rejects a malformed body immediately after.+// Route middleware runs before the validators, so c.req.valid() is unavailable.async function readJsonBody(c: Context): Promise<Record<string, unknown>> {const raw = (await c.req.json().catch(() => ({}))) as unknown;if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {diff --git a/apps/api/src/task/response.ts b/apps/api/src/task/response.tsindex bd9738417..c0afb0037 100644--- a/apps/api/src/task/response.ts+++ b/apps/api/src/task/response.ts@@ -22,15 +22,12 @@ export const taskSchema = zdescription: "The slug of the column the task sits in.",}),priority: z.string().openapi({ description: priorityDescription }),- // Nullable, not optional: the columns are always selected and may be null.startDate: nullableResponseTimestamp,dueDate: nullableResponseTimestamp,createdAt: responseTimestamp,}).openapi("Task");-// The single-task route joins the assignee; the list/board route returns the-// richer BoardTask below.export const taskWithAssigneeSchema = taskSchema.extend({assigneeName: z.string().nullable(),@@ -60,7 +57,6 @@ const taskExternalLinkSchema = z}).openapi("TaskExternalLink");-// The board task carries the joined assignee and the task's labels and links.export const boardTaskSchema = z.object({id: z.string(),@@ -94,7 +90,6 @@ export const boardColumnSchema = z}).openapi("BoardColumn");-// listTasks returns the project's board, not a flat task list.export const boardSchema = z.object({data: zdiff --git a/apps/api/src/task/schema.ts b/apps/api/src/task/schema.tsindex 1847a7a0e..2d518fc18 100644--- a/apps/api/src/task/schema.ts+++ b/apps/api/src/task/schema.ts@@ -7,13 +7,11 @@ export const projectIdParam = z.object({ projectId: z.string() });const priority = z.enum(VALID_PRIORITIES);-// Every filter is optional; the outer object is required so it can be a-// RouteParameter, and the handler treats an empty object as "no filters".+// Required object of optional filters: a RouteParameter cannot itself be optional.export const listTasksQuery = z.object({status: z.string().optional(),priority: z.string().optional(),assigneeId: z.string().optional(),- // Query strings arrive as text; both are coerced after validation.page: z.string().optional()diff --git a/apps/api/src/telegram-integration/schema.ts b/apps/api/src/telegram-integration/schema.tsindex 62d4c380b..75c2a3abe 100644--- a/apps/api/src/telegram-integration/schema.ts+++ b/apps/api/src/telegram-integration/schema.ts@@ -11,8 +11,7 @@ export const createTelegramBody = z.object({events: integrationEventToggles.optional(),});-// Mirrors telegramIntegrationPatchBodySchema in controllers/telegram-controller,-// which still types buildNextTelegramConfigFromPatch.+// Must match TelegramIntegrationPatchBody in controllers/telegram-controller.export const updateTelegramBody = z.object({botToken: z.string().optional(),chatId: z.string().optional(),diff --git a/apps/api/src/workflow-rule/response.ts b/apps/api/src/workflow-rule/response.tsindex 9ca863d38..3a5f6bb48 100644--- a/apps/api/src/workflow-rule/response.ts+++ b/apps/api/src/workflow-rule/response.ts@@ -1,7 +1,5 @@import { responseTimestamp, z } from "../openapi";-// getWorkflowRules left-joins the column, so the column fields are null when-// the referenced column has been removed.export const workflowRuleSchema = z.object({id: z.string(),@@ -25,7 +23,6 @@ export const workflowRuleSchema = zexport const workflowRuleListSchema = z.array(workflowRuleSchema);-// Upsert and delete return the raw row, without the joined column fields.export const workflowRuleRowSchema = z.object({id: z.string(),diff --git a/apps/docs/openapi.json b/apps/docs/openapi.jsonindex bfecd5329..93958fc4f 100644--- a/apps/docs/openapi.json+++ b/apps/docs/openapi.json@@ -2052,6 +2052,17 @@"installationId"]},+ "GitHubIntegrationNotFound": {+ "type": "object",+ "properties": {+ "error": {+ "type": "string"+ }+ },+ "required": [+ "error"+ ]+ },"GitHubDeleteResult": {"type": "object","properties": {@@ -2264,6 +2275,17 @@"updatedAt"]},+ "GiteaIntegrationNotFound": {+ "type": "object",+ "properties": {+ "error": {+ "type": "string"+ }+ },+ "required": [+ "error"+ ]+ },"GiteaDeleteResult": {"type": "object","properties": {@@ -10240,15 +10262,7 @@"content": {"application/json": {"schema": {- "type": "object",- "properties": {- "error": {- "type": "string"- }- },- "required": [- "error"- ]+ "$ref": "#/components/schemas/GitHubIntegrationNotFound"}}}@@ -10764,15 +10778,7 @@"content": {"application/json": {"schema": {- "type": "object",- "properties": {- "error": {- "type": "string"- }- },- "required": [- "error"- ]+ "$ref": "#/components/schemas/GiteaIntegrationNotFound"}}}