@paramms/chat-widget 1.0.33 → 1.0.35

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,15 @@
1
1
  import type { ConnectionId, ConversationId, MessageId, ProfileId, SubjectId, UserId } from './ids.js';
2
2
  import type { Channel, Conversation, Message, MessageContent, Subject, AnnotationStroke } from './entities.js';
3
3
  import type { ManifestAction } from './actions.js';
4
+ /** Dashboard-configured pre-chat qualification form, delivered in the manifest. */
5
+ export interface PreChatConfig {
6
+ enabled: boolean;
7
+ showWhen?: 'always' | 'offline';
8
+ fields?: ('name' | 'email' | 'phone')[];
9
+ topics?: string[];
10
+ callbackOption?: boolean;
11
+ title?: string;
12
+ }
4
13
  export type ErrorCode = 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'BAD_REQUEST' | 'RATE_LIMITED' | 'PAYLOAD_TOO_LARGE' | 'CONFLICT' | 'INTERNAL';
5
14
  export type ClientFrame = {
6
15
  type: 'auth';
@@ -137,6 +146,7 @@ export type ServerFrame = {
137
146
  offline?: boolean;
138
147
  offlineMessage?: string;
139
148
  whiteLabel?: boolean;
149
+ preChat?: PreChatConfig;
140
150
  } | {
141
151
  type: 'message';
142
152
  message: Message;
package/dist/react.d.ts CHANGED
@@ -139,8 +139,18 @@ export interface ChatAppProps {
139
139
  * origin than the socket. Normally omit.
140
140
  * @deprecated pass a single `url`; kept for back-compat. */
141
141
  apiUrl?: string;
142
- /** Your Relay profile ID required */
143
- profileId: string;
142
+ /** A chatroom id. Provide `profileId` OR `tenantId` (see below). When both
143
+ * are given, profileId also fixes where the ✎ "new conversation" opens. */
144
+ profileId?: string;
145
+ /** Tenant-level identification — the natural fit for a chat app: lists
146
+ * EVERY conversation this user has with your business across ALL of its
147
+ * chatrooms, without naming one. Use this when the platform runs several
148
+ * chatrooms under one tenant (e.g. a marketplace chatroom for
149
+ * `<MarketplaceChat/>` pages PLUS a general-support chatroom) — the inbox
150
+ * shows both, and each row opens against its own chatroom. The ✎ compose
151
+ * button opens the tenant's default chatroom (its oldest, as reported by
152
+ * the server). */
153
+ tenantId?: string;
144
154
  /** A signed identity token (ES256 JWT) for chatrooms with signed identity
145
155
  * enabled — the production tier. Wins over `userId`. */
146
156
  token?: string;
@@ -152,7 +162,9 @@ export interface ChatAppProps {
152
162
  userName?: string;
153
163
  /** Optional: shown to agents in the dashboard */
154
164
  userEmail?: string;
155
- /** Which conversations the list shows (default 'tenant'):
165
+ /** Which conversations the list shows when configured with a profileId
166
+ * (default 'tenant'; irrelevant with `tenantId`, which is always
167
+ * tenant-wide):
156
168
  * 'tenant' — every conversation this user has with the business that
157
169
  * owns `profileId`, across ALL of its chatrooms — like a real
158
170
  * messaging app. Each row opens against its own chatroom.
@@ -165,6 +177,13 @@ export interface ChatAppProps {
165
177
  accent?: string;
166
178
  /** Container height. Default: '100%' */
167
179
  height?: string;
180
+ /** When provided, ChatApp renders an always-visible close (✕) control in the
181
+ * top-right corner of its container. Pass this whenever ChatApp is shown in
182
+ * an overlay/panel or as a mobile-fullscreen surface (ChatAppLauncher wires
183
+ * it automatically) so there is a reliable way OUT — without it, an inline
184
+ * fullscreen panel on a phone (no Escape key, no reachable backdrop) traps
185
+ * the user. Omit for a bare inline embed the host chromes itself. */
186
+ onClose?: () => void;
168
187
  /** i18n overrides */
169
188
  i18n?: import('./chatlist.js').ChatListOptions['i18n'];
170
189
  }
@@ -179,6 +198,16 @@ export interface ChatAppProps {
179
198
  * and each row opens against its own chatroom. Pass `scope="profile"` to
180
199
  * limit it to one chatroom's threads.
181
200
  *
201
+ * Identify at either level:
202
+ * • `tenantId` — the natural fit for a chat app. A platform often runs
203
+ * SEVERAL chatrooms under one business (a marketplace chatroom for
204
+ * `<MarketplaceChat/>` pages plus a general-support chatroom, …); with
205
+ * `tenantId` the inbox shows the user's chats with all of them, no
206
+ * profileId needed. Compose opens the tenant's default chatroom.
207
+ * • `profileId` — any one of the business's chatrooms; still lists
208
+ * tenant-wide by default (`scope="tenant"`), and fixes where compose
209
+ * opens.
210
+ *
182
211
  * @example
183
212
  * ```tsx
184
213
  * 'use client'
@@ -189,7 +218,7 @@ export interface ChatAppProps {
189
218
  * <div style={{ height: '100vh' }}>
190
219
  * <ChatApp
191
220
  * url={process.env.NEXT_PUBLIC_RELAY_URL}
192
- * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}
221
+ * tenantId={process.env.NEXT_PUBLIC_RELAY_TENANT_ID} // or profileId={…}
193
222
  * userId={session?.user.id}
194
223
  * userName={session?.user.name}
195
224
  * userEmail={session?.user.email}
@@ -199,7 +228,7 @@ export interface ChatAppProps {
199
228
  * }
200
229
  * ```
201
230
  */
202
- export declare function ChatApp({ url, apiUrl, profileId, token, refreshToken, userId, userName, userEmail, accent, height, i18n, scope, }: ChatAppProps): JSX.Element;
231
+ export declare function ChatApp({ url, apiUrl, profileId, tenantId, token, refreshToken, userId, userName, userEmail, accent, height, i18n, onClose, scope, }: ChatAppProps): JSX.Element;
203
232
  export interface ChatAppLauncherProps {
204
233
  /** Relay URL — ONE url, any scheme; `https://api.relay.paramms.com` is the
205
234
  * recommended form. The WebSocket URL and REST base are derived from it. */
@@ -207,8 +236,13 @@ export interface ChatAppLauncherProps {
207
236
  /** HTTP(S) base for REST calls — only when REST is on a different origin.
208
237
  * @deprecated pass a single `url`; kept for back-compat. */
209
238
  apiUrl?: string;
210
- /** Your Relay profile ID required */
211
- profileId: string;
239
+ /** A chatroom id. Provide `profileId` OR `tenantId`. */
240
+ profileId?: string;
241
+ /** Tenant-level identification — the panel lists EVERY conversation this
242
+ * user has with your business across ALL of its chatrooms (see
243
+ * ChatAppProps.tenantId). The ✎ compose opens the tenant's default
244
+ * chatroom. */
245
+ tenantId?: string;
212
246
  /** A signed identity token (ES256 JWT) for chatrooms with signed identity
213
247
  * enabled — the production tier. Wins over `userId`. */
214
248
  token?: string;
@@ -266,5 +300,5 @@ export interface ChatAppLauncherProps {
266
300
  * />
267
301
  * ```
268
302
  */
269
- export declare function ChatAppLauncher({ url, apiUrl, profileId, token, refreshToken, userId, userName, userEmail, scope, accent, floating, position, label, panelWidth, panelHeight, }: ChatAppLauncherProps): JSX.Element;
303
+ export declare function ChatAppLauncher({ url, apiUrl, profileId, tenantId, token, refreshToken, userId, userName, userEmail, scope, accent, floating, position, label, panelWidth, panelHeight, }: ChatAppLauncherProps): JSX.Element;
270
304
  export {};