@doist/comms-sdk 0.1.0-alpha.1 → 0.2.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.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/clients/add-comment-helper.js +18 -2
  3. package/dist/cjs/clients/base-client.js +11 -5
  4. package/dist/cjs/clients/channels-client.js +142 -14
  5. package/dist/cjs/clients/comments-client.js +99 -14
  6. package/dist/cjs/clients/conversation-messages-client.js +91 -9
  7. package/dist/cjs/clients/conversations-client.js +166 -15
  8. package/dist/cjs/clients/groups-client.js +98 -5
  9. package/dist/cjs/clients/inbox-client.js +102 -16
  10. package/dist/cjs/clients/reactions-client.js +40 -2
  11. package/dist/cjs/clients/search-client.js +50 -0
  12. package/dist/cjs/clients/threads-client.js +238 -24
  13. package/dist/cjs/clients/users-client.js +138 -11
  14. package/dist/cjs/clients/workspace-users-client.js +110 -10
  15. package/dist/cjs/clients/workspaces-client.js +89 -8
  16. package/dist/cjs/comms-api.js +1 -0
  17. package/dist/cjs/consts/endpoints.js +8 -3
  18. package/dist/cjs/testUtils/test-defaults.js +3 -1
  19. package/dist/cjs/types/api-version.js +8 -0
  20. package/dist/cjs/types/entities.js +119 -98
  21. package/dist/cjs/types/index.js +1 -0
  22. package/dist/cjs/types/requests.js +0 -1
  23. package/dist/cjs/utils/url-helpers.js +3 -1
  24. package/dist/esm/clients/add-comment-helper.js +18 -2
  25. package/dist/esm/clients/base-client.js +11 -5
  26. package/dist/esm/clients/channels-client.js +143 -15
  27. package/dist/esm/clients/comments-client.js +100 -15
  28. package/dist/esm/clients/conversation-messages-client.js +92 -10
  29. package/dist/esm/clients/conversations-client.js +167 -16
  30. package/dist/esm/clients/groups-client.js +98 -5
  31. package/dist/esm/clients/inbox-client.js +102 -16
  32. package/dist/esm/clients/reactions-client.js +40 -2
  33. package/dist/esm/clients/search-client.js +50 -0
  34. package/dist/esm/clients/threads-client.js +239 -25
  35. package/dist/esm/clients/users-client.js +138 -11
  36. package/dist/esm/clients/workspace-users-client.js +110 -10
  37. package/dist/esm/clients/workspaces-client.js +90 -9
  38. package/dist/esm/comms-api.js +1 -0
  39. package/dist/esm/consts/endpoints.js +8 -3
  40. package/dist/esm/testUtils/test-defaults.js +2 -0
  41. package/dist/esm/types/api-version.js +5 -0
  42. package/dist/esm/types/entities.js +111 -97
  43. package/dist/esm/types/index.js +1 -0
  44. package/dist/esm/types/requests.js +0 -1
  45. package/dist/esm/utils/url-helpers.js +3 -1
  46. package/dist/types/clients/add-comment-helper.d.ts +20 -1
  47. package/dist/types/clients/base-client.d.ts +10 -0
  48. package/dist/types/clients/channels-client.d.ts +126 -6
  49. package/dist/types/clients/comments-client.d.ts +77 -6
  50. package/dist/types/clients/conversation-messages-client.d.ts +79 -5
  51. package/dist/types/clients/conversations-client.d.ts +146 -3
  52. package/dist/types/clients/groups-client.d.ts +98 -5
  53. package/dist/types/clients/inbox-client.d.ts +463 -5
  54. package/dist/types/clients/reactions-client.d.ts +40 -2
  55. package/dist/types/clients/search-client.d.ts +50 -0
  56. package/dist/types/clients/threads-client.d.ts +204 -8
  57. package/dist/types/clients/users-client.d.ts +138 -11
  58. package/dist/types/clients/workspace-users-client.d.ts +110 -10
  59. package/dist/types/clients/workspaces-client.d.ts +82 -7
  60. package/dist/types/comms-api.d.ts +3 -0
  61. package/dist/types/consts/endpoints.d.ts +6 -1
  62. package/dist/types/testUtils/test-defaults.d.ts +1 -0
  63. package/dist/types/types/api-version.d.ts +6 -0
  64. package/dist/types/types/entities.d.ts +1654 -126
  65. package/dist/types/types/index.d.ts +1 -0
  66. package/dist/types/types/requests.d.ts +2 -21
  67. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { ENDPOINT_COMMENTS } from '../consts/endpoints.js';
3
3
  import { request } from '../transport/http-client.js';
4
- import { CommentSchema, StatusOkSchema } from '../types/entities.js';
4
+ import { CommentSchema, createCommentSchema, StatusOkSchema, } from '../types/entities.js';
5
5
  import { addCommentRequest } from './add-comment-helper.js';
6
6
  import { BaseClient } from './base-client.js';
7
7
  export const CommentListSchema = z.array(CommentSchema);
@@ -10,16 +10,46 @@ export const CommentListSchema = z.array(CommentSchema);
10
10
  * on `createComment` when the caller doesn't supply one.
11
11
  */
12
12
  export class CommentsClient extends BaseClient {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.linkBaseUrl = this.getLinkBaseUrl();
16
+ // Reuse the shared singletons when no custom base is configured.
17
+ this.commentSchema = this.linkBaseUrl
18
+ ? createCommentSchema(this.linkBaseUrl)
19
+ : CommentSchema;
20
+ this.commentListSchema = this.linkBaseUrl
21
+ ? z.array(this.commentSchema)
22
+ : CommentListSchema;
23
+ // `getone` wraps the comment in `{ comment: ... }`; built once per client.
24
+ this.wrappedCommentSchema = z
25
+ .object({ comment: this.commentSchema })
26
+ .transform((data) => data.comment);
27
+ }
13
28
  /**
14
- * Lists comments in a thread. `newerThan` / `olderThan` (`Date`) are
29
+ * Gets all comments for a thread. `newerThan` / `olderThan` (`Date`) are
15
30
  * converted to `newer_than_ts` / `older_than_ts` epoch seconds on the
16
31
  * wire.
32
+ *
33
+ * @param args - The arguments for getting comments.
34
+ * @param args.threadId - The thread ID.
35
+ * @param args.newerThan - Optional date to get comments newer than.
36
+ * @param args.olderThan - Optional date to get comments older than.
37
+ * @param args.limit - Optional limit on number of comments returned.
38
+ * @returns An array of comment objects.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const comments = await api.comments.getComments({
43
+ * threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
44
+ * newerThan: new Date('2024-01-01'),
45
+ * })
46
+ * comments.forEach(c => console.log(c.content))
47
+ * ```
17
48
  */
18
49
  getComments(args) {
19
50
  const params = { threadId: args.threadId };
20
- const newerThan = args.newerThan ?? args.from;
21
- if (newerThan)
22
- params.newerThanTs = Math.floor(newerThan.getTime() / 1000);
51
+ if (args.newerThan)
52
+ params.newerThanTs = Math.floor(args.newerThan.getTime() / 1000);
23
53
  if (args.olderThan)
24
54
  params.olderThanTs = Math.floor(args.olderThan.getTime() / 1000);
25
55
  if (args.limit)
@@ -31,11 +61,15 @@ export class CommentsClient extends BaseClient {
31
61
  apiToken: this.apiToken,
32
62
  payload: params,
33
63
  customFetch: this.customFetch,
34
- }).then((response) => CommentListSchema.parse(response.data));
64
+ }).then((response) => this.commentListSchema.parse(response.data));
35
65
  }
36
- /** Fetches a single comment by ID. The API wraps it in `{comment: ...}`. */
66
+ /**
67
+ * Gets a single comment object by id. The API wraps it in `{comment: ...}`.
68
+ *
69
+ * @param id - The comment ID.
70
+ * @returns The comment object.
71
+ */
37
72
  getComment(id) {
38
- const wrappedSchema = z.object({ comment: CommentSchema }).transform((data) => data.comment);
39
73
  return request({
40
74
  httpMethod: 'GET',
41
75
  baseUri: this.getBaseUri(),
@@ -43,15 +77,51 @@ export class CommentsClient extends BaseClient {
43
77
  apiToken: this.apiToken,
44
78
  payload: { id },
45
79
  customFetch: this.customFetch,
46
- }).then((response) => wrappedSchema.parse(response.data));
80
+ }).then((response) => this.wrappedCommentSchema.parse(response.data));
47
81
  }
48
82
  /**
49
- * Creates a new comment. `id` is auto-generated if not supplied.
83
+ * Creates a new comment on a thread. `id` is auto-generated if not supplied.
84
+ *
85
+ * @param args - The arguments for creating a comment.
86
+ * @param args.threadId - The thread ID.
87
+ * @param args.content - The comment content.
88
+ * @param args.recipients - Optional array of user IDs to notify directly.
89
+ * @param args.groups - Optional array of custom group IDs to notify.
90
+ * @param args.directMentions - Optional array of user IDs that were @-mentioned in
91
+ * `content`.
92
+ * @param args.notifyAudience - Optional broader audience to notify in addition to
93
+ * `recipients` and `groups`. `'channel'` notifies everyone in the channel;
94
+ * `'thread'` notifies everyone who has interacted with the thread.
95
+ * @param args.attachments - Optional array of {@link Attachment} objects.
96
+ * @returns The created comment object.
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * // Notify everyone who has interacted with the thread, plus two extra users.
101
+ * const comment = await api.comments.createComment({
102
+ * threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
103
+ * content: 'Great idea! Let\'s proceed.',
104
+ * notifyAudience: 'thread',
105
+ * recipients: [101, 202],
106
+ * })
107
+ * ```
50
108
  */
51
109
  createComment(args) {
52
- return addCommentRequest({ baseUri: this.getBaseUri(), apiToken: this.apiToken, customFetch: this.customFetch }, args);
110
+ return addCommentRequest({
111
+ baseUri: this.getBaseUri(),
112
+ apiToken: this.apiToken,
113
+ customFetch: this.customFetch,
114
+ schema: this.commentSchema,
115
+ }, args);
53
116
  }
54
- /** Updates a comment. */
117
+ /**
118
+ * Updates a comment's properties.
119
+ *
120
+ * @param args - The arguments for updating a comment.
121
+ * @param args.id - The comment ID.
122
+ * @param args.content - The new comment content.
123
+ * @returns The updated comment object.
124
+ */
55
125
  updateComment(args) {
56
126
  return request({
57
127
  httpMethod: 'POST',
@@ -60,9 +130,13 @@ export class CommentsClient extends BaseClient {
60
130
  apiToken: this.apiToken,
61
131
  payload: { ...args },
62
132
  customFetch: this.customFetch,
63
- }).then((response) => CommentSchema.parse(response.data));
133
+ }).then((response) => this.commentSchema.parse(response.data));
64
134
  }
65
- /** Permanently deletes a comment. */
135
+ /**
136
+ * Permanently deletes a comment.
137
+ *
138
+ * @param id - The comment ID.
139
+ */
66
140
  deleteComment(id) {
67
141
  return request({
68
142
  httpMethod: 'POST',
@@ -74,7 +148,18 @@ export class CommentsClient extends BaseClient {
74
148
  }).then((response) => StatusOkSchema.parse(response.data));
75
149
  }
76
150
  /**
77
- * Marks the user's read position in a thread. Comment IDs are strings.
151
+ * Marks the user's read position in a thread. Used to track where the user has read up to,
152
+ * so clients can scroll to this position and show a visual indicator (blue line).
153
+ * Comment IDs are strings.
154
+ *
155
+ * @param args - The arguments for marking read position.
156
+ * @param args.threadId - The thread ID.
157
+ * @param args.commentId - The comment ID to mark as the last read position.
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * await api.comments.markPosition({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', commentId: '7YpL3oZ4kZ9vP7Q1tR2sX41' })
162
+ * ```
78
163
  */
79
164
  markPosition(args) {
80
165
  return request({
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { ENDPOINT_CONVERSATION_MESSAGES } from '../consts/endpoints.js';
3
3
  import { request } from '../transport/http-client.js';
4
- import { ConversationMessageSchema, StatusOkSchema, } from '../types/entities.js';
4
+ import { ConversationMessageSchema, createConversationMessageSchema, StatusOkSchema, } from '../types/entities.js';
5
5
  import { resolveCreateId } from '../utils/uuidv7.js';
6
6
  import { BaseClient } from './base-client.js';
7
7
  export const ConversationMessageListSchema = z.array(ConversationMessageSchema);
@@ -10,7 +10,36 @@ export const ConversationMessageListSchema = z.array(ConversationMessageSchema);
10
10
  * message `id` on `createMessage` when the caller doesn't supply one.
11
11
  */
12
12
  export class ConversationMessagesClient extends BaseClient {
13
- /** Lists messages in a conversation. */
13
+ constructor() {
14
+ super(...arguments);
15
+ this.linkBaseUrl = this.getLinkBaseUrl();
16
+ // Reuse the shared singletons when no custom base is configured.
17
+ this.messageSchema = this.linkBaseUrl
18
+ ? createConversationMessageSchema(this.linkBaseUrl)
19
+ : ConversationMessageSchema;
20
+ this.messageListSchema = this.linkBaseUrl
21
+ ? z.array(this.messageSchema)
22
+ : ConversationMessageListSchema;
23
+ }
24
+ /**
25
+ * Gets all messages in a conversation.
26
+ *
27
+ * @param args - The arguments for getting messages.
28
+ * @param args.conversationId - The conversation ID.
29
+ * @param args.newerThan - Optional date to get messages newer than.
30
+ * @param args.olderThan - Optional date to get messages older than.
31
+ * @param args.limit - Optional limit on number of messages returned.
32
+ * @param args.cursor - Optional cursor for pagination.
33
+ * @returns An array of message objects.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const messages = await api.conversationMessages.getMessages({
38
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
39
+ * newerThan: new Date('2024-01-01'),
40
+ * })
41
+ * ```
42
+ */
14
43
  getMessages(args) {
15
44
  const params = { conversationId: args.conversationId };
16
45
  if (args.newerThan)
@@ -28,13 +57,41 @@ export class ConversationMessagesClient extends BaseClient {
28
57
  apiToken: this.apiToken,
29
58
  payload: params,
30
59
  customFetch: this.customFetch,
31
- }).then((response) => ConversationMessageListSchema.parse(response.data));
60
+ }).then((response) => this.messageListSchema.parse(response.data));
32
61
  }
33
- /** Fetches a single message by ID. */
62
+ /**
63
+ * Gets a single conversation message by id.
64
+ *
65
+ * @param id - The message ID.
66
+ * @returns The conversation message object.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const message = await api.conversationMessages.getMessage('7YpL3oZ4kZ9vP7Q1tR2sX43')
71
+ * ```
72
+ */
34
73
  getMessage(id) {
35
- return this.simple('GET', 'getone', { id }, ConversationMessageSchema);
74
+ return this.simple('GET', 'getone', { id }, this.messageSchema);
36
75
  }
37
- /** Creates a new message. `id` is auto-generated if not supplied. */
76
+ /**
77
+ * Creates a new message in a conversation. `id` is auto-generated if not
78
+ * supplied.
79
+ *
80
+ * @param args - The arguments for creating a message.
81
+ * @param args.conversationId - The conversation ID.
82
+ * @param args.content - The message content.
83
+ * @param args.attachments - Optional array of {@link Attachment} objects.
84
+ * @param args.actions - Optional array of action objects.
85
+ * @returns The created message object.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const message = await api.conversationMessages.createMessage({
90
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
91
+ * content: 'Thanks for the update!',
92
+ * })
93
+ * ```
94
+ */
38
95
  createMessage(args) {
39
96
  const params = {
40
97
  conversationId: args.conversationId,
@@ -51,9 +108,25 @@ export class ConversationMessagesClient extends BaseClient {
51
108
  params.directGroupMentions = args.directGroupMentions;
52
109
  if (args.notify !== undefined)
53
110
  params.notify = args.notify;
54
- return this.simple('POST', 'add', params, ConversationMessageSchema);
111
+ return this.simple('POST', 'add', params, this.messageSchema);
55
112
  }
56
- /** Updates a message. */
113
+ /**
114
+ * Updates a conversation message.
115
+ *
116
+ * @param args - The arguments for updating a message.
117
+ * @param args.id - The message ID.
118
+ * @param args.content - The new message content.
119
+ * @param args.attachments - Optional array of {@link Attachment} objects.
120
+ * @returns The updated message object.
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * const message = await api.conversationMessages.updateMessage({
125
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX43',
126
+ * content: 'Updated message content',
127
+ * })
128
+ * ```
129
+ */
57
130
  updateMessage(args) {
58
131
  const params = { id: args.id, content: args.content };
59
132
  if (args.attachments)
@@ -64,9 +137,18 @@ export class ConversationMessagesClient extends BaseClient {
64
137
  params.directMentions = args.directMentions;
65
138
  if (args.directGroupMentions)
66
139
  params.directGroupMentions = args.directGroupMentions;
67
- return this.simple('POST', 'update', params, ConversationMessageSchema);
140
+ return this.simple('POST', 'update', params, this.messageSchema);
68
141
  }
69
- /** Permanently deletes a message. */
142
+ /**
143
+ * Permanently deletes a conversation message.
144
+ *
145
+ * @param id - The message ID.
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * await api.conversationMessages.deleteMessage('7YpL3oZ4kZ9vP7Q1tR2sX43')
150
+ * ```
151
+ */
70
152
  deleteMessage(id) {
71
153
  return this.simple('POST', 'remove', { id }, StatusOkSchema);
72
154
  }
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { ENDPOINT_CONVERSATIONS } from '../consts/endpoints.js';
3
3
  import { request } from '../transport/http-client.js';
4
- import { ConversationSchema, StatusOkSchema, UnreadConversationSchema, } from '../types/entities.js';
4
+ import { ConversationSchema, createConversationSchema, StatusOkSchema, UnreadConversationSchema, } from '../types/entities.js';
5
5
  import { resolveCreateId } from '../utils/uuidv7.js';
6
6
  import { BaseClient } from './base-client.js';
7
7
  export const ConversationListSchema = z.array(ConversationSchema);
@@ -16,7 +16,31 @@ const GetUnreadResponseSchema = z.object({
16
16
  * already-assigned `id` and your generated one is silently dropped.
17
17
  */
18
18
  export class ConversationsClient extends BaseClient {
19
- /** Lists conversations in a workspace. */
19
+ constructor() {
20
+ super(...arguments);
21
+ this.linkBaseUrl = this.getLinkBaseUrl();
22
+ // Reuse the shared singletons when no custom base is configured.
23
+ this.conversationSchema = this.linkBaseUrl
24
+ ? createConversationSchema(this.linkBaseUrl)
25
+ : ConversationSchema;
26
+ this.conversationListSchema = this.linkBaseUrl
27
+ ? z.array(this.conversationSchema)
28
+ : ConversationListSchema;
29
+ }
30
+ /**
31
+ * Gets all conversations for a workspace.
32
+ *
33
+ * @param args - The arguments for getting conversations.
34
+ * @param args.workspaceId - The workspace ID.
35
+ * @param args.archived - Optional flag to include archived conversations.
36
+ * @returns An array of conversation objects.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const conversations = await api.conversations.getConversations({ workspaceId: 123 })
41
+ * conversations.forEach(c => console.log(c.title))
42
+ * ```
43
+ */
20
44
  getConversations(args) {
21
45
  return request({
22
46
  httpMethod: 'GET',
@@ -25,66 +49,193 @@ export class ConversationsClient extends BaseClient {
25
49
  apiToken: this.apiToken,
26
50
  payload: args,
27
51
  customFetch: this.customFetch,
28
- }).then((response) => ConversationListSchema.parse(response.data));
52
+ }).then((response) => this.conversationListSchema.parse(response.data));
29
53
  }
30
- /** Fetches a single conversation by ID. */
54
+ /**
55
+ * Gets a single conversation object by id.
56
+ *
57
+ * @param id - The conversation ID.
58
+ * @returns The conversation object.
59
+ */
31
60
  getConversation(id) {
32
- return this.simple('GET', 'getone', { id }, ConversationSchema);
61
+ return this.simple('GET', 'getone', { id }, this.conversationSchema);
33
62
  }
34
63
  /**
35
64
  * Gets an existing 1:1 / group conversation with `userIds`, or creates a
36
65
  * new one. `id` is auto-generated if not supplied — on dedupe, the
37
66
  * backend returns the existing conversation's `id` instead.
67
+ *
68
+ * @param args - The arguments for getting or creating a conversation.
69
+ * @param args.workspaceId - The workspace ID.
70
+ * @param args.userIds - Array of user IDs to include in the conversation.
71
+ * @returns The conversation object (existing or newly created).
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const conversation = await api.conversations.getOrCreateConversation({
76
+ * workspaceId: 123,
77
+ * userIds: [101, 202, 303],
78
+ * })
79
+ * ```
38
80
  */
39
81
  getOrCreateConversation(args) {
40
- return this.simple('GET', 'get_or_create', { ...args, id: resolveCreateId(args.id) }, ConversationSchema);
82
+ return this.simple('GET', 'get_or_create', { ...args, id: resolveCreateId(args.id) }, this.conversationSchema);
41
83
  }
42
- /** Updates a conversation's title. */
84
+ /**
85
+ * Updates a conversation's title.
86
+ *
87
+ * @param args - The arguments for updating a conversation.
88
+ * @param args.id - The conversation ID.
89
+ * @param args.title - The new title for the conversation.
90
+ * @param args.archived - Optional flag to archive/unarchive the conversation.
91
+ * @returns The updated conversation object.
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const conversation = await api.conversations.updateConversation({
96
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX42',
97
+ * title: 'New Title',
98
+ * })
99
+ * ```
100
+ */
43
101
  updateConversation(args) {
44
102
  const params = { id: args.id, title: args.title };
45
103
  if (args.archived !== undefined)
46
104
  params.archived = args.archived;
47
- return this.simple('POST', 'update', params, ConversationSchema);
105
+ return this.simple('POST', 'update', params, this.conversationSchema);
48
106
  }
107
+ /**
108
+ * Archives a conversation.
109
+ *
110
+ * @param id - The conversation ID.
111
+ * @returns The updated conversation object.
112
+ */
49
113
  archiveConversation(id) {
50
- return this.simple('GET', 'archive', { id }, ConversationSchema);
114
+ return this.simple('GET', 'archive', { id }, this.conversationSchema);
51
115
  }
116
+ /**
117
+ * Unarchives a conversation.
118
+ *
119
+ * @param id - The conversation ID.
120
+ * @returns The updated conversation object.
121
+ */
52
122
  unarchiveConversation(id) {
53
- return this.simple('GET', 'unarchive', { id }, ConversationSchema);
123
+ return this.simple('GET', 'unarchive', { id }, this.conversationSchema);
54
124
  }
125
+ /**
126
+ * Adds a user to a conversation.
127
+ *
128
+ * @param args - The arguments for adding a user.
129
+ * @param args.id - The conversation ID.
130
+ * @param args.userId - The user ID to add.
131
+ * @returns The updated conversation object.
132
+ */
55
133
  addUser(args) {
56
- return this.simple('POST', 'add_user', { ...args }, ConversationSchema);
134
+ return this.simple('POST', 'add_user', { ...args }, this.conversationSchema);
57
135
  }
136
+ /**
137
+ * Adds multiple users to a conversation.
138
+ *
139
+ * @param args - The arguments for adding users.
140
+ * @param args.id - The conversation ID.
141
+ * @param args.userIds - Array of user IDs to add.
142
+ * @returns The updated conversation object.
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * await api.conversations.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', userIds: [101, 202] })
147
+ * ```
148
+ */
58
149
  addUsers(args) {
59
- return this.simple('POST', 'add_users', { ...args }, ConversationSchema);
150
+ return this.simple('POST', 'add_users', { ...args }, this.conversationSchema);
60
151
  }
152
+ /**
153
+ * Removes a user from a conversation.
154
+ *
155
+ * @param args - The arguments for removing a user.
156
+ * @param args.id - The conversation ID.
157
+ * @param args.userId - The user ID to remove.
158
+ * @returns The updated conversation object.
159
+ */
61
160
  removeUser(args) {
62
- return this.simple('POST', 'remove_user', { ...args }, ConversationSchema);
161
+ return this.simple('POST', 'remove_user', { ...args }, this.conversationSchema);
63
162
  }
163
+ /**
164
+ * Removes multiple users from a conversation.
165
+ *
166
+ * @param args - The arguments for removing users.
167
+ * @param args.id - The conversation ID.
168
+ * @param args.userIds - Array of user IDs to remove.
169
+ * @returns The updated conversation object.
170
+ */
64
171
  removeUsers(args) {
65
- return this.simple('POST', 'remove_users', { ...args }, ConversationSchema);
172
+ return this.simple('POST', 'remove_users', { ...args }, this.conversationSchema);
66
173
  }
174
+ /**
175
+ * Marks a conversation as read.
176
+ *
177
+ * @param args - The arguments for marking as read.
178
+ * @param args.id - The conversation ID.
179
+ * @param args.objIndex - Optional index of the message to mark as last read.
180
+ * @param args.messageId - Optional message ID to mark as last read.
181
+ */
67
182
  markRead(args) {
68
183
  return this.simple('POST', 'mark_read', { ...args }, StatusOkSchema);
69
184
  }
185
+ /**
186
+ * Marks a conversation as unread.
187
+ *
188
+ * @param args - The arguments for marking as unread.
189
+ * @param args.id - The conversation ID.
190
+ * @param args.objIndex - Optional index of the message to mark as last unread.
191
+ * @param args.messageId - Optional message ID to mark as last unread.
192
+ */
70
193
  markUnread(args) {
71
194
  return this.simple('POST', 'mark_unread', { ...args }, StatusOkSchema);
72
195
  }
73
196
  /**
74
197
  * Returns unread conversations for a workspace, paired with the unread
75
198
  * version counter.
199
+ *
200
+ * @param workspaceId - The workspace ID.
201
+ * @returns Object containing the array of unread conversation references and a version counter.
76
202
  */
77
203
  getUnread(workspaceId) {
78
204
  return this.simple('GET', 'get_unread', { workspaceId }, GetUnreadResponseSchema);
79
205
  }
206
+ /**
207
+ * Clears all unread conversations for a workspace.
208
+ *
209
+ * @param workspaceId - The workspace ID.
210
+ */
80
211
  clearUnread(workspaceId) {
81
212
  return this.simple('GET', 'clear_unread', { workspaceId }, StatusOkSchema);
82
213
  }
214
+ /**
215
+ * Mutes a conversation for a specified number of minutes.
216
+ * The user will receive no notifications from this conversation during that period.
217
+ *
218
+ * @param args - The arguments for muting a conversation.
219
+ * @param args.id - The conversation ID.
220
+ * @param args.minutes - Number of minutes to mute the conversation.
221
+ * @returns The updated conversation object.
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * const conversation = await api.conversations.muteConversation({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', minutes: 30 })
226
+ * ```
227
+ */
83
228
  muteConversation(args) {
84
- return this.simple('GET', 'mute', { ...args }, ConversationSchema);
229
+ return this.simple('GET', 'mute', { ...args }, this.conversationSchema);
85
230
  }
231
+ /**
232
+ * Unmutes a conversation.
233
+ *
234
+ * @param id - The conversation ID.
235
+ * @returns The updated conversation object.
236
+ */
86
237
  unmuteConversation(id) {
87
- return this.simple('GET', 'unmute', { id }, ConversationSchema);
238
+ return this.simple('GET', 'unmute', { id }, this.conversationSchema);
88
239
  }
89
240
  simple(httpMethod, suffix, params, schema) {
90
241
  return request({