@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
@@ -19,7 +19,31 @@ const GetUnreadResponseSchema = zod_1.z.object({
19
19
  * already-assigned `id` and your generated one is silently dropped.
20
20
  */
21
21
  class ConversationsClient extends base_client_1.BaseClient {
22
- /** Lists conversations in a workspace. */
22
+ constructor() {
23
+ super(...arguments);
24
+ this.linkBaseUrl = this.getLinkBaseUrl();
25
+ // Reuse the shared singletons when no custom base is configured.
26
+ this.conversationSchema = this.linkBaseUrl
27
+ ? (0, entities_1.createConversationSchema)(this.linkBaseUrl)
28
+ : entities_1.ConversationSchema;
29
+ this.conversationListSchema = this.linkBaseUrl
30
+ ? zod_1.z.array(this.conversationSchema)
31
+ : exports.ConversationListSchema;
32
+ }
33
+ /**
34
+ * Gets all conversations for a workspace.
35
+ *
36
+ * @param args - The arguments for getting conversations.
37
+ * @param args.workspaceId - The workspace ID.
38
+ * @param args.archived - Optional flag to include archived conversations.
39
+ * @returns An array of conversation objects.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const conversations = await api.conversations.getConversations({ workspaceId: 123 })
44
+ * conversations.forEach(c => console.log(c.title))
45
+ * ```
46
+ */
23
47
  getConversations(args) {
24
48
  return (0, http_client_1.request)({
25
49
  httpMethod: 'GET',
@@ -28,66 +52,193 @@ class ConversationsClient extends base_client_1.BaseClient {
28
52
  apiToken: this.apiToken,
29
53
  payload: args,
30
54
  customFetch: this.customFetch,
31
- }).then((response) => exports.ConversationListSchema.parse(response.data));
55
+ }).then((response) => this.conversationListSchema.parse(response.data));
32
56
  }
33
- /** Fetches a single conversation by ID. */
57
+ /**
58
+ * Gets a single conversation object by id.
59
+ *
60
+ * @param id - The conversation ID.
61
+ * @returns The conversation object.
62
+ */
34
63
  getConversation(id) {
35
- return this.simple('GET', 'getone', { id }, entities_1.ConversationSchema);
64
+ return this.simple('GET', 'getone', { id }, this.conversationSchema);
36
65
  }
37
66
  /**
38
67
  * Gets an existing 1:1 / group conversation with `userIds`, or creates a
39
68
  * new one. `id` is auto-generated if not supplied — on dedupe, the
40
69
  * backend returns the existing conversation's `id` instead.
70
+ *
71
+ * @param args - The arguments for getting or creating a conversation.
72
+ * @param args.workspaceId - The workspace ID.
73
+ * @param args.userIds - Array of user IDs to include in the conversation.
74
+ * @returns The conversation object (existing or newly created).
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const conversation = await api.conversations.getOrCreateConversation({
79
+ * workspaceId: 123,
80
+ * userIds: [101, 202, 303],
81
+ * })
82
+ * ```
41
83
  */
42
84
  getOrCreateConversation(args) {
43
- return this.simple('GET', 'get_or_create', { ...args, id: (0, uuidv7_1.resolveCreateId)(args.id) }, entities_1.ConversationSchema);
85
+ return this.simple('GET', 'get_or_create', { ...args, id: (0, uuidv7_1.resolveCreateId)(args.id) }, this.conversationSchema);
44
86
  }
45
- /** Updates a conversation's title. */
87
+ /**
88
+ * Updates a conversation's title.
89
+ *
90
+ * @param args - The arguments for updating a conversation.
91
+ * @param args.id - The conversation ID.
92
+ * @param args.title - The new title for the conversation.
93
+ * @param args.archived - Optional flag to archive/unarchive the conversation.
94
+ * @returns The updated conversation object.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const conversation = await api.conversations.updateConversation({
99
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX42',
100
+ * title: 'New Title',
101
+ * })
102
+ * ```
103
+ */
46
104
  updateConversation(args) {
47
105
  const params = { id: args.id, title: args.title };
48
106
  if (args.archived !== undefined)
49
107
  params.archived = args.archived;
50
- return this.simple('POST', 'update', params, entities_1.ConversationSchema);
108
+ return this.simple('POST', 'update', params, this.conversationSchema);
51
109
  }
110
+ /**
111
+ * Archives a conversation.
112
+ *
113
+ * @param id - The conversation ID.
114
+ * @returns The updated conversation object.
115
+ */
52
116
  archiveConversation(id) {
53
- return this.simple('GET', 'archive', { id }, entities_1.ConversationSchema);
117
+ return this.simple('GET', 'archive', { id }, this.conversationSchema);
54
118
  }
119
+ /**
120
+ * Unarchives a conversation.
121
+ *
122
+ * @param id - The conversation ID.
123
+ * @returns The updated conversation object.
124
+ */
55
125
  unarchiveConversation(id) {
56
- return this.simple('GET', 'unarchive', { id }, entities_1.ConversationSchema);
126
+ return this.simple('GET', 'unarchive', { id }, this.conversationSchema);
57
127
  }
128
+ /**
129
+ * Adds a user to a conversation.
130
+ *
131
+ * @param args - The arguments for adding a user.
132
+ * @param args.id - The conversation ID.
133
+ * @param args.userId - The user ID to add.
134
+ * @returns The updated conversation object.
135
+ */
58
136
  addUser(args) {
59
- return this.simple('POST', 'add_user', { ...args }, entities_1.ConversationSchema);
137
+ return this.simple('POST', 'add_user', { ...args }, this.conversationSchema);
60
138
  }
139
+ /**
140
+ * Adds multiple users to a conversation.
141
+ *
142
+ * @param args - The arguments for adding users.
143
+ * @param args.id - The conversation ID.
144
+ * @param args.userIds - Array of user IDs to add.
145
+ * @returns The updated conversation object.
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * await api.conversations.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', userIds: [101, 202] })
150
+ * ```
151
+ */
61
152
  addUsers(args) {
62
- return this.simple('POST', 'add_users', { ...args }, entities_1.ConversationSchema);
153
+ return this.simple('POST', 'add_users', { ...args }, this.conversationSchema);
63
154
  }
155
+ /**
156
+ * Removes a user from a conversation.
157
+ *
158
+ * @param args - The arguments for removing a user.
159
+ * @param args.id - The conversation ID.
160
+ * @param args.userId - The user ID to remove.
161
+ * @returns The updated conversation object.
162
+ */
64
163
  removeUser(args) {
65
- return this.simple('POST', 'remove_user', { ...args }, entities_1.ConversationSchema);
164
+ return this.simple('POST', 'remove_user', { ...args }, this.conversationSchema);
66
165
  }
166
+ /**
167
+ * Removes multiple users from a conversation.
168
+ *
169
+ * @param args - The arguments for removing users.
170
+ * @param args.id - The conversation ID.
171
+ * @param args.userIds - Array of user IDs to remove.
172
+ * @returns The updated conversation object.
173
+ */
67
174
  removeUsers(args) {
68
- return this.simple('POST', 'remove_users', { ...args }, entities_1.ConversationSchema);
175
+ return this.simple('POST', 'remove_users', { ...args }, this.conversationSchema);
69
176
  }
177
+ /**
178
+ * Marks a conversation as read.
179
+ *
180
+ * @param args - The arguments for marking as read.
181
+ * @param args.id - The conversation ID.
182
+ * @param args.objIndex - Optional index of the message to mark as last read.
183
+ * @param args.messageId - Optional message ID to mark as last read.
184
+ */
70
185
  markRead(args) {
71
186
  return this.simple('POST', 'mark_read', { ...args }, entities_1.StatusOkSchema);
72
187
  }
188
+ /**
189
+ * Marks a conversation as unread.
190
+ *
191
+ * @param args - The arguments for marking as unread.
192
+ * @param args.id - The conversation ID.
193
+ * @param args.objIndex - Optional index of the message to mark as last unread.
194
+ * @param args.messageId - Optional message ID to mark as last unread.
195
+ */
73
196
  markUnread(args) {
74
197
  return this.simple('POST', 'mark_unread', { ...args }, entities_1.StatusOkSchema);
75
198
  }
76
199
  /**
77
200
  * Returns unread conversations for a workspace, paired with the unread
78
201
  * version counter.
202
+ *
203
+ * @param workspaceId - The workspace ID.
204
+ * @returns Object containing the array of unread conversation references and a version counter.
79
205
  */
80
206
  getUnread(workspaceId) {
81
207
  return this.simple('GET', 'get_unread', { workspaceId }, GetUnreadResponseSchema);
82
208
  }
209
+ /**
210
+ * Clears all unread conversations for a workspace.
211
+ *
212
+ * @param workspaceId - The workspace ID.
213
+ */
83
214
  clearUnread(workspaceId) {
84
215
  return this.simple('GET', 'clear_unread', { workspaceId }, entities_1.StatusOkSchema);
85
216
  }
217
+ /**
218
+ * Mutes a conversation for a specified number of minutes.
219
+ * The user will receive no notifications from this conversation during that period.
220
+ *
221
+ * @param args - The arguments for muting a conversation.
222
+ * @param args.id - The conversation ID.
223
+ * @param args.minutes - Number of minutes to mute the conversation.
224
+ * @returns The updated conversation object.
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * const conversation = await api.conversations.muteConversation({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', minutes: 30 })
229
+ * ```
230
+ */
86
231
  muteConversation(args) {
87
- return this.simple('GET', 'mute', { ...args }, entities_1.ConversationSchema);
232
+ return this.simple('GET', 'mute', { ...args }, this.conversationSchema);
88
233
  }
234
+ /**
235
+ * Unmutes a conversation.
236
+ *
237
+ * @param id - The conversation ID.
238
+ * @returns The updated conversation object.
239
+ */
89
240
  unmuteConversation(id) {
90
- return this.simple('GET', 'unmute', { id }, entities_1.ConversationSchema);
241
+ return this.simple('GET', 'unmute', { id }, this.conversationSchema);
91
242
  }
92
243
  simple(httpMethod, suffix, params, schema) {
93
244
  return (0, http_client_1.request)({
@@ -18,7 +18,18 @@ exports.GroupListSchema = zod_1.z.array(entities_1.GroupSchema);
18
18
  * `workspace_id` alongside the group `id`.
19
19
  */
20
20
  class GroupsClient extends base_client_1.BaseClient {
21
- /** Lists groups in a workspace. */
21
+ /**
22
+ * Gets all groups for a given workspace.
23
+ *
24
+ * @param workspaceId - The workspace ID.
25
+ * @returns An array of group objects.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const groups = await api.groups.getGroups(123)
30
+ * groups.forEach(g => console.log(g.name))
31
+ * ```
32
+ */
22
33
  getGroups(workspaceId) {
23
34
  return (0, http_client_1.request)({
24
35
  httpMethod: 'GET',
@@ -29,31 +40,113 @@ class GroupsClient extends base_client_1.BaseClient {
29
40
  customFetch: this.customFetch,
30
41
  }).then((response) => exports.GroupListSchema.parse(response.data));
31
42
  }
32
- /** Fetches a single group by ID (requires `workspaceId`). */
43
+ /**
44
+ * Gets a single group object by id. Requires `workspaceId`.
45
+ *
46
+ * @param args - The arguments for getting a group.
47
+ * @param args.id - The group ID.
48
+ * @param args.workspaceId - The workspace ID.
49
+ * @returns The group object.
50
+ */
33
51
  getGroup(args) {
34
52
  return this.simple('GET', 'getone', { ...args }, entities_1.GroupSchema);
35
53
  }
36
- /** Creates a new group. `id` is auto-generated if not supplied. */
54
+ /**
55
+ * Creates a new group. `id` is auto-generated if not supplied.
56
+ *
57
+ * @param args - The arguments for creating a group.
58
+ * @param args.workspaceId - The workspace ID.
59
+ * @param args.name - The group name.
60
+ * @param args.id - Optional caller-supplied group ID (for optimistic-UI workflows).
61
+ * @param args.description - Optional group description.
62
+ * @param args.userIds - Optional array of user IDs to add to the group.
63
+ * @returns The created group object.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const group = await api.groups.createGroup({
68
+ * workspaceId: 123,
69
+ * name: 'Engineering Team',
70
+ * userIds: [1, 2, 3],
71
+ * })
72
+ * ```
73
+ */
37
74
  createGroup(args) {
38
75
  return this.simple('POST', 'add', { ...args, id: (0, uuidv7_1.resolveCreateId)(args.id) }, entities_1.GroupSchema);
39
76
  }
40
- /** Updates a group. Requires `workspaceId`. */
77
+ /**
78
+ * Updates a group's properties. Requires `workspaceId`.
79
+ *
80
+ * @param args - The arguments for updating a group.
81
+ * @param args.id - The group ID.
82
+ * @param args.workspaceId - The workspace ID.
83
+ * @param args.name - Optional new group name.
84
+ * @param args.description - Optional new group description.
85
+ * @returns The updated group object.
86
+ */
41
87
  updateGroup(args) {
42
88
  return this.simple('POST', 'update', { ...args }, entities_1.GroupSchema);
43
89
  }
44
- /** Permanently deletes a group. Requires `workspaceId`. */
90
+ /**
91
+ * Permanently deletes a group. Requires `workspaceId`.
92
+ *
93
+ * @param args - The arguments for deleting a group.
94
+ * @param args.id - The group ID.
95
+ * @param args.workspaceId - The workspace ID.
96
+ */
45
97
  deleteGroup(args) {
46
98
  return this.simple('POST', 'remove', { ...args }, entities_1.StatusOkSchema);
47
99
  }
100
+ /**
101
+ * Adds a user to a group.
102
+ *
103
+ * @param args - The arguments for adding a user.
104
+ * @param args.id - The group ID.
105
+ * @param args.workspaceId - The workspace ID.
106
+ * @param args.userId - The user ID to add.
107
+ */
48
108
  addUser(args) {
49
109
  return this.simple('POST', 'add_user', { ...args }, entities_1.StatusOkSchema);
50
110
  }
111
+ /**
112
+ * Adds multiple users to a group.
113
+ *
114
+ * @param args - The arguments for adding users.
115
+ * @param args.id - The group ID.
116
+ * @param args.workspaceId - The workspace ID.
117
+ * @param args.userIds - Array of user IDs to add.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * await api.groups.addUsers({
122
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX45',
123
+ * workspaceId: 123,
124
+ * userIds: [101, 202, 303],
125
+ * })
126
+ * ```
127
+ */
51
128
  addUsers(args) {
52
129
  return this.simple('POST', 'add_users', { ...args }, entities_1.StatusOkSchema);
53
130
  }
131
+ /**
132
+ * Removes a user from a group.
133
+ *
134
+ * @param args - The arguments for removing a user.
135
+ * @param args.id - The group ID.
136
+ * @param args.workspaceId - The workspace ID.
137
+ * @param args.userId - The user ID to remove.
138
+ */
54
139
  removeUser(args) {
55
140
  return this.simple('POST', 'remove_user', { ...args }, entities_1.StatusOkSchema);
56
141
  }
142
+ /**
143
+ * Removes multiple users from a group.
144
+ *
145
+ * @param args - The arguments for removing users.
146
+ * @param args.id - The group ID.
147
+ * @param args.workspaceId - The workspace ID.
148
+ * @param args.userIds - Array of user IDs to remove.
149
+ */
57
150
  removeUsers(args) {
58
151
  return this.simple('POST', 'remove_users', { ...args }, entities_1.StatusOkSchema);
59
152
  }
@@ -1,23 +1,57 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InboxClient = void 0;
3
+ exports.InboxClient = exports.InboxThreadListSchema = void 0;
4
+ const zod_1 = require("zod");
4
5
  const endpoints_1 = require("../consts/endpoints");
5
6
  const http_client_1 = require("../transport/http-client");
6
7
  const entities_1 = require("../types/entities");
7
8
  const base_client_1 = require("./base-client");
9
+ exports.InboxThreadListSchema = zod_1.z.array(entities_1.InboxThreadSchema);
8
10
  /** Client for `/api/v1/inbox/`. */
9
11
  class InboxClient extends base_client_1.BaseClient {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.linkBaseUrl = this.getLinkBaseUrl();
15
+ // Reuse the shared singletons when no custom base is configured.
16
+ this.inboxThreadSchema = this.linkBaseUrl
17
+ ? (0, entities_1.createInboxThreadSchema)(this.linkBaseUrl)
18
+ : entities_1.InboxThreadSchema;
19
+ this.inboxThreadListSchema = this.linkBaseUrl
20
+ ? zod_1.z.array(this.inboxThreadSchema)
21
+ : exports.InboxThreadListSchema;
22
+ }
10
23
  /**
11
24
  * Gets inbox items (threads).
25
+ *
26
+ * @param args - The arguments for getting inbox.
27
+ * @param args.workspaceId - The workspace ID.
28
+ * @param args.newerThan - Optional date to get items newer than.
29
+ * @param args.olderThan - Optional date to get items older than.
30
+ * @param args.limit - Optional limit on number of items returned.
31
+ * @param args.cursor - Optional cursor for pagination.
32
+ * @param args.archiveFilter - Optional filter: 'active' (default), 'archived', or 'all'.
33
+ * @returns Inbox threads.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const inbox = await api.inbox.getInbox({
38
+ * workspaceId: 123,
39
+ * newerThan: new Date('2024-01-01'),
40
+ * })
41
+ *
42
+ * // Include archived (done) items alongside active ones
43
+ * const allInbox = await api.inbox.getInbox({
44
+ * workspaceId: 123,
45
+ * archiveFilter: 'all',
46
+ * })
47
+ * ```
12
48
  */
13
49
  getInbox(args) {
14
50
  const params = { workspace_id: args.workspaceId };
15
- const newerThan = args.newerThan ?? args.since;
16
- if (newerThan)
17
- params.newer_than_ts = Math.floor(newerThan.getTime() / 1000);
18
- const olderThan = args.olderThan ?? args.until;
19
- if (olderThan)
20
- params.older_than_ts = Math.floor(olderThan.getTime() / 1000);
51
+ if (args.newerThan)
52
+ params.newer_than_ts = Math.floor(args.newerThan.getTime() / 1000);
53
+ if (args.olderThan)
54
+ params.older_than_ts = Math.floor(args.olderThan.getTime() / 1000);
21
55
  if (args.limit)
22
56
  params.limit = args.limit;
23
57
  if (args.cursor)
@@ -31,9 +65,20 @@ class InboxClient extends base_client_1.BaseClient {
31
65
  apiToken: this.apiToken,
32
66
  payload: params,
33
67
  customFetch: this.customFetch,
34
- }).then((response) => response.data.map((thread) => entities_1.InboxThreadSchema.parse(thread)));
68
+ }).then((response) => this.inboxThreadListSchema.parse(response.data));
35
69
  }
36
- /** Gets unread count for inbox. */
70
+ /**
71
+ * Gets unread count for inbox.
72
+ *
73
+ * @param workspaceId - The workspace ID.
74
+ * @returns The unread count.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const count = await api.inbox.getCount(123)
79
+ * console.log(`Unread items: ${count}`)
80
+ * ```
81
+ */
37
82
  getCount(workspaceId) {
38
83
  return (0, http_client_1.request)({
39
84
  httpMethod: 'GET',
@@ -44,7 +89,16 @@ class InboxClient extends base_client_1.BaseClient {
44
89
  customFetch: this.customFetch,
45
90
  }).then((response) => response.data.data);
46
91
  }
47
- /** Archives a thread in the inbox. */
92
+ /**
93
+ * Archives a thread in the inbox.
94
+ *
95
+ * @param id - The thread ID.
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * await api.inbox.archiveThread('7YpL3oZ4kZ9vP7Q1tR2sX3z')
100
+ * ```
101
+ */
48
102
  archiveThread(id) {
49
103
  return (0, http_client_1.request)({
50
104
  httpMethod: 'POST',
@@ -55,7 +109,16 @@ class InboxClient extends base_client_1.BaseClient {
55
109
  customFetch: this.customFetch,
56
110
  }).then(() => undefined);
57
111
  }
58
- /** Unarchives a thread in the inbox. */
112
+ /**
113
+ * Unarchives a thread in the inbox.
114
+ *
115
+ * @param id - The thread ID.
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * await api.inbox.unarchiveThread('7YpL3oZ4kZ9vP7Q1tR2sX3z')
120
+ * ```
121
+ */
59
122
  unarchiveThread(id) {
60
123
  return (0, http_client_1.request)({
61
124
  httpMethod: 'POST',
@@ -66,7 +129,16 @@ class InboxClient extends base_client_1.BaseClient {
66
129
  customFetch: this.customFetch,
67
130
  }).then(() => undefined);
68
131
  }
69
- /** Marks all inbox items as read in a workspace. */
132
+ /**
133
+ * Marks all inbox items as read in a workspace.
134
+ *
135
+ * @param workspaceId - The workspace ID.
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * await api.inbox.markAllRead(123)
140
+ * ```
141
+ */
70
142
  markAllRead(workspaceId) {
71
143
  return (0, http_client_1.request)({
72
144
  httpMethod: 'POST',
@@ -77,14 +149,28 @@ class InboxClient extends base_client_1.BaseClient {
77
149
  customFetch: this.customFetch,
78
150
  }).then(() => undefined);
79
151
  }
80
- /** Archives all inbox items in a workspace. */
152
+ /**
153
+ * Archives all inbox items in a workspace.
154
+ *
155
+ * @param args - The arguments for archiving all.
156
+ * @param args.workspaceId - The workspace ID.
157
+ * @param args.channelIds - Optional array of channel IDs to filter by.
158
+ * @param args.olderThan - Optional date to filter items older than.
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * await api.inbox.archiveAll({
163
+ * workspaceId: 123,
164
+ * olderThan: new Date('2024-01-01'),
165
+ * })
166
+ * ```
167
+ */
81
168
  archiveAll(args) {
82
169
  const params = { workspace_id: args.workspaceId };
83
170
  if (args.channelIds)
84
171
  params.channel_ids = args.channelIds;
85
- const olderThan = args.olderThan ?? args.until;
86
- if (olderThan)
87
- params.older_than_ts = Math.floor(olderThan.getTime() / 1000);
172
+ if (args.olderThan)
173
+ params.older_than_ts = Math.floor(args.olderThan.getTime() / 1000);
88
174
  return (0, http_client_1.request)({
89
175
  httpMethod: 'POST',
90
176
  baseUri: this.getBaseUri(),
@@ -17,7 +17,20 @@ function reactionTarget(args) {
17
17
  * Client for interacting with Comms reaction endpoints.
18
18
  */
19
19
  class ReactionsClient extends base_client_1.BaseClient {
20
- /** Adds an emoji reaction to a thread, comment, or conversation message. */
20
+ /**
21
+ * Adds an emoji reaction to a thread, comment, or conversation message.
22
+ *
23
+ * @param args - The arguments for adding a reaction.
24
+ * @param args.threadId - Optional thread ID.
25
+ * @param args.commentId - Optional comment ID.
26
+ * @param args.messageId - Optional message ID (for conversation messages).
27
+ * @param args.reaction - The reaction emoji to add.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * await api.reactions.add({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', reaction: '👍' })
32
+ * ```
33
+ */
21
34
  add(args) {
22
35
  return (0, http_client_1.request)({
23
36
  httpMethod: 'POST',
@@ -33,6 +46,18 @@ class ReactionsClient extends base_client_1.BaseClient {
33
46
  *
34
47
  * Returns an object with emoji reactions as keys and arrays of user IDs as
35
48
  * values, or null if no reactions.
49
+ *
50
+ * @param args - The arguments for getting reactions.
51
+ * @param args.threadId - Optional thread ID.
52
+ * @param args.commentId - Optional comment ID.
53
+ * @param args.messageId - Optional message ID (for conversation messages).
54
+ * @returns A reaction object with emoji reactions as keys and arrays of user IDs as values, or null if no reactions.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const reactions = await api.reactions.get({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z' })
59
+ * // Returns: { "👍": [101, 202, 303], "❤️": [101, 202] }
60
+ * ```
36
61
  */
37
62
  get(args) {
38
63
  return (0, http_client_1.request)({
@@ -44,7 +69,20 @@ class ReactionsClient extends base_client_1.BaseClient {
44
69
  customFetch: this.customFetch,
45
70
  }).then((response) => response.data);
46
71
  }
47
- /** Removes an emoji reaction from a thread, comment, or conversation message. */
72
+ /**
73
+ * Removes an emoji reaction from a thread, comment, or conversation message.
74
+ *
75
+ * @param args - The arguments for removing a reaction.
76
+ * @param args.threadId - Optional thread ID.
77
+ * @param args.commentId - Optional comment ID.
78
+ * @param args.messageId - Optional message ID (for conversation messages).
79
+ * @param args.reaction - The reaction emoji to remove.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * await api.reactions.remove({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', reaction: '👍' })
84
+ * ```
85
+ */
48
86
  remove(args) {
49
87
  return (0, http_client_1.request)({
50
88
  httpMethod: 'POST',
@@ -11,6 +11,26 @@ const base_client_1 = require("./base-client");
11
11
  class SearchClient extends base_client_1.BaseClient {
12
12
  /**
13
13
  * Searches across all threads and conversations in a workspace.
14
+ *
15
+ * @param args - The arguments for searching.
16
+ * @param args.query - The search query string. Optional when `mentionSelf: true` is set; required otherwise.
17
+ * @param args.workspaceId - The workspace ID to search in.
18
+ * @param args.channelIds - Optional array of channel IDs to filter by.
19
+ * @param args.authorIds - Optional array of author user IDs to filter by.
20
+ * @param args.mentionSelf - Optional flag to filter by mentions of the current user. When true, `query` may be omitted.
21
+ * @param args.dateFrom - Optional start date for filtering (YYYY-MM-DD).
22
+ * @param args.dateTo - Optional end date for filtering (YYYY-MM-DD).
23
+ * @param args.limit - Optional limit on number of results returned.
24
+ * @param args.cursor - Optional cursor for pagination.
25
+ * @returns Search results with pagination.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const results = await api.search.search({
30
+ * query: 'important meeting',
31
+ * workspaceId: 123,
32
+ * })
33
+ * ```
14
34
  */
15
35
  search(args) {
16
36
  const params = { workspace_id: args.workspaceId };
@@ -44,6 +64,21 @@ class SearchClient extends base_client_1.BaseClient {
44
64
  }
45
65
  /**
46
66
  * Searches within comments of a specific thread.
67
+ *
68
+ * @param args - The arguments for searching within a thread.
69
+ * @param args.query - The search query string.
70
+ * @param args.threadId - The thread ID to search in.
71
+ * @param args.limit - Optional limit on number of results returned.
72
+ * @param args.cursor - Optional cursor for pagination.
73
+ * @returns Comment IDs that match the search query.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const results = await api.search.searchThread({
78
+ * query: 'deadline',
79
+ * threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
80
+ * })
81
+ * ```
47
82
  */
48
83
  searchThread(args) {
49
84
  const params = {
@@ -65,6 +100,21 @@ class SearchClient extends base_client_1.BaseClient {
65
100
  }
66
101
  /**
67
102
  * Searches within messages of a specific conversation.
103
+ *
104
+ * @param args - The arguments for searching within a conversation.
105
+ * @param args.query - The search query string.
106
+ * @param args.conversationId - The conversation ID to search in.
107
+ * @param args.limit - Optional limit on number of results returned.
108
+ * @param args.cursor - Optional cursor for pagination.
109
+ * @returns Message IDs that match the search query.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * const results = await api.search.searchConversation({
114
+ * query: 'budget',
115
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
116
+ * })
117
+ * ```
68
118
  */
69
119
  searchConversation(args) {
70
120
  const params = {