Skip to content

Commit 9064564

Browse files
authored
Merge branch 'staging' into fix-search-element
2 parents a84ff57 + d982511 commit 9064564

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3298
-1994
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ updates:
88
- package-ecosystem: "npm" # See documentation for possible values
99
directory: "/" # Location of package manifests
1010
schedule:
11-
interval: "weekly"
11+
interval: "daily"
12+
target-branch: "staging"
1213

.github/workflows/playwright.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main, staging ]
5+
pull_request:
6+
branches: [ main, staging ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
services:
12+
falkordb:
13+
image: falkordb/falkordb:latest
14+
ports:
15+
- 6379:6379
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: lts/*
21+
- name: Install dependencies
22+
run: npm ci
23+
- name: Install Playwright Browsers
24+
run: npx playwright install --with-deps
25+
- name: Set up environment variables and run tests
26+
env:
27+
FALKORDB_URL: ${{ secrets.FALKORDB_URL }}
28+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
29+
SECRET_TOKEN: ${{ secrets.SECRET_TOKEN }}
30+
NEXT_PUBLIC_MODE: UNLIMITED
31+
BACKEND_URL: ${{ secrets.BACKEND_URL }}
32+
run: |
33+
npm install
34+
npm run build
35+
NEXTAUTH_SECRET=SECRET npm start & npx playwright test --reporter=dot,list
36+
- uses: actions/upload-artifact@v4
37+
if: ${{ !cancelled() }}
38+
with:
39+
name: playwright-report
40+
path: playwright-report/
41+
retention-days: 30

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ next-env.d.ts
3737

3838

3939
# vscode
40-
/.vscode/
40+
/.vscode/
41+
node_modules/
42+
/test-results/
43+
/playwright-report/
44+
/blob-report/
45+
/playwright/.cache/

app/api/chat/[graph]/route.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
import { NextRequest, NextResponse } from "next/server"
2+
import { getEnvVariables } from "../../utils"
23

34

4-
export async function POST(request: NextRequest, { params }: { params: { graph: string } }) {
5+
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
56

6-
const graphName = params.graph
7+
const repo = (await params).graph
78
const msg = request.nextUrl.searchParams.get('msg')
89

910
try {
10-
const result = await fetch(`${process.env.BACKEND_URL}/chat`, {
11+
12+
if (!msg) {
13+
throw new Error("Message parameter is required")
14+
}
15+
16+
const { url, token } = getEnvVariables()
17+
18+
const result = await fetch(`${url}/chat`, {
1119
method: 'POST',
12-
body: JSON.stringify({ repo: graphName, msg }),
20+
body: JSON.stringify({ repo, msg }),
1321
headers: {
14-
"Authorization": process.env.SECRET_TOKEN!,
22+
"Authorization": token,
1523
"Content-Type": 'application/json'
16-
}
24+
},
25+
cache: 'no-store'
1726
})
1827

1928
if (!result.ok) {
@@ -24,6 +33,7 @@ export async function POST(request: NextRequest, { params }: { params: { graph:
2433

2534
return NextResponse.json({ result: json }, { status: 200 })
2635
} catch (err) {
27-
return NextResponse.json({ message: (err as Error).message }, { status: 400 })
36+
console.error(err)
37+
return NextResponse.json((err as Error).message, { status: 400 })
2838
}
2939
}
Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,34 @@
1+
import { getEnvVariables } from "@/app/api/utils";
12
import { NextRequest, NextResponse } from "next/server";
23

3-
export async function GET(request: NextRequest, { params }: { params: { graph: string, node: string } }) {
4+
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string, node: string }> }) {
45

5-
const nodeId = parseInt(params.node);
6-
const graphId = params.graph;
7-
try {
8-
9-
const result = await fetch(`${process.env.BACKEND_URL}/get_neighbors?repo=${graphId}&node_id=${nodeId}`, {
10-
method: 'GET',
11-
headers: {
12-
"Authorization": process.env.SECRET_TOKEN!,
13-
}
14-
})
15-
16-
const json = await result.json()
6+
const p = await params;
177

18-
return NextResponse.json({ result: json }, { status: 200 })
19-
} catch (err) {
20-
return NextResponse.json({ massage: (err as Error).message }, { status: 400 })
21-
}
22-
}
8+
const repo = p.graph;
9+
const src = Number(p.node);
10+
const dest = Number(request.nextUrl.searchParams.get('targetId'))
2311

24-
export async function POST(request: NextRequest, { params }: { params: { graph: string, node: string } }) {
12+
try {
2513

26-
const nodeId = params.node;
27-
const graphId = params.graph;
28-
const targetId = request.nextUrl.searchParams.get('targetId')
14+
if (!dest) {
15+
throw new Error("targetId is required");
16+
}
2917

30-
try {
18+
const { url, token } = getEnvVariables()
3119

32-
const result = await fetch(`${process.env.BACKEND_URL}/find_paths`, {
20+
const result = await fetch(`${url}/find_paths`, {
3321
method: 'POST',
3422
headers: {
35-
"Authorization": process.env.SECRET_TOKEN!,
23+
"Authorization": token,
3624
'Content-Type': 'application/json'
3725
},
3826
body: JSON.stringify({
39-
repo: graphId,
40-
src: Number(nodeId),
41-
dest: Number(targetId!)
42-
})
27+
repo,
28+
src,
29+
dest
30+
}),
31+
cache: 'no-store'
4332
})
4433

4534
if (!result.ok) {
@@ -50,6 +39,7 @@ export async function POST(request: NextRequest, { params }: { params: { graph:
5039

5140
return NextResponse.json({ result: json }, { status: 200 })
5241
} catch (err) {
53-
return NextResponse.json({ massage: (err as Error).message }, { status: 200 })
42+
console.error(err)
43+
return NextResponse.json((err as Error).message, { status: 400 })
5444
}
5545
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { getEnvVariables } from "@/app/api/utils";
2+
import { NextRequest, NextResponse } from "next/server";
3+
4+
export async function GET(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
5+
6+
const repo = (await params).graph
7+
8+
try {
9+
10+
const { url, token } = getEnvVariables()
11+
12+
const result = await fetch(`${url}/list_commits`, {
13+
method: 'POST',
14+
body: JSON.stringify({ repo }),
15+
headers: {
16+
"Authorization": token,
17+
"Content-Type": 'application/json'
18+
},
19+
cache: 'no-store'
20+
})
21+
22+
if (!result.ok) {
23+
throw new Error(await result.text())
24+
}
25+
26+
const json = await result.json()
27+
28+
return NextResponse.json({ result: json }, { status: 200 })
29+
} catch (err) {
30+
console.error(err)
31+
return NextResponse.json((err as Error).message, { status: 400 })
32+
}
33+
}
34+
35+
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
36+
37+
}

app/api/repo/[graph]/info/route.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { NextRequest, NextResponse } from "next/server";
2+
import { getEnvVariables } from "@/app/api/utils";
3+
4+
export async function GET(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
5+
6+
const repo = (await params).graph
7+
8+
try {
9+
10+
const { url, token } = getEnvVariables();
11+
12+
const result = await fetch(`${url}/repo_info`, {
13+
method: 'POST',
14+
body: JSON.stringify({ repo }),
15+
headers: {
16+
"Authorization": token,
17+
"Content-Type": 'application/json'
18+
},
19+
cache: 'no-store'
20+
})
21+
22+
if (!result.ok) {
23+
throw new Error(await result.text())
24+
}
25+
26+
const json = await result.json()
27+
28+
return NextResponse.json({ result: json }, { status: 200 })
29+
} catch (err) {
30+
console.error(err)
31+
return NextResponse.json((err as Error).message, { status: 400 })
32+
}
33+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { NextRequest, NextResponse } from "next/server";
2+
import { getEnvVariables } from "@/app/api/utils";
3+
4+
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
5+
6+
const repo = (await params).graph;
7+
const node_ids = (await request.json()).nodeIds.map((id: string) => Number(id));
8+
9+
try {
10+
11+
const { url, token } = getEnvVariables();
12+
13+
if (node_ids.length === 0) {
14+
throw new Error("nodeIds is required");
15+
}
16+
17+
const result = await fetch(`${url}/get_neighbors`, {
18+
method: 'POST',
19+
body: JSON.stringify({ node_ids, repo }),
20+
headers: {
21+
"Content-Type": 'application/json',
22+
"Authorization": token,
23+
},
24+
cache: 'no-store'
25+
})
26+
27+
const json = await result.json()
28+
29+
return NextResponse.json({ result: json }, { status: 200 })
30+
} catch (err) {
31+
console.error(err)
32+
return NextResponse.json((err as Error).message, { status: 400 })
33+
}
34+
}

0 commit comments

Comments
 (0)