@botonic/plugin-flow-builder 0.21.0-alpha.4 → 0.21.0-alpha.6
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.d.ts +3 -5
- package/lib/cjs/action.js +23 -16
- package/lib/cjs/action.js.map +1 -1
- package/lib/cjs/content-fields/content-fields-base.d.ts +7 -0
- package/lib/cjs/content-fields/{content-base.js → content-fields-base.js} +7 -2
- package/lib/cjs/content-fields/content-fields-base.js.map +1 -0
- package/lib/cjs/content-fields/{button.d.ts → flow-button.d.ts} +3 -3
- package/lib/cjs/content-fields/{button.js → flow-button.js} +5 -5
- package/lib/cjs/content-fields/flow-button.js.map +1 -0
- package/lib/cjs/content-fields/flow-carousel.d.ts +10 -0
- package/lib/cjs/content-fields/{carousel.js → flow-carousel.js} +10 -10
- package/lib/cjs/content-fields/flow-carousel.js.map +1 -0
- package/lib/cjs/content-fields/flow-element.d.ts +11 -0
- package/lib/cjs/content-fields/{element.js → flow-element.js} +6 -7
- package/lib/cjs/content-fields/flow-element.js.map +1 -0
- package/lib/cjs/content-fields/flow-image.d.ts +9 -0
- package/lib/cjs/content-fields/{image.js → flow-image.js} +4 -5
- package/lib/cjs/content-fields/flow-image.js.map +1 -0
- package/lib/cjs/content-fields/flow-text.d.ts +12 -0
- package/lib/cjs/content-fields/{text.js → flow-text.js} +8 -8
- package/lib/cjs/content-fields/flow-text.js.map +1 -0
- package/lib/cjs/content-fields/index.d.ts +7 -0
- package/lib/cjs/content-fields/index.js +16 -0
- package/lib/cjs/content-fields/index.js.map +1 -0
- package/lib/cjs/content-fields/types.d.ts +4 -0
- package/lib/cjs/content-fields/types.js +3 -0
- package/lib/cjs/content-fields/types.js.map +1 -0
- package/lib/cjs/flow-builder-models.d.ts +174 -0
- package/lib/cjs/flow-builder-models.js +22 -0
- package/lib/cjs/flow-builder-models.js.map +1 -0
- package/lib/cjs/functions/conditional-queue-status.d.ts +2 -2
- package/lib/cjs/functions/conditional-queue-status.js +15 -2
- package/lib/cjs/functions/conditional-queue-status.js.map +1 -1
- package/lib/cjs/functions/index.d.ts +1 -1
- package/lib/cjs/functions/index.js +3 -1
- package/lib/cjs/functions/index.js.map +1 -1
- package/lib/cjs/handoff.d.ts +1 -1
- package/lib/cjs/handoff.js +11 -15
- package/lib/cjs/handoff.js.map +1 -1
- package/lib/cjs/index.d.ts +19 -14
- package/lib/cjs/index.js +40 -24
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils.d.ts +1 -2
- package/lib/cjs/utils.js +6 -6
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/action.d.ts +3 -5
- package/lib/esm/action.js +22 -15
- package/lib/esm/action.js.map +1 -1
- package/lib/esm/content-fields/content-fields-base.d.ts +7 -0
- package/lib/esm/content-fields/content-fields-base.js +16 -0
- package/lib/esm/content-fields/content-fields-base.js.map +1 -0
- package/lib/esm/content-fields/{button.d.ts → flow-button.d.ts} +3 -3
- package/lib/esm/content-fields/{button.js → flow-button.js} +4 -4
- package/lib/esm/content-fields/flow-button.js.map +1 -0
- package/lib/esm/content-fields/flow-carousel.d.ts +10 -0
- package/lib/esm/content-fields/{carousel.js → flow-carousel.js} +9 -9
- package/lib/esm/content-fields/flow-carousel.js.map +1 -0
- package/lib/esm/content-fields/flow-element.d.ts +11 -0
- package/lib/esm/content-fields/{element.js → flow-element.js} +4 -5
- package/lib/esm/content-fields/flow-element.js.map +1 -0
- package/lib/esm/content-fields/flow-image.d.ts +9 -0
- package/lib/esm/content-fields/{image.js → flow-image.js} +3 -4
- package/lib/esm/content-fields/flow-image.js.map +1 -0
- package/lib/esm/content-fields/flow-text.d.ts +12 -0
- package/lib/esm/content-fields/{text.js → flow-text.js} +4 -4
- package/lib/esm/content-fields/flow-text.js.map +1 -0
- package/lib/esm/content-fields/index.d.ts +7 -0
- package/lib/esm/content-fields/index.js +7 -0
- package/lib/esm/content-fields/index.js.map +1 -0
- package/lib/esm/content-fields/types.d.ts +4 -0
- package/lib/esm/content-fields/types.js +2 -0
- package/lib/esm/content-fields/types.js.map +1 -0
- package/lib/esm/flow-builder-models.d.ts +174 -0
- package/lib/esm/flow-builder-models.js +19 -0
- package/lib/esm/flow-builder-models.js.map +1 -0
- package/lib/esm/functions/conditional-queue-status.d.ts +2 -2
- package/lib/esm/functions/conditional-queue-status.js +15 -2
- package/lib/esm/functions/conditional-queue-status.js.map +1 -1
- package/lib/esm/functions/index.d.ts +1 -1
- package/lib/esm/functions/index.js +3 -1
- package/lib/esm/functions/index.js.map +1 -1
- package/lib/esm/handoff.d.ts +1 -1
- package/lib/esm/handoff.js +12 -16
- package/lib/esm/handoff.js.map +1 -1
- package/lib/esm/index.d.ts +19 -14
- package/lib/esm/index.js +35 -21
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/utils.d.ts +1 -2
- package/lib/esm/utils.js +4 -4
- package/lib/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/action.tsx +26 -20
- package/src/content-fields/content-fields-base.ts +15 -0
- package/src/content-fields/{button.tsx → flow-button.tsx} +5 -5
- package/src/content-fields/flow-carousel.tsx +39 -0
- package/src/content-fields/{element.tsx → flow-element.tsx} +8 -6
- package/src/content-fields/{image.tsx → flow-image.tsx} +5 -6
- package/src/content-fields/{text.tsx → flow-text.tsx} +5 -5
- package/src/content-fields/index.ts +7 -0
- package/src/content-fields/types.ts +5 -0
- package/src/flow-builder-models.ts +220 -0
- package/src/functions/conditional-queue-status.ts +24 -2
- package/src/functions/index.ts +3 -1
- package/src/handoff.ts +18 -17
- package/src/index.ts +75 -50
- package/src/utils.ts +10 -5
- package/lib/cjs/content-fields/button.js.map +0 -1
- package/lib/cjs/content-fields/carousel.d.ts +0 -10
- package/lib/cjs/content-fields/carousel.js.map +0 -1
- package/lib/cjs/content-fields/content-base.d.ts +0 -10
- package/lib/cjs/content-fields/content-base.js.map +0 -1
- package/lib/cjs/content-fields/element.d.ts +0 -11
- package/lib/cjs/content-fields/element.js.map +0 -1
- package/lib/cjs/content-fields/image.d.ts +0 -9
- package/lib/cjs/content-fields/image.js.map +0 -1
- package/lib/cjs/content-fields/text.d.ts +0 -12
- package/lib/cjs/content-fields/text.js.map +0 -1
- package/lib/cjs/hubtype-models.d.ts +0 -152
- package/lib/cjs/hubtype-models.js +0 -50
- package/lib/cjs/hubtype-models.js.map +0 -1
- package/lib/esm/content-fields/button.js.map +0 -1
- package/lib/esm/content-fields/carousel.d.ts +0 -10
- package/lib/esm/content-fields/carousel.js.map +0 -1
- package/lib/esm/content-fields/content-base.d.ts +0 -10
- package/lib/esm/content-fields/content-base.js +0 -11
- package/lib/esm/content-fields/content-base.js.map +0 -1
- package/lib/esm/content-fields/element.d.ts +0 -11
- package/lib/esm/content-fields/element.js.map +0 -1
- package/lib/esm/content-fields/image.d.ts +0 -9
- package/lib/esm/content-fields/image.js.map +0 -1
- package/lib/esm/content-fields/text.d.ts +0 -12
- package/lib/esm/content-fields/text.js.map +0 -1
- package/lib/esm/hubtype-models.d.ts +0 -152
- package/lib/esm/hubtype-models.js +0 -47
- package/lib/esm/hubtype-models.js.map +0 -1
- package/src/content-fields/carousel.tsx +0 -39
- package/src/content-fields/content-base.ts +0 -15
- package/src/hubtype-models.ts +0 -190
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-element.js","sourceRoot":"","sources":["../../../src/content-fields/flow-element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IAAlD;;QACS,UAAK,GAAG,EAAE,CAAA;QACV,aAAQ,GAAG,EAAE,CAAA;QAEb,UAAK,GAAG,EAAE,CAAA;QACV,WAAM,GAAG,KAAK,CAAA;IAgBvB,CAAC;IAdC,MAAM,CAAC,cAAc,CACnB,SAA8B,EAC9B,MAAc;QAEd,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAChD,UAAU,CAAC,KAAK,GAAG,WAAW,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;QACvE,UAAU,CAAC,QAAQ,GAAG,WAAW,CAAC,eAAe,CAC/C,MAAM,EACN,SAAS,CAAC,QAAQ,CACnB,CAAA;QACD,UAAU,CAAC,KAAK,GAAG,WAAW,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;QACxE,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACxE,OAAO,UAAU,CAAA;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ImageNode } from '../flow-builder-models';
|
|
3
|
+
import { ContentFieldsBase } from './content-fields-base';
|
|
4
|
+
export declare class FlowImage extends ContentFieldsBase {
|
|
5
|
+
src: string;
|
|
6
|
+
code: string;
|
|
7
|
+
static fromHubtypeCMS(component: ImageNode, locale: string): FlowImage;
|
|
8
|
+
toBotonic(index: number): JSX.Element;
|
|
9
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Image } from '@botonic/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { ContentFieldsBase } from './content-base';
|
|
3
|
+
import { ContentFieldsBase } from './content-fields-base';
|
|
5
4
|
export class FlowImage extends ContentFieldsBase {
|
|
6
5
|
constructor() {
|
|
7
6
|
super(...arguments);
|
|
@@ -11,11 +10,11 @@ export class FlowImage extends ContentFieldsBase {
|
|
|
11
10
|
static fromHubtypeCMS(component, locale) {
|
|
12
11
|
const newImage = new FlowImage(component.id);
|
|
13
12
|
newImage.code = component.code;
|
|
14
|
-
newImage.src = getImageByLocale(locale, component.content.image);
|
|
13
|
+
newImage.src = this.getImageByLocale(locale, component.content.image);
|
|
15
14
|
return newImage;
|
|
16
15
|
}
|
|
17
16
|
toBotonic(index) {
|
|
18
17
|
return React.createElement(Image, { src: this.src, key: index });
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
//# sourceMappingURL=image.js.map
|
|
20
|
+
//# sourceMappingURL=flow-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-image.js","sourceRoot":"","sources":["../../../src/content-fields/flow-image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEzD,MAAM,OAAO,SAAU,SAAQ,iBAAiB;IAAhD;;QACS,QAAG,GAAG,EAAE,CAAA;QACR,SAAI,GAAG,EAAE,CAAA;IAYlB,CAAC;IAVC,MAAM,CAAC,cAAc,CAAC,SAAoB,EAAE,MAAc;QACxD,MAAM,QAAQ,GAAG,IAAI,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC5C,QAAQ,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QAC9B,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACrE,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,SAAS,CAAC,KAAa;QACrB,OAAO,oBAAC,KAAK,IAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,GAAI,CAAA;IAC7C,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonStyle, TextNode } from '../flow-builder-models';
|
|
3
|
+
import { ContentFieldsBase } from './content-fields-base';
|
|
4
|
+
import { FlowButton } from './flow-button';
|
|
5
|
+
export declare class FlowText extends ContentFieldsBase {
|
|
6
|
+
text: string;
|
|
7
|
+
code: string;
|
|
8
|
+
buttons: FlowButton[];
|
|
9
|
+
buttonStyle: ButtonStyle;
|
|
10
|
+
static fromHubtypeCMS(component: TextNode, locale: string): FlowText;
|
|
11
|
+
toBotonic(index: number): JSX.Element;
|
|
12
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Text } from '@botonic/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { ButtonStyle } from '../
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { ButtonStyle } from '../flow-builder-models';
|
|
4
|
+
import { ContentFieldsBase } from './content-fields-base';
|
|
5
|
+
import { FlowButton } from './flow-button';
|
|
6
6
|
export class FlowText extends ContentFieldsBase {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
@@ -25,4 +25,4 @@ export class FlowText extends ContentFieldsBase {
|
|
|
25
25
|
this.buttons.map((button, index) => button.renderButton(index, this.buttonStyle))));
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
//# sourceMappingURL=text.js.map
|
|
28
|
+
//# sourceMappingURL=flow-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-text.js","sourceRoot":"","sources":["../../../src/content-fields/flow-text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,WAAW,EAAY,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,MAAM,OAAO,QAAS,SAAQ,iBAAiB;IAA/C;;QACS,SAAI,GAAG,EAAE,CAAA;QACT,SAAI,GAAG,EAAE,CAAA;QACT,YAAO,GAAiB,EAAE,CAAA;QAC1B,gBAAW,GAAG,WAAW,CAAC,MAAM,CAAA;IAuBzC,CAAC;IArBC,MAAM,CAAC,cAAc,CAAC,SAAmB,EAAE,MAAc;QACvD,MAAM,OAAO,GAAG,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC1C,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QAC7B,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,IAAI,WAAW,CAAC,MAAM,CAAA;QAC3E,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACvE,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CACvD,UAAU,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAC1C,CAAA;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,SAAS,CAAC,KAAa;QACrB,OAAO,CACL,oBAAC,IAAI,IAAC,GAAG,EAAE,KAAK;YACb,IAAI,CAAC,IAAI;YACT,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAClC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAC7C,CACI,CACR,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ContentFieldsBase } from './content-fields-base';
|
|
2
|
+
export { FlowButton } from './flow-button';
|
|
3
|
+
export { FlowCarousel } from './flow-carousel';
|
|
4
|
+
export { FlowElement } from './flow-element';
|
|
5
|
+
export { FlowImage } from './flow-image';
|
|
6
|
+
export { FlowText } from './flow-text';
|
|
7
|
+
export type { FlowContent } from './types';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ContentFieldsBase } from './content-fields-base';
|
|
2
|
+
export { FlowButton } from './flow-button';
|
|
3
|
+
export { FlowCarousel } from './flow-carousel';
|
|
4
|
+
export { FlowElement } from './flow-element';
|
|
5
|
+
export { FlowImage } from './flow-image';
|
|
6
|
+
export { FlowText } from './flow-text';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/content-fields/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export interface FlowBuilderData {
|
|
2
|
+
version: string;
|
|
3
|
+
name: string;
|
|
4
|
+
locales: string[];
|
|
5
|
+
start_node_id?: string;
|
|
6
|
+
ai_model_id?: string;
|
|
7
|
+
nodes: NodeComponent[];
|
|
8
|
+
}
|
|
9
|
+
export declare enum NodeType {
|
|
10
|
+
TEXT = "text",
|
|
11
|
+
IMAGE = "image",
|
|
12
|
+
CAROUSEL = "carousel",
|
|
13
|
+
HANDOFF = "handoff",
|
|
14
|
+
KEYWORD = "keyword",
|
|
15
|
+
INTENT = "intent",
|
|
16
|
+
START_UP = "start-up",
|
|
17
|
+
URL = "url",
|
|
18
|
+
PAYLOAD = "payload",
|
|
19
|
+
FUNCTION = "function"
|
|
20
|
+
}
|
|
21
|
+
export interface BaseNode {
|
|
22
|
+
id: string;
|
|
23
|
+
type: NodeType;
|
|
24
|
+
}
|
|
25
|
+
export interface Meta {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
}
|
|
29
|
+
export interface Node extends BaseNode {
|
|
30
|
+
code: string;
|
|
31
|
+
meta: Meta;
|
|
32
|
+
follow_up?: NodeLink;
|
|
33
|
+
target?: NodeLink;
|
|
34
|
+
}
|
|
35
|
+
export interface NodeLink {
|
|
36
|
+
id: string;
|
|
37
|
+
type: NodeType;
|
|
38
|
+
}
|
|
39
|
+
export interface TextLocale {
|
|
40
|
+
message: string;
|
|
41
|
+
locale: string;
|
|
42
|
+
}
|
|
43
|
+
export declare enum ButtonStyle {
|
|
44
|
+
BUTTON = "button",
|
|
45
|
+
QUICK_REPLY = "quick-reply"
|
|
46
|
+
}
|
|
47
|
+
export interface UrlLocale {
|
|
48
|
+
id: string;
|
|
49
|
+
locale: string;
|
|
50
|
+
}
|
|
51
|
+
export interface PayloadLocale {
|
|
52
|
+
id: string;
|
|
53
|
+
locale: string;
|
|
54
|
+
}
|
|
55
|
+
export interface Button {
|
|
56
|
+
id: string;
|
|
57
|
+
text: TextLocale[];
|
|
58
|
+
target?: NodeLink;
|
|
59
|
+
hidden: string;
|
|
60
|
+
url?: UrlLocale;
|
|
61
|
+
payload?: PayloadLocale;
|
|
62
|
+
}
|
|
63
|
+
export interface TextNodeContent {
|
|
64
|
+
text: TextLocale[];
|
|
65
|
+
buttons_style?: ButtonStyle;
|
|
66
|
+
buttons: Button[];
|
|
67
|
+
}
|
|
68
|
+
export interface TextNode extends Node {
|
|
69
|
+
type: NodeType.TEXT;
|
|
70
|
+
content: TextNodeContent;
|
|
71
|
+
}
|
|
72
|
+
export interface MediaFileLocale {
|
|
73
|
+
id: string;
|
|
74
|
+
file: string;
|
|
75
|
+
locale: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ImageNodeContent {
|
|
78
|
+
image: MediaFileLocale[];
|
|
79
|
+
}
|
|
80
|
+
export interface ImageNode extends Node {
|
|
81
|
+
type: NodeType.IMAGE;
|
|
82
|
+
content: ImageNodeContent;
|
|
83
|
+
}
|
|
84
|
+
export interface CarouselElementNode {
|
|
85
|
+
id: string;
|
|
86
|
+
title: TextLocale[];
|
|
87
|
+
subtitle: TextLocale[];
|
|
88
|
+
image: MediaFileLocale[];
|
|
89
|
+
button: Button;
|
|
90
|
+
}
|
|
91
|
+
export interface CarouselNodeContent {
|
|
92
|
+
elements: CarouselElementNode[];
|
|
93
|
+
}
|
|
94
|
+
export interface CarouselNode extends Node {
|
|
95
|
+
type: NodeType.CAROUSEL;
|
|
96
|
+
content: CarouselNodeContent;
|
|
97
|
+
}
|
|
98
|
+
export interface QueueLocale {
|
|
99
|
+
id: string;
|
|
100
|
+
name: string;
|
|
101
|
+
locale: string;
|
|
102
|
+
}
|
|
103
|
+
export interface HandoffNodeContent {
|
|
104
|
+
message: TextLocale[];
|
|
105
|
+
fail_message: TextLocale[];
|
|
106
|
+
queue: QueueLocale[];
|
|
107
|
+
}
|
|
108
|
+
export interface HandoffNode extends Node {
|
|
109
|
+
type: NodeType.HANDOFF;
|
|
110
|
+
content: HandoffNodeContent;
|
|
111
|
+
}
|
|
112
|
+
export interface InputLocale {
|
|
113
|
+
values: string[];
|
|
114
|
+
locale: string;
|
|
115
|
+
}
|
|
116
|
+
export interface KeywordNodeContent {
|
|
117
|
+
title: TextLocale[];
|
|
118
|
+
keywords: InputLocale[];
|
|
119
|
+
}
|
|
120
|
+
export interface KeywordNode extends Node {
|
|
121
|
+
type: NodeType.KEYWORD;
|
|
122
|
+
content: KeywordNodeContent;
|
|
123
|
+
}
|
|
124
|
+
export interface IntentNodeContent {
|
|
125
|
+
title: TextLocale[];
|
|
126
|
+
intents: InputLocale[];
|
|
127
|
+
confidence: number;
|
|
128
|
+
}
|
|
129
|
+
export interface IntentNode extends Node {
|
|
130
|
+
type: NodeType.INTENT;
|
|
131
|
+
content: IntentNodeContent;
|
|
132
|
+
}
|
|
133
|
+
export interface StartNode extends BaseNode {
|
|
134
|
+
type: NodeType.START_UP;
|
|
135
|
+
target: NodeLink;
|
|
136
|
+
}
|
|
137
|
+
export interface UrlNodeContent {
|
|
138
|
+
url: string;
|
|
139
|
+
}
|
|
140
|
+
export interface UrlNode extends BaseNode {
|
|
141
|
+
type: NodeType.URL;
|
|
142
|
+
content: UrlNodeContent;
|
|
143
|
+
}
|
|
144
|
+
export interface PayloadNodeContent {
|
|
145
|
+
payload: string;
|
|
146
|
+
}
|
|
147
|
+
export interface PayloadNode extends BaseNode {
|
|
148
|
+
type: NodeType.PAYLOAD;
|
|
149
|
+
content: PayloadNodeContent;
|
|
150
|
+
}
|
|
151
|
+
export declare type ArgumentType = number | string | Record<any, any>;
|
|
152
|
+
export interface FunctionNodeArgument {
|
|
153
|
+
type: ArgumentType;
|
|
154
|
+
name: string;
|
|
155
|
+
value: string;
|
|
156
|
+
}
|
|
157
|
+
export interface FunctionNodeArgumentLocale {
|
|
158
|
+
locale: string;
|
|
159
|
+
values: FunctionNodeArgument[];
|
|
160
|
+
}
|
|
161
|
+
export interface FunctionNodeResult {
|
|
162
|
+
result: string;
|
|
163
|
+
target: NodeLink;
|
|
164
|
+
}
|
|
165
|
+
export interface FunctionNodeContent {
|
|
166
|
+
action: string;
|
|
167
|
+
arguments: FunctionNodeArgumentLocale[];
|
|
168
|
+
result_mapping: FunctionNodeResult[];
|
|
169
|
+
}
|
|
170
|
+
export interface FunctionNode extends Node {
|
|
171
|
+
type: NodeType.FUNCTION;
|
|
172
|
+
content: FunctionNodeContent;
|
|
173
|
+
}
|
|
174
|
+
export declare type NodeComponent = TextNode | ImageNode | CarouselNode | HandoffNode | KeywordNode | IntentNode | UrlNode | StartNode | PayloadNode | FunctionNode;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var NodeType;
|
|
2
|
+
(function (NodeType) {
|
|
3
|
+
NodeType["TEXT"] = "text";
|
|
4
|
+
NodeType["IMAGE"] = "image";
|
|
5
|
+
NodeType["CAROUSEL"] = "carousel";
|
|
6
|
+
NodeType["HANDOFF"] = "handoff";
|
|
7
|
+
NodeType["KEYWORD"] = "keyword";
|
|
8
|
+
NodeType["INTENT"] = "intent";
|
|
9
|
+
NodeType["START_UP"] = "start-up";
|
|
10
|
+
NodeType["URL"] = "url";
|
|
11
|
+
NodeType["PAYLOAD"] = "payload";
|
|
12
|
+
NodeType["FUNCTION"] = "function";
|
|
13
|
+
})(NodeType || (NodeType = {}));
|
|
14
|
+
export var ButtonStyle;
|
|
15
|
+
(function (ButtonStyle) {
|
|
16
|
+
ButtonStyle["BUTTON"] = "button";
|
|
17
|
+
ButtonStyle["QUICK_REPLY"] = "quick-reply";
|
|
18
|
+
})(ButtonStyle || (ButtonStyle = {}));
|
|
19
|
+
//# sourceMappingURL=flow-builder-models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-builder-models.js","sourceRoot":"","sources":["../../src/flow-builder-models.ts"],"names":[],"mappings":"AASA,MAAM,CAAN,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,2BAAe,CAAA;IACf,iCAAqB,CAAA;IACrB,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;IACjB,iCAAqB,CAAA;IACrB,uBAAW,CAAA;IACX,+BAAmB,CAAA;IACnB,iCAAqB,CAAA;AACvB,CAAC,EAXW,QAAQ,KAAR,QAAQ,QAWnB;AA6BD,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,0CAA2B,CAAA;AAC7B,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function conditionalQueueStatus({ queue_id }: {
|
|
2
|
-
queue_id:
|
|
1
|
+
export declare function conditionalQueueStatus({ queue_id, }: {
|
|
2
|
+
queue_id: string;
|
|
3
3
|
}): Promise<string>;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1
2
|
import axios from 'axios';
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
import { getWebpackEnvVar } from '../utils';
|
|
4
|
+
const _HUBTYPE_API_URL_ = getWebpackEnvVar(
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
typeof HUBTYPE_API_URL !== 'undefined' && HUBTYPE_API_URL, 'HUBTYPE_API_URL', 'https://api.hubtype.com');
|
|
7
|
+
export async function conditionalQueueStatus({ queue_id, }) {
|
|
8
|
+
const response = await axios.get(`${_HUBTYPE_API_URL_}/v1/queues/${queue_id}/availability/`,
|
|
9
|
+
// TODO: Make it configurable in the future
|
|
10
|
+
{
|
|
11
|
+
params: {
|
|
12
|
+
check_queue_schedule: true,
|
|
13
|
+
check_waiting_cases: false,
|
|
14
|
+
check_available_agents: false,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
4
17
|
const isAvailable = response.data.available;
|
|
5
18
|
return isAvailable ? 'open' : 'closed';
|
|
6
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,iBAAiB,GAAG,gBAAgB;AACxC,aAAa;AACb,OAAO,eAAe,KAAK,WAAW,IAAI,eAAe,EACzD,iBAAiB,EACjB,yBAAyB,CAC1B,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,EAC3C,QAAQ,GAGT;IACC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAC9B,GAAG,iBAAiB,cAAc,QAAQ,gBAAgB;IAC1D,2CAA2C;IAC3C;QACE,MAAM,EAAE;YACN,oBAAoB,EAAE,IAAI;YAC1B,mBAAmB,EAAE,KAAK;YAC1B,sBAAsB,EAAE,KAAK;SAC9B;KACF,CACF,CAAA;IACD,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAA;IAC3C,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { conditionalProvider } from './conditional-provider';
|
|
2
2
|
import { conditionalQueueStatus } from './conditional-queue-status';
|
|
3
3
|
export declare const DEFAULT_FUNCTIONS: {
|
|
4
|
-
'
|
|
4
|
+
'check-queue-status': typeof conditionalQueueStatus;
|
|
5
5
|
'conditional-provider': typeof conditionalProvider;
|
|
6
6
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { conditionalProvider } from './conditional-provider';
|
|
2
2
|
import { conditionalQueueStatus } from './conditional-queue-status';
|
|
3
3
|
export const DEFAULT_FUNCTIONS = {
|
|
4
|
-
|
|
4
|
+
// TODO: Rename api action name
|
|
5
|
+
// 'conditional-queue-status': conditionalQueueStatus,
|
|
6
|
+
'check-queue-status': conditionalQueueStatus,
|
|
5
7
|
'conditional-provider': conditionalProvider,
|
|
6
8
|
};
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAEnE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAEnE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,+BAA+B;IAC/B,sDAAsD;IACtD,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,mBAAmB;CAC5C,CAAA"}
|
package/lib/esm/handoff.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActionRequest } from '@botonic/react';
|
|
2
|
-
export declare function doHandoff(request: ActionRequest): Promise<
|
|
2
|
+
export declare function doHandoff(request: ActionRequest, queue: string, note?: string, agentEmail?: string): Promise<void>;
|
package/lib/esm/handoff.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
// This function should just do a basic handoff
|
|
4
|
-
// TODO: add missing options: withNote, withAgent
|
|
5
|
-
export async function doHandoff(request) {
|
|
1
|
+
import { HandOffBuilder } from '@botonic/core';
|
|
2
|
+
export async function doHandoff(request, queue, note, agentEmail) {
|
|
6
3
|
var _a;
|
|
7
4
|
// @ts-ignore
|
|
8
5
|
const flowBuilderPlugin = request.plugins.hubtypeFlowBuilder;
|
|
9
6
|
const handoffContent = await flowBuilderPlugin.getHandoffContent();
|
|
10
|
-
console.log(handoffContent);
|
|
11
7
|
// @ts-ignore
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
const handOffBuilder = new HandOffBuilder(request.session);
|
|
17
|
-
handOffBuilder.withQueue('Test');
|
|
18
|
-
handOffBuilder.withOnFinishPayload((_a = handoffContent.target) === null || _a === void 0 ? void 0 : _a.id);
|
|
19
|
-
await handOffBuilder.handOff();
|
|
20
|
-
return handoffContent.content.message[0].message;
|
|
8
|
+
const handOffBuilder = new HandOffBuilder(request.session);
|
|
9
|
+
handOffBuilder.withQueue(queue);
|
|
10
|
+
if (note) {
|
|
11
|
+
handOffBuilder.withNote(note);
|
|
21
12
|
}
|
|
22
|
-
|
|
13
|
+
if (agentEmail) {
|
|
14
|
+
handOffBuilder.withAgentEmail(agentEmail);
|
|
15
|
+
}
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
17
|
+
handOffBuilder.withOnFinishPayload((_a = handoffContent.target) === null || _a === void 0 ? void 0 : _a.id);
|
|
18
|
+
await handOffBuilder.handOff();
|
|
23
19
|
}
|
|
24
20
|
//# sourceMappingURL=handoff.js.map
|
package/lib/esm/handoff.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAG9C,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,OAAsB,EACtB,KAAa,EACb,IAAa,EACb,UAAmB;;IAEnB,aAAa;IACb,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAyB,CAAA;IACnE,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,EAAE,CAAA;IAElE,aAAa;IACb,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC1D,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAE/B,IAAI,IAAI,EAAE;QACR,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;KAC9B;IAED,IAAI,UAAU,EAAE;QACd,cAAc,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;KAC1C;IACD,oEAAoE;IACpE,cAAc,CAAC,mBAAmB,CAAC,MAAA,cAAc,CAAC,MAAM,0CAAE,EAAG,CAAC,CAAA;IAC9D,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;AAChC,CAAC"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Input, Plugin, PluginPostRequest, PluginPreRequest } from '@botonic/core';
|
|
2
|
-
import { FlowContent } from './content-fields
|
|
3
|
-
import {
|
|
4
|
-
declare type BotonicPluginFlowBuilderOptions = {
|
|
1
|
+
import { Input, Plugin, PluginPostRequest, PluginPreRequest, Session } from '@botonic/core';
|
|
2
|
+
import { FlowContent } from './content-fields';
|
|
3
|
+
import { FlowBuilderData, FunctionNode, HandoffNode, IntentNode, KeywordNode, NodeComponent } from './flow-builder-models';
|
|
4
|
+
export declare type BotonicPluginFlowBuilderOptions = {
|
|
5
5
|
flowUrl: string;
|
|
6
|
-
flow
|
|
7
|
-
customFunctions
|
|
6
|
+
flow?: FlowBuilderData;
|
|
7
|
+
customFunctions?: Record<any, any>;
|
|
8
|
+
getLocale: (session: Session) => string;
|
|
9
|
+
getAccessToken: () => string;
|
|
8
10
|
};
|
|
9
11
|
export default class BotonicPluginFlowBuilder implements Plugin {
|
|
10
12
|
readonly options: BotonicPluginFlowBuilderOptions;
|
|
@@ -12,19 +14,22 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
12
14
|
private flow;
|
|
13
15
|
private functions;
|
|
14
16
|
private currentRequest;
|
|
17
|
+
private getAccessToken;
|
|
18
|
+
getLocale: (session: Session) => string;
|
|
15
19
|
constructor(options: BotonicPluginFlowBuilderOptions);
|
|
16
|
-
readFlowContent(): Promise<
|
|
20
|
+
readFlowContent(): Promise<FlowBuilderData>;
|
|
17
21
|
pre(request: PluginPreRequest): Promise<void>;
|
|
18
22
|
post(_request: PluginPostRequest): Promise<void>;
|
|
19
|
-
getContent(id: string): Promise<
|
|
20
|
-
getHandoffContent(): Promise<
|
|
21
|
-
getFlowContent(hubtypeContent:
|
|
23
|
+
getContent(id: string): Promise<NodeComponent>;
|
|
24
|
+
getHandoffContent(): Promise<HandoffNode>;
|
|
25
|
+
getFlowContent(hubtypeContent: NodeComponent, locale: string): FlowContent | undefined;
|
|
26
|
+
getStartId(): Promise<string>;
|
|
22
27
|
getContents(id: string, locale: string, prevContents?: FlowContent[]): Promise<FlowContent[]>;
|
|
23
28
|
getPayloadByInput(input: Input, locale: string): Promise<string | undefined>;
|
|
24
|
-
hasIntent(node:
|
|
29
|
+
hasIntent(node: IntentNode, intent: string, locale: string): boolean;
|
|
25
30
|
getPayloadByKeyword(input: Input, locale: string): Promise<string | undefined>;
|
|
26
|
-
matchKeywords(node:
|
|
31
|
+
matchKeywords(node: KeywordNode, input: string, locale: string): boolean;
|
|
27
32
|
containsAnyKeywords(input: string, keywords: string[]): boolean;
|
|
28
|
-
callFunction(functionNode:
|
|
33
|
+
callFunction(functionNode: FunctionNode, locale: string): Promise<string>;
|
|
29
34
|
}
|
|
30
|
-
export {};
|
|
35
|
+
export { FlowBuilderAction } from './action';
|
package/lib/esm/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import { FlowCarousel } from './content-fields
|
|
3
|
-
import {
|
|
4
|
-
import { FlowText } from './content-fields/text';
|
|
2
|
+
import { FlowCarousel, FlowImage, FlowText, } from './content-fields';
|
|
3
|
+
import { NodeType, } from './flow-builder-models';
|
|
5
4
|
import { DEFAULT_FUNCTIONS } from './functions';
|
|
6
|
-
import { MessageContentType, } from './hubtype-models';
|
|
7
5
|
export default class BotonicPluginFlowBuilder {
|
|
8
6
|
constructor(options) {
|
|
9
7
|
this.options = options;
|
|
8
|
+
this.getLocale = options.getLocale;
|
|
9
|
+
this.getAccessToken = options.getAccessToken;
|
|
10
10
|
this.flowUrl = options.flowUrl;
|
|
11
11
|
this.flow = options.flow || this.readFlowContent();
|
|
12
12
|
const customFunctions = options.customFunctions || {};
|
|
13
13
|
this.functions = Object.assign(Object.assign({}, DEFAULT_FUNCTIONS), customFunctions);
|
|
14
14
|
}
|
|
15
15
|
async readFlowContent() {
|
|
16
|
-
const response = await axios.get(this.flowUrl
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return
|
|
16
|
+
const response = await axios.get(this.flowUrl, {
|
|
17
|
+
headers: { Authorization: `Bearer ${this.getAccessToken()}` },
|
|
18
|
+
});
|
|
19
|
+
return response.data;
|
|
20
20
|
}
|
|
21
21
|
async pre(request) {
|
|
22
22
|
this.currentRequest = request;
|
|
@@ -25,35 +25,43 @@ export default class BotonicPluginFlowBuilder {
|
|
|
25
25
|
async post(_request) { }
|
|
26
26
|
async getContent(id) {
|
|
27
27
|
const flow = await this.flow;
|
|
28
|
-
const content = flow.nodes.find(
|
|
28
|
+
const content = flow.nodes.find(node => node.id === id);
|
|
29
29
|
if (!content)
|
|
30
30
|
throw Error(`text with id: '${id}' not found`);
|
|
31
31
|
return content;
|
|
32
32
|
}
|
|
33
33
|
async getHandoffContent() {
|
|
34
34
|
const flow = await this.flow;
|
|
35
|
-
const content = flow.nodes.find(
|
|
35
|
+
const content = flow.nodes.find(node => node.type === NodeType.HANDOFF);
|
|
36
36
|
if (!content)
|
|
37
37
|
throw Error(`Handoff node not found`);
|
|
38
38
|
return content;
|
|
39
39
|
}
|
|
40
40
|
getFlowContent(hubtypeContent, locale) {
|
|
41
41
|
switch (hubtypeContent.type) {
|
|
42
|
-
case
|
|
42
|
+
case NodeType.TEXT:
|
|
43
43
|
return FlowText.fromHubtypeCMS(hubtypeContent, locale);
|
|
44
|
-
case
|
|
44
|
+
case NodeType.IMAGE:
|
|
45
45
|
return FlowImage.fromHubtypeCMS(hubtypeContent, locale);
|
|
46
|
-
case
|
|
46
|
+
case NodeType.CAROUSEL:
|
|
47
47
|
return FlowCarousel.fromHubtypeCMS(hubtypeContent, locale);
|
|
48
48
|
default:
|
|
49
49
|
return undefined;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
async getStartId() {
|
|
53
|
+
const flow = await this.flow;
|
|
54
|
+
const startNode = flow.nodes.find(node => node.type === NodeType.START_UP);
|
|
55
|
+
if (!startNode) {
|
|
56
|
+
throw new Error('start-up id must be defined');
|
|
57
|
+
}
|
|
58
|
+
return startNode.target.id;
|
|
59
|
+
}
|
|
52
60
|
async getContents(id, locale, prevContents) {
|
|
53
61
|
const contents = prevContents || [];
|
|
54
62
|
const hubtypeContent = await this.getContent(id);
|
|
55
63
|
const content = await this.getFlowContent(hubtypeContent, locale);
|
|
56
|
-
if (hubtypeContent.type ===
|
|
64
|
+
if (hubtypeContent.type === NodeType.FUNCTION) {
|
|
57
65
|
const targetId = await this.callFunction(hubtypeContent, locale);
|
|
58
66
|
return this.getContents(targetId, locale, contents);
|
|
59
67
|
}
|
|
@@ -72,7 +80,7 @@ export default class BotonicPluginFlowBuilder {
|
|
|
72
80
|
var _a;
|
|
73
81
|
try {
|
|
74
82
|
const flow = await this.flow;
|
|
75
|
-
const intents = flow.nodes.filter(node => node.type
|
|
83
|
+
const intents = flow.nodes.filter(node => node.type === NodeType.INTENT);
|
|
76
84
|
if (input.intent) {
|
|
77
85
|
const matchedIntents = intents.filter(node =>
|
|
78
86
|
//@ts-ignore
|
|
@@ -95,7 +103,7 @@ export default class BotonicPluginFlowBuilder {
|
|
|
95
103
|
var _a;
|
|
96
104
|
try {
|
|
97
105
|
const flow = await this.flow;
|
|
98
|
-
const keywordNodes = flow.nodes.filter(node => node.type ==
|
|
106
|
+
const keywordNodes = flow.nodes.filter(node => node.type == NodeType.KEYWORD);
|
|
99
107
|
const matchedKeywordNodes = keywordNodes.filter(node =>
|
|
100
108
|
//@ts-ignore
|
|
101
109
|
this.matchKeywords(node, input.data, locale));
|
|
@@ -121,11 +129,13 @@ export default class BotonicPluginFlowBuilder {
|
|
|
121
129
|
return false;
|
|
122
130
|
}
|
|
123
131
|
async callFunction(functionNode, locale) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const nameValues = functionNode.content.arguments
|
|
127
|
-
.find(arg => arg.locale === locale)
|
|
128
|
-
|
|
132
|
+
var _a;
|
|
133
|
+
const functionNodeId = functionNode.id;
|
|
134
|
+
const nameValues = (_a = functionNode.content.arguments
|
|
135
|
+
.find(arg => arg.locale === locale)) === null || _a === void 0 ? void 0 : _a.values.map(value => ({ [value.name]: value.value }));
|
|
136
|
+
if (!nameValues) {
|
|
137
|
+
throw new Error(`No arguments found for node with id ${functionNodeId}`);
|
|
138
|
+
}
|
|
129
139
|
const args = Object.assign({
|
|
130
140
|
session: this.currentRequest.session,
|
|
131
141
|
results: [functionNode.content.result_mapping.map(r => r.result)],
|
|
@@ -133,7 +143,11 @@ export default class BotonicPluginFlowBuilder {
|
|
|
133
143
|
const functionResult = await this.functions[functionNode.content.action](args);
|
|
134
144
|
// TODO define result_mapping per locale??
|
|
135
145
|
const result = functionNode.content.result_mapping.find(r => r.result === functionResult);
|
|
146
|
+
if (!result) {
|
|
147
|
+
throw new Error(`No result found for result_mapping for node with id: ${functionNodeId}`);
|
|
148
|
+
}
|
|
136
149
|
return result.target.id;
|
|
137
150
|
}
|
|
138
151
|
}
|
|
152
|
+
export { FlowBuilderAction } from './action';
|
|
139
153
|
//# sourceMappingURL=index.js.map
|
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":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EACL,YAAY,EAEZ,SAAS,EACT,QAAQ,GACT,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAOL,QAAQ,GAET,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAU/C,MAAM,CAAC,OAAO,OAAO,wBAAwB;IAQ3C,YAAqB,OAAwC;QAAxC,YAAO,GAAP,OAAO,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