Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ae08207
refactor(trpc): extract shared tRPC client setup to @superset/trpc/cl…
Kitenite Feb 13, 2026
ae60b73
refactor(db): extract findOrgMembership to deduplicate membership checks
Kitenite Feb 13, 2026
fff2be2
refactor(trpc): extract shared image upload utility
Kitenite Feb 13, 2026
dcce28f
refactor(mcp): deduplicate task tools (priority enums, UUID/slug reso…
Kitenite Feb 13, 2026
5827f12
refactor(trpc): extract disconnectIntegration utility for linear/slack
Kitenite Feb 13, 2026
a0013e3
refactor(shared): consolidate DEVICE_ONLINE_THRESHOLD_MS constant
Kitenite Feb 13, 2026
90ac3de
Marketing refactor
Kitenite Feb 13, 2026
8ea3b3a
date fallback
Kitenite Feb 13, 2026
515abc9
fix(trpc): align react and @types/react versions with monorepo
Kitenite Feb 13, 2026
762458c
Merge remote-tracking branch 'origin' into kitenite/duplicate-logic
Kitenite Feb 13, 2026
d0a268b
Revert "fix(trpc): align react and @types/react versions with monorepo"
Kitenite Feb 13, 2026
bc33874
Revert "refactor(shared): consolidate DEVICE_ONLINE_THRESHOLD_MS cons…
Kitenite Feb 13, 2026
f945a5b
Revert "refactor(trpc): extract disconnectIntegration utility for lin…
Kitenite Feb 13, 2026
d53c8a9
Revert "refactor(mcp): deduplicate task tools (priority enums, UUID/s…
Kitenite Feb 13, 2026
8087964
Revert "refactor(trpc): extract shared tRPC client setup to @superset…
Kitenite Feb 13, 2026
73a2dc7
Cleanup
Kitenite Feb 13, 2026
03f19c9
Merge remote-tracking branch 'origin' into kitenite/duplicate-logic
Kitenite Feb 13, 2026
e7f4f4d
fix(mcp): add missing @superset/shared dependency for claude-command …
Kitenite Feb 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions apps/api/src/app/api/github/install/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { auth } from "@superset/auth/server";
import { db } from "@superset/db/client";
import { members } from "@superset/db/schema";
import { and, eq } from "drizzle-orm";
import { findOrgMembership } from "@superset/db/utils";

import { env } from "@/env";
import { createSignedState } from "@/lib/oauth-state";
Expand All @@ -23,11 +21,9 @@ export async function GET(request: Request) {
);
}

