wingbot 3.53.0-alpha.1 → 3.53.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.53.0-alpha.1",
3
+ "version": "3.53.0",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,9 +5,12 @@
5
5
  module.exports = async (req, res) => {
6
6
  [...Object.keys(req.state), ...Object.keys(res.newState)]
7
7
  .forEach((key) => {
8
- const match = key.match(/^(_~_R_|_R_)/);
9
- if (match) {
10
- res.setState({ [key]: null });
8
+ const match = key.match(/^_R_/);
9
+ if (match && (req.state[key] || res.newState[key])) {
10
+ res.setState({
11
+ [key]: null,
12
+ [`_~${key}`]: { t: 't', c: 1 }
13
+ });
11
14
  }
12
15
  });
13
16
  };
@@ -195,7 +195,9 @@ function selectTranslation (resolverId, params, texts, data) {
195
195
  if (texts.length === 1) {
196
196
  return [
197
197
  renderMessageText(texts[0].t, data),
198
- seqState && resolverId ? { [key]: null } : {}
198
+ seqState && resolverId
199
+ ? vars.expiresAfter(key, null, 1)
200
+ : {}
199
201
  ];
200
202
  }
201
203
 
@@ -220,7 +222,9 @@ function selectTranslation (resolverId, params, texts, data) {
220
222
  : Math.floor(Math.random() * texts.length);
221
223
  return [
222
224
  renderMessageText(texts[index].t, data),
223
- seqState ? vars.clear(key) : {}
225
+ seqState
226
+ ? vars.expiresAfter(key, null, 1)
227
+ : {}
224
228
  ];
225
229
  }
226
230
 
@@ -177,7 +177,7 @@ function prepareState (state, firstInTurnover, sessionCreated) {
177
177
  }
178
178
 
179
179
  if (value.t === SESSION_DIALOGUE_CONTEXT) {
180
- if (value.p === state._lastVisitedPath) {
180
+ if (value.p === state._lastVisitedPath && value.p !== undefined) {
181
181
  // context still matches - make it just DIALOGUE_CONTEXT
182
182
  state[key] = { // eslint-disable-line no-param-reassign
183
183
  t: DIALOG_CONTEXT,
@@ -225,7 +225,9 @@ function mergeState (previousState, req, res, senderStateUpdate, firstInTurnover
225
225
  continue;
226
226
  }
227
227
  const value = res.newState[key];
228
- if (DIALOGUE_CONTEXT_TYPES.includes(value.t) && typeof value.p === 'undefined') {
228
+ if (DIALOGUE_CONTEXT_TYPES.includes(value.t) && typeof value.p === 'undefined'
229
+ && res.newState._lastVisitedPath !== undefined) {
230
+
229
231
  Object.assign(value, { p: res.newState._lastVisitedPath });
230
232
  }
231
233
  }