@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
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Comms SDK (TypeScript)
1
+ # Comms SDK TypeScript
2
2
 
3
3
  The official TypeScript SDK for the Comms REST API.
4
4
 
@@ -36,6 +36,23 @@ function applyNotifyAudience(params) {
36
36
  const { notifyAudience: _stripped, groups, ...rest } = params;
37
37
  return { ...rest, groups: [...(groups ?? []), sentinel] };
38
38
  }
39
+ /**
40
+ * Internal helper that powers `comments.createComment`,
41
+ * `threads.closeThread`, and `threads.reopenThread`.
42
+ *
43
+ * Normalizes the `notifyAudience` flag into a sentinel `groups` entry,
44
+ * rejects sentinel IDs passed via `groups` / `directGroupMentions`, mints a
45
+ * UUIDv7 `id` when the caller omits one, and posts to `/comments/add`. When
46
+ * `threadAction` is set (`'close'` / `'reopen'`), it is forwarded on the
47
+ * wire so the same request both adds the comment and transitions the
48
+ * parent thread.
49
+ *
50
+ * @param context - Per-call client context (base URI, API token, optional `customFetch`).
51
+ * @param params - The comment payload (`{@link CreateCommentArgs}`).
52
+ * @param options - Optional configuration.
53
+ * @param options.threadAction - When set, also transitions the parent thread (`'close'` or `'reopen'`).
54
+ * @returns The parsed {@link Comment} returned by the API.
55
+ */
39
56
  function addCommentRequest(context, params, options) {
40
57
  const normalized = applyNotifyAudience(params);
41
58
  const withId = { ...normalized, id: (0, uuidv7_1.resolveCreateId)(normalized.id) };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseClient = void 0;
4
4
  const endpoints_1 = require("../consts/endpoints");
5
+ const api_version_1 = require("../types/api-version");
5
6
  /**
6
7
  * Base class for every Comms API client. Centralizes URL handling and
7
8
  * config so individual clients stay focused on their endpoints.
@@ -10,6 +11,7 @@ class BaseClient {
10
11
  constructor(config) {
11
12
  this.apiToken = config.apiToken;
12
13
  this.baseUrl = config.baseUrl;
14
+ this.defaultVersion = config.version || api_version_1.DEFAULT_API_VERSION;
13
15
  this.customFetch = config.customFetch;
14
16
  }
15
17
  /**
@@ -17,11 +19,7 @@ class BaseClient {
17
19
  * slash so relative paths resolve cleanly through `URL`.
18
20
  */
19
21
  getBaseUri() {
20
- if (this.baseUrl) {
21
- const normalizedBaseUrl = this.baseUrl.endsWith('/') ? this.baseUrl : `${this.baseUrl}/`;
22
- return `${normalizedBaseUrl}api/v1/`;
23
- }
24
- return (0, endpoints_1.getCommsBaseUri)();
22
+ return (0, endpoints_1.getCommsBaseUri)(this.defaultVersion, this.baseUrl);
25
23
  }
26
24
  }
27
25
  exports.BaseClient = BaseClient;
@@ -14,7 +14,20 @@ exports.ChannelListSchema = zod_1.z.array(entities_1.ChannelSchema);
14
14
  * to keep an optimistic-UI ID stable through the round-trip.
15
15
  */
16
16
  class ChannelsClient extends base_client_1.BaseClient {
17
- /** Lists channels in a workspace. */
17
+ /**
18
+ * Gets all channels for a given workspace.
19
+ *
20
+ * @param args - The arguments for getting channels.
21
+ * @param args.workspaceId - The workspace ID.
22
+ * @param args.archived - Optional flag to include archived channels.
23
+ * @returns An array of channel objects.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const channels = await api.channels.getChannels({ workspaceId: 123 })
28
+ * channels.forEach(ch => console.log(ch.name))
29
+ * ```
30
+ */
18
31
  getChannels(args) {
19
32
  return (0, http_client_1.request)({
20
33
  httpMethod: 'GET',
@@ -25,47 +38,151 @@ class ChannelsClient extends base_client_1.BaseClient {
25
38
  customFetch: this.customFetch,
26
39
  }).then((response) => exports.ChannelListSchema.parse(response.data));
27
40
  }
28
- /** Fetches a single channel by ID. */
41
+ /**
42
+ * Gets a single channel object by id.
43
+ *
44
+ * @param id - The channel ID.
45
+ * @returns The channel object.
46
+ */
29
47
  getChannel(id) {
30
48
  return this.simple('GET', 'getone', { id }, entities_1.ChannelSchema);
31
49
  }
32
- /** Creates a new channel. `id` is auto-generated if not supplied. */
50
+ /**
51
+ * Creates a new channel. `id` is auto-generated if not supplied — pass your
52
+ * own `id` to keep an optimistic-UI ID stable through the round-trip.
53
+ *
54
+ * @param args - The arguments for creating a channel.
55
+ * @param args.workspaceId - The workspace ID.
56
+ * @param args.name - The channel name.
57
+ * @param args.description - Optional channel description.
58
+ * @param args.color - Optional channel color.
59
+ * @param args.userIds - Optional array of user IDs to add to the channel.
60
+ * @param args.public - Optional flag to make the channel public.
61
+ * @returns The created channel object.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const channel = await api.channels.createChannel({
66
+ * workspaceId: 123,
67
+ * name: 'Engineering',
68
+ * description: 'Engineering team channel',
69
+ * })
70
+ * ```
71
+ */
33
72
  createChannel(args) {
34
73
  return this.simple('POST', 'add', { ...args, id: (0, uuidv7_1.resolveCreateId)(args.id) }, entities_1.ChannelSchema);
35
74
  }
36
- /** Partial update of an existing channel. */
75
+ /**
76
+ * Partial update of an existing channel.
77
+ *
78
+ * @param args - The arguments for updating a channel.
79
+ * @param args.id - The channel ID.
80
+ * @param args.name - Optional new channel name.
81
+ * @param args.description - Optional new channel description.
82
+ * @param args.color - Optional new channel color.
83
+ * @param args.public - Optional flag to change channel visibility.
84
+ * @returns The updated channel object.
85
+ */
37
86
  updateChannel(args) {
38
87
  return this.simple('POST', 'update', { ...args }, entities_1.ChannelSchema);
39
88
  }
40
- /** Updates the channel's view filter (`only_open` / `all` / `only_closed`). */
89
+ /**
90
+ * Updates the channel's view filter (`only_open` / `all` / `only_closed`).
91
+ *
92
+ * @param args - The arguments for updating the channel filter.
93
+ * @param args.id - The channel ID.
94
+ * @param args.filterClosed - The new filter value.
95
+ */
41
96
  updateFilters(args) {
42
97
  return this.simple('POST', 'update_filters', { ...args }, entities_1.StatusOkSchema);
43
98
  }
44
- /** Permanently deletes a channel. */
99
+ /**
100
+ * Permanently deletes a channel.
101
+ *
102
+ * @param id - The channel ID.
103
+ */
45
104
  deleteChannel(id) {
46
105
  return this.simple('POST', 'remove', { id }, entities_1.StatusOkSchema);
47
106
  }
107
+ /**
108
+ * Archives a channel.
109
+ *
110
+ * @param id - The channel ID.
111
+ */
48
112
  archiveChannel(id) {
49
113
  return this.simple('POST', 'archive', { id }, entities_1.StatusOkSchema);
50
114
  }
115
+ /**
116
+ * Unarchives a channel.
117
+ *
118
+ * @param id - The channel ID.
119
+ */
51
120
  unarchiveChannel(id) {
52
121
  return this.simple('POST', 'unarchive', { id }, entities_1.StatusOkSchema);
53
122
  }
123
+ /**
124
+ * Favorites a channel.
125
+ *
126
+ * @param id - The channel ID.
127
+ */
54
128
  favoriteChannel(id) {
55
129
  return this.simple('POST', 'favorite', { id }, entities_1.StatusOkSchema);
56
130
  }
131
+ /**
132
+ * Unfavorites a channel.
133
+ *
134
+ * @param id - The channel ID.
135
+ */
57
136
  unfavoriteChannel(id) {
58
137
  return this.simple('POST', 'unfavorite', { id }, entities_1.StatusOkSchema);
59
138
  }
139
+ /**
140
+ * Adds a user to a channel.
141
+ *
142
+ * @param args - The arguments for adding a user.
143
+ * @param args.id - The channel ID.
144
+ * @param args.userId - The user ID to add.
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * await api.channels.addUser({ id: '7YpL3oZ4kZ9vP7Q1tR2sX44', userId: 101 })
149
+ * ```
150
+ */
60
151
  addUser(args) {
61
152
  return this.simple('POST', 'add_user', { ...args }, entities_1.ChannelSchema);
62
153
  }
154
+ /**
155
+ * Adds multiple users to a channel.
156
+ *
157
+ * @param args - The arguments for adding users.
158
+ * @param args.id - The channel ID.
159
+ * @param args.userIds - Array of user IDs to add.
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * await api.channels.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX44', userIds: [101, 202] })
164
+ * ```
165
+ */
63
166
  addUsers(args) {
64
167
  return this.simple('POST', 'add_users', { ...args }, entities_1.ChannelSchema);
65
168
  }
169
+ /**
170
+ * Removes a user from a channel.
171
+ *
172
+ * @param args - The arguments for removing a user.
173
+ * @param args.id - The channel ID.
174
+ * @param args.userId - The user ID to remove.
175
+ */
66
176
  removeUser(args) {
67
177
  return this.simple('POST', 'remove_user', { ...args }, entities_1.ChannelSchema);
68
178
  }
179
+ /**
180
+ * Removes multiple users from a channel.
181
+ *
182
+ * @param args - The arguments for removing users.
183
+ * @param args.id - The channel ID.
184
+ * @param args.userIds - Array of user IDs to remove.
185
+ */
69
186
  removeUsers(args) {
70
187
  return this.simple('POST', 'remove_users', { ...args }, entities_1.ChannelSchema);
71
188
  }
@@ -14,15 +14,30 @@ exports.CommentListSchema = zod_1.z.array(entities_1.CommentSchema);
14
14
  */
15
15
  class CommentsClient extends base_client_1.BaseClient {
16
16
  /**
17
- * Lists comments in a thread. `newerThan` / `olderThan` (`Date`) are
17
+ * Gets all comments for a thread. `newerThan` / `olderThan` (`Date`) are
18
18
  * converted to `newer_than_ts` / `older_than_ts` epoch seconds on the
19
19
  * wire.
20
+ *
21
+ * @param args - The arguments for getting comments.
22
+ * @param args.threadId - The thread ID.
23
+ * @param args.newerThan - Optional date to get comments newer than.
24
+ * @param args.olderThan - Optional date to get comments older than.
25
+ * @param args.limit - Optional limit on number of comments returned.
26
+ * @returns An array of comment objects.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const comments = await api.comments.getComments({
31
+ * threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
32
+ * newerThan: new Date('2024-01-01'),
33
+ * })
34
+ * comments.forEach(c => console.log(c.content))
35
+ * ```
20
36
  */
21
37
  getComments(args) {
22
38
  const params = { threadId: args.threadId };
23
- const newerThan = args.newerThan ?? args.from;
24
- if (newerThan)
25
- params.newerThanTs = Math.floor(newerThan.getTime() / 1000);
39
+ if (args.newerThan)
40
+ params.newerThanTs = Math.floor(args.newerThan.getTime() / 1000);
26
41
  if (args.olderThan)
27
42
  params.olderThanTs = Math.floor(args.olderThan.getTime() / 1000);
28
43
  if (args.limit)
@@ -36,7 +51,12 @@ class CommentsClient extends base_client_1.BaseClient {
36
51
  customFetch: this.customFetch,
37
52
  }).then((response) => exports.CommentListSchema.parse(response.data));
38
53
  }
39
- /** Fetches a single comment by ID. The API wraps it in `{comment: ...}`. */
54
+ /**
55
+ * Gets a single comment object by id. The API wraps it in `{comment: ...}`.
56
+ *
57
+ * @param id - The comment ID.
58
+ * @returns The comment object.
59
+ */
40
60
  getComment(id) {
41
61
  const wrappedSchema = zod_1.z.object({ comment: entities_1.CommentSchema }).transform((data) => data.comment);
42
62
  return (0, http_client_1.request)({
@@ -49,12 +69,43 @@ class CommentsClient extends base_client_1.BaseClient {
49
69
  }).then((response) => wrappedSchema.parse(response.data));
50
70
  }
51
71
  /**
52
- * Creates a new comment. `id` is auto-generated if not supplied.
72
+ * Creates a new comment on a thread. `id` is auto-generated if not supplied.
73
+ *
74
+ * @param args - The arguments for creating a comment.
75
+ * @param args.threadId - The thread ID.
76
+ * @param args.content - The comment content.
77
+ * @param args.recipients - Optional array of user IDs to notify directly.
78
+ * @param args.groups - Optional array of custom group IDs to notify.
79
+ * @param args.directMentions - Optional array of user IDs that were @-mentioned in
80
+ * `content`.
81
+ * @param args.notifyAudience - Optional broader audience to notify in addition to
82
+ * `recipients` and `groups`. `'channel'` notifies everyone in the channel;
83
+ * `'thread'` notifies everyone who has interacted with the thread.
84
+ * @param args.attachments - Optional array of {@link Attachment} objects.
85
+ * @returns The created comment object.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * // Notify everyone who has interacted with the thread, plus two extra users.
90
+ * const comment = await api.comments.createComment({
91
+ * threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
92
+ * content: 'Great idea! Let\'s proceed.',
93
+ * notifyAudience: 'thread',
94
+ * recipients: [101, 202],
95
+ * })
96
+ * ```
53
97
  */
54
98
  createComment(args) {
55
99
  return (0, add_comment_helper_1.addCommentRequest)({ baseUri: this.getBaseUri(), apiToken: this.apiToken, customFetch: this.customFetch }, args);
56
100
  }
57
- /** Updates a comment. */
101
+ /**
102
+ * Updates a comment's properties.
103
+ *
104
+ * @param args - The arguments for updating a comment.
105
+ * @param args.id - The comment ID.
106
+ * @param args.content - The new comment content.
107
+ * @returns The updated comment object.
108
+ */
58
109
  updateComment(args) {
59
110
  return (0, http_client_1.request)({
60
111
  httpMethod: 'POST',
@@ -65,7 +116,11 @@ class CommentsClient extends base_client_1.BaseClient {
65
116
  customFetch: this.customFetch,
66
117
  }).then((response) => entities_1.CommentSchema.parse(response.data));
67
118
  }
68
- /** Permanently deletes a comment. */
119
+ /**
120
+ * Permanently deletes a comment.
121
+ *
122
+ * @param id - The comment ID.
123
+ */
69
124
  deleteComment(id) {
70
125
  return (0, http_client_1.request)({
71
126
  httpMethod: 'POST',
@@ -77,7 +132,18 @@ class CommentsClient extends base_client_1.BaseClient {
77
132
  }).then((response) => entities_1.StatusOkSchema.parse(response.data));
78
133
  }
79
134
  /**
80
- * Marks the user's read position in a thread. Comment IDs are strings.
135
+ * Marks the user's read position in a thread. Used to track where the user has read up to,
136
+ * so clients can scroll to this position and show a visual indicator (blue line).
137
+ * Comment IDs are strings.
138
+ *
139
+ * @param args - The arguments for marking read position.
140
+ * @param args.threadId - The thread ID.
141
+ * @param args.commentId - The comment ID to mark as the last read position.
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * await api.comments.markPosition({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', commentId: '7YpL3oZ4kZ9vP7Q1tR2sX41' })
146
+ * ```
81
147
  */
82
148
  markPosition(args) {
83
149
  return (0, http_client_1.request)({
@@ -13,7 +13,25 @@ exports.ConversationMessageListSchema = zod_1.z.array(entities_1.ConversationMes
13
13
  * message `id` on `createMessage` when the caller doesn't supply one.
14
14
  */
15
15
  class ConversationMessagesClient extends base_client_1.BaseClient {
16
- /** Lists messages in a conversation. */
16
+ /**
17
+ * Gets all messages in a conversation.
18
+ *
19
+ * @param args - The arguments for getting messages.
20
+ * @param args.conversationId - The conversation ID.
21
+ * @param args.newerThan - Optional date to get messages newer than.
22
+ * @param args.olderThan - Optional date to get messages older than.
23
+ * @param args.limit - Optional limit on number of messages returned.
24
+ * @param args.cursor - Optional cursor for pagination.
25
+ * @returns An array of message objects.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const messages = await api.conversationMessages.getMessages({
30
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
31
+ * newerThan: new Date('2024-01-01'),
32
+ * })
33
+ * ```
34
+ */
17
35
  getMessages(args) {
18
36
  const params = { conversationId: args.conversationId };
19
37
  if (args.newerThan)
@@ -33,11 +51,39 @@ class ConversationMessagesClient extends base_client_1.BaseClient {
33
51
  customFetch: this.customFetch,
34
52
  }).then((response) => exports.ConversationMessageListSchema.parse(response.data));
35
53
  }
36
- /** Fetches a single message by ID. */
54
+ /**
55
+ * Gets a single conversation message by id.
56
+ *
57
+ * @param id - The message ID.
58
+ * @returns The conversation message object.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const message = await api.conversationMessages.getMessage('7YpL3oZ4kZ9vP7Q1tR2sX43')
63
+ * ```
64
+ */
37
65
  getMessage(id) {
38
66
  return this.simple('GET', 'getone', { id }, entities_1.ConversationMessageSchema);
39
67
  }
40
- /** Creates a new message. `id` is auto-generated if not supplied. */
68
+ /**
69
+ * Creates a new message in a conversation. `id` is auto-generated if not
70
+ * supplied.
71
+ *
72
+ * @param args - The arguments for creating a message.
73
+ * @param args.conversationId - The conversation ID.
74
+ * @param args.content - The message content.
75
+ * @param args.attachments - Optional array of {@link Attachment} objects.
76
+ * @param args.actions - Optional array of action objects.
77
+ * @returns The created message object.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const message = await api.conversationMessages.createMessage({
82
+ * conversationId: '7YpL3oZ4kZ9vP7Q1tR2sX42',
83
+ * content: 'Thanks for the update!',
84
+ * })
85
+ * ```
86
+ */
41
87
  createMessage(args) {
42
88
  const params = {
43
89
  conversationId: args.conversationId,
@@ -56,7 +102,23 @@ class ConversationMessagesClient extends base_client_1.BaseClient {
56
102
  params.notify = args.notify;
57
103
  return this.simple('POST', 'add', params, entities_1.ConversationMessageSchema);
58
104
  }
59
- /** Updates a message. */
105
+ /**
106
+ * Updates a conversation message.
107
+ *
108
+ * @param args - The arguments for updating a message.
109
+ * @param args.id - The message ID.
110
+ * @param args.content - The new message content.
111
+ * @param args.attachments - Optional array of {@link Attachment} objects.
112
+ * @returns The updated message object.
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const message = await api.conversationMessages.updateMessage({
117
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX43',
118
+ * content: 'Updated message content',
119
+ * })
120
+ * ```
121
+ */
60
122
  updateMessage(args) {
61
123
  const params = { id: args.id, content: args.content };
62
124
  if (args.attachments)
@@ -69,7 +131,16 @@ class ConversationMessagesClient extends base_client_1.BaseClient {
69
131
  params.directGroupMentions = args.directGroupMentions;
70
132
  return this.simple('POST', 'update', params, entities_1.ConversationMessageSchema);
71
133
  }
72
- /** Permanently deletes a message. */
134
+ /**
135
+ * Permanently deletes a conversation message.
136
+ *
137
+ * @param id - The message ID.
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * await api.conversationMessages.deleteMessage('7YpL3oZ4kZ9vP7Q1tR2sX43')
142
+ * ```
143
+ */
73
144
  deleteMessage(id) {
74
145
  return this.simple('POST', 'remove', { id }, entities_1.StatusOkSchema);
75
146
  }
@@ -19,7 +19,20 @@ 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
+ /**
23
+ * Gets all conversations for a workspace.
24
+ *
25
+ * @param args - The arguments for getting conversations.
26
+ * @param args.workspaceId - The workspace ID.
27
+ * @param args.archived - Optional flag to include archived conversations.
28
+ * @returns An array of conversation objects.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const conversations = await api.conversations.getConversations({ workspaceId: 123 })
33
+ * conversations.forEach(c => console.log(c.title))
34
+ * ```
35
+ */
23
36
  getConversations(args) {
24
37
  return (0, http_client_1.request)({
25
38
  httpMethod: 'GET',
@@ -30,7 +43,12 @@ class ConversationsClient extends base_client_1.BaseClient {
30
43
  customFetch: this.customFetch,
31
44
  }).then((response) => exports.ConversationListSchema.parse(response.data));
32
45
  }
33
- /** Fetches a single conversation by ID. */
46
+ /**
47
+ * Gets a single conversation object by id.
48
+ *
49
+ * @param id - The conversation ID.
50
+ * @returns The conversation object.
51
+ */
34
52
  getConversation(id) {
35
53
  return this.simple('GET', 'getone', { id }, entities_1.ConversationSchema);
36
54
  }
@@ -38,54 +56,176 @@ class ConversationsClient extends base_client_1.BaseClient {
38
56
  * Gets an existing 1:1 / group conversation with `userIds`, or creates a
39
57
  * new one. `id` is auto-generated if not supplied — on dedupe, the
40
58
  * backend returns the existing conversation's `id` instead.
59
+ *
60
+ * @param args - The arguments for getting or creating a conversation.
61
+ * @param args.workspaceId - The workspace ID.
62
+ * @param args.userIds - Array of user IDs to include in the conversation.
63
+ * @returns The conversation object (existing or newly created).
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const conversation = await api.conversations.getOrCreateConversation({
68
+ * workspaceId: 123,
69
+ * userIds: [101, 202, 303],
70
+ * })
71
+ * ```
41
72
  */
42
73
  getOrCreateConversation(args) {
43
74
  return this.simple('GET', 'get_or_create', { ...args, id: (0, uuidv7_1.resolveCreateId)(args.id) }, entities_1.ConversationSchema);
44
75
  }
45
- /** Updates a conversation's title. */
76
+ /**
77
+ * Updates a conversation's title.
78
+ *
79
+ * @param args - The arguments for updating a conversation.
80
+ * @param args.id - The conversation ID.
81
+ * @param args.title - The new title for the conversation.
82
+ * @param args.archived - Optional flag to archive/unarchive the conversation.
83
+ * @returns The updated conversation object.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const conversation = await api.conversations.updateConversation({
88
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX42',
89
+ * title: 'New Title',
90
+ * })
91
+ * ```
92
+ */
46
93
  updateConversation(args) {
47
94
  const params = { id: args.id, title: args.title };
48
95
  if (args.archived !== undefined)
49
96
  params.archived = args.archived;
50
97
  return this.simple('POST', 'update', params, entities_1.ConversationSchema);
51
98
  }
99
+ /**
100
+ * Archives a conversation.
101
+ *
102
+ * @param id - The conversation ID.
103
+ * @returns The updated conversation object.
104
+ */
52
105
  archiveConversation(id) {
53
106
  return this.simple('GET', 'archive', { id }, entities_1.ConversationSchema);
54
107
  }
108
+ /**
109
+ * Unarchives a conversation.
110
+ *
111
+ * @param id - The conversation ID.
112
+ * @returns The updated conversation object.
113
+ */
55
114
  unarchiveConversation(id) {
56
115
  return this.simple('GET', 'unarchive', { id }, entities_1.ConversationSchema);
57
116
  }
117
+ /**
118
+ * Adds a user to a conversation.
119
+ *
120
+ * @param args - The arguments for adding a user.
121
+ * @param args.id - The conversation ID.
122
+ * @param args.userId - The user ID to add.
123
+ * @returns The updated conversation object.
124
+ */
58
125
  addUser(args) {
59
126
  return this.simple('POST', 'add_user', { ...args }, entities_1.ConversationSchema);
60
127
  }
128
+ /**
129
+ * Adds multiple users to a conversation.
130
+ *
131
+ * @param args - The arguments for adding users.
132
+ * @param args.id - The conversation ID.
133
+ * @param args.userIds - Array of user IDs to add.
134
+ * @returns The updated conversation object.
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * await api.conversations.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', userIds: [101, 202] })
139
+ * ```
140
+ */
61
141
  addUsers(args) {
62
142
  return this.simple('POST', 'add_users', { ...args }, entities_1.ConversationSchema);
63
143
  }
144
+ /**
145
+ * Removes a user from a conversation.
146
+ *
147
+ * @param args - The arguments for removing a user.
148
+ * @param args.id - The conversation ID.
149
+ * @param args.userId - The user ID to remove.
150
+ * @returns The updated conversation object.
151
+ */
64
152
  removeUser(args) {
65
153
  return this.simple('POST', 'remove_user', { ...args }, entities_1.ConversationSchema);
66
154
  }
155
+ /**
156
+ * Removes multiple users from a conversation.
157
+ *
158
+ * @param args - The arguments for removing users.
159
+ * @param args.id - The conversation ID.
160
+ * @param args.userIds - Array of user IDs to remove.
161
+ * @returns The updated conversation object.
162
+ */
67
163
  removeUsers(args) {
68
164
  return this.simple('POST', 'remove_users', { ...args }, entities_1.ConversationSchema);
69
165
  }
166
+ /**
167
+ * Marks a conversation as read.
168
+ *
169
+ * @param args - The arguments for marking as read.
170
+ * @param args.id - The conversation ID.
171
+ * @param args.objIndex - Optional index of the message to mark as last read.
172
+ * @param args.messageId - Optional message ID to mark as last read.
173
+ */
70
174
  markRead(args) {
71
175
  return this.simple('POST', 'mark_read', { ...args }, entities_1.StatusOkSchema);
72
176
  }
177
+ /**
178
+ * Marks a conversation as unread.
179
+ *
180
+ * @param args - The arguments for marking as unread.
181
+ * @param args.id - The conversation ID.
182
+ * @param args.objIndex - Optional index of the message to mark as last unread.
183
+ * @param args.messageId - Optional message ID to mark as last unread.
184
+ */
73
185
  markUnread(args) {
74
186
  return this.simple('POST', 'mark_unread', { ...args }, entities_1.StatusOkSchema);
75
187
  }
76
188
  /**
77
189
  * Returns unread conversations for a workspace, paired with the unread
78
190
  * version counter.
191
+ *
192
+ * @param workspaceId - The workspace ID.
193
+ * @returns Object containing the array of unread conversation references and a version counter.
79
194
  */
80
195
  getUnread(workspaceId) {
81
196
  return this.simple('GET', 'get_unread', { workspaceId }, GetUnreadResponseSchema);
82
197
  }
198
+ /**
199
+ * Clears all unread conversations for a workspace.
200
+ *
201
+ * @param workspaceId - The workspace ID.
202
+ */
83
203
  clearUnread(workspaceId) {
84
204
  return this.simple('GET', 'clear_unread', { workspaceId }, entities_1.StatusOkSchema);
85
205
  }
206
+ /**
207
+ * Mutes a conversation for a specified number of minutes.
208
+ * The user will receive no notifications from this conversation during that period.
209
+ *
210
+ * @param args - The arguments for muting a conversation.
211
+ * @param args.id - The conversation ID.
212
+ * @param args.minutes - Number of minutes to mute the conversation.
213
+ * @returns The updated conversation object.
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const conversation = await api.conversations.muteConversation({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', minutes: 30 })
218
+ * ```
219
+ */
86
220
  muteConversation(args) {
87
221
  return this.simple('GET', 'mute', { ...args }, entities_1.ConversationSchema);
88
222
  }
223
+ /**
224
+ * Unmutes a conversation.
225
+ *
226
+ * @param id - The conversation ID.
227
+ * @returns The updated conversation object.
228
+ */
89
229
  unmuteConversation(id) {
90
230
  return this.simple('GET', 'unmute', { id }, entities_1.ConversationSchema);
91
231
  }