const membership = await db.query.members.findFirst({
where: and(
eq(members.organizationId, organizationId),
eq(members.userId, session.user.id),
),
const membership = await findOrgMembership({
userId: session.user.id,
organizationId,
});

if (!membership) {
Expand Down
12 changes: 4 additions & 8 deletions apps/api/src/app/api/integrations/linear/connect/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { auth } from "@superset/auth/server";
import { db } from "@superset/db/client";
import { members } from "@superset/db/schema";
import { and, eq } from "drizzle-orm";
import { findOrgMembership } from "@superset/db/utils";

import { env } from "@/env";
import { createSignedState } from "@/lib/oauth-state";
Expand All @@ -25,11 +23,9 @@ export async function GET(request: Request) {
);
}

const membership = await db.query.members.findFirst({
where: and(
eq(members.organizationId, organizationId),
eq(members.userId, session.user.id),
),
const membership = await findOrgMembership({
userId: session.user.id,
organizationId,
});

if (!membership) {
Expand Down
11 changes: 2 additions & 9 deletions apps/api/src/app/api/integrations/slack/connect/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { auth } from "@superset/auth/server";
import { db } from "@superset/db/client";
import { members } from "@superset/db/schema";
import { and, eq } from "drizzle-orm";
import { findOrgMembership } from "@superset/db/utils";

import { env } from "@/env";
import { createSignedState } from "@/lib/oauth-state";
Expand Down Expand Up @@ -42,12 +40,7 @@ export async function GET(request: Request) {

const userId = session.user.id;

const membership = await db.query.members.findFirst({
where: and(
eq(members.organizationId, organizationId),
eq(members.userId, userId),
),
});
const membership = await findOrgMembership({ userId, organizationId });

if (!membership) {
return Response.json(
Expand Down
15 changes: 5 additions & 10 deletions apps/api/src/app/api/integrations/slack/link/route.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { createHmac } from "node:crypto";
import { auth } from "@superset/auth/server";
import { db } from "@superset/db/client";
import {
integrationConnections,
members,
usersSlackUsers,
} from "@superset/db/schema";
import { integrationConnections, usersSlackUsers } from "@superset/db/schema";
import { findOrgMembership } from "@superset/db/utils";
import { and, eq } from "drizzle-orm";
import { headers } from "next/headers";
import { env } from "@/env";
Expand Down Expand Up @@ -65,11 +62,9 @@ export async function GET(request: Request) {
);
}

const membership = await db.query.members.findFirst({
where: and(
eq(members.organizationId, connection.organizationId),
eq(members.userId, session.user.id),
),
const membership = await findOrgMembership({
userId: session.user.id,
organizationId: connection.organizationId,
});

if (!membership) {
Expand Down
16 changes: 4 additions & 12 deletions apps/marketing/src/lib/blog-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import type { BlogCategory } from "./blog-constants";
import { formatContentDate } from "./content-utils";
import type { Person } from "./people";

export interface TocItem {
Expand All @@ -25,17 +26,8 @@ export interface BlogPost {
content: string;
}

export function formatBlogDate(date: string): string {
return new Date(date).toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
});
}
export { slugify } from "./content-utils";

export function slugify(text: string): string {
return text
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/(^-|-$)/g, "");
export function formatBlogDate(date: string): string {
return formatContentDate(date, "short");
}
11 changes: 2 additions & 9 deletions apps/marketing/src/lib/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from "node:fs";
import path from "node:path";
import matter from "gray-matter";
import { type BlogPost, slugify, type TocItem } from "./blog-utils";
import { normalizeContentDate } from "./content-utils";
import { getPersonById } from "./people";

export { BLOG_CATEGORIES, type BlogCategory } from "./blog-constants";
Expand All @@ -21,15 +22,7 @@ function parseFrontmatter(filePath: string): BlogPost | null {
const { data, content } = matter(fileContent);

const slug = path.basename(filePath, ".mdx");

let dateValue: string;
if (data.date instanceof Date) {
dateValue = data.date.toISOString().split("T")[0] as string;
} else if (data.date) {
dateValue = String(data.date);
} else {
dateValue = new Date().toISOString().split("T")[0] as string;
}
const dateValue = normalizeContentDate(data.date) as string;

const authorId: string = data.author ?? "unknown";
const author = getPersonById(authorId) ?? {
Expand Down
17 changes: 5 additions & 12 deletions apps/marketing/src/lib/changelog-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* These can be safely imported in both server and client components.
*/

import { formatContentDate } from "./content-utils";

export interface ChangelogEntry {
slug: string;
url: string;
Expand All @@ -13,17 +15,8 @@ export interface ChangelogEntry {
content: string;
}

export function formatChangelogDate(date: string): string {
return new Date(date).toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
});
}
export { slugify } from "./content-utils";

export function slugify(text: string): string {
return text
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/(^-|-$)/g, "");
export function formatChangelogDate(date: string): string {
return formatContentDate(date, "long");
}
11 changes: 2 additions & 9 deletions apps/marketing/src/lib/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from "node:fs";
import path from "node:path";
import matter from "gray-matter";
import { type ChangelogEntry, slugify } from "./changelog-utils";
import { normalizeContentDate } from "./content-utils";

export {
type ChangelogEntry,
Expand All @@ -17,15 +18,7 @@ function parseFrontmatter(filePath: string): ChangelogEntry | null {
const { data, content } = matter(fileContent);

const slug = path.basename(filePath, ".mdx");

let dateValue: string;
if (data.date instanceof Date) {
dateValue = data.date.toISOString().split("T")[0] as string;
} else if (data.date) {
dateValue = String(data.date);
} else {
dateValue = new Date().toISOString().split("T")[0] as string;
}
const dateValue = normalizeContentDate(data.date) as string;

return {
slug,
Expand Down
8 changes: 3 additions & 5 deletions apps/marketing/src/lib/compare-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* These can be safely imported in both server and client components.
*/

import { formatContentDate } from "./content-utils";

export interface ComparisonPage {
slug: string;
url: string;
Expand All @@ -18,9 +20,5 @@ export interface ComparisonPage {
}

export function formatCompareDate(date: string): string {
return new Date(date).toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
});
return formatContentDate(date, "short");
}
21 changes: 5 additions & 16 deletions apps/marketing/src/lib/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from "node:path";
import matter from "gray-matter";
import { slugify, type TocItem } from "./blog-utils";
import type { ComparisonPage } from "./compare-utils";
import { normalizeContentDate } from "./content-utils";

export { type ComparisonPage, formatCompareDate } from "./compare-utils";

Expand All @@ -14,22 +15,10 @@ function parseFrontmatter(filePath: string): ComparisonPage | null {
const { data, content } = matter(fileContent);

const slug = path.basename(filePath, ".mdx");

let dateValue: string;
if (data.date instanceof Date) {
dateValue = data.date.toISOString().split("T")[0] as string;
} else if (data.date) {
dateValue = String(data.date);
} else {
dateValue = new Date().toISOString().split("T")[0] as string;
}

let lastUpdated: string | undefined;
if (data.lastUpdated instanceof Date) {
lastUpdated = data.lastUpdated.toISOString().split("T")[0] as string;
} else if (data.lastUpdated) {
lastUpdated = String(data.lastUpdated);
}
const dateValue = normalizeContentDate(data.date) as string;
const lastUpdated = normalizeContentDate(data.lastUpdated, {
fallbackToNow: false,
});

return {
slug,
Expand Down
46 changes: 46 additions & 0 deletions apps/marketing/src/lib/content-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const MONTH_SHORT = "short";
const _MONTH_LONG = "long";

export function formatContentDate(
date: string,
monthStyle: "short" | "long" = MONTH_SHORT,
): string {
return new Date(date).toLocaleDateString("en-US", {
year: "numeric",
month: monthStyle,
day: "numeric",
});
}

export function slugify(text: string): string {
return text
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/(^-|-$)/g, "");
}

function toDateInput(dateValue: Date | string | number): string {
return new Date(dateValue).toISOString().split("T")[0] as string;
}

export function normalizeContentDate(
value: unknown,
options: { fallbackToNow?: boolean } = {},
): string | undefined {
const { fallbackToNow = true } = options;
const fallback = fallbackToNow ? toDateInput(Date.now()) : undefined;

if (value instanceof Date) {
return toDateInput(value);
}

if (typeof value === "string" || typeof value === "number") {
return value ? String(value) : fallback;
}

if (value) {
return String(value);
}

return fallback;
}
1 change: 0 additions & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/db/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./membership";
export * from "./sql";
19 changes: 19 additions & 0 deletions packages/db/src/utils/membership.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { and, eq } from "drizzle-orm";

import { db } from "../client";
import { members } from "../schema";

export async function findOrgMembership({
userId,
organizationId,
}: {
userId: string;
organizationId: string;
}) {
return db.query.members.findFirst({
where: and(
eq(members.organizationId, organizationId),
eq(members.userId, userId),
),
});
}
Loading