@magmamath/students-features 1.0.1 → 1.0.2-rc.10

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 (89) hide show
  1. package/.editorconfig +15 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc +22 -0
  4. package/.gitattributes +3 -0
  5. package/.github/actions/setup/action.yml +37 -0
  6. package/.github/workflows/ci.yml +73 -0
  7. package/.gitignore +84 -0
  8. package/.idea/.gitignore +8 -0
  9. package/.idea/codeStyles/Project.xml +62 -0
  10. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  11. package/.idea/copilot.data.migration.agent.xml +6 -0
  12. package/.idea/copilot.data.migration.ask.xml +6 -0
  13. package/.idea/copilot.data.migration.ask2agent.xml +6 -0
  14. package/.idea/copilot.data.migration.edit.xml +6 -0
  15. package/.idea/inspectionProfiles/Project_Default.xml +8 -0
  16. package/.idea/jsLinters/eslint.xml +6 -0
  17. package/.idea/modules.xml +8 -0
  18. package/.idea/prettier.xml +7 -0
  19. package/.idea/students-features.iml +12 -0
  20. package/.idea/vcs.xml +6 -0
  21. package/.idea/workspace.xml +663 -0
  22. package/.nvmrc +1 -0
  23. package/.prettierrc +11 -0
  24. package/.release-it.json +17 -0
  25. package/.watchmanconfig +1 -0
  26. package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +541 -0
  27. package/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs +28 -0
  28. package/.yarn/releases/yarn-3.6.1.cjs +874 -0
  29. package/babel.config.js +5 -0
  30. package/bob.config.js +25 -0
  31. package/dist/commonjs/features/chatbot/helpers.js +3 -0
  32. package/dist/commonjs/features/chatbot/helpers.js.map +1 -1
  33. package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js +14 -2
  34. package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
  35. package/dist/commonjs/features/chatbot/model/ThreadItem.js +52 -11
  36. package/dist/commonjs/features/chatbot/model/ThreadItem.js.map +1 -1
  37. package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
  38. package/dist/module/features/chatbot/helpers.js +3 -0
  39. package/dist/module/features/chatbot/helpers.js.map +1 -1
  40. package/dist/module/features/chatbot/model/ChatBotThreadManager.js +14 -2
  41. package/dist/module/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
  42. package/dist/module/features/chatbot/model/ThreadItem.js +52 -11
  43. package/dist/module/features/chatbot/model/ThreadItem.js.map +1 -1
  44. package/dist/module/features/chatbot/types/model.types.js.map +1 -1
  45. package/dist/typescript/commonjs/features/chatbot/helpers.d.ts.map +1 -1
  46. package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -1
  47. package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts +38 -13
  48. package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts.map +1 -1
  49. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +7 -1
  50. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
  51. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +6 -2
  52. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
  53. package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts +17 -0
  54. package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts.map +1 -1
  55. package/dist/typescript/module/features/chatbot/helpers.d.ts.map +1 -1
  56. package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -1
  57. package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts +38 -13
  58. package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts.map +1 -1
  59. package/dist/typescript/module/features/chatbot/types/api.types.d.ts +7 -1
  60. package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
  61. package/dist/typescript/module/features/chatbot/types/model.types.d.ts +6 -2
  62. package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
  63. package/dist/typescript/module/features/chatbot/types/units.types.d.ts +17 -0
  64. package/dist/typescript/module/features/chatbot/types/units.types.d.ts.map +1 -1
  65. package/example/.expo/README.md +8 -0
  66. package/example/.expo/devices.json +3 -0
  67. package/example/.expo/web/cache/production/images/favicon/favicon-24272cdaeff82cc5facdaccd982a6f05b60c4504704bbf94c19a6388659880bb-contain-transparent/favicon-48.png +0 -0
  68. package/example/app.json +30 -0
  69. package/example/assets/adaptive-icon.png +0 -0
  70. package/example/assets/favicon.png +0 -0
  71. package/example/assets/icon.png +0 -0
  72. package/example/assets/splash-icon.png +0 -0
  73. package/example/babel.config.js +28 -0
  74. package/example/index.js +8 -0
  75. package/example/metro.config.js +18 -0
  76. package/example/package.json +25 -0
  77. package/example/src/App.tsx +8 -0
  78. package/example/tsconfig.json +6 -0
  79. package/example/yarn.lock +6552 -0
  80. package/package.json +1 -1
  81. package/src/features/chatbot/helpers.ts +1 -0
  82. package/src/features/chatbot/model/ChatBotThreadManager.ts +15 -2
  83. package/src/features/chatbot/model/ThreadItem.ts +69 -16
  84. package/src/features/chatbot/types/api.types.ts +9 -1
  85. package/src/features/chatbot/types/model.types.ts +13 -2
  86. package/src/features/chatbot/types/units.types.ts +20 -0
  87. package/tsconfig.build.json +4 -0
  88. package/tsconfig.json +34 -0
  89. package/yarn.lock +10904 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magmamath/students-features",
3
- "version": "1.0.1",
3
+ "version": "1.0.2-rc.10",
4
4
  "description": "Magmamath features library",
5
5
  "source": "src/index.ts",
6
6
  "main": "src/index.ts",
@@ -103,6 +103,7 @@ export function prepareChatRequestPayload(
103
103
  ...(imageCdnId && { imageCdnId }),
104
104
  ...(imageAltText && { altText: imageAltText }),
105
105
  ...(!!problemStandards?.length && { problemStandards }),
106
+ ...(!!answerOptions?.length && { answerOptions }),
106
107
  },
107
108
  }
108
109
  }
@@ -63,8 +63,21 @@ export class ChatBotThreadManager {
63
63
  const content = await this.drawBoardAdapter.getContent()
64
64
  if (!content) return threadItem
65
65
  threadItem.setValidationKey(content.validationKey)
66
- if (content.text) return threadItem.setText(content.text)
67
- if (content.strokes?.length) return threadItem.setStrokes(content.strokes)
66
+ threadItem.setHintNumber(content.hintNumber)
67
+ threadItem.setStudentInput(content.studentInput)
68
+
69
+ if (content.strokes?.length) {
70
+ threadItem.setStrokes(content.strokes)
71
+ }
72
+ if (content.spreadSheetContent?.length) {
73
+ threadItem.setSpreadSheetContent(content.spreadSheetContent)
74
+ }
75
+ if (content.equationWriterContent?.length) {
76
+ threadItem.setEquationWriterContent(content.equationWriterContent)
77
+ }
78
+ if (content.drawBoardImage) {
79
+ threadItem.setDrawBoardImage(content.drawBoardImage)
80
+ }
68
81
  } catch {}
69
82
 
70
83
  return threadItem
@@ -1,24 +1,44 @@
1
- import { FullStrokeData, IThreadItem } from '../types/units.types'
1
+ import {
2
+ EquationItem,
3
+ FullStrokeData,
4
+ IThreadItem,
5
+ SpreadsheetItem,
6
+ } from '../types/units.types'
2
7
  import { generateRandomId } from '../../../lib/helpers/helpers'
3
8
 
4
9
  type ThreadItemProps = {
5
10
  strokes?: FullStrokeData[]
6
- text?: string
7
11
  key: string
12
+ spreadSheetContent?: SpreadsheetItem[]
13
+ equationWriterContent?: EquationItem[]
14
+ drawBoardImage?: string
15
+ hintNumber?: number
16
+ studentInput?: string
8
17
  }
9
18
 
19
+ const DEFAULT_HINT_NUMBER = 0
20
+ const DEFAULT_STUDENT_INPUT = 'none'
21
+
10
22
  export class ThreadItem implements IThreadItem {
11
23
  public readonly id = generateRandomId()
12
24
  public readonly history: string[] = []
13
25
  public strokesValidationKey: string | null = null
14
26
  public strokes: FullStrokeData[] | null
15
- public text: string | null = null
16
27
  public errorStrokesIds: string[] | null = null
28
+ public spreadSheetContent?: SpreadsheetItem[]
29
+ public equationWriterContent?: EquationItem[]
30
+ public drawBoardImage?: string
31
+ public hintNumber: number
32
+ public studentInput: string
17
33
 
18
34
  public constructor(props?: ThreadItemProps | null) {
19
35
  this.strokes = props?.strokes ?? null
20
- this.text = props?.text ?? null
21
36
  this.strokesValidationKey = props?.key ?? null
37
+ this.spreadSheetContent = props?.spreadSheetContent
38
+ this.equationWriterContent = props?.equationWriterContent
39
+ this.drawBoardImage = props?.drawBoardImage
40
+ this.hintNumber = props?.hintNumber ?? DEFAULT_HINT_NUMBER
41
+ this.studentInput = props?.studentInput ?? DEFAULT_STUDENT_INPUT
22
42
  }
23
43
 
24
44
  public setStrokes(strokes: FullStrokeData[]) {
@@ -26,11 +46,6 @@ export class ThreadItem implements IThreadItem {
26
46
  return this
27
47
  }
28
48
 
29
- public setText(text: string) {
30
- this.text = text
31
- return this
32
- }
33
-
34
49
  public setValidationKey(key: string) {
35
50
  this.strokesValidationKey = key
36
51
  return this
@@ -41,19 +56,57 @@ export class ThreadItem implements IThreadItem {
41
56
  return this
42
57
  }
43
58
 
59
+ public setSpreadSheetContent(content: SpreadsheetItem[]) {
60
+ this.spreadSheetContent = content
61
+ return this
62
+ }
63
+
64
+ public setEquationWriterContent(content: EquationItem[]) {
65
+ this.equationWriterContent = content
66
+ return this
67
+ }
68
+
69
+ public setDrawBoardImage(image: string) {
70
+ this.drawBoardImage = image
71
+ return this
72
+ }
73
+
74
+ public setHintNumber(hintNumber: number) {
75
+ this.hintNumber = hintNumber
76
+ return this
77
+ }
78
+
79
+ public setStudentInput(studentInput: string) {
80
+ this.studentInput = studentInput
81
+ return this
82
+ }
83
+
84
+ private getBaseHintProps() {
85
+ return {
86
+ hintNumber: this.hintNumber,
87
+ studentInput: this.studentInput,
88
+ ...(this.drawBoardImage && { drawBoardImage: this.drawBoardImage }),
89
+ }
90
+ }
91
+
44
92
  public getNextHintProps() {
93
+ const baseProps = this.getBaseHintProps()
45
94
  if (this.history.length) {
46
- return {
47
- previousHint: this.history[this.history.length - 1],
48
- }
95
+ return { previousHint: this.history[this.history.length - 1], ...baseProps }
49
96
  }
50
97
 
51
- if (this.text) {
52
- return { drawBoardText: this.text }
98
+ if (this.strokes?.length) {
99
+ return { stroke: this.strokes, ...baseProps }
53
100
  }
54
101
 
55
- if (this.strokes && this.strokes.length > 0) {
56
- return { stroke: this.strokes }
102
+ if (this.spreadSheetContent?.length) {
103
+ return { spreadSheetContent: this.spreadSheetContent, ...baseProps }
57
104
  }
105
+
106
+ if (this.equationWriterContent?.length) {
107
+ return { equationWriterContent: this.equationWriterContent, ...baseProps }
108
+ }
109
+
110
+ return baseProps
58
111
  }
59
112
  }
@@ -1,4 +1,6 @@
1
- import { ChatAnswer, FullStrokeData, Stroke } from './units.types'
1
+ import { ChatAnswer, FullStrokeData, Stroke, EquationItem,
2
+ SpreadsheetItem,
3
+ } from './units.types'
2
4
  import { ProblemStandard } from './model.types'
3
5
 
4
6
  export type GetAlternativesPayload = {
@@ -107,6 +109,12 @@ export type ChatHintPayload = {
107
109
  imageAltText?: string
108
110
  imageCdnId?: string
109
111
  drawBoardText?: string
112
+ spreadSheetContent?: SpreadsheetItem[]
113
+ equationWriterContent?: EquationItem[]
114
+ drawBoardImage?: string
115
+ hintNumber: number
116
+ studentInput: string
117
+ answerOptions?: string[]
110
118
  }
111
119
 
112
120
  export type ChatHintResponse = {
@@ -16,7 +16,14 @@ import {
16
16
  SendMessageResponse,
17
17
  } from './api.types'
18
18
  import { ExtendWithOptional } from '../../../lib/helpers/types'
19
- import { ChatAnswer, ChatItem, ConversationMessage, FullStrokeData } from './units.types'
19
+ import {
20
+ EquationItem,
21
+ ChatAnswer,
22
+ ChatItem,
23
+ ConversationMessage,
24
+ FullStrokeData,
25
+ SpreadsheetItem,
26
+ } from './units.types'
20
27
  import { WithAbortSignal } from '../../../lib/types/requests'
21
28
  import { RequestOptionalConfig } from '../../../lib/effector/createControllerEffect'
22
29
 
@@ -114,8 +121,12 @@ type GetVisibleStrokesResponse = {
114
121
 
115
122
  type GetBoardContentResponse = {
116
123
  strokes?: FullStrokeData[]
117
- text?: string
118
124
  validationKey: string
125
+ spreadSheetContent?: SpreadsheetItem[]
126
+ equationWriterContent?: EquationItem[]
127
+ drawBoardImage?: string
128
+ hintNumber: number
129
+ studentInput: string
119
130
  }
120
131
 
121
132
  export type IChatDrawBoardAdapter = {
@@ -2,16 +2,36 @@ export type Stroke = {
2
2
  x: number[]
3
3
  y: number[]
4
4
  }
5
+
5
6
  export type FullStrokeData = Stroke & {
6
7
  id: string
7
8
  }
8
9
 
10
+ export type EquationItem = {
11
+ id: string
12
+ value?: string
13
+ }
14
+
15
+ export type SpreadsheetItem = {
16
+ id: string
17
+ value?: string
18
+ point: {
19
+ x: number
20
+ y: number
21
+ }
22
+ }
23
+
9
24
  export type IThreadItem = {
10
25
  id: string
11
26
  strokesValidationKey: string | null
12
27
  strokes: FullStrokeData[] | null
13
28
  history: string[]
14
29
  errorStrokesIds: string[] | null
30
+ spreadSheetContent?: SpreadsheetItem[]
31
+ equationWriterContent?: EquationItem[]
32
+ drawBoardImage?: string
33
+ hintNumber: number
34
+ studentInput: string
15
35
  }
16
36
 
17
37
  export type ChatAnswer = {
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig",
3
+ "exclude": ["example", "dist"]
4
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "compilerOptions": {
3
+ "paths": {
4
+ "@magmamath/students-features": ["./src/index"]
5
+ },
6
+ "target": "esnext",
7
+ "baseUrl": "./",
8
+ "lib": [
9
+ "dom",
10
+ "dom.iterable",
11
+ "esnext"
12
+ ],
13
+ "declaration": true,
14
+ "allowJs": true,
15
+ "skipLibCheck": true,
16
+ "esModuleInterop": true,
17
+ "allowSyntheticDefaultImports": true,
18
+ "strict": true,
19
+ "forceConsistentCasingInFileNames": true,
20
+ "module": "esnext",
21
+ "moduleResolution": "node",
22
+ "resolveJsonModule": true,
23
+ "isolatedModules": true,
24
+ "jsx": "react",
25
+ "experimentalDecorators": true
26
+ },
27
+ "include": [
28
+ "src"
29
+ ],
30
+ "exclude": [
31
+ "node_modules",
32
+ "example"
33
+ ]
34
+ }