@webuildbots/webuildbots-sdk 7.2.1 → 8.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.
- package/lib/builder/block/complex-bb.d.ts +3 -0
- package/lib/builder/block/complex-bb.js +3 -0
- package/lib/builder/block/gallery-bb.d.ts +3 -0
- package/lib/builder/block/gallery-bb.js +27 -0
- package/lib/builder/block/text-bb.d.ts +2 -0
- package/lib/builder/block/text-bb.js +12 -2
- package/lib/builder/choice/choice-builder.js +3 -0
- package/lib/builder/response-builder.d.ts +2 -1
- package/lib/builder/response-builder.js +11 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +5 -1
- package/lib/interfaces/webhook.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ComplexBlockTypes, ImageAspectRatios, TopElementStyles } from '../../const/block-enums';
|
|
2
2
|
import ItemBuilder from '../item-builder';
|
|
3
3
|
import BlockBuilder from './block-builder';
|
|
4
|
+
/**
|
|
5
|
+
* @depreciated - Use {@link GalleryBB} instead
|
|
6
|
+
*/
|
|
4
7
|
export default class ComplexBB extends BlockBuilder {
|
|
5
8
|
static readonly ITEM_LIMIT = 10;
|
|
6
9
|
constructor(complexBlockType?: ComplexBlockTypes, topElementStyle?: TopElementStyles, imageAspectRatio?: ImageAspectRatios);
|
|
@@ -18,6 +18,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
var block_enums_1 = require("../../const/block-enums");
|
|
20
20
|
var block_builder_1 = __importDefault(require("./block-builder"));
|
|
21
|
+
/**
|
|
22
|
+
* @depreciated - Use {@link GalleryBB} instead
|
|
23
|
+
*/
|
|
21
24
|
var ComplexBB = /** @class */ (function (_super) {
|
|
22
25
|
__extends(ComplexBB, _super);
|
|
23
26
|
function ComplexBB(complexBlockType, topElementStyle, imageAspectRatio) {
|
|
@@ -0,0 +1,27 @@
|
|
|
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 complex_bb_1 = __importDefault(require("./complex-bb"));
|
|
20
|
+
var GalleryBB = /** @class */ (function (_super) {
|
|
21
|
+
__extends(GalleryBB, _super);
|
|
22
|
+
function GalleryBB() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
return GalleryBB;
|
|
26
|
+
}(complex_bb_1.default));
|
|
27
|
+
exports.default = GalleryBB;
|
|
@@ -3,6 +3,7 @@ import Block from '../../interfaces/block';
|
|
|
3
3
|
import Polylang from '../../interfaces/polylang';
|
|
4
4
|
import Polyphrase from '../../interfaces/polyphrase';
|
|
5
5
|
import BlockBuilder from './block-builder';
|
|
6
|
+
import { DeepPartial } from '../../helpers/helpers-types';
|
|
6
7
|
/**
|
|
7
8
|
* @depreciated - Use {@link BasicBB} instead
|
|
8
9
|
*/
|
|
@@ -11,4 +12,5 @@ export default class TextBB extends BlockBuilder {
|
|
|
11
12
|
addText(lang: string, text: string, textKey?: string): this;
|
|
12
13
|
setText(polylang: Polylang, textKey?: string): this;
|
|
13
14
|
setAllText(source: Polyphrase | Block): this;
|
|
15
|
+
build(): DeepPartial<Block>;
|
|
14
16
|
}
|
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
var block_enums_1 = require("../../const/block-enums");
|
|
20
20
|
var text_overflow_enums_1 = require("../../const/text-overflow-enums");
|
|
21
21
|
var block_builder_1 = __importDefault(require("./block-builder"));
|
|
22
|
+
var defaultTextKey = 'default';
|
|
22
23
|
function isBlock(arg) {
|
|
23
24
|
return arg.content !== undefined;
|
|
24
25
|
}
|
|
@@ -37,7 +38,7 @@ var TextBB = /** @class */ (function (_super) {
|
|
|
37
38
|
}
|
|
38
39
|
// {@code textKey} is used to identify when the text should be used e.g. sad, happy
|
|
39
40
|
TextBB.prototype.addText = function (lang, text, textKey) {
|
|
40
|
-
if (textKey === void 0) { textKey =
|
|
41
|
+
if (textKey === void 0) { textKey = defaultTextKey; }
|
|
41
42
|
if (!this.block.content.text[textKey]) {
|
|
42
43
|
this.block.content.text[textKey] = {};
|
|
43
44
|
}
|
|
@@ -45,7 +46,7 @@ var TextBB = /** @class */ (function (_super) {
|
|
|
45
46
|
return this;
|
|
46
47
|
};
|
|
47
48
|
TextBB.prototype.setText = function (polylang, textKey) {
|
|
48
|
-
if (textKey === void 0) { textKey =
|
|
49
|
+
if (textKey === void 0) { textKey = defaultTextKey; }
|
|
49
50
|
for (var _i = 0, _a = Object.keys(polylang); _i < _a.length; _i++) {
|
|
50
51
|
var lang = _a[_i];
|
|
51
52
|
this.addText(lang, polylang[lang], textKey);
|
|
@@ -56,6 +57,15 @@ var TextBB = /** @class */ (function (_super) {
|
|
|
56
57
|
this.block.content.text = isBlock(source) ? source.content.text : source;
|
|
57
58
|
return this;
|
|
58
59
|
};
|
|
60
|
+
TextBB.prototype.build = function () {
|
|
61
|
+
var text = this.block.content.text;
|
|
62
|
+
var defaultPolylang = text[defaultTextKey] || {};
|
|
63
|
+
var firstTranslation = Object.values(defaultPolylang)[0];
|
|
64
|
+
if (!firstTranslation) {
|
|
65
|
+
throw new Error('This block requires at least some default text, you need to call setText(..) or addText(..) with a truthy value for the text');
|
|
66
|
+
}
|
|
67
|
+
return _super.prototype.build.call(this);
|
|
68
|
+
};
|
|
59
69
|
return TextBB;
|
|
60
70
|
}(block_builder_1.default));
|
|
61
71
|
exports.default = TextBB;
|
|
@@ -43,6 +43,9 @@ var ChoiceBuilder = /** @class */ (function () {
|
|
|
43
43
|
if (this.functionArgs) {
|
|
44
44
|
this.choice.functionArgs = this.functionArgs;
|
|
45
45
|
}
|
|
46
|
+
if (!this.choice.title) {
|
|
47
|
+
throw new Error('This block requires a title, you need to call setTitle(..) or addTitle(..) with a truthy value for the title');
|
|
48
|
+
}
|
|
46
49
|
// Clone here so we an use the same builder twice
|
|
47
50
|
return helpers_types_1.clone(this.choice);
|
|
48
51
|
};
|
|
@@ -7,12 +7,13 @@ import Block from '../interfaces/block';
|
|
|
7
7
|
import { DeepPartial } from '../helpers/helpers-types';
|
|
8
8
|
import { BlockPointer, WebhookResponse } from '..';
|
|
9
9
|
import BlockBuilder from './block/block-builder';
|
|
10
|
-
import { FunctionFailureParams } from '../interfaces/webhook';
|
|
10
|
+
import { FollowUpParams, FunctionFailureParams } from '../interfaces/webhook';
|
|
11
11
|
export default class ResponseBuilder {
|
|
12
12
|
private resp;
|
|
13
13
|
pushBlock(block: DeepPartial<Block> | BlockBuilder): this;
|
|
14
14
|
pushBlockPointer(blockPointer: BlockPointer): this;
|
|
15
15
|
functionFailure(params: FunctionFailureParams): this;
|
|
16
16
|
unsetFunctionForm(): this;
|
|
17
|
+
setFollowUp(params: FollowUpParams): this;
|
|
17
18
|
build(): WebhookResponse;
|
|
18
19
|
}
|
|
@@ -34,6 +34,17 @@ var ResponseBuilder = /** @class */ (function () {
|
|
|
34
34
|
this.resp.unsetFunctionForm = true;
|
|
35
35
|
return this;
|
|
36
36
|
};
|
|
37
|
+
ResponseBuilder.prototype.setFollowUp = function (params) {
|
|
38
|
+
var block = params.block, schedule = params.schedule, _a = params.viaEmail, viaEmail = _a === void 0 ? false : _a, _b = params.cancelExisting, cancelExisting = _b === void 0 ? false : _b, _c = params.blockArgs, blockArgs = _c === void 0 ? {} : _c;
|
|
39
|
+
this.resp.followUp = {
|
|
40
|
+
block: block,
|
|
41
|
+
schedule: schedule,
|
|
42
|
+
viaEmail: viaEmail,
|
|
43
|
+
blockArgs: blockArgs,
|
|
44
|
+
cancelExisting: cancelExisting
|
|
45
|
+
};
|
|
46
|
+
return this;
|
|
47
|
+
};
|
|
37
48
|
ResponseBuilder.prototype.build = function () {
|
|
38
49
|
return this.resp;
|
|
39
50
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import BlockBuilder from './builder/block/block-builder';
|
|
2
|
+
import BasicBB from './builder/block/basic-bb';
|
|
3
|
+
import GalleryBB from './builder/block/gallery-bb';
|
|
2
4
|
import ComplexBB from './builder/block/complex-bb';
|
|
3
5
|
import DevSwitchBB from './builder/block/dev-switch-bb';
|
|
4
6
|
import EmailFormTableBB from './builder/block/email-form-table-bb';
|
|
@@ -18,4 +20,4 @@ import ItemBuilder from './builder/item-builder';
|
|
|
18
20
|
import DefinedIB from './builder/defined-ib';
|
|
19
21
|
import ResponseBuilder from './builder/response-builder';
|
|
20
22
|
import { WebhookRequest, WebhookResponse, ResponseUnitType, ResponseUnit, BlockPointer, Client, JWTPayload } from './interfaces/webhook';
|
|
21
|
-
export { BlockBuilder, ComplexBB, FunctionBB, EmailFormTableBB, ImageBB, SelectBB, TextBB, VideoBB, DevSwitchBB, BlockCB, ChoiceBuilder, DefinedCB, DefinedIB, ExtensionCB, LocationCB, PhoneCB, UrlCB, ItemBuilder, WebhookResponse, WebhookRequest, ResponseUnit, ResponseUnitType, BlockPointer, ResponseBuilder, Client, JWTPayload };
|
|
23
|
+
export { BlockBuilder, ComplexBB, FunctionBB, EmailFormTableBB, ImageBB, SelectBB, TextBB, VideoBB, DevSwitchBB, 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,9 +3,13 @@ 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.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.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.DevSwitchBB = exports.VideoBB = exports.TextBB = exports.SelectBB = exports.ImageBB = 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
|
+
var basic_bb_1 = __importDefault(require("./builder/block/basic-bb"));
|
|
10
|
+
exports.BasicBB = basic_bb_1.default;
|
|
11
|
+
var gallery_bb_1 = __importDefault(require("./builder/block/gallery-bb"));
|
|
12
|
+
exports.GalleryBB = gallery_bb_1.default;
|
|
9
13
|
var complex_bb_1 = __importDefault(require("./builder/block/complex-bb"));
|
|
10
14
|
exports.ComplexBB = complex_bb_1.default;
|
|
11
15
|
var dev_switch_bb_1 = __importDefault(require("./builder/block/dev-switch-bb"));
|
|
@@ -8,6 +8,7 @@ export interface WebhookResponse {
|
|
|
8
8
|
tryAgain?: boolean;
|
|
9
9
|
errBlockPointer?: BlockPointer;
|
|
10
10
|
botResponse: ResponseUnit[];
|
|
11
|
+
followUp?: FollowUpParams;
|
|
11
12
|
}
|
|
12
13
|
export interface Client {
|
|
13
14
|
system: {
|
|
@@ -44,3 +45,10 @@ export interface FunctionFailureParams {
|
|
|
44
45
|
tryAgain?: boolean;
|
|
45
46
|
resetForm?: boolean;
|
|
46
47
|
}
|
|
48
|
+
export interface FollowUpParams {
|
|
49
|
+
block: BlockPointer;
|
|
50
|
+
schedule: Date;
|
|
51
|
+
viaEmail?: boolean;
|
|
52
|
+
blockArgs?: Record<string, any>;
|
|
53
|
+
cancelExisting?: boolean;
|
|
54
|
+
}
|