@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,284 @@
1
+ export default function createTaskMethods(client) {
2
+ return {
3
+ /**
4
+ * Retrieves tasks assigned to the currently authenticated user.
5
+ * Supports filtering, sorting, and both index and cursor pagination.
6
+ * @param {GetTasksParams} [params] - Optional query parameters for filtering, sorting, and pagination.
7
+ * @returns {Promise<GetTasksResponse>} Paginated list of tasks.
8
+ */
9
+ async getMyTasks(params) {
10
+ return client._request({
11
+ method: 'GET',
12
+ endpoint: '/v1/tasks/',
13
+ params: params,
14
+ sendJWT: true,
15
+ });
16
+ },
17
+ /**
18
+ * Bulk-create one or more tasks under a single project — single
19
+ * round-trip replacement for the per-draft create loop the
20
+ * EnhancedTaskCreatorModal used to drive. Per-task partial success
21
+ * is returned in `results[]`; if `announce` is set and at least
22
+ * one task creates, the server also posts a Nu reply linking the
23
+ * new tasks back to the source message and rendering them as
24
+ * inline taskCards.
25
+ */
26
+ async bulkCreate(data) {
27
+ if (!data?.projectId)
28
+ throw new Error('projectId is required.');
29
+ if (!Array.isArray(data?.tasks) || data.tasks.length === 0) {
30
+ throw new Error('tasks is required and must contain at least one draft.');
31
+ }
32
+ return client._request({
33
+ method: 'POST',
34
+ endpoint: '/v1/tasks/bulk-create',
35
+ body: data,
36
+ sendJWT: true,
37
+ });
38
+ },
39
+ /**
40
+ * Updates the status of a specific task.
41
+ * Requires authentication and permission.
42
+ * @param {string} taskId - The ID of the task to update.
43
+ * @param {UpdateTaskStatusData} data - The new status for the task.
44
+ * @returns {Promise<Task>} The updated task object.
45
+ */
46
+ async updateTaskStatus(taskId, data) {
47
+ if (!taskId)
48
+ throw new Error('taskId is required.');
49
+ if (!data || !data.status)
50
+ throw new Error('status is required in the request body.');
51
+ return client._request({
52
+ method: 'PUT',
53
+ endpoint: `/v1/tasks/${taskId}`,
54
+ body: data,
55
+ sendJWT: true,
56
+ });
57
+ },
58
+ /**
59
+ * Toggles the acknowledgement status of a specific task.
60
+ * Requires authentication and permission.
61
+ * @param {string} taskId - The ID of the task to acknowledge/unacknowledge.
62
+ * @returns {Promise<Task>} The updated task object with the new acknowledgement status.
63
+ */
64
+ async acknowledgeTask(taskId) {
65
+ if (!taskId)
66
+ throw new Error('taskId is required.');
67
+ return client._request({
68
+ method: 'PUT',
69
+ endpoint: `/v1/tasks/acknowledge/${taskId}`,
70
+ sendJWT: true,
71
+ });
72
+ },
73
+ /**
74
+ * Retrieves the count of unacknowledged tasks for the current user within a specific project.
75
+ * Requires authentication.
76
+ * @param {string} projectId - The ID of the project.
77
+ * @returns {Promise<UnacknowledgedTaskCountResponse>} An object containing total, creator, and reviewer unacknowledged task counts.
78
+ */
79
+ async getUnacknowledgedTaskCount(projectId) {
80
+ if (!projectId)
81
+ throw new Error('projectId is required.');
82
+ return client._request({
83
+ method: 'GET',
84
+ endpoint: `/v1/tasks/unacknowledged/${projectId}`,
85
+ sendJWT: true,
86
+ });
87
+ },
88
+ /**
89
+ * Acknowledge every unacknowledged mention-task the current user has in a
90
+ * project. Idempotent server-side.
91
+ * @param {string} projectId - The ID of the project.
92
+ * @returns {Promise<AcknowledgeAllTasksResponse>} The number acknowledged and the remaining unacknowledged count.
93
+ */
94
+ async acknowledgeAllTasks(projectId) {
95
+ if (!projectId)
96
+ throw new Error('projectId is required.');
97
+ return client._request({
98
+ method: 'PUT',
99
+ endpoint: `/v1/tasks/acknowledge-all/${projectId}`,
100
+ sendJWT: true,
101
+ });
102
+ },
103
+ /**
104
+ * Add the calling user to a task's `followers` list.
105
+ * Idempotent server-side — following an already-followed task is a no-op
106
+ * and still returns the current task.
107
+ * @param taskId - The ID of the task to follow.
108
+ * @returns The updated task with the new followers array.
109
+ */
110
+ async followTask(taskId) {
111
+ if (!taskId)
112
+ throw new Error('taskId is required.');
113
+ return client._request({
114
+ method: 'PUT',
115
+ endpoint: `/v1/tasks/${taskId}/follow`,
116
+ sendJWT: true,
117
+ });
118
+ },
119
+ /**
120
+ * Remove the calling user from a task's `followers` list.
121
+ * Idempotent server-side — unfollowing a task you don't follow is a
122
+ * no-op and still returns the current task.
123
+ * @param taskId - The ID of the task to unfollow.
124
+ * @returns The updated task with the new followers array.
125
+ */
126
+ async unfollowTask(taskId) {
127
+ if (!taskId)
128
+ throw new Error('taskId is required.');
129
+ return client._request({
130
+ method: 'PUT',
131
+ endpoint: `/v1/tasks/${taskId}/unfollow`,
132
+ sendJWT: true,
133
+ });
134
+ },
135
+ /**
136
+ * Permanently delete a task. Gated server-side by
137
+ * `canRemove{Visibility}BoardTask` for at least one of the parent
138
+ * board's visibility tiers (see `boardPermission('Remove', 'BoardTask')`).
139
+ *
140
+ * Returns void; the server responds with 204 No Content.
141
+ *
142
+ * @param taskId - The ID of the task to delete.
143
+ */
144
+ async deleteTask(taskId) {
145
+ if (!taskId)
146
+ throw new Error('taskId is required.');
147
+ return client._request({
148
+ method: 'DELETE',
149
+ endpoint: `/v1/tasks/${taskId}`,
150
+ sendJWT: true,
151
+ });
152
+ },
153
+ /**
154
+ * Retrieves the event log for a specific task.
155
+ * Returns paginated events in reverse chronological order with populated actor info.
156
+ * @param {string} taskId - The ID of the task.
157
+ * @param {GetTaskEventsParams} [params] - Optional pagination, sort, search, and filter params.
158
+ * @returns {Promise<GetTaskEventsResponse>} Paginated list of task events.
159
+ */
160
+ async getTaskEvents(taskId, params) {
161
+ if (!taskId)
162
+ throw new Error('taskId is required.');
163
+ return client._request({
164
+ method: 'GET',
165
+ endpoint: `/v1/tasks/${taskId}/events`,
166
+ params,
167
+ sendJWT: true,
168
+ });
169
+ },
170
+ // ========================================================================
171
+ // Task details, links and tags
172
+ // ========================================================================
173
+ /**
174
+ * Update a board task's subject, description, assignee or status.
175
+ * Requires the boards capability and board-task write permission.
176
+ * @param {string} taskId - The task ID.
177
+ * @param {UpdateTaskDetailsData} data - Fields to change.
178
+ * @returns {Promise<Task>} The updated task.
179
+ * @throws {Error} 'taskId is required.' when `taskId` is falsy.
180
+ */
181
+ async updateTaskDetails(taskId, data) {
182
+ if (!taskId)
183
+ throw new Error('taskId is required.');
184
+ return client._request({
185
+ method: 'PUT',
186
+ endpoint: `/v1/tasks/${taskId}/details`,
187
+ body: data,
188
+ sendJWT: true,
189
+ });
190
+ },
191
+ /**
192
+ * Link two tasks with a typed relation (related, blocks, blockedBy, duplicate).
193
+ * The link is symmetrical: both tasks reflect the relationship.
194
+ * @param {string} taskId - The task ID.
195
+ * @param {LinkTaskData} data - `linkedTaskId` and `type`.
196
+ * @returns {Promise<TaskLink>} The created link.
197
+ * @throws {Error} 'taskId is required.' or 'linkedTaskId is required.'.
198
+ */
199
+ async linkTask(taskId, data) {
200
+ if (!taskId)
201
+ throw new Error('taskId is required.');
202
+ if (!data.linkedTaskId)
203
+ throw new Error('linkedTaskId is required.');
204
+ return client._request({
205
+ method: 'POST',
206
+ endpoint: `/v1/tasks/${taskId}/links`,
207
+ body: data,
208
+ sendJWT: true,
209
+ });
210
+ },
211
+ /**
212
+ * Remove a task-to-task link.
213
+ * @param {string} taskId - The task ID.
214
+ * @param {string} linkedTaskId - The other task in the link.
215
+ * @returns {Promise<void>} Resolves once removed.
216
+ * @throws {Error} 'taskId is required.' or 'linkedTaskId is required.'.
217
+ */
218
+ async unlinkTask(taskId, linkedTaskId) {
219
+ if (!taskId)
220
+ throw new Error('taskId is required.');
221
+ if (!linkedTaskId)
222
+ throw new Error('linkedTaskId is required.');
223
+ await client._request({
224
+ method: 'DELETE',
225
+ endpoint: `/v1/tasks/${taskId}/links/${linkedTaskId}`,
226
+ sendJWT: true,
227
+ });
228
+ },
229
+ /**
230
+ * List the tasks linked to a task, with the relation type of each link.
231
+ * @param {string} taskId - The task ID.
232
+ * @returns {Promise<TaskLink[]>} The task's links.
233
+ * @throws {Error} 'taskId is required.' when `taskId` is falsy.
234
+ */
235
+ async getTaskLinks(taskId) {
236
+ if (!taskId)
237
+ throw new Error('taskId is required.');
238
+ return client._request({
239
+ method: 'GET',
240
+ endpoint: `/v1/tasks/${taskId}/links`,
241
+ sendJWT: true,
242
+ });
243
+ },
244
+ /**
245
+ * Attach a project tag to a task.
246
+ * @param {string} taskId - The task ID.
247
+ * @param {string} tagId - The tag ID.
248
+ * @returns {Promise<Task>} The updated task.
249
+ * @throws {Error} 'taskId is required.' or 'tagId is required.'.
250
+ */
251
+ async tagTask(taskId, tagId) {
252
+ if (!taskId)
253
+ throw new Error('taskId is required.');
254
+ if (!tagId)
255
+ throw new Error('tagId is required.');
256
+ return client._request({
257
+ method: 'PUT',
258
+ endpoint: `/v1/tasks/${taskId}/tag`,
259
+ body: { tagId },
260
+ sendJWT: true,
261
+ });
262
+ },
263
+ /**
264
+ * Detach a project tag from a task.
265
+ * @param {string} taskId - The task ID.
266
+ * @param {string} tagId - The tag ID.
267
+ * @returns {Promise<Task>} The updated task.
268
+ * @throws {Error} 'taskId is required.' or 'tagId is required.'.
269
+ */
270
+ async untagTask(taskId, tagId) {
271
+ if (!taskId)
272
+ throw new Error('taskId is required.');
273
+ if (!tagId)
274
+ throw new Error('tagId is required.');
275
+ return client._request({
276
+ method: 'PUT',
277
+ endpoint: `/v1/tasks/${taskId}/untag`,
278
+ body: { tagId },
279
+ sendJWT: true,
280
+ });
281
+ },
282
+ };
283
+ }
284
+ //# sourceMappingURL=task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/routes/task.ts"],"names":[],"mappings":"AAwJA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,MAAoB;IAC5D,OAAO;QACL;;;;;eAKO;QACP,KAAK,CAAC,UAAU,CAAC,MAAuB;YACtC,O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,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;;;WAMG;QACH,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,KAAa;YAC3C,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACpD,IAAI,CAAC,KAAK;gBAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC,QAAQ,CAAO;gBAC3B,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,aAAa,MAAM,QAAQ;gBACrC,IAAI,EAAE,EAAE,KAAK,EAAE;gBACf,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,80 @@
1
+ import NuramaClient from '../NuramaClient.js';
2
+ export type RelationResourceType = 'chat' | 'chatMessage';
3
+ export interface TaskRelation {
4
+ id: string;
5
+ taskId: string;
6
+ resourceId: string;
7
+ resourceType: RelationResourceType;
8
+ creatorId: string;
9
+ createdAt: string;
10
+ relatedBy?: any;
11
+ chat?: {
12
+ id: string;
13
+ topicId: string;
14
+ topicType: string;
15
+ visibility: string;
16
+ chatType: string;
17
+ subject?: string | null;
18
+ publicId?: string | null;
19
+ } | null;
20
+ asset?: any | null;
21
+ submission?: {
22
+ id: string;
23
+ name: string;
24
+ } | null;
25
+ publicLink?: {
26
+ id: string;
27
+ name: string;
28
+ } | null;
29
+ message?: {
30
+ id: string;
31
+ chatId: string;
32
+ content: string | null;
33
+ authorId: string | null;
34
+ author: any;
35
+ mentions: string[];
36
+ assetMentions: string[];
37
+ folderMentions: string[];
38
+ createdAt: string;
39
+ } | null;
40
+ }
41
+ export interface PaginatedTaskRelations {
42
+ results: TaskRelation[];
43
+ page: number;
44
+ limit: number;
45
+ totalPages: number;
46
+ totalResults: number;
47
+ hasNextPage?: boolean;
48
+ hasPrevPage?: boolean;
49
+ }
50
+ export default function createTaskRelationMethods(client: NuramaClient): {
51
+ /**
52
+ * List the relations attached to a task — chat messages, chats, or
53
+ * other resources that reference this task as context.
54
+ */
55
+ getTaskRelations(taskId: string, params?: {
56
+ page?: number;
57
+ limit?: number;
58
+ }): Promise<PaginatedTaskRelations>;
59
+ /**
60
+ * Attach a related resource (chat message, chat, etc.) to a task,
61
+ * so the task surface shows the originating context.
62
+ */
63
+ createTaskRelation(taskId: string, data: {
64
+ resourceId: string;
65
+ resourceType: RelationResourceType;
66
+ }): Promise<TaskRelation>;
67
+ /** Detach a related resource from a task. */
68
+ deleteTaskRelation(taskId: string, relationId: string): Promise<void>;
69
+ /** List task relations referencing a chat (reverse lookup). */
70
+ getRelationsForChat(chatId: string, params?: {
71
+ page?: number;
72
+ limit?: number;
73
+ }): Promise<PaginatedTaskRelations>;
74
+ /** List task relations referencing a specific chat message (reverse lookup). */
75
+ getRelationsForMessage(messageId: string, params?: {
76
+ page?: number;
77
+ limit?: number;
78
+ }): Promise<PaginatedTaskRelations>;
79
+ };
80
+ //# sourceMappingURL=taskRelation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taskRelation.d.ts","sourceRoot":"","sources":["../../src/routes/taskRelation.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,aAAa,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,oBAAoB,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QAC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sB,CAAC;IAUlC;;;OAGG;+BAEO,MAAM,QACR;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,oBAAoB,CAAA;KAAE,GAC/D,OAAO,CAAC,YAAY,CAAC;IAYxB,6CAA6C;+BACZ,MAAM,cAAc,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3E,+DAA+D;gCAErD,MAAM,WACL;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACzC,OAAO,CAAC,sBAAsB,CAAC;IAUlC,gFAAgF;sCAEnE,MAAM,WACR;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACzC,OAAO,CAAC,sBAAsB,CAAC;EAUrC"}
@@ -0,0 +1,71 @@
1
+ export default function createTaskRelationMethods(client) {
2
+ return {
3
+ /**
4
+ * List the relations attached to a task — chat messages, chats, or
5
+ * other resources that reference this task as context.
6
+ */
7
+ async getTaskRelations(taskId, params) {
8
+ if (!taskId)
9
+ throw new Error('taskId is required.');
10
+ return client._request({
11
+ method: 'GET',
12
+ endpoint: `/v1/tasks/${taskId}/relations`,
13
+ params,
14
+ sendJWT: true,
15
+ });
16
+ },
17
+ /**
18
+ * Attach a related resource (chat message, chat, etc.) to a task,
19
+ * so the task surface shows the originating context.
20
+ */
21
+ async createTaskRelation(taskId, data) {
22
+ if (!taskId)
23
+ throw new Error('taskId is required.');
24
+ if (!data?.resourceId)
25
+ throw new Error('resourceId is required.');
26
+ if (!data?.resourceType)
27
+ throw new Error('resourceType is required.');
28
+ return client._request({
29
+ method: 'POST',
30
+ endpoint: `/v1/tasks/${taskId}/relations`,
31
+ body: data,
32
+ sendJWT: true,
33
+ });
34
+ },
35
+ /** Detach a related resource from a task. */
36
+ async deleteTaskRelation(taskId, relationId) {
37
+ if (!taskId)
38
+ throw new Error('taskId is required.');
39
+ if (!relationId)
40
+ throw new Error('relationId is required.');
41
+ return client._request({
42
+ method: 'DELETE',
43
+ endpoint: `/v1/tasks/${taskId}/relations/${relationId}`,
44
+ sendJWT: true,
45
+ });
46
+ },
47
+ /** List task relations referencing a chat (reverse lookup). */
48
+ async getRelationsForChat(chatId, params) {
49
+ if (!chatId)
50
+ throw new Error('chatId is required.');
51
+ return client._request({
52
+ method: 'GET',
53
+ endpoint: `/v1/chats/${chatId}/relations`,
54
+ params,
55
+ sendJWT: true,
56
+ });
57
+ },
58
+ /** List task relations referencing a specific chat message (reverse lookup). */
59
+ async getRelationsForMessage(messageId, params) {
60
+ if (!messageId)
61
+ throw new Error('messageId is required.');
62
+ return client._request({
63
+ method: 'GET',
64
+ endpoint: `/v1/chat-messages/${messageId}/relations`,
65
+ params,
66
+ sendJWT: true,
67
+ });
68
+ },
69
+ };
70
+ }
71
+ //# sourceMappingURL=taskRelation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taskRelation.js","sourceRoot":"","sources":["../../src/routes/taskRelation.ts"],"names":[],"mappings":"AA+CA,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,MAAoB;IACpE,OAAO;QACL;;;WAGG;QACH,KAAK,CAAC,gBAAgB,CACpB,MAAc,EACd,MAA0C;YAE1C,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACpD,OAAO,MAAM,CAAC,QAAQ,CAAyB;gBAC7C,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,aAAa,MAAM,YAAY;gBACzC,MAAM;gBACN,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;WAGG;QACH,KAAK,CAAC,kBAAkB,CACtB,MAAc,EACd,IAAgE;YAEhE,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACpD,IAAI,CAAC,IAAI,EAAE,UAAU;gBAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC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gBACN,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,97 @@
1
+ import NuramaClient from '../NuramaClient.js';
2
+ /**
3
+ * Personal Access Token kinds. v1 only mints `pat`; the rest are
4
+ * reserved for the future OAuth grant flow and are listed here so
5
+ * downstream code can switch on the kind without importing a server-
6
+ * side enum.
7
+ */
8
+ export type TokenKind = 'pat' | 'oauthAccess' | 'oauthRefresh' | 'botAccess';
9
+ /**
10
+ * Granted action verbs on a token. Mirrors the backend's
11
+ * `@config/tokenScopes` registry; adding a scope on the BE means
12
+ * adding it here too (or callers fall back to `string` when they
13
+ * accept arbitrary scopes from configuration).
14
+ */
15
+ export type TokenScope = 'chat:read' | 'chat:write' | 'tasks:read' | 'tasks:write' | 'assets:read' | 'assets:write' | 'projects:read' | 'projects:write' | 'workspaces:read' | 'workspaces:write' | 'convos:read' | 'convos:write' | 'notifications:read' | 'notifications:write' | 'ai:use';
16
+ /**
17
+ * The shape returned by `listTokens` and (without the `token` field)
18
+ * the metadata half of `createToken`. Never includes the raw secret —
19
+ * that is shown exactly once at creation time and is the caller's
20
+ * responsibility to capture.
21
+ */
22
+ export interface TokenSummary {
23
+ id: string;
24
+ name: string;
25
+ prefix: string;
26
+ scopes: TokenScope[];
27
+ kind: TokenKind;
28
+ lastUsed?: string | null;
29
+ expiresAt?: string | null;
30
+ createdAt: string;
31
+ }
32
+ export interface CreateTokenData {
33
+ /** Customer-facing label. 1–80 characters. */
34
+ name: string;
35
+ /** At least one scope. Validated against the backend registry. */
36
+ scopes: TokenScope[];
37
+ /** Optional ISO date. Null / omitted = non-expiring. */
38
+ expiresAt?: string | null;
39
+ }
40
+ export interface UpdateTokenScopesData {
41
+ /**
42
+ * The COMPLETE new scope set, not a delta — the same shape
43
+ * `createToken` takes, so what a token may do is always stated in
44
+ * full rather than accumulated through edits nobody can review.
45
+ * At least one scope.
46
+ */
47
+ scopes: TokenScope[];
48
+ }
49
+ export interface CreateTokenResponse extends TokenSummary {
50
+ /**
51
+ * The raw secret. Returned ONLY in this response. The server keeps a
52
+ * one-way hash and cannot recover this value — the customer must
53
+ * capture it immediately (typical pattern: reveal-once modal with a
54
+ * copy button).
55
+ */
56
+ token: string;
57
+ }
58
+ /**
59
+ * Personal Access Token surface — auth-gated, owner-scoped. Any
60
+ * logged-in user can mint, list, and revoke their own tokens; there
61
+ * is no admin-on-behalf surface here (admins managing bot keys do
62
+ * that via the `bot` methods).
63
+ */
64
+ export default function createTokenMethods(client: NuramaClient): {
65
+ /**
66
+ * Mint a new Personal Access Token for the calling user.
67
+ * The raw secret is in the response's `token` field — store it
68
+ * immediately, it cannot be retrieved again.
69
+ */
70
+ createToken(data: CreateTokenData): Promise<CreateTokenResponse>;
71
+ /**
72
+ * List the caller's Personal Access Tokens. Bot-access keys held
73
+ * by the same user (rare but possible — admin who's also a bot
74
+ * owner) are filtered out server-side and surface via the bot
75
+ * management screens instead.
76
+ */
77
+ listTokens(): Promise<TokenSummary[]>;
78
+ /**
79
+ * Replace the scopes on one of the caller's Personal Access Tokens.
80
+ *
81
+ * `scopes` is the complete new set, not a delta. This exists because
82
+ * the scope registry grows over time: a token minted before a scope
83
+ * existed cannot hold it, and without this the only remedy is minting
84
+ * a replacement and reconfiguring everywhere the old one is used.
85
+ *
86
+ * The change takes effect on the token's very next request. Scopes
87
+ * remain a ceiling, never a floor — widening a token never lets it do
88
+ * anything its owner cannot already do.
89
+ */
90
+ updateTokenScopes(tokenId: string, data: UpdateTokenScopesData): Promise<TokenSummary>;
91
+ /**
92
+ * Revoke one of the caller's Personal Access Tokens. The revocation
93
+ * is immediate — the token will return 401 on the very next request.
94
+ */
95
+ deleteToken(tokenId: string): Promise<void>;
96
+ };
97
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/routes/token.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB,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;;;OAWG;+BAC8B,MAAM,QAAQ,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC;IAU5F;;;OAGG;yBACwB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;EASpD"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Personal Access Token surface — auth-gated, owner-scoped. Any
3
+ * logged-in user can mint, list, and revoke their own tokens; there
4
+ * is no admin-on-behalf surface here (admins managing bot keys do
5
+ * that via the `bot` methods).
6
+ */
7
+ export default function createTokenMethods(client) {
8
+ return {
9
+ /**
10
+ * Mint a new Personal Access Token for the calling user.
11
+ * The raw secret is in the response's `token` field — store it
12
+ * immediately, it cannot be retrieved again.
13
+ */
14
+ async createToken(data) {
15
+ return client._request({
16
+ method: 'POST',
17
+ endpoint: '/v1/tokens',
18
+ body: data,
19
+ sendJWT: true,
20
+ });
21
+ },
22
+ /**
23
+ * List the caller's Personal Access Tokens. Bot-access keys held
24
+ * by the same user (rare but possible — admin who's also a bot
25
+ * owner) are filtered out server-side and surface via the bot
26
+ * management screens instead.
27
+ */
28
+ async listTokens() {
29
+ return client._request({
30
+ method: 'GET',
31
+ endpoint: '/v1/tokens',
32
+ sendJWT: true,
33
+ bypassCache: true,
34
+ });
35
+ },
36
+ /**
37
+ * Replace the scopes on one of the caller's Personal Access Tokens.
38
+ *
39
+ * `scopes` is the complete new set, not a delta. This exists because
40
+ * the scope registry grows over time: a token minted before a scope
41
+ * existed cannot hold it, and without this the only remedy is minting
42
+ * a replacement and reconfiguring everywhere the old one is used.
43
+ *
44
+ * The change takes effect on the token's very next request. Scopes
45
+ * remain a ceiling, never a floor — widening a token never lets it do
46
+ * anything its owner cannot already do.
47
+ */
48
+ async updateTokenScopes(tokenId, data) {
49
+ if (!tokenId)
50
+ throw new Error('tokenId is required.');
51
+ return client._request({
52
+ method: 'PATCH',
53
+ endpoint: `/v1/tokens/${tokenId}`,
54
+ body: data,
55
+ sendJWT: true,
56
+ });
57
+ },
58
+ /**
59
+ * Revoke one of the caller's Personal Access Tokens. The revocation
60
+ * is immediate — the token will return 401 on the very next request.
61
+ */
62
+ async deleteToken(tokenId) {
63
+ if (!tokenId)
64
+ throw new Error('tokenId is required.');
65
+ return client._request({
66
+ method: 'DELETE',
67
+ endpoint: `/v1/tokens/${tokenId}`,
68
+ sendJWT: true,
69
+ });
70
+ },
71
+ };
72
+ }
73
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/routes/token.ts"],"names":[],"mappings":"AA+EA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,MAAoB;IAC7D,OAAO;QACL;;;;WAIG;QACH,KAAK,CAAC,WAAW,CAAC,IAAqB;YACrC,OAAO,MAAM,CAAC,QAAQ,CAAsB;gBAC1C,MAAM,EAAE,MAAM;gBACd,QAAQ,EAAE,YAAY;gBACtB,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;;WAKG;QACH,KAAK,CAAC,UAAU;YACd,OAAO,MAAM,CAAC,QAAQ,CAAiB;gBACrC,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,IAAI;aAClB,CAAC,CAAC;QACL,CAAC;QAED;;;;;;;;;;;WAWG;QACH,KAAK,CAAC,iBAAiB,CAAC,OAAe,EAAE,IAA2B;YAClE,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;YACtD,OAAO,MAAM,CAAC,QAAQ,CAAe;gBACnC,MAAM,EAAE,OAAO;gBACf,QAAQ,EAAE,cAAc,OAAO,EAAE;gBACjC,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;WAGG;QACH,KAAK,CAAC,WAAW,CAAC,OAAe;YAC/B,IAAI,CAAC,OAA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