@doist/comms-sdk 0.0.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 (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -45
  3. package/dist/cjs/authentication.js +211 -0
  4. package/dist/cjs/clients/add-comment-helper.js +70 -0
  5. package/dist/cjs/clients/base-client.js +25 -0
  6. package/dist/cjs/clients/channels-client.js +200 -0
  7. package/dist/cjs/clients/comments-client.js +159 -0
  8. package/dist/cjs/clients/conversation-messages-client.js +158 -0
  9. package/dist/cjs/clients/conversations-client.js +243 -0
  10. package/dist/cjs/clients/groups-client.js +164 -0
  11. package/dist/cjs/clients/inbox-client.js +171 -0
  12. package/dist/cjs/clients/reactions-client.js +97 -0
  13. package/dist/cjs/clients/search-client.js +138 -0
  14. package/dist/cjs/clients/threads-client.js +330 -0
  15. package/dist/cjs/clients/users-client.js +326 -0
  16. package/dist/cjs/clients/workspace-users-client.js +240 -0
  17. package/dist/cjs/clients/workspaces-client.js +166 -0
  18. package/dist/cjs/comms-api.js +66 -0
  19. package/dist/cjs/consts/endpoints.js +32 -0
  20. package/dist/cjs/index.js +48 -0
  21. package/dist/cjs/package.json +1 -0
  22. package/dist/cjs/testUtils/msw-handlers.js +51 -0
  23. package/dist/cjs/testUtils/msw-setup.js +21 -0
  24. package/dist/cjs/testUtils/obsidian-fetch-adapter.js +53 -0
  25. package/dist/cjs/testUtils/test-defaults.js +104 -0
  26. package/dist/cjs/transport/fetch-with-retry.js +136 -0
  27. package/dist/cjs/transport/http-client.js +56 -0
  28. package/dist/cjs/transport/http-dispatcher.js +143 -0
  29. package/dist/cjs/types/api-version.js +8 -0
  30. package/dist/cjs/types/entities.js +411 -0
  31. package/dist/cjs/types/enums.js +37 -0
  32. package/dist/cjs/types/errors.js +12 -0
  33. package/dist/cjs/types/http.js +4 -0
  34. package/dist/cjs/types/index.js +22 -0
  35. package/dist/cjs/types/requests.js +116 -0
  36. package/dist/cjs/utils/case-conversion.js +54 -0
  37. package/dist/cjs/utils/index.js +19 -0
  38. package/dist/cjs/utils/timestamp-conversion.js +49 -0
  39. package/dist/cjs/utils/url-helpers.js +131 -0
  40. package/dist/cjs/utils/uuidv7.js +174 -0
  41. package/dist/esm/authentication.js +203 -0
  42. package/dist/esm/clients/add-comment-helper.js +67 -0
  43. package/dist/esm/clients/base-client.js +21 -0
  44. package/dist/esm/clients/channels-client.js +196 -0
  45. package/dist/esm/clients/comments-client.js +155 -0
  46. package/dist/esm/clients/conversation-messages-client.js +154 -0
  47. package/dist/esm/clients/conversations-client.js +239 -0
  48. package/dist/esm/clients/groups-client.js +160 -0
  49. package/dist/esm/clients/inbox-client.js +167 -0
  50. package/dist/esm/clients/reactions-client.js +93 -0
  51. package/dist/esm/clients/search-client.js +134 -0
  52. package/dist/esm/clients/threads-client.js +326 -0
  53. package/dist/esm/clients/users-client.js +322 -0
  54. package/dist/esm/clients/workspace-users-client.js +236 -0
  55. package/dist/esm/clients/workspaces-client.js +162 -0
  56. package/dist/esm/comms-api.js +62 -0
  57. package/dist/esm/consts/endpoints.js +28 -0
  58. package/dist/esm/index.js +17 -0
  59. package/dist/esm/testUtils/msw-handlers.js +45 -0
  60. package/dist/esm/testUtils/msw-setup.js +18 -0
  61. package/dist/esm/testUtils/obsidian-fetch-adapter.js +50 -0
  62. package/dist/esm/testUtils/test-defaults.js +101 -0
  63. package/dist/esm/transport/fetch-with-retry.js +133 -0
  64. package/dist/esm/transport/http-client.js +51 -0
  65. package/dist/esm/transport/http-dispatcher.js +104 -0
  66. package/dist/esm/types/api-version.js +5 -0
  67. package/dist/esm/types/entities.js +408 -0
  68. package/dist/esm/types/enums.js +34 -0
  69. package/dist/esm/types/errors.js +8 -0
  70. package/dist/esm/types/http.js +1 -0
  71. package/dist/esm/types/index.js +6 -0
  72. package/dist/esm/types/requests.js +113 -0
  73. package/dist/esm/utils/case-conversion.js +47 -0
  74. package/dist/esm/utils/index.js +3 -0
  75. package/dist/esm/utils/timestamp-conversion.js +45 -0
  76. package/dist/esm/utils/url-helpers.js +112 -0
  77. package/dist/esm/utils/uuidv7.js +163 -0
  78. package/dist/types/authentication.d.ts +160 -0
  79. package/dist/types/clients/add-comment-helper.d.ts +29 -0
  80. package/dist/types/clients/base-client.d.ts +28 -0
  81. package/dist/types/clients/channels-client.d.ts +208 -0
  82. package/dist/types/clients/comments-client.d.ts +224 -0
  83. package/dist/types/clients/conversation-messages-client.d.ts +198 -0
  84. package/dist/types/clients/conversations-client.d.ts +346 -0
  85. package/dist/types/clients/groups-client.d.ts +148 -0
  86. package/dist/types/clients/inbox-client.d.ts +96 -0
  87. package/dist/types/clients/reactions-client.d.ts +57 -0
  88. package/dist/types/clients/search-client.d.ts +70 -0
  89. package/dist/types/clients/threads-client.d.ts +536 -0
  90. package/dist/types/clients/users-client.d.ts +250 -0
  91. package/dist/types/clients/workspace-users-client.d.ts +147 -0
  92. package/dist/types/clients/workspaces-client.d.ts +152 -0
  93. package/dist/types/comms-api.d.ts +62 -0
  94. package/dist/types/consts/endpoints.d.ts +24 -0
  95. package/dist/types/index.d.ts +18 -0
  96. package/dist/types/testUtils/msw-handlers.d.ts +28 -0
  97. package/dist/types/testUtils/msw-setup.d.ts +1 -0
  98. package/dist/types/testUtils/obsidian-fetch-adapter.d.ts +29 -0
  99. package/dist/types/testUtils/test-defaults.d.ts +17 -0
  100. package/dist/types/transport/fetch-with-retry.d.ts +4 -0
  101. package/dist/types/transport/http-client.d.ts +13 -0
  102. package/dist/types/transport/http-dispatcher.d.ts +10 -0
  103. package/dist/types/types/api-version.d.ts +6 -0
  104. package/dist/types/types/entities.d.ts +1288 -0
  105. package/dist/types/types/enums.d.ts +55 -0
  106. package/dist/types/types/errors.d.ts +6 -0
  107. package/dist/types/types/http.d.ts +54 -0
  108. package/dist/types/types/index.d.ts +6 -0
  109. package/dist/types/types/requests.d.ts +366 -0
  110. package/dist/types/utils/case-conversion.d.ts +8 -0
  111. package/dist/types/utils/index.d.ts +3 -0
  112. package/dist/types/utils/timestamp-conversion.d.ts +13 -0
  113. package/dist/types/utils/url-helpers.d.ts +88 -0
  114. package/dist/types/utils/uuidv7.d.ts +40 -0
  115. package/package.json +91 -8
@@ -0,0 +1,346 @@
1
+ import { z } from 'zod';
2
+ import { type Conversation, type StatusOk, type UnreadConversation } from '../types/entities.js';
3
+ import type { AddConversationUserArgs, AddConversationUsersArgs, GetConversationsArgs, GetOrCreateConversationArgs, MuteConversationArgs, RemoveConversationUserArgs, RemoveConversationUsersArgs, UpdateConversationArgs } from '../types/requests.js';
4
+ import { BaseClient } from './base-client.js';
5
+ export declare const ConversationListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
6
+ id: z.ZodString;
7
+ workspaceId: z.ZodNumber;
8
+ userIds: z.ZodArray<z.ZodNumber>;
9
+ messageCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
10
+ lastObjIndex: z.ZodNumber;
11
+ snippet: z.ZodString;
12
+ snippetCreators: z.ZodArray<z.ZodNumber>;
13
+ lastActive: z.ZodDate;
14
+ mutedUntil: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
15
+ archived: z.ZodBoolean;
16
+ created: z.ZodDate;
17
+ creator: z.ZodNumber;
18
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ private: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
20
+ lastMessage: z.ZodOptional<z.ZodNullable<z.ZodObject<{
21
+ id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
22
+ content: z.ZodString;
23
+ creator: z.ZodNumber;
24
+ conversationId: z.ZodString;
25
+ posted: z.ZodDate;
26
+ systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
27
+ attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
28
+ attachmentId: z.ZodString;
29
+ urlType: z.ZodString;
30
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
+ fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
34
+ underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
37
+ imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
38
+ imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
39
+ duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
40
+ uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
+ videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
+ videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
44
+ }, z.core.$loose>>>>;
45
+ reactions: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodNumber>>>>;
46
+ actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
47
+ objIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
48
+ lastEdited: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
49
+ deleted: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
50
+ directGroupMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
51
+ directMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
52
+ version: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
53
+ workspaceId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
54
+ }, z.core.$strip>>>;
55
+ }, z.core.$strip>, z.ZodTransform<{
56
+ url: string;
57
+ id: string;
58
+ workspaceId: number;
59
+ userIds: number[];
60
+ lastObjIndex: number;
61
+ snippet: string;
62
+ snippetCreators: number[];
63
+ lastActive: Date;
64
+ archived: boolean;
65
+ created: Date;
66
+ creator: number;
67
+ messageCount?: number | null | undefined;
68
+ mutedUntil?: Date | null | undefined;
69
+ title?: string | null | undefined;
70
+ private?: boolean | null | undefined;
71
+ lastMessage?: {
72
+ id: string;
73
+ content: string;
74
+ creator: number;
75
+ conversationId: string;
76
+ posted: Date;
77
+ systemMessage?: unknown;
78
+ attachments?: {
79
+ [x: string]: unknown;
80
+ attachmentId: string;
81
+ urlType: string;
82
+ title?: string | null | undefined;
83
+ url?: string | null | undefined;
84
+ fileName?: string | null | undefined;
85
+ fileSize?: number | null | undefined;
86
+ underlyingType?: string | null | undefined;
87
+ description?: string | null | undefined;
88
+ image?: string | null | undefined;
89
+ imageWidth?: number | null | undefined;
90
+ imageHeight?: number | null | undefined;
91
+ duration?: string | null | undefined;
92
+ uploadState?: string | null | undefined;
93
+ video?: string | null | undefined;
94
+ videoType?: string | null | undefined;
95
+ videoAutoPlay?: boolean | null | undefined;
96
+ }[] | null | undefined;
97
+ reactions?: Record<string, number[]> | null | undefined;
98
+ actions?: unknown[] | null | undefined;
99
+ objIndex?: number | null | undefined;
100
+ lastEdited?: Date | null | undefined;
101
+ deleted?: boolean | null | undefined;
102
+ directGroupMentions?: string[] | null | undefined;
103
+ directMentions?: number[] | null | undefined;
104
+ version?: number | null | undefined;
105
+ workspaceId?: number | null | undefined;
106
+ } | null | undefined;
107
+ }, {
108
+ id: string;
109
+ workspaceId: number;
110
+ userIds: number[];
111
+ lastObjIndex: number;
112
+ snippet: string;
113
+ snippetCreators: number[];
114
+ lastActive: Date;
115
+ archived: boolean;
116
+ created: Date;
117
+ creator: number;
118
+ messageCount?: number | null | undefined;
119
+ mutedUntil?: Date | null | undefined;
120
+ title?: string | null | undefined;
121
+ private?: boolean | null | undefined;
122
+ lastMessage?: {
123
+ id: string;
124
+ content: string;
125
+ creator: number;
126
+ conversationId: string;
127
+ posted: Date;
128
+ systemMessage?: unknown;
129
+ attachments?: {
130
+ [x: string]: unknown;
131
+ attachmentId: string;
132
+ urlType: string;
133
+ title?: string | null | undefined;
134
+ url?: string | null | undefined;
135
+ fileName?: string | null | undefined;
136
+ fileSize?: number | null | undefined;
137
+ underlyingType?: string | null | undefined;
138
+ description?: string | null | undefined;
139
+ image?: string | null | undefined;
140
+ imageWidth?: number | null | undefined;
141
+ imageHeight?: number | null | undefined;
142
+ duration?: string | null | undefined;
143
+ uploadState?: string | null | undefined;
144
+ video?: string | null | undefined;
145
+ videoType?: string | null | undefined;
146
+ videoAutoPlay?: boolean | null | undefined;
147
+ }[] | null | undefined;
148
+ reactions?: Record<string, number[]> | null | undefined;
149
+ actions?: unknown[] | null | undefined;
150
+ objIndex?: number | null | undefined;
151
+ lastEdited?: Date | null | undefined;
152
+ deleted?: boolean | null | undefined;
153
+ directGroupMentions?: string[] | null | undefined;
154
+ directMentions?: number[] | null | undefined;
155
+ version?: number | null | undefined;
156
+ workspaceId?: number | null | undefined;
157
+ } | null | undefined;
158
+ }>>>;
159
+ /**
160
+ * Client for `/api/v1/conversations/`. `getOrCreate` requires an `id` (the
161
+ * SDK auto-generates one for new conversations); the backend dedupes on
162
+ * `userIds`, so an existing conversation will be returned with its own
163
+ * already-assigned `id` and your generated one is silently dropped.
164
+ */
165
+ export declare class ConversationsClient extends BaseClient {
166
+ /**
167
+ * Gets all conversations for a workspace.
168
+ *
169
+ * @param args - The arguments for getting conversations.
170
+ * @param args.workspaceId - The workspace ID.
171
+ * @param args.archived - Optional flag to include archived conversations.
172
+ * @returns An array of conversation objects.
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * const conversations = await api.conversations.getConversations({ workspaceId: 123 })
177
+ * conversations.forEach(c => console.log(c.title))
178
+ * ```
179
+ */
180
+ getConversations(args: GetConversationsArgs): Promise<Conversation[]>;
181
+ /**
182
+ * Gets a single conversation object by id.
183
+ *
184
+ * @param id - The conversation ID.
185
+ * @returns The conversation object.
186
+ */
187
+ getConversation(id: string): Promise<Conversation>;
188
+ /**
189
+ * Gets an existing 1:1 / group conversation with `userIds`, or creates a
190
+ * new one. `id` is auto-generated if not supplied — on dedupe, the
191
+ * backend returns the existing conversation's `id` instead.
192
+ *
193
+ * @param args - The arguments for getting or creating a conversation.
194
+ * @param args.workspaceId - The workspace ID.
195
+ * @param args.userIds - Array of user IDs to include in the conversation.
196
+ * @returns The conversation object (existing or newly created).
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * const conversation = await api.conversations.getOrCreateConversation({
201
+ * workspaceId: 123,
202
+ * userIds: [101, 202, 303],
203
+ * })
204
+ * ```
205
+ */
206
+ getOrCreateConversation(args: GetOrCreateConversationArgs): Promise<Conversation>;
207
+ /**
208
+ * Updates a conversation's title.
209
+ *
210
+ * @param args - The arguments for updating a conversation.
211
+ * @param args.id - The conversation ID.
212
+ * @param args.title - The new title for the conversation.
213
+ * @param args.archived - Optional flag to archive/unarchive the conversation.
214
+ * @returns The updated conversation object.
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * const conversation = await api.conversations.updateConversation({
219
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX42',
220
+ * title: 'New Title',
221
+ * })
222
+ * ```
223
+ */
224
+ updateConversation(args: UpdateConversationArgs): Promise<Conversation>;
225
+ /**
226
+ * Archives a conversation.
227
+ *
228
+ * @param id - The conversation ID.
229
+ * @returns The updated conversation object.
230
+ */
231
+ archiveConversation(id: string): Promise<Conversation>;
232
+ /**
233
+ * Unarchives a conversation.
234
+ *
235
+ * @param id - The conversation ID.
236
+ * @returns The updated conversation object.
237
+ */
238
+ unarchiveConversation(id: string): Promise<Conversation>;
239
+ /**
240
+ * Adds a user to a conversation.
241
+ *
242
+ * @param args - The arguments for adding a user.
243
+ * @param args.id - The conversation ID.
244
+ * @param args.userId - The user ID to add.
245
+ * @returns The updated conversation object.
246
+ */
247
+ addUser(args: AddConversationUserArgs): Promise<Conversation>;
248
+ /**
249
+ * Adds multiple users to a conversation.
250
+ *
251
+ * @param args - The arguments for adding users.
252
+ * @param args.id - The conversation ID.
253
+ * @param args.userIds - Array of user IDs to add.
254
+ * @returns The updated conversation object.
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * await api.conversations.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', userIds: [101, 202] })
259
+ * ```
260
+ */
261
+ addUsers(args: AddConversationUsersArgs): Promise<Conversation>;
262
+ /**
263
+ * Removes a user from a conversation.
264
+ *
265
+ * @param args - The arguments for removing a user.
266
+ * @param args.id - The conversation ID.
267
+ * @param args.userId - The user ID to remove.
268
+ * @returns The updated conversation object.
269
+ */
270
+ removeUser(args: RemoveConversationUserArgs): Promise<Conversation>;
271
+ /**
272
+ * Removes multiple users from a conversation.
273
+ *
274
+ * @param args - The arguments for removing users.
275
+ * @param args.id - The conversation ID.
276
+ * @param args.userIds - Array of user IDs to remove.
277
+ * @returns The updated conversation object.
278
+ */
279
+ removeUsers(args: RemoveConversationUsersArgs): Promise<Conversation>;
280
+ /**
281
+ * Marks a conversation as read.
282
+ *
283
+ * @param args - The arguments for marking as read.
284
+ * @param args.id - The conversation ID.
285
+ * @param args.objIndex - Optional index of the message to mark as last read.
286
+ * @param args.messageId - Optional message ID to mark as last read.
287
+ */
288
+ markRead(args: {
289
+ id: string;
290
+ objIndex?: number;
291
+ messageId?: string;
292
+ }): Promise<StatusOk>;
293
+ /**
294
+ * Marks a conversation as unread.
295
+ *
296
+ * @param args - The arguments for marking as unread.
297
+ * @param args.id - The conversation ID.
298
+ * @param args.objIndex - Optional index of the message to mark as last unread.
299
+ * @param args.messageId - Optional message ID to mark as last unread.
300
+ */
301
+ markUnread(args: {
302
+ id: string;
303
+ objIndex?: number;
304
+ messageId?: string;
305
+ }): Promise<StatusOk>;
306
+ /**
307
+ * Returns unread conversations for a workspace, paired with the unread
308
+ * version counter.
309
+ *
310
+ * @param workspaceId - The workspace ID.
311
+ * @returns Object containing the array of unread conversation references and a version counter.
312
+ */
313
+ getUnread(workspaceId: number): Promise<{
314
+ data: UnreadConversation[];
315
+ version: number;
316
+ }>;
317
+ /**
318
+ * Clears all unread conversations for a workspace.
319
+ *
320
+ * @param workspaceId - The workspace ID.
321
+ */
322
+ clearUnread(workspaceId: number): Promise<StatusOk>;
323
+ /**
324
+ * Mutes a conversation for a specified number of minutes.
325
+ * The user will receive no notifications from this conversation during that period.
326
+ *
327
+ * @param args - The arguments for muting a conversation.
328
+ * @param args.id - The conversation ID.
329
+ * @param args.minutes - Number of minutes to mute the conversation.
330
+ * @returns The updated conversation object.
331
+ *
332
+ * @example
333
+ * ```typescript
334
+ * const conversation = await api.conversations.muteConversation({ id: '7YpL3oZ4kZ9vP7Q1tR2sX42', minutes: 30 })
335
+ * ```
336
+ */
337
+ muteConversation(args: MuteConversationArgs): Promise<Conversation>;
338
+ /**
339
+ * Unmutes a conversation.
340
+ *
341
+ * @param id - The conversation ID.
342
+ * @returns The updated conversation object.
343
+ */
344
+ unmuteConversation(id: string): Promise<Conversation>;
345
+ private simple;
346
+ }
@@ -0,0 +1,148 @@
1
+ import { z } from 'zod';
2
+ import { type Group, type StatusOk } from '../types/entities.js';
3
+ import type { AddGroupUserArgs, AddGroupUsersArgs, RemoveGroupUserArgs, RemoveGroupUsersArgs } from '../types/requests.js';
4
+ import { BaseClient } from './base-client.js';
5
+ export declare const GroupListSchema: z.ZodArray<z.ZodObject<{
6
+ id: z.ZodString;
7
+ name: z.ZodString;
8
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
+ workspaceId: z.ZodNumber;
10
+ userIds: z.ZodArray<z.ZodNumber>;
11
+ version: z.ZodNumber;
12
+ }, z.core.$strip>>;
13
+ /**
14
+ * Client for `/api/v1/groups/`. The broadcast markers `EVERYONE` /
15
+ * `EVERYONE_IN_THREAD` are NOT addressable through these endpoints — they
16
+ * only appear as members of `direct_group_mentions` / `groups` lists on
17
+ * thread/comment writes.
18
+ *
19
+ * `getone` / `update` / `remove` and the member-management ops all require
20
+ * `workspace_id` alongside the group `id`.
21
+ */
22
+ export declare class GroupsClient extends BaseClient {
23
+ /**
24
+ * Gets all groups for a given workspace.
25
+ *
26
+ * @param workspaceId - The workspace ID.
27
+ * @returns An array of group objects.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const groups = await api.groups.getGroups(123)
32
+ * groups.forEach(g => console.log(g.name))
33
+ * ```
34
+ */
35
+ getGroups(workspaceId: number): Promise<Group[]>;
36
+ /**
37
+ * Gets a single group object by id. Requires `workspaceId`.
38
+ *
39
+ * @param args - The arguments for getting a group.
40
+ * @param args.id - The group ID.
41
+ * @param args.workspaceId - The workspace ID.
42
+ * @returns The group object.
43
+ */
44
+ getGroup(args: {
45
+ id: string;
46
+ workspaceId: number;
47
+ }): Promise<Group>;
48
+ /**
49
+ * Creates a new group. `id` is auto-generated if not supplied.
50
+ *
51
+ * @param args - The arguments for creating a group.
52
+ * @param args.workspaceId - The workspace ID.
53
+ * @param args.name - The group name.
54
+ * @param args.id - Optional caller-supplied group ID (for optimistic-UI workflows).
55
+ * @param args.description - Optional group description.
56
+ * @param args.userIds - Optional array of user IDs to add to the group.
57
+ * @returns The created group object.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const group = await api.groups.createGroup({
62
+ * workspaceId: 123,
63
+ * name: 'Engineering Team',
64
+ * userIds: [1, 2, 3],
65
+ * })
66
+ * ```
67
+ */
68
+ createGroup(args: {
69
+ workspaceId: number;
70
+ name: string;
71
+ id?: string;
72
+ description?: string;
73
+ userIds?: number[];
74
+ }): Promise<Group>;
75
+ /**
76
+ * Updates a group's properties. Requires `workspaceId`.
77
+ *
78
+ * @param args - The arguments for updating a group.
79
+ * @param args.id - The group ID.
80
+ * @param args.workspaceId - The workspace ID.
81
+ * @param args.name - Optional new group name.
82
+ * @param args.description - Optional new group description.
83
+ * @returns The updated group object.
84
+ */
85
+ updateGroup(args: {
86
+ id: string;
87
+ workspaceId: number;
88
+ name?: string;
89
+ description?: string;
90
+ }): Promise<Group>;
91
+ /**
92
+ * Permanently deletes a group. Requires `workspaceId`.
93
+ *
94
+ * @param args - The arguments for deleting a group.
95
+ * @param args.id - The group ID.
96
+ * @param args.workspaceId - The workspace ID.
97
+ */
98
+ deleteGroup(args: {
99
+ id: string;
100
+ workspaceId: number;
101
+ }): Promise<StatusOk>;
102
+ /**
103
+ * Adds a user to a group.
104
+ *
105
+ * @param args - The arguments for adding a user.
106
+ * @param args.id - The group ID.
107
+ * @param args.workspaceId - The workspace ID.
108
+ * @param args.userId - The user ID to add.
109
+ */
110
+ addUser(args: AddGroupUserArgs): Promise<StatusOk>;
111
+ /**
112
+ * Adds multiple users to a group.
113
+ *
114
+ * @param args - The arguments for adding users.
115
+ * @param args.id - The group ID.
116
+ * @param args.workspaceId - The workspace ID.
117
+ * @param args.userIds - Array of user IDs to add.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * await api.groups.addUsers({
122
+ * id: '7YpL3oZ4kZ9vP7Q1tR2sX45',
123
+ * workspaceId: 123,
124
+ * userIds: [101, 202, 303],
125
+ * })
126
+ * ```
127
+ */
128
+ addUsers(args: AddGroupUsersArgs): Promise<StatusOk>;
129
+ /**
130
+ * Removes a user from a group.
131
+ *
132
+ * @param args - The arguments for removing a user.
133
+ * @param args.id - The group ID.
134
+ * @param args.workspaceId - The workspace ID.
135
+ * @param args.userId - The user ID to remove.
136
+ */
137
+ removeUser(args: RemoveGroupUserArgs): Promise<StatusOk>;
138
+ /**
139
+ * Removes multiple users from a group.
140
+ *
141
+ * @param args - The arguments for removing users.
142
+ * @param args.id - The group ID.
143
+ * @param args.workspaceId - The workspace ID.
144
+ * @param args.userIds - Array of user IDs to remove.
145
+ */
146
+ removeUsers(args: RemoveGroupUsersArgs): Promise<StatusOk>;
147
+ private simple;
148
+ }
@@ -0,0 +1,96 @@
1
+ import { type InboxThread } from '../types/entities.js';
2
+ import type { ArchiveAllArgs, GetInboxArgs } from '../types/requests.js';
3
+ import { BaseClient } from './base-client.js';
4
+ /** Client for `/api/v1/inbox/`. */
5
+ export declare class InboxClient extends BaseClient {
6
+ /**
7
+ * Gets inbox items (threads).
8
+ *
9
+ * @param args - The arguments for getting inbox.
10
+ * @param args.workspaceId - The workspace ID.
11
+ * @param args.newerThan - Optional date to get items newer than.
12
+ * @param args.olderThan - Optional date to get items older than.
13
+ * @param args.limit - Optional limit on number of items returned.
14
+ * @param args.cursor - Optional cursor for pagination.
15
+ * @param args.archiveFilter - Optional filter: 'active' (default), 'archived', or 'all'.
16
+ * @returns Inbox threads.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const inbox = await api.inbox.getInbox({
21
+ * workspaceId: 123,
22
+ * newerThan: new Date('2024-01-01'),
23
+ * })
24
+ *
25
+ * // Include archived (done) items alongside active ones
26
+ * const allInbox = await api.inbox.getInbox({
27
+ * workspaceId: 123,
28
+ * archiveFilter: 'all',
29
+ * })
30
+ * ```
31
+ */
32
+ getInbox(args: GetInboxArgs): Promise<InboxThread[]>;
33
+ /**
34
+ * Gets unread count for inbox.
35
+ *
36
+ * @param workspaceId - The workspace ID.
37
+ * @returns The unread count.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const count = await api.inbox.getCount(123)
42
+ * console.log(`Unread items: ${count}`)
43
+ * ```
44
+ */
45
+ getCount(workspaceId: number): Promise<number>;
46
+ /**
47
+ * Archives a thread in the inbox.
48
+ *
49
+ * @param id - The thread ID.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * await api.inbox.archiveThread('7YpL3oZ4kZ9vP7Q1tR2sX3z')
54
+ * ```
55
+ */
56
+ archiveThread(id: string): Promise<void>;
57
+ /**
58
+ * Unarchives a thread in the inbox.
59
+ *
60
+ * @param id - The thread ID.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * await api.inbox.unarchiveThread('7YpL3oZ4kZ9vP7Q1tR2sX3z')
65
+ * ```
66
+ */
67
+ unarchiveThread(id: string): Promise<void>;
68
+ /**
69
+ * Marks all inbox items as read in a workspace.
70
+ *
71
+ * @param workspaceId - The workspace ID.
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * await api.inbox.markAllRead(123)
76
+ * ```
77
+ */
78
+ markAllRead(workspaceId: number): Promise<void>;
79
+ /**
80
+ * Archives all inbox items in a workspace.
81
+ *
82
+ * @param args - The arguments for archiving all.
83
+ * @param args.workspaceId - The workspace ID.
84
+ * @param args.channelIds - Optional array of channel IDs to filter by.
85
+ * @param args.olderThan - Optional date to filter items older than.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * await api.inbox.archiveAll({
90
+ * workspaceId: 123,
91
+ * olderThan: new Date('2024-01-01'),
92
+ * })
93
+ * ```
94
+ */
95
+ archiveAll(args: ArchiveAllArgs): Promise<void>;
96
+ }
@@ -0,0 +1,57 @@
1
+ import type { ReactionObject } from '../types/entities.js';
2
+ import type { AddReactionArgs, GetReactionsArgs, RemoveReactionArgs } from '../types/requests.js';
3
+ import { BaseClient } from './base-client.js';
4
+ /**
5
+ * Client for interacting with Comms reaction endpoints.
6
+ */
7
+ export declare class ReactionsClient extends BaseClient {
8
+ /**
9
+ * Adds an emoji reaction to a thread, comment, or conversation message.
10
+ *
11
+ * @param args - The arguments for adding a reaction.
12
+ * @param args.threadId - Optional thread ID.
13
+ * @param args.commentId - Optional comment ID.
14
+ * @param args.messageId - Optional message ID (for conversation messages).
15
+ * @param args.reaction - The reaction emoji to add.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * await api.reactions.add({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', reaction: '👍' })
20
+ * ```
21
+ */
22
+ add(args: AddReactionArgs): Promise<void>;
23
+ /**
24
+ * Gets reactions for a thread, comment, or conversation message.
25
+ *
26
+ * Returns an object with emoji reactions as keys and arrays of user IDs as
27
+ * values, or null if no reactions.
28
+ *
29
+ * @param args - The arguments for getting reactions.
30
+ * @param args.threadId - Optional thread ID.
31
+ * @param args.commentId - Optional comment ID.
32
+ * @param args.messageId - Optional message ID (for conversation messages).
33
+ * @returns A reaction object with emoji reactions as keys and arrays of user IDs as values, or null if no reactions.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const reactions = await api.reactions.get({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z' })
38
+ * // Returns: { "👍": [101, 202, 303], "❤️": [101, 202] }
39
+ * ```
40
+ */
41
+ get(args: GetReactionsArgs): Promise<ReactionObject>;
42
+ /**
43
+ * Removes an emoji reaction from a thread, comment, or conversation message.
44
+ *
45
+ * @param args - The arguments for removing a reaction.
46
+ * @param args.threadId - Optional thread ID.
47
+ * @param args.commentId - Optional comment ID.
48
+ * @param args.messageId - Optional message ID (for conversation messages).
49
+ * @param args.reaction - The reaction emoji to remove.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * await api.reactions.remove({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', reaction: '👍' })
54
+ * ```
55
+ */
56
+ remove(args: RemoveReactionArgs): Promise<void>;
57
+ }