@webinex/chatify 2.0.0-alpha4 → 2.0.0-alpha8

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.
@@ -1,6 +1,6 @@
1
1
  import { AxiosInstance } from 'axios';
2
2
  import * as SignalR from '@microsoft/signalr';
3
- import { Account, AddChatRequest, AddChatMemberRequest, Chat, ChatListItem, ChatMessage, ReadChatMessageEvent, ReadChatMessageRequest, RemoveChatMemberRequest, SendChatMessageRequest, UpdateChatNameRequest, SendThreadMessageRequest, Thread, ThreadMessage, ThreadWatchListItem as ThreadListItem } from './types';
3
+ import { Account, AddChatRequest, AddChatMemberRequest, Chat, ChatListItem, ChatMessage, ReadChatMessageEvent, ReadChatMessageRequest, RemoveChatMemberRequest, SendChatMessageRequest, UpdateChatNameRequest, SendThreadMessageRequest, Thread, ThreadMessage, ThreadWatchListItem as ThreadListItem, UpdateAccountRequest } from './types';
4
4
  export interface ChatifySignalRConfig {
5
5
  hubUri?: string;
6
6
  accessTokenFactory?: () => Promise<string>;
@@ -10,7 +10,7 @@ export interface ChatifyClientConfig {
10
10
  axios: AxiosInstance;
11
11
  signalR: ChatifySignalRConfig;
12
12
  }
13
- export declare const CHATIFY_SIGNALR_METHODS: readonly ["chatify://chat-new-message", "chatify://chat-created", "chatify://chat-message-read", "chatify://chat-member-added", "chatify://chat-member-removed", "chatify://chat-name-changed", "chatify://thread-created", "chatify://thread-message-new", "chatify://thread-message-read", "chatify://thread-watch-added", "chatify://thread-watch-removed"];
13
+ export declare const CHATIFY_SIGNALR_METHODS: readonly ["chatify://chat-new-message", "chatify://chat-created", "chatify://chat-message-read", "chatify://chat-member-added", "chatify://chat-member-removed", "chatify://chat-name-changed", "chatify://thread-created", "chatify://thread-message-new", "chatify://thread-message-read", "chatify://thread-watch-added", "chatify://thread-watch-removed", "chatify://thread-updated"];
14
14
  export type ChatifySignalRMethod = (typeof CHATIFY_SIGNALR_METHODS)[number];
15
15
  export type ChatifySignalRArgsByMethod = {
16
16
  'chatify://chat-new-message': [message: ChatMessage];
@@ -37,6 +37,7 @@ export type ChatifySignalRArgsByMethod = {
37
37
  'chatify://thread-watch-added': [thread: ThreadListItem];
38
38
  'chatify://thread-watch-removed': [id: string];
39
39
  'chatify://thread-created': [thread: ThreadListItem, watch: boolean];
40
+ 'chatify://thread-updated': [threadId: string, threadName: string];
40
41
  };
41
42
  export declare class ChatifyClient {
42
43
  private _config;
@@ -48,10 +49,11 @@ export declare class ChatifyClient {
48
49
  constructor(config: ChatifyClientConfig);
49
50
  connect: () => Promise<SignalR.HubConnection | undefined>;
50
51
  private createAndStartConnection;
51
- subscribe: <TMethod extends "chatify://chat-created" | "chatify://chat-name-changed" | "chatify://chat-new-message" | "chatify://chat-message-read" | "chatify://chat-member-added" | "chatify://chat-member-removed" | "chatify://thread-created" | "chatify://thread-message-new" | "chatify://thread-message-read" | "chatify://thread-watch-added" | "chatify://thread-watch-removed">(method: TMethod, subscriber: (args: ChatifySignalRArgsByMethod[TMethod]) => void) => () => ((args: any[]) => void)[];
52
+ subscribe: <TMethod extends "chatify://chat-created" | "chatify://chat-name-changed" | "chatify://chat-new-message" | "chatify://chat-message-read" | "chatify://chat-member-added" | "chatify://chat-member-removed" | "chatify://thread-created" | "chatify://thread-message-new" | "chatify://thread-message-read" | "chatify://thread-watch-added" | "chatify://thread-watch-removed" | "chatify://thread-updated">(method: TMethod, subscriber: (args: ChatifySignalRArgsByMethod[TMethod]) => void) => () => ((args: any[]) => void)[];
52
53
  subscribeReconnect: (subscriber: () => any) => () => (() => void)[];
53
54
  private get axios();
54
55
  accounts: () => Promise<Account[]>;
56
+ updateAccount: (request: UpdateAccountRequest) => Promise<void>;
55
57
  chats: () => Promise<ChatListItem[]>;
56
58
  chat: (id: string) => Promise<Chat>;
57
59
  addChat: (args: AddChatRequest) => Promise<string>;
@@ -1,12 +1,32 @@
1
+ export interface Optional<TValue> {
2
+ hasValue: boolean;
3
+ value?: TValue | null;
4
+ }
1
5
  export interface File {
2
6
  name: string;
3
7
  bytes: number;
4
8
  ref: string;
5
9
  }
10
+ export interface Period {
11
+ start: string;
12
+ end: string;
13
+ }
14
+ export interface AutoReply {
15
+ text: string;
16
+ period: Period;
17
+ }
6
18
  export interface Account {
7
19
  id: string;
8
20
  name: string;
9
21
  avatar: string;
22
+ autoReply: AutoReply | null;
23
+ }
24
+ export interface UpdateAccountRequest {
25
+ id: string;
26
+ autoReply?: Optional<AutoReply> | null;
27
+ name?: Optional<string> | null;
28
+ avatar?: Optional<string> | null;
29
+ active?: Optional<boolean> | null;
10
30
  }
11
31
  export interface MessageBase {
12
32
  id: string;
package/dist/index.d.ts CHANGED
@@ -83,15 +83,35 @@ declare const ChatList: Customizable<react.ComponentType<unknown>>;
83
83
 
84
84
  declare const SYSTEM_ID = "chatify::system";
85
85
 
86
+ interface Optional<TValue> {
87
+ hasValue: boolean;
88
+ value?: TValue | null;
89
+ }
86
90
  interface File {
87
91
  name: string;
88
92
  bytes: number;
89
93
  ref: string;
90
94
  }
95
+ interface Period {
96
+ start: string;
97
+ end: string;
98
+ }
99
+ interface AutoReply {
100
+ text: string;
101
+ period: Period;
102
+ }
91
103
  interface Account {
92
104
  id: string;
93
105
  name: string;
94
106
  avatar: string;
107
+ autoReply: AutoReply | null;
108
+ }
109
+ interface UpdateAccountRequest {
110
+ id: string;
111
+ autoReply?: Optional<AutoReply> | null;
112
+ name?: Optional<string> | null;
113
+ avatar?: Optional<string> | null;
114
+ active?: Optional<boolean> | null;
95
115
  }
96
116
  interface MessageBase {
97
117
  id: string;
@@ -195,7 +215,7 @@ interface ChatifyClientConfig {
195
215
  axios: AxiosInstance;
196
216
  signalR: ChatifySignalRConfig;
197
217
  }
198
- declare const CHATIFY_SIGNALR_METHODS: readonly ["chatify://chat-new-message", "chatify://chat-created", "chatify://chat-message-read", "chatify://chat-member-added", "chatify://chat-member-removed", "chatify://chat-name-changed", "chatify://thread-created", "chatify://thread-message-new", "chatify://thread-message-read", "chatify://thread-watch-added", "chatify://thread-watch-removed"];
218
+ declare const CHATIFY_SIGNALR_METHODS: readonly ["chatify://chat-new-message", "chatify://chat-created", "chatify://chat-message-read", "chatify://chat-member-added", "chatify://chat-member-removed", "chatify://chat-name-changed", "chatify://thread-created", "chatify://thread-message-new", "chatify://thread-message-read", "chatify://thread-watch-added", "chatify://thread-watch-removed", "chatify://thread-updated"];
199
219
  type ChatifySignalRMethod = (typeof CHATIFY_SIGNALR_METHODS)[number];
200
220
  type ChatifySignalRArgsByMethod = {
201
221
  'chatify://chat-new-message': [message: ChatMessage];
@@ -222,6 +242,7 @@ type ChatifySignalRArgsByMethod = {
222
242
  'chatify://thread-watch-added': [thread: ThreadWatchListItem];
223
243
  'chatify://thread-watch-removed': [id: string];
224
244
  'chatify://thread-created': [thread: ThreadWatchListItem, watch: boolean];
245
+ 'chatify://thread-updated': [threadId: string, threadName: string];
225
246
  };
226
247
  declare class ChatifyClient {
227
248
  private _config;
@@ -233,10 +254,11 @@ declare class ChatifyClient {
233
254
  constructor(config: ChatifyClientConfig);
234
255
  connect: () => Promise<SignalR.HubConnection | undefined>;
235
256
  private createAndStartConnection;
236
- subscribe: <TMethod extends "chatify://chat-created" | "chatify://chat-name-changed" | "chatify://chat-new-message" | "chatify://chat-message-read" | "chatify://chat-member-added" | "chatify://chat-member-removed" | "chatify://thread-created" | "chatify://thread-message-new" | "chatify://thread-message-read" | "chatify://thread-watch-added" | "chatify://thread-watch-removed">(method: TMethod, subscriber: (args: ChatifySignalRArgsByMethod[TMethod]) => void) => () => ((args: any[]) => void)[];
257
+ subscribe: <TMethod extends "chatify://chat-created" | "chatify://chat-name-changed" | "chatify://chat-new-message" | "chatify://chat-message-read" | "chatify://chat-member-added" | "chatify://chat-member-removed" | "chatify://thread-created" | "chatify://thread-message-new" | "chatify://thread-message-read" | "chatify://thread-watch-added" | "chatify://thread-watch-removed" | "chatify://thread-updated">(method: TMethod, subscriber: (args: ChatifySignalRArgsByMethod[TMethod]) => void) => () => ((args: any[]) => void)[];
237
258
  subscribeReconnect: (subscriber: () => any) => () => (() => void)[];
238
259
  private get axios();
239
260
  accounts: () => Promise<Account[]>;
261
+ updateAccount: (request: UpdateAccountRequest) => Promise<void>;
240
262
  chats: () => Promise<ChatListItem[]>;
241
263
  chat: (id: string) => Promise<Chat>;
242
264
  addChat: (args: AddChatRequest) => Promise<string>;
@@ -13359,4 +13381,4 @@ declare const Chatify: {
13359
13381
  Chat: typeof ChatPanel;
13360
13382
  };
13361
13383
 
13362
- export { Account, AddChatMemberRequest, AddChatRequest, Avatar, AvatarProps, CHATIFY_SIGNALR_METHODS, Chat, ChatContext, ChatEditableHeaderName, ChatGroupAside, ChatGroupBody, ChatGroupContext, ChatGroupCustomizeValue, ChatGroupFooter, ChatGroupHeader, ChatGroupLayoutCustomizeValue, ChatGroupMain, ChatGroupPanel, ChatHeaderActions, ChatList, ChatListCustomizeValue, ChatListItem, ChatListItemAvatar, ChatListItemBox, ChatListItemBoxProps, ChatListItemLastMessage, ChatListItemLastMessageAuthor, ChatListItemLastMessageContent, ChatListItemLastMessageSentAt, ChatListItemName, ChatListItemUnreadCount, ChatMembersButton, ChatMembersCustomizeValue, ChatMembersPanel, ChatMembersPreview, ChatMessage, ChatMessageListResult, ChatPanel, ChatPanelCustomizeValue, ChatPanelProps, ChatProps, ChatValue, ChatView, ChatViewCustomizeValue, Chatify, ChatifyClient, ChatifyClientConfig, ChatifyProps, ChatifySignalRArgsByMethod, ChatifySignalRConfig, ChatifySignalRMethod, Conversation, ConversationActions, ConversationBody, ConversationContext, ConversationContextValue, ConversationCustomizeValue, ConversationHeader, ConversationName, ConversationProps, ConversationValue, CreateChatButton, CreateChatForm, CreateChatFormProps, CreateChatFormValue, CreateChatMemberInput, CreateChatMemberInputProps, CreateChatNameInput, CreateChatNameInputProps, CreateChatPanel, CreateChatPanelCustomizeValue, Customizable, CustomizeContext, DEFAULT_CHAT_VIEW_CUSTOMIZE_VALUE, File, ICONS, Icon, IconProps, IconType, InputBox, InputBoxCustomizeValue, InputBoxFile, InputBoxFileList, InputBoxFileListProps, InputBoxFileProps, InputFileButton, InputFilesBox, InputFilesBoxProps, InputSubmitButtonBox, InputSubmitButtonBoxProps, InputTextBox, Localizer, LocalizerContext, MessageAuthor, MessageBase, MessageBody, MessageBox, MessageBoxProps, MessageContent, MessageCustomizeValue, MessageFile, MessageFileList, MessageFileProps, MessageInfoBox, MessageReadObserver, MessageReadObserverProps, MessageRow, MessageRowProps, MessageSkeleton, MessageSkeletonProps, MessageText, NextMessagesObserver, NextMessagesObserverProps, ReadChatMessageEvent, ReadChatMessageRequest, RemoveChatMemberRequest, SYSTEM_ID, SendChatMessageRequest, SendThreadMessageRequest, SendingMessageBox, SendingMessageBoxProps, SendingMessageContent, SendingMessageCustomizeValue, SendingMessageInfoBox, SendingMessageText, SystemMessageBox, SystemMessageBoxProps, SystemMessageCustomizeValue, SystemMessageRow, SystemMessageRowProps, SystemMessageText, TextInputBoxProps, Thread, ThreadActions, ThreadContext, ThreadContextValue, ThreadCustomizeValue, ThreadMessage, ThreadMessageList, ThreadPanel, ThreadPanelProps, ThreadWatchListItem, UpdateChatNameRequest, calcThreadListUnreadCount, calcThreadUnreadCount, chatId, chatifyApi, color, customize, defaultLocalizer, formatSystemMessage, parseThreadMessageId, unsubscribe, useChatContext, useChatGroupContext, useChatListItem, useConversation, useCustomize, useCustomizeContext, useLocalizer, useThreadContext, useUnreadThreadMessageCount };
13384
+ export { Account, AddChatMemberRequest, AddChatRequest, AutoReply, Avatar, AvatarProps, CHATIFY_SIGNALR_METHODS, Chat, ChatContext, ChatEditableHeaderName, ChatGroupAside, ChatGroupBody, ChatGroupContext, ChatGroupCustomizeValue, ChatGroupFooter, ChatGroupHeader, ChatGroupLayoutCustomizeValue, ChatGroupMain, ChatGroupPanel, ChatHeaderActions, ChatList, ChatListCustomizeValue, ChatListItem, ChatListItemAvatar, ChatListItemBox, ChatListItemBoxProps, ChatListItemLastMessage, ChatListItemLastMessageAuthor, ChatListItemLastMessageContent, ChatListItemLastMessageSentAt, ChatListItemName, ChatListItemUnreadCount, ChatMembersButton, ChatMembersCustomizeValue, ChatMembersPanel, ChatMembersPreview, ChatMessage, ChatMessageListResult, ChatPanel, ChatPanelCustomizeValue, ChatPanelProps, ChatProps, ChatValue, ChatView, ChatViewCustomizeValue, Chatify, ChatifyClient, ChatifyClientConfig, ChatifyProps, ChatifySignalRArgsByMethod, ChatifySignalRConfig, ChatifySignalRMethod, Conversation, ConversationActions, ConversationBody, ConversationContext, ConversationContextValue, ConversationCustomizeValue, ConversationHeader, ConversationName, ConversationProps, ConversationValue, CreateChatButton, CreateChatForm, CreateChatFormProps, CreateChatFormValue, CreateChatMemberInput, CreateChatMemberInputProps, CreateChatNameInput, CreateChatNameInputProps, CreateChatPanel, CreateChatPanelCustomizeValue, Customizable, CustomizeContext, DEFAULT_CHAT_VIEW_CUSTOMIZE_VALUE, File, ICONS, Icon, IconProps, IconType, InputBox, InputBoxCustomizeValue, InputBoxFile, InputBoxFileList, InputBoxFileListProps, InputBoxFileProps, InputFileButton, InputFilesBox, InputFilesBoxProps, InputSubmitButtonBox, InputSubmitButtonBoxProps, InputTextBox, Localizer, LocalizerContext, MessageAuthor, MessageBase, MessageBody, MessageBox, MessageBoxProps, MessageContent, MessageCustomizeValue, MessageFile, MessageFileList, MessageFileProps, MessageInfoBox, MessageReadObserver, MessageReadObserverProps, MessageRow, MessageRowProps, MessageSkeleton, MessageSkeletonProps, MessageText, NextMessagesObserver, NextMessagesObserverProps, Optional, Period, ReadChatMessageEvent, ReadChatMessageRequest, RemoveChatMemberRequest, SYSTEM_ID, SendChatMessageRequest, SendThreadMessageRequest, SendingMessageBox, SendingMessageBoxProps, SendingMessageContent, SendingMessageCustomizeValue, SendingMessageInfoBox, SendingMessageText, SystemMessageBox, SystemMessageBoxProps, SystemMessageCustomizeValue, SystemMessageRow, SystemMessageRowProps, SystemMessageText, TextInputBoxProps, Thread, ThreadActions, ThreadContext, ThreadContextValue, ThreadCustomizeValue, ThreadMessage, ThreadMessageList, ThreadPanel, ThreadPanelProps, ThreadWatchListItem, UpdateAccountRequest, UpdateChatNameRequest, calcThreadListUnreadCount, calcThreadUnreadCount, chatId, chatifyApi, color, customize, defaultLocalizer, formatSystemMessage, parseThreadMessageId, unsubscribe, useChatContext, useChatGroupContext, useChatListItem, useConversation, useCustomize, useCustomizeContext, useLocalizer, useThreadContext, useUnreadThreadMessageCount };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@webinex/chatify",
3
3
  "description": "Webinex Chatify",
4
4
  "private": false,
5
- "version": "2.0.0-alpha4",
5
+ "version": "2.0.0-alpha8",
6
6
  "author": "Webinex Dev",
7
7
  "license": "Apache-2.0",
8
8
  "main": "src/index.ts",
@@ -459,6 +459,14 @@ const __chatifyApi = __baseApi.injectEndpoints({
459
459
  if (index !== -1) threads.splice(index, 1);
460
460
  }),
461
461
  ),
462
+ __settings.client.subscribe('chatify://thread-updated', ([threadId, threadName]) =>
463
+ updateCachedData((threads) => {
464
+ const thread = threads.find((x) => x.id === threadId);
465
+ if (!thread) return;
466
+
467
+ thread.name = threadName;
468
+ }),
469
+ ),
462
470
  ).when(cacheEntryRemoved);
463
471
  },
464
472
  }),
@@ -509,6 +517,14 @@ const __chatifyApi = __baseApi.injectEndpoints({
509
517
  thread.watch = false;
510
518
  }),
511
519
  ),
520
+ __settings.client.subscribe(
521
+ 'chatify://thread-updated',
522
+ ([threadId, threadName]) =>
523
+ id === threadId &&
524
+ updateCachedData((thread) => {
525
+ thread.name = threadName;
526
+ }),
527
+ ),
512
528
  ).when(cacheEntryRemoved);
513
529
  },
514
530
  }),
@@ -16,6 +16,7 @@ import {
16
16
  Thread,
17
17
  ThreadMessage,
18
18
  ThreadWatchListItem as ThreadListItem,
19
+ UpdateAccountRequest,
19
20
  } from './types';
20
21
 
21
22
  export interface ChatifySignalRConfig {
@@ -47,6 +48,7 @@ export const CHATIFY_SIGNALR_METHODS = [
47
48
  'chatify://thread-message-read',
48
49
  'chatify://thread-watch-added',
49
50
  'chatify://thread-watch-removed',
51
+ 'chatify://thread-updated',
50
52
  ] as const;
51
53
 
52
54
  export type ChatifySignalRMethod = (typeof CHATIFY_SIGNALR_METHODS)[number];
@@ -77,6 +79,7 @@ export type ChatifySignalRArgsByMethod = {
77
79
  'chatify://thread-watch-added': [thread: ThreadListItem];
78
80
  'chatify://thread-watch-removed': [id: string];
79
81
  'chatify://thread-created': [thread: ThreadListItem, watch: boolean];
82
+ 'chatify://thread-updated': [threadId: string, threadName: string];
80
83
  };
81
84
 
82
85
  export class ChatifyClient {
@@ -166,6 +169,10 @@ export class ChatifyClient {
166
169
  return data;
167
170
  };
168
171
 
172
+ public updateAccount = async (request: UpdateAccountRequest) => {
173
+ await this.axios.put(`account/${encodeURIComponent(request.id)}`, request);
174
+ };
175
+
169
176
  public chats = async () => {
170
177
  const { data } = await this.axios.get<ChatListItem[]>('chat');
171
178
  return data;
@@ -1,13 +1,37 @@
1
+ export interface Optional<TValue> {
2
+ hasValue: boolean;
3
+ value?: TValue | null;
4
+ }
5
+
1
6
  export interface File {
2
7
  name: string;
3
8
  bytes: number;
4
9
  ref: string;
5
10
  }
6
11
 
12
+ export interface Period {
13
+ start: string;
14
+ end: string;
15
+ }
16
+
17
+ export interface AutoReply {
18
+ text: string;
19
+ period: Period;
20
+ }
21
+
7
22
  export interface Account {
8
23
  id: string;
9
24
  name: string;
10
25
  avatar: string;
26
+ autoReply: AutoReply | null;
27
+ }
28
+
29
+ export interface UpdateAccountRequest {
30
+ id: string;
31
+ autoReply?: Optional<AutoReply> | null;
32
+ name?: Optional<string> | null;
33
+ avatar?: Optional<string> | null;
34
+ active?: Optional<boolean> | null;
11
35
  }
12
36
 
13
37
  export interface MessageBase {
@@ -75,7 +75,7 @@
75
75
  }
76
76
 
77
77
  .wxchtf-chat-info {
78
- min-width: 1;
78
+ min-width: 0;
79
79
  }
80
80
 
81
81
  .wxchtf-chat-name {
@@ -6,14 +6,14 @@
6
6
  flex: auto;
7
7
  display: flex;
8
8
  flex-flow: row nowrap;
9
- min-width: 1;
9
+ min-width: 0;
10
10
  }
11
11
 
12
12
  .wxchtf-conversation {
13
13
  flex: auto;
14
14
  display: flex;
15
15
  flex-flow: row nowrap;
16
- min-width: 1;
16
+ min-width: 0;
17
17
 
18
18
  .wxchtf-conversation-main {
19
19
  flex: 1;