@doist/comms-sdk 0.1.0-alpha.1 → 0.2.0

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 (62) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/clients/add-comment-helper.js +17 -0
  3. package/dist/cjs/clients/base-client.js +3 -5
  4. package/dist/cjs/clients/channels-client.js +123 -6
  5. package/dist/cjs/clients/comments-client.js +75 -9
  6. package/dist/cjs/clients/conversation-messages-client.js +76 -5
  7. package/dist/cjs/clients/conversations-client.js +143 -3
  8. package/dist/cjs/clients/groups-client.js +98 -5
  9. package/dist/cjs/clients/inbox-client.js +87 -14
  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 +211 -16
  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 +80 -7
  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/index.js +1 -0
  21. package/dist/cjs/types/requests.js +0 -1
  22. package/dist/esm/clients/add-comment-helper.js +17 -0
  23. package/dist/esm/clients/base-client.js +3 -5
  24. package/dist/esm/clients/channels-client.js +123 -6
  25. package/dist/esm/clients/comments-client.js +75 -9
  26. package/dist/esm/clients/conversation-messages-client.js +76 -5
  27. package/dist/esm/clients/conversations-client.js +143 -3
  28. package/dist/esm/clients/groups-client.js +98 -5
  29. package/dist/esm/clients/inbox-client.js +87 -14
  30. package/dist/esm/clients/reactions-client.js +40 -2
  31. package/dist/esm/clients/search-client.js +50 -0
  32. package/dist/esm/clients/threads-client.js +211 -16
  33. package/dist/esm/clients/users-client.js +138 -11
  34. package/dist/esm/clients/workspace-users-client.js +110 -10
  35. package/dist/esm/clients/workspaces-client.js +80 -7
  36. package/dist/esm/comms-api.js +1 -0
  37. package/dist/esm/consts/endpoints.js +8 -3
  38. package/dist/esm/testUtils/test-defaults.js +2 -0
  39. package/dist/esm/types/api-version.js +5 -0
  40. package/dist/esm/types/index.js +1 -0
  41. package/dist/esm/types/requests.js +0 -1
  42. package/dist/types/clients/add-comment-helper.d.ts +17 -0
  43. package/dist/types/clients/base-client.d.ts +4 -0
  44. package/dist/types/clients/channels-client.d.ts +123 -6
  45. package/dist/types/clients/comments-client.d.ts +73 -6
  46. package/dist/types/clients/conversation-messages-client.d.ts +76 -5
  47. package/dist/types/clients/conversations-client.d.ts +143 -3
  48. package/dist/types/clients/groups-client.d.ts +98 -5
  49. package/dist/types/clients/inbox-client.d.ts +81 -5
  50. package/dist/types/clients/reactions-client.d.ts +40 -2
  51. package/dist/types/clients/search-client.d.ts +50 -0
  52. package/dist/types/clients/threads-client.d.ts +200 -8
  53. package/dist/types/clients/users-client.d.ts +138 -11
  54. package/dist/types/clients/workspace-users-client.d.ts +110 -10
  55. package/dist/types/clients/workspaces-client.d.ts +80 -7
  56. package/dist/types/comms-api.d.ts +3 -0
  57. package/dist/types/consts/endpoints.d.ts +6 -1
  58. package/dist/types/testUtils/test-defaults.d.ts +1 -0
  59. package/dist/types/types/api-version.d.ts +6 -0
  60. package/dist/types/types/index.d.ts +1 -0
  61. package/dist/types/types/requests.d.ts +2 -21
  62. package/package.json +1 -1
@@ -6,15 +6,36 @@ import { BaseClient } from './base-client.js';
6
6
  export class InboxClient extends BaseClient {
7
7
  /**
8
8
  * Gets inbox items (threads).
9
+ *
10
+ * @param args - The arguments for getting inbox.
11
+ * @param args.workspaceId - The workspace ID.
12
+ * @param args.newerThan - Optional date to get items newer than.
13
+ * @param args.olderThan - Optional date to get items older than.
14
+ * @param args.limit - Optional limit on number of items returned.
15
+ * @param args.cursor - Optional cursor for pagination.
16
+ * @param args.archiveFilter - Optional filter: 'active' (default), 'archived', or 'all'.
17
+ * @returns Inbox threads.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const inbox = await api.inbox.getInbox({
22
+ * workspaceId: 123,
23
+ * newerThan: new Date('2024-01-01'),
24
+ * })
25
+ *
26
+ * // Include archived (done) items alongside active ones
27
+ * const allInbox = await api.inbox.getInbox({
28
+ * workspaceId: 123,
29
+ * archiveFilter: 'all',
30
+ * })
31
+ * ```
9
32
  */
10
33
  getInbox(args) {
11
34
  const params = { workspace_id: args.workspaceId };
12
- const newerThan = args.newerThan ?? args.since;
13
- if (newerThan)
14
- params.newer_than_ts = Math.floor(newerThan.getTime() / 1000);
15
- const olderThan = args.olderThan ?? args.until;
16
- if (olderThan)
17
- params.older_than_ts = Math.floor(olderThan.getTime() / 1000);
35
+ if (args.newerThan)
36
+ params.newer_than_ts = Math.floor(args.newerThan.getTime() / 1000);
37
+ if (args.olderThan)
38
+ params.older_than_ts = Math.floor(args.olderThan.getTime() / 1000);
18
39
  if (args.limit)
19
40
  params.limit = args.limit;
20
41
  if (args.cursor)
@@ -30,7 +51,18 @@ export class InboxClient extends BaseClient {
30
51
  customFetch: this.customFetch,
31
52
  }).then((response) => response.data.map((thread) => InboxThreadSchema.parse(thread)));
32
53
  }
33
- /** Gets unread count for inbox. */
54
+ /**
55
+ * Gets unread count for inbox.
56
+ *
57
+ * @param workspaceId - The workspace ID.
58
+ * @returns The unread count.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const count = await api.inbox.getCount(123)
63
+ * console.log(`Unread items: ${count}`)
64
+ * ```
65
+ */
34
66
  getCount(workspaceId) {
35
67
  return request({
36
68
  httpMethod: 'GET',
@@ -41,7 +73,16 @@ export class InboxClient extends BaseClient {
41
73
  customFetch: this.customFetch,
42
74
  }).then((response) => response.data.data);
43
75
  }
44
- /** Archives a thread in the inbox. */
76
+ /**
77
+ * Archives a thread in the inbox.
78
+ *
79
+ * @param id - The thread ID.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * await api.inbox.archiveThread('7YpL3oZ4kZ9vP7Q1tR2sX3z')
84
+ * ```
85
+ */
45
86
  archiveThread(id) {
46
87
  return request({
47
88
  httpMethod: 'POST',
@@ -52,7 +93,16 @@ export class InboxClient extends BaseClient {
52
93
  customFetch: this.customFetch,
53
94
  }).then(() => undefined);
54
95
  }
55
- /** Unarchives a thread in the inbox. */
96
+ /**
97
+ * Unarchives a thread in the inbox.
98
+ *
99
+ * @param id - The thread ID.
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * await api.inbox.unarchiveThread('7YpL3oZ4kZ9vP7Q1tR2sX3z')
104
+ * ```
105
+ */
56
106
  unarchiveThread(id) {
57
107
  return request({
58
108
  httpMethod: 'POST',
@@ -63,7 +113,16 @@ export class InboxClient extends BaseClient {
63
113
  customFetch: this.customFetch,
64
114
  }).then(() => undefined);
65
115
  }
66
- /** Marks all inbox items as read in a workspace. */
116
+ /**
117
+ * Marks all inbox items as read in a workspace.
118
+ *
119
+ * @param workspaceId - The workspace ID.
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * await api.inbox.markAllRead(123)
124
+ * ```
125
+ */
67
126
  markAllRead(workspaceId) {
68
127
  return request({
69
128
  httpMethod: 'POST',
@@ -74,14 +133,28 @@ export class InboxClient extends BaseClient {
74
133
  customFetch: this.customFetch,
75
134
  }).then(() => undefined);
76
135
  }
77
- /** Archives all inbox items in a workspace. */
136
+ /**
137
+ * Archives all inbox items in a workspace.
138
+ *
139
+ * @param args - The arguments for archiving all.
140
+ * @param args.workspaceId - The workspace ID.
141
+ * @param args.channelIds - Optional array of channel IDs to filter by.
142
+ * @param args.olderThan - Optional date to filter items older than.
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * await api.inbox.archiveAll({
147
+ * workspaceId: 123,
148
+ * olderThan: new Date('2024-01-01'),
149
+ * })
150
+ * ```
151
+ */
78
152
  archiveAll(args) {
79
153
  const params = { workspace_id: args.workspaceId };
80
154
  if (args.channelIds)
81
155
  params.channel_ids = args.channelIds;
82
- const olderThan = args.olderThan ?? args.until;
83
- if (olderThan)
84
- params.older_than_ts = Math.floor(olderThan.getTime() / 1000);
156
+ if (args.olderThan)
157
+ params.older_than_ts = Math.floor(args.olderThan.getTime() / 1000);
85
158
  return request({
86
159
  httpMethod: 'POST',
87
160
  baseUri: this.getBaseUri(),
@@ -14,7 +14,20 @@ function reactionTarget(args) {
14
14
  * Client for interacting with Comms reaction endpoints.
15
15
  */
16
16
  export class ReactionsClient extends BaseClient {
17
- /** Adds an emoji reaction to a thread, comment, or conversation message. */
17
+ /**
18
+ * Adds an emoji reaction to a thread, comment, or conversation message.
19
+ *
20
+ * @param args - The arguments for adding a reaction.
21
+ * @param args.threadId - Optional thread ID.
22
+ * @param args.commentId - Optional comment ID.
23
+ * @param args.messageId - Optional message ID (for conversation messages).
24
+ * @param args.reaction - The reaction emoji to add.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * await api.reactions.add({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', reaction: '👍' })
29
+ * ```
30
+ */
18
31
  add(args) {
19
32
  return request({
20
33
  httpMethod: 'POST',
@@ -30,6 +43,18 @@ export class ReactionsClient extends BaseClient {
30
43
  *
31
44
  * Returns an object with emoji reactions as keys and arrays of user IDs as
32
45
  * values, or null if no reactions.
46
+ *
47
+ * @param args - The arguments for getting reactions.
48
+ * @param args.threadId - Optional thread ID.
49
+ * @param args.commentId - Optional comment ID.
50
+ * @param args.messageId - Optional message ID (for conversation messages).
51
+ * @returns A reaction object with emoji reactions as keys and arrays of user IDs as values, or null if no reactions.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const reactions = await api.reactions.get({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z' })
56
+ * // Returns: { "👍": [101, 202, 303], "❤️": [101, 202] }
57
+ * ```
33
58
  */
34
59
  get(args) {
35
60
  return request({
@@ -41,7 +66,20 @@ export class ReactionsClient extends BaseClient {
41
66
  customFetch: this.customFetch,
42
67
  }).then((response) => response.data);
43
68
  }
44
- /** Removes an emoji reaction from a thread, comment, or conversation message. */
69
+ /**
70
+ * Removes an emoji reaction from a thread, comment, or conversation message.
71
+ *
72
+ * @param args - The arguments for removing a reaction.
73
+ * @param args.threadId - Optional thread ID.
74
+ * @param args.commentId - Optional comment ID.
75
+ * @param args.messageId - Optional message ID (for conversation messages).
76
+ * @param args.reaction - The reaction emoji to remove.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * await api.reactions.remove({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', reaction: '👍' })
81
+ * ```
82
+ */
45
83
  remove(args) {
46
84
  return request({
47
85
  httpMethod: 'POST',
@@ -8,6 +8,26 @@ import { BaseClient } from './base-client.js';
8
8
  export class SearchClient extends BaseClient {
9
9
  /**
10
10
  * Searches across all threads and conversations in a workspace.
11
+ *
12
+ * @param args - The arguments for searching.
13
+ * @param args.query - The search query string. Optional when `mentionSelf: true` is set; required otherwise.
14
+ * @param args.workspaceId - The workspace ID to search in.
15
+ * @param args.channelIds - Optional array of channel IDs to filter by.
16
+ * @param args.authorIds - Optional array of author user IDs to filter by.
17
+ * @param args.mentionSelf - Optional flag to filter by mentions of the current user. When true, `query` may be omitted.
18
+ * @param args.dateFrom - Optional start date for filtering (YYYY-MM-DD).
19
+ * @param args.dateTo - Optional end date for filtering (YYYY-MM-DD).
20
+ * @param args.limit - Optional limit on number of results returned.
21
+ * @param args.cursor - Optional cursor for pagination.
22
+ * @returns Search results with pagination.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const results = await api.search.search({
27
+ * query: 'important meeting',
28
+ * workspaceId: 123,
29
+ * })
30
+ * ```
11
31
  */
12
32
  search(args) {
13
33
  const params = { workspace_id: args.workspaceId };
@@ -41,6 +61,21 @@ export class SearchClient extends BaseClient {
41
61
  }
42
62
  /**
43
63
  * Searches within comments of a specific thread.
64
+ *
65
+ * @param args - The arguments for searching within a thread.
66
+ * @param args.query - The search query string.
67
+ * @param args.threadId - The thread ID to search in.
68
+ * @param args.limit - Optional limit on number of results returned.
69
+ * @param args.cursor - Optional cursor for pagination.
70
+ * @returns Comment IDs that match the search query.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const results = await api.search.searchThread({
75
+ * query: 'deadline',
76
+ * threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
77
+ * })
78
+ * ```
44
79
  */
45
80
  searchThread(args) {
46
81
  const params = {
@@ -62,6 +97,21 @@ export class SearchClient extends BaseClient {
62
97
  }
63
98
  /**
64
99
  * Searches within messages of a specific conversation.
100
+ *
101
+ * @param args - The arguments for searching within a conversation.
102
+ * @param args.query - The search query string.
103
+ * @param args.conversationId - The conversation ID to search in.
104
+ * @param args.limit - Optional limit on number of results returned.
105
+ * @param args.cursor - Optional cursor for pagination.
106
+ * @returns Message IDs that match the search query.
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const results = await api.search.searchConversation({
111
+ * query: 'budget',
112
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
113
+ * })
114
+ * ```
65
115
  */
66
116
  searchConversation(args) {
67
117
  const params = {
@@ -17,19 +17,40 @@ const GetUnreadResponseSchema = z.object({
17
17
  */
18
18
  export class ThreadsClient extends BaseClient {
19
19
  /**
20
- * Lists threads. At least one of `channelId` / `workspaceId` is required.
20
+ * Gets threads. At least one of `channelId` / `workspaceId` is required.
21
21
  * `newerThan` / `olderThan` (`Date`) are converted to the
22
22
  * `newer_than_ts` / `older_than_ts` epoch-second params on the wire.
23
+ *
24
+ * @param args - The arguments for getting threads.
25
+ * @param args.workspaceId - The workspace ID.
26
+ * @param args.channelId - Optional channel ID to narrow to a single channel.
27
+ * @param args.archived - Optional flag to include archived threads.
28
+ * @param args.newerThan - Optional date to get threads newer than.
29
+ * @param args.olderThan - Optional date to get threads older than.
30
+ * @param args.limit - Optional limit on number of threads returned.
31
+ * @returns An array of thread objects.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const threads = await api.threads.getThreads({
36
+ * workspaceId: 123,
37
+ * channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44',
38
+ * })
39
+ * threads.forEach(t => console.log(t.title))
40
+ * ```
23
41
  */
24
42
  getThreads(args) {
25
- const { newerThan, olderThan, newer_than_ts, older_than_ts, ...rest } = args;
26
- const resolvedNewerThan = newerThan ? Math.floor(newerThan.getTime() / 1000) : newer_than_ts;
27
- const resolvedOlderThan = olderThan ? Math.floor(olderThan.getTime() / 1000) : older_than_ts;
28
- const params = {
29
- ...rest,
30
- ...(resolvedNewerThan != null ? { newer_than_ts: resolvedNewerThan } : {}),
31
- ...(resolvedOlderThan != null ? { older_than_ts: resolvedOlderThan } : {}),
32
- };
43
+ const params = { workspaceId: args.workspaceId };
44
+ if (args.channelId != null)
45
+ params.channelId = args.channelId;
46
+ if (args.archived != null)
47
+ params.archived = args.archived;
48
+ if (args.limit != null)
49
+ params.limit = args.limit;
50
+ if (args.newerThan)
51
+ params.newer_than_ts = Math.floor(args.newerThan.getTime() / 1000);
52
+ if (args.olderThan)
53
+ params.older_than_ts = Math.floor(args.olderThan.getTime() / 1000);
33
54
  return request({
34
55
  httpMethod: 'GET',
35
56
  baseUri: this.getBaseUri(),
@@ -39,52 +60,147 @@ export class ThreadsClient extends BaseClient {
39
60
  customFetch: this.customFetch,
40
61
  }).then((response) => ThreadListSchema.parse(response.data));
41
62
  }
42
- /** Fetches a single thread by ID. */
63
+ /**
64
+ * Gets a single thread object by id.
65
+ *
66
+ * @param id - The thread ID.
67
+ * @returns The thread object.
68
+ */
43
69
  getThread(id) {
44
70
  return this.simple('GET', 'getone', { id }, ThreadSchema);
45
71
  }
46
- /** Creates a new thread. `id` is auto-generated if not supplied. */
72
+ /**
73
+ * Creates a new thread in a channel. `id` is auto-generated if not supplied.
74
+ *
75
+ * @param args - The arguments for creating a thread.
76
+ * @param args.channelId - The channel ID.
77
+ * @param args.title - Optional thread title.
78
+ * @param args.content - The thread content.
79
+ * @param args.recipients - Optional array of user IDs to notify.
80
+ * @param args.groups - Optional array of custom group IDs to notify.
81
+ * @returns The created thread object.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const thread = await api.threads.createThread({
86
+ * channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44',
87
+ * title: 'New Feature Discussion',
88
+ * content: 'Let\'s discuss the new feature...',
89
+ * })
90
+ * ```
91
+ */
47
92
  createThread(args) {
48
93
  return this.simple('POST', 'add', { ...args, id: resolveCreateId(args.id) }, ThreadSchema);
49
94
  }
50
- /** Partial update of an existing thread. */
95
+ /**
96
+ * Partial update of an existing thread.
97
+ *
98
+ * @param args - The arguments for updating a thread.
99
+ * @param args.id - The thread ID.
100
+ * @param args.title - Optional new thread title.
101
+ * @param args.content - Optional new thread content.
102
+ * @returns The updated thread object.
103
+ */
51
104
  updateThread(args) {
52
105
  return this.simple('POST', 'update', { ...args }, ThreadSchema);
53
106
  }
54
- /** Permanently deletes a thread. */
107
+ /**
108
+ * Permanently deletes a thread.
109
+ *
110
+ * @param id - The thread ID.
111
+ */
55
112
  deleteThread(id) {
56
113
  return this.simple('POST', 'remove', { id }, StatusOkSchema);
57
114
  }
58
- /** Saves a thread (formerly "star"). */
115
+ /**
116
+ * Saves a thread (formerly "star").
117
+ *
118
+ * @param id - The thread ID.
119
+ */
59
120
  saveThread(id) {
60
121
  return this.simple('GET', 'save', { id }, StatusOkSchema);
61
122
  }
62
- /** Unsaves a thread (formerly "unstar"). */
123
+ /**
124
+ * Unsaves a thread (formerly "unstar").
125
+ *
126
+ * @param id - The thread ID.
127
+ */
63
128
  unsaveThread(id) {
64
129
  return this.simple('GET', 'unsave', { id }, StatusOkSchema);
65
130
  }
131
+ /**
132
+ * Pins a thread.
133
+ *
134
+ * @param id - The thread ID.
135
+ */
66
136
  pinThread(id) {
67
137
  return this.simple('GET', 'pin', { id }, StatusOkSchema);
68
138
  }
139
+ /**
140
+ * Unpins a thread.
141
+ *
142
+ * @param id - The thread ID.
143
+ */
69
144
  unpinThread(id) {
70
145
  return this.simple('GET', 'unpin', { id }, StatusOkSchema);
71
146
  }
72
- /** Moves a thread to another channel. */
147
+ /**
148
+ * Moves a thread to another channel.
149
+ *
150
+ * @param args - The arguments for moving a thread.
151
+ * @param args.id - The thread ID.
152
+ * @param args.toChannel - The target channel ID.
153
+ * @returns The updated thread object.
154
+ */
73
155
  moveToChannel(args) {
74
156
  return this.simple('GET', 'move_to_channel', { ...args }, ThreadSchema);
75
157
  }
158
+ /**
159
+ * Marks a thread as read.
160
+ *
161
+ * @param args - The arguments for marking a thread as read.
162
+ * @param args.id - The thread ID.
163
+ * @param args.objIndex - The index of the last known read message.
164
+ */
76
165
  markRead(args) {
77
166
  return this.simple('POST', 'mark_read', { ...args }, StatusOkSchema);
78
167
  }
168
+ /**
169
+ * Marks a thread as unread.
170
+ *
171
+ * @param args - The arguments for marking a thread as unread.
172
+ * @param args.id - The thread ID.
173
+ * @param args.objIndex - The index of the last unread message. Use -1 to mark the whole thread as unread.
174
+ */
79
175
  markUnread(args) {
80
176
  return this.simple('POST', 'mark_unread', { ...args }, StatusOkSchema);
81
177
  }
178
+ /**
179
+ * Marks a thread as unread for others. Useful to notify others about thread changes.
180
+ *
181
+ * @param args - The arguments for marking a thread as unread for others.
182
+ * @param args.id - The thread ID.
183
+ * @param args.objIndex - The index of the last unread message. Use -1 to mark the whole thread as unread.
184
+ */
82
185
  markUnreadForOthers(args) {
83
186
  return this.simple('POST', 'mark_unread_for_others', { ...args }, StatusOkSchema);
84
187
  }
85
188
  /**
86
189
  * Marks every thread in a workspace or channel as read. Exactly one of
87
190
  * `workspaceId` / `channelId` should be set.
191
+ *
192
+ * @param args - Either workspaceId or channelId (one is required).
193
+ * @param args.workspaceId - The workspace ID.
194
+ * @param args.channelId - The channel ID.
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * // Mark all in workspace
199
+ * await api.threads.markAllRead({ workspaceId: 123 })
200
+ *
201
+ * // Mark all in channel
202
+ * await api.threads.markAllRead({ channelId: '7YpL3oZ4kZ9vP7Q1tR2sX44' })
203
+ * ```
88
204
  */
89
205
  markAllRead(args) {
90
206
  if (!args.workspaceId && !args.channelId) {
@@ -92,25 +208,104 @@ export class ThreadsClient extends BaseClient {
92
208
  }
93
209
  return this.simple('POST', 'mark_all_read', { ...args }, StatusOkSchema);
94
210
  }
211
+ /**
212
+ * Clears unread threads in a workspace.
213
+ *
214
+ * @param workspaceId - The workspace ID.
215
+ */
95
216
  clearUnread(workspaceId) {
96
217
  return this.simple('GET', 'clear_unread', { workspaceId }, StatusOkSchema);
97
218
  }
98
219
  /**
99
220
  * Returns unread threads for a workspace, paired with the unread version
100
221
  * counter and (optionally) the inbox unread count.
222
+ *
223
+ * @param workspaceId - The workspace ID.
224
+ * @returns Object containing the array of unread thread references, a version counter, and optionally the inbox unread count.
101
225
  */
102
226
  getUnread(workspaceId) {
103
227
  return this.simple('GET', 'get_unread', { workspaceId }, GetUnreadResponseSchema);
104
228
  }
229
+ /**
230
+ * Mutes a thread for a specified number of minutes.
231
+ * When muted, you will not get notified in your inbox about new comments.
232
+ *
233
+ * @param args - The arguments for muting a thread.
234
+ * @param args.id - The thread ID.
235
+ * @param args.minutes - Number of minutes to mute the thread.
236
+ * @returns The updated thread object.
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * const thread = await api.threads.muteThread({ id: '7YpL3oZ4kZ9vP7Q1tR2sX3z', minutes: 30 })
241
+ * ```
242
+ */
105
243
  muteThread(args) {
106
244
  return this.simple('GET', 'mute', { ...args }, ThreadSchema);
107
245
  }
246
+ /**
247
+ * Unmutes a thread.
248
+ * You will start to see notifications in your inbox again when new comments are added.
249
+ *
250
+ * @param id - The thread ID.
251
+ * @returns The updated thread object.
252
+ */
108
253
  unmuteThread(id) {
109
254
  return this.simple('GET', 'unmute', { id }, ThreadSchema);
110
255
  }
256
+ /**
257
+ * Closes a thread by adding a comment with a close action.
258
+ *
259
+ * @param args - The arguments for closing a thread.
260
+ * @param args.id - The thread ID.
261
+ * @param args.content - The comment content.
262
+ * @param args.attachments - Optional array of {@link Attachment} objects.
263
+ * @param args.actions - Optional array of action objects.
264
+ * @param args.recipients - Optional array of user IDs to notify directly.
265
+ * @param args.groups - Optional array of custom group IDs to notify.
266
+ * @param args.directMentions - Optional array of user IDs that were @-mentioned in
267
+ * `content`.
268
+ * @param args.notifyAudience - Optional broader audience to notify in addition to
269
+ * `recipients` and `groups`. `'channel'` notifies everyone in the channel;
270
+ * `'thread'` notifies everyone who has interacted with the thread.
271
+ * @returns The created comment object.
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * const comment = await api.threads.closeThread({
276
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
277
+ * content: 'Closing this thread — resolved.',
278
+ * })
279
+ * ```
280
+ */
111
281
  closeThread(args) {
112
282
  return this.addCommentWithAction(args, 'close');
113
283
  }
284
+ /**
285
+ * Reopens a thread by adding a comment with a reopen action.
286
+ *
287
+ * @param args - The arguments for reopening a thread.
288
+ * @param args.id - The thread ID.
289
+ * @param args.content - The comment content.
290
+ * @param args.attachments - Optional array of {@link Attachment} objects.
291
+ * @param args.actions - Optional array of action objects.
292
+ * @param args.recipients - Optional array of user IDs to notify directly.
293
+ * @param args.groups - Optional array of custom group IDs to notify.
294
+ * @param args.directMentions - Optional array of user IDs that were @-mentioned in
295
+ * `content`.
296
+ * @param args.notifyAudience - Optional broader audience to notify in addition to
297
+ * `recipients` and `groups`. `'channel'` notifies everyone in the channel;
298
+ * `'thread'` notifies everyone who has interacted with the thread.
299
+ * @returns The created comment object.
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * const comment = await api.threads.reopenThread({
304
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
305
+ * content: 'Reopening — need further discussion.',
306
+ * })
307
+ * ```
308
+ */
114
309
  reopenThread(args) {
115
310
  return this.addCommentWithAction(args, 'reopen');
116
311
  }