@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.
Files changed (112) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/api-client/__mocks__/chatbot-api-client.mock.js +21 -47
  3. package/dist/api-client/__mocks__/chatbot-api-client.mock.js.map +1 -1
  4. package/dist/api-client/base/chatbot-api-client.js +3 -4
  5. package/dist/api-client/base/chatbot-api-client.js.map +1 -1
  6. package/dist/api-client/help-center/__tests__/converter-from-models.test.js +48 -15
  7. package/dist/api-client/help-center/__tests__/converter-from-models.test.js.map +1 -1
  8. package/dist/api-client/help-center/__tests__/converter-to-models.test.js +23 -22
  9. package/dist/api-client/help-center/__tests__/converter-to-models.test.js.map +1 -1
  10. package/dist/api-client/help-center/chatbot-api-client.js +51 -52
  11. package/dist/api-client/help-center/chatbot-api-client.js.map +1 -1
  12. package/dist/api-client/help-center/converter-from-models.js +15 -12
  13. package/dist/api-client/help-center/converter-from-models.js.map +1 -1
  14. package/dist/api-client/help-center/converter-to-models.js +29 -26
  15. package/dist/api-client/help-center/converter-to-models.js.map +1 -1
  16. package/dist/api-client/help-center/index.d.ts +2 -1
  17. package/dist/api-client/help-center/index.d.ts.map +1 -1
  18. package/dist/api-client/help-center/index.js +1 -0
  19. package/dist/api-client/help-center/index.js.map +1 -1
  20. package/dist/api-client/help-center/native-client.js +1192 -2884
  21. package/dist/api-client/help-center/native-client.js.map +1 -1
  22. package/dist/api-client/index.d.ts +2 -1
  23. package/dist/api-client/index.d.ts.map +1 -1
  24. package/dist/api-client/index.js +14 -7
  25. package/dist/api-client/index.js.map +1 -1
  26. package/dist/api-client/models/__mocks__/models.mock.js +154 -124
  27. package/dist/api-client/models/__mocks__/models.mock.js.map +1 -1
  28. package/dist/api-client/models/index.d.ts +2 -1
  29. package/dist/api-client/models/index.d.ts.map +1 -1
  30. package/dist/api-client/models/index.js +8 -7
  31. package/dist/api-client/models/index.js.map +1 -1
  32. package/dist/api-client/titan-chat/__tests__/native-client.test.js +6 -6
  33. package/dist/api-client/titan-chat/__tests__/native-client.test.js.map +1 -1
  34. package/dist/api-client/titan-chat/chatbot-api-client.js +40 -35
  35. package/dist/api-client/titan-chat/chatbot-api-client.js.map +1 -1
  36. package/dist/api-client/titan-chat/index.d.ts +2 -1
  37. package/dist/api-client/titan-chat/index.d.ts.map +1 -1
  38. package/dist/api-client/titan-chat/index.js +1 -0
  39. package/dist/api-client/titan-chat/index.js.map +1 -1
  40. package/dist/api-client/titan-chat/native-client.d.ts +14 -14
  41. package/dist/api-client/titan-chat/native-client.d.ts.map +1 -1
  42. package/dist/api-client/titan-chat/native-client.js +359 -809
  43. package/dist/api-client/titan-chat/native-client.js.map +1 -1
  44. package/dist/api-client/utils/__tests__/model-utils.test.js +454 -191
  45. package/dist/api-client/utils/__tests__/model-utils.test.js.map +1 -1
  46. package/dist/api-client/utils/model-utils.d.ts.map +1 -1
  47. package/dist/api-client/utils/model-utils.js +28 -25
  48. package/dist/api-client/utils/model-utils.js.map +1 -1
  49. package/dist/hooks/use-customization-chatbot.js +2 -1
  50. package/dist/hooks/use-customization-chatbot.js.map +1 -1
  51. package/dist/index.d.ts +1 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +6 -5
  54. package/dist/index.js.map +1 -1
  55. package/dist/models/chatbot-customizations.js +2 -1
  56. package/dist/models/chatbot-customizations.js.map +1 -1
  57. package/dist/models/index.d.ts +1 -1
  58. package/dist/models/index.d.ts.map +1 -1
  59. package/dist/models/index.js +2 -1
  60. package/dist/models/index.js.map +1 -1
  61. package/dist/stores/__tests__/chatbot-ui-backend.store.test.js +267 -172
  62. package/dist/stores/__tests__/chatbot-ui-backend.store.test.js.map +1 -1
  63. package/dist/stores/__tests__/chatbot-ui.store.test.js +61 -64
  64. package/dist/stores/__tests__/chatbot-ui.store.test.js.map +1 -1
  65. package/dist/stores/__tests__/filter.store.test.js +243 -116
  66. package/dist/stores/__tests__/filter.store.test.js.map +1 -1
  67. package/dist/stores/__tests__/initialize.store.test.js +9 -8
  68. package/dist/stores/__tests__/initialize.store.test.js.map +1 -1
  69. package/dist/stores/__tests__/message-feedback-guardrail.store.test.js +8 -7
  70. package/dist/stores/__tests__/message-feedback-guardrail.store.test.js.map +1 -1
  71. package/dist/stores/__tests__/message-feedback.store.test.js +34 -27
  72. package/dist/stores/__tests__/message-feedback.store.test.js.map +1 -1
  73. package/dist/stores/__tests__/session-feedback.store.test.js +9 -8
  74. package/dist/stores/__tests__/session-feedback.store.test.js.map +1 -1
  75. package/dist/stores/chatbot-ui-backend.store.js +171 -240
  76. package/dist/stores/chatbot-ui-backend.store.js.map +1 -1
  77. package/dist/stores/chatbot-ui.store.js +73 -46
  78. package/dist/stores/chatbot-ui.store.js.map +1 -1
  79. package/dist/stores/filter.store.js +298 -378
  80. package/dist/stores/filter.store.js.map +1 -1
  81. package/dist/stores/index.d.ts +5 -3
  82. package/dist/stores/index.d.ts.map +1 -1
  83. package/dist/stores/index.js +3 -2
  84. package/dist/stores/index.js.map +1 -1
  85. package/dist/stores/initialize.store.js +55 -51
  86. package/dist/stores/initialize.store.js.map +1 -1
  87. package/dist/stores/message-feedback-base.store.js +2 -1
  88. package/dist/stores/message-feedback-base.store.js.map +1 -1
  89. package/dist/stores/message-feedback-guardrail.store.js +50 -47
  90. package/dist/stores/message-feedback-guardrail.store.js.map +1 -1
  91. package/dist/stores/message-feedback.store.js +84 -89
  92. package/dist/stores/message-feedback.store.js.map +1 -1
  93. package/dist/stores/session-feedback.store.js +46 -39
  94. package/dist/stores/session-feedback.store.js.map +1 -1
  95. package/dist/utils/__tests__/axios-utils.test.js +8 -7
  96. package/dist/utils/__tests__/axios-utils.test.js.map +1 -1
  97. package/dist/utils/axios-utils.js +9 -7
  98. package/dist/utils/axios-utils.js.map +1 -1
  99. package/dist/utils/test-utils.js +5 -5
  100. package/dist/utils/test-utils.js.map +1 -1
  101. package/package.json +3 -3
  102. package/src/api-client/help-center/index.ts +2 -1
  103. package/src/api-client/help-center/native-client.ts +4 -4
  104. package/src/api-client/index.ts +2 -6
  105. package/src/api-client/models/index.ts +15 -13
  106. package/src/api-client/titan-chat/index.ts +2 -1
  107. package/src/api-client/titan-chat/native-client.ts +17 -14
  108. package/src/api-client/utils/model-utils.ts +4 -8
  109. package/src/index.ts +1 -1
  110. package/src/models/index.ts +1 -1
  111. package/src/stores/index.ts +5 -12
  112. package/tsconfig.tsbuildinfo +1 -1
@@ -1,86 +1,46 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
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 (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;
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
- var __metadata = (this && this.__metadata) || function (k, v) {
19
+ }
20
+ function _ts_metadata(k, v) {
8
21
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
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
- let MessageFeedbackStore = class MessageFeedbackStore {
32
+ import { CHATBOT_UI_STORE_TOKEN, IChatbotUiStore } from './chatbot-ui.store';
33
+ export class MessageFeedbackStore {
19
34
  get isCommentAlwaysRequired() {
20
- var _a, _b;
21
- return (_b = (_a = this.chatbotUiStore.customizations.feedback) === null || _a === void 0 ? void 0 : _a.isCommentAlwaysRequired) !== null && _b !== void 0 ? _b : false;
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 (this.formState.$.unrelated.value ||
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
- __decorate([
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
- __metadata("design:type", Object)
108
+ _ts_metadata("design:type", typeof MessageFeedbackFormState === "undefined" ? Object : MessageFeedbackFormState)
116
109
  ], MessageFeedbackStore.prototype, "formState", void 0);
117
- __decorate([
110
+ _ts_decorate([
118
111
  computed,
119
- __metadata("design:type", Object),
120
- __metadata("design:paramtypes", [])
112
+ _ts_metadata("design:type", void 0),
113
+ _ts_metadata("design:paramtypes", [])
121
114
  ], MessageFeedbackStore.prototype, "isCommentAlwaysRequired", null);
122
- __decorate([
115
+ _ts_decorate([
123
116
  computed,
124
- __metadata("design:type", Object),
125
- __metadata("design:paramtypes", [])
117
+ _ts_metadata("design:type", void 0),
118
+ _ts_metadata("design:paramtypes", [])
126
119
  ], MessageFeedbackStore.prototype, "isTextAreaVisible", null);
127
- __decorate([
120
+ _ts_decorate([
128
121
  computed,
129
- __metadata("design:type", Object),
130
- __metadata("design:paramtypes", [])
122
+ _ts_metadata("design:type", void 0),
123
+ _ts_metadata("design:paramtypes", [])
131
124
  ], MessageFeedbackStore.prototype, "isValid", null);
132
- __decorate([
133
- action,
134
- __metadata("design:type", Object)
125
+ _ts_decorate([
126
+ action
135
127
  ], MessageFeedbackStore.prototype, "createFormState", void 0);
136
- MessageFeedbackStore = __decorate([
128
+ MessageFeedbackStore = _ts_decorate([
137
129
  injectable(),
138
- __param(0, inject(CHATBOT_UI_STORE_TOKEN)),
139
- __metadata("design:paramtypes", [Object])
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
- export { MessageFeedbackStore };
136
+
142
137
  //# sourceMappingURL=message-feedback.store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-feedback.store.js","sourceRoot":"","sources":["../../src/stores/message-feedback.store.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC7D,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;AACvC,OAAO,EAAE,sBAAsB,EAAmB,MAAM,oBAAoB,CAAC;AAatE,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAG7B,IAAc,uBAAuB;;QACjC,OAAO,MAAA,MAAA,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,QAAQ,0CAAE,uBAAuB,mCAAI,KAAK,CAAC;IACzF,CAAC;IAED,IAAc,iBAAiB;QAC3B,OAAO,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;IACxE,CAAC;IAED,IAAc,OAAO;QACjB,OAAO,CACH,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK;YAChC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK;YAC9B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK;YAC9B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK;YAChC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAA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AAQ,CAAC,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;QACjD,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;CAmCJ,CAAA;AAtFe;IAAX,UAAU;;uDAAsC;AAEjD;IAAC,QAAQ;;;mEAER;AAED;IAAC,QAAQ;;;6DAER;AAED;IAAC,QAAQ;;;mDAQR;AAoCO;IADP,MAAM;;6DAgCL;AAtFO,oBAAoB;IADhC,UAAU,EAAE;IAsBI,WAAA,MAAM,CAAC,sBAAsB,CAAC,CAAA;;GArBlC,oBAAoB,CAuFhC"}
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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ACF,EAAEM,OAAO,CAACJ,KAAK,IAChB,CAACF,EAAEO,SAAS,CAACL,KAAK,IAClB,CAACF,EAAEC,KAAK,CAACC,KAAK;gBAClB,OAAOwB,kBAAkB,0CAA0C;YACvE;YACA3B,UAAU0B,qBAAqB;YAC/B,OAAO1B;QACX;QAhEI,IAAI,CAACA,SAAS,GAAG,IAAI,CAACwB,eAAe;QACrCnC,eAAe,IAAI;IACvB;AA+DJ"}
@@ -1,26 +1,38 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
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 (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;
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
- var __metadata = (this && this.__metadata) || function (k, v) {
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
- let SessionFeedbackStore = class SessionFeedbackStore {
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
- ? Models.FeedbackRatings.ThumbsUp
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
- Object.defineProperty(this, "formState", {
34
- enumerable: true,
35
- configurable: true,
36
- writable: true,
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
- __decorate([
46
- observable,
47
- __metadata("design:type", Object)
51
+ }
52
+ _ts_decorate([
53
+ observable
48
54
  ], SessionFeedbackStore.prototype, "formState", void 0);
49
- __decorate([
55
+ _ts_decorate([
50
56
  computed,
51
- __metadata("design:type", Object),
52
- __metadata("design:paramtypes", [])
57
+ _ts_metadata("design:type", void 0),
58
+ _ts_metadata("design:paramtypes", [])
53
59
  ], SessionFeedbackStore.prototype, "isValid", null);
54
- __decorate([
60
+ _ts_decorate([
55
61
  computed,
56
- __metadata("design:type", Object),
57
- __metadata("design:paramtypes", [])
62
+ _ts_metadata("design:type", typeof FeedbackDraft === "undefined" ? Object : FeedbackDraft),
63
+ _ts_metadata("design:paramtypes", [])
58
64
  ], SessionFeedbackStore.prototype, "feedback", null);
59
- __decorate([
65
+ _ts_decorate([
60
66
  computed,
61
- __metadata("design:type", Object),
62
- __metadata("design:paramtypes", [])
67
+ _ts_metadata("design:type", void 0),
68
+ _ts_metadata("design:paramtypes", [])
63
69
  ], SessionFeedbackStore.prototype, "isThumbsUp", null);
64
- __decorate([
70
+ _ts_decorate([
65
71
  computed,
66
- __metadata("design:type", Object),
67
- __metadata("design:paramtypes", [])
72
+ _ts_metadata("design:type", void 0),
73
+ _ts_metadata("design:paramtypes", [])
68
74
  ], SessionFeedbackStore.prototype, "isThumbsDown", null);
69
- SessionFeedbackStore = __decorate([
75
+ SessionFeedbackStore = _ts_decorate([
70
76
  injectable(),
71
- __metadata("design:paramtypes", [])
77
+ _ts_metadata("design:type", Function),
78
+ _ts_metadata("design:paramtypes", [])
72
79
  ], SessionFeedbackStore);
73
- export { SessionFeedbackStore };
80
+
74
81
  //# sourceMappingURL=session-feedback.store.js.map
@@ -1 +1 @@
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;AAIhC,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;YACH,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;IACN,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;;;oDASR;AAED;IAAC,QAAQ;;;sDAGR;AAED;IAAC,QAAQ;;;wDAGR;AA/BQ,oBAAoB;IADhC,UAAU,EAAE;;GACA,oBAAoB,CAoChC"}
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 => setTimeout(() => resolve('done'), 100));
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 => setTimeout(() => resolve('done'), 100));
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,"file":"axios-utils.test.js","sourceRoot":"","sources":["../../../src/utils/__tests__/axios-utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,E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AAK,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAC9E,MAAM,SAAS,GAAG,GAAG,CAAC;QAEtB,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3F,MAAM,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,CAAC,CAAC;QACR,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
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([action, timeoutPromise]);
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,"file":"axios-utils.js","sourceRoot":"","sources":["../../src/utils/axios-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC7B,MAAkB,EAClB,SAAiB,EACjB,eAAgC;IAEhC,IAAI,SAAS,GAA8C,SAAS,CAAC;IACrE,MAAM,cAAc,GAAG,IAAI,OAAO,CAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAChD,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YACxB,eAAe,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAClD,MAAM,CAAC,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC;QAClD,CAAC,EAAE,SAAS,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC;QACD,OAAO,MAAM,OAAO,CAAC;IACzB,CAAC;YAAS,CAAC;QACP,IAAI,SAAS,EAAE,CAAC;YACZ,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,SAAS,GAAG,SAAS,CAAC;QAC1B,CAAC;IACL,CAAC;AACL,CAAC"}
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"}
@@ -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 => rootContainer.bind(identifier).toSelf());
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,"file":"test-utils.js","sourceRoot":"","sources":["../../src/utils/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC7B,iBAAwD,EACxD,kBAAkD,EACpD,EAAE;IACA,MAAM,aAAa,GAAG,IAAI,SAAS,EAAE,CAAC;IACtC,IAAI,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACnC,iBAAiB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACrF,CAAC;SAAM,CAAC;QACJ,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,GAAG,EAAE;QACR,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAClC,SAAS,CAAC,MAAM,GAAG,aAAa,CAAC;QACjC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAC9B,OAAO,SAAS,CAAC;IACrB,CAAC,CAAC;AACN,CAAC,CAAC"}
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": "7.1.1",
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": "^7.1.1",
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": "3cccf1b9de3865c3b591d237dd7342fab212ce66"
45
+ "gitHead": "3af2e2dd99b7d735dbb763075de074986f866ce3"
46
46
  }
@@ -1 +1,2 @@
1
- export { ChatbotApiClient, IChatbotClientSettingsHelpCenter } from './chatbot-api-client';
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);
@@ -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
- IChatbotClientSettings,
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';