Skip to content

Commit 8b78200

Browse files
aadamgoughAdam Gough
andauthored
fix(onedrive): fixed advanced mode (#1122)
* fixed onedrive advanced mode * removed logger * removed loger * added a slack instruction * remove folderId --------- Co-authored-by: Adam Gough <[email protected]>
1 parent c8f4791 commit 8b78200

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

apps/sim/blocks/blocks/onedrive.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,14 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
200200
params: (params) => {
201201
const { credential, folderSelector, manualFolderId, mimeType, ...rest } = params
202202

203-
// Use folderSelector if provided, otherwise use manualFolderId
204-
const effectiveFolderId = (folderSelector || manualFolderId || '').trim()
205-
206203
return {
204+
...rest,
207205
accessToken: credential,
208-
folderId: effectiveFolderId,
206+
// Pass both; tools will prioritize manualFolderId over folderSelector
207+
folderSelector,
208+
manualFolderId,
209209
pageSize: rest.pageSize ? Number.parseInt(rest.pageSize as string, 10) : undefined,
210210
mimeType: mimeType,
211-
...rest,
212211
}
213212
},
214213
},

apps/sim/tools/onedrive/create_folder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ export const createFolderTool: ToolConfig<OneDriveToolParams, OneDriveUploadResp
3232
visibility: 'user-only',
3333
description: 'Select the parent folder to create the folder in',
3434
},
35-
folderId: {
35+
manualFolderId: {
3636
type: 'string',
3737
required: false,
3838
visibility: 'hidden',
39-
description: 'ID of the parent folder (internal use)',
39+
description: 'Manually entered parent folder ID (advanced mode)',
4040
},
4141
},
4242

4343
request: {
4444
url: (params) => {
4545
// Use specific parent folder URL if parentId is provided
46-
const parentFolderId = params.folderSelector || params.folderId
46+
const parentFolderId = params.manualFolderId || params.folderSelector
4747
if (parentFolderId) {
48-
return `https://graph.microsoft.com/v1.0/me/drive/items/${parentFolderId}/children`
48+
return `https://graph.microsoft.com/v1.0/me/drive/items/${encodeURIComponent(parentFolderId)}/children`
4949
}
5050
return 'https://graph.microsoft.com/v1.0/me/drive/root/children'
5151
},

apps/sim/tools/onedrive/list.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export const listTool: ToolConfig<OneDriveToolParams, OneDriveListResponse> = {
3737
visibility: 'user-only',
3838
description: 'Select the folder to list files from',
3939
},
40-
folderId: {
40+
manualFolderId: {
4141
type: 'string',
4242
required: false,
4343
visibility: 'hidden',
44-
description: 'The ID of the folder to list files from (internal use)',
44+
description: 'The manually entered folder ID (advanced mode)',
4545
},
4646
query: {
4747
type: 'string',
@@ -60,9 +60,10 @@ export const listTool: ToolConfig<OneDriveToolParams, OneDriveListResponse> = {
6060
request: {
6161
url: (params) => {
6262
// Use specific folder if provided, otherwise use root
63-
const folderId = params.folderId || params.folderSelector
64-
const baseUrl = folderId
65-
? `https://graph.microsoft.com/v1.0/me/drive/items/${folderId}/children`
63+
const folderId = params.manualFolderId || params.folderSelector
64+
const encodedFolderId = folderId ? encodeURIComponent(folderId) : ''
65+
const baseUrl = encodedFolderId
66+
? `https://graph.microsoft.com/v1.0/me/drive/items/${encodedFolderId}/children`
6667
: 'https://graph.microsoft.com/v1.0/me/drive/root/children'
6768

6869
const url = new URL(baseUrl)
@@ -83,7 +84,6 @@ export const listTool: ToolConfig<OneDriveToolParams, OneDriveListResponse> = {
8384
url.searchParams.append('$top', params.pageSize.toString())
8485
}
8586

86-
// Remove the $skip logic entirely. Instead, use the full nextLink URL if provided
8787
return url.toString()
8888
},
8989
method: 'GET',

apps/sim/tools/onedrive/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export interface OneDriveUploadResponse extends ToolResponse {
4848

4949
export interface OneDriveToolParams {
5050
accessToken: string
51-
folderId?: string
5251
folderSelector?: string
52+
manualFolderId?: string
5353
folderName?: string
5454
fileId?: string
5555
fileName?: string

apps/sim/tools/onedrive/upload.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export const uploadTool: ToolConfig<OneDriveToolParams, OneDriveUploadResponse>
4848
visibility: 'user-only',
4949
description: 'Select the folder to upload the file to',
5050
},
51-
folderId: {
51+
manualFolderId: {
5252
type: 'string',
5353
required: false,
5454
visibility: 'hidden',
55-
description: 'The ID of the folder to upload the file to (internal use)',
55+
description: 'Manually entered folder ID (advanced mode)',
5656
},
5757
},
5858

@@ -67,9 +67,9 @@ export const uploadTool: ToolConfig<OneDriveToolParams, OneDriveUploadResponse>
6767
}
6868

6969
// Build the proper URL based on parent folder
70-
const parentFolderId = params.folderSelector || params.folderId
70+
const parentFolderId = params.manualFolderId || params.folderSelector
7171
if (parentFolderId && parentFolderId.trim() !== '') {
72-
return `https://graph.microsoft.com/v1.0/me/drive/items/${parentFolderId}:/${fileName}:/content`
72+
return `https://graph.microsoft.com/v1.0/me/drive/items/${encodeURIComponent(parentFolderId)}:/${fileName}:/content`
7373
}
7474
// Default to root folder
7575
return `https://graph.microsoft.com/v1.0/me/drive/root:/${fileName}:/content`

apps/sim/triggers/slack/webhook.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const slackWebhookTrigger: TriggerConfig = {
6767
'Go to "Basic Information", find the "Signing Secret", and paste it in the field above.',
6868
'Go to "OAuth & Permissions" and add bot token scopes:<br><ul class="mt-1 ml-5 list-disc"><li><code>app_mentions:read</code> - For viewing messages that tag your bot with an @</li><li><code>chat:write</code> - To send messages to channels your bot is a part of</li></ul>',
6969
'Go to "Event Subscriptions":<br><ul class="mt-1 ml-5 list-disc"><li>Enable events</li><li>Under "Subscribe to Bot Events", add <code>app_mention</code> to listen to messages that mention your bot</li><li>Paste the Webhook URL (from above) into the "Request URL" field</li></ul>',
70+
'Go to "Install App" in the left sidebar and install the app into your desired Slack workspace and channel.',
7071
'Save changes in both Slack and here.',
7172
],
7273

0 commit comments

Comments
 (0)