@scryme/chat 2.91.43 → 2.91.76

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/src/sdk.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import axios, { AxiosRequestConfig } from 'axios';
2
- import { setGlobalToken } from './custom-instance';
2
+ import { setGlobalToken, parseSDKError } from './custom-instance';
3
3
  import { getSkyrmeChatAPI } from './generated/v3-server';
4
4
  import type {
5
5
  V3ProvisionWorkspaceDto,
@@ -560,7 +560,7 @@ export interface AssignSupportTicketDto {
560
560
  /**
561
561
  * Options for starting a new live chat session.
562
562
  */
563
- export interface StartLiveChatDto {
563
+ export interface SupportStartLiveChatDto {
564
564
  /** Unique workspace identifier where live chat is initialized. */
565
565
  workspaceId: string;
566
566
  /** Optional metadata associated with the live chat session. */
@@ -570,7 +570,7 @@ export interface StartLiveChatDto {
570
570
  /**
571
571
  * Options for creating or updating a customer profile.
572
572
  */
573
- export interface CreateCustomerProfileDto {
573
+ export interface SupportCreateCustomerProfileDto {
574
574
  /** Associated workspace identifier. */
575
575
  workspaceId: string;
576
576
  /** User ID of the customer. */
@@ -724,7 +724,7 @@ export class ScrymeSDK {
724
724
  }
725
725
  } catch (error) {
726
726
  console.error('ScrymeSDK failed to authenticate via client_credentials:', error);
727
- throw error;
727
+ throw parseSDKError(error);
728
728
  }
729
729
  }
730
730
 
@@ -788,7 +788,11 @@ export class ScrymeSDK {
788
788
  cleanArgs.push(config);
789
789
  }
790
790
 
791
- return (originalMethod as (...a: unknown[]) => unknown)(...cleanArgs);
791
+ try {
792
+ return await (originalMethod as (...a: unknown[]) => unknown)(...cleanArgs);
793
+ } catch (error) {
794
+ throw parseSDKError(error);
795
+ }
792
796
  };
793
797
  }
794
798
  return originalMethod;
@@ -1135,98 +1139,143 @@ export class ScrymeSDK {
1135
1139
  */
1136
1140
  message: {
1137
1141
  /**
1138
- * Lists messages in a channel with cursor pagination support.
1142
+ * Lists messages in a channel with cursor pagination support via V3 API.
1143
+ * @param slug The unique workspace slug.
1139
1144
  * @param channelId Unique identifier of the channel.
1140
1145
  * @param params Query parameters for limiting, sorting, or pagination cursors.
1141
1146
  * @param options Optional request config override.
1142
- * @returns Object containing the messages array and next pagination cursor exactly from the endpoint.
1143
1147
  */
1144
1148
  list: async (
1149
+ slug: string,
1145
1150
  channelId: string,
1146
- params?: ChannelsControllerGetMessagesParams,
1151
+ params?: { cursor?: string; limit?: string },
1147
1152
  options?: AxiosRequestConfig
1148
1153
  ): Promise<{ messages: ChannelMessage[]; nextCursor?: string }> => {
1149
- return this.raw.channelsControllerGetMessages(channelId, params, options) as unknown as { messages: ChannelMessage[]; nextCursor?: string };
1154
+ const queryParams: any = {};
1155
+ if (params?.cursor) queryParams.cursor = params.cursor;
1156
+ if (params?.limit) queryParams.limit = params.limit;
1157
+
1158
+ const res = (await this.raw.v3WorkspacesControllerGetChannelMessages(
1159
+ slug,
1160
+ channelId,
1161
+ queryParams,
1162
+ options
1163
+ )) as unknown as { success: boolean; data: { messages: ChannelMessage[]; nextCursor?: string } };
1164
+ return res?.data ?? (res as unknown as { messages: ChannelMessage[]; nextCursor?: string });
1150
1165
  },
1151
1166
  /**
1152
- * Sends a new message to a channel.
1167
+ * Sends a new message to a channel via V3 API.
1168
+ * @param slug The unique workspace slug.
1153
1169
  * @param channelId Unique identifier of the target channel.
1154
- * @param data The message content string or structured CreateMessageDto object.
1170
+ * @param data The message content string or structured payload object.
1155
1171
  * @param options Optional request config override.
1156
- * @returns The created message exactly from the endpoint.
1157
1172
  */
1158
1173
  create: async (
1174
+ slug: string,
1159
1175
  channelId: string,
1160
1176
  data: CreateMessageDto | string,
1161
1177
  options?: AxiosRequestConfig
1162
1178
  ): Promise<ChannelMessage> => {
1163
1179
  const payload = typeof data === 'string' ? { content: data } : data;
1164
- return this.raw.channelsControllerCreateMessage(channelId, {
1165
- ...options,
1166
- data: payload,
1167
- }) as unknown as ChannelMessage;
1180
+ const mergedConfig = { ...options, data: payload };
1181
+ const res = (await this.raw.v3WorkspacesControllerCreateChannelMessage(slug, channelId, mergedConfig)) as unknown as {
1182
+ success: boolean;
1183
+ data: { message: ChannelMessage };
1184
+ };
1185
+ return res?.data?.message ?? (res as unknown as ChannelMessage);
1168
1186
  },
1169
1187
  /**
1170
- * Updates the content of a previously sent message in a channel.
1188
+ * Updates the content of a previously sent message in a channel via V3 API.
1189
+ * @param slug The unique workspace slug.
1171
1190
  * @param channelId Unique identifier of the channel containing the message.
1172
1191
  * @param messageId Unique identifier of the message to update.
1173
1192
  * @param data The new content payload.
1174
1193
  * @param options Optional request config override.
1175
- * @returns The updated message details exactly from the endpoint.
1176
1194
  */
1177
1195
  update: async (
1196
+ slug: string,
1178
1197
  channelId: string,
1179
1198
  messageId: string,
1180
1199
  data: ChannelsControllerUpdateMessageBody,
1181
1200
  options?: AxiosRequestConfig
1182
1201
  ): Promise<ChannelMessage> => {
1183
- return this.raw.channelsControllerUpdateMessage(channelId, messageId, data, options) as unknown as ChannelMessage;
1202
+ const mergedConfig = { ...options, data };
1203
+ const res = (await this.raw.v3WorkspacesControllerUpdateChannelMessage(
1204
+ slug,
1205
+ channelId,
1206
+ messageId,
1207
+ mergedConfig
1208
+ )) as unknown as { success: boolean; data: { message: ChannelMessage } };
1209
+ return res?.data?.message ?? (res as unknown as ChannelMessage);
1184
1210
  },
1185
1211
  /**
1186
- * Permanently deletes a message in a channel.
1212
+ * Permanently deletes a message in a channel via V3 API.
1213
+ * @param slug The unique workspace slug.
1187
1214
  * @param channelId Unique identifier of the channel containing the message.
1188
1215
  * @param messageId Unique identifier of the message to delete.
1189
1216
  * @param options Optional request config override.
1190
- * @returns Success status indicating that the message was deleted exactly from the endpoint.
1191
1217
  */
1192
1218
  delete: async (
1219
+ slug: string,
1193
1220
  channelId: string,
1194
1221
  messageId: string,
1195
1222
  options?: AxiosRequestConfig
1196
1223
  ): Promise<{ success: boolean }> => {
1197
- return this.raw.channelsControllerDeleteMessage(channelId, messageId, options) as unknown as { success: boolean };
1224
+ const res = (await this.raw.v3WorkspacesControllerDeleteChannelMessage(
1225
+ slug,
1226
+ channelId,
1227
+ messageId,
1228
+ options
1229
+ )) as unknown as { success: boolean; data?: { success: boolean } };
1230
+ return res?.data ?? res;
1198
1231
  },
1199
1232
  /**
1200
- * Adds a reaction (emoji) to a message in a channel.
1233
+ * Adds a reaction (emoji) to a message in a channel via V3 API.
1234
+ * @param slug The unique workspace slug.
1201
1235
  * @param channelId Unique identifier of the channel containing the message.
1202
1236
  * @param messageId Unique identifier of the message.
1203
1237
  * @param data Object containing the target emoji character.
1204
1238
  * @param options Optional request config override.
1205
- * @returns The reaction response returned exactly from the endpoint.
1206
1239
  */
1207
1240
  addReaction: async (
1241
+ slug: string,
1208
1242
  channelId: string,
1209
1243
  messageId: string,
1210
1244
  data: ChannelsControllerAddReactionBody,
1211
1245
  options?: AxiosRequestConfig
1212
- ): Promise<ChannelsControllerAddReactionResult> => {
1213
- return this.raw.channelsControllerAddReaction(channelId, messageId, data, options) as unknown as ChannelsControllerAddReactionResult;
1246
+ ): Promise<any> => {
1247
+ const mergedConfig = { ...options, data };
1248
+ const res = (await this.raw.v3WorkspacesControllerAddChannelMessageReaction(
1249
+ slug,
1250
+ channelId,
1251
+ messageId,
1252
+ mergedConfig
1253
+ )) as unknown as { success: boolean; data: { reaction: any } };
1254
+ return res?.data?.reaction ?? res;
1214
1255
  },
1215
1256
  /**
1216
- * Removes a reaction (emoji) from a message in a channel.
1257
+ * Removes a reaction (emoji) from a message in a channel via V3 API.
1258
+ * @param slug The unique workspace slug.
1217
1259
  * @param channelId Unique identifier of the channel containing the message.
1218
1260
  * @param messageId Unique identifier of the message.
1219
1261
  * @param emoji The emoji character to remove.
1220
1262
  * @param options Optional request config override.
1221
- * @returns The reaction removal response returned exactly from the endpoint.
1222
1263
  */
1223
1264
  removeReaction: async (
1265
+ slug: string,
1224
1266
  channelId: string,
1225
1267
  messageId: string,
1226
1268
  emoji: string,
1227
1269
  options?: AxiosRequestConfig
1228
- ): Promise<ChannelsControllerRemoveReactionResult> => {
1229
- return this.raw.channelsControllerRemoveReaction(channelId, messageId, emoji, options) as unknown as ChannelsControllerRemoveReactionResult;
1270
+ ): Promise<{ success: boolean }> => {
1271
+ const res = (await this.raw.v3WorkspacesControllerRemoveChannelMessageReaction(
1272
+ slug,
1273
+ channelId,
1274
+ messageId,
1275
+ emoji,
1276
+ options
1277
+ )) as unknown as { success: boolean; data?: { success: boolean } };
1278
+ return res?.data ?? res;
1230
1279
  },
1231
1280
  },
1232
1281
  };
@@ -1316,69 +1365,83 @@ export class ScrymeSDK {
1316
1365
  }
1317
1366
 
1318
1367
  /**
1319
- * Operations for managing direct messages (DMs) and direct message conversations.
1368
+ * Operations for managing direct messages (DMs) and direct message conversations via V3 API.
1320
1369
  */
1321
1370
  public get dm() {
1322
1371
  return {
1323
1372
  /**
1324
- * Lists all active direct message conversations for the authenticated user.
1373
+ * Lists all active direct message conversations for the authenticated user/bot via V3 API.
1325
1374
  * @param options Optional request config override.
1326
- * @returns List of active DM conversations returned exactly from the endpoint.
1327
1375
  */
1328
1376
  list: async (options?: AxiosRequestConfig): Promise<DmConversation[]> => {
1329
- return this.raw.dmsControllerGetDms(options) as unknown as DmConversation[];
1377
+ const res = (await this.raw.v3DmsControllerGetDms(options)) as unknown as {
1378
+ success: boolean;
1379
+ data: { conversations: DmConversation[] };
1380
+ };
1381
+ return res?.data?.conversations ?? (res as unknown as DmConversation[]);
1330
1382
  },
1331
1383
  /**
1332
- * Creates/initiates a direct message conversation with specified users.
1384
+ * Creates/initiates a direct message conversation via V3 API.
1333
1385
  * @param data Create direct message details containing target participant IDs.
1334
1386
  * @param options Optional request config override.
1335
- * @returns Details of the created DM conversation exactly from the endpoint.
1336
1387
  */
1337
- create: async (data: CreateDmDto, options?: AxiosRequestConfig): Promise<DmConversation> => {
1338
- return this.raw.dmsControllerCreateDm(data, options) as unknown as DmConversation;
1388
+ create: async (data: CreateDmDto | { targetUserId?: string; userId?: string }, options?: AxiosRequestConfig): Promise<DmConversation> => {
1389
+ const res = (await this.raw.v3DmsControllerCreateDm(data as any, options)) as unknown as {
1390
+ success: boolean;
1391
+ data: { conversation: DmConversation };
1392
+ };
1393
+ return res?.data?.conversation ?? (res as unknown as DmConversation);
1339
1394
  },
1340
1395
  /**
1341
- * Retrieves details of a specific direct message conversation.
1396
+ * Retrieves details of a specific direct message conversation via V3 API.
1342
1397
  * @param dmId Unique identifier of the direct message conversation.
1343
1398
  * @param options Optional request config override.
1344
- * @returns Detailed direct message conversation object exactly from the endpoint.
1345
1399
  */
1346
1400
  get: async (dmId: string, options?: AxiosRequestConfig): Promise<DmConversation> => {
1347
- return this.raw.dmsControllerGetDm(dmId, options) as unknown as DmConversation;
1401
+ const res = (await this.raw.v3DmsControllerGetDm(dmId, options)) as unknown as {
1402
+ success: boolean;
1403
+ data: { conversation: DmConversation };
1404
+ };
1405
+ return res?.data?.conversation ?? (res as unknown as DmConversation);
1348
1406
  },
1349
1407
  /**
1350
- * Deletes/closes an active direct message conversation.
1408
+ * Deletes/closes an active direct message conversation via V3 API.
1351
1409
  * @param dmId Unique identifier of the direct message conversation to close.
1352
1410
  * @param options Optional request config override.
1353
- * @returns Success status indicating that the DM conversation was deleted exactly from the endpoint.
1354
1411
  */
1355
1412
  delete: async (dmId: string, options?: AxiosRequestConfig): Promise<{ success: boolean }> => {
1356
- return this.raw.dmsControllerDeleteDm(dmId, options) as unknown as { success: boolean };
1413
+ const res = (await this.raw.v3DmsControllerDeleteDm(dmId, options)) as unknown as {
1414
+ success: boolean;
1415
+ data?: { success: boolean };
1416
+ };
1417
+ return res?.data ?? res;
1357
1418
  },
1358
1419
  /**
1359
- * Sub-namespace for managing direct messages in a specific DM conversation.
1420
+ * Sub-namespace for managing direct messages in a specific DM conversation via V3 API.
1360
1421
  */
1361
1422
  message: {
1362
1423
  /**
1363
- * Lists messages in a direct message conversation with cursor pagination.
1424
+ * Lists messages in a direct message conversation with cursor pagination via V3 API.
1364
1425
  * @param dmId Unique identifier of the direct message conversation.
1365
1426
  * @param params Query parameters for pagination limits, cursors or search filters.
1366
1427
  * @param options Optional request config override.
1367
- * @returns List of direct messages and next pagination cursor exactly from the endpoint.
1368
1428
  */
1369
1429
  list: async (
1370
1430
  dmId: string,
1371
1431
  params?: DmsControllerGetMessagesParams,
1372
1432
  options?: AxiosRequestConfig
1373
1433
  ): Promise<{ messages: ChannelMessage[]; nextCursor?: string }> => {
1374
- return this.raw.dmsControllerGetMessages(dmId, params, options) as unknown as { messages: ChannelMessage[]; nextCursor?: string };
1434
+ const res = (await this.raw.v3DmsControllerGetMessages(dmId, params, options)) as unknown as {
1435
+ success: boolean;
1436
+ data: { messages: ChannelMessage[]; nextCursor?: string };
1437
+ };
1438
+ return res?.data ?? (res as unknown as { messages: ChannelMessage[]; nextCursor?: string });
1375
1439
  },
1376
1440
  /**
1377
- * Sends a new message in a direct message conversation.
1441
+ * Sends a new message in a direct message conversation via V3 API.
1378
1442
  * @param dmId Unique identifier of the direct message conversation.
1379
1443
  * @param data The message content string or structured CreateMessageDto object.
1380
1444
  * @param options Optional request config override.
1381
- * @returns The sent message exactly from the endpoint.
1382
1445
  */
1383
1446
  create: async (
1384
1447
  dmId: string,
@@ -1386,18 +1449,19 @@ export class ScrymeSDK {
1386
1449
  options?: AxiosRequestConfig
1387
1450
  ): Promise<ChannelMessage> => {
1388
1451
  const payload = typeof data === 'string' ? { content: data } : data;
1389
- return this.raw.dmsControllerCreateMessage(dmId, {
1390
- ...options,
1391
- data: payload,
1392
- }) as unknown as ChannelMessage;
1452
+ const mergedConfig = { ...options, data: payload };
1453
+ const res = (await this.raw.v3DmsControllerCreateMessage(dmId, mergedConfig)) as unknown as {
1454
+ success: boolean;
1455
+ data: { message: ChannelMessage };
1456
+ };
1457
+ return res?.data?.message ?? (res as unknown as ChannelMessage);
1393
1458
  },
1394
1459
  /**
1395
- * Updates the content of a previously sent direct message.
1460
+ * Updates the content of a previously sent direct message via V3 API.
1396
1461
  * @param dmId Unique identifier of the direct message conversation.
1397
1462
  * @param messageId Unique identifier of the message to update.
1398
1463
  * @param data The new content payload.
1399
1464
  * @param options Optional request config override.
1400
- * @returns The updated message details exactly from the endpoint.
1401
1465
  */
1402
1466
  update: async (
1403
1467
  dmId: string,
@@ -1405,53 +1469,68 @@ export class ScrymeSDK {
1405
1469
  data: UpdateDmMessageDto,
1406
1470
  options?: AxiosRequestConfig
1407
1471
  ): Promise<ChannelMessage> => {
1408
- return this.raw.dmsControllerUpdateMessage(dmId, messageId, data, options) as unknown as ChannelMessage;
1472
+ const mergedConfig = { ...options, data };
1473
+ const res = (await this.raw.v3DmsControllerUpdateMessage(dmId, messageId, mergedConfig)) as unknown as {
1474
+ success: boolean;
1475
+ data: { message: ChannelMessage };
1476
+ };
1477
+ return res?.data?.message ?? (res as unknown as ChannelMessage);
1409
1478
  },
1410
1479
  /**
1411
- * Permanently deletes a direct message.
1480
+ * Permanently deletes a direct message via V3 API.
1412
1481
  * @param dmId Unique identifier of the direct message conversation.
1413
1482
  * @param messageId Unique identifier of the message to delete.
1414
1483
  * @param options Optional request config override.
1415
- * @returns Success status indicating that the message was deleted exactly from the endpoint.
1416
1484
  */
1417
1485
  delete: async (
1418
1486
  dmId: string,
1419
1487
  messageId: string,
1420
1488
  options?: AxiosRequestConfig
1421
1489
  ): Promise<{ success: boolean }> => {
1422
- return this.raw.dmsControllerDeleteMessage(dmId, messageId, options) as unknown as { success: boolean };
1490
+ const res = (await this.raw.v3DmsControllerDeleteMessage(dmId, messageId, options)) as unknown as {
1491
+ success: boolean;
1492
+ data?: { success: boolean };
1493
+ };
1494
+ return res?.data ?? res;
1423
1495
  },
1424
1496
  /**
1425
- * Adds a reaction (emoji) to a direct message.
1497
+ * Adds a reaction (emoji) to a direct message via V3 API.
1426
1498
  * @param dmId Unique identifier of the direct message conversation.
1427
1499
  * @param messageId Unique identifier of the message.
1428
1500
  * @param data Object containing the target emoji character.
1429
1501
  * @param options Optional request config override.
1430
- * @returns The reaction response returned exactly from the endpoint.
1431
1502
  */
1432
1503
  addReaction: async (
1433
1504
  dmId: string,
1434
1505
  messageId: string,
1435
1506
  data: DmsControllerAddReactionBody,
1436
1507
  options?: AxiosRequestConfig
1437
- ): Promise<DmsControllerAddReactionResult> => {
1438
- return this.raw.dmsControllerAddReaction(dmId, messageId, data, options) as unknown as DmsControllerAddReactionResult;
1508
+ ): Promise<any> => {
1509
+ const mergedConfig = { ...options, data };
1510
+ const res = (await this.raw.v3DmsControllerAddReaction(dmId, messageId, mergedConfig)) as unknown as {
1511
+ success: boolean;
1512
+ data: { reaction: any };
1513
+ };
1514
+ return res?.data?.reaction ?? res;
1439
1515
  },
1440
1516
  /**
1441
- * Removes a reaction (emoji) from a direct message.
1517
+ * Removes a reaction (emoji) from a direct message via V3 API.
1442
1518
  * @param dmId Unique identifier of the direct message conversation.
1443
1519
  * @param messageId Unique identifier of the message.
1444
1520
  * @param emoji The emoji character to remove.
1445
1521
  * @param options Optional request config override.
1446
- * @returns The reaction removal response returned exactly from the endpoint.
1447
1522
  */
1448
1523
  removeReaction: async (
1449
1524
  dmId: string,
1450
1525
  messageId: string,
1451
1526
  emoji: string,
1452
1527
  options?: AxiosRequestConfig
1453
- ): Promise<DmsControllerRemoveReactionResult> => {
1454
- return this.raw.dmsControllerRemoveReaction(dmId, messageId, emoji, options) as unknown as DmsControllerRemoveReactionResult;
1528
+ ): Promise<{ success: boolean }> => {
1529
+ const res = (await this.raw.v3DmsControllerRemoveReaction(dmId, messageId, emoji, options)) as unknown as {
1530
+ success: boolean;
1531
+ data?: { success: boolean };
1532
+ };
1533
+ return res?.data ?? res;
1455
1534
  },
1456
1535
  },
1457
1536
  };
@@ -1797,7 +1876,7 @@ export class ScrymeSDK {
1797
1876
  * @param options Optional request config override.
1798
1877
  */
1799
1878
  start: async (
1800
- data: StartLiveChatDto,
1879
+ data: SupportStartLiveChatDto,
1801
1880
  options?: AxiosRequestConfig
1802
1881
  ): Promise<LiveChatSession> => {
1803
1882
  return this.raw.supportControllerStartLiveChat({
@@ -1828,7 +1907,7 @@ export class ScrymeSDK {
1828
1907
  * @param options Optional request config override.
1829
1908
  */
1830
1909
  createProfile: async (
1831
- data: CreateCustomerProfileDto,
1910
+ data: SupportCreateCustomerProfileDto,
1832
1911
  options?: AxiosRequestConfig
1833
1912
  ): Promise<CustomerProfile> => {
1834
1913
  return this.raw.supportControllerCreateCustomerProfile({