@ethora/sdk-backend 26.2.2 → 26.2.4

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/README.md CHANGED
@@ -141,10 +141,20 @@ export class ChatService {
141
141
  // routes/chat.ts
142
142
  import express, { Request, Response } from 'express';
143
143
  import { getEthoraSDKService } from '@ethora/sdk-backend';
144
+ import type {
145
+ ChatRepository,
146
+ ApiResponse,
147
+ CreateChatRoomRequest,
148
+ CreateUserData,
149
+ UpdateUserData,
150
+ GetUsersQueryParams,
151
+ GetUserChatsQueryParams,
152
+ UUID
153
+ } from '@ethora/sdk-backend';
144
154
  import axios from 'axios';
145
155
 
146
156
  const router = express.Router();
147
- const chatService = getEthoraSDKService();
157
+ const chatService: ChatRepository = getEthoraSDKService();
148
158
 
149
159
  // Create a chat room for a workspace
150
160
  router.post(
@@ -152,9 +162,9 @@ router.post(
152
162
  async (req: Request, res: Response) => {
153
163
  try {
154
164
  const { workspaceId } = req.params;
155
- const roomData = req.body;
165
+ const roomData: Partial<CreateChatRoomRequest> = req.body;
156
166
 
157
- const response = await chatService.createChatRoom(workspaceId, {
167
+ const response: ApiResponse = await chatService.createChatRoom(workspaceId, {
158
168
  title: roomData.title || `Chat Room ${workspaceId}`,
159
169
  uuid: workspaceId,
160
170
  type: roomData.type || 'group',
@@ -179,9 +189,9 @@ router.post(
179
189
  router.post('/users/:userId', async (req: Request, res: Response) => {
180
190
  try {
181
191
  const { userId } = req.params;
182
- const userData = req.body;
192
+ const userData: CreateUserData = req.body;
183
193
 
184
- const response = await chatService.createUser(userId, userData);
194
+ const response: ApiResponse = await chatService.createUser(userId, userData);
185
195
  res.json({ success: true, data: response });
186
196
  } catch (error) {
187
197
  if (axios.isAxiosError(error)) {
@@ -254,11 +264,11 @@ router.get('/users/:userId/chat-token', (req: Request, res: Response) => {
254
264
  router.get('/users', async (req: Request, res: Response) => {
255
265
  try {
256
266
  const { chatName, xmppUsername } = req.query;
257
- const params: any = {};
267
+ const params: GetUsersQueryParams = {};
258
268
  if (chatName) params.chatName = String(chatName);
259
269
  if (xmppUsername) params.xmppUsername = String(xmppUsername);
260
270
 
261
- const response = await chatService.getUsers(
271
+ const response: ApiResponse = await chatService.getUsers(
262
272
  Object.keys(params).length > 0 ? params : undefined,
263
273
  );
264
274
  res.json({ success: true, data: response });
@@ -277,17 +287,12 @@ router.get('/users', async (req: Request, res: Response) => {
277
287
  // Update users (batch)
278
288
  router.patch('/users', async (req: Request, res: Response) => {
279
289
  try {
280
- const { users } = req.body;
290
+ const { users } = req.body as { users: UpdateUserData[] };
281
291
  if (!Array.isArray(users) || users.length === 0) {
282
292
  return res.status(400).json({ error: 'users must be a non-empty array' });
283
293
  }
284
- if (users.length > 100) {
285
- return res
286
- .status(400)
287
- .json({ error: 'Maximum 100 users allowed per request' });
288
- }
289
294
 
290
- const response = await chatService.updateUsers(users);
295
+ const response: ApiResponse = await chatService.updateUsers(users);
291
296
  res.json({ success: true, data: response });
292
297
  } catch (error) {
293
298
  if (axios.isAxiosError(error)) {
@@ -301,6 +306,33 @@ router.patch('/users', async (req: Request, res: Response) => {
301
306
  }
302
307
  });
303
308
 
309
+ // Update chat room
310
+ router.patch(
311
+ '/workspaces/:workspaceId/chat',
312
+ async (req: Request, res: Response) => {
313
+ try {
314
+ const { workspaceId } = req.params;
315
+ const updateData: { title?: string; description?: string } = req.body;
316
+ const response: ApiResponse = await chatService.updateChatRoom(workspaceId, updateData);
317
+ res.json({ success: true, data: response });
318
+ } catch (error) {
319
+ res.status(500).json({ error: 'Failed to update chat room' });
320
+ }
321
+ },
322
+ );
323
+
324
+ // Get user chats
325
+ router.get('/users/:userId/chats', async (req: Request, res: Response) => {
326
+ try {
327
+ const { userId } = req.params;
328
+ const query: GetUserChatsQueryParams = req.query as unknown as GetUserChatsQueryParams;
329
+ const response: ApiResponse = await chatService.getUserChats(userId, query);
330
+ res.json({ success: true, data: response });
331
+ } catch (error) {
332
+ res.status(500).json({ error: 'Failed to get user chats' });
333
+ }
334
+ });
335
+
304
336
  export default router;
305
337
  ```
306
338
 
@@ -314,9 +346,9 @@ import axios from 'axios';
314
346
 
315
347
  @Injectable()
316
348
  export class ChatService {
317
- private readonly ethoraService = getEthoraSDKService();
349
+ private readonly ethoraService: ChatRepository = getEthoraSDKService();
318
350
 
319
- async createChatRoom(workspaceId: string, roomData?: any) {
351
+ async createChatRoom(workspaceId: string, roomData?: Partial<CreateChatRoomRequest>): Promise<ApiResponse> {
320
352
  try {
321
353
  return await this.ethoraService.createChatRoom(workspaceId, roomData);
322
354
  } catch (error) {
@@ -333,7 +365,7 @@ export class ChatService {
333
365
  }
334
366
  }
335
367
 
336
- async createUser(userId: string, userData?: any) {
368
+ async createUser(userId: string, userData?: CreateUserData): Promise<ApiResponse> {
337
369
  try {
338
370
  return await this.ethoraService.createUser(userId, userData);
339
371
  } catch (error) {
@@ -366,13 +398,16 @@ export class ChatController {
366
398
  @Post('workspaces/:workspaceId/rooms')
367
399
  async createChatRoom(
368
400
  @Param('workspaceId') workspaceId: string,
369
- @Body() roomData: any,
370
- ) {
401
+ @Body() roomData: Partial<CreateChatRoomRequest>,
402
+ ): Promise<ApiResponse> {
371
403
  return this.chatService.createChatRoom(workspaceId, roomData);
372
404
  }
373
405
 
374
406
  @Post('users/:userId')
375
- async createUser(@Param('userId') userId: string, @Body() userData: any) {
407
+ async createUser(
408
+ @Param('userId') userId: string,
409
+ @Body() userData: CreateUserData
410
+ ): Promise<ApiResponse> {
376
411
  return this.chatService.createUser(userId, userData);
377
412
  }
378
413
 
@@ -396,12 +431,12 @@ export async function chatRoutes(fastify: FastifyInstance) {
396
431
  // Create chat room
397
432
  fastify.post(
398
433
  '/workspaces/:workspaceId/chat',
399
- async (request: FastifyRequest, reply: FastifyReply) => {
434
+ async (request: FastifyRequest, reply: FastifyReply): Promise<ApiResponse | void> => {
400
435
  const { workspaceId } = request.params as { workspaceId: string };
401
- const roomData = request.body as any;
436
+ const roomData = request.body as Partial<CreateChatRoomRequest>;
402
437
 
403
438
  try {
404
- const response = await chatService.createChatRoom(
439
+ const response: ApiResponse = await chatService.createChatRoom(
405
440
  workspaceId,
406
441
  roomData,
407
442
  );
@@ -435,8 +470,8 @@ async function setupWorkspaceChat(
435
470
  workspaceId: string,
436
471
  userIds: string[],
437
472
  adminUserId: string,
438
- ) {
439
- const chatService = getEthoraSDKService();
473
+ ): Promise<{ success: boolean }> {
474
+ const chatService: ChatRepository = getEthoraSDKService();
440
475
 
441
476
  try {
442
477
  // 1. Create chat room
@@ -485,8 +520,8 @@ When a new user joins your platform:
485
520
  async function onboardNewUser(
486
521
  userId: string,
487
522
  userData: { firstName: string; lastName: string; email: string },
488
- ) {
489
- const chatService = getEthoraSDKService();
523
+ ): Promise<{ success: boolean; chatToken: string }> {
524
+ const chatService: ChatRepository = getEthoraSDKService();
490
525
 
491
526
  try {
492
527
  // Create user in chat service
@@ -498,7 +533,7 @@ async function onboardNewUser(
498
533
  });
499
534
 
500
535
  // Generate client token for frontend
501
- const clientToken = chatService.createChatUserJwtToken(userId);
536
+ const clientToken: string = chatService.createChatUserJwtToken(userId);
502
537
 
503
538
  return {
504
539
  success: true,
@@ -516,8 +551,11 @@ async function onboardNewUser(
516
551
  When adding a user to an existing workspace:
517
552
 
518
553
  ```typescript
519
- async function addUserToWorkspace(workspaceId: string, userId: string) {
520
- const chatService = getEthoraSDKService();
554
+ async function addUserToWorkspace(
555
+ workspaceId: string,
556
+ userId: string,
557
+ ): Promise<{ success: boolean }> {
558
+ const chatService: ChatRepository = getEthoraSDKService();
521
559
 
522
560
  try {
523
561
  // Ensure user exists
@@ -543,8 +581,11 @@ async function addUserToWorkspace(workspaceId: string, userId: string) {
543
581
  When removing a user from a workspace:
544
582
 
545
583
  ```typescript
546
- async function removeUserFromWorkspace(workspaceId: string, userId: string) {
547
- const chatService = getEthoraSDKService();
584
+ async function removeUserFromWorkspace(
585
+ workspaceId: string,
586
+ userId: string,
587
+ ): Promise<{ success: boolean }> {
588
+ const chatService: ChatRepository = getEthoraSDKService();
548
589
 
549
590
  try {
550
591
  // Remove access from workspace chat room
@@ -561,8 +602,8 @@ async function removeUserFromWorkspace(workspaceId: string, userId: string) {
561
602
  async function removeMultipleUsersFromWorkspace(
562
603
  workspaceId: string,
563
604
  userIds: string[],
564
- ) {
565
- const chatService = getEthoraSDKService();
605
+ ): Promise<{ success: boolean }> {
606
+ const chatService: ChatRepository = getEthoraSDKService();
566
607
 
567
608
  try {
568
609
  await chatService.removeUserAccessFromChatRoom(workspaceId, userIds);
@@ -580,8 +621,11 @@ async function removeMultipleUsersFromWorkspace(
580
621
  When deleting a workspace:
581
622
 
582
623
  ```typescript
583
- async function cleanupWorkspaceChat(workspaceId: string, userIds: string[]) {
584
- const chatService = getEthoraSDKService();
624
+ async function cleanupWorkspaceChat(
625
+ workspaceId: string,
626
+ userIds: string[],
627
+ ): Promise<{ success: boolean }> {
628
+ const chatService: ChatRepository = getEthoraSDKService();
585
629
 
586
630
  try {
587
631
  // Delete chat room (handles non-existent gracefully)
@@ -609,21 +653,25 @@ async function cleanupWorkspaceChat(workspaceId: string, userIds: string[]) {
609
653
  Retrieve users from the chat service:
610
654
 
611
655
  ```typescript
612
- async function getUsersExample() {
613
- const chatService = getEthoraSDKService();
656
+ async function getUsersExample(): Promise<{
657
+ allUsers: ApiResponse;
658
+ groupChatUsers: ApiResponse;
659
+ oneOnOneUsers: ApiResponse
660
+ }> {
661
+ const chatService: ChatRepository = getEthoraSDKService();
614
662
 
615
663
  try {
616
664
  // Get all users
617
- const allUsers = await chatService.getUsers();
665
+ const allUsers: ApiResponse = await chatService.getUsers();
618
666
  console.log(`Total users: ${allUsers.results?.length || 0}`);
619
667
 
620
668
  // Get users by chat name (group chat)
621
- const groupChatUsers = await chatService.getUsers({
669
+ const groupChatUsers: ApiResponse = await chatService.getUsers({
622
670
  chatName: 'appId_workspaceId',
623
671
  });
624
672
 
625
673
  // Get users by chat name (1-on-1 chat)
626
- const oneOnOneUsers = await chatService.getUsers({
674
+ const oneOnOneUsers: ApiResponse = await chatService.getUsers({
627
675
  chatName: 'userA-userB',
628
676
  });
629
677
 
@@ -640,41 +688,65 @@ async function getUsersExample() {
640
688
  Update multiple users at once:
641
689
 
642
690
  ```typescript
643
- async function updateUsersExample() {
644
- const chatService = getEthoraSDKService();
691
+ async function updateUsersExample(): Promise<ApiResponse> {
692
+ const chatService: ChatRepository = getEthoraSDKService();
645
693
 
646
694
  try {
647
695
  // Update multiple users (1-100 users per request)
648
- const response = await chatService.updateUsers([
696
+ const response: ApiResponse = await chatService.updateUsers([
649
697
  {
650
698
  xmppUsername: 'appId_user1',
651
699
  firstName: 'John',
652
700
  lastName: 'Doe',
653
- username: 'johndoe',
654
- profileImage: 'https://example.com/avatar1.jpg',
655
- },
656
- {
657
- xmppUsername: 'appId_user2',
658
- firstName: 'Jane',
659
- lastName: 'Smith',
660
- username: 'janesmith',
661
- },
701
+ }
662
702
  ]);
663
703
 
664
- // Check results
665
- response.results?.forEach((result: any) => {
666
- if (result.status === 'updated') {
667
- console.log(`User ${result.xmppUsername} updated successfully`);
668
- } else if (result.status === 'not-found') {
669
- console.warn(`User ${result.xmppUsername} not found`);
670
- } else if (result.status === 'skipped') {
671
- console.log(`User ${result.xmppUsername} update skipped`);
672
- }
704
+ return response;
705
+ } catch (error) {
706
+ console.error('Failed to update users:', error);
707
+ throw error;
708
+ }
709
+ }
710
+ ```
711
+
712
+ ### Use Case 8: Updating Chat Room Metadata
713
+
714
+ Update room title or description:
715
+
716
+ ```typescript
717
+ async function updateRoomExample(): Promise<ApiResponse> {
718
+ const chatService: ChatRepository = getEthoraSDKService();
719
+
720
+ try {
721
+ const response: ApiResponse = await chatService.updateChatRoom('workspaceId', {
722
+ title: 'New Room Title',
723
+ description: 'New Description',
673
724
  });
725
+ return response;
726
+ } catch (error) {
727
+ console.error('Failed to update room:', error);
728
+ throw error;
729
+ }
730
+ }
731
+ ```
732
+
733
+ ### Use Case 9: Getting User Chats
674
734
 
735
+ Retrieve all rooms the user has access to:
736
+
737
+ ```typescript
738
+ async function getUserChatsExample(): Promise<ApiResponse> {
739
+ const chatService: ChatRepository = getEthoraSDKService();
740
+
741
+ try {
742
+ const query: GetUserChatsQueryParams = {
743
+ limit: 20,
744
+ includeMembers: true
745
+ };
746
+ const response: ApiResponse = await chatService.getUserChats('userId', query);
675
747
  return response;
676
748
  } catch (error) {
677
- console.error('Failed to update users:', error);
749
+ console.error('Failed to get user chats:', error);
678
750
  throw error;
679
751
  }
680
752
  }
@@ -684,37 +756,56 @@ async function updateUsersExample() {
684
756
 
685
757
  ### Core Methods
686
758
 
687
- #### `createUser(userId: UUID, userData?: Record<string, unknown>): Promise<ApiResponse>`
759
+ #### `createUser(userId: UUID, userData?: CreateUserData): Promise<ApiResponse>`
688
760
 
689
761
  Creates a user in the chat service using the `/v2/users/batch` endpoint.
690
762
 
691
- **Parameters:**
692
- - `userId` (UUID): The unique identifier of the user
693
- - `userData` (optional): Additional user data
694
- - `firstName` (string): User's first name
695
- - `lastName` (string): User's last name (minimum 2 characters)
696
- - `email` (string): User's email address
697
- - `password` (string): User's password
698
- - `displayName` (string): Display name (will be split into firstName/lastName if needed)
763
+ **Interface: `CreateUserData`**
764
+ ```typescript
765
+ interface CreateUserData {
766
+ email: string; // string: User's email address
767
+ firstName: string; // string: User's first name
768
+ lastName: string; // string: User's last name (min 2 chars)
769
+ password?: string; // string (optional): User's password
770
+ displayName?: string; // string (optional): Full display name
771
+ }
772
+ ```
699
773
 
700
- **Returns:** Promise resolving to the API response
774
+ **Example Request:**
775
+ ```typescript
776
+ await sdk.createUser("user-uuid-123", {
777
+ email: "john@example.com",
778
+ firstName: "John",
779
+ lastName: "Doe"
780
+ });
781
+ ```
701
782
 
702
783
  **Note:** The API requires `lastName` to be at least 2 characters. If not provided or too short, defaults to "User".
703
784
 
704
785
  ---
705
786
 
706
- #### `createChatRoom(chatId: UUID, roomData?: Record<string, unknown>): Promise<ApiResponse>`
787
+ #### `createChatRoom(chatId: UUID, roomData?: CreateChatRoomRequest): Promise<ApiResponse>`
707
788
 
708
789
  Creates a chat room using the `/v2/chats` endpoint.
709
790
 
710
- **Parameters:**
711
- - `chatId` (UUID): The unique identifier of the chat/workspace
712
- - `roomData` (optional): Room configuration
713
- - `title` (string): Chat room title
714
- - `uuid` (string): Room UUID (defaults to chatId)
715
- - `type` (string): Room type (defaults to "group")
791
+ **Interface: `CreateChatRoomRequest`**
792
+ ```typescript
793
+ interface CreateChatRoomRequest {
794
+ title: string; // string: The display name of the chat room
795
+ uuid: string; // string: The workspace/chat identifier
796
+ type: string; // string: The room type (e.g., "group")
797
+ }
798
+ ```
716
799
 
717
- **Returns:** Promise resolving to the API response
800
+ **Example Request:**
801
+ ```typescript
802
+ const roomData: CreateChatRoomRequest = {
803
+ title: "Engineering",
804
+ uuid: "room-abc-123",
805
+ type: "group"
806
+ };
807
+ await sdk.createChatRoom("room-abc-123", roomData);
808
+ ```
718
809
 
719
810
  ---
720
811
 
@@ -722,11 +813,14 @@ Creates a chat room using the `/v2/chats` endpoint.
722
813
 
723
814
  Grants user(s) access to a chat room using the `/v2/chats/users-access` endpoint.
724
815
 
725
- **Parameters:**
726
- - `chatId` (UUID): The unique identifier of the chat/workspace
727
- - `userId` (UUID | UUID[]): Single user ID or array of user IDs
816
+ **Example Request:**
817
+ ```typescript
818
+ // Single user
819
+ await sdk.grantUserAccessToChatRoom("workspace-123", "user-uuid-456");
728
820
 
729
- **Returns:** Promise resolving to the API response
821
+ // Multiple users
822
+ await sdk.grantUserAccessToChatRoom("workspace-123", ["user-1", "user-2"]);
823
+ ```
730
824
 
731
825
  **Note:** User IDs are automatically prefixed with `{appId}_` if they don't already have the prefix.
732
826
 
@@ -736,11 +830,10 @@ Grants user(s) access to a chat room using the `/v2/chats/users-access` endpoint
736
830
 
737
831
  Removes user(s) access from a chat room using the `/v2/chats/users-access` DELETE endpoint.
738
832
 
739
- **Parameters:**
740
- - `chatId` (UUID): The unique identifier of the chat/workspace
741
- - `userId` (UUID | UUID[]): Single user ID or array of user IDs to remove
742
-
743
- **Returns:** Promise resolving to the API response
833
+ **Example Request:**
834
+ ```typescript
835
+ await sdk.removeUserAccessFromChatRoom("workspace-123", "user-456");
836
+ ```
744
837
 
745
838
  **Note:** User IDs are automatically prefixed with `{appId}_` if they don't already have the prefix.
746
839
 
@@ -783,20 +876,79 @@ Retrieves users from the chat service using the `/v2/chats/users` endpoint.
783
876
 
784
877
  Updates multiple users at once using the `/v2/chats/users` PATCH endpoint.
785
878
 
786
- **Parameters:**
787
- - `users` (UpdateUserData[]): Array of user data to update (1-100 users)
788
- - `xmppUsername` (string, required): XMPP username to identify the user
789
- - `firstName` (string, optional): First name
790
- - `lastName` (string, optional): Last name
791
- - `username` (string, optional): Username
792
- - `profileImage` (string, optional): Profile image URL
879
+ **Interface: `UpdateUserData`**
880
+ ```typescript
881
+ interface UpdateUserData {
882
+ xmppUsername: string; // string: Required (format: {appId}_{userId})
883
+ firstName?: string; // string (optional): New first name
884
+ lastName?: string; // string (optional): New last name
885
+ username?: string; // string (optional): New username
886
+ profileImage?: string; // string (optional): URL to profile image
887
+ description?: string; // string (optional): User bio/description
888
+ email?: string; // string (optional): New email address
889
+ }
890
+ ```
891
+
892
+ **Example Request:**
893
+ ```typescript
894
+ await sdk.updateUsers([
895
+ { xmppUsername: "appId_user1", firstName: "NewName" }
896
+ ]);
897
+ ```
898
+
899
+ ---
900
+
901
+ #### `getUserChats(userId: UUID, params?: GetUserChatsQueryParams): Promise<ApiResponse>`
902
+
903
+ Retrieves all rooms the user has access to.
904
+
905
+ **Interface: `GetUserChatsQueryParams`**
906
+ ```typescript
907
+ interface GetUserChatsQueryParams {
908
+ limit?: number; // number (optional): Pagination limit
909
+ offset?: number; // number (optional): Pagination offset
910
+ includeMembers?: boolean; // boolean (optional): Whether to return member lists
911
+ }
912
+ ```
913
+
914
+ **Example Request:**
915
+ ```typescript
916
+ const query: GetUserChatsQueryParams = { limit: 50, includeMembers: true };
917
+ await sdk.getUserChats("user-uuid-123", query);
918
+ ```
919
+
920
+ ---
921
+
922
+ #### `updateChatRoom(chatId: UUID, updateData: { title?: string; description?: string }): Promise<ApiResponse>`
923
+
924
+ Updates the metadata for a specific chat room.
793
925
 
794
- **Returns:** Promise resolving to the API response with results array
926
+ **Example Request:**
927
+ ```typescript
928
+ await sdk.updateChatRoom("workspace-123", {
929
+ title: "New Team Title",
930
+ description: "Updated room description"
931
+ });
932
+ ```
795
933
 
796
- **Response Status Values:**
797
- - `updated`: User was successfully updated (includes updated user data)
798
- - `not-found`: User was not found
799
- - `skipped`: User update was skipped
934
+ ---
935
+
936
+ #### `getUsers(params?: GetUsersQueryParams): Promise<ApiResponse>`
937
+
938
+ Retrieves users from the chat service using the `/v2/chats/users` endpoint.
939
+
940
+ **Interface: `GetUsersQueryParams`**
941
+ ```typescript
942
+ interface GetUsersQueryParams {
943
+ chatName?: string; // string (optional): Filter by roomId (appId_roomId)
944
+ xmppUsername?: string; // string (optional): Filter by specific JID
945
+ }
946
+ ```
947
+
948
+ **Example Request:**
949
+ ```typescript
950
+ await sdk.getUsers({ chatName: "appId_workspace-123" });
951
+ ```
800
952
 
801
953
  **Limits:** 1-100 users per request
802
954
 
@@ -806,10 +958,10 @@ Updates multiple users at once using the `/v2/chats/users` PATCH endpoint.
806
958
 
807
959
  Deletes users from the chat service using the `/v1/users/batch` endpoint.
808
960
 
809
- **Parameters:**
810
- - `userIds` (UUID[]): Array of user IDs to delete
811
-
812
- **Returns:** Promise resolving to the API response
961
+ **Example Request:**
962
+ ```typescript
963
+ await sdk.deleteUsers(["user-id-1", "user-id-2"]);
964
+ ```
813
965
 
814
966
  **Note:** Gracefully handles non-existent users (422 status with "not found").
815
967
 
@@ -819,10 +971,10 @@ Deletes users from the chat service using the `/v1/users/batch` endpoint.
819
971
 
820
972
  Deletes a chat room using the `/v1/chats` endpoint.
821
973
 
822
- **Parameters:**
823
- - `chatId` (UUID): The unique identifier of the chat/workspace
824
-
825
- **Returns:** Promise resolving to the API response
974
+ **Example Request:**
975
+ ```typescript
976
+ await sdk.deleteChatRoom("workspace-uuid-123");
977
+ ```
826
978
 
827
979
  **Note:** Gracefully handles non-existent rooms (422 status with "not found").
828
980
 
@@ -39,14 +39,16 @@ export declare const ETHORA_JID_DOMAIN = "@conference.xmpp.ethoradev.com";
39
39
  * In a real implementation, this would read from environment variables,
40
40
  * a secrets manager, or a configuration file.
41
41
  *
42
+ * @param overrides - Optional overrides for appId and appSecret
42
43
  * @returns Secrets configuration object
43
44
  * @throws Error if required secrets are not configured
44
45
  */
45
- export declare function getSecretsSync(): Secrets;
46
+ export declare function getSecretsSync(overrides?: Partial<Secrets>): Secrets;
46
47
  /**
47
48
  * Gets or creates a singleton instance of secrets
48
49
  *
50
+ * @param overrides - Optional overrides for appId and appSecret
49
51
  * @returns Secrets configuration object
50
52
  */
51
- export declare function getSecrets(): Secrets;
53
+ export declare function getSecrets(overrides?: Partial<Secrets>): Secrets;
52
54
  //# sourceMappingURL=secrets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/config/secrets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,aAG7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,mCAAmC,CAAC;AAElE;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAoBxC;AAOD;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAKpC"}
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/config/secrets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,aAG7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,mCAAmC,CAAC;AAElE;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAqBpE;AAOD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAShE"}
@@ -25,13 +25,14 @@ exports.ETHORA_JID_DOMAIN = "@conference.xmpp.ethoradev.com";
25
25
  * In a real implementation, this would read from environment variables,
26
26
  * a secrets manager, or a configuration file.
27
27
  *
28
+ * @param overrides - Optional overrides for appId and appSecret
28
29
  * @returns Secrets configuration object
29
30
  * @throws Error if required secrets are not configured
30
31
  */
31
- function getSecretsSync() {
32
+ function getSecretsSync(overrides) {
32
33
  const chatApiUrl = process.env.ETHORA_CHAT_API_URL;
33
- const chatAppId = process.env.ETHORA_CHAT_APP_ID;
34
- const chatAppSecret = process.env.ETHORA_CHAT_APP_SECRET;
34
+ const chatAppId = overrides?.chatAppId || process.env.ETHORA_CHAT_APP_ID;
35
+ const chatAppSecret = overrides?.chatAppSecret || process.env.ETHORA_CHAT_APP_SECRET;
35
36
  if (!chatApiUrl || !chatAppId || !chatAppSecret) {
36
37
  throw new Error("Missing required Ethora configuration. Please set the following environment variables:\n" +
37
38
  "- ETHORA_CHAT_API_URL\n" +
@@ -42,7 +43,7 @@ function getSecretsSync() {
42
43
  chatApiUrl,
43
44
  chatAppId,
44
45
  chatAppSecret,
45
- chatBotJid: process.env.ETHORA_CHAT_BOT_JID,
46
+ chatBotJid: overrides?.chatBotJid || process.env.ETHORA_CHAT_BOT_JID,
46
47
  };
47
48
  }
48
49
  /**
@@ -52,11 +53,16 @@ let secretsInstance = null;
52
53
  /**
53
54
  * Gets or creates a singleton instance of secrets
54
55
  *
56
+ * @param overrides - Optional overrides for appId and appSecret
55
57
  * @returns Secrets configuration object
56
58
  */
57
- function getSecrets() {
58
- if (!secretsInstance) {
59
- secretsInstance = getSecretsSync();
59
+ function getSecrets(overrides) {
60
+ if (!secretsInstance || overrides) {
61
+ const newSecrets = getSecretsSync(overrides);
62
+ if (!secretsInstance) {
63
+ secretsInstance = newSecrets;
64
+ }
65
+ return newSecrets;
60
66
  }
61
67
  return secretsInstance;
62
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/config/secrets.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAgDH,wCAoBC;AAYD,gCAKC;AA3DD;;GAEG;AACU,QAAA,eAAe,GAAkB;IAC5C,KAAK,EAAE,KAAK,EAAE,aAAa;IAC3B,OAAO,EAAE,IAAI,EAAE,YAAY;CAC5B,CAAC;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAG,gCAAgC,CAAC;AAElE;;;;;;;;GAQG;AACH,SAAgB,cAAc;IAC5B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IACnD,MAAM,SAAS,GAAG,OAAO,CAAC,GAA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