wingbot 3.52.2-alpha.7 → 3.52.3

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.52.2-alpha.7",
3
+ "version": "3.52.3",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/AiMatching.js CHANGED
@@ -518,18 +518,8 @@ class AiMatching {
518
518
  finalScore -= (matchedEntitiesTextLength / textLength) * remainingScore;
519
519
  }
520
520
 
521
- // eslint-disable-next-line no-console
522
- console.log({
523
- finalScore,
524
- rule,
525
- baseScore,
526
- score,
527
- allOptional,
528
- entities,
529
- reqEntities,
530
- matchedEntitiesTextLength,
531
- countOfAdditionalItems
532
- });
521
+ // eslint-disable-next-line no-console,max-len,object-curly-newline
522
+ // console.log({ finalScore, rule, baseScore, score, allOptional, entities, reqEntities, matchedEntitiesTextLength, countOfAdditionalItems });
533
523
 
534
524
  if (finalScore <= 0) {
535
525
  return null;
@@ -613,10 +603,8 @@ class AiMatching {
613
603
  : (x) => x
614
604
  );
615
605
 
616
- // eslint-disable-next-line no-console
617
- console.log({
618
- wantedEntities, entitiesScore, handicap, matched, minScore, requestIntent
619
- });
606
+ // eslint-disable-next-line no-console,max-len,object-curly-newline
607
+ // console.log({ wantedEntities, entitiesScore, handicap, matched, minScore, requestIntent });
620
608
 
621
609
  const allOptional = wantedEntities.every((e) => e.optional
622
610
  && (!e.op || useEntities.every((n) => n.entity !== e.entity)));
@@ -630,10 +618,8 @@ class AiMatching {
630
618
 
631
619
  const score = Math.round((scoreWithHandicap * multiMatchGain) * 10000) / 10000;
632
620
 
633
- // eslint-disable-next-line no-console
634
- console.log({
635
- IMS: score, normalizedScore, scoreWithHandicap, multiMatchGain, wantedEntities
636
- });
621
+ // eslint-disable-next-line no-console,max-len,object-curly-newline
622
+ // console.log({ IMS: score, normalizedScore, scoreWithHandicap, multiMatchGain, wantedEntities });
637
623
 
638
624
  return {
639
625
  score,
@@ -752,10 +738,8 @@ class AiMatching {
752
738
  }
753
739
  }
754
740
 
755
- // eslint-disable-next-line no-console
756
- console.log({
757
- wantedEntities, sum, handicap, rl: requestEntities.length, ml: matched.length
758
- });
741
+ // eslint-disable-next-line no-console,max-len
742
+ // console.log({ wantedEntities, sum, handicap, rl: requestEntities.length, ml: matched.length });
759
743
 
760
744
  // @todo - neni mozne, by doslo k negativnimu handicapu
761
745
  handicap += (requestEntities.length + fromState - matched.length)
package/src/Processor.js CHANGED
@@ -241,14 +241,14 @@ class Processor extends EventEmitter {
241
241
  }
242
242
 
243
243
  _createPostBack (postbackAcumulator, req, res, features) {
244
- const postBack = (action, inputData = {}, dontWaitTillEndOfLoop = false) => {
244
+ const postBack = (action, inputData = {}, dispatchSync = false) => {
245
245
  let data = inputData;
246
246
  if (typeof data === 'function') {
247
247
  // @ts-ignore
248
248
  data = data();
249
249
  }
250
250
 
251
- if (dontWaitTillEndOfLoop) {
251
+ if (dispatchSync) {
252
252
  let previousAction;
253
253
  return Promise.resolve(data)
254
254
  .then((resolvedData) => {
@@ -283,7 +283,7 @@ class Processor extends EventEmitter {
283
283
  postbackAcumulator.push({ action, data, features });
284
284
  }
285
285
 
286
- return Promise.resolve();
286
+ return Promise.resolve(undefined);
287
287
  };
288
288
 
289
289
  return postBack;
package/src/Router.js CHANGED
@@ -15,18 +15,48 @@ function defaultPathContext () {
15
15
  }
16
16
 
17
17
  /**
18
- *
18
+ * @typedef {true|false|null|undefined|-1|void} RoutingInstruction
19
+ */
20
+
21
+ /**
22
+ * @callback PostBackDataCallback
23
+ * @returns {object|Promise<object>}
24
+ */
25
+
26
+ /**
27
+ * @callback PostBack postback function
28
+ * @param {string} [action]
29
+ * @param {object|PostBackDataCallback} [data]
30
+ * @param {boolean} [dispatchSync]
31
+ * @returns {Promise<RoutingInstruction>}
32
+ */
33
+
34
+ /**
19
35
  * @template {object} [S=object]
20
36
  * @template {object} [C=object]
21
37
  * @callback Resolver processing function
22
38
  * @param {Request<S,C>} [req]
23
39
  * @param {Responder} [res]
24
- * @param {Function} [postBack]
40
+ * @param {PostBack} [postBack]
41
+ * @returns {RoutingInstruction}
25
42
  */
26
43
 
27
44
  /**
45
+ * @template {object} [S=object]
46
+ * @template {object} [C=object]
47
+ * @callback Reduce processing function
48
+ * @param {Request<S,C>} [req]
49
+ * @param {Responder} [res]
50
+ * @param {PostBack} [postBack]
51
+ * @param {string} [path]
52
+ * @returns {RoutingInstruction}
53
+ */
54
+
55
+ /**
56
+ * @template {object} [S=object]
57
+ * @template {object} [C=object]
28
58
  * @typedef {object} IRouter
29
- * @prop {Function} reduce
59
+ * @prop {Reduce<S,C>} reduce
30
60
  */
31
61
 
32
62
  /**