@servicetitan/titan-chatbot-api 7.1.1 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/api-client/__mocks__/chatbot-api-client.mock.js +21 -47
- package/dist/api-client/__mocks__/chatbot-api-client.mock.js.map +1 -1
- package/dist/api-client/base/chatbot-api-client.js +3 -4
- package/dist/api-client/base/chatbot-api-client.js.map +1 -1
- package/dist/api-client/help-center/__tests__/converter-from-models.test.js +48 -15
- package/dist/api-client/help-center/__tests__/converter-from-models.test.js.map +1 -1
- package/dist/api-client/help-center/__tests__/converter-to-models.test.js +23 -22
- package/dist/api-client/help-center/__tests__/converter-to-models.test.js.map +1 -1
- package/dist/api-client/help-center/chatbot-api-client.js +51 -52
- package/dist/api-client/help-center/chatbot-api-client.js.map +1 -1
- package/dist/api-client/help-center/converter-from-models.js +15 -12
- package/dist/api-client/help-center/converter-from-models.js.map +1 -1
- package/dist/api-client/help-center/converter-to-models.js +29 -26
- package/dist/api-client/help-center/converter-to-models.js.map +1 -1
- package/dist/api-client/help-center/index.d.ts +2 -1
- package/dist/api-client/help-center/index.d.ts.map +1 -1
- package/dist/api-client/help-center/index.js +1 -0
- package/dist/api-client/help-center/index.js.map +1 -1
- package/dist/api-client/help-center/native-client.js +1192 -2884
- package/dist/api-client/help-center/native-client.js.map +1 -1
- package/dist/api-client/index.d.ts +2 -1
- package/dist/api-client/index.d.ts.map +1 -1
- package/dist/api-client/index.js +14 -7
- package/dist/api-client/index.js.map +1 -1
- package/dist/api-client/models/__mocks__/models.mock.js +154 -124
- package/dist/api-client/models/__mocks__/models.mock.js.map +1 -1
- package/dist/api-client/models/index.d.ts +2 -1
- package/dist/api-client/models/index.d.ts.map +1 -1
- package/dist/api-client/models/index.js +8 -7
- package/dist/api-client/models/index.js.map +1 -1
- package/dist/api-client/titan-chat/__tests__/native-client.test.js +6 -6
- package/dist/api-client/titan-chat/__tests__/native-client.test.js.map +1 -1
- package/dist/api-client/titan-chat/chatbot-api-client.js +40 -35
- package/dist/api-client/titan-chat/chatbot-api-client.js.map +1 -1
- package/dist/api-client/titan-chat/index.d.ts +2 -1
- package/dist/api-client/titan-chat/index.d.ts.map +1 -1
- package/dist/api-client/titan-chat/index.js +1 -0
- package/dist/api-client/titan-chat/index.js.map +1 -1
- package/dist/api-client/titan-chat/native-client.d.ts +14 -14
- package/dist/api-client/titan-chat/native-client.d.ts.map +1 -1
- package/dist/api-client/titan-chat/native-client.js +359 -809
- package/dist/api-client/titan-chat/native-client.js.map +1 -1
- package/dist/api-client/utils/__tests__/model-utils.test.js +454 -191
- package/dist/api-client/utils/__tests__/model-utils.test.js.map +1 -1
- package/dist/api-client/utils/model-utils.d.ts.map +1 -1
- package/dist/api-client/utils/model-utils.js +28 -25
- package/dist/api-client/utils/model-utils.js.map +1 -1
- package/dist/hooks/use-customization-chatbot.js +2 -1
- package/dist/hooks/use-customization-chatbot.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/models/chatbot-customizations.js +2 -1
- package/dist/models/chatbot-customizations.js.map +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +2 -1
- package/dist/models/index.js.map +1 -1
- package/dist/stores/__tests__/chatbot-ui-backend.store.test.js +267 -172
- package/dist/stores/__tests__/chatbot-ui-backend.store.test.js.map +1 -1
- package/dist/stores/__tests__/chatbot-ui.store.test.js +61 -64
- package/dist/stores/__tests__/chatbot-ui.store.test.js.map +1 -1
- package/dist/stores/__tests__/filter.store.test.js +243 -116
- package/dist/stores/__tests__/filter.store.test.js.map +1 -1
- package/dist/stores/__tests__/initialize.store.test.js +9 -8
- package/dist/stores/__tests__/initialize.store.test.js.map +1 -1
- package/dist/stores/__tests__/message-feedback-guardrail.store.test.js +8 -7
- package/dist/stores/__tests__/message-feedback-guardrail.store.test.js.map +1 -1
- package/dist/stores/__tests__/message-feedback.store.test.js +34 -27
- package/dist/stores/__tests__/message-feedback.store.test.js.map +1 -1
- package/dist/stores/__tests__/session-feedback.store.test.js +9 -8
- package/dist/stores/__tests__/session-feedback.store.test.js.map +1 -1
- package/dist/stores/chatbot-ui-backend.store.js +171 -240
- package/dist/stores/chatbot-ui-backend.store.js.map +1 -1
- package/dist/stores/chatbot-ui.store.js +73 -46
- package/dist/stores/chatbot-ui.store.js.map +1 -1
- package/dist/stores/filter.store.js +298 -378
- package/dist/stores/filter.store.js.map +1 -1
- package/dist/stores/index.d.ts +5 -3
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +3 -2
- package/dist/stores/index.js.map +1 -1
- package/dist/stores/initialize.store.js +55 -51
- package/dist/stores/initialize.store.js.map +1 -1
- package/dist/stores/message-feedback-base.store.js +2 -1
- package/dist/stores/message-feedback-base.store.js.map +1 -1
- package/dist/stores/message-feedback-guardrail.store.js +50 -47
- package/dist/stores/message-feedback-guardrail.store.js.map +1 -1
- package/dist/stores/message-feedback.store.js +84 -89
- package/dist/stores/message-feedback.store.js.map +1 -1
- package/dist/stores/session-feedback.store.js +46 -39
- package/dist/stores/session-feedback.store.js.map +1 -1
- package/dist/utils/__tests__/axios-utils.test.js +8 -7
- package/dist/utils/__tests__/axios-utils.test.js.map +1 -1
- package/dist/utils/axios-utils.js +9 -7
- package/dist/utils/axios-utils.js.map +1 -1
- package/dist/utils/test-utils.js +5 -5
- package/dist/utils/test-utils.js.map +1 -1
- package/package.json +3 -3
- package/src/api-client/help-center/index.ts +2 -1
- package/src/api-client/help-center/native-client.ts +4 -4
- package/src/api-client/index.ts +2 -6
- package/src/api-client/models/index.ts +15 -13
- package/src/api-client/titan-chat/index.ts +2 -1
- package/src/api-client/titan-chat/native-client.ts +17 -14
- package/src/api-client/utils/model-utils.ts +4 -8
- package/src/index.ts +1 -1
- package/src/models/index.ts +1 -1
- package/src/stores/index.ts +5 -12
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,86 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for
|
|
17
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
18
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
}
|
|
7
|
-
|
|
19
|
+
}
|
|
20
|
+
function _ts_metadata(k, v) {
|
|
8
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return function
|
|
12
|
-
|
|
22
|
+
}
|
|
23
|
+
function _ts_param(paramIndex, decorator) {
|
|
24
|
+
return function(target, key) {
|
|
25
|
+
decorator(target, key, paramIndex);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
13
28
|
import { inject, injectable } from '@servicetitan/react-ioc';
|
|
14
29
|
import { FieldState, FormState } from 'formstate';
|
|
15
30
|
import { action, computed, makeObservable, observable } from 'mobx';
|
|
16
31
|
import { Models } from '../api-client';
|
|
17
|
-
import { CHATBOT_UI_STORE_TOKEN } from './chatbot-ui.store';
|
|
18
|
-
|
|
32
|
+
import { CHATBOT_UI_STORE_TOKEN, IChatbotUiStore } from './chatbot-ui.store';
|
|
33
|
+
export class MessageFeedbackStore {
|
|
19
34
|
get isCommentAlwaysRequired() {
|
|
20
|
-
var
|
|
21
|
-
|
|
35
|
+
var _ref;
|
|
36
|
+
var _this_chatbotUiStore_customizations_feedback;
|
|
37
|
+
return (_ref = (_this_chatbotUiStore_customizations_feedback = this.chatbotUiStore.customizations.feedback) === null || _this_chatbotUiStore_customizations_feedback === void 0 ? void 0 : _this_chatbotUiStore_customizations_feedback.isCommentAlwaysRequired) !== null && _ref !== void 0 ? _ref : false;
|
|
22
38
|
}
|
|
23
39
|
get isTextAreaVisible() {
|
|
24
40
|
return this.isCommentAlwaysRequired || this.formState.$.other.value;
|
|
25
41
|
}
|
|
26
42
|
get isValid() {
|
|
27
|
-
return
|
|
28
|
-
this.formState.$.unclear.value ||
|
|
29
|
-
this.formState.$.notFull.value ||
|
|
30
|
-
this.formState.$.incorrect.value ||
|
|
31
|
-
this.formState.$.other.value);
|
|
32
|
-
}
|
|
33
|
-
constructor(chatbotUiStore) {
|
|
34
|
-
Object.defineProperty(this, "chatbotUiStore", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true,
|
|
38
|
-
value: chatbotUiStore
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(this, "formState", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
configurable: true,
|
|
43
|
-
writable: true,
|
|
44
|
-
value: void 0
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(this, "createFormState", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
writable: true,
|
|
50
|
-
value: () => {
|
|
51
|
-
const formState = new FormState({
|
|
52
|
-
unrelated: new FieldState(false),
|
|
53
|
-
unclear: new FieldState(false),
|
|
54
|
-
notFull: new FieldState(false),
|
|
55
|
-
incorrect: new FieldState(false),
|
|
56
|
-
other: new FieldState(false),
|
|
57
|
-
otherComment: new FieldState('')
|
|
58
|
-
.validators($ => {
|
|
59
|
-
if (this.isCommentAlwaysRequired) {
|
|
60
|
-
// Internal users can't submit empty feedback
|
|
61
|
-
return $ ? false : 'Enter details.';
|
|
62
|
-
}
|
|
63
|
-
// External users can submit empty feedback if "Other" is not selected
|
|
64
|
-
if (!this.formState.$.other.value) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return $ ? false : 'Enter details.';
|
|
68
|
-
})
|
|
69
|
-
.disableAutoValidation(),
|
|
70
|
-
}).validators($ => {
|
|
71
|
-
const nothingSelected = !$.unrelated.value &&
|
|
72
|
-
!$.unclear.value &&
|
|
73
|
-
!$.notFull.value &&
|
|
74
|
-
!$.incorrect.value &&
|
|
75
|
-
!$.other.value;
|
|
76
|
-
return nothingSelected ? 'At least one item has to be selected.' : false;
|
|
77
|
-
});
|
|
78
|
-
formState.disableAutoValidation();
|
|
79
|
-
return formState;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
this.formState = this.createFormState();
|
|
83
|
-
makeObservable(this);
|
|
43
|
+
return this.formState.$.unrelated.value || this.formState.$.unclear.value || this.formState.$.notFull.value || this.formState.$.incorrect.value || this.formState.$.other.value;
|
|
84
44
|
}
|
|
85
45
|
export() {
|
|
86
46
|
const fs = this.formState.$;
|
|
@@ -102,41 +62,76 @@ let MessageFeedbackStore = class MessageFeedbackStore {
|
|
|
102
62
|
}
|
|
103
63
|
const feedback = {
|
|
104
64
|
rating: Models.FeedbackRatings.ThumbsDown,
|
|
105
|
-
options
|
|
65
|
+
options
|
|
106
66
|
};
|
|
107
67
|
if (fs.otherComment.value) {
|
|
108
68
|
feedback.description = fs.otherComment.value;
|
|
109
69
|
}
|
|
110
70
|
return feedback;
|
|
111
71
|
}
|
|
112
|
-
|
|
113
|
-
|
|
72
|
+
constructor(chatbotUiStore){
|
|
73
|
+
_define_property(this, "chatbotUiStore", void 0);
|
|
74
|
+
_define_property(this, "formState", void 0);
|
|
75
|
+
_define_property(this, "createFormState", void 0);
|
|
76
|
+
this.chatbotUiStore = chatbotUiStore;
|
|
77
|
+
this.createFormState = ()=>{
|
|
78
|
+
const formState = new FormState({
|
|
79
|
+
unrelated: new FieldState(false),
|
|
80
|
+
unclear: new FieldState(false),
|
|
81
|
+
notFull: new FieldState(false),
|
|
82
|
+
incorrect: new FieldState(false),
|
|
83
|
+
other: new FieldState(false),
|
|
84
|
+
otherComment: new FieldState('').validators(($)=>{
|
|
85
|
+
if (this.isCommentAlwaysRequired) {
|
|
86
|
+
// Internal users can't submit empty feedback
|
|
87
|
+
return $ ? false : 'Enter details.';
|
|
88
|
+
}
|
|
89
|
+
// External users can submit empty feedback if "Other" is not selected
|
|
90
|
+
if (!this.formState.$.other.value) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return $ ? false : 'Enter details.';
|
|
94
|
+
}).disableAutoValidation()
|
|
95
|
+
}).validators(($)=>{
|
|
96
|
+
const nothingSelected = !$.unrelated.value && !$.unclear.value && !$.notFull.value && !$.incorrect.value && !$.other.value;
|
|
97
|
+
return nothingSelected ? 'At least one item has to be selected.' : false;
|
|
98
|
+
});
|
|
99
|
+
formState.disableAutoValidation();
|
|
100
|
+
return formState;
|
|
101
|
+
};
|
|
102
|
+
this.formState = this.createFormState();
|
|
103
|
+
makeObservable(this);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
_ts_decorate([
|
|
114
107
|
observable,
|
|
115
|
-
|
|
108
|
+
_ts_metadata("design:type", typeof MessageFeedbackFormState === "undefined" ? Object : MessageFeedbackFormState)
|
|
116
109
|
], MessageFeedbackStore.prototype, "formState", void 0);
|
|
117
|
-
|
|
110
|
+
_ts_decorate([
|
|
118
111
|
computed,
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
_ts_metadata("design:type", void 0),
|
|
113
|
+
_ts_metadata("design:paramtypes", [])
|
|
121
114
|
], MessageFeedbackStore.prototype, "isCommentAlwaysRequired", null);
|
|
122
|
-
|
|
115
|
+
_ts_decorate([
|
|
123
116
|
computed,
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
_ts_metadata("design:type", void 0),
|
|
118
|
+
_ts_metadata("design:paramtypes", [])
|
|
126
119
|
], MessageFeedbackStore.prototype, "isTextAreaVisible", null);
|
|
127
|
-
|
|
120
|
+
_ts_decorate([
|
|
128
121
|
computed,
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
_ts_metadata("design:type", void 0),
|
|
123
|
+
_ts_metadata("design:paramtypes", [])
|
|
131
124
|
], MessageFeedbackStore.prototype, "isValid", null);
|
|
132
|
-
|
|
133
|
-
action
|
|
134
|
-
__metadata("design:type", Object)
|
|
125
|
+
_ts_decorate([
|
|
126
|
+
action
|
|
135
127
|
], MessageFeedbackStore.prototype, "createFormState", void 0);
|
|
136
|
-
MessageFeedbackStore =
|
|
128
|
+
MessageFeedbackStore = _ts_decorate([
|
|
137
129
|
injectable(),
|
|
138
|
-
|
|
139
|
-
|
|
130
|
+
_ts_param(0, inject(CHATBOT_UI_STORE_TOKEN)),
|
|
131
|
+
_ts_metadata("design:type", Function),
|
|
132
|
+
_ts_metadata("design:paramtypes", [
|
|
133
|
+
typeof IChatbotUiStore === "undefined" ? Object : IChatbotUiStore
|
|
134
|
+
])
|
|
140
135
|
], MessageFeedbackStore);
|
|
141
|
-
|
|
136
|
+
|
|
142
137
|
//# sourceMappingURL=message-feedback.store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/stores/message-feedback.store.ts"],"sourcesContent":["import { inject, injectable } from '@servicetitan/react-ioc';\nimport { FieldState, FormState } from 'formstate';\nimport { action, computed, makeObservable, observable } from 'mobx';\nimport { Models } from '../api-client';\nimport { CHATBOT_UI_STORE_TOKEN, IChatbotUiStore } from './chatbot-ui.store';\nimport { FeedbackDraft, IMessageFeedbackBaseStore } from './message-feedback-base.store';\n\nexport type MessageFeedbackFormState = FormState<{\n unrelated: FieldState<boolean>;\n unclear: FieldState<boolean>;\n notFull: FieldState<boolean>;\n incorrect: FieldState<boolean>;\n other: FieldState<boolean>;\n otherComment: FieldState<string>;\n}>;\n\n@injectable()\nexport class MessageFeedbackStore implements IMessageFeedbackBaseStore<MessageFeedbackFormState> {\n @observable formState!: MessageFeedbackFormState;\n\n @computed get isCommentAlwaysRequired() {\n return this.chatbotUiStore.customizations.feedback?.isCommentAlwaysRequired ?? false;\n }\n\n @computed get isTextAreaVisible() {\n return this.isCommentAlwaysRequired || this.formState.$.other.value;\n }\n\n @computed get isValid() {\n return (\n this.formState.$.unrelated.value ||\n this.formState.$.unclear.value ||\n this.formState.$.notFull.value ||\n this.formState.$.incorrect.value ||\n this.formState.$.other.value\n );\n }\n\n constructor(@inject(CHATBOT_UI_STORE_TOKEN) private readonly chatbotUiStore: IChatbotUiStore) {\n this.formState = this.createFormState();\n makeObservable(this);\n }\n\n export(): FeedbackDraft {\n const fs = this.formState.$;\n const options: Models.FeedbackOptions[] = [];\n if (fs.unrelated.value) {\n options.push(Models.FeedbackOptions.Unrelated);\n }\n if (fs.unclear.value) {\n options.push(Models.FeedbackOptions.Unclear);\n }\n if (fs.notFull.value) {\n options.push(Models.FeedbackOptions.Incomplete);\n }\n if (fs.incorrect.value) {\n options.push(Models.FeedbackOptions.Incorrect);\n }\n if (fs.other.value) {\n options.push(Models.FeedbackOptions.Other);\n }\n const feedback: FeedbackDraft = {\n rating: Models.FeedbackRatings.ThumbsDown,\n options,\n };\n if (fs.otherComment.value) {\n feedback.description = fs.otherComment.value;\n }\n return feedback;\n }\n\n @action\n private createFormState = (): MessageFeedbackFormState => {\n const formState = new FormState({\n unrelated: new FieldState(false),\n unclear: new FieldState(false),\n notFull: new FieldState(false),\n incorrect: new FieldState(false),\n other: new FieldState(false),\n otherComment: new FieldState('')\n .validators($ => {\n if (this.isCommentAlwaysRequired) {\n // Internal users can't submit empty feedback\n return $ ? false : 'Enter details.';\n }\n // External users can submit empty feedback if \"Other\" is not selected\n if (!this.formState.$.other.value) {\n return false;\n }\n return $ ? false : 'Enter details.';\n })\n .disableAutoValidation(),\n }).validators($ => {\n const nothingSelected =\n !$.unrelated.value &&\n !$.unclear.value &&\n !$.notFull.value &&\n !$.incorrect.value &&\n !$.other.value;\n return nothingSelected ? 'At least one item has to be selected.' : false;\n });\n formState.disableAutoValidation();\n return formState;\n };\n}\n"],"names":["inject","injectable","FieldState","FormState","action","computed","makeObservable","observable","Models","CHATBOT_UI_STORE_TOKEN","IChatbotUiStore","MessageFeedbackStore","isCommentAlwaysRequired","chatbotUiStore","customizations","feedback","isTextAreaVisible","formState","$","other","value","isValid","unrelated","unclear","notFull","incorrect","export","fs","options","push","FeedbackOptions","Unrelated","Unclear","Incomplete","Incorrect","Other","rating","FeedbackRatings","ThumbsDown","otherComment","description","createFormState","validators","disableAutoValidation","nothingSelected"],"mappings":"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"}
|
|
@@ -1,26 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for
|
|
17
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
18
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
}
|
|
7
|
-
|
|
19
|
+
}
|
|
20
|
+
function _ts_metadata(k, v) {
|
|
8
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
}
|
|
22
|
+
}
|
|
10
23
|
import { injectable } from '@servicetitan/react-ioc';
|
|
11
24
|
import { FieldState, FormState } from 'formstate';
|
|
12
25
|
import { computed, makeObservable, observable } from 'mobx';
|
|
13
26
|
import { Models } from '../api-client';
|
|
14
|
-
|
|
27
|
+
import { FeedbackDraft } from './message-feedback-base.store';
|
|
28
|
+
export class SessionFeedbackStore {
|
|
15
29
|
get isValid() {
|
|
16
30
|
return this.formState.$.thumbs.value !== 0;
|
|
17
31
|
}
|
|
18
32
|
get feedback() {
|
|
19
33
|
return {
|
|
20
|
-
rating: this.formState.$.thumbs.value > 0
|
|
21
|
-
|
|
22
|
-
: Models.FeedbackRatings.ThumbsDown,
|
|
23
|
-
description: this.formState.$.comment.value || undefined,
|
|
34
|
+
rating: this.formState.$.thumbs.value > 0 ? Models.FeedbackRatings.ThumbsUp : Models.FeedbackRatings.ThumbsDown,
|
|
35
|
+
description: this.formState.$.comment.value || undefined
|
|
24
36
|
};
|
|
25
37
|
}
|
|
26
38
|
get isThumbsUp() {
|
|
@@ -29,46 +41,41 @@ let SessionFeedbackStore = class SessionFeedbackStore {
|
|
|
29
41
|
get isThumbsDown() {
|
|
30
42
|
return this.formState.$.thumbs.value < 0;
|
|
31
43
|
}
|
|
32
|
-
constructor()
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
value: new FormState({
|
|
38
|
-
thumbs: new FieldState(0),
|
|
39
|
-
comment: new FieldState(''),
|
|
40
|
-
})
|
|
41
|
-
});
|
|
44
|
+
constructor(){
|
|
45
|
+
_define_property(this, "formState", new FormState({
|
|
46
|
+
thumbs: new FieldState(0),
|
|
47
|
+
comment: new FieldState('')
|
|
48
|
+
}));
|
|
42
49
|
makeObservable(this);
|
|
43
50
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
observable
|
|
47
|
-
__metadata("design:type", Object)
|
|
51
|
+
}
|
|
52
|
+
_ts_decorate([
|
|
53
|
+
observable
|
|
48
54
|
], SessionFeedbackStore.prototype, "formState", void 0);
|
|
49
|
-
|
|
55
|
+
_ts_decorate([
|
|
50
56
|
computed,
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
_ts_metadata("design:type", void 0),
|
|
58
|
+
_ts_metadata("design:paramtypes", [])
|
|
53
59
|
], SessionFeedbackStore.prototype, "isValid", null);
|
|
54
|
-
|
|
60
|
+
_ts_decorate([
|
|
55
61
|
computed,
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
_ts_metadata("design:type", typeof FeedbackDraft === "undefined" ? Object : FeedbackDraft),
|
|
63
|
+
_ts_metadata("design:paramtypes", [])
|
|
58
64
|
], SessionFeedbackStore.prototype, "feedback", null);
|
|
59
|
-
|
|
65
|
+
_ts_decorate([
|
|
60
66
|
computed,
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
_ts_metadata("design:type", void 0),
|
|
68
|
+
_ts_metadata("design:paramtypes", [])
|
|
63
69
|
], SessionFeedbackStore.prototype, "isThumbsUp", null);
|
|
64
|
-
|
|
70
|
+
_ts_decorate([
|
|
65
71
|
computed,
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
_ts_metadata("design:type", void 0),
|
|
73
|
+
_ts_metadata("design:paramtypes", [])
|
|
68
74
|
], SessionFeedbackStore.prototype, "isThumbsDown", null);
|
|
69
|
-
SessionFeedbackStore =
|
|
75
|
+
SessionFeedbackStore = _ts_decorate([
|
|
70
76
|
injectable(),
|
|
71
|
-
|
|
77
|
+
_ts_metadata("design:type", Function),
|
|
78
|
+
_ts_metadata("design:paramtypes", [])
|
|
72
79
|
], SessionFeedbackStore);
|
|
73
|
-
|
|
80
|
+
|
|
74
81
|
//# sourceMappingURL=session-feedback.store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/stores/session-feedback.store.ts"],"sourcesContent":["import { injectable } from '@servicetitan/react-ioc';\nimport { FieldState, FormState } from 'formstate';\nimport { computed, makeObservable, observable } from 'mobx';\nimport { Models } from '../api-client';\nimport { FeedbackDraft } from './message-feedback-base.store';\n\n@injectable()\nexport class SessionFeedbackStore {\n @observable\n formState = new FormState({\n thumbs: new FieldState<number>(0),\n comment: new FieldState<string>(''),\n });\n\n @computed\n get isValid() {\n return this.formState.$.thumbs.value !== 0;\n }\n\n @computed\n get feedback(): FeedbackDraft {\n return {\n rating:\n this.formState.$.thumbs.value > 0\n ? Models.FeedbackRatings.ThumbsUp\n : Models.FeedbackRatings.ThumbsDown,\n description: this.formState.$.comment.value || undefined,\n };\n }\n\n @computed\n get isThumbsUp() {\n return this.formState.$.thumbs.value > 0;\n }\n\n @computed\n get isThumbsDown() {\n return this.formState.$.thumbs.value < 0;\n }\n\n constructor() {\n makeObservable(this);\n }\n}\n"],"names":["injectable","FieldState","FormState","computed","makeObservable","observable","Models","FeedbackDraft","SessionFeedbackStore","isValid","formState","$","thumbs","value","feedback","rating","FeedbackRatings","ThumbsUp","ThumbsDown","description","comment","undefined","isThumbsUp","isThumbsDown"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,UAAU,QAAQ,0BAA0B;AACrD,SAASC,UAAU,EAAEC,SAAS,QAAQ,YAAY;AAClD,SAASC,QAAQ,EAAEC,cAAc,EAAEC,UAAU,QAAQ,OAAO;AAC5D,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,aAAa,QAAQ,gCAAgC;AAG9D,OAAO,MAAMC;IAOT,IACIC,UAAU;QACV,OAAO,IAAI,CAACC,SAAS,CAACC,CAAC,CAACC,MAAM,CAACC,KAAK,KAAK;IAC7C;IAEA,IACIC,WAA0B;QAC1B,OAAO;YACHC,QACI,IAAI,CAACL,SAAS,CAACC,CAAC,CAACC,MAAM,CAACC,KAAK,GAAG,IAC1BP,OAAOU,eAAe,CAACC,QAAQ,GAC/BX,OAAOU,eAAe,CAACE,UAAU;YAC3CC,aAAa,IAAI,CAACT,SAAS,CAACC,CAAC,CAACS,OAAO,CAACP,KAAK,IAAIQ;QACnD;IACJ;IAEA,IACIC,aAAa;QACb,OAAO,IAAI,CAACZ,SAAS,CAACC,CAAC,CAACC,MAAM,CAACC,KAAK,GAAG;IAC3C;IAEA,IACIU,eAAe;QACf,OAAO,IAAI,CAACb,SAAS,CAACC,CAAC,CAACC,MAAM,CAACC,KAAK,GAAG;IAC3C;IAEA,aAAc;QAhCd,uBACAH,aAAY,IAAIR,UAAU;YACtBU,QAAQ,IAAIX,WAAmB;YAC/BmB,SAAS,IAAInB,WAAmB;QACpC;QA6BIG,eAAe,IAAI;IACvB;AACJ"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { expect } from '@jest/globals';
|
|
2
2
|
import { withTimeout } from '../axios-utils';
|
|
3
|
-
describe('axios-utils', ()
|
|
4
|
-
beforeEach(()
|
|
3
|
+
describe('axios-utils', ()=>{
|
|
4
|
+
beforeEach(()=>{
|
|
5
5
|
jest.useFakeTimers();
|
|
6
6
|
jest.setSystemTime(new Date('2000-01-01T00:00:00.000Z'));
|
|
7
7
|
});
|
|
8
|
-
afterEach(()
|
|
8
|
+
afterEach(()=>{
|
|
9
9
|
jest.clearAllMocks();
|
|
10
10
|
jest.useRealTimers();
|
|
11
11
|
});
|
|
12
|
-
test('should withTimeout (timeout first)', async ()
|
|
12
|
+
test('should withTimeout (timeout first)', async ()=>{
|
|
13
13
|
const abortController = new AbortController();
|
|
14
14
|
const spyAbort = jest.spyOn(abortController, 'abort');
|
|
15
|
-
const action = new Promise(resolve
|
|
15
|
+
const action = new Promise((resolve)=>setTimeout(()=>resolve('done'), 100));
|
|
16
16
|
const timeoutMs = 50;
|
|
17
17
|
const p = expect(withTimeout(action, timeoutMs, abortController)).rejects.toThrow('The request is timed out');
|
|
18
18
|
await jest.advanceTimersByTimeAsync(50);
|
|
19
19
|
await p;
|
|
20
20
|
expect(spyAbort).toHaveBeenCalledWith('The request is timed out');
|
|
21
21
|
});
|
|
22
|
-
test('should withTimeout (resolves first)', async ()
|
|
22
|
+
test('should withTimeout (resolves first)', async ()=>{
|
|
23
23
|
const abortController = new AbortController();
|
|
24
24
|
const spyAbort = jest.spyOn(abortController, 'abort');
|
|
25
|
-
const action = new Promise(resolve
|
|
25
|
+
const action = new Promise((resolve)=>setTimeout(()=>resolve('done'), 100));
|
|
26
26
|
const timeoutMs = 150;
|
|
27
27
|
const p = expect(withTimeout(action, timeoutMs, abortController)).resolves.toEqual('done');
|
|
28
28
|
await jest.advanceTimersByTimeAsync(100);
|
|
@@ -30,4 +30,5 @@ describe('axios-utils', () => {
|
|
|
30
30
|
expect(spyAbort).not.toHaveBeenCalled();
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
|
+
|
|
33
34
|
//# sourceMappingURL=axios-utils.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/__tests__/axios-utils.test.ts"],"sourcesContent":["import { expect } from '@jest/globals';\nimport { withTimeout } from '../axios-utils';\n\ndescribe('axios-utils', () => {\n beforeEach(() => {\n jest.useFakeTimers();\n jest.setSystemTime(new Date('2000-01-01T00:00:00.000Z'));\n });\n\n afterEach(() => {\n jest.clearAllMocks();\n jest.useRealTimers();\n });\n\n test('should withTimeout (timeout first)', async () => {\n const abortController = new AbortController();\n const spyAbort = jest.spyOn(abortController, 'abort');\n const action = new Promise(resolve => setTimeout(() => resolve('done'), 100));\n const timeoutMs = 50;\n\n const p = expect(withTimeout(action, timeoutMs, abortController)).rejects.toThrow(\n 'The request is timed out'\n );\n await jest.advanceTimersByTimeAsync(50);\n await p;\n expect(spyAbort).toHaveBeenCalledWith('The request is timed out');\n });\n\n test('should withTimeout (resolves first)', async () => {\n const abortController = new AbortController();\n const spyAbort = jest.spyOn(abortController, 'abort');\n const action = new Promise(resolve => setTimeout(() => resolve('done'), 100));\n const timeoutMs = 150;\n\n const p = expect(withTimeout(action, timeoutMs, abortController)).resolves.toEqual('done');\n await jest.advanceTimersByTimeAsync(100);\n await p;\n expect(spyAbort).not.toHaveBeenCalled();\n });\n});\n"],"names":["expect","withTimeout","describe","beforeEach","jest","useFakeTimers","setSystemTime","Date","afterEach","clearAllMocks","useRealTimers","test","abortController","AbortController","spyAbort","spyOn","action","Promise","resolve","setTimeout","timeoutMs","p","rejects","toThrow","advanceTimersByTimeAsync","toHaveBeenCalledWith","resolves","toEqual","not","toHaveBeenCalled"],"mappings":"AAAA,SAASA,MAAM,QAAQ,gBAAgB;AACvC,SAASC,WAAW,QAAQ,iBAAiB;AAE7CC,SAAS,eAAe;IACpBC,WAAW;QACPC,KAAKC,aAAa;QAClBD,KAAKE,aAAa,CAAC,IAAIC,KAAK;IAChC;IAEAC,UAAU;QACNJ,KAAKK,aAAa;QAClBL,KAAKM,aAAa;IACtB;IAEAC,KAAK,sCAAsC;QACvC,MAAMC,kBAAkB,IAAIC;QAC5B,MAAMC,WAAWV,KAAKW,KAAK,CAACH,iBAAiB;QAC7C,MAAMI,SAAS,IAAIC,QAAQC,CAAAA,UAAWC,WAAW,IAAMD,QAAQ,SAAS;QACxE,MAAME,YAAY;QAElB,MAAMC,IAAIrB,OAAOC,YAAYe,QAAQI,WAAWR,kBAAkBU,OAAO,CAACC,OAAO,CAC7E;QAEJ,MAAMnB,KAAKoB,wBAAwB,CAAC;QACpC,MAAMH;QACNrB,OAAOc,UAAUW,oBAAoB,CAAC;IAC1C;IAEAd,KAAK,uCAAuC;QACxC,MAAMC,kBAAkB,IAAIC;QAC5B,MAAMC,WAAWV,KAAKW,KAAK,CAACH,iBAAiB;QAC7C,MAAMI,SAAS,IAAIC,QAAQC,CAAAA,UAAWC,WAAW,IAAMD,QAAQ,SAAS;QACxE,MAAME,YAAY;QAElB,MAAMC,IAAIrB,OAAOC,YAAYe,QAAQI,WAAWR,kBAAkBc,QAAQ,CAACC,OAAO,CAAC;QACnF,MAAMvB,KAAKoB,wBAAwB,CAAC;QACpC,MAAMH;QACNrB,OAAOc,UAAUc,GAAG,CAACC,gBAAgB;IACzC;AACJ"}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Aborts the action if it takes longer than the specified timeout.
|
|
3
|
-
*/
|
|
4
|
-
export async function withTimeout(action, timeoutMs, abortController) {
|
|
3
|
+
*/ export async function withTimeout(action, timeoutMs, abortController) {
|
|
5
4
|
let timeoutId = undefined;
|
|
6
|
-
const timeoutPromise = new Promise((_, reject)
|
|
7
|
-
timeoutId = setTimeout(()
|
|
5
|
+
const timeoutPromise = new Promise((_, reject)=>{
|
|
6
|
+
timeoutId = setTimeout(()=>{
|
|
8
7
|
abortController.abort('The request is timed out');
|
|
9
8
|
reject(new Error('The request is timed out'));
|
|
10
9
|
}, timeoutMs);
|
|
11
10
|
});
|
|
12
|
-
const promise = Promise.race([
|
|
11
|
+
const promise = Promise.race([
|
|
12
|
+
action,
|
|
13
|
+
timeoutPromise
|
|
14
|
+
]);
|
|
13
15
|
try {
|
|
14
16
|
return await promise;
|
|
15
|
-
}
|
|
16
|
-
finally {
|
|
17
|
+
} finally{
|
|
17
18
|
if (timeoutId) {
|
|
18
19
|
clearTimeout(timeoutId);
|
|
19
20
|
timeoutId = undefined;
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
}
|
|
24
|
+
|
|
23
25
|
//# sourceMappingURL=axios-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/utils/axios-utils.ts"],"sourcesContent":["/**\n * Aborts the action if it takes longer than the specified timeout.\n */\nexport async function withTimeout<T>(\n action: Promise<T>,\n timeoutMs: number,\n abortController: AbortController\n): Promise<T> {\n let timeoutId: ReturnType<typeof setTimeout> | undefined = undefined;\n const timeoutPromise = new Promise<T>((_, reject) => {\n timeoutId = setTimeout(() => {\n abortController.abort('The request is timed out');\n reject(new Error('The request is timed out'));\n }, timeoutMs);\n });\n const promise = Promise.race([action, timeoutPromise]);\n try {\n return await promise;\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = undefined;\n }\n }\n}\n"],"names":["withTimeout","action","timeoutMs","abortController","timeoutId","undefined","timeoutPromise","Promise","_","reject","setTimeout","abort","Error","promise","race","clearTimeout"],"mappings":"AAAA;;CAEC,GACD,OAAO,eAAeA,YAClBC,MAAkB,EAClBC,SAAiB,EACjBC,eAAgC;IAEhC,IAAIC,YAAuDC;IAC3D,MAAMC,iBAAiB,IAAIC,QAAW,CAACC,GAAGC;QACtCL,YAAYM,WAAW;YACnBP,gBAAgBQ,KAAK,CAAC;YACtBF,OAAO,IAAIG,MAAM;QACrB,GAAGV;IACP;IACA,MAAMW,UAAUN,QAAQO,IAAI,CAAC;QAACb;QAAQK;KAAe;IACrD,IAAI;QACA,OAAO,MAAMO;IACjB,SAAU;QACN,IAAIT,WAAW;YACXW,aAAaX;YACbA,YAAYC;QAChB;IACJ;AACJ"}
|
package/dist/utils/test-utils.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Container } from '@servicetitan/react-ioc';
|
|
2
|
-
export const initTestContainer = (serviceIdentifier, initDependenciesFn)
|
|
2
|
+
export const initTestContainer = (serviceIdentifier, initDependenciesFn)=>{
|
|
3
3
|
const rootContainer = new Container();
|
|
4
4
|
if (Array.isArray(serviceIdentifier)) {
|
|
5
|
-
serviceIdentifier.forEach(identifier
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
5
|
+
serviceIdentifier.forEach((identifier)=>rootContainer.bind(identifier).toSelf());
|
|
6
|
+
} else {
|
|
8
7
|
rootContainer.bind(serviceIdentifier).toSelf();
|
|
9
8
|
}
|
|
10
|
-
return ()
|
|
9
|
+
return ()=>{
|
|
11
10
|
const container = new Container();
|
|
12
11
|
container.parent = rootContainer;
|
|
13
12
|
initDependenciesFn(container);
|
|
14
13
|
return container;
|
|
15
14
|
};
|
|
16
15
|
};
|
|
16
|
+
|
|
17
17
|
//# sourceMappingURL=test-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/utils/test-utils.ts"],"sourcesContent":["import { Container } from '@servicetitan/react-ioc';\n\ntype Newable<T> = new (...args: never[]) => T;\n\nexport const initTestContainer = (\n serviceIdentifier: Newable<unknown> | Newable<unknown>[],\n initDependenciesFn: (container: Container) => void\n) => {\n const rootContainer = new Container();\n if (Array.isArray(serviceIdentifier)) {\n serviceIdentifier.forEach(identifier => rootContainer.bind(identifier).toSelf());\n } else {\n rootContainer.bind(serviceIdentifier).toSelf();\n }\n\n return () => {\n const container = new Container();\n container.parent = rootContainer;\n initDependenciesFn(container);\n return container;\n };\n};\n"],"names":["Container","initTestContainer","serviceIdentifier","initDependenciesFn","rootContainer","Array","isArray","forEach","identifier","bind","toSelf","container","parent"],"mappings":"AAAA,SAASA,SAAS,QAAQ,0BAA0B;AAIpD,OAAO,MAAMC,oBAAoB,CAC7BC,mBACAC;IAEA,MAAMC,gBAAgB,IAAIJ;IAC1B,IAAIK,MAAMC,OAAO,CAACJ,oBAAoB;QAClCA,kBAAkBK,OAAO,CAACC,CAAAA,aAAcJ,cAAcK,IAAI,CAACD,YAAYE,MAAM;IACjF,OAAO;QACHN,cAAcK,IAAI,CAACP,mBAAmBQ,MAAM;IAChD;IAEA,OAAO;QACH,MAAMC,YAAY,IAAIX;QACtBW,UAAUC,MAAM,GAAGR;QACnBD,mBAAmBQ;QACnB,OAAOA;IACX;AACJ,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/titan-chatbot-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Chatbot client API package",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"push:local": "yalc push"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@servicetitan/titan-chat-ui-common": "^
|
|
20
|
+
"@servicetitan/titan-chat-ui-common": "^8.0.0",
|
|
21
21
|
"lodash": "^4.18.1",
|
|
22
22
|
"nanoid": "^5.1.5"
|
|
23
23
|
},
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"cli": {
|
|
43
43
|
"webpack": false
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "3af2e2dd99b7d735dbb763075de074986f866ce3"
|
|
46
46
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { IChatbotClientSettingsHelpCenter } from './chatbot-api-client';
|
|
2
|
+
export { ChatbotApiClient } from './chatbot-api-client';
|
|
@@ -480,7 +480,7 @@ export class ChatClient {
|
|
|
480
480
|
fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
|
|
481
481
|
fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
|
|
482
482
|
}
|
|
483
|
-
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
|
|
483
|
+
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] as string | undefined }), headers: _headers });
|
|
484
484
|
} else if (status !== 200 && status !== 204) {
|
|
485
485
|
const _responseText = response.data;
|
|
486
486
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
@@ -750,7 +750,7 @@ export class ConfigurationClient {
|
|
|
750
750
|
fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
|
|
751
751
|
fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
|
|
752
752
|
}
|
|
753
|
-
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
|
|
753
|
+
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] as string | undefined }), headers: _headers });
|
|
754
754
|
} else if (status !== 200 && status !== 204) {
|
|
755
755
|
const _responseText = response.data;
|
|
756
756
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
@@ -2152,7 +2152,7 @@ export class TestOpsClient {
|
|
|
2152
2152
|
fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
|
|
2153
2153
|
fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
|
|
2154
2154
|
}
|
|
2155
|
-
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
|
|
2155
|
+
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] as string | undefined }), headers: _headers });
|
|
2156
2156
|
} else if (status !== 200 && status !== 204) {
|
|
2157
2157
|
const _responseText = response.data;
|
|
2158
2158
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
@@ -2219,7 +2219,7 @@ export class UserClient {
|
|
|
2219
2219
|
fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
|
|
2220
2220
|
fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
|
|
2221
2221
|
}
|
|
2222
|
-
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
|
|
2222
|
+
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] as string | undefined }), headers: _headers });
|
|
2223
2223
|
} else if (status !== 200 && status !== 204) {
|
|
2224
2224
|
const _responseText = response.data;
|
|
2225
2225
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
package/src/api-client/index.ts
CHANGED
|
@@ -4,9 +4,5 @@ export * as Models from './models';
|
|
|
4
4
|
export * as ModelsMocks from './models/__mocks__/models.mock';
|
|
5
5
|
export * as ClientMocks from './__mocks__/chatbot-api-client.mock';
|
|
6
6
|
export * as ModelsUtils from './utils/model-utils';
|
|
7
|
-
export {
|
|
8
|
-
|
|
9
|
-
IChatbotApiClient,
|
|
10
|
-
CHATBOT_CLIENT_SETTINGS,
|
|
11
|
-
CHATBOT_API_CLIENT,
|
|
12
|
-
} from './base/chatbot-api-client';
|
|
7
|
+
export type { IChatbotClientSettings, IChatbotApiClient } from './base/chatbot-api-client';
|
|
8
|
+
export { CHATBOT_CLIENT_SETTINGS, CHATBOT_API_CLIENT } from './base/chatbot-api-client';
|