@doist/comms-sdk 0.1.0-alpha.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 (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -0
  3. package/dist/cjs/authentication.js +211 -0
  4. package/dist/cjs/clients/add-comment-helper.js +53 -0
  5. package/dist/cjs/clients/base-client.js +27 -0
  6. package/dist/cjs/clients/channels-client.js +83 -0
  7. package/dist/cjs/clients/comments-client.js +93 -0
  8. package/dist/cjs/clients/conversation-messages-client.js +87 -0
  9. package/dist/cjs/clients/conversations-client.js +103 -0
  10. package/dist/cjs/clients/groups-client.js +71 -0
  11. package/dist/cjs/clients/inbox-client.js +98 -0
  12. package/dist/cjs/clients/reactions-client.js +59 -0
  13. package/dist/cjs/clients/search-client.js +88 -0
  14. package/dist/cjs/clients/threads-client.js +135 -0
  15. package/dist/cjs/clients/users-client.js +199 -0
  16. package/dist/cjs/clients/workspace-users-client.js +140 -0
  17. package/dist/cjs/clients/workspaces-client.js +93 -0
  18. package/dist/cjs/comms-api.js +65 -0
  19. package/dist/cjs/consts/endpoints.js +27 -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 +102 -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/entities.js +411 -0
  30. package/dist/cjs/types/enums.js +37 -0
  31. package/dist/cjs/types/errors.js +12 -0
  32. package/dist/cjs/types/http.js +4 -0
  33. package/dist/cjs/types/index.js +21 -0
  34. package/dist/cjs/types/requests.js +117 -0
  35. package/dist/cjs/utils/case-conversion.js +54 -0
  36. package/dist/cjs/utils/index.js +19 -0
  37. package/dist/cjs/utils/timestamp-conversion.js +49 -0
  38. package/dist/cjs/utils/url-helpers.js +131 -0
  39. package/dist/cjs/utils/uuidv7.js +174 -0
  40. package/dist/esm/authentication.js +203 -0
  41. package/dist/esm/clients/add-comment-helper.js +50 -0
  42. package/dist/esm/clients/base-client.js +23 -0
  43. package/dist/esm/clients/channels-client.js +79 -0
  44. package/dist/esm/clients/comments-client.js +89 -0
  45. package/dist/esm/clients/conversation-messages-client.js +83 -0
  46. package/dist/esm/clients/conversations-client.js +99 -0
  47. package/dist/esm/clients/groups-client.js +67 -0
  48. package/dist/esm/clients/inbox-client.js +94 -0
  49. package/dist/esm/clients/reactions-client.js +55 -0
  50. package/dist/esm/clients/search-client.js +84 -0
  51. package/dist/esm/clients/threads-client.js +131 -0
  52. package/dist/esm/clients/users-client.js +195 -0
  53. package/dist/esm/clients/workspace-users-client.js +136 -0
  54. package/dist/esm/clients/workspaces-client.js +89 -0
  55. package/dist/esm/comms-api.js +61 -0
  56. package/dist/esm/consts/endpoints.js +23 -0
  57. package/dist/esm/index.js +17 -0
  58. package/dist/esm/testUtils/msw-handlers.js +45 -0
  59. package/dist/esm/testUtils/msw-setup.js +18 -0
  60. package/dist/esm/testUtils/obsidian-fetch-adapter.js +50 -0
  61. package/dist/esm/testUtils/test-defaults.js +99 -0
  62. package/dist/esm/transport/fetch-with-retry.js +133 -0
  63. package/dist/esm/transport/http-client.js +51 -0
  64. package/dist/esm/transport/http-dispatcher.js +104 -0
  65. package/dist/esm/types/entities.js +408 -0
  66. package/dist/esm/types/enums.js +34 -0
  67. package/dist/esm/types/errors.js +8 -0
  68. package/dist/esm/types/http.js +1 -0
  69. package/dist/esm/types/index.js +5 -0
  70. package/dist/esm/types/requests.js +114 -0
  71. package/dist/esm/utils/case-conversion.js +47 -0
  72. package/dist/esm/utils/index.js +3 -0
  73. package/dist/esm/utils/timestamp-conversion.js +45 -0
  74. package/dist/esm/utils/url-helpers.js +112 -0
  75. package/dist/esm/utils/uuidv7.js +163 -0
  76. package/dist/types/authentication.d.ts +160 -0
  77. package/dist/types/clients/add-comment-helper.d.ts +12 -0
  78. package/dist/types/clients/base-client.d.ts +24 -0
  79. package/dist/types/clients/channels-client.d.ts +91 -0
  80. package/dist/types/clients/comments-client.d.ts +157 -0
  81. package/dist/types/clients/conversation-messages-client.d.ts +127 -0
  82. package/dist/types/clients/conversations-client.d.ts +206 -0
  83. package/dist/types/clients/groups-client.d.ts +55 -0
  84. package/dist/types/clients/inbox-client.d.ts +20 -0
  85. package/dist/types/clients/reactions-client.d.ts +19 -0
  86. package/dist/types/clients/search-client.d.ts +20 -0
  87. package/dist/types/clients/threads-client.d.ts +344 -0
  88. package/dist/types/clients/users-client.d.ts +123 -0
  89. package/dist/types/clients/workspace-users-client.d.ts +47 -0
  90. package/dist/types/clients/workspaces-client.d.ts +79 -0
  91. package/dist/types/comms-api.d.ts +59 -0
  92. package/dist/types/consts/endpoints.d.ts +19 -0
  93. package/dist/types/index.d.ts +18 -0
  94. package/dist/types/testUtils/msw-handlers.d.ts +28 -0
  95. package/dist/types/testUtils/msw-setup.d.ts +1 -0
  96. package/dist/types/testUtils/obsidian-fetch-adapter.d.ts +29 -0
  97. package/dist/types/testUtils/test-defaults.d.ts +16 -0
  98. package/dist/types/transport/fetch-with-retry.d.ts +4 -0
  99. package/dist/types/transport/http-client.d.ts +13 -0
  100. package/dist/types/transport/http-dispatcher.d.ts +10 -0
  101. package/dist/types/types/entities.d.ts +1288 -0
  102. package/dist/types/types/enums.d.ts +55 -0
  103. package/dist/types/types/errors.d.ts +6 -0
  104. package/dist/types/types/http.d.ts +54 -0
  105. package/dist/types/types/index.d.ts +5 -0
  106. package/dist/types/types/requests.d.ts +385 -0
  107. package/dist/types/utils/case-conversion.d.ts +8 -0
  108. package/dist/types/utils/index.d.ts +3 -0
  109. package/dist/types/utils/timestamp-conversion.d.ts +13 -0
  110. package/dist/types/utils/url-helpers.d.ts +88 -0
  111. package/dist/types/utils/uuidv7.d.ts +40 -0
  112. package/package.json +93 -0
@@ -0,0 +1,344 @@
1
+ import { z } from 'zod';
2
+ import { type Comment, type StatusOk, type Thread, type UnreadThread } from '../types/entities.js';
3
+ import type { CloseThreadArgs, CreateThreadArgs, GetThreadsArgs, MarkThreadReadArgs, MarkThreadUnreadArgs, MarkThreadUnreadForOthersArgs, MoveThreadToChannelArgs, MuteThreadArgs, ReopenThreadArgs, UpdateThreadArgs } from '../types/requests.js';
4
+ import { BaseClient } from './base-client.js';
5
+ export declare const ThreadListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
6
+ id: z.ZodString;
7
+ title: z.ZodString;
8
+ content: z.ZodString;
9
+ creator: z.ZodNumber;
10
+ creatorName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
+ channelId: z.ZodString;
12
+ workspaceId: z.ZodNumber;
13
+ actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
14
+ attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
15
+ attachmentId: z.ZodString;
16
+ urlType: z.ZodString;
17
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
21
+ underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
25
+ imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
26
+ duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
+ videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
+ videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
31
+ }, z.core.$loose>>>>;
32
+ commentCount: z.ZodNumber;
33
+ closed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
34
+ directGroupMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
35
+ directMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
36
+ groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
37
+ lastEdited: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
38
+ lastObjIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
39
+ lastUpdated: z.ZodDate;
40
+ mutedUntil: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
41
+ participants: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
42
+ pinned: z.ZodOptional<z.ZodBoolean>;
43
+ pinnedTs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
44
+ posted: z.ZodDate;
45
+ reactions: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
46
+ recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
47
+ responders: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
48
+ snippet: z.ZodString;
49
+ snippetCreator: z.ZodNumber;
50
+ snippetMaskAvatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ snippetMaskPoster: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
53
+ toEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
54
+ isArchived: z.ZodBoolean;
55
+ isSaved: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
56
+ inInbox: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
57
+ lastComment: z.ZodOptional<z.ZodNullable<z.ZodObject<{
58
+ id: z.ZodString;
59
+ content: z.ZodString;
60
+ creator: z.ZodNumber;
61
+ creatorName: z.ZodString;
62
+ threadId: z.ZodString;
63
+ channelId: z.ZodString;
64
+ posted: z.ZodDate;
65
+ systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
66
+ attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
67
+ attachmentId: z.ZodString;
68
+ urlType: z.ZodString;
69
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
+ fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
73
+ underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
74
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
75
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
76
+ imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
77
+ imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
78
+ duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
80
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
+ videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
83
+ }, z.core.$loose>>>>;
84
+ reactions: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodNumber>>>>;
85
+ actions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
86
+ objIndex: z.ZodNumber;
87
+ lastEdited: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
88
+ deleted: z.ZodBoolean;
89
+ deletedBy: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
90
+ directGroupMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
91
+ directMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
92
+ groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
93
+ recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
94
+ toEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
95
+ version: z.ZodNumber;
96
+ workspaceId: z.ZodNumber;
97
+ }, z.core.$strip>>>;
98
+ }, z.core.$strip>, z.ZodTransform<{
99
+ url: string;
100
+ id: string;
101
+ title: string;
102
+ content: string;
103
+ creator: number;
104
+ channelId: string;
105
+ workspaceId: number;
106
+ commentCount: number;
107
+ lastUpdated: Date;
108
+ posted: Date;
109
+ snippet: string;
110
+ snippetCreator: number;
111
+ isArchived: boolean;
112
+ creatorName?: string | null | undefined;
113
+ actions?: unknown[] | null | undefined;
114
+ attachments?: {
115
+ [x: string]: unknown;
116
+ attachmentId: string;
117
+ urlType: string;
118
+ title?: string | null | undefined;
119
+ url?: string | null | undefined;
120
+ fileName?: string | null | undefined;
121
+ fileSize?: number | null | undefined;
122
+ underlyingType?: string | null | undefined;
123
+ description?: string | null | undefined;
124
+ image?: string | null | undefined;
125
+ imageWidth?: number | null | undefined;
126
+ imageHeight?: number | null | undefined;
127
+ duration?: string | null | undefined;
128
+ uploadState?: string | null | undefined;
129
+ video?: string | null | undefined;
130
+ videoType?: string | null | undefined;
131
+ videoAutoPlay?: boolean | null | undefined;
132
+ }[] | null | undefined;
133
+ closed?: boolean | null | undefined;
134
+ directGroupMentions?: string[] | null | undefined;
135
+ directMentions?: number[] | null | undefined;
136
+ groups?: string[] | null | undefined;
137
+ lastEdited?: Date | null | undefined;
138
+ lastObjIndex?: number | null | undefined;
139
+ mutedUntil?: Date | null | undefined;
140
+ participants?: number[] | null | undefined;
141
+ pinned?: boolean | undefined;
142
+ pinnedTs?: number | null | undefined;
143
+ reactions?: Record<string, unknown> | null | undefined;
144
+ recipients?: number[] | null | undefined;
145
+ responders?: number[] | null | undefined;
146
+ snippetMaskAvatarUrl?: string | null | undefined;
147
+ snippetMaskPoster?: string | null | undefined;
148
+ systemMessage?: unknown;
149
+ toEmails?: string[] | null | undefined;
150
+ isSaved?: boolean | null | undefined;
151
+ inInbox?: boolean | null | undefined;
152
+ lastComment?: {
153
+ id: string;
154
+ content: string;
155
+ creator: number;
156
+ creatorName: string;
157
+ threadId: string;
158
+ channelId: string;
159
+ posted: Date;
160
+ objIndex: number;
161
+ deleted: boolean;
162
+ version: number;
163
+ workspaceId: number;
164
+ systemMessage?: unknown;
165
+ attachments?: {
166
+ [x: string]: unknown;
167
+ attachmentId: string;
168
+ urlType: string;
169
+ title?: string | null | undefined;
170
+ url?: string | null | undefined;
171
+ fileName?: string | null | undefined;
172
+ fileSize?: number | null | undefined;
173
+ underlyingType?: string | null | undefined;
174
+ description?: string | null | undefined;
175
+ image?: string | null | undefined;
176
+ imageWidth?: number | null | undefined;
177
+ imageHeight?: number | null | undefined;
178
+ duration?: string | null | undefined;
179
+ uploadState?: string | null | undefined;
180
+ video?: string | null | undefined;
181
+ videoType?: string | null | undefined;
182
+ videoAutoPlay?: boolean | null | undefined;
183
+ }[] | null | undefined;
184
+ reactions?: Record<string, number[]> | null | undefined;
185
+ actions?: unknown[] | null | undefined;
186
+ lastEdited?: Date | null | undefined;
187
+ deletedBy?: number | null | undefined;
188
+ directGroupMentions?: string[] | null | undefined;
189
+ directMentions?: number[] | null | undefined;
190
+ groups?: string[] | null | undefined;
191
+ recipients?: number[] | null | undefined;
192
+ toEmails?: string[] | null | undefined;
193
+ } | null | undefined;
194
+ }, {
195
+ id: string;
196
+ title: string;
197
+ content: string;
198
+ creator: number;
199
+ channelId: string;
200
+ workspaceId: number;
201
+ commentCount: number;
202
+ lastUpdated: Date;
203
+ posted: Date;
204
+ snippet: string;
205
+ snippetCreator: number;
206
+ isArchived: boolean;
207
+ creatorName?: string | null | undefined;
208
+ actions?: unknown[] | null | undefined;
209
+ attachments?: {
210
+ [x: string]: unknown;
211
+ attachmentId: string;
212
+ urlType: string;
213
+ title?: string | null | undefined;
214
+ url?: string | null | undefined;
215
+ fileName?: string | null | undefined;
216
+ fileSize?: number | null | undefined;
217
+ underlyingType?: string | null | undefined;
218
+ description?: string | null | undefined;
219
+ image?: string | null | undefined;
220
+ imageWidth?: number | null | undefined;
221
+ imageHeight?: number | null | undefined;
222
+ duration?: string | null | undefined;
223
+ uploadState?: string | null | undefined;
224
+ video?: string | null | undefined;
225
+ videoType?: string | null | undefined;
226
+ videoAutoPlay?: boolean | null | undefined;
227
+ }[] | null | undefined;
228
+ closed?: boolean | null | undefined;
229
+ directGroupMentions?: string[] | null | undefined;
230
+ directMentions?: number[] | null | undefined;
231
+ groups?: string[] | null | undefined;
232
+ lastEdited?: Date | null | undefined;
233
+ lastObjIndex?: number | null | undefined;
234
+ mutedUntil?: Date | null | undefined;
235
+ participants?: number[] | null | undefined;
236
+ pinned?: boolean | undefined;
237
+ pinnedTs?: number | null | undefined;
238
+ reactions?: Record<string, unknown> | null | undefined;
239
+ recipients?: number[] | null | undefined;
240
+ responders?: number[] | null | undefined;
241
+ snippetMaskAvatarUrl?: string | null | undefined;
242
+ snippetMaskPoster?: string | null | undefined;
243
+ systemMessage?: unknown;
244
+ toEmails?: string[] | null | undefined;
245
+ isSaved?: boolean | null | undefined;
246
+ inInbox?: boolean | null | undefined;
247
+ lastComment?: {
248
+ id: string;
249
+ content: string;
250
+ creator: number;
251
+ creatorName: string;
252
+ threadId: string;
253
+ channelId: string;
254
+ posted: Date;
255
+ objIndex: number;
256
+ deleted: boolean;
257
+ version: number;
258
+ workspaceId: number;
259
+ systemMessage?: unknown;
260
+ attachments?: {
261
+ [x: string]: unknown;
262
+ attachmentId: string;
263
+ urlType: string;
264
+ title?: string | null | undefined;
265
+ url?: string | null | undefined;
266
+ fileName?: string | null | undefined;
267
+ fileSize?: number | null | undefined;
268
+ underlyingType?: string | null | undefined;
269
+ description?: string | null | undefined;
270
+ image?: string | null | undefined;
271
+ imageWidth?: number | null | undefined;
272
+ imageHeight?: number | null | undefined;
273
+ duration?: string | null | undefined;
274
+ uploadState?: string | null | undefined;
275
+ video?: string | null | undefined;
276
+ videoType?: string | null | undefined;
277
+ videoAutoPlay?: boolean | null | undefined;
278
+ }[] | null | undefined;
279
+ reactions?: Record<string, number[]> | null | undefined;
280
+ actions?: unknown[] | null | undefined;
281
+ lastEdited?: Date | null | undefined;
282
+ deletedBy?: number | null | undefined;
283
+ directGroupMentions?: string[] | null | undefined;
284
+ directMentions?: number[] | null | undefined;
285
+ groups?: string[] | null | undefined;
286
+ recipients?: number[] | null | undefined;
287
+ toEmails?: string[] | null | undefined;
288
+ } | null | undefined;
289
+ }>>>;
290
+ /**
291
+ * Client for `/api/v1/threads/`. The SDK auto-generates the thread `id` on
292
+ * `createThread` when the caller doesn't supply one.
293
+ */
294
+ export declare class ThreadsClient extends BaseClient {
295
+ /**
296
+ * Lists threads. At least one of `channelId` / `workspaceId` is required.
297
+ * `newerThan` / `olderThan` (`Date`) are converted to the
298
+ * `newer_than_ts` / `older_than_ts` epoch-second params on the wire.
299
+ */
300
+ getThreads(args: GetThreadsArgs): Promise<Thread[]>;
301
+ /** Fetches a single thread by ID. */
302
+ getThread(id: string): Promise<Thread>;
303
+ /** Creates a new thread. `id` is auto-generated if not supplied. */
304
+ createThread(args: CreateThreadArgs): Promise<Thread>;
305
+ /** Partial update of an existing thread. */
306
+ updateThread(args: UpdateThreadArgs): Promise<Thread>;
307
+ /** Permanently deletes a thread. */
308
+ deleteThread(id: string): Promise<StatusOk>;
309
+ /** Saves a thread (formerly "star"). */
310
+ saveThread(id: string): Promise<StatusOk>;
311
+ /** Unsaves a thread (formerly "unstar"). */
312
+ unsaveThread(id: string): Promise<StatusOk>;
313
+ pinThread(id: string): Promise<StatusOk>;
314
+ unpinThread(id: string): Promise<StatusOk>;
315
+ /** Moves a thread to another channel. */
316
+ moveToChannel(args: MoveThreadToChannelArgs): Promise<Thread>;
317
+ markRead(args: MarkThreadReadArgs): Promise<StatusOk>;
318
+ markUnread(args: MarkThreadUnreadArgs): Promise<StatusOk>;
319
+ markUnreadForOthers(args: MarkThreadUnreadForOthersArgs): Promise<StatusOk>;
320
+ /**
321
+ * Marks every thread in a workspace or channel as read. Exactly one of
322
+ * `workspaceId` / `channelId` should be set.
323
+ */
324
+ markAllRead(args: {
325
+ workspaceId?: number;
326
+ channelId?: string;
327
+ }): Promise<StatusOk>;
328
+ clearUnread(workspaceId: number): Promise<StatusOk>;
329
+ /**
330
+ * Returns unread threads for a workspace, paired with the unread version
331
+ * counter and (optionally) the inbox unread count.
332
+ */
333
+ getUnread(workspaceId: number): Promise<{
334
+ data: UnreadThread[];
335
+ version: number;
336
+ inboxUnread?: number | null;
337
+ }>;
338
+ muteThread(args: MuteThreadArgs): Promise<Thread>;
339
+ unmuteThread(id: string): Promise<Thread>;
340
+ closeThread(args: CloseThreadArgs): Promise<Comment>;
341
+ reopenThread(args: ReopenThreadArgs): Promise<Comment>;
342
+ private addCommentWithAction;
343
+ private simple;
344
+ }
@@ -0,0 +1,123 @@
1
+ import { type User } from '../types/entities.js';
2
+ import type { UpdateUserArgs } from '../types/requests.js';
3
+ import { BaseClient } from './base-client.js';
4
+ type EmailExistsResponse = {
5
+ exists: boolean;
6
+ verified: boolean;
7
+ };
8
+ type MfaChallengeResponse = {
9
+ mfaToken: string;
10
+ };
11
+ type LoginWithGoogleArgs = {
12
+ idToken: string;
13
+ nonce: string;
14
+ timezone?: string;
15
+ lang?: string;
16
+ mfaToken?: string;
17
+ };
18
+ type RegisterArgs = {
19
+ name: string;
20
+ email: string;
21
+ password: string;
22
+ lang?: string;
23
+ acceptTerms?: boolean;
24
+ };
25
+ type LoginArgs = {
26
+ email: string;
27
+ password: string;
28
+ setSessionCookie?: boolean;
29
+ };
30
+ type MfaChallengeArgs = {
31
+ challengeId: string;
32
+ factor: string;
33
+ methodType: string;
34
+ };
35
+ /**
36
+ * Client for the `/api/v1/users/` endpoints. Authentication flows through
37
+ * Todoist-ID; `register` / `login` / `loginWithGoogle` / `loginWithToken` /
38
+ * `loginWithTodoist` are the available entry points.
39
+ */
40
+ export declare class UsersClient extends BaseClient {
41
+ /** Registers a new user via the Todoist-ID bridge. */
42
+ register(args: RegisterArgs): Promise<User>;
43
+ /** Logs in an existing user. */
44
+ login(args: LoginArgs): Promise<User>;
45
+ /**
46
+ * Logs in using a valid token (sent via Authorization header). The SDK
47
+ * client is already configured with the token, so no args are needed.
48
+ */
49
+ loginWithToken(): Promise<User>;
50
+ /**
51
+ * Exchanges the browser's Todoist web-session cookie for a Comms session.
52
+ * Only useful when running in a browser context on the shared Todoist
53
+ * registrable domain — the cookie is sent automatically by the browser.
54
+ */
55
+ loginWithTodoist(): Promise<User>;
56
+ /** Logs in (and auto-signs-up) via a Google ID token. */
57
+ loginWithGoogle(args: LoginWithGoogleArgs): Promise<User>;
58
+ /**
59
+ * Completes an MFA challenge issued by `loginWithGoogle` (returns an MFA
60
+ * token to pass back to `loginWithGoogle.mfaToken`).
61
+ */
62
+ mfaChallenge(args: MfaChallengeArgs): Promise<MfaChallengeResponse>;
63
+ /** Logs out the current user and clears the session cookie. */
64
+ logout(): Promise<void>;
65
+ /** Returns the user associated with the current access token. */
66
+ getSessionUser(): Promise<User>;
67
+ /**
68
+ * Fetches a single user. Defaults to the session user when no `id` is
69
+ * passed. Cross-workspace lookups require that the caller and the target
70
+ * share a workspace.
71
+ */
72
+ getUser(args?: {
73
+ id?: number;
74
+ workspaceId?: number;
75
+ asList?: boolean;
76
+ }): Promise<User>;
77
+ /** Looks up a user by their email address. */
78
+ getUserByEmail(email: string): Promise<User>;
79
+ /**
80
+ * Updates the logged-in user's profile. Most fields are proxied to
81
+ * Todoist (full name, password, language, timezone, etc.).
82
+ */
83
+ update(args: UpdateUserArgs): Promise<User>;
84
+ /** Updates the user's password. Requires `currentPassword`. */
85
+ updatePassword(args: {
86
+ newPassword: string;
87
+ currentPassword?: string;
88
+ }): Promise<User>;
89
+ /** Removes the user's avatar. */
90
+ removeAvatar(): Promise<User>;
91
+ /**
92
+ * Invalidates the current API token and returns the user with a fresh
93
+ * token.
94
+ */
95
+ invalidateToken(): Promise<User>;
96
+ /**
97
+ * Validates that an arbitrary token is still active. Note this is sent
98
+ * as a GET — the token is read from the query string, not the
99
+ * Authorization header.
100
+ */
101
+ validateToken(token: string): Promise<void>;
102
+ /** Marks the user as active on a workspace (presence beacon). */
103
+ heartbeat(args: {
104
+ workspaceId: number;
105
+ platform: string;
106
+ }): Promise<void>;
107
+ /** Resets the user's presence for a workspace. */
108
+ resetPresence(workspaceId: number): Promise<void>;
109
+ /** Checks whether an email address is registered (and verified). */
110
+ checkEmail(email: string): Promise<EmailExistsResponse>;
111
+ /**
112
+ * Returns the current per-channel mail unsubscribe settings for the
113
+ * caller's primary email.
114
+ */
115
+ getUnsubscribeSettings(): Promise<Record<string, boolean>>;
116
+ /** Toggles per-email-type opt-out settings. */
117
+ updateUnsubscribeSettings(settings: Record<string, boolean>): Promise<{
118
+ status: string;
119
+ }>;
120
+ private get;
121
+ private post;
122
+ }
123
+ export {};
@@ -0,0 +1,47 @@
1
+ import { type WorkspaceUser } from '../types/entities.js';
2
+ import { UserType } from '../types/enums.js';
3
+ import type { GetUserByEmailArgs, GetUserByIdArgs, GetUserInfoArgs, GetUserLocalTimeArgs, GetWorkspaceUsersArgs } from '../types/requests.js';
4
+ import { BaseClient } from './base-client.js';
5
+ /**
6
+ * Client for `/api/v1/workspace_users/`. The backend's `add` endpoint
7
+ * rejects non-empty `name` and `channelIds` — set neither.
8
+ */
9
+ export declare class WorkspaceUsersClient extends BaseClient {
10
+ /** Returns workspace user objects for the given workspace id. */
11
+ getWorkspaceUsers(args: GetWorkspaceUsersArgs): Promise<WorkspaceUser[]>;
12
+ /** Returns workspace user IDs for the given workspace id. */
13
+ getWorkspaceUserIds(workspaceId: number): Promise<number[]>;
14
+ /** Gets a user by id. */
15
+ getUserById(args: GetUserByIdArgs): Promise<WorkspaceUser>;
16
+ /** Gets a user by email. */
17
+ getUserByEmail(args: GetUserByEmailArgs): Promise<WorkspaceUser>;
18
+ /** Gets the user's info in the context of the workspace. */
19
+ getUserInfo(args: GetUserInfoArgs): Promise<Record<string, unknown>>;
20
+ /** Gets the user's local time (e.g., "2017-05-10 07:55:40"). */
21
+ getUserLocalTime(args: GetUserLocalTimeArgs): Promise<string>;
22
+ /** Adds a person to a workspace. */
23
+ addUser(args: {
24
+ workspaceId: number;
25
+ email: string;
26
+ userType?: UserType;
27
+ }): Promise<WorkspaceUser>;
28
+ /** Updates a person in a workspace. */
29
+ updateUser(args: {
30
+ workspaceId: number;
31
+ userType: UserType;
32
+ email?: string;
33
+ userId?: number;
34
+ }): Promise<WorkspaceUser>;
35
+ /** Removes a person from a workspace. */
36
+ removeUser(args: {
37
+ workspaceId: number;
38
+ email?: string;
39
+ userId?: number;
40
+ }): Promise<void>;
41
+ /** Sends a new workspace invitation to the selected user. */
42
+ resendInvite(args: {
43
+ workspaceId: number;
44
+ email: string;
45
+ userId?: number;
46
+ }): Promise<void>;
47
+ }
@@ -0,0 +1,79 @@
1
+ import { z } from 'zod';
2
+ import { Channel, Workspace } from '../types/entities.js';
3
+ import { BaseClient } from './base-client.js';
4
+ export declare const ChannelListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
5
+ id: z.ZodString;
6
+ name: z.ZodString;
7
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ creator: z.ZodNumber;
9
+ userIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
10
+ color: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
11
+ public: z.ZodBoolean;
12
+ workspaceId: z.ZodNumber;
13
+ archived: z.ZodBoolean;
14
+ created: z.ZodDate;
15
+ useDefaultRecipients: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
16
+ defaultGroups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
17
+ defaultRecipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
18
+ isFavorited: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
19
+ icon: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
20
+ version: z.ZodNumber;
21
+ filters: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
22
+ }, z.core.$strip>, z.ZodTransform<{
23
+ url: string;
24
+ id: string;
25
+ name: string;
26
+ creator: number;
27
+ public: boolean;
28
+ workspaceId: number;
29
+ archived: boolean;
30
+ created: Date;
31
+ version: number;
32
+ description?: string | null | undefined;
33
+ userIds?: number[] | null | undefined;
34
+ color?: number | null | undefined;
35
+ useDefaultRecipients?: boolean | null | undefined;
36
+ defaultGroups?: string[] | null | undefined;
37
+ defaultRecipients?: number[] | null | undefined;
38
+ isFavorited?: boolean | null | undefined;
39
+ icon?: number | null | undefined;
40
+ filters?: Record<string, string> | null | undefined;
41
+ }, {
42
+ id: string;
43
+ name: string;
44
+ creator: number;
45
+ public: boolean;
46
+ workspaceId: number;
47
+ archived: boolean;
48
+ created: Date;
49
+ version: number;
50
+ description?: string | null | undefined;
51
+ userIds?: number[] | null | undefined;
52
+ color?: number | null | undefined;
53
+ useDefaultRecipients?: boolean | null | undefined;
54
+ defaultGroups?: string[] | null | undefined;
55
+ defaultRecipients?: number[] | null | undefined;
56
+ isFavorited?: boolean | null | undefined;
57
+ icon?: number | null | undefined;
58
+ filters?: Record<string, string> | null | undefined;
59
+ }>>>;
60
+ /**
61
+ * Client for `/api/v1/workspaces/`. Workspace IDs are integers. The backend
62
+ * currently rejects any `color` other than `1` on add/update.
63
+ */
64
+ export declare class WorkspacesClient extends BaseClient {
65
+ /** Gets all the user's workspaces. */
66
+ getWorkspaces(): Promise<Workspace[]>;
67
+ /** Gets a single workspace object by id. */
68
+ getWorkspace(id: number): Promise<Workspace>;
69
+ /** Gets the user's default workspace. */
70
+ getDefaultWorkspace(): Promise<Workspace>;
71
+ /** Creates a new workspace. */
72
+ createWorkspace(name: string): Promise<Workspace>;
73
+ /** Updates an existing workspace. */
74
+ updateWorkspace(id: number, name: string): Promise<Workspace>;
75
+ /** Removes a workspace and all its data (not recoverable). */
76
+ removeWorkspace(id: number): Promise<void>;
77
+ /** Gets the public channels of a workspace. */
78
+ getPublicChannels(id: number): Promise<Channel[]>;
79
+ }
@@ -0,0 +1,59 @@
1
+ import { ChannelsClient } from './clients/channels-client.js';
2
+ import { CommentsClient } from './clients/comments-client.js';
3
+ import { ConversationMessagesClient } from './clients/conversation-messages-client.js';
4
+ import { ConversationsClient } from './clients/conversations-client.js';
5
+ import { GroupsClient } from './clients/groups-client.js';
6
+ import { InboxClient } from './clients/inbox-client.js';
7
+ import { ReactionsClient } from './clients/reactions-client.js';
8
+ import { SearchClient } from './clients/search-client.js';
9
+ import { ThreadsClient } from './clients/threads-client.js';
10
+ import { UsersClient } from './clients/users-client.js';
11
+ import { WorkspaceUsersClient } from './clients/workspace-users-client.js';
12
+ import { WorkspacesClient } from './clients/workspaces-client.js';
13
+ import type { CustomFetch } from './types/http.js';
14
+ export type CommsApiOptions = {
15
+ /** Optional custom API base URL. If not provided, defaults to Comms' standard API endpoint. */
16
+ baseUrl?: string;
17
+ /** Optional custom fetch implementation for cross-platform compatibility (e.g., Obsidian, React Native, Electron). */
18
+ customFetch?: CustomFetch;
19
+ };
20
+ /**
21
+ * The main API client for interacting with the Comms REST API.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * import { CommsApi } from '@doist/comms-sdk'
26
+ *
27
+ * const api = new CommsApi('your-api-token')
28
+ * const user = await api.users.getSessionUser()
29
+ * ```
30
+ */
31
+ export declare class CommsApi {
32
+ users: UsersClient;
33
+ workspaces: WorkspacesClient;
34
+ workspaceUsers: WorkspaceUsersClient;
35
+ channels: ChannelsClient;
36
+ threads: ThreadsClient;
37
+ groups: GroupsClient;
38
+ conversations: ConversationsClient;
39
+ comments: CommentsClient;
40
+ conversationMessages: ConversationMessagesClient;
41
+ inbox: InboxClient;
42
+ reactions: ReactionsClient;
43
+ search: SearchClient;
44
+ /**
45
+ * Creates a new Comms API client.
46
+ *
47
+ * @param authToken - Your Comms API token.
48
+ * @param options - Optional configuration options.
49
+ */
50
+ constructor(authToken: string, options?: CommsApiOptions);
51
+ /**
52
+ * Drains the SDK's process-global connection pool. CLIs and scripts
53
+ * should `await api.close()` before exit so Node's event loop empties
54
+ * immediately instead of waiting ~4s on keep-alive. Affects every
55
+ * `CommsApi` and OAuth helper in the same process — it's a
56
+ * process-shutdown gesture, not an instance teardown. Browser-safe.
57
+ */
58
+ close(): Promise<void>;
59
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Gets the base URI for Comms API requests.
3
+ *
4
+ * @param domainBase - Custom domain base URL. Defaults to Comms' API domain.
5
+ * @returns Complete base URI with trailing slash (e.g., 'https://comms.todoist.com/api/v1/')
6
+ */
7
+ export declare function getCommsBaseUri(domainBase?: string): string;
8
+ export declare const ENDPOINT_USERS = "users";
9
+ export declare const ENDPOINT_WORKSPACES = "workspaces";
10
+ export declare const ENDPOINT_CHANNELS = "channels";
11
+ export declare const ENDPOINT_THREADS = "threads";
12
+ export declare const ENDPOINT_GROUPS = "groups";
13
+ export declare const ENDPOINT_CONVERSATIONS = "conversations";
14
+ export declare const ENDPOINT_COMMENTS = "comments";
15
+ export declare const ENDPOINT_NOTIFICATIONS = "notifications";
16
+ export declare const ENDPOINT_INBOX = "inbox";
17
+ export declare const ENDPOINT_REACTIONS = "reactions";
18
+ export declare const ENDPOINT_SEARCH = "search";
19
+ export declare const ENDPOINT_CONVERSATION_MESSAGES = "conversation_messages";