@botfabrik/engine-webclient 4.37.2 → 4.37.4

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.
@@ -1,6 +1,7 @@
1
1
  import type { SessionInfo } from '@botfabrik/engine-core';
2
+ import type { Environment } from '@botfabrik/engine-domain';
2
3
  import type { Socket } from 'socket.io';
3
4
  import { WebClientProps } from './index';
4
5
  import type { SessionInfoClientPayload, SessionInfoUserPayload } from './types';
5
- declare const createSessionInfo: (socket: Socket, name: string, sessionInfo: SessionInfo<SessionInfoClientPayload, SessionInfoUserPayload>, props: WebClientProps) => () => Promise<SessionInfo<SessionInfoClientPayload, SessionInfoUserPayload>>;
6
+ declare const createSessionInfo: (socket: Socket, clientName: string, environment: Environment, sessionInfo: SessionInfo<SessionInfoClientPayload, SessionInfoUserPayload>, props: WebClientProps) => () => Promise<SessionInfo<SessionInfoClientPayload, SessionInfoUserPayload>>;
6
7
  export default createSessionInfo;
@@ -7,7 +7,7 @@ const buildUserAgentInfos_1 = __importDefault(require("./buildUserAgentInfos"));
7
7
  const extractIP_1 = __importDefault(require("./extractIP"));
8
8
  const extractLocale_1 = __importDefault(require("./extractLocale"));
9
9
  const index_1 = require("./index");
10
- const createSessionInfoBase = async (querystrings, headers, ip, clientName, sessionInfo, props) => {
10
+ const createSessionInfoBase = async (querystrings, headers, ip, clientName, environment, sessionInfo, props) => {
11
11
  const userId = querystrings.userId;
12
12
  const userAgent = (0, buildUserAgentInfos_1.default)(headers['user-agent'], querystrings);
13
13
  const client = {
@@ -35,12 +35,12 @@ const createSessionInfoBase = async (querystrings, headers, ip, clientName, sess
35
35
  const userInfos = await props.requestUserInfos(querystrings);
36
36
  user = Object.assign({}, user, userInfos);
37
37
  }
38
- return { client, user, contexts, environment: 'PROD' };
38
+ return { client, user, contexts, environment };
39
39
  };
40
- const createSessionInfo = (socket, name, sessionInfo, props) => async () => {
40
+ const createSessionInfo = (socket, clientName, environment, sessionInfo, props) => async () => {
41
41
  const request = socket.request;
42
42
  const querystrings = socket.handshake.query;
43
43
  const ip = (0, extractIP_1.default)(request);
44
- return await createSessionInfoBase(querystrings, request.headers, ip, name, sessionInfo, props);
44
+ return await createSessionInfoBase(querystrings, request.headers, ip, clientName, environment, sessionInfo, props);
45
45
  };
46
46
  exports.default = createSessionInfo;
@@ -53,7 +53,7 @@ const createSessionInfo_1 = __importDefault(require("./createSessionInfo"));
53
53
  environment: 'PROD',
54
54
  };
55
55
  (0, globals_1.it)('without user payload', async () => {
56
- const sessionInfo = await (0, createSessionInfo_1.default)(socket, 'my-client', defaultSessionInfo, {})();
56
+ const sessionInfo = await (0, createSessionInfo_1.default)(socket, 'my-client', 'TEST', defaultSessionInfo, {})();
57
57
  // client
58
58
  (0, globals_1.expect)(sessionInfo.client.name).toBe('my-client');
59
59
  (0, globals_1.expect)(sessionInfo.client.type).toBe('webclient');
@@ -83,7 +83,7 @@ const createSessionInfo_1 = __importDefault(require("./createSessionInfo"));
83
83
  const props = {
84
84
  requestUserInfos,
85
85
  };
86
- const sessionInfo = await (0, createSessionInfo_1.default)(socket, 'my-client', defaultSessionInfo, props)();
86
+ const sessionInfo = await (0, createSessionInfo_1.default)(socket, 'my-client', 'TEST', defaultSessionInfo, props)();
87
87
  (0, globals_1.expect)(sessionInfo.user.id).toBe('hans.muster@PRIMARY');
88
88
  (0, globals_1.expect)(sessionInfo.user.displayName).toBe('Hans Muster');
89
89
  (0, globals_1.expect)(sessionInfo.user.payload.username).toBe('hans.muster');
@@ -97,10 +97,11 @@ const createSessionInfo_1 = __importDefault(require("./createSessionInfo"));
97
97
  const props = {
98
98
  requestUserInfos,
99
99
  };
100
- const sessionInfo = await (0, createSessionInfo_1.default)(socket, 'my-client', defaultSessionInfo, props)();
100
+ const sessionInfo = await (0, createSessionInfo_1.default)(socket, 'my-client', 'TEST', defaultSessionInfo, props)();
101
101
  (0, globals_1.expect)(sessionInfo.user.id).toBe('user-id');
102
102
  (0, globals_1.expect)(sessionInfo.user.displayName).toBe('Webseiten Besucher');
103
103
  (0, globals_1.expect)(sessionInfo.user.locale).toBe('de_DE');
104
104
  (0, globals_1.expect)(sessionInfo.user.payload).toStrictEqual({});
105
+ (0, globals_1.expect)(sessionInfo.environment).toBe('TEST');
105
106
  });
106
107
  });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Client, SessionInfoUser } from '@botfabrik/engine-core';
2
+ import type { Environment } from '@botfabrik/engine-domain';
2
3
  import { Action } from '@botfabrik/engine-domain';
3
4
  import { SpeechToTextProps } from './speechToText';
4
5
  import type { SessionInfoUserPayload, WebclientMiddlewareState } from './types';
@@ -23,6 +24,6 @@ export declare enum Devices {
23
24
  Desktop = "desktop",
24
25
  None = "none"
25
26
  }
26
- declare const _default: (clientName: string, props: WebClientProps) => Client<WebclientMiddlewareState>;
27
+ declare const _default: (clientName: string, environment: Environment, props: WebClientProps) => Client<WebclientMiddlewareState>;
27
28
  export default _default;
28
29
  export declare const CLIENT_TYPE = "webclient";
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@ var Devices;
45
45
  Devices["Desktop"] = "desktop";
46
46
  Devices["None"] = "none";
47
47
  })(Devices = exports.Devices || (exports.Devices = {}));
48
- exports.default = (clientName, props) => async (bot) => {
48
+ exports.default = (clientName, environment, props) => async (bot) => {
49
49
  const logger = bot.logger;
50
50
  bot.webserver.express.enable('trust proxy');
51
51
  bot.webserver.express.get('/', (_req, res) => {
@@ -97,7 +97,7 @@ exports.default = (clientName, props) => async (bot) => {
97
97
  const { sessionId, sessionInfo: defaultSessionInfo, isNew, } = await (0, requestSessionData_1.default)(querystrings, sessionsCollection, clientName, props);
98
98
  // create a channel for each session
99
99
  socket.join(sessionId);
100
- const sessionInfo = await (0, createSessionInfo_1.default)(socket, clientName, defaultSessionInfo, props)();
100
+ const sessionInfo = await (0, createSessionInfo_1.default)(socket, clientName, environment, defaultSessionInfo, props)();
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botfabrik/engine-webclient",
3
- "version": "4.37.2",
3
+ "version": "4.37.4",
4
4
  "description": "Webclient for Botfabriks Bot Engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,10 +18,10 @@
18
18
  "prepublishOnly": "npm run build"
19
19
  },
20
20
  "dependencies": {
21
- "@botfabrik/engine-core": "^4.37.2",
22
- "@botfabrik/engine-domain": "^4.37.2",
23
- "@botfabrik/engine-transcript-export": "^4.37.2",
24
- "@botfabrik/engine-utils": "^4.37.2",
21
+ "@botfabrik/engine-core": "^4.37.4",
22
+ "@botfabrik/engine-domain": "^4.37.4",
23
+ "@botfabrik/engine-transcript-export": "^4.37.4",
24
+ "@botfabrik/engine-utils": "^4.37.4",
25
25
  "@google-cloud/speech": "^5.1.0",
26
26
  "accept-language-parser": "^1.5.0",
27
27
  "express": "^4.18.1",
@@ -40,5 +40,5 @@
40
40
  "rimraf": "^3.0.2",
41
41
  "typescript": "^4.8.3"
42
42
  },
43
- "gitHead": "7e51f1f46b99db000b74ef015f5e561e0139480e"
43
+ "gitHead": "39de3392b222a4353161bfd6fe0b4a2d9551dc85"
44
44
  }