@botonic/plugin-flow-builder 0.25.0-alpha.8 → 0.25.0-beta.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/lib/cjs/action/index.js +4 -2
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.js +2 -1
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/api.d.ts +3 -1
- package/lib/cjs/api.js +26 -3
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/constants.d.ts +3 -1
- package/lib/cjs/constants.js +4 -2
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/content-fields/flow-text.d.ts +4 -2
- package/lib/cjs/content-fields/flow-text.js +17 -10
- package/lib/cjs/content-fields/flow-text.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/function.d.ts +3 -1
- package/lib/cjs/content-fields/hubtype-fields/function.js +1 -0
- package/lib/cjs/content-fields/hubtype-fields/function.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +2 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +2 -3
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +2 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +2 -2
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +2 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +2 -2
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/cjs/functions/conditional-bot-variable.d.ts +8 -0
- package/lib/cjs/functions/conditional-bot-variable.js +11 -0
- package/lib/cjs/functions/conditional-bot-variable.js.map +1 -0
- package/lib/cjs/functions/conditional-country.d.ts +7 -0
- package/lib/cjs/functions/conditional-country.js +9 -0
- package/lib/cjs/functions/conditional-country.js.map +1 -0
- package/lib/cjs/functions/conditional-provider.js +1 -3
- package/lib/cjs/functions/conditional-provider.js.map +1 -1
- package/lib/cjs/functions/conditional-queue-status.d.ts +8 -2
- package/lib/cjs/functions/conditional-queue-status.js +14 -6
- package/lib/cjs/functions/conditional-queue-status.js.map +1 -1
- package/lib/cjs/functions/index.d.ts +4 -0
- package/lib/cjs/functions/index.js +4 -0
- package/lib/cjs/functions/index.js.map +1 -1
- package/lib/cjs/index.d.ts +3 -2
- package/lib/cjs/index.js +30 -14
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils.d.ts +2 -0
- package/lib/cjs/utils.js +18 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/action/index.js +4 -2
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/knowledge-bases.js +2 -1
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/api.d.ts +3 -1
- package/lib/esm/api.js +27 -4
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/constants.d.ts +3 -1
- package/lib/esm/constants.js +3 -1
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/content-fields/flow-text.d.ts +4 -2
- package/lib/esm/content-fields/flow-text.js +18 -11
- package/lib/esm/content-fields/flow-text.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/function.d.ts +3 -1
- package/lib/esm/content-fields/hubtype-fields/function.js +1 -0
- package/lib/esm/content-fields/hubtype-fields/function.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +2 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +2 -3
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +2 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +2 -2
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +2 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +2 -2
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/esm/functions/conditional-bot-variable.d.ts +8 -0
- package/lib/esm/functions/conditional-bot-variable.js +7 -0
- package/lib/esm/functions/conditional-bot-variable.js.map +1 -0
- package/lib/esm/functions/conditional-country.d.ts +7 -0
- package/lib/esm/functions/conditional-country.js +5 -0
- package/lib/esm/functions/conditional-country.js.map +1 -0
- package/lib/esm/functions/conditional-provider.js +1 -3
- package/lib/esm/functions/conditional-provider.js.map +1 -1
- package/lib/esm/functions/conditional-queue-status.d.ts +8 -2
- package/lib/esm/functions/conditional-queue-status.js +14 -6
- package/lib/esm/functions/conditional-queue-status.js.map +1 -1
- package/lib/esm/functions/index.d.ts +4 -0
- package/lib/esm/functions/index.js +4 -0
- package/lib/esm/functions/index.js.map +1 -1
- package/lib/esm/index.d.ts +3 -2
- package/lib/esm/index.js +30 -14
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/utils.d.ts +2 -0
- package/lib/esm/utils.js +16 -0
- package/lib/esm/utils.js.map +1 -1
- package/package.json +4 -6
- package/src/action/index.tsx +4 -2
- package/src/action/knowledge-bases.ts +3 -2
- package/src/api.ts +35 -4
- package/src/constants.ts +3 -1
- package/src/content-fields/flow-text.tsx +23 -17
- package/src/content-fields/hubtype-fields/function.ts +4 -1
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx +4 -2
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx +4 -2
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx +4 -2
- package/src/functions/conditional-bot-variable.ts +18 -0
- package/src/functions/conditional-country.ts +14 -0
- package/src/functions/conditional-provider.ts +1 -2
- package/src/functions/conditional-queue-status.ts +17 -6
- package/src/functions/index.ts +4 -0
- package/src/index.ts +48 -17
- package/src/utils.ts +26 -0
package/lib/cjs/action/index.js
CHANGED
|
@@ -24,7 +24,8 @@ class FlowBuilderAction extends react_2.default.Component {
|
|
|
24
24
|
}
|
|
25
25
|
render() {
|
|
26
26
|
const { contents } = this.props;
|
|
27
|
-
|
|
27
|
+
const request = this.context;
|
|
28
|
+
return contents.map(content => content.toBotonic(content.id, request));
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
exports.FlowBuilderAction = FlowBuilderAction;
|
|
@@ -32,7 +33,8 @@ FlowBuilderAction.contextType = react_1.RequestContext;
|
|
|
32
33
|
class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
|
33
34
|
render() {
|
|
34
35
|
const { contents } = this.props;
|
|
35
|
-
|
|
36
|
+
const request = this.context;
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Multichannel, Object.assign({ text: { buttonsAsText: false } }, { children: contents.map(content => content.toBotonic(content.id, request)) })));
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
exports.FlowBuilderMultichannelAction = FlowBuilderMultichannelAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/action/index.tsx"],"names":[],"mappings":";;;;;AAAA,0CAA4E;AAC5E,0DAAyB;AAGzB,sDAA4D;AAE5D,wCAAiD;AACjD,uDAA+D;AAC/D,yCAAkD;AAMlD,MAAa,iBAAkB,SAAQ,eAAK,CAAC,SAAiC;IAG5E,MAAM,CAAO,WAAW,CACtB,OAAsB;;YAEtB,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YAC/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,OAAO,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AO,YAAY,CAAA;;CACpB"}
|
|
@@ -10,6 +10,7 @@ function createNodeFromKnowledgeBase(cmsApi, request) {
|
|
|
10
10
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
11
|
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
12
12
|
const locale = flowBuilderPlugin.getLocale(request.session);
|
|
13
|
+
const resolvedLocale = cmsApi.getResolvedLocale(locale);
|
|
13
14
|
const knowledgeBaseConfig = cmsApi.getKnowledgeBaseConfig();
|
|
14
15
|
if (flowBuilderPlugin.getKnowledgeBaseResponse &&
|
|
15
16
|
(knowledgeBaseConfig === null || knowledgeBaseConfig === void 0 ? void 0 : knowledgeBaseConfig.isActive)) {
|
|
@@ -26,7 +27,7 @@ function createNodeFromKnowledgeBase(cmsApi, request) {
|
|
|
26
27
|
text: [
|
|
27
28
|
{
|
|
28
29
|
message: knowledgeBaseResponse.answer,
|
|
29
|
-
locale,
|
|
30
|
+
locale: resolvedLocale,
|
|
30
31
|
},
|
|
31
32
|
],
|
|
32
33
|
buttons_style: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";;;;AAEA,+BAAiC;AAGjC,qEAIyC;AACzC,wCAAiD;AACjD,yCAAkD;AAElD,SAAsB,2BAA2B,CAC/C,MAAsB,EACtB,OAAsB;;QAEtB,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC3D,MAAM,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;QACvD,M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
@@ -22,7 +22,9 @@ export declare class FlowBuilderApi {
|
|
|
22
22
|
hasMetConfidenceThreshold(node: HtIntentNode, predictedConfidence: number): boolean;
|
|
23
23
|
getNodeByKeyword(userInput: string, locale: string): HtKeywordNode | undefined;
|
|
24
24
|
private matchKeywords;
|
|
25
|
-
private
|
|
25
|
+
private inputMatchesAnyKeyword;
|
|
26
|
+
private resolveKeywordAsRegExp;
|
|
26
27
|
getPayload(target?: HtNodeLink): string | undefined;
|
|
27
28
|
private createPayloadWithParams;
|
|
29
|
+
getResolvedLocale(locale: string): string;
|
|
28
30
|
}
|
package/lib/cjs/api.js
CHANGED
|
@@ -112,11 +112,23 @@ class FlowBuilderApi {
|
|
|
112
112
|
return undefined;
|
|
113
113
|
}
|
|
114
114
|
matchKeywords(node, input, locale) {
|
|
115
|
-
const result = node.content.keywords.find(
|
|
115
|
+
const result = node.content.keywords.find(keywords => keywords.locale === locale &&
|
|
116
|
+
this.inputMatchesAnyKeyword(input, keywords.values));
|
|
116
117
|
return Boolean(result);
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
return keywords.some(keyword =>
|
|
119
|
+
inputMatchesAnyKeyword(input, keywords) {
|
|
120
|
+
return keywords.some(keyword => {
|
|
121
|
+
const regExpMatchArray = keyword.match(constants_1.REG_EXP_PATTERN);
|
|
122
|
+
if (regExpMatchArray) {
|
|
123
|
+
return this.resolveKeywordAsRegExp(regExpMatchArray, input);
|
|
124
|
+
}
|
|
125
|
+
return input.includes(keyword);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
resolveKeywordAsRegExp(regExpMatchArray, input) {
|
|
129
|
+
const [, pattern, flags] = regExpMatchArray;
|
|
130
|
+
const keywordAsRegExp = new RegExp(pattern, flags);
|
|
131
|
+
return input.match(keywordAsRegExp);
|
|
120
132
|
}
|
|
121
133
|
getPayload(target) {
|
|
122
134
|
if (!target) {
|
|
@@ -136,6 +148,17 @@ class FlowBuilderApi {
|
|
|
136
148
|
const payloadJson = JSON.stringify(Object.assign(Object.assign({}, customParams), { followUpId: (_a = botActionNode.follow_up) === null || _a === void 0 ? void 0 : _a.id }));
|
|
137
149
|
return `${payloadNode.content.payload}${constants_1.SEPARATOR}${payloadJson}`;
|
|
138
150
|
}
|
|
151
|
+
getResolvedLocale(locale) {
|
|
152
|
+
if (this.flow.locales.find(flowLocale => flowLocale === locale)) {
|
|
153
|
+
return locale;
|
|
154
|
+
}
|
|
155
|
+
const language = locale.split('-')[0];
|
|
156
|
+
if (this.flow.locales.find(flowLocale => flowLocale === language)) {
|
|
157
|
+
console.log(`locale: ${locale} has been resolved as ${language}`);
|
|
158
|
+
return language;
|
|
159
|
+
}
|
|
160
|
+
throw new Error(`locale: ${locale} cannot be resolved in ${this.flow.locales}`);
|
|
161
|
+
}
|
|
139
162
|
}
|
|
140
163
|
exports.FlowBuilderApi = FlowBuilderApi;
|
|
141
164
|
//# sourceMappingURL=api.js.map
|
package/lib/cjs/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AAEzB,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AAEzB,2CAAwD;AACxD,oEAYwC;AAGxC,MAAa,cAAc;IAKzB,gBAAuB,CAAC;IAExB,MAAM,CAAO,MAAM,CAAC,OAA8B;;;YAChD,MAAM,MAAM,GAAG,IAAI,cAAc,EAAE,CAAA;YAEnC,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;YACxB,MAAM,CAAC,IAAI,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAA;YACzE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;YAEhC,OAAO,MAAM,CAAA;;KACd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M,CAAC,EAAE;YAC/D,OAAO,MAAM,CAAA;SACd;QACD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACrC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,KAAK,QAAQ,CAAC,EAAE;YACjE,OAAO,CAAC,GAAG,CAAC,WAAW,MAAM,yBAAyB,QAAQ,EAAE,CAAC,CAAA;YACjE,OAAO,QAAQ,CAAA;SAChB;QACD,MAAM,IAAI,KAAK,CACb,WAAW,MAAM,2BAA2B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAChE,CAAA;IACH,CAAC;CACF;AAzND,wCAyNC"}
|
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const SEPARATOR = "|";
|
|
2
2
|
export declare const SOURCE_INFO_SEPARATOR: string;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const VARIABLE_PATTERN: RegExp;
|
|
4
|
+
export declare const ACCESS_TOKEN_VARIABLE_KEY = "_access_token";
|
|
5
|
+
export declare const REG_EXP_PATTERN: RegExp;
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.REG_EXP_PATTERN = exports.ACCESS_TOKEN_VARIABLE_KEY = exports.VARIABLE_PATTERN = exports.SOURCE_INFO_SEPARATOR = exports.SEPARATOR = void 0;
|
|
4
4
|
exports.SEPARATOR = '|';
|
|
5
5
|
exports.SOURCE_INFO_SEPARATOR = `${exports.SEPARATOR}source_`;
|
|
6
|
-
exports.
|
|
6
|
+
exports.VARIABLE_PATTERN = /{([^}]+)}/g;
|
|
7
|
+
exports.ACCESS_TOKEN_VARIABLE_KEY = '_access_token';
|
|
8
|
+
exports.REG_EXP_PATTERN = /^\/(.*)\/([gimyus]*)$/;
|
|
7
9
|
//# sourceMappingURL=constants.js.map
|
package/lib/cjs/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,GAAG,CAAA;AACf,QAAA,qBAAqB,GAAG,GAAG,iBAAS,SAAS,CAAA;AAC7C,QAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,GAAG,CAAA;AACf,QAAA,qBAAqB,GAAG,GAAG,iBAAS,SAAS,CAAA;AAC7C,QAAA,gBAAgB,GAAG,YAAY,CAAA;AAC/B,QAAA,yBAAyB,GAAG,eAAe,CAAA;AAC3C,QAAA,eAAe,GAAG,uBAAuB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ActionRequest } from '@botonic/react';
|
|
1
2
|
import { FlowBuilderApi } from '../api';
|
|
2
3
|
import { ContentFieldsBase } from './content-fields-base';
|
|
3
4
|
import { FlowButton } from './flow-button';
|
|
@@ -8,6 +9,7 @@ export declare class FlowText extends ContentFieldsBase {
|
|
|
8
9
|
buttons: FlowButton[];
|
|
9
10
|
buttonStyle: HtButtonStyle;
|
|
10
11
|
static fromHubtypeCMS(cmsText: HtTextNode, locale: string, cmsApi: FlowBuilderApi): FlowText;
|
|
11
|
-
static replaceVariables(text: string,
|
|
12
|
-
|
|
12
|
+
static replaceVariables(text: string, request: ActionRequest): string;
|
|
13
|
+
private static isValidType;
|
|
14
|
+
toBotonic(id: string, request: ActionRequest): JSX.Element;
|
|
13
15
|
}
|
|
@@ -4,6 +4,7 @@ exports.FlowText = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("@botonic/react");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
7
8
|
const content_fields_base_1 = require("./content-fields-base");
|
|
8
9
|
const flow_button_1 = require("./flow-button");
|
|
9
10
|
const hubtype_fields_1 = require("./hubtype-fields");
|
|
@@ -19,25 +20,31 @@ class FlowText extends content_fields_base_1.ContentFieldsBase {
|
|
|
19
20
|
const newText = new FlowText(cmsText.id);
|
|
20
21
|
newText.code = cmsText.code;
|
|
21
22
|
newText.buttonStyle = cmsText.content.buttons_style || hubtype_fields_1.HtButtonStyle.BUTTON;
|
|
22
|
-
newText.text = this.
|
|
23
|
+
newText.text = this.getTextByLocale(locale, cmsText.content.text);
|
|
23
24
|
newText.buttons = cmsText.content.buttons.map(button => flow_button_1.FlowButton.fromHubtypeCMS(button, locale, cmsApi));
|
|
24
25
|
return newText;
|
|
25
26
|
}
|
|
26
|
-
static replaceVariables(text,
|
|
27
|
-
const matches = text.match(constants_1.
|
|
27
|
+
static replaceVariables(text, request) {
|
|
28
|
+
const matches = text.match(constants_1.VARIABLE_PATTERN);
|
|
28
29
|
let replacedText = text;
|
|
29
|
-
if (matches &&
|
|
30
|
+
if (matches && request) {
|
|
30
31
|
matches.forEach(match => {
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const keyPath = match.slice(1, -1);
|
|
33
|
+
const botVariable = keyPath.endsWith(constants_1.ACCESS_TOKEN_VARIABLE_KEY)
|
|
34
|
+
? match
|
|
35
|
+
: (0, utils_1.getValueFromKeyPath)(request, keyPath);
|
|
36
|
+
replacedText = replacedText.replace(match, this.isValidType(botVariable) ? botVariable : match);
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
return replacedText;
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
static isValidType(botVariable) {
|
|
42
|
+
const validTypes = ['boolean', 'string', 'number'];
|
|
43
|
+
return validTypes.includes(typeof botVariable);
|
|
44
|
+
}
|
|
45
|
+
toBotonic(id, request) {
|
|
46
|
+
const replacedText = FlowText.replaceVariables(this.text, request);
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Text, { children: [replacedText, this.buttons.map((button, buttonIndex) => button.renderButton(buttonIndex, this.buttonStyle))] }, id));
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
exports.FlowText = FlowText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-text.js","sourceRoot":"","sources":["../../../src/content-fields/flow-text.tsx"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"flow-text.js","sourceRoot":"","sources":["../../../src/content-fields/flow-text.tsx"],"names":[],"mappings":";;;;AAAA,0CAAoD;AAIpD,4CAA0E;AAC1E,oCAA8C;AAC9C,+DAAyD;AACzD,+CAA0C;AAC1C,qDAA4D;AAE5D,MAAa,QAAS,SAAQ,uCAAiB;IAA/C;;QACS,SAAI,GAAG,EAAE,CAAA;QACT,SAAI,GAAG,EAAE,CAAA;QACT,YAAO,GAAiB,EAAE,CAAA;QAC1B,gBAAW,GAAG,8BAAa,CAAC,MAAM,CAAA;IAqD3C,CAAC;IAnDC,MAAM,CAAC,cAAc,CACnB,OAAmB,EACnB,MAAc,EACd,MAAsB;QAEtB,MAAM,OAAO,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACxC,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QAC3B,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,IAAI,8BAAa,CAAC,MAAM,CAAA;QAC3E,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACjE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CACrD,wBAAU,CAAC,cAAc,CAAC,MAAM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YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CACnD,KAJQ,EAAE,CAKN,CACR,CAAA;IACH,CAAC;CACF;AAzDD,4BAyDC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HtBaseNode, HtNodeLink } from './common';
|
|
2
2
|
import { HtNodeWithContentType } from './node-types';
|
|
3
3
|
export declare enum HtArgumentType {
|
|
4
|
+
BOOLEAN = "boolean",
|
|
4
5
|
NUMBER = "number",
|
|
5
6
|
STRING = "string",
|
|
6
7
|
JSON = "json"
|
|
@@ -18,11 +19,12 @@ export interface HtFunctionResult {
|
|
|
18
19
|
result: string;
|
|
19
20
|
target?: HtNodeLink;
|
|
20
21
|
}
|
|
22
|
+
export type HtFunctionArguments = HtFunctionArgumentLocale | HtFunctionArgument;
|
|
21
23
|
export interface HtFunctionNode extends HtBaseNode {
|
|
22
24
|
type: HtNodeWithContentType.FUNCTION;
|
|
23
25
|
content: {
|
|
24
26
|
action: string;
|
|
25
|
-
arguments:
|
|
27
|
+
arguments: HtFunctionArguments[];
|
|
26
28
|
result_mapping: HtFunctionResult[];
|
|
27
29
|
};
|
|
28
30
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HtArgumentType = void 0;
|
|
4
4
|
var HtArgumentType;
|
|
5
5
|
(function (HtArgumentType) {
|
|
6
|
+
HtArgumentType["BOOLEAN"] = "boolean";
|
|
6
7
|
HtArgumentType["NUMBER"] = "number";
|
|
7
8
|
HtArgumentType["STRING"] = "string";
|
|
8
9
|
HtArgumentType["JSON"] = "json";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/function.ts"],"names":[],"mappings":";;;AAGA,IAAY,
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/function.ts"],"names":[],"mappings":";;;AAGA,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;IACjB,+BAAa,CAAA;AACf,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { WhatsappButtonListRowProps } from '@botonic/react';
|
|
2
|
+
import { FlowBuilderApi } from '../../api';
|
|
2
3
|
import { ContentFieldsBase } from '../content-fields-base';
|
|
3
4
|
import { HtWhatsappButtonListRow } from '../hubtype-fields';
|
|
4
5
|
export declare class FlowWhatsappButtonListRow extends ContentFieldsBase {
|
|
5
6
|
title: string;
|
|
6
7
|
description: string;
|
|
7
8
|
targetId?: string;
|
|
8
|
-
static fromHubtypeCMS(component: HtWhatsappButtonListRow, locale: string): FlowWhatsappButtonListRow;
|
|
9
|
+
static fromHubtypeCMS(component: HtWhatsappButtonListRow, locale: string, cmsApi: FlowBuilderApi): FlowWhatsappButtonListRow;
|
|
9
10
|
toBotonic(rowIndex: number, sectionIndex: number): WhatsappButtonListRowProps | undefined;
|
|
10
11
|
private getRowId;
|
|
11
12
|
}
|
|
@@ -9,12 +9,11 @@ class FlowWhatsappButtonListRow extends content_fields_base_1.ContentFieldsBase
|
|
|
9
9
|
this.title = '';
|
|
10
10
|
this.description = '';
|
|
11
11
|
}
|
|
12
|
-
static fromHubtypeCMS(component, locale) {
|
|
13
|
-
var _a;
|
|
12
|
+
static fromHubtypeCMS(component, locale, cmsApi) {
|
|
14
13
|
const newRow = new FlowWhatsappButtonListRow(component.id);
|
|
15
14
|
newRow.title = this.getTextByLocale(locale, component.text);
|
|
16
15
|
newRow.description = this.getTextByLocale(locale, component.description);
|
|
17
|
-
newRow.targetId = (
|
|
16
|
+
newRow.targetId = cmsApi.getPayload(component.target);
|
|
18
17
|
return newRow;
|
|
19
18
|
}
|
|
20
19
|
toBotonic(rowIndex, sectionIndex) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-whatsapp-button-list-row.js","sourceRoot":"","sources":["../../../../src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"flow-whatsapp-button-list-row.js","sourceRoot":"","sources":["../../../../src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx"],"names":[],"mappings":";;;AAGA,+CAAuD;AACvD,gEAA0D;AAG1D,MAAa,yBAA0B,SAAQ,uCAAiB;IAAhE;;QACS,UAAK,GAAG,EAAE,CAAA;QACV,gBAAW,GAAG,EAAE,CAAA;IAiCzB,CAAC;IA9BC,MAAM,CAAC,cAAc,CACnB,SAAkC,EAClC,MAAc,EACd,MAAsB;QAEtB,MAAM,MAAM,GAAG,IAAI,yBAAyB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC1D,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QAC3D,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,WAAW,CAAC,CAAA;QACxE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QACrD,OAAO,MAAM,CAAA;IACf,CAAC;IAED,SAAS,CACP,QAAgB,EAChB,YAAoB;QAEpB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,oBAAoB,IAAI,CAAC,KAAK,iBAAiB,CAAC,CAAA;YAC9D,OAAO,SAAS,CAAA;SACjB;QACD,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;YACzC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAA;IACH,CAAC;IAEO,QAAQ,CAAC,QAAgB,EAAE,YAAoB;QACrD,OAAO,GAAG,IAAI,CAAC,QAAQ,GAAG,iCAAqB,GAAG,YAAY,IAAI,QAAQ,EAAE,CAAA;IAC9E,CAAC;CACF;AAnCD,8DAmCC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { WhatsappButtonListSectionProps } from '@botonic/react';
|
|
2
|
+
import { FlowBuilderApi } from '../../api';
|
|
2
3
|
import { HtWhatsappButtonListSection } from '../hubtype-fields';
|
|
3
4
|
import { ContentFieldsBase } from './../content-fields-base';
|
|
4
5
|
import { FlowWhatsappButtonListRow } from './flow-whatsapp-button-list-row';
|
|
5
6
|
export declare class FlowWhatsappButtonListSection extends ContentFieldsBase {
|
|
6
7
|
title: string;
|
|
7
8
|
rows: FlowWhatsappButtonListRow[];
|
|
8
|
-
static fromHubtypeCMS(component: HtWhatsappButtonListSection, locale: string): FlowWhatsappButtonListSection;
|
|
9
|
+
static fromHubtypeCMS(component: HtWhatsappButtonListSection, locale: string, cmsApi: FlowBuilderApi): FlowWhatsappButtonListSection;
|
|
9
10
|
toBotonic(sectionIndex: number): WhatsappButtonListSectionProps;
|
|
10
11
|
}
|
|
@@ -9,10 +9,10 @@ class FlowWhatsappButtonListSection extends content_fields_base_1.ContentFieldsB
|
|
|
9
9
|
this.title = '';
|
|
10
10
|
this.rows = [];
|
|
11
11
|
}
|
|
12
|
-
static fromHubtypeCMS(component, locale) {
|
|
12
|
+
static fromHubtypeCMS(component, locale, cmsApi) {
|
|
13
13
|
const newButton = new FlowWhatsappButtonListSection(component.id);
|
|
14
14
|
newButton.title = this.getTextByLocale(locale, component.title);
|
|
15
|
-
newButton.rows = component.rows.map(row => flow_whatsapp_button_list_row_1.FlowWhatsappButtonListRow.fromHubtypeCMS(row, locale));
|
|
15
|
+
newButton.rows = component.rows.map(row => flow_whatsapp_button_list_row_1.FlowWhatsappButtonListRow.fromHubtypeCMS(row, locale, cmsApi));
|
|
16
16
|
return newButton;
|
|
17
17
|
}
|
|
18
18
|
toBotonic(sectionIndex) {
|
package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-whatsapp-button-list-section.js","sourceRoot":"","sources":["../../../../src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"flow-whatsapp-button-list-section.js","sourceRoot":"","sources":["../../../../src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx"],"names":[],"mappings":";;;AAOA,kEAA4D;AAC5D,mFAA2E;AAE3E,MAAa,6BAA8B,SAAQ,uCAAiB;IAApE;;QACS,UAAK,GAAG,EAAE,CAAA;QACV,SAAI,GAAgC,EAAE,CAAA;IA2B/C,CAAC;IAzBC,MAAM,CAAC,cAAc,CACnB,SAAsC,EACtC,MAAc,EACd,MAAsB;QAEtB,MAAM,SAAS,GAAG,IAAI,6BAA6B,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QACjE,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;QAC/D,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CACxC,yDAAyB,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAC9D,CAAA;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS,CAAC,YAAoB;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAC3B,CAAC,GAAiC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;YACnD,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;YACxD,IAAI,UAAU;gBAAE,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACpC,OAAO,GAAG,CAAA;QACZ,CAAC,EACD,EAAE,CACH,CAAA;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAA;IACpC,CAAC;CACF;AA7BD,sEA6BC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlowBuilderApi } from '../../api';
|
|
1
2
|
import { HtWhatsappButtonListNode } from '../hubtype-fields';
|
|
2
3
|
import { ContentFieldsBase } from './../content-fields-base';
|
|
3
4
|
import { FlowWhatsappButtonListSection } from './flow-whatsapp-button-list-section';
|
|
@@ -6,6 +7,6 @@ export declare class FlowWhatsappButtonList extends ContentFieldsBase {
|
|
|
6
7
|
text: string;
|
|
7
8
|
listButtonText: string;
|
|
8
9
|
sections: FlowWhatsappButtonListSection[];
|
|
9
|
-
static fromHubtypeCMS(component: HtWhatsappButtonListNode, locale: string): FlowWhatsappButtonList;
|
|
10
|
+
static fromHubtypeCMS(component: HtWhatsappButtonListNode, locale: string, cmsApi: FlowBuilderApi): FlowWhatsappButtonList;
|
|
10
11
|
toBotonic(id: string): JSX.Element;
|
|
11
12
|
}
|
|
@@ -13,12 +13,12 @@ class FlowWhatsappButtonList extends content_fields_base_1.ContentFieldsBase {
|
|
|
13
13
|
this.listButtonText = '';
|
|
14
14
|
this.sections = [];
|
|
15
15
|
}
|
|
16
|
-
static fromHubtypeCMS(component, locale) {
|
|
16
|
+
static fromHubtypeCMS(component, locale, cmsApi) {
|
|
17
17
|
const newWhatsappButtonList = new FlowWhatsappButtonList(component.id);
|
|
18
18
|
newWhatsappButtonList.code = component.code;
|
|
19
19
|
newWhatsappButtonList.text = this.getTextByLocale(locale, component.content.text);
|
|
20
20
|
newWhatsappButtonList.listButtonText = this.getTextByLocale(locale, component.content.button_text);
|
|
21
|
-
newWhatsappButtonList.sections = component.content.sections.map(section => flow_whatsapp_button_list_section_1.FlowWhatsappButtonListSection.fromHubtypeCMS(section, locale));
|
|
21
|
+
newWhatsappButtonList.sections = component.content.sections.map(section => flow_whatsapp_button_list_section_1.FlowWhatsappButtonListSection.fromHubtypeCMS(section, locale, cmsApi));
|
|
22
22
|
return newWhatsappButtonList;
|
|
23
23
|
}
|
|
24
24
|
toBotonic(id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-whatsapp-button-list.js","sourceRoot":"","sources":["../../../../src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx"],"names":[],"mappings":";;;;AAAA,0CAAmD;
|
|
1
|
+
{"version":3,"file":"flow-whatsapp-button-list.js","sourceRoot":"","sources":["../../../../src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx"],"names":[],"mappings":";;;;AAAA,0CAAmD;AAKnD,kEAA4D;AAC5D,2FAAmF;AAEnF,MAAa,sBAAuB,SAAQ,uCAAiB;IAA7D;;QACS,SAAI,GAAG,EAAE,CAAA;QACT,SAAI,GAAG,EAAE,CAAA;QACT,mBAAc,GAAG,EAAE,CAAA;QACnB,aAAQ,GAAoC,EAAE,CAAA;IAmCvD,CAAC;IAjCC,MAAM,CAAC,cAAc,CACnB,SAAmC,EACnC,MAAc,EACd,MAAsB;QAEtB,MAAM,qBAAqB,GAAG,IAAI,sBAAsB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QACtE,qBAAqB,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QAC3C,qBAAqB,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAC/C,MAAM,EACN,SAAS,CAAC,OAAO,CAAC,IAAI,CACvB,CAAA;QACD,qBAAqB,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CACzD,MAAM,EACN,SAAS,CAAC,OAAO,CAAC,WAAW,CAC9B,CAAA;QACD,qBAAqB,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CACxE,iEAA6B,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CACtE,CAAA;QACD,OAAO,qBAAqB,CAAA;IAC9B,CAAC;IAED,SAAS,CAAC,EAAU;QAClB,OAAO,CACL,uBAAC,0BAAkB,IAEjB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,MAAM,EAAE,IAAI,CAAC,cAAc,EAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,CACpD,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAChC,IALI,EAAE,CAMa,CACvB,CAAA;IACH,CAAC;CACF;AAvCD,wDAuCC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionRequest } from '@botonic/react';
|
|
2
|
+
interface ConditionalCountryArgs {
|
|
3
|
+
request: ActionRequest;
|
|
4
|
+
results: string[];
|
|
5
|
+
keyPath: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function conditionalBotVariable({ request, results, keyPath, }: ConditionalCountryArgs): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.conditionalBotVariable = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
function conditionalBotVariable({ request, results, keyPath, }) {
|
|
6
|
+
var _a;
|
|
7
|
+
const botVariable = (0, utils_1.getValueFromKeyPath)(request, keyPath);
|
|
8
|
+
return (_a = results.find(result => result === botVariable)) !== null && _a !== void 0 ? _a : 'default';
|
|
9
|
+
}
|
|
10
|
+
exports.conditionalBotVariable = conditionalBotVariable;
|
|
11
|
+
//# sourceMappingURL=conditional-bot-variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional-bot-variable.js","sourceRoot":"","sources":["../../../src/functions/conditional-bot-variable.ts"],"names":[],"mappings":";;;AAEA,oCAA8C;AAQ9C,SAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,OAAO,EACP,OAAO,GACgB;;IACvB,MAAM,WAAW,GAAG,IAAA,2BAAmB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACzD,OAAO,MAAA,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,WAAW,CAAC,mCAAI,SAAS,CAAA;AACpE,CAAC;AAPD,wDAOC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.conditionalCountry = void 0;
|
|
4
|
+
function conditionalCountry({ request, results, }) {
|
|
5
|
+
const country = request.session.user.extra_data.country;
|
|
6
|
+
return results.find(result => result === country) || 'default';
|
|
7
|
+
}
|
|
8
|
+
exports.conditionalCountry = conditionalCountry;
|
|
9
|
+
//# sourceMappingURL=conditional-country.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional-country.js","sourceRoot":"","sources":["../../../src/functions/conditional-country.ts"],"names":[],"mappings":";;;AAOA,SAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,OAAO,GACgB;IACvB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAA;IACvD,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,OAAO,CAAC,IAAI,SAAS,CAAA;AAChE,CAAC;AAND,gDAMC"}
|
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.conditionalProvider = void 0;
|
|
4
4
|
function conditionalProvider({ request, results, }) {
|
|
5
5
|
const provider = request.session.user.provider;
|
|
6
|
-
|
|
7
|
-
return provider;
|
|
8
|
-
return 'default';
|
|
6
|
+
return results.find(result => result === provider) || 'default';
|
|
9
7
|
}
|
|
10
8
|
exports.conditionalProvider = conditionalProvider;
|
|
11
9
|
//# sourceMappingURL=conditional-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-provider.js","sourceRoot":"","sources":["../../../src/functions/conditional-provider.ts"],"names":[],"mappings":";;;AAOA,SAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,OAAO,GACiB;IACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAA;IAC9C,
|
|
1
|
+
{"version":3,"file":"conditional-provider.js","sourceRoot":"","sources":["../../../src/functions/conditional-provider.ts"],"names":[],"mappings":";;;AAOA,SAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,OAAO,GACiB;IACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAA;IAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,QAAQ,CAAC,IAAI,SAAS,CAAA;AACjE,CAAC;AAND,kDAMC"}
|
|
@@ -3,8 +3,14 @@ type ConditionalQueueStatusArgs = {
|
|
|
3
3
|
request: ActionRequest;
|
|
4
4
|
queue_id: string;
|
|
5
5
|
queue_name: string;
|
|
6
|
+
check_available_agents: boolean;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
+
declare enum QueueStatusResult {
|
|
9
|
+
OPEN = "open",
|
|
10
|
+
CLOSED = "closed",
|
|
11
|
+
OPEN_WITHOUT_AGENTS = "open-without-agents"
|
|
12
|
+
}
|
|
13
|
+
export declare function conditionalQueueStatus({ queue_id, check_available_agents, }: ConditionalQueueStatusArgs): Promise<QueueStatusResult>;
|
|
8
14
|
interface AvailabilityData {
|
|
9
15
|
available: boolean;
|
|
10
16
|
waiting_cases: number;
|
|
@@ -13,5 +19,5 @@ interface AvailabilityData {
|
|
|
13
19
|
name: string;
|
|
14
20
|
available_agents: number;
|
|
15
21
|
}
|
|
16
|
-
export declare function getQueueAvailability(queueId: string): Promise<AvailabilityData>;
|
|
22
|
+
export declare function getQueueAvailability(queueId: string, checkAvailableAgents?: boolean): Promise<AvailabilityData>;
|
|
17
23
|
export {};
|
|
@@ -4,15 +4,23 @@ exports.getQueueAvailability = exports.conditionalQueueStatus = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
6
|
const HUBTYPE_API_URL = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com';
|
|
7
|
-
|
|
7
|
+
var QueueStatusResult;
|
|
8
|
+
(function (QueueStatusResult) {
|
|
9
|
+
QueueStatusResult["OPEN"] = "open";
|
|
10
|
+
QueueStatusResult["CLOSED"] = "closed";
|
|
11
|
+
QueueStatusResult["OPEN_WITHOUT_AGENTS"] = "open-without-agents";
|
|
12
|
+
})(QueueStatusResult || (QueueStatusResult = {}));
|
|
13
|
+
function conditionalQueueStatus({ queue_id, check_available_agents, }) {
|
|
8
14
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
const data = yield getQueueAvailability(queue_id);
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
const data = yield getQueueAvailability(queue_id, check_available_agents);
|
|
16
|
+
if (check_available_agents && data.open && data.available_agents === 0) {
|
|
17
|
+
return QueueStatusResult.OPEN_WITHOUT_AGENTS;
|
|
18
|
+
}
|
|
19
|
+
return data.open ? QueueStatusResult.OPEN : QueueStatusResult.CLOSED;
|
|
12
20
|
});
|
|
13
21
|
}
|
|
14
22
|
exports.conditionalQueueStatus = conditionalQueueStatus;
|
|
15
|
-
function getQueueAvailability(queueId) {
|
|
23
|
+
function getQueueAvailability(queueId, checkAvailableAgents = false) {
|
|
16
24
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
25
|
const response = yield axios_1.default.get(`${HUBTYPE_API_URL}/public/v1/queues/${queueId}/availability/`,
|
|
18
26
|
// TODO: Make it configurable in the future
|
|
@@ -20,7 +28,7 @@ function getQueueAvailability(queueId) {
|
|
|
20
28
|
params: {
|
|
21
29
|
check_queue_schedule: true,
|
|
22
30
|
check_waiting_cases: false,
|
|
23
|
-
check_available_agents:
|
|
31
|
+
check_available_agents: checkAvailableAgents,
|
|
24
32
|
},
|
|
25
33
|
});
|
|
26
34
|
return response.data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AAEzB,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AAEzB,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAShF,IAAK,iBAIJ;AAJD,WAAK,iBAAiB;IACpB,kCAAa,CAAA;IACb,sCAAiB,CAAA;IACjB,gEAA2C,CAAA;AAC7C,CAAC,EAJI,iBAAiB,KAAjB,iBAAiB,QAIrB;AAED,SAAsB,sBAAsB,CAAC,EAC3C,QAAQ,EACR,sBAAsB,GACK;;QAC3B,MAAM,IAAI,GAAG,MAAM,oBAAoB,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAA;QACzE,IAAI,sBAAsB,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,gBAAgB,KAAK,CAAC,EAAE;YACtE,OAAO,iBAAiB,CAAC,mBAAmB,CAAA;SAC7C;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAA;IACtE,CAAC;CAAA;AATD,wDASC;AAWD,SAAsB,oBAAoB,CACxC,OAAe,EACf,oBAAoB,GAAG,KAAK;;QAE5B,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,GAAG,eAAe,qBAAqB,OAAO,gBAAgB;QAC9D,2CAA2C;QAC3C;YACE,MAAM,EAAE;gBACN,oBAAoB,EAAE,IAAI;gBAC1B,mBAAmB,EAAE,KAAK;gBAC1B,sBAAsB,EAAE,oBAAoB;aAC7C;SACF,CACF,CAAA;QACD,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;CAAA;AAhBD,oDAgBC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { conditionalBotVariable } from './conditional-bot-variable';
|
|
2
|
+
import { conditionalCountry } from './conditional-country';
|
|
1
3
|
import { conditionalProvider } from './conditional-provider';
|
|
2
4
|
import { conditionalQueueStatus } from './conditional-queue-status';
|
|
3
5
|
export declare const DEFAULT_FUNCTIONS: {
|
|
4
6
|
'check-queue-status': typeof conditionalQueueStatus;
|
|
5
7
|
'get-channel-type': typeof conditionalProvider;
|
|
8
|
+
'check-country': typeof conditionalCountry;
|
|
9
|
+
'check-bot-variable': typeof conditionalBotVariable;
|
|
6
10
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_FUNCTIONS = void 0;
|
|
4
|
+
const conditional_bot_variable_1 = require("./conditional-bot-variable");
|
|
5
|
+
const conditional_country_1 = require("./conditional-country");
|
|
4
6
|
const conditional_provider_1 = require("./conditional-provider");
|
|
5
7
|
const conditional_queue_status_1 = require("./conditional-queue-status");
|
|
6
8
|
exports.DEFAULT_FUNCTIONS = {
|
|
7
9
|
// TODO: Rename api action name
|
|
8
10
|
'check-queue-status': conditional_queue_status_1.conditionalQueueStatus,
|
|
9
11
|
'get-channel-type': conditional_provider_1.conditionalProvider,
|
|
12
|
+
'check-country': conditional_country_1.conditionalCountry,
|
|
13
|
+
'check-bot-variable': conditional_bot_variable_1.conditionalBotVariable,
|
|
10
14
|
};
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/index.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;AAC5D,yEAAmE;AAEtD,QAAA,iBAAiB,GAAG;IAC/B,+BAA+B;IAC/B,oBAAoB,EAAE,iDAAsB;IAC5C,kBAAkB,EAAE,0CAAmB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/index.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE,+DAA0D;AAC1D,iEAA4D;AAC5D,yEAAmE;AAEtD,QAAA,iBAAiB,GAAG;IAC/B,+BAA+B;IAC/B,oBAAoB,EAAE,iDAAsB;IAC5C,kBAAkB,EAAE,0CAAmB;IACvC,eAAe,EAAE,wCAAkB;IACnC,oBAAoB,EAAE,iDAAsB;CAC7C,CAAA"}
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Plugin, PluginPreRequest, Session } from '@botonic/core';
|
|
|
2
2
|
import { ActionRequest } from '@botonic/react';
|
|
3
3
|
import { FlowBuilderApi } from './api';
|
|
4
4
|
import { FlowContent } from './content-fields';
|
|
5
|
-
import {
|
|
5
|
+
import { HtNodeWithContent } from './content-fields/hubtype-fields';
|
|
6
6
|
import { BotonicPluginFlowBuilderOptions, KnowledgeBaseResponse, PayloadParamsBase } from './types';
|
|
7
7
|
export default class BotonicPluginFlowBuilder implements Plugin {
|
|
8
8
|
readonly options: BotonicPluginFlowBuilderOptions;
|
|
@@ -22,7 +22,8 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
22
22
|
getStartContents(locale: string): Promise<FlowContent[]>;
|
|
23
23
|
getContentsByNode(node: HtNodeWithContent, locale: string, prevContents?: FlowContent[]): Promise<FlowContent[]>;
|
|
24
24
|
private getFlowContent;
|
|
25
|
-
callFunction
|
|
25
|
+
private callFunction;
|
|
26
|
+
private getArgumentsByLocale;
|
|
26
27
|
getPayloadParams<T extends PayloadParamsBase>(payload: string): T;
|
|
27
28
|
}
|
|
28
29
|
export * from './action';
|