bibot 1.0.21 → 1.0.23
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/dist/component/Avatar.d.ts +1 -0
- package/dist/component/Icons.d.ts +4 -1
- package/dist/index.js +46 -55
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +46 -55
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
@@ -1,5 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
|
2
|
+
interface iconColor {
|
3
|
+
color: string | undefined;
|
4
|
+
}
|
5
|
+
declare function SendMessageIcon({ color }: iconColor): React.JSX.Element;
|
3
6
|
declare function DefaultBotProfile(): React.JSX.Element;
|
4
7
|
declare function ChatIcon(): React.JSX.Element;
|
5
8
|
declare function CloseIcon(): React.JSX.Element;
|
package/dist/index.js
CHANGED
@@ -3520,64 +3520,49 @@ var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(p
|
|
3520
3520
|
return Promise.reject(e);
|
3521
3521
|
}
|
3522
3522
|
};
|
3523
|
+
var handleRetries = function handleRetries(data, attempt) {
|
3524
|
+
try {
|
3525
|
+
var maxAttempts = 30;
|
3526
|
+
var delay = 10000;
|
3527
|
+
if (attempt >= maxAttempts) {
|
3528
|
+
return Promise.resolve("Sorry this is taking longer than usual. Please try again later");
|
3529
|
+
}
|
3530
|
+
return Promise.resolve(new Promise(function (resolve) {
|
3531
|
+
return setTimeout(resolve, delay);
|
3532
|
+
})).then(function () {
|
3533
|
+
return _catch(function () {
|
3534
|
+
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3535
|
+
tries: attempt + 1
|
3536
|
+
}))).then(function (message) {
|
3537
|
+
if (message === defaultSlacker) {
|
3538
|
+
return Promise.resolve(handleRetries(data, attempt + 1));
|
3539
|
+
} else {
|
3540
|
+
return message;
|
3541
|
+
}
|
3542
|
+
});
|
3543
|
+
}, function (error) {
|
3544
|
+
return error.message;
|
3545
|
+
});
|
3546
|
+
});
|
3547
|
+
} catch (e) {
|
3548
|
+
return Promise.reject(e);
|
3549
|
+
}
|
3550
|
+
};
|
3523
3551
|
var askBiBot = function askBiBot(data) {
|
3524
3552
|
try {
|
3525
3553
|
return Promise.resolve(_catch(function () {
|
3526
3554
|
var path = "" + domain.inference + resources.q;
|
3527
3555
|
return Promise.resolve(pluginAxiosInstance.post(path, data)).then(function (response) {
|
3528
3556
|
if (response.data.message === defaultSlacker) {
|
3529
|
-
return
|
3530
|
-
return Promise.resolve(new Promise(function (resolve) {
|
3531
|
-
return setTimeout(resolve, 6000);
|
3532
|
-
})).then(function () {
|
3533
|
-
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3534
|
-
tries: 2
|
3535
|
-
})));
|
3536
|
-
});
|
3537
|
-
}, function (error2) {
|
3538
|
-
if (error2.code === 'ECONNABORTED' || error2.message.includes('Endpoint request timed out')) {
|
3539
|
-
return _catch(function () {
|
3540
|
-
return Promise.resolve(new Promise(function (resolve) {
|
3541
|
-
return setTimeout(resolve, 6000);
|
3542
|
-
})).then(function () {
|
3543
|
-
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3544
|
-
tries: 3
|
3545
|
-
})));
|
3546
|
-
});
|
3547
|
-
}, function (error3) {
|
3548
|
-
return error3.message;
|
3549
|
-
});
|
3550
|
-
} else {
|
3551
|
-
return error2.message;
|
3552
|
-
}
|
3553
|
-
});
|
3557
|
+
return Promise.resolve(handleRetries(data, 1));
|
3554
3558
|
} else {
|
3555
3559
|
return response.data.message;
|
3556
3560
|
}
|
3557
3561
|
});
|
3558
3562
|
}, function (error1) {
|
3563
|
+
console.log('This is the error1 from the endpoint on the 1st try:', error1);
|
3559
3564
|
console.log(error1.message);
|
3560
|
-
|
3561
|
-
return _catch(function () {
|
3562
|
-
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3563
|
-
tries: 2
|
3564
|
-
})));
|
3565
|
-
}, function (error2) {
|
3566
|
-
if (error2.code === 'ECONNABORTED' || error2.message.includes('Endpoint request timed out')) {
|
3567
|
-
return _catch(function () {
|
3568
|
-
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3569
|
-
tries: 3
|
3570
|
-
})));
|
3571
|
-
}, function (error3) {
|
3572
|
-
return error3.message;
|
3573
|
-
});
|
3574
|
-
} else {
|
3575
|
-
return error2.message;
|
3576
|
-
}
|
3577
|
-
});
|
3578
|
-
} else {
|
3579
|
-
return error1.message;
|
3580
|
-
}
|
3565
|
+
return error1.message;
|
3581
3566
|
}));
|
3582
3567
|
} catch (e) {
|
3583
3568
|
return Promise.reject(e);
|
@@ -3599,7 +3584,7 @@ var askTimedOutBiBot = function askTimedOutBiBot(data) {
|
|
3599
3584
|
return Promise.reject(e);
|
3600
3585
|
}
|
3601
3586
|
};
|
3602
|
-
var defaultSlacker = "
|
3587
|
+
var defaultSlacker = "BiBot_Retry_Later";
|
3603
3588
|
var pluginAxiosInstance = createPluginAxiosInstance();
|
3604
3589
|
|
3605
3590
|
var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
@@ -3744,7 +3729,8 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3744
3729
|
|
3745
3730
|
var styles = {"chat-bubble":"_31at8","chat-toggle":"_1tkAI","chat-window":"_2vdWr","chat-header":"_1ngBE","message-list":"_27MrF","message":"_3XbXj","user":"_3l8QX","bot":"_1MqZg","loader":"_3mrL1","l5":"_25GkQ","input-area":"_6V_kl","loading-bubbles":"_1XTQS","bubble":"_32ZvK","bounce":"_V8DEW"};
|
3746
3731
|
|
3747
|
-
function SendMessageIcon() {
|
3732
|
+
function SendMessageIcon(_ref) {
|
3733
|
+
var color = _ref.color;
|
3748
3734
|
return React__default.createElement("svg", {
|
3749
3735
|
xmlns: 'http://www.w3.org/2000/svg',
|
3750
3736
|
className: 'icon icon-tabler icon-tabler-send-2',
|
@@ -3752,7 +3738,7 @@ function SendMessageIcon() {
|
|
3752
3738
|
height: '24',
|
3753
3739
|
viewBox: '0 0 24 24',
|
3754
3740
|
"stroke-width": '1.5',
|
3755
|
-
stroke:
|
3741
|
+
stroke: color,
|
3756
3742
|
fill: 'none',
|
3757
3743
|
"stroke-linecap": 'round',
|
3758
3744
|
"stroke-linejoin": 'round'
|
@@ -3849,7 +3835,8 @@ var Avatar = function Avatar(_ref) {
|
|
3849
3835
|
var source = _ref.source,
|
3850
3836
|
height = _ref.height,
|
3851
3837
|
width = _ref.width,
|
3852
|
-
indicator = _ref.indicator
|
3838
|
+
indicator = _ref.indicator,
|
3839
|
+
borderColor = _ref.borderColor;
|
3853
3840
|
return React__default.createElement("div", {
|
3854
3841
|
style: {
|
3855
3842
|
width: width
|
@@ -3857,7 +3844,7 @@ var Avatar = function Avatar(_ref) {
|
|
3857
3844
|
}, React__default.createElement("div", {
|
3858
3845
|
style: {
|
3859
3846
|
backgroundColor: 'transparent',
|
3860
|
-
border:
|
3847
|
+
border: "1px solid " + borderColor,
|
3861
3848
|
height: height,
|
3862
3849
|
width: width,
|
3863
3850
|
borderRadius: '50%',
|
@@ -3954,7 +3941,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
3954
3941
|
style: {
|
3955
3942
|
backgroundColor: '#dfdfdf',
|
3956
3943
|
position: 'absolute',
|
3957
|
-
bottom: '
|
3944
|
+
bottom: '60px',
|
3958
3945
|
right: '25px',
|
3959
3946
|
width: 350,
|
3960
3947
|
height: 500,
|
@@ -3984,6 +3971,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
3984
3971
|
fontWeight: 'bold'
|
3985
3972
|
}
|
3986
3973
|
}, React.createElement(Avatar, {
|
3974
|
+
borderColor: isLoading ? '#fff' : chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color,
|
3987
3975
|
indicator: isOnline ? 'green' : '#dedede',
|
3988
3976
|
width: '40px',
|
3989
3977
|
height: '40px',
|
@@ -4043,6 +4031,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4043
4031
|
display: 'flex'
|
4044
4032
|
}
|
4045
4033
|
}, React.createElement(Avatar, {
|
4034
|
+
borderColor: isLoading ? '#fff' : chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color,
|
4046
4035
|
width: '20px',
|
4047
4036
|
height: '20px',
|
4048
4037
|
source: chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.logo_url
|
@@ -4077,11 +4066,11 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4077
4066
|
style: {
|
4078
4067
|
display: 'flex',
|
4079
4068
|
alignItems: 'center',
|
4080
|
-
borderTop: '1px solid #
|
4069
|
+
borderTop: '1px solid #b6b6b6',
|
4081
4070
|
padding: 10,
|
4082
4071
|
borderBottomLeftRadius: 8,
|
4083
4072
|
borderBottomRightRadius: 8,
|
4084
|
-
backgroundColor: '#
|
4073
|
+
backgroundColor: '#dedede'
|
4085
4074
|
}
|
4086
4075
|
}, React.createElement("input", {
|
4087
4076
|
style: {
|
@@ -4108,7 +4097,9 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4108
4097
|
cursor: 'pointer'
|
4109
4098
|
},
|
4110
4099
|
onClick: sendInputInquiry
|
4111
|
-
}, React.createElement(SendMessageIcon,
|
4100
|
+
}, React.createElement(SendMessageIcon, {
|
4101
|
+
color: isLoading ? '#fff' : chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color
|
4102
|
+
})))), React.createElement("button", {
|
4112
4103
|
onClick: toggleChat,
|
4113
4104
|
className: styles['chat-toggle'],
|
4114
4105
|
style: {
|