@@ -3,6 +3,7 @@ import { createLogger } from '@/lib/logs/console/logger'
33import type { BlockConfig } from '@/blocks/types'
44import { AuthMode } from '@/blocks/types'
55import type { OneDriveResponse } from '@/tools/onedrive/types'
6+ import { normalizeExcelValuesForToolParams } from '@/tools/onedrive/utils'
67
78const logger = createLogger ( 'OneDriveBlock' )
89
@@ -78,9 +79,10 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
7879 {
7980 id : 'values' ,
8081 title : 'Values' ,
81- type : 'long-input' ,
82- placeholder :
83- 'Enter values as JSON array of arrays (e.g., [["A1","B1"],["A2","B2"]]) or an array of objects' ,
82+ type : 'code' ,
83+ language : 'json' ,
84+ generationType : 'json-object' ,
85+ placeholder : 'Enter a JSON array of rows (e.g., [["A1","B1"],["A2","B2"]])' ,
8486 condition : {
8587 field : 'operation' ,
8688 value : 'create_file' ,
@@ -89,6 +91,13 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
8991 value : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ,
9092 } ,
9193 } ,
94+ wandConfig : {
95+ enabled : true ,
96+ prompt :
97+ 'Generate a JSON array of arrays that can be written directly into an Excel worksheet.' ,
98+ placeholder : 'Describe the table you want to generate...' ,
99+ generationType : 'json-object' ,
100+ } ,
92101 required : false ,
93102 } ,
94103 // File upload (basic mode)
@@ -351,17 +360,15 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
351360 params : ( params ) => {
352361 const { credential, folderId, fileId, mimeType, values, downloadFileName, ...rest } = params
353362
354- let parsedValues
355- try {
356- parsedValues = values ? JSON . parse ( values as string ) : undefined
357- } catch ( error ) {
358- throw new Error ( 'Invalid JSON format for values' )
363+ let normalizedValues : ReturnType < typeof normalizeExcelValuesForToolParams >
364+ if ( values !== undefined ) {
365+ normalizedValues = normalizeExcelValuesForToolParams ( values )
359366 }
360367
361368 return {
362369 credential,
363370 ...rest ,
364- values : parsedValues ,
371+ values : normalizedValues ,
365372 folderId : folderId || undefined ,
366373 fileId : fileId || undefined ,
367374 pageSize : rest . pageSize ? Number . parseInt ( rest . pageSize as string , 10 ) : undefined ,
@@ -380,7 +387,7 @@ export const OneDriveBlock: BlockConfig<OneDriveResponse> = {
380387 fileReference : { type : 'json' , description : 'File reference from previous block' } ,
381388 content : { type : 'string' , description : 'Text content to upload' } ,
382389 mimeType : { type : 'string' , description : 'MIME type of file to create' } ,
383- values : { type : 'string ' , description : 'Cell values for new Excel as JSON' } ,
390+ values : { type : 'json ' , description : 'Cell values for new Excel as JSON' } ,
384391 fileId : { type : 'string' , description : 'File ID to download' } ,
385392 downloadFileName : { type : 'string' , description : 'File name override for download' } ,
386393 folderId : { type : 'string' , description : 'Folder ID' } ,
0 commit comments