@azure/web-pubsub-chat-client 1.0.0-beta.1

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.
@@ -0,0 +1,253 @@
1
+ import { WebPubSubClientCredential } from "@azure/web-pubsub-client";
2
+ import { type PagedAsyncIterableIterator } from "@azure/core-paging";
3
+ import type { MessageInfo, RoomInfo, RoomDetail, UserProfile, SendMessageResult } from "./models.js";
4
+ import type { OnMemberJoinedArgs, OnMemberLeftArgs, OnMessageArgs, OnRoomJoinedArgs, OnRoomLeftArgs, OnStartedArgs, OnStoppedArgs } from "./events.js";
5
+ import type { ListRoomMessagesOptions, StartOptions, GetRoomDetailOptions, CreateRoomOptions, SendToRoomOptions, GetUserProfileOptions, AddUserToRoomOptions, RemoveUserFromRoomOptions } from "./options.js";
6
+ /**
7
+ * Error thrown by `ChatClient` operations. Inspect {@link ChatError.code}
8
+ * for a stable, machine-readable error code and compare it against
9
+ * {@link KnownChatErrorCode} members rather than matching on the message.
10
+ */
11
+ declare class ChatError extends Error {
12
+ /** Stable, machine-readable error code. Compare against {@link KnownChatErrorCode}. */
13
+ readonly code: string;
14
+ constructor(message: string, code: string);
15
+ }
16
+ /**
17
+ * Client for building chat applications on Azure Web PubSub.
18
+ *
19
+ * A `ChatClient` wraps a `WebPubSubClient` and exposes a room-based chat
20
+ * API: create and inspect rooms, manage members, send messages, page
21
+ * through history, and subscribe to real-time chat events. It owns the
22
+ * underlying connection's lifecycle — call {@link ChatClient.start} to
23
+ * connect and authenticate, and {@link ChatClient.stop} to disconnect.
24
+ *
25
+ * Construct from a `WebPubSubClientCredential`, then call `start()` to
26
+ * connect and authenticate.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const client = new ChatClient(credential);
31
+ * await client.start();
32
+ * client.on("message", (e) => console.log(e.message.content.text));
33
+ * const room = await client.createRoom("My Room", ["bob"]);
34
+ * await client.sendToRoom(room.roomId, "Hello!");
35
+ * ```
36
+ */
37
+ declare class ChatClient {
38
+ /** The underlying transport. Private — `ChatClient` builds and owns it. */
39
+ private readonly _connection;
40
+ private readonly _emitter;
41
+ private readonly _rooms;
42
+ private _conversationIds;
43
+ private _userId;
44
+ private _isStarted;
45
+ private _startPromise;
46
+ private _connectionStoppedTCS;
47
+ private _isConnectionStopping;
48
+ /**
49
+ * Create a `ChatClient` from a {@link WebPubSubClientCredential}.
50
+ *
51
+ * `ChatClient` builds and owns the underlying transport: `start()`
52
+ * connects and authenticates, `stop()` disconnects. The instance is
53
+ * created but not started — call `start()` to connect.
54
+ *
55
+ * @param credential - A `WebPubSubClientCredential` that yields a
56
+ * client-access URL.
57
+ */
58
+ constructor(credential: WebPubSubClientCredential);
59
+ private _handleNotification;
60
+ /** Invoke server event and return typed data */
61
+ private invokeWithReturnType;
62
+ /**
63
+ * Create a `ChatClient` and `start()` it in one step.
64
+ *
65
+ * @param clientAccessUrl - A client-access URL.
66
+ * @param options - Optional cancellation token for the start operation.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * const chat = await ChatClient.start(clientAccessUrl);
71
+ * ```
72
+ */
73
+ static start(clientAccessUrl: string, options?: StartOptions): Promise<ChatClient>;
74
+ /**
75
+ * Create a `ChatClient` and `start()` it in one step.
76
+ *
77
+ * @param credential - A `WebPubSubClientCredential` that yields a
78
+ * client-access URL.
79
+ * @param options - Optional cancellation token for the start operation.
80
+ */
81
+ static start(credential: WebPubSubClientCredential, options?: StartOptions): Promise<ChatClient>;
82
+ /**
83
+ * Connect the underlying transport and authenticate with the chat
84
+ * service.
85
+ *
86
+ * Idempotent: concurrent calls share a single in-flight promise, and
87
+ * calls made on an already-started client resolve immediately. After
88
+ * `stop()` the client can be started again; state from the previous
89
+ * session is reset.
90
+ *
91
+ * @param options - Cancellation token for the start operation. Aborting
92
+ * leaves the client in its initial (not-started) state.
93
+ */
94
+ start(options?: StartOptions): Promise<void>;
95
+ private startCore;
96
+ private ensureStarted;
97
+ /**
98
+ * Fetch a user's profile.
99
+ *
100
+ * @param userId - Id of the user to look up.
101
+ * @param options - Optional `{ abortSignal }`.
102
+ */
103
+ getUserProfile(userId: string, options?: GetUserProfileOptions): Promise<UserProfile>;
104
+ private sendToConversation;
105
+ /**
106
+ * Send a text message to a room and return the service-assigned message id.
107
+ *
108
+ * The room must be one this client has created or joined. The sender also
109
+ * observes the message through the `"message"` event.
110
+ *
111
+ * @param roomId - Target room.
112
+ * @param message - Message text to send.
113
+ * @param options - Optional `{ abortSignal }`.
114
+ * @returns A {@link SendMessageResult} with the service-assigned `messageId`.
115
+ */
116
+ sendToRoom(roomId: string, message: string, options?: SendToRoomOptions): Promise<SendMessageResult>;
117
+ private fetchRoomDetail;
118
+ /**
119
+ * Fetch the detailed view of a room.
120
+ *
121
+ * @param roomId - Room to query.
122
+ * @param options - Optional `{ withMembers, abortSignal }`. Pass
123
+ * `withMembers: true` to populate the returned `members` list; it is
124
+ * left undefined otherwise.
125
+ */
126
+ getRoomDetail(roomId: string, options?: GetRoomDetailOptions): Promise<RoomDetail>;
127
+ /**
128
+ * Create a room and its initial members. The current user is always
129
+ * included in the resulting member list.
130
+ *
131
+ * @param title - Display title for the room.
132
+ * @param members - Other user ids to invite. The caller is added
133
+ * automatically; duplicates are de-duplicated.
134
+ * @param options - Optional `{ roomId, abortSignal }`. Pass `roomId`
135
+ * to choose an id explicitly; omit to let the service assign one.
136
+ */
137
+ createRoom(title: string, members: string[], options?: CreateRoomOptions): Promise<RoomDetail>;
138
+ private manageRoomMember;
139
+ private ensureRoomCached;
140
+ /** Add a user to a room. This is an admin operation where one user adds another user to a room. */
141
+ addUserToRoom(roomId: string, userId: string, options?: AddUserToRoomOptions): Promise<void>;
142
+ /** Remove a user from a room. This is an admin operation where one user removes another user from a room. */
143
+ removeUserFromRoom(roomId: string, userId: string, options?: RemoveUserFromRoomOptions): Promise<void>;
144
+ /**
145
+ * List messages in a room as a paged async iterator.
146
+ *
147
+ * The iterator transparently fetches additional pages from the
148
+ * service as you iterate. For Teams-style infinite scrolling, drive
149
+ * the iterator one page at a time via `byPage(...)`:
150
+ *
151
+ * @example Stream every message (e.g. for export or full sync):
152
+ * ```ts
153
+ * for await (const msg of client.listRoomMessages(roomId)) {
154
+ * console.log(msg.content.text);
155
+ * }
156
+ * ```
157
+ *
158
+ * @example Load history one page at a time (Teams-style scroll-back):
159
+ * ```ts
160
+ * // Load up to 50 messages per page.
161
+ * const pages = client.listRoomMessages(roomId).byPage({ maxPageSize: 50 });
162
+ * const first = await pages.next();
163
+ * displayMessages(first.value);
164
+ * // later, when the user scrolls up:
165
+ * const more = await pages.next();
166
+ * displayMessages(more.value);
167
+ * ```
168
+ *
169
+ * The room must be one this client has created or joined.
170
+ */
171
+ listRoomMessages(roomId: string, options?: ListRoomMessagesOptions): PagedAsyncIterableIterator<MessageInfo>;
172
+ /** Cached rooms known to the client. */
173
+ get rooms(): RoomInfo[];
174
+ /** Whether the current client has the room in its local joined-room cache. */
175
+ hasJoinedRoom(roomId: string): boolean;
176
+ /**
177
+ * The chat-domain identity of this client, established by `start()`.
178
+ *
179
+ * @throws `ChatError` with code `NotStarted` if the client is not started.
180
+ */
181
+ get userId(): string;
182
+ /**
183
+ * Subscribe to a chat-client event.
184
+ *
185
+ * Mirrors the underlying `WebPubSubClient.on(event, listener)` shape:
186
+ * one explicit overload per event, returns `void`, paired with
187
+ * `off(event, listener)` for removal. Pass the same callback
188
+ * reference to `off()` to unsubscribe.
189
+ *
190
+ * Chat-lifecycle events `started` and `stopped` are exposed here.
191
+ * Lower-level transport-connection events (`connected`,
192
+ * `disconnected`) are managed internally and are not exposed on the
193
+ * public surface.
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * const onMsg = (e: OnMessageArgs) => console.log(e.message.content.text);
198
+ * client.on("message", onMsg);
199
+ * // later
200
+ * client.off("message", onMsg);
201
+ * ```
202
+ */
203
+ on(event: "started", listener: (e: OnStartedArgs) => void): void;
204
+ /** Subscribe to the `stopped` event, fired when the client transitions from started to not-started. */
205
+ on(event: "stopped", listener: (e: OnStoppedArgs) => void): void;
206
+ /** Subscribe to the `message` event, fired when a message arrives in a joined room. */
207
+ on(event: "message", listener: (e: OnMessageArgs) => void): void;
208
+ /** Subscribe to the `room-joined` event, fired when this client joins a room. */
209
+ on(event: "room-joined", listener: (e: OnRoomJoinedArgs) => void): void;
210
+ /** Subscribe to the `room-left` event, fired when this client leaves a room. */
211
+ on(event: "room-left", listener: (e: OnRoomLeftArgs) => void): void;
212
+ /** Subscribe to the `member-joined` event, fired when another user joins a room this client is in. */
213
+ on(event: "member-joined", listener: (e: OnMemberJoinedArgs) => void): void;
214
+ /** Subscribe to the `member-left` event, fired when another user leaves a room this client is in. */
215
+ on(event: "member-left", listener: (e: OnMemberLeftArgs) => void): void;
216
+ /** Remove a `started` listener previously registered with `on()`. */
217
+ off(event: "started", listener: (e: OnStartedArgs) => void): void;
218
+ /** Remove a `stopped` listener previously registered with `on()`. */
219
+ off(event: "stopped", listener: (e: OnStoppedArgs) => void): void;
220
+ /** Remove a `message` listener previously registered with `on()`. */
221
+ off(event: "message", listener: (e: OnMessageArgs) => void): void;
222
+ /** Remove a `room-joined` listener previously registered with `on()`. */
223
+ off(event: "room-joined", listener: (e: OnRoomJoinedArgs) => void): void;
224
+ /** Remove a `room-left` listener previously registered with `on()`. */
225
+ off(event: "room-left", listener: (e: OnRoomLeftArgs) => void): void;
226
+ /** Remove a `member-joined` listener previously registered with `on()`. */
227
+ off(event: "member-joined", listener: (e: OnMemberJoinedArgs) => void): void;
228
+ /** Remove a `member-left` listener previously registered with `on()`. */
229
+ off(event: "member-left", listener: (e: OnMemberLeftArgs) => void): void;
230
+ /**
231
+ * Stop the underlying connection and reset client state. Idempotent.
232
+ *
233
+ * After resolution the client returns to its initial state and may
234
+ * be started again via `start()`. Callers that want the same identity
235
+ * should keep their authentication source (URL or credential)
236
+ * constant.
237
+ *
238
+ * Stopping is not cancellable: it tears down the transport and clears
239
+ * local state, mirroring the underlying `WebPubSubClient.stop()`, which
240
+ * takes no options.
241
+ */
242
+ stop(): Promise<void>;
243
+ /**
244
+ * Reset chat-domain state. Emits `"stopped"` exactly once per
245
+ * started → not-started transition: if `_isStarted` was already
246
+ * false on entry (e.g. the pre-start guard inside `startCore()` or
247
+ * the post-failure rollback), no event fires.
248
+ */
249
+ private resetState;
250
+ private stopConnection;
251
+ }
252
+ export { ChatClient, ChatError };
253
+ //# sourceMappingURL=chatClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatClient.d.ts","sourceRoot":"","sources":["../src/chatClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,yBAAyB,EAAqB,MAAM,0BAA0B,CAAC;AAC1H,OAAO,EAAyB,KAAK,0BAA0B,EAAqB,MAAM,oBAAoB,CAAC;AAgB/G,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,KAAK,EAEV,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,uBAAuB,EAEvB,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,cAAc,CAAC;AAMtB;;;;GAIG;AACH,cAAM,SAAU,SAAQ,KAAK;IAC3B,uFAAuF;IACvF,SAAgB,IAAI,EAAE,MAAM,CAAC;gBACjB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAK1C;AAqBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,cAAM,UAAU;IACd,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAkB;IAE9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsB;IAC/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;IAC1D,OAAO,CAAC,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,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ declare const INVOCATION_NAME: {
2
+ readonly LOGIN: "chat.login";
3
+ readonly LIST_USER_CONVERSATION: "chat.listUserConversation";
4
+ readonly GET_USER_PROPERTIES: "chat.getUserProperties";
5
+ readonly GET_ROOM: "chat.getRoom";
6
+ readonly LIST_MESSAGES: "chat.queryMessageHistory";
7
+ readonly SEND_TEXT_MESSAGE: "chat.sendTextMessage";
8
+ readonly CREATE_ROOM: "chat.createRoom";
9
+ readonly JOIN_ROOM: "chat.joinRoom";
10
+ readonly MANAGE_ROOM_MEMBER: "chat.manageRoomMember";
11
+ };
12
+ declare const ERRORS: {
13
+ readonly RoomAlreadyExists: "RoomAlreadyExists";
14
+ readonly UserAlreadyInRoom: "UserAlreadyInRoom";
15
+ readonly NoPermissionInRoom: "NoPermissionInRoom";
16
+ readonly NotStarted: "NotStarted";
17
+ readonly UnknownRoom: "UnknownRoom";
18
+ readonly InvalidServerResponse: "InvalidServerResponse";
19
+ };
20
+ export { INVOCATION_NAME, ERRORS };
21
+ //# sourceMappingURL=constant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../src/constant.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe;;;;;;;;;;CAUX,CAAC;AAEX,QAAA,MAAM,MAAM;;;;;;;CAOF,CAAC;AAEX,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,70 @@
1
+ import type { MessageInfo, RoomInfo } from "./models.js";
2
+ /**
3
+ * A chat message payload. Extends the wire `MessageInfo` so existing
4
+ * accessors keep working and reserves room for client-only metadata in
5
+ * future revisions of the SDK.
6
+ */
7
+ export interface ChatMessage extends MessageInfo {
8
+ }
9
+ /**
10
+ * Argument of the `"started"` event listener. Fired after `start()`
11
+ * completes successfully — the underlying connection is open, chat-
12
+ * domain login has resolved, and `client.userId` / `client.rooms` are
13
+ * populated. Mirrors the `On<Event>Args` shape used by the underlying
14
+ * `WebPubSubClient` (e.g. `OnConnectedArgs`).
15
+ */
16
+ export interface OnStartedArgs {
17
+ /** The chat-domain identity of this client. Equivalent to `client.userId`. */
18
+ userId: string;
19
+ }
20
+ /**
21
+ * Argument of the `"stopped"` event listener. Fired when the chat
22
+ * client transitions from started to not-started — either because
23
+ * `stop()` was called or the underlying connection terminated. Empty
24
+ * payload (reserved for future fields), matching upstream
25
+ * `WebPubSubClient.OnStoppedArgs`.
26
+ */
27
+ export interface OnStoppedArgs {
28
+ }
29
+ /**
30
+ * Argument of the `"message"` event listener. Naming mirrors the
31
+ * `On<Event>Args` convention used by the underlying `WebPubSubClient`
32
+ * (e.g. `OnGroupDataMessageArgs`).
33
+ */
34
+ export interface OnMessageArgs {
35
+ /** Room the message belongs to. */
36
+ roomId: string;
37
+ /** The message. */
38
+ message: ChatMessage;
39
+ }
40
+ /** Argument of the `"room-joined"` event listener. Fired when the current client joins a room. */
41
+ export interface OnRoomJoinedArgs {
42
+ /** The room that was joined. */
43
+ room: RoomInfo;
44
+ }
45
+ /** Argument of the `"room-left"` event listener. Fired when the current client leaves a room. */
46
+ export interface OnRoomLeftArgs {
47
+ /** Id of the room that was left. */
48
+ roomId: string;
49
+ /** Title of the room that was left. */
50
+ title: string;
51
+ }
52
+ /** Argument of the `"member-joined"` event listener. Fired when another user joins a room this client is in. */
53
+ export interface OnMemberJoinedArgs {
54
+ /** Id of the room the member joined. */
55
+ roomId: string;
56
+ /** Title of the room the member joined. */
57
+ title: string;
58
+ /** Id of the user who joined. */
59
+ userId: string;
60
+ }
61
+ /** Argument of the `"member-left"` event listener. Fired when another user leaves a room this client is in. */
62
+ export interface OnMemberLeftArgs {
63
+ /** Id of the room the member left. */
64
+ roomId: string;
65
+ /** Title of the room the member left. */
66
+ title: string;
67
+ /** Id of the user who left. */
68
+ userId: string;
69
+ }
70
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,WAAW;CAAG;AAEnD;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;CAAG;AAEjC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,kGAAkG;AAClG,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,iGAAiG;AACjG,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gHAAgH;AAChH,MAAM,WAAW,kBAAkB;IACjC,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,+GAA+G;AAC/G,MAAM,WAAW,gBAAgB;IAC/B,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB"}