@botfabrik/engine-webclient 4.43.2 → 4.44.7
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/README.md +75 -75
- package/dist/client/assets/index-2bed803d.js.map +1 -1
- package/dist/client/index.html +18 -20
- package/dist/createSessionInfo.test.js +10 -2
- package/dist/embed/bundle.js.map +1 -1
- package/dist/extractIP.test.js +4 -1
- package/dist/index.js +20 -6
- package/dist/middleware/index.js +3 -1
- package/dist/requestSessionData.js +4 -1
- package/dist/requestSessionData.test.js +10 -2
- package/dist/speechToText.js +5 -2
- package/package.json +43 -43
package/dist/extractIP.test.js
CHANGED
|
@@ -9,7 +9,10 @@ const extractIP_1 = __importDefault(require("./extractIP"));
|
|
|
9
9
|
(0, globals_1.it)('takes IP from x-forwarded-for header', () => {
|
|
10
10
|
const request = {
|
|
11
11
|
headers: { 'x-forwarded-for': '192.168.1.1, 192.168.1.1' },
|
|
12
|
-
connection: {
|
|
12
|
+
connection: {
|
|
13
|
+
remoteAddress: '192.168.1.2',
|
|
14
|
+
socket: { remoteAddress: '192.168.1.4' },
|
|
15
|
+
},
|
|
13
16
|
socket: { remoteAddress: '192.168.1.3' },
|
|
14
17
|
};
|
|
15
18
|
(0, globals_1.expect)((0, extractIP_1.default)(request)).toBe('192.168.1.1');
|
package/dist/index.js
CHANGED
|
@@ -101,10 +101,15 @@ exports.default = (clientName, environment, props) => async (bot) => {
|
|
|
101
101
|
const session = await bot.createSession(sessionId, sessionInfo);
|
|
102
102
|
// sending active language and translations to client
|
|
103
103
|
const clientLocale = (0, getSupportedClientLocale_1.default)(session.translator.locale);
|
|
104
|
-
nsp
|
|
104
|
+
nsp
|
|
105
|
+
.to(sessionId)
|
|
106
|
+
.emit('set-translations', clientLocale, bot.translation.getResourceBundle(clientLocale)[clientName] || {});
|
|
105
107
|
// sending persisted state to client
|
|
106
108
|
const previousConversations = await (0, loadPreviousConversation_1.default)(bot.store, sessionId);
|
|
107
|
-
nsp.to(sessionId).emit('restore-client-state', {
|
|
109
|
+
nsp.to(sessionId).emit('restore-client-state', {
|
|
110
|
+
sessionId,
|
|
111
|
+
messages: previousConversations,
|
|
112
|
+
});
|
|
108
113
|
// enable speech support
|
|
109
114
|
if (props.speech) {
|
|
110
115
|
nsp.to(sessionId).emit('enable-speech-support');
|
|
@@ -135,8 +140,12 @@ exports.default = (clientName, environment, props) => async (bot) => {
|
|
|
135
140
|
if (isNew && props.getStartedAction) {
|
|
136
141
|
await session.dispatch(props.getStartedAction);
|
|
137
142
|
}
|
|
138
|
-
if (isNew &&
|
|
139
|
-
|
|
143
|
+
if (isNew &&
|
|
144
|
+
props.expandChatWindowAtStart &&
|
|
145
|
+
props.expandChatWindowAtStart !== Devices.None) {
|
|
146
|
+
nsp
|
|
147
|
+
.to(session.id)
|
|
148
|
+
.emit('expand-window', { devices: props.expandChatWindowAtStart });
|
|
140
149
|
}
|
|
141
150
|
// forward actions from webclient
|
|
142
151
|
socket.on('action', async (action) => {
|
|
@@ -146,8 +155,13 @@ exports.default = (clientName, environment, props) => async (bot) => {
|
|
|
146
155
|
await session.dispatch((0, engine_domain_1.guestDisconnected)(sessionId));
|
|
147
156
|
});
|
|
148
157
|
socket.on('conversation-rating', async (rating) => {
|
|
149
|
-
sessionsCollection.updateOne({ _id: sessionId }, {
|
|
150
|
-
|
|
158
|
+
sessionsCollection.updateOne({ _id: sessionId }, {
|
|
159
|
+
$set: { 'sessionInfo.client.payload.conversationRating': rating },
|
|
160
|
+
});
|
|
161
|
+
session.dispatch({
|
|
162
|
+
type: engine_domain_1.ActionTypes.CONVERSATION_RATING_FROM_GUEST,
|
|
163
|
+
payload: { rating },
|
|
164
|
+
});
|
|
151
165
|
});
|
|
152
166
|
socket.on('audio-message', async (buffer) => {
|
|
153
167
|
if (props.speech) {
|
package/dist/middleware/index.js
CHANGED
|
@@ -18,7 +18,9 @@ exports.default = (clientName, nsp) => async () => {
|
|
|
18
18
|
const expandChatWindow = (action) => {
|
|
19
19
|
const devices = action.payload?.devices;
|
|
20
20
|
if (!!devices && devices !== __1.Devices.None) {
|
|
21
|
-
nsp
|
|
21
|
+
nsp
|
|
22
|
+
.to(session.id)
|
|
23
|
+
.emit('expand-window', { devices: action.payload.devices });
|
|
22
24
|
}
|
|
23
25
|
};
|
|
24
26
|
const sessionInfo = session.getSessionInfo();
|
|
@@ -7,7 +7,10 @@ const requestSessionData = async (querystrings, sessionsCollection, clientName,
|
|
|
7
7
|
'sessionInfo.client.type': index_1.CLIENT_TYPE,
|
|
8
8
|
'sessionInfo.client.name': clientName,
|
|
9
9
|
};
|
|
10
|
-
let findSessionRecordQuery = {
|
|
10
|
+
let findSessionRecordQuery = {
|
|
11
|
+
_id: querystrings.sessionId,
|
|
12
|
+
...baseQuery,
|
|
13
|
+
};
|
|
11
14
|
if (props.requestSessionRecordQuery) {
|
|
12
15
|
const customQuery = await props.requestSessionRecordQuery(querystrings);
|
|
13
16
|
findSessionRecordQuery = Object.assign({}, baseQuery, customQuery);
|
|
@@ -21,7 +21,11 @@ const requestSessionData_1 = __importDefault(require("./requestSessionData"));
|
|
|
21
21
|
};
|
|
22
22
|
const { sessionId, isNew } = await (0, requestSessionData_1.default)(querystrings, sessionsCollection, 'test-bot', {});
|
|
23
23
|
(0, globals_1.expect)(findOne).toHaveBeenCalledTimes(1);
|
|
24
|
-
(0, globals_1.expect)(findOne).toHaveBeenCalledWith({
|
|
24
|
+
(0, globals_1.expect)(findOne).toHaveBeenCalledWith({
|
|
25
|
+
_id: 'session-id',
|
|
26
|
+
'sessionInfo.client.name': 'test-bot',
|
|
27
|
+
'sessionInfo.client.type': 'webclient',
|
|
28
|
+
}, { _id: 1, sessionInfo: 1 });
|
|
25
29
|
(0, globals_1.expect)(sessionId).toBe('generated-uuid');
|
|
26
30
|
(0, globals_1.expect)(isNew).toBe(true);
|
|
27
31
|
});
|
|
@@ -33,7 +37,11 @@ const requestSessionData_1 = __importDefault(require("./requestSessionData"));
|
|
|
33
37
|
};
|
|
34
38
|
const { sessionId, isNew } = await (0, requestSessionData_1.default)(querystrings, sessionsCollection, 'test-bot', {});
|
|
35
39
|
(0, globals_1.expect)(findOne).toHaveBeenCalledTimes(1);
|
|
36
|
-
(0, globals_1.expect)(findOne).toHaveBeenCalledWith({
|
|
40
|
+
(0, globals_1.expect)(findOne).toHaveBeenCalledWith({
|
|
41
|
+
_id: 'session-id',
|
|
42
|
+
'sessionInfo.client.name': 'test-bot',
|
|
43
|
+
'sessionInfo.client.type': 'webclient',
|
|
44
|
+
}, { _id: 1, sessionInfo: 1 });
|
|
37
45
|
(0, globals_1.expect)(sessionId).toBe('session-id');
|
|
38
46
|
(0, globals_1.expect)(isNew).toBe(false);
|
|
39
47
|
});
|
package/dist/speechToText.js
CHANGED
|
@@ -16,7 +16,9 @@ const speechToText = (speechProps, locale, speechBytes) => {
|
|
|
16
16
|
const audio = {
|
|
17
17
|
content: speechBytes,
|
|
18
18
|
};
|
|
19
|
-
const phrases = speechProps.contextPhrases && speechProps.contextPhrases[locale]
|
|
19
|
+
const phrases = speechProps.contextPhrases && speechProps.contextPhrases[locale]
|
|
20
|
+
? speechProps.contextPhrases[locale]
|
|
21
|
+
: [];
|
|
20
22
|
const config = {
|
|
21
23
|
encoding: 'LINEAR16',
|
|
22
24
|
sampleRateHertz: 16000,
|
|
@@ -37,7 +39,8 @@ const speechToText = (speechProps, locale, speechBytes) => {
|
|
|
37
39
|
.then((data) => {
|
|
38
40
|
const response = data[0];
|
|
39
41
|
const transcription = response?.results
|
|
40
|
-
?.map((result) => (result?.alternatives && result.alternatives[0]?.transcript) ||
|
|
42
|
+
?.map((result) => (result?.alternatives && result.alternatives[0]?.transcript) ||
|
|
43
|
+
'')
|
|
41
44
|
.join('\n') || '';
|
|
42
45
|
resolve(transcription);
|
|
43
46
|
})
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
2
|
+
"name": "@botfabrik/engine-webclient",
|
|
3
|
+
"version": "4.44.7",
|
|
4
|
+
"description": "Webclient for Botfabriks Bot Engine",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "npm run clean && npm run build:client && npm run build:server && npm run build:script-tag && npm run copy:client && npm run copy:script-tag",
|
|
9
|
+
"build:script-tag": "(cd ./script-tag && npm run build && cd ..)",
|
|
10
|
+
"build:client": "(cd ./client && npm run build && cd ..)",
|
|
11
|
+
"build:server": "tsc",
|
|
12
|
+
"copy:script-tag": "copyfiles -u 2 ./script-tag/dist/**/*.* ./dist/embed && copyfiles -u 2 ./script-tag/public/**/*.* ./dist/embed",
|
|
13
|
+
"copy:client": "copyfiles -u 2 ./client/dist/** ./dist/client && copyfiles -u 2 ./client/dist/**/*.* ./dist/client",
|
|
14
|
+
"clean": "rimraf ./dist",
|
|
15
|
+
"test": "jest --verbose",
|
|
16
|
+
"test:watch": "jest --watch",
|
|
17
|
+
"prepare": "(cd client && npm install); (cd script-tag && npm install)",
|
|
18
|
+
"prepublishOnly": "npm run build",
|
|
19
|
+
"update": "npx npm-check-updates -i"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@botfabrik/engine-core": "^4.44.7",
|
|
23
|
+
"@botfabrik/engine-domain": "^4.44.7",
|
|
24
|
+
"@botfabrik/engine-transcript-export": "^4.44.7",
|
|
25
|
+
"@botfabrik/engine-utils": "^4.44.7",
|
|
26
|
+
"@google-cloud/speech": "^6.0.1",
|
|
27
|
+
"accept-language-parser": "^1.5.0",
|
|
28
|
+
"express": "^4.18.2",
|
|
29
|
+
"mongodb": "^5.7.0",
|
|
30
|
+
"socket.io": "4.7.2",
|
|
31
|
+
"ua-parser-js": "^1.0.35",
|
|
32
|
+
"uuid": "^9.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/accept-language-parser": "^1.5.3",
|
|
36
|
+
"@types/express": "^4.17.17",
|
|
37
|
+
"@types/serve-static": "^1.15.2",
|
|
38
|
+
"@types/ua-parser-js": "^0.7.36",
|
|
39
|
+
"@types/uuid": "^9.0.2",
|
|
40
|
+
"copyfiles": "^2.4.1",
|
|
41
|
+
"rimraf": "^5.0.1",
|
|
42
|
+
"typescript": "^5.1.6"
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "e0c2d4df522be4f2a367fb693b1a4b9b863d57f3"
|
|
45
45
|
}
|