Skip to content

Commit 34b2e43

Browse files
committed
improvement(tools): added file selector for confluence, wip. removed unneccessary restricted google scopes
1 parent d5e1560 commit 34b2e43

File tree

18 files changed

+1059
-27
lines changed

18 files changed

+1059
-27
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { NextResponse } from 'next/server'
2+
3+
export async function POST(request: Request) {
4+
try {
5+
const { domain, accessToken, title, limit = 50 } = await request.json()
6+
7+
if (!domain) {
8+
return NextResponse.json({ error: 'Domain is required' }, { status: 400 })
9+
}
10+
11+
if (!accessToken) {
12+
return NextResponse.json({ error: 'Access token is required' }, { status: 400 })
13+
}
14+
15+
// Build the URL with query parameters
16+
const baseUrl = `https://${domain}/wiki/api/v2/pages`
17+
const queryParams = new URLSearchParams()
18+
19+
if (limit) {
20+
queryParams.append('limit', limit.toString())
21+
}
22+
23+
if (title) {
24+
queryParams.append('title', title)
25+
}
26+
27+
const queryString = queryParams.toString()
28+
const url = queryString ? `${baseUrl}?${queryString}` : baseUrl
29+
30+
console.log(`Fetching Confluence pages from: ${url}`)
31+
32+
// Make the request to Confluence API
33+
const response = await fetch(url, {
34+
method: 'GET',
35+
headers: {
36+
'Content-Type': 'application/json',
37+
Authorization: `Bearer ${accessToken}`,
38+
},
39+
})
40+
41+
if (!response.ok) {
42+
console.error(`Confluence API error: ${response.status} ${response.statusText}`)
43+
let errorMessage
44+
45+
try {
46+
const errorData = await response.json()
47+
errorMessage = errorData.message || `Failed to fetch Confluence pages (${response.status})`
48+
console.error('Error details:', errorData)
49+
} catch (e) {
50+
errorMessage = `Failed to fetch Confluence pages: ${response.status} ${response.statusText}`
51+
}
52+
53+
return NextResponse.json({ error: errorMessage }, { status: response.status })
54+
}
55+
56+
const data = await response.json()
57+
console.log('Confluence API response:', JSON.stringify(data, null, 2).substring(0, 300) + '...')
58+
console.log(`Found ${data.results?.length || 0} pages`)
59+
60+
if (data.results && data.results.length > 0) {
61+
console.log('First few pages:')
62+
data.results.slice(0, 3).forEach((page: any) => {
63+
console.log(`- ${page.id}: ${page.title}`)
64+
})
65+
}
66+
67+
return NextResponse.json({
68+
files: data.results.map((page: any) => ({
69+
id: page.id,
70+
name: page.title,
71+
mimeType: 'confluence/page',
72+
url: page._links?.webui || '',
73+
modifiedTime: page.version?.createdAt || '',
74+
spaceId: page.spaceId,
75+
webViewLink: page._links?.webui || '',
76+
})),
77+
})
78+
} catch (error) {
79+
console.error('Error fetching Confluence pages:', error)
80+
return NextResponse.json(
81+
{ error: (error as Error).message || 'Internal server error' },
82+
{ status: 500 }
83+
)
84+
}
85+
}

sim/app/w/[id]/components/workflow-block/components/sub-block/components/credential-selector/components/oauth-required-modal.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ export interface OAuthRequiredModalProps {
3636
const SCOPE_DESCRIPTIONS: Record<string, string> = {
3737
'https://www.googleapis.com/auth/gmail.send': 'Send emails on your behalf',
3838
// 'https://www.googleapis.com/auth/gmail.readonly': 'View and read your email messages',
39-
'https://www.googleapis.com/auth/drive': 'View and manage your Google Drive files',
39+
// 'https://www.googleapis.com/auth/drive': 'View and manage your Google Drive files',
4040
'https://www.googleapis.com/auth/drive.file': 'View and manage your Google Drive files',
41-
'https://www.googleapis.com/auth/documents': 'View and manage your Google Docs',
41+
// 'https://www.googleapis.com/auth/documents': 'View and manage your Google Docs',
4242
'https://www.googleapis.com/auth/calendar': 'View and manage your calendar',
4343
'https://www.googleapis.com/auth/userinfo.email': 'View your email address',
4444
'https://www.googleapis.com/auth/userinfo.profile': 'View your basic profile info',
4545
'https://www.googleapis.com/auth/spreadsheets': 'View and manage your Google Sheets',
4646
'read:confluence-content.all': 'Read Confluence content',
47+
'read:page:confluence': 'Read Confluence pages',
48+
'write:confluence-content': 'Write Confluence content',
49+
'read:me': 'Read your profile information',
50+
offline_access: 'Access your account when you are not using the application',
4751
repo: 'Access your repositories',
4852
workflow: 'Manage repository workflows',
4953
'user:email': 'Access your email address',

0 commit comments

Comments
 (0)