@magmamath/students-features 0.3.3 → 0.4.0-rc.0

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 (234) hide show
  1. package/dist/commonjs/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
  2. package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js +6 -4
  3. package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
  4. package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js +12 -1
  5. package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
  6. package/dist/commonjs/features/chatbot/components/Chatbot.js +5 -1
  7. package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
  8. package/dist/commonjs/features/chatbot/context/ChatBotContext.js +17 -0
  9. package/dist/commonjs/features/chatbot/context/ChatBotContext.js.map +1 -0
  10. package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.js +58 -0
  11. package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.js.map +1 -0
  12. package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.js +99 -0
  13. package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.js.map +1 -0
  14. package/dist/commonjs/features/chatbot/index.js +0 -7
  15. package/dist/commonjs/features/chatbot/index.js.map +1 -1
  16. package/dist/commonjs/features/chatbot/model/ChatBotModel.js +136 -117
  17. package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
  18. package/dist/commonjs/features/chatbot/model/{ChatBotMessageHandler.js → ChatBotThreadManager.js} +28 -17
  19. package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js.map +1 -0
  20. package/dist/commonjs/features/chatbot/model/{api.js → ChatbotApi.js} +16 -1
  21. package/dist/commonjs/features/chatbot/model/ChatbotApi.js.map +1 -0
  22. package/dist/commonjs/features/chatbot/model/ChatsCacheModel.js +110 -0
  23. package/dist/commonjs/features/chatbot/model/ChatsCacheModel.js.map +1 -0
  24. package/dist/commonjs/features/chatbot/model/DefaultMessageCreator.js +0 -1
  25. package/dist/commonjs/features/chatbot/model/DefaultMessageCreator.js.map +1 -1
  26. package/dist/commonjs/features/chatbot/model/ThreadItem.js +21 -8
  27. package/dist/commonjs/features/chatbot/model/ThreadItem.js.map +1 -1
  28. package/dist/commonjs/features/chatbot/model/messagesHelper.js +1 -5
  29. package/dist/commonjs/features/chatbot/model/messagesHelper.js.map +1 -1
  30. package/dist/commonjs/features/chatbot/model/t2s.js +0 -6
  31. package/dist/commonjs/features/chatbot/model/t2s.js.map +1 -1
  32. package/dist/commonjs/features/chatbot/model/translation.helpers.js.map +1 -1
  33. package/dist/commonjs/features/chatbot/model/translation.js +54 -45
  34. package/dist/commonjs/features/chatbot/model/translation.js.map +1 -1
  35. package/dist/commonjs/features/chatbot/types/api.types.js +4 -0
  36. package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
  37. package/dist/commonjs/features/chatbot/types/units.types.js +2 -0
  38. package/dist/commonjs/features/chatbot/types/units.types.js.map +1 -0
  39. package/dist/commonjs/lib/effector/createEntityFieldStore.js +4 -0
  40. package/dist/commonjs/lib/effector/createEntityFieldStore.js.map +1 -1
  41. package/dist/commonjs/lib/helpers/randomElements.js +24 -0
  42. package/dist/commonjs/lib/helpers/randomElements.js.map +1 -0
  43. package/dist/commonjs/shared/icons/HighlighterIcon.js +36 -0
  44. package/dist/commonjs/shared/icons/HighlighterIcon.js.map +1 -0
  45. package/dist/commonjs/shared/icons/StopIcon.js +33 -0
  46. package/dist/commonjs/shared/icons/StopIcon.js.map +1 -0
  47. package/dist/commonjs/shared/icons/icon.types.js +4 -0
  48. package/dist/module/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
  49. package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js +6 -4
  50. package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
  51. package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js +12 -1
  52. package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
  53. package/dist/module/features/chatbot/components/Chatbot.js +6 -2
  54. package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
  55. package/dist/module/features/chatbot/context/ChatBotContext.js +12 -0
  56. package/dist/module/features/chatbot/context/ChatBotContext.js.map +1 -0
  57. package/dist/module/features/chatbot/errorSpotting/ErrorSpottingButton.js +52 -0
  58. package/dist/module/features/chatbot/errorSpotting/ErrorSpottingButton.js.map +1 -0
  59. package/dist/module/features/chatbot/errorSpotting/ErrorSpottingModel.js +94 -0
  60. package/dist/module/features/chatbot/errorSpotting/ErrorSpottingModel.js.map +1 -0
  61. package/dist/module/features/chatbot/index.js +0 -1
  62. package/dist/module/features/chatbot/index.js.map +1 -1
  63. package/dist/module/features/chatbot/model/ChatBotModel.js +138 -119
  64. package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
  65. package/dist/module/features/chatbot/model/{ChatBotMessageHandler.js → ChatBotThreadManager.js} +26 -15
  66. package/dist/module/features/chatbot/model/ChatBotThreadManager.js.map +1 -0
  67. package/dist/module/features/chatbot/model/{api.js → ChatbotApi.js} +16 -1
  68. package/dist/module/features/chatbot/model/ChatbotApi.js.map +1 -0
  69. package/dist/module/features/chatbot/model/ChatsCacheModel.js +104 -0
  70. package/dist/module/features/chatbot/model/ChatsCacheModel.js.map +1 -0
  71. package/dist/module/features/chatbot/model/DefaultMessageCreator.js +0 -1
  72. package/dist/module/features/chatbot/model/DefaultMessageCreator.js.map +1 -1
  73. package/dist/module/features/chatbot/model/ThreadItem.js +21 -8
  74. package/dist/module/features/chatbot/model/ThreadItem.js.map +1 -1
  75. package/dist/module/features/chatbot/model/messagesHelper.js +1 -5
  76. package/dist/module/features/chatbot/model/messagesHelper.js.map +1 -1
  77. package/dist/module/features/chatbot/model/t2s.js +1 -7
  78. package/dist/module/features/chatbot/model/t2s.js.map +1 -1
  79. package/dist/module/features/chatbot/model/translation.helpers.js.map +1 -1
  80. package/dist/module/features/chatbot/model/translation.js +54 -45
  81. package/dist/module/features/chatbot/model/translation.js.map +1 -1
  82. package/dist/module/features/chatbot/types/api.types.js +2 -0
  83. package/dist/module/features/chatbot/types/model.types.js.map +1 -1
  84. package/dist/module/features/chatbot/types/units.types.js +2 -0
  85. package/dist/module/features/chatbot/types/units.types.js.map +1 -0
  86. package/dist/module/lib/effector/createEntityFieldStore.js +4 -0
  87. package/dist/module/lib/effector/createEntityFieldStore.js.map +1 -1
  88. package/dist/module/lib/helpers/randomElements.js +20 -0
  89. package/dist/module/lib/helpers/randomElements.js.map +1 -0
  90. package/dist/module/shared/icons/HighlighterIcon.js +29 -0
  91. package/dist/module/shared/icons/HighlighterIcon.js.map +1 -0
  92. package/dist/module/shared/icons/StopIcon.js +26 -0
  93. package/dist/module/shared/icons/StopIcon.js.map +1 -0
  94. package/dist/module/shared/icons/icon.types.js +2 -0
  95. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts +1 -0
  96. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
  97. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +1 -1
  98. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -1
  99. package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -1
  100. package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -1
  101. package/dist/typescript/commonjs/features/chatbot/context/ChatBotContext.d.ts +8 -0
  102. package/dist/typescript/commonjs/features/chatbot/context/ChatBotContext.d.ts.map +1 -0
  103. package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts +3 -0
  104. package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts.map +1 -0
  105. package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts +28 -0
  106. package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts.map +1 -0
  107. package/dist/typescript/commonjs/features/chatbot/index.d.ts +4 -3
  108. package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
  109. package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +19 -14
  110. package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
  111. package/dist/typescript/{module/features/chatbot/model/ChatBotMessageHandler.d.ts → commonjs/features/chatbot/model/ChatBotThreadManager.d.ts} +11 -8
  112. package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -0
  113. package/dist/typescript/commonjs/features/chatbot/model/{api.d.ts → ChatbotApi.d.ts} +4 -3
  114. package/dist/typescript/commonjs/features/chatbot/model/ChatbotApi.d.ts.map +1 -0
  115. package/dist/typescript/commonjs/features/chatbot/model/ChatsCacheModel.d.ts +26 -0
  116. package/dist/typescript/commonjs/features/chatbot/model/ChatsCacheModel.d.ts.map +1 -0
  117. package/dist/typescript/commonjs/features/chatbot/model/DefaultMessageCreator.d.ts +3 -2
  118. package/dist/typescript/commonjs/features/chatbot/model/DefaultMessageCreator.d.ts.map +1 -1
  119. package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts +12 -6
  120. package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts.map +1 -1
  121. package/dist/typescript/commonjs/features/chatbot/model/messagesHelper.d.ts +3 -4
  122. package/dist/typescript/commonjs/features/chatbot/model/messagesHelper.d.ts.map +1 -1
  123. package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts +2 -4
  124. package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts.map +1 -1
  125. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts +7 -8
  126. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +1 -1
  127. package/dist/typescript/commonjs/features/chatbot/model/translation.helpers.d.ts +2 -1
  128. package/dist/typescript/commonjs/features/chatbot/model/translation.helpers.d.ts.map +1 -1
  129. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +2 -11
  130. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
  131. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +26 -19
  132. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
  133. package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts +2 -1
  134. package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts.map +1 -1
  135. package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts +31 -0
  136. package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts.map +1 -0
  137. package/dist/typescript/commonjs/lib/effector/createEntityFieldStore.d.ts +2 -0
  138. package/dist/typescript/commonjs/lib/effector/createEntityFieldStore.d.ts.map +1 -1
  139. package/dist/typescript/commonjs/lib/helpers/randomElements.d.ts +2 -0
  140. package/dist/typescript/commonjs/lib/helpers/randomElements.d.ts.map +1 -0
  141. package/dist/typescript/commonjs/shared/icons/HighlighterIcon.d.ts +4 -0
  142. package/dist/typescript/commonjs/shared/icons/HighlighterIcon.d.ts.map +1 -0
  143. package/dist/typescript/commonjs/shared/icons/StopIcon.d.ts +4 -0
  144. package/dist/typescript/commonjs/shared/icons/StopIcon.d.ts.map +1 -0
  145. package/dist/typescript/commonjs/shared/icons/icon.types.d.ts +2 -0
  146. package/dist/typescript/commonjs/shared/icons/icon.types.d.ts.map +1 -1
  147. package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts +1 -0
  148. package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
  149. package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +1 -1
  150. package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -1
  151. package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -1
  152. package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -1
  153. package/dist/typescript/module/features/chatbot/context/ChatBotContext.d.ts +8 -0
  154. package/dist/typescript/module/features/chatbot/context/ChatBotContext.d.ts.map +1 -0
  155. package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts +3 -0
  156. package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts.map +1 -0
  157. package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts +28 -0
  158. package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts.map +1 -0
  159. package/dist/typescript/module/features/chatbot/index.d.ts +4 -3
  160. package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
  161. package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +19 -14
  162. package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
  163. package/dist/typescript/{commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts → module/features/chatbot/model/ChatBotThreadManager.d.ts} +11 -8
  164. package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -0
  165. package/dist/typescript/module/features/chatbot/model/{api.d.ts → ChatbotApi.d.ts} +4 -3
  166. package/dist/typescript/module/features/chatbot/model/ChatbotApi.d.ts.map +1 -0
  167. package/dist/typescript/module/features/chatbot/model/ChatsCacheModel.d.ts +26 -0
  168. package/dist/typescript/module/features/chatbot/model/ChatsCacheModel.d.ts.map +1 -0
  169. package/dist/typescript/module/features/chatbot/model/DefaultMessageCreator.d.ts +3 -2
  170. package/dist/typescript/module/features/chatbot/model/DefaultMessageCreator.d.ts.map +1 -1
  171. package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts +12 -6
  172. package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts.map +1 -1
  173. package/dist/typescript/module/features/chatbot/model/messagesHelper.d.ts +3 -4
  174. package/dist/typescript/module/features/chatbot/model/messagesHelper.d.ts.map +1 -1
  175. package/dist/typescript/module/features/chatbot/model/t2s.d.ts +2 -4
  176. package/dist/typescript/module/features/chatbot/model/t2s.d.ts.map +1 -1
  177. package/dist/typescript/module/features/chatbot/model/translation.d.ts +7 -8
  178. package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +1 -1
  179. package/dist/typescript/module/features/chatbot/model/translation.helpers.d.ts +2 -1
  180. package/dist/typescript/module/features/chatbot/model/translation.helpers.d.ts.map +1 -1
  181. package/dist/typescript/module/features/chatbot/types/api.types.d.ts +2 -11
  182. package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
  183. package/dist/typescript/module/features/chatbot/types/model.types.d.ts +26 -19
  184. package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
  185. package/dist/typescript/module/features/chatbot/types/translation.types.d.ts +2 -1
  186. package/dist/typescript/module/features/chatbot/types/translation.types.d.ts.map +1 -1
  187. package/dist/typescript/module/features/chatbot/types/units.types.d.ts +31 -0
  188. package/dist/typescript/module/features/chatbot/types/units.types.d.ts.map +1 -0
  189. package/dist/typescript/module/lib/effector/createEntityFieldStore.d.ts +2 -0
  190. package/dist/typescript/module/lib/effector/createEntityFieldStore.d.ts.map +1 -1
  191. package/dist/typescript/module/lib/helpers/randomElements.d.ts +2 -0
  192. package/dist/typescript/module/lib/helpers/randomElements.d.ts.map +1 -0
  193. package/dist/typescript/module/shared/icons/HighlighterIcon.d.ts +4 -0
  194. package/dist/typescript/module/shared/icons/HighlighterIcon.d.ts.map +1 -0
  195. package/dist/typescript/module/shared/icons/StopIcon.d.ts +4 -0
  196. package/dist/typescript/module/shared/icons/StopIcon.d.ts.map +1 -0
  197. package/dist/typescript/module/shared/icons/icon.types.d.ts +2 -0
  198. package/dist/typescript/module/shared/icons/icon.types.d.ts.map +1 -1
  199. package/package.json +2 -2
  200. package/src/features/chatbot/components/ChatMessage/ChatMessage.tsx +1 -0
  201. package/src/features/chatbot/components/ChatMessage/ReceivedMessage.tsx +3 -0
  202. package/src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx +14 -0
  203. package/src/features/chatbot/components/Chatbot.tsx +3 -2
  204. package/src/features/chatbot/context/ChatBotContext.ts +18 -0
  205. package/src/features/chatbot/errorSpotting/ErrorSpottingButton.tsx +53 -0
  206. package/src/features/chatbot/errorSpotting/ErrorSpottingModel.ts +116 -0
  207. package/src/features/chatbot/index.ts +3 -3
  208. package/src/features/chatbot/model/ChatBotModel.ts +123 -124
  209. package/src/features/chatbot/model/{ChatBotMessageHandler.ts → ChatBotThreadManager.ts} +28 -16
  210. package/src/features/chatbot/model/{api.ts → ChatbotApi.ts} +19 -2
  211. package/src/features/chatbot/model/ChatsCacheModel.ts +94 -0
  212. package/src/features/chatbot/model/DefaultMessageCreator.ts +3 -3
  213. package/src/features/chatbot/model/ThreadItem.ts +20 -9
  214. package/src/features/chatbot/model/messagesHelper.ts +2 -6
  215. package/src/features/chatbot/model/t2s.ts +3 -10
  216. package/src/features/chatbot/model/translation.helpers.ts +2 -1
  217. package/src/features/chatbot/model/translation.ts +52 -46
  218. package/src/features/chatbot/types/api.types.ts +2 -12
  219. package/src/features/chatbot/types/model.types.ts +38 -26
  220. package/src/features/chatbot/types/translation.types.ts +2 -1
  221. package/src/features/chatbot/types/units.types.ts +34 -0
  222. package/src/lib/effector/createEntityFieldStore.ts +9 -1
  223. package/src/lib/helpers/randomElements.ts +22 -0
  224. package/src/shared/icons/HighlighterIcon.tsx +21 -0
  225. package/src/shared/icons/StopIcon.tsx +17 -0
  226. package/src/shared/icons/icon.types.ts +9 -6
  227. package/dist/commonjs/features/chatbot/model/ChatBotMessageHandler.js.map +0 -1
  228. package/dist/commonjs/features/chatbot/model/api.js.map +0 -1
  229. package/dist/module/features/chatbot/model/ChatBotMessageHandler.js.map +0 -1
  230. package/dist/module/features/chatbot/model/api.js.map +0 -1
  231. package/dist/typescript/commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts.map +0 -1
  232. package/dist/typescript/commonjs/features/chatbot/model/api.d.ts.map +0 -1
  233. package/dist/typescript/module/features/chatbot/model/ChatBotMessageHandler.d.ts.map +0 -1
  234. package/dist/typescript/module/features/chatbot/model/api.d.ts.map +0 -1
