@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.
- package/.editorconfig +15 -0
- package/.eslintignore +2 -0
- package/.eslintrc +22 -0
- package/.gitattributes +3 -0
- package/.github/actions/setup/action.yml +37 -0
- package/.github/workflows/ci.yml +73 -0
- package/.gitignore +84 -0
- package/.idea/.gitignore +8 -0
- package/.idea/codeStyles/Project.xml +62 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/copilot.data.migration.agent.xml +6 -0
- package/.idea/copilot.data.migration.ask.xml +6 -0
- package/.idea/copilot.data.migration.ask2agent.xml +6 -0
- package/.idea/copilot.data.migration.edit.xml +6 -0
- package/.idea/inspectionProfiles/Project_Default.xml +8 -0
- package/.idea/jsLinters/eslint.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/students-features.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +663 -0
- package/.nvmrc +1 -0
- package/.prettierrc +11 -0
- package/.release-it.json +17 -0
- package/.watchmanconfig +1 -0
- package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +541 -0
- package/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs +28 -0
- package/.yarn/releases/yarn-3.6.1.cjs +874 -0
- package/babel.config.js +5 -0
- package/bob.config.js +25 -0
- package/dist/commonjs/features/chatbot/helpers.js +3 -0
- package/dist/commonjs/features/chatbot/helpers.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js +14 -2
- package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ThreadItem.js +52 -11
- package/dist/commonjs/features/chatbot/model/ThreadItem.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
- package/dist/module/features/chatbot/helpers.js +3 -0
- package/dist/module/features/chatbot/helpers.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotThreadManager.js +14 -2
- package/dist/module/features/chatbot/model/ChatBotThreadManager.js.map +1 -1
- package/dist/module/features/chatbot/model/ThreadItem.js +52 -11
- package/dist/module/features/chatbot/model/ThreadItem.js.map +1 -1
- package/dist/module/features/chatbot/types/model.types.js.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts +38 -13
- package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +7 -1
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +6 -2
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts +17 -0
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts +38 -13
- package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts +7 -1
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts +6 -2
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts +17 -0
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts.map +1 -1
- package/example/.expo/README.md +8 -0
- package/example/.expo/devices.json +3 -0
- package/example/.expo/web/cache/production/images/favicon/favicon-24272cdaeff82cc5facdaccd982a6f05b60c4504704bbf94c19a6388659880bb-contain-transparent/favicon-48.png +0 -0
- package/example/app.json +30 -0
- package/example/assets/adaptive-icon.png +0 -0
- package/example/assets/favicon.png +0 -0
- package/example/assets/icon.png +0 -0
- package/example/assets/splash-icon.png +0 -0
- package/example/babel.config.js +28 -0
- package/example/index.js +8 -0
- package/example/metro.config.js +18 -0
- package/example/package.json +25 -0
- package/example/src/App.tsx +8 -0
- package/example/tsconfig.json +6 -0
- package/example/yarn.lock +6552 -0
- package/package.json +1 -1
- package/src/features/chatbot/helpers.ts +1 -0
- package/src/features/chatbot/model/ChatBotThreadManager.ts +15 -2
- package/src/features/chatbot/model/ThreadItem.ts +69 -16
- package/src/features/chatbot/types/api.types.ts +9 -1
- package/src/features/chatbot/types/model.types.ts +13 -2
- package/src/features/chatbot/types/units.types.ts +20 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +34 -0
- package/yarn.lock +10904 -0
package/package.json
CHANGED
|
@@ -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
|
-
|
|
67
|
-
|
|
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 {
|
|
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.
|
|
52
|
-
return {
|
|
98
|
+
if (this.strokes?.length) {
|
|
99
|
+
return { stroke: this.strokes, ...baseProps }
|
|
53
100
|
}
|
|
54
101
|
|
|
55
|
-
if (this.
|
|
56
|
-
return {
|
|
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
|
|
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 {
|
|
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 = {
|
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
|
+
}
|