import { IManifestUpdater } from "../../IManifestUpdater" ; import { GeneratorTeamsAppOptions } from "../../../GeneratorTeamsAppOptions" ; export class MessageExtensionManifestUpdater implements IManifestUpdater { public updateManifest ( manifest , options ) { if ( ! manifest . composeExtensions ) { manifest . composeExtensions = [ ] ; } let command = options . messagingExtensionType !== "queryLink" ? { id : options . messageExtensionName , title : options . messageExtensionTitle , description : options . messageExtensionDescription , initialRun : true , parameters : [ { name : 'parameter' , description : 'Description of the parameter' , title : 'Parameter' , } ] , type : options . messagingExtensionType } : undefined ; if ( options . messagingExtensionType === "action" ) { if ( options . messagingExtensionActionContext ) { command . context = options . messagingExtensionActionContext ; } switch ( options . messagingExtensionActionInputType ) { case "static" : command . fetchTask = false ; command . parameters = [ { "name" : "email" , "description" : "Enter an e-mail address" , "title" : "E-mail" } ] ; break ; case "adaptiveCard" : case "taskModule" : command . fetchTask = true ; command . parameters = undefined ; break ; default : throw new Error ( "Invalid Messaging extension input type" ) ; } } if ( options . messagingExtensionType !== "queryLink" ) { let composeExtension = manifest . composeExtensions . find ( ( ce ) => ce . botId == options . messageExtensionId ) ; if ( options . existingManifest && composeExtension ) { if ( options . messagingExtensionCanUpdateConfiguration ) { composeExtension . commands . unshift ( command ) ; composeExtension . canUpdateConfiguration = options . messagingExtensionCanUpdateConfiguration ; } else { composeExtension . commands . push ( command ) ; } } else { manifest . composeExtensions . push ( { botId : options . messageExtensionId , canUpdateConfiguration : options . messagingExtensionCanUpdateConfiguration , commands : [ command ] } ) ; } } else { if ( ! options . existingManifest ) { manifest . composeExtensions . push ( { botId : options . messageExtensionId , canUpdateConfiguration : options . messagingExtensionCanUpdateConfiguration , commands : [ ] , messageHandlers : [ { type : "link" , value : { domains : options . messageExtensionLinkDomains } } ] } ) ; } } } }