@microsoft/agents-hosting-dialogs 0.1.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -0
- package/dist/src/agentComponent.d.ts +18 -0
- package/dist/src/agentComponent.js +55 -0
- package/dist/src/agentComponent.js.map +1 -0
- package/dist/src/agentStateSet.d.ts +48 -0
- package/dist/src/agentStateSet.js +66 -0
- package/dist/src/agentStateSet.js.map +1 -0
- package/dist/src/choices/choice.d.ts +14 -0
- package/dist/src/choices/choice.js +7 -0
- package/dist/src/choices/choice.js.map +1 -0
- package/dist/src/choices/choiceFactory.d.ts +81 -0
- package/dist/src/choices/choiceFactory.js +133 -0
- package/dist/src/choices/choiceFactory.js.map +1 -0
- package/dist/src/choices/findChoices.d.ts +28 -0
- package/dist/src/choices/findChoices.js +46 -0
- package/dist/src/choices/findChoices.js.map +1 -0
- package/dist/src/choices/findValues.d.ts +36 -0
- package/dist/src/choices/findValues.js +129 -0
- package/dist/src/choices/findValues.js.map +1 -0
- package/dist/src/choices/index.d.ts +11 -0
- package/dist/src/choices/index.js +28 -0
- package/dist/src/choices/index.js.map +1 -0
- package/dist/src/choices/modelResult.d.ts +11 -0
- package/dist/src/choices/modelResult.js +3 -0
- package/dist/src/choices/modelResult.js.map +1 -0
- package/dist/src/choices/recognizeChoices.d.ts +16 -0
- package/dist/src/choices/recognizeChoices.js +81 -0
- package/dist/src/choices/recognizeChoices.js.map +1 -0
- package/dist/src/choices/tokenizer.d.ts +25 -0
- package/dist/src/choices/tokenizer.js +73 -0
- package/dist/src/choices/tokenizer.js.map +1 -0
- package/dist/src/componentDialog.d.ts +178 -0
- package/dist/src/componentDialog.js +252 -0
- package/dist/src/componentDialog.js.map +1 -0
- package/dist/src/componentRegistration.d.ts +22 -0
- package/dist/src/componentRegistration.js +32 -0
- package/dist/src/componentRegistration.js.map +1 -0
- package/dist/src/configurable.d.ts +22 -0
- package/dist/src/configurable.js +60 -0
- package/dist/src/configurable.js.map +1 -0
- package/dist/src/configuration.d.ts +11 -0
- package/dist/src/configuration.js +17 -0
- package/dist/src/configuration.js.map +1 -0
- package/dist/src/converter.d.ts +13 -0
- package/dist/src/converter.js +7 -0
- package/dist/src/converter.js.map +1 -0
- package/dist/src/dialog.d.ts +184 -0
- package/dist/src/dialog.js +201 -0
- package/dist/src/dialog.js.map +1 -0
- package/dist/src/dialogContainer.d.ts +61 -0
- package/dist/src/dialogContainer.js +82 -0
- package/dist/src/dialogContainer.js.map +1 -0
- package/dist/src/dialogContext.d.ts +272 -0
- package/dist/src/dialogContext.js +444 -0
- package/dist/src/dialogContext.js.map +1 -0
- package/dist/src/dialogContextError.d.ts +27 -0
- package/dist/src/dialogContextError.js +39 -0
- package/dist/src/dialogContextError.js.map +1 -0
- package/dist/src/dialogEvent.d.ts +20 -0
- package/dist/src/dialogEvent.js +3 -0
- package/dist/src/dialogEvent.js.map +1 -0
- package/dist/src/dialogEvents.d.ts +15 -0
- package/dist/src/dialogEvents.js +20 -0
- package/dist/src/dialogEvents.js.map +1 -0
- package/dist/src/dialogHelper.d.ts +32 -0
- package/dist/src/dialogHelper.js +116 -0
- package/dist/src/dialogHelper.js.map +1 -0
- package/dist/src/dialogInstance.d.ts +30 -0
- package/dist/src/dialogInstance.js +3 -0
- package/dist/src/dialogInstance.js.map +1 -0
- package/dist/src/dialogManager.d.ts +73 -0
- package/dist/src/dialogManager.js +156 -0
- package/dist/src/dialogManager.js.map +1 -0
- package/dist/src/dialogReason.d.ts +35 -0
- package/dist/src/dialogReason.js +40 -0
- package/dist/src/dialogReason.js.map +1 -0
- package/dist/src/dialogSet.d.ts +85 -0
- package/dist/src/dialogSet.js +138 -0
- package/dist/src/dialogSet.js.map +1 -0
- package/dist/src/dialogTurnResult.d.ts +34 -0
- package/dist/src/dialogTurnResult.js +3 -0
- package/dist/src/dialogTurnResult.js.map +1 -0
- package/dist/src/dialogTurnStateConstants.d.ts +12 -0
- package/dist/src/dialogTurnStateConstants.js +17 -0
- package/dist/src/dialogTurnStateConstants.js.map +1 -0
- package/dist/src/dialogTurnStatus.d.ts +34 -0
- package/dist/src/dialogTurnStatus.js +39 -0
- package/dist/src/dialogTurnStatus.js.map +1 -0
- package/dist/src/dialogsAgentComponent.d.ts +17 -0
- package/dist/src/dialogsAgentComponent.js +65 -0
- package/dist/src/dialogsAgentComponent.js.map +1 -0
- package/dist/src/dialogsComponentRegistration.d.ts +28 -0
- package/dist/src/dialogsComponentRegistration.js +45 -0
- package/dist/src/dialogsComponentRegistration.js.map +1 -0
- package/dist/src/i18n.d.ts +15 -0
- package/dist/src/i18n.js +28 -0
- package/dist/src/i18n.js.map +1 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/index.js +48 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/intentScore.d.ts +11 -0
- package/dist/src/intentScore.js +3 -0
- package/dist/src/intentScore.js.map +1 -0
- package/dist/src/memory/componentMemoryScopes.d.ts +18 -0
- package/dist/src/memory/componentMemoryScopes.js +54 -0
- package/dist/src/memory/componentMemoryScopes.js.map +1 -0
- package/dist/src/memory/componentPathResolvers.d.ts +18 -0
- package/dist/src/memory/componentPathResolvers.js +52 -0
- package/dist/src/memory/componentPathResolvers.js.map +1 -0
- package/dist/src/memory/dialogPath.d.ts +17 -0
- package/dist/src/memory/dialogPath.js +30 -0
- package/dist/src/memory/dialogPath.js.map +1 -0
- package/dist/src/memory/dialogStateManager.d.ts +156 -0
- package/dist/src/memory/dialogStateManager.js +598 -0
- package/dist/src/memory/dialogStateManager.js.map +1 -0
- package/dist/src/memory/index.d.ts +12 -0
- package/dist/src/memory/index.js +29 -0
- package/dist/src/memory/index.js.map +1 -0
- package/dist/src/memory/pathResolvers/aliasPathResolver.d.ts +25 -0
- package/dist/src/memory/pathResolvers/aliasPathResolver.js +37 -0
- package/dist/src/memory/pathResolvers/aliasPathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/atAtPathResolver.d.ts +11 -0
- package/dist/src/memory/pathResolvers/atAtPathResolver.js +18 -0
- package/dist/src/memory/pathResolvers/atAtPathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/atPathResolver.d.ts +20 -0
- package/dist/src/memory/pathResolvers/atPathResolver.js +46 -0
- package/dist/src/memory/pathResolvers/atPathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/dollarPathResolver.d.ts +11 -0
- package/dist/src/memory/pathResolvers/dollarPathResolver.js +18 -0
- package/dist/src/memory/pathResolvers/dollarPathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/hashPathResolver.d.ts +11 -0
- package/dist/src/memory/pathResolvers/hashPathResolver.js +18 -0
- package/dist/src/memory/pathResolvers/hashPathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/index.d.ts +11 -0
- package/dist/src/memory/pathResolvers/index.js +28 -0
- package/dist/src/memory/pathResolvers/index.js.map +1 -0
- package/dist/src/memory/pathResolvers/pathResolver.d.ts +13 -0
- package/dist/src/memory/pathResolvers/pathResolver.js +7 -0
- package/dist/src/memory/pathResolvers/pathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/percentPathResolver.d.ts +11 -0
- package/dist/src/memory/pathResolvers/percentPathResolver.js +18 -0
- package/dist/src/memory/pathResolvers/percentPathResolver.js.map +1 -0
- package/dist/src/memory/scopePath.d.ts +18 -0
- package/dist/src/memory/scopePath.js +23 -0
- package/dist/src/memory/scopePath.js.map +1 -0
- package/dist/src/memory/scopes/agentStateMemoryScope.d.ts +53 -0
- package/dist/src/memory/scopes/agentStateMemoryScope.js +82 -0
- package/dist/src/memory/scopes/agentStateMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/classMemoryScope.d.ts +29 -0
- package/dist/src/memory/scopes/classMemoryScope.js +65 -0
- package/dist/src/memory/scopes/classMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/conversationMemoryScope.d.ts +15 -0
- package/dist/src/memory/scopes/conversationMemoryScope.js +23 -0
- package/dist/src/memory/scopes/conversationMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/dialogClassMemoryScope.d.ts +19 -0
- package/dist/src/memory/scopes/dialogClassMemoryScope.js +42 -0
- package/dist/src/memory/scopes/dialogClassMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/dialogContextMemoryScope.d.ts +19 -0
- package/dist/src/memory/scopes/dialogContextMemoryScope.js +48 -0
- package/dist/src/memory/scopes/dialogContextMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/dialogMemoryScope.d.ts +32 -0
- package/dist/src/memory/scopes/dialogMemoryScope.js +74 -0
- package/dist/src/memory/scopes/dialogMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/index.d.ts +15 -0
- package/dist/src/memory/scopes/index.js +32 -0
- package/dist/src/memory/scopes/index.js.map +1 -0
- package/dist/src/memory/scopes/memoryScope.d.ts +52 -0
- package/dist/src/memory/scopes/memoryScope.js +54 -0
- package/dist/src/memory/scopes/memoryScope.js.map +1 -0
- package/dist/src/memory/scopes/settingsMemoryScope.d.ts +68 -0
- package/dist/src/memory/scopes/settingsMemoryScope.js +216 -0
- package/dist/src/memory/scopes/settingsMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/thisMemoryScope.d.ts +26 -0
- package/dist/src/memory/scopes/thisMemoryScope.js +43 -0
- package/dist/src/memory/scopes/thisMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/turnMemoryScope.d.ts +29 -0
- package/dist/src/memory/scopes/turnMemoryScope.js +52 -0
- package/dist/src/memory/scopes/turnMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/userMemoryScope.d.ts +15 -0
- package/dist/src/memory/scopes/userMemoryScope.js +23 -0
- package/dist/src/memory/scopes/userMemoryScope.js.map +1 -0
- package/dist/src/memory/turnPath.d.ts +21 -0
- package/dist/src/memory/turnPath.js +38 -0
- package/dist/src/memory/turnPath.js.map +1 -0
- package/dist/src/prompts/activityPrompt.d.ts +101 -0
- package/dist/src/prompts/activityPrompt.js +166 -0
- package/dist/src/prompts/activityPrompt.js.map +1 -0
- package/dist/src/prompts/attachmentPrompt.d.ts +37 -0
- package/dist/src/prompts/attachmentPrompt.js +55 -0
- package/dist/src/prompts/attachmentPrompt.js.map +1 -0
- package/dist/src/prompts/choicePrompt.d.ts +83 -0
- package/dist/src/prompts/choicePrompt.js +116 -0
- package/dist/src/prompts/choicePrompt.js.map +1 -0
- package/dist/src/prompts/confirmPrompt.d.ts +82 -0
- package/dist/src/prompts/confirmPrompt.js +163 -0
- package/dist/src/prompts/confirmPrompt.js.map +1 -0
- package/dist/src/prompts/datetimePrompt.d.ts +65 -0
- package/dist/src/prompts/datetimePrompt.js +109 -0
- package/dist/src/prompts/datetimePrompt.js.map +1 -0
- package/dist/src/prompts/index.d.ts +13 -0
- package/dist/src/prompts/index.js +30 -0
- package/dist/src/prompts/index.js.map +1 -0
- package/dist/src/prompts/numberPrompt.d.ts +55 -0
- package/dist/src/prompts/numberPrompt.js +134 -0
- package/dist/src/prompts/numberPrompt.js.map +1 -0
- package/dist/src/prompts/prompt.d.ts +256 -0
- package/dist/src/prompts/prompt.js +260 -0
- package/dist/src/prompts/prompt.js.map +1 -0
- package/dist/src/prompts/promptCultureModels.d.ts +72 -0
- package/dist/src/prompts/promptCultureModels.js +123 -0
- package/dist/src/prompts/promptCultureModels.js.map +1 -0
- package/dist/src/prompts/textPrompt.d.ts +54 -0
- package/dist/src/prompts/textPrompt.js +72 -0
- package/dist/src/prompts/textPrompt.js.map +1 -0
- package/dist/src/recognizer.d.ts +43 -0
- package/dist/src/recognizer.js +104 -0
- package/dist/src/recognizer.js.map +1 -0
- package/dist/src/recognizerResult.d.ts +19 -0
- package/dist/src/recognizerResult.js +24 -0
- package/dist/src/recognizerResult.js.map +1 -0
- package/dist/src/serviceCollection.d.ts +112 -0
- package/dist/src/serviceCollection.js +209 -0
- package/dist/src/serviceCollection.js.map +1 -0
- package/dist/src/stringUtils.d.ts +36 -0
- package/dist/src/stringUtils.js +62 -0
- package/dist/src/stringUtils.js.map +1 -0
- package/dist/src/template.d.ts +18 -0
- package/dist/src/template.js +7 -0
- package/dist/src/template.js.map +1 -0
- package/dist/src/waterfallDialog.d.ts +101 -0
- package/dist/src/waterfallDialog.js +179 -0
- package/dist/src/waterfallDialog.js.map +1 -0
- package/dist/src/waterfallStepContext.d.ts +71 -0
- package/dist/src/waterfallStepContext.js +78 -0
- package/dist/src/waterfallStepContext.js.map +1 -0
- package/package.json +49 -0
- package/src/agentComponent.ts +23 -0
- package/src/agentStateSet.ts +75 -0
- package/src/choices/choice.ts +16 -0
- package/src/choices/choiceFactory.ts +189 -0
- package/src/choices/findChoices.ts +70 -0
- package/src/choices/findValues.ts +179 -0
- package/src/choices/index.ts +11 -0
- package/src/choices/modelResult.ts +11 -0
- package/src/choices/recognizeChoices.ts +94 -0
- package/src/choices/tokenizer.ts +93 -0
- package/src/componentDialog.ts +306 -0
- package/src/componentRegistration.ts +30 -0
- package/src/configurable.ts +55 -0
- package/src/configuration.ts +22 -0
- package/src/converter.ts +15 -0
- package/src/dialog.ts +243 -0
- package/src/dialogContainer.ts +90 -0
- package/src/dialogContext.ts +607 -0
- package/src/dialogContextError.ts +50 -0
- package/src/dialogEvent.ts +23 -0
- package/src/dialogEvents.ts +16 -0
- package/src/dialogHelper.ts +154 -0
- package/src/dialogInstance.ts +32 -0
- package/src/dialogManager.ts +202 -0
- package/src/dialogReason.ts +40 -0
- package/src/dialogSet.ts +168 -0
- package/src/dialogTurnResult.ts +37 -0
- package/src/dialogTurnStateConstants.ts +13 -0
- package/src/dialogTurnStatus.ts +38 -0
- package/src/dialogsAgentComponent.ts +71 -0
- package/src/dialogsComponentRegistration.ts +49 -0
- package/src/i18n.ts +17 -0
- package/src/index.ts +31 -0
- package/src/intentScore.ts +11 -0
- package/src/memory/componentMemoryScopes.ts +28 -0
- package/src/memory/componentPathResolvers.ts +29 -0
- package/src/memory/dialogPath.ts +33 -0
- package/src/memory/dialogStateManager.ts +661 -0
- package/src/memory/index.ts +12 -0
- package/src/memory/pathResolvers/aliasPathResolver.ts +44 -0
- package/src/memory/pathResolvers/atAtPathResolver.ts +14 -0
- package/src/memory/pathResolvers/atPathResolver.ts +45 -0
- package/src/memory/pathResolvers/dollarPathResolver.ts +14 -0
- package/src/memory/pathResolvers/hashPathResolver.ts +14 -0
- package/src/memory/pathResolvers/index.ts +11 -0
- package/src/memory/pathResolvers/pathResolver.ts +14 -0
- package/src/memory/pathResolvers/percentPathResolver.ts +14 -0
- package/src/memory/scopePath.ts +19 -0
- package/src/memory/scopes/agentStateMemoryScope.ts +92 -0
- package/src/memory/scopes/classMemoryScope.ts +71 -0
- package/src/memory/scopes/conversationMemoryScope.ts +19 -0
- package/src/memory/scopes/dialogClassMemoryScope.ts +43 -0
- package/src/memory/scopes/dialogContextMemoryScope.ts +51 -0
- package/src/memory/scopes/dialogMemoryScope.ts +79 -0
- package/src/memory/scopes/index.ts +15 -0
- package/src/memory/scopes/memoryScope.ts +70 -0
- package/src/memory/scopes/settingsMemoryScope.ts +239 -0
- package/src/memory/scopes/thisMemoryScope.ts +44 -0
- package/src/memory/scopes/turnMemoryScope.ts +54 -0
- package/src/memory/scopes/userMemoryScope.ts +19 -0
- package/src/memory/turnPath.ts +45 -0
- package/src/prompts/activityPrompt.ts +202 -0
- package/src/prompts/attachmentPrompt.ts +62 -0
- package/src/prompts/choicePrompt.ts +176 -0
- package/src/prompts/confirmPrompt.ts +182 -0
- package/src/prompts/datetimePrompt.ts +110 -0
- package/src/prompts/index.ts +13 -0
- package/src/prompts/numberPrompt.ts +117 -0
- package/src/prompts/prompt.ts +459 -0
- package/src/prompts/promptCultureModels.ts +178 -0
- package/src/prompts/textPrompt.ts +82 -0
- package/src/recognizer.ts +127 -0
- package/src/recognizerResult.ts +37 -0
- package/src/serviceCollection.ts +305 -0
- package/src/stringUtils.ts +62 -0
- package/src/template.ts +20 -0
- package/src/waterfallDialog.ts +215 -0
- package/src/waterfallStepContext.ts +96 -0
- package/vendor/cldr-data/README.md +5 -0
- package/vendor/cldr-data/main/de/numbers.json +156 -0
- package/vendor/cldr-data/main/en/numbers.json +159 -0
- package/vendor/cldr-data/main/es/numbers.json +156 -0
- package/vendor/cldr-data/main/fr/numbers.json +157 -0
- package/vendor/cldr-data/main/ja/numbers.json +120 -0
- package/vendor/cldr-data/main/nl/numbers.json +156 -0
- package/vendor/cldr-data/main/pt/numbers.json +156 -0
- package/vendor/cldr-data/main/zh/numbers.json +214 -0
- package/vendor/cldr-data/supplemental/likelySubtags.json +1844 -0
- package/vendor/cldr-data/supplemental/numberingSystems.json +343 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ConfirmPrompt = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
39
|
+
* Licensed under the MIT License.
|
|
40
|
+
*/
|
|
41
|
+
const Recognizers = __importStar(require("@microsoft/recognizers-text-choice"));
|
|
42
|
+
const choices_1 = require("../choices");
|
|
43
|
+
const prompt_1 = require("./prompt");
|
|
44
|
+
const promptCultureModels_1 = require("./promptCultureModels");
|
|
45
|
+
/**
|
|
46
|
+
* Prompts a user to confirm something with a "yes" or "no" response.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* By default the prompt will return to the calling dialog a `boolean` representing the users
|
|
50
|
+
* selection.
|
|
51
|
+
*/
|
|
52
|
+
class ConfirmPrompt extends prompt_1.Prompt {
|
|
53
|
+
/**
|
|
54
|
+
* Creates a new ConfirmPrompt instance.
|
|
55
|
+
*
|
|
56
|
+
* @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
|
|
57
|
+
* @param validator (Optional) validator that will be called each time the user responds to the prompt.
|
|
58
|
+
* @param defaultLocale (Optional) locale to use if `TurnContext.activity.locale` is not specified. Defaults to a value of `en-us`.
|
|
59
|
+
* @param choiceDefaults (Optional) Overrides the dictionary of Default Choices on [[PromptCultureModels.getSupportedCultures()]].
|
|
60
|
+
*/
|
|
61
|
+
constructor(dialogId, validator, defaultLocale, choiceDefaults) {
|
|
62
|
+
super(dialogId, validator);
|
|
63
|
+
this.style = prompt_1.ListStyle.auto;
|
|
64
|
+
this.defaultLocale = defaultLocale;
|
|
65
|
+
if (choiceDefaults === undefined) {
|
|
66
|
+
const supported = {};
|
|
67
|
+
promptCultureModels_1.PromptCultureModels.getSupportedCultures().forEach((culture) => {
|
|
68
|
+
supported[culture.locale] = {
|
|
69
|
+
choices: [culture.yesInLanguage, culture.noInLanguage],
|
|
70
|
+
options: {
|
|
71
|
+
inlineSeparator: culture.separator,
|
|
72
|
+
inlineOr: culture.inlineOr,
|
|
73
|
+
inlineOrMore: culture.inlineOrMore,
|
|
74
|
+
includeNumbers: true,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
this.choiceDefaults = supported;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this.choiceDefaults = choiceDefaults;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Prompts the user for input.
|
|
86
|
+
*
|
|
87
|
+
* @param context TurnContext, context for the current
|
|
88
|
+
* turn of conversation with the user.
|
|
89
|
+
* @param state Contains state for the current instance of the prompt on the dialog stack.
|
|
90
|
+
* @param options A PromptOptions object constructed
|
|
91
|
+
* from the options initially provided in the call to Prompt.
|
|
92
|
+
* @param isRetry `true` if this is the first time this prompt dialog instance
|
|
93
|
+
* on the stack is prompting the user for input; otherwise, false.
|
|
94
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
95
|
+
*/
|
|
96
|
+
async onPrompt(context, state, options, isRetry) {
|
|
97
|
+
// Format prompt to send
|
|
98
|
+
let prompt;
|
|
99
|
+
const channelId = context.activity.channelId;
|
|
100
|
+
const culture = this.determineCulture(context.activity);
|
|
101
|
+
const choiceOptions = this.choiceOptions || this.choiceDefaults[culture].options;
|
|
102
|
+
const choices = this.confirmChoices || this.choiceDefaults[culture].choices;
|
|
103
|
+
if (isRetry && options.retryPrompt) {
|
|
104
|
+
prompt = this.appendChoices(options.retryPrompt, channelId, choices, this.style, choiceOptions);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
prompt = this.appendChoices(options.prompt, channelId, choices, this.style, choiceOptions);
|
|
108
|
+
}
|
|
109
|
+
// Send prompt
|
|
110
|
+
await context.sendActivity(prompt);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Attempts to recognize the user's input.
|
|
114
|
+
*
|
|
115
|
+
* @param context TurnContext, context for the current
|
|
116
|
+
* turn of conversation with the user.
|
|
117
|
+
* @param _state Contains state for the current instance of the prompt on the dialog stack.
|
|
118
|
+
* @param _options A PromptOptions object constructed
|
|
119
|
+
* from the options initially provided in the call to Prompt.
|
|
120
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
121
|
+
*/
|
|
122
|
+
async onRecognize(context, _state, _options) {
|
|
123
|
+
var _a;
|
|
124
|
+
const result = { succeeded: false };
|
|
125
|
+
const activity = context.activity;
|
|
126
|
+
const utterance = activity.text;
|
|
127
|
+
if (!utterance) {
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
const culture = this.determineCulture(context.activity);
|
|
131
|
+
const results = Recognizers.recognizeBoolean(utterance, (_a = _options.recognizeLanguage) !== null && _a !== void 0 ? _a : culture);
|
|
132
|
+
if (results.length > 0 && results[0].resolution) {
|
|
133
|
+
result.succeeded = true;
|
|
134
|
+
result.value = results[0].resolution.value;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// If the prompt text was sent to the user with numbers, the prompt should recognize number choices.
|
|
138
|
+
const choiceOptions = this.choiceOptions || this.choiceDefaults[culture].options;
|
|
139
|
+
if (typeof choiceOptions.includeNumbers !== 'boolean' || choiceOptions.includeNumbers) {
|
|
140
|
+
const confirmChoices = this.confirmChoices || this.choiceDefaults[culture].choices;
|
|
141
|
+
const choices = [confirmChoices[0], confirmChoices[1]];
|
|
142
|
+
const secondOrMoreAttemptResults = (0, choices_1.recognizeChoices)(utterance, choices);
|
|
143
|
+
if (secondOrMoreAttemptResults.length > 0) {
|
|
144
|
+
result.succeeded = true;
|
|
145
|
+
result.value = secondOrMoreAttemptResults[0].resolution.index === 0;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @private
|
|
153
|
+
*/
|
|
154
|
+
determineCulture(activity) {
|
|
155
|
+
let culture = promptCultureModels_1.PromptCultureModels.mapToNearestLanguage(activity.locale || this.defaultLocale || promptCultureModels_1.PromptCultureModels.English.locale);
|
|
156
|
+
if (!(culture && this.choiceDefaults[culture])) {
|
|
157
|
+
culture = promptCultureModels_1.PromptCultureModels.English.locale;
|
|
158
|
+
}
|
|
159
|
+
return culture;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.ConfirmPrompt = ConfirmPrompt;
|
|
163
|
+
//# sourceMappingURL=confirmPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirmPrompt.js","sourceRoot":"","sources":["../../../src/prompts/confirmPrompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,gFAAiE;AAEjE,wCAA2E;AAC3E,qCAAoG;AACpG,+DAA2D;AAO3D;;;;;;GAMG;AACH,MAAa,aAAc,SAAQ,eAAe;IA+BhD;;;;;;;SAOK;IACL,YACE,QAAgB,EAChB,SAAoC,EACpC,aAAsB,EACtB,cAA4C;QAE5C,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,kBAAS,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAElC,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,SAAS,GAAgC,EAAE,CAAA;YACjD,yCAAmB,CAAC,oBAAoB,EAAE,CAAC,OAAO,CAAC,CAAC,OAAO,EAAQ,EAAE;gBACnE,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG;oBAC1B,OAAO,EAAE,CAAC,OA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AAM,0BAA0B,GAAG,IAAA,0BAAgB,EAAC,SAAS,EAAE,OAAO,CAAC,CAAA;gBACvE,IAAI,0BAA0B,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC1C,MAAM,CAAC,SAAS,GAAG,IAAI,CAAA;oBACvB,MAAM,CAAC,KAAK,GAAG,0BAA0B,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,KAAK,CAAC,CAAA;gBACrE,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;SAEK;IACG,gBAAgB,CAAE,QAAkB;QAC1C,IAAI,OAAO,GAAG,yCAAmB,CAAC,oBAAoB,CACpD,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,aAAa,IAAI,yCAAmB,CAAC,OAAO,CAAC,MAAM,CAC5E,CAAA;QACD,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;YAC/C,OAAO,GAAG,yCAAmB,CAAC,OAAO,CAAC,MAAM,CAAA;QAC9C,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AA/JD,sCA+JC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { TurnContext } from '@microsoft/agents-hosting';
|
|
2
|
+
import { Prompt, PromptOptions, PromptRecognizerResult, PromptValidator } from './prompt';
|
|
3
|
+
/**
|
|
4
|
+
* Result returned by the `DateTimePrompt`.
|
|
5
|
+
*/
|
|
6
|
+
export interface DateTimeResolution {
|
|
7
|
+
/**
|
|
8
|
+
* TIMEX expression representing ambiguity of the recognized time.
|
|
9
|
+
*/
|
|
10
|
+
timex: string;
|
|
11
|
+
/**
|
|
12
|
+
* Type of time recognized. Possible values are 'date', 'time', 'datetime', 'daterange',
|
|
13
|
+
* 'timerange', 'datetimerange', 'duration', or 'set'.
|
|
14
|
+
*/
|
|
15
|
+
type: string;
|
|
16
|
+
/**
|
|
17
|
+
* Value of the specified [type](#type) that's a reasonable approximation given the ambiguity
|
|
18
|
+
* of the [timex](#timex).
|
|
19
|
+
*/
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Prompts a user to enter a datetime expression.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* By default the prompt will return to the calling dialog a `DateTimeResolution[]`.
|
|
27
|
+
*/
|
|
28
|
+
export declare class DateTimePrompt extends Prompt<DateTimeResolution[]> {
|
|
29
|
+
/**
|
|
30
|
+
* The prompts default locale that should be recognized.
|
|
31
|
+
*/
|
|
32
|
+
defaultLocale: string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new DateTimePrompt instance.
|
|
35
|
+
*
|
|
36
|
+
* @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
|
|
37
|
+
* @param validator (Optional) validator that will be called each time the user responds to the prompt.
|
|
38
|
+
* @param defaultLocale (Optional) locale to use if `TurnContext.activity.locale` is not specified. Defaults to a value of `en-us`.
|
|
39
|
+
*/
|
|
40
|
+
constructor(dialogId: string, validator?: PromptValidator<DateTimeResolution[]>, defaultLocale?: string);
|
|
41
|
+
/**
|
|
42
|
+
* Prompts the user for input.
|
|
43
|
+
*
|
|
44
|
+
* @param context TurnContext, context for the current
|
|
45
|
+
* turn of conversation with the user.
|
|
46
|
+
* @param state Contains state for the current instance of the prompt on the dialog stack.
|
|
47
|
+
* @param options A PromptOptions object constructed
|
|
48
|
+
* from the options initially provided in the call to Prompt.
|
|
49
|
+
* @param isRetry `true` if this is the first time this prompt dialog instance
|
|
50
|
+
* on the stack is prompting the user for input; otherwise, false.
|
|
51
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
52
|
+
*/
|
|
53
|
+
protected onPrompt(context: TurnContext, state: any, options: PromptOptions, isRetry: boolean): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Attempts to recognize the user's input.
|
|
56
|
+
*
|
|
57
|
+
* @param context TurnContext, context for the current
|
|
58
|
+
* turn of conversation with the user.
|
|
59
|
+
* @param _state Contains state for the current instance of the prompt on the dialog stack.
|
|
60
|
+
* @param _options A PromptOptions object constructed
|
|
61
|
+
* from the options initially provided in the call to Prompt.
|
|
62
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
63
|
+
*/
|
|
64
|
+
protected onRecognize(context: TurnContext, _state: any, _options: PromptOptions): Promise<PromptRecognizerResult<DateTimeResolution[]>>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DateTimePrompt = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
39
|
+
* Licensed under the MIT License.
|
|
40
|
+
*/
|
|
41
|
+
const Recognizers = __importStar(require("@microsoft/recognizers-text-date-time"));
|
|
42
|
+
const agents_hosting_1 = require("@microsoft/agents-hosting");
|
|
43
|
+
const prompt_1 = require("./prompt");
|
|
44
|
+
/**
|
|
45
|
+
* Prompts a user to enter a datetime expression.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* By default the prompt will return to the calling dialog a `DateTimeResolution[]`.
|
|
49
|
+
*/
|
|
50
|
+
class DateTimePrompt extends prompt_1.Prompt {
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new DateTimePrompt instance.
|
|
53
|
+
*
|
|
54
|
+
* @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
|
|
55
|
+
* @param validator (Optional) validator that will be called each time the user responds to the prompt.
|
|
56
|
+
* @param defaultLocale (Optional) locale to use if `TurnContext.activity.locale` is not specified. Defaults to a value of `en-us`.
|
|
57
|
+
*/
|
|
58
|
+
constructor(dialogId, validator, defaultLocale) {
|
|
59
|
+
super(dialogId, validator);
|
|
60
|
+
this.defaultLocale = defaultLocale;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Prompts the user for input.
|
|
64
|
+
*
|
|
65
|
+
* @param context TurnContext, context for the current
|
|
66
|
+
* turn of conversation with the user.
|
|
67
|
+
* @param state Contains state for the current instance of the prompt on the dialog stack.
|
|
68
|
+
* @param options A PromptOptions object constructed
|
|
69
|
+
* from the options initially provided in the call to Prompt.
|
|
70
|
+
* @param isRetry `true` if this is the first time this prompt dialog instance
|
|
71
|
+
* on the stack is prompting the user for input; otherwise, false.
|
|
72
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
73
|
+
*/
|
|
74
|
+
async onPrompt(context, state, options, isRetry) {
|
|
75
|
+
if (isRetry && options.retryPrompt) {
|
|
76
|
+
await context.sendActivity(options.retryPrompt, undefined, agents_hosting_1.InputHints.ExpectingInput);
|
|
77
|
+
}
|
|
78
|
+
else if (options.prompt) {
|
|
79
|
+
await context.sendActivity(options.prompt, undefined, agents_hosting_1.InputHints.ExpectingInput);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Attempts to recognize the user's input.
|
|
84
|
+
*
|
|
85
|
+
* @param context TurnContext, context for the current
|
|
86
|
+
* turn of conversation with the user.
|
|
87
|
+
* @param _state Contains state for the current instance of the prompt on the dialog stack.
|
|
88
|
+
* @param _options A PromptOptions object constructed
|
|
89
|
+
* from the options initially provided in the call to Prompt.
|
|
90
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
91
|
+
*/
|
|
92
|
+
async onRecognize(context, _state, _options) {
|
|
93
|
+
const result = { succeeded: false };
|
|
94
|
+
const activity = context.activity;
|
|
95
|
+
const utterance = activity.text;
|
|
96
|
+
if (!utterance) {
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
const locale = activity.locale || this.defaultLocale || 'en-us';
|
|
100
|
+
const results = Recognizers.recognizeDateTime(utterance, locale);
|
|
101
|
+
if (results.length > 0 && results[0].resolution) {
|
|
102
|
+
result.succeeded = true;
|
|
103
|
+
result.value = results[0].resolution.values;
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.DateTimePrompt = DateTimePrompt;
|
|
109
|
+
//# sourceMappingURL=datetimePrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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QACvE,MAAM,OAAO,GAAU,WAAW,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QACvE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;YAChD,MAAM,CAAC,SAAS,GAAG,IAAI,CAAA;YACvB,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAA;QAC7C,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAzED,wCAyEC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export * from './activityPrompt';
|
|
6
|
+
export * from './attachmentPrompt';
|
|
7
|
+
export * from './choicePrompt';
|
|
8
|
+
export * from './confirmPrompt';
|
|
9
|
+
export * from './datetimePrompt';
|
|
10
|
+
export * from './numberPrompt';
|
|
11
|
+
export * from './prompt';
|
|
12
|
+
export * from './textPrompt';
|
|
13
|
+
export * from './promptCultureModels';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19
|
+
* Licensed under the MIT License.
|
|
20
|
+
*/
|
|
21
|
+
__exportStar(require("./activityPrompt"), exports);
|
|
22
|
+
__exportStar(require("./attachmentPrompt"), exports);
|
|
23
|
+
__exportStar(require("./choicePrompt"), exports);
|
|
24
|
+
__exportStar(require("./confirmPrompt"), exports);
|
|
25
|
+
__exportStar(require("./datetimePrompt"), exports);
|
|
26
|
+
__exportStar(require("./numberPrompt"), exports);
|
|
27
|
+
__exportStar(require("./prompt"), exports);
|
|
28
|
+
__exportStar(require("./textPrompt"), exports);
|
|
29
|
+
__exportStar(require("./promptCultureModels"), exports);
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/prompts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,mDAAgC;AAChC,qDAAkC;AAClC,iDAA8B;AAC9B,kDAA+B;AAC/B,mDAAgC;AAChC,iDAA8B;AAC9B,2CAAwB;AACxB,+CAA4B;AAC5B,wDAAqC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { TurnContext } from '@microsoft/agents-hosting';
|
|
6
|
+
import { Prompt, PromptOptions, PromptRecognizerResult, PromptValidator } from './prompt';
|
|
7
|
+
/**
|
|
8
|
+
* Prompts a user to enter a number.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* By default the prompt will return to the calling dialog a `number` representing the users input.
|
|
12
|
+
*/
|
|
13
|
+
export declare class NumberPrompt extends Prompt<number> {
|
|
14
|
+
/**
|
|
15
|
+
* The prompts default locale that should be recognized.
|
|
16
|
+
*/
|
|
17
|
+
defaultLocale?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new NumberPrompt instance.
|
|
20
|
+
*
|
|
21
|
+
* @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
|
|
22
|
+
* @param validator (Optional) validator that will be called each time the user responds to the prompt.
|
|
23
|
+
* @param defaultLocale (Optional) locale to use if `TurnContext.activity.locale` is not specified. Defaults to a value of `en-us`.
|
|
24
|
+
*/
|
|
25
|
+
constructor(dialogId: string, validator?: PromptValidator<number>, defaultLocale?: string);
|
|
26
|
+
/**
|
|
27
|
+
* Prompts the user for input.
|
|
28
|
+
*
|
|
29
|
+
* @param context [TurnContext] context for the current
|
|
30
|
+
* turn of conversation with the user.
|
|
31
|
+
* @param state Contains state for the current instance of the prompt on the dialog stack.
|
|
32
|
+
* @param options A [PromptOptions] object constructed
|
|
33
|
+
* from the options initially provided in the call to Prompt.
|
|
34
|
+
* @param isRetry `true` if this is the first time this prompt dialog instance
|
|
35
|
+
* on the stack is prompting the user for input; otherwise, false.
|
|
36
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
37
|
+
*/
|
|
38
|
+
protected onPrompt(context: TurnContext, state: unknown, options: PromptOptions, isRetry: boolean): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Attempts to recognize the user's input.
|
|
41
|
+
*
|
|
42
|
+
* @param context [TurnContext], context for the current
|
|
43
|
+
* turn of conversation with the user.
|
|
44
|
+
* @param _state Contains state for the current instance of the prompt on the dialog stack.
|
|
45
|
+
* @param _options A [PromptOptions] object constructed
|
|
46
|
+
* from the options initially provided in the call to Prompt.
|
|
47
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
48
|
+
*/
|
|
49
|
+
protected onRecognize(context: TurnContext, _state: unknown, _options: PromptOptions): Promise<PromptRecognizerResult<number>>;
|
|
50
|
+
/**
|
|
51
|
+
* @private
|
|
52
|
+
* The portions of the Globalize parsing library we use only need the first letters for internationalization culture
|
|
53
|
+
*/
|
|
54
|
+
private getCultureFormattedForGlobalize;
|
|
55
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.NumberPrompt = void 0;
|
|
44
|
+
const globalize_1 = __importDefault(require("globalize"));
|
|
45
|
+
const recognizers_text_number_1 = require("@microsoft/recognizers-text-number");
|
|
46
|
+
const locales = __importStar(require("../i18n"));
|
|
47
|
+
const agents_hosting_1 = require("@microsoft/agents-hosting");
|
|
48
|
+
const prompt_1 = require("./prompt");
|
|
49
|
+
// Load all registered locales into Globalize library
|
|
50
|
+
Object.values(locales).forEach((locale) => globalize_1.default.load(locale));
|
|
51
|
+
/**
|
|
52
|
+
* Prompts a user to enter a number.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* By default the prompt will return to the calling dialog a `number` representing the users input.
|
|
56
|
+
*/
|
|
57
|
+
class NumberPrompt extends prompt_1.Prompt {
|
|
58
|
+
/**
|
|
59
|
+
* Creates a new NumberPrompt instance.
|
|
60
|
+
*
|
|
61
|
+
* @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
|
|
62
|
+
* @param validator (Optional) validator that will be called each time the user responds to the prompt.
|
|
63
|
+
* @param defaultLocale (Optional) locale to use if `TurnContext.activity.locale` is not specified. Defaults to a value of `en-us`.
|
|
64
|
+
*/
|
|
65
|
+
constructor(dialogId, validator, defaultLocale) {
|
|
66
|
+
super(dialogId, validator);
|
|
67
|
+
this.defaultLocale = defaultLocale;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Prompts the user for input.
|
|
71
|
+
*
|
|
72
|
+
* @param context [TurnContext] context for the current
|
|
73
|
+
* turn of conversation with the user.
|
|
74
|
+
* @param state Contains state for the current instance of the prompt on the dialog stack.
|
|
75
|
+
* @param options A [PromptOptions] object constructed
|
|
76
|
+
* from the options initially provided in the call to Prompt.
|
|
77
|
+
* @param isRetry `true` if this is the first time this prompt dialog instance
|
|
78
|
+
* on the stack is prompting the user for input; otherwise, false.
|
|
79
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
80
|
+
*/
|
|
81
|
+
async onPrompt(context, state, options, isRetry) {
|
|
82
|
+
if (isRetry && options.retryPrompt) {
|
|
83
|
+
await context.sendActivity(options.retryPrompt, undefined, agents_hosting_1.InputHints.ExpectingInput);
|
|
84
|
+
}
|
|
85
|
+
else if (options.prompt) {
|
|
86
|
+
await context.sendActivity(options.prompt, undefined, agents_hosting_1.InputHints.ExpectingInput);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Attempts to recognize the user's input.
|
|
91
|
+
*
|
|
92
|
+
* @param context [TurnContext], context for the current
|
|
93
|
+
* turn of conversation with the user.
|
|
94
|
+
* @param _state Contains state for the current instance of the prompt on the dialog stack.
|
|
95
|
+
* @param _options A [PromptOptions] object constructed
|
|
96
|
+
* from the options initially provided in the call to Prompt.
|
|
97
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
98
|
+
*/
|
|
99
|
+
async onRecognize(context, _state, _options) {
|
|
100
|
+
const result = { succeeded: false };
|
|
101
|
+
const activity = context.activity;
|
|
102
|
+
const utterance = activity.text;
|
|
103
|
+
if (!utterance) {
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
const defaultLocale = this.defaultLocale || 'en-us';
|
|
107
|
+
const locale = activity.locale || defaultLocale;
|
|
108
|
+
const [{ resolution = null } = {}] = (0, recognizers_text_number_1.recognizeNumber)(utterance, locale) || [];
|
|
109
|
+
if (resolution) {
|
|
110
|
+
result.succeeded = true;
|
|
111
|
+
// Note: if we encounter an exception loading a globalize number parser, fall back to the
|
|
112
|
+
// parser for the default locale
|
|
113
|
+
const parser = (0, globalize_1.default)(this.getCultureFormattedForGlobalize(locale));
|
|
114
|
+
let numberParser;
|
|
115
|
+
try {
|
|
116
|
+
numberParser = parser.numberParser();
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
numberParser = (0, globalize_1.default)(this.getCultureFormattedForGlobalize(defaultLocale)).numberParser();
|
|
120
|
+
}
|
|
121
|
+
result.value = numberParser(resolution.value);
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @private
|
|
127
|
+
* The portions of the Globalize parsing library we use only need the first letters for internationalization culture
|
|
128
|
+
*/
|
|
129
|
+
getCultureFormattedForGlobalize(culture) {
|
|
130
|
+
return culture.slice(0, 2).toLowerCase();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.NumberPrompt = NumberPrompt;
|
|
134
|
+
//# sourceMappingURL=numberPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberPrompt.js","sourceRoot":"","sources":["../../../src/prompts/numberPrompt.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0DAAiC;AACjC,gFAAoE;AACpE,iDAAkC;AAClC,8DAAmE;AACnE,qCAAyF;AAEzF,qDAAqD;AACrD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,mBAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAElE;;;;;GAKG;AACH,MAAa,YAAa,SAAQ,eAAc;IAM9C;;;;;;SAMK;IACL,YAAa,QAAgB,EAAE,SAAmC,EAAE,aAAsB;QACxF,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;QAC1B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED;;;;;;;;;;;SAWK;IACK,KAAK,CAAC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