623861bb7c95576196a122816fac07395c3b253d350e70256c5f0b090d8266a4.json 13 KB

1
  1. {"ast":null,"code":"\"use strict\";\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.DialogConnectionFactory = void 0;\n/* eslint-disable max-classes-per-file */\nconst Exports_js_1 = require(\"../common.browser/Exports.js\");\nconst Exports_js_2 = require(\"../common.speech/Exports.js\");\nconst Exports_js_3 = require(\"../sdk/Exports.js\");\nconst ConnectionFactoryBase_js_1 = require(\"./ConnectionFactoryBase.js\");\nconst Exports_js_4 = require(\"./Exports.js\");\nconst HeaderNames_js_1 = require(\"./HeaderNames.js\");\nconst QueryParameterNames_js_1 = require(\"./QueryParameterNames.js\");\nclass DialogConnectionFactory extends ConnectionFactoryBase_js_1.ConnectionFactoryBase {\n create(config, authInfo, connectionId) {\n const applicationId = config.parameters.getProperty(Exports_js_3.PropertyId.Conversation_ApplicationId, \"\");\n const dialogType = config.parameters.getProperty(Exports_js_3.PropertyId.Conversation_DialogType);\n const region = config.parameters.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_Region);\n const language = config.parameters.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_RecoLanguage, \"en-US\");\n const requestTurnStatus = config.parameters.getProperty(Exports_js_3.PropertyId.Conversation_Request_Bot_Status_Messages, \"true\");\n const queryParams = {};\n queryParams[HeaderNames_js_1.HeaderNames.ConnectionId] = connectionId;\n queryParams[QueryParameterNames_js_1.QueryParameterNames.Format] = config.parameters.getProperty(Exports_js_2.OutputFormatPropertyName, Exports_js_3.OutputFormat[Exports_js_3.OutputFormat.Simple]).toLowerCase();\n queryParams[QueryParameterNames_js_1.QueryParameterNames.Language] = language;\n queryParams[QueryParameterNames_js_1.QueryParameterNames.RequestBotStatusMessages] = requestTurnStatus;\n if (applicationId) {\n queryParams[QueryParameterNames_js_1.QueryParameterNames.BotId] = applicationId;\n if (dialogType === Exports_js_3.DialogServiceConfig.DialogTypes.CustomCommands) {\n queryParams[HeaderNames_js_1.HeaderNames.CustomCommandsAppId] = applicationId;\n }\n }\n const resourceInfix = dialogType === Exports_js_3.DialogServiceConfig.DialogTypes.CustomCommands ? \"commands/\" : \"\";\n const version = dialogType === Exports_js_3.DialogServiceConfig.DialogTypes.CustomCommands ? \"v1\" : dialogType === Exports_js_3.DialogServiceConfig.DialogTypes.BotFramework ? \"v3\" : \"v0\";\n const headers = {};\n if (authInfo.token != null && authInfo.token !== \"\") {\n headers[authInfo.headerName] = authInfo.token;\n }\n // The URL used for connection is chosen in a priority order of specification:\n // 1. If a custom endpoint is provided, that URL is used verbatim.\n // 2. If a custom host is provided (e.g. \"wss://my.custom.endpoint.com:1123\"), a URL is constructed from it.\n // 3. If no custom connection details are provided, a URL is constructed from default values.\n let endpoint = config.parameters.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_Endpoint, \"\");\n if (!endpoint) {\n const hostSuffix = ConnectionFactoryBase_js_1.ConnectionFactoryBase.getHostSuffix(region);\n const host = config.parameters.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_Host, `wss://${region}.${DialogConnectionFactory.BaseUrl}${hostSuffix}`);\n const standardizedHost = host.endsWith(\"/\") ? host : host + \"/\";\n endpoint = `${standardizedHost}${resourceInfix}${DialogConnectionFactory.ApiKey}/${version}`;\n }\n this.setCommonUrlParams(config, queryParams, endpoint);\n const enableCompression = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\n return new Exports_js_1.WebsocketConnection(endpoint, queryParams, headers, new Exports_js_4.WebsocketMessageFormatter(), Exports_js_1.ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\n }\n}\nexports.DialogConnectionFactory = DialogConnectionFactory;\nDialogConnectionFactory.ApiKey = \"api\";\nDialogConnectionFactory.BaseUrl = \"convai.speech\";","map":{"version":3,"names":["Object","defineProperty","exports","value","DialogConnectionFactory","Exports_js_1","require","Exports_js_2","Exports_js_3","ConnectionFactoryBase_js_1","Exports_js_4","HeaderNames_js_1","QueryParameterNames_js_1","ConnectionFactoryBase","create","config","authInfo","connectionId","applicationId","parameters","getProperty","PropertyId","Conversation_ApplicationId","dialogType","Conversation_DialogType","region","SpeechServiceConnection_Region","language","SpeechServiceConnection_RecoLanguage","requestTurnStatus","Conversation_Request_Bot_Status_Messages","queryParams","HeaderNames","ConnectionId","QueryParameterNames","Format","OutputFormatPropertyName","OutputFormat","Simple","toLowerCase","Language","RequestBotStatusMessages","BotId","DialogServiceConfig","DialogTypes","CustomCommands","CustomCommandsAppId","resourceInfix","version","BotFramework","headers","token","headerName","endpoint","SpeechServiceConnection_Endpoint","hostSuffix","getHostSuffix","host","SpeechServiceConnection_Host","BaseUrl","standardizedHost","endsWith","ApiKey","setCommonUrlParams","enableCompression","WebsocketConnection","WebsocketMessageFormatter","ProxyInfo","fromRecognizerConfig"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/DialogConnectorFactory.js"],"sourcesContent":["\"use strict\";\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DialogConnectionFactory = void 0;\n/* eslint-disable max-classes-per-file */\nconst Exports_js_1 = require(\"../common.browser/Exports.js\");\nconst Exports_js_2 = require(\"../common.speech/Exports.js\");\nconst Exports_js_3 = require(\"../sdk/Exports.js\");\nconst ConnectionFactoryBase_js_1 = require(\"./ConnectionFactoryBase.js\");\nconst Exports_js_4 = require(\"./Exports.js\");\nconst HeaderNames_js_1 = require(\"./HeaderNames.js\");\nconst QueryParameterNames_js_1 = require(\"./QueryParameterNames.js\");\nclass DialogConnectionFactory extends ConnectionFactoryBase_js_1.ConnectionFactoryBase {\n create(config, authInfo, connectionId) {\n const applicationId = config.parameters.getProperty(Exports_js_3.PropertyId.Conversation_ApplicationId, \"\");\n const dialogType = config.parameters.getProperty(Exports_js_3.PropertyId.Conversation_DialogType);\n const region = config.parameters.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_Region);\n const language = config.parameters.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_RecoLanguage, \"en-US\");\n const requestTurnStatus = config.parameters.getProperty(Exports_js_3.PropertyId.Conversation_Request_Bot_Status_Messages, \"true\");\n const queryParams = {};\n queryParams[HeaderNames_js_1.HeaderNames.ConnectionId] = connectionId;\n queryParams[QueryParameterNames_js_1.QueryParameterNames.Format] = config.parameters.getProperty(Exports_js_2.OutputFormatPropertyName, Exports_js_3.OutputFormat[Exports_js_3.OutputFormat.Simple]).toLowerCase();\n queryParams[QueryParameterNames_js_1.QueryParameterNames.Language] = language;\n queryParams[QueryParameterNames_js_1.QueryParameterNames.RequestBotStatusMessages] = requestTurnStatus;\n if (applicationId) {\n queryParams[QueryParameterNames_js_1.QueryParameterNames.BotId] = applicationId;\n if (dialogType === Exports_js_3.DialogServiceConfig.DialogTypes.CustomCommands) {\n queryParams[HeaderNames_js_1.HeaderNames.CustomCommandsAppId] = applicationId;\n }\n }\n const resourceInfix = dialogType === Exports_js_3.DialogServiceConfig.DialogTypes.CustomCommands ? \"commands/\"\n : \"\";\n const version = dialogType === Exports_js_3.DialogServiceConfig.DialogTypes.CustomCommands ? \"v1\"\n : dialogType === Exports_js_3.DialogServiceConfig.DialogTypes.BotFramework ? \"v3\"\n : \"v0\";\n const headers = {};\n if (authInfo.token != null && authInfo.token !== \"\") {\n headers[authInfo.headerName] = authInfo.token;\n }\n // The URL used for connection is chosen in a priority order of specification:\n // 1. If a custom endpoint is provided, that URL is used verbatim.\n // 2. If a custom host is provided (e.g. \"wss://my.custom.endpoint.com:1123\"), a URL is constructed from it.\n // 3. If no custom connection details are provided, a URL is constructed from default values.\n let endpoint = config.parameters.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_Endpoint, \"\");\n if (!endpoint) {\n const hostSuffix = ConnectionFactoryBase_js_1.ConnectionFactoryBase.getHostSuffix(region);\n const host = config.parameters.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_Host, `wss://${region}.${DialogConnectionFactory.BaseUrl}${hostSuffix}`);\n const standardizedHost = host.endsWith(\"/\") ? host : host + \"/\";\n endpoint = `${standardizedHost}${resourceInfix}${DialogConnectionFactory.ApiKey}/${version}`;\n }\n this.setCommonUrlParams(config, queryParams, endpoint);\n const enableCompression = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\n return new Exports_js_1.WebsocketConnection(endpoint, queryParams, headers, new Exports_js_4.WebsocketMessageFormatter(), Exports_js_1.ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\n }\n}\nexports.DialogConnectionFactory = DialogConnectionFactory;\nDialogConnectionFactory.ApiKey = \"api\";\nDialogConnectionFactory.BaseUrl = \"convai.speech\";\n\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACAA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,uBAAuB,GAAG,KAAK,CAAC;AACxC;AACA,MAAMC,YAAY,GAAGC,OAAO,CAAC,8BAA8B,CAAC;AAC5D,MAAMC,YAAY,GAAGD,OAAO,CAAC,6BAA6B,CAAC;AAC3D,MAAME,YAAY,GAAGF,OAAO,CAAC,mBAAmB,CAAC;AACjD,MAAMG,0BAA0B,GAAGH,OAAO,CAAC,4BAA4B,CAAC;AACxE,MAAMI,YAAY,GAAGJ,OAAO,CAAC,cAAc,CAAC;AAC5C,MAAMK,gBAAgB,GAAGL,OAAO,CAAC,kBAAkB,CAAC;AACpD,MAAMM,wBAAwB,GAAGN,OAAO,CAAC,0BAA0B,CAAC;AACpE,MAAMF,uBAAuB,SAASK,0BAA0B,CAACI,qBAAqB,CAAC;EACnFC,MAAMA,CAACC,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAE;IACnC,MAAMC,aAAa,GAAGH,MAAM,CAACI,UAAU,CAACC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