quickblox-react-ui-kit 0.2.3 → 0.2.5

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 (123) hide show
  1. package/README.md +3 -2
  2. package/dist/CommonTypes/FunctionResult.d.ts +5 -1
  3. package/dist/Data/DefaultConfigurations.d.ts +2 -2
  4. package/dist/Data/repository/DialogsRepository.d.ts +1 -0
  5. package/dist/Data/repository/EventMessagesRepository.d.ts +1 -0
  6. package/dist/Data/repository/MessagesRepository.d.ts +2 -2
  7. package/dist/Domain/entity/NotificationTypes.d.ts +1 -0
  8. package/dist/Domain/repository/IDialogsRepository.d.ts +1 -0
  9. package/dist/Domain/repository/IMessagesRepository.d.ts +2 -2
  10. package/dist/Domain/use_cases/CreateDialogUseCase.d.ts +2 -1
  11. package/dist/Domain/use_cases/LeaveDialogUseCase.d.ts +2 -1
  12. package/dist/Domain/use_cases/RemoveUsersFromTheDialogUseCase.d.ts +2 -1
  13. package/dist/Domain/use_cases/SubscribeToDialogEventsUseCase.d.ts +1 -0
  14. package/dist/Domain/use_cases/UpdateDialogUseCase.d.ts +2 -1
  15. package/dist/Domain/use_cases/ai/AIAnswerAssistUseCase.d.ts +13 -0
  16. package/dist/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.d.ts +13 -0
  17. package/dist/Domain/use_cases/ai/AITranslateUseCase.d.ts +14 -0
  18. package/dist/Domain/use_cases/ai/AITranslateWithProxyUseCase.d.ts +14 -0
  19. package/dist/Presentation/Views/Base/BaseViewModel.d.ts +3 -0
  20. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.d.ts +4 -1
  21. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.d.ts +3 -2
  22. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.d.ts +5 -13
  23. package/dist/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.d.ts +8 -0
  24. package/dist/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.d.ts +7 -0
  25. package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.d.ts +3 -0
  26. package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.d.ts +12 -3
  27. package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesView.d.ts +10 -0
  28. package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesViewModel.d.ts +2 -2
  29. package/dist/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.d.ts +7 -0
  30. package/dist/Presentation/components/UI/Dialogs/MessagesView/SystemMessageBanner/SystemMessageBanner.d.ts +7 -0
  31. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.d.ts +7 -0
  32. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.d.ts +7 -0
  33. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.d.ts +8 -0
  34. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.d.ts +7 -0
  35. package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.d.ts +4 -0
  36. package/dist/QBconfig.d.ts +14 -3
  37. package/dist/index-ui.d.ts +5 -1
  38. package/dist/index-ui.js +410 -61
  39. package/dist/utils/utils.d.ts +9 -0
  40. package/global.d.ts +12 -4
  41. package/package.json +5 -1
  42. package/src/App.tsx +1 -1
  43. package/src/CommonTypes/FunctionResult.ts +6 -1
  44. package/src/Data/DefaultConfigurations.ts +155 -19
  45. package/src/Data/repository/DialogsRepository.ts +4 -0
  46. package/src/Data/repository/EventMessagesRepository.ts +34 -0
  47. package/src/Data/repository/MessagesRepository.ts +16 -10
  48. package/src/Data/source/exception/MapperDTOException.ts +3 -0
  49. package/src/Data/source/remote/RemoteDataSource.ts +134 -112
  50. package/src/Domain/entity/NotificationTypes.ts +2 -0
  51. package/src/Domain/repository/IDialogsRepository.ts +2 -0
  52. package/src/Domain/repository/IMessagesRepository.ts +2 -2
  53. package/src/Domain/use_cases/CreateDialogUseCase.ts +8 -1
  54. package/src/Domain/use_cases/GetAllDialogsUseCaseWithMock.ts +1 -0
  55. package/src/Domain/use_cases/LeaveDialogUseCase.ts +8 -1
  56. package/src/Domain/use_cases/RemoveUsersFromTheDialogUseCase.ts +40 -17
  57. package/src/Domain/use_cases/SendTextMessageUseCase.ts +3 -2
  58. package/src/Domain/use_cases/SubscribeToDialogEventsUseCase.ts +21 -0
  59. package/src/Domain/use_cases/UpdateDialogUseCase.ts +8 -1
  60. package/src/Domain/use_cases/ai/AIAnswerAssistUseCase.ts +69 -0
  61. package/src/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.ts +71 -0
  62. package/src/Domain/use_cases/ai/AIRephraseUseCase.ts +38 -36
  63. package/src/Domain/use_cases/ai/AIRephraseWithProxyUseCase.ts +25 -21
  64. package/src/Domain/use_cases/ai/AITranslateUseCase.ts +76 -0
  65. package/src/Domain/use_cases/ai/AITranslateWithProxyUseCase.ts +79 -0
  66. package/src/Domain/use_cases/base/Subscribable/SubscriptionPerformer.ts +7 -10
  67. package/src/Presentation/Views/Base/BaseViewModel.ts +3 -0
  68. package/src/Presentation/Views/Dialogs/Dialogs.scss +3 -0
  69. package/src/Presentation/Views/Dialogs/Dialogs.tsx +1 -1
  70. package/src/Presentation/Views/Dialogs/useDialogsViewModel.ts +109 -48
  71. package/src/Presentation/assets/styles/_variables.scss +19 -0
  72. package/src/Presentation/components/UI/Buttons/MainButton/MainButton.scss +9 -0
  73. package/src/Presentation/components/UI/Dialogs/EditDialog/EditDialog.scss +3 -0
  74. package/src/Presentation/components/UI/Dialogs/InviteMembers/InviteMembers.scss +3 -0
  75. package/src/Presentation/components/UI/Dialogs/MembersList/MembersList.scss +3 -0
  76. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.ts +7 -2
  77. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.tsx +10 -4
  78. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.ts +29 -15
  79. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.tsx +10 -6
  80. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +10 -6
  81. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +17 -0
  82. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy.tsx +16 -0
  83. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +13 -12
  84. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy.tsx +13 -12
  85. package/src/Presentation/components/UI/Dialogs/MessagesView/AudioAttachmentComponent/AudioAttachmentComponent.tsx +1 -1
  86. package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.scss +76 -0
  87. package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.tsx +40 -0
  88. package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.scss +26 -0
  89. package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.tsx +25 -0
  90. package/src/Presentation/components/UI/Dialogs/MessagesView/ImageAttachmentComponent/ImageAttachmentComponent.tsx +8 -6
  91. package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.tsx +6 -0
  92. package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss +5 -7
  93. package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx +138 -405
  94. package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.scss +14 -26
  95. package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +658 -429
  96. package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesViewModel.ts +2 -2
  97. package/src/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.tsx +1 -1
  98. package/src/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.scss +23 -0
  99. package/src/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.tsx +17 -0
  100. package/src/Presentation/components/UI/Dialogs/MessagesView/SystemMessageBanner/SystemMessageBanner.scss +21 -0
  101. package/src/Presentation/components/UI/Dialogs/MessagesView/SystemMessageBanner/SystemMessageBanner.tsx +17 -0
  102. package/src/Presentation/components/UI/Dialogs/MessagesView/useMessagesViewModel.ts +124 -83
  103. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.scss +62 -0
  104. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.tsx +25 -0
  105. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.scss +61 -0
  106. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.tsx +32 -0
  107. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.scss +29 -3
  108. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.tsx +55 -4
  109. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.scss +40 -0
  110. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.tsx +26 -0
  111. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.scss +62 -0
  112. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.tsx +25 -0
  113. package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.svg +5 -0
  114. package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.tsx +50 -0
  115. package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +3 -15
  116. package/src/Presentation/components/providers/QuickBloxUIKitProvider/useQbInitializedDataContext.ts +15 -14
  117. package/src/QBconfig.ts +156 -10
  118. package/src/index-ui.ts +8 -1
  119. package/src/index.scss +0 -1
  120. package/src/package_artan_react_ui.json +13 -9
  121. package/src/package_original.json +5 -1
  122. package/src/utils/utils.ts +63 -0
  123. package/src/Presentation/assets/styles/_reset-styles.scss +0 -435
@@ -1,3 +1,12 @@
1
+ import { MessageEntity } from '../Domain/entity/MessageEntity';
2
+ import { IChatMessage } from '../Data/source/AISource';
3
+ import { Tone } from '../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone';
1
4
  export declare const completeSentence: (text?: string) => string;
2
5
  export declare const tokenCounter: (text?: string) => number;
3
6
  export declare const loopToLimitTokens: <T>(limit: number, data: T[], getValue?: (item: T) => string, tokens?: number) => T[];
7
+ export declare class AIUtils {
8
+ static createTranslatePrompt(textToSend: string, language?: string): string;
9
+ static createAnswerAssistPrompt(textToSend: string): string;
10
+ static createRephrasePrompt(textToSend: string, tone?: Tone): string;
11
+ static messageEntitiesToIChatMessageCollection(messageEntities: MessageEntity[], currentUserId: number | undefined, MAX_TOKENS?: number): IChatMessage[];
12
+ }
package/global.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ interface Tone {
2
+ name: string;
3
+ description: string;
4
+ iconEmoji: string;
5
+ }
6
+
1
7
  type Dictionary<T> = Record<string, T>;
2
8
 
3
9
  type DictionaryByKey<T, V> = {
@@ -21,20 +27,22 @@ type ProxyConfig = {
21
27
  api: string;
22
28
  servername: string;
23
29
  port: string;
24
- sessionToken: string;
25
30
  };
26
31
  interface WidgetConfig {
27
32
  apiKey: string;
28
33
  useDefault: boolean;
34
+ maxTokens: number;
29
35
  proxyConfig: ProxyConfig;
30
36
  }
31
37
 
32
- interface AITranslateWidgetConfig extends WidgetConfig{
33
- defaultLanguage: string; languages: string[];
38
+ interface AITranslateWidgetConfig extends WidgetConfig {
39
+ defaultLanguage: string;
40
+ languages: string[];
34
41
  }
35
42
 
36
43
  interface AIRephraseWidgetConfig extends WidgetConfig {
37
- defaultTone: string
44
+ defaultTone: string;
45
+ Tones: Tone[];
38
46
  }
39
47
 
40
48
  interface QBConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quickblox-react-ui-kit",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "main": "dist/index-ui.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -8,6 +8,10 @@
8
8
  "@types/react": "^18.0.26",
9
9
  "@types/react-dom": "^18.0.9",
10
10
  "classnames": "^2.3.2",
11
+ "qb-ai-answer-assistant": "^0.1.0",
12
+ "qb-ai-core": "^0.1.0",
13
+ "qb-ai-rephrase": "^0.1.0",
14
+ "qb-ai-translate": "^0.1.0",
11
15
  "react": "^18.2.0",
12
16
  "react-dom": "^18.2.0",
13
17
  "react-router-dom": "^6.11.1",
package/src/App.tsx CHANGED
@@ -28,7 +28,7 @@ function App() {
28
28
  const { connectionRepository } = useQBConnection();
29
29
 
30
30
  const initLoginData: LoginData = {
31
- login: 'artimed', // vit1
31
+ login: 'anruaav2', // vit1
32
32
  password: 'quickblox',
33
33
  };
34
34
 
@@ -1,3 +1,5 @@
1
+ import {Tone} from "../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone";
2
+
1
3
  export type FunctionResult<T> = {
2
4
  result: T | T[] | boolean;
3
5
  error: any;
@@ -7,10 +9,12 @@ export type ProxyConfig = {
7
9
  api: string;
8
10
  servername: string;
9
11
  port: string;
10
- sessionToken: string;
11
12
  };
12
13
  export interface WidgetConfig {
14
+ organizationName: string;
15
+ openAIModel: string;
13
16
  apiKey: string;
17
+ maxTokens: number;
14
18
  useDefault: boolean;
15
19
  proxyConfig: ProxyConfig;
16
20
  }
@@ -22,6 +26,7 @@ export interface AITranslateWidgetConfig extends WidgetConfig {
22
26
 
23
27
  export interface AIRephraseWidgetConfig extends WidgetConfig {
24
28
  defaultTone: string;
29
+ Tones: Tone[];
25
30
  }
26
31
 
27
32
  export interface QBConfig {
@@ -9,6 +9,7 @@ const supportedLanguagesForIATranslate: string[] = [
9
9
  'German',
10
10
  ];
11
11
 
12
+ // ["en-US", "zh-CN", "ja-JP"]
12
13
  const languageBCP47: Record<string, string> = {
13
14
  'ar-SA': 'Arabic',
14
15
  'bn-BD': 'Bangla',
@@ -80,15 +81,17 @@ export class DefaultConfigurations {
80
81
  api: 'v1/chat/completions',
81
82
  servername: 'https://api.openai.com',
82
83
  port: '',
83
- sessionToken: '',
84
84
  };
85
85
  }
86
86
 
87
- static getDefaultLanguageForAITranslate(): string {
87
+ static getDefaultLanguageForAITranslate(
88
+ configAITranslate: AITranslateWidgetConfig,
89
+ ): string {
88
90
  let languageForAITranslate = 'English';
89
- const { defaultLanguage } =
91
+ const defaultLanguage: string =
92
+ configAITranslate.defaultLanguage ||
90
93
  DefaultConfigurations.getDefaultQBConfig().configAIApi
91
- .AITranslateWidgetConfig;
94
+ .AITranslateWidgetConfig.defaultLanguage;
92
95
 
93
96
  if (
94
97
  defaultLanguage.length > 0 &&
@@ -106,11 +109,14 @@ export class DefaultConfigurations {
106
109
  return languageForAITranslate;
107
110
  }
108
111
 
109
- static getAdditionalLanguagesForAITranslate(): string[] {
112
+ static getAdditionalLanguagesForAITranslate(
113
+ configAITranslate: AITranslateWidgetConfig,
114
+ ): string[] {
110
115
  const additionalLanguages: string[] = [];
111
- const { languages } =
116
+ const languages: string[] =
117
+ configAITranslate.languages ||
112
118
  DefaultConfigurations.getDefaultQBConfig().configAIApi
113
- .AITranslateWidgetConfig;
119
+ .AITranslateWidgetConfig.languages;
114
120
 
115
121
  languages.forEach((item) => {
116
122
  if (supportedLanguagesForIATranslate.includes(item)) {
@@ -135,43 +141,109 @@ export class DefaultConfigurations {
135
141
  },
136
142
  configAIApi: {
137
143
  AIAnswerAssistWidgetConfig: {
144
+ organizationName: 'Quickblox',
145
+ openAIModel: 'gpt-3.5-turbo',
138
146
  apiKey: '',
147
+ maxTokens: 3584,
139
148
  useDefault: true,
140
149
  proxyConfig: {
141
150
  api: 'v1/chat/completions',
142
151
  servername: 'https://api.openai.com/',
143
152
  port: '',
144
- sessionToken: '',
145
153
  },
146
154
  },
147
155
  AITranslateWidgetConfig: {
156
+ organizationName: 'Quickblox',
157
+ openAIModel: 'gpt-3.5-turbo',
148
158
  apiKey: '',
159
+ maxTokens: 3584,
149
160
  useDefault: true,
150
161
  defaultLanguage: 'English',
151
- languages: [
152
- 'English',
153
- 'Spanish',
154
- 'French',
155
- 'Portuguese',
156
- 'German',
157
- 'Ukrainian',
158
- ],
162
+ languages: ['English', 'French', 'Portuguese', 'German', 'Ukrainian'],
159
163
  proxyConfig: {
160
164
  api: 'v1/chat/completions',
161
- servername: 'https://api.openai.com/',
165
+ servername: '',
162
166
  port: '',
163
- sessionToken: '',
164
167
  },
168
+ // proxyConfig: {
169
+ // api: 'v1/chat/completions',
170
+ // servername: 'http://localhost',
171
+ // port: '3012',
172
+ // },
165
173
  },
166
174
  AIRephraseWidgetConfig: {
175
+ organizationName: 'Quickblox',
176
+ openAIModel: 'gpt-3.5-turbo',
167
177
  apiKey: '',
178
+ maxTokens: 3584,
168
179
  useDefault: true,
169
180
  defaultTone: 'Professional',
181
+ Tones: [
182
+ {
183
+ name: 'Professional Tone',
184
+ description:
185
+ 'This would edit messages to sound more formal, using technical vocabulary, clear sentence structures, and maintaining a respectful tone. It would avoid colloquial language and ensure appropriate salutations and sign-offs',
186
+ iconEmoji: '👔',
187
+ },
188
+ {
189
+ name: 'Friendly Tone',
190
+ description:
191
+ 'This would adjust messages to reflect a casual, friendly tone. It would incorporate casual language, use emoticons, exclamation points, and other informalities to make the message seem more friendly and approachable.',
192
+ iconEmoji: '🤝',
193
+ },
194
+ {
195
+ name: 'Encouraging Tone',
196
+ description:
197
+ 'This tone would be useful for motivation and encouragement. It would include positive words, affirmations, and express support and belief in the recipient.',
198
+ iconEmoji: '💪',
199
+ },
200
+ {
201
+ name: 'Empathetic Tone',
202
+ description:
203
+ 'This tone would be utilized to display understanding and empathy. It would involve softer language, acknowledging feelings, and demonstrating compassion and support.',
204
+ iconEmoji: '🤲',
205
+ },
206
+ {
207
+ name: 'Neutral Tone',
208
+ description:
209
+ 'For times when you want to maintain an even, unbiased, and objective tone. It would avoid extreme language and emotive words, opting for clear, straightforward communication.',
210
+ iconEmoji: '😐',
211
+ },
212
+ {
213
+ name: 'Assertive Tone',
214
+ description:
215
+ 'This tone is beneficial for making clear points, standing ground, or in negotiations. It uses direct language, is confident, and does not mince words.',
216
+ iconEmoji: '🔨',
217
+ },
218
+ {
219
+ name: 'Instructive Tone',
220
+ description:
221
+ 'This tone would be useful for tutorials, guides, or other teaching and training materials. It is clear, concise, and walks the reader through steps or processes in a logical manner.',
222
+ iconEmoji: '📖',
223
+ },
224
+ {
225
+ name: 'Persuasive Tone',
226
+ description:
227
+ 'This tone can be used when trying to convince someone or argue a point. It uses persuasive language, powerful words, and logical reasoning.',
228
+ iconEmoji: '☝️',
229
+ },
230
+ {
231
+ name: 'Sarcastic/Ironic Tone',
232
+ description:
233
+ 'This tone can make the communication more humorous or show an ironic stance. It is harder to implement as it requires the AI to understand nuanced language and may not always be taken as intended by the reader.',
234
+ iconEmoji: '😏',
235
+ },
236
+ {
237
+ name: 'Poetic Tone',
238
+ description:
239
+ 'This would add an artistic touch to messages, using figurative language, rhymes, and rhythm to create a more expressive text.',
240
+ iconEmoji: '🎭',
241
+ },
242
+ ],
170
243
  proxyConfig: {
171
244
  api: 'v1/chat/completions',
172
245
  servername: 'https://api.openai.com/',
173
246
  port: '',
174
- sessionToken: '',
175
247
  },
176
248
  },
177
249
  },
@@ -190,6 +262,70 @@ export class DefaultConfigurations {
190
262
  enable: true,
191
263
  },
192
264
  },
265
+ // credentials: {
266
+ // appId: -1,
267
+ // accountKey: '',
268
+ // authKey: '',
269
+ // authSecret: '',
270
+ // sessionToken: '',
271
+ // },
272
+ // configAIApi: {
273
+ // AIAnswerAssistWidgetConfig: {
274
+ // apiKey: '',
275
+ // useDefault: true,
276
+ // proxyConfig: {
277
+ // api: 'v1/chat/completions',
278
+ // servername: 'https://api.openai.com/',
279
+ // port: '',
280
+ // sessionToken: '',
281
+ // },
282
+ // },
283
+ // AITranslateWidgetConfig: {
284
+ // apiKey: '',
285
+ // useDefault: true,
286
+ // defaultLanguage: 'English',
287
+ // languages: [
288
+ // 'English',
289
+ // 'Spanish',
290
+ // 'French',
291
+ // 'Portuguese',
292
+ // 'German',
293
+ // 'Ukrainian',
294
+ // ],
295
+ // proxyConfig: {
296
+ // api: 'v1/chat/completions',
297
+ // servername: 'https://api.openai.com/',
298
+ // port: '',
299
+ // sessionToken: '',
300
+ // },
301
+ // },
302
+ // AIRephraseWidgetConfig: {
303
+ // apiKey: '',
304
+ // useDefault: true,
305
+ // defaultTone: 'Professional',
306
+ // proxyConfig: {
307
+ // api: 'v1/chat/completions',
308
+ // servername: 'https://api.openai.com/',
309
+ // port: '',
310
+ // sessionToken: '',
311
+ // },
312
+ // },
313
+ // },
314
+ // appConfig: {
315
+ // maxFileSize: 10 * 1024 * 1024,
316
+ // sessionTimeOut: 122,
317
+ // chatProtocol: {
318
+ // active: 2,
319
+ // },
320
+ // debug: true,
321
+ // endpoints: {
322
+ // api: 'api.quickblox.com',
323
+ // chat: 'chat.quickblox.com',
324
+ // },
325
+ // streamManagement: {
326
+ // enable: true,
327
+ // },
328
+ // },
193
329
  };
194
330
  }
195
331
 
@@ -52,6 +52,10 @@ export default class DialogsRepository implements IDialogsRepository {
52
52
  this.dialogLocalDTOMapper = new DialogLocalDTOMapper();
53
53
  }
54
54
 
55
+ release() {
56
+ this.localDataStorage.clearAll();
57
+ }
58
+
55
59
  subscribeLocalSync(subscriber: FunctionTypeVoidToVoid): void {
56
60
  this.localDataStorage.subscribe(subscriber);
57
61
  }
@@ -47,6 +47,8 @@ export default class EventMessagesRepository
47
47
  new SubscriptionPerformer<MessageEntity>();
48
48
  this.subscriptionOnSystemMessages[NotificationTypes.DELETE_LEAVE_DIALOG] =
49
49
  new SubscriptionPerformer<MessageEntity>();
50
+ this.subscriptionOnSystemMessages[NotificationTypes.REMOVE_USER] =
51
+ new SubscriptionPerformer<MessageEntity>();
50
52
  this.subscriptionOnSystemMessages[NotificationTypes.NEW_DIALOG] =
51
53
  new SubscriptionPerformer<MessageEntity>();
52
54
  this.remoteDs.subscribeOnSystemMessaging(
@@ -61,6 +63,10 @@ export default class EventMessagesRepository
61
63
  NotificationTypes.DELETE_LEAVE_DIALOG,
62
64
  this.DeleteLeaveDialogEventHandler.bind(this),
63
65
  );
66
+ this.remoteDs.subscribeOnSystemMessaging(
67
+ NotificationTypes.REMOVE_USER,
68
+ this.RemoteUserDialogEventHandler.bind(this),
69
+ );
64
70
  this.remoteDs.subscribeOnMessaging(this.NewMessageEventHandler.bind(this));
65
71
  this.remoteDs.subscribeOnUpdateMessageStatus(
66
72
  this.UpdateMessageStatusEventHandler.bind(this),
@@ -158,6 +164,31 @@ export default class EventMessagesRepository
158
164
  });
159
165
  }
160
166
 
167
+ protected RemoteUserDialogEventHandler(messageInfo: RemoteMessageDTO): void {
168
+ this.messageDTOMapper
169
+ .toEntity<RemoteMessageDTO, MessageEntity>(messageInfo)
170
+ // eslint-disable-next-line promise/always-return
171
+ .then((currentMessage: MessageEntity) => {
172
+ console.log(
173
+ 'have system message new dialog',
174
+ JSON.stringify(currentMessage),
175
+ );
176
+ this.subscriptionOnSystemMessages[
177
+ NotificationTypes.REMOVE_USER
178
+ ].informSubscribers(currentMessage, EventMessageType.SystemMessage);
179
+ })
180
+ .catch((reason) => {
181
+ const errorMessage = stringifyError(reason);
182
+
183
+ console.log(
184
+ 'get system message with new dialog with exception:',
185
+ errorMessage,
186
+ );
187
+
188
+ throw new Error(errorMessage);
189
+ });
190
+ }
191
+
161
192
  protected UpdateDialogEventHandler(messageInfo: RemoteMessageDTO): void {
162
193
  console.log('call UpdateDialogEventHandler');
163
194
  if (this.messageDTOMapper) {
@@ -274,6 +305,9 @@ export default class EventMessagesRepository
274
305
  case NotificationTypes.DELETE_LEAVE_DIALOG:
275
306
  SystemMessageType = NotificationTypes.DELETE_LEAVE_DIALOG;
276
307
  break;
308
+ case NotificationTypes.REMOVE_USER:
309
+ SystemMessageType = NotificationTypes.REMOVE_USER;
310
+ break;
277
311
  case NotificationTypes.UPDATE_DIALOG:
278
312
  SystemMessageType = NotificationTypes.UPDATE_DIALOG;
279
313
  break;
@@ -225,7 +225,7 @@ export default class MessagesRepository implements IMessagesRepository {
225
225
  await this.remoteDataSource.typingMessageStop(remoteDialogDTO, senderId);
226
226
  }
227
227
 
228
- async saveMessageToLocal(entity: MessageEntity): Promise<boolean> {
228
+ async saveMessageToLocal(entity: MessageEntity): Promise<MessageEntity> {
229
229
  try {
230
230
  const dto: RemoteMessageDTO = await this.messageLocalDTOMapper.fromEntity(
231
231
  entity,
@@ -233,26 +233,32 @@ export default class MessagesRepository implements IMessagesRepository {
233
233
 
234
234
  await this.localDataStorage.saveMessage(dto);
235
235
 
236
- return Promise.resolve(true);
236
+ return Promise.resolve(entity);
237
237
  } catch (e) {
238
- return Promise.resolve(false);
238
+ // eslint-disable-next-line no-param-reassign
239
+ entity.delivered_ids = [];
240
+
241
+ return Promise.resolve(entity);
239
242
  }
240
243
  }
241
244
 
242
- async sendMessageToRemote(entity: MessageEntity): Promise<boolean> {
245
+ async sendMessageToRemote(entity: MessageEntity): Promise<MessageEntity> {
246
+ let messageResult: MessageEntity = entity;
247
+
243
248
  try {
244
- const dto: RemoteMessageDTO =
249
+ const dtoParam: RemoteMessageDTO =
245
250
  await this.messageRemoteDTOMapper.fromEntity(entity);
246
251
 
247
- await this.remoteDataSource.sendMessage(dto);
252
+ const dtoResult: RemoteMessageDTO =
253
+ await this.remoteDataSource.sendMessage(dtoParam);
248
254
 
249
- return Promise.resolve(true);
255
+ messageResult = await this.messageRemoteDTOMapper.toEntity(dtoResult);
256
+
257
+ return Promise.resolve(messageResult);
250
258
  } catch (e) {
251
259
  // eslint-disable-next-line prefer-promise-reject-errors
252
- return Promise.reject(false);
260
+ return Promise.reject(messageResult);
253
261
  }
254
-
255
- return Promise.resolve(false);
256
262
  }
257
263
 
258
264
  async updateMessageInLocal(entity: MessageEntity): Promise<boolean> {
@@ -15,5 +15,8 @@ export class MapperDTOException extends RepositoryException {
15
15
  constructor(message: string, code: number, description = '') {
16
16
  super(message, code);
17
17
  this._description = description;
18
+ if (this._description) {
19
+ this.message += ` ${this._description}`;
20
+ }
18
21
  }
19
22
  }