@scryme/chat 2.13.3 → 2.13.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/dist/sdk.js CHANGED
@@ -57,11 +57,21 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
57
57
  import axios from 'axios';
58
58
  import { setGlobalToken } from './custom-instance';
59
59
  import { getSkyrmeChatAPI } from './generated/v3-server';
60
+ /**
61
+ * The primary client SDK class for accessing the Scryme Chat platform APIs.
62
+ * Supports automated OAuth2 Token management and provides clean, type-safe namespaces.
63
+ */
60
64
  var ScrymeSDK = /** @class */ (function () {
65
+ /**
66
+ * Constructs a new ScrymeSDK instance.
67
+ * @param options Configuration options for baseURL, tokens, and credentials.
68
+ */
61
69
  function ScrymeSDK(options) {
62
70
  if (options === void 0) { options = {}; }
63
71
  var _a;
72
+ /** The currently cached access token. */
64
73
  this.token = null;
74
+ /** Timestamp in milliseconds indicating when the cached token will expire. */
65
75
  this.tokenExpiresAt = null;
66
76
  this.clientId = options.clientId;
67
77
  this.clientSecret = options.clientSecret;
@@ -77,7 +87,9 @@ var ScrymeSDK = /** @class */ (function () {
77
87
  var g = globalThis;
78
88
  var env = ((_a = g.process) === null || _a === void 0 ? void 0 : _a.env) || g.__env__ || {};
79
89
  var isProd = env.NODE_ENV === 'production' ||
80
- (typeof window !== 'undefined' && window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1');
90
+ (typeof window !== 'undefined' &&
91
+ window.location.hostname !== 'localhost' &&
92
+ window.location.hostname !== '127.0.0.1');
81
93
  url =
82
94
  env.API_URL ||
83
95
  env.NEXT_PUBLIC_API_URL ||
@@ -86,6 +98,10 @@ var ScrymeSDK = /** @class */ (function () {
86
98
  }
87
99
  this.baseURL = url.replace(/\/$/, '');
88
100
  }
101
+ /**
102
+ * Synchronizes the authentication token to local storage and the global configuration.
103
+ * @param token The token to synchronize.
104
+ */
89
105
  ScrymeSDK.prototype.syncToken = function (token) {
90
106
  if (!token)
91
107
  return;
@@ -97,7 +113,9 @@ var ScrymeSDK = /** @class */ (function () {
97
113
  }
98
114
  };
99
115
  /**
100
- * Automatically retrieves or refreshes the M2M OAuth2 Token using client_credentials
116
+ * Automatically retrieves a cached token, or fetches a new one via M2M OAuth2 Client Credentials
117
+ * if a clientId and clientSecret are configured.
118
+ * @returns A promise resolving to the token string, or null if unauthenticated.
101
119
  */
102
120
  ScrymeSDK.prototype.getOrFetchToken = function () {
103
121
  return __awaiter(this, void 0, void 0, function () {
@@ -158,7 +176,8 @@ var ScrymeSDK = /** @class */ (function () {
158
176
  });
159
177
  };
160
178
  /**
161
- * Gets the axios request config containing authorization and base url
179
+ * Generates the default request configuration containing the authorization headers and baseURL.
180
+ * @returns Request configuration object.
162
181
  */
163
182
  ScrymeSDK.prototype.getRequestConfig = function () {
164
183
  return __awaiter(this, void 0, void 0, function () {
@@ -230,67 +249,155 @@ var ScrymeSDK = /** @class */ (function () {
230
249
  });
231
250
  Object.defineProperty(ScrymeSDK.prototype, "workspace", {
232
251
  // --- High-level nested namespace chains for excellent DX ---
252
+ /**
253
+ * Operations for managing workspaces, including creation, updating, retrieval,
254
+ * members, and channels.
255
+ */
233
256
  get: function () {
234
257
  var _this = this;
235
258
  return {
259
+ /**
260
+ * Lists all workspaces in the authenticated organization context.
261
+ * @param options Optional request config override.
262
+ * @returns List of workspaces returned exactly from the endpoint.
263
+ */
236
264
  list: function (options) { return __awaiter(_this, void 0, void 0, function () {
237
265
  return __generator(this, function (_a) {
238
266
  return [2 /*return*/, this.raw.v3WorkspacesControllerGetWorkspaces(options)];
239
267
  });
240
268
  }); },
269
+ /**
270
+ * Retrieves detailed information of a specific workspace by its slug.
271
+ * @param slug The unique workspace slug identifier.
272
+ * @param options Optional request config override.
273
+ * @returns Workspace details returned exactly from the endpoint.
274
+ */
241
275
  get: function (slug, options) { return __awaiter(_this, void 0, void 0, function () {
242
276
  return __generator(this, function (_a) {
243
277
  return [2 /*return*/, this.raw.v3WorkspacesControllerGetWorkspaceBySlug(slug, options)];
244
278
  });
245
279
  }); },
280
+ /**
281
+ * Provisions a new workspace inside the organization.
282
+ * @param data Workspace creation and configuration data.
283
+ * @param options Optional request config override.
284
+ * @returns Provisioned workspace and bot configuration exactly from the endpoint.
285
+ */
246
286
  create: function (data, options) { return __awaiter(_this, void 0, void 0, function () {
247
287
  return __generator(this, function (_a) {
248
288
  return [2 /*return*/, this.raw.v3WorkspacesControllerProvisionWorkspace(data, options)];
249
289
  });
250
290
  }); },
291
+ /**
292
+ * Updates the configurations and metadata of an existing workspace.
293
+ * @param slug The unique workspace slug identifier.
294
+ * @param data Fields to update.
295
+ * @param options Optional request config override.
296
+ * @returns The updated workspace details exactly from the endpoint.
297
+ */
251
298
  update: function (slug, data, options) { return __awaiter(_this, void 0, void 0, function () {
252
299
  return __generator(this, function (_a) {
253
300
  return [2 /*return*/, this.raw.v3WorkspacesControllerUpdateWorkspace(slug, data, options)];
254
301
  });
255
302
  }); },
303
+ /**
304
+ * Permanently deletes a specific workspace by its slug.
305
+ * @param slug The unique workspace slug identifier.
306
+ * @param options Optional request config override.
307
+ * @returns Deletion status response exactly from the endpoint.
308
+ */
256
309
  delete: function (slug, options) { return __awaiter(_this, void 0, void 0, function () {
257
310
  return __generator(this, function (_a) {
258
311
  return [2 /*return*/, this.raw.v3WorkspacesControllerDeleteWorkspace(slug, options)];
259
312
  });
260
313
  }); },
314
+ /**
315
+ * Operations for managing workspace members, including listing, adding, role updates, and removal.
316
+ */
261
317
  members: {
318
+ /**
319
+ * Lists all members currently in a workspace.
320
+ * @param slug The unique workspace slug identifier.
321
+ * @param options Optional request config override.
322
+ * @returns List of workspace members exactly from the endpoint.
323
+ */
262
324
  list: function (slug, options) { return __awaiter(_this, void 0, void 0, function () {
263
325
  return __generator(this, function (_a) {
264
326
  return [2 /*return*/, this.raw.v3WorkspacesControllerGetWorkspaceMembers(slug, options)];
265
327
  });
266
328
  }); },
329
+ /**
330
+ * Adds a new member to the workspace.
331
+ * @param slug The unique workspace slug identifier.
332
+ * @param data Input DTO containing the user's email and role.
333
+ * @param options Optional request config override.
334
+ * @returns Newly added member details exactly from the endpoint.
335
+ */
267
336
  add: function (slug, data, options) { return __awaiter(_this, void 0, void 0, function () {
268
337
  return __generator(this, function (_a) {
269
338
  return [2 /*return*/, this.raw.v3WorkspacesControllerAddWorkspaceMember(slug, data, options)];
270
339
  });
271
340
  }); },
341
+ /**
342
+ * Retrieves membership details of a specific member in a workspace.
343
+ * @param slug The unique workspace slug identifier.
344
+ * @param memberId Unique ID of the workspace member (user ID).
345
+ * @param options Optional request config override.
346
+ * @returns Workspace member details exactly from the endpoint.
347
+ */
272
348
  get: function (slug, memberId, options) { return __awaiter(_this, void 0, void 0, function () {
273
349
  return __generator(this, function (_a) {
274
350
  return [2 /*return*/, this.raw.v3WorkspacesControllerGetWorkspaceMember(slug, memberId, options)];
275
351
  });
276
352
  }); },
353
+ /**
354
+ * Updates the role or configuration of a workspace member.
355
+ * @param slug The unique workspace slug identifier.
356
+ * @param memberId Unique ID of the workspace member (user ID).
357
+ * @param data Update details containing the target role.
358
+ * @param options Optional request config override.
359
+ * @returns The updated workspace member details exactly from the endpoint.
360
+ */
277
361
  update: function (slug, memberId, data, options) { return __awaiter(_this, void 0, void 0, function () {
278
362
  return __generator(this, function (_a) {
279
363
  return [2 /*return*/, this.raw.v3WorkspacesControllerUpdateWorkspaceMember(slug, memberId, data, options)];
280
364
  });
281
365
  }); },
366
+ /**
367
+ * Removes a member from the workspace.
368
+ * @param slug The unique workspace slug identifier.
369
+ * @param memberId Unique ID of the workspace member (user ID).
370
+ * @param options Optional request config override.
371
+ * @returns Workspace member deletion confirmation exactly from the endpoint.
372
+ */
282
373
  delete: function (slug, memberId, options) { return __awaiter(_this, void 0, void 0, function () {
283
374
  return __generator(this, function (_a) {
284
375
  return [2 /*return*/, this.raw.v3WorkspacesControllerDeleteWorkspaceMember(slug, memberId, options)];
285
376
  });
286
377
  }); },
287
378
  },
379
+ /**
380
+ * Operations for listing and creating channels inside a workspace.
381
+ */
288
382
  channels: {
383
+ /**
384
+ * Lists all public channels (and private channels the user has access to) in a workspace.
385
+ * @param slug The unique workspace slug identifier.
386
+ * @param options Optional request config override.
387
+ * @returns List of channels returned exactly from the endpoint.
388
+ */
289
389
  list: function (slug, options) { return __awaiter(_this, void 0, void 0, function () {
290
390
  return __generator(this, function (_a) {
291
391
  return [2 /*return*/, this.raw.channelsControllerGetWorkspaceChannels(slug, options)];
292
392
  });
293
393
  }); },
394
+ /**
395
+ * Creates a new channel within a workspace.
396
+ * @param slug The unique workspace slug identifier.
397
+ * @param data Configuration DTO for the new channel.
398
+ * @param options Optional request config override.
399
+ * @returns Details of the created channel exactly from the endpoint.
400
+ */
294
401
  create: function (slug, data, options) { return __awaiter(_this, void 0, void 0, function () {
295
402
  return __generator(this, function (_a) {
296
403
  return [2 /*return*/, this.raw.channelsControllerCreateChannel(slug, data, options)];
@@ -303,30 +410,71 @@ var ScrymeSDK = /** @class */ (function () {
303
410
  configurable: true
304
411
  });
305
412
  Object.defineProperty(ScrymeSDK.prototype, "channel", {
413
+ /**
414
+ * Operations for managing specific channels and channel message actions.
415
+ */
306
416
  get: function () {
307
417
  var _this = this;
308
418
  return {
419
+ /**
420
+ * Retrieves detailed information of a specific channel.
421
+ * @param slug The unique workspace slug identifier.
422
+ * @param channelId Unique identifier of the channel.
423
+ * @param options Optional request config override.
424
+ * @returns Channel details returned exactly from the endpoint.
425
+ */
309
426
  get: function (slug, channelId, options) { return __awaiter(_this, void 0, void 0, function () {
310
427
  return __generator(this, function (_a) {
311
428
  return [2 /*return*/, this.raw.channelsControllerGetChannel(slug, channelId, options)];
312
429
  });
313
430
  }); },
431
+ /**
432
+ * Updates configuration, description, icon or status of an existing channel.
433
+ * @param slug The unique workspace slug identifier.
434
+ * @param channelId Unique identifier of the channel.
435
+ * @param data Configuration options to update.
436
+ * @param options Optional request config override.
437
+ * @returns The updated channel details exactly from the endpoint.
438
+ */
314
439
  update: function (slug, channelId, data, options) { return __awaiter(_this, void 0, void 0, function () {
315
440
  return __generator(this, function (_a) {
316
441
  return [2 /*return*/, this.raw.channelsControllerUpdateChannel(slug, channelId, data, options)];
317
442
  });
318
443
  }); },
444
+ /**
445
+ * Permanently deletes a channel from a workspace.
446
+ * @param slug The unique workspace slug identifier.
447
+ * @param channelId Unique identifier of the channel to delete.
448
+ * @param options Optional request config override.
449
+ * @returns Success status indicating that the channel was deleted exactly from the endpoint.
450
+ */
319
451
  delete: function (slug, channelId, options) { return __awaiter(_this, void 0, void 0, function () {
320
452
  return __generator(this, function (_a) {
321
453
  return [2 /*return*/, this.raw.channelsControllerDeleteChannel(slug, channelId, options)];
322
454
  });
323
455
  }); },
456
+ /**
457
+ * Sub-namespace for managing messages inside a channel.
458
+ */
324
459
  message: {
460
+ /**
461
+ * Lists messages in a channel with cursor pagination support.
462
+ * @param channelId Unique identifier of the channel.
463
+ * @param params Query parameters for limiting, sorting, or pagination cursors.
464
+ * @param options Optional request config override.
465
+ * @returns Object containing the messages array and next pagination cursor exactly from the endpoint.
466
+ */
325
467
  list: function (channelId, params, options) { return __awaiter(_this, void 0, void 0, function () {
326
468
  return __generator(this, function (_a) {
327
469
  return [2 /*return*/, this.raw.channelsControllerGetMessages(channelId, params, options)];
328
470
  });
329
471
  }); },
472
+ /**
473
+ * Sends a new message to a channel.
474
+ * @param channelId Unique identifier of the target channel.
475
+ * @param options Optional request config override. Note that standard message data (like text content) can be passed inside options.data.
476
+ * @returns The created message exactly from the endpoint.
477
+ */
330
478
  create: function (channelId, options) { return __awaiter(_this, void 0, void 0, function () {
331
479
  return __generator(this, function (_a) {
332
480
  return [2 /*return*/, this.raw.channelsControllerCreateMessage(channelId, options)];
@@ -339,24 +487,58 @@ var ScrymeSDK = /** @class */ (function () {
339
487
  configurable: true
340
488
  });
341
489
  Object.defineProperty(ScrymeSDK.prototype, "message", {
490
+ /**
491
+ * Operations for modifying, reacting to, or deleting existing channel messages.
492
+ */
342
493
  get: function () {
343
494
  var _this = this;
344
495
  return {
496
+ /**
497
+ * Updates the content of a previously sent message.
498
+ * @param channelId Unique identifier of the channel containing the message.
499
+ * @param messageId Unique identifier of the message to update.
500
+ * @param data The new content payload.
501
+ * @param options Optional request config override.
502
+ * @returns The updated message details exactly from the endpoint.
503
+ */
345
504
  update: function (channelId, messageId, data, options) { return __awaiter(_this, void 0, void 0, function () {
346
505
  return __generator(this, function (_a) {
347
506
  return [2 /*return*/, this.raw.channelsControllerUpdateMessage(channelId, messageId, data, options)];
348
507
  });
349
508
  }); },
509
+ /**
510
+ * Permanently deletes a message.
511
+ * @param channelId Unique identifier of the channel containing the message.
512
+ * @param messageId Unique identifier of the message to delete.
513
+ * @param options Optional request config override.
514
+ * @returns Success status indicating that the message was deleted exactly from the endpoint.
515
+ */
350
516
  delete: function (channelId, messageId, options) { return __awaiter(_this, void 0, void 0, function () {
351
517
  return __generator(this, function (_a) {
352
518
  return [2 /*return*/, this.raw.channelsControllerDeleteMessage(channelId, messageId, options)];
353
519
  });
354
520
  }); },
521
+ /**
522
+ * Adds a reaction (emoji) to a message.
523
+ * @param channelId Unique identifier of the channel containing the message.
524
+ * @param messageId Unique identifier of the message.
525
+ * @param data Object containing the target emoji character.
526
+ * @param options Optional request config override.
527
+ * @returns The reaction response returned exactly from the endpoint.
528
+ */
355
529
  addReaction: function (channelId, messageId, data, options) { return __awaiter(_this, void 0, void 0, function () {
356
530
  return __generator(this, function (_a) {
357
531
  return [2 /*return*/, this.raw.channelsControllerAddReaction(channelId, messageId, data, options)];
358
532
  });
359
533
  }); },
534
+ /**
535
+ * Removes a reaction (emoji) from a message.
536
+ * @param channelId Unique identifier of the channel containing the message.
537
+ * @param messageId Unique identifier of the message.
538
+ * @param emoji The emoji character to remove.
539
+ * @param options Optional request config override.
540
+ * @returns The reaction removal response returned exactly from the endpoint.
541
+ */
360
542
  removeReaction: function (channelId, messageId, emoji, options) { return __awaiter(_this, void 0, void 0, function () {
361
543
  return __generator(this, function (_a) {
362
544
  return [2 /*return*/, this.raw.channelsControllerRemoveReaction(channelId, messageId, emoji, options)];
@@ -368,35 +550,77 @@ var ScrymeSDK = /** @class */ (function () {
368
550
  configurable: true
369
551
  });
370
552
  Object.defineProperty(ScrymeSDK.prototype, "dm", {
553
+ /**
554
+ * Operations for managing direct messages (DMs) and direct message conversations.
555
+ */
371
556
  get: function () {
372
557
  var _this = this;
373
558
  return {
559
+ /**
560
+ * Lists all active direct message conversations for the authenticated user.
561
+ * @param options Optional request config override.
562
+ * @returns List of active DM conversations returned exactly from the endpoint.
563
+ */
374
564
  list: function (options) { return __awaiter(_this, void 0, void 0, function () {
375
565
  return __generator(this, function (_a) {
376
566
  return [2 /*return*/, this.raw.dmsControllerGetDms(options)];
377
567
  });
378
568
  }); },
569
+ /**
570
+ * Creates/initiates a direct message conversation with specified users.
571
+ * @param data Create direct message details containing target participant IDs.
572
+ * @param options Optional request config override.
573
+ * @returns Details of the created DM conversation exactly from the endpoint.
574
+ */
379
575
  create: function (data, options) { return __awaiter(_this, void 0, void 0, function () {
380
576
  return __generator(this, function (_a) {
381
577
  return [2 /*return*/, this.raw.dmsControllerCreateDm(data, options)];
382
578
  });
383
579
  }); },
580
+ /**
581
+ * Retrieves details of a specific direct message conversation.
582
+ * @param dmId Unique identifier of the direct message conversation.
583
+ * @param options Optional request config override.
584
+ * @returns Detailed direct message conversation object exactly from the endpoint.
585
+ */
384
586
  get: function (dmId, options) { return __awaiter(_this, void 0, void 0, function () {
385
587
  return __generator(this, function (_a) {
386
588
  return [2 /*return*/, this.raw.dmsControllerGetDm(dmId, options)];
387
589
  });
388
590
  }); },
591
+ /**
592
+ * Deletes/closes an active direct message conversation.
593
+ * @param dmId Unique identifier of the direct message conversation to close.
594
+ * @param options Optional request config override.
595
+ * @returns Success status indicating that the DM conversation was deleted exactly from the endpoint.
596
+ */
389
597
  delete: function (dmId, options) { return __awaiter(_this, void 0, void 0, function () {
390
598
  return __generator(this, function (_a) {
391
599
  return [2 /*return*/, this.raw.dmsControllerDeleteDm(dmId, options)];
392
600
  });
393
601
  }); },
602
+ /**
603
+ * Sub-namespace for managing direct messages in a specific DM conversation.
604
+ */
394
605
  message: {
606
+ /**
607
+ * Lists messages in a direct message conversation with cursor pagination.
608
+ * @param dmId Unique identifier of the direct message conversation.
609
+ * @param params Query parameters for pagination limits, cursors or search filters.
610
+ * @param options Optional request config override.
611
+ * @returns List of direct messages and next pagination cursor exactly from the endpoint.
612
+ */
395
613
  list: function (dmId, params, options) { return __awaiter(_this, void 0, void 0, function () {
396
614
  return __generator(this, function (_a) {
397
615
  return [2 /*return*/, this.raw.dmsControllerGetMessages(dmId, params, options)];
398
616
  });
399
617
  }); },
618
+ /**
619
+ * Sends a new message in a direct message conversation.
620
+ * @param dmId Unique identifier of the direct message conversation.
621
+ * @param options Optional request config override. Note that content/attachments can be passed inside options.data.
622
+ * @returns The sent message exactly from the endpoint.
623
+ */
400
624
  create: function (dmId, options) { return __awaiter(_this, void 0, void 0, function () {
401
625
  return __generator(this, function (_a) {
402
626
  return [2 /*return*/, this.raw.dmsControllerCreateMessage(dmId, options)];
@@ -409,19 +633,40 @@ var ScrymeSDK = /** @class */ (function () {
409
633
  configurable: true
410
634
  });
411
635
  Object.defineProperty(ScrymeSDK.prototype, "user", {
636
+ /**
637
+ * Operations for retrieving information about the current user or other user profiles,
638
+ * as well as performing user searches.
639
+ */
412
640
  get: function () {
413
641
  var _this = this;
414
642
  return {
643
+ /**
644
+ * Retrieves the profile details of the currently authenticated user.
645
+ * @param options Optional request config override.
646
+ * @returns The active user's profile returned exactly from the endpoint.
647
+ */
415
648
  me: function (options) { return __awaiter(_this, void 0, void 0, function () {
416
649
  return __generator(this, function (_a) {
417
650
  return [2 /*return*/, this.raw.usersControllerGetMe(options)];
418
651
  });
419
652
  }); },
653
+ /**
654
+ * Retrieves the public profile of a user by their user ID.
655
+ * @param userId Unique identifier of the target user.
656
+ * @param options Optional request config override.
657
+ * @returns Public user profile returned exactly from the endpoint.
658
+ */
420
659
  get: function (userId, options) { return __awaiter(_this, void 0, void 0, function () {
421
660
  return __generator(this, function (_a) {
422
661
  return [2 /*return*/, this.raw.usersControllerGetUser(userId, options)];
423
662
  });
424
663
  }); },
664
+ /**
665
+ * Searches the organization or workspace directory for user profiles matching specific queries.
666
+ * @param params Object containing search filters and query string parameters.
667
+ * @param options Optional request config override.
668
+ * @returns List of matching user profiles returned exactly from the endpoint.
669
+ */
425
670
  search: function (params, options) { return __awaiter(_this, void 0, void 0, function () {
426
671
  return __generator(this, function (_a) {
427
672
  return [2 /*return*/, this.raw.usersControllerSearchUsers(params, options)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scryme/chat",
3
- "version": "2.13.3",
3
+ "version": "2.13.4",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"