@magmamath/students-features 0.3.0 → 0.3.1-rc.1

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 (68) hide show
  1. package/dist/commonjs/features/chatbot/index.js +7 -0
  2. package/dist/commonjs/features/chatbot/index.js.map +1 -1
  3. package/dist/commonjs/features/chatbot/model/ChatBotMessageHandler.js +80 -0
  4. package/dist/commonjs/features/chatbot/model/ChatBotMessageHandler.js.map +1 -0
  5. package/dist/commonjs/features/chatbot/model/DefaultMessageCreator.js +48 -0
  6. package/dist/commonjs/features/chatbot/model/DefaultMessageCreator.js.map +1 -0
  7. package/dist/commonjs/features/chatbot/model/ThreadItem.js +29 -0
  8. package/dist/commonjs/features/chatbot/model/ThreadItem.js.map +1 -0
  9. package/dist/commonjs/features/chatbot/model/constants.js +10 -0
  10. package/dist/commonjs/features/chatbot/model/constants.js.map +1 -0
  11. package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
  12. package/dist/module/features/chatbot/index.js +1 -0
  13. package/dist/module/features/chatbot/index.js.map +1 -1
  14. package/dist/module/features/chatbot/model/ChatBotMessageHandler.js +75 -0
  15. package/dist/module/features/chatbot/model/ChatBotMessageHandler.js.map +1 -0
  16. package/dist/module/features/chatbot/model/DefaultMessageCreator.js +43 -0
  17. package/dist/module/features/chatbot/model/DefaultMessageCreator.js.map +1 -0
  18. package/dist/module/features/chatbot/model/ThreadItem.js +24 -0
  19. package/dist/module/features/chatbot/model/ThreadItem.js.map +1 -0
  20. package/dist/module/features/chatbot/model/constants.js +6 -0
  21. package/dist/module/features/chatbot/model/constants.js.map +1 -0
  22. package/dist/module/features/chatbot/types/model.types.js.map +1 -1
  23. package/dist/typescript/commonjs/features/chatbot/index.d.ts +1 -0
  24. package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
  25. package/dist/typescript/commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts +31 -0
  26. package/dist/typescript/commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts.map +1 -0
  27. package/dist/typescript/commonjs/features/chatbot/model/DefaultMessageCreator.d.ts +21 -0
  28. package/dist/typescript/commonjs/features/chatbot/model/DefaultMessageCreator.d.ts.map +1 -0
  29. package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts +21 -0
  30. package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts.map +1 -0
  31. package/dist/typescript/commonjs/features/chatbot/model/constants.d.ts +4 -0
  32. package/dist/typescript/commonjs/features/chatbot/model/constants.d.ts.map +1 -0
  33. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts +2 -2
  34. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +1 -1
  35. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +15 -0
  36. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
  37. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +13 -9
  38. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
  39. package/dist/typescript/commonjs/lib/helpers/types.d.ts +1 -1
  40. package/dist/typescript/commonjs/lib/helpers/types.d.ts.map +1 -1
  41. package/dist/typescript/module/features/chatbot/index.d.ts +1 -0
  42. package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
  43. package/dist/typescript/module/features/chatbot/model/ChatBotMessageHandler.d.ts +31 -0
  44. package/dist/typescript/module/features/chatbot/model/ChatBotMessageHandler.d.ts.map +1 -0
  45. package/dist/typescript/module/features/chatbot/model/DefaultMessageCreator.d.ts +21 -0
  46. package/dist/typescript/module/features/chatbot/model/DefaultMessageCreator.d.ts.map +1 -0
  47. package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts +21 -0
  48. package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts.map +1 -0
  49. package/dist/typescript/module/features/chatbot/model/constants.d.ts +4 -0
  50. package/dist/typescript/module/features/chatbot/model/constants.d.ts.map +1 -0
  51. package/dist/typescript/module/features/chatbot/model/translation.d.ts +2 -2
  52. package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +1 -1
  53. package/dist/typescript/module/features/chatbot/types/api.types.d.ts +15 -0
  54. package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
  55. package/dist/typescript/module/features/chatbot/types/model.types.d.ts +13 -9
  56. package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
  57. package/dist/typescript/module/lib/helpers/types.d.ts +1 -1
  58. package/dist/typescript/module/lib/helpers/types.d.ts.map +1 -1
  59. package/package.json +1 -1
  60. package/src/features/chatbot/index.ts +1 -0
  61. package/src/features/chatbot/model/ChatBotMessageHandler.ts +106 -0
  62. package/src/features/chatbot/model/DefaultMessageCreator.ts +57 -0
  63. package/src/features/chatbot/model/ThreadItem.ts +28 -0
  64. package/src/features/chatbot/model/constants.ts +3 -0
  65. package/src/features/chatbot/model/translation.ts +2 -2
  66. package/src/features/chatbot/types/api.types.ts +18 -0
  67. package/src/features/chatbot/types/model.types.ts +15 -8
  68. package/src/lib/helpers/types.ts +1 -1
@@ -1 +1 @@
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,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACV,sBAAsB,EACvB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEzD,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,UAAU,EAAE,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;IACrB,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SAAS;IACb,QAAQ,aAAa;CACtB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,cAAc,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,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,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACV,sBAAsB,EACtB,MAAM,EACP,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,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,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,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACpB,GAAG,EAAE;QACH,eAAe,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC,u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@
1
- export type AccomplishTo<T, To> = Partial<Omit<To, keyof T>> & T;
1
+ export type ExtendWithOptional<T, To> = Partial<Omit<To, keyof T>> & T;
2
2
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/helpers/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/helpers/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
@@ -3,4 +3,5 @@ export { ChatbotModel } from './model/ChatBotModel';
3
3
  export { AudioStatus, type AudioProvider } from './types/t2s.types';
4
4
  export { MessageVariant, type ConversationMessage, type ChatbotRenderer, type ChatbotModelProps, } from './types/model.types';
5
5
  export type { PostMessageResponse, ChatAnswer } from './types/api.types';
6
+ export { ChatMessageHandler } from './model/ChatBotMessageHandler';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/chatbot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/chatbot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA"}
@@ -0,0 +1,31 @@
1
+ import { Store } from 'effector';
2
+ import { ChatHintPayload, ChatHintResponse, PostMessagePayload, PostMessageResponse } from '../types/api.types';
3
+ import { ChatbotMessages, IChatDrawBoardAdapter } from '../types/model.types';
4
+ type ChatMessageHandlerProps = {
5
+ messagesLimit?: number;
6
+ messages: ChatbotMessages;
7
+ drawBoardAdapter: IChatDrawBoardAdapter;
8
+ api: {
9
+ getHint: (props: ChatHintPayload) => Promise<ChatHintResponse>;
10
+ };
11
+ };
12
+ type ResetCacheProps = {
13
+ key: string;
14
+ };
15
+ export declare class ChatMessageHandler {
16
+ private readonly api;
17
+ private readonly drawBoardAdapter;
18
+ private readonly threads;
19
+ private readonly messagesLimit;
20
+ private currentKey;
21
+ private currentBinding;
22
+ private readonly defaultMessages;
23
+ constructor({ drawBoardAdapter, api, messagesLimit, messages, }: ChatMessageHandlerProps);
24
+ bindKeyStore($store: Store<string>): this;
25
+ private getThreadItem;
26
+ readonly postMessageFx: ({ problemAnswer, problem, answer, language, }: PostMessagePayload) => Promise<PostMessageResponse>;
27
+ resetThread: import("effector/effector.umd").Effect<ResetCacheProps, void, Error>;
28
+ resetAll(): void;
29
+ }
30
+ export {};
31
+ //# sourceMappingURL=ChatBotMessageHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatBotMessageHandler.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/model/ChatBotMessageHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAG7E,KAAK,uBAAuB,GAAG;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,eAAe,CAAA;IACzB,gBAAgB,EAAE,qBAAqB,CAAA;IACvC,GAAG,EAAE;QACH,OAAO,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAA;KAC/D,CAAA;CACF,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAA;IACpB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuB;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IAExD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAA;IAC9B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,cAAc,CAA4B;IAElD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAA;gBAEb,EACjB,gBAAgB,EAChB,GAAG,EACH,aAA6D,EAC7D,QAAQ,GACT,EAAE,uBAAuB;IAOnB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;YAQ3B,aAAa;IAc3B,SAAgB,aAAa,kDAK1B,kBAAkB,KAAG,OAAO,CAAC,mBAAmB,CAAC,CAqBnD;IAEM,WAAW,uEAEhB;IAEK,QAAQ;CAGhB"}
@@ -0,0 +1,21 @@
1
+ import { ChatAnswer, PostMessageResponse } from '../types/api.types';
2
+ type ChatMessage = PostMessageResponse & {
3
+ id: string;
4
+ isOwnMessage: boolean;
5
+ };
6
+ type DefaultMessageSettings = {
7
+ isOwn?: boolean;
8
+ };
9
+ type DefaultMessageCreatorProps<K extends string> = {
10
+ textGetter: (key: K) => string;
11
+ };
12
+ export declare class DefaultMessagesCreator<K extends string> {
13
+ readonly languageChanged: import("effector").EventCallable<void>;
14
+ private readonly list;
15
+ private readonly getter;
16
+ constructor({ textGetter }: DefaultMessageCreatorProps<K>);
17
+ createMessage(key: K, { isOwn }?: DefaultMessageSettings): ChatMessage;
18
+ createOption(key: K): ChatAnswer;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=DefaultMessageCreator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultMessageCreator.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/model/DefaultMessageCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAGpE,KAAK,WAAW,GAAG,mBAAmB,GAAG;IACvC,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,KAAK,sBAAsB,GAAG;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,KAAK,0BAA0B,CAAC,CAAC,SAAS,MAAM,IAAI;IAClD,UAAU,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,CAAA;CAC/B,CAAA;AAED,qBAAa,sBAAsB,CAAC,CAAC,SAAS,MAAM;IAClD,SAAgB,eAAe,yCAAgB;IAE/C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyC;IAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAA;gBAEX,EAAE,UAAU,EAAE,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAclD,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,KAAa,EAAE,GAAE,sBAA2B;IAYpE,YAAY,CAAC,GAAG,EAAE,CAAC;CAQ3B"}
@@ -0,0 +1,21 @@
1
+ import { Stroke } from '../types/api.types';
2
+ type ThreadItemProps = {
3
+ strokes?: Stroke[] | null;
4
+ };
5
+ export declare class ThreadItem {
6
+ readonly strokes: Stroke[] | null;
7
+ readonly hints: string[];
8
+ constructor({ strokes }?: ThreadItemProps);
9
+ getNextHintProps(): {
10
+ previousHint: string;
11
+ stroke?: undefined;
12
+ } | {
13
+ stroke: Stroke[];
14
+ previousHint?: undefined;
15
+ } | {
16
+ previousHint?: undefined;
17
+ stroke?: undefined;
18
+ };
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=ThreadItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreadItem.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/model/ThreadItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;CAC1B,CAAA;AAED,qBAAa,UAAU;IACrB,SAAgB,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IACxC,SAAgB,KAAK,EAAE,MAAM,EAAE,CAAK;gBAEjB,EAAE,OAAO,EAAE,GAAE,eAAoB;IAI7C,gBAAgB;;;;;;;;;;CAaxB"}
@@ -0,0 +1,4 @@
1
+ export declare const CHAT_BOT_MODEL_DEFAULTS: {
2
+ THREAD_MESSAGES_LIMIT: number;
3
+ };
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/model/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB;;CAEnC,CAAA"}
@@ -1,13 +1,13 @@
1
1
  import { EventCallable, Store } from 'effector';
2
2
  import { TranslateMessageFxProps } from '../types/translation.types';
3
- import { ChatbotModelProps, ConversationMessage } from '../types/model.types';
3
+ import { ChatbotMessages, ConversationMessage } from '../types/model.types';
4
4
  import { GetAlternativesResponse } from '../types/api.types';
5
5
  import { ChatbotAPI } from './api';
6
6
  import { EntityFieldStore } from '../../../lib/effector/createEntityFieldStore';
7
7
  type ChatbotTranslationProps = {
8
8
  api: ChatbotAPI;
9
9
  $key: Store<string>;
10
- defaultMessages: ChatbotModelProps['messages'];
10
+ defaultMessages: ChatbotMessages;
11
11
  messagesModel: EntityFieldStore<ConversationMessage[]>;
12
12
  alternativesModel: {
13
13
  set: EventCallable<GetAlternativesResponse | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/model/translation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,aAAa,EAAmB,KAAK,EAAE,MAAM,UAAU,CAAA;AACnG,OAAO,EAGL,uBAAuB,EAExB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAO/E,KAAK,uBAAuB,GAAG;IAC7B,GAAG,EAAE,UAAU,CAAA;IACf,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACnB,eAAe,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAA;IAC9C,aAAa,EAAE,gBAAgB,CAAC,mBAAmB,EAAE,CAAC,CAAA;IACtD,iBAAiB,EAAE;QACjB,GAAG,EAAE,aAAa,CAAC,uBAAuB,GAAG,IAAI,CAAC,CA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MAAM,CAAC,CAAA;IACnB,eAAe,EAAE,eAAe,CAAA;IAChC,aAAa,EAAE,gBAAgB,CAAC,mBAAmB,EAAE,CAAC,CAAA;IACtD,iBAAiB,EAAE;QACjB,GAAG,EAAE,aAAa,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAA;QAClD,MAAM,EAAE,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAA;KAC9C,CAAA;CACF,CAAA;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAA;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAA;IACrB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAA;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAA;IAC9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAA;IAElC,QAAQ,CAAC,eAAe,yBAAyB;IACjD,QAAQ,CAAC,aAAa,4CAAuC;IAE7D,QAAQ,CAAC,sBAAsB;;qCAAA;gBAEnB,EACV,GAAG,EACH,IAAI,EACJ,eAAe,EACf,aAAa,EACb,iBAAiB,GAClB,EAAE,uBAAuB;IAmB1B,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,sBAAsB;YAShB,gBAAgB;IAmB9B,OAAO,CAAC,4BAA4B;IAIpC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAkDhC;IAED,SAAgB,mBAAmB,mFA0BlC;IAEM,KAAK;CAGb"}
@@ -63,4 +63,19 @@ export type GoogleText2SpeechPayload = {
63
63
  export type GoogleText2SpeechResponse = string | undefined | {
64
64
  audioContent?: string;
65
65
  };
66
+ export type Stroke = {
67
+ x: number[];
68
+ y: number[];
69
+ };
70
+ export type ChatHintPayload = {
71
+ problemDescription: string;
72
+ correctAnswer: string[];
73
+ userAnswer?: string | string[];
74
+ stroke?: Stroke[];
75
+ previousHint?: string;
76
+ language: string;
77
+ };
78
+ export type ChatHintResponse = {
79
+ message: string;
80
+ };
66
81
  //# sourceMappingURL=api.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/api.types.ts"],"names":[],"mappings":"AAAA,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,sBAAsB,GAAG;IACnC,cAAc,EAAE,MAAM,CAAA;IACtB,oBAAoB,EAAE,MAAM,CAAA;CAC7B,GAAG,IAAI,CAAA;AAER,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,EAAE;QACP,OAAO,EAAE,UAAU,EAAE,CAAA;QACrB,KAAK,EAAE,UAAU,EAAE,CAAA;KACpB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,cAAc,EAAE;QAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,UAAU,EAAE,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE;QACJ,YAAY,EAAE;YAAE,cAAc,EAAE,MAAM,CAAC;YAAC,sBAAsB,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAC3E,CAAA;CACF,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAA;QACpB,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,WAAW,EAAE;QACX,aAAa,EAAE,MAAM,CAAA;QACrB,KAAK,EAAE,MAAM,CAAA;QACb,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,SAAS,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
1
+ {"version":3,"file":"api.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/api.types.ts"],"names":[],"mappings":"AAAA,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,sBAAsB,GAAG;IACnC,cAAc,EAAE,MAAM,CAAA;IACtB,oBAAoB,EAAE,MAAM,CAAA;CAC7B,GAAG,IAAI,CAAA;AAER,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,EAAE;QACP,OAAO,EAAE,UAAU,EAAE,CAAA;QACrB,KAAK,EAAE,UAAU,EAAE,CAAA;KACpB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IA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AG,SAAS,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtF,MAAM,MAAM,MAAM,GAAG;IACnB,CAAC,EAAE,MAAM,EAAE,CAAA;IACX,CAAC,EAAE,MAAM,EAAE,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import type { Store } from 'effector';
2
- import { GetAlternativesResponse, PostMessagePayload, PostMessageResponse, GoogleTranslatePayload, GoogleTranslateResponse, GoogleText2SpeechPayload, GoogleText2SpeechResponse, ChatAnswer, GetAlternativesPayload } from './api.types';
3
- import { AccomplishTo } from '../../../lib/helpers/types';
2
+ import { GetAlternativesResponse, PostMessagePayload, PostMessageResponse, GoogleTranslatePayload, GoogleTranslateResponse, GoogleText2SpeechPayload, GoogleText2SpeechResponse, ChatAnswer, GetAlternativesPayload, Stroke } from './api.types';
3
+ import { ExtendWithOptional } from '../../../lib/helpers/types';
4
4
  export type ConversationMessage = {
5
5
  id: string;
6
6
  message: string;
@@ -10,6 +10,12 @@ export type ConversationMessage = {
10
10
  translatedMessage?: string;
11
11
  endMessage?: boolean;
12
12
  };
13
+ export type ChatbotMessages = {
14
+ error: ConversationMessage;
15
+ start: ConversationMessage;
16
+ endMessage: ConversationMessage;
17
+ anotherHintOption: ChatAnswer;
18
+ };
13
19
  export type ChatbotModelProps = {
14
20
  $key?: Store<string>;
15
21
  api: {
@@ -18,12 +24,7 @@ export type ChatbotModelProps = {
18
24
  postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>;
19
25
  postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>;
20
26
  };
21
- messages: {
22
- error: ConversationMessage;
23
- start: ConversationMessage;
24
- endMessage: ConversationMessage;
25
- anotherHintOption: ChatAnswer;
26
- };
27
+ messages: ChatbotMessages;
27
28
  };
28
29
  export type SendHelpParams = {
29
30
  payload: PostMessagePayload;
@@ -51,5 +52,8 @@ export type ChatbotRenderer = {
51
52
  variant: MessageVariant;
52
53
  withTextToSpeech: boolean;
53
54
  };
54
- export type CreateMessageResponse = AccomplishTo<PostMessageResponse, ConversationMessage>;
55
+ export type CreateMessageResponse = ExtendWithOptional<PostMessageResponse, ConversationMessage>;
56
+ export type IChatDrawBoardAdapter = {
57
+ getVisibleStrokes(): Promise<Stroke[] | null>;
58
+ };
55
59
  //# 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"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACV,sBAAsB,EACvB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEzD,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,UAAU,EAAE,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;CACr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AAE,MAAM,CAAA;IACf,OAAO,EAAE,cAAc,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,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,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACV,sBAAsB,EACtB,MAAM,EACP,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,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,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,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACpB,GAAG,EAAE;QACH,eAAe,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAA;QACpF,WAAW,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,OAA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Partial<Omit<To, keyof T>> & T;
2
2
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/helpers/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/helpers/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magmamath/students-features",
3
- "version": "0.3.0",
3
+ "version": "0.3.1-rc.1",
4
4
  "description": "Magmamath features library",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/commonjs/index.js",
@@ -8,3 +8,4 @@ export {
8
8
  type ChatbotModelProps,
9
9
  } from './types/model.types'
10
10
  export type { PostMessageResponse, ChatAnswer } from './types/api.types'
11
+ export { ChatMessageHandler } from './model/ChatBotMessageHandler'
@@ -0,0 +1,106 @@
1
+ import { ThreadItem } from './ThreadItem'
2
+ import { Store } from 'effector'
3
+ import { createEffect } from 'effector/effector.umd'
4
+ import {
5
+ ChatHintPayload,
6
+ ChatHintResponse,
7
+ PostMessagePayload,
8
+ PostMessageResponse,
9
+ } from '../types/api.types'
10
+ import { ChatbotMessages, IChatDrawBoardAdapter } from '../types/model.types'
11
+ import { CHAT_BOT_MODEL_DEFAULTS } from './constants'
12
+
13
+ type ChatMessageHandlerProps = {
14
+ messagesLimit?: number
15
+ messages: ChatbotMessages
16
+ drawBoardAdapter: IChatDrawBoardAdapter
17
+ api: {
18
+ getHint: (props: ChatHintPayload) => Promise<ChatHintResponse>
19
+ }
20
+ }
21
+
22
+ type ResetCacheProps = {
23
+ key: string
24
+ }
25
+
26
+ export class ChatMessageHandler {
27
+ private readonly api
28
+ private readonly drawBoardAdapter: IChatDrawBoardAdapter
29
+ private readonly threads = new Map<string, ThreadItem>()
30
+
31
+ private readonly messagesLimit
32
+ private currentKey = ''
33
+ private currentBinding: null | (() => void) = null
34
+
35
+ private readonly defaultMessages
36
+
37
+ public constructor({
38
+ drawBoardAdapter,
39
+ api,
40
+ messagesLimit = CHAT_BOT_MODEL_DEFAULTS.THREAD_MESSAGES_LIMIT,
41
+ messages,
42
+ }: ChatMessageHandlerProps) {
43
+ this.api = api
44
+ this.drawBoardAdapter = drawBoardAdapter
45
+ this.messagesLimit = messagesLimit
46
+ this.defaultMessages = messages
47
+ }
48
+
49
+ public bindKeyStore($store: Store<string>) {
50
+ this.currentBinding?.()
51
+ this.currentBinding = $store.watch((value) => {
52
+ this.currentKey = value
53
+ })
54
+ return this
55
+ }
56
+
57
+ private async getThreadItem() {
58
+ const key = this.currentKey
59
+ let threadItem = this.threads.get(key)
60
+ if (threadItem) return threadItem
61
+ try {
62
+ const strokes = await this.drawBoardAdapter.getVisibleStrokes()
63
+ threadItem = new ThreadItem({ strokes })
64
+ } catch {
65
+ threadItem = new ThreadItem()
66
+ }
67
+ this.threads.set(key, threadItem)
68
+ return threadItem
69
+ }
70
+
71
+ public readonly postMessageFx = async ({
72
+ problemAnswer,
73
+ problem,
74
+ answer,
75
+ language,
76
+ }: PostMessagePayload): Promise<PostMessageResponse> => {
77
+ const threadItem = await this.getThreadItem()
78
+
79
+ const result = await this.api.getHint({
80
+ ...threadItem.getNextHintProps(),
81
+ correctAnswer: problemAnswer,
82
+ problemDescription: problem,
83
+ userAnswer: answer,
84
+ language,
85
+ })
86
+
87
+ threadItem.hints.push(result.message)
88
+ const nextOptions =
89
+ threadItem.hints.length < this.messagesLimit ? [this.defaultMessages.anotherHintOption] : []
90
+
91
+ return {
92
+ message: result.message,
93
+ options: nextOptions,
94
+ threadId: '',
95
+ endMessage: !nextOptions.length,
96
+ }
97
+ }
98
+
99
+ public resetThread = createEffect(({ key }: ResetCacheProps) => {
100
+ this.threads.delete(key)
101
+ })
102
+
103
+ public resetAll() {
104
+ this.threads.clear()
105
+ }
106
+ }
@@ -0,0 +1,57 @@
1
+ import { ChatAnswer, PostMessageResponse } from '../types/api.types'
2
+ import { createEvent } from 'effector'
3
+
4
+ type ChatMessage = PostMessageResponse & {
5
+ id: string
6
+ isOwnMessage: boolean
7
+ }
8
+
9
+ type DefaultMessageSettings = {
10
+ isOwn?: boolean
11
+ }
12
+
13
+ type DefaultMessageCreatorProps<K extends string> = {
14
+ textGetter: (key: K) => string
15
+ }
16
+
17
+ export class DefaultMessagesCreator<K extends string> {
18
+ public readonly languageChanged = createEvent()
19
+
20
+ private readonly list = new Map<ChatMessage | ChatAnswer, K>()
21
+ private readonly getter
22
+
23
+ constructor({ textGetter }: DefaultMessageCreatorProps<K>) {
24
+ this.getter = textGetter
25
+
26
+ this.languageChanged.watch(() => {
27
+ this.list.forEach((key, chatMessage) => {
28
+ if ('message' in chatMessage) {
29
+ chatMessage.message = this.getter(key)
30
+ return
31
+ }
32
+ chatMessage.text = this.getter(key)
33
+ })
34
+ })
35
+ }
36
+
37
+ public createMessage(key: K, { isOwn = false }: DefaultMessageSettings = {}) {
38
+ const message: ChatMessage = {
39
+ id: this.list.size.toString(),
40
+ message: this.getter(key),
41
+ threadId: '',
42
+ options: [],
43
+ isOwnMessage: isOwn,
44
+ }
45
+ this.list.set(message, key)
46
+ return message
47
+ }
48
+
49
+ public createOption(key: K) {
50
+ const option: ChatAnswer = {
51
+ text: this.getter(key),
52
+ promptKey: '',
53
+ }
54
+ this.list.set(option, key)
55
+ return option
56
+ }
57
+ }
@@ -0,0 +1,28 @@
1
+ import { Stroke } from '../types/api.types'
2
+
3
+ type ThreadItemProps = {
4
+ strokes?: Stroke[] | null
5
+ }
6
+
7
+ export class ThreadItem {
8
+ public readonly strokes: Stroke[] | null
9
+ public readonly hints: string[] = []
10
+
11
+ public constructor({ strokes }: ThreadItemProps = {}) {
12
+ this.strokes = strokes ?? null
13
+ }
14
+
15
+ public getNextHintProps() {
16
+ if (this.hints.length) {
17
+ return {
18
+ previousHint: this.hints[this.hints.length - 1],
19
+ }
20
+ }
21
+
22
+ if (this.strokes) {
23
+ return { stroke: this.strokes }
24
+ }
25
+
26
+ return {}
27
+ }
28
+ }
@@ -0,0 +1,3 @@
1
+ export const CHAT_BOT_MODEL_DEFAULTS = {
2
+ THREAD_MESSAGES_LIMIT: 3,
3
+ }
@@ -5,7 +5,7 @@ import {
5
5
  TranslateMessageFxProps,
6
6
  TranslateRequestProps,
7
7
  } from '../types/translation.types'
8
- import { ChatbotModelProps, ConversationMessage } from '../types/model.types'
8
+ import { ChatbotMessages, ConversationMessage } from '../types/model.types'
9
9
  import { GetAlternativesResponse } from '../types/api.types'
10
10
  import { decodeHTMLEntities } from '../helpers'
11
11
  import { ChatbotAPI } from './api'
@@ -19,7 +19,7 @@ import {
19
19
  type ChatbotTranslationProps = {
20
20
  api: ChatbotAPI
21
21
  $key: Store<string>
22
- defaultMessages: ChatbotModelProps['messages']
22
+ defaultMessages: ChatbotMessages
23
23
  messagesModel: EntityFieldStore<ConversationMessage[]>
24
24
  alternativesModel: {
25
25
  set: EventCallable<GetAlternativesResponse | null>
@@ -64,3 +64,21 @@ export type GoogleText2SpeechPayload = {
64
64
  }
65
65
 
66
66
  export type GoogleText2SpeechResponse = string | undefined | { audioContent?: string }
67
+
68
+ export type Stroke = {
69
+ x: number[]
70
+ y: number[]
71
+ }
72
+
73
+ export type ChatHintPayload = {
74
+ problemDescription: string
75
+ correctAnswer: string[]
76
+ userAnswer?: string | string[]
77
+ stroke?: Stroke[]
78
+ previousHint?: string
79
+ language: string
80
+ }
81
+
82
+ export type ChatHintResponse = {
83
+ message: string
84
+ }
@@ -9,8 +9,9 @@ import {
9
9
  GoogleText2SpeechResponse,
10
10
  ChatAnswer,
11
11
  GetAlternativesPayload,
12
+ Stroke,
12
13
  } from './api.types'
13
- import { AccomplishTo } from '../../../lib/helpers/types'
14
+ import { ExtendWithOptional } from '../../../lib/helpers/types'
14
15
 
15
16
  export type ConversationMessage = {
16
17
  id: string
@@ -22,6 +23,13 @@ export type ConversationMessage = {
22
23
  endMessage?: boolean
23
24
  }
24
25
 
26
+ export type ChatbotMessages = {
27
+ error: ConversationMessage
28
+ start: ConversationMessage
29
+ endMessage: ConversationMessage
30
+ anotherHintOption: ChatAnswer
31
+ }
32
+
25
33
  export type ChatbotModelProps = {
26
34
  $key?: Store<string>
27
35
  api: {
@@ -30,12 +38,7 @@ export type ChatbotModelProps = {
30
38
  postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>
31
39
  postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>
32
40
  }
33
- messages: {
34
- error: ConversationMessage
35
- start: ConversationMessage
36
- endMessage: ConversationMessage
37
- anotherHintOption: ChatAnswer
38
- }
41
+ messages: ChatbotMessages
39
42
  }
40
43
 
41
44
  export type SendHelpParams = {
@@ -70,4 +73,8 @@ export type ChatbotRenderer = {
70
73
  withTextToSpeech: boolean
71
74
  }
72
75
 
73
- export type CreateMessageResponse = AccomplishTo<PostMessageResponse, ConversationMessage>
76
+ export type CreateMessageResponse = ExtendWithOptional<PostMessageResponse, ConversationMessage>
77
+
78
+ export type IChatDrawBoardAdapter = {
79
+ getVisibleStrokes(): Promise<Stroke[] | null>
80
+ }
@@ -1 +1 @@
1
- export type AccomplishTo<T, To> = Partial<Omit<To, keyof T>> & T
1
+ export type ExtendWithOptional<T, To> = Partial<Omit<To, keyof T>> & T