@webuildbots/webuildbots-sdk 8.3.1 → 9.2.1

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.
@@ -0,0 +1,8 @@
1
+ import { RulesLogic } from 'json-logic-js';
2
+ import BlockBuilder from './block-builder';
3
+ export default class LogicBB extends BlockBuilder {
4
+ constructor();
5
+ formId(formId: string): this;
6
+ defaultMappingBlockId(blockId: string): this;
7
+ condition(condition: RulesLogic, blockId: string): this;
8
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ var block_enums_1 = require("../../const/block-enums");
20
+ var block_builder_1 = __importDefault(require("./block-builder"));
21
+ var LogicBB = /** @class */ (function (_super) {
22
+ __extends(LogicBB, _super);
23
+ function LogicBB() {
24
+ var _this = _super.call(this) || this;
25
+ _this.block.type = block_enums_1.BlockTypes.FUNCTION;
26
+ _this.block.function = {};
27
+ _this.block.function.type = block_enums_1.FunctionTypes.LOGIC_BLOCK;
28
+ _this.block.function.logic = { expressions: [] };
29
+ return _this;
30
+ }
31
+ LogicBB.prototype.formId = function (formId) {
32
+ this.block.function.logic.formId = formId;
33
+ return this;
34
+ };
35
+ LogicBB.prototype.defaultMappingBlockId = function (blockId) {
36
+ this.block.function.logic.defaultMappingBlockId = blockId;
37
+ return this;
38
+ };
39
+ LogicBB.prototype.condition = function (condition, blockId) {
40
+ this.block.function.logic.expressions.push({ condition: condition, blockId: blockId });
41
+ return this;
42
+ };
43
+ return LogicBB;
44
+ }(block_builder_1.default));
45
+ exports.default = LogicBB;
@@ -1,3 +1,4 @@
1
1
  import BlockCB from './block-cb';
2
2
  export declare const backToMenu: () => BlockCB;
3
3
  export declare const speakToSomeoneCB: () => BlockCB;
4
+ export declare const tryAgainCB: (value: any, args?: any) => BlockCB;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.speakToSomeoneCB = exports.backToMenu = void 0;
6
+ exports.tryAgainCB = exports.speakToSomeoneCB = exports.backToMenu = void 0;
7
7
  var block_cb_1 = __importDefault(require("./block-cb"));
8
8
  var common_blocks_enums_1 = require("../../const/common-blocks-enums");
9
9
  var languages_enums_1 = require("../../const/languages-enums");
@@ -21,3 +21,10 @@ var speakToSomeoneCB = function () {
21
21
  .addTitle(languages_enums_1.Languages.WELSH, "Siaradwch â'r tîm");
22
22
  };
23
23
  exports.speakToSomeoneCB = speakToSomeoneCB;
24
+ var tryAgainCB = function (value, args) {
25
+ return new block_cb_1.default(value)
26
+ .addTitle(languages_enums_1.Languages.ENGLISH, 'Try again')
27
+ .addTitle(languages_enums_1.Languages.WELSH, 'Ceisio eto')
28
+ .args(args);
29
+ };
30
+ exports.tryAgainCB = tryAgainCB;
@@ -42,5 +42,6 @@ export declare enum VoiceAction {
42
42
  }
43
43
  export declare enum FunctionTypes {
44
44
  EMAIL_FORM_AS_TABLE = "email-form-as-table",
45
- UNSET_FORM = "unset-form"
45
+ UNSET_FORM = "unset-form",
46
+ LOGIC_BLOCK = "logic-block"
46
47
  }
@@ -55,4 +55,5 @@ var FunctionTypes;
55
55
  (function (FunctionTypes) {
56
56
  FunctionTypes["EMAIL_FORM_AS_TABLE"] = "email-form-as-table";
57
57
  FunctionTypes["UNSET_FORM"] = "unset-form";
58
+ FunctionTypes["LOGIC_BLOCK"] = "logic-block";
58
59
  })(FunctionTypes = exports.FunctionTypes || (exports.FunctionTypes = {}));
package/lib/index.d.ts CHANGED
@@ -21,4 +21,5 @@ import ItemBuilder from './builder/item-builder';
21
21
  import DefinedIB from './builder/defined-ib';
22
22
  import ResponseBuilder from './builder/response-builder';
23
23
  import { WebhookRequest, WebhookResponse, ResponseUnitType, ResponseUnit, BlockPointer, Client, JWTPayload } from './interfaces/webhook';
24
- export { BlockBuilder, ComplexBB, FunctionBB, EmailFormTableBB, UnsetFormBB, ImageBB, SelectBB, TextBB, VideoBB, DevSwitchBB, BlockCB, ChoiceBuilder, DefinedCB, DefinedIB, ExtensionCB, LocationCB, PhoneCB, UrlCB, GalleryBB, BasicBB, ItemBuilder, WebhookResponse, WebhookRequest, ResponseUnit, ResponseUnitType, BlockPointer, ResponseBuilder, Client, JWTPayload };
24
+ import LogicBB from './builder/block/logic-bb';
25
+ export { BlockBuilder, ComplexBB, FunctionBB, EmailFormTableBB, UnsetFormBB, ImageBB, SelectBB, TextBB, VideoBB, DevSwitchBB, LogicBB, BlockCB, ChoiceBuilder, DefinedCB, DefinedIB, ExtensionCB, LocationCB, PhoneCB, UrlCB, GalleryBB, BasicBB, ItemBuilder, WebhookResponse, WebhookRequest, ResponseUnit, ResponseUnitType, BlockPointer, ResponseBuilder, Client, JWTPayload };
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ResponseBuilder = exports.ResponseUnitType = exports.ItemBuilder = exports.BasicBB = exports.GalleryBB = exports.UrlCB = exports.PhoneCB = exports.LocationCB = exports.ExtensionCB = exports.DefinedIB = exports.DefinedCB = exports.ChoiceBuilder = exports.BlockCB = exports.DevSwitchBB = exports.VideoBB = exports.TextBB = exports.SelectBB = exports.ImageBB = exports.UnsetFormBB = exports.EmailFormTableBB = exports.FunctionBB = exports.ComplexBB = exports.BlockBuilder = void 0;
6
+ exports.ResponseBuilder = exports.ResponseUnitType = exports.ItemBuilder = exports.BasicBB = exports.GalleryBB = exports.UrlCB = exports.PhoneCB = exports.LocationCB = exports.ExtensionCB = exports.DefinedIB = exports.DefinedCB = exports.ChoiceBuilder = exports.BlockCB = exports.LogicBB = exports.DevSwitchBB = exports.VideoBB = exports.TextBB = exports.SelectBB = exports.ImageBB = exports.UnsetFormBB = exports.EmailFormTableBB = exports.FunctionBB = exports.ComplexBB = exports.BlockBuilder = void 0;
7
7
  var block_builder_1 = __importDefault(require("./builder/block/block-builder"));
8
8
  exports.BlockBuilder = block_builder_1.default;
9
9
  var basic_bb_1 = __importDefault(require("./builder/block/basic-bb"));
@@ -50,3 +50,5 @@ var response_builder_1 = __importDefault(require("./builder/response-builder"));
50
50
  exports.ResponseBuilder = response_builder_1.default;
51
51
  var webhook_1 = require("./interfaces/webhook");
52
52
  Object.defineProperty(exports, "ResponseUnitType", { enumerable: true, get: function () { return webhook_1.ResponseUnitType; } });
53
+ var logic_bb_1 = __importDefault(require("./builder/block/logic-bb"));
54
+ exports.LogicBB = logic_bb_1.default;
@@ -1,5 +1,7 @@
1
1
  export default interface Block {
2
+ _id?: any;
2
3
  version: number;
4
+ clientDbId?: any;
3
5
  created: Date;
4
6
  deleted?: boolean;
5
7
  delay?: number;
@@ -10,6 +12,7 @@ export default interface Block {
10
12
  next?: string;
11
13
  onReply?: {
12
14
  blockId: string;
15
+ module?: string;
13
16
  args?: any;
14
17
  };
15
18
  formFieldCallback?: {
@@ -71,11 +74,12 @@ export default interface Block {
71
74
  value?: any;
72
75
  };
73
76
  profile?: any;
77
+ formValue?: string;
74
78
  userStatus?: string;
75
- formField?: boolean;
76
79
  session?: any;
77
80
  functionArgs?: any;
78
81
  persistentMenu?: boolean;
82
+ next?: string;
79
83
  selectBlock?: {
80
84
  id: string;
81
85
  };
@@ -95,26 +99,57 @@ export default interface Block {
95
99
  value?: any;
96
100
  };
97
101
  profile?: any;
102
+ formValue?: string;
98
103
  userStatus?: string;
99
- formField?: boolean;
100
104
  session?: any;
101
105
  functionArgs?: any;
102
106
  persistentMenu?: boolean;
107
+ next?: string;
103
108
  selectBlock?: {
104
109
  id: string;
105
110
  };
106
111
  };
112
+ serialized?: string;
107
113
  }>;
108
114
  };
109
115
  function?: {
110
116
  name?: string;
111
117
  handlerName?: string;
112
118
  type?: string;
119
+ logic?: {
120
+ formId: string;
121
+ defaultMappingBlockId: string;
122
+ expressions?: Array<{
123
+ condition: any;
124
+ blockId: string;
125
+ }>;
126
+ };
113
127
  emailFormAsTable?: {
114
128
  toEmail: string;
115
129
  fromEmail?: string;
116
130
  subject: string;
117
131
  };
132
+ argosLabsExecuteScenario?: {
133
+ apiScenarioId: string;
134
+ apiPamId: string;
135
+ botParameters?: any;
136
+ startedMessage: {
137
+ any?: string;
138
+ en?: string;
139
+ nl?: string;
140
+ cy?: string;
141
+ it?: string;
142
+ de?: string;
143
+ };
144
+ finishedMessage: {
145
+ any?: string;
146
+ en?: string;
147
+ nl?: string;
148
+ cy?: string;
149
+ it?: string;
150
+ de?: string;
151
+ };
152
+ };
118
153
  args: any;
119
154
  formId?: string;
120
155
  todo?: boolean;
@@ -141,11 +176,12 @@ export default interface Block {
141
176
  value?: any;
142
177
  };
143
178
  profile?: any;
179
+ formValue?: string;
144
180
  userStatus?: string;
145
- formField?: boolean;
146
181
  session?: any;
147
182
  functionArgs?: any;
148
183
  persistentMenu?: boolean;
184
+ next?: string;
149
185
  selectBlock?: {
150
186
  id: string;
151
187
  };
@@ -171,5 +207,4 @@ export default interface Block {
171
207
  jovoFollowUpState?: string;
172
208
  alexaPermissionRequired?: string;
173
209
  };
174
- _id?: any;
175
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webuildbots/webuildbots-sdk",
3
- "version": "8.3.1",
3
+ "version": "9.2.1",
4
4
  "description": "webuildbots sdk",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -52,6 +52,7 @@
52
52
  "typescript": "^4.0.3"
53
53
  },
54
54
  "dependencies": {
55
+ "@types/json-logic-js": "^1.2.1",
55
56
  "bson-objectid": "^1.3.1",
56
57
  "deep-equal": "^2.0.4",
57
58
  "flatted": "^3.1.0",
@@ -60,4 +61,4 @@
60
61
  "md5": "^2.3.0",
61
62
  "wbb-logger": "^1.1.0"
62
63
  }
63
- }
64
+ }
File without changes
File without changes
@@ -1,6 +0,0 @@
1
- interface Address1And2 {
2
- address1: string;
3
- address2: string;
4
- }
5
- export declare const compareAddress: (a: Address1And2, b: Address1And2) => boolean;
6
- export {};
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compareAddress = void 0;
4
- var string_utils_1 = require("./string-utils");
5
- var compareAddress = function (a, b) {
6
- return (string_utils_1.eqIgnoreCaseAndPunctuations(a.address1, b.address1) ||
7
- string_utils_1.eqIgnoreCaseAndPunctuations(a.address1, b.address1 + " " + b.address2) ||
8
- string_utils_1.eqIgnoreCaseAndPunctuations(a.address1 + " " + a.address2, b.address1) ||
9
- string_utils_1.eqIgnoreCaseAndPunctuations(a.address1 + " " + a.address2, b.address1 + " " + b.address2));
10
- };
11
- exports.compareAddress = compareAddress;
@@ -1,14 +0,0 @@
1
- /**
2
- * Strip emojis and punctuation from {@code s}
3
- *
4
- * @param s
5
- */
6
- export declare function stripEmojiPunc(s: string): string;
7
- /**
8
- * Fill a given path with parameters by replacing the placeholder
9
- * @param path e.g. /user/{id}/edit
10
- * @param params key-value pair
11
- */
12
- export declare const fillPath: (path: string, params: Record<string, any>) => string;
13
- export declare const removeNonAlphaNum: (s: string) => string;
14
- export declare const eqIgnoreCaseAndPunctuations: (a: string, b: string) => boolean;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.eqIgnoreCaseAndPunctuations = exports.removeNonAlphaNum = exports.fillPath = exports.stripEmojiPunc = void 0;
7
- var emoji_regex_1 = __importDefault(require("emoji-regex"));
8
- var emojiRE = emoji_regex_1.default();
9
- /**
10
- * Strip emojis and punctuation from {@code s}
11
- *
12
- * @param s
13
- */
14
- function stripEmojiPunc(s) {
15
- return s.replace(/[.,/#!$%^&*;:{}=\-_`~()]/g, '').replace(emojiRE, '');
16
- }
17
- exports.stripEmojiPunc = stripEmojiPunc;
18
- /**
19
- * Fill a given path with parameters by replacing the placeholder
20
- * @param path e.g. /user/{id}/edit
21
- * @param params key-value pair
22
- */
23
- var fillPath = function (path, params) {
24
- for (var _i = 0, _a = Object.keys(params); _i < _a.length; _i++) {
25
- var key = _a[_i];
26
- path = path.replace(new RegExp("{" + key + "}", 'g'), params[key]);
27
- }
28
- return path;
29
- };
30
- exports.fillPath = fillPath;
31
- // remove any non alphabet or number character
32
- var removeNonAlphaNum = function (s) { return s.replace(/[^A-z0-9]/g, ''); };
33
- exports.removeNonAlphaNum = removeNonAlphaNum;
34
- var eqIgnoreCaseAndPunctuations = function (a, b) {
35
- return exports.removeNonAlphaNum(a).toLowerCase() === exports.removeNonAlphaNum(b).toLowerCase();
36
- };
37
- exports.eqIgnoreCaseAndPunctuations = eqIgnoreCaseAndPunctuations;