@channelhub/widget 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChannelHubInbox.d.ts.map +1 -1
- package/dist/api.d.ts +7 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +37 -27
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1485 -1003
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ChannelHubInbox.tsx +512 -15
- package/src/api.ts +12 -1
- package/src/index.ts +1 -1
- package/src/types.ts +12 -0
package/src/api.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Connection, Conversation, Message, MessageAttachment, Page } from './types.js';
|
|
1
|
+
import type { ChannelHubAgent, Connection, Conversation, Message, MessageAttachment, Page } from './types.js';
|
|
2
2
|
|
|
3
3
|
export class ChannelHubClient {
|
|
4
4
|
constructor(private readonly apiUrl: string, private readonly token: string) {}
|
|
@@ -18,6 +18,17 @@ export class ChannelHubClient {
|
|
|
18
18
|
return body as T;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
getSessionMe(): Promise<{ tenantId: string; scopes: string[]; agent?: ChannelHubAgent | null }> {
|
|
22
|
+
return this.request('/v1/auth/session/me');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
assignConversation(conversationId: string, agent: ChannelHubAgent | null): Promise<Conversation> {
|
|
26
|
+
return this.request(`/v1/conversations/${encodeURIComponent(conversationId)}/assignee`, {
|
|
27
|
+
method: 'PATCH',
|
|
28
|
+
body: JSON.stringify({ agent }),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
listConnections(): Promise<Connection[]> { return this.request('/v1/connections'); }
|
|
22
33
|
|
|
23
34
|
listConversations(cursor?: string): Promise<Page<Conversation>> {
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,6 @@ export { ChannelHubInbox } from './ChannelHubInbox.js';
|
|
|
5
5
|
export { ChannelHubChannels } from './ChannelHubChannels.js';
|
|
6
6
|
export { ChannelHubNotificationBell } from './ChannelHubNotificationBell.js';
|
|
7
7
|
export { ChannelHubClient } from './api.js';
|
|
8
|
-
export type { WidgetProps, WidgetTheme, Conversation, Message, ChannelHubInboxHandle } from './types.js';
|
|
8
|
+
export type { WidgetProps, WidgetTheme, Conversation, Message, ChannelHubInboxHandle, ChannelHubAgent } from './types.js';
|
|
9
9
|
export type { ChannelHubChannelsProps, ChannelConnection } from './ChannelHubChannels.js';
|
|
10
10
|
export type { ChannelHubNotificationBellProps } from './ChannelHubNotificationBell.js';
|
package/src/types.ts
CHANGED
|
@@ -4,6 +4,14 @@ export type Provider = 'facebook' | 'instagram' | 'telegram' | 'zalo' | string;
|
|
|
4
4
|
|
|
5
5
|
export type Connection = { id: string; provider: Provider; type?: string; metadata?: Record<string, unknown> };
|
|
6
6
|
|
|
7
|
+
export interface ChannelHubAgent {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
avatarUrl?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
export type Conversation = {
|
|
8
16
|
id: string;
|
|
9
17
|
connectionId: string;
|
|
@@ -19,6 +27,7 @@ export type Conversation = {
|
|
|
19
27
|
lastMessageDirection?: 'inbound' | 'outbound';
|
|
20
28
|
messageCount?: number;
|
|
21
29
|
unreadCount?: number;
|
|
30
|
+
assignedAgent?: ChannelHubAgent | null;
|
|
22
31
|
};
|
|
23
32
|
|
|
24
33
|
export type MessageAttachment = {
|
|
@@ -35,6 +44,7 @@ export type Message = {
|
|
|
35
44
|
attachments?: MessageAttachment[];
|
|
36
45
|
occurredAt: string;
|
|
37
46
|
senderId?: string;
|
|
47
|
+
senderAgent?: ChannelHubAgent | null;
|
|
38
48
|
};
|
|
39
49
|
|
|
40
50
|
export type Page<T> = { items: T[]; nextCursor?: string };
|
|
@@ -126,6 +136,8 @@ export type WidgetProps = {
|
|
|
126
136
|
hideKeyboardHint?: boolean;
|
|
127
137
|
locale?: 'vi' | 'en';
|
|
128
138
|
extensions?: Extension[];
|
|
139
|
+
currentAgent?: ChannelHubAgent | null;
|
|
140
|
+
teamAgents?: ChannelHubAgent[];
|
|
129
141
|
onNewMessage?: (conversationId: string) => void;
|
|
130
142
|
onConversationSelect?: (conversationId: string) => void;
|
|
131
143
|
};
|