@@ -1,30 +1,33 @@
1
1
  import type { Store } from 'effector';
2
- import { GetAlternativesResponse, PostMessagePayload, PostMessageResponse, GoogleTranslatePayload, GoogleTranslateResponse, GoogleText2SpeechPayload, GoogleText2SpeechResponse, ChatAnswer, GetAlternativesPayload, Stroke } from './api.types';
2
+ import { ChatHintPayload, ChatHintResponse, GetAlternativesPayload, GetAlternativesResponse, GoogleText2SpeechPayload, GoogleText2SpeechResponse, GoogleTranslatePayload, GoogleTranslateResponse, PostMessagePayload, PostMessageResponse } from './api.types';
3
3
  import { ExtendWithOptional } from '../../../lib/helpers/types';
4
- export type ConversationMessage = {
5
- id: string;
6
- message: string;
7
- threadId: string;
8
- options: ChatAnswer[];
9
- isOwnMessage: boolean;
10
- translatedMessage?: string;
11
- endMessage?: boolean;
12
- };
4
+ import { ChatAnswer, ConversationMessage, FullStrokeData } from './units.types';
13
5
  export type ChatbotMessages = {
14
6
  error: ConversationMessage;
15
7
  start: ConversationMessage;
16
8
  endMessage: ConversationMessage;
17
9
  anotherHintOption: ChatAnswer;
18
10
  };
11
+ export type SpotErrorPayload = {
12
+ strokes: FullStrokeData[];
13
+ };
14
+ export type SpotErrorResponse = {
15
+ strokesIds: string[];
16
+ };
17
+ export type ChatbotApiRequests = {
18
+ getAlternatives: (props: GetAlternativesPayload) => Promise<GetAlternativesResponse>;
19
+ postMessage: (props: PostMessagePayload) => Promise<PostMessageResponse>;
20
+ postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>;
21
+ postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>;
22
+ spotError: (props: SpotErrorPayload) => Promise<SpotErrorResponse>;
23
+ };
19
24
  export type ChatbotModelProps = {
20
25
  $key?: Store<string>;
21
- api: {
22
- getAlternatives: (props: GetAlternativesPayload) => Promise<GetAlternativesResponse>;
23
- postMessage: (props: PostMessagePayload) => Promise<PostMessageResponse>;
24
- postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>;
25
- postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>;
26
+ api: Omit<ChatbotApiRequests, 'postMessage'> & {
27
+ requestHint: (props: ChatHintPayload) => Promise<ChatHintResponse>;
26
28
  };
27
29
  messages: ChatbotMessages;
30
+ threadMessagesLimit?: number;
28
31
  };
29
32
  export type SendHelpParams = {
30
33
  message: string;
@@ -32,8 +35,6 @@ export type SendHelpParams = {
32
35
  };
33
36
  export type SendHelpProps = SendHelpParams & {
34
37
  key: string;
35
- isTranslated: boolean;
36
- threadId: string;
37
38
  context: ChatbotContext | null;
38
39
  };
39
40
  export type SetHintMessageProps = {
@@ -55,9 +56,14 @@ export type ChatbotRenderer = {
55
56
  variant: MessageVariant;
56
57
  withTextToSpeech: boolean;
57
58
  };
58
- export type CreateMessageResponse = ExtendWithOptional<PostMessageResponse, ConversationMessage>;
59
+ export type CreateMessageResponse = ExtendWithOptional<Omit<PostMessageResponse, 'thread'>, ConversationMessage>;
60
+ type GetVisibleStrokesResponse = {
61
+ strokes: FullStrokeData[];
62
+ validationKey: string;
63
+ };
59
64
  export type IChatDrawBoardAdapter = {
60
- getVisibleStrokes(): Promise<Stroke[] | null>;
65
+ $strokesValidationKey: Store<string | null>;
66
+ getVisibleStrokes(): Promise<GetVisibleStrokesResponse | null>;
61
67
  };
62
68
  export type ChatbotContext = {
63
69
  language: string;
@@ -67,4 +73,5 @@ export type ChatbotContext = {
67
73
  translationTargetLanguage: string;
68
74
  imageDescription?: string;
69
75
  };
76
+ export {};
70
77
  //# sourceMappingURL=model.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/model.types.ts"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AC,EAAE,MAAM,CAAA;CAC1B,CAAA"}
1
+ {"version":3,"file":"model.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/model.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE/E,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,mBAAmB,CAAA;IAC1B,KAAK,EAAE,mBAAmB,CAAA;IAC1B,UAAU,EAAE,mBAAmB,CAAA;IAC/B,iBAAiB,EAAE,UAAU,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,cAAc,EAAE,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAA;IACpF,WAAW,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACxE,iBAAiB,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAA;IACtF,gBAAgB,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAA;IACzF,SAAS,EAAE,CAAC,KAAK,EAAE,gB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AK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,qBAAqB,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAC3C,iBAAiB,IAAI,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;CAC/D,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC1B,yBAAyB,EAAE,MAAM,CAAA;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA"}
@@ -1,11 +1,12 @@
1
- import { ConversationMessage } from './model.types';
2
1
  import { GetAlternativesResponse } from './api.types';
2
+ import { ConversationMessage } from './units.types';
3
3
  export type TranslateBatchFxProps = {
4
4
  messages: ConversationMessage[];
5
5
  targetLanguage: string;
6
6
  alternatives: GetAlternativesResponse | null;
7
7
  };
8
8
  export type TranslateMessageFxProps = {
9
+ preventTranslate?: boolean;
9
10
  messages: ConversationMessage[];
10
11
  targetLanguage: string;
11
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"translation.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/translation.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,uBAAuB,GAAG,IAAI,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,YAAY,EAAE,uBAAuB,CAAA;IACrC,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAC7B,CAAA;AACD,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,uBAAuB,GAAG,IAAI,CAAA;IAC5C,WAAW,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAC7C,CAAA;AACD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC5B,YAAY,EAAE;QACZ,KAAK,EAAE,MAAM,EAAE,CAAA;QACf,OAAO,EAAE,MAAM,EAAE,CAAA;KAClB,GAAG,IAAI,CAAA;CACT,CAAA;AAED,MAAM,MAAM,qBAAqB,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI;IACzE,QAAQ,EAAE,IAAI,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA"}
1
+ {"version":3,"file":"translation.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/translation.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,uBAAuB,GAAG,IAAI,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,YAAY,EAAE,uBAAuB,CAAA;IACrC,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAC7B,CAAA;AACD,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,uBAAuB,GAAG,IAAI,CAAA;IAC5C,WAAW,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAC7C,CAAA;AACD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC5B,YAAY,EAAE;QACZ,KAAK,EAAE,MAAM,EAAE,CAAA;QACf,OAAO,EAAE,MAAM,EAAE,CAAA;KAClB,GAAG,IAAI,CAAA;CACT,CAAA;AAED,MAAM,MAAM,qBAAqB,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI;IACzE,QAAQ,EAAE,IAAI,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA"}
@@ -0,0 +1,31 @@
1
+ export type Stroke = {
2
+ x: number[];
3
+ y: number[];
4
+ };
5
+ export type FullStrokeData = Stroke & {
6
+ id?: string;
7
+ };
8
+ export type IThreadItem = {
9
+ key: string | null;
10
+ strokes: FullStrokeData[] | null;
11
+ history: string[];
12
+ };
13
+ export type ChatAnswer = {
14
+ text: string;
15
+ promptKey: string;
16
+ translatedText?: string;
17
+ };
18
+ export type ConversationMessage = {
19
+ id: string;
20
+ message: string;
21
+ options: ChatAnswer[];
22
+ isOwnMessage: boolean;
23
+ translatedMessage?: string;
24
+ endMessage?: boolean;
25
+ };
26
+ export type ChatItem = {
27
+ messages: ConversationMessage[];
28
+ isAvailable: boolean;
29
+ currentThread: IThreadItem | null;
30
+ };
31
+ //# sourceMappingURL=units.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/units.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG;IACnB,CAAC,EAAE,MAAM,EAAE,CAAA;IACX,CAAC,EAAE,MAAM,EAAE,CAAA;CACZ,CAAA;AACD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG;IACpC,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;IAChC,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,UAAU,EAAE,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,WAAW,GAAG,IAAI,CAAA;CAClC,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { Event } from 'effector';
1
2
  type UpdateField<T> = {
2
3
  key: string;
3
4
  } & ({
@@ -11,6 +12,7 @@ export declare class EntityFieldStore<T> {
11
12
  readonly setField: import("effector").EventCallable<UpdateField<T>>;
12
13
  readonly reset: import("effector").EventCallable<void>;
13
14
  readonly $state: import("effector").StoreWritable<Record<string, T>>;
15
+ on<EV>(event: Event<EV>, fn: (state: Record<string, T>, payload: EV) => Record<string, T> | void): this;
14
16
  }
15
17
  export declare function createEntityFieldStore<T>(): EntityFieldStore<T>;
16
18
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"createEntityFieldStore.d.ts","sourceRoot":"","sources":["../../../../../src/lib/effector/createEntityFieldStore.ts"],"names":[],"mappings":"AAEA,KAAK,WAAW,CAAC,CAAC,IAAI;IACpB,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,CAAC;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,EAAE,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAI,CAAA;CAAE,CAAC,CAAA;AAEnF,qBAAa,gBAAgB,CAAC,CAAC;IAC7B,SAAgB,QAAQ,mDAAgC;IACxD,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,MAAM,sDAUF;CACrB;AAED,wBAAgB,sBAAsB,CAAC,CAAC,yBAEvC"}
1
+ {"version":3,"file":"createEntityFieldStore.d.ts","sourceRoot":"","sources":["../../../../../src/lib/effector/createEntityFieldStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,EAAE,MAAM,UAAU,CAAA;AAE1D,KAAK,WAAW,CAAC,CAAC,IAAI;IACpB,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,CAAC;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,EAAE,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAI,CAAA;CAAE,CAAC,CAAA;AAEnF,qBAAa,gBAAgB,CAAC,CAAC;IAC7B,SAAgB,QAAQ,mDAAgC;IACxD,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,MAAM,sDAUF;IAEb,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,EAChB,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,IAAI;CAK1E;AAED,wBAAgB,sBAAsB,CAAC,CAAC,yBAEvC"}
@@ -0,0 +1,2 @@
1
+ export declare function getRandomElements<T>(array: T[], limit?: number): T[];
2
+ //# sourceMappingURL=randomElements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"randomElements.d.ts","sourceRoot":"","sources":["../../../../../src/lib/helpers/randomElements.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,SAAe,GAAG,CAAC,EAAE,CAqB1E"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { IconProps } from './icon.types';
3
+ export declare function HighlighterIcon({ size, color, style }: IconProps): React.JSX.Element;
4
+ //# sourceMappingURL=HighlighterIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HighlighterIcon.d.ts","sourceRoot":"","sources":["../../../../../src/shared/icons/HighlighterIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGxC,wBAAgB,eAAe,CAAC,EAAE,IAAS,EAAE,KAAwB,EAAE,KAAK,EAAE,EAAE,SAAS,qBAexF"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { IconProps } from './icon.types';
3
+ export declare function StopIcon({ size, color, style }: IconProps): React.JSX.Element;
4
+ //# sourceMappingURL=StopIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StopIcon.d.ts","sourceRoot":"","sources":["../../../../../src/shared/icons/StopIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGxC,wBAAgB,QAAQ,CAAC,EAAE,IAAS,EAAE,KAAwB,EAAE,KAAK,EAAE,EAAE,SAAS,qBAWjF"}
@@ -1,3 +1,4 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
1
2
  export type IconProps = {
2
3
  color?: string;
3
4
  className?: string;
@@ -5,5 +6,6 @@ export type IconProps = {
5
6
  strokeWidth?: string;
6
7
  width?: number;
7
8
  height?: number;
9
+ style?: StyleProp<ViewStyle>;
8
10
  };
9
11
  //# sourceMappingURL=icon.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"icon.types.d.ts","sourceRoot":"","sources":["../../../../../src/shared/icons/icon.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA"}
1
+ {"version":3,"file":"icon.types.d.ts","sourceRoot":"","sources":["../../../../../src/shared/icons/icon.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEnD,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAC7B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magmamath/students-features",
3
- "version": "0.3.3",
3
+ "version": "0.4.0-rc.0",
4
4
  "description": "Magmamath features library",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/commonjs/index.js",
@@ -27,7 +27,7 @@
27
27
  "react-native-svg": "^15.10.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@magmamath/react-native-ui": "0.3.22",
30
+ "@magmamath/react-native-ui": "0.4.1-rc.0",
31
31
  "@react-native/eslint-config": "^0.73.1",
32
32
  "@release-it/conventional-changelog": "^9.0.2",
33
33
  "@types/jest": "^29.5.5",
@@ -13,6 +13,7 @@ type ChatMessageProps = {
13
13
  withTextToSpeech?: boolean
14
14
  audioStatus: AudioStatus
15
15
  renderer?: (props: ChatbotRenderer) => ReactNode
16
+ withErrorSpotting?: boolean
16
17
  }
17
18
 
18
19
  export type VariantProps = Omit<ChatMessageProps, 'variant'>
@@ -4,6 +4,7 @@ import { VariantProps } from './ChatMessage'
4
4
  import { ChatbotIcon } from '../../../../shared/icons/ChatbotIcon'
5
5
  import { MessageTextToSpeech } from './MessageTextToSpeech'
6
6
  import { MessageVariant } from '../../types/model.types'
7
+ import { ErrorSpottingButton } from '../../errorSpotting/ErrorSpottingButton'
7
8
 
8
9
  export const ReceivedMessage = ({
9
10
  message,
@@ -13,6 +14,7 @@ export const ReceivedMessage = ({
13
14
  audioStatus,
14
15
  renderer,
15
16
  withTextToSpeech = true,
17
+ withErrorSpotting,
16
18
  }: VariantProps) => (
17
19
  <View style={styles.container}>
18
20
  <View style={styles.icon}>
@@ -24,6 +26,7 @@ export const ReceivedMessage = ({
24
26
  {renderer
25
27
  ? renderer({ message, variant: MessageVariant.RECEIVED, withTextToSpeech })
26
28
  : message}
29
+ {!!withErrorSpotting && <ErrorSpottingButton />}
27
30
  </Text>
28
31
  {withTextToSpeech && (
29
32
  <MessageTextToSpeech
@@ -7,6 +7,7 @@ import { MessageLoader } from '../ChatMessage/MessageLoader'
7
7
  import { Alternatives } from '../Alternatives/Alternatives'
8
8
  import { AUDIO_CONFIG, DEFAULT_VOICE, TEXT_TO_SPEECH_CONFIG } from '../../constants'
9
9
  import { MessageVariant, ChatbotRenderer } from '../../types/model.types'
10
+ import { ConversationMessage } from '../../types/units.types'
10
11
 
11
12
  type ChatbotMessagesProps = {
12
13
  model: ChatbotModel
@@ -26,6 +27,16 @@ const BOTTOM_OFFSET = Platform.select({
26
27
  default: 294,
27
28
  })
28
29
 
30
+ function findListReceivedMessage(messages: ConversationMessage[]) {
31
+ let i = messages.length - 1
32
+ while (i >= 2) {
33
+ const message = messages[i]
34
+ if (!message.isOwnMessage && !message.endMessage) return messages[i]
35
+ i--
36
+ }
37
+ return null
38
+ }
39
+
29
40
  export const ChatbotMessages = ({
30
41
  model,
31
42
  isHintFeedback,
@@ -63,6 +74,8 @@ export const ChatbotMessages = ({
63
74
  void model.sendHelpRequestFx({ message, translatedMessage })
64
75
  }
65
76
 
77
+ const lastReceivedMessage = findListReceivedMessage(messages)
78
+
66
79
  return (
67
80
  <View style={[styles.container, { maxHeight: MAX_HEIGHT }]}>
68
81
  <ScrollView
@@ -89,6 +102,7 @@ export const ChatbotMessages = ({
89
102
  isTextToSpeechPending={isTextToSpeechPending}
90
103
  variant={isOwnMessage ? MessageVariant.SENT : MessageVariant.RECEIVED}
91
104
  withTextToSpeech={isTextToSpeechEnabled && !isOwnMessage}
105
+ withErrorSpotting={!isHelpRequestPending && lastReceivedMessage?.id === id}
92
106
  />
93
107
  ))}
94
108
 
@@ -6,6 +6,7 @@ import { ChatControls } from './ChatControls/ChatControls'
6
6
  import { AUDIO_CONFIG, DEFAULT_VOICE } from '../constants'
7
7
  import { ChatbotRenderer } from '../types/model.types'
8
8
  import React from 'react'
9
+ import { ChatBotContext } from '../context/ChatBotContext'
9
10
 
10
11
  type ChatbotProps = {
11
12
  model: ChatbotModel
@@ -48,7 +49,7 @@ export const Chatbot = ({
48
49
  }
49
50
 
50
51
  return (
51
- <>
52
+ <ChatBotContext.Provider value={{ model }}>
52
53
  <ChatbotMessages
53
54
  model={model}
54
55
  renderer={renderer}
@@ -67,6 +68,6 @@ export const Chatbot = ({
67
68
  ButtonWrapper={ButtonWrapper}
68
69
  iconSize={iconSize}
69
70
  />
70
- </>
71
+ </ChatBotContext.Provider>
71
72
  )
72
73
  }
@@ -0,0 +1,18 @@
1
+ import { createContext, useContext } from 'react'
2
+ import { ChatbotModel } from '../model/ChatBotModel'
3
+
4
+ type ChatBotContextProps = {
5
+ model: ChatbotModel
6
+ }
7
+
8
+ export const ChatBotContext = createContext<ChatBotContextProps | null>(null)
9
+
10
+ export function useChatModel() {
11
+ const context = useContext(ChatBotContext)
12
+ if (!context) {
13
+ throw new Error(
14
+ 'Something went wrong, you are probably trying to use component that is supposed to be inside ChatBotContext.Provider',
15
+ )
16
+ }
17
+ return context.model
18
+ }
@@ -0,0 +1,53 @@
1
+ import React from 'react'
2
+ import { Button, COLORS, StopIcon } from '@magmamath/react-native-ui'
3
+ import { useChatModel } from '../context/ChatBotContext'
4
+ import { useStoreMap, useUnit } from 'effector-react'
5
+ import { StyleSheet, View } from 'react-native'
6
+ import { HighlighterIcon } from '../../../shared/icons/HighlighterIcon'
7
+
8
+ export const ErrorSpottingButton = () => {
9
+ const model = useChatModel()
10
+ const activeErrorSpotting = useUnit(model.errorSpotting.$activeData)
11
+ const validationKey = useUnit(model.errorSpotting.$validationKey)
12
+ const isLoading = useUnit(model.errorSpotting.$isLoading)
13
+ const currentThread = useStoreMap(model.$currentChatData, (chatData) => chatData.currentThread)
14
+
15
+ if (!currentThread?.strokes) return null
16
+
17
+ const isActive = !!activeErrorSpotting?.isActive
18
+ return (
19
+ <View style={styles.container}>
20
+ <Button
21
+ style={buttonStyles}
22
+ disabled={validationKey !== currentThread.key}
23
+ isActive={isActive}
24
+ isLoading={isLoading}
25
+ variant={'secondary'}
26
+ colorScheme={'blue'}
27
+ size={'small'}
28
+ onPress={() => {
29
+ if (isLoading) return
30
+ model.errorSpotting.errorSpottingPressed()
31
+ }}
32
+ icon={isActive ? <StopIcon color={COLORS.NEUTRAL_1} /> : <HighlighterIcon />}
33
+ >
34
+ show error
35
+ </Button>
36
+ </View>
37
+ )
38
+ }
39
+
40
+ const buttonStyles = StyleSheet.create({
41
+ container: {
42
+ marginLeft: 'auto',
43
+ },
44
+ text: {
45
+ textTransform: 'uppercase',
46
+ },
47
+ })
48
+
49
+ const styles = StyleSheet.create({
50
+ container: {
51
+ width: '100%',
52
+ },
53
+ })
@@ -0,0 +1,116 @@
1
+ import { ChatbotAPI } from '../model/ChatbotApi'
2
+ import { createEvent, createStore, sample, createEffect, Store } from 'effector'
3
+ import { ChatItem } from '../types/units.types'
4
+
5
+ type ErrorSpottingProps = {
6
+ api: ChatbotAPI
7
+ $currentChatData: Store<ChatItem>
8
+ }
9
+
10
+ type ActiveErrorSpottingData = {
11
+ isActive: boolean
12
+ isDisabled: boolean
13
+ strokesIds: string[]
14
+ validationKey: null | string
15
+ }
16
+
17
+ type ErrorSpottingReducerProps = {
18
+ chatData: ChatItem
19
+ activeSpotting: ActiveErrorSpottingData | null
20
+ }
21
+
22
+ export class ErrorSpottingModel {
23
+ private readonly api: ChatbotAPI
24
+
25
+ public readonly errorSpottingPressed = createEvent()
26
+ private readonly activeDataChanged = createEvent<
27
+ | ((state: ActiveErrorSpottingData | null) => ActiveErrorSpottingData | null | void)
28
+ | ActiveErrorSpottingData
29
+ | null
30
+ >()
31
+
32
+ public readonly $validationKey = createStore<string | null>(null)
33
+ public readonly $activeData = createStore<ActiveErrorSpottingData | null>(null)
34
+ .on(this.activeDataChanged, (state, payload) => {
35
+ if (typeof payload === 'function') return payload(state)
36
+ return payload
37
+ })
38
+ .on(this.$validationKey, (state, payload) => {
39
+ if (!state || payload === null) return state
40
+ const isDisabled = payload !== state.validationKey
41
+ return { ...state, isDisabled, isActive: isDisabled ? false : state.isActive }
42
+ })
43
+
44
+ public readonly $isLoading
45
+
46
+ public constructor({ api, $currentChatData }: ErrorSpottingProps) {
47
+ this.api = api
48
+
49
+ this.$isLoading = api.spotErrorFx.pending
50
+
51
+ this.$activeData.on($currentChatData, (state, payload) => {
52
+ if (!state || state.validationKey !== payload.currentThread?.key) return null
53
+ })
54
+
55
+ sample({
56
+ clock: api.spotErrorFx.doneData,
57
+ source: {
58
+ chatData: $currentChatData,
59
+ activeSpotting: this.$activeData,
60
+ validationKey: this.$validationKey,
61
+ },
62
+ fn: (source, result) => {
63
+ const key = source.chatData.currentThread?.key || null
64
+ const currentKey = source.validationKey
65
+ const isDisabled = !!currentKey && currentKey !== key
66
+ return {
67
+ validationKey: key,
68
+ strokesIds: result.strokesIds,
69
+ isActive: !isDisabled,
70
+ isDisabled,
71
+ }
72
+ },
73
+ target: this.$activeData,
74
+ })
75
+
76
+ sample({
77
+ clock: this.errorSpottingPressed,
78
+ source: {
79
+ chatData: $currentChatData,
80
+ activeSpotting: this.$activeData,
81
+ },
82
+ fn: (source) => source,
83
+ target: createEffect(({ chatData, activeSpotting }: ErrorSpottingReducerProps) => {
84
+ if (!chatData.currentThread?.strokes) return
85
+ if (!activeSpotting) {
86
+ return this.api.spotErrorFx({ strokes: chatData.currentThread.strokes })
87
+ }
88
+ this.toggleActiveSpotting()
89
+ }),
90
+ })
91
+ }
92
+
93
+ private toggleActiveSpotting() {
94
+ this.activeDataChanged((state) => {
95
+ if (state) return { ...state, isActive: !state.isActive }
96
+ })
97
+ }
98
+
99
+ public bindStrokesValidation($store: Store<string | null>) {
100
+ sample({
101
+ source: $store,
102
+ target: this.$validationKey,
103
+ })
104
+ return this
105
+ }
106
+
107
+ public abortPendingRequest() {
108
+ const isPending = this.api.spotErrorFx.pending.getState()
109
+ if (isPending) this.api.spotErrorFx.controller.abort()
110
+ }
111
+
112
+ public reset() {
113
+ this.activeDataChanged(null)
114
+ this.abortPendingRequest()
115
+ }
116
+ }
@@ -3,11 +3,11 @@ export { ChatbotModel } from './model/ChatBotModel'
3
3
  export { AudioStatus, type AudioProvider } from './types/t2s.types'
4
4
  export {
5
5
  MessageVariant,
6
- type ConversationMessage,
7
6
  type ChatbotRenderer,
8
7
  type ChatbotModelProps,
9
8
  type IChatDrawBoardAdapter,
10
9
  } from './types/model.types'
11
- export type { PostMessageResponse, ChatAnswer } from './types/api.types'
12
- export { ChatMessageHandler } from './model/ChatBotMessageHandler'
10
+ export type { PostMessageResponse } from './types/api.types'
13
11
  export { DefaultMessagesCreator } from './model/DefaultMessageCreator'
12
+ export type { ChatAnswer } from './types/units.types'
13
+ export type { ConversationMessage } from './types/units.types'