Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions apps/docs/app/[lang]/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { findNeighbour } from 'fumadocs-core/server'
import { findNeighbour } from 'fumadocs-core/page-tree'
import defaultMdxComponents from 'fumadocs-ui/mdx'
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/page'
import { ChevronLeft, ChevronRight } from 'lucide-react'
Expand Down Expand Up @@ -186,9 +186,6 @@ export default async function Page(props: { params: Promise<{ slug?: string[]; l
footer: <TOCFooter />,
single: false,
}}
article={{
className: 'scroll-smooth max-sm:pb-16',
}}
tableOfContentPopover={{
style: 'clerk',
enabled: true,
Expand Down
18 changes: 5 additions & 13 deletions apps/docs/components/docs-layout/sidebar-components.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { type ReactNode, useEffect, useState } from 'react'
import type { PageTree } from 'fumadocs-core/server'
import type { Folder, Item, Separator } from 'fumadocs-core/page-tree'
import { ChevronRight } from 'lucide-react'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
Expand All @@ -11,7 +11,7 @@ function isActive(url: string, pathname: string, nested = true): boolean {
return url === pathname || (nested && pathname.startsWith(`${url}/`))
}

export function SidebarItem({ item }: { item: PageTree.Item }) {
export function SidebarItem({ item }: { item: Item }) {
const pathname = usePathname()
const active = isActive(item.url, pathname, false)

Expand All @@ -33,15 +33,7 @@ export function SidebarItem({ item }: { item: PageTree.Item }) {
)
}

export function SidebarFolder({
item,
level,
children,
}: {
item: PageTree.Folder
level: number
children: ReactNode
}) {
export function SidebarFolder({ item, children }: { item: Folder; children: ReactNode }) {
const pathname = usePathname()
const hasActiveChild = checkHasActiveChild(item, pathname)
const [open, setOpen] = useState(hasActiveChild)
Expand Down Expand Up @@ -112,15 +104,15 @@ export function SidebarFolder({
)
}

export function SidebarSeparator({ item }: { item: PageTree.Separator }) {
export function SidebarSeparator({ item }: { item: Separator }) {
return (
<p className='mt-4 mb-1.5 px-2.5 font-semibold text-[10px] text-gray-500/80 uppercase tracking-wide dark:text-gray-500'>
{item.name}
</p>
)
}

function checkHasActiveChild(node: PageTree.Folder, pathname: string): boolean {
function checkHasActiveChild(node: Folder, pathname: string): boolean {
if (node.index && isActive(node.index.url, pathname)) {
return true
}
Expand Down
5 changes: 2 additions & 3 deletions apps/docs/lib/llms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import type { InferPageType } from 'fumadocs-core/source'
import type { source } from '@/lib/source'

export async function getLLMText(page: InferPageType<typeof source>) {
const processed = await page.data.getText('processed')
return `# ${page.data.title} (${page.url})

${page.data.description || ''}

${page.data.content || ''}`
${processed}`
}
2 changes: 1 addition & 1 deletion apps/docs/lib/source.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { loader } from 'fumadocs-core/source'
import { docs } from '@/.source'
import { docs } from '@/.source/server'
import { i18n } from './i18n'

export const source = loader({
Expand Down
7 changes: 5 additions & 2 deletions apps/docs/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ const config = {
destination: '/introduction',
permanent: true,
},
]
},
async rewrites() {
return [
{
source: '/docs/:path*.mdx',
source: '/:path*.mdx',
destination: '/llms.mdx/:path*',
permanent: true,
},
]
},
Expand Down
14 changes: 7 additions & 7 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "Apache-2.0",
"scripts": {
"dev": "next dev --port 3001",
"build": "NODE_OPTIONS='--max-old-space-size=8192' next build",
"build": "fumadocs-mdx && NODE_OPTIONS='--max-old-space-size=8192' next build",
"start": "next start",
"postinstall": "fumadocs-mdx",
"type-check": "tsc --noEmit"
Expand All @@ -14,14 +14,14 @@
"@tabler/icons-react": "^3.31.0",
"@vercel/og": "^0.6.5",
"clsx": "^2.1.1",
"fumadocs-core": "15.8.2",
"fumadocs-mdx": "11.10.1",
"fumadocs-ui": "15.8.2",
"fumadocs-core": "16.2.3",
"fumadocs-mdx": "14.1.0",
"fumadocs-ui": "16.2.3",
"lucide-react": "^0.511.0",
"next": "15.4.8",
"next": "16.0.7",
"next-themes": "^0.4.6",
"react": "19.1.0",
"react-dom": "19.1.0",
"react": "19.2.1",
"react-dom": "19.2.1",
"tailwind-merge": "^3.0.2"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/middleware.ts → apps/docs/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { type NextFetchEvent, type NextRequest, NextResponse } from 'next/server
import { i18n } from '@/lib/i18n'

const { rewrite: rewriteLLM } = rewritePath('/docs/*path', '/llms.mdx/*path')
const i18nMiddleware = createI18nMiddleware(i18n)
const i18nProxy = createI18nMiddleware(i18n)

export default function middleware(request: NextRequest, event: NextFetchEvent) {
export default function proxy(request: NextRequest, event: NextFetchEvent) {
if (isMarkdownPreferred(request)) {
const result = rewriteLLM(request.nextUrl.pathname)

Expand All @@ -15,7 +15,7 @@ export default function middleware(request: NextRequest, event: NextFetchEvent)
}
}

return i18nMiddleware(request, event)
return i18nProxy(request, event)
}

export const config = {
Expand Down
5 changes: 5 additions & 0 deletions apps/docs/source.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { defineConfig, defineDocs } from 'fumadocs-mdx/config'

export const docs = defineDocs({
dir: 'content/docs',
docs: {
postprocess: {
includeProcessedMarkdown: true,
},
},
})

export default defineConfig({
Expand Down
7 changes: 4 additions & 3 deletions apps/docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react-jsx",
"incremental": true,
"paths": {
"@/.source": ["./.source/index.ts"],
"@/.source/*": ["./.source/*"],
"@/*": ["./*"]
},
"plugins": [
Expand All @@ -31,7 +31,8 @@
"**/*.tsx",
".next/types/**/*.ts",
"content/docs/execution/index.mdx",
"content/docs/connections/index.mdx"
"content/docs/connections/index.mdx",
".next/dev/types/**/*.ts"
],
"exclude": ["node_modules"]
}
10 changes: 3 additions & 7 deletions apps/sim/app/api/mcp/servers/[id]/refresh/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ export const dynamic = 'force-dynamic'
/**
* POST - Refresh an MCP server connection (requires any workspace permission)
*/
export const POST = withMcpAuth('read')(
async (
request: NextRequest,
{ userId, workspaceId, requestId },
{ params }: { params: { id: string } }
) => {
const serverId = params.id
export const POST = withMcpAuth<{ id: string }>('read')(
async (request: NextRequest, { userId, workspaceId, requestId }, { params }) => {
const { id: serverId } = await params

try {
logger.info(
Expand Down
10 changes: 3 additions & 7 deletions apps/sim/app/api/mcp/servers/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ export const dynamic = 'force-dynamic'
/**
* PATCH - Update an MCP server in the workspace (requires write or admin permission)
*/
export const PATCH = withMcpAuth('write')(
async (
request: NextRequest,
{ userId, workspaceId, requestId },
{ params }: { params: { id: string } }
) => {
const serverId = params.id
export const PATCH = withMcpAuth<{ id: string }>('write')(
async (request: NextRequest, { userId, workspaceId, requestId }, { params }) => {
const { id: serverId } = await params

try {
const body = getParsedBody(request) || (await request.json())
Expand Down
5 changes: 2 additions & 3 deletions apps/sim/app/api/workflows/[id]/paused/[executionId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ export async function GET(
{
params,
}: {
params: { id: string; executionId: string }
params: Promise<{ id: string; executionId: string }>
}
) {
const workflowId = params.id
const executionId = params.executionId
const { id: workflowId, executionId } = await params

const access = await validateWorkflowAccess(request, workflowId, false)
if (access.error) {
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/app/api/workflows/[id]/paused/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export async function GET(
{
params,
}: {
params: { id: string }
params: Promise<{ id: string }>
}
) {
const workflowId = params.id
const { id: workflowId } = await params

const access = await validateWorkflowAccess(request, workflowId, false)
if (access.error) {
Expand Down
14 changes: 8 additions & 6 deletions apps/sim/lib/mcp/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export interface McpAuthContext {
requestId: string
}

export type McpRouteHandler = (
export type McpRouteHandler<TParams = Record<string, string>> = (
request: NextRequest,
context: McpAuthContext,
...args: any[]
routeContext: { params: Promise<TParams> }
) => Promise<NextResponse>

interface AuthResult {
Expand Down Expand Up @@ -170,11 +170,13 @@ function getPermissionErrorMessage(permissionLevel: McpPermissionLevel): string
* @returns Middleware wrapper function
*
*/
export function withMcpAuth(permissionLevel: McpPermissionLevel = 'read') {
return function middleware(handler: McpRouteHandler) {
export function withMcpAuth<TParams = Record<string, string>>(
permissionLevel: McpPermissionLevel = 'read'
) {
return function middleware(handler: McpRouteHandler<TParams>) {
return async function wrappedHandler(
request: NextRequest,
...args: any[]
routeContext: { params: Promise<TParams> }
): Promise<NextResponse> {
const authResult = await validateMcpAuth(request, permissionLevel)

Expand All @@ -183,7 +185,7 @@ export function withMcpAuth(permissionLevel: McpPermissionLevel = 'read') {
}

try {
return await handler(request, (authResult as AuthResult).context, ...args)
return await handler(request, (authResult as AuthResult).context, routeContext)
} catch (error) {
logger.error(
`[${(authResult as AuthResult).context.requestId}] Error in MCP route handler:`,
Expand Down
13 changes: 9 additions & 4 deletions apps/sim/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,22 @@ const nextConfig: NextConfig = {
typescript: {
ignoreBuildErrors: isTruthy(env.DOCKER_BUILD),
},
eslint: {
ignoreDuringBuilds: isTruthy(env.DOCKER_BUILD),
},
output: isTruthy(env.DOCKER_BUILD) ? 'standalone' : undefined,
turbopack: {
resolveExtensions: ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.json'],
},
serverExternalPackages: ['unpdf', 'ffmpeg-static', 'fluent-ffmpeg'],
serverExternalPackages: [
'unpdf',
'ffmpeg-static',
'fluent-ffmpeg',
'pino',
'pino-pretty',
'thread-stream',
],
experimental: {
optimizeCss: true,
turbopackSourceMaps: false,
turbopackFileSystemCacheForDev: true,
},
...(isDev && {
allowedDevOrigins: [
Expand Down
16 changes: 8 additions & 8 deletions apps/sim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"node": ">=20.0.0"
},
"scripts": {
"dev": "next dev --turbo --port 3000",
"dev:classic": "next dev",
"dev": "next dev --port 3000",
"dev:webpack": "next dev --webpack",
"dev:sockets": "bun run socket-server/index.ts",
"dev:full": "concurrently -n \"App,Realtime\" -c \"cyan,magenta\" \"bun run dev\" \"bun run dev:sockets\"",
"build": "next build --turbopack",
"build": "next build",
"start": "next start",
"prepare": "cd ../.. && bun husky",
"test": "vitest run",
Expand Down Expand Up @@ -98,7 +98,7 @@
"mammoth": "^1.9.0",
"mysql2": "3.14.3",
"nanoid": "^3.3.7",
"next": "15.4.8",
"next": "16.0.7",
"next-mdx-remote": "^5.0.0",
"next-runtime-env": "3.3.0",
"next-themes": "^0.4.6",
Expand All @@ -108,9 +108,9 @@
"posthog-js": "1.268.9",
"posthog-node": "5.9.2",
"prismjs": "^1.30.0",
"react": "19.1.0",
"react": "19.2.1",
"react-colorful": "5.6.1",
"react-dom": "19.1.0",
"react-dom": "19.2.1",
"react-google-drive-picker": "^1.2.2",
"react-hook-form": "^7.54.2",
"react-markdown": "^10.1.0",
Expand Down Expand Up @@ -166,8 +166,8 @@
"sharp"
],
"overrides": {
"next": "15.4.8",
"@next/env": "15.4.8",
"next": "16.0.7",
"@next/env": "16.0.7",
"drizzle-orm": "^0.44.5",
"postgres": "^3.4.5"
}
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/middleware.ts → apps/sim/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isHosted } from './lib/core/config/environment'
import { generateRuntimeCSP } from './lib/core/security/csp'
import { createLogger } from './lib/logs/console/logger'

const logger = createLogger('Middleware')
const logger = createLogger('Proxy')

const SUSPICIOUS_UA_PATTERNS = [
/^\s*$/, // Empty user agents
Expand Down Expand Up @@ -131,7 +131,7 @@ function handleSecurityFiltering(request: NextRequest): NextResponse | null {
return null
}

export async function middleware(request: NextRequest) {
export async function proxy(request: NextRequest) {
const url = request.nextUrl

const sessionCookie = getSessionCookie(request)
Expand Down
Loading