import { schema } from '@osd/config-schema' ; import { IRouter } from '../../http' ; export const registerUpdateRoute = ( router ) => { router . put ( { path : '/{type}/{id}' , validate : { params : schema . object ( { type : schema . string ( ) , id : schema . string ( ) , } ) , body : schema . object ( { attributes : schema . recordOf ( schema . string ( ) , schema . any ( ) ) , version : schema . maybe ( schema . string ( ) ) , references : schema . maybe ( schema . arrayOf ( schema . object ( { name : schema . string ( ) , type : schema . string ( ) , id : schema . string ( ) , } ) ) ) , } ) , } , } , router . handleLegacyErrors ( async ( context , req , res ) => { const { type , id } = req . params ; const { attributes , version , references } = req . body ; const options = { version , references } ; const result = await context . core . savedObjects . client . update ( type , id , attributes , options ) ; return res . ok ( { body : result } ) ; } ) ) ; } ;