mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
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 <adamgough@Mac.attlocal.net>
This commit is contained in:
@@ -200,15 +200,14 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
|
||||
params: (params) => {
|
||||
const { credential, folderSelector, manualFolderId, mimeType, ...rest } = params
|
||||
|
||||
// Use folderSelector if provided, otherwise use manualFolderId
|
||||
const effectiveFolderId = (folderSelector || manualFolderId || '').trim()
|
||||
|
||||
return {
|
||||
...rest,
|
||||
accessToken: credential,
|
||||
folderId: effectiveFolderId,
|
||||
// Pass both; tools will prioritize manualFolderId over folderSelector
|
||||
folderSelector,
|
||||
manualFolderId,
|
||||
pageSize: rest.pageSize ? Number.parseInt(rest.pageSize as string, 10) : undefined,
|
||||
mimeType: mimeType,
|
||||
...rest,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -32,20 +32,20 @@ export const createFolderTool: ToolConfig<OneDriveToolParams, OneDriveUploadResp
|
||||
visibility: 'user-only',
|
||||
description: 'Select the parent folder to create the folder in',
|
||||
},
|
||||
folderId: {
|
||||
manualFolderId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'hidden',
|
||||
description: 'ID of the parent folder (internal use)',
|
||||
description: 'Manually entered parent folder ID (advanced mode)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
// Use specific parent folder URL if parentId is provided
|
||||
const parentFolderId = params.folderSelector || params.folderId
|
||||
const parentFolderId = params.manualFolderId || params.folderSelector
|
||||
if (parentFolderId) {
|
||||
return `https://graph.microsoft.com/v1.0/me/drive/items/${parentFolderId}/children`
|
||||
return `https://graph.microsoft.com/v1.0/me/drive/items/${encodeURIComponent(parentFolderId)}/children`
|
||||
}
|
||||
return 'https://graph.microsoft.com/v1.0/me/drive/root/children'
|
||||
},
|
||||
|
||||
@@ -37,11 +37,11 @@ export const listTool: ToolConfig<OneDriveToolParams, OneDriveListResponse> = {
|
||||
visibility: 'user-only',
|
||||
description: 'Select the folder to list files from',
|
||||
},
|
||||
folderId: {
|
||||
manualFolderId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'hidden',
|
||||
description: 'The ID of the folder to list files from (internal use)',
|
||||
description: 'The manually entered folder ID (advanced mode)',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
@@ -60,9 +60,10 @@ export const listTool: ToolConfig<OneDriveToolParams, OneDriveListResponse> = {
|
||||
request: {
|
||||
url: (params) => {
|
||||
// Use specific folder if provided, otherwise use root
|
||||
const folderId = params.folderId || params.folderSelector
|
||||
const baseUrl = folderId
|
||||
? `https://graph.microsoft.com/v1.0/me/drive/items/${folderId}/children`
|
||||
const folderId = params.manualFolderId || params.folderSelector
|
||||
const encodedFolderId = folderId ? encodeURIComponent(folderId) : ''
|
||||
const baseUrl = encodedFolderId
|
||||
? `https://graph.microsoft.com/v1.0/me/drive/items/${encodedFolderId}/children`
|
||||
: 'https://graph.microsoft.com/v1.0/me/drive/root/children'
|
||||
|
||||
const url = new URL(baseUrl)
|
||||
@@ -83,7 +84,6 @@ export const listTool: ToolConfig<OneDriveToolParams, OneDriveListResponse> = {
|
||||
url.searchParams.append('$top', params.pageSize.toString())
|
||||
}
|
||||
|
||||
// Remove the $skip logic entirely. Instead, use the full nextLink URL if provided
|
||||
return url.toString()
|
||||
},
|
||||
method: 'GET',
|
||||
|
||||
@@ -48,8 +48,8 @@ export interface OneDriveUploadResponse extends ToolResponse {
|
||||
|
||||
export interface OneDriveToolParams {
|
||||
accessToken: string
|
||||
folderId?: string
|
||||
folderSelector?: string
|
||||
manualFolderId?: string
|
||||
folderName?: string
|
||||
fileId?: string
|
||||
fileName?: string
|
||||
|
||||
@@ -48,11 +48,11 @@ export const uploadTool: ToolConfig<OneDriveToolParams, OneDriveUploadResponse>
|
||||
visibility: 'user-only',
|
||||
description: 'Select the folder to upload the file to',
|
||||
},
|
||||
folderId: {
|
||||
manualFolderId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'hidden',
|
||||
description: 'The ID of the folder to upload the file to (internal use)',
|
||||
description: 'Manually entered folder ID (advanced mode)',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -67,9 +67,9 @@ export const uploadTool: ToolConfig<OneDriveToolParams, OneDriveUploadResponse>
|
||||
}
|
||||
|
||||
// Build the proper URL based on parent folder
|
||||
const parentFolderId = params.folderSelector || params.folderId
|
||||
const parentFolderId = params.manualFolderId || params.folderSelector
|
||||
if (parentFolderId && parentFolderId.trim() !== '') {
|
||||
return `https://graph.microsoft.com/v1.0/me/drive/items/${parentFolderId}:/${fileName}:/content`
|
||||
return `https://graph.microsoft.com/v1.0/me/drive/items/${encodeURIComponent(parentFolderId)}:/${fileName}:/content`
|
||||
}
|
||||
// Default to root folder
|
||||
return `https://graph.microsoft.com/v1.0/me/drive/root:/${fileName}:/content`
|
||||
|
||||
@@ -67,6 +67,7 @@ export const slackWebhookTrigger: TriggerConfig = {
|
||||
'Go to "Basic Information", find the "Signing Secret", and paste it in the field above.',
|
||||
'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>',
|
||||
'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>',
|
||||
'Go to "Install App" in the left sidebar and install the app into your desired Slack workspace and channel.',
|
||||
'Save changes in both Slack and here.',
|
||||
],
|
||||
|
||||
|
||||
Reference in New Issue
Block a user