@botonic/plugin-flow-builder 0.34.2 → 0.35.0-alpha.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/cjs/action/fallback.d.ts +1 -1
- package/lib/cjs/action/fallback.js +2 -2
- package/lib/cjs/action/fallback.js.map +1 -1
- package/lib/cjs/action/first-interaction.js +5 -5
- package/lib/cjs/action/first-interaction.js.map +1 -1
- package/lib/cjs/action/index.d.ts +1 -1
- package/lib/cjs/action/index.js +2 -3
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.d.ts +1 -1
- package/lib/cjs/action/knowledge-bases.js +2 -2
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/action/payload.d.ts +1 -1
- package/lib/cjs/action/payload.js +2 -2
- package/lib/cjs/action/payload.js.map +1 -1
- package/lib/cjs/api.d.ts +6 -6
- package/lib/cjs/api.js +24 -24
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/content-fields/flow-handoff.js +2 -2
- package/lib/cjs/content-fields/flow-handoff.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 +0 -1
- package/lib/cjs/content-fields/hubtype-fields/index.js +0 -1
- package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +0 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.js +0 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +1 -2
- package/lib/cjs/functions/conditional-country.js +1 -1
- package/lib/cjs/functions/conditional-country.js.map +1 -1
- package/lib/cjs/helpers.d.ts +2 -4
- package/lib/cjs/helpers.js +8 -5
- package/lib/cjs/helpers.js.map +1 -1
- package/lib/cjs/index.d.ts +6 -7
- package/lib/cjs/index.js +14 -17
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/tracking.d.ts +0 -1
- package/lib/cjs/tracking.js +0 -1
- package/lib/cjs/tracking.js.map +1 -1
- package/lib/cjs/types.d.ts +6 -8
- package/lib/cjs/types.js.map +1 -1
- package/lib/cjs/user-input/index.d.ts +2 -2
- package/lib/cjs/user-input/index.js +0 -8
- package/lib/cjs/user-input/index.js.map +1 -1
- package/lib/cjs/utils.d.ts +1 -2
- package/lib/cjs/utils.js +2 -2
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/action/fallback.d.ts +1 -1
- package/lib/esm/action/fallback.js +2 -2
- package/lib/esm/action/fallback.js.map +1 -1
- package/lib/esm/action/first-interaction.js +5 -5
- package/lib/esm/action/first-interaction.js.map +1 -1
- package/lib/esm/action/index.d.ts +1 -1
- package/lib/esm/action/index.js +2 -3
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/knowledge-bases.d.ts +1 -1
- package/lib/esm/action/knowledge-bases.js +2 -2
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/action/payload.d.ts +1 -1
- package/lib/esm/action/payload.js +2 -2
- package/lib/esm/action/payload.js.map +1 -1
- package/lib/esm/api.d.ts +6 -6
- package/lib/esm/api.js +24 -24
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/content-fields/flow-handoff.js +2 -2
- package/lib/esm/content-fields/flow-handoff.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 +0 -1
- package/lib/esm/content-fields/hubtype-fields/index.js +0 -1
- package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +0 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.js +0 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +1 -2
- package/lib/esm/functions/conditional-country.js +1 -1
- package/lib/esm/functions/conditional-country.js.map +1 -1
- package/lib/esm/helpers.d.ts +2 -4
- package/lib/esm/helpers.js +8 -5
- package/lib/esm/helpers.js.map +1 -1
- package/lib/esm/index.d.ts +6 -7
- package/lib/esm/index.js +14 -17
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/tracking.d.ts +0 -1
- package/lib/esm/tracking.js +0 -1
- package/lib/esm/tracking.js.map +1 -1
- package/lib/esm/types.d.ts +6 -8
- package/lib/esm/types.js.map +1 -1
- package/lib/esm/user-input/index.d.ts +2 -2
- package/lib/esm/user-input/index.js +0 -8
- package/lib/esm/user-input/index.js.map +1 -1
- package/lib/esm/utils.d.ts +1 -2
- package/lib/esm/utils.js +3 -3
- package/lib/esm/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/action/fallback.ts +2 -5
- package/src/action/first-interaction.ts +3 -6
- package/src/action/index.tsx +2 -3
- package/src/action/knowledge-bases.ts +8 -8
- package/src/action/payload.ts +1 -2
- package/src/api.ts +33 -43
- package/src/content-fields/flow-handoff.tsx +2 -2
- package/src/content-fields/hubtype-fields/common.ts +1 -0
- package/src/content-fields/hubtype-fields/index.ts +0 -1
- package/src/content-fields/hubtype-fields/node-types.ts +0 -1
- package/src/content-fields/hubtype-fields/nodes.ts +0 -2
- package/src/functions/conditional-country.ts +1 -1
- package/src/helpers.ts +17 -11
- package/src/index.ts +19 -20
- package/src/tracking.ts +0 -1
- package/src/types.ts +22 -10
- package/src/user-input/index.ts +1 -11
- package/src/utils.ts +3 -7
- package/lib/cjs/content-fields/hubtype-fields/intent.d.ts +0 -10
- package/lib/cjs/content-fields/hubtype-fields/intent.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/intent.js.map +0 -1
- package/lib/cjs/user-input/intent.d.ts +0 -4
- package/lib/cjs/user-input/intent.js +0 -45
- package/lib/cjs/user-input/intent.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/intent.d.ts +0 -10
- package/lib/esm/content-fields/hubtype-fields/intent.js +0 -2
- package/lib/esm/content-fields/hubtype-fields/intent.js.map +0 -1
- package/lib/esm/user-input/intent.d.ts +0 -4
- package/lib/esm/user-input/intent.js +0 -41
- package/lib/esm/user-input/intent.js.map +0 -1
- package/src/content-fields/hubtype-fields/intent.ts +0 -12
- package/src/user-input/intent.ts +0 -59
|
@@ -5,7 +5,6 @@ import { HtFunctionNode } from './function';
|
|
|
5
5
|
import { HtGoToFlow } from './go-to-flow';
|
|
6
6
|
import { HtHandoffNode } from './handoff';
|
|
7
7
|
import { HtImageNode } from './image';
|
|
8
|
-
import { HtIntentNode } from './intent';
|
|
9
8
|
import { HtKeywordNode } from './keyword';
|
|
10
9
|
import { HtKnowledgeBaseNode } from './knowledge-base';
|
|
11
10
|
import { HtPayloadNode } from './payload';
|
|
@@ -15,6 +14,6 @@ import { HtUrlNode } from './url';
|
|
|
15
14
|
import { HtVideoNode } from './video';
|
|
16
15
|
import { HtWhatsappButtonListNode } from './whatsapp-button-list';
|
|
17
16
|
import { HtWhatsappCTAUrlButtonNode } from './whatsapp-cta-url-button';
|
|
18
|
-
export type HtNodeWithContent = HtTextNode | HtImageNode | HtVideoNode | HtCarouselNode | HtHandoffNode | HtKeywordNode |
|
|
17
|
+
export type HtNodeWithContent = HtTextNode | HtImageNode | HtVideoNode | HtCarouselNode | HtHandoffNode | HtKeywordNode | HtFunctionNode | HtFallbackNode | HtWhatsappButtonListNode | HtWhatsappCTAUrlButtonNode | HtSmartIntentNode | HtKnowledgeBaseNode | HtBotActionNode;
|
|
19
18
|
export type HtNodeWithoutContent = HtUrlNode | HtPayloadNode | HtGoToFlow;
|
|
20
19
|
export type HtNodeComponent = HtNodeWithContent | HtNodeWithoutContent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function conditionalCountry({ request, results, }) {
|
|
2
|
-
const country = request.
|
|
2
|
+
const country = request.getUserCountry();
|
|
3
3
|
return results.find(result => result === country) || 'default';
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=conditional-country.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-country.js","sourceRoot":"","sources":["../../../src/functions/conditional-country.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,kBAAkB,CAAC,EACjC,OAAO,EACP,OAAO,GACgB;IACvB,MAAM,OAAO,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"conditional-country.js","sourceRoot":"","sources":["../../../src/functions/conditional-country.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,kBAAkB,CAAC,EACjC,OAAO,EACP,OAAO,GACgB;IACvB,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAA;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,OAAO,CAAC,IAAI,SAAS,CAAA;AAChE,CAAC"}
|
package/lib/esm/helpers.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResolvedPlugins } from '@botonic/core';
|
|
2
2
|
import BotonicPluginFlowBuilder from './index';
|
|
3
|
-
export declare function getFlowBuilderPlugin(plugins:
|
|
4
|
-
[id: string]: Plugin;
|
|
5
|
-
}): BotonicPluginFlowBuilder;
|
|
3
|
+
export declare function getFlowBuilderPlugin(plugins: ResolvedPlugins): BotonicPluginFlowBuilder;
|
package/lib/esm/helpers.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
const FLOW_BUILDER_PLUGIN_NAME = 'BotonicPluginFlowBuilder';
|
|
2
2
|
export function getFlowBuilderPlugin(plugins) {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const ERROR_MESSAGE = `You must include '@botonic/plugin-flow-builder' in your plugins file.`;
|
|
4
|
+
if (Object.values(plugins).length === 0) {
|
|
5
|
+
throw new Error(ERROR_MESSAGE);
|
|
6
|
+
}
|
|
7
|
+
const flowBuilderPlugin = Object.values(plugins).find(plugin => plugin.constructor.name === FLOW_BUILDER_PLUGIN_NAME);
|
|
8
|
+
if (!flowBuilderPlugin) {
|
|
9
|
+
throw new Error(ERROR_MESSAGE);
|
|
10
|
+
}
|
|
8
11
|
return flowBuilderPlugin;
|
|
9
12
|
}
|
|
10
13
|
//# sourceMappingURL=helpers.js.map
|
package/lib/esm/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAIA,MAAM,wBAAwB,GAAG,0BAA0B,CAAA;AAE3D,MAAM,UAAU,oBAAoB,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAIA,MAAM,wBAAwB,GAAG,0BAA0B,CAAA;AAE3D,MAAM,UAAU,oBAAoB,CAClC,OAAwB;IAExB,MAAM,aAAa,GAAG,uEAAuE,CAAA;IAE7F,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;KAC/B;IAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CACnD,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,wBAAwB,CACxB,CAAA;IAExC,IAAI,CAAC,iBAAiB,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;KAC/B;IAED,OAAO,iBAAiB,CAAA;AAC1B,CAAC"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin, PluginPreRequest, Session } from '@botonic/core';
|
|
1
|
+
import { Plugin, PluginPreRequest, ResolvedPlugins, Session } from '@botonic/core';
|
|
2
2
|
import { FlowBuilderApi } from './api';
|
|
3
3
|
import { FlowContent } from './content-fields';
|
|
4
4
|
import { HtNodeWithContent } from './content-fields/hubtype-fields';
|
|
@@ -10,24 +10,23 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
10
10
|
private functions;
|
|
11
11
|
private currentRequest;
|
|
12
12
|
getAccessToken: (session: Session) => string;
|
|
13
|
-
getLocale: (session: Session) => string;
|
|
14
13
|
trackEvent?: TrackEventFunction;
|
|
15
14
|
getKnowledgeBaseResponse?: KnowledgeBaseFunction;
|
|
16
15
|
smartIntentsConfig: SmartIntentsInferenceConfig;
|
|
17
16
|
inShadowing: InShadowingConfig;
|
|
18
17
|
jsonVersion: FlowBuilderJSONVersion;
|
|
19
18
|
apiUrl: string;
|
|
20
|
-
constructor(options: BotonicPluginFlowBuilderOptions);
|
|
19
|
+
constructor(options: BotonicPluginFlowBuilderOptions<ResolvedPlugins, any>);
|
|
21
20
|
resolveFlowUrl(request: PluginPreRequest): string;
|
|
22
21
|
pre(request: PluginPreRequest): Promise<void>;
|
|
23
22
|
private updateRequestBeforeRoutes;
|
|
24
|
-
private
|
|
23
|
+
private removeSourceSuffix;
|
|
25
24
|
post(request: PluginPreRequest): void;
|
|
26
|
-
getContentsByContentID(contentID: string,
|
|
25
|
+
getContentsByContentID(contentID: string, prevContents?: FlowContent[]): Promise<FlowContent[]>;
|
|
27
26
|
getUUIDByContentID(contentID: string): string;
|
|
28
27
|
private getContentsById;
|
|
29
|
-
getStartContents(
|
|
30
|
-
getContentsByNode(node: HtNodeWithContent,
|
|
28
|
+
getStartContents(): Promise<FlowContent[]>;
|
|
29
|
+
getContentsByNode(node: HtNodeWithContent, prevContents?: FlowContent[]): Promise<FlowContent[]>;
|
|
31
30
|
private getFlowContent;
|
|
32
31
|
private callFunction;
|
|
33
32
|
private getArgumentsByLocale;
|
package/lib/esm/index.js
CHANGED
|
@@ -15,8 +15,7 @@ export default class BotonicPluginFlowBuilder {
|
|
|
15
15
|
this.apiUrl = options.apiUrl || FLOW_BUILDER_API_URL_PROD;
|
|
16
16
|
this.jsonVersion = options.jsonVersion || FlowBuilderJSONVersion.LATEST;
|
|
17
17
|
this.flow = options.flow;
|
|
18
|
-
this.
|
|
19
|
-
this.getAccessToken = resolveGetAccessToken(options);
|
|
18
|
+
this.getAccessToken = resolveGetAccessToken(options.getAccessToken);
|
|
20
19
|
this.trackEvent = options.trackEvent;
|
|
21
20
|
this.getKnowledgeBaseResponse = options.getKnowledgeBaseResponse;
|
|
22
21
|
this.smartIntentsConfig = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.smartIntentsConfig), { useLatest: this.jsonVersion === FlowBuilderJSONVersion.LATEST });
|
|
@@ -46,8 +45,7 @@ export default class BotonicPluginFlowBuilder {
|
|
|
46
45
|
});
|
|
47
46
|
const checkUserTextInput = inputHasTextData(request.input) && !request.input.payload;
|
|
48
47
|
if (checkUserTextInput) {
|
|
49
|
-
const
|
|
50
|
-
const resolvedLocale = this.cmsApi.getResolvedLocale(locale);
|
|
48
|
+
const resolvedLocale = this.cmsApi.getResolvedLocale();
|
|
51
49
|
const nodeByUserInput = yield getNodeByUserInput(this.cmsApi, resolvedLocale, request, this.smartIntentsConfig);
|
|
52
50
|
request.input.payload = this.cmsApi.getPayload(nodeByUserInput === null || nodeByUserInput === void 0 ? void 0 : nodeByUserInput.target);
|
|
53
51
|
}
|
|
@@ -56,7 +54,7 @@ export default class BotonicPluginFlowBuilder {
|
|
|
56
54
|
}
|
|
57
55
|
updateRequestBeforeRoutes(request) {
|
|
58
56
|
if (request.input.payload) {
|
|
59
|
-
request.input.payload = this.
|
|
57
|
+
request.input.payload = this.removeSourceSuffix(request.input.payload);
|
|
60
58
|
if (this.cmsApi.isBotAction(request.input.payload)) {
|
|
61
59
|
const cmsBotAction = this.cmsApi.getNodeById(request.input.payload);
|
|
62
60
|
request.input.payload =
|
|
@@ -64,43 +62,42 @@ export default class BotonicPluginFlowBuilder {
|
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
|
-
|
|
65
|
+
removeSourceSuffix(payload) {
|
|
68
66
|
return payload.split(SOURCE_INFO_SEPARATOR)[0];
|
|
69
67
|
}
|
|
70
68
|
post(request) {
|
|
71
69
|
request.input.nluResolution = undefined;
|
|
72
70
|
}
|
|
73
|
-
getContentsByContentID(contentID,
|
|
71
|
+
getContentsByContentID(contentID, prevContents) {
|
|
74
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
73
|
const node = this.cmsApi.getNodeByContentID(contentID);
|
|
76
|
-
return yield this.getContentsByNode(node,
|
|
74
|
+
return yield this.getContentsByNode(node, prevContents);
|
|
77
75
|
});
|
|
78
76
|
}
|
|
79
77
|
getUUIDByContentID(contentID) {
|
|
80
78
|
const node = this.cmsApi.getNodeByContentID(contentID);
|
|
81
79
|
return node.id;
|
|
82
80
|
}
|
|
83
|
-
getContentsById(id,
|
|
81
|
+
getContentsById(id, prevContents) {
|
|
84
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
83
|
const node = this.cmsApi.getNodeById(id);
|
|
86
|
-
return yield this.getContentsByNode(node,
|
|
84
|
+
return yield this.getContentsByNode(node, prevContents);
|
|
87
85
|
});
|
|
88
86
|
}
|
|
89
|
-
getStartContents(
|
|
87
|
+
getStartContents() {
|
|
90
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
const resolvedLocale = this.cmsApi.getResolvedLocale(locale);
|
|
92
89
|
const startNode = this.cmsApi.getStartNode();
|
|
93
90
|
this.currentRequest.session.flow_thread_id = uuidv7();
|
|
94
|
-
return yield this.getContentsByNode(startNode
|
|
91
|
+
return yield this.getContentsByNode(startNode);
|
|
95
92
|
});
|
|
96
93
|
}
|
|
97
|
-
getContentsByNode(node,
|
|
94
|
+
getContentsByNode(node, prevContents) {
|
|
98
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
96
|
const contents = prevContents || [];
|
|
100
|
-
const resolvedLocale = this.cmsApi.getResolvedLocale(
|
|
97
|
+
const resolvedLocale = this.cmsApi.getResolvedLocale();
|
|
101
98
|
if (node.type === HtNodeWithContentType.FUNCTION) {
|
|
102
99
|
const targetId = yield this.callFunction(node, resolvedLocale);
|
|
103
|
-
return this.getContentsById(targetId,
|
|
100
|
+
return this.getContentsById(targetId, contents);
|
|
104
101
|
}
|
|
105
102
|
const content = this.getFlowContent(node, resolvedLocale);
|
|
106
103
|
if (content) {
|
|
@@ -112,7 +109,7 @@ export default class BotonicPluginFlowBuilder {
|
|
|
112
109
|
}
|
|
113
110
|
// TODO: prevent infinite recursive calls
|
|
114
111
|
if (node.follow_up) {
|
|
115
|
-
return this.getContentsById(node.follow_up.id,
|
|
112
|
+
return this.getContentsById(node.follow_up.id, contents);
|
|
116
113
|
}
|
|
117
114
|
return contents;
|
|
118
115
|
});
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EACL,yBAAyB,EACzB,SAAS,EACT,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,aAAa,EACb,YAAY,EAEZ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAQL,qBAAqB,GACtB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAEL,sBAAsB,GAKvB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MA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AAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAA;QACrE,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,WAAW,CAAC,MAAc;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;CACF;AAED,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAEL,sBAAsB,GAEvB,MAAM,SAAS,CAAA;AAChB,cAAc,WAAW,CAAA"}
|
package/lib/esm/tracking.d.ts
CHANGED
package/lib/esm/tracking.js
CHANGED
|
@@ -6,7 +6,6 @@ export var EventAction;
|
|
|
6
6
|
(function (EventAction) {
|
|
7
7
|
EventAction["FlowNode"] = "flow_node";
|
|
8
8
|
EventAction["Keyword"] = "nlu_keyword";
|
|
9
|
-
EventAction["Intent"] = "nlu_intent";
|
|
10
9
|
EventAction["IntentSmart"] = "nlu_intent_smart";
|
|
11
10
|
EventAction["Knowledgebase"] = "knowledgebase";
|
|
12
11
|
EventAction["Fallback"] = "fallback";
|
package/lib/esm/tracking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/tracking.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAGnC,OAAO,EAEL,qBAAqB,GACtB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/tracking.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAGnC,OAAO,EAEL,qBAAqB,GACtB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,oBAAoB,E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,EAAE,WAAW,CAAC,EAAE;oBAClB,YAAY,EAAE,MAAA,WAAW,CAAC,aAAa,mCAAI,KAAK;iBACjD,CAAC,CAAA;gBACF,MAAM,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;aAC3D;SACF;;CACF;AAED,SAAS,mBAAmB,CAC1B,OAAsB,EACtB,WAMC;;IAED,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,OAAO,CAAC,cAAc,mCAAI,MAAM,EAAE,CAAA;IAC/D,OAAO,CAAC,OAAO,CAAC,cAAc,GAAG,YAAY,CAAA;IAE7C,OAAO;QACL,YAAY;QACZ,MAAM,EAAE,WAAW,CAAC,MAAM;QAC1B,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,UAAU,EAAE,WAAW,CAAC,EAAE;QAC1B,iBAAiB,EAAE,WAAW,CAAC,IAAI;QACnC,oBAAoB,EAAE,WAAW,CAAC,YAAY;KAC/C,CAAA;AACH,CAAC"}
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import { PluginPreRequest,
|
|
2
|
-
import { ActionRequest } from '@botonic/react';
|
|
1
|
+
import { BotContext, PluginPreRequest, ResolvedPlugins } from '@botonic/core';
|
|
3
2
|
import { HtFlowBuilderData } from './content-fields/hubtype-fields';
|
|
4
3
|
export interface InShadowingConfig {
|
|
5
4
|
allowKeywords: boolean;
|
|
6
5
|
allowSmartIntents: boolean;
|
|
7
6
|
allowKnowledgeBases: boolean;
|
|
8
7
|
}
|
|
9
|
-
export interface BotonicPluginFlowBuilderOptions {
|
|
8
|
+
export interface BotonicPluginFlowBuilderOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> {
|
|
10
9
|
apiUrl?: string;
|
|
11
10
|
jsonVersion?: FlowBuilderJSONVersion;
|
|
12
11
|
flow?: HtFlowBuilderData;
|
|
13
12
|
customFunctions?: Record<any, any>;
|
|
14
|
-
getLocale: (session: Session) => string;
|
|
15
13
|
getAccessToken: () => string;
|
|
16
|
-
trackEvent?: TrackEventFunction
|
|
17
|
-
getKnowledgeBaseResponse?: KnowledgeBaseFunction
|
|
14
|
+
trackEvent?: TrackEventFunction<TPlugins, TExtraData>;
|
|
15
|
+
getKnowledgeBaseResponse?: KnowledgeBaseFunction<TPlugins, TExtraData>;
|
|
18
16
|
smartIntentsConfig?: {
|
|
19
17
|
numSmartIntentsToUse: number;
|
|
20
18
|
};
|
|
21
19
|
inShadowing?: Partial<InShadowingConfig>;
|
|
22
20
|
}
|
|
23
|
-
export type TrackEventFunction = (request:
|
|
24
|
-
export type KnowledgeBaseFunction = (request:
|
|
21
|
+
export type TrackEventFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, eventAction: string, args?: Record<string, any>) => Promise<void>;
|
|
22
|
+
export type KnowledgeBaseFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, sources: string[], instructions: string, messageId: string, memoryLength: number) => Promise<KnowledgeBaseResponse>;
|
|
25
23
|
export interface FlowBuilderApiOptions {
|
|
26
24
|
url: string;
|
|
27
25
|
flowUrl: string;
|
package/lib/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AA0DA,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAC7B,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;AACnB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ActionRequest } from '@botonic/react';
|
|
2
2
|
import { FlowBuilderApi } from '../api';
|
|
3
|
-
import {
|
|
3
|
+
import { HtKeywordNode, HtSmartIntentNode } from '../content-fields/hubtype-fields';
|
|
4
4
|
import { SmartIntentsInferenceConfig } from './smart-intent';
|
|
5
|
-
export declare function getNodeByUserInput(cmsApi: FlowBuilderApi, locale: string, request: ActionRequest, smartIntentsConfig: SmartIntentsInferenceConfig): Promise<HtSmartIntentNode |
|
|
5
|
+
export declare function getNodeByUserInput(cmsApi: FlowBuilderApi, locale: string, request: ActionRequest, smartIntentsConfig: SmartIntentsInferenceConfig): Promise<HtSmartIntentNode | HtKeywordNode | undefined>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { inputHasTextData, isKeywordsAllowed, isSmartIntentsAllowed, } from '../utils';
|
|
3
|
-
import { getIntentNodeByInput } from './intent';
|
|
4
3
|
import { KeywordMatcher } from './keyword';
|
|
5
4
|
import { SmartIntentsApi } from './smart-intent';
|
|
6
5
|
export function getNodeByUserInput(cmsApi, locale, request, smartIntentsConfig) {
|
|
@@ -24,13 +23,6 @@ export function getNodeByUserInput(cmsApi, locale, request, smartIntentsConfig)
|
|
|
24
23
|
return smartIntentNode;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
|
-
// TODO: Remove this because frontend no allow create intents babel
|
|
28
|
-
if (isSmartIntentsAllowed(request)) {
|
|
29
|
-
const intentNode = yield getIntentNodeByInput(cmsApi, locale, request);
|
|
30
|
-
if (intentNode) {
|
|
31
|
-
return intentNode;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
26
|
}
|
|
35
27
|
return undefined;
|
|
36
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/user-input/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/user-input/index.ts"],"names":[],"mappings":";AAOA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,eAAe,EAA+B,MAAM,gBAAgB,CAAA;AAE7E,MAAM,UAAgB,kBAAkB,CACtC,MAAsB,EACtB,MAAc,EACd,OAAsB,EACtB,kBAA+C;;QAE/C,IAAI,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACnC,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAAE;gBAC9B,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC;oBACxC,MAAM;oBACN,MAAM;oBACN,OAAO;iBACR,CAAC,CAAA;gBACF,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,cAAc,CACrD,OAAO,CAAC,KAAK,CAAC,IAAK,CACpB,CAAA;gBACD,IAAI,WAAW,EAAE;oBACf,OAAO,WAAW,CAAA;iBACnB;aACF;YAED,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE;gBAClC,MAAM,eAAe,GAAG,IAAI,eAAe,CACzC,MAAM,EACN,OAAO,EACP,kBAAkB,CACnB,CAAA;gBACD,MAAM,eAAe,GAAG,MAAM,eAAe,CAAC,cAAc,EAAE,CAAA;gBAC9D,IAAI,eAAe,EAAE;oBACnB,OAAO,eAAe,CAAA;iBACvB;aACF;SACF;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;CAAA"}
|
package/lib/esm/utils.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Input, Session } from '@botonic/core';
|
|
2
2
|
import { ActionRequest } from '@botonic/react';
|
|
3
|
-
|
|
4
|
-
export declare function resolveGetAccessToken(options: BotonicPluginFlowBuilderOptions): (session: Session) => string;
|
|
3
|
+
export declare function resolveGetAccessToken(getAccessToken: (session: Session) => string): (session: Session) => string;
|
|
5
4
|
export declare function getValueFromKeyPath(request: ActionRequest, keyPath: string): any;
|
|
6
5
|
export declare function inputHasTextData(input: Input): boolean;
|
|
7
6
|
export declare function isKeywordsAllowed(request: ActionRequest): boolean;
|
package/lib/esm/utils.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { INPUT } from '@botonic/core';
|
|
2
2
|
import { getFlowBuilderPlugin } from './helpers';
|
|
3
|
-
import { ProcessEnvNodeEnvs
|
|
3
|
+
import { ProcessEnvNodeEnvs } from './types';
|
|
4
4
|
function getAccessTokenFromSession(session) {
|
|
5
5
|
if (!session._access_token) {
|
|
6
6
|
throw new Error('No access token found in session');
|
|
7
7
|
}
|
|
8
8
|
return session._access_token;
|
|
9
9
|
}
|
|
10
|
-
export function resolveGetAccessToken(
|
|
10
|
+
export function resolveGetAccessToken(getAccessToken) {
|
|
11
11
|
switch (process.env.NODE_ENV) {
|
|
12
12
|
case ProcessEnvNodeEnvs.PRODUCTION:
|
|
13
13
|
return getAccessTokenFromSession;
|
|
14
14
|
case ProcessEnvNodeEnvs.DEVELOPMENT:
|
|
15
|
-
return
|
|
15
|
+
return getAccessToken;
|
|
16
16
|
default:
|
|
17
17
|
throw new Error('No method defined for getting access token');
|
|
18
18
|
}
|
package/lib/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,eAAe,CAAA;AAGrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,eAAe,CAAA;AAGrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAqB,kBAAkB,EAAE,M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CAAC,KAAY;IAC3C,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAA;AAC9D,CAAC;AAED,SAAS,YAAY,CACnB,OAAsB,EACtB,OAAgC;IAEhC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACrD,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,OAAO,CAAC,SAAS,IAAI,CAAC,SAAS,IAAI,iBAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;AAC5E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAsB;IACtD,OAAO,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;AAC/C,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAsB;IAC1D,OAAO,YAAY,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAsB;IAC5D,OAAO,YAAY,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAA;AACrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-flow-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0-alpha.1",
|
|
4
4
|
"main": "./lib/cjs/index.js",
|
|
5
5
|
"module": "./lib/esm/index.js",
|
|
6
6
|
"description": "Use Flow Builder to show your contents",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.ts*'"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@botonic/react": "
|
|
17
|
+
"@botonic/react": "0.35.0-alpha.1",
|
|
18
18
|
"axios": "^1.7.9",
|
|
19
19
|
"uuid": "^10.0.0"
|
|
20
20
|
},
|
package/src/action/fallback.ts
CHANGED
|
@@ -9,13 +9,10 @@ export async function getContentsByFallback({
|
|
|
9
9
|
cmsApi,
|
|
10
10
|
flowBuilderPlugin,
|
|
11
11
|
request,
|
|
12
|
-
resolvedLocale,
|
|
13
12
|
}: FlowBuilderContext): Promise<FlowContent[]> {
|
|
14
13
|
const fallbackNode = await getFallbackNode(cmsApi, request)
|
|
15
|
-
const fallbackContents =
|
|
16
|
-
fallbackNode
|
|
17
|
-
resolvedLocale
|
|
18
|
-
)
|
|
14
|
+
const fallbackContents =
|
|
15
|
+
await flowBuilderPlugin.getContentsByNode(fallbackNode)
|
|
19
16
|
|
|
20
17
|
return fallbackContents
|
|
21
18
|
}
|
|
@@ -10,9 +10,8 @@ import { getContentsByPayload } from './payload'
|
|
|
10
10
|
export async function getContentsByFirstInteraction(
|
|
11
11
|
context: FlowBuilderContext
|
|
12
12
|
): Promise<FlowContent[]> {
|
|
13
|
-
const { flowBuilderPlugin, request
|
|
14
|
-
const firstInteractionContents =
|
|
15
|
-
await flowBuilderPlugin.getStartContents(resolvedLocale)
|
|
13
|
+
const { flowBuilderPlugin, request } = context
|
|
14
|
+
const firstInteractionContents = await flowBuilderPlugin.getStartContents()
|
|
16
15
|
|
|
17
16
|
// If the first interaction has a FlowBotAction, it should be the last content
|
|
18
17
|
// and avoid to render the match with keywords,intents or knowledge base
|
|
@@ -54,7 +53,6 @@ async function getContentsByUserInput({
|
|
|
54
53
|
|
|
55
54
|
const hasRepeatedContent = await checkRepeatedContents(
|
|
56
55
|
flowBuilderPlugin,
|
|
57
|
-
resolvedLocale,
|
|
58
56
|
contentsByKeywordsOrIntents
|
|
59
57
|
)
|
|
60
58
|
|
|
@@ -85,10 +83,9 @@ function getConversationStartId(cmsApi: FlowBuilderApi) {
|
|
|
85
83
|
|
|
86
84
|
async function checkRepeatedContents(
|
|
87
85
|
flowBuilderPlugin: BotonicPluginFlowBuilder,
|
|
88
|
-
resolvedLocale: string,
|
|
89
86
|
contentsByKeywordsOrIntents: FlowContent[]
|
|
90
87
|
) {
|
|
91
|
-
const startContents = await flowBuilderPlugin.getStartContents(
|
|
88
|
+
const startContents = await flowBuilderPlugin.getStartContents()
|
|
92
89
|
const contentIds = new Set(
|
|
93
90
|
contentsByKeywordsOrIntents.map(content => content.id)
|
|
94
91
|
)
|
package/src/action/index.tsx
CHANGED
|
@@ -83,7 +83,7 @@ async function getContents(
|
|
|
83
83
|
if (request.session.is_first_interaction) {
|
|
84
84
|
return await getContentsByFirstInteraction(context)
|
|
85
85
|
}
|
|
86
|
-
// TODO: Add needed logic when we can define contents for
|
|
86
|
+
// TODO: Add needed logic when we can define contents for multi locale queue position message
|
|
87
87
|
if (request.input.type === INPUT.EVENT_QUEUE_POSITION_CHANGED) {
|
|
88
88
|
return []
|
|
89
89
|
}
|
|
@@ -121,8 +121,7 @@ function getContext(
|
|
|
121
121
|
): FlowBuilderContext {
|
|
122
122
|
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
|
|
123
123
|
const cmsApi = flowBuilderPlugin.cmsApi
|
|
124
|
-
const
|
|
125
|
-
const resolvedLocale = flowBuilderPlugin.cmsApi.getResolvedLocale(locale)
|
|
124
|
+
const resolvedLocale = flowBuilderPlugin.cmsApi.getResolvedLocale()
|
|
126
125
|
return {
|
|
127
126
|
cmsApi,
|
|
128
127
|
flowBuilderPlugin,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BotContext, ResolvedPlugins } from '@botonic/core'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
DISABLED_MEMORY_LENGTH,
|
|
@@ -15,7 +15,6 @@ export async function getContentsByKnowledgeBase({
|
|
|
15
15
|
cmsApi,
|
|
16
16
|
flowBuilderPlugin,
|
|
17
17
|
request,
|
|
18
|
-
resolvedLocale,
|
|
19
18
|
}: FlowBuilderContext): Promise<FlowContent[]> {
|
|
20
19
|
if (isKnowledgeBasesAllowed(request)) {
|
|
21
20
|
const startNodeKnowledgeBaseFlow = cmsApi.getStartNodeKnowledgeBaseFlow()
|
|
@@ -25,8 +24,7 @@ export async function getContentsByKnowledgeBase({
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
const contents = await flowBuilderPlugin.getContentsByNode(
|
|
28
|
-
startNodeKnowledgeBaseFlow
|
|
29
|
-
resolvedLocale
|
|
27
|
+
startNodeKnowledgeBaseFlow
|
|
30
28
|
)
|
|
31
29
|
|
|
32
30
|
const knowledgeBaseContent = contents.find(
|
|
@@ -65,9 +63,11 @@ export async function getContentsByKnowledgeBase({
|
|
|
65
63
|
return []
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
async function getContentsWithKnowledgeResponse
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
async function getContentsWithKnowledgeResponse<
|
|
67
|
+
T extends ResolvedPlugins = ResolvedPlugins,
|
|
68
|
+
>(
|
|
69
|
+
getKnowledgeBaseResponse: KnowledgeBaseFunction<T>,
|
|
70
|
+
request: BotContext<T>,
|
|
71
71
|
contents: FlowContent[],
|
|
72
72
|
knowledgeBaseContent: FlowKnowledgeBase,
|
|
73
73
|
flowId: string
|
|
@@ -119,7 +119,7 @@ function updateContentsWithResponse(
|
|
|
119
119
|
|
|
120
120
|
async function trackKnowledgeBase(
|
|
121
121
|
response: KnowledgeBaseResponse,
|
|
122
|
-
request:
|
|
122
|
+
request: BotContext,
|
|
123
123
|
knowledgeBaseContent: FlowKnowledgeBase,
|
|
124
124
|
flowId: string
|
|
125
125
|
) {
|
package/src/action/payload.ts
CHANGED
|
@@ -6,7 +6,6 @@ export async function getContentsByPayload({
|
|
|
6
6
|
cmsApi,
|
|
7
7
|
flowBuilderPlugin,
|
|
8
8
|
request,
|
|
9
|
-
resolvedLocale,
|
|
10
9
|
contentID,
|
|
11
10
|
}: FlowBuilderContext): Promise<FlowContent[]> {
|
|
12
11
|
const id = contentID
|
|
@@ -15,7 +14,7 @@ export async function getContentsByPayload({
|
|
|
15
14
|
const targetNode = id ? cmsApi.getNodeById<HtNodeWithContent>(id) : undefined
|
|
16
15
|
|
|
17
16
|
if (targetNode) {
|
|
18
|
-
return await flowBuilderPlugin.getContentsByNode(targetNode
|
|
17
|
+
return await flowBuilderPlugin.getContentsByNode(targetNode)
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
return []
|