mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
feat(copilot): add rename operation to user_table tool (#3691)
* feat(copilot): add rename operation to user_table tool * fix(copilot): use newName instead of name for table rename operation
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
insertRow,
|
||||
queryRows,
|
||||
renameColumn,
|
||||
renameTable,
|
||||
updateColumnConstraints,
|
||||
updateColumnType,
|
||||
updateRow,
|
||||
@@ -878,6 +879,36 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
|
||||
}
|
||||
}
|
||||
|
||||
case 'rename': {
|
||||
if (!args.tableId) {
|
||||
return { success: false, message: 'Table ID is required' }
|
||||
}
|
||||
const newName = (args as Record<string, unknown>).newName as string | undefined
|
||||
if (!newName) {
|
||||
return { success: false, message: 'newName is required for renaming a table' }
|
||||
}
|
||||
if (!workspaceId) {
|
||||
return { success: false, message: 'Workspace ID is required' }
|
||||
}
|
||||
|
||||
const table = await getTableById(args.tableId)
|
||||
if (!table) {
|
||||
return { success: false, message: `Table not found: ${args.tableId}` }
|
||||
}
|
||||
if (table.workspaceId !== workspaceId) {
|
||||
return { success: false, message: 'Table not found' }
|
||||
}
|
||||
|
||||
const requestId = crypto.randomUUID().slice(0, 8)
|
||||
const renamed = await renameTable(args.tableId, newName, requestId)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `Renamed table to "${renamed.name}"`,
|
||||
data: { table: { id: renamed.id, name: renamed.name } },
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return { success: false, message: `Unknown operation: ${operation}` }
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ export const UserTableArgsSchema = z.object({
|
||||
'rename_column',
|
||||
'delete_column',
|
||||
'update_column',
|
||||
'rename',
|
||||
]),
|
||||
args: z
|
||||
.object({
|
||||
|
||||
Reference in New Issue
Block a user