@magmamath/students-features 0.3.0-rc.13 → 0.3.0-rc.15
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/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js +1 -1
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js +1 -1
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/Chatbot.js +1 -1
- package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js +34 -86
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/api.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/messagesHelper.js +46 -0
- package/dist/commonjs/features/chatbot/model/messagesHelper.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/translation.helpers.js +69 -0
- package/dist/commonjs/features/chatbot/model/translation.helpers.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/translation.js +106 -135
- package/dist/commonjs/features/chatbot/model/translation.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
- package/dist/commonjs/index.js +9 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/lib/helpers/types.js +2 -0
- package/dist/commonjs/lib/helpers/types.js.map +1 -0
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +1 -1
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js +1 -1
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/module/features/chatbot/components/Chatbot.js +1 -1
- package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/module/features/chatbot/index.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotModel.js +34 -86
- package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/module/features/chatbot/model/api.js.map +1 -1
- package/dist/module/features/chatbot/model/messagesHelper.js +41 -0
- package/dist/module/features/chatbot/model/messagesHelper.js.map +1 -0
- package/dist/module/features/chatbot/model/translation.helpers.js +63 -0
- package/dist/module/features/chatbot/model/translation.helpers.js.map +1 -0
- package/dist/module/features/chatbot/model/translation.js +107 -136
- package/dist/module/features/chatbot/model/translation.js.map +1 -1
- package/dist/module/features/chatbot/types/model.types.js.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/helpers/types.js +2 -0
- package/dist/module/lib/helpers/types.js.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/index.d.ts +2 -2
- package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +5 -5
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/api.d.ts +5 -7
- package/dist/typescript/commonjs/features/chatbot/model/api.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/messagesHelper.d.ts +21 -0
- package/dist/typescript/commonjs/features/chatbot/model/messagesHelper.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts +9 -9
- package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/translation.helpers.d.ts +10 -0
- package/dist/typescript/commonjs/features/chatbot/model/translation.helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +4 -0
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts +20 -5
- package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/index.d.ts +1 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/lib/helpers/types.d.ts +2 -0
- package/dist/typescript/commonjs/lib/helpers/types.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/index.d.ts +2 -2
- package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +5 -5
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/api.d.ts +5 -7
- package/dist/typescript/module/features/chatbot/model/api.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/messagesHelper.d.ts +21 -0
- package/dist/typescript/module/features/chatbot/model/messagesHelper.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/translation.d.ts +9 -9
- package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/translation.helpers.d.ts +10 -0
- package/dist/typescript/module/features/chatbot/model/translation.helpers.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts +4 -0
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/translation.types.d.ts +20 -5
- package/dist/typescript/module/features/chatbot/types/translation.types.d.ts.map +1 -1
- package/dist/typescript/module/index.d.ts +1 -0
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/dist/typescript/module/lib/helpers/types.d.ts +2 -0
- package/dist/typescript/module/lib/helpers/types.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/features/chatbot/components/Alternatives/Alternatives.tsx +1 -1
- package/src/features/chatbot/components/ChatControls/ChatControls.tsx +1 -1
- package/src/features/chatbot/components/Chatbot.tsx +1 -1
- package/src/features/chatbot/index.ts +7 -2
- package/src/features/chatbot/model/ChatBotModel.ts +27 -85
- package/src/features/chatbot/model/api.ts +24 -33
- package/src/features/chatbot/model/messagesHelper.ts +48 -0
- package/src/features/chatbot/model/translation.helpers.ts +58 -0
- package/src/features/chatbot/model/translation.ts +112 -160
- package/src/features/chatbot/types/model.types.ts +5 -0
- package/src/features/chatbot/types/translation.types.ts +21 -5
- package/src/index.ts +1 -0
- package/src/lib/helpers/types.ts +1 -0
|
@@ -1,23 +1,20 @@
|
|
|
1
|
+
import { attach, createEffect, createEvent, EventCallable, restore, sample, Store } from 'effector'
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
restore,
|
|
4
|
-
attach,
|
|
5
|
-
createEffect,
|
|
6
|
-
type Effect,
|
|
7
|
-
sample,
|
|
8
|
-
Store,
|
|
9
|
-
EventCallable,
|
|
10
|
-
} from 'effector'
|
|
11
|
-
import {
|
|
12
|
-
TranslateAlternativesFxProps,
|
|
3
|
+
AddTranslationToAlternativesProps,
|
|
13
4
|
TranslateBatchFxProps,
|
|
14
5
|
TranslateMessageFxProps,
|
|
6
|
+
TranslateRequestProps,
|
|
15
7
|
} from '../types/translation.types'
|
|
16
8
|
import { ChatbotModelProps, ConversationMessage } from '../types/model.types'
|
|
17
9
|
import { GetAlternativesResponse } from '../types/api.types'
|
|
18
10
|
import { decodeHTMLEntities } from '../helpers'
|
|
19
11
|
import { ChatbotAPI } from './api'
|
|
20
12
|
import { EntityFieldStore } from '../../../lib/effector/createEntityFieldStore'
|
|
13
|
+
import {
|
|
14
|
+
addTranslationsToAlternative,
|
|
15
|
+
addTranslationToOptions,
|
|
16
|
+
getOptionsForTranslation,
|
|
17
|
+
} from './translation.helpers'
|
|
21
18
|
|
|
22
19
|
type ChatbotTranslationProps = {
|
|
23
20
|
api: ChatbotAPI
|
|
@@ -40,12 +37,7 @@ export class ChatbotTranslation {
|
|
|
40
37
|
readonly setIsTranslated = createEvent<boolean>()
|
|
41
38
|
readonly $isTranslated = restore(this.setIsTranslated, false)
|
|
42
39
|
|
|
43
|
-
readonly
|
|
44
|
-
readonly translateBatchFx: Effect<TranslateBatchFxProps['params'], ConversationMessage[]>
|
|
45
|
-
readonly translateAlternativesFx: Effect<
|
|
46
|
-
TranslateAlternativesFxProps['params'],
|
|
47
|
-
GetAlternativesResponse | null
|
|
48
|
-
>
|
|
40
|
+
readonly translateAllMessagesFx
|
|
49
41
|
|
|
50
42
|
constructor({
|
|
51
43
|
api,
|
|
@@ -60,10 +52,15 @@ export class ChatbotTranslation {
|
|
|
60
52
|
this.messagesModel = messagesModel
|
|
61
53
|
this.alternativesModel = alternativesModel
|
|
62
54
|
|
|
63
|
-
this.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
this.translateAllMessagesFx = attach({
|
|
56
|
+
source: [this.$key, this.messagesModel.$state, this.alternativesModel.$store],
|
|
57
|
+
mapParams: (params: TranslateBatchFxProps['params'], [key, messages, alternatives]) => ({
|
|
58
|
+
params,
|
|
59
|
+
messages: messages[key] ?? [],
|
|
60
|
+
alternatives,
|
|
61
|
+
}),
|
|
62
|
+
effect: this.translateBatchFx,
|
|
63
|
+
})
|
|
67
64
|
this.initTranslationSamples()
|
|
68
65
|
}
|
|
69
66
|
|
|
@@ -73,7 +70,7 @@ export class ChatbotTranslation {
|
|
|
73
70
|
return true
|
|
74
71
|
}
|
|
75
72
|
|
|
76
|
-
const allTranslated = messages.every(message => message.translatedMessage)
|
|
73
|
+
const allTranslated = messages.every((message) => message.translatedMessage)
|
|
77
74
|
if (allTranslated) {
|
|
78
75
|
this.setIsTranslated(true)
|
|
79
76
|
return true
|
|
@@ -84,160 +81,115 @@ export class ChatbotTranslation {
|
|
|
84
81
|
|
|
85
82
|
private initTranslationSamples() {
|
|
86
83
|
sample({
|
|
87
|
-
clock: this.
|
|
84
|
+
clock: this.translateAllMessagesFx.doneData,
|
|
88
85
|
source: [this.$key] as const,
|
|
89
86
|
fn: ([key], translatedMessages) => ({ key, data: translatedMessages }),
|
|
90
87
|
target: this.messagesModel.setField,
|
|
91
88
|
})
|
|
92
89
|
}
|
|
93
90
|
|
|
94
|
-
private
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
targetLanguage: params.targetLanguage,
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
if (translatedAlternatives.options) {
|
|
115
|
-
translatedAlternatives.options.hints = hintAlternatives.map((alternative, index) => ({
|
|
116
|
-
...alternative,
|
|
117
|
-
translatedMessage: decodeHTMLEntities(
|
|
118
|
-
response.data.translations[index].translatedText,
|
|
119
|
-
),
|
|
120
|
-
}))
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (defaultAlternatives.length) {
|
|
125
|
-
const defaultText = defaultAlternatives.map(({ text }) => text)
|
|
126
|
-
const response = await this.api.translateTextFx({
|
|
127
|
-
text: defaultText,
|
|
128
|
-
targetLanguage: params.targetLanguage,
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
if (translatedAlternatives.options) {
|
|
132
|
-
translatedAlternatives.options.default = defaultAlternatives.map(
|
|
133
|
-
(alternative, index) => ({
|
|
134
|
-
...alternative,
|
|
135
|
-
translatedText: decodeHTMLEntities(
|
|
136
|
-
response.data.translations[index].translatedText,
|
|
137
|
-
),
|
|
138
|
-
}),
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return translatedAlternatives as GetAlternativesResponse | null
|
|
144
|
-
}),
|
|
145
|
-
})
|
|
91
|
+
private async translateRequest<List extends Record<string, string[]>>({
|
|
92
|
+
textList,
|
|
93
|
+
targetLanguage,
|
|
94
|
+
}: TranslateRequestProps<List>) {
|
|
95
|
+
const text = Object.values(textList).flat()
|
|
96
|
+
const response = await this.api.translateTextFx({ text, targetLanguage })
|
|
97
|
+
const translatedText = response.data.translations.map(({ translatedText }) =>
|
|
98
|
+
decodeHTMLEntities(translatedText),
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
return Object.entries(textList).reduce(
|
|
102
|
+
(result, [key, texts]) => {
|
|
103
|
+
result[key as keyof List] = translatedText.splice(0, texts.length)
|
|
104
|
+
return result
|
|
105
|
+
},
|
|
106
|
+
{} as Record<keyof List, string[]>,
|
|
107
|
+
)
|
|
146
108
|
}
|
|
147
109
|
|
|
148
|
-
private
|
|
149
|
-
|
|
150
|
-
const optionsText = message.options.map(({ text }) => text)
|
|
151
|
-
const response = await this.api.translateTextFx({
|
|
152
|
-
text: [message.message, ...optionsText],
|
|
153
|
-
targetLanguage,
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
const translatedOptions = response.data.translations.slice(1)
|
|
157
|
-
const optionsCopy = [...message.options]
|
|
158
|
-
const newOptions = optionsCopy.map((option, index) => ({
|
|
159
|
-
...option,
|
|
160
|
-
translatedText: decodeHTMLEntities(translatedOptions[index].translatedText),
|
|
161
|
-
}))
|
|
162
|
-
|
|
163
|
-
return {
|
|
164
|
-
...message,
|
|
165
|
-
translatedMessage: decodeHTMLEntities(response.data.translations[0].translatedText),
|
|
166
|
-
options: newOptions,
|
|
167
|
-
} as ConversationMessage
|
|
168
|
-
})
|
|
110
|
+
private addTranslationToAlternatives(props: AddTranslationToAlternativesProps) {
|
|
111
|
+
this.alternativesModel.set(addTranslationsToAlternative(props))
|
|
169
112
|
}
|
|
170
113
|
|
|
171
|
-
private
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
: undefined
|
|
114
|
+
private readonly translateBatchFx = createEffect(
|
|
115
|
+
async ({ messages, params, alternatives }: TranslateBatchFxProps) => {
|
|
116
|
+
if (this.shouldSkipTranslation(messages)) {
|
|
117
|
+
return messages
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const defaultMessages = [this.defaultMessages.error, this.defaultMessages.endMessage]
|
|
121
|
+
const defaultOptions = [this.defaultMessages.anotherHintOption]
|
|
122
|
+
const options = getOptionsForTranslation({ lastMessage: messages.at(-1), alternatives })
|
|
123
|
+
|
|
124
|
+
const translatedTextsList = await this.translateRequest({
|
|
125
|
+
textList: {
|
|
126
|
+
messages: messages.map(({ message }) => message),
|
|
127
|
+
defaultMessages: defaultMessages.map(({ message }) => message),
|
|
128
|
+
defaultOptions: defaultOptions.map(({ text }) => text),
|
|
129
|
+
lastMessage: options.lastMessage || [],
|
|
130
|
+
alternativesHints: options.alternatives?.hints || [],
|
|
131
|
+
alternativesDefaults: options.alternatives?.default || [],
|
|
132
|
+
},
|
|
133
|
+
targetLanguage: params.targetLanguage,
|
|
134
|
+
})
|
|
193
135
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
136
|
+
translatedTextsList.defaultMessages.forEach((message, index) => {
|
|
137
|
+
defaultMessages[index].translatedMessage = message
|
|
138
|
+
})
|
|
139
|
+
translatedTextsList.defaultOptions.forEach((message, index) => {
|
|
140
|
+
defaultOptions[index].translatedText = message
|
|
141
|
+
})
|
|
142
|
+
if (options.alternatives && alternatives) {
|
|
143
|
+
this.addTranslationToAlternatives({
|
|
144
|
+
alternatives,
|
|
145
|
+
translatedHints: translatedTextsList.alternativesHints,
|
|
146
|
+
translatedDefaults: translatedTextsList.alternativesDefaults,
|
|
197
147
|
})
|
|
148
|
+
}
|
|
198
149
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
// TODO: move this AFTER state update in sample and remove initTranslationSamples it is not needed
|
|
204
|
-
// TODO: maybe just one request to translate everything
|
|
205
|
-
this.setIsTranslated(true)
|
|
206
|
-
|
|
207
|
-
const translatedMessages = response.data.translations.map(
|
|
208
|
-
({ translatedText }) => translatedText,
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
return messages.map((message, index) => {
|
|
212
|
-
const isLastMessage = index === messages.length - 1
|
|
213
|
-
return {
|
|
214
|
-
...message,
|
|
215
|
-
options: isLastMessage ? lastMessageTranslatedOptions : message.options,
|
|
216
|
-
translatedMessage: decodeHTMLEntities(translatedMessages[index]),
|
|
217
|
-
}
|
|
218
|
-
}) as ConversationMessage[]
|
|
219
|
-
}),
|
|
220
|
-
})
|
|
221
|
-
}
|
|
150
|
+
// TODO: move this AFTER state update in sample and remove initTranslationSamples it is not needed
|
|
151
|
+
this.setIsTranslated(true)
|
|
222
152
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
153
|
+
return messages.map((message, index): ConversationMessage => {
|
|
154
|
+
const isLastMessage = index === messages.length - 1
|
|
155
|
+
return {
|
|
156
|
+
...message,
|
|
157
|
+
options: isLastMessage
|
|
158
|
+
? addTranslationToOptions(message.options, translatedTextsList.lastMessage)
|
|
159
|
+
: message.options,
|
|
160
|
+
translatedMessage: translatedTextsList.messages[index],
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
},
|
|
164
|
+
)
|
|
229
165
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
166
|
+
public readonly translateMessagesFx = createEffect(
|
|
167
|
+
async ({
|
|
168
|
+
messages,
|
|
233
169
|
targetLanguage,
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
170
|
+
}: TranslateMessageFxProps): Promise<ConversationMessage[]> => {
|
|
171
|
+
const text = messages
|
|
172
|
+
.map(({ options, message }) => {
|
|
173
|
+
return [message, ...options.map(({ text }) => text)]
|
|
174
|
+
})
|
|
175
|
+
.flat()
|
|
176
|
+
|
|
177
|
+
const response = await this.api.translateTextFx({ text, targetLanguage })
|
|
178
|
+
const translatedTexts = response.data.translations.map(({ translatedText }) =>
|
|
179
|
+
decodeHTMLEntities(translatedText),
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
return messages.map((message): ConversationMessage => {
|
|
183
|
+
const options = message.options
|
|
184
|
+
const translatedMessage = translatedTexts.shift()
|
|
185
|
+
return {
|
|
186
|
+
...message,
|
|
187
|
+
translatedMessage,
|
|
188
|
+
options: addTranslationToOptions(options, translatedTexts.splice(0, options.length)),
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
},
|
|
192
|
+
)
|
|
241
193
|
|
|
242
194
|
public reset() {
|
|
243
195
|
this.setIsTranslated(false)
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ChatAnswer,
|
|
11
11
|
GetAlternativesPayload,
|
|
12
12
|
} from './api.types'
|
|
13
|
+
import { AccomplishTo } from '../../../lib/helpers/types'
|
|
13
14
|
|
|
14
15
|
export type ConversationMessage = {
|
|
15
16
|
id: string
|
|
@@ -32,6 +33,8 @@ export type ChatbotModelProps = {
|
|
|
32
33
|
messages: {
|
|
33
34
|
error: ConversationMessage
|
|
34
35
|
start: ConversationMessage
|
|
36
|
+
endMessage: ConversationMessage
|
|
37
|
+
anotherHintOption: ChatAnswer
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
|
|
@@ -66,3 +69,5 @@ export type ChatbotRenderer = {
|
|
|
66
69
|
variant: MessageVariant
|
|
67
70
|
withTextToSpeech: boolean
|
|
68
71
|
}
|
|
72
|
+
|
|
73
|
+
export type CreateMessageResponse = AccomplishTo<PostMessageResponse, ConversationMessage>
|
|
@@ -6,16 +6,32 @@ export type TranslateBatchFxProps = {
|
|
|
6
6
|
params: {
|
|
7
7
|
targetLanguage: string
|
|
8
8
|
}
|
|
9
|
+
alternatives: GetAlternativesResponse | null
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export type TranslateMessageFxProps = {
|
|
12
|
-
|
|
13
|
+
messages: ConversationMessage[]
|
|
13
14
|
targetLanguage: string
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export type
|
|
17
|
+
export type AddTranslationToAlternativesProps = {
|
|
18
|
+
alternatives: GetAlternativesResponse
|
|
19
|
+
translatedHints: string[]
|
|
20
|
+
translatedDefaults: string[]
|
|
21
|
+
}
|
|
22
|
+
export type GetOptionsProps = {
|
|
17
23
|
alternatives: GetAlternativesResponse | null
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
lastMessage: ConversationMessage | undefined
|
|
25
|
+
}
|
|
26
|
+
export type GetOptionsResult = {
|
|
27
|
+
lastMessage: string[] | null
|
|
28
|
+
alternatives: {
|
|
29
|
+
hints: string[]
|
|
30
|
+
default: string[]
|
|
31
|
+
} | null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type TranslateRequestProps<List extends Record<string, string[]>> = {
|
|
35
|
+
textList: List
|
|
36
|
+
targetLanguage: string
|
|
21
37
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useFeaturesLocalization, setFeaturesLocalization, Locale } from './shared/translation'
|
|
2
2
|
export type { LocalizationConfig } from './shared/translation'
|
|
3
|
+
export { generateRandomId } from './lib/helpers/helpers'
|
|
3
4
|
export * from './features/chatbot'
|
|
4
5
|
export * from './features/feedback'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type AccomplishTo<T, To> = Partial<Omit<To, keyof T>> & T
|