@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.
Files changed (325) hide show
  1. package/dist/index.js +20 -0
  2. package/dist/src/agentComponent.d.ts +18 -0
  3. package/dist/src/agentComponent.js +55 -0
  4. package/dist/src/agentComponent.js.map +1 -0
  5. package/dist/src/agentStateSet.d.ts +48 -0
  6. package/dist/src/agentStateSet.js +66 -0
  7. package/dist/src/agentStateSet.js.map +1 -0
  8. package/dist/src/choices/choice.d.ts +14 -0
  9. package/dist/src/choices/choice.js +7 -0
  10. package/dist/src/choices/choice.js.map +1 -0
  11. package/dist/src/choices/choiceFactory.d.ts +81 -0
  12. package/dist/src/choices/choiceFactory.js +133 -0
  13. package/dist/src/choices/choiceFactory.js.map +1 -0
  14. package/dist/src/choices/findChoices.d.ts +28 -0
  15. package/dist/src/choices/findChoices.js +46 -0
  16. package/dist/src/choices/findChoices.js.map +1 -0
  17. package/dist/src/choices/findValues.d.ts +36 -0
  18. package/dist/src/choices/findValues.js +129 -0
  19. package/dist/src/choices/findValues.js.map +1 -0
  20. package/dist/src/choices/index.d.ts +11 -0
  21. package/dist/src/choices/index.js +28 -0
  22. package/dist/src/choices/index.js.map +1 -0
  23. package/dist/src/choices/modelResult.d.ts +11 -0
  24. package/dist/src/choices/modelResult.js +3 -0
  25. package/dist/src/choices/modelResult.js.map +1 -0
  26. package/dist/src/choices/recognizeChoices.d.ts +16 -0
  27. package/dist/src/choices/recognizeChoices.js +81 -0
  28. package/dist/src/choices/recognizeChoices.js.map +1 -0
  29. package/dist/src/choices/tokenizer.d.ts +25 -0
  30. package/dist/src/choices/tokenizer.js +73 -0
  31. package/dist/src/choices/tokenizer.js.map +1 -0
  32. package/dist/src/componentDialog.d.ts +178 -0
  33. package/dist/src/componentDialog.js +252 -0
  34. package/dist/src/componentDialog.js.map +1 -0
  35. package/dist/src/componentRegistration.d.ts +22 -0
  36. package/dist/src/componentRegistration.js +32 -0
  37. package/dist/src/componentRegistration.js.map +1 -0
  38. package/dist/src/configurable.d.ts +22 -0
  39. package/dist/src/configurable.js +60 -0
  40. package/dist/src/configurable.js.map +1 -0
  41. package/dist/src/configuration.d.ts +11 -0
  42. package/dist/src/configuration.js +17 -0
  43. package/dist/src/configuration.js.map +1 -0
  44. package/dist/src/converter.d.ts +13 -0
  45. package/dist/src/converter.js +7 -0
  46. package/dist/src/converter.js.map +1 -0
  47. package/dist/src/dialog.d.ts +184 -0
  48. package/dist/src/dialog.js +201 -0
  49. package/dist/src/dialog.js.map +1 -0
  50. package/dist/src/dialogContainer.d.ts +61 -0
  51. package/dist/src/dialogContainer.js +82 -0
  52. package/dist/src/dialogContainer.js.map +1 -0
  53. package/dist/src/dialogContext.d.ts +272 -0
  54. package/dist/src/dialogContext.js +444 -0
  55. package/dist/src/dialogContext.js.map +1 -0
  56. package/dist/src/dialogContextError.d.ts +27 -0
  57. package/dist/src/dialogContextError.js +39 -0
  58. package/dist/src/dialogContextError.js.map +1 -0
  59. package/dist/src/dialogEvent.d.ts +20 -0
  60. package/dist/src/dialogEvent.js +3 -0
  61. package/dist/src/dialogEvent.js.map +1 -0
  62. package/dist/src/dialogEvents.d.ts +15 -0
  63. package/dist/src/dialogEvents.js +20 -0
  64. package/dist/src/dialogEvents.js.map +1 -0
  65. package/dist/src/dialogHelper.d.ts +32 -0
  66. package/dist/src/dialogHelper.js +116 -0
  67. package/dist/src/dialogHelper.js.map +1 -0
  68. package/dist/src/dialogInstance.d.ts +30 -0
  69. package/dist/src/dialogInstance.js +3 -0
  70. package/dist/src/dialogInstance.js.map +1 -0
  71. package/dist/src/dialogManager.d.ts +73 -0
  72. package/dist/src/dialogManager.js +156 -0
  73. package/dist/src/dialogManager.js.map +1 -0
  74. package/dist/src/dialogReason.d.ts +35 -0
  75. package/dist/src/dialogReason.js +40 -0
  76. package/dist/src/dialogReason.js.map +1 -0
  77. package/dist/src/dialogSet.d.ts +85 -0
  78. package/dist/src/dialogSet.js +138 -0
  79. package/dist/src/dialogSet.js.map +1 -0
  80. package/dist/src/dialogTurnResult.d.ts +34 -0
  81. package/dist/src/dialogTurnResult.js +3 -0
  82. package/dist/src/dialogTurnResult.js.map +1 -0
  83. package/dist/src/dialogTurnStateConstants.d.ts +12 -0
  84. package/dist/src/dialogTurnStateConstants.js +17 -0
  85. package/dist/src/dialogTurnStateConstants.js.map +1 -0
  86. package/dist/src/dialogTurnStatus.d.ts +34 -0
  87. package/dist/src/dialogTurnStatus.js +39 -0
  88. package/dist/src/dialogTurnStatus.js.map +1 -0
  89. package/dist/src/dialogsAgentComponent.d.ts +17 -0
  90. package/dist/src/dialogsAgentComponent.js +65 -0
  91. package/dist/src/dialogsAgentComponent.js.map +1 -0
  92. package/dist/src/dialogsComponentRegistration.d.ts +28 -0
  93. package/dist/src/dialogsComponentRegistration.js +45 -0
  94. package/dist/src/dialogsComponentRegistration.js.map +1 -0
  95. package/dist/src/i18n.d.ts +15 -0
  96. package/dist/src/i18n.js +28 -0
  97. package/dist/src/i18n.js.map +1 -0
  98. package/dist/src/index.d.ts +29 -0
  99. package/dist/src/index.js +48 -0
  100. package/dist/src/index.js.map +1 -0
  101. package/dist/src/intentScore.d.ts +11 -0
  102. package/dist/src/intentScore.js +3 -0
  103. package/dist/src/intentScore.js.map +1 -0
  104. package/dist/src/memory/componentMemoryScopes.d.ts +18 -0
  105. package/dist/src/memory/componentMemoryScopes.js +54 -0
  106. package/dist/src/memory/componentMemoryScopes.js.map +1 -0
  107. package/dist/src/memory/componentPathResolvers.d.ts +18 -0
  108. package/dist/src/memory/componentPathResolvers.js +52 -0
  109. package/dist/src/memory/componentPathResolvers.js.map +1 -0
  110. package/dist/src/memory/dialogPath.d.ts +17 -0
  111. package/dist/src/memory/dialogPath.js +30 -0
  112. package/dist/src/memory/dialogPath.js.map +1 -0
  113. package/dist/src/memory/dialogStateManager.d.ts +156 -0
  114. package/dist/src/memory/dialogStateManager.js +598 -0
  115. package/dist/src/memory/dialogStateManager.js.map +1 -0
  116. package/dist/src/memory/index.d.ts +12 -0
  117. package/dist/src/memory/index.js +29 -0
  118. package/dist/src/memory/index.js.map +1 -0
  119. package/dist/src/memory/pathResolvers/aliasPathResolver.d.ts +25 -0
  120. package/dist/src/memory/pathResolvers/aliasPathResolver.js +37 -0
  121. package/dist/src/memory/pathResolvers/aliasPathResolver.js.map +1 -0
  122. package/dist/src/memory/pathResolvers/atAtPathResolver.d.ts +11 -0
  123. package/dist/src/memory/pathResolvers/atAtPathResolver.js +18 -0
  124. package/dist/src/memory/pathResolvers/atAtPathResolver.js.map +1 -0
  125. package/dist/src/memory/pathResolvers/atPathResolver.d.ts +20 -0
  126. package/dist/src/memory/pathResolvers/atPathResolver.js +46 -0
  127. package/dist/src/memory/pathResolvers/atPathResolver.js.map +1 -0
  128. package/dist/src/memory/pathResolvers/dollarPathResolver.d.ts +11 -0
  129. package/dist/src/memory/pathResolvers/dollarPathResolver.js +18 -0
  130. package/dist/src/memory/pathResolvers/dollarPathResolver.js.map +1 -0
  131. package/dist/src/memory/pathResolvers/hashPathResolver.d.ts +11 -0
  132. package/dist/src/memory/pathResolvers/hashPathResolver.js +18 -0
  133. package/dist/src/memory/pathResolvers/hashPathResolver.js.map +1 -0
  134. package/dist/src/memory/pathResolvers/index.d.ts +11 -0
  135. package/dist/src/memory/pathResolvers/index.js +28 -0
  136. package/dist/src/memory/pathResolvers/index.js.map +1 -0
  137. package/dist/src/memory/pathResolvers/pathResolver.d.ts +13 -0
  138. package/dist/src/memory/pathResolvers/pathResolver.js +7 -0
  139. package/dist/src/memory/pathResolvers/pathResolver.js.map +1 -0
  140. package/dist/src/memory/pathResolvers/percentPathResolver.d.ts +11 -0
  141. package/dist/src/memory/pathResolvers/percentPathResolver.js +18 -0
  142. package/dist/src/memory/pathResolvers/percentPathResolver.js.map +1 -0
  143. package/dist/src/memory/scopePath.d.ts +18 -0
  144. package/dist/src/memory/scopePath.js +23 -0
  145. package/dist/src/memory/scopePath.js.map +1 -0
  146. package/dist/src/memory/scopes/agentStateMemoryScope.d.ts +53 -0
  147. package/dist/src/memory/scopes/agentStateMemoryScope.js +82 -0
  148. package/dist/src/memory/scopes/agentStateMemoryScope.js.map +1 -0
  149. package/dist/src/memory/scopes/classMemoryScope.d.ts +29 -0
  150. package/dist/src/memory/scopes/classMemoryScope.js +65 -0
  151. package/dist/src/memory/scopes/classMemoryScope.js.map +1 -0
  152. package/dist/src/memory/scopes/conversationMemoryScope.d.ts +15 -0
  153. package/dist/src/memory/scopes/conversationMemoryScope.js +23 -0
  154. package/dist/src/memory/scopes/conversationMemoryScope.js.map +1 -0
  155. package/dist/src/memory/scopes/dialogClassMemoryScope.d.ts +19 -0
  156. package/dist/src/memory/scopes/dialogClassMemoryScope.js +42 -0
  157. package/dist/src/memory/scopes/dialogClassMemoryScope.js.map +1 -0
  158. package/dist/src/memory/scopes/dialogContextMemoryScope.d.ts +19 -0
  159. package/dist/src/memory/scopes/dialogContextMemoryScope.js +48 -0
  160. package/dist/src/memory/scopes/dialogContextMemoryScope.js.map +1 -0
  161. package/dist/src/memory/scopes/dialogMemoryScope.d.ts +32 -0
  162. package/dist/src/memory/scopes/dialogMemoryScope.js +74 -0
  163. package/dist/src/memory/scopes/dialogMemoryScope.js.map +1 -0
  164. package/dist/src/memory/scopes/index.d.ts +15 -0
  165. package/dist/src/memory/scopes/index.js +32 -0
  166. package/dist/src/memory/scopes/index.js.map +1 -0
  167. package/dist/src/memory/scopes/memoryScope.d.ts +52 -0
  168. package/dist/src/memory/scopes/memoryScope.js +54 -0
  169. package/dist/src/memory/scopes/memoryScope.js.map +1 -0
  170. package/dist/src/memory/scopes/settingsMemoryScope.d.ts +68 -0
  171. package/dist/src/memory/scopes/settingsMemoryScope.js +216 -0
  172. package/dist/src/memory/scopes/settingsMemoryScope.js.map +1 -0
  173. package/dist/src/memory/scopes/thisMemoryScope.d.ts +26 -0
  174. package/dist/src/memory/scopes/thisMemoryScope.js +43 -0
  175. package/dist/src/memory/scopes/thisMemoryScope.js.map +1 -0
  176. package/dist/src/memory/scopes/turnMemoryScope.d.ts +29 -0
  177. package/dist/src/memory/scopes/turnMemoryScope.js +52 -0
  178. package/dist/src/memory/scopes/turnMemoryScope.js.map +1 -0
  179. package/dist/src/memory/scopes/userMemoryScope.d.ts +15 -0
  180. package/dist/src/memory/scopes/userMemoryScope.js +23 -0
  181. package/dist/src/memory/scopes/userMemoryScope.js.map +1 -0
  182. package/dist/src/memory/turnPath.d.ts +21 -0
  183. package/dist/src/memory/turnPath.js +38 -0
  184. package/dist/src/memory/turnPath.js.map +1 -0
  185. package/dist/src/prompts/activityPrompt.d.ts +101 -0
  186. package/dist/src/prompts/activityPrompt.js +166 -0
  187. package/dist/src/prompts/activityPrompt.js.map +1 -0
  188. package/dist/src/prompts/attachmentPrompt.d.ts +37 -0
  189. package/dist/src/prompts/attachmentPrompt.js +55 -0
  190. package/dist/src/prompts/attachmentPrompt.js.map +1 -0
  191. package/dist/src/prompts/choicePrompt.d.ts +83 -0
  192. package/dist/src/prompts/choicePrompt.js +116 -0
  193. package/dist/src/prompts/choicePrompt.js.map +1 -0
  194. package/dist/src/prompts/confirmPrompt.d.ts +82 -0
  195. package/dist/src/prompts/confirmPrompt.js +163 -0
  196. package/dist/src/prompts/confirmPrompt.js.map +1 -0
  197. package/dist/src/prompts/datetimePrompt.d.ts +65 -0
  198. package/dist/src/prompts/datetimePrompt.js +109 -0
  199. package/dist/src/prompts/datetimePrompt.js.map +1 -0
  200. package/dist/src/prompts/index.d.ts +13 -0
  201. package/dist/src/prompts/index.js +30 -0
  202. package/dist/src/prompts/index.js.map +1 -0
  203. package/dist/src/prompts/numberPrompt.d.ts +55 -0
  204. package/dist/src/prompts/numberPrompt.js +134 -0
  205. package/dist/src/prompts/numberPrompt.js.map +1 -0
  206. package/dist/src/prompts/prompt.d.ts +256 -0
  207. package/dist/src/prompts/prompt.js +260 -0
  208. package/dist/src/prompts/prompt.js.map +1 -0
  209. package/dist/src/prompts/promptCultureModels.d.ts +72 -0
  210. package/dist/src/prompts/promptCultureModels.js +123 -0
  211. package/dist/src/prompts/promptCultureModels.js.map +1 -0
  212. package/dist/src/prompts/textPrompt.d.ts +54 -0
  213. package/dist/src/prompts/textPrompt.js +72 -0
  214. package/dist/src/prompts/textPrompt.js.map +1 -0
  215. package/dist/src/recognizer.d.ts +43 -0
  216. package/dist/src/recognizer.js +104 -0
  217. package/dist/src/recognizer.js.map +1 -0
  218. package/dist/src/recognizerResult.d.ts +19 -0
  219. package/dist/src/recognizerResult.js +24 -0
  220. package/dist/src/recognizerResult.js.map +1 -0
  221. package/dist/src/serviceCollection.d.ts +112 -0
  222. package/dist/src/serviceCollection.js +209 -0
  223. package/dist/src/serviceCollection.js.map +1 -0
  224. package/dist/src/stringUtils.d.ts +36 -0
  225. package/dist/src/stringUtils.js +62 -0
  226. package/dist/src/stringUtils.js.map +1 -0
  227. package/dist/src/template.d.ts +18 -0
  228. package/dist/src/template.js +7 -0
  229. package/dist/src/template.js.map +1 -0
  230. package/dist/src/waterfallDialog.d.ts +101 -0
  231. package/dist/src/waterfallDialog.js +179 -0
  232. package/dist/src/waterfallDialog.js.map +1 -0
  233. package/dist/src/waterfallStepContext.d.ts +71 -0
  234. package/dist/src/waterfallStepContext.js +78 -0
  235. package/dist/src/waterfallStepContext.js.map +1 -0
  236. package/package.json +49 -0
  237. package/src/agentComponent.ts +23 -0
  238. package/src/agentStateSet.ts +75 -0
  239. package/src/choices/choice.ts +16 -0
  240. package/src/choices/choiceFactory.ts +189 -0
  241. package/src/choices/findChoices.ts +70 -0
  242. package/src/choices/findValues.ts +179 -0
  243. package/src/choices/index.ts +11 -0
  244. package/src/choices/modelResult.ts +11 -0
  245. package/src/choices/recognizeChoices.ts +94 -0
  246. package/src/choices/tokenizer.ts +93 -0
  247. package/src/componentDialog.ts +306 -0
  248. package/src/componentRegistration.ts +30 -0
  249. package/src/configurable.ts +55 -0
  250. package/src/configuration.ts +22 -0
  251. package/src/converter.ts +15 -0
  252. package/src/dialog.ts +243 -0
  253. package/src/dialogContainer.ts +90 -0
  254. package/src/dialogContext.ts +607 -0
  255. package/src/dialogContextError.ts +50 -0
  256. package/src/dialogEvent.ts +23 -0
  257. package/src/dialogEvents.ts +16 -0
  258. package/src/dialogHelper.ts +154 -0
  259. package/src/dialogInstance.ts +32 -0
  260. package/src/dialogManager.ts +202 -0
  261. package/src/dialogReason.ts +40 -0
  262. package/src/dialogSet.ts +168 -0
  263. package/src/dialogTurnResult.ts +37 -0
  264. package/src/dialogTurnStateConstants.ts +13 -0
  265. package/src/dialogTurnStatus.ts +38 -0
  266. package/src/dialogsAgentComponent.ts +71 -0
  267. package/src/dialogsComponentRegistration.ts +49 -0
  268. package/src/i18n.ts +17 -0
  269. package/src/index.ts +31 -0
  270. package/src/intentScore.ts +11 -0
  271. package/src/memory/componentMemoryScopes.ts +28 -0
  272. package/src/memory/componentPathResolvers.ts +29 -0
  273. package/src/memory/dialogPath.ts +33 -0
  274. package/src/memory/dialogStateManager.ts +661 -0
  275. package/src/memory/index.ts +12 -0
  276. package/src/memory/pathResolvers/aliasPathResolver.ts +44 -0
  277. package/src/memory/pathResolvers/atAtPathResolver.ts +14 -0
  278. package/src/memory/pathResolvers/atPathResolver.ts +45 -0
  279. package/src/memory/pathResolvers/dollarPathResolver.ts +14 -0
  280. package/src/memory/pathResolvers/hashPathResolver.ts +14 -0
  281. package/src/memory/pathResolvers/index.ts +11 -0
  282. package/src/memory/pathResolvers/pathResolver.ts +14 -0
  283. package/src/memory/pathResolvers/percentPathResolver.ts +14 -0
  284. package/src/memory/scopePath.ts +19 -0
  285. package/src/memory/scopes/agentStateMemoryScope.ts +92 -0
  286. package/src/memory/scopes/classMemoryScope.ts +71 -0
  287. package/src/memory/scopes/conversationMemoryScope.ts +19 -0
  288. package/src/memory/scopes/dialogClassMemoryScope.ts +43 -0
  289. package/src/memory/scopes/dialogContextMemoryScope.ts +51 -0
  290. package/src/memory/scopes/dialogMemoryScope.ts +79 -0
  291. package/src/memory/scopes/index.ts +15 -0
  292. package/src/memory/scopes/memoryScope.ts +70 -0
  293. package/src/memory/scopes/settingsMemoryScope.ts +239 -0
  294. package/src/memory/scopes/thisMemoryScope.ts +44 -0
  295. package/src/memory/scopes/turnMemoryScope.ts +54 -0
  296. package/src/memory/scopes/userMemoryScope.ts +19 -0
  297. package/src/memory/turnPath.ts +45 -0
  298. package/src/prompts/activityPrompt.ts +202 -0
  299. package/src/prompts/attachmentPrompt.ts +62 -0
  300. package/src/prompts/choicePrompt.ts +176 -0
  301. package/src/prompts/confirmPrompt.ts +182 -0
  302. package/src/prompts/datetimePrompt.ts +110 -0
  303. package/src/prompts/index.ts +13 -0
  304. package/src/prompts/numberPrompt.ts +117 -0
  305. package/src/prompts/prompt.ts +459 -0
  306. package/src/prompts/promptCultureModels.ts +178 -0
  307. package/src/prompts/textPrompt.ts +82 -0
  308. package/src/recognizer.ts +127 -0
  309. package/src/recognizerResult.ts +37 -0
  310. package/src/serviceCollection.ts +305 -0
  311. package/src/stringUtils.ts +62 -0
  312. package/src/template.ts +20 -0
  313. package/src/waterfallDialog.ts +215 -0
  314. package/src/waterfallStepContext.ts +96 -0
  315. package/vendor/cldr-data/README.md +5 -0
  316. package/vendor/cldr-data/main/de/numbers.json +156 -0
  317. package/vendor/cldr-data/main/en/numbers.json +159 -0
  318. package/vendor/cldr-data/main/es/numbers.json +156 -0
  319. package/vendor/cldr-data/main/fr/numbers.json +157 -0
  320. package/vendor/cldr-data/main/ja/numbers.json +120 -0
  321. package/vendor/cldr-data/main/nl/numbers.json +156 -0
  322. package/vendor/cldr-data/main/pt/numbers.json +156 -0
  323. package/vendor/cldr-data/main/zh/numbers.json +214 -0
  324. package/vendor/cldr-data/supplemental/likelySubtags.json +1844 -0
  325. 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,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,YAAY,CAAC;oBACtD,OAAO,EAAE;wBACP,eAAe,EAAE,OAAO,CAAC,SAAS;wBAClC,QAAQ,EAAE,OAAO,CAAC,QAAQ;wBAC1B,YAAY,EAAE,OAAO,CAAC,YAAY;wBAClC,cAAc,EAAE,IAAI;qBACrB;iBACF,CAAA;YACH,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,cAAc,GAAG,SAAS,CAAA;QACjC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;QACtC,CAAC;IACH,CAAC;IAED;;;;;;;;;;;SAWK;IACK,KAAK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AmB,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
+ {"version":3,"file":"datetimePrompt.js","sourceRoot":"","sources":["../../../src/prompts/datetimePrompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,mFAAoE;AACpE,8DAA6E;AAC7E,qCAAyF;AAwBzF;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,eAA4B;IAM9D;;;;;;SAMK;IACL,YAAa,QAAgB,EAAE,SAAiD,EAAE,aAAsB;QACtG,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;QAC1B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED;;;;;;;;;;;SAWK;IACK,KAAK,CAAC,QAAQ,CACtB,OAAoB,EACpB,KAAU,EACV,OAA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ompt';
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;A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