import { AudioPlayer } from "./audio-player" ; import { InteractionModel } from "./interaction-model" ; import { AlexaSession } from "./alexa-session" ; const uuid = require ( "uuid" ) ; /**
 * Manages state of the Alexa device interaction across sessions.
 *
 * Holds information about the user, the current session, as well as the AudioPlayer, if in use.
 *
 * To emulate a user with a linked account, set the access token property.
 */ export class AlexaContext { private _accessToken : string = null ; private _userID : string ; private _session : AlexaSession ; public constructor ( private _skillURL , private _interactionModel , private _audioPlayer , private _applicationID ? ) { } public applicationID ( ) { if ( this . _applicationID === undefined || this . _applicationID === null ) { this . _applicationID = "amzn1.echo-sdk-ams.app." + uuid . v4 ( ) ; } return this . _applicationID ; } public skillURL ( ) { return this . _skillURL ; } public interactionModel ( ) { return this . _interactionModel ; } public userID ( ) { if ( this . _userID === undefined || this . _userID === null ) { this . _userID = "amzn1.ask.account." + uuid . v4 ( ) ; } return this . _userID ; } public setUserID ( userID ) { this . _userID = userID ; } public accessToken ( ) { return this . _accessToken ; } public setAccessToken ( token ) { this . _accessToken = token ; } public audioPlayer ( ) { return this . _audioPlayer ; } public audioPlayerEnabled ( ) { return this . _audioPlayer !== null ; } public newSession ( ) { this . _session = new AlexaSession ( ) ; } public session ( ) { return this . _session ; } public endSession ( ) { this . _session = null ; } public activeSession ( ) { return this . _session !== null ; } }