diff --git a/frontend/.eslintrc.json b/frontend/.eslintrc.json index 0e81f9b9..33c3ccbf 100644 --- a/frontend/.eslintrc.json +++ b/frontend/.eslintrc.json @@ -1,3 +1,11 @@ { - "extends": "next/core-web-vitals" -} \ No newline at end of file + "extends": ["next/core-web-vitals", "prettier"], + "rules": { + "indent": ["error", 2], + "eol-last": ["error", "always"], + "max-len": ["error", { "code": 120, "ignoreUrls": true, "ignoreStrings": true, "ignoreTemplateLiterals": true }], + "semi": ["error", "always"], + "no-trailing-spaces": ["error"], + "arrow-body-style": ["warn", "as-needed"] + } +} diff --git a/frontend/.prettierrc.json b/frontend/.prettierrc.json new file mode 100644 index 00000000..bce1eec4 --- /dev/null +++ b/frontend/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "tabWidth": 2, + "printWidth": 120, + "trailingComma": "es5", + "endOfLine": "lf" +} diff --git a/frontend/app/api/auth/[...nextauth]/route.ts b/frontend/app/api/auth/[...nextauth]/route.ts index 1d895d2f..38464031 100644 --- a/frontend/app/api/auth/[...nextauth]/route.ts +++ b/frontend/app/api/auth/[...nextauth]/route.ts @@ -1,5 +1,5 @@ -import { authOptions } from '@/lib/auth' -import NextAuth from 'next-auth' +import { authOptions } from '@/lib/auth'; +import NextAuth from 'next-auth'; -const handler = NextAuth(authOptions) -export { handler as GET, handler as POST } +const handler = NextAuth(authOptions); +export { handler as GET, handler as POST }; diff --git a/frontend/app/api/limits/workspace/[workspaceId]/route.ts b/frontend/app/api/limits/workspace/[workspaceId]/route.ts index 02b52bf3..e32c0b8a 100644 --- a/frontend/app/api/limits/workspace/[workspaceId]/route.ts +++ b/frontend/app/api/limits/workspace/[workspaceId]/route.ts @@ -1,12 +1,12 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; export async function GET(req: NextRequest, { params }: { params: { workspaceId: string } }): Promise { const workspaceId = params.workspaceId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return await fetcher(`/limits/workspace/${workspaceId}`, { method: 'GET', @@ -14,5 +14,5 @@ export async function GET(req: NextRequest, { params }: { params: { workspaceId: 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); } diff --git a/frontend/app/api/limits/workspace/[workspaceId]/storage/route.ts b/frontend/app/api/limits/workspace/[workspaceId]/storage/route.ts index e1321a70..425b66d5 100644 --- a/frontend/app/api/limits/workspace/[workspaceId]/storage/route.ts +++ b/frontend/app/api/limits/workspace/[workspaceId]/storage/route.ts @@ -1,12 +1,12 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; export async function GET(req: NextRequest, { params }: { params: { workspaceId: string } }): Promise { const workspaceId = params.workspaceId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return await fetcher(`/limits/workspace/${workspaceId}/storage`, { method: 'GET', @@ -14,6 +14,6 @@ export async function GET(req: NextRequest, { params }: { params: { workspaceId: 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); } diff --git a/frontend/app/api/projects/[projectId]/api-keys/route.ts b/frontend/app/api/projects/[projectId]/api-keys/route.ts index 3a9fb15b..fbc6330b 100644 --- a/frontend/app/api/projects/[projectId]/api-keys/route.ts +++ b/frontend/app/api/projects/[projectId]/api-keys/route.ts @@ -1,14 +1,14 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' -import { type NextRequest } from 'next/server' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; +import { type NextRequest } from 'next/server'; export async function POST(req: NextRequest, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); return await fetch(`${process.env.BACKEND_URL}/api/v1/projects/${projectId}/api-keys`, { method: 'POST', @@ -21,9 +21,9 @@ export async function POST(req: NextRequest, { params }: { params: { projectId: } export async function GET(req: NextRequest, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const session = await getServerSession(authOptions); + const user = session!.user; return await fetch(`${process.env.BACKEND_URL}/api/v1/projects/${projectId}/api-keys`, { method: 'GET', @@ -34,11 +34,11 @@ export async function GET(req: NextRequest, { params }: { params: { projectId: s } export async function DELETE(req: NextRequest, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); return await fetch(`${process.env.BACKEND_URL}/api/v1/projects/${projectId}/api-keys`, { method: 'DELETE', @@ -48,4 +48,4 @@ export async function DELETE(req: NextRequest, { params }: { params: { projectId }, body: JSON.stringify(body) }); -} \ No newline at end of file +} diff --git a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/[datapointId]/route.ts b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/[datapointId]/route.ts index a231d44b..288b37a8 100644 --- a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/[datapointId]/route.ts +++ b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/[datapointId]/route.ts @@ -1,15 +1,15 @@ -import { authOptions } from "@/lib/auth"; -import { fetcher } from "@/lib/utils"; -import { getServerSession } from "next-auth"; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; +import { getServerSession } from 'next-auth'; export async function POST(req: Request, { params }: { params: { projectId: string, datasetId: string, datapointId: string } }): Promise { const projectId = params.projectId; const datasetId = params.datasetId; const datapointId = params.datapointId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); return await fetcher(`/projects/${projectId}/datasets/${datasetId}/datapoints/${datapointId}`, { method: 'POST', @@ -18,5 +18,5 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); } diff --git a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/all/route.ts b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/all/route.ts index c703ba9f..cc6e9bca 100644 --- a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/all/route.ts +++ b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/all/route.ts @@ -1,12 +1,12 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function DELETE(req: Request, { params }: { params: { projectId: string, datasetId: string } }): Promise { const projectId = params.projectId; const datasetId = params.datasetId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return await fetcher(`/projects/${projectId}/datasets/${datasetId}/datapoints/all`, { method: 'DELETE', @@ -14,5 +14,5 @@ export async function DELETE(req: Request, { params }: { params: { projectId: st 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); } diff --git a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/route.ts b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/route.ts index 137370ff..d73466f0 100644 --- a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/route.ts +++ b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/datapoints/route.ts @@ -1,29 +1,29 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; export async function GET(req: NextRequest, { params }: { params: { projectId: string, datasetId: string } }): Promise { const projectId = params.projectId; const datasetId = params.datasetId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return await fetcher(`/projects/${projectId}/datasets/${datasetId}/datapoints?${req.nextUrl.searchParams.toString()}`, { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) + }); } export async function POST(req: Request, { params }: { params: { projectId: string, datasetId: string } }): Promise { const projectId = params.projectId; const datasetId = params.datasetId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); return await fetcher(`/projects/${projectId}/datasets/${datasetId}/datapoints`, { method: 'POST', @@ -32,16 +32,16 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); } export async function DELETE(req: Request, { params }: { params: { projectId: string, datasetId: string } }): Promise { const projectId = params.projectId; const datasetId = params.datasetId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); return await fetcher(`/projects/${projectId}/datasets/${datasetId}/datapoints`, { method: 'DELETE', @@ -50,5 +50,5 @@ export async function DELETE(req: Request, { params }: { params: { projectId: st Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); } diff --git a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/file-upload/route.ts b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/file-upload/route.ts index f45c45e0..30b21245 100644 --- a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/file-upload/route.ts +++ b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/file-upload/route.ts @@ -1,16 +1,16 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' -import { type NextRequest } from 'next/server' -import { fetcher } from '@/lib/utils' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; +import { type NextRequest } from 'next/server'; +import { fetcher } from '@/lib/utils'; export async function POST(req: NextRequest, { params }: { params: { projectId: string, datasetId: string } }): Promise { - const projectId = params.projectId - const datasetId = params.datasetId - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const datasetId = params.datasetId; + const session = await getServerSession(authOptions); + const user = session!.user; - const data = await req.formData() + const data = await req.formData(); const res = await fetcher(`/projects/${projectId}/datasets/${datasetId}/file-upload`, { method: 'POST', @@ -18,7 +18,7 @@ export async function POST(req: NextRequest, { params }: { params: { projectId: Authorization: `Bearer ${user.apiKey}` }, body: data - }) + }); - return res + return res; } diff --git a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/index/route.ts b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/index/route.ts index 956be424..39b8d7b4 100644 --- a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/index/route.ts +++ b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/index/route.ts @@ -1,14 +1,14 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' -import { fetcher } from '@/lib/utils' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; export async function POST(req: Request, { params }: { params: { projectId: string, datasetId: string } }): Promise { - const projectId = params.projectId - const datasetId = params.datasetId - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const datasetId = params.datasetId; + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); const res = await fetcher(`/projects/${projectId}/datasets/${datasetId}/index`, { method: 'POST', @@ -17,7 +17,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return new Response(res.body) + return new Response(res.body); } diff --git a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/route.ts b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/route.ts index c1c15f0f..bc1cbb99 100644 --- a/frontend/app/api/projects/[projectId]/datasets/[datasetId]/route.ts +++ b/frontend/app/api/projects/[projectId]/datasets/[datasetId]/route.ts @@ -1,57 +1,57 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function POST(req: Request, { params }: { params: { projectId: string, datasetId: string } }): Promise { - const projectId = params.projectId; - const datasetId = params.datasetId; - const session = await getServerSession(authOptions) - const user = session!.user - - const body = await req.json() - - const res = await fetcher(`/projects/${projectId}/datasets/${datasetId}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${user.apiKey}` - }, - body: JSON.stringify(body) - }) - - return new Response(res.body) + const projectId = params.projectId; + const datasetId = params.datasetId; + const session = await getServerSession(authOptions); + const user = session!.user; + + const body = await req.json(); + + const res = await fetcher(`/projects/${projectId}/datasets/${datasetId}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${user.apiKey}` + }, + body: JSON.stringify(body) + }); + + return new Response(res.body); } export async function GET(req: Request, { params }: { params: { projectId: string, datasetId: string } }): Promise { - const projectId = params.projectId; - const datasetId = params.datasetId; - const session = await getServerSession(authOptions) - const user = session!.user - - const res = await fetcher(`/projects/${projectId}/datasets/${datasetId}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${user.apiKey}` - } - }) - - return new Response(res.body) + const projectId = params.projectId; + const datasetId = params.datasetId; + const session = await getServerSession(authOptions); + const user = session!.user; + + const res = await fetcher(`/projects/${projectId}/datasets/${datasetId}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${user.apiKey}` + } + }); + + return new Response(res.body); } export async function DELETE(req: Request, { params }: { params: { projectId: string, datasetId: string } }): Promise { - const projectId = params.projectId; - const datasetId = params.datasetId; - const session = await getServerSession(authOptions) - const user = session!.user - - const res = await fetcher(`/projects/${projectId}/datasets/${datasetId}`, { - method: 'DELETE', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${user.apiKey}` - } - }) - - return new Response(res.body) + const projectId = params.projectId; + const datasetId = params.datasetId; + const session = await getServerSession(authOptions); + const user = session!.user; + + const res = await fetcher(`/projects/${projectId}/datasets/${datasetId}`, { + method: 'DELETE', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${user.apiKey}` + } + }); + + return new Response(res.body); } diff --git a/frontend/app/api/projects/[projectId]/datasets/route.ts b/frontend/app/api/projects/[projectId]/datasets/route.ts index be6f02fd..258cd275 100644 --- a/frontend/app/api/projects/[projectId]/datasets/route.ts +++ b/frontend/app/api/projects/[projectId]/datasets/route.ts @@ -1,38 +1,38 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function POST(req: Request, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); - const res = await fetcher(`/projects/${projectId}/datasets`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${user.apiKey}` - }, - body: JSON.stringify(body) - }) + const res = await fetcher(`/projects/${projectId}/datasets`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${user.apiKey}` + }, + body: JSON.stringify(body) + }); - return new Response(res.body) + return new Response(res.body); } export async function GET(req: Request, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const session = await getServerSession(authOptions); + const user = session!.user; - const res = await fetcher(`/projects/${projectId}/datasets`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${user.apiKey}` - } - }) + const res = await fetcher(`/projects/${projectId}/datasets`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${user.apiKey}` + } + }); - return new Response(res.body) -} \ No newline at end of file + return new Response(res.body); +} diff --git a/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/checks/route.ts b/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/checks/route.ts index d45b20a0..6b0b3343 100644 --- a/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/checks/route.ts +++ b/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/checks/route.ts @@ -1,23 +1,23 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function PUT(req: Request, { params }: { params: { projectId: string, endpointId: string } }): Promise { - const projectId = params.projectId; - const endpointId = params.endpointId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const endpointId = params.endpointId; + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); - const res = await fetcher(`/projects/${projectId}/endpoints/${endpointId}/checks`, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${user.apiKey}` - }, - body: JSON.stringify(body) - }) + const res = await fetcher(`/projects/${projectId}/endpoints/${endpointId}/checks`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${user.apiKey}` + }, + body: JSON.stringify(body) + }); - return new Response(res.body) -} \ No newline at end of file + return new Response(res.body); +} diff --git a/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/log-datasets/route.ts b/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/log-datasets/route.ts index 1b63b6f4..6b7e8b27 100644 --- a/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/log-datasets/route.ts +++ b/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/log-datasets/route.ts @@ -1,35 +1,35 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function PUT(req: Request, { params }: { params: { projectId: string, endpointId: string } }): Promise { - const projectId = params.projectId; - const endpointId = params.endpointId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const endpointId = params.endpointId; + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); - return await fetcher(`/projects/${projectId}/endpoints/${endpointId}/log-datasets`, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${user.apiKey}` - }, - body: JSON.stringify(body) - }) + return await fetcher(`/projects/${projectId}/endpoints/${endpointId}/log-datasets`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${user.apiKey}` + }, + body: JSON.stringify(body) + }); } export async function GET(req: Request, { params }: { params: { projectId: string, endpointId: string } }): Promise { - const projectId = params.projectId; - const endpointId = params.endpointId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const endpointId = params.endpointId; + const session = await getServerSession(authOptions); + const user = session!.user; - return await fetcher(`/projects/${projectId}/endpoints/${endpointId}/log-datasets`, { - method: 'GET', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) -} \ No newline at end of file + return await fetcher(`/projects/${projectId}/endpoints/${endpointId}/log-datasets`, { + method: 'GET', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); +} diff --git a/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/pipeline-version-graphs/route.ts b/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/pipeline-version-graphs/route.ts index 66c07012..7305c57d 100644 --- a/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/pipeline-version-graphs/route.ts +++ b/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/pipeline-version-graphs/route.ts @@ -1,17 +1,17 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string, endpointId: string } }): Promise { - const projectId = params.projectId; - const endpointId = params.endpointId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const endpointId = params.endpointId; + const session = await getServerSession(authOptions); + const user = session!.user; - return await fetcher(`/projects/${projectId}/endpoints/${endpointId}/pipeline-version-graphs`, { - method: 'GET', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) -} \ No newline at end of file + return await fetcher(`/projects/${projectId}/endpoints/${endpointId}/pipeline-version-graphs`, { + method: 'GET', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); +} diff --git a/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/pipeline-versions/route.ts b/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/pipeline-versions/route.ts index 3f4bb481..5252d93a 100644 --- a/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/pipeline-versions/route.ts +++ b/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/pipeline-versions/route.ts @@ -1,17 +1,17 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string, endpointId: string } }): Promise { - const projectId = params.projectId; - const endpointId = params.endpointId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const endpointId = params.endpointId; + const session = await getServerSession(authOptions); + const user = session!.user; - return await fetcher(`/projects/${projectId}/endpoints/${endpointId}/pipeline-versions`, { - method: 'GET', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) -} \ No newline at end of file + return await fetcher(`/projects/${projectId}/endpoints/${endpointId}/pipeline-versions`, { + method: 'GET', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); +} diff --git a/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/route.ts b/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/route.ts index f4576b9c..77bda2f8 100644 --- a/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/route.ts +++ b/frontend/app/api/projects/[projectId]/endpoints/[endpointId]/route.ts @@ -1,37 +1,37 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string, endpointId: string } }): Promise { - const projectId = params.projectId; - const endpointId = params.endpointId; - const session = await getServerSession(authOptions) - const user = session!.user - - const res = await fetcher(`/projects/${projectId}/endpoints/${endpointId}`, { - method: 'GET', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) - - return new Response(res.body) + const projectId = params.projectId; + const endpointId = params.endpointId; + const session = await getServerSession(authOptions); + const user = session!.user; + + const res = await fetcher(`/projects/${projectId}/endpoints/${endpointId}`, { + method: 'GET', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); + + return new Response(res.body); } export async function DELETE(req: Request, { params }: { params: { projectId: string, endpointId: string } }): Promise { - const projectId = params.projectId - const endpointId = params.endpointId; + const projectId = params.projectId; + const endpointId = params.endpointId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const res = await fetcher(`/projects/${projectId}/endpoints/${endpointId}`, { - method: 'DELETE', - headers: { - Authorization: `Bearer ${user.apiKey}` - } - }) + const res = await fetcher(`/projects/${projectId}/endpoints/${endpointId}`, { + method: 'DELETE', + headers: { + Authorization: `Bearer ${user.apiKey}` + } + }); - return new Response(res.body) + return new Response(res.body); } diff --git a/frontend/app/api/projects/[projectId]/endpoints/route.ts b/frontend/app/api/projects/[projectId]/endpoints/route.ts index fbd83dfe..320130d3 100644 --- a/frontend/app/api/projects/[projectId]/endpoints/route.ts +++ b/frontend/app/api/projects/[projectId]/endpoints/route.ts @@ -1,37 +1,37 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const session = await getServerSession(authOptions); + const user = session!.user; - const res = await fetcher(`/projects/${projectId}/endpoints`, { - method: 'GET', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) + const res = await fetcher(`/projects/${projectId}/endpoints`, { + method: 'GET', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); - return new Response(res.body) + return new Response(res.body); } export async function POST(req: Request, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); - const res = await fetcher(`/projects/${projectId}/endpoints`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Authorization': `Bearer ${user.apiKey}` - }, - body: JSON.stringify(body) - }) + const res = await fetcher(`/projects/${projectId}/endpoints`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${user.apiKey}` + }, + body: JSON.stringify(body) + }); - return new Response(res.body) -} \ No newline at end of file + return new Response(res.body); +} diff --git a/frontend/app/api/projects/[projectId]/evaluation-score-distribution/route.ts b/frontend/app/api/projects/[projectId]/evaluation-score-distribution/route.ts index 5b10e193..e10fc970 100644 --- a/frontend/app/api/projects/[projectId]/evaluation-score-distribution/route.ts +++ b/frontend/app/api/projects/[projectId]/evaluation-score-distribution/route.ts @@ -1,17 +1,17 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; export async function GET(req: NextRequest, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const session = await getServerSession(authOptions); + const user = session!.user; - return await fetcher(`/projects/${projectId}/evaluation-score-distribution?${req.nextUrl.searchParams.toString()}`, { - method: 'GET', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) + return await fetcher(`/projects/${projectId}/evaluation-score-distribution?${req.nextUrl.searchParams.toString()}`, { + method: 'GET', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); } diff --git a/frontend/app/api/projects/[projectId]/evaluation-score-stats/route.ts b/frontend/app/api/projects/[projectId]/evaluation-score-stats/route.ts index 9480170f..81e3ab4c 100644 --- a/frontend/app/api/projects/[projectId]/evaluation-score-stats/route.ts +++ b/frontend/app/api/projects/[projectId]/evaluation-score-stats/route.ts @@ -1,17 +1,17 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; export async function GET(req: NextRequest, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const session = await getServerSession(authOptions); + const user = session!.user; - return await fetcher(`/projects/${projectId}/evaluation-score-stats?${req.nextUrl.searchParams.toString()}`, { - method: 'GET', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) + return await fetcher(`/projects/${projectId}/evaluation-score-stats?${req.nextUrl.searchParams.toString()}`, { + method: 'GET', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); } diff --git a/frontend/app/api/projects/[projectId]/evaluations/[evaluationId]/datapoints/[datapointId]/route.ts b/frontend/app/api/projects/[projectId]/evaluations/[evaluationId]/datapoints/[datapointId]/route.ts index 008b377c..4912175c 100644 --- a/frontend/app/api/projects/[projectId]/evaluations/[evaluationId]/datapoints/[datapointId]/route.ts +++ b/frontend/app/api/projects/[projectId]/evaluations/[evaluationId]/datapoints/[datapointId]/route.ts @@ -1,18 +1,18 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string, evaluationId: string, datapointId: string } }): Promise { - const projectId = params.projectId; - const evaluationId = params.evaluationId; - const datapointId = params.datapointId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const evaluationId = params.evaluationId; + const datapointId = params.datapointId; + const session = await getServerSession(authOptions); + const user = session!.user; - return await fetcher(`/projects/${projectId}/evaluations/${evaluationId}/datapoints/${datapointId}`, { - method: 'GET', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) -} \ No newline at end of file + return await fetcher(`/projects/${projectId}/evaluations/${evaluationId}/datapoints/${datapointId}`, { + method: 'GET', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); +} diff --git a/frontend/app/api/projects/[projectId]/evaluations/[evaluationId]/route.ts b/frontend/app/api/projects/[projectId]/evaluations/[evaluationId]/route.ts index 7f559c51..fb4130a7 100644 --- a/frontend/app/api/projects/[projectId]/evaluations/[evaluationId]/route.ts +++ b/frontend/app/api/projects/[projectId]/evaluations/[evaluationId]/route.ts @@ -1,31 +1,31 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string, evaluationId: string } }): Promise { - const projectId = params.projectId; - const evaluationId = params.evaluationId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const evaluationId = params.evaluationId; + const session = await getServerSession(authOptions); + const user = session!.user; - return await fetcher(`/projects/${projectId}/evaluations/${evaluationId}`, { - method: 'GET', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) + return await fetcher(`/projects/${projectId}/evaluations/${evaluationId}`, { + method: 'GET', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); } export async function DELETE(req: Request, { params }: { params: { projectId: string, evaluationId: string } }): Promise { - const projectId = params.projectId; - const evaluationId = params.evaluationId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const evaluationId = params.evaluationId; + const session = await getServerSession(authOptions); + const user = session!.user; - return await fetcher(`/projects/${projectId}/evaluations/${evaluationId}`, { - method: 'DELETE', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) + return await fetcher(`/projects/${projectId}/evaluations/${evaluationId}`, { + method: 'DELETE', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); } diff --git a/frontend/app/api/projects/[projectId]/evaluations/route.ts b/frontend/app/api/projects/[projectId]/evaluations/route.ts index d5f1aa77..f4f38a67 100644 --- a/frontend/app/api/projects/[projectId]/evaluations/route.ts +++ b/frontend/app/api/projects/[projectId]/evaluations/route.ts @@ -1,16 +1,16 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const projectId = params.projectId; + const session = await getServerSession(authOptions); + const user = session!.user; - return await fetcher(`/projects/${projectId}/evaluations`, { - method: 'GET', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) + return await fetcher(`/projects/${projectId}/evaluations`, { + method: 'GET', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); } diff --git a/frontend/app/api/projects/[projectId]/event-templates/[templateId]/events/route.ts b/frontend/app/api/projects/[projectId]/event-templates/[templateId]/events/route.ts index 4db7834c..5f2beb02 100644 --- a/frontend/app/api/projects/[projectId]/event-templates/[templateId]/events/route.ts +++ b/frontend/app/api/projects/[projectId]/event-templates/[templateId]/events/route.ts @@ -1,5 +1,5 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; @@ -8,8 +8,8 @@ export async function GET(req: NextRequest, { params }: { params: { projectId: s const projectId = params.projectId; const templateId = params.templateId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/event-templates/${templateId}/events?${req.nextUrl.searchParams.toString()}`, { @@ -18,7 +18,7 @@ export async function GET(req: NextRequest, { params }: { params: { projectId: s 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return res + return res; } diff --git a/frontend/app/api/projects/[projectId]/event-templates/[templateId]/metrics/route.ts b/frontend/app/api/projects/[projectId]/event-templates/[templateId]/metrics/route.ts index db73d84d..fb339986 100644 --- a/frontend/app/api/projects/[projectId]/event-templates/[templateId]/metrics/route.ts +++ b/frontend/app/api/projects/[projectId]/event-templates/[templateId]/metrics/route.ts @@ -1,5 +1,5 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; @@ -8,8 +8,8 @@ export async function GET(req: NextRequest, { params }: { params: { projectId: s const projectId = params.projectId; const templateId = params.templateId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/event-templates/${templateId}/metrics?${req.nextUrl.searchParams.toString()}`, { method: 'GET', @@ -17,7 +17,7 @@ export async function GET(req: NextRequest, { params }: { params: { projectId: s 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return res + return res; } diff --git a/frontend/app/api/projects/[projectId]/event-templates/route.ts b/frontend/app/api/projects/[projectId]/event-templates/route.ts index 8e2b8490..54c07f1b 100644 --- a/frontend/app/api/projects/[projectId]/event-templates/route.ts +++ b/frontend/app/api/projects/[projectId]/event-templates/route.ts @@ -1,15 +1,15 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function POST(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); const res = await fetcher(`/projects/${projectId}/event-templates`, { method: 'POST', @@ -18,17 +18,17 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return res + return res; } export async function GET(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/event-templates`, { method: 'GET', @@ -36,8 +36,8 @@ export async function GET(req: Request, { params }: { params: { projectId: strin 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return res + return res; } diff --git a/frontend/app/api/projects/[projectId]/events/metrics/route.ts b/frontend/app/api/projects/[projectId]/events/metrics/route.ts index 791dcf02..4493bd7e 100644 --- a/frontend/app/api/projects/[projectId]/events/metrics/route.ts +++ b/frontend/app/api/projects/[projectId]/events/metrics/route.ts @@ -1,18 +1,18 @@ -import { authOptions } from "@/lib/auth"; -import { fetcher } from "@/lib/utils"; -import { getServerSession } from "next-auth"; -import { NextRequest } from "next/server"; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; +import { getServerSession } from 'next-auth'; +import { NextRequest } from 'next/server'; export async function GET(req: NextRequest, { params }: { params: { projectId: string, } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return fetcher(`/projects/${projectId}/events/metrics?` + req.nextUrl.searchParams.toString(), { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) + }); } diff --git a/frontend/app/api/projects/[projectId]/events/route.ts b/frontend/app/api/projects/[projectId]/events/route.ts index d98b7791..01c8e530 100644 --- a/frontend/app/api/projects/[projectId]/events/route.ts +++ b/frontend/app/api/projects/[projectId]/events/route.ts @@ -1,12 +1,12 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; export async function GET(req: NextRequest, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/events?${req.nextUrl.searchParams.toString()}`, { method: 'GET', @@ -14,7 +14,7 @@ export async function GET(req: NextRequest, { params }: { params: { projectId: s 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return new Response(res.body) + return new Response(res.body); } diff --git a/frontend/app/api/projects/[projectId]/label-classes/route.ts b/frontend/app/api/projects/[projectId]/label-classes/route.ts index f00ed6d6..f8185104 100644 --- a/frontend/app/api/projects/[projectId]/label-classes/route.ts +++ b/frontend/app/api/projects/[projectId]/label-classes/route.ts @@ -1,12 +1,12 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return await fetcher(`/projects/${projectId}/label-classes`, { method: 'GET', @@ -14,15 +14,15 @@ export async function GET(req: Request, { params }: { params: { projectId: strin 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` } - }) + }); } export async function POST(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); return await fetcher(`/projects/${projectId}/label-classes`, { method: 'POST', @@ -31,5 +31,5 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); } diff --git a/frontend/app/api/projects/[projectId]/pipeline-versions/[pipelineVersionId]/route.ts b/frontend/app/api/projects/[projectId]/pipeline-versions/[pipelineVersionId]/route.ts index c4a39cb0..0f6f0fb6 100644 --- a/frontend/app/api/projects/[projectId]/pipeline-versions/[pipelineVersionId]/route.ts +++ b/frontend/app/api/projects/[projectId]/pipeline-versions/[pipelineVersionId]/route.ts @@ -1,13 +1,13 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; export async function GET(req: Request, { params }: { params: { projectId: string, pipelineVersionId: string } }): Promise { const projectId = params.projectId; const pipelineVersionId = params.pipelineVersionId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetch(`${process.env.BACKEND_URL}/api/v1/projects/${projectId}/pipeline-versions/${pipelineVersionId}`, { method: 'GET', @@ -15,7 +15,7 @@ export async function GET(req: Request, { params }: { params: { projectId: strin 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` } - }) + }); - return new Response(res.body, { status: res.status }) + return new Response(res.body, { status: res.status }); } diff --git a/frontend/app/api/projects/[projectId]/pipeline-versions/route.ts b/frontend/app/api/projects/[projectId]/pipeline-versions/route.ts index fb83ca38..cb8098c3 100644 --- a/frontend/app/api/projects/[projectId]/pipeline-versions/route.ts +++ b/frontend/app/api/projects/[projectId]/pipeline-versions/route.ts @@ -1,14 +1,14 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function POST(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user - const body = await req.json() + const session = await getServerSession(authOptions); + const user = session!.user; + const body = await req.json(); const res = await fetcher(`/projects/${projectId}/pipeline-versions`, { method: 'POST', @@ -17,7 +17,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); return new Response(res.body, { status: res.status, statusText: res.statusText }); } diff --git a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/route.ts b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/route.ts index 628e4342..2247f924 100644 --- a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/route.ts +++ b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/route.ts @@ -1,49 +1,49 @@ -import { authOptions } from "@/lib/auth"; -import { fetcher } from "@/lib/utils"; -import { getServerSession } from "next-auth"; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; +import { getServerSession } from 'next-auth'; export async function DELETE(req: Request, { params }: { params: { projectId: string, pipelineId: string } }): Promise { - const projectId = params.projectId - const pipelineId = params.pipelineId + const projectId = params.projectId; + const pipelineId = params.pipelineId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}`, { method: 'DELETE', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return new Response(res.body) + return new Response(res.body); } export async function GET(req: Request, { params }: { params: { projectId: string, pipelineId: string } }): Promise { - const projectId = params.projectId - const pipelineId = params.pipelineId + const projectId = params.projectId; + const pipelineId = params.pipelineId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}`, { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return new Response(res.body) + return new Response(res.body); } export async function POST(req: Request, { params }: { params: { projectId: string, pipelineId: string } }): Promise { - const projectId = params.projectId - const pipelineId = params.pipelineId - const session = await getServerSession(authOptions) - const user = session!.user - const body = await req.json() + const projectId = params.projectId; + const pipelineId = params.pipelineId; + const session = await getServerSession(authOptions); + const user = session!.user; + const body = await req.json(); const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}`, { method: 'POST', @@ -52,7 +52,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return new Response(res.body) -} \ No newline at end of file + return new Response(res.body); +} diff --git a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/target/route.ts b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/target/route.ts index 75ae78c5..49b52bd0 100644 --- a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/target/route.ts +++ b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/target/route.ts @@ -1,14 +1,14 @@ -import { authOptions } from "@/lib/auth"; -import { fetcher } from "@/lib/utils"; -import { getServerSession } from "next-auth"; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; +import { getServerSession } from 'next-auth'; export async function POST(req: Request, { params }: { params: { projectId: string, pipelineId: string } }): Promise { - const projectId = params.projectId - const pipelineId = params.pipelineId - const session = await getServerSession(authOptions) - const user = session!.user - const body = await req.json() + const projectId = params.projectId; + const pipelineId = params.pipelineId; + const session = await getServerSession(authOptions); + const user = session!.user; + const body = await req.json(); const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}/target`, { method: 'POST', @@ -17,7 +17,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return res -} \ No newline at end of file + return res; +} diff --git a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions-info/route.ts b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions-info/route.ts index 4558338c..29808918 100644 --- a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions-info/route.ts +++ b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions-info/route.ts @@ -1,5 +1,5 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string, pipelineId: string } }): Promise { @@ -7,15 +7,15 @@ export async function GET(req: Request, { params }: { params: { projectId: strin const projectId = params.projectId; const pipelineId = params.pipelineId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}/versions-info`, { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return res -} \ No newline at end of file + return res; +} diff --git a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/[pipelineVersionId]/overwrite/route.ts b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/[pipelineVersionId]/overwrite/route.ts index d21611a2..311800ae 100644 --- a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/[pipelineVersionId]/overwrite/route.ts +++ b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/[pipelineVersionId]/overwrite/route.ts @@ -1,5 +1,5 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function POST(req: Request, { params }: { params: { projectId: string, pipelineId: string, pipelineVersionId: string } }): Promise { @@ -8,10 +8,10 @@ export async function POST(req: Request, { params }: { params: { projectId: stri const pipelineId = params.pipelineId; const pipelineVersionId = params.pipelineVersionId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}/versions/${pipelineVersionId}/overwrite`, { method: 'POST', @@ -20,7 +20,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return res + return res; } diff --git a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/[pipelineVersionId]/route.ts b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/[pipelineVersionId]/route.ts index 09dbf591..f2cc68d1 100644 --- a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/[pipelineVersionId]/route.ts +++ b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/[pipelineVersionId]/route.ts @@ -1,5 +1,5 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function POST(req: Request, { params }: { params: { projectId: string, pipelineId: string, pipelineVersionId: string } }): Promise { @@ -8,10 +8,10 @@ export async function POST(req: Request, { params }: { params: { projectId: stri const pipelineId = params.pipelineId; const pipelineVersionId = params.pipelineVersionId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}/versions/${pipelineVersionId}`, { method: 'POST', @@ -20,9 +20,9 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return res + return res; } export async function DELETE(req: Request, { params }: { params: { projectId: string, pipelineId: string, pipelineVersionId: string } }): Promise { @@ -31,8 +31,8 @@ export async function DELETE(req: Request, { params }: { params: { projectId: st const pipelineId = params.pipelineId; const pipelineVersionId = params.pipelineVersionId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}/versions/${pipelineVersionId}`, { method: 'DELETE', @@ -40,9 +40,9 @@ export async function DELETE(req: Request, { params }: { params: { projectId: st 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` } - }) + }); - return res + return res; } export async function GET(req: Request, { params }: { params: { projectId: string, pipelineId: string, pipelineVersionId: string } }): Promise { @@ -51,8 +51,8 @@ export async function GET(req: Request, { params }: { params: { projectId: strin const pipelineId = params.pipelineId; const pipelineVersionId = params.pipelineVersionId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}/versions/${pipelineVersionId}`, { method: 'GET', @@ -60,7 +60,7 @@ export async function GET(req: Request, { params }: { params: { projectId: strin 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` } - }) + }); - return res -} \ No newline at end of file + return res; +} diff --git a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/deploy/route.ts b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/deploy/route.ts index 1c3f002e..463fbaa2 100644 --- a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/deploy/route.ts +++ b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/deploy/route.ts @@ -1,13 +1,13 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; export async function POST(req: Request, { params }: { params: { projectId: string, pipelineId: string } }): Promise { const projectId = params.projectId; const pipelineId = params.pipelineId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const body = await req.json(); const res = await fetch(`${process.env.BACKEND_URL}/api/v1/projects/${projectId}/pipelines/${pipelineId}/versions/deploy`, { @@ -17,7 +17,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return new Response(res.body, { status: res.status }) + return new Response(res.body, { status: res.status }); } diff --git a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/route.ts b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/route.ts index 6a99b92d..6d62d534 100644 --- a/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/route.ts +++ b/frontend/app/api/projects/[projectId]/pipelines/[pipelineId]/versions/route.ts @@ -1,5 +1,5 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string, pipelineId: string } }): Promise { @@ -7,17 +7,17 @@ export async function GET(req: Request, { params }: { params: { projectId: strin const projectId = params.projectId; const pipelineId = params.pipelineId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}/versions`, { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return res + return res; } export async function POST(req: Request, { params }: { params: { projectId: string, pipelineId: string } }): Promise { @@ -25,9 +25,9 @@ export async function POST(req: Request, { params }: { params: { projectId: stri const projectId = params.projectId; const pipelineId = params.pipelineId; - const session = await getServerSession(authOptions) - const user = session!.user - const body = await req.json() + const session = await getServerSession(authOptions); + const user = session!.user; + const body = await req.json(); const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}/versions`, { method: 'POST', @@ -36,7 +36,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); return new Response(res.body, { status: res.status, statusText: res.statusText }); } @@ -46,15 +46,15 @@ export async function DELETE(req: Request, { params }: { params: { projectId: st const projectId = params.projectId; const pipelineId = params.pipelineId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/pipelines/${pipelineId}/versions`, { method: 'DELETE', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return new Response(res.body, { status: res.status, statusText: res.statusText }) + return new Response(res.body, { status: res.status, statusText: res.statusText }); } diff --git a/frontend/app/api/projects/[projectId]/pipelines/interrupt/graph/route.ts b/frontend/app/api/projects/[projectId]/pipelines/interrupt/graph/route.ts index d21949ac..6fa2aa99 100644 --- a/frontend/app/api/projects/[projectId]/pipelines/interrupt/graph/route.ts +++ b/frontend/app/api/projects/[projectId]/pipelines/interrupt/graph/route.ts @@ -1,12 +1,12 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; export async function POST(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); const res = await fetch(`${process.env.BACKEND_URL}/api/v1/projects/${projectId}/pipelines/interrupt/graph`, { method: 'POST', @@ -16,7 +16,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}`, }, body: JSON.stringify(body), - }) + }); - return new Response(res.body) + return new Response(res.body); } diff --git a/frontend/app/api/projects/[projectId]/pipelines/route.ts b/frontend/app/api/projects/[projectId]/pipelines/route.ts index dac0da0a..c9c20843 100644 --- a/frontend/app/api/projects/[projectId]/pipelines/route.ts +++ b/frontend/app/api/projects/[projectId]/pipelines/route.ts @@ -1,11 +1,11 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/pipelines`, { method: 'GET', @@ -13,17 +13,17 @@ export async function GET(req: Request, { params }: { params: { projectId: strin 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return new Response(res.body) + return new Response(res.body); } export async function POST(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); const res = await fetcher(`/projects/${projectId}/pipelines`, { method: 'POST', @@ -32,7 +32,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return new Response(res.body) + return new Response(res.body); } diff --git a/frontend/app/api/projects/[projectId]/pipelines/run/graph/route.ts b/frontend/app/api/projects/[projectId]/pipelines/run/graph/route.ts index c2c501eb..1913deb9 100644 --- a/frontend/app/api/projects/[projectId]/pipelines/run/graph/route.ts +++ b/frontend/app/api/projects/[projectId]/pipelines/run/graph/route.ts @@ -1,12 +1,12 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; export async function POST(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); const headers = new Headers({ 'Content-Type': 'text/event-stream', diff --git a/frontend/app/api/projects/[projectId]/route.ts b/frontend/app/api/projects/[projectId]/route.ts index 65aeb7a8..42c42860 100644 --- a/frontend/app/api/projects/[projectId]/route.ts +++ b/frontend/app/api/projects/[projectId]/route.ts @@ -1,17 +1,17 @@ -import { authOptions } from "@/lib/auth"; -import { fetcher } from "@/lib/utils"; -import { getServerSession } from "next-auth"; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; +import { getServerSession } from 'next-auth'; export async function DELETE(req: Request, { params }: { params: { projectId: string } }): Promise { - const projectId = params.projectId; + const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - return fetcher(`/projects/${projectId}`, { - method: 'DELETE', - headers: { - Authorization: `Bearer ${user.apiKey}` - }, - }) + return fetcher(`/projects/${projectId}`, { + method: 'DELETE', + headers: { + Authorization: `Bearer ${user.apiKey}` + }, + }); } diff --git a/frontend/app/api/projects/[projectId]/sessions/route.ts b/frontend/app/api/projects/[projectId]/sessions/route.ts index 40d6d2fb..7fc623d9 100644 --- a/frontend/app/api/projects/[projectId]/sessions/route.ts +++ b/frontend/app/api/projects/[projectId]/sessions/route.ts @@ -1,12 +1,12 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; export async function GET(req: NextRequest, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcher(`/projects/${projectId}/sessions?${req.nextUrl.searchParams.toString()}`, { method: 'GET', @@ -14,7 +14,7 @@ export async function GET(req: NextRequest, { params }: { params: { projectId: s 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); - return new Response(res.body) + return new Response(res.body); } diff --git a/frontend/app/api/projects/[projectId]/spans/[spanId]/export/route.ts b/frontend/app/api/projects/[projectId]/spans/[spanId]/export/route.ts index d317a8f5..90b1cf61 100644 --- a/frontend/app/api/projects/[projectId]/spans/[spanId]/export/route.ts +++ b/frontend/app/api/projects/[projectId]/spans/[spanId]/export/route.ts @@ -1,13 +1,13 @@ -import { authOptions } from "@/lib/auth"; -import { getServerSession } from "next-auth"; +import { authOptions } from '@/lib/auth'; +import { getServerSession } from 'next-auth'; export async function POST(req: Request, { params }: { params: { projectId: string, spanId: string } }): Promise { const projectId = params.projectId; const spanId = params.spanId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const body = await req.json(); const res = await fetch(`${process.env.BACKEND_URL}/api/v1/projects/${projectId}/spans/${spanId}/export`, { @@ -17,7 +17,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return new Response(res.body, { status: res.status }) + return new Response(res.body, { status: res.status }); } diff --git a/frontend/app/api/projects/[projectId]/spans/[spanId]/labels/[labelId]/route.ts b/frontend/app/api/projects/[projectId]/spans/[spanId]/labels/[labelId]/route.ts index f04cfd60..0c8aa167 100644 --- a/frontend/app/api/projects/[projectId]/spans/[spanId]/labels/[labelId]/route.ts +++ b/frontend/app/api/projects/[projectId]/spans/[spanId]/labels/[labelId]/route.ts @@ -1,5 +1,5 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function DELETE(req: Request, { params }: { params: { projectId: string, spanId: string, labelId: string } }): Promise { @@ -7,8 +7,8 @@ export async function DELETE(req: Request, { params }: { params: { projectId: st const spanId = params.spanId; const labelId = params.labelId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return await fetcher(`/projects/${projectId}/spans/${spanId}/labels/${labelId}`, { method: 'DELETE', @@ -16,5 +16,5 @@ export async function DELETE(req: Request, { params }: { params: { projectId: st 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` } - }) -} \ No newline at end of file + }); +} diff --git a/frontend/app/api/projects/[projectId]/spans/[spanId]/labels/route.ts b/frontend/app/api/projects/[projectId]/spans/[spanId]/labels/route.ts index 2c1dda67..2b43d27d 100644 --- a/frontend/app/api/projects/[projectId]/spans/[spanId]/labels/route.ts +++ b/frontend/app/api/projects/[projectId]/spans/[spanId]/labels/route.ts @@ -1,13 +1,13 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { projectId: string, spanId: string } }): Promise { const projectId = params.projectId; const spanId = params.spanId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return await fetcher(`/projects/${projectId}/spans/${spanId}/labels`, { method: 'GET', @@ -15,17 +15,17 @@ export async function GET(req: Request, { params }: { params: { projectId: strin 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` } - }) + }); } export async function POST(req: Request, { params }: { params: { projectId: string, spanId: string } }): Promise { const projectId = params.projectId; const spanId = params.spanId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); return await fetcher(`/projects/${projectId}/spans/${spanId}/labels`, { method: 'POST', @@ -34,5 +34,5 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); } diff --git a/frontend/app/api/projects/[projectId]/spans/[spanId]/route.ts b/frontend/app/api/projects/[projectId]/spans/[spanId]/route.ts index e8b14ef2..7346db91 100644 --- a/frontend/app/api/projects/[projectId]/spans/[spanId]/route.ts +++ b/frontend/app/api/projects/[projectId]/spans/[spanId]/route.ts @@ -1,18 +1,18 @@ -import { authOptions } from "@/lib/auth"; -import { fetcher } from "@/lib/utils"; -import { getServerSession } from "next-auth"; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; +import { getServerSession } from 'next-auth'; export async function GET(req: Request, { params }: { params: { projectId: string, spanId: string } }): Promise { const projectId = params.projectId; const spanId = params.spanId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return fetcher(`/projects/${projectId}/spans/${spanId}`, { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) -} \ No newline at end of file + }); +} diff --git a/frontend/app/api/projects/[projectId]/templates/route.ts b/frontend/app/api/projects/[projectId]/templates/route.ts index 180940b6..e8cbf5a0 100644 --- a/frontend/app/api/projects/[projectId]/templates/route.ts +++ b/frontend/app/api/projects/[projectId]/templates/route.ts @@ -1,17 +1,17 @@ -import { authOptions } from "@/lib/auth"; -import { fetcher } from "@/lib/utils"; -import { getServerSession } from "next-auth"; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; +import { getServerSession } from 'next-auth'; export async function GET(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return fetcher(`/projects/${projectId}/templates`, { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) + }); } diff --git a/frontend/app/api/projects/[projectId]/traces/[traceId]/route.ts b/frontend/app/api/projects/[projectId]/traces/[traceId]/route.ts index 014838d1..2634034f 100644 --- a/frontend/app/api/projects/[projectId]/traces/[traceId]/route.ts +++ b/frontend/app/api/projects/[projectId]/traces/[traceId]/route.ts @@ -1,18 +1,18 @@ -import { authOptions } from "@/lib/auth"; -import { fetcher } from "@/lib/utils"; -import { getServerSession } from "next-auth"; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; +import { getServerSession } from 'next-auth'; export async function GET(req: Request, { params }: { params: { projectId: string, traceId: string } }): Promise { const projectId = params.projectId; const traceId = params.traceId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return fetcher(`/projects/${projectId}/traces/${traceId}`, { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) -} \ No newline at end of file + }); +} diff --git a/frontend/app/api/projects/[projectId]/traces/metrics/route.ts b/frontend/app/api/projects/[projectId]/traces/metrics/route.ts index 970cd86e..fc3e4f78 100644 --- a/frontend/app/api/projects/[projectId]/traces/metrics/route.ts +++ b/frontend/app/api/projects/[projectId]/traces/metrics/route.ts @@ -1,28 +1,28 @@ -import { authOptions } from "@/lib/auth"; -import { fetcher } from "@/lib/utils"; -import { getServerSession } from "next-auth"; -import { NextRequest } from "next/server"; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; +import { getServerSession } from 'next-auth'; +import { NextRequest } from 'next/server'; export async function GET(req: NextRequest, { params }: { params: { projectId: string, } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return fetcher(`/projects/${projectId}/traces/metrics?` + req.nextUrl.searchParams.toString(), { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) + }); } export async function POST(req: Request, { params }: { params: { projectId: string } }): Promise { const projectId = params.projectId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const body = await req.json(); const res = await fetch(`${process.env.BACKEND_URL}/api/v1/projects/${projectId}/traces/metrics`, { @@ -32,7 +32,7 @@ export async function POST(req: Request, { params }: { params: { projectId: stri Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return new Response(res.body, { status: res.status }) -} \ No newline at end of file + return new Response(res.body, { status: res.status }); +} diff --git a/frontend/app/api/projects/[projectId]/traces/route.ts b/frontend/app/api/projects/[projectId]/traces/route.ts index b895e30b..5623f384 100644 --- a/frontend/app/api/projects/[projectId]/traces/route.ts +++ b/frontend/app/api/projects/[projectId]/traces/route.ts @@ -1,13 +1,13 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; export async function GET(req: NextRequest, { params }: { params: { projectId: string } }): Promise { - const session = await getServerSession(authOptions) - const user = session!.user - const projectId = params.projectId + const session = await getServerSession(authOptions); + const user = session!.user; + const projectId = params.projectId; return await fetcher(`/projects/${projectId}/traces?${req.nextUrl.searchParams.toString()}`, { method: 'GET', @@ -15,5 +15,5 @@ export async function GET(req: NextRequest, { params }: { params: { projectId: s 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); } diff --git a/frontend/app/api/projects/[projectId]/traces/workshop/[pipelineVersionId]/route.ts b/frontend/app/api/projects/[projectId]/traces/workshop/[pipelineVersionId]/route.ts index 0ffc69ce..1b306064 100644 --- a/frontend/app/api/projects/[projectId]/traces/workshop/[pipelineVersionId]/route.ts +++ b/frontend/app/api/projects/[projectId]/traces/workshop/[pipelineVersionId]/route.ts @@ -1,18 +1,18 @@ -import { authOptions } from "@/lib/auth"; -import { fetcher } from "@/lib/utils"; -import { getServerSession } from "next-auth"; +import { authOptions } from '@/lib/auth'; +import { fetcher } from '@/lib/utils'; +import { getServerSession } from 'next-auth'; export async function GET(req: Request, { params }: { params: { projectId: string, pipelineVersionId: string } }): Promise { const projectId = params.projectId; const pipelineVersionId = params.pipelineVersionId; - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return fetcher(`/projects/${projectId}/traces/workshop/${pipelineVersionId}`, { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, - }) -} \ No newline at end of file + }); +} diff --git a/frontend/app/api/projects/route.ts b/frontend/app/api/projects/route.ts index 10e0ca90..0a2ce5ec 100644 --- a/frontend/app/api/projects/route.ts +++ b/frontend/app/api/projects/route.ts @@ -1,21 +1,21 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' -import { type NextRequest } from 'next/server' -import { fetcher } from '@/lib/utils' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; +import { type NextRequest } from 'next/server'; +import { fetcher } from '@/lib/utils'; export async function POST(req: NextRequest): Promise { - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() + const body = await req.json(); - return await fetcher(`/projects`, { + return await fetcher('/projects', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); } diff --git a/frontend/app/api/workspaces/[workspaceId]/route.ts b/frontend/app/api/workspaces/[workspaceId]/route.ts index bcd37e26..d7c54b77 100644 --- a/frontend/app/api/workspaces/[workspaceId]/route.ts +++ b/frontend/app/api/workspaces/[workspaceId]/route.ts @@ -1,18 +1,18 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; export async function GET(req: Request, { params }: { params: { workspaceId: string } }): Promise { - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const res = await fetcher(`/workspaces/${params.workspaceId}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${user.apiKey}` - }, - }) + const res = await fetcher(`/workspaces/${params.workspaceId}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${user.apiKey}` + }, + }); - return new Response(res.body) + return new Response(res.body); } diff --git a/frontend/app/api/workspaces/[workspaceId]/users/route.ts b/frontend/app/api/workspaces/[workspaceId]/users/route.ts index 848fa924..e65c5d26 100644 --- a/frontend/app/api/workspaces/[workspaceId]/users/route.ts +++ b/frontend/app/api/workspaces/[workspaceId]/users/route.ts @@ -1,19 +1,19 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; export async function POST(req: Request, { params }: { params: { workspaceId: string } }): Promise { - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() - const res = await fetch(`${process.env.BACKEND_URL}/api/v1/workspaces/${params.workspaceId}/users`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${user.apiKey}` - }, - body: JSON.stringify(body) - }) + const body = await req.json(); + const res = await fetch(`${process.env.BACKEND_URL}/api/v1/workspaces/${params.workspaceId}/users`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${user.apiKey}` + }, + body: JSON.stringify(body) + }); - return new Response(res.body, { status: res.status }) -} \ No newline at end of file + return new Response(res.body, { status: res.status }); +} diff --git a/frontend/app/api/workspaces/route.ts b/frontend/app/api/workspaces/route.ts index efa979cd..8c0e9736 100644 --- a/frontend/app/api/workspaces/route.ts +++ b/frontend/app/api/workspaces/route.ts @@ -1,12 +1,12 @@ -import { getServerSession } from 'next-auth' -import { authOptions } from '@/lib/auth' +import { getServerSession } from 'next-auth'; +import { authOptions } from '@/lib/auth'; import { fetcher } from '@/lib/utils'; import { NextRequest } from 'next/server'; export async function GET(req: NextRequest): Promise { - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; return await fetcher('/workspaces?' + req.nextUrl.searchParams.toString(), { method: 'GET', @@ -14,22 +14,22 @@ export async function GET(req: NextRequest): Promise { 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); } export async function POST(req: Request): Promise { - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; - const body = await req.json() - const res = await fetcher(`/workspaces`, { + const body = await req.json(); + const res = await fetcher('/workspaces', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, body: JSON.stringify(body) - }) + }); - return new Response(res.body) -} \ No newline at end of file + return new Response(res.body); +} diff --git a/frontend/app/error.tsx b/frontend/app/error.tsx index 5d8894d9..42c76802 100644 --- a/frontend/app/error.tsx +++ b/frontend/app/error.tsx @@ -1,6 +1,6 @@ -'use client' // Error components must be Client Components +'use client'; // Error components must be Client Components -import Link from 'next/link' +import Link from 'next/link'; import Image from 'next/image'; import icon from '@/assets/logo/icon_light.svg'; @@ -18,5 +18,5 @@ export default function Error({

Oops, something went wrong

- ) + ); } diff --git a/frontend/app/errors/internal/page.tsx b/frontend/app/errors/internal/page.tsx index 62c78648..91d7d42a 100644 --- a/frontend/app/errors/internal/page.tsx +++ b/frontend/app/errors/internal/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from 'next/link'; import Image from 'next/image'; import icon from '@/assets/logo/icon_light.svg'; @@ -12,5 +12,5 @@ export default function InternalError() {

Oops, something went wrong

- ) + ); } diff --git a/frontend/app/layout.tsx b/frontend/app/layout.tsx index c54cb6c2..47ecec9e 100644 --- a/frontend/app/layout.tsx +++ b/frontend/app/layout.tsx @@ -7,7 +7,7 @@ import { Metadata } from 'next'; export const metadata: Metadata = { metadataBase: new URL('https://www.lmnr.ai'), title: 'laminar', -} +}; export default async function RootLayout({ diff --git a/frontend/app/on-sign-up/page.tsx b/frontend/app/on-sign-up/page.tsx index 1d58b81a..a0b3dbb5 100644 --- a/frontend/app/on-sign-up/page.tsx +++ b/frontend/app/on-sign-up/page.tsx @@ -9,7 +9,7 @@ import CreateFirstWorkspaceAndProject from '@/components/onboarding/create-first export const metadata: Metadata = { title: 'Create workspace and project', -} +}; export default async function ProjectsPage() { @@ -29,5 +29,5 @@ export default async function ProjectsPage() { - ) + ); } diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index 9c2baaaf..3feeda7b 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -1,7 +1,7 @@ -import { authOptions } from "@/lib/auth"; -import { getServerSession } from "next-auth"; -import { Metadata } from 'next' -import { redirect } from "next/navigation"; +import { authOptions } from '@/lib/auth'; +import { getServerSession } from 'next-auth'; +import { Metadata } from 'next'; +import { redirect } from 'next/navigation'; export const metadata: Metadata = { @@ -9,7 +9,7 @@ export const metadata: Metadata = { openGraph: { type: 'website', title: 'Laminar', - description: 'Orchestration engine for LLM agents', + description: 'The LLM engineering platform', }, twitter: { card: 'summary', @@ -17,10 +17,10 @@ export const metadata: Metadata = { title: 'Laminar', images: { url: 'https://www.lmnr.ai/twitter-image.png', - alt: 'Logo of Laminar - Orchestration engine for LLM agents', + alt: 'Logo of Laminar - the LLM engineering platform', }, } -} +}; export default async function LandingPage() { diff --git a/frontend/app/project/[projectId]/dashboard/page.tsx b/frontend/app/project/[projectId]/dashboard/page.tsx index 3c07ccfa..736d2649 100644 --- a/frontend/app/project/[projectId]/dashboard/page.tsx +++ b/frontend/app/project/[projectId]/dashboard/page.tsx @@ -9,18 +9,18 @@ import { EventTemplate } from '@/lib/events/types'; export const metadata: Metadata = { title: 'Dashboard', -} +}; const getEventTemplates = async (session: Session, projectId: string): Promise => { - const user = session.user + const user = session.user; return await fetcherJSON(`/projects/${projectId}/event-templates`, { - method: "GET", + method: 'GET', headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${user.apiKey}` + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${user.apiKey}` }, }); -} +}; export default async function DashboardPage({ params, diff --git a/frontend/app/project/[projectId]/datasets/[datasetId]/page.tsx b/frontend/app/project/[projectId]/datasets/[datasetId]/page.tsx index 6ea89198..4f499710 100644 --- a/frontend/app/project/[projectId]/datasets/[datasetId]/page.tsx +++ b/frontend/app/project/[projectId]/datasets/[datasetId]/page.tsx @@ -4,12 +4,12 @@ import { fetcherJSON } from '@/lib/utils'; import { getServerSession } from 'next-auth'; import { redirect } from 'next/navigation'; -import { Metadata } from 'next' +import { Metadata } from 'next'; import Dataset from '@/components/dataset/dataset'; export const metadata: Metadata = { title: 'Dataset', -} +}; export default async function DatasetPage({ params, diff --git a/frontend/app/project/[projectId]/datasets/page.tsx b/frontend/app/project/[projectId]/datasets/page.tsx index 0a07b9ad..e94452f7 100644 --- a/frontend/app/project/[projectId]/datasets/page.tsx +++ b/frontend/app/project/[projectId]/datasets/page.tsx @@ -6,7 +6,7 @@ import Datasets from '@/components/datasets/datasets'; export const metadata: Metadata = { title: 'Datasets', -} +}; export default async function LogsPage({ params, diff --git a/frontend/app/project/[projectId]/env/page.tsx b/frontend/app/project/[projectId]/env/page.tsx index 4dd93166..44d26b9f 100644 --- a/frontend/app/project/[projectId]/env/page.tsx +++ b/frontend/app/project/[projectId]/env/page.tsx @@ -6,16 +6,16 @@ import Env from '@/components/env/env'; export const metadata: Metadata = { title: 'Env Variables', -} +}; export default async function EnvPage() { - const session = await getServerSession(authOptions) + const session = await getServerSession(authOptions); if (!session) { redirect('/sign-in'); } return ( - ) + ); } diff --git a/frontend/app/project/[projectId]/evaluations/[evaluationId]/page.tsx b/frontend/app/project/[projectId]/evaluations/[evaluationId]/page.tsx index c40e6b0a..e161ef65 100644 --- a/frontend/app/project/[projectId]/evaluations/[evaluationId]/page.tsx +++ b/frontend/app/project/[projectId]/evaluations/[evaluationId]/page.tsx @@ -7,7 +7,7 @@ import Evaluation from '@/components/evaluation/evaluation'; export const metadata: Metadata = { title: 'Evaluation results', -} +}; export default async function EvaluationPage({params}: {params: { projectId: string, evaluationId: string }}) { diff --git a/frontend/app/project/[projectId]/evaluations/page.tsx b/frontend/app/project/[projectId]/evaluations/page.tsx index ad55210e..2eaab041 100644 --- a/frontend/app/project/[projectId]/evaluations/page.tsx +++ b/frontend/app/project/[projectId]/evaluations/page.tsx @@ -8,7 +8,7 @@ import { Evaluation } from '@/lib/evaluation/types'; export const metadata: Metadata = { title: 'Evaluations', -} +}; export default async function EvaluationsPage({ params, diff --git a/frontend/app/project/[projectId]/events/[eventId]/page.tsx b/frontend/app/project/[projectId]/events/[eventId]/page.tsx index b025f63c..cf0a3ac6 100644 --- a/frontend/app/project/[projectId]/events/[eventId]/page.tsx +++ b/frontend/app/project/[projectId]/events/[eventId]/page.tsx @@ -1,6 +1,6 @@ import { authOptions } from '@/lib/auth'; import { getServerSession } from 'next-auth'; -import { fetcher } from "@/lib/utils"; +import { fetcher } from '@/lib/utils'; import { redirect } from 'next/navigation'; import EventComponent from '@/components/event/event'; import { EventTemplate, Event } from '@/lib/events/types'; @@ -8,34 +8,34 @@ import { Metadata } from 'next'; export const metadata: Metadata = { title: 'Event', -} +}; const getEventTemplate = async (userApiKey: string, projectId: string, templateId: string) => { const response = await fetcher(`/projects/${projectId}/event-templates/${templateId}`, { - method: "GET", + method: 'GET', headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${userApiKey}` + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${userApiKey}` }, } ); return await response.json() as EventTemplate; -} +}; const getMetrics = async (userApiKey: string, projectId: string, templateId: string, pastHours: string, groupByInterval: string) => { const response = await fetcher(`/projects/${projectId}/event-templates/${templateId}/metrics?pastHours=${pastHours}&groupByInterval=${groupByInterval}&aggregation=Total&metric=eventCount`, { - method: "GET", + method: 'GET', headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${userApiKey}` + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${userApiKey}` }, } ); return await response.json() as any; -} +}; export default async function EventTemplatePage({ params, @@ -50,17 +50,17 @@ export default async function EventTemplatePage({ redirect('/sign-in'); } - const pastHours = searchParams.pastHours ?? "24"; + const pastHours = searchParams.pastHours ?? '24'; - let groupByInterval = "minute"; - if (pastHours === "1") { - groupByInterval = "minute"; - } else if (pastHours === "7") { - groupByInterval = "minute"; - } else if (pastHours === "24") { - groupByInterval = "hour"; + let groupByInterval = 'minute'; + if (pastHours === '1') { + groupByInterval = 'minute'; + } else if (pastHours === '7') { + groupByInterval = 'minute'; + } else if (pastHours === '24') { + groupByInterval = 'hour'; } else { - groupByInterval = "day"; + groupByInterval = 'day'; } const eventTemplate = await getEventTemplate(session.user.apiKey, params.projectId, params.eventId); diff --git a/frontend/app/project/[projectId]/events/page.tsx b/frontend/app/project/[projectId]/events/page.tsx index d9470c4f..8588f79f 100644 --- a/frontend/app/project/[projectId]/events/page.tsx +++ b/frontend/app/project/[projectId]/events/page.tsx @@ -8,7 +8,7 @@ import { EventTemplate } from '@/lib/events/types'; export const metadata: Metadata = { title: 'Events', -} +}; export default async function EventTemplatesPage({ params, @@ -36,4 +36,4 @@ export default async function EventTemplatesPage({ return ( ); -} \ No newline at end of file +} diff --git a/frontend/app/project/[projectId]/layout.tsx b/frontend/app/project/[projectId]/layout.tsx index f1989cf2..2c70edc5 100644 --- a/frontend/app/project/[projectId]/layout.tsx +++ b/frontend/app/project/[projectId]/layout.tsx @@ -14,8 +14,8 @@ export default async function ProjectIdLayout({ children: React.ReactNode; params: { projectId: string }; }) { - const projectId = params.projectId - const session = await getServerSession(authOptions) + const projectId = params.projectId; + const session = await getServerSession(authOptions); if (!session) { redirect('/sign-in'); } @@ -27,7 +27,7 @@ export default async function ProjectIdLayout({ 'Content-Type': 'application/json', Authorization: `Bearer ${user.apiKey}` }, - }) + }); return ( diff --git a/frontend/app/project/[projectId]/pipelines/[pipelineId]/page.tsx b/frontend/app/project/[projectId]/pipelines/[pipelineId]/page.tsx index 40fa70fd..3733227d 100644 --- a/frontend/app/project/[projectId]/pipelines/[pipelineId]/page.tsx +++ b/frontend/app/project/[projectId]/pipelines/[pipelineId]/page.tsx @@ -4,31 +4,31 @@ import { PipelineVersion } from '@/lib/pipeline/types'; import { fetcherJSON } from '@/lib/utils'; import { Session, getServerSession } from 'next-auth'; import { redirect } from 'next/navigation'; -import { Metadata } from 'next' +import { Metadata } from 'next'; const URL_QUERY_PARAMS = { SELECTED_VERSION_ID: 'versionId', -} +}; // TODO: Add pipeline name to the params export const metadata: Metadata = { title: 'Pipeline', -} +}; // required to force reload on each pipeline page visit -export const dynamic = 'force-dynamic' -export const revalidate = 0 +export const dynamic = 'force-dynamic'; +export const revalidate = 0; const getPipelineVersion = async (session: Session, projectId: string, pipelineId: string, versionId: string): Promise => { - const user = session.user + const user = session.user; return await fetcherJSON(`/projects/${projectId}/pipelines/${pipelineId}/versions/${versionId}`, { - method: "GET", + method: 'GET', headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${user.apiKey}` + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${user.apiKey}` }, }); -} +}; export default async function PipelinePage({ params, diff --git a/frontend/app/project/[projectId]/pipelines/page.tsx b/frontend/app/project/[projectId]/pipelines/page.tsx index 1ac1ce5c..b95ff14c 100644 --- a/frontend/app/project/[projectId]/pipelines/page.tsx +++ b/frontend/app/project/[projectId]/pipelines/page.tsx @@ -4,15 +4,15 @@ import { redirect } from 'next/navigation'; import Pipelines from '@/components/pipelines/pipelines'; -import { Metadata } from 'next' +import { Metadata } from 'next'; export const metadata: Metadata = { title: 'Pipelines', -} +}; // required to force reload on each pipeline page visit however apparently this is not working -export const dynamic = 'force-dynamic' -export const revalidate = 0 +export const dynamic = 'force-dynamic'; +export const revalidate = 0; export default async function PipelinesPage() { @@ -23,5 +23,5 @@ export default async function PipelinesPage() { return ( - ) + ); } diff --git a/frontend/app/project/[projectId]/settings/page.tsx b/frontend/app/project/[projectId]/settings/page.tsx index 24fcf1b2..97bae793 100644 --- a/frontend/app/project/[projectId]/settings/page.tsx +++ b/frontend/app/project/[projectId]/settings/page.tsx @@ -1,33 +1,33 @@ import { getServerSession } from 'next-auth'; import { authOptions } from '@/lib/auth'; -import { fetcherJSON } from "@/lib/utils"; +import { fetcherJSON } from '@/lib/utils'; import { redirect } from 'next/navigation'; import { Metadata } from 'next'; import Settings from '@/components/settings/settings'; export const metadata: Metadata = { title: 'Settings', -} +}; const getProjectApiKeys = async (projectId: string) => { - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcherJSON(`/projects/${projectId}/api-keys`, { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, }); - return await res -} + return await res; +}; export default async function ApiKeysPage( { params }: { params: { projectId: string } } ) { - const apiKeys = await getProjectApiKeys(params.projectId) + const apiKeys = await getProjectApiKeys(params.projectId); - const session = await getServerSession(authOptions) + const session = await getServerSession(authOptions); if (!session) { redirect('/sign-in'); } @@ -36,5 +36,5 @@ export default async function ApiKeysPage( <> - ) + ); } diff --git a/frontend/app/project/[projectId]/traces/page.tsx b/frontend/app/project/[projectId]/traces/page.tsx index f3528eef..b826f28f 100644 --- a/frontend/app/project/[projectId]/traces/page.tsx +++ b/frontend/app/project/[projectId]/traces/page.tsx @@ -8,7 +8,7 @@ import Header from '@/components/ui/header'; export const metadata: Metadata = { title: 'Traces', -} +}; export default async function TracesPage() { @@ -20,7 +20,7 @@ export default async function TracesPage() { return ( <> -
+
); diff --git a/frontend/app/projects/page.tsx b/frontend/app/projects/page.tsx index 1b3d5f17..08665d84 100644 --- a/frontend/app/projects/page.tsx +++ b/frontend/app/projects/page.tsx @@ -11,7 +11,7 @@ import Header from '@/components/ui/header'; export const metadata: Metadata = { title: 'Projects', -} +}; export default async function ProjectsPage() { @@ -29,5 +29,5 @@ export default async function ProjectsPage() { - ) + ); } diff --git a/frontend/app/sign-in/page.tsx b/frontend/app/sign-in/page.tsx index dde48aef..5a7f8fc9 100644 --- a/frontend/app/sign-in/page.tsx +++ b/frontend/app/sign-in/page.tsx @@ -1,7 +1,7 @@ -import { getServerSession } from 'next-auth' -import logo from '@/assets/logo/laminar_light.svg' -import Image from 'next/image' -import { redirect } from 'next/navigation' +import { getServerSession } from 'next-auth'; +import logo from '@/assets/logo/laminar_light.svg'; +import Image from 'next/image'; +import { redirect } from 'next/navigation'; import { DefaultSignInButton } from '@/components/sign-in/dummy-signin'; export default async function SignInPage({ @@ -11,14 +11,14 @@ export default async function SignInPage({ params: {}; searchParams?: { [key: string]: string | string[] | undefined } }) { - const session = await getServerSession() + const session = await getServerSession(); let callbackUrl = searchParams?.callbackUrl ?? '/on-sign-up'; if (Array.isArray(callbackUrl)) { - callbackUrl = callbackUrl[0] + callbackUrl = callbackUrl[0]; } if (session?.user) { - redirect(callbackUrl) + redirect(callbackUrl); } return (
@@ -28,5 +28,5 @@ export default async function SignInPage({
- ) + ); } diff --git a/frontend/app/workspace/[workspaceId]/page.tsx b/frontend/app/workspace/[workspaceId]/page.tsx index 3bf29631..b94822fa 100644 --- a/frontend/app/workspace/[workspaceId]/page.tsx +++ b/frontend/app/workspace/[workspaceId]/page.tsx @@ -1,6 +1,6 @@ import { getServerSession } from 'next-auth'; import { authOptions } from '@/lib/auth'; -import { fetcherJSON } from "@/lib/utils"; +import { fetcherJSON } from '@/lib/utils'; import { redirect } from 'next/navigation'; import { Metadata } from 'next'; import { WorkspaceWithUsers } from '@/lib/workspaces/types'; @@ -11,26 +11,26 @@ import Header from '@/components/ui/header'; export const metadata: Metadata = { title: 'Workspace', -} +}; const getWorkspace = async (workspaceId: string): Promise => { - const session = await getServerSession(authOptions) - const user = session!.user + const session = await getServerSession(authOptions); + const user = session!.user; const res = await fetcherJSON(`/workspaces/${workspaceId}`, { method: 'GET', headers: { Authorization: `Bearer ${user.apiKey}` }, }); - return await res -} + return await res; +}; export default async function WorkspacePage( { params }: { params: { workspaceId: string } } ) { - const session = await getServerSession(authOptions) + const session = await getServerSession(authOptions); if (!session) { redirect('/sign-in'); } @@ -51,5 +51,5 @@ export default async function WorkspacePage( /> - ) + ); } diff --git a/frontend/assets/logo/discord.tsx b/frontend/assets/logo/discord.tsx index 2693b254..b8d8614a 100644 --- a/frontend/assets/logo/discord.tsx +++ b/frontend/assets/logo/discord.tsx @@ -1,4 +1,4 @@ -import * as React from "react" +import * as React from 'react'; const DiscordLogo = (props: any) => ( ( > -) -export default DiscordLogo +); +export default DiscordLogo; diff --git a/frontend/components/button-scroll-to-bottom.tsx b/frontend/components/button-scroll-to-bottom.tsx index 2b686e8a..0eb8531a 100644 --- a/frontend/components/button-scroll-to-bottom.tsx +++ b/frontend/components/button-scroll-to-bottom.tsx @@ -1,14 +1,14 @@ -'use client' +'use client'; -import * as React from 'react' +import * as React from 'react'; -import { cn } from '@/lib/utils' -import { useAtBottom } from '@/lib/hooks/use-at-bottom' -import { Button, type ButtonProps } from '@/components/ui/button' -import { IconArrowDown } from '@/components/ui/icons' +import { cn } from '@/lib/utils'; +import { useAtBottom } from '@/lib/hooks/use-at-bottom'; +import { Button, type ButtonProps } from '@/components/ui/button'; +import { IconArrowDown } from '@/components/ui/icons'; export function ButtonScrollToBottom ({ className, ...props }: ButtonProps) { - const isAtBottom = useAtBottom() + const isAtBottom = useAtBottom(); return ( - ) + ); } diff --git a/frontend/components/client-timestamp-formatter.tsx b/frontend/components/client-timestamp-formatter.tsx index 7ac53c12..45359cd6 100644 --- a/frontend/components/client-timestamp-formatter.tsx +++ b/frontend/components/client-timestamp-formatter.tsx @@ -1,20 +1,20 @@ import { useEffect, useState } from 'react'; -import { TIME_MILLISECONDS_FORMAT, convertToLocalTimeWithMillis, formatTimestamp } from "@/lib/utils"; +import { TIME_MILLISECONDS_FORMAT, convertToLocalTimeWithMillis, formatTimestamp } from '@/lib/utils'; // This component is a client-side only component that will format a timestamp // If it's not used, then there will be error because SSR will try to render // this component with server's rather than user's timezone. export default function ClientTimestampFormatter({ timestamp, format = null }: { timestamp: string, format?: string | null }) { - const [formattedTimestamp, setFormattedTimestamp] = useState(''); + const [formattedTimestamp, setFormattedTimestamp] = useState(''); - // This function will now run on the client side after mounting - useEffect(() => { - if (format === TIME_MILLISECONDS_FORMAT) { - setFormattedTimestamp(convertToLocalTimeWithMillis(timestamp)); - } else { - setFormattedTimestamp(formatTimestamp(timestamp)); - } - }, []); + // This function will now run on the client side after mounting + useEffect(() => { + if (format === TIME_MILLISECONDS_FORMAT) { + setFormattedTimestamp(convertToLocalTimeWithMillis(timestamp)); + } else { + setFormattedTimestamp(formatTimestamp(timestamp)); + } + }, []); - return ({formattedTimestamp}); + return ({formattedTimestamp}); }; diff --git a/frontend/components/dashboard/dashboard.tsx b/frontend/components/dashboard/dashboard.tsx index c5c5718d..0dbcfb98 100644 --- a/frontend/components/dashboard/dashboard.tsx +++ b/frontend/components/dashboard/dashboard.tsx @@ -1,21 +1,21 @@ -'use client' +'use client'; -import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts" +import { CartesianGrid, Line, LineChart, XAxis, YAxis } from 'recharts'; import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, -} from "@/components/ui/chart" -import { cn, formatTimestampFromSeconds, formatTimestampFromSecondsWithInterval, getGroupByInterval } from "@/lib/utils"; -import { useEffect, useState } from "react"; -import DateRangeFilter from "../ui/date-range-filter"; -import { Skeleton } from "../ui/skeleton"; -import { usePathname, useRouter, useSearchParams } from "next/navigation"; -import { GroupByPeriodSelect } from "../ui/group-by-period-select"; -import { TraceMetricDatapoint } from "@/lib/traces/types"; -import Header from "../ui/header"; -import { useProjectContext } from "@/contexts/project-context"; +} from '@/components/ui/chart'; +import { cn, formatTimestampFromSeconds, formatTimestampFromSecondsWithInterval, getGroupByInterval } from '@/lib/utils'; +import { useEffect, useState } from 'react'; +import DateRangeFilter from '../ui/date-range-filter'; +import { Skeleton } from '../ui/skeleton'; +import { usePathname, useRouter, useSearchParams } from 'next/navigation'; +import { GroupByPeriodSelect } from '../ui/group-by-period-select'; +import { TraceMetricDatapoint } from '@/lib/traces/types'; +import Header from '../ui/header'; +import { useProjectContext } from '@/contexts/project-context'; interface CustomChartProps { @@ -51,9 +51,9 @@ export function CustomChart({ const chartConfig = { [xAxisKey]: { - color: "hsl(var(--chart-2))", + color: 'hsl(var(--chart-2))', }, - } satisfies ChartConfig + } satisfies ChartConfig; useEffect(() => { if (!pastHours && !startDate && !endDate) { @@ -65,27 +65,27 @@ export function CustomChart({ groupByInterval: defaultGroupByInterval }; if (pastHours) { - body["pastHours"] = pastHours; + body['pastHours'] = pastHours; } else { - body["startDate"] = startDate; - body["endDate"] = endDate; + body['startDate'] = startDate; + body['endDate'] = endDate; } fetch(`/api/projects/${projectId}/traces/metrics`, { method: 'POST', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, body: JSON.stringify(body) }) .then(res => res.json()).then((data: any) => { - setData(data) - }) + setData(data); + }); }, [defaultGroupByInterval, pastHours, startDate, endDate]); return ( -
+
{title}
@@ -136,7 +136,7 @@ export function CustomChart({ }
- ) + ); } export interface DashboardProps { @@ -166,7 +166,7 @@ export default function Dashboard() { return ( <> -
+
@@ -236,7 +236,7 @@ export default function Dashboard() { startDate={startDate} endDate={endDate} defaultGroupByInterval={groupByInterval} - countComponent={(data: TraceMetricDatapoint[]) => {"$" + data?.reduce((acc, curr) => acc + curr.value, 0).toFixed(5)}} + countComponent={(data: TraceMetricDatapoint[]) => {'$' + data?.reduce((acc, curr) => acc + curr.value, 0).toFixed(5)}} />
diff --git a/frontend/components/dashboard/events-metrics.tsx b/frontend/components/dashboard/events-metrics.tsx index f6afcf81..6e79ef95 100644 --- a/frontend/components/dashboard/events-metrics.tsx +++ b/frontend/components/dashboard/events-metrics.tsx @@ -1,27 +1,27 @@ -'use client' +'use client'; -import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts" +import { CartesianGrid, Line, LineChart, XAxis, YAxis } from 'recharts'; import { Card, CardContent, CardHeader, CardTitle, -} from "@/components/ui/card" +} from '@/components/ui/card'; import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, -} from "@/components/ui/chart" -import { cn, formatTimestampFromSeconds, getGroupByInterval } from "@/lib/utils"; -import { useEffect, useState } from "react"; -import { EventTemplate } from "@/lib/events/types"; -import DateRangeFilter from "../ui/date-range-filter"; -import { Skeleton } from "../ui/skeleton"; -import { useSearchParams } from "next/navigation"; -import { GroupByPeriodSelect } from "../ui/group-by-period-select"; -import Mono from "../ui/mono"; +} from '@/components/ui/chart'; +import { cn, formatTimestampFromSeconds, getGroupByInterval } from '@/lib/utils'; +import { useEffect, useState } from 'react'; +import { EventTemplate } from '@/lib/events/types'; +import DateRangeFilter from '../ui/date-range-filter'; +import { Skeleton } from '../ui/skeleton'; +import { useSearchParams } from 'next/navigation'; +import { GroupByPeriodSelect } from '../ui/group-by-period-select'; +import Mono from '../ui/mono'; interface CustomChartProps { @@ -41,15 +41,15 @@ export function CustomChart({ endDate, defaultGroupByInterval, }: CustomChartProps) { - const [xAxisKey, setXAxisKey] = useState("time"); - const [yAxisKey, setYAxisKey] = useState("value"); + const [xAxisKey, setXAxisKey] = useState('time'); + const [yAxisKey, setYAxisKey] = useState('value'); const [data, setData] = useState(null); const chartConfig = { [xAxisKey]: { - color: "hsl(var(--chart-2))", + color: 'hsl(var(--chart-2))', }, - } satisfies ChartConfig + } satisfies ChartConfig; const inferredGroupBy = getGroupByInterval(pastHours, startDate, endDate, defaultGroupByInterval); @@ -68,17 +68,17 @@ export function CustomChart({ fetch(url, { method: 'GET', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, }) .then(res => res.json().then((data: any) => { setData(data); - })) + })); }, [eventTemplate, pastHours, startDate, endDate, defaultGroupByInterval]); return ( -
+
{eventTemplate.name}
@@ -128,7 +128,7 @@ export function CustomChart({ }
- ) + ); } export interface DashboardProps { diff --git a/frontend/components/dataset/add-datapoints-dialog.tsx b/frontend/components/dataset/add-datapoints-dialog.tsx index 32a3c24e..1b5b09fa 100644 --- a/frontend/components/dataset/add-datapoints-dialog.tsx +++ b/frontend/components/dataset/add-datapoints-dialog.tsx @@ -1,13 +1,13 @@ import React, { useState } from 'react'; -import { Button } from '@/components/ui/button' +import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger -} from '@/components/ui/dialog' +} from '@/components/ui/dialog'; import DatasetUpload from './dataset-upload'; @@ -41,5 +41,5 @@ export default function AddDatapointsDialog({ datasetId, onUpdate }: AddDatapoin /> - ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/dataset/dataset-panel.tsx b/frontend/components/dataset/dataset-panel.tsx index f001b728..b0e5f276 100644 --- a/frontend/components/dataset/dataset-panel.tsx +++ b/frontend/components/dataset/dataset-panel.tsx @@ -1,16 +1,16 @@ -import { useProjectContext } from "@/contexts/project-context"; -import { ChevronsRight } from "lucide-react"; -import { Skeleton } from "../ui/skeleton"; -import { Label } from "../ui/label"; -import { ScrollArea } from "../ui/scroll-area"; -import { Button } from "../ui/button"; -import Mono from "../ui/mono"; -import { Datapoint } from "@/lib/dataset/types"; -import Formatter from "../ui/formatter"; -import { useEffect, useState } from "react"; -import { useRouter } from "next/navigation"; -import { isJsonStringAValidObject } from "@/lib/utils"; -import { useToast } from "@/lib/hooks/use-toast"; +import { useProjectContext } from '@/contexts/project-context'; +import { ChevronsRight } from 'lucide-react'; +import { Skeleton } from '../ui/skeleton'; +import { Label } from '../ui/label'; +import { ScrollArea } from '../ui/scroll-area'; +import { Button } from '../ui/button'; +import Mono from '../ui/mono'; +import { Datapoint } from '@/lib/dataset/types'; +import Formatter from '../ui/formatter'; +import { useEffect, useState } from 'react'; +import { useRouter } from 'next/navigation'; +import { isJsonStringAValidObject } from '@/lib/utils'; +import { useToast } from '@/lib/hooks/use-toast'; interface DatasetPanelProps { datasetId: string; @@ -26,7 +26,7 @@ const deepEqual = (x: Object | null, y: Object | null): boolean => { ok(x).length === ok(y).length && ok(x).every((key: string) => deepEqual((x as any)[key], (y as any)[key])) ) : (x === y); -} +}; export default function DatasetPanel({ datasetId, datapoint, onClose }: DatasetPanelProps) { const { projectId } = useProjectContext(); @@ -44,7 +44,7 @@ export default function DatasetPanel({ datasetId, datapoint, onClose }: DatasetP setNewData(datapoint.data); setNewTarget(datapoint.target); setNewMetadata(datapoint.metadata); - }, [datapoint]) + }, [datapoint]); return (
@@ -54,10 +54,10 @@ export default function DatasetPanel({ datasetId, datapoint, onClose }: DatasetP variant="ghost" className='px-1' onClick={() => { - setNewData(datapoint.data) - setNewTarget(datapoint.target) - setNewMetadata(datapoint.metadata) - onClose() + setNewData(datapoint.data); + setNewTarget(datapoint.target); + setNewMetadata(datapoint.metadata); + onClose(); }} > @@ -74,7 +74,11 @@ export default function DatasetPanel({ datasetId, datapoint, onClose }: DatasetP variant='outline' // disable if no changes or invalid json disabled={!isValidJsonData || !isValidJsonTarget || !isValidJsonMetadata || - (deepEqual(datapoint.data, newData) && deepEqual(datapoint.target, newTarget)) && deepEqual(datapoint.metadata, newMetadata)} + ( + deepEqual(datapoint.data, newData) + && deepEqual(datapoint.target, newTarget) + && deepEqual(datapoint.metadata, newMetadata)) + } onClick={async () => { const res = await fetch(`/api/projects/${projectId}/datasets/${datasetId}/datapoints/${datapoint.id}`, { method: 'POST', @@ -86,18 +90,18 @@ export default function DatasetPanel({ datasetId, datapoint, onClose }: DatasetP target: newTarget, metadata: newMetadata, }) - }) + }); if (!res.ok) { toast({ title: 'Failed to save changes', variant: 'destructive', - }) - return + }); + return; } - router.refresh() + router.refresh(); toast({ title: 'Changes saved', - }) + }); }} > Save changes @@ -150,9 +154,9 @@ export default function DatasetPanel({ datasetId, datapoint, onClose }: DatasetP setIsValidJsonTarget(false); } }} /> - {!isValidJsonTarget && ( -

Invalid JSON object

- )} + {!isValidJsonTarget && ( +

Invalid JSON object

+ )}
@@ -179,9 +183,9 @@ export default function DatasetPanel({ datasetId, datapoint, onClose }: DatasetP setIsValidJsonMetadata(false); } }} /> - {!isValidJsonMetadata && ( -

Invalid JSON object

- )} + {!isValidJsonMetadata && ( +

Invalid JSON object

+ )}
@@ -198,5 +202,5 @@ export default function DatasetPanel({ datasetId, datapoint, onClose }: DatasetP ) }
- ) + ); } diff --git a/frontend/components/dataset/dataset-upload.tsx b/frontend/components/dataset/dataset-upload.tsx index bebbb807..7b539ee5 100644 --- a/frontend/components/dataset/dataset-upload.tsx +++ b/frontend/components/dataset/dataset-upload.tsx @@ -40,9 +40,9 @@ export default function DatasetUpload({ uploadFile( file, `/api/projects/${projectId}/datasets/${datasetId}/file-upload`, false ).then(_ => { - onSuccessfulUpload?.() + onSuccessfulUpload?.(); }).catch(error => { - toast({ title: 'Error', description: 'Error uploading file' + error }) + toast({ title: 'Error', description: 'Error uploading file' + error }); }).finally(() => { setIsLoading(false); }); diff --git a/frontend/components/dataset/dataset.tsx b/frontend/components/dataset/dataset.tsx index 3c8233b6..55387693 100644 --- a/frontend/components/dataset/dataset.tsx +++ b/frontend/components/dataset/dataset.tsx @@ -1,22 +1,22 @@ -'use client' +'use client'; -import { Datapoint, Dataset as DatasetType } from "@/lib/dataset/types"; -import { useEffect, useState } from "react"; -import { ColumnDef } from "@tanstack/react-table"; -import AddDatapointsDialog from "./add-datapoints-dialog"; -import { DataTable } from "@/components/ui/datatable"; -import IndexDatasetDialog from "./index-dataset-dialog"; +import { Datapoint, Dataset as DatasetType } from '@/lib/dataset/types'; +import { useEffect, useState } from 'react'; +import { ColumnDef } from '@tanstack/react-table'; +import AddDatapointsDialog from './add-datapoints-dialog'; +import { DataTable } from '@/components/ui/datatable'; +import IndexDatasetDialog from './index-dataset-dialog'; import { usePathname, useRouter, useSearchParams } from 'next/navigation'; -import ManualAddDatapoint from "./manual-add-datapoint-dialog"; -import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "../ui/resizable"; -import DatasetPanel from "./dataset-panel"; -import Header from "../ui/header"; -import DeleteDatapointsDialog from "./delete-datapoints-dialog"; -import { useToast } from "@/lib/hooks/use-toast"; -import { useProjectContext } from "@/contexts/project-context"; -import ClientTimestampFormatter from "../client-timestamp-formatter"; -import { PaginatedResponse } from "@/lib/types"; -import { Resizable } from "re-resizable"; +import ManualAddDatapoint from './manual-add-datapoint-dialog'; +import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '../ui/resizable'; +import DatasetPanel from './dataset-panel'; +import Header from '../ui/header'; +import DeleteDatapointsDialog from './delete-datapoints-dialog'; +import { useToast } from '@/lib/hooks/use-toast'; +import { useProjectContext } from '@/contexts/project-context'; +import ClientTimestampFormatter from '../client-timestamp-formatter'; +import { PaginatedResponse } from '@/lib/types'; +import { Resizable } from 're-resizable'; interface DatasetProps { dataset: DatasetType; @@ -42,7 +42,7 @@ export default function Dataset({ } const parsed = param ? parseInt(param as string) : defaultValue; return isNaN(parsed) ? defaultValue : parsed; - } + }; const pageNumber = parseNumericSearchParam('pageNumber', 0); const pageSize = Math.max(parseNumericSearchParam('pageSize', 50), 1); @@ -73,16 +73,16 @@ export default function Dataset({ title: 'Error deleting datapoints', }); } - } + }; const getDatapoints = async () => { setDatapoints(undefined); let url = `/api/projects/${projectId}/datasets/` + `${dataset.id}/datapoints?pageNumber=${pageNumber}&pageSize=${pageSize}`; const res = await fetch(url, { - method: "GET", + method: 'GET', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, }); @@ -108,20 +108,20 @@ export default function Dataset({ size: 200, }, { - accessorFn: (row) => row.target ? JSON.stringify(row.target) : "-", + accessorFn: (row) => row.target ? JSON.stringify(row.target) : '-', header: 'Target', size: 200, }, { - accessorFn: (row) => row.metadata ? JSON.stringify(row.metadata) : "-", + accessorFn: (row) => row.metadata ? JSON.stringify(row.metadata) : '-', header: 'Metadata', size: 200, }, - ] + ]; return (
-
+

diff --git a/frontend/components/dataset/delete-datapoints-dialog.tsx b/frontend/components/dataset/delete-datapoints-dialog.tsx index 492e7444..fa508503 100644 --- a/frontend/components/dataset/delete-datapoints-dialog.tsx +++ b/frontend/components/dataset/delete-datapoints-dialog.tsx @@ -1,8 +1,8 @@ -import { Dialog, DialogHeader, DialogContent, DialogTrigger, DialogTitle, DialogFooter } from "../ui/dialog"; -import { Button } from "../ui/button"; -import { Label } from "../ui/label"; -import { useState } from "react"; -import { Loader } from "lucide-react"; +import { Dialog, DialogHeader, DialogContent, DialogTrigger, DialogTitle, DialogFooter } from '../ui/dialog'; +import { Button } from '../ui/button'; +import { Label } from '../ui/label'; +import { useState } from 'react'; +import { Loader } from 'lucide-react'; export interface DeleteDatapointsDialogProps { selectedDatapointIds: string[]; @@ -57,5 +57,5 @@ export default function DeleteDatapointsDialog({ - ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/dataset/index-dataset-dialog.tsx b/frontend/components/dataset/index-dataset-dialog.tsx index 2f8d6df3..536ecffd 100644 --- a/frontend/components/dataset/index-dataset-dialog.tsx +++ b/frontend/components/dataset/index-dataset-dialog.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; -import { Button } from '@/components/ui/button' -import { useToast } from '../../lib/hooks/use-toast' +import { Button } from '@/components/ui/button'; +import { useToast } from '../../lib/hooks/use-toast'; import { Dialog, DialogContent, @@ -9,7 +9,7 @@ import { DialogHeader, DialogTitle, DialogTrigger -} from '@/components/ui/dialog' +} from '@/components/ui/dialog'; import { Loader, NotepadText } from 'lucide-react'; import { useProjectContext } from '@/contexts/project-context'; import { Label } from '@/components/ui/label'; @@ -23,10 +23,10 @@ interface IndexDatasetDialogProps { } export default function IndexDatasetDialog({ datasetId, defaultDataset, onUpdate }: IndexDatasetDialogProps) { - const { projectId } = useProjectContext() + const { projectId } = useProjectContext(); const [isDialogOpen, setIsDialogOpen] = useState(false); - const [selectedIndexKey, setSelectedIndexKey] = useState(defaultDataset.indexedOn ?? ""); + const [selectedIndexKey, setSelectedIndexKey] = useState(defaultDataset.indexedOn ?? ''); const [isLoading, setIsLoading] = useState(false); const { toast } = useToast(); @@ -39,19 +39,19 @@ export default function IndexDatasetDialog({ datasetId, defaultDataset, onUpdate method: 'POST', body: JSON.stringify({ indexColumn: selectedIndexKey }), cache: 'no-cache', - }) + }); if (res.status != 200) { setIsLoading(false); toast({ title: 'Error indexing dataset', - }) - return + }); + return; } toast({ title: 'Successfully indexed dataset', - }) + }); const newDataset = await res.json(); setSelectedIndexKey(newDataset.indexedOn); @@ -59,7 +59,7 @@ export default function IndexDatasetDialog({ datasetId, defaultDataset, onUpdate setIsLoading(false); setIsDialogOpen(false); - } + }; return ( @@ -77,9 +77,9 @@ export default function IndexDatasetDialog({ datasetId, defaultDataset, onUpdate Index dataset - - ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/dataset/manual-add-datapoint-dialog.tsx b/frontend/components/dataset/manual-add-datapoint-dialog.tsx index 2e223284..c0b40559 100644 --- a/frontend/components/dataset/manual-add-datapoint-dialog.tsx +++ b/frontend/components/dataset/manual-add-datapoint-dialog.tsx @@ -1,10 +1,10 @@ -import { useProjectContext } from "@/contexts/project-context"; -import { useCallback, useState } from "react"; -import { useToast } from '../../lib/hooks/use-toast' -import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "../ui/dialog"; -import { Button } from "../ui/button"; +import { useProjectContext } from '@/contexts/project-context'; +import { useCallback, useState } from 'react'; +import { useToast } from '../../lib/hooks/use-toast'; +import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '../ui/dialog'; +import { Button } from '../ui/button'; import { Loader, Plus } from 'lucide-react'; -import Ide from "../ui/ide"; +import Ide from '../ui/ide'; const DEFAULT_DATA = '{\n "data": {},\n "target": {}\n}'; @@ -15,15 +15,15 @@ interface TypeDatapointDialogProps { // Dialog to add a single datapoint to a dataset by manually typing export default function ManualAddDatapointDialog({ datasetId, onUpdate }: TypeDatapointDialogProps) { - const { projectId } = useProjectContext() + const { projectId } = useProjectContext(); const [isDialogOpen, setIsDialogOpen] = useState(false); const { toast } = useToast(); const [isLoading, setIsLoading] = useState(false); const [data, setData] = useState(DEFAULT_DATA); // Datapoint's "data" field const showError = useCallback((message: string) => { - toast({ title: "Add datapoint error", variant: 'destructive', description: message, duration: 10000 }) - }, []) + toast({ title: 'Add datapoint error', variant: 'destructive', description: message, duration: 10000 }); + }, []); const addDatapoint = async () => { setIsLoading(true); @@ -38,17 +38,17 @@ export default function ManualAddDatapointDialog({ datasetId, onUpdate }: TypeDa datapoints: [JSON.parse(data)], }), cache: 'no-cache', - }) + }); if (res.status != 200) { showError('Error adding datapoint'); setIsLoading(false); - return + return; } toast({ title: 'Successfully added datapoint' - }) + }); onUpdate?.(); setIsLoading(false); @@ -56,9 +56,9 @@ export default function ManualAddDatapointDialog({ datasetId, onUpdate }: TypeDa } catch (e) { showError('Please enter a valid JSON'); setIsLoading(false); - return + return; } - } + }; return ( { @@ -90,5 +90,5 @@ export default function ManualAddDatapointDialog({ datasetId, onUpdate }: TypeDa - ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/dataset/unstructured-file-upload.tsx b/frontend/components/dataset/unstructured-file-upload.tsx index da1b5dc1..0c2d45d6 100644 --- a/frontend/components/dataset/unstructured-file-upload.tsx +++ b/frontend/components/dataset/unstructured-file-upload.tsx @@ -42,9 +42,9 @@ export default function UnstructuredFileUpload({ uploadFile( file, `/api/projects/${projectId}/datasets/${datasetId}/file-upload`, true ).then(_ => { - onSuccessfulUpload?.() + onSuccessfulUpload?.(); }).catch(error => { - toast({ title: 'Error', description: 'Error uploading file' + error }) + toast({ title: 'Error', description: 'Error uploading file' + error }); }).finally(() => { setIsLoading(false); }); diff --git a/frontend/components/datasets/create-dataset-dialog.tsx b/frontend/components/datasets/create-dataset-dialog.tsx index 0530a74a..f04fe4db 100644 --- a/frontend/components/datasets/create-dataset-dialog.tsx +++ b/frontend/components/datasets/create-dataset-dialog.tsx @@ -31,7 +31,7 @@ export default function CreateDatasetDialog({ }: CreateDatasetDialogProps) { const dataset = { name: newDatasetName, projectId: projectId - } + }; const res = await fetch(`/api/projects/${projectId}/datasets`, { method: 'POST', @@ -84,5 +84,5 @@ export default function CreateDatasetDialog({ }: CreateDatasetDialogProps) { - ) + ); } diff --git a/frontend/components/datasets/datasets.tsx b/frontend/components/datasets/datasets.tsx index 7ae906e1..5421a849 100644 --- a/frontend/components/datasets/datasets.tsx +++ b/frontend/components/datasets/datasets.tsx @@ -14,7 +14,7 @@ import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu" +} from '@/components/ui/dropdown-menu'; import useSWR from 'swr'; import CreateDatasetDialog from './create-dataset-dialog'; import UpdateDatasetDialog from './update-dataset-dialog'; @@ -30,7 +30,7 @@ export default function Datasets() { const { projectId } = useProjectContext(); const fetcher = (url: string) => fetch(url).then(res => res.json()); const router = useRouter(); - const { data, isLoading, mutate } = useSWR>(`/api/projects/${projectId}/datasets/`, fetcher) + const { data, isLoading, mutate } = useSWR>(`/api/projects/${projectId}/datasets/`, fetcher); const updateDataset = async (datasetId: string, dataset: Dataset) => { const res = await fetch(`/api/projects/${projectId}/datasets/${datasetId}`, { @@ -41,55 +41,51 @@ export default function Datasets() { }); res.json(); mutate(); - } + }; const deleteDataset = async (datasetId: string) => { const res = await fetch(`/api/projects/${projectId}/datasets/${datasetId}`, { method: 'DELETE', }); mutate(); - } + }; const columns: ColumnDef[] = [ { - cell: ({ row }) => { - return {row.original.id} - }, + cell: ({ row }) => {row.original.id}, size: 300, - header: "ID", + header: 'ID', }, { - accessorKey: "name", - header: "name", + accessorKey: 'name', + header: 'name', }, { - header: "Created at", - accessorKey: "createdAt", + header: 'Created at', + accessorKey: 'createdAt', cell: (row) => , }, { - id: "actions", - cell: ({ row }) => { - return ( - - - - - - { deleteDataset(row.original.id); e.stopPropagation() }} - > + id: 'actions', + cell: ({ row }) => ( + + + + + + { deleteDataset(row.original.id); e.stopPropagation(); }} + > Delete - - - - - ) - }, + + + + + ), } - ] + ]; return (
diff --git a/frontend/components/datasets/update-dataset-dialog.tsx b/frontend/components/datasets/update-dataset-dialog.tsx index 4eaf5222..265ece41 100644 --- a/frontend/components/datasets/update-dataset-dialog.tsx +++ b/frontend/components/datasets/update-dataset-dialog.tsx @@ -33,7 +33,7 @@ export default function UpdateDatasetDialog({ oldDataset, doUpdate, isDropdown = doUpdate?.(datasetId, dataset!); setIsLoading(false); setOpen(false); - } + }; return (
e.stopPropagation()}> @@ -61,7 +61,7 @@ export default function UpdateDatasetDialog({ oldDataset, doUpdate, isDropdown = />
- diff --git a/frontend/components/env/add-env-var-dialog.tsx b/frontend/components/env/add-env-var-dialog.tsx index 2e3b84e3..9c064122 100644 --- a/frontend/components/env/add-env-var-dialog.tsx +++ b/frontend/components/env/add-env-var-dialog.tsx @@ -1,9 +1,9 @@ -import { Button } from "@/components/ui/button" -import { Label } from "@/components/ui/label"; -import { useState } from "react"; -import { Input } from "../ui/input"; -import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "../ui/dialog"; -import { Plus } from "lucide-react"; +import { Button } from '@/components/ui/button'; +import { Label } from '@/components/ui/label'; +import { useState } from 'react'; +import { Input } from '../ui/input'; +import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '../ui/dialog'; +import { Plus } from 'lucide-react'; import { Select, SelectContent, @@ -11,7 +11,7 @@ import { SelectTrigger, SelectValue, } from '@/components/ui/select'; -import { EnvVars } from "@/lib/env/utils"; +import { EnvVars } from '@/lib/env/utils'; interface AddEnvVarDialogProps { onAdd: (name: string, value: string) => void @@ -19,9 +19,9 @@ interface AddEnvVarDialogProps { export default function AddEnvVarDialog({ onAdd }: AddEnvVarDialogProps) { - const [envVarType, setEnvVarType] = useState('') - const [envVarName, setEnvVarName] = useState('') - const [envVarValue, setEnvVarValue] = useState('') + const [envVarType, setEnvVarType] = useState(''); + const [envVarName, setEnvVarName] = useState(''); + const [envVarValue, setEnvVarValue] = useState(''); return ( @@ -40,11 +40,11 @@ export default function AddEnvVarDialog({ onAdd }: AddEnvVarDialogProps) { { - setEnvVarName(e.target.value) + setEnvVarName(e.target.value); }} /> } @@ -77,7 +77,7 @@ export default function AddEnvVarDialog({ onAdd }: AddEnvVarDialogProps) { placeholder="Value" spellCheck={false} onChange={(e) => { - setEnvVarValue(e.target.value) + setEnvVarValue(e.target.value); }} />
@@ -86,10 +86,10 @@ export default function AddEnvVarDialog({ onAdd }: AddEnvVarDialogProps) {

- ) + ); } diff --git a/frontend/components/evaluation/chart.tsx b/frontend/components/evaluation/chart.tsx index dadf70a1..8e9bc621 100644 --- a/frontend/components/evaluation/chart.tsx +++ b/frontend/components/evaluation/chart.tsx @@ -3,26 +3,26 @@ import { ChartContainer, ChartTooltip, ChartTooltipContent, -} from "@/components/ui/chart" -import { useProjectContext } from "@/contexts/project-context" -import { cn, swrFetcher } from "@/lib/utils" -import { Bar, BarChart, CartesianGrid, XAxis } from "recharts" -import useSWR from "swr" -import { Skeleton } from "../ui/skeleton" -import React, { useEffect, useState } from "react" -import { usePathname, useSearchParams } from "next/navigation" +} from '@/components/ui/chart'; +import { useProjectContext } from '@/contexts/project-context'; +import { cn, swrFetcher } from '@/lib/utils'; +import { Bar, BarChart, CartesianGrid, XAxis } from 'recharts'; +import useSWR from 'swr'; +import { Skeleton } from '../ui/skeleton'; +import React, { useEffect, useState } from 'react'; +import { usePathname, useSearchParams } from 'next/navigation'; const URL_QUERY_PARAMS = { COMPARE_EVAL_ID: 'comparedEvaluationId', -} +}; const getEvaluationIdFromPathname = (pathName: string) => { if (pathName.endsWith('/')) { - pathName = pathName.slice(0, -1); + pathName = pathName.slice(0, -1); } const pathParts = pathName.split('/'); return pathParts[pathParts.length - 1]; -} +}; type BucketRow = { lowerBound: number; @@ -30,15 +30,11 @@ type BucketRow = { heights: number[]; } -const getTransformedData = (data: []) => { - return data.map((row: BucketRow, index: number) => { - return { - index, - height: row.heights[0], - comparedHeight: row.heights.length > 1 ? row.heights[1] : undefined, - } - }) -} +const getTransformedData = (data: []) => data.map((row: BucketRow, index: number) => ({ + index, + height: row.heights[0], + comparedHeight: row.heights.length > 1 ? row.heights[1] : undefined, +})); function renderTick(tickProps: any) { const { x, y, payload } = tickProps; @@ -78,7 +74,7 @@ export default function Chart({ scoreName, className }: ChartProps) { const [evaluationId, setEvaluationId] = useState(getEvaluationIdFromPathname(pathName)); const [comparedEvaluationId, setComparedEvaluationId] = useState(searchParams.get(URL_QUERY_PARAMS.COMPARE_EVAL_ID)); - + const { data, isLoading, error } = useSWR(`/api/projects/${projectId}/evaluation-score-distribution?evaluationIds=${evaluationId + (comparedEvaluationId ? `,${comparedEvaluationId}` : '')}&scoreName=${scoreName}`, swrFetcher); useEffect(() => { @@ -88,15 +84,15 @@ export default function Chart({ scoreName, className }: ChartProps) { useEffect(() => { setComparedEvaluationId(searchParams.get(URL_QUERY_PARAMS.COMPARE_EVAL_ID)); }, [searchParams]); - + const chartConfig = { - ["index"]: { - color: "hsl(var(--chart-1))", + ['index']: { + color: 'hsl(var(--chart-1))', }, - } satisfies ChartConfig + } satisfies ChartConfig; return ( -
+
{/*
Score distribution: {scoreName}
*/} @@ -123,5 +119,5 @@ export default function Chart({ scoreName, className }: ChartProps) {
- ) + ); } diff --git a/frontend/components/evaluation/evaluation.tsx b/frontend/components/evaluation/evaluation.tsx index 830ca70a..74416671 100644 --- a/frontend/components/evaluation/evaluation.tsx +++ b/frontend/components/evaluation/evaluation.tsx @@ -1,24 +1,24 @@ 'use client'; -import { Evaluation as EvaluationType, EvaluationDatapointPreviewWithCompared, EvaluationResultsInfo } from "@/lib/evaluation/types"; -import { ColumnDef } from "@tanstack/react-table"; -import { useEffect, useState } from "react"; -import { DataTable } from "../ui/datatable"; -import { useProjectContext } from "@/contexts/project-context"; -import Header from "../ui/header"; -import { usePathname, useRouter, useSearchParams } from "next/navigation"; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; -import { mergeOriginalWithComparedDatapoints } from "@/lib/evaluation/utils"; -import { ArrowRight } from "lucide-react"; -import { Button } from "../ui/button"; -import { Resizable } from "re-resizable"; -import TraceView from "../traces/trace-view"; -import Chart from "./chart"; -import ScoreCard from "./score-card"; +import { Evaluation as EvaluationType, EvaluationDatapointPreviewWithCompared, EvaluationResultsInfo } from '@/lib/evaluation/types'; +import { ColumnDef } from '@tanstack/react-table'; +import { useEffect, useState } from 'react'; +import { DataTable } from '../ui/datatable'; +import { useProjectContext } from '@/contexts/project-context'; +import Header from '../ui/header'; +import { usePathname, useRouter, useSearchParams } from 'next/navigation'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'; +import { mergeOriginalWithComparedDatapoints } from '@/lib/evaluation/utils'; +import { ArrowRight } from 'lucide-react'; +import { Button } from '../ui/button'; +import { Resizable } from 're-resizable'; +import TraceView from '../traces/trace-view'; +import Chart from './chart'; +import ScoreCard from './score-card'; const URL_QUERY_PARAMS = { COMPARE_EVAL_ID: 'comparedEvaluationId', -} +}; interface EvaluationProps { evaluationInfo: EvaluationResultsInfo; @@ -41,7 +41,7 @@ export default function Evaluation({ useEffect(() => { const comparedEvaluationId = searchParams.get(URL_QUERY_PARAMS.COMPARE_EVAL_ID); handleComparedEvaluationChange(comparedEvaluationId ?? null); - }, []) + }, []); let defaultResults = evaluationInfo.results as EvaluationDatapointPreviewWithCompared[]; const [results, setResults] = useState(defaultResults); @@ -55,30 +55,33 @@ export default function Evaluation({ // This is ok to search for selected datapoint among defaultResults before we have pagination const [selectedDatapoint, setSelectedDatapoint] = useState(defaultResults.find((result) => result.id === searchParams.get('datapointId')) ?? null); - - // Selected score name must usually not be undefined, as we expect to have at least one score, it's done just to not throw error if there are no scores - const [selectedScoreName, setSelectedScoreName] = useState(scoreColumns.size > 0 ? Array.from(scoreColumns)[0] : undefined); + + // Selected score name must usually not be undefined, as we expect to have at least one score, + // it's done just to not throw error if there are no scores + const [selectedScoreName, setSelectedScoreName] = useState( + scoreColumns.size > 0 ? Array.from(scoreColumns)[0] : undefined + ); // Columns used when there is no compared evaluation let defaultColumns: ColumnDef[] = [ { accessorFn: (row) => JSON.stringify(row.data), - header: "Data", + header: 'Data', }, { - accessorFn: (row) => row.target ? JSON.stringify(row.target) : "-", - header: "Target", + accessorFn: (row) => row.target ? JSON.stringify(row.target) : '-', + header: 'Target', }, { - accessorFn: (row) => row.executorOutput ? JSON.stringify(row.executorOutput) : "-", - header: "Output", + accessorFn: (row) => row.executorOutput ? JSON.stringify(row.executorOutput) : '-', + header: 'Output', }, ]; defaultColumns = defaultColumns.concat(Array.from(scoreColumns).map((scoreColumn) => ({ - header: scoreColumn, - accessorFn: (row) => row.scores?.[scoreColumn] ?? "-", - size: 150, - }))); + header: scoreColumn, + accessorFn: (row) => row.scores?.[scoreColumn] ?? '-', + size: 150, + }))); const [columns, setColumns] = useState(defaultColumns); @@ -87,7 +90,7 @@ export default function Evaluation({ searchParams.set('datapointId', row.id); router.push(`${pathName}?${searchParams.toString()}`); - } + }; const handleComparedEvaluationChange = (comparedEvaluationId: string | null) => { if (comparedEvaluationId === undefined) { @@ -113,28 +116,26 @@ export default function Evaluation({ let columnsWithCompared: ColumnDef[] = [ { accessorFn: (row) => JSON.stringify(row.data), - header: "Data", + header: 'Data', }, { - accessorFn: (row) => row.target ? JSON.stringify(row.target) : "-", - header: "Target", + accessorFn: (row) => row.target ? JSON.stringify(row.target) : '-', + header: 'Target', }, ]; columnsWithCompared = columnsWithCompared.concat(Array.from(scoreColumns).map((scoreColumn) => ({ header: scoreColumn, - cell: (row) => { - return
-
{row.row.original.comparedScores?.[scoreColumn] ?? "-"}
- -
{row.row.original.scores?.[scoreColumn] ?? "-"}
-
- }, + cell: (row) =>
+
{row.row.original.comparedScores?.[scoreColumn] ?? '-'}
+ +
{row.row.original.scores?.[scoreColumn] ?? '-'}
+
, }))); setColumns(columnsWithCompared); - }) + }); searchParams.set(URL_QUERY_PARAMS.COMPARE_EVAL_ID, comparedEvaluationId); router.push(`${pathName}?${searchParams.toString()}`); - } + }; // It will reload the page const handleEvaluationChange = (evaluationId: string) => { @@ -143,7 +144,7 @@ export default function Evaluation({ const pathParts = currentPathName.split('/'); pathParts[pathParts.length - 1] = evaluationId; router.push(`${pathParts.join('/')}?${searchParams.toString()}`); - } + }; return (
@@ -178,11 +179,13 @@ export default function Evaluation({ - {evaluations.filter((item) => (comparedEvaluation === null || item.id != comparedEvaluation.id)).map((item) => ( - - {item.name} - - ))} + {evaluations + .filter((item) => (comparedEvaluation === null || item.id != comparedEvaluation.id)) + .map((item) => ( + + {item.name} + + ))}
@@ -191,7 +194,7 @@ export default function Evaluation({ @@ -279,4 +282,4 @@ export default function Evaluation({ }
); -} \ No newline at end of file +} diff --git a/frontend/components/evaluation/score-card.tsx b/frontend/components/evaluation/score-card.tsx index 390534a1..8a1d902c 100644 --- a/frontend/components/evaluation/score-card.tsx +++ b/frontend/components/evaluation/score-card.tsx @@ -1,14 +1,14 @@ -import { useProjectContext } from "@/contexts/project-context"; -import { swrFetcher } from "@/lib/utils"; -import { usePathname, useSearchParams } from "next/navigation"; -import { useEffect, useState } from "react"; -import useSWR from "swr"; -import { Skeleton } from "../ui/skeleton"; -import { ArrowRight } from "lucide-react"; +import { useProjectContext } from '@/contexts/project-context'; +import { swrFetcher } from '@/lib/utils'; +import { usePathname, useSearchParams } from 'next/navigation'; +import { useEffect, useState } from 'react'; +import useSWR from 'swr'; +import { Skeleton } from '../ui/skeleton'; +import { ArrowRight } from 'lucide-react'; const URL_QUERY_PARAMS = { COMPARE_EVAL_ID: 'comparedEvaluationId', -} +}; const getEvaluationIdFromPathname = (pathName: string) => { if (pathName.endsWith('/')) { @@ -16,7 +16,7 @@ const getEvaluationIdFromPathname = (pathName: string) => { } const pathParts = pathName.split('/'); return pathParts[pathParts.length - 1]; -} +}; interface ScoreCardProps { scoreName: string; @@ -65,15 +65,17 @@ export default function ScoreCard({scoreName}: ScoreCardProps) { {!isComparedLoading && comparedData && !isComparedError && comparedData.averageValue != null && (
= comparedData.averageValue ? 'text-green-400' : 'text-red-400')}`}> {data.averageValue >= comparedData.averageValue ? 'â–²' : 'â–¼'} - {Math.abs(data.averageValue - comparedData.averageValue).toFixed(2)} + {Math.abs(data.averageValue - comparedData.averageValue).toFixed(2)} {comparedData.averageValue !== 0 && ( - ({((data.averageValue - comparedData.averageValue) / comparedData.averageValue * 100).toFixed(2)}%) + + ({((data.averageValue - comparedData.averageValue) / comparedData.averageValue * 100).toFixed(2)}%) + )}
)} -
+ )} - ) + ); } diff --git a/frontend/components/evaluations/create-evaluation-dialog.tsx b/frontend/components/evaluations/create-evaluation-dialog.tsx deleted file mode 100644 index f51566ce..00000000 --- a/frontend/components/evaluations/create-evaluation-dialog.tsx +++ /dev/null @@ -1,177 +0,0 @@ -'use client'; - -import { Button } from '@/components/ui/button'; -import { - Dialog, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger -} from '@/components/ui/dialog'; -import { Label } from '@/components/ui/label'; -import { Input } from '@/components/ui/input'; -import { Info, Loader, Plus } from 'lucide-react'; -import { cn, getLocalDevSessions, getLocalEnvVars } from '@/lib/utils'; -import { useState } from 'react'; -import { useRouter } from 'next/navigation'; -import DatasetSelect from '../ui/dataset-select'; -import { useProjectContext } from '@/contexts/project-context'; -import PipelineSelect from '../ui/pipeline-select'; -import { Switch } from '../ui/switch'; -import { DisplayableGraph, GenericNode } from '@/lib/flow/types'; - - -export default function CreateEvaluationDialog() { - const { projectId } = useProjectContext(); - const env = getLocalEnvVars(projectId); - const devSessionIds = getLocalDevSessions - const router = useRouter(); - const [isDialogOpen, setIsDialogOpen] = useState(false); - - const [isLoading, setIsLoading] = useState(false); - - const [name, setName] = useState(''); - const [datasetId, setDatasetId] = useState(null); - const [evaluatorPipelineVersionId, setEvaluatorPipelineVersionId] = useState(null); - const [evaluatorPipelineId, setEvaluatorPipelineId] = useState(null); - const [evaluatorPipelineGraph, setEvaluatorPipelineGraph] = useState(null); - - const [enableExecutorPipeline, setEnableExecutorPipeline] = useState(true); - const [executorPipelineVersionId, setExecutorPipelineVersionId] = useState(null); - const [executorPipelineId, setExecutorPipelineId] = useState(null); - const [executorPipelineGraph, setExecutorPipelineGraph] = useState(null); - - const createNewEvaluation = async () => { - setIsLoading(true); - - const res = await fetch(`/api/projects/${projectId}/evaluations/`, { - method: 'POST', - body: JSON.stringify({ - name, - datasetId, - executorPipelineVersionId: enableExecutorPipeline ? executorPipelineVersionId : null, - evaluatorPipelineVersionId, - env, - devSessionIds, - }), - }); - const json = await res.json(); - setName(''); - setDatasetId(null); - setEvaluatorPipelineVersionId(null); - setExecutorPipelineVersionId(null); - setEnableExecutorPipeline(true); - setIsLoading(false); - setIsDialogOpen(false); - router.push(`/project/${projectId}/evaluations/${json.id}`); - } - - const isEvaluationComplete = (): boolean => { - const isExecutorPipelineComplete = enableExecutorPipeline ? executorPipelineId != null && executorPipelineVersionId != null : true; - return isExecutorPipelineComplete && name.trim().length > 0 && datasetId != null && evaluatorPipelineVersionId != null; - } - - // const extractNodeNames = (graph: DisplayableGraph | null, nodeType: string): string[] | null => { - // if (graph == null) { - // return null; - // } - // const nodes = graph.nodes.filter((node) => node.type === nodeType); - // return nodes.map(node => (node.data as GenericNode).name); - // } - // const executorInputNames = extractNodeNames(executorPipelineGraph, 'Input'); - // const executorOutputNames = extractNodeNames(executorPipelineGraph, 'Output'); - // const evaluatorInputNames = extractNodeNames(evaluatorPipelineGraph, 'Input'); - - return ( - <> - - - - - - - Create new evaluation - -
- - setName(e.target.value)} - /> -
- - -
- {enableExecutorPipeline && ( -
- { - setExecutorPipelineVersionId(pipelineVersion?.id ?? null) - setExecutorPipelineGraph(pipelineVersion?.displayableGraph ?? null) - }} - onPipelineChange={(pipeline) => { - setExecutorPipelineId(pipeline.id ?? null) - }} - defaultPipelineId={executorPipelineId ?? undefined} - defaultPipelineVersionId={executorPipelineVersionId ?? undefined} - hideWorkshopVersions - /> - {/* {executorInputNames != null && ( -
- - -
- )} - {executorOutputNames != null && ( -
- - -
- )} */} -
- )} - - { - setEvaluatorPipelineVersionId(pipelineVersion?.id ?? null); - setEvaluatorPipelineGraph(pipelineVersion?.displayableGraph ?? null); - }} - onPipelineChange={(pipeline) => { - if (pipeline.id !== evaluatorPipelineId) { - setEvaluatorPipelineVersionId(null); - setEvaluatorPipelineGraph(null); - } - setEvaluatorPipelineId(pipeline.id ?? null); - }} - hideWorkshopVersions - /> - {/* {evaluatorInputNames && ( -
- - -
- )} */} - - setDatasetId(dataset.id)} /> -
- - - -
-
- - ); -} diff --git a/frontend/components/evaluations/evaluations.tsx b/frontend/components/evaluations/evaluations.tsx index a70bed6c..ae9325a6 100644 --- a/frontend/components/evaluations/evaluations.tsx +++ b/frontend/components/evaluations/evaluations.tsx @@ -1,15 +1,15 @@ -'use client' +'use client'; -import { useProjectContext } from "@/contexts/project-context"; -import { Evaluation } from "@/lib/evaluation/types"; -import { ColumnDef } from "@tanstack/react-table"; -import ClientTimestampFormatter from "../client-timestamp-formatter"; -import { useRouter } from "next/navigation"; -import { DataTable } from "../ui/datatable"; -import Mono from "../ui/mono"; -import Header from "../ui/header"; -import EvalsPagePlaceholder from "./page-placeholder"; -import { useUserContext } from "@/contexts/user-context"; +import { useProjectContext } from '@/contexts/project-context'; +import { Evaluation } from '@/lib/evaluation/types'; +import { ColumnDef } from '@tanstack/react-table'; +import ClientTimestampFormatter from '../client-timestamp-formatter'; +import { useRouter } from 'next/navigation'; +import { DataTable } from '../ui/datatable'; +import Mono from '../ui/mono'; +import Header from '../ui/header'; +import EvalsPagePlaceholder from './page-placeholder'; +import { useUserContext } from '@/contexts/user-context'; export interface EvaluationProps { evaluations: Evaluation[]; @@ -23,23 +23,23 @@ export default function Evaluations({ evaluations }: EvaluationProps) { const columns: ColumnDef[] = [ { - accessorKey: "groupId", - header: "Group id", + accessorKey: 'groupId', + header: 'Group id', size: 120 }, { - accessorKey: "id", + accessorKey: 'id', cell: (row) => {String(row.getValue())}, - header: "ID", + header: 'ID', size: 300 }, { - accessorKey: "name", - header: "Name", + accessorKey: 'name', + header: 'Name', }, { - header: "Created at", - accessorKey: "createdAt", + header: 'Created at', + accessorKey: 'createdAt', cell: (row) => , } ]; @@ -51,7 +51,7 @@ export default function Evaluations({ evaluations }: EvaluationProps) { - ) + ); } return ( @@ -65,7 +65,7 @@ export default function Evaluations({ evaluations }: EvaluationProps) {
{ - router.push(`/project/${projectId}/evaluations/${row.original.id}`) + router.push(`/project/${projectId}/evaluations/${row.original.id}`); }} />
diff --git a/frontend/components/evaluations/page-placeholder.tsx b/frontend/components/evaluations/page-placeholder.tsx index 36f5a775..45036226 100644 --- a/frontend/components/evaluations/page-placeholder.tsx +++ b/frontend/components/evaluations/page-placeholder.tsx @@ -1,13 +1,13 @@ -import { useState } from "react"; -import Code from "../ui/code"; -import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"; -import { PYTHON_INSTALL, TYPESCRIPT_INSTALL } from "@/lib/const"; -import { useProjectContext } from "@/contexts/project-context"; +import { useState } from 'react'; +import Code from '../ui/code'; +import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'; +import { PYTHON_INSTALL, TYPESCRIPT_INSTALL } from '@/lib/const'; +import { useProjectContext } from '@/contexts/project-context'; export default function EvalsPagePlaceholder() { const { projectId } = useProjectContext(); const [tabValue, setTabValue] = useState('python'); - + const pythonEval = `from lmnr import evaluate evaluate( @@ -23,7 +23,7 @@ evaluate( }, group_id="my_first_feature", project_api_key='' -)` +)`; const tsEval = `import { evaluate } from '@lmnr-ai/lmnr'; evaluate({ @@ -42,7 +42,7 @@ evaluate({ projectApiKey: '' } }) -` +`; return (
@@ -50,7 +50,7 @@ evaluate({

Evaluations

- You don{"'"}t have any evaluations in this project yet. + You don{'\''}t have any evaluations in this project yet. To run an evaluation you can start by following the example below.

Install Laminar

@@ -100,7 +100,7 @@ evaluate({

Cannot run evaluations?

Message us - and we{"'"}ll be happy to help. + and we{'\''}ll be happy to help.

diff --git a/frontend/components/event/delete-event-template-dialog.tsx b/frontend/components/event/delete-event-template-dialog.tsx index 0cd4f58d..ae477db7 100644 --- a/frontend/components/event/delete-event-template-dialog.tsx +++ b/frontend/components/event/delete-event-template-dialog.tsx @@ -41,7 +41,7 @@ export default function DeleteEventTemplateDialog({ setIsDialogOpen(false); router.push(`/project/${projectId}/event-templates`); router.refresh(); - } + }; return ( @@ -57,7 +57,8 @@ export default function DeleteEventTemplateDialog({ Delete event {defaultEventTemplate.name} - ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/pipeline/nodes/error-node.tsx b/frontend/components/pipeline/nodes/error-node.tsx index 79371960..4d45be9f 100644 --- a/frontend/components/pipeline/nodes/error-node.tsx +++ b/frontend/components/pipeline/nodes/error-node.tsx @@ -1,14 +1,12 @@ -import { memo } from 'react' -import GenericNodeComponent from './generic-node' -import { ErrorNode } from '@/lib/flow/types' +import { memo } from 'react'; +import GenericNodeComponent from './generic-node'; +import { ErrorNode } from '@/lib/flow/types'; -const ErrorNodeComponent = ({ id, data }: { id: string, data: ErrorNode }) => { - return ( - <> - - - - ) -} +const ErrorNodeComponent = ({ id, data }: { id: string, data: ErrorNode }) => ( + <> + + + +); -export default memo(ErrorNodeComponent) +export default memo(ErrorNodeComponent); diff --git a/frontend/components/pipeline/nodes/extractor-node.tsx b/frontend/components/pipeline/nodes/extractor-node.tsx index 37518c8a..3f67536f 100644 --- a/frontend/components/pipeline/nodes/extractor-node.tsx +++ b/frontend/components/pipeline/nodes/extractor-node.tsx @@ -1,4 +1,4 @@ -import { ExtractorNode } from '@/lib/flow/types' +import { ExtractorNode } from '@/lib/flow/types'; import useStore from '@/lib/flow/store'; import { Label } from '@/components/ui/label'; import { memo } from 'react'; @@ -25,7 +25,7 @@ const ExtractorNodeComponent = ({ data }: { data: ExtractorNode }) => { mode="javascript" /> - ) -} + ); +}; -export default memo(ExtractorNodeComponent) +export default memo(ExtractorNodeComponent); diff --git a/frontend/components/pipeline/nodes/format-validator-node.tsx b/frontend/components/pipeline/nodes/format-validator-node.tsx index f372d158..edecdf4d 100644 --- a/frontend/components/pipeline/nodes/format-validator-node.tsx +++ b/frontend/components/pipeline/nodes/format-validator-node.tsx @@ -1,4 +1,4 @@ -import { FormatValidatorNode } from '@/lib/flow/types' +import { FormatValidatorNode } from '@/lib/flow/types'; import useStore from '@/lib/flow/store'; import { Label } from '@/components/ui/label'; import Ide from '@/components/ui/ide'; @@ -23,7 +23,7 @@ const FormatValidatorNodeComponent = ({ data }: { data: FormatValidatorNode }) = mode="javascript" /> - ) -} + ); +}; -export default FormatValidatorNodeComponent +export default FormatValidatorNodeComponent; diff --git a/frontend/components/pipeline/nodes/function-node.tsx b/frontend/components/pipeline/nodes/function-node.tsx index 4f152e21..95500b9e 100644 --- a/frontend/components/pipeline/nodes/function-node.tsx +++ b/frontend/components/pipeline/nodes/function-node.tsx @@ -1,4 +1,4 @@ -import { FunctionNode, NodeHandleType } from '@/lib/flow/types' +import { FunctionNode, NodeHandleType } from '@/lib/flow/types'; import useStore from '@/lib/flow/store'; import { Label } from '@/components/ui/label'; import { memo } from 'react'; @@ -18,22 +18,24 @@ const FunctionNodeComponent = ({ data }: { data: FunctionNode }) => {
{ - let newParameters = [...data.parameterNames] - let dynamicInputs = [...data.dynamicInputs!] - newParameters[index] = v.target.value - dynamicInputs[index].name = v.target.value - updateNodeData(data.id, { parameterNames: newParameters, dynamicInputs } as FunctionNode) + let newParameters = [...data.parameterNames]; + let dynamicInputs = [...data.dynamicInputs!]; + newParameters[index] = v.target.value; + dynamicInputs[index].name = v.target.value; + updateNodeData(data.id, { parameterNames: newParameters, dynamicInputs } as FunctionNode); }}> @@ -43,17 +45,17 @@ const FunctionNodeComponent = ({ data }: { data: FunctionNode }) => {
- ) -} + ); +}; -export default memo(FunctionNodeComponent) +export default memo(FunctionNodeComponent); diff --git a/frontend/components/pipeline/nodes/generic-node.tsx b/frontend/components/pipeline/nodes/generic-node.tsx index 10854dd7..1b077b97 100644 --- a/frontend/components/pipeline/nodes/generic-node.tsx +++ b/frontend/components/pipeline/nodes/generic-node.tsx @@ -1,14 +1,14 @@ -import useStore from '@/lib/flow/store' -import { Handle, Position, type Connection, useUpdateNodeInternals, useOnSelectionChange, Node, Edge } from 'reactflow' -import { type GenericNode, NodeType, NodeHandleType } from '@/lib/flow/types' -import { Input } from '@/components/ui/input' -import { Label } from '@/components/ui/label' -import { cn } from '@/lib/utils' -import { useFlowContext } from '@/contexts/pipeline-version-context' -import { memo, useCallback, useEffect, useState } from 'react' -import { NODE_TYPE_TO_DOCS, createNodeData } from '@/lib/flow/utils' -import { Button } from '@/components/ui/button' -import { Info, Settings, Trash } from 'lucide-react' +import useStore from '@/lib/flow/store'; +import { Handle, Position, type Connection, useUpdateNodeInternals, useOnSelectionChange, Node, Edge } from 'reactflow'; +import { type GenericNode, NodeType, NodeHandleType } from '@/lib/flow/types'; +import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; +import { cn } from '@/lib/utils'; +import { useFlowContext } from '@/contexts/pipeline-version-context'; +import { memo, useCallback, useEffect, useState } from 'react'; +import { NODE_TYPE_TO_DOCS, createNodeData } from '@/lib/flow/utils'; +import { Button } from '@/components/ui/button'; +import { Info, Settings, Trash } from 'lucide-react'; interface GenericNodeComponentProps { id: string @@ -19,73 +19,82 @@ interface GenericNodeComponentProps { const GenericNodeComponent = ({ id, data, children }: GenericNodeComponentProps) => { - const { getNode, updateNodeData, dropEdgeForHandle, edges, setNodes, setFocusedNodeId, focusedNodeId, highlightedNodeId } = useStore(state => state) - const { editable } = useFlowContext() - const [shouldUpdate, setShouldUpdate] = useState(false) - const updateNodeInternals = useUpdateNodeInternals() - const [nodeName, setNodeName] = useState(data.name) - const [isSelected, setIsSelected] = useState(false) + const { + getNode, + updateNodeData, + dropEdgeForHandle, + edges, + setNodes, + setFocusedNodeId, + focusedNodeId, + highlightedNodeId + } = useStore(state => state); + const { editable } = useFlowContext(); + const [shouldUpdate, setShouldUpdate] = useState(false); + const updateNodeInternals = useUpdateNodeInternals(); + const [nodeName, setNodeName] = useState(data.name); + const [isSelected, setIsSelected] = useState(false); const onChange = useCallback(({ nodes, edges }: { nodes: Node[], edges: Edge[] }) => { if (nodes.length === 0) { - setIsSelected(false) - return + setIsSelected(false); + return; } - setIsSelected(nodes[0].id === id) + setIsSelected(nodes[0].id === id); - }, []) + }, []); useOnSelectionChange({ onChange - }) + }); useEffect(() => { - updateNodeInternals(id) - setNodeName(data.name) - }, [data]) + updateNodeInternals(id); + setNodeName(data.name); + }, [data]); useEffect(() => { - const defaultData = createNodeData("", data.type) + const defaultData = createNodeData('', data.type); - const newDataKeys = new Set(Object.keys(defaultData)) - const currentDataKeys = new Set(Object.keys(data)) + const newDataKeys = new Set(Object.keys(defaultData)); + const currentDataKeys = new Set(Object.keys(data)); - const missingKeys = Array.from(newDataKeys).filter(key => !currentDataKeys.has(key)) + const missingKeys = Array.from(newDataKeys).filter(key => !currentDataKeys.has(key)); if (defaultData.version !== data.version) { - setShouldUpdate(true) + setShouldUpdate(true); } // model is now optional and can be disabled on LLM nodes. if (data.type === NodeType.LLM && missingKeys.length === 1 && missingKeys[0] === 'model') { - return + return; } - setShouldUpdate(missingKeys.length > 0) - }, [data]) + setShouldUpdate(missingKeys.length > 0); + }, [data]); const isValidConnection = (connection: Connection) => { - if (!connection.source || !connection.target) return false + if (!connection.source || !connection.target) return false; - const sourceNode = getNode(connection.source) - const targetNode = getNode(connection.target) + const sourceNode = getNode(connection.source); + const targetNode = getNode(connection.target); - const sourceHandleType = sourceNode?.data.outputs.find(output => output.id === connection.sourceHandle)?.type - let targetHandleType = targetNode?.data.inputs.find(input => input.id === connection.targetHandle)?.type + const sourceHandleType = sourceNode?.data.outputs.find(output => output.id === connection.sourceHandle)?.type; + let targetHandleType = targetNode?.data.inputs.find(input => input.id === connection.targetHandle)?.type; // when trying to connect to a dynamic input, the targetHandleType cannot be found in the node's inputs if (!targetHandleType) { - targetHandleType = targetNode?.data.dynamicInputs?.find(input => input.id === connection.targetHandle)?.type + targetHandleType = targetNode?.data.dynamicInputs?.find(input => input.id === connection.targetHandle)?.type; } // if target handle is any, any connection is valid - if (targetHandleType == NodeHandleType.ANY || sourceHandleType == NodeHandleType.ANY) return true + if (targetHandleType == NodeHandleType.ANY || sourceHandleType == NodeHandleType.ANY) return true; - return sourceHandleType === targetHandleType - } + return sourceHandleType === targetHandleType; + }; const [clickTimeout, setClickTimeout] = useState(null); @@ -104,17 +113,15 @@ const GenericNodeComponent = ({ id, data, children }: GenericNodeComponentProps) }; // combine data.inputs and data.fixedInputs - const inputs = data.inputs.concat(data.dynamicInputs?.map(input => { - return { - id: input.id, - name: input.name, - type: input.type, - } - }) ?? []) + const inputs = data.inputs.concat(data.dynamicInputs?.map(input => ({ + id: input.id, + name: input.name, + type: input.type, + })) ?? []); return ( <> -
+
{ handleDoubleClick(data.id) }} + onClick={() => { handleDoubleClick(data.id); }} > -
+
}
-
+
{ @@ -184,35 +187,35 @@ const GenericNodeComponent = ({ id, data, children }: GenericNodeComponentProps) variant={'destructive'} onClick={() => { - const defaultData = createNodeData("", data.type) as any + const defaultData = createNodeData('', data.type) as any; - const newDataKeys = new Set(Object.keys(defaultData)) - const currentDataKeys = new Set(Object.keys(data)) + const newDataKeys = new Set(Object.keys(defaultData)); + const currentDataKeys = new Set(Object.keys(data)); - const missingKeys = Array.from(newDataKeys).filter(key => !currentDataKeys.has(key)) + const missingKeys = Array.from(newDataKeys).filter(key => !currentDataKeys.has(key)); - const obsoleteKeys = Array.from(currentDataKeys).filter(key => !newDataKeys.has(key)) + const obsoleteKeys = Array.from(currentDataKeys).filter(key => !newDataKeys.has(key)); // add missing keys with default values amd remove obsolete keys const newData: any = { ...data, ...Object.fromEntries(missingKeys.map(key => [key, defaultData[key]])), - } + }; - obsoleteKeys.forEach(key => delete newData[key]) + obsoleteKeys.forEach(key => delete newData[key]); // drop all edges connected to this node for (const handle of data.inputs.concat(data.dynamicInputs ?? []).concat(data.outputs)) { - dropEdgeForHandle(handle.id) + dropEdgeForHandle(handle.id); } // update inputs and outputs - newData.inputs = defaultData.inputs - newData.outputs = defaultData.outputs + newData.inputs = defaultData.inputs; + newData.outputs = defaultData.outputs; - updateNodeData(id, newData) + updateNodeData(id, newData); updateNodeInternals(id); - setShouldUpdate(false) + setShouldUpdate(false); }} > Update node @@ -227,10 +230,10 @@ const GenericNodeComponent = ({ id, data, children }: GenericNodeComponentProps) className="w-full nodrag nowheel" value={nodeName} onChange={e => { - setNodeName(e.currentTarget.value) - updateNodeData(id, { name: e.currentTarget.value } as GenericNode) + setNodeName(e.currentTarget.value); + updateNodeData(id, { name: e.currentTarget.value } as GenericNode); }} - onClick={(e) => { e.stopPropagation() }} + onClick={(e) => { e.stopPropagation(); }} spellCheck={false} /> {children} @@ -267,35 +270,35 @@ const GenericNodeComponent = ({ id, data, children }: GenericNodeComponentProps)
0 ? '' : ' hidden')}> { data.outputs.map((output, i) => - ( -
- -
-
- {output.name ? output.name : "output"} + ( +
+ +
+
+ {output.name ? output.name : 'output'} +
+
-
-
- )) + )) }
@@ -305,7 +308,7 @@ const GenericNodeComponent = ({ id, data, children }: GenericNodeComponentProps)
- ) -} + ); +}; -export default memo(GenericNodeComponent) +export default memo(GenericNodeComponent); diff --git a/frontend/components/pipeline/nodes/input-node.tsx b/frontend/components/pipeline/nodes/input-node.tsx index 8bddcc03..3e58cdd5 100644 --- a/frontend/components/pipeline/nodes/input-node.tsx +++ b/frontend/components/pipeline/nodes/input-node.tsx @@ -1,6 +1,6 @@ -import GenericNodeComponent from './generic-node' -import { NodeHandleType, type InputNode } from '@/lib/flow/types' +import GenericNodeComponent from './generic-node'; +import { NodeHandleType, type InputNode } from '@/lib/flow/types'; import useStore from '@/lib/flow/store'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Label } from '@/components/ui/label'; @@ -19,7 +19,7 @@ const InputNodeComponent = ({ id, data }: { id: string, data: InputNode }) => { const newOutputs = [{ ...data.outputs[0], type: value - }] + }]; updateNodeData(id, { outputs: newOutputs, @@ -32,16 +32,19 @@ const InputNodeComponent = ({ id, data }: { id: string, data: InputNode }) => { { - Object.values(NodeHandleType).filter(t => [NodeHandleType.STRING, NodeHandleType.STRING_LIST, NodeHandleType.CHAT_MESSAGE_LIST].includes(t)).map((nodeType, i) => ( - - {nodeType} - - )) + Object.values(NodeHandleType) + .filter(t => + [NodeHandleType.STRING, NodeHandleType.STRING_LIST, NodeHandleType.CHAT_MESSAGE_LIST].includes(t)) + .map((nodeType, i) => ( + + {nodeType} + + )) } - ) -} + ); +}; -export default memo(InputNodeComponent) +export default memo(InputNodeComponent); diff --git a/frontend/components/pipeline/nodes/json-extractor-node.tsx b/frontend/components/pipeline/nodes/json-extractor-node.tsx index e61cba0d..f605a063 100644 --- a/frontend/components/pipeline/nodes/json-extractor-node.tsx +++ b/frontend/components/pipeline/nodes/json-extractor-node.tsx @@ -1,4 +1,4 @@ -import { JsonExtractorNode } from '@/lib/flow/types' +import { JsonExtractorNode } from '@/lib/flow/types'; import useStore from '@/lib/flow/store'; import { Label } from '@/components/ui/label'; import { memo } from 'react'; @@ -29,10 +29,10 @@ const JsonExtractorNodeComponent = ({ data }: { data: JsonExtractorNode }) => { minLines={3} />
- ) -} + ); +}; -export default memo(JsonExtractorNodeComponent) +export default memo(JsonExtractorNodeComponent); diff --git a/frontend/components/pipeline/nodes/llm.tsx b/frontend/components/pipeline/nodes/llm.tsx index a840011d..18b4cc2a 100644 --- a/frontend/components/pipeline/nodes/llm.tsx +++ b/frontend/components/pipeline/nodes/llm.tsx @@ -24,14 +24,16 @@ export default function LLM({ const updateNodeData = useStore((state) => state.updateNodeData); const dropEdgeForHandle = useStore((state) => state.dropEdgeForHandle); - const defaultInputs = new Map(data.dynamicInputs?.map((input) => [input.name!, input]) ?? []); + const defaultInputs = new Map( + data.dynamicInputs?.map((input) => [input.name!, input]) ?? [] + ); // stores what was last selected in the model select, so we can restore it after re-disabling the model input const [selectedModelId, setSelectedModelId] = useState(data.model ?? 'openai:gpt-3.5-turbo'); const [isPromptDisabled, setIsPromptDisabled] = useState(false); useEffect(() => { setIsPromptDisabled(selectedModelId.startsWith('openai:o1-mini') || selectedModelId.startsWith('openai:o1-preview')); - }, [selectedModelId]) + }, [selectedModelId]); return (
@@ -46,7 +48,7 @@ export default function LLM({ updateNodeData(data.id, { dynamicInputs: inputs, prompt: value - } as LLMNode) + } as LLMNode); edgeIdsToRemove.forEach((id) => { dropEdgeForHandle(id); @@ -72,7 +74,7 @@ export default function LLM({ ...data.inputs ], model: undefined - } as LLMNode) + } as LLMNode); } else { dropEdgeForHandle( data @@ -83,7 +85,7 @@ export default function LLM({ updateNodeData(data.id, { model: selectedModelId, inputs: data.inputs.filter(input => !(input.name === 'model' && input.type === NodeHandleType.STRING)) - } as LLMNode) + } as LLMNode); } }} /> @@ -96,7 +98,7 @@ export default function LLM({ onModelChange={model => { updateNodeData(data.id, { model: model.id - } as LLMNode) + } as LLMNode); setSelectedModelId(model.id); }} /> {isPromptDisabled && ( @@ -125,8 +127,8 @@ export default function LLM({ checked={data.modelParams !== null} onCheckedChange={(checked) => { updateNodeData(data.id, { - modelParams: checked ? "{\n \"temperature\": 0\n}" : null - } as LLMNode) + modelParams: checked ? '{\n "temperature": 0\n}' : null + } as LLMNode); }} />
@@ -139,7 +141,7 @@ export default function LLM({ try { updateNodeData(data.id, { modelParams: value - } as LLMNode) + } as LLMNode); } catch (e) { } }} @@ -162,7 +164,7 @@ export default function LLM({ type: NodeHandleType.CHAT_MESSAGE_LIST }, ...data.inputs] - } as LLMNode) + } as LLMNode); } else { dropEdgeForHandle( data @@ -174,7 +176,7 @@ export default function LLM({ inputs: [ ...data.inputs.filter(input => !(input.name === 'chat_messages' && input.type === NodeHandleType.CHAT_MESSAGE_LIST)) ] - } as unknown as LLMNode) + } as unknown as LLMNode); } }} @@ -195,7 +197,7 @@ export default function LLM({ name: 'messages', type: NodeHandleType.CHAT_MESSAGE_LIST }] - } as LLMNode) + } as LLMNode); } else { updateNodeData(data.id, { outputs: [{ @@ -203,7 +205,7 @@ export default function LLM({ name: 'output', type: NodeHandleType.STRING }] - } as LLMNode) + } as LLMNode); } }} /> @@ -219,10 +221,10 @@ export default function LLM({ onCheckedChange={(checked) => { updateNodeData(data.id, { stream: checked, - } as LLMNode) + } as LLMNode); }} />
- ) + ); }; diff --git a/frontend/components/pipeline/nodes/map-node.tsx b/frontend/components/pipeline/nodes/map-node.tsx index d9385803..3efb7b8c 100644 --- a/frontend/components/pipeline/nodes/map-node.tsx +++ b/frontend/components/pipeline/nodes/map-node.tsx @@ -29,7 +29,7 @@ export default function MapNodeComponent({ updateNodeData(data.id, { pipelineName: pipeline.name, pipelineId: pipeline.id - } as MapNode) + } as MapNode); }} onPipelineVersionChange={(pv) => { if (pv !== null) { @@ -37,7 +37,7 @@ export default function MapNodeComponent({ pipelineVersionName: pv.name, pipelineVersionId: pv.id, runnableGraph: pv.runnableGraph - } as MapNode) + } as MapNode); } else { updateNodeData(data.id, { pipelineVersionName: '', @@ -48,5 +48,5 @@ export default function MapNodeComponent({ }} />
- ) + ); }; diff --git a/frontend/components/pipeline/nodes/output-node.tsx b/frontend/components/pipeline/nodes/output-node.tsx index a43deedf..cc0d0d63 100644 --- a/frontend/components/pipeline/nodes/output-node.tsx +++ b/frontend/components/pipeline/nodes/output-node.tsx @@ -1,6 +1,6 @@ -import { memo } from 'react' -import GenericNodeComponent from './generic-node' -import { type OutputNode } from '@/lib/flow/types' +import { memo } from 'react'; +import GenericNodeComponent from './generic-node'; +import { type OutputNode } from '@/lib/flow/types'; import useStore from '@/lib/flow/store'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; @@ -19,7 +19,7 @@ const OutputNodeComponent = ({ id, data }: { id: string, data: OutputNode }) => - ) -} + ); +}; -export default memo(OutputNodeComponent) +export default memo(OutputNodeComponent); diff --git a/frontend/components/pipeline/nodes/semantic-search-node.tsx b/frontend/components/pipeline/nodes/semantic-search-node.tsx index 8e85549f..26571f6c 100644 --- a/frontend/components/pipeline/nodes/semantic-search-node.tsx +++ b/frontend/components/pipeline/nodes/semantic-search-node.tsx @@ -1,23 +1,23 @@ -import { memo, useState } from 'react' -import useStore from '@/lib/flow/store' -import { type SemanticSearchNode } from '@/lib/flow/types' -import { Label } from '@/components/ui/label' -import { Input } from '@/components/ui/input' -import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTrigger } from '@/components/ui/dialog' -import DatasetSelect from '@/components/ui/dataset-select' -import { Dataset } from '@/lib/dataset/types' -import { Button } from '@/components/ui/button' -import DefaultTextarea from '@/components/ui/default-textarea' -import { Database, X } from 'lucide-react' -import { Slider } from '@/components/ui/slider' +import { memo, useState } from 'react'; +import useStore from '@/lib/flow/store'; +import { type SemanticSearchNode } from '@/lib/flow/types'; +import { Label } from '@/components/ui/label'; +import { Input } from '@/components/ui/input'; +import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTrigger } from '@/components/ui/dialog'; +import DatasetSelect from '@/components/ui/dataset-select'; +import { Dataset } from '@/lib/dataset/types'; +import { Button } from '@/components/ui/button'; +import DefaultTextarea from '@/components/ui/default-textarea'; +import { Database, X } from 'lucide-react'; +import { Slider } from '@/components/ui/slider'; const SemanticSearchNodeComponent = ({ data }: { data: SemanticSearchNode; }) => { - const [selectedDataset, setSelectedDataset] = useState(null) - const [dialogOpen, setDialogOpen] = useState(false) + const [selectedDataset, setSelectedDataset] = useState(null); + const [dialogOpen, setDialogOpen] = useState(false); const id = data.id; const updateNodeData = useStore((state) => state.updateNodeData); @@ -84,7 +84,7 @@ const SemanticSearchNodeComponent = ({ { - setSelectedDataset(dataset) + setSelectedDataset(dataset); }} /> @@ -95,7 +95,7 @@ const SemanticSearchNodeComponent = ({ updateNodeData(id, { datasets: data.datasets.concat(selectedDataset!) } as SemanticSearchNode); - setDialogOpen(false) + setDialogOpen(false); }} > Add dataset diff --git a/frontend/components/pipeline/nodes/semantic-similarity-node.tsx b/frontend/components/pipeline/nodes/semantic-similarity-node.tsx index bac136ee..c49b8ecc 100644 --- a/frontend/components/pipeline/nodes/semantic-similarity-node.tsx +++ b/frontend/components/pipeline/nodes/semantic-similarity-node.tsx @@ -4,5 +4,5 @@ import { SemanticSimilarityNode } from '@/lib/flow/types'; const SemanticSimilarityNodeComponent = ({ data }: { data: SemanticSimilarityNode }) => {
-
-} \ No newline at end of file +
; +}; diff --git a/frontend/components/pipeline/nodes/semantic-switch-node.tsx b/frontend/components/pipeline/nodes/semantic-switch-node.tsx index bcdf1840..a5b775d1 100644 --- a/frontend/components/pipeline/nodes/semantic-switch-node.tsx +++ b/frontend/components/pipeline/nodes/semantic-switch-node.tsx @@ -1,5 +1,5 @@ -import { NodeHandleType, SemanticSwitchNode } from '@/lib/flow/types' +import { NodeHandleType, SemanticSwitchNode } from '@/lib/flow/types'; import useStore from '@/lib/flow/store'; import { Label } from '@/components/ui/label'; import { Button } from '@/components/ui/button'; @@ -28,9 +28,9 @@ export default function SemanticSwitchNodeComponent({ data }: { data: SemanticSw updateNodeData(id, { routes: data.routes.filter((_, i) => i !== index), outputs: data.outputs.filter((_, i) => i !== index) - } as SemanticSwitchNode) + } as SemanticSwitchNode); - dropEdgeForHandle(data.outputs[index].id) + dropEdgeForHandle(data.outputs[index].id); }}> delete route @@ -39,8 +39,10 @@ export default function SemanticSwitchNodeComponent({ data }: { data: SemanticSw { updateNodeData(id, { routes: data.routes.map((r, i) => i === index ? { ...r, name: e.currentTarget.value } : r), - outputs: data.outputs.map((output, i) => i === index ? { ...output, name: e.currentTarget.value } : output) - } as SemanticSwitchNode) + outputs: data + .outputs + .map((output, i) => i === index ? { ...output, name: e.currentTarget.value } : output) + } as SemanticSwitchNode); }} /> @@ -59,19 +61,19 @@ export default function SemanticSwitchNodeComponent({ data }: { data: SemanticSw ...r, examples: r.examples?.map((_, k) => k === i ? e.currentTarget.value : _) } : r) - } as SemanticSwitchNode) + } as SemanticSwitchNode); }} />
@@ -85,7 +87,7 @@ export default function SemanticSwitchNodeComponent({ data }: { data: SemanticSw ...r, examples: [...r.examples ?? [], ''] } : r) - } as SemanticSwitchNode) + } as SemanticSwitchNode); }} >Add example
@@ -99,17 +101,17 @@ export default function SemanticSwitchNodeComponent({ data }: { data: SemanticSw updateNodeData(id, { routes: [...data.routes, { name: 'New route', - examples: ["Example 1", "Example 2"] + examples: ['Example 1', 'Example 2'] }], outputs: [...data.outputs, { id: v4(), name: 'New route', type: NodeHandleType.STRING }] - } as SemanticSwitchNode) + } as SemanticSwitchNode); }} >Add route
- ) + ); } diff --git a/frontend/components/pipeline/nodes/string-template-node.tsx b/frontend/components/pipeline/nodes/string-template-node.tsx index 285f8318..2529e65f 100644 --- a/frontend/components/pipeline/nodes/string-template-node.tsx +++ b/frontend/components/pipeline/nodes/string-template-node.tsx @@ -19,7 +19,9 @@ const StringTemplateNodeComponent = ({ const dropEdgeForHandle = useStore((state) => state.dropEdgeForHandle); const id = data.id; - const defaultInputs = new Map(data.dynamicInputs?.map((input) => [input.name!, input]) ?? []); + const defaultInputs = new Map( + data.dynamicInputs?.map((input) => [input.name!, input]) ?? [] + ); return ( <> @@ -36,7 +38,7 @@ const StringTemplateNodeComponent = ({ updateNodeData(id, { dynamicInputs: inputs, text: value - } as StringTemplateNode) + } as StringTemplateNode); edgeIdsToRemove.forEach((id) => { dropEdgeForHandle(id); diff --git a/frontend/components/pipeline/nodes/subpipeline-node.tsx b/frontend/components/pipeline/nodes/subpipeline-node.tsx index d654af82..0a821382 100644 --- a/frontend/components/pipeline/nodes/subpipeline-node.tsx +++ b/frontend/components/pipeline/nodes/subpipeline-node.tsx @@ -29,24 +29,26 @@ export default function SubpipelineNodeComponent({ updateNodeData(data.id, { pipelineName: pipeline.name, pipelineId: pipeline.id - } as SubpipelineNode) + } as SubpipelineNode); }} onPipelineVersionChange={(pv) => { data.inputs.forEach((input) => { dropEdgeForHandle(input.id); - }) + }); if (pv !== null) { updateNodeData(data.id, { - inputs: Object.values(pv.runnableGraph.nodes).filter((node) => node.type === NodeType.INPUT).map((node) => ({ - id: node.id, - name: node.name, - type: (node as InputNode).inputType - } as GenericNodeHandle)), + inputs: Object.values(pv.runnableGraph.nodes) + .filter((node) => node.type === NodeType.INPUT) + .map((node) => ({ + id: node.id, + name: node.name, + type: (node as InputNode).inputType + } as GenericNodeHandle)), pipelineVersionName: pv.name, pipelineVersionId: pv.id, runnableGraph: pv.runnableGraph - } as SubpipelineNode) + } as SubpipelineNode); } else { updateNodeData(data.id, { inputs: [] as GenericNodeHandle[], @@ -58,5 +60,5 @@ export default function SubpipelineNodeComponent({ }} /> - ) + ); }; diff --git a/frontend/components/pipeline/nodes/switch-node.tsx b/frontend/components/pipeline/nodes/switch-node.tsx index 6157170e..ec355424 100644 --- a/frontend/components/pipeline/nodes/switch-node.tsx +++ b/frontend/components/pipeline/nodes/switch-node.tsx @@ -1,5 +1,5 @@ -import { NodeHandleType, RouterNode } from '@/lib/flow/types' +import { NodeHandleType, RouterNode } from '@/lib/flow/types'; import useStore from '@/lib/flow/store'; import { Label } from '@/components/ui/label'; import { Button } from '@/components/ui/button'; @@ -32,9 +32,9 @@ export default function SwitchNodeComponent({ data }: { data: RouterNode }) { updateNodeData(id, { routes: data.routes.filter((_, i) => i !== index), outputs: data.outputs.filter((_, i) => i !== index) - } as RouterNode) + } as RouterNode); - dropEdgeForHandle(data.outputs[index].id) + dropEdgeForHandle(data.outputs[index].id); }}> delete @@ -47,8 +47,10 @@ export default function SwitchNodeComponent({ data }: { data: RouterNode }) { onChange={(e) => { updateNodeData(id, { routes: data.routes.map((r, i) => i === index ? { ...r, name: e.currentTarget.value } : r), - outputs: data.outputs.map((output, i) => i === index ? { ...output, name: e.currentTarget.value } : output) - } as RouterNode) + outputs: data + .outputs + .map((output, i) => i === index ? { ...output, name: e.currentTarget.value } : output), + } as RouterNode); }} /> @@ -78,7 +80,7 @@ export default function SwitchNodeComponent({ data }: { data: RouterNode }) { updateNodeData(id, { routes: newRoutes, outputs: newOutputs - } as RouterNode) + } as RouterNode); }} >Add route @@ -106,19 +108,19 @@ export default function SwitchNodeComponent({ data }: { data: RouterNode }) { name: 'default' } ] - } as RouterNode) + } as RouterNode); } else { - dropEdgeForHandle(data.outputs[data.outputs.length - 1].id) + dropEdgeForHandle(data.outputs[data.outputs.length - 1].id); updateNodeData(id, { hasDefaultRoute: false, outputs: data.outputs.slice(0, data.outputs.length - 1), routes: data.routes.slice(0, data.routes.length - 1) - } as RouterNode) + } as RouterNode); } }} /> - ) + ); } diff --git a/frontend/components/pipeline/nodes/tool-call-node.tsx b/frontend/components/pipeline/nodes/tool-call-node.tsx index 60195cd6..bb6d36ee 100644 --- a/frontend/components/pipeline/nodes/tool-call-node.tsx +++ b/frontend/components/pipeline/nodes/tool-call-node.tsx @@ -1,12 +1,10 @@ -import { ToolCallNode } from "@/lib/flow/types"; +import { ToolCallNode } from '@/lib/flow/types'; import { Label } from '@/components/ui/label'; -const ToolCallNodeComponent = ({ data }: { data: ToolCallNode }) => { - return ( -
- -
- ) -} +const ToolCallNodeComponent = ({ data }: { data: ToolCallNode }) => ( +
+ +
+); export default ToolCallNodeComponent; diff --git a/frontend/components/pipeline/nodes/unify-node.tsx b/frontend/components/pipeline/nodes/unify-node.tsx index 3ba9cc82..74391cfc 100644 --- a/frontend/components/pipeline/nodes/unify-node.tsx +++ b/frontend/components/pipeline/nodes/unify-node.tsx @@ -21,7 +21,9 @@ const UnifyNodeComponent = ({ const [prompt, setSystemInstruction] = useState(data.prompt); const { updateNodeData, dropEdgeForHandle } = useStore(); - const defaultInputs = new Map(data.dynamicInputs?.map((input) => [input.name!, input]) ?? []); + const defaultInputs = new Map( + data.dynamicInputs?.map((input) => [input.name!, input]) ?? [] + ); // hack needed to update prompt from copilot message changes useEffect(() => { @@ -42,7 +44,7 @@ const UnifyNodeComponent = ({ updateNodeData(id, { dynamicInputs: inputs, prompt: value - } as UnifyNode) + } as UnifyNode); edgeIdsToRemove.forEach((id) => { dropEdgeForHandle(id); @@ -52,9 +54,14 @@ const UnifyNodeComponent = ({ }} placeholder='prompt' /> - { - updateNodeData(id, updates) - }} /> + { + updateNodeData(id, updates); + }} />
{ updateNodeData(id, { modelParams: checked ? { 'temperature': 0 } : null - } as UnifyNode) + } as UnifyNode); }} />
@@ -71,10 +78,10 @@ const UnifyNodeComponent = ({ value={JSON.stringify(data.modelParams, null, 4) ?? ''} onChange={(value) => { try { - const parsed = JSON.parse(value) + const parsed = JSON.parse(value); updateNodeData(id, { modelParams: parsed - } as UnifyNode) + } as UnifyNode); } catch (e) { } @@ -95,20 +102,20 @@ const UnifyNodeComponent = ({ name: 'chat_messages', type: NodeHandleType.CHAT_MESSAGE_LIST }] - } as UnifyNode) + } as UnifyNode); } else { dropEdgeForHandle(data.inputs[0].id); updateNodeData(id, { inputs: [] } as unknown as UnifyNode) - ; + ; } }} /> - ) + ); }; export default memo(UnifyNodeComponent); diff --git a/frontend/components/pipeline/nodes/web-search-node.tsx b/frontend/components/pipeline/nodes/web-search-node.tsx index e79b8cc0..ea3dd00f 100644 --- a/frontend/components/pipeline/nodes/web-search-node.tsx +++ b/frontend/components/pipeline/nodes/web-search-node.tsx @@ -1,6 +1,6 @@ -import { memo } from 'react' -import GenericNodeComponent from './generic-node' -import { WebSearchNode } from '@/lib/flow/types' +import { memo } from 'react'; +import GenericNodeComponent from './generic-node'; +import { WebSearchNode } from '@/lib/flow/types'; import { Label } from '@/components/ui/label'; import DefaultTextarea from '@/components/ui/default-textarea'; import useStore from '@/lib/flow/store'; @@ -24,7 +24,7 @@ const WebSearchNodeComponent = ({ defaultValue={data.limit} onChange={(e) => { - const l = Number.isNaN(Number(e.currentTarget.value)) ? 0 : Number(e.currentTarget.value) + const l = Number.isNaN(Number(e.currentTarget.value)) ? 0 : Number(e.currentTarget.value); updateNodeData(data.id, { limit: l @@ -48,7 +48,7 @@ const WebSearchNodeComponent = ({ onCheckedChange={(semanticTextSearchEnabled) => { updateNodeData(data.id, { semanticTextSearchEnabled, - } as WebSearchNode) + } as WebSearchNode); }} /> @@ -60,7 +60,9 @@ const WebSearchNodeComponent = ({ defaultValue={data.semanticTextSearchLimit ?? 10} onChange={(e) => { updateNodeData(data.id, { - semanticTextSearchLimit: Number.isNaN(Number(e.currentTarget.value)) ? 10 : Number(e.currentTarget.value) + semanticTextSearchLimit: Number.isNaN(Number(e.currentTarget.value)) + ? 10 + : Number(e.currentTarget.value) } as WebSearchNode); }} /> diff --git a/frontend/components/pipeline/nodes/zenguard-node.tsx b/frontend/components/pipeline/nodes/zenguard-node.tsx index a1b1de84..d40d4cae 100644 --- a/frontend/components/pipeline/nodes/zenguard-node.tsx +++ b/frontend/components/pipeline/nodes/zenguard-node.tsx @@ -1,13 +1,13 @@ -import { memo } from 'react' -import GenericNodeComponent from './generic-node' -import { DetectorType, ZenguardNode } from '@/lib/flow/types' -import { Checkbox } from '@/components/ui/checkbox' -import { Label } from '@/components/ui/label' +import { memo } from 'react'; +import GenericNodeComponent from './generic-node'; +import { DetectorType, ZenguardNode } from '@/lib/flow/types'; +import { Checkbox } from '@/components/ui/checkbox'; +import { Label } from '@/components/ui/label'; import useStore from '@/lib/flow/store'; -import { Button } from '@/components/ui/button' -import { IconZenguard } from '@/components/ui/icons' +import { Button } from '@/components/ui/button'; +import { IconZenguard } from '@/components/ui/icons'; -const DETECTOR_TYPE_TO_DISPLAY_NAME_MAP: Record = { "prompt_injection": "Prompt Injection", "pii": "PII (Personally Identifiable Info)", "topics/allowed": "Allowed Topics", "topics/banned": "Banned Topics", "keywords": "Keywords", "secrets": "Secrets" }; +const DETECTOR_TYPE_TO_DISPLAY_NAME_MAP: Record = { 'prompt_injection': 'Prompt Injection', 'pii': 'PII (Personally Identifiable Info)', 'topics/allowed': 'Allowed Topics', 'topics/banned': 'Banned Topics', 'keywords': 'Keywords', 'secrets': 'Secrets' }; const ZenguardNodeComponent = ({ id, @@ -31,7 +31,7 @@ const ZenguardNodeComponent = ({ onCheckedChange={(checked) => { updateNodeData(id, { detectors: data.detectors.map((d) => d.type === detector.type ? { ...d, enabled: checked } : d) - } as ZenguardNode) + } as ZenguardNode); }} /> diff --git a/frontend/components/pipeline/overwrite-workshop-button.tsx b/frontend/components/pipeline/overwrite-workshop-button.tsx index bc59aba3..f980ff7b 100644 --- a/frontend/components/pipeline/overwrite-workshop-button.tsx +++ b/frontend/components/pipeline/overwrite-workshop-button.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; -import { Button } from '@/components/ui/button' -import { useToast } from '../../lib/hooks/use-toast' +import { Button } from '@/components/ui/button'; +import { useToast } from '../../lib/hooks/use-toast'; import { Dialog, DialogContent, @@ -9,7 +9,7 @@ import { DialogHeader, DialogTitle, DialogTrigger -} from '@/components/ui/dialog' +} from '@/components/ui/dialog'; import { Label } from '../ui/label'; import { Loader, Pencil, ShieldQuestion } from 'lucide-react'; import { PipelineVersionInfo } from '@/lib/pipeline/types'; @@ -27,12 +27,16 @@ interface OverwriteWorkshopButtonProps { /** * Button which overrides the current workshop version (unsaved changes) with one of the commit's contents. */ -export default function OverwriteWorkshopButton({ workshopVersionId, selectedPipelineVersion, onPipelineVersionsChange }: OverwriteWorkshopButtonProps) { +export default function OverwriteWorkshopButton({ + workshopVersionId, + selectedPipelineVersion, + onPipelineVersionsChange +}: OverwriteWorkshopButtonProps) { const router = useRouter(); const pathName = usePathname(); - const { projectId } = useProjectContext() + const { projectId } = useProjectContext(); const { toast } = useToast(); - const searchParams = useSearchParams() + const searchParams = useSearchParams(); const [isLoading, setIsLoading] = useState(false); const [isDialogOpen, setIsDialogOpen] = useState(false); @@ -49,28 +53,28 @@ export default function OverwriteWorkshopButton({ workshopVersionId, selectedPip refVersionId: selectedPipelineVersion.id, }), cache: 'no-cache', - }) + }); if (res.status != 200) { toast({ title: 'Error overwriting workshop version', variant: 'destructive' - }) + }); setIsLoading(false); - return + return; } toast({ title: 'Workshop version is overwritten' - }) + }); setIsLoading(false); setIsDialogOpen(false); // This method must redirect to workshop version onPipelineVersionsChange(); - } + }; return ( @@ -105,4 +109,4 @@ export default function OverwriteWorkshopButton({ workshopVersionId, selectedPip ); -} \ No newline at end of file +} diff --git a/frontend/components/pipeline/pipeline-bottom-panel.tsx b/frontend/components/pipeline/pipeline-bottom-panel.tsx index 576b9fea..3cf4fe11 100644 --- a/frontend/components/pipeline/pipeline-bottom-panel.tsx +++ b/frontend/components/pipeline/pipeline-bottom-panel.tsx @@ -1,11 +1,11 @@ -import { ImperativePanelHandle } from "react-resizable-panels" -import { useState } from "react" -import { Maximize2, Minimize2 } from "lucide-react" -import PipelineOutputs from "./pipeline-outputs" -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" -import PipelineHistory from "./pipeline-history" -import { PipelineVersion } from "@/lib/pipeline/types" -import { Skeleton } from "../ui/skeleton" +import { ImperativePanelHandle } from 'react-resizable-panels'; +import { useState } from 'react'; +import { Maximize2, Minimize2 } from 'lucide-react'; +import PipelineOutputs from './pipeline-outputs'; +import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; +import PipelineHistory from './pipeline-history'; +import { PipelineVersion } from '@/lib/pipeline/types'; +import { Skeleton } from '../ui/skeleton'; interface PipelineBottomPanelProps { pipelineVersion: PipelineVersion @@ -15,14 +15,14 @@ interface PipelineBottomPanelProps { export default function PipelineBottomPanel({ pipelineVersion, onTraceHover }: PipelineBottomPanelProps) { - const [selectedTab, setSelectedTab] = useState<"runs" | "history">("runs") + const [selectedTab, setSelectedTab] = useState<'runs' | 'history'>('runs'); return ( setSelectedTab(value as "runs" | "history")} + onValueChange={(value) => setSelectedTab(value as 'runs' | 'history')} >
{/*
- ) + ); -} \ No newline at end of file +} diff --git a/frontend/components/pipeline/pipeline-sheet.tsx b/frontend/components/pipeline/pipeline-sheet.tsx index f24fc500..4fdc09e8 100644 --- a/frontend/components/pipeline/pipeline-sheet.tsx +++ b/frontend/components/pipeline/pipeline-sheet.tsx @@ -9,19 +9,19 @@ import { WebSearchNode, JsonExtractorNode, FunctionNode, -} from "@/lib/flow/types"; -import useStore from "@/lib/flow/store"; -import LLM from "./nodes/llm"; -import SemanticSearchNodeComponent from "./nodes/semantic-search-node"; -import { ScrollArea } from "../ui/scroll-area"; -import SwitchNodeComponent from "./nodes/switch-node"; -import StringTemplateNodeComponent from "./nodes/string-template-node"; -import SemanticSwitchNodeComponent from "./nodes/semantic-switch-node"; -import JsonExtractorNodeComponent from "./nodes/json-extractor-node"; -import WebSearchNodeComponent from "./nodes/web-search-node"; -import FunctionNodeComponent from "./nodes/function-node"; -import { Input } from "../ui/input"; -import { Label } from "../ui/label"; +} from '@/lib/flow/types'; +import useStore from '@/lib/flow/store'; +import LLM from './nodes/llm'; +import SemanticSearchNodeComponent from './nodes/semantic-search-node'; +import { ScrollArea } from '../ui/scroll-area'; +import SwitchNodeComponent from './nodes/switch-node'; +import StringTemplateNodeComponent from './nodes/string-template-node'; +import SemanticSwitchNodeComponent from './nodes/semantic-switch-node'; +import JsonExtractorNodeComponent from './nodes/json-extractor-node'; +import WebSearchNodeComponent from './nodes/web-search-node'; +import FunctionNodeComponent from './nodes/function-node'; +import { Input } from '../ui/input'; +import { Label } from '../ui/label'; interface PipelineSheetProps { editable: boolean @@ -29,47 +29,47 @@ interface PipelineSheetProps { function RenderNode({ data, editable }: { data: GenericNode, editable: boolean }) { switch (data.type) { - case NodeType.LLM: - return ( - - ) - case NodeType.SEMANTIC_SEARCH: - return ( - - ) - case NodeType.SWITCH: - return ( - - ) - case NodeType.STRING_TEMPLATE: - return ( - - ) - case NodeType.SEMANTIC_SWITCH: - return ( - - ) - case NodeType.JSON_EXTRACTOR: - return ( - - ) - case NodeType.WEB_SEARCH: - return ( - - ) - case NodeType.FUNCTION: - return ( - - ) - default: - return null + case NodeType.LLM: + return ( + + ); + case NodeType.SEMANTIC_SEARCH: + return ( + + ); + case NodeType.SWITCH: + return ( + + ); + case NodeType.STRING_TEMPLATE: + return ( + + ); + case NodeType.SEMANTIC_SWITCH: + return ( + + ); + case NodeType.JSON_EXTRACTOR: + return ( + + ); + case NodeType.WEB_SEARCH: + return ( + + ); + case NodeType.FUNCTION: + return ( + + ); + default: + return null; } } export default function PipelineSheet({ editable }: PipelineSheetProps) { - const { focusedNodeId, getNode, updateNodeData } = useStore(store => store) + const { focusedNodeId, getNode, updateNodeData } = useStore(store => store); - const data = getNode(focusedNodeId ?? "")?.data + const data = getNode(focusedNodeId ?? '')?.data; return (
@@ -86,7 +86,7 @@ export default function PipelineSheet({ editable }: PipelineSheetProps) { updateNodeData(data.id, { ...data, name: e.currentTarget.value - }) + }); }} className="w-full" /> @@ -100,6 +100,6 @@ export default function PipelineSheet({ editable }: PipelineSheetProps) { }
- ) + ); -} \ No newline at end of file +} diff --git a/frontend/components/pipeline/pipeline-trace.tsx b/frontend/components/pipeline/pipeline-trace.tsx index 1a1cd20f..8d00da4d 100644 --- a/frontend/components/pipeline/pipeline-trace.tsx +++ b/frontend/components/pipeline/pipeline-trace.tsx @@ -5,7 +5,7 @@ import PipelineInput from './pipeline-input'; import { ScrollArea } from '../ui/scroll-area'; import { AiOutlineMinusCircle } from 'react-icons/ai'; import { DEFAULT_INPUT_VALUE_FOR_HANDLE_TYPE } from '@/lib/flow/utils'; -import { v4 as uuidv4 } from 'uuid' +import { v4 as uuidv4 } from 'uuid'; import { PipelineExecutionMode } from '@/lib/pipeline/types'; interface PipelineTraceProps { @@ -17,7 +17,7 @@ export default function PipelineTrace({ }: PipelineTraceProps) { const deleteInput = (index: number) => { setAllInputs(allInputs.filter((_, i) => i !== index)); - } + }; return (
@@ -48,7 +48,8 @@ export default function PipelineTrace({ }: PipelineTraceProps) { let inputNodes if (mode === PipelineExecutionMode.Node && focusedNodeId) { - inputNodes = Array.from(getRunGraph().nodes.values()).filter(node => node.type === NodeType.INPUT) as InputNode[]; + inputNodes = Array.from(getRunGraph().nodes.values()) + .filter(node => node.type === NodeType.INPUT) as InputNode[]; } else { // Private pipelines will only come here if they are not in Unit test mode // Public pipelines don't have Unit test mode and will always come here diff --git a/frontend/components/pipeline/pipeline.tsx b/frontend/components/pipeline/pipeline.tsx index 4b97cd5a..69a49cbf 100644 --- a/frontend/components/pipeline/pipeline.tsx +++ b/frontend/components/pipeline/pipeline.tsx @@ -1,63 +1,63 @@ -'use client' - -import { useContext, useEffect, useState, useRef, useMemo } from 'react' -import Flow from './flow' -import PipelineTrace from './pipeline-trace' -import PipelineHeader from './pipeline-header' -import { ProjectContext } from '@/contexts/project-context' -import useStore from '@/lib/flow/store' -import { Label } from '../ui/label' -import { InputVariable, Pipeline as PipelineType, PipelineExecutionMode, PipelineVersion } from '@/lib/pipeline/types' -import { FlowContextProvider } from '@/contexts/pipeline-version-context' -import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable" -import { ImperativePanelHandle } from 'react-resizable-panels' -import { useToast } from '@/lib/hooks/use-toast' -import Toolbar from './pipeline-toolbar' -import { STORED_INPUTS_STATE_UNSEEN, cn, convertAllStoredInputsToUnseen, convertStoredInputToUnseen, getStoredInputs, setStoredInputs } from '@/lib/utils' -import { Graph } from '@/lib/flow/graph' -import { createClient } from '@supabase/supabase-js' -import { useUserContext } from '@/contexts/user-context' -import { Skeleton } from '../ui/skeleton' -import PipelineBottomPanel from './pipeline-bottom-panel' -import { SUPABASE_ANON_KEY, SUPABASE_URL, USE_REALTIME } from '@/lib/const' -import { PresenceUser } from '@/lib/user/types' -import { v4 as uuidv4 } from 'uuid' -import PipelineSheet from './pipeline-sheet' -import { InputNode, NodeType } from '@/lib/flow/types' -import { DEFAULT_INPUT_VALUE_FOR_HANDLE_TYPE } from '@/lib/flow/utils' -import { Button } from '../ui/button' -import { ChevronsRight, PlayIcon, StopCircle } from 'lucide-react' -import { removeHashFromId } from '@/lib/pipeline/utils' -import { ScrollArea } from '../ui/scroll-area' -import { usePrevious } from '@/lib/hooks/use-previous' -import Header from '../ui/header' -import { Switch } from '../ui/switch' -import * as Y from 'yjs' -import eventEmitter from '@/lib/pipeline/eventEmitter' +'use client'; + +import { useContext, useEffect, useState, useRef, useMemo } from 'react'; +import Flow from './flow'; +import PipelineTrace from './pipeline-trace'; +import PipelineHeader from './pipeline-header'; +import { ProjectContext } from '@/contexts/project-context'; +import useStore from '@/lib/flow/store'; +import { Label } from '../ui/label'; +import { InputVariable, Pipeline as PipelineType, PipelineExecutionMode, PipelineVersion } from '@/lib/pipeline/types'; +import { FlowContextProvider } from '@/contexts/pipeline-version-context'; +import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable'; +import { ImperativePanelHandle } from 'react-resizable-panels'; +import { useToast } from '@/lib/hooks/use-toast'; +import Toolbar from './pipeline-toolbar'; +import { STORED_INPUTS_STATE_UNSEEN, cn, convertAllStoredInputsToUnseen, convertStoredInputToUnseen, getStoredInputs, setStoredInputs } from '@/lib/utils'; +import { Graph } from '@/lib/flow/graph'; +import { createClient } from '@supabase/supabase-js'; +import { useUserContext } from '@/contexts/user-context'; +import { Skeleton } from '../ui/skeleton'; +import PipelineBottomPanel from './pipeline-bottom-panel'; +import { SUPABASE_ANON_KEY, SUPABASE_URL, USE_REALTIME } from '@/lib/const'; +import { PresenceUser } from '@/lib/user/types'; +import { v4 as uuidv4 } from 'uuid'; +import PipelineSheet from './pipeline-sheet'; +import { InputNode, NodeType } from '@/lib/flow/types'; +import { DEFAULT_INPUT_VALUE_FOR_HANDLE_TYPE } from '@/lib/flow/utils'; +import { Button } from '../ui/button'; +import { ChevronsRight, PlayIcon, StopCircle } from 'lucide-react'; +import { removeHashFromId } from '@/lib/pipeline/utils'; +import { ScrollArea } from '../ui/scroll-area'; +import { usePrevious } from '@/lib/hooks/use-previous'; +import Header from '../ui/header'; +import { Switch } from '../ui/switch'; +import * as Y from 'yjs'; +import eventEmitter from '@/lib/pipeline/eventEmitter'; interface PipelineProps { pipeline: PipelineType; defaultSelectedVersion?: PipelineVersion; } -export const dynamic = 'force-dynamic' +export const dynamic = 'force-dynamic'; const AUTO_SAVE_TIMEOUT_MS = 750; enum RunGraphState { - Run = "run", - Idle = "idle" + Run = 'run', + Idle = 'idle' } export default function Pipeline({ pipeline }: PipelineProps) { - const [bottomPanelMinSize, setBottomPanelMinSize] = useState(0) - const { projectId } = useContext(ProjectContext) - const [isSheetOpen, setIsSheetOpen] = useState(false) - const [runGraphState, setRunGraphState] = useState(RunGraphState.Idle) + const [bottomPanelMinSize, setBottomPanelMinSize] = useState(0); + const { projectId } = useContext(ProjectContext); + const [isSheetOpen, setIsSheetOpen] = useState(false); + const [runGraphState, setRunGraphState] = useState(RunGraphState.Idle); // default to latest WORKSHOP pipeline version - const [selectedPipelineVersion, setSelectedPipelineVersion] = useState(null) + const [selectedPipelineVersion, setSelectedPipelineVersion] = useState(null); const { ydoc, syncNodesWithYDoc, @@ -77,13 +77,13 @@ export default function Pipeline({ pipeline }: PipelineProps) { setAllInputs, breakpointNodeIds, setBreakpointNodeIds, - } = useStore(state => state) + } = useStore(state => state); const autoSaveFuncTimeoutId = useRef(null); const externalUpdateTimeoutId = useRef(null); const [unsavedChanges, setUnsavedChanges] = useState(false); const [isUpdatingByAnotherClient, setIsUpdatingByAnotherClient] = useState(false); - const [presenceUsers, setPresenceUsers] = useState([]) + const [presenceUsers, setPresenceUsers] = useState([]); const [leftPanelOpen, setLeftPanelOpen] = useState(true); const [rightPanelOpen, setRightPanelOpen] = useState(true); const flowPanelRef = useRef(null); @@ -93,10 +93,9 @@ export default function Pipeline({ pipeline }: PipelineProps) { const seenClientIds = useRef([]); const { toast } = useToast(); - const { supabaseAccessToken, username, imageUrl } = useUserContext() + const { supabaseAccessToken, username, imageUrl } = useUserContext(); - const supabase = useMemo(() => { - return USE_REALTIME + const supabase = useMemo(() => USE_REALTIME ? createClient( SUPABASE_URL, SUPABASE_ANON_KEY, @@ -108,31 +107,31 @@ export default function Pipeline({ pipeline }: PipelineProps) { }, } ) - : null}, []) + : null, []); - supabase?.realtime.setAuth(supabaseAccessToken) + supabase?.realtime.setAuth(supabaseAccessToken); useEffect(() => { - document.title = `${pipeline.name}` + document.title = `${pipeline.name}`; if (window?.innerHeight) { - setBottomPanelMinSize((46 / (window.innerHeight - 100)) * 100) + setBottomPanelMinSize((46 / (window.innerHeight - 100)) * 100); } eventEmitter.on('run', (action) => { if (action === 'cancel' || action === 'done') { - setRunGraphState(RunGraphState.Idle) + setRunGraphState(RunGraphState.Idle); } else if (action === 'run') { - setRunGraphState(RunGraphState.Run) + setRunGraphState(RunGraphState.Run); } - }) + }); // remove all channels on unmount return () => { - supabase?.removeAllChannels() - setFocusedNodeId(null) - } - }, []) + supabase?.removeAllChannels(); + setFocusedNodeId(null); + }; + }, []); const handleDocUpdate = (update: Uint8Array, origin: any) => { @@ -142,7 +141,7 @@ export default function Pipeline({ pipeline }: PipelineProps) { } if (origin === 'external') { - syncNodesWithYDoc() + syncNodesWithYDoc(); return; } @@ -154,45 +153,43 @@ export default function Pipeline({ pipeline }: PipelineProps) { pipelineVersionId: selectedPipelineVersion!.id, diff: Array.from(update) }, - }) + }); } - } + }; useEffect(() => { - setIsSheetOpen(focusedNodeId !== null) - }, [focusedNodeId]) + setIsSheetOpen(focusedNodeId !== null); + }, [focusedNodeId]); const updateSelectedPipelineVersion = (versionId: string) => { - setFocusedNodeId(null) + setFocusedNodeId(null); fetch(`/api/projects/${projectId}/pipelines/${pipeline.id}/versions/${versionId}`, { method: 'GET', cache: 'no-store' }).then(res => res.json()).then(pipelineVersion => { - removeHashFromId(pipelineVersion) - setSelectedPipelineVersion(pipelineVersion) - }) - } + removeHashFromId(pipelineVersion); + setSelectedPipelineVersion(pipelineVersion); + }); + }; const saveVersion = async ( rf: any, graph: Graph, projectId: string, selectedPipelineVersion: PipelineVersion, - ) => { - return await fetch( - `/api/projects/${projectId}/pipelines/${selectedPipelineVersion.pipelineId}/versions/${selectedPipelineVersion.id}`, - { - method: 'POST', - body: JSON.stringify({ - ...selectedPipelineVersion, - displayableGraph: rf, - runnableGraph: graph.toObject() - }), - cache: 'no-store', - } - ); - } + ) => await fetch( + `/api/projects/${projectId}/pipelines/${selectedPipelineVersion.pipelineId}/versions/${selectedPipelineVersion.id}`, + { + method: 'POST', + body: JSON.stringify({ + ...selectedPipelineVersion, + displayableGraph: rf, + runnableGraph: graph.toObject() + }), + cache: 'no-store', + } + ); const autoSave = async ( projectId: string, @@ -211,11 +208,11 @@ export default function Pipeline({ pipeline }: PipelineProps) { toast({ title: 'Error saving pipeline version', variant: 'destructive' - }) + }); } setUnsavedChanges(false); - } + }; useEffect(() => { @@ -225,20 +222,20 @@ export default function Pipeline({ pipeline }: PipelineProps) { isFirstRender.current = true; - if (selectedPipelineVersion === null) return + if (selectedPipelineVersion === null) return; if (selectedPipelineVersion.displayableGraph == undefined) { - return + return; } // First time, we read all inputs (for pipeline and all node graphs) from the storage convertAllStoredInputsToUnseen(selectedPipelineVersion!.id!); // updating nodes and edges from selected pipeline version - const flow = selectedPipelineVersion.displayableGraph + const flow = selectedPipelineVersion.displayableGraph; - setNodes((_) => flow.nodes) - setEdges((_) => flow.edges) + setNodes((_) => flow.nodes); + setEdges((_) => flow.edges); const currentPresenceUser: PresenceUser = { id: presenceId.current, @@ -252,13 +249,13 @@ export default function Pipeline({ pipeline }: PipelineProps) { } // setting up listener for changes on selected pipeline version - const newChannel = supabase?.channel('pipeline_versions_' + selectedPipelineVersion.id!) + const newChannel = supabase?.channel('pipeline_versions_' + selectedPipelineVersion.id!); channel.current = newChannel ?.on('presence', { event: 'sync' }, () => { const newState = channel.current.presenceState(); - const presenceUsers = Object.values(newState).map((u: any) => ({ id: u[0].id, username: u[0].username, imageUrl: u[0].imageUrl })).filter((user) => { - return user.id != currentPresenceUser.id; - }).sort((user1, user2) => { return user1.id.localeCompare(user2.id) }); + const presenceUsers = Object.values(newState) + .map((u: any) => ({ id: u[0].id, username: u[0].username, imageUrl: u[0].imageUrl })) + .filter((user) => user.id != currentPresenceUser.id).sort((user1, user2) => user1.id.localeCompare(user2.id)); setPresenceUsers(presenceUsers); }) .on('broadcast', { event: 'graph' }, handleExternalGraphUpdate) @@ -273,23 +270,23 @@ export default function Pipeline({ pipeline }: PipelineProps) { pipelineVersionId: selectedPipelineVersion.id, diff: Array.from(Y.encodeStateAsUpdate(ydoc)) }, - }) - await newChannel.track(currentPresenceUser) + }); + await newChannel.track(currentPresenceUser); } - }) + }); - ydoc.on('update', handleDocUpdate) + ydoc.on('update', handleDocUpdate); return () => { - newChannel?.unsubscribe() - ydoc.off('update', handleDocUpdate) - } + newChannel?.unsubscribe(); + ydoc.off('update', handleDocUpdate); + }; - }, [selectedPipelineVersion]) + }, [selectedPipelineVersion]); const handleInitialSync = (e: any) => { const payload = e.payload as { senderId: string, pipelineVersionId: string, diff: Int8Array }; @@ -300,13 +297,13 @@ export default function Pipeline({ pipeline }: PipelineProps) { } if (payload.diff) { - const diff = new Uint8Array(payload.diff) + const diff = new Uint8Array(payload.diff); - Y.applyUpdate(ydoc, diff, "external") + Y.applyUpdate(ydoc, diff, 'external'); // if we haven't seen this client id yet, we send our state if (seenClientIds.current.indexOf(payload.senderId) === -1) { - seenClientIds.current.push(payload.senderId) + seenClientIds.current.push(payload.senderId); channel.current.send({ type: 'broadcast', @@ -316,11 +313,11 @@ export default function Pipeline({ pipeline }: PipelineProps) { senderId: presenceId.current, diff: Array.from(Y.encodeStateAsUpdate(ydoc)) }, - }) + }); } } - } + }; useEffect(() => { @@ -338,7 +335,7 @@ export default function Pipeline({ pipeline }: PipelineProps) { } if (selectedPipelineVersion === null) { - return + return; } // don't autosave endpoint pipelines @@ -356,7 +353,7 @@ export default function Pipeline({ pipeline }: PipelineProps) { ); setUnsavedChanges(true); - }, [nodes, edges]) + }, [nodes, edges]); const handleExternalGraphUpdate = (e: any) => { @@ -368,8 +365,8 @@ export default function Pipeline({ pipeline }: PipelineProps) { }; if (payload.diff && payload.pipelineVersionId === selectedPipelineVersion?.id) { - const diff = new Uint8Array(payload.diff) - Y.applyUpdate(ydoc, diff, "external") + const diff = new Uint8Array(payload.diff); + Y.applyUpdate(ydoc, diff, 'external'); } // add some latency to avoid flickering during simultaneous updates @@ -381,7 +378,7 @@ export default function Pipeline({ pipeline }: PipelineProps) { setIsUpdatingByAnotherClient(false); }, 500); - } + }; const prevFocusedNodeId = usePrevious(focusedNodeId); const prevMode = usePrevious(mode); @@ -389,10 +386,11 @@ export default function Pipeline({ pipeline }: PipelineProps) { useEffect(() => { if (!selectedPipelineVersion) return; - // The node may be focused, but if we're not in Node execution mode, we're still working with whole pipeline's inputs. + // The node may be focused, but if we're not in Node execution mode, + // we're still working with whole pipeline's inputs. let storeFocusedNodeId = (mode === PipelineExecutionMode.Node) ? focusedNodeId : null; setStoredInputs(selectedPipelineVersion.id!, storeFocusedNodeId, allInputs); - }, [allInputs]) + }, [allInputs]); // Update allInputs when nodes change useEffect(() => { @@ -432,15 +430,13 @@ export default function Pipeline({ pipeline }: PipelineProps) { let currentInputs: InputVariable[][]; if (localPipelineInputs.state === STORED_INPUTS_STATE_UNSEEN) { if (localPipelineInputs.inputs.length === 0) { - const newPipelineInputs = inputNodes.map(inputNode => { - return { - id: inputNode.id, - name: inputNode.name, - value: DEFAULT_INPUT_VALUE_FOR_HANDLE_TYPE[inputNode.inputType], - type: inputNode.inputType, - executionId: uuidv4() // Added new execution - }; - }); + const newPipelineInputs = inputNodes.map(inputNode => ({ + id: inputNode.id, + name: inputNode.name, + value: DEFAULT_INPUT_VALUE_FOR_HANDLE_TYPE[inputNode.inputType], + type: inputNode.inputType, + executionId: uuidv4() // Added new execution + })); currentInputs = [newPipelineInputs]; } else { currentInputs = localPipelineInputs.inputs; @@ -476,7 +472,7 @@ export default function Pipeline({ pipeline }: PipelineProps) { value: DEFAULT_INPUT_VALUE_FOR_HANDLE_TYPE[inputNode.inputType], type: inputNode.inputType, executionId, - } + }; } else { return { id: inputNode.id, @@ -484,7 +480,7 @@ export default function Pipeline({ pipeline }: PipelineProps) { value: input.value, type: inputNode.inputType, executionId, - } + }; } } else { return { @@ -495,7 +491,7 @@ export default function Pipeline({ pipeline }: PipelineProps) { executionId, }; } - }) + }); }); // allInputs is stored in store as a convenience, so that we don't always pass pipeline version id and focusedNodeId @@ -506,22 +502,22 @@ export default function Pipeline({ pipeline }: PipelineProps) { return (
-
+
{ - supabase?.removeAllChannels() - updateSelectedPipelineVersion(version.id) + supabase?.removeAllChannels(); + updateSelectedPipelineVersion(version.id); }} onPipelineVersionSave={() => { autoSave(projectId, selectedPipelineVersion!).then(() => { toast({ title: 'Pipeline version saved', duration: 1000 - }) - }) + }); + }); }} onLeftPanelOpenChange={(open) => setLeftPanelOpen(open) @@ -556,10 +552,10 @@ export default function Pipeline({ pipeline }: PipelineProps) { (
- + @@ -671,11 +667,14 @@ export default function Pipeline({ pipeline }: PipelineProps) { - + - ) + ); } diff --git a/frontend/components/pipeline/stream-trace.tsx b/frontend/components/pipeline/stream-trace.tsx index c02f6846..a61b3d80 100644 --- a/frontend/components/pipeline/stream-trace.tsx +++ b/frontend/components/pipeline/stream-trace.tsx @@ -1,22 +1,22 @@ -import React, { useEffect, useState } from 'react' -import { SpanCard } from '../traces/span-card' -import { getDuration, getDurationString, renderNodeInput } from '@/lib/flow/utils' -import { ScrollArea } from '../ui/scroll-area' -import { Label } from '../ui/label' -import { RunTrace } from '@/lib/traces/types' -import StatusLabel from '../ui/status-label' -import { CircleDollarSign, Clock3, Coins, FastForward, Loader, Play } from 'lucide-react' -import { StreamMessage } from './pipeline-outputs' -import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs' -import { Skeleton } from '../ui/skeleton' -import Formatter from '../ui/formatter' -import { Button } from '../ui/button' -import { v4 } from 'uuid' -import { ConditionValue, NodeType } from '@/lib/flow/types' -import useStore from '@/lib/flow/store' -import eventEmitter from '@/lib/pipeline/eventEmitter' -import { GraphMessagePreview } from '@/lib/pipeline/types' -import { cn } from '@/lib/utils' +import React, { useEffect, useState } from 'react'; +import { SpanCard } from '../traces/span-card'; +import { getDuration, getDurationString, renderNodeInput } from '@/lib/flow/utils'; +import { ScrollArea } from '../ui/scroll-area'; +import { Label } from '../ui/label'; +import { RunTrace } from '@/lib/traces/types'; +import StatusLabel from '../ui/status-label'; +import { CircleDollarSign, Clock3, Coins, FastForward, Loader, Play } from 'lucide-react'; +import { StreamMessage } from './pipeline-outputs'; +import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'; +import { Skeleton } from '../ui/skeleton'; +import Formatter from '../ui/formatter'; +import { Button } from '../ui/button'; +import { v4 } from 'uuid'; +import { ConditionValue, NodeType } from '@/lib/flow/types'; +import useStore from '@/lib/flow/store'; +import eventEmitter from '@/lib/pipeline/eventEmitter'; +import { GraphMessagePreview } from '@/lib/pipeline/types'; +import { cn } from '@/lib/utils'; interface StreaTraceProps { streamMessages: StreamMessage[] @@ -26,27 +26,27 @@ interface StreaTraceProps { export default function StreamTrace({ streamMessages, runTrace, onNodeRun }: StreaTraceProps) { - const { highlightNode } = useStore() - const [selectedMessage, setSelectedMessage] = useState(null) + const { highlightNode } = useStore(); + const [selectedMessage, setSelectedMessage] = useState(null); useEffect(() => { if (selectedMessage) { - setSelectedMessage(streamMessages.find(m => m.id === selectedMessage.id) || null) + setSelectedMessage(streamMessages.find(m => m.id === selectedMessage.id) || null); } else if (streamMessages.some(node => node.reachedBreakpoint)) { - setSelectedMessage(streamMessages.find(node => node.reachedBreakpoint) || null) + setSelectedMessage(streamMessages.find(node => node.reachedBreakpoint) || null); } - }, [streamMessages]) + }, [streamMessages]); const status = () => { // if any stream message has reached breakpoint if (streamMessages.some(node => node.reachedBreakpoint)) { - return 'Breakpoint' + return 'Breakpoint'; } - return streamMessages.length > 0 ? 'Running' : "Idle" - } + return streamMessages.length > 0 ? 'Running' : 'Idle'; + }; return (
@@ -65,7 +65,7 @@ export default function StreamTrace({ streamMessages, runTrace, onNodeRun }: Str
- +
)} @@ -141,10 +141,10 @@ export default function StreamTrace({ streamMessages, runTrace, onNodeRun }: Str onClick={() => { if (!selectedMessage) { - return + return; } - let messages = streamMessages.map(node => node.message!) + let messages = streamMessages.map(node => node.message!); // updating message ids for (const message of messages) { @@ -153,27 +153,27 @@ export default function StreamTrace({ streamMessages, runTrace, onNodeRun }: Str continue; } - const oldId = message.id - const newId = v4() + const oldId = message.id; + const newId = v4(); if (typeof message?.value === 'object' && (message?.value as ConditionValue).value) { - message.value = (message?.value as ConditionValue).value + message.value = (message?.value as ConditionValue).value; } if (message?.inputMessageIds.includes(oldId)) { - message.inputMessageIds = message.inputMessageIds.map(id => id === oldId ? newId : id) + message.inputMessageIds = message.inputMessageIds.map(id => id === oldId ? newId : id); } - message.id = newId + message.id = newId; const now = new Date(); - const nowISO = now.toISOString() + const nowISO = now.toISOString(); message.startTime = nowISO; message.endTime = nowISO; } - onNodeRun?.(selectedMessage) + onNodeRun?.(selectedMessage); }} > @@ -186,8 +186,8 @@ export default function StreamTrace({ streamMessages, runTrace, onNodeRun }: Str variant='secondary' className='h-6' onClick={() => { - eventEmitter.emit('graph', 'continue') - selectedMessage.reachedBreakpoint = false + eventEmitter.emit('graph', 'continue'); + selectedMessage.reachedBreakpoint = false; }} > @@ -240,16 +240,16 @@ export default function StreamTrace({ streamMessages, runTrace, onNodeRun }: Str } {selectedMessage?.message?.inputMessageIds && ( selectedMessage.message.inputMessageIds.map((id, index) => { - const node = streamMessages.find(node => node.message?.id === id) + const node = streamMessages.find(node => node.message?.id === id); return (
{node?.nodeName}
- +
- ) + ); }) )} @@ -261,7 +261,7 @@ export default function StreamTrace({ streamMessages, runTrace, onNodeRun }: Str
- ) + ); } @@ -290,7 +290,7 @@ function StreamTraceCard({ node, selected, showSpinner = true }: StreamTraceCard } - ) + ); } @@ -305,8 +305,8 @@ export function TraceCard({ message, selected, onTraceHover, breakpoint = false return (
{ onTraceHover?.(message.nodeId) }} - onMouseLeave={() => { onTraceHover?.(undefined) }} + onMouseEnter={() => { onTraceHover?.(message.nodeId); }} + onMouseLeave={() => { onTraceHover?.(undefined); }} > {selected && (
@@ -320,5 +320,5 @@ export function TraceCard({ message, selected, onTraceHover, breakpoint = false
- ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/pipeline/target-version.tsx b/frontend/components/pipeline/target-version.tsx index 72455a78..b56c85d8 100644 --- a/frontend/components/pipeline/target-version.tsx +++ b/frontend/components/pipeline/target-version.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; -import { Button } from '@/components/ui/button' -import { useToast } from '../../lib/hooks/use-toast' +import { Button } from '@/components/ui/button'; +import { useToast } from '../../lib/hooks/use-toast'; import { Dialog, DialogContent, @@ -9,7 +9,7 @@ import { DialogHeader, DialogTitle, DialogTrigger -} from '@/components/ui/dialog' +} from '@/components/ui/dialog'; import { Label } from '../ui/label'; import { Loader, Pencil, ShieldQuestion } from 'lucide-react'; import { PipelineVersionInfo } from '@/lib/pipeline/types'; @@ -26,12 +26,16 @@ interface SetTargetVersionButtonProps { /** * Button which overrides the current workshop version (unsaved changes) with one of the commit's contents. */ -export default function SetTargetVersionButton({ pipelineId, pipelineVersionId, onTargetVersionChanged: onPipelineVersionsChange }: SetTargetVersionButtonProps) { +export default function SetTargetVersionButton({ + pipelineId, + pipelineVersionId, + onTargetVersionChanged: onPipelineVersionsChange +}: SetTargetVersionButtonProps) { const router = useRouter(); const pathName = usePathname(); - const { projectId } = useProjectContext() + const { projectId } = useProjectContext(); const { toast } = useToast(); - const searchParams = useSearchParams() + const searchParams = useSearchParams(); const [isLoading, setIsLoading] = useState(false); const [isDialogOpen, setIsDialogOpen] = useState(false); @@ -48,28 +52,28 @@ export default function SetTargetVersionButton({ pipelineId, pipelineVersionId, pipelineVersionId: pipelineVersionId, }), cache: 'no-cache', - }) + }); if (res.status != 200) { toast({ title: 'Error setting target pipeline version', variant: 'destructive' - }) + }); setIsLoading(false); - return + return; } toast({ title: 'Target pipeline version is set', - }) + }); setIsLoading(false); setIsDialogOpen(false); // This method must redirect to workshop version onPipelineVersionsChange?.(pipelineVersionId); - } + }; return ( @@ -104,4 +108,4 @@ export default function SetTargetVersionButton({ pipelineId, pipelineVersionId, ); -} \ No newline at end of file +} diff --git a/frontend/components/pipeline/trace-card.tsx b/frontend/components/pipeline/trace-card.tsx deleted file mode 100644 index e69de29b..00000000 diff --git a/frontend/components/pipeline/use-api.tsx b/frontend/components/pipeline/use-api.tsx index 21181104..ba97db58 100644 --- a/frontend/components/pipeline/use-api.tsx +++ b/frontend/components/pipeline/use-api.tsx @@ -4,9 +4,9 @@ import { DialogHeader, DialogTitle, DialogTrigger -} from '@/components/ui/dialog' -import { Button } from '../ui/button' -import { Code2, Copy } from 'lucide-react' +} from '@/components/ui/dialog'; +import { Button } from '../ui/button'; +import { Code2, Copy } from 'lucide-react'; import { InputNode, NodeType, RunnableGraph } from '@/lib/flow/types'; import { getDefaultGraphInputs } from '@/lib/flow/utils'; import Code from '../ui/code'; @@ -28,26 +28,20 @@ export default function UseApi({ pipelineName, targetRunnableGraph }: UseApiProp const [copied, setCopied] = useState(false); const envVars = getRequiredEnvVars(nodes); - const env = Array.from(envVars).reduce((acc, model) => { - return { - ...acc, - [model]: `$${model}` - } - }, {}); - - const pythonEnv = Array.from(envVars).reduce((acc, model) => { - return { - ...acc, - [model]: `os.environ[${model}]` - } - }, {}); - - const tsEnv = Array.from(envVars).reduce((acc, model) => { - return { - ...acc, - [model]: `process.env.${model}` - } - }, {}); + const env = Array.from(envVars).reduce((acc, model) => ({ + ...acc, + [model]: `$${model}` + }), {}); + + const pythonEnv = Array.from(envVars).reduce((acc, model) => ({ + ...acc, + [model]: `os.environ[${model}]` + }), {}); + + const tsEnv = Array.from(envVars).reduce((acc, model) => ({ + ...acc, + [model]: `process.env.${model}` + }), {}); let body = { pipeline: pipelineName, @@ -55,16 +49,16 @@ export default function UseApi({ pipelineName, targetRunnableGraph }: UseApiProp env, metadata: {}, stream: false - } + }; const indentAll = (str: string, indentBy: number) => str.split('\n').map((line, index) => { if (index === 0) return line; - return ' '.repeat(indentBy) + `${line}` - }).join('\n') + return ' '.repeat(indentBy) + `${line}`; + }).join('\n'); const curlString = `curl 'https://api.lmnr.ai/v1/pipeline/run' \\ -H "Content-Type: application/json" \\ -H "Authorization: Bearer $LAMINAR_API_KEY" \\ --d '${JSON.stringify(body, null, 2)}'` +-d '${JSON.stringify(body, null, 2)}'`; const pythonString = `from lmnr import Laminar as L @@ -78,7 +72,7 @@ result = L.run( metadata={}, ) print(result) -` +`; const tsString = `import { Laminar as L } from '@lmnr-ai/lmnr'; @@ -91,7 +85,7 @@ const result = await L.run({ metadata: {}, }); console.log(result); -` +`; return ( @@ -113,15 +107,15 @@ console.log(result); variant="ghost" onClick={() => { navigator.clipboard.writeText(selectedTab === 'python' ? pythonString : selectedTab === 'ts' ? tsString : curlString); - setCopied(true) + setCopied(true); }}> { - setCopied(false) - setSelectedTab(value) + setCopied(false); + setSelectedTab(value); }}> Python @@ -141,5 +135,5 @@ console.log(result); - ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/pipelines/create-pipeline-dialog.tsx b/frontend/components/pipelines/create-pipeline-dialog.tsx index cf764953..9fda8d4d 100644 --- a/frontend/components/pipelines/create-pipeline-dialog.tsx +++ b/frontend/components/pipelines/create-pipeline-dialog.tsx @@ -41,7 +41,7 @@ export function CreatePipelineDialog({ onUpdate }: CreatePipelineDialogProps) { // Allow to click "Create" with an empty pipeline name. Otherwise, if the button is simply disabled, // then it's hard to understand that name is required. if (!pipelineName) { - toast({ title: 'Set the pipeline name', description: 'Pipelines need a name to be created', variant: 'default' }) + toast({ title: 'Set the pipeline name', description: 'Pipelines need a name to be created', variant: 'default' }); return; }; @@ -58,8 +58,13 @@ export function CreatePipelineDialog({ onUpdate }: CreatePipelineDialogProps) { }); if (res.status !== 200) { - // Just a generic error message, since most likely the error has happened because the pipeline with the same name already exists. - toast({ title: 'Error creating pipeline', description: 'Pipeline name must be unique in the project', variant: 'destructive' }) + // Just a generic error message, since most likely the error has happened + // because the pipeline with the same name already exists. + toast({ + title: 'Error creating pipeline', + description: 'Pipeline name must be unique in the project', + variant: 'destructive' + }); setIsLoading(false); return; } @@ -71,7 +76,7 @@ export function CreatePipelineDialog({ onUpdate }: CreatePipelineDialogProps) { // Must come after router.push, otherwise multiple enter presses will create multiple pipelines setIsLoading(false); - } + }; useEffect(() => { const fetchTemplates = async () => { @@ -81,7 +86,7 @@ export function CreatePipelineDialog({ onUpdate }: CreatePipelineDialogProps) { if (json.length > 0) { setSelectedTemplateId(json[0].id); } - } + }; fetchTemplates(); }, []); @@ -126,12 +131,16 @@ export function CreatePipelineDialog({ onUpdate }: CreatePipelineDialogProps) { )} - - ) + ); } diff --git a/frontend/components/pipelines/pipelines.tsx b/frontend/components/pipelines/pipelines.tsx index 0ffac107..f68def98 100644 --- a/frontend/components/pipelines/pipelines.tsx +++ b/frontend/components/pipelines/pipelines.tsx @@ -6,7 +6,7 @@ import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu" +} from '@/components/ui/dropdown-menu'; import { useProjectContext } from '@/contexts/project-context'; import { MoreVertical } from 'lucide-react'; import { swrFetcher } from '@/lib/utils'; @@ -45,55 +45,52 @@ export default function Pipelines() { mutate(); if (newVisibility === 'PUBLIC') { - navigator.clipboard.writeText(`https://www.lmnr.ai/pub/${oldPipeline.id!}`) + navigator.clipboard.writeText(`https://www.lmnr.ai/pub/${oldPipeline.id!}`); toast({ title: 'Share URL copied to clipboard', - }) + }); } else if (newVisibility === 'PRIVATE') { toast({ title: 'Pipeline has been changed to private', - }) + }); } - } + }; const deletePipeline = async (pipelineId: string) => { const res = await fetch(`/api/projects/${projectId}/pipelines/${pipelineId}`, { method: 'DELETE' }); mutate(); - } + }; const columns: ColumnDef[] = [ { - accessorKey: "id", + accessorKey: 'id', cell: (row) => {String(row.getValue())}, - header: "ID", + header: 'ID', size: 320 }, { - accessorKey: "name", - header: "Name", + accessorKey: 'name', + header: 'Name', size: 240 }, { - header: "Created at", - accessorFn: (pipeline) => { - return pipeline.createdAt! - }, + header: 'Created at', + accessorFn: (pipeline) => pipeline.createdAt!, cell: (row) => , }, { - id: "actions", - cell: ({ row }) => { - return ( - - - - - - {/* {(row.original.visibility! === "PRIVATE") && ( { + id: 'actions', + cell: ({ row }) => ( + + + + + + {/* {(row.original.visibility! === "PRIVATE") && ( { updateVisibility(row.original, 'PUBLIC') e.stopPropagation() }}> @@ -107,25 +104,24 @@ export default function Pipelines() { Make private )} */} - {(row.original.visibility! === "PUBLIC") && ( { e.stopPropagation() }}> - + {(row.original.visibility! === 'PUBLIC') && ( { e.stopPropagation(); }}> + View public - - - )} - - { - deletePipeline(row.original.id!) - e.stopPropagation() - }}> + + + )} + + { + deletePipeline(row.original.id!); + e.stopPropagation(); + }}> Delete - - - - ) - }, + + + + ), } - ] + ]; const router = useRouter(); @@ -145,8 +141,8 @@ export default function Pipelines() { data={data} columns={[...columns]} onRowClick={(row) => { - router.push(`/project/${projectId}/pipelines/${row.original.id}`) - router.refresh() + router.push(`/project/${projectId}/pipelines/${row.original.id}`); + router.refresh(); }} emptyRow={ diff --git a/frontend/components/pipelines/template-select.tsx b/frontend/components/pipelines/template-select.tsx index a959dbbc..902072a0 100644 --- a/frontend/components/pipelines/template-select.tsx +++ b/frontend/components/pipelines/template-select.tsx @@ -1,7 +1,7 @@ -import { TemplateInfo } from "@/lib/pipeline/types"; -import { Card } from "../ui/card"; -import { Label } from "../ui/label"; -import { cn } from "@/lib/utils"; +import { TemplateInfo } from '@/lib/pipeline/types'; +import { Card } from '../ui/card'; +import { Label } from '../ui/label'; +import { cn } from '@/lib/utils'; interface TemplateSelectProps { className?: string @@ -20,12 +20,12 @@ export default function TemplateSelect({ const evalTemplates = templates.filter(t => t.displayGroup === 'eval'); const semanticEventEvalTemplates = templates.filter(t => t.displayGroup === 'semantic_event_eval'); return ( -
+
{buildTemplates.map((t) => ( setTemplateId(t.id)} > @@ -42,7 +42,7 @@ export default function TemplateSelect({
{semanticEventEvalTemplates.map((t) => ( setTemplateId(t.id)} > @@ -58,7 +58,7 @@ export default function TemplateSelect({
{evalTemplates.map((t) => ( setTemplateId(t.id)} > @@ -71,4 +71,4 @@ export default function TemplateSelect({
); -} \ No newline at end of file +} diff --git a/frontend/components/pipelines/update-pipeline-dialog.tsx b/frontend/components/pipelines/update-pipeline-dialog.tsx index 18cb8eaf..88b70707 100644 --- a/frontend/components/pipelines/update-pipeline-dialog.tsx +++ b/frontend/components/pipelines/update-pipeline-dialog.tsx @@ -46,7 +46,7 @@ export function UpdatePipelineDialog({ oldPipeline, onUpdate, isDropdown = true onUpdate?.(); setIsLoading(false); setIsDialogOpen(false); - } + }; return (
e.stopPropagation()}> @@ -84,5 +84,5 @@ export function UpdatePipelineDialog({ oldPipeline, onUpdate, isDropdown = true
- ) + ); } diff --git a/frontend/components/profile/profile-header.tsx b/frontend/components/profile/profile-header.tsx index 34ca8e96..77646523 100644 --- a/frontend/components/profile/profile-header.tsx +++ b/frontend/components/profile/profile-header.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React from 'react'; export default function ProfileHeader() { @@ -14,5 +14,5 @@ export default function ProfileHeader() {
- ) + ); }; diff --git a/frontend/components/profile/profile.tsx b/frontend/components/profile/profile.tsx index 395dc71e..c9fedfc9 100644 --- a/frontend/components/profile/profile.tsx +++ b/frontend/components/profile/profile.tsx @@ -1,7 +1,7 @@ 'use client'; -import { useUserContext } from "@/contexts/user-context"; -import { Label } from "../ui/label"; +import { useUserContext } from '@/contexts/user-context'; +import { Label } from '../ui/label'; export default function Profile() { const user = useUserContext(); @@ -15,5 +15,5 @@ export default function Profile() { - ) + ); } diff --git a/frontend/components/project/project-navbar-collapsed.tsx b/frontend/components/project/project-navbar-collapsed.tsx index e7e75b07..921a8529 100644 --- a/frontend/components/project/project-navbar-collapsed.tsx +++ b/frontend/components/project/project-navbar-collapsed.tsx @@ -1,4 +1,4 @@ -'use client' +'use client'; import { cn } from '@/lib/utils'; import { Cable, Database, Gauge, LockKeyhole, Rocket, Rows4, Settings, File, Home, LayoutGrid, ArrowBigDown, ArrowBigUp } from 'lucide-react'; @@ -12,7 +12,7 @@ import { TooltipContent, TooltipProvider, TooltipTrigger, -} from "@/components/ui/tooltip" +} from '@/components/ui/tooltip'; interface ProjectNavBarProps { projectId: string; @@ -20,7 +20,7 @@ interface ProjectNavBarProps { export default function ProjectNavbarCollapsed({ projectId }: ProjectNavBarProps) { - const pathname = usePathname() + const pathname = usePathname(); const navbarOptions = [ { @@ -83,7 +83,12 @@ export default function ProjectNavbarCollapsed({ projectId }: ProjectNavBarProps - + @@ -94,11 +99,17 @@ export default function ProjectNavbarCollapsed({ projectId }: ProjectNavBarProps - // - // - //
- // {option.name.charAt(0).toUpperCase() + option.name.slice(1)} - //
+ // + // + //
+ // {option.name.charAt(0).toUpperCase() + option.name.slice(1)} + //
// ))} diff --git a/frontend/components/project/project-navbar.tsx b/frontend/components/project/project-navbar.tsx index 0282dd97..15d62d44 100644 --- a/frontend/components/project/project-navbar.tsx +++ b/frontend/components/project/project-navbar.tsx @@ -1,4 +1,4 @@ -'use client' +'use client'; import { cn } from '@/lib/utils'; import { Cable, Database, Gauge, LockKeyhole, Rocket, Rows4 } from 'lucide-react'; @@ -14,7 +14,7 @@ interface ProjectNavBarProps { export default function ProjectNavbar({ projectId }: ProjectNavBarProps) { - const pathname = usePathname() + const pathname = usePathname(); const navbarOptions = [ { @@ -57,7 +57,7 @@ export default function ProjectNavbar({ projectId }: ProjectNavBarProps) {
{navbarOptions.map((option, i) => ( - + {option.name} diff --git a/frontend/components/projects/project-create-dialog.tsx b/frontend/components/projects/project-create-dialog.tsx index ab399cf8..6daffbee 100644 --- a/frontend/components/projects/project-create-dialog.tsx +++ b/frontend/components/projects/project-create-dialog.tsx @@ -1,6 +1,6 @@ -import { Project, WorkspaceWithProjects } from "@/lib/workspaces/types" -import { useRouter } from "next/navigation" -import { useCallback, useState } from "react" +import { Project, WorkspaceWithProjects } from '@/lib/workspaces/types'; +import { useRouter } from 'next/navigation'; +import { useCallback, useState } from 'react'; import { Dialog, DialogContent, @@ -10,11 +10,11 @@ import { DialogTrigger } from '@/components/ui/dialog'; import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@/components/ui/select'; -import { Button } from "../ui/button"; -import { Loader, Plus } from "lucide-react"; -import { Label } from "../ui/label"; -import { Input } from "../ui/input"; -import { useToast } from "@/lib/hooks/use-toast"; +import { Button } from '../ui/button'; +import { Loader, Plus } from 'lucide-react'; +import { Label } from '../ui/label'; +import { Input } from '../ui/input'; +import { useToast } from '@/lib/hooks/use-toast'; interface ProjectCreateDialogProps { onProjectCreate?: () => void @@ -22,15 +22,15 @@ interface ProjectCreateDialogProps { } export default function ProjectCreateDialog({ onProjectCreate, workspaces }: ProjectCreateDialogProps) { - const [newProjectWorkspaceId, setNewProjectWorkspaceId] = useState(undefined) - const [newProjectName, setNewProjectName] = useState('') + const [newProjectWorkspaceId, setNewProjectWorkspaceId] = useState(undefined); + const [newProjectName, setNewProjectName] = useState(''); - const [isCreatingProject, setIsCreatingProject] = useState(false) + const [isCreatingProject, setIsCreatingProject] = useState(false); const router = useRouter(); const { toast } = useToast(); const createNewProject = useCallback(async () => { - setIsCreatingProject(true) + setIsCreatingProject(true); try { const res = await fetch('/api/projects', { method: 'POST', @@ -39,24 +39,24 @@ export default function ProjectCreateDialog({ onProjectCreate, workspaces }: Pro workspaceId: newProjectWorkspaceId }) }); - const newProject = await res.json() as Project + const newProject = await res.json() as Project; onProjectCreate?.(); - router.push(`/project/${newProject.id}/traces`) - setIsCreatingProject(false) + router.push(`/project/${newProject.id}/traces`); + setIsCreatingProject(false); } catch (e) { toast({ title: 'Error creating project', variant: 'destructive', description: 'Possible reason: you have reached the projects limit in this workspace.' - }) - setIsCreatingProject(false) + }); + setIsCreatingProject(false); } - }, [newProjectName, newProjectWorkspaceId]) + }, [newProjectName, newProjectWorkspaceId]); return ( { if (workspaces.length > 0) { - setNewProjectWorkspaceId(workspaces[0].id) + setNewProjectWorkspaceId(workspaces[0].id); } }}> @@ -96,12 +96,16 @@ export default function ProjectCreateDialog({ onProjectCreate, workspaces }: Pro />
- - ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/projects/projects-alert.tsx b/frontend/components/projects/projects-alert.tsx index 87afab41..1f2d4c2f 100644 --- a/frontend/components/projects/projects-alert.tsx +++ b/frontend/components/projects/projects-alert.tsx @@ -1,5 +1,5 @@ -import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert' -import { ExclamationTriangleIcon } from '@radix-ui/react-icons' +import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; +import { ExclamationTriangleIcon } from '@radix-ui/react-icons'; export default function ProjectsAlert() { return ( @@ -11,5 +11,5 @@ export default function ProjectsAlert() { {/* todo!() return to the main page */} - ) + ); } diff --git a/frontend/components/projects/projects-header.tsx b/frontend/components/projects/projects-header.tsx index 5a8b2fc5..22a27b44 100644 --- a/frontend/components/projects/projects-header.tsx +++ b/frontend/components/projects/projects-header.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React from 'react'; export default function ProjectsHeader() { @@ -14,5 +14,5 @@ export default function ProjectsHeader() {
- ) + ); }; diff --git a/frontend/components/projects/projects.tsx b/frontend/components/projects/projects.tsx index c8ac66ac..70d53532 100644 --- a/frontend/components/projects/projects.tsx +++ b/frontend/components/projects/projects.tsx @@ -1,7 +1,7 @@ 'use client'; -import React from 'react' -import ProjectCard from '@/components/projects/project-card' +import React from 'react'; +import ProjectCard from '@/components/projects/project-card'; import { Label } from '../ui/label'; import { WorkspaceWithProjects } from '@/lib/workspaces/types'; import ProjectCreateDialog from './project-create-dialog'; diff --git a/frontend/components/projects/workspace-create-dialog.tsx b/frontend/components/projects/workspace-create-dialog.tsx index d86194df..d2b001ee 100644 --- a/frontend/components/projects/workspace-create-dialog.tsx +++ b/frontend/components/projects/workspace-create-dialog.tsx @@ -1,6 +1,6 @@ -import { WorkspaceWithProjects } from "@/lib/workspaces/types" -import { useRouter } from "next/navigation" -import { useState } from "react" +import { WorkspaceWithProjects } from '@/lib/workspaces/types'; +import { useRouter } from 'next/navigation'; +import { useState } from 'react'; import { Dialog, DialogContent, @@ -9,10 +9,10 @@ import { DialogTitle, DialogTrigger } from '@/components/ui/dialog'; -import { Button } from "../ui/button"; -import { Loader, Plus } from "lucide-react"; -import { Label } from "../ui/label"; -import { Input } from "../ui/input"; +import { Button } from '../ui/button'; +import { Loader, Plus } from 'lucide-react'; +import { Label } from '../ui/label'; +import { Input } from '../ui/input'; interface WorkspaceCreateDialogProps { onWorkspaceCreate?: () => void @@ -38,7 +38,7 @@ export default function WorkspaceCreateDialog({ onWorkspaceCreate }: WorkspaceCr onWorkspaceCreate?.(); router.push(`/workspace/${newWorkspace.id}`); setIsCreatingWorkspace(false); - } + }; return ( @@ -70,5 +70,5 @@ export default function WorkspaceCreateDialog({ onWorkspaceCreate }: WorkspaceCr - ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/projects/workspaces-navbar.tsx b/frontend/components/projects/workspaces-navbar.tsx index 3ba270da..447a2728 100644 --- a/frontend/components/projects/workspaces-navbar.tsx +++ b/frontend/components/projects/workspaces-navbar.tsx @@ -1,14 +1,14 @@ -'use client' +'use client'; -import Image from "next/image"; -import Link from "next/link"; +import Image from 'next/image'; +import Link from 'next/link'; import logo from '@/assets/logo/laminar_light.svg'; -import AvatarMenu from "../user/avatar-menu"; +import AvatarMenu from '../user/avatar-menu'; import useSWR from 'swr'; -import { WorkspaceWithProjects } from "@/lib/workspaces/types"; -import { Skeleton } from "../ui/skeleton"; -import { cn, swrFetcher } from "@/lib/utils"; -import { usePathname } from "next/navigation"; +import { WorkspaceWithProjects } from '@/lib/workspaces/types'; +import { Skeleton } from '../ui/skeleton'; +import { cn, swrFetcher } from '@/lib/utils'; +import { usePathname } from 'next/navigation'; export default function WorkspacesNavbar() { const { data, isLoading } = useSWR('/api/workspaces', swrFetcher); @@ -29,7 +29,7 @@ export default function WorkspacesNavbar() { Workspaces {isLoading && [...Array(5).keys()].map((_, index) => ())} {!isLoading && (data as WorkspaceWithProjects[]).map((workspace) => ( - + {workspace.name} ))} diff --git a/frontend/components/settings/delete-project.tsx b/frontend/components/settings/delete-project.tsx index 03a900ff..2133b7aa 100644 --- a/frontend/components/settings/delete-project.tsx +++ b/frontend/components/settings/delete-project.tsx @@ -1,80 +1,84 @@ -'use client' +'use client'; -import { Button } from "../ui/button" +import { Button } from '../ui/button'; import { - Dialog, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger + Dialog, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger } from '@/components/ui/dialog'; -import { Label } from "../ui/label"; -import { Input } from "../ui/input"; -import { useState } from "react"; -import { useProjectContext } from "@/contexts/project-context"; -import { Loader, Trash } from "lucide-react"; -import { cn } from "@/lib/utils"; +import { Label } from '../ui/label'; +import { Input } from '../ui/input'; +import { useState } from 'react'; +import { useProjectContext } from '@/contexts/project-context'; +import { Loader, Trash } from 'lucide-react'; +import { cn } from '@/lib/utils'; interface DeleteProjectProps { } export default function DeleteProject({ }: DeleteProjectProps) { - const { projectId, projectName } = useProjectContext() + const { projectId, projectName } = useProjectContext(); - const [inputProjectName, setInputProjectName] = useState('') - const [isDeleteProjectDialogOpen, setIsDeleteProjectDialogOpen] = useState(false); - const [isLoading, setIsLoading] = useState(false); + const [inputProjectName, setInputProjectName] = useState(''); + const [isDeleteProjectDialogOpen, setIsDeleteProjectDialogOpen] = useState(false); + const [isLoading, setIsLoading] = useState(false); - const deleteProject = async () => { - setIsLoading(true); + const deleteProject = async () => { + setIsLoading(true); - const res = await fetch(`/api/projects/${projectId}`, { - method: 'DELETE' - }); + const res = await fetch(`/api/projects/${projectId}`, { + method: 'DELETE' + }); - // Full force reload of the page. Otherwise, the project - // will still be accessible in the projects page. - window.location.href = '/projects'; - } + // Full force reload of the page. Otherwise, the project + // will still be accessible in the projects page. + window.location.href = '/projects'; + }; - return ( -
-
-

Delete project

-
+ ); } diff --git a/frontend/components/settings/project-api-keys.tsx b/frontend/components/settings/project-api-keys.tsx index f3382ded..1eda908c 100644 --- a/frontend/components/settings/project-api-keys.tsx +++ b/frontend/components/settings/project-api-keys.tsx @@ -1,5 +1,5 @@ -import { ProjectApiKey } from "@/lib/api-keys/types" -import { Button } from "../ui/button" +import { ProjectApiKey } from '@/lib/api-keys/types'; +import { Button } from '../ui/button'; import { Dialog, DialogContent, @@ -8,14 +8,14 @@ import { DialogTitle, DialogTrigger } from '@/components/ui/dialog'; -import { Copy, Plus } from "lucide-react"; -import { Label } from "../ui/label"; -import { Input } from "../ui/input"; -import { useCallback, useState } from "react"; -import { useProjectContext } from "@/contexts/project-context"; -import { useToast } from "@/lib/hooks/use-toast"; -import DeleteProject from "./delete-project"; -import RevokeDialog from "./revoke-dialog"; +import { Copy, Plus } from 'lucide-react'; +import { Label } from '../ui/label'; +import { Input } from '../ui/input'; +import { useCallback, useState } from 'react'; +import { useProjectContext } from '@/contexts/project-context'; +import { useToast } from '@/lib/hooks/use-toast'; +import DeleteProject from './delete-project'; +import RevokeDialog from './revoke-dialog'; interface ApiKeysProps { apiKeys: ProjectApiKey[] @@ -24,9 +24,9 @@ interface ApiKeysProps { export default function ProjectApiKeys({ apiKeys }: ApiKeysProps) { const [isGenerateKeyDialogOpen, setIsGenerateKeyDialogOpen] = useState(false); - const [projectApiKeys, setProjectApiKeys] = useState(apiKeys) - const [newApiKeyName, setNewApiKeyName] = useState('') - const { projectId } = useProjectContext() + const [projectApiKeys, setProjectApiKeys] = useState(apiKeys); + const [newApiKeyName, setNewApiKeyName] = useState(''); + const { projectId } = useProjectContext(); const { toast } = useToast(); const generateNewAPIKey = useCallback(async (newName: string) => { @@ -34,28 +34,28 @@ export default function ProjectApiKeys({ apiKeys }: ApiKeysProps) { method: 'POST', body: JSON.stringify({ name: newName }) }); - await res.json() + await res.json(); - getProjectApiKeys() - }, []) + getProjectApiKeys(); + }, []); const deleteApiKey = useCallback(async (apiKeyVal: string) => { const res = await fetch(`/api/projects/${projectId}/api-keys`, { method: 'DELETE', body: JSON.stringify({ apiKey: apiKeyVal }) }); - await res.text() + await res.text(); - getProjectApiKeys() - }, []) + getProjectApiKeys(); + }, []); const getProjectApiKeys = async () => { const res = await fetch(`/api/projects/${projectId}/api-keys`, { method: 'GET' }); - const data = await res.json() - setProjectApiKeys(data) - } + const data = await res.json(); + setProjectApiKeys(data); + }; return ( <> @@ -91,7 +91,7 @@ export default function ProjectApiKeys({ apiKeys }: ApiKeysProps) {
- ) + ); } diff --git a/frontend/components/settings/revoke-dialog.tsx b/frontend/components/settings/revoke-dialog.tsx index de00d08b..ab0bf47c 100644 --- a/frontend/components/settings/revoke-dialog.tsx +++ b/frontend/components/settings/revoke-dialog.tsx @@ -1,10 +1,10 @@ -import { ProjectApiKey } from "@/lib/api-keys/types"; -import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "../ui/dialog"; -import { useState } from "react"; -import { Button } from "../ui/button"; -import { Loader, Trash2 } from "lucide-react"; -import { Label } from "../ui/label"; -import { cn } from "@/lib/utils"; +import { ProjectApiKey } from '@/lib/api-keys/types'; +import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '../ui/dialog'; +import { useState } from 'react'; +import { Button } from '../ui/button'; +import { Loader, Trash2 } from 'lucide-react'; +import { Label } from '../ui/label'; +import { cn } from '@/lib/utils'; interface RevokeApiKeyDialogProps { obj: { name?: string, value: string }; @@ -41,4 +41,4 @@ export default function RevokeDialog({ obj, onRevoke, entity }: RevokeApiKeyDial ); -} \ No newline at end of file +} diff --git a/frontend/components/settings/settings-header.tsx b/frontend/components/settings/settings-header.tsx index df3f04ac..20ddd04f 100644 --- a/frontend/components/settings/settings-header.tsx +++ b/frontend/components/settings/settings-header.tsx @@ -1,17 +1,17 @@ -'use client' +'use client'; -import { useProjectContext } from "@/contexts/project-context" +import { useProjectContext } from '@/contexts/project-context'; export default function SettingsHeader() { - const { projectName } = useProjectContext() + const { projectName } = useProjectContext(); - return ( -
-
- {projectName} -
/
-
settings
-
-
- ) -} \ No newline at end of file + return ( +
+
+ {projectName} +
/
+
settings
+
+
+ ); +} diff --git a/frontend/components/settings/settings.tsx b/frontend/components/settings/settings.tsx index fa0ceffe..fff15796 100644 --- a/frontend/components/settings/settings.tsx +++ b/frontend/components/settings/settings.tsx @@ -1,9 +1,9 @@ 'use client'; -import { ProjectApiKey } from "@/lib/api-keys/types" -import Header from "../ui/header"; -import ProjectApiKeys from "./project-api-keys"; -import DeleteProject from "./delete-project"; +import { ProjectApiKey } from '@/lib/api-keys/types'; +import Header from '../ui/header'; +import ProjectApiKeys from './project-api-keys'; +import DeleteProject from './delete-project'; interface SettingsProps { apiKeys: ProjectApiKey[] @@ -18,5 +18,5 @@ export default function Settings({ apiKeys }: SettingsProps) { - ) + ); } diff --git a/frontend/components/sign-in/dummy-signin.tsx b/frontend/components/sign-in/dummy-signin.tsx index 73826cbd..e28be802 100644 --- a/frontend/components/sign-in/dummy-signin.tsx +++ b/frontend/components/sign-in/dummy-signin.tsx @@ -1,6 +1,6 @@ 'use client'; -import { signIn } from 'next-auth/react' +import { signIn } from 'next-auth/react'; interface DefaultSigninProps { showIcon?: boolean @@ -15,11 +15,11 @@ export function DefaultSignInButton({ className, ...props }: DefaultSigninProps) { - signIn('email', { callbackUrl: callbackUrl, email: 'username@example.com', name: 'username' }) + signIn('email', { callbackUrl: callbackUrl, email: 'username@example.com', name: 'username' }); return (
Signing in...
- ) + ); } diff --git a/frontend/components/traces/add-label-popover.tsx b/frontend/components/traces/add-label-popover.tsx index 854c1684..6394eaf8 100644 --- a/frontend/components/traces/add-label-popover.tsx +++ b/frontend/components/traces/add-label-popover.tsx @@ -1,15 +1,15 @@ -import { LabelClass, LabelType, SpanLabel } from "@/lib/traces/types"; -import { cn, swrFetcher } from "@/lib/utils"; -import { useState } from "react"; -import useSWR from "swr"; -import { Plus, Tag, X } from "lucide-react"; -import { Button } from "../ui/button"; -import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"; -import { useProjectContext } from "@/contexts/project-context"; -import { Table, TableBody, TableCell, TableRow } from "../ui/table"; -import { AddLabel } from "./add-label"; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; -import { useUserContext } from "@/contexts/user-context"; +import { LabelClass, LabelType, SpanLabel } from '@/lib/traces/types'; +import { cn, swrFetcher } from '@/lib/utils'; +import { useState } from 'react'; +import useSWR from 'swr'; +import { Plus, Tag, X } from 'lucide-react'; +import { Button } from '../ui/button'; +import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'; +import { useProjectContext } from '@/contexts/project-context'; +import { Table, TableBody, TableCell, TableRow } from '../ui/table'; +import { AddLabel } from './add-label'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'; +import { useUserContext } from '@/contexts/user-context'; interface AddLabelPopoverProps { spanId: string; @@ -40,9 +40,9 @@ export function AddLabelPopover({ }); if (response.ok) { - mutateLabels() + mutateLabels(); } - } + }; const removeLabel = async (labelId: string) => { const response = await fetch(`/api/projects/${projectId}/spans/${spanId}/labels/${labelId}`, { @@ -53,24 +53,24 @@ export function AddLabelPopover({ }); if (response.ok) { - mutateLabels() + mutateLabels(); } - } + }; const indexToValue = (index: number, labelClass: LabelClass) => { if (labelClass.labelType === LabelType.BOOLEAN) { if (index === 1) { - return "true" + return 'true'; } else if (index === 0) { - return "false" + return 'false'; } - return undefined + return undefined; } - return labelClass.valueMap[index] - } + return labelClass.valueMap[index]; + }; const findLabel = (labelClassId: string): SpanLabel | undefined => - labels?.find(label => label.classId === labelClassId && label.userEmail === email) + labels?.find(label => label.classId === labelClassId && label.userEmail === email); return ( @@ -85,7 +85,7 @@ export function AddLabelPopover({

Labels

@@ -145,15 +148,15 @@ export function AddLabelPopover({ )} {mode === 'add' && ( { - setMode('list') - mutateLabels() - mutateLabelClasses() + setMode('list'); + mutateLabels(); + mutateLabelClasses(); }} /> )}
- ) + ); } @@ -161,24 +164,28 @@ function LabelBooleanInput({ value, onChange }: { value: string | undefined, onC return (
-
{ - onChange("false") +
{ + onChange('false'); }}> False
-
{ - onChange("true") +
{ + onChange('true'); }}> True
- ) + ); } -function LabelCategoricalInput({ value, values, onChange }: { value: string | undefined, values: string[], onChange: (value: string) => void }) { +function LabelCategoricalInput({ + value, + values, + onChange +}: { value: string | undefined, values: string[], onChange: (value: string) => void }) { return ( -
+
- ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/traces/add-label.tsx b/frontend/components/traces/add-label.tsx index ce7ff20d..32d7687f 100644 --- a/frontend/components/traces/add-label.tsx +++ b/frontend/components/traces/add-label.tsx @@ -1,16 +1,16 @@ -import { LabelClass, SpanLabel, LabelType } from "@/lib/traces/types"; -import { cn, swrFetcher } from "@/lib/utils"; -import { useState } from "react"; -import useSWR from "swr"; -import { Label } from "../ui/label"; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; -import { ArrowLeft, Loader, PlusCircle, Trash2 } from "lucide-react"; -import { Input } from "../ui/input"; -import { Button } from "../ui/button"; -import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"; -import { useProjectContext } from "@/contexts/project-context"; -import { Table, TableBody, TableCell, TableRow } from "../ui/table"; -import DefaultTextarea from "../ui/default-textarea"; +import { LabelClass, SpanLabel, LabelType } from '@/lib/traces/types'; +import { cn, swrFetcher } from '@/lib/utils'; +import { useState } from 'react'; +import useSWR from 'swr'; +import { Label } from '../ui/label'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'; +import { ArrowLeft, Loader, PlusCircle, Trash2 } from 'lucide-react'; +import { Input } from '../ui/input'; +import { Button } from '../ui/button'; +import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'; +import { useProjectContext } from '@/contexts/project-context'; +import { Table, TableBody, TableCell, TableRow } from '../ui/table'; +import DefaultTextarea from '../ui/default-textarea'; interface AddLabelProps { spanId: string; @@ -26,7 +26,7 @@ export function AddLabel({ const [selectedType, setSelectedType] = useState(LabelType.BOOLEAN); const [typeName, setTypeName] = useState(''); const [isSaving, setIsSaving] = useState(false); - const [valueMap, setValueMap] = useState(["", ""]); + const [valueMap, setValueMap] = useState(['', '']); const [description, setDescription] = useState(null); const isLabelValueMapValid = valueMap.length > 0 && valueMap.every(value => value.length > 0); @@ -47,7 +47,7 @@ export function AddLabel({ setIsSaving(false); onClose(); - } + }; return (
@@ -73,10 +73,10 @@ export function AddLabel({
{ - const selectedDataset = datasets!.find((dataset) => dataset.id === datasetId)! - onDatasetChange(selectedDataset) + const selectedDataset = datasets!.find((dataset) => dataset.id === datasetId)!; + onDatasetChange(selectedDataset); }} > diff --git a/frontend/components/ui/datatable-filter.tsx b/frontend/components/ui/datatable-filter.tsx index c284653c..14a56ccd 100644 --- a/frontend/components/ui/datatable-filter.tsx +++ b/frontend/components/ui/datatable-filter.tsx @@ -1,15 +1,15 @@ -import { usePathname, useRouter, useSearchParams } from "next/navigation"; -import { Popover, PopoverTrigger } from "./popover"; -import { Button } from "./button"; -import { PopoverContent } from "@radix-ui/react-popover"; -import { ColumnDef } from "@tanstack/react-table"; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select"; -import { Input } from "./input"; -import { useEffect, useState } from "react"; -import { ListFilter, X } from "lucide-react"; -import { DatatableFilter } from "@/lib/types"; -import { Label } from "./label"; -import { cn, getFilterFromUrlParams } from "@/lib/utils"; +import { usePathname, useRouter, useSearchParams } from 'next/navigation'; +import { Popover, PopoverTrigger } from './popover'; +import { Button } from './button'; +import { PopoverContent } from '@radix-ui/react-popover'; +import { ColumnDef } from '@tanstack/react-table'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select'; +import { Input } from './input'; +import { useEffect, useState } from 'react'; +import { ListFilter, X } from 'lucide-react'; +import { DatatableFilter } from '@/lib/types'; +import { Label } from './label'; +import { cn, getFilterFromUrlParams } from '@/lib/utils'; interface DataTableFilterProps { columns: ColumnDef[]; @@ -17,9 +17,7 @@ interface DataTableFilterProps { className?: string; } -const toFilterUrlParam = (filters: DatatableFilter[]): string => { - return JSON.stringify(filters); -} +const toFilterUrlParam = (filters: DatatableFilter[]): string => JSON.stringify(filters); const SELECT_OPERATORS = [ { key: 'eq', label: '=' }, @@ -28,7 +26,7 @@ const SELECT_OPERATORS = [ { key: 'lte', label: '<=' }, { key: 'gte', label: '>=' }, { key: 'ne', label: '!=' }, -] +]; export default function DataTableFilter({ columns, className, customFilterColumns }: DataTableFilterProps) { const router = useRouter(); @@ -44,13 +42,13 @@ export default function DataTableFilter({ columns, className, customFilte return filter.column.split('.')[1].length > 0 && !!filter.operator && !!filter.value; } return !!filter.column && !!filter.operator && !!filter.value; - } + }; return (
- ) + ); } interface RowProps { @@ -191,7 +187,7 @@ function DataTableFilterRow({
{ searchParams.delete('pastHours'); - searchParams.set('startDate', calendarDate?.from?.toISOString() ?? ""); - searchParams.set('endDate', calendarDate?.to?.toISOString() ?? ""); + searchParams.set('startDate', calendarDate?.from?.toISOString() ?? ''); + searchParams.set('endDate', calendarDate?.to?.toISOString() ?? ''); setIsPopoverOpen(false); router.push(`${pathName}?${searchParams.toString()}`); }} @@ -177,7 +177,7 @@ function AbsoluteDateRangeFilter() {
- ) + ); } export default function DateRangeFilter() { @@ -200,8 +200,8 @@ export default function DateRangeFilter() { {RANGES.map((range, index) => (
{ searchParams.delete('startDate'); searchParams.delete('endDate'); @@ -218,5 +218,5 @@ export default function DateRangeFilter() { }
- ) + ); } diff --git a/frontend/components/ui/default-textarea.tsx b/frontend/components/ui/default-textarea.tsx index fd2b0296..92217bcb 100644 --- a/frontend/components/ui/default-textarea.tsx +++ b/frontend/components/ui/default-textarea.tsx @@ -1,12 +1,10 @@ -import React from 'react' -import TextareaAutosize, { type TextareaAutosizeProps } from 'react-textarea-autosize' -import { cn } from '@/lib/utils' +import React from 'react'; +import TextareaAutosize, { type TextareaAutosizeProps } from 'react-textarea-autosize'; +import { cn } from '@/lib/utils'; -const DefaultTextarea = ({ className, ...props }: TextareaAutosizeProps) => { - return -} +const DefaultTextarea = ({ className, ...props }: TextareaAutosizeProps) => ; -export default DefaultTextarea +export default DefaultTextarea; diff --git a/frontend/components/ui/dialog.tsx b/frontend/components/ui/dialog.tsx index b46f956c..13648d44 100644 --- a/frontend/components/ui/dialog.tsx +++ b/frontend/components/ui/dialog.tsx @@ -1,18 +1,18 @@ -"use client" +'use client'; -import * as React from "react" -import * as DialogPrimitive from "@radix-ui/react-dialog" -import { Cross2Icon } from "@radix-ui/react-icons" +import * as React from 'react'; +import * as DialogPrimitive from '@radix-ui/react-dialog'; +import { Cross2Icon } from '@radix-ui/react-icons'; -import { cn } from "@/lib/utils" +import { cn } from '@/lib/utils'; -const Dialog = DialogPrimitive.Root +const Dialog = DialogPrimitive.Root; -const DialogTrigger = DialogPrimitive.Trigger +const DialogTrigger = DialogPrimitive.Trigger; -const DialogPortal = DialogPrimitive.Portal +const DialogPortal = DialogPrimitive.Portal; -const DialogClose = DialogPrimitive.Close +const DialogClose = DialogPrimitive.Close; const DialogOverlay = React.forwardRef< React.ElementRef, @@ -21,13 +21,13 @@ const DialogOverlay = React.forwardRef< -)) -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName +)); +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; const DialogContent = React.forwardRef< React.ElementRef, @@ -38,7 +38,7 @@ const DialogContent = React.forwardRef< */} -)) -DialogContent.displayName = DialogPrimitive.Content.displayName +)); +DialogContent.displayName = DialogPrimitive.Content.displayName; const DialogHeader = ({ className, @@ -59,13 +59,13 @@ const DialogHeader = ({ }: React.HTMLAttributes) => (
-) -DialogHeader.displayName = "DialogHeader" +); +DialogHeader.displayName = 'DialogHeader'; const DialogFooter = ({ className, @@ -73,13 +73,13 @@ const DialogFooter = ({ }: React.HTMLAttributes) => (
-) -DialogFooter.displayName = "DialogFooter" +); +DialogFooter.displayName = 'DialogFooter'; const DialogTitle = React.forwardRef< React.ElementRef, @@ -88,13 +88,13 @@ const DialogTitle = React.forwardRef< -)) -DialogTitle.displayName = DialogPrimitive.Title.displayName +)); +DialogTitle.displayName = DialogPrimitive.Title.displayName; const DialogDescription = React.forwardRef< React.ElementRef, @@ -102,11 +102,11 @@ const DialogDescription = React.forwardRef< >(({ className, ...props }, ref) => ( -)) -DialogDescription.displayName = DialogPrimitive.Description.displayName +)); +DialogDescription.displayName = DialogPrimitive.Description.displayName; export { Dialog, @@ -119,4 +119,4 @@ export { DialogFooter, DialogTitle, DialogDescription, -} +}; diff --git a/frontend/components/ui/dropdown-menu.tsx b/frontend/components/ui/dropdown-menu.tsx index 0ff2be22..970397c9 100644 --- a/frontend/components/ui/dropdown-menu.tsx +++ b/frontend/components/ui/dropdown-menu.tsx @@ -1,26 +1,26 @@ -'use client' +'use client'; -import * as React from 'react' -import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu' +import * as React from 'react'; +import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; import { CheckIcon, ChevronRightIcon, DotFilledIcon -} from '@radix-ui/react-icons' +} from '@radix-ui/react-icons'; -import { cn } from '@/lib/utils' +import { cn } from '@/lib/utils'; -const DropdownMenu = DropdownMenuPrimitive.Root +const DropdownMenu = DropdownMenuPrimitive.Root; -const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger +const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger; -const DropdownMenuGroup = DropdownMenuPrimitive.Group +const DropdownMenuGroup = DropdownMenuPrimitive.Group; -const DropdownMenuPortal = DropdownMenuPrimitive.Portal +const DropdownMenuPortal = DropdownMenuPrimitive.Portal; -const DropdownMenuSub = DropdownMenuPrimitive.Sub +const DropdownMenuSub = DropdownMenuPrimitive.Sub; -const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup +const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup; const DropdownMenuSubTrigger = React.forwardRef< React.ElementRef, @@ -40,9 +40,9 @@ React.ComponentPropsWithoutRef & { {children} -)) +)); DropdownMenuSubTrigger.displayName = - DropdownMenuPrimitive.SubTrigger.displayName + DropdownMenuPrimitive.SubTrigger.displayName; const DropdownMenuSubContent = React.forwardRef< React.ElementRef, @@ -56,9 +56,9 @@ React.ComponentPropsWithoutRef )} {...props} /> -)) +)); DropdownMenuSubContent.displayName = - DropdownMenuPrimitive.SubContent.displayName + DropdownMenuPrimitive.SubContent.displayName; const DropdownMenuContent = React.forwardRef< React.ElementRef, @@ -76,8 +76,8 @@ React.ComponentPropsWithoutRef {...props} /> -)) -DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName +)); +DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName; const DropdownMenuItem = React.forwardRef< React.ElementRef, @@ -94,8 +94,8 @@ React.ComponentPropsWithoutRef & { )} {...props} /> -)) -DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName +)); +DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName; const DropdownMenuCheckboxItem = React.forwardRef< React.ElementRef, @@ -117,9 +117,9 @@ React.ComponentPropsWithoutRef {children} -)) +)); DropdownMenuCheckboxItem.displayName = - DropdownMenuPrimitive.CheckboxItem.displayName + DropdownMenuPrimitive.CheckboxItem.displayName; const DropdownMenuRadioItem = React.forwardRef< React.ElementRef, @@ -140,8 +140,8 @@ React.ComponentPropsWithoutRef {children} -)) -DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName +)); +DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName; const DropdownMenuLabel = React.forwardRef< React.ElementRef, @@ -158,8 +158,8 @@ React.ComponentPropsWithoutRef & { )} {...props} /> -)) -DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName +)); +DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName; const DropdownMenuSeparator = React.forwardRef< React.ElementRef, @@ -170,21 +170,19 @@ React.ComponentPropsWithoutRef className={cn('-mx-1 my-1 h-px bg-muted', className)} {...props} /> -)) -DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName +)); +DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName; const DropdownMenuShortcut = ({ className, ...props -}: React.HTMLAttributes) => { - return ( - - ) -} -DropdownMenuShortcut.displayName = 'DropdownMenuShortcut' +}: React.HTMLAttributes) => ( + +); +DropdownMenuShortcut.displayName = 'DropdownMenuShortcut'; export { DropdownMenu, @@ -202,4 +200,4 @@ export { DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuRadioGroup -} +}; diff --git a/frontend/components/ui/editable-chat-message-content-part.tsx b/frontend/components/ui/editable-chat-message-content-part.tsx index d25d4659..7d461d86 100644 --- a/frontend/components/ui/editable-chat-message-content-part.tsx +++ b/frontend/components/ui/editable-chat-message-content-part.tsx @@ -1,11 +1,11 @@ -import { AiOutlineMinusCircle } from 'react-icons/ai' -import { useState } from 'react' -import { ChatMessageContentPart, ChatMessageImage, ChatMessageImageUrl, ChatMessageText } from '@/lib/types' -import DefaultTextarea from './default-textarea' -import { Input } from './input' -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select' +import { AiOutlineMinusCircle } from 'react-icons/ai'; +import { useState } from 'react'; +import { ChatMessageContentPart, ChatMessageImage, ChatMessageImageUrl, ChatMessageText } from '@/lib/types'; +import DefaultTextarea from './default-textarea'; +import { Input } from './input'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select'; -const SUPPORTED_MEDIA_TYPES = ['image/jpeg', 'image/png', 'image/webp', 'image/gif'] +const SUPPORTED_MEDIA_TYPES = ['image/jpeg', 'image/png', 'image/webp', 'image/gif']; interface EditableChatMessageContentPartProps { defaultPart: ChatMessageContentPart @@ -26,38 +26,38 @@ export default function EditableChatMessageContentPart({ defaultPart, index, onD } else if (newType === 'image') { newPart = { type: 'image', mediaType: SUPPORTED_MEDIA_TYPES[0], data: '' - } + }; } else { - newPart = { type: 'image_url', url: '', detail: null } + newPart = { type: 'image_url', url: '', detail: null }; }; setPart(newPart); onEdit(index, newPart); - } + }; const textChange = (text: string) => { const newPart = { ...part, text }; setPart(newPart); onEdit(index, newPart); - } + }; const mediaTypeChange = (mediaType: string) => { const newPart = { ...part, mediaType }; setPart(newPart); onEdit(index, newPart); - } + }; const imageDataChange = (data: string) => { const newPart = { ...part, data }; setPart(newPart); onEdit(index, newPart); - } + }; const imageUrlChange = (url: string) => { const newPart = { ...part, url }; setPart(newPart); onEdit(index, newPart); - } + }; return (
@@ -69,7 +69,7 @@ export default function EditableChatMessageContentPart({ defaultPart, index, onD
-
@@ -80,7 +80,7 @@ export default function EditableChatMessageContentPart({ defaultPart, index, onD key="text" placeholder="Text content" defaultValue={(part as ChatMessageText).text} - onChange={e => { textChange(e.currentTarget.value) }} + onChange={e => { textChange(e.currentTarget.value); }} spellCheck={false} maxLength={-1} /> @@ -103,7 +103,7 @@ export default function EditableChatMessageContentPart({ defaultPart, index, onD { imageDataChange(e.currentTarget.value) }} + onChange={e => { imageDataChange(e.currentTarget.value); }} spellCheck={false} maxLength={-1} /> @@ -112,7 +112,7 @@ export default function EditableChatMessageContentPart({ defaultPart, index, onD { imageUrlChange(e.currentTarget.value) }} + onChange={e => { imageUrlChange(e.currentTarget.value); }} spellCheck={false} maxLength={-1} /> @@ -120,5 +120,5 @@ export default function EditableChatMessageContentPart({ defaultPart, index, onD ) }
- ) + ); }; diff --git a/frontend/components/ui/editable-chat-message-content-parts.tsx b/frontend/components/ui/editable-chat-message-content-parts.tsx index 05451eec..e77b2efe 100644 --- a/frontend/components/ui/editable-chat-message-content-parts.tsx +++ b/frontend/components/ui/editable-chat-message-content-parts.tsx @@ -1,7 +1,7 @@ -import { ChatMessageContentPart, ChatMessageText } from '@/lib/types' -import { useEffect, useRef } from 'react' -import EditableChatMessageContentPart from './editable-chat-message-content-part' -import { AiOutlinePlusCircle } from 'react-icons/ai' +import { ChatMessageContentPart, ChatMessageText } from '@/lib/types'; +import { useEffect, useRef } from 'react'; +import EditableChatMessageContentPart from './editable-chat-message-content-part'; +import { AiOutlinePlusCircle } from 'react-icons/ai'; interface EditableChatMessageContentPartsProps { parts: ChatMessageContentPart[] @@ -16,31 +16,31 @@ export default function EditableChatMessageContentParts({ parts, setParts }: Edi useEffect(() => { idsRef.current = parts.map((_, index) => index); - }, []) + }, []); const addPart = () => { const newPart: ChatMessageText = { type: 'text', text: '' - } + }; const newId = idsRef.current!.length > 0 ? idsRef.current![idsRef.current!.length - 1] + 1 : 0; idsRef.current!.push(newId); - setParts([...parts, newPart]) - } + setParts([...parts, newPart]); + }; const deletePart = (index: number) => { idsRef.current!.splice(index, 1); - const newParts = [...parts] - newParts.splice(index, 1) - setParts(newParts) - } + const newParts = [...parts]; + newParts.splice(index, 1); + setParts(newParts); + }; const editPart = (index: number, part: ChatMessageContentPart) => { - const newParts = [...parts] - newParts[index] = part - setParts(newParts) - } + const newParts = [...parts]; + newParts[index] = part; + setParts(newParts); + }; return (
@@ -57,5 +57,5 @@ export default function EditableChatMessageContentParts({ parts, setParts }: Edi
- ) + ); } diff --git a/frontend/components/ui/editable-chat-message.tsx b/frontend/components/ui/editable-chat-message.tsx index fca8041d..cc638b81 100644 --- a/frontend/components/ui/editable-chat-message.tsx +++ b/frontend/components/ui/editable-chat-message.tsx @@ -1,12 +1,12 @@ -import { AiOutlineMinusCircle } from 'react-icons/ai' -import TextareaAutosize from 'react-textarea-autosize' -import { use, useEffect, useRef, useState } from 'react' -import { ChatMessage, ChatMessageContentPart } from '@/lib/types' -import DefaultTextarea from './default-textarea' -import { List, ListPlus, Minus } from 'lucide-react' -import EditableChatMessageContentParts from './editable-chat-message-content-parts' -import { isStringType } from '@/lib/utils' -import { Button } from './button' +import { AiOutlineMinusCircle } from 'react-icons/ai'; +import TextareaAutosize from 'react-textarea-autosize'; +import { use, useEffect, useRef, useState } from 'react'; +import { ChatMessage, ChatMessageContentPart } from '@/lib/types'; +import DefaultTextarea from './default-textarea'; +import { List, ListPlus, Minus } from 'lucide-react'; +import EditableChatMessageContentParts from './editable-chat-message-content-parts'; +import { isStringType } from '@/lib/utils'; +import { Button } from './button'; interface EditableChatMessageProps { defaultMessage: ChatMessage @@ -16,40 +16,40 @@ interface EditableChatMessageProps { } export default function EditableChatMessage({ defaultMessage, index, onDelete, onEdit }: EditableChatMessageProps) { - const [content, setContent] = useState(defaultMessage.content) - const [role, setRole] = useState(defaultMessage.role) + const [content, setContent] = useState(defaultMessage.content); + const [role, setRole] = useState(defaultMessage.role); useEffect(() => { - setContent(content) - }, [content]) + setContent(content); + }, [content]); const changeRole = () => { const newMessage: ChatMessage = { content, role: role === 'user' ? 'assistant' : 'user' - } + }; - setRole(newMessage.role) - onEdit(index, newMessage) - } + setRole(newMessage.role); + onEdit(index, newMessage); + }; const textContentChange = (content: string) => { const newMessage: ChatMessage = { role, content - } - setContent(newMessage.content) - onEdit(index, newMessage) - } + }; + setContent(newMessage.content); + onEdit(index, newMessage); + }; const partsChange = (parts: ChatMessageContentPart[]) => { const newMessage: ChatMessage = { role, content: parts - } - setContent(newMessage.content) - onEdit(index, newMessage) - } + }; + setContent(newMessage.content); + onEdit(index, newMessage); + }; const toggleType = () => { let newMessage: ChatMessage; @@ -57,31 +57,31 @@ export default function EditableChatMessage({ defaultMessage, index, onDelete, o newMessage = { role, content: [{ type: 'text', text: content }] - } + }; } else { newMessage = { role, content: (content.length > 0 && content[0].type === 'text') ? content[0].text : '' - } + }; } - setContent(newMessage.content) - onEdit(index, newMessage) - } + setContent(newMessage.content); + onEdit(index, newMessage); + }; return (
- -
-
@@ -91,18 +91,18 @@ export default function EditableChatMessage({ defaultMessage, index, onDelete, o key="text-content" placeholder="Message" defaultValue={content} - onChange={e => { textContentChange(e.currentTarget.value) }} + onChange={e => { textContentChange(e.currentTarget.value); }} spellCheck={false} maxLength={-1} /> ) : (
{ - partsChange(parts) + partsChange(parts); }} />
) }
- ) + ); }; diff --git a/frontend/components/ui/editable-chat.tsx b/frontend/components/ui/editable-chat.tsx index d61db5ec..7e272abb 100644 --- a/frontend/components/ui/editable-chat.tsx +++ b/frontend/components/ui/editable-chat.tsx @@ -1,7 +1,7 @@ -import EditableChatMessage from './editable-chat-message' -import { Button } from './button' -import { ChatMessage } from '@/lib/types' -import { useEffect, useRef, useState } from 'react' +import EditableChatMessage from './editable-chat-message'; +import { Button } from './button'; +import { ChatMessage } from '@/lib/types'; +import { useEffect, useRef, useState } from 'react'; interface EditableChatProps { messages: ChatMessage[] @@ -10,10 +10,10 @@ interface EditableChatProps { /** * Container for EditableChatMessage list. - * + * * The main purpose of this component is to (1) map messages to EditableChatMessage components, * and (2) manage the keys for each EditableChatMessage component to be uniquely identified by DOM. - * + * * Main point: when "setMessages" is called, the component will re-render with the new messages. * However, essentially, idsRef will help each EditableChatMessage to be "remembered" by DOM with persistent id * and not be re-rendered. @@ -27,36 +27,36 @@ export default function EditableChat({ messages, setMessages }: EditableChatProp useEffect(() => { idsRef.current = messages.map((_, index) => index); - }, []) + }, []); useEffect(() => { // Force re-render, otherwise when switching the mode, it doesn't render anything thinking that the idsRef.current is null. forceUpdate(n => n + 1); - }, [idsRef.current]) + }, [idsRef.current]); const addMessage = () => { const newMessage: ChatMessage = { role: 'user', content: '' - } + }; const newId = idsRef.current!.length > 0 ? idsRef.current![idsRef.current!.length - 1] + 1 : 0; idsRef.current!.push(newId); - setMessages([...messages, newMessage]) - } + setMessages([...messages, newMessage]); + }; const deleteMessage = (index: number) => { idsRef.current!.splice(index, 1); - const newMessages = [...messages] - newMessages.splice(index, 1) - setMessages(newMessages) - } + const newMessages = [...messages]; + newMessages.splice(index, 1); + setMessages(newMessages); + }; const editMessage = (index: number, message: ChatMessage) => { - const newMessages = [...messages] - newMessages[index] = message - setMessages(newMessages) - } + const newMessages = [...messages]; + newMessages[index] = message; + setMessages(newMessages); + }; return ( (idsRef.current !== null) && ( @@ -75,5 +75,5 @@ export default function EditableChat({ messages, setMessages }: EditableChatProp
) - ) + ); } diff --git a/frontend/components/ui/editable-string-list.tsx b/frontend/components/ui/editable-string-list.tsx index 58090677..d1a4bf1f 100644 --- a/frontend/components/ui/editable-string-list.tsx +++ b/frontend/components/ui/editable-string-list.tsx @@ -1,6 +1,6 @@ -import { AiOutlineMinusCircle } from 'react-icons/ai' -import { Button } from './button' -import DefaultTextarea from './default-textarea' +import { AiOutlineMinusCircle } from 'react-icons/ai'; +import { Button } from './button'; +import DefaultTextarea from './default-textarea'; interface EditableStringListProps { messages: string[] @@ -9,10 +9,10 @@ interface EditableStringListProps { export default function EditableStringList({ messages, setMessages }: EditableStringListProps) { const deleteMessage = (index: number) => { - const newMessages = [...messages] - newMessages.splice(index, 1) - setMessages(newMessages) - } + const newMessages = [...messages]; + newMessages.splice(index, 1); + setMessages(newMessages); + }; // TODO: Each string must be uniquely identifiable (simply keying by index is not enough since string in the middle can be deleted) return ( @@ -26,20 +26,20 @@ export default function EditableStringList({ messages, setMessages }: EditableSt defaultValue={message} className="w-full" onChange={(e) => { - const newMessages = [...messages] - newMessages[index] = e.currentTarget.value - setMessages(newMessages) + const newMessages = [...messages]; + newMessages[index] = e.currentTarget.value; + setMessages(newMessages); }} />
-
))} - + - ) + ); } diff --git a/frontend/components/ui/formatter.tsx b/frontend/components/ui/formatter.tsx index 39392926..97c48770 100644 --- a/frontend/components/ui/formatter.tsx +++ b/frontend/components/ui/formatter.tsx @@ -1,13 +1,13 @@ -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select"; -import { useState } from "react"; -import YAML from 'yaml' +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select'; +import { useState } from 'react'; +import YAML from 'yaml'; import CodeMirror from '@uiw/react-codemirror'; import { createTheme } from '@uiw/codemirror-themes'; import { githubDarkStyle } from '@uiw/codemirror-theme-github'; import { json } from '@codemirror/lang-json'; import { yaml } from '@codemirror/lang-yaml'; -import { EditorView } from "@codemirror/view"; -import { cn } from "@/lib/utils"; +import { EditorView } from '@codemirror/view'; +import { cn } from '@/lib/utils'; interface OutputFormatterProps { value: string; @@ -29,37 +29,37 @@ const myTheme = createTheme({ styles: githubDarkStyle, }); -export default function Formatter({ value, defaultMode = "text", editable = false, onChange, className }: OutputFormatterProps) { +export default function Formatter({ value, defaultMode = 'text', editable = false, onChange, className }: OutputFormatterProps) { - const [mode, setMode] = useState(defaultMode) + const [mode, setMode] = useState(defaultMode); const renderText = (value: string) => { // if mode is YAML try to parse it as YAML - if (mode === "yaml") { + if (mode === 'yaml') { try { - const yamlFormatted = YAML.stringify(JSON.parse(value)) - return yamlFormatted + const yamlFormatted = YAML.stringify(JSON.parse(value)); + return yamlFormatted; } catch (e) { - return value + return value; } - } else if (mode === "json") { + } else if (mode === 'json') { try { if (JSON.parse(value) === value) { - return value + return value; } - const jsonFormatted = JSON.stringify(JSON.parse(value), null, 2) - return jsonFormatted + const jsonFormatted = JSON.stringify(JSON.parse(value), null, 2); + return jsonFormatted; } catch (e) { - return value + return value; } } - return value - } + return value; + }; return ( -
+
@@ -92,7 +92,7 @@ export default function Formatter({ value, defaultMode = "text", editable = fals editable={editable} value={renderText(value)} onChange={v => { - if (mode === "yaml") { + if (mode === 'yaml') { try { const parsedYaml = YAML.parse(v); onChange?.(JSON.stringify(parsedYaml, null, 2)); @@ -100,11 +100,11 @@ export default function Formatter({ value, defaultMode = "text", editable = fals onChange?.(v); } } else { - onChange?.(v) + onChange?.(v); } }} />
- ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/ui/group-by-period-select.tsx b/frontend/components/ui/group-by-period-select.tsx index 43ef342a..de668353 100644 --- a/frontend/components/ui/group-by-period-select.tsx +++ b/frontend/components/ui/group-by-period-select.tsx @@ -1,6 +1,6 @@ -import { useRouter, useSearchParams } from "next/navigation" -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select"; -import { getGroupByInterval, isGroupByIntervalAvailable } from "@/lib/utils"; +import { useRouter, useSearchParams } from 'next/navigation'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select'; +import { getGroupByInterval, isGroupByIntervalAvailable } from '@/lib/utils'; export function GroupByPeriodSelect() { @@ -31,5 +31,5 @@ export function GroupByPeriodSelect() {
- ) + ); } diff --git a/frontend/components/ui/header.tsx b/frontend/components/ui/header.tsx index 53692750..62b69234 100644 --- a/frontend/components/ui/header.tsx +++ b/frontend/components/ui/header.tsx @@ -1,8 +1,8 @@ -'use client' +'use client'; -import { useProjectContext } from '@/contexts/project-context' -import { Button } from './button' -import Link from 'next/link' +import { useProjectContext } from '@/contexts/project-context'; +import { Button } from './button'; +import Link from 'next/link'; interface HeaderProps { path: string @@ -12,9 +12,9 @@ interface HeaderProps { export default function Header({ path, children, className }: HeaderProps) { - const { projectId, projectName } = useProjectContext() + const { projectId, projectName } = useProjectContext(); - const segments = path.split('/') + const segments = path.split('/'); return (
@@ -25,25 +25,23 @@ export default function Header({ path, children, className }: HeaderProps) {
/
} - {segments.map((segment, index) => { - return ( -
- {index > 0 &&
/
} - {index === segments.length - 1 ?
{segment}
: - {segment} - } -
- ) - })} + {segments.map((segment, index) => ( +
+ {index > 0 &&
/
} + {index === segments.length - 1 ?
{segment}
: + {segment} + } +
+ ))} {children}
- -
- ) + ); }; diff --git a/frontend/components/ui/icons.tsx b/frontend/components/ui/icons.tsx index 085e76b4..4903dc55 100644 --- a/frontend/components/ui/icons.tsx +++ b/frontend/components/ui/icons.tsx @@ -1,15 +1,15 @@ -'use client' +'use client'; -import * as React from 'react' +import * as React from 'react'; -import { cn } from '@/lib/utils' +import { cn } from '@/lib/utils'; function IconNextChat({ className, inverted, ...props }: React.ComponentProps<'svg'> & { inverted?: boolean }) { - const id = React.useId() + const id = React.useId(); return ( - ) + ); } function IconOpenAI({ className, ...props }: React.ComponentProps<'svg'>) { @@ -101,7 +101,7 @@ function IconOpenAI({ className, ...props }: React.ComponentProps<'svg'>) { OpenAI icon - ) + ); } function IconVercel({ className, ...props }: React.ComponentProps<'svg'>) { @@ -118,7 +118,7 @@ function IconVercel({ className, ...props }: React.ComponentProps<'svg'>) { fill="currentColor" > - ) + ); } function IconGitHub({ className, ...props }: React.ComponentProps<'svg'>) { @@ -134,7 +134,7 @@ function IconGitHub({ className, ...props }: React.ComponentProps<'svg'>) { GitHub - ) + ); } function IconGoogle({ className, ...props }: React.ComponentProps<'svg'>) { @@ -152,7 +152,7 @@ function IconGoogle({ className, ...props }: React.ComponentProps<'svg'>) { c-35.841,0-65,29.159-65,65s29.159,65,65,65c28.867,0,53.398-18.913,61.852-45H105V85h105v20c0,57.897-47.103,105-105,105 S0,162.897,0,105z" /> - ) + ); } function IconSeparator({ className, ...props }: React.ComponentProps<'svg'>) { @@ -171,7 +171,7 @@ function IconSeparator({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconArrowDown({ className, ...props }: React.ComponentProps<'svg'>) { @@ -185,7 +185,7 @@ function IconArrowDown({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconArrowRight({ className, ...props }: React.ComponentProps<'svg'>) { @@ -199,7 +199,7 @@ function IconArrowRight({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconUser({ className, ...props }: React.ComponentProps<'svg'>) { @@ -213,7 +213,7 @@ function IconUser({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconPlus({ className, ...props }: React.ComponentProps<'svg'>) { @@ -227,7 +227,7 @@ function IconPlus({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconArrowElbow({ className, ...props }: React.ComponentProps<'svg'>) { @@ -241,7 +241,7 @@ function IconArrowElbow({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconSpinner({ className, ...props }: React.ComponentProps<'svg'>) { @@ -255,7 +255,7 @@ function IconSpinner({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconMessage({ className, ...props }: React.ComponentProps<'svg'>) { @@ -269,7 +269,7 @@ function IconMessage({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconTrash({ className, ...props }: React.ComponentProps<'svg'>) { @@ -283,7 +283,7 @@ function IconTrash({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconRefresh({ className, ...props }: React.ComponentProps<'svg'>) { @@ -297,7 +297,7 @@ function IconRefresh({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconStop({ className, ...props }: React.ComponentProps<'svg'>) { @@ -311,7 +311,7 @@ function IconStop({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconSidebar({ className, ...props }: React.ComponentProps<'svg'>) { @@ -325,7 +325,7 @@ function IconSidebar({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconMoon({ className, ...props }: React.ComponentProps<'svg'>) { @@ -339,7 +339,7 @@ function IconMoon({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconSun({ className, ...props }: React.ComponentProps<'svg'>) { @@ -353,7 +353,7 @@ function IconSun({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconCopy({ className, ...props }: React.ComponentProps<'svg'>) { @@ -367,7 +367,7 @@ function IconCopy({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconCheck({ className, ...props }: React.ComponentProps<'svg'>) { @@ -381,7 +381,7 @@ function IconCheck({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconDownload({ className, ...props }: React.ComponentProps<'svg'>) { @@ -395,7 +395,7 @@ function IconDownload({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconClose({ className, ...props }: React.ComponentProps<'svg'>) { @@ -409,7 +409,7 @@ function IconClose({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconEdit({ className, ...props }: React.ComponentProps<'svg'>) { @@ -429,7 +429,7 @@ function IconEdit({ className, ...props }: React.ComponentProps<'svg'>) { d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" /> - ) + ); } function IconShare({ className, ...props }: React.ComponentProps<'svg'>) { @@ -443,7 +443,7 @@ function IconShare({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconUsers({ className, ...props }: React.ComponentProps<'svg'>) { @@ -457,7 +457,7 @@ function IconUsers({ className, ...props }: React.ComponentProps<'svg'>) { > - ) + ); } function IconExternalLink({ @@ -474,7 +474,7 @@ function IconExternalLink({ > - ) + ); } function IconChevronUpDown({ @@ -491,7 +491,7 @@ function IconChevronUpDown({ > - ) + ); } function IconMinusCircle({ @@ -508,7 +508,7 @@ function IconMinusCircle({ > - ) + ); } function IconGear({ @@ -525,7 +525,7 @@ function IconGear({ > - ) + ); } function IconZenguard({ @@ -576,4 +576,4 @@ export { IconChevronUpDown, IconZenguard, IconGoogle -} +}; diff --git a/frontend/components/ui/ide-json.tsx b/frontend/components/ui/ide-json.tsx index 9e137466..600e15db 100644 --- a/frontend/components/ui/ide-json.tsx +++ b/frontend/components/ui/ide-json.tsx @@ -1,6 +1,6 @@ -import ReactAce from "react-ace"; -import "ace-builds/src-noconflict/mode-json"; -import "ace-builds/src-noconflict/theme-tomorrow"; +import ReactAce from 'react-ace'; +import 'ace-builds/src-noconflict/mode-json'; +import 'ace-builds/src-noconflict/theme-tomorrow'; interface IdeJsonProps { @@ -27,6 +27,6 @@ export default function IdeJson({ value, onChange }: IdeJsonProps) { style={{ width: '100%', height: '200px' }} /> - ) + ); -} \ No newline at end of file +} diff --git a/frontend/components/ui/ide.tsx b/frontend/components/ui/ide.tsx index fc667a29..2c8c298d 100644 --- a/frontend/components/ui/ide.tsx +++ b/frontend/components/ui/ide.tsx @@ -1,15 +1,15 @@ -import ReactAce, { IAceEditorProps } from "react-ace"; +import ReactAce, { IAceEditorProps } from 'react-ace'; -import "ace-builds/src-noconflict/ext-language_tools"; -import "ace-builds/src-noconflict/ext-beautify"; -import "ace-builds/src-noconflict/theme-github"; -import "ace-builds/src-noconflict/theme-one_dark"; -import "ace-builds/src-noconflict/mode-json"; -import "ace-builds/src-noconflict/mode-yaml"; -import "ace-builds/src-noconflict/mode-python"; -import "ace-builds/src-noconflict/mode-handlebars"; -import "ace-builds/src-noconflict/mode-typescript"; -import "ace-builds/src-noconflict/mode-markdown"; +import 'ace-builds/src-noconflict/ext-language_tools'; +import 'ace-builds/src-noconflict/ext-beautify'; +import 'ace-builds/src-noconflict/theme-github'; +import 'ace-builds/src-noconflict/theme-one_dark'; +import 'ace-builds/src-noconflict/mode-json'; +import 'ace-builds/src-noconflict/mode-yaml'; +import 'ace-builds/src-noconflict/mode-python'; +import 'ace-builds/src-noconflict/mode-handlebars'; +import 'ace-builds/src-noconflict/mode-typescript'; +import 'ace-builds/src-noconflict/mode-markdown'; interface IdeProps extends IAceEditorProps { } @@ -38,5 +38,5 @@ export default function Ide({ ...props }: IdeProps) { {...props} /> - ) -} \ No newline at end of file + ); +} diff --git a/frontend/components/ui/input-password.tsx b/frontend/components/ui/input-password.tsx index b4fd4902..5666196c 100644 --- a/frontend/components/ui/input-password.tsx +++ b/frontend/components/ui/input-password.tsx @@ -1,6 +1,6 @@ -import * as React from 'react' +import * as React from 'react'; -import { cn } from '@/lib/utils' +import { cn } from '@/lib/utils'; import { EyeIcon, EyeOffIcon } from 'lucide-react'; import { fontSecurity, fontSans } from '@/lib/fonts'; @@ -11,7 +11,7 @@ export interface InputPasswordProps /** * Text input field with password visibility toggle. - * + * * It doesn't use type=password so that it doesn't try to autofill passwords from the browser. * It uses text-security-disc font to hide the password. * Note that in this case special browser security features won't work, assuming that API keys, which are put here, @@ -29,7 +29,7 @@ const InputPassword = React.forwardRef( )}> ( - ) + ); } -) -InputPassword.displayName = 'InputPassword' +); +InputPassword.displayName = 'InputPassword'; -export { InputPassword } +export { InputPassword }; diff --git a/frontend/components/ui/input.tsx b/frontend/components/ui/input.tsx index cf4b30f1..7dbe2dc9 100644 --- a/frontend/components/ui/input.tsx +++ b/frontend/components/ui/input.tsx @@ -1,25 +1,23 @@ -import * as React from 'react' +import * as React from 'react'; -import { cn } from '@/lib/utils' +import { cn } from '@/lib/utils'; export interface InputProps extends React.InputHTMLAttributes { } const Input = React.forwardRef( - ({ className, type, ...props }, ref) => { - return ( - - ) - } -) -Input.displayName = 'Input' + ({ className, type, ...props }, ref) => ( + + ) +); +Input.displayName = 'Input'; -export { Input } +export { Input }; diff --git a/frontend/components/ui/label.tsx b/frontend/components/ui/label.tsx index 8be94331..c9676b7c 100644 --- a/frontend/components/ui/label.tsx +++ b/frontend/components/ui/label.tsx @@ -1,14 +1,14 @@ -'use client' +'use client'; -import * as React from 'react' -import * as LabelPrimitive from '@radix-ui/react-label' -import { cva, type VariantProps } from 'class-variance-authority' +import * as React from 'react'; +import * as LabelPrimitive from '@radix-ui/react-label'; +import { cva, type VariantProps } from 'class-variance-authority'; -import { cn } from '@/lib/utils' +import { cn } from '@/lib/utils'; const labelVariants = cva( 'text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70' -) +); const Label = React.forwardRef< React.ElementRef, @@ -20,7 +20,7 @@ VariantProps className={cn(labelVariants(), className)} {...props} /> -)) -Label.displayName = LabelPrimitive.Root.displayName +)); +Label.displayName = LabelPrimitive.Root.displayName; -export { Label } +export { Label }; diff --git a/frontend/components/ui/mono.tsx b/frontend/components/ui/mono.tsx index c833288c..44384a75 100644 --- a/frontend/components/ui/mono.tsx +++ b/frontend/components/ui/mono.tsx @@ -1,8 +1,8 @@ -import { cn } from "@/lib/utils"; -import { ReactNode } from "react"; +import { cn } from '@/lib/utils'; +import { ReactNode } from 'react'; export default function Mono({ className, children }: { className?: string, children: ReactNode }) { return ( - {children} + {children} ); -} \ No newline at end of file +} diff --git a/frontend/components/ui/pagination.tsx b/frontend/components/ui/pagination.tsx index 7715f05a..c61d834f 100644 --- a/frontend/components/ui/pagination.tsx +++ b/frontend/components/ui/pagination.tsx @@ -1,67 +1,67 @@ -import * as React from "react" +import * as React from 'react'; import { ChevronLeftIcon, ChevronRightIcon, DotsHorizontalIcon, -} from "@radix-ui/react-icons" +} from '@radix-ui/react-icons'; -import { cn } from "@/lib/utils" -import { ButtonProps, buttonVariants } from "@/components/ui/button" +import { cn } from '@/lib/utils'; +import { ButtonProps, buttonVariants } from '@/components/ui/button'; -const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => ( +const Pagination = ({ className, ...props }: React.ComponentProps<'nav'>) => (