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.

feat: enhance GitHub issue and pull request handling matching

Andrej Acevski660e0265dbc9
diff --git a/apps/api/src/github-integration/controllers/import-issues.ts b/apps/api/src/github-integration/controllers/import-issues.ts
index 7ae8c9aec..d7a02d330 100644
--- a/apps/api/src/github-integration/controllers/import-issues.ts
+++ b/apps/api/src/github-integration/controllers/import-issues.ts
@@ -1,28 +1,76 @@
-import { createId } from "@paralleldrive/cuid2";
import { and, eq } from "drizzle-orm";
+import { HTTPException } from "hono/http-exception";
import db from "../../database";
import {
activityTable,
- externalLinkTable,
integrationTable,
labelTable,
+ projectTable,
taskTable,
} from "../../database/schema";
+import type { GitHubConfig } from "../../plugins/github/config";
import {
createExternalLink,
findExternalLink,
} from "../../plugins/github/services/link-manager";
+import { findTaskByNumber } from "../../plugins/github/services/task-service";
+import { extractTaskNumber } from "../../plugins/github/utils/branch-matcher";
import {
extractIssuePriority,
extractIssueStatus,
} from "../../plugins/github/utils/extract-priority";
-import { getGithubApp } from "../../plugins/github/utils/github-app";
+import { formatTaskDescriptionFromIssue } from "../../plugins/github/utils/format";
+import { getInstallationOctokit } from "../../plugins/github/utils/github-app";
+import getNextTaskNumber from "../../task/controllers/get-next-task-number";
+
+type ImportResult = {
+ imported: number;
+ updated: number;
+ skipped: number;
+ errors?: string[];
+};
+
+type GitHubIssue = {
+ number: number;
+ title: string;
+ body: string | null;
+ html_url: string;
+ state: string;
+ labels: Array<{ name?: string; color?: string } | string>;
+ user: { login: string; avatar_url: string } | null;
+ pull_request?: unknown;
+};
+
+type GitHubComment = {
+ id: number;
+ body: string;
+ html_url: string;
+ user: { login: string; avatar_url: string } | null;
+ created_at: string;
+};
+
+type GitHubPullRequest = {
+ number: number;
+ title: string;
+ body: string | null;
+ html_url: string;
+ state: string;
+ head: { ref: string };
+ user: { login: string; avatar_url: string } | null;
+};
+
+export async function importIssues(projectId: string): Promise<ImportResult> {
+ const errors: string[] = [];
+ let imported = 0;
+ let updated = 0;
+ let skipped = 0;
-export async function importIssues(projectId: string) {
- const githubApp = getGithubApp();
+ const project = await db.query.projectTable.findFirst({
+ where: eq(projectTable.id, projectId),
+ });
- if (!githubApp) {
- return { error: "GitHub app not configured" };
+ if (!project) {
+ throw new HTTPException(404, { message: "Project not found" });
}
const integration = await db.query.integrationTable.findFirst({
@@ -33,232 +81,361 @@ export async function importIssues(projectId: string) {
});
if (!integration) {
- return { error: "GitHub integration not found" };
+ throw new HTTPException(404, { message: "GitHub integration not found" });
}
- const config = JSON.parse(integration.config) as {
- repositoryOwner: string;
- repositoryName: string;
- installationId: number | null;
- };
-
- if (!config.installationId) {
- return { error: "GitHub installation not found" };
+ if (!integration.isActive) {
+ throw new HTTPException(400, {
+ message: "GitHub integration is not active",
+ });
}
- // Get project with workspace ID for label association
- const project = await db.query.projectTable.findFirst({
- where: eq(db._.fullSchema.projectTable.id, projectId),
- with: {
- workspace: true,
- },
- });
+ const config = JSON.parse(integration.config) as GitHubConfig;
- if (!project) {
- return { error: "Project not found" };
+ if (!config.installationId) {
+ throw new HTTPException(400, {
+ message: "GitHub installation ID not configured",
+ });
}
- const installationOctokit = await githubApp.getInstallationOctokit(
- config.installationId,
- );
+ const octokit = await getInstallationOctokit(config.installationId);
- let imported = 0;
- let skipped = 0;
+ const allIssues: GitHubIssue[] = [];
let page = 1;
const perPage = 100;
- // Paginate through all issues (open and closed)
while (true) {
- const { data: issues } = await installationOctokit.rest.issues.listForRepo({
+ const { data: issues } = await octokit.rest.issues.listForRepo({
owner: config.repositoryOwner,
repo: config.repositoryName,
- state: "all", // Import both open and closed issues
+ state: "open",
per_page: perPage,
page,
});
- // No more issues, break
- if (!issues || issues.length === 0) {
- break;
- }
+ if (issues.length === 0) break;
+
+ const issuesOnly = issues.filter(
+ (issue) => !issue.pull_request,
+ ) as GitHubIssue[];
+ allIssues.push(...issuesOnly);
+
+ if (issues.length < perPage) break;
+ page++;
+ }
+
+ for (const issue of allIssues) {
+ try {
+ const result = await importSingleIssue(
+ issue,
+ integration.id,
+ projectId,
+ project.workspaceId,
+ config,
+ octokit,
+ );
- for (const issue of issues) {
- // Skip pull requests
- if (issue.pull_request) {
+ if (result === "imported") {
+ imported++;
+ } else if (result === "updated") {
+ updated++;
+ } else {
skipped++;
- continue;
}
+ } catch (error) {
+ const errorMessage =
+ error instanceof Error ? error.message : String(error);
+ errors.push(`Issue #${issue.number}: ${errorMessage}`);
+ }
+ }
+
+ const allPRs: GitHubPullRequest[] = [];
+ page = 1;
- const existingLink = await findExternalLink(
+ while (true) {
+ const { data: pulls } = await octokit.rest.pulls.list({
+ owner: config.repositoryOwner,
+ repo: config.repositoryName,
+ state: "open",
+ per_page: perPage,
+ page,
+ });
+
+ if (pulls.length === 0) break;
+
+ allPRs.push(...(pulls as GitHubPullRequest[]));
+
+ if (pulls.length < perPage) break;
+ page++;
+ }
+
+ for (const pr of allPRs) {
+ try {
+ await linkPullRequestToTask(
+ pr,
integration.id,
- "issue",
- issue.number.toString(),
+ projectId,
+ project.slug,
+ config,
);
+ } catch (error) {
+ const errorMessage =
+ error instanceof Error ? error.message : String(error);
+ errors.push(`PR #${pr.number}: ${errorMessage}`);
+ }
+ }
- if (existingLink) {
- const taskExists = await db.query.taskTable.findFirst({
- where: eq(taskTable.id, existingLink.taskId),
- });
+ return {
+ imported,
+ updated,
+ skipped,
+ ...(errors.length > 0 ? { errors } : {}),
+ };
+}
- if (taskExists) {
- skipped++;
- continue;
- }
+async function importSingleIssue(
+ issue: GitHubIssue,
+ integrationId: string,
+ projectId: string,
+ workspaceId: string,
+ config: GitHubConfig,
+ octokit: Awaited<ReturnType<typeof getInstallationOctokit>>,
+): Promise<"imported" | "updated" | "skipped"> {
+ const existingLink = await findExternalLink(
+ integrationId,
+ "issue",
+ issue.number.toString(),
+ );
- await db
- .delete(externalLinkTable)
- .where(eq(externalLinkTable.id, existingLink.id));
- }
+ const priority = extractIssuePriority(issue.labels);
+ const status = extractIssueStatus(issue.labels);
- const priority = extractIssuePriority(issue.labels);
- const statusFromLabels = extractIssueStatus(issue.labels);
-
- const taskStatus =
- issue.state === "closed" ? "done" : statusFromLabels || "to-do";
-
- const [newTask] = await db
- .insert(taskTable)
- .values({
- title: issue.title,
- description: issue.body || null,
- projectId,
- number: issue.number,
- status: taskStatus,
- priority: priority || "no-priority",
- position: 0,
- createdAt: new Date(issue.created_at),
- })
- .returning();
-
- if (!newTask) {
- continue;
- }
+ if (existingLink) {
+ const updateData: Record<string, unknown> = {
+ title: issue.title,
+ description: formatTaskDescriptionFromIssue(issue.body),
+ };
- // Create external link
- await createExternalLink({
- taskId: newTask.id,
- integrationId: integration.id,
- resourceType: "issue",
- externalId: issue.number.toString(),
- url: issue.html_url,
- title: issue.title,
- metadata: {
- state: issue.state,
- importedFrom: "github",
- author: issue.user?.login,
- },
- });
-
- // Import labels
- if (issue.labels && issue.labels.length > 0) {
- for (const label of issue.labels) {
- const labelName = typeof label === "string" ? label : label?.name;
- const labelColor = typeof label === "string" ? null : label?.color;
-
- if (!labelName) {
- continue;
- }
-
- // Skip system labels (already applied to task fields)
- const isSystemLabel =
- labelName.startsWith("priority:") ||
- labelName.startsWith("status:");
-
- if (isSystemLabel) {
- continue;
- }
-
- // Create label with both workspace and task association
- const color = labelColor ? `#${labelColor}` : "#6B7280";
- await db.insert(labelTable).values({
- name: labelName,
- color,
- taskId: newTask.id,
- workspaceId: project.workspaceId,
- });
- }
- }
+ if (priority) updateData.priority = priority;
+ if (status) updateData.status = status;
- // Import comments
- const { data: comments } =
- await installationOctokit.rest.issues.listComments({
- owner: config.repositoryOwner,
- repo: config.repositoryName,
- issue_number: issue.number,
- per_page: 100, // GitHub max
- });
-
- if (comments && comments.length > 0) {
- for (const comment of comments) {
- if (comment.user?.login.endsWith("[bot]")) {
- continue;
- }
-
- await db.insert(activityTable).values({
- id: createId(),
- taskId: newTask.id,
- type: "comment",
- content: comment.body,
- externalUserName: comment.user?.login || "Unknown",
- externalUserAvatar: comment.user?.avatar_url,
- externalSource: "github",
- externalUrl: comment.html_url,
- createdAt: new Date(comment.created_at),
- });
- }
- }
+ await db
+ .update(taskTable)
+ .set(updateData)
+ .where(eq(taskTable.id, existingLink.taskId));
+
+ await importLabelsForTask(issue.labels, existingLink.taskId, workspaceId);
+
+ await importCommentsForTask(
+ issue.number,
+ existingLink.taskId,
+ config,
+ octokit,
+ );
+
+ return "updated";
+ }
+
+ const nextTaskNumber = await getNextTaskNumber(projectId);
+
+ const taskValues: typeof taskTable.$inferInsert = {
+ projectId,
+ userId: null,
+ title: issue.title,
+ description: formatTaskDescriptionFromIssue(issue.body),
+ status: status || "to-do",
+ priority: priority || null,
+ number: nextTaskNumber + 1,
+ };
- try {
- const { data: timeline } =
- await installationOctokit.rest.issues.listEventsForTimeline({
- owner: config.repositoryOwner,
- repo: config.repositoryName,
- issue_number: issue.number,
- per_page: 100,
- });
-
- for (const event of timeline) {
- if (
- event.event === "cross-referenced" &&
- "source" in event &&
- event.source?.issue?.pull_request
- ) {
- const prIssue = event.source.issue;
- const prNumber = prIssue.number;
-
- const existingPRLink = await findExternalLink(
- integration.id,
- "pull_request",
- prNumber.toString(),
- );
-
- if (!existingPRLink) {
- await createExternalLink({
- taskId: newTask.id,
- integrationId: integration.id,
- resourceType: "pull_request",
- externalId: prNumber.toString(),
- url: prIssue.html_url,
- title: prIssue.title,
- metadata: {
- state: prIssue.state,
- merged: prIssue.pull_request?.merged_at ? true : false,
- importedFrom: "github-import",
- author: prIssue.user?.login,
- },
- });
- }
- }
- }
- } catch {
- // Timeline API requires specific permissions, silently skip if unavailable
+ const [createdTask] = await db
+ .insert(taskTable)
+ .values(taskValues)
+ .returning();
+
+ if (!createdTask) {
+ throw new Error("Failed to create task");
+ }
+
+ await createExternalLink({
+ taskId: createdTask.id,
+ integrationId,
+ resourceType: "issue",
+ externalId: issue.number.toString(),
+ url: issue.html_url,
+ title: issue.title,
+ metadata: {
+ state: issue.state,
+ createdFrom: "github-import",
+ author: issue.user?.login,
+ },
+ });
+
+ await importLabelsForTask(issue.labels, createdTask.id, workspaceId);
+
+ await importCommentsForTask(issue.number, createdTask.id, config, octokit);
+
+ return "imported";
+}
+
+async function importLabelsForTask(
+ issueLabels: GitHubIssue["labels"],
+ taskId: string,
+ workspaceId: string,
+): Promise<void> {
+ const nonSystemLabels = issueLabels
+ .map((label) => {
+ if (typeof label === "string") {
+ return { name: label, color: "#6B7280" };
}
+ return {
+ name: label.name,
+ color: label.color ? `#${label.color}` : "#6B7280",
+ };
+ })
+ .filter(
+ (label) =>
+ label.name &&
+ !label.name.startsWith("priority:") &&
+ !label.name.startsWith("status:"),
+ ) as Array<{ name: string; color: string }>;
+
+ for (const labelData of nonSystemLabels) {
+ const existingLabelOnTask = await db.query.labelTable.findFirst({
+ where: and(
+ eq(labelTable.taskId, taskId),
+ eq(labelTable.name, labelData.name),
+ ),
+ });
- imported++;
+ if (existingLabelOnTask) {
+ continue;
}
+ const existingWorkspaceLabel = await db.query.labelTable.findFirst({
+ where: and(
+ eq(labelTable.workspaceId, workspaceId),
+ eq(labelTable.name, labelData.name),
+ ),
+ });
+
+ const colorToUse = existingWorkspaceLabel?.color || labelData.color;
+
+ await db.insert(labelTable).values({
+ name: labelData.name,
+ color: colorToUse,
+ taskId,
+ workspaceId,
+ });
+ }
+}
+
+async function importCommentsForTask(
+ issueNumber: number,
+ taskId: string,
+ config: GitHubConfig,
+ octokit: Awaited<ReturnType<typeof getInstallationOctokit>>,
+): Promise<void> {
+ const allComments: GitHubComment[] = [];
+ let page = 1;
+ const perPage = 100;
+
+ while (true) {
+ const { data: comments } = await octokit.rest.issues.listComments({
+ owner: config.repositoryOwner,
+ repo: config.repositoryName,
+ issue_number: issueNumber,
+ per_page: perPage,
+ page,
+ });
+
+ if (comments.length === 0) break;
+
+ allComments.push(...(comments as GitHubComment[]));
+
+ if (comments.length < perPage) break;
page++;
}
- return { imported, skipped };
+ const existingActivities = await db.query.activityTable.findMany({
+ where: and(
+ eq(activityTable.taskId, taskId),
+ eq(activityTable.externalSource, "github"),
+ ),
+ });
+
+ const existingExternalUrls = new Set(
+ existingActivities.filter((a) => a.externalUrl).map((a) => a.externalUrl),
+ );
+
+ for (const comment of allComments) {
+ const username = comment.user?.login ?? "";
+ if (username.endsWith("[bot]")) {
+ continue;
+ }
+
+ if (existingExternalUrls.has(comment.html_url)) {
+ continue;
+ }
+
+ await db.insert(activityTable).values({
+ taskId,
+ type: "comment",
+ content: comment.body,
+ externalUserName: comment.user?.login ?? "Unknown",
+ externalUserAvatar: comment.user?.avatar_url ?? null,
+ externalSource: "github",
+ externalUrl: comment.html_url,
+ });
+ }
+}
+
+async function linkPullRequestToTask(
+ pr: GitHubPullRequest,
+ integrationId: string,
+ projectId: string,
+ projectSlug: string,
+ config: GitHubConfig,
+): Promise<void> {
+ const taskNumber = extractTaskNumber(
+ pr.head.ref,
+ pr.title,
+ pr.body ?? undefined,
+ config,
+ projectSlug,
+ );
+
+ if (!taskNumber) {
+ return;
+ }
+
+ const task = await findTaskByNumber(projectId, taskNumber);
+
+ if (!task) {
+ return;
+ }
+
+ const existingLink = await findExternalLink(
+ integrationId,
+ "pull_request",
+ pr.number.toString(),
+ );
+
+ if (existingLink) {
+ return;
+ }
+
+ await createExternalLink({
+ taskId: task.id,
+ integrationId,
+ resourceType: "pull_request",
+ externalId: pr.number.toString(),
+ url: pr.html_url,
+ title: pr.title,
+ metadata: {
+ state: pr.state,
+ branch: pr.head.ref,
+ author: pr.user?.login,
+ },
+ });
}
diff --git a/apps/api/src/plugins/github/services/task-service.ts b/apps/api/src/plugins/github/services/task-service.ts
index 2f6daa853..0723eb792 100644
--- a/apps/api/src/plugins/github/services/task-service.ts
+++ b/apps/api/src/plugins/github/services/task-service.ts
@@ -34,6 +34,11 @@ export async function getIntegrationWithProject(integrationId: string) {
}
export async function findIntegrationByRepo(owner: string, repo: string) {
+ const integrations = await findAllIntegrationsByRepo(owner, repo);
+ return integrations[0] || null;
+}
+
+export async function findAllIntegrationsByRepo(owner: string, repo: string) {
const integrations = await db.query.integrationTable.findMany({
where: and(
eq(integrationTable.type, "github"),
@@ -44,7 +49,7 @@ export async function findIntegrationByRepo(owner: string, repo: string) {
},
});
- return integrations.find((integration) => {
+ return integrations.filter((integration) => {
try {
const config = JSON.parse(integration.config);
return config.repositoryOwner === owner && config.repositoryName === repo;
diff --git a/apps/api/src/plugins/github/webhook-handler.ts b/apps/api/src/plugins/github/webhook-handler.ts
index f608485e4..fc33be45c 100644
--- a/apps/api/src/plugins/github/webhook-handler.ts
+++ b/apps/api/src/plugins/github/webhook-handler.ts
@@ -15,13 +15,19 @@ export async function handleGitHubWebhook(
eventName: string,
deliveryId: string,
): Promise<{ success: boolean; error?: string }> {
+ console.log(
+ `[GitHub Webhook] Received event: ${eventName}, delivery: ${deliveryId}`,
+ );
+
const githubApp = getGithubApp();
if (!githubApp) {
+ console.error("[GitHub Webhook] GitHub App not configured");
return { success: false, error: "GitHub integration not configured" };
}
try {
+ console.log(`[GitHub Webhook] Verifying and processing ${eventName}...`);
await githubApp.webhooks.verifyAndReceive({
id: deliveryId,
name: eventName as
@@ -34,9 +40,10 @@ export async function handleGitHubWebhook(
payload: body,
});
+ console.log(`[GitHub Webhook] Successfully processed ${eventName}`);
return { success: true };
} catch (error) {
- console.error("Webhook verification failed:", error);
+ console.error("[GitHub Webhook] Verification/processing failed:", error);
return {
success: false,
error:
@@ -54,61 +61,164 @@ export function setupWebhookHandlers() {
}
githubApp.webhooks.on("issues.opened", async ({ payload }) => {
- await handleIssueOpened(payload as Parameters<typeof handleIssueOpened>[0]);
+ console.log("[GitHub Webhook] Handling issues.opened");
+ try {
+ await handleIssueOpened(
+ payload as Parameters<typeof handleIssueOpened>[0],
+ );
+ console.log("[GitHub Webhook] issues.opened handled successfully");
+ } catch (error) {
+ console.error("[GitHub Webhook] issues.opened handler error:", error);
+ throw error;
+ }
});
githubApp.webhooks.on("issues.closed", async ({ payload }) => {
- await handleIssueClosed(payload as Parameters<typeof handleIssueClosed>[0]);
+ console.log("[GitHub Webhook] Handling issues.closed");
+ try {
+ await handleIssueClosed(
+ payload as Parameters<typeof handleIssueClosed>[0],
+ );
+ console.log("[GitHub Webhook] issues.closed handled successfully");
+ } catch (error) {
+ console.error("[GitHub Webhook] issues.closed handler error:", error);
+ throw error;
+ }
});
githubApp.webhooks.on("issues.labeled", async ({ payload }) => {
- await handleIssueLabeled(
- payload as Parameters<typeof handleIssueLabeled>[0],
- );
+ console.log("[GitHub Webhook] Handling issues.labeled");
+ try {
+ await handleIssueLabeled(
+ payload as Parameters<typeof handleIssueLabeled>[0],
+ );
+ console.log("[GitHub Webhook] issues.labeled handled successfully");
+ } catch (error) {
+ console.error("[GitHub Webhook] issues.labeled handler error:", error);
+ throw error;
+ }
});
githubApp.webhooks.on("issues.unlabeled", async ({ payload }) => {
- await handleIssueLabeled(
- payload as Parameters<typeof handleIssueLabeled>[0],
- );
+ console.log("[GitHub Webhook] Handling issues.unlabeled");
+ try {
+ await handleIssueLabeled(
+ payload as Parameters<typeof handleIssueLabeled>[0],
+ );
+ console.log("[GitHub Webhook] issues.unlabeled handled successfully");
+ } catch (error) {
+ console.error("[GitHub Webhook] issues.unlabeled handler error:", error);
+ throw error;
+ }
});
githubApp.webhooks.on("issues.edited", async ({ payload }) => {
- await handleIssueEdited(payload as Parameters<typeof handleIssueEdited>[0]);
+ console.log("[GitHub Webhook] Handling issues.edited");
+ try {
+ await handleIssueEdited(
+ payload as Parameters<typeof handleIssueEdited>[0],
+ );
+ console.log("[GitHub Webhook] issues.edited handled successfully");
+ } catch (error) {
+ console.error("[GitHub Webhook] issues.edited handler error:", error);
+ throw error;
+ }
});
githubApp.webhooks.on("push", async ({ payload }) => {
- await handlePush(payload as Parameters<typeof handlePush>[0]);
+ console.log("[GitHub Webhook] Handling push");
+ try {
+ await handlePush(payload as Parameters<typeof handlePush>[0]);
+ console.log("[GitHub Webhook] push handled successfully");
+ } catch (error) {
+ console.error("[GitHub Webhook] push handler error:", error);
+ throw error;
+ }
});
githubApp.webhooks.on("pull_request.opened", async ({ payload }) => {
- await handlePullRequestOpened(
- payload as Parameters<typeof handlePullRequestOpened>[0],
- );
+ console.log("[GitHub Webhook] Handling pull_request.opened");
+ try {
+ await handlePullRequestOpened(
+ payload as Parameters<typeof handlePullRequestOpened>[0],
+ );
+ console.log("[GitHub Webhook] pull_request.opened handled successfully");
+ } catch (error) {
+ console.error(
+ "[GitHub Webhook] pull_request.opened handler error:",
+ error,
+ );
+ throw error;
+ }
});
githubApp.webhooks.on("pull_request.closed", async ({ payload }) => {
- await handlePullRequestClosed(
- payload as Parameters<typeof handlePullRequestClosed>[0],
- );
+ console.log("[GitHub Webhook] Handling pull_request.closed");
+ try {
+ await handlePullRequestClosed(
+ payload as Parameters<typeof handlePullRequestClosed>[0],
+ );
+ console.log("[GitHub Webhook] pull_request.closed handled successfully");
+ } catch (error) {
+ console.error(
+ "[GitHub Webhook] pull_request.closed handler error:",
+ error,
+ );
+ throw error;
+ }
});
githubApp.webhooks.on("pull_request.reopened", async ({ payload }) => {
- await handlePullRequestOpened(
- payload as Parameters<typeof handlePullRequestOpened>[0],
- );
+ console.log("[GitHub Webhook] Handling pull_request.reopened");
+ try {
+ await handlePullRequestOpened(
+ payload as Parameters<typeof handlePullRequestOpened>[0],
+ );
+ console.log(
+ "[GitHub Webhook] pull_request.reopened handled successfully",
+ );
+ } catch (error) {
+ console.error(
+ "[GitHub Webhook] pull_request.reopened handler error:",
+ error,
+ );
+ throw error;
+ }
});
githubApp.webhooks.on("label.created", async ({ payload }) => {
- await handleLabelCreated(
- payload as Parameters<typeof handleLabelCreated>[0],
- );
+ console.log("[GitHub Webhook] Handling label.created");
+ try {
+ await handleLabelCreated(
+ payload as Parameters<typeof handleLabelCreated>[0],
+ );
+ console.log("[GitHub Webhook] label.created handled successfully");
+ } catch (error) {
+ console.error("[GitHub Webhook] label.created handler error:", error);
+ throw error;
+ }
});
githubApp.webhooks.on("issue_comment.created", async ({ payload }) => {
- await handleIssueCommentCreated(
- payload as Parameters<typeof handleIssueCommentCreated>[0],
- );
+ console.log("[GitHub Webhook] Handling issue_comment.created");
+ try {
+ await handleIssueCommentCreated(
+ payload as Parameters<typeof handleIssueCommentCreated>[0],
+ );
+ console.log(
+ "[GitHub Webhook] issue_comment.created handled successfully",
+ );
+ } catch (error) {
+ console.error(
+ "[GitHub Webhook] issue_comment.created handler error:",
+ error,
+ );
+ throw error;
+ }
+ });
+
+ githubApp.webhooks.onError((error) => {
+ console.error("[GitHub Webhook] Error in webhook handler:", error);
});
console.log("✓ GitHub webhook handlers registered");
diff --git a/apps/api/src/plugins/github/webhooks/issue-closed.ts b/apps/api/src/plugins/github/webhooks/issue-closed.ts
index 15c2bd14b..3c33b749d 100644
--- a/apps/api/src/plugins/github/webhooks/issue-closed.ts
+++ b/apps/api/src/plugins/github/webhooks/issue-closed.ts
@@ -2,7 +2,7 @@ import { and, eq } from "drizzle-orm";
import db from "../../../database";
import { externalLinkTable, taskTable } from "../../../database/schema";
import { updateExternalLink } from "../services/link-manager";
-import { findIntegrationByRepo } from "../services/task-service";
+import { findAllIntegrationsByRepo } from "../services/task-service";
type IssueClosedPayload = {
action: string;
@@ -22,52 +22,52 @@ type IssueClosedPayload = {
export async function handleIssueClosed(payload: IssueClosedPayload) {
const { issue, repository } = payload;
- const integration = await findIntegrationByRepo(
+ const integrations = await findAllIntegrationsByRepo(
repository.owner.login,
repository.name,
);
- if (!integration) {
- return;
- }
+ for (const integration of integrations) {
+ const externalLink = await db.query.externalLinkTable.findFirst({
+ where: and(
+ eq(externalLinkTable.integrationId, integration.id),
+ eq(externalLinkTable.resourceType, "issue"),
+ eq(externalLinkTable.externalId, issue.number.toString()),
+ ),
+ });
- const externalLink = await db.query.externalLinkTable.findFirst({
- where: and(
- eq(externalLinkTable.integrationId, integration.id),
- eq(externalLinkTable.resourceType, "issue"),
- eq(externalLinkTable.externalId, issue.number.toString()),
- ),
- });
+ if (!externalLink) {
+ continue;
+ }
- if (!externalLink) {
- return;
- }
+ const task = await db.query.taskTable.findFirst({
+ where: eq(taskTable.id, externalLink.taskId),
+ });
- const task = await db.query.taskTable.findFirst({
- where: eq(taskTable.id, externalLink.taskId),
- });
+ if (!task) {
+ continue;
+ }
- if (!task) {
- return;
- }
+ const existingMetadata = externalLink.metadata
+ ? JSON.parse(externalLink.metadata)
+ : {};
- const existingMetadata = externalLink.metadata
- ? JSON.parse(externalLink.metadata)
- : {};
+ if (existingMetadata.createdFrom === "kaneo") {
+ continue;
+ }
- if (existingMetadata.createdFrom === "kaneo") {
- return;
- }
+ await db
+ .update(taskTable)
+ .set({ status: "done" })
+ .where(eq(taskTable.id, task.id));
- await db
- .update(taskTable)
- .set({ status: "done" })
- .where(eq(taskTable.id, task.id));
+ await updateExternalLink(externalLink.id, {
+ metadata: {
+ ...existingMetadata,
+ state: "closed",
+ },
+ });
- await updateExternalLink(externalLink.id, {
- metadata: {
- ...existingMetadata,
- state: "closed",
- },
- });
+ return;
+ }
}
diff --git a/apps/api/src/plugins/github/webhooks/issue-comment-created.ts b/apps/api/src/plugins/github/webhooks/issue-comment-created.ts
index 68ace8efb..82aa921c8 100644
--- a/apps/api/src/plugins/github/webhooks/issue-comment-created.ts
+++ b/apps/api/src/plugins/github/webhooks/issue-comment-created.ts
@@ -1,7 +1,7 @@
import db from "../../../database";
import { activityTable } from "../../../database/schema";
import { findExternalLink } from "../services/link-manager";
-import { findIntegrationByRepo } from "../services/task-service";
+import { findAllIntegrationsByRepo } from "../services/task-service";
type IssueCommentCreatedPayload = {
action: string;
@@ -38,32 +38,32 @@ export async function handleIssueCommentCreated(
return;
}
- const integration = await findIntegrationByRepo(
+ const integrations = await findAllIntegrationsByRepo(
repository.owner.login,
repository.name,
);
- if (!integration) {
- return;
- }
+ for (const integration of integrations) {
+ const existingLink = await findExternalLink(
+ integration.id,
+ "issue",
+ issue.number.toString(),
+ );
- const existingLink = await findExternalLink(
- integration.id,
- "issue",
- issue.number.toString(),
- );
+ if (!existingLink) {
+ continue;
+ }
+
+ await db.insert(activityTable).values({
+ taskId: existingLink.taskId,
+ type: "comment",
+ content: comment.body,
+ externalUserName: comment.user?.login ?? "Unknown",
+ externalUserAvatar: comment.user?.avatar_url ?? null,
+ externalSource: "github",
+ externalUrl: comment.html_url,
+ });
- if (!existingLink) {
return;
}
-
- await db.insert(activityTable).values({
- taskId: existingLink.taskId,
- type: "comment",
- content: comment.body,
- externalUserName: comment.user?.login ?? "Unknown",
- externalUserAvatar: comment.user?.avatar_url ?? null,
- externalSource: "github",
- externalUrl: comment.html_url,
- });
}
diff --git a/apps/api/src/plugins/github/webhooks/issue-edited.ts b/apps/api/src/plugins/github/webhooks/issue-edited.ts
index c90b502ed..9b4e48dd6 100644
--- a/apps/api/src/plugins/github/webhooks/issue-edited.ts
+++ b/apps/api/src/plugins/github/webhooks/issue-edited.ts
@@ -2,7 +2,7 @@ import { eq } from "drizzle-orm";
import db from "../../../database";
import { taskTable } from "../../../database/schema";
import { findExternalLink, updateExternalLink } from "../services/link-manager";
-import { findIntegrationByRepo } from "../services/task-service";
+import { findAllIntegrationsByRepo } from "../services/task-service";
import { formatTaskDescriptionFromIssue } from "../utils/format";
type IssueEditedPayload = {
@@ -31,7 +31,6 @@ type IssueEditedPayload = {
export async function handleIssueEdited(payload: IssueEditedPayload) {
const { issue, repository, changes } = payload;
- // Early exit if no relevant changes
if (!changes?.title && !changes?.body) {
console.log(
`Issue #${issue.number} edited but no title/body changes detected`,
@@ -39,146 +38,137 @@ export async function handleIssueEdited(payload: IssueEditedPayload) {
return;
}
- const integration = await findIntegrationByRepo(
+ const integrations = await findAllIntegrationsByRepo(
repository.owner.login,
repository.name,
);
- if (!integration) {
- console.log(
- `No integration found for ${repository.owner.login}/${repository.name}`,
+ for (const integration of integrations) {
+ const externalLink = await findExternalLink(
+ integration.id,
+ "issue",
+ issue.number.toString(),
);
- return;
- }
-
- const externalLink = await findExternalLink(
- integration.id,
- "issue",
- issue.number.toString(),
- );
- if (!externalLink) {
- console.log(`No linked task found for issue #${issue.number}`);
- return;
- }
+ if (!externalLink) {
+ continue;
+ }
- const task = await db.query.taskTable.findFirst({
- where: eq(taskTable.id, externalLink.taskId),
- });
+ const task = await db.query.taskTable.findFirst({
+ where: eq(taskTable.id, externalLink.taskId),
+ });
- if (!task) {
- console.error(`Task ${externalLink.taskId} not found`);
- return;
- }
+ if (!task) {
+ console.error(`Task ${externalLink.taskId} not found`);
+ continue;
+ }
- const metadata = externalLink.metadata
- ? JSON.parse(externalLink.metadata)
- : {};
+ const metadata = externalLink.metadata
+ ? JSON.parse(externalLink.metadata)
+ : {};
- const updateData: Record<string, unknown> = {};
- const updatedMetadata = { ...metadata };
+ const updateData: Record<string, unknown> = {};
+ const updatedMetadata = { ...metadata };
- // Initialize lastSync if not present
- if (!updatedMetadata.lastSync) {
- updatedMetadata.lastSync = {};
- }
+ if (!updatedMetadata.lastSync) {
+ updatedMetadata.lastSync = {};
+ }
- // Handle title change
- if (changes.title) {
- const lastTitleSync = metadata.lastSync?.title;
-
- // LOOP PREVENTION
- let shouldUpdateTitle = true;
-
- if (lastTitleSync) {
- // Skip if this value was just synced from Kaneo
- if (
- lastTitleSync.value === issue.title &&
- lastTitleSync.source === "kaneo"
- ) {
- console.log("Skipping title update - already synced from Kaneo");
- shouldUpdateTitle = false;
+ if (changes.title) {
+ const lastTitleSync = metadata.lastSync?.title;
+
+ let shouldUpdateTitle = true;
+
+ if (lastTitleSync) {
+ if (
+ lastTitleSync.value === issue.title &&
+ lastTitleSync.source === "kaneo"
+ ) {
+ console.log("Skipping title update - already synced from Kaneo");
+ shouldUpdateTitle = false;
+ }
+
+ const timeSinceLastSync =
+ Date.now() - new Date(lastTitleSync.timestamp).getTime();
+ if (timeSinceLastSync < 2000 && shouldUpdateTitle) {
+ console.log(
+ `Skipping title update - recent sync detected (${timeSinceLastSync}ms ago)`,
+ );
+ shouldUpdateTitle = false;
+ }
}
- // Skip if recent sync (within 2 seconds)
- const timeSinceLastSync =
- Date.now() - new Date(lastTitleSync.timestamp).getTime();
- if (timeSinceLastSync < 2000 && shouldUpdateTitle) {
+ if (shouldUpdateTitle) {
+ updateData.title = issue.title;
+ updatedMetadata.lastSync.title = {
+ timestamp: new Date().toISOString(),
+ source: "github",
+ value: issue.title,
+ };
console.log(
- `Skipping title update - recent sync detected (${timeSinceLastSync}ms ago)`,
+ `Updating task title from GitHub: "${changes.title.from}" → "${issue.title}"`,
);
- shouldUpdateTitle = false;
}
}
- if (shouldUpdateTitle) {
- updateData.title = issue.title;
- updatedMetadata.lastSync.title = {
- timestamp: new Date().toISOString(),
- source: "github",
- value: issue.title,
- };
- console.log(
- `Updating task title from GitHub: "${changes.title.from}" → "${issue.title}"`,
- );
- }
- }
-
- // Handle description change
- if (changes.body) {
- const lastDescSync = metadata.lastSync?.description;
- const formattedDescription = formatTaskDescriptionFromIssue(issue.body);
-
- // LOOP PREVENTION
- let shouldUpdateDescription = true;
-
- if (lastDescSync) {
- // Skip if this value was just synced from Kaneo
- if (
- lastDescSync.value === formattedDescription &&
- lastDescSync.source === "kaneo"
- ) {
- console.log("Skipping description update - already synced from Kaneo");
- shouldUpdateDescription = false;
+ if (changes.body) {
+ const lastDescSync = metadata.lastSync?.description;
+ const formattedDescription = formatTaskDescriptionFromIssue(issue.body);
+
+ let shouldUpdateDescription = true;
+
+ if (lastDescSync) {
+ if (
+ lastDescSync.value === formattedDescription &&
+ lastDescSync.source === "kaneo"
+ ) {
+ console.log(
+ "Skipping description update - already synced from Kaneo",
+ );
+ shouldUpdateDescription = false;
+ }
+
+ const timeSinceLastSync =
+ Date.now() - new Date(lastDescSync.timestamp).getTime();
+ if (timeSinceLastSync < 2000 && shouldUpdateDescription) {
+ console.log(
+ `Skipping description update - recent sync detected (${timeSinceLastSync}ms ago)`,
+ );
+ shouldUpdateDescription = false;
+ }
}
- // Skip if recent sync (within 2 seconds)
- const timeSinceLastSync =
- Date.now() - new Date(lastDescSync.timestamp).getTime();
- if (timeSinceLastSync < 2000 && shouldUpdateDescription) {
- console.log(
- `Skipping description update - recent sync detected (${timeSinceLastSync}ms ago)`,
- );
- shouldUpdateDescription = false;
+ if (shouldUpdateDescription) {
+ updateData.description = formattedDescription;
+ updatedMetadata.lastSync.description = {
+ timestamp: new Date().toISOString(),
+ source: "github",
+ value: formattedDescription,
+ };
+ console.log("Updating task description from GitHub");
}
}
- if (shouldUpdateDescription) {
- updateData.description = formattedDescription;
- updatedMetadata.lastSync.description = {
- timestamp: new Date().toISOString(),
- source: "github",
- value: formattedDescription,
- };
- console.log("Updating task description from GitHub");
- }
- }
+ if (Object.keys(updateData).length > 0) {
+ await db
+ .update(taskTable)
+ .set(updateData)
+ .where(eq(taskTable.id, task.id));
- // Apply updates if any
- if (Object.keys(updateData).length > 0) {
- await db.update(taskTable).set(updateData).where(eq(taskTable.id, task.id));
+ await updateExternalLink(externalLink.id, {
+ title: issue.title,
+ metadata: updatedMetadata,
+ });
- await updateExternalLink(externalLink.id, {
- title: issue.title,
- metadata: updatedMetadata,
- });
+ console.log(
+ `Synced ${Object.keys(updateData).join(", ")} from GitHub issue #${issue.number} to task ${task.id}`,
+ );
+ } else {
+ console.log(
+ `No updates needed for task ${task.id} from issue #${issue.number}`,
+ );
+ }
- console.log(
- `Synced ${Object.keys(updateData).join(", ")} from GitHub issue #${issue.number} to task ${task.id}`,
- );
- } else {
- console.log(
- `No updates needed for task ${task.id} from issue #${issue.number}`,
- );
+ return;
}
}
diff --git a/apps/api/src/plugins/github/webhooks/issue-labeled.ts b/apps/api/src/plugins/github/webhooks/issue-labeled.ts
index 25141c081..18b1e5f10 100644
--- a/apps/api/src/plugins/github/webhooks/issue-labeled.ts
+++ b/apps/api/src/plugins/github/webhooks/issue-labeled.ts
@@ -1,8 +1,8 @@
import { eq } from "drizzle-orm";
import db from "../../../database";
-import { labelTable, projectTable, taskTable } from "../../../database/schema";
+import { labelTable, taskTable } from "../../../database/schema";
import { findExternalLink } from "../services/link-manager";
-import { findIntegrationByRepo } from "../services/task-service";
+import { findAllIntegrationsByRepo } from "../services/task-service";
import {
extractIssuePriority,
extractIssueStatus,
@@ -27,98 +27,98 @@ type IssueLabeledPayload = {
export async function handleIssueLabeled(payload: IssueLabeledPayload) {
const { issue, repository, label: addedLabel } = payload;
- const integration = await findIntegrationByRepo(
+ const integrations = await findAllIntegrationsByRepo(
repository.owner.login,
repository.name,
);
- if (!integration) {
- return;
- }
+ for (const integration of integrations) {
+ const existingLink = await findExternalLink(
+ integration.id,
+ "issue",
+ issue.number.toString(),
+ );
- const existingLink = await findExternalLink(
- integration.id,
- "issue",
- issue.number.toString(),
- );
+ if (!existingLink) {
+ continue;
+ }
- if (!existingLink) {
- return;
- }
+ const priority = extractIssuePriority(issue.labels);
+ const status = extractIssueStatus(issue.labels);
- const priority = extractIssuePriority(issue.labels);
- const status = extractIssueStatus(issue.labels);
+ const updateData: Record<string, unknown> = {};
- const updateData: Record<string, unknown> = {};
+ if (priority) {
+ updateData.priority = priority;
+ }
- if (priority) {
- updateData.priority = priority;
- }
+ if (status) {
+ updateData.status = status;
+ }
- if (status) {
- updateData.status = status;
- }
+ if (Object.keys(updateData).length > 0) {
+ await db
+ .update(taskTable)
+ .set(updateData)
+ .where(eq(taskTable.id, existingLink.taskId));
+ }
- if (Object.keys(updateData).length > 0) {
- await db
- .update(taskTable)
- .set(updateData)
- .where(eq(taskTable.id, existingLink.taskId));
- }
+ if (!addedLabel) {
+ return;
+ }
- if (!addedLabel) {
- return;
- }
+ const isSystemLabel =
+ addedLabel.name.startsWith("priority:") ||
+ addedLabel.name.startsWith("status:");
- const isSystemLabel =
- addedLabel.name.startsWith("priority:") ||
- addedLabel.name.startsWith("status:");
+ if (isSystemLabel) {
+ return;
+ }
- if (isSystemLabel) {
- return;
- }
+ if (payload.action === "labeled") {
+ const task = await db.query.taskTable.findFirst({
+ where: eq(taskTable.id, existingLink.taskId),
+ with: {
+ project: true,
+ },
+ });
- if (payload.action === "labeled") {
- const task = await db.query.taskTable.findFirst({
- where: eq(taskTable.id, existingLink.taskId),
- with: {
- project: true,
- },
- });
+ if (task?.project?.workspaceId) {
+ const existingLabel = await db.query.labelTable.findFirst({
+ where: (table, { and, eq }) =>
+ and(
+ eq(table.workspaceId, task.project.workspaceId),
+ eq(table.name, addedLabel.name),
+ eq(table.taskId, task.id),
+ ),
+ });
- if (task?.project?.workspaceId) {
- const existingLabel = await db.query.labelTable.findFirst({
+ if (!existingLabel) {
+ const color = addedLabel.color ? `#${addedLabel.color}` : "#6B7280";
+ await db.insert(labelTable).values({
+ name: addedLabel.name,
+ color,
+ taskId: task.id,
+ workspaceId: task.project.workspaceId,
+ });
+ }
+ }
+ }
+
+ if (payload.action === "unlabeled") {
+ const labelsToDelete = await db.query.labelTable.findMany({
where: (table, { and, eq }) =>
and(
- eq(table.workspaceId, task.project.workspaceId),
+ eq(table.taskId, existingLink.taskId),
eq(table.name, addedLabel.name),
- eq(table.taskId, task.id),
),
});
- if (!existingLabel) {
- const color = addedLabel.color ? `#${addedLabel.color}` : "#6B7280";
- await db.insert(labelTable).values({
- name: addedLabel.name,
- color,
- taskId: task.id,
- workspaceId: task.project.workspaceId,
- });
+ for (const label of labelsToDelete) {
+ await db.delete(labelTable).where(eq(labelTable.id, label.id));
}
}
- }
- if (payload.action === "unlabeled") {
- const labelsToDelete = await db.query.labelTable.findMany({
- where: (table, { and, eq }) =>
- and(
- eq(table.taskId, existingLink.taskId),
- eq(table.name, addedLabel.name),
- ),
- });
-
- for (const label of labelsToDelete) {
- await db.delete(labelTable).where(eq(labelTable.id, label.id));
- }
+ return;
}
}
diff --git a/apps/api/src/plugins/github/webhooks/issue-opened.ts b/apps/api/src/plugins/github/webhooks/issue-opened.ts
index 5c7f47faa..0f5244020 100644
--- a/apps/api/src/plugins/github/webhooks/issue-opened.ts
+++ b/apps/api/src/plugins/github/webhooks/issue-opened.ts
@@ -4,7 +4,7 @@ import { projectTable, taskTable } from "../../../database/schema";
import getNextTaskNumber from "../../../task/controllers/get-next-task-number";
import type { GitHubConfig } from "../config";
import { createExternalLink, findExternalLink } from "../services/link-manager";
-import { findIntegrationByRepo } from "../services/task-service";
+import { findAllIntegrationsByRepo } from "../services/task-service";
import {
extractIssuePriority,
extractIssueStatus,
@@ -38,131 +38,133 @@ export async function handleIssueOpened(payload: IssueOpenedPayload) {
const { issue, repository } = payload;
- const integration = await findIntegrationByRepo(
+ const integrations = await findAllIntegrationsByRepo(
repository.owner.login,
repository.name,
);
- if (!integration) {
+ if (integrations.length === 0) {
return;
}
- const config = JSON.parse(integration.config) as GitHubConfig;
- const projectId = integration.projectId;
+ for (const integration of integrations) {
+ const config = JSON.parse(integration.config) as GitHubConfig;
+ const projectId = integration.projectId;
- const priority = extractIssuePriority(issue.labels);
- const status = extractIssueStatus(issue.labels);
+ const priority = extractIssuePriority(issue.labels);
+ const status = extractIssueStatus(issue.labels);
- const existingLink = await findExternalLink(
- integration.id,
- "issue",
- issue.number.toString(),
- );
-
- if (existingLink) {
- console.log(
- `Issue #${issue.number} already linked to task ${existingLink.taskId}, skipping creation`,
+ const existingLink = await findExternalLink(
+ integration.id,
+ "issue",
+ issue.number.toString(),
);
- return;
- }
-
- const nextTaskNumber = await getNextTaskNumber(projectId);
-
- const taskValues: typeof taskTable.$inferInsert = {
- projectId,
- userId: null,
- title: issue.title,
- description: formatTaskDescriptionFromIssue(issue.body),
- status: "to-do",
- priority: null,
- number: nextTaskNumber + 1,
- };
-
- if (priority) taskValues.priority = priority;
- if (status) taskValues.status = status;
-
- const [createdTask] = await db
- .insert(taskTable)
- .values(taskValues)
- .returning();
-
- if (!createdTask) {
- console.error("Failed to create task from GitHub issue");
- return;
- }
- await createExternalLink({
- taskId: createdTask.id,
- integrationId: integration.id,
- resourceType: "issue",
- externalId: issue.number.toString(),
- url: issue.html_url,
- title: issue.title,
- metadata: {
- state: "open",
- createdFrom: "github",
- author: issue.user?.login,
- },
- });
-
- const project = await db.query.projectTable.findFirst({
- where: eq(projectTable.id, projectId),
- });
-
- if (!project) {
- console.error("Project not found for task linking comment");
- return;
- }
-
- const clientUrl = process.env.KANEO_CLIENT_URL || "http://localhost:5173";
- const taskUrl = `${clientUrl}/dashboard/workspace/${project.workspaceId}/project/${projectId}/task/${createdTask.id}`;
- const taskIdentifier = `${project.slug.toUpperCase()}-${createdTask.number}`;
-
- try {
- let installationId = config.installationId;
- if (!installationId) {
- const { data: installation } =
- await githubApp.octokit.rest.apps.getRepoInstallation({
- owner: repository.owner.login,
- repo: repository.name,
- });
- installationId = installation.id;
+ if (existingLink) {
+ console.log(
+ `Issue #${issue.number} already linked to task ${existingLink.taskId} in project ${projectId}, skipping`,
+ );
+ continue;
}
- const octokit = await githubApp.getInstallationOctokit(installationId);
-
- const existingLabels =
- issue.labels
- ?.map((label) => (typeof label === "string" ? label : label.name))
- .filter(Boolean) || [];
+ const nextTaskNumber = await getNextTaskNumber(projectId);
+
+ const taskValues: typeof taskTable.$inferInsert = {
+ projectId,
+ userId: null,
+ title: issue.title,
+ description: formatTaskDescriptionFromIssue(issue.body),
+ status: "to-do",
+ priority: null,
+ number: nextTaskNumber + 1,
+ };
+
+ if (priority) taskValues.priority = priority;
+ if (status) taskValues.status = status;
+
+ const [createdTask] = await db
+ .insert(taskTable)
+ .values(taskValues)
+ .returning();
+
+ if (!createdTask) {
+ console.error("Failed to create task from GitHub issue");
+ continue;
+ }
- const labelsToAdd: string[] = [];
+ await createExternalLink({
+ taskId: createdTask.id,
+ integrationId: integration.id,
+ resourceType: "issue",
+ externalId: issue.number.toString(),
+ url: issue.html_url,
+ title: issue.title,
+ metadata: {
+ state: "open",
+ createdFrom: "github",
+ author: issue.user?.login,
+ },
+ });
- if (priority && !existingLabels.includes(`priority:${priority}`)) {
- labelsToAdd.push(`priority:${priority}`);
- }
+ const project = await db.query.projectTable.findFirst({
+ where: eq(projectTable.id, projectId),
+ });
- if (status && !existingLabels.includes(`status:${status}`)) {
- labelsToAdd.push(`status:${status}`);
+ if (!project) {
+ console.error("Project not found for task linking comment");
+ continue;
}
- if (labelsToAdd.length > 0) {
- await addLabelsToIssue(
- octokit,
- repository.owner.login,
- repository.name,
- issue.number,
- labelsToAdd,
- );
+ const clientUrl = process.env.KANEO_CLIENT_URL || "http://localhost:5173";
+ const taskUrl = `${clientUrl}/dashboard/workspace/${project.workspaceId}/project/${projectId}/task/${createdTask.id}`;
+ const taskIdentifier = `${project.slug.toUpperCase()}-${createdTask.number}`;
+
+ try {
+ let installationId = config.installationId;
+ if (!installationId) {
+ const { data: installation } =
+ await githubApp.octokit.rest.apps.getRepoInstallation({
+ owner: repository.owner.login,
+ repo: repository.name,
+ });
+ installationId = installation.id;
+ }
+
+ const octokit = await githubApp.getInstallationOctokit(installationId);
+
+ const existingLabels =
+ issue.labels
+ ?.map((label) => (typeof label === "string" ? label : label.name))
+ .filter(Boolean) || [];
+
+ const labelsToAdd: string[] = [];
+
+ if (priority && !existingLabels.includes(`priority:${priority}`)) {
+ labelsToAdd.push(`priority:${priority}`);
+ }
+
+ if (status && !existingLabels.includes(`status:${status}`)) {
+ labelsToAdd.push(`status:${status}`);
+ }
+
+ if (labelsToAdd.length > 0) {
+ await addLabelsToIssue(
+ octokit,
+ repository.owner.login,
+ repository.name,
+ issue.number,
+ labelsToAdd,
+ );
+ }
+
+ await octokit.rest.issues.createComment({
+ owner: repository.owner.login,
+ repo: repository.name,
+ issue_number: issue.number,
+ body: `[${taskIdentifier}](${taskUrl})`,
+ });
+ } catch (error) {
+ console.error("Failed to process GitHub issue:", error);
}
-
- await octokit.rest.issues.createComment({
- owner: repository.owner.login,
- repo: repository.name,
- issue_number: issue.number,
- body: `[${taskIdentifier}](${taskUrl})`,
- });
- } catch (error) {
- console.error("Failed to process GitHub issue:", error);
}
}
diff --git a/apps/api/src/plugins/github/webhooks/label-created.ts b/apps/api/src/plugins/github/webhooks/label-created.ts
index c018fd1ed..7d809e867 100644
--- a/apps/api/src/plugins/github/webhooks/label-created.ts
+++ b/apps/api/src/plugins/github/webhooks/label-created.ts
@@ -1,7 +1,7 @@
import { eq } from "drizzle-orm";
import db from "../../../database";
import { labelTable, projectTable } from "../../../database/schema";
-import { findIntegrationByRepo } from "../services/task-service";
+import { findAllIntegrationsByRepo } from "../services/task-service";
type LabelCreatedPayload = {
action: string;
@@ -19,40 +19,42 @@ type LabelCreatedPayload = {
export async function handleLabelCreated(payload: LabelCreatedPayload) {
const { repository, label } = payload;
- const integration = await findIntegrationByRepo(
+ const integrations = await findAllIntegrationsByRepo(
repository.owner.login,
repository.name,
);
- if (!integration?.project) {
- return;
+ for (const integration of integrations) {
+ if (!integration.project) {
+ continue;
+ }
+
+ const project = await db.query.projectTable.findFirst({
+ where: eq(projectTable.id, integration.project.id),
+ });
+
+ if (!project?.workspaceId) {
+ continue;
+ }
+
+ const labelExists = await db.query.labelTable.findFirst({
+ where: (table, { and, eq }) =>
+ and(
+ eq(table.workspaceId, project.workspaceId),
+ eq(table.name, label.name),
+ ),
+ });
+
+ if (labelExists) {
+ continue;
+ }
+
+ const color = label.color ? `#${label.color}` : "#6B7280";
+
+ await db.insert(labelTable).values({
+ name: label.name,
+ color,
+ workspaceId: project.workspaceId,
+ });
}
-
- const project = await db.query.projectTable.findFirst({
- where: eq(projectTable.id, integration.project.id),
- });
-
- if (!project?.workspaceId) {
- return;
- }
-
- const labelExists = await db.query.labelTable.findFirst({
- where: (table, { and, eq }) =>
- and(
- eq(table.workspaceId, project.workspaceId),
- eq(table.name, label.name),
- ),
- });
-
- if (labelExists) {
- return;
- }
-
- const color = label.color ? `#${label.color}` : "#6B7280";
-
- await db.insert(labelTable).values({
- name: label.name,
- color,
- workspaceId: project.workspaceId,
- });
}
diff --git a/apps/api/src/plugins/github/webhooks/pull-request-closed.ts b/apps/api/src/plugins/github/webhooks/pull-request-closed.ts
index 7159d66c7..49dc48be2 100644
--- a/apps/api/src/plugins/github/webhooks/pull-request-closed.ts
+++ b/apps/api/src/plugins/github/webhooks/pull-request-closed.ts
@@ -4,7 +4,7 @@ import { externalLinkTable } from "../../../database/schema";
import type { GitHubConfig } from "../config";
import { updateExternalLink } from "../services/link-manager";
import {
- findIntegrationByRepo,
+ findAllIntegrationsByRepo,
findTaskById,
updateTaskStatus,
} from "../services/task-service";
@@ -31,65 +31,65 @@ type PRClosedPayload = {
export async function handlePullRequestClosed(payload: PRClosedPayload) {
const { pull_request, repository } = payload;
- const integration = await findIntegrationByRepo(
+ const integrations = await findAllIntegrationsByRepo(
repository.owner.login,
repository.name,
);
- if (!integration) {
- return;
- }
-
- const config = JSON.parse(integration.config) as GitHubConfig;
+ for (const integration of integrations) {
+ const config = JSON.parse(integration.config) as GitHubConfig;
- const externalLink = await db.query.externalLinkTable.findFirst({
- where: and(
- eq(externalLinkTable.integrationId, integration.id),
- eq(externalLinkTable.resourceType, "pull_request"),
- eq(externalLinkTable.externalId, pull_request.number.toString()),
- ),
- });
+ const externalLink = await db.query.externalLinkTable.findFirst({
+ where: and(
+ eq(externalLinkTable.integrationId, integration.id),
+ eq(externalLinkTable.resourceType, "pull_request"),
+ eq(externalLinkTable.externalId, pull_request.number.toString()),
+ ),
+ });
- if (!externalLink) {
- return;
- }
+ if (!externalLink) {
+ continue;
+ }
- const task = await findTaskById(externalLink.taskId);
+ const task = await findTaskById(externalLink.taskId);
- if (!task) {
- return;
- }
-
- const existingMetadata = externalLink.metadata
- ? JSON.parse(externalLink.metadata)
- : {};
+ if (!task) {
+ continue;
+ }
- await updateExternalLink(externalLink.id, {
- metadata: {
- ...existingMetadata,
- state: "closed",
- merged: pull_request.merged,
- mergedAt: pull_request.merged_at,
- },
- });
+ const existingMetadata = externalLink.metadata
+ ? JSON.parse(externalLink.metadata)
+ : {};
- if (pull_request.merged) {
- const allTaskPRs = await db.query.externalLinkTable.findMany({
- where: and(
- eq(externalLinkTable.taskId, task.id),
- eq(externalLinkTable.resourceType, "pull_request"),
- ),
+ await updateExternalLink(externalLink.id, {
+ metadata: {
+ ...existingMetadata,
+ state: "closed",
+ merged: pull_request.merged,
+ mergedAt: pull_request.merged_at,
+ },
});
- const hasOpenPRs = allTaskPRs.some((pr) => {
- if (pr.id === externalLink.id) return false;
- const metadata = pr.metadata ? JSON.parse(pr.metadata) : {};
- return metadata.state === "open";
- });
+ if (pull_request.merged) {
+ const allTaskPRs = await db.query.externalLinkTable.findMany({
+ where: and(
+ eq(externalLinkTable.taskId, task.id),
+ eq(externalLinkTable.resourceType, "pull_request"),
+ ),
+ });
+
+ const hasOpenPRs = allTaskPRs.some((pr) => {
+ if (pr.id === externalLink.id) return false;
+ const metadata = pr.metadata ? JSON.parse(pr.metadata) : {};
+ return metadata.state === "open";
+ });
- if (!hasOpenPRs) {
- const targetStatus = config.statusTransitions?.onPRMerge || "done";
- await updateTaskStatus(task.id, targetStatus);
+ if (!hasOpenPRs) {
+ const targetStatus = config.statusTransitions?.onPRMerge || "done";
+ await updateTaskStatus(task.id, targetStatus);
+ }
}
+
+ return;
}
}
diff --git a/apps/api/src/plugins/github/webhooks/pull-request-opened.ts b/apps/api/src/plugins/github/webhooks/pull-request-opened.ts
index 6b437f348..66bb36589 100644
--- a/apps/api/src/plugins/github/webhooks/pull-request-opened.ts
+++ b/apps/api/src/plugins/github/webhooks/pull-request-opened.ts
@@ -1,7 +1,7 @@
import type { GitHubConfig } from "../config";
import { createExternalLink, findExternalLink } from "../services/link-manager";
import {
- findIntegrationByRepo,
+ findAllIntegrationsByRepo,
findTaskByNumber,
updateTaskStatus,
} from "../services/task-service";
@@ -31,66 +31,70 @@ type PROpenedPayload = {
export async function handlePullRequestOpened(payload: PROpenedPayload) {
const { pull_request, repository } = payload;
- const integration = await findIntegrationByRepo(
+ const integrations = await findAllIntegrationsByRepo(
repository.owner.login,
repository.name,
);
- if (!integration || !integration.project) {
- return;
- }
+ for (const integration of integrations) {
+ if (!integration.project) {
+ continue;
+ }
- const config = JSON.parse(integration.config) as GitHubConfig;
- const projectSlug = integration.project.slug;
- const branchName = pull_request.head.ref;
+ const config = JSON.parse(integration.config) as GitHubConfig;
+ const projectSlug = integration.project.slug;
+ const branchName = pull_request.head.ref;
- const taskNumber = extractTaskNumber(
- branchName,
- pull_request.title,
- pull_request.body ?? undefined,
- config,
- projectSlug,
- );
+ const taskNumber = extractTaskNumber(
+ branchName,
+ pull_request.title,
+ pull_request.body ?? undefined,
+ config,
+ projectSlug,
+ );
- if (!taskNumber) {
- return;
- }
+ if (!taskNumber) {
+ continue;
+ }
- const task = await findTaskByNumber(integration.projectId, taskNumber);
+ const task = await findTaskByNumber(integration.projectId, taskNumber);
- if (!task) {
- return;
- }
+ if (!task) {
+ continue;
+ }
- const existingLink = await findExternalLink(
- integration.id,
- "pull_request",
- pull_request.number.toString(),
- );
+ const existingLink = await findExternalLink(
+ integration.id,
+ "pull_request",
+ pull_request.number.toString(),
+ );
- if (existingLink) {
- return;
- }
+ if (existingLink) {
+ continue;
+ }
+
+ await createExternalLink({
+ taskId: task.id,
+ integrationId: integration.id,
+ resourceType: "pull_request",
+ externalId: pull_request.number.toString(),
+ url: pull_request.html_url,
+ title: pull_request.title,
+ metadata: {
+ state: pull_request.state,
+ draft: pull_request.draft,
+ merged: pull_request.merged,
+ branch: branchName,
+ author: pull_request.user?.login,
+ },
+ });
- await createExternalLink({
- taskId: task.id,
- integrationId: integration.id,
- resourceType: "pull_request",
- externalId: pull_request.number.toString(),
- url: pull_request.html_url,
- title: pull_request.title,
- metadata: {
- state: pull_request.state,
- draft: pull_request.draft,
- merged: pull_request.merged,
- branch: branchName,
- author: pull_request.user?.login,
- },
- });
+ const targetStatus = config.statusTransitions?.onPROpen || "in-review";
- const targetStatus = config.statusTransitions?.onPROpen || "in-review";
+ if (task.status !== targetStatus && task.status !== "done") {
+ await updateTaskStatus(task.id, targetStatus);
+ }
- if (task.status !== targetStatus && task.status !== "done") {
- await updateTaskStatus(task.id, targetStatus);
+ return;
}
}
diff --git a/apps/api/src/plugins/github/webhooks/push.ts b/apps/api/src/plugins/github/webhooks/push.ts
index e0f54f1aa..f4ceb03c4 100644
--- a/apps/api/src/plugins/github/webhooks/push.ts
+++ b/apps/api/src/plugins/github/webhooks/push.ts
@@ -1,7 +1,7 @@
import type { GitHubConfig } from "../config";
import { createOrUpdateExternalLink } from "../services/link-manager";
import {
- findIntegrationByRepo,
+ findAllIntegrationsByRepo,
findTaskByNumber,
updateTaskStatus,
} from "../services/task-service";
@@ -34,61 +34,108 @@ export async function handlePush(payload: PushPayload) {
const { ref, repository, head_commit } = payload;
const branchName = ref.replace("refs/heads/", "");
+ console.log(`[Push] Processing branch: ${branchName}`);
if (PROTECTED_BRANCHES.includes(branchName)) {
+ console.log(`[Push] Skipping protected branch: ${branchName}`);
return;
}
- const integration = await findIntegrationByRepo(
+ const integrations = await findAllIntegrationsByRepo(
repository.owner.login,
repository.name,
);
- if (!integration || !integration.project) {
+ if (integrations.length === 0) {
+ console.log(
+ `[Push] No integrations found for ${repository.owner.login}/${repository.name}`,
+ );
return;
}
- const config = JSON.parse(integration.config) as GitHubConfig;
- const projectSlug = integration.project.slug;
-
- const taskNumber = extractTaskNumberFromBranch(
- branchName,
- config,
- projectSlug,
+ console.log(
+ `[Push] Found ${integrations.length} integration(s) for this repo`,
);
- if (!taskNumber) {
- return;
- }
+ for (const integration of integrations) {
+ if (!integration.project) {
+ continue;
+ }
+
+ const config = JSON.parse(integration.config) as GitHubConfig;
+ const projectSlug = integration.project.slug;
+ console.log(
+ `[Push] Trying project: ${projectSlug}, pattern: ${config.branchPattern}`,
+ );
+
+ const taskNumber = extractTaskNumberFromBranch(
+ branchName,
+ config,
+ projectSlug,
+ );
+
+ if (!taskNumber) {
+ console.log(
+ `[Push] Could not extract task number from branch: ${branchName} (pattern: ${config.branchPattern}, slug: ${projectSlug})`,
+ );
+ continue;
+ }
+
+ console.log(
+ `[Push] Extracted task number: ${taskNumber} for project ${projectSlug}`,
+ );
- const task = await findTaskByNumber(integration.projectId, taskNumber);
+ const task = await findTaskByNumber(integration.projectId, taskNumber);
+
+ if (!task) {
+ console.log(
+ `[Push] Task #${taskNumber} not found in project ${integration.projectId}`,
+ );
+ continue;
+ }
+
+ console.log(
+ `[Push] Found task: ${task.id}, current status: ${task.status}`,
+ );
+
+ await createOrUpdateExternalLink({
+ taskId: task.id,
+ integrationId: integration.id,
+ resourceType: "branch",
+ externalId: branchName,
+ url: `${repository.html_url}/tree/${branchName}`,
+ title: branchName,
+ metadata: {
+ lastCommit: head_commit
+ ? {
+ sha: head_commit.id,
+ message: head_commit.message,
+ author: head_commit.author?.name,
+ timestamp: head_commit.timestamp,
+ }
+ : null,
+ },
+ });
+
+ const targetStatus =
+ config.statusTransitions?.onBranchPush || "in-progress";
+ console.log(
+ `[Push] Target status: ${targetStatus}, current: ${task.status}`,
+ );
+
+ if (task.status !== targetStatus && task.status !== "done") {
+ console.log(
+ `[Push] Updating task ${task.id} status from ${task.status} to ${targetStatus}`,
+ );
+ await updateTaskStatus(task.id, targetStatus);
+ } else {
+ console.log(`[Push] Skipping status update - already ${task.status}`);
+ }
- if (!task) {
return;
}
- await createOrUpdateExternalLink({
- taskId: task.id,
- integrationId: integration.id,
- resourceType: "branch",
- externalId: branchName,
- url: `${repository.html_url}/tree/${branchName}`,
- title: branchName,
- metadata: {
- lastCommit: head_commit
- ? {
- sha: head_commit.id,
- message: head_commit.message,
- author: head_commit.author?.name,
- timestamp: head_commit.timestamp,
- }
- : null,
- },
- });
-
- const targetStatus = config.statusTransitions?.onBranchPush || "in-progress";
-
- if (task.status !== targetStatus && task.status !== "done") {
- await updateTaskStatus(task.id, targetStatus);
- }
+ console.log(
+ `[Push] No matching task found in any integrated project for branch: ${branchName}`,
+ );
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 91f75ce47..13476f5ef 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -61,8 +61,8 @@ importers:
specifier: ^1.1.0
version: 1.1.0
'@paralleldrive/cuid2':
- specifier: ^3.0.4
- version: 3.0.4
+ specifier: ^3.0.6
+ version: 3.0.6
'@valibot/to-json-schema':
specifier: ^1.5.0
@@ -71,7 +71,7 @@ importers:
version: 6.0.0
better-auth:
specifier: ^1.4.10
croner:
specifier: ^9.1.0
version: 9.1.0
@@ -79,8 +79,8 @@ importers:
specifier: ^0.31.8
version: 0.31.8
drizzle-orm:
- specifier: ^0.41.0
+ specifier: ^0.45.1
hono:
specifier: ^4.11.3
version: 4.11.3
@@ -122,8 +122,8 @@ importers:
apps/docs:
dependencies:
'@fumadocs/mdx-remote':
- specifier: ^1.4.3
+ specifier: ^1.4.4
'@radix-ui/react-hover-card':
specifier: ^1.1.15
@@ -137,20 +137,20 @@ importers:
specifier: ^2.1.1
version: 2.1.1
fumadocs-core:
- specifier: 16.4.1
+ specifier: 16.4.3
fumadocs-mdx:
- specifier: 14.2.3
+ specifier: 14.2.4
fumadocs-openapi:
- specifier: ^10.2.1
+ specifier: ^10.2.3
fumadocs-twoslash:
specifier: ^3.1.10
fumadocs-ui:
- specifier: 16.4.1
+ specifier: 16.4.3
lucide-react:
specifier: ^0.562.0
version: 0.562.0([email protected])
@@ -229,7 +229,7 @@ importers:
version: 3.2.2([email protected])
'@hookform/resolvers':
specifier: ^5.2.2
'@radix-ui/react-accordion':
specifier: ^1.2.12
@@ -313,7 +313,7 @@ importers:
version: 19.0.0-beta-ebf51a3-20250411
better-auth:
specifier: ^1.4.10
class-variance-authority:
specifier: ^0.7.1
version: 0.7.1
@@ -333,8 +333,8 @@ importers:
specifier: ^12.23.26
hono:
- specifier: ^4.10.4
- version: 4.11.1
+ specifier: ^4.11.3
+ version: 4.11.3
immer:
specifier: ^11.1.0
version: 11.1.3
@@ -345,14 +345,14 @@ importers:
specifier: ^19.2.0
version: 19.2.3
react-day-picker:
- specifier: 9.9.0
- version: 9.9.0([email protected])
+ specifier: 9.13.0
+ version: 9.13.0([email protected])
react-dom:
specifier: ^19.2.0
version: 19.2.3([email protected])
react-hook-form:
- specifier: ^7.69.0
- version: 7.69.0([email protected])
+ specifier: ^7.70.0
+ version: 7.70.0([email protected])
react-use-websocket:
specifier: ^4.11.1
version: 4.13.0
@@ -431,8 +431,8 @@ importers:
version: 19.2.3([email protected])
devDependencies:
'@react-email/preview-server':
- specifier: 5.1.0
+ specifier: 5.1.1
'@types/react':
specifier: ^19.2.7
version: 19.2.7
@@ -440,8 +440,8 @@ importers:
specifier: ^19.2.3
version: 19.2.3(@types/[email protected])
react-email:
- specifier: 5.1.0
- version: 5.1.0
+ specifier: 5.1.1
+ version: 5.1.1
packages/libs:
devDependencies:
@@ -1379,14 +1379,14 @@ packages:
'@floating-ui/[email protected]':
resolution: {integrity: sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==}
- '@formatjs/[email protected]':
- resolution: {integrity: sha512-kzk635kEmsxrrEWQXY7uKRocFCVXR4es5OQqcqCGg2NPtQztG/OBkE9THHu6UOTxpfyIkZhh6DjPBZGRp7y3og==}
+ '@formatjs/[email protected]':
+ resolution: {integrity: sha512-YFApUDWFmjpPwAE7VcY7PYVjm6JaLZOAo0UfCQj1/OGi/1QtduG9kIBHmVC551M6AI01qvuP5kjbDebrZOT4Vg==}
- '@formatjs/[email protected]':
- resolution: {integrity: sha512-NaeABectKdTCOnlH9VFGmMS3K0JuR7Soc2t5R2MCkBrM3H/hlKVYh0XSrcjjPkbjIdrF7L/Bzx9JtGuVaSfYlA==}
+ '@formatjs/[email protected]':
+ resolution: {integrity: sha512-AWsSZupIBMU/y04Nj24CjohyNVyfItMJPxSzX5OJwedDEIbGLOHkPxCjAeLeiLF2dw4xmQA8psktdi9MaebBQw==}
- '@fumadocs/[email protected]':
- resolution: {integrity: sha512-3idm86CegIoDCEygZNmBM8Ekoa0la7pxLA50qvLlzkAyPEkmm7zTMUV/cDaMW0s/uiIHa62rcxVuThc87O8sSg==}
+ '@fumadocs/[email protected]':
+ resolution: {integrity: sha512-tODOw9cYWJkzJ6I+CG16U0QjRmwEVNUavlSn6jUyn4CJ7OjpnFU+jgOiqPm8STFghNYcYVjt3SlrRledGQKR4Q==}
peerDependencies:
'@types/react': '*'
fumadocs-core: ^15.0.0 || ^16.0.0
@@ -1395,8 +1395,8 @@ packages:
'@types/react':
optional: true
- '@fumadocs/[email protected]':
- resolution: {integrity: sha512-biv5/6+7BbAs8yuP3il1JzE+nUkndvC+qFrsX3a08ybqO7bZ0kXkVgr8n6bNmI4Yz8fTy61ZvwEyTqYmPa9Y1g==}
+ '@fumadocs/[email protected]':
+ resolution: {integrity: sha512-KXMWieCzgDc4pchFHf3AXPB589jHAUTz+kOGWTszOqVRBrdX2DQYEFnhJ4PG5KEiLs9dwYmC26VcKHWEGtxqXw==}
peerDependencies:
'@types/react': '*'
next: 16.x.x
@@ -1848,8 +1848,8 @@ packages:
'@oslojs/[email protected]':
resolution: {integrity: sha512-70wQhgYmndg4GCPxPPxPGevRKqTIJ2Nh4OkiMWmDAVYsTQ+Ta7Sq+rPevXyXGdzr30/qZBnyOalCszoMxlyldQ==}
- '@paralleldrive/[email protected]':
- resolution: {integrity: sha512-sM6M2PWrByOEpN2QYAdulhEbSZmChwj0e52u4hpwB7u4PznFiNAavtE6m7O8tWUlzX+jT2eKKtc5/ZgX+IHrtg==}
+ '@paralleldrive/[email protected]':
+ resolution: {integrity: sha512-ujtxTTvr4fwPrzuQT7o6VLKs5BzdWetR9+/zRQ0SyK9hVIwZQllEccxgcHYXN6I3Z429y1yg3F6+uiVxMDPrLQ==}
hasBin: true
'@radix-ui/[email protected]':
@@ -2520,8 +2520,8 @@ packages:
peerDependencies:
react: ^18.0 || ^19.0 || ^19.0.0-rc
- '@react-email/[email protected]':
- resolution: {integrity: sha512-mNqeCjXkU9NdVCtgQnj4l7w426G8xyFH4hejgrWa7wVaIUyVUwh9h9TqlPw9j4aisoBwnOYghbV987ejXd0i4w==}
+ '@react-email/[email protected]':
+ resolution: {integrity: sha512-prMwnjWY9h57HL3MU2NRrj6ePjN7+A23vRwOjpVFczSW5InjitODFG1fRPKpdmIrRtVvj8XHdr7KDW0QXD8tow==}
'@react-email/[email protected]':
resolution: {integrity: sha512-aYK8q0IPkBXyMsbpMXgxazwHxYJxTrXrV95GFuu2HbEiIToMwSyUgb8HDFYwPqqfV03/jbwqlsXmFxsOd+VNaw==}
@@ -3941,8 +3941,8 @@ packages:
resolution: {integrity: sha512-O9EC/miwdnRDY10qRxM8P3Pg8hXe3LyU4ZipReKOgTwn4OqANmftj8XJz1UPUAS6NMHf0E2htjsbQujUTkncCg==}
hasBin: true
- resolution: {integrity: sha512-7A4ZxhHk9gdlXmTdPj/lREtP+3u8KvZ4yEN6MYVxBzZGex5Wtdc+CWSbu7btgF6TB0N+MNPrvW7RKBbxJchs/Q==}
+ resolution: {integrity: sha512-Te0FOdKIistGNPMq2jscdqngBRfBpC8uMFVwqjf6gtTVJHIQ/dosgV/CLBU2N4ZJBsXL5savCba9b0YJskKdcA==}
peerDependencies:
'@aws-sdk/client-rds-data': '>=3'
'@cloudflare/workers-types': '>=4'
@@ -3952,12 +3952,13 @@ packages:
'@neondatabase/serverless': '>=0.10.0'
'@op-engineering/op-sqlite': '>=2'
'@opentelemetry/api': ^1.4.1
- '@planetscale/database': '>=1'
+ '@planetscale/database': '>=1.13'
'@prisma/client': '*'
'@tidbcloud/serverless': '*'
'@types/better-sqlite3': '*'
'@types/pg': '*'
'@types/sql.js': '*'
+ '@upstash/redis': '>=1.34.7'
'@vercel/postgres': '>=0.8.0'
'@xata.io/client': '*'
better-sqlite3: '>=7'
@@ -4001,6 +4002,8 @@ packages:
optional: true
'@types/sql.js':
optional: true
+ '@upstash/redis':
+ optional: true
'@vercel/postgres':
optional: true
'@xata.io/client':
@@ -4238,11 +4241,12 @@ packages:
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
- resolution: {integrity: sha512-qx86oRMNg9doSa0WJhkCnXm2OwOZCSYKWqzTWyisZmzy8b4YBuPYx90OMvpI34nIcNNsoLqtWk3NchB6C9kMhg==}
+ resolution: {integrity: sha512-EAiUdV4XScVdoG/OdN2s3BdjTWZtmbywy1E1cQ7AAlbwZglOAgH8M0a8BwMllmt9ScT5co85z76D4Hdy9XN//g==}
peerDependencies:
'@mixedbread/sdk': ^0.46.0
'@orama/core': 1.x.x
+ '@oramacloud/client': 2.x.x
'@tanstack/react-router': 1.x.x
'@types/react': '*'
algoliasearch: 5.x.x
@@ -4258,6 +4262,8 @@ packages:
optional: true
'@orama/core':
optional: true
+ '@oramacloud/client':
+ optional: true
'@tanstack/react-router':
optional: true
'@types/react':
@@ -4279,8 +4285,8 @@ packages:
zod:
optional: true
- resolution: {integrity: sha512-O69DI58bRuCYjvxs/ERer0cclBFup9LEDfO5gPgIaRqFyHxaEuVvV+1D/DOE/ZgtP2rFwUsjM4bST59RAcwgDA==}
+ resolution: {integrity: sha512-YuDgzTopMuOOQmOhvOUfmXn2RryZY5Ev+9uwAzTBEYcLIpxIBxZl0/jHaLoYdlOMBM65AO6OBngA2SucC2hkIQ==}
hasBin: true
peerDependencies:
'@fumadocs/mdx-remote': ^1.4.0
@@ -4301,8 +4307,8 @@ packages:
vite:
optional: true
- resolution: {integrity: sha512-cWmcoyOxoVMW6kezmYLuTe4W2tb0oTXlGBnCQFn5LgUS5+fTCf/HxnUImvGDTKt7zqoVPc8agjxv5vknDWua8Q==}
+ resolution: {integrity: sha512-si/dJ6SGGuZTp8CP3VzYIdn2iQU2H6ysGg09PCWq2YvoV6TEDWQki+PIpCVeUnIvM1VLG13Lih2SsFuh3ao19A==}
peerDependencies:
'@scalar/api-client-react': '*'
'@types/react': '*'
@@ -4326,8 +4332,8 @@ packages:
'@types/react':
optional: true
- resolution: {integrity: sha512-4nU0GLrjNnQDuokj3t80numrExE2b12lDZVLaEjolnJEjxDTjw5U7utYx09ylJ/NgzNB7Ithj/aTY8bPeDiGoA==}
+ resolution: {integrity: sha512-xO6nrP/P++8ktncST5cnT/WmBYPCAmu+0cAGX1lf0/gYgBvnkRyDxNiLnpOGwL2+cWooa3+qI+1+lGME9kBeWg==}
peerDependencies:
'@types/react': '*'
react: ^19.2.0
@@ -4467,10 +4473,6 @@ packages:
hono:
optional: true
- resolution: {integrity: sha512-KsFcH0xxHes0J4zaQgWbYwmz3UPOOskdqZmItstUG93+Wk1ePBLkLGwbP9zlmh1BFUiL8Qp+Xfu9P7feJWpGNg==}
- engines: {node: '>=16.9.0'}
-
resolution: {integrity: sha512-PmQi306+M/ct/m5s66Hrg+adPnkD5jiO6IjA7WhWw0gSBSo1EcRegwuI1deZ+wd5pzCGynCcn2DprnE4/yEV4w==}
engines: {node: '>=16.9.0'}
@@ -5127,8 +5129,8 @@ packages:
resolution: {integrity: sha512-tt6PvKu4WyzPwWUzy/hvPFqn+uwXO0K1ZHka8az3NnrhWJDmSqI8ncWq0fkL0k/lmmi5tAC11FXwXuh0rFbt1A==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
- resolution: {integrity: sha512-mn8wBFV9G9+UFHIrq+pZ2r2zL4aPau/by3kJb3cM7+5tQHMt6HGQB8FDIeKFYp8o0D2pnH6nVsO88N4AmUxIWg==}
+ resolution: {integrity: sha512-7eM+hpOtrKrBDCh7Ypu2lJ9Z7PNZBdi/8AT3AX8xoCj43BBVHD0hPSTEvMtkMpfs8FCqBGhxB+uToIQimA111g==}
engines: {node: ^14.16.0 || >=16.10.0}
hasBin: true
@@ -5413,8 +5415,8 @@ packages:
resolution: {integrity: sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==}
- resolution: {integrity: sha512-NtkJbuX6cl/VaGNb3sVVhmMA6LSMnL5G3xNL+61IyoZj0mUZFWTg4hmj7PHjIQ8MXN9dHWhUHFoJWG6y60DKSg==}
+ resolution: {integrity: sha512-euzj5Hlq+lOHqI53NiuNhCP8HWgsPf/bBAVijR50hNaY1XwjKjShAnIe8jm8RD2W9IJUvihDIZ+KrmqfFzNhFQ==}
engines: {node: '>=18'}
peerDependencies:
react: '>=16.8.0'
@@ -5424,13 +5426,13 @@ packages:
peerDependencies:
react: ^19.2.3
- resolution: {integrity: sha512-uVvtKcea0kd+QRwH5/Cw/znnijIge+Jog0IFagi0JiZgQ/GrDQ/qD98AwGVV1vM3hGbSugOvmcMayamFc4Zz1g==}
+ resolution: {integrity: sha512-NUwnOXyxCJtr2xJO4uiEVmBwRg00rgvV2WZe6Z+a2HqGeTTOiLpKoQOvroKGFzUemkQKQlVRFPdPvSK/1uanmw==}
engines: {node: '>=20.0.0'}
hasBin: true
- resolution: {integrity: sha512-yt6ZGME9f4F6WHwevrvpAjh42HMvocuSnSIHUGycBqXIJdhqGSPQzTpGF+1NLREk/58IdPxEMfPcFCjlMhclGw==}
+ resolution: {integrity: sha512-COOMajS4FI3Wuwrs3GPpi/Jeef/5W1DRR84Yl5/ShlT3dKVFUfoGiEZ/QE6Uw8P4T2/CLJdcTVYKvWBMQTEpvw==}
engines: {node: '>=18.0.0'}
peerDependencies:
react: ^16.8.0 || ^17 || ^18 || ^19
@@ -5830,9 +5832,6 @@ packages:
resolution: {integrity: sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==}
- resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==}
-
resolution: {integrity: sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==}
engines: {node: '>=18'}
@@ -6883,7 +6882,7 @@ snapshots:
lucide-react: 0.525.0([email protected])
react: 19.2.3
react-dom: 19.2.3([email protected])
- react-hook-form: 7.69.0([email protected])
+ react-hook-form: 7.70.0([email protected])
tailwind-merge: 2.6.0
tailwindcss: 4.1.18
zod: 3.25.76
@@ -7311,19 +7310,19 @@ snapshots:
'@floating-ui/[email protected]': {}
- '@formatjs/[email protected]':
+ '@formatjs/[email protected]':
dependencies:
tslib: 2.8.1
- '@formatjs/[email protected]':
+ '@formatjs/[email protected]':
dependencies:
- '@formatjs/fast-memoize': 3.0.1
+ '@formatjs/fast-memoize': 3.0.2
tslib: 2.8.1
dependencies:
'@mdx-js/mdx': 3.1.1
gray-matter: 4.0.3
react: 19.2.3
zod: 4.3.5
@@ -7332,10 +7331,9 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
- lodash.merge: 4.6.2
postcss-selector-parser: 7.1.1
react: 19.2.3
@@ -7348,6 +7346,7 @@ snapshots:
transitivePeerDependencies:
- '@mixedbread/sdk'
- '@orama/core'
+ - '@oramacloud/client'
- '@tanstack/react-router'
- algoliasearch
- lucide-react
@@ -7379,10 +7378,10 @@ snapshots:
'@standard-schema/spec': 1.1.0
hono: 4.11.3
dependencies:
'@standard-schema/utils': 0.3.0
- react-hook-form: 7.69.0([email protected])
+ react-hook-form: 7.70.0([email protected])
optional: true
@@ -7763,7 +7762,7 @@ snapshots:
'@oslojs/[email protected]': {}
- '@paralleldrive/[email protected]':
+ '@paralleldrive/[email protected]':
dependencies:
'@noble/hashes': 2.0.1
bignumber.js: 9.3.1
@@ -8451,7 +8450,7 @@ snapshots:
marked: 15.0.12
react: 19.2.3
dependencies:
transitivePeerDependencies:
@@ -9559,7 +9558,7 @@ snapshots:
dependencies:
@@ -9575,7 +9574,7 @@ snapshots:
zod: 4.3.5
optionalDependencies:
drizzle-kit: 0.31.8
pg: 8.16.3
react: 19.2.3
@@ -9866,7 +9865,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
optionalDependencies:
'@types/pg': 8.16.0
kysely: 0.28.9
@@ -10143,9 +10142,9 @@ snapshots:
optional: true
dependencies:
- '@formatjs/intl-localematcher': 0.7.3
+ '@formatjs/intl-localematcher': 0.7.4
'@orama/orama': 3.1.18
'@shikijs/rehype': 3.20.0
'@shikijs/transformers': 3.20.0
@@ -10162,6 +10161,7 @@ snapshots:
remark-rehype: 11.1.2
scroll-into-view-if-needed: 3.1.0
shiki: 3.20.0
+ tinyglobby: 0.2.15
unist-util-visit: 5.0.0
optionalDependencies:
'@tanstack/react-router': 1.144.0([email protected]([email protected]))([email protected])
@@ -10174,14 +10174,14 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@mdx-js/mdx': 3.1.1
'@standard-schema/spec': 1.1.0
chokidar: 5.0.0
esbuild: 0.27.2
estree-util-value-to-estree: 3.5.0
js-yaml: 4.1.1
mdast-util-to-markdown: 2.1.2
picocolors: 1.1.1
@@ -10195,7 +10195,7 @@ snapshots:
vfile: 6.0.3
zod: 4.3.5
optionalDependencies:
'@types/react': 19.2.7
react: 19.2.3
@@ -10203,7 +10203,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@fumari/json-schema-to-typescript': 2.0.0([email protected])
@@ -10214,16 +10214,17 @@ snapshots:
'@scalar/openapi-parser': 0.23.9
ajv: 8.17.1
class-variance-authority: 0.7.1
github-slugger: 2.0.0
hast-util-to-jsx-runtime: 2.3.6
js-yaml: 4.1.1
+ lucide-react: 0.562.0([email protected])
openapi-sampler: 1.6.2
react: 19.2.3
react-dom: 19.2.3([email protected])
- react-hook-form: 7.69.0([email protected])
+ react-hook-form: 7.70.0([email protected])
remark: 15.0.1
remark-rehype: 11.1.2
tailwind-merge: 3.4.0
@@ -10236,11 +10237,11 @@ snapshots:
- prettier
- supports-color
dependencies:
'@shikijs/twoslash': 3.20.0([email protected])
mdast-util-from-markdown: 2.0.2
mdast-util-gfm: 3.1.0
mdast-util-to-hast: 13.2.1
@@ -10256,9 +10257,9 @@ snapshots:
- supports-color
- typescript
dependencies:
@@ -10270,7 +10271,8 @@ snapshots:
'@radix-ui/react-slot': 1.2.4(@types/[email protected])([email protected])
class-variance-authority: 0.7.1
+ lucide-react: 0.562.0([email protected])
react: 19.2.3
react-dom: 19.2.3([email protected])
@@ -10282,10 +10284,10 @@ snapshots:
transitivePeerDependencies:
- '@mixedbread/sdk'
- '@orama/core'
+ - '@oramacloud/client'
- '@tanstack/react-router'
- '@types/react-dom'
- algoliasearch
- - lucide-react
- next
- react-router
- supports-color
@@ -10522,8 +10524,6 @@ snapshots:
'@hono/standard-validator': 0.2.1(@standard-schema/[email protected])([email protected])
hono: 4.11.3
-
@@ -11330,13 +11330,13 @@ snapshots:
dependencies:
citty: 0.1.6
consola: 3.4.2
pathe: 2.0.3
pkg-types: 2.3.0
- tinyexec: 0.3.2
+ tinyexec: 1.0.2
@@ -11655,7 +11655,7 @@ snapshots:
dependencies:
'@date-fns/tz': 1.4.1
date-fns: 4.1.0
@@ -11667,7 +11667,7 @@ snapshots:
react: 19.2.3
scheduler: 0.27.0
dependencies:
'@babel/parser': 7.28.5
'@babel/traverse': 7.28.5
@@ -11681,7 +11681,7 @@ snapshots:
log-symbols: 7.0.1
mime-types: 3.0.2
normalize-path: 3.0.0
- nypm: 0.6.0
+ nypm: 0.6.2
ora: 8.2.0
prompts: 2.4.2
socket.io: 4.8.1
@@ -11691,7 +11691,7 @@ snapshots:
- supports-color
- utf-8-validate
dependencies:
react: 19.2.3
@@ -12197,8 +12197,6 @@ snapshots:
-