@scryme/chat 0.0.1 → 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/src/sdk.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import axios, { AxiosRequestConfig } from 'axios';
2
+ import { setGlobalToken } from './custom-instance';
2
3
  import { getSkyrmeChatAPI } from './generated/v3-server';
3
4
  import type {
4
5
  V3ProvisionWorkspaceDto,
@@ -14,33 +15,441 @@ import type {
14
15
  UpdateDmMessageDto,
15
16
  MarkAsReadDto,
16
17
  UsersControllerSearchUsersParams,
17
- V3WorkspacesControllerGetWorkspaces200,
18
- V3WorkspacesControllerGetWorkspaceBySlug200,
19
- V3WorkspacesControllerProvisionWorkspace201,
20
- V3WorkspacesControllerUpdateWorkspace200,
21
- V3WorkspacesControllerDeleteWorkspace200,
22
18
  DmsControllerGetMessagesParams,
19
+ V3WorkspacesControllerGetWorkspacesResult,
20
+ V3WorkspacesControllerGetWorkspaceBySlugResult,
21
+ V3WorkspacesControllerProvisionWorkspaceResult,
22
+ V3WorkspacesControllerUpdateWorkspaceResult,
23
+ V3WorkspacesControllerDeleteWorkspaceResult,
24
+ V3WorkspacesControllerGetWorkspaceMembersResult,
25
+ V3WorkspacesControllerAddWorkspaceMemberResult,
26
+ V3WorkspacesControllerGetWorkspaceMemberResult,
27
+ V3WorkspacesControllerUpdateWorkspaceMemberResult,
28
+ V3WorkspacesControllerDeleteWorkspaceMemberResult,
29
+ ChannelsControllerGetWorkspaceChannelsResult,
30
+ ChannelsControllerCreateChannelResult,
31
+ ChannelsControllerGetChannelResult,
32
+ ChannelsControllerUpdateChannelResult,
33
+ ChannelsControllerDeleteChannelResult,
34
+ ChannelsControllerGetMessagesResult,
35
+ ChannelsControllerCreateMessageResult,
36
+ ChannelsControllerUpdateMessageResult,
37
+ ChannelsControllerDeleteMessageResult,
38
+ ChannelsControllerAddReactionResult,
39
+ ChannelsControllerRemoveReactionResult,
40
+ DmsControllerGetDmsResult,
41
+ DmsControllerCreateDmResult,
42
+ DmsControllerGetDmResult,
43
+ DmsControllerDeleteDmResult,
44
+ DmsControllerGetMessagesResult,
45
+ DmsControllerCreateMessageResult,
46
+ UsersControllerGetMeResult,
47
+ UsersControllerGetUserResult,
48
+ UsersControllerSearchUsersResult,
23
49
  } from './generated/v3-server';
24
50
 
51
+ // --- High-fidelity Response and Entity Interfaces for Excellent DX ---
52
+
53
+ /**
54
+ * Represents a workspace in the Scryme platform (Enterprise M2M API V3).
55
+ */
56
+ export interface V3Workspace {
57
+ /** Unique workspace identifier. */
58
+ id: string;
59
+ /** Display name of the workspace. */
60
+ name: string;
61
+ /** Unique URL-friendly slug representing the workspace. */
62
+ slug: string;
63
+ /** Description of the workspace. */
64
+ description?: string | null;
65
+ /** Icon identifier or URL. */
66
+ icon?: string | null;
67
+ /** Industry categorization of the workspace. */
68
+ industry?: string | null;
69
+ /** Custom branding configuration object. */
70
+ brandingConfig?: any;
71
+ /** ISO timestamp when the workspace was created. */
72
+ createdAt: string;
73
+ /** ISO timestamp when the workspace was last updated. */
74
+ updatedAt?: string;
75
+ }
76
+
77
+ /**
78
+ * Envelope response containing a list of workspaces.
79
+ */
80
+ export interface V3WorkspacesResponse {
81
+ /** Indicates whether the API call was successful. */
82
+ success: boolean;
83
+ /** The payload of the response containing the workspaces. */
84
+ data: {
85
+ /** List of workspaces returned by the API. */
86
+ workspaces: V3Workspace[];
87
+ };
88
+ /** ISO timestamp of when the response was generated. */
89
+ timestamp: string;
90
+ }
91
+
92
+ /**
93
+ * Envelope response containing a single workspace.
94
+ */
95
+ export interface V3WorkspaceResponse {
96
+ /** Indicates whether the API call was successful. */
97
+ success: boolean;
98
+ /** The payload of the response containing the workspace. */
99
+ data: {
100
+ /** The retrieved workspace details. */
101
+ workspace: V3Workspace;
102
+ };
103
+ /** ISO timestamp of when the response was generated. */
104
+ timestamp: string;
105
+ }
106
+
107
+ /**
108
+ * Envelope response containing provisioned workspace details and its default system bot.
109
+ */
110
+ export interface V3ProvisionWorkspaceResponse {
111
+ /** Indicates whether the API call was successful. */
112
+ success: boolean;
113
+ /** The payload containing details of the newly provisioned workspace and bot. */
114
+ data: {
115
+ /** Basic details of the provisioned workspace. */
116
+ workspace: {
117
+ /** Unique workspace identifier. */
118
+ id: string;
119
+ /** Display name of the workspace. */
120
+ name: string;
121
+ /** Unique slug for the workspace. */
122
+ slug: string;
123
+ };
124
+ /** Details of the automatically generated system bot for the workspace. */
125
+ bot: {
126
+ /** Unique identifier of the bot. */
127
+ id: string;
128
+ /** Client ID used for bot authentication. */
129
+ clientId: string;
130
+ /** Client Secret used for bot authentication. */
131
+ clientSecret: string;
132
+ };
133
+ };
134
+ /** ISO timestamp of when the response was generated. */
135
+ timestamp: string;
136
+ }
137
+
138
+ /**
139
+ * Envelope response containing workspace deletion confirmation.
140
+ */
141
+ export interface V3DeleteWorkspaceResponse {
142
+ /** Indicates whether the API call was successful. */
143
+ success: boolean;
144
+ /** The payload indicating deletion status. */
145
+ data: {
146
+ /** True if the workspace was deleted successfully. */
147
+ success: boolean;
148
+ };
149
+ /** ISO timestamp of when the response was generated. */
150
+ timestamp: string;
151
+ }
152
+
153
+ /**
154
+ * Details of a member belonging to a workspace.
155
+ */
156
+ export interface V3WorkspaceMember {
157
+ /** Unique membership identifier. */
158
+ id: string;
159
+ /** Unique workspace identifier. */
160
+ workspaceId: string;
161
+ /** Unique user identifier. */
162
+ userId: string;
163
+ /** Associated department identifier if the member is assigned to one. */
164
+ departmentId?: string | null;
165
+ /** The member's role (e.g., owner, admin, moderator, member, guest). */
166
+ role: string;
167
+ /** Type of member (e.g., regular user, bot, guest). */
168
+ memberType: string;
169
+ /** ISO timestamp of when the member joined the workspace. */
170
+ joinedAt: string;
171
+ /** Member's notification preferences. */
172
+ notificationPreference: string;
173
+ /** Nested basic details of the member's user profile. */
174
+ user: {
175
+ /** Unique user identifier. */
176
+ id: string;
177
+ /** Full name of the user. */
178
+ name: string;
179
+ /** Email address of the user. */
180
+ email: string;
181
+ /** URL to the user's avatar image. */
182
+ avatar?: string | null;
183
+ /** Current status message or indicator of the user. */
184
+ status?: string | null;
185
+ };
186
+ }
187
+
188
+ /**
189
+ * Envelope response containing a list of workspace members.
190
+ */
191
+ export interface V3WorkspaceMembersResponse {
192
+ /** Indicates whether the API call was successful. */
193
+ success: boolean;
194
+ /** The payload containing workspace members. */
195
+ data: {
196
+ /** List of members belonging to the workspace. */
197
+ members: V3WorkspaceMember[];
198
+ };
199
+ /** ISO timestamp of when the response was generated. */
200
+ timestamp: string;
201
+ }
202
+
203
+ /**
204
+ * Envelope response containing a newly added workspace member.
205
+ */
206
+ export interface V3AddWorkspaceMemberResponse {
207
+ /** Indicates whether the API call was successful. */
208
+ success: boolean;
209
+ /** The payload containing the added workspace member. */
210
+ data: {
211
+ /** Details of the added member. */
212
+ member: V3WorkspaceMember;
213
+ };
214
+ /** ISO timestamp of when the response was generated. */
215
+ timestamp: string;
216
+ }
217
+
218
+ /**
219
+ * Envelope response containing details of a specific workspace member.
220
+ */
221
+ export interface V3GetWorkspaceMemberResponse {
222
+ /** Indicates whether the API call was successful. */
223
+ success: boolean;
224
+ /** The payload containing the workspace member details. */
225
+ data: {
226
+ /** Details of the workspace member. */
227
+ member: V3WorkspaceMember;
228
+ };
229
+ /** ISO timestamp of when the response was generated. */
230
+ timestamp: string;
231
+ }
232
+
233
+ /**
234
+ * Envelope response containing the updated workspace member details.
235
+ */
236
+ export interface V3UpdateWorkspaceMemberResponse {
237
+ /** Indicates whether the API call was successful. */
238
+ success: boolean;
239
+ /** The payload containing the updated workspace member. */
240
+ data: {
241
+ /** Details of the updated member. */
242
+ member: V3WorkspaceMember;
243
+ };
244
+ /** ISO timestamp of when the response was generated. */
245
+ timestamp: string;
246
+ }
247
+
248
+ /**
249
+ * Envelope response containing workspace member removal confirmation.
250
+ */
251
+ export interface V3DeleteWorkspaceMemberResponse {
252
+ /** Indicates whether the API call was successful. */
253
+ success: boolean;
254
+ /** The payload indicating deletion status. */
255
+ data: {
256
+ /** True if the workspace member was removed successfully. */
257
+ success: boolean;
258
+ };
259
+ /** ISO timestamp of when the response was generated. */
260
+ timestamp: string;
261
+ }
262
+
263
+ /**
264
+ * Represents a channel in a workspace.
265
+ */
266
+ export interface WorkspaceChannel {
267
+ /** Unique channel identifier. */
268
+ id: string;
269
+ /** Display name of the channel. */
270
+ name: string;
271
+ /** Unique URL-friendly slug representing the channel. */
272
+ slug: string;
273
+ /** Optional icon name or identifier for the channel. */
274
+ icon?: string;
275
+ /** Type of the channel. */
276
+ type: 'public' | 'private';
277
+ /** Optional descriptive text about the channel. */
278
+ description?: string | null;
279
+ /** True if the channel is private and restricted. */
280
+ isPrivate: boolean;
281
+ /** Unique workspace identifier. */
282
+ workspaceId: string;
283
+ /** Optional parent channel or category identifier. */
284
+ parentId?: string | null;
285
+ /** ISO timestamp when the channel was created. */
286
+ createdAt: string;
287
+ /** ISO timestamp when the channel was last updated. */
288
+ updatedAt: string;
289
+ /** Unread message count in this channel for the active user. */
290
+ unreadCount?: number;
291
+ /** Mentions count in this channel for the active user. */
292
+ mentionCount?: number;
293
+ }
294
+
295
+ /**
296
+ * Represents a message sent to a workspace channel or direct message conversation.
297
+ */
298
+ export interface ChannelMessage {
299
+ /** Unique message identifier. */
300
+ id: string;
301
+ /** The text content of the message. */
302
+ content: string;
303
+ /** ISO timestamp when the message was sent. */
304
+ createdAt: string;
305
+ /** ISO timestamp when the message was last updated. */
306
+ updatedAt: string;
307
+ /** The unique channel identifier if sent within a channel. */
308
+ channelId: string;
309
+ /** Unique identifier of the user who sent the message. */
310
+ userId: string;
311
+ /** Basic profile details of the user who sent the message. */
312
+ user: {
313
+ /** Unique user identifier. */
314
+ id: string;
315
+ /** Display name of the user. */
316
+ name: string;
317
+ /** Username of the user. */
318
+ username?: string;
319
+ /** URL to the user's avatar image. */
320
+ avatar?: string | null;
321
+ };
322
+ /** Optional identifier of the message this message is replying to. */
323
+ replyToId?: string | null;
324
+ /** Optional identifier of the root thread message. */
325
+ threadId?: string | null;
326
+ /** Optional attachments uploaded with the message. */
327
+ attachments?: any[];
328
+ /** Reactions associated with this message. */
329
+ reactions?: any[];
330
+ }
331
+
332
+ /**
333
+ * Represents a direct message conversation between users.
334
+ */
335
+ export interface DmConversation {
336
+ /** Unique conversation identifier. */
337
+ id: string;
338
+ /** ISO timestamp when the DM conversation was created. */
339
+ createdAt: string;
340
+ /** ISO timestamp when the DM conversation was last updated. */
341
+ updatedAt: string;
342
+ /** List of participant profiles in this conversation. */
343
+ participants: {
344
+ /** Participant record ID. */
345
+ id: string;
346
+ /** Unique user ID of the participant. */
347
+ userId: string;
348
+ /** Associated conversation ID. */
349
+ conversationId: string;
350
+ /** Profile details of the participant user. */
351
+ user: {
352
+ /** Unique user identifier. */
353
+ id: string;
354
+ /** Display name of the user. */
355
+ name: string;
356
+ /** Username of the user. */
357
+ username?: string;
358
+ /** URL to the user's avatar image. */
359
+ avatar?: string | null;
360
+ };
361
+ }[];
362
+ /** Messages belonging to this DM conversation. */
363
+ messages?: any[];
364
+ /** Metadata count summaries for the conversation. */
365
+ _count?: {
366
+ /** Total number of messages in the conversation. */
367
+ messages: number;
368
+ };
369
+ }
370
+
371
+ /**
372
+ * Public or private profile information of a user.
373
+ */
374
+ export interface UserProfile {
375
+ /** Unique user identifier. */
376
+ id: string;
377
+ /** Display name of the user. */
378
+ name: string;
379
+ /** Unique username of the user. */
380
+ username: string;
381
+ /** Email address of the user (available only on self profile or with appropriate access). */
382
+ email?: string;
383
+ /** URL to the user's avatar image. */
384
+ avatar?: string | null;
385
+ /** Current status message or custom presence text. */
386
+ status?: string | null;
387
+ /** Global application role of the user (e.g., admin, member). */
388
+ role?: string;
389
+ /** ISO timestamp when the user account was created. */
390
+ createdAt?: string;
391
+ }
392
+
393
+ /**
394
+ * Configuration options for initializing the Scryme SDK.
395
+ */
25
396
  export interface ScrymeSDKOptions {
397
+ /**
398
+ * The base URL of the Scryme API server.
399
+ * If not provided, the SDK will automatically resolve it from localStorage or environment variables.
400
+ */
26
401
  baseURL?: string;
402
+ /** OAuth2 Client ID for Machine-to-Machine (M2M) authentication. */
27
403
  clientId?: string;
404
+ /** OAuth2 Client Secret for Machine-to-Machine (M2M) authentication. */
28
405
  clientSecret?: string;
406
+ /** Static Bearer token or pre-fetched session token. */
29
407
  token?: string;
30
408
  }
31
409
 
410
+ /**
411
+ * The primary client SDK class for accessing the Scryme Chat platform APIs.
412
+ * Supports automated OAuth2 Token management and provides clean, type-safe namespaces.
413
+ */
32
414
  export class ScrymeSDK {
415
+ /** The currently cached access token. */
33
416
  private token: string | null = null;
417
+ /** Timestamp in milliseconds indicating when the cached token will expire. */
34
418
  private tokenExpiresAt: number | null = null;
419
+ /** Normalized base URL of the target API server. */
35
420
  public baseURL: string;
421
+ /** OAuth2 Client ID used for client credentials flow. */
36
422
  private clientId?: string;
423
+ /** OAuth2 Client Secret used for client credentials flow. */
37
424
  private clientSecret?: string;
38
425
 
426
+ /**
427
+ * Synchronizes the authentication token to local storage and the global configuration.
428
+ * @param token The token to synchronize.
429
+ */
430
+ private syncToken(token: string | null) {
431
+ if (!token) return;
432
+ setGlobalToken(token);
433
+ if (typeof window !== 'undefined') {
434
+ window.localStorage.setItem('bearer_token', token);
435
+ window.localStorage.setItem('better-auth.session-token', token);
436
+ window.localStorage.setItem('better-auth.session_token', token);
437
+ }
438
+ }
439
+
440
+ /**
441
+ * Constructs a new ScrymeSDK instance.
442
+ * @param options Configuration options for baseURL, tokens, and credentials.
443
+ */
39
444
  constructor(options: ScrymeSDKOptions = {}) {
40
445
  this.clientId = options.clientId;
41
446
  this.clientSecret = options.clientSecret;
42
447
  this.token = options.token || null;
43
448
 
449
+ if (this.token) {
450
+ this.syncToken(this.token);
451
+ }
452
+
44
453
  let url = options.baseURL || '';
45
454
  if (!url && typeof window !== 'undefined') {
46
455
  url = window.localStorage.getItem('CUSTOM_API_URL') || '';
@@ -53,7 +462,9 @@ export class ScrymeSDK {
53
462
  const env = g.process?.env || g.__env__ || {};
54
463
  const isProd =
55
464
  env.NODE_ENV === 'production' ||
56
- (typeof window !== 'undefined' && window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1');
465
+ (typeof window !== 'undefined' &&
466
+ window.location.hostname !== 'localhost' &&
467
+ window.location.hostname !== '127.0.0.1');
57
468
 
58
469
  url =
59
470
  env.API_URL ||
@@ -65,7 +476,9 @@ export class ScrymeSDK {
65
476
  }
66
477
 
67
478
  /**
68
- * Automatically retrieves or refreshes the M2M OAuth2 Token using client_credentials
479
+ * Automatically retrieves a cached token, or fetches a new one via M2M OAuth2 Client Credentials
480
+ * if a clientId and clientSecret are configured.
481
+ * @returns A promise resolving to the token string, or null if unauthenticated.
69
482
  */
70
483
  public async getOrFetchToken(): Promise<string | null> {
71
484
  // If we already have a token and it is not expired, return it
@@ -89,6 +502,7 @@ export class ScrymeSDK {
89
502
 
90
503
  if (response.data?.success && response.data?.data?.access_token) {
91
504
  this.token = response.data.data.access_token;
505
+ this.syncToken(this.token);
92
506
  if (response.data.data.expires_in) {
93
507
  // Expire 10 seconds early as a safety buffer
94
508
  this.tokenExpiresAt = Date.now() + (response.data.data.expires_in - 10) * 1000;
@@ -99,6 +513,7 @@ export class ScrymeSDK {
99
513
  } else if (response.data?.access_token) {
100
514
  // Fallback in case response is not wrapped
101
515
  this.token = response.data.access_token;
516
+ this.syncToken(this.token);
102
517
  if (response.data.expires_in) {
103
518
  this.tokenExpiresAt = Date.now() + (response.data.expires_in - 10) * 1000;
104
519
  } else {
@@ -116,7 +531,8 @@ export class ScrymeSDK {
116
531
  }
117
532
 
118
533
  /**
119
- * Gets the axios request config containing authorization and base url
534
+ * Generates the default request configuration containing the authorization headers and baseURL.
535
+ * @returns Request configuration object.
120
536
  */
121
537
  private async getRequestConfig(): Promise<any> {
122
538
  const token = await this.getOrFetchToken();
@@ -173,125 +589,414 @@ export class ScrymeSDK {
173
589
 
174
590
  // --- High-level nested namespace chains for excellent DX ---
175
591
 
592
+ /**
593
+ * Operations for managing workspaces, including creation, updating, retrieval,
594
+ * members, and channels.
595
+ */
176
596
  public get workspace() {
177
597
  return {
178
- list: async (options?: AxiosRequestConfig): Promise<V3WorkspacesControllerGetWorkspaces200> => {
179
- return this.raw.v3WorkspacesControllerGetWorkspaces(options);
598
+ /**
599
+ * Lists all workspaces in the authenticated organization context.
600
+ * @param options Optional request config override.
601
+ * @returns List of workspaces returned exactly from the endpoint.
602
+ */
603
+ list: async (options?: AxiosRequestConfig): Promise<V3WorkspacesResponse> => {
604
+ return this.raw.v3WorkspacesControllerGetWorkspaces(options) as any;
180
605
  },
181
- get: async (slug: string, options?: AxiosRequestConfig): Promise<V3WorkspacesControllerGetWorkspaceBySlug200> => {
182
- return this.raw.v3WorkspacesControllerGetWorkspaceBySlug(slug, options);
606
+ /**
607
+ * Retrieves detailed information of a specific workspace by its slug.
608
+ * @param slug The unique workspace slug identifier.
609
+ * @param options Optional request config override.
610
+ * @returns Workspace details returned exactly from the endpoint.
611
+ */
612
+ get: async (slug: string, options?: AxiosRequestConfig): Promise<V3WorkspaceResponse> => {
613
+ return this.raw.v3WorkspacesControllerGetWorkspaceBySlug(slug, options) as any;
183
614
  },
184
- create: async (data: V3ProvisionWorkspaceDto, options?: AxiosRequestConfig): Promise<V3WorkspacesControllerProvisionWorkspace201> => {
185
- return this.raw.v3WorkspacesControllerProvisionWorkspace(data, options);
615
+ /**
616
+ * Provisions a new workspace inside the organization.
617
+ * @param data Workspace creation and configuration data.
618
+ * @param options Optional request config override.
619
+ * @returns Provisioned workspace and bot configuration exactly from the endpoint.
620
+ */
621
+ create: async (
622
+ data: V3ProvisionWorkspaceDto,
623
+ options?: AxiosRequestConfig
624
+ ): Promise<V3ProvisionWorkspaceResponse> => {
625
+ return this.raw.v3WorkspacesControllerProvisionWorkspace(data, options) as any;
186
626
  },
187
- update: async (slug: string, data: V3UpdateWorkspaceDto, options?: AxiosRequestConfig): Promise<V3WorkspacesControllerUpdateWorkspace200> => {
188
- return this.raw.v3WorkspacesControllerUpdateWorkspace(slug, data, options);
627
+ /**
628
+ * Updates the configurations and metadata of an existing workspace.
629
+ * @param slug The unique workspace slug identifier.
630
+ * @param data Fields to update.
631
+ * @param options Optional request config override.
632
+ * @returns The updated workspace details exactly from the endpoint.
633
+ */
634
+ update: async (
635
+ slug: string,
636
+ data: V3UpdateWorkspaceDto,
637
+ options?: AxiosRequestConfig
638
+ ): Promise<V3WorkspaceResponse> => {
639
+ return this.raw.v3WorkspacesControllerUpdateWorkspace(slug, data, options) as any;
189
640
  },
190
- delete: async (slug: string, options?: AxiosRequestConfig): Promise<V3WorkspacesControllerDeleteWorkspace200> => {
191
- return this.raw.v3WorkspacesControllerDeleteWorkspace(slug, options);
641
+ /**
642
+ * Permanently deletes a specific workspace by its slug.
643
+ * @param slug The unique workspace slug identifier.
644
+ * @param options Optional request config override.
645
+ * @returns Deletion status response exactly from the endpoint.
646
+ */
647
+ delete: async (slug: string, options?: AxiosRequestConfig): Promise<V3DeleteWorkspaceResponse> => {
648
+ return this.raw.v3WorkspacesControllerDeleteWorkspace(slug, options) as any;
192
649
  },
650
+ /**
651
+ * Operations for managing workspace members, including listing, adding, role updates, and removal.
652
+ */
193
653
  members: {
194
- list: async (slug: string, options?: AxiosRequestConfig): Promise<any> => {
195
- return this.raw.v3WorkspacesControllerGetWorkspaceMembers(slug, options);
654
+ /**
655
+ * Lists all members currently in a workspace.
656
+ * @param slug The unique workspace slug identifier.
657
+ * @param options Optional request config override.
658
+ * @returns List of workspace members exactly from the endpoint.
659
+ */
660
+ list: async (slug: string, options?: AxiosRequestConfig): Promise<V3WorkspaceMembersResponse> => {
661
+ return this.raw.v3WorkspacesControllerGetWorkspaceMembers(slug, options) as any;
196
662
  },
197
- add: async (slug: string, data: V3AddMemberDto, options?: AxiosRequestConfig): Promise<any> => {
198
- return this.raw.v3WorkspacesControllerAddWorkspaceMember(slug, data, options);
663
+ /**
664
+ * Adds a new member to the workspace.
665
+ * @param slug The unique workspace slug identifier.
666
+ * @param data Input DTO containing the user's email and role.
667
+ * @param options Optional request config override.
668
+ * @returns Newly added member details exactly from the endpoint.
669
+ */
670
+ add: async (
671
+ slug: string,
672
+ data: V3AddMemberDto,
673
+ options?: AxiosRequestConfig
674
+ ): Promise<V3AddWorkspaceMemberResponse> => {
675
+ return this.raw.v3WorkspacesControllerAddWorkspaceMember(slug, data, options) as any;
199
676
  },
200
- get: async (slug: string, memberId: string, options?: AxiosRequestConfig): Promise<any> => {
201
- return this.raw.v3WorkspacesControllerGetWorkspaceMember(slug, memberId, options);
677
+ /**
678
+ * Retrieves membership details of a specific member in a workspace.
679
+ * @param slug The unique workspace slug identifier.
680
+ * @param memberId Unique ID of the workspace member (user ID).
681
+ * @param options Optional request config override.
682
+ * @returns Workspace member details exactly from the endpoint.
683
+ */
684
+ get: async (
685
+ slug: string,
686
+ memberId: string,
687
+ options?: AxiosRequestConfig
688
+ ): Promise<V3GetWorkspaceMemberResponse> => {
689
+ return this.raw.v3WorkspacesControllerGetWorkspaceMember(slug, memberId, options) as any;
202
690
  },
203
- update: async (slug: string, memberId: string, data: V3UpdateMemberRoleDto, options?: AxiosRequestConfig): Promise<any> => {
204
- return this.raw.v3WorkspacesControllerUpdateWorkspaceMember(slug, memberId, data, options);
691
+ /**
692
+ * Updates the role or configuration of a workspace member.
693
+ * @param slug The unique workspace slug identifier.
694
+ * @param memberId Unique ID of the workspace member (user ID).
695
+ * @param data Update details containing the target role.
696
+ * @param options Optional request config override.
697
+ * @returns The updated workspace member details exactly from the endpoint.
698
+ */
699
+ update: async (
700
+ slug: string,
701
+ memberId: string,
702
+ data: V3UpdateMemberRoleDto,
703
+ options?: AxiosRequestConfig
704
+ ): Promise<V3UpdateWorkspaceMemberResponse> => {
705
+ return this.raw.v3WorkspacesControllerUpdateWorkspaceMember(slug, memberId, data, options) as any;
205
706
  },
206
- delete: async (slug: string, memberId: string, options?: AxiosRequestConfig): Promise<any> => {
207
- return this.raw.v3WorkspacesControllerDeleteWorkspaceMember(slug, memberId, options);
707
+ /**
708
+ * Removes a member from the workspace.
709
+ * @param slug The unique workspace slug identifier.
710
+ * @param memberId Unique ID of the workspace member (user ID).
711
+ * @param options Optional request config override.
712
+ * @returns Workspace member deletion confirmation exactly from the endpoint.
713
+ */
714
+ delete: async (
715
+ slug: string,
716
+ memberId: string,
717
+ options?: AxiosRequestConfig
718
+ ): Promise<V3DeleteWorkspaceMemberResponse> => {
719
+ return this.raw.v3WorkspacesControllerDeleteWorkspaceMember(slug, memberId, options) as any;
208
720
  },
209
721
  },
722
+ /**
723
+ * Operations for listing and creating channels inside a workspace.
724
+ */
210
725
  channels: {
211
- list: async (slug: string, options?: AxiosRequestConfig): Promise<any> => {
212
- return this.raw.channelsControllerGetWorkspaceChannels(slug, options);
726
+ /**
727
+ * Lists all public channels (and private channels the user has access to) in a workspace.
728
+ * @param slug The unique workspace slug identifier.
729
+ * @param options Optional request config override.
730
+ * @returns List of channels returned exactly from the endpoint.
731
+ */
732
+ list: async (slug: string, options?: AxiosRequestConfig): Promise<WorkspaceChannel[]> => {
733
+ return this.raw.channelsControllerGetWorkspaceChannels(slug, options) as any;
213
734
  },
214
- create: async (slug: string, data: CreateWorkspaceChannelDto, options?: AxiosRequestConfig): Promise<any> => {
215
- return this.raw.channelsControllerCreateChannel(slug, data, options);
735
+ /**
736
+ * Creates a new channel within a workspace.
737
+ * @param slug The unique workspace slug identifier.
738
+ * @param data Configuration DTO for the new channel.
739
+ * @param options Optional request config override.
740
+ * @returns Details of the created channel exactly from the endpoint.
741
+ */
742
+ create: async (
743
+ slug: string,
744
+ data: CreateWorkspaceChannelDto,
745
+ options?: AxiosRequestConfig
746
+ ): Promise<WorkspaceChannel> => {
747
+ return this.raw.channelsControllerCreateChannel(slug, data, options) as any;
216
748
  },
217
749
  },
218
750
  };
219
751
  }
220
752
 
753
+ /**
754
+ * Operations for managing specific channels and channel message actions.
755
+ */
221
756
  public get channel() {
222
757
  return {
223
- get: async (slug: string, channelId: string, options?: AxiosRequestConfig): Promise<any> => {
224
- return this.raw.channelsControllerGetChannel(slug, channelId, options);
758
+ /**
759
+ * Retrieves detailed information of a specific channel.
760
+ * @param slug The unique workspace slug identifier.
761
+ * @param channelId Unique identifier of the channel.
762
+ * @param options Optional request config override.
763
+ * @returns Channel details returned exactly from the endpoint.
764
+ */
765
+ get: async (slug: string, channelId: string, options?: AxiosRequestConfig): Promise<WorkspaceChannel> => {
766
+ return this.raw.channelsControllerGetChannel(slug, channelId, options) as any;
225
767
  },
226
- update: async (slug: string, channelId: string, data: UpdateWorkspaceChannelDto, options?: AxiosRequestConfig): Promise<any> => {
227
- return this.raw.channelsControllerUpdateChannel(slug, channelId, data, options);
768
+ /**
769
+ * Updates configuration, description, icon or status of an existing channel.
770
+ * @param slug The unique workspace slug identifier.
771
+ * @param channelId Unique identifier of the channel.
772
+ * @param data Configuration options to update.
773
+ * @param options Optional request config override.
774
+ * @returns The updated channel details exactly from the endpoint.
775
+ */
776
+ update: async (
777
+ slug: string,
778
+ channelId: string,
779
+ data: UpdateWorkspaceChannelDto,
780
+ options?: AxiosRequestConfig
781
+ ): Promise<WorkspaceChannel> => {
782
+ return this.raw.channelsControllerUpdateChannel(slug, channelId, data, options) as any;
228
783
  },
229
- delete: async (slug: string, channelId: string, options?: AxiosRequestConfig): Promise<any> => {
230
- return this.raw.channelsControllerDeleteChannel(slug, channelId, options);
784
+ /**
785
+ * Permanently deletes a channel from a workspace.
786
+ * @param slug The unique workspace slug identifier.
787
+ * @param channelId Unique identifier of the channel to delete.
788
+ * @param options Optional request config override.
789
+ * @returns Success status indicating that the channel was deleted exactly from the endpoint.
790
+ */
791
+ delete: async (slug: string, channelId: string, options?: AxiosRequestConfig): Promise<{ success: boolean }> => {
792
+ return this.raw.channelsControllerDeleteChannel(slug, channelId, options) as any;
231
793
  },
794
+ /**
795
+ * Sub-namespace for managing messages inside a channel.
796
+ */
232
797
  message: {
233
- list: async (channelId: string, params?: ChannelsControllerGetMessagesParams, options?: AxiosRequestConfig): Promise<any> => {
234
- return this.raw.channelsControllerGetMessages(channelId, params, options);
798
+ /**
799
+ * Lists messages in a channel with cursor pagination support.
800
+ * @param channelId Unique identifier of the channel.
801
+ * @param params Query parameters for limiting, sorting, or pagination cursors.
802
+ * @param options Optional request config override.
803
+ * @returns Object containing the messages array and next pagination cursor exactly from the endpoint.
804
+ */
805
+ list: async (
806
+ channelId: string,
807
+ params?: ChannelsControllerGetMessagesParams,
808
+ options?: AxiosRequestConfig
809
+ ): Promise<{ messages: ChannelMessage[]; nextCursor?: string }> => {
810
+ return this.raw.channelsControllerGetMessages(channelId, params, options) as any;
235
811
  },
236
- create: async (channelId: string, options?: AxiosRequestConfig): Promise<any> => {
237
- return this.raw.channelsControllerCreateMessage(channelId, options);
812
+ /**
813
+ * Sends a new message to a channel.
814
+ * @param channelId Unique identifier of the target channel.
815
+ * @param options Optional request config override. Note that standard message data (like text content) can be passed inside options.data.
816
+ * @returns The created message exactly from the endpoint.
817
+ */
818
+ create: async (channelId: string, options?: AxiosRequestConfig): Promise<ChannelMessage> => {
819
+ return this.raw.channelsControllerCreateMessage(channelId, options) as any;
238
820
  },
239
821
  },
240
822
  };
241
823
  }
242
824
 
825
+ /**
826
+ * Operations for modifying, reacting to, or deleting existing channel messages.
827
+ */
243
828
  public get message() {
244
829
  return {
245
- update: async (channelId: string, messageId: string, data: ChannelsControllerUpdateMessageBody, options?: AxiosRequestConfig): Promise<any> => {
246
- return this.raw.channelsControllerUpdateMessage(channelId, messageId, data, options);
830
+ /**
831
+ * Updates the content of a previously sent message.
832
+ * @param channelId Unique identifier of the channel containing the message.
833
+ * @param messageId Unique identifier of the message to update.
834
+ * @param data The new content payload.
835
+ * @param options Optional request config override.
836
+ * @returns The updated message details exactly from the endpoint.
837
+ */
838
+ update: async (
839
+ channelId: string,
840
+ messageId: string,
841
+ data: ChannelsControllerUpdateMessageBody,
842
+ options?: AxiosRequestConfig
843
+ ): Promise<ChannelMessage> => {
844
+ return this.raw.channelsControllerUpdateMessage(channelId, messageId, data, options) as any;
247
845
  },
248
- delete: async (channelId: string, messageId: string, options?: AxiosRequestConfig): Promise<any> => {
249
- return this.raw.channelsControllerDeleteMessage(channelId, messageId, options);
846
+ /**
847
+ * Permanently deletes a message.
848
+ * @param channelId Unique identifier of the channel containing the message.
849
+ * @param messageId Unique identifier of the message to delete.
850
+ * @param options Optional request config override.
851
+ * @returns Success status indicating that the message was deleted exactly from the endpoint.
852
+ */
853
+ delete: async (
854
+ channelId: string,
855
+ messageId: string,
856
+ options?: AxiosRequestConfig
857
+ ): Promise<{ success: boolean }> => {
858
+ return this.raw.channelsControllerDeleteMessage(channelId, messageId, options) as any;
250
859
  },
251
- addReaction: async (channelId: string, messageId: string, data: ChannelsControllerAddReactionBody, options?: AxiosRequestConfig): Promise<any> => {
252
- return this.raw.channelsControllerAddReaction(channelId, messageId, data, options);
860
+ /**
861
+ * Adds a reaction (emoji) to a message.
862
+ * @param channelId Unique identifier of the channel containing the message.
863
+ * @param messageId Unique identifier of the message.
864
+ * @param data Object containing the target emoji character.
865
+ * @param options Optional request config override.
866
+ * @returns The reaction response returned exactly from the endpoint.
867
+ */
868
+ addReaction: async (
869
+ channelId: string,
870
+ messageId: string,
871
+ data: ChannelsControllerAddReactionBody,
872
+ options?: AxiosRequestConfig
873
+ ): Promise<any> => {
874
+ return this.raw.channelsControllerAddReaction(channelId, messageId, data, options) as any;
253
875
  },
254
- removeReaction: async (channelId: string, messageId: string, emoji: string, options?: AxiosRequestConfig): Promise<any> => {
255
- return this.raw.channelsControllerRemoveReaction(channelId, messageId, emoji, options);
876
+ /**
877
+ * Removes a reaction (emoji) from a message.
878
+ * @param channelId Unique identifier of the channel containing the message.
879
+ * @param messageId Unique identifier of the message.
880
+ * @param emoji The emoji character to remove.
881
+ * @param options Optional request config override.
882
+ * @returns The reaction removal response returned exactly from the endpoint.
883
+ */
884
+ removeReaction: async (
885
+ channelId: string,
886
+ messageId: string,
887
+ emoji: string,
888
+ options?: AxiosRequestConfig
889
+ ): Promise<any> => {
890
+ return this.raw.channelsControllerRemoveReaction(channelId, messageId, emoji, options) as any;
256
891
  },
257
892
  };
258
893
  }
259
894
 
895
+ /**
896
+ * Operations for managing direct messages (DMs) and direct message conversations.
897
+ */
260
898
  public get dm() {
261
899
  return {
262
- list: async (options?: AxiosRequestConfig): Promise<any> => {
263
- return this.raw.dmsControllerGetDms(options);
900
+ /**
901
+ * Lists all active direct message conversations for the authenticated user.
902
+ * @param options Optional request config override.
903
+ * @returns List of active DM conversations returned exactly from the endpoint.
904
+ */
905
+ list: async (options?: AxiosRequestConfig): Promise<DmConversation[]> => {
906
+ return this.raw.dmsControllerGetDms(options) as any;
264
907
  },
265
- create: async (data: CreateDmDto, options?: AxiosRequestConfig): Promise<any> => {
266
- return this.raw.dmsControllerCreateDm(data, options);
908
+ /**
909
+ * Creates/initiates a direct message conversation with specified users.
910
+ * @param data Create direct message details containing target participant IDs.
911
+ * @param options Optional request config override.
912
+ * @returns Details of the created DM conversation exactly from the endpoint.
913
+ */
914
+ create: async (data: CreateDmDto, options?: AxiosRequestConfig): Promise<DmConversation> => {
915
+ return this.raw.dmsControllerCreateDm(data, options) as any;
267
916
  },
268
- get: async (dmId: string, options?: AxiosRequestConfig): Promise<any> => {
269
- return this.raw.dmsControllerGetDm(dmId, options);
917
+ /**
918
+ * Retrieves details of a specific direct message conversation.
919
+ * @param dmId Unique identifier of the direct message conversation.
920
+ * @param options Optional request config override.
921
+ * @returns Detailed direct message conversation object exactly from the endpoint.
922
+ */
923
+ get: async (dmId: string, options?: AxiosRequestConfig): Promise<DmConversation> => {
924
+ return this.raw.dmsControllerGetDm(dmId, options) as any;
270
925
  },
271
- delete: async (dmId: string, options?: AxiosRequestConfig): Promise<any> => {
272
- return this.raw.dmsControllerDeleteDm(dmId, options);
926
+ /**
927
+ * Deletes/closes an active direct message conversation.
928
+ * @param dmId Unique identifier of the direct message conversation to close.
929
+ * @param options Optional request config override.
930
+ * @returns Success status indicating that the DM conversation was deleted exactly from the endpoint.
931
+ */
932
+ delete: async (dmId: string, options?: AxiosRequestConfig): Promise<{ success: boolean }> => {
933
+ return this.raw.dmsControllerDeleteDm(dmId, options) as any;
273
934
  },
935
+ /**
936
+ * Sub-namespace for managing direct messages in a specific DM conversation.
937
+ */
274
938
  message: {
275
- list: async (dmId: string, params?: DmsControllerGetMessagesParams, options?: AxiosRequestConfig): Promise<any> => {
276
- return this.raw.dmsControllerGetMessages(dmId, params, options);
939
+ /**
940
+ * Lists messages in a direct message conversation with cursor pagination.
941
+ * @param dmId Unique identifier of the direct message conversation.
942
+ * @param params Query parameters for pagination limits, cursors or search filters.
943
+ * @param options Optional request config override.
944
+ * @returns List of direct messages and next pagination cursor exactly from the endpoint.
945
+ */
946
+ list: async (
947
+ dmId: string,
948
+ params?: DmsControllerGetMessagesParams,
949
+ options?: AxiosRequestConfig
950
+ ): Promise<{ messages: ChannelMessage[]; nextCursor?: string }> => {
951
+ return this.raw.dmsControllerGetMessages(dmId, params, options) as any;
277
952
  },
278
- create: async (dmId: string, options?: AxiosRequestConfig): Promise<any> => {
279
- return this.raw.dmsControllerCreateMessage(dmId, options);
953
+ /**
954
+ * Sends a new message in a direct message conversation.
955
+ * @param dmId Unique identifier of the direct message conversation.
956
+ * @param options Optional request config override. Note that content/attachments can be passed inside options.data.
957
+ * @returns The sent message exactly from the endpoint.
958
+ */
959
+ create: async (dmId: string, options?: AxiosRequestConfig): Promise<ChannelMessage> => {
960
+ return this.raw.dmsControllerCreateMessage(dmId, options) as any;
280
961
  },
281
962
  },
282
963
  };
283
964
  }
284
965
 
966
+ /**
967
+ * Operations for retrieving information about the current user or other user profiles,
968
+ * as well as performing user searches.
969
+ */
285
970
  public get user() {
286
971
  return {
287
- me: async (options?: AxiosRequestConfig): Promise<any> => {
288
- return this.raw.usersControllerGetMe(options);
972
+ /**
973
+ * Retrieves the profile details of the currently authenticated user.
974
+ * @param options Optional request config override.
975
+ * @returns The active user's profile returned exactly from the endpoint.
976
+ */
977
+ me: async (options?: AxiosRequestConfig): Promise<UserProfile> => {
978
+ return this.raw.usersControllerGetMe(options) as any;
289
979
  },
290
- get: async (userId: string, options?: AxiosRequestConfig): Promise<any> => {
291
- return this.raw.usersControllerGetUser(userId, options);
980
+ /**
981
+ * Retrieves the public profile of a user by their user ID.
982
+ * @param userId Unique identifier of the target user.
983
+ * @param options Optional request config override.
984
+ * @returns Public user profile returned exactly from the endpoint.
985
+ */
986
+ get: async (userId: string, options?: AxiosRequestConfig): Promise<UserProfile> => {
987
+ return this.raw.usersControllerGetUser(userId, options) as any;
292
988
  },
293
- search: async (params: UsersControllerSearchUsersParams, options?: AxiosRequestConfig): Promise<any> => {
294
- return this.raw.usersControllerSearchUsers(params, options);
989
+ /**
990
+ * Searches the organization or workspace directory for user profiles matching specific queries.
991
+ * @param params Object containing search filters and query string parameters.
992
+ * @param options Optional request config override.
993
+ * @returns List of matching user profiles returned exactly from the endpoint.
994
+ */
995
+ search: async (
996
+ params: UsersControllerSearchUsersParams,
997
+ options?: AxiosRequestConfig
998
+ ): Promise<UserProfile[]> => {
999
+ return this.raw.usersControllerSearchUsers(params, options) as any;
295
1000
  },
296
1001
  };
297
1002
  }