@paramms/chat-widget 1.0.33 → 1.0.34

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.
@@ -179,6 +191,16 @@ export interface ChatAppProps {
179
191
  * and each row opens against its own chatroom. Pass `scope="profile"` to
180
192
  * limit it to one chatroom's threads.
181
193
  *
194
+ * Identify at either level:
195
+ * • `tenantId` — the natural fit for a chat app. A platform often runs
196
+ * SEVERAL chatrooms under one business (a marketplace chatroom for
197
+ * `<MarketplaceChat/>` pages plus a general-support chatroom, …); with
198
+ * `tenantId` the inbox shows the user's chats with all of them, no
199
+ * profileId needed. Compose opens the tenant's default chatroom.
200
+ * • `profileId` — any one of the business's chatrooms; still lists
201
+ * tenant-wide by default (`scope="tenant"`), and fixes where compose
202
+ * opens.
203
+ *
182
204
  * @example
183
205
  * ```tsx
184
206
  * 'use client'
@@ -189,7 +211,7 @@ export interface ChatAppProps {
189
211
  * <div style={{ height: '100vh' }}>
190
212
  * <ChatApp
191
213
  * url={process.env.NEXT_PUBLIC_RELAY_URL}
192
- * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}
214
+ * tenantId={process.env.NEXT_PUBLIC_RELAY_TENANT_ID} // or profileId={…}
193
215
  * userId={session?.user.id}
194
216
  * userName={session?.user.name}
195
217
  * userEmail={session?.user.email}
@@ -199,7 +221,7 @@ export interface ChatAppProps {
199
221
  * }
200
222
  * ```
201
223
  */
202
- export declare function ChatApp({ url, apiUrl, profileId, token, refreshToken, userId, userName, userEmail, accent, height, i18n, scope, }: ChatAppProps): JSX.Element;
224
+ export declare function ChatApp({ url, apiUrl, profileId, tenantId, token, refreshToken, userId, userName, userEmail, accent, height, i18n, scope, }: ChatAppProps): JSX.Element;
203
225
  export interface ChatAppLauncherProps {
204
226
  /** Relay URL — ONE url, any scheme; `https://api.relay.paramms.com` is the
205
227
  * recommended form. The WebSocket URL and REST base are derived from it. */
@@ -207,8 +229,13 @@ export interface ChatAppLauncherProps {
207
229
  /** HTTP(S) base for REST calls — only when REST is on a different origin.
208
230
  * @deprecated pass a single `url`; kept for back-compat. */
209
231
  apiUrl?: string;
210
- /** Your Relay profile ID required */
211
- profileId: string;
232
+ /** A chatroom id. Provide `profileId` OR `tenantId`. */
233
+ profileId?: string;
234
+ /** Tenant-level identification — the panel lists EVERY conversation this
235
+ * user has with your business across ALL of its chatrooms (see
236
+ * ChatAppProps.tenantId). The ✎ compose opens the tenant's default
237
+ * chatroom. */
238
+ tenantId?: string;
212
239
  /** A signed identity token (ES256 JWT) for chatrooms with signed identity
213
240
  * enabled — the production tier. Wins over `userId`. */
214
241
  token?: string;
@@ -266,5 +293,5 @@ export interface ChatAppLauncherProps {
266
293
  * />
267
294
  * ```
268
295
  */
269
- export declare function ChatAppLauncher({ url, apiUrl, profileId, token, refreshToken, userId, userName, userEmail, scope, accent, floating, position, label, panelWidth, panelHeight, }: ChatAppLauncherProps): JSX.Element;
296
+ export declare function ChatAppLauncher({ url, apiUrl, profileId, tenantId, token, refreshToken, userId, userName, userEmail, scope, accent, floating, position, label, panelWidth, panelHeight, }: ChatAppLauncherProps): JSX.Element;
270
297
  export {};