@servicetitan/titan-chatbot-api 3.1.2 → 3.1.3
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 +12 -0
- package/dist/stores/message-feedback-guardrail.store.d.ts +4 -4
- package/dist/stores/message-feedback-guardrail.store.d.ts.map +1 -1
- package/dist/stores/message-feedback-guardrail.store.js +21 -9
- package/dist/stores/message-feedback-guardrail.store.js.map +1 -1
- package/dist/stores/message-feedback.store.d.ts +7 -8
- package/dist/stores/message-feedback.store.d.ts.map +1 -1
- package/dist/stores/message-feedback.store.js +17 -18
- package/dist/stores/message-feedback.store.js.map +1 -1
- package/dist/stores/session-feedback.store.d.ts +3 -4
- package/dist/stores/session-feedback.store.d.ts.map +1 -1
- package/dist/stores/session-feedback.store.js +3 -4
- package/dist/stores/session-feedback.store.js.map +1 -1
- package/package.json +5 -7
- package/src/stores/message-feedback-guardrail.store.ts +24 -11
- package/src/stores/message-feedback.store.ts +23 -29
- package/src/stores/session-feedback.store.ts +3 -4
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v3.1.3 (Fri Aug 22 2025)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- SPA-7126: Removed non-compatible with Anvil2 dependencies [#45](https://github.com/servicetitan/titan-chatbot-client/pull/45) ([@AlexYarmolchuk](https://github.com/AlexYarmolchuk))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Alexandr Yarmolchuk ([@AlexYarmolchuk](https://github.com/AlexYarmolchuk))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v3.1.1 (Thu Aug 14 2025)
|
|
2
14
|
|
|
3
15
|
#### 🐛 Bug Fix
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FormState } from 'formstate';
|
|
1
|
+
import { FieldState, FormState } from 'formstate';
|
|
3
2
|
import { Models } from '../api-client';
|
|
4
3
|
import { IMessageFeedbackBaseStore } from './message-feedback-base.store';
|
|
5
4
|
export type FeedbackFormState = FormState<{
|
|
6
|
-
linkUrl:
|
|
7
|
-
comment:
|
|
5
|
+
linkUrl: FieldState<string>;
|
|
6
|
+
comment: FieldState<string>;
|
|
8
7
|
}>;
|
|
9
8
|
export declare class MessageFeedbackGuardrailStore implements IMessageFeedbackBaseStore<FeedbackFormState> {
|
|
10
9
|
formState: FeedbackFormState;
|
|
11
10
|
get isValid(): boolean;
|
|
12
11
|
constructor();
|
|
13
12
|
export(): Models.Feedback;
|
|
13
|
+
getFormErrors(): string[];
|
|
14
14
|
private createFormState;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=message-feedback-guardrail.store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-feedback-guardrail.store.d.ts","sourceRoot":"","sources":["../../src/stores/message-feedback-guardrail.store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"message-feedback-guardrail.store.d.ts","sourceRoot":"","sources":["../../src/stores/message-feedback-guardrail.store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,MAAM,MAAM,iBAAiB,GAAG,SAAS,CAAC;IACtC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC,CAAC;AAEH,qBACa,6BAA8B,YAAW,yBAAyB,CAAC,iBAAiB,CAAC;IAClF,SAAS,EAAG,iBAAiB,CAAC;IAE1C,IAAc,OAAO,YAEpB;;IAOD,MAAM,IAAI,MAAM,CAAC,QAAQ;IAoBzB,aAAa,IAAI,MAAM,EAAE;IAezB,OAAO,CAAC,eAAe,CAYrB;CACL"}
|
|
@@ -7,9 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { InputFieldState, TextAreaFieldState, formStateToJS } from '@servicetitan/form';
|
|
11
10
|
import { injectable } from '@servicetitan/react-ioc';
|
|
12
|
-
import { FormState } from 'formstate';
|
|
11
|
+
import { FieldState, FormState } from 'formstate';
|
|
13
12
|
import { action, computed, makeObservable, observable } from 'mobx';
|
|
14
13
|
import { Models } from '../api-client';
|
|
15
14
|
let MessageFeedbackGuardrailStore = class MessageFeedbackGuardrailStore {
|
|
@@ -29,8 +28,8 @@ let MessageFeedbackGuardrailStore = class MessageFeedbackGuardrailStore {
|
|
|
29
28
|
writable: true,
|
|
30
29
|
value: () => {
|
|
31
30
|
const formState = new FormState({
|
|
32
|
-
linkUrl: new
|
|
33
|
-
comment: new
|
|
31
|
+
linkUrl: new FieldState(''),
|
|
32
|
+
comment: new FieldState(''),
|
|
34
33
|
});
|
|
35
34
|
formState.validators($ => {
|
|
36
35
|
const nothingSelected = !$.linkUrl.value && !$.comment.value;
|
|
@@ -45,24 +44,37 @@ let MessageFeedbackGuardrailStore = class MessageFeedbackGuardrailStore {
|
|
|
45
44
|
makeObservable(this);
|
|
46
45
|
}
|
|
47
46
|
export() {
|
|
48
|
-
const
|
|
47
|
+
const fs = this.formState.$;
|
|
49
48
|
let feedback = {
|
|
50
49
|
rating: Models.FeedbackRatings.GuardrailFeedback,
|
|
51
50
|
};
|
|
52
|
-
if (
|
|
51
|
+
if (fs.linkUrl.value) {
|
|
53
52
|
feedback = {
|
|
54
53
|
...feedback,
|
|
55
|
-
linkUrl:
|
|
54
|
+
linkUrl: fs.linkUrl.value,
|
|
56
55
|
};
|
|
57
56
|
}
|
|
58
|
-
if (
|
|
57
|
+
if (fs.comment.value) {
|
|
59
58
|
feedback = {
|
|
60
59
|
...feedback,
|
|
61
|
-
description:
|
|
60
|
+
description: fs.comment.value,
|
|
62
61
|
};
|
|
63
62
|
}
|
|
64
63
|
return new Models.Feedback(feedback);
|
|
65
64
|
}
|
|
65
|
+
getFormErrors() {
|
|
66
|
+
const errors = [];
|
|
67
|
+
if (this.formState.formError) {
|
|
68
|
+
errors.push(this.formState.formError);
|
|
69
|
+
}
|
|
70
|
+
if (this.formState.$.linkUrl.error) {
|
|
71
|
+
errors.push(this.formState.$.linkUrl.error);
|
|
72
|
+
}
|
|
73
|
+
if (this.formState.$.comment.error) {
|
|
74
|
+
errors.push(this.formState.$.comment.error);
|
|
75
|
+
}
|
|
76
|
+
return errors;
|
|
77
|
+
}
|
|
66
78
|
};
|
|
67
79
|
__decorate([
|
|
68
80
|
observable,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-feedback-guardrail.store.js","sourceRoot":"","sources":["../../src/stores/message-feedback-guardrail.store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"message-feedback-guardrail.store.js","sourceRoot":"","sources":["../../src/stores/message-feedback-guardrail.store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAShC,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAGtC,IAAc,OAAO;QACjB,OAAO,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAA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gBACX,WAAW,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK;aAChC,CAAC;QACN,CAAC;QACD,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED,aAAa;QACT,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CAgBJ,CAAA;AA3De;IAAX,UAAU;;gEAA+B;AAE1C;IAAC,QAAQ;;;4DAER;AA0CO;IADP,MAAM;;sEAaL;AA3DO,6BAA6B;IADzC,UAAU,EAAE;;GACA,6BAA6B,CA4DzC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FormState } from 'formstate';
|
|
1
|
+
import { FieldState, FormState } from 'formstate';
|
|
3
2
|
import { Models } from '../api-client';
|
|
4
3
|
import { IChatbotUiStore } from './chatbot-ui.store';
|
|
5
4
|
import { IMessageFeedbackBaseStore } from './message-feedback-base.store';
|
|
6
5
|
export type MessageFeedbackFormState = FormState<{
|
|
7
|
-
unrelated:
|
|
8
|
-
unclear:
|
|
9
|
-
notFull:
|
|
10
|
-
incorrect:
|
|
11
|
-
other:
|
|
12
|
-
otherComment:
|
|
6
|
+
unrelated: FieldState<boolean>;
|
|
7
|
+
unclear: FieldState<boolean>;
|
|
8
|
+
notFull: FieldState<boolean>;
|
|
9
|
+
incorrect: FieldState<boolean>;
|
|
10
|
+
other: FieldState<boolean>;
|
|
11
|
+
otherComment: FieldState<string>;
|
|
13
12
|
}>;
|
|
14
13
|
export declare class MessageFeedbackStore implements IMessageFeedbackBaseStore<MessageFeedbackFormState> {
|
|
15
14
|
private readonly chatbotUiStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-feedback.store.d.ts","sourceRoot":"","sources":["../../src/stores/message-feedback.store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"message-feedback.store.d.ts","sourceRoot":"","sources":["../../src/stores/message-feedback.store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAA0B,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAAG,SAAS,CAAC;IAC7C,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7B,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7B,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/B,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC3B,YAAY,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;CACpC,CAAC,CAAC;AAEH,qBACa,oBAAqB,YAAW,yBAAyB,CAAC,wBAAwB,CAAC;IAqBhD,OAAO,CAAC,QAAQ,CAAC,cAAc;IApB/D,SAAS,EAAG,wBAAwB,CAAC;IAEjD,IAAc,uBAAuB,YAEpC;IAED,IAAc,iBAAiB,YAE9B;IAED,IAAc,OAAO,YAQpB;gBAE4D,cAAc,EAAE,eAAe;IAK5F,MAAM,IAAI,MAAM,CAAC,SAAS;IAgC1B,OAAO,CAAC,eAAe,CA+BrB;CACL"}
|
|
@@ -10,9 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
|
-
import { CheckboxFieldState, FormValidators, TextAreaFieldState, formStateToJS, } from '@servicetitan/form';
|
|
14
13
|
import { inject, injectable } from '@servicetitan/react-ioc';
|
|
15
|
-
import { FormState } from 'formstate';
|
|
14
|
+
import { FieldState, FormState } from 'formstate';
|
|
16
15
|
import { action, computed, makeObservable, observable } from 'mobx';
|
|
17
16
|
import { Models } from '../api-client';
|
|
18
17
|
import { CHATBOT_UI_STORE_TOKEN } from './chatbot-ui.store';
|
|
@@ -50,22 +49,22 @@ let MessageFeedbackStore = class MessageFeedbackStore {
|
|
|
50
49
|
writable: true,
|
|
51
50
|
value: () => {
|
|
52
51
|
const formState = new FormState({
|
|
53
|
-
unrelated: new
|
|
54
|
-
unclear: new
|
|
55
|
-
notFull: new
|
|
56
|
-
incorrect: new
|
|
57
|
-
other: new
|
|
58
|
-
otherComment: new
|
|
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('')
|
|
59
58
|
.validators($ => {
|
|
60
59
|
if (this.isCommentAlwaysRequired) {
|
|
61
60
|
// Internal users can't submit empty feedback
|
|
62
|
-
return
|
|
61
|
+
return $ ? false : 'Enter details.';
|
|
63
62
|
}
|
|
64
63
|
// External users can submit empty feedback if "Other" is not selected
|
|
65
64
|
if (!this.formState.$.other.value) {
|
|
66
65
|
return false;
|
|
67
66
|
}
|
|
68
|
-
return
|
|
67
|
+
return $ ? false : 'Enter details.';
|
|
69
68
|
})
|
|
70
69
|
.disableAutoValidation(),
|
|
71
70
|
}).validators($ => {
|
|
@@ -84,31 +83,31 @@ let MessageFeedbackStore = class MessageFeedbackStore {
|
|
|
84
83
|
makeObservable(this);
|
|
85
84
|
}
|
|
86
85
|
export() {
|
|
87
|
-
const
|
|
86
|
+
const fs = this.formState.$;
|
|
88
87
|
const options = [];
|
|
89
|
-
if (
|
|
88
|
+
if (fs.unrelated.value) {
|
|
90
89
|
options.push(Models.FeedbackOptions.Unrelated);
|
|
91
90
|
}
|
|
92
|
-
if (
|
|
91
|
+
if (fs.unclear.value) {
|
|
93
92
|
options.push(Models.FeedbackOptions.Unclear);
|
|
94
93
|
}
|
|
95
|
-
if (
|
|
94
|
+
if (fs.notFull.value) {
|
|
96
95
|
options.push(Models.FeedbackOptions.Incomplete);
|
|
97
96
|
}
|
|
98
|
-
if (
|
|
97
|
+
if (fs.incorrect.value) {
|
|
99
98
|
options.push(Models.FeedbackOptions.Incorrect);
|
|
100
99
|
}
|
|
101
|
-
if (
|
|
100
|
+
if (fs.other.value) {
|
|
102
101
|
options.push(Models.FeedbackOptions.Other);
|
|
103
102
|
}
|
|
104
103
|
let feedback = {
|
|
105
104
|
rating: Models.FeedbackRatings.ThumbsDown,
|
|
106
105
|
options,
|
|
107
106
|
};
|
|
108
|
-
if (
|
|
107
|
+
if (fs.otherComment.value) {
|
|
109
108
|
feedback = {
|
|
110
109
|
...feedback,
|
|
111
|
-
description:
|
|
110
|
+
description: fs.otherComment.value,
|
|
112
111
|
};
|
|
113
112
|
}
|
|
114
113
|
return new Models.Feedback(feedback);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-feedback.store.js","sourceRoot":"","sources":["../../src/stores/message-feedback.store.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,
|
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;AAzFe;IAAX,UAAU;;uDAAsC;AAEjD;IAAC,QAAQ;;;mEAER;AAED;IAAC,QAAQ;;;6DAER;AAED;IAAC,QAAQ;;;mDAQR;AAuCO;IADP,MAAM;;6DAgCL;AAzFO,oBAAoB;IADhC,UAAU,EAAE;IAsBI,WAAA,MAAM,CAAC,sBAAsB,CAAC,CAAA;;GArBlC,oBAAoB,CA0FhC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FormState } from 'formstate';
|
|
1
|
+
import { FieldState, FormState } from 'formstate';
|
|
3
2
|
import { Models } from '../api-client';
|
|
4
3
|
export declare class SessionFeedbackStore {
|
|
5
4
|
formState: FormState<{
|
|
6
|
-
thumbs:
|
|
7
|
-
comment:
|
|
5
|
+
thumbs: FieldState<number>;
|
|
6
|
+
comment: FieldState<string>;
|
|
8
7
|
}>;
|
|
9
8
|
get isValid(): boolean;
|
|
10
9
|
get feedback(): Models.Feedback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-feedback.store.d.ts","sourceRoot":"","sources":["../../src/stores/session-feedback.store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-feedback.store.d.ts","sourceRoot":"","sources":["../../src/stores/session-feedback.store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,qBACa,oBAAoB;IAE7B,SAAS;;;OAGN;IAEH,IACI,OAAO,YAEV;IAED,IACI,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAQ9B;IAED,IACI,UAAU,YAEb;IAED,IACI,YAAY,YAEf;;CAKJ"}
|
|
@@ -7,9 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { InputFieldState, TextAreaFieldState } from '@servicetitan/form';
|
|
11
10
|
import { injectable } from '@servicetitan/react-ioc';
|
|
12
|
-
import { FormState } from 'formstate';
|
|
11
|
+
import { FieldState, FormState } from 'formstate';
|
|
13
12
|
import { computed, makeObservable, observable } from 'mobx';
|
|
14
13
|
import { Models } from '../api-client';
|
|
15
14
|
let SessionFeedbackStore = class SessionFeedbackStore {
|
|
@@ -36,8 +35,8 @@ let SessionFeedbackStore = class SessionFeedbackStore {
|
|
|
36
35
|
configurable: true,
|
|
37
36
|
writable: true,
|
|
38
37
|
value: new FormState({
|
|
39
|
-
thumbs: new
|
|
40
|
-
comment: new
|
|
38
|
+
thumbs: new FieldState(0),
|
|
39
|
+
comment: new FieldState(''),
|
|
41
40
|
})
|
|
42
41
|
});
|
|
43
42
|
makeObservable(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-feedback.store.js","sourceRoot":"","sources":["../../src/stores/session-feedback.store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"session-feedback.store.js","sourceRoot":"","sources":["../../src/stores/session-feedback.store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGhC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAO7B,IACI,OAAO;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,IACI,QAAQ;QACR,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC;YACvB,MAAM,EACF,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC;gBAC7B,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ;gBACjC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,UAAU;YAC3C,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,SAAS;SAC3D,CAAC,CAAC;IACP,CAAC;IAED,IACI,UAAU;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED,IACI,YAAY;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED;QA/BA;;;;mBAAY,IAAI,SAAS,CAAC;gBACtB,MAAM,EAAE,IAAI,UAAU,CAAS,CAAC,CAAC;gBACjC,OAAO,EAAE,IAAI,UAAU,CAAS,EAAE,CAAC;aACtC,CAAC;WAAC;QA6BC,cAAc,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACJ,CAAA;AAlCG;IADC,UAAU;;uDAIR;AAEH;IAAC,QAAQ;;;mDAGR;AAED;IAAC,QAAQ;8BACO,MAAM,CAAC,QAAQ;;oDAQ9B;AAED;IAAC,QAAQ;;;sDAGR;AAED;IAAC,QAAQ;;;wDAGR;AA/BQ,oBAAoB;IADhC,UAAU,EAAE;;GACA,oBAAoB,CAoChC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/titan-chatbot-api",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Chatbot client API package",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,13 +17,11 @@
|
|
|
17
17
|
"push:local": "yalc push"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@servicetitan/titan-chat-ui-common": "^3.1.
|
|
20
|
+
"@servicetitan/titan-chat-ui-common": "^3.1.3",
|
|
21
21
|
"lodash": "^4.17.21",
|
|
22
22
|
"nanoid": "^5.1.5"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@servicetitan/form": ">=27",
|
|
26
|
-
"@servicetitan/form-state": ">=27",
|
|
27
25
|
"@servicetitan/log-service": ">=27",
|
|
28
26
|
"@servicetitan/react-ioc": ">=24",
|
|
29
27
|
"axios": ">=0.28.0",
|
|
@@ -31,8 +29,8 @@
|
|
|
31
29
|
"mobx": ">=6",
|
|
32
30
|
"mobx-react": ">=9",
|
|
33
31
|
"mobx-utils": ">=6",
|
|
34
|
-
"react": "
|
|
35
|
-
"react-dom": "
|
|
32
|
+
"react": ">=18",
|
|
33
|
+
"react-dom": ">=18"
|
|
36
34
|
},
|
|
37
35
|
"keywords": [
|
|
38
36
|
"ServiceTitan"
|
|
@@ -44,5 +42,5 @@
|
|
|
44
42
|
"cli": {
|
|
45
43
|
"webpack": false
|
|
46
44
|
},
|
|
47
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "55f94919492c182aa6272eb38006c1e064ae04ba"
|
|
48
46
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { InputFieldState, TextAreaFieldState, formStateToJS } from '@servicetitan/form';
|
|
2
1
|
import { injectable } from '@servicetitan/react-ioc';
|
|
3
|
-
import { FormState } from 'formstate';
|
|
2
|
+
import { FieldState, FormState } from 'formstate';
|
|
4
3
|
import { action, computed, makeObservable, observable } from 'mobx';
|
|
5
4
|
import { Models } from '../api-client';
|
|
6
5
|
import { IMessageFeedbackBaseStore } from './message-feedback-base.store';
|
|
7
6
|
|
|
8
7
|
export type FeedbackFormState = FormState<{
|
|
9
|
-
linkUrl:
|
|
10
|
-
comment:
|
|
8
|
+
linkUrl: FieldState<string>;
|
|
9
|
+
comment: FieldState<string>;
|
|
11
10
|
}>;
|
|
12
11
|
|
|
13
12
|
@injectable()
|
|
@@ -24,30 +23,44 @@ export class MessageFeedbackGuardrailStore implements IMessageFeedbackBaseStore<
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
export(): Models.Feedback {
|
|
27
|
-
const
|
|
26
|
+
const fs = this.formState.$;
|
|
28
27
|
let feedback: Models.IFeedback = {
|
|
29
28
|
rating: Models.FeedbackRatings.GuardrailFeedback,
|
|
30
29
|
};
|
|
31
|
-
if (
|
|
30
|
+
if (fs.linkUrl.value) {
|
|
32
31
|
feedback = {
|
|
33
32
|
...feedback,
|
|
34
|
-
linkUrl:
|
|
33
|
+
linkUrl: fs.linkUrl.value,
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
|
-
if (
|
|
36
|
+
if (fs.comment.value) {
|
|
38
37
|
feedback = {
|
|
39
38
|
...feedback,
|
|
40
|
-
description:
|
|
39
|
+
description: fs.comment.value,
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
42
|
return new Models.Feedback(feedback);
|
|
44
43
|
}
|
|
45
44
|
|
|
45
|
+
getFormErrors(): string[] {
|
|
46
|
+
const errors: string[] = [];
|
|
47
|
+
if (this.formState.formError) {
|
|
48
|
+
errors.push(this.formState.formError);
|
|
49
|
+
}
|
|
50
|
+
if (this.formState.$.linkUrl.error) {
|
|
51
|
+
errors.push(this.formState.$.linkUrl.error);
|
|
52
|
+
}
|
|
53
|
+
if (this.formState.$.comment.error) {
|
|
54
|
+
errors.push(this.formState.$.comment.error);
|
|
55
|
+
}
|
|
56
|
+
return errors;
|
|
57
|
+
}
|
|
58
|
+
|
|
46
59
|
@action
|
|
47
60
|
private createFormState = () => {
|
|
48
61
|
const formState = new FormState({
|
|
49
|
-
linkUrl: new
|
|
50
|
-
comment: new
|
|
62
|
+
linkUrl: new FieldState(''),
|
|
63
|
+
comment: new FieldState(''),
|
|
51
64
|
});
|
|
52
65
|
formState.validators($ => {
|
|
53
66
|
const nothingSelected = !$.linkUrl.value && !$.comment.value;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CheckboxFieldState,
|
|
3
|
-
FormValidators,
|
|
4
|
-
TextAreaFieldState,
|
|
5
|
-
formStateToJS,
|
|
6
|
-
} from '@servicetitan/form';
|
|
7
1
|
import { inject, injectable } from '@servicetitan/react-ioc';
|
|
8
|
-
import { FormState } from 'formstate';
|
|
2
|
+
import { FieldState, FormState } from 'formstate';
|
|
9
3
|
import { action, computed, makeObservable, observable } from 'mobx';
|
|
10
4
|
import { Models } from '../api-client';
|
|
11
5
|
import { CHATBOT_UI_STORE_TOKEN, IChatbotUiStore } from './chatbot-ui.store';
|
|
12
6
|
import { IMessageFeedbackBaseStore } from './message-feedback-base.store';
|
|
13
7
|
|
|
14
8
|
export type MessageFeedbackFormState = FormState<{
|
|
15
|
-
unrelated:
|
|
16
|
-
unclear:
|
|
17
|
-
notFull:
|
|
18
|
-
incorrect:
|
|
19
|
-
other:
|
|
20
|
-
otherComment:
|
|
9
|
+
unrelated: FieldState<boolean>;
|
|
10
|
+
unclear: FieldState<boolean>;
|
|
11
|
+
notFull: FieldState<boolean>;
|
|
12
|
+
incorrect: FieldState<boolean>;
|
|
13
|
+
other: FieldState<boolean>;
|
|
14
|
+
otherComment: FieldState<string>;
|
|
21
15
|
}>;
|
|
22
16
|
|
|
23
17
|
@injectable()
|
|
@@ -48,31 +42,31 @@ export class MessageFeedbackStore implements IMessageFeedbackBaseStore<MessageFe
|
|
|
48
42
|
}
|
|
49
43
|
|
|
50
44
|
export(): Models.IFeedback {
|
|
51
|
-
const
|
|
45
|
+
const fs = this.formState.$;
|
|
52
46
|
const options: Models.FeedbackOptions[] = [];
|
|
53
|
-
if (
|
|
47
|
+
if (fs.unrelated.value) {
|
|
54
48
|
options.push(Models.FeedbackOptions.Unrelated);
|
|
55
49
|
}
|
|
56
|
-
if (
|
|
50
|
+
if (fs.unclear.value) {
|
|
57
51
|
options.push(Models.FeedbackOptions.Unclear);
|
|
58
52
|
}
|
|
59
|
-
if (
|
|
53
|
+
if (fs.notFull.value) {
|
|
60
54
|
options.push(Models.FeedbackOptions.Incomplete);
|
|
61
55
|
}
|
|
62
|
-
if (
|
|
56
|
+
if (fs.incorrect.value) {
|
|
63
57
|
options.push(Models.FeedbackOptions.Incorrect);
|
|
64
58
|
}
|
|
65
|
-
if (
|
|
59
|
+
if (fs.other.value) {
|
|
66
60
|
options.push(Models.FeedbackOptions.Other);
|
|
67
61
|
}
|
|
68
62
|
let feedback: Models.IFeedback = {
|
|
69
63
|
rating: Models.FeedbackRatings.ThumbsDown,
|
|
70
64
|
options,
|
|
71
65
|
};
|
|
72
|
-
if (
|
|
66
|
+
if (fs.otherComment.value) {
|
|
73
67
|
feedback = {
|
|
74
68
|
...feedback,
|
|
75
|
-
description:
|
|
69
|
+
description: fs.otherComment.value,
|
|
76
70
|
};
|
|
77
71
|
}
|
|
78
72
|
return new Models.Feedback(feedback);
|
|
@@ -81,22 +75,22 @@ export class MessageFeedbackStore implements IMessageFeedbackBaseStore<MessageFe
|
|
|
81
75
|
@action
|
|
82
76
|
private createFormState = (): MessageFeedbackFormState => {
|
|
83
77
|
const formState = new FormState({
|
|
84
|
-
unrelated: new
|
|
85
|
-
unclear: new
|
|
86
|
-
notFull: new
|
|
87
|
-
incorrect: new
|
|
88
|
-
other: new
|
|
89
|
-
otherComment: new
|
|
78
|
+
unrelated: new FieldState(false),
|
|
79
|
+
unclear: new FieldState(false),
|
|
80
|
+
notFull: new FieldState(false),
|
|
81
|
+
incorrect: new FieldState(false),
|
|
82
|
+
other: new FieldState(false),
|
|
83
|
+
otherComment: new FieldState('')
|
|
90
84
|
.validators($ => {
|
|
91
85
|
if (this.isCommentAlwaysRequired) {
|
|
92
86
|
// Internal users can't submit empty feedback
|
|
93
|
-
return
|
|
87
|
+
return $ ? false : 'Enter details.';
|
|
94
88
|
}
|
|
95
89
|
// External users can submit empty feedback if "Other" is not selected
|
|
96
90
|
if (!this.formState.$.other.value) {
|
|
97
91
|
return false;
|
|
98
92
|
}
|
|
99
|
-
return
|
|
93
|
+
return $ ? false : 'Enter details.';
|
|
100
94
|
})
|
|
101
95
|
.disableAutoValidation(),
|
|
102
96
|
}).validators($ => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { InputFieldState, TextAreaFieldState } from '@servicetitan/form';
|
|
2
1
|
import { injectable } from '@servicetitan/react-ioc';
|
|
3
|
-
import { FormState } from 'formstate';
|
|
2
|
+
import { FieldState, FormState } from 'formstate';
|
|
4
3
|
import { computed, makeObservable, observable } from 'mobx';
|
|
5
4
|
import { Models } from '../api-client';
|
|
6
5
|
|
|
@@ -8,8 +7,8 @@ import { Models } from '../api-client';
|
|
|
8
7
|
export class SessionFeedbackStore {
|
|
9
8
|
@observable
|
|
10
9
|
formState = new FormState({
|
|
11
|
-
thumbs: new
|
|
12
|
-
comment: new
|
|
10
|
+
thumbs: new FieldState<number>(0),
|
|
11
|
+
comment: new FieldState<string>(''),
|
|
13
12
|
});
|
|
14
13
|
|
|
15
14
|
@computed
|