Skip to content

Commit 942da88

Browse files
authored
fix(notion): remove hyphenation of incoming page ID's (#2507)
1 parent 2146326 commit 942da88

File tree

10 files changed

+9
-202
lines changed

10 files changed

+9
-202
lines changed

apps/sim/blocks/blocks/notion.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export const NotionBlock: BlockConfig<NotionResponse> = {
3535
title: 'Notion Account',
3636
type: 'oauth-input',
3737
serviceId: 'notion',
38-
requiredScopes: ['workspace.content', 'workspace.name', 'page.read', 'page.write'],
3938
placeholder: 'Select Notion account',
4039
required: true,
4140
},

apps/sim/lib/auth/auth.ts

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ export const auth = betterAuth({
212212
'github',
213213
'email-password',
214214
'confluence',
215-
// 'supabase',
216215
'x',
217216
'notion',
218217
'microsoft',
@@ -950,56 +949,6 @@ export const auth = betterAuth({
950949
},
951950
},
952951

953-
// Supabase provider (unused)
954-
// {
955-
// providerId: 'supabase',
956-
// clientId: env.SUPABASE_CLIENT_ID as string,
957-
// clientSecret: env.SUPABASE_CLIENT_SECRET as string,
958-
// authorizationUrl: 'https://api.supabase.com/v1/oauth/authorize',
959-
// tokenUrl: 'https://api.supabase.com/v1/oauth/token',
960-
// userInfoUrl: 'https://dummy-not-used.supabase.co',
961-
// scopes: ['database.read', 'database.write', 'projects.read'],
962-
// responseType: 'code',
963-
// pkce: true,
964-
// redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/supabase`,
965-
// getUserInfo: async (tokens) => {
966-
// try {
967-
// logger.info('Creating Supabase user profile from token data')
968-
969-
// let userId = 'supabase-user'
970-
// if (tokens.idToken) {
971-
// try {
972-
// const decodedToken = JSON.parse(
973-
// Buffer.from(tokens.idToken.split('.')[1], 'base64').toString()
974-
// )
975-
// if (decodedToken.sub) {
976-
// userId = decodedToken.sub
977-
// }
978-
// } catch (e) {
979-
// logger.warn('Failed to decode Supabase ID token', {
980-
// error: e,
981-
// })
982-
// }
983-
// }
984-
985-
// const uniqueId = `${userId}-${Date.now()}`
986-
// const now = new Date()
987-
988-
// return {
989-
// id: uniqueId,
990-
// name: 'Supabase User',
991-
// email: `${uniqueId.replace(/[^a-zA-Z0-9]/g, '')}@supabase.user`,
992-
// emailVerified: false,
993-
// createdAt: now,
994-
// updatedAt: now,
995-
// }
996-
// } catch (error) {
997-
// logger.error('Error creating Supabase user profile:', { error })
998-
// return null
999-
// }
1000-
// },
1001-
// },
1002-
1003952
// X provider
1004953
{
1005954
providerId: 'x',
@@ -1133,57 +1082,6 @@ export const auth = betterAuth({
11331082
},
11341083
},
11351084

1136-
// Discord provider (unused)
1137-
// {
1138-
// providerId: 'discord',
1139-
// clientId: env.DISCORD_CLIENT_ID as string,
1140-
// clientSecret: env.DISCORD_CLIENT_SECRET as string,
1141-
// authorizationUrl: 'https://discord.com/api/oauth2/authorize',
1142-
// tokenUrl: 'https://discord.com/api/oauth2/token',
1143-
// userInfoUrl: 'https://discord.com/api/users/@me',
1144-
// scopes: ['identify', 'bot', 'messages.read', 'guilds', 'guilds.members.read'],
1145-
// responseType: 'code',
1146-
// accessType: 'offline',
1147-
// authentication: 'basic',
1148-
// prompt: 'consent',
1149-
// redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/discord`,
1150-
// getUserInfo: async (tokens) => {
1151-
// try {
1152-
// const response = await fetch('https://discord.com/api/users/@me', {
1153-
// headers: {
1154-
// Authorization: `Bearer ${tokens.accessToken}`,
1155-
// },
1156-
// })
1157-
1158-
// if (!response.ok) {
1159-
// logger.error('Error fetching Discord user info:', {
1160-
// status: response.status,
1161-
// statusText: response.statusText,
1162-
// })
1163-
// return null
1164-
// }
1165-
1166-
// const profile = await response.json()
1167-
// const now = new Date()
1168-
1169-
// return {
1170-
// id: profile.id,
1171-
// name: profile.username || 'Discord User',
1172-
// email: profile.email || `${profile.id}@discord.user`,
1173-
// image: profile.avatar
1174-
// ? `https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.png`
1175-
// : undefined,
1176-
// emailVerified: profile.verified || false,
1177-
// createdAt: now,
1178-
// updatedAt: now,
1179-
// }
1180-
// } catch (error) {
1181-
// logger.error('Error in Discord getUserInfo:', { error })
1182-
// return null
1183-
// }
1184-
// },
1185-
// },
1186-
11871085
// Jira provider
11881086
{
11891087
providerId: 'jira',
@@ -1323,7 +1221,6 @@ export const auth = betterAuth({
13231221
authorizationUrl: 'https://api.notion.com/v1/oauth/authorize',
13241222
tokenUrl: 'https://api.notion.com/v1/oauth/token',
13251223
userInfoUrl: 'https://api.notion.com/v1/users/me',
1326-
scopes: ['workspace.content', 'workspace.name', 'page.read', 'page.write'],
13271224
responseType: 'code',
13281225
pkce: false,
13291226
accessType: 'offline',

apps/sim/lib/oauth/oauth.ts

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
AirtableIcon,
44
AsanaIcon,
55
ConfluenceIcon,
6-
// DiscordIcon,
76
DropboxIcon,
87
GithubIcon,
98
GmailIcon,
@@ -32,7 +31,6 @@ import {
3231
ShopifyIcon,
3332
SlackIcon,
3433
SpotifyIcon,
35-
// SupabaseIcon,
3634
TrelloIcon,
3735
WealthboxIcon,
3836
WebflowIcon,
@@ -49,12 +47,10 @@ export type OAuthProvider =
4947
| 'google'
5048
| 'github'
5149
| 'x'
52-
// | 'supabase'
5350
| 'confluence'
5451
| 'airtable'
5552
| 'notion'
5653
| 'jira'
57-
// | 'discord'
5854
| 'dropbox'
5955
| 'microsoft'
6056
| 'linear'
@@ -86,12 +82,10 @@ export type OAuthService =
8682
| 'google-groups'
8783
| 'github'
8884
| 'x'
89-
// | 'supabase'
9085
| 'confluence'
9186
| 'airtable'
9287
| 'notion'
9388
| 'jira'
94-
// | 'discord'
9589
| 'dropbox'
9690
| 'microsoft-excel'
9791
| 'microsoft-teams'
@@ -388,23 +382,6 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig> = {
388382
},
389383
defaultService: 'x',
390384
},
391-
// supabase: {
392-
// id: 'supabase',
393-
// name: 'Supabase',
394-
// icon: (props) => SupabaseIcon(props),
395-
// services: {
396-
// supabase: {
397-
// id: 'supabase',
398-
// name: 'Supabase',
399-
// description: 'Connect to your Supabase projects and manage data.',
400-
// providerId: 'supabase',
401-
// icon: (props) => SupabaseIcon(props),
402-
// baseProviderIcon: (props) => SupabaseIcon(props),
403-
// scopes: ['database.read', 'database.write', 'projects.read'],
404-
// },
405-
// },
406-
// defaultService: 'supabase',
407-
// },
408385
confluence: {
409386
id: 'confluence',
410387
name: 'Confluence',
@@ -518,23 +495,6 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig> = {
518495
},
519496
defaultService: 'airtable',
520497
},
521-
// discord: {
522-
// id: 'discord',
523-
// name: 'Discord',
524-
// icon: (props) => DiscordIcon(props),
525-
// services: {
526-
// discord: {
527-
// id: 'discord',
528-
// name: 'Discord',
529-
// description: 'Read and send messages to Discord channels and interact with servers.',
530-
// providerId: 'discord',
531-
// icon: (props) => DiscordIcon(props),
532-
// baseProviderIcon: (props) => DiscordIcon(props),
533-
// scopes: ['identify', 'bot', 'messages.read', 'guilds', 'guilds.members.read'],
534-
// },
535-
// },
536-
// defaultService: 'discord',
537-
// },
538498
notion: {
539499
id: 'notion',
540500
name: 'Notion',
@@ -547,7 +507,7 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig> = {
547507
providerId: 'notion',
548508
icon: (props) => NotionIcon(props),
549509
baseProviderIcon: (props) => NotionIcon(props),
550-
scopes: ['workspace.content', 'workspace.name', 'page.read', 'page.write'],
510+
scopes: [],
551511
},
552512
},
553513
defaultService: 'notion',
@@ -1272,18 +1232,6 @@ function getProviderAuthConfig(provider: string): ProviderAuthConfig {
12721232
useBasicAuth: false,
12731233
}
12741234
}
1275-
// case 'discord': {
1276-
// const { clientId, clientSecret } = getCredentials(
1277-
// env.DISCORD_CLIENT_ID,
1278-
// env.DISCORD_CLIENT_SECRET
1279-
// )
1280-
// return {
1281-
// tokenEndpoint: 'https://discord.com/api/v10/oauth2/token',
1282-
// clientId,
1283-
// clientSecret,
1284-
// useBasicAuth: true,
1285-
// }
1286-
// }
12871235
case 'microsoft': {
12881236
const { clientId, clientSecret } = getCredentials(
12891237
env.MICROSOFT_CLIENT_ID,

apps/sim/tools/notion/create_database.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,10 @@ export const notionCreateDatabaseTool: ToolConfig<NotionCreateDatabaseParams, No
7575
}
7676
}
7777

78-
// Format parent ID
79-
const formattedParentId = params.parentId.replace(
80-
/(.{8})(.{4})(.{4})(.{4})(.{12})/,
81-
'$1-$2-$3-$4-$5'
82-
)
83-
8478
const body = {
8579
parent: {
8680
type: 'page_id',
87-
page_id: formattedParentId,
81+
page_id: params.parentId,
8882
},
8983
title: [
9084
{

apps/sim/tools/notion/create_page.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,13 @@ export const notionCreatePageTool: ToolConfig<NotionCreatePageParams, NotionResp
5454
}
5555
},
5656
body: (params: NotionCreatePageParams) => {
57-
// Format parent ID with hyphens if needed
58-
const formattedParentId = params.parentId.replace(
59-
/(.{8})(.{4})(.{4})(.{4})(.{12})/,
60-
'$1-$2-$3-$4-$5'
61-
)
62-
63-
// Prepare the body for page parent
6457
const body: any = {
6558
parent: {
6659
type: 'page_id',
67-
page_id: formattedParentId,
60+
page_id: params.parentId,
6861
},
6962
}
7063

71-
// Add title if provided
7264
if (params.title) {
7365
body.properties = {
7466
title: {
@@ -87,7 +79,6 @@ export const notionCreatePageTool: ToolConfig<NotionCreatePageParams, NotionResp
8779
body.properties = {}
8880
}
8981

90-
// Add content if provided
9182
if (params.content) {
9283
body.children = [
9384
{
@@ -115,7 +106,6 @@ export const notionCreatePageTool: ToolConfig<NotionCreatePageParams, NotionResp
115106
const data = await response.json()
116107
let pageTitle = 'Untitled'
117108

118-
// Try to extract the title from properties
119109
if (data.properties?.title) {
120110
const titleProperty = data.properties.title
121111
if (

apps/sim/tools/notion/query_database.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ export const notionQueryDatabaseTool: ToolConfig<NotionQueryDatabaseParams, Noti
4848

4949
request: {
5050
url: (params: NotionQueryDatabaseParams) => {
51-
const formattedId = params.databaseId.replace(
52-
/(.{8})(.{4})(.{4})(.{4})(.{12})/,
53-
'$1-$2-$3-$4-$5'
54-
)
55-
return `https://api.notion.com/v1/databases/${formattedId}/query`
51+
return `https://api.notion.com/v1/databases/${params.databaseId}/query`
5652
},
5753
method: 'POST',
5854
headers: (params: NotionQueryDatabaseParams) => {

apps/sim/tools/notion/read.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ export const notionReadTool: ToolConfig<NotionReadParams, NotionResponse> = {
2929

3030
request: {
3131
url: (params: NotionReadParams) => {
32-
// Format page ID with hyphens if needed
33-
const formattedId = params.pageId.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, '$1-$2-$3-$4-$5')
34-
35-
// Use the page endpoint to get page properties
36-
return `https://api.notion.com/v1/pages/${formattedId}`
32+
return `https://api.notion.com/v1/pages/${params.pageId}`
3733
},
3834
method: 'GET',
3935
headers: (params: NotionReadParams) => {
@@ -85,12 +81,9 @@ export const notionReadTool: ToolConfig<NotionReadParams, NotionResponse> = {
8581
}
8682
}
8783

88-
// Format page ID for blocks endpoint
89-
const formattedId = pageId.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, '$1-$2-$3-$4-$5')
90-
9184
// Fetch page content using blocks endpoint
9285
const blocksResponse = await fetch(
93-
`https://api.notion.com/v1/blocks/${formattedId}/children?page_size=100`,
86+
`https://api.notion.com/v1/blocks/${pageId}/children?page_size=100`,
9487
{
9588
method: 'GET',
9689
headers: {

apps/sim/tools/notion/read_database.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@ export const notionReadDatabaseTool: ToolConfig<NotionReadDatabaseParams, Notion
3434

3535
request: {
3636
url: (params: NotionReadDatabaseParams) => {
37-
// Format database ID with hyphens if needed
38-
const formattedId = params.databaseId.replace(
39-
/(.{8})(.{4})(.{4})(.{4})(.{12})/,
40-
'$1-$2-$3-$4-$5'
41-
)
42-
43-
return `https://api.notion.com/v1/databases/${formattedId}`
37+
return `https://api.notion.com/v1/databases/${params.databaseId}`
4438
},
4539
method: 'GET',
4640
headers: (params: NotionReadDatabaseParams) => {

apps/sim/tools/notion/update_page.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ export const notionUpdatePageTool: ToolConfig<NotionUpdatePageParams, NotionResp
3535

3636
request: {
3737
url: (params: NotionUpdatePageParams) => {
38-
// Format page ID with hyphens if needed
39-
const formattedId = params.pageId.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, '$1-$2-$3-$4-$5')
40-
return `https://api.notion.com/v1/pages/${formattedId}`
38+
return `https://api.notion.com/v1/pages/${params.pageId}`
4139
},
4240
method: 'PATCH',
4341
headers: (params: NotionUpdatePageParams) => {

apps/sim/tools/notion/write.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ export const notionWriteTool: ToolConfig<NotionWriteParams, NotionResponse> = {
3535

3636
request: {
3737
url: (params: NotionWriteParams) => {
38-
// Format page ID with hyphens if needed
39-
const formattedId = params.pageId.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, '$1-$2-$3-$4-$5')
40-
return `https://api.notion.com/v1/blocks/${formattedId}/children`
38+
return `https://api.notion.com/v1/blocks/${params.pageId}/children`
4139
},
4240
method: 'PATCH',
4341
headers: (params: NotionWriteParams) => {

0 commit comments

Comments
 (0)