import { IScopedClusterClient } from 'src/core/server' ; import { LicensingPluginStart } from '../../../licensing/server' ; export async function canStartTrial ( client ) { try { const { body : response } = await client . asCurrentUser . license . getTrialStatus ( ) ; return response . eligible_to_start_trial ; } catch ( error ) { return error . body ; } } interface StartTrialArg { client : IScopedClusterClient ; licensing : LicensingPluginStart ; } export async function startTrial ( { client , licensing } ) { try { const { body : response } = await client . asCurrentUser . license . postStartTrial ( { acknowledge : true , } ) ; const { trial_was_started : trialWasStarted } = response ; if ( trialWasStarted ) { await licensing . refresh ( ) ; } return response ; } catch ( error ) { return error . body ; } }