@nurama/sdk 0.0.0-stage → 1.4.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 (225) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +1080 -2
  4. package/dist/BotClient.d.ts +66 -0
  5. package/dist/BotClient.d.ts.map +1 -0
  6. package/dist/BotClient.js +68 -0
  7. package/dist/BotClient.js.map +1 -0
  8. package/dist/NuramaClient.d.ts +480 -0
  9. package/dist/NuramaClient.d.ts.map +1 -0
  10. package/dist/NuramaClient.js +902 -0
  11. package/dist/NuramaClient.js.map +1 -0
  12. package/dist/browser/nurama-bot-sdk.js +12051 -0
  13. package/dist/browser/nurama-bot-sdk.min.js +1 -0
  14. package/dist/browser/nurama-sdk.js +12003 -0
  15. package/dist/browser/nurama-sdk.min.js +1 -0
  16. package/dist/routes/ai.d.ts +280 -0
  17. package/dist/routes/ai.d.ts.map +1 -0
  18. package/dist/routes/ai.js +173 -0
  19. package/dist/routes/ai.js.map +1 -0
  20. package/dist/routes/asset.d.ts +493 -0
  21. package/dist/routes/asset.d.ts.map +1 -0
  22. package/dist/routes/asset.js +848 -0
  23. package/dist/routes/asset.js.map +1 -0
  24. package/dist/routes/auth.d.ts +218 -0
  25. package/dist/routes/auth.d.ts.map +1 -0
  26. package/dist/routes/auth.js +454 -0
  27. package/dist/routes/auth.js.map +1 -0
  28. package/dist/routes/blogPosts.d.ts +17 -0
  29. package/dist/routes/blogPosts.d.ts.map +1 -0
  30. package/dist/routes/blogPosts.js +29 -0
  31. package/dist/routes/blogPosts.js.map +1 -0
  32. package/dist/routes/board.d.ts +187 -0
  33. package/dist/routes/board.d.ts.map +1 -0
  34. package/dist/routes/board.js +270 -0
  35. package/dist/routes/board.js.map +1 -0
  36. package/dist/routes/bot.d.ts +202 -0
  37. package/dist/routes/bot.d.ts.map +1 -0
  38. package/dist/routes/bot.js +229 -0
  39. package/dist/routes/bot.js.map +1 -0
  40. package/dist/routes/chat.d.ts +842 -0
  41. package/dist/routes/chat.d.ts.map +1 -0
  42. package/dist/routes/chat.js +863 -0
  43. package/dist/routes/chat.js.map +1 -0
  44. package/dist/routes/chatAi.d.ts +51 -0
  45. package/dist/routes/chatAi.d.ts.map +1 -0
  46. package/dist/routes/chatAi.js +109 -0
  47. package/dist/routes/chatAi.js.map +1 -0
  48. package/dist/routes/config.d.ts +11 -0
  49. package/dist/routes/config.d.ts.map +1 -0
  50. package/dist/routes/config.js +24 -0
  51. package/dist/routes/config.js.map +1 -0
  52. package/dist/routes/convo.d.ts +169 -0
  53. package/dist/routes/convo.d.ts.map +1 -0
  54. package/dist/routes/convo.js +284 -0
  55. package/dist/routes/convo.js.map +1 -0
  56. package/dist/routes/credits.d.ts +82 -0
  57. package/dist/routes/credits.d.ts.map +1 -0
  58. package/dist/routes/credits.js +49 -0
  59. package/dist/routes/credits.js.map +1 -0
  60. package/dist/routes/device.d.ts +74 -0
  61. package/dist/routes/device.d.ts.map +1 -0
  62. package/dist/routes/device.js +122 -0
  63. package/dist/routes/device.js.map +1 -0
  64. package/dist/routes/folder.d.ts +75 -0
  65. package/dist/routes/folder.d.ts.map +1 -0
  66. package/dist/routes/folder.js +99 -0
  67. package/dist/routes/folder.js.map +1 -0
  68. package/dist/routes/invite.d.ts +61 -0
  69. package/dist/routes/invite.d.ts.map +1 -0
  70. package/dist/routes/invite.js +86 -0
  71. package/dist/routes/invite.js.map +1 -0
  72. package/dist/routes/joinLink.d.ts +88 -0
  73. package/dist/routes/joinLink.d.ts.map +1 -0
  74. package/dist/routes/joinLink.js +205 -0
  75. package/dist/routes/joinLink.js.map +1 -0
  76. package/dist/routes/membership.d.ts +116 -0
  77. package/dist/routes/membership.d.ts.map +1 -0
  78. package/dist/routes/membership.js +183 -0
  79. package/dist/routes/membership.js.map +1 -0
  80. package/dist/routes/notification.d.ts +103 -0
  81. package/dist/routes/notification.d.ts.map +1 -0
  82. package/dist/routes/notification.js +89 -0
  83. package/dist/routes/notification.js.map +1 -0
  84. package/dist/routes/oauthGrant.d.ts +45 -0
  85. package/dist/routes/oauthGrant.d.ts.map +1 -0
  86. package/dist/routes/oauthGrant.js +32 -0
  87. package/dist/routes/oauthGrant.js.map +1 -0
  88. package/dist/routes/payment.d.ts +56 -0
  89. package/dist/routes/payment.d.ts.map +1 -0
  90. package/dist/routes/payment.js +78 -0
  91. package/dist/routes/payment.js.map +1 -0
  92. package/dist/routes/product.d.ts +43 -0
  93. package/dist/routes/product.d.ts.map +1 -0
  94. package/dist/routes/product.js +53 -0
  95. package/dist/routes/product.js.map +1 -0
  96. package/dist/routes/project.d.ts +821 -0
  97. package/dist/routes/project.d.ts.map +1 -0
  98. package/dist/routes/project.js +1153 -0
  99. package/dist/routes/project.js.map +1 -0
  100. package/dist/routes/public.d.ts +269 -0
  101. package/dist/routes/public.d.ts.map +1 -0
  102. package/dist/routes/public.js +412 -0
  103. package/dist/routes/public.js.map +1 -0
  104. package/dist/routes/scratch.d.ts +70 -0
  105. package/dist/routes/scratch.d.ts.map +1 -0
  106. package/dist/routes/scratch.js +67 -0
  107. package/dist/routes/scratch.js.map +1 -0
  108. package/dist/routes/settings.d.ts +102 -0
  109. package/dist/routes/settings.d.ts.map +1 -0
  110. package/dist/routes/settings.js +94 -0
  111. package/dist/routes/settings.js.map +1 -0
  112. package/dist/routes/shortlink.d.ts +79 -0
  113. package/dist/routes/shortlink.d.ts.map +1 -0
  114. package/dist/routes/shortlink.js +25 -0
  115. package/dist/routes/shortlink.js.map +1 -0
  116. package/dist/routes/socket.d.ts +108 -0
  117. package/dist/routes/socket.d.ts.map +1 -0
  118. package/dist/routes/socket.js +573 -0
  119. package/dist/routes/socket.js.map +1 -0
  120. package/dist/routes/storage.d.ts +44 -0
  121. package/dist/routes/storage.d.ts.map +1 -0
  122. package/dist/routes/storage.js +49 -0
  123. package/dist/routes/storage.js.map +1 -0
  124. package/dist/routes/subscription.d.ts +184 -0
  125. package/dist/routes/subscription.d.ts.map +1 -0
  126. package/dist/routes/subscription.js +219 -0
  127. package/dist/routes/subscription.js.map +1 -0
  128. package/dist/routes/supportChat.d.ts +40 -0
  129. package/dist/routes/supportChat.d.ts.map +1 -0
  130. package/dist/routes/supportChat.js +53 -0
  131. package/dist/routes/supportChat.js.map +1 -0
  132. package/dist/routes/supportTicket.d.ts +89 -0
  133. package/dist/routes/supportTicket.d.ts.map +1 -0
  134. package/dist/routes/supportTicket.js +54 -0
  135. package/dist/routes/supportTicket.js.map +1 -0
  136. package/dist/routes/tag.d.ts +72 -0
  137. package/dist/routes/tag.d.ts.map +1 -0
  138. package/dist/routes/tag.js +81 -0
  139. package/dist/routes/tag.js.map +1 -0
  140. package/dist/routes/task.d.ts +252 -0
  141. package/dist/routes/task.d.ts.map +1 -0
  142. package/dist/routes/task.js +284 -0
  143. package/dist/routes/task.js.map +1 -0
  144. package/dist/routes/taskRelation.d.ts +80 -0
  145. package/dist/routes/taskRelation.d.ts.map +1 -0
  146. package/dist/routes/taskRelation.js +71 -0
  147. package/dist/routes/taskRelation.js.map +1 -0
  148. package/dist/routes/token.d.ts +97 -0
  149. package/dist/routes/token.d.ts.map +1 -0
  150. package/dist/routes/token.js +73 -0
  151. package/dist/routes/token.js.map +1 -0
  152. package/dist/routes/user.d.ts +112 -0
  153. package/dist/routes/user.d.ts.map +1 -0
  154. package/dist/routes/user.js +151 -0
  155. package/dist/routes/user.js.map +1 -0
  156. package/dist/routes/version.d.ts +42 -0
  157. package/dist/routes/version.d.ts.map +1 -0
  158. package/dist/routes/version.js +38 -0
  159. package/dist/routes/version.js.map +1 -0
  160. package/dist/routes/webhook.d.ts +170 -0
  161. package/dist/routes/webhook.d.ts.map +1 -0
  162. package/dist/routes/webhook.js +173 -0
  163. package/dist/routes/webhook.js.map +1 -0
  164. package/dist/routes/workspace.d.ts +120 -0
  165. package/dist/routes/workspace.d.ts.map +1 -0
  166. package/dist/routes/workspace.js +199 -0
  167. package/dist/routes/workspace.js.map +1 -0
  168. package/dist/utils/uploadSessionManager.d.ts +133 -0
  169. package/dist/utils/uploadSessionManager.d.ts.map +1 -0
  170. package/dist/utils/uploadSessionManager.js +321 -0
  171. package/dist/utils/uploadSessionManager.js.map +1 -0
  172. package/dist/utils/urlParams.d.ts +35 -0
  173. package/dist/utils/urlParams.d.ts.map +1 -0
  174. package/dist/utils/urlParams.js +146 -0
  175. package/dist/utils/urlParams.js.map +1 -0
  176. package/dist/version.d.ts +15 -0
  177. package/dist/version.d.ts.map +1 -0
  178. package/dist/version.js +12 -0
  179. package/dist/version.js.map +1 -0
  180. package/package.json +87 -3
  181. package/src/BotClient.ts +113 -0
  182. package/src/NuramaClient.ts +1253 -0
  183. package/src/bot-browser-entry.js +15 -0
  184. package/src/browser-entry.js +20 -0
  185. package/src/routes/ai.ts +378 -0
  186. package/src/routes/asset.ts +1104 -0
  187. package/src/routes/auth.ts +587 -0
  188. package/src/routes/blogPosts.ts +29 -0
  189. package/src/routes/board.ts +403 -0
  190. package/src/routes/bot.ts +356 -0
  191. package/src/routes/chat.ts +1292 -0
  192. package/src/routes/chatAi.ts +125 -0
  193. package/src/routes/config.ts +31 -0
  194. package/src/routes/convo.ts +321 -0
  195. package/src/routes/credits.ts +112 -0
  196. package/src/routes/device.ts +133 -0
  197. package/src/routes/folder.ts +154 -0
  198. package/src/routes/invite.ts +133 -0
  199. package/src/routes/joinLink.ts +233 -0
  200. package/src/routes/membership.ts +237 -0
  201. package/src/routes/notification.ts +166 -0
  202. package/src/routes/oauthGrant.ts +64 -0
  203. package/src/routes/payment.ts +104 -0
  204. package/src/routes/product.ts +67 -0
  205. package/src/routes/project.ts +1528 -0
  206. package/src/routes/public.ts +496 -0
  207. package/src/routes/scratch.ts +94 -0
  208. package/src/routes/settings.ts +152 -0
  209. package/src/routes/shortlink.ts +90 -0
  210. package/src/routes/socket.ts +757 -0
  211. package/src/routes/storage.ts +83 -0
  212. package/src/routes/subscription.ts +307 -0
  213. package/src/routes/supportChat.ts +62 -0
  214. package/src/routes/supportTicket.ts +114 -0
  215. package/src/routes/tag.ts +131 -0
  216. package/src/routes/task.ts +431 -0
  217. package/src/routes/taskRelation.ts +125 -0
  218. package/src/routes/token.ts +152 -0
  219. package/src/routes/user.ts +214 -0
  220. package/src/routes/version.ts +62 -0
  221. package/src/routes/webhook.ts +295 -0
  222. package/src/routes/workspace.ts +223 -0
  223. package/src/utils/uploadSessionManager.ts +407 -0
  224. package/src/utils/urlParams.ts +181 -0
  225. package/src/version.ts +22 -0
@@ -0,0 +1,863 @@
1
+ /**
2
+ * Defines chat-related methods for the NuramaClient.
3
+ * @param {NuramaClient} client - The NuramaClient instance.
4
+ * @returns {object} An object containing the chat-related methods.
5
+ */
6
+ export default function createChatMethods(client) {
7
+ return {
8
+ // --- Topic Chats ---
9
+ /**
10
+ * Creates a topic chat for a project or asset at a given visibility.
11
+ * Requires `canCreateCreatorChat` (visibility `creator`) or `canCreateReviewerChat`
12
+ * (visibility `reviewer`) on the topic resource. Although `visibility` is optional in
13
+ * the type, the permission check only passes when it is one of those two values, so
14
+ * omitting it results in 403.
15
+ * @param {CreateTopicChatData} data - `topicType` (`project` | `asset`), `topicId`, optional `subject` (max 100 chars) and `visibility`.
16
+ * @returns {Promise<ChatResponse>} The created chat.
17
+ */
18
+ async createTopicChat(data) {
19
+ return client._request({
20
+ method: 'POST',
21
+ endpoint: '/v1/chats/topic',
22
+ body: data,
23
+ sendJWT: true,
24
+ });
25
+ },
26
+ /**
27
+ * Retrieves the topic chat for a project, asset, public release or task, together
28
+ * with its most recent messages and their replies.
29
+ * Requires `canGetCreatorChat` or `canGetReviewerChat` on the chat, matching
30
+ * `params.visibility`. `replies` (default 10, max 100) and `sort` (default `{ id: -1 }`)
31
+ * are honoured, but `messages` is accepted and then not forwarded by the API handler,
32
+ * so 10 recent messages are always returned.
33
+ * @param {string} topicId - The ID of the topic resource (project, asset, public release or task).
34
+ * @param {GetChatByTopicIdParams} params - See GetChatByTopicIdParams. `topicType` is one of `project`, `asset`, `public`, `task`.
35
+ * @returns {Promise<ChatResponse>} The chat, including `recentMessages`.
36
+ * @throws {Error} 'topicId is required.' when `topicId` is falsy.
37
+ */
38
+ async getChatByTopicId(topicId, params) {
39
+ if (!topicId)
40
+ throw new Error('topicId is required.');
41
+ return client._request({
42
+ method: 'GET',
43
+ endpoint: `/v1/chats/topic/${topicId}`,
44
+ params: params,
45
+ sendJWT: true,
46
+ });
47
+ },
48
+ // --- Member Chats ---
49
+ /**
50
+ * Creates a member ("Team") chat in a workspace with the given members.
51
+ * Only `scopeType: 'workspace'` is accepted by the API: project-scoped member chats
52
+ * are deprecated and `social` is not supported yet, so both are rejected with 400
53
+ * even though the type still allows them. Requires `canCreateWorkspaceMemberChat` on
54
+ * the workspace. The caller is always added as the first member, every member must
55
+ * be chat-eligible in the scope (`membersInvalid` otherwise), and a random approved
56
+ * colour is assigned (the API also accepts an optional `color`, not exposed on this type).
57
+ * @param {CreateMemberChatData} data - `scopeType`, `scopeId`, `memberIds` and optional `subject` (max 100 chars).
58
+ * @returns {Promise<MemberChatResponse>} The created member chat.
59
+ */
60
+ async createMemberChat(data) {
61
+ return client._request({
62
+ method: 'POST',
63
+ endpoint: '/v1/chats/member',
64
+ body: data,
65
+ sendJWT: true,
66
+ });
67
+ },
68
+ /**
69
+ * Lists the member chats the caller belongs to, most recently updated first, each
70
+ * with its recent messages.
71
+ * Defaults to index pagination (`page`, `limit` max 20); pass `paginate: 'cursor'` for
72
+ * cursor pagination. `updatedBefore` is only accepted with index pagination,
73
+ * `recentMessages` caps the messages returned per chat (default and max 20), and
74
+ * `archived` narrows to chats the caller has (`true`) or has not (`false`) archived.
75
+ * `createdBefore` / `createdAfter` from DateRangeParams are not accepted by this
76
+ * endpoint and cause a 400.
77
+ * @param {GetUsersMemberChatsParams} [params] - See GetUsersMemberChatsParams.
78
+ * @returns {Promise<PaginatedResponse<MemberChatResponse>>} A paginated list of member chats.
79
+ */
80
+ async getUsersMemberChats(params) {
81
+ return client._request({
82
+ method: 'GET',
83
+ endpoint: '/v1/chats/member',
84
+ params: params,
85
+ sendJWT: true,
86
+ });
87
+ },
88
+ /**
89
+ * Retrieves a member chat by ID without its messages.
90
+ * The caller must be a member of the chat.
91
+ * @param {string} chatId - The ID of the member chat.
92
+ * @returns {Promise<MemberChatResponse>} The member chat with `participants`, `members` and `icon` populated.
93
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
94
+ */
95
+ async getMemberChat(chatId) {
96
+ if (!chatId)
97
+ throw new Error('chatId is required.');
98
+ return client._request({
99
+ method: 'GET',
100
+ endpoint: `/v1/chats/member/${chatId}`,
101
+ sendJWT: true,
102
+ });
103
+ },
104
+ /**
105
+ * Retrieves every project topic chat (creator/reviewer) the caller can
106
+ * access across all projects in a workspace, with the latest message and
107
+ * message count for each, ordered by most recent activity. Powers the
108
+ * workspace-level "Project Chat" list.
109
+ * Requires `canGetWorkspace` on the workspace; access to each project's chats is
110
+ * derived from the caller's inherited `canGetCreatorChat` / `canGetReviewerChat`.
111
+ * @param {string} workspaceId - The ID of the workspace.
112
+ * @returns {Promise<Array<object>>} An array of `{ project, visibility, chat }` entries; `chat.recentMessages` holds at most the latest message.
113
+ * @throws {Error} 'workspaceId is required.' when `workspaceId` is falsy.
114
+ */
115
+ async getWorkspaceProjectChats(workspaceId) {
116
+ if (!workspaceId)
117
+ throw new Error('workspaceId is required.');
118
+ return client._request({
119
+ method: 'GET',
120
+ endpoint: `/v1/chats/workspace/${workspaceId}/project-chats`,
121
+ sendJWT: true,
122
+ });
123
+ },
124
+ /**
125
+ * Updates a member chat's subject and/or colour.
126
+ * The caller must be a member of the chat. `subject` is limited to 100 characters
127
+ * and `color` must be one of the approved palette colours.
128
+ * @param {string} chatId - The ID of the member chat.
129
+ * @param {UpdateMemberChatData} data - The new `subject` and/or `color`.
130
+ * @returns {Promise<MemberChatResponse>} The updated member chat.
131
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
132
+ */
133
+ async updateMemberChat(chatId, data) {
134
+ if (!chatId)
135
+ throw new Error('chatId is required.');
136
+ return client._request({
137
+ method: 'PUT',
138
+ endpoint: `/v1/chats/member/${chatId}`,
139
+ body: data,
140
+ sendJWT: true,
141
+ });
142
+ },
143
+ /**
144
+ * Marks a member chat, its messages and its attachments for deletion.
145
+ * Only the chat's creator may delete it; other members receive 403. From the
146
+ * members' perspective the chat disappears immediately; the rows are removed later
147
+ * by the cleanup service.
148
+ * @param {string} chatId - The ID of the member chat.
149
+ * @returns {Promise<void>} Resolves with `null` (the API sends an empty body).
150
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
151
+ */
152
+ async deleteMemberChat(chatId) {
153
+ if (!chatId)
154
+ throw new Error('chatId is required.');
155
+ return client._request({
156
+ method: 'DELETE',
157
+ endpoint: `/v1/chats/member/${chatId}`,
158
+ sendJWT: true,
159
+ });
160
+ },
161
+ /**
162
+ * Archives a member chat for the calling user only.
163
+ * Adds the caller to the chat's `archivedBy` list; other members' view of the chat
164
+ * is unaffected. The caller must be a member of the chat.
165
+ * @param {string} chatId - The ID of the member chat.
166
+ * @returns {Promise<MemberChatResponse>} The updated member chat.
167
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
168
+ */
169
+ async archiveMemberChat(chatId) {
170
+ if (!chatId)
171
+ throw new Error('chatId is required.');
172
+ return client._request({
173
+ method: 'PUT',
174
+ endpoint: `/v1/chats/member/${chatId}/archive`,
175
+ sendJWT: true,
176
+ });
177
+ },
178
+ /**
179
+ * Unarchives a member chat for the calling user only.
180
+ * Removes the caller from the chat's `archivedBy` list. The caller must be a member
181
+ * of the chat.
182
+ * @param {string} chatId - The ID of the member chat.
183
+ * @returns {Promise<MemberChatResponse>} The updated member chat.
184
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
185
+ */
186
+ async unarchiveMemberChat(chatId) {
187
+ if (!chatId)
188
+ throw new Error('chatId is required.');
189
+ return client._request({
190
+ method: 'PUT',
191
+ endpoint: `/v1/chats/member/${chatId}/unarchive`,
192
+ sendJWT: true,
193
+ });
194
+ },
195
+ /**
196
+ * Creates an icon asset for a member chat and returns signed upload URLs for it.
197
+ * Any existing icon is marked for deletion. The caller must be a member of the chat;
198
+ * `sizeInMB` is capped at 10 and `name` at 100 characters. Upload the file to the
199
+ * returned `signedUrlData.urls` afterwards, exactly as for any asset upload.
200
+ * @param {string} chatId - The ID of the member chat.
201
+ * @param {UpdateMemberChatIconData} data - `name` (with extension), `checksum` (MD5 or SHA-256) and `sizeInMB`.
202
+ * @returns {Promise<{ chat: MemberChatResponse } & AttachmentUploadRecord>} The updated `chat` plus the created upload record. Note the record's fields (`asset`, `signedUrlData`, `status`, ...) are spread directly onto the response; there is no `iconData` key despite the declared type.
203
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
204
+ */
205
+ async updateMemberChatIcon(chatId, data) {
206
+ if (!chatId)
207
+ throw new Error('chatId is required.');
208
+ return client._request({
209
+ method: 'PUT',
210
+ endpoint: `/v1/chats/member/${chatId}/icon`,
211
+ body: data,
212
+ sendJWT: true,
213
+ });
214
+ },
215
+ /**
216
+ * Lists the members that can be added to an existing member chat, based on the chat's
217
+ * scope and the caller's role in it.
218
+ * The caller must be a member of the chat. For workspace-scoped chats the result is a
219
+ * flat array of memberships; for legacy project-scoped chats it is an
220
+ * `AddableMembersByScope` object.
221
+ * @param {string} chatId - The ID of the member chat.
222
+ * @returns {Promise<MemberResponse[] | AddableMembersByScope>} Addable memberships, each with its `user` populated.
223
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
224
+ */
225
+ async getAddableMembers(chatId) {
226
+ if (!chatId)
227
+ throw new Error('chatId is required.');
228
+ return client._request({
229
+ method: 'GET',
230
+ endpoint: `/v1/chats/member/members/${chatId}`,
231
+ sendJWT: true,
232
+ });
233
+ },
234
+ /**
235
+ * Lists the members addable to a NEW member chat, by scope, before the chat
236
+ * exists. Use this to populate the create-chat member picker — unlike the
237
+ * raw membership-list endpoints it isn't admin-gated, so non-admin members
238
+ * allowed to start a Team Chat still get the correct list.
239
+ * Requires `canCreateWorkspaceMemberChat` (or `canCreateProjectMemberChat`) on the
240
+ * scope. For `project` scope the result is an `AddableMembersByScope` object; note
241
+ * that project-scoped member chats can no longer be created.
242
+ * @param {'workspace' | 'project'} scopeType - Scope of the chat to create.
243
+ * @param {string} scopeId - ID of the scope resource.
244
+ * @returns {Promise<MemberResponse[] | AddableMembersByScope>} Addable memberships, each with its `user` populated.
245
+ * @throws {Error} 'scopeType is required.' or 'scopeId is required.' when either is falsy.
246
+ */
247
+ async getScopeAddableMembers(scopeType, scopeId) {
248
+ if (!scopeType)
249
+ throw new Error('scopeType is required.');
250
+ if (!scopeId)
251
+ throw new Error('scopeId is required.');
252
+ return client._request({
253
+ method: 'GET',
254
+ endpoint: '/v1/chats/member/addable',
255
+ params: { scopeType, scopeId },
256
+ sendJWT: true,
257
+ });
258
+ },
259
+ /**
260
+ * Adds users to a member chat by user ID.
261
+ * The caller must be a member of the chat, and every user must be chat-eligible in
262
+ * the chat's scope (`membersInvalid` otherwise). `memberIds` is not enforced by
263
+ * validation, but the request cannot succeed without it.
264
+ * @param {string} chatId - The ID of the member chat.
265
+ * @param {MemberIdList} data - `memberIds`: the user IDs to add.
266
+ * @returns {Promise<MemberChatResponse>} The updated member chat.
267
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
268
+ */
269
+ async addMembers(chatId, data) {
270
+ if (!chatId)
271
+ throw new Error('chatId is required.');
272
+ return client._request({
273
+ method: 'PUT',
274
+ endpoint: `/v1/chats/member/members/${chatId}`,
275
+ body: data,
276
+ sendJWT: true,
277
+ });
278
+ },
279
+ /**
280
+ * Removes users from a member chat by user ID.
281
+ * The caller must be a member of the chat. The chat's creator cannot be removed
282
+ * (`ownerCannotLeaveChat`) and unknown user IDs produce `userNotFound`. Sent as a
283
+ * DELETE with a JSON body.
284
+ * @param {string} chatId - The ID of the member chat.
285
+ * @param {MemberIdList} data - `memberIds`: the user IDs to remove.
286
+ * @returns {Promise<MemberChatResponse>} The updated member chat.
287
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
288
+ */
289
+ async removeMembers(chatId, data) {
290
+ if (!chatId)
291
+ throw new Error('chatId is required.');
292
+ return client._request({
293
+ method: 'DELETE',
294
+ endpoint: `/v1/chats/member/members/${chatId}`,
295
+ body: data,
296
+ sendJWT: true,
297
+ });
298
+ },
299
+ // --- Generic Chat Management ---
300
+ /**
301
+ * Retrieves a topic chat (project, asset, task or public) by ID without its messages.
302
+ * Requires `canGetCreatorChat` or `canGetReviewerChat` on the chat, matching its
303
+ * visibility. Only topic chats are served here; member chats are served by
304
+ * `getMemberChat` and a member chat ID yields `chatNotFound`.
305
+ * @param {string} chatId - The ID of the topic chat.
306
+ * @returns {Promise<ChatResponse>} The chat with `participants` populated.
307
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
308
+ */
309
+ async getChat(chatId) {
310
+ if (!chatId)
311
+ throw new Error('chatId is required.');
312
+ return client._request({
313
+ method: 'GET',
314
+ endpoint: `/v1/chats/${chatId}`,
315
+ sendJWT: true,
316
+ });
317
+ },
318
+ /**
319
+ * Updates the subject of a topic chat.
320
+ * Requires `canUpdateCreatorChat` or `canUpdateReviewerChat` on the chat, matching
321
+ * its visibility. `subject` is limited to 100 characters. For member chats use
322
+ * `updateMemberChat`.
323
+ * @param {string} chatId - The ID of the topic chat.
324
+ * @param {UpdateChatSubjectData} data - The new `subject`.
325
+ * @returns {Promise<ChatResponse>} The updated chat.
326
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
327
+ */
328
+ async updateChatSubject(chatId, data) {
329
+ if (!chatId)
330
+ throw new Error('chatId is required.');
331
+ return client._request({
332
+ method: 'PUT',
333
+ endpoint: `/v1/chats/${chatId}`,
334
+ body: data,
335
+ sendJWT: true,
336
+ });
337
+ },
338
+ /**
339
+ * Marks a topic chat for deletion.
340
+ * In practice this only succeeds for `user`-topic chats owned by the caller: project
341
+ * and asset topic chats are refused with `topicChatsMayNotBeDeleted`, and any other
342
+ * topic type with `unknownError`. Member chats are deleted with `deleteMemberChat`.
343
+ * @param {string} chatId - The ID of the chat.
344
+ * @returns {Promise<void>} Resolves with `null` (the API sends an empty body).
345
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
346
+ */
347
+ async deleteChat(chatId) {
348
+ if (!chatId)
349
+ throw new Error('chatId is required.');
350
+ return client._request({
351
+ method: 'DELETE',
352
+ endpoint: `/v1/chats/${chatId}`,
353
+ sendJWT: true,
354
+ });
355
+ },
356
+ // --- Messages ---
357
+ /**
358
+ * Posts a message to any chat type (topic, member, submission, AI, support).
359
+ * Either `content` (max 10,000 chars) or at least one attachment is required. API
360
+ * tokens need the `chat:write` scope (`tokenScopeMissing` / 403 otherwise); users
361
+ * need message-create permission on the chat, e.g. `canCreateCreatorChatMessage` /
362
+ * `canCreateReviewerChatMessage` for topic chats or membership for member chats.
363
+ * Limits: 6 attachments, 10 of each mention kind, 5 quotes, 5 link previews and
364
+ * 100 annotations. Mentioning users in topic/member/submission chats creates tasks
365
+ * and notifications for them. `pageContext` is only read by AI chats and ignored by
366
+ * every other chat type.
367
+ * @param {string} chatId - The ID of the chat to post in.
368
+ * @param {CreateMessageData} data - See CreateMessageData. `attachments` may mix upload-shape (`FileAttachmentData`) and scratch-shape (`ScratchAttachmentRef`) items.
369
+ * @returns {Promise<ChatMessageResponse>} The created message. When upload-shape attachments were sent it also carries `attachmentData` with the created assets and their signed upload URLs.
370
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
371
+ */
372
+ async createMessage(chatId, data) {
373
+ if (!chatId)
374
+ throw new Error('chatId is required.');
375
+ return client._request({
376
+ method: 'POST',
377
+ endpoint: `/v1/chats/${chatId}/new-message`,
378
+ body: data,
379
+ sendJWT: true,
380
+ });
381
+ },
382
+ /**
383
+ * Posts a message to an asset's chat at the given visibility, creating the chat first
384
+ * if it does not exist yet (asset chats are normally auto-created, so this mainly
385
+ * covers legacy assets).
386
+ * Only media assets are accepted (`assetInvalidFunctionType` / 404 otherwise).
387
+ * Requires both `canCreate{Creator|Reviewer}Chat` and
388
+ * `canCreate{Creator|Reviewer}ChatMessage` on the asset for the chosen visibility.
389
+ * The body follows the same rules as `createMessage`. The `params` argument is
390
+ * neither validated nor forwarded by the API handler, so the returned chat always
391
+ * carries 10 recent messages with 10 replies each, sorted `{ id: -1 }`.
392
+ * @param {string} assetId - The ID of the media asset.
393
+ * @param {'creator' | 'reviewer'} visibility - Which of the asset's two chats to post in.
394
+ * @param {CreateAssetChatAndMessageData} data - See CreateMessageData.
395
+ * @param {CreateAssetChatAndMessageParams} [params] - Accepted for backwards compatibility only; currently ignored by the API.
396
+ * @returns {Promise<any>} `{ chat, message }`: the chat re-read after the message landed (so `recentMessages` includes it) and the created message, which carries `attachmentData` when upload-shape attachments were sent.
397
+ * @throws {Error} 'assetId is required.' when `assetId` is falsy.
398
+ */
399
+ async createAssetChatAndMessage(assetId, visibility, data, params) {
400
+ if (!assetId)
401
+ throw new Error('assetId is required.');
402
+ return client._request({
403
+ method: 'POST',
404
+ endpoint: `/v1/chats/asset/${assetId}/${visibility}/new-message`,
405
+ body: data,
406
+ params: params, // Params for recent messages/replies included in response
407
+ sendJWT: true,
408
+ });
409
+ },
410
+ /**
411
+ * Lists a chat's active messages with their recent replies and populated
412
+ * attachments and mentions.
413
+ * Requires read access to the chat (`canGetChat`); API tokens need the `chat:read`
414
+ * scope (`tokenScopeMissing` / 403 otherwise). Defaults to index pagination (`page`,
415
+ * `limit` max 100, sort `{ id: -1 }`); pass `paginate: 'cursor'` for cursor
416
+ * pagination. `createdBefore` / `createdAfter` are only accepted with index
417
+ * pagination and `updatedBefore` is not accepted at all. `replyLimit` (default 10,
418
+ * max 100) sets the replies returned per message; `replies` is a deprecated alias
419
+ * that takes precedence over `replyLimit` whenever it is set to anything other than 10.
420
+ * @param {string} chatId - The ID of the chat.
421
+ * @param {GetMessagesParams} [params] - See GetMessagesParams.
422
+ * @returns {Promise<PaginatedResponse<ChatMessageResponse>>} A paginated list of messages.
423
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
424
+ */
425
+ async getMessages(chatId, params) {
426
+ if (!chatId)
427
+ throw new Error('chatId is required.');
428
+ return client._request({
429
+ method: 'GET',
430
+ endpoint: `/v1/chats/${chatId}/messages`,
431
+ params: params,
432
+ sendJWT: true,
433
+ });
434
+ },
435
+ /**
436
+ * Retrieves a single message by ID with its most recent replies.
437
+ * Requires read access to the message's chat (`canGetChatMessage`). `replies`
438
+ * defaults to 10 (max 100) and `sort` (default `{ id: -1 }`) orders the included replies.
439
+ * @param {string} messageId - The ID of the message.
440
+ * @param {GetMessageParams} [params] - See GetMessageParams.
441
+ * @returns {Promise<ChatMessageResponse>} The message.
442
+ * @throws {Error} 'messageId is required.' when `messageId` is falsy.
443
+ */
444
+ async getMessage(messageId, params) {
445
+ if (!messageId)
446
+ throw new Error('messageId is required.');
447
+ return client._request({
448
+ method: 'GET',
449
+ endpoint: `/v1/chats/message/${messageId}`,
450
+ params: params,
451
+ sendJWT: true,
452
+ });
453
+ },
454
+ /**
455
+ * Revises a message's content, mentions, quotes, annotations and link previews,
456
+ * keeping the previous version as a revision.
457
+ * Only the author may revise, and in topic/submission chats they also need
458
+ * `canUpdateOwnChatMessage`. Annotations are replaced, not merged: omit
459
+ * `annotations` to keep the current ones, send `[]` to remove them all.
460
+ * `linkPreviews` likewise replaces the stored previews. Same size limits as
461
+ * `createMessage`.
462
+ * @param {string} messageId - The ID of the message to revise.
463
+ * @param {ReviseMessageData} data - See ReviseMessageData.
464
+ * @returns {Promise<ChatMessageResponse>} The revised message.
465
+ * @throws {Error} 'messageId is required.' when `messageId` is falsy.
466
+ */
467
+ async reviseMessage(messageId, data) {
468
+ if (!messageId)
469
+ throw new Error('messageId is required.');
470
+ return client._request({
471
+ method: 'PUT',
472
+ endpoint: `/v1/chats/message/${messageId}`,
473
+ body: data,
474
+ sendJWT: true,
475
+ });
476
+ },
477
+ /**
478
+ * Marks a message for deletion.
479
+ * Only the author may delete, and in topic/submission chats they also need
480
+ * `canDeleteOwnChatMessage`. The row is removed later by the cleanup service.
481
+ * @param {string} messageId - The ID of the message.
482
+ * @returns {Promise<ChatMessageResponse>} The deleted message.
483
+ * @throws {Error} 'messageId is required.' when `messageId` is falsy.
484
+ */
485
+ async deleteMessage(messageId) {
486
+ if (!messageId)
487
+ throw new Error('messageId is required.');
488
+ return client._request({
489
+ method: 'DELETE',
490
+ endpoint: `/v1/chats/message/${messageId}`,
491
+ sendJWT: true,
492
+ });
493
+ },
494
+ // --- Replies ---
495
+ /**
496
+ * Lists the active replies to a message, with attachments populated.
497
+ * Requires read access to the message's chat (`canGetChatMessage`). Defaults to
498
+ * index pagination (`page`, `limit` max 100, sort `{ id: -1 }`); pass
499
+ * `paginate: 'cursor'` for cursor pagination. `createdBefore` / `createdAfter` are
500
+ * only accepted with index pagination and `updatedBefore` is not accepted at all.
501
+ * @param {string} messageId - The ID of the parent message.
502
+ * @param {GetRepliesParams} [params] - See GetRepliesParams.
503
+ * @returns {Promise<PaginatedResponse<ChatMessageResponse>>} A paginated list of replies.
504
+ * @throws {Error} 'messageId is required.' when `messageId` is falsy.
505
+ */
506
+ async getReplies(messageId, params) {
507
+ if (!messageId)
508
+ throw new Error('messageId is required.');
509
+ return client._request({
510
+ method: 'GET',
511
+ endpoint: `/v1/chats/message/${messageId}/replies`,
512
+ params: params,
513
+ sendJWT: true,
514
+ });
515
+ },
516
+ // --- Attachments ---
517
+ /**
518
+ * Creates attachment assets for an existing message and returns signed upload URLs
519
+ * for them.
520
+ * Only the message's author may attach, and in topic/submission chats they also
521
+ * need `canCreateAttachment`. Only image and video file names are accepted, each
522
+ * `checksum` must be a 32-64 character hex MD5/SHA-256 digest, `id` must be an
523
+ * integer no greater than 10, and the message may hold at most 6 attachments in
524
+ * total (`exceedsMaxAttachments`). The request is also checked against the
525
+ * workspace storage quota (`uploadRequestExceedsSubscription`).
526
+ * @param {string} messageId - The ID of the message.
527
+ * @param {FileAttachmentData[]} attachments - The files to attach; sent as the raw JSON body array.
528
+ * @returns {Promise<AttachmentResponse[]>} One record per input file: the input item plus `status` and, on success, `asset` and `signedUrlData` (or `error` on failure). Not a bare `Asset` as the declared type suggests.
529
+ * @throws {Error} 'messageId is required.' when `messageId` is falsy.
530
+ */
531
+ async addAttachments(messageId, attachments) {
532
+ if (!messageId)
533
+ throw new Error('messageId is required.');
534
+ return client._request({
535
+ method: 'POST',
536
+ endpoint: `/v1/chats/message/${messageId}/attachment/`,
537
+ body: attachments,
538
+ sendJWT: true,
539
+ });
540
+ },
541
+ /**
542
+ * Removes an attachment from a message and marks the asset for deletion.
543
+ * Only the author may remove attachments, and in topic/submission chats they also
544
+ * need `canDeleteOwnAttachment`. If the message is left with no content and no
545
+ * attachments it is marked for deletion as well, and the deleted message is returned.
546
+ * @param {string} messageId - The ID of the message.
547
+ * @param {string} assetId - The ID of the attached asset to remove.
548
+ * @returns {Promise<ChatMessageResponse>} The updated (or deleted) message.
549
+ * @throws {Error} 'messageId is required.' or 'assetId is required.' when either is falsy.
550
+ */
551
+ async removeAttachment(messageId, assetId) {
552
+ if (!messageId)
553
+ throw new Error('messageId is required.');
554
+ if (!assetId)
555
+ throw new Error('assetId is required.');
556
+ return client._request({
557
+ method: 'DELETE',
558
+ endpoint: `/v1/chats/message/${messageId}/attachment/${assetId}`,
559
+ sendJWT: true,
560
+ });
561
+ },
562
+ // --- Mentions ---
563
+ /**
564
+ * Lists the messages in which the caller was mentioned.
565
+ * Defaults to index pagination (`page`, `limit` max 100, sort `{ id: -1 }`); pass
566
+ * `paginate: 'cursor'` for cursor pagination. Filter with `chatId` and/or
567
+ * `authorId`. `createdBefore` is only accepted with index pagination;
568
+ * `createdAfter` and `updatedBefore` from DateRangeParams are not accepted by this
569
+ * endpoint and cause a 400.
570
+ * @param {GetUsersMentionsParams} [params] - See GetUsersMentionsParams.
571
+ * @returns {Promise<PaginatedResponse<ChatMessageResponse>>} A paginated list of messages.
572
+ */
573
+ async getMentions(params) {
574
+ return client._request({
575
+ method: 'GET',
576
+ endpoint: '/v1/chats/mentions',
577
+ params: params,
578
+ sendJWT: true,
579
+ });
580
+ },
581
+ // --- Summaries ---
582
+ // --- Reactions ---
583
+ /**
584
+ * Adds the caller's emoji reaction to a message, replacing any reaction they already
585
+ * had on it.
586
+ * Each user holds at most one reaction per message. Requires message-create
587
+ * permission on the chat (`canCreateReaction`). `emoji` must be 1-10 characters.
588
+ * @param {string} messageId - The ID of the message.
589
+ * @param {CreateReactionData} data - The `emoji` to react with.
590
+ * @returns {Promise<ChatMessageResponse>} The updated message, including `reactions`.
591
+ * @throws {Error} 'messageId is required.' when `messageId` is falsy.
592
+ */
593
+ async createReaction(messageId, data) {
594
+ if (!messageId)
595
+ throw new Error('messageId is required.');
596
+ return client._request({
597
+ method: 'POST',
598
+ endpoint: `/v1/chats/message/${messageId}/reaction`,
599
+ body: data,
600
+ sendJWT: true,
601
+ });
602
+ },
603
+ /**
604
+ * Removes the caller's own reaction from a message.
605
+ * Gated by the same permission as `createReaction`. Calling it when the caller has
606
+ * no reaction is a no-op that still returns the message.
607
+ * @param {string} messageId - The ID of the message.
608
+ * @returns {Promise<ChatMessageResponse>} The updated message.
609
+ * @throws {Error} 'messageId is required.' when `messageId` is falsy.
610
+ */
611
+ async removeReaction(messageId) {
612
+ if (!messageId)
613
+ throw new Error('messageId is required.');
614
+ return client._request({
615
+ method: 'DELETE',
616
+ endpoint: `/v1/chats/message/${messageId}/reaction`,
617
+ sendJWT: true,
618
+ });
619
+ },
620
+ // --- Follow/Unfollow ---
621
+ /**
622
+ * Adds the caller to a chat's following list so they are notified about new
623
+ * messages and updates.
624
+ * Works with topic, member and submission chats and is idempotent. Requires
625
+ * message-create permission on the chat (`canCreateChatMessage`).
626
+ * @param {string} chatId - The ID of the chat to follow.
627
+ * @returns {Promise<void>} Resolves once followed. The API sends an empty body; re-fetch the chat if you need its `following` list.
628
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
629
+ */
630
+ async followChat(chatId) {
631
+ if (!chatId)
632
+ throw new Error('chatId is required.');
633
+ await client._request({
634
+ method: 'PUT',
635
+ endpoint: `/v1/chats/${chatId}/follow`,
636
+ sendJWT: true,
637
+ });
638
+ },
639
+ /**
640
+ * Removes the caller from a chat's following list.
641
+ * Works with topic, member and submission chats and is idempotent. No chat
642
+ * permission is checked, so users can stop notifications for a chat they have
643
+ * since lost access to.
644
+ * @param {string} chatId - The ID of the chat to unfollow.
645
+ * @returns {Promise<void>} Resolves once unfollowed. The API sends an empty body.
646
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
647
+ */
648
+ async unfollowChat(chatId) {
649
+ if (!chatId)
650
+ throw new Error('chatId is required.');
651
+ await client._request({
652
+ method: 'PUT',
653
+ endpoint: `/v1/chats/${chatId}/unfollow`,
654
+ sendJWT: true,
655
+ });
656
+ },
657
+ // --- Mentionable Assets ---
658
+ /**
659
+ * Lists the active assets that can be mentioned (`{{assetMention:assetId}}`) in a chat.
660
+ * What is returned depends on the chat: project and asset topic chats return the
661
+ * project's assets at the chat's visibility; project-scoped member chats and
662
+ * submission chats return all of the project's assets; AI chats return the topic
663
+ * project's assets filtered to the caller's own visibility tiers; workspace/social
664
+ * member chats return an empty list. Requires read access to the chat
665
+ * (`canGetChatMentionableAssets`). Defaults to index pagination (`page`, `limit`
666
+ * max 100, sort `{ name: 1 }`); pass `paginate: 'cursor'` for cursor pagination.
667
+ * `startAt` / `includeStartAtRecord` are not accepted here.
668
+ * @param {string} chatId - The ID of the chat.
669
+ * @param {GetMentionableAssetsParams} [params] - See GetMentionableAssetsParams. `nameSearch` is a case-insensitive partial match.
670
+ * @returns {Promise<PaginatedResponse<Asset>>} A paginated list of assets.
671
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
672
+ */
673
+ async getMentionableAssets(chatId, params) {
674
+ if (!chatId)
675
+ throw new Error('chatId is required.');
676
+ return client._request({
677
+ method: 'GET',
678
+ endpoint: `/v1/chats/${chatId}/mentionable/assets`,
679
+ params: params,
680
+ sendJWT: true,
681
+ });
682
+ },
683
+ // --- Mentionable Folders ---
684
+ /**
685
+ * Lists the active folders that can be mentioned (`{{folderMention:folderId}}`) in a chat.
686
+ * What is returned depends on the chat: project and asset topic chats return the
687
+ * project's folders at the chat's visibility; project-scoped member chats return
688
+ * all of the project's folders; submission chats return the project's
689
+ * reviewer-visibility folders; AI chats return the topic project's folders filtered
690
+ * to the caller's own visibility tiers; workspace/social member chats return an
691
+ * empty list. Requires read access to the chat (`canGetChatMentionableFolders`).
692
+ * Defaults to index pagination (`page`, `limit` max 100, sort `{ name: 1 }`); pass
693
+ * `paginate: 'cursor'` for cursor pagination. `startAt` / `includeStartAtRecord`
694
+ * are not accepted here.
695
+ * @param {string} chatId - The ID of the chat.
696
+ * @param {GetMentionableFoldersParams} [params] - See GetMentionableFoldersParams. `nameSearch` is a case-insensitive partial match.
697
+ * @returns {Promise<PaginatedResponse<Folder>>} A paginated list of folders.
698
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
699
+ */
700
+ async getMentionableFolders(chatId, params) {
701
+ if (!chatId)
702
+ throw new Error('chatId is required.');
703
+ return client._request({
704
+ method: 'GET',
705
+ endpoint: `/v1/chats/${chatId}/mentionable/folders`,
706
+ params: params,
707
+ sendJWT: true,
708
+ });
709
+ },
710
+ // --- Mentionable Submissions ---
711
+ /**
712
+ * Lists the active submissions in a chat's project that can be mentioned
713
+ * (`{{submissionMention:submissionId}}`).
714
+ * The project is resolved from the chat (project/asset/task topic chats,
715
+ * project-scoped member chats, submission chats and project-scoped AI chats); chats
716
+ * without a project return an empty page. Requires read access to the chat
717
+ * (`canGetChatMentionableSubmissions`). Index pagination only (`page`, `limit` max
718
+ * 100, sort `{ createdAt: -1 }`, also sortable by `subject` and `lastMessageAt`);
719
+ * cursor-pagination params cause a 400.
720
+ * @param {string} chatId - The ID of the chat.
721
+ * @param {GetMentionableSubmissionsParams} [params] - See GetMentionableSubmissionsParams. `nameSearch` is a case-insensitive partial match on the subject.
722
+ * @returns {Promise<PaginatedResponse<MentionableSubmission>>} A paginated list of submissions.
723
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
724
+ */
725
+ async getMentionableSubmissions(chatId, params) {
726
+ if (!chatId)
727
+ throw new Error('chatId is required.');
728
+ return client._request({
729
+ method: 'GET',
730
+ endpoint: `/v1/chats/${chatId}/mentionable/submissions`,
731
+ params: params,
732
+ sendJWT: true,
733
+ });
734
+ },
735
+ // --- Mentionable Public collections ---
736
+ /**
737
+ * Lists the active public releases (share links) owned by a chat's project that can
738
+ * be mentioned (`{{publicMention:token}}`).
739
+ * The project is resolved from the chat exactly as for `getMentionableSubmissions`;
740
+ * chats without a project return an empty page. Requires read access to the chat
741
+ * (`canGetChatMentionablePublics`). Index pagination only (`page`, `limit` max 100,
742
+ * sort `{ createdAt: -1 }`, also sortable by `title` and `expires`);
743
+ * cursor-pagination params cause a 400.
744
+ * @param {string} chatId - The ID of the chat.
745
+ * @param {GetMentionablePublicsParams} [params] - See GetMentionablePublicsParams. `nameSearch` is a case-insensitive partial match on the title.
746
+ * @returns {Promise<PaginatedResponse<MentionablePublic>>} A paginated list of public releases; use each entry's `token` in the mention.
747
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
748
+ */
749
+ async getMentionablePublics(chatId, params) {
750
+ if (!chatId)
751
+ throw new Error('chatId is required.');
752
+ return client._request({
753
+ method: 'GET',
754
+ endpoint: `/v1/chats/${chatId}/mentionable/publics`,
755
+ params: params,
756
+ sendJWT: true,
757
+ });
758
+ },
759
+ // --- Mentionable Tasks (boards addon required) ---
760
+ /**
761
+ * Lists the board tasks that can be mentioned (`{{taskMention:taskId}}`) in a chat.
762
+ * Requires the workspace to have the `boards` capability (`capabilityNotAvailable`
763
+ * / 403 otherwise) and read access to the chat (`canGetChatMentionableTasks`).
764
+ * Project, asset and task topic chats return tasks in the project on boards whose
765
+ * visibility includes the chat's; project-scoped member chats return every board
766
+ * task in the project; submission chats return tasks on reviewer-visible boards;
767
+ * workspace/social member chats return an empty list. Legacy tasks without a board
768
+ * are never returned. Defaults to index pagination (`page`, `limit` max 100, sort
769
+ * `{ updatedAt: -1 }`); pass `paginate: 'cursor'` for cursor pagination.
770
+ * @param {string} chatId - The ID of the chat.
771
+ * @param {GetMentionableTasksParams} [params] - See GetMentionableTasksParams. `nameSearch` matches a subject substring, an exact task number or an exact task ID.
772
+ * @returns {Promise<PaginatedResponse<any>>} A paginated list of task summaries (`id`, `subject`, `taskNumber`, `status`, `projectId`, `boardId`, `assignedToId`, `createdAt`, `updatedAt`).
773
+ * @throws {Error} 'chatId is required.' when `chatId` is falsy.
774
+ */
775
+ async getMentionableTasks(chatId, params) {
776
+ if (!chatId)
777
+ throw new Error('chatId is required.');
778
+ return client._request({
779
+ method: 'GET',
780
+ endpoint: `/v1/chats/${chatId}/mentionable/tasks`,
781
+ params: params,
782
+ sendJWT: true,
783
+ });
784
+ },
785
+ // --- Highlighting ---
786
+ /**
787
+ * Highlights a message, recording the caller as the highlighter.
788
+ * In topic and submission chats this requires `canHighlightMessage` on the chat; in
789
+ * member chats any member may highlight. For project and asset topic chats a system
790
+ * message is posted in the project chat of the same visibility, a
791
+ * `chatHighlightMessage` notification is sent and project members are emailed.
792
+ * @param {string} messageId - The ID of the message.
793
+ * @returns {Promise<ChatMessageResponse>} The highlighted message.
794
+ * @throws {Error} 'messageId is required.' when `messageId` is falsy.
795
+ */
796
+ async highlightMessage(messageId) {
797
+ if (!messageId)
798
+ throw new Error('messageId is required.');
799
+ return client._request({
800
+ method: 'PUT',
801
+ endpoint: `/v1/chats/message/${messageId}/highlight`,
802
+ sendJWT: true,
803
+ });
804
+ },
805
+ /**
806
+ * Removes the highlight from a message.
807
+ * Clears the highlighter fields and removes the associated system messages and
808
+ * notification. Same permission as `highlightMessage`.
809
+ * @param {string} messageId - The ID of the message.
810
+ * @returns {Promise<ChatMessageResponse>} The unhighlighted message.
811
+ * @throws {Error} 'messageId is required.' when `messageId` is falsy.
812
+ */
813
+ async unhighlightMessage(messageId) {
814
+ if (!messageId)
815
+ throw new Error('messageId is required.');
816
+ return client._request({
817
+ method: 'PUT',
818
+ endpoint: `/v1/chats/message/${messageId}/unhighlight`,
819
+ sendJWT: true,
820
+ });
821
+ },
822
+ // --- Short Links ---
823
+ /**
824
+ * Creates a short link for a chat message, or returns the existing one if the
825
+ * message already has a short link.
826
+ * Visibility is inherited from the parent chat (`creator` / `reviewer` for topic
827
+ * chats, `null` for member chats). Requires read access to the message's chat
828
+ * (`canCreateMessageShortLink`).
829
+ * @param {string} messageId - The ID of the message.
830
+ * @returns {Promise<{ code: string; shortUrl: string }>} The 8-character alphanumeric `code` and the complete `shortUrl`.
831
+ * @throws {Error} 'messageId is required.' when `messageId` is falsy.
832
+ */
833
+ async createMessageShortLink(messageId) {
834
+ if (!messageId)
835
+ throw new Error('messageId is required.');
836
+ return client._request({
837
+ method: 'POST',
838
+ endpoint: `/v1/chats/message/${messageId}/shortlink`,
839
+ sendJWT: true,
840
+ });
841
+ },
842
+ // --- Link Previews ---
843
+ /**
844
+ * Fetches Open Graph / meta-tag preview data for one to five URLs.
845
+ * Each preview carries an HMAC-SHA256 `signature` that must be passed back
846
+ * unchanged in `linkPreviews` when creating or revising a message, as the API
847
+ * verifies it to reject spoofed previews. Duplicate URLs are collapsed and URLs
848
+ * that fail validation, fetching or SSRF checks are omitted, so `previews` may be
849
+ * shorter than `urls`. Rate limited to 30 requests per minute per IP.
850
+ * @param {FetchLinkPreviewsData} data - `urls`: 1-5 absolute http(s) URLs, each at most 2048 characters.
851
+ * @returns {Promise<LinkPreviewResponse>} `{ previews }`.
852
+ */
853
+ async fetchLinkPreviews(data) {
854
+ return client._request({
855
+ method: 'POST',
856
+ endpoint: '/v1/link-preview',
857
+ body: data,
858
+ sendJWT: true,
859
+ });
860
+ },
861
+ };
862
+ }
863
+ //# sourceMappingURL=chat.js.map