@ethora/sdk-backend 25.1.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.
- package/LICENSE +201 -0
- package/README.md +889 -0
- package/dist/config/secrets.d.ts +52 -0
- package/dist/config/secrets.d.ts.map +1 -0
- package/dist/config/secrets.js +63 -0
- package/dist/config/secrets.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/repositories/EthoraSDKService.d.ts +142 -0
- package/dist/repositories/EthoraSDKService.d.ts.map +1 -0
- package/dist/repositories/EthoraSDKService.js +444 -0
- package/dist/repositories/EthoraSDKService.js.map +1 -0
- package/dist/types/index.d.ts +171 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/jwt.d.ts +34 -0
- package/dist/utils/jwt.d.ts.map +1 -0
- package/dist/utils/jwt.js +86 -0
- package/dist/utils/jwt.js.map +1 -0
- package/dist/utils/logger.d.ts +26 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +58 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Concrete implementation of the ChatRepository using the Ethora API
|
|
4
|
+
*
|
|
5
|
+
* This class handles chat operations in the Ethora chat service. It manages
|
|
6
|
+
* JWT authentication tokens for server-to-server communication and uses
|
|
7
|
+
* HTTP clients to make asynchronous API calls.
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.EthoraSDKService = void 0;
|
|
16
|
+
exports.getEthoraSDKService = getEthoraSDKService;
|
|
17
|
+
const crypto_1 = require("crypto");
|
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
|
19
|
+
const secrets_1 = require("../config/secrets");
|
|
20
|
+
const jwt_1 = require("../utils/jwt");
|
|
21
|
+
const logger_1 = require("../utils/logger");
|
|
22
|
+
const logger = (0, logger_1.getLogger)("EthoraSDKService");
|
|
23
|
+
/**
|
|
24
|
+
* EthoraSDKService - Concrete implementation of ChatRepository
|
|
25
|
+
*/
|
|
26
|
+
class EthoraSDKService {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.secrets = (0, secrets_1.getSecrets)();
|
|
29
|
+
this.baseEthoraUrl = this.secrets.chatApiUrl;
|
|
30
|
+
// Create axios instance with default configuration
|
|
31
|
+
this.httpClient = axios_1.default.create({
|
|
32
|
+
timeout: secrets_1.DEFAULT_TIMEOUT.total,
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
logger.debug("EthoraSDKService instance initialized");
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generates a fully-qualified chat room JID from a workspace ID
|
|
41
|
+
*
|
|
42
|
+
* The JID is constructed in the format `<appId>_<workspace_id>@conference.xmpp.ethoradev.com`.
|
|
43
|
+
* This method uses a static JID domain to provide a unique identifier for a chat room.
|
|
44
|
+
*
|
|
45
|
+
* @param workspaceId - The unique identifier of the workspace
|
|
46
|
+
* @param full - Whether to include the full JID domain
|
|
47
|
+
* @returns The fully-qualified JID string for the chat room
|
|
48
|
+
*/
|
|
49
|
+
createChatName(workspaceId, full = true) {
|
|
50
|
+
logger.debug(`Creating chat room name (JID) for workspace ID: ${workspaceId}`);
|
|
51
|
+
const chatName = full
|
|
52
|
+
? `${this.secrets.chatAppId}_${workspaceId}${secrets_1.ETHORA_JID_DOMAIN}`
|
|
53
|
+
: `${this.secrets.chatAppId}_${workspaceId}`;
|
|
54
|
+
logger.info(`Chat room name created: '${chatName}'`);
|
|
55
|
+
return chatName;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a client-side JWT token for a specific user ID
|
|
59
|
+
*
|
|
60
|
+
* This method generates a JWT token for a user that can be used for client-side
|
|
61
|
+
* authentication with the chat service. The token payload includes the
|
|
62
|
+
* user's ID and the app ID.
|
|
63
|
+
*
|
|
64
|
+
* @param userId - The unique identifier of the user
|
|
65
|
+
* @returns The encoded JWT token for client-side authentication
|
|
66
|
+
*/
|
|
67
|
+
createChatUserJwtToken(userId) {
|
|
68
|
+
logger.debug(`Creating a client-side JWT token for user ID: ${userId}`);
|
|
69
|
+
return (0, jwt_1.createClientToken)(userId);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Creates the necessary headers for an API call with a JWT token
|
|
73
|
+
*
|
|
74
|
+
* @returns The headers dictionary containing the `x-custom-token` field
|
|
75
|
+
*/
|
|
76
|
+
getHeaders() {
|
|
77
|
+
logger.debug("Retrieving headers for a server-to-server API call");
|
|
78
|
+
return {
|
|
79
|
+
"x-custom-token": (0, jwt_1.createServerToken)(),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Makes an HTTP request with error handling
|
|
84
|
+
*
|
|
85
|
+
* @param config - Axios request configuration
|
|
86
|
+
* @returns The API response
|
|
87
|
+
*/
|
|
88
|
+
async makeRequest(config) {
|
|
89
|
+
try {
|
|
90
|
+
const response = await this.httpClient.request({
|
|
91
|
+
...config,
|
|
92
|
+
headers: {
|
|
93
|
+
...this.getHeaders(),
|
|
94
|
+
...config.headers,
|
|
95
|
+
},
|
|
96
|
+
timeout: secrets_1.DEFAULT_TIMEOUT.total,
|
|
97
|
+
});
|
|
98
|
+
return response.data;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
102
|
+
const axiosError = error;
|
|
103
|
+
logger.error(`API call failed with status code: ${axiosError.response?.status}. ` +
|
|
104
|
+
`Response: ${axiosError.response?.data}`, error);
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
logger.error("An unexpected error occurred during API call", error);
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Creates a user in the chat service
|
|
113
|
+
*
|
|
114
|
+
* Uses the batch API endpoint to create a single user. The API expects:
|
|
115
|
+
* - bypassEmailConfirmation: true
|
|
116
|
+
* - usersList: array with user objects containing email, firstName, lastName, password, uuid
|
|
117
|
+
*
|
|
118
|
+
* @param userId - The unique identifier of the user (used as uuid)
|
|
119
|
+
* @param userData - Additional user data (optional) - can include email, firstName, lastName, password, etc.
|
|
120
|
+
* @returns The API response
|
|
121
|
+
*/
|
|
122
|
+
async createUser(userId, userData) {
|
|
123
|
+
logger.info(`Attempting to create user with ID: ${userId}`);
|
|
124
|
+
const createUrl = `${this.baseEthoraUrl}/v1/users/batch`;
|
|
125
|
+
// Extract user fields from userData or use defaults
|
|
126
|
+
// Generate unique email using UUID if not provided
|
|
127
|
+
const email = userData?.email || `${(0, crypto_1.randomUUID)()}@example.com`;
|
|
128
|
+
const password = userData?.password || `password_${userId}`;
|
|
129
|
+
// Handle firstName and lastName - split displayName if provided
|
|
130
|
+
// API requires lastName to be at least 2 characters and not empty
|
|
131
|
+
let firstName;
|
|
132
|
+
let lastName;
|
|
133
|
+
if (userData?.firstName) {
|
|
134
|
+
firstName = userData.firstName;
|
|
135
|
+
lastName = userData?.lastName || "";
|
|
136
|
+
}
|
|
137
|
+
else if (userData?.displayName) {
|
|
138
|
+
const displayName = userData.displayName;
|
|
139
|
+
const nameParts = displayName.trim().split(/\s+/);
|
|
140
|
+
firstName = nameParts[0] || "User";
|
|
141
|
+
lastName = nameParts.slice(1).join(" ") || "";
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
firstName = "User";
|
|
145
|
+
lastName = "";
|
|
146
|
+
}
|
|
147
|
+
// Ensure lastName meets API requirements: at least 2 characters, not empty
|
|
148
|
+
if (!lastName || lastName.length < 2) {
|
|
149
|
+
// Use a default lastName if empty or too short
|
|
150
|
+
lastName = "User";
|
|
151
|
+
}
|
|
152
|
+
// Use plain userId without prefixing
|
|
153
|
+
const userIdStr = String(userId);
|
|
154
|
+
const payload = {
|
|
155
|
+
bypassEmailConfirmation: true,
|
|
156
|
+
usersList: [
|
|
157
|
+
{
|
|
158
|
+
uuid: userIdStr,
|
|
159
|
+
email: email,
|
|
160
|
+
firstName: firstName,
|
|
161
|
+
lastName: lastName,
|
|
162
|
+
password: password,
|
|
163
|
+
...(userData &&
|
|
164
|
+
Object.fromEntries(Object.entries(userData).filter(([key]) => ![
|
|
165
|
+
"email",
|
|
166
|
+
"firstName",
|
|
167
|
+
"lastName",
|
|
168
|
+
"password",
|
|
169
|
+
"uuid",
|
|
170
|
+
"displayName",
|
|
171
|
+
"role", // Role is not allowed in user creation payload
|
|
172
|
+
].includes(key)))),
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
};
|
|
176
|
+
logger.debug(`Chat service API URL: ${createUrl}`);
|
|
177
|
+
logger.debug(`Request payload: ${JSON.stringify(payload)}`);
|
|
178
|
+
return this.makeRequest({
|
|
179
|
+
method: "POST",
|
|
180
|
+
url: createUrl,
|
|
181
|
+
data: payload,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Creates a chat room for a workspace
|
|
186
|
+
*
|
|
187
|
+
* @param workspaceId - The unique identifier of the workspace
|
|
188
|
+
* @param roomData - Additional room data (optional)
|
|
189
|
+
* @returns The API response
|
|
190
|
+
*/
|
|
191
|
+
async createChatRoom(workspaceId, roomData) {
|
|
192
|
+
logger.info(`Attempting to create chat room for workspace ID: ${workspaceId}`);
|
|
193
|
+
const createUrl = `${this.baseEthoraUrl}/v1/chats`;
|
|
194
|
+
// Create chat room - API expects title, uuid, and type
|
|
195
|
+
const payload = {
|
|
196
|
+
title: roomData?.title || `Chat Room ${workspaceId}`,
|
|
197
|
+
uuid: String(workspaceId),
|
|
198
|
+
type: roomData?.type || "group",
|
|
199
|
+
...roomData, // Allow roomData to override fields if provided
|
|
200
|
+
};
|
|
201
|
+
logger.debug(`Chat service API URL: ${createUrl}`);
|
|
202
|
+
logger.debug(`Request payload: ${JSON.stringify(payload)}`);
|
|
203
|
+
return this.makeRequest({
|
|
204
|
+
method: "POST",
|
|
205
|
+
url: createUrl,
|
|
206
|
+
data: payload,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Grants a user access to a chat room
|
|
211
|
+
*
|
|
212
|
+
* Uses plain userIds without prefixing (matching how users are created)
|
|
213
|
+
*
|
|
214
|
+
* @param workspaceId - The unique identifier of the workspace
|
|
215
|
+
* @param userId - The unique identifier of the user (or array of user IDs)
|
|
216
|
+
* @returns The API response
|
|
217
|
+
*/
|
|
218
|
+
async grantUserAccessToChatRoom(workspaceId, userId) {
|
|
219
|
+
logger.info(`Granting user(s) access to chat room for workspace ${workspaceId}`);
|
|
220
|
+
const chatName = this.createChatName(workspaceId, false);
|
|
221
|
+
// Use /v1/chats/users-access endpoint with chatName and members array
|
|
222
|
+
const grantUrl = `${this.baseEthoraUrl}/v1/chats/users-access`;
|
|
223
|
+
// Convert single userId to array if needed
|
|
224
|
+
// Use plain userIds without prefixing
|
|
225
|
+
const members = Array.isArray(userId)
|
|
226
|
+
? userId.map((id) => String(id))
|
|
227
|
+
: [String(userId)];
|
|
228
|
+
const payload = {
|
|
229
|
+
chatName: chatName,
|
|
230
|
+
members: members,
|
|
231
|
+
};
|
|
232
|
+
logger.debug(`Chat service API URL: ${grantUrl}`);
|
|
233
|
+
logger.debug(`Request payload: ${JSON.stringify(payload)}`);
|
|
234
|
+
logger.debug(`Using XMPP usernames for members: ${members.join(", ")}`);
|
|
235
|
+
try {
|
|
236
|
+
return await this.makeRequest({
|
|
237
|
+
method: "POST",
|
|
238
|
+
url: grantUrl,
|
|
239
|
+
data: payload,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
244
|
+
const errorData = error.response?.data;
|
|
245
|
+
logger.error(`Failed to grant user access. Status: ${error.response?.status}, Response: ${JSON.stringify(errorData)}`, error);
|
|
246
|
+
// Log the XMPP usernames that were attempted for debugging
|
|
247
|
+
logger.debug(`Attempted XMPP usernames: ${members.join(", ")}`);
|
|
248
|
+
}
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Grants chatbot access to a chat room
|
|
254
|
+
*
|
|
255
|
+
* @param workspaceId - The unique identifier of the workspace
|
|
256
|
+
* @returns The API response
|
|
257
|
+
*/
|
|
258
|
+
async grantChatbotAccessToChatRoom(workspaceId) {
|
|
259
|
+
logger.info(`Granting chatbot access to chat room for workspace ${workspaceId}`);
|
|
260
|
+
if (!this.secrets.chatBotJid) {
|
|
261
|
+
const error = new Error("Chatbot JID not configured. Set ETHORA_CHAT_BOT_JID environment variable.");
|
|
262
|
+
logger.error("Cannot grant chatbot access", error);
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
// Extract username from JID (format: "username@domain" -> "username")
|
|
266
|
+
const chatbotUsername = this.secrets.chatBotJid.split("@")[0];
|
|
267
|
+
// Use the same grant access method with chatbot JID
|
|
268
|
+
return this.grantUserAccessToChatRoom(workspaceId, chatbotUsername);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Deletes users from the chat service
|
|
272
|
+
*
|
|
273
|
+
* @param userIds - Array of user IDs to delete
|
|
274
|
+
* @returns The API response
|
|
275
|
+
*/
|
|
276
|
+
async deleteUsers(userIds) {
|
|
277
|
+
logger.info(`Attempting to delete users: ${userIds.join(", ")}`);
|
|
278
|
+
const deleteUrl = `${this.baseEthoraUrl}/v1/users/batch`;
|
|
279
|
+
const payload = {
|
|
280
|
+
usersIdList: userIds.map((id) => String(id)),
|
|
281
|
+
};
|
|
282
|
+
logger.debug(`Chat service API URL: ${deleteUrl}`);
|
|
283
|
+
logger.debug(`Request payload: ${JSON.stringify(payload)}`);
|
|
284
|
+
try {
|
|
285
|
+
return await this.makeRequest({
|
|
286
|
+
method: "DELETE",
|
|
287
|
+
url: deleteUrl,
|
|
288
|
+
data: payload,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
// Handle the case where users don't exist (422 with "not found")
|
|
293
|
+
if (axios_1.default.isAxiosError(error) &&
|
|
294
|
+
error.response?.status === 422 &&
|
|
295
|
+
typeof error.response.data === "string" &&
|
|
296
|
+
error.response.data.includes("not found")) {
|
|
297
|
+
logger.info("No users to delete from the chat service. The request contained non-existent users.");
|
|
298
|
+
return { ok: false };
|
|
299
|
+
}
|
|
300
|
+
throw error;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Deletes a chat room from the chat service by its workspace ID
|
|
305
|
+
*
|
|
306
|
+
* This method sends a DELETE request to the Ethora API using the workspace ID
|
|
307
|
+
* to construct the chat name. It gracefully handles the case where the chat room
|
|
308
|
+
* is already non-existent (422 Not Found).
|
|
309
|
+
*
|
|
310
|
+
* @param workspaceId - The unique identifier of the workspace associated with the chat room
|
|
311
|
+
* @returns The JSON response from the chat service upon successful deletion or a success status if not found
|
|
312
|
+
*/
|
|
313
|
+
async deleteChatRoom(workspaceId) {
|
|
314
|
+
logger.info(`Attempting to delete chat room for workspace ID: ${workspaceId}`);
|
|
315
|
+
const deleteUrl = `${this.baseEthoraUrl}/v1/chats`;
|
|
316
|
+
// We must use the short name when deleting the chat room
|
|
317
|
+
const chatName = this.createChatName(workspaceId, false);
|
|
318
|
+
const payload = {
|
|
319
|
+
name: chatName,
|
|
320
|
+
};
|
|
321
|
+
logger.debug(`Chat service API URL: ${deleteUrl}`);
|
|
322
|
+
logger.debug(`Request payload: ${JSON.stringify(payload)}`);
|
|
323
|
+
try {
|
|
324
|
+
const response = await this.makeRequest({
|
|
325
|
+
method: "DELETE",
|
|
326
|
+
url: deleteUrl,
|
|
327
|
+
data: payload,
|
|
328
|
+
});
|
|
329
|
+
logger.info(`Chat room '${chatName}' successfully deleted`);
|
|
330
|
+
return response;
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
334
|
+
const axiosError = error;
|
|
335
|
+
const statusCode = axiosError.response?.status;
|
|
336
|
+
const responseText = axiosError.response?.data;
|
|
337
|
+
// Handle the case where the room does not exist (Ethora returns 422 with "not found" in body)
|
|
338
|
+
if (statusCode === 422 &&
|
|
339
|
+
typeof responseText === "string" &&
|
|
340
|
+
responseText.toLowerCase().includes("not found")) {
|
|
341
|
+
logger.warn(`Chat room '${chatName}' not found during deletion attempt (Ignored 422)`);
|
|
342
|
+
return { ok: false, reason: "Chat room not found" };
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
// Re-throw if it's not a "not found" case
|
|
346
|
+
throw error;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Updates multiple users in the chat service
|
|
351
|
+
*
|
|
352
|
+
* This method sends a PATCH request to update multiple users at once.
|
|
353
|
+
* The endpoint accepts an array of user objects with userId and optional
|
|
354
|
+
* fields. Only provided fields will be updated.
|
|
355
|
+
*
|
|
356
|
+
* Limits: 1-100 users per request
|
|
357
|
+
* Response contains results array with status for each user:
|
|
358
|
+
* - updated: user was successfully updated (includes updated user data)
|
|
359
|
+
* - not-found: user was not found
|
|
360
|
+
* - skipped: user update was skipped
|
|
361
|
+
*
|
|
362
|
+
* @param users - Array of user data to update (1-100 users)
|
|
363
|
+
* @returns The API response with results array containing status for each user
|
|
364
|
+
*/
|
|
365
|
+
async updateUsers(users) {
|
|
366
|
+
// Validate user count limit
|
|
367
|
+
if (users.length === 0) {
|
|
368
|
+
throw new Error("At least 1 user is required for update");
|
|
369
|
+
}
|
|
370
|
+
if (users.length > 100) {
|
|
371
|
+
throw new Error("Maximum 100 users allowed per update request");
|
|
372
|
+
}
|
|
373
|
+
logger.info(`Attempting to update ${users.length} user(s)`);
|
|
374
|
+
const updateUrl = `${this.baseEthoraUrl}/v1/chats/users`;
|
|
375
|
+
// Remove userId from payload if present, as API doesn't accept it
|
|
376
|
+
// API expects xmppUsername or other identifier fields instead
|
|
377
|
+
const cleanedUsers = users.map((user) => {
|
|
378
|
+
const { userId, ...rest } = user;
|
|
379
|
+
return rest;
|
|
380
|
+
});
|
|
381
|
+
const payload = {
|
|
382
|
+
users: cleanedUsers,
|
|
383
|
+
};
|
|
384
|
+
logger.debug(`Chat service API URL: ${updateUrl}`);
|
|
385
|
+
logger.debug(`Request payload: ${JSON.stringify(payload)}`);
|
|
386
|
+
return this.makeRequest({
|
|
387
|
+
method: "PATCH",
|
|
388
|
+
url: updateUrl,
|
|
389
|
+
data: payload,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Gets users from the chat service
|
|
394
|
+
*
|
|
395
|
+
* This method supports multiple query modes:
|
|
396
|
+
* - No parameters: returns all users of the app
|
|
397
|
+
* - chatName parameter: returns all users of the chat
|
|
398
|
+
* - For group chats: use appId_uuId format
|
|
399
|
+
* - For 1-on-1 chats: use xmppUsernameA-xmppUsernameB format
|
|
400
|
+
* - xmppUsername parameter: returns a specific user by XMPP username
|
|
401
|
+
*
|
|
402
|
+
* @param params - Query parameters for filtering users (optional)
|
|
403
|
+
* @returns The API response
|
|
404
|
+
*/
|
|
405
|
+
async getUsers(params) {
|
|
406
|
+
const getUrl = `${this.baseEthoraUrl}/v1/chats/users`;
|
|
407
|
+
// Build query parameters
|
|
408
|
+
const queryParams = [];
|
|
409
|
+
if (params?.chatName) {
|
|
410
|
+
queryParams.push(`chatName=${encodeURIComponent(params.chatName)}`);
|
|
411
|
+
}
|
|
412
|
+
if (params?.xmppUsername) {
|
|
413
|
+
queryParams.push(`xmppUsername=${encodeURIComponent(params.xmppUsername)}`);
|
|
414
|
+
}
|
|
415
|
+
const urlWithParams = queryParams.length > 0 ? `${getUrl}?${queryParams.join("&")}` : getUrl;
|
|
416
|
+
logger.info(params
|
|
417
|
+
? `Getting users with params: ${JSON.stringify(params)}`
|
|
418
|
+
: "Getting all users of the app");
|
|
419
|
+
logger.debug(`Chat service API URL: ${urlWithParams}`);
|
|
420
|
+
return this.makeRequest({
|
|
421
|
+
method: "GET",
|
|
422
|
+
url: urlWithParams,
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
exports.EthoraSDKService = EthoraSDKService;
|
|
427
|
+
/**
|
|
428
|
+
* Provides a singleton instance of EthoraSDKService
|
|
429
|
+
*
|
|
430
|
+
* This dependency injection function is intended for use with a DI framework
|
|
431
|
+
* or as a simple factory function. It creates and returns a single instance
|
|
432
|
+
* of `EthoraSDKService`.
|
|
433
|
+
*
|
|
434
|
+
* @returns A singleton instance of the chat repository implementation
|
|
435
|
+
*/
|
|
436
|
+
let repositoryInstance = null;
|
|
437
|
+
function getEthoraSDKService() {
|
|
438
|
+
if (!repositoryInstance) {
|
|
439
|
+
logger.debug("Creating new EthoraSDKService instance");
|
|
440
|
+
repositoryInstance = new EthoraSDKService();
|
|
441
|
+
}
|
|
442
|
+
return repositoryInstance;
|
|
443
|
+
}
|
|
444
|
+
//# sourceMappingURL=EthoraSDKService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EthoraSDKService.js","sourceRoot":"","sources":["../../src/repositories/EthoraSDKService.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;AA4hBH,kDAMC;AAhiBD,mCAAoC;AACpC,kDAA6E;AAY7E,+CAI2B;AAC3B,sCAAoE;AACpE,4CAA4C;AAE5C,MAAM,MAAM,GAAG,IAAA,kBAAS,EAAC,kBAAkB,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAa,gBAAgB;IAK3B;QAHiB,YAAO,GAA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vD,OAAO,IAAI,CAAC,WAAW,CAAc;YACnC,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,aAAa;SACnB,CAAC,CAAC;IACL,CAAC;CACF;AAnfD,4CAmfC;AAED;;;;;;;;GAQG;AACH,IAAI,kBAAkB,GAA4B,IAAI,CAAC;AAEvD,SAAgB,mBAAmB;IACjC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACvD,kBAAkB,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the Ethora SDK
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* UUID type - can be a string or UUID object
|
|
6
|
+
*/
|
|
7
|
+
export type UUID = string;
|
|
8
|
+
/**
|
|
9
|
+
* Chat room name format options
|
|
10
|
+
*/
|
|
11
|
+
export interface ChatNameOptions {
|
|
12
|
+
/** Whether to include the full JID domain */
|
|
13
|
+
full?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* JWT token payload for server authentication
|
|
17
|
+
*/
|
|
18
|
+
export interface ServerTokenPayload {
|
|
19
|
+
data: {
|
|
20
|
+
appId: string;
|
|
21
|
+
type: "server";
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* JWT token payload for client authentication
|
|
26
|
+
*/
|
|
27
|
+
export interface ClientTokenPayload {
|
|
28
|
+
data: {
|
|
29
|
+
type: "client";
|
|
30
|
+
userId: string;
|
|
31
|
+
appId: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* API response structure
|
|
36
|
+
*/
|
|
37
|
+
export interface ApiResponse {
|
|
38
|
+
ok?: boolean;
|
|
39
|
+
reason?: string;
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Chat room creation request payload
|
|
44
|
+
*/
|
|
45
|
+
export interface CreateChatRoomRequest {
|
|
46
|
+
title: string;
|
|
47
|
+
uuid: string;
|
|
48
|
+
type: string;
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Delete chat room request payload
|
|
53
|
+
*/
|
|
54
|
+
export interface DeleteChatRoomRequest {
|
|
55
|
+
name: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Grant access request payload
|
|
59
|
+
*/
|
|
60
|
+
export interface GrantAccessRequest {
|
|
61
|
+
chatName: string;
|
|
62
|
+
members: string[];
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* User data for batch update
|
|
67
|
+
*/
|
|
68
|
+
export interface UpdateUserData {
|
|
69
|
+
userId?: string;
|
|
70
|
+
xmppUsername?: string;
|
|
71
|
+
firstName?: string;
|
|
72
|
+
lastName?: string;
|
|
73
|
+
username?: string;
|
|
74
|
+
profileImage?: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
token?: string;
|
|
77
|
+
email?: string;
|
|
78
|
+
appId?: string;
|
|
79
|
+
homeScreen?: string;
|
|
80
|
+
registrationChannelType?: string;
|
|
81
|
+
updatedAt?: string;
|
|
82
|
+
authMethod?: string;
|
|
83
|
+
resetPasswordExpires?: string;
|
|
84
|
+
resetPasswordToken?: string;
|
|
85
|
+
roles?: string[];
|
|
86
|
+
tags?: string[];
|
|
87
|
+
__v?: number;
|
|
88
|
+
isProfileOpen?: boolean;
|
|
89
|
+
isAssetsOpen?: boolean;
|
|
90
|
+
isAgreeWithTerms?: boolean;
|
|
91
|
+
[key: string]: string | string[] | number | boolean | undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Batch update users request payload
|
|
95
|
+
*/
|
|
96
|
+
export interface UpdateUsersRequest {
|
|
97
|
+
users: UpdateUserData[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get users query parameters
|
|
101
|
+
*/
|
|
102
|
+
export interface GetUsersQueryParams {
|
|
103
|
+
chatName?: string;
|
|
104
|
+
xmppUsername?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Chat repository interface
|
|
108
|
+
*/
|
|
109
|
+
export interface ChatRepository {
|
|
110
|
+
/**
|
|
111
|
+
* Creates a fully-qualified chat room JID from a workspace ID
|
|
112
|
+
*/
|
|
113
|
+
createChatName(workspaceId: UUID, full?: boolean): string;
|
|
114
|
+
/**
|
|
115
|
+
* Creates a client-side JWT token for a specific user ID
|
|
116
|
+
*/
|
|
117
|
+
createChatUserJwtToken(userId: UUID): string;
|
|
118
|
+
/**
|
|
119
|
+
* Creates a user in the chat service
|
|
120
|
+
*/
|
|
121
|
+
createUser(userId: UUID, userData?: Record<string, unknown>): Promise<ApiResponse>;
|
|
122
|
+
/**
|
|
123
|
+
* Creates a chat room for a workspace
|
|
124
|
+
*/
|
|
125
|
+
createChatRoom(workspaceId: UUID, roomData?: Record<string, unknown>): Promise<ApiResponse>;
|
|
126
|
+
/**
|
|
127
|
+
* Grants a user access to a chat room
|
|
128
|
+
*/
|
|
129
|
+
grantUserAccessToChatRoom(workspaceId: UUID, userId: UUID | UUID[]): Promise<ApiResponse>;
|
|
130
|
+
/**
|
|
131
|
+
* Grants chatbot access to a chat room
|
|
132
|
+
*/
|
|
133
|
+
grantChatbotAccessToChatRoom(workspaceId: UUID): Promise<ApiResponse>;
|
|
134
|
+
/**
|
|
135
|
+
* Deletes users from the chat service
|
|
136
|
+
*/
|
|
137
|
+
deleteUsers(userIds: UUID[]): Promise<ApiResponse>;
|
|
138
|
+
/**
|
|
139
|
+
* Deletes a chat room by workspace ID
|
|
140
|
+
*/
|
|
141
|
+
deleteChatRoom(workspaceId: UUID): Promise<ApiResponse>;
|
|
142
|
+
/**
|
|
143
|
+
* Updates multiple users in the chat service
|
|
144
|
+
*
|
|
145
|
+
* Sends PATCH request to /v1/chats/users with array of users.
|
|
146
|
+
* Only provided fields will be updated.
|
|
147
|
+
* Limits: 1-100 users per request.
|
|
148
|
+
*
|
|
149
|
+
* Response contains results array with status for each user:
|
|
150
|
+
* - updated: user was successfully updated (includes updated user data)
|
|
151
|
+
* - not-found: user was not found
|
|
152
|
+
* - skipped: user update was skipped
|
|
153
|
+
*
|
|
154
|
+
* @param users - Array of user data to update (1-100 users)
|
|
155
|
+
* @returns The API response with results array containing status for each user
|
|
156
|
+
*/
|
|
157
|
+
updateUsers(users: UpdateUserData[]): Promise<ApiResponse>;
|
|
158
|
+
/**
|
|
159
|
+
* Gets users from the chat service
|
|
160
|
+
*
|
|
161
|
+
* Query parameters:
|
|
162
|
+
* - No params: returns all users of the app
|
|
163
|
+
* - chatName: returns all users of the chat (appId_uuId for group chats, xmppUsernameA-xmppUsernameB for 1-on-1)
|
|
164
|
+
* - xmppUsername: returns a specific user by XMPP username
|
|
165
|
+
*
|
|
166
|
+
* @param params - Query parameters for filtering users
|
|
167
|
+
* @returns The API response
|
|
168
|
+
*/
|
|
169
|
+
getUsers(params?: GetUsersQueryParams): Promise<ApiResponse>;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,QAAQ,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,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