import type { SerializableRecord } from '@kbn/utility-types' ; import { MigrateFunction } from 'src/plugins/kibana_utils/common' ; import { LocatorDefinition , LocatorPublic } from '../../../src/plugins/share/public' ; export const HELLO_LOCATOR = 'HELLO_LOCATOR' ; export interface HelloLocatorV1Params extends SerializableRecord { name : string ; } export interface HelloLocatorV2Params extends SerializableRecord { firstName : string ; lastName : string ; } export type HelloLocatorParams = HelloLocatorV2Params ; const migrateV1ToV2 = ( v1 ) => { const v2 = { firstName : v1 . name , lastName : '' , } ; return v2 ; } ; export type HelloLocator = LocatorPublic < HelloLocatorParams > ; export class HelloLocatorDefinition implements LocatorDefinition < HelloLocatorParams > { public readonly id = HELLO_LOCATOR ; public readonly getLocation = async ( { firstName , lastName } ) => { return { app : 'locatorExamples' , path : `/hello?firstName=${ encodeURIComponent ( firstName ) }&lastName=${ encodeURIComponent ( lastName ) }` , state : { } , } ; } ; public readonly migrations = { '0.0.2' : migrateV1ToV2 as unknown as MigrateFunction , } ; }