Skip to content

Commit ba6627f

Browse files
committed
fix(onedrive): align tools with live Graph API docs, add missing endpoints
- wire up search/move/copy/create_share_link tools into block operation switch (were registered but unreachable, would throw 'Invalid OneDrive operation') - fix tools.config.params to remap new canonical subBlock ids to correct tool param names - add onedrive_get_item and onedrive_get_drive_info tools (item metadata, drive quota) — both within existing Files.Read/Files.ReadWrite scope - add missing block inputs/outputs for new operations - alphabetize onedrive registry entries
1 parent c34a3bc commit ba6627f

10 files changed

Lines changed: 912 additions & 5 deletions

File tree

apps/sim/blocks/blocks/onedrive.ts

Lines changed: 297 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const logger = createLogger('OneDriveBlock')
1212
export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
1313
type: 'onedrive',
1414
name: 'OneDrive',
15-
description: 'Create, upload, download, list, and delete files',
15+
description: 'Create, upload, download, search, move, copy, share, and delete files',
1616
authMode: AuthMode.OAuth,
1717
longDescription:
18-
'Integrate OneDrive into the workflow. Can create text and Excel files, upload files, download files, list files, and delete files or folders.',
18+
'Integrate OneDrive into the workflow. Can create text and Excel files, upload files, download files, list and search files, move or rename files, copy files, create sharing links, and delete files or folders.',
1919
docsLink: 'https://docs.sim.ai/integrations/onedrive',
2020
category: 'tools',
2121
integrationType: IntegrationType.Documents,
@@ -33,6 +33,12 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
3333
{ label: 'Upload File', id: 'upload' },
3434
{ label: 'Download File', id: 'download' },
3535
{ label: 'List Files', id: 'list' },
36+
{ label: 'Search Files', id: 'search' },
37+
{ label: 'Get Item Info', id: 'get_item' },
38+
{ label: 'Get Drive Info', id: 'get_drive_info' },
39+
{ label: 'Move/Rename File', id: 'move' },
40+
{ label: 'Copy File', id: 'copy' },
41+
{ label: 'Create Sharing Link', id: 'create_share_link' },
3642
{ label: 'Delete File', id: 'delete' },
3743
],
3844
},
@@ -231,14 +237,37 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
231237
title: 'Search Query',
232238
type: 'short-input',
233239
placeholder: 'Search for specific files (e.g., name contains "report")',
234-
condition: { field: 'operation', value: 'list' },
240+
condition: { field: 'operation', value: ['list', 'search'] },
235241
},
236242
{
237243
id: 'pageSize',
238244
title: 'Results Per Page',
239245
type: 'short-input',
240246
placeholder: 'Number of results (default: 100, max: 1000)',
241-
condition: { field: 'operation', value: 'list' },
247+
condition: { field: 'operation', value: ['list', 'search'] },
248+
},
249+
// Get Item Info Fields - File Selector (basic mode)
250+
{
251+
id: 'getItemFileSelector',
252+
title: 'Select File or Folder',
253+
type: 'file-selector',
254+
canonicalParamId: 'getItemFileId',
255+
serviceId: 'onedrive',
256+
selectorKey: 'onedrive.files',
257+
requiredScopes: getScopesForService('onedrive'),
258+
placeholder: 'Select a file or folder (leave empty for the drive root)',
259+
mode: 'basic',
260+
dependsOn: ['credential'],
261+
condition: { field: 'operation', value: 'get_item' },
262+
},
263+
{
264+
id: 'getItemManualFileId',
265+
title: 'File or Folder ID',
266+
type: 'short-input',
267+
canonicalParamId: 'getItemFileId',
268+
placeholder: 'Enter file or folder ID (leave empty for the drive root)',
269+
mode: 'advanced',
270+
condition: { field: 'operation', value: 'get_item' },
242271
},
243272
// Download File Fields - File Selector (basic mode)
244273
{
@@ -274,6 +303,170 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
274303
placeholder: 'Optional: Override the filename',
275304
condition: { field: 'operation', value: 'download' },
276305
},
306+
// Move/Rename File Fields - File Selector (basic mode)
307+
{
308+
id: 'moveFileSelector',
309+
title: 'Select File or Folder to Move',
310+
type: 'file-selector',
311+
canonicalParamId: 'moveFileId',
312+
serviceId: 'onedrive',
313+
selectorKey: 'onedrive.files',
314+
requiredScopes: getScopesForService('onedrive'),
315+
placeholder: 'Select a file or folder to move or rename',
316+
mode: 'basic',
317+
dependsOn: ['credential'],
318+
condition: { field: 'operation', value: 'move' },
319+
required: true,
320+
},
321+
{
322+
id: 'moveManualFileId',
323+
title: 'File or Folder ID',
324+
type: 'short-input',
325+
canonicalParamId: 'moveFileId',
326+
placeholder: 'Enter file or folder ID to move or rename',
327+
mode: 'advanced',
328+
condition: { field: 'operation', value: 'move' },
329+
required: true,
330+
},
331+
{
332+
id: 'moveDestinationFolderSelector',
333+
title: 'Select Destination Folder',
334+
type: 'file-selector',
335+
canonicalParamId: 'moveDestinationFolderId',
336+
serviceId: 'onedrive',
337+
selectorKey: 'onedrive.folders',
338+
requiredScopes: getScopesForService('onedrive'),
339+
mimeType: 'application/vnd.microsoft.graph.folder',
340+
placeholder: 'Select a destination folder (leave empty to only rename)',
341+
dependsOn: ['credential'],
342+
mode: 'basic',
343+
condition: { field: 'operation', value: 'move' },
344+
},
345+
{
346+
id: 'moveDestinationManualFolderId',
347+
title: 'Destination Folder ID',
348+
type: 'short-input',
349+
canonicalParamId: 'moveDestinationFolderId',
350+
placeholder: 'Enter destination folder ID (leave empty to only rename)',
351+
dependsOn: ['credential'],
352+
mode: 'advanced',
353+
condition: { field: 'operation', value: 'move' },
354+
},
355+
{
356+
id: 'newName',
357+
title: 'New Name',
358+
type: 'short-input',
359+
placeholder: 'New name for the file or folder (leave empty to only move)',
360+
condition: { field: 'operation', value: 'move' },
361+
},
362+
// Copy File Fields - File Selector (basic mode)
363+
{
364+
id: 'copyFileSelector',
365+
title: 'Select File or Folder to Copy',
366+
type: 'file-selector',
367+
canonicalParamId: 'copyFileId',
368+
serviceId: 'onedrive',
369+
selectorKey: 'onedrive.files',
370+
requiredScopes: getScopesForService('onedrive'),
371+
placeholder: 'Select a file or folder to copy',
372+
mode: 'basic',
373+
dependsOn: ['credential'],
374+
condition: { field: 'operation', value: 'copy' },
375+
required: true,
376+
},
377+
{
378+
id: 'copyManualFileId',
379+
title: 'File or Folder ID',
380+
type: 'short-input',
381+
canonicalParamId: 'copyFileId',
382+
placeholder: 'Enter file or folder ID to copy',
383+
mode: 'advanced',
384+
condition: { field: 'operation', value: 'copy' },
385+
required: true,
386+
},
387+
{
388+
id: 'copyDestinationFolderSelector',
389+
title: 'Select Destination Folder',
390+
type: 'file-selector',
391+
canonicalParamId: 'copyDestinationFolderId',
392+
serviceId: 'onedrive',
393+
selectorKey: 'onedrive.folders',
394+
requiredScopes: getScopesForService('onedrive'),
395+
mimeType: 'application/vnd.microsoft.graph.folder',
396+
placeholder: 'Select a destination folder',
397+
dependsOn: ['credential'],
398+
mode: 'basic',
399+
condition: { field: 'operation', value: 'copy' },
400+
required: true,
401+
},
402+
{
403+
id: 'copyDestinationManualFolderId',
404+
title: 'Destination Folder ID',
405+
type: 'short-input',
406+
canonicalParamId: 'copyDestinationFolderId',
407+
placeholder: 'Enter destination folder ID',
408+
dependsOn: ['credential'],
409+
mode: 'advanced',
410+
condition: { field: 'operation', value: 'copy' },
411+
required: true,
412+
},
413+
{
414+
id: 'destinationFileName',
415+
title: 'New Name',
416+
type: 'short-input',
417+
placeholder: 'Optional name for the copy (defaults to the original name)',
418+
condition: { field: 'operation', value: 'copy' },
419+
},
420+
// Create Sharing Link Fields - File Selector (basic mode)
421+
{
422+
id: 'shareLinkFileSelector',
423+
title: 'Select File or Folder to Share',
424+
type: 'file-selector',
425+
canonicalParamId: 'shareLinkFileId',
426+
serviceId: 'onedrive',
427+
selectorKey: 'onedrive.files',
428+
requiredScopes: getScopesForService('onedrive'),
429+
placeholder: 'Select a file or folder to share',
430+
mode: 'basic',
431+
dependsOn: ['credential'],
432+
condition: { field: 'operation', value: 'create_share_link' },
433+
required: true,
434+
},
435+
{
436+
id: 'shareLinkManualFileId',
437+
title: 'File or Folder ID',
438+
type: 'short-input',
439+
canonicalParamId: 'shareLinkFileId',
440+
placeholder: 'Enter file or folder ID to share',
441+
mode: 'advanced',
442+
condition: { field: 'operation', value: 'create_share_link' },
443+
required: true,
444+
},
445+
{
446+
id: 'linkType',
447+
title: 'Link Type',
448+
type: 'dropdown',
449+
options: [
450+
{ label: 'View (read-only)', id: 'view' },
451+
{ label: 'Edit (read-write)', id: 'edit' },
452+
{ label: 'Embed', id: 'embed' },
453+
],
454+
placeholder: 'Select link type',
455+
condition: { field: 'operation', value: 'create_share_link' },
456+
required: true,
457+
},
458+
{
459+
id: 'linkScope',
460+
title: 'Link Scope',
461+
type: 'dropdown',
462+
options: [
463+
{ label: 'Anyone with the link', id: 'anonymous' },
464+
{ label: 'People in my organization', id: 'organization' },
465+
{ label: 'Specific people', id: 'users' },
466+
],
467+
placeholder: 'Select who can use the link',
468+
condition: { field: 'operation', value: 'create_share_link' },
469+
},
277470
// Delete File Fields - File Selector (basic mode)
278471
{
279472
id: 'deleteFileSelector',
@@ -308,6 +501,12 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
308501
'onedrive_create_folder',
309502
'onedrive_download',
310503
'onedrive_list',
504+
'onedrive_search',
505+
'onedrive_get_item',
506+
'onedrive_get_drive_info',
507+
'onedrive_move',
508+
'onedrive_copy',
509+
'onedrive_create_share_link',
311510
'onedrive_delete',
312511
],
313512
config: {
@@ -322,6 +521,18 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
322521
return 'onedrive_download'
323522
case 'list':
324523
return 'onedrive_list'
524+
case 'search':
525+
return 'onedrive_search'
526+
case 'get_item':
527+
return 'onedrive_get_item'
528+
case 'get_drive_info':
529+
return 'onedrive_get_drive_info'
530+
case 'move':
531+
return 'onedrive_move'
532+
case 'copy':
533+
return 'onedrive_copy'
534+
case 'create_share_link':
535+
return 'onedrive_create_share_link'
325536
case 'delete':
326537
return 'onedrive_delete'
327538
default:
@@ -335,9 +546,15 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
335546
uploadFolderId,
336547
createFolderParentId,
337548
listFolderId,
549+
moveDestinationFolderId,
550+
copyDestinationFolderId,
338551
// File canonical params (per-operation)
339552
downloadFileId,
340553
deleteFileId,
554+
moveFileId,
555+
copyFileId,
556+
shareLinkFileId,
557+
getItemFileId,
341558
mimeType,
342559
values,
343560
downloadFileName,
@@ -377,6 +594,29 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
377594
case 'delete':
378595
resolvedFileId = deleteFileId?.trim() || undefined
379596
break
597+
case 'move':
598+
resolvedFileId = moveFileId?.trim() || undefined
599+
break
600+
case 'copy':
601+
resolvedFileId = copyFileId?.trim() || undefined
602+
break
603+
case 'create_share_link':
604+
resolvedFileId = shareLinkFileId?.trim() || undefined
605+
break
606+
case 'get_item':
607+
resolvedFileId = getItemFileId?.trim() || undefined
608+
break
609+
}
610+
611+
// Resolve destinationFolderId based on operation
612+
let resolvedDestinationFolderId: string | undefined
613+
switch (params.operation) {
614+
case 'move':
615+
resolvedDestinationFolderId = moveDestinationFolderId?.trim() || undefined
616+
break
617+
case 'copy':
618+
resolvedDestinationFolderId = copyDestinationFolderId?.trim() || undefined
619+
break
380620
}
381621

382622
return {
@@ -386,6 +626,7 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
386626
file: normalizedFile,
387627
folderId: resolvedFolderId,
388628
fileId: resolvedFileId,
629+
destinationFolderId: resolvedDestinationFolderId,
389630
pageSize: rest.pageSize ? Number.parseInt(rest.pageSize as string, 10) : undefined,
390631
mimeType: mimeType,
391632
...(downloadFileName && { fileName: downloadFileName }),
@@ -411,9 +652,29 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
411652
deleteFileId: { type: 'string', description: 'File to delete' },
412653
downloadFileName: { type: 'string', description: 'File name override for download' },
413654
folderName: { type: 'string', description: 'Folder name for create_folder' },
414-
// List operation inputs
655+
// List / Search operation inputs
415656
query: { type: 'string', description: 'Search query' },
416657
pageSize: { type: 'number', description: 'Results per page' },
658+
// Move operation inputs
659+
moveFileId: { type: 'string', description: 'File or folder to move or rename' },
660+
moveDestinationFolderId: { type: 'string', description: 'Destination folder for move' },
661+
newName: { type: 'string', description: 'New name for move/rename' },
662+
// Copy operation inputs
663+
copyFileId: { type: 'string', description: 'File or folder to copy' },
664+
copyDestinationFolderId: { type: 'string', description: 'Destination folder for copy' },
665+
destinationFileName: { type: 'string', description: 'Optional name for the copy' },
666+
// Create sharing link operation inputs
667+
shareLinkFileId: { type: 'string', description: 'File or folder to share' },
668+
linkType: { type: 'string', description: 'Type of sharing link: view, edit, or embed' },
669+
linkScope: {
670+
type: 'string',
671+
description: 'Who can use the link: anonymous, organization, or users',
672+
},
673+
// Get item operation inputs
674+
getItemFileId: {
675+
type: 'string',
676+
description: 'File or folder to retrieve metadata for (empty for drive root)',
677+
},
417678
},
418679
outputs: {
419680
success: { type: 'boolean', description: 'Whether the operation was successful' },
@@ -428,6 +689,37 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
428689
description:
429690
'An array of OneDrive file objects, each containing details such as id, name, size, and more.',
430691
},
692+
nextPageToken: {
693+
type: 'string',
694+
description: 'Token for retrieving the next page of list/search results, if any',
695+
},
696+
sourceFileId: {
697+
type: 'string',
698+
description: 'The ID of the file or folder that was copied',
699+
},
700+
name: {
701+
type: 'string',
702+
description: 'The requested name for the copy, if provided',
703+
},
704+
monitorUrl: {
705+
type: 'string',
706+
description: 'URL to poll for the status of an asynchronous copy operation',
707+
},
708+
link: {
709+
type: 'json',
710+
description: 'The created sharing link, including its type, scope, and URL',
711+
},
712+
driveId: { type: 'string', description: 'The ID of the drive' },
713+
driveType: {
714+
type: 'string',
715+
description: 'The type of drive (e.g., "personal", "business")',
716+
},
717+
webUrl: { type: 'string', description: 'URL to the drive in the browser' },
718+
owner: { type: 'string', description: 'Display name of the drive owner' },
719+
quota: {
720+
type: 'json',
721+
description: 'Drive storage quota information (total, used, remaining, deleted, state)',
722+
},
431723
},
432724
}
433725

0 commit comments

Comments
 (0)