@botonic/plugin-flow-builder 0.25.0-alpha.9 → 0.25.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 +5 -3
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.js +4 -2
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/api.d.ts +6 -2
- package/lib/cjs/api.js +35 -7
- 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-handoff.js +1 -1
- package/lib/cjs/content-fields/flow-handoff.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/common.d.ts +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.d.ts +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.js +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +1 -0
- package/lib/cjs/content-fields/hubtype-fields/node-types.js +1 -0
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +2 -1
- package/lib/cjs/content-fields/hubtype-fields/smart-intent.d.ts +11 -0
- package/lib/cjs/content-fields/hubtype-fields/smart-intent.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/smart-intent.js.map +1 -0
- 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/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 +8 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/{action/tracking.js → tracking.js} +1 -1
- package/lib/cjs/tracking.js.map +1 -0
- package/lib/cjs/types.d.ts +1 -1
- package/lib/cjs/user-input/index.d.ts +4 -0
- package/lib/cjs/{action/user-input.js → user-input/index.js} +8 -4
- package/lib/cjs/user-input/index.js.map +1 -0
- package/lib/cjs/{action → user-input}/intent.js +1 -1
- package/lib/cjs/user-input/intent.js.map +1 -0
- package/lib/cjs/{action → user-input}/keyword.js +1 -1
- package/lib/cjs/user-input/keyword.js.map +1 -0
- package/lib/cjs/user-input/smart-intent.d.ts +4 -0
- package/lib/cjs/user-input/smart-intent.js +40 -0
- package/lib/cjs/user-input/smart-intent.js.map +1 -0
- 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 +5 -3
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/knowledge-bases.js +4 -2
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/api.d.ts +6 -2
- package/lib/esm/api.js +36 -8
- 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-handoff.js +1 -1
- package/lib/esm/content-fields/flow-handoff.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/common.d.ts +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.d.ts +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.js +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +1 -0
- package/lib/esm/content-fields/hubtype-fields/node-types.js +1 -0
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +2 -1
- package/lib/esm/content-fields/hubtype-fields/smart-intent.d.ts +11 -0
- package/lib/esm/content-fields/hubtype-fields/smart-intent.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/smart-intent.js.map +1 -0
- 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/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 +8 -4
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/{action/tracking.js → tracking.js} +1 -1
- package/lib/esm/tracking.js.map +1 -0
- package/lib/esm/types.d.ts +1 -1
- package/lib/esm/user-input/index.d.ts +4 -0
- package/lib/esm/{action/user-input.js → user-input/index.js} +8 -4
- package/lib/esm/user-input/index.js.map +1 -0
- package/lib/esm/{action → user-input}/intent.js +1 -1
- package/lib/esm/user-input/intent.js.map +1 -0
- package/lib/esm/{action → user-input}/keyword.js +1 -1
- package/lib/esm/user-input/keyword.js.map +1 -0
- package/lib/esm/user-input/smart-intent.d.ts +4 -0
- package/lib/esm/user-input/smart-intent.js +36 -0
- package/lib/esm/user-input/smart-intent.js.map +1 -0
- 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 -4
- package/src/action/index.tsx +5 -3
- package/src/action/knowledge-bases.ts +4 -3
- package/src/api.ts +51 -8
- package/src/constants.ts +3 -1
- package/src/content-fields/flow-handoff.tsx +1 -1
- package/src/content-fields/flow-text.tsx +23 -17
- package/src/content-fields/hubtype-fields/common.ts +1 -0
- package/src/content-fields/hubtype-fields/index.ts +1 -0
- package/src/content-fields/hubtype-fields/node-types.ts +1 -0
- package/src/content-fields/hubtype-fields/nodes.ts +2 -0
- package/src/content-fields/hubtype-fields/smart-intent.ts +12 -0
- 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/index.ts +4 -0
- package/src/index.ts +15 -6
- package/src/{action/tracking.ts → tracking.ts} +1 -1
- package/src/types.ts +1 -1
- package/src/{action/user-input.ts → user-input/index.ts} +13 -5
- package/src/{action → user-input}/intent.ts +1 -1
- package/src/{action → user-input}/keyword.ts +1 -1
- package/src/user-input/smart-intent.ts +42 -0
- package/src/utils.ts +26 -0
- package/lib/cjs/action/intent.js.map +0 -1
- package/lib/cjs/action/keyword.js.map +0 -1
- package/lib/cjs/action/tracking.js.map +0 -1
- package/lib/cjs/action/user-input.d.ts +0 -4
- package/lib/cjs/action/user-input.js.map +0 -1
- package/lib/esm/action/intent.js.map +0 -1
- package/lib/esm/action/keyword.js.map +0 -1
- package/lib/esm/action/tracking.js.map +0 -1
- package/lib/esm/action/user-input.d.ts +0 -4
- package/lib/esm/action/user-input.js.map +0 -1
- /package/lib/cjs/{action/tracking.d.ts → tracking.d.ts} +0 -0
- /package/lib/cjs/{action → user-input}/intent.d.ts +0 -0
- /package/lib/cjs/{action → user-input}/keyword.d.ts +0 -0
- /package/lib/esm/{action/tracking.d.ts → tracking.d.ts} +0 -0
- /package/lib/esm/{action → user-input}/intent.d.ts +0 -0
- /package/lib/esm/{action → user-input}/keyword.d.ts +0 -0
package/lib/cjs/action/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const react_2 = tslib_1.__importDefault(require("react"));
|
|
|
8
8
|
const content_fields_1 = require("../content-fields");
|
|
9
9
|
const helpers_1 = require("../helpers");
|
|
10
10
|
const knowledge_bases_1 = require("./knowledge-bases");
|
|
11
|
-
const tracking_1 = require("
|
|
11
|
+
const tracking_1 = require("../tracking");
|
|
12
12
|
class FlowBuilderAction extends react_2.default.Component {
|
|
13
13
|
static botonicInit(request) {
|
|
14
14
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/action/index.t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,CAAC,UAAU,KAClC,qBAAqB,EAAE,IAAI,GAC5B,CAAA;SACF;QAED,MAAM,iBAAiB,GAAG,MAAM,IAAA,6CAA2B,EAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC5E,IAAI,iBAAiB,EAAE;YACrB,OAAO,iBAAiB,CAAA;SACzB;QAED,MAAM,qBAAqB,GACzB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAA;QACzD,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAA;QAClE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,GAAG,CAAC,qBAAqB,CAAA;QAE9E,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,oBAAS,CAAC,QAAQ,CAAC,CAAA;QAC7C,OAAO,YAAY,CAAA;;CACpB"}
|
|
@@ -5,11 +5,12 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const uuid_1 = require("uuid");
|
|
6
6
|
const hubtype_fields_1 = require("../content-fields/hubtype-fields");
|
|
7
7
|
const helpers_1 = require("../helpers");
|
|
8
|
-
const tracking_1 = require("
|
|
8
|
+
const tracking_1 = require("../tracking");
|
|
9
9
|
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,12 +27,13 @@ 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,
|
|
33
34
|
buttons: [],
|
|
34
35
|
},
|
|
36
|
+
flow_id: 'randomUUID',
|
|
35
37
|
id: (0, uuid_1.v4)(),
|
|
36
38
|
code: 'knowledge-response',
|
|
37
39
|
meta: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";;;;AAEA,+BAAiC;AAGjC,qEAIyC;AACzC,wCAAiD;AACjD,
|
|
1
|
+
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";;;;AAEA,+BAAiC;AAGjC,qEAIyC;AACzC,wCAAiD;AACjD,0CAAmD;AAEnD,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,MAAM,mBAAmB,GAAG,MAAM,CAAC,sBAAsB,EAAE,CAAA;QAE3D,IACE,iBAAiB,CAAC,wBAAwB;aAC1C,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,QAAQ,CAAA,EAC7B;YACA,IAAI;gBACF,MAAM,qBAAqB,GACzB,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAA;gBAC3D,IAAI,qBAAqB,CAAC,YAAY,EAAE;oBACtC,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,oBAAS,CAAC,kBAAkB,EAAE;wBACtD,MAAM,EAAE,qBAAqB,CAAC,MAAM;wBACpC,oBAAoB,EAAE,qBAAqB,CAAC,OAAO,CAAC,GAAG,CACrD,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,iBAAiB,CACnC;qBACF,CAAC,CAAA;oBAEF,MAAM,iBAAiB,GAAe;wBACpC,IAAI,EAAE,sCAAqB,CAAC,IAAI;wBAChC,OAAO,EAAE;4BACP,IAAI,EAAE;gCACJ;oCACE,OAAO,EAAE,qBAAqB,CAAC,MAAM;oCACrC,MAAM,EAAE,cAAc;iCACvB;6BACF;4BACD,aAAa,EAAE,SAAS;4BACxB,OAAO,EAAE,EAAE;yBACZ;wBACD,OAAO,EAAE,YAAY;wBACrB,EAAE,EAAE,IAAA,SAAI,GAAE;wBACV,IAAI,EAAE,oBAAoB;wBAC1B,IAAI,EAAE;4BACJ,CAAC,EAAE,CAAC;4BACJ,CAAC,EAAE,CAAC;yBACL;wBACD,SAAS,EAAE,mBAAmB,CAAC,QAAQ;qBACxC,CAAA;oBACD,OAAO,iBAAiB,CAAA;iBACzB;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;gBACxD,OAAO,SAAS,CAAA;aACjB;SACF;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CAAA;AArDD,kEAqDC"}
|
package/lib/cjs/api.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Input, PluginPreRequest } from '@botonic/core';
|
|
2
2
|
import { HtFlowBuilderData, HtIntentNode, HtKeywordNode, HtNodeComponent, HtNodeLink, HtNodeWithContent } from './content-fields/hubtype-fields';
|
|
3
|
+
import { HtSmartIntentNode } from './content-fields/hubtype-fields/smart-intent';
|
|
3
4
|
import { FlowBuilderApiOptions } from './types';
|
|
4
5
|
export declare class FlowBuilderApi {
|
|
5
6
|
url: string;
|
|
@@ -10,7 +11,7 @@ export declare class FlowBuilderApi {
|
|
|
10
11
|
private getFlow;
|
|
11
12
|
getNodeByFlowId(id: string): HtNodeWithContent;
|
|
12
13
|
getNodeById<T extends HtNodeComponent>(id: string): T;
|
|
13
|
-
|
|
14
|
+
getNodeByContentID(contentID: string): HtNodeComponent;
|
|
14
15
|
getStartNode(): HtNodeWithContent;
|
|
15
16
|
getFallbackNode(alternate: boolean): HtNodeWithContent;
|
|
16
17
|
getKnowledgeBaseConfig(): {
|
|
@@ -18,12 +19,15 @@ export declare class FlowBuilderApi {
|
|
|
18
19
|
isActive: boolean;
|
|
19
20
|
} | undefined;
|
|
20
21
|
getIntentNode(input: Input, locale: string): HtIntentNode | undefined;
|
|
22
|
+
getSmartIntentNodes(): HtSmartIntentNode[];
|
|
21
23
|
private nodeContainsIntent;
|
|
22
24
|
hasMetConfidenceThreshold(node: HtIntentNode, predictedConfidence: number): boolean;
|
|
23
25
|
getNodeByKeyword(userInput: string, locale: string): HtKeywordNode | undefined;
|
|
24
26
|
private matchKeywords;
|
|
25
|
-
private
|
|
27
|
+
private inputMatchesAnyKeyword;
|
|
28
|
+
private resolveKeywordAsRegExp;
|
|
26
29
|
getPayload(target?: HtNodeLink): string | undefined;
|
|
27
30
|
private createPayloadWithParams;
|
|
31
|
+
private getFollowUpContentID;
|
|
28
32
|
getResolvedLocale(locale: string): string;
|
|
29
33
|
}
|
package/lib/cjs/api.js
CHANGED
|
@@ -40,10 +40,10 @@ class FlowBuilderApi {
|
|
|
40
40
|
}
|
|
41
41
|
return node;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
const content = this.flow.nodes.find(node => 'code' in node ? node.code ===
|
|
43
|
+
getNodeByContentID(contentID) {
|
|
44
|
+
const content = this.flow.nodes.find(node => 'code' in node ? node.code === contentID : false);
|
|
45
45
|
if (!content)
|
|
46
|
-
throw Error(`Node with
|
|
46
|
+
throw Error(`Node with contentID: '${contentID}' not found`);
|
|
47
47
|
return content;
|
|
48
48
|
}
|
|
49
49
|
getStartNode() {
|
|
@@ -91,6 +91,9 @@ class FlowBuilderApi {
|
|
|
91
91
|
}
|
|
92
92
|
return undefined;
|
|
93
93
|
}
|
|
94
|
+
getSmartIntentNodes() {
|
|
95
|
+
return this.flow.nodes.filter(node => node.type === hubtype_fields_1.HtNodeWithContentType.SMART_INTENT);
|
|
96
|
+
}
|
|
94
97
|
nodeContainsIntent(node, intent, locale) {
|
|
95
98
|
return node.content.intents.some(i => i.locale === locale && i.values.includes(intent));
|
|
96
99
|
}
|
|
@@ -112,11 +115,23 @@ class FlowBuilderApi {
|
|
|
112
115
|
return undefined;
|
|
113
116
|
}
|
|
114
117
|
matchKeywords(node, input, locale) {
|
|
115
|
-
const result = node.content.keywords.find(
|
|
118
|
+
const result = node.content.keywords.find(keywords => keywords.locale === locale &&
|
|
119
|
+
this.inputMatchesAnyKeyword(input, keywords.values));
|
|
116
120
|
return Boolean(result);
|
|
117
121
|
}
|
|
118
|
-
|
|
119
|
-
return keywords.some(keyword =>
|
|
122
|
+
inputMatchesAnyKeyword(input, keywords) {
|
|
123
|
+
return keywords.some(keyword => {
|
|
124
|
+
const regExpMatchArray = keyword.match(constants_1.REG_EXP_PATTERN);
|
|
125
|
+
if (regExpMatchArray) {
|
|
126
|
+
return this.resolveKeywordAsRegExp(regExpMatchArray, input);
|
|
127
|
+
}
|
|
128
|
+
return input.includes(keyword);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
resolveKeywordAsRegExp(regExpMatchArray, input) {
|
|
132
|
+
const [, pattern, flags] = regExpMatchArray;
|
|
133
|
+
const keywordAsRegExp = new RegExp(pattern, flags);
|
|
134
|
+
return input.match(keywordAsRegExp);
|
|
120
135
|
}
|
|
121
136
|
getPayload(target) {
|
|
122
137
|
if (!target) {
|
|
@@ -133,9 +148,22 @@ class FlowBuilderApi {
|
|
|
133
148
|
const payloadId = botActionNode.content.payload_id;
|
|
134
149
|
const payloadNode = this.getNodeById(payloadId);
|
|
135
150
|
const customParams = JSON.parse(botActionNode.content.payload_params || '{}');
|
|
136
|
-
const
|
|
151
|
+
const followUpContentID = this.getFollowUpContentID((_a = botActionNode.follow_up) === null || _a === void 0 ? void 0 : _a.id);
|
|
152
|
+
const payloadJson = JSON.stringify(Object.assign(Object.assign({}, customParams), { followUpContentID }));
|
|
137
153
|
return `${payloadNode.content.payload}${constants_1.SEPARATOR}${payloadJson}`;
|
|
138
154
|
}
|
|
155
|
+
getFollowUpContentID(id) {
|
|
156
|
+
const followUpNode = id
|
|
157
|
+
? this.getNodeById(id)
|
|
158
|
+
: undefined;
|
|
159
|
+
if ((followUpNode === null || followUpNode === void 0 ? void 0 : followUpNode.type) === hubtype_fields_1.HtNodeWithoutContentType.GO_TO_FLOW) {
|
|
160
|
+
return this.getNodeById(followUpNode === null || followUpNode === void 0 ? void 0 : followUpNode.content.flow_id)
|
|
161
|
+
.code;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return followUpNode === null || followUpNode === void 0 ? void 0 : followUpNode.code;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
139
167
|
getResolvedLocale(locale) {
|
|
140
168
|
if (this.flow.locales.find(flowLocale => flowLocale === locale)) {
|
|
141
169
|
return locale;
|
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,oEAawC;AAIxC,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,CAA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AAO,QAAQ,CAAA;SAChB;QACD,MAAM,IAAI,KAAK,CACb,WAAW,MAAM,2BAA2B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAChE,CAAA;IACH,CAAC;CACF;AAjPD,wCAiPC"}
|
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"}
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const core_1 = require("@botonic/core");
|
|
7
7
|
const react_1 = require("@botonic/react");
|
|
8
|
-
const tracking_1 = require("../
|
|
8
|
+
const tracking_1 = require("../tracking");
|
|
9
9
|
const conditional_queue_status_1 = require("../functions/conditional-queue-status");
|
|
10
10
|
const content_fields_base_1 = require("./content-fields-base");
|
|
11
11
|
class FlowHandoff extends content_fields_base_1.ContentFieldsBase {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-handoff.js","sourceRoot":"","sources":["../../../src/content-fields/flow-handoff.tsx"],"names":[],"mappings":";;;;;AAAA,wCAA8C;AAC9C,0CAA+D;AAG/D,
|
|
1
|
+
{"version":3,"file":"flow-handoff.js","sourceRoot":"","sources":["../../../src/content-fields/flow-handoff.tsx"],"names":[],"mappings":";;;;;AAAA,wCAA8C;AAC9C,0CAA+D;AAG/D,0CAAmD;AAEnD,oFAA4E;AAC5E,+DAAyD;AAGzD,MAAa,WAAY,SAAQ,uCAAiB;IAMhD,MAAM,CAAC,cAAc,CACnB,UAAyB,EACzB,MAAc,EACd,MAAsB;QAEtB,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;QACjD,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;QACjC,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,OA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E,IAAI,CAAC,KAAK,CAAC,EAAE;oBACvB,gBAAgB,EAAE,gBAAgB,CAAC,gBAAgB,GAAG,CAAC;oBACvD,iBAAiB,EACf,gBAAgB,CAAC,oCAAoC,GAAG,CAAC;iBAC5D,CAAA;gBACD,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,oBAAS,CAAC,cAAc,EAAE,SAAS,CAAC,CAAA;gBAE9D,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;gBACvC,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;aAC/B;QACH,CAAC;KAAA;IAED,SAAS;QACP,OAAO,uBAAC,uBAAe,IAAC,eAAe,EAAE,IAAI,GAAI,CAAA;IACnD,CAAC;CACF;AAtED,kCAsEC"}
|
|
@@ -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,EAAE,MAAM,EAAE,MAAM,CAAC,CAClD,CAAA;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,MAAM,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CAAC;CACF;AAzDD,4BAyDC"}
|
|
@@ -15,6 +15,7 @@ tslib_1.__exportStar(require("./keyword"), exports);
|
|
|
15
15
|
tslib_1.__exportStar(require("./node-types"), exports);
|
|
16
16
|
tslib_1.__exportStar(require("./nodes"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./payload"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./smart-intent"), exports);
|
|
18
19
|
tslib_1.__exportStar(require("./text"), exports);
|
|
19
20
|
tslib_1.__exportStar(require("./url"), exports);
|
|
20
21
|
tslib_1.__exportStar(require("./video"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,mDAAwB;AACxB,qDAA0B;AAC1B,mDAAwB;AACxB,qDAA0B;AAC1B,qDAA0B;AAC1B,uDAA4B;AAC5B,oDAAyB;AACzB,kDAAuB;AACvB,mDAAwB;AACxB,oDAAyB;AACzB,uDAA4B;AAC5B,kDAAuB;AACvB,oDAAyB;AACzB,iDAAsB;AACtB,gDAAqB;AACrB,kDAAuB;AACvB,iEAAsC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,mDAAwB;AACxB,qDAA0B;AAC1B,mDAAwB;AACxB,qDAA0B;AAC1B,qDAA0B;AAC1B,uDAA4B;AAC5B,oDAAyB;AACzB,kDAAuB;AACvB,mDAAwB;AACxB,oDAAyB;AACzB,uDAA4B;AAC5B,kDAAuB;AACvB,oDAAyB;AACzB,yDAA8B;AAC9B,iDAAsB;AACtB,gDAAqB;AACrB,kDAAuB;AACvB,iEAAsC"}
|
|
@@ -9,6 +9,7 @@ var HtNodeWithContentType;
|
|
|
9
9
|
HtNodeWithContentType["TEXT"] = "text";
|
|
10
10
|
HtNodeWithContentType["KEYWORD"] = "keyword";
|
|
11
11
|
HtNodeWithContentType["INTENT"] = "intent";
|
|
12
|
+
HtNodeWithContentType["SMART_INTENT"] = "smart-intent";
|
|
12
13
|
HtNodeWithContentType["FUNCTION"] = "function";
|
|
13
14
|
HtNodeWithContentType["FALLBACK"] = "fallback";
|
|
14
15
|
HtNodeWithContentType["VIDEO"] = "video";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-types.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/node-types.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"node-types.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/node-types.ts"],"names":[],"mappings":";;;AAAA,IAAY,qBAYX;AAZD,WAAY,qBAAqB;IAC/B,8CAAqB,CAAA;IACrB,4CAAmB,CAAA;IACnB,wCAAe,CAAA;IACf,sCAAa,CAAA;IACb,4CAAmB,CAAA;IACnB,0CAAiB,CAAA;IACjB,sDAA6B,CAAA;IAC7B,8CAAqB,CAAA;IACrB,8CAAqB,CAAA;IACrB,wCAAe,CAAA;IACf,sEAA6C,CAAA;AAC/C,CAAC,EAZW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAYhC;AAED,IAAY,wBAKX;AALD,WAAY,wBAAwB;IAClC,uCAAW,CAAA;IACX,+CAAmB,CAAA;IACnB,qDAAyB,CAAA;IACzB,qDAAyB,CAAA;AAC3B,CAAC,EALW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAKnC;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB"}
|
|
@@ -8,10 +8,11 @@ import { HtImageNode } from './image';
|
|
|
8
8
|
import { HtIntentNode } from './intent';
|
|
9
9
|
import { HtKeywordNode } from './keyword';
|
|
10
10
|
import { HtPayloadNode } from './payload';
|
|
11
|
+
import { HtSmartIntentNode } from './smart-intent';
|
|
11
12
|
import { HtTextNode } from './text';
|
|
12
13
|
import { HtUrlNode } from './url';
|
|
13
14
|
import { HtVideoNode } from './video';
|
|
14
15
|
import { HtWhatsappButtonListNode } from './whatsapp-button-list';
|
|
15
|
-
export type HtNodeWithContent = HtTextNode | HtImageNode | HtVideoNode | HtCarouselNode | HtHandoffNode | HtKeywordNode | HtIntentNode | HtFunctionNode | HtFallbackNode | HtWhatsappButtonListNode;
|
|
16
|
+
export type HtNodeWithContent = HtTextNode | HtImageNode | HtVideoNode | HtCarouselNode | HtHandoffNode | HtKeywordNode | HtIntentNode | HtFunctionNode | HtFallbackNode | HtWhatsappButtonListNode | HtSmartIntentNode;
|
|
16
17
|
export type HtNodeWithoutContent = HtUrlNode | HtPayloadNode | HtGoToFlow | HtBotActionNode;
|
|
17
18
|
export type HtNodeComponent = HtNodeWithContent | HtNodeWithoutContent;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HtBaseNode } from './common';
|
|
2
|
+
import { HtNodeWithContentType } from './node-types';
|
|
3
|
+
interface SmartIntent {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
}
|
|
7
|
+
export interface HtSmartIntentNode extends HtBaseNode {
|
|
8
|
+
type: HtNodeWithContentType.SMART_INTENT;
|
|
9
|
+
content: SmartIntent;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-intent.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/smart-intent.ts"],"names":[],"mappings":""}
|
|
@@ -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-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
|
@@ -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"}
|