wingbot 3.40.0 → 3.40.2

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.40.0",
3
+ "version": "3.40.2",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Plugins.js CHANGED
@@ -42,7 +42,7 @@ const wrapPluginFunction = require('./utils/wrapPluginFunction');
42
42
  * Custom code plugins for BuildRouter and wingbot.ai
43
43
  *
44
44
  * @template {object} [S=object]
45
- * @template {object} C=Object
45
+ * @template {object} [C=Object]
46
46
  * @class Plugins
47
47
  */
48
48
  class Plugins {
@@ -72,7 +72,7 @@ class Plugins {
72
72
  *
73
73
  * @param {string} name
74
74
  * @param {object} [paramsData]
75
- * @param {Map<string,Function[]>|Object<string,Function>} [items]
75
+ * @param {Map<string,Function[]>|Object<string,Middleware<S>>} [items]
76
76
  * @param {object} [context]
77
77
  * @param {boolean} [context.isLastIndex]
78
78
  * @param {Router} [context.router]
@@ -104,6 +104,7 @@ class Plugins {
104
104
  let useItems = items;
105
105
 
106
106
  if (!(items instanceof Map)) {
107
+ // @ts-ignore
107
108
  useItems = new Map(
108
109
  Object.keys(items)
109
110
  .map((key) => [
package/src/Responder.js CHANGED
@@ -25,7 +25,8 @@ const EXCEPTION_HOPCOUNT_THRESHOLD = 5;
25
25
  /** @typedef {import('./Request')} Request */
26
26
 
27
27
  /**
28
- * @enum {string}
28
+ * @enum {string} ExpectedInput
29
+ * @readonly
29
30
  */
30
31
  const ExpectedInput = {
31
32
  TYPE_PASSWORD: 'password'
@@ -95,7 +96,7 @@ class Responder {
95
96
  };
96
97
 
97
98
  /**
98
- * @type {Object<string,ExpectedInput>}
99
+ * @prop {Object<keyof ExpectedInput,ExpectedInput>}
99
100
  */
100
101
  this.ExpectedInputTypes = ExpectedInput;
101
102
 
package/src/Tester.js CHANGED
@@ -121,7 +121,9 @@ class Tester {
121
121
  /**
122
122
  * @prop {object} predefined test data to use
123
123
  */
124
- this.testData = {};
124
+ this.testData = {
125
+ automatedTesting: true
126
+ };
125
127
 
126
128
  /**
127
129
  * @prop {boolean} allow tester to process empty responses
@@ -228,6 +230,8 @@ class Tester {
228
230
  && !(res.status === 204 && this._pluginBlocksCollector.length > 0)
229
231
  && !(res.status === 204 && this.allowEmptyResponse)) {
230
232
 
233
+ this.debug();
234
+
231
235
  if (res.status === 204) {
232
236
  throw Object.assign(new Error(`Bot did not respond (status ${res.status})`), { code: res.status });
233
237
  }
@@ -21,6 +21,7 @@ const stateData = require('./stateData');
21
21
  * @param {Request} req
22
22
  * @param {Responder} res
23
23
  * @param {string} template
24
+ * @returns {string}
24
25
  * @example
25
26
  *
26
27
  * const { compileWithState } = require('wingbot');
@@ -69,13 +69,19 @@ const StepState = {
69
69
  async function getNextStep (req, res, postBack) {
70
70
  let invalid = null;
71
71
  const {
72
- _slotState: slotState, _slotSteps: steps, _slotDone: doneAction
72
+ _slotState: slotState, _slotSteps: steps, _slotDone: doneAction, ...rest
73
73
  } = { ...req.state, ...res.newState };
74
74
 
75
75
  for (const slot of slotState) {
76
76
  const step = steps.find((s) => s.entity === slot.e);
77
+ if (step && slot.s === StepState.INITIALIZED && (
78
+ (step.type !== StepType.MULTI && rest[slot.e])
79
+ || (step.type === StepType.MULTI && rest[slot.e.replace(/^@/, '+')] && rest[slot.e.replace(/^@/, '+')].length))) {
80
+
81
+ slot.s = StepState.FILLED;
82
+ }
83
+
77
84
  if (slot.s === StepState.FILLED && step && step.validateAction) {
78
- // eslint-disable-next-line
79
85
  await postBack(step.validateAction, {}, true);
80
86
  if (res.finalMessageSent) {
81
87
  invalid = step;