ajaxter-chat 3.1.0 → 3.2.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.
@@ -1,208 +1,242 @@
1
- // ─── Remote Config (from chatData.json) ────────────────────────────────────
1
+ // ─── Ajaxter Server Config Shape ─────────────────────────────────────────────
2
+
3
+ export interface AjaxterWidgetTheme {
4
+ header: { background: string; text: string };
5
+ agent: { messageBackground: string; messageText: string };
6
+ visitor: { messageBackground: string; messageText: string };
7
+ }
8
+
9
+ export interface AjaxterWidgetFeatures {
10
+ emoji: boolean;
11
+ rating: boolean;
12
+ transcript: boolean;
13
+ voice: boolean;
14
+ attachment: boolean;
15
+ webCall: boolean;
16
+ }
17
+
18
+ export interface AjaxterMinimized {
19
+ desktop: { type: 'slide' | 'round' | 'square'; height?: number; width?: number; borderRadiusTop?: number; borderRadiusBottom?: number };
20
+ mobile: { type: 'round' | 'slide' | 'square' };
21
+ }
22
+
23
+ export interface AjaxterWidgetSettings {
24
+ type: 'inline' | 'popup' | 'embed';
25
+ language: string;
26
+ minimized: AjaxterMinimized;
27
+ maximized: { desktop: { height: number; width: number } };
28
+ theme: AjaxterWidgetTheme;
29
+ notification?: {
30
+ all?: { sound?: boolean; agentTyping?: boolean; visitorTyping?: boolean };
31
+ desktop?: { preview?: boolean };
32
+ mobile?: { preview?: boolean };
33
+ };
34
+ behavior?: { defaultView?: string };
35
+ visibility?: {
36
+ all?: { showWhenOffline?: boolean };
37
+ desktop?: { position?: string; show?: boolean };
38
+ mobile?: { position?: string; show?: boolean };
39
+ };
40
+ features: AjaxterWidgetFeatures;
41
+ scheduler?: { enabled: boolean; config?: unknown };
42
+ states?: Record<string, unknown>;
43
+ }
44
+
45
+ /** Internal fields that drive the npm widget behaviour */
46
+ export interface AjaxterInternalConfig {
47
+ id: string;
48
+ apiKey: string;
49
+ status: ChatStatus;
50
+ chatType: ChatType;
51
+ /** 'slider' = side drawer, 'popup' = centered modal, 'inline' = embedded in page */
52
+ displayMode: DisplayMode;
53
+ primaryColor: string;
54
+ buttonLabel: string;
55
+ brandName: string | null;
56
+ supportPhone: string | null;
57
+ privacyPolicyUrl: string | null;
58
+ showPrivacyNotice: boolean;
59
+ allowVoiceMessage: boolean;
60
+ allowAttachment: boolean;
61
+ allowEmoji: boolean;
62
+ allowWebCall: boolean;
63
+ maxEmojiCount: number;
64
+ allowTranscript: boolean;
65
+ allowReport: boolean;
66
+ allowBlock: boolean;
67
+ }
68
+
69
+ /** Full response shape from GET /api/chat-config */
70
+ export interface AjaxterConfigResponse {
71
+ ok: boolean;
72
+ data: {
73
+ settingsVersion: string;
74
+ propertyName: string;
75
+ branding: { name: string };
76
+ widget: AjaxterWidgetSettings;
77
+ _internal: AjaxterInternalConfig;
78
+ developers: ChatUser[];
79
+ users: ChatUser[];
80
+ sampleChats: Record<string, ChatMessage[]>;
81
+ sampleTickets: Ticket[];
82
+ blockedUsers: string[];
83
+ };
84
+ }
85
+
86
+ /** The merged WidgetConfig shape used throughout the widget components */
2
87
  export interface WidgetConfig {
3
- id: string;
4
- apiKey: string;
5
- status: ChatStatus;
6
- chatType: ChatType;
7
- primaryColor: string;
8
- buttonLabel: string;
9
- buttonPosition: 'bottom-right' | 'bottom-left';
10
- welcomeTitle: string;
11
- welcomeSubtitle: string;
12
- /** Shown in footer (e.g. branch / location name) */
13
- branch?: string;
14
- /** Optional label above branch (e.g. "Answers by") */
15
- footerPoweredBy?: string;
16
- /** Shown on home “Call Us” (tel: link) */
17
- supportPhone?: string;
18
- /**
19
- * Who is using the widget. `developer` = support staff: “Need Support” becomes “Provide Support”
20
- * and lists customers; “New Conversation” lists other developers (excl. viewerUid).
21
- */
22
- viewerType?: 'user' | 'developer';
23
- /** Current user id when viewerType is developer — excluded from developer pick lists */
24
- viewerUid?: string;
25
- /** Display name for transfer notes (optional) */
26
- viewerName?: string;
27
- /**
28
- * Host app project scope (set when embedding passes `viewer.projectId`).
29
- * Use for API calls; lists can be filtered to users in the same project.
30
- */
31
- viewerProjectId?: string;
32
- /** Privacy Policy URL (linked from chat consent banner) */
88
+ id: string;
89
+ apiKey: string;
90
+ status: ChatStatus;
91
+ chatType: ChatType;
92
+ displayMode: DisplayMode;
93
+ primaryColor: string;
94
+ buttonLabel: string;
95
+ buttonPosition: 'bottom-right' | 'bottom-left';
96
+ welcomeTitle: string;
97
+ welcomeSubtitle: string;
98
+ branch?: string;
99
+ footerPoweredBy?: string;
100
+ supportPhone?: string;
101
+ viewerType?: 'user' | 'developer';
102
+ viewerUid?: string;
103
+ viewerName?: string;
104
+ viewerProjectId?: string;
33
105
  privacyPolicyUrl?: string;
34
- /** Set false to hide the consent note above the composer */
35
106
  showPrivacyNotice?: boolean;
36
- /** Product brand (e.g. Ajaxter) */
37
- brandName?: string;
38
- /** Home promotion: “Take a Website Tour” link */
39
- websiteTourUrl?: string;
40
- /** Optional override for the lead line in the promotion card */
41
- promotionLead?: string;
107
+ brandName?: string;
108
+ websiteTourUrl?: string;
109
+ promotionLead?: string;
42
110
  allowVoiceMessage: boolean;
43
- allowAttachment: boolean;
44
- allowEmoji: boolean;
45
- allowWebCall: boolean;
46
- maxEmojiCount: number;
111
+ allowAttachment: boolean;
112
+ allowEmoji: boolean;
113
+ allowWebCall: boolean;
114
+ maxEmojiCount: number;
47
115
  allowTranscriptDownload: boolean;
48
- allowReport: boolean;
49
- allowBlock: boolean;
50
- /**
51
- * When `true` (set by the server if this viewer is spam-blocked or not in allowed user/ticket/chat lists),
52
- * the widget hides all normal navigation and shows only the blocked-user screen with a re-enable request form.
53
- */
54
- viewerBlocked?: boolean;
55
- /** Optional override for the blocked message (default is a fixed spam notice). */
116
+ allowReport: boolean;
117
+ allowBlock: boolean;
118
+ viewerBlocked?: boolean;
56
119
  blockedViewerMessage?: string;
57
- /**
58
- * Absolute URL for `POST` JSON re-enable requests. If omitted, the submit button explains that no endpoint is configured.
59
- * @example https://api.example.com/widgets/reenable-request
60
- */
61
120
  reenableRequestUrl?: string;
62
- /**
63
- * Current presence from your API/DB (include in chatData or a session payload).
64
- * When set, it initializes the status control and overrides session-only cache.
65
- */
66
- presenceStatus?: PresenceStatus;
67
- /**
68
- * Production: `POST` JSON `{ widgetId, apiKey, viewerUid?, status }` to save presence in your database.
69
- * The client still mirrors to sessionStorage as a local fallback.
70
- */
121
+ presenceStatus?: PresenceStatus;
71
122
  presenceUpdateUrl?: string;
123
+ /** Full Ajaxter settings from server (for display-mode, theming, etc.) */
124
+ ajaxterSettings?: AjaxterWidgetSettings;
72
125
  }
73
126
 
74
127
  export interface RemoteChatData {
75
- widget: WidgetConfig;
76
- developers: ChatUser[];
77
- users: ChatUser[];
78
- sampleChats: Record<string, ChatMessage[]>;
128
+ widget: WidgetConfig;
129
+ developers: ChatUser[];
130
+ users: ChatUser[];
131
+ sampleChats: Record<string, ChatMessage[]>;
79
132
  sampleTickets: Ticket[];
80
133
  blockedUsers: string[];
81
134
  }
82
135
 
83
- // ─── Enums ──────────────────────────────────────────────────────────────────
136
+ // ─── Enums ───────────────────────────────────────────────────────────────────
84
137
  export type ChatStatus = 'ACTIVE' | 'DISABLE' | 'MAINTENANCE';
85
138
  export type ChatType = 'SUPPORT' | 'CHAT' | 'BOTH';
139
+ export type DisplayMode = 'slider' | 'popup' | 'inline';
86
140
  export type UserType = 'developer' | 'user';
87
141
  export type OnlineStatus = 'online' | 'away' | 'offline';
88
142
  export type BottomTab = 'home' | 'chats' | 'tickets';
89
- export type Screen =
90
- | 'home'
91
- | 'user-list'
92
- | 'chat'
93
- | 'recent-chats'
94
- | 'tickets'
95
- | 'ticket-new'
96
- | 'ticket-detail'
97
- | 'block-list'
98
- | 'call';
143
+ export type Screen =
144
+ | 'home' | 'user-list' | 'chat' | 'recent-chats'
145
+ | 'tickets' | 'ticket-new' | 'ticket-detail'
146
+ | 'block-list' | 'call';
99
147
  export type UserListContext = 'support' | 'conversation';
100
148
  export type MessageType = 'text' | 'voice' | 'attachment' | 'emoji';
101
-
102
- /** Home status selector; persist via `presenceUpdateUrl` in production */
103
149
  export type PresenceStatus = 'ACTIVE' | 'AWAY' | 'DND';
104
150
 
105
- // ─── User ───────────────────────────────────────────────────────────────────
151
+ // ─── User ────────────────────────────────────────────────────────────────────
106
152
  export interface ChatUser {
107
- uid: string;
108
- name: string;
109
- email: string;
110
- mobile: string;
111
- project: string;
112
- type: UserType;
113
- avatar: string | null;
114
- status: OnlineStatus;
153
+ uid: string;
154
+ name: string;
155
+ email: string;
156
+ mobile: string;
157
+ project: string;
158
+ type: UserType;
159
+ avatar: string | null;
160
+ status: OnlineStatus;
115
161
  designation: string;
116
- /**
117
- * When `true` for the row matching the current viewer (`viewerUid` / `viewer.uid`),
118
- * the widget shows the spam/blocked screen (same as `widget.viewerBlocked`).
119
- */
120
162
  viewerBlocked?: boolean;
121
163
  }
122
164
 
123
- // ─── Message ────────────────────────────────────────────────────────────────
165
+ // ─── Message ─────────────────────────────────────────────────────────────────
124
166
  export interface ChatMessage {
125
- id: string;
126
- senderId: string;
127
- receiverId: string;
128
- text: string;
129
- timestamp: string;
130
- type: MessageType;
131
- status: 'sent' | 'delivered' | 'read';
167
+ id: string;
168
+ senderId: string;
169
+ receiverId: string;
170
+ text: string;
171
+ timestamp: string;
172
+ type: MessageType;
173
+ status: 'sent' | 'delivered' | 'read';
132
174
  attachmentName?: string;
133
175
  attachmentSize?: string;
134
- /** Blob URL for attachment download (local send) */
135
- attachmentUrl?: string;
136
- /** e.g. image/png — used for inline image preview in bubbles */
176
+ attachmentUrl?: string;
137
177
  attachmentMime?: string;
138
- voiceDuration?: number; // seconds
139
- /** Blob URL for in-bubble audio playback (local recording) */
140
- voiceUrl?: string;
178
+ voiceDuration?: number;
179
+ voiceUrl?: string;
141
180
  }
142
181
 
143
- // ─── Ticket ─────────────────────────────────────────────────────────────────
182
+ // ─── Ticket ──────────────────────────────────────────────────────────────────
144
183
  export interface Ticket {
145
- id: string;
146
- title: string;
184
+ id: string;
185
+ title: string;
147
186
  description: string;
148
- status: 'open' | 'in-progress' | 'resolved' | 'closed';
149
- priority: 'low' | 'medium' | 'high';
150
- createdAt: string;
151
- updatedAt: string;
152
- assignedTo: string | null;
187
+ status: 'open' | 'in-progress' | 'resolved' | 'closed';
188
+ priority: 'low' | 'medium' | 'high';
189
+ createdAt: string;
190
+ updatedAt: string;
191
+ assignedTo: string | null;
153
192
  }
154
193
 
155
194
  // ─── Recent Chat ─────────────────────────────────────────────────────────────
156
195
  export interface RecentChat {
157
- id: string;
158
- user: ChatUser;
196
+ id: string;
197
+ user: ChatUser;
159
198
  lastMessage: string;
160
- lastTime: string;
161
- unread: number;
162
- isPaused: boolean;
199
+ lastTime: string;
200
+ unread: number;
201
+ isPaused: boolean;
163
202
  }
164
203
 
165
- // ─── Call ───────────────────────────────────────────────────────────────────
204
+ // ─── Call ────────────────────────────────────────────────────────────────────
166
205
  export type CallState = 'idle' | 'calling' | 'connected' | 'ended';
167
-
168
206
  export interface CallSession {
169
- state: CallState;
170
- peer: ChatUser | null;
171
- startedAt: Date | null;
172
- isMuted: boolean;
207
+ state: CallState;
208
+ peer: ChatUser | null;
209
+ startedAt: Date | null;
210
+ isMuted: boolean;
173
211
  isCameraOn: boolean;
174
212
  }
175
213
 
176
214
  // ─── Local env config ────────────────────────────────────────────────────────
177
215
  export interface LocalEnvConfig {
178
- apiKey: string;
216
+ apiKey: string;
179
217
  widgetId: string;
218
+ socketUrl: string;
180
219
  }
181
220
 
182
- // ─── Theme prop (still overridable) ─────────────────────────────────────────
221
+ // ─── Theme prop ──────────────────────────────────────────────────────────────
183
222
  export interface ChatWidgetTheme {
184
- primaryColor?: string;
185
- fontFamily?: string;
186
- buttonColor?: string;
223
+ primaryColor?: string;
224
+ fontFamily?: string;
225
+ buttonColor?: string;
187
226
  buttonTextColor?: string;
188
- buttonLabel?: string;
189
- buttonPosition?: 'bottom-right' | 'bottom-left';
190
- borderRadius?: string;
227
+ buttonLabel?: string;
228
+ buttonPosition?: 'bottom-right' | 'bottom-left';
229
+ borderRadius?: string;
191
230
  }
192
231
 
193
- /**
194
- * Pass the logged-in user from your React app so the widget matches identity and UI (user vs developer).
195
- * Overrides `viewerUid`, `viewerName`, `viewerType` from remote `chatData.json` when provided.
196
- */
197
232
  export interface ChatWidgetViewer {
198
- uid: string;
199
- name: string;
200
- type: UserType;
201
- /** When set, directory lists only include users whose `ChatUser.project` equals this string (exact match). */
233
+ uid: string;
234
+ name: string;
235
+ type: UserType;
202
236
  projectId?: string;
203
237
  }
204
238
 
205
239
  export interface ChatWidgetProps {
206
- theme?: ChatWidgetTheme;
240
+ theme?: ChatWidgetTheme;
207
241
  viewer?: ChatWidgetViewer;
208
242
  }