@botonic/plugin-flow-builder 0.21.0-alpha.0 → 0.21.0-alpha.2
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/{action.d.ts → cjs/action.d.ts} +0 -0
- package/lib/cjs/action.js +46 -0
- package/lib/cjs/action.js.map +1 -0
- package/lib/{content-fields → cjs/content-fields}/button.d.ts +0 -0
- package/lib/{content-fields → cjs/content-fields}/button.js +2 -4
- package/lib/cjs/content-fields/button.js.map +1 -0
- package/lib/{content-fields → cjs/content-fields}/carousel.d.ts +0 -0
- package/lib/{content-fields → cjs/content-fields}/carousel.js +2 -5
- package/lib/cjs/content-fields/carousel.js.map +1 -0
- package/lib/{content-fields → cjs/content-fields}/content-base.d.ts +0 -0
- package/lib/{content-fields → cjs/content-fields}/content-base.js +0 -0
- package/lib/cjs/content-fields/content-base.js.map +1 -0
- package/lib/{content-fields → cjs/content-fields}/element.d.ts +0 -0
- package/lib/{content-fields → cjs/content-fields}/element.js +0 -0
- package/lib/cjs/content-fields/element.js.map +1 -0
- package/lib/{content-fields → cjs/content-fields}/image.d.ts +0 -0
- package/lib/{content-fields → cjs/content-fields}/image.js +2 -4
- package/lib/cjs/content-fields/image.js.map +1 -0
- package/lib/{content-fields → cjs/content-fields}/text.d.ts +0 -0
- package/lib/{content-fields → cjs/content-fields}/text.js +2 -4
- package/lib/cjs/content-fields/text.js.map +1 -0
- package/lib/{functions → cjs/functions}/conditional-provider.d.ts +0 -0
- package/lib/{functions → cjs/functions}/conditional-provider.js +0 -0
- package/lib/cjs/functions/conditional-provider.js.map +1 -0
- package/lib/{functions → cjs/functions}/conditional-queue-status.d.ts +0 -0
- package/lib/cjs/functions/conditional-queue-status.js +12 -0
- package/lib/cjs/functions/conditional-queue-status.js.map +1 -0
- package/lib/{functions → cjs/functions}/index.d.ts +0 -0
- package/lib/{functions → cjs/functions}/index.js +0 -0
- package/lib/cjs/functions/index.js.map +1 -0
- package/lib/{handoff.d.ts → cjs/handoff.d.ts} +0 -0
- package/lib/cjs/handoff.js +28 -0
- package/lib/cjs/handoff.js.map +1 -0
- package/lib/{hubtype-models.d.ts → cjs/hubtype-models.d.ts} +0 -0
- package/lib/{hubtype-models.js → cjs/hubtype-models.js} +0 -0
- package/lib/cjs/hubtype-models.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +142 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{utils.d.ts → cjs/utils.d.ts} +0 -0
- package/lib/{utils.js → cjs/utils.js} +0 -0
- package/lib/cjs/utils.js.map +1 -0
- package/lib/esm/action.d.ts +15 -0
- package/lib/esm/action.js +41 -0
- package/lib/esm/action.js.map +1 -0
- package/lib/esm/content-fields/button.d.ts +10 -0
- package/lib/esm/content-fields/button.js +26 -0
- package/lib/esm/content-fields/button.js.map +1 -0
- package/lib/esm/content-fields/carousel.d.ts +10 -0
- package/lib/esm/content-fields/carousel.js +29 -0
- package/lib/esm/content-fields/carousel.js.map +1 -0
- package/lib/esm/content-fields/content-base.d.ts +10 -0
- package/lib/esm/content-fields/content-base.js +11 -0
- package/lib/esm/content-fields/content-base.js.map +1 -0
- package/lib/esm/content-fields/element.d.ts +11 -0
- package/lib/esm/content-fields/element.js +21 -0
- package/lib/esm/content-fields/element.js.map +1 -0
- package/lib/esm/content-fields/image.d.ts +9 -0
- package/lib/esm/content-fields/image.js +21 -0
- package/lib/esm/content-fields/image.js.map +1 -0
- package/lib/esm/content-fields/text.d.ts +12 -0
- package/lib/esm/content-fields/text.js +28 -0
- package/lib/esm/content-fields/text.js.map +1 -0
- package/lib/esm/functions/conditional-provider.d.ts +4 -0
- package/lib/esm/functions/conditional-provider.js +7 -0
- package/lib/esm/functions/conditional-provider.js.map +1 -0
- package/lib/esm/functions/conditional-queue-status.d.ts +3 -0
- package/lib/esm/functions/conditional-queue-status.js +7 -0
- package/lib/esm/functions/conditional-queue-status.js.map +1 -0
- package/lib/esm/functions/index.d.ts +6 -0
- package/lib/esm/functions/index.js +7 -0
- package/lib/esm/functions/index.js.map +1 -0
- package/lib/esm/handoff.d.ts +2 -0
- package/lib/esm/handoff.js +24 -0
- package/lib/esm/handoff.js.map +1 -0
- package/lib/esm/hubtype-models.d.ts +152 -0
- package/lib/esm/hubtype-models.js +47 -0
- package/lib/esm/hubtype-models.js.map +1 -0
- package/lib/esm/index.d.ts +30 -0
- package/lib/esm/index.js +138 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/utils.d.ts +2 -0
- package/lib/esm/utils.js +6 -0
- package/lib/esm/utils.js.map +1 -0
- package/package.json +5 -5
- package/src/action.tsx +1 -4
- package/src/content-fields/carousel.tsx +9 -12
- package/src/index.ts +1 -1
- package/lib/action.js +0 -62
- package/lib/action.js.map +0 -1
- package/lib/content-fields/button.js.map +0 -1
- package/lib/content-fields/carousel.js.map +0 -1
- package/lib/content-fields/content-base.js.map +0 -1
- package/lib/content-fields/element.js.map +0 -1
- package/lib/content-fields/image.js.map +0 -1
- package/lib/content-fields/text.js.map +0 -1
- package/lib/functions/conditional-provider.js.map +0 -1
- package/lib/functions/conditional-queue-status.js +0 -25
- package/lib/functions/conditional-queue-status.js.map +0 -1
- package/lib/functions/index.js.map +0 -1
- package/lib/handoff.js +0 -39
- package/lib/handoff.js.map +0 -1
- package/lib/hubtype-models.js.map +0 -1
- package/lib/index.js +0 -171
- package/lib/index.js.map +0 -1
- package/lib/utils.js.map +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getImageByLocale } from '../utils';
|
|
2
|
+
import { FlowButton } from './button';
|
|
3
|
+
import { ContentFieldsBase } from './content-base';
|
|
4
|
+
export class FlowElement extends ContentFieldsBase {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.title = '';
|
|
8
|
+
this.subtitle = '';
|
|
9
|
+
this.image = '';
|
|
10
|
+
this.hidden = false;
|
|
11
|
+
}
|
|
12
|
+
static fromHubtypeCMS(component, locale) {
|
|
13
|
+
const newElement = new FlowElement(component.id);
|
|
14
|
+
newElement.title = FlowElement.getTextByLocale(locale, component.title);
|
|
15
|
+
newElement.subtitle = FlowElement.getTextByLocale(locale, component.subtitle);
|
|
16
|
+
newElement.image = getImageByLocale(locale, component.image);
|
|
17
|
+
newElement.buttons = FlowButton.fromHubtypeCMS(component.button, locale);
|
|
18
|
+
return newElement;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../../src/content-fields/element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,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;IAavB,CAAC;IAXC,MAAM,CAAC,cAAc,CAAC,SAAoB,EAAE,MAAc;QACxD,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,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;QAC5D,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 { HtImageNode } from '../hubtype-models';
|
|
3
|
+
import { ContentFieldsBase } from './content-base';
|
|
4
|
+
export declare class FlowImage extends ContentFieldsBase {
|
|
5
|
+
src: string;
|
|
6
|
+
code: string;
|
|
7
|
+
static fromHubtypeCMS(component: HtImageNode, locale: string): FlowImage;
|
|
8
|
+
toBotonic(index: number): JSX.Element;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Image } from '@botonic/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { getImageByLocale } from '../utils';
|
|
4
|
+
import { ContentFieldsBase } from './content-base';
|
|
5
|
+
export class FlowImage extends ContentFieldsBase {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.src = '';
|
|
9
|
+
this.code = '';
|
|
10
|
+
}
|
|
11
|
+
static fromHubtypeCMS(component, locale) {
|
|
12
|
+
const newImage = new FlowImage(component.id);
|
|
13
|
+
newImage.code = component.code;
|
|
14
|
+
newImage.src = getImageByLocale(locale, component.content.image);
|
|
15
|
+
return newImage;
|
|
16
|
+
}
|
|
17
|
+
toBotonic(index) {
|
|
18
|
+
return React.createElement(Image, { src: this.src, key: index });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/content-fields/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,MAAM,OAAO,SAAU,SAAQ,iBAAiB;IAAhD;;QACS,QAAG,GAAG,EAAE,CAAA;QACR,SAAI,GAAG,EAAE,CAAA;IAYlB,CAAC;IAVC,MAAM,CAAC,cAAc,CAAC,SAAsB,EAAE,MAAc;QAC1D,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,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAChE,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, HtTextNode } from '../hubtype-models';
|
|
3
|
+
import { FlowButton } from './button';
|
|
4
|
+
import { ContentFieldsBase } from './content-base';
|
|
5
|
+
export declare class FlowText extends ContentFieldsBase {
|
|
6
|
+
text: string;
|
|
7
|
+
code: string;
|
|
8
|
+
buttons: FlowButton[];
|
|
9
|
+
buttonStyle: ButtonStyle;
|
|
10
|
+
static fromHubtypeCMS(component: HtTextNode, locale: string): FlowText;
|
|
11
|
+
toBotonic(index: number): JSX.Element;
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Text } from '@botonic/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ButtonStyle } from '../hubtype-models';
|
|
4
|
+
import { FlowButton } from './button';
|
|
5
|
+
import { ContentFieldsBase } from './content-base';
|
|
6
|
+
export class FlowText extends ContentFieldsBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.text = '';
|
|
10
|
+
this.code = '';
|
|
11
|
+
this.buttons = [];
|
|
12
|
+
this.buttonStyle = ButtonStyle.BUTTON;
|
|
13
|
+
}
|
|
14
|
+
static fromHubtypeCMS(component, locale) {
|
|
15
|
+
const newText = new FlowText(component.id);
|
|
16
|
+
newText.code = component.code;
|
|
17
|
+
newText.buttonStyle = component.content.buttons_style || ButtonStyle.BUTTON;
|
|
18
|
+
newText.text = FlowText.getTextByLocale(locale, component.content.text);
|
|
19
|
+
newText.buttons = component.content.buttons.map(button => FlowButton.fromHubtypeCMS(button, locale));
|
|
20
|
+
return newText;
|
|
21
|
+
}
|
|
22
|
+
toBotonic(index) {
|
|
23
|
+
return (React.createElement(Text, { key: index },
|
|
24
|
+
this.text,
|
|
25
|
+
this.buttons.map((button, index) => button.renderButton(index, this.buttonStyle))));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/content-fields/text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,WAAW,EAAc,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,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,SAAqB,EAAE,MAAc;QACzD,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 @@
|
|
|
1
|
+
{"version":3,"file":"conditional-provider.js","sourceRoot":"","sources":["../../../src/functions/conditional-provider.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE;IACtD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAA;IACtC,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAA;IAC/C,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
export async function conditionalQueueStatus({ queueId }) {
|
|
3
|
+
const response = await axios.get(`https://api.hubtype.com/v1/queues/${queueId}/availability/`);
|
|
4
|
+
const isAvailable = response.data.available;
|
|
5
|
+
return isAvailable ? 'open' : 'closed';
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=conditional-queue-status.js.map
|
|
@@ -0,0 +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,EAAE,OAAO,EAAE;IACtD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAC9B,qCAAqC,OAAO,gBAAgB,CAC7D,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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { conditionalProvider } from './conditional-provider';
|
|
2
|
+
import { conditionalQueueStatus } from './conditional-queue-status';
|
|
3
|
+
export declare const DEFAULT_FUNCTIONS: {
|
|
4
|
+
'conditional-queue-status': typeof conditionalQueueStatus;
|
|
5
|
+
'conditional-provider': typeof conditionalProvider;
|
|
6
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { conditionalProvider } from './conditional-provider';
|
|
2
|
+
import { conditionalQueueStatus } from './conditional-queue-status';
|
|
3
|
+
export const DEFAULT_FUNCTIONS = {
|
|
4
|
+
'conditional-queue-status': conditionalQueueStatus,
|
|
5
|
+
'conditional-provider': conditionalProvider,
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,0BAA0B,EAAE,sBAAsB;IAClD,sBAAsB,EAAE,mBAAmB;CAC5C,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getOpenQueues, HandOffBuilder } from '@botonic/core';
|
|
2
|
+
// TODO: Remove all "getOpenQueues" logic and open/closed messages.
|
|
3
|
+
// This function should just do a basic handoff
|
|
4
|
+
// TODO: add missing options: withNote, withAgent
|
|
5
|
+
export async function doHandoff(request) {
|
|
6
|
+
var _a;
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const flowBuilderPlugin = request.plugins.hubtypeFlowBuilder;
|
|
9
|
+
const handoffContent = await flowBuilderPlugin.getHandoffContent();
|
|
10
|
+
console.log(handoffContent);
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
let openQueues = await getOpenQueues(request.session);
|
|
13
|
+
const queueName = 'Test';
|
|
14
|
+
if (openQueues.queues.indexOf(queueName) !== -1) {
|
|
15
|
+
// @ts-ignore
|
|
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;
|
|
21
|
+
}
|
|
22
|
+
return handoffContent.content.failMessage[0].message;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAG7D,mEAAmE;AACnE,+CAA+C;AAC/C,iDAAiD;AAEjD,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAsB;;IACpD,aAAa;IACb,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAyB,CAAA;IACnE,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,EAAE,CAAA;IAClE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAC3B,aAAa;IACb,IAAI,UAAU,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACrD,MAAM,SAAS,GAAG,MAAM,CAAA;IACxB,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/C,aAAa;QACb,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC1D,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAChC,cAAc,CAAC,mBAAmB,CAAC,MAAA,cAAc,CAAC,MAAM,0CAAE,EAAG,CAAC,CAAA;QAC9D,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;QAE9B,OAAO,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;KACjD;IAED,OAAO,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export declare enum ButtonStyle {
|
|
2
|
+
BUTTON = "button",
|
|
3
|
+
QUICK_REPLY = "quick-reply"
|
|
4
|
+
}
|
|
5
|
+
export declare enum MessageContentType {
|
|
6
|
+
CAROUSEL = "carousel",
|
|
7
|
+
IMAGE = "image",
|
|
8
|
+
TEXT = "text",
|
|
9
|
+
KEYWORD = "keyword",
|
|
10
|
+
HANDOFF = "handoff",
|
|
11
|
+
FUNCTION = "function",
|
|
12
|
+
INTENT = "intent"
|
|
13
|
+
}
|
|
14
|
+
export declare enum NonMessageContentType {
|
|
15
|
+
INTENT = "intent",
|
|
16
|
+
PAYLOAD = "payload",
|
|
17
|
+
QUEUE = "queue",
|
|
18
|
+
URL = "url"
|
|
19
|
+
}
|
|
20
|
+
export declare enum SubContentType {
|
|
21
|
+
BUTTON = "button",
|
|
22
|
+
ELEMENT = "element"
|
|
23
|
+
}
|
|
24
|
+
export declare enum MediaContentType {
|
|
25
|
+
ASSET = "asset"
|
|
26
|
+
}
|
|
27
|
+
export declare enum StartFieldsType {
|
|
28
|
+
STARTUP = "startUp"
|
|
29
|
+
}
|
|
30
|
+
export declare enum InputContentType {
|
|
31
|
+
INPUT = "user-input"
|
|
32
|
+
}
|
|
33
|
+
export declare enum InputType {
|
|
34
|
+
INTENTS = "intents",
|
|
35
|
+
KEYWORDS = "keywords"
|
|
36
|
+
}
|
|
37
|
+
export declare const NodeContentType: {
|
|
38
|
+
INPUT: InputContentType.INPUT;
|
|
39
|
+
CAROUSEL: MessageContentType.CAROUSEL;
|
|
40
|
+
IMAGE: MessageContentType.IMAGE;
|
|
41
|
+
TEXT: MessageContentType.TEXT;
|
|
42
|
+
KEYWORD: MessageContentType.KEYWORD;
|
|
43
|
+
HANDOFF: MessageContentType.HANDOFF;
|
|
44
|
+
FUNCTION: MessageContentType.FUNCTION;
|
|
45
|
+
INTENT: MessageContentType.INTENT;
|
|
46
|
+
};
|
|
47
|
+
export declare type NodeContentType = MessageContentType | InputContentType;
|
|
48
|
+
export interface HtFlowBuilderData {
|
|
49
|
+
version: string;
|
|
50
|
+
name: string;
|
|
51
|
+
locales: string[];
|
|
52
|
+
nodes: HtNodeComponent[];
|
|
53
|
+
}
|
|
54
|
+
export interface HtNodeLink {
|
|
55
|
+
id: string;
|
|
56
|
+
type: NodeContentType;
|
|
57
|
+
}
|
|
58
|
+
export interface HtBaseNode {
|
|
59
|
+
id: string;
|
|
60
|
+
code: string;
|
|
61
|
+
meta: {
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
};
|
|
65
|
+
follow_up?: HtNodeLink;
|
|
66
|
+
target?: HtNodeLink;
|
|
67
|
+
}
|
|
68
|
+
export interface HtTextLocale {
|
|
69
|
+
message: string;
|
|
70
|
+
locale: string;
|
|
71
|
+
}
|
|
72
|
+
export interface HtInputLocale {
|
|
73
|
+
values: string[];
|
|
74
|
+
locale: string;
|
|
75
|
+
}
|
|
76
|
+
export interface HtMediaFileLocale {
|
|
77
|
+
id: string;
|
|
78
|
+
file: string;
|
|
79
|
+
locale: string;
|
|
80
|
+
}
|
|
81
|
+
export interface HtTextNode extends HtBaseNode {
|
|
82
|
+
type: MessageContentType.TEXT;
|
|
83
|
+
content: {
|
|
84
|
+
text: HtTextLocale[];
|
|
85
|
+
buttons_style?: ButtonStyle;
|
|
86
|
+
buttons: HtButton[];
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export interface HtButton {
|
|
90
|
+
id: string;
|
|
91
|
+
text: HtTextLocale[];
|
|
92
|
+
target?: HtNodeLink;
|
|
93
|
+
hidden: string[];
|
|
94
|
+
}
|
|
95
|
+
export interface HtImageNode extends HtBaseNode {
|
|
96
|
+
type: MessageContentType.IMAGE;
|
|
97
|
+
content: {
|
|
98
|
+
image: HtMediaFileLocale[];
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export interface HtCarouselNode extends HtBaseNode {
|
|
102
|
+
type: MessageContentType.CAROUSEL;
|
|
103
|
+
content: {
|
|
104
|
+
elements: HtElement[];
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export interface HtElement {
|
|
108
|
+
id: string;
|
|
109
|
+
title: HtTextLocale[];
|
|
110
|
+
subtitle: HtTextLocale[];
|
|
111
|
+
image: HtMediaFileLocale[];
|
|
112
|
+
button: HtButton;
|
|
113
|
+
hidden: string[];
|
|
114
|
+
}
|
|
115
|
+
export interface HtIntentNode extends HtBaseNode {
|
|
116
|
+
type: MessageContentType.INTENT;
|
|
117
|
+
content: {
|
|
118
|
+
title: HtTextLocale[];
|
|
119
|
+
intents: HtInputLocale[];
|
|
120
|
+
confidence: number;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export interface HtKeywordNode extends HtBaseNode {
|
|
124
|
+
type: MessageContentType.KEYWORD;
|
|
125
|
+
content: {
|
|
126
|
+
title: HtTextLocale[];
|
|
127
|
+
keywords: HtInputLocale[];
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export interface HtHandoffNode extends HtBaseNode {
|
|
131
|
+
type: MessageContentType.HANDOFF;
|
|
132
|
+
content: {
|
|
133
|
+
queue: HtQueueLocale[];
|
|
134
|
+
message: HtTextLocale[];
|
|
135
|
+
failMessage: HtTextLocale[];
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
export interface HtQueueLocale {
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
locale: string;
|
|
142
|
+
}
|
|
143
|
+
export interface HtFunctionNode extends HtBaseNode {
|
|
144
|
+
type: MessageContentType.FUNCTION;
|
|
145
|
+
content: {
|
|
146
|
+
subtype: string;
|
|
147
|
+
action: string;
|
|
148
|
+
arguments: Array<any>;
|
|
149
|
+
result_mapping: Array<any>;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export declare type HtNodeComponent = HtTextNode | HtImageNode | HtCarouselNode | HtIntentNode | HtKeywordNode | HtHandoffNode | HtFunctionNode;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export var ButtonStyle;
|
|
2
|
+
(function (ButtonStyle) {
|
|
3
|
+
ButtonStyle["BUTTON"] = "button";
|
|
4
|
+
ButtonStyle["QUICK_REPLY"] = "quick-reply";
|
|
5
|
+
})(ButtonStyle || (ButtonStyle = {}));
|
|
6
|
+
export var MessageContentType;
|
|
7
|
+
(function (MessageContentType) {
|
|
8
|
+
MessageContentType["CAROUSEL"] = "carousel";
|
|
9
|
+
MessageContentType["IMAGE"] = "image";
|
|
10
|
+
MessageContentType["TEXT"] = "text";
|
|
11
|
+
MessageContentType["KEYWORD"] = "keyword";
|
|
12
|
+
MessageContentType["HANDOFF"] = "handoff";
|
|
13
|
+
MessageContentType["FUNCTION"] = "function";
|
|
14
|
+
MessageContentType["INTENT"] = "intent";
|
|
15
|
+
})(MessageContentType || (MessageContentType = {}));
|
|
16
|
+
// TODO: refactor types correctly
|
|
17
|
+
export var NonMessageContentType;
|
|
18
|
+
(function (NonMessageContentType) {
|
|
19
|
+
NonMessageContentType["INTENT"] = "intent";
|
|
20
|
+
NonMessageContentType["PAYLOAD"] = "payload";
|
|
21
|
+
NonMessageContentType["QUEUE"] = "queue";
|
|
22
|
+
NonMessageContentType["URL"] = "url";
|
|
23
|
+
})(NonMessageContentType || (NonMessageContentType = {}));
|
|
24
|
+
export var SubContentType;
|
|
25
|
+
(function (SubContentType) {
|
|
26
|
+
SubContentType["BUTTON"] = "button";
|
|
27
|
+
SubContentType["ELEMENT"] = "element";
|
|
28
|
+
})(SubContentType || (SubContentType = {}));
|
|
29
|
+
export var MediaContentType;
|
|
30
|
+
(function (MediaContentType) {
|
|
31
|
+
MediaContentType["ASSET"] = "asset";
|
|
32
|
+
})(MediaContentType || (MediaContentType = {}));
|
|
33
|
+
export var StartFieldsType;
|
|
34
|
+
(function (StartFieldsType) {
|
|
35
|
+
StartFieldsType["STARTUP"] = "startUp";
|
|
36
|
+
})(StartFieldsType || (StartFieldsType = {}));
|
|
37
|
+
export var InputContentType;
|
|
38
|
+
(function (InputContentType) {
|
|
39
|
+
InputContentType["INPUT"] = "user-input";
|
|
40
|
+
})(InputContentType || (InputContentType = {}));
|
|
41
|
+
export var InputType;
|
|
42
|
+
(function (InputType) {
|
|
43
|
+
InputType["INTENTS"] = "intents";
|
|
44
|
+
InputType["KEYWORDS"] = "keywords";
|
|
45
|
+
})(InputType || (InputType = {}));
|
|
46
|
+
export const NodeContentType = Object.assign(Object.assign({}, MessageContentType), InputContentType);
|
|
47
|
+
//# sourceMappingURL=hubtype-models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hub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AED,MAAM,CAAC,MAAM,eAAe,mCACvB,kBAAkB,GAClB,gBAAgB,CACpB,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Input, Plugin, PluginPostRequest, PluginPreRequest } from '@botonic/core';
|
|
2
|
+
import { FlowContent } from './content-fields/content-base';
|
|
3
|
+
import { HtFlowBuilderData, HtFunctionNode, HtHandoffNode, HtIntentNode, HtKeywordNode, HtNodeComponent } from './hubtype-models';
|
|
4
|
+
declare type BotonicPluginFlowBuilderOptions = {
|
|
5
|
+
flowUrl: string;
|
|
6
|
+
flow: any;
|
|
7
|
+
customFunctions: Record<any, any>;
|
|
8
|
+
};
|
|
9
|
+
export default class BotonicPluginFlowBuilder implements Plugin {
|
|
10
|
+
readonly options: BotonicPluginFlowBuilderOptions;
|
|
11
|
+
private flowUrl;
|
|
12
|
+
private flow;
|
|
13
|
+
private functions;
|
|
14
|
+
private currentRequest;
|
|
15
|
+
constructor(options: BotonicPluginFlowBuilderOptions);
|
|
16
|
+
readFlowContent(): Promise<HtFlowBuilderData>;
|
|
17
|
+
pre(request: PluginPreRequest): Promise<void>;
|
|
18
|
+
post(_request: PluginPostRequest): Promise<void>;
|
|
19
|
+
getContent(id: string): Promise<HtNodeComponent>;
|
|
20
|
+
getHandoffContent(): Promise<HtHandoffNode>;
|
|
21
|
+
getFlowContent(hubtypeContent: HtNodeComponent, locale: string): FlowContent | undefined;
|
|
22
|
+
getContents(id: string, locale: string, prevContents?: FlowContent[]): Promise<FlowContent[]>;
|
|
23
|
+
getPayloadByInput(input: Input, locale: string): Promise<string | undefined>;
|
|
24
|
+
hasIntent(node: HtIntentNode, intent: string, locale: string): boolean;
|
|
25
|
+
getPayloadByKeyword(input: Input, locale: string): Promise<string | undefined>;
|
|
26
|
+
matchKeywords(node: HtKeywordNode, input: string, locale: string): boolean;
|
|
27
|
+
containsAnyKeywords(input: string, keywords: string[]): boolean;
|
|
28
|
+
callFunction(functionNode: HtFunctionNode, locale: string): Promise<string>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { FlowCarousel } from './content-fields/carousel';
|
|
3
|
+
import { FlowImage } from './content-fields/image';
|
|
4
|
+
import { FlowText } from './content-fields/text';
|
|
5
|
+
import { DEFAULT_FUNCTIONS } from './functions';
|
|
6
|
+
import { MessageContentType, } from './hubtype-models';
|
|
7
|
+
export default class BotonicPluginFlowBuilder {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.flowUrl = options.flowUrl;
|
|
11
|
+
this.flow = options.flow || this.readFlowContent();
|
|
12
|
+
const customFunctions = options.customFunctions || {};
|
|
13
|
+
this.functions = Object.assign(Object.assign({}, DEFAULT_FUNCTIONS), customFunctions);
|
|
14
|
+
}
|
|
15
|
+
async readFlowContent() {
|
|
16
|
+
const response = await axios.get(this.flowUrl);
|
|
17
|
+
const data = await response.data;
|
|
18
|
+
//@ts-ignore
|
|
19
|
+
return Promise.resolve(data);
|
|
20
|
+
}
|
|
21
|
+
async pre(request) {
|
|
22
|
+
this.currentRequest = request;
|
|
23
|
+
}
|
|
24
|
+
async post(_request) { }
|
|
25
|
+
async getContent(id) {
|
|
26
|
+
const flow = await this.flow;
|
|
27
|
+
const content = flow.nodes.find((c) => c.id === id);
|
|
28
|
+
if (!content)
|
|
29
|
+
throw Error(`text with id: '${id}' not found`);
|
|
30
|
+
return content;
|
|
31
|
+
}
|
|
32
|
+
async getHandoffContent() {
|
|
33
|
+
const flow = await this.flow;
|
|
34
|
+
const content = flow.nodes.find((c) => c.type === 'handoff');
|
|
35
|
+
if (!content)
|
|
36
|
+
throw Error(`Handoff node not found`);
|
|
37
|
+
return content;
|
|
38
|
+
}
|
|
39
|
+
getFlowContent(hubtypeContent, locale) {
|
|
40
|
+
switch (hubtypeContent.type) {
|
|
41
|
+
case MessageContentType.TEXT:
|
|
42
|
+
return FlowText.fromHubtypeCMS(hubtypeContent, locale);
|
|
43
|
+
case MessageContentType.IMAGE:
|
|
44
|
+
return FlowImage.fromHubtypeCMS(hubtypeContent, locale);
|
|
45
|
+
case MessageContentType.CAROUSEL:
|
|
46
|
+
return FlowCarousel.fromHubtypeCMS(hubtypeContent, locale);
|
|
47
|
+
default:
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async getContents(id, locale, prevContents) {
|
|
52
|
+
const contents = prevContents || [];
|
|
53
|
+
const hubtypeContent = await this.getContent(id);
|
|
54
|
+
const content = await this.getFlowContent(hubtypeContent, locale);
|
|
55
|
+
if (hubtypeContent.type === MessageContentType.FUNCTION) {
|
|
56
|
+
const targetId = await this.callFunction(hubtypeContent, locale);
|
|
57
|
+
return this.getContents(targetId, locale, contents);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if (content)
|
|
61
|
+
contents.push(content);
|
|
62
|
+
// TODO: prevent infinite recursive calls
|
|
63
|
+
if (hubtypeContent.follow_up)
|
|
64
|
+
return this.getContents(hubtypeContent.follow_up.id, locale, contents);
|
|
65
|
+
}
|
|
66
|
+
// execute function
|
|
67
|
+
// return this.getContents(function result_mapping target, locale, contents)
|
|
68
|
+
return contents;
|
|
69
|
+
}
|
|
70
|
+
async getPayloadByInput(input, locale) {
|
|
71
|
+
var _a;
|
|
72
|
+
try {
|
|
73
|
+
const flow = await this.flow;
|
|
74
|
+
const intents = flow.nodes.filter(node => node.type == MessageContentType.INTENT);
|
|
75
|
+
if (input.intent) {
|
|
76
|
+
const matchedIntents = intents.filter(node =>
|
|
77
|
+
//@ts-ignore
|
|
78
|
+
this.hasIntent(node, input.intent, locale));
|
|
79
|
+
if (matchedIntents.length > 0) {
|
|
80
|
+
return (_a = matchedIntents[0].target) === null || _a === void 0 ? void 0 : _a.id;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error('Error getting payload by input: ', error);
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
hasIntent(node, intent, locale) {
|
|
90
|
+
const result = node.content.intents.find(i => i.locale === locale && i.values.includes(intent));
|
|
91
|
+
return Boolean(result);
|
|
92
|
+
}
|
|
93
|
+
async getPayloadByKeyword(input, locale) {
|
|
94
|
+
var _a;
|
|
95
|
+
try {
|
|
96
|
+
const flow = await this.flow;
|
|
97
|
+
const keywordNodes = flow.nodes.filter(node => node.type == MessageContentType.KEYWORD);
|
|
98
|
+
const matchedKeywordNodes = keywordNodes.filter(node =>
|
|
99
|
+
//@ts-ignore
|
|
100
|
+
this.matchKeywords(node, input.data, locale));
|
|
101
|
+
if (matchedKeywordNodes.length > 0) {
|
|
102
|
+
return (_a = matchedKeywordNodes[0].target) === null || _a === void 0 ? void 0 : _a.id;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.error('Error getting payload by input: ', error);
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
matchKeywords(node, input, locale) {
|
|
111
|
+
const result = node.content.keywords.find(i => i.locale === locale && this.containsAnyKeywords(input, i.values));
|
|
112
|
+
return Boolean(result);
|
|
113
|
+
}
|
|
114
|
+
containsAnyKeywords(input, keywords) {
|
|
115
|
+
for (let i = 0; i < keywords.length; i++) {
|
|
116
|
+
if (input.includes(keywords[i])) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
async callFunction(functionNode, locale) {
|
|
123
|
+
// Check if target is missing or missing arguments
|
|
124
|
+
// TODO: get arguments by locale
|
|
125
|
+
const nameValues = functionNode.content.arguments
|
|
126
|
+
.find(arg => arg.locale === locale)
|
|
127
|
+
.values.map(value => ({ [value.name]: value.value }));
|
|
128
|
+
const args = Object.assign({
|
|
129
|
+
session: this.currentRequest.session,
|
|
130
|
+
results: [functionNode.content.result_mapping.map(r => r.result)],
|
|
131
|
+
}, ...nameValues);
|
|
132
|
+
const functionResult = await this.functions[functionNode.content.action](args);
|
|
133
|
+
// TODO define result_mapping per locale??
|
|
134
|
+
const result = functionNode.content.result_mapping.find(r => r.result === functionResult);
|
|
135
|
+
return result.target.id;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAQL,kBAAkB,GACnB,MAAM,kBAAkB,CAAA;AAQzB,MAAM,CAAC,OAAO,OAAO,wBAAwB;IAM3C,YAAqB,OAAwC;QAAxC,YAAO,GAAP,OAAO,CAAiC;QAC3D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,eAAe,EAAE,CAAA;QAClD,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAA;QACrD,IAAI,CAAC,SAAS,mCAAQ,iBAAiB,GAAK,eAAe,CAAE,CAAA;IAC/D,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9C,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAA;QAChC,YAAY;QACZ,OAAO,OAAO,CAAC,OAAO,CAAC,IAA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C,CAAC,MAAM,CAAC,CAAC;SAClE,EACD,GAAG,UAAU,CACd,CAAA;QACD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CACtE,IAAI,CACL,CAAA;QACD,0CAA0C;QAC1C,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CACrD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,cAAc,CACjC,CAAA;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAA;IACzB,CAAC;CACF"}
|
package/lib/esm/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,KAA0B;;IACzE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,CAAA;IAClD,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,EAAE,CAAA;AAC3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-flow-builder",
|
|
3
|
-
"version": "0.21.0-alpha.
|
|
4
|
-
"main": "lib/index.js",
|
|
3
|
+
"version": "0.21.0-alpha.2",
|
|
4
|
+
"main": "./lib/cjs/index.js",
|
|
5
|
+
"module": "./lib/esm/index.js",
|
|
5
6
|
"description": "Use Flow Builder to show your contents",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"build": "rm -rf lib && ../../node_modules/.bin/tsc",
|
|
8
|
-
"build:watch": "
|
|
8
|
+
"build": "rm -rf lib && ../../node_modules/.bin/tsc -p tsconfig.json && ../../node_modules/.bin/tsc -p tsconfig.esm.json",
|
|
9
|
+
"build:watch": "npm run build -- --watch",
|
|
9
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
11
|
"cloc": "../../scripts/qa/cloc-package.sh .",
|
|
11
12
|
"prepare": "node ../../preinstall.js",
|
|
@@ -46,7 +47,6 @@
|
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
49
|
"@babel/runtime": "^7.20.13",
|
|
49
|
-
"@botonic/core": "^0.21.0",
|
|
50
50
|
"@botonic/react": "^0.21.0",
|
|
51
51
|
"axios": "^1.3.3"
|
|
52
52
|
}
|
package/src/action.tsx
CHANGED
|
@@ -53,10 +53,7 @@ export default class FlowBuilderAction extends React.Component<FlowBuilderAction
|
|
|
53
53
|
// @ts-ignore
|
|
54
54
|
return <Text>{handoffMsg}</Text>
|
|
55
55
|
} else {
|
|
56
|
-
return contents!.map((content, index) =>
|
|
57
|
-
console.log({ content, index })
|
|
58
|
-
return content.toBotonic(index)
|
|
59
|
-
})
|
|
56
|
+
return contents!.map((content, index) => content.toBotonic(index))
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
59
|
}
|