UNPKG

microsoft-cognitiveservices-speech-sdk

Version:
1 lines 9.31 kB
{"version":3,"sources":["src/sdk/BotFrameworkConfig.ts"],"names":[],"mappings":"AAIA,OAAO,EAAuB,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAGxF;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,uBAAuB;IAE3D;;OAEG;;IAKH;;;;;;;;;;OAUG;WACW,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,kBAAkB;IAkBxG;;;;;;;;;;;;;;;;;OAiBG;WACW,sBAAsB,CAChC,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAC3D,kBAAkB;IAkBrB;;;;;;;;;;;;;;;;;;;OAmBG;WACW,QAAQ,CAClB,IAAI,EAAE,GAAG,GAAG,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,EACxB,KAAK,CAAC,EAAE,MAAM,GAAG,kBAAkB;IAoBvC;;;;;;;;;;;;;;;OAeG;WACW,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,kBAAkB;CAe1F","file":"BotFrameworkConfig.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport { DialogServiceConfig, DialogServiceConfigImpl } from \"./DialogServiceConfig.js\";\r\nimport { PropertyId } from \"./Exports.js\";\r\n\r\n/**\r\n * Class that defines configurations for the dialog service connector object for using a Bot Framework backend.\r\n * @class BotFrameworkConfig\r\n */\r\nexport class BotFrameworkConfig extends DialogServiceConfigImpl {\r\n\r\n /**\r\n * Creates an instance of BotFrameworkConfig.\r\n */\r\n public constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Creates a bot framework configuration instance with the provided subscription information.\r\n * @member BotFrameworkConfig.fromSubscription\r\n * @function\r\n * @public\r\n * @param subscription Subscription key associated with the bot\r\n * @param region The region name (see the <a href=\"https://aka.ms/csspeech/region\">region page</a>).\r\n * @param botId Optional. Identifier for using a specific bot within an Azure resource group. Equivalent to the\r\n * resource name.\r\n * @returns {BotFrameworkConfig} A new bot framework configuration instance.\r\n */\r\n public static fromSubscription(subscription: string, region: string, botId?: string): BotFrameworkConfig {\r\n Contracts.throwIfNullOrWhitespace(subscription, \"subscription\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const botFrameworkConfig: BotFrameworkConfig = new DialogServiceConfigImpl();\r\n botFrameworkConfig.setProperty(\r\n PropertyId.Conversation_DialogType,\r\n DialogServiceConfig.DialogTypes.BotFramework);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Key, subscription);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Region, region);\r\n\r\n if (botId) {\r\n botFrameworkConfig.setProperty(PropertyId.Conversation_ApplicationId, botId);\r\n }\r\n\r\n return botFrameworkConfig;\r\n }\r\n\r\n /**\r\n * Creates a bot framework configuration instance for the specified authorization token and region.\r\n * Note: The caller must ensure that an authorization token is valid. Before an authorization token expires, the\r\n * caller must refresh it by setting the authorizationToken property on the corresponding\r\n * DialogServiceConnector instance created with this config. The contents of configuration objects are copied\r\n * when connectors are created, so setting authorizationToken on a DialogServiceConnector will not update the\r\n * original configuration's authorization token. Create a new configuration instance or set the\r\n * SpeechServiceAuthorization_Token property to update an existing instance if it will be used to create\r\n * further DialogServiceConnectors.\r\n * @member BotFrameworkConfig.fromAuthorizationToken\r\n * @function\r\n * @public\r\n * @param authorizationToken The authorization token associated with the bot\r\n * @param region The region name (see the <a href=\"https://aka.ms/csspeech/region\">region page</a>).\r\n * @param botId Optional. Identifier for using a specific bot within an Azure resource group. Equivalent to the\r\n * resource name.\r\n * @returns {BotFrameworkConfig} A new bot framework configuration instance.\r\n */\r\n public static fromAuthorizationToken(\r\n authorizationToken: string, region: string, botId?: string\r\n ): BotFrameworkConfig {\r\n Contracts.throwIfNullOrWhitespace(authorizationToken, \"authorizationToken\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const botFrameworkConfig: BotFrameworkConfig = new DialogServiceConfigImpl();\r\n botFrameworkConfig.setProperty(\r\n PropertyId.Conversation_DialogType,\r\n DialogServiceConfig.DialogTypes.BotFramework);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceAuthorization_Token, authorizationToken);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Region, region);\r\n\r\n if (botId) {\r\n botFrameworkConfig.setProperty(PropertyId.Conversation_ApplicationId, botId);\r\n }\r\n\r\n return botFrameworkConfig;\r\n }\r\n\r\n /**\r\n * Creates an instance of a BotFrameworkConfig.\r\n * This method is intended only for users who use a non-default service host. The standard resource path will be\r\n * assumed. For services with a non-standard resource path or no path at all, use fromEndpoint instead.\r\n * Note: Query parameters are not allowed in the host URI and must be set by other APIs.\r\n * Note: To use an authorization token with fromHost, use fromHost(URL) and then set the AuthorizationToken\r\n * property on the created BotFrameworkConfig instance.\r\n * Note: Added in version 1.15.0.\r\n * @member BotFrameworkConfig.fromHost\r\n * @function\r\n * @public\r\n * @param {URL | string} host - If a URL is provided, the fully-qualified host with protocol (e.g.\r\n * wss://your.host.com:1234) will be used. If a string is provided, it will be embedded in\r\n * wss://{host}.convai.speech.azure.us.\r\n * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization\r\n * token must be set.\r\n * @param botId Optional. Identifier for using a specific bot within an Azure resource group. Equivalent to the\r\n * resource name.\r\n * @returns {BotFrameworkConfig} A new bot framework configuration instance.\r\n */\r\n public static fromHost(\r\n host: URL | string,\r\n subscriptionKey?: string,\r\n botId?: string): BotFrameworkConfig {\r\n\r\n void botId;\r\n Contracts.throwIfNullOrUndefined(host, \"host\");\r\n const resolvedHost: URL = host instanceof URL ? host : new URL(`wss://${host}.convai.speech.azure.us`);\r\n Contracts.throwIfNullOrUndefined(resolvedHost, \"resolvedHost\");\r\n\r\n const botFrameworkConfig: BotFrameworkConfig = new DialogServiceConfigImpl();\r\n botFrameworkConfig.setProperty(\r\n PropertyId.Conversation_DialogType,\r\n DialogServiceConfig.DialogTypes.BotFramework);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Host, resolvedHost.toString());\r\n\r\n if (undefined !== subscriptionKey) {\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Key, subscriptionKey);\r\n }\r\n\r\n return botFrameworkConfig;\r\n }\r\n\r\n /**\r\n * Creates an instance of a BotFrameworkConfig.\r\n * This method is intended only for users who use a non-standard service endpoint or parameters.\r\n * Note: The query parameters specified in the endpoint URL are not changed, even if they are set by any other APIs.\r\n * Note: To use authorization token with fromEndpoint, pass an empty string to the subscriptionKey in the\r\n * fromEndpoint method, and then set authorizationToken=\"token\" on the created BotFrameworkConfig instance to\r\n * use the authorization token.\r\n * Note: Added in version 1.15.0.\r\n * @member BotFrameworkConfig.fromEndpoint\r\n * @function\r\n * @public\r\n * @param {URL} endpoint - The service endpoint to connect to.\r\n * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization\r\n * token must be set.\r\n * @returns {BotFrameworkConfig} - A new bot framework configuration instance using the provided endpoint.\r\n */\r\n public static fromEndpoint(endpoint: URL, subscriptionKey?: string): BotFrameworkConfig {\r\n Contracts.throwIfNull(endpoint, \"endpoint\");\r\n\r\n const botFrameworkConfig: BotFrameworkConfig = new DialogServiceConfigImpl();\r\n botFrameworkConfig.setProperty(\r\n PropertyId.Conversation_DialogType,\r\n DialogServiceConfig.DialogTypes.BotFramework);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Endpoint, endpoint.toString());\r\n\r\n if (undefined !== subscriptionKey) {\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Key, subscriptionKey);\r\n }\r\n\r\n return botFrameworkConfig;\r\n }\r\n}\r\n"